summaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2002-05-08 23:48:12 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2002-05-08 23:48:12 +0000
commit9032bc383a2d084c322ed9b9b5fa7df7b600b2ac (patch)
tree0e62e17772f4c08eb85d099782cb70be1df38da0 /win32
parentb13f9b9b812159a1bddb40e35e81102a2c1eac7b (diff)
downloadperl-9032bc383a2d084c322ed9b9b5fa7df7b600b2ac.tar.gz
Rework #16506 some more.
p4raw-id: //depot/perl@16507
Diffstat (limited to 'win32')
-rw-r--r--win32/win32.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/win32/win32.c b/win32/win32.c
index 59e7ee8e7a..06068bf043 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -1651,12 +1651,36 @@ win32_utime(const char *filename, struct utimbuf *times)
return rc;
}
+typedef union {
+ unsigned __int64 ft_i64;
+ FILETIME ft_val;
+} FT_t;
+
+#ifdef __GNUC__
+#define Const64(x) x##LL
+#else
+#define Const64(x) x##i64
+#endif
+/* Number of 100 nanosecond units from 1/1/1601 to 1/1/1970 */
+#define EPOCH_BIAS Const64(116444736000000000)
+
/* NOTE: This does not compute the timezone info (doing so can be expensive,
* and appears to be unsupported even by glibc) */
DllExport int
win32_gettimeofday(struct timeval *tp, void *not_used)
{
- return PerlProc_gettimeofday(tp, not_used); // Implemented in Time::HiRes.
+ FT_t ft;
+
+ /* this returns time in 100-nanosecond units (i.e. tens of usecs) */
+ GetSystemTimeAsFileTime(&ft.ft_val);
+
+ /* seconds since epoch */
+ tp->tv_sec = (long)((ft.ft_i64 - EPOCH_BIAS) / Const64(10000000));
+
+ /* microseconds remaining */
+ tp->tv_usec = (long)((ft.ft_i64 / Const64(10)) % Const64(1000000));
+
+ return 0;
}
DllExport int