From 5c0a8cc86ebe85e1b46e20f253f09c86bdc83169 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Tue, 29 Sep 2015 13:56:27 -0500 Subject: [svn-r27912] Revert of r27887, which caused failures in the vds test. These changes will be merged more carefully so we can more easily identify any errors that arise. Tested on: Ubuntu 15.04 (Linux 3.19 x86_64) w/ gcc 4.9.2 serial and parallel (w/ MPICH 3.1.4) --- CMakeLists.txt | 4 -- autogen.sh | 58 ++++++++++----------- config/cmake/HDF5_Examples.cmake.in | 70 ++++++++------------------ config/cmake/README.txt.cmake.in | 33 ++++-------- release_docs/USING_CMake_Examples.txt | 57 +++++++++++---------- src/CMakeLists.txt | 12 ++--- src/H5S.c | 40 +++++++-------- src/H5Sall.c | 18 +++---- src/H5Shyper.c | 94 +++++++++++++++-------------------- src/H5Snone.c | 16 ++---- src/H5Spoint.c | 51 ++++++++----------- 11 files changed, 176 insertions(+), 277 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1035142..96d5772 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -212,10 +212,6 @@ if (NOT HDF5_INSTALL_DATA_DIR) endif (NOT WIN32) endif (NOT HDF5_INSTALL_DATA_DIR) -if(DEFINED ADDITIONAL_CMAKE_PREFIX_PATH AND EXISTS "${ADDITIONAL_CMAKE_PREFIX_PATH}") - set (CMAKE_PREFIX_PATH ${ADDITIONAL_CMAKE_PREFIX_PATH} ${CMAKE_PREFIX_PATH}) -endif(DEFINED ADDITIONAL_CMAKE_PREFIX_PATH AND EXISTS "${ADDITIONAL_CMAKE_PREFIX_PATH}") - #----------------------------------------------------------------------------- # parse the full version number from H5public.h and include in H5_VERS_INFO #----------------------------------------------------------------------------- diff --git a/autogen.sh b/autogen.sh index d76c016..237e1b1 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # # Copyright by The HDF Group. # All rights reserved. @@ -60,7 +60,7 @@ # # This script takes two potential options: # -# -p +# -p, --production # # When this is selected, the autotools versions are set to the paths # and versions used by The HDF Group to produce the released versions @@ -70,7 +70,7 @@ # to have recent versions of the autotools this option will probably # be removed. # -# -v +# -v, --verbose # # This emits some extra information, mainly tool versions. @@ -89,19 +89,33 @@ verbose=false optspec=":hpv-" while getopts "$optspec" optchar; do case "${optchar}" in + -) + case "${OPTARG}" in + production) + echo "Setting production mode..." + echo + production=true + ;; + verbose) + echo "Setting verbosity: high" + echo + verbose=true + ;; + *) + if [ "$OPTERR" = 1 ] && [ "${optspec:0:1}" != ":" ]; then + echo "Unknown option --${OPTARG}" >&2 + fi + ;; + esac;; h) - echo "usage: $0 [OPTIONS]" - echo - echo " -h Print this help message." + echo "usage: $0 [-p|--production]" echo echo " -p Used by THG to ensure that particular versions" echo " of the autotools are used and hard-codes" echo " autotools paths to THG machines. Not for" echo " non-HDF-Group users!" echo - echo " -v Show more verbose output." - echo - echo " NOTE: Each tool can be set via an environment variable." + echo " NOTE: Each autotool can be set via an environment variable." echo " These are documented inside this autogen.sh script." echo exit 0 @@ -382,37 +396,15 @@ bin/make_overflow src/H5overflow.txt || exit 1 # to install a later version of bison. See the OS X note at the top # of this script. echo -echo "Generating H5LT parser code (requires yacc/bison):" -echo "Generate hl/src/H5LTparse.c from hl/src/H5LTparse.y" -# HDF5_BISON is set via the environment or 'which bison', above -if test -z ${HDF5_BISON}; then - echo - echo "*************************" - echo " ERROR - bison not found" - echo "*************************" - echo "bison is required to generate parser code in H5LT" - echo - exit 127 -fi +echo "Running flex/bison:" cd hl/src +echo "Generate hl/src/H5LTparse.c from hl/src/H5LTparse.y" if [ "$verbose" = true ] ; then ${HDF5_BISON} --version fi ${HDF5_BISON} -pH5LTyy -o H5LTparse.c -d H5LTparse.y -echo -echo "Generating H5LT lexer code (requires lex/flex):" echo "Generate hl/src/H5LTanalyze.c from hl/src/H5LTanalyze.l" -# HDF5_FLEX is set via the environment or 'which flex', above -if test -z ${HDF5_FLEX}; then - echo - echo "************************" - echo " ERROR - flex not found" - echo "************************" - echo "flex is required to generate lexer code in H5LT" - echo - exit 127 -fi if [ "$verbose" = true ] ; then ${HDF5_FLEX} --version fi diff --git a/config/cmake/HDF5_Examples.cmake.in b/config/cmake/HDF5_Examples.cmake.in index 65e2e9e..d0c0509 100644 --- a/config/cmake/HDF5_Examples.cmake.in +++ b/config/cmake/HDF5_Examples.cmake.in @@ -1,48 +1,20 @@ cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR) ############################################################################################################### -# This script will build and run the examples from a folder +# This script will build and run the examples from a compressed file # Execute from a command line: -# ctest -S HDF5_Examples.cmake,OPTION=VALUE -C Release -V -O test.log +# ctest -S HDF5_Examples.cmake,HDF5Examples -C Release -V -O test.log ############################################################################################################### +set(INSTALLDIR "@CMAKE_INSTALL_PREFIX@") 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") +#set(NO_MAC_FORTRAN "true") #set(BUILD_OPTIONS "${BUILD_OPTIONS} -DHDF_BUILD_FORTRAN:BOOL=ON") - -# handle input parameters to script. -#INSTALLDIR - HDF5 root folder -#CTEST_BUILD_CONFIGURATION - Release, Debug, RelWithDebInfo -#CTEST_SOURCE_NAME - name of source folder; HDF4Examples -#STATICLIBRARIES - Default is YES -#NO_MAC_FORTRAN - set to TRUE to allow shared libs on a Mac) -if(DEFINED CTEST_SCRIPT_ARG) - # transform ctest script arguments of the form - # script.ctest,var1=value1,var2=value2 - # to variables with the respective names set to the respective values - string(REPLACE "," ";" script_args "${CTEST_SCRIPT_ARG}") - foreach(current_var ${script_args}) - if ("${current_var}" MATCHES "^([^=]+)=(.+)$") - set("${CMAKE_MATCH_1}" "${CMAKE_MATCH_2}") - endif() - endforeach() -endif() -if(NOT DEFINED INSTALLDIR) - set(INSTALLDIR "@CMAKE_INSTALL_PREFIX@") -endif() -if(NOT DEFINED CTEST_BUILD_CONFIGURATION) - set(CTEST_BUILD_CONFIGURATION "Release") -endif() -if(NOT DEFINED CTEST_SOURCE_NAME) - set(CTEST_SOURCE_NAME "HDF5Examples") -endif() -if(NOT DEFINED STATICLIBRARIES) - set(STATICLIBRARIES "YES") -endif() - -#TAR_SOURCE - name of tarfile -#if(NOT DEFINED TAR_SOURCE) -# set(CTEST_USE_TAR_SOURCE "HDF5Examples-1.10.1-Source") -#endif() +set(BUILD_OPTIONS "${BUILD_OPTIONS} -DHDF_ENABLE_F2003:BOOL=ON") +#set(CTEST_USE_TAR_SOURCE "${CTEST_SCRIPT_ARG}") ############################################################################################################### # Adjust the following SET Commands as needed @@ -70,7 +42,7 @@ endif(WIN32) # For any comments please contact cdashhelp@hdfgroup.org # ############################################################################################################### - + #----------------------------------------------------------------------------- # MAC machines need special option #----------------------------------------------------------------------------- @@ -81,14 +53,14 @@ if(APPLE) set(ENV{CC} "${XCODE_CC}") set(ENV{CXX} "${XCODE_CXX}") if(NOT NO_MAC_FORTRAN) - # Shared fortran is not supported, build static + # Shared fortran is not supported, build static set(BUILD_OPTIONS "${BUILD_OPTIONS} -DBUILD_SHARED_LIBS:BOOL=OFF -DCMAKE_ANSI_CFLAGS:STRING=-fPIC") else(NOT NO_MAC_FORTRAN) set(BUILD_OPTIONS "${BUILD_OPTIONS} -DHDF_BUILD_FORTRAN:BOOL=OFF") endif(NOT NO_MAC_FORTRAN) 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}\"") ## -------------------------- @@ -97,19 +69,19 @@ if(CTEST_USE_TAR_SOURCE) ## -------------------------- if(WIN32) message(STATUS "extracting... [${CMAKE_EXECUTABLE_NAME} -E tar -xvf ${CTEST_USE_TAR_SOURCE}.zip]") - execute_process(COMMAND ${CMAKE_EXECUTABLE_NAME} -E tar -xvf ${CTEST_DASHBOARD_ROOT}\\${CTEST_USE_TAR_SOURCE}.zip RESULT_VARIABLE rv) - else() + execute_process(COMMAND ${CMAKE_EXECUTABLE_NAME} -E tar -xvf ${CTEST_USE_TAR_SOURCE}.zip RESULT_VARIABLE rv) + else(WIN32) message(STATUS "extracting... [${CMAKE_EXECUTABLE_NAME} -E tar -xvf ${CTEST_USE_TAR_SOURCE}.tar]") - execute_process(COMMAND ${CMAKE_EXECUTABLE_NAME} -E tar -xvf ${CTEST_DASHBOARD_ROOT}/${CTEST_USE_TAR_SOURCE}.tar RESULT_VARIABLE rv) - endif() - + execute_process(COMMAND ${CMAKE_EXECUTABLE_NAME} -E tar -xvf ${CTEST_USE_TAR_SOURCE}.tar RESULT_VARIABLE rv) + endif(WIN32) + if(NOT rv EQUAL 0) message(STATUS "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) endif(CTEST_USE_TAR_SOURCE) - + #----------------------------------------------------------------------------- ## Clear the build directory ## -------------------------- @@ -132,11 +104,11 @@ 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") - + #----------------------------------------------------------------------------- configure_file(${CTEST_SOURCE_DIRECTORY}/config/cmake/CTestCustom.cmake ${CTEST_BINARY_DIRECTORY}/CTestCustom.cmake) ctest_read_custom_files ("${CTEST_BINARY_DIRECTORY}") @@ -150,5 +122,5 @@ if(res GREATER 0) message (FATAL_ERROR "tests FAILED") endif(res GREATER 0) #----------------------------------------------------------------------------- -############################################################################################################## +############################################################################################################## message(STATUS "DONE") \ No newline at end of file diff --git a/config/cmake/README.txt.cmake.in b/config/cmake/README.txt.cmake.in index ec40abe..a12c5aa 100644 --- a/config/cmake/README.txt.cmake.in +++ b/config/cmake/README.txt.cmake.in @@ -1,11 +1,11 @@ @HDF5_PACKAGE_NAME@ version @HDF5_PACKAGE_VERSION_STRING@ ------------------------------------------------------------------------------ -This directory contains the binary (release) distribution of +This directory contains the binary (release) distribution of @HDF5_PACKAGE_NAME@ @HDF5_PACKAGE_VERSION_MAJOR@ that was compiled on; - @BINARY_PLATFORM@. + @BINARY_PLATFORM@. -It was built with the following options: +It was built with the following options: -- @LIB_TYPE@ C/C++/Fortran libraries -- SZIP (encoder enabled) and ZLIB -- @LIB_TYPE@ HDF5 tools @@ -24,38 +24,27 @@ Installation After Installation =========================================================================== -The examples folder, HDF5Examples, located in the +The examples folder, HDF5Examples, located in the HDF5 install folder, can be built and tested with CMake and the supplied HDF5_Examples.cmake file. The HDF5_Examples.cmake expects HDF5 to have -been installed in the default location with above compilers. Also, the CMake +been installed in the default location with above compilers. Also, the CMake utility should be installed. To test the installation with the examples; Create a directory to run the examples. Copy HDF5Examples folder to this directory. Copy HDF5_Examples.cmake to this directory. - The default source folder is defined as "HDF5Examples". It can be changed - with the CTEST_SOURCE_NAME script option. - The default installation folder is defined as "@CMAKE_INSTALL_PREFIX@". - It can be changed with the INSTALLDIR script option. - The default ctest configuration is defined as "Release". It can be changed - with the CTEST_BUILD_CONFIGURATION script option. Note that this must - be the same as the value used with the -C command line option. - The default build configuration is defined to build and use static libraries. - Shared libraries can be used with the STATICLIBRARIES script option set to "NO". - Other options can be changed by editing the HDF5_Examples.cmake file. - - If the defaults are okay, execute from this directory: - ctest -S HDF5_Examples.cmake -C Release -V -O test.log - If the defaults need change, execute from this directory: - ctest -S HDF5_Examples.cmake,CTEST_SOURCE_NAME=MyExamples,INSTALLDIR=MyLocation -C Release -V -O test.log + Edit HDF5_Examples.cmake line 8 to set INSTALLDIR to where HDF5 is installed. + (The default should be correct unless you installed into a different folder.) + Execute from this directory: + ctest -S HDF5_Examples.cmake,HDF5Examples -C Release -V -O test.log When executed, the ctest script will save the results to the log file, test.log, as -indicated by the ctest command. If you wish the to see more build and test information, +indicated by the ctest command. If you wish the to see more build and test information, add "-VV" to the ctest command. The output should show; 100% tests passed, 0 tests failed out of 156. -For more information see USING_CMake_Examples.txt in the install folder. +For more information see USING_CMake_Examples.txt in the install folder. =========================================================================== Documentation for this release can be found at the following URL: diff --git a/release_docs/USING_CMake_Examples.txt b/release_docs/USING_CMake_Examples.txt index a6854ae..d52a719 100644 --- a/release_docs/USING_CMake_Examples.txt +++ b/release_docs/USING_CMake_Examples.txt @@ -28,8 +28,8 @@ I. Preconditions the HDF Install Utility (the *.msi file in the binary package for Windows or the *.sh on Linux). If you are using a Windows platform, you can obtain a pre-built Windows binary from The HDF Group's website - at www.hdfgroup.org. - + at www.hdfgroup.org. See Section "III. Common changes to the + HDF518_Examples.cmake file", for the line to change the location. ======================================================================== @@ -37,41 +37,40 @@ II. Building HDF5 Examples with CMake ======================================================================== Files in the HDF5 install directory: - HDF5Examples folder + HDF5Examples-0.1.1-Source folder HDF518_Examples.cmake Default installation process: Create a directory to run the examples, i.e. \test_hdf5. - Copy HDF5Examples folder to this directory. - Copy HDF5_Examples.cmake to this directory. - The default source folder is defined as "HDF5Examples". It can be changed - with the CTEST_SOURCE_NAME script option. - The default installation folder is defined as "@CMAKE_INSTALL_PREFIX@". - It can be changed with the INSTALLDIR script option. - The default ctest configuration is defined as "Release". It can be changed - with the CTEST_BUILD_CONFIGURATION script option. Note that this must - be the same as the value used with the -C command line option. - The default build configuration is defined to build and use static libraries. - Shared libraries can be used with the STATICLIBRARIES script option set to "NO". - Other options can be changed by editing the HDF5_Examples.cmake file. - - If the defaults are okay, execute from this directory: - ctest -S HDF5_Examples.cmake -C Release -V -O test.log - If the defaults need change, execute from this directory: - ctest -S HDF5_Examples.cmake,CTEST_SOURCE_NAME=MyExamples,INSTALLDIR=MyLocation -C Release -V -O test.log - - When executed, the ctest script will save the results to the log file, test.log, as - indicated by the ctest command. If you wish the to see more build and test information, - add "-VV" to the ctest command. The output should show; - 100% tests passed, 0 tests failed out of 156. + Copy HDF5Examples-0.1.1-Source folder to this directory. + Copy HDF518_Examples.cmake to this directory. + Edit line 8 of the HDF518_Examples.cmake file and change the INSTALLDIR + to the HDF5 install location. + + Execute from this directory: + ctest -S HDF518_Examples.cmake,HDF5Examples-0.1.1-Source -C Release -O test.log + +The script will use the examples folder HDF5Examples-0.1.1-Source, + and create a build directory inside the HDF5Examples-0.1.1-Source directory. + It will then configure, build, and execute the examples. All the log files + will be found under the build\Testing\Temporary directory, check these for + errors. + +The amount of script information can be increased by adding -V to the ctest + command. Even more information can be shown by adding -VV instead of -V. ======================================================================== -III. Other changes to the HDF518_Examples.cmake file +III. Common changes to the HDF518_Examples.cmake file ======================================================================== -Line 10: uncomment to build and test Fortran examples. +Line 8: change the INSTALLDIR to a different HDF5 install location. + +Line 14: uncomment to allow Mac machines to build shared examples. + +Line 15: uncomment to build and test Fortran examples. + +Line 16: comment to NOT build and test Fortran examples with F2003 option. -Line 43-45: uncomment to use a source tarball or zipfile; - Add script option "TAR_SOURCE=MySource.tar". +Line 17: uncomment to use a compressed source file. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6253f51..ff69d5e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -820,11 +820,6 @@ if (HDF5_GENERATE_HEADERS) endif (PERL_FOUND) endif (HDF5_GENERATE_HEADERS) -set (H5_PUBLIC_GENERATED_HEADERS - ${HDF5_SRC_DIR}/H5version.h - ${HDF5_SRC_DIR}/H5overflow.h -) - #----------------------------------------------------------------------------- # Setup the H5Detect utility which generates H5Tinit with platform # specific type checks inside @@ -837,7 +832,7 @@ endif (MSVC OR MINGW) if (HDF5_GENERATE_HEADERS) add_dependencies(H5detect generate_precompiled) else (HDF5_GENERATE_HEADERS) - add_dependencies(H5detect "${H5_PUBLIC_GENERATED_HEADERS}") + add_dependencies(H5detect "${HDF5_SRC_DIR}/H5version.h;${HDF5_SRC_DIR}/H5overflow.h") endif (HDF5_GENERATE_HEADERS) set (CMD $) @@ -856,7 +851,7 @@ endif (MSVC OR MINGW) if (HDF5_GENERATE_HEADERS) add_dependencies(H5detect generate_precompiled) else (HDF5_GENERATE_HEADERS) - add_dependencies(H5make_libsettings "${H5_PUBLIC_GENERATED_HEADERS}") + add_dependencies(H5make_libsettings "${HDF5_SRC_DIR}/H5version.h;${HDF5_SRC_DIR}/H5overflow.h") endif (HDF5_GENERATE_HEADERS) set (CMD $) @@ -905,7 +900,7 @@ endif (HDF5_ENABLE_DEBUG_APIS) set (install_targets ${HDF5_LIB_TARGET}) if (BUILD_SHARED_LIBS) - add_library (${HDF5_LIBSH_TARGET} SHARED ${common_SRCS} ${H5_PUBLIC_HEADERS} ${H5_PRIVATE_HEADERS} ${H5_GENERATED_HEADERS}) + add_library (${HDF5_LIBSH_TARGET} SHARED ${common_SRCS} ${H5_PUBLIC_HEADERS} ${H5_PRIVATE_HEADERS}) TARGET_C_PROPERTIES (${HDF5_LIBSH_TARGET} SHARED " " " ") target_link_libraries (${HDF5_LIBSH_TARGET} ${LINK_SHARED_LIBS}) if (NOT WIN32) @@ -950,7 +945,6 @@ if (NOT HDF5_INSTALL_NO_DEVELOPMENT) install ( FILES ${H5_PUBLIC_HEADERS} - ${H5_PUBLIC_GENERATED_HEADERS} DESTINATION ${HDF5_INSTALL_INCLUDE_DIR} COMPONENT diff --git a/src/H5S.c b/src/H5S.c index af7d395..1d07f14 100644 --- a/src/H5S.c +++ b/src/H5S.c @@ -1576,12 +1576,11 @@ done: herr_t H5S_encode(H5S_t *obj, unsigned char **p, size_t *nalloc) { - H5F_t *f = NULL; /* Fake file structure*/ - unsigned char *pp = (*p); /* Local pointer for decoding */ size_t extent_size; /* Size of serialized dataspace extent */ hssize_t sselect_size; /* Signed size of serialized dataspace selection */ size_t select_size; /* Size of serialized dataspace selection */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_t *f = NULL; /* Fake file structure*/ + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT @@ -1600,28 +1599,27 @@ H5S_encode(H5S_t *obj, unsigned char **p, size_t *nalloc) /* Verify the size of buffer. If it's not big enough, simply return the * right size without filling the buffer. */ - if(!pp || *nalloc < (extent_size + select_size + 1 + 1 + 1 + 4)) + if(!*p || *nalloc < (extent_size + select_size + 1 + 1 + 1 + 4)) *nalloc = extent_size + select_size + 1 + 1 + 1 + 4; else { /* Encode the type of the information */ - *pp++ = H5O_SDSPACE_ID; + *(*p)++ = H5O_SDSPACE_ID; /* Encode the version of the dataspace information */ - *pp++ = H5S_ENCODE_VERSION; + *(*p)++ = H5S_ENCODE_VERSION; /* Encode the "size of size" information */ - *pp++ = (unsigned char)H5F_SIZEOF_SIZE(f); + *(*p)++ = (unsigned char)H5F_SIZEOF_SIZE(f); /* Encode size of extent information. Pointer is actually moved in this macro. */ - UINT32ENCODE(pp, extent_size); + UINT32ENCODE(*p, extent_size); /* Encode the extent part of dataspace */ - if(H5O_msg_encode(f, H5O_SDSPACE_ID, TRUE, pp, obj) < 0) + if(H5O_msg_encode(f, H5O_SDSPACE_ID, TRUE, *p, obj) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTENCODE, FAIL, "can't encode extent space") - pp += extent_size; + *p += extent_size; /* Encode the selection part of dataspace. */ - *p = pp; if(H5S_SELECT_SERIALIZE(obj, p) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTENCODE, FAIL, "can't encode select space") } /* end else */ @@ -1694,39 +1692,38 @@ done: H5S_t* H5S_decode(const unsigned char **p) { - H5F_t *f = NULL; /* Fake file structure*/ - H5S_t *ds; /* Decoded dataspace */ - H5S_extent_t *extent; /* Entent of decoded dataspace */ - const unsigned char *pp = (*p); /* Local pointer for decoding */ + H5S_t *ds; + H5S_extent_t *extent; size_t extent_size; /* size of the extent message*/ + H5F_t *f = NULL; /* Fake file structure*/ uint8_t sizeof_size; /* 'Size of sizes' for file */ H5S_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Decode the type of the information */ - if(*pp++ != H5O_SDSPACE_ID) + if(*(*p)++ != H5O_SDSPACE_ID) HGOTO_ERROR(H5E_DATASPACE, H5E_BADMESG, NULL, "not an encoded dataspace") /* Decode the version of the dataspace information */ - if(*pp++ != H5S_ENCODE_VERSION) + if(*(*p)++ != H5S_ENCODE_VERSION) HGOTO_ERROR(H5E_DATASPACE, H5E_VERSION, NULL, "unknown version of encoded dataspace") /* Decode the "size of size" information */ - sizeof_size = *pp++; + sizeof_size = *(*p)++; /* Allocate "fake" file structure */ if(NULL == (f = H5F_fake_alloc(sizeof_size))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate fake file struct") /* Decode size of extent information */ - UINT32DECODE(pp, extent_size); + UINT32DECODE(*p, extent_size); /* Decode the extent part of dataspace */ /* (pass mostly bogus file pointer and bogus DXPL) */ - if((extent = (H5S_extent_t *)H5O_msg_decode(f, H5P_DEFAULT, NULL, H5O_SDSPACE_ID, pp))==NULL) + if((extent = (H5S_extent_t *)H5O_msg_decode(f, H5P_DEFAULT, NULL, H5O_SDSPACE_ID, *p))==NULL) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDECODE, NULL, "can't decode object") - pp += extent_size; + *p += extent_size; /* Copy the extent into dataspace structure */ if((ds = H5FL_CALLOC(H5S_t))==NULL) @@ -1742,7 +1739,6 @@ H5S_decode(const unsigned char **p) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, NULL, "unable to set all selection") /* Decode the select part of dataspace. I believe this part always exists. */ - *p = pp; if(H5S_SELECT_DESERIALIZE(&ds, p) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDECODE, NULL, "can't decode space selection") diff --git a/src/H5Sall.c b/src/H5Sall.c index fb6b45f..79796c3 100644 --- a/src/H5Sall.c +++ b/src/H5Sall.c @@ -516,25 +516,19 @@ H5S_all_serial_size (const H5S_t H5_ATTR_UNUSED *space) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S_all_serialize(const H5S_t *space, uint8_t **p) +H5S_all_serialize (const H5S_t *space, uint8_t **p) { - uint8_t *pp = (*p); /* Local pointer for decoding */ - FUNC_ENTER_NOAPI_NOINIT_NOERR - /* Check args */ HDassert(space); HDassert(p); - HDassert(pp); + HDassert(*p); /* Store the preamble information */ - UINT32ENCODE(pp, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */ - UINT32ENCODE(pp, (uint32_t)1); /* Store the version number */ - UINT32ENCODE(pp, (uint32_t)0); /* Store the un-used padding */ - UINT32ENCODE(pp, (uint32_t)0); /* Store the additional information length */ - - /* Update encoding pointer */ - *p = pp; + UINT32ENCODE(*p, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */ + UINT32ENCODE(*p, (uint32_t)1); /* Store the version number */ + UINT32ENCODE(*p, (uint32_t)0); /* Store the un-used padding */ + UINT32ENCODE(*p, (uint32_t)0); /* Store the additional information length */ FUNC_LEAVE_NOAPI(SUCCEED) } /* H5S_all_serialize() */ diff --git a/src/H5Shyper.c b/src/H5Shyper.c index 11e5369..1a4e4f5 100644 --- a/src/H5Shyper.c +++ b/src/H5Shyper.c @@ -2014,14 +2014,14 @@ H5S_hyper_serial_size(const H5S_t *space) PURPOSE Serialize the current selection into a user-provided buffer. USAGE - void H5S_hyper_serialize_helper(spans, start, end, rank, buf) + herr_t H5S_hyper_serialize_helper(spans, start, end, rank, buf) H5S_hyper_span_info_t *spans; IN: Hyperslab span tree to serialize hssize_t start[]; IN/OUT: Accumulated start points hssize_t end[]; IN/OUT: Accumulated end points hsize_t rank; IN: Current rank looking at uint8 *buf; OUT: Buffer to put serialized selection into RETURNS - + Non-negative on success/Negative on failure DESCRIPTION Serializes the current element selection into a buffer. (Primarily for storing on disk). @@ -2030,13 +2030,13 @@ H5S_hyper_serial_size(const H5S_t *space) EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -static void -H5S_hyper_serialize_helper(const H5S_hyper_span_info_t *spans, +static herr_t +H5S_hyper_serialize_helper (const H5S_hyper_span_info_t *spans, hsize_t *start, hsize_t *end, hsize_t rank, uint8_t **p) { H5S_hyper_span_t *curr; /* Pointer to current hyperslab span */ - uint8_t *pp = (*p); /* Local pointer for decoding */ hsize_t u; /* Index variable */ + herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_NOAPI_NOINIT @@ -2045,7 +2045,7 @@ H5S_hyper_serialize_helper(const H5S_hyper_span_info_t *spans, HDassert(start); HDassert(end); HDassert(rank < H5O_LAYOUT_NDIMS); - HDassert(p && pp); + HDassert(p && *p); /* Walk through the list of spans, recursing or outputing them */ curr=spans->head; @@ -2057,35 +2057,33 @@ H5S_hyper_serialize_helper(const H5S_hyper_span_info_t *spans, end[rank]=curr->high; /* Recurse down to the next dimension */ - *p = pp; - H5S_hyper_serialize_helper(curr->down, start, end, rank = 1, p); + if(H5S_hyper_serialize_helper(curr->down,start,end,rank+1,p)<0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTFREE, FAIL, "failed to release hyperslab spans") } /* end if */ else { /* Encode all the previous dimensions starting & ending points */ /* Encode previous starting points */ for(u=0; ulow); + UINT32ENCODE(*p, (uint32_t)curr->low); /* Encode previous ending points */ for(u=0; uhigh); + UINT32ENCODE(*p, (uint32_t)curr->high); } /* end else */ /* Advance to next node */ curr=curr->next; } /* end while */ - /* Update encoding pointer */ - *p = pp; - - FUNC_LEAVE_NOAPI_VOID +done: + FUNC_LEAVE_NOAPI(ret_value) } /* H5S_hyper_serialize_helper() */ @@ -2111,15 +2109,14 @@ H5S_hyper_serialize_helper(const H5S_hyper_span_info_t *spans, REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S_hyper_serialize(const H5S_t *space, uint8_t **p) +H5S_hyper_serialize (const H5S_t *space, uint8_t **p) { const H5S_hyper_dim_t *diminfo; /* Alias for dataspace's diminfo information */ - uint8_t *pp = (*p); /* Local pointer for decoding */ hsize_t tmp_count[H5O_LAYOUT_NDIMS]; /* Temporary hyperslab counts */ - hsize_t offset[H5O_LAYOUT_NDIMS]; /* Offset of element in dataspace */ + hsize_t offset[H5O_LAYOUT_NDIMS]; /* Offset of element in dataspace */ hsize_t start[H5O_LAYOUT_NDIMS]; /* Location of start of hyperslab */ hsize_t end[H5O_LAYOUT_NDIMS]; /* Location of end of hyperslab */ - hsize_t temp_off; /* Offset in a given dimension */ + hsize_t temp_off; /* Offset in a given dimension */ uint8_t *lenp; /* pointer to length location for later storage */ uint32_t len = 0; /* number of bytes used */ uint32_t version; /* Version number */ @@ -2131,10 +2128,7 @@ H5S_hyper_serialize(const H5S_t *space, uint8_t **p) FUNC_ENTER_NOAPI_NOINIT_NOERR - /* Check args */ HDassert(space); - HDassert(p); - HDassert(pp); /* Calculate version */ if(space->select.sel_info.hslab->unlim_dim >= 0) { @@ -2145,17 +2139,17 @@ H5S_hyper_serialize(const H5S_t *space, uint8_t **p) version = 1; /* Store the preamble information */ - UINT32ENCODE(pp, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */ - UINT32ENCODE(pp, version); /* Store the version number */ + UINT32ENCODE(*p, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */ + UINT32ENCODE(*p, version); /* Store the version number */ if(version >= 2) - *pp++ = flags; /* Store the flags */ + *(*p)++ = flags; /* Store the flags */ else - UINT32ENCODE(pp, (uint32_t)0); /* Store the un-used padding */ - lenp = pp; /* Keep the pointer to the length location for later */ - pp += 4; /* Skip over space for length */ + UINT32ENCODE(*p, (uint32_t)0); /* Store the un-used padding */ + lenp = *p; /* keep the pointer to the length location for later */ + *p += 4; /* skip over space for length */ /* Encode number of dimensions */ - UINT32ENCODE(pp, (uint32_t)space->extent.rank); + UINT32ENCODE(*p, (uint32_t)space->extent.rank); len += 4; /* If there is an unlimited dimension, only encode opt_unlim_diminfo */ @@ -2167,10 +2161,10 @@ H5S_hyper_serialize(const H5S_t *space, uint8_t **p) /* Iterate over dimensions */ for(i = 0; i < space->extent.rank; i++) { /* Encode start/stride/block/count */ - UINT64ENCODE(pp, space->select.sel_info.hslab->opt_diminfo[i].start); - UINT64ENCODE(pp, space->select.sel_info.hslab->opt_diminfo[i].stride); - UINT64ENCODE(pp, space->select.sel_info.hslab->opt_diminfo[i].count); - UINT64ENCODE(pp, space->select.sel_info.hslab->opt_diminfo[i].block); + UINT64ENCODE(*p, space->select.sel_info.hslab->opt_diminfo[i].start); + UINT64ENCODE(*p, space->select.sel_info.hslab->opt_diminfo[i].stride); + UINT64ENCODE(*p, space->select.sel_info.hslab->opt_diminfo[i].count); + UINT64ENCODE(*p, space->select.sel_info.hslab->opt_diminfo[i].block); } /* end for */ } /* end if */ /* Check for a "regular" hyperslab selection */ @@ -2188,7 +2182,7 @@ H5S_hyper_serialize(const H5S_t *space, uint8_t **p) /* Encode number of hyperslabs */ H5_CHECK_OVERFLOW(block_count, hsize_t, uint32_t); - UINT32ENCODE(pp, (uint32_t)block_count); + UINT32ENCODE(*p, (uint32_t)block_count); len+=4; /* Now serialize the information for the regular hyperslab */ @@ -2211,11 +2205,11 @@ H5S_hyper_serialize(const H5S_t *space, uint8_t **p) /* Encode hyperslab starting location */ for(u = 0; u < ndims; u++) - UINT32ENCODE(pp, (uint32_t)offset[u]); + UINT32ENCODE(*p, (uint32_t)offset[u]); /* Encode hyperslab ending location */ for(u = 0; u < ndims; u++) - UINT32ENCODE(pp, (uint32_t)(offset[u] + (diminfo[u].block - 1))); + UINT32ENCODE(*p, (uint32_t)(offset[u] + (diminfo[u].block - 1))); /* Move the offset to the next sequence to start */ offset[fast_dim]+=diminfo[fast_dim].stride; @@ -2266,7 +2260,7 @@ H5S_hyper_serialize(const H5S_t *space, uint8_t **p) /* Encode number of hyperslabs */ block_count = H5S_hyper_span_nblocks(space->select.sel_info.hslab->span_lst); H5_CHECK_OVERFLOW(block_count, hsize_t, uint32_t); - UINT32ENCODE(pp, (uint32_t)block_count); + UINT32ENCODE(*p, (uint32_t)block_count); len+=4; /* Add 8 bytes times the rank for each hyperslab selected */ @@ -2274,16 +2268,12 @@ H5S_hyper_serialize(const H5S_t *space, uint8_t **p) len += (uint32_t)(8 * space->extent.rank * block_count); /* Encode each hyperslab in selection */ - *p = pp; H5S_hyper_serialize_helper(space->select.sel_info.hslab->span_lst, start, end, (hsize_t)0, p); } /* end else */ /* Encode length */ UINT32ENCODE(lenp, (uint32_t)len); /* Store the length of the extra information */ - /* Update encoding pointer */ - *p = pp; - FUNC_LEAVE_NOAPI(SUCCEED) } /* H5S_hyper_serialize() */ @@ -2316,7 +2306,6 @@ static herr_t H5S_hyper_deserialize(H5S_t *space, uint32_t H5_ATTR_UNUSED version, uint8_t flags, const uint8_t **p) { - const uint8_t *pp = (*p); /* Local pointer for decoding */ unsigned rank; /* rank of points */ size_t num_elem=0; /* number of elements in selection */ hsize_t start[H5O_LAYOUT_NDIMS]; /* hyperslab start information */ @@ -2337,7 +2326,7 @@ H5S_hyper_deserialize(H5S_t *space, uint32_t H5_ATTR_UNUSED version, uint8_t fla /* Check args */ HDassert(space); HDassert(p); - HDassert(pp); + HDassert(*p); /* Deserialize slabs to select */ /* (The header and rank have already beed decoded) */ @@ -2351,10 +2340,10 @@ H5S_hyper_deserialize(H5S_t *space, uint32_t H5_ATTR_UNUSED version, uint8_t fla /* Iterate over dimensions */ for(i = 0; i < space->extent.rank; i++) { /* Decode start/stride/block/count */ - UINT64DECODE(pp, start[i]); - UINT64DECODE(pp, stride[i]); - UINT64DECODE(pp, count[i]); - UINT64DECODE(pp, block[i]); + UINT64DECODE(*p, start[i]); + UINT64DECODE(*p, stride[i]); + UINT64DECODE(*p, count[i]); + UINT64DECODE(*p, block[i]); } /* end for */ /* Select the hyperslab to the current selection */ @@ -2363,7 +2352,7 @@ H5S_hyper_deserialize(H5S_t *space, uint32_t H5_ATTR_UNUSED version, uint8_t fla } /* end if */ else { /* decode the number of points */ - UINT32DECODE(pp,num_elem); + UINT32DECODE(*p,num_elem); /* Set the count & stride for all blocks */ for(tcount=count,tstride=stride,j=0; jextent.rank); + UINT32ENCODE(*p, (uint32_t)space->extent.rank); len+=4; /* Encode number of elements */ - UINT32ENCODE(pp, (uint32_t)space->select.num_elem); + UINT32ENCODE(*p, (uint32_t)space->select.num_elem); len+=4; /* Encode each point in selection */ @@ -862,7 +858,7 @@ H5S_point_serialize (const H5S_t *space, uint8_t **p) /* Encode each point */ for(u=0; uextent.rank; u++) - UINT32ENCODE(pp, (uint32_t)curr->pnt[u]); + UINT32ENCODE(*p, (uint32_t)curr->pnt[u]); curr=curr->next; } /* end while */ @@ -870,9 +866,6 @@ H5S_point_serialize (const H5S_t *space, uint8_t **p) /* Encode length */ UINT32ENCODE(lenp, (uint32_t)len); /* Store the length of the extra information */ - /* Update encoding pointer */ - *p = pp; - FUNC_LEAVE_NOAPI(SUCCEED) } /* H5S_point_serialize() */ @@ -905,25 +898,24 @@ static herr_t H5S_point_deserialize(H5S_t *space, uint32_t H5_ATTR_UNUSED version, uint8_t H5_ATTR_UNUSED flags, const uint8_t **p) { - H5S_seloper_t op = H5S_SELECT_SET; /* Selection operation */ - hsize_t *coord = NULL, *tcoord; /* Pointer to array of elements */ - const uint8_t *pp = (*p); /* Local pointer for decoding */ - size_t num_elem = 0; /* Number of elements in selection */ - unsigned rank; /* Rank of points */ + H5S_seloper_t op=H5S_SELECT_SET; /* Selection operation */ + unsigned rank; /* Rank of points */ + size_t num_elem=0; /* Number of elements in selection */ + hsize_t *coord=NULL, *tcoord; /* Pointer to array of elements */ unsigned i, j; /* local counting variables */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_NOAPI_NOINIT /* Check args */ HDassert(space); HDassert(p); - HDassert(pp); + HDassert(*p); /* Deserialize points to select */ /* (The header and rank have already beed decoded) */ rank = space->extent.rank; /* Retrieve rank from space */ - UINT32DECODE(pp, num_elem); /* decode the number of points */ + UINT32DECODE(*p, num_elem); /* decode the number of points */ /* Allocate space for the coordinates */ if(NULL == (coord = (hsize_t *)H5MM_malloc(num_elem * rank * sizeof(hsize_t)))) @@ -932,15 +924,12 @@ H5S_point_deserialize(H5S_t *space, uint32_t H5_ATTR_UNUSED version, uint8_t H5_ /* Retrieve the coordinates from the buffer */ for(tcoord = coord, i = 0; i < num_elem; i++) for(j = 0; j < (unsigned)rank; j++, tcoord++) - UINT32DECODE(pp, *tcoord); + UINT32DECODE(*p, *tcoord); /* Select points */ if(H5S_select_elements(space, op, num_elem, (const hsize_t *)coord) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection") - /* Update decoding pointer */ - *p = pp; - done: /* Free the coordinate array if necessary */ if(coord != NULL) -- cgit v0.12