Cygwin: Cleanup time handling

* Redefine NSPERSEC to NS100PERSEC
* Define NSPERSEC as nanosecs per second
* Define USPERSEC as microsecs per second
* Use above constants throughout where appropriate
* Rename to_us to timespec_to_us and inline
* Rename it_bad to timespec_bad and inline

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen
2018-02-07 13:07:44 +01:00
parent f8ce691223
commit 2af67d21b2
13 changed files with 115 additions and 97 deletions

View File

@@ -107,7 +107,10 @@ pselect (int maxfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
else
{
/* Convert to microseconds or -1 if to == NULL */
LONGLONG us = to ? to->tv_sec * 1000000LL + (to->tv_nsec + 999) / 1000 : -1LL;
LONGLONG us = to ? to->tv_sec * USPERSEC
+ (to->tv_nsec + (NSPERSEC/USPERSEC) - 1)
/ (NSPERSEC/USPERSEC)
: -1LL;
if (to)
select_printf ("to->tv_sec %ld, to->tv_nsec %ld, us %D", to->tv_sec, to->tv_nsec, us);