Release CPU when waiting
authorPatrice Mandin <patmandin@gmail.com>
Fri, 01 Apr 2005 15:19:26 +0000
changeset 104563b8e93a3a52
parent 1044 d36ea7925763
child 1046 f09d5edfc7a3
Release CPU when waiting
src/timer/mint/SDL_systimer.c
     1.1 --- a/src/timer/mint/SDL_systimer.c	Wed Mar 30 12:38:03 2005 +0000
     1.2 +++ b/src/timer/mint/SDL_systimer.c	Fri Apr 01 15:19:26 2005 +0000
     1.3 @@ -39,8 +39,10 @@
     1.4  #include <string.h>
     1.5  #include <errno.h>
     1.6  
     1.7 +#include <mint/cookie.h>
     1.8 +#include <mint/sysvars.h>
     1.9  #include <mint/osbind.h>
    1.10 -#include <mint/sysvars.h>
    1.11 +#include <mint/mintbind.h>
    1.12  
    1.13  #include "SDL_error.h"
    1.14  #include "SDL_timer.h"
    1.15 @@ -52,10 +54,12 @@
    1.16  /* The first ticks value of the application */
    1.17  static Uint32 start;
    1.18  static SDL_bool supervisor;
    1.19 +static int mint_present; /* can we use Syield() ? */
    1.20  
    1.21  void SDL_StartTicks(void)
    1.22  {
    1.23  	void *oldpile;
    1.24 +	unsigned long dummy;
    1.25  
    1.26  	/* Set first ticks value */
    1.27  	oldpile=(void *)Super(0);
    1.28 @@ -63,12 +67,14 @@
    1.29  	Super(oldpile);
    1.30  
    1.31  	start *= 5;	/* One _hz_200 tic is 5ms */
    1.32 +
    1.33 +	mint_present = (Getcookie(C_MiNT, &dummy) == C_FOUND);
    1.34  }
    1.35  
    1.36  Uint32 SDL_GetTicks (void)
    1.37  {
    1.38  	Uint32 now;
    1.39 -	void *oldpile;
    1.40 +	void *oldpile=NULL;
    1.41  
    1.42  	/* Check if we are in supervisor mode 
    1.43  	   (this is the case when called from SDL_ThreadedTimerCheck,
    1.44 @@ -93,6 +99,9 @@
    1.45  
    1.46  	now = SDL_GetTicks();
    1.47  	while ((SDL_GetTicks()-now)<ms){
    1.48 +		if (mint_present) {
    1.49 +			Syield();
    1.50 +		}
    1.51  	}
    1.52  }
    1.53