aboutsummaryrefslogtreecommitdiff
path: root/pthreads/ptw32_timespec.c
diff options
context:
space:
mode:
Diffstat (limited to 'pthreads/ptw32_timespec.c')
-rw-r--r--pthreads/ptw32_timespec.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/pthreads/ptw32_timespec.c b/pthreads/ptw32_timespec.c
index 6a2cb565a..6318957a8 100644
--- a/pthreads/ptw32_timespec.c
+++ b/pthreads/ptw32_timespec.c
@@ -39,13 +39,13 @@
#include "implement.h"
-#ifdef NEED_FTIME
+#if defined(NEED_FTIME)
/*
* time between jan 1, 1601 and jan 1, 1970 in units of 100 nanoseconds
*/
#define PTW32_TIMESPEC_TO_FILETIME_OFFSET \
- ( ((LONGLONG) 27111902 << 32) + (LONGLONG) 3577643008 )
+ ( ((int64_t) 27111902 << 32) + (int64_t) 3577643008 )
INLINE void
ptw32_timespec_to_filetime (const struct timespec *ts, FILETIME * ft)
@@ -58,7 +58,7 @@ ptw32_timespec_to_filetime (const struct timespec *ts, FILETIME * ft)
* -------------------------------------------------------------------
*/
{
- *(LONGLONG *) ft = ts->tv_sec * 10000000
+ *(int64_t *) ft = ts->tv_sec * 10000000
+ (ts->tv_nsec + 50) / 100 + PTW32_TIMESPEC_TO_FILETIME_OFFSET;
}
@@ -74,10 +74,10 @@ ptw32_filetime_to_timespec (const FILETIME * ft, struct timespec *ts)
*/
{
ts->tv_sec =
- (int) ((*(LONGLONG *) ft - PTW32_TIMESPEC_TO_FILETIME_OFFSET) / 10000000);
+ (int) ((*(int64_t *) ft - PTW32_TIMESPEC_TO_FILETIME_OFFSET) / 10000000);
ts->tv_nsec =
- (int) ((*(LONGLONG *) ft - PTW32_TIMESPEC_TO_FILETIME_OFFSET -
- ((LONGLONG) ts->tv_sec * (LONGLONG) 10000000)) * 100);
+ (int) ((*(int64_t *) ft - PTW32_TIMESPEC_TO_FILETIME_OFFSET -
+ ((int64_t) ts->tv_sec * (int64_t) 10000000)) * 100);
}
#endif /* NEED_FTIME */