Port Sys_Sleep() to SDL

This commit is contained in:
dhewg 2011-12-21 14:13:16 +01:00
parent e7482b4957
commit 317e63887c
5 changed files with 10 additions and 33 deletions

View file

@ -62,10 +62,6 @@ int main(int argc, char *argv[]) {
//=========================================================================== //===========================================================================
void Sys_Sleep( const int time ) {
sleep( time );
}
void EditorPrintConsole( const char *test ) { void EditorPrintConsole( const char *test ) {
} }

View file

@ -439,22 +439,6 @@ ID_TIME_T Sys_FileTimeStamp(FILE * fp) {
return st.st_mtime; return st.st_mtime;
} }
void Sys_Sleep(int msec) {
if ( msec < 20 ) {
static int last = 0;
int now = Sys_Milliseconds();
if ( now - last > 1000 ) {
Sys_Printf("WARNING: Sys_Sleep - %d < 20 msec is not portable\n", msec);
last = now;
}
// ignore that sleep call, keep going
return;
}
// use nanosleep? keep sleeping if signal interrupt?
if (usleep(msec * 1000) == -1)
Sys_Printf("usleep: %s\n", strerror(errno));
}
char *Sys_GetClipboardData(void) { char *Sys_GetClipboardData(void) {
Sys_Printf( "TODO: Sys_GetClipboardData\n" ); Sys_Printf( "TODO: Sys_GetClipboardData\n" );
return NULL; return NULL;

View file

@ -143,11 +143,8 @@ void Sys_Printf( const char *msg, ... )id_attribute((format(printf,1,2)));
void Sys_DebugPrintf( const char *fmt, ... )id_attribute((format(printf,1,2))); void Sys_DebugPrintf( const char *fmt, ... )id_attribute((format(printf,1,2)));
void Sys_DebugVPrintf( const char *fmt, va_list arg ); void Sys_DebugVPrintf( const char *fmt, va_list arg );
// a decent minimum sleep time to avoid going below the process scheduler speeds
#define SYS_MINSLEEP 20
// allow game to yield CPU time // allow game to yield CPU time
// NOTE: due to SYS_MINSLEEP this is very bad portability karma, and should be completely removed // NOTE: due to SDL_TIMESLICE this is very bad portability karma, and should be completely removed
void Sys_Sleep( int msec ); void Sys_Sleep( int msec );
// Sys_Milliseconds should only be used for profiling purposes, // Sys_Milliseconds should only be used for profiling purposes,

View file

@ -42,6 +42,15 @@ static bool waiting[MAX_TRIGGER_EVENTS] = { };
static xthreadInfo *thread[MAX_THREADS] = { }; static xthreadInfo *thread[MAX_THREADS] = { };
static size_t thread_count = 0; static size_t thread_count = 0;
/*
==============
Sys_Sleep
==============
*/
void Sys_Sleep(int msec) {
SDL_Delay(msec);
}
/* /*
================== ==================
Sys_InitThreads Sys_InitThreads

View file

@ -321,15 +321,6 @@ void Sys_DebugVPrintf( const char *fmt, va_list arg ) {
OutputDebugString( msg ); OutputDebugString( msg );
} }
/*
==============
Sys_Sleep
==============
*/
void Sys_Sleep( int msec ) {
Sleep( msec );
}
/* /*
============== ==============
Sys_ShowWindow Sys_ShowWindow