[Mono-devel-list] bug in _wapi_calc_timeout

Dick Porter dick at ximian.com
Mon May 12 10:29:23 EDT 2003

On Mon, 2003-05-12 at 11:37, Martin Dvorak wrote:
> While trying to get mono working on FreeBSD 5-CURRENT, I've found a bug 
> in function _wapi_calc_timeout in mono/io-layer/misc.c. Current 
> implementation of this function may return timeout with tv_nsec > 10^9, 
> which is invalid on FreeBSD (guess should be invalid on every OS, but 

Good catch.

> ...). I propose following implementation:
> void _wapi_calc_timeout(struct timespec *timeout, guint32 ms)
> {
>          struct timeval now;
>          div_t divvy;
>          gettimeofday(&now, NULL);
>          divvy=div(now.tv_usec+1000*(int)ms, 1000);

That needs to be div(now.tv_usec+1000*(int)ms, 1000000) so that divvy
holds seconds and µseconds.

I'll commit the change to CVS now.


- Dick

More information about the Mono-devel-list mailing list