diff options
author | José Fonseca <[email protected]> | 2010-02-04 18:24:36 +0000 |
---|---|---|
committer | José Fonseca <[email protected]> | 2010-02-04 18:24:36 +0000 |
commit | 5ee324ad3cfe62de661a1a6a7a60b2eec5738ef1 (patch) | |
tree | 2fac3e46756b028b2e9396f87997b6c2bd7c2ad6 /src/gallium/auxiliary/util/u_time.h | |
parent | b7b7ea9532055a189eb1d276301937eae39f4168 (diff) |
util: Reimplement u_time on top of os_time.
Diffstat (limited to 'src/gallium/auxiliary/util/u_time.h')
-rw-r--r-- | src/gallium/auxiliary/util/u_time.h | 89 |
1 files changed, 59 insertions, 30 deletions
diff --git a/src/gallium/auxiliary/util/u_time.h b/src/gallium/auxiliary/util/u_time.h index a6189a247bb..7580ac0de4c 100644 --- a/src/gallium/auxiliary/util/u_time.h +++ b/src/gallium/auxiliary/util/u_time.h @@ -38,15 +38,7 @@ #include "pipe/p_config.h" -#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) -#include <time.h> /* timeval */ -#include <unistd.h> /* usleep */ -#endif - -#if defined(PIPE_OS_HAIKU) -#include <sys/time.h> /* timeval */ -#include <unistd.h> -#endif +#include "os/os_time.h" #include "pipe/p_compiler.h" @@ -63,43 +55,80 @@ extern "C" { */ struct util_time { -#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) - struct timeval tv; -#else int64_t counter; -#endif }; -void -util_time_get(struct util_time *t); +PIPE_DEPRECATED +static INLINE void +util_time_get(struct util_time *t) +{ + t->counter = os_time_get(); +} + -void +PIPE_DEPRECATED +static INLINE void util_time_add(const struct util_time *t1, int64_t usecs, - struct util_time *t2); + struct util_time *t2) +{ + t2->counter = t1->counter + usecs; +} -uint64_t -util_time_micros( void ); -int64_t +PIPE_DEPRECATED +static INLINE int64_t util_time_diff(const struct util_time *t1, - const struct util_time *t2); + const struct util_time *t2) +{ + return t2->counter - t1->counter; +} + /** - * Returns non-zero when the timeout expires. + * Compare two time values. + * + * Not publicly available because it does not take in account wrap-arounds. + * Use util_time_timeout instead. */ -boolean +static INLINE int +_util_time_compare(const struct util_time *t1, + const struct util_time *t2) +{ + if (t1->counter < t2->counter) + return -1; + else if(t1->counter > t2->counter) + return 1; + else + return 0; +} + + +PIPE_DEPRECATED +static INLINE boolean util_time_timeout(const struct util_time *start, const struct util_time *end, - const struct util_time *curr); + const struct util_time *curr) +{ + return os_time_timeout(start->counter, end->counter, curr->counter); +} -#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) -#define util_time_sleep usleep -#else -void -util_time_sleep(unsigned usecs); -#endif + +PIPE_DEPRECATED +static INLINE int64_t +util_time_micros(void) +{ + return os_time_get(); +} + + +PIPE_DEPRECATED +static INLINE void +util_time_sleep(int64_t usecs) +{ + os_time_sleep(usecs); +} #ifdef __cplusplus |