mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-01 23:48:29 +00:00
@@ -60,18 +60,11 @@ static SDL_sem_impl_t SDL_sem_impl_active = { 0 };
|
||||
// APIs not available on WinPhone 8.1
|
||||
// https://www.microsoft.com/en-us/download/details.aspx?id=47328
|
||||
|
||||
#if !SDL_WINAPI_FAMILY_PHONE
|
||||
#ifdef SDL_PLATFORM_WINRT
|
||||
// Functions are guaranteed to be available
|
||||
#define pWaitOnAddress WaitOnAddress
|
||||
#define pWakeByAddressSingle WakeByAddressSingle
|
||||
#else
|
||||
typedef BOOL(WINAPI *pfnWaitOnAddress)(volatile VOID *, PVOID, SIZE_T, DWORD);
|
||||
typedef VOID(WINAPI *pfnWakeByAddressSingle)(PVOID);
|
||||
|
||||
static pfnWaitOnAddress pWaitOnAddress = NULL;
|
||||
static pfnWakeByAddressSingle pWakeByAddressSingle = NULL;
|
||||
#endif
|
||||
|
||||
typedef struct SDL_semaphore_atom
|
||||
{
|
||||
@@ -196,7 +189,6 @@ static const SDL_sem_impl_t SDL_sem_impl_atom = {
|
||||
&SDL_GetSemaphoreValue_atom,
|
||||
&SDL_SignalSemaphore_atom,
|
||||
};
|
||||
#endif // !SDL_WINAPI_FAMILY_PHONE
|
||||
|
||||
/**
|
||||
* Fallback Semaphore implementation using Kernel Semaphores
|
||||
@@ -217,12 +209,7 @@ static SDL_Semaphore *SDL_CreateSemaphore_kern(Uint32 initial_value)
|
||||
sem = (SDL_sem_kern *)SDL_malloc(sizeof(*sem));
|
||||
if (sem) {
|
||||
// Create the semaphore, with max value 32K
|
||||
// !!! FIXME: CreateSemaphoreEx is available in Vista and later, so if XP support is dropped, we can lose this #ifdef.
|
||||
#ifdef SDL_PLATFORM_WINRT
|
||||
sem->id = CreateSemaphoreEx(NULL, initial_value, 32 * 1024, NULL, 0, SEMAPHORE_ALL_ACCESS);
|
||||
#else
|
||||
sem->id = CreateSemaphore(NULL, initial_value, 32 * 1024, NULL);
|
||||
#endif
|
||||
sem->count = initial_value;
|
||||
if (!sem->id) {
|
||||
SDL_SetError("Couldn't create semaphore");
|
||||
@@ -316,12 +303,7 @@ SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value)
|
||||
// Default to fallback implementation
|
||||
const SDL_sem_impl_t *impl = &SDL_sem_impl_kern;
|
||||
|
||||
#if !SDL_WINAPI_FAMILY_PHONE
|
||||
if (!SDL_GetHintBoolean(SDL_HINT_WINDOWS_FORCE_SEMAPHORE_KERNEL, false)) {
|
||||
#ifdef SDL_PLATFORM_WINRT
|
||||
// Link statically on this platform
|
||||
impl = &SDL_sem_impl_atom;
|
||||
#else
|
||||
/* We already statically link to features from this Api
|
||||
* Set (e.g. WaitForSingleObject). Dynamically loading
|
||||
* API Sets is not explicitly documented but according to
|
||||
@@ -338,9 +320,7 @@ SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value)
|
||||
impl = &SDL_sem_impl_atom;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
// Copy instead of using pointer to save one level of indirection
|
||||
SDL_copyp(&SDL_sem_impl_active, impl);
|
||||
|
Reference in New Issue
Block a user