src/thread


Log

Author Commit Date CI Message
Sylvain 16824865 2022-11-18T11:01:21 Cleanup of SDL_SetError that already return -1 value
Pierre Wendling 5ddac7e0 2022-10-10T22:04:02 PSP: Fix type mismatch warnings.
Pierre Wendling c1317175 2022-10-10T22:02:17 PSP: Fix `Wformat` warnings.
Pierre Wendling 65527537 2021-03-30T04:32:39 N3DS port (squashed) A dedicated renderer using Citro3D would likely allow for better much better graphical performances.
Anonymous Maarten 2105c7f6 2022-10-06T00:58:26 SDL_thread.c: fix unused function SDL_FreeErrBuf when building without thread support (emscripten)
Sam Lantinga 17b43b0f 2022-10-08T09:32:09 Don't try to create a semaphore for the mutex implementation if threads are disabled Fixes https://github.com/libsdl-org/SDL/issues/6344
chalonverse f317d619 2022-07-01T13:59:14 Xbox GDKX support (#5869) * Xbox GDK support (14 squashed commits) * Added basic keyboard testing * Update readme * Code review fixes * Fixed issue where controller add/removal wasn't working (since the device notification events don't work on Xbox, have to use the joystick thread to poll XInput)
Sam Lantinga b6f1c918 2022-06-27T17:44:55 Fixed Watcom C build
Sam Lantinga cbd01874 2022-06-27T16:59:50 Removed the limit on the size of the SDL error message Also added SDL_GetOriginalMemoryFunctions() Fixes https://github.com/libsdl-org/SDL/issues/5795
Sam Lantinga adc68758 2022-06-17T10:22:28 Added SDL_copyp to avoid size mismatch when copying values (thanks @1bsyl!) Closes https://github.com/libsdl-org/SDL/pull/5811
Francisco Javier Trujillo Mata 52f00833 2022-06-13T20:58:18 Add Thread drivers
Michael Fitzmayer 9b75fa01 2022-05-11T18:31:34 N-Gage port: add changes from code reviews, overall cleanup (#5618) * Add changes from code review by @ccawley2011, #5597, overall cleanup * Update N-Gage README, minor cleanup and rephrasing * Call SDL_SetMainReady() before calling SDL_main, return SDL_main instead of main
Michael Fitzmayer fbd230bb 2022-05-03T17:51:49 Add support for the Nokia N-Gage (#5597) * Add initial support for the Nokia N-Gage * N-Gage: disable clipping for the time being, issue needs to be resolved later * Move va_copy definition to SDL_internal.h * Move stdlib.h include to SDL_config_ngage.h, much cleaner this way * Remove redundant include, add HAVE_STDLIB_H * Revert "N-Gage: disable clipping for the time being, issue needs to be resolved later" This reverts commit 4f5f0fc36cc7f34fad05e45671dfa7b8dc32fd51. * N-Gage: fix clipping issue by providing proper math functions
Ryan C. Gordon d4a01bfe 2022-04-20T14:07:30 os2: SDL_DestroyMutex should ignore NULL mutexes. Every other backend does this, so this should match, now. It's possible this was harmless, but we can avoid the system call and the (likely?) debug message when it fails, though!
Ozkan Sezer e8c48981 2022-02-05T08:56:56 pthread/SDL_systhread.c: always include errno.h fixes build for several targets after commit 87b02d3 for bug #5283.
Sylvain df0d696a 2022-02-02T15:22:14 RISCOS: attempt to fix compilation ERANGE
Sylvain 87b02d37 2022-02-02T15:09:29 Linux thread name limitation: test for ERANGE (see bug #5283)
Sylvain 220a9596 2022-02-02T10:01:11 Remove testing instruction (see bug #5283)
Sylvain 9e46a512 2022-02-02T09:58:15 Fixed bug #5283 - limit thread name to 16 characters when using pthread_setname_np()
pionere 60deadba 2022-01-17T17:22:30 re-use return value of SDL_SetError/WIN_SetErrorFromHRESULT/SDL_OutOfMemory
pionere ebdd5366 2022-01-17T16:26:02 use SDL_InvalidParamError or SDL_assert instead of custom SDL_SetError
Ozkan Sezer c6c4d421 2022-01-11T11:33:02 pthread: disable SetThreadPriority for OS/2 too
Sam Lantinga 120c76c8 2022-01-03T09:40:00 Updated copyright for 2022
Francisco Javier Trujillo Mata 8ed0cc43 2021-12-15T22:30:04 Fix wrong value for thread priorities following official PSP Docs
Francisco Javier Trujillo Mata 996f30b0 2021-11-23T15:27:41 Use lightweight mutex
Sylvain 4d566e5d 2021-11-22T16:39:22 VITA, PSP: use SDL_malloc
Frank Praznik 43ddc59f 2021-11-02T16:56:14 Export SDL_LinuxSetThreadPriorityAndPolicy() function (#4877) It's marked as being a public symbol internally, however, it was missing from the header files and not visible in the shared library. This adds it to the necessary headers and to the DynAPI list to expose it for use by applications. Co-authored-by: Frank Praznik <frank.praznik@oh.rr.com>
Ivan Epifanov 512355d7 2021-09-20T20:21:05 Vita: fix thread detach. Remove leftover KillThread
Ivan Epifanov ddcd847c 2021-09-20T14:08:01 Vita: fix thread priority Add support for thread name and stack size
Cameron Gutman 5dccffd7 2021-08-23T21:16:58 Allow usage of the new Condition Variable code with Critical Sections Vista and later provide the SleepConditionVariableCS() function for this. Since SDL_syscond_srw.c doesn't require SRW locks anymore, rename it to SDL_syscond_cv.c which better reflects the implementation of condition variables rather than the implementation of mutexes. Fixes #4051.
Ozkan Sezer 77c8d111 2021-08-10T20:55:50 configuration updates for dlopen: - cmake, configure (CheckDLOPEN): --enable-sdl-dlopen is now history.. detach the dl api discovery from SDL_LOADSO_DLOPEN functionality. define HAVE_DLOPEN. also define DYNAPI_NEEDS_DLOPEN (CheckDLOPEN is called only for relevant platforms.) - update SDL_config.in and SDL_config.cmake accordingly. - SDL_dynapi.h: set SDL_DYNAMIC_API to 0 if DYNAPI_NEEDS_DLOPEN is defined, but HAVE_DLOPEN is not. - pthread/SDL_systhread.c: conditionalize dl api use to HAVE_DLOPEN - SDL_x11opengl.c, SDL_DirectFB_opengl.c, SDL_naclopengles.c: rely on HAVE_DLOPEN, not SDL_LOADSO_DLOPEN. - SDL_config_android.h, SDL_config_iphoneos.h, SDL_config_macosx.h, SDL_config_pandora.h, and SDL_config_wiz.h: define HAVE_DLOPEN. Closes: https://github.com/libsdl-org/SDL/pull/4351
Ivan Epifanov e3ea5b64 2021-04-24T10:16:21 Migrate to lightweight mutexes
Ryan C. Gordon 7d02248c 2021-04-02T14:36:53 tls: wrap reference to a mutex into an #if !SDL_THREADS_DISABLED test.
Xing Ji fb283a73 2021-03-24T22:42:47 Squashed commit of the following: commit 6b8f933589aa3925978a23e77a305a7e89c6ae4a Author: Xing Ji <jixingcn@gmail.com> Date: Wed Mar 24 22:31:29 2021 +0800 update the dynapi by `gendynapi.pl` commit ebd1790c19983b652713f40ab1e139e485e1a2b7 Author: Xing Ji <jixingcn@gmail.com> Date: Wed Mar 24 22:17:48 2021 +0800 revert the change in src/dynapi commit 734b5f85c1613070081e39238e84198128971b53 Merge: 5a56e5a8 5ac6bd54 Author: Xing Ji <jixingcn@gmail.com> Date: Wed Mar 24 22:14:40 2021 +0800 Merge remote-tracking branch 'libsdl/main' into jixingcn commit 5a56e5a8227d9cff6b497b681c618a76bec1cae1 Author: Xing Ji <jixingcn@gmail.com> Date: Mon Mar 22 23:55:10 2021 +0800 Fix #3596, can call the `SDL_TLSCleanup` to cleanup the TLS data when closing the application
Fabrice Fontaine b55b11af 2021-03-23T08:07:56 src/thread/pthread/SDL_systhread.c: drop include of SDL_platform.h Drop include of SDL_platform.h as SDL_plaform.h is already included by SDL_internal.h -> SDL_config.h -> SDL_platform.h Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Ivan Epifanov a4ddb175 2021-03-08T19:28:58 Formatting
Ivan Epifanov 189d3c16 2021-01-20T23:41:35 FIFO is default (and not defined in vitasdk, ugh)
Ivan Epifanov 87a118b6 2021-01-20T23:33:28 Use native mutexes
Ivan Epifanov 7423ae1a 2021-01-20T23:33:16 Formatting
Ivan Epifanov 7b0b1a12 2020-12-23T17:26:52 Update thread api to 2.0.14
Ivan Epifanov 2d64e37e 2020-11-02T18:09:43 Initial rebase of xerpi's port
Cameron Gutman f70e1973 2021-02-08T18:31:08 Fix waiting on condition variables with the SRW lock implmentation When SleepConditionVariableSRW() releases the SRW lock internally, it causes our SDL_mutex_srw state to become inconsistent. The lock is unowned yet inside, the owner is still the sleeping thread and more importantly the owner count is still 1. The next time someone acquires the lock, they will bump the owner count from 1 to 2. At that point, the lock is hosed. From the internal lock state, it looks to us like that owner has acquired the lock recursively, even though they have not. When they call SDL_UnlockMutex(), it will see the owner count > 0 and not call ReleaseSRWLockExclusive(). Now when someone calls SDL_CondSignal(), SleepConditionVariableSRW() will start the wakeup process by attempting to re-acquire the SRW lock. This will deadlock because the lock was never released after the other thread had used it. The thread waiting on the condition variable will never be able to wake up, even if the SDL_CondWaitTimeout() function is used and the timeout expires.
Ozkan Sezer 265a1cc9 2021-01-05T15:50:02 use WIN_StringToUTF8W instead of WIN_StringToUTF8 where needed (#2) cf. bug #5435. - SDL_wasapi_win32.c (GetWasapiDeviceName): pwszVal is WCHAR* - windows/SDL_sysfilesystem.c (SDL_GetBasePath, SDL_GetPrefPath) - windows/SDL_sysurl.c (SDL_SYS_OpenURL): wurl is WCHAR* - SDL_windowssensor.c (ConnectSensor): bstr_name is WCHAR* - windows/SDL_systhread.c (SDL_SYS_SetupThread): strw is WCHAR*
Ozkan Sezer 01a2f276 2021-01-04T01:23:50 consistently use TEXT() macro with LoadLibrary() and GetModuleHandle() cf. bug #5435.
Sam Lantinga 9130f7c3 2021-01-02T10:25:38 Updated copyright for 2021
Joel Linn 8fc0baad 2020-12-28T11:43:11 Add SDL_cond implementation using Windows Condition Variables Is automatically used when the SRW SDL_mutex implementation is active. Otherwise falls back to the generic implementation. v2: - Rebase onto master fa3ea1051a4b
Joel Linn 2443e51e 2020-12-28T11:42:49 Add optional suffix `_generic` to generic SDL_cond impl Allows for runtime selectable implementation
Joel Linn e7c47941 2020-12-25T17:10:02 Disable WaitOnAddress SDL_sem implementation on Windows Phone Apps that use the required APIs do not pass certification.
Joel Linn d6afc1c6 2020-12-25T04:00:20 thread/windows: Statically link synchronization APIs on WINRT GetModuleHandleW is not available on those platforms --- .../WinPhone81_VS2013/SDL-WinPhone81.vcxproj | 8 ++++---- VisualC-WinRT/WinRT81_VS2013/SDL-WinRT81.vcxproj | 12 ++++++------ src/thread/windows/SDL_sysmutex.c | 12 ++++++++++++ src/thread/windows/SDL_syssem.c | 11 +++++++++++ 4 files changed, 33 insertions(+), 10 deletions(-)
Joel Linn d0b8295c 2020-12-23T13:36:46 Add SDL_sem implementation using Atomics and WaitOnAddress API. Keep Semaphore Kernel Object impl for Windows 7 and older - choose at runtime v2: - Fix mixed int/LONG types - Reorder definitions - Add missing include v3: - Use `GetModuleHandle()` to load the API Set
Joel Linn 548cb908 2020-12-23T13:33:36 Add SDL_mutex implementation using Windows Slim Reader/Writer Locks Keep Critical Section impl for Windows XP/Vista - choose at runtime v2: - Add SRW definitions as suggested by Ozkan Sezer Allows building against older platform headers. - Rename "hidden" function parameter `mutex_` to `_mutex` v3: - Use GetModuleHandle instead of LoadLibrary - Fix typo in comment
Ozkan Sezer a19c008a 2020-12-22T17:10:02 use GetModuleHandleW() to retrieve kernel32.dll handle (bug #5390.) SDL_systhread.c and SDL_syslocale.c used to call LoadLibrary() without calling FreeLibrary() later. GetModuleHandleW() should always succeed because GetModuleHandleW() itself is imported from kernel32.dll and we don't need to bother releasing it.
Sam Lantinga cb361896 2020-12-09T07:16:22 Fixed bug 5235 - All internal sources should include SDL_assert.h Ryan C. Gordon We should really stick this in SDL_internal.h or something so it's always available.
Sam Lantinga 0500c044 2020-11-12T07:53:05 Fix SDL_HINT_THREAD_FORCE_REALTIME_TIME_CRITICAL also applying to HIGH priorities As the name suggests, the hint should only apply to SDL_THREAD_PRIORITY_TIME_CRITICAL The resulting priorities for my current distro result in these values: | High | Time Critical Hint |--------------|----------------- 0 | P=10 N=-10 | P=5 N=-15 1 | P=10 N=-10 | P=-21 N=0
Sam Lantinga 07eae7d6 2020-11-11T08:47:18 Fix process randomly getting killed when SDL_THREAD_PRIORITY_HIGH/TIME_CRITICAL is set When we request realtime priority from rtkit, we have a rttime limit. If we exceed that limit, the kernel will send SIGKILL to the process to terminate it. This isn't something that most high priority processes will want, only processes that selectively opt into SCHED_RR/FIFO through SDL_HINT_THREAD_PRIORITY_POLICY should be subject to this level of scrutiny. This change: * Switches non-apple posix OSs to use SCHED_OTHER instead of SCHED_RR for SDL_THREAD_PRIORITY_HIGH/SDL_THREAD_PRIORITY_TIME_CRITICAL. * Fixes using a hardcoded RLIMIT_RTTIME, instead queries it from rtkit * Only sets RLIMIT_RTTIME for MakeRealtime rtkit requests * Adds a note regarding the possible SIGKILL with SDL_HINT_THREAD_PRIORITY_POLICY * Introduces SDL_HINT_THREAD_FORCE_REALTIME_TIME_CRITICAL to allow apps to acquire realtime scheduling policies on Linux
Ozkan Sezer a90f0400 2020-10-15T21:37:30 os2: a _lot_ of coding style cleanup, sot that they match the SDL style. also renamed the 'debug' macro to debug_os2: the former was dangerously a common name. the binary (dll) output is precisely the same as before.
Ozkan Sezer d2723875 2020-10-14T23:01:06 os2: integrate the port into main tree.
Ozkan Sezer 1d9cf23e 2020-10-14T23:01:05 os2: updated copyright dates for 2020. header guard fixes.
Ozkan Sezer 54ced668 2020-10-14T23:01:04 port from 2.0.12 to 2.0.13 / current SDL-hg repository. - video: VideoBootStrap->available() is gone. - thread: all important SDL_CreateThread internal data now put into struct SDL_Thread: changes to SDL_SYS_CreateThread().
Ozkan Sezer 222f0268 2020-10-14T23:01:03 os/2: port from SDL2-2.0.4 to SDL2-2.0.5: changes to SDL_os2audio.c, SDL_os2video.c, os2/SDL_systhread.c in order to accomodate SDL2-2.0.5 changes. - audio: WaitDone() is gone, CloseDevice() interface changes. - events / video: DropFile() changes: SDL_DROPBEGIN and SDL_DROPCOMPLETE events, window IDs for drops. - thread: struct SDL_Thread->stacksize
Ozkan Sezer f9af19f5 2020-10-14T23:01:02 os2: updates to SDL_systhread.c: removed lots of garbage. added SDL_PASSED_BEGINTHREAD_ENDTHREAD guard, because the code requires it.
Ozkan Sezer 74cfb81d 2020-10-14T23:01:00 os2: add port files for SDL2-2.0.4 from Andrey Vasilkin only geniconv/iconv.h (was from LGPL libiconv) is replaced with a generic minimal iconv.h based on public knowledge.
Sam Lantinga 0713c579 2020-05-26T13:19:44 More Linux fixes.
Sam Lantinga c7d1dab1 2020-05-26T13:19:41 Rename Linux-only variable.
Sam Lantinga b820a81f 2020-05-26T13:19:35 Include SDL_hints.h.
Sam Lantinga de866e66 2020-05-26T13:19:29 Include SDL_hint.h.
Sam Lantinga abd58418 2020-05-26T13:19:19 Make some changes to SDL_SetThreadPriority to try and have SDL transparently handle more of the work. 1. Comment that SDL_SetThreadPriority will make any necessary system changes when applying priority. 2. Add a hint to override SDL's default behavior for scheduler policy. 3. Modify the pthreads SDL_SetThreadPriority so that instead of just using the current thread scheduler policy it will change it to a policy that should work best for the requested priority. 4. Add hint checks in SDL_SetThreadPriority so that #3 can be overridden if desired. 5. Modify the Linux SDL_SetThreadPriority so that in the case that policy, either by SDL defaults or from the hint, is a realtime policy it uses the realtime rtkit API. 6. Prior to calling rtkit on Linux make the necessary thread state changes that rtkit requires. Currently this is done every time as it isn't expected that SDL_SetThreadPriority will be called repeatedly for a thread.
Sam Lantinga b6afbe63 2020-04-07T09:38:57 Added SDL_log.h to SDL_internal.h so logging is available everywhere
Sam Lantinga 378a5cfb 2020-04-01T16:39:05 Updated thread priorities for Apple operating systems
Ryan C. Gordon 46bb47cf 2020-03-26T22:14:59 thread: Put all important SDL_CreateThread internal data into SDL_Thread. This avoids the need to malloc something extra, use a semaphore, etc, and fixes Emscripten with pthreads support, which might not spin up a web worker until after SDL_CreateThread returns and thus can't wait on a semaphore at this point in any case. Fixes Bugzilla #5064.
Sam Lantinga bd5da73a 2020-03-01T12:50:42 Fixed bug 4992 - UWP/WinRT does not set thread priority when using SDL_SetThreadPriority Ethan Lee Attached is a diff that I used to get SetThreadPriority working locally. I still have no idea what the minimum SDK version is since Microsoft never documented it, but it's worth pointing out that they're much more aggressive about using the latest VS and UWP SDK anyway (for example, an updated Xbox is no longer compatible with VS2017, and updates are required to have a network connection of any kind).
Cameron Cawley 8f1a916a 2020-02-13T20:50:47 Add basic support for compiling on RISC OS
Sam Lantinga a8780c6a 2020-01-16T20:49:25 Updated copyright date for 2020
Sylvain Becker 81cdd500 2019-10-30T17:35:40 Remove redundant 'SDL_GetErrBuf' declaration
Sylvain Becker b458d7a2 2019-10-30T15:13:55 Readability: remove redundant cast to the same type
Sam Lantinga 01c924fa 2019-03-19T17:20:54 Hopefully fixed the mingw32 build
Sam Lantinga deb7d08c 2019-03-19T17:05:22 Fixed Visual Studio build
Sam Lantinga ac23d78f 2019-03-19T16:53:55 Didn't need to add SDL_windows.h include, that was already included
Sam Lantinga b2e76d86 2019-03-19T16:52:09 Fixed Windows RT build
Sam Lantinga 5e13087b 2019-01-04T22:01:14 Updated copyright for 2019
Sylvain Becker 252dc85e 2018-12-06T09:22:00 Fix warnings detected on Android build
Ryan C. Gordon 1689e9f9 2018-12-05T16:51:22 linux: Move SDL_LinuxSetThreadPriority() elsewhere to fix build. Fixes Bugzilla #4393.
Sylvain Becker 6259a726 2018-12-05T16:13:12 Warnings: fix a documentation warning and missing prototypes
Ryan C. Gordon c4bc59a5 2018-12-01T10:36:26 Patched to compile on Linux with --disable-threads. Fixes Bugzilla #4393.
Ryan C. Gordon acb05f50 2018-10-11T16:40:01 thread: make SDL_CreateThreadWithStackSize() a public API.
Ryan C. Gordon 0ad4b0b6 2018-05-21T12:00:21 thread: fixed compiler warnings on non-Linux systems that use pthread. (static function rtkit_setpriority was unused, moved it in with rest of __LINUX__ section.)
Sam Lantinga 8f780e76 2018-04-23T22:17:56 Fixed build
Sam Lantinga f521b22e 2018-04-23T22:07:56 Added SDL_THREAD_PRIORITY_TIME_CRITICAL
Sam Lantinga a1b8fa60 2018-04-23T21:50:03 TryLockMutex: Fix error handling for TryLockMutex Christian Herzig pthread_mutex_trylock() and by the way, pthread_mutex_lock() do not set errno. Pthread-methods directly return error code as int. See related man-pages for details.
Sam Lantinga b5d231ee 2018-04-23T19:20:12 Handle NULL return from SDL_DBus_GetContext()
Sam Lantinga 43231256 2018-04-23T19:18:52 Added SDL_LinuxSetThreadPriority() to directly set the priority of a Linux thread (tid) This function tries using RealtimeKit connecting over DBUS as needed.
Sam Lantinga 816a6e68 2018-04-23T17:10:36 Added support for adjusting thread priorities using Linux RealtimeKit Michael Sartain This is a quick pass at adding Linux RealtimeKit thread priority support to SDL. It allows me to bump the thread priority to high without root privileges or setting any caps, etc. rtkit readme here: http://git.0pointer.net/rtkit.git/tree/README
Sam Lantinga f9f45d0b 2018-02-25T19:51:34 Fixed bug 4097 - Segmentation fault by SDL_CreateThreadWithStackSize Dongsun Kim Normal case 1. [thread 1] SDL_CreateThreadWithStackSize calls SDL_SYS_CreateThread. 2. [thread 1] If successful, it calls SDL_SemWait. 3. [thread 2] SDL_RunThread calls SDL_SYS_SetupThread, SDL_ThreadID, SDL_SemPost. 4. [thread 1] SDL_CreateThreadWithStackSize calls SDL_DestroySemaphore, SDL_free. Crash case (Segmentation fault) 1. [thread 1] SDL_CreateThreadWithStackSize calls SDL_SYS_CreateThread. 2. [thread 1] If successful, it calls SDL_SemWait. --> Error return due to SIGNAL(SYSTEM or Real Time) at sem_wait(pthread). 3. [thread 1] SDL_CreateThreadWithStackSize calls SDL_DestroySemaphore, SDL_free. 4. [thread 2] SDL_RunThread calls SDL_SYS_SetupThread, SDL_ThreadID, SDL_SemPost. --> Segmentation fault at strlen or sem_post.
Ryan C. Gordon 75a58303 2018-02-17T23:57:57 pthread: fix error code checks (thanks, Andreas!). Most pthread functions return 0 on success and non-zero on error, but those errors might be positive or negative, so checking for return values in the Unix style, where errors are less than zero, is a bug. Fixes Bugzilla #4039.
sezero 40b27fd5 2018-02-12T17:00:00 revert the recent typecast assignment changes (see bug #4079) also change the void* typedefs for the two vulkan function pointers added in vulkan_internal.h into generic function pointer typedefs.
Sam Lantinga 90e72bf4 2018-01-30T18:08:34 Fixed ISO C99 compatibility SDL now builds with gcc 7.2 with the following command line options: -Wall -pedantic-errors -Wno-deprecated-declarations -Wno-overlength-strings --std=c99
Sam Lantinga e3cc5b2c 2018-01-03T10:03:25 Updated copyright for 2018
Ryan C. Gordon 140cc460 2017-12-31T03:35:41 windows: Use WaitForSingleObjectEx() always This is available since Windows XP, so it's safe to use always, not just in a WinRT ifdef.
Sam Lantinga 0d011ec6 2017-08-28T00:22:23 Renaming of guard header names to quiet -Wreserved-id-macro
Sam Lantinga de91b124 2017-08-14T06:28:21 Fixed bug 3745 - specify SDLCALL as the calling convention for API callbacks Patches contributed by Ozkan Sezer