[Nut-upsdev] windows_port NUT branch
Charles Lepple
clepple at gmail.com
Thu Dec 16 14:07:58 UTC 2010
On Dec 16, 2010, at 7:16 AM, Frédéric Bohé wrote:
> As a side note, beware that your implementation of usleep could lead
> to
> call Sleep(0) (immediate return) if n<1000. usleep is supposed to
> round
> up the time spent depending on system activity and timers granularity.
Related: http://trac.networkupstools.org/projects/nut/changeset/2729
To fix the rounding, I would recommend adding a constant to the
numerator:
timeout = (d_sec*1000) + (d_usec+999)/1000;
versus:
timeout = (d_sec*1000) + (d_usec/1000) + (((d_usec % 1000)!=0)?1:0);
The same could be applied to the usleep -> Sleep function. It saves an
extra call to the mod function.
FWIW, I have mingw-w32api 3.3 here, and it does not have usleep in the
headers (only Sleep).
More information about the Nut-upsdev
mailing list