[PATCH_v2] use CLOCK_MONOTONIC_COARSE posix timer instead of CLOCK_MONOTONIC in Xorg
Yaakov (Cygwin/X)
yselkowitz at users.sourceforge.net
Thu Aug 26 19:21:35 PDT 2010
On Fri, 2010-08-27 at 09:20 +0800, Zhao Yakui wrote:
> diff --git a/os/utils.c b/os/utils.c
> index 51455cc..a37a99d 100644
> --- a/os/utils.c
> +++ b/os/utils.c
> @@ -427,7 +427,17 @@ GetTimeInMillis(void)
>
> #ifdef MONOTONIC_CLOCK
> struct timespec tp;
> - if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
> + static clockid_t clockid;
> + if (!clockid) {
> +#if defined(__linux__) && defined(CLOCK_MONONOTIC_COARSE)
s/MONONOTIC/MONOTONIC/
But shouldn't that just be #ifdef CLOCK_MONOTONIC_COARSE? What if
another system besides Linux implements it?
> + if ((clock_getres(CLOCK_MONOTONIC_COARSE, &tp) == 0) &&
> + (tp.tv_nsec / 1000 <= 1000))
> + clockid = CLOCK_MONOTONIC_COARSE;
> + else
> +#endif
> + clockid = CLOCK_MONOTONIC;
> + }
> + if (clock_gettime(clockid, &tp) == 0)
> return (tp.tv_sec * 1000) + (tp.tv_nsec / 1000000L);
> #endif
>
Yaakov
Cygwin/X
More information about the xorg-devel
mailing list