Mesa (master): gallium/os: Fix os_time_sleep() on Windows for small durations.

Jose Fonseca jrfonseca at kemper.freedesktop.org
Thu Dec 6 17:13:21 UTC 2012


Module: Mesa
Branch: master
Commit: 7e14293556bf8b4248728d2952752c13f70647f3
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=7e14293556bf8b4248728d2952752c13f70647f3

Author: José Fonseca <jfonseca at vmware.com>
Date:   Tue Dec  4 19:44:08 2012 +0000

gallium/os: Fix os_time_sleep() on Windows for small durations.

Prevents undetermined sleeps.

Reviewed-by: Brian Paul <brianp at vmware.com>

---

 src/gallium/auxiliary/os/os_time.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/src/gallium/auxiliary/os/os_time.c b/src/gallium/auxiliary/os/os_time.c
index 4055125..f943e0f 100644
--- a/src/gallium/auxiliary/os/os_time.c
+++ b/src/gallium/auxiliary/os/os_time.c
@@ -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




More information about the mesa-commit mailing list