summaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>2002-05-08 22:49:33 +0000
committerGurusamy Sarathy <gsar@cpan.org>2002-05-08 22:49:33 +0000
commit57ab3dfef762780a52fccd428b2a630bc33a48f4 (patch)
tree22d944da0465db82999d4d066201b8145bc1641c /win32
parentdd15e2708920dbc7ca0967cd7bb3cf4d1bdabec2 (diff)
downloadperl-57ab3dfef762780a52fccd428b2a630bc33a48f4.tar.gz
make the gettimeofday() implementation in Time::HiRes available
from perl p4raw-id: //depot/perl@16503
Diffstat (limited to 'win32')
-rw-r--r--win32/config.bc2
-rw-r--r--win32/config.gc2
-rw-r--r--win32/config.vc2
-rw-r--r--win32/config.vc644
-rw-r--r--win32/config_H.bc2
-rw-r--r--win32/config_H.gc2
-rw-r--r--win32/config_H.vc2
-rw-r--r--win32/config_H.vc644
-rw-r--r--win32/perlhost.h9
-rw-r--r--win32/win32.c32
-rw-r--r--win32/win32iop.h3
11 files changed, 53 insertions, 11 deletions
diff --git a/win32/config.bc b/win32/config.bc
index 679cfdfcf4..69c351642b 100644
--- a/win32/config.bc
+++ b/win32/config.bc
@@ -229,7 +229,7 @@ d_getservent_r='undef'
d_getservprotos='define'
d_getspnam='undef'
d_getspnam_r='undef'
-d_gettimeod='undef'
+d_gettimeod='define'
d_gmtime_r='undef'
d_gnulibc='undef'
d_grpasswd='undef'
diff --git a/win32/config.gc b/win32/config.gc
index 32bbf1c462..0170104062 100644
--- a/win32/config.gc
+++ b/win32/config.gc
@@ -293,7 +293,7 @@ d_getsbyport='define'
d_getsent='undef'
d_getservprotos='define'
d_getspnam='undef'
-d_gettimeod='undef'
+d_gettimeod='define'
d_gnulibc='undef'
d_grpasswd='undef'
d_hasmntopt='undef'
diff --git a/win32/config.vc b/win32/config.vc
index 2b0aea084e..e11c5b3bee 100644
--- a/win32/config.vc
+++ b/win32/config.vc
@@ -229,7 +229,7 @@ d_getservent_r='undef'
d_getservprotos='define'
d_getspnam='undef'
d_getspnam_r='undef'
-d_gettimeod='undef'
+d_gettimeod='define'
d_gmtime_r='undef'
d_gnulibc='undef'
d_grpasswd='undef'
diff --git a/win32/config.vc64 b/win32/config.vc64
index e834d3427a..1c1652bddc 100644
--- a/win32/config.vc64
+++ b/win32/config.vc64
@@ -157,7 +157,7 @@ d_finite='undef'
d_finitel='undef'
d_flexfnam='define'
d_flock='define'
-d_flockproto='undef'
+d_flockproto='define'
d_fork='undef'
d_fp_class='undef'
d_fpathconf='undef'
@@ -229,7 +229,7 @@ d_getservent_r='undef'
d_getservprotos='define'
d_getspnam='undef'
d_getspnam_r='undef'
-d_gettimeod='undef'
+d_gettimeod='define'
d_gmtime_r='undef'
d_gnulibc='undef'
d_grpasswd='undef'
diff --git a/win32/config_H.bc b/win32/config_H.bc
index a754aa9981..6bb8aad76b 100644
--- a/win32/config_H.bc
+++ b/win32/config_H.bc
@@ -169,7 +169,7 @@
* <sys/resource.h> needs to be included (see I_SYS_RESOURCE).
* The type "Timeval" should be used to refer to "struct timeval".
*/
-/*#define HAS_GETTIMEOFDAY /**/
+#define HAS_GETTIMEOFDAY /**/
#ifdef HAS_GETTIMEOFDAY
#define Timeval struct timeval /* Structure used by gettimeofday() */
#endif
diff --git a/win32/config_H.gc b/win32/config_H.gc
index 2a8c97baa5..d4aa8db46c 100644
--- a/win32/config_H.gc
+++ b/win32/config_H.gc
@@ -169,7 +169,7 @@
* <sys/resource.h> needs to be included (see I_SYS_RESOURCE).
* The type "Timeval" should be used to refer to "struct timeval".
*/
-/*#define HAS_GETTIMEOFDAY /**/
+#define HAS_GETTIMEOFDAY /**/
#ifdef HAS_GETTIMEOFDAY
#define Timeval struct timeval /* Structure used by gettimeofday() */
#endif
diff --git a/win32/config_H.vc b/win32/config_H.vc
index 9aa8c21677..94cbd1300a 100644
--- a/win32/config_H.vc
+++ b/win32/config_H.vc
@@ -169,7 +169,7 @@
* <sys/resource.h> needs to be included (see I_SYS_RESOURCE).
* The type "Timeval" should be used to refer to "struct timeval".
*/
-/*#define HAS_GETTIMEOFDAY /**/
+#define HAS_GETTIMEOFDAY /**/
#ifdef HAS_GETTIMEOFDAY
#define Timeval struct timeval /* Structure used by gettimeofday() */
#endif
diff --git a/win32/config_H.vc64 b/win32/config_H.vc64
index 2771c63e26..c68cbe32c7 100644
--- a/win32/config_H.vc64
+++ b/win32/config_H.vc64
@@ -169,7 +169,7 @@
* <sys/resource.h> needs to be included (see I_SYS_RESOURCE).
* The type "Timeval" should be used to refer to "struct timeval".
*/
-/*#define HAS_GETTIMEOFDAY /**/
+#define HAS_GETTIMEOFDAY /**/
#ifdef HAS_GETTIMEOFDAY
#define Timeval struct timeval /* Structure used by gettimeofday() */
#endif
@@ -3464,7 +3464,7 @@
* to the program to supply one. A good guess is
* extern int flock(int, int);
*/
-/*#define HAS_FLOCK_PROTO /**/
+#define HAS_FLOCK_PROTO /**/
/* HAS_FPCLASSL:
* This symbol, if defined, indicates that the fpclassl routine is
diff --git a/win32/perlhost.h b/win32/perlhost.h
index dfc1ebf947..c91d9a8b90 100644
--- a/win32/perlhost.h
+++ b/win32/perlhost.h
@@ -1681,6 +1681,12 @@ PerlProcSignal(struct IPerlProc* piPerl, int sig, Sighandler_t subcode)
return win32_signal(sig, subcode);
}
+int
+PerlProcGetTimeOfDay(struct IPerlProc* piPerl, struct timeval *t, void *z)
+{
+ return win32_gettimeofday(t, z);
+}
+
#ifdef USE_ITHREADS
static THREAD_RET_TYPE
win32_start_child(LPVOID arg)
@@ -1934,7 +1940,8 @@ struct IPerlProc perlProc =
PerlProcSpawnvp,
PerlProcASpawn,
PerlProcLastHost,
- PerlProcPopenList
+ PerlProcPopenList,
+ PerlProcGetTimeOfDay
};
diff --git a/win32/win32.c b/win32/win32.c
index ca684c84cd..06068bf043 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -1651,6 +1651,38 @@ 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)
+{
+ 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
win32_uname(struct utsname *name)
{
diff --git a/win32/win32iop.h b/win32/win32iop.h
index 1568a12207..52c59b45b5 100644
--- a/win32/win32iop.h
+++ b/win32/win32iop.h
@@ -134,6 +134,7 @@ DllExport int win32_ioctl(int i, unsigned int u, char *data);
DllExport int win32_link(const char *oldname, const char *newname);
DllExport int win32_unlink(const char *f);
DllExport int win32_utime(const char *f, struct utimbuf *t);
+DllExport int win32_gettimeofday(struct timeval *tp, void *not_used);
DllExport int win32_uname(struct utsname *n);
DllExport int win32_wait(int *status);
DllExport int win32_waitpid(int pid, int *status, int flags);
@@ -178,6 +179,7 @@ END_EXTERN_C
#undef ioctl
#undef unlink
#undef utime
+#undef gettimeofday
#undef uname
#undef wait
@@ -292,6 +294,7 @@ END_EXTERN_C
#define link win32_link
#define unlink win32_unlink
#define utime win32_utime
+#define gettimeofday win32_gettimeofday
#define uname win32_uname
#define wait win32_wait
#define waitpid win32_waitpid