X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fio-layer%2Fmisc.c;h=82835cc52b937ac0598b8bdb4c66fed8d2bd9e9a;hb=a12069b2401a3b1d822af66ab09935144904dab8;hp=67ffbeed501bd517bb1981edd4cead369218c49f;hpb=a4bb9199bf324547ad42de17902b0b0558d8a98d;p=mono.git diff --git a/mono/io-layer/misc.c b/mono/io-layer/misc.c index 67ffbeed501..82835cc52b9 100644 --- a/mono/io-layer/misc.c +++ b/mono/io-layer/misc.c @@ -11,17 +11,20 @@ #include #include #include +#include #include "misc-private.h" void _wapi_calc_timeout(struct timespec *timeout, guint32 ms) { struct timeval now; - div_t divvy; - - divvy=div((int)ms, 1000); - gettimeofday(&now, NULL); + div_t ms_divvy, overflow_divvy; + + gettimeofday (&now, NULL); + + ms_divvy = div (ms, 1000); + overflow_divvy = div ((now.tv_usec / 1000) + ms_divvy.rem, 1000); - timeout->tv_sec=now.tv_sec+divvy.quot; - timeout->tv_nsec=(now.tv_usec+divvy.rem)*1000; + timeout->tv_sec = now.tv_sec + ms_divvy.quot + overflow_divvy.quot; + timeout->tv_nsec = overflow_divvy.rem * 1000000; }