SDL 2.0
SDL_timer_c.h File Reference
#include "../SDL_internal.h"
#include "SDL_timer.h"
+ Include dependency graph for SDL_timer_c.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ROUND_RESOLUTION(X)    (((X+TIMER_RESOLUTION-1)/TIMER_RESOLUTION)*TIMER_RESOLUTION)
 

Functions

void SDL_TicksInit (void)
 
void SDL_TicksQuit (void)
 
int SDL_TimerInit (void)
 
void SDL_TimerQuit (void)
 

Macro Definition Documentation

◆ ROUND_RESOLUTION

#define ROUND_RESOLUTION (   X)     (((X+TIMER_RESOLUTION-1)/TIMER_RESOLUTION)*TIMER_RESOLUTION)

Definition at line 30 of file SDL_timer_c.h.

Function Documentation

◆ SDL_TicksInit()

void SDL_TicksInit ( void  )

Referenced by SDL_InitSubSystem(), and SDL_VideoInit().

◆ SDL_TicksQuit()

void SDL_TicksQuit ( void  )

Referenced by SDL_Quit().

◆ SDL_TimerInit()

int SDL_TimerInit ( void  )

Definition at line 207 of file SDL_timer.c.

208{
210
211 if (!SDL_AtomicGet(&data->active)) {
212 const char *name = "SDLTimer";
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. */
228 if (!data->thread) {
230 return -1;
231 }
232
233 SDL_AtomicSet(&data->nextID, 1);
234 }
235 return 0;
236}
#define SDL_AtomicSet
#define SDL_CreateMutex
#define SDL_CreateSemaphore
#define SDL_AtomicGet
#define SDL_DestroyMutex
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1974
GLuint const GLchar * name
SDL_Thread * SDL_CreateThreadInternal(int(*fn)(void *), const char *name, const size_t stacksize, void *data)
Definition: SDL_thread.c:429
static SDL_TimerData SDL_timer_data
Definition: SDL_timer.c:71
void SDL_TimerQuit(void)
Definition: SDL_timer.c:239
static int SDL_TimerThread(void *_data)
Definition: SDL_timer.c:101
SDL_mutex * timermap_lock
Definition: SDL_timer.c:55

References SDL_AtomicGet, SDL_AtomicSet, SDL_CreateMutex, SDL_CreateSemaphore, SDL_CreateThreadInternal(), SDL_DestroyMutex, SDL_timer_data, SDL_TimerQuit(), SDL_TimerThread(), and SDL_TimerData::timermap_lock.

Referenced by SDL_AddTimer(), and SDL_InitSubSystem().

◆ SDL_TimerQuit()

void SDL_TimerQuit ( void  )

Definition at line 239 of file SDL_timer.c.

240{
242 SDL_Timer *timer;
243 SDL_TimerMap *entry;
244
245 if (SDL_AtomicCAS(&data->active, 1, 0)) { /* active? Move to inactive. */
246 /* Shutdown the timer thread */
247 if (data->thread) {
248 SDL_SemPost(data->sem);
249 SDL_WaitThread(data->thread, NULL);
250 data->thread = NULL;
251 }
252
254 data->sem = NULL;
255
256 /* Clean up the timer entries */
257 while (data->timers) {
258 timer = data->timers;
259 data->timers = timer->next;
260 SDL_free(timer);
261 }
262 while (data->freelist) {
263 timer = data->freelist;
264 data->freelist = timer->next;
265 SDL_free(timer);
266 }
267 while (data->timermap) {
268 entry = data->timermap;
269 data->timermap = entry->next;
270 SDL_free(entry);
271 }
272
273 SDL_DestroyMutex(data->timermap_lock);
274 data->timermap_lock = NULL;
275 }
276}
#define SDL_AtomicCAS
#define SDL_SemPost
#define SDL_DestroySemaphore
#define SDL_free
#define SDL_WaitThread
#define NULL
Definition: begin_code.h:167
struct _SDL_Timer * next
Definition: SDL_timer.c:39
struct _SDL_TimerMap * next
Definition: SDL_timer.c:46

References SDL_Timer::next, SDL_TimerMap::next, NULL, SDL_AtomicCAS, SDL_DestroyMutex, SDL_DestroySemaphore, SDL_free, SDL_SemPost, SDL_timer_data, and SDL_WaitThread.

Referenced by SDL_QuitSubSystem(), and SDL_TimerInit().