diff options
author | Eric Engestrom <[email protected]> | 2019-08-01 22:38:00 +0100 |
---|---|---|
committer | Eric Engestrom <[email protected]> | 2019-08-02 18:38:52 +0100 |
commit | 55eadf971ade0189e905b5157e59cca91802fba7 (patch) | |
tree | 93b16d64543fd78db0e08920d5ba0fe72a6196a2 /src | |
parent | bffa23313a470b7813eb1e0386cb056b662fc8e4 (diff) |
util/os_time: use detect_os.h to uncouple from gallium
Signed-off-by: Eric Engestrom <[email protected]>
Reviewed-by: Matt Turner <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/util/os_time.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/util/os_time.c b/src/util/os_time.c index 22195c5a669..92fc3638ddb 100644 --- a/src/util/os_time.c +++ b/src/util/os_time.c @@ -33,13 +33,11 @@ */ #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 */ @@ -55,13 +53,13 @@ int64_t os_time_get_nano(void) { -#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) +#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); @@ -95,13 +93,13 @@ 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 DETECT_OS_WINDOWS @@ -148,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 } @@ -162,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 } @@ -184,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 } |