Added few more stubs so that control reaches to DestroyDevice().
[mesa.git] / src / util / os_time.c
index 8d8291ff17316e6611f54595d626db580f08e585..92fc3638ddb8bec2994d99b2693f76c401d491a3 100644 (file)
  */
 
 #include "os_time.h"
-
-/* TODO: fix this dependency */
-#include "gallium/include/pipe/p_config.h"
+#include "detect_os.h"
 
 #include "util/u_atomic.h"
 
-#if defined(PIPE_OS_UNIX)
+#if DETECT_OS_UNIX
+#  include <unistd.h> /* usleep */
 #  include <time.h> /* timeval */
 #  include <sys/time.h> /* timeval */
 #  include <sched.h> /* sched_yield */
 #  include <errno.h>
-#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
+#elif DETECT_OS_WINDOWS
 #  include <windows.h>
 #else
 #  error Unsupported OS
 int64_t
 os_time_get_nano(void)
 {
-#if defined(PIPE_OS_LINUX)
+#if DETECT_OS_LINUX || DETECT_OS_BSD
 
    struct timespec tv;
    clock_gettime(CLOCK_MONOTONIC, &tv);
    return tv.tv_nsec + tv.tv_sec*INT64_C(1000000000);
 
-#elif defined(PIPE_OS_UNIX)
+#elif DETECT_OS_UNIX
 
    struct timeval tv;
    gettimeofday(&tv, NULL);
    return tv.tv_usec*INT64_C(1000) + tv.tv_sec*INT64_C(1000000000);
 
-#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
+#elif DETECT_OS_WINDOWS
 
    static LARGE_INTEGER frequency;
    LARGE_INTEGER counter;
@@ -94,16 +93,16 @@ os_time_get_nano(void)
 void
 os_time_sleep(int64_t usecs)
 {
-#if defined(PIPE_OS_LINUX)
+#if DETECT_OS_LINUX
    struct timespec time;
    time.tv_sec = usecs / 1000000;
    time.tv_nsec = (usecs % 1000000) * 1000;
    while (clock_nanosleep(CLOCK_MONOTONIC, 0, &time, &time) == EINTR);
 
-#elif defined(PIPE_OS_UNIX)
+#elif DETECT_OS_UNIX
    usleep(usecs);
 
-#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
+#elif DETECT_OS_WINDOWS
    DWORD dwMilliseconds = (DWORD) ((usecs + 999) / 1000);
    /* Avoid Sleep(O) as that would cause to sleep for an undetermined duration */
    if (dwMilliseconds) {
@@ -147,7 +146,7 @@ os_wait_until_zero(volatile int *var, uint64_t timeout)
 
    if (timeout == OS_TIMEOUT_INFINITE) {
       while (p_atomic_read(var)) {
-#if defined(PIPE_OS_UNIX)
+#if DETECT_OS_UNIX
          sched_yield();
 #endif
       }
@@ -161,7 +160,7 @@ os_wait_until_zero(volatile int *var, uint64_t timeout)
          if (os_time_timeout(start_time, end_time, os_time_get_nano()))
             return false;
 
-#if defined(PIPE_OS_UNIX)
+#if DETECT_OS_UNIX
          sched_yield();
 #endif
       }
@@ -183,7 +182,7 @@ os_wait_until_zero_abs_timeout(volatile int *var, int64_t timeout)
       if (os_time_get_nano() >= timeout)
          return false;
 
-#if defined(PIPE_OS_UNIX)
+#if DETECT_OS_UNIX
       sched_yield();
 #endif
    }