diff options
-rwxr-xr-x | configure | 146 | ||||
-rw-r--r-- | configure.in | 33 | ||||
-rw-r--r-- | src/H5Omtime.c | 11 | ||||
-rw-r--r-- | src/H5config.h.in | 3 | ||||
-rw-r--r-- | test/mtime.c | 65 |
5 files changed, 227 insertions, 31 deletions
@@ -7855,8 +7855,7 @@ fi - -for ac_func in difftime gettimeofday +for ac_func in difftime do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_func" >&5 @@ -7932,6 +7931,84 @@ fi done +for ac_func in gettimeofday +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. */ +#include <assert.h> +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); +char (*f) (); + +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +f = $ac_func; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +eval "$as_ac_var=no" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + have_gettime="yes" +else + have_gettime="no" +fi +done + + @@ -29118,6 +29195,7 @@ cat >>confdefs.h <<\_ACEOF #define HAVE_STRUCT_TIMEZONE 1 _ACEOF +have_struct_tz="yes" echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 else @@ -29128,6 +29206,70 @@ echo "${ECHO_T}no" >&6 fi rm -f conftest.$ac_objext conftest.$ac_ext + +if test "$have_gettime" = "yes" -a "$have_struct_tz" = "yes"; then + echo "$as_me:$LINENO: checking whether gettimeofday() gives timezone" >&5 +echo $ECHO_N "checking whether gettimeofday() gives timezone... $ECHO_C" >&6 + if test "$cross_compiling" = yes; then + { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling" >&5 +echo "$as_me: error: cannot run test program while cross compiling" >&2;} + { (exit 1); exit 1; }; } +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" + + #include <time.h> + #include <sys/time.h> + int main(void) + { + struct timeval tv; + struct timezone tz; + tz.tz_minuteswest = 7777; /* Initialize to an unreasonable number */ + tz.tz_dsttime = 7; + gettimeofday(&tv, &tz); + /* Check whether the function returned any value at all */ + if(tz.tz_minuteswest == 7777 && tz.tz_dsttime == 7) + exit(1); + else exit (0); + } +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + hdf5_use_tz="yes" +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +( exit $ac_status ) +hdf5_use_tz="no" +fi +rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + if test "$hdf5_use_tz" = "yes"; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + +cat >>confdefs.h <<\_ACEOF +#define GETTIMEOFDAY_GIVES_TZ 1 +_ACEOF + + else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + fi +fi + echo "$as_me:$LINENO: checking for st_blocks in struct stat" >&5 echo $ECHO_N "checking for st_blocks in struct stat... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF diff --git a/configure.in b/configure.in index a0a6c2f..8d736d0 100644 --- a/configure.in +++ b/configure.in @@ -537,7 +537,8 @@ dnl ---------------------------------------------------------------------- dnl Check for these two functions before <sys/time.h> is checked for, otherwise dnl they are not detected correctly on Solaris [2.6]. dnl -AC_CHECK_FUNCS(difftime gettimeofday) +AC_CHECK_FUNCS(difftime) +AC_CHECK_FUNCS([gettimeofday], [have_gettime="yes"], [have_gettime="no"]) dnl Unix AC_CHECK_HEADERS([sys/resource.h sys/time.h unistd.h sys/ioctl.h sys/stat.h]) @@ -1495,9 +1496,39 @@ AC_TRY_COMPILE([ #include <time.h>],[struct timezone tz; tz.tz_minuteswest=0;], AC_DEFINE(HAVE_STRUCT_TIMEZONE, 1, [Define if \`struct timezone' is defined]) +have_struct_tz="yes" AC_MSG_RESULT(yes), AC_MSG_RESULT(no)) +dnl If gettimeofday() is going to be used, make sure it uses the timezone struct + +if test "$have_gettime" = "yes" -a "$have_struct_tz" = "yes"; then + AC_MSG_CHECKING(whether gettimeofday() gives timezone) + AC_TRY_RUN([ + #include <time.h> + #include <sys/time.h> + int main(void) + { + struct timeval tv; + struct timezone tz; + tz.tz_minuteswest = 7777; /* Initialize to an unreasonable number */ + tz.tz_dsttime = 7; + gettimeofday(&tv, &tz); + /* Check whether the function returned any value at all */ + if(tz.tz_minuteswest == 7777 && tz.tz_dsttime == 7) + exit(1); + else exit (0); + }], [hdf5_use_tz="yes"], [hdf5_use_tz="no"],) + + if test "$hdf5_use_tz" = "yes"; then + AC_MSG_RESULT([yes]) + AC_DEFINE([GETTIMEOFDAY_GIVES_TZ], [1], + [Define if gettimeofday() populates the tz pointer passed in]) + else + AC_MSG_RESULT([no]) + fi +fi + dnl ---------------------------------------------------------------------- dnl Does the struct stat have the st_blocks field? This field is not Posix. dnl diff --git a/src/H5Omtime.c b/src/H5Omtime.c index ac99bc1..2c53950 100644 --- a/src/H5Omtime.c +++ b/src/H5Omtime.c @@ -233,15 +233,17 @@ H5O_mtime_decode(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const uint8_t *p, /* Irix5.3 */ { struct timezone tz; + if (HDBSDgettimeofday(NULL, &tz)<0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to obtain local timezone information"); the_time -= tz.tz_minuteswest * 60 - (tm.tm_isdst ? 3600 : 0); } -#elif defined(H5_HAVE_GETTIMEOFDAY) && defined(H5_HAVE_STRUCT_TIMEZONE) +#elif defined(H5_HAVE_GETTIMEOFDAY) && defined(H5_HAVE_STRUCT_TIMEZONE) && defined(H5_GETTIMEOFDAY_GIVES_TZ) { struct timezone tz; + struct timeval tv; /* Used as a placebo; some systems don't like NULL */ - if (HDgettimeofday(NULL, &tz) < 0) + if (HDgettimeofday(&tv, &tz) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to obtain local timezone information"); the_time -= tz.tz_minuteswest * 60 - (tm.tm_isdst ? 3600 : 0); @@ -250,12 +252,13 @@ H5O_mtime_decode(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const uint8_t *p, { struct timeb timebuffer; long tz; - + ftime(&timebuffer); tz = timebuffer.timezone; /* daylight is not handled properly. Currently we just hard-code the problem. */ - the_time -= tz*60; +/* the_time -= tz * 60; */ + the_time -= tz * 60 - 3600; /* the_time -= tz * 60 - 3600 * _daylight;*/ } #else diff --git a/src/H5config.h.in b/src/H5config.h.in index e6c92d7..f91986b 100644 --- a/src/H5config.h.in +++ b/src/H5config.h.in @@ -356,6 +356,9 @@ /* Define if `__tm_gmtoff' is a member of `struct tm' */ #undef HAVE___TM_GMTOFF +/* Define if gettimeofday() populates the tz pointer passed in */ +#undef GETTIMEOFDAY_GIVES_TZ + /* Define if your system's `MPI_File_set_size' function works for files over 2GB. */ #undef MPI_FILE_SET_SIZE_BIG diff --git a/test/mtime.c b/test/mtime.c index f92465a..a3a3652 100644 --- a/test/mtime.c +++ b/test/mtime.c @@ -74,14 +74,14 @@ main(void) /* Create the file, create a dataset, then close the file */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) - return 1; - if ((space=H5Screate_simple(1, size, NULL))<0) return 1; + TEST_ERROR; + if ((space=H5Screate_simple(1, size, NULL))<0) TEST_ERROR; if ((dset=H5Dcreate(file, "dset", H5T_NATIVE_SCHAR, space, H5P_DEFAULT))<0) - return 1; + TEST_ERROR; now = time(NULL); - if (H5Dclose(dset)<0) return 1; - if (H5Sclose(space)<0) return 1; - if (H5Fclose(file)<0) return 1; + if (H5Dclose(dset)<0) TEST_ERROR; + if (H5Sclose(space)<0) TEST_ERROR; + if (H5Fclose(file)<0) TEST_ERROR; /* * Open the file and get the modification time. We'll test the new @@ -89,21 +89,21 @@ main(void) * knowing its name. */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if ((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl))<0) return 1; - if (H5Gget_objinfo(file, "dset", TRUE, &sb1)<0) return 1; - if ((dset=H5Dopen(file, "dset"))<0) return 1; - if (H5Gget_objinfo(dset, ".", TRUE, &sb2)<0) return 1; - if (H5Dclose(dset)<0) return 1; - if (H5Fclose(file)<0) return 1; + if ((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl))<0) TEST_ERROR; + if (H5Gget_objinfo(file, "dset", TRUE, &sb1)<0) TEST_ERROR; + if ((dset=H5Dopen(file, "dset"))<0) TEST_ERROR; + if (H5Gget_objinfo(dset, ".", TRUE, &sb2)<0) TEST_ERROR; + if (H5Dclose(dset)<0) TEST_ERROR; + if (H5Fclose(file)<0) TEST_ERROR; /* Compare times from the two ways of calling H5Gget_objinfo() */ if (sb1.objno[0]!=sb2.objno[0] || sb1.objno[1]!=sb2.objno[1] || sb1.mtime!=sb2.mtime) { - H5_FAILED(); + H5_FAILED(); puts(" Calling H5Gget_objinfo() with the dataset ID returned"); puts(" different values than calling it with a file and dataset"); puts(" name."); - return 1; + goto error; } /* Compare times -- they must be within 60 seconds of one another */ @@ -114,13 +114,13 @@ main(void) puts(" cannot be queried on this system. See H5O_mtime_decode()."); return 0; } else if (fabs(HDdifftime(now, sb1.mtime))>60.0) { - H5_FAILED(); + H5_FAILED(); tm = localtime(&(sb1.mtime)); strftime((char*)buf1, sizeof buf1, "%Y-%m-%d %H:%M:%S", tm); tm = localtime(&now); strftime((char*)buf2, sizeof buf2, "%Y-%m-%d %H:%M:%S", tm); printf(" got: %s\n ans: %s\n", buf1, buf2); - return 1; + goto error; } PASSED(); @@ -140,14 +140,21 @@ main(void) file = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT); if (file >= 0){ if(H5Gget_objinfo(file, "/Dataset1", TRUE, &sb1)<0) - return 1; - if(sb1.mtime!=MTIME1) return 1; - if (H5Fclose(file)<0) return 1; + TEST_ERROR; + if(sb1.mtime!=MTIME1) { + H5_FAILED(); + /* If this fails, examine H5Omtime.c. Modification time is very + * system dependant (e.g., on Windows DST must be hardcoded). */ + puts(" Old modification time incorrect"); + goto error; + } + if (H5Fclose(file)<0) TEST_ERROR; } else { + H5_FAILED(); printf("***cannot open the pre-created old modification test file (%s)\n", testfile); - return 1; + goto error; } /* end else */ } PASSED(); @@ -168,14 +175,19 @@ main(void) file = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT); if (file >= 0){ if(H5Gget_objinfo(file, "/Dataset1", TRUE, &sb2)<0) - return 1; - if(sb2.mtime!=MTIME2) return 1; - if (H5Fclose(file)<0) return 1; + TEST_ERROR; + if(sb2.mtime!=MTIME2) { + H5_FAILED(); + puts(" Modification time incorrect."); + goto error; + } + if (H5Fclose(file)<0) TEST_ERROR; } else { + H5_FAILED(); printf("***cannot open the pre-created old modification test file (%s)\n", testfile); - return 1; + goto error; } /* end else */ } PASSED(); @@ -184,6 +196,11 @@ main(void) puts("All modification time tests passed."); h5_cleanup(FILENAME, fapl); return 0; + + /* Something broke */ + error: + return 1; } + |