[PATCH 1/6] server: Use monotonic clock for relative timeouts.

Alexandre Julliard julliard at winehq.org
Thu Feb 20 09:36:03 CST 2020


Piotr Caban <piotr at codeweavers.com> writes:

> +static inline timeout_t monotonic_counter(void)
> +{
> +#ifdef __APPLE__
> +    static mach_timebase_info_data_t timebase;
> +
> +    if (!timebase.denom) mach_timebase_info( &timebase );
> +#ifdef HAVE_MACH_CONTINUOUS_TIME
> +    if (&mach_continuous_time != NULL)
> +        return mach_continuous_time() * timebase.numer / timebase.denom / 1000000;
> +#endif
> +    return mach_absolute_time() * timebase.numer / timebase.denom / 1000000;
> +#elif defined(HAVE_CLOCK_GETTIME)
> +    struct timespec ts;
> +#ifdef CLOCK_MONOTONIC_RAW
> +    if (!clock_gettime( CLOCK_MONOTONIC_RAW, &ts ))
> +        return (timeout_t)ts.tv_sec * TICKS_PER_SEC + ts.tv_nsec / 100;
> +#endif
> +    if (!clock_gettime( CLOCK_MONOTONIC, &ts ))
> +        return (timeout_t)ts.tv_sec * TICKS_PER_SEC + ts.tv_nsec / 100;
> +#endif
> +    return current_time - server_start_time;
> +}

We have almost the same function in request.c, I don't think we want two
of these. Also you didn't change the scaling for the Mac case.

-- 
Alexandre Julliard
julliard at winehq.org



More information about the wine-devel mailing list