diff options
-rw-r--r-- | config/cmake/H5pubconf.h.in | 4 | ||||
-rw-r--r-- | configure.ac | 29 | ||||
-rw-r--r-- | src/H5Iint.c | 8 | ||||
-rw-r--r-- | src/H5SL.c | 10 | ||||
-rw-r--r-- | src/H5T.c | 32 | ||||
-rw-r--r-- | src/H5Tconv.c | 24 | ||||
-rw-r--r-- | src/H5system.c | 1 | ||||
-rw-r--r-- | test/big.c | 20 | ||||
-rw-r--r-- | test/ntypes.c | 15 | ||||
-rw-r--r-- | test/vol.c | 11 |
10 files changed, 80 insertions, 74 deletions
diff --git a/config/cmake/H5pubconf.h.in b/config/cmake/H5pubconf.h.in index 37e8746..ca26447 100644 --- a/config/cmake/H5pubconf.h.in +++ b/config/cmake/H5pubconf.h.in @@ -14,13 +14,13 @@ #ifndef H5_CONFIG_H_ #define H5_CONFIG_H_ -/* Define if the Windows virtual file driver should be compiled */ +/* Define if this is a Windows machine */ #cmakedefine H5_HAVE_WINDOWS @H5_HAVE_WINDOWS@ /* Define if using MinGW */ #cmakedefine H5_HAVE_MINGW @H5_HAVE_MINGW@ -/* Define if on the Windows platform and default WIN32 API */ +/* Define if on the Windows platform and using the Win32 API */ #cmakedefine H5_HAVE_WIN32_API @H5_HAVE_WIN32_API@ /* Define if using a Windows compiler (i.e. Visual Studio) */ diff --git a/configure.ac b/configure.ac index 7659c8c..994b31a 100644 --- a/configure.ac +++ b/configure.ac @@ -1461,7 +1461,12 @@ case "$host_cpu-$host_vendor-$host_os" in ## VFD on Linux systems. H5_CPPFLAGS="-D_GNU_SOURCE $H5_CPPFLAGS" ;; - + *mingw*) + AC_DEFINE([HAVE_WINDOWS], [1], [Define if this is a Windows machine]) + AC_DEFINE([HAVE_WIN32_API], [1], [Define if on the Windows platform using the Win32 API]) + AC_DEFINE([HAVE_MINGW], [1], [Define if using MinGW]) + H5_CPPFLAGS="-D_GNU_SOURCE -D__USE_MINGW_ANSI_STDIO $H5_CPPFLAGS" + ;; esac ## Need to add the AM_ and H5_ into CFLAGS/CPPFLAGS to make them visible @@ -1737,6 +1742,7 @@ if test "x$HAVE_SZLIB" = "xyes" -a "x$HAVE_SZLIB_H" = "xyes"; then LL_PATH="$LD_LIBRARY_PATH" + # CROSS-COMPILING: Assume 'yes' now that libaec is so prevalent AC_CACHE_VAL([hdf5_cv_szlib_can_encode], [AC_RUN_IFELSE( [AC_LANG_PROGRAM([ @@ -1745,7 +1751,7 @@ if test "x$HAVE_SZLIB" = "xyes" -a "x$HAVE_SZLIB_H" = "xyes"; then /* SZ_encoder_enabled returns 1 if encoder is present */ return SZ_encoder_enabled() != 1; ]])] - , [hdf5_cv_szlib_can_encode=yes], [hdf5_cv_szlib_can_encode=no],)] + , [hdf5_cv_szlib_can_encode=yes], [hdf5_cv_szlib_can_encode=no], [hdf5_cv_szlib_can_encode=yes])] ) AC_DEFINE([HAVE_FILTER_SZIP], [1], @@ -1928,8 +1934,8 @@ if test "X$THREADSAFE" = "Xyes"; then ## supported a priori. POSIX.1-2001 requires that a conformant ## system need only support one of SYSTEM or PROCESS scopes. ## - ## For cross-compiling, we've added a pessimistic 'no'. You can - ## hand-hack the config file if you know otherwise. + ## CROSS-COMPILING: Use a pessimistic 'no'. You can hand-hack the config + ## file if you know otherwise. AC_MSG_CHECKING([Pthreads supports system scope]) AC_CACHE_VAL([hdf5_cv_system_scope_threads], [AC_RUN_IFELSE( @@ -3433,6 +3439,7 @@ esac ## The machine's conversion gets the correct value. We define the macro and disable ## this kind of test until we figure out what algorithm they use. ## +## CROSS-COMPILING: Assume 'no' AC_MSG_CHECKING([if using special algorithm to convert long double to (unsigned) long values]) ## NOTE: Place all configure test programs into cmake's source file, then use a preprocessor directive @@ -3447,7 +3454,7 @@ else AC_CACHE_VAL([hdf5_cv_ldouble_to_long_special], [AC_RUN_IFELSE( [AC_LANG_SOURCE([$TEST_SRC])] - , [hdf5_cv_ldouble_to_long_special=yes], [hdf5_cv_ldouble_to_long_special=no],)]) + , [hdf5_cv_ldouble_to_long_special=yes], [hdf5_cv_ldouble_to_long_special=no], [hdf5_cv_ldouble_to_long_special=no])]) fi if test ${hdf5_cv_ldouble_to_long_special} = "yes"; then @@ -3466,6 +3473,7 @@ fi ## ..., 7fffff..., the compiler uses a unknown algorithm. We define a ## macro and skip the test for now until we know about the algorithm. ## +## CROSS-COMPILING: Assume 'no' AC_MSG_CHECKING([if using special algorithm to convert (unsigned) long to long double values]) TEST_SRC="`(echo \"#define H5_LONG_TO_LDOUBLE_SPECIAL_TEST 1\"; cat $srcdir/config/cmake/ConversionTests.c)`" @@ -3476,7 +3484,7 @@ else AC_CACHE_VAL([hdf5_cv_long_to_ldouble_special], [AC_RUN_IFELSE( [AC_LANG_SOURCE([$TEST_SRC])] - , [hdf5_cv_long_to_ldouble_special=yes], [hdf5_cv_long_to_ldouble_special=no],)]) + , [hdf5_cv_long_to_ldouble_special=yes], [hdf5_cv_long_to_ldouble_special=no], [hdf5_cv_long_to_ldouble_special=no])]) fi if test ${hdf5_cv_long_to_ldouble_special} = "yes"; then @@ -3498,6 +3506,7 @@ fi ## 0x4351ccf385ebc8a0ffcc... will make the converted values wildly wrong. ## This test detects this wrong behavior and disable the test. ## +## CROSS-COMPILING: Assume 'yes' AC_MSG_CHECKING([if correctly converting long double to (unsigned) long long values]) TEST_SRC="`(echo \"#define H5_LDOUBLE_TO_LLONG_ACCURATE_TEST 1\"; cat $srcdir/config/cmake/ConversionTests.c)`" @@ -3507,7 +3516,7 @@ if test ${ac_cv_sizeof_long_double} = 0; then else AC_CACHE_VAL([hdf5_cv_ldouble_to_llong_accurate], [AC_RUN_IFELSE([AC_LANG_SOURCE([$TEST_SRC])], - [hdf5_cv_ldouble_to_llong_accurate=yes], [hdf5_cv_ldouble_to_llong_accurate=no],[])]) + [hdf5_cv_ldouble_to_llong_accurate=yes], [hdf5_cv_ldouble_to_llong_accurate=no], [hdf5_cv_ldouble_to_llong_accurate=yes])]) fi if test ${hdf5_cv_ldouble_to_llong_accurate} = "yes"; then @@ -3527,6 +3536,7 @@ fi ## When the bit sequences are 003fff..., 007fff..., 00ffff..., 01ffff..., ## ..., 7fffff..., the converted values are twice as big as they should be. ## +## CROSS-COMPILING: Assume 'yes' AC_MSG_CHECKING([if correctly converting (unsigned) long long to long double values]) TEST_SRC="`(echo \"#define H5_LLONG_TO_LDOUBLE_CORRECT_TEST 1\"; cat $srcdir/config/cmake/ConversionTests.c)`" @@ -3536,7 +3546,7 @@ if test ${ac_cv_sizeof_long_double} = 0; then else AC_CACHE_VAL([hdf5_cv_llong_to_ldouble_correct], [AC_RUN_IFELSE([AC_LANG_SOURCE([$TEST_SRC])], - [hdf5_cv_llong_to_ldouble_correct=yes], [hdf5_cv_llong_to_ldouble_correct=no],[])]) + [hdf5_cv_llong_to_ldouble_correct=yes], [hdf5_cv_llong_to_ldouble_correct=no], [hdf5_cv_llong_to_ldouble_correct=yes])]) fi if test ${hdf5_cv_llong_to_ldouble_correct} = "yes"; then @@ -3551,6 +3561,7 @@ fi ## Set the flag to indicate that the machine is IBM ppc64le and cannot ## accurately convert some long double values. ## +## CROSS-COMPILING: Assume 'yes' AC_MSG_CHECKING([if the system is IBM ppc64le and cannot correctly convert some long double values]) TEST_SRC="`(echo \"#define H5_DISABLE_SOME_LDOUBLE_CONV_TEST 1\"; cat $srcdir/config/cmake/ConversionTests.c)`" @@ -3560,7 +3571,7 @@ if test ${ac_cv_sizeof_long_double} = 0; then else AC_CACHE_VAL([hdf5_cv_disable_some_ldouble_conv], [AC_RUN_IFELSE([AC_LANG_SOURCE([$TEST_SRC])], - [hdf5_cv_disable_some_ldouble_conv=yes], [hdf5_cv_disable_some_ldouble_conv=no],[])]) + [hdf5_cv_disable_some_ldouble_conv=yes], [hdf5_cv_disable_some_ldouble_conv=no], [hdf5_cv_disable_some_ldouble_conv=yes])]) fi if test ${hdf5_cv_disable_some_ldouble_conv} = "yes"; then diff --git a/src/H5Iint.c b/src/H5Iint.c index 5ffac4d..8a6b7ae 100644 --- a/src/H5Iint.c +++ b/src/H5Iint.c @@ -389,9 +389,9 @@ H5I__mark_node(void *_info, void H5_ATTR_UNUSED *key, void *_udata) #ifdef H5I_DEBUG if (H5DEBUG(I)) { HDfprintf(H5DEBUG(I), - "H5I: discard type=%d obj=0x%08lx " + "H5I: discard type=%d obj=%p " "failure ignored\n", - (int)udata->type_info->cls->type, (unsigned long)(info->object)); + (int)udata->type_info->cls->type, info->object); } #endif /* H5I_DEBUG */ @@ -412,9 +412,9 @@ H5I__mark_node(void *_info, void H5_ATTR_UNUSED *key, void *_udata) #ifdef H5I_DEBUG if (H5DEBUG(I)) { HDfprintf(H5DEBUG(I), - "H5I: free type=%d obj=0x%08lx " + "H5I: free type=%d obj=%p " "failure ignored\n", - (int)udata->type_info->cls->type, (unsigned long)(info->object)); + (int)udata->type_info->cls->type, info->object); } #endif /* H5I_DEBUG */ @@ -156,9 +156,9 @@ #define H5SL_GROW(X, LVL, ERR) \ { \ /* Check if we need to increase allocation of forward pointers */ \ - if (LVL + 1 >= 1u << X->log_nalloc) { \ + if (LVL + 1 >= ((size_t)1) << X->log_nalloc) { \ H5SL_node_t **_tmp; \ - HDassert(LVL + 1 == 1U << X->log_nalloc); \ + HDassert(LVL + 1 == ((size_t)1) << X->log_nalloc); \ /* Double the amount of allocated space */ \ X->log_nalloc++; \ \ @@ -178,7 +178,7 @@ \ /* Create the new factory */ \ H5SL_fac_g[H5SL_fac_nused_g] = \ - H5FL_fac_init((1u << H5SL_fac_nused_g) * sizeof(H5SL_node_t *)); \ + H5FL_fac_init((((size_t)1) << H5SL_fac_nused_g) * sizeof(H5SL_node_t *)); \ H5SL_fac_nused_g++; \ } \ \ @@ -198,9 +198,9 @@ #define H5SL_SHRINK(X, LVL) \ { \ /* Check if we can reduce the allocation of forward pointers */ \ - if (LVL <= 1u << (X->log_nalloc - 1)) { \ + if (LVL <= ((size_t)1) << (X->log_nalloc - 1)) { \ H5SL_node_t **_tmp; \ - HDassert(LVL == 1U << (X->log_nalloc - 1)); \ + HDassert(LVL == ((size_t)1) << (X->log_nalloc - 1)); \ X->log_nalloc--; \ \ /* Allocate space for new forward pointers */ \ @@ -1503,9 +1503,9 @@ H5T_top_term_package(void) if (H5DEBUG(T)) { HDfprintf(H5DEBUG(T), "H5T: conversion function " - "0x%08lx failed to free private data for " + "0x%016zx failed to free private data for " "%s (ignored)\n", - (unsigned long)(path->conv.u.app_func), path->name); + (size_t)path->conv.u.app_func, path->name); } /* end if */ #endif H5E_clear_stack(NULL); /*ignore the error*/ @@ -1518,9 +1518,9 @@ H5T_top_term_package(void) if (H5DEBUG(T)) { HDfprintf(H5DEBUG(T), "H5T: conversion function " - "0x%08lx failed to free private data for " + "0x%016zx failed to free private data for " "%s (ignored)\n", - (unsigned long)(path->conv.u.lib_func), path->name); + (size_t)path->conv.u.lib_func, path->name); } /* end if */ #endif H5E_clear_stack(NULL); /*ignore the error*/ @@ -2632,9 +2632,9 @@ H5T__register(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, H5T_con #ifdef H5T_DEBUG if (H5DEBUG(T)) HDfprintf(H5DEBUG(T), - "H5T: conversion function 0x%08lx " + "H5T: conversion function 0x%016zx " "failed to free private data for %s (ignored)\n", - (unsigned long)(old_path->conv.u.app_func), old_path->name); + (size_t)old_path->conv.u.app_func, old_path->name); #endif } /* end if */ } /* end if */ @@ -2643,9 +2643,9 @@ H5T__register(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, H5T_con #ifdef H5T_DEBUG if (H5DEBUG(T)) HDfprintf(H5DEBUG(T), - "H5T: conversion function 0x%08lx " + "H5T: conversion function 0x%016zx " "failed to free private data for %s (ignored)\n", - (unsigned long)(old_path->conv.u.lib_func), old_path->name); + (size_t)old_path->conv.u.lib_func, old_path->name); #endif } /* end if */ (void)H5T_close_real(old_path->src); @@ -2812,9 +2812,9 @@ H5T__unregister(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, H5T_c #ifdef H5T_DEBUG if (H5DEBUG(T)) HDfprintf(H5DEBUG(T), - "H5T: conversion function 0x%08lx failed " + "H5T: conversion function 0x%016zx failed " "to free private data for %s (ignored)\n", - (unsigned long)(path->conv.u.app_func), path->name); + (size_t)path->conv.u.app_func, path->name); #endif } /* end if */ } /* end if */ @@ -2823,9 +2823,9 @@ H5T__unregister(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, H5T_c #ifdef H5T_DEBUG if (H5DEBUG(T)) HDfprintf(H5DEBUG(T), - "H5T: conversion function 0x%08lx failed " + "H5T: conversion function 0x%016zx failed " "to free private data for %s (ignored)\n", - (unsigned long)(path->conv.u.lib_func), path->name); + (size_t)path->conv.u.lib_func, path->name); #endif } /* end if */ (void)H5T_close_real(path->src); @@ -5220,8 +5220,8 @@ H5T__path_find_real(const H5T_t *src, const H5T_t *dst, const char *name, H5T_co (size_t)0, NULL, NULL, H5CX_get_dxpl()) < 0) { #ifdef H5T_DEBUG if (H5DEBUG(T)) - HDfprintf(H5DEBUG(T), "H5T: conversion function 0x%08lx free failed for %s (ignored)\n", - (unsigned long)(path->conv.u.app_func), path->name); + HDfprintf(H5DEBUG(T), "H5T: conversion function 0x%016zx free failed for %s (ignored)\n", + (size_t)path->conv.u.app_func, path->name); #endif H5E_clear_stack(NULL); /*ignore the failure*/ } /* end if */ @@ -5230,8 +5230,8 @@ H5T__path_find_real(const H5T_t *src, const H5T_t *dst, const char *name, H5T_co (size_t)0, NULL, NULL) < 0) { #ifdef H5T_DEBUG if (H5DEBUG(T)) - HDfprintf(H5DEBUG(T), "H5T: conversion function 0x%08lx free failed for %s (ignored)\n", - (unsigned long)(path->conv.u.lib_func), path->name); + HDfprintf(H5DEBUG(T), "H5T: conversion function 0x%016zx free failed for %s (ignored)\n", + (size_t)path->conv.u.lib_func, path->name); #endif H5E_clear_stack(NULL); /*ignore the failure*/ } /* end if */ diff --git a/src/H5Tconv.c b/src/H5Tconv.c index 93ca59f..8118eb0 100644 --- a/src/H5Tconv.c +++ b/src/H5Tconv.c @@ -887,7 +887,17 @@ done: /* Macro defining action on source data which needs to be aligned (before main action) */ #define H5T_CONV_LOOP_PRE_SALIGN(ST) \ { \ - H5MM_memcpy(&src_aligned, src, sizeof(ST)); \ + /* The uint8_t * cast is required to avoid tripping over undefined behavior. \ + * \ + * The typed pointer arrives via a void pointer, which may have any alignment. \ + * We then cast it to a pointer to a type that is assumed to be aligned, which \ + * is undefined behavior (section 6.3.2.3 paragraph 7 of the C99 standard). \ + * In the past this hasn't caused many problems, but in some cases (e.g. \ + * converting long doubles on macOS), an optimizing compiler might do the \ + * wrong thing (in the macOS case, the conversion uses SSE, which has stricter \ + * requirements about alignment). \ + */ \ + H5MM_memcpy(&src_aligned, (const uint8_t *)src, sizeof(ST)); \ } /* Macro defining action on source data which doesn't need to be aligned (before main action) */ @@ -919,7 +929,17 @@ done: /* Macro defining action on destination data which needs to be aligned (after main action) */ #define H5T_CONV_LOOP_POST_DALIGN(DT) \ { \ - H5MM_memcpy(dst, &dst_aligned, sizeof(DT)); \ + /* The uint8_t * cast is required to avoid tripping over undefined behavior. \ + * \ + * The typed pointer arrives via a void pointer, which may have any alignment. \ + * We then cast it to a pointer to a type that is assumed to be aligned, which \ + * is undefined behavior (section 6.3.2.3 paragraph 7 of the C99 standard). \ + * In the past this hasn't caused many problems, but in some cases (e.g. \ + * converting long doubles on macOS), an optimizing compiler might do the \ + * wrong thing (in the macOS case, the conversion uses SSE, which has stricter \ + * requirements about alignment). \ + */ \ + H5MM_memcpy((uint8_t *)dst, &dst_aligned, sizeof(DT)); \ } /* Macro defining action on destination data which doesn't need to be aligned (after main action) */ diff --git a/src/H5system.c b/src/H5system.c index ecaa0f6..8991f6a 100644 --- a/src/H5system.c +++ b/src/H5system.c @@ -983,6 +983,7 @@ Wstrcasestr_wrap(const char *haystack, const char *needle) else return StrStrIA(haystack, needle); } + #endif /* H5_HAVE_WIN32_API */ /* dirname() and basename() are not easily ported to Windows and basename @@ -11,12 +11,6 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Robb Matzke - * Wednesday, April 8, 1998 - * Modified: Albert Cheng - * September 11, 2010 - */ -/* * The purpose of this test is to verify if a virtual file driver can handle: * a. Large file (2GB) * This should exceed 32bits I/O system since offset is a signed @@ -62,12 +56,6 @@ #define MAX_TRIES 100 -#if H5_SIZEOF_LONG_LONG >= 8 -#define GB8LL ((unsigned long long)8 * 1024 * 1024 * 1024) -#else -#define GB8LL 0 /*cannot do the test*/ -#endif - /* Define Small, Large, Extra Large, Huge File which * correspond to less than 2GB, 2GB, 4GB, and tens of GB file size. * NO_FILE stands for "no file" to be tested. @@ -330,7 +318,7 @@ static int writer(char *filename, hid_t fapl, fsizes_t testsize, int wrt_n) { hsize_t size1[4] = {8, 1024, 1024, 1024}; - hsize_t size2[1] = {GB8LL}; + hsize_t size2[1] = {8LL * 1024LL * 1024LL * 1024LL}; hsize_t hs_start[1]; hsize_t hs_size[1]; hid_t file = -1, space1 = -1, space2 = -1, mem_space = -1, d1 = -1, d2 = -1; @@ -689,12 +677,6 @@ test_family(hid_t fapl) * because we would generate multi-gigabyte files. */ HDputs("Checking if file system is adequate for this test..."); - if (sizeof(long long) < 8 || 0 == GB8LL) { - HDputs("Test skipped because sizeof(long long) is too small. This"); - HDputs("hardware apparently doesn't support 64-bit integer types."); - usage(); - goto quit; - } if (!sparse_support) { HDputs("Test skipped because file system does not support holes."); usage(); diff --git a/test/ntypes.c b/test/ntypes.c index 92b2896..707c71d 100644 --- a/test/ntypes.c +++ b/test/ntypes.c @@ -381,10 +381,7 @@ test_compound_dtype2(hid_t file) #else #error "Unknown 'long' size" #endif -#if H5_SIZEOF_LONG_LONG == 4 - if (H5Tinsert(tid2, "ll2", HOFFSET(s2, ll2), H5T_STD_I32BE) < 0) - TEST_ERROR; -#elif H5_SIZEOF_LONG_LONG == 8 +#if H5_SIZEOF_LONG_LONG == 8 if (H5Tinsert(tid2, "ll2", HOFFSET(s2, ll2), H5T_STD_I64BE) < 0) TEST_ERROR; #else @@ -397,10 +394,7 @@ test_compound_dtype2(hid_t file) TEST_ERROR; if (H5Tinsert(tid, "st", HOFFSET(s1, st), tid2) < 0) TEST_ERROR; -#if H5_SIZEOF_LONG_LONG == 4 - if (H5Tinsert(tid, "l", HOFFSET(s1, l), H5T_STD_U32BE) < 0) - TEST_ERROR; -#elif H5_SIZEOF_LONG_LONG == 8 +#if H5_SIZEOF_LONG_LONG == 8 if (H5Tinsert(tid, "l", HOFFSET(s1, l), H5T_STD_U64BE) < 0) TEST_ERROR; #else @@ -532,10 +526,7 @@ test_compound_dtype2(hid_t file) TEST_ERROR; if (H5Tget_order(mem_id) != H5Tget_order(H5T_NATIVE_LLONG)) TEST_ERROR; -#if H5_SIZEOF_LONG_LONG == 4 - if (H5Tget_size(mem_id) < H5Tget_size(H5T_STD_I32LE)) - TEST_ERROR; -#elif H5_SIZEOF_LONG_LONG == 8 +#if H5_SIZEOF_LONG_LONG == 8 if (H5Tget_size(mem_id) < H5Tget_size(H5T_STD_I64LE)) TEST_ERROR; #else @@ -573,9 +573,9 @@ reg_opt_datatype_get(void H5_ATTR_UNUSED *obj, H5VL_datatype_get_args_t *args, h static herr_t fake_vol_info_to_str(const void *info, char **str) { - herr_t ret_value = SUCCEED; /* Return value */ - const int val = *(const int *)info; - const int str_size = 16; /* The size of the string */ + const int val = *(const int *)info; + const size_t str_size = 16; /* The size of the string */ + herr_t ret_value = SUCCEED; /* Verify the info is correct before continuing */ if (val != INT_MAX) { @@ -584,9 +584,10 @@ fake_vol_info_to_str(const void *info, char **str) } /* Allocate the string long enough for the info */ - *str = (char *)malloc(str_size); + if (NULL == (*str = (char *)HDcalloc(1, str_size))) + return FAIL; - HDsnprintf(*str, str_size, "%d", *((const int *)info)); + HDsnprintf(*str, str_size, "%d", val); return ret_value; } /* end fake_vol_info_to_str() */ |