Removed SDL_ATOMIC_DISABLED
It turns out that because we redefine SDL functions internally, it is safe to call SDL mutex functions while initializing the jump tablemain
parent
6e1b11368d
commit
31f34e9504
|
@ -210,7 +210,6 @@ if(EMSCRIPTEN)
|
||||||
|
|
||||||
set(SDL_ASSEMBLY_DEFAULT OFF)
|
set(SDL_ASSEMBLY_DEFAULT OFF)
|
||||||
set(SDL_SHARED_AVAILABLE OFF)
|
set(SDL_SHARED_AVAILABLE OFF)
|
||||||
set(SDL_ATOMIC_DEFAULT OFF)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(VITA OR PSP OR PS2 OR N3DS OR RISCOS)
|
if(VITA OR PSP OR PS2 OR N3DS OR RISCOS)
|
||||||
|
@ -238,7 +237,6 @@ if(SDL_SHARED_DEFAULT AND SDL_STATIC_DEFAULT AND SDL_SHARED_AVAILABLE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(SDL_SUBSYSTEMS
|
set(SDL_SUBSYSTEMS
|
||||||
Atomic
|
|
||||||
Audio
|
Audio
|
||||||
Video
|
Video
|
||||||
Render
|
Render
|
||||||
|
|
|
@ -256,7 +256,6 @@
|
||||||
#cmakedefine SDL_VIDEO_CAPTURE
|
#cmakedefine SDL_VIDEO_CAPTURE
|
||||||
|
|
||||||
/* Allow disabling of core subsystems */
|
/* Allow disabling of core subsystems */
|
||||||
#cmakedefine SDL_ATOMIC_DISABLED @SDL_ATOMIC_DISABLED@
|
|
||||||
#cmakedefine SDL_AUDIO_DISABLED @SDL_AUDIO_DISABLED@
|
#cmakedefine SDL_AUDIO_DISABLED @SDL_AUDIO_DISABLED@
|
||||||
#cmakedefine SDL_FILE_DISABLED @SDL_FILE_DISABLED@
|
#cmakedefine SDL_FILE_DISABLED @SDL_FILE_DISABLED@
|
||||||
#cmakedefine SDL_JOYSTICK_DISABLED @SDL_JOYSTICK_DISABLED@
|
#cmakedefine SDL_JOYSTICK_DISABLED @SDL_JOYSTICK_DISABLED@
|
||||||
|
|
|
@ -59,25 +59,7 @@ extern __inline int _SDL_xchg_watcom(volatile int *a, int v);
|
||||||
/* This function is where all the magic happens... */
|
/* This function is where all the magic happens... */
|
||||||
SDL_bool SDL_AtomicTryLock(SDL_SpinLock *lock)
|
SDL_bool SDL_AtomicTryLock(SDL_SpinLock *lock)
|
||||||
{
|
{
|
||||||
#ifdef SDL_ATOMIC_DISABLED
|
#if defined(HAVE_GCC_ATOMICS) || defined(HAVE_GCC_SYNC_LOCK_TEST_AND_SET)
|
||||||
/* Terrible terrible damage */
|
|
||||||
static SDL_Mutex *_spinlock_mutex;
|
|
||||||
|
|
||||||
if (!_spinlock_mutex) {
|
|
||||||
/* Race condition on first lock... */
|
|
||||||
_spinlock_mutex = SDL_CreateMutex();
|
|
||||||
}
|
|
||||||
SDL_LockMutex(_spinlock_mutex);
|
|
||||||
if (*lock == 0) {
|
|
||||||
*lock = 1;
|
|
||||||
SDL_UnlockMutex(_spinlock_mutex);
|
|
||||||
return SDL_TRUE;
|
|
||||||
} else {
|
|
||||||
SDL_UnlockMutex(_spinlock_mutex);
|
|
||||||
return SDL_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(HAVE_GCC_ATOMICS) || defined(HAVE_GCC_SYNC_LOCK_TEST_AND_SET)
|
|
||||||
return __sync_lock_test_and_set(lock, 1) == 0;
|
return __sync_lock_test_and_set(lock, 1) == 0;
|
||||||
|
|
||||||
#elif defined(_MSC_VER) && (defined(_M_ARM) || defined(_M_ARM64))
|
#elif defined(_MSC_VER) && (defined(_M_ARM) || defined(_M_ARM64))
|
||||||
|
@ -160,8 +142,22 @@ SDL_bool SDL_AtomicTryLock(SDL_SpinLock *lock)
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
#else
|
#else
|
||||||
#error Please implement for your platform.
|
/* Terrible terrible damage */
|
||||||
return SDL_FALSE;
|
static SDL_Mutex *_spinlock_mutex;
|
||||||
|
|
||||||
|
if (!_spinlock_mutex) {
|
||||||
|
/* Race condition on first lock... */
|
||||||
|
_spinlock_mutex = SDL_CreateMutex();
|
||||||
|
}
|
||||||
|
SDL_LockMutex(_spinlock_mutex);
|
||||||
|
if (*lock == 0) {
|
||||||
|
*lock = 1;
|
||||||
|
SDL_UnlockMutex(_spinlock_mutex);
|
||||||
|
return SDL_TRUE;
|
||||||
|
} else {
|
||||||
|
SDL_UnlockMutex(_spinlock_mutex);
|
||||||
|
return SDL_FALSE;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -535,22 +535,15 @@ static void SDL_InitDynamicAPI(void)
|
||||||
*/
|
*/
|
||||||
static SDL_bool already_initialized = SDL_FALSE;
|
static SDL_bool already_initialized = SDL_FALSE;
|
||||||
|
|
||||||
/* SDL_AtomicLock calls SDL mutex functions to emulate if
|
|
||||||
SDL_ATOMIC_DISABLED, which we can't do here, so in such a
|
|
||||||
configuration, you're on your own. */
|
|
||||||
#ifndef SDL_ATOMIC_DISABLED
|
|
||||||
static SDL_SpinLock lock = 0;
|
static SDL_SpinLock lock = 0;
|
||||||
SDL_AtomicLock_REAL(&lock);
|
SDL_AtomicLock_REAL(&lock);
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!already_initialized) {
|
if (!already_initialized) {
|
||||||
SDL_InitDynamicAPILocked();
|
SDL_InitDynamicAPILocked();
|
||||||
already_initialized = SDL_TRUE;
|
already_initialized = SDL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef SDL_ATOMIC_DISABLED
|
|
||||||
SDL_AtomicUnlock_REAL(&lock);
|
SDL_AtomicUnlock_REAL(&lock);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#else /* SDL_DYNAMIC_API */
|
#else /* SDL_DYNAMIC_API */
|
||||||
|
|
Loading…
Reference in New Issue