summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perform/sio_engine.c44
-rw-r--r--perform/sio_perf.c22
-rw-r--r--perform/sio_timer.c394
-rw-r--r--perform/sio_timer.h4
-rw-r--r--src/H5private.h5
-rw-r--r--src/H5system.c46
-rw-r--r--src/H5win32defs.h16
7 files changed, 297 insertions, 234 deletions
diff --git a/perform/sio_engine.c b/perform/sio_engine.c
index d4e7ad3..8e792bd 100644
--- a/perform/sio_engine.c
+++ b/perform/sio_engine.c
@@ -21,7 +21,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
-#include <unistd.h>
+#ifdef H5_HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <errno.h>
#include "hdf5.h"
@@ -227,7 +229,7 @@ do_sio(parameters param)
*/
/* Open file for write */
- strcpy(base_name, "#sio_tmp");
+ HDstrcpy(base_name, "#sio_tmp");
sio_create_filename(iot, base_name, fname, sizeof(fname), &param);
if (sio_debug_level > 0)
@@ -335,7 +337,7 @@ sio_create_filename(iotype iot, const char *base_name, char *fullname, size_t si
}
/* First use the environment variable and then try the constant */
- prefix = getenv("HDF5_PREFIX");
+ prefix = HDgetenv("HDF5_PREFIX");
#ifdef HDF5_PREFIX
if (!prefix)
@@ -349,8 +351,8 @@ sio_create_filename(iotype iot, const char *base_name, char *fullname, size_t si
* directory instead. */
register char *user, *login, *subdir;
- user = getenv("USER");
- login = getenv("LOGIN");
+ user = HDgetenv("USER");
+ login = HDgetenv("LOGIN");
subdir = (user ? user : login);
if (subdir) {
@@ -363,24 +365,24 @@ sio_create_filename(iotype iot, const char *base_name, char *fullname, size_t si
fullname[i] = subdir[j];
} else {
/* We didn't append the prefix yet */
- strncpy(fullname, prefix, MIN(strlen(prefix), size));
+ HDstrncpy(fullname, prefix, MIN(HDstrlen(prefix), size));
}
- if ((strlen(fullname) + strlen(base_name) + 1) < size) {
+ if ((HDstrlen(fullname) + HDstrlen(base_name) + 1) < size) {
/* Append the base_name with a slash first. Multiple slashes are
* handled below. */
h5_stat_t buf;
if (HDstat(fullname, &buf) < 0)
/* The directory doesn't exist just yet */
- if (mkdir(fullname, (mode_t)0755) < 0 && errno != EEXIST) {
+ if (HDmkdir(fullname, 0755) < 0 && errno != EEXIST) {
/* We couldn't make the "/tmp/${USER,LOGIN}" subdirectory.
* Default to PREFIX's original prefix value. */
- strcpy(fullname, prefix);
+ HDstrcpy(fullname, prefix);
}
- strcat(fullname, "/");
- strcat(fullname, base_name);
+ HDstrcat(fullname, "/");
+ HDstrcat(fullname, base_name);
} else {
/* Buffer is too small */
return NULL;
@@ -389,19 +391,19 @@ sio_create_filename(iotype iot, const char *base_name, char *fullname, size_t si
/* Buffer is too small */
return NULL;
} else {
- strcpy(fullname, base_name);
+ HDstrcpy(fullname, base_name);
}
/* Append a suffix */
if (suffix) {
- if (strlen(fullname) + strlen(suffix) >= size)
+ if (HDstrlen(fullname) + HDstrlen(suffix) >= size)
return NULL;
- strcat(fullname, suffix);
+ HDstrcat(fullname, suffix);
}
/* Remove any double slashes in the filename */
- for (ptr = fullname, i = j = 0; ptr && i < size; i++, ptr++) {
+ for (ptr = fullname, i = j = 0; ptr && (i < size); i++, ptr++) {
if (*ptr != '/' || last != '/')
fullname[j++] = *ptr;
@@ -537,14 +539,14 @@ do_write(results *res, file_descr *fd, parameters *parms, void *buffer)
h5dset_space_id, H5P_DEFAULT, h5dcpl, H5P_DEFAULT);
if (h5ds_id < 0) {
- fprintf(stderr, "HDF5 Dataset Create failed\n");
+ HDfprintf(stderr, "HDF5 Dataset Create failed\n");
GOTOERROR(FAIL);
}
hrc = H5Pclose(h5dcpl);
/* verifying the close of the dcpl */
if (hrc < 0) {
- fprintf(stderr, "HDF5 Property List Close failed\n");
+ HDfprintf(stderr, "HDF5 Property List Close failed\n");
GOTOERROR(FAIL);
}
@@ -841,7 +843,7 @@ do_read(results *res, file_descr *fd, parameters *parms, void *buffer)
sprintf(dname, "Dataset_%ld", parms->num_bytes);
h5ds_id = H5Dopen2(fd->h5fd, dname, H5P_DEFAULT);
if (h5ds_id < 0) {
- fprintf(stderr, "HDF5 Dataset open failed\n");
+ HDfprintf(stderr, "HDF5 Dataset open failed\n");
GOTOERROR(FAIL);
}
@@ -1048,7 +1050,7 @@ do_fopen(parameters *param, char *fname, file_descr *fd /*out*/, int flags)
fd->posixfd = POSIXOPEN(fname, O_RDONLY);
if (fd->posixfd < 0 ) {
- fprintf(stderr, "POSIX File Open failed(%s)\n", fname);
+ HDfprintf(stderr, "POSIX File Open failed(%s)\n", fname);
GOTOERROR(FAIL);
}
@@ -1129,7 +1131,7 @@ set_vfd(parameters *param)
HDmemset(memb_name, 0, sizeof memb_name);
HDmemset(memb_addr, 0, sizeof memb_addr);
- assert(HDstrlen(multi_letters)==H5FD_MEM_NTYPES);
+ HDassert(HDstrlen(multi_letters)==H5FD_MEM_NTYPES);
for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t,mt)) {
memb_fapl[mt] = H5P_DEFAULT;
sprintf(sv[mt], "%%s-%c.h5", multi_letters[mt]);
@@ -1220,7 +1222,7 @@ do_cleanupfile(iotype iot, char *filename)
hid_t driver;
if (clean_file_g == -1)
- clean_file_g = (getenv("HDF5_NOCLEANUP")==NULL) ? 1 : 0;
+ clean_file_g = (HDgetenv("HDF5_NOCLEANUP")==NULL) ? 1 : 0;
if (clean_file_g){
diff --git a/perform/sio_perf.c b/perform/sio_perf.c
index 5b97667..d852a45 100644
--- a/perform/sio_perf.c
+++ b/perform/sio_perf.c
@@ -353,7 +353,7 @@ main(int argc, char **argv)
}
if (opts->output_file) {
- if ((output = fopen(opts->output_file, "w")) == NULL) {
+ if ((output = HDfopen(opts->output_file, "w")) == NULL) {
fprintf(stderr, "%s: cannot open output file\n", progname);
perror(opts->output_file);
goto finish;
@@ -918,7 +918,7 @@ report_parameters(struct options *opts)
}
{
- char *prefix = getenv("HDF5_PREFIX");
+ char *prefix = HDgetenv("HDF5_PREFIX");
HDfprintf(output, "Env HDF5_PREFIX=%s\n",
(prefix ? prefix : "not set"));
@@ -992,9 +992,9 @@ parse_command_line(int argc, char *argv[])
if (isalnum(*end) && i < 10)
buf[i++] = *end;
- if (!strcasecmp(buf, "hdf5")) {
+ if (!HDstrcasecmp(buf, "hdf5")) {
cl_opts->io_types |= SIO_HDF5;
- } else if (!strcasecmp(buf, "posix")) {
+ } else if (!HDstrcasecmp(buf, "posix")) {
cl_opts->io_types |= SIO_POSIX;
} else {
fprintf(stderr, "sio_perf: invalid --api option %s\n",
@@ -1145,19 +1145,19 @@ parse_command_line(int argc, char *argv[])
cl_opts->h5_threshold = parse_size_directive(opt_arg);
break;
case 'v':
- if (!strcasecmp(opt_arg, "sec2")) {
+ if (!HDstrcasecmp(opt_arg, "sec2")) {
cl_opts->vfd=sec2;
- } else if (!strcasecmp(opt_arg, "stdio")) {
+ } else if (!HDstrcasecmp(opt_arg, "stdio")) {
cl_opts->vfd=stdio;
- } else if (!strcasecmp(opt_arg, "core")) {
+ } else if (!HDstrcasecmp(opt_arg, "core")) {
cl_opts->vfd=core;
- } else if (!strcasecmp(opt_arg, "split")) {
+ } else if (!HDstrcasecmp(opt_arg, "split")) {
cl_opts->vfd=split;
- } else if (!strcasecmp(opt_arg, "multi")) {
+ } else if (!HDstrcasecmp(opt_arg, "multi")) {
cl_opts->vfd=multi;
- } else if (!strcasecmp(opt_arg, "family")) {
+ } else if (!HDstrcasecmp(opt_arg, "family")) {
cl_opts->vfd=family;
- } else if (!strcasecmp(opt_arg, "direct")) {
+ } else if (!HDstrcasecmp(opt_arg, "direct")) {
cl_opts->vfd=direct;
} else {
fprintf(stderr, "sio_perf: invalid --api option %s\n",
diff --git a/perform/sio_timer.c b/perform/sio_timer.c
index cce4f4b..f188a10 100644
--- a/perform/sio_timer.c
+++ b/perform/sio_timer.c
@@ -1,197 +1,197 @@
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * Copyright by The HDF Group. *
- * All rights reserved. *
- * *
- * This file is part of HDF5. The full HDF5 copyright notice, including *
- * terms governing use, modification, and redistribution, is contained in *
- * the files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
-/*
- * Purpose:
- *
- * This is a module of useful timing functions for performance testing.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "sio_timer.h"
-
-
-#include "sio_perf.h"
-
-/*
- * The number to divide the tv_usec field with to get a nice decimal to add to
- * the number of seconds.
- */
-#define MICROSECOND 1000000.0
-
-/* global variables */
-sio_time *timer_g; /* timer: global for stub functions */
-
-/*
- * Function: sub_time
- * Purpose: Struct two time values, and return the difference, in microseconds
- *
- * Note that the function assumes that a > b
- * Programmer: Leon Arber, 1/27/06
- */
-static double sub_time(struct timeval* a, struct timeval* b)
-{
- return (((double)a->tv_sec +
- ((double)a->tv_usec) / MICROSECOND) -
- ((double)b->tv_sec +
- ((double)b->tv_usec) / MICROSECOND));
-}
-
-
-/*
- * Function: sio_time_new
- * Purpose: Build us a brand, spankin', new performance time object.
- * The object is a black box to the user.
- * Return: Pointer to sio_time object
- * Programmer: Bill Wendling, 01. October 2001
- * Modifications:
- */
-sio_time *
-sio_time_new(void)
-{
- sio_time *pt = (sio_time *)calloc(1, sizeof(struct sio_time_));
-
- /* set global timer variable */
- timer_g = pt;
-
- return pt;
-}
-
-/*
- * Function: sio_time_destroy
- * Purpose: Remove the memory allocated for the sio_time object. Only
- * need to call on a pointer allocated with the ``sio_time_new''
- * function.
- * Return: Nothing
- * Programmer: Bill Wendling, 01. October 2001
- * Modifications:
- */
-void
-sio_time_destroy(sio_time *pt)
-{
- free(pt);
- /* reset the global timer pointer too. */
- timer_g = NULL;
-}
-
-
-
-/*
- * Function: set_time
- * Purpose: Set the time in a ``sio_time'' object.
- * Return: Pointer to the passed in ``sio_time'' object.
- * Programmer: Bill Wendling, 01. October 2001
- * Modifications:
- */
-sio_time *
-set_time(sio_time *pt, timer_type t, int start_stop)
-{
- if (pt) {
- if (start_stop == START) {
- gettimeofday(&pt->sys_timer[t], NULL);
-
- /* When we start the timer for HDF5_FINE_WRITE_FIXED_DIMS or HDF5_FINE_READ_FIXED_DIMS
- * we compute the time it took to only open the file */
- if(t == HDF5_FINE_WRITE_FIXED_DIMS)
- pt->total_time[HDF5_FILE_WRITE_OPEN] += sub_time(&(pt->sys_timer[t]), &(pt->sys_timer[HDF5_GROSS_WRITE_FIXED_DIMS]));
- else if(t == HDF5_FINE_READ_FIXED_DIMS)
- pt->total_time[HDF5_FILE_READ_OPEN] += sub_time(&(pt->sys_timer[t]), &(pt->sys_timer[HDF5_GROSS_READ_FIXED_DIMS]));
-
-
- } else {
- struct timeval sys_t;
-
- gettimeofday(&sys_t, NULL);
- pt->total_time[t] += sub_time(&sys_t, &(pt->sys_timer[t]));
-
-/* ((double)sys_t.tv_sec +
- ((double)sys_t.tv_usec) / MICROSECOND) -
- ((double)pt->sys_timer[t].tv_sec +
- ((double)pt->sys_timer[t].tv_usec) / MICROSECOND);*/
-
- /* When we stop the timer for HDF5_GROSS_WRITE_FIXED_DIMS or HDF5_GROSS_READ_FIXED_DIMS
- * we compute the time it took to close the file after the last read/write finished */
- if(t == HDF5_GROSS_WRITE_FIXED_DIMS)
- pt->total_time[HDF5_FILE_WRITE_CLOSE] += sub_time(&(pt->sys_timer[t]), &(pt->sys_timer[HDF5_FINE_WRITE_FIXED_DIMS]));
- else if(t == HDF5_GROSS_READ_FIXED_DIMS)
- pt->total_time[HDF5_FILE_READ_CLOSE] += sub_time(&(pt->sys_timer[t]), &(pt->sys_timer[HDF5_FINE_READ_FIXED_DIMS]));
-
- }
-
- if (sio_debug_level >= 4) {
- const char *msg;
-
- switch (t) {
- case HDF5_FILE_OPENCLOSE:
- msg = "File Open/Close";
- break;
- case HDF5_DATASET_CREATE:
- msg = "Dataset Create";
- break;
- case HDF5_MPI_WRITE:
- msg = "MPI Write";
- break;
- case HDF5_MPI_READ:
- msg = "MPI Read";
- break;
- case HDF5_FINE_WRITE_FIXED_DIMS:
- msg = "Fine Write";
- break;
- case HDF5_FINE_READ_FIXED_DIMS:
- msg = "Fine Read";
- break;
- case HDF5_GROSS_WRITE_FIXED_DIMS:
- msg = "Gross Write";
- break;
- case HDF5_GROSS_READ_FIXED_DIMS:
- msg = "Gross Read";
- break;
- case HDF5_RAW_WRITE_FIXED_DIMS:
- msg = "Raw Write";
- break;
- case HDF5_RAW_READ_FIXED_DIMS:
- msg = "Raw Read";
- break;
- default:
- msg = "Unknown Timer";
- break;
- }
-
- fprintf(output, " %s %s: %.2f\n", msg,
- (start_stop == START ? "Start" : "Stop"),
- pt->total_time[t]);
- }
- }
-
- return pt;
-}
-
-/*
- * Function: get_time
- * Purpose: Get the time from a ``sio_time'' object.
- * Return: The number of seconds as a DOUBLE.
- * Programmer: Bill Wendling, 01. October 2001
- * Modifications:
- */
-double
-get_time(sio_time *pt, timer_type t)
-{
- return pt->total_time[t];
-}
-#ifdef STANDALONE
-#include "sio_standalone.c"
-#endif
-
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * Purpose:
+ *
+ * This is a module of useful timing functions for performance testing.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "sio_timer.h"
+
+
+#include "sio_perf.h"
+
+/*
+ * The number to divide the tv_usec field with to get a nice decimal to add to
+ * the number of seconds.
+ */
+#define MICROSECOND 1000000.0
+
+/* global variables */
+sio_time *timer_g; /* timer: global for stub functions */
+
+/*
+ * Function: sub_time
+ * Purpose: Struct two time values, and return the difference, in microseconds
+ *
+ * Note that the function assumes that a > b
+ * Programmer: Leon Arber, 1/27/06
+ */
+static double sub_time(struct timeval* a, struct timeval* b)
+{
+ return (((double)a->tv_sec +
+ ((double)a->tv_usec) / MICROSECOND) -
+ ((double)b->tv_sec +
+ ((double)b->tv_usec) / MICROSECOND));
+}
+
+
+/*
+ * Function: sio_time_new
+ * Purpose: Build us a brand, spankin', new performance time object.
+ * The object is a black box to the user.
+ * Return: Pointer to sio_time object
+ * Programmer: Bill Wendling, 01. October 2001
+ * Modifications:
+ */
+sio_time *
+sio_time_new(void)
+{
+ sio_time *pt = (sio_time *)calloc(1, sizeof(struct sio_time_));
+
+ /* set global timer variable */
+ timer_g = pt;
+
+ return pt;
+}
+
+/*
+ * Function: sio_time_destroy
+ * Purpose: Remove the memory allocated for the sio_time object. Only
+ * need to call on a pointer allocated with the ``sio_time_new''
+ * function.
+ * Return: Nothing
+ * Programmer: Bill Wendling, 01. October 2001
+ * Modifications:
+ */
+void
+sio_time_destroy(sio_time *pt)
+{
+ free(pt);
+ /* reset the global timer pointer too. */
+ timer_g = NULL;
+}
+
+
+
+/*
+ * Function: set_time
+ * Purpose: Set the time in a ``sio_time'' object.
+ * Return: Pointer to the passed in ``sio_time'' object.
+ * Programmer: Bill Wendling, 01. October 2001
+ * Modifications:
+ */
+sio_time *
+set_time(sio_time *pt, timer_type t, int start_stop)
+{
+ if (pt) {
+ if (start_stop == START) {
+ HDgettimeofday(&pt->sys_timer[t], NULL);
+
+ /* When we start the timer for HDF5_FINE_WRITE_FIXED_DIMS or HDF5_FINE_READ_FIXED_DIMS
+ * we compute the time it took to only open the file */
+ if(t == HDF5_FINE_WRITE_FIXED_DIMS)
+ pt->total_time[HDF5_FILE_WRITE_OPEN] += sub_time(&(pt->sys_timer[t]), &(pt->sys_timer[HDF5_GROSS_WRITE_FIXED_DIMS]));
+ else if(t == HDF5_FINE_READ_FIXED_DIMS)
+ pt->total_time[HDF5_FILE_READ_OPEN] += sub_time(&(pt->sys_timer[t]), &(pt->sys_timer[HDF5_GROSS_READ_FIXED_DIMS]));
+
+
+ } else {
+ struct timeval sys_t;
+
+ HDgettimeofday(&sys_t, NULL);
+ pt->total_time[t] += sub_time(&sys_t, &(pt->sys_timer[t]));
+
+/* ((double)sys_t.tv_sec +
+ ((double)sys_t.tv_usec) / MICROSECOND) -
+ ((double)pt->sys_timer[t].tv_sec +
+ ((double)pt->sys_timer[t].tv_usec) / MICROSECOND);*/
+
+ /* When we stop the timer for HDF5_GROSS_WRITE_FIXED_DIMS or HDF5_GROSS_READ_FIXED_DIMS
+ * we compute the time it took to close the file after the last read/write finished */
+ if(t == HDF5_GROSS_WRITE_FIXED_DIMS)
+ pt->total_time[HDF5_FILE_WRITE_CLOSE] += sub_time(&(pt->sys_timer[t]), &(pt->sys_timer[HDF5_FINE_WRITE_FIXED_DIMS]));
+ else if(t == HDF5_GROSS_READ_FIXED_DIMS)
+ pt->total_time[HDF5_FILE_READ_CLOSE] += sub_time(&(pt->sys_timer[t]), &(pt->sys_timer[HDF5_FINE_READ_FIXED_DIMS]));
+
+ }
+
+ if (sio_debug_level >= 4) {
+ const char *msg;
+
+ switch (t) {
+ case HDF5_FILE_OPENCLOSE:
+ msg = "File Open/Close";
+ break;
+ case HDF5_DATASET_CREATE:
+ msg = "Dataset Create";
+ break;
+ case HDF5_MPI_WRITE:
+ msg = "MPI Write";
+ break;
+ case HDF5_MPI_READ:
+ msg = "MPI Read";
+ break;
+ case HDF5_FINE_WRITE_FIXED_DIMS:
+ msg = "Fine Write";
+ break;
+ case HDF5_FINE_READ_FIXED_DIMS:
+ msg = "Fine Read";
+ break;
+ case HDF5_GROSS_WRITE_FIXED_DIMS:
+ msg = "Gross Write";
+ break;
+ case HDF5_GROSS_READ_FIXED_DIMS:
+ msg = "Gross Read";
+ break;
+ case HDF5_RAW_WRITE_FIXED_DIMS:
+ msg = "Raw Write";
+ break;
+ case HDF5_RAW_READ_FIXED_DIMS:
+ msg = "Raw Read";
+ break;
+ default:
+ msg = "Unknown Timer";
+ break;
+ }
+
+ fprintf(output, " %s %s: %.2f\n", msg,
+ (start_stop == START ? "Start" : "Stop"),
+ pt->total_time[t]);
+ }
+ }
+
+ return pt;
+}
+
+/*
+ * Function: get_time
+ * Purpose: Get the time from a ``sio_time'' object.
+ * Return: The number of seconds as a DOUBLE.
+ * Programmer: Bill Wendling, 01. October 2001
+ * Modifications:
+ */
+double
+get_time(sio_time *pt, timer_type t)
+{
+ return pt->total_time[t];
+}
+#ifdef STANDALONE
+#include "sio_standalone.c"
+#endif
+
diff --git a/perform/sio_timer.h b/perform/sio_timer.h
index 445a02e..943ce28 100644
--- a/perform/sio_timer.h
+++ b/perform/sio_timer.h
@@ -26,6 +26,10 @@
# include <time.h>
#endif
+#ifdef _WIN32
+# include <winsock.h>
+#endif /* _WIN32 */
+
/* The different types of timers we can have */
typedef enum timer_type_ {
HDF5_FILE_OPENCLOSE,
diff --git a/src/H5private.h b/src/H5private.h
index 43b8a95..cb776de 100644
--- a/src/H5private.h
+++ b/src/H5private.h
@@ -1156,8 +1156,11 @@ H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...);
#define HDstrchr(S,C) strchr(S,C)
#endif /* HDstrchr */
#ifndef HDstrcmp
- #define HDstrcmp(X,Y) strcmp(X,Y)
+ #define HDstrcmp(X,Y) strcmp(X,Y)
#endif /* HDstrcmp */
+#ifndef HDstrcasecmp
+ #define HDstrcasecmp(X,Y) strcasecmp(X,Y)
+#endif /* HDstrcasecmp */
#ifndef HDstrcoll
#define HDstrcoll(X,Y) strcoll(X,Y)
#endif /* HDstrcoll */
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
+
/*
*-------------------------------------------------------------------------
diff --git a/src/H5win32defs.h b/src/H5win32defs.h
index 0cf7172..49e445d 100644
--- a/src/H5win32defs.h
+++ b/src/H5win32defs.h
@@ -33,18 +33,26 @@ typedef __int64 h5_stat_size_t;
#define HDdup(F) _dup(F)
#define HDfdopen(N,S) _fdopen(N,S)
#define HDfileno(F) _fileno(F)
-
-#if _MSC_VER > 1200
+#if _MSC_VER > 1310 /* Newer than VS.NET 2003 */
#define HDftruncate(F,L) _chsize_s(F,L)
#else
#define HDftruncate(F,L) chsize(F,L)
#endif
-
#define HDfstat(F,B) _fstati64(F,B)
#define HDisatty(F) _isatty(F)
#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
+ extern "C" {
+ #endif /* __cplusplus */
+ int HDgettimeofday(struct timeval *tv, void *tz);
+ #ifdef __cplusplus
+ }
+ #endif /* __cplusplus */
+ #define HDgettimeofday(V,Z) HDgettimeofday(V,Z)
+#endif /* H5_HAVE_GETTIMEOFDAY */
#define HDgetdrive() _getdrive()
#define HDlseek(F,O,W) _lseeki64(F,O,W)
#define HDmemset(X,C,Z) memset((void*)(X),C,Z)
@@ -52,13 +60,13 @@ typedef __int64 h5_stat_size_t;
#define HDopen(S,F,M) _open(S,F|_O_BINARY,M)
#define HDread(F,M,Z) _read(F,M,Z)
#define HDsetvbuf(F,S,M,Z) setvbuf(F,S,M,(Z>1?Z:2))
+#define HDstrcasecmp(A,B) _stricmp(A,B)
#define HDstrdup(S) _strdup(S)
#define HDsnprintf _snprintf /*varargs*/
#define HDtzset() _tzset()
#define HDunlink(S) _unlink(S)
#define HDvsnprintf(S,N,FMT,A) _vsnprintf(S,N,FMT,A)
#define HDwrite(F,M,Z) _write(F,M,Z)
-#define HDstrtoull(S,R,N) _strtoui64(S,R,N)
/* Non-POSIX functions */