mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-06-18 03:58:54 +00:00
Make sure timers are initialized before any threads start
This prevents race conditions and divide by zero if multiple threads start using the time functions simultaneously.
(cherry picked from commit b378bc5c83)
This commit is contained in:
parent
000da98663
commit
44ec2027f3
1 changed files with 5 additions and 0 deletions
|
|
@ -27,6 +27,7 @@
|
|||
#include "SDL_systhread.h"
|
||||
#include "SDL_hints.h"
|
||||
#include "../SDL_error_c.h"
|
||||
#include "../timer/SDL_timer_c.h"
|
||||
|
||||
/* The storage is local to the thread, but the IDs are global for the process */
|
||||
|
||||
|
|
@ -371,6 +372,10 @@ SDL_Thread *SDL_CreateThreadWithStackSize(int(SDLCALL *fn)(void *),
|
|||
|
||||
SDL_InitTLSData();
|
||||
|
||||
#ifndef SDL_TIMERS_DISABLED
|
||||
SDL_TicksInit();
|
||||
#endif
|
||||
|
||||
/* Allocate memory for the thread info structure */
|
||||
thread = (SDL_Thread *)SDL_calloc(1, sizeof(*thread));
|
||||
if (!thread) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue