1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/timer/dummy/SDL_systimer.c Thu Feb 16 10:11:48 2006 +0000
1.3 @@ -0,0 +1,83 @@
1.4 +/*
1.5 + SDL - Simple DirectMedia Layer
1.6 + Copyright (C) 1997-2006 Sam Lantinga
1.7 +
1.8 + This library is free software; you can redistribute it and/or
1.9 + modify it under the terms of the GNU Lesser General Public
1.10 + License as published by the Free Software Foundation; either
1.11 + version 2.1 of the License, or (at your option) any later version.
1.12 +
1.13 + This library is distributed in the hope that it will be useful,
1.14 + but WITHOUT ANY WARRANTY; without even the implied warranty of
1.15 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1.16 + Lesser General Public License for more details.
1.17 +
1.18 + You should have received a copy of the GNU Lesser General Public
1.19 + License along with this library; if not, write to the Free Software
1.20 + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1.21 +
1.22 + Sam Lantinga
1.23 + slouken@libsdl.org
1.24 +*/
1.25 +
1.26 +void SDL_StartTicks(void)
1.27 +{
1.28 +}
1.29 +
1.30 +Uint32 SDL_GetTicks (void)
1.31 +{
1.32 + SDL_Unsupported();
1.33 + return 0;
1.34 +}
1.35 +
1.36 +void SDL_Delay (Uint32 ms)
1.37 +{
1.38 + SDL_Unsupported();
1.39 +}
1.40 +
1.41 +#include "SDL_thread.h"
1.42 +
1.43 +/* Data to handle a single periodic alarm */
1.44 +static int timer_alive = 0;
1.45 +static SDL_Thread *timer = NULL;
1.46 +
1.47 +static int RunTimer(void *unused)
1.48 +{
1.49 + while ( timer_alive ) {
1.50 + if ( SDL_timer_running ) {
1.51 + SDL_ThreadedTimerCheck();
1.52 + }
1.53 + SDL_Delay(1);
1.54 + }
1.55 + return(0);
1.56 +}
1.57 +
1.58 +/* This is only called if the event thread is not running */
1.59 +int SDL_SYS_TimerInit(void)
1.60 +{
1.61 + timer_alive = 1;
1.62 + timer = SDL_CreateThread(RunTimer, NULL);
1.63 + if ( timer == NULL )
1.64 + return(-1);
1.65 + return(SDL_SetTimerThreaded(1));
1.66 +}
1.67 +
1.68 +void SDL_SYS_TimerQuit(void)
1.69 +{
1.70 + timer_alive = 0;
1.71 + if ( timer ) {
1.72 + SDL_WaitThread(timer, NULL);
1.73 + timer = NULL;
1.74 + }
1.75 +}
1.76 +
1.77 +int SDL_SYS_StartTimer(void)
1.78 +{
1.79 + SDL_SetError("Internal logic error: threaded timer in use");
1.80 + return(-1);
1.81 +}
1.82 +
1.83 +void SDL_SYS_StopTimer(void)
1.84 +{
1.85 + return;
1.86 +}