From 528e0d1cac689310beecf02e56a10b764afa2651 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Mon, 8 Jul 2013 10:52:49 -0500 Subject: [svn-r23869] HDFFV-8302: replace (v)snprintf with _(v)snprintf for windows. Merge from trunk along with other windows functions and HD prefix corrections. HDFFV-8394: Add cmake code to package examples Tested: local linux --- CMakeLists.txt | 196 ++++++++++++++++++++++++++++++++-- MANIFEST | 4 + config/cmake/CTestCustom.cmake | 2 +- config/cmake/HDF518_Examples.cmake.in | 112 +++++++++++++++++++ config/cmake/cacheinit.cmake | 3 +- hl/c++/test/ptableTest.cpp | 17 +++ hl/examples/ex_image2.c | 8 ++ hl/src/H5IM.c | 4 +- hl/src/H5LT.c | 87 ++++++++------- hl/src/H5LTanalyze.c | 32 +++--- hl/src/H5LTanalyze.l | 4 + hl/src/H5LTparse.y | 4 + hl/test/test_image.c | 9 ++ perform/sio_standalone.h | 23 +++- perform/zip_perf.c | 150 +++++++++++++------------- release_docs/USING_CMake_Examples.txt | 12 +++ src/H5FDstdio.c | 4 + src/H5system.c | 24 +++++ src/H5win32defs.h | 10 +- 19 files changed, 559 insertions(+), 146 deletions(-) create mode 100644 config/cmake/HDF518_Examples.cmake.in create mode 100644 release_docs/USING_CMake_Examples.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 4d9c2b2..bef95d0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -463,6 +463,155 @@ IF (HDF5_DISABLE_COMPILER_WARNINGS) ENDIF (HDF5_DISABLE_COMPILER_WARNINGS) #----------------------------------------------------------------------------- +# CDash is configured to only allow 3000 warnings, so +# break into groups (from the config/gnu-flags file) +#----------------------------------------------------------------------------- +IF (NOT MSVC) + # Append warning flags + # Don't use the '-Wtraditional' flag, we're way past having K&R C code + # SET (H5_CFLAGS "${H5_CFLAGS} -Wtraditional") + # Don't use the '-Wtraditional-conversion' flag, there's too many warnings + # from GCC's assert macro + # SET (H5_CFLAGS "${H5_CFLAGS} -Wtraditional-conversion") + + # Append warning flags from gcc-3* case + # (don't use -Wpadded flag for normal builds, many of the warnings its + # issuing can't be fixed and they are making it hard to detect other, + # more important warnings) + #SET (H5_CFLAGS "${H5_CFLAGS} -Wfloat-equal -Wmissing-format-attribute -Wpadded") + SET (H5_CFLAGS1 "${H5_CFLAGS1} -Wfloat-equal -Wmissing-format-attribute") + + # Append warning flags from gcc-3.2* case + SET (H5_CFLAGS1 "${H5_CFLAGS1} -Wmissing-noreturn -Wpacked -Wdisabled-optimization") + + # Enable more format checking flags, beyond the basic -Wformat included + # in -Wall + SET (H5_CFLAGS1 "${H5_CFLAGS1} -Wformat=2") + + # The "unreachable code" warning appears to be reliable now... + # (this warning was removed in gcc 4.5+) + #SET (H5_CFLAGS "${H5_CFLAGS} -Wunreachable-code") + + # Append warning flags from gcc-3.3* case + SET (H5_CFLAGS1 "${H5_CFLAGS1} -Wendif-labels") + + # Append warning flags from gcc-3.4* case + SET (H5_CFLAGS2 "${H5_CFLAGS2} -Wdeclaration-after-statement -Wold-style-definition -Winvalid-pch") + + # Append more extra warning flags that only gcc4.0+ know about + SET (H5_CFLAGS2 "${H5_CFLAGS2} -Wvariadic-macros -Winit-self -Wmissing-include-dirs -Wswitch-default -Wswitch-enum -Wunused-macros") + + # Append more extra warning flags that only gcc 4.1+ know about + SET (H5_CFLAGS3 "${H5_CFLAGS3} -Wunsafe-loop-optimizations -Wc++-compat") + + # Append more extra warning flags that only gcc 4.2+ know about + SET (H5_CFLAGS3 "${H5_CFLAGS3} -Wstrict-overflow") + + # Append more extra warning flags that only gcc 4.3+ know about + # + # Technically, variable-length arrays are part of the C99 standard, but + # we should approach them a bit cautiously... -QAK + SET (H5_CFLAGS3 "${H5_CFLAGS3} -Wlogical-op -Wlarger-than=2048 -Wvla") + + # Append more extra warning flags that only gcc 4.4+ know about + SET (H5_CFLAGS3 "${H5_CFLAGS4} -Wsync-nand -Wframe-larger-than=16384 -Wpacked-bitfield-compat") + + # Append more extra warning flags that only gcc 4.5+ know about + SET (H5_CFLAGS4 "${H5_CFLAGS4} -Wstrict-overflow=5 -Wjump-misses-init -Wunsuffixed-float-constants") + + # Append more extra warning flags that only gcc 4.6+ know about + SET (H5_CFLAGS4 "${H5_CFLAGS5} -Wdouble-promotion -Wsuggest-attribute=const -Wtrampolines") + + # Append more extra warning flags that only gcc 4.7+ know about + SET (H5_CFLAGS4 "${H5_CFLAGS5} -Wstack-usage=8192 -Wvector-operation-performance -Wsuggest-attribute=pure -Wsuggest-attribute=noreturn") +ENDIF (NOT MSVC) + +#----------------------------------------------------------------------------- +# Option to allow the user to enable all warnings +#----------------------------------------------------------------------------- +OPTION (HDF5_ENABLE_ALL_WARNINGS "Enable all warnings" OFF) +IF (HDF5_ENABLE_ALL_WARNINGS) + IF (MSVC) + STRING (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") + SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Wall") + STRING (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Wall") + ELSE (MSVC) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -pedantic ${H5_CFLAGS1} ${H5_CFLAGS2} ${H5_CFLAGS3} ${H5_CFLAGS4}") + ENDIF (MSVC) +ENDIF (HDF5_ENABLE_ALL_WARNINGS) + +#----------------------------------------------------------------------------- +# Option to allow the user to enable warnings by groups +#----------------------------------------------------------------------------- +OPTION (HDF5_ENABLE_GROUPZERO_WARNINGS "Enable group zero warnings" OFF) +IF (HDF5_ENABLE_GROUPZERO_WARNINGS) + IF (MSVC) + STRING (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") + SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W1") + STRING (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W1") + ELSE (MSVC) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -pedantic") + ENDIF (MSVC) +ENDIF (HDF5_ENABLE_GROUPZERO_WARNINGS) + +#----------------------------------------------------------------------------- +# Option to allow the user to enable warnings by groups +#----------------------------------------------------------------------------- +OPTION (HDF5_ENABLE_GROUPONE_WARNINGS "Enable group one warnings" OFF) +IF (HDF5_ENABLE_GROUPONE_WARNINGS) + IF (MSVC) + STRING (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") + SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W2") + STRING (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W2") + ELSE (MSVC) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${H5_CFLAGS1}") + ENDIF (MSVC) +ENDIF (HDF5_ENABLE_GROUPONE_WARNINGS) + +#----------------------------------------------------------------------------- +# Option to allow the user to enable warnings by groups +#----------------------------------------------------------------------------- +OPTION (HDF5_ENABLE_GROUPTWO_WARNINGS "Enable group two warnings" OFF) +IF (HDF5_ENABLE_GROUPTWO_WARNINGS) + IF (MSVC) + STRING (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") + SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3") + STRING (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3") + ELSE (MSVC) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${H5_CFLAGS2}") + ENDIF (MSVC) +ENDIF (HDF5_ENABLE_GROUPTWO_WARNINGS) + +#----------------------------------------------------------------------------- +# Option to allow the user to enable warnings by groups +#----------------------------------------------------------------------------- +OPTION (HDF5_ENABLE_GROUPTHREE_WARNINGS "Enable group three warnings" OFF) +IF (HDF5_ENABLE_GROUPTHREE_WARNINGS) + IF (MSVC) + STRING (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") + SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4") + STRING (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4") + ELSE (MSVC) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${H5_CFLAGS3}") + ENDIF (MSVC) +ENDIF (HDF5_ENABLE_GROUPTHREE_WARNINGS) + +#----------------------------------------------------------------------------- +# Option to allow the user to enable warnings by groups +#----------------------------------------------------------------------------- +OPTION (HDF5_ENABLE_GROUPFOUR_WARNINGS "Enable group four warnings" OFF) +IF (HDF5_ENABLE_GROUPFOUR_WARNINGS) + IF (NOT MSVC) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${H5_CFLAGS4}") + ENDIF (NOT MSVC) +ENDIF (HDF5_ENABLE_GROUPFOUR_WARNINGS) + +#----------------------------------------------------------------------------- # This is in here to help some of the GCC based IDES like Eclipse # and code blocks parse the compiler errors and warnings better. #----------------------------------------------------------------------------- @@ -543,12 +692,10 @@ HDF5_SETUP_FILTERS (NBIT) HDF5_SETUP_FILTERS (SCALEOFFSET) INCLUDE (ExternalProject) -OPTION (HDF5_ALLOW_EXTERNAL_SUPPORT "Allow External Library Building" "NO") -OPTION (ZLIB_USE_EXTERNAL "Use External Library Building for ZLIB" 0) -OPTION (SZIP_USE_EXTERNAL "Use External Library Building for SZIP" 0) +OPTION (HDF5_ALLOW_EXTERNAL_SUPPORT "Allow External Library Building (NO SVN TGZ)" "NO") IF (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "SVN" OR HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ") - SET (ZLIB_USE_EXTERNAL 1) - SET (SZIP_USE_EXTERNAL 1) + OPTION (ZLIB_USE_EXTERNAL "Use External Library Building for ZLIB" 1) + OPTION (SZIP_USE_EXTERNAL "Use External Library Building for SZIP" 1) IF (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "SVN") SET (ZLIB_URL ${ZLIB_SVN_URL}) SET (SZIP_URL ${SZIP_SVN_URL}) @@ -558,6 +705,9 @@ IF (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "SVN" OR HDF5_ALLOW_EXTERNAL_SUPPORT MAT ENDIF (NOT TGZ_PATH) SET (ZLIB_URL ${TGZ_PATH}/${ZLIB_TGZ_NAME}) SET (SZIP_URL ${TGZ_PATH}/${SZIP_TGZ_NAME}) + ELSE (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "SVN") + SET (ZLIB_USE_EXTERNAL 0) + SET (SZIP_USE_EXTERNAL 0) ENDIF (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "SVN") ENDIF (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "SVN" OR HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ") @@ -949,6 +1099,31 @@ INSTALL ( ) #----------------------------------------------------------------------------- +# Configure the HDF518_Examples.cmake file and the examples +#----------------------------------------------------------------------------- +OPTION (HDF5_PACK_EXAMPLES_FILE "Package the HDF5 Library Examples Compressed File" OFF) +IF (HDF5_PACK_EXAMPLES_FILE) + CONFIGURE_FILE ( + ${HDF5_RESOURCES_DIR}/HDF518_Examples.cmake.in + ${HDF5_BINARY_DIR}/HDF518_Examples.cmake @ONLY + ) + INSTALL ( + FILES ${HDF5_BINARY_DIR}/HDF518_Examples.cmake + DESTINATION ${HDF5_INSTALL_DATA_DIR} + COMPONENT hdfdocuments + ) + IF (EXISTS "${HDF5_EXAMPLES_COMPRESSED_PATH}/${HDF5_EXAMPLES_COMPRESSED_FILE}") + INSTALL ( + FILES + ${HDF5_EXAMPLES_COMPRESSED_PATH}/${HDF5_EXAMPLES_COMPRESSED_FILE} + ${HDF5_SOURCE_DIR}/release_docs/USING_CMake_Examples.txt + DESTINATION ${HDF5_INSTALL_DATA_DIR} + COMPONENT hdfdocuments + ) + ENDIF (EXISTS "${HDF5_EXAMPLES_COMPRESSED_PATH}/${HDF5_EXAMPLES_COMPRESSED_FILE}") +ENDIF (HDF5_PACK_EXAMPLES_FILE) + +#----------------------------------------------------------------------------- # Add Document File(s) to CMake Install #----------------------------------------------------------------------------- IF (NOT HDF5_EXTERNALLY_CONFIGURED) @@ -956,7 +1131,6 @@ IF (NOT HDF5_EXTERNALLY_CONFIGURED) FILES ${HDF5_SOURCE_DIR}/ACKNOWLEDGMENTS ${HDF5_SOURCE_DIR}/COPYING - ${HDF5_SOURCE_DIR}/README.txt DESTINATION ${HDF5_INSTALL_DATA_DIR} COMPONENT hdfdocuments ) @@ -998,12 +1172,12 @@ IF (NOT HDF5_EXTERNALLY_CONFIGURED) ${HDF5_SOURCE_DIR}/release_docs/INSTALL_parallel ) ENDIF (HDF5_ENABLE_PARALLEL) - INSTALL ( - FILES ${release_files} - DESTINATION ${HDF5_INSTALL_DATA_DIR}/release_docs - COMPONENT hdfdocuments - ) ENDIF (HDF5_PACK_INSTALL_DOCS) + INSTALL ( + FILES ${release_files} + DESTINATION ${HDF5_INSTALL_DATA_DIR} + COMPONENT hdfdocuments + ) ENDIF (EXISTS "${HDF5_SOURCE_DIR}/release_docs" AND IS_DIRECTORY "${HDF5_SOURCE_DIR}/release_docs") ENDIF (NOT HDF5_EXTERNALLY_CONFIGURED) diff --git a/MANIFEST b/MANIFEST index 2a0213a..61ba83f 100644 --- a/MANIFEST +++ b/MANIFEST @@ -2248,6 +2248,10 @@ # CMake-specific User Files ./config/cmake/UserMacros/Windows_MT.cmake +# CMake-specific Examples Files +./config/cmake/HDF518_Examples.cmake.in +./release_docs/USING_CMake_Examples.txt + ./CMakeLists.txt ./CTestConfig.cmake ./UserMacros.cmake diff --git a/config/cmake/CTestCustom.cmake b/config/cmake/CTestCustom.cmake index 76a403e..236519b 100644 --- a/config/cmake/CTestCustom.cmake +++ b/config/cmake/CTestCustom.cmake @@ -1,4 +1,4 @@ -SET (CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS 1500) +SET (CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS 3000) SET (CTEST_CUSTOM_WARNING_EXCEPTION ${CTEST_CUSTOM_WARNING_EXCEPTION} diff --git a/config/cmake/HDF518_Examples.cmake.in b/config/cmake/HDF518_Examples.cmake.in new file mode 100644 index 0000000..699e2d0 --- /dev/null +++ b/config/cmake/HDF518_Examples.cmake.in @@ -0,0 +1,112 @@ +cmake_minimum_required(VERSION 2.8.10 FATAL_ERROR) +############################################################################################################### +# This script will build and run the examples from a compressed file +# Execute from a command line: +# ctest -S HDF518_Examples.cmake,HDF5Examples-0.1.1-Source -C Release -O test.log +############################################################################################################### + +set(INSTALLDIR "@CMAKE_INSTALL_PREFIX@/@HDF5_PACKAGE_VERSION@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(STATICLIBRARIES "@H5_ENABLE_STATIC_LIB@") +set(CTEST_SOURCE_NAME ${CTEST_SCRIPT_ARG}) +set(CTEST_DASHBOARD_ROOT ${CTEST_SCRIPT_DIRECTORY}) +set(CTEST_BUILD_CONFIGURATION "Release") + +############################################################################################################### +# Adjust the following SET Commands as needed +############################################################################################################### +if(WIN32) + if(STATICLIBRARIES) + set(BUILD_OPTIONS "-DUSE_SHARED_LIBS:BOOL=OFF") + endif(STATICLIBRARIES) + set(ENV{HDF5_DIR} "${INSTALLDIR}/cmake/hdf5") + set(CTEST_BINARY_NAME ${CTEST_SOURCE_NAME}\\build) + set(CTEST_SOURCE_DIRECTORY "${CTEST_DASHBOARD_ROOT}\\${CTEST_SOURCE_NAME}") + set(CTEST_BINARY_DIRECTORY "${CTEST_DASHBOARD_ROOT}\\${CTEST_BINARY_NAME}") +else(WIN32) + if(STATICLIBRARIES) + set(BUILD_OPTIONS "-DUSE_SHARED_LIBS:BOOL=OFF -DCMAKE_ANSI_CFLAGS:STRING=-fPIC") + endif(STATICLIBRARIES) + set(ENV{HDF5_DIR} "${INSTALLDIR}/share/cmake/hdf5") + set(ENV{LD_LIBRARY_PATH} "${INSTALLDIR}/lib") + set(CTEST_BINARY_NAME ${CTEST_SOURCE_NAME}/build) + set(CTEST_SOURCE_DIRECTORY "${CTEST_DASHBOARD_ROOT}/${CTEST_SOURCE_NAME}") + set(CTEST_BINARY_DIRECTORY "${CTEST_DASHBOARD_ROOT}/${CTEST_BINARY_NAME}") +endif(WIN32) + +############################################################################################################### +# For any comments please contact cdashhelp@hdfgroup.org +# +############################################################################################################### + +#----------------------------------------------------------------------------- +# MAC machines need special option +#----------------------------------------------------------------------------- +if(APPLE) + # Compiler choice + execute_process(COMMAND xcrun --find cc OUTPUT_VARIABLE XCODE_CC OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND xcrun --find c++ OUTPUT_VARIABLE XCODE_CXX OUTPUT_STRIP_TRAILING_WHITESPACE) + set(ENV{CC} "${XCODE_CC}") + set(ENV{CXX} "${XCODE_CXX}") + # Shared fortran is not supported, build static + set(BUILD_OPTIONS "${BUILD_OPTIONS} -DBUILD_SHARED_LIBS:BOOL=OFF -DCMAKE_ANSI_CFLAGS:STRING=-fPIC") + set(BUILD_OPTIONS "${BUILD_OPTIONS} -DCTEST_USE_LAUNCHERS:BOOL=ON -DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=OFF") +endif(APPLE) + +#----------------------------------------------------------------------------- +set(CTEST_CMAKE_COMMAND "\"${CMAKE_COMMAND}\"") +## Uncompress source in tar file provided +## -------------------------- +if(WIN32) + set(CTEST_7Z_COMMAND "C:/Program Files/7-Zip/7z.exe") + message("extracting... [${CTEST_7Z_COMMAND} x ${CTEST_SOURCE_NAME}.zip]") + execute_process(COMMAND ${CTEST_7Z_COMMAND} x ${CTEST_SOURCE_NAME}.zip RESULT_VARIABLE rv) +else(WIN32) + message("extracting... [${CTEST_CMAKE_COMMAND} -E tar -xvf ${CTEST_SOURCE_NAME}.tar.gz]") + execute_process(COMMAND tar -xvf ${CTEST_SOURCE_NAME}.tar.gz RESULT_VARIABLE rv) +endif(WIN32) + +if(NOT rv EQUAL 0) + message("extracting... [error-(${rv}) clean up]") + file(REMOVE_RECURSE "${CTEST_SOURCE_DIRECTORY}") + message(FATAL_ERROR "error: extract of ${CTEST_SOURCE_NAME} failed") +endif(NOT rv EQUAL 0) + +#----------------------------------------------------------------------------- +## Clear the build directory +## -------------------------- +set(CTEST_START_WITH_EMPTY_BINARY_DIRECTORY TRUE) +file(MAKE_DIRECTORY "${CTEST_BINARY_DIRECTORY}") +ctest_empty_binary_directory(${CTEST_BINARY_DIRECTORY}) + +# Use multiple CPU cores to build +include(ProcessorCount) +ProcessorCount(N) +if(NOT N EQUAL 0) + if(NOT WIN32) + set(CTEST_BUILD_FLAGS -j${N}) + endif(NOT WIN32) + set(ctest_test_args ${ctest_test_args} PARALLEL_LEVEL ${N}) +endif() +set (CTEST_CONFIGURE_COMMAND + "${CTEST_CMAKE_COMMAND} -C \"${CTEST_SOURCE_DIRECTORY}/config/cmake/cacheinit.cmake\" -DCMAKE_BUILD_TYPE:STRING=${CTEST_BUILD_CONFIGURATION} ${BUILD_OPTIONS} \"-G${CTEST_CMAKE_GENERATOR}\" \"${CTEST_SOURCE_DIRECTORY}\"" +) + +#----------------------------------------------------------------------------- +## -- set output to english +set($ENV{LC_MESSAGES} "en_EN") + +#----------------------------------------------------------------------------- + ## NORMAL process + ## -------------------------- + CTEST_START (Experimental) + CTEST_CONFIGURE (BUILD "${CTEST_BINARY_DIRECTORY}") + CTEST_READ_CUSTOM_FILES ("${CTEST_BINARY_DIRECTORY}") + CTEST_BUILD (BUILD "${CTEST_BINARY_DIRECTORY}" APPEND) + CTEST_TEST (BUILD "${CTEST_BINARY_DIRECTORY}" APPEND ${ctest_test_args} RETURN_VALUE res) + if(res GREATER 0) + message (FATAL_ERROR "tests FAILED") + endif(res GREATER 0) +#----------------------------------------------------------------------------- +############################################################################################################## +message("DONE") \ No newline at end of file diff --git a/config/cmake/cacheinit.cmake b/config/cmake/cacheinit.cmake index 312e9f3..f76d908 100644 --- a/config/cmake/cacheinit.cmake +++ b/config/cmake/cacheinit.cmake @@ -60,7 +60,8 @@ SET (HDF5_PACKAGE_EXTLIBS OFF CACHE BOOL "(WINDOWS)CPACK - include external libr SET (HDF5_NO_PACKAGES OFF CACHE BOOL "CPACK - Disable packaging" FORCE) -SET (HDF5_ALLOW_EXTERNAL_SUPPORT "NO" CACHE STRING "Allow External Library Building" FORCE) +SET (HDF5_ALLOW_EXTERNAL_SUPPORT "NO" CACHE STRING "Allow External Library Building (NO SVN TGZ)" FORCE) +SET_PROPERTY(CACHE HDF5_ALLOW_EXTERNAL_SUPPORT PROPERTY STRINGS NO SVN TGZ) SET (ZLIB_SVN_URL "http://svn.hdfgroup.uiuc.edu/zlib/trunk" CACHE STRING "Use ZLib from HDF repository" FORCE) diff --git a/hl/c++/test/ptableTest.cpp b/hl/c++/test/ptableTest.cpp index a2b5efd..929058d 100644 --- a/hl/c++/test/ptableTest.cpp +++ b/hl/c++/test/ptableTest.cpp @@ -183,9 +183,17 @@ int TestCompoundDatatype() goto out; PASSED(); + + H5Tclose(dtypeID); return 0; out: + + H5E_BEGIN_TRY { + H5Tclose(dtypeID); + } H5E_END_TRY; + + H5_FAILED(); return 1; } @@ -515,10 +523,19 @@ int SystemTest() if(ct1[1].b != ct2[2].g.b) goto out; + H5Tclose(dtypeID1); + H5Tclose(dtypeID2); + PASSED(); return 0; out: + + H5E_BEGIN_TRY { + H5Tclose(dtypeID1); + H5Tclose(dtypeID2); + } H5E_END_TRY; + H5_FAILED(); return 1; } diff --git a/hl/examples/ex_image2.c b/hl/examples/ex_image2.c index 77398c4..76c3a75 100644 --- a/hl/examples/ex_image2.c +++ b/hl/examples/ex_image2.c @@ -46,6 +46,10 @@ int main( void ) /* make the image */ status=H5IMmake_image_8bit( file_id, IMAGE1_NAME, width, height, gbuf ); + if (gbuf) { + free(gbuf); + gbuf = NULL; + } /*------------------------------------------------------------------------- * define a palette, blue to red tones @@ -75,6 +79,10 @@ int main( void ) /* make dataset */ status=H5IMmake_image_24bit( file_id, IMAGE2_NAME, width, height, "INTERLACE_PIXEL", gbuf ); + if (gbuf) { + free(gbuf); + gbuf = NULL; + } /* close the file. */ H5Fclose( file_id ); diff --git a/hl/src/H5IM.c b/hl/src/H5IM.c index 11f4014..2621ca4 100644 --- a/hl/src/H5IM.c +++ b/hl/src/H5IM.c @@ -564,7 +564,7 @@ herr_t H5IMlink_palette( hid_t loc_id, /* close */ if(H5Sclose(asid) < 0) goto out; - if ( H5Tclose( atid ) < 0) + if(H5Tclose(atid) < 0) goto out; if(H5Aclose(aid) < 0) goto out; @@ -630,6 +630,8 @@ herr_t H5IMlink_palette( hid_t loc_id, /* close */ if(H5Sclose(asid) < 0) goto out; + if(H5Tclose(atid) < 0) + goto out; if(H5Aclose(aid) < 0) goto out; diff --git a/hl/src/H5LT.c b/hl/src/H5LT.c index 678642f..b2c8949 100644 --- a/hl/src/H5LT.c +++ b/hl/src/H5LT.c @@ -803,7 +803,7 @@ herr_t H5LTmake_dataset_string(hid_t loc_id, if((tid = H5Tcopy(H5T_C_S1)) < 0 ) goto out; - size = strlen(buf) + 1; /* extra null term */ + size = HDstrlen(buf) + 1; /* extra null term */ if(H5Tset_size(tid, size) < 0) goto out; @@ -1354,7 +1354,7 @@ find_dataset(hid_t loc_id, const char *name, const H5L_info_t *linfo, void *op_d * cause the iterator to immediately return that positive value, * indicating short-circuit success */ - if(strcmp(name, (char *)op_data) == 0) + if(HDstrcmp(name, (char *)op_data) == 0) ret = 1; return ret; @@ -1437,7 +1437,7 @@ herr_t H5LTset_attribute_string( hid_t loc_id, if ( (attr_type = H5Tcopy( H5T_C_S1 )) < 0 ) goto out; - attr_size = strlen( attr_data ) + 1; /* extra null term */ + attr_size = HDstrlen( attr_data ) + 1; /* extra null term */ if ( H5Tset_size( attr_type, (size_t)attr_size) < 0 ) goto out; @@ -1936,7 +1936,7 @@ find_attr(hid_t loc_id, const char *name, const H5A_info_t *ainfo, * cause the iterator to immediately return that positive value, * indicating short-circuit success */ - if(strcmp(name, (char *)op_data) == 0) + if(HDstrcmp(name, (char *)op_data) == 0) ret = H5_ITER_STOP; return ret; @@ -2168,17 +2168,19 @@ hid_t H5LTtext_to_dtype(const char *text, H5LT_lang_t lang_type) goto out; if(lang_type != H5LT_DDL) { - fprintf(stderr, "only DDL is supported for now.\n"); + HDfprintf(stderr, "only DDL is supported for now.\n"); goto out; } - input_len = strlen(text); - myinput = strdup(text); + input_len = HDstrlen(text); + myinput = HDstrdup(text); - if((type_id = H5LTyyparse()) < 0) + if((type_id = H5LTyyparse()) < 0) { + HDfree(myinput); goto out; + } - free(myinput); + HDfree(myinput); input_len = 0; return type_id; @@ -2207,12 +2209,12 @@ realloc_and_append(hbool_t _no_user_buf, size_t *len, char *buf, char *str_to_ad { if(_no_user_buf) { /* If the buffer isn't big enough, reallocate it. Otherwise, go to do strcat. */ - if(str_to_add && ((ssize_t)(*len - (strlen(buf) + strlen(str_to_add) + 1)) < LIMIT)) { - *len += ((strlen(buf) + strlen(str_to_add) + 1) / INCREMENT + 1) * INCREMENT; - buf = (char*)realloc(buf, *len); - } else if(!str_to_add && ((ssize_t)(*len - strlen(buf) - 1) < LIMIT)) { + if(str_to_add && ((ssize_t)(*len - (HDstrlen(buf) + HDstrlen(str_to_add) + 1)) < LIMIT)) { + *len += ((HDstrlen(buf) + HDstrlen(str_to_add) + 1) / INCREMENT + 1) * INCREMENT; + buf = (char*)HDrealloc(buf, *len); + } else if(!str_to_add && ((ssize_t)(*len - HDstrlen(buf) - 1) < LIMIT)) { *len += INCREMENT; - buf = (char*)realloc(buf, *len); + buf = (char*)HDrealloc(buf, *len); } } @@ -2220,7 +2222,7 @@ realloc_and_append(hbool_t _no_user_buf, size_t *len, char *buf, char *str_to_ad goto out; if(str_to_add) - strcat(buf, str_to_add); + HDstrcat(buf, str_to_add); return buf; @@ -2249,7 +2251,7 @@ indentation(size_t x, char* str, hbool_t no_u_buf, size_t *s_len) char tmp_str[TMP_LEN]; if (x < 80) { - memset(tmp_str, ' ', x); + HDmemset(tmp_str, ' ', x); tmp_str[x]='\0'; } else HDsnprintf(tmp_str, TMP_LEN, "error: the indentation exceeds the number of cols."); @@ -2310,8 +2312,8 @@ print_enum(hid_t type, char* str, size_t *str_len, hbool_t no_ubuf, size_t indt) dst_size = H5Tget_size(native); /* Get the names and raw values of all members */ - name = (char**)calloc((size_t)nmembs, sizeof(char *)); - value = (unsigned char*)calloc((size_t)nmembs, MAX(dst_size, super_size)); + name = (char**)HDcalloc((size_t)nmembs, sizeof(char *)); + value = (unsigned char*)HDcalloc((size_t)nmembs, MAX(dst_size, super_size)); for (i = 0; i < nmembs; i++) { if((name[i] = H5Tget_member_name(type, (unsigned)i))==NULL) @@ -2359,10 +2361,10 @@ print_enum(hid_t type, char* str, size_t *str_len, hbool_t no_ubuf, size_t indt) /* Release resources */ for(i = 0; i < nmembs; i++) - free(name[i]); + HDfree(name[i]); - free(name); - free(value); + HDfree(name); + HDfree(value); H5Tclose(super); return str; @@ -2378,12 +2380,12 @@ out: if(name) { for(i = 0; i < nmembs; i++) if(name[i]) - free(name[i]); - free(name); + HDfree(name[i]); + HDfree(name); } /* end if */ if(value) - free(value); + HDfree(value); if(super >= 0) H5Tclose(super); @@ -2418,13 +2420,13 @@ herr_t H5LTdtype_to_text(hid_t dtype, char *str, H5LT_lang_t lang_type, size_t * goto out; if(len && !str) { - text_str = (char*)calloc(str_len, sizeof(char)); + text_str = (char*)HDcalloc(str_len, sizeof(char)); text_str[0]='\0'; if(!(text_str = H5LT_dtype_to_text(dtype, text_str, lang_type, &str_len, 1))) goto out; - *len = strlen(text_str) + 1; + *len = HDstrlen(text_str) + 1; if(text_str) - free(text_str); + HDfree(text_str); text_str = NULL; } else if(len && str) { if(!(H5LT_dtype_to_text(dtype, str, lang_type, len, 0))) @@ -2744,7 +2746,7 @@ next: if(tag) { HDsnprintf(tmp_str, TMP_LEN, "OPQ_TAG \"%s\";\n", tag); if(tag) - free(tag); + HDfree(tag); tag = NULL; } else HDsnprintf(tmp_str, TMP_LEN, "OPQ_TAG \"\";\n"); @@ -2777,14 +2779,14 @@ next: goto out; if(H5LTdtype_to_text(super, NULL, lang, &super_len) < 0) goto out; - stmp = (char*)calloc(super_len, sizeof(char)); + stmp = (char*)HDcalloc(super_len, sizeof(char)); if(H5LTdtype_to_text(super, stmp, lang, &super_len) < 0) goto out; if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, stmp))) goto out; if(stmp) - free(stmp); + HDfree(stmp); stmp = NULL; HDsnprintf(tmp_str, TMP_LEN, ";\n"); @@ -2821,14 +2823,14 @@ next: goto out; if(H5LTdtype_to_text(super, NULL, lang, &super_len) < 0) goto out; - stmp = (char*)calloc(super_len, sizeof(char)); + stmp = (char*)HDcalloc(super_len, sizeof(char)); if(H5LTdtype_to_text(super, stmp, lang, &super_len) < 0) goto out; if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, stmp))) goto out; if(stmp) - free(stmp); + HDfree(stmp); stmp = NULL; HDsnprintf(tmp_str, TMP_LEN, "\n"); if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) @@ -2879,13 +2881,13 @@ next: goto out; if(H5LTdtype_to_text(super, NULL, lang, &super_len) < 0) goto out; - stmp = (char*)calloc(super_len, sizeof(char)); + stmp = (char*)HDcalloc(super_len, sizeof(char)); if(H5LTdtype_to_text(super, stmp, lang, &super_len) < 0) goto out; if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, stmp))) goto out; if(stmp) - free(stmp); + HDfree(stmp); stmp = NULL; HDsnprintf(tmp_str, TMP_LEN, "\n"); if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) @@ -2934,13 +2936,13 @@ next: if(H5LTdtype_to_text(mtype, NULL, lang, &mlen) < 0) goto out; - mtmp = (char*)calloc(mlen, sizeof(char)); + mtmp = (char*)HDcalloc(mlen, sizeof(char)); if(H5LTdtype_to_text(mtype, mtmp, lang, &mlen) < 0) goto out; if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, mtmp))) goto out; if(mtmp) - free(mtmp); + HDfree(mtmp); mtmp = NULL; if (H5T_COMPOUND == mclass) @@ -2950,7 +2952,7 @@ next: if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) goto out; if(mname) - free(mname); + HDfree(mname); mname = NULL; HDsnprintf(tmp_str, TMP_LEN, " : %lu;\n", (unsigned long)moffset); @@ -3024,8 +3026,11 @@ herr_t H5LTget_attribute_string( hid_t loc_id, return -1; /* Get the attribute */ - if ( H5LT_get_attribute_disk( obj_id, attr_name, data ) < 0 ) - return -1; + if ( H5LT_get_attribute_disk( obj_id, attr_name, data ) < 0 ) + { + H5Oclose(obj_id); + return -1; + } /* Close the object */ if(H5Oclose(obj_id) < 0) @@ -3458,6 +3463,8 @@ static herr_t H5LT_get_attribute_mem(hid_t loc_id, return 0; out: + if(obj_id > 0) + H5Oclose(obj_id); if(attr_id > 0) H5Aclose(attr_id); return -1; @@ -3555,7 +3562,7 @@ herr_t H5LT_set_attribute_string(hid_t dset_id, if((tid = H5Tcopy(H5T_C_S1)) < 0) return FAIL; - size = strlen(buf) + 1; /* extra null term */ + size = HDstrlen(buf) + 1; /* extra null term */ if(H5Tset_size(tid,(size_t)size) < 0) goto out; diff --git a/hl/src/H5LTanalyze.c b/hl/src/H5LTanalyze.c index b88b577..f02bed6 100644 --- a/hl/src/H5LTanalyze.c +++ b/hl/src/H5LTanalyze.c @@ -51,7 +51,7 @@ #include #ifdef H5_HAVE_UNISTD_H #include -#endif +#endif /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ #ifdef c_plusplus @@ -1400,54 +1400,58 @@ case 57: YY_RULE_SETUP #line 159 "H5LTanalyze.l" { +#ifdef H5_HAVE_WIN32_API + H5LTyylval.sval = _strdup(yytext); +#else /* H5_HAVE_WIN32_API */ H5LTyylval.sval = strdup(yytext); +#endif /* H5_HAVE_WIN32_API */ BEGIN INITIAL; return STRING; } YY_BREAK case 58: YY_RULE_SETUP -#line 165 "H5LTanalyze.l" +#line 169 "H5LTanalyze.l" {return token('{');} YY_BREAK case 59: YY_RULE_SETUP -#line 166 "H5LTanalyze.l" +#line 170 "H5LTanalyze.l" {return token('}');} YY_BREAK case 60: YY_RULE_SETUP -#line 167 "H5LTanalyze.l" +#line 171 "H5LTanalyze.l" {return token('[');} YY_BREAK case 61: YY_RULE_SETUP -#line 168 "H5LTanalyze.l" +#line 172 "H5LTanalyze.l" {return token(']');} YY_BREAK case 62: YY_RULE_SETUP -#line 169 "H5LTanalyze.l" +#line 173 "H5LTanalyze.l" {return token(':');} YY_BREAK case 63: YY_RULE_SETUP -#line 170 "H5LTanalyze.l" +#line 174 "H5LTanalyze.l" {return token(';');} YY_BREAK case 64: YY_RULE_SETUP -#line 171 "H5LTanalyze.l" +#line 175 "H5LTanalyze.l" ; YY_BREAK case 65: YY_RULE_SETUP -#line 172 "H5LTanalyze.l" +#line 176 "H5LTanalyze.l" { return 0; } YY_BREAK case 66: YY_RULE_SETUP -#line 174 "H5LTanalyze.l" +#line 178 "H5LTanalyze.l" ECHO; YY_BREAK #line 1432 "H5LTanalyze.c" @@ -2032,7 +2036,11 @@ FILE *file; #if YY_NEVER_INTERACTIVE b->yy_is_interactive = 0; #else - b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; +#ifdef H5_HAVE_WIN32_API + b->yy_is_interactive = file ? (isatty( _fileno(file) ) > 0) : 0; +#else /* H5_HAVE_WIN32_API */ + b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; +#endif /* H5_HAVE_WIN32_API */ #endif #endif } @@ -2327,7 +2335,7 @@ int main() return 0; } #endif -#line 174 "H5LTanalyze.l" +#line 178 "H5LTanalyze.l" int my_yyinput(char *buf, int max_size) { diff --git a/hl/src/H5LTanalyze.l b/hl/src/H5LTanalyze.l index 3f63f50..581672b 100644 --- a/hl/src/H5LTanalyze.l +++ b/hl/src/H5LTanalyze.l @@ -157,7 +157,11 @@ OPQ_TAG {return token(OPQ_TAG_TOKEN);} return token('"'); } [^\"]+ { +#ifdef H5_HAVE_WIN32_API + H5LTyylval.sval = _strdup(yytext); +#else /* H5_HAVE_WIN32_API */ H5LTyylval.sval = strdup(yytext); +#endif /* H5_HAVE_WIN32_API */ BEGIN INITIAL; return STRING; } diff --git a/hl/src/H5LTparse.y b/hl/src/H5LTparse.y index a021efc..b91e97e 100644 --- a/hl/src/H5LTparse.y +++ b/hl/src/H5LTparse.y @@ -329,7 +329,11 @@ enum_list : ; enum_def : '"' enum_symbol '"' { is_enum_memb = 1; /*indicate member of enum*/ +#ifdef H5_HAVE_WIN32_API + enum_memb_symbol = _strdup(yylval.sval); +#else /* H5_HAVE_WIN32_API */ enum_memb_symbol = strdup(yylval.sval); +#endif /* H5_HAVE_WIN32_API */ } enum_val ';' { diff --git a/hl/test/test_image.c b/hl/test/test_image.c index 5c0c7ca..5a52980 100644 --- a/hl/test/test_image.c +++ b/hl/test/test_image.c @@ -289,6 +289,15 @@ static int test_simple(void) *------------------------------------------------------------------------- */ + if(buf1) + HDfree(buf1); + if(buf2) + HDfree(buf2); + if(buf1_out) + HDfree(buf1_out); + if(buf2_out) + HDfree(buf2_out); + /* Close the file. */ if(H5Fclose( fid ) < 0) goto out; diff --git a/perform/sio_standalone.h b/perform/sio_standalone.h index 677a8ae..b407ecb 100644 --- a/perform/sio_standalone.h +++ b/perform/sio_standalone.h @@ -62,7 +62,15 @@ */ #define HDabort() abort() #define HDabs(X) abs(X) +#ifdef H5_HAVE_WIN32_API +#define HDaccess(F,M) _access(F, M) +#define R_OK 4 /* Test for read permission. */ +#define W_OK 2 /* Test for write permission. */ +#define X_OK 1 /* Test for execute permission. */ +#define F_OK 0 /* Test for existence. */ +#else /* H5_HAVE_WIN32_API */ #define HDaccess(F,M) access(F, M) +#endif /* H5_HAVE_WIN32_API */ #define HDacos(X) acos(X) #ifdef H5_HAVE_ALARM #define HDalarm(N) alarm(N) @@ -214,7 +222,12 @@ H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...); #define HDgetpwuid(U) getpwuid(U) #define HDgetrusage(X,S) getrusage(X,S) #define HDgets(S) gets(S) +#ifdef H5_HAVE_VISUAL_STUDIO + H5_DLL int Wgettimeofday(struct timeval *tv, struct timezone *tz); +#define HDgettimeofday(V,Z) Wgettimeofday(V,Z) +#else /* H5_HAVE_VISUAL_STUDIO */ #define HDgettimeofday(S,P) gettimeofday(S,P) +#endif /* H5_HAVE_VISUAL_STUDIO */ #define HDgetuid() getuid() #define HDgmtime(T) gmtime(T) #define HDisalnum(C) isalnum((int)(C)) /*cast for solaris warning*/ @@ -355,7 +368,8 @@ int HDremove_all(const char * fname); #define HDsinh(X) sinh(X) #define HDsleep(N) sleep(N) #ifdef H5_HAVE_WIN32_API -#define HDsnprintf _snprintf /*varargs*/ +H5_DLL int c99_snprintf(char* str, size_t size, const char* format, ...); +#define HDsnprintf c99_snprintf /*varargs*/ #else #define HDsnprintf snprintf /*varargs*/ #endif @@ -373,7 +387,11 @@ H5_DLL void HDsrand(unsigned int seed); #endif /* sscanf() variable arguments */ +#ifdef H5_HAVE_WIN32_API +#define HDstrcasecmp(A,B) _stricmp(A,B) +#else #define HDstrcasecmp(X,Y) strcasecmp(X,Y) +#endif #define HDstrcat(X,Y) strcat(X,Y) #define HDstrchr(S,C) strchr(S,C) #define HDstrcmp(X,Y) strcmp(X,Y) @@ -433,7 +451,8 @@ H5_DLL int64_t HDstrtoll (const char *s, const char **rest, int base); #define HDvprintf(FMT,A) vprintf(FMT,A) #define HDvsprintf(S,FMT,A) vsprintf(S,FMT,A) #ifdef H5_HAVE_WIN32_API -# define HDvsnprintf(S,N,FMT,A) _vsnprintf(S,N,FMT,A) +H5_DLL int c99_vsnprintf(char* str, size_t size, const char* format, va_list ap); +#define HDvsnprintf c99_vsnprintf #else # define HDvsnprintf(S,N,FMT,A) vsnprintf(S,N,FMT,A) #endif diff --git a/perform/zip_perf.c b/perform/zip_perf.c index b13e0ec..f76e10b 100644 --- a/perform/zip_perf.c +++ b/perform/zip_perf.c @@ -157,11 +157,11 @@ error(const char *fmt, ...) va_list ap; va_start(ap, fmt); - fprintf(stderr, "%s: error: ", prog); - vfprintf(stderr, fmt, ap); - fprintf(stderr, "\n"); + HDfprintf(stderr, "%s: error: ", prog); + HDvfprintf(stderr, fmt, ap); + HDfprintf(stderr, "\n"); va_end(ap); - exit(EXIT_FAILURE); + HDexit(EXIT_FAILURE); } /* @@ -174,9 +174,9 @@ error(const char *fmt, ...) static void cleanup(void) { - if (!getenv("HDF5_NOCLEANUP")) - unlink(filename); - free(filename); + if (!HDgetenv("HDF5_NOCLEANUP")) + HDunlink(filename); + HDfree(filename); } static void @@ -189,7 +189,7 @@ write_file(Bytef *source, uLongf sourceLen) /* destination buffer needs to be at least 0.1% larger than sourceLen * plus 12 bytes */ destLen = (uLongf)((double)sourceLen + ((double)sourceLen * 0.1)) + 12; - dest = (Bytef *)malloc(destLen); + dest = (Bytef *)HDmalloc(destLen); if (!dest) error("out of memory"); @@ -204,7 +204,7 @@ write_file(Bytef *source, uLongf sourceLen) ((double)timer_start.tv_usec) / MICROSECOND); if (report_once_flag) { - printf("\tCompression Ratio: %g\n", ((double)destLen) / (double)sourceLen); + HDfprintf(stdout, "\tCompression Ratio: %g\n", ((double)destLen) / (double)sourceLen); report_once_flag = 0; } @@ -213,10 +213,10 @@ write_file(Bytef *source, uLongf sourceLen) /* loop to make sure we write everything out that we want to write */ for (;;) { - int rc = (int)write(output, d_ptr, (size_t)d_len); + int rc = (int)HDwrite(output, d_ptr, (size_t)d_len); if (rc == -1) - error(strerror(errno)); + error(HDstrerror(errno)); if (rc == (int)d_len) break; @@ -225,7 +225,7 @@ write_file(Bytef *source, uLongf sourceLen) d_ptr += rc; } - free(dest); + HDfree(dest); } /* @@ -299,7 +299,7 @@ static void get_unique_name(void) { const char *prefix = NULL; - const char *env = getenv("HDF5_PREFIX"); + const char *env = HDgetenv("HDF5_PREFIX"); if (env) prefix = env; @@ -309,19 +309,19 @@ get_unique_name(void) if (prefix) /* 2 = 1 for '/' + 1 for null terminator */ - filename = (char *) HDmalloc(strlen(prefix) + strlen(ZIP_PERF_FILE) + 2); + filename = (char *) HDmalloc(HDstrlen(prefix) + HDstrlen(ZIP_PERF_FILE) + 2); else - filename = (char *) HDmalloc(strlen(ZIP_PERF_FILE) + 1); + filename = (char *) HDmalloc(HDstrlen(ZIP_PERF_FILE) + 1); if (!filename) error("out of memory"); filename[0] = 0; if (prefix){ - strcpy(filename, prefix); - strcat(filename, "/"); + HDstrcpy(filename, prefix); + HDstrcat(filename, "/"); } - strcat(filename, ZIP_PERF_FILE); + HDstrcat(filename, ZIP_PERF_FILE); } /* @@ -334,30 +334,30 @@ get_unique_name(void) static void usage(void) { - printf("usage: %s [OPTIONS]\n", prog); - printf(" OPTIONS\n"); - printf(" -h, --help Print this usage message and exit\n"); - printf(" -1...-9 Level of compression, from 1 to 9\n"); - printf(" -c P, --compressability=P Percentage of compressability of the random\n"); - printf(" data you want [default: 0]"); - printf(" -s S, --file-size=S Maximum size of uncompressed file [default: 64M]\n"); - printf(" -B S, --max-buffer_size=S Maximum size of buffer [default: 1M]\n"); - printf(" -b S, --min-buffer_size=S Minumum size of buffer [default: 128K]\n"); - printf(" -p D, --prefix=D The directory prefix to place the file\n"); - printf(" -r, --random-test Use random data to write to the file\n"); - printf(" [default: no]\n"); - printf("\n"); - printf(" D - a directory which exists\n"); - printf(" P - a number between 0 and 100\n"); - printf(" S - is a size specifier, an integer >=0 followed by a size indicator:\n"); - printf("\n"); - printf(" K - Kilobyte (%d)\n", ONE_KB); - printf(" M - Megabyte (%d)\n", ONE_MB); - printf(" G - Gigabyte (%d)\n", ONE_GB); - printf("\n"); - printf(" Example: 37M = 37 Megabytes = %d bytes\n", 37 * ONE_MB); - printf("\n"); - fflush(stdout); + HDfprintf(stdout, "usage: %s [OPTIONS]\n", prog); + HDfprintf(stdout, " OPTIONS\n"); + HDfprintf(stdout, " -h, --help Print this usage message and exit\n"); + HDfprintf(stdout, " -1...-9 Level of compression, from 1 to 9\n"); + HDfprintf(stdout, " -c P, --compressability=P Percentage of compressability of the random\n"); + HDfprintf(stdout, " data you want [default: 0]"); + HDfprintf(stdout, " -s S, --file-size=S Maximum size of uncompressed file [default: 64M]\n"); + HDfprintf(stdout, " -B S, --max-buffer_size=S Maximum size of buffer [default: 1M]\n"); + HDfprintf(stdout, " -b S, --min-buffer_size=S Minumum size of buffer [default: 128K]\n"); + HDfprintf(stdout, " -p D, --prefix=D The directory prefix to place the file\n"); + HDfprintf(stdout, " -r, --random-test Use random data to write to the file\n"); + HDfprintf(stdout, " [default: no]\n"); + HDfprintf(stdout, "\n"); + HDfprintf(stdout, " D - a directory which exists\n"); + HDfprintf(stdout, " P - a number between 0 and 100\n"); + HDfprintf(stdout, " S - is a size specifier, an integer >=0 followed by a size indicator:\n"); + HDfprintf(stdout, "\n"); + HDfprintf(stdout, " K - Kilobyte (%d)\n", ONE_KB); + HDfprintf(stdout, " M - Megabyte (%d)\n", ONE_MB); + HDfprintf(stdout, " G - Gigabyte (%d)\n", ONE_GB); + HDfprintf(stdout, "\n"); + HDfprintf(stdout, " Example: 37M = 37 Megabytes = %d bytes\n", 37 * ONE_MB); + HDfprintf(stdout, "\n"); + HDfflush(stdout); } /* @@ -380,7 +380,7 @@ parse_size_directive(const char *size) unsigned long s; char *endptr; - s = strtoul(size, &endptr, 10); + s = HDstrtoul(size, &endptr, 10); if (endptr && *endptr) { while (*endptr != '\0' && (*endptr == ' ' || *endptr == '\t')) @@ -419,16 +419,16 @@ fill_with_random_data(Bytef *src, uLongf src_len) Bytef *buf = src; int fd = HDopen("/dev/urandom", O_RDONLY, 0); - printf("Using /dev/urandom for random data\n"); + HDfprintf(stdout, "Using /dev/urandom for random data\n"); if (fd < 0) - error(strerror(errno)); + error(HDstrerror(errno)); for (;;) { - ssize_t rc = read(fd, buf, src_len); + ssize_t rc = HDread(fd, buf, src_len); if (rc == -1) - error(strerror(errno)); + error(HDstrerror(errno)); if (rc == (ssize_t)len) break; @@ -437,7 +437,7 @@ fill_with_random_data(Bytef *src, uLongf src_len) len -= rc; } } else { - printf("Using random() for random data\n"); + HDfprintf(stdout, "Using random() for random data\n"); for (u = 0; u < src_len; ++u) src[u] = (Bytef)(0xff & HDrandom()); @@ -446,7 +446,7 @@ fill_with_random_data(Bytef *src, uLongf src_len) if (compress_percent) { unsigned long s = src_len * compress_percent / 100; - memset(src, '\0', s); + HDmemset(src, '\0', s); } } @@ -463,7 +463,7 @@ do_write_test(unsigned long file_size, unsigned long min_buf_size, register unsigned long i, iters; iters = file_size / src_len; - src = (Bytef *)calloc(1, sizeof(Bytef) * src_len); + src = (Bytef *)HDcalloc(1, sizeof(Bytef) * src_len); if (!src) { cleanup(); @@ -475,26 +475,26 @@ do_write_test(unsigned long file_size, unsigned long min_buf_size, if (random_test) fill_with_random_data(src, src_len); - printf("Buffer size == "); + HDfprintf(stdout, "Buffer size == "); if (src_len >= ONE_KB && (src_len % ONE_KB) == 0) { if (src_len >= ONE_MB && (src_len % ONE_MB) == 0) { - printf("%ldMB", src_len / ONE_MB); + HDfprintf(stdout, "%ldMB", src_len / ONE_MB); } else { - printf("%ldKB", src_len / ONE_KB); + HDfprintf(stdout, "%ldKB", src_len / ONE_KB); } } else { - printf("%ld", src_len); + HDfprintf(stdout, "%ld", src_len); } - printf("\n"); + HDfprintf(stdout, "\n"); /* do uncompressed data write */ HDgettimeofday(&timer_start, NULL); output = HDopen(filename, O_RDWR | O_CREAT, S_IRWXU); if (output == -1) - error(strerror(errno)); + error(HDstrerror(errno)); for (i = 0; i <= iters; ++i) { Bytef *s_ptr = src; @@ -502,10 +502,10 @@ do_write_test(unsigned long file_size, unsigned long min_buf_size, /* loop to make sure we write everything out that we want to write */ for (;;) { - ssize_t rc = write(output, s_ptr, s_len); + ssize_t rc = HDwrite(output, s_ptr, s_len); if (rc == -1) - error(strerror(errno)); + error(HDstrerror(errno)); if (rc == (ssize_t)s_len) break; @@ -515,7 +515,7 @@ do_write_test(unsigned long file_size, unsigned long min_buf_size, } } - close(output); + HDclose(output); HDgettimeofday(&timer_stop, NULL); total_time = ((double)timer_stop.tv_sec + @@ -523,17 +523,17 @@ do_write_test(unsigned long file_size, unsigned long min_buf_size, ((double)timer_start.tv_sec + ((double)timer_start.tv_usec) / MICROSECOND); - printf("\tUncompressed Write Time: %.2fs\n", total_time); - printf("\tUncompressed Write Throughput: %.2fMB/s\n", + HDfprintf(stdout, "\tUncompressed Write Time: %.2fs\n", total_time); + HDfprintf(stdout, "\tUncompressed Write Throughput: %.2fMB/s\n", MB_PER_SEC(file_size, total_time)); - unlink(filename); + HDunlink(filename); /* do compressed data write */ output = HDopen(filename, O_RDWR | O_CREAT, S_IRWXU); if (output == -1) - error(strerror(errno)); + error(HDstrerror(errno)); report_once_flag = 1; HDgettimeofday(&timer_start, NULL); @@ -541,7 +541,7 @@ do_write_test(unsigned long file_size, unsigned long min_buf_size, for (total_len = 0; total_len < file_size; total_len += src_len) write_file(src, src_len); - close(output); + HDclose(output); HDgettimeofday(&timer_stop, NULL); total_time = ((double)timer_stop.tv_sec + @@ -549,13 +549,13 @@ do_write_test(unsigned long file_size, unsigned long min_buf_size, ((double)timer_start.tv_sec + ((double)timer_start.tv_usec) / MICROSECOND); - printf("\tCompressed Write Time: %.2fs\n", total_time); - printf("\tCompressed Write Throughput: %.2fMB/s\n", + HDfprintf(stdout, "\tCompressed Write Time: %.2fs\n", total_time); + HDfprintf(stdout, "\tCompressed Write Throughput: %.2fMB/s\n", MB_PER_SEC(file_size, total_time)); - printf("\tCompression Time: %gs\n", compression_time); + HDfprintf(stdout, "\tCompression Time: %gs\n", compression_time); - unlink(filename); - free(src); + HDunlink(filename); + HDfree(src); } } @@ -574,7 +574,7 @@ main(int argc, char **argv) int opt; prog = argv[0]; - + /* Initialize h5tools lib */ h5tools_init(); @@ -593,7 +593,7 @@ main(int argc, char **argv) min_buf_size = parse_size_directive(opt_arg); break; case 'c': - compress_percent = (int)strtol(opt_arg, NULL, 10); + compress_percent = (int)HDstrtol(opt_arg, NULL, 10); if (compress_percent < 0) compress_percent = 0; @@ -626,12 +626,12 @@ main(int argc, char **argv) error("minmum buffer size (%d) exceeds maximum buffer size (%d)", min_buf_size, max_buf_size); - printf("Filesize: %ld\n", file_size); + HDfprintf(stdout, "Filesize: %ld\n", file_size); if (compress_level == Z_DEFAULT_COMPRESSION) - printf("Compression Level: 6\n"); + HDfprintf(stdout, "Compression Level: 6\n"); else - printf("Compression Level: %d\n", compress_level); + HDfprintf(stdout, "Compression Level: %d\n", compress_level); get_unique_name(); do_write_test(file_size, min_buf_size, max_buf_size); @@ -652,7 +652,7 @@ main(int argc, char **argv) int main(void) { - printf("No compression IO performance because zlib was not configured\n"); + HDfprintf(stdout, "No compression IO performance because zlib was not configured\n"); return EXIT_SUCCESS; } diff --git a/release_docs/USING_CMake_Examples.txt b/release_docs/USING_CMake_Examples.txt new file mode 100644 index 0000000..33c43a3 --- /dev/null +++ b/release_docs/USING_CMake_Examples.txt @@ -0,0 +1,12 @@ +The compressed examples file, located in the HDF5 install folder, +can be built and tested with CMake and the supplied +HDF518_Examples.cmake file. It is recommended that you copy those +two files to your development location before continuing. + +The command line to be used is shown at the top of the file. Also, +the location of the HDF5 installation should be verified and +changed if necessary. + +When executed, the ctest script will save the results to the log file +indicated by the ctest command. If you wish the to see more build +and test information, add "-VV" to the ctest command. diff --git a/src/H5FDstdio.c b/src/H5FDstdio.c index 9601cb0..d182185 100644 --- a/src/H5FDstdio.c +++ b/src/H5FDstdio.c @@ -412,7 +412,11 @@ H5FD_stdio_open( const char *name, unsigned flags, hid_t fapl_id, } /* Get the file descriptor (needed for truncate and some Windows information) */ +#ifdef H5_HAVE_WIN32_API + file->fd = _fileno(file->fp); +#else /* H5_HAVE_WIN32_API */ file->fd = fileno(file->fp); +#endif /* H5_HAVE_WIN32_API */ if(file->fd < 0) { free(file); fclose(f); diff --git a/src/H5system.c b/src/H5system.c index bc77131..2a94028 100644 --- a/src/H5system.c +++ b/src/H5system.c @@ -667,6 +667,30 @@ Wgetlogin() return NULL; } +int c99_snprintf(char* str, size_t size, const char* format, ...) +{ + int count; + va_list ap; + + va_start(ap, format); + count = c99_vsnprintf(str, size, format, ap); + va_end(ap); + + return count; +} + +int c99_vsnprintf(char* str, size_t size, const char* format, va_list ap) +{ + int count = -1; + + if (size != 0) + count = _vsnprintf_s(str, size, _TRUNCATE, format, ap); + if (count == -1) + count = _vscprintf(format, ap); + + return count; +} + #endif diff --git a/src/H5win32defs.h b/src/H5win32defs.h index e9b87625..d452925 100644 --- a/src/H5win32defs.h +++ b/src/H5win32defs.h @@ -29,6 +29,7 @@ typedef struct _stati64 h5_stat_t; typedef __int64 h5_stat_size_t; #define HDaccess(F,M) _access(F,M) +#define HDchdir(S) _chdir(S) #define HDclose(F) _close(F) #define HDdup(F) _dup(F) #define HDfdopen(N,S) _fdopen(N,S) @@ -47,16 +48,15 @@ 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 HDrmdir(S) _rmdir(S) #define HDsetvbuf(F,S,M,Z) setvbuf(F,S,M,(Z>1?Z:2)) #define HDsleep(S) Sleep(S*1000) #define HDstat(S,B) _stati64(S,B) #define HDstrcasecmp(A,B) _stricmp(A,B) #define HDstrtoull(S,R,N) _strtoui64(S,R,N) #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) #ifdef H5_HAVE_VISUAL_STUDIO @@ -75,11 +75,15 @@ struct timezone { #endif /* __cplusplus */ H5_DLL int Wgettimeofday(struct timeval *tv, struct timezone *tz); H5_DLL char* Wgetlogin(); + H5_DLL int c99_snprintf(char* str, size_t size, const char* format, ...); + H5_DLL int c99_vsnprintf(char* str, size_t size, const char* format, va_list ap); #ifdef __cplusplus } #endif /* __cplusplus */ #define HDgettimeofday(V,Z) Wgettimeofday(V,Z) -#define HDgetlogin() Wgetlogin() +#define HDgetlogin() Wgetlogin() +#define HDsnprintf c99_snprintf /*varargs*/ +#define HDvsnprintf c99_vsnprintf #endif /* H5_HAVE_VISUAL_STUDIO */ -- cgit v0.12