[Mono-dev] [PATCH] eglib patch to avoid double overflow in win32 gtimers
Miguel de Icaza
miguel at novell.com
Wed May 6 19:49:17 EDT 2009
Hello,
Can you apply to both 2-4 and trunk?
> The calculation:
> *microseconds = (gulong)(1000000.0 * (stop - timer->start) / freq);
>
> isn't ideal ordering for long-running timers and may overflow after
> multiplying by 1000000.0 but before having a chance to divide by freq. A
> simple reordering of operations makes this less likely.
>
> Also, I made it so that it only needs to query the performance counter
> frequency once rather than each time. The patch also handles errors
> getting the performance counter frequency (currently falls back to freq
> = 1, but perhaps it should use freq = 1000000? Does anyone have hardware
> where this actually fails?). This prevents possible divide-by-zero
> exceptions.
>
> Jeff
>
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
More information about the Mono-devel-list
mailing list