Mercurial > sdl-ios-xcode
comparison src/timer/dc/SDL_systimer.c @ 1668:4da1ee79c9af SDL-1.3
more tweaking indent options
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 29 May 2006 04:04:35 +0000 |
parents | 782fd950bd46 |
children |
comparison
equal
deleted
inserted
replaced
1667:1fddae038bc8 | 1668:4da1ee79c9af |
---|---|
35 jif = ms * HZ /1000 | 35 jif = ms * HZ /1000 |
36 ms = jif * 1000/HZ | 36 ms = jif * 1000/HZ |
37 */ | 37 */ |
38 | 38 |
39 void | 39 void |
40 SDL_StartTicks (void) | 40 SDL_StartTicks(void) |
41 { | 41 { |
42 /* Set first ticks value */ | 42 /* Set first ticks value */ |
43 start = jiffies; | 43 start = jiffies; |
44 } | 44 } |
45 | 45 |
46 Uint32 | 46 Uint32 |
47 SDL_GetTicks (void) | 47 SDL_GetTicks(void) |
48 { | 48 { |
49 return ((jiffies - start) * 1000 / HZ); | 49 return ((jiffies - start) * 1000 / HZ); |
50 } | 50 } |
51 | 51 |
52 void | 52 void |
53 SDL_Delay (Uint32 ms) | 53 SDL_Delay(Uint32 ms) |
54 { | 54 { |
55 thd_sleep (ms); | 55 thd_sleep(ms); |
56 } | 56 } |
57 | 57 |
58 /* Data to handle a single periodic alarm */ | 58 /* Data to handle a single periodic alarm */ |
59 static int timer_alive = 0; | 59 static int timer_alive = 0; |
60 static SDL_Thread *timer = NULL; | 60 static SDL_Thread *timer = NULL; |
61 | 61 |
62 static int | 62 static int |
63 RunTimer (void *unused) | 63 RunTimer(void *unused) |
64 { | 64 { |
65 while (timer_alive) { | 65 while (timer_alive) { |
66 if (SDL_timer_running) { | 66 if (SDL_timer_running) { |
67 SDL_ThreadedTimerCheck (); | 67 SDL_ThreadedTimerCheck(); |
68 } | 68 } |
69 SDL_Delay (10); | 69 SDL_Delay(10); |
70 } | 70 } |
71 return (0); | 71 return (0); |
72 } | 72 } |
73 | 73 |
74 /* This is only called if the event thread is not running */ | 74 /* This is only called if the event thread is not running */ |
75 int | 75 int |
76 SDL_SYS_TimerInit (void) | 76 SDL_SYS_TimerInit(void) |
77 { | 77 { |
78 timer_alive = 1; | 78 timer_alive = 1; |
79 timer = SDL_CreateThread (RunTimer, NULL); | 79 timer = SDL_CreateThread(RunTimer, NULL); |
80 if (timer == NULL) | 80 if (timer == NULL) |
81 return (-1); | 81 return (-1); |
82 return (SDL_SetTimerThreaded (1)); | 82 return (SDL_SetTimerThreaded(1)); |
83 } | 83 } |
84 | 84 |
85 void | 85 void |
86 SDL_SYS_TimerQuit (void) | 86 SDL_SYS_TimerQuit(void) |
87 { | 87 { |
88 timer_alive = 0; | 88 timer_alive = 0; |
89 if (timer) { | 89 if (timer) { |
90 SDL_WaitThread (timer, NULL); | 90 SDL_WaitThread(timer, NULL); |
91 timer = NULL; | 91 timer = NULL; |
92 } | 92 } |
93 } | 93 } |
94 | 94 |
95 int | 95 int |
96 SDL_SYS_StartTimer (void) | 96 SDL_SYS_StartTimer(void) |
97 { | 97 { |
98 SDL_SetError ("Internal logic error: DC uses threaded timer"); | 98 SDL_SetError("Internal logic error: DC uses threaded timer"); |
99 return (-1); | 99 return (-1); |
100 } | 100 } |
101 | 101 |
102 void | 102 void |
103 SDL_SYS_StopTimer (void) | 103 SDL_SYS_StopTimer(void) |
104 { | 104 { |
105 return; | 105 return; |
106 } | 106 } |
107 | 107 |
108 #endif /* SDL_TIMER_DC */ | 108 #endif /* SDL_TIMER_DC */ |