[PATCH] os: Actually use the computed clockid in GetTimeInMicros
Julien Cristau
jcristau at debian.org
Tue Nov 5 07:33:20 PST 2013
On Tue, Nov 5, 2013 at 07:10:27 -0800, Keith Packard wrote:
> The selection of which clock to use for this function was not actually
> getting used when fetching the final clock value.
>
> Reported-by: Julien Cristau <jcristau at debian.org>
> Signed-off-by: Keith Packard <keithp at keithp.com>
> ---
> os/utils.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/os/utils.c b/os/utils.c
> index 995f62a..2aeb312 100644
> --- a/os/utils.c
> +++ b/os/utils.c
> @@ -480,7 +480,7 @@ GetTimeInMicros(void)
> else
> clockid = ~0L;
> }
> - if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
> + if (clock_gettime(clockid, &tp) == 0)
> return (CARD64) tp.tv_sec * (CARD64)1000000 + tp.tv_nsec / 1000;
> #endif
>
I think you actually want
diff --git a/os/utils.c b/os/utils.c
index 995f62a..472ed4f 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -480,7 +480,7 @@ GetTimeInMicros(void)
else
clockid = ~0L;
}
- if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
+ if (clockid != ~0L && clock_gettime(clockid, &tp) == 0)
return (CARD64) tp.tv_sec * (CARD64)1000000 + tp.tv_nsec / 1000;
#endif
as ~0L is not a valid clock id, so that case should fall back to
gettimeofday. At least that's how GetTimeInMillis seems to handle it.
Cheers,
Julien
More information about the xorg-devel
mailing list