Removed the need for SDL_CreateTLS()

This eliminates the tap dancing needed for allocating TLS slots, we'll automatically allocate them as needed, in a thread-safe way.
This commit is contained in:
Sam Lantinga
2024-07-16 09:43:07 -07:00
parent 1592452cad
commit ec3bb4c029
12 changed files with 75 additions and 112 deletions

View File

@@ -36,14 +36,11 @@ HANDLE SDL_GetWaitableTimer()
static SDL_TLSID TLS_timer_handle;
HANDLE timer;
if (!TLS_timer_handle) {
TLS_timer_handle = SDL_CreateTLS();
}
timer = SDL_GetTLS(TLS_timer_handle);
timer = SDL_GetTLS(&TLS_timer_handle);
if (!timer) {
timer = CreateWaitableTimerExW(NULL, NULL, CREATE_WAITABLE_TIMER_HIGH_RESOLUTION, TIMER_ALL_ACCESS);
if (timer) {
SDL_SetTLS(TLS_timer_handle, timer, SDL_CleanupWaitableTimer);
SDL_SetTLS(&TLS_timer_handle, timer, SDL_CleanupWaitableTimer);
}
}
return timer;