[Mesa-dev] [PATCH 2/2] gallium/os: fix os_time_get_nano() to roll over less

Jose Fonseca jfonseca at vmware.com
Wed Aug 16 22:37:50 UTC 2017


On 16/08/17 14:22, Brian Paul wrote:
> From: Frank Richter <frank.richter at dynardo.de>
> 
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102241
> Cc: mesa-stable at lists.freedesktop.org
> Reviewed-by: Brian Paul <brianp at vmware.com>
> ---
>   src/gallium/auxiliary/os/os_time.c | 9 ++++++++-
>   1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/src/gallium/auxiliary/os/os_time.c b/src/gallium/auxiliary/os/os_time.c
> index e169139..e4a1cae 100644
> --- a/src/gallium/auxiliary/os/os_time.c
> +++ b/src/gallium/auxiliary/os/os_time.c
> @@ -69,10 +69,17 @@ os_time_get_nano(void)
>   
>      static LARGE_INTEGER frequency;
>      LARGE_INTEGER counter;
> +   int64_t secs, nanosecs;
>      if(!frequency.QuadPart)
>         QueryPerformanceFrequency(&frequency);
>      QueryPerformanceCounter(&counter);
> -   return counter.QuadPart*INT64_C(1000000000)/frequency.QuadPart;
> +   /* Compute seconds and nanoseconds parts separately to
> +    * reduce severity of precision loss.
> +    */
> +   secs = counter.QuadPart / frequency.QuadPart;
> +   nanosecs = (counter.QuadPart % frequency.QuadPart) * INT64_C(1000000000)
> +      / frequency.QuadPart;
> +   return secs*INT64_C(1000000000) + nanosecs;
>   
>   #else
>   
> 

Series looks great.

Thanks!

Reviewed-by: Jose Fonseca <jfonseca at vmware.com>


More information about the mesa-dev mailing list