Skip to content

Commit

Permalink
Add SDL_sem implementation using Atomics and WaitOnAddress API.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
JoelLinn committed Dec 23, 2020
1 parent 2b040ce commit d0b8295
Show file tree
Hide file tree
Showing 2 changed files with 338 additions and 22 deletions.
16 changes: 16 additions & 0 deletions include/SDL_hints.h
Expand Up @@ -1210,6 +1210,22 @@ extern "C" {
*/
#define SDL_HINT_WINDOWS_FORCE_MUTEX_CRITICAL_SECTIONS "SDL_WINDOWS_FORCE_MUTEX_CRITICAL_SECTIONS"

/**
* \brief Force SDL to use Kernel Semaphores on Windows.
* Kernel Semaphores are inter-process and require a context
* switch on every interaction. On Windows 8 and newer, the
* WaitOnAddress API is available. Using that and atomics to
* implement semaphores increases performance.
* SDL will fall back to Kernel Objects on older OS versions
* or if forced to by this hint.
*
* This variable can be set to the following values:
* "0" - Use Atomics and WaitOnAddress API when available. If not, fall back to Kernel Objects. (default)
* "1" - Force the use of Kernel Objects in all cases.
*
*/
#define SDL_HINT_WINDOWS_FORCE_SEMAPHORE_KERNEL "SDL_WINDOWS_FORCE_SEMAPHORE_KERNEL"

/**
* \brief Tell SDL which Dispmanx layer to use on a Raspberry PI
*
Expand Down

0 comments on commit d0b8295

Please sign in to comment.