Release CPU when waiting
authorPatrice Mandin <patmandin@gmail.com>
Fri, 01 Apr 2005 15:19:26 +0000
changeset 1045 63b8e93a3a52
parent 1044 d36ea7925763
child 1046 f09d5edfc7a3
Release CPU when waiting
src/timer/mint/SDL_systimer.c
--- a/src/timer/mint/SDL_systimer.c	Wed Mar 30 12:38:03 2005 +0000
+++ b/src/timer/mint/SDL_systimer.c	Fri Apr 01 15:19:26 2005 +0000
@@ -39,8 +39,10 @@
 #include <string.h>
 #include <errno.h>
 
+#include <mint/cookie.h>
+#include <mint/sysvars.h>
 #include <mint/osbind.h>
-#include <mint/sysvars.h>
+#include <mint/mintbind.h>
 
 #include "SDL_error.h"
 #include "SDL_timer.h"
@@ -52,10 +54,12 @@
 /* The first ticks value of the application */
 static Uint32 start;
 static SDL_bool supervisor;
+static int mint_present; /* can we use Syield() ? */
 
 void SDL_StartTicks(void)
 {
 	void *oldpile;
+	unsigned long dummy;
 
 	/* Set first ticks value */
 	oldpile=(void *)Super(0);
@@ -63,12 +67,14 @@
 	Super(oldpile);
 
 	start *= 5;	/* One _hz_200 tic is 5ms */
+
+	mint_present = (Getcookie(C_MiNT, &dummy) == C_FOUND);
 }
 
 Uint32 SDL_GetTicks (void)
 {
 	Uint32 now;
-	void *oldpile;
+	void *oldpile=NULL;
 
 	/* Check if we are in supervisor mode 
 	   (this is the case when called from SDL_ThreadedTimerCheck,
@@ -93,6 +99,9 @@
 
 	now = SDL_GetTicks();
 	while ((SDL_GetTicks()-now)<ms){
+		if (mint_present) {
+			Syield();
+		}
 	}
 }