summaryrefslogtreecommitdiffstats
path: root/src/H5system.c
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2009-05-21 15:40:03 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2009-05-21 15:40:03 (GMT)
commitd2ef2af9b28e1648345c575403d7e575044b7445 (patch)
tree581cf5c2c9865c6eedcc1a6a57fb4334bf8a1647 /src/H5system.c
parentb75740341f787f9a4c3ddadeb0668066084b465f (diff)
downloadhdf5-d2ef2af9b28e1648345c575403d7e575044b7445.zip
hdf5-d2ef2af9b28e1648345c575403d7e575044b7445.tar.gz
hdf5-d2ef2af9b28e1648345c575403d7e575044b7445.tar.bz2
[svn-r16969] Updated perf_serial test to work on windows.
Tested: Windows and h5committest
Diffstat (limited to 'src/H5system.c')
-rw-r--r--src/H5system.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/H5system.c b/src/H5system.c
index 8956e9b..36ec1c1 100644
--- a/src/H5system.c
+++ b/src/H5system.c
@@ -580,6 +580,52 @@ HDremove_all(const char *fname)
}
#endif
+/*-------------------------------------------------------------------------
+ * Function: HDgettimeofday
+ *
+ * Purpose: Wrapper function for gettimeofday on Windows systems
+ *
+ * This function can get the time as well as a timezone
+ *
+ * Return: 0
+ *
+ * This implementation is taken from the Cygwin source distribution at
+ * src/winsup/mingw/mingwex/gettimeofday.c
+ *
+ * The original source code was contributed by
+ * Danny Smith <dannysmith@users.sourceforge.net>
+ * and released in the public domain.
+ *
+ * Programmer: Scott Wegner
+ * May 19, 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+#if !defined(H5_HAVE_GETTIMEOFDAY) && defined(_WIN32)
+
+/* Offset between 1/1/1601 and 1/1/1970 in 100 nanosec units */
+#define _W32_FT_OFFSET (116444736000000000ULL)
+
+int
+HDgettimeofday(struct timeval *tv, void *tz)
+ {
+ union {
+ unsigned long long ns100; /*time since 1 Jan 1601 in 100ns units */
+ FILETIME ft;
+ } _now;
+
+ if(tv)
+ {
+ GetSystemTimeAsFileTime (&_now.ft);
+ tv->tv_usec=(long)((_now.ns100 / 10ULL) % 1000000ULL );
+ tv->tv_sec= (long)((_now.ns100 - _W32_FT_OFFSET) / 10000000ULL);
+ }
+ /* Always return 0 as per Open Group Base Specifications Issue 6.
+ Do not set errno on error. */
+ return 0;
+}
+#endif
+
/*
*-------------------------------------------------------------------------