X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fgallium%2Fauxiliary%2Futil%2Fu_time.h;h=15899c2c884064d09ce801b59a38bb3301a42259;hb=a1a7738223b754044213b969371823ec52b0a9e2;hp=35d97d16c739758674fd3f18eeb0224e5a8fecb4;hpb=ef2bf418b45c7966e9fe78359058b8d44f570be1;p=mesa.git diff --git a/src/gallium/auxiliary/util/u_time.h b/src/gallium/auxiliary/util/u_time.h index 35d97d16c73..15899c2c884 100644 --- a/src/gallium/auxiliary/util/u_time.h +++ b/src/gallium/auxiliary/util/u_time.h @@ -38,10 +38,7 @@ #include "pipe/p_config.h" -#if defined(PIPE_OS_LINUX) -#include /* timeval */ -#include /* usleep */ -#endif +#include "os/os_time.h" #include "pipe/p_compiler.h" @@ -58,43 +55,92 @@ extern "C" { */ struct util_time { -#if defined(PIPE_OS_LINUX) - 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 +/** + * Return t2 = t1 + usecs + */ +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 +/** + * Return difference between times, in microseconds + */ +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; +} + + +/** + * Compare two time values. + * + * Not publicly available because it does not take in account wrap-arounds. + * Use util_time_timeout instead. + */ +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; +} + /** * Returns non-zero when the timeout expires. */ -boolean +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) -#define util_time_sleep usleep -#else -void -util_time_sleep(unsigned usecs); -#endif + +/** + * Return current time in microseconds + */ +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