Mercurial > sdl-ios-xcode
annotate src/timer/beos/SDL_systimer.c @ 1361:19418e4422cb
New configure-based build system. Still work in progress, but much improved
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Thu, 16 Feb 2006 10:11:48 +0000 |
parents | c71e05b4dc2e |
children | d910939febfa |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
0 | 4 |
5 This library is free software; you can redistribute it and/or | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
0 | 7 License as published by the Free Software Foundation; either |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
0 | 9 |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
13 Lesser General Public License for more details. |
0 | 14 |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
0 | 18 |
19 Sam Lantinga | |
252
e8157fcb3114
Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
20 slouken@libsdl.org |
0 | 21 */ |
22 | |
23 #include <be/kernel/OS.h> | |
24 | |
25 #include "SDL_thread.h" | |
26 #include "SDL_timer.h" | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
27 #include "../SDL_timer_c.h" |
0 | 28 |
29 static bigtime_t start; | |
30 | |
31 void SDL_StartTicks(void) | |
32 { | |
33 /* Set first ticks value */ | |
34 start = system_time(); | |
35 } | |
36 | |
37 Uint32 SDL_GetTicks(void) | |
38 { | |
39 return((system_time()-start)/1000); | |
40 } | |
41 | |
42 void SDL_Delay(Uint32 ms) | |
43 { | |
44 snooze(ms*1000); | |
45 } | |
46 | |
47 /* Data to handle a single periodic alarm */ | |
48 static int timer_alive = 0; | |
49 static SDL_Thread *timer = NULL; | |
50 | |
51 static int RunTimer(void *unused) | |
52 { | |
53 while ( timer_alive ) { | |
54 if ( SDL_timer_running ) { | |
55 SDL_ThreadedTimerCheck(); | |
56 } | |
57 SDL_Delay(10); | |
58 } | |
59 return(0); | |
60 } | |
61 | |
62 /* This is only called if the event thread is not running */ | |
63 int SDL_SYS_TimerInit(void) | |
64 { | |
65 timer_alive = 1; | |
66 timer = SDL_CreateThread(RunTimer, NULL); | |
67 if ( timer == NULL ) | |
68 return(-1); | |
69 return(SDL_SetTimerThreaded(1)); | |
70 } | |
71 | |
72 void SDL_SYS_TimerQuit(void) | |
73 { | |
74 timer_alive = 0; | |
75 if ( timer ) { | |
76 SDL_WaitThread(timer, NULL); | |
77 timer = NULL; | |
78 } | |
79 } | |
80 | |
81 int SDL_SYS_StartTimer(void) | |
82 { | |
83 SDL_SetError("Internal logic error: BeOS uses threaded timer"); | |
84 return(-1); | |
85 } | |
86 | |
87 void SDL_SYS_StopTimer(void) | |
88 { | |
89 return; | |
90 } |