[Mesa-dev] [PATCH 1/2] util: Remove dependency on gallium header file

George Kyriazis george.kyriazis at intel.com
Thu Nov 16 16:15:26 UTC 2017


Do not depend on gallium/include/pipe/p_config.h for PIPE_OS_* defines.
Use standard OS defines instead.
---
 src/util/os_time.c | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/src/util/os_time.c b/src/util/os_time.c
index 72dc7e4..1c34bfd 100644
--- a/src/util/os_time.c
+++ b/src/util/os_time.c
@@ -34,12 +34,9 @@
 
 #include "os_time.h"
 
-/* TODO: fix this dependency */
-#include "gallium/include/pipe/p_config.h"
-
 #include "util/u_atomic.h"
 
-#if defined(PIPE_OS_UNIX)
+#if defined(__unix__)
 #  include <unistd.h> /* usleep */
 #  include <time.h> /* timeval */
 #  include <sys/time.h> /* timeval */
@@ -55,19 +52,19 @@
 int64_t
 os_time_get_nano(void)
 {
-#if defined(PIPE_OS_LINUX)
+#if defined(__linux__)
 
    struct timespec tv;
    clock_gettime(CLOCK_MONOTONIC, &tv);
    return tv.tv_nsec + tv.tv_sec*INT64_C(1000000000);
 
-#elif defined(PIPE_OS_UNIX)
+#elif defined(__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 defined(_MSC_VER)
 
    static LARGE_INTEGER frequency;
    LARGE_INTEGER counter;
@@ -95,16 +92,16 @@ os_time_get_nano(void)
 void
 os_time_sleep(int64_t usecs)
 {
-#if defined(PIPE_OS_LINUX)
+#if defined(__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 defined(__unix__)
    usleep(usecs);
 
-#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
+#elif defined(_MSC_VER)
    DWORD dwMilliseconds = (DWORD) ((usecs + 999) / 1000);
    /* Avoid Sleep(O) as that would cause to sleep for an undetermined duration */
    if (dwMilliseconds) {
@@ -148,7 +145,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 defined(__unix__)
          sched_yield();
 #endif
       }
@@ -162,7 +159,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 defined(__unix__)
          sched_yield();
 #endif
       }
@@ -184,7 +181,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 defined(__unix__)
       sched_yield();
 #endif
    }
-- 
2.7.4



More information about the mesa-dev mailing list