src/timer/dummy/SDL_systimer.c
author Sam Lantinga
Tue, 21 Feb 2006 08:46:50 +0000
changeset 1402 d910939febfa
parent 1361 19418e4422cb
child 1484 b2b476a4a73c
permissions -rw-r--r--
Use consistent identifiers for the various platforms we support.
Make sure every source file includes SDL_config.h, so the proper system
headers are chosen.
     1 /*
     2     SDL - Simple DirectMedia Layer
     3     Copyright (C) 1997-2006 Sam Lantinga
     4 
     5     This library is free software; you can redistribute it and/or
     6     modify it under the terms of the GNU Lesser General Public
     7     License as published by the Free Software Foundation; either
     8     version 2.1 of the License, or (at your option) any later version.
     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
    13     Lesser General Public License for more details.
    14 
    15     You should have received a copy of the GNU Lesser General Public
    16     License along with this library; if not, write to the Free Software
    17     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    18 
    19     Sam Lantinga
    20     slouken@libsdl.org
    21 */
    22 #include "SDL_config.h"
    23 
    24 void SDL_StartTicks(void)
    25 {
    26 }
    27 
    28 Uint32 SDL_GetTicks (void)
    29 {
    30 	SDL_Unsupported();
    31 	return 0;
    32 }
    33 
    34 void SDL_Delay (Uint32 ms)
    35 {
    36 	SDL_Unsupported();
    37 }
    38 
    39 #include "SDL_thread.h"
    40 
    41 /* Data to handle a single periodic alarm */
    42 static int timer_alive = 0;
    43 static SDL_Thread *timer = NULL;
    44 
    45 static int RunTimer(void *unused)
    46 {
    47 	while ( timer_alive ) {
    48 		if ( SDL_timer_running ) {
    49 			SDL_ThreadedTimerCheck();
    50 		}
    51 		SDL_Delay(1);
    52 	}
    53 	return(0);
    54 }
    55 
    56 /* This is only called if the event thread is not running */
    57 int SDL_SYS_TimerInit(void)
    58 {
    59 	timer_alive = 1;
    60 	timer = SDL_CreateThread(RunTimer, NULL);
    61 	if ( timer == NULL )
    62 		return(-1);
    63 	return(SDL_SetTimerThreaded(1));
    64 }
    65 
    66 void SDL_SYS_TimerQuit(void)
    67 {
    68 	timer_alive = 0;
    69 	if ( timer ) {
    70 		SDL_WaitThread(timer, NULL);
    71 		timer = NULL;
    72 	}
    73 }
    74 
    75 int SDL_SYS_StartTimer(void)
    76 {
    77 	SDL_SetError("Internal logic error: threaded timer in use");
    78 	return(-1);
    79 }
    80 
    81 void SDL_SYS_StopTimer(void)
    82 {
    83 	return;
    84 }