| 204 | } |
| 205 | |
| 206 | int |
| 207 | SDL_TimerInit(void) |
| 208 | { |
| 209 | SDL_TimerData *data = &SDL_timer_data; |
| 210 | |
| 211 | if (!SDL_AtomicGet(&data->active)) { |
| 212 | const char *name = "SDLTimer"; |
| 213 | data->timermap_lock = SDL_CreateMutex(); |
| 214 | if (!data->timermap_lock) { |
| 215 | return -1; |
| 216 | } |
| 217 | |
| 218 | data->sem = SDL_CreateSemaphore(0); |
| 219 | if (!data->sem) { |
| 220 | SDL_DestroyMutex(data->timermap_lock); |
| 221 | return -1; |
| 222 | } |
| 223 | |
| 224 | SDL_AtomicSet(&data->active, 1); |
| 225 | |
| 226 | /* Timer threads use a callback into the app, so we can't set a limited stack size here. */ |
| 227 | data->thread = SDL_CreateThreadInternal(SDL_TimerThread, name, 0, data); |
| 228 | if (!data->thread) { |
| 229 | SDL_TimerQuit(); |
| 230 | return -1; |
| 231 | } |
| 232 | |
| 233 | SDL_AtomicSet(&data->nextID, 1); |
| 234 | } |
| 235 | return 0; |
| 236 | } |
| 237 | |
| 238 | void |
| 239 | SDL_TimerQuit(void) |
no test coverage detected