OSDN Git Service

gallium/os: Fix os_time_sleep() on Windows for small durations.
authorJosé Fonseca <jfonseca@vmware.com>
Tue, 4 Dec 2012 19:44:08 +0000 (19:44 +0000)
committerJosé Fonseca <jfonseca@vmware.com>
Thu, 6 Dec 2012 17:12:31 +0000 (17:12 +0000)
Prevents undetermined sleeps.

Reviewed-by: Brian Paul <brianp@vmware.com>
src/gallium/auxiliary/os/os_time.c

index 4055125..f943e0f 100644 (file)
@@ -88,7 +88,11 @@ os_time_get_nano(void)
 void
 os_time_sleep(int64_t usecs)
 {
-   Sleep((usecs + 999) / 1000);
+   DWORD dwMilliseconds = (usecs + 999) / 1000;
+   /* Avoid Sleep(O) as that would cause to sleep for an undetermined duration */
+   if (dwMilliseconds) {
+      Sleep(dwMilliseconds);
+   }
 }
 
 #endif