[PATCH_v2] use CLOCK_MONOTONIC_COARSE posix timer instead of CLOCK_MONOTONIC in Xorg

Jeremy Huddleston jeremyhu at apple.com
Thu Aug 26 20:36:00 PDT 2010


On Aug 26, 2010, at 18:20, yakui.zhao at intel.com wrote:
> #ifdef MONOTONIC_CLOCK
>     struct timespec tp;
> -    if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
> +    static clockid_t clockid;

static clockid_t clockid = 0;

> +    if (!clockid) {
> +#if defined(__linux__) && defined(CLOCK_MONONOTIC_COARSE)
> +	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



More information about the xorg-devel mailing list