diff options
Diffstat (limited to 'src/gallium/auxiliary/os')
-rw-r--r-- | src/gallium/auxiliary/os/os_time.c | 15 | ||||
-rw-r--r-- | src/gallium/auxiliary/os/os_time.h | 7 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/os/os_time.c b/src/gallium/auxiliary/os/os_time.c index 3e9d50a598a..40551252b25 100644 --- a/src/gallium/auxiliary/os/os_time.c +++ b/src/gallium/auxiliary/os/os_time.c @@ -36,6 +36,7 @@ #include "pipe/p_config.h" #if defined(PIPE_OS_UNIX) +# include <time.h> /* timeval */ # include <sys/time.h> /* timeval */ #elif defined(PIPE_SUBSYSTEM_WINDOWS_USER) # include <windows.h> @@ -68,6 +69,20 @@ os_time_get(void) } +uint64_t +os_time_get_nano(void) +{ +#if defined(PIPE_OS_UNIX) + struct timespec tv; + clock_gettime(CLOCK_REALTIME, &tv); + return tv.tv_nsec + tv.tv_sec * 1000000000LL; + +#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER) + return os_time_get() * 1000; +#endif +} + + #if defined(PIPE_SUBSYSTEM_WINDOWS_USER) void diff --git a/src/gallium/auxiliary/os/os_time.h b/src/gallium/auxiliary/os/os_time.h index 7e0f67a76b0..54101a1f546 100644 --- a/src/gallium/auxiliary/os/os_time.h +++ b/src/gallium/auxiliary/os/os_time.h @@ -58,6 +58,13 @@ os_time_get(void); /* + * Get the current time in nanoseconds from an unknown base. + */ +uint64_t +os_time_get_nano(void); + + +/* * Sleep. */ #if defined(PIPE_OS_UNIX) |