diff --git a/src/posix/sdl/i_system.cpp b/src/posix/sdl/i_system.cpp index 753589819b..02dc270e46 100644 --- a/src/posix/sdl/i_system.cpp +++ b/src/posix/sdl/i_system.cpp @@ -113,7 +113,12 @@ void I_WaitVBL (int count) { // I_WaitVBL is never used to actually synchronize to the // vertical blank. Instead, it's used for delay purposes. - usleep (1000000 * count / 70); + struct timespec delay, rem; + delay.tv_sec = count / 70; + /* Avoid overflow. Microsec res should be good enough. */ + delay.tv_nsec = (count%70)*1000000/70 * 1000; + while(nanosleep(&delay, &rem) == -1 && errno == EINTR) + delay = rem; } //