From 092b339c8faadfd8bd4964bf8c553025d9532f96 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 9 May 2017 18:08:00 -0700 Subject: [PATCH] Replace usleep with nanosleep for macOS too --- src/posix/cocoa/i_system.mm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/posix/cocoa/i_system.mm b/src/posix/cocoa/i_system.mm index a9cb70809..7b7c6dcc2 100644 --- a/src/posix/cocoa/i_system.mm +++ b/src/posix/cocoa/i_system.mm @@ -77,7 +77,12 @@ void I_WaitVBL(const 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; }