summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2011-04-14 19:33:15 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2011-04-14 19:33:15 (GMT)
commit9978868c117845a1a54a516ca5cc9657c83a83c1 (patch)
treeec6dbcefd6dae1b63d0ae012f07ae81e308adf99
parent2a5e9f353fedaeb5ba5fdfac77c78a89342655db (diff)
downloadhdf5-9978868c117845a1a54a516ca5cc9657c83a83c1.zip
hdf5-9978868c117845a1a54a516ca5cc9657c83a83c1.tar.gz
hdf5-9978868c117845a1a54a516ca5cc9657c83a83c1.tar.bz2
[svn-r20499] Fixes erroneous H5_HAVE_GETTIMEOFDAY behavior on Windows (JIRA HDFFV-5931). Previously, H5_HAVE_GETTIMEOFDAY was never properly defined. The timezone struct and Wgettimeofday() timezone output was also added.
This is a merge of several changesets from the log_vfd branch where this work took place: 20355, 20359, 20411, 20413, 20431, 20460 Tested on: Windows
-rw-r--r--config/cmake/ConfigureChecks.cmake4
-rw-r--r--src/H5system.c21
-rw-r--r--src/H5timer.c4
-rw-r--r--src/H5win32defs.h21
-rwxr-xr-xwindows/src/H5pubconf.h6
5 files changed, 37 insertions, 19 deletions
diff --git a/config/cmake/ConfigureChecks.cmake b/config/cmake/ConfigureChecks.cmake
index fce4900..f1883cd 100644
--- a/config/cmake/ConfigureChecks.cmake
+++ b/config/cmake/ConfigureChecks.cmake
@@ -175,8 +175,10 @@ IF (WINDOWS)
SET (H5_STDC_HEADERS 1)
SET (H5_HAVE_GETHOSTNAME 1)
SET (H5_HAVE_GETCONSOLESCREENBUFFERINFO 1)
- SET (H5_HAVE_TIMEZONE 1)
SET (H5_HAVE_FUNCTION 1)
+ SET (H5_GETTIMEOFDAY_GIVES_TZ 1)
+ SET (H5_HAVE_TIMEZONE 1)
+ SET (H5_HAVE_GETTIMEOFDAY 1)
SET (H5_LONE_COLON 0)
ENDIF (WINDOWS)
diff --git a/src/H5system.c b/src/H5system.c
index 02ea625..afe07b0 100644
--- a/src/H5system.c
+++ b/src/H5system.c
@@ -604,25 +604,36 @@ HDremove_all(const char *fname)
*
*-------------------------------------------------------------------------
*/
-#if !defined(H5_HAVE_GETTIMEOFDAY) && defined(_WIN32)
+#ifdef _WIN32
-/* Offset between 1/1/1601 and 1/1/1970 in 100 nanosec units */
+/* Offset between 1/1/1601 and 1/1/1970 in 100 nanosecond units */
#define _W32_FT_OFFSET (116444736000000000ULL)
int
-Wgettimeofday(struct timeval *tv, void *tz)
+Wgettimeofday(struct timeval *tv, struct timezone *tz)
{
union {
unsigned long long ns100; /*time since 1 Jan 1601 in 100ns units */
FILETIME ft;
} _now;
- if(tv)
- {
+ static int tzsetflag;
+
+ if(tv) {
GetSystemTimeAsFileTime (&_now.ft);
tv->tv_usec=(long)((_now.ns100 / 10ULL) % 1000000ULL );
tv->tv_sec= (long)((_now.ns100 - _W32_FT_OFFSET) / 10000000ULL);
}
+
+ if(tz) {
+ if(!tzsetflag) {
+ _tzset();
+ tzsetflag = 1;
+ }
+ tz->tz_minuteswest = _timezone / 60;
+ tz->tz_dsttime = _daylight;
+ }
+
/* Always return 0 as per Open Group Base Specifications Issue 6.
Do not set errno on error. */
return 0;
diff --git a/src/H5timer.c b/src/H5timer.c
index 8334402..7bdee8a 100644
--- a/src/H5timer.c
+++ b/src/H5timer.c
@@ -39,9 +39,9 @@
# include <sys/resource.h>
#endif
-#ifdef H5_HAVE_GETTIMEOFDAY
+#if defined(H5_HAVE_GETTIMEOFDAY) && defined(H5_HAVE_SYS_TIME_H)
#include <sys/time.h>
-#endif /* H5_HAVE_GETTIMEOFDAY */
+#endif
/****************/
diff --git a/src/H5win32defs.h b/src/H5win32defs.h
index 6ccc86a..a428899 100644
--- a/src/H5win32defs.h
+++ b/src/H5win32defs.h
@@ -44,16 +44,21 @@ typedef __int64 h5_stat_size_t;
#define HDstat(S,B) _stati64(S,B)
#define HDgetcwd(S,Z) _getcwd(S,Z)
#define HDgetdcwd(D,S,Z) _getdcwd(D,S,Z)
-#ifndef H5_HAVE_GETTIMEOFDAY
- #ifdef __cplusplus
+
+struct timezone {
+ int tz_minuteswest;
+ int tz_dsttime;
+};
+
+#ifdef __cplusplus
extern "C" {
- #endif /* __cplusplus */
- H5_DLL int Wgettimeofday(struct timeval *tv, void *tz);
- #ifdef __cplusplus
+#endif /* __cplusplus */
+H5_DLL int Wgettimeofday(struct timeval *tv, struct timezone *tz);
+#ifdef __cplusplus
}
- #endif /* __cplusplus */
- #define HDgettimeofday(V,Z) Wgettimeofday(V,Z)
-#endif /* H5_HAVE_GETTIMEOFDAY */
+#endif /* __cplusplus */
+#define HDgettimeofday(V,Z) Wgettimeofday(V,Z)
+
#define HDgetdrive() _getdrive()
#define HDlseek(F,O,W) _lseeki64(F,O,W)
#define HDoff_t __int64
diff --git a/windows/src/H5pubconf.h b/windows/src/H5pubconf.h
index c84ebac..ad4ea72 100755
--- a/windows/src/H5pubconf.h
+++ b/windows/src/H5pubconf.h
@@ -71,7 +71,7 @@
/* #undef H5_FP_TO_ULLONG_RIGHT_MAXIMUM 1 */
/* Define if gettimeofday() populates the tz pointer passed in */
-/* #undef H5_GETTIMEOFDAY_GIVES_TZ */
+#define H5_GETTIMEOFDAY_GIVES_TZ 1
/* Define to 1 if you have the `alarm' function. */
/* #undef H5_HAVE_ALARM */
@@ -169,7 +169,7 @@
/* #undef H5_HAVE_GETTEXTINFO */
/* Define to 1 if you have the `gettimeofday' function. */
-/* #undef H5_HAVE_GETTIMEOFDAY */
+#define H5_HAVE_GETTIMEOFDAY
/* Define to 1 if you have the `get_fpc_csr' function. */
/* #undef H5_HAVE_GET_FPC_CSR */
@@ -311,7 +311,7 @@
/* #undef H5_HAVE_STRUCT_TEXT_INFO */
/* Define if `struct timezone' is defined */
-/* #undef H5_HAVE_STRUCT_TIMEZONE */
+#define H5_HAVE_STRUCT_TIMEZONE 1
/* Define to 1 if `tm_zone' is member of `struct tm'. */
/* #undef H5_HAVE_STRUCT_TM_TM_ZONE */