summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorM. Scot Breitenfeld <brtnfld@hdfgroup.org>2019-06-25 17:39:35 (GMT)
committerM. Scot Breitenfeld <brtnfld@hdfgroup.org>2019-06-25 17:39:35 (GMT)
commit35c9af8371c4da7f5327c76ddab097b442128f59 (patch)
treed51be51c385a9b463388ba154efc3fa37cad49e8 /src
parentc752332bfd0e9c3090f3a0c02d0253cd45c2e2ce (diff)
parent1d8f7bf297100ec11204442708a7f670a89f3f02 (diff)
downloadhdf5-inactive/parallel_vds_develop.zip
hdf5-inactive/parallel_vds_develop.tar.gz
hdf5-inactive/parallel_vds_develop.tar.bz2
Merge branch 'develop' into parallel_vds_developinactive/parallel_vds_develop
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt86
-rw-r--r--src/H5.c6
-rw-r--r--src/H5A.c26
-rw-r--r--src/H5AC.c2
-rw-r--r--src/H5Abtree2.c9
-rw-r--r--src/H5Adense.c41
-rw-r--r--src/H5Adeprec.c13
-rw-r--r--src/H5Aint.c66
-rw-r--r--src/H5Apkg.h2
-rw-r--r--src/H5B.c59
-rw-r--r--src/H5B2.c8
-rw-r--r--src/H5B2cache.c6
-rw-r--r--src/H5B2int.c75
-rw-r--r--src/H5B2leaf.c14
-rw-r--r--src/H5Bcache.c3
-rw-r--r--src/H5Bdbg.c6
-rw-r--r--src/H5C.c69
-rw-r--r--src/H5CX.c646
-rw-r--r--src/H5CXprivate.h30
-rw-r--r--src/H5Cimage.c16
-rw-r--r--src/H5Clog_trace.c2
-rw-r--r--src/H5Cmpio.c12
-rw-r--r--src/H5D.c44
-rw-r--r--src/H5Dbtree.c5
-rw-r--r--src/H5Dbtree2.c3
-rw-r--r--src/H5Dchunk.c585
-rw-r--r--src/H5Dcompact.c18
-rw-r--r--src/H5Dcontig.c68
-rw-r--r--src/H5Ddeprec.c18
-rw-r--r--src/H5Dearray.c11
-rw-r--r--src/H5Defl.c5
-rw-r--r--src/H5Dfarray.c4
-rw-r--r--src/H5Dfill.c11
-rw-r--r--src/H5Dint.c116
-rw-r--r--src/H5Dio.c4
-rw-r--r--src/H5Dlayout.c1
-rw-r--r--src/H5Dmpio.c114
-rw-r--r--src/H5Dpkg.h17
-rw-r--r--src/H5Dprivate.h1
-rw-r--r--src/H5Dscatgath.c88
-rw-r--r--src/H5Dselect.c10
-rw-r--r--src/H5Dvirtual.c71
-rw-r--r--src/H5E.c10
-rw-r--r--src/H5EA.c5
-rw-r--r--src/H5EAcache.c13
-rw-r--r--src/H5EAdbg.c6
-rw-r--r--src/H5EAhdr.c3
-rw-r--r--src/H5EAstat.c3
-rw-r--r--src/H5EAtest.c2
-rw-r--r--src/H5Eint.c14
-rw-r--r--src/H5F.c109
-rw-r--r--src/H5FA.c9
-rw-r--r--src/H5FAcache.c9
-rw-r--r--src/H5FAhdr.c3
-rw-r--r--src/H5FAstat.c3
-rw-r--r--src/H5FAtest.c2
-rw-r--r--src/H5FD.c4
-rw-r--r--src/H5FDcore.c6
-rw-r--r--src/H5FDdirect.c10
-rw-r--r--src/H5FDfamily.c6
-rw-r--r--src/H5FDlog.c2
-rw-r--r--src/H5FDmpio.c2
-rw-r--r--src/H5FDmulti.c52
-rw-r--r--src/H5FL.c12
-rw-r--r--src/H5FS.c3
-rw-r--r--src/H5FScache.c5
-rw-r--r--src/H5Faccum.c21
-rw-r--r--src/H5Fint.c25
-rw-r--r--src/H5Fmpi.c2
-rw-r--r--src/H5Fprivate.h26
-rw-r--r--src/H5Fpublic.h7
-rw-r--r--src/H5Fsuper.c14
-rw-r--r--src/H5Fsuper_cache.c4
-rw-r--r--src/H5G.c11
-rw-r--r--src/H5Gbtree2.c13
-rw-r--r--src/H5Gcache.c3
-rw-r--r--src/H5Gdeprec.c49
-rw-r--r--src/H5Gent.c3
-rw-r--r--src/H5Glink.c19
-rw-r--r--src/H5Gloc.c5
-rw-r--r--src/H5Gname.c3
-rw-r--r--src/H5Gnode.c4
-rw-r--r--src/H5Gtest.c1
-rw-r--r--src/H5Gtraverse.c4
-rw-r--r--src/H5HF.c6
-rw-r--r--src/H5HFcache.c20
-rw-r--r--src/H5HFdbg.c2
-rw-r--r--src/H5HFhdr.c3
-rw-r--r--src/H5HFhuge.c4
-rw-r--r--src/H5HFman.c2
-rw-r--r--src/H5HFsection.c8
-rw-r--r--src/H5HFtest.c4
-rw-r--r--src/H5HFtiny.c3
-rw-r--r--src/H5HG.c6
-rw-r--r--src/H5HGcache.c4
-rw-r--r--src/H5HL.c2
-rw-r--r--src/H5HLcache.c11
-rw-r--r--src/H5I.c11
-rw-r--r--src/H5Ipublic.h1
-rw-r--r--src/H5L.c43
-rw-r--r--src/H5Lexternal.c17
-rw-r--r--src/H5MM.c46
-rw-r--r--src/H5MMprivate.h1
-rw-r--r--src/H5O.c14
-rw-r--r--src/H5Oalloc.c11
-rw-r--r--src/H5Oattr.c20
-rw-r--r--src/H5Oattribute.c2
-rw-r--r--src/H5Ocache.c7
-rw-r--r--src/H5Ocopy.c4
-rw-r--r--src/H5Odrvinfo.c10
-rw-r--r--src/H5Odtype.c8
-rw-r--r--src/H5Oefl.c4
-rw-r--r--src/H5Ofill.c43
-rw-r--r--src/H5Oflush.c1
-rw-r--r--src/H5Oint.c8
-rw-r--r--src/H5Olayout.c18
-rw-r--r--src/H5Olink.c14
-rw-r--r--src/H5Omtime.c2
-rw-r--r--src/H5Oname.c2
-rw-r--r--src/H5Opkg.h4
-rw-r--r--src/H5Opline.c5
-rw-r--r--src/H5Osdspace.c8
-rw-r--r--src/H5Oshared.c5
-rw-r--r--src/H5P.c19
-rw-r--r--src/H5PB.c23
-rw-r--r--src/H5Pacpl.c50
-rw-r--r--src/H5Pdapl.c6
-rw-r--r--src/H5Pdcpl.c44
-rw-r--r--src/H5Pdeprec.c49
-rw-r--r--src/H5Pdxpl.c2
-rw-r--r--src/H5Pfapl.c59
-rw-r--r--src/H5Pgcpl.c6
-rw-r--r--src/H5Pint.c249
-rw-r--r--src/H5Plapl.c2
-rw-r--r--src/H5Plcpl.c54
-rw-r--r--src/H5Pocpl.c2
-rw-r--r--src/H5Pocpypl.c2
-rw-r--r--src/H5Ppkg.h4
-rw-r--r--src/H5Pprivate.h4
-rw-r--r--src/H5Ppublic.h7
-rw-r--r--src/H5Rint.c4
-rw-r--r--src/H5S.c446
-rw-r--r--src/H5SL.c4
-rw-r--r--src/H5SM.c5
-rw-r--r--src/H5SMbtree2.c3
-rw-r--r--src/H5SMcache.c4
-rw-r--r--src/H5SMmessage.c5
-rw-r--r--src/H5ST.c16
-rw-r--r--src/H5Sall.c370
-rw-r--r--src/H5Sdbg.c18
-rw-r--r--src/H5Sdeprec.c121
-rw-r--r--src/H5Shyper.c10691
-rw-r--r--src/H5Smpio.c1243
-rw-r--r--src/H5Snone.c577
-rw-r--r--src/H5Spkg.h191
-rw-r--r--src/H5Spoint.c1577
-rw-r--r--src/H5Sprivate.h58
-rw-r--r--src/H5Spublic.h113
-rw-r--r--src/H5Sselect.c910
-rw-r--r--src/H5Stest.c333
-rw-r--r--src/H5T.c60
-rw-r--r--src/H5Tcommit.c4
-rw-r--r--src/H5Tconv.c24
-rw-r--r--src/H5Tenum.c6
-rw-r--r--src/H5Tfields.c12
-rw-r--r--src/H5Tnative.c14
-rw-r--r--src/H5Torder.c4
-rw-r--r--src/H5Tvlen.c34
-rw-r--r--src/H5VL.c443
-rw-r--r--src/H5VLcallback.c360
-rw-r--r--src/H5VLconnector.h417
-rw-r--r--src/H5VLconnector_passthru.h166
-rw-r--r--src/H5VLint.c1044
-rw-r--r--src/H5VLnative.c25
-rw-r--r--src/H5VLnative_attr.c16
-rw-r--r--src/H5VLnative_dataset.c19
-rw-r--r--src/H5VLnative_file.c25
-rw-r--r--src/H5VLnative_group.c14
-rw-r--r--src/H5VLnative_link.c32
-rw-r--r--src/H5VLnative_object.c25
-rw-r--r--src/H5VLnative_private.h8
-rw-r--r--src/H5VLpassthru.c314
-rw-r--r--src/H5VLpkg.h15
-rw-r--r--src/H5VLprivate.h36
-rw-r--r--src/H5VLpublic.h491
-rw-r--r--src/H5VM.c23
-rw-r--r--src/H5VMprivate.h3
-rw-r--r--src/H5Z.c6
-rw-r--r--src/H5Zfletcher32.c6
-rw-r--r--src/H5Zscaleoffset.c29
-rw-r--r--src/H5Zshuffle.c18
-rw-r--r--src/H5Ztrans.c8
-rw-r--r--src/H5checksum.c11
-rw-r--r--src/H5dbg.c2
-rw-r--r--src/H5err.txt2
-rw-r--r--src/H5private.h14
-rw-r--r--src/H5public.h4
-rw-r--r--src/H5system.c132
-rw-r--r--src/H5timer.c16
-rw-r--r--src/H5trace.c26
-rw-r--r--src/H5vers.txt2
-rw-r--r--src/H5win32defs.h14
-rw-r--r--src/Makefile.am13
-rw-r--r--src/libhdf5.settings.in2
204 files changed, 15150 insertions, 9342 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 6b105a9..4cf4965 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -533,6 +533,7 @@ set (H5S_SOURCES
${HDF5_SRC_DIR}/H5S.c
${HDF5_SRC_DIR}/H5Sall.c
${HDF5_SRC_DIR}/H5Sdbg.c
+ ${HDF5_SRC_DIR}/H5Sdeprec.c
${HDF5_SRC_DIR}/H5Shyper.c
${HDF5_SRC_DIR}/H5Smpio.c
${HDF5_SRC_DIR}/H5Snone.c
@@ -639,6 +640,8 @@ set (H5VL_SOURCES
${HDF5_SRC_DIR}/H5VLpassthru.c
)
set (H5VL_HDRS
+ ${HDF5_SRC_DIR}/H5VLconnector.h
+ ${HDF5_SRC_DIR}/H5VLconnector_passthru.h
${HDF5_SRC_DIR}/H5VLnative.h
${HDF5_SRC_DIR}/H5VLpassthru.h
${HDF5_SRC_DIR}/H5VLpublic.h
@@ -944,7 +947,7 @@ if (BUILD_SHARED_LIBS)
endif ()
if (LOCAL_BATCH_TEST)
- if ("${LOCAL_BATCH_SCRIPT_COMMAND}" STREQUAL "raybsub")
+ if (LOCAL_BATCH_SCRIPT_COMMAND STREQUAL "raybsub")
configure_file (
${HDF5_SOURCE_DIR}/bin/batch/${LOCAL_BATCH_SCRIPT_COMMAND}
${HDF5_BINARY_DIR}/${LOCAL_BATCH_SCRIPT_COMMAND} ESCAPE_QUOTES @ONLY
@@ -966,7 +969,7 @@ endif ()
if (NOT EXISTS ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c)
add_executable (H5detect ${HDF5_SRC_DIR}/H5detect.c)
- target_include_directories(H5detect PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_include_directories (H5detect PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
target_compile_definitions(H5detect PUBLIC ${HDF_EXTRA_C_FLAGS} ${HDF_EXTRA_FLAGS})
TARGET_C_PROPERTIES (H5detect STATIC)
target_link_libraries (H5detect
@@ -1056,7 +1059,7 @@ else ()
endif ()
add_executable (H5make_libsettings ${HDF5_SRC_DIR}/H5make_libsettings.c)
-target_include_directories(H5make_libsettings PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+target_include_directories (H5make_libsettings PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
target_compile_definitions(H5make_libsettings PUBLIC ${HDF_EXTRA_C_FLAGS} ${HDF_EXTRA_FLAGS})
TARGET_C_PROPERTIES (H5make_libsettings STATIC)
target_link_libraries (H5make_libsettings
@@ -1096,41 +1099,48 @@ option (HDF5_ENABLE_DEBUG_APIS "Turn on extra debug output in all packages" OFF)
#-----------------------------------------------------------------------------
# Add H5Tinit source to build - generated by H5detect/CMake at configure time
#-----------------------------------------------------------------------------
-set (gen_SRCS ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c ${HDF5_BINARY_DIR}/H5lib_settings.c)
-add_custom_target (gen_${HDF5_LIB_TARGET} ALL DEPENDS ${HDF5_GENERATED_SOURCE_DIR}/gen_SRCS.stamp1 ${HDF5_GENERATED_SOURCE_DIR}/gen_SRCS.stamp2)
-
-add_library (${HDF5_LIB_TARGET} STATIC ${common_SRCS} ${gen_SRCS} ${H5_PUBLIC_HEADERS} ${H5_PRIVATE_HEADERS} ${H5_GENERATED_HEADERS})
-target_include_directories(${HDF5_LIB_TARGET}
- PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>"
- INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
-)
-target_compile_definitions(${HDF5_LIB_TARGET}
- PUBLIC
- ${HDF_EXTRA_C_FLAGS}
- ${HDF_EXTRA_FLAGS}
- $<IF:$<CONFIG:Debug>,DEBUG,NDEBUG>
- PRIVATE
- $<$<BOOL:${HDF5_ENABLE_TRACE}>:H5_DEBUG_API> # Enable tracing of the API
- $<$<BOOL:${HDF5_ENABLE_DEBUG_APIS}>:H5Z_DEBUG;H5T_DEBUG;H5ST_DEBUG;H5S_DEBUG;H5O_DEBUG;H5I_DEBUG;H5HL_DEBUG;H5F_DEBUG;H5D_DEBUG;H5B2_DEBUG;H5AC_DEBUG>
-)
-TARGET_C_PROPERTIES (${HDF5_LIB_TARGET} STATIC)
-target_link_libraries (${HDF5_LIB_TARGET}
- PRIVATE ${LINK_LIBS} ${LINK_COMP_LIBS} "$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_LIBRARIES}>"
- PUBLIC $<$<NOT:$<PLATFORM_ID:Windows>>:${CMAKE_DL_LIBS}>
-)
-set_global_variable (HDF5_LIBRARIES_TO_EXPORT ${HDF5_LIB_TARGET})
-H5_SET_LIB_OPTIONS (${HDF5_LIB_TARGET} ${HDF5_LIB_NAME} STATIC 0)
-set_target_properties (${HDF5_LIB_TARGET} PROPERTIES FOLDER libraries)
-add_dependencies (${HDF5_LIB_TARGET} gen_${HDF5_LIB_TARGET})
-
-set (install_targets ${HDF5_LIB_TARGET})
+if (NOT ONLY_SHARED_LIBS)
+ set (gen_SRCS ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c ${HDF5_BINARY_DIR}/H5lib_settings.c)
+ add_custom_target (gen_${HDF5_LIB_TARGET} ALL DEPENDS ${HDF5_GENERATED_SOURCE_DIR}/gen_SRCS.stamp1 ${HDF5_GENERATED_SOURCE_DIR}/gen_SRCS.stamp2)
+
+ add_library (${HDF5_LIB_TARGET} STATIC ${common_SRCS} ${gen_SRCS} ${H5_PUBLIC_HEADERS} ${H5_PRIVATE_HEADERS} ${H5_GENERATED_HEADERS})
+ target_include_directories (${HDF5_LIB_TARGET}
+ PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>"
+ INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
+ )
+ target_compile_definitions(${HDF5_LIB_TARGET}
+ PUBLIC
+ ${HDF_EXTRA_C_FLAGS}
+ ${HDF_EXTRA_FLAGS}
+ $<IF:$<CONFIG:Debug>,DEBUG,NDEBUG>
+ PRIVATE
+ $<$<BOOL:${HDF5_ENABLE_TRACE}>:H5_DEBUG_API> # Enable tracing of the API
+ $<$<BOOL:${HDF5_ENABLE_DEBUG_APIS}>:H5Z_DEBUG;H5T_DEBUG;H5ST_DEBUG;H5S_DEBUG;H5O_DEBUG;H5I_DEBUG;H5HL_DEBUG;H5F_DEBUG;H5D_DEBUG;H5B2_DEBUG;H5AC_DEBUG>
+ )
+ TARGET_C_PROPERTIES (${HDF5_LIB_TARGET} STATIC)
+ target_link_libraries (${HDF5_LIB_TARGET}
+ PRIVATE ${LINK_LIBS} ${LINK_COMP_LIBS} "$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_LIBRARIES}>"
+ PUBLIC $<$<NOT:$<PLATFORM_ID:Windows>>:${CMAKE_DL_LIBS}>
+ )
+ if (NOT WIN32)
+ target_link_libraries (${HDF5_LIB_TARGET}
+ PRIVATE $<$<BOOL:${HDF5_ENABLE_THREADSAFE}>:Threads::Threads>
+ )
+ endif ()
+ set_global_variable (HDF5_LIBRARIES_TO_EXPORT ${HDF5_LIB_TARGET})
+ H5_SET_LIB_OPTIONS (${HDF5_LIB_TARGET} ${HDF5_LIB_NAME} STATIC 0)
+ set_target_properties (${HDF5_LIB_TARGET} PROPERTIES FOLDER libraries)
+ add_dependencies (${HDF5_LIB_TARGET} gen_${HDF5_LIB_TARGET})
+
+ set (install_targets ${HDF5_LIB_TARGET})
+endif ()
if (BUILD_SHARED_LIBS)
set (shared_gen_SRCS ${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c ${HDF5_BINARY_DIR}/shared/H5lib_settings.c)
add_custom_target (gen_${HDF5_LIBSH_TARGET} ALL DEPENDS ${HDF5_GENERATED_SOURCE_DIR}/shared/shared_gen_SRCS.stamp1 ${HDF5_GENERATED_SOURCE_DIR}/shared/shared_gen_SRCS.stamp2)
add_library (${HDF5_LIBSH_TARGET} SHARED ${common_SRCS} ${shared_gen_SRCS} ${H5_PUBLIC_HEADERS} ${H5_PRIVATE_HEADERS} ${H5_GENERATED_HEADERS})
- target_include_directories(${HDF5_LIBSH_TARGET}
+ target_include_directories (${HDF5_LIBSH_TARGET}
PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>"
INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
)
@@ -1147,8 +1157,8 @@ if (BUILD_SHARED_LIBS)
)
TARGET_C_PROPERTIES (${HDF5_LIBSH_TARGET} SHARED)
target_link_libraries (${HDF5_LIBSH_TARGET}
- PRIVATE ${LINK_LIBS} ${LINK_COMP_LIBS} "$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_LIBRARIES}>"
- PUBLIC $<$<NOT:$<PLATFORM_ID:Windows>>:${CMAKE_DL_LIBS}> $<$<BOOL:${HDF5_ENABLE_THREADSAFE}>:Threads::Threads>
+ PRIVATE ${LINK_LIBS} ${LINK_COMP_LIBS} "$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_LIBRARIES}>" $<$<BOOL:${HDF5_ENABLE_THREADSAFE}>:Threads::Threads>
+ PUBLIC $<$<NOT:$<PLATFORM_ID:Windows>>:${CMAKE_DL_LIBS}>
)
set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_LIBSH_TARGET}")
H5_SET_LIB_OPTIONS (${HDF5_LIBSH_TARGET} ${HDF5_LIB_NAME} SHARED "LIB")
@@ -1181,7 +1191,9 @@ if (HDF5_EXPORTED_TARGETS)
if (BUILD_SHARED_LIBS)
INSTALL_TARGET_PDB (${HDF5_LIBSH_TARGET} ${HDF5_INSTALL_BIN_DIR} libraries)
endif ()
- INSTALL_TARGET_PDB (${HDF5_LIB_TARGET} ${HDF5_INSTALL_BIN_DIR} libraries)
+ if (NOT ONLY_SHARED_LIBS)
+ INSTALL_TARGET_PDB (${HDF5_LIB_TARGET} ${HDF5_INSTALL_BIN_DIR} libraries)
+ endif ()
install (
TARGETS
@@ -1210,7 +1222,9 @@ foreach (libs ${LINK_LIBS} ${LINK_COMP_LIBS})
set (_PKG_CONFIG_LIBS_PRIVATE "${_PKG_CONFIG_LIBS_PRIVATE} -l${libs}")
endforeach ()
-set (_PKG_CONFIG_LIBS "${_PKG_CONFIG_LIBS} -l${HDF5_LIB_CORENAME}")
+if (NOT ONLY_SHARED_LIBS)
+ set (_PKG_CONFIG_LIBS "${_PKG_CONFIG_LIBS} -l${HDF5_LIB_CORENAME}")
+endif ()
if (BUILD_SHARED_LIBS)
set (_PKG_CONFIG_SH_LIBS "${_PKG_CONFIG_SH_LIBS} -l${HDF5_LIB_CORENAME}")
endif ()
diff --git a/src/H5.c b/src/H5.c
index bf4643c..104c9fd 100644
--- a/src/H5.c
+++ b/src/H5.c
@@ -214,7 +214,7 @@ H5_init_library(void)
*/
if(H5E_init() < 0)
HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize error interface")
- if(H5VL_init() < 0)
+ if(H5VL_init_phase1() < 0)
HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize vol interface")
if(H5P_init() < 0)
HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize property list interface")
@@ -229,6 +229,10 @@ H5_init_library(void)
if(H5FS_init() < 0)
HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize FS interface")
+ /* Finish initializing interfaces that depend on the interfaces above */
+ if(H5VL_init_phase2() < 0)
+ HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize vol interface")
+
/* Debugging? */
H5_debug_mask("-all");
H5_debug_mask(HDgetenv("HDF5_DEBUG"));
diff --git a/src/H5A.c b/src/H5A.c
index 9c3ad7e..abf8694 100644
--- a/src/H5A.c
+++ b/src/H5A.c
@@ -254,7 +254,6 @@ H5Acreate2(hid_t loc_id, const char *attr_name, hid_t type_id, hid_t space_id,
{
void *attr = NULL; /* Attribute created */
H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */
- H5P_genplist_t *plist; /* Property list pointer */
H5VL_loc_params_t loc_params;
hid_t ret_value = H5I_INVALID_HID; /* Return value */
@@ -277,16 +276,6 @@ H5Acreate2(hid_t loc_id, const char *attr_name, hid_t type_id, hid_t space_id,
if(H5CX_set_apl(&aapl_id, H5P_CLS_AACC, loc_id, TRUE) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info")
- /* Get the property list structure for the acpl */
- if(NULL == (plist = (H5P_genplist_t *)H5I_object(acpl_id)))
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
-
- /* Set creation properties */
- if(H5P_set(plist, H5VL_PROP_ATTR_TYPE_ID, &type_id) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for datatype id")
- if(H5P_set(plist, H5VL_PROP_ATTR_SPACE_ID, &space_id) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for space id")
-
/* Get the location object */
if(NULL == (vol_obj = H5VL_vol_object(loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier")
@@ -296,7 +285,7 @@ H5Acreate2(hid_t loc_id, const char *attr_name, hid_t type_id, hid_t space_id,
loc_params.obj_type = H5I_get_type(loc_id);
/* Create the attribute */
- if(NULL == (attr = H5VL_attr_create(vol_obj, &loc_params, attr_name, acpl_id, aapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)))
+ if(NULL == (attr = H5VL_attr_create(vol_obj, &loc_params, attr_name, type_id, space_id, acpl_id, aapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)))
HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, H5I_INVALID_HID, "unable to create attribute")
/* Register the new attribute and get an ID for it */
@@ -350,7 +339,6 @@ H5Acreate_by_name(hid_t loc_id, const char *obj_name, const char *attr_name,
{
void *attr = NULL; /* attr token from VOL connector */
H5VL_object_t *vol_obj = NULL; /* object token of loc_id */
- H5P_genplist_t *plist; /* Property list pointer */
H5VL_loc_params_t loc_params;
hid_t ret_value = H5I_INVALID_HID; /* Return value */
@@ -380,16 +368,6 @@ H5Acreate_by_name(hid_t loc_id, const char *obj_name, const char *attr_name,
H5CX_set_lapl(lapl_id);
}
- /* Get the plist structure */
- if(NULL == (plist = (H5P_genplist_t *)H5I_object(acpl_id)))
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5I_INVALID_HID, "can't find object for ID")
-
- /* Set creation properties */
- if(H5P_set(plist, H5VL_PROP_ATTR_TYPE_ID, &type_id) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for datatype id")
- if(H5P_set(plist, H5VL_PROP_ATTR_SPACE_ID, &space_id) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for space id")
-
/* Set up location struct */
loc_params.type = H5VL_OBJECT_BY_NAME;
loc_params.obj_type = H5I_get_type(loc_id);
@@ -401,7 +379,7 @@ H5Acreate_by_name(hid_t loc_id, const char *obj_name, const char *attr_name,
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier")
/* Create the attribute */
- if(NULL == (attr = H5VL_attr_create(vol_obj, &loc_params, attr_name, acpl_id, aapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)))
+ if(NULL == (attr = H5VL_attr_create(vol_obj, &loc_params, attr_name, type_id, space_id, acpl_id, aapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)))
HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, H5I_INVALID_HID, "unable to create attribute")
/* Register the new attribute and get an ID for it */
diff --git a/src/H5AC.c b/src/H5AC.c
index 440dfd8..dc88fd4 100644
--- a/src/H5AC.c
+++ b/src/H5AC.c
@@ -349,7 +349,7 @@ H5AC_create(const H5F_t *f, H5AC_cache_config_t *config_ptr, H5AC_cache_image_co
aux_ptr->sync_point_done = NULL;
aux_ptr->p0_image_len = 0;
- sprintf(prefix, "%d:", mpi_rank);
+ HDsprintf(prefix, "%d:", mpi_rank);
if(mpi_rank == 0) {
if(NULL == (aux_ptr->d_slist_ptr = H5SL_create(H5SL_TYPE_HADDR, NULL)))
diff --git a/src/H5Abtree2.c b/src/H5Abtree2.c
index 07da8e2..3377aa2 100644
--- a/src/H5Abtree2.c
+++ b/src/H5Abtree2.c
@@ -35,6 +35,7 @@
#include "H5private.h" /* Generic Functions */
#include "H5Apkg.h" /* Attributes */
#include "H5Eprivate.h" /* Error handling */
+#include "H5MMprivate.h" /* Memory management */
#include "H5SMprivate.h" /* Shared object header messages */
@@ -318,7 +319,7 @@ H5A__dense_btree2_name_encode(uint8_t *raw, const void *_nrecord, void H5_ATTR_U
FUNC_ENTER_STATIC_NOERR
/* Encode the record's fields */
- HDmemcpy(raw, nrecord->id.id, (size_t)H5O_FHEAP_ID_LEN);
+ H5MM_memcpy(raw, nrecord->id.id, (size_t)H5O_FHEAP_ID_LEN);
raw += H5O_FHEAP_ID_LEN;
*raw++ = nrecord->flags;
UINT32ENCODE(raw, nrecord->corder)
@@ -349,7 +350,7 @@ H5A__dense_btree2_name_decode(const uint8_t *raw, void *_nrecord, void H5_ATTR_U
FUNC_ENTER_STATIC_NOERR
/* Decode the record's fields */
- HDmemcpy(nrecord->id.id, raw, (size_t)H5O_FHEAP_ID_LEN);
+ H5MM_memcpy(nrecord->id.id, raw, (size_t)H5O_FHEAP_ID_LEN);
raw += H5O_FHEAP_ID_LEN;
nrecord->flags = *raw++;
UINT32DECODE(raw, nrecord->corder)
@@ -477,7 +478,7 @@ H5A__dense_btree2_corder_encode(uint8_t *raw, const void *_nrecord, void H5_ATTR
FUNC_ENTER_STATIC_NOERR
/* Encode the record's fields */
- HDmemcpy(raw, nrecord->id.id, (size_t)H5O_FHEAP_ID_LEN);
+ H5MM_memcpy(raw, nrecord->id.id, (size_t)H5O_FHEAP_ID_LEN);
raw += H5O_FHEAP_ID_LEN;
*raw++ = nrecord->flags;
UINT32ENCODE(raw, nrecord->corder)
@@ -507,7 +508,7 @@ H5A__dense_btree2_corder_decode(const uint8_t *raw, void *_nrecord, void H5_ATTR
FUNC_ENTER_STATIC_NOERR
/* Decode the record's fields */
- HDmemcpy(nrecord->id.id, raw, (size_t)H5O_FHEAP_ID_LEN);
+ H5MM_memcpy(nrecord->id.id, raw, (size_t)H5O_FHEAP_ID_LEN);
raw += H5O_FHEAP_ID_LEN;
nrecord->flags = *raw++;
UINT32DECODE(raw, nrecord->corder)
diff --git a/src/H5Adense.c b/src/H5Adense.c
index 021fa76..bddfe31 100644
--- a/src/H5Adense.c
+++ b/src/H5Adense.c
@@ -325,14 +325,11 @@ H5A__dense_fnd_cb(const H5A_t *attr, hbool_t *took_ownership, void *_user_attr)
*/
if(*user_attr != NULL) {
H5A_t *old_attr = *user_attr;
- if(old_attr->shared) {
- /* Free any dynamically allocated items */
- if(H5A__free(old_attr) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release attribute info")
- /* Destroy shared attribute struct */
- old_attr->shared = H5FL_FREE(H5A_shared_t, old_attr->shared);
- } /* end if */
+ /* Free any dynamically allocated items */
+ if(old_attr->shared)
+ if(H5A__shared_free(old_attr) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release attribute info")
old_attr = H5FL_FREE(H5A_t, old_attr);
} /* end if */
@@ -899,6 +896,7 @@ H5A__dense_rename(H5F_t *f, const H5O_ainfo_t *ainfo, const char *old_name,
H5HF_t *fheap = NULL; /* Fractal heap handle */
H5HF_t *shared_fheap = NULL; /* Fractal heap handle for shared header messages */
H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */
+ H5B2_t *bt2_corder = NULL; /* v2 B-tree handle for creation order ndex */
H5A_t *attr_copy = NULL; /* Copy of attribute to rename */
htri_t attr_sharable; /* Flag indicating attributes are sharable */
htri_t shared_mesg; /* Should this message be stored in the Shared Message table? */
@@ -976,6 +974,33 @@ H5A__dense_rename(H5F_t *f, const H5O_ainfo_t *ainfo, const char *old_name,
if(H5A__set_version(f, attr_copy) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "unable to update attribute version")
+ /* Need to remove the attribute from the creation order index v2 B-tree */
+ if(ainfo->index_corder) {
+ htri_t corder_attr_exists; /* Attribute exists in v2 B-tree */
+
+ /* Open the creation order index v2 B-tree */
+ HDassert(H5F_addr_defined(ainfo->corder_bt2_addr));
+ if(NULL == (bt2_corder = H5B2_open(f, ainfo->corder_bt2_addr, NULL)))
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation index")
+
+ /* Set up the creation order to search for */
+ udata.corder = attr_copy->shared->crt_idx;
+
+ if((corder_attr_exists = H5B2_find(bt2_corder, &udata, NULL, NULL)) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "can't search for attribute in name index")
+
+ if(corder_attr_exists) {
+ H5A_bt2_ud_rm_t rm_udata;
+
+ /* Set up the creation order in user data for the v2 B-tree 'record remove' callback */
+ rm_udata.common.corder = attr_copy->shared->crt_idx;
+
+ /* Remove the record from the creation order index v2 B-tree */
+ if(H5B2_remove(bt2_corder, &rm_udata, NULL, NULL) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTREMOVE, FAIL, "unable to remove attribute from creation order index v2 B-tree")
+ }
+ }
+
/* Insert renamed attribute back into dense storage */
/* (Possibly making it shared) */
if(H5A__dense_insert(f, ainfo, attr_copy) < 0)
@@ -1023,6 +1048,8 @@ done:
HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap")
if(bt2_name && H5B2_close(bt2_name) < 0)
HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index")
+ if(bt2_corder && H5B2_close(bt2_corder) < 0)
+ HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for creation order index")
if(attr_copy)
H5O_msg_free(H5O_ATTR_ID, attr_copy);
diff --git a/src/H5Adeprec.c b/src/H5Adeprec.c
index b438cd2..8d0e33c 100644
--- a/src/H5Adeprec.c
+++ b/src/H5Adeprec.c
@@ -119,7 +119,6 @@ H5Acreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id,
void *attr = NULL; /* attr token from VOL connector */
H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */
H5VL_loc_params_t loc_params;
- H5P_genplist_t *plist; /* Property list pointer */
hid_t ret_value = H5I_INVALID_HID; /* Return value */
FUNC_ENTER_API(H5I_INVALID_HID)
@@ -139,16 +138,6 @@ H5Acreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id,
if(H5P_DEFAULT == acpl_id)
acpl_id = H5P_ATTRIBUTE_CREATE_DEFAULT;
- /* Get the plist structure */
- if(NULL == (plist = (H5P_genplist_t *)H5I_object(acpl_id)))
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5I_INVALID_HID, "can't find object for ID")
-
- /* Set creation properties */
- if(H5P_set(plist, H5VL_PROP_ATTR_TYPE_ID, &type_id) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for datatype id")
- if(H5P_set(plist, H5VL_PROP_ATTR_SPACE_ID, &space_id) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for space id")
-
/* Set location parameters */
loc_params.type = H5VL_OBJECT_BY_SELF;
loc_params.obj_type = H5I_get_type(loc_id);
@@ -158,7 +147,7 @@ H5Acreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id,
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier")
/* Create the attribute */
- if(NULL == (attr = H5VL_attr_create(vol_obj, &loc_params, name, acpl_id, H5P_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)))
+ if(NULL == (attr = H5VL_attr_create(vol_obj, &loc_params, name, type_id, space_id, acpl_id, H5P_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)))
HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, H5I_INVALID_HID, "unable to create attribute")
/* Register the new attribute and get an ID for it */
diff --git a/src/H5Aint.c b/src/H5Aint.c
index 6502fa4..808d9b3 100644
--- a/src/H5Aint.c
+++ b/src/H5Aint.c
@@ -108,6 +108,7 @@ static herr_t H5A__iterate_common(hid_t loc_id, H5_index_t idx_type,
const unsigned H5O_attr_ver_bounds[] = {
H5O_ATTR_VERSION_1, /* H5F_LIBVER_EARLIEST */
H5O_ATTR_VERSION_3, /* H5F_LIBVER_V18 */
+ H5O_ATTR_VERSION_3, /* H5F_LIBVER_V110 */
H5O_ATTR_VERSION_LATEST /* H5F_LIBVER_LATEST */
};
@@ -646,21 +647,21 @@ H5A__read(const H5A_t *attr, const H5T_t *mem_type, void *buf)
HGOTO_ERROR(H5E_ATTR, H5E_NOSPACE, FAIL, "memory allocation failed")
/* Copy the attribute data into the buffer for conversion */
- HDmemcpy(tconv_buf, attr->shared->data, (src_type_size * nelmts));
+ H5MM_memcpy(tconv_buf, attr->shared->data, (src_type_size * nelmts));
/* Perform datatype conversion. */
if(H5T_convert(tpath, src_id, dst_id, nelmts, (size_t)0, (size_t)0, tconv_buf, bkg_buf) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "datatype conversion failed")
/* Copy the converted data into the user's buffer */
- HDmemcpy(buf, tconv_buf, (dst_type_size * nelmts));
+ H5MM_memcpy(buf, tconv_buf, (dst_type_size * nelmts));
} /* end if */
/* No type conversion necessary */
else {
HDassert(dst_type_size == src_type_size);
/* Copy the attribute data into the user's buffer */
- HDmemcpy(buf, attr->shared->data, (dst_type_size * nelmts));
+ H5MM_memcpy(buf, attr->shared->data, (dst_type_size * nelmts));
} /* end else */
} /* end else */
} /* end if */
@@ -747,7 +748,7 @@ H5A__write(H5A_t *attr, const H5T_t *mem_type, const void *buf)
HGOTO_ERROR(H5E_ATTR, H5E_CANTALLOC, FAIL, "memory allocation failed")
/* Copy the user's data into the buffer for conversion */
- HDmemcpy(tconv_buf, buf, (src_type_size * nelmts));
+ H5MM_memcpy(tconv_buf, buf, (src_type_size * nelmts));
/* Perform datatype conversion */
if(H5T_convert(tpath, src_id, dst_id, nelmts, (size_t)0, (size_t)0, tconv_buf, bkg_buf) < 0)
@@ -770,8 +771,8 @@ H5A__write(H5A_t *attr, const H5T_t *mem_type, const void *buf)
if(NULL == (attr->shared->data = H5FL_BLK_MALLOC(attr_buf, dst_type_size * nelmts)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
- /* Copy the attribute data into the user's buffer */
- HDmemcpy(attr->shared->data, buf, (dst_type_size * nelmts));
+ /* Copy the attribute data into the attribute data buffer */
+ H5MM_memcpy(attr->shared->data, buf, (dst_type_size * nelmts));
} /* end else */
/* Modify the attribute in the object header */
@@ -827,7 +828,7 @@ H5A__get_name(H5A_t *attr, size_t buf_size, char *buf)
/* Copy all/some of the name */
if(buf && copy_len > 0) {
- HDmemcpy(buf, attr->shared->name, copy_len);
+ H5MM_memcpy(buf, attr->shared->name, copy_len);
/* Terminate the string */
buf[copy_len]='\0';
@@ -1091,48 +1092,55 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5A__free
+ * Function: H5A__shared_free
*
- * Purpose: Frees all memory associated with an attribute, but does not
- * free the H5A_t structure (which should be done in H5T_close).
+ * Purpose: Cleans up the shared attribute data. This will free
+ * the attribute's shared structure as well.
+ *
+ * attr and attr->shared must not be NULL
*
* Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
- * Monday, November 15, 2004
+ * Programmer: Quincey Koziol
+ * Monday, November 15, 2004
*
*-------------------------------------------------------------------------
*/
herr_t
-H5A__free(H5A_t *attr)
+H5A__shared_free(H5A_t *attr)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
HDassert(attr);
+ HDassert(attr->shared);
- /* Free dynamically allocated items */
+ /* Free dynamically allocated items.
+ * When possible, keep trying to shut things down (via HDONE_ERROR).
+ */
if(attr->shared->name) {
H5MM_xfree(attr->shared->name);
attr->shared->name = NULL;
}
if(attr->shared->dt) {
if(H5T_close_real(attr->shared->dt) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release datatype info")
+ HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release datatype info")
attr->shared->dt = NULL;
}
if(attr->shared->ds) {
if(H5S_close(attr->shared->ds) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release dataspace info")
+ HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release dataspace info")
attr->shared->ds = NULL;
}
if(attr->shared->data)
attr->shared->data = H5FL_BLK_FREE(attr_buf, attr->shared->data);
-done:
+ /* Destroy shared attribute struct */
+ attr->shared = H5FL_FREE(H5A_shared_t, attr->shared);
+
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5A__free() */
+} /* end H5A__shared_free() */
/*-------------------------------------------------------------------------
@@ -1196,11 +1204,9 @@ H5A__close(H5A_t *attr)
/* Reference count can be 0. It only happens when H5A__create fails. */
if(attr->shared->nrefs <= 1) {
/* Free dynamically allocated items */
- if(H5A__free(attr) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release attribute info")
-
- /* Destroy shared attribute struct */
- attr->shared = H5FL_FREE(H5A_shared_t, attr->shared);
+ if(attr->shared)
+ if(H5A__shared_free(attr) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release attribute info")
} /* end if */
else {
/* There are other references to the shared part of the attribute.
@@ -2240,7 +2246,7 @@ H5A__attr_copy_file(const H5A_t *attr_src, H5F_t *file_dst, hbool_t *recompute_s
if(NULL == (buf = H5FL_BLK_MALLOC(attr_buf, buf_size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation NULLed for raw data chunk")
- HDmemcpy(buf, attr_src->shared->data, attr_src->shared->data_size);
+ H5MM_memcpy(buf, attr_src->shared->data, attr_src->shared->data_size);
/* Allocate background memory */
if(H5T_path_bkg(tpath_src_mem) || H5T_path_bkg(tpath_mem_dst))
@@ -2251,7 +2257,7 @@ H5A__attr_copy_file(const H5A_t *attr_src, H5F_t *file_dst, hbool_t *recompute_s
if(H5T_convert(tpath_src_mem, tid_src, tid_mem, nelmts, (size_t)0, (size_t)0, buf, bkg_buf) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "datatype conversion NULLed")
- HDmemcpy(reclaim_buf, buf, buf_size);
+ H5MM_memcpy(reclaim_buf, buf, buf_size);
/* Set background buffer to all zeros */
if(bkg_buf)
@@ -2261,14 +2267,14 @@ H5A__attr_copy_file(const H5A_t *attr_src, H5F_t *file_dst, hbool_t *recompute_s
if(H5T_convert(tpath_mem_dst, tid_mem, tid_dst, nelmts, (size_t)0, (size_t)0, buf, bkg_buf) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "datatype conversion NULLed")
- HDmemcpy(attr_dst->shared->data, buf, attr_dst->shared->data_size);
+ H5MM_memcpy(attr_dst->shared->data, buf, attr_dst->shared->data_size);
if(H5D_vlen_reclaim(tid_mem, buf_space, reclaim_buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_BADITER, NULL, "unable to reclaim variable-length data")
} /* end if */
else {
HDassert(attr_dst->shared->data_size == attr_src->shared->data_size);
- HDmemcpy(attr_dst->shared->data, attr_src->shared->data, attr_src->shared->data_size);
+ H5MM_memcpy(attr_dst->shared->data, attr_src->shared->data, attr_src->shared->data_size);
} /* end else */
} /* end if(attr_src->shared->data) */
@@ -2395,9 +2401,13 @@ H5A__attr_post_copy_file(const H5O_loc_t *src_oloc, const H5A_t *attr_src,
/* Check for expanding references */
if(cpy_info->expand_ref) {
size_t ref_count;
+ size_t dst_dt_size; /* Destination datatype size */
+ /* Determine size of the destination datatype */
+ if(0 == (dst_dt_size = H5T_get_size(attr_dst->shared->dt)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to determine datatype size")
/* Determine # of reference elements to copy */
- ref_count = attr_dst->shared->data_size / H5T_get_size(attr_dst->shared->dt);
+ ref_count = attr_dst->shared->data_size / dst_dt_size;
/* Copy objects referenced in source buffer to destination file and set destination elements */
if(H5O_copy_expand_ref(file_src, attr_dst->shared->data, file_dst, attr_dst->shared->data, ref_count, H5T_get_ref_type(attr_dst->shared->dt), cpy_info) < 0)
diff --git a/src/H5Apkg.h b/src/H5Apkg.h
index 91061cd..f3870c0 100644
--- a/src/H5Apkg.h
+++ b/src/H5Apkg.h
@@ -196,7 +196,7 @@ H5_DLL H5A_t *H5A__copy(H5A_t *new_attr, const H5A_t *old_attr);
H5_DLL hid_t H5A__get_type(H5A_t *attr);
H5_DLL herr_t H5A__get_info(const H5A_t *attr, H5A_info_t *ainfo);
H5_DLL hid_t H5A__get_create_plist(H5A_t* attr);
-H5_DLL herr_t H5A__free(H5A_t *attr);
+H5_DLL herr_t H5A__shared_free(H5A_t *attr);
H5_DLL herr_t H5A__close(H5A_t *attr);
H5_DLL herr_t H5A__close_cb(H5VL_object_t *attr_vol_obj);
H5_DLL htri_t H5A__get_ainfo(H5F_t *f, H5O_t *oh, H5O_ainfo_t *ainfo);
diff --git a/src/H5B.c b/src/H5B.c
index 71b9020..2a34fae 100644
--- a/src/H5B.c
+++ b/src/H5B.c
@@ -107,6 +107,7 @@
#include "H5Eprivate.h" /* Error handling */
#include "H5Iprivate.h" /* IDs */
#include "H5MFprivate.h" /* File memory management */
+#include "H5MMprivate.h" /* Memory management */
#include "H5Pprivate.h" /* Property lists */
@@ -436,8 +437,8 @@ H5B__split(H5F_t *f, H5B_ins_ud_t *bt_ud, unsigned idx,
side = "LEFT";
else
side = "MIDDLE";
- fprintf(H5DEBUG(B), "H5B__split: %3u {%5.3f,%5.3f,%5.3f} %6s",
- shared->two_k, split_ratios[0], split_ratios[1], split_ratios[2], side);
+ HDfprintf(H5DEBUG(B), "H5B__split: %3u {%5.3f,%5.3f,%5.3f} %6s",
+ shared->two_k, split_ratios[0], split_ratios[1], split_ratios[2], side);
}
#endif
@@ -464,7 +465,7 @@ H5B__split(H5F_t *f, H5B_ins_ud_t *bt_ud, unsigned idx,
nright = shared->two_k - nleft;
#ifdef H5B_DEBUG
if(H5DEBUG(B))
- fprintf(H5DEBUG(B), " split %3d/%-3d\n", nleft, nright);
+ HDfprintf(H5DEBUG(B), " split %3d/%-3d\n", nleft, nright);
#endif
/*
@@ -484,10 +485,10 @@ H5B__split(H5F_t *f, H5B_ins_ud_t *bt_ud, unsigned idx,
*/
split_bt_ud->cache_flags = H5AC__DIRTIED_FLAG;
- HDmemcpy(split_bt_ud->bt->native,
+ H5MM_memcpy(split_bt_ud->bt->native,
bt_ud->bt->native + nleft * shared->type->sizeof_nkey,
(nright + 1) * shared->type->sizeof_nkey);
- HDmemcpy(split_bt_ud->bt->child,
+ H5MM_memcpy(split_bt_ud->bt->child,
&bt_ud->bt->child[nleft],
nright * sizeof(haddr_t));
@@ -612,9 +613,9 @@ H5B_insert(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata)
/* update left and right keys */
if(!lt_key_changed)
- HDmemcpy(lt_key, H5B_NKEY(bt_ud.bt,shared,0), type->sizeof_nkey);
+ H5MM_memcpy(lt_key, H5B_NKEY(bt_ud.bt,shared,0), type->sizeof_nkey);
if(!rt_key_changed)
- HDmemcpy(rt_key, H5B_NKEY(split_bt_ud.bt,shared,split_bt_ud.bt->nchildren), type->sizeof_nkey);
+ H5MM_memcpy(rt_key, H5B_NKEY(split_bt_ud.bt,shared,split_bt_ud.bt->nchildren), type->sizeof_nkey);
/*
* Copy the old root node to some other file location and make the new root
@@ -657,11 +658,11 @@ H5B_insert(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata)
new_root_bt->nchildren = 2;
new_root_bt->child[0] = bt_ud.addr;
- HDmemcpy(H5B_NKEY(new_root_bt, shared, 0), lt_key, shared->type->sizeof_nkey);
+ H5MM_memcpy(H5B_NKEY(new_root_bt, shared, 0), lt_key, shared->type->sizeof_nkey);
new_root_bt->child[1] = split_bt_ud.addr;
- HDmemcpy(H5B_NKEY(new_root_bt, shared, 1), md_key, shared->type->sizeof_nkey);
- HDmemcpy(H5B_NKEY(new_root_bt, shared, 2), rt_key, shared->type->sizeof_nkey);
+ H5MM_memcpy(H5B_NKEY(new_root_bt, shared, 1), md_key, shared->type->sizeof_nkey);
+ H5MM_memcpy(H5B_NKEY(new_root_bt, shared, 2), rt_key, shared->type->sizeof_nkey);
/* Insert the modified copy of the old root into the file again */
if(H5AC_insert_entry(f, H5AC_BT, addr, new_root_bt, H5AC__NO_FLAGS_SET) < 0)
@@ -726,9 +727,9 @@ H5B__insert_child(H5B_t *bt, unsigned *bt_flags, unsigned idx,
base = H5B_NKEY(bt, shared, (idx + 1));
if((idx + 1) == bt->nchildren) {
/* Make room for the new key */
- HDmemcpy(base + shared->type->sizeof_nkey, base,
+ H5MM_memcpy(base + shared->type->sizeof_nkey, base,
shared->type->sizeof_nkey); /* No overlap possible - memcpy() OK */
- HDmemcpy(base, md_key, shared->type->sizeof_nkey);
+ H5MM_memcpy(base, md_key, shared->type->sizeof_nkey);
/* The MD_KEY is the left key of the new node */
if(H5B_INS_RIGHT == anchor)
@@ -741,7 +742,7 @@ H5B__insert_child(H5B_t *bt, unsigned *bt_flags, unsigned idx,
/* Make room for the new key */
HDmemmove(base + shared->type->sizeof_nkey, base,
(bt->nchildren - idx) * shared->type->sizeof_nkey);
- HDmemcpy(base, md_key, shared->type->sizeof_nkey);
+ H5MM_memcpy(base, md_key, shared->type->sizeof_nkey);
/* The MD_KEY is the left key of the new node */
if(H5B_INS_RIGHT == anchor)
@@ -915,7 +916,7 @@ H5B__insert_helper(H5F_t *f, H5B_ins_ud_t *bt_ud, const H5B_class_t *type,
* node. This node is not empty (handled above).
*/
my_ins = H5B_INS_LEFT;
- HDmemcpy(md_key, H5B_NKEY(bt,shared,idx), type->sizeof_nkey);
+ H5MM_memcpy(md_key, H5B_NKEY(bt,shared,idx), type->sizeof_nkey);
if((type->new_node)(f, H5B_INS_LEFT, H5B_NKEY(bt, shared, idx), udata,
md_key, &new_child_bt_ud.addr/*out*/) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert minimum leaf node")
@@ -963,7 +964,7 @@ H5B__insert_helper(H5F_t *f, H5B_ins_ud_t *bt_ud, const H5B_class_t *type,
*/
idx = bt->nchildren - 1;
my_ins = H5B_INS_RIGHT;
- HDmemcpy(md_key, H5B_NKEY(bt, shared, idx + 1), type->sizeof_nkey);
+ H5MM_memcpy(md_key, H5B_NKEY(bt, shared, idx + 1), type->sizeof_nkey);
if((type->new_node)(f, H5B_INS_RIGHT, md_key, udata,
H5B_NKEY(bt, shared, idx + 1), &new_child_bt_ud.addr/*out*/) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert maximum leaf node")
@@ -1021,7 +1022,7 @@ H5B__insert_helper(H5F_t *f, H5B_ins_ud_t *bt_ud, const H5B_class_t *type,
*lt_key_changed = FALSE;
} /* end if */
else
- HDmemcpy(lt_key, H5B_NKEY(bt, shared, idx), type->sizeof_nkey);
+ H5MM_memcpy(lt_key, H5B_NKEY(bt, shared, idx), type->sizeof_nkey);
} /* end if */
if(*rt_key_changed) {
bt_ud->cache_flags |= H5AC__DIRTIED_FLAG;
@@ -1031,7 +1032,7 @@ H5B__insert_helper(H5F_t *f, H5B_ins_ud_t *bt_ud, const H5B_class_t *type,
*rt_key_changed = FALSE;
} /* end if */
else
- HDmemcpy(rt_key, H5B_NKEY(bt, shared, idx + 1), type->sizeof_nkey);
+ H5MM_memcpy(rt_key, H5B_NKEY(bt, shared, idx + 1), type->sizeof_nkey);
} /* end if */
/*
@@ -1080,7 +1081,7 @@ H5B__insert_helper(H5F_t *f, H5B_ins_ud_t *bt_ud, const H5B_class_t *type,
* by the left and right node).
*/
if(split_bt_ud->bt) {
- HDmemcpy(md_key, H5B_NKEY(split_bt_ud->bt, shared, 0), type->sizeof_nkey);
+ H5MM_memcpy(md_key, H5B_NKEY(split_bt_ud->bt, shared, 0), type->sizeof_nkey);
ret_value = H5B_INS_RIGHT;
#ifdef H5B_DEBUG
/*
@@ -1339,7 +1340,7 @@ H5B__remove_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type, int level,
/* Don't propagate change out of this B-tree node */
*lt_key_changed = FALSE;
else
- HDmemcpy(lt_key, H5B_NKEY(bt, shared, idx), type->sizeof_nkey);
+ H5MM_memcpy(lt_key, H5B_NKEY(bt, shared, idx), type->sizeof_nkey);
} /* end if */
if(*rt_key_changed) {
HDassert(type->critical_key == H5B_RIGHT);
@@ -1348,7 +1349,7 @@ H5B__remove_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type, int level,
/* Don't propagate change out of this B-tree node */
*rt_key_changed = FALSE;
else
- HDmemcpy(rt_key, H5B_NKEY(bt, shared, idx + 1), type->sizeof_nkey);
+ H5MM_memcpy(rt_key, H5B_NKEY(bt, shared, idx + 1), type->sizeof_nkey);
} /* end if */
/*
@@ -1383,7 +1384,7 @@ H5B__remove_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type, int level,
* in its left neighbor, but only if it is not the critical
* key for the right-most child of the left neighbor */
if(type->critical_key == H5B_LEFT)
- HDmemcpy(H5B_NKEY(sibling, shared, sibling->nchildren),
+ H5MM_memcpy(H5B_NKEY(sibling, shared, sibling->nchildren),
H5B_NKEY(bt, shared, 1), type->sizeof_nkey);
sibling->right = bt->right;
@@ -1400,7 +1401,7 @@ H5B__remove_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type, int level,
* its right neighbor, but only if it is not the critical
* key for the left-most child of the right neighbor */
if(type->critical_key == H5B_RIGHT)
- HDmemcpy(H5B_NKEY(sibling, shared, 0),
+ H5MM_memcpy(H5B_NKEY(sibling, shared, 0),
H5B_NKEY(bt, shared, 0), type->sizeof_nkey);
sibling->left = bt->left;
@@ -1442,7 +1443,7 @@ H5B__remove_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type, int level,
/* Slide all keys down 1, update lt_key */
HDmemmove(H5B_NKEY(bt, shared, 0), H5B_NKEY(bt, shared, 1),
bt->nchildren * type->sizeof_nkey);
- HDmemcpy(lt_key, H5B_NKEY(bt, shared, 0), type->sizeof_nkey);
+ H5MM_memcpy(lt_key, H5B_NKEY(bt, shared, 0), type->sizeof_nkey);
*lt_key_changed = TRUE;
} else
/* Slide all but the leftmost 2 keys down, leaving the leftmost
@@ -1471,7 +1472,7 @@ H5B__remove_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type, int level,
H5B_NKEY(bt, shared, bt->nchildren), type->sizeof_nkey);
else {
/* Just update rt_key */
- HDmemcpy(rt_key, H5B_NKEY(bt, shared, bt->nchildren - 1),
+ H5MM_memcpy(rt_key, H5B_NKEY(bt, shared, bt->nchildren - 1),
type->sizeof_nkey);
*rt_key_changed = TRUE;
} /* end else */
@@ -1516,7 +1517,7 @@ H5B__remove_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type, int level,
if(NULL == (sibling = (H5B_t *)H5AC_protect(f, H5AC_BT, bt->left, &cache_udata, H5AC__NO_FLAGS_SET)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5B_INS_ERROR, "unable to protect node")
- HDmemcpy(H5B_NKEY(sibling, shared, sibling->nchildren),
+ H5MM_memcpy(H5B_NKEY(sibling, shared, sibling->nchildren),
H5B_NKEY(bt, shared, 0), type->sizeof_nkey);
if(H5AC_unprotect(f, H5AC_BT, bt->left, sibling, H5AC__DIRTIED_FLAG) < 0)
@@ -1531,7 +1532,7 @@ H5B__remove_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type, int level,
if(NULL == (sibling = (H5B_t *)H5AC_protect(f, H5AC_BT, bt->right, &cache_udata, H5AC__NO_FLAGS_SET)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5B_INS_ERROR, "unable to protect node")
- HDmemcpy(H5B_NKEY(sibling, shared, 0),
+ H5MM_memcpy(H5B_NKEY(sibling, shared, 0),
H5B_NKEY(bt, shared, bt->nchildren), type->sizeof_nkey);
if(H5AC_unprotect(f, H5AC_BT, bt->right, sibling, H5AC__DIRTIED_FLAG) < 0)
@@ -1811,7 +1812,7 @@ H5B__copy(const H5B_t *old_bt)
HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for B-tree root node")
/* Copy the main structure */
- HDmemcpy(new_node, old_bt, sizeof(H5B_t));
+ H5MM_memcpy(new_node, old_bt, sizeof(H5B_t));
/* Reset cache info */
HDmemset(&new_node->cache_info, 0, sizeof(H5AC_info_t));
@@ -1821,8 +1822,8 @@ H5B__copy(const H5B_t *old_bt)
HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for B-tree root node")
/* Copy the other structures */
- HDmemcpy(new_node->native, old_bt->native, shared->sizeof_keys);
- HDmemcpy(new_node->child, old_bt->child, (sizeof(haddr_t) * shared->two_k));
+ H5MM_memcpy(new_node->native, old_bt->native, shared->sizeof_keys);
+ H5MM_memcpy(new_node->child, old_bt->child, (sizeof(haddr_t) * shared->two_k));
/* Increment the ref-count on the raw page */
H5UC_INC(new_node->rc_shared);
diff --git a/src/H5B2.c b/src/H5B2.c
index cf8e4a9..6b0d7a3 100644
--- a/src/H5B2.c
+++ b/src/H5B2.c
@@ -662,7 +662,7 @@ H5B2_find(H5B2_t *bt2, void *udata, H5B2_found_t op, void *op_data)
if(hdr->min_native_rec == NULL)
if(NULL == (hdr->min_native_rec = H5MM_malloc(hdr->cls->nrec_size)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree min record info")
- HDmemcpy(hdr->min_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size);
+ H5MM_memcpy(hdr->min_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size);
} /* end if */
} /* end if */
if(idx == (unsigned)(leaf->nrec - 1)) {
@@ -670,7 +670,7 @@ H5B2_find(H5B2_t *bt2, void *udata, H5B2_found_t op, void *op_data)
if(hdr->max_native_rec == NULL)
if(NULL == (hdr->max_native_rec = H5MM_malloc(hdr->cls->nrec_size)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree max record info")
- HDmemcpy(hdr->max_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size);
+ H5MM_memcpy(hdr->max_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size);
} /* end if */
} /* end if */
} /* end if */
@@ -1343,7 +1343,7 @@ H5B2_modify(H5B2_t *bt2, void *udata, H5B2_modify_t op, void *op_data)
if(hdr->min_native_rec == NULL)
if(NULL == (hdr->min_native_rec = H5MM_malloc(hdr->cls->nrec_size)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree min record info")
- HDmemcpy(hdr->min_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size);
+ H5MM_memcpy(hdr->min_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size);
} /* end if */
} /* end if */
if(idx == (unsigned)(leaf->nrec - 1)) {
@@ -1351,7 +1351,7 @@ H5B2_modify(H5B2_t *bt2, void *udata, H5B2_modify_t op, void *op_data)
if(hdr->max_native_rec == NULL)
if(NULL == (hdr->max_native_rec = H5MM_malloc(hdr->cls->nrec_size)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree max record info")
- HDmemcpy(hdr->max_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size);
+ H5MM_memcpy(hdr->max_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size);
} /* end if */
} /* end if */
} /* end if */
diff --git a/src/H5B2cache.c b/src/H5B2cache.c
index 2e1d37b..2a77bd5 100644
--- a/src/H5B2cache.c
+++ b/src/H5B2cache.c
@@ -391,7 +391,7 @@ H5B2__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED le
HDassert(hdr);
/* Magic number */
- HDmemcpy(image, H5B2_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC);
+ H5MM_memcpy(image, H5B2_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC);
image += H5_SIZEOF_MAGIC;
/* Version # */
@@ -811,7 +811,7 @@ H5B2__cache_int_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED le
HDassert(internal->hdr);
/* Magic number */
- HDmemcpy(image, H5B2_INT_MAGIC, (size_t)H5_SIZEOF_MAGIC);
+ H5MM_memcpy(image, H5B2_INT_MAGIC, (size_t)H5_SIZEOF_MAGIC);
image += H5_SIZEOF_MAGIC;
/* Version # */
@@ -1212,7 +1212,7 @@ H5B2__cache_leaf_serialize(const H5F_t H5_ATTR_UNUSED *f, void *_image, size_t H
HDassert(leaf->hdr);
/* magic number */
- HDmemcpy(image, H5B2_LEAF_MAGIC, (size_t)H5_SIZEOF_MAGIC);
+ H5MM_memcpy(image, H5B2_LEAF_MAGIC, (size_t)H5_SIZEOF_MAGIC);
image += H5_SIZEOF_MAGIC;
/* version # */
diff --git a/src/H5B2int.c b/src/H5B2int.c
index b3f855f..9940cd7 100644
--- a/src/H5B2int.c
+++ b/src/H5B2int.c
@@ -35,6 +35,7 @@
#include "H5private.h" /* Generic Functions */
#include "H5B2pkg.h" /* v2 B-trees */
#include "H5Eprivate.h" /* Error handling */
+#include "H5MMprivate.h" /* Memory management */
#include "H5VMprivate.h" /* Vectors and arrays */
@@ -241,17 +242,17 @@ H5B2__split1(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr,
mid_record = old_node_nrec / 2;
/* Copy "upper half" of records to new child */
- HDmemcpy(H5B2_NAT_NREC(right_native, hdr, 0),
+ H5MM_memcpy(H5B2_NAT_NREC(right_native, hdr, 0),
H5B2_NAT_NREC(left_native, hdr, mid_record + (unsigned)1),
hdr->cls->nrec_size * (old_node_nrec - (mid_record + (unsigned)1)));
/* Copy "upper half" of node pointers, if the node is an internal node */
if(depth > 1)
- HDmemcpy(&(right_node_ptrs[0]), &(left_node_ptrs[mid_record + (unsigned)1]),
+ H5MM_memcpy(&(right_node_ptrs[0]), &(left_node_ptrs[mid_record + (unsigned)1]),
sizeof(H5B2_node_ptr_t) * (size_t)(old_node_nrec - mid_record));
/* Copy "middle" record to internal node */
- HDmemcpy(H5B2_INT_NREC(internal, hdr, idx), H5B2_NAT_NREC(left_native, hdr, mid_record), hdr->cls->nrec_size);
+ H5MM_memcpy(H5B2_INT_NREC(internal, hdr, idx), H5B2_NAT_NREC(left_native, hdr, mid_record), hdr->cls->nrec_size);
/* Mark nodes as dirty */
left_child_flags |= H5AC__DIRTIED_FLAG;
@@ -510,14 +511,14 @@ H5B2__redistribute2(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal,
uint16_t move_nrec = (uint16_t)(*right_nrec - new_right_nrec); /* Number of records to move from right node to left */
/* Copy record from parent node down into left child */
- HDmemcpy(H5B2_NAT_NREC(left_native, hdr, *left_nrec), H5B2_INT_NREC(internal, hdr, idx), hdr->cls->nrec_size);
+ H5MM_memcpy(H5B2_NAT_NREC(left_native, hdr, *left_nrec), H5B2_INT_NREC(internal, hdr, idx), hdr->cls->nrec_size);
/* See if we need to move records from right node */
if(move_nrec > 1)
- HDmemcpy(H5B2_NAT_NREC(left_native, hdr, (*left_nrec + 1)), H5B2_NAT_NREC(right_native, hdr, 0), hdr->cls->nrec_size * (size_t)(move_nrec - 1));
+ H5MM_memcpy(H5B2_NAT_NREC(left_native, hdr, (*left_nrec + 1)), H5B2_NAT_NREC(right_native, hdr, 0), hdr->cls->nrec_size * (size_t)(move_nrec - 1));
/* Move record from right node into parent node */
- HDmemcpy(H5B2_INT_NREC(internal, hdr, idx), H5B2_NAT_NREC(right_native, hdr, (move_nrec - 1)), hdr->cls->nrec_size);
+ H5MM_memcpy(H5B2_INT_NREC(internal, hdr, idx), H5B2_NAT_NREC(right_native, hdr, (move_nrec - 1)), hdr->cls->nrec_size);
/* Slide records in right node down */
HDmemmove(H5B2_NAT_NREC(right_native, hdr, 0), H5B2_NAT_NREC(right_native, hdr, move_nrec), hdr->cls->nrec_size * new_right_nrec);
@@ -534,7 +535,7 @@ H5B2__redistribute2(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal,
right_moved_nrec -= (hssize_t)moved_nrec;
/* Copy node pointers from right node to left */
- HDmemcpy(&(left_node_ptrs[*left_nrec + 1]), &(right_node_ptrs[0]), sizeof(H5B2_node_ptr_t) * move_nrec);
+ H5MM_memcpy(&(left_node_ptrs[*left_nrec + 1]), &(right_node_ptrs[0]), sizeof(H5B2_node_ptr_t) * move_nrec);
/* Slide node pointers in right node down */
HDmemmove(&(right_node_ptrs[0]), &(right_node_ptrs[move_nrec]), sizeof(H5B2_node_ptr_t) * (new_right_nrec + (unsigned)1));
@@ -569,14 +570,14 @@ H5B2__redistribute2(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal,
hdr->cls->nrec_size * (*right_nrec));
/* Copy record from parent node down into right child */
- HDmemcpy(H5B2_NAT_NREC(right_native, hdr, (move_nrec - 1)), H5B2_INT_NREC(internal, hdr, idx), hdr->cls->nrec_size);
+ H5MM_memcpy(H5B2_NAT_NREC(right_native, hdr, (move_nrec - 1)), H5B2_INT_NREC(internal, hdr, idx), hdr->cls->nrec_size);
/* See if we need to move records from left node */
if(move_nrec > 1)
- HDmemcpy(H5B2_NAT_NREC(right_native, hdr, 0), H5B2_NAT_NREC(left_native, hdr, ((*left_nrec - move_nrec) + 1)), hdr->cls->nrec_size * (size_t)(move_nrec - 1));
+ H5MM_memcpy(H5B2_NAT_NREC(right_native, hdr, 0), H5B2_NAT_NREC(left_native, hdr, ((*left_nrec - move_nrec) + 1)), hdr->cls->nrec_size * (size_t)(move_nrec - 1));
/* Move record from left node into parent node */
- HDmemcpy(H5B2_INT_NREC(internal, hdr, idx), H5B2_NAT_NREC(left_native, hdr, (*left_nrec - move_nrec)), hdr->cls->nrec_size);
+ H5MM_memcpy(H5B2_INT_NREC(internal, hdr, idx), H5B2_NAT_NREC(left_native, hdr, (*left_nrec - move_nrec)), hdr->cls->nrec_size);
/* Handle node pointers, if we have an internal node */
if(depth > 1) {
@@ -587,7 +588,7 @@ H5B2__redistribute2(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal,
HDmemmove(&(right_node_ptrs[move_nrec]), &(right_node_ptrs[0]), sizeof(H5B2_node_ptr_t) * (size_t)(*right_nrec + 1));
/* Copy node pointers from left node to right */
- HDmemcpy(&(right_node_ptrs[0]), &(left_node_ptrs[new_left_nrec + 1]), sizeof(H5B2_node_ptr_t) * move_nrec);
+ H5MM_memcpy(&(right_node_ptrs[0]), &(left_node_ptrs[new_left_nrec + 1]), sizeof(H5B2_node_ptr_t) * move_nrec);
/* Count the number of records being moved */
for(u = 0; u < move_nrec; u++)
@@ -775,16 +776,16 @@ H5B2__redistribute3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal,
uint16_t moved_middle_nrec = 0; /* Number of records moved into left node */
/* Move left parent record down to left node */
- HDmemcpy(H5B2_NAT_NREC(left_native, hdr, *left_nrec), H5B2_INT_NREC(internal, hdr, idx - 1), hdr->cls->nrec_size);
+ H5MM_memcpy(H5B2_NAT_NREC(left_native, hdr, *left_nrec), H5B2_INT_NREC(internal, hdr, idx - 1), hdr->cls->nrec_size);
/* Move records from middle node into left node */
if((new_left_nrec - 1) > *left_nrec) {
moved_middle_nrec = (uint16_t)(new_left_nrec - (*left_nrec + 1));
- HDmemcpy(H5B2_NAT_NREC(left_native, hdr, *left_nrec + 1), H5B2_NAT_NREC(middle_native, hdr, 0), hdr->cls->nrec_size * moved_middle_nrec);
+ H5MM_memcpy(H5B2_NAT_NREC(left_native, hdr, *left_nrec + 1), H5B2_NAT_NREC(middle_native, hdr, 0), hdr->cls->nrec_size * moved_middle_nrec);
} /* end if */
/* Move record from middle node up to parent node */
- HDmemcpy(H5B2_INT_NREC(internal, hdr, idx - 1), H5B2_NAT_NREC(middle_native, hdr, moved_middle_nrec), hdr->cls->nrec_size);
+ H5MM_memcpy(H5B2_INT_NREC(internal, hdr, idx - 1), H5B2_NAT_NREC(middle_native, hdr, moved_middle_nrec), hdr->cls->nrec_size);
moved_middle_nrec++;
/* Slide records in middle node down */
@@ -798,7 +799,7 @@ H5B2__redistribute3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal,
/* Move middle node pointers into left node */
move_nptrs = (unsigned)(new_left_nrec - *left_nrec);
- HDmemcpy(&(left_node_ptrs[*left_nrec + 1]), &(middle_node_ptrs[0]), sizeof(H5B2_node_ptr_t)*move_nptrs);
+ H5MM_memcpy(&(left_node_ptrs[*left_nrec + 1]), &(middle_node_ptrs[0]), sizeof(H5B2_node_ptr_t)*move_nptrs);
/* Count the number of records being moved into the left node */
for(u = 0, moved_nrec = 0; u < move_nptrs; u++)
@@ -832,14 +833,14 @@ H5B2__redistribute3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal,
HDmemmove(H5B2_NAT_NREC(right_native, hdr, right_nrec_move), H5B2_NAT_NREC(right_native, hdr, 0), hdr->cls->nrec_size * (*right_nrec));
/* Move right parent record down to right node */
- HDmemcpy(H5B2_NAT_NREC(right_native, hdr, right_nrec_move - 1), H5B2_INT_NREC(internal, hdr, idx), hdr->cls->nrec_size);
+ H5MM_memcpy(H5B2_NAT_NREC(right_native, hdr, right_nrec_move - 1), H5B2_INT_NREC(internal, hdr, idx), hdr->cls->nrec_size);
/* Move records from middle node into right node */
if(right_nrec_move > 1)
- HDmemcpy(H5B2_NAT_NREC(right_native, hdr, 0), H5B2_NAT_NREC(middle_native, hdr, ((curr_middle_nrec - right_nrec_move) + 1)), hdr->cls->nrec_size * (right_nrec_move - 1));
+ H5MM_memcpy(H5B2_NAT_NREC(right_native, hdr, 0), H5B2_NAT_NREC(middle_native, hdr, ((curr_middle_nrec - right_nrec_move) + 1)), hdr->cls->nrec_size * (right_nrec_move - 1));
/* Move record from middle node up to parent node */
- HDmemcpy(H5B2_INT_NREC(internal, hdr, idx), H5B2_NAT_NREC(middle_native, hdr, (curr_middle_nrec - right_nrec_move)), hdr->cls->nrec_size);
+ H5MM_memcpy(H5B2_INT_NREC(internal, hdr, idx), H5B2_NAT_NREC(middle_native, hdr, (curr_middle_nrec - right_nrec_move)), hdr->cls->nrec_size);
/* Move node pointers also if this is an internal node */
if(depth > 1) {
@@ -850,7 +851,7 @@ H5B2__redistribute3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal,
HDmemmove(&(right_node_ptrs[right_nrec_move]), &(right_node_ptrs[0]), sizeof(H5B2_node_ptr_t) * (size_t)(*right_nrec + 1));
/* Move middle node pointers into right node */
- HDmemcpy(&(right_node_ptrs[0]), &(middle_node_ptrs[(curr_middle_nrec - right_nrec_move) + 1]), sizeof(H5B2_node_ptr_t) * right_nrec_move);
+ H5MM_memcpy(&(right_node_ptrs[0]), &(middle_node_ptrs[(curr_middle_nrec - right_nrec_move) + 1]), sizeof(H5B2_node_ptr_t) * right_nrec_move);
/* Count the number of records being moved into the right node */
for(u = 0, moved_nrec = 0; u < right_nrec_move; u++)
@@ -881,14 +882,14 @@ H5B2__redistribute3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal,
HDmemmove(H5B2_NAT_NREC(middle_native, hdr, left_nrec_move), H5B2_NAT_NREC(middle_native, hdr, 0), hdr->cls->nrec_size * curr_middle_nrec);
/* Move left parent record down to middle node */
- HDmemcpy(H5B2_NAT_NREC(middle_native, hdr, left_nrec_move - 1), H5B2_INT_NREC(internal, hdr, idx - 1), hdr->cls->nrec_size);
+ H5MM_memcpy(H5B2_NAT_NREC(middle_native, hdr, left_nrec_move - 1), H5B2_INT_NREC(internal, hdr, idx - 1), hdr->cls->nrec_size);
/* Move left records to middle node */
if(left_nrec_move > 1)
HDmemmove(H5B2_NAT_NREC(middle_native, hdr, 0), H5B2_NAT_NREC(left_native, hdr, new_left_nrec + 1), hdr->cls->nrec_size * (left_nrec_move - 1));
/* Move left parent record up from left node */
- HDmemcpy(H5B2_INT_NREC(internal, hdr, idx - 1), H5B2_NAT_NREC(left_native, hdr, new_left_nrec), hdr->cls->nrec_size);
+ H5MM_memcpy(H5B2_INT_NREC(internal, hdr, idx - 1), H5B2_NAT_NREC(left_native, hdr, new_left_nrec), hdr->cls->nrec_size);
/* Move node pointers also if this is an internal node */
if(depth > 1) {
@@ -899,7 +900,7 @@ H5B2__redistribute3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal,
HDmemmove(&(middle_node_ptrs[left_nrec_move]), &(middle_node_ptrs[0]), sizeof(H5B2_node_ptr_t) * (size_t)(curr_middle_nrec + 1));
/* Move left node pointers into middle node */
- HDmemcpy(&(middle_node_ptrs[0]), &(left_node_ptrs[new_left_nrec + 1]), sizeof(H5B2_node_ptr_t) * left_nrec_move);
+ H5MM_memcpy(&(middle_node_ptrs[0]), &(left_node_ptrs[new_left_nrec + 1]), sizeof(H5B2_node_ptr_t) * left_nrec_move);
/* Count the number of records being moved into the left node */
for(u = 0, moved_nrec = 0; u < left_nrec_move; u++)
@@ -927,13 +928,13 @@ H5B2__redistribute3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal,
unsigned right_nrec_move = (unsigned)(*right_nrec - new_right_nrec); /* Number of records to move out of right node */
/* Move right parent record down to middle node */
- HDmemcpy(H5B2_NAT_NREC(middle_native, hdr, curr_middle_nrec), H5B2_INT_NREC(internal, hdr, idx), hdr->cls->nrec_size);
+ H5MM_memcpy(H5B2_NAT_NREC(middle_native, hdr, curr_middle_nrec), H5B2_INT_NREC(internal, hdr, idx), hdr->cls->nrec_size);
/* Move right records to middle node */
HDmemmove(H5B2_NAT_NREC(middle_native, hdr, (curr_middle_nrec + 1)), H5B2_NAT_NREC(right_native, hdr, 0), hdr->cls->nrec_size * (right_nrec_move - 1));
/* Move right parent record up from right node */
- HDmemcpy(H5B2_INT_NREC(internal, hdr, idx), H5B2_NAT_NREC(right_native, hdr, right_nrec_move - 1), hdr->cls->nrec_size);
+ H5MM_memcpy(H5B2_INT_NREC(internal, hdr, idx), H5B2_NAT_NREC(right_native, hdr, right_nrec_move - 1), hdr->cls->nrec_size);
/* Slide right records down */
HDmemmove(H5B2_NAT_NREC(right_native, hdr, 0), H5B2_NAT_NREC(right_native, hdr, right_nrec_move), hdr->cls->nrec_size * new_right_nrec);
@@ -944,7 +945,7 @@ H5B2__redistribute3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal,
unsigned u; /* Local index variable */
/* Move right node pointers into middle node */
- HDmemcpy(&(middle_node_ptrs[curr_middle_nrec + 1]), &(right_node_ptrs[0]), sizeof(H5B2_node_ptr_t) * right_nrec_move);
+ H5MM_memcpy(&(middle_node_ptrs[curr_middle_nrec + 1]), &(right_node_ptrs[0]), sizeof(H5B2_node_ptr_t) * right_nrec_move);
/* Count the number of records being moved into the right node */
for(u = 0, moved_nrec = 0; u < right_nrec_move; u++)
@@ -1113,14 +1114,14 @@ H5B2__merge2(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr,
/* Redistribute records into left node */
{
/* Copy record from parent node to proper location */
- HDmemcpy(H5B2_NAT_NREC(left_native, hdr, *left_nrec), H5B2_INT_NREC(internal, hdr, idx), hdr->cls->nrec_size);
+ H5MM_memcpy(H5B2_NAT_NREC(left_native, hdr, *left_nrec), H5B2_INT_NREC(internal, hdr, idx), hdr->cls->nrec_size);
/* Copy records from right node to left node */
- HDmemcpy(H5B2_NAT_NREC(left_native, hdr, *left_nrec + 1), H5B2_NAT_NREC(right_native, hdr, 0), hdr->cls->nrec_size * (*right_nrec));
+ H5MM_memcpy(H5B2_NAT_NREC(left_native, hdr, *left_nrec + 1), H5B2_NAT_NREC(right_native, hdr, 0), hdr->cls->nrec_size * (*right_nrec));
/* Copy node pointers from right node into left node */
if(depth > 1)
- HDmemcpy(&(left_node_ptrs[*left_nrec + 1]), &(right_node_ptrs[0]), sizeof(H5B2_node_ptr_t) * (size_t)(*right_nrec + 1));
+ H5MM_memcpy(&(left_node_ptrs[*left_nrec + 1]), &(right_node_ptrs[0]), sizeof(H5B2_node_ptr_t) * (size_t)(*right_nrec + 1));
/* Update flush dependencies for grandchildren, if using SWMR */
if(hdr->swmr_write && depth > 1)
@@ -1304,13 +1305,13 @@ H5B2__merge3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr,
middle_moved_nrec = middle_nrec_move;
/* Copy record from parent node to proper location in left node */
- HDmemcpy(H5B2_NAT_NREC(left_native, hdr, *left_nrec), H5B2_INT_NREC(internal, hdr, idx - 1), hdr->cls->nrec_size);
+ H5MM_memcpy(H5B2_NAT_NREC(left_native, hdr, *left_nrec), H5B2_INT_NREC(internal, hdr, idx - 1), hdr->cls->nrec_size);
/* Copy records from middle node to left node */
- HDmemcpy(H5B2_NAT_NREC(left_native, hdr, *left_nrec + 1), H5B2_NAT_NREC(middle_native, hdr, 0), hdr->cls->nrec_size * (middle_nrec_move - 1));
+ H5MM_memcpy(H5B2_NAT_NREC(left_native, hdr, *left_nrec + 1), H5B2_NAT_NREC(middle_native, hdr, 0), hdr->cls->nrec_size * (middle_nrec_move - 1));
/* Copy record from middle node to proper location in parent node */
- HDmemcpy(H5B2_INT_NREC(internal, hdr, idx - 1), H5B2_NAT_NREC(middle_native, hdr, (middle_nrec_move - 1)), hdr->cls->nrec_size);
+ H5MM_memcpy(H5B2_INT_NREC(internal, hdr, idx - 1), H5B2_NAT_NREC(middle_native, hdr, (middle_nrec_move - 1)), hdr->cls->nrec_size);
/* Slide records in middle node down */
HDmemmove(H5B2_NAT_NREC(middle_native, hdr, 0), H5B2_NAT_NREC(middle_native, hdr, middle_nrec_move), hdr->cls->nrec_size * (*middle_nrec - middle_nrec_move));
@@ -1320,7 +1321,7 @@ H5B2__merge3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr,
unsigned u; /* Local index variable */
/* Copy node pointers from middle node into left node */
- HDmemcpy(&(left_node_ptrs[*left_nrec + 1]), &(middle_node_ptrs[0]), sizeof(H5B2_node_ptr_t) * middle_nrec_move);
+ H5MM_memcpy(&(left_node_ptrs[*left_nrec + 1]), &(middle_node_ptrs[0]), sizeof(H5B2_node_ptr_t) * middle_nrec_move);
/* Count the number of records being moved into the left node */
for(u = 0; u < middle_nrec_move; u++)
@@ -1348,15 +1349,15 @@ H5B2__merge3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr,
/* Redistribute records into middle node */
{
/* Copy record from parent node to proper location in middle node */
- HDmemcpy(H5B2_NAT_NREC(middle_native, hdr, *middle_nrec), H5B2_INT_NREC(internal, hdr, idx), hdr->cls->nrec_size);
+ H5MM_memcpy(H5B2_NAT_NREC(middle_native, hdr, *middle_nrec), H5B2_INT_NREC(internal, hdr, idx), hdr->cls->nrec_size);
/* Copy records from right node to middle node */
- HDmemcpy(H5B2_NAT_NREC(middle_native, hdr, *middle_nrec + 1), H5B2_NAT_NREC(right_native, hdr, 0), hdr->cls->nrec_size * (*right_nrec));
+ H5MM_memcpy(H5B2_NAT_NREC(middle_native, hdr, *middle_nrec + 1), H5B2_NAT_NREC(right_native, hdr, 0), hdr->cls->nrec_size * (*right_nrec));
/* Move node pointers also if this is an internal node */
if(depth > 1)
/* Copy node pointers from right node into middle node */
- HDmemcpy(&(middle_node_ptrs[*middle_nrec + 1]), &(right_node_ptrs[0]), sizeof(H5B2_node_ptr_t) * (size_t)(*right_nrec + 1));
+ H5MM_memcpy(&(middle_node_ptrs[*middle_nrec + 1]), &(right_node_ptrs[0]), sizeof(H5B2_node_ptr_t) * (size_t)(*right_nrec + 1));
/* Update flush dependencies for grandchildren, if using SWMR */
if(hdr->swmr_write && depth > 1)
@@ -1539,7 +1540,7 @@ H5B2__iterate_node(H5B2_hdr_t *hdr, uint16_t depth, const H5B2_node_ptr_t *curr_
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree internal node pointers")
/* Copy the node pointers */
- HDmemcpy(node_ptrs, internal->node_ptrs, (sizeof(H5B2_node_ptr_t) * (size_t)(curr_node->node_nrec + 1)));
+ H5MM_memcpy(node_ptrs, internal->node_ptrs, (sizeof(H5B2_node_ptr_t) * (size_t)(curr_node->node_nrec + 1)));
} /* end if */
else {
H5B2_leaf_t *leaf; /* Pointer to leaf node */
@@ -1559,7 +1560,7 @@ H5B2__iterate_node(H5B2_hdr_t *hdr, uint16_t depth, const H5B2_node_ptr_t *curr_
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree internal native keys")
/* Copy the native keys */
- HDmemcpy(native, node_native, (hdr->cls->nrec_size * curr_node->node_nrec));
+ H5MM_memcpy(native, node_native, (hdr->cls->nrec_size * curr_node->node_nrec));
/* Unlock the node */
if(H5AC_unprotect(hdr->f, curr_node_class, curr_node->addr, node, (unsigned)(hdr->swmr_write ? H5AC__PIN_ENTRY_FLAG : H5AC__NO_FLAGS_SET)) < 0)
diff --git a/src/H5B2leaf.c b/src/H5B2leaf.c
index 54d40ea..beca40c 100644
--- a/src/H5B2leaf.c
+++ b/src/H5B2leaf.c
@@ -412,7 +412,7 @@ H5B2__insert_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr,
if(hdr->min_native_rec == NULL)
if(NULL == (hdr->min_native_rec = H5MM_malloc(hdr->cls->nrec_size)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree min record info")
- HDmemcpy(hdr->min_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size);
+ H5MM_memcpy(hdr->min_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size);
} /* end if */
} /* end if */
if(idx == (unsigned)(leaf->nrec - 1)) {
@@ -420,7 +420,7 @@ H5B2__insert_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr,
if(hdr->max_native_rec == NULL)
if(NULL == (hdr->max_native_rec = H5MM_malloc(hdr->cls->nrec_size)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree max record info")
- HDmemcpy(hdr->max_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size);
+ H5MM_memcpy(hdr->max_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size);
} /* end if */
} /* end if */
} /* end if */
@@ -561,7 +561,7 @@ H5B2__update_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr,
if(hdr->min_native_rec == NULL)
if(NULL == (hdr->min_native_rec = H5MM_malloc(hdr->cls->nrec_size)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree min record info")
- HDmemcpy(hdr->min_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size);
+ H5MM_memcpy(hdr->min_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size);
} /* end if */
} /* end if */
if(idx == (unsigned)(leaf->nrec - 1)) {
@@ -569,7 +569,7 @@ H5B2__update_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr,
if(hdr->max_native_rec == NULL)
if(NULL == (hdr->max_native_rec = H5MM_malloc(hdr->cls->nrec_size)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree max record info")
- HDmemcpy(hdr->max_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size);
+ H5MM_memcpy(hdr->max_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size);
} /* end if */
} /* end if */
} /* end if */
@@ -664,9 +664,9 @@ H5B2__swap_leaf(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal,
} /* end else */
/* Swap records (use disk page as temporary buffer) */
- HDmemcpy(hdr->page, H5B2_NAT_NREC(child_native, hdr, 0), hdr->cls->nrec_size);
- HDmemcpy(H5B2_NAT_NREC(child_native, hdr, 0), swap_loc, hdr->cls->nrec_size);
- HDmemcpy(swap_loc, hdr->page, hdr->cls->nrec_size);
+ H5MM_memcpy(hdr->page, H5B2_NAT_NREC(child_native, hdr, 0), hdr->cls->nrec_size);
+ H5MM_memcpy(H5B2_NAT_NREC(child_native, hdr, 0), swap_loc, hdr->cls->nrec_size);
+ H5MM_memcpy(swap_loc, hdr->page, hdr->cls->nrec_size);
/* Mark parent as dirty */
*internal_flags_ptr |= H5AC__DIRTIED_FLAG;
diff --git a/src/H5Bcache.c b/src/H5Bcache.c
index a0a75c8..c2c7a80 100644
--- a/src/H5Bcache.c
+++ b/src/H5Bcache.c
@@ -35,6 +35,7 @@
#include "H5private.h" /* Generic Functions */
#include "H5Bpkg.h" /* B-link trees */
#include "H5Eprivate.h" /* Error handling */
+#include "H5MMprivate.h" /* Memory management */
/****************/
@@ -304,7 +305,7 @@ H5B__cache_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len,
HDassert(shared->type->encode);
/* magic number */
- HDmemcpy(image, H5B_MAGIC, (size_t)H5_SIZEOF_MAGIC);
+ H5MM_memcpy(image, H5B_MAGIC, (size_t)H5_SIZEOF_MAGIC);
image += 4;
/* node type and level */
diff --git a/src/H5Bdbg.c b/src/H5Bdbg.c
index c491783..665e826 100644
--- a/src/H5Bdbg.c
+++ b/src/H5Bdbg.c
@@ -193,13 +193,13 @@ H5B__assert(H5F_t *f, haddr_t addr, const H5B_class_t *type, void *udata)
FUNC_ENTER_PACKAGE
if(0 == ncalls++) {
- if(H5DEBUG(B))
- fprintf(H5DEBUG(B), "H5B: debugging B-trees (expensive)\n");
+ if(H5DEBUG(B))
+ HDfprintf(H5DEBUG(B), "H5B: debugging B-trees (expensive)\n");
} /* end if */
/* Get shared info for B-tree */
if(NULL == (rc_shared = (type->get_shared)(f, udata)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree's shared ref. count object")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree's shared ref. count object")
shared = (H5B_shared_t *)H5UC_GET_OBJ(rc_shared);
HDassert(shared);
diff --git a/src/H5C.c b/src/H5C.c
index c1d9d17..ad2f762 100644
--- a/src/H5C.c
+++ b/src/H5C.c
@@ -1483,31 +1483,17 @@ H5C_insert_entry(H5F_t * f,
H5C__UPDATE_STATS_FOR_INSERTION(cache_ptr, entry_ptr)
#ifdef H5_HAVE_PARALLEL
- if(H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) {
- coll_access = (H5P_USER_TRUE == f->coll_md_read ? TRUE : FALSE);
-
- /* If not explicitly disabled, get the cmdr setting from the API context */
- if(!coll_access && H5P_FORCE_FALSE != f->coll_md_read)
- coll_access = H5CX_get_coll_metadata_read();
- } /* end if */
+ if(H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI))
+ coll_access = H5CX_get_coll_metadata_read();
entry_ptr->coll_access = coll_access;
if(coll_access) {
H5C__INSERT_IN_COLL_LIST(cache_ptr, entry_ptr, FAIL)
/* Make sure the size of the collective entries in the cache remain in check */
- if(H5P_USER_TRUE == f->coll_md_read) {
- if(cache_ptr->max_cache_size * 80 < cache_ptr->coll_list_size * 100) {
- if(H5C_clear_coll_entries(cache_ptr, TRUE) < 0)
- HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "can't clear collective metadata entries")
- } /* end if */
- } /* end if */
- else {
- if(cache_ptr->max_cache_size * 40 < cache_ptr->coll_list_size * 100) {
- if(H5C_clear_coll_entries(cache_ptr, TRUE) < 0)
- HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "can't clear collective metadata entries")
- } /* end if */
- } /* end else */
+ if(cache_ptr->max_cache_size * 80 < cache_ptr->coll_list_size * 100)
+ if(H5C_clear_coll_entries(cache_ptr, TRUE) < 0)
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "can't clear collective metadata entries")
} /* end if */
#endif
@@ -2243,13 +2229,8 @@ H5C_protect(H5F_t * f,
ring = H5CX_get_ring();
#ifdef H5_HAVE_PARALLEL
- if(H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) {
- coll_access = (H5P_USER_TRUE == f->coll_md_read ? TRUE : FALSE);
-
- /* If not explicitly disabled, get the cmdr setting from the API context */
- if(!coll_access && H5P_FORCE_FALSE != f->coll_md_read)
- coll_access = H5CX_get_coll_metadata_read();
- } /* end if */
+ if(H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI))
+ coll_access = H5CX_get_coll_metadata_read();
#endif /* H5_HAVE_PARALLEL */
/* first check to see if the target is in cache */
@@ -2286,7 +2267,7 @@ H5C_protect(H5F_t * f,
the entry in their cache still have to participate in the
bcast. */
#ifdef H5_HAVE_PARALLEL
- if(H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI) && coll_access) {
+ if(coll_access) {
if(!(entry_ptr->is_dirty) && !(entry_ptr->coll_access)) {
MPI_Comm comm; /* File MPI Communicator */
int mpi_code; /* MPI error code */
@@ -2304,7 +2285,7 @@ H5C_protect(H5F_t * f,
if(NULL == (entry_ptr->image_ptr = H5MM_malloc(entry_ptr->size + H5C_IMAGE_EXTRA_SPACE)))
HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, "memory allocation failed for on disk image buffer")
#if H5C_DO_MEMORY_SANITY_CHECKS
- HDmemcpy(((uint8_t *)entry_ptr->image_ptr) + entry_ptr->size, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE);
+ H5MM_memcpy(((uint8_t *)entry_ptr->image_ptr) + entry_ptr->size, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE);
#endif /* H5C_DO_MEMORY_SANITY_CHECKS */
if(0 == mpi_rank)
if(H5C__generate_image(f, cache_ptr, entry_ptr) < 0)
@@ -2601,21 +2582,11 @@ H5C_protect(H5F_t * f,
} /* end if */
#ifdef H5_HAVE_PARALLEL
- if(H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) {
- /* Make sure the size of the collective entries in the cache remain in check */
- if(coll_access) {
- if(H5P_USER_TRUE == f->coll_md_read) {
- if(cache_ptr->max_cache_size * 80 < cache_ptr->coll_list_size * 100)
- if(H5C_clear_coll_entries(cache_ptr, TRUE) < 0)
- HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, NULL, "can't clear collective metadata entries")
- } /* end if */
- else {
- if(cache_ptr->max_cache_size * 40 < cache_ptr->coll_list_size * 100)
- if(H5C_clear_coll_entries(cache_ptr, TRUE) < 0)
- HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, NULL, "can't clear collective metadata entries")
- } /* end else */
- } /* end if */
- } /* end if */
+ /* Make sure the size of the collective entries in the cache remain in check */
+ if(coll_access)
+ if(cache_ptr->max_cache_size * 80 < cache_ptr->coll_list_size * 100)
+ if(H5C_clear_coll_entries(cache_ptr, TRUE) < 0)
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, NULL, "can't clear collective metadata entries")
#endif /* H5_HAVE_PARALLEL */
done:
@@ -6071,7 +6042,7 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags)
if(NULL == (entry_ptr->image_ptr = H5MM_malloc(entry_ptr->size + H5C_IMAGE_EXTRA_SPACE)))
HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for on disk image buffer")
#if H5C_DO_MEMORY_SANITY_CHECKS
- HDmemcpy(((uint8_t *)entry_ptr->image_ptr) + entry_ptr->size, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE);
+ H5MM_memcpy(((uint8_t *)entry_ptr->image_ptr) + entry_ptr->size, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE);
#endif /* H5C_DO_MEMORY_SANITY_CHECKS */
} /* end if */
@@ -6571,7 +6542,7 @@ H5C_load_entry(H5F_t * f,
if(NULL == (image = (uint8_t *)H5MM_malloc(len + H5C_IMAGE_EXTRA_SPACE)))
HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, "memory allocation failed for on disk image buffer")
#if H5C_DO_MEMORY_SANITY_CHECKS
- HDmemcpy(image + len, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE);
+ H5MM_memcpy(image + len, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE);
#endif /* H5C_DO_MEMORY_SANITY_CHECKS */
#ifdef H5_HAVE_PARALLEL
@@ -6609,7 +6580,7 @@ H5C_load_entry(H5F_t * f,
HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, "image null after H5MM_realloc()")
image = (uint8_t *)new_image;
#if H5C_DO_MEMORY_SANITY_CHECKS
- HDmemcpy(image + len, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE);
+ H5MM_memcpy(image + len, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE);
#endif /* H5C_DO_MEMORY_SANITY_CHECKS */
} /* end if */
@@ -6653,7 +6624,7 @@ H5C_load_entry(H5F_t * f,
HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, "image null after H5MM_realloc()")
image = (uint8_t *)new_image;
#if H5C_DO_MEMORY_SANITY_CHECKS
- HDmemcpy(image + actual_len, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE);
+ H5MM_memcpy(image + actual_len, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE);
#endif /* H5C_DO_MEMORY_SANITY_CHECKS */
if(actual_len > len) {
@@ -8485,7 +8456,7 @@ H5C__serialize_single_entry(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t *entry
if(NULL == (entry_ptr->image_ptr = H5MM_malloc(entry_ptr->size + H5C_IMAGE_EXTRA_SPACE)) )
HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for on disk image buffer")
#if H5C_DO_MEMORY_SANITY_CHECKS
- HDmemcpy(((uint8_t *)entry_ptr->image_ptr) + image_size, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE);
+ H5MM_memcpy(((uint8_t *)entry_ptr->image_ptr) + image_size, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE);
#endif /* H5C_DO_MEMORY_SANITY_CHECKS */
} /* end if */
@@ -8602,7 +8573,7 @@ H5C__generate_image(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr)
if(NULL == (entry_ptr->image_ptr = H5MM_realloc(entry_ptr->image_ptr, new_len + H5C_IMAGE_EXTRA_SPACE)))
HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for on disk image buffer")
#if H5C_DO_MEMORY_SANITY_CHECKS
- HDmemcpy(((uint8_t *)entry_ptr->image_ptr) + new_len, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE);
+ H5MM_memcpy(((uint8_t *)entry_ptr->image_ptr) + new_len, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE);
#endif /* H5C_DO_MEMORY_SANITY_CHECKS */
/* Update statistics for resizing the entry */
diff --git a/src/H5CX.c b/src/H5CX.c
index 3ad4649..2287805 100644
--- a/src/H5CX.c
+++ b/src/H5CX.c
@@ -53,7 +53,7 @@
* each thread individually. The association of contexts to threads will
* be handled by the pthread library.
*
- * In order for this macro to work, H5E__get_my_stack() must be preceeded
+ * In order for this macro to work, H5CX_get_my_context() must be preceeded
* by "H5CX_node_t *ctx =".
*/
#define H5CX_get_my_context() H5CX__get_context()
@@ -64,17 +64,22 @@
#define H5CX_get_my_context() (&H5CX_head_g)
#endif /* H5_HAVE_THREADSAFE */
+/* Common macro for the retrieving the pointer to a property list */
+#define H5CX_RETRIEVE_PLIST(PL, FAILVAL) \
+ /* Check if the property list is already available */ \
+ if(NULL == (*head)->ctx.PL) \
+ /* Get the property list pointer */ \
+ if(NULL == ((*head)->ctx.PL = (H5P_genplist_t *)H5I_object((*head)->ctx.H5_GLUE(PL,_id)))) \
+ HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, (FAILVAL), "can't get property list")
+
/* Common macro for the duplicated code to retrieve properties from a property list */
#define H5CX_RETRIEVE_PROP_COMMON(PL, DEF_PL, PROP_NAME, PROP_FIELD) \
/* Check for default property list */ \
if((*head)->ctx.H5_GLUE(PL,_id) == (DEF_PL)) \
- HDmemcpy(&(*head)->ctx.PROP_FIELD, &H5_GLUE3(H5CX_def_,PL,_cache).PROP_FIELD, sizeof(H5_GLUE3(H5CX_def_,PL,_cache).PROP_FIELD)); \
+ H5MM_memcpy(&(*head)->ctx.PROP_FIELD, &H5_GLUE3(H5CX_def_,PL,_cache).PROP_FIELD, sizeof(H5_GLUE3(H5CX_def_,PL,_cache).PROP_FIELD)); \
else { \
- /* Check if the property list is already available */ \
- if(NULL == (*head)->ctx.PL) \
- /* Get the dataset transfer property list pointer */ \
- if(NULL == ((*head)->ctx.PL = (H5P_genplist_t *)H5I_object((*head)->ctx.H5_GLUE(PL,_id)))) \
- HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, FAIL, "can't get default dataset transfer property list") \
+ /* Retrieve the property list */ \
+ H5CX_RETRIEVE_PLIST(PL, FAIL) \
\
/* Get the property */ \
if(H5P_get((*head)->ctx.PL, (PROP_NAME), &(*head)->ctx.PROP_FIELD) < 0) \
@@ -108,11 +113,8 @@
\
/* Check if property exists in DXPL */ \
if(!(*head)->ctx.H5_GLUE(PROP_FIELD,_set)) { \
- /* Check if the property list is already available */ \
- if(NULL == (*head)->ctx.dxpl) \
- /* Get the dataset transfer property list pointer */ \
- if(NULL == ((*head)->ctx.dxpl = (H5P_genplist_t *)H5I_object((*head)->ctx.dxpl_id))) \
- HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, FAIL, "can't get default dataset transfer property list") \
+ /* Retrieve the dataset transfer property list */ \
+ H5CX_RETRIEVE_PLIST(dxpl, FAIL) \
\
if((check_prop = H5P_exist_plist((*head)->ctx.dxpl, PROP_NAME)) < 0) \
HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "error checking for property") \
@@ -129,15 +131,12 @@
/* Macro for the duplicated code to test and set properties for a property list */
#define H5CX_SET_PROP(PROP_NAME, PROP_FIELD) \
if((*head)->ctx.H5_GLUE(PROP_FIELD,_set)) { \
- /* Check if the property list is already available */ \
- if(NULL == (*head)->ctx.dxpl) \
- /* Get the dataset transfer property list pointer */ \
- if(NULL == ((*head)->ctx.dxpl = (H5P_genplist_t *)H5I_object((*head)->ctx.dxpl_id))) \
- HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, NULL, "can't get default dataset transfer property list") \
+ /* Retrieve the dataset transfer property list */ \
+ H5CX_RETRIEVE_PLIST(dxpl, NULL) \
\
- /* Set the chunk filter mask property */ \
+ /* Set the property */ \
if(H5P_set((*head)->ctx.dxpl, PROP_NAME, &(*head)->ctx.PROP_FIELD) < 0) \
- HGOTO_ERROR(H5E_CONTEXT, H5E_CANTSET, NULL, "error setting filter mask xfer property") \
+ HGOTO_ERROR(H5E_CONTEXT, H5E_CANTSET, NULL, "error setting data xfer property") \
} /* end if */
#endif /* H5_HAVE_PARALLEL */
@@ -175,7 +174,7 @@
* corresponding property in the property list to be set when the API
* context is popped, when returning from the API routine. Note that the
* naming of these fields, <foo> and <foo>_set, is important for the
-* H5CX_TEST_SET_PROP and H5CX_SET_PROP macros to work properly.
+ * H5CX_TEST_SET_PROP and H5CX_SET_PROP macros to work properly.
*/
typedef struct H5CX_t {
/* DXPL */
@@ -186,6 +185,18 @@ typedef struct H5CX_t {
hid_t lapl_id; /* LAPL ID for API operation */
H5P_genplist_t *lapl; /* Link Access Property List */
+ /* DCPL */
+ hid_t dcpl_id; /* DCPL ID for API operation */
+ H5P_genplist_t *dcpl; /* Dataset Creation Property List */
+
+ /* DAPL */
+ hid_t dapl_id; /* DAPL ID for API operation */
+ H5P_genplist_t *dapl; /* Dataset Access Property List */
+
+ /* FAPL */
+ hid_t fapl_id; /* FAPL ID for API operation */
+ H5P_genplist_t *fapl; /* File Access Property List */
+
/* Internal: Object tagging info */
haddr_t tag; /* Current object's tag (ohdr chunk #0 address) */
@@ -274,6 +285,22 @@ typedef struct H5CX_t {
size_t nlinks; /* Number of soft / UD links to traverse (H5L_ACS_NLINKS_NAME) */
hbool_t nlinks_valid; /* Whether number of soft / UD links to traverse is valid */
+ /* Cached DCPL properties */
+ hbool_t do_min_dset_ohdr; /* Whether to minimize dataset object header */
+ hbool_t do_min_dset_ohdr_valid; /* Whether minimize dataset object header flag is valid */
+
+ /* Cached DAPL properties */
+ char *extfile_prefix; /* Prefix for external file */
+ hbool_t extfile_prefix_valid; /* Whether the prefix for external file is valid */
+ char *vds_prefix; /* Prefix for VDS */
+ hbool_t vds_prefix_valid; /* Whether the prefix for VDS is valid */
+
+ /* Cached FAPL properties */
+ H5F_libver_t low_bound; /* low_bound property for H5Pset_libver_bounds() */
+ hbool_t low_bound_valid; /* Whether low_bound property is valid */
+ H5F_libver_t high_bound; /* high_bound property for H5Pset_libver_bounds */
+ hbool_t high_bound_valid; /* Whether high_bound property is valid */
+
/* Cached VOL settings */
H5VL_connector_prop_t vol_connector_prop; /* Property for VOL connector ID & info */
hbool_t vol_connector_prop_valid; /* Whether property for VOL connector ID & info is valid */
@@ -328,6 +355,25 @@ typedef struct H5CX_lapl_cache_t {
size_t nlinks; /* Number of soft / UD links to traverse (H5L_ACS_NLINKS_NAME) */
} H5CX_lapl_cache_t;
+/* Typedef for cached default dataset creation property list information */
+/* (Same as the cached DXPL struct, above, except for the default DCPL) */
+typedef struct H5CX_dcpl_cache_t {
+ hbool_t do_min_dset_ohdr; /* Whether to minimize dataset object header */
+} H5CX_dcpl_cache_t;
+
+/* Typedef for cached default dataset access property list information */
+/* (Same as the cached DXPL struct, above, except for the default DXPL) */
+typedef struct H5CX_dapl_cache_t {
+ char *extfile_prefix; /* Prefix for external file */
+ char *vds_prefix; /* Prefix for VDS */
+} H5CX_dapl_cache_t;
+
+/* Typedef for cached default file access property list information */
+/* (Same as the cached DXPL struct, above, except for the default DCPL) */
+typedef struct H5CX_fapl_cache_t {
+ H5F_libver_t low_bound; /* low_bound property for H5Pset_libver_bounds() */
+ H5F_libver_t high_bound; /* high_bound property for H5Pset_libver_bounds */
+} H5CX_fapl_cache_t;
/********************/
/* Local Prototypes */
@@ -361,9 +407,21 @@ static H5CX_dxpl_cache_t H5CX_def_dxpl_cache;
/* Define a "default" link access property list cache structure to use for default LAPLs */
static H5CX_lapl_cache_t H5CX_def_lapl_cache;
+/* Define a "default" dataset creation property list cache structure to use for default DCPLs */
+static H5CX_dcpl_cache_t H5CX_def_dcpl_cache;
+
+/* Define a "default" dataset access property list cache structure to use for default DAPLs */
+static H5CX_dapl_cache_t H5CX_def_dapl_cache;
+
+/* Define a "default" file access property list cache structure to use for default FAPLs */
+static H5CX_fapl_cache_t H5CX_def_fapl_cache;
+
/* Declare a static free list to manage H5CX_node_t structs */
H5FL_DEFINE_STATIC(H5CX_node_t);
+/* Declare a static free list to manage H5CX_state_t structs */
+H5FL_DEFINE_STATIC(H5CX_state_t);
+
/*--------------------------------------------------------------------------
@@ -381,6 +439,9 @@ H5CX__init_package(void)
{
H5P_genplist_t *dx_plist; /* Data transfer property list */
H5P_genplist_t *la_plist; /* Link access property list */
+ H5P_genplist_t *dc_plist; /* Dataset creation property list */
+ H5P_genplist_t *da_plist; /* Dataset access property list */
+ H5P_genplist_t *fa_plist; /* File access property list */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
@@ -480,6 +541,53 @@ H5CX__init_package(void)
if(H5P_get(la_plist, H5L_ACS_NLINKS_NAME, &H5CX_def_lapl_cache.nlinks) < 0)
HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve number of soft / UD links to traverse")
+
+ /* Reset the "default DCPL cache" information */
+ HDmemset(&H5CX_def_dcpl_cache, 0, sizeof(H5CX_dcpl_cache_t));
+
+ /* Get the default DCPL cache information */
+
+ /* Get the default dataset creation property list */
+ if(NULL == (dc_plist = (H5P_genplist_t *)H5I_object(H5P_DATASET_CREATE_DEFAULT)))
+ HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, FAIL, "not a dataset create property list")
+
+ /* Get flag to indicate whether to minimize dataset object header */
+ if(H5P_get(dc_plist, H5D_CRT_MIN_DSET_HDR_SIZE_NAME, &H5CX_def_dcpl_cache.do_min_dset_ohdr) < 0)
+ HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve dataset minimize flag")
+
+ /* Reset the "default DAPL cache" information */
+ HDmemset(&H5CX_def_dapl_cache, 0, sizeof(H5CX_dapl_cache_t));
+
+ /* Get the default DAPL cache information */
+
+ /* Get the default dataset access property list */
+ if(NULL == (da_plist = (H5P_genplist_t *)H5I_object(H5P_DATASET_ACCESS_DEFAULT)))
+ HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, FAIL, "not a dataset create property list")
+
+ /* Get the prefix for the external file */
+ if(H5P_peek(da_plist, H5D_ACS_EFILE_PREFIX_NAME, &H5CX_def_dapl_cache.extfile_prefix) < 0)
+ HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve prefix for external file")
+
+ /* Get the prefix for the VDS file */
+ if(H5P_peek(da_plist, H5D_ACS_VDS_PREFIX_NAME, &H5CX_def_dapl_cache.vds_prefix) < 0)
+ HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve prefix for VDS")
+
+ /* Reset the "default FAPL cache" information */
+ HDmemset(&H5CX_def_fapl_cache, 0, sizeof(H5CX_fapl_cache_t));
+
+ /* Get the default FAPL cache information */
+
+ /* Get the default file access property list */
+ if(NULL == (fa_plist = (H5P_genplist_t *)H5I_object(H5P_FILE_ACCESS_DEFAULT)))
+ HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, FAIL, "not a dataset create property list")
+
+ /* Get low_bound */
+ if(H5P_get(fa_plist, H5F_ACS_LIBVER_LOW_BOUND_NAME, &H5CX_def_fapl_cache.low_bound) < 0)
+ HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve dataset minimize flag")
+
+ if(H5P_get(fa_plist, H5F_ACS_LIBVER_HIGH_BOUND_NAME, &H5CX_def_fapl_cache.high_bound) < 0)
+ HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve dataset minimize flag")
+
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5CX__init_package() */
@@ -603,7 +711,10 @@ H5CX__push_common(H5CX_node_t *cnode)
/* Set non-zero context info */
cnode->ctx.dxpl_id = H5P_DATASET_XFER_DEFAULT;
+ cnode->ctx.dcpl_id = H5P_DATASET_CREATE_DEFAULT;
+ cnode->ctx.dapl_id = H5P_DATASET_ACCESS_DEFAULT;
cnode->ctx.lapl_id = H5P_LINK_ACCESS_DEFAULT;
+ cnode->ctx.fapl_id = H5P_FILE_ACCESS_DEFAULT;
cnode->ctx.tag = H5AC__INVALID_TAG;
cnode->ctx.ring = H5AC_RING_USER;
@@ -680,6 +791,217 @@ H5CX_push_special(void)
/*-------------------------------------------------------------------------
+ * Function: H5CX_retrieve_state
+ *
+ * Purpose: Retrieve the state of an API context, for later resumption.
+ *
+ * Note: This routine _only_ tracks the state of API context information
+ * set before the VOL callback is invoked, not values that are
+ * set internal to the library. It's main purpose is to provide
+ * API context state to VOL connectors.
+ *
+ * Return: Non-negative on success / Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * January 8, 2019
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5CX_retrieve_state(H5CX_state_t **api_state)
+{
+ H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* Sanity check */
+ HDassert(head && *head);
+ HDassert(api_state);
+
+ /* Allocate & clear API context state */
+ if(NULL == (*api_state = H5FL_CALLOC(H5CX_state_t)))
+ HGOTO_ERROR(H5E_CONTEXT, H5E_CANTALLOC, FAIL, "unable to allocate new API context state")
+
+ /* Check for non-default DXPL */
+ if(H5P_DATASET_XFER_DEFAULT != (*head)->ctx.dxpl_id) {
+ /* Retrieve the DXPL property list */
+ H5CX_RETRIEVE_PLIST(dxpl, FAIL)
+
+ /* Copy the DXPL ID */
+ if(((*api_state)->dxpl_id = H5P_copy_plist((H5P_genplist_t *)(*head)->ctx.dxpl, FALSE)) < 0)
+ HGOTO_ERROR(H5E_CONTEXT, H5E_CANTCOPY, FAIL, "can't copy property list")
+ } /* end if */
+ else
+ (*api_state)->dxpl_id = H5P_DATASET_XFER_DEFAULT;
+
+ /* Check for non-default LAPL */
+ if(H5P_LINK_ACCESS_DEFAULT != (*head)->ctx.lapl_id) {
+ /* Retrieve the LAPL property list */
+ H5CX_RETRIEVE_PLIST(lapl, FAIL)
+
+ /* Copy the LAPL ID */
+ if(((*api_state)->lapl_id = H5P_copy_plist((H5P_genplist_t *)(*head)->ctx.lapl, FALSE)) < 0)
+ HGOTO_ERROR(H5E_CONTEXT, H5E_CANTCOPY, FAIL, "can't copy property list")
+ } /* end if */
+ else
+ (*api_state)->lapl_id = H5P_LINK_ACCESS_DEFAULT;
+
+ /* Keep a reference to the current VOL wrapping context */
+ (*api_state)->vol_wrap_ctx = (*head)->ctx.vol_wrap_ctx;
+ if(NULL != (*api_state)->vol_wrap_ctx)
+ if(H5VL_inc_vol_wrapper((*api_state)->vol_wrap_ctx) < 0)
+ HGOTO_ERROR(H5E_CONTEXT, H5E_CANTINC, FAIL, "can't increment refcount on VOL wrapping context")
+
+ /* Keep a copy of the VOL connector property, if there is one */
+ if((*head)->ctx.vol_connector_prop_valid && (*head)->ctx.vol_connector_prop.connector_id > 0) {
+ /* Get the connector property */
+ H5MM_memcpy(&(*api_state)->vol_connector_prop, &(*head)->ctx.vol_connector_prop, sizeof(H5VL_connector_prop_t));
+
+ /* Check for actual VOL connector property */
+ if((*api_state)->vol_connector_prop.connector_id) {
+ /* Copy connector info, if it exists */
+ if((*api_state)->vol_connector_prop.connector_info) {
+ H5VL_class_t *connector; /* Pointer to connector */
+ void *new_connector_info = NULL; /* Copy of connector info */
+
+ /* Retrieve the connector for the ID */
+ if(NULL == (connector = (H5VL_class_t *)H5I_object((*api_state)->vol_connector_prop.connector_id)))
+ HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, FAIL, "not a VOL connector ID")
+
+ /* Allocate and copy connector info */
+ if(H5VL_copy_connector_info(connector, &new_connector_info, (*api_state)->vol_connector_prop.connector_info) < 0)
+ HGOTO_ERROR(H5E_CONTEXT, H5E_CANTCOPY, FAIL, "connector info copy failed")
+ (*api_state)->vol_connector_prop.connector_info = new_connector_info;
+ } /* end if */
+
+ /* Increment the refcount on the connector ID */
+ if(H5I_inc_ref((*api_state)->vol_connector_prop.connector_id, FALSE) < 0)
+ HGOTO_ERROR(H5E_CONTEXT, H5E_CANTINC, FAIL, "incrementing VOL connector ID failed")
+ } /* end if */
+ } /* end if */
+
+#ifdef H5_HAVE_PARALLEL
+ /* Save parallel I/O settings */
+ (*api_state)->coll_metadata_read = (*head)->ctx.coll_metadata_read;
+#endif /* H5_HAVE_PARALLEL */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5CX_retrieve_state() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5CX_restore_state
+ *
+ * Purpose: Restore an API context, from a previously retrieved state.
+ *
+ * Note: This routine _only_ resets the state of API context information
+ * set before the VOL callback is invoked, not values that are
+ * set internal to the library. It's main purpose is to restore
+ * API context state from VOL connectors.
+ *
+ * Return: Non-negative on success / Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * January 9, 2019
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5CX_restore_state(const H5CX_state_t *api_state)
+{
+ H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */
+
+ FUNC_ENTER_NOAPI_NOINIT_NOERR
+
+ /* Sanity check */
+ HDassert(head && *head);
+ HDassert(api_state);
+
+ /* Restore the DXPL info */
+ (*head)->ctx.dxpl_id = api_state->dxpl_id;
+ (*head)->ctx.dxpl = NULL;
+
+ /* Restore the LAPL info */
+ (*head)->ctx.lapl_id = api_state->lapl_id;
+ (*head)->ctx.lapl = NULL;
+
+ /* Restore the VOL wrapper context */
+ (*head)->ctx.vol_wrap_ctx = api_state->vol_wrap_ctx;
+
+ /* Restore the VOL connector info */
+ if(api_state->vol_connector_prop.connector_id) {
+ H5MM_memcpy(&(*head)->ctx.vol_connector_prop, &api_state->vol_connector_prop, sizeof(H5VL_connector_prop_t));
+ (*head)->ctx.vol_connector_prop_valid = TRUE;
+ } /* end if */
+
+#ifdef H5_HAVE_PARALLEL
+ /* Restore parallel I/O settings */
+ (*head)->ctx.coll_metadata_read = api_state->coll_metadata_read;
+#endif /* H5_HAVE_PARALLEL */
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5CX_restore_state() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5CX_free_state
+ *
+ * Purpose: Free a previously retrievedAPI context state
+ *
+ * Return: Non-negative on success / Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * January 9, 2019
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5CX_free_state(H5CX_state_t *api_state)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* Sanity check */
+ HDassert(api_state);
+
+ /* Release the DXPL */
+ if(api_state->dxpl_id != H5P_DATASET_XFER_DEFAULT)
+ if(H5I_dec_ref(api_state->dxpl_id) < 0)
+ HGOTO_ERROR(H5E_CONTEXT, H5E_CANTDEC, FAIL, "can't decrement refcount on DXPL")
+
+ /* Release the LAPL */
+ if(api_state->lapl_id != H5P_LINK_ACCESS_DEFAULT)
+ if(H5I_dec_ref(api_state->lapl_id) < 0)
+ HGOTO_ERROR(H5E_CONTEXT, H5E_CANTDEC, FAIL, "can't decrement refcount on LAPL")
+
+ /* Release the VOL wrapper context */
+ if(api_state->vol_wrap_ctx)
+ if(H5VL_dec_vol_wrapper(api_state->vol_wrap_ctx) < 0)
+ HGOTO_ERROR(H5E_CONTEXT, H5E_CANTDEC, FAIL, "can't decrement refcount on VOL wrapping context")
+
+ /* Release the VOL connector property, if it was set */
+ if(api_state->vol_connector_prop.connector_id) {
+ /* Clean up any VOL connector info */
+ if(api_state->vol_connector_prop.connector_info)
+ if(H5VL_free_connector_info(api_state->vol_connector_prop.connector_id, api_state->vol_connector_prop.connector_info) < 0)
+ HGOTO_ERROR(H5E_CONTEXT, H5E_CANTRELEASE, FAIL, "unable to release VOL connector info object")
+ /* Decrement connector ID */
+ if(H5I_dec_ref(api_state->vol_connector_prop.connector_id) < 0)
+ HDONE_ERROR(H5E_CONTEXT, H5E_CANTDEC, FAIL, "can't close VOL connector ID")
+ } /* end if */
+
+ /* Free the state */
+ api_state = H5FL_FREE(H5CX_state_t, api_state);
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5CX_free_state() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5CX_is_def_dxpl
*
* Purpose: Checks if the API context is using the library's default DXPL
@@ -735,6 +1057,71 @@ H5CX_set_dxpl(hid_t dxpl_id)
/*-------------------------------------------------------------------------
+ * Function: H5CX_set_dcpl
+ *
+ * Purpose: Sets the DCPL for the current API call context.
+ *
+ * Return: <none>
+ *
+ * Programmer: Quincey Koziol
+ * March 6, 2019
+ *
+ *-------------------------------------------------------------------------
+ */
+void
+H5CX_set_dcpl(hid_t dcpl_id)
+{
+ H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */
+
+ FUNC_ENTER_NOAPI_NOINIT_NOERR
+
+ /* Sanity check */
+ HDassert(*head);
+
+ /* Set the API context's DCPL to a new value */
+ (*head)->ctx.dcpl_id = dcpl_id;
+
+ FUNC_LEAVE_NOAPI_VOID
+} /* end H5CX_set_dcpl() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5CX_set_libver_bounds
+ *
+ * Purpose: Sets the low/high bounds according to "f" for the current API call context.
+ * When "f" is NULL, the low/high bounds are set to latest format.
+ *
+ * Return: Non-negative on success / Negative on failure
+ *
+ * Programmer: Vailin Choi
+ * March 27, 2019
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5CX_set_libver_bounds(H5F_t *f)
+{
+ H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* Sanity check */
+ HDassert(head && *head);
+
+ /* Set the API context value */
+ (*head)->ctx.low_bound = (f == NULL) ? H5F_LIBVER_LATEST : H5F_LOW_BOUND(f);
+ (*head)->ctx.high_bound = (f == NULL) ? H5F_LIBVER_LATEST : H5F_HIGH_BOUND(f);
+
+ /* Mark the values as valid */
+ (*head)->ctx.low_bound_valid = TRUE;
+ (*head)->ctx.high_bound_valid = TRUE;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5CX_set_libver_bounds() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5CX_set_lapl
*
* Purpose: Sets the LAPL for the current API call context.
@@ -803,6 +1190,8 @@ H5CX_set_apl(hid_t *acspl_id, const H5P_libclass_t *libclass,
*acspl_id = *libclass->def_plist_id;
else {
htri_t is_lapl; /* Whether the access property list is (or is derived from) a link access property list */
+ htri_t is_dapl; /* Whether the access property list is (or is derived from) a dataset access property list */
+ htri_t is_fapl; /* Whether the access property list is (or is derived from) a file access property list */
#ifdef H5CX_DEBUG
/* Sanity check the access property list class */
@@ -816,10 +1205,22 @@ H5CX_set_apl(hid_t *acspl_id, const H5P_libclass_t *libclass,
else if(is_lapl)
(*head)->ctx.lapl_id = *acspl_id;
+ /* Check for dataset access property and set API context if so */
+ if((is_dapl = H5P_class_isa(*libclass->pclass, *H5P_CLS_DACC->pclass)) < 0)
+ HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "can't check for dataset access class")
+ else if(is_dapl)
+ (*head)->ctx.dapl_id = *acspl_id;
+
+ /* Check for file access property and set API context if so */
+ if((is_fapl = H5P_class_isa(*libclass->pclass, *H5P_CLS_FACC->pclass)) < 0)
+ HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "can't check for file access class")
+ else if(is_fapl)
+ (*head)->ctx.fapl_id = *acspl_id;
+
#ifdef H5_HAVE_PARALLEL
/* If this routine is not guaranteed to be collective (i.e. it doesn't
- * modify the structural metadata in a file), check if we should use
- * a collective metadata read.
+ * modify the structural metadata in a file), check if the application
+ * specified a collective metadata read for just this operation.
*/
if(!is_collective) {
H5P_genplist_t *plist; /* Property list pointer */
@@ -893,6 +1294,7 @@ H5CX_set_loc(hid_t
#endif /* H5_HAVE_PARALLEL */
loc_id)
{
+#ifdef H5_HAVE_PARALLEL
H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */
herr_t ret_value = SUCCEED; /* Return value */
@@ -901,7 +1303,6 @@ H5CX_set_loc(hid_t
/* Sanity check */
HDassert(head && *head);
-#ifdef H5_HAVE_PARALLEL
/* Set collective metadata read flag */
(*head)->ctx.coll_metadata_read = TRUE;
@@ -922,10 +1323,14 @@ H5CX_set_loc(hid_t
if(mpi_comm != MPI_COMM_NULL)
MPI_Barrier(mpi_comm);
} /* end if */
-#endif /* H5_HAVE_PARALLEL */
done:
FUNC_LEAVE_NOAPI(ret_value)
+#else /* H5_HAVE_PARALLEL */
+ FUNC_ENTER_NOAPI_NOINIT_NOERR
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+#endif /* H5_HAVE_PARALLEL */
} /* end H5CX_set_loc() */
@@ -987,7 +1392,7 @@ H5CX_set_vol_connector_prop(const H5VL_connector_prop_t *vol_connector_prop)
HDassert(head && *head);
/* Set the API context value */
- HDmemcpy(&(*head)->ctx.vol_connector_prop, vol_connector_prop, sizeof(H5VL_connector_prop_t));
+ H5MM_memcpy(&(*head)->ctx.vol_connector_prop, vol_connector_prop, sizeof(H5VL_connector_prop_t));
/* Mark the value as valid */
(*head)->ctx.vol_connector_prop_valid = TRUE;
@@ -1112,7 +1517,7 @@ H5CX_get_vol_connector_prop(H5VL_connector_prop_t *vol_connector_prop)
/* Check for value that was set */
if((*head)->ctx.vol_connector_prop_valid)
/* Get the value */
- HDmemcpy(vol_connector_prop, &(*head)->ctx.vol_connector_prop, sizeof(H5VL_connector_prop_t));
+ H5MM_memcpy(vol_connector_prop, &(*head)->ctx.vol_connector_prop, sizeof(H5VL_connector_prop_t));
else
HDmemset(vol_connector_prop, 0, sizeof(H5VL_connector_prop_t));
@@ -1343,7 +1748,7 @@ H5CX_get_btree_split_ratios(double split_ratio[3])
H5CX_RETRIEVE_PROP_VALID(dxpl, H5P_DATASET_XFER_DEFAULT, H5D_XFER_BTREE_SPLIT_RATIO_NAME, btree_split_ratio)
/* Get the B-tree split ratio values */
- HDmemcpy(split_ratio, &(*head)->ctx.btree_split_ratio, sizeof((*head)->ctx.btree_split_ratio));
+ H5MM_memcpy(split_ratio, &(*head)->ctx.btree_split_ratio, sizeof((*head)->ctx.btree_split_ratio));
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -2028,6 +2433,193 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5CX_get_nlinks() */
+/*-------------------------------------------------------------------------
+ * Function: H5CX_get_libver_bounds
+ *
+ * Purpose: Retrieves the low/high bounds for the current API call context.
+ *
+ * Return: Non-negative on success / Negative on failure
+ *
+ * Programmer: Vailin Choi
+ * March 27, 2019
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5CX_get_libver_bounds(H5F_libver_t *low_bound, H5F_libver_t *high_bound)
+{
+ H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* Sanity check */
+ HDassert(low_bound);
+ HDassert(high_bound);
+ HDassert(head && *head);
+ HDassert(H5P_DEFAULT != (*head)->ctx.fapl_id);
+
+ H5CX_RETRIEVE_PROP_VALID(fapl, H5P_FILE_ACCESS_DEFAULT, H5F_ACS_LIBVER_LOW_BOUND_NAME, low_bound)
+ H5CX_RETRIEVE_PROP_VALID(fapl, H5P_FILE_ACCESS_DEFAULT, H5F_ACS_LIBVER_HIGH_BOUND_NAME, high_bound)
+
+ /* Get the values */
+ *low_bound = (*head)->ctx.low_bound;
+ *high_bound = (*head)->ctx.high_bound;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5CX_get_libver_bounds() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5CX_get_dset_min_ohdr_flag
+ *
+ * Purpose: Retrieves the flag that indicates whether the dataset object
+ * header should be minimized
+ *
+ * Return: Non-negative on success / Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * March 6, 2019
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5CX_get_dset_min_ohdr_flag(hbool_t *dset_min_ohdr_flag)
+{
+ H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* Sanity check */
+ HDassert(dset_min_ohdr_flag);
+ HDassert(head && *head);
+ HDassert(H5P_DEFAULT != (*head)->ctx.dcpl_id);
+
+ H5CX_RETRIEVE_PROP_VALID(dcpl, H5P_DATASET_CREATE_DEFAULT, H5D_CRT_MIN_DSET_HDR_SIZE_NAME, do_min_dset_ohdr)
+
+ /* Get the value */
+ *dset_min_ohdr_flag = (*head)->ctx.do_min_dset_ohdr;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5CX_get_dset_min_ohdr_flag() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5CX_get_ext_file_prefix
+ *
+ * Purpose: Retrieves the prefix for external file
+ *
+ * Return: Non-negative on success / Negative on failure
+ *
+ * Programmer: Raymond Lu
+ * March 6, 2019
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5CX_get_ext_file_prefix(char **extfile_prefix)
+{
+ H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* Sanity check */
+ HDassert(extfile_prefix);
+ HDassert(head && *head);
+ HDassert(H5P_DEFAULT != (*head)->ctx.dapl_id);
+
+ /* Check if the value has been retrieved already */
+ if(!(*head)->ctx.extfile_prefix_valid) {
+ /* Check for default DAPL */
+ if((*head)->ctx.dapl_id == H5P_DATASET_ACCESS_DEFAULT)
+ (*head)->ctx.extfile_prefix = H5CX_def_dapl_cache.extfile_prefix;
+ else {
+ /* Check if the property list is already available */
+ if(NULL == (*head)->ctx.dapl)
+ /* Get the dataset access property list pointer */
+ if(NULL == ((*head)->ctx.dapl = (H5P_genplist_t *)H5I_object((*head)->ctx.dapl_id)))
+ HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, FAIL, "can't get default dataset access property list")
+
+ /* Get the prefix for the external file */
+ /* (Note: 'peek', not 'get' - if this turns out to be a problem, we may need
+ * to copy it and free this in the H5CX pop routine. -QAK)
+ */
+ if(H5P_peek((*head)->ctx.dapl, H5D_ACS_EFILE_PREFIX_NAME, &(*head)->ctx.extfile_prefix) < 0)
+ HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve external file prefix")
+ } /* end else */
+
+ /* Mark the value as valid */
+ (*head)->ctx.extfile_prefix_valid = TRUE;
+ } /* end if */
+
+ /* Get the value */
+ *extfile_prefix = (*head)->ctx.extfile_prefix;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5CX_get_ext_file_prefix() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5CX_get_vds_prefix
+ *
+ * Purpose: Retrieves the prefix for VDS
+ *
+ * Return: Non-negative on success / Negative on failure
+ *
+ * Programmer: Raymond Lu
+ * March 6, 2019
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5CX_get_vds_prefix(char **vds_prefix)
+{
+ H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* Sanity check */
+ HDassert(vds_prefix);
+ HDassert(head && *head);
+ HDassert(H5P_DEFAULT != (*head)->ctx.dapl_id);
+
+ /* Check if the value has been retrieved already */
+ if(!(*head)->ctx.vds_prefix_valid) {
+ /* Check for default DAPL */
+ if((*head)->ctx.dapl_id == H5P_DATASET_ACCESS_DEFAULT)
+ (*head)->ctx.vds_prefix = H5CX_def_dapl_cache.vds_prefix;
+ else {
+ /* Check if the property list is already available */
+ if(NULL == (*head)->ctx.dapl)
+ /* Get the dataset access property list pointer */
+ if(NULL == ((*head)->ctx.dapl = (H5P_genplist_t *)H5I_object((*head)->ctx.dapl_id)))
+ HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, FAIL, "can't get default dataset access property list")
+
+ /* Get the prefix for the VDS */
+ /* (Note: 'peek', not 'get' - if this turns out to be a problem, we may need
+ * to copy it and free this in the H5CX pop routine. -QAK)
+ */
+ if(H5P_peek((*head)->ctx.dapl, H5D_ACS_VDS_PREFIX_NAME, &(*head)->ctx.vds_prefix) < 0)
+ HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve VDS prefix")
+ } /* end else */
+
+ /* Mark the value as valid */
+ (*head)->ctx.vds_prefix_valid = TRUE;
+ } /* end if */
+
+ /* Get the value */
+ *vds_prefix = (*head)->ctx.vds_prefix;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5CX_get_vds_prefix() */
+
/*-------------------------------------------------------------------------
* Function: H5CX_set_tag
diff --git a/src/H5CXprivate.h b/src/H5CXprivate.h
index 04c6f55..91316e4 100644
--- a/src/H5CXprivate.h
+++ b/src/H5CXprivate.h
@@ -39,6 +39,19 @@
/* Library Private Typedefs */
/****************************/
+/* API context state */
+typedef struct H5CX_state_t {
+ hid_t dxpl_id; /* DXPL for operation */
+ hid_t lapl_id; /* LAPL for operation */
+ void *vol_wrap_ctx; /* VOL connector's "wrap context" for creating IDs */
+ H5VL_connector_prop_t vol_connector_prop; /* VOL connector property */
+
+#ifdef H5_HAVE_PARALLEL
+ /* Internal: Parallel I/O settings */
+ hbool_t coll_metadata_read; /* Whether to use collective I/O for metadata read */
+#endif /* H5_HAVE_PARALLEL */
+} H5CX_state_t;
+
/*****************************/
/* Library-private Variables */
@@ -57,9 +70,16 @@ H5_DLL herr_t H5CX_pop(void);
H5_DLL void H5CX_push_special(void);
H5_DLL hbool_t H5CX_is_def_dxpl(void);
+/* API context state routines */
+H5_DLL herr_t H5CX_retrieve_state(H5CX_state_t **api_state);
+H5_DLL herr_t H5CX_restore_state(const H5CX_state_t *api_state);
+H5_DLL herr_t H5CX_free_state(H5CX_state_t *api_state);
+
/* "Setter" routines for API context info */
H5_DLL void H5CX_set_dxpl(hid_t dxpl_id);
H5_DLL void H5CX_set_lapl(hid_t lapl_id);
+H5_DLL void H5CX_set_dcpl(hid_t dcpl_id);
+H5_DLL herr_t H5CX_set_libver_bounds(H5F_t *f);
H5_DLL herr_t H5CX_set_apl(hid_t *acspl_id, const H5P_libclass_t *libclass,
hid_t loc_id, hbool_t is_collective);
H5_DLL herr_t H5CX_set_loc(hid_t loc_id);
@@ -106,6 +126,16 @@ H5_DLL herr_t H5CX_get_dt_conv_cb(H5T_conv_cb_t *cb_struct);
/* "Getter" routines for LAPL properties cached in API context */
H5_DLL herr_t H5CX_get_nlinks(size_t *nlinks);
+/* "Getter" routines for DCPL properties cached in API context */
+H5_DLL herr_t H5CX_get_dset_min_ohdr_flag(hbool_t *dset_min_ohdr_flag);
+
+/* "Getter" routines for DAPL properties cached in API context */
+H5_DLL herr_t H5CX_get_ext_file_prefix(char **prefix_extfile);
+H5_DLL herr_t H5CX_get_vds_prefix(char **prefix_vds);
+
+/* "Getter" routines for FAPL properties cached in API context */
+H5_DLL herr_t H5CX_get_libver_bounds(H5F_libver_t *low_bound, H5F_libver_t *high_bound);
+
/* "Setter" routines for API context info */
H5_DLL void H5CX_set_tag(haddr_t tag);
H5_DLL void H5CX_set_ring(H5AC_ring_t ring);
diff --git a/src/H5Cimage.c b/src/H5Cimage.c
index bdab1a3..db44c7a 100644
--- a/src/H5Cimage.c
+++ b/src/H5Cimage.c
@@ -1065,9 +1065,9 @@ H5C__read_cache_image(H5F_t *f, H5C_t *cache_ptr)
H5C__UPDATE_STATS_FOR_CACHE_IMAGE_READ(cache_ptr)
#ifdef H5_HAVE_PARALLEL
- if ( aux_ptr ) {
+ if ( aux_ptr ) {
- /* Broadcast cache image */
+ /* Broadcast cache image */
if ( MPI_SUCCESS !=
(mpi_result = MPI_Bcast(cache_ptr->image_buffer,
(int)cache_ptr->image_len, MPI_BYTE,
@@ -2020,11 +2020,11 @@ H5C__decode_cache_image_entry(const H5F_t *f, const H5C_t *cache_ptr,
HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for on disk image buffer")
#if H5C_DO_MEMORY_SANITY_CHECKS
- HDmemcpy(((uint8_t *)image_ptr) + size, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE);
+ H5MM_memcpy(((uint8_t *)image_ptr) + size, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE);
#endif /* H5C_DO_MEMORY_SANITY_CHECKS */
/* Copy the entry image from the cache image block */
- HDmemcpy(image_ptr, p, size);
+ H5MM_memcpy(image_ptr, p, size);
p += size;
/* Copy data into target */
@@ -2219,7 +2219,7 @@ H5C__encode_cache_image_header(const H5F_t *f, const H5C_t *cache_ptr,
p = *buf;
/* write signature */
- HDmemcpy(p, H5C__MDCI_BLOCK_SIGNATURE, (size_t)H5C__MDCI_BLOCK_SIGNATURE_LEN);
+ H5MM_memcpy(p, H5C__MDCI_BLOCK_SIGNATURE, (size_t)H5C__MDCI_BLOCK_SIGNATURE_LEN);
p += H5C__MDCI_BLOCK_SIGNATURE_LEN;
/* write version */
@@ -2355,7 +2355,7 @@ H5C__encode_cache_image_entry(H5F_t *f, H5C_t *cache_ptr, uint8_t **buf,
H5F_addr_encode(f, &p, ie_ptr->fd_parent_addrs[u]);
/* Copy entry image */
- HDmemcpy(p, ie_ptr->image_ptr, ie_ptr->size);
+ H5MM_memcpy(p, ie_ptr->image_ptr, ie_ptr->size);
p += ie_ptr->size;
/* Update buffer pointer */
@@ -3422,11 +3422,11 @@ H5C__reconstruct_cache_entry(const H5F_t *f, H5C_t *cache_ptr,
if(NULL == (pf_entry_ptr->image_ptr = H5MM_malloc(pf_entry_ptr->size + H5C_IMAGE_EXTRA_SPACE)))
HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, "memory allocation failed for on disk image buffer")
#if H5C_DO_MEMORY_SANITY_CHECKS
- HDmemcpy(((uint8_t *)pf_entry_ptr->image_ptr) + size, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE);
+ H5MM_memcpy(((uint8_t *)pf_entry_ptr->image_ptr) + size, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE);
#endif /* H5C_DO_MEMORY_SANITY_CHECKS */
/* Copy the entry image from the cache image block */
- HDmemcpy(pf_entry_ptr->image_ptr, p, pf_entry_ptr->size);
+ H5MM_memcpy(pf_entry_ptr->image_ptr, p, pf_entry_ptr->size);
p += pf_entry_ptr->size;
/* Initialize the rest of the fields in the prefetched entry */
diff --git a/src/H5Clog_trace.c b/src/H5Clog_trace.c
index 7c1305c..713f333 100644
--- a/src/H5Clog_trace.c
+++ b/src/H5Clog_trace.c
@@ -41,7 +41,7 @@
/****************/
/* Max log message size */
-#define H5C_MAX_TRACE_LOG_MSG_SIZE 2048
+#define H5C_MAX_TRACE_LOG_MSG_SIZE 4096
/******************/
diff --git a/src/H5Cmpio.c b/src/H5Cmpio.c
index ecaed62..84ec16c 100644
--- a/src/H5Cmpio.c
+++ b/src/H5Cmpio.c
@@ -214,10 +214,10 @@ H5C_apply_candidate_list(H5F_t * f,
HDmemset(tbl_buf, 0, sizeof(tbl_buf));
- sprintf(&(tbl_buf[0]), "candidate list = ");
+ HDsprintf(&(tbl_buf[0]), "candidate list = ");
for(u = 0; u < num_candidates; u++)
- sprintf(&(tbl_buf[HDstrlen(tbl_buf)]), " 0x%llx", (long long)(*(candidates_list_ptr + u)));
- sprintf(&(tbl_buf[HDstrlen(tbl_buf)]), "\n");
+ HDsprintf(&(tbl_buf[HDstrlen(tbl_buf)]), " 0x%llx", (long long)(*(candidates_list_ptr + u)));
+ HDsprintf(&(tbl_buf[HDstrlen(tbl_buf)]), "\n");
HDfprintf(stdout, "%s", tbl_buf);
#endif /* H5C_APPLY_CANDIDATE_LIST__DEBUG */
@@ -280,10 +280,10 @@ H5C_apply_candidate_list(H5F_t * f,
#if H5C_APPLY_CANDIDATE_LIST__DEBUG
for ( i = 0; i < 1024; i++ )
tbl_buf[i] = '\0';
- sprintf(&(tbl_buf[0]), "candidate assignment table = ");
+ HDsprintf(&(tbl_buf[0]), "candidate assignment table = ");
for(i = 0; i <= mpi_size; i++)
- sprintf(&(tbl_buf[HDstrlen(tbl_buf)]), " %d", candidate_assignment_table[i]);
- sprintf(&(tbl_buf[HDstrlen(tbl_buf)]), "\n");
+ HDsprintf(&(tbl_buf[HDstrlen(tbl_buf)]), " %d", candidate_assignment_table[i]);
+ HDsprintf(&(tbl_buf[HDstrlen(tbl_buf)]), "\n");
HDfprintf(stdout, "%s", tbl_buf);
HDfprintf(stdout, "%s:%d: flush entries [%u, %u].\n",
diff --git a/src/H5D.c b/src/H5D.c
index fc350f2..a8cefd9 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -105,11 +105,10 @@ hid_t
H5Dcreate2(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id,
hid_t lcpl_id, hid_t dcpl_id, hid_t dapl_id)
{
- void *dset = NULL; /* New dataset's info */
- H5VL_object_t *vol_obj = NULL; /* object token of loc_id */
+ void *dset = NULL; /* New dataset's info */
+ H5VL_object_t *vol_obj = NULL; /* object token of loc_id */
H5VL_loc_params_t loc_params;
- H5P_genplist_t *plist = NULL; /* Property list pointer */
- hid_t ret_value = H5I_INVALID_HID; /* Return value */
+ hid_t ret_value = H5I_INVALID_HID; /* Return value */
FUNC_ENTER_API(H5I_INVALID_HID)
H5TRACE7("i", "i*siiiii", loc_id, name, type_id, space_id, lcpl_id, dcpl_id,
@@ -135,32 +134,23 @@ H5Dcreate2(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id,
if(TRUE != H5P_isa_class(dcpl_id, H5P_DATASET_CREATE))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "dcpl_id is not a dataset create property list ID")
+ /* Set the DCPL for the API context */
+ H5CX_set_dcpl(dcpl_id);
+
/* Verify access property list and set up collective metadata if appropriate */
if(H5CX_set_apl(&dapl_id, H5P_CLS_DACC, loc_id, TRUE) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info")
- /* Get the property list structure for the dcpl */
- if(NULL == (plist = (H5P_genplist_t *)H5I_object(dcpl_id)))
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5I_INVALID_HID, "can't find object for ID")
-
/* Get the location object */
if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier")
- /* Set creation properties */
- if(H5P_set(plist, H5VL_PROP_DSET_TYPE_ID, &type_id) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for datatype id")
- if(H5P_set(plist, H5VL_PROP_DSET_SPACE_ID, &space_id) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for space id")
- if(H5P_set(plist, H5VL_PROP_DSET_LCPL_ID, &lcpl_id) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for lcpl id")
-
/* Set location parameters */
loc_params.type = H5VL_OBJECT_BY_SELF;
loc_params.obj_type = H5I_get_type(loc_id);
/* Create the dataset */
- if(NULL == (dset = H5VL_dataset_create(vol_obj, &loc_params, name, dcpl_id, dapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)))
+ if(NULL == (dset = H5VL_dataset_create(vol_obj, &loc_params, name, lcpl_id, type_id, space_id, dcpl_id, dapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, H5I_INVALID_HID, "unable to create dataset")
/* Get an atom for the dataset */
@@ -213,9 +203,8 @@ H5Dcreate_anon(hid_t loc_id, hid_t type_id, hid_t space_id, hid_t dcpl_id,
hid_t dapl_id)
{
void *dset = NULL; /* dset token from VOL connector */
- H5VL_object_t *vol_obj = NULL; /* object token of loc_id */
+ H5VL_object_t *vol_obj = NULL; /* object token of loc_id */
H5VL_loc_params_t loc_params;
- H5P_genplist_t *plist; /* Property list pointer */
hid_t ret_value = H5I_INVALID_HID; /* Return value */
FUNC_ENTER_API(H5I_INVALID_HID)
@@ -228,6 +217,9 @@ H5Dcreate_anon(hid_t loc_id, hid_t type_id, hid_t space_id, hid_t dcpl_id,
if(TRUE != H5P_isa_class(dcpl_id, H5P_DATASET_CREATE))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not dataset create property list ID")
+ /* Set the DCPL for the API context */
+ H5CX_set_dcpl(dcpl_id);
+
/* Verify access property list and set up collective metadata if appropriate */
if(H5CX_set_apl(&dapl_id, H5P_CLS_DACC, loc_id, TRUE) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info")
@@ -236,22 +228,12 @@ H5Dcreate_anon(hid_t loc_id, hid_t type_id, hid_t space_id, hid_t dcpl_id,
if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier")
- /* Get the plist structure */
- if(NULL == (plist = (H5P_genplist_t *)H5I_object(dcpl_id)))
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5I_INVALID_HID, "can't find object for ID")
-
- /* set creation properties */
- if(H5P_set(plist, H5VL_PROP_DSET_TYPE_ID, &type_id) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for datatype id")
- if(H5P_set(plist, H5VL_PROP_DSET_SPACE_ID, &space_id) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for space id")
-
/* Set location parameters */
loc_params.type = H5VL_OBJECT_BY_SELF;
loc_params.obj_type = H5I_get_type(loc_id);
/* Create the dataset */
- if(NULL == (dset = H5VL_dataset_create(vol_obj, &loc_params, NULL, dcpl_id, dapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)))
+ if(NULL == (dset = H5VL_dataset_create(vol_obj, &loc_params, NULL, H5P_LINK_CREATE_DEFAULT, type_id, space_id, dcpl_id, dapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, H5I_INVALID_HID, "unable to create dataset")
/* Get an atom for the dataset */
@@ -455,7 +437,7 @@ H5Dget_type(hid_t dset_id)
if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid dataset identifier")
- /* get the datatype */
+ /* Get the datatype */
if(H5VL_dataset_get(vol_obj, H5VL_DATASET_GET_TYPE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, H5I_INVALID_HID, "unable to get datatype")
diff --git a/src/H5Dbtree.c b/src/H5Dbtree.c
index b61aed4..c13c36a 100644
--- a/src/H5Dbtree.c
+++ b/src/H5Dbtree.c
@@ -39,6 +39,7 @@
#include "H5FLprivate.h" /* Free Lists */
#include "H5Iprivate.h" /* IDs */
#include "H5MFprivate.h" /* File space management */
+#include "H5MMprivate.h" /* Memory management */
#include "H5Oprivate.h" /* Object headers */
#include "H5Sprivate.h" /* Dataspaces */
#include "H5VMprivate.h" /* Vector and array functions */
@@ -847,7 +848,7 @@ H5D__btree_shared_create(const H5F_t *f, H5O_storage_chunk_t *store,
/* Set up the "local" information for this dataset's chunks */
if(NULL == (my_layout = H5FL_MALLOC(H5O_layout_chunk_t)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate chunk layout")
- HDmemcpy(my_layout, layout, sizeof(H5O_layout_chunk_t));
+ H5MM_memcpy(my_layout, layout, sizeof(H5O_layout_chunk_t));
shared->udata = my_layout;
/* Make shared B-tree info reference counted */
@@ -1087,7 +1088,7 @@ H5D__btree_idx_iterate_cb(H5F_t H5_ATTR_UNUSED *f, const void *_lt_key,
HDcompile_assert(sizeof(chunk_rec.filter_mask) == sizeof(lt_key->filter_mask));
/* Compose generic chunk record for callback */
- HDmemcpy(&chunk_rec, lt_key, sizeof(*lt_key));
+ H5MM_memcpy(&chunk_rec, lt_key, sizeof(*lt_key));
chunk_rec.chunk_addr = addr;
/* Make "generic chunk" callback */
diff --git a/src/H5Dbtree2.c b/src/H5Dbtree2.c
index b32f395..d25e0f0 100644
--- a/src/H5Dbtree2.c
+++ b/src/H5Dbtree2.c
@@ -32,6 +32,7 @@
#include "H5Dpkg.h" /* Datasets */
#include "H5FLprivate.h" /* Free Lists */
#include "H5MFprivate.h" /* File space management */
+#include "H5MMprivate.h" /* Memory management */
#include "H5VMprivate.h" /* Vector and array functions */
@@ -248,7 +249,7 @@ H5D__bt2_crt_context(void *_udata)
/* Set up the "local" information for this dataset's chunk dimension sizes */
if(NULL == (my_dim = (uint32_t *)H5FL_BLK_MALLOC(chunk_dim, H5O_LAYOUT_NDIMS * sizeof(uint32_t))))
HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, NULL, "can't allocate chunk dims")
- HDmemcpy(my_dim, udata->dim, H5O_LAYOUT_NDIMS * sizeof(uint32_t));
+ H5MM_memcpy(my_dim, udata->dim, H5O_LAYOUT_NDIMS * sizeof(uint32_t));
ctx->dim = my_dim;
/*
diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c
index e165569..a8dc398 100644
--- a/src/H5Dchunk.c
+++ b/src/H5Dchunk.c
@@ -276,6 +276,8 @@ static hbool_t H5D__chunk_cinfo_cache_found(const H5D_chunk_cached_t *last,
static herr_t H5D__free_chunk_info(void *item, void *key, void *opdata);
static herr_t H5D__create_chunk_map_single(H5D_chunk_map_t *fm,
const H5D_io_info_t *io_info);
+static herr_t H5D__create_chunk_file_map_all(H5D_chunk_map_t *fm,
+ const H5D_io_info_t *io_info);
static herr_t H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm,
const H5D_io_info_t *io_info);
static herr_t H5D__create_chunk_mem_map_hyper(const H5D_chunk_map_t *fm);
@@ -313,6 +315,7 @@ const H5D_layout_ops_t H5D_LOPS_CHUNK[1] = {{
H5D__chunk_construct,
H5D__chunk_init,
H5D__chunk_is_space_alloc,
+ H5D__chunk_is_data_cached,
H5D__chunk_io_init,
H5D__chunk_read,
H5D__chunk_write,
@@ -340,6 +343,7 @@ const H5D_layout_ops_t H5D_LOPS_NONEXISTENT[1] = {{
NULL,
NULL,
NULL,
+ NULL,
#ifdef H5_HAVE_PARALLEL
NULL,
NULL,
@@ -394,10 +398,13 @@ H5D__chunk_direct_write(const H5D_t *dset, uint32_t filters, hsize_t *offset,
FUNC_ENTER_PACKAGE_TAG(dset->oloc.addr)
+ /* Sanity checks */
+ HDassert(layout->type == H5D_CHUNKED);
+
io_info.dset = dset;
/* Allocate dataspace and initialize it if it hasn't been. */
- if(!(*layout->ops->is_space_alloc)(&layout->storage))
+ if(!H5D__chunk_is_space_alloc(&layout->storage))
/* Allocate storage */
if(H5D__alloc_storage(&io_info, H5D_ALLOC_WRITE, FALSE, NULL) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize storage")
@@ -435,13 +442,17 @@ H5D__chunk_direct_write(const H5D_t *dset, uint32_t filters, hsize_t *offset,
if(0 == idx_info.pline->nused && H5F_addr_defined(old_chunk.offset))
/* If there are no filters and we are overwriting the chunk we can just set values */
need_insert = FALSE;
- else
+ else {
/* Otherwise, create the chunk it if it doesn't exist, or reallocate the chunk
* if its size has changed.
*/
if(H5D__chunk_file_alloc(&idx_info, &old_chunk, &udata.chunk_block, &need_insert, scaled) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "unable to allocate chunk")
+ /* Cache the new chunk information */
+ H5D__chunk_cinfo_cache_update(&dset->shared->cache.chunk.last, &udata);
+ } /* end else */
+
/* Make sure the address of the chunk is returned. */
if(!H5F_addr_defined(udata.chunk_block.offset))
HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "chunk address isn't defined")
@@ -506,7 +517,8 @@ H5D__chunk_direct_read(const H5D_t *dset, hsize_t *offset, uint32_t* filters,
*filters = 0;
/* Allocate dataspace and initialize it if it hasn't been. */
- if(!(*layout->ops->is_space_alloc)(&layout->storage))
+ if(!H5D__chunk_is_space_alloc(&layout->storage)
+ && !H5D__chunk_is_data_cached(dset->shared))
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "storage is not initialized")
/* Calculate the index of this chunk */
@@ -695,15 +707,18 @@ H5D__chunk_set_info_real(H5O_layout_chunk_t *layout, unsigned ndims,
/* Compute the # of chunks in dataset dimensions */
for(u = 0, layout->nchunks = 1, layout->max_nchunks = 1; u < ndims; u++) {
- /* Sanity check */
- HDassert(layout->dim[u] > 0);
-
/* Round up to the next integer # of chunks, to accommodate partial chunks */
layout->chunks[u] = ((curr_dims[u] + layout->dim[u]) - 1) / layout->dim[u];
if(H5S_UNLIMITED == max_dims[u])
layout->max_chunks[u] = H5S_UNLIMITED;
else
+ {
+ /* Sanity check */
+ if(layout->dim[u] == 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "dimension size must be > 0, dim = %u ", u)
+
layout->max_chunks[u] = ((max_dims[u] + layout->dim[u]) - 1) / layout->dim[u];
+ }
/* Accumulate the # of chunks */
layout->nchunks *= layout->chunks[u];
@@ -1019,6 +1034,30 @@ H5D__chunk_is_space_alloc(const H5O_storage_t *storage)
/*-------------------------------------------------------------------------
+ * Function: H5D__chunk_is_data_cached
+ *
+ * Purpose: Query if raw data is cached for dataset
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Neil Fortner
+ * Wednessday, March 6, 2016
+ *
+ *-------------------------------------------------------------------------
+ */
+hbool_t
+H5D__chunk_is_data_cached(const H5D_shared_t *shared_dset)
+{
+ FUNC_ENTER_PACKAGE_NOERR
+
+ /* Sanity checks */
+ HDassert(shared_dset);
+
+ FUNC_LEAVE_NOAPI(shared_dset->cache.chunk.nused > 0)
+} /* end H5D__chunk_is_data_cached() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5D__chunk_io_init
*
* Purpose: Performs initialization before any sort of I/O on the raw data
@@ -1044,7 +1083,6 @@ H5D__chunk_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf
hbool_t iter_init = FALSE; /* Selection iteration info has been initialized */
unsigned f_ndims; /* The number of dimensions of the file's dataspace */
int sm_ndims; /* The number of dimensions of the memory buffer's dataspace (signed) */
- H5SL_node_t *curr_node; /* Current node in skip list */
char bogus; /* "bogus" buffer to pass to selection iterator */
unsigned u; /* Local index variable */
herr_t ret_value = SUCCEED; /* Return value */
@@ -1073,21 +1111,19 @@ H5D__chunk_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf
if((file_space_normalized = H5S_hyper_normalize_offset((H5S_t *)file_space, old_offset)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to normalize selection")
- /* Decide the number of chunks in each dimension*/
- for(u = 0; u < f_ndims; u++) {
+ /* Decide the number of chunks in each dimension */
+ for(u = 0; u < f_ndims; u++)
/* Keep the size of the chunk dimensions as hsize_t for various routines */
fm->chunk_dim[u] = fm->layout->u.chunk.dim[u];
- } /* end for */
#ifdef H5_HAVE_PARALLEL
/* Calculate total chunk in file map*/
fm->select_chunk = NULL;
if(io_info->using_mpi_vfd) {
H5_CHECK_OVERFLOW(fm->layout->u.chunk.nchunks, hsize_t, size_t);
- if(fm->layout->u.chunk.nchunks) {
+ if(fm->layout->u.chunk.nchunks)
if(NULL == (fm->select_chunk = (H5D_chunk_info_t **)H5MM_calloc((size_t)fm->layout->u.chunk.nchunks * sizeof(H5D_chunk_info_t *))))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate chunk info")
- }
} /* end if */
#endif /* H5_HAVE_PARALLEL */
@@ -1129,10 +1165,9 @@ H5D__chunk_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf
HDassert(fm->single_space);
/* Allocate the single chunk information */
- if(NULL == dataset->shared->cache.chunk.single_chunk_info) {
+ if(NULL == dataset->shared->cache.chunk.single_chunk_info)
if(NULL == (dataset->shared->cache.chunk.single_chunk_info = H5FL_MALLOC(H5D_chunk_info_t)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate chunk info")
- } /* end if */
fm->single_chunk_info = dataset->shared->cache.chunk.single_chunk_info;
HDassert(fm->single_chunk_info);
@@ -1147,10 +1182,9 @@ H5D__chunk_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf
hbool_t sel_hyper_flag; /* Whether file selection is a hyperslab */
/* Initialize skip list for chunk selections */
- if(NULL == dataset->shared->cache.chunk.sel_chunks) {
+ if(NULL == dataset->shared->cache.chunk.sel_chunks)
if(NULL == (dataset->shared->cache.chunk.sel_chunks = H5SL_create(H5SL_TYPE_HSIZE, NULL)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTCREATE, FAIL, "can't create skip list for chunk selections")
- } /* end if */
fm->sel_chunks = dataset->shared->cache.chunk.sel_chunks;
HDassert(fm->sel_chunks);
@@ -1172,25 +1206,17 @@ H5D__chunk_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf
/* Check if file selection is a not a hyperslab selection */
if(sel_hyper_flag) {
/* Build the file selection for each chunk */
- if(H5D__create_chunk_file_map_hyper(fm, io_info) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create file chunk selections")
-
- /* Clean file chunks' hyperslab span "scratch" information */
- curr_node = H5SL_first(fm->sel_chunks);
- while(curr_node) {
- H5D_chunk_info_t *chunk_info; /* Pointer chunk information */
-
- /* Get pointer to chunk's information */
- chunk_info = (H5D_chunk_info_t *)H5SL_item(curr_node);
- HDassert(chunk_info);
-
- /* Clean hyperslab span's "scratch" information */
- if(H5S_hyper_reset_scratch(chunk_info->fspace) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to reset span scratch info")
+ if(H5S_SEL_ALL == fm->fsel_type) {
+ if(H5D__create_chunk_file_map_all(fm, io_info) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create file chunk selections")
+ } /* end if */
+ else {
+ /* Sanity check */
+ HDassert(fm->fsel_type == H5S_SEL_HYPERSLABS);
- /* Get the next chunk node in the skip list */
- curr_node = H5SL_next(curr_node);
- } /* end while */
+ if(H5D__create_chunk_file_map_hyper(fm, io_info) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create file chunk selections")
+ } /* end else */
} /* end if */
else {
H5S_sel_iter_op_t iter_op; /* Operator for iteration */
@@ -1245,15 +1271,14 @@ H5D__chunk_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf
fm->mchunk_tmpl = tmp_mspace;
/* Create temporary datatypes for selection iteration */
- if(!file_type) {
+ if(!file_type)
if(NULL == (file_type = H5T_copy(dataset->shared->type, H5T_COPY_ALL)))
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "unable to copy file datatype")
- } /* end if */
/* Create selection iterator for memory selection */
if(0 == (elmt_size = H5T_get_size(mem_type)))
HGOTO_ERROR(H5E_DATATYPE, H5E_BADSIZE, FAIL, "datatype size invalid")
- if(H5S_select_iter_init(&(fm->mem_iter), mem_space, elmt_size) < 0)
+ if(H5S_select_iter_init(&(fm->mem_iter), mem_space, elmt_size, 0) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator")
iter_init = TRUE; /* Selection iteration info has been initialized */
@@ -1263,26 +1288,6 @@ H5D__chunk_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf
/* Spaces aren't the same shape, iterate over the memory selection directly */
if(H5S_select_iterate(&bogus, file_type, file_space, &iter_op, fm) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create memory chunk selections")
-
- /* Clean up hyperslab stuff, if necessary */
- if(fm->msel_type != H5S_SEL_POINTS) {
- /* Clean memory chunks' hyperslab span "scratch" information */
- curr_node = H5SL_first(fm->sel_chunks);
- while(curr_node) {
- H5D_chunk_info_t *chunk_info; /* Pointer chunk information */
-
- /* Get pointer to chunk's information */
- chunk_info = (H5D_chunk_info_t *)H5SL_item(curr_node);
- HDassert(chunk_info);
-
- /* Clean hyperslab span's "scratch" information */
- if(H5S_hyper_reset_scratch(chunk_info->mspace) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to reset span scratch info")
-
- /* Get the next chunk node in the skip list */
- curr_node = H5SL_next(curr_node);
- } /* end while */
- } /* end if */
} /* end else */
} /* end else */
@@ -1538,9 +1543,214 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5D__create_chunk_file_map_all
+ *
+ * Purpose: Create all chunk selections in file, for an "all" selection.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * Monday, January 21, 2019
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5D__create_chunk_file_map_all(H5D_chunk_map_t *fm, const H5D_io_info_t
+#ifndef H5_HAVE_PARALLEL
+ H5_ATTR_UNUSED
+#endif /* H5_HAVE_PARALLEL */
+ *io_info)
+{
+ H5S_t *tmp_fchunk = NULL; /* Temporary file dataspace */
+ hsize_t file_dims[H5S_MAX_RANK]; /* File dataspace dims */
+ hsize_t sel_points; /* Number of elements in file selection */
+ hsize_t zeros[H5S_MAX_RANK]; /* All zero vector (for start parameter to setting hyperslab on partial chunks) */
+ hsize_t coords[H5S_MAX_RANK]; /* Current coordinates of chunk */
+ hsize_t end[H5S_MAX_RANK]; /* Final coordinates of chunk */
+ hsize_t scaled[H5S_MAX_RANK]; /* Scaled coordinates for this chunk */
+ hsize_t chunk_index; /* "Index" of chunk */
+ hsize_t curr_partial_clip[H5S_MAX_RANK]; /* Current partial dimension sizes to clip against */
+ hsize_t partial_dim_size[H5S_MAX_RANK]; /* Size of a partial dimension */
+ hbool_t is_partial_dim[H5S_MAX_RANK]; /* Whether a dimension is currently a partial chunk */
+ unsigned num_partial_dims; /* Current number of partial dimensions */
+ unsigned u; /* Local index variable */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_STATIC
+
+ /* Sanity check */
+ HDassert(fm->f_ndims > 0);
+
+ /* Get number of elements selected in file */
+ sel_points = fm->nelmts;
+
+ /* Get dataspace dimensions */
+ if(H5S_get_simple_extent_dims(fm->file_space, file_dims, NULL) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get file selection bound info")
+
+ /* Set initial chunk location, partial dimensions, etc */
+ num_partial_dims = 0;
+ HDmemset(zeros, 0, sizeof(zeros));
+ for(u = 0; u < fm->f_ndims; u++) {
+ /* Validate this chunk dimension */
+ if(fm->layout->u.chunk.dim[u] == 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "chunk size must be > 0, dim = %u ", u)
+
+ /* Set up start / end coordinates for first chunk */
+ scaled[u] = 0;
+ coords[u] = 0;
+ end[u] = fm->chunk_dim[u] - 1;
+
+ /* Iniitialize partial chunk dimension information */
+ partial_dim_size[u] = file_dims[u] % fm->chunk_dim[u];
+ if(file_dims[u] < fm->chunk_dim[u]) {
+ curr_partial_clip[u] = partial_dim_size[u];
+ is_partial_dim[u] = TRUE;
+ num_partial_dims++;
+ } /* end if */
+ else {
+ curr_partial_clip[u] = fm->chunk_dim[u];
+ is_partial_dim[u] = FALSE;
+ } /* end else */
+ } /* end for */
+
+ /* Set the index of this chunk */
+ chunk_index = 0;
+
+ /* Create "temporary" chunk for selection operations (copy file space) */
+ if(NULL == (tmp_fchunk = H5S_create_simple(fm->f_ndims, fm->chunk_dim, NULL)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTCREATE, FAIL, "unable to create dataspace for chunk")
+
+ /* Iterate through each chunk in the dataset */
+ while(sel_points) {
+ H5D_chunk_info_t *new_chunk_info; /* chunk information to insert into skip list */
+ hssize_t schunk_points; /* Number of elements in chunk selection */
+
+ /* Add temporary chunk to the list of chunks */
+
+ /* Allocate the file & memory chunk information */
+ if(NULL == (new_chunk_info = H5FL_MALLOC(H5D_chunk_info_t)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate chunk info")
+
+ /* Initialize the chunk information */
+
+ /* Set the chunk index */
+ new_chunk_info->index = chunk_index;
+
+#ifdef H5_HAVE_PARALLEL
+ /* Store chunk selection information, for multi-chunk I/O */
+ if(io_info->using_mpi_vfd)
+ fm->select_chunk[chunk_index] = new_chunk_info;
+#endif /* H5_HAVE_PARALLEL */
+
+ /* Set the file chunk dataspace */
+ if(NULL == (new_chunk_info->fspace = H5S_copy(tmp_fchunk, TRUE, FALSE)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy chunk dataspace")
+ new_chunk_info->fspace_shared = FALSE;
+
+ /* If there are partial dimensions for this chunk, set the hyperslab for them */
+ if(num_partial_dims > 0)
+ if(H5S_select_hyperslab(new_chunk_info->fspace, H5S_SELECT_SET, zeros, NULL, curr_partial_clip, NULL) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTSELECT, FAIL, "can't create chunk selection")
+
+ /* Set the memory chunk dataspace */
+ new_chunk_info->mspace = NULL;
+ new_chunk_info->mspace_shared = FALSE;
+
+ /* Copy the chunk's scaled coordinates */
+ H5MM_memcpy(new_chunk_info->scaled, scaled, sizeof(hsize_t) * fm->f_ndims);
+ new_chunk_info->scaled[fm->f_ndims] = 0;
+
+ /* Insert the new chunk into the skip list */
+ if(H5SL_insert(fm->sel_chunks, new_chunk_info, &new_chunk_info->index) < 0) {
+ H5D__free_chunk_info(new_chunk_info, NULL, NULL);
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert chunk into skip list")
+ } /* end if */
+
+ /* Get number of elements selected in chunk */
+ if((schunk_points = H5S_GET_SELECT_NPOINTS(new_chunk_info->fspace)) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get file selection # of elements")
+ H5_CHECKED_ASSIGN(new_chunk_info->chunk_points, uint32_t, schunk_points, hssize_t);
+
+ /* Decrement # of points left in file selection */
+ sel_points -= (hsize_t)schunk_points;
+
+ /* Advance to next chunk if we are not done */
+ if(sel_points > 0) {
+ int curr_dim; /* Current dimension to increment */
+
+ /* Increment chunk index */
+ chunk_index++;
+
+ /* Set current increment dimension */
+ curr_dim = (int)fm->f_ndims - 1;
+
+ /* Increment chunk location in fastest changing dimension */
+ coords[curr_dim] += fm->chunk_dim[curr_dim];
+ scaled[curr_dim]++;
+ end[curr_dim] += fm->chunk_dim[curr_dim];
+
+ /* Bring chunk location back into bounds, if necessary */
+ if(coords[curr_dim] >= file_dims[curr_dim]) {
+ do {
+ /* Reset current dimension's location to 0 */
+ coords[curr_dim] = 0;
+ scaled[curr_dim] = 0;
+ end[curr_dim] = fm->chunk_dim[curr_dim] - 1;
+
+ /* Check for previous partial chunk in this dimension */
+ if(is_partial_dim[curr_dim] && end[curr_dim] < file_dims[curr_dim]) {
+ /* Sanity check */
+ HDassert(num_partial_dims > 0);
+
+ /* Reset partial chunk information for this dimension */
+ curr_partial_clip[curr_dim] = fm->chunk_dim[curr_dim];
+ is_partial_dim[curr_dim] = FALSE;
+ num_partial_dims--;
+ } /* end if */
+
+ /* Decrement current dimension */
+ curr_dim--;
+
+ /* Check for valid current dim */
+ if(curr_dim >= 0) {
+ /* Increment chunk location in current dimension */
+ coords[curr_dim] += fm->chunk_dim[curr_dim];
+ scaled[curr_dim]++;
+ end[curr_dim] = (coords[curr_dim] + fm->chunk_dim[curr_dim]) - 1;
+ } /* end if */
+ } while(curr_dim >= 0 && (coords[curr_dim] >= file_dims[curr_dim]));
+ } /* end if */
+
+ /* Check for valid current dim */
+ if(curr_dim >= 0) {
+ /* Check for partial chunk in this dimension */
+ if(!is_partial_dim[curr_dim] && file_dims[curr_dim] <= end[curr_dim]) {
+ /* Set partial chunk information for this dimension */
+ curr_partial_clip[curr_dim] = partial_dim_size[curr_dim];
+ is_partial_dim[curr_dim] = TRUE;
+ num_partial_dims++;
+
+ /* Sanity check */
+ HDassert(num_partial_dims <= fm->f_ndims);
+ } /* end if */
+ } /* end if */
+ } /* end if */
+ } /* end while */
+
+done:
+ /* Clean up */
+ if(tmp_fchunk && H5S_close(tmp_fchunk) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't release temporary dataspace")
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5D__create_chunk_file_map_all() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5D__create_chunk_file_map_hyper
*
- * Purpose: Create all chunk selections in file.
+ * Purpose: Create all chunk selections in file, for a hyperslab selection.
*
* Return: Non-negative on success/Negative on failure
*
@@ -1556,8 +1766,9 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t
#endif /* H5_HAVE_PARALLEL */
*io_info)
{
- hsize_t sel_start[H5O_LAYOUT_NDIMS]; /* Offset of low bound of file selection */
- hsize_t sel_end[H5O_LAYOUT_NDIMS]; /* Offset of high bound of file selection */
+ H5S_t *tmp_fchunk = NULL; /* Temporary file dataspace */
+ hsize_t sel_start[H5O_LAYOUT_NDIMS]; /* Offset of low bound of file selection */
+ hsize_t sel_end[H5O_LAYOUT_NDIMS]; /* Offset of high bound of file selection */
hsize_t sel_points; /* Number of elements in file selection */
hsize_t start_coords[H5O_LAYOUT_NDIMS]; /* Starting coordinates of selection */
hsize_t coords[H5O_LAYOUT_NDIMS]; /* Current coordinates of chunk */
@@ -1572,7 +1783,7 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t
FUNC_ENTER_STATIC
/* Sanity check */
- HDassert(fm->f_ndims>0);
+ HDassert(fm->f_ndims > 0);
/* Get number of elements selected in file */
sel_points = fm->nelmts;
@@ -1596,53 +1807,36 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t
/* Iterate through each chunk in the dataset */
while(sel_points) {
- /* Check for intersection of temporary chunk and file selection */
+ /* Check for intersection of current chunk and file selection */
/* (Casting away const OK - QAK) */
if(TRUE == H5S_hyper_intersect_block((H5S_t *)fm->file_space, coords, end)) {
- H5S_t *tmp_fchunk; /* Temporary file dataspace */
H5D_chunk_info_t *new_chunk_info; /* chunk information to insert into skip list */
hssize_t schunk_points; /* Number of elements in chunk selection */
- /* Create "temporary" chunk for selection operations (copy file space) */
- if(NULL == (tmp_fchunk = H5S_copy(fm->file_space, TRUE, FALSE)))
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy memory space")
-
- /* Make certain selections are stored in span tree form (not "optimized hyperslab" or "all") */
- if(H5S_hyper_convert(tmp_fchunk) < 0) {
- (void)H5S_close(tmp_fchunk);
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to convert selection to span trees")
- } /* end if */
-
- /* "AND" temporary chunk and current chunk */
- if(H5S_select_hyperslab(tmp_fchunk,H5S_SELECT_AND,coords,NULL,fm->chunk_dim,NULL) < 0) {
- (void)H5S_close(tmp_fchunk);
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't create chunk selection")
- } /* end if */
+ /* Create dataspace for chunk, 'AND'ing the overall selection with
+ * the current chunk.
+ */
+ if(H5S_combine_hyperslab(fm->file_space, H5S_SELECT_AND, coords, NULL, fm->chunk_dim, NULL, &tmp_fchunk) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to combine file space selection with chunk block")
/* Resize chunk's dataspace dimensions to size of chunk */
- if(H5S_set_extent_real(tmp_fchunk,fm->chunk_dim) < 0) {
- (void)H5S_close(tmp_fchunk);
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't adjust chunk dimensions")
- } /* end if */
+ if(H5S_set_extent_real(tmp_fchunk, fm->chunk_dim) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTSELECT, FAIL, "can't adjust chunk dimensions")
/* Move selection back to have correct offset in chunk */
- if(H5S_SELECT_ADJUST_U(tmp_fchunk, coords) < 0) {
- (void)H5S_close(tmp_fchunk);
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't adjust chunk selection")
- }
+ if(H5S_SELECT_ADJUST_U(tmp_fchunk, coords) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTSELECT, FAIL, "can't adjust chunk selection")
/* Add temporary chunk to the list of chunks */
/* Allocate the file & memory chunk information */
- if (NULL==(new_chunk_info = H5FL_MALLOC(H5D_chunk_info_t))) {
- (void)H5S_close(tmp_fchunk);
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate chunk info")
- } /* end if */
+ if(NULL == (new_chunk_info = H5FL_MALLOC(H5D_chunk_info_t)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate chunk info")
/* Initialize the chunk information */
/* Set the chunk index */
- new_chunk_info->index=chunk_index;
+ new_chunk_info->index = chunk_index;
#ifdef H5_HAVE_PARALLEL
/* Store chunk selection information, for multi-chunk I/O */
@@ -1653,18 +1847,16 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t
/* Set the file chunk dataspace */
new_chunk_info->fspace = tmp_fchunk;
new_chunk_info->fspace_shared = FALSE;
+ tmp_fchunk = NULL;
/* Set the memory chunk dataspace */
- new_chunk_info->mspace=NULL;
+ new_chunk_info->mspace = NULL;
new_chunk_info->mspace_shared = FALSE;
/* Copy the chunk's scaled coordinates */
- HDmemcpy(new_chunk_info->scaled, scaled, sizeof(hsize_t) * fm->f_ndims);
+ H5MM_memcpy(new_chunk_info->scaled, scaled, sizeof(hsize_t) * fm->f_ndims);
new_chunk_info->scaled[fm->f_ndims] = 0;
- /* Copy the chunk's scaled coordinates */
- HDmemcpy(new_chunk_info->scaled, scaled, sizeof(hsize_t) * fm->f_ndims);
-
/* Insert the new chunk into the skip list */
if(H5SL_insert(fm->sel_chunks, new_chunk_info, &new_chunk_info->index) < 0) {
H5D__free_chunk_info(new_chunk_info, NULL, NULL);
@@ -1672,7 +1864,7 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t
} /* end if */
/* Get number of elements selected in chunk */
- if((schunk_points = H5S_GET_SELECT_NPOINTS(tmp_fchunk)) < 0)
+ if((schunk_points = H5S_GET_SELECT_NPOINTS(new_chunk_info->fspace)) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get file selection # of elements")
H5_CHECKED_ASSIGN(new_chunk_info->chunk_points, uint32_t, schunk_points, hssize_t);
@@ -1688,12 +1880,11 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t
chunk_index++;
/* Set current increment dimension */
- curr_dim=(int)fm->f_ndims-1;
+ curr_dim = (int)fm->f_ndims - 1;
/* Increment chunk location in fastest changing dimension */
- H5_CHECK_OVERFLOW(fm->chunk_dim[curr_dim],hsize_t,hssize_t);
- coords[curr_dim]+=fm->chunk_dim[curr_dim];
- end[curr_dim]+=fm->chunk_dim[curr_dim];
+ coords[curr_dim] += fm->chunk_dim[curr_dim];
+ end[curr_dim] += fm->chunk_dim[curr_dim];
scaled[curr_dim]++;
/* Bring chunk location back into bounds, if necessary */
@@ -1707,11 +1898,14 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t
/* Decrement current dimension */
curr_dim--;
- /* Increment chunk location in current dimension */
- scaled[curr_dim]++;
- coords[curr_dim] += fm->chunk_dim[curr_dim];
- end[curr_dim] = (coords[curr_dim] + fm->chunk_dim[curr_dim]) - 1;
- } while(coords[curr_dim] > sel_end[curr_dim]);
+ /* Check for valid current dim */
+ if(curr_dim >= 0) {
+ /* Increment chunk location in current dimension */
+ scaled[curr_dim]++;
+ coords[curr_dim] += fm->chunk_dim[curr_dim];
+ end[curr_dim] = (coords[curr_dim] + fm->chunk_dim[curr_dim]) - 1;
+ } /* end if */
+ } while(curr_dim >= 0 && (coords[curr_dim] > sel_end[curr_dim]));
/* Re-calculate the index of this chunk */
chunk_index = H5VM_array_offset_pre(fm->f_ndims, fm->layout->u.chunk.down_chunks, scaled);
@@ -1719,6 +1913,11 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t
} /* end while */
done:
+ /* Clean up on failure */
+ if(ret_value < 0)
+ if(tmp_fchunk && H5S_close(tmp_fchunk) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't release temporary dataspace")
+
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__create_chunk_file_map_hyper() */
@@ -1742,13 +1941,13 @@ done:
static herr_t
H5D__create_chunk_mem_map_hyper(const H5D_chunk_map_t *fm)
{
+ H5D_chunk_info_t *chunk_info; /* Pointer to chunk information */
H5SL_node_t *curr_node; /* Current node in skip list */
- hsize_t file_sel_start[H5O_LAYOUT_NDIMS]; /* Offset of low bound of file selection */
- hsize_t file_sel_end[H5O_LAYOUT_NDIMS]; /* Offset of high bound of file selection */
- hsize_t mem_sel_start[H5O_LAYOUT_NDIMS]; /* Offset of low bound of file selection */
- hsize_t mem_sel_end[H5O_LAYOUT_NDIMS]; /* Offset of high bound of file selection */
- hssize_t adjust[H5O_LAYOUT_NDIMS]; /* Adjustment to make to all file chunks */
- hssize_t chunk_adjust[H5O_LAYOUT_NDIMS]; /* Adjustment to make to a particular chunk */
+ hsize_t file_sel_start[H5S_MAX_RANK]; /* Offset of low bound of file selection */
+ hsize_t file_sel_end[H5S_MAX_RANK]; /* Offset of high bound of file selection */
+ hsize_t mem_sel_start[H5S_MAX_RANK]; /* Offset of low bound of file selection */
+ hsize_t mem_sel_end[H5S_MAX_RANK]; /* Offset of high bound of file selection */
+ hssize_t adjust[H5S_MAX_RANK]; /* Adjustment to make to all file chunks */
unsigned u; /* Local index variable */
herr_t ret_value = SUCCEED; /* Return value */
@@ -1759,10 +1958,8 @@ H5D__create_chunk_mem_map_hyper(const H5D_chunk_map_t *fm)
/* Check for all I/O going to a single chunk */
if(H5SL_count(fm->sel_chunks)==1) {
- H5D_chunk_info_t *chunk_info; /* Pointer to chunk information */
-
/* Get the node */
- curr_node=H5SL_first(fm->sel_chunks);
+ curr_node = H5SL_first(fm->sel_chunks);
/* Get pointer to chunk's information */
chunk_info = (H5D_chunk_info_t *)H5SL_item(curr_node);
@@ -1785,54 +1982,74 @@ H5D__create_chunk_mem_map_hyper(const H5D_chunk_map_t *fm)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get file selection bound info")
/* Calculate the adjustment for memory selection from file selection */
- HDassert(fm->m_ndims==fm->f_ndims);
- for(u=0; u<fm->f_ndims; u++) {
- H5_CHECK_OVERFLOW(file_sel_start[u],hsize_t,hssize_t);
- H5_CHECK_OVERFLOW(mem_sel_start[u],hsize_t,hssize_t);
- adjust[u]=(hssize_t)file_sel_start[u]-(hssize_t)mem_sel_start[u];
+ HDassert(fm->m_ndims == fm->f_ndims);
+ for(u = 0; u < fm->f_ndims; u++) {
+ H5_CHECK_OVERFLOW(file_sel_start[u], hsize_t, hssize_t);
+ H5_CHECK_OVERFLOW(mem_sel_start[u], hsize_t, hssize_t);
+ adjust[u] = (hssize_t)file_sel_start[u] - (hssize_t)mem_sel_start[u];
} /* end for */
/* Iterate over each chunk in the chunk list */
- curr_node=H5SL_first(fm->sel_chunks);
+ curr_node = H5SL_first(fm->sel_chunks);
while(curr_node) {
- H5D_chunk_info_t *chunk_info; /* Pointer to chunk information */
+ hsize_t coords[H5S_MAX_RANK]; /* Current coordinates of chunk */
+ hssize_t chunk_adjust[H5S_MAX_RANK]; /* Adjustment to make to a particular chunk */
+ H5S_sel_type chunk_sel_type; /* Chunk's selection type */
/* Get pointer to chunk's information */
chunk_info = (H5D_chunk_info_t *)H5SL_item(curr_node);
HDassert(chunk_info);
+ /* Compute the chunk coordinates from the scaled coordinates */
+ for(u = 0; u < fm->f_ndims; u++)
+ coords[u] = chunk_info->scaled[u] * fm->layout->u.chunk.dim[u];
+
/* Copy the information */
/* Copy the memory dataspace */
if((chunk_info->mspace = H5S_copy(fm->mem_space, TRUE, FALSE)) == NULL)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy memory space")
- /* Release the current selection */
- if(H5S_SELECT_RELEASE(chunk_info->mspace) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection")
+ /* Get the chunk's selection type */
+ if((chunk_sel_type = H5S_GET_SELECT_TYPE(chunk_info->fspace)) < H5S_SEL_NONE)
+ HGOTO_ERROR(H5E_DATASET, H5E_BADSELECT, FAIL, "unable to get type of selection")
+
+ /* Set memory selection for "all" chunk selections */
+ if(H5S_SEL_ALL == chunk_sel_type) {
+ /* Adjust the chunk coordinates */
+ for(u = 0; u < fm->f_ndims; u++)
+ coords[u] -= adjust[u];
- /* Copy the file chunk's selection */
- if(H5S_select_copy(chunk_info->mspace,chunk_info->fspace,FALSE) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy selection")
+ /* Set to same shape as chunk */
+ if(H5S_select_hyperslab(chunk_info->mspace, H5S_SELECT_SET, coords, NULL, fm->chunk_dim, NULL) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTSELECT, FAIL, "can't create chunk memory selection")
+ } /* end if */
+ else {
+ /* Sanity check */
+ HDassert(H5S_SEL_HYPERSLABS == chunk_sel_type);
- /* Compute the adjustment for this chunk */
- for(u = 0; u < fm->f_ndims; u++) {
- hsize_t coords[H5O_LAYOUT_NDIMS]; /* Current coordinates of chunk */
+ /* Release the current selection */
+ if(H5S_SELECT_RELEASE(chunk_info->mspace) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection")
- /* Compute the chunk coordinates from the scaled coordinates */
- coords[u] = chunk_info->scaled[u] * fm->layout->u.chunk.dim[u];
+ /* Copy the file chunk's selection */
+ if(H5S_select_copy(chunk_info->mspace, chunk_info->fspace, FALSE) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy selection")
- /* Compensate for the chunk offset */
- H5_CHECK_OVERFLOW(coords[u], hsize_t, hssize_t);
- chunk_adjust[u] = adjust[u] - (hssize_t)coords[u]; /*lint !e771 The adjust array will always be initialized */
- } /* end for */
+ /* Compute the adjustment for this chunk */
+ for(u = 0; u < fm->f_ndims; u++) {
+ /* Compensate for the chunk offset */
+ H5_CHECK_OVERFLOW(coords[u], hsize_t, hssize_t);
+ chunk_adjust[u] = adjust[u] - (hssize_t)coords[u]; /*lint !e771 The adjust array will always be initialized */
+ } /* end for */
- /* Adjust the selection */
- if(H5S_hyper_adjust_s(chunk_info->mspace, chunk_adjust) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to adjust selection")
+ /* Adjust the selection */
+ if(H5S_hyper_adjust_s(chunk_info->mspace, chunk_adjust) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to adjust selection")
+ } /* end else */
/* Get the next chunk node in the skip list */
- curr_node=H5SL_next(curr_node);
+ curr_node = H5SL_next(curr_node);
} /* end while */
} /* end else */
@@ -1920,9 +2137,9 @@ H5D__chunk_file_cb(void H5_ATTR_UNUSED *elem, const H5T_t H5_ATTR_UNUSED *type,
chunk_info->chunk_points = 0;
/* Set the chunk's scaled coordinates */
- HDmemcpy(chunk_info->scaled, scaled, sizeof(hsize_t) * fm->f_ndims);
+ H5MM_memcpy(chunk_info->scaled, scaled, sizeof(hsize_t) * fm->f_ndims);
chunk_info->scaled[fm->f_ndims] = 0;
- HDmemcpy(chunk_info->scaled, scaled, sizeof(hsize_t) * fm->f_ndims);
+ H5MM_memcpy(chunk_info->scaled, scaled, sizeof(hsize_t) * fm->f_ndims);
/* Insert the new chunk into the skip list */
if(H5SL_insert(fm->sel_chunks,chunk_info,&chunk_info->index) < 0) {
@@ -1976,7 +2193,7 @@ H5D__chunk_mem_cb(void H5_ATTR_UNUSED *elem, const H5T_t H5_ATTR_UNUSED *type, u
{
H5D_chunk_map_t *fm = (H5D_chunk_map_t *)_fm; /* File<->memory chunk mapping info */
H5D_chunk_info_t *chunk_info; /* Chunk information for current chunk */
- hsize_t coords_in_mem[H5O_LAYOUT_NDIMS]; /* Coordinates of element in memory */
+ hsize_t coords_in_mem[H5S_MAX_RANK]; /* Coordinates of element in memory */
hsize_t chunk_index; /* Chunk index */
herr_t ret_value = SUCCEED; /* Return value */
@@ -2001,11 +2218,10 @@ H5D__chunk_mem_cb(void H5_ATTR_UNUSED *elem, const H5T_t H5_ATTR_UNUSED *type, u
HGOTO_ERROR(H5E_DATASPACE, H5E_NOTFOUND, H5_ITER_ERROR, "can't locate chunk in skip list")
/* Check if the chunk already has a memory space */
- if(NULL == chunk_info->mspace) {
+ if(NULL == chunk_info->mspace)
/* Copy the template memory chunk dataspace */
if(NULL == (chunk_info->mspace = H5S_copy(fm->mchunk_tmpl, FALSE, FALSE)))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, H5_ITER_ERROR, "unable to copy file space")
- } /* end else */
/* Update the "last chunk seen" information */
fm->last_index = chunk_index;
@@ -2164,11 +2380,11 @@ H5D__chunk_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info,
HDassert(fm);
/* Set up "nonexistent" I/O info object */
- HDmemcpy(&nonexistent_io_info, io_info, sizeof(nonexistent_io_info));
+ H5MM_memcpy(&nonexistent_io_info, io_info, sizeof(nonexistent_io_info));
nonexistent_io_info.layout_ops = *H5D_LOPS_NONEXISTENT;
/* Set up contiguous I/O info object */
- HDmemcpy(&ctg_io_info, io_info, sizeof(ctg_io_info));
+ H5MM_memcpy(&ctg_io_info, io_info, sizeof(ctg_io_info));
ctg_io_info.store = &ctg_store;
ctg_io_info.layout_ops = *H5D_LOPS_CONTIG;
@@ -2176,7 +2392,7 @@ H5D__chunk_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info,
H5_CHECKED_ASSIGN(ctg_store.contig.dset_size, hsize_t, io_info->dset->shared->layout.u.chunk.size, uint32_t);
/* Set up compact I/O info object */
- HDmemcpy(&cpt_io_info, io_info, sizeof(cpt_io_info));
+ H5MM_memcpy(&cpt_io_info, io_info, sizeof(cpt_io_info));
cpt_io_info.store = &cpt_store;
cpt_io_info.layout_ops = *H5D_LOPS_COMPACT;
@@ -2314,7 +2530,7 @@ H5D__chunk_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info,
HDassert(fm);
/* Set up contiguous I/O info object */
- HDmemcpy(&ctg_io_info, io_info, sizeof(ctg_io_info));
+ H5MM_memcpy(&ctg_io_info, io_info, sizeof(ctg_io_info));
ctg_io_info.store = &ctg_store;
ctg_io_info.layout_ops = *H5D_LOPS_CONTIG;
@@ -2322,7 +2538,7 @@ H5D__chunk_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info,
H5_CHECKED_ASSIGN(ctg_store.contig.dset_size, hsize_t, io_info->dset->shared->layout.u.chunk.size, uint32_t);
/* Set up compact I/O info object */
- HDmemcpy(&cpt_io_info, io_info, sizeof(cpt_io_info));
+ H5MM_memcpy(&cpt_io_info, io_info, sizeof(cpt_io_info));
cpt_io_info.store = &cpt_store;
cpt_io_info.layout_ops = *H5D_LOPS_COMPACT;
@@ -2677,7 +2893,7 @@ H5D__chunk_cinfo_cache_update(H5D_chunk_cached_t *last, const H5D_chunk_ud_t *ud
HDassert(udata->common.scaled);
/* Stored the information to cache */
- HDmemcpy(last->scaled, udata->common.scaled, sizeof(hsize_t) * udata->common.layout->ndims);
+ H5MM_memcpy(last->scaled, udata->common.scaled, sizeof(hsize_t) * udata->common.layout->ndims);
last->addr = udata->chunk_block.offset;
H5_CHECKED_ASSIGN(last->nbytes, uint32_t, udata->chunk_block.length, hsize_t);
last->chunk_idx = udata->chunk_idx;
@@ -2914,9 +3130,6 @@ H5D__chunk_lookup(const H5D_t *dset, const hsize_t *scaled,
/* Check for cached information */
if(!H5D__chunk_cinfo_cache_found(&dset->shared->cache.chunk.last, udata)) {
H5D_chk_idx_info_t idx_info; /* Chunked index info */
-#ifdef H5_HAVE_PARALLEL
- H5P_coll_md_read_flag_t temp_cmr; /* Temp value to hold the coll metadata read setting */
-#endif /* H5_HAVE_PARALLEL */
/* Compose chunked index info struct */
idx_info.f = dset->oloc.file;
@@ -2925,25 +3138,18 @@ H5D__chunk_lookup(const H5D_t *dset, const hsize_t *scaled,
idx_info.storage = &dset->shared->layout.storage.u.chunk;
#ifdef H5_HAVE_PARALLEL
- if(H5F_HAS_FEATURE(idx_info.f, H5FD_FEAT_HAS_MPI)) {
- /* disable collective metadata read for chunk indexes
- as it is highly unlikely that users would read the
- same chunks from all processes. MSC - might turn on
- for root node? */
- temp_cmr = H5F_COLL_MD_READ(idx_info.f);
- H5F_set_coll_md_read(idx_info.f, H5P_FORCE_FALSE);
- } /* end if */
+ /* Disable collective metadata read for chunk indexes as it is
+ * highly unlikely that users would read the same chunks from all
+ * processes.
+ */
+ if(H5F_HAS_FEATURE(idx_info.f, H5FD_FEAT_HAS_MPI))
+ H5CX_set_coll_metadata_read(FALSE);
#endif /* H5_HAVE_PARALLEL */
/* Go get the chunk information */
if((dset->shared->layout.storage.u.chunk.ops->get_addr)(&idx_info, udata) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't query chunk address")
-#ifdef H5_HAVE_PARALLEL
- if(H5F_HAS_FEATURE(idx_info.f, H5FD_FEAT_HAS_MPI))
- H5F_set_coll_md_read(idx_info.f, temp_cmr);
-#endif /* H5_HAVE_PARALLEL */
-
/*
* Cache the information retrieved.
*
@@ -3056,7 +3262,7 @@ H5D__chunk_flush_entry(const H5D_t *dset, H5D_rdcc_ent_t *ent, hbool_t reset)
*/
if(NULL == (buf = H5MM_malloc(alloc)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for pipeline")
- HDmemcpy(buf, ent->chunk, alloc);
+ H5MM_memcpy(buf, ent->chunk, alloc);
} /* end if */
else {
/*
@@ -3469,7 +3675,7 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata,
*/
if(NULL == (chunk = H5D__chunk_mem_alloc(chunk_size, pline)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for raw data chunk")
- HDmemcpy(chunk, ent->chunk, chunk_size);
+ H5MM_memcpy(chunk, ent->chunk, chunk_size);
ent->chunk = (uint8_t *)H5D__chunk_mem_xfree(ent->chunk, old_pline);
ent->chunk = (uint8_t *)chunk;
chunk = NULL;
@@ -3495,7 +3701,7 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata,
*/
if(NULL == (chunk = H5D__chunk_mem_alloc(chunk_size, pline)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for raw data chunk")
- HDmemcpy(chunk, ent->chunk, chunk_size);
+ H5MM_memcpy(chunk, ent->chunk, chunk_size);
ent->chunk = (uint8_t *)H5D__chunk_mem_xfree(ent->chunk, old_pline);
ent->chunk = (uint8_t *)chunk;
@@ -3624,7 +3830,7 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata,
(void)H5D__chunk_mem_xfree(tmp_chunk, old_pline);
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for raw data chunk")
} /* end if */
- HDmemcpy(chunk, tmp_chunk, chunk_size);
+ H5MM_memcpy(chunk, tmp_chunk, chunk_size);
(void)H5D__chunk_mem_xfree(tmp_chunk, old_pline);
} /* end if */
} /* end if */
@@ -3705,7 +3911,7 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata,
ent->chunk_block.offset = chunk_addr;
ent->chunk_block.length = chunk_alloc;
ent->chunk_idx = udata->chunk_idx;
- HDmemcpy(ent->scaled, udata->common.scaled, sizeof(hsize_t) * layout->u.chunk.ndims);
+ H5MM_memcpy(ent->scaled, udata->common.scaled, sizeof(hsize_t) * layout->u.chunk.ndims);
H5_CHECKED_ASSIGN(ent->rd_count, uint32_t, chunk_size, size_t);
H5_CHECKED_ASSIGN(ent->wr_count, uint32_t, chunk_size, size_t);
ent->chunk = (uint8_t *)chunk;
@@ -3833,7 +4039,7 @@ H5D__chunk_unlock(const H5D_io_info_t *io_info, const H5D_chunk_ud_t *udata,
fake_ent.edge_chunk_state = H5D_RDCC_DISABLE_FILTERS;
if(udata->new_unfilt_chunk)
fake_ent.edge_chunk_state |= H5D_RDCC_NEWLY_DISABLED_FILTERS;
- HDmemcpy(fake_ent.scaled, udata->common.scaled, sizeof(hsize_t) * layout->u.chunk.ndims);
+ H5MM_memcpy(fake_ent.scaled, udata->common.scaled, sizeof(hsize_t) * layout->u.chunk.ndims);
HDassert(layout->u.chunk.size > 0);
fake_ent.chunk_idx = udata->chunk_idx;
fake_ent.chunk_block.offset = udata->chunk_block.offset;
@@ -4120,7 +4326,7 @@ H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_
if(has_unfilt_edge_chunks) {
if(NULL == (unfilt_fill_buf = H5D__chunk_mem_alloc(orig_chunk_size, &def_pline)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for raw data chunk")
- HDmemcpy(unfilt_fill_buf, fb_info.fill_buf, orig_chunk_size);
+ H5MM_memcpy(unfilt_fill_buf, fb_info.fill_buf, orig_chunk_size);
} /* end if */
/* Retrieve filter settings from API context */
@@ -4838,12 +5044,12 @@ H5D__chunk_prune_fill(H5D_chunk_it_ud1_t *udata, hbool_t new_unfilt_chunk)
HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate chunk selection iterator")
/* Create a selection iterator for scattering the elements to memory buffer */
- if(H5S_select_iter_init(chunk_iter, udata->chunk_space, layout->u.chunk.dim[rank]) < 0)
+ if(H5S_select_iter_init(chunk_iter, udata->chunk_space, layout->u.chunk.dim[rank], 0) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize chunk selection information")
chunk_iter_init = TRUE;
/* Scatter the data into memory */
- if(H5D__scatter_mem(udata->fb_info.fill_buf, udata->chunk_space, chunk_iter, (size_t)sel_nelmts, chunk/*out*/) < 0)
+ if(H5D__scatter_mem(udata->fb_info.fill_buf, chunk_iter, (size_t)sel_nelmts, chunk/*out*/) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "scatter failed")
@@ -5654,7 +5860,7 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata)
if(udata->chunk_in_cache && udata->chunk) {
HDassert(!H5F_addr_defined(chunk_rec->chunk_addr));
- HDmemcpy(buf, udata->chunk, nbytes);
+ H5MM_memcpy(buf, udata->chunk, nbytes);
udata->chunk = NULL;
}
else {
@@ -5688,7 +5894,7 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata)
HDassert(H5F_addr_defined(ent->chunk_block.offset));
H5_CHECKED_ASSIGN(nbytes, size_t, shared_fo->layout.u.chunk.size, uint32_t);
- HDmemcpy(buf, ent->chunk, nbytes);
+ H5MM_memcpy(buf, ent->chunk, nbytes);
}
else {
/* read chunk data from the source file */
@@ -5722,7 +5928,7 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5_ITER_ERROR, "datatype conversion failed")
/* Copy into another buffer, to reclaim memory later */
- HDmemcpy(reclaim_buf, buf, reclaim_buf_size);
+ H5MM_memcpy(reclaim_buf, buf, reclaim_buf_size);
/* Set background buffer to all zeros */
HDmemset(bkg, 0, buf_size);
@@ -5753,7 +5959,7 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata)
} /* end if */
/* After fix ref, copy the new reference elements to the buffer to write out */
- HDmemcpy(buf, bkg, buf_size);
+ H5MM_memcpy(buf, bkg, buf_size);
} /* end if */
/* Set up destination chunk callback information for insertion */
@@ -6053,7 +6259,7 @@ H5D__chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src,
for(ent = shared_fo->cache.chunk.head; ent; ent = next) {
if(!H5F_addr_defined(ent->chunk_block.offset)) {
- HDmemcpy(chunk_rec.scaled, ent->scaled, sizeof(chunk_rec.scaled));
+ H5MM_memcpy(chunk_rec.scaled, ent->scaled, sizeof(chunk_rec.scaled));
udata.chunk = ent->chunk;
udata.chunk_in_cache = TRUE;
if(H5D__chunk_copy_cb(&chunk_rec, &udata) < 0)
@@ -6303,15 +6509,16 @@ H5D__chunk_stats(const H5D_t *dset, hbool_t headers)
HGOTO_DONE(SUCCEED)
if (headers) {
- fprintf(H5DEBUG(AC), "H5D: raw data cache statistics\n");
- fprintf(H5DEBUG(AC), " %-18s %8s %8s %8s %8s+%-8s\n",
+ HDfprintf(H5DEBUG(AC), "H5D: raw data cache statistics\n");
+ HDfprintf(H5DEBUG(AC), " %-18s %8s %8s %8s %8s+%-8s\n",
"Layer", "Hits", "Misses", "MissRate", "Inits", "Flushes");
- fprintf(H5DEBUG(AC), " %-18s %8s %8s %8s %8s-%-8s\n",
+ HDfprintf(H5DEBUG(AC), " %-18s %8s %8s %8s %8s-%-8s\n",
"-----", "----", "------", "--------", "-----", "-------");
}
#ifdef H5AC_DEBUG
- if (H5DEBUG(AC)) headers = TRUE;
+ if (H5DEBUG(AC))
+ headers = TRUE;
#endif
if (headers) {
@@ -6322,12 +6529,12 @@ H5D__chunk_stats(const H5D_t *dset, hbool_t headers)
miss_rate = 0.0;
}
if (miss_rate > 100) {
- sprintf(ascii, "%7d%%", (int) (miss_rate + 0.5));
+ HDsprintf(ascii, "%7d%%", (int) (miss_rate + 0.5));
} else {
- sprintf(ascii, "%7.2f%%", miss_rate);
+ HDsprintf(ascii, "%7.2f%%", miss_rate);
}
- fprintf(H5DEBUG(AC), " %-18s %8u %8u %7s %8d+%-9ld\n",
+ HDfprintf(H5DEBUG(AC), " %-18s %8u %8u %7s %8d+%-9ld\n",
"raw data chunks", rdcc->stats.nhits, rdcc->stats.nmisses, ascii,
rdcc->stats.ninits, (long)(rdcc->stats.nflushes)-(long)(rdcc->stats.ninits));
}
diff --git a/src/H5Dcompact.c b/src/H5Dcompact.c
index c0c2a80..29401f8 100644
--- a/src/H5Dcompact.c
+++ b/src/H5Dcompact.c
@@ -80,6 +80,7 @@ const H5D_layout_ops_t H5D_LOPS_COMPACT[1] = {{
H5D__compact_construct,
NULL,
H5D__compact_is_space_alloc,
+ NULL,
H5D__compact_io_init,
H5D__contig_read,
H5D__contig_write,
@@ -528,7 +529,7 @@ H5D__compact_copy(H5F_t *f_src, H5O_storage_compact_t *_storage_src, H5F_t *f_ds
if(NULL == (buf = H5FL_BLK_MALLOC(type_conv, buf_size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
- HDmemcpy(buf, storage_src->buf, storage_src->size);
+ H5MM_memcpy(buf, storage_src->buf, storage_src->size);
/* allocate temporary bkg buff for data conversion */
if(NULL == (bkg = H5FL_BLK_MALLOC(type_conv, buf_size)))
@@ -539,7 +540,7 @@ H5D__compact_copy(H5F_t *f_src, H5O_storage_compact_t *_storage_src, H5F_t *f_ds
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype conversion failed")
/* Copy into another buffer, to reclaim memory later */
- HDmemcpy(reclaim_buf, buf, buf_size);
+ H5MM_memcpy(reclaim_buf, buf, buf_size);
/* Set background buffer to all zeros */
HDmemset(bkg, 0, buf_size);
@@ -548,7 +549,7 @@ H5D__compact_copy(H5F_t *f_src, H5O_storage_compact_t *_storage_src, H5F_t *f_ds
if(H5T_convert(tpath_mem_dst, tid_mem, tid_dst, nelmts, (size_t)0, (size_t)0, buf, bkg) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype conversion failed")
- HDmemcpy(storage_dst->buf, buf, storage_dst->size);
+ H5MM_memcpy(storage_dst->buf, buf, storage_dst->size);
if(H5D_vlen_reclaim(tid_mem, buf_space, reclaim_buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_BADITER, FAIL, "unable to reclaim variable-length data")
@@ -558,9 +559,14 @@ H5D__compact_copy(H5F_t *f_src, H5O_storage_compact_t *_storage_src, H5F_t *f_ds
/* Check for expanding references */
if(cpy_info->expand_ref) {
size_t ref_count;
+ size_t src_dt_size; /* Source datatype size */
+
+ /* Determine largest datatype size */
+ if(0 == (src_dt_size = H5T_get_size(dt_src)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to determine datatype size")
/* Determine # of reference elements to copy */
- ref_count = storage_src->size / H5T_get_size(dt_src);
+ ref_count = storage_src->size / src_dt_size;
/* Copy objects referenced in source buffer to destination file and set destination elements */
if(H5O_copy_expand_ref(f_src, storage_src->buf, f_dst,
@@ -573,11 +579,11 @@ H5D__compact_copy(H5F_t *f_src, H5O_storage_compact_t *_storage_src, H5F_t *f_ds
} /* end if */
else
/* Type conversion not necessary */
- HDmemcpy(storage_dst->buf, storage_src->buf, storage_src->size);
+ H5MM_memcpy(storage_dst->buf, storage_src->buf, storage_src->size);
} /* end if */
else
/* Type conversion not necessary */
- HDmemcpy(storage_dst->buf, storage_src->buf, storage_src->size);
+ H5MM_memcpy(storage_dst->buf, storage_src->buf, storage_src->size);
/* Mark destination buffer as dirty */
storage_dst->dirty = TRUE;
diff --git a/src/H5Dcontig.c b/src/H5Dcontig.c
index ad12ba0..8733633 100644
--- a/src/H5Dcontig.c
+++ b/src/H5Dcontig.c
@@ -40,6 +40,7 @@
#include "H5FLprivate.h" /* Free Lists */
#include "H5Iprivate.h" /* IDs */
#include "H5MFprivate.h" /* File memory management */
+#include "H5MMprivate.h" /* Memory management */
#include "H5FOprivate.h" /* File objects */
#include "H5Oprivate.h" /* Object headers */
#include "H5Pprivate.h" /* Property lists */
@@ -118,6 +119,7 @@ const H5D_layout_ops_t H5D_LOPS_CONTIG[1] = {{
H5D__contig_construct,
H5D__contig_init,
H5D__contig_is_space_alloc,
+ H5D__contig_is_data_cached,
H5D__contig_io_init,
H5D__contig_read,
H5D__contig_write,
@@ -538,6 +540,30 @@ H5D__contig_is_space_alloc(const H5O_storage_t *storage)
/*-------------------------------------------------------------------------
+ * Function: H5D__contig_is_data_cached
+ *
+ * Purpose: Query if raw data is cached for dataset
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Neil Fortner
+ * Wednessday, March 6, 2016
+ *
+ *-------------------------------------------------------------------------
+ */
+hbool_t
+H5D__contig_is_data_cached(const H5D_shared_t *shared_dset)
+{
+ FUNC_ENTER_PACKAGE_NOERR
+
+ /* Sanity checks */
+ HDassert(shared_dset);
+
+ FUNC_LEAVE_NOAPI(shared_dset->cache.contig.sieve_size > 0)
+} /* end H5D__contig_is_data_cached() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5D__contig_io_init
*
* Purpose: Performs initialization before any sort of I/O on the raw data
@@ -751,15 +777,10 @@ H5D__contig_readvv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len,
HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "block read failed")
/* Grab the data out of the buffer (must be first piece of data in buffer ) */
- HDmemcpy(buf, dset_contig->sieve_buf, len);
+ H5MM_memcpy(buf, dset_contig->sieve_buf, len);
/* Reset sieve buffer dirty flag */
dset_contig->sieve_dirty = FALSE;
-
- /* Stash local copies of these value */
- sieve_start = dset_contig->sieve_loc;
- sieve_size = dset_contig->sieve_size;
- sieve_end = sieve_start+sieve_size;
} /* end else */
} /* end if */
else {
@@ -771,7 +792,7 @@ H5D__contig_readvv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len,
unsigned char *base_sieve_buf = dset_contig->sieve_buf + (addr - sieve_start);
/* Grab the data out of the buffer */
- HDmemcpy(buf, base_sieve_buf, len);
+ H5MM_memcpy(buf, base_sieve_buf, len);
} /* end if */
/* Entire request is not within this data sieve buffer */
else {
@@ -825,17 +846,12 @@ H5D__contig_readvv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len,
min = MIN3(rel_eoa - dset_contig->sieve_loc, max_data, dset_contig->sieve_buf_size);
H5_CHECKED_ASSIGN(dset_contig->sieve_size, size_t, min, hsize_t);
- /* Update local copies of sieve information */
- sieve_start = dset_contig->sieve_loc;
- sieve_size = dset_contig->sieve_size;
- sieve_end = sieve_start + sieve_size;
-
/* Read the new sieve buffer */
if(H5F_block_read(file, H5FD_MEM_DRAW, dset_contig->sieve_loc, dset_contig->sieve_size, dset_contig->sieve_buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "block read failed")
/* Grab the data out of the buffer (must be first piece of data in buffer ) */
- HDmemcpy(buf, dset_contig->sieve_buf, len);
+ H5MM_memcpy(buf, dset_contig->sieve_buf, len);
/* Reset sieve buffer dirty flag */
dset_contig->sieve_dirty = FALSE;
@@ -1033,7 +1049,7 @@ H5D__contig_writevv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len,
} /* end if */
/* Grab the data out of the buffer (must be first piece of data in buffer ) */
- HDmemcpy(dset_contig->sieve_buf, buf, len);
+ H5MM_memcpy(dset_contig->sieve_buf, buf, len);
/* Set sieve buffer dirty flag */
dset_contig->sieve_dirty = TRUE;
@@ -1053,7 +1069,7 @@ H5D__contig_writevv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len,
unsigned char *base_sieve_buf = dset_contig->sieve_buf + (addr - sieve_start);
/* Put the data into the sieve buffer */
- HDmemcpy(base_sieve_buf, buf, len);
+ H5MM_memcpy(base_sieve_buf, buf, len);
/* Set sieve buffer dirty flag */
dset_contig->sieve_dirty = TRUE;
@@ -1096,7 +1112,7 @@ H5D__contig_writevv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len,
HDmemmove(dset_contig->sieve_buf + len, dset_contig->sieve_buf, dset_contig->sieve_size);
/* Copy in new information (must be first in sieve buffer) */
- HDmemcpy(dset_contig->sieve_buf, buf, len);
+ H5MM_memcpy(dset_contig->sieve_buf, buf, len);
/* Adjust sieve location */
dset_contig->sieve_loc = addr;
@@ -1105,16 +1121,11 @@ H5D__contig_writevv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len,
/* Append to existing sieve buffer */
else {
/* Copy in new information */
- HDmemcpy(dset_contig->sieve_buf + sieve_size, buf, len);
+ H5MM_memcpy(dset_contig->sieve_buf + sieve_size, buf, len);
} /* end else */
/* Adjust sieve size */
dset_contig->sieve_size += len;
-
- /* Update local copies of sieve information */
- sieve_start = dset_contig->sieve_loc;
- sieve_size = dset_contig->sieve_size;
- sieve_end = sieve_start + sieve_size;
} /* end if */
/* Can't add the new data onto the existing sieve buffer */
else {
@@ -1146,11 +1157,6 @@ H5D__contig_writevv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len,
min = MIN3(rel_eoa - dset_contig->sieve_loc, max_data, dset_contig->sieve_buf_size);
H5_CHECKED_ASSIGN(dset_contig->sieve_size, size_t, min, hsize_t);
- /* Update local copies of sieve information */
- sieve_start = dset_contig->sieve_loc;
- sieve_size = dset_contig->sieve_size;
- sieve_end = sieve_start + sieve_size;
-
/* Check if there is any point in reading the data from the file */
if(dset_contig->sieve_size > len) {
/* Read the new sieve buffer */
@@ -1159,7 +1165,7 @@ H5D__contig_writevv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len,
} /* end if */
/* Grab the data out of the buffer (must be first piece of data in buffer ) */
- HDmemcpy(dset_contig->sieve_buf, buf, len);
+ H5MM_memcpy(dset_contig->sieve_buf, buf, len);
/* Set sieve buffer dirty flag */
dset_contig->sieve_dirty = TRUE;
@@ -1514,7 +1520,7 @@ H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src,
if(try_sieve && (addr_src >= sieve_start) && ((addr_src + src_nbytes -1) < sieve_end)) {
unsigned char *base_sieve_buf = shared_fo->cache.contig.sieve_buf + (addr_src - sieve_start);
- HDmemcpy(buf, base_sieve_buf, src_nbytes);
+ H5MM_memcpy(buf, base_sieve_buf, src_nbytes);
} else
/* Read raw data from source file */
if(H5F_block_read(f_src, H5FD_MEM_DRAW, addr_src, src_nbytes, buf) < 0)
@@ -1527,7 +1533,7 @@ H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src,
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype conversion failed")
/* Copy into another buffer, to reclaim memory later */
- HDmemcpy(reclaim_buf, buf, mem_nbytes);
+ H5MM_memcpy(reclaim_buf, buf, mem_nbytes);
/* Set background buffer to all zeros */
HDmemset(bkg, 0, buf_size);
@@ -1553,7 +1559,7 @@ H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src,
HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy reference attribute")
/* After fix ref, copy the new reference elements to the buffer to write out */
- HDmemcpy(buf, bkg, buf_size);
+ H5MM_memcpy(buf, bkg, buf_size);
} /* end if */
else
/* Reset value to zero */
diff --git a/src/H5Ddeprec.c b/src/H5Ddeprec.c
index 76827b4..6380bee 100644
--- a/src/H5Ddeprec.c
+++ b/src/H5Ddeprec.c
@@ -116,7 +116,6 @@ H5Dcreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id,
void *dset = NULL; /* dset token from VOL connector */
H5VL_object_t *vol_obj = NULL; /* object token of loc_id */
H5VL_loc_params_t loc_params;
- H5P_genplist_t *plist; /* Property list pointer */
hid_t lcpl_id = H5P_LINK_CREATE_DEFAULT;
hid_t dapl_id = H5P_DEFAULT; /* DAPL used by library */
hid_t ret_value = H5I_INVALID_HID; /* Return value */
@@ -136,22 +135,13 @@ H5Dcreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id,
if(TRUE != H5P_isa_class(dcpl_id, H5P_DATASET_CREATE))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not dataset create property list ID")
+ /* Set the DCPL for the API context */
+ H5CX_set_dcpl(dcpl_id);
+
/* Verify access property list and set up collective metadata if appropriate */
if(H5CX_set_apl(&dapl_id, H5P_CLS_DACC, loc_id, TRUE) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info")
- /* Get the plist structure */
- if(NULL == (plist = (H5P_genplist_t *)H5I_object(dcpl_id)))
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5I_INVALID_HID, "can't find object for ID")
-
- /* set creation properties */
- if(H5P_set(plist, H5VL_PROP_DSET_TYPE_ID, &type_id) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for datatype id")
- if(H5P_set(plist, H5VL_PROP_DSET_SPACE_ID, &space_id) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for space id")
- if(H5P_set(plist, H5VL_PROP_DSET_LCPL_ID, &lcpl_id) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for lcpl id")
-
/* Set location parameters */
loc_params.type = H5VL_OBJECT_BY_SELF;
loc_params.obj_type = H5I_get_type(loc_id);
@@ -161,7 +151,7 @@ H5Dcreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id,
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier")
/* Create the dataset through the VOL */
- if(NULL == (dset = H5VL_dataset_create(vol_obj, &loc_params, name, dcpl_id, H5P_DATASET_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)))
+ if(NULL == (dset = H5VL_dataset_create(vol_obj, &loc_params, name, lcpl_id, type_id, space_id, dcpl_id, H5P_DATASET_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, H5I_INVALID_HID, "unable to create dataset")
/* Get an atom for the dataset */
diff --git a/src/H5Dearray.c b/src/H5Dearray.c
index a20145a..b23ac46 100644
--- a/src/H5Dearray.c
+++ b/src/H5Dearray.c
@@ -37,6 +37,7 @@
#include "H5EAprivate.h" /* Extensible arrays */
#include "H5FLprivate.h" /* Free Lists */
#include "H5MFprivate.h" /* File space management */
+#include "H5MMprivate.h" /* Memory management */
#include "H5VMprivate.h" /* Vector functions */
@@ -437,7 +438,7 @@ H5D__earray_debug(FILE *stream, int indent, int fwidth, hsize_t idx,
HDassert(elmt);
/* Print element */
- sprintf(temp_str, "Element #%llu:", (unsigned long long)idx);
+ HDsprintf(temp_str, "Element #%llu:", (unsigned long long)idx);
HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, temp_str,
*(const haddr_t *)elmt);
@@ -596,7 +597,7 @@ H5D__earray_filt_debug(FILE *stream, int indent, int fwidth, hsize_t idx,
HDassert(elmt);
/* Print element */
- sprintf(temp_str, "Element #%llu:", (unsigned long long)idx);
+ HDsprintf(temp_str, "Element #%llu:", (unsigned long long)idx);
HDfprintf(stream, "%*s%-*s {%a, %u, %0x}\n", indent, "", fwidth, temp_str,
elmt->addr, elmt->nbytes, elmt->filter_mask);
@@ -1197,11 +1198,11 @@ H5D__earray_idx_resize(H5O_layout_chunk_t *layout)
hsize_t swizzled_max_chunks[H5O_LAYOUT_NDIMS]; /* Swizzled form of max # of chunks in each dimension */
/* Get the swizzled chunk dimensions */
- HDmemcpy(layout->u.earray.swizzled_dim, layout->dim, (layout->ndims - 1) * sizeof(layout->dim[0]));
+ H5MM_memcpy(layout->u.earray.swizzled_dim, layout->dim, (layout->ndims - 1) * sizeof(layout->dim[0]));
H5VM_swizzle_coords(uint32_t, layout->u.earray.swizzled_dim, layout->u.earray.unlim_dim);
/* Get the swizzled number of chunks in each dimension */
- HDmemcpy(swizzled_chunks, layout->chunks, (layout->ndims - 1) * sizeof(swizzled_chunks[0]));
+ H5MM_memcpy(swizzled_chunks, layout->chunks, (layout->ndims - 1) * sizeof(swizzled_chunks[0]));
H5VM_swizzle_coords(hsize_t, swizzled_chunks, layout->u.earray.unlim_dim);
/* Get the swizzled "down" sizes for each dimension */
@@ -1209,7 +1210,7 @@ H5D__earray_idx_resize(H5O_layout_chunk_t *layout)
HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't compute swizzled 'down' chunk size value")
/* Get the swizzled max number of chunks in each dimension */
- HDmemcpy(swizzled_max_chunks, layout->max_chunks, (layout->ndims - 1) * sizeof(swizzled_max_chunks[0]));
+ H5MM_memcpy(swizzled_max_chunks, layout->max_chunks, (layout->ndims - 1) * sizeof(swizzled_max_chunks[0]));
H5VM_swizzle_coords(hsize_t, swizzled_max_chunks, layout->u.earray.unlim_dim);
/* Get the swizzled max "down" sizes for each dimension */
diff --git a/src/H5Defl.c b/src/H5Defl.c
index b2f9b29..91caa61 100644
--- a/src/H5Defl.c
+++ b/src/H5Defl.c
@@ -91,6 +91,7 @@ const H5D_layout_ops_t H5D_LOPS_EFL[1] = {{
H5D__efl_construct,
NULL,
H5D__efl_is_space_alloc,
+ NULL,
H5D__efl_io_init,
H5D__contig_read,
H5D__contig_write,
@@ -226,7 +227,7 @@ H5D__efl_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t H5_ATTR_UNU
{
FUNC_ENTER_STATIC_NOERR
- HDmemcpy(&io_info->store->efl, &(io_info->dset->shared->dcpl_cache.efl), sizeof(H5O_efl_t));
+ H5MM_memcpy(&io_info->store->efl, &(io_info->dset->shared->dcpl_cache.efl), sizeof(H5O_efl_t));
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5D__efl_io_init() */
@@ -476,7 +477,6 @@ H5D__efl_readvv(const H5D_io_info_t *io_info,
HDassert(io_info->u.rbuf);
HDassert(io_info->dset);
HDassert(io_info->dset->shared);
- HDassert(io_info->dset->shared->extfile_prefix);
HDassert(dset_curr_seq);
HDassert(dset_len_arr);
HDassert(dset_off_arr);
@@ -560,7 +560,6 @@ H5D__efl_writevv(const H5D_io_info_t *io_info,
HDassert(io_info->u.wbuf);
HDassert(io_info->dset);
HDassert(io_info->dset->shared);
- HDassert(io_info->dset->shared->extfile_prefix);
HDassert(dset_curr_seq);
HDassert(dset_len_arr);
HDassert(dset_off_arr);
diff --git a/src/H5Dfarray.c b/src/H5Dfarray.c
index 372ae26..2d85e3b 100644
--- a/src/H5Dfarray.c
+++ b/src/H5Dfarray.c
@@ -434,7 +434,7 @@ H5D__farray_debug(FILE *stream, int indent, int fwidth, hsize_t idx,
HDassert(elmt);
/* Print element */
- sprintf(temp_str, "Element #%llu:", (unsigned long long)idx);
+ HDsprintf(temp_str, "Element #%llu:", (unsigned long long)idx);
HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, temp_str,
*(const haddr_t *)elmt);
@@ -699,7 +699,7 @@ H5D__farray_filt_debug(FILE *stream, int indent, int fwidth, hsize_t idx,
HDassert(elmt);
/* Print element */
- sprintf(temp_str, "Element #%llu:", (unsigned long long)idx);
+ HDsprintf(temp_str, "Element #%llu:", (unsigned long long)idx);
HDfprintf(stream, "%*s%-*s {%a, %u, %0x}\n", indent, "", fwidth, temp_str,
elmt->addr, elmt->nbytes, elmt->filter_mask);
diff --git a/src/H5Dfill.c b/src/H5Dfill.c
index 619f699..3ccee90 100644
--- a/src/H5Dfill.c
+++ b/src/H5Dfill.c
@@ -38,6 +38,7 @@
#include "H5Eprivate.h" /* Error handling */
#include "H5FLprivate.h" /* Free Lists */
#include "H5Iprivate.h" /* IDs */
+#include "H5MMprivate.h" /* Memory management */
#include "H5VMprivate.h" /* Vector and array functions */
#include "H5WBprivate.h" /* Wrapped Buffers */
@@ -275,12 +276,12 @@ H5D__fill(const void *fill, const H5T_t *fill_type, void *buf,
HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate memory selection iterator")
/* Create a selection iterator for scattering the elements to memory buffer */
- if(H5S_select_iter_init(mem_iter, space, dst_type_size) < 0)
+ if(H5S_select_iter_init(mem_iter, space, dst_type_size, 0) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information")
mem_iter_init = TRUE;
/* Scatter the data into memory */
- if(H5D__scatter_mem(tmp_buf, space, mem_iter, (size_t)nelmts, buf/*out*/) < 0)
+ if(H5D__scatter_mem(tmp_buf, mem_iter, (size_t)nelmts, buf/*out*/) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "scatter failed")
} /* end if */
else {
@@ -300,7 +301,7 @@ H5D__fill(const void *fill, const H5T_t *fill_type, void *buf,
HGOTO_ERROR(H5E_DATASET, H5E_NOSPACE, FAIL, "can't get actual buffer")
/* Copy the user's data into the buffer for conversion */
- HDmemcpy(elem_ptr, fill, src_type_size);
+ H5MM_memcpy(elem_ptr, fill, src_type_size);
/* If there's no VL type of data, do conversion first then fill the data into
* the memory buffer. */
@@ -577,7 +578,7 @@ H5D__fill_refill_vl(H5D_fill_buf_info_t *fb_info, size_t nelmts)
HDassert(fb_info->fill_buf);
/* Make a copy of the (disk-based) fill value into the buffer */
- HDmemcpy(fb_info->fill_buf, fb_info->fill->buf, fb_info->file_elmt_size);
+ H5MM_memcpy(fb_info->fill_buf, fb_info->fill->buf, fb_info->file_elmt_size);
/* Reset first element of background buffer, if necessary */
if(H5T_path_bkg(fb_info->fill_to_mem_tpath))
@@ -603,7 +604,7 @@ H5D__fill_refill_vl(H5D_fill_buf_info_t *fb_info, size_t nelmts)
if(!buf)
HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "memory allocation failed for temporary fill buffer")
- HDmemcpy(buf, fb_info->fill_buf, fb_info->fill_buf_size);
+ H5MM_memcpy(buf, fb_info->fill_buf, fb_info->fill_buf_size);
/* Type convert the dataset buffer, to copy any VL components */
if(H5T_convert(fb_info->mem_to_dset_tpath, fb_info->mem_tid, fb_info->file_tid, nelmts, (size_t)0, (size_t)0, fb_info->fill_buf, fb_info->bkg_buf) < 0)
diff --git a/src/H5Dint.c b/src/H5Dint.c
index 7eb1aaf..cd120d0 100644
--- a/src/H5Dint.c
+++ b/src/H5Dint.c
@@ -54,7 +54,7 @@ static herr_t H5D__init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, cons
static herr_t H5D__cache_dataspace_info(const H5D_t *dset);
static herr_t H5D__init_space(H5F_t *file, const H5D_t *dset, const H5S_t *space);
static herr_t H5D__update_oh_info(H5F_t *file, H5D_t *dset, hid_t dapl_id);
-static herr_t H5D__build_file_prefix(const H5D_t *dset, hid_t dapl_id, const char *prefix_type, char **file_prefix);
+static herr_t H5D__build_file_prefix(const H5D_t *dset, H5F_prefix_open_t prefix_type, char **file_prefix);
static herr_t H5D__open_oid(H5D_t *dataset, hid_t dapl_id);
static herr_t H5D__init_storage(const H5D_io_info_t *io_info, hbool_t full_overwrite,
hsize_t old_dim[]);
@@ -112,6 +112,10 @@ static const H5I_class_t H5I_DATASET_CLS[1] = {{
/* Flag indicating "top" of interface has been initialized */
static hbool_t H5D_top_package_initialize_s = FALSE;
+/* Prefixes of VDS and external file from the environment variables
+ * HDF5_EXTFILE_PREFIX and HDF5_VDS_PREFIX */
+const static char *H5D_prefix_ext_env = NULL;
+const static char *H5D_prefix_vds_env = NULL;
/*-------------------------------------------------------------------------
@@ -188,6 +192,10 @@ H5D__init_package(void)
/* Mark "top" of interface as initialized, too */
H5D_top_package_initialize_s = TRUE;
+ /* Retrieve the prefixes of VDS and external file from the environment variable */
+ H5D_prefix_vds_env = HDgetenv("HDF5_VDS_PREFIX");
+ H5D_prefix_ext_env = HDgetenv("HDF5_EXTFILE_PREFIX");
+
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__init_package() */
@@ -470,7 +478,7 @@ H5D__new(hid_t dcpl_id, hbool_t creating, hbool_t vl_type)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
/* Copy the default dataset information */
- HDmemcpy(new_dset, &H5D_def_dset, sizeof(H5D_shared_t));
+ H5MM_memcpy(new_dset, &H5D_def_dset, sizeof(H5D_shared_t));
/* If we are using the default dataset creation property list, during creation
* don't bother to copy it, just increment the reference count
@@ -678,7 +686,6 @@ done:
static herr_t
H5D__use_minimized_dset_headers(H5F_t *file, H5D_t *dset, hbool_t *minimize)
{
- H5P_genplist_t *plist = NULL;
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI_NOINIT;
@@ -687,11 +694,9 @@ H5D__use_minimized_dset_headers(H5F_t *file, H5D_t *dset, hbool_t *minimize)
HDassert(dset);
HDassert(minimize);
- plist = H5P_object_verify(dset->shared->dcpl_id, H5P_DATASET_CREATE);
- if(NULL == plist)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "problem getting dcpl")
- if(H5P_get(plist, H5D_CRT_MIN_DSET_HDR_SIZE_NAME, minimize) == FAIL)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get minimize value from dcpl")
+ /* Get the dataset object header minimize flag for this call */
+ if(H5CX_get_dset_min_ohdr_flag(minimize) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataset object header minimize flag from API context")
if(FALSE == *minimize)
*minimize = H5F_get_min_dset_ohdr(file);
@@ -774,7 +779,7 @@ H5D__calculate_minimum_header_size(H5F_t *file, H5D_t *dset, H5O_t *ohdr)
/* Shallow copy the fill value property */
/* guards against shared component modification */
- HDmemcpy(&old_fill_prop, fill_prop, sizeof(old_fill_prop));
+ H5MM_memcpy(&old_fill_prop, fill_prop, sizeof(old_fill_prop));
if (H5O_msg_reset_share(H5O_FILL_ID, &old_fill_prop) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, "can't reset the copied fill property")
@@ -1000,7 +1005,7 @@ H5D__update_oh_info(H5F_t *file, H5D_t *dset, hid_t dapl_id)
/* Shallow copy the fill value property */
/* (we only want to make certain that the shared component isn't modified) */
- HDmemcpy(&old_fill_prop, fill_prop, sizeof(old_fill_prop));
+ H5MM_memcpy(&old_fill_prop, fill_prop, sizeof(old_fill_prop));
/* Reset shared component info */
H5O_msg_reset_share(H5O_FILL_ID, &old_fill_prop);
@@ -1083,15 +1088,13 @@ done:
*--------------------------------------------------------------------------
*/
static herr_t
-H5D__build_file_prefix(const H5D_t *dset, hid_t dapl_id, const char *prefix_type,
- char **file_prefix /*out*/)
+H5D__build_file_prefix(const H5D_t *dset, H5F_prefix_open_t prefix_type, char **file_prefix /*out*/)
{
char *prefix = NULL; /* prefix used to look for the file */
char *filepath = NULL; /* absolute path of directory the HDF5 file is in */
size_t filepath_len; /* length of file path */
size_t prefix_len; /* length of prefix */
size_t file_prefix_len; /* length of expanded prefix */
- H5P_genplist_t *plist = NULL; /* Property list pointer */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
@@ -1105,20 +1108,22 @@ H5D__build_file_prefix(const H5D_t *dset, hid_t dapl_id, const char *prefix_type
/* XXX: Future thread-safety note - getenv is not required
* to be reentrant.
*/
- if(HDstrcmp(prefix_type, H5D_ACS_VDS_PREFIX_NAME) == 0)
- prefix = HDgetenv("HDF5_VDS_PREFIX");
- else if(HDstrcmp(prefix_type, H5D_ACS_EFILE_PREFIX_NAME) == 0)
- prefix = HDgetenv("HDF5_EXTFILE_PREFIX");
- else
- HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "prefix name is not sensible")
-
- if(prefix == NULL || *prefix == '\0') {
- /* Set prefix to value of prefix_type property */
- if(NULL == (plist = H5P_object_verify(dapl_id, H5P_DATASET_ACCESS)))
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
- if(H5P_peek(plist, prefix_type, &prefix) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file prefix")
- } /* end if */
+ if(H5F_PREFIX_VDS == prefix_type) {
+ prefix = (char *)H5D_prefix_vds_env;
+
+ if(prefix == NULL || *prefix == '\0') {
+ if(H5CX_get_vds_prefix(&prefix) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get the prefix for vds file")
+ }
+ } else if(H5F_PREFIX_EFILE == prefix_type) {
+ prefix = (char *)H5D_prefix_ext_env;
+
+ if(prefix == NULL || *prefix == '\0') {
+ if(H5CX_get_ext_file_prefix(&prefix) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get the prefix for the external file")
+ }
+ } else
+ HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "prefix name is not sensible")
/* Prefix has to be checked for NULL / empty string again because the
* code above might have updated it.
@@ -1127,8 +1132,7 @@ H5D__build_file_prefix(const H5D_t *dset, hid_t dapl_id, const char *prefix_type
/* filename is interpreted as relative to the current directory,
* does not need to be expanded
*/
- if(NULL == (*file_prefix = (char *)H5MM_strdup("")))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
+ *file_prefix = NULL;
} /* end if */
else {
if(HDstrncmp(prefix, "${ORIGIN}", HDstrlen("${ORIGIN}")) == 0) {
@@ -1326,11 +1330,11 @@ H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id,
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to set up flush append property")
/* Set the external file prefix */
- if(H5D__build_file_prefix(new_dset, dapl_id, H5D_ACS_EFILE_PREFIX_NAME, &new_dset->shared->extfile_prefix) < 0)
+ if(H5D__build_file_prefix(new_dset, H5F_PREFIX_EFILE, &new_dset->shared->extfile_prefix) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize external file prefix")
/* Set the VDS file prefix */
- if(H5D__build_file_prefix(new_dset, dapl_id, H5D_ACS_VDS_PREFIX_NAME, &new_dset->shared->vds_prefix) < 0)
+ if(H5D__build_file_prefix(new_dset, H5F_PREFIX_VDS, &new_dset->shared->vds_prefix) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize VDS prefix")
/* Add the dataset to the list of opened objects in the file */
@@ -1485,11 +1489,11 @@ H5D_open(const H5G_loc_t *loc, hid_t dapl_id)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, NULL, "can't copy path")
/* Get the external file prefix */
- if(H5D__build_file_prefix(dataset, dapl_id, H5D_ACS_EFILE_PREFIX_NAME, &extfile_prefix) < 0)
+ if(H5D__build_file_prefix(dataset, H5F_PREFIX_EFILE, &extfile_prefix) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize external file prefix")
/* Get the VDS prefix */
- if(H5D__build_file_prefix(dataset, dapl_id, H5D_ACS_VDS_PREFIX_NAME, &vds_prefix) < 0)
+ if(H5D__build_file_prefix(dataset, H5F_PREFIX_VDS, &vds_prefix) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize VDS prefix")
/* Check if dataset was already open */
@@ -1533,8 +1537,13 @@ H5D_open(const H5G_loc_t *loc, hid_t dapl_id)
/* Check whether the external file prefix of the already open dataset
* matches the new external file prefix
*/
- if(HDstrcmp(extfile_prefix, dataset->shared->extfile_prefix) != 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, NULL, "new external file prefix does not match external file prefix of already open dataset")
+ if(extfile_prefix && dataset->shared->extfile_prefix) {
+ if(HDstrcmp(extfile_prefix, dataset->shared->extfile_prefix) != 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, NULL, "new external file prefix does not match external file prefix of already open dataset")
+ } else {
+ if(extfile_prefix || dataset->shared->extfile_prefix)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, NULL, "new external file prefix does not match external file prefix of already open dataset")
+ }
/* Check if the object has been opened through the top file yet */
if(H5FO_top_count(dataset->oloc.file, dataset->oloc.addr) == 0) {
@@ -1642,7 +1651,7 @@ H5D__append_flush_setup(H5D_t *dset, hid_t dapl_id)
dset->shared->append_flush.ndims = info.ndims;
dset->shared->append_flush.func = info.func;
dset->shared->append_flush.udata = info.udata;
- HDmemcpy(dset->shared->append_flush.boundary, info.boundary, sizeof(info.boundary));
+ H5MM_memcpy(dset->shared->append_flush.boundary, info.boundary, sizeof(info.boundary));
} /* end if */
} /* end if */
} /* end if */
@@ -2192,30 +2201,6 @@ H5D_nameof(const H5D_t *dataset)
/*-------------------------------------------------------------------------
- * Function: H5D_typeof
- *
- * Purpose: Returns a pointer to the dataset's datatype. The datatype
- * is not copied.
- *
- * Return: Success: Ptr to the dataset's datatype, uncopied.
- * Failure: NULL
- *-------------------------------------------------------------------------
- */
-H5T_t *
-H5D_typeof(const H5D_t *dset)
-{
- /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
- FUNC_ENTER_NOAPI_NOINIT_NOERR
-
- HDassert(dset);
- HDassert(dset->shared);
- HDassert(dset->shared->type);
-
- FUNC_LEAVE_NOAPI(dset->shared->type)
-} /* end H5D_typeof() */
-
-
-/*-------------------------------------------------------------------------
* Function: H5D__alloc_storage
*
* Purpose: Allocate storage for the raw data of a dataset.
@@ -2778,7 +2763,7 @@ H5D__set_extent(H5D_t *dset, const hsize_t *size)
/* Keep the current dataspace dimensions for later */
HDcompile_assert(sizeof(curr_dims) == sizeof(dset->shared->curr_dims));
- HDmemcpy(curr_dims, dset->shared->curr_dims, H5S_MAX_RANK * sizeof(curr_dims[0]));
+ H5MM_memcpy(curr_dims, dset->shared->curr_dims, H5S_MAX_RANK * sizeof(curr_dims[0]));
/* Modify the size of the dataspace */
if((changed = H5S_set_extent(dset->shared->space, size)) < 0)
@@ -2872,7 +2857,7 @@ H5D__set_extent(H5D_t *dset, const hsize_t *size)
dset->shared->layout.storage.u.virt.list[u].virtual_space_status = H5O_VIRTUAL_STATUS_CORRECT;
/* Patch sub-source datasets */
- for(v = 0; v < dset->shared->layout.storage.u.virt.list[u].sub_dset_nalloc; v++)
+ for(v = 0; v < dset->shared->layout.storage.u.virt.list[u].sub_dset_nused; v++)
if(H5S_set_extent(dset->shared->layout.storage.u.virt.list[u].sub_dset[v].virtual_select, size) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to modify size of dataspace")
} /* end for */
@@ -2898,7 +2883,8 @@ H5D__set_extent(H5D_t *dset, const hsize_t *size)
*-------------------------------------------------------------------------
*/
if(H5D_CHUNKED == dset->shared->layout.type) {
- if(shrink && (*dset->shared->layout.ops->is_space_alloc)(&dset->shared->layout.storage))
+ if(shrink && ((*dset->shared->layout.ops->is_space_alloc)(&dset->shared->layout.storage)
+ || (dset->shared->layout.ops->is_data_cached && (*dset->shared->layout.ops->is_data_cached)(dset->shared))))
/* Remove excess chunks */
if(H5D__chunk_prune_by_extent(dset, curr_dims) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to remove chunks")
@@ -3062,7 +3048,7 @@ H5D__format_convert(H5D_t *dataset)
idx_info.storage = &dataset->shared->layout.storage.u.chunk;
/* Copy the current layout info to the new layout */
- HDmemcpy(newlayout, &dataset->shared->layout, sizeof(H5O_layout_t));
+ H5MM_memcpy(newlayout, &dataset->shared->layout, sizeof(H5O_layout_t));
/* Set up info for version 1 B-tree in the new layout */
newlayout->version = H5O_LAYOUT_VERSION_3;
@@ -3113,7 +3099,7 @@ H5D__format_convert(H5D_t *dataset)
HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to release chunk index info")
/* Copy the new layout to the dataset's layout */
- HDmemcpy(&dataset->shared->layout, newlayout, sizeof(H5O_layout_t));
+ H5MM_memcpy(&dataset->shared->layout, newlayout, sizeof(H5O_layout_t));
break;
diff --git a/src/H5Dio.c b/src/H5Dio.c
index 2f87e38..9343b80 100644
--- a/src/H5Dio.c
+++ b/src/H5Dio.c
@@ -518,7 +518,8 @@ H5D__read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space,
* has been overwritten. So just proceed in reading.
*/
if(nelmts > 0 && dataset->shared->dcpl_cache.efl.nused == 0 &&
- !(*dataset->shared->layout.ops->is_space_alloc)(&dataset->shared->layout.storage)) {
+ !(*dataset->shared->layout.ops->is_space_alloc)(&dataset->shared->layout.storage) &&
+ !(dataset->shared->layout.ops->is_data_cached && (*dataset->shared->layout.ops->is_data_cached)(dataset->shared))) {
H5D_fill_value_t fill_status; /* Whether/How the fill value is defined */
/* Retrieve dataset's fill-value properties */
@@ -550,6 +551,7 @@ H5D__read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space,
/* Sanity check that space is allocated, if there are elements */
if(nelmts > 0)
HDassert((*dataset->shared->layout.ops->is_space_alloc)(&dataset->shared->layout.storage)
+ || (dataset->shared->layout.ops->is_data_cached && (*dataset->shared->layout.ops->is_data_cached)(dataset->shared))
|| dataset->shared->dcpl_cache.efl.nused > 0
|| dataset->shared->layout.type == H5D_COMPACT);
diff --git a/src/H5Dlayout.c b/src/H5Dlayout.c
index 494d2c8..fb28489 100644
--- a/src/H5Dlayout.c
+++ b/src/H5Dlayout.c
@@ -50,6 +50,7 @@
const unsigned H5O_layout_ver_bounds[] = {
H5O_LAYOUT_VERSION_1, /* H5F_LIBVER_EARLIEST */
H5O_LAYOUT_VERSION_3, /* H5F_LIBVER_V18 */ /* H5O_LAYOUT_VERSION_DEFAULT */
+ H5O_LAYOUT_VERSION_4, /* H5F_LIBVER_V110 */
H5O_LAYOUT_VERSION_LATEST /* H5F_LIBVER_LATEST */
};
diff --git a/src/H5Dmpio.c b/src/H5Dmpio.c
index f5da33d..467b1b7 100644
--- a/src/H5Dmpio.c
+++ b/src/H5Dmpio.c
@@ -800,6 +800,10 @@ H5D__chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_inf
HDassert(type_info);
HDassert(fm);
+ /* Disable collective metadata reads for chunked dataset I/O operations
+ * in order to prevent potential hangs */
+ H5CX_set_coll_metadata_read(FALSE);
+
/* Check the optional property list for the collective chunk IO optimization option */
if(H5CX_get_mpio_chunk_opt_mode(&chunk_opt_mode) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "couldn't get chunk optimization option")
@@ -1423,7 +1427,7 @@ H5D__link_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_in
for (i = 0, offset = 0; i < (size_t) mpi_rank; i++)
offset += num_chunks_selected_array[i];
- HDmemcpy(chunk_list, &collective_chunk_list[offset], num_chunks_selected_array[mpi_rank] * sizeof(H5D_filtered_collective_io_info_t));
+ H5MM_memcpy(chunk_list, &collective_chunk_list[offset], num_chunks_selected_array[mpi_rank] * sizeof(H5D_filtered_collective_io_info_t));
/* Create single MPI type encompassing each selection in the dataspace */
if (H5D__mpio_filtered_collective_write_type(chunk_list, chunk_list_num_entries,
@@ -1549,7 +1553,7 @@ if(H5DEBUG(D))
HGOTO_ERROR(H5E_DATASET, H5E_CANTRECV, FAIL, "unable to obtain MPIO mode")
/* Set up contiguous I/O info object */
- HDmemcpy(&ctg_io_info, io_info, sizeof(ctg_io_info));
+ H5MM_memcpy(&ctg_io_info, io_info, sizeof(ctg_io_info));
ctg_io_info.store = &ctg_store;
ctg_io_info.layout_ops = *H5D_LOPS_CONTIG;
@@ -1557,7 +1561,7 @@ if(H5DEBUG(D))
ctg_store.contig.dset_size = (hsize_t)io_info->dset->shared->layout.u.chunk.size;
/* Set up compact I/O info object */
- HDmemcpy(&cpt_io_info, io_info, sizeof(cpt_io_info));
+ H5MM_memcpy(&cpt_io_info, io_info, sizeof(cpt_io_info));
cpt_io_info.store = &cpt_store;
cpt_io_info.layout_ops = *H5D_LOPS_COMPACT;
@@ -1784,7 +1788,7 @@ H5D__multi_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_i
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "couldn't construct filtered I/O info list")
/* Set up contiguous I/O info object */
- HDmemcpy(&ctg_io_info, io_info, sizeof(ctg_io_info));
+ H5MM_memcpy(&ctg_io_info, io_info, sizeof(ctg_io_info));
ctg_io_info.store = &ctg_store;
ctg_io_info.layout_ops = *H5D_LOPS_CONTIG;
@@ -1889,7 +1893,7 @@ H5D__multi_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_i
/* Collect the new chunk info back to the local copy, since only the record in the
* collective array gets updated by the chunk re-allocation */
- HDmemcpy(&chunk_list[i].chunk_states.new_chunk, &collective_chunk_list[offset].chunk_states.new_chunk, sizeof(chunk_list[i].chunk_states.new_chunk));
+ H5MM_memcpy(&chunk_list[i].chunk_states.new_chunk, &collective_chunk_list[offset].chunk_states.new_chunk, sizeof(chunk_list[i].chunk_states.new_chunk));
H5_CHECKED_ASSIGN(mpi_type_count, int, chunk_list[i].chunk_states.new_chunk.length, hsize_t);
@@ -2313,7 +2317,7 @@ if(H5DEBUG(D))
/* Broadcasting the MPI_IO option info. and chunk address info. */
if(MPI_SUCCESS != (mpi_code = MPI_Bcast(total_chunk_addr_array, (int)(sizeof(haddr_t) * fm->layout->u.chunk.nchunks), MPI_BYTE, (int)0, io_info->comm)))
- HMPI_GOTO_ERROR(FAIL, "MPI_BCast failed", mpi_code)
+ HMPI_GOTO_ERROR(FAIL, "MPI_BCast failed", mpi_code)
} /* end if */
/* Start at first node in chunk skip list */
@@ -2513,8 +2517,8 @@ H5D__obtain_mpio_mode(H5D_io_info_t* io_info, H5D_chunk_map_t *fm,
/* merge buffer io_mode info and chunk addr into one */
- HDmemcpy(mergebuf, assign_io_mode, total_chunks);
- HDmemcpy(tempbuf, chunk_addr, sizeof(haddr_t) * total_chunks);
+ H5MM_memcpy(mergebuf, assign_io_mode, total_chunks);
+ H5MM_memcpy(tempbuf, chunk_addr, sizeof(haddr_t) * total_chunks);
H5MM_free(nproc_per_chunk);
} /* end if */
@@ -2523,8 +2527,8 @@ H5D__obtain_mpio_mode(H5D_io_info_t* io_info, H5D_chunk_map_t *fm,
if(MPI_SUCCESS != (mpi_code = MPI_Bcast(mergebuf, ((sizeof(haddr_t) + 1) * total_chunks), MPI_BYTE, root, comm)))
HMPI_GOTO_ERROR(FAIL, "MPI_BCast failed", mpi_code)
- HDmemcpy(assign_io_mode, mergebuf, total_chunks);
- HDmemcpy(chunk_addr, tempbuf, sizeof(haddr_t) * total_chunks);
+ H5MM_memcpy(assign_io_mode, mergebuf, total_chunks);
+ H5MM_memcpy(chunk_addr, tempbuf, sizeof(haddr_t) * total_chunks);
#ifdef H5_HAVE_INSTRUMENTED_LIBRARY
{
@@ -2626,7 +2630,7 @@ H5D__construct_filtered_io_info_list(const H5D_io_info_t *io_info, const H5D_typ
local_info_array[i].async_info.receive_buffer_array = NULL;
local_info_array[i].async_info.receive_requests_array = NULL;
- HDmemcpy(local_info_array[i].scaled, chunk_info->scaled, sizeof(chunk_info->scaled));
+ H5MM_memcpy(local_info_array[i].scaled, chunk_info->scaled, sizeof(chunk_info->scaled));
if ((select_npoints = H5S_GET_SELECT_NPOINTS(chunk_info->mspace)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "dataspace is invalid")
@@ -2738,6 +2742,9 @@ H5D__chunk_redistribute_shared_chunks(const H5D_io_info_t *io_info, const H5D_ty
if ((mpi_size = H5F_mpi_get_size(io_info->dset->oloc.file)) < 0)
HGOTO_ERROR(H5E_IO, H5E_MPI, FAIL, "unable to obtain mpi size")
+ /* Set to latest format for encoding dataspace */
+ H5CX_set_libver_bounds(NULL);
+
if (*local_chunk_array_num_entries)
if (NULL == (send_requests = (MPI_Request *) H5MM_malloc(*local_chunk_array_num_entries * sizeof(MPI_Request))))
HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate send requests buffer")
@@ -2799,8 +2806,9 @@ H5D__chunk_redistribute_shared_chunks(const H5D_io_info_t *io_info, const H5D_ty
/* Sort the new list in order of previous owner so that each original owner of a chunk
* entry gets that entry back, with the possibly newly-modified "new_owner" field
*/
- HDqsort(shared_chunks_info_array, shared_chunks_info_array_num_entries,
- sizeof(H5D_filtered_collective_io_info_t), H5D__cmp_filtered_collective_io_info_entry_owner);
+ if(shared_chunks_info_array_num_entries > 1)
+ HDqsort(shared_chunks_info_array, shared_chunks_info_array_num_entries,
+ sizeof(H5D_filtered_collective_io_info_t), H5D__cmp_filtered_collective_io_info_entry_owner);
send_displacements[0] = 0;
for (i = 1; i < (size_t) mpi_size; i++)
@@ -2837,45 +2845,45 @@ H5D__chunk_redistribute_shared_chunks(const H5D_io_info_t *io_info, const H5D_ty
size_t mod_data_size;
/* Look up the chunk and get its file and memory dataspaces */
- if (NULL == (chunk_info = (H5D_chunk_info_t *) H5SL_search(fm->sel_chunks, &chunk_entry->index)))
+ if(NULL == (chunk_info = (H5D_chunk_info_t *) H5SL_search(fm->sel_chunks, &chunk_entry->index)))
HGOTO_ERROR(H5E_DATASPACE, H5E_NOTFOUND, FAIL, "can't locate chunk in skip list")
/* Determine size of serialized chunk file dataspace, plus the size of
* the data being written
*/
- if (H5S_encode(chunk_info->fspace, &mod_data_p, &mod_data_size) < 0)
+ if(H5S_encode(chunk_info->fspace, &mod_data_p, &mod_data_size) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTENCODE, FAIL, "unable to get encoded dataspace size")
- if ((iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->mspace)) < 0)
+ if((iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->mspace)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "dataspace is invalid")
mod_data_size += (size_t) iter_nelmts * type_info->src_type_size;
- if (NULL == (mod_data[num_send_requests] = (unsigned char *) H5MM_malloc(mod_data_size)))
+ if(NULL == (mod_data[num_send_requests] = (unsigned char *) H5MM_malloc(mod_data_size)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate chunk modification send buffer")
/* Serialize the chunk's file dataspace into the buffer */
mod_data_p = mod_data[num_send_requests];
- if (H5S_encode(chunk_info->fspace, &mod_data_p, &mod_data_size) < 0)
+ if(H5S_encode(chunk_info->fspace, &mod_data_p, &mod_data_size) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTENCODE, FAIL, "unable to encode dataspace")
/* Initialize iterator for memory selection */
- if (H5S_select_iter_init(mem_iter, chunk_info->mspace, type_info->src_type_size) < 0)
+ if(H5S_select_iter_init(mem_iter, chunk_info->mspace, type_info->src_type_size, 0) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information")
mem_iter_init = TRUE;
/* Collect the modification data into the buffer */
- if(!H5D__gather_mem(io_info->u.wbuf, chunk_info->mspace, mem_iter, (size_t)iter_nelmts, mod_data_p))
+ if(0 == H5D__gather_mem(io_info->u.wbuf, mem_iter, (size_t)iter_nelmts, mod_data_p))
HGOTO_ERROR(H5E_IO, H5E_CANTGATHER, FAIL, "couldn't gather from write buffer")
/* Send modification data to new owner */
H5_CHECK_OVERFLOW(mod_data_size, size_t, int)
H5_CHECK_OVERFLOW(chunk_entry->index, hsize_t, int)
- if (MPI_SUCCESS != (mpi_code = MPI_Isend(mod_data[num_send_requests], (int) mod_data_size, MPI_BYTE,
+ if(MPI_SUCCESS != (mpi_code = MPI_Isend(mod_data[num_send_requests], (int) mod_data_size, MPI_BYTE,
chunk_entry->owners.new_owner, (int) chunk_entry->index, io_info->comm, &send_requests[num_send_requests])))
HMPI_GOTO_ERROR(FAIL, "MPI_Isend failed", mpi_code)
- if (mem_iter_init && H5S_SELECT_ITER_RELEASE(mem_iter) < 0)
+ if(mem_iter_init && H5S_SELECT_ITER_RELEASE(mem_iter) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "couldn't release memory selection iterator")
mem_iter_init = FALSE;
@@ -3044,11 +3052,11 @@ H5D__mpio_filtered_collective_write_type(H5D_filtered_collective_io_info_t *chun
} /* end if */
done:
- if (write_buf_array)
+ if(write_buf_array)
H5MM_free(write_buf_array);
- if (file_offset_array)
+ if(file_offset_array)
H5MM_free(file_offset_array);
- if (length_array)
+ if(length_array)
H5MM_free(length_array);
FUNC_LEAVE_NOAPI(ret_value)
@@ -3166,7 +3174,7 @@ H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk
if (NULL == (mem_iter = (H5S_sel_iter_t *) H5MM_malloc(sizeof(H5S_sel_iter_t))))
HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate memory iterator")
- if (H5S_select_iter_init(mem_iter, chunk_info->mspace, type_info->src_type_size) < 0)
+ if(H5S_select_iter_init(mem_iter, chunk_info->mspace, type_info->src_type_size, 0) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information")
mem_iter_init = TRUE;
@@ -3176,99 +3184,99 @@ H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk
* from the current process, then apply any modifications from other processes. Finally,
* filter the newly-updated chunk.
*/
- switch (io_info->op_type) {
+ switch(io_info->op_type) {
case H5D_IO_OP_READ:
- if (NULL == (file_iter = (H5S_sel_iter_t *) H5MM_malloc(sizeof(H5S_sel_iter_t))))
+ if(NULL == (file_iter = (H5S_sel_iter_t *) H5MM_malloc(sizeof(H5S_sel_iter_t))))
HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate file iterator")
- if (H5S_select_iter_init(file_iter, chunk_info->fspace, type_info->src_type_size) < 0)
+ if(H5S_select_iter_init(file_iter, chunk_info->fspace, type_info->src_type_size, 0) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information")
file_iter_init = TRUE;
- if ((iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->fspace)) < 0)
+ if((iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->fspace)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "dataspace is invalid")
- if (NULL == (tmp_gath_buf = H5MM_malloc((hsize_t) iter_nelmts * type_info->src_type_size)))
+ if(NULL == (tmp_gath_buf = H5MM_malloc((hsize_t) iter_nelmts * type_info->src_type_size)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate temporary gather buffer")
- if (!H5D__gather_mem(chunk_entry->buf, chunk_info->fspace, file_iter, (size_t) iter_nelmts, tmp_gath_buf))
+ if(!H5D__gather_mem(chunk_entry->buf, file_iter, (size_t) iter_nelmts, tmp_gath_buf))
HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "couldn't gather from chunk buffer")
- if ((iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->mspace)) < 0)
+ if((iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->mspace)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "dataspace is invalid")
- if (H5D__scatter_mem(tmp_gath_buf, chunk_info->mspace, mem_iter, (size_t) iter_nelmts, io_info->u.rbuf) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "couldn't scatter to read buffer")
+ if(H5D__scatter_mem(tmp_gath_buf, mem_iter, (size_t) iter_nelmts, io_info->u.rbuf) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "couldn't scatter to read buffer")
break;
case H5D_IO_OP_WRITE:
- if ((iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->mspace)) < 0)
+ if((iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->mspace)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "dataspace is invalid")
- if (NULL == (tmp_gath_buf = H5MM_malloc((hsize_t) iter_nelmts * type_info->src_type_size)))
+ if(NULL == (tmp_gath_buf = H5MM_malloc((hsize_t) iter_nelmts * type_info->src_type_size)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate temporary gather buffer")
/* Gather modification data from the application write buffer into a temporary buffer */
- if(!H5D__gather_mem(io_info->u.wbuf, chunk_info->mspace, mem_iter, (size_t) iter_nelmts, tmp_gath_buf))
+ if(0 == H5D__gather_mem(io_info->u.wbuf, mem_iter, (size_t) iter_nelmts, tmp_gath_buf))
HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "couldn't gather from write buffer")
- if (H5S_SELECT_ITER_RELEASE(mem_iter) < 0)
+ if(H5S_SELECT_ITER_RELEASE(mem_iter) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "couldn't release selection iterator")
mem_iter_init = FALSE;
/* Initialize iterator for file selection */
- if (H5S_select_iter_init(mem_iter, chunk_info->fspace, type_info->dst_type_size) < 0)
+ if(H5S_select_iter_init(mem_iter, chunk_info->fspace, type_info->dst_type_size, 0) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize file selection information")
mem_iter_init = TRUE;
- if ((iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->fspace)) < 0)
+ if((iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->fspace)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "dataspace is invalid")
/* Scatter the owner's modification data into the chunk data buffer according to
* the file space.
*/
- if(H5D__scatter_mem(tmp_gath_buf, chunk_info->fspace, mem_iter, (size_t) iter_nelmts, chunk_entry->buf) < 0)
+ if(H5D__scatter_mem(tmp_gath_buf, mem_iter, (size_t) iter_nelmts, chunk_entry->buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "couldn't scatter to chunk data buffer")
- if (H5S_SELECT_ITER_RELEASE(mem_iter) < 0)
+ if(H5S_SELECT_ITER_RELEASE(mem_iter) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "couldn't release selection iterator")
mem_iter_init = FALSE;
- if (MPI_SUCCESS != (mpi_code = MPI_Waitall(chunk_entry->async_info.num_receive_requests,
+ if(MPI_SUCCESS != (mpi_code = MPI_Waitall(chunk_entry->async_info.num_receive_requests,
chunk_entry->async_info.receive_requests_array, MPI_STATUSES_IGNORE)))
HMPI_GOTO_ERROR(FAIL, "MPI_Waitall failed", mpi_code)
/* For each asynchronous receive call previously posted, receive the chunk modification
* buffer from another rank and update the chunk data
*/
- for (i = 0; i < (size_t) chunk_entry->async_info.num_receive_requests; i++) {
+ for(i = 0; i < (size_t) chunk_entry->async_info.num_receive_requests; i++) {
const unsigned char *mod_data_p;
/* Decode the process' chunk file dataspace */
mod_data_p = chunk_entry->async_info.receive_buffer_array[i];
- if (NULL == (dataspace = H5S_decode(&mod_data_p)))
+ if(NULL == (dataspace = H5S_decode(&mod_data_p)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTDECODE, FAIL, "unable to decode dataspace")
- if (H5S_select_iter_init(mem_iter, dataspace, type_info->dst_type_size) < 0)
+ if(H5S_select_iter_init(mem_iter, dataspace, type_info->dst_type_size, 0) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information")
mem_iter_init = TRUE;
- if ((iter_nelmts = H5S_GET_SELECT_NPOINTS(dataspace)) < 0)
+ if((iter_nelmts = H5S_GET_SELECT_NPOINTS(dataspace)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "dataspace is invalid")
/* Update the chunk data with the received modification data */
- if(H5D__scatter_mem(mod_data_p, dataspace, mem_iter, (size_t) iter_nelmts, chunk_entry->buf) < 0)
+ if(H5D__scatter_mem(mod_data_p, mem_iter, (size_t) iter_nelmts, chunk_entry->buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "couldn't scatter to write buffer")
- if (H5S_SELECT_ITER_RELEASE(mem_iter) < 0)
+ if(H5S_SELECT_ITER_RELEASE(mem_iter) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "couldn't release selection iterator")
mem_iter_init = FALSE;
- if (dataspace) {
- if (H5S_close(dataspace) < 0)
+ if(dataspace) {
+ if(H5S_close(dataspace) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "can't close dataspace")
dataspace = NULL;
- }
+ } /* end if */
H5MM_free(chunk_entry->async_info.receive_buffer_array[i]);
} /* end for */
diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h
index 2767aa1..db67101 100644
--- a/src/H5Dpkg.h
+++ b/src/H5Dpkg.h
@@ -113,12 +113,14 @@ typedef struct H5D_type_info_t {
/* Forward declaration of structs used below */
struct H5D_io_info_t;
struct H5D_chunk_map_t;
+typedef struct H5D_shared_t H5D_shared_t;
/* Function pointers for I/O on particular types of dataset layouts */
typedef herr_t (*H5D_layout_construct_func_t)(H5F_t *f, H5D_t *dset);
typedef herr_t (*H5D_layout_init_func_t)(H5F_t *f, const H5D_t *dset,
hid_t dapl_id);
typedef hbool_t (*H5D_layout_is_space_alloc_func_t)(const H5O_storage_t *storage);
+typedef hbool_t (*H5D_layout_is_data_cached_func_t)(const H5D_shared_t *shared_dset);
typedef herr_t (*H5D_layout_io_init_func_t)(const struct H5D_io_info_t *io_info,
const H5D_type_info_t *type_info,
hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space,
@@ -144,6 +146,7 @@ typedef struct H5D_layout_ops_t {
H5D_layout_construct_func_t construct; /* Layout constructor for new datasets */
H5D_layout_init_func_t init; /* Layout initializer for dataset */
H5D_layout_is_space_alloc_func_t is_space_alloc; /* Query routine to determine if storage is allocated */
+ H5D_layout_is_data_cached_func_t is_data_cached; /* Query routine to determine if any raw data is cached. If routine is not present then the layout type never caches raw data. */
H5D_layout_io_init_func_t io_init; /* I/O initialization routine */
H5D_layout_read_func_t ser_read; /* High-level I/O routine for reading data in serial */
H5D_layout_write_func_t ser_write; /* High-level I/O routine for writing data in serial */
@@ -429,7 +432,7 @@ typedef struct H5D_rdcdc_t {
* created once for a given dataset. Thus, if a dataset is opened twice,
* there will be two IDs and two H5D_t structs, both sharing one H5D_shared_t.
*/
-typedef struct H5D_shared_t {
+struct H5D_shared_t {
size_t fo_count; /* Reference count */
hbool_t closing; /* Flag to indicate dataset is closing */
hid_t type_id; /* ID for dataset's datatype */
@@ -459,7 +462,7 @@ typedef struct H5D_shared_t {
H5D_append_flush_t append_flush; /* Append flush property information */
char *extfile_prefix; /* expanded external file prefix */
char *vds_prefix; /* expanded vds prefix */
-} H5D_shared_t;
+};
struct H5D_t {
H5O_loc_t oloc; /* Object header location */
@@ -591,10 +594,10 @@ H5_DLL herr_t H5D__select_write(const H5D_io_info_t *io_info,
hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space);
/* Functions that perform scatter-gather serial I/O operations */
-H5_DLL herr_t H5D__scatter_mem(const void *_tscat_buf, const H5S_t *space,
- H5S_sel_iter_t *iter, size_t nelmts, void *_buf);
-H5_DLL size_t H5D__gather_mem(const void *_buf, const H5S_t *space,
- H5S_sel_iter_t *iter, size_t nelmts, void *_tgath_buf/*out*/);
+H5_DLL herr_t H5D__scatter_mem(const void *_tscat_buf, H5S_sel_iter_t *iter,
+ size_t nelmts, void *_buf);
+H5_DLL size_t H5D__gather_mem(const void *_buf, H5S_sel_iter_t *iter,
+ size_t nelmts, void *_tgath_buf/*out*/);
H5_DLL herr_t H5D__scatgath_read(const H5D_io_info_t *io_info,
const H5D_type_info_t *type_info,
hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space);
@@ -618,6 +621,7 @@ H5_DLL herr_t H5D__layout_oh_write(const H5D_t *dataset, H5O_t *oh, unsigned upd
/* Functions that operate on contiguous storage */
H5_DLL herr_t H5D__contig_alloc(H5F_t *f, H5O_storage_contig_t *storage);
H5_DLL hbool_t H5D__contig_is_space_alloc(const H5O_storage_t *storage);
+H5_DLL hbool_t H5D__contig_is_data_cached(const H5D_shared_t *shared_dset);
H5_DLL herr_t H5D__contig_fill(const H5D_io_info_t *io_info);
H5_DLL herr_t H5D__contig_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info,
hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space,
@@ -636,6 +640,7 @@ H5_DLL htri_t H5D__chunk_cacheable(const H5D_io_info_t *io_info, haddr_t caddr,
H5_DLL herr_t H5D__chunk_create(const H5D_t *dset /*in,out*/);
H5_DLL herr_t H5D__chunk_set_info(const H5D_t *dset);
H5_DLL hbool_t H5D__chunk_is_space_alloc(const H5O_storage_t *storage);
+H5_DLL hbool_t H5D__chunk_is_data_cached(const H5D_shared_t *shared_dset);
H5_DLL herr_t H5D__chunk_lookup(const H5D_t *dset, const hsize_t *scaled,
H5D_chunk_ud_t *udata);
H5_DLL herr_t H5D__chunk_allocated(const H5D_t *dset, hsize_t *nbytes);
diff --git a/src/H5Dprivate.h b/src/H5Dprivate.h
index 6fb7889..bc44d2a 100644
--- a/src/H5Dprivate.h
+++ b/src/H5Dprivate.h
@@ -166,7 +166,6 @@ H5_DLL herr_t H5D_mult_refresh_close(hid_t dset_id);
H5_DLL herr_t H5D_mult_refresh_reopen(H5D_t *dataset);
H5_DLL H5O_loc_t *H5D_oloc(H5D_t *dataset);
H5_DLL H5G_name_t *H5D_nameof(const H5D_t *dataset);
-H5_DLL H5T_t *H5D_typeof(const H5D_t *dset);
H5_DLL herr_t H5D_flush_all(const H5F_t *f);
H5_DLL hid_t H5D_get_create_plist(const H5D_t *dset);
H5_DLL hid_t H5D_get_access_plist(const H5D_t *dset);
diff --git a/src/H5Dscatgath.c b/src/H5Dscatgath.c
index 266f5f5..cdf9da2 100644
--- a/src/H5Dscatgath.c
+++ b/src/H5Dscatgath.c
@@ -27,6 +27,7 @@
#include "H5Eprivate.h" /* Error handling */
#include "H5FLprivate.h" /* Free Lists */
#include "H5Iprivate.h" /* IDs */
+#include "H5MMprivate.h" /* Memory management */
/****************/
@@ -43,13 +44,11 @@
/* Local Prototypes */
/********************/
static herr_t H5D__scatter_file(const H5D_io_info_t *io_info,
- const H5S_t *file_space, H5S_sel_iter_t *file_iter, size_t nelmts,
- const void *buf);
+ H5S_sel_iter_t *file_iter, size_t nelmts, const void *buf);
static size_t H5D__gather_file(const H5D_io_info_t *io_info,
- const H5S_t *file_space, H5S_sel_iter_t *file_iter, size_t nelmts,
- void *buf);
-static herr_t H5D__compound_opt_read(size_t nelmts, const H5S_t *mem_space,
- H5S_sel_iter_t *iter, const H5D_type_info_t *type_info, void *user_buf/*out*/);
+ H5S_sel_iter_t *file_iter, size_t nelmts, void *buf);
+static herr_t H5D__compound_opt_read(size_t nelmts, H5S_sel_iter_t *iter,
+ const H5D_type_info_t *type_info, void *user_buf/*out*/);
static herr_t H5D__compound_opt_write(size_t nelmts, const H5D_type_info_t *type_info);
@@ -90,9 +89,8 @@ H5FL_SEQ_EXTERN(hsize_t);
*-------------------------------------------------------------------------
*/
static herr_t
-H5D__scatter_file(const H5D_io_info_t *_io_info,
- const H5S_t *space, H5S_sel_iter_t *iter, size_t nelmts,
- const void *_buf)
+H5D__scatter_file(const H5D_io_info_t *_io_info, H5S_sel_iter_t *iter,
+ size_t nelmts, const void *_buf)
{
H5D_io_info_t tmp_io_info; /* Temporary I/O info object */
hsize_t *off = NULL; /* Pointer to sequence offsets */
@@ -111,13 +109,12 @@ H5D__scatter_file(const H5D_io_info_t *_io_info,
/* Check args */
HDassert(_io_info);
- HDassert(space);
HDassert(iter);
HDassert(nelmts > 0);
HDassert(_buf);
/* Set up temporary I/O info object */
- HDmemcpy(&tmp_io_info, _io_info, sizeof(*_io_info));
+ H5MM_memcpy(&tmp_io_info, _io_info, sizeof(*_io_info));
tmp_io_info.op_type = H5D_IO_OP_WRITE;
tmp_io_info.u.wbuf = _buf;
@@ -138,7 +135,7 @@ H5D__scatter_file(const H5D_io_info_t *_io_info,
/* Loop until all elements are written */
while(nelmts > 0) {
/* Get list of sequences for selection to write */
- if(H5S_SELECT_GET_SEQ_LIST(space, H5S_GET_SEQ_LIST_SORTED, iter, vec_size, nelmts, &nseq, &nelem, off, len) < 0)
+ if(H5S_SELECT_ITER_GET_SEQ_LIST(iter, vec_size, nelmts, &nseq, &nelem, off, len) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed")
/* Reset the current sequence information */
@@ -191,9 +188,8 @@ done:
*-------------------------------------------------------------------------
*/
static size_t
-H5D__gather_file(const H5D_io_info_t *_io_info,
- const H5S_t *space, H5S_sel_iter_t *iter, size_t nelmts,
- void *_buf/*out*/)
+H5D__gather_file(const H5D_io_info_t *_io_info, H5S_sel_iter_t *iter,
+ size_t nelmts, void *_buf/*out*/)
{
H5D_io_info_t tmp_io_info; /* Temporary I/O info object */
hsize_t *off = NULL; /* Pointer to sequence offsets */
@@ -214,13 +210,12 @@ H5D__gather_file(const H5D_io_info_t *_io_info,
HDassert(_io_info);
HDassert(_io_info->dset);
HDassert(_io_info->store);
- HDassert(space);
HDassert(iter);
HDassert(nelmts > 0);
HDassert(_buf);
/* Set up temporary I/O info object */
- HDmemcpy(&tmp_io_info, _io_info, sizeof(*_io_info));
+ H5MM_memcpy(&tmp_io_info, _io_info, sizeof(*_io_info));
tmp_io_info.op_type = H5D_IO_OP_READ;
tmp_io_info.u.rbuf = _buf;
@@ -241,7 +236,7 @@ H5D__gather_file(const H5D_io_info_t *_io_info,
/* Loop until all elements are read */
while(nelmts > 0) {
/* Get list of sequences for selection to read */
- if(H5S_SELECT_GET_SEQ_LIST(space, H5S_GET_SEQ_LIST_SORTED, iter, vec_size, nelmts, &nseq, &nelem, off, len) < 0)
+ if(H5S_SELECT_ITER_GET_SEQ_LIST(iter, vec_size, nelmts, &nseq, &nelem, off, len) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, 0, "sequence length generation failed")
/* Reset the current sequence information */
@@ -288,8 +283,8 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5D__scatter_mem (const void *_tscat_buf, const H5S_t *space,
- H5S_sel_iter_t *iter, size_t nelmts, void *_buf/*out*/)
+H5D__scatter_mem(const void *_tscat_buf, H5S_sel_iter_t *iter, size_t nelmts,
+ void *_buf/*out*/)
{
uint8_t *buf = (uint8_t *)_buf; /* Get local copies for address arithmetic */
const uint8_t *tscat_buf = (const uint8_t *)_tscat_buf;
@@ -307,7 +302,6 @@ H5D__scatter_mem (const void *_tscat_buf, const H5S_t *space,
/* Check args */
HDassert(tscat_buf);
- HDassert(space);
HDassert(iter);
HDassert(nelmts > 0);
HDassert(buf);
@@ -329,7 +323,7 @@ H5D__scatter_mem (const void *_tscat_buf, const H5S_t *space,
/* Loop until all elements are written */
while(nelmts > 0) {
/* Get list of sequences for selection to write */
- if(H5S_SELECT_GET_SEQ_LIST(space, 0, iter, vec_size, nelmts, &nseq, &nelem, off, len) < 0)
+ if(H5S_SELECT_ITER_GET_SEQ_LIST(iter, vec_size, nelmts, &nseq, &nelem, off, len) < 0)
HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, 0, "sequence length generation failed")
/* Loop, while sequences left to process */
@@ -337,7 +331,7 @@ H5D__scatter_mem (const void *_tscat_buf, const H5S_t *space,
/* Get the number of bytes in sequence */
curr_len = len[curr_seq];
- HDmemcpy(buf + off[curr_seq], tscat_buf, curr_len);
+ H5MM_memcpy(buf + off[curr_seq], tscat_buf, curr_len);
/* Advance offset in destination buffer */
tscat_buf += curr_len;
@@ -376,8 +370,8 @@ done:
*-------------------------------------------------------------------------
*/
size_t
-H5D__gather_mem(const void *_buf, const H5S_t *space,
- H5S_sel_iter_t *iter, size_t nelmts, void *_tgath_buf/*out*/)
+H5D__gather_mem(const void *_buf, H5S_sel_iter_t *iter, size_t nelmts,
+ void *_tgath_buf/*out*/)
{
const uint8_t *buf = (const uint8_t *)_buf; /* Get local copies for address arithmetic */
uint8_t *tgath_buf = (uint8_t *)_tgath_buf;
@@ -395,7 +389,6 @@ H5D__gather_mem(const void *_buf, const H5S_t *space,
/* Check args */
HDassert(buf);
- HDassert(space);
HDassert(iter);
HDassert(nelmts > 0);
HDassert(tgath_buf);
@@ -417,7 +410,7 @@ H5D__gather_mem(const void *_buf, const H5S_t *space,
/* Loop until all elements are written */
while(nelmts > 0) {
/* Get list of sequences for selection to write */
- if(H5S_SELECT_GET_SEQ_LIST(space, 0, iter, vec_size, nelmts, &nseq, &nelem, off, len) < 0)
+ if(H5S_SELECT_ITER_GET_SEQ_LIST(iter, vec_size, nelmts, &nseq, &nelem, off, len) < 0)
HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, 0, "sequence length generation failed")
/* Loop, while sequences left to process */
@@ -425,7 +418,7 @@ H5D__gather_mem(const void *_buf, const H5S_t *space,
/* Get the number of bytes in sequence */
curr_len = len[curr_seq];
- HDmemcpy(tgath_buf, buf + off[curr_seq], curr_len);
+ H5MM_memcpy(tgath_buf, buf + off[curr_seq], curr_len);
/* Advance offset in gather buffer */
tgath_buf += curr_len;
@@ -495,13 +488,13 @@ H5D__scatgath_read(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf
HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate file iterator")
/* Figure out the strip mine size. */
- if(H5S_select_iter_init(file_iter, file_space, type_info->src_type_size) < 0)
+ if(H5S_select_iter_init(file_iter, file_space, type_info->src_type_size, H5S_SEL_ITER_GET_SEQ_LIST_SORTED) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize file selection information")
file_iter_init = TRUE; /*file selection iteration info has been initialized */
- if(H5S_select_iter_init(mem_iter, mem_space, type_info->dst_type_size) < 0)
+ if(H5S_select_iter_init(mem_iter, mem_space, type_info->dst_type_size, 0) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information")
mem_iter_init = TRUE; /*file selection iteration info has been initialized */
- if(H5S_select_iter_init(bkg_iter, mem_space, type_info->dst_type_size) < 0)
+ if(H5S_select_iter_init(bkg_iter, mem_space, type_info->dst_type_size, 0) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize background selection information")
bkg_iter_init = TRUE; /*file selection iteration info has been initialized */
@@ -522,7 +515,7 @@ H5D__scatgath_read(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf
/*
* Gather data
*/
- n = H5D__gather_file(io_info, file_space, file_iter, smine_nelmts, type_info->tconv_buf/*out*/);
+ n = H5D__gather_file(io_info, file_iter, smine_nelmts, type_info->tconv_buf/*out*/);
if(n != smine_nelmts)
HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file gather failed")
@@ -531,12 +524,12 @@ H5D__scatgath_read(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf
* bypass the rest of steps.
*/
if(type_info->cmpd_subset && H5T_SUBSET_FALSE != type_info->cmpd_subset->subset) {
- if(H5D__compound_opt_read(smine_nelmts, mem_space, mem_iter, type_info, buf /*out*/) < 0)
+ if(H5D__compound_opt_read(smine_nelmts, mem_iter, type_info, buf /*out*/) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "datatype conversion failed")
} /* end if */
else {
if(H5T_BKG_YES == type_info->need_bkg) {
- n = H5D__gather_mem(buf, mem_space, bkg_iter, smine_nelmts, type_info->bkg_buf/*out*/);
+ n = H5D__gather_mem(buf, bkg_iter, smine_nelmts, type_info->bkg_buf/*out*/);
if(n != smine_nelmts)
HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "mem gather failed")
} /* end if */
@@ -562,7 +555,7 @@ H5D__scatgath_read(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf
}
/* Scatter the data into memory */
- if(H5D__scatter_mem(type_info->tconv_buf, mem_space, mem_iter, smine_nelmts, buf/*out*/) < 0)
+ if(H5D__scatter_mem(type_info->tconv_buf, mem_iter, smine_nelmts, buf/*out*/) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "scatter failed")
} /* end else */
} /* end for */
@@ -635,13 +628,13 @@ H5D__scatgath_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_in
HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate file iterator")
/* Figure out the strip mine size. */
- if(H5S_select_iter_init(file_iter, file_space, type_info->dst_type_size) < 0)
+ if(H5S_select_iter_init(file_iter, file_space, type_info->dst_type_size, H5S_SEL_ITER_GET_SEQ_LIST_SORTED) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize file selection information")
file_iter_init = TRUE; /*file selection iteration info has been initialized */
- if(H5S_select_iter_init(mem_iter, mem_space, type_info->src_type_size) < 0)
+ if(H5S_select_iter_init(mem_iter, mem_space, type_info->src_type_size, 0) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information")
mem_iter_init = TRUE; /*file selection iteration info has been initialized */
- if(H5S_select_iter_init(bkg_iter, file_space, type_info->dst_type_size) < 0)
+ if(H5S_select_iter_init(bkg_iter, file_space, type_info->dst_type_size, H5S_SEL_ITER_GET_SEQ_LIST_SORTED) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize background selection information")
bkg_iter_init = TRUE; /*file selection iteration info has been initialized */
@@ -658,7 +651,7 @@ H5D__scatgath_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_in
* buffer. Also gather data from the file into the background buffer
* if necessary.
*/
- n = H5D__gather_mem(buf, mem_space, mem_iter, smine_nelmts, type_info->tconv_buf/*out*/);
+ n = H5D__gather_mem(buf, mem_iter, smine_nelmts, type_info->tconv_buf/*out*/);
if(n != smine_nelmts)
HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "mem gather failed")
@@ -675,7 +668,7 @@ H5D__scatgath_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_in
} /* end if */
else {
if(H5T_BKG_YES == type_info->need_bkg) {
- n = H5D__gather_file(io_info, file_space, bkg_iter, smine_nelmts, type_info->bkg_buf/*out*/);
+ n = H5D__gather_file(io_info, bkg_iter, smine_nelmts, type_info->bkg_buf/*out*/);
if(n != smine_nelmts)
HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file gather failed")
} /* end if */
@@ -705,7 +698,7 @@ H5D__scatgath_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_in
/*
* Scatter the data out to the file.
*/
- if(H5D__scatter_file(io_info, file_space, file_iter, smine_nelmts, type_info->tconv_buf) < 0)
+ if(H5D__scatter_file(io_info, file_iter, smine_nelmts, type_info->tconv_buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "scatter failed")
} /* end for */
@@ -761,7 +754,7 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5D__compound_opt_read(size_t nelmts, const H5S_t *space, H5S_sel_iter_t *iter,
+H5D__compound_opt_read(size_t nelmts, H5S_sel_iter_t *iter,
const H5D_type_info_t *type_info, void *user_buf/*out*/)
{
uint8_t *ubuf = (uint8_t *)user_buf; /* Cast for pointer arithmetic */
@@ -777,7 +770,6 @@ H5D__compound_opt_read(size_t nelmts, const H5S_t *space, H5S_sel_iter_t *iter,
/* Check args */
HDassert(nelmts > 0);
- HDassert(space);
HDassert(iter);
HDassert(type_info);
HDassert(type_info->cmpd_subset);
@@ -814,7 +806,7 @@ H5D__compound_opt_read(size_t nelmts, const H5S_t *space, H5S_sel_iter_t *iter,
size_t elmtno; /* Element counter */
/* Get list of sequences for selection to write */
- if(H5S_SELECT_GET_SEQ_LIST(space, 0, iter, vec_size, nelmts, &nseq, &elmtno, off, len) < 0)
+ if(H5S_SELECT_ITER_GET_SEQ_LIST(iter, vec_size, nelmts, &nseq, &elmtno, off, len) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, 0, "sequence length generation failed")
/* Loop, while sequences left to process */
@@ -981,7 +973,7 @@ H5Dscatter(H5D_scatter_func_t op, void *op_data, hid_t type_id,
HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate selection iterator")
/* Initialize selection iterator */
- if(H5S_select_iter_init(iter, dst_space, type_size) < 0)
+ if(H5S_select_iter_init(iter, dst_space, type_size, 0) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize selection iterator information")
iter_init = TRUE;
@@ -1005,7 +997,7 @@ H5Dscatter(H5D_scatter_func_t op, void *op_data, hid_t type_id,
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "callback returned more elements than in selection")
/* Scatter data */
- if(H5D__scatter_mem(src_buf, dst_space, iter, nelmts_scatter, dst_buf) < 0)
+ if(H5D__scatter_mem(src_buf, iter, nelmts_scatter, dst_buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "scatter failed")
nelmts -= (hssize_t)nelmts_scatter;
@@ -1091,14 +1083,14 @@ H5Dgather(hid_t src_space_id, const void *src_buf, hid_t type_id,
HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate selection iterator")
/* Initialize selection iterator */
- if(H5S_select_iter_init(iter, src_space, type_size) < 0)
+ if(H5S_select_iter_init(iter, src_space, type_size, 0) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize selection iterator information")
iter_init = TRUE;
/* Loop until all data has been scattered */
while(nelmts > 0) {
/* Gather data */
- if(0 == (nelmts_gathered = H5D__gather_mem(src_buf, src_space, iter, MIN(dst_buf_nelmts, (size_t)nelmts), dst_buf)))
+ if(0 == (nelmts_gathered = H5D__gather_mem(src_buf, iter, MIN(dst_buf_nelmts, (size_t)nelmts), dst_buf)))
HGOTO_ERROR(H5E_IO, H5E_CANTCOPY, FAIL, "gather failed")
HDassert(nelmts_gathered == MIN(dst_buf_nelmts, (size_t)nelmts));
diff --git a/src/H5Dselect.c b/src/H5Dselect.c
index 0ec3423..a843d93 100644
--- a/src/H5Dselect.c
+++ b/src/H5Dselect.c
@@ -175,12 +175,12 @@ H5D__select_io(const H5D_io_info_t *io_info, size_t elmt_size,
HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate file iterator")
/* Initialize file iterator */
- if(H5S_select_iter_init(file_iter, file_space, elmt_size) < 0)
+ if(H5S_select_iter_init(file_iter, file_space, elmt_size, H5S_SEL_ITER_GET_SEQ_LIST_SORTED) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator")
file_iter_init = 1; /* File selection iteration info has been initialized */
/* Initialize memory iterator */
- if(H5S_select_iter_init(mem_iter, mem_space, elmt_size) < 0)
+ if(H5S_select_iter_init(mem_iter, mem_space, elmt_size, 0) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator")
mem_iter_init = 1; /* Memory selection iteration info has been initialized */
@@ -193,7 +193,7 @@ H5D__select_io(const H5D_io_info_t *io_info, size_t elmt_size,
/* Check if more file sequences are needed */
if(curr_file_seq >= file_nseq) {
/* Get sequences for file selection */
- if(H5S_SELECT_GET_SEQ_LIST(file_space, H5S_GET_SEQ_LIST_SORTED, file_iter, vec_size, nelmts, &file_nseq, &file_nelem, file_off, file_len) < 0)
+ if(H5S_SELECT_ITER_GET_SEQ_LIST(file_iter, vec_size, nelmts, &file_nseq, &file_nelem, file_off, file_len) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed")
/* Start at the beginning of the sequences again */
@@ -203,7 +203,7 @@ H5D__select_io(const H5D_io_info_t *io_info, size_t elmt_size,
/* Check if more memory sequences are needed */
if(curr_mem_seq >= mem_nseq) {
/* Get sequences for memory selection */
- if(H5S_SELECT_GET_SEQ_LIST(mem_space, 0, mem_iter, vec_size, nelmts, &mem_nseq, &mem_nelem, mem_off, mem_len) < 0)
+ if(H5S_SELECT_ITER_GET_SEQ_LIST(mem_iter, vec_size, nelmts, &mem_nseq, &mem_nelem, mem_off, mem_len) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed")
/* Start at the beginning of the sequences again */
@@ -227,6 +227,8 @@ H5D__select_io(const H5D_io_info_t *io_info, size_t elmt_size,
/* Decrement number of elements left to process */
HDassert(((size_t)tmp_file_len % elmt_size) == 0);
+ if(elmt_size == 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "Resulted in division by zero")
nelmts -= ((size_t)tmp_file_len / elmt_size);
} /* end while */
} /* end else */
diff --git a/src/H5Dvirtual.c b/src/H5Dvirtual.c
index 8c78feb..61e67f9 100644
--- a/src/H5Dvirtual.c
+++ b/src/H5Dvirtual.c
@@ -35,6 +35,13 @@
* until the virtual dataset is closed.
*/
+/*
+ * Note: H5S_select_project_intersection has been updated to no longer require
+ * that the source and source intersect spaces have the same extent. This file
+ * should therefore be updated to remove code that ensures this condition, which
+ * should improve both maintainability and performance.
+ */
+
/****************/
/* Module Setup */
/****************/
@@ -79,6 +86,7 @@
/********************/
/* Layout operation callbacks */
+static hbool_t H5D__virtual_is_data_cached(const H5D_shared_t *shared_dset);
static herr_t H5D__virtual_read(H5D_io_info_t *io_info, const H5D_type_info_t
*type_info, hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space,
H5D_chunk_map_t *fm);
@@ -122,6 +130,7 @@ const H5D_layout_ops_t H5D_LOPS_VIRTUAL[1] = {{
NULL,
H5D__virtual_init,
H5D__virtual_is_space_alloc,
+ H5D__virtual_is_data_cached,
NULL,
H5D__virtual_read,
H5D__virtual_write,
@@ -425,11 +434,13 @@ H5D__virtual_store_layout(H5F_t *f, H5O_layout_t *layout)
/* Sanity checking */
HDassert(f);
HDassert(layout);
+ HDassert(layout->storage.u.virt.serial_list_hobjid.addr == HADDR_UNDEF);
/* Create block if # of used entries > 0 */
+ if(layout->storage.u.virt.list_nused > 0) {
- if((layout->storage.u.virt.serial_list_hobjid.addr == HADDR_UNDEF)
- && (layout->storage.u.virt.list_nused > 0)) {
+ /* Set the low/high bounds according to 'f' for the API context */
+ H5CX_set_libver_bounds(f);
/* Allocate array for caching results of strlen */
if(NULL == (str_size = (size_t *)H5MM_malloc(2 * layout->storage.u.virt.list_nused * sizeof(size_t))))
@@ -492,11 +503,11 @@ H5D__virtual_store_layout(H5F_t *f, H5O_layout_t *layout)
/* Encode each entry */
for(i = 0; i < layout->storage.u.virt.list_nused; i++) {
/* Source file name */
- HDmemcpy((char *)heap_block_p, layout->storage.u.virt.list[i].source_file_name, str_size[2 * i]);
+ H5MM_memcpy((char *)heap_block_p, layout->storage.u.virt.list[i].source_file_name, str_size[2 * i]);
heap_block_p += str_size[2 * i];
/* Source dataset name */
- HDmemcpy((char *)heap_block_p, layout->storage.u.virt.list[i].source_dset_name, str_size[(2 * i) + 1]);
+ H5MM_memcpy((char *)heap_block_p, layout->storage.u.virt.list[i].source_dset_name, str_size[(2 * i) + 1]);
heap_block_p += str_size[(2 * i) + 1];
/* Source selection */
@@ -1129,7 +1140,7 @@ H5D__virtual_str_append(const char *src, size_t src_len, char **p, char **buf,
/* Copy string to *p. Note that since src in not NULL terminated, we must
* use memcpy */
- (void)HDmemcpy(*p, src, src_len);
+ (void)H5MM_memcpy(*p, src, src_len);
/* Advance *p */
*p += src_len;
@@ -2268,6 +2279,54 @@ H5D__virtual_is_space_alloc(const H5O_storage_t H5_ATTR_UNUSED *storage)
/*-------------------------------------------------------------------------
+ * Function: H5D__virtual_is_data_cached
+ *
+ * Purpose: Query if raw data is cached for dataset
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Neil Fortner
+ * Wednessday, March 6, 2016
+ *
+ *-------------------------------------------------------------------------
+ */
+static hbool_t
+H5D__virtual_is_data_cached(const H5D_shared_t *shared_dset)
+{
+ const H5O_storage_virtual_t *storage; /* Convenience pointer */
+ size_t i, j; /* Local index variables */
+ hbool_t ret_value = FALSE; /* Return value */
+
+ FUNC_ENTER_PACKAGE_NOERR
+
+ /* Sanity checks */
+ HDassert(shared_dset);
+ storage = &shared_dset->layout.storage.u.virt;
+
+ /* Iterate over mappings */
+ for(i = 0; i < storage->list_nused; i++)
+ /* Check for "printf" source dataset resolution */
+ if(storage->list[i].psfn_nsubs || storage->list[i].psdn_nsubs) {
+ /* Iterate over sub-source dsets */
+ for(j = storage->list[i].sub_dset_io_start; j < storage->list[i].sub_dset_io_end; j++)
+ /* Check for cahced data in source dset */
+ if(storage->list[i].sub_dset[j].dset
+ && storage->list[i].sub_dset[j].dset->shared->layout.ops->is_data_cached
+ && storage->list[i].sub_dset[j].dset->shared->layout.ops->is_data_cached(storage->list[i].sub_dset[j].dset->shared))
+ HGOTO_DONE(TRUE);
+ } /* end if */
+ else
+ if(storage->list[i].source_dset.dset
+ && storage->list[i].source_dset.dset->shared->layout.ops->is_data_cached
+ && storage->list[i].source_dset.dset->shared->layout.ops->is_data_cached(storage->list[i].source_dset.dset->shared))
+ HGOTO_DONE(TRUE);
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5D__virtual_is_data_cached() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5D__virtual_pre_io
*
* Purpose: Project all virtual mappings onto mem_space, with the
@@ -3030,7 +3089,7 @@ H5D__virtual_refresh_source_dset(H5D_t **dset)
/* Discard the identifier & replace the dataset */
if(NULL == (vol_obj = (H5VL_object_t *)H5I_remove(temp_id)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTREMOVE, FAIL, "can't unregister source dataset ID")
- if(NULL == (*dset = (H5D_t *)H5VL_object_data(vol_obj)))
+ if(NULL == (*dset = (H5D_t *)H5VL_object_unwrap(vol_obj)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't retrieve library object from VOL object")
vol_obj->data = NULL;
diff --git a/src/H5E.c b/src/H5E.c
index 06ae806..07eaf18 100644
--- a/src/H5E.c
+++ b/src/H5E.c
@@ -866,7 +866,7 @@ H5Eget_msg(hid_t msg_id, H5E_type_t *type, char *msg_str, size_t size)
H5E_msg_t *msg; /* Pointer to error message */
ssize_t ret_value = -1; /* Return value */
- FUNC_ENTER_API((-1))
+ FUNC_ENTER_API_NOCLEAR((-1))
H5TRACE4("Zs", "i*Et*sz", msg_id, type, msg_str, size);
/* Get the message object */
@@ -1386,7 +1386,7 @@ H5Epush2(hid_t err_stack, const char *file, const char *func, unsigned line,
*/
/* Format the description */
- va_start(ap, fmt);
+ HDva_start(ap, fmt);
va_started = TRUE;
#ifdef H5_HAVE_VASPRINTF
@@ -1402,8 +1402,8 @@ H5Epush2(hid_t err_stack, const char *file, const char *func, unsigned line,
/* If the description doesn't fit into the initial buffer size, allocate more space and try again */
while((desc_len = HDvsnprintf(tmp, (size_t)tmp_len, fmt, ap)) > (tmp_len - 1)) {
/* shutdown & restart the va_list */
- va_end(ap);
- va_start(ap, fmt);
+ HDva_end(ap);
+ HDva_start(ap, fmt);
/* Release the previous description, it's too small */
H5MM_xfree(tmp);
@@ -1421,7 +1421,7 @@ H5Epush2(hid_t err_stack, const char *file, const char *func, unsigned line,
done:
if(va_started)
- va_end(ap);
+ HDva_end(ap);
#ifdef H5_HAVE_VASPRINTF
/* Memory was allocated with HDvasprintf so it needs to be freed
* with HDfree
diff --git a/src/H5EA.c b/src/H5EA.c
index 9ceb144..d0bf474 100644
--- a/src/H5EA.c
+++ b/src/H5EA.c
@@ -46,6 +46,7 @@
#include "H5Eprivate.h" /* Error handling */
#include "H5EApkg.h" /* Extensible Arrays */
#include "H5FLprivate.h" /* Free Lists */
+#include "H5MMprivate.h" /* Memory management */
#include "H5VMprivate.h" /* Vector functions */
@@ -693,7 +694,7 @@ H5EA_set(const H5EA_t *ea, hsize_t idx, const void *elmt))
HDassert(thing_unprot_func);
/* Set element in thing's element buffer */
- HDmemcpy(thing_elmt_buf + (hdr->cparam.cls->nat_elmt_size * thing_elmt_idx), elmt, hdr->cparam.cls->nat_elmt_size);
+ H5MM_memcpy(thing_elmt_buf + (hdr->cparam.cls->nat_elmt_size * thing_elmt_idx), elmt, hdr->cparam.cls->nat_elmt_size);
thing_cache_flags |= H5AC__DIRTIED_FLAG;
/* Update max. element set in array, if appropriate */
@@ -765,7 +766,7 @@ H5EA_get(const H5EA_t *ea, hsize_t idx, void *elmt))
} /* end if */
else
/* Get element from thing's element buffer */
- HDmemcpy(elmt, thing_elmt_buf + (hdr->cparam.cls->nat_elmt_size * thing_elmt_idx), hdr->cparam.cls->nat_elmt_size);
+ H5MM_memcpy(elmt, thing_elmt_buf + (hdr->cparam.cls->nat_elmt_size * thing_elmt_idx), hdr->cparam.cls->nat_elmt_size);
} /* end else */
CATCH
diff --git a/src/H5EAcache.c b/src/H5EAcache.c
index 8138991..da67e6b 100644
--- a/src/H5EAcache.c
+++ b/src/H5EAcache.c
@@ -41,6 +41,7 @@
#include "H5Eprivate.h" /* Error handling */
#include "H5EApkg.h" /* Extensible Arrays */
#include "H5MFprivate.h" /* File memory management */
+#include "H5MMprivate.h" /* Memory management */
#include "H5VMprivate.h" /* Vectors and arrays */
#include "H5WBprivate.h" /* Wrapped Buffers */
@@ -479,7 +480,7 @@ H5EA__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED le
HDassert(hdr);
/* Magic number */
- HDmemcpy(image, H5EA_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC);
+ H5MM_memcpy(image, H5EA_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC);
image += H5_SIZEOF_MAGIC;
/* Version # */
@@ -867,7 +868,7 @@ H5EA__cache_iblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED
/* Get temporary pointer to serialized info */
/* Magic number */
- HDmemcpy(image, H5EA_IBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC);
+ H5MM_memcpy(image, H5EA_IBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC);
image += H5_SIZEOF_MAGIC;
/* Version # */
@@ -1179,7 +1180,7 @@ H5EA__cache_sblock_deserialize(const void *_image, size_t len,
size_t tot_page_init_size = sblock->ndblks * sblock->dblk_page_init_size; /* Compute total size of 'page init' buffer */
/* Retrieve the 'page init' bitmasks */
- HDmemcpy(sblock->page_init, image, tot_page_init_size);
+ H5MM_memcpy(sblock->page_init, image, tot_page_init_size);
image += tot_page_init_size;
} /* end if */
@@ -1276,7 +1277,7 @@ H5EA__cache_sblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED
HDassert(sblock->hdr);
/* Magic number */
- HDmemcpy(image, H5EA_SBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC);
+ H5MM_memcpy(image, H5EA_SBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC);
image += H5_SIZEOF_MAGIC;
/* Version # */
@@ -1298,7 +1299,7 @@ H5EA__cache_sblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED
size_t tot_page_init_size = sblock->ndblks * sblock->dblk_page_init_size; /* Compute total size of 'page init' buffer */
/* Store the 'page init' bitmasks */
- HDmemcpy(image, sblock->page_init, tot_page_init_size);
+ H5MM_memcpy(image, sblock->page_init, tot_page_init_size);
image += tot_page_init_size;
} /* end if */
@@ -1690,7 +1691,7 @@ H5EA__cache_dblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED
HDassert(dblock->hdr);
/* Magic number */
- HDmemcpy(image, H5EA_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC);
+ H5MM_memcpy(image, H5EA_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC);
image += H5_SIZEOF_MAGIC;
/* Version # */
diff --git a/src/H5EAdbg.c b/src/H5EAdbg.c
index 1a2b973..3d6c2ed 100644
--- a/src/H5EAdbg.c
+++ b/src/H5EAdbg.c
@@ -264,7 +264,7 @@ H5EA__iblock_debug(H5F_t *f, haddr_t H5_ATTR_UNUSED addr, FILE *stream, int inde
HDfprintf(stream, "%*sData Block Addresses in Index Block:\n", indent, "");
for(u = 0; u < iblock->ndblk_addrs; u++) {
/* Print address */
- sprintf(temp_str, "Address #%u:", u);
+ HDsprintf(temp_str, "Address #%u:", u);
HDfprintf(stream, "%*s%-*s %a\n", (indent + 3), "", MAX(0, (fwidth - 3)),
temp_str,
iblock->dblk_addrs[u]);
@@ -280,7 +280,7 @@ H5EA__iblock_debug(H5F_t *f, haddr_t H5_ATTR_UNUSED addr, FILE *stream, int inde
HDfprintf(stream, "%*sSuper Block Addresses in Index Block:\n", indent, "");
for(u = 0; u < iblock->nsblk_addrs; u++) {
/* Print address */
- sprintf(temp_str, "Address #%u:", u);
+ HDsprintf(temp_str, "Address #%u:", u);
HDfprintf(stream, "%*s%-*s %a\n", (indent + 3), "", MAX(0, (fwidth - 3)),
temp_str,
iblock->sblk_addrs[u]);
@@ -371,7 +371,7 @@ H5EA__sblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent,
HDfprintf(stream, "%*sData Block Addresses in Super Block:\n", indent, "");
for(u = 0; u < sblock->ndblks; u++) {
/* Print address */
- sprintf(temp_str, "Address #%u:", u);
+ HDsprintf(temp_str, "Address #%u:", u);
HDfprintf(stream, "%*s%-*s %a\n", (indent + 3), "", MAX(0, (fwidth - 3)),
temp_str,
sblock->dblk_addrs[u]);
diff --git a/src/H5EAhdr.c b/src/H5EAhdr.c
index 62a23b8..18d642f 100644
--- a/src/H5EAhdr.c
+++ b/src/H5EAhdr.c
@@ -41,6 +41,7 @@
#include "H5Eprivate.h" /* Error handling */
#include "H5EApkg.h" /* Extensible Arrays */
#include "H5MFprivate.h" /* File memory management */
+#include "H5MMprivate.h" /* Memory management */
#include "H5VMprivate.h" /* Vectors and arrays */
@@ -407,7 +408,7 @@ H5EA__hdr_create(H5F_t *f, const H5EA_create_t *cparam, void *ctx_udata))
hdr->idx_blk_addr = HADDR_UNDEF;
/* Set the creation parameters for the array */
- HDmemcpy(&hdr->cparam, cparam, sizeof(hdr->cparam));
+ H5MM_memcpy(&hdr->cparam, cparam, sizeof(hdr->cparam));
/* Finish initializing extensible array header */
if(H5EA__hdr_init(hdr, ctx_udata) < 0)
diff --git a/src/H5EAstat.c b/src/H5EAstat.c
index 72c4d14..509d3f8 100644
--- a/src/H5EAstat.c
+++ b/src/H5EAstat.c
@@ -40,6 +40,7 @@
#include "H5private.h" /* Generic Functions */
#include "H5Eprivate.h" /* Error handling */
#include "H5EApkg.h" /* Extensible Arrays */
+#include "H5MMprivate.h" /* Memory management */
/****************/
@@ -108,7 +109,7 @@ HDfprintf(stderr, "%s: Called\n", FUNC);
HDassert(stats);
/* Copy extensible array statistics */
- HDmemcpy(stats, &ea->hdr->stats, sizeof(ea->hdr->stats));
+ H5MM_memcpy(stats, &ea->hdr->stats, sizeof(ea->hdr->stats));
END_FUNC(PRIV) /* end H5EA_get_stats() */
diff --git a/src/H5EAtest.c b/src/H5EAtest.c
index 7c02e16..814e64f 100644
--- a/src/H5EAtest.c
+++ b/src/H5EAtest.c
@@ -336,7 +336,7 @@ H5EA__test_debug(FILE *stream, int indent, int fwidth, hsize_t idx,
HDassert(elmt);
/* Print element */
- sprintf(temp_str, "Element #%llu:", (unsigned long long)idx);
+ HDsprintf(temp_str, "Element #%llu:", (unsigned long long)idx);
HDfprintf(stream, "%*s%-*s %llu\n", indent, "", fwidth, temp_str,
(unsigned long long)*(const uint64_t *)elmt);
diff --git a/src/H5Eint.c b/src/H5Eint.c
index 66653ca..e76db82 100644
--- a/src/H5Eint.c
+++ b/src/H5Eint.c
@@ -704,7 +704,7 @@ H5E_printf_stack(H5E_t *estack, const char *file, const char *func, unsigned lin
*/
/* Start the variable-argument parsing */
- va_start(ap, fmt);
+ HDva_start(ap, fmt);
va_started = TRUE;
#ifdef H5_HAVE_VASPRINTF
@@ -720,8 +720,8 @@ H5E_printf_stack(H5E_t *estack, const char *file, const char *func, unsigned lin
/* If the description doesn't fit into the initial buffer size, allocate more space and try again */
while((desc_len = HDvsnprintf(tmp, (size_t)tmp_len, fmt, ap)) > (tmp_len - 1)) {
/* shutdown & restart the va_list */
- va_end(ap);
- va_start(ap, fmt);
+ HDva_end(ap);
+ HDva_start(ap, fmt);
/* Release the previous description, it's too small */
H5MM_xfree(tmp);
@@ -739,7 +739,7 @@ H5E_printf_stack(H5E_t *estack, const char *file, const char *func, unsigned lin
done:
if(va_started)
- va_end(ap);
+ HDva_end(ap);
#ifdef H5_HAVE_VASPRINTF
/* Memory was allocated with HDvasprintf so it needs to be freed
* with HDfree
@@ -883,11 +883,11 @@ H5E__clear_entries(H5E_t *estack, size_t nentries)
/* Release strings */
if(error->func_name)
- H5MM_xfree((void *)error->func_name); /* Casting away const OK - QAK */
+ error->func_name = (const char *) H5MM_xfree((void *)error->func_name); /* Casting away const OK - QAK */
if(error->file_name)
- H5MM_xfree((void *)error->file_name); /* Casting away const OK - QAK */
+ error->file_name = (const char *) H5MM_xfree((void *)error->file_name); /* Casting away const OK - QAK */
if(error->desc)
- H5MM_xfree((void *)error->desc); /* Casting away const OK - QAK */
+ error->desc = (const char *) H5MM_xfree((void *)error->desc); /* Casting away const OK - QAK */
} /* end for */
/* Decrement number of errors on stack */
diff --git a/src/H5F.c b/src/H5F.c
index 9df8140..d216cd2 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -560,20 +560,21 @@ done:
*
* Purpose: Check if the file can be opened with the given fapl.
*
- * Return: TRUE/FALSE/FAIL
+ * Return: Succeed: TRUE/FALSE
+ * Failure: FAIL (includes file does not exist)
*
*-------------------------------------------------------------------------
*/
htri_t
-H5Fis_accessible(const char *name, hid_t fapl_id)
+H5Fis_accessible(const char *filename, hid_t fapl_id)
{
htri_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
- H5TRACE2("t", "*si", name, fapl_id);
+ H5TRACE2("t", "*si", filename, fapl_id);
/* Check args */
- if(!name || !*name)
+ if(!filename || !*filename)
HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "no file name specified")
/* Check the file access property list */
@@ -584,7 +585,7 @@ H5Fis_accessible(const char *name, hid_t fapl_id)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not file access property list")
/* Check if file is accessible */
- if(H5VL_file_specific(NULL, H5VL_FILE_IS_ACCESSIBLE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, fapl_id, name, &ret_value) < 0)
+ if(H5VL_file_specific(NULL, H5VL_FILE_IS_ACCESSIBLE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, fapl_id, filename, &ret_value) < 0)
HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "unable to determine if file is accessible as HDF5")
done:
@@ -838,6 +839,68 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5Fdelete
+ *
+ * Purpose: Deletes an HDF5 file.
+ *
+ * Return: SUCCEED/FAIL
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Fdelete(const char *filename, hid_t fapl_id)
+{
+ H5P_genplist_t *plist; /* Property list pointer */
+ H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */
+ htri_t is_hdf5 = FAIL;
+ herr_t ret_value = SUCCEED;
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE2("e", "*si", filename, fapl_id);
+
+ /* Check args */
+ if(!filename || !*filename)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "no file name specified")
+
+ /* Check the file access property list */
+ if(H5P_DEFAULT == fapl_id)
+ fapl_id = H5P_FILE_ACCESS_DEFAULT;
+ else
+ if(TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list")
+
+ /* Verify access property list and set up collective metadata if appropriate */
+ if(H5CX_set_apl(&fapl_id, H5P_CLS_FACC, H5I_INVALID_HID, TRUE) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info")
+
+ /* Get the VOL info from the fapl */
+ if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(fapl_id, H5I_GENPROP_LST)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list")
+ if(H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL connector info")
+
+ /* Stash a copy of the "top-level" connector property, before any pass-through
+ * connectors modify or unwrap it.
+ */
+ if(H5CX_set_vol_connector_prop(&connector_prop) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set VOL connector info in API context")
+
+ /* Make sure this is HDF5 storage for this VOL connector */
+ if(H5VL_file_specific(NULL, H5VL_FILE_IS_ACCESSIBLE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, fapl_id, filename, &is_hdf5) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "unable to determine if file is accessible as HDF5")
+ if(!is_hdf5)
+ HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "not an HDF5 file")
+
+ /* Delete the file */
+ if(H5VL_file_specific(NULL, H5VL_FILE_DELETE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, fapl_id, filename, &ret_value) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTDELETEFILE, FAIL, "unable to delete the file")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Fdelete() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5Freopen
*
* Purpose: Reopen a file. The new file handle which is returned points
@@ -921,6 +984,42 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5Fget_fileno
+ *
+ * Purpose: Public API to retrieve the file's 'file number' that uniquely
+ * identifies each open file.
+ *
+ * Return: SUCCEED/FAIL
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Fget_fileno(hid_t file_id, unsigned long *fileno)
+{
+ herr_t ret_value = SUCCEED;
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE2("e", "i*Ul", file_id, fileno);
+
+ /* If no fileno pointer was passed in, exit quietly */
+ if(fileno) {
+ H5VL_object_t *vol_obj; /* File info */
+
+ /* Get the internal file structure */
+ if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(file_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+
+ /* Get the flags */
+ if((ret_value = H5VL_file_get(vol_obj, H5VL_FILE_GET_FILENO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, fileno)) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get file's 'file number'")
+ } /* end if */
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Fget_fileno() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5Fget_freespace
*
* Purpose: Retrieves the amount of free space in the file.
diff --git a/src/H5FA.c b/src/H5FA.c
index 61aaa53..8c86193 100644
--- a/src/H5FA.c
+++ b/src/H5FA.c
@@ -41,6 +41,7 @@
#include "H5Eprivate.h" /* Error handling */
#include "H5FApkg.h" /* Fixed Arrays */
#include "H5FLprivate.h" /* Free Lists */
+#include "H5MMprivate.h" /* Memory management */
#include "H5VMprivate.h" /* Vector functions */
@@ -371,7 +372,7 @@ H5FA_set(const H5FA_t *fa, hsize_t idx, const void *elmt))
/* Check for paging data block */
if(!dblock->npages) {
/* Set element in data block */
- HDmemcpy(((uint8_t *)dblock->elmts) + (hdr->cparam.cls->nat_elmt_size * idx), elmt, hdr->cparam.cls->nat_elmt_size);
+ H5MM_memcpy(((uint8_t *)dblock->elmts) + (hdr->cparam.cls->nat_elmt_size * idx), elmt, hdr->cparam.cls->nat_elmt_size);
dblock_cache_flags |= H5AC__DIRTIED_FLAG;
} /* end if */
else { /* paging */
@@ -410,7 +411,7 @@ H5FA_set(const H5FA_t *fa, hsize_t idx, const void *elmt))
H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block page, address = %llu", (unsigned long long)dblk_page_addr)
/* Set the element in the data block page */
- HDmemcpy(((uint8_t *)dblk_page->elmts) + (hdr->cparam.cls->nat_elmt_size * elmt_idx), elmt, hdr->cparam.cls->nat_elmt_size);
+ H5MM_memcpy(((uint8_t *)dblk_page->elmts) + (hdr->cparam.cls->nat_elmt_size * elmt_idx), elmt, hdr->cparam.cls->nat_elmt_size);
dblk_page_cache_flags |= H5AC__DIRTIED_FLAG;
} /* end else */
@@ -474,7 +475,7 @@ H5FA_get(const H5FA_t *fa, hsize_t idx, void *elmt))
/* Check for paged data block */
if(!dblock->npages)
/* Retrieve element from data block */
- HDmemcpy(elmt, ((uint8_t *)dblock->elmts) + (hdr->cparam.cls->nat_elmt_size * idx), hdr->cparam.cls->nat_elmt_size);
+ H5MM_memcpy(elmt, ((uint8_t *)dblock->elmts) + (hdr->cparam.cls->nat_elmt_size * idx), hdr->cparam.cls->nat_elmt_size);
else { /* paging */
size_t page_idx; /* Index of page within data block */
@@ -512,7 +513,7 @@ H5FA_get(const H5FA_t *fa, hsize_t idx, void *elmt))
H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block page, address = %llu", (unsigned long long)dblk_page_addr)
/* Retrieve element from data block */
- HDmemcpy(elmt, ((uint8_t *)dblk_page->elmts) + (hdr->cparam.cls->nat_elmt_size * elmt_idx), hdr->cparam.cls->nat_elmt_size);
+ H5MM_memcpy(elmt, ((uint8_t *)dblk_page->elmts) + (hdr->cparam.cls->nat_elmt_size * elmt_idx), hdr->cparam.cls->nat_elmt_size);
} /* end else */
} /* end else */
} /* end else */
diff --git a/src/H5FAcache.c b/src/H5FAcache.c
index 1f199e9..f440efe 100644
--- a/src/H5FAcache.c
+++ b/src/H5FAcache.c
@@ -41,6 +41,7 @@
#include "H5Eprivate.h" /* Error handling */
#include "H5FApkg.h" /* Fixed Arrays */
#include "H5MFprivate.h" /* File memory management */
+#include "H5MMprivate.h" /* Memory management */
#include "H5VMprivate.h" /* Vectors and arrays */
#include "H5WBprivate.h" /* Wrapped Buffers */
@@ -409,7 +410,7 @@ H5FA__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED le
HDassert(hdr);
/* Magic number */
- HDmemcpy(image, H5FA_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC);
+ H5MM_memcpy(image, H5FA_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC);
image += H5_SIZEOF_MAGIC;
/* Version # */
@@ -693,7 +694,7 @@ H5FA__cache_dblock_deserialize(const void *_image, size_t len,
/* Page initialization flags */
if(dblock->npages > 0) {
- HDmemcpy(dblock->dblk_page_init, image, dblock->dblk_page_init_size);
+ H5MM_memcpy(dblock->dblk_page_init, image, dblock->dblk_page_init_size);
image += dblock->dblk_page_init_size;
} /* end if */
@@ -797,7 +798,7 @@ H5FA__cache_dblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED
HDassert(dblock->hdr);
/* Magic number */
- HDmemcpy(image, H5FA_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC);
+ H5MM_memcpy(image, H5FA_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC);
image += H5_SIZEOF_MAGIC;
/* Version # */
@@ -812,7 +813,7 @@ H5FA__cache_dblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED
/* Page init flags */
if(dblock->npages > 0) {
/* Store the 'page init' bitmasks */
- HDmemcpy(image, dblock->dblk_page_init, dblock->dblk_page_init_size);
+ H5MM_memcpy(image, dblock->dblk_page_init, dblock->dblk_page_init_size);
image += dblock->dblk_page_init_size;
} /* end if */
diff --git a/src/H5FAhdr.c b/src/H5FAhdr.c
index 2e3db0b..8f29b83 100644
--- a/src/H5FAhdr.c
+++ b/src/H5FAhdr.c
@@ -39,6 +39,7 @@
#include "H5Eprivate.h" /* Error handling */
#include "H5FApkg.h" /* Fixed Arrays */
#include "H5MFprivate.h" /* File memory management */
+#include "H5MMprivate.h" /* Memory management */
/****************/
@@ -207,7 +208,7 @@ H5FA__hdr_create(H5F_t *f, const H5FA_create_t *cparam, void *ctx_udata))
hdr->dblk_addr = HADDR_UNDEF;
/* Set the creation parameters for the array */
- HDmemcpy(&hdr->cparam, cparam, sizeof(hdr->cparam));
+ H5MM_memcpy(&hdr->cparam, cparam, sizeof(hdr->cparam));
/* Finish initializing fixed array header */
if(H5FA__hdr_init(hdr, ctx_udata) < 0)
diff --git a/src/H5FAstat.c b/src/H5FAstat.c
index 3c06855..49a56a9 100644
--- a/src/H5FAstat.c
+++ b/src/H5FAstat.c
@@ -38,6 +38,7 @@
#include "H5private.h" /* Generic Functions */
#include "H5Eprivate.h" /* Error handling */
#include "H5FApkg.h" /* Fixed Arrays */
+#include "H5MMprivate.h" /* Memory management */
/****************/
@@ -105,7 +106,7 @@ HDfprintf(stderr, "%s: Called\n", FUNC);
HDassert(stats);
/* Copy fixed array statistics */
- HDmemcpy(stats, &fa->hdr->stats, sizeof(fa->hdr->stats));
+ H5MM_memcpy(stats, &fa->hdr->stats, sizeof(fa->hdr->stats));
END_FUNC(PRIV) /* end H5FA_get_stats() */
diff --git a/src/H5FAtest.c b/src/H5FAtest.c
index 27cd8b7..e55d408 100644
--- a/src/H5FAtest.c
+++ b/src/H5FAtest.c
@@ -315,7 +315,7 @@ H5FA__test_debug(FILE *stream, int indent, int fwidth, hsize_t idx,
HDassert(elmt);
/* Print element */
- sprintf(temp_str, "Element #%llu:", (unsigned long long)idx);
+ HDsprintf(temp_str, "Element #%llu:", (unsigned long long)idx);
HDfprintf(stream, "%*s%-*s %llu\n", indent, "", fwidth, temp_str,
(unsigned long long)*(const uint64_t *)elmt);
diff --git a/src/H5FD.c b/src/H5FD.c
index 5585f37..61969b6 100644
--- a/src/H5FD.c
+++ b/src/H5FD.c
@@ -293,7 +293,7 @@ H5FD_register(const void *_cls, size_t size, hbool_t app_ref)
/* Copy the class structure so the caller can reuse or free it */
if(NULL == (saved = (H5FD_class_t *)H5MM_malloc(size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5I_INVALID_HID, "memory allocation failed for file driver class struct")
- HDmemcpy(saved, cls, size);
+ H5MM_memcpy(saved, cls, size);
/* Create the new class ID */
if((ret_value = H5I_register(H5I_VFL, saved, app_ref)) < 0)
@@ -1367,7 +1367,7 @@ H5FD_get_fs_type_map(const H5FD_t *file, H5FD_mem_t *type_map)
} /* end if */
else
/* Copy class's default free space type mapping */
- HDmemcpy(type_map, file->cls->fl_map, sizeof(file->cls->fl_map));
+ H5MM_memcpy(type_map, file->cls->fl_map, sizeof(file->cls->fl_map));
done:
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5FDcore.c b/src/H5FDcore.c
index d1a17cd..6db8af6 100644
--- a/src/H5FDcore.c
+++ b/src/H5FDcore.c
@@ -848,7 +848,7 @@ H5FD__core_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr
HGOTO_ERROR(H5E_FILE, H5E_CANTCOPY, NULL, "image_memcpy callback failed")
} /* end if */
else
- HDmemcpy(file->mem, file_image_info.buffer, size);
+ H5MM_memcpy(file->mem, file_image_info.buffer, size);
} /* end if */
/* Read in existing data from the file if there is no image */
else {
@@ -1300,7 +1300,7 @@ H5FD__core_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU
nbytes = MIN(size,(size_t)(file->eof-addr));
#endif /* NDEBUG */
- HDmemcpy(buf, file->mem + addr, nbytes);
+ H5MM_memcpy(buf, file->mem + addr, nbytes);
size -= nbytes;
addr += nbytes;
buf = (char *)buf + nbytes;
@@ -1386,7 +1386,7 @@ H5FD__core_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UN
}
/* Write from BUF to memory */
- HDmemcpy(file->mem + addr, buf, size);
+ H5MM_memcpy(file->mem + addr, buf, size);
/* Mark memory buffer as modified */
file->dirty = TRUE;
diff --git a/src/H5FDdirect.c b/src/H5FDdirect.c
index 10c368a..33a0ef4 100644
--- a/src/H5FDdirect.c
+++ b/src/H5FDdirect.c
@@ -422,7 +422,7 @@ H5FD_direct_fapl_copy(const void *_old_fa)
HDassert(new_fa);
/* Copy the general information */
- HDmemcpy(new_fa, old_fa, sizeof(H5FD_direct_fapl_t));
+ H5MM_memcpy(new_fa, old_fa, sizeof(H5FD_direct_fapl_t));
FUNC_LEAVE_NOAPI(new_fa)
} /* end H5FD_direct_fapl_copy() */
@@ -976,12 +976,12 @@ H5FD_direct_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UN
* next section of data. */
p2 = (unsigned char*)copy_buf + copy_offset;
if((copy_size + copy_offset) <= alloc_size) {
- HDmemcpy(buf, p2, copy_size);
+ H5MM_memcpy(buf, p2, copy_size);
buf = (unsigned char *)buf + copy_size;
copy_size = 0;
} /* end if */
else {
- HDmemcpy(buf, p2, alloc_size - copy_offset);
+ H5MM_memcpy(buf, p2, alloc_size - copy_offset);
buf = (unsigned char*)buf + alloc_size - copy_offset;
copy_size -= alloc_size - copy_offset;
copy_offset = 0;
@@ -1189,11 +1189,11 @@ H5FD_direct_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_U
*/
p1 = (unsigned char *)copy_buf + copy_offset;
if((copy_size + copy_offset) <= alloc_size) {
- HDmemcpy(p1, p3, copy_size);
+ H5MM_memcpy(p1, p3, copy_size);
copy_size = 0;
} /* end if */
else {
- HDmemcpy(p1, p3, alloc_size - copy_offset);
+ H5MM_memcpy(p1, p3, alloc_size - copy_offset);
p3 = (const unsigned char *)p3 + (alloc_size - copy_offset);
copy_size -= alloc_size - copy_offset;
copy_offset = 0;
diff --git a/src/H5FDfamily.c b/src/H5FDfamily.c
index 4d40cf3..c8893f9 100644
--- a/src/H5FDfamily.c
+++ b/src/H5FDfamily.c
@@ -411,7 +411,7 @@ H5FD_family_fapl_copy(const void *_old_fa)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
/* Copy the fields of the structure */
- HDmemcpy(new_fa, old_fa, sizeof(H5FD_family_fapl_t));
+ H5MM_memcpy(new_fa, old_fa, sizeof(H5FD_family_fapl_t));
/* Deep copy the property list objects in the structure */
if(old_fa->memb_fapl_id==H5P_FILE_ACCESS_DEFAULT) {
@@ -715,7 +715,7 @@ H5FD_family_open(const char *name, unsigned flags, hid_t fapl_id,
(0==file->nmembs ? flags : t_flags), file->memb_fapl_id, HADDR_UNDEF);
} H5E_END_TRY;
if (!file->memb[file->nmembs]) {
- if (0==file->nmembs)
+ if (0 == file->nmembs)
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open member file")
H5E_clear_stack(NULL);
break;
@@ -723,7 +723,7 @@ H5FD_family_open(const char *name, unsigned flags, hid_t fapl_id,
file->nmembs++;
}
- /* If the file is reopened and there's only one member file existing, this file maybe
+ /* If the file is reopened and there's only one member file existing, this file may be
* smaller than the size specified through H5Pset_fapl_family(). Update the actual
* member size.
*/
diff --git a/src/H5FDlog.c b/src/H5FDlog.c
index 655d7d3..06a0e61 100644
--- a/src/H5FDlog.c
+++ b/src/H5FDlog.c
@@ -405,7 +405,7 @@ H5FD_log_fapl_copy(const void *_old_fa)
HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, NULL, "unable to allocate log file FAPL")
/* Copy the general information */
- HDmemcpy(new_fa, old_fa, sizeof(H5FD_log_fapl_t));
+ H5MM_memcpy(new_fa, old_fa, sizeof(H5FD_log_fapl_t));
/* Deep copy the log file name */
if(old_fa->logfile != NULL)
diff --git a/src/H5FDmpio.c b/src/H5FDmpio.c
index 614c7ba..50b5676 100644
--- a/src/H5FDmpio.c
+++ b/src/H5FDmpio.c
@@ -764,7 +764,7 @@ if(H5FD_mpio_Debug[(int)'t'])
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
/* Copy the general information */
- HDmemcpy(new_fa, old_fa, sizeof(H5FD_mpio_fapl_t));
+ H5MM_memcpy(new_fa, old_fa, sizeof(H5FD_mpio_fapl_t));
/* Duplicate communicator and Info object. */
if(H5FD_mpi_comm_info_dup(old_fa->comm, old_fa->info, &new_fa->comm, &new_fa->info) < 0)
diff --git a/src/H5FDmulti.c b/src/H5FDmulti.c
index fac0909..6cfef55 100644
--- a/src/H5FDmulti.c
+++ b/src/H5FDmulti.c
@@ -981,8 +981,7 @@ H5FD_multi_fapl_free(void *_fa)
*-------------------------------------------------------------------------
*/
static H5FD_t *
-H5FD_multi_open(const char *name, unsigned flags, hid_t fapl_id,
- haddr_t maxaddr)
+H5FD_multi_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr)
{
H5FD_multi_t *file=NULL;
hid_t close_fapl=-1;
@@ -996,7 +995,7 @@ H5FD_multi_open(const char *name, unsigned flags, hid_t fapl_id,
/* Check arguments */
if (!name || !*name)
H5Epush_ret(func, H5E_ERR_CLS, H5E_ARGS, H5E_BADVALUE, "invalid file name", NULL)
- if (0==maxaddr || HADDR_UNDEF==maxaddr)
+ if (0 == maxaddr || HADDR_UNDEF == maxaddr)
H5Epush_ret(func, H5E_ERR_CLS, H5E_ARGS, H5E_BADRANGE, "bogus maxaddr", NULL)
/*
@@ -1007,41 +1006,41 @@ H5FD_multi_open(const char *name, unsigned flags, hid_t fapl_id,
*/
if(NULL == (file = (H5FD_multi_t *)calloc((size_t)1, sizeof(H5FD_multi_t))))
H5Epush_ret(func, H5E_ERR_CLS, H5E_RESOURCE, H5E_NOSPACE, "memory allocation failed", NULL)
- if(H5P_FILE_ACCESS_DEFAULT==fapl_id || H5FD_MULTI!=H5Pget_driver(fapl_id)) {
+ if(H5P_FILE_ACCESS_DEFAULT == fapl_id || H5FD_MULTI != H5Pget_driver(fapl_id)) {
close_fapl = fapl_id = H5Pcreate(H5P_FILE_ACCESS);
- if(H5Pset_fapl_multi(fapl_id, NULL, NULL, NULL, NULL, TRUE)<0)
+ if(H5Pset_fapl_multi(fapl_id, NULL, NULL, NULL, NULL, TRUE) < 0)
H5Epush_goto(func, H5E_ERR_CLS, H5E_FILE, H5E_CANTSET, "can't set property value", error)
}
fa = (const H5FD_multi_fapl_t *)H5Pget_driver_info(fapl_id);
assert(fa);
ALL_MEMBERS(mt) {
- file->fa.memb_map[mt] = fa->memb_map[mt];
- file->fa.memb_addr[mt] = fa->memb_addr[mt];
- if (fa->memb_fapl[mt]>=0)
- H5Iinc_ref(fa->memb_fapl[mt]);
+ file->fa.memb_map[mt] = fa->memb_map[mt];
+ file->fa.memb_addr[mt] = fa->memb_addr[mt];
+ if (fa->memb_fapl[mt] >= 0)
+ H5Iinc_ref(fa->memb_fapl[mt]);
file->fa.memb_fapl[mt] = fa->memb_fapl[mt];
- if (fa->memb_name[mt])
- file->fa.memb_name[mt] = my_strdup(fa->memb_name[mt]);
- else
- file->fa.memb_name[mt] = NULL;
+ if (fa->memb_name[mt])
+ file->fa.memb_name[mt] = my_strdup(fa->memb_name[mt]);
+ else
+ file->fa.memb_name[mt] = NULL;
} END_MEMBERS;
file->fa.relax = fa->relax;
file->flags = flags;
file->name = my_strdup(name);
- if (close_fapl>=0)
- if(H5Pclose(close_fapl)<0)
+ if (close_fapl >= 0)
+ if(H5Pclose(close_fapl) < 0)
H5Epush_goto(func, H5E_ERR_CLS, H5E_FILE, H5E_CANTCLOSEOBJ, "can't close property list", error)
/* Compute derived properties and open member files */
- if (compute_next(file)<0)
+ if (compute_next(file) < 0)
H5Epush_goto(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "compute_next() failed", error);
- if (open_members(file)<0)
+ if (open_members(file) < 0)
H5Epush_goto(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "open_members() failed", error);
/* We must have opened at least the superblock file */
- if (H5FD_MEM_DEFAULT==(m=file->fa.memb_map[H5FD_MEM_SUPER]))
+ if (H5FD_MEM_DEFAULT == (m = file->fa.memb_map[H5FD_MEM_SUPER]))
m = H5FD_MEM_SUPER;
- if (NULL==file->memb[m])
+ if (NULL == file->memb[m])
goto error;
return (H5FD_t*)file;
@@ -1049,13 +1048,14 @@ H5FD_multi_open(const char *name, unsigned flags, hid_t fapl_id,
error:
/* Cleanup and fail */
if (file) {
- ALL_MEMBERS(mt) {
- if (file->memb[mt]) (void)H5FDclose(file->memb[mt]);
- if (file->fa.memb_fapl[mt]>=0) (void)H5Idec_ref(file->fa.memb_fapl[mt]);
- if (file->fa.memb_name[mt]) free(file->fa.memb_name[mt]);
- } END_MEMBERS;
- if (file->name) free(file->name);
- free(file);
+ ALL_MEMBERS(mt) {
+ if (file->memb[mt]) (void)H5FDclose(file->memb[mt]);
+ if (file->fa.memb_fapl[mt] >= 0) (void)H5Idec_ref(file->fa.memb_fapl[mt]);
+ if (file->fa.memb_name[mt]) free(file->fa.memb_name[mt]);
+ } END_MEMBERS;
+ if (file->name)
+ free(file->name);
+ free(file);
}
return NULL;
}
diff --git a/src/H5FL.c b/src/H5FL.c
index 89a580a..a662713 100644
--- a/src/H5FL.c
+++ b/src/H5FL.c
@@ -642,7 +642,7 @@ H5FL__reg_term(void)
tmp = H5FL_reg_gc_head.first->next;
#ifdef H5FL_DEBUG
-printf("%s: head->name = %s, head->allocated = %d\n", FUNC, H5FL_reg_gc_head.first->list->name, (int)H5FL_reg_gc_head.first->list->allocated);
+HDprintf("%s: head->name = %s, head->allocated = %d\n", FUNC, H5FL_reg_gc_head.first->list->name, (int)H5FL_reg_gc_head.first->list->allocated);
#endif /* H5FL_DEBUG */
/* Check if the list has allocations outstanding */
if(H5FL_reg_gc_head.first->list->allocated > 0) {
@@ -1142,7 +1142,7 @@ H5FL_blk_realloc(H5FL_blk_head_t *head, void *block, size_t new_size H5FL_TRACK_
if((ret_value=H5FL_blk_malloc(head,new_size H5FL_TRACK_INFO_INT))==NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for block")
blk_size=MIN(new_size,temp->size);
- HDmemcpy(ret_value,block,blk_size);
+ H5MM_memcpy(ret_value,block,blk_size);
H5FL_blk_free(head,block);
} /* end if */
else {
@@ -1312,7 +1312,7 @@ H5FL__blk_term(void)
tmp = H5FL_blk_gc_head.first->next;
#ifdef H5FL_DEBUG
-printf("%s: head->name = %s, head->allocated = %d\n", FUNC, H5FL_blk_gc_head.first->pq->name, (int)H5FL_blk_gc_head.first->pq->allocated);
+HDprintf("%s: head->name = %s, head->allocated = %d\n", FUNC, H5FL_blk_gc_head.first->pq->name, (int)H5FL_blk_gc_head.first->pq->allocated);
#endif /* H5FL_DEBUG */
/* Check if the list has allocations outstanding */
@@ -1630,7 +1630,7 @@ H5FL_arr_realloc(H5FL_arr_head_t *head, void * obj, size_t new_elem)
/* Copy the appropriate amount of elements */
blk_size = head->list_arr[MIN(temp->nelem, new_elem)].size;
- HDmemcpy(ret_value, obj, blk_size);
+ H5MM_memcpy(ret_value, obj, blk_size);
/* Free the old block */
H5FL_arr_free(head, obj);
@@ -1780,7 +1780,7 @@ H5FL__arr_term(void)
/* Check if the list has allocations outstanding */
#ifdef H5FL_DEBUG
-printf("%s: head->name = %s, head->allocated = %d\n", FUNC, H5FL_arr_gc_head.first->list->name, (int)H5FL_arr_gc_head.first->list->allocated);
+HDprintf("%s: head->name = %s, head->allocated = %d\n", FUNC, H5FL_arr_gc_head.first->list->name, (int)H5FL_arr_gc_head.first->list->allocated);
#endif /* H5FL_DEBUG */
if(H5FL_arr_gc_head.first->list->allocated > 0) {
/* Add free list to the list of nodes with allocations open still */
@@ -2408,7 +2408,7 @@ H5FL__fac_term_all(void)
tmp = H5FL_fac_gc_head.first->next;
#ifdef H5FL_DEBUG
-printf("%s: head->size = %d, head->allocated = %d\n", FUNC, (int)H5FL_fac_gc_head.first->list->size, (int)H5FL_fac_gc_head.first->list->allocated);
+HDprintf("%s: head->size = %d, head->allocated = %d\n", FUNC, (int)H5FL_fac_gc_head.first->list->size, (int)H5FL_fac_gc_head.first->list->allocated);
#endif /* H5FL_DEBUG */
/* The list cannot have any allocations outstanding */
diff --git a/src/H5FS.c b/src/H5FS.c
index 8fee634..dbcb6b5 100644
--- a/src/H5FS.c
+++ b/src/H5FS.c
@@ -36,6 +36,7 @@
#include "H5Eprivate.h" /* Error handling */
#include "H5FSpkg.h" /* File free space */
#include "H5MFprivate.h" /* File memory management */
+#include "H5MMprivate.h" /* Memory management */
/****************/
@@ -615,7 +616,7 @@ H5FS__new(const H5F_t *f, uint16_t nclasses, const H5FS_section_class_t *classes
HDassert(u == classes[u]->type);
/* Copy the class information into the free space manager */
- HDmemcpy(&fspace->sect_cls[u], classes[u], sizeof(H5FS_section_class_t));
+ H5MM_memcpy(&fspace->sect_cls[u], classes[u], sizeof(H5FS_section_class_t));
/* Call the class initialization routine, if there is one */
if(fspace->sect_cls[u].init_cls)
diff --git a/src/H5FScache.c b/src/H5FScache.c
index ac0874e..7525a9a 100644
--- a/src/H5FScache.c
+++ b/src/H5FScache.c
@@ -38,6 +38,7 @@
#include "H5Fprivate.h" /* File */
#include "H5FSpkg.h" /* File free space */
#include "H5MFprivate.h" /* File memory management */
+#include "H5MMprivate.h" /* Memory management */
#include "H5VMprivate.h" /* Vectors and arrays */
#include "H5WBprivate.h" /* Wrapped Buffers */
@@ -707,7 +708,7 @@ H5FS__cache_hdr_serialize(const H5F_t *f, void *_image, size_t len,
(fspace->alloc_sect_size == (size_t)fspace->sect_size)));
/* Magic number */
- HDmemcpy(image, H5FS_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC);
+ H5MM_memcpy(image, H5FS_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC);
image += H5_SIZEOF_MAGIC;
/* Version # */
@@ -1265,7 +1266,7 @@ H5FS__cache_sinfo_serialize(const H5F_t *f, void *_image, size_t len,
HDassert(fspace->sect_cls);
/* Magic number */
- HDmemcpy(image, H5FS_SINFO_MAGIC, (size_t)H5_SIZEOF_MAGIC);
+ H5MM_memcpy(image, H5FS_SINFO_MAGIC, (size_t)H5_SIZEOF_MAGIC);
image += H5_SIZEOF_MAGIC;
/* Version # */
diff --git a/src/H5Faccum.c b/src/H5Faccum.c
index 0b33f8e..8d7852b 100644
--- a/src/H5Faccum.c
+++ b/src/H5Faccum.c
@@ -38,6 +38,7 @@
#include "H5Eprivate.h" /* Error handling */
#include "H5Fpkg.h" /* File access */
#include "H5FDprivate.h" /* File drivers */
+#include "H5MMprivate.h" /* Memory management */
#include "H5VMprivate.h" /* Vectors and arrays */
@@ -198,7 +199,7 @@ H5F__accum_read(H5F_t *f, H5FD_mem_t map_type, haddr_t addr,
} /* end if */
/* Copy the data out of the buffer */
- HDmemcpy(buf, accum->buf + (addr - new_addr), size);
+ H5MM_memcpy(buf, accum->buf + (addr - new_addr), size);
/* Adjust the accumulator address & size */
accum->loc = new_addr;
@@ -250,7 +251,7 @@ H5F__accum_read(H5F_t *f, H5FD_mem_t map_type, haddr_t addr,
} /* end else */
/* Copy the dirty region to buffer */
- HDmemcpy((unsigned char *)buf + buf_off, (unsigned char *)accum->buf + accum->dirty_off + dirty_off, overlap_size);
+ H5MM_memcpy((unsigned char *)buf + buf_off, (unsigned char *)accum->buf + accum->dirty_off + dirty_off, overlap_size);
} /* end if */
} /* end else */
} /* end if */
@@ -457,7 +458,7 @@ H5F__accum_write(H5F_t *f, H5FD_mem_t map_type, haddr_t addr,
HDmemmove(accum->buf + size, accum->buf, accum->size);
/* Copy the new metadata at the front */
- HDmemcpy(accum->buf, buf, size);
+ H5MM_memcpy(accum->buf, buf, size);
/* Set the new size & location of the metadata accumulator */
accum->loc = addr;
@@ -479,7 +480,7 @@ H5F__accum_write(H5F_t *f, H5FD_mem_t map_type, haddr_t addr,
HGOTO_ERROR(H5E_IO, H5E_CANTRESIZE, FAIL, "can't adjust metadata accumulator")
/* Copy the new metadata to the end */
- HDmemcpy(accum->buf + accum->size, buf, size);
+ H5MM_memcpy(accum->buf + accum->size, buf, size);
/* Adjust the dirty region and mark accumulator dirty */
if(accum->dirty)
@@ -502,7 +503,7 @@ H5F__accum_write(H5F_t *f, H5FD_mem_t map_type, haddr_t addr,
size_t dirty_off = (size_t)(addr - accum->loc);
/* Copy the new metadata to the proper location within the accumulator */
- HDmemcpy(accum->buf + dirty_off, buf, size);
+ H5MM_memcpy(accum->buf + dirty_off, buf, size);
/* Adjust the dirty region and mark accumulator dirty */
if(accum->dirty) {
@@ -545,7 +546,7 @@ H5F__accum_write(H5F_t *f, H5FD_mem_t map_type, haddr_t addr,
HDmemmove(accum->buf + size, accum->buf + old_offset, (accum->size - old_offset));
/* Copy the new metadata at the front */
- HDmemcpy(accum->buf, buf, size);
+ H5MM_memcpy(accum->buf, buf, size);
/* Set the new size & location of the metadata accumulator */
accum->loc = addr;
@@ -582,7 +583,7 @@ H5F__accum_write(H5F_t *f, H5FD_mem_t map_type, haddr_t addr,
dirty_off = (size_t)(addr - accum->loc);
/* Copy the new metadata to the end */
- HDmemcpy(accum->buf + dirty_off, buf, size);
+ H5MM_memcpy(accum->buf + dirty_off, buf, size);
/* Set the new size of the metadata accumulator */
accum->size += add_size;
@@ -625,7 +626,7 @@ H5F__accum_write(H5F_t *f, H5FD_mem_t map_type, haddr_t addr,
} /* end if */
/* Copy the new metadata to the buffer */
- HDmemcpy(accum->buf, buf, size);
+ H5MM_memcpy(accum->buf, buf, size);
/* Set the new size & location of the metadata accumulator */
accum->loc = addr;
@@ -688,7 +689,7 @@ H5F__accum_write(H5F_t *f, H5FD_mem_t map_type, haddr_t addr,
accum->size = size;
/* Store the piece of metadata in the accumulator */
- HDmemcpy(accum->buf, buf, size);
+ H5MM_memcpy(accum->buf, buf, size);
/* Adjust the dirty region and mark accumulator dirty */
accum->dirty_off = 0;
@@ -721,7 +722,7 @@ H5F__accum_write(H5F_t *f, H5FD_mem_t map_type, haddr_t addr,
accum->size = size;
/* Store the piece of metadata in the accumulator */
- HDmemcpy(accum->buf, buf, size);
+ H5MM_memcpy(accum->buf, buf, size);
/* Adjust the dirty region and mark accumulator dirty */
accum->dirty_off = 0;
diff --git a/src/H5Fint.c b/src/H5Fint.c
index dd8774a..bb092f3 100644
--- a/src/H5Fint.c
+++ b/src/H5Fint.c
@@ -509,6 +509,7 @@ H5F__get_objects_cb(void *obj_ptr, hid_t obj_id, void *key)
case H5I_ERROR_CLASS:
case H5I_ERROR_MSG:
case H5I_ERROR_STACK:
+ case H5I_SPACE_SEL_ITER:
case H5I_NTYPES:
default:
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5_ITER_ERROR, "unknown or invalid data object")
@@ -853,7 +854,7 @@ htri_t
H5F__is_hdf5(const char *name, hid_t fapl_id)
{
H5FD_t *file = NULL; /* Low-level file struct */
- haddr_t sig_addr; /* Addess of hdf5 file signature */
+ haddr_t sig_addr = HADDR_UNDEF; /* Addess of hdf5 file signature */
htri_t ret_value = FAIL; /* Return value */
FUNC_ENTER_PACKAGE
@@ -863,7 +864,7 @@ H5F__is_hdf5(const char *name, hid_t fapl_id)
* should work with arbitrary VFDs, unlike H5Fis_hdf5().
*/
if(NULL == (file = H5FD_open(name, H5F_ACC_RDONLY, fapl_id, HADDR_UNDEF)))
- HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to open file")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to open file")
/* The file is an hdf5 file if the hdf5 file signature can be found */
if(H5FD_locate_signature(file, &sig_addr) < 0)
@@ -874,7 +875,7 @@ done:
/* Close the file */
if(file)
if(H5FD_close(file) < 0 && TRUE == ret_value)
- HDONE_ERROR(H5E_IO, H5E_CANTCLOSEFILE, FAIL, "unable to close file")
+ HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close file")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5F__is_hdf5() */
@@ -1362,19 +1363,10 @@ H5F__dest(H5F_t *f, hbool_t flush)
HDONE_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "can't close property list")
/* Clean up the cached VOL connector ID & info */
- if(f->shared->vol_info) {
- H5VL_class_t *connector; /* Pointer to connector */
-
- /* Retrieve the connector for the ID */
- if(NULL == (connector = (H5VL_class_t *)H5I_object(f->shared->vol_id)))
- /* Push error, but keep going*/
- HDONE_ERROR(H5E_FILE, H5E_BADTYPE, FAIL, "not a VOL connector ID")
-
- /* Free the connector info */
- if(H5VL_free_connector_info(connector, f->shared->vol_info) < 0)
+ if(f->shared->vol_info)
+ if(H5VL_free_connector_info(f->shared->vol_id, f->shared->vol_info) < 0)
/* Push error, but keep going*/
HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "unable to release VOL connector info object")
- } /* end if */
if(f->shared->vol_id > 0)
if(H5I_dec_ref(f->shared->vol_id) < 0)
/* Push error, but keep going*/
@@ -3261,7 +3253,7 @@ H5F_get_metadata_read_retry_info(H5F_t *file, H5F_retry_info_t *info)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
/* Copy the information */
- HDmemcpy(info->retries[j], file->shared->retries[i], tot_size);
+ H5MM_memcpy(info->retries[j], file->shared->retries[i], tot_size);
}
/* Increment location in info->retries[] array */
@@ -3343,7 +3335,7 @@ H5F__start_swmr_write(H5F_t *f)
HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "file superblock version - should be at least 3")
/* Check for correct file format version */
- if((f->shared->low_bound != H5F_LIBVER_V110) || (f->shared->high_bound != H5F_LIBVER_V110))
+ if((f->shared->low_bound < H5F_LIBVER_V110) || (f->shared->high_bound < H5F_LIBVER_V110))
HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "file format version does not support SWMR - needs to be 1.10 or greater")
/* Should not be marked for SWMR writing mode already */
@@ -3626,6 +3618,7 @@ H5F__get_file(void *obj, H5I_type_t type)
case H5I_ERROR_CLASS:
case H5I_ERROR_MSG:
case H5I_ERROR_STACK:
+ case H5I_SPACE_SEL_ITER:
case H5I_NTYPES:
default:
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object")
diff --git a/src/H5Fmpi.c b/src/H5Fmpi.c
index 6ddbfbb..5bbd717 100644
--- a/src/H5Fmpi.c
+++ b/src/H5Fmpi.c
@@ -94,7 +94,7 @@ H5F_get_mpi_handle(const H5F_t *f, MPI_File **f_handle)
FUNC_ENTER_NOAPI(FAIL)
- assert(f && f->shared);
+ HDassert(f && f->shared);
/* Dispatch to driver */
if ((ret_value = H5FD_get_vfd_handle(f->shared->lf, fapl, (void **)f_handle)) < 0)
diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h
index 5f7a1b2..e9b6c32 100644
--- a/src/H5Fprivate.h
+++ b/src/H5Fprivate.h
@@ -28,6 +28,7 @@ typedef struct H5F_t H5F_t;
#include "H5FDpublic.h" /* File drivers */
/* Private headers needed by this file */
+#include "H5MMprivate.h" /* Memory management */
#ifdef H5_HAVE_PARALLEL
#include "H5Pprivate.h" /* Property lists */
#endif /* H5_HAVE_PARALLEL */
@@ -134,7 +135,7 @@ typedef struct H5F_t H5F_t;
\
HDcompile_assert(sizeof(double) == 8); \
HDcompile_assert(sizeof(double) == sizeof(uint64_t)); \
- HDmemcpy(&_n, &n, sizeof(double)); \
+ H5MM_memcpy(&_n, &n, sizeof(double)); \
for(_u = 0; _u < sizeof(uint64_t); _u++, _n >>= 8) \
*_p++ = (uint8_t)(_n & 0xff); \
(p) = (uint8_t *)(p) + 8; \
@@ -159,16 +160,16 @@ typedef struct H5F_t H5F_t;
(i) |= (uint16_t)((*(p) & 0xff) << 8); (p)++; \
}
-# define INT32DECODE(p, i) { \
- (i) = ((int32_t)(*(p) & (unsigned)0xff)); (p)++; \
- (i) |= ((int32_t)(*(p) & (unsigned)0xff) << 8); (p)++; \
- (i) |= ((int32_t)(*(p) & (unsigned)0xff) << 16); (p)++; \
- (i) |= ((int32_t)(((*(p) & (unsigned)0xff) << 24) | \
- ((*(p) & (unsigned)0x80) ? (unsigned)(~0xffffffff) : (unsigned)0x0))); (p)++; \
+# define INT32DECODE(p, i) { \
+ (i) = ((int32_t)(*(p) & 0xff)); (p)++; \
+ (i) |= ((int32_t)(*(p) & 0xff) << 8); (p)++; \
+ (i) |= ((int32_t)(*(p) & 0xff) << 16); (p)++; \
+ (i) |= ((int32_t)(((*(p) & (unsigned)0xff) << 24) | \
+ ((*(p) & 0x80) ? ~0xffffffffULL : 0x0ULL))); (p)++; \
}
-# define UINT32DECODE(p, i) { \
- (i) = (uint32_t)(*(p) & 0xff); (p)++; \
+# define UINT32DECODE(p, i) { \
+ (i) = (uint32_t)(*(p) & 0xff); (p)++; \
(i) |= ((uint32_t)(*(p) & 0xff) << 8); (p)++; \
(i) |= ((uint32_t)(*(p) & 0xff) << 16); (p)++; \
(i) |= ((uint32_t)(*(p) & 0xff) << 24); (p)++; \
@@ -240,7 +241,7 @@ typedef struct H5F_t H5F_t;
(p) += 8; \
for(_u = 0; _u < sizeof(uint64_t); _u++) \
_n = (_n << 8) | *(--p); \
- HDmemcpy(&(n), &_n, sizeof(double)); \
+ H5MM_memcpy(&(n), &_n, sizeof(double)); \
(p) += 8; \
}
@@ -701,8 +702,9 @@ typedef enum H5F_mem_page_t {
/* Type of prefix for opening prefixed files */
typedef enum H5F_prefix_open_t {
- H5F_PREFIX_VDS, /* Virtual dataset prefix */
- H5F_PREFIX_ELINK /* External link prefix */
+ H5F_PREFIX_VDS = 0, /* Virtual dataset prefix */
+ H5F_PREFIX_ELINK = 1, /* External link prefix */
+ H5F_PREFIX_EFILE = 2 /* External file prefix */
} H5F_prefix_open_t;
diff --git a/src/H5Fpublic.h b/src/H5Fpublic.h
index 9f1ed01..dd794e4 100644
--- a/src/H5Fpublic.h
+++ b/src/H5Fpublic.h
@@ -178,11 +178,12 @@ typedef enum H5F_libver_t {
H5F_LIBVER_ERROR = -1,
H5F_LIBVER_EARLIEST = 0, /* Use the earliest possible format for storing objects */
H5F_LIBVER_V18 = 1, /* Use the latest v18 format for storing objects */
- H5F_LIBVER_V110 = 2, /* Use the latest v10 format for storing objects */
+ H5F_LIBVER_V110 = 2, /* Use the latest v110 format for storing objects */
+ H5F_LIBVER_V112 = 3, /* Use the latest v112 format for storing objects */
H5F_LIBVER_NBOUNDS
} H5F_libver_t;
-#define H5F_LIBVER_LATEST H5F_LIBVER_V110
+#define H5F_LIBVER_LATEST H5F_LIBVER_V112
/* File space handling strategy */
typedef enum H5F_fspace_strategy_t {
@@ -232,9 +233,11 @@ H5_DLL hid_t H5Fopen(const char *filename, unsigned flags,
H5_DLL hid_t H5Freopen(hid_t file_id);
H5_DLL herr_t H5Fflush(hid_t object_id, H5F_scope_t scope);
H5_DLL herr_t H5Fclose(hid_t file_id);
+H5_DLL herr_t H5Fdelete(const char *filename, hid_t fapl_id);
H5_DLL hid_t H5Fget_create_plist(hid_t file_id);
H5_DLL hid_t H5Fget_access_plist(hid_t file_id);
H5_DLL herr_t H5Fget_intent(hid_t file_id, unsigned *intent);
+H5_DLL herr_t H5Fget_fileno(hid_t file_id, unsigned long *fileno);
H5_DLL ssize_t H5Fget_obj_count(hid_t file_id, unsigned types);
H5_DLL ssize_t H5Fget_obj_ids(hid_t file_id, unsigned types, size_t max_objs, hid_t *obj_id_list);
H5_DLL herr_t H5Fget_vfd_handle(hid_t file_id, hid_t fapl, void **file_handle);
diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c
index 489cc21..ef52844 100644
--- a/src/H5Fsuper.c
+++ b/src/H5Fsuper.c
@@ -76,6 +76,7 @@ H5FL_DEFINE(H5F_super_t);
static const unsigned HDF5_superblock_ver_bounds[] = {
HDF5_SUPERBLOCK_VERSION_DEF, /* H5F_LIBVER_EARLIEST */
HDF5_SUPERBLOCK_VERSION_2, /* H5F_LIBVER_V18 */
+ HDF5_SUPERBLOCK_VERSION_3, /* H5F_LIBVER_V110 */
HDF5_SUPERBLOCK_VERSION_LATEST /* H5F_LIBVER_LATEST */
};
@@ -512,15 +513,12 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read)
#endif /* H5_HAVE_PARALLEL */
/* Check if superblock address is different from base address and adjust
- * base address and "end of address" address if so.
+ * base address and "end of file" address if so.
*/
if(!H5F_addr_eq(super_addr, sblock->base_addr)) {
- /* Check if the superblock moved earlier in the file */
- if(H5F_addr_lt(super_addr, sblock->base_addr))
- udata.stored_eof -= (sblock->base_addr - super_addr);
- else
- /* The superblock moved later in the file */
- udata.stored_eof += (super_addr - sblock->base_addr);
+ /* If the superblock moved in the file, adjust the EOF */
+ /* (Handles moving earlier & later) */
+ udata.stored_eof -= (sblock->base_addr - super_addr);
/* Adjust base address for offsets of the HDF5 data in the file */
sblock->base_addr = super_addr;
@@ -555,7 +553,7 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read)
/* Set the B-tree internal node values, etc */
if(H5P_set(c_plist, H5F_CRT_BTREE_RANK_NAME, udata.btree_k) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set rank for btree internal nodes")
- HDmemcpy(sblock->btree_k, udata.btree_k, sizeof(unsigned) * (size_t)H5B_NUM_BTREE_ID);
+ H5MM_memcpy(sblock->btree_k, udata.btree_k, sizeof(unsigned) * (size_t)H5B_NUM_BTREE_ID);
} /* end if */
else {
/* Get the (default) B-tree internal node values, etc */
diff --git a/src/H5Fsuper_cache.c b/src/H5Fsuper_cache.c
index 361f8a1..125d6cf 100644
--- a/src/H5Fsuper_cache.c
+++ b/src/H5Fsuper_cache.c
@@ -269,7 +269,7 @@ H5F__drvrinfo_prefix_decode(H5O_drvinfo_t *drvrinfo, char *drv_name,
/* Driver name and/or version */
if(drv_name) {
- HDmemcpy(drv_name, (const char *)image, (size_t)8);
+ H5MM_memcpy(drv_name, (const char *)image, (size_t)8);
drv_name[8] = '\0';
image += 8; /* advance past name/version */
} /* end if */
@@ -682,7 +682,7 @@ H5F__cache_superblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNU
HDassert(sblock->cache_info.flush_me_last);
/* Encode the common portion of the file superblock for all versions */
- HDmemcpy(image, H5F_SIGNATURE, (size_t)H5F_SIGNATURE_LEN);
+ H5MM_memcpy(image, H5F_SIGNATURE, (size_t)H5F_SIGNATURE_LEN);
image += H5F_SIGNATURE_LEN;
*image++ = (uint8_t)sblock->super_vers;
diff --git a/src/H5G.c b/src/H5G.c
index 20df130..fdf613c 100644
--- a/src/H5G.c
+++ b/src/H5G.c
@@ -320,7 +320,6 @@ H5Gcreate2(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id,
void *grp = NULL; /* Structure for new group */
H5VL_object_t *vol_obj = NULL; /* object token of loc_id */
H5VL_loc_params_t loc_params;
- H5P_genplist_t *plist; /* Property list pointer */
hid_t ret_value = H5I_INVALID_HID; /* Return value */
FUNC_ENTER_API(H5I_INVALID_HID)
@@ -350,12 +349,6 @@ H5Gcreate2(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id,
if(H5CX_set_apl(&gapl_id, H5P_CLS_GACC, loc_id, TRUE) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info")
- /* Get the gcpl structure and set the link properties on it */
- if(NULL == (plist = (H5P_genplist_t *)H5I_object(gcpl_id)))
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5I_INVALID_HID, "can't find object for ID")
- if(H5P_set(plist, H5VL_PROP_GRP_LCPL_ID, &lcpl_id) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set property value for lcpl id")
-
/* Get the location object */
if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier")
@@ -365,7 +358,7 @@ H5Gcreate2(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id,
loc_params.obj_type = H5I_get_type(loc_id);
/* Create the group */
- if(NULL == (grp = H5VL_group_create(vol_obj, &loc_params, name, gcpl_id, gapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)))
+ if(NULL == (grp = H5VL_group_create(vol_obj, &loc_params, name, lcpl_id, gcpl_id, gapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)))
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5I_INVALID_HID, "unable to create group")
/* Get an atom for the group */
@@ -444,7 +437,7 @@ H5Gcreate_anon(hid_t loc_id, hid_t gcpl_id, hid_t gapl_id)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier")
/* Create the group */
- if(NULL == (grp = H5VL_group_create(vol_obj, &loc_params, NULL, gcpl_id, gapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)))
+ if(NULL == (grp = H5VL_group_create(vol_obj, &loc_params, NULL, H5P_LINK_CREATE_DEFAULT, gcpl_id, gapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)))
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5I_INVALID_HID, "unable to create group")
/* Get an atom for the group */
diff --git a/src/H5Gbtree2.c b/src/H5Gbtree2.c
index 721d591..71e0b2d 100644
--- a/src/H5Gbtree2.c
+++ b/src/H5Gbtree2.c
@@ -35,6 +35,7 @@
#include "H5private.h" /* Generic Functions */
#include "H5Eprivate.h" /* Error handling */
#include "H5Gpkg.h" /* Groups */
+#include "H5MMprivate.h" /* Memory management */
/****************/
@@ -206,7 +207,7 @@ H5G_dense_btree2_name_store(void *_nrecord, const void *_udata)
/* Copy user information info native record */
nrecord->hash = udata->common.name_hash;
- HDmemcpy(nrecord->id, udata->id, (size_t)H5G_DENSE_FHEAP_ID_LEN);
+ H5MM_memcpy(nrecord->id, udata->id, (size_t)H5G_DENSE_FHEAP_ID_LEN);
FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5G_dense_btree2_name_store() */
@@ -305,7 +306,7 @@ H5G_dense_btree2_name_encode(uint8_t *raw, const void *_nrecord, void H5_ATTR_UN
/* Encode the record's fields */
UINT32ENCODE(raw, nrecord->hash)
- HDmemcpy(raw, nrecord->id, (size_t)H5G_DENSE_FHEAP_ID_LEN);
+ H5MM_memcpy(raw, nrecord->id, (size_t)H5G_DENSE_FHEAP_ID_LEN);
FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5G_dense_btree2_name_encode() */
@@ -333,7 +334,7 @@ H5G_dense_btree2_name_decode(const uint8_t *raw, void *_nrecord, void H5_ATTR_UN
/* Decode the record's fields */
UINT32DECODE(raw, nrecord->hash)
- HDmemcpy(nrecord->id, raw, (size_t)H5G_DENSE_FHEAP_ID_LEN);
+ H5MM_memcpy(nrecord->id, raw, (size_t)H5G_DENSE_FHEAP_ID_LEN);
FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5G_dense_btree2_name_decode() */
@@ -393,7 +394,7 @@ H5G_dense_btree2_corder_store(void *_nrecord, const void *_udata)
/* Copy user information info native record */
nrecord->corder = udata->common.corder;
- HDmemcpy(nrecord->id, udata->id, (size_t)H5G_DENSE_FHEAP_ID_LEN);
+ H5MM_memcpy(nrecord->id, udata->id, (size_t)H5G_DENSE_FHEAP_ID_LEN);
FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5G_dense_btree2_corder_store() */
@@ -469,7 +470,7 @@ H5G_dense_btree2_corder_encode(uint8_t *raw, const void *_nrecord, void H5_ATTR_
/* Encode the record's fields */
INT64ENCODE(raw, nrecord->corder)
- HDmemcpy(raw, nrecord->id, (size_t)H5G_DENSE_FHEAP_ID_LEN);
+ H5MM_memcpy(raw, nrecord->id, (size_t)H5G_DENSE_FHEAP_ID_LEN);
FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5G_dense_btree2_corder_encode() */
@@ -497,7 +498,7 @@ H5G_dense_btree2_corder_decode(const uint8_t *raw, void *_nrecord, void H5_ATTR_
/* Decode the record's fields */
INT64DECODE(raw, nrecord->corder)
- HDmemcpy(nrecord->id, raw, (size_t)H5G_DENSE_FHEAP_ID_LEN);
+ H5MM_memcpy(nrecord->id, raw, (size_t)H5G_DENSE_FHEAP_ID_LEN);
FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5G_dense_btree2_corder_decode() */
diff --git a/src/H5Gcache.c b/src/H5Gcache.c
index b447cad..0ffdc53 100644
--- a/src/H5Gcache.c
+++ b/src/H5Gcache.c
@@ -36,6 +36,7 @@
#include "H5Eprivate.h" /* Error handling */
#include "H5Gpkg.h" /* Groups */
#include "H5MFprivate.h" /* File memory management */
+#include "H5MMprivate.h" /* Memory management */
#include "H5WBprivate.h" /* Wrapped Buffers */
@@ -287,7 +288,7 @@ H5G__cache_node_serialize(const H5F_t *f, void *_image, size_t len,
HDassert(len == sym->node_size);
/* magic number */
- HDmemcpy(image, H5G_NODE_MAGIC, (size_t)H5_SIZEOF_MAGIC);
+ H5MM_memcpy(image, H5G_NODE_MAGIC, (size_t)H5_SIZEOF_MAGIC);
image += H5_SIZEOF_MAGIC;
/* version number */
diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c
index cb03b5e..95627d2 100644
--- a/src/H5Gdeprec.c
+++ b/src/H5Gdeprec.c
@@ -172,7 +172,6 @@ H5Gcreate1(hid_t loc_id, const char *name, size_t size_hint)
void *grp = NULL; /* New group created */
H5VL_object_t *vol_obj; /* Object token of loc_id */
H5VL_loc_params_t loc_params;
- H5P_genplist_t *plist; /* Property list pointer */
hid_t tmp_gcpl = H5I_INVALID_HID; /* Temporary group creation property list */
hid_t lcpl_id = H5P_LINK_CREATE_DEFAULT;
hid_t ret_value = H5I_INVALID_HID; /* Return value */
@@ -217,14 +216,6 @@ H5Gcreate1(hid_t loc_id, const char *name, size_t size_hint)
if(H5CX_set_loc(loc_id) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTSET, H5I_INVALID_HID, "can't set collective metadata read info")
- /* Get the plist structure */
- if(NULL == (plist = (H5P_genplist_t *)H5I_object(tmp_gcpl)))
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5I_INVALID_HID, "can't find object for ID")
-
- /* get creation properties */
- if(H5P_set(plist, H5VL_PROP_GRP_LCPL_ID, &lcpl_id) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't get property value for lcpl id")
-
/* Set location parameters */
loc_params.type = H5VL_OBJECT_BY_SELF;
loc_params.obj_type = H5I_get_type(loc_id);
@@ -234,7 +225,7 @@ H5Gcreate1(hid_t loc_id, const char *name, size_t size_hint)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier")
/* Create the group */
- if(NULL == (grp = H5VL_group_create(vol_obj, &loc_params, name, tmp_gcpl, H5P_GROUP_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)))
+ if(NULL == (grp = H5VL_group_create(vol_obj, &loc_params, name, lcpl_id, tmp_gcpl, H5P_GROUP_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)))
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5I_INVALID_HID, "unable to create group")
/* Get an atom for the group */
@@ -323,7 +314,6 @@ herr_t
H5Glink(hid_t cur_loc_id, H5G_link_t type, const char *cur_name, const char *new_name)
{
hid_t lcpl_id = H5P_LINK_CREATE_DEFAULT;
- H5P_genplist_t *plist; /* Property list pointer */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -339,10 +329,6 @@ H5Glink(hid_t cur_loc_id, H5G_link_t type, const char *cur_name, const char *new
if(H5CX_set_loc(cur_loc_id) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info")
- /* Get the plist structure */
- if(NULL == (plist = (H5P_genplist_t *)H5I_object(lcpl_id)))
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
-
/* Create link */
if(type == H5L_TYPE_HARD) {
H5VL_object_t *vol_obj; /* Object token of loc_id */
@@ -363,18 +349,12 @@ H5Glink(hid_t cur_loc_id, H5G_link_t type, const char *cur_name, const char *new
if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(cur_loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
- /* set creation properties */
- if(H5P_set(plist, H5VL_PROP_LINK_TARGET, &vol_obj->data) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for target")
- if(H5P_set(plist, H5VL_PROP_LINK_TARGET_LOC_PARAMS, &loc_params1) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for target loc params")
-
/* Construct a temporary VOL object */
tmp_vol_obj.data = NULL;
tmp_vol_obj.connector = vol_obj->connector;
/* Create the link through the VOL */
- if(H5VL_link_create(H5VL_LINK_CREATE_HARD, &tmp_vol_obj, &loc_params2, lcpl_id, H5P_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0)
+ if(H5VL_link_create(H5VL_LINK_CREATE_HARD, &tmp_vol_obj, &loc_params2, lcpl_id, H5P_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, vol_obj->data, loc_params1) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link")
} /* end if */
else if(type == H5L_TYPE_SOFT) {
@@ -390,12 +370,8 @@ H5Glink(hid_t cur_loc_id, H5G_link_t type, const char *cur_name, const char *new
if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(cur_loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
- /* set creation properties */
- if(H5P_set(plist, H5VL_PROP_LINK_TARGET_NAME, &cur_name) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for target name")
-
/* Create the link through the VOL */
- if(H5VL_link_create(H5VL_LINK_CREATE_SOFT, vol_obj, &loc_params, lcpl_id, H5P_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0)
+ if(H5VL_link_create(H5VL_LINK_CREATE_SOFT, vol_obj, &loc_params, lcpl_id, H5P_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, cur_name) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link")
} /* end else-if */
else
@@ -419,7 +395,6 @@ H5Glink2(hid_t cur_loc_id, const char *cur_name, H5G_link_t type,
hid_t new_loc_id, const char *new_name)
{
hid_t lcpl_id = H5P_LINK_CREATE_DEFAULT;
- H5P_genplist_t *plist; /* Property list pointer */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -435,10 +410,6 @@ H5Glink2(hid_t cur_loc_id, const char *cur_name, H5G_link_t type,
if(H5CX_set_loc(cur_loc_id) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info")
- /* Get the plist structure */
- if(NULL == (plist = (H5P_genplist_t *)H5I_object(lcpl_id)))
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
-
/* Create the appropriate kind of link */
if(type == H5L_TYPE_HARD) {
H5VL_object_t *vol_obj1; /* Object token of loc_id */
@@ -462,14 +433,8 @@ H5Glink2(hid_t cur_loc_id, const char *cur_name, H5G_link_t type,
if(NULL == (vol_obj2 = (H5VL_object_t *)H5I_object(new_loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
- /* set creation properties */
- if(H5P_set(plist, H5VL_PROP_LINK_TARGET, &vol_obj1->data) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for target id")
- if(H5P_set(plist, H5VL_PROP_LINK_TARGET_LOC_PARAMS, &loc_params1) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for target name")
-
/* Create the link through the VOL */
- if(H5VL_link_create(H5VL_LINK_CREATE_HARD, vol_obj2, &loc_params2, lcpl_id, H5P_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0)
+ if(H5VL_link_create(H5VL_LINK_CREATE_HARD, vol_obj2, &loc_params2, lcpl_id, H5P_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, vol_obj1->data, loc_params1) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link")
} /* end if */
else if(type == H5L_TYPE_SOFT) {
@@ -490,12 +455,8 @@ H5Glink2(hid_t cur_loc_id, const char *cur_name, H5G_link_t type,
if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(new_loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
- /* set creation properties */
- if(H5P_set(plist, H5VL_PROP_LINK_TARGET_NAME, &cur_name) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for target name")
-
/* Create the link through the VOL */
- if(H5VL_link_create(H5VL_LINK_CREATE_SOFT, vol_obj, &loc_params, lcpl_id, H5P_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0)
+ if(H5VL_link_create(H5VL_LINK_CREATE_SOFT, vol_obj, &loc_params, lcpl_id, H5P_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, cur_name) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link")
} /* end else-if */
else
diff --git a/src/H5Gent.c b/src/H5Gent.c
index baee35c..19aef10 100644
--- a/src/H5Gent.c
+++ b/src/H5Gent.c
@@ -32,6 +32,7 @@
#include "H5FLprivate.h" /* Free Lists */
#include "H5Gpkg.h" /* Groups */
#include "H5HLprivate.h" /* Local Heaps */
+#include "H5MMprivate.h" /* Memory management */
/****************/
@@ -331,7 +332,7 @@ H5G__ent_copy(H5G_entry_t *dst, const H5G_entry_t *src, H5_copy_depth_t depth)
HDassert(depth == H5_COPY_SHALLOW || depth == H5_COPY_DEEP);
/* Copy the top level information */
- HDmemcpy(dst, src, sizeof(H5G_entry_t));
+ H5MM_memcpy(dst, src, sizeof(H5G_entry_t));
/* Deep copy the names */
if(depth == H5_COPY_DEEP) {
diff --git a/src/H5Glink.c b/src/H5Glink.c
index 82a2dcf..04ccbc5 100644
--- a/src/H5Glink.c
+++ b/src/H5Glink.c
@@ -402,15 +402,14 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5G__link_sort_table
+ * Function: H5G__link_sort_table
*
* Purpose: Sort table containing a list of links for a group
*
- * Return: Success: Non-negative
- * Failure: Negative
+ * Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
- * Nov 20, 2006
+ * Programmer: Quincey Koziol
+ * Nov 20, 2006
*
*-------------------------------------------------------------------------
*/
@@ -418,11 +417,20 @@ herr_t
H5G__link_sort_table(H5G_link_table_t *ltable, H5_index_t idx_type,
H5_iter_order_t order)
{
+ herr_t ret_value = SUCCEED;
+
FUNC_ENTER_PACKAGE_NOERR
/* Sanity check */
HDassert(ltable);
+ /* Can't sort when empty since the links table will be NULL */
+ if(0 == ltable->nlinks)
+ HGOTO_DONE(ret_value);
+
+ /* This should never be NULL if the number of links is non-zero */
+ HDassert(ltable->lnks);
+
/* Pick appropriate sorting routine */
if(idx_type == H5_INDEX_NAME) {
if(order == H5_ITER_INC)
@@ -442,6 +450,7 @@ H5G__link_sort_table(H5G_link_table_t *ltable, H5_index_t idx_type,
HDassert(order == H5_ITER_NATIVE);
} /* end else */
+done:
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5G__link_sort_table() */
diff --git a/src/H5Gloc.c b/src/H5Gloc.c
index 5724031..e47d3be 100644
--- a/src/H5Gloc.c
+++ b/src/H5Gloc.c
@@ -226,7 +226,10 @@ H5G_loc_real(void *obj, H5I_type_t type, H5G_loc_t *loc)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get group location of a virtual file driver (VFD)")
case H5I_VOL:
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get group location of a virtual object layer (VOL) driver")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get group location of a virtual object layer (VOL) connector")
+
+ case H5I_SPACE_SEL_ITER:
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get group location of a dataspace selection iterator")
case H5I_UNINIT:
case H5I_BADID:
diff --git a/src/H5Gname.c b/src/H5Gname.c
index 2aece2b..16c1ca7 100644
--- a/src/H5Gname.c
+++ b/src/H5Gname.c
@@ -522,7 +522,7 @@ H5G_name_copy(H5G_name_t *dst, const H5G_name_t *src, H5_copy_depth_t depth)
HDassert(depth == H5_COPY_SHALLOW || depth == H5_COPY_DEEP);
/* Copy the top level information */
- HDmemcpy(dst, src, sizeof(H5G_name_t));
+ H5MM_memcpy(dst, src, sizeof(H5G_name_t));
/* Deep copy the names */
if(depth == H5_COPY_DEEP) {
@@ -828,6 +828,7 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key)
case H5I_ERROR_CLASS:
case H5I_ERROR_MSG:
case H5I_ERROR_STACK:
+ case H5I_SPACE_SEL_ITER:
case H5I_NTYPES:
default:
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unknown data object")
diff --git a/src/H5Gnode.c b/src/H5Gnode.c
index 72b3633..b79b7d2 100644
--- a/src/H5Gnode.c
+++ b/src/H5Gnode.c
@@ -672,7 +672,7 @@ H5G__node_insert(H5F_t *f, haddr_t addr, void H5_ATTR_UNUSED *_lt_key,
if(NULL == (snrt = (H5G_node_t *)H5AC_protect(f, H5AC_SNODE, *new_node_p, f, H5AC__NO_FLAGS_SET)))
HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_INS_ERROR, "unable to split symbol table node")
- HDmemcpy(snrt->entry, sn->entry + H5F_SYM_LEAF_K(f),
+ H5MM_memcpy(snrt->entry, sn->entry + H5F_SYM_LEAF_K(f),
H5F_SYM_LEAF_K(f) * sizeof(H5G_entry_t));
snrt->nsyms = H5F_SYM_LEAF_K(f);
snrt_flags |= H5AC__DIRTIED_FLAG;
@@ -1262,7 +1262,7 @@ H5G__node_copy(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr,
char *link_name; /* Pointer to value of soft link */
/* Make a temporary copy, so that it will not change the info in the cache */
- HDmemcpy(&tmp_src_ent, src_ent, sizeof(H5G_entry_t));
+ H5MM_memcpy(&tmp_src_ent, src_ent, sizeof(H5G_entry_t));
/* Set up group location for soft link to start in */
H5G_name_reset(&grp_path);
diff --git a/src/H5Gtest.c b/src/H5Gtest.c
index af6acb3..0b431b1 100644
--- a/src/H5Gtest.c
+++ b/src/H5Gtest.c
@@ -616,6 +616,7 @@ H5G__user_path_test(hid_t obj_id, char *user_path, size_t *user_path_len, unsign
case H5I_ERROR_CLASS:
case H5I_ERROR_MSG:
case H5I_ERROR_STACK:
+ case H5I_SPACE_SEL_ITER:
case H5I_NTYPES:
default:
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unknown data object type")
diff --git a/src/H5Gtraverse.c b/src/H5Gtraverse.c
index d029bea..492b5b9 100644
--- a/src/H5Gtraverse.c
+++ b/src/H5Gtraverse.c
@@ -555,7 +555,7 @@ H5G__traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target,
* Copy the component name into a null-terminated buffer so
* we can pass it down to the other symbol table functions.
*/
- HDmemcpy(comp, name, nchars);
+ H5MM_memcpy(comp, name, nchars);
comp[nchars] = '\0';
/*
@@ -670,7 +670,7 @@ H5G__traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target,
/* Only keep the creation order information from the parent
* group's link info
*/
- HDmemcpy(&tmp_linfo, &def_linfo, sizeof(H5O_linfo_t));
+ H5MM_memcpy(&tmp_linfo, &def_linfo, sizeof(H5O_linfo_t));
tmp_linfo.track_corder = par_linfo.track_corder;
tmp_linfo.index_corder = par_linfo.index_corder;
linfo = &tmp_linfo;
diff --git a/src/H5HF.c b/src/H5HF.c
index 3df7e7b..5d52ca4 100644
--- a/src/H5HF.c
+++ b/src/H5HF.c
@@ -42,6 +42,8 @@
#include "H5FOprivate.h" /* File objects */
#include "H5HFpkg.h" /* Fractal heaps */
#include "H5MFprivate.h" /* File memory management */
+#include "H5MMprivate.h" /* Memory management */
+
/****************/
/* Local Macros */
@@ -104,7 +106,7 @@ H5HF_op_read(const void *obj, size_t obj_len, void *op_data)
FUNC_ENTER_NOAPI_NOINIT_NOERR
/* Perform "read", using memcpy() */
- HDmemcpy(op_data, obj, obj_len);
+ H5MM_memcpy(op_data, obj, obj_len);
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5HF_op_read() */
@@ -129,7 +131,7 @@ H5HF_op_write(const void *obj, size_t obj_len, void *op_data)
FUNC_ENTER_NOAPI_NOINIT_NOERR
/* Perform "write", using memcpy() */
- HDmemcpy((void *)obj, op_data, obj_len); /* Casting away const OK -QAK */
+ H5MM_memcpy((void *)obj, op_data, obj_len); /* Casting away const OK -QAK */
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5HF_op_write() */
diff --git a/src/H5HFcache.c b/src/H5HFcache.c
index 0c5d3aa..2d1c1f2 100644
--- a/src/H5HFcache.c
+++ b/src/H5HFcache.c
@@ -772,7 +772,7 @@ H5HF__cache_hdr_serialize(const H5F_t *f, void *_image, size_t len,
hdr->f = f;
/* Magic number */
- HDmemcpy(image, H5HF_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC);
+ H5MM_memcpy(image, H5HF_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC);
image += H5_SIZEOF_MAGIC;
/* Version # */
@@ -1362,7 +1362,7 @@ H5HF__cache_iblock_serialize(const H5F_t *f, void *_image, size_t len,
hdr->f = f;
/* Magic number */
- HDmemcpy(image, H5HF_IBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC);
+ H5MM_memcpy(image, H5HF_IBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC);
image += H5_SIZEOF_MAGIC;
/* Version # */
@@ -1677,7 +1677,7 @@ H5HF__cache_dblock_verify_chksum(const void *_image, size_t len, void *_udata)
/* Set up parameters for filter pipeline */
nbytes = len;
filter_mask = udata->filter_mask;
- HDmemcpy(read_buf, image, len);
+ H5MM_memcpy(read_buf, image, len);
/* Push direct block data through I/O filter pipeline */
if(H5Z_pipeline(&(hdr->pline), H5Z_FLAG_REVERSE, &filter_mask, H5Z_ENABLE_EDC, filter_cb, &nbytes, &len, &read_buf) < 0)
@@ -1724,7 +1724,7 @@ H5HF__cache_dblock_verify_chksum(const void *_image, size_t len, void *_udata)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
/* Copy un-filtered data into block's buffer */
- HDmemcpy(udata->dblk, read_buf, len);
+ H5MM_memcpy(udata->dblk, read_buf, len);
} /* end if */
done:
@@ -1829,7 +1829,7 @@ H5HF__cache_dblock_deserialize(const void *_image, size_t len, void *_udata,
HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, NULL, "memory allocation failed for pipeline buffer")
/* Copy compressed image into buffer */
- HDmemcpy(read_buf, image, len);
+ H5MM_memcpy(read_buf, image, len);
/* Push direct block data through I/O filter pipeline */
nbytes = len;
@@ -1841,7 +1841,7 @@ H5HF__cache_dblock_deserialize(const void *_image, size_t len, void *_udata,
HDassert(nbytes == dblock->size);
/* Copy un-filtered data into block's buffer */
- HDmemcpy(dblock->blk, read_buf, dblock->size);
+ H5MM_memcpy(dblock->blk, read_buf, dblock->size);
} /* end if */
} /* end if */
else {
@@ -1856,7 +1856,7 @@ H5HF__cache_dblock_deserialize(const void *_image, size_t len, void *_udata,
/* Copy image to dblock->blk */
HDassert(dblock->size == len);
- HDmemcpy(dblock->blk, image, dblock->size);
+ H5MM_memcpy(dblock->blk, image, dblock->size);
} /* end else */
/* Start decoding direct block */
@@ -2146,7 +2146,7 @@ H5HF__cache_dblock_pre_serialize(H5F_t *f, void *_thing,
image = dblock->blk;
/* Magic number */
- HDmemcpy(image, H5HF_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC);
+ H5MM_memcpy(image, H5HF_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC);
image += H5_SIZEOF_MAGIC;
/* Version # */
@@ -2201,7 +2201,7 @@ H5HF__cache_dblock_pre_serialize(H5F_t *f, void *_thing,
HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "memory allocation failed for pipeline buffer")
/* Copy the direct block's image into the buffer to compress */
- HDmemcpy(write_buf, dblock->blk, write_size);
+ H5MM_memcpy(write_buf, dblock->blk, write_size);
/* Push direct block data through I/O filter pipeline */
nbytes = write_size;
@@ -2460,7 +2460,7 @@ H5HF__cache_dblock_serialize(const H5F_t *f, void *image, size_t len,
HDassert(dblock->write_size == len);
/* Copy the image from *(dblock->write_buf) to *image */
- HDmemcpy(image, dblock->write_buf, dblock->write_size);
+ H5MM_memcpy(image, dblock->write_buf, dblock->write_size);
/* Free *(dblock->write_buf) if it was allocated by the
* pre-serialize function
diff --git a/src/H5HFdbg.c b/src/H5HFdbg.c
index fc437dc..22de0c4 100644
--- a/src/H5HFdbg.c
+++ b/src/H5HFdbg.c
@@ -483,7 +483,7 @@ H5HF_dblock_debug_cb(H5FS_section_info_t *_sect, void *_udata)
/* Flag overlaps */
if (overlap)
- fprintf(udata->stream, "***THAT FREE BLOCK OVERLAPPED A PREVIOUS ONE!\n");
+ HDfprintf(udata->stream, "***THAT FREE BLOCK OVERLAPPED A PREVIOUS ONE!\n");
else
udata->amount_free += len;
} /* end if */
diff --git a/src/H5HFhdr.c b/src/H5HFhdr.c
index b014017..5750a03 100644
--- a/src/H5HFhdr.c
+++ b/src/H5HFhdr.c
@@ -36,6 +36,7 @@
#include "H5Eprivate.h" /* Error handling */
#include "H5HFpkg.h" /* Fractal heaps */
#include "H5MFprivate.h" /* File memory management */
+#include "H5MMprivate.h" /* Memory management */
#include "H5VMprivate.h" /* Vectors and arrays */
/****************/
@@ -387,7 +388,7 @@ H5HF_hdr_create(H5F_t *f, const H5HF_create_t *cparam)
/* Set the creation parameters for the heap */
hdr->max_man_size = cparam->max_man_size;
hdr->checksum_dblocks = cparam->checksum_dblocks;
- HDmemcpy(&(hdr->man_dtable.cparam), &(cparam->managed), sizeof(H5HF_dtable_cparam_t));
+ H5MM_memcpy(&(hdr->man_dtable.cparam), &(cparam->managed), sizeof(H5HF_dtable_cparam_t));
/* Set root table address to indicate that the heap is empty currently */
hdr->man_dtable.table_addr = HADDR_UNDEF;
diff --git a/src/H5HFhuge.c b/src/H5HFhuge.c
index 6e475ad..d496d62 100644
--- a/src/H5HFhuge.c
+++ b/src/H5HFhuge.c
@@ -355,7 +355,7 @@ HDfprintf(stderr, "%s: obj_size = %Zu\n", FUNC, obj_size);
write_size = obj_size;
if(NULL == (write_buf = H5MM_malloc(write_size)))
HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "memory allocation failed for pipeline buffer")
- HDmemcpy(write_buf, obj, write_size);
+ H5MM_memcpy(write_buf, obj, write_size);
/* Push direct block data through I/O filter pipeline */
nbytes = write_size;
@@ -794,7 +794,7 @@ H5HF__huge_op_real(H5HF_hdr_t *hdr, const uint8_t *id, hbool_t is_read,
/* Copy object to user's buffer if there's filters on heap data */
/* (if there's no filters, the object was read directly into the user's buffer) */
if(hdr->filter_len > 0)
- HDmemcpy(op_data, read_buf, (size_t)obj_size);
+ H5MM_memcpy(op_data, read_buf, (size_t)obj_size);
} /* end if */
else {
/* Call the user's 'op' callback */
diff --git a/src/H5HFman.c b/src/H5HFman.c
index 7f90f49..e5b5cb8 100644
--- a/src/H5HFman.c
+++ b/src/H5HFman.c
@@ -183,7 +183,7 @@ H5HF__man_insert(H5HF_hdr_t *hdr, size_t obj_size, const void *obj, void *_id)
p = dblock->blk + blk_off;
/* Copy the object's data into the heap */
- HDmemcpy(p, obj, obj_size);
+ H5MM_memcpy(p, obj, obj_size);
p += obj_size;
/* Sanity check */
diff --git a/src/H5HFsection.c b/src/H5HFsection.c
index 36e966e..f5ac8e5 100644
--- a/src/H5HFsection.c
+++ b/src/H5HFsection.c
@@ -3082,7 +3082,7 @@ H5HF__sect_indirect_reduce_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect,
HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "allocation failed for row section pointer array")
/* Transfer row sections between current & peer sections */
- HDmemcpy(&peer_sect->u.indirect.dir_rows[0],
+ H5MM_memcpy(&peer_sect->u.indirect.dir_rows[0],
&sect->u.indirect.dir_rows[0],
(sizeof(H5HF_free_section_t *) * peer_dir_nrows));
HDmemmove(&sect->u.indirect.dir_rows[0],
@@ -3321,7 +3321,7 @@ H5HF__sect_indirect_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect,
HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "allocation failed for indirect section pointer array")
/* Transfer child indirect sections between current & peer sections */
- HDmemcpy(&peer_sect->u.indirect.indir_ents[0],
+ H5MM_memcpy(&peer_sect->u.indirect.indir_ents[0],
&sect->u.indirect.indir_ents[sect->u.indirect.indir_nents - peer_nentries],
(sizeof(H5HF_free_section_t *) * peer_nentries));
sect->u.indirect.indir_nents -= (peer_nentries + 1); /* Transferred blocks, plus child entry */
@@ -3636,7 +3636,7 @@ H5HF__sect_indirect_merge_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect1,
sect1->u.indirect.dir_rows = new_dir_rows;
/* Transfer the second section's rows to first section */
- HDmemcpy(&sect1->u.indirect.dir_rows[sect1->u.indirect.dir_nrows],
+ H5MM_memcpy(&sect1->u.indirect.dir_rows[sect1->u.indirect.dir_nrows],
&sect2->u.indirect.dir_rows[src_row2],
(sizeof(H5HF_free_section_t *) * nrows_moved2));
@@ -3682,7 +3682,7 @@ H5HF__sect_indirect_merge_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect1,
sect1->u.indirect.indir_ents = new_indir_ents;
/* Transfer the second section's entries to first section */
- HDmemcpy(&sect1->u.indirect.indir_ents[sect1->u.indirect.indir_nents],
+ H5MM_memcpy(&sect1->u.indirect.indir_ents[sect1->u.indirect.indir_nents],
&sect2->u.indirect.indir_ents[0],
(sizeof(H5HF_free_section_t *) * sect2->u.indirect.indir_nents));
} /* end else */
diff --git a/src/H5HFtest.c b/src/H5HFtest.c
index 1b1f688..6f174bb 100644
--- a/src/H5HFtest.c
+++ b/src/H5HFtest.c
@@ -32,6 +32,8 @@
#include "H5private.h" /* Generic Functions */
#include "H5Eprivate.h" /* Error handling */
#include "H5HFpkg.h" /* Fractal heaps */
+#include "H5MMprivate.h" /* Memory management */
+
/****************/
/* Local Macros */
@@ -100,7 +102,7 @@ H5HF_get_cparam_test(const H5HF_t *fh, H5HF_create_t *cparam)
else
H5_CHECKED_ASSIGN(cparam->id_len, uint16_t, fh->hdr->id_len, unsigned);
cparam->max_man_size = fh->hdr->max_man_size;
- HDmemcpy(&(cparam->managed), &(fh->hdr->man_dtable.cparam), sizeof(H5HF_dtable_cparam_t));
+ H5MM_memcpy(&(cparam->managed), &(fh->hdr->man_dtable.cparam), sizeof(H5HF_dtable_cparam_t));
H5O_msg_copy(H5O_PLINE_ID, &(fh->hdr->pline), &(cparam->pline));
FUNC_LEAVE_NOAPI(SUCCEED)
diff --git a/src/H5HFtiny.c b/src/H5HFtiny.c
index 5cf1c08..0c27180 100644
--- a/src/H5HFtiny.c
+++ b/src/H5HFtiny.c
@@ -35,6 +35,7 @@
#include "H5private.h" /* Generic Functions */
#include "H5Eprivate.h" /* Error handling */
#include "H5HFpkg.h" /* Fractal heaps */
+#include "H5MMprivate.h" /* Memory management */
/****************/
@@ -176,7 +177,7 @@ HDfprintf(stderr, "%s: obj_size = %Zu\n", FUNC, obj_size);
*id++ = enc_obj_size & H5HF_TINY_MASK_EXT_2;
} /* end else */
- HDmemcpy(id, obj, obj_size);
+ H5MM_memcpy(id, obj, obj_size);
HDmemset(id + obj_size, 0, (hdr->id_len - ((size_t)1 + (size_t)hdr->tiny_len_extended + obj_size)));
/* Update statistics about heap */
diff --git a/src/H5HG.c b/src/H5HG.c
index df1c82d..231294b 100644
--- a/src/H5HG.c
+++ b/src/H5HG.c
@@ -168,7 +168,7 @@ H5HG__create(H5F_t *f, size_t size)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, "memory allocation failed")
/* Initialize the header */
- HDmemcpy(heap->chunk, H5HG_MAGIC, (size_t)H5_SIZEOF_MAGIC);
+ H5MM_memcpy(heap->chunk, H5HG_MAGIC, (size_t)H5_SIZEOF_MAGIC);
p = heap->chunk + H5_SIZEOF_MAGIC;
*p++ = H5HG_VERSION;
*p++ = 0; /*reserved*/
@@ -553,7 +553,7 @@ H5HG_insert(H5F_t *f, size_t size, void *obj, H5HG_t *hobj/*out*/)
/* Copy data into the heap */
if(size > 0) {
- HDmemcpy(heap->obj[idx].begin + H5HG_SIZEOF_OBJHDR(f), obj, size);
+ H5MM_memcpy(heap->obj[idx].begin + H5HG_SIZEOF_OBJHDR(f), obj, size);
#ifdef OLD_WAY
/* Don't bother zeroing out the rest of the info in the heap -QAK */
HDmemset(heap->obj[idx].begin + H5HG_SIZEOF_OBJHDR(f) + size, 0,
@@ -618,7 +618,7 @@ H5HG_read(H5F_t *f, H5HG_t *hobj, void *object/*out*/, size_t *buf_size)
/* Allocate a buffer for the object read in, if the user didn't give one */
if(!object && NULL == (object = H5MM_malloc(size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
- HDmemcpy(object, p, size);
+ H5MM_memcpy(object, p, size);
/*
* Advance the heap in the CWFS list. We might have done this already
diff --git a/src/H5HGcache.c b/src/H5HGcache.c
index beaea7b..29e88df 100644
--- a/src/H5HGcache.c
+++ b/src/H5HGcache.c
@@ -271,7 +271,7 @@ H5HG__cache_heap_deserialize(const void *_image, size_t len, void *_udata,
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
/* Copy the image buffer into the newly allocate chunk */
- HDmemcpy(heap->chunk, _image, len);
+ H5MM_memcpy(heap->chunk, _image, len);
/* Deserialize the heap's header */
if(H5HG__hdr_deserialize(heap, (const uint8_t *)heap->chunk, f) < 0)
@@ -448,7 +448,7 @@ H5HG__cache_heap_serialize(const H5F_t *f, void *image, size_t len,
HDassert(heap->chunk);
/* copy the image into the buffer */
- HDmemcpy(image, heap->chunk, len);
+ H5MM_memcpy(image, heap->chunk, len);
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5HG__cache_heap_serialize() */
diff --git a/src/H5HL.c b/src/H5HL.c
index 735077c..f290294 100644
--- a/src/H5HL.c
+++ b/src/H5HL.c
@@ -725,7 +725,7 @@ H5HL_insert(H5F_t *f, H5HL_t *heap, size_t buf_size, const void *buf))
} /* end if */
/* Copy the data into the heap */
- HDmemcpy(heap->dblk_image + offset, buf, buf_size);
+ H5MM_memcpy(heap->dblk_image + offset, buf, buf_size);
/* Set return value */
ret_value = offset;
diff --git a/src/H5HLcache.c b/src/H5HLcache.c
index 926f787..8b04b47 100644
--- a/src/H5HLcache.c
+++ b/src/H5HLcache.c
@@ -36,6 +36,7 @@
#include "H5Eprivate.h" /* Error handling */
#include "H5HLpkg.h" /* Local Heaps */
#include "H5MFprivate.h" /* File memory management */
+#include "H5MMprivate.h" /* Memory management */
#include "H5WBprivate.h" /* Wrapped Buffers */
@@ -464,7 +465,7 @@ H5HL__cache_prefix_deserialize(const void *_image, size_t len, void *_udata,
image = ((const uint8_t *)_image) + heap->prfx_size;
/* Copy the heap data from the speculative read buffer */
- HDmemcpy(heap->dblk_image, image, heap->dblk_size);
+ H5MM_memcpy(heap->dblk_image, image, heap->dblk_size);
/* Build free list */
if(H5HL__fl_deserialize(heap) < 0)
@@ -587,7 +588,7 @@ H5HL__cache_prefix_serialize(const H5F_t *f, void *_image, size_t len,
heap->free_block = heap->freelist ? heap->freelist->offset : H5HL_FREE_NULL;
/* Serialize the heap prefix */
- HDmemcpy(image, H5HL_MAGIC, (size_t)H5_SIZEOF_MAGIC);
+ H5MM_memcpy(image, H5HL_MAGIC, (size_t)H5_SIZEOF_MAGIC);
image += H5_SIZEOF_MAGIC;
*image++ = H5HL_VERSION;
*image++ = 0; /*reserved*/
@@ -615,7 +616,7 @@ H5HL__cache_prefix_serialize(const H5F_t *f, void *_image, size_t len,
H5HL__fl_serialize(heap);
/* Copy the heap data block into the cache image */
- HDmemcpy(image, heap->dblk_image, heap->dblk_size);
+ H5MM_memcpy(image, heap->dblk_image, heap->dblk_size);
/* Sanity check */
HDassert((size_t)(image - (uint8_t *)_image) + heap->dblk_size == len);
@@ -756,7 +757,7 @@ H5HL__cache_datablock_deserialize(const void *image, size_t len, void *_udata,
HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "can't allocate data block image buffer");
/* copy the datablock from the read buffer */
- HDmemcpy(heap->dblk_image, image, len);
+ H5MM_memcpy(heap->dblk_image, image, len);
/* Build free list */
if(FAIL == H5HL__fl_deserialize(heap))
@@ -851,7 +852,7 @@ H5HL__cache_datablock_serialize(const H5F_t *f, void *image, size_t len,
H5HL__fl_serialize(heap);
/* Copy the heap's data block into the cache's image */
- HDmemcpy(image, heap->dblk_image, heap->dblk_size);
+ H5MM_memcpy(image, heap->dblk_image, heap->dblk_size);
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5HL__cache_datablock_serialize() */
diff --git a/src/H5I.c b/src/H5I.c
index ca9ff61..cdc849b 100644
--- a/src/H5I.c
+++ b/src/H5I.c
@@ -355,6 +355,9 @@ H5Itype_exists(H5I_type_t type)
FUNC_ENTER_API(FAIL)
H5TRACE1("t", "It", type);
+ if(H5I_IS_LIB_TYPE(type))
+ HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "cannot call public function on library type")
+
if (type <= H5I_BADID || type >= H5I_next_type)
HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number")
@@ -1131,7 +1134,7 @@ done:
*
*-------------------------------------------------------------------------
*/
-void *
+static void *
H5I__remove_verify(hid_t id, H5I_type_t id_type)
{
void * ret_value = NULL; /*return value */
@@ -1940,6 +1943,8 @@ H5I__iterate_pub_cb(void H5_ATTR_UNUSED *obj, hid_t id, void *_udata)
ret_value = H5_ITER_STOP; /* terminate iteration early */
else if(cb_ret_val < 0)
ret_value = H5_ITER_ERROR; /* indicate failure (which terminates iteration) */
+ else
+ ret_value = H5_ITER_CONT; /* continue iteration */
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5I__iterate_pub_cb() */
@@ -2166,7 +2171,6 @@ H5Iget_name(hid_t id, char *name/*out*/, size_t size)
{
H5VL_object_t *vol_obj; /* Object token of loc_id */
H5VL_loc_params_t loc_params;
- H5G_loc_t loc; /* Object location */
ssize_t ret_value; /* Return value */
FUNC_ENTER_API((-1))
@@ -2181,7 +2185,7 @@ H5Iget_name(hid_t id, char *name/*out*/, size_t size)
loc_params.obj_type = H5I_get_type(id);
/* Retrieve object's name */
- if(H5VL_object_get(vol_obj, &loc_params, H5VL_ID_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value, name, size) < 0)
+ if(H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value, name, size) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, (-1), "can't retrieve object name")
done:
@@ -2379,6 +2383,7 @@ H5I__id_dump_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata)
case H5I_ERROR_CLASS:
case H5I_ERROR_MSG:
case H5I_ERROR_STACK:
+ case H5I_SPACE_SEL_ITER:
case H5I_NTYPES:
default:
break; /* Other types of IDs are not stored in files */
diff --git a/src/H5Ipublic.h b/src/H5Ipublic.h
index 56873ec..def785f 100644
--- a/src/H5Ipublic.h
+++ b/src/H5Ipublic.h
@@ -46,6 +46,7 @@ typedef enum H5I_type_t {
H5I_ERROR_CLASS, /* type ID for error classes */
H5I_ERROR_MSG, /* type ID for error messages */
H5I_ERROR_STACK, /* type ID for error stacks */
+ H5I_SPACE_SEL_ITER, /* type ID for dataspace selection iterator */
H5I_NTYPES /* number of library types, MUST BE LAST! */
} H5I_type_t;
diff --git a/src/H5L.c b/src/H5L.c
index 1f45740..98976a6 100644
--- a/src/H5L.c
+++ b/src/H5L.c
@@ -449,7 +449,6 @@ H5Lcreate_soft(const char *link_target, hid_t link_loc_id, const char *link_name
{
H5VL_object_t *vol_obj = NULL; /* object token of loc_id */
H5VL_loc_params_t loc_params;
- H5P_genplist_t *plist = NULL; /* Property list pointer */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -483,20 +482,12 @@ H5Lcreate_soft(const char *link_target, hid_t link_loc_id, const char *link_name
if(NULL == (vol_obj = (H5VL_object_t *)H5VL_vol_object(link_loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
- /* Get the plist structure */
- if(NULL == (plist = (H5P_genplist_t *)H5I_object(lcpl_id)))
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
-
- /* set creation properties */
- if(H5P_set(plist, H5VL_PROP_LINK_TARGET_NAME, &link_target) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for target name")
-
/* Verify access property list and set up collective metadata if appropriate */
if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, link_loc_id, TRUE) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info")
/* Create the link */
- if(H5VL_link_create(H5VL_LINK_CREATE_SOFT, vol_obj, &loc_params, lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0)
+ if(H5VL_link_create(H5VL_LINK_CREATE_SOFT, vol_obj, &loc_params, lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, link_target) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTCREATE, FAIL, "unable to create soft link")
done:
@@ -529,7 +520,6 @@ H5Lcreate_hard(hid_t cur_loc_id, const char *cur_name,
H5VL_object_t tmp_vol_obj; /* Temporary object token of */
H5VL_loc_params_t loc_params1;
H5VL_loc_params_t loc_params2;
- H5P_genplist_t *plist; /* Property list pointer */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -583,22 +573,12 @@ H5Lcreate_hard(hid_t cur_loc_id, const char *cur_name,
if(vol_obj1->connector->cls->value != vol_obj2->connector->cls->value)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Objects are accessed through different VOL connectors and can't be linked")
- /* Get the link creation plist structure */
- if(NULL == (plist = (H5P_genplist_t *)H5I_object(lcpl_id)))
- HGOTO_ERROR(H5E_LINK, H5E_BADATOM, FAIL, "can't find object for ID")
-
- /* Set creation properties */
- if(H5P_set(plist, H5VL_PROP_LINK_TARGET, (vol_obj1 ? &(vol_obj1->data) : NULL)) < 0)
- HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't set property value for target id")
- if(H5P_set(plist, H5VL_PROP_LINK_TARGET_LOC_PARAMS, &loc_params1) < 0)
- HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't set property value for target name")
-
/* Construct a temporary VOL object */
tmp_vol_obj.data = (vol_obj2 ? (vol_obj2->data) : NULL);
tmp_vol_obj.connector = (vol_obj1 != NULL ? vol_obj1->connector : vol_obj2->connector);
/* Create the link */
- if(H5VL_link_create(H5VL_LINK_CREATE_HARD, &tmp_vol_obj, &loc_params2, lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0)
+ if(H5VL_link_create(H5VL_LINK_CREATE_HARD, &tmp_vol_obj, &loc_params2, lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (vol_obj1 ? vol_obj1->data : NULL), loc_params1) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTCREATE, FAIL, "unable to create hard link")
done:
@@ -636,7 +616,6 @@ H5Lcreate_ud(hid_t link_loc_id, const char *link_name, H5L_type_t link_type,
{
H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */
H5VL_loc_params_t loc_params;
- H5P_genplist_t *plist; /* Property list pointer */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -668,20 +647,8 @@ H5Lcreate_ud(hid_t link_loc_id, const char *link_name, H5L_type_t link_type,
if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(link_loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
- /* Get the plist structure */
- if(NULL == (plist = (H5P_genplist_t *)H5I_object(lcpl_id)))
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
-
- /* set creation properties */
- if(H5P_set(plist, H5VL_PROP_LINK_TYPE, &link_type) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value from plist")
- if(H5P_set(plist, H5VL_PROP_LINK_UDATA, &udata) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value from plist")
- if(H5P_set(plist, H5VL_PROP_LINK_UDATA_SIZE, &udata_size) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value from plist")
-
/* Create external link */
- if(H5VL_link_create(H5VL_LINK_CREATE_UD, vol_obj, &loc_params, lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0)
+ if(H5VL_link_create(H5VL_LINK_CREATE_UD, vol_obj, &loc_params, lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)link_type, udata, udata_size) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link")
done:
@@ -1676,7 +1643,7 @@ H5L_register(const H5L_class_t *cls)
} /* end if */
/* Copy link class info into table */
- HDmemcpy(H5L_table_g + i, cls, sizeof(H5L_class_t));
+ H5MM_memcpy(H5L_table_g + i, cls, sizeof(H5L_class_t));
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -2217,7 +2184,7 @@ H5L__create_ud(const H5G_loc_t *link_loc, const char *link_name,
/* Fill in UD link-specific information in the link struct*/
if(ud_data_size > 0) {
lnk.u.ud.udata = H5MM_malloc((size_t)ud_data_size);
- HDmemcpy(lnk.u.ud.udata, ud_data, (size_t) ud_data_size);
+ H5MM_memcpy(lnk.u.ud.udata, ud_data, (size_t) ud_data_size);
} /* end if */
else
lnk.u.ud.udata = NULL;
diff --git a/src/H5Lexternal.c b/src/H5Lexternal.c
index 0f3296f..3c4ffcc 100644
--- a/src/H5Lexternal.c
+++ b/src/H5Lexternal.c
@@ -306,7 +306,7 @@ H5L__extern_query(const char H5_ATTR_UNUSED * link_name, const void *_udata, siz
buf_size = udata_size;
/* Copy the udata verbatim up to buf_size */
- HDmemcpy(buf, udata, buf_size);
+ H5MM_memcpy(buf, udata, buf_size);
} /* end if */
/* Set return value */
@@ -349,7 +349,6 @@ H5Lcreate_external(const char *file_name, const char *obj_name,
size_t file_name_len; /* Length of file name string */
size_t norm_obj_name_len; /* Length of normalized object name string */
uint8_t *p; /* Pointer into external link buffer */
- H5P_genplist_t *plist; /* Property list pointer */
H5L_type_t link_type = H5L_TYPE_EXTERNAL;
herr_t ret_value = SUCCEED; /* Return value */
@@ -400,20 +399,8 @@ H5Lcreate_external(const char *file_name, const char *obj_name,
if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(link_loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier")
- /* Get the plist structure */
- if(NULL == (plist = (H5P_genplist_t *)H5I_object(lcpl_id)))
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
-
- /* Set creation properties */
- if(H5P_set(plist, H5VL_PROP_LINK_TYPE, &link_type) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value from plist")
- if(H5P_set(plist, H5VL_PROP_LINK_UDATA, &ext_link_buf) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value from plist")
- if(H5P_set(plist, H5VL_PROP_LINK_UDATA_SIZE, &buf_size) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value from plist")
-
/* Create an external link */
- if(H5VL_link_create(H5VL_LINK_CREATE_UD, vol_obj, &loc_params, lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0)
+ if(H5VL_link_create(H5VL_LINK_CREATE_UD, vol_obj, &loc_params, lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)link_type, ext_link_buf, buf_size) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create external link")
done:
diff --git a/src/H5MM.c b/src/H5MM.c
index 866dfbe..85d82a9 100644
--- a/src/H5MM.c
+++ b/src/H5MM.c
@@ -274,7 +274,7 @@ H5MM_malloc(size_t size)
#if defined H5_MEMORY_ALLOC_SANITY_CHECK
/* Initialize block list head singleton */
if(!H5MM_init_s) {
- HDmemcpy(H5MM_block_head_s.sig, H5MM_block_signature_s, H5MM_SIG_SIZE);
+ H5MM_memcpy(H5MM_block_head_s.sig, H5MM_block_signature_s, H5MM_SIG_SIZE);
H5MM_block_head_s.next = &H5MM_block_head_s;
H5MM_block_head_s.prev = &H5MM_block_head_s;
H5MM_block_head_s.u.info.size = SIZET_MAX;
@@ -291,15 +291,15 @@ H5MM_malloc(size_t size)
if(NULL != (block = (H5MM_block_t *)HDmalloc(alloc_size))) {
/* Set up block */
- HDmemcpy(block->sig, H5MM_block_signature_s, H5MM_SIG_SIZE);
+ H5MM_memcpy(block->sig, H5MM_block_signature_s, H5MM_SIG_SIZE);
block->next = H5MM_block_head_s.next;
H5MM_block_head_s.next = block;
block->next->prev = block;
block->prev = &H5MM_block_head_s;
block->u.info.size = size;
block->u.info.in_use = TRUE;
- HDmemcpy(block->b, H5MM_block_head_guard_s, H5MM_HEAD_GUARD_SIZE);
- HDmemcpy(block->b + H5MM_HEAD_GUARD_SIZE + size, H5MM_block_tail_guard_s, H5MM_TAIL_GUARD_SIZE);
+ H5MM_memcpy(block->b, H5MM_block_head_guard_s, H5MM_HEAD_GUARD_SIZE);
+ H5MM_memcpy(block->b + H5MM_HEAD_GUARD_SIZE + size, H5MM_block_tail_guard_s, H5MM_TAIL_GUARD_SIZE);
/* Update statistics */
H5MM_total_alloc_bytes_s += size;
@@ -417,7 +417,7 @@ H5MM_realloc(void *mem, size_t size)
H5MM__sanity_check(mem);
ret_value = H5MM_malloc(size);
- HDmemcpy(ret_value, mem, MIN(size, old_size));
+ H5MM_memcpy(ret_value, mem, MIN(size, old_size));
H5MM_xfree(mem);
} /* end if */
else
@@ -564,3 +564,39 @@ H5MM_xfree(void *mem)
FUNC_LEAVE_NOAPI(NULL)
} /* end H5MM_xfree() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5MM_memcpy
+ *
+ * Purpose: Like memcpy(3) but with sanity checks on the parameters,
+ * particularly buffer overlap.
+ *
+ * Return: Success: pointer to dest
+ * Failure: NULL
+ *
+ * Programmer: Dana Robinson
+ * Spring 2019
+ *
+ *-------------------------------------------------------------------------
+ */
+void *
+H5MM_memcpy(void *dest, const void *src, size_t n)
+{
+ void *ret = NULL;
+
+ /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
+ FUNC_ENTER_NOAPI_NOINIT_NOERR
+
+ HDassert(dest);
+ HDassert(src);
+
+ /* Check for buffer overlap */
+ HDassert((char *)dest >= (const char *)src + n || (const char *)src >= (char *)dest + n);
+
+ /* Copy */
+ ret = HDmemcpy(dest, src, n);
+
+ FUNC_LEAVE_NOAPI(ret)
+
+} /* end H5MM_memcpy() */
+
diff --git a/src/H5MMprivate.h b/src/H5MMprivate.h
index 0524601..2053215 100644
--- a/src/H5MMprivate.h
+++ b/src/H5MMprivate.h
@@ -45,6 +45,7 @@ H5_DLL void *H5MM_realloc(void *mem, size_t size);
H5_DLL char *H5MM_xstrdup(const char *s);
H5_DLL char *H5MM_strdup(const char *s);
H5_DLL void *H5MM_xfree(void *mem);
+H5_DLL void *H5MM_memcpy(void *dest, const void *src, size_t n);
#if defined H5_MEMORY_ALLOC_SANITY_CHECK
H5_DLL void H5MM_sanity_check_all(void);
H5_DLL void H5MM_final_sanity_check(void);
diff --git a/src/H5O.c b/src/H5O.c
index 4e2f603..093d429 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -314,7 +314,6 @@ H5Olink(hid_t obj_id, hid_t new_loc_id, const char *new_name, hid_t lcpl_id,
H5VL_object_t tmp_vol_obj; /* Temporary object token of */
H5VL_loc_params_t loc_params1;
H5VL_loc_params_t loc_params2;
- H5P_genplist_t *plist; /* Property list pointer */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -363,22 +362,12 @@ H5Olink(hid_t obj_id, hid_t new_loc_id, const char *new_name, hid_t lcpl_id,
if (vol_obj1->connector->cls->value != vol_obj2->connector->cls->value)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Objects are accessed through different VOL connectors and can't be linked")
- /* Get the plist structure */
- if(NULL == (plist = (H5P_genplist_t *)H5I_object(lcpl_id)))
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
-
- /* set creation properties */
- if(H5P_set(plist, H5VL_PROP_LINK_TARGET, &vol_obj1->data) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for target id")
- if(H5P_set(plist, H5VL_PROP_LINK_TARGET_LOC_PARAMS, &loc_params1) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for target id")
-
/* Construct a temporary VOL object */
tmp_vol_obj.data = vol_obj2->data;
tmp_vol_obj.connector = (vol_obj1 != NULL ? vol_obj1->connector : vol_obj2->connector);
/* Create a link to the object */
- if(H5VL_link_create(H5VL_LINK_CREATE_HARD, &tmp_vol_obj, &loc_params2, lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0)
+ if(H5VL_link_create(H5VL_LINK_CREATE_HARD, &tmp_vol_obj, &loc_params2, lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, vol_obj1->data, loc_params1) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, "unable to create link")
done:
@@ -1113,6 +1102,7 @@ H5Oclose(hid_t object_id)
case H5I_ERROR_CLASS:
case H5I_ERROR_MSG:
case H5I_ERROR_STACK:
+ case H5I_SPACE_SEL_ITER:
case H5I_NTYPES:
default:
HGOTO_ERROR(H5E_ARGS, H5E_CANTRELEASE, FAIL, "not a valid file object ID (dataset, group, or datatype)")
diff --git a/src/H5Oalloc.c b/src/H5Oalloc.c
index 23dd928..c1f90cb 100644
--- a/src/H5Oalloc.c
+++ b/src/H5Oalloc.c
@@ -36,6 +36,7 @@
#include "H5Eprivate.h" /* Error handling */
#include "H5FLprivate.h" /* Free lists */
#include "H5MFprivate.h" /* File memory management */
+#include "H5MMprivate.h" /* Memory management */
#include "H5Opkg.h" /* Object headers */
/****************/
@@ -949,7 +950,7 @@ H5O__alloc_chunk(H5F_t *f, H5O_t *oh, size_t size, size_t found_null,
* # at the beginning of the chunk image.
*/
if(oh->version > H5O_VERSION_1) {
- HDmemcpy(p, H5O_CHK_MAGIC, (size_t)H5_SIZEOF_MAGIC);
+ H5MM_memcpy(p, H5O_CHK_MAGIC, (size_t)H5_SIZEOF_MAGIC);
p += H5_SIZEOF_MAGIC;
} /* end if */
@@ -988,7 +989,7 @@ H5O__alloc_chunk(H5F_t *f, H5O_t *oh, size_t size, size_t found_null,
HDassert(curr_msg->type->id != H5O_CONT_ID);
/* Copy the raw data */
- HDmemcpy(p, curr_msg->raw - (size_t)H5O_SIZEOF_MSGHDR_OH(oh),
+ H5MM_memcpy(p, curr_msg->raw - (size_t)H5O_SIZEOF_MSGHDR_OH(oh),
curr_msg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh));
/* Update the message info */
@@ -1044,7 +1045,7 @@ H5O__alloc_chunk(H5F_t *f, H5O_t *oh, size_t size, size_t found_null,
null_msg->chunkno = oh->mesg[found_msg->msgno].chunkno;
/* Copy the message to move (& its prefix) to its new location */
- HDmemcpy(p, oh->mesg[found_msg->msgno].raw - H5O_SIZEOF_MSGHDR_OH(oh),
+ H5MM_memcpy(p, oh->mesg[found_msg->msgno].raw - H5O_SIZEOF_MSGHDR_OH(oh),
oh->mesg[found_msg->msgno].raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh));
/* Switch moved message to point to new location */
@@ -1519,7 +1520,7 @@ H5O__move_cont(H5F_t *f, H5O_t *oh, unsigned cont_u)
move_size = curr_msg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh);
/* Move message out of deleted chunk */
- HDmemcpy(move_start, curr_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh), move_size);
+ H5MM_memcpy(move_start, curr_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh), move_size);
curr_msg->raw = move_start + H5O_SIZEOF_MSGHDR_OH(oh);
curr_msg->chunkno = cont_chunkno;
chk_dirtied = TRUE;
@@ -1791,7 +1792,7 @@ H5O__move_msgs_forward(H5F_t *f, H5O_t *oh)
} /* end if */
/* Copy raw data for non-null message to new chunk */
- HDmemcpy(null_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh), curr_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh), curr_msg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh));
+ H5MM_memcpy(null_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh), curr_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh), curr_msg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh));
/* Point non-null message at null message's space */
curr_msg->chunkno = null_msg->chunkno;
diff --git a/src/H5Oattr.c b/src/H5Oattr.c
index c420046..f685a00c 100644
--- a/src/H5Oattr.c
+++ b/src/H5Oattr.c
@@ -200,7 +200,7 @@ H5O_attr_decode(H5F_t *f, H5O_t *open_oh, unsigned H5_ATTR_UNUSED mesg_flags,
* What's actually shared, though, is only the extent.
*/
if(NULL == (attr->shared->ds = H5FL_CALLOC(H5S_t)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
/* Decode attribute's dataspace extent */
if((extent = (H5S_extent_t *)(H5O_MSG_SDSPACE->decode)(f, open_oh,
@@ -208,7 +208,7 @@ H5O_attr_decode(H5F_t *f, H5O_t *open_oh, unsigned H5_ATTR_UNUSED mesg_flags,
HGOTO_ERROR(H5E_ATTR, H5E_CANTDECODE, NULL, "can't decode attribute dataspace")
/* Copy the extent information to the dataspace */
- HDmemcpy(&(attr->shared->ds->extent), extent, sizeof(H5S_extent_t));
+ H5MM_memcpy(&(attr->shared->ds->extent), extent, sizeof(H5S_extent_t));
/* Release temporary extent information */
extent = H5FL_FREE(H5S_extent_t, extent);
@@ -240,7 +240,7 @@ H5O_attr_decode(H5F_t *f, H5O_t *open_oh, unsigned H5_ATTR_UNUSED mesg_flags,
if(attr->shared->data_size) {
if(NULL == (attr->shared->data = H5FL_BLK_MALLOC(attr_buf, attr->shared->data_size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
- HDmemcpy(attr->shared->data, p, attr->shared->data_size);
+ H5MM_memcpy(attr->shared->data, p, attr->shared->data_size);
} /* end if */
/* Increment the reference count for this object header message in cache(compact
@@ -253,15 +253,11 @@ H5O_attr_decode(H5F_t *f, H5O_t *open_oh, unsigned H5_ATTR_UNUSED mesg_flags,
done:
if(NULL == ret_value)
if(attr) {
- if(attr->shared) {
- /* Free any dynamically allocated items */
- if(H5A__free(attr) < 0)
+ /* Free any dynamically allocated items */
+ if(attr->shared)
+ if(H5A__shared_free(attr) < 0)
HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, NULL, "can't release attribute info")
- /* Destroy shared attribute struct */
- attr->shared = H5FL_FREE(H5A_shared_t, attr->shared);
- } /* end if */
-
attr = H5FL_FREE(H5A_t, attr);
} /* end if */
@@ -336,7 +332,7 @@ H5O_attr_encode(H5F_t *f, uint8_t *p, const void *mesg)
*p++ = attr->shared->encoding;
/* Write the name including null terminator */
- HDmemcpy(p, attr->shared->name, name_len);
+ H5MM_memcpy(p, attr->shared->name, name_len);
if(attr->shared->version < H5O_ATTR_VERSION_2) {
/* Pad to the correct number of bytes */
HDmemset(p + name_len, 0, H5O_ALIGN_OLD(name_len) - name_len);
@@ -369,7 +365,7 @@ H5O_attr_encode(H5F_t *f, uint8_t *p, const void *mesg)
/* Store attribute data. If there's no data, store 0 as fill value. */
if(attr->shared->data)
- HDmemcpy(p, attr->shared->data, attr->shared->data_size);
+ H5MM_memcpy(p, attr->shared->data, attr->shared->data_size);
else
HDmemset(p, 0, attr->shared->data_size);
diff --git a/src/H5Oattribute.c b/src/H5Oattribute.c
index 6e135c5..57ec9b8 100644
--- a/src/H5Oattribute.c
+++ b/src/H5Oattribute.c
@@ -862,7 +862,7 @@ H5O__attr_write_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/,
/* (Needs to occur before updating the shared message, or the hash
* value on the old & new messages will be the same) */
- HDmemcpy(((H5A_t *)mesg->native)->shared->data, udata->attr->shared->data, udata->attr->shared->data_size);
+ H5MM_memcpy(((H5A_t *)mesg->native)->shared->data, udata->attr->shared->data, udata->attr->shared->data_size);
} /* end if */
/* Mark the message as modified */
diff --git a/src/H5Ocache.c b/src/H5Ocache.c
index 578cff0..683d155 100644
--- a/src/H5Ocache.c
+++ b/src/H5Ocache.c
@@ -36,6 +36,7 @@
#include "H5Eprivate.h" /* Error handling */
#include "H5FLprivate.h" /* Free lists */
#include "H5MFprivate.h" /* File memory management */
+#include "H5MMprivate.h" /* Memory management */
#include "H5Opkg.h" /* Object headers */
#include "H5WBprivate.h" /* Wrapped Buffers */
@@ -542,7 +543,7 @@ H5O__cache_serialize(const H5F_t *f, void *image, size_t len, void *_thing)
* Can we rework things so that the object header and the cache
* share a buffer?
*/
- HDmemcpy(image, oh->chunk[0].image, len);
+ H5MM_memcpy(image, oh->chunk[0].image, len);
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -900,7 +901,7 @@ H5O__cache_chk_serialize(const H5F_t *f, void *image, size_t len, void *_thing)
/* copy the chunk into the image -- this is potentially expensive.
* Can we rework things so that the chunk and the cache share a buffer?
*/
- HDmemcpy(image, chk_proxy->oh->chunk[chk_proxy->chunkno].image, len);
+ H5MM_memcpy(image, chk_proxy->oh->chunk[chk_proxy->chunkno].image, len);
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -1352,7 +1353,7 @@ H5O__chunk_deserialize(H5O_t *oh, haddr_t addr, size_t len, const uint8_t *image
oh->chunk[chunkno].chunk_proxy = NULL;
/* Copy disk image into chunk's image */
- HDmemcpy(oh->chunk[chunkno].image, image, oh->chunk[chunkno].size);
+ H5MM_memcpy(oh->chunk[chunkno].image, image, oh->chunk[chunkno].size);
/* Point into chunk image to decode */
chunk_image = oh->chunk[chunkno].image;
diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c
index a3d4884..9578f95 100644
--- a/src/H5Ocopy.c
+++ b/src/H5Ocopy.c
@@ -732,7 +732,7 @@ H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/,
* header. This will be written when the header is flushed to disk.
*/
if(oh_dst->version > H5O_VERSION_1)
- HDmemcpy(current_pos, H5O_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC);
+ H5MM_memcpy(current_pos, H5O_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC);
current_pos += H5O_SIZEOF_HDR(oh_dst) - H5O_SIZEOF_CHKSUM_OH(oh_dst);
/* Loop through destination messages, updating their "raw" info */
@@ -755,7 +755,7 @@ H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/,
/* Copy each message that wasn't dirtied above */
if(!mesg_dst->dirty)
/* Copy the message header plus the message's raw data. */
- HDmemcpy(current_pos, mesg_src->raw - msghdr_size, msghdr_size + mesg_src->raw_size);
+ H5MM_memcpy(current_pos, mesg_src->raw - msghdr_size, msghdr_size + mesg_src->raw_size);
/* Set message's raw pointer to destination chunk's new "image" */
mesg_dst->raw = current_pos + msghdr_size;
diff --git a/src/H5Odrvinfo.c b/src/H5Odrvinfo.c
index 159c950..eb678e4 100644
--- a/src/H5Odrvinfo.c
+++ b/src/H5Odrvinfo.c
@@ -101,7 +101,7 @@ H5O_drvinfo_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh,
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for driver info message")
/* Retrieve driver name */
- HDmemcpy(mesg->name, p, 8);
+ H5MM_memcpy(mesg->name, p, 8);
mesg->name[8] = '\0';
p += 8;
@@ -116,7 +116,7 @@ H5O_drvinfo_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh,
} /* end if */
/* Copy encoded driver info into buffer */
- HDmemcpy(mesg->buf, p, mesg->len);
+ H5MM_memcpy(mesg->buf, p, mesg->len);
/* Set return value */
ret_value = (void *)mesg;
@@ -152,11 +152,11 @@ H5O_drvinfo_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_share
/* Store version, driver name, buffer length, & encoded buffer */
*p++ = H5O_DRVINFO_VERSION;
- HDmemcpy(p, mesg->name, 8);
+ H5MM_memcpy(p, mesg->name, 8);
p += 8;
HDassert(mesg->len <= 65535);
UINT16ENCODE(p, mesg->len);
- HDmemcpy(p, mesg->buf, mesg->len);
+ H5MM_memcpy(p, mesg->buf, mesg->len);
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5O_drvinfo_encode() */
@@ -200,7 +200,7 @@ H5O_drvinfo_copy(const void *_mesg, void *_dest)
dest = (H5O_drvinfo_t *)H5MM_xfree(dest);
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
} /* end if */
- HDmemcpy(dest->buf, mesg->buf, mesg->len);
+ H5MM_memcpy(dest->buf, mesg->buf, mesg->len);
/* Set return value */
ret_value = dest;
diff --git a/src/H5Odtype.c b/src/H5Odtype.c
index 28970d1..39d8bac 100644
--- a/src/H5Odtype.c
+++ b/src/H5Odtype.c
@@ -250,7 +250,7 @@ H5O_dtype_decode_helper(H5F_t *f, unsigned *ioflags/*in,out*/, const uint8_t **p
HDassert(0 == (z & 0x7)); /*must be aligned*/
if(NULL == (dt->shared->u.opaque.tag = (char *)H5MM_malloc(z + 1)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
- HDmemcpy(dt->shared->u.opaque.tag, *pp, z);
+ H5MM_memcpy(dt->shared->u.opaque.tag, *pp, z);
dt->shared->u.opaque.tag[z] = '\0';
*pp += z;
break;
@@ -483,7 +483,7 @@ H5O_dtype_decode_helper(H5F_t *f, unsigned *ioflags/*in,out*/, const uint8_t **p
} /* end for */
/* Values */
- HDmemcpy(dt->shared->u.enumer.value, *pp,
+ H5MM_memcpy(dt->shared->u.enumer.value, *pp,
dt->shared->u.enumer.nmembs * dt->shared->parent->shared->size);
*pp += dt->shared->u.enumer.nmembs * dt->shared->parent->shared->size;
break;
@@ -882,7 +882,7 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt)
z = HDstrlen(dt->shared->u.opaque.tag);
aligned = (z + 7) & (H5T_OPAQUE_TAG_MAX - 8);
flags = (unsigned)(flags | aligned);
- HDmemcpy(*pp, dt->shared->u.opaque.tag, MIN(z,aligned));
+ H5MM_memcpy(*pp, dt->shared->u.opaque.tag, MIN(z,aligned));
for(n = MIN(z, aligned); n < aligned; n++)
(*pp)[n] = 0;
*pp += aligned;
@@ -997,7 +997,7 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt)
} /* end for */
/* Values */
- HDmemcpy(*pp, dt->shared->u.enumer.value, dt->shared->u.enumer.nmembs * dt->shared->parent->shared->size);
+ H5MM_memcpy(*pp, dt->shared->u.enumer.value, dt->shared->u.enumer.nmembs * dt->shared->parent->shared->size);
*pp += dt->shared->u.enumer.nmembs * dt->shared->parent->shared->size;
break;
diff --git a/src/H5Oefl.c b/src/H5Oefl.c
index 6a81a46..b18d819 100644
--- a/src/H5Oefl.c
+++ b/src/H5Oefl.c
@@ -461,7 +461,7 @@ H5O__efl_copy_file(H5F_t H5_ATTR_UNUSED *file_src, void *mesg_src, H5F_t *file_d
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
/* Copy the "top level" information */
- HDmemcpy(efl_dst, efl_src, sizeof(H5O_efl_t));
+ H5MM_memcpy(efl_dst, efl_src, sizeof(H5O_efl_t));
/* Determine size needed for destination heap */
heap_size = H5HL_ALIGN(1); /* "empty" name */
@@ -488,7 +488,7 @@ H5O__efl_copy_file(H5F_t H5_ATTR_UNUSED *file_src, void *mesg_src, H5F_t *file_d
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
/* copy content from the source. Need to update later */
- HDmemcpy(efl_dst->slot, efl_src->slot, size);
+ H5MM_memcpy(efl_dst->slot, efl_src->slot, size);
} /* end if */
/* copy the name from the source */
diff --git a/src/H5Ofill.c b/src/H5Ofill.c
index 125da36..53abff3 100644
--- a/src/H5Ofill.c
+++ b/src/H5Ofill.c
@@ -156,7 +156,8 @@ const H5O_msg_class_t H5O_MSG_FILL_NEW[1] = {{
/* Format version bounds for fill value */
const unsigned H5O_fill_ver_bounds[] = {
H5O_FILL_VERSION_1, /* H5F_LIBVER_EARLIEST */
- H5O_FILL_VERSION_2, /* H5F_LIBVER_V18 */
+ H5O_FILL_VERSION_3, /* H5F_LIBVER_V18 */
+ H5O_FILL_VERSION_3, /* H5F_LIBVER_V110 */
H5O_FILL_VERSION_LATEST /* H5F_LIBVER_LATEST */
};
@@ -232,7 +233,7 @@ H5O_fill_new_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh,
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "destination buffer too small")
if(NULL == (fill->buf = H5MM_malloc((size_t)fill->size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fill value")
- HDmemcpy(fill->buf, p, (size_t)fill->size);
+ H5MM_memcpy(fill->buf, p, (size_t)fill->size);
} /* end if */
} /* end if */
else
@@ -270,7 +271,7 @@ H5O_fill_new_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh,
H5_CHECK_OVERFLOW(fill->size, ssize_t, size_t);
if(NULL == (fill->buf = H5MM_malloc((size_t)fill->size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fill value")
- HDmemcpy(fill->buf, p, (size_t)fill->size);
+ H5MM_memcpy(fill->buf, p, (size_t)fill->size);
/* Set the "defined" flag */
fill->fill_defined = TRUE;
@@ -353,7 +354,7 @@ H5O_fill_old_decode(H5F_t *f, H5O_t *open_oh,
if(NULL == (fill->buf = H5MM_malloc((size_t)fill->size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fill value")
- HDmemcpy(fill->buf, p, (size_t)fill->size);
+ H5MM_memcpy(fill->buf, p, (size_t)fill->size);
fill->fill_defined = TRUE;
} /* end if */
else
@@ -420,7 +421,7 @@ H5O_fill_new_encode(H5F_t H5_ATTR_UNUSED *f, uint8_t *p, const void *_fill)
if(fill->size > 0)
if(fill->buf) {
H5_CHECK_OVERFLOW(fill->size, ssize_t, size_t);
- HDmemcpy(p, fill->buf, (size_t)fill->size);
+ H5MM_memcpy(p, fill->buf, (size_t)fill->size);
} /* end if */
} /* end if */
} /* end if */
@@ -459,7 +460,7 @@ H5O_fill_new_encode(H5F_t H5_ATTR_UNUSED *f, uint8_t *p, const void *_fill)
/* Encode the fill value */
HDassert(fill->buf);
H5_CHECK_OVERFLOW(fill->size, ssize_t, size_t);
- HDmemcpy(p, fill->buf, (size_t)fill->size);
+ H5MM_memcpy(p, fill->buf, (size_t)fill->size);
} /* end if */
else {
/* Flags */
@@ -499,7 +500,7 @@ H5O_fill_old_encode(H5F_t H5_ATTR_UNUSED *f, uint8_t *p, const void *_fill)
UINT32ENCODE(p, fill->size);
if(fill->buf)
- HDmemcpy(p, fill->buf, (size_t)fill->size);
+ H5MM_memcpy(p, fill->buf, (size_t)fill->size);
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5O_fill_old_encode() */
@@ -551,7 +552,7 @@ H5O_fill_copy(const void *_src, void *_dst)
H5_CHECK_OVERFLOW(src->size, ssize_t, size_t);
if(NULL == (dst->buf = H5MM_malloc((size_t)src->size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fill value")
- HDmemcpy(dst->buf, src->buf, (size_t)src->size);
+ H5MM_memcpy(dst->buf, src->buf, (size_t)src->size);
/* Check for needing to convert/copy fill value */
if(src->type) {
@@ -890,40 +891,40 @@ H5O__fill_debug(H5F_t H5_ATTR_UNUSED *f, const void *_fill, FILE *stream,
HDfprintf(stream, "%*s%-*s ", indent, "", fwidth, "Space Allocation Time:");
switch(fill->alloc_time) {
case H5D_ALLOC_TIME_EARLY:
- fprintf(stream,"Early\n");
+ HDfprintf(stream,"Early\n");
break;
case H5D_ALLOC_TIME_LATE:
- fprintf(stream,"Late\n");
+ HDfprintf(stream,"Late\n");
break;
case H5D_ALLOC_TIME_INCR:
- fprintf(stream,"Incremental\n");
+ HDfprintf(stream,"Incremental\n");
break;
case H5D_ALLOC_TIME_DEFAULT:
case H5D_ALLOC_TIME_ERROR:
default:
- fprintf(stream,"Unknown!\n");
+ HDfprintf(stream,"Unknown!\n");
break;
} /* end switch */
HDfprintf(stream, "%*s%-*s ", indent, "", fwidth, "Fill Time:");
switch(fill->fill_time) {
case H5D_FILL_TIME_ALLOC:
- fprintf(stream,"On Allocation\n");
+ HDfprintf(stream,"On Allocation\n");
break;
case H5D_FILL_TIME_NEVER:
- fprintf(stream,"Never\n");
+ HDfprintf(stream,"Never\n");
break;
case H5D_FILL_TIME_IFSET:
- fprintf(stream,"If Set\n");
+ HDfprintf(stream,"If Set\n");
break;
case H5D_FILL_TIME_ERROR:
default:
- fprintf(stream,"Unknown!\n");
+ HDfprintf(stream,"Unknown!\n");
break;
} /* end switch */
@@ -931,20 +932,20 @@ H5O__fill_debug(H5F_t H5_ATTR_UNUSED *f, const void *_fill, FILE *stream,
H5P_is_fill_value_defined((const H5O_fill_t *)fill, &fill_status);
switch(fill_status) {
case H5D_FILL_VALUE_UNDEFINED:
- fprintf(stream,"Undefined\n");
+ HDfprintf(stream,"Undefined\n");
break;
case H5D_FILL_VALUE_DEFAULT:
- fprintf(stream,"Default\n");
+ HDfprintf(stream,"Default\n");
break;
case H5D_FILL_VALUE_USER_DEFINED:
- fprintf(stream,"User Defined\n");
+ HDfprintf(stream,"User Defined\n");
break;
case H5D_FILL_VALUE_ERROR:
default:
- fprintf(stream,"Unknown!\n");
+ HDfprintf(stream,"Unknown!\n");
break;
} /* end switch */
@@ -1025,7 +1026,7 @@ H5O_fill_convert(H5O_fill_t *fill, H5T_t *dset_type, hbool_t *fill_changed)
else {
if(NULL == (buf = H5MM_malloc(H5T_get_size(dset_type))))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion")
- HDmemcpy(buf, fill->buf, H5T_get_size(fill->type));
+ H5MM_memcpy(buf, fill->buf, H5T_get_size(fill->type));
} /* end else */
/* Use CALLOC here to clear the buffer in case later the library thinks there's
diff --git a/src/H5Oflush.c b/src/H5Oflush.c
index da9d1d0..f5ede4a 100644
--- a/src/H5Oflush.c
+++ b/src/H5Oflush.c
@@ -491,6 +491,7 @@ H5O_refresh_metadata_reopen(hid_t oid, H5G_loc_t *obj_loc, H5VL_t *vol_connector
case H5I_ERROR_CLASS:
case H5I_ERROR_MSG:
case H5I_ERROR_STACK:
+ case H5I_SPACE_SEL_ITER:
case H5I_NTYPES:
default:
HGOTO_ERROR(H5E_OHDR, H5E_BADTYPE, FAIL, "not a valid file object ID (dataset, group, or datatype)")
diff --git a/src/H5Oint.c b/src/H5Oint.c
index d3a409c..45a8046 100644
--- a/src/H5Oint.c
+++ b/src/H5Oint.c
@@ -38,9 +38,7 @@
#include "H5Iprivate.h" /* IDs */
#include "H5Lprivate.h" /* Links */
#include "H5MFprivate.h" /* File memory management */
-#ifdef H5O_ENABLE_BOGUS
#include "H5MMprivate.h" /* Memory management */
-#endif /* H5O_ENABLE_BOGUS */
#include "H5Opkg.h" /* Object headers */
#include "H5VLprivate.h" /* Virtual Object Layer */
@@ -132,6 +130,7 @@ const H5O_msg_class_t *const H5O_msg_class_g[] = {
const unsigned H5O_obj_ver_bounds[] = {
H5O_VERSION_1, /* H5F_LIBVER_EARLIEST */
H5O_VERSION_2, /* H5F_LIBVER_V18 */
+ H5O_VERSION_2, /* H5F_LIBVER_V110 */
H5O_VERSION_LATEST /* H5F_LIBVER_LATEST */
};
@@ -496,7 +495,7 @@ H5O__apply_ohdr(H5F_t *f, H5O_t *oh, hid_t ocpl_id, size_t size_hint, size_t ini
/* Put magic # for object header in first chunk */
if(H5O_VERSION_1 < oh->version)
- HDmemcpy(oh->chunk[0].image, H5O_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC);
+ H5MM_memcpy(oh->chunk[0].image, H5O_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC);
/* Create the message list */
oh->nmesgs = 1;
@@ -1849,6 +1848,7 @@ H5O_get_loc(hid_t object_id)
case H5I_ERROR_CLASS:
case H5I_ERROR_MSG:
case H5I_ERROR_STACK:
+ case H5I_SPACE_SEL_ITER:
case H5I_NTYPES:
default:
HGOTO_ERROR(H5E_OHDR, H5E_BADTYPE, NULL, "invalid object type")
@@ -1921,7 +1921,7 @@ H5O_loc_copy(H5O_loc_t *dst, H5O_loc_t *src, H5_copy_depth_t depth)
HDassert(depth == H5_COPY_SHALLOW || depth == H5_COPY_DEEP);
/* Copy the top level information */
- HDmemcpy(dst, src, sizeof(H5O_loc_t));
+ H5MM_memcpy(dst, src, sizeof(H5O_loc_t));
/* Deep copy the names */
if(depth == H5_COPY_DEEP) {
diff --git a/src/H5Olayout.c b/src/H5Olayout.c
index 317654a..25cae05 100644
--- a/src/H5Olayout.c
+++ b/src/H5Olayout.c
@@ -189,7 +189,7 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh,
if(mesg->storage.u.compact.size > 0) {
if(NULL == (mesg->storage.u.compact.buf = H5MM_malloc(mesg->storage.u.compact.size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for compact data buffer")
- HDmemcpy(mesg->storage.u.compact.buf, p, mesg->storage.u.compact.size);
+ H5MM_memcpy(mesg->storage.u.compact.buf, p, mesg->storage.u.compact.size);
p += mesg->storage.u.compact.size;
} /* end if */
} /* end if */
@@ -210,7 +210,7 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh,
HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, NULL, "memory allocation failed for compact data buffer")
/* Compact data */
- HDmemcpy(mesg->storage.u.compact.buf, p, mesg->storage.u.compact.size);
+ H5MM_memcpy(mesg->storage.u.compact.buf, p, mesg->storage.u.compact.size);
p += mesg->storage.u.compact.size;
} /* end if */
@@ -425,14 +425,14 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh,
tmp_size = HDstrlen((const char *)heap_block_p) + 1;
if(NULL == (mesg->storage.u.virt.list[i].source_file_name = (char *)H5MM_malloc(tmp_size)))
HGOTO_ERROR(H5E_OHDR, H5E_RESOURCE, NULL, "unable to allocate memory for source file name")
- (void)HDmemcpy(mesg->storage.u.virt.list[i].source_file_name, heap_block_p, tmp_size);
+ (void)H5MM_memcpy(mesg->storage.u.virt.list[i].source_file_name, heap_block_p, tmp_size);
heap_block_p += tmp_size;
/* Source dataset name */
tmp_size = HDstrlen((const char *)heap_block_p) + 1;
if(NULL == (mesg->storage.u.virt.list[i].source_dset_name = (char *)H5MM_malloc(tmp_size)))
HGOTO_ERROR(H5E_OHDR, H5E_RESOURCE, NULL, "unable to allocate memory for source dataset name")
- (void)HDmemcpy(mesg->storage.u.virt.list[i].source_dset_name, heap_block_p, tmp_size);
+ (void)H5MM_memcpy(mesg->storage.u.virt.list[i].source_dset_name, heap_block_p, tmp_size);
heap_block_p += tmp_size;
/* Source selection */
@@ -581,7 +581,7 @@ H5O__layout_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p,
/* Raw data */
if(mesg->storage.u.compact.size > 0) {
if(mesg->storage.u.compact.buf)
- HDmemcpy(p, mesg->storage.u.compact.buf, mesg->storage.u.compact.size);
+ H5MM_memcpy(p, mesg->storage.u.compact.buf, mesg->storage.u.compact.size);
else
HDmemset(p, 0, mesg->storage.u.compact.size);
p += mesg->storage.u.compact.size;
@@ -750,7 +750,7 @@ H5O__layout_copy(const void *_mesg, void *_dest)
HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "unable to allocate memory for compact dataset")
/* Copy over the raw data */
- HDmemcpy(dest->storage.u.compact.buf, mesg->storage.u.compact.buf, dest->storage.u.compact.size);
+ H5MM_memcpy(dest->storage.u.compact.buf, mesg->storage.u.compact.buf, dest->storage.u.compact.size);
} /* end if */
else
HDassert(dest->storage.u.compact.buf == NULL);
@@ -1047,7 +1047,8 @@ H5O__layout_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst,
layout_dst->storage.u.contig.size = H5S_extent_nelem(udata->src_space_extent) *
H5T_get_size(udata->src_dtype);
- if(H5D__contig_is_space_alloc(&layout_src->storage)) {
+ if(H5D__contig_is_space_alloc(&layout_src->storage)
+ || (cpy_info->shared_fo && H5D__contig_is_data_cached((const H5D_shared_t *)cpy_info->shared_fo))) {
/* copy contiguous raw data */
if(H5D__contig_copy(file_src, &layout_src->storage.u.contig, file_dst, &layout_dst->storage.u.contig, udata->src_dtype, cpy_info) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy contiguous storage")
@@ -1056,7 +1057,8 @@ H5O__layout_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst,
break;
case H5D_CHUNKED:
- if(H5D__chunk_is_space_alloc(&layout_src->storage)) {
+ if(H5D__chunk_is_space_alloc(&layout_src->storage)
+ || (cpy_info->shared_fo && H5D__chunk_is_data_cached((const H5D_shared_t *)cpy_info->shared_fo))) {
/* Create chunked layout */
if(H5D__chunk_copy(file_src, &layout_src->storage.u.chunk, &layout_src->u.chunk, file_dst, &layout_dst->storage.u.chunk, udata->src_space_extent, udata->src_dtype, udata->common.src_pline, cpy_info) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy chunked storage")
diff --git a/src/H5Olink.c b/src/H5Olink.c
index 55e1aee..4bd952b 100644
--- a/src/H5Olink.c
+++ b/src/H5Olink.c
@@ -202,7 +202,7 @@ H5O__link_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh,
/* Get the link's name */
if(NULL == (lnk->name = (char *)H5MM_malloc(len + 1)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
- HDmemcpy(lnk->name, p, len);
+ H5MM_memcpy(lnk->name, p, len);
lnk->name[len] = '\0';
p += len;
@@ -220,7 +220,7 @@ H5O__link_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh,
HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "invalid link length")
if(NULL == (lnk->u.soft.name = (char *)H5MM_malloc((size_t)len + 1)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
- HDmemcpy(lnk->u.soft.name, p, len);
+ H5MM_memcpy(lnk->u.soft.name, p, len);
lnk->u.soft.name[len] = '\0';
p += len;
break;
@@ -240,7 +240,7 @@ H5O__link_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh,
{
if(NULL == (lnk->u.ud.udata = H5MM_malloc((size_t)len)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
- HDmemcpy(lnk->u.ud.udata, p, len);
+ H5MM_memcpy(lnk->u.ud.udata, p, len);
p += len;
}
else
@@ -349,7 +349,7 @@ H5O_link_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, con
} /* end switch */
/* Store the link's name */
- HDmemcpy(p, lnk->name, (size_t)len);
+ H5MM_memcpy(p, lnk->name, (size_t)len);
p += len;
/* Store the appropriate information for each type of link */
@@ -364,7 +364,7 @@ H5O_link_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, con
len = (uint16_t)HDstrlen(lnk->u.soft.name);
HDassert(len > 0);
UINT16ENCODE(p, len)
- HDmemcpy(p, lnk->u.soft.name, (size_t)len);
+ H5MM_memcpy(p, lnk->u.soft.name, (size_t)len);
p += len;
break;
@@ -380,7 +380,7 @@ H5O_link_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, con
UINT16ENCODE(p, len)
if(len > 0)
{
- HDmemcpy(p, lnk->u.ud.udata, (size_t)len);
+ H5MM_memcpy(p, lnk->u.ud.udata, (size_t)len);
p+=len;
}
break;
@@ -437,7 +437,7 @@ H5O_link_copy(const void *_mesg, void *_dest)
if(lnk->u.ud.size > 0) {
if(NULL == (dest->u.ud.udata = H5MM_malloc(lnk->u.ud.size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
- HDmemcpy(dest->u.ud.udata, lnk->u.ud.udata, lnk->u.ud.size);
+ H5MM_memcpy(dest->u.ud.udata, lnk->u.ud.udata, lnk->u.ud.size);
} /* end if */
} /* end if */
diff --git a/src/H5Omtime.c b/src/H5Omtime.c
index 172f9ab..fbf7613 100644
--- a/src/H5Omtime.c
+++ b/src/H5Omtime.c
@@ -289,7 +289,7 @@ H5O_mtime_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared,
/* encode */
tm = HDgmtime(mesg);
- sprintf((char*)p, "%04d%02d%02d%02d%02d%02d",
+ HDsprintf((char*)p, "%04d%02d%02d%02d%02d%02d",
1900+tm->tm_year, 1+tm->tm_mon, tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec);
diff --git a/src/H5Oname.c b/src/H5Oname.c
index a710944..1f20f10 100644
--- a/src/H5Oname.c
+++ b/src/H5Oname.c
@@ -297,7 +297,7 @@ H5O__name_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream,
HDassert(indent >= 0);
HDassert(fwidth >= 0);
- fprintf(stream, "%*s%-*s `%s'\n", indent, "", fwidth,
+ HDfprintf(stream, "%*s%-*s `%s'\n", indent, "", fwidth,
"Name:",
mesg->s);
diff --git a/src/H5Opkg.h b/src/H5Opkg.h
index 668f4f0..4afa452 100644
--- a/src/H5Opkg.h
+++ b/src/H5Opkg.h
@@ -134,9 +134,9 @@
) : 0)) \
)
#define H5O_SIZEOF_MSGHDR_OH(O) \
- H5O_SIZEOF_MSGHDR_VERS((O)->version, (O)->flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED)
+ (unsigned)H5O_SIZEOF_MSGHDR_VERS((O)->version, (O)->flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED)
#define H5O_SIZEOF_MSGHDR_F(F, C) \
- H5O_SIZEOF_MSGHDR_VERS(MAX((H5F_STORE_MSG_CRT_IDX(F) ? H5O_VERSION_LATEST : H5O_VERSION_1), (uint8_t)H5O_obj_ver_bounds[H5F_LOW_BOUND(F)]), (C))
+ (unsigned)H5O_SIZEOF_MSGHDR_VERS(MAX((H5F_STORE_MSG_CRT_IDX(F) ? H5O_VERSION_LATEST : H5O_VERSION_1), (uint8_t)H5O_obj_ver_bounds[H5F_LOW_BOUND(F)]), (C))
/*
* Size of chunk "header" for each chunk
diff --git a/src/H5Opline.c b/src/H5Opline.c
index 1fae1b8..609f2eb 100644
--- a/src/H5Opline.c
+++ b/src/H5Opline.c
@@ -93,6 +93,7 @@ const H5O_msg_class_t H5O_MSG_PLINE[1] = {{
const unsigned H5O_pline_ver_bounds[] = {
H5O_PLINE_VERSION_1, /* H5F_LIBVER_EARLIEST */
H5O_PLINE_VERSION_2, /* H5F_LIBVER_V18 */
+ H5O_PLINE_VERSION_2, /* H5F_LIBVER_V110 */
H5O_PLINE_VERSION_LATEST /* H5F_LIBVER_LATEST */
};
@@ -318,7 +319,7 @@ H5O_pline_encode(H5F_t H5_ATTR_UNUSED *f, uint8_t *p/*out*/, const void *mesg)
/* Encode name, if there is one to encode */
if(name_length > 0) {
/* Store name, with null terminator */
- HDmemcpy(p, name, name_length);
+ H5MM_memcpy(p, name, name_length);
p += name_length;
/* Pad out name to alignment, in older versions */
@@ -409,7 +410,7 @@ H5O_pline_copy(const void *_src, void *_dst/*out*/)
if(NULL == (dst->filter[i].cd_values = (unsigned *)H5MM_malloc(src->filter[i].cd_nelmts* sizeof(unsigned))))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
- HDmemcpy(dst->filter[i].cd_values, src->filter[i].cd_values,
+ H5MM_memcpy(dst->filter[i].cd_values, src->filter[i].cd_values,
src->filter[i].cd_nelmts * sizeof(unsigned));
} /* end if */
else
diff --git a/src/H5Osdspace.c b/src/H5Osdspace.c
index 74fa72e..b7f70d1 100644
--- a/src/H5Osdspace.c
+++ b/src/H5Osdspace.c
@@ -189,7 +189,7 @@ H5O__sdspace_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh,
done:
if(!ret_value && sdim) {
- H5S_extent_release(sdim);
+ H5S__extent_release(sdim);
sdim = H5FL_FREE(H5S_extent_t, sdim);
} /* end if */
@@ -310,7 +310,7 @@ H5O_sdspace_copy(const void *_mesg, void *_dest)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
/* Copy extent information */
- if(H5S_extent_copy_real(dest, mesg, TRUE) < 0)
+ if(H5S__extent_copy_real(dest, mesg, TRUE) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "can't copy extent")
/* Set return value */
@@ -391,7 +391,7 @@ H5O__sdspace_reset(void *_mesg)
FUNC_ENTER_STATIC_NOERR
- H5S_extent_release(mesg);
+ H5S__extent_release(mesg);
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5O__sdspace_reset() */
@@ -470,7 +470,7 @@ H5O_sdspace_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void *mesg_src,
HGOTO_ERROR(H5E_DATASPACE, H5E_NOSPACE, FAIL, "dataspace extent allocation failed")
/* Create a copy of the dataspace extent */
- if(H5S_extent_copy_real(udata->src_space_extent, src_space_extent, TRUE) < 0)
+ if(H5S__extent_copy_real(udata->src_space_extent, src_space_extent, TRUE) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy extent")
} /* end if */
diff --git a/src/H5Oshared.c b/src/H5Oshared.c
index 4fc0488..67ca76f 100644
--- a/src/H5Oshared.c
+++ b/src/H5Oshared.c
@@ -39,6 +39,7 @@
#include "H5Fprivate.h" /* File access */
#include "H5Gprivate.h" /* Groups */
#include "H5HFprivate.h" /* Fractal heap */
+#include "H5MMprivate.h" /* Memory management */
#include "H5Opkg.h" /* Object headers */
#include "H5SMprivate.h" /* Shared object header messages */
#include "H5WBprivate.h" /* Wrapped Buffers */
@@ -358,7 +359,7 @@ H5O__shared_decode(H5F_t *f, H5O_t *open_oh, unsigned *ioflags, const uint8_t *b
*/
if(sh_mesg.type == H5O_SHARE_TYPE_SOHM) {
HDassert(version >= H5O_SHARED_VERSION_3);
- HDmemcpy(&sh_mesg.u.heap_id, buf, sizeof(sh_mesg.u.heap_id));
+ H5MM_memcpy(&sh_mesg.u.heap_id, buf, sizeof(sh_mesg.u.heap_id));
} /* end if */
else {
/* The H5O_COMMITTED_FLAG should be set if this message
@@ -426,7 +427,7 @@ H5O__shared_encode(const H5F_t *f, uint8_t *buf/*out*/, const H5O_shared_t *sh_m
* object header that holds it.
*/
if(sh_mesg->type == H5O_SHARE_TYPE_SOHM)
- HDmemcpy(buf, &(sh_mesg->u.heap_id), sizeof(sh_mesg->u.heap_id));
+ H5MM_memcpy(buf, &(sh_mesg->u.heap_id), sizeof(sh_mesg->u.heap_id));
else
H5F_addr_encode(f, &buf, sh_mesg->u.loc.oh_addr);
diff --git a/src/H5P.c b/src/H5P.c
index 72d7ae8..09ff7f0 100644
--- a/src/H5P.c
+++ b/src/H5P.c
@@ -817,14 +817,17 @@ done:
/*--------------------------------------------------------------------------
NAME
- H5Pencode
+ H5Pencode2
PURPOSE
- Routine to convert the property values in a property list into a binary buffer
+ Routine to convert the property values in a property list into a binary buffer.
+ The encoding of property values will be done according to the file format
+ setting in fapl_id.
USAGE
- herr_t H5Pencode(plist_id, buf, nalloc)
+ herr_t H5Pencode(plist_id, buf, nalloc, fapl_id)
hid_t plist_id; IN: Identifier to property list to encode
void *buf: OUT: buffer to gold the encoded plist
size_t *nalloc; IN/OUT: size of buffer needed to encode plist
+ hid_t fapl_id; IN: File access property list ID
RETURNS
Returns non-negative on success, negative on failure.
DESCRIPTION
@@ -837,25 +840,29 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
herr_t
-H5Pencode(hid_t plist_id, void *buf, size_t *nalloc)
+H5Pencode2(hid_t plist_id, void *buf, size_t *nalloc, hid_t fapl_id)
{
H5P_genplist_t *plist; /* Property list to query */
herr_t ret_value = SUCCEED; /* return value */
FUNC_ENTER_API(FAIL)
- H5TRACE3("e", "i*x*z", plist_id, buf, nalloc);
+ H5TRACE4("e", "i*x*zi", plist_id, buf, nalloc, fapl_id);
/* Check arguments. */
if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list");
+ /* Verify access property list and set up collective metadata if appropriate */
+ if(H5CX_set_apl(&fapl_id, H5P_CLS_FACC, H5I_INVALID_HID, TRUE) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info")
+
/* Call the internal encode routine */
if((ret_value = H5P__encode(plist, TRUE, buf, nalloc)) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTENCODE, FAIL, "unable to encode property list");
done:
FUNC_LEAVE_API(ret_value)
-} /* H5Pencode() */
+} /* H5Pencode2() */
/*--------------------------------------------------------------------------
diff --git a/src/H5PB.c b/src/H5PB.c
index a325ad1..25c5f43 100644
--- a/src/H5PB.c
+++ b/src/H5PB.c
@@ -36,6 +36,7 @@
#include "H5Fpkg.h" /* Files */
#include "H5FDprivate.h" /* File drivers */
#include "H5Iprivate.h" /* IDs */
+#include "H5MMprivate.h" /* Memory management */
#include "H5PBpkg.h" /* File access */
#include "H5SLprivate.h" /* Skip List */
@@ -252,7 +253,7 @@ H5PB_print_stats(const H5PB_t *page_buf)
HDassert(page_buf);
- printf("PAGE BUFFER STATISTICS:\n");
+ HDprintf("PAGE BUFFER STATISTICS:\n");
HDprintf("******* METADATA\n");
HDprintf("\t Total Accesses: %u\n", page_buf->accesses[0]);
@@ -609,7 +610,7 @@ H5PB_update_entry(H5PB_t *page_buf, haddr_t addr, size_t size, const void *buf)
HDassert(addr + size <= page_addr + page_buf->page_size);
offset = addr - page_addr;
- HDmemcpy((uint8_t *)page_entry->page_buf_ptr + offset, buf, size);
+ H5MM_memcpy((uint8_t *)page_entry->page_buf_ptr + offset, buf, size);
/* move to top of LRU list */
H5PB__MOVE_TO_TOP_LRU(page_buf, page_entry)
@@ -818,7 +819,7 @@ H5PB_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, void *buf/*out*/
offset = addr - first_page_addr;
HDassert(page_buf->page_size > offset);
- HDmemcpy(buf, (uint8_t *)page_entry->page_buf_ptr + offset,
+ H5MM_memcpy(buf, (uint8_t *)page_entry->page_buf_ptr + offset,
page_buf->page_size - (size_t)offset);
/* move to top of LRU list */
@@ -829,7 +830,7 @@ H5PB_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, void *buf/*out*/
offset = (num_touched_pages-2)*page_buf->page_size +
(page_buf->page_size - (addr - first_page_addr));
- HDmemcpy((uint8_t *)buf + offset, page_entry->page_buf_ptr,
+ H5MM_memcpy((uint8_t *)buf + offset, page_entry->page_buf_ptr,
(size_t)((addr + size) - last_page_addr));
/* move to top of LRU list */
@@ -839,7 +840,7 @@ H5PB_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, void *buf/*out*/
else {
offset = i*page_buf->page_size;
- HDmemcpy((uint8_t *)buf+(i*page_buf->page_size) , page_entry->page_buf_ptr,
+ H5MM_memcpy((uint8_t *)buf+(i*page_buf->page_size) , page_entry->page_buf_ptr,
page_buf->page_size);
} /* end else */
} /* end if */
@@ -872,7 +873,7 @@ H5PB_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, void *buf/*out*/
buf_offset = (0 == i ? 0 : size - access_size);
/* copy the requested data from the page into the input buffer */
- HDmemcpy((uint8_t *)buf + buf_offset, (uint8_t *)page_entry->page_buf_ptr + offset, access_size);
+ H5MM_memcpy((uint8_t *)buf + buf_offset, (uint8_t *)page_entry->page_buf_ptr + offset, access_size);
/* Update LRU */
H5PB__MOVE_TO_TOP_LRU(page_buf, page_entry)
@@ -937,7 +938,7 @@ H5PB_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, void *buf/*out*/
/* Copy the requested data from the page into the input buffer */
offset = (0 == i ? addr - search_addr : 0);
buf_offset = (0 == i ? 0 : size - access_size);
- HDmemcpy((uint8_t *)buf + buf_offset, (uint8_t *)new_page_buf + offset, access_size);
+ H5MM_memcpy((uint8_t *)buf + buf_offset, (uint8_t *)new_page_buf + offset, access_size);
/* Create the new PB entry */
if(NULL == (page_entry = H5FL_CALLOC(H5PB_entry_t)))
@@ -1102,7 +1103,7 @@ H5PB_write(H5F_t *f, H5FD_mem_t type, haddr_t addr,
HDassert(page_buf->page_size > offset);
/* Update page's data */
- HDmemcpy((uint8_t *)page_entry->page_buf_ptr + offset, buf, page_buf->page_size - (size_t)offset);
+ H5MM_memcpy((uint8_t *)page_entry->page_buf_ptr + offset, buf, page_buf->page_size - (size_t)offset);
/* Mark page dirty and push to top of LRU */
page_entry->is_dirty = TRUE;
@@ -1121,7 +1122,7 @@ H5PB_write(H5F_t *f, H5FD_mem_t type, haddr_t addr,
(page_buf->page_size - (addr - first_page_addr));
/* Update page's data */
- HDmemcpy(page_entry->page_buf_ptr, (const uint8_t *)buf + offset,
+ H5MM_memcpy(page_entry->page_buf_ptr, (const uint8_t *)buf + offset,
(size_t)((addr + size) - last_page_addr));
/* Mark page dirty and push to top of LRU */
@@ -1173,7 +1174,7 @@ H5PB_write(H5F_t *f, H5FD_mem_t type, haddr_t addr,
buf_offset = (0 == i ? 0 : size - access_size);
/* Copy the requested data from the input buffer into the page */
- HDmemcpy((uint8_t *)page_entry->page_buf_ptr + offset, (const uint8_t *)buf + buf_offset, access_size);
+ H5MM_memcpy((uint8_t *)page_entry->page_buf_ptr + offset, (const uint8_t *)buf + buf_offset, access_size);
/* Mark page dirty and push to top of LRU */
page_entry->is_dirty = TRUE;
@@ -1289,7 +1290,7 @@ H5PB_write(H5F_t *f, H5FD_mem_t type, haddr_t addr,
} /* end else */
/* Copy the requested data from the page into the input buffer */
- HDmemcpy((uint8_t *)new_page_buf + offset, (const uint8_t *)buf+buf_offset, access_size);
+ H5MM_memcpy((uint8_t *)new_page_buf + offset, (const uint8_t *)buf+buf_offset, access_size);
/* Page is dirty now */
page_entry->is_dirty = TRUE;
diff --git a/src/H5Pacpl.c b/src/H5Pacpl.c
index 2322c76..53e68fa 100644
--- a/src/H5Pacpl.c
+++ b/src/H5Pacpl.c
@@ -40,10 +40,6 @@
/* Local Macros */
/****************/
-/* Definitions for locations parameters */
-#define H5A_CRT_LOCATION_SIZE sizeof(H5VL_loc_params_t)
-#define H5A_CRT_LOCATION_DEF H5I_BADID
-
/******************/
/* Local Typedefs */
@@ -59,9 +55,6 @@
/* Local Prototypes */
/********************/
-/* Property class callbacks */
-static herr_t H5P_acrt_reg_prop(H5P_genclass_t *pclass);
-
/*********************/
/* Package Variables */
@@ -76,7 +69,7 @@ const H5P_libclass_t H5P_CLS_ACRT[1] = {{
&H5P_CLS_ATTRIBUTE_CREATE_g, /* Pointer to class */
&H5P_CLS_ATTRIBUTE_CREATE_ID_g, /* Pointer to class ID */
&H5P_LST_ATTRIBUTE_CREATE_ID_g, /* Pointer to default property list ID */
- H5P_acrt_reg_prop, /* Default property registration routine */
+ NULL, /* Default property registration routine */
NULL, /* Class creation callback */
NULL, /* Class creation callback info */
@@ -91,44 +84,3 @@ const H5P_libclass_t H5P_CLS_ACRT[1] = {{
/* Library Private Variables */
/*****************************/
-
-/*-------------------------------------------------------------------------
- * Function: H5P_acrt_reg_prop
- *
- * Purpose: Register the attribute creation property list class's properties
- *
- * Return: SUCCEED/FAIL
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5P_acrt_reg_prop(H5P_genclass_t *pclass)
-{
- hid_t type_id = H5I_INVALID_HID;
- hid_t space_id = H5I_INVALID_HID;
- H5VL_loc_params_t loc_params;
- herr_t ret_value = SUCCEED;
-
- FUNC_ENTER_NOAPI_NOINIT
-
- /* Register the type ID property*/
- if(H5P__register_real(pclass, H5VL_PROP_ATTR_TYPE_ID, sizeof(hid_t), &type_id,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
-
- /* Register the space ID property */
- if(H5P__register_real(pclass, H5VL_PROP_ATTR_SPACE_ID, sizeof(hid_t), &space_id,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
-
- /* Register the lcpl ID property */
- HDmemset(&loc_params, 0, sizeof(H5VL_loc_params_t));
- loc_params.obj_type = H5A_CRT_LOCATION_DEF;
- if(H5P__register_real(pclass, H5VL_PROP_ATTR_LOC_PARAMS, H5A_CRT_LOCATION_SIZE, &loc_params,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5P_acrt_reg_prop() */
-
diff --git a/src/H5Pdapl.c b/src/H5Pdapl.c
index 00e598f..5ce12b4 100644
--- a/src/H5Pdapl.c
+++ b/src/H5Pdapl.c
@@ -37,8 +37,8 @@
#include "H5Eprivate.h" /* Error handling */
#include "H5Fprivate.h" /* Files */
#include "H5Iprivate.h" /* IDs */
+#include "H5MMprivate.h" /* Memory management */
#include "H5Ppkg.h" /* Property lists */
-#include "H5MMprivate.h" /* Memory management */
/****************/
@@ -341,7 +341,7 @@ H5P__dapl_vds_file_pref_enc(const void *value, void **_pp, size_t *size)
/* encode the prefix */
if(NULL != vds_file_pref) {
- HDmemcpy(*(char **)pp, vds_file_pref, len);
+ H5MM_memcpy(*(char **)pp, vds_file_pref, len);
*pp += len;
} /* end if */
} /* end if */
@@ -589,7 +589,7 @@ H5P__dapl_efile_pref_enc(const void *value, void **_pp, size_t *size)
/* encode the prefix */
if(NULL != efile_pref) {
- HDmemcpy(*(char **)pp, efile_pref, len);
+ H5MM_memcpy(*(char **)pp, efile_pref, len);
*pp += len;
} /* end if */
} /* end if */
diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c
index b85f105..6b9edf1 100644
--- a/src/H5Pdcpl.c
+++ b/src/H5Pdcpl.c
@@ -246,9 +246,6 @@ static hbool_t H5P_dcrt_def_layout_init_g = FALSE;
static herr_t
H5P__dcrt_reg_prop(H5P_genclass_t *pclass)
{
- hid_t type_id = H5I_INVALID_HID;
- hid_t space_id = H5I_INVALID_HID;
- hid_t lcpl_id = H5P_LINK_CREATE_DEFAULT;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
@@ -283,21 +280,6 @@ H5P__dcrt_reg_prop(H5P_genclass_t *pclass)
NULL, NULL, NULL, NULL) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
- /* Register the type ID property*/
- if(H5P__register_real(pclass, H5VL_PROP_DSET_TYPE_ID, sizeof(hid_t), &type_id,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, H5P_ignore_cmp, NULL) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
-
- /* Register the space ID property */
- if(H5P__register_real(pclass, H5VL_PROP_DSET_SPACE_ID, sizeof(hid_t), &space_id,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, H5P_ignore_cmp, NULL) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
-
- /* Register the lcpl ID property */
- if(H5P__register_real(pclass, H5VL_PROP_DSET_LCPL_ID, sizeof(hid_t), &lcpl_id,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, H5P_ignore_cmp, NULL) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
-
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5P__dcrt_reg_prop() */
@@ -439,13 +421,13 @@ H5P__dcrt_layout_enc(const void *value, void **_pp, size_t *size)
for(u = 0; u < layout->storage.u.virt.list_nused; u++) {
/* Source file name */
tmp_size = HDstrlen(layout->storage.u.virt.list[u].source_file_name) + (size_t)1;
- (void)HDmemcpy(*pp, layout->storage.u.virt.list[u].source_file_name, tmp_size);
+ (void)H5MM_memcpy(*pp, layout->storage.u.virt.list[u].source_file_name, tmp_size);
*pp += tmp_size;
*size += tmp_size;
/* Source dataset name */
tmp_size = HDstrlen(layout->storage.u.virt.list[u].source_dset_name) + (size_t)1;
- (void)HDmemcpy(*pp, layout->storage.u.virt.list[u].source_dset_name, tmp_size);
+ (void)H5MM_memcpy(*pp, layout->storage.u.virt.list[u].source_dset_name, tmp_size);
*pp += tmp_size;
*size += tmp_size;
@@ -615,14 +597,14 @@ H5P__dcrt_layout_dec(const void **_pp, void *value)
tmp_size = HDstrlen((const char *)*pp) + 1;
if(NULL == (tmp_layout.storage.u.virt.list[u].source_file_name = (char *)H5MM_malloc(tmp_size)))
HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "unable to allocate memory for source file name")
- (void)HDmemcpy(tmp_layout.storage.u.virt.list[u].source_file_name, *pp, tmp_size);
+ (void)H5MM_memcpy(tmp_layout.storage.u.virt.list[u].source_file_name, *pp, tmp_size);
*pp += tmp_size;
/* Source dataset name */
tmp_size = HDstrlen((const char *)*pp) + 1;
if(NULL == (tmp_layout.storage.u.virt.list[u].source_dset_name = (char *)H5MM_malloc(tmp_size)))
HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "unable to allocate memory for source dataset name")
- (void)HDmemcpy(tmp_layout.storage.u.virt.list[u].source_dset_name, *pp, tmp_size);
+ (void)H5MM_memcpy(tmp_layout.storage.u.virt.list[u].source_dset_name, *pp, tmp_size);
*pp += tmp_size;
/* Source selection */
@@ -687,7 +669,7 @@ H5P__dcrt_layout_dec(const void **_pp, void *value)
} /* end switch */
/* Set the value */
- HDmemcpy(value, layout, sizeof(H5O_layout_t));
+ H5MM_memcpy(value, layout, sizeof(H5O_layout_t));
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -1036,7 +1018,7 @@ H5P__dcrt_fill_value_enc(const void *value, void **_pp, size_t *size)
/* Encode the fill value & datatype */
if(fill->size > 0) {
/* Encode the fill value itself */
- HDmemcpy(*pp, (uint8_t *)fill->buf, (size_t)fill->size);
+ H5MM_memcpy(*pp, (uint8_t *)fill->buf, (size_t)fill->size);
*pp += fill->size;
/* Encode fill value datatype */
@@ -1133,7 +1115,7 @@ H5P__dcrt_fill_value_dec(const void **_pp, void *_value)
/* Allocate fill buffer and copy the contents in it */
if(NULL == (fill->buf = H5MM_malloc((size_t)fill->size)))
HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed for fill value buffer")
- HDmemcpy((uint8_t *)fill->buf, *pp, (size_t)fill->size);
+ H5MM_memcpy((uint8_t *)fill->buf, *pp, (size_t)fill->size);
*pp += fill->size;
enc_size = *(*pp)++;
@@ -1448,7 +1430,7 @@ H5P__dcrt_ext_file_list_enc(const void *value, void **_pp, size_t *size)
UINT64ENCODE_VAR(*pp, enc_value, enc_size);
/* Encode name */
- HDmemcpy(*pp, (uint8_t *)(efl->slot[u].name), len);
+ H5MM_memcpy(*pp, (uint8_t *)(efl->slot[u].name), len);
*pp += len;
/* Encode offset */
@@ -2035,7 +2017,7 @@ H5Pset_chunk(hid_t plist_id, int ndims, const hsize_t dim[/*ndims*/])
#endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */
/* Verify & initialize property's chunk dims */
- HDmemcpy(&chunk_layout, &H5D_def_layout_chunk_g, sizeof(H5D_def_layout_chunk_g));
+ H5MM_memcpy(&chunk_layout, &H5D_def_layout_chunk_g, sizeof(H5D_def_layout_chunk_g));
HDmemset(&chunk_layout.u.chunk.dim, 0, sizeof(chunk_layout.u.chunk.dim));
chunk_nelmts = 1;
for(u = 0; u < (unsigned)ndims; u++) {
@@ -2204,7 +2186,7 @@ H5Pset_virtual(hid_t dcpl_id, hid_t vspace_id, const char *src_file_name,
HGOTO_ERROR(H5E_PLIST, H5E_CANTRESET, FAIL, "can't release layout message")
/* Copy the default virtual layout */
- HDmemcpy(&virtual_layout, &H5D_def_layout_virtual_g, sizeof(H5D_def_layout_virtual_g));
+ H5MM_memcpy(&virtual_layout, &H5D_def_layout_virtual_g, sizeof(H5D_def_layout_virtual_g));
/* Sanity check */
HDassert(virtual_layout.storage.u.virt.list_nalloc == 0);
@@ -3243,7 +3225,7 @@ H5Pset_fill_value(hid_t plist_id, hid_t type_id, const void *value)
fill.size = (ssize_t)H5T_get_size(type);
if(NULL == (fill.buf = H5MM_malloc((size_t)fill.size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "memory allocation failed for fill value")
- HDmemcpy(fill.buf, value, (size_t)fill.size);
+ H5MM_memcpy(fill.buf, value, (size_t)fill.size);
/* Set up type conversion function */
if(NULL == (tpath = H5T_path_find(type, type)))
@@ -3351,7 +3333,7 @@ H5P_get_fill_value(H5P_genplist_t *plist, const H5T_t *type, void *value/*out*/)
if(H5T_path_bkg(tpath) && NULL == (bkg = H5MM_malloc(H5T_get_size(fill.type))))
HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed for type conversion")
} /* end else */
- HDmemcpy(buf, fill.buf, H5T_get_size(fill.type));
+ H5MM_memcpy(buf, fill.buf, H5T_get_size(fill.type));
/* Do the conversion */
if((dst_id = H5I_register(H5I_DATATYPE, H5T_copy(type, H5T_COPY_TRANSIENT), FALSE)) < 0)
@@ -3359,7 +3341,7 @@ H5P_get_fill_value(H5P_genplist_t *plist, const H5T_t *type, void *value/*out*/)
if(H5T_convert(tpath, src_id, dst_id, (size_t)1, (size_t)0, (size_t)0, buf, bkg) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "datatype conversion failed")
if(buf != value)
- HDmemcpy(value, buf, H5T_get_size(type));
+ H5MM_memcpy(value, buf, H5T_get_size(type));
done:
if(buf != value)
diff --git a/src/H5Pdeprec.c b/src/H5Pdeprec.c
index 4a63b36..1b5f581 100644
--- a/src/H5Pdeprec.c
+++ b/src/H5Pdeprec.c
@@ -36,6 +36,7 @@
/* Headers */
/***********/
#include "H5private.h" /* Generic Functions */
+#include "H5CXprivate.h" /* API Contexts */
#include "H5Eprivate.h" /* Error handling */
#include "H5Fprivate.h" /* Files */
#include "H5Iprivate.h" /* IDs */
@@ -486,6 +487,54 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Pget_version() */
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5Pencode1
+ PURPOSE
+ Routine to convert the property values in a property list into a binary buffer
+ USAGE
+ herr_t H5Pencode1(plist_id, buf, nalloc)
+ hid_t plist_id; IN: Identifier to property list to encode
+ void *buf: OUT: buffer to gold the encoded plist
+ size_t *nalloc; IN/OUT: size of buffer needed to encode plist
+ RETURNS
+ Returns non-negative on success, negative on failure.
+ DESCRIPTION
+ Encodes a property list into a binary buffer. If the buffer is NULL, then
+ the call will set the size needed to encode the plist in nalloc. Otherwise
+ the routine will encode the plist in buf.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+herr_t
+H5Pencode1(hid_t plist_id, void *buf, size_t *nalloc)
+{
+ H5P_genplist_t *plist; /* Property list to query */
+ hid_t temp_fapl_id = H5P_DEFAULT;
+ herr_t ret_value = SUCCEED; /* return value */
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE3("e", "i*x*z", plist_id, buf, nalloc);
+
+ /* Check arguments. */
+ if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list");
+
+ /* Verify access property list and set up collective metadata if appropriate */
+ if(H5CX_set_apl(&temp_fapl_id, H5P_CLS_FACC, H5I_INVALID_HID, TRUE) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info")
+
+ /* Call the internal encode routine */
+ if((ret_value = H5P__encode(plist, TRUE, buf, nalloc)) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTENCODE, FAIL, "unable to encode property list");
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* H5Pencode1() */
+
/*-------------------------------------------------------------------------
* Function: H5Pset_file_space
*
diff --git a/src/H5Pdxpl.c b/src/H5Pdxpl.c
index 8338d84..df9cf4e 100644
--- a/src/H5Pdxpl.c
+++ b/src/H5Pdxpl.c
@@ -695,7 +695,7 @@ H5P__dxfr_xform_enc(const void *value, void **_pp, size_t *size)
HDassert(pexp);
/* Copy the expression into the buffer */
- HDmemcpy(*pp, (const uint8_t *)pexp, len);
+ H5MM_memcpy(*pp, (const uint8_t *)pexp, len);
*pp += len;
*pp[0] = '\0';
} /* end if */
diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c
index 452ea3f..585e913 100644
--- a/src/H5Pfapl.c
+++ b/src/H5Pfapl.c
@@ -1064,7 +1064,7 @@ H5P__file_driver_copy(void *value)
else if(driver->fapl_size > 0) {
if(NULL == (new_pl = H5MM_malloc(driver->fapl_size)))
HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "driver info allocation failed")
- HDmemcpy(new_pl, info->driver_info, driver->fapl_size);
+ H5MM_memcpy(new_pl, info->driver_info, driver->fapl_size);
} /* end else-if */
else
HGOTO_ERROR(H5E_PLIST, H5E_UNSUPPORTED, FAIL, "no way to copy driver info")
@@ -2597,7 +2597,7 @@ H5Pset_file_image(hid_t fapl_id, void *buf_ptr, size_t buf_len)
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTCOPY, FAIL, "image_memcpy callback failed")
} /* end if */
else
- HDmemcpy(image_info.buffer, buf_ptr, buf_len);
+ H5MM_memcpy(image_info.buffer, buf_ptr, buf_len);
} /* end if */
else
image_info.buffer = NULL;
@@ -2691,7 +2691,7 @@ H5Pget_file_image(hid_t fapl_id, void **buf_ptr_ptr, size_t *buf_len_ptr)
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTCOPY, FAIL, "image_memcpy callback failed")
} /* end if */
else
- HDmemcpy(copy_ptr, image_info.buffer, image_info.size);
+ H5MM_memcpy(copy_ptr, image_info.buffer, image_info.size);
} /* end if */
*buf_ptr_ptr = copy_ptr;
@@ -2894,7 +2894,7 @@ H5P__file_image_info_copy(void *value)
HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "image_memcpy callback failed")
} /* end if */
else
- HDmemcpy(info->buffer, old_buffer, info->size);
+ H5MM_memcpy(info->buffer, old_buffer, info->size);
} /* end if */
/* Copy udata if it exists */
@@ -3089,7 +3089,7 @@ H5P__facc_cache_image_config_dec(const void **_pp, void *_value)
HDcompile_assert(sizeof(size_t) <= sizeof(uint64_t));
/* Set property to default value */
- HDmemcpy(config, &H5F_def_mdc_initCacheImageCfg_g, sizeof(H5AC_cache_image_config_t));
+ H5MM_memcpy(config, &H5F_def_mdc_initCacheImageCfg_g, sizeof(H5AC_cache_image_config_t));
/* Decode type sizes */
enc_size = *(*pp)++;
@@ -3480,7 +3480,7 @@ H5P__facc_cache_config_enc(const void *value, void **_pp, size_t *size)
H5_ENCODE_UNSIGNED(*pp, config->close_trace_file);
- HDmemcpy(*pp, (const uint8_t *)(config->trace_file_name), (size_t)(H5AC__MAX_TRACE_FILE_NAME_LEN + 1));
+ H5MM_memcpy(*pp, (const uint8_t *)(config->trace_file_name), (size_t)(H5AC__MAX_TRACE_FILE_NAME_LEN + 1));
*pp += H5AC__MAX_TRACE_FILE_NAME_LEN + 1;
H5_ENCODE_UNSIGNED(*pp, config->evictions_enabled);
@@ -3615,7 +3615,7 @@ H5P__facc_cache_config_dec(const void **_pp, void *_value)
HDcompile_assert(sizeof(size_t) <= sizeof(uint64_t));
/* Set property to default value */
- HDmemcpy(config, &H5F_def_mdc_initCacheCfg_g, sizeof(H5AC_cache_config_t));
+ H5MM_memcpy(config, &H5F_def_mdc_initCacheCfg_g, sizeof(H5AC_cache_config_t));
/* Decode type sizes */
enc_size = *(*pp)++;
@@ -4195,7 +4195,7 @@ H5Pget_mdc_log_options(hid_t plist_id, hbool_t *is_enabled, char *location,
/* Copy log location to output buffer */
if(location_ptr && location)
- HDmemcpy(location, location_ptr, *location_size);
+ H5MM_memcpy(location, location_ptr, *location_size);
/* Get location size, including terminating NULL */
if(location_size) {
@@ -4250,7 +4250,7 @@ H5P_facc_mdc_log_location_enc(const void *value, void **_pp, size_t *size)
/* encode the prefix */
if(NULL != log_location) {
- HDmemcpy(*(char **)pp, log_location, len);
+ H5MM_memcpy(*(char **)pp, log_location, len);
*pp += len;
} /* end if */
} /* end if */
@@ -4536,7 +4536,7 @@ H5P__encode_coll_md_read_flag_t(const void *value, void **_pp, size_t *size)
if(NULL != *pp) {
/* Encode the value */
- HDmemcpy(*pp, coll_md_read_flag, sizeof(H5P_coll_md_read_flag_t));
+ H5MM_memcpy(*pp, coll_md_read_flag, sizeof(H5P_coll_md_read_flag_t));
*pp += sizeof(H5P_coll_md_read_flag_t);
} /* end if */
@@ -4907,6 +4907,43 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5P_reset_vol_class
+ *
+ * Purpose: Change the VOL connector for a file access property class.
+ *
+ * Note: The VOL property will be copied into the property list and
+ * the reference count on the previous VOL will _NOT_ be decremented.
+ * The reference count on the new VOL will _NOT_ be incremented.
+ *
+ * Return: SUCCEED/FAIL
+ *
+ * Programmer: Quincey Koziol
+ * March 8, 2019
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5P_reset_vol_class(const H5P_genclass_t *pclass, const H5VL_connector_prop_t *vol_prop)
+{
+ H5VL_connector_prop_t old_vol_prop; /* Previous VOL connector property */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* Get the connector ID & info property */
+ if(H5P__class_get(pclass, H5F_ACS_VOL_CONN_NAME, &old_vol_prop) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get VOL connector ID & info")
+
+ /* Set the new connector ID & info property */
+ if(H5P__class_set(pclass, H5F_ACS_VOL_CONN_NAME, vol_prop) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set VOL connector ID & info")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5P_set_vol_class() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5Pset_vol
*
* Purpose: Set the file VOL connector (VOL_ID) for a file access
@@ -5231,7 +5268,7 @@ H5P__facc_vol_cmp(const void *_info1, const void *_info2, size_t H5_ATTR_UNUSED
/* Use one of the classes (cls1) info comparison routines to compare the
* info objects
*/
- HDassert(cls1->info_cmp == cls2->info_cmp);
+ HDassert(cls1->info_cls.cmp == cls2->info_cls.cmp);
status = H5VL_cmp_connector_info(cls1, &cmp_value, info1->connector_info, info2->connector_info);
HDassert(status >= 0);
diff --git a/src/H5Pgcpl.c b/src/H5Pgcpl.c
index ab289e4..e2fdcea 100644
--- a/src/H5Pgcpl.c
+++ b/src/H5Pgcpl.c
@@ -128,7 +128,6 @@ static const H5O_linfo_t H5G_def_linfo_g = H5G_CRT_LINK_INFO_DEF; /* Defaul
static herr_t
H5P__gcrt_reg_prop(H5P_genclass_t *pclass)
{
- hid_t lcpl_id = H5P_LINK_CREATE_DEFAULT;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
@@ -145,11 +144,6 @@ H5P__gcrt_reg_prop(H5P_genclass_t *pclass)
NULL, NULL, NULL, NULL) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
- /* Register the lcpl ID property */
- if(H5P__register_real(pclass, H5VL_PROP_GRP_LCPL_ID, sizeof(hid_t), &lcpl_id,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
-
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5P__gcrt_reg_prop() */
diff --git a/src/H5Pint.c b/src/H5Pint.c
index e2ae792..0670adc 100644
--- a/src/H5Pint.c
+++ b/src/H5Pint.c
@@ -127,62 +127,65 @@ static herr_t H5P__free_del_name_cb(void *item, void H5_ATTR_UNUSED *key, void H
* Predefined property list classes. These are initialized at runtime by
* H5P__init_package() in this source file.
*/
-hid_t H5P_CLS_ROOT_ID_g = FAIL;
+hid_t H5P_CLS_ROOT_ID_g = H5I_INVALID_HID;
H5P_genclass_t *H5P_CLS_ROOT_g = NULL;
-hid_t H5P_CLS_OBJECT_CREATE_ID_g = FAIL;
+hid_t H5P_CLS_OBJECT_CREATE_ID_g = H5I_INVALID_HID;
H5P_genclass_t *H5P_CLS_OBJECT_CREATE_g = NULL;
-hid_t H5P_CLS_FILE_CREATE_ID_g = FAIL;
+hid_t H5P_CLS_FILE_CREATE_ID_g = H5I_INVALID_HID;
H5P_genclass_t *H5P_CLS_FILE_CREATE_g = NULL;
-hid_t H5P_CLS_FILE_ACCESS_ID_g = FAIL;
+hid_t H5P_CLS_FILE_ACCESS_ID_g = H5I_INVALID_HID;
H5P_genclass_t *H5P_CLS_FILE_ACCESS_g = NULL;
-hid_t H5P_CLS_DATASET_CREATE_ID_g = FAIL;
+hid_t H5P_CLS_DATASET_CREATE_ID_g = H5I_INVALID_HID;
H5P_genclass_t *H5P_CLS_DATASET_CREATE_g = NULL;
-hid_t H5P_CLS_DATASET_ACCESS_ID_g = FAIL;
+hid_t H5P_CLS_DATASET_ACCESS_ID_g = H5I_INVALID_HID;
H5P_genclass_t *H5P_CLS_DATASET_ACCESS_g = NULL;
-hid_t H5P_CLS_DATASET_XFER_ID_g = FAIL;
+hid_t H5P_CLS_DATASET_XFER_ID_g = H5I_INVALID_HID;
H5P_genclass_t *H5P_CLS_DATASET_XFER_g = NULL;
-hid_t H5P_CLS_FILE_MOUNT_ID_g = FAIL;
+hid_t H5P_CLS_FILE_MOUNT_ID_g = H5I_INVALID_HID;
H5P_genclass_t *H5P_CLS_FILE_MOUNT_g = NULL;
-hid_t H5P_CLS_GROUP_CREATE_ID_g = FAIL;
+hid_t H5P_CLS_GROUP_CREATE_ID_g = H5I_INVALID_HID;
H5P_genclass_t *H5P_CLS_GROUP_CREATE_g = NULL;
-hid_t H5P_CLS_GROUP_ACCESS_ID_g = FAIL;
+hid_t H5P_CLS_GROUP_ACCESS_ID_g = H5I_INVALID_HID;
H5P_genclass_t *H5P_CLS_GROUP_ACCESS_g = NULL;
-hid_t H5P_CLS_DATATYPE_CREATE_ID_g = FAIL;
+hid_t H5P_CLS_DATATYPE_CREATE_ID_g = H5I_INVALID_HID;
H5P_genclass_t *H5P_CLS_DATATYPE_CREATE_g = NULL;
-hid_t H5P_CLS_DATATYPE_ACCESS_ID_g = FAIL;
+hid_t H5P_CLS_DATATYPE_ACCESS_ID_g = H5I_INVALID_HID;
H5P_genclass_t *H5P_CLS_DATATYPE_ACCESS_g = NULL;
-hid_t H5P_CLS_ATTRIBUTE_CREATE_ID_g = FAIL;
+hid_t H5P_CLS_ATTRIBUTE_CREATE_ID_g = H5I_INVALID_HID;
H5P_genclass_t *H5P_CLS_ATTRIBUTE_CREATE_g = NULL;
-hid_t H5P_CLS_ATTRIBUTE_ACCESS_ID_g = FAIL;
+hid_t H5P_CLS_ATTRIBUTE_ACCESS_ID_g = H5I_INVALID_HID;
H5P_genclass_t *H5P_CLS_ATTRIBUTE_ACCESS_g = NULL;
-hid_t H5P_CLS_OBJECT_COPY_ID_g = FAIL;
+hid_t H5P_CLS_OBJECT_COPY_ID_g = H5I_INVALID_HID;
H5P_genclass_t *H5P_CLS_OBJECT_COPY_g = NULL;
-hid_t H5P_CLS_LINK_CREATE_ID_g = FAIL;
+hid_t H5P_CLS_LINK_CREATE_ID_g = H5I_INVALID_HID;
H5P_genclass_t *H5P_CLS_LINK_CREATE_g = NULL;
-hid_t H5P_CLS_LINK_ACCESS_ID_g = FAIL;
+hid_t H5P_CLS_LINK_ACCESS_ID_g = H5I_INVALID_HID;
H5P_genclass_t *H5P_CLS_LINK_ACCESS_g = NULL;
-hid_t H5P_CLS_STRING_CREATE_ID_g = FAIL;
+hid_t H5P_CLS_STRING_CREATE_ID_g = H5I_INVALID_HID;
H5P_genclass_t *H5P_CLS_STRING_CREATE_g = NULL;
+hid_t H5P_CLS_VOL_INITIALIZE_ID_g = H5I_INVALID_HID;
+H5P_genclass_t *H5P_CLS_VOL_INITIALIZE_g = NULL;
/*
* Predefined property lists for each predefined class. These are initialized
* at runtime by H5P__init_package() in this source file.
*/
-hid_t H5P_LST_FILE_CREATE_ID_g = FAIL;
-hid_t H5P_LST_FILE_ACCESS_ID_g = FAIL;
-hid_t H5P_LST_DATASET_CREATE_ID_g = FAIL;
-hid_t H5P_LST_DATASET_ACCESS_ID_g = FAIL;
-hid_t H5P_LST_DATASET_XFER_ID_g = FAIL;
-hid_t H5P_LST_FILE_MOUNT_ID_g = FAIL;
-hid_t H5P_LST_GROUP_CREATE_ID_g = FAIL;
-hid_t H5P_LST_GROUP_ACCESS_ID_g = FAIL;
-hid_t H5P_LST_DATATYPE_CREATE_ID_g = FAIL;
-hid_t H5P_LST_DATATYPE_ACCESS_ID_g = FAIL;
-hid_t H5P_LST_ATTRIBUTE_CREATE_ID_g = FAIL;
-hid_t H5P_LST_ATTRIBUTE_ACCESS_ID_g = FAIL;
-hid_t H5P_LST_OBJECT_COPY_ID_g = FAIL;
-hid_t H5P_LST_LINK_CREATE_ID_g = FAIL;
-hid_t H5P_LST_LINK_ACCESS_ID_g = FAIL;
+hid_t H5P_LST_FILE_CREATE_ID_g = H5I_INVALID_HID;
+hid_t H5P_LST_FILE_ACCESS_ID_g = H5I_INVALID_HID;
+hid_t H5P_LST_DATASET_CREATE_ID_g = H5I_INVALID_HID;
+hid_t H5P_LST_DATASET_ACCESS_ID_g = H5I_INVALID_HID;
+hid_t H5P_LST_DATASET_XFER_ID_g = H5I_INVALID_HID;
+hid_t H5P_LST_FILE_MOUNT_ID_g = H5I_INVALID_HID;
+hid_t H5P_LST_GROUP_CREATE_ID_g = H5I_INVALID_HID;
+hid_t H5P_LST_GROUP_ACCESS_ID_g = H5I_INVALID_HID;
+hid_t H5P_LST_DATATYPE_CREATE_ID_g = H5I_INVALID_HID;
+hid_t H5P_LST_DATATYPE_ACCESS_ID_g = H5I_INVALID_HID;
+hid_t H5P_LST_ATTRIBUTE_CREATE_ID_g = H5I_INVALID_HID;
+hid_t H5P_LST_ATTRIBUTE_ACCESS_ID_g = H5I_INVALID_HID;
+hid_t H5P_LST_OBJECT_COPY_ID_g = H5I_INVALID_HID;
+hid_t H5P_LST_LINK_CREATE_ID_g = H5I_INVALID_HID;
+hid_t H5P_LST_LINK_ACCESS_ID_g = H5I_INVALID_HID;
+hid_t H5P_LST_VOL_INITIALIZE_ID_g = H5I_INVALID_HID;
/* Root property list class library initialization object */
const H5P_libclass_t H5P_CLS_ROOT[1] = {{
@@ -283,6 +286,26 @@ const H5P_libclass_t H5P_CLS_TACC[1] = {{
NULL /* Class close callback info */
}};
+/* VOL initialization property list class library initialization object */
+/* (move to proper source code file when used for real) */
+const H5P_libclass_t H5P_CLS_VINI[1] = {{
+ "VOL initialization", /* Class name for debugging */
+ H5P_TYPE_VOL_INITIALIZE, /* Class type */
+
+ &H5P_CLS_ROOT_g, /* Parent class */
+ &H5P_CLS_VOL_INITIALIZE_g, /* Pointer to class */
+ &H5P_CLS_VOL_INITIALIZE_ID_g, /* Pointer to class ID */
+ &H5P_LST_VOL_INITIALIZE_ID_g, /* Pointer to default property list ID */
+ NULL, /* Default property registration routine */
+
+ NULL, /* Class creation callback */
+ NULL, /* Class creation callback info */
+ NULL, /* Class copy callback */
+ NULL, /* Class copy callback info */
+ NULL, /* Class close callback */
+ NULL /* Class close callback info */
+}};
+
/* Library property list classes defined in other code modules */
/* (And not present in src/H5Pprivate.h) */
@@ -331,7 +354,8 @@ static H5P_libclass_t const * const init_class[] = {
H5P_CLS_TACC, /* Datatype access */
H5P_CLS_ACRT, /* Attribute creation */
H5P_CLS_AACC, /* Attribute access */
- H5P_CLS_LCRT /* Link creation */
+ H5P_CLS_LCRT, /* Link creation */
+ H5P_CLS_VINI /* VOL initialization */
};
/* Declare a free list to manage the H5P_genclass_t struct */
@@ -525,7 +549,8 @@ H5P_term_package(void)
H5P_LST_OBJECT_COPY_ID_g =
H5P_LST_LINK_CREATE_ID_g =
H5P_LST_LINK_ACCESS_ID_g =
- H5P_LST_FILE_MOUNT_ID_g = (-1);
+ H5P_LST_VOL_INITIALIZE_ID_g =
+ H5P_LST_FILE_MOUNT_ID_g = H5I_INVALID_HID;
} /* end if */
} /* end if */
@@ -552,6 +577,7 @@ H5P_term_package(void)
H5P_CLS_OBJECT_COPY_g =
H5P_CLS_LINK_CREATE_g =
H5P_CLS_LINK_ACCESS_g =
+ H5P_CLS_VOL_INITIALIZE_g =
H5P_CLS_FILE_MOUNT_g = NULL;
H5P_CLS_ROOT_ID_g =
@@ -571,7 +597,8 @@ H5P_term_package(void)
H5P_CLS_OBJECT_COPY_ID_g =
H5P_CLS_LINK_CREATE_ID_g =
H5P_CLS_LINK_ACCESS_ID_g =
- H5P_CLS_FILE_MOUNT_ID_g = (-1);
+ H5P_CLS_VOL_INITIALIZE_ID_g =
+ H5P_CLS_FILE_MOUNT_ID_g = H5I_INVALID_HID;
} /* end if */
} /* end if */
@@ -631,7 +658,7 @@ H5P__do_prop_cb1(H5SL_t *slist, H5P_genprop_t *prop, H5P_prp_cb1_t cb)
/* Allocate space for a temporary copy of the property value */
if(NULL == (tmp_value = H5MM_malloc(prop->size)))
HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed for temporary property value")
- HDmemcpy(tmp_value, prop->value, prop->size);
+ H5MM_memcpy(tmp_value, prop->value, prop->size);
/* Call "type 1" callback ('create', 'copy' or 'close') */
if(cb(prop->name, prop->size, tmp_value) < 0)
@@ -642,7 +669,7 @@ H5P__do_prop_cb1(H5SL_t *slist, H5P_genprop_t *prop, H5P_prp_cb1_t cb)
HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "Can't copy property")
/* Copy the changed value into the new property */
- HDmemcpy(pcopy->value, tmp_value, prop->size);
+ H5MM_memcpy(pcopy->value, tmp_value, prop->size);
/* Insert the changed property into the property list */
if(H5P__add_prop(slist, pcopy) < 0)
@@ -990,7 +1017,7 @@ H5P__dup_prop(H5P_genprop_t *oprop, H5P_prop_within_t type)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
/* Copy basic property information */
- HDmemcpy(prop, oprop, sizeof(H5P_genprop_t));
+ H5MM_memcpy(prop, oprop, sizeof(H5P_genprop_t));
/* Check if we should duplicate the name or share it */
@@ -1030,7 +1057,7 @@ H5P__dup_prop(H5P_genprop_t *oprop, H5P_prop_within_t type)
HDassert(prop->size > 0);
if(NULL == (prop->value = H5MM_malloc(prop->size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
- HDmemcpy(prop->value, oprop->value, prop->size);
+ H5MM_memcpy(prop->value, oprop->value, prop->size);
} /* end if */
/* Set return value */
@@ -1117,7 +1144,7 @@ H5P__create_prop(const char *name, size_t size, H5P_prop_within_t type,
if(value != NULL) {
if(NULL == (prop->value = H5MM_malloc (prop->size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
- HDmemcpy(prop->value, value, prop->size);
+ H5MM_memcpy(prop->value, value, prop->size);
} /* end if */
else
prop->value = NULL;
@@ -2727,7 +2754,7 @@ H5P__poke_plist_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop,
HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "property has zero size")
/* Overwrite value in property */
- HDmemcpy(prop->value, udata->value, prop->size);
+ H5MM_memcpy(prop->value, udata->value, prop->size);
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -2779,7 +2806,7 @@ H5P__poke_pclass_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop
if(NULL == (pcopy = H5P__dup_prop(prop, H5P_PROP_WITHIN_LIST)))
HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "Can't copy property")
- HDmemcpy(pcopy->value, udata->value, pcopy->size);
+ H5MM_memcpy(pcopy->value, udata->value, pcopy->size);
/* Insert the changed property into the property list */
if(H5P__add_prop(plist->props, pcopy) < 0)
@@ -2888,7 +2915,7 @@ H5P__set_plist_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop,
/* Make a copy of the current value, in case the callback fails */
if(NULL == (tmp_value = H5MM_malloc(prop->size)))
HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed temporary property value")
- HDmemcpy(tmp_value, udata->value, prop->size);
+ H5MM_memcpy(tmp_value, udata->value, prop->size);
/* Call user's callback */
if((*(prop->set))(plist->plist_id, name, prop->size, tmp_value) < 0)
@@ -2909,7 +2936,7 @@ H5P__set_plist_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop,
} /* end if */
/* Copy new [possibly unchanged] value into property value */
- HDmemcpy(prop->value, prp_value, prop->size);
+ H5MM_memcpy(prop->value, prp_value, prop->size);
done:
/* Free the temporary value buffer */
@@ -2968,7 +2995,7 @@ H5P__set_pclass_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop,
/* Make a copy of the current value, in case the callback fails */
if(NULL == (tmp_value = H5MM_malloc(prop->size)))
HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed temporary property value")
- HDmemcpy(tmp_value, udata->value, prop->size);
+ H5MM_memcpy(tmp_value, udata->value, prop->size);
/* Call user's callback */
if((*(prop->set))(plist->plist_id, name, prop->size, tmp_value) < 0)
@@ -2985,7 +3012,7 @@ H5P__set_pclass_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop,
if(NULL == (pcopy = H5P__dup_prop(prop, H5P_PROP_WITHIN_LIST)))
HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "Can't copy property")
- HDmemcpy(pcopy->value, prp_value, pcopy->size);
+ H5MM_memcpy(pcopy->value, prp_value, pcopy->size);
/* Insert the changed property into the property list */
if(H5P__add_prop(plist->props, pcopy) < 0)
@@ -3061,6 +3088,116 @@ done:
/*--------------------------------------------------------------------------
NAME
+ H5P__class_get
+ PURPOSE
+ Internal routine to get a property's value from a property class.
+ USAGE
+ herr_t H5P__class_get(pclass, name, value)
+ const H5P_genclass_t *pclass; IN: Property class to find property in
+ const char *name; IN: Name of property to get
+ void *value; IN: Pointer to the value for the property
+ RETURNS
+ Returns non-negative on success, negative on failure.
+ DESCRIPTION
+ Gets the current value for a property in a property class. The property
+ name must exist or this routine will fail.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ The 'get' callback routine registered for this property will _NOT_ be
+ called, this routine is designed for internal library use only!
+
+ This routine may not be called for zero-sized properties and will
+ return an error in that case.
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+herr_t
+H5P__class_get(const H5P_genclass_t *pclass, const char *name, void *value)
+{
+ H5P_genprop_t *prop; /* Temporary property pointer */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_PACKAGE
+
+ /* Sanity check */
+ HDassert(pclass);
+ HDassert(name);
+ HDassert(value);
+
+ /* Find property in list */
+ if(NULL == (prop = (H5P_genprop_t *)H5SL_search(pclass->props, name)))
+ HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "property doesn't exist")
+
+ /* Check for property size >0 */
+ if(0 == prop->size)
+ HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "property has zero size")
+
+ /* Copy the property value */
+ H5MM_memcpy(value, prop->value, prop->size);
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5P__class_get() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5P__class_set
+ PURPOSE
+ Internal routine to set a property's value in a property class.
+ USAGE
+ herr_t H5P__class_set(pclass, name, value)
+ const H5P_genclass_t *pclass; IN: Property class to find property in
+ const char *name; IN: Name of property to set
+ const void *value; IN: Pointer to the value for the property
+ RETURNS
+ Returns non-negative on success, negative on failure.
+ DESCRIPTION
+ Sets a new value for a property in a property class. The property name
+ must exist or this routine will fail.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ The 'set' callback routine registered for this property will _NOT_ be
+ called, this routine is designed for internal library use only!
+
+ This routine may not be called for zero-sized properties and will
+ return an error in that case.
+
+ The previous value is overwritten, not released in any way.
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+herr_t
+H5P__class_set(const H5P_genclass_t *pclass, const char *name, const void *value)
+{
+ H5P_genprop_t *prop; /* Temporary property pointer */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_PACKAGE
+
+ /* Sanity check */
+ HDassert(pclass);
+ HDassert(name);
+ HDassert(value);
+
+ /* Find property in list */
+ if(NULL == (prop = (H5P_genprop_t *)H5SL_search(pclass->props, name)))
+ HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "property doesn't exist")
+
+ /* Check for property size >0 */
+ if(0 == prop->size)
+ HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "property has zero size")
+
+ /* Copy the property value */
+ H5MM_memcpy(prop->value, value, prop->size);
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5P__class_set() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
H5P_exist_plist
PURPOSE
Internal routine to query the existance of a property in a property list.
@@ -4234,7 +4371,7 @@ H5P__peek_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop,
HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "property has zero size")
/* Make a (shallow) copy of the value */
- HDmemcpy(udata->value, prop->value, prop->size);
+ H5MM_memcpy(udata->value, prop->value, prop->size);
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -4334,18 +4471,18 @@ H5P__get_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop,
/* Make a copy of the current value, in case the callback fails */
if(NULL == (tmp_value = H5MM_malloc(prop->size)))
HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed temporary property value")
- HDmemcpy(tmp_value, prop->value, prop->size);
+ H5MM_memcpy(tmp_value, prop->value, prop->size);
/* Call user's callback */
if((*(prop->get))(plist->plist_id, name, prop->size, tmp_value) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't set property value")
/* Copy new [possibly unchanged] value into return value */
- HDmemcpy(udata->value, tmp_value, prop->size);
+ H5MM_memcpy(udata->value, tmp_value, prop->size);
} /* end if */
/* No 'get' callback, just copy value */
else
- HDmemcpy(udata->value, prop->value, prop->size);
+ H5MM_memcpy(udata->value, prop->value, prop->size);
done:
/* Free the temporary value buffer */
@@ -4518,7 +4655,7 @@ H5P__del_pclass_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop,
/* Allocate space for a temporary copy of the property value */
if(NULL == (tmp_value = H5MM_malloc(prop->size)))
HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed for temporary property value")
- HDmemcpy(tmp_value, prop->value, prop->size);
+ H5MM_memcpy(tmp_value, prop->value, prop->size);
/* Call user's callback */
if((*(prop->del))(plist->plist_id, name, prop->size, tmp_value) < 0)
@@ -4967,7 +5104,7 @@ H5P_close(void *_plist)
/* Allocate space for a temporary copy of the property value */
if(NULL==(tmp_value=H5MM_malloc(tmp->size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for temporary property value")
- HDmemcpy(tmp_value,tmp->value,tmp->size);
+ H5MM_memcpy(tmp_value,tmp->value,tmp->size);
/* Call the 'close' callback */
(tmp->close)(tmp->name,tmp->size,tmp_value);
@@ -5298,7 +5435,7 @@ H5P__new_plist_of_type(H5P_plist_type_t type)
FUNC_ENTER_PACKAGE
/* Sanity checks */
- HDcompile_assert(H5P_TYPE_ATTRIBUTE_ACCESS == (H5P_TYPE_MAX_TYPE - 1));
+ HDcompile_assert(H5P_TYPE_VOL_INITIALIZE == (H5P_TYPE_MAX_TYPE - 1));
HDassert(type >= H5P_TYPE_USER && type <= H5P_TYPE_LINK_ACCESS);
/* Check arguments */
@@ -5377,6 +5514,10 @@ H5P__new_plist_of_type(H5P_plist_type_t type)
class_id = H5P_CLS_LINK_ACCESS_ID_g;
break;
+ case H5P_TYPE_VOL_INITIALIZE:
+ class_id = H5P_CLS_VOL_INITIALIZE_ID_g;
+ break;
+
case H5P_TYPE_USER: /* shut compiler warnings up */
case H5P_TYPE_ROOT:
case H5P_TYPE_MAX_TYPE:
diff --git a/src/H5Plapl.c b/src/H5Plapl.c
index bedeed9..7a7cc23 100644
--- a/src/H5Plapl.c
+++ b/src/H5Plapl.c
@@ -715,7 +715,7 @@ H5P__lacc_elink_pref_enc(const void *value, void **_pp, size_t *size)
/* encode the prefix */
if(NULL != elink_pref) {
- HDmemcpy(*(char **)pp, elink_pref, len);
+ H5MM_memcpy(*(char **)pp, elink_pref, len);
*pp += len;
} /* end if */
} /* end if */
diff --git a/src/H5Plcpl.c b/src/H5Plcpl.c
index 16be52a..ace853a 100644
--- a/src/H5Plcpl.c
+++ b/src/H5Plcpl.c
@@ -48,30 +48,6 @@
#define H5L_CRT_INTERMEDIATE_GROUP_ENC H5P__encode_unsigned
#define H5L_CRT_INTERMEDIATE_GROUP_DEC H5P__decode_unsigned
-/* ======== VOL specific properties ========= */
-/* Definitions for target object ID */
-#define H5L_CRT_TARGET_SIZE sizeof(void *)
-#define H5L_CRT_TARGET_DEF NULL
-
-/* Definitions for Location params */
-#define H5L_CRT_LOCATION_SIZE sizeof(H5VL_loc_params_t)
-#define H5L_CRT_LOCATION_DEF {H5I_BADID, H5VL_OBJECT_BY_SELF, {{HADDR_UNDEF}}}
-
-/* Definitions for target object NAME */
-#define H5L_CRT_TARGET_NAME_SIZE sizeof(char *)
-#define H5L_CRT_TARGET_NAME_DEF NULL
-
-/* Definitions for link type */
-#define H5L_CRT_LINK_TYPE_SIZE sizeof(link_type)
-#define H5L_CRT_LINK_TYPE_DEF H5L_TYPE_ERROR
-
-/* Definitions for UDATA */
-#define H5L_CRT_UDATA_SIZE sizeof(void *)
-#define H5L_CRT_UDATA_DEF NULL
-
-/* Definitions for UDATA_SIZE */
-#define H5L_CRT_UDATA_SIZE_SIZE sizeof(size_t)
-#define H5L_CRT_UDATA_SIZE_DEF 0
/******************/
/* Local Typedefs */
@@ -143,12 +119,6 @@ static const unsigned H5L_def_intmd_group_g = H5L_CRT_INTERMEDIATE_GROUP_DEF;
herr_t
H5P_lcrt_reg_prop(H5P_genclass_t *pclass)
{
- void* target = H5L_CRT_TARGET_DEF;
- H5VL_loc_params_t loc_params = H5L_CRT_LOCATION_DEF;
- char *target_name = H5L_CRT_TARGET_NAME_DEF;
- H5L_type_t link_type = H5L_CRT_LINK_TYPE_DEF;
- void *udata = H5L_CRT_UDATA_DEF;
- size_t udata_size = H5L_CRT_UDATA_SIZE_DEF;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -159,30 +129,6 @@ H5P_lcrt_reg_prop(H5P_genclass_t *pclass)
NULL, NULL, NULL, NULL) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
- if(H5P__register_real(pclass, H5VL_PROP_LINK_TARGET, H5L_CRT_TARGET_SIZE, &target,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
-
- if(H5P__register_real(pclass, H5VL_PROP_LINK_TARGET_LOC_PARAMS, H5L_CRT_LOCATION_SIZE, &loc_params,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
-
- if(H5P__register_real(pclass, H5VL_PROP_LINK_TARGET_NAME, H5L_CRT_TARGET_NAME_SIZE, &target_name,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
-
- if(H5P__register_real(pclass, H5VL_PROP_LINK_TYPE, H5L_CRT_LINK_TYPE_SIZE, &link_type,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
-
- if(H5P__register_real(pclass, H5VL_PROP_LINK_UDATA, H5L_CRT_UDATA_SIZE, &udata,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
-
- if(H5P__register_real(pclass, H5VL_PROP_LINK_UDATA_SIZE, H5L_CRT_UDATA_SIZE_SIZE, &udata_size,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
-
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5P_lcrt_reg_prop() */
diff --git a/src/H5Pocpl.c b/src/H5Pocpl.c
index c2bf6cb..a60c593 100644
--- a/src/H5Pocpl.c
+++ b/src/H5Pocpl.c
@@ -1501,7 +1501,7 @@ H5P__ocrt_pipeline_enc(const void *value, void **_pp, size_t *size)
*(*pp)++ = (uint8_t)TRUE;
/* encode filter name */
- HDmemcpy(*pp, (uint8_t *)(pline->filter[u].name), H5Z_COMMON_NAME_LEN);
+ H5MM_memcpy(*pp, (uint8_t *)(pline->filter[u].name), H5Z_COMMON_NAME_LEN);
*pp += H5Z_COMMON_NAME_LEN;
} /* end if */
else
diff --git a/src/H5Pocpypl.c b/src/H5Pocpypl.c
index 666a945..2dc92f9 100644
--- a/src/H5Pocpypl.c
+++ b/src/H5Pocpypl.c
@@ -384,7 +384,7 @@ H5P__ocpy_merge_comm_dt_list_enc(const void *value, void **_pp, size_t *size)
/* Encode merge committed dtype list */
if(*pp) {
- HDmemcpy(*(char **)pp, dt_list->path, len);
+ H5MM_memcpy(*(char **)pp, dt_list->path, len);
*pp += len;
} /* end if */
diff --git a/src/H5Ppkg.h b/src/H5Ppkg.h
index 13f3b13..c8e5e98 100644
--- a/src/H5Ppkg.h
+++ b/src/H5Ppkg.h
@@ -151,6 +151,10 @@ H5_DLL herr_t H5P__register(H5P_genclass_t **pclass, const char *name, size_t si
H5P_prp_close_func_t prp_close);
H5_DLL herr_t H5P__add_prop(H5SL_t *props, H5P_genprop_t *prop);
H5_DLL herr_t H5P__access_class(H5P_genclass_t *pclass, H5P_class_mod_t mod);
+H5_DLL herr_t H5P__class_get(const H5P_genclass_t *pclass, const char *name,
+ void *value);
+H5_DLL herr_t H5P__class_set(const H5P_genclass_t *pclass, const char *name,
+ const void *value);
H5_DLL htri_t H5P__exist_pclass(H5P_genclass_t *pclass, const char *name);
H5_DLL herr_t H5P__get_size_plist(const H5P_genplist_t *plist, const char *name,
size_t *size);
diff --git a/src/H5Pprivate.h b/src/H5Pprivate.h
index 866f088..07910c3 100644
--- a/src/H5Pprivate.h
+++ b/src/H5Pprivate.h
@@ -78,6 +78,7 @@ typedef enum H5P_plist_type_t {
H5P_TYPE_LINK_CREATE = 16,
H5P_TYPE_LINK_ACCESS = 17,
H5P_TYPE_ATTRIBUTE_ACCESS = 18,
+ H5P_TYPE_VOL_INITIALIZE = 19,
H5P_TYPE_MAX_TYPE
} H5P_plist_type_t;
@@ -148,6 +149,7 @@ H5_DLLVAR const struct H5P_libclass_t H5P_CLS_OCPY[1]; /* Object copy */
/* Forward declaration of structs used below */
struct H5O_fill_t;
struct H5T_t;
+struct H5VL_connector_prop_t;
/* Package initialization routine */
H5_DLL herr_t H5P_init(void);
@@ -178,6 +180,8 @@ H5_DLL const void *H5P_peek_driver_info(H5P_genplist_t *plist);
H5_DLL herr_t H5P_set_driver(H5P_genplist_t *plist, hid_t new_driver_id,
const void *new_driver_info);
H5_DLL herr_t H5P_set_vol(H5P_genplist_t *plist, hid_t vol_id, const void *vol_info);
+H5_DLL herr_t H5P_reset_vol_class(const H5P_genclass_t *pclass,
+ const struct H5VL_connector_prop_t *vol_prop);
H5_DLL herr_t H5P_set_vlen_mem_manager(H5P_genplist_t *plist,
H5MM_allocate_t alloc_func, void *alloc_info, H5MM_free_t free_func,
void *free_info);
diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h
index 078fe74..cad2071 100644
--- a/src/H5Ppublic.h
+++ b/src/H5Ppublic.h
@@ -68,6 +68,7 @@
#define H5P_OBJECT_COPY (H5OPEN H5P_CLS_OBJECT_COPY_ID_g)
#define H5P_LINK_CREATE (H5OPEN H5P_CLS_LINK_CREATE_ID_g)
#define H5P_LINK_ACCESS (H5OPEN H5P_CLS_LINK_ACCESS_ID_g)
+#define H5P_VOL_INITIALIZE (H5OPEN H5P_CLS_VOL_INITIALIZE_ID_g)
/*
* The library's default property lists
@@ -87,6 +88,7 @@
#define H5P_OBJECT_COPY_DEFAULT (H5OPEN H5P_LST_OBJECT_COPY_ID_g)
#define H5P_LINK_CREATE_DEFAULT (H5OPEN H5P_LST_LINK_CREATE_ID_g)
#define H5P_LINK_ACCESS_DEFAULT (H5OPEN H5P_LST_LINK_ACCESS_ID_g)
+#define H5P_VOL_INITIALIZE_DEFAULT (H5OPEN H5P_LST_VOL_INITIALIZE_ID_g)
/* Common creation order flags (for links in groups and attributes on objects) */
#define H5P_CRT_ORDER_TRACKED 0x0001
@@ -195,6 +197,7 @@ H5_DLLVAR hid_t H5P_CLS_ATTRIBUTE_ACCESS_ID_g;
H5_DLLVAR hid_t H5P_CLS_OBJECT_COPY_ID_g;
H5_DLLVAR hid_t H5P_CLS_LINK_CREATE_ID_g;
H5_DLLVAR hid_t H5P_CLS_LINK_ACCESS_ID_g;
+H5_DLLVAR hid_t H5P_CLS_VOL_INITIALIZE_ID_g;
/* Default roperty list IDs */
/* (Internal to library, do not use! Use macros above) */
@@ -213,6 +216,7 @@ H5_DLLVAR hid_t H5P_LST_ATTRIBUTE_ACCESS_ID_g;
H5_DLLVAR hid_t H5P_LST_OBJECT_COPY_ID_g;
H5_DLLVAR hid_t H5P_LST_LINK_CREATE_ID_g;
H5_DLLVAR hid_t H5P_LST_LINK_ACCESS_ID_g;
+H5_DLLVAR hid_t H5P_LST_VOL_INITIALIZE_ID_g;
/*********************/
/* Public Prototypes */
@@ -236,7 +240,7 @@ H5_DLL herr_t H5Pinsert2(hid_t plist_id, const char *name, size_t size,
H5P_prp_compare_func_t prp_cmp, H5P_prp_close_func_t prp_close);
H5_DLL herr_t H5Pset(hid_t plist_id, const char *name, const void *value);
H5_DLL htri_t H5Pexist(hid_t plist_id, const char *name);
-H5_DLL herr_t H5Pencode(hid_t plist_id, void *buf, size_t *nalloc);
+H5_DLL herr_t H5Pencode2(hid_t plist_id, void *buf, size_t *nalloc, hid_t fapl_id);
H5_DLL hid_t H5Pdecode(const void *buf);
H5_DLL herr_t H5Pget_size(hid_t id, const char *name, size_t *size);
H5_DLL herr_t H5Pget_nprops(hid_t id, size_t *nprops);
@@ -536,6 +540,7 @@ H5_DLL herr_t H5Pinsert1(hid_t plist_id, const char *name, size_t size,
void *value, H5P_prp_set_func_t prp_set, H5P_prp_get_func_t prp_get,
H5P_prp_delete_func_t prp_delete, H5P_prp_copy_func_t prp_copy,
H5P_prp_close_func_t prp_close);
+H5_DLL herr_t H5Pencode1(hid_t plist_id, void *buf, size_t *nalloc);
H5_DLL H5Z_filter_t H5Pget_filter1(hid_t plist_id, unsigned filter,
unsigned int *flags/*out*/, size_t *cd_nelmts/*out*/,
unsigned cd_values[]/*out*/, size_t namelen, char name[]);
diff --git a/src/H5Rint.c b/src/H5Rint.c
index a4f76ce..8109ac0 100644
--- a/src/H5Rint.c
+++ b/src/H5Rint.c
@@ -23,6 +23,7 @@
/***********/
#include "H5private.h" /* Generic Functions */
#include "H5ACprivate.h" /* Metadata cache */
+#include "H5CXprivate.h" /* API Contexts */
#include "H5Dprivate.h" /* Datasets */
#include "H5Eprivate.h" /* Error handling */
#include "H5Gprivate.h" /* Groups */
@@ -215,6 +216,9 @@ H5R__create(void *_ref, H5G_loc_t *loc, const char *name, H5R_type_t ref_type, H
obj_loc.path = &path;
H5G_loc_reset(&obj_loc);
+ /* Set the FAPL for the API context */
+ H5CX_set_libver_bounds(loc->oloc->file);
+
/* Find the object */
if(H5G_loc_find(loc, name, &obj_loc) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_NOTFOUND, FAIL, "object not found")
diff --git a/src/H5S.c b/src/H5S.c
index 2faf540..5153045 100644
--- a/src/H5S.c
+++ b/src/H5S.c
@@ -23,9 +23,11 @@
/***********/
#include "H5private.h" /* Generic Functions */
#include "H5Eprivate.h" /* Error handling */
+#include "H5CXprivate.h" /* API Contexts */
#include "H5Fprivate.h" /* Files */
#include "H5FLprivate.h" /* Free lists */
#include "H5Iprivate.h" /* IDs */
+#include "H5MMprivate.h" /* Memory management */
#include "H5Oprivate.h" /* Object headers */
#include "H5Spkg.h" /* Dataspaces */
@@ -46,7 +48,12 @@
/********************/
/* Local Prototypes */
/********************/
-static htri_t H5S_is_simple(const H5S_t *sdim);
+static htri_t H5S__is_simple(const H5S_t *sdim);
+
+
+/*****************************/
+/* Library Private Variables */
+/*****************************/
/*********************/
@@ -60,18 +67,10 @@ hbool_t H5_PKG_INIT_VAR = FALSE;
const unsigned H5O_sdspace_ver_bounds[] = {
H5O_SDSPACE_VERSION_1, /* H5F_LIBVER_EARLIEST */
H5O_SDSPACE_VERSION_2, /* H5F_LIBVER_V18 */
+ H5O_SDSPACE_VERSION_2, /* H5F_LIBVER_V110 */
H5O_SDSPACE_VERSION_LATEST /* H5F_LIBVER_LATEST */
};
-/*****************************/
-/* Library Private Variables */
-/*****************************/
-
-
-/*******************/
-/* Local Variables */
-/*******************/
-
/* Declare a free list to manage the H5S_extent_t struct */
H5FL_DEFINE(H5S_extent_t);
@@ -81,6 +80,11 @@ H5FL_DEFINE(H5S_t);
/* Declare a free list to manage the array's of hsize_t's */
H5FL_ARR_DEFINE(hsize_t, H5S_MAX_RANK);
+
+/*******************/
+/* Local Variables */
+/*******************/
+
/* Dataspace ID class */
static const H5I_class_t H5I_DATASPACE_CLS[1] = {{
H5I_DATASPACE, /* ID class value */
@@ -89,6 +93,14 @@ static const H5I_class_t H5I_DATASPACE_CLS[1] = {{
(H5I_free_t)H5S_close /* Callback routine for closing objects of this class */
}};
+/* Dataspace selection iterator ID class */
+static const H5I_class_t H5I_SPACE_SEL_ITER_CLS[1] = {{
+ H5I_SPACE_SEL_ITER, /* ID class value */
+ 0, /* Class flags */
+ 0, /* # of reserved IDs for class */
+ (H5I_free_t)H5S_sel_iter_close /* Callback routine for closing objects of this class */
+}};
+
/* Flag indicating "top" of interface has been initialized */
static hbool_t H5S_top_package_initialize_s = FALSE;
@@ -112,9 +124,13 @@ H5S__init_package(void)
FUNC_ENTER_PACKAGE
- /* Initialize the atom group for the file IDs */
+ /* Initialize the atom group for the dataspace IDs */
if(H5I_register_type(H5I_DATASPACE_CLS) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize interface")
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize dataspace ID class")
+
+ /* Initialize the atom group for the dataspace selction iterator IDs */
+ if(H5I_register_type(H5I_SPACE_SEL_ITER_CLS) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize dataspace selection iterator ID class")
/* Mark "top" of interface as initialized, too */
H5S_top_package_initialize_s = TRUE;
@@ -155,6 +171,11 @@ H5S_top_term_package(void)
n++; /*H5I*/
} /* end if */
+ if(H5I_nmembers(H5I_SPACE_SEL_ITER) > 0) {
+ (void)H5I_clear_type(H5I_SPACE_SEL_ITER, FALSE, FALSE);
+ n++; /*H5I*/
+ } /* end if */
+
/* Mark "top" of interface as closed */
if(0 == n)
H5S_top_package_initialize_s = FALSE;
@@ -194,11 +215,15 @@ H5S_term_package(void)
if(H5_PKG_INIT_VAR) {
/* Sanity checks */
HDassert(0 == H5I_nmembers(H5I_DATASPACE));
+ HDassert(0 == H5I_nmembers(H5I_SPACE_SEL_ITER));
HDassert(FALSE == H5S_top_package_initialize_s);
/* Destroy the dataspace object id group */
n += (H5I_dec_type_ref(H5I_DATASPACE) > 0);
+ /* Destroy the dataspace selection iterator object id group */
+ n += (H5I_dec_type_ref(H5I_SPACE_SEL_ITER) > 0);
+
/* Mark interface as closed */
if(0 == n)
H5_PKG_INIT_VAR = FALSE;
@@ -329,10 +354,9 @@ H5S_create(H5S_class_t type)
ret_value = new_ds;
done:
- if(ret_value == NULL) {
+ if(ret_value == NULL)
if(new_ds && H5S_close(new_ds) < 0)
HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, NULL, "unable to release dataspace")
- } /* end if */
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5S_create() */
@@ -359,7 +383,7 @@ done:
hid_t
H5Screate(H5S_class_t type)
{
- H5S_t *new_ds=NULL; /* New dataspace structure */
+ H5S_t *new_ds = NULL; /* New dataspace structure */
hid_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -373,21 +397,20 @@ H5Screate(H5S_class_t type)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "unable to create dataspace")
/* Atomize */
- if((ret_value = H5I_register (H5I_DATASPACE, new_ds, TRUE)) < 0)
+ if((ret_value = H5I_register(H5I_DATASPACE, new_ds, TRUE)) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace atom")
done:
- if(ret_value < 0) {
+ if(ret_value < 0)
if(new_ds && H5S_close(new_ds) < 0)
HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace")
- } /* end if */
FUNC_LEAVE_API(ret_value)
} /* end H5Screate() */
/*-------------------------------------------------------------------------
- * Function: H5S_extent_release
+ * Function: H5S__extent_release
*
* Purpose: Releases all memory associated with a dataspace extent.
*
@@ -396,16 +419,12 @@ done:
* Programmer: Quincey Koziol
* Thursday, July 23, 1998
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
herr_t
-H5S_extent_release(H5S_extent_t *extent)
+H5S__extent_release(H5S_extent_t *extent)
{
- herr_t ret_value=SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(FAIL)
+ FUNC_ENTER_PACKAGE_NOERR
HDassert(extent);
@@ -417,9 +436,8 @@ H5S_extent_release(H5S_extent_t *extent)
extent->max = H5FL_ARR_FREE(hsize_t, extent->max);
} /* end if */
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5S_extent_release() */
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5S__extent_release() */
/*-------------------------------------------------------------------------
@@ -445,16 +463,20 @@ H5S_close(H5S_t *ds)
/* Release selection (this should come before the extent release) */
if(H5S_SELECT_RELEASE(ds) < 0)
- HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace selection")
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace selection")
/* Release extent */
- if(H5S_extent_release(&ds->extent) < 0)
- HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace extent")
-
- /* Release the main structure */
- ds = H5FL_FREE(H5S_t, ds);
+ if(H5S__extent_release(&ds->extent) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace extent")
done:
+ /* Release the main structure.
+ * Always do this to ensure that we don't leak memory when calling this
+ * function on partially constructed dataspaces (which will fail one or
+ * both of the above calls)
+ */
+ H5FL_FREE(H5S_t, ds);
+
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5S_close() */
@@ -466,13 +488,9 @@ done:
*
* Return: Non-negative on success/Negative on failure
*
- * Errors:
- *
* Programmer: Robb Matzke
* Tuesday, December 9, 1997
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
herr_t
@@ -484,7 +502,7 @@ H5Sclose(hid_t space_id)
H5TRACE1("e", "i", space_id);
/* Check args */
- if (NULL == H5I_object_verify(space_id,H5I_DATASPACE))
+ if(NULL == H5I_object_verify(space_id, H5I_DATASPACE))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace")
/* When the reference count reaches zero the resources are freed */
@@ -502,14 +520,11 @@ done:
* Purpose: Copies a dataspace.
*
* Return: Success: ID of the new dataspace
- *
* Failure: Negative
*
* Programmer: Robb Matzke
* Friday, January 30, 1998
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
hid_t
@@ -535,10 +550,9 @@ H5Scopy(hid_t space_id)
HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace atom")
done:
- if(ret_value < 0) {
+ if(ret_value < 0)
if(dst && H5S_close(dst) < 0)
HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace")
- } /* end if */
FUNC_LEAVE_API(ret_value)
} /* end H5Scopy() */
@@ -554,8 +568,6 @@ done:
* Programmer: Quincey Koziol
* Thursday, July 23, 1998
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
herr_t
@@ -593,8 +605,6 @@ done:
* Programmer: Neil Fortner
* Monday, February 23, 2015
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
herr_t
@@ -608,7 +618,7 @@ H5S_extent_copy(H5S_t *dst, const H5S_t *src)
HDassert(src);
/* Copy extent */
- if(H5S_extent_copy_real(&(dst->extent), &(src->extent), TRUE) < 0)
+ if(H5S__extent_copy_real(&(dst->extent), &(src->extent), TRUE) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy extent")
/* If the selection is 'all', update the number of elements selected in the
@@ -623,7 +633,7 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5S_extent_copy_real
+ * Function: H5S__extent_copy_real
*
* Purpose: Copies a dataspace extent
*
@@ -632,20 +642,18 @@ done:
* Programmer: Quincey Koziol
* Wednesday, June 3, 1998
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
herr_t
-H5S_extent_copy_real(H5S_extent_t *dst, const H5S_extent_t *src, hbool_t copy_max)
+H5S__extent_copy_real(H5S_extent_t *dst, const H5S_extent_t *src, hbool_t copy_max)
{
unsigned u;
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(FAIL)
+ FUNC_ENTER_PACKAGE
/* Release destination extent before we copy over it */
- if(H5S_extent_release(dst) < 0)
+ if(H5S__extent_release(dst) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace extent")
/* Copy the regular fields */
@@ -690,7 +698,7 @@ H5S_extent_copy_real(H5S_extent_t *dst, const H5S_extent_t *src, hbool_t copy_ma
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5S_extent_copy_real() */
+} /* end H5S__extent_copy_real() */
/*-------------------------------------------------------------------------
@@ -704,14 +712,11 @@ done:
* selection)
*
* Return: Success: A pointer to a new copy of SRC
- *
* Failure: NULL
*
* Programmer: Robb Matzke
* Thursday, December 4, 1997
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
H5S_t *
@@ -726,7 +731,7 @@ H5S_copy(const H5S_t *src, hbool_t share_selection, hbool_t copy_max)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
/* Copy the source dataspace's extent */
- if(H5S_extent_copy_real(&(dst->extent), &(src->extent), copy_max) < 0)
+ if(H5S__extent_copy_real(&(dst->extent), &(src->extent), copy_max) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "can't copy extent")
/* Copy the source dataspace's selection */
@@ -751,7 +756,6 @@ done:
* Purpose: Determines how many data points a dataset extent has.
*
* Return: Success: Number of data points in the dataset extent.
- *
* Failure: negative
*
* Programmer: Robb Matzke
@@ -761,9 +765,6 @@ done:
* pattern, don't call it directly, use the appropriate macro
* defined in H5Sprivate.h.
*
- * Modifications:
- * Changed Name - QAK 7/7/98
- *
*-------------------------------------------------------------------------
*/
hssize_t
@@ -790,15 +791,11 @@ done:
* Purpose: Determines how many data points a dataset extent has.
*
* Return: Success: Number of data points in the dataset.
- *
* Failure: negative
*
* Programmer: Robb Matzke
* Tuesday, December 9, 1997
*
- * Modifications:
- * Changed Name - QAK 7/7/98
- *
*-------------------------------------------------------------------------
*/
hssize_t
@@ -832,14 +829,11 @@ done:
*
* Return: Success: Maximum number of data points the dataspace
* may have.
- *
* Failure: 0
*
* Programmer: Robb Matzke
* Tuesday, December 9, 1997
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
hsize_t
@@ -853,7 +847,7 @@ H5S_get_npoints_max(const H5S_t *ds)
/* check args */
HDassert(ds);
- switch (H5S_GET_EXTENT_TYPE(ds)) {
+ switch(H5S_GET_EXTENT_TYPE(ds)) {
case H5S_NULL:
ret_value = 0;
break;
@@ -863,31 +857,30 @@ H5S_get_npoints_max(const H5S_t *ds)
break;
case H5S_SIMPLE:
- if (ds->extent.max) {
- for (ret_value=1, u=0; u<ds->extent.rank; u++) {
- if (H5S_UNLIMITED==ds->extent.max[u]) {
+ if(ds->extent.max) {
+ for(ret_value = 1, u = 0; u < ds->extent.rank; u++) {
+ if(H5S_UNLIMITED == ds->extent.max[u]) {
ret_value = HSIZET_MAX;
break;
- }
+ } /* end if */
else
ret_value *= ds->extent.max[u];
- }
- }
- else {
- for (ret_value=1, u=0; u<ds->extent.rank; u++)
+ } /* end for */
+ } /* end if */
+ else
+ for(ret_value = 1, u = 0; u < ds->extent.rank; u++)
ret_value *= ds->extent.size[u];
- }
break;
case H5S_NO_CLASS:
default:
HDassert("unknown dataspace class" && 0);
HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, 0, "internal error (unknown dataspace class)")
- }
+ } /* end switch */
done:
FUNC_LEAVE_NOAPI(ret_value)
-}
+} /* end H5S_get_npoints_max() */
/*-------------------------------------------------------------------------
@@ -896,21 +889,18 @@ done:
* Purpose: Determines the dimensionality of a dataspace.
*
* Return: Success: The number of dimensions in a dataspace.
- *
* Failure: Negative
*
* Programmer: Robb Matzke
* Thursday, December 11, 1997
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
int
H5Sget_simple_extent_ndims(hid_t space_id)
{
- H5S_t *ds;
- int ret_value;
+ H5S_t *ds;
+ int ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE1("Is", "i", space_id);
@@ -933,7 +923,6 @@ done:
*
* Return: Success: Non-negative number of dimensions. Zero
* implies a scalar.
- *
* Failure: Negative
*
* Programmer: Robb Matzke
@@ -943,8 +932,6 @@ done:
* pattern, don't call it directly, use the appropriate macro
* defined in H5Sprivate.h.
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
int
@@ -979,43 +966,36 @@ done:
* Function: H5Sget_simple_extent_dims
*
* Purpose: Returns the size and maximum sizes in each dimension of
- * a dataspace DS through the DIMS and MAXDIMS arguments.
+ * a dataspace DS through the DIMS and MAXDIMS arguments.
*
* Return: Success: Number of dimensions, the same value as
* returned by H5Sget_simple_extent_ndims().
- *
* Failure: Negative
*
* Programmer: Robb Matzke
* Thursday, December 11, 1997
*
- * Modifications:
- * June 18, 1998 Albert Cheng
- * Added maxdims argument. Removed dims argument check
- * since it can still return ndims even if both dims and
- * maxdims are NULLs.
- *
*-------------------------------------------------------------------------
*/
int
H5Sget_simple_extent_dims(hid_t space_id, hsize_t dims[]/*out*/,
- hsize_t maxdims[]/*out*/)
+ hsize_t maxdims[]/*out*/)
{
- H5S_t *ds;
- int ret_value;
+ H5S_t *ds;
+ int ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE3("Is", "ixx", space_id, dims, maxdims);
/* Check args */
- if (NULL == (ds = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))
+ if(NULL == (ds = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace")
ret_value = H5S_get_simple_extent_dims(ds, dims, maxdims);
done:
FUNC_LEAVE_API(ret_value)
-}
+} /* end H5Sget_simple_extent_dims() */
/*-------------------------------------------------------------------------
@@ -1081,14 +1061,11 @@ done:
* function may not be meaningful for all types of dataspaces.
*
* Return: Success: Number of dimensions. Zero implies scalar.
- *
* Failure: Negative
*
* Programmer: Robb Matzke
* Thursday, December 11, 1997
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
int
@@ -1155,13 +1132,6 @@ done:
* Programmer: Quincey Koziol
* Tuesday, December 31, 2002
*
- * Modifications:
- *
- * John Mainzer, 6/6/05
- * Updated function to use the new dirtied parameter of
- * H5AC_unprotect() instead of manipulating the is_dirty
- * field of the cache info.
- *
*-------------------------------------------------------------------------
*/
herr_t
@@ -1191,7 +1161,6 @@ done:
* Purpose: Reads the dataspace from an object header.
*
* Return: Success: Pointer to a new dataspace.
- *
* Failure: NULL
*
* Programmer: Robb Matzke
@@ -1224,10 +1193,9 @@ H5S_read(const H5O_loc_t *loc)
ret_value = ds;
done:
- if(ret_value == NULL) {
+ if(ret_value == NULL)
if(ds != NULL)
ds = H5FL_FREE(H5S_t, ds);
- } /* end if */
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5S_read() */
@@ -1235,11 +1203,11 @@ done:
/*--------------------------------------------------------------------------
NAME
- H5S_is_simple
+ H5S__is_simple
PURPOSE
Check if a dataspace is simple (internal)
USAGE
- htri_t H5S_is_simple(sdim)
+ htri_t H5S__is_simple(sdim)
H5S_t *sdim; IN: Pointer to dataspace object to query
RETURNS
TRUE/FALSE/FAIL
@@ -1248,21 +1216,21 @@ done:
has orthogonal, evenly spaced dimensions.
--------------------------------------------------------------------------*/
static htri_t
-H5S_is_simple(const H5S_t *sdim)
+H5S__is_simple(const H5S_t *sdim)
{
htri_t ret_value = FAIL; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
/* Check args and all the boring stuff. */
HDassert(sdim);
/* H5S_NULL shouldn't be simple dataspace */
ret_value = (H5S_GET_EXTENT_TYPE(sdim) == H5S_SIMPLE ||
- H5S_GET_EXTENT_TYPE(sdim) == H5S_SCALAR) ? TRUE : FALSE;
+ H5S_GET_EXTENT_TYPE(sdim) == H5S_SCALAR) ? TRUE : FALSE;
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5S_is_simple() */
+} /* end H5S__is_simple() */
/*--------------------------------------------------------------------------
@@ -1282,21 +1250,21 @@ H5S_is_simple(const H5S_t *sdim)
htri_t
H5Sis_simple(hid_t space_id)
{
- H5S_t *space; /* dataspace to modify */
- htri_t ret_value;
+ H5S_t *space; /* Dataspace to check */
+ htri_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE1("t", "i", space_id);
/* Check args and all the boring stuff. */
- if ((space = (H5S_t *)H5I_object_verify(space_id,H5I_DATASPACE)) == NULL)
+ if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a dataspace")
- ret_value = H5S_is_simple(space);
+ ret_value = H5S__is_simple(space);
- done:
+done:
FUNC_LEAVE_API(ret_value)
-}
+} /* end H5Sis_simple() */
/*--------------------------------------------------------------------------
@@ -1324,56 +1292,44 @@ H5Sis_simple(hid_t space_id)
Currently, only the first dimension in the array (the slowest) may be
unlimited in size.
- MODIFICATION
- A null dataspace cannot be created from simple space with this function.
-
- Christian Chilan 01/17/2007
- Verifies that each element of DIMS is not equal to H5S_UNLIMITED.
-
- Raymond Lu 03/30/2011
- We allow 0 dimension size for non-unlimited dimension starting from 1.8.7
- release.
--------------------------------------------------------------------------*/
herr_t
H5Sset_extent_simple(hid_t space_id, int rank, const hsize_t dims[/*rank*/],
- const hsize_t max[/*rank*/])
+ const hsize_t max[/*rank*/])
{
- H5S_t *space; /* dataspace to modify */
- int u; /* local counting variable */
- herr_t ret_value=SUCCEED; /* Return value */
+ H5S_t *space; /* Dataspace to modify */
+ int u; /* Local counting variable */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE4("e", "iIs*[a1]h*[a1]h", space_id, rank, dims, max);
/* Check args */
- if ((space = (H5S_t *)H5I_object_verify(space_id,H5I_DATASPACE)) == NULL)
+ if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a dataspace")
- if (rank > 0 && dims == NULL)
+ if(rank > 0 && dims == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no dimensions specified")
- if (rank<0 || rank>H5S_MAX_RANK)
+ if(rank < 0 || rank > H5S_MAX_RANK)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid rank")
- if (dims) {
- for (u=0; u<rank; u++) {
- if (H5S_UNLIMITED==dims[u])
+ if(dims)
+ for(u = 0; u < rank; u++)
+ if(H5S_UNLIMITED == dims[u])
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "current dimension must have a specific size, not H5S_UNLIMITED")
- }
- }
- if (max!=NULL) {
- if(dims==NULL)
+ if(max != NULL) {
+ if(dims == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "maximum dimension specified, but no current dimensions specified")
- for (u=0; u<rank; u++) {
- if (max[u]!=H5S_UNLIMITED && max[u]<dims[u])
+ for(u = 0; u < rank; u++)
+ if(max[u] != H5S_UNLIMITED && max[u] < dims[u])
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid maximum dimension size")
- }
- }
+ } /* end if */
/* Do it */
- if (H5S_set_extent_simple(space, (unsigned)rank, dims, max)<0)
+ if(H5S_set_extent_simple(space, (unsigned)rank, dims, max) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to set simple extent")
done:
FUNC_LEAVE_API(ret_value)
-}
+} /* end H5Sset_extent_simple() */
/*-------------------------------------------------------------------------
@@ -1384,19 +1340,17 @@ done:
*
* Return: Non-negative on success/Negative on failure
*
- * Programmer: Robb Matzke (copied from H5Sset_extent_simple)
+ * Programmer: Robb Matzke
* Wednesday, July 8, 1998
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
herr_t
H5S_set_extent_simple(H5S_t *space, unsigned rank, const hsize_t *dims,
- const hsize_t *max)
+ const hsize_t *max)
{
unsigned u; /* Local index variable */
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -1405,7 +1359,7 @@ H5S_set_extent_simple(H5S_t *space, unsigned rank, const hsize_t *dims,
HDassert(0 == rank || dims);
/* shift out of the previous state to a "simple" dataspace. */
- if(H5S_extent_release(&space->extent) < 0)
+ if(H5S__extent_release(&space->extent) < 0)
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "failed to release previous dataspace extent")
if(rank == 0) { /* scalar variable */
@@ -1432,12 +1386,11 @@ H5S_set_extent_simple(H5S_t *space, unsigned rank, const hsize_t *dims,
/* Copy the maximum dimensions if specified. Otherwise, the maximal dimensions are the
* same as the dimension */
space->extent.max = (hsize_t *)H5FL_ARR_MALLOC(hsize_t, (size_t)rank);
- if(max != NULL) {
- HDmemcpy(space->extent.max, max, sizeof(hsize_t) * rank);
- } else {
+ if(max != NULL)
+ H5MM_memcpy(space->extent.max, max, sizeof(hsize_t) * rank);
+ else
for(u = 0; u < space->extent.rank; u++)
space->extent.max[u] = dims[u];
- }
} /* end else */
/* Selection related cleanup */
@@ -1453,7 +1406,7 @@ H5S_set_extent_simple(H5S_t *space, unsigned rank, const hsize_t *dims,
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_set_extent_simple() */
+} /* end H5S_set_extent_simple() */
/*-------------------------------------------------------------------------
@@ -1469,26 +1422,20 @@ done:
* than the corresponding element of DIMS.
*
* Return: Success: The ID for the new simple dataspace object.
- *
* Failure: Negative
*
* Programmer: Quincey Koziol
* Tuesday, January 27, 1998
*
- * Modification:
- * Raymond Lu 03/30/2011
- * We allow 0-dimension for non-unlimited dimension starting
- * from 1.8.7 release.
- *
*-------------------------------------------------------------------------
*/
hid_t
H5Screate_simple(int rank, const hsize_t dims[/*rank*/],
- const hsize_t maxdims[/*rank*/])
+ const hsize_t maxdims[/*rank*/])
{
H5S_t *space = NULL;
int i;
- hid_t ret_value;
+ hid_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE3("i", "Is*[a0]h*[a0]h", rank, dims, maxdims);
@@ -1514,7 +1461,7 @@ H5Screate_simple(int rank, const hsize_t dims[/*rank*/],
} /* end for */
/* Create the space and set the extent */
- if(NULL == (space = H5S_create_simple((unsigned)rank,dims,maxdims)))
+ if(NULL == (space = H5S_create_simple((unsigned)rank, dims, maxdims)))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create simple dataspace")
/* Atomize */
@@ -1522,10 +1469,9 @@ H5Screate_simple(int rank, const hsize_t dims[/*rank*/],
HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace ID")
done:
- if(ret_value < 0) {
+ if(ret_value < 0)
if(space && H5S_close(space) < 0)
HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace")
- } /* end if */
FUNC_LEAVE_API(ret_value)
} /* end H5Screate_simple() */
@@ -1539,32 +1485,26 @@ done:
* Return: Success: The ID for the new simple dataspace object.
* Failure: Negative
*
- * Errors:
- *
* Programmer: Quincey Koziol
* Thursday, April 3, 2003
*
- * Modifications:
- * Extracted from H5Screate_simple
- * Quincey Koziol, Thursday, April 3, 2003
- *
*-------------------------------------------------------------------------
*/
H5S_t *
H5S_create_simple(unsigned rank, const hsize_t dims[/*rank*/],
- const hsize_t maxdims[/*rank*/])
+ const hsize_t maxdims[/*rank*/])
{
H5S_t *ret_value = NULL; /* Return value */
FUNC_ENTER_NOAPI(NULL)
/* Check arguments */
- HDassert(rank <=H5S_MAX_RANK);
+ HDassert(rank <= H5S_MAX_RANK);
/* Create the space and set the extent */
- if(NULL==(ret_value=H5S_create(H5S_SIMPLE)))
+ if(NULL == (ret_value = H5S_create(H5S_SIMPLE)))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, NULL, "can't create simple dataspace")
- if(H5S_set_extent_simple(ret_value,rank,dims,maxdims)<0)
+ if(H5S_set_extent_simple(ret_value, rank, dims, maxdims) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, NULL, "can't set dimensions")
done:
@@ -1573,42 +1513,46 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Sencode
+ * Function: H5Sencode2
*
* Purpose: Given a dataspace ID, converts the object description
* (including selection) into binary in a buffer.
+ * The selection will be encoded according to the file
+ * format setting in fapl.
*
* Return: Success: non-negative
- *
- * Failure: negative
+ * Failure: negative
*
* Programmer: Raymond Lu
* slu@ncsa.uiuc.edu
* July 14, 2004
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
herr_t
-H5Sencode(hid_t obj_id, void *buf, size_t *nalloc)
+H5Sencode2(hid_t obj_id, void *buf, size_t *nalloc, hid_t fapl_id)
{
H5S_t *dspace;
herr_t ret_value=SUCCEED;
FUNC_ENTER_API(FAIL)
- H5TRACE3("e", "i*x*z", obj_id, buf, nalloc);
+ H5TRACE4("e", "i*x*zi", obj_id, buf, nalloc, fapl_id);
/* Check argument and retrieve object */
- if (NULL == (dspace = (H5S_t *)H5I_object_verify(obj_id, H5I_DATASPACE)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace")
+ if(NULL == (dspace = (H5S_t *)H5I_object_verify(obj_id, H5I_DATASPACE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace")
+
+ /* Verify access property list and set up collective metadata if appropriate */
+ if(H5CX_set_apl(&fapl_id, H5P_CLS_FACC, H5I_INVALID_HID, TRUE) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info")
- if(H5S_encode(dspace, (unsigned char **)&buf, nalloc)<0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTENCODE, FAIL, "can't encode dataspace")
+
+ if(H5S_encode(dspace, (unsigned char **)&buf, nalloc) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTENCODE, FAIL, "can't encode dataspace")
done:
FUNC_LEAVE_API(ret_value)
-}
+} /* H5Sencode2() */
/*-------------------------------------------------------------------------
@@ -1697,7 +1641,6 @@ done:
* return a new object handle.
*
* Return: Success: dataspace ID(non-negative)
- *
* Failure: negative
*
* Programmer: Raymond Lu
@@ -1737,7 +1680,6 @@ done:
* description of dataspace and returns a new object handle.
*
* Return: Success: dataspace ID(non-negative)
- *
* Failure: negative
*
* Programmer: Raymond Lu
@@ -1784,11 +1726,11 @@ H5S_decode(const unsigned char **p)
pp += extent_size;
/* Copy the extent into dataspace structure */
- if((ds = H5FL_CALLOC(H5S_t))==NULL)
+ if(NULL == (ds = H5FL_CALLOC(H5S_t)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for dataspace conversion path table")
- if(H5O_msg_copy(H5O_SDSPACE_ID, extent, &(ds->extent)) == NULL)
+ if(NULL == H5O_msg_copy(H5O_SDSPACE_ID, extent, &(ds->extent)))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "can't copy object")
- if(H5S_extent_release(extent) < 0)
+ if(H5S__extent_release(extent) < 0)
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTDELETE, NULL, "can't release previous dataspace")
extent = H5FL_FREE(H5S_extent_t, extent);
@@ -1819,11 +1761,8 @@ done:
* Purpose: Internal function for retrieving the type of extent for a dataspace object
*
* Return: Success: The class of the dataspace object
- *
* Failure: N5S_NO_CLASS
*
- * Errors:
- *
* Programmer: Quincey Koziol
* Thursday, September 28, 2000
*
@@ -1831,8 +1770,6 @@ done:
* pattern, don't call it directly, use the appropriate macro
* defined in H5Sprivate.h.
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
H5S_class_t
@@ -1844,11 +1781,11 @@ H5S_get_simple_extent_type(const H5S_t *space)
HDassert(space);
- ret_value=H5S_GET_EXTENT_TYPE(space);
+ ret_value = H5S_GET_EXTENT_TYPE(space);
done:
FUNC_LEAVE_NOAPI(ret_value)
-}
+} /* end H5S_get_simple_extent_type() */
/*-------------------------------------------------------------------------
@@ -1857,36 +1794,31 @@ done:
* Purpose: Retrieves the type of extent for a dataspace object
*
* Return: Success: The class of the dataspace object
- *
* Failure: N5S_NO_CLASS
*
- * Errors:
- *
* Programmer: Quincey Koziol
* Thursday, July 23, 1998
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
H5S_class_t
H5Sget_simple_extent_type(hid_t sid)
{
H5S_t *space;
- H5S_class_t ret_value;
+ H5S_class_t ret_value; /* Return value */
FUNC_ENTER_API(H5S_NO_CLASS)
H5TRACE1("Sc", "i", sid);
/* Check arguments */
- if (NULL == (space = (H5S_t *)H5I_object_verify(sid, H5I_DATASPACE)))
+ if(NULL == (space = (H5S_t *)H5I_object_verify(sid, H5I_DATASPACE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5S_NO_CLASS, "not a dataspace")
- ret_value=H5S_GET_EXTENT_TYPE(space);
+ ret_value = H5S_GET_EXTENT_TYPE(space);
done:
FUNC_LEAVE_API(ret_value)
-}
+} /* end H5Sget_simple_extent_type() */
/*--------------------------------------------------------------------------
@@ -1906,68 +1838,25 @@ done:
herr_t
H5Sset_extent_none(hid_t space_id)
{
- H5S_t *space; /* dataspace to modify */
- herr_t ret_value=SUCCEED; /* Return value */
+ H5S_t *space; /* Dataspace to modify */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE1("e", "i", space_id);
/* Check args */
- if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))
+ if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a dataspace")
/* Clear the previous extent from the dataspace */
- if(H5S_extent_release(&space->extent)<0)
+ if(H5S__extent_release(&space->extent) < 0)
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTDELETE, FAIL, "can't release previous dataspace")
- space->extent.type=H5S_NO_CLASS;
+ space->extent.type = H5S_NO_CLASS;
done:
FUNC_LEAVE_API(ret_value)
-} /* end H5Sset_extent_none() */
-
-
-/*--------------------------------------------------------------------------
- NAME
- H5Soffset_simple
- PURPOSE
- Changes the offset of a selection within a simple dataspace extent
- USAGE
- herr_t H5Soffset_simple(space_id, offset)
- hid_t space_id; IN: Dataspace object to reset
- const hssize_t *offset; IN: Offset to position the selection at
- RETURNS
- Non-negative on success/Negative on failure
- DESCRIPTION
- This function creates an offset for the selection within an extent, allowing
- the same shaped selection to be moved to different locations within a
- dataspace without requiring it to be re-defined.
---------------------------------------------------------------------------*/
-herr_t
-H5Soffset_simple(hid_t space_id, const hssize_t *offset)
-{
- H5S_t *space; /* dataspace to modify */
- herr_t ret_value=SUCCEED; /* Return value */
-
- FUNC_ENTER_API(FAIL)
- H5TRACE2("e", "i*Hs", space_id, offset);
-
- /* Check args */
- if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a dataspace")
- if (space->extent.rank==0 || (H5S_GET_EXTENT_TYPE(space)==H5S_SCALAR
- || H5S_GET_EXTENT_TYPE(space)==H5S_NULL))
- HGOTO_ERROR(H5E_ATOM, H5E_UNSUPPORTED, FAIL, "can't set offset on scalar or null dataspace")
- if (offset == NULL)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no offset specified")
-
- /* Set the selection offset */
- if(H5S_select_offset(space,offset)<0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't set offset")
-
-done:
- FUNC_LEAVE_API(ret_value)
-} /* end H5Soffset_simple() */
+} /* end H5Sset_extent_none() */
/*-------------------------------------------------------------------------
@@ -1996,7 +1885,7 @@ H5S_set_extent(H5S_t *space, const hsize_t *size)
HDassert(size);
/* Verify that the dimensions being changed are allowed to change */
- for(u = 0; u < space->extent.rank; u++) {
+ for(u = 0; u < space->extent.rank; u++)
if(space->extent.size[u] != size[u]) {
/* Check for invalid dimension size modification */
if(space->extent.max && H5S_UNLIMITED != space->extent.max[u] &&
@@ -2006,7 +1895,6 @@ H5S_set_extent(H5S_t *space, const hsize_t *size)
/* Indicate that dimension size can be modified */
ret_value = TRUE;
} /* end if */
- } /* end for */
/* Update dimension size(s) */
if(ret_value)
@@ -2033,7 +1921,7 @@ done:
*
*-------------------------------------------------------------------------
*/
-hbool_t
+H5_ATTR_PURE hbool_t
H5S_has_extent(const H5S_t *ds)
{
hbool_t ret_value = FALSE; /* Return value */
@@ -2104,7 +1992,6 @@ done:
* Purpose: Determines if two dataspace extents are equal.
*
* Return: Success: TRUE if equal, FALSE if unequal
- *
* Failure: Negative
*
* Programmer: Quincey Koziol
@@ -2116,7 +2003,7 @@ htri_t
H5Sextent_equal(hid_t space1_id, hid_t space2_id)
{
const H5S_t *ds1, *ds2; /* Dataspaces to compare */
- htri_t ret_value;
+ htri_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE2("t", "ii", space1_id, space2_id);
@@ -2148,7 +2035,7 @@ done:
DESCRIPTION
Compare two dataspaces if their extents are identical.
--------------------------------------------------------------------------*/
-htri_t
+H5_ATTR_PURE htri_t
H5S_extent_equal(const H5S_t *ds1, const H5S_t *ds2)
{
unsigned u; /* Local index variable */
@@ -2209,7 +2096,7 @@ done:
*
*-------------------------------------------------------------------------
*/
-hsize_t
+H5_ATTR_PURE hsize_t
H5S_extent_nelem(const H5S_extent_t *ext)
{
FUNC_ENTER_NOAPI_NOINIT_NOERR
@@ -2257,6 +2144,5 @@ H5S_set_version(H5F_t *f, H5S_t *ds)
done:
FUNC_LEAVE_NOAPI(ret_value)
-
} /* end H5S_set_version() */
diff --git a/src/H5SL.c b/src/H5SL.c
index c0934ca..5f00fb8 100644
--- a/src/H5SL.c
+++ b/src/H5SL.c
@@ -240,7 +240,7 @@
/* Allocate space for new forward pointers */ \
if(NULL == (_tmp = (H5SL_node_t **)H5FL_FAC_MALLOC(H5SL_fac_g[X->log_nalloc]))) \
HGOTO_ERROR(H5E_SLIST, H5E_CANTALLOC, ERR, "memory allocation failed") \
- HDmemcpy((void *)_tmp, (const void *)X->forward, (LVL + 1) * sizeof(H5SL_node_t *)); \
+ H5MM_memcpy((void *)_tmp, (const void *)X->forward, (LVL + 1) * sizeof(H5SL_node_t *)); \
X->forward = (H5SL_node_t **)H5FL_FAC_FREE(H5SL_fac_g[X->log_nalloc-1], (void *)X->forward); \
X->forward = _tmp; \
} /* end if */ \
@@ -262,7 +262,7 @@
/* Allocate space for new forward pointers */ \
if(NULL == (_tmp = (H5SL_node_t **)H5FL_FAC_MALLOC(H5SL_fac_g[X->log_nalloc]))) \
HGOTO_ERROR(H5E_SLIST, H5E_NOSPACE, NULL, "memory allocation failed") \
- HDmemcpy((void *)_tmp, (const void *)X->forward, (LVL) * sizeof(H5SL_node_t *)); \
+ H5MM_memcpy((void *)_tmp, (const void *)X->forward, (LVL) * sizeof(H5SL_node_t *)); \
X->forward = (H5SL_node_t **)H5FL_FAC_FREE(H5SL_fac_g[X->log_nalloc+1], (void *)X->forward); \
X->forward = _tmp; \
} /* end if */ \
diff --git a/src/H5SM.c b/src/H5SM.c
index 0fa3489..290e575 100644
--- a/src/H5SM.c
+++ b/src/H5SM.c
@@ -274,6 +274,7 @@ H5SM__type_to_flag(unsigned type_id, unsigned *type_flag)
case H5O_FILL_ID:
type_id = H5O_FILL_NEW_ID;
/* Fall through... */
+ H5_ATTR_FALLTHROUGH
case H5O_SDSPACE_ID:
case H5O_DTYPE_ID:
@@ -2318,7 +2319,7 @@ H5SM__read_iter_op(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, unsigned sequence,
HGOTO_ERROR(H5E_SOHM, H5E_NOSPACE, H5_ITER_ERROR, "memory allocation failed")
/* Copy the encoded message into the buffer to return */
- HDmemcpy(udata->encoding_buf, mesg->raw, udata->buf_size);
+ H5MM_memcpy(udata->encoding_buf, mesg->raw, udata->buf_size);
/* Found the message we were looking for */
ret_value = H5_ITER_STOP;
@@ -2356,7 +2357,7 @@ H5SM__read_mesg_fh_cb(const void *obj, size_t obj_len, void *_udata)
HGOTO_ERROR(H5E_SOHM, H5E_NOSPACE, FAIL, "memory allocation failed")
/* Copy the message from the heap */
- HDmemcpy(udata->encoding_buf, obj, obj_len);
+ H5MM_memcpy(udata->encoding_buf, obj, obj_len);
udata->buf_size = obj_len;
done:
diff --git a/src/H5SMbtree2.c b/src/H5SMbtree2.c
index f0c4963..7f6c804 100644
--- a/src/H5SMbtree2.c
+++ b/src/H5SMbtree2.c
@@ -24,6 +24,7 @@
/***********/
#include "H5private.h" /* Generic Functions */
#include "H5Eprivate.h" /* Error handling */
+#include "H5MMprivate.h" /* Memory management */
#include "H5Opkg.h" /* Object Headers */
#include "H5SMpkg.h" /* Shared object header messages */
@@ -248,7 +249,7 @@ H5SM_bt2_convert_to_list_op(const void * record, void *op_data)
/* Insert this message at the end of the list */
HDassert(list->messages[mesg_idx].location == H5SM_NO_LOC);
HDassert(message->location != H5SM_NO_LOC);
- HDmemcpy(&(list->messages[mesg_idx]), message, sizeof(H5SM_sohm_t));
+ H5MM_memcpy(&(list->messages[mesg_idx]), message, sizeof(H5SM_sohm_t));
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5SM_bt2_convert_to_list_op() */
diff --git a/src/H5SMcache.c b/src/H5SMcache.c
index f0b469a..49ce2b4 100644
--- a/src/H5SMcache.c
+++ b/src/H5SMcache.c
@@ -388,7 +388,7 @@ H5SM__cache_table_serialize(const H5F_t *f, void *_image, size_t len,
HDassert(H5F_SOHM_VERS(f) == HDF5_SHAREDHEADER_VERSION);
/* Encode magic number */
- HDmemcpy(image, H5SM_TABLE_MAGIC, (size_t)H5_SIZEOF_MAGIC);
+ H5MM_memcpy(image, H5SM_TABLE_MAGIC, (size_t)H5_SIZEOF_MAGIC);
image += H5_SIZEOF_MAGIC;
/* Encode each index header */
@@ -710,7 +710,7 @@ H5SM__cache_list_serialize(const H5F_t *f, void *_image, size_t len,
HDassert(list->header->list_size == len);
/* Encode magic number */
- HDmemcpy(image, H5SM_LIST_MAGIC, (size_t)H5_SIZEOF_MAGIC);
+ H5MM_memcpy(image, H5SM_LIST_MAGIC, (size_t)H5_SIZEOF_MAGIC);
image += H5_SIZEOF_MAGIC;
/* serialize messages from the messages array */
diff --git a/src/H5SMmessage.c b/src/H5SMmessage.c
index ad84b24..0cca6bb 100644
--- a/src/H5SMmessage.c
+++ b/src/H5SMmessage.c
@@ -24,6 +24,7 @@
/***********/
#include "H5private.h" /* Generic Functions */
#include "H5Eprivate.h" /* Error handling */
+#include "H5MMprivate.h" /* Memory management */
#include "H5Opkg.h" /* Object Headers */
#include "H5SMpkg.h" /* Shared object header messages */
@@ -302,7 +303,7 @@ H5SM__message_encode(uint8_t *raw, const void *_nrecord, void *_ctx)
if(message->location == H5SM_IN_HEAP) {
UINT32ENCODE(raw, message->u.heap_loc.ref_count);
- HDmemcpy(raw, message->u.heap_loc.fheap_id.id, (size_t)H5O_FHEAP_ID_LEN);
+ H5MM_memcpy(raw, message->u.heap_loc.fheap_id.id, (size_t)H5O_FHEAP_ID_LEN);
} /* end if */
else {
HDassert(message->location == H5SM_IN_OH);
@@ -343,7 +344,7 @@ H5SM__message_decode(const uint8_t *raw, void *_nrecord, void *_ctx)
if(message->location == H5SM_IN_HEAP) {
UINT32DECODE(raw, message->u.heap_loc.ref_count);
- HDmemcpy(message->u.heap_loc.fheap_id.id, raw, (size_t)H5O_FHEAP_ID_LEN);
+ H5MM_memcpy(message->u.heap_loc.fheap_id.id, raw, (size_t)H5O_FHEAP_ID_LEN);
} /* end if */
else {
HDassert(message->location == H5SM_IN_OH);
diff --git a/src/H5ST.c b/src/H5ST.c
index dd5b63c..3a1020b 100644
--- a/src/H5ST.c
+++ b/src/H5ST.c
@@ -743,19 +743,19 @@ H5ST__dump_internal(H5ST_ptr_t p)
FUNC_ENTER_STATIC_NOERR
if(p) {
- printf("p=%p\n", (void *)p);
- printf("\tp->up=%p\n", (void *)p->up);
- printf("\tp->parent=%p\n", (void *)p->parent);
- printf("\tp->lokid=%p\n", (void *)p->lokid);
- printf("\tp->hikid=%p\n", (void *)p->hikid);
- printf("\tp->eqkid=%p\n", (void *)p->eqkid);
- printf("\tp->splitchar=%c\n", p->splitchar);
+ HDprintf("p=%p\n", (void *)p);
+ HDprintf("\tp->up=%p\n", (void *)p->up);
+ HDprintf("\tp->parent=%p\n", (void *)p->parent);
+ HDprintf("\tp->lokid=%p\n", (void *)p->lokid);
+ HDprintf("\tp->hikid=%p\n", (void *)p->hikid);
+ HDprintf("\tp->eqkid=%p\n", (void *)p->eqkid);
+ HDprintf("\tp->splitchar=%c\n", p->splitchar);
H5ST__dump_internal(p->lokid);
if(p->splitchar)
H5ST__dump_internal(p->eqkid);
else
- printf("%s\n", (char *)p->eqkid);
+ HDprintf("%s\n", (char *)p->eqkid);
H5ST__dump_internal(p->hikid);
} /* end if */
diff --git a/src/H5Sall.c b/src/H5Sall.c
index 3b77b98..fbe7041 100644
--- a/src/H5Sall.c
+++ b/src/H5Sall.c
@@ -18,38 +18,55 @@
* Purpose: "All" selection dataspace I/O functions.
*/
+/****************/
+/* Module Setup */
+/****************/
+
#include "H5Smodule.h" /* This source code file is part of the H5S module */
+/***********/
+/* Headers */
+/***********/
#include "H5private.h" /* Generic Functions */
#include "H5Eprivate.h" /* Error handling */
#include "H5Iprivate.h" /* ID Functions */
#include "H5Spkg.h" /* Dataspace functions */
-#include "H5VMprivate.h" /* Vector functions */
+#include "H5VMprivate.h" /* Vector functions */
+
+
+/****************/
+/* Local Macros */
+/****************/
+
+
+/******************/
+/* Local Typedefs */
+/******************/
+
-/* Static function prototypes */
+/********************/
+/* Local Prototypes */
+/********************/
/* Selection callbacks */
static herr_t H5S__all_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection);
-static herr_t H5S__all_get_seq_list(const H5S_t *space, unsigned flags,
- H5S_sel_iter_t *iter, size_t maxseq, size_t maxbytes,
- size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len);
static herr_t H5S__all_release(H5S_t *space);
static htri_t H5S__all_is_valid(const H5S_t *space);
static hssize_t H5S__all_serial_size(const H5S_t *space);
static herr_t H5S__all_serialize(const H5S_t *space, uint8_t **p);
-static herr_t H5S__all_deserialize(H5S_t *space, uint32_t version, uint8_t flags,
- const uint8_t **p);
+static herr_t H5S__all_deserialize(H5S_t **space, const uint8_t **p);
static herr_t H5S__all_bounds(const H5S_t *space, hsize_t *start, hsize_t *end);
static herr_t H5S__all_offset(const H5S_t *space, hsize_t *off);
static int H5S__all_unlim_dim(const H5S_t *space);
static htri_t H5S__all_is_contiguous(const H5S_t *space);
static htri_t H5S__all_is_single(const H5S_t *space);
static htri_t H5S__all_is_regular(const H5S_t *space);
+static htri_t H5S__all_shape_same(const H5S_t *space1, const H5S_t *space2);
static herr_t H5S__all_adjust_u(H5S_t *space, const hsize_t *offset);
static herr_t H5S__all_project_scalar(const H5S_t *space, hsize_t *offset);
static herr_t H5S__all_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset);
-static herr_t H5S__all_iter_init(H5S_sel_iter_t *iter, const H5S_t *space);
+static herr_t H5S__all_iter_init(const H5S_t *space, H5S_sel_iter_t *iter);
/* Selection iteration callbacks */
static herr_t H5S__all_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords);
@@ -58,15 +75,26 @@ static hsize_t H5S__all_iter_nelmts(const H5S_sel_iter_t *iter);
static htri_t H5S__all_iter_has_next_block(const H5S_sel_iter_t *iter);
static herr_t H5S__all_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem);
static herr_t H5S__all_iter_next_block(H5S_sel_iter_t *sel_iter);
+static herr_t H5S__all_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq,
+ size_t maxbytes, size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len);
static herr_t H5S__all_iter_release(H5S_sel_iter_t *sel_iter);
+
+/*****************************/
+/* Library Private Variables */
+/*****************************/
+
+
+/*********************/
+/* Package Variables */
+/*********************/
+
/* Selection properties for "all" selections */
const H5S_select_class_t H5S_sel_all[1] = {{
H5S_SEL_ALL,
/* Methods on selection */
H5S__all_copy,
- H5S__all_get_seq_list,
H5S__all_release,
H5S__all_is_valid,
H5S__all_serial_size,
@@ -79,12 +107,18 @@ const H5S_select_class_t H5S_sel_all[1] = {{
H5S__all_is_contiguous,
H5S__all_is_single,
H5S__all_is_regular,
+ H5S__all_shape_same,
H5S__all_adjust_u,
H5S__all_project_scalar,
H5S__all_project_simple,
H5S__all_iter_init,
}};
+
+/*******************/
+/* Local Variables */
+/*******************/
+
/* Iteration properties for "all" selections */
static const H5S_sel_iter_class_t H5S_sel_iter_all[1] = {{
H5S_SEL_ALL,
@@ -96,16 +130,18 @@ static const H5S_sel_iter_class_t H5S_sel_iter_all[1] = {{
H5S__all_iter_has_next_block,
H5S__all_iter_next,
H5S__all_iter_next_block,
+ H5S__all_iter_get_seq_list,
H5S__all_iter_release,
}};
+
/*-------------------------------------------------------------------------
* Function: H5S__all_iter_init
*
* Purpose: Initializes iteration information for "all" selection.
*
- * Return: non-negative on success, negative on failure.
+ * Return: Non-negative on success, negative on failure.
*
* Programmer: Quincey Koziol
* Tuesday, June 16, 1998
@@ -113,7 +149,7 @@ static const H5S_sel_iter_class_t H5S_sel_iter_all[1] = {{
*-------------------------------------------------------------------------
*/
static herr_t
-H5S__all_iter_init(H5S_sel_iter_t *iter, const H5S_t *space)
+H5S__all_iter_init(const H5S_t H5_ATTR_UNUSED *space, H5S_sel_iter_t *iter)
{
FUNC_ENTER_STATIC_NOERR
@@ -121,9 +157,6 @@ H5S__all_iter_init(H5S_sel_iter_t *iter, const H5S_t *space)
HDassert(space && H5S_SEL_ALL == H5S_GET_SELECT_TYPE(space));
HDassert(iter);
- /* Initialize the number of elements to iterate over */
- iter->elmt_left = H5S_GET_SELECT_NPOINTS(space);
-
/* Start at the upper left location */
iter->u.all.elmt_offset = 0;
iter->u.all.byte_offset = 0;
@@ -132,7 +165,7 @@ H5S__all_iter_init(H5S_sel_iter_t *iter, const H5S_t *space)
iter->type = H5S_sel_iter_all;
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5S__all_iter_init() */
+} /* end H5S__all_iter_init() */
/*-------------------------------------------------------------------------
@@ -141,7 +174,7 @@ H5S__all_iter_init(H5S_sel_iter_t *iter, const H5S_t *space)
* Purpose: Retrieve the current coordinates of iterator for current
* selection
*
- * Return: non-negative on success, negative on failure
+ * Return: Non-negative on success, negative on failure
*
* Programmer: Quincey Koziol
* Tuesday, April 22, 2003
@@ -165,7 +198,7 @@ H5S__all_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords)
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S__all_iter_coords() */
+} /* end H5S__all_iter_coords() */
/*-------------------------------------------------------------------------
@@ -174,7 +207,7 @@ done:
* Purpose: Retrieve the current block of iterator for current
* selection
*
- * Return: non-negative on success, negative on failure
+ * Return: Non-negative on success, negative on failure
*
* Programmer: Quincey Koziol
* Monday, June 2, 2003
@@ -204,7 +237,7 @@ H5S__all_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end)
} /* end for */
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5S__all_iter_block() */
+} /* end H5S__all_iter_block() */
/*-------------------------------------------------------------------------
@@ -212,7 +245,7 @@ H5S__all_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end)
*
* Purpose: Return number of elements left to process in iterator
*
- * Return: non-negative number of elements on success, zero on failure
+ * Return: Non-negative number of elements on success, zero on failure
*
* Programmer: Quincey Koziol
* Tuesday, June 16, 1998
@@ -228,7 +261,7 @@ H5S__all_iter_nelmts(const H5S_sel_iter_t *iter)
HDassert(iter);
FUNC_LEAVE_NOAPI(iter->elmt_left)
-} /* H5S__all_iter_nelmts() */
+} /* end H5S__all_iter_nelmts() */
/*--------------------------------------------------------------------------
@@ -257,7 +290,7 @@ H5S__all_iter_has_next_block(const H5S_sel_iter_t H5_ATTR_UNUSED *iter)
HDassert(iter);
FUNC_LEAVE_NOAPI(FALSE)
-} /* H5S__all_iter_has_next_block() */
+} /* end H5S__all_iter_has_next_block() */
/*--------------------------------------------------------------------------
@@ -292,7 +325,7 @@ H5S__all_iter_next(H5S_sel_iter_t *iter, size_t nelem)
iter->u.all.byte_offset += (nelem * iter->elmt_size);
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5S__all_iter_next() */
+} /* end H5S__all_iter_next() */
/*--------------------------------------------------------------------------
@@ -321,7 +354,77 @@ H5S__all_iter_next_block(H5S_sel_iter_t H5_ATTR_UNUSED *iter)
HDassert(iter);
FUNC_LEAVE_NOAPI(FAIL)
-} /* H5S__all_iter_next_block() */
+} /* end H5S__all_iter_next_block() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S__all_iter_get_seq_list
+ PURPOSE
+ Create a list of offsets & lengths for a selection
+ USAGE
+ herr_t H5S__all_iter_get_seq_list(iter,maxseq,maxelem,nseq,nelem,off,len)
+ H5S_sel_iter_t *iter; IN/OUT: Selection iterator describing last
+ position of interest in selection.
+ size_t maxseq; IN: Maximum number of sequences to generate
+ size_t maxelem; IN: Maximum number of elements to include in the
+ generated sequences
+ size_t *nseq; OUT: Actual number of sequences generated
+ size_t *nelem; OUT: Actual number of elements in sequences generated
+ hsize_t *off; OUT: Array of offsets
+ size_t *len; OUT: Array of lengths
+ RETURNS
+ Non-negative on success/Negative on failure.
+ DESCRIPTION
+ Use the selection in the dataspace to generate a list of byte offsets and
+ lengths for the region(s) selected. Start/Restart from the position in the
+ ITER parameter. The number of sequences generated is limited by the MAXSEQ
+ parameter and the number of sequences actually generated is stored in the
+ NSEQ parameter.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+static herr_t
+H5S__all_iter_get_seq_list(H5S_sel_iter_t *iter, size_t H5_ATTR_UNUSED maxseq,
+ size_t maxelem, size_t *nseq, size_t *nelem, hsize_t *off, size_t *len)
+{
+ size_t elem_used; /* The number of elements used */
+
+ FUNC_ENTER_STATIC_NOERR
+
+ /* Check args */
+ HDassert(iter);
+ HDassert(maxseq > 0);
+ HDassert(maxelem > 0);
+ HDassert(nseq);
+ HDassert(nelem);
+ HDassert(off);
+ HDassert(len);
+
+ /* Determine the actual number of elements to use */
+ H5_CHECK_OVERFLOW(iter->elmt_left, hsize_t, size_t);
+ elem_used = MIN(maxelem, (size_t)iter->elmt_left);
+ HDassert(elem_used > 0);
+
+ /* Compute the offset in the dataset */
+ off[0] = iter->u.all.byte_offset;
+ len[0] = elem_used * iter->elmt_size;
+
+ /* Should only need one sequence for 'all' selections */
+ *nseq = 1;
+
+ /* Set the number of elements used */
+ *nelem = elem_used;
+
+ /* Update the iterator */
+ iter->elmt_left -= elem_used;
+ iter->u.all.elmt_offset += elem_used;
+ iter->u.all.byte_offset += len[0];
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5S__all_iter_get_seq_list() */
/*--------------------------------------------------------------------------
@@ -350,7 +453,7 @@ H5S__all_iter_release(H5S_sel_iter_t H5_ATTR_UNUSED * iter)
HDassert(iter);
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5S__all_iter_release() */
+} /* end H5S__all_iter_release() */
/*--------------------------------------------------------------------------
@@ -382,7 +485,7 @@ H5S__all_release(H5S_t *space)
space->select.num_elem = 0;
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5S__all_release() */
+} /* end H5S__all_release() */
/*--------------------------------------------------------------------------
@@ -391,9 +494,10 @@ H5S__all_release(H5S_t *space)
PURPOSE
Copy a selection from one dataspace to another
USAGE
- herr_t H5S__all_copy(dst, src)
+ herr_t H5S__all_copy(dst, src, share_selection)
H5S_t *dst; OUT: Pointer to the destination dataspace
H5S_t *src; IN: Pointer to the source dataspace
+ hbool_t; IN: Whether to share the selection between the dataspaces
RETURNS
Non-negative on success/Negative on failure
DESCRIPTION
@@ -519,7 +623,7 @@ H5S__all_serialize(const H5S_t *space, uint8_t **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)H5S_ALL_VERSION_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 */
@@ -527,7 +631,7 @@ H5S__all_serialize(const H5S_t *space, uint8_t **p)
*p = pp;
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5S__all_serialize() */
+} /* end H5S__all_serialize() */
/*--------------------------------------------------------------------------
@@ -537,10 +641,8 @@ H5S__all_serialize(const H5S_t *space, uint8_t **p)
Deserialize the current selection from a user-provided buffer.
USAGE
herr_t H5S_all_deserialize(space, p)
- H5S_t *space; IN/OUT: Dataspace pointer to place
+ H5S_t **space; IN/OUT: Dataspace pointer to place
selection into
- uint32_t version IN: Selection version
- uint8_t flags IN: Selection flags
uint8 **p; OUT: Pointer to buffer holding serialized
selection. Will be advanced to end of
serialized selection.
@@ -555,24 +657,53 @@ H5S__all_serialize(const H5S_t *space, uint8_t **p)
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
-H5S__all_deserialize(H5S_t *space, uint32_t H5_ATTR_UNUSED version, uint8_t H5_ATTR_UNUSED flags,
- const uint8_t H5_ATTR_UNUSED **p)
+H5S__all_deserialize(H5S_t **space, const uint8_t **p)
{
+ uint32_t version; /* Version number */
+ H5S_t *tmp_space = NULL; /* Pointer to actual dataspace to use,
+ either *space or a newly allocated one */
herr_t ret_value = SUCCEED; /* return value */
FUNC_ENTER_STATIC
- HDassert(space);
HDassert(p);
HDassert(*p);
+ /* As part of the efforts to push all selection-type specific coding
+ to the callbacks, the coding for the allocation of a null dataspace
+ is moved from H5S_select_deserialize() in H5Sselect.c.
+ This is needed for decoding virtual layout in H5O__layout_decode() */
+
+ /* Allocate space if not provided */
+ if(!*space) {
+ if(NULL == (tmp_space = H5S_create(H5S_SIMPLE)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create dataspace")
+ } /* end if */
+ else
+ tmp_space = *space;
+
+ /* Decode version */
+ UINT32DECODE(*p, version);
+
+ /* Skip over the remainder of the header */
+ *p += 8;
+
/* Change to "all" selection */
- if(H5S_select_all(space, TRUE) < 0)
+ if(H5S_select_all(tmp_space, TRUE) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection")
+ /* Return space to the caller if allocated */
+ if(!*space)
+ *space = tmp_space;
+
done:
+ /* Free temporary space if not passed to caller (only happens on error) */
+ if(!*space && tmp_space)
+ if(H5S_close(tmp_space) < 0)
+ HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "can't close dataspace")
+
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S__all_deserialize() */
+} /* end H5S__all_deserialize() */
/*--------------------------------------------------------------------------
@@ -622,7 +753,7 @@ H5S__all_bounds(const H5S_t *space, hsize_t *start, hsize_t *end)
} /* end for */
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5S__all_bounds() */
+} /* end H5S__all_bounds() */
/*--------------------------------------------------------------------------
@@ -657,7 +788,7 @@ H5S__all_offset(const H5S_t H5_ATTR_UNUSED *space, hsize_t *offset)
*offset = 0;
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5S__all_offset() */
+} /* end H5S__all_offset() */
/*--------------------------------------------------------------------------
@@ -716,7 +847,7 @@ H5S__all_is_contiguous(const H5S_t H5_ATTR_UNUSED *space)
HDassert(space);
FUNC_LEAVE_NOAPI(TRUE)
-} /* H5S__all_is_contiguous() */
+} /* end H5S__all_is_contiguous() */
/*--------------------------------------------------------------------------
@@ -745,7 +876,7 @@ H5S__all_is_single(const H5S_t H5_ATTR_UNUSED *space)
HDassert(space);
FUNC_LEAVE_NOAPI(TRUE)
-} /* H5S__all_is_single() */
+} /* end H5S__all_is_single() */
/*--------------------------------------------------------------------------
@@ -776,7 +907,71 @@ H5S__all_is_regular(const H5S_t H5_ATTR_UNUSED *space)
HDassert(space);
FUNC_LEAVE_NOAPI(TRUE)
-} /* H5S__all_is_regular() */
+} /* end H5S__all_is_regular() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S__all_shape_same
+ PURPOSE
+ Check if a two "all" selections are the same shape
+ USAGE
+ htri_t H5S__all_shape_same(space1, space2)
+ const H5S_t *space1; IN: First dataspace to check
+ const H5S_t *space2; IN: Second dataspace to check
+ RETURNS
+ TRUE / FALSE / FAIL
+ DESCRIPTION
+ Checks to see if the current selection in each dataspace are the same
+ shape.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+static htri_t
+H5S__all_shape_same(const H5S_t *space1, const H5S_t *space2)
+{
+ int space1_dim; /* Current dimension in first dataspace */
+ int space2_dim; /* Current dimension in second dataspace */
+ htri_t ret_value = TRUE; /* Return value */
+
+ FUNC_ENTER_STATIC_NOERR
+
+ /* Check args */
+ HDassert(space1);
+ HDassert(space2);
+
+ /* Initialize dataspace dims */
+ space1_dim = (int)space1->extent.rank - 1;
+ space2_dim = (int)space2->extent.rank - 1;
+
+ /* Recall that space1_rank >= space2_rank.
+ *
+ * In the following while loop, we test to see if space1 and space2
+ * have identical size in all dimensions they have in common.
+ */
+ while(space2_dim >= 0) {
+ if(space1->extent.size[space1_dim] != space2->extent.size[space2_dim])
+ HGOTO_DONE(FALSE)
+
+ space1_dim--;
+ space2_dim--;
+ } /* end while */
+
+ /* Since we are selecting the entire space, we must also verify that space1
+ * has size 1 in all dimensions that it does not share with space2.
+ */
+ while(space1_dim >= 0) {
+ if(space1->extent.size[space1_dim] != 1)
+ HGOTO_DONE(FALSE)
+
+ space1_dim--;
+ } /* end while */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5S__all_shape_same() */
/*--------------------------------------------------------------------------
@@ -807,7 +1002,7 @@ H5S__all_adjust_u(H5S_t H5_ATTR_UNUSED *space, const hsize_t H5_ATTR_UNUSED *off
HDassert(offset);
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5S__all_adjust_u() */
+} /* end H5S__all_adjust_u() */
/*-------------------------------------------------------------------------
@@ -816,7 +1011,7 @@ H5S__all_adjust_u(H5S_t H5_ATTR_UNUSED *space, const hsize_t H5_ATTR_UNUSED *off
* Purpose: Projects a single element 'all' selection into a scalar
* dataspace
*
- * Return: non-negative on success, negative on failure.
+ * Return: Non-negative on success, negative on failure.
*
* Programmer: Quincey Koziol
* Sunday, July 18, 2010
@@ -836,7 +1031,7 @@ H5S__all_project_scalar(const H5S_t H5_ATTR_UNUSED *space, hsize_t *offset)
*offset = 0;
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5S__all_project_scalar() */
+} /* end H5S__all_project_scalar() */
/*-------------------------------------------------------------------------
@@ -845,7 +1040,7 @@ H5S__all_project_scalar(const H5S_t H5_ATTR_UNUSED *space, hsize_t *offset)
* Purpose: Projects an 'all' selection onto/into a simple dataspace
* of a different rank
*
- * Return: non-negative on success, negative on failure.
+ * Return: Non-negative on success, negative on failure.
*
* Programmer: Quincey Koziol
* Sunday, July 18, 2010
@@ -853,7 +1048,8 @@ H5S__all_project_scalar(const H5S_t H5_ATTR_UNUSED *space, hsize_t *offset)
*-------------------------------------------------------------------------
*/
static herr_t
-H5S__all_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *offset)
+H5S__all_project_simple(const H5S_t H5_ATTR_UNUSED *base_space,
+ H5S_t *new_space, hsize_t H5_ATTR_UNUSED *offset)
{
herr_t ret_value = SUCCEED; /* Return value */
@@ -870,7 +1066,7 @@ H5S__all_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *offs
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S__all_project_simple() */
+} /* end H5S__all_project_simple() */
/*--------------------------------------------------------------------------
@@ -914,7 +1110,7 @@ H5S_select_all(H5S_t *space, hbool_t rel_prev)
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_select_all() */
+} /* end H5S_select_all() */
/*--------------------------------------------------------------------------
@@ -953,79 +1149,5 @@ H5Sselect_all(hid_t spaceid)
done:
FUNC_LEAVE_API(ret_value)
-} /* H5Sselect_all() */
-
-
-/*--------------------------------------------------------------------------
- NAME
- H5S__all_get_seq_list
- PURPOSE
- Create a list of offsets & lengths for a selection
- USAGE
- herr_t H5S__all_get_seq_list(space,flags,iter,maxseq,maxelem,nseq,nelem,off,len)
- H5S_t *space; IN: Dataspace containing selection to use.
- unsigned flags; IN: Flags for extra information about operation
- H5S_sel_iter_t *iter; IN/OUT: Selection iterator describing last
- position of interest in selection.
- size_t maxseq; IN: Maximum number of sequences to generate
- size_t maxelem; IN: Maximum number of elements to include in the
- generated sequences
- size_t *nseq; OUT: Actual number of sequences generated
- size_t *nelem; OUT: Actual number of elements in sequences generated
- hsize_t *off; OUT: Array of offsets
- size_t *len; OUT: Array of lengths
- RETURNS
- Non-negative on success/Negative on failure.
- DESCRIPTION
- Use the selection in the dataspace to generate a list of byte offsets and
- lengths for the region(s) selected. Start/Restart from the position in the
- ITER parameter. The number of sequences generated is limited by the MAXSEQ
- parameter and the number of sequences actually generated is stored in the
- NSEQ parameter.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-static herr_t
-H5S__all_get_seq_list(const H5S_t H5_ATTR_UNUSED *space, unsigned H5_ATTR_UNUSED flags, H5S_sel_iter_t *iter,
- size_t H5_ATTR_UNUSED maxseq, size_t maxelem, size_t *nseq, size_t *nelem,
- hsize_t *off, size_t *len)
-{
- size_t elem_used; /* The number of elements used */
-
- FUNC_ENTER_STATIC_NOERR
-
- /* Check args */
- HDassert(space);
- HDassert(iter);
- HDassert(maxseq > 0);
- HDassert(maxelem > 0);
- HDassert(nseq);
- HDassert(nelem);
- HDassert(off);
- HDassert(len);
-
- /* Determine the actual number of elements to use */
- H5_CHECK_OVERFLOW(iter->elmt_left, hsize_t, size_t);
- elem_used = MIN(maxelem, (size_t)iter->elmt_left);
- HDassert(elem_used > 0);
-
- /* Compute the offset in the dataset */
- off[0] = iter->u.all.byte_offset;
- len[0] = elem_used * iter->elmt_size;
-
- /* Should only need one sequence for 'all' selections */
- *nseq = 1;
-
- /* Set the number of elements used */
- *nelem = elem_used;
-
- /* Update the iterator */
- iter->elmt_left -= elem_used;
- iter->u.all.elmt_offset += elem_used;
- iter->u.all.byte_offset += len[0];
-
- FUNC_LEAVE_NOAPI(SUCCEED)
-} /* end H5S__all_get_seq_list() */
+} /* end H5Sselect_all() */
diff --git a/src/H5Sdbg.c b/src/H5Sdbg.c
index ebd05ce..8171191 100644
--- a/src/H5Sdbg.c
+++ b/src/H5Sdbg.c
@@ -57,16 +57,16 @@
/********************/
-/*********************/
-/* Package Variables */
-/*********************/
-
-
/*****************************/
/* Library Private Variables */
/*****************************/
+/*********************/
+/* Package Variables */
+/*********************/
+
+
/*******************/
/* Local Variables */
/*******************/
@@ -94,24 +94,24 @@ H5S_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth)
switch(H5S_GET_EXTENT_TYPE(mesg)) {
case H5S_NULL:
- fprintf(stream, "%*s%-*s H5S_NULL\n", indent, "", fwidth,
+ HDfprintf(stream, "%*s%-*s H5S_NULL\n", indent, "", fwidth,
"Space class:");
break;
case H5S_SCALAR:
- fprintf(stream, "%*s%-*s H5S_SCALAR\n", indent, "", fwidth,
+ HDfprintf(stream, "%*s%-*s H5S_SCALAR\n", indent, "", fwidth,
"Space class:");
break;
case H5S_SIMPLE:
- fprintf(stream, "%*s%-*s H5S_SIMPLE\n", indent, "", fwidth,
+ HDfprintf(stream, "%*s%-*s H5S_SIMPLE\n", indent, "", fwidth,
"Space class:");
H5O_debug_id(H5O_SDSPACE_ID, f, &(mesg->extent), stream, indent + 3, MAX(0, fwidth - 3));
break;
case H5S_NO_CLASS:
default:
- fprintf(stream, "%*s%-*s **UNKNOWN-%ld**\n", indent, "", fwidth,
+ HDfprintf(stream, "%*s%-*s **UNKNOWN-%ld**\n", indent, "", fwidth,
"Space class:", (long)(H5S_GET_EXTENT_TYPE(mesg)));
break;
} /* end switch */
diff --git a/src/H5Sdeprec.c b/src/H5Sdeprec.c
new file mode 100644
index 0000000..e4ec1b0
--- /dev/null
+++ b/src/H5Sdeprec.c
@@ -0,0 +1,121 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*-------------------------------------------------------------------------
+ *
+ * Created: H5Sdeprec.c
+ *
+ * Purpose: Deprecated functions from the H5S interface. These
+ * functions are here for compatibility purposes and may be
+ * removed in the future. Applications should switch to the
+ * newer APIs.
+ *
+ *-------------------------------------------------------------------------
+ */
+
+/****************/
+/* Module Setup */
+/****************/
+
+#include "H5Smodule.h" /* This source code file is part of the H5S module */
+
+
+/***********/
+/* Headers */
+/***********/
+#include "H5private.h" /* Generic Functions */
+#include "H5CXprivate.h" /* API Contexts */
+#include "H5Spkg.h" /* Dataspaces */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5Iprivate.h" /* IDs */
+
+
+/****************/
+/* Local Macros */
+/****************/
+
+
+/******************/
+/* Local Typedefs */
+/******************/
+
+
+/********************/
+/* Package Typedefs */
+/********************/
+
+
+/********************/
+/* Local Prototypes */
+/********************/
+
+
+/*********************/
+/* Package Variables */
+/*********************/
+
+
+/*****************************/
+/* Library Private Variables */
+/*****************************/
+
+
+/*******************/
+/* Local Variables */
+/*******************/
+
+
+#ifndef H5_NO_DEPRECATED_SYMBOLS
+
+/*-------------------------------------------------------------------------
+ * Function: H5Sencode1
+ *
+ * Purpose: Given a dataspace ID, converts the object description
+ * (including selection) into binary in a buffer.
+ *
+ * Return: Success: non-negative
+ * Failure: negative
+ *
+ * Programmer: Raymond Lu
+ * slu@ncsa.uiuc.edu
+ * July 14, 2004
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Sencode1(hid_t obj_id, void *buf, size_t *nalloc)
+{
+ H5S_t *dspace;
+ hid_t temp_fapl_id = H5P_DEFAULT;
+ herr_t ret_value=SUCCEED;
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE3("e", "i*x*z", obj_id, buf, nalloc);
+
+ /* Check argument and retrieve object */
+ if (NULL == (dspace = (H5S_t *)H5I_object_verify(obj_id, H5I_DATASPACE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace")
+
+ /* Verify access property list and set up collective metadata if appropriate */
+ if(H5CX_set_apl(&temp_fapl_id, H5P_CLS_FACC, H5I_INVALID_HID, TRUE) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info")
+
+ /* Use (earliest, latest) i.e. not latest format */
+ if(H5S_encode(dspace, (unsigned char **)&buf, nalloc)<0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTENCODE, FAIL, "can't encode dataspace")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* H5Sencode1() */
+#endif /* H5_NO_DEPRECATED_SYMBOLS */
+
diff --git a/src/H5Shyper.c b/src/H5Shyper.c
index 88c570d..2acc135 100644
--- a/src/H5Shyper.c
+++ b/src/H5Shyper.c
@@ -18,56 +18,163 @@
* Purpose: Hyperslab selection dataspace I/O functions.
*/
+/****************/
+/* Module Setup */
+/****************/
+
#include "H5Smodule.h" /* This source code file is part of the H5S module */
-#include "H5private.h" /* Generic Functions */
+/***********/
+/* Headers */
+/***********/
+#include "H5private.h" /* Generic Functions */
+#include "H5CXprivate.h" /* API Contexts */
#include "H5Eprivate.h" /* Error handling */
#include "H5FLprivate.h" /* Free Lists */
#include "H5Iprivate.h" /* ID Functions */
-#include "H5Spkg.h" /* Dataspace functions */
-#include "H5VMprivate.h" /* Vector functions */
+#include "H5MMprivate.h" /* Memory management */
+#include "H5Spkg.h" /* Dataspace functions */
+#include "H5VMprivate.h" /* Vector functions */
-/* Local Macros */
-/* Local datatypes */
+/****************/
+/* Local Macros */
+/****************/
-/* Static function prototypes */
+/* Macro for checking if two ranges overlap one another */
+/*
+ * Check for the inverse of whether the ranges are disjoint. If they are
+ * disjoint, then the low bound of one of the ranges must be greater than the
+ * high bound of the other.
+ */
+/* (Assumes that low & high bounds are _inclusive_) */
+#define H5S_RANGE_OVERLAP(L1, H1, L2, H2) \
+ (!((L1) > (H2) || (L2) > (H1)))
+
+/* Flags for which hyperslab fragments to compute */
+#define H5S_HYPER_COMPUTE_B_NOT_A 0x01
+#define H5S_HYPER_COMPUTE_A_AND_B 0x02
+#define H5S_HYPER_COMPUTE_A_NOT_B 0x04
+
+/* Macro to advance a span, possibly recycling it first */
+#define H5S_HYPER_ADVANCE_SPAN(recover, curr_span, next_span) \
+ do { \
+ H5S_hyper_span_t *saved_next_span = (next_span); \
+ \
+ /* Check if the span should be recovered */ \
+ if(recover) { \
+ H5S__hyper_free_span(curr_span); \
+ (recover) = FALSE; \
+ } /* end if */ \
+ \
+ /* Set the current span to saved next span */ \
+ (curr_span) = saved_next_span; \
+ } while(0)
+
+/* Macro to add "skipped" elements to projection during the execution of
+ * H5S__hyper_project_intersect() */
+#define H5S_HYPER_PROJ_INT_ADD_SKIP(UDATA, ADD, ERR) \
+ do { \
+ /* If there are any elements to add, we must add them \
+ * to the projection first before adding skip */ \
+ if((UDATA)->nelem > 0) \
+ if(H5S__hyper_proj_int_build_proj(UDATA) < 0) \
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, ERR, "can't add elements to projected selection") \
+ (UDATA)->skip += (ADD); \
+ } while(0) /* end H5S_HYPER_PROJ_INT_ADD_SKIP() */
+
+
+/******************/
+/* Local Typedefs */
+/******************/
+
+/* Define alias for hsize_t, for allocating H5S_hyper_span_info_t + bounds objects */
+/* (Makes it easier to understand the alloc / free calls) */
+typedef hsize_t hbounds_t;
+
+/* Struct for holding persistent information during iteration for
+ * H5S__hyper_project_intersect() */
+typedef struct {
+ const H5S_hyper_span_t *ds_span[H5S_MAX_RANK]; /* Array of the current spans in the destination space in each dimension */
+ hsize_t ds_low[H5S_MAX_RANK]; /* Array of current low bounds (of iteration) for each element in ds_span */
+ H5S_hyper_span_info_t *ps_span_info[H5S_MAX_RANK]; /* Array of span info structs for projected space during iteration */
+ uint32_t ps_clean_bitmap; /* Bitmap of whether the nth rank has a clean projected space since the last time it was set to 1 */
+ unsigned ss_rank; /* Rank of source space */
+ unsigned ds_rank; /* Rank of destination space */
+ unsigned depth; /* Current depth of iterator in destination space */
+ hsize_t skip; /* Number of elements to skip in projected space */
+ hsize_t nelem; /* Number of elements to add to projected space (after skip) */
+ uint64_t op_gen; /* Operation generation for counting elements */
+} H5S_hyper_project_intersect_ud_t;
+
+/* Assert that H5S_MAX_RANK is <= 32 so our trick with using a 32 bit bitmap
+ * (ps_clean_bitmap) works. If H5S_MAX_RANK increases either increase the size
+ * of ps_clean_bitmap or change the algorithm to use an array. */
+#if H5S_MAX_RANK > 32
+#error H5S_MAX_RANK too large for ps_clean_bitmap field in H5S_hyper_project_intersect_ud_t struct
+#endif
+
+
+/********************/
+/* Local Prototypes */
+/********************/
static H5S_hyper_span_t *H5S__hyper_new_span(hsize_t low, hsize_t high,
H5S_hyper_span_info_t *down, H5S_hyper_span_t *next);
-static herr_t H5S__hyper_span_precompute(H5S_hyper_span_info_t *spans, size_t elmt_size);
-static void H5S__hyper_span_scratch(H5S_hyper_span_info_t *spans);
-static H5S_hyper_span_info_t *H5S__hyper_copy_span(H5S_hyper_span_info_t *spans);
+static H5S_hyper_span_info_t *H5S__hyper_new_span_info(unsigned rank);
+static H5S_hyper_span_info_t *H5S__hyper_copy_span(H5S_hyper_span_info_t *spans,
+ unsigned rank);
static hbool_t H5S__hyper_cmp_spans(const H5S_hyper_span_info_t *span_info1,
const H5S_hyper_span_info_t *span_info2);
-static herr_t H5S__hyper_free_span_info(H5S_hyper_span_info_t *span_info);
-static herr_t H5S__hyper_free_span(H5S_hyper_span_t *span);
-static hbool_t H5S__hyper_is_valid_helper(const H5S_hyper_span_info_t *spans,
- const hssize_t *offset, const hsize_t *size);
-static herr_t H5S__hyper_recover_span(hbool_t *recover,
- H5S_hyper_span_t **curr_span, H5S_hyper_span_t *next_span);
-static H5S_hyper_span_t *H5S__hyper_coord_to_span(unsigned rank,
- const hsize_t *coords);
-static herr_t H5S__hyper_append_span(H5S_hyper_span_t **prev_span,
- H5S_hyper_span_info_t **span_tree, hsize_t low, hsize_t high,
- H5S_hyper_span_info_t *down, H5S_hyper_span_t *next);
+static void H5S__hyper_free_span_info(H5S_hyper_span_info_t *span_info);
+static void H5S__hyper_free_span(H5S_hyper_span_t *span);
+static herr_t H5S__hyper_span_blocklist(const H5S_hyper_span_info_t *spans,
+ hsize_t start[], hsize_t end[], hsize_t rank, hsize_t *startblock, hsize_t *numblocks,
+ hsize_t **buf);
+static herr_t H5S__get_select_hyper_blocklist(H5S_t *space, hsize_t startblock,
+ hsize_t numblocks, hsize_t *buf);
+static H5S_hyper_span_t *H5S__hyper_coord_to_span(unsigned rank, const hsize_t *coords);
+static herr_t H5S__hyper_append_span(H5S_hyper_span_info_t **span_tree,
+ unsigned ndims, hsize_t low, hsize_t high, H5S_hyper_span_info_t *down);
static herr_t H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans,
- H5S_hyper_span_info_t *b_spans, H5S_hyper_span_info_t **a_not_b,
+ H5S_hyper_span_info_t *b_spans, unsigned selector,
+ unsigned ndims, H5S_hyper_span_info_t **a_not_b,
H5S_hyper_span_info_t **a_and_b, H5S_hyper_span_info_t **b_not_a);
-static herr_t H5S__hyper_merge_spans(H5S_t *space,
- H5S_hyper_span_info_t *new_spans, hbool_t can_own);
-static hsize_t H5S__hyper_spans_nelem(const H5S_hyper_span_info_t *spans);
+static herr_t H5S__hyper_merge_spans(H5S_t *space, H5S_hyper_span_info_t *new_spans);
+static hsize_t H5S__hyper_spans_nelem_helper(H5S_hyper_span_info_t *spans,
+ uint64_t op_gen);
+static hsize_t H5S__hyper_spans_nelem(H5S_hyper_span_info_t *spans);
+static herr_t H5S__hyper_add_disjoint_spans(H5S_t *space, H5S_hyper_span_info_t *new_spans);
static H5S_hyper_span_info_t *H5S__hyper_make_spans(unsigned rank,
- const hsize_t *start, const hsize_t *stride, const hsize_t *count,
- const hsize_t *block);
+ const hsize_t *start, const hsize_t *stride,
+ const hsize_t *count, const hsize_t *block);
+static herr_t H5S__hyper_update_diminfo(H5S_t *space, H5S_seloper_t op,
+ const H5S_hyper_dim_t *new_hyper_diminfo);
static herr_t H5S__hyper_generate_spans(H5S_t *space);
+static hbool_t H5S__check_spans_overlap(const H5S_hyper_span_info_t *spans1,
+ const H5S_hyper_span_info_t *spans2);
+static herr_t H5S__fill_in_new_space(H5S_t *space1, H5S_seloper_t op,
+ H5S_hyper_span_info_t *space2_span_lst, hbool_t can_own_span2,
+ hbool_t *span2_owned, hbool_t *updated_spans, H5S_t **result);
static herr_t H5S__generate_hyperslab(H5S_t *space, H5S_seloper_t op,
const hsize_t start[], const hsize_t stride[], const hsize_t count[],
const hsize_t block[]);
-/* Needed for use in hyperslab code (H5Shyper.c) */
-#ifdef NEW_HYPERSLAB_API
-static herr_t H5S_select_select (H5S_t *space1, H5S_seloper_t op, H5S_t *space2);
-#endif /*NEW_HYPERSLAB_API*/
+static herr_t H5S__set_regular_hyperslab(H5S_t *space, const hsize_t start[],
+ const hsize_t *app_stride, const hsize_t app_count[], const hsize_t *app_block,
+ const hsize_t *opt_stride, const hsize_t opt_count[], const hsize_t *opt_block);
+static herr_t H5S__fill_in_select(H5S_t *space1, H5S_seloper_t op, H5S_t *space2,
+ H5S_t **result);
+static H5S_t *H5S__combine_select(H5S_t *space1, H5S_seloper_t op, H5S_t *space2);
+static herr_t H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq,
+ size_t maxelem, size_t *nseq, size_t *nelem, hsize_t *off, size_t *len);
+static herr_t H5S__hyper_iter_get_seq_list_opt(H5S_sel_iter_t *iter, size_t maxseq,
+ size_t maxelem, size_t *nseq, size_t *nelem, hsize_t *off, size_t *len);
+static herr_t H5S__hyper_iter_get_seq_list_single(H5S_sel_iter_t *iter, size_t maxseq,
+ size_t maxelem, size_t *nseq, size_t *nelem, hsize_t *off, size_t *len);
+static herr_t H5S__hyper_proj_int_build_proj(H5S_hyper_project_intersect_ud_t *udata);
+static herr_t H5S__hyper_proj_int_iterate(const H5S_hyper_span_info_t *ss_span_info,
+ const H5S_hyper_span_info_t *sis_span_info, hsize_t count, unsigned depth,
+ H5S_hyper_project_intersect_ud_t *udata);
static void H5S__hyper_get_clip_diminfo(hsize_t start, hsize_t stride,
hsize_t *count, hsize_t *block, hsize_t clip_size);
static hsize_t H5S__hyper_get_clip_extent_real(const H5S_t *clip_space,
@@ -75,15 +182,12 @@ static hsize_t H5S__hyper_get_clip_extent_real(const H5S_t *clip_space,
/* Selection callbacks */
static herr_t H5S__hyper_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection);
-static herr_t H5S__hyper_get_seq_list(const H5S_t *space, unsigned flags,
- H5S_sel_iter_t *iter, size_t maxseq, size_t maxbytes,
- size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len);
static herr_t H5S__hyper_release(H5S_t *space);
static htri_t H5S__hyper_is_valid(const H5S_t *space);
+static hsize_t H5S__hyper_span_nblocks(H5S_hyper_span_info_t *spans);
static hssize_t H5S__hyper_serial_size(const H5S_t *space);
static herr_t H5S__hyper_serialize(const H5S_t *space, uint8_t **p);
-static herr_t H5S__hyper_deserialize(H5S_t *space, uint32_t version, uint8_t flags,
- const uint8_t **p);
+static herr_t H5S__hyper_deserialize(H5S_t **space, const uint8_t **p);
static herr_t H5S__hyper_bounds(const H5S_t *space, hsize_t *start, hsize_t *end);
static herr_t H5S__hyper_offset(const H5S_t *space, hsize_t *offset);
static int H5S__hyper_unlim_dim(const H5S_t *space);
@@ -92,10 +196,11 @@ static herr_t H5S__hyper_num_elem_non_unlim(const H5S_t *space,
static htri_t H5S__hyper_is_contiguous(const H5S_t *space);
static htri_t H5S__hyper_is_single(const H5S_t *space);
static htri_t H5S__hyper_is_regular(const H5S_t *space);
+static htri_t H5S__hyper_shape_same(const H5S_t *space1, const H5S_t *space2);
static herr_t H5S__hyper_adjust_u(H5S_t *space, const hsize_t *offset);
static herr_t H5S__hyper_project_scalar(const H5S_t *space, hsize_t *offset);
static herr_t H5S__hyper_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset);
-static herr_t H5S__hyper_iter_init(H5S_sel_iter_t *iter, const H5S_t *space);
+static herr_t H5S__hyper_iter_init(const H5S_t *space, H5S_sel_iter_t *iter);
/* Selection iteration callbacks */
static herr_t H5S__hyper_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords);
@@ -104,12 +209,19 @@ static hsize_t H5S__hyper_iter_nelmts(const H5S_sel_iter_t *iter);
static htri_t H5S__hyper_iter_has_next_block(const H5S_sel_iter_t *sel_iter);
static herr_t H5S__hyper_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem);
static herr_t H5S__hyper_iter_next_block(H5S_sel_iter_t *sel_iter);
+static herr_t H5S__hyper_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq,
+ size_t maxbytes, size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len);
static herr_t H5S__hyper_iter_release(H5S_sel_iter_t *sel_iter);
-/* Static function for optimizing hyperslab */
-static hbool_t H5S__hyper_rebuild_helper(const H5S_hyper_span_t *span,
- H5S_hyper_dim_t span_slab_info[], unsigned rank);
-static hbool_t H5S__hyper_rebuild(H5S_t *space);
+
+/*****************************/
+/* Library Private Variables */
+/*****************************/
+
+
+/*********************/
+/* Package Variables */
+/*********************/
/* Selection properties for hyperslab selections */
const H5S_select_class_t H5S_sel_hyper[1] = {{
@@ -117,7 +229,6 @@ const H5S_select_class_t H5S_sel_hyper[1] = {{
/* Methods on selection */
H5S__hyper_copy,
- H5S__hyper_get_seq_list,
H5S__hyper_release,
H5S__hyper_is_valid,
H5S__hyper_serial_size,
@@ -130,12 +241,25 @@ const H5S_select_class_t H5S_sel_hyper[1] = {{
H5S__hyper_is_contiguous,
H5S__hyper_is_single,
H5S__hyper_is_regular,
+ H5S__hyper_shape_same,
H5S__hyper_adjust_u,
H5S__hyper_project_scalar,
H5S__hyper_project_simple,
H5S__hyper_iter_init,
}};
+/* Format version bounds for dataspace hyperslab selection */
+const unsigned H5O_sds_hyper_ver_bounds[] = {
+ H5S_HYPER_VERSION_1, /* H5F_LIBVER_EARLIEST */
+ H5S_HYPER_VERSION_1, /* H5F_LIBVER_V18 */
+ H5S_HYPER_VERSION_2, /* H5F_LIBVER_V110 */
+ H5S_HYPER_VERSION_3 /* H5F_LIBVER_LATEST */
+};
+
+/*******************/
+/* Local Variables */
+/*******************/
+
/* Iteration properties for hyperslab selections */
static const H5S_sel_iter_class_t H5S_sel_iter_hyper[1] = {{
H5S_SEL_HYPERSLABS,
@@ -147,22 +271,21 @@ static const H5S_sel_iter_class_t H5S_sel_iter_hyper[1] = {{
H5S__hyper_iter_has_next_block,
H5S__hyper_iter_next,
H5S__hyper_iter_next_block,
+ H5S__hyper_iter_get_seq_list,
H5S__hyper_iter_release,
}};
-/* Static variables */
-
/* Arrays for default stride, block, etc. */
-static const hsize_t H5S_hyper_zeros_g[H5O_LAYOUT_NDIMS] = {
+static const hsize_t H5S_hyper_zeros_g[H5S_MAX_RANK] = {
0,0,0,0, 0,0,0,0,
0,0,0,0, 0,0,0,0,
0,0,0,0, 0,0,0,0,
- 0,0,0,0, 0,0,0,0,0};
-static const hsize_t H5S_hyper_ones_g[H5O_LAYOUT_NDIMS] = {
+ 0,0,0,0, 0,0,0,0};
+static const hsize_t H5S_hyper_ones_g[H5S_MAX_RANK] = {
1,1,1,1, 1,1,1,1,
1,1,1,1, 1,1,1,1,
1,1,1,1, 1,1,1,1,
- 1,1,1,1, 1,1,1,1,1};
+ 1,1,1,1, 1,1,1,1};
/* Declare a free list to manage the H5S_hyper_sel_t struct */
H5FL_DEFINE_STATIC(H5S_hyper_sel_t);
@@ -170,12 +293,18 @@ H5FL_DEFINE_STATIC(H5S_hyper_sel_t);
/* Declare a free list to manage the H5S_hyper_span_t struct */
H5FL_DEFINE_STATIC(H5S_hyper_span_t);
-/* Declare a free list to manage the H5S_hyper_span_info_t struct */
-H5FL_DEFINE_STATIC(H5S_hyper_span_info_t);
+/* Declare a free list to manage the H5S_hyper_span_info_t + hsize_t array struct */
+H5FL_BARR_DEFINE_STATIC(H5S_hyper_span_info_t, hbounds_t, H5S_MAX_RANK * 2);
/* Declare extern free list to manage the H5S_sel_iter_t struct */
H5FL_EXTERN(H5S_sel_iter_t);
+/* Current operation generation */
+/* (Start with '1' to avoid clashing with '0' value in newly allocated structs) */
+static uint64_t H5S_hyper_op_gen_g = 1;
+
+
+/* Uncomment this, to provide the debugging routines for printing selection info */
/* #define H5S_HYPER_DEBUG */
#ifdef H5S_HYPER_DEBUG
static herr_t
@@ -184,9 +313,9 @@ H5S__hyper_print_spans_helper(FILE *f, const H5S_hyper_span_t *span, unsigned de
FUNC_ENTER_STATIC_NOERR
while(span) {
- HDfprintf(f,"%s: depth=%u, span=%p, (%Hu, %Hu), nelem=%Hu, pstride=%Hu\n", FUNC, depth, span, span->low, span->high, span->nelem, span->pstride);
- if(span->down && span->down->head) {
- HDfprintf(f,"%s: spans=%p, count=%u, scratch=%p, head=%p\n", FUNC, span->down, span->down->count, span->down->scratch, span->down->head);
+ HDfprintf(f,"%s: %*sdepth=%u, span=%p, (%Hu, %Hu), next=%p\n", FUNC, depth * 2, "", depth, span, span->low, span->high, span->next);
+ if(span->down) {
+ HDfprintf(f,"%s: %*sspans=%p, count=%u, bounds[0]={%Hu, %Hu}, head=%p\n", FUNC, (depth + 1) * 2, "", span->down, span->down->count, span->down->low_bounds[0], span->down->high_bounds[0], span->down->head);
H5S__hyper_print_spans_helper(f, span->down->head, depth + 1);
} /* end if */
span = span->next;
@@ -201,7 +330,7 @@ H5S__hyper_print_spans(FILE *f, const H5S_hyper_span_info_t *span_lst)
FUNC_ENTER_STATIC_NOERR
if(span_lst != NULL) {
- HDfprintf(f, "%s: spans=%p, count=%u, scratch=%p, head=%p\n", FUNC, span_lst, span_lst->count, span_lst->scratch, span_lst->head);
+ HDfprintf(f, "%s: spans=%p, count=%u, bounds[0]={%Hu, %Hu}, head=%p\n", FUNC, span_lst, span_lst->count, span_lst->low_bounds[0], span_lst->high_bounds[0], span_lst->head);
H5S__hyper_print_spans_helper(f, span_lst->head, 0);
} /* end if */
@@ -250,25 +379,194 @@ H5S__hyper_print_diminfo(FILE *f, const H5S_t *space)
{
FUNC_ENTER_STATIC_NOERR
- H5S__hyper_print_diminfo_helper(f, "opt_diminfo", space->extent.rank, space->select.sel_info.hslab->opt_diminfo);
- H5S__hyper_print_diminfo_helper(f, "app_diminfo", space->extent.rank, space->select.sel_info.hslab->app_diminfo);
+ H5S__hyper_print_diminfo_helper(f, "diminfo.opt", space->extent.rank, space->select.sel_info.hslab->diminfo.opt);
+ H5S__hyper_print_diminfo_helper(f, "diminfo.app", space->extent.rank, space->select.sel_info.hslab->diminfo.app);
FUNC_LEAVE_NOAPI(SUCCEED)
}
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S__hyper_print_spans_dfs
+ PURPOSE
+ Output the span elements for one span list in depth-first order
+ USAGE
+ herr_t H5S__hyper_print_spans_dfs(f, span_lst, depth)
+ FILE *f; IN: the file to output
+ const H5S_hyper_span_info_t *span_lst; IN: the span list to output
+ unsigned depth; IN: the level of this span list
+ RETURNS
+ non-negative on success, negative on failure
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+static herr_t
+H5S__hyper_print_spans_dfs(FILE *f, const H5S_hyper_span_info_t *span_lst,
+ unsigned depth, unsigned dims)
+{
+ H5S_hyper_span_t *actual_tail = NULL;
+ H5S_hyper_span_t *cur_elem;
+ unsigned num_elems = 0;
+ unsigned u, elem_idx;
+
+ FUNC_ENTER_STATIC_NOERR
+
+ /* get the actual tail from head */
+ cur_elem = span_lst->head;
+ HDassert(cur_elem); /* at least 1 element */
+ while(cur_elem) {
+ actual_tail = cur_elem;
+ cur_elem = cur_elem->next;
+ num_elems++;
+ } /* end while */
+
+ for(u = 0; u < depth; u++)
+ HDfprintf(f, "\t");
+ HDfprintf(f, "DIM[%u]: ref_count=%u, #elems=%u, head=%p, tail=%p, actual_tail=%p, matched=%t\n", depth,
+ span_lst->count, num_elems, span_lst->head,
+ span_lst->tail, actual_tail, (span_lst->tail == actual_tail));
+
+ for(u = 0; u < depth; u++)
+ HDfprintf(f, "\t");
+ HDfprintf(f, "low_bounds=[");
+ for(u = 0; u < dims - 1; u++)
+ HDfprintf(f, "%llu,", span_lst->low_bounds[u]);
+ HDfprintf(f, "%llu]\n", span_lst->low_bounds[dims - 1]);
+
+ for(u = 0; u < depth; u++)
+ HDfprintf(f, "\t");
+ HDfprintf(f, "high_bounds=[");
+ for(u = 0; u < dims - 1; u++)
+ HDfprintf(f, "%llu,", span_lst->high_bounds[u]);
+ HDfprintf(f, "%llu]\n", span_lst->high_bounds[dims - 1]);
+
+ cur_elem = span_lst->head;
+ elem_idx = 0;
+ while(cur_elem) {
+ for(u = 0; u < depth; u++)
+ HDfprintf(f, "\t");
+ HDfprintf(f, "ELEM[%u]: ptr=%p, low=%Hu, high=%Hu, down=%p\n",
+ elem_idx++, cur_elem, cur_elem->low, cur_elem->high, cur_elem->down);
+ if(cur_elem->down)
+ H5S__hyper_print_spans_dfs(f, cur_elem->down, depth + 1, dims);
+ cur_elem = cur_elem->next;
+ } /* end while */
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5S__hyper_print_spans_dfs() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S__hyper_print_space_dfs
+ PURPOSE
+ Output the span elements for one hyperslab selection space in depth-first order
+ USAGE
+ herr_t H5S__hyper_print_space_dfs(f, space)
+ FILE *f; IN: the file to output
+ const H5S_t *space; IN: the selection space to output
+ RETURNS
+ non-negative on success, negative on failure
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+static herr_t
+H5S__hyper_print_space_dfs(FILE *f, const H5S_t *space)
+{
+ const H5S_hyper_sel_t *hslab = space->select.sel_info.hslab;
+ const unsigned dims = space->extent.rank;
+ unsigned u;
+
+ FUNC_ENTER_STATIC_NOERR
+
+ HDassert(hslab);
+
+ HDfprintf(f, "=======================\n");
+ HDfprintf(f, "SPACE: span_lst=%p, #dims=%u, offset_changed=%d\n", hslab->span_lst, dims, space->select.offset_changed);
+
+ HDfprintf(f, " offset=[");
+ for(u = 0; u < dims - 1; u++)
+ HDfprintf(f, "%lld,", space->select.offset[u]);
+ HDfprintf(f, "%lld]\n", space->select.offset[dims - 1]);
+
+ HDfprintf(f, " low_bounds=[");
+ if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) {
+ for(u = 0; u < dims - 1; u++)
+ HDfprintf(f, "%llu,", space->select.sel_info.hslab->diminfo.low_bounds[u]);
+ HDfprintf(f, "%llu]\n", space->select.sel_info.hslab->diminfo.low_bounds[dims - 1]);
+ } /* end if */
+ else {
+ for(u = 0; u < dims - 1; u++)
+ HDfprintf(f, "%llu,", space->select.sel_info.hslab->span_lst->low_bounds[u]);
+ HDfprintf(f, "%llu]\n", space->select.sel_info.hslab->span_lst->low_bounds[dims - 1]);
+ } /* end else */
+
+ HDfprintf(f, " high_bounds=[");
+ if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) {
+ for(u = 0; u < dims - 1; u++)
+ HDfprintf(f, "%llu,", space->select.sel_info.hslab->diminfo.high_bounds[u]);
+ HDfprintf(f, "%llu]\n", space->select.sel_info.hslab->diminfo.high_bounds[dims - 1]);
+ } /* end if */
+ else {
+ for(u = 0; u < dims - 1; u++)
+ HDfprintf(f, "%llu,", space->select.sel_info.hslab->span_lst->high_bounds[u]);
+ HDfprintf(f, "%llu]\n", space->select.sel_info.hslab->span_lst->high_bounds[dims - 1]);
+ } /* end else */
+
+ /* Print out diminfo, if it's valid */
+ if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES)
+ H5S__hyper_print_diminfo(f, space);
+
+ /* Start print out the highest-order of dimension */
+ if(hslab->span_lst)
+ H5S__hyper_print_spans_dfs(f, hslab->span_lst, 0, dims);
+ HDfprintf(f, "=======================\n\n");
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5S__hyper_print_space_dfs() */
#endif /* H5S_HYPER_DEBUG */
/*-------------------------------------------------------------------------
+ * Function: H5S__hyper_get_op_gen
+ *
+ * Purpose: Acquire a unique operation generation value
+ *
+ * Return: Operation generation value (can't fail)
+ *
+ * Programmer: Quincey Koziol
+ * Saturday, January 19, 2019
+ *
+ * Notes: Assumes that a 64-bit value will not wrap around during
+ * the lifespan of the process.
+ *
+ *-------------------------------------------------------------------------
+ */
+uint64_t
+H5S__hyper_get_op_gen(void)
+{
+ FUNC_ENTER_PACKAGE_NOERR
+
+ FUNC_LEAVE_NOAPI(H5S_hyper_op_gen_g++);
+} /* end H5S__hyper_op_gen() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5S__hyper_iter_init
*
- * Purpose: Initializes iteration information for hyperslab span tree selection.
+ * Purpose: Initializes iteration information for hyperslab selection.
*
- * Return: non-negative on success, negative on failure.
+ * Return: Non-negative on success, negative on failure.
*
* Programmer: Quincey Koziol
* Saturday, February 24, 2001
*
- * Notes: If the 'elmt_size' parameter is set to zero, the regular
+ * Notes: If the 'iter->elmt_size' field is set to zero, the regular
* hyperslab selection iterator will not be 'flattened'. This
* is used by the H5S_select_shape_same() code to avoid changing
* the rank and appearance of the selection.
@@ -276,37 +574,47 @@ H5S__hyper_print_diminfo(FILE *f, const H5S_t *space)
*-------------------------------------------------------------------------
*/
static herr_t
-H5S__hyper_iter_init(H5S_sel_iter_t *iter, const H5S_t *space)
+H5S__hyper_iter_init(const H5S_t *space, H5S_sel_iter_t *iter)
{
- unsigned rank; /* Dataspace's dimension rank */
- unsigned u; /* Index variable */
+ hsize_t *slab_size; /* Pointer to the dataspace dimensions to use for calc. slab */
+ hsize_t acc; /* Accumulator for computing cumulative sizes */
+ unsigned slab_dim; /* Rank of the fastest changing dimension for calc. slab */
+ unsigned rank; /* Dataspace's dimension rank */
+ unsigned u; /* Index variable */
+ int i; /* Index variable */
+ herr_t ret_value = SUCCEED; /* return value */
- FUNC_ENTER_STATIC_NOERR
+ FUNC_ENTER_STATIC
/* Check args */
HDassert(space && H5S_SEL_HYPERSLABS == H5S_GET_SELECT_TYPE(space));
HDassert(iter);
HDassert(space->select.sel_info.hslab->unlim_dim < 0);
- /* Initialize the number of points to iterate over */
- iter->elmt_left = space->select.num_elem;
+ /* Initialize the hyperslab iterator's rank */
iter->u.hyp.iter_rank = 0;
/* Get the rank of the dataspace */
- rank = space->extent.rank;
+ rank = iter->rank;
+
+ /* Attempt to rebuild diminfo if it is invalid and has not been confirmed
+ * to be impossible.
+ */
+ if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_NO)
+ H5S__hyper_rebuild((H5S_t *)space); /* Casting away const OK -NAF */
/* Check for the special case of just one H5Sselect_hyperslab call made */
- if(space->select.sel_info.hslab->diminfo_valid) {
+ if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) {
/* Initialize the information needed for regular hyperslab I/O */
const H5S_hyper_dim_t *tdiminfo; /* Temporary pointer to diminfo information */
const hsize_t *mem_size; /* Temporary pointer to dataspace extent's dimension sizes */
unsigned cont_dim = 0; /* # of contiguous dimensions */
/* Set the temporary pointer to the dimension information */
- tdiminfo = space->select.sel_info.hslab->opt_diminfo;
+ tdiminfo = space->select.sel_info.hslab->diminfo.opt;
/* Set the temporary pointer to the dataspace extent's dimension sizes */
- mem_size = space->extent.size;
+ mem_size = iter->dims;
/*
* For a regular hyperslab to be contiguous up to some dimension, it
@@ -333,11 +641,9 @@ H5S__hyper_iter_init(H5S_sel_iter_t *iter, const H5S_t *space)
/* Check if the regular selection can be "flattened" */
if(cont_dim > 0) {
- hsize_t acc; /* Accumulator for "flattened" dimension's sizes */
- unsigned last_dim_flattened = 1; /* Flag to indicate that the last dimension was flattened */
+ hbool_t last_dim_flattened = TRUE; /* Flag to indicate that the last dimension was flattened */
unsigned flat_rank = rank-cont_dim; /* Number of dimensions after flattening */
unsigned curr_dim; /* Current dimension */
- int i; /* Index variable */
/* Set the iterator's rank to the contiguous dimensions */
iter->u.hyp.iter_rank = flat_rank;
@@ -351,7 +657,7 @@ H5S__hyper_iter_init(H5S_sel_iter_t *iter, const H5S_t *space)
acc *= mem_size[i];
/* Indicate that the dimension was flattened */
- last_dim_flattened = 1;
+ last_dim_flattened = TRUE;
} /* end if */
else {
if(last_dim_flattened) {
@@ -366,10 +672,10 @@ H5S__hyper_iter_init(H5S_sel_iter_t *iter, const H5S_t *space)
iter->u.hyp.diminfo[curr_dim].count = tdiminfo[i].count;
iter->u.hyp.diminfo[curr_dim].block = tdiminfo[i].block * acc;
iter->u.hyp.size[curr_dim] = mem_size[i] * acc;
- iter->u.hyp.sel_off[curr_dim] = space->select.offset[i] * (hssize_t)acc;
+ iter->u.hyp.sel_off[curr_dim] = iter->sel_off[i] * (hssize_t)acc;
/* Reset the "last dim flattened" flag to avoid flattened any further dimensions */
- last_dim_flattened = 0;
+ last_dim_flattened = FALSE;
/* Reset the "accumulator" for possible further dimension flattening */
acc = 1;
@@ -381,7 +687,7 @@ H5S__hyper_iter_init(H5S_sel_iter_t *iter, const H5S_t *space)
iter->u.hyp.diminfo[curr_dim].count = tdiminfo[i].count;
iter->u.hyp.diminfo[curr_dim].block = tdiminfo[i].block;
iter->u.hyp.size[curr_dim] = mem_size[i];
- iter->u.hyp.sel_off[curr_dim] = space->select.offset[i];
+ iter->u.hyp.sel_off[curr_dim] = iter->sel_off[i];
} /* end else */
/* Decrement "current" flattened dimension */
@@ -392,20 +698,23 @@ H5S__hyper_iter_init(H5S_sel_iter_t *iter, const H5S_t *space)
/* Initialize "flattened" iterator offset to initial location and dataspace extent and selection information to correct values */
for(u = 0; u < flat_rank; u++)
iter->u.hyp.off[u] = iter->u.hyp.diminfo[u].start;
+
+ /* Set up information for computing slab sizes */
+ slab_dim = iter->u.hyp.iter_rank - 1;
+ slab_size = iter->u.hyp.size;
} /* end if */
else {
+ /* Make local copy of the regular selection information */
+ HDcompile_assert(sizeof(iter->u.hyp.diminfo) == sizeof(space->select.sel_info.hslab->diminfo.opt));
+ H5MM_memcpy(iter->u.hyp.diminfo, tdiminfo, sizeof(iter->u.hyp.diminfo));
+
/* Initialize position to initial location */
- /* Also make local copy of the regular selection information */
- for(u = 0; u < rank; u++) {
- /* Regular selection information */
- iter->u.hyp.diminfo[u].start = tdiminfo[u].start;
- iter->u.hyp.diminfo[u].stride = tdiminfo[u].stride;
- iter->u.hyp.diminfo[u].count = tdiminfo[u].count;
- iter->u.hyp.diminfo[u].block = tdiminfo[u].block;
-
- /* Position information */
+ for(u = 0; u < rank; u++)
iter->u.hyp.off[u] = tdiminfo[u].start;
- } /* end if */
+
+ /* Set up information for computing slab sizes */
+ slab_dim = iter->rank - 1;
+ slab_size = iter->dims;
} /* end else */
/* Flag the diminfo information as valid in the iterator */
@@ -414,16 +723,30 @@ H5S__hyper_iter_init(H5S_sel_iter_t *iter, const H5S_t *space)
/* Initialize irregular region information also (for release) */
iter->u.hyp.spans = NULL;
} /* end if */
- else {
+ else { /* Initialize the information needed for non-regular hyperslab I/O */
H5S_hyper_span_info_t *spans; /* Pointer to hyperslab span info node */
-/* Initialize the information needed for non-regular hyperslab I/O */
- HDassert(space->select.sel_info.hslab->span_lst);
- /* Make a copy of the span tree to iterate over */
- iter->u.hyp.spans = H5S__hyper_copy_span(space->select.sel_info.hslab->span_lst);
-
- /* Set the nelem & pstride values according to the element size */
- H5S__hyper_span_precompute(iter->u.hyp.spans, iter->elmt_size);
+ /* If this iterator is created from an API call, by default we clone the
+ * selection now, as the dataspace could be modified or go out of scope.
+ *
+ * However, if the H5S_SEL_ITER_SHARE_WITH_DATASPACE flag is given,
+ * the selection is shared between the selection iterator and the
+ * dataspace. In this case, the application _must_not_ modify or
+ * close the dataspace that the iterator is operating on, or undefined
+ * behavior will occur.
+ */
+ if((iter->flags & H5S_SEL_ITER_API_CALL) &&
+ !(iter->flags & H5S_SEL_ITER_SHARE_WITH_DATASPACE)) {
+ /* Copy the span tree */
+ if(NULL == (iter->u.hyp.spans = H5S__hyper_copy_span(space->select.sel_info.hslab->span_lst, space->extent.rank)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy span tree")
+ } /* end if */
+ else {
+ /* Share the source dataspace's span tree by incrementing the reference count on it */
+ HDassert(space->select.sel_info.hslab->span_lst);
+ iter->u.hyp.spans = space->select.sel_info.hslab->span_lst;
+ iter->u.hyp.spans->count++;
+ } /* end else */
/* Initialize the starting span_info's and spans */
spans = iter->u.hyp.spans;
@@ -442,14 +765,33 @@ H5S__hyper_iter_init(H5S_sel_iter_t *iter, const H5S_t *space)
spans = spans->head->down;
} /* end for */
+ /* Set up information for computing slab sizes */
+ slab_dim = iter->rank - 1;
+ slab_size = iter->dims;
+
/* Flag the diminfo information as not valid in the iterator */
iter->u.hyp.diminfo_valid = FALSE;
} /* end else */
+ /* Compute the cumulative size of dataspace dimensions */
+ for(i = (int)slab_dim, acc = iter->elmt_size; i >= 0; i--) {
+ iter->u.hyp.slab[i] = acc;
+ acc *= slab_size[i];
+ } /* end for */
+
+ /* Initialize more information for irregular hyperslab selections */
+ if(!iter->u.hyp.diminfo_valid) {
+ /* Set the offset of the first element iterated on, in each dimension */
+ for(u = 0; u < rank; u++)
+ /* Compute the sequential element offset */
+ iter->u.hyp.loc_off[u] = ((hsize_t)((hssize_t)iter->u.hyp.off[u] + iter->sel_off[u])) * iter->u.hyp.slab[u];
+ } /* end if */
+
/* Initialize type of selection iterator */
iter->type = H5S_sel_iter_hyper;
- FUNC_LEAVE_NOAPI(SUCCEED)
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5S__hyper_iter_init() */
@@ -459,7 +801,7 @@ H5S__hyper_iter_init(H5S_sel_iter_t *iter, const H5S_t *space)
* Purpose: Retrieve the current coordinates of iterator for current
* selection
*
- * Return: non-negative on success, negative on failure
+ * Return: Non-negative on success, negative on failure
*
* Programmer: Quincey Koziol
* Tuesday, April 22, 2003
@@ -529,10 +871,10 @@ H5S__hyper_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords)
HDassert(v < 0);
} /* end if */
else
- HDmemcpy(coords, iter->u.hyp.off, sizeof(hsize_t) * iter->rank);
+ H5MM_memcpy(coords, iter->u.hyp.off, sizeof(hsize_t) * iter->rank);
} /* end if */
else
- HDmemcpy(coords, iter->u.hyp.off, sizeof(hsize_t) * iter->rank);
+ H5MM_memcpy(coords, iter->u.hyp.off, sizeof(hsize_t) * iter->rank);
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5S__hyper_iter_coords() */
@@ -544,7 +886,7 @@ H5S__hyper_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords)
* Purpose: Retrieve the current block of iterator for current
* selection
*
- * Return: non-negative on success, negative on failure
+ * Return: Non-negative on success, negative on failure
*
* Programmer: Quincey Koziol
* Monday, June 2, 2003
@@ -570,20 +912,18 @@ H5S__hyper_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end)
/* Check for a single "regular" hyperslab */
if(iter->u.hyp.diminfo_valid) {
- /* Compute the end of the block */
+ /* Copy the start and compute the end of the block */
for(u = 0; u < iter->rank; u++) {
start[u] = iter->u.hyp.off[u];
end[u] = (start[u] + iter->u.hyp.diminfo[u].block) - 1;
} /* end for */
} /* end if */
else {
- /* Copy the start of the block */
- for(u = 0; u < iter->rank; u++)
+ /* Copy the start & end of the block */
+ for(u = 0; u < iter->rank; u++) {
start[u] = iter->u.hyp.span[u]->low;
-
- /* Copy the end of the block */
- for(u = 0; u < iter->rank; u++)
end[u] = iter->u.hyp.span[u]->high;
+ } /* end for */
} /* end else */
FUNC_LEAVE_NOAPI(SUCCEED)
@@ -595,7 +935,7 @@ H5S__hyper_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end)
*
* Purpose: Return number of elements left to process in iterator
*
- * Return: non-negative number of elements on success, zero on failure
+ * Return: Non-negative number of elements on success, zero on failure
*
* Programmer: Quincey Koziol
* Tuesday, June 16, 1998
@@ -631,7 +971,7 @@ H5S__hyper_iter_nelmts(const H5S_sel_iter_t *iter)
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-static htri_t
+static H5_ATTR_PURE htri_t
H5S__hyper_iter_has_next_block(const H5S_sel_iter_t *iter)
{
unsigned u; /* Local index variable */
@@ -689,7 +1029,7 @@ H5S__hyper_iter_next(H5S_sel_iter_t *iter, size_t nelem)
{
unsigned ndims; /* Number of dimensions of dataset */
int fast_dim; /* Rank of the fastest changing dimension for the dataspace */
- unsigned i; /* Counters */
+ unsigned u; /* Counters */
FUNC_ENTER_STATIC_NOERR
@@ -697,19 +1037,17 @@ H5S__hyper_iter_next(H5S_sel_iter_t *iter, size_t nelem)
/* (i.e. a regular hyperslab selection */
if(iter->u.hyp.diminfo_valid) {
const H5S_hyper_dim_t *tdiminfo; /* Temporary pointer to diminfo information */
- hsize_t iter_offset[H5O_LAYOUT_NDIMS];
- hsize_t iter_count[H5O_LAYOUT_NDIMS];
+ hsize_t iter_offset[H5S_MAX_RANK];
+ hsize_t iter_count[H5S_MAX_RANK];
int temp_dim; /* Temporary rank holder */
/* Check if this is a "flattened" regular hyperslab selection */
- if(iter->u.hyp.iter_rank != 0 && iter->u.hyp.iter_rank < iter->rank) {
+ if(iter->u.hyp.iter_rank != 0 && iter->u.hyp.iter_rank < iter->rank)
/* Set the aliases for the dimension rank */
ndims = iter->u.hyp.iter_rank;
- } /* end if */
- else {
+ else
/* Set the aliases for the dimension rank */
ndims = iter->rank;
- } /* end else */
/* Set the fastest dimension rank */
fast_dim = (int)ndims - 1;
@@ -718,14 +1056,14 @@ H5S__hyper_iter_next(H5S_sel_iter_t *iter, size_t nelem)
tdiminfo = iter->u.hyp.diminfo;
/* Calculate the offset and block count for each dimension */
- for(i = 0; i < ndims; i++) {
- if(tdiminfo[i].count == 1) {
- iter_offset[i] = iter->u.hyp.off[i] - tdiminfo[i].start;
- iter_count[i] = 0;
+ for(u = 0; u < ndims; u++) {
+ if(tdiminfo[u].count == 1) {
+ iter_offset[u] = iter->u.hyp.off[u] - tdiminfo[u].start;
+ iter_count[u] = 0;
} /* end if */
else {
- iter_offset[i] = (iter->u.hyp.off[i] - tdiminfo[i].start) % tdiminfo[i].stride;
- iter_count[i] = (iter->u.hyp.off[i] - tdiminfo[i].start) / tdiminfo[i].stride;
+ iter_offset[u] = (iter->u.hyp.off[u] - tdiminfo[u].start) % tdiminfo[u].stride;
+ iter_count[u] = (iter->u.hyp.off[u] - tdiminfo[u].start) / tdiminfo[u].stride;
} /* end else */
} /* end for */
@@ -750,10 +1088,9 @@ H5S__hyper_iter_next(H5S_sel_iter_t *iter, size_t nelem)
/* Decrement the number of elements advanced */
nelem -= actual_elem;
} /* end if */
- else {
+ else
/* Move to the next row in the current dimension */
iter_offset[temp_dim]++;
- } /* end else */
/* If this block is still in the range of blocks to output for the dimension, break out of loop */
if(iter_offset[temp_dim] < tdiminfo[temp_dim].block)
@@ -776,8 +1113,8 @@ H5S__hyper_iter_next(H5S_sel_iter_t *iter, size_t nelem)
} /* end while */
/* Translate current iter_offset and iter_count into iterator position */
- for(i = 0; i < ndims; i++)
- iter->u.hyp.off[i] = tdiminfo[i].start + (tdiminfo[i].stride * iter_count[i]) + iter_offset[i];
+ for(u = 0; u < ndims; u++)
+ iter->u.hyp.off[u] = tdiminfo[u].start + (tdiminfo[u].stride * iter_count[u]) + iter_offset[u];
} /* end if */
/* Must be an irregular hyperslab selection */
else {
@@ -821,15 +1158,13 @@ H5S__hyper_iter_next(H5S_sel_iter_t *iter, size_t nelem)
/* Decrement the number of elements advanced */
nelem -= actual_elem;
} /* end if */
- else {
+ else
/* Move to the next row in the current dimension */
abs_arr[curr_dim]++;
- } /* end else */
/* Check if we are still within the span */
- if(abs_arr[curr_dim] <= curr_span->high) {
+ if(abs_arr[curr_dim] <= curr_span->high)
break;
- } /* end if */
/* If we walked off that span, advance to the next span */
else {
/* Advance span in this dimension */
@@ -845,10 +1180,9 @@ H5S__hyper_iter_next(H5S_sel_iter_t *iter, size_t nelem)
break;
} /* end if */
- else {
+ else
/* If we finished the span list in this dimension, decrement the dimension worked on and loop again */
curr_dim--;
- } /* end else */
} /* end else */
} /* end while */
@@ -907,22 +1241,20 @@ H5S__hyper_iter_next_block(H5S_sel_iter_t *iter)
FUNC_ENTER_STATIC_NOERR
/* Check for the special case of just one H5Sselect_hyperslab call made */
- /* (i.e. a regular hyperslab selection */
+ /* (i.e. a regular hyperslab selection) */
if(iter->u.hyp.diminfo_valid) {
const H5S_hyper_dim_t *tdiminfo; /* Temporary pointer to diminfo information */
- hsize_t iter_offset[H5O_LAYOUT_NDIMS];
- hsize_t iter_count[H5O_LAYOUT_NDIMS];
+ hsize_t iter_offset[H5S_MAX_RANK];
+ hsize_t iter_count[H5S_MAX_RANK];
int temp_dim; /* Temporary rank holder */
/* Check if this is a "flattened" regular hyperslab selection */
- if(iter->u.hyp.iter_rank != 0 && iter->u.hyp.iter_rank < iter->rank) {
+ if(iter->u.hyp.iter_rank != 0 && iter->u.hyp.iter_rank < iter->rank)
/* Set the aliases for the dimension rank */
ndims = iter->u.hyp.iter_rank;
- } /* end if */
- else {
+ else
/* Set the aliases for the dimension rank */
ndims = iter->rank;
- } /* end else */
/* Set the fastest dimension rank */
fast_dim = (int)ndims - 1;
@@ -945,14 +1277,12 @@ H5S__hyper_iter_next_block(H5S_sel_iter_t *iter)
/* Advance one block */
temp_dim = fast_dim; /* Start with the fastest changing dimension */
while(temp_dim >= 0) {
- if(temp_dim == fast_dim) {
+ if(temp_dim == fast_dim)
/* Move iterator over current block */
iter_offset[temp_dim] += tdiminfo[temp_dim].block;
- } /* end if */
- else {
+ else
/* Move to the next row in the current dimension */
iter_offset[temp_dim]++;
- } /* end else */
/* If this block is still in the range of blocks to output for the dimension, break out of loop */
if(iter_offset[temp_dim] < tdiminfo[temp_dim].block)
@@ -1001,19 +1331,16 @@ H5S__hyper_iter_next_block(H5S_sel_iter_t *iter)
curr_span = ispan[curr_dim];
/* Increment absolute position */
- if(curr_dim == fast_dim) {
+ if(curr_dim == fast_dim)
/* Move the iterator over rest of element in span */
abs_arr[curr_dim] = curr_span->high + 1;
- } /* end if */
- else {
+ else
/* Move to the next row in the current dimension */
abs_arr[curr_dim]++;
- } /* end else */
/* Check if we are still within the span */
- if(abs_arr[curr_dim] <= curr_span->high) {
+ if(abs_arr[curr_dim] <= curr_span->high)
break;
- } /* end if */
/* If we walked off that span, advance to the next span */
else {
/* Advance span in this dimension */
@@ -1029,10 +1356,9 @@ H5S__hyper_iter_next_block(H5S_sel_iter_t *iter)
break;
} /* end if */
- else {
+ else
/* If we finished the span list in this dimension, decrement the dimension worked on and loop again */
curr_dim--;
- } /* end else */
} /* end else */
} /* end while */
@@ -1063,231 +1389,1467 @@ H5S__hyper_iter_next_block(H5S_sel_iter_t *iter)
} /* end else */
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* end H5S__hyper_iter_next() */
+} /* end H5S__hyper_iter_next_block() */
/*--------------------------------------------------------------------------
NAME
- H5S__hyper_iter_release
+ H5S__hyper_iter_get_seq_list_gen
PURPOSE
- Release hyperslab selection iterator information for a dataspace
+ Create a list of offsets & lengths for a selection
USAGE
- herr_t H5S__hyper_iter_release(iter)
- H5S_sel_iter_t *iter; IN: Pointer to selection iterator
+ herr_t H5S__hyper_iter_get_seq_list_gen(iter,maxseq,maxelem,nseq,nelem,off,len)
+ H5S_sel_iter_t *iter; IN/OUT: Selection iterator describing last
+ position of interest in selection.
+ size_t maxseq; IN: Maximum number of sequences to generate
+ size_t maxelem; IN: Maximum number of elements to include in the
+ generated sequences
+ size_t *nseq; OUT: Actual number of sequences generated
+ size_t *nelem; OUT: Actual number of elements in sequences generated
+ hsize_t *off; OUT: Array of offsets
+ size_t *len; OUT: Array of lengths
RETURNS
- Non-negative on success/Negative on failure
+ Non-negative on success/Negative on failure.
DESCRIPTION
- Releases all information for a dataspace hyperslab selection iterator
+ Use the selection in the dataspace to generate a list of byte offsets and
+ lengths for the region(s) selected. Start/Restart from the position in the
+ ITER parameter. The number of sequences generated is limited by the MAXSEQ
+ parameter and the number of sequences actually generated is stored in the
+ NSEQ parameter.
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
-H5S__hyper_iter_release(H5S_sel_iter_t *iter)
+H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelem,
+ size_t *nseq, size_t *nelem, hsize_t *off, size_t *len)
{
+ H5S_hyper_span_t *curr_span; /* Current hyperslab span node */
+ H5S_hyper_span_t **ispan; /* Iterator's hyperslab span nodes */
+ hsize_t *slab; /* Cumulative size of each dimension in bytes */
+ hsize_t loc_off; /* Byte offset in the dataspace */
+ hsize_t last_span_end = 0; /* The offset of the end of the last span */
+ hsize_t *abs_arr; /* Absolute hyperslab span position, in elements */
+ hsize_t *loc_arr; /* Byte offset of hyperslab span position within buffer */
+ const hssize_t *sel_off; /* Offset within the dataspace extent */
+ size_t span_elmts = 0; /* Number of elements to actually use for this span */
+ size_t span_size = 0; /* Number of bytes in current span to actually process */
+ size_t io_left; /* Initial number of elements to process */
+ size_t io_elmts_left; /* Number of elements left to process */
+ size_t io_used; /* Number of elements processed */
+ size_t curr_seq = 0; /* Number of sequence/offsets stored in the arrays */
+ size_t elem_size; /* Size of each element iterating over */
+ unsigned ndims; /* Number of dimensions of dataset */
+ unsigned fast_dim; /* Rank of the fastest changing dimension for the dataspace */
+ int curr_dim; /* Current dimension being operated on */
+ unsigned u; /* Index variable */
+
FUNC_ENTER_STATIC_NOERR
/* Check args */
HDassert(iter);
+ HDassert(maxseq > 0);
+ HDassert(maxelem > 0);
+ HDassert(nseq);
+ HDassert(nelem);
+ HDassert(off);
+ HDassert(len);
-/* Release the information needed for non-regular hyperslab I/O */
- /* Free the copy of the selections span tree */
- if(iter->u.hyp.spans != NULL)
- H5S__hyper_free_span_info(iter->u.hyp.spans);
+ /* Set the rank of the fastest changing dimension */
+ ndims = iter->rank;
+ fast_dim = (ndims - 1);
+
+ /* Get the pointers to the current span info and span nodes */
+ curr_span = iter->u.hyp.span[fast_dim];
+ abs_arr = iter->u.hyp.off;
+ loc_arr = iter->u.hyp.loc_off;
+ slab = iter->u.hyp.slab;
+ sel_off = iter->sel_off;
+ ispan = iter->u.hyp.span;
+ elem_size = iter->elmt_size;
+
+ /* Set the amount of elements to perform I/O on, etc. */
+ H5_CHECK_OVERFLOW(iter->elmt_left, hsize_t, size_t);
+ io_elmts_left = io_left = MIN(maxelem, (size_t)iter->elmt_left);
+
+ /* Set the offset of the first element iterated on */
+ for(u = 0, loc_off = 0; u < ndims; u++)
+ loc_off += loc_arr[u];
+
+ /* Take care of any partial spans leftover from previous I/Os */
+ if(abs_arr[fast_dim] != curr_span->low) {
+ /* Finish the span in the fastest changing dimension */
+
+ /* Compute the number of elements to attempt in this span */
+ H5_CHECKED_ASSIGN(span_elmts, size_t, ((curr_span->high - abs_arr[fast_dim]) + 1), hsize_t);
+
+ /* Check number of elements against upper bounds allowed */
+ if(span_elmts > io_elmts_left)
+ span_elmts = io_elmts_left;
+
+ /* Set the span_size, in bytes */
+ span_size = span_elmts * elem_size;
+
+ /* Add the partial span to the list of sequences */
+ off[curr_seq] = loc_off;
+ len[curr_seq] = span_size;
+
+ /* Increment sequence count */
+ curr_seq++;
+
+ /* Set the location of the last span's end */
+ last_span_end = loc_off + span_size;
+
+ /* Decrement I/O left to perform */
+ io_elmts_left -= span_elmts;
+
+ /* Check if we are done */
+ if(io_elmts_left > 0) {
+ /* Move to next span in fastest changing dimension */
+ curr_span = curr_span->next;
+
+ if(NULL != curr_span) {
+ /* Move location offset of destination */
+ loc_off += (curr_span->low - abs_arr[fast_dim]) * elem_size;
+
+ /* Move iterator for fastest changing dimension */
+ abs_arr[fast_dim] = curr_span->low;
+ loc_arr[fast_dim] = ((hsize_t)((hssize_t)curr_span->low + sel_off[fast_dim])) * slab[fast_dim];
+ ispan[fast_dim] = curr_span;
+ } /* end if */
+ } /* end if */
+ else {
+ /* Advance the hyperslab iterator */
+ abs_arr[fast_dim] += span_elmts;
+
+ /* Check if we are still within the span */
+ if(abs_arr[fast_dim] <= curr_span->high) {
+ /* Sanity check */
+ HDassert(ispan[fast_dim] == curr_span);
+
+ /* Update byte offset */
+ loc_arr[fast_dim] += span_size;
+ } /* end if */
+ /* If we walked off that span, advance to the next span */
+ else {
+ /* Advance span in this dimension */
+ curr_span = curr_span->next;
+
+ /* Check if we have a valid span in this dimension still */
+ if(NULL != curr_span) {
+ /* Reset absolute position */
+ abs_arr[fast_dim] = curr_span->low;
+
+ /* Update location offset */
+ loc_arr[fast_dim] = ((hsize_t)((hssize_t)curr_span->low + sel_off[fast_dim])) * slab[fast_dim];
+
+ /* Reset the span in the current dimension */
+ ispan[fast_dim] = curr_span;
+ } /* end if */
+ } /* end else */
+ } /* end else */
+
+ /* Adjust iterator pointers */
+
+ if(NULL == curr_span) {
+/* Same as code in main loop */
+ /* Start at the next fastest dim */
+ curr_dim = (int)(fast_dim - 1);
+
+ /* Work back up through the dimensions */
+ while(curr_dim >= 0) {
+ /* Reset the current span */
+ curr_span = ispan[curr_dim];
+
+ /* Increment absolute position */
+ abs_arr[curr_dim]++;
+
+ /* Check if we are still within the span */
+ if(abs_arr[curr_dim] <= curr_span->high) {
+ /* Update location offset */
+ loc_arr[curr_dim] += slab[curr_dim];
+
+ break;
+ } /* end if */
+ /* If we walked off that span, advance to the next span */
+ else {
+ /* Advance span in this dimension */
+ curr_span = curr_span->next;
+
+ /* Check if we have a valid span in this dimension still */
+ if(NULL != curr_span) {
+ /* Reset the span in the current dimension */
+ ispan[curr_dim] = curr_span;
+
+ /* Reset absolute position */
+ abs_arr[curr_dim] = curr_span->low;
+
+ /* Update byte location */
+ loc_arr[curr_dim] = ((hsize_t)((hssize_t)curr_span->low + sel_off[curr_dim])) * slab[curr_dim];
+
+ break;
+ } /* end if */
+ else
+ /* If we finished the span list in this dimension, decrement the dimension worked on and loop again */
+ curr_dim--;
+ } /* end else */
+ } /* end while */
+
+ /* Check if we have more spans in the tree */
+ if(curr_dim >= 0) {
+ /* Walk back down the iterator positions, resetting them */
+ while((unsigned)curr_dim < fast_dim) {
+ HDassert(curr_span);
+ HDassert(curr_span->down);
+ HDassert(curr_span->down->head);
+
+ /* Increment current dimension */
+ curr_dim++;
+
+ /* Set the new span_info & span for this dimension */
+ ispan[curr_dim] = curr_span->down->head;
+
+ /* Advance span down the tree */
+ curr_span = curr_span->down->head;
+
+ /* Reset the absolute offset for the dim */
+ abs_arr[curr_dim] = curr_span->low;
+
+ /* Update the location offset */
+ loc_arr[curr_dim] = ((hsize_t)((hssize_t)curr_span->low + sel_off[curr_dim])) * slab[curr_dim];
+ } /* end while */
+
+ /* Verify that the curr_span points to the fastest dim */
+ HDassert(curr_span == ispan[fast_dim]);
+
+ /* Reset the buffer offset */
+ for(u = 0, loc_off = 0; u < ndims; u++)
+ loc_off += loc_arr[u];
+ } /* end else */
+ else
+ /* We had better be done with I/O or bad things are going to happen... */
+ HDassert(io_elmts_left == 0);
+ } /* end if */
+ } /* end if */
+
+ /* Perform the I/O on the elements, based on the position of the iterator */
+ while(io_elmts_left > 0 && curr_seq < maxseq) {
+ H5S_hyper_span_t *prev_span; /* Previous hyperslab span node */
+
+ /* Sanity check */
+ HDassert(curr_span);
+
+ /* Set to current span, so the first adjustment to loc_off is 0 */
+ prev_span = curr_span;
+
+ /* Loop over all the spans in the fastest changing dimension */
+ while(curr_span != NULL) {
+ hsize_t nelmts; /* # of elements covered by current span */
+
+ /* Move location offset of current span */
+ loc_off += (curr_span->low - prev_span->low) * elem_size;
+
+ /* Compute the number of elements to attempt in this span */
+ nelmts = (curr_span->high - curr_span->low) + 1;
+ H5_CHECKED_ASSIGN(span_elmts, size_t, nelmts, hsize_t);
+
+ /* Check number of elements against upper bounds allowed */
+ if(span_elmts >= io_elmts_left) {
+ /* Trim the number of elements to output */
+ span_elmts = io_elmts_left;
+ span_size = span_elmts * elem_size;
+ io_elmts_left = 0;
+
+/* COMMON */
+ /* Store the I/O information for the span */
+
+ /* Check if this is appending onto previous sequence */
+ if(curr_seq > 0 && last_span_end == loc_off)
+ len[curr_seq - 1] += span_size;
+ else {
+ off[curr_seq] = loc_off;
+ len[curr_seq] = span_size;
+
+ /* Increment the number of sequences in arrays */
+ curr_seq++;
+ } /* end else */
+/* end COMMON */
+
+ /* Break out now, we are finished with I/O */
+ break;
+ } /* end if */
+ else {
+ /* Decrement I/O left to perform */
+ span_size = span_elmts * elem_size;
+ io_elmts_left -= span_elmts;
+
+/* COMMON */
+ /* Store the I/O information for the span */
+
+ /* Check if this is appending onto previous sequence */
+ if(curr_seq > 0 && last_span_end == loc_off)
+ len[curr_seq - 1] += span_size;
+ else {
+ off[curr_seq] = loc_off;
+ len[curr_seq] = span_size;
+
+ /* Increment the number of sequences in arrays */
+ curr_seq++;
+ } /* end else */
+/* end COMMON */
+
+ /* If the sequence & offset arrays are full, do what? */
+ if(curr_seq >= maxseq)
+ /* Break out now, we are finished with sequences */
+ break;
+ } /* end else */
+
+ /* Set the location of the last span's end */
+ last_span_end = loc_off + span_size;
+
+ /* Move to next span in fastest changing dimension */
+ prev_span = curr_span;
+ curr_span = curr_span->next;
+ } /* end while */
+
+ /* Check if we are done */
+ if(io_elmts_left == 0 || curr_seq >= maxseq) {
+ /* Sanity checks */
+ HDassert(curr_span);
+
+ /* Update absolute position */
+ abs_arr[fast_dim] = curr_span->low + span_elmts;
+
+ /* Check if we are still within the span */
+ if(abs_arr[fast_dim] <= curr_span->high) {
+ /* Reset the span for the fast dimension */
+ ispan[fast_dim] = curr_span;
+
+ /* Update location offset */
+ loc_arr[fast_dim] = ((hsize_t)((hssize_t)curr_span->low + (hssize_t)span_elmts + sel_off[fast_dim])) * slab[fast_dim];
+
+ break;
+ } /* end if */
+ /* If we walked off that span, advance to the next span */
+ else {
+ /* Advance span in this dimension */
+ curr_span = curr_span->next;
+
+ /* Check if we have a valid span in this dimension still */
+ if(curr_span != NULL) {
+ /* Reset absolute position */
+ abs_arr[fast_dim] = curr_span->low;
+ loc_arr[fast_dim] = ((hsize_t)((hssize_t)curr_span->low + sel_off[fast_dim])) * slab[fast_dim];
+ ispan[fast_dim] = curr_span;
+
+ break;
+ } /* end if */
+ } /* end else */
+ } /* end if */
+
+ /* Adjust iterator pointers */
+
+ /* Start at the next fastest dim */
+ curr_dim = (int)(fast_dim - 1);
+
+ /* Work back up through the dimensions */
+ while(curr_dim >= 0) {
+ /* Reset the current span */
+ curr_span = ispan[curr_dim];
+
+ /* Increment absolute position */
+ abs_arr[curr_dim]++;
+
+ /* Check if we are still within the span */
+ if(abs_arr[curr_dim] <= curr_span->high) {
+ /* Update location offset */
+ loc_arr[curr_dim] += slab[curr_dim];
+
+ break;
+ } /* end if */
+ /* If we walked off that span, advance to the next span */
+ else {
+ /* Advance span in this dimension */
+ curr_span = curr_span->next;
+
+ /* Check if we have a valid span in this dimension still */
+ if(curr_span != NULL) {
+ /* Reset the span in the current dimension */
+ ispan[curr_dim] = curr_span;
+
+ /* Reset absolute position */
+ abs_arr[curr_dim] = curr_span->low;
+
+ /* Update location offset */
+ loc_arr[curr_dim] = ((hsize_t)((hssize_t)curr_span->low + sel_off[curr_dim])) * slab[curr_dim];
+
+ break;
+ } /* end if */
+ else
+ /* If we finished the span list in this dimension, decrement the dimension worked on and loop again */
+ curr_dim--;
+ } /* end else */
+ } /* end while */
+
+ /* Check if we are finished with the spans in the tree */
+ if(curr_dim < 0) {
+ /* We had better be done with I/O or bad things are going to happen... */
+ HDassert(io_elmts_left == 0);
+ break;
+ } /* end if */
+ else {
+ /* Walk back down the iterator positions, resetting them */
+ while((unsigned)curr_dim < fast_dim) {
+ HDassert(curr_span);
+ HDassert(curr_span->down);
+ HDassert(curr_span->down->head);
+
+ /* Increment current dimension to the next dimension down */
+ curr_dim++;
+
+ /* Set the new span for the next dimension down */
+ ispan[curr_dim] = curr_span->down->head;
+
+ /* Advance span down the tree */
+ curr_span = curr_span->down->head;
+
+ /* Reset the absolute offset for the dim */
+ abs_arr[curr_dim] = curr_span->low;
+
+ /* Update location offset */
+ loc_arr[curr_dim] = ((hsize_t)((hssize_t)curr_span->low + sel_off[curr_dim])) * slab[curr_dim];
+ } /* end while */
+
+ /* Verify that the curr_span points to the fastest dim */
+ HDassert(curr_span == ispan[fast_dim]);
+ } /* end else */
+
+ /* Reset the buffer offset */
+ for(u = 0, loc_off = 0; u < ndims; u++)
+ loc_off += loc_arr[u];
+ } /* end while */
+
+ /* Decrement number of elements left in iterator */
+ io_used = io_left - io_elmts_left;
+ iter->elmt_left -= io_used;
+
+ /* Set the number of sequences generated */
+ *nseq = curr_seq;
+
+ /* Set the number of elements used */
+ *nelem = io_used;
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* end H5S__hyper_iter_release() */
+} /* end H5S__hyper_iter_get_seq_list_gen() */
/*--------------------------------------------------------------------------
NAME
- H5S__hyper_new_span
+ H5S__hyper_iter_get_seq_list_opt
PURPOSE
- Make a new hyperslab span node
+ Create a list of offsets & lengths for a selection
USAGE
- H5S_hyper_span_t *H5S__hyper_new_span(low, high, down, next)
- hsize_t low, high; IN: Low and high bounds for new span node
- H5S_hyper_span_info_t *down; IN: Down span tree for new node
- H5S_hyper_span_t *next; IN: Next span for new node
+ herr_t H5S__hyper_iter_get_seq_list_opt(iter,maxseq,maxelem,nseq,nelem,off,len)
+ H5S_sel_iter_t *iter; IN/OUT: Selection iterator describing last
+ position of interest in selection.
+ size_t maxseq; IN: Maximum number of sequences to generate
+ size_t maxelem; IN: Maximum number of elements to include in the
+ generated sequences
+ size_t *nseq; OUT: Actual number of sequences generated
+ size_t *nelem; OUT: Actual number of elements in sequences generated
+ hsize_t *off; OUT: Array of offsets
+ size_t *len; OUT: Array of lengths
RETURNS
- Pointer to next span node on success, NULL on failure
+ Non-negative on success/Negative on failure.
DESCRIPTION
- Allocate and initialize a new hyperslab span node, filling in the low &
- high bounds, the down span and next span pointers also. Increment the
- reference count of the 'down span' if applicable.
+ Use the selection in the dataspace to generate a list of byte offsets and
+ lengths for the region(s) selected. Start/Restart from the position in the
+ ITER parameter. The number of sequences generated is limited by the MAXSEQ
+ parameter and the number of sequences actually generated is stored in the
+ NSEQ parameter.
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-static H5S_hyper_span_t *
-H5S__hyper_new_span(hsize_t low, hsize_t high, H5S_hyper_span_info_t *down, H5S_hyper_span_t *next)
+static herr_t
+H5S__hyper_iter_get_seq_list_opt(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelem,
+ size_t *nseq, size_t *nelem, hsize_t *off, size_t *len)
{
- H5S_hyper_span_t *ret_value = NULL; /* Return value */
+ hsize_t *mem_size; /* Size of the source buffer */
+ hsize_t *slab; /* Hyperslab size */
+ const hssize_t *sel_off; /* Selection offset in dataspace */
+ hsize_t offset[H5S_MAX_RANK]; /* Coordinate offset in dataspace */
+ hsize_t tmp_count[H5S_MAX_RANK]; /* Temporary block count */
+ hsize_t tmp_block[H5S_MAX_RANK]; /* Temporary block offset */
+ hsize_t wrap[H5S_MAX_RANK]; /* Bytes to wrap around at the end of a row */
+ hsize_t skip[H5S_MAX_RANK]; /* Bytes to skip between blocks */
+ const H5S_hyper_dim_t *tdiminfo; /* Temporary pointer to diminfo information */
+ hsize_t fast_dim_start, /* Local copies of fastest changing dimension info */
+ fast_dim_stride,
+ fast_dim_block,
+ fast_dim_offset;
+ size_t fast_dim_buf_off; /* Local copy of amount to move fastest dimension buffer offset */
+ size_t fast_dim_count; /* Number of blocks left in fastest changing dimension */
+ size_t tot_blk_count; /* Total number of blocks left to output */
+ size_t act_blk_count; /* Actual number of blocks to output */
+ size_t total_rows; /* Total number of entire rows to output */
+ size_t curr_rows; /* Current number of entire rows to output */
+ unsigned fast_dim; /* Rank of the fastest changing dimension for the dataspace */
+ unsigned ndims; /* Number of dimensions of dataset */
+ int temp_dim; /* Temporary rank holder */
+ hsize_t loc; /* Coordinate offset */
+ size_t curr_seq = 0; /* Current sequence being operated on */
+ size_t actual_elem; /* The actual number of elements to count */
+ size_t actual_bytes;/* The actual number of bytes to copy */
+ size_t io_left; /* The number of elements left in I/O operation */
+ size_t start_io_left; /* The initial number of elements left in I/O operation */
+ size_t elem_size; /* Size of each element iterating over */
+ unsigned u; /* Local index variable */
- FUNC_ENTER_STATIC
+ FUNC_ENTER_STATIC_NOERR
- /* Allocate a new span node */
- if(NULL == (ret_value = H5FL_MALLOC(H5S_hyper_span_t)))
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate hyperslab span")
+ /* Check args */
+ HDassert(iter);
+ HDassert(maxseq > 0);
+ HDassert(maxelem > 0);
+ HDassert(nseq);
+ HDassert(nelem);
+ HDassert(off);
+ HDassert(len);
- /* Copy the span's basic information */
- ret_value->low = low;
- ret_value->high = high;
- ret_value->nelem = (high - low) + 1;
- ret_value->pstride = 0;
- ret_value->down = down;
- ret_value->next = next;
+ /* Set the local copy of the diminfo pointer */
+ tdiminfo = iter->u.hyp.diminfo;
- /* Increment the reference count of the 'down span' if there is one */
- if(ret_value->down)
- ret_value->down->count++;
+ /* Check if this is a "flattened" regular hyperslab selection */
+ if(iter->u.hyp.iter_rank != 0 && iter->u.hyp.iter_rank < iter->rank) {
+ /* Set the aliases for a few important dimension ranks */
+ ndims = iter->u.hyp.iter_rank;
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5S__hyper_new_span() */
+ /* Set the local copy of the selection offset */
+ sel_off = iter->u.hyp.sel_off;
+
+ /* Set up the pointer to the size of the memory dataspace */
+ mem_size = iter->u.hyp.size;
+ } /* end if */
+ else {
+ /* Set the aliases for a few important dimension ranks */
+ ndims = iter->rank;
+
+ /* Set the local copy of the selection offset */
+ sel_off = iter->sel_off;
+
+ /* Set up the pointer to the size of the memory dataspace */
+ mem_size = iter->dims;
+ } /* end else */
+
+ /* Set up some local variables */
+ fast_dim = ndims - 1;
+ elem_size = iter->elmt_size;
+ slab = iter->u.hyp.slab;
+
+ /* Calculate the number of elements to sequence through */
+ H5_CHECK_OVERFLOW(iter->elmt_left, hsize_t, size_t);
+ io_left = MIN((size_t)iter->elmt_left, maxelem);
+
+ /* Sanity check that there aren't any "remainder" sequences in process */
+ HDassert(!((iter->u.hyp.off[fast_dim] - tdiminfo[fast_dim].start) % tdiminfo[fast_dim].stride != 0 ||
+ ((iter->u.hyp.off[fast_dim] != tdiminfo[fast_dim].start) && tdiminfo[fast_dim].count == 1)));
+
+ /* We've cleared the "remainder" of the previous fastest dimension
+ * sequence before calling this routine, so we must be at the beginning of
+ * a sequence. Use the fancy algorithm to compute the offsets and run
+ * through as many as possible, until the buffer fills up.
+ */
+
+ /* Keep the number of elements we started with */
+ start_io_left = io_left;
+
+ /* Compute the arrays to perform I/O on */
+
+ /* Copy the location of the point to get */
+ /* (Add in the selection offset) */
+ for(u = 0; u < ndims; u++)
+ offset[u] = (hsize_t)((hssize_t)iter->u.hyp.off[u] + sel_off[u]);
+
+ /* Compute the current "counts" for this location */
+ for(u = 0; u < ndims; u++) {
+ if(tdiminfo[u].count == 1) {
+ tmp_count[u] = 0;
+ tmp_block[u] = iter->u.hyp.off[u] - tdiminfo[u].start;
+ } /* end if */
+ else {
+ tmp_count[u] = (iter->u.hyp.off[u] - tdiminfo[u].start) / tdiminfo[u].stride;
+ tmp_block[u] = (iter->u.hyp.off[u] - tdiminfo[u].start) % tdiminfo[u].stride;
+ } /* end else */
+ } /* end for */
+
+ /* Compute the initial buffer offset */
+ for(u = 0, loc = 0; u < ndims; u++)
+ loc += offset[u] * slab[u];
+
+ /* Set the number of elements to write each time */
+ H5_CHECKED_ASSIGN(actual_elem, size_t, tdiminfo[fast_dim].block, hsize_t);
+
+ /* Set the number of actual bytes */
+ actual_bytes = actual_elem * elem_size;
+
+ /* Set local copies of information for the fastest changing dimension */
+ fast_dim_start = tdiminfo[fast_dim].start;
+ fast_dim_stride = tdiminfo[fast_dim].stride;
+ fast_dim_block = tdiminfo[fast_dim].block;
+ H5_CHECKED_ASSIGN(fast_dim_buf_off, size_t, slab[fast_dim] * fast_dim_stride, hsize_t);
+ fast_dim_offset = (hsize_t)((hssize_t)fast_dim_start + sel_off[fast_dim]);
+
+ /* Compute the number of blocks which would fit into the buffer */
+ H5_CHECK_OVERFLOW(io_left / fast_dim_block, hsize_t, size_t);
+ tot_blk_count = (size_t)(io_left / fast_dim_block);
+
+ /* Don't go over the maximum number of sequences allowed */
+ tot_blk_count = MIN(tot_blk_count, (maxseq - curr_seq));
+
+ /* Compute the amount to wrap at the end of each row */
+ for(u = 0; u < ndims; u++)
+ wrap[u] = (mem_size[u] - (tdiminfo[u].stride * tdiminfo[u].count)) * slab[u];
+
+ /* Compute the amount to skip between blocks */
+ for(u = 0; u < ndims; u++)
+ skip[u] = (tdiminfo[u].stride - tdiminfo[u].block) * slab[u];
+
+ /* Check if there is a partial row left (with full blocks) */
+ if(tmp_count[fast_dim] > 0) {
+ /* Get number of blocks in fastest dimension */
+ H5_CHECKED_ASSIGN(fast_dim_count, size_t, tdiminfo[fast_dim].count - tmp_count[fast_dim], hsize_t);
+
+ /* Make certain this entire row will fit into buffer */
+ fast_dim_count = MIN(fast_dim_count, tot_blk_count);
+
+ /* Number of blocks to sequence over */
+ act_blk_count = fast_dim_count;
+
+ /* Loop over all the blocks in the fastest changing dimension */
+ while(fast_dim_count > 0) {
+ /* Store the sequence information */
+ off[curr_seq] = loc;
+ len[curr_seq] = actual_bytes;
+
+ /* Increment sequence count */
+ curr_seq++;
+
+ /* Increment information to reflect block just processed */
+ loc += fast_dim_buf_off;
+
+ /* Decrement number of blocks */
+ fast_dim_count--;
+ } /* end while */
+
+ /* Decrement number of elements left */
+ io_left -= actual_elem * act_blk_count;
+
+ /* Decrement number of blocks left */
+ tot_blk_count -= act_blk_count;
+
+ /* Increment information to reflect block just processed */
+ tmp_count[fast_dim] += act_blk_count;
+
+ /* Check if we finished the entire row of blocks */
+ if(tmp_count[fast_dim] >= tdiminfo[fast_dim].count) {
+ /* Increment offset in destination buffer */
+ loc += wrap[fast_dim];
+
+ /* Increment information to reflect block just processed */
+ offset[fast_dim] = fast_dim_offset; /* reset the offset in the fastest dimension */
+ tmp_count[fast_dim] = 0;
+
+ /* Increment the offset and count for the other dimensions */
+ temp_dim = (int)fast_dim - 1;
+ while(temp_dim >= 0) {
+ /* Move to the next row in the curent dimension */
+ offset[temp_dim]++;
+ tmp_block[temp_dim]++;
+
+ /* If this block is still in the range of blocks to output for the dimension, break out of loop */
+ if(tmp_block[temp_dim] < tdiminfo[temp_dim].block)
+ break;
+ else {
+ /* Move to the next block in the current dimension */
+ offset[temp_dim] += (tdiminfo[temp_dim].stride - tdiminfo[temp_dim].block);
+ loc += skip[temp_dim];
+ tmp_block[temp_dim] = 0;
+ tmp_count[temp_dim]++;
+
+ /* If this block is still in the range of blocks to output for the dimension, break out of loop */
+ if(tmp_count[temp_dim] < tdiminfo[temp_dim].count)
+ break;
+ else {
+ offset[temp_dim] = (hsize_t)((hssize_t)tdiminfo[temp_dim].start + sel_off[temp_dim]);
+ loc += wrap[temp_dim];
+ tmp_count[temp_dim] = 0; /* reset back to the beginning of the line */
+ tmp_block[temp_dim] = 0;
+ } /* end else */
+ } /* end else */
+
+ /* Decrement dimension count */
+ temp_dim--;
+ } /* end while */
+ } /* end if */
+ else {
+ /* Update the offset in the fastest dimension */
+ offset[fast_dim] += (fast_dim_stride * act_blk_count);
+ } /* end else */
+ } /* end if */
+
+ /* Compute the number of entire rows to read in */
+ H5_CHECK_OVERFLOW(tot_blk_count / tdiminfo[fast_dim].count, hsize_t, size_t);
+ curr_rows = total_rows = (size_t)(tot_blk_count / tdiminfo[fast_dim].count);
+
+ /* Reset copy of number of blocks in fastest dimension */
+ H5_CHECKED_ASSIGN(fast_dim_count, size_t, tdiminfo[fast_dim].count, hsize_t);
+
+ /* Read in data until an entire sequence can't be written out any longer */
+ while(curr_rows > 0) {
+
+#define DUFF_GUTS \
+/* Store the sequence information */ \
+off[curr_seq] = loc; \
+len[curr_seq] = actual_bytes; \
+ \
+/* Increment sequence count */ \
+curr_seq++; \
+ \
+/* Increment information to reflect block just processed */ \
+loc += fast_dim_buf_off;
+
+#ifdef NO_DUFFS_DEVICE
+ /* Loop over all the blocks in the fastest changing dimension */
+ while(fast_dim_count > 0) {
+ DUFF_GUTS
+
+ /* Decrement number of blocks */
+ fast_dim_count--;
+ } /* end while */
+#else /* NO_DUFFS_DEVICE */
+ {
+ size_t duffs_index; /* Counting index for Duff's device */
+
+ duffs_index = (fast_dim_count + 7) / 8;
+ switch (fast_dim_count % 8) {
+ default:
+ HDassert(0 && "This Should never be executed!");
+ break;
+ case 0:
+ do
+ {
+ DUFF_GUTS
+ H5_ATTR_FALLTHROUGH
+ case 7:
+ DUFF_GUTS
+ H5_ATTR_FALLTHROUGH
+ case 6:
+ DUFF_GUTS
+ H5_ATTR_FALLTHROUGH
+ case 5:
+ DUFF_GUTS
+ H5_ATTR_FALLTHROUGH
+ case 4:
+ DUFF_GUTS
+ H5_ATTR_FALLTHROUGH
+ case 3:
+ DUFF_GUTS
+ H5_ATTR_FALLTHROUGH
+ case 2:
+ DUFF_GUTS
+ H5_ATTR_FALLTHROUGH
+ case 1:
+ DUFF_GUTS
+ } while (--duffs_index > 0);
+ } /* end switch */
+ }
+#endif /* NO_DUFFS_DEVICE */
+#undef DUFF_GUTS
+
+ /* Increment offset in destination buffer */
+ loc += wrap[fast_dim];
+
+ /* Increment the offset and count for the other dimensions */
+ temp_dim = (int)fast_dim - 1;
+ while(temp_dim >= 0) {
+ /* Move to the next row in the curent dimension */
+ offset[temp_dim]++;
+ tmp_block[temp_dim]++;
+
+ /* If this block is still in the range of blocks to output for the dimension, break out of loop */
+ if(tmp_block[temp_dim] < tdiminfo[temp_dim].block)
+ break;
+ else {
+ /* Move to the next block in the current dimension */
+ offset[temp_dim] += (tdiminfo[temp_dim].stride - tdiminfo[temp_dim].block);
+ loc += skip[temp_dim];
+ tmp_block[temp_dim] = 0;
+ tmp_count[temp_dim]++;
+
+ /* If this block is still in the range of blocks to output for the dimension, break out of loop */
+ if(tmp_count[temp_dim] < tdiminfo[temp_dim].count)
+ break;
+ else {
+ offset[temp_dim] = (hsize_t)((hssize_t)tdiminfo[temp_dim].start + sel_off[temp_dim]);
+ loc += wrap[temp_dim];
+ tmp_count[temp_dim] = 0; /* reset back to the beginning of the line */
+ tmp_block[temp_dim] = 0;
+ } /* end else */
+ } /* end else */
+
+ /* Decrement dimension count */
+ temp_dim--;
+ } /* end while */
+
+ /* Decrement the number of rows left */
+ curr_rows--;
+ } /* end while */
+
+ /* Adjust the number of blocks & elements left to transfer */
+
+ /* Decrement number of elements left */
+ H5_CHECK_OVERFLOW(actual_elem * (total_rows * tdiminfo[fast_dim].count), hsize_t, size_t);
+ io_left -= (size_t)(actual_elem * (total_rows * tdiminfo[fast_dim].count));
+
+ /* Decrement number of blocks left */
+ H5_CHECK_OVERFLOW((total_rows * tdiminfo[fast_dim].count), hsize_t, size_t);
+ tot_blk_count -= (size_t)(total_rows * tdiminfo[fast_dim].count);
+
+ /* Read in partial row of blocks */
+ if(io_left > 0 && curr_seq < maxseq) {
+ /* Get remaining number of blocks left to output */
+ fast_dim_count = tot_blk_count;
+
+ /* Loop over all the blocks in the fastest changing dimension */
+ while(fast_dim_count > 0) {
+ /* Store the sequence information */
+ off[curr_seq] = loc;
+ len[curr_seq] = actual_bytes;
+
+ /* Increment sequence count */
+ curr_seq++;
+
+ /* Increment information to reflect block just processed */
+ loc += fast_dim_buf_off;
+
+ /* Decrement number of blocks */
+ fast_dim_count--;
+ } /* end while */
+
+ /* Decrement number of elements left */
+ io_left -= actual_elem * tot_blk_count;
+
+ /* Increment information to reflect block just processed */
+ offset[fast_dim] += (fast_dim_stride * tot_blk_count); /* move the offset in the fastest dimension */
+
+ /* Handle any leftover, partial blocks in this row */
+ if(io_left > 0 && curr_seq < maxseq) {
+ actual_elem = io_left;
+ actual_bytes = actual_elem * elem_size;
+
+ /* Store the sequence information */
+ off[curr_seq] = loc;
+ len[curr_seq] = actual_bytes;
+
+ /* Increment sequence count */
+ curr_seq++;
+
+ /* Decrement the number of elements left */
+ io_left -= actual_elem;
+
+ /* Increment buffer correctly */
+ offset[fast_dim] += actual_elem;
+ } /* end if */
+
+ /* don't bother checking slower dimensions */
+ HDassert(io_left == 0 || curr_seq == maxseq);
+ } /* end if */
+
+ /* Update the iterator */
+
+ /* Update the iterator with the location we stopped */
+ /* (Subtract out the selection offset) */
+ for(u = 0; u < ndims; u++)
+ iter->u.hyp.off[u] = (hsize_t)((hssize_t)offset[u] - sel_off[u]);
+
+ /* Decrement the number of elements left in selection */
+ iter->elmt_left -= (start_io_left - io_left);
+
+ /* Increment the number of sequences generated */
+ *nseq += curr_seq;
+
+ /* Increment the number of elements used */
+ *nelem += start_io_left - io_left;
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5S__hyper_iter_get_seq_list_opt() */
/*--------------------------------------------------------------------------
NAME
- H5S__hyper_span_precompute_helper
+ H5S__hyper_iter_get_seq_list_single
PURPOSE
- Helper routine to precompute the nelem and pstrides in bytes.
+ Create a list of offsets & lengths for a selection
USAGE
- void H5S__hyper_span_precompute_helper(span_info, elmt_size)
- H5S_hyper_span_info_t *span_info; IN/OUT: Span tree to work on
- size_t elmt_size; IN: element size to work with
+ herr_t H5S__hyper_iter_get_seq_list_single(flags, iter, maxseq, maxelem, nseq, nelem, off, len)
+ unsigned flags; IN: Flags for extra information about operation
+ H5S_sel_iter_t *iter; IN/OUT: Selection iterator describing last
+ position of interest in selection.
+ size_t maxseq; IN: Maximum number of sequences to generate
+ size_t maxelem; IN: Maximum number of elements to include in the
+ generated sequences
+ size_t *nseq; OUT: Actual number of sequences generated
+ size_t *nelem; OUT: Actual number of elements in sequences generated
+ hsize_t *off; OUT: Array of offsets
+ size_t *len; OUT: Array of lengths
RETURNS
- None
+ Non-negative on success/Negative on failure.
DESCRIPTION
- Change the nelem and pstride values in the span tree from elements to
- bytes using the elmt_size parameter.
+ Use the selection in the dataspace to generate a list of byte offsets and
+ lengths for the region(s) selected. Start/Restart from the position in the
+ ITER parameter. The number of sequences generated is limited by the MAXSEQ
+ parameter and the number of sequences actually generated is stored in the
+ NSEQ parameter.
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-static void
-H5S__hyper_span_precompute_helper(H5S_hyper_span_info_t *spans, size_t elmt_size)
+static herr_t
+H5S__hyper_iter_get_seq_list_single(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelem,
+ size_t *nseq, size_t *nelem, hsize_t *off, size_t *len)
{
+ const H5S_hyper_dim_t *tdiminfo; /* Temporary pointer to diminfo information */
+ const hssize_t *sel_off; /* Selection offset in dataspace */
+ hsize_t *mem_size; /* Size of the source buffer */
+ hsize_t base_offset[H5S_MAX_RANK]; /* Base coordinate offset in dataspace */
+ hsize_t offset[H5S_MAX_RANK]; /* Coordinate offset in dataspace */
+ hsize_t *slab; /* Hyperslab size */
+ hsize_t fast_dim_block; /* Local copies of fastest changing dimension info */
+ hsize_t loc; /* Coordinate offset */
+ size_t tot_blk_count; /* Total number of blocks left to output */
+ size_t elem_size; /* Size of each element iterating over */
+ size_t io_left; /* The number of elements left in I/O operation */
+ size_t actual_elem; /* The actual number of elements to count */
+ unsigned ndims; /* Number of dimensions of dataset */
+ unsigned fast_dim; /* Rank of the fastest changing dimension for the dataspace */
+ unsigned skip_dim; /* Rank of the dimension to skip along */
+ unsigned u; /* Local index variable */
+
FUNC_ENTER_STATIC_NOERR
- /* Sanity checks */
- HDassert(spans);
- HDassert(spans->scratch == (H5S_hyper_span_info_t *)~((size_t)NULL) ||
- spans->scratch == NULL);
+ /* Check args */
+ HDassert(iter);
+ HDassert(maxseq > 0);
+ HDassert(maxelem > 0);
+ HDassert(nseq);
+ HDassert(nelem);
+ HDassert(off);
+ HDassert(len);
+
+ /* Set a local copy of the diminfo pointer */
+ tdiminfo = iter->u.hyp.diminfo;
- /* Check if we've already set this down span tree */
- if(spans->scratch != (H5S_hyper_span_info_t *)~((size_t)NULL)) {
- H5S_hyper_span_t *span; /* Hyperslab span */
+ /* Check if this is a "flattened" regular hyperslab selection */
+ if(iter->u.hyp.iter_rank != 0 && iter->u.hyp.iter_rank < iter->rank) {
+ /* Set the aliases for a few important dimension ranks */
+ ndims = iter->u.hyp.iter_rank;
- /* Set the tree's scratch pointer */
- spans->scratch = (H5S_hyper_span_info_t *)~((size_t)NULL);
+ /* Set the local copy of the selection offset */
+ sel_off = iter->u.hyp.sel_off;
- /* Set the scratch pointers in all the nodes */
- span = spans->head;
+ /* Set up the pointer to the size of the memory dataspace */
+ mem_size = iter->u.hyp.size;
+ } /* end if */
+ else {
+ /* Set the aliases for a few important dimension ranks */
+ ndims = iter->rank;
- /* Loop over all the spans for this down span tree */
- while(span != NULL) {
- /* If there are down spans, precompute their values also */
- if(span->down != NULL)
- H5S__hyper_span_precompute_helper(span->down, elmt_size);
+ /* Set the local copy of the selection offset */
+ sel_off = iter->sel_off;
- /* Change the nelem & pstride values into bytes */
- span->nelem *= elmt_size;
- span->pstride *= elmt_size;
+ /* Set up the pointer to the size of the memory dataspace */
+ mem_size = iter->dims;
+ } /* end else */
- /* Advance to next span */
- span = span->next;
- } /* end while */
+ /* Set up some local variables */
+ fast_dim = ndims - 1;
+ elem_size = iter->elmt_size;
+ slab = iter->u.hyp.slab;
+
+ /* Copy the base location of the block */
+ /* (Add in the selection offset) */
+ for(u = 0; u < ndims; u++)
+ base_offset[u] = (hsize_t)((hssize_t)tdiminfo[u].start + sel_off[u]);
+
+ /* Copy the location of the point to get */
+ /* (Add in the selection offset) */
+ for(u = 0; u < ndims; u++)
+ offset[u] = (hsize_t)((hssize_t)iter->u.hyp.off[u] + sel_off[u]);
+
+ /* Compute the initial buffer offset */
+ for(u = 0, loc = 0; u < ndims; u++)
+ loc += offset[u] * slab[u];
+
+ /* Set local copies of information for the fastest changing dimension */
+ fast_dim_block = tdiminfo[fast_dim].block;
+
+ /* Calculate the number of elements to sequence through */
+ H5_CHECK_OVERFLOW(iter->elmt_left, hsize_t, size_t);
+ io_left = MIN((size_t)iter->elmt_left, maxelem);
+
+ /* Compute the number of blocks which would fit into the buffer */
+ H5_CHECK_OVERFLOW(io_left / fast_dim_block, hsize_t, size_t);
+ tot_blk_count = (size_t)(io_left / fast_dim_block);
+
+ /* Don't go over the maximum number of sequences allowed */
+ tot_blk_count = MIN(tot_blk_count, maxseq);
+
+ /* Set the number of elements to write each time */
+ H5_CHECKED_ASSIGN(actual_elem, size_t, fast_dim_block, hsize_t);
+
+ /* Check for blocks to operate on */
+ if(tot_blk_count > 0) {
+ size_t actual_bytes; /* The actual number of bytes to copy */
+
+ /* Set the number of actual bytes */
+ actual_bytes = actual_elem * elem_size;
+
+ /* Check for 1-dim selection */
+ if(0 == fast_dim) {
+ /* Sanity checks */
+ HDassert(1 == tot_blk_count);
+ HDassert(io_left == actual_elem);
+
+ /* Store the sequence information */
+ *off++ = loc;
+ *len++ = actual_bytes;
+ } /* end if */
+ else {
+ hsize_t skip_slab; /* Temporary copy of slab[fast_dim - 1] */
+ size_t blk_count; /* Total number of blocks left to output */
+ int i; /* Local index variable */
+
+ /* Find first dimension w/block >1 */
+ skip_dim = fast_dim;
+ for(i = (int)(fast_dim - 1); i >= 0; i--)
+ if(tdiminfo[i].block > 1) {
+ skip_dim = (unsigned)i;
+ break;
+ } /* end if */
+ skip_slab = slab[skip_dim];
+
+ /* Check for being able to use fast algorithm for 1-D */
+ if(0 == skip_dim) {
+ /* Create sequences until an entire row can't be used */
+ blk_count = tot_blk_count;
+ while(blk_count > 0) {
+ /* Store the sequence information */
+ *off++ = loc;
+ *len++ = actual_bytes;
+
+ /* Increment offset in destination buffer */
+ loc += skip_slab;
+
+ /* Decrement block count */
+ blk_count--;
+ } /* end while */
+
+ /* Move to the next location */
+ offset[skip_dim] += tot_blk_count;
+ } /* end if */
+ else {
+ hsize_t tmp_block[H5S_MAX_RANK]; /* Temporary block offset */
+ hsize_t skip[H5S_MAX_RANK]; /* Bytes to skip between blocks */
+ int temp_dim; /* Temporary rank holder */
+
+ /* Set the starting block location */
+ for(u = 0; u < ndims; u++)
+ tmp_block[u] = iter->u.hyp.off[u] - tdiminfo[u].start;
+
+ /* Compute the amount to skip between sequences */
+ for(u = 0; u < ndims; u++)
+ skip[u] = (mem_size[u] - tdiminfo[u].block) * slab[u];
+
+ /* Create sequences until an entire row can't be used */
+ blk_count = tot_blk_count;
+ while(blk_count > 0) {
+ /* Store the sequence information */
+ *off++ = loc;
+ *len++ = actual_bytes;
+
+ /* Set temporary dimension for advancing offsets */
+ temp_dim = (int)skip_dim;
+
+ /* Increment offset in destination buffer */
+ loc += skip_slab;
+
+ /* Increment the offset and count for the other dimensions */
+ while(temp_dim >= 0) {
+ /* Move to the next row in the curent dimension */
+ offset[temp_dim]++;
+ tmp_block[temp_dim]++;
+
+ /* If this block is still in the range of blocks to output for the dimension, break out of loop */
+ if(tmp_block[temp_dim] < tdiminfo[temp_dim].block)
+ break;
+ else {
+ offset[temp_dim] = base_offset[temp_dim];
+ loc += skip[temp_dim];
+ tmp_block[temp_dim] = 0;
+ } /* end else */
+
+ /* Decrement dimension count */
+ temp_dim--;
+ } /* end while */
+
+ /* Decrement block count */
+ blk_count--;
+ } /* end while */
+ } /* end else */
+ } /* end else */
+
+ /* Update the iterator, if there were any blocks used */
+
+ /* Decrement the number of elements left in selection */
+ iter->elmt_left -= tot_blk_count * actual_elem;
+
+ /* Check if there are elements left in iterator */
+ if(iter->elmt_left > 0) {
+ /* Update the iterator with the location we stopped */
+ /* (Subtract out the selection offset) */
+ for(u = 0; u < ndims; u++)
+ iter->u.hyp.off[u] = (hsize_t)((hssize_t)offset[u] - sel_off[u]);
+ } /* end if */
+
+ /* Increment the number of sequences generated */
+ *nseq += tot_blk_count;
+
+ /* Increment the number of elements used */
+ *nelem += tot_blk_count * actual_elem;
} /* end if */
- FUNC_LEAVE_NOAPI_VOID
-} /* end H5S__hyper_span_precompute_helper() */
+ /* Check for partial block, with room for another sequence */
+ if(io_left > (tot_blk_count * actual_elem) && tot_blk_count < maxseq) {
+ size_t elmt_remainder; /* Elements remaining */
+
+ /* Compute elements left */
+ elmt_remainder = io_left - (tot_blk_count * actual_elem);
+ HDassert(elmt_remainder < fast_dim_block);
+ HDassert(elmt_remainder > 0);
+
+ /* Store the sequence information */
+ *off++ = loc;
+ *len++ = elmt_remainder * elem_size;
+
+ /* Update the iterator with the location we stopped */
+ iter->u.hyp.off[fast_dim] += (hsize_t)elmt_remainder;
+
+ /* Decrement the number of elements left in selection */
+ iter->elmt_left -= elmt_remainder;
+
+ /* Increment the number of sequences generated */
+ (*nseq)++;
+
+ /* Increment the number of elements used */
+ *nelem += elmt_remainder;
+ } /* end if */
+
+ /* Sanity check */
+ HDassert(*nseq > 0);
+ HDassert(*nelem > 0);
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5S__hyper_iter_get_seq_list_single() */
/*--------------------------------------------------------------------------
NAME
- H5S__hyper_span_precompute
+ H5S__hyper_iter_get_seq_list
PURPOSE
- Precompute the nelem and pstrides in bytes.
+ Create a list of offsets & lengths for a selection
USAGE
- herr_t H5S__hyper_span_precompute(span_info, elmt_size)
- H5S_hyper_span_info_t *span_info; IN/OUT: Span tree to work on
- size_t elmt_size; IN: element size to work with
+ herr_t H5S__hyper_iter_get_seq_list(iter,maxseq,maxelem,nseq,nelem,off,len)
+ H5S_t *space; IN: Dataspace containing selection to use.
+ unsigned flags; IN: Flags for extra information about operation
+ H5S_sel_iter_t *iter; IN/OUT: Selection iterator describing last
+ position of interest in selection.
+ size_t maxseq; IN: Maximum number of sequences to generate
+ size_t maxelem; IN: Maximum number of elements to include in the
+ generated sequences
+ size_t *nseq; OUT: Actual number of sequences generated
+ size_t *nelem; OUT: Actual number of elements in sequences generated
+ hsize_t *off; OUT: Array of offsets (in bytes)
+ size_t *len; OUT: Array of lengths (in bytes)
RETURNS
- Non-negative on success, negative on failure
+ Non-negative on success/Negative on failure.
DESCRIPTION
- Change the nelem and pstride values in the span tree from elements to
- bytes using the elmt_size parameter.
+ Use the selection in the dataspace to generate a list of byte offsets and
+ lengths for the region(s) selected. Start/Restart from the position in the
+ ITER parameter. The number of sequences generated is limited by the MAXSEQ
+ parameter and the number of sequences actually generated is stored in the
+ NSEQ parameter.
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
-H5S__hyper_span_precompute(H5S_hyper_span_info_t *spans, size_t elmt_size)
+H5S__hyper_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq,
+ size_t maxelem, size_t *nseq, size_t *nelem, hsize_t *off, size_t *len)
{
+ herr_t ret_value = FAIL; /* return value */
+
FUNC_ENTER_STATIC_NOERR
- HDassert(spans);
+ /* Check args */
+ HDassert(iter);
+ HDassert(iter->elmt_left > 0);
+ HDassert(maxseq > 0);
+ HDassert(maxelem > 0);
+ HDassert(nseq);
+ HDassert(nelem);
+ HDassert(off);
+ HDassert(len);
- /* Call the helper routine to actually do the work */
- H5S__hyper_span_precompute_helper(spans, elmt_size);
+ /* Check for the special case of just one H5Sselect_hyperslab call made */
+ if(iter->u.hyp.diminfo_valid) {
+ const H5S_hyper_dim_t *tdiminfo; /* Temporary pointer to diminfo information */
+ const hssize_t *sel_off; /* Selection offset in dataspace */
+ unsigned ndims; /* Number of dimensions of dataset */
+ unsigned fast_dim; /* Rank of the fastest changing dimension for the dataspace */
+ hbool_t single_block; /* Whether the selection is a single block */
+ unsigned u; /* Local index variable */
- /* Reset the scratch pointers for the next routine which needs them */
- H5S__hyper_span_scratch(spans);
+ /* Set a local copy of the diminfo pointer */
+ tdiminfo = iter->u.hyp.diminfo;
- FUNC_LEAVE_NOAPI(SUCCEED)
-} /* end H5S__hyper_span_precompute() */
+ /* Check if this is a "flattened" regular hyperslab selection */
+ if(iter->u.hyp.iter_rank != 0 && iter->u.hyp.iter_rank < iter->rank) {
+ /* Set the aliases for a few important dimension ranks */
+ ndims = iter->u.hyp.iter_rank;
+
+ /* Set the local copy of the selection offset */
+ sel_off = iter->u.hyp.sel_off;
+ } /* end if */
+ else {
+ /* Set the aliases for a few important dimension ranks */
+ ndims = iter->rank;
+
+ /* Set the local copy of the selection offset */
+ sel_off = iter->sel_off;
+ } /* end else */
+ fast_dim = ndims - 1;
+
+ /* Check if we stopped in the middle of a sequence of elements */
+ if((iter->u.hyp.off[fast_dim] - tdiminfo[fast_dim].start) % tdiminfo[fast_dim].stride != 0 ||
+ ((iter->u.hyp.off[fast_dim] != tdiminfo[fast_dim].start) && tdiminfo[fast_dim].count == 1)) {
+ hsize_t *slab; /* Hyperslab size */
+ hsize_t loc; /* Coordinate offset */
+ size_t leftover; /* The number of elements left over from the last sequence */
+ size_t actual_elem; /* The actual number of elements to count */
+ size_t elem_size; /* Size of each element iterating over */
+
+ /* Calculate the number of elements left in the sequence */
+ if(tdiminfo[fast_dim].count == 1) {
+ H5_CHECKED_ASSIGN(leftover, size_t, tdiminfo[fast_dim].block - (iter->u.hyp.off[fast_dim] - tdiminfo[fast_dim].start), hsize_t);
+ } /* end if */
+ else {
+ H5_CHECKED_ASSIGN(leftover, size_t, tdiminfo[fast_dim].block - ((iter->u.hyp.off[fast_dim] - tdiminfo[fast_dim].start) % tdiminfo[fast_dim].stride), hsize_t);
+ } /* end else */
+
+ /* Make certain that we don't write too many */
+ actual_elem = MIN3(leftover, (size_t)iter->elmt_left, maxelem);
+
+ /* Set up some local variables */
+ elem_size = iter->elmt_size;
+ slab = iter->u.hyp.slab;
+
+ /* Compute the initial buffer offset */
+ for(u = 0, loc = 0; u < ndims; u++)
+ loc += ((hsize_t)((hssize_t)iter->u.hyp.off[u] + sel_off[u])) * slab[u];
+
+ /* Add a new sequence */
+ off[0] = loc;
+ H5_CHECKED_ASSIGN(len[0], size_t, actual_elem * elem_size, hsize_t);
+
+ /* Increment sequence array locations */
+ off++;
+ len++;
+
+ /* Advance the hyperslab iterator */
+ H5S__hyper_iter_next(iter, actual_elem);
+
+ /* Decrement the number of elements left in selection */
+ iter->elmt_left -= actual_elem;
+
+ /* Decrement element/sequence limits */
+ maxelem -= actual_elem;
+ maxseq--;
+
+ /* Set the number of sequences generated and elements used */
+ *nseq = 1;
+ *nelem = actual_elem;
+
+ /* Check for using up all the sequences/elements */
+ if(0 == iter->elmt_left || 0 == maxelem || 0 == maxseq)
+ return(SUCCEED);
+ } /* end if */
+ else {
+ /* Reset the number of sequences generated and elements used */
+ *nseq = 0;
+ *nelem = 0;
+ } /* end else */
+
+ /* Check for a single block selected */
+ single_block = TRUE;
+ for(u = 0; u < ndims; u++)
+ if(1 != tdiminfo[u].count) {
+ single_block = FALSE;
+ break;
+ } /* end if */
+
+ /* Check for single block selection */
+ if(single_block)
+ /* Use single-block optimized call to generate sequence list */
+ ret_value = H5S__hyper_iter_get_seq_list_single(iter, maxseq, maxelem, nseq, nelem, off, len);
+ else
+ /* Use optimized call to generate sequence list */
+ ret_value = H5S__hyper_iter_get_seq_list_opt(iter, maxseq, maxelem, nseq, nelem, off, len);
+ } /* end if */
+ else
+ /* Call the general sequence generator routine */
+ ret_value = H5S__hyper_iter_get_seq_list_gen(iter, maxseq, maxelem, nseq, nelem, off, len);
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5S__hyper_iter_get_seq_list() */
/*--------------------------------------------------------------------------
NAME
- H5S__hyper_span_scratch
+ H5S__hyper_iter_release
PURPOSE
- Reset the scratch pointers on hyperslab span trees
+ Release hyperslab selection iterator information for a dataspace
USAGE
- void H5S__hyper_span_scratch(span_info)
- H5S_hyper_span_info_t *span_info; IN: Span tree to reset
+ herr_t H5S__hyper_iter_release(iter)
+ H5S_sel_iter_t *iter; IN: Pointer to selection iterator
RETURNS
- <none>
+ Non-negative on success/Negative on failure
DESCRIPTION
- Reset the scratch pointers on a hyperslab span tree to NULL.
+ Releases all information for a dataspace hyperslab selection iterator
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-static void
-H5S__hyper_span_scratch(H5S_hyper_span_info_t *spans)
+static herr_t
+H5S__hyper_iter_release(H5S_sel_iter_t *iter)
{
FUNC_ENTER_STATIC_NOERR
- HDassert(spans);
+ /* Check args */
+ HDassert(iter);
- /* Check if we've already set this down span tree */
- if(spans->scratch != NULL) {
- H5S_hyper_span_t *span; /* Hyperslab span */
+ /* Free the copy of the hyperslab selection span tree */
+ if(iter->u.hyp.spans != NULL)
+ H5S__hyper_free_span_info(iter->u.hyp.spans);
- /* Reset the tree's scratch pointer */
- spans->scratch = NULL;
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5S__hyper_iter_release() */
- /* Set the scratch pointers in all the nodes */
- span = spans->head;
- while(span != NULL) {
- /* If there are down spans, set their scratch value also */
- if(span->down != NULL)
- H5S__hyper_span_scratch(span->down);
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S__hyper_new_span
+ PURPOSE
+ Make a new hyperslab span node
+ USAGE
+ H5S_hyper_span_t *H5S__hyper_new_span(low, high, down, next)
+ hsize_t low, high; IN: Low and high bounds for new span node
+ H5S_hyper_span_info_t *down; IN: Down span tree for new node
+ H5S_hyper_span_t *next; IN: Next span for new node
+ RETURNS
+ Pointer to new span node on success, NULL on failure
+ DESCRIPTION
+ Allocate and initialize a new hyperslab span node, filling in the low &
+ high bounds, the down span and next span pointers also. Increment the
+ reference count of the 'down span' if applicable.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+static H5S_hyper_span_t *
+H5S__hyper_new_span(hsize_t low, hsize_t high, H5S_hyper_span_info_t *down,
+ H5S_hyper_span_t *next)
+{
+ H5S_hyper_span_t *ret_value = NULL; /* Return value */
- /* Advance to next span */
- span = span->next;
- } /* end while */
- } /* end if */
+ FUNC_ENTER_STATIC
- FUNC_LEAVE_NOAPI_VOID
-} /* end H5S__hyper_span_scratch() */
+ /* Allocate a new span node */
+ if(NULL == (ret_value = H5FL_MALLOC(H5S_hyper_span_t)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate hyperslab span")
+
+ /* Copy the span's basic information */
+ ret_value->low = low;
+ ret_value->high = high;
+ ret_value->down = down;
+ ret_value->next = next;
+
+ /* Increment the reference count of the 'down span' if there is one */
+ if(ret_value->down)
+ ret_value->down->count++;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5S__hyper_new_span() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S__hyper_new_span_info
+ PURPOSE
+ Make a new hyperslab span info node
+ USAGE
+ H5S_hyper_span_info_t *H5S__hyper_new_span_info(rank)
+ unsigned rank; IN: Rank of span info, in selection
+ RETURNS
+ Pointer to new span node info on success, NULL on failure
+ DESCRIPTION
+ Allocate and initialize a new hyperslab span info node of a given rank,
+ setting up the low & high bound array pointers.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ Note that this uses the C99 "flexible array member" feature.
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+static H5S_hyper_span_info_t *
+H5S__hyper_new_span_info(unsigned rank)
+{
+ H5S_hyper_span_info_t *ret_value = NULL; /* Return value */
+
+ FUNC_ENTER_STATIC
+
+ /* Sanity check */
+ HDassert(rank > 0);
+ HDassert(rank <= H5S_MAX_RANK);
+
+ /* Allocate a new span info node */
+ if(NULL == (ret_value = (H5S_hyper_span_info_t *)H5FL_ARR_CALLOC(hbounds_t, rank * 2)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate hyperslab span info")
+
+ /* Set low & high bound pointers into the 'bounds' array */
+ ret_value->low_bounds = ret_value->bounds;
+ ret_value->high_bounds = &ret_value->bounds[rank];
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5S__hyper_new_span_info() */
/*--------------------------------------------------------------------------
@@ -1296,8 +2858,10 @@ H5S__hyper_span_scratch(H5S_hyper_span_info_t *spans)
PURPOSE
Helper routine to copy a hyperslab span tree
USAGE
- H5S_hyper_span_info_t * H5S__hyper_copy_span_helper(spans)
- H5S_hyper_span_info_t *spans; IN: Span tree to copy
+ H5S_hyper_span_info_t * H5S__hyper_copy_span_helper(spans, rank)
+ H5S_hyper_span_info_t *spans; IN: Span tree to copy
+ unsigned rank; IN: Rank of span tree
+ uint64_t op_gen; IN: Operation generation
RETURNS
Pointer to the copied span tree on success, NULL on failure
DESCRIPTION
@@ -1308,7 +2872,8 @@ H5S__hyper_span_scratch(H5S_hyper_span_info_t *spans)
REVISION LOG
--------------------------------------------------------------------------*/
static H5S_hyper_span_info_t *
-H5S__hyper_copy_span_helper(H5S_hyper_span_info_t *spans)
+H5S__hyper_copy_span_helper(H5S_hyper_span_info_t *spans, unsigned rank,
+ uint64_t op_gen)
{
H5S_hyper_span_t *span; /* Hyperslab span */
H5S_hyper_span_t *new_span; /* Temporary hyperslab span */
@@ -1320,26 +2885,30 @@ H5S__hyper_copy_span_helper(H5S_hyper_span_info_t *spans)
/* Sanity checks */
HDassert(spans);
- HDassert(spans->scratch != (H5S_hyper_span_info_t *)~((size_t)NULL));
/* Check if the span tree was already copied */
- if(spans->scratch != NULL) {
+ if(spans->op_gen == op_gen) {
/* Just return the value of the already copied span tree */
- ret_value = spans->scratch;
+ ret_value = spans->u.copied;
/* Increment the reference count of the span tree */
ret_value->count++;
} /* end if */
else {
/* Allocate a new span_info node */
- if(NULL == (ret_value = H5FL_CALLOC(H5S_hyper_span_info_t)))
+ if(NULL == (ret_value = H5S__hyper_new_span_info(rank)))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate hyperslab span info")
- /* Copy the span_info information */
+ /* Set the non-zero span_info information */
+ H5MM_memcpy(ret_value->low_bounds, spans->low_bounds, rank * sizeof(hsize_t));
+ H5MM_memcpy(ret_value->high_bounds, spans->high_bounds, rank * sizeof(hsize_t));
ret_value->count = 1;
- /* Set the scratch pointer in the node being copied to the newly allocated node */
- spans->scratch = ret_value;
+ /* Set the operation generation for the span info, to avoid future copies */
+ spans->op_gen = op_gen;
+
+ /* Set the 'copied' pointer in the node being copied to the newly allocated node */
+ spans->u.copied = ret_value;
/* Copy over the nodes in the span list */
span = spans->head;
@@ -1355,12 +2924,9 @@ H5S__hyper_copy_span_helper(H5S_hyper_span_info_t *spans)
else
prev_span->next = new_span;
- /* Copy the pstride */
- new_span->pstride = span->pstride;
-
/* Recurse to copy the 'down' spans, if there are any */
if(span->down != NULL) {
- if(NULL == (new_down = H5S__hyper_copy_span_helper(span->down)))
+ if(NULL == (new_down = H5S__hyper_copy_span_helper(span->down, rank - 1, op_gen)))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "can't copy hyperslab spans")
new_span->down = new_down;
} /* end if */
@@ -1371,6 +2937,9 @@ H5S__hyper_copy_span_helper(H5S_hyper_span_info_t *spans)
/* Advance to next span */
span = span->next;
} /* end while */
+
+ /* Retain a pointer to the last span */
+ ret_value->tail = prev_span;
} /* end else */
done:
@@ -1384,10 +2953,11 @@ done:
PURPOSE
Copy a hyperslab span tree
USAGE
- H5S_hyper_span_info_t * H5S__hyper_copy_span(span_info)
- H5S_hyper_span_info_t *span_info; IN: Span tree to copy
+ H5S_hyper_span_info_t * H5S__hyper_copy_span(span_info, rank)
+ H5S_hyper_span_info_t *span_info; IN: Span tree to copy
+ unsigned rank; IN: Rank of span tree
RETURNS
- Non-negative on success, negative on failure
+ Pointer to the copied span tree on success, NULL on failure
DESCRIPTION
Copy a hyperslab span tree, using reference counting as appropriate.
(Which means that just the nodes in the top span tree are duplicated and
@@ -1398,21 +2968,23 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
static H5S_hyper_span_info_t *
-H5S__hyper_copy_span(H5S_hyper_span_info_t *spans)
+H5S__hyper_copy_span(H5S_hyper_span_info_t *spans, unsigned rank)
{
+ uint64_t op_gen; /* Operation generation value */
H5S_hyper_span_info_t *ret_value = NULL; /* Return value */
FUNC_ENTER_STATIC
+ /* Sanity check */
HDassert(spans);
+ /* Acquire an operation generation value for this operation */
+ op_gen = H5S__hyper_get_op_gen();
+
/* Copy the hyperslab span tree */
- if(NULL == (ret_value = H5S__hyper_copy_span_helper(spans)))
+ if(NULL == (ret_value = H5S__hyper_copy_span_helper(spans, rank, op_gen)))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "can't copy hyperslab span tree")
- /* Reset the scratch pointers for the next routine which needs them */
- H5S__hyper_span_scratch(spans);
-
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5S__hyper_copy_span() */
@@ -1422,90 +2994,94 @@ done:
NAME
H5S__hyper_cmp_spans
PURPOSE
- Check if two hyperslab slabs are the same
+ Check if two hyperslab span trees are the same
USAGE
hbool_t H5S__hyper_cmp_spans(span1, span2)
- H5S_hyper_span_t *span1; IN: First span tree to compare
- H5S_hyper_span_t *span2; IN: Second span tree to compare
+ H5S_hyper_span_info_t *span_info1; IN: First span tree to compare
+ H5S_hyper_span_info_t *span_info2; IN: Second span tree to compare
RETURNS
TRUE (1) or FALSE (0) on success, can't fail
DESCRIPTION
- Compare two hyperslab slabs to determine if they refer to the same
- selection. If span1 & span2 are both NULL, that counts as equal
+ Compare two hyperslab span trees to determine if they refer to the same
+ selection. If span1 & span2 are both NULL, that counts as equal.
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-static hbool_t
-H5S__hyper_cmp_spans(const H5S_hyper_span_info_t *span_info1, const H5S_hyper_span_info_t *span_info2)
+static H5_ATTR_PURE hbool_t
+H5S__hyper_cmp_spans(const H5S_hyper_span_info_t *span_info1,
+ const H5S_hyper_span_info_t *span_info2)
{
- hbool_t ret_value = FALSE; /* Return value */
+ hbool_t ret_value = TRUE; /* Return value */
FUNC_ENTER_STATIC_NOERR
/* Check for redundant comparison (or both spans being NULL) */
- if(span_info1 == span_info2)
- ret_value = TRUE;
- else {
+ if(span_info1 != span_info2) {
/* Check for one span being NULL */
if(span_info1 == NULL || span_info2 == NULL)
- ret_value = FALSE;
+ HGOTO_DONE(FALSE)
else {
- const H5S_hyper_span_t *span1;
- const H5S_hyper_span_t *span2;
-
- /* Get the pointers to the actual lists of spans */
- span1 = span_info1->head;
- span2 = span_info2->head;
-
- /* Sanity checking */
- HDassert(span1);
- HDassert(span2);
-
- /* infinite loop which must be broken out of */
- while(1) {
- /* Check for both spans being NULL */
- if(span1 == NULL && span2 == NULL) {
- ret_value = TRUE;
- break;
- } /* end if */
- else {
- /* Check for one span being NULL */
- if(span1 == NULL || span2 == NULL) {
- ret_value = FALSE;
- break;
- } /* end if */
+ /* Compare low & high bounds for this span list */
+ /* (Could compare lower dimensions also, but not certain if
+ * that's worth it. - QAK, 2019/01/23)
+ */
+ if(span_info1->low_bounds[0] != span_info2->low_bounds[0])
+ HGOTO_DONE(FALSE)
+ else if(span_info1->high_bounds[0] != span_info2->high_bounds[0])
+ HGOTO_DONE(FALSE)
+ else {
+ const H5S_hyper_span_t *span1;
+ const H5S_hyper_span_t *span2;
+
+ /* Get the pointers to the actual lists of spans */
+ span1 = span_info1->head;
+ span2 = span_info2->head;
+
+ /* Sanity checking */
+ HDassert(span1);
+ HDassert(span2);
+
+ /* infinite loop which must be broken out of */
+ while(1) {
+ /* Check for both spans being NULL */
+ if(span1 == NULL && span2 == NULL)
+ HGOTO_DONE(TRUE)
else {
- /* Check if the actual low & high span information is the same */
- if(span1->low != span2->low || span1->high != span2->high) {
- ret_value = FALSE;
- break;
- } /* end if */
+ /* Check for one span being NULL */
+ if(span1 == NULL || span2 == NULL)
+ HGOTO_DONE(FALSE)
else {
- if(span1->down != NULL || span2 != NULL) {
- if(!H5S__hyper_cmp_spans(span1->down, span2->down)) {
- ret_value = FALSE;
- break;
+ /* Check if the actual low & high span information is the same */
+ if(span1->low != span2->low || span1->high != span2->high)
+ HGOTO_DONE(FALSE)
+ else {
+ if(span1->down != NULL || span2->down != NULL) {
+ if(!H5S__hyper_cmp_spans(span1->down, span2->down))
+ HGOTO_DONE(FALSE)
+ else {
+ /* Keep going... */
+ } /* end else */
} /* end if */
else {
/* Keep going... */
} /* end else */
- } /* end if */
- else {
- /* Keep going... */
} /* end else */
} /* end else */
} /* end else */
- } /* end else */
- /* Advance to the next nodes in the span list */
- span1 = span1->next;
- span2 = span2->next;
- } /* end while */
+ /* Advance to the next nodes in the span list */
+ span1 = span1->next;
+ span2 = span2->next;
+ } /* end while */
+ } /* end else */
} /* end else */
- } /* end else */
+ } /* end if */
+ /* Fall through, with default return value of 'TRUE' if spans were already visited */
+
+done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5S__hyper_cmp_spans() */
@@ -1516,10 +3092,10 @@ H5S__hyper_cmp_spans(const H5S_hyper_span_info_t *span_info1, const H5S_hyper_sp
PURPOSE
Free a hyperslab span info node
USAGE
- herr_t H5S__hyper_free_span_info(span_info)
+ void H5S__hyper_free_span_info(span_info)
H5S_hyper_span_info_t *span_info; IN: Span info node to free
RETURNS
- Non-negative on success, negative on failure
+ None
DESCRIPTION
Free a hyperslab span info node, along with all the span nodes and the
'down spans' from the nodes, if reducing their reference count to zero
@@ -1529,14 +3105,12 @@ H5S__hyper_cmp_spans(const H5S_hyper_span_info_t *span_info1, const H5S_hyper_sp
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-static herr_t
+static void
H5S__hyper_free_span_info(H5S_hyper_span_info_t *span_info)
{
- H5S_hyper_span_t *span, *next_span;
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_STATIC
+ FUNC_ENTER_STATIC_NOERR
+ /* Sanity check */
HDassert(span_info);
/* Decrement the span tree's reference count */
@@ -1544,22 +3118,28 @@ H5S__hyper_free_span_info(H5S_hyper_span_info_t *span_info)
/* Free the span tree if the reference count drops to zero */
if(span_info->count == 0) {
+ H5S_hyper_span_t *span; /* Pointer to spans to iterate over */
/* Work through the list of spans pointed to by this 'info' node */
span = span_info->head;
while(span != NULL) {
+ H5S_hyper_span_t *next_span; /* Pointer to next span to iterate over */
+
+ /* Keep a pointer to the next span */
next_span = span->next;
- if(H5S__hyper_free_span(span) < 0)
- HGOTO_ERROR(H5E_INTERNAL, H5E_CANTFREE, FAIL, "failed to release hyperslab span")
+
+ /* Free the current span */
+ H5S__hyper_free_span(span);
+
+ /* Advance to next span */
span = next_span;
} /* end while */
/* Free this span info */
- span_info = H5FL_FREE(H5S_hyper_span_info_t, span_info);
+ span_info = (H5S_hyper_span_info_t *)H5FL_ARR_FREE(hbounds_t, span_info);
} /* end if */
-done:
- FUNC_LEAVE_NOAPI(ret_value)
+ FUNC_LEAVE_NOAPI_VOID
} /* end H5S__hyper_free_span_info() */
@@ -1569,10 +3149,10 @@ done:
PURPOSE
Free a hyperslab span node
USAGE
- herr_t H5S__hyper_free_span(span)
+ void H5S__hyper_free_span(span)
H5S_hyper_span_t *span; IN: Span node to free
RETURNS
- Non-negative on success, negative on failure
+ None
DESCRIPTION
Free a hyperslab span node, along with the 'down spans' from the node,
if reducing their reference count to zero indicates it is appropriate to
@@ -1582,25 +3162,22 @@ done:
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-static herr_t
+static void
H5S__hyper_free_span(H5S_hyper_span_t *span)
{
- herr_t ret_value = SUCCEED;
-
- FUNC_ENTER_STATIC
+ FUNC_ENTER_STATIC_NOERR
+ /* Sanity check */
HDassert(span);
/* Decrement the reference count of the 'down spans', freeing them if appropriate */
if(span->down != NULL)
- if(H5S__hyper_free_span_info(span->down) < 0)
- HGOTO_ERROR(H5E_INTERNAL, H5E_CANTFREE, FAIL, "failed to release hyperslab span tree")
+ H5S__hyper_free_span_info(span->down);
/* Free this span */
span = H5FL_FREE(H5S_hyper_span_t, span);
-done:
- FUNC_LEAVE_NOAPI(ret_value)
+ FUNC_LEAVE_NOAPI_VOID
} /* end H5S__hyper_free_span() */
@@ -1610,11 +3187,12 @@ done:
PURPOSE
Copy a selection from one dataspace to another
USAGE
- herr_t H5S__hyper_copy(dst, src)
+ herr_t H5S__hyper_copy(dst, src, share_selection)
H5S_t *dst; OUT: Pointer to the destination dataspace
H5S_t *src; IN: Pointer to the source dataspace
+ hbool_t; IN: Whether to share the selection between the dataspaces
RETURNS
- Non-negative on success/Negative on failure
+ Non-negative on success, negative on failure
DESCRIPTION
Copies all the hyperslab selection information from the source
dataspace to the destination dataspace.
@@ -1651,15 +3229,8 @@ H5S__hyper_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection)
/* Copy the hyperslab information */
dst_hslab->diminfo_valid = src_hslab->diminfo_valid;
- if(src_hslab->diminfo_valid) {
- size_t u; /* Local index variable */
-
- for(u=0; u<src->extent.rank; u++) {
- dst_hslab->opt_diminfo[u]=src_hslab->opt_diminfo[u];
- dst_hslab->app_diminfo[u]=src_hslab->app_diminfo[u];
- } /* end for */
- } /* end if */
- dst->select.sel_info.hslab->span_lst=src->select.sel_info.hslab->span_lst;
+ if(src_hslab->diminfo_valid == H5S_DIMINFO_VALID_YES)
+ H5MM_memcpy(&dst_hslab->diminfo, &src_hslab->diminfo, sizeof(H5S_hyper_diminfo_t));
/* Check if there is hyperslab span information to copy */
/* (Regular hyperslab information is copied with the selection structure) */
@@ -1671,7 +3242,7 @@ H5S__hyper_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection)
} /* end if */
else
/* Copy the hyperslab span information */
- dst->select.sel_info.hslab->span_lst = H5S__hyper_copy_span(src->select.sel_info.hslab->span_lst);
+ dst->select.sel_info.hslab->span_lst = H5S__hyper_copy_span(src->select.sel_info.hslab->span_lst, src->extent.rank);
} /* end if */
else
dst->select.sel_info.hslab->span_lst = NULL;
@@ -1687,18 +3258,16 @@ done:
/*--------------------------------------------------------------------------
NAME
- H5S__hyper_is_valid_helper
+ H5S__hyper_is_valid
PURPOSE
Check whether the selection fits within the extent, with the current
offset defined.
USAGE
- hbool_t H5S__hyper_is_valid_helper(spans, offset, rank);
- const H5S_hyper_span_info_t *spans; IN: Pointer to current hyperslab span tree
- const hssize_t *offset; IN: Pointer to offset array
- const hsize_t *size; IN: Pointer to size array
- hsize_t rank; IN: Current rank looking at
+ htri_t H5S__hyper_is_valid(space);
+ H5S_t *space; IN: Dataspace pointer to query
RETURNS
- TRUE if the selection fits within the extent, FALSE if it does not
+ TRUE if the selection fits within the extent, FALSE if it does not and
+ Negative on an error.
DESCRIPTION
Determines if the current selection at the current offset fits within the
extent for the dataspace.
@@ -1707,109 +3276,109 @@ done:
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-static hbool_t
-H5S__hyper_is_valid_helper(const H5S_hyper_span_info_t *spans, const hssize_t *offset,
- const hsize_t *size)
+static htri_t
+H5S__hyper_is_valid(const H5S_t *space)
{
- H5S_hyper_span_t *curr; /* Hyperslab information nodes */
- hbool_t ret_value = TRUE; /* Return value */
+ const hsize_t *low_bounds, *high_bounds; /* Pointers to the correct pair of low & high bounds */
+ unsigned u; /* Counter */
+ htri_t ret_value = TRUE; /* return value */
FUNC_ENTER_STATIC_NOERR
- HDassert(spans);
- HDassert(offset);
- HDassert(size);
+ HDassert(space);
- /* Check each point to determine whether selection + offset is within extent */
- curr = spans->head;
- while(curr != NULL) {
- /* Check if an offset has been defined */
- /* Bounds check the selected point + offset against the extent */
- if((((hssize_t)curr->low + *offset) >= (hssize_t)*size)
- || (((hssize_t)curr->low + *offset) < 0)
- || (((hssize_t)curr->high + *offset) >= (hssize_t)*size)
- || (((hssize_t)curr->high + *offset) < 0))
- HGOTO_DONE(FALSE)
+ /* Check for unlimited selection */
+ if(space->select.sel_info.hslab->unlim_dim >= 0)
+ HGOTO_DONE(FALSE)
- /* Recurse if this node has down spans */
- if(curr->down != NULL)
- if(!H5S__hyper_is_valid_helper(curr->down, offset + 1, size + 1))
- HGOTO_DONE(FALSE)
+ /* Check which set of low & high bounds we should be using */
+ if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) {
+ low_bounds = space->select.sel_info.hslab->diminfo.low_bounds;
+ high_bounds = space->select.sel_info.hslab->diminfo.high_bounds;
+ } /* end if */
+ else {
+ low_bounds = space->select.sel_info.hslab->span_lst->low_bounds;
+ high_bounds = space->select.sel_info.hslab->span_lst->high_bounds;
+ } /* end else */
- /* Advance to next node */
- curr = curr->next;
- } /* end while */
+ /* Check each dimension */
+ for(u = 0; u < space->extent.rank; u++) {
+ /* Bounds check the selected point + offset against the extent */
+ if(((hssize_t)low_bounds[u] + space->select.offset[u]) < 0)
+ HGOTO_DONE(FALSE)
+ if((high_bounds[u] + (hsize_t)space->select.offset[u]) >= space->extent.size[u])
+ HGOTO_DONE(FALSE)
+ } /* end for */
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5S__hyper_is_valid_helper() */
+} /* end H5S__hyper_is_valid() */
/*--------------------------------------------------------------------------
NAME
- H5S__hyper_is_valid
+ H5S__hyper_span_nblocks_helper
PURPOSE
- Check whether the selection fits within the extent, with the current
- offset defined.
+ Helper routine to count the number of blocks in a span tree
USAGE
- htri_t H5S__hyper_is_valid(space);
- H5S_t *space; IN: Dataspace pointer to query
+ hsize_t H5S__hyper_span_nblocks_helper(spans)
+ H5S_hyper_span_info_t *spans; IN: Hyperslab span tree to count blocks of
+ uint64_t op_gen; IN: Operation generation
RETURNS
- TRUE if the selection fits within the extent, FALSE if it does not and
- Negative on an error.
+ Number of blocks in span tree on success; negative on failure
DESCRIPTION
- Determines if the current selection at the current offset fits within the
- extent for the dataspace.
+ Counts the number of blocks described by the spans in a span tree.
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-static htri_t
-H5S__hyper_is_valid(const H5S_t *space)
+static hsize_t
+H5S__hyper_span_nblocks_helper(H5S_hyper_span_info_t *spans, uint64_t op_gen)
{
- htri_t ret_value = TRUE; /* return value */
+ hsize_t ret_value = 0; /* Return value */
FUNC_ENTER_STATIC_NOERR
- HDassert(space);
+ /* Sanity check */
+ HDassert(spans);
- /* Check for unlimited selection */
- if(space->select.sel_info.hslab->unlim_dim >= 0)
- HGOTO_DONE(FALSE)
+ /* Check if the span tree was already counted */
+ if(spans->op_gen == op_gen)
+ /* Just return the # of blocks in the already counted span tree */
+ ret_value = spans->u.nblocks;
+ else { /* Count the number of elements in the span tree */
+ H5S_hyper_span_t *span; /* Hyperslab span */
- /* Check for a "regular" hyperslab selection */
- if(space->select.sel_info.hslab->diminfo_valid) {
- const H5S_hyper_dim_t *diminfo=space->select.sel_info.hslab->opt_diminfo; /* local alias for diminfo */
- hssize_t end; /* The high bound of a region in a dimension */
- unsigned u; /* Counter */
+ span = spans->head;
+ if(span->down) {
+ while(span) {
+ /* If there are down spans, add the total down span blocks */
+ ret_value += H5S__hyper_span_nblocks_helper(span->down, op_gen);
- /* Check each dimension */
- for(u = 0; u < space->extent.rank; u++) {
- /* if block or count is zero, then can skip the test since */
- /* no data point is chosen */
- if(diminfo[u].count && diminfo[u].block) {
- /* Bounds check the start point in this dimension */
- if(((hssize_t)diminfo[u].start + space->select.offset[u]) < 0 ||
- ((hssize_t)diminfo[u].start + space->select.offset[u]) >= (hssize_t)space->extent.size[u])
- HGOTO_DONE(FALSE)
+ /* Advance to next span */
+ span = span->next;
+ } /* end while */
+ } /* end if */
+ else {
+ while(span) {
+ /* If there are no down spans, just count the block in this span */
+ ret_value++;
- /* Compute the largest location in this dimension */
- end = (hssize_t)(diminfo[u].start + diminfo[u].stride * (diminfo[u].count - 1) + (diminfo[u].block - 1)) + space->select.offset[u];
+ /* Advance to next span */
+ span = span->next;
+ } /* end while */
+ } /* end else */
- /* Bounds check the end point in this dimension */
- if(end < 0 || end >= (hssize_t)space->extent.size[u])
- HGOTO_DONE(FALSE)
- } /* end if */
- } /* end for */
- } /* end if */
- else
- /* Call the recursive routine to validate the span tree */
- ret_value = H5S__hyper_is_valid_helper(space->select.sel_info.hslab->span_lst, space->select.offset, space->extent.size);
+ /* Set the operation generation for this span tree, to avoid re-computing */
+ spans->op_gen = op_gen;
+
+ /* Hold a copy of the # of blocks */
+ spans->u.nblocks = ret_value;
+ } /* end else */
-done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5S__hyper_is_valid() */
+} /* end H5S__hyper_span_nblocks_helper() */
/*--------------------------------------------------------------------------
@@ -1819,7 +3388,7 @@ done:
Count the number of blocks in a span tree
USAGE
hsize_t H5S__hyper_span_nblocks(spans)
- const H5S_hyper_span_info_t *spans; IN: Hyperslab span tree to count elements of
+ H5S_hyper_span_info_t *spans; IN: Hyperslab span tree to count blocks of
RETURNS
Number of blocks in span tree on success; negative on failure
DESCRIPTION
@@ -1830,7 +3399,7 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
static hsize_t
-H5S__hyper_span_nblocks(const H5S_hyper_span_info_t *spans)
+H5S__hyper_span_nblocks(H5S_hyper_span_info_t *spans)
{
hsize_t ret_value = 0; /* Return value */
@@ -1838,21 +3407,13 @@ H5S__hyper_span_nblocks(const H5S_hyper_span_info_t *spans)
/* Count the number of elements in the span tree */
if(spans != NULL) {
- H5S_hyper_span_t *span; /* Hyperslab span */
+ uint64_t op_gen; /* Operation generation value */
- span = spans->head;
- while(span != NULL) {
- /* If there are down spans, add the total down span blocks */
- if(span->down != NULL)
- ret_value += H5S__hyper_span_nblocks(span->down);
- /* If there are no down spans, just count the block in this span */
- else
- ret_value++;
+ /* Acquire an operation generation value for this operation */
+ op_gen = H5S__hyper_get_op_gen();
- /* Advance to next span */
- span = span->next;
- } /* end while */
- } /* end else */
+ ret_value = H5S__hyper_span_nblocks_helper(spans, op_gen);
+ } /* end if */
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5S__hyper_span_nblocks() */
@@ -1864,8 +3425,9 @@ H5S__hyper_span_nblocks(const H5S_hyper_span_info_t *spans)
PURPOSE
Get the number of hyperslab blocks in current hyperslab selection
USAGE
- hsize_t H5S__get_select_hyper_nblocks(space)
+ hsize_t H5S__get_select_hyper_nblocks(space, app_ref)
H5S_t *space; IN: Dataspace ptr of selection to query
+ hbool_t app_ref; IN: Whether this is an appl. ref. call
RETURNS
The number of hyperslab blocks in selection on success, negative on failure
DESCRIPTION
@@ -1876,7 +3438,7 @@ H5S__hyper_span_nblocks(const H5S_hyper_span_info_t *spans)
REVISION LOG
--------------------------------------------------------------------------*/
static hsize_t
-H5S__get_select_hyper_nblocks(const H5S_t *space)
+H5S__get_select_hyper_nblocks(const H5S_t *space, hbool_t app_ref)
{
hsize_t ret_value = 0; /* Return value */
@@ -1886,12 +3448,14 @@ H5S__get_select_hyper_nblocks(const H5S_t *space)
HDassert(space->select.sel_info.hslab->unlim_dim < 0);
/* Check for a "regular" hyperslab selection */
- if(space->select.sel_info.hslab->diminfo_valid) {
+ /* (No need to rebuild the dimension info yet -QAK) */
+ if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) {
unsigned u; /* Local index variable */
/* Check each dimension */
for(ret_value = 1, u = 0; u < space->extent.rank; u++)
- ret_value *= space->select.sel_info.hslab->app_diminfo[u].count;
+ ret_value *= (app_ref ? space->select.sel_info.hslab->diminfo.app[u].count :
+ space->select.sel_info.hslab->diminfo.opt[u].count);
} /* end if */
else
ret_value = H5S__hyper_span_nblocks(space->select.sel_info.hslab->span_lst);
@@ -1934,7 +3498,7 @@ H5Sget_select_hyper_nblocks(hid_t spaceid)
if(space->select.sel_info.hslab->unlim_dim >= 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "cannot get number of blocks for unlimited selection")
- ret_value = (hssize_t)H5S__get_select_hyper_nblocks(space);
+ ret_value = (hssize_t)H5S__get_select_hyper_nblocks(space, TRUE);
done:
FUNC_LEAVE_API(ret_value)
@@ -1943,6 +3507,207 @@ done:
/*--------------------------------------------------------------------------
NAME
+ H5S__hyper_get_enc_size_real
+ PURPOSE
+ Determine the size to encode the hyperslab selection info
+ USAGE
+ hssize_t H5S__hyper_get_enc_size_real(max_size, enc_size)
+ hsize_t max_size: IN: The maximum size of the hyperslab selection info
+ unint8_t *enc_size: OUT:The encoding size
+ RETURNS
+ The size to encode hyperslab selection info
+ DESCRIPTION
+ Determine the size by comparing "max_size" with (2^32 - 1) and (2^16 - 1).
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+static uint8_t
+H5S__hyper_get_enc_size_real(hsize_t max_size)
+{
+ uint8_t ret_value = H5S_SELECT_INFO_ENC_SIZE_2;
+
+ FUNC_ENTER_STATIC_NOERR
+
+ if(max_size > H5S_UINT32_MAX)
+ ret_value = H5S_SELECT_INFO_ENC_SIZE_8;
+ else if(max_size > H5S_UINT16_MAX)
+ ret_value = H5S_SELECT_INFO_ENC_SIZE_4;
+ else
+ ret_value = H5S_SELECT_INFO_ENC_SIZE_2;
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5S__hyper_get_enc_size_real() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S__hyper_get_version_enc_size
+ PURPOSE
+ Determine the version and encoded size to use for encoding hyperslab selection info
+ USAGE
+ hssize_t H5S__hyper_get_version_enc_size(space, block_count, version, enc_size)
+ const H5S_t *space: IN: The dataspace
+ hsize_t block_count: IN: The number of blocks in the selection
+ uint32_t *version: OUT: The version to use for encoding
+ uint8_t *enc_size: OUT: The encoded size to use
+
+ RETURNS
+ The version and the size to encode hyperslab selection info
+ DESCRIPTION
+ Determine the version to use for encoding hyperslab selection info based
+ on the following:
+ (1) the file format setting in fapl
+ (2) whether the number of blocks or selection high bounds exceeds H5S_UINT32_MAX or not
+
+ Determine the encoded size based on version:
+ For version 3, the encoded size is determined according to:
+ (a) regular hyperslab
+ (1) The maximum needed to store start/stride/count/block
+ (2) Special handling for count/block: need to provide room for H5S_UNLIMITED
+ (b) irregular hyperslab
+ The maximum size needed to store:
+ (1) the number of blocks
+ (2) the selection high bounds
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+static herr_t
+H5S__hyper_get_version_enc_size(const H5S_t *space, hsize_t block_count, uint32_t *version, uint8_t *enc_size)
+{
+ hsize_t bounds_start[H5S_MAX_RANK]; /* Starting coordinate of bounding box */
+ hsize_t bounds_end[H5S_MAX_RANK]; /* Opposite coordinate of bounding box */
+ hbool_t count_up_version = FALSE; /* Whether number of blocks exceed H5S_UINT32_MAX */
+ hbool_t bound_up_version = FALSE; /* Whether high bounds exceed H5S_UINT32_MAX */
+ H5F_libver_t low_bound; /* The 'low' bound of library format versions */
+ H5F_libver_t high_bound; /* The 'high' bound of library format versions */
+ htri_t is_regular; /* A regular hyperslab or not */
+ uint32_t tmp_version; /* Local temporay version */
+ unsigned u; /* Local index variable */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_STATIC
+
+ /* Get bounding box for the selection */
+ HDmemset(bounds_end, 0, sizeof(bounds_end));
+
+ if(space->select.sel_info.hslab->unlim_dim < 0) /* ! H5S_UNLIMITED */
+ /* Get bounding box for the selection */
+ if(H5S__hyper_bounds(space, bounds_start, bounds_end) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get selection bounds")
+
+ /* Determine whether the number of blocks or the high bounds in the selection exceed (2^32 - 1) */
+ if(block_count > H5S_UINT32_MAX)
+ count_up_version = TRUE;
+ else {
+ for(u = 0; u < space->extent.rank; u++)
+ if(bounds_end[u] > H5S_UINT32_MAX) {
+ bound_up_version = TRUE;
+ break;
+ } /* end if */
+ } /* end else */
+
+ /* Get the file's low_bound and high_bound */
+ if(H5CX_get_libver_bounds(&low_bound, &high_bound) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get low/high bounds from API context")
+
+ /* Determine regular hyperslab */
+ is_regular = H5S__hyper_is_regular(space);
+
+ if(low_bound >= H5F_LIBVER_V112 || space->select.sel_info.hslab->unlim_dim >= 0)
+ tmp_version = MAX(H5S_HYPER_VERSION_2, H5O_sds_hyper_ver_bounds[low_bound]);
+ else {
+ if(count_up_version || bound_up_version)
+ tmp_version = is_regular ? H5S_HYPER_VERSION_2 : H5S_HYPER_VERSION_3;
+ else
+ tmp_version = (is_regular && block_count >= 4) ? H5O_sds_hyper_ver_bounds[low_bound] : H5S_HYPER_VERSION_1;
+ } /* end else */
+
+ /* Version bounds check */
+ if(tmp_version > H5O_sds_hyper_ver_bounds[high_bound]) {
+ /* Fail for irregular hyperslab if exceeds 32 bits */
+ if(count_up_version)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "The number of blocks in hyperslab selection exceeds 2^32")
+ else if(bound_up_version)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "The end of bounding box in hyperslab selection exceeds 2^32")
+ else
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "Dataspace hyperslab selection version out of bounds")
+ } /* end if */
+
+ /* Set the message version */
+ *version = tmp_version;
+
+ /* Determine the encoded size based on version */
+ switch(tmp_version) {
+ case H5S_HYPER_VERSION_1:
+ *enc_size = H5S_SELECT_INFO_ENC_SIZE_4;
+ break;
+
+ case H5S_HYPER_VERSION_2:
+ *enc_size = H5S_SELECT_INFO_ENC_SIZE_8;
+ break;
+
+ case H5S_HYPER_VERSION_3:
+ if(is_regular) {
+ uint8_t enc1, enc2;
+ hsize_t max1 = 0;
+ hsize_t max2 = 0;
+
+ /* Find max for count[] and block[] */
+ for(u = 0; u < space->extent.rank; u++) {
+ if(space->select.sel_info.hslab->diminfo.opt[u].count != H5S_UNLIMITED &&
+ space->select.sel_info.hslab->diminfo.opt[u].count > max1)
+ max1 = space->select.sel_info.hslab->diminfo.opt[u].count;
+ if(space->select.sel_info.hslab->diminfo.opt[u].block != H5S_UNLIMITED &&
+ space->select.sel_info.hslab->diminfo.opt[u].block > max1)
+ max1 = space->select.sel_info.hslab->diminfo.opt[u].block;
+ } /* end for */
+
+ /* +1 to provide room for H5S_UNLIMITED */
+ enc1 = H5S__hyper_get_enc_size_real(++max1);
+
+ /* Find max for start[] and stride[] */
+ for(u = 0; u < space->extent.rank; u++) {
+ if(space->select.sel_info.hslab->diminfo.opt[u].start > max2)
+ max2 = space->select.sel_info.hslab->diminfo.opt[u].start;
+ if(space->select.sel_info.hslab->diminfo.opt[u].stride > max2)
+ max2 = space->select.sel_info.hslab->diminfo.opt[u].stride;
+ } /* end for */
+
+ /* Determine the encoding size */
+ enc2 = H5S__hyper_get_enc_size_real(max2);
+
+ *enc_size = MAX(enc1, enc2);
+ } /* end if */
+ else {
+ hsize_t max_size = block_count;
+ HDassert(space->select.sel_info.hslab->unlim_dim < 0);
+
+ /* Find max for block_count and bounds_end[] */
+ for(u = 0; u < space->extent.rank; u++)
+ if(bounds_end[u] > max_size)
+ max_size = bounds_end[u];
+
+ /* Determine the encoding size */
+ *enc_size = H5S__hyper_get_enc_size_real(max_size);
+ } /* end else */
+ break;
+
+ default:
+ HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unknown hyperslab selection version")
+ break;
+ } /* end switch */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5S__hyper_get_version_enc_size() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
H5S__hyper_serial_size
PURPOSE
Determine the number of bytes needed to store the serialized hyperslab
@@ -1963,49 +3728,74 @@ done:
static hssize_t
H5S__hyper_serial_size(const H5S_t *space)
{
- hsize_t block_count; /* block counter for regular hyperslabs */
- unsigned u; /* Counter */
- hssize_t ret_value = -1; /* return value */
+ hsize_t block_count = 0; /* block counter for regular hyperslabs */
+ uint32_t version; /* Version number */
+ uint8_t enc_size; /* Encoded size of hyerslab selection info */
+ hssize_t ret_value = -1; /* return value */
- FUNC_ENTER_STATIC_NOERR
+ FUNC_ENTER_STATIC
HDassert(space);
- /* Check for version (right now, an unlimited dimension is the only thing
- * that would bump the version) */
- if(space->select.sel_info.hslab->unlim_dim >= 0)
+ if(space->select.sel_info.hslab->unlim_dim < 0) /* ! H5S_UNLIMITED */
+ block_count = H5S__get_select_hyper_nblocks(space, FALSE);
+
+ /* Determine the version and the encoded size */
+ if(H5S__hyper_get_version_enc_size(space, block_count, &version, &enc_size) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't determine hyper version & enc_size")
+
+ if(version == H5S_HYPER_VERSION_3) {
+ /* Version 3: regular */
+ /* Size required is always:
+ * <type (4 bytes)> + <version (4 bytes)> + <flags (1 byte)> +
+ * <size of offset info (1 byte)> + <rank (4 bytes)> +
+ * (4 (start/stride/count/block) * <enc_size> * <rank>) =
+ * 14 + (4 * enc_size * rank) bytes
+ */
+ if(H5S__hyper_is_regular(space))
+ ret_value = (hssize_t)14 +
+ ((hssize_t)4 * (hssize_t)enc_size * (hssize_t)space->extent.rank);
+ else {
+ /* Version 3: irregular */
+ /* Size required is always:
+ * <type (4 bytes)> + <version (4 bytes)> + <flags (1 byte)> +
+ * <size of offset info (1 byte)> + <rank (4 bytes)> +
+ * < # of blocks (depend on enc_size) > +
+ * (2 (starting/ending offset) * <rank> * <enc_size> * <# of blocks) =
+ * = 14 bytes + enc_size (block_count) + (2 * enc_size * rank * block_count) bytes
+ */
+ ret_value = 14 + enc_size;
+ H5_CHECK_OVERFLOW(((unsigned)2 * enc_size * space->extent.rank * block_count), hsize_t, hssize_t);
+ ret_value += (hssize_t)((unsigned)2 * enc_size * space->extent.rank * block_count);
+ } /* end else */
+ } /* end if */
+ else if(version == H5S_HYPER_VERSION_2) {
/* Version 2 */
/* Size required is always:
* <type (4 bytes)> + <version (4 bytes)> + <flags (1 byte)> +
* <length (4 bytes)> + <rank (4 bytes)> +
- * (4 (start/stride/count/block) * <rank> * <value (8 bytes)>) =
- * 17 + (4 * rank * 8) bytes
+ * (4 (start/stride/count/block) * <enc_size (8 bytes)> * <rank>) =
+ * 17 + (4 * 8 * rank) bytes
*/
- ret_value = (hssize_t)17 + ((hssize_t)4 * (hssize_t)space->extent.rank
- * (hssize_t)8);
+ HDassert(enc_size == 8);
+ ret_value = (hssize_t)17 + ((hssize_t)4 * (hssize_t)8 * (hssize_t)space->extent.rank);
+ } /* end else-if */
else {
+ HDassert(version == H5S_HYPER_VERSION_1);
+ HDassert(enc_size == 4);
/* Version 1 */
/* Basic number of bytes required to serialize hyperslab selection:
* <type (4 bytes)> + <version (4 bytes)> + <padding (4 bytes)> +
- * <length (4 bytes)> + <rank (4 bytes)> + <# of blocks (4 bytes)>
- * = 24 bytes
+ * <length (4 bytes)> + <rank (4 bytes)> + <# of blocks (4 bytes)> +
+ * (2 (starting/ending offset) * <enc_size (4 bytes)> * <rank> * <# of blocks) =
+ * = 24 bytes + (2 * 4 * rank * block_count)
*/
ret_value = 24;
-
- /* Check for a "regular" hyperslab selection */
- if(space->select.sel_info.hslab->diminfo_valid) {
- /* Check each dimension */
- for(block_count = 1, u = 0; u < space->extent.rank; u++)
- block_count *= space->select.sel_info.hslab->opt_diminfo[u].count;
- } /* end if */
- else
- /* Spin through hyperslab spans, adding 8 * rank bytes for each block */
- block_count = H5S__hyper_span_nblocks(space->select.sel_info.hslab->span_lst);
-
H5_CHECK_OVERFLOW((8 * space->extent.rank * block_count), hsize_t, hssize_t);
- ret_value += (hssize_t)(8 * block_count * space->extent.rank);
+ ret_value += (hssize_t)(8 * space->extent.rank * block_count);
} /* end else */
+done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5S__hyper_serial_size() */
@@ -2016,12 +3806,13 @@ 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)
+ void H5S__hyper_serialize_helper(spans, start, end, rank, enc_size, 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
+ uint8_t enc_size IN: Encoded size of hyperslab selection info
+ uint8_t *buf; OUT: Buffer to put serialized selection into
RETURNS
None
DESCRIPTION
@@ -2034,7 +3825,7 @@ H5S__hyper_serial_size(const H5S_t *space)
--------------------------------------------------------------------------*/
static void
H5S__hyper_serialize_helper(const H5S_hyper_span_info_t *spans,
- hsize_t *start, hsize_t *end, hsize_t rank, uint8_t **p)
+ hsize_t *start, hsize_t *end, hsize_t rank, uint8_t enc_size, uint8_t **p)
{
H5S_hyper_span_t *curr; /* Pointer to current hyperslab span */
uint8_t *pp = (*p); /* Local pointer for decoding */
@@ -2045,7 +3836,7 @@ H5S__hyper_serialize_helper(const H5S_hyper_span_info_t *spans,
HDassert(spans);
HDassert(start);
HDassert(end);
- HDassert(rank < H5O_LAYOUT_NDIMS);
+ HDassert(rank < H5S_MAX_RANK);
HDassert(p && pp);
/* Walk through the list of spans, recursing or outputting them */
@@ -2058,26 +3849,65 @@ H5S__hyper_serialize_helper(const H5S_hyper_span_info_t *spans,
end[rank] = curr->high;
/* Recurse down to the next dimension */
- H5S__hyper_serialize_helper(curr->down, start, end, rank + 1, &pp);
+ H5S__hyper_serialize_helper(curr->down, start, end, rank + 1, enc_size, &pp);
} /* end if */
else {
hsize_t u; /* Index variable */
/* Encode all the previous dimensions starting & ending points */
+ switch(enc_size) {
+ case H5S_SELECT_INFO_ENC_SIZE_2:
+ /* Encode previous starting points */
+ for(u=0; u<rank; u++)
+ UINT16ENCODE(pp, (uint16_t)start[u]);
- /* Encode previous starting points */
- for(u = 0; u < rank; u++)
- UINT32ENCODE(pp, (uint32_t)start[u]);
+ /* Encode starting point for this span */
+ UINT16ENCODE(pp, (uint16_t)curr->low);
- /* Encode starting point for this span */
- UINT32ENCODE(pp, (uint32_t)curr->low);
+ /* Encode previous ending points */
+ for(u=0; u<rank; u++)
+ UINT16ENCODE(pp, (uint16_t)end[u]);
- /* Encode previous ending points */
- for(u = 0; u < rank; u++)
- UINT32ENCODE(pp, (uint32_t)end[u]);
+ /* Encode starting point for this span */
+ UINT16ENCODE(pp, (uint16_t)curr->high);
+ break;
+
+ case H5S_SELECT_INFO_ENC_SIZE_4:
+ /* Encode previous starting points */
+ for(u=0; u<rank; u++)
+ UINT32ENCODE(pp, (uint32_t)start[u]);
+
+ /* Encode starting point for this span */
+ UINT32ENCODE(pp, (uint32_t)curr->low);
+
+ /* Encode previous ending points */
+ for(u=0; u<rank; u++)
+ UINT32ENCODE(pp, (uint32_t)end[u]);
+
+ /* Encode starting point for this span */
+ UINT32ENCODE(pp, (uint32_t)curr->high);
+ break;
+
+ case H5S_SELECT_INFO_ENC_SIZE_8:
+ /* Encode previous starting points */
+ for(u=0; u<rank; u++)
+ UINT64ENCODE(pp, (uint64_t)start[u]);
+
+ /* Encode starting point for this span */
+ UINT64ENCODE(pp, (uint64_t)curr->low);
- /* Encode starting point for this span */
- UINT32ENCODE(pp, (uint32_t)curr->high);
+ /* Encode previous ending points */
+ for(u=0; u<rank; u++)
+ UINT64ENCODE(pp, (uint64_t)end[u]);
+
+ /* Encode starting point for this span */
+ UINT64ENCODE(pp, (uint64_t)curr->high);
+ break;
+
+ default:
+ HDassert(0 && "Unknown enc size?!?");
+
+ } /* end switch */
} /* end else */
/* Advance to next node */
@@ -2088,7 +3918,7 @@ H5S__hyper_serialize_helper(const H5S_hyper_span_info_t *spans,
*p = pp;
FUNC_LEAVE_NOAPI_VOID
-} /* H5S__hyper_serialize_helper() */
+} /* end H5S__hyper_serialize_helper() */
/*--------------------------------------------------------------------------
@@ -2115,14 +3945,26 @@ H5S__hyper_serialize_helper(const H5S_hyper_span_info_t *spans,
static herr_t
H5S__hyper_serialize(const H5S_t *space, uint8_t **p)
{
- uint8_t *pp; /* Local pointer for decoding */
- uint8_t *lenp; /* Pointer to length location for later storage */
- uint32_t len = 0; /* Number of bytes used */
+ const H5S_hyper_dim_t *diminfo; /* Alias for dataspace's diminfo information */
+ hsize_t tmp_count[H5S_MAX_RANK]; /* Temporary hyperslab counts */
+ hsize_t offset[H5S_MAX_RANK]; /* Offset of element in dataspace */
+ hsize_t start[H5S_MAX_RANK]; /* Location of start of hyperslab */
+ hsize_t end[H5S_MAX_RANK]; /* Location of end of hyperslab */
+ uint8_t *pp; /* Local pointer for decoding */
+ uint8_t *lenp = NULL; /* pointer to length location for later storage */
+ uint32_t len = 0; /* number of bytes used */
uint32_t version; /* Version number */
uint8_t flags = 0; /* Flags for message */
- hsize_t block_count; /* Block counter for regular hyperslabs */
+ hsize_t block_count = 0; /* block counter for regular hyperslabs */
+ unsigned fast_dim; /* Rank of the fastest changing dimension for the dataspace */
+ unsigned ndims; /* Rank of the dataspace */
+ unsigned u; /* Local counting variable */
+ hbool_t complete = FALSE; /* Whether we are done with the iteration */
+ hbool_t is_regular; /* Whether selection is regular */
+ uint8_t enc_size;
+ herr_t ret_value = SUCCEED; /* return value */
- FUNC_ENTER_STATIC_NOERR
+ FUNC_ENTER_STATIC
/* Sanity checks */
HDassert(space);
@@ -2130,161 +3972,228 @@ H5S__hyper_serialize(const H5S_t *space, uint8_t **p)
pp = (*p);
HDassert(pp);
- /* Calculate version */
- if(space->select.sel_info.hslab->unlim_dim >= 0) {
- version = 2;
- flags |= H5S_SELECT_FLAG_UNLIM;
- } /* end if */
- else
- version = 1;
+ /* Set some convienence values */
+ ndims = space->extent.rank;
+ diminfo = space->select.sel_info.hslab->diminfo.opt;
+
+ if(space->select.sel_info.hslab->unlim_dim < 0) /* ! H5S_UNLIMITED */
+ block_count = H5S__get_select_hyper_nblocks(space, FALSE);
+
+ /* Determine the version and the encoded size */
+ if(H5S__hyper_get_version_enc_size(space, block_count, &version, &enc_size) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't determine hyper version & enc_size")
+
+ is_regular = H5S__hyper_is_regular(space);
+ if(is_regular &&
+ (version == H5S_HYPER_VERSION_2 || version == H5S_HYPER_VERSION_3))
+ flags |= H5S_HYPER_REGULAR;
/* 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 */
- if(version >= 2)
- *(pp)++ = 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 */
- /* Encode number of dimensions */
- UINT32ENCODE(pp, (uint32_t)space->extent.rank);
- len += 4;
+ if(version >= 3) {
+ *(pp)++ = flags; /* Store the flags */
+ *(pp)++ = enc_size; /* Store size of offset info */
+ } /* end if */
+ else {
+ if(version == 2)
+ *(pp)++ = 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 */
- /* If there is an unlimited dimension, only encode opt_unlim_diminfo */
- if(flags & H5S_SELECT_FLAG_UNLIM) {
- unsigned i;
+ len += 4; /* ndims */
+ } /* end else */
- HDassert(H5S_UNLIMITED == HSIZE_UNDEF);
+ /* Encode number of dimensions */
+ UINT32ENCODE(pp, (uint32_t)ndims);
- /* Iterate over dimensions */
- for(i = 0; i < space->extent.rank; i++) {
+ if(is_regular) {
+ if(version >= H5S_HYPER_VERSION_2) {
+ HDassert(H5S_UNLIMITED == HSIZE_UNDEF);
+
+ /* Iterate over dimensions */
/* 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);
- } /* end for */
- } /* end if */
- /* Check for a "regular" hyperslab selection */
- else if(space->select.sel_info.hslab->diminfo_valid) {
- const H5S_hyper_dim_t *diminfo; /* Alias for dataspace's diminfo information */
- hsize_t offset[H5O_LAYOUT_NDIMS]; /* Offset of element in dataspace */
- hsize_t tmp_count[H5O_LAYOUT_NDIMS]; /* Temporary hyperslab counts */
- unsigned fast_dim; /* Rank of the fastest changing dimension for the dataspace */
- unsigned ndims; /* Rank of the dataspace */
- unsigned u; /* Local counting variable */
- hbool_t done; /* Whether we are done with the iteration */
+ switch(enc_size) {
+ case H5S_SELECT_INFO_ENC_SIZE_2:
+ HDassert(version == H5S_HYPER_VERSION_3);
+ for(u = 0; u < space->extent.rank; u++) {
+ UINT16ENCODE(pp, diminfo[u].start);
+ UINT16ENCODE(pp, diminfo[u].stride);
+ if(diminfo[u].count == H5S_UNLIMITED)
+ UINT16ENCODE(pp, H5S_UINT16_MAX)
+ else
+ UINT16ENCODE(pp, diminfo[u].count)
+ if(diminfo[u].block == H5S_UNLIMITED)
+ UINT16ENCODE(pp, H5S_UINT16_MAX)
+ else
+ UINT16ENCODE(pp, diminfo[u].block)
+ } /* end for */
+ break;
- /* Set some convenience values */
- ndims = space->extent.rank;
- fast_dim = ndims - 1;
- diminfo = space->select.sel_info.hslab->opt_diminfo;
+ case H5S_SELECT_INFO_ENC_SIZE_4:
+ HDassert(version == H5S_HYPER_VERSION_3);
+ for(u = 0; u < space->extent.rank; u++) {
+ UINT32ENCODE(pp, diminfo[u].start);
+ UINT32ENCODE(pp, diminfo[u].stride);
+ if(diminfo[u].count == H5S_UNLIMITED)
+ UINT32ENCODE(pp, H5S_UINT32_MAX)
+ else
+ UINT32ENCODE(pp, diminfo[u].count)
+ if(diminfo[u].block == H5S_UNLIMITED)
+ UINT32ENCODE(pp, H5S_UINT32_MAX)
+ else
+ UINT32ENCODE(pp, diminfo[u].block)
+ } /* end for */
+ break;
- /* Check each dimension */
- for(block_count = 1, u = 0; u < ndims; u++)
- block_count *= diminfo[u].count;
+ case H5S_SELECT_INFO_ENC_SIZE_8:
+ HDassert(version == H5S_HYPER_VERSION_2 || version == H5S_HYPER_VERSION_3);
+ for(u = 0; u < space->extent.rank; u++) {
+ UINT64ENCODE(pp, diminfo[u].start);
+ UINT64ENCODE(pp, diminfo[u].stride);
+ if(diminfo[u].count == H5S_UNLIMITED)
+ UINT64ENCODE(pp, H5S_UINT64_MAX)
+ else
+ UINT64ENCODE(pp, diminfo[u].count)
+ if(diminfo[u].block == H5S_UNLIMITED)
+ UINT64ENCODE(pp, H5S_UINT64_MAX)
+ else
+ UINT64ENCODE(pp, diminfo[u].block)
+ } /* end for */
+ if(version == H5S_HYPER_VERSION_2)
+ len += (4 * space->extent.rank * 8);
+ break;
+ default:
+ HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unknown offset info size for hyperslab")
+ break;
+ } /* end switch */
+ } /* end if */
+ else {
+ HDassert(version == H5S_HYPER_VERSION_1);
+
+ /* Set some convienence values */
+ fast_dim = ndims - 1;
- /* Encode number of hyperslabs */
- H5_CHECK_OVERFLOW(block_count, hsize_t, uint32_t);
- UINT32ENCODE(pp, (uint32_t)block_count);
- len += 4;
+ /* Encode number of hyperslabs */
+ H5_CHECK_OVERFLOW(block_count, hsize_t, uint32_t);
+ UINT32ENCODE(pp, (uint32_t)block_count);
+ len += 4;
- /* Now serialize the information for the regular hyperslab */
+ /* Now serialize the information for the regular hyperslab */
- /* Build the tables of count sizes as well as the initial offset */
- for(u = 0; u < ndims; u++) {
- tmp_count[u] = diminfo[u].count;
- offset[u] = diminfo[u].start;
- } /* end for */
+ /* Build the tables of count sizes as well as the initial offset */
+ for(u = 0; u < ndims; u++) {
+ tmp_count[u] = diminfo[u].count;
+ offset[u] = diminfo[u].start;
+ } /* end for */
- /* We're not done with the iteration */
- done = FALSE;
+ /* Go iterate over the hyperslabs */
+ while(complete == FALSE) {
+ /* Iterate over the blocks in the fastest dimension */
+ while(tmp_count[fast_dim] > 0) {
+ /* Add 8 bytes times the rank for each hyperslab selected */
+ len += 8 * ndims;
- /* Go iterate over the hyperslabs */
- while(done == FALSE) {
- /* Iterate over the blocks in the fastest dimension */
- while(tmp_count[fast_dim] > 0) {
- /* Add 8 bytes times the rank for each hyperslab selected */
- len += 8 * ndims;
+ /* Encode hyperslab starting location */
+ for(u = 0; u < ndims; u++)
+ UINT32ENCODE(pp, (uint32_t)offset[u]);
- /* Encode hyperslab starting location */
- for(u = 0; u < ndims; u++)
- UINT32ENCODE(pp, (uint32_t)offset[u]);
+ /* Encode hyperslab ending location */
+ for(u = 0; u < ndims; u++)
+ UINT32ENCODE(pp, (uint32_t)(offset[u] + (diminfo[u].block - 1)));
- /* Encode hyperslab ending location */
- for(u = 0; u < ndims; u++)
- UINT32ENCODE(pp, (uint32_t)(offset[u] + (diminfo[u].block - 1)));
+ /* Move the offset to the next sequence to start */
+ offset[fast_dim]+=diminfo[fast_dim].stride;
+
+ /* Decrement the block count */
+ tmp_count[fast_dim]--;
+ } /* end while */
- /* Move the offset to the next sequence to start */
- offset[fast_dim]+=diminfo[fast_dim].stride;
+ /* Work on other dimensions if necessary */
+ if(fast_dim > 0) {
+ int temp_dim; /* Temporary rank holder */
- /* Decrement the block count */
- tmp_count[fast_dim]--;
- } /* end while */
+ /* Reset the block counts */
+ tmp_count[fast_dim] = diminfo[fast_dim].count;
- /* Work on other dimensions if necessary */
- if(fast_dim > 0) {
- int temp_dim; /* Temporary rank holder */
+ /* Bubble up the decrement to the slower changing dimensions */
+ temp_dim = (int)fast_dim - 1;
+ while(temp_dim >= 0 && complete == FALSE) {
+ /* Decrement the block count */
+ tmp_count[temp_dim]--;
- /* Reset the block counts */
- tmp_count[fast_dim] = diminfo[fast_dim].count;
+ /* Check if we have more blocks left */
+ if(tmp_count[temp_dim] > 0)
+ break;
- /* Bubble up the decrement to the slower changing dimensions */
- temp_dim = (int)fast_dim - 1;
- while(temp_dim >= 0 && done == FALSE) {
- /* Decrement the block count */
- tmp_count[temp_dim]--;
+ /* Check for getting out of iterator */
+ if(temp_dim == 0)
+ complete = TRUE;
- /* Check if we have more blocks left */
- if(tmp_count[temp_dim] > 0)
- break;
+ /* Reset the block count in this dimension */
+ tmp_count[temp_dim] = diminfo[temp_dim].count;
- /* Check for getting out of iterator */
- if(temp_dim == 0)
- done = TRUE;
+ /* Wrapped a dimension, go up to next dimension */
+ temp_dim--;
+ } /* end while */
+ } /* end if */
+ else
+ break; /* Break out now, for 1-D selections */
- /* Reset the block count in this dimension */
- tmp_count[temp_dim] = diminfo[temp_dim].count;
+ /* Re-compute offset array */
+ for(u = 0; u < ndims; u++)
+ offset[u] = diminfo[u].start + diminfo[u].stride * (diminfo[u].count - tmp_count[u]);
+ } /* end while */
+ } /* end else */
+ } /* end if */
+ else { /* irregular */
+ /* Encode number of hyperslabs */
+ switch(enc_size) {
+ case H5S_SELECT_INFO_ENC_SIZE_2:
+ HDassert(version == H5S_HYPER_VERSION_3);
+ H5_CHECK_OVERFLOW(block_count, hsize_t, uint16_t);
+ UINT16ENCODE(pp, (uint16_t)block_count);
+ break;
- /* Wrapped a dimension, go up to next dimension */
- temp_dim--;
- } /* end while */
- } /* end if */
- else
- break; /* Break out now, for 1-D selections */
+ case H5S_SELECT_INFO_ENC_SIZE_4:
+ HDassert(version == H5S_HYPER_VERSION_1 || version == H5S_HYPER_VERSION_3);
+ H5_CHECK_OVERFLOW(block_count, hsize_t, uint32_t);
+ UINT32ENCODE(pp, (uint32_t)block_count);
+ break;
- /* Re-compute offset array */
- for(u = 0; u < ndims; u++)
- offset[u] = diminfo[u].start + diminfo[u].stride * (diminfo[u].count - tmp_count[u]);
- } /* end while */
- } /* end if */
- else {
- hsize_t start[H5O_LAYOUT_NDIMS]; /* Location of start of hyperslab */
- hsize_t end[H5O_LAYOUT_NDIMS]; /* Location of end of hyperslab */
+ case H5S_SELECT_INFO_ENC_SIZE_8:
+ HDassert(version == H5S_HYPER_VERSION_3);
+ UINT64ENCODE(pp, block_count);
+ break;
- /* 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);
- len += 4;
+ default:
+ HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unknown offset info size for hyperslab")
+ break;
+ } /* end switch */
- /* Add 8 bytes times the rank for each hyperslab selected */
- H5_CHECK_OVERFLOW((8 * space->extent.rank * block_count), hsize_t, size_t);
- len += (uint32_t)(8 * space->extent.rank * block_count);
+ if(version == H5S_HYPER_VERSION_1) {
+ len += 4; /* block_count */
- /* Encode each hyperslab in selection */
- H5S__hyper_serialize_helper(space->select.sel_info.hslab->span_lst, start, end, (hsize_t)0, &pp);
+ /* Add 8 bytes times the rank for each hyperslab selected */
+ H5_CHECK_OVERFLOW((8 * ndims * block_count), hsize_t, size_t);
+ len += (uint32_t)(8 * ndims * block_count);
+ } /* end if */
+
+ H5S__hyper_serialize_helper(space->select.sel_info.hslab->span_lst, start, end, (hsize_t)0, enc_size, &pp);
} /* end else */
/* Encode length */
- UINT32ENCODE(lenp, (uint32_t)len); /* Store the length of the extra information */
+ if(version <= H5S_HYPER_VERSION_2)
+ UINT32ENCODE(lenp, (uint32_t)len); /* Store the length of the extra information */
/* Update encoding pointer */
*p = pp;
- FUNC_LEAVE_NOAPI(SUCCEED)
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5S__hyper_serialize() */
@@ -2295,10 +4204,8 @@ H5S__hyper_serialize(const H5S_t *space, uint8_t **p)
Deserialize the current selection from a user-provided buffer.
USAGE
herr_t H5S__hyper_deserialize(space, p)
- H5S_t *space; IN/OUT: Dataspace pointer to place
+ H5S_t **space; IN/OUT: Dataspace pointer to place
selection into
- uint32_t version IN: Selection version
- uint8_t flags IN: Selection flags
uint8 **p; OUT: Pointer to buffer holding serialized
selection. Will be advanced to end of
serialized selection.
@@ -2313,82 +4220,216 @@ H5S__hyper_serialize(const H5S_t *space, uint8_t **p)
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
-H5S__hyper_deserialize(H5S_t *space, uint32_t H5_ATTR_UNUSED version, uint8_t flags,
- const uint8_t **p)
+H5S__hyper_deserialize(H5S_t **space, const uint8_t **p)
{
- unsigned rank; /* Rank of points */
- const uint8_t *pp; /* Local pointer for decoding */
- hsize_t start[H5O_LAYOUT_NDIMS]; /* Hyperslab start information */
- hsize_t block[H5O_LAYOUT_NDIMS]; /* Hyperslab block information */
- unsigned u; /* Local counting variable */
- herr_t ret_value = FAIL; /* Return value */
+ H5S_t *tmp_space = NULL; /* Pointer to actual dataspace to use,
+ either *space or a newly allocated one */
+ hsize_t dims[H5S_MAX_RANK]; /* Dimenion sizes */
+ hsize_t start[H5S_MAX_RANK]; /* hyperslab start information */
+ hsize_t block[H5S_MAX_RANK]; /* hyperslab block information */
+ uint32_t version; /* Version number */
+ uint8_t flags = 0; /* Flags */
+ uint8_t enc_size = 0; /* Encoded size of selection info */
+ unsigned rank; /* rank of points */
+ const uint8_t *pp; /* Local pointer for decoding */
+ unsigned u; /* Local counting variable */
+ herr_t ret_value=FAIL; /* return value */
FUNC_ENTER_STATIC
/* Check args */
- HDassert(space);
HDassert(p);
pp = (*p);
HDassert(pp);
- /* Deserialize slabs to select */
- /* (The header and rank have already beed decoded) */
- rank = space->extent.rank; /* Retrieve rank from space */
+ /* As part of the efforts to push all selection-type specific coding
+ to the callbacks, the coding for the allocation of a null dataspace
+ is moved from H5S_select_deserialize() in H5Sselect.c to here.
+ This is needed for decoding virtual layout in H5O__layout_decode() */
+ /* Allocate space if not provided */
+ if(!*space) {
+ if(NULL == (tmp_space = H5S_create(H5S_SIMPLE)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create dataspace")
+ } /* end if */
+ else
+ tmp_space = *space;
- /* If there is an unlimited dimension, only encode opt_unlim_diminfo */
- if(flags & H5S_SELECT_FLAG_UNLIM) {
- hsize_t stride[H5O_LAYOUT_NDIMS]; /* Hyperslab stride information */
- hsize_t count[H5O_LAYOUT_NDIMS]; /* Hyperslab count information */
+ /* Decode version */
+ UINT32DECODE(pp, version);
+
+ if(version >= (uint32_t)H5S_HYPER_VERSION_2) {
+ /* Decode flags */
+ flags = *(pp)++;
+
+ if(version >= (uint32_t)H5S_HYPER_VERSION_3)
+ /* decode size of offset info */
+ enc_size = *(pp)++;
+ else {
+ /* Skip over the remainder of the header */
+ pp += 4;
+ enc_size = H5S_SELECT_INFO_ENC_SIZE_8;
+ } /* end else */
+
+ /* Check for unknown flags */
+ if(flags & ~H5S_SELECT_FLAG_BITS)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTLOAD, FAIL, "unknown flag for selection")
+ } /* end if */
+ else {
+ /* Skip over the remainder of the header */
+ pp += 8;
+ enc_size = H5S_SELECT_INFO_ENC_SIZE_4;
+ } /* end else */
+
+ /* Check encoded */
+ if(enc_size & ~H5S_SELECT_INFO_ENC_SIZE_BITS)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTLOAD, FAIL, "unknown size of point/offset info for selection")
+
+ /* Decode the rank of the point selection */
+ UINT32DECODE(pp,rank);
+
+ if(!*space) {
+ /* Patch the rank of the allocated dataspace */
+ (void)HDmemset(dims, 0, (size_t)rank * sizeof(dims[0]));
+ if(H5S_set_extent_simple(tmp_space, rank, dims, NULL) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't set dimensions")
+ } /* end if */
+ else
+ /* Verify the rank of the provided dataspace */
+ if(rank != tmp_space->extent.rank)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "rank of serialized selection does not match dataspace")
+
+ if(flags & H5S_HYPER_REGULAR) {
+ hsize_t stride[H5S_MAX_RANK]; /* Hyperslab stride information */
+ hsize_t count[H5S_MAX_RANK]; /* Hyperslab count information */
/* Sanity checks */
HDassert(H5S_UNLIMITED == HSIZE_UNDEF);
HDassert(version >= 2);
- /* Iterate over dimensions */
- for(u = 0; u < rank; u++) {
- /* Decode start/stride/block/count */
- UINT64DECODE(pp, start[u]);
- UINT64DECODE(pp, stride[u]);
- UINT64DECODE(pp, count[u]);
- UINT64DECODE(pp, block[u]);
- } /* end for */
+ /* Decode start/stride/block/count */
+ switch(enc_size) {
+ case H5S_SELECT_INFO_ENC_SIZE_2:
+ for(u = 0; u < tmp_space->extent.rank; u++) {
+ UINT16DECODE(pp, start[u]);
+ UINT16DECODE(pp, stride[u]);
+
+ UINT16DECODE(pp, count[u]);
+ if((uint16_t)count[u] == H5S_UINT16_MAX)
+ count[u] = H5S_UNLIMITED;
+
+ UINT16DECODE(pp, block[u]);
+ if((uint16_t)block[u] == H5S_UINT16_MAX)
+ block[u] = H5S_UNLIMITED;
+ } /* end for */
+ break;
+
+ case H5S_SELECT_INFO_ENC_SIZE_4:
+ for(u = 0; u < tmp_space->extent.rank; u++) {
+ UINT32DECODE(pp, start[u]);
+ UINT32DECODE(pp, stride[u]);
+
+ UINT32DECODE(pp, count[u]);
+ if((uint32_t)count[u] == H5S_UINT32_MAX)
+ count[u] = H5S_UNLIMITED;
+ UINT32DECODE(pp, block[u]);
+ if((uint32_t)block[u] == H5S_UINT32_MAX)
+ block[u] = H5S_UNLIMITED;
+ } /* end for */
+ break;
+
+ case H5S_SELECT_INFO_ENC_SIZE_8:
+ for(u = 0; u < tmp_space->extent.rank; u++) {
+ UINT64DECODE(pp, start[u]);
+ UINT64DECODE(pp, stride[u]);
+
+ UINT64DECODE(pp, count[u]);
+ if((uint64_t)count[u] == H5S_UINT64_MAX)
+ count[u] = H5S_UNLIMITED;
+
+ UINT64DECODE(pp, block[u]);
+ if((uint64_t)block[u] == H5S_UINT64_MAX)
+ block[u] = H5S_UNLIMITED;
+ } /* end for */
+ break;
+
+ default:
+ HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unknown offset info size for hyperslab")
+ break;
+ } /* end switch */
+
/* Select the hyperslab to the current selection */
- if((ret_value = H5S_select_hyperslab(space, H5S_SELECT_SET, start, stride, count, block)) < 0)
+ if((ret_value = H5S_select_hyperslab(tmp_space, H5S_SELECT_SET, start, stride, count, block)) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "can't change selection")
} /* end if */
else {
const hsize_t *stride; /* Hyperslab stride information */
const hsize_t *count; /* Hyperslab count information */
- hsize_t end[H5O_LAYOUT_NDIMS]; /* Hyperslab end information */
- hsize_t *tstart; /* Temporary hyperslab pointers */
- hsize_t *tend; /* Temporary hyperslab pointers */
- hsize_t *tblock; /* Temporary hyperslab pointers */
- size_t block_count; /* Number of blocks in selection */
- unsigned v; /* Local counting variable */
+ hsize_t end[H5S_MAX_RANK]; /* Hyperslab end information */
+ hsize_t *tstart; /* Temporary hyperslab pointers */
+ hsize_t *tend; /* Temporary hyperslab pointers */
+ hsize_t *tblock; /* Temporary hyperslab pointers */
+ size_t num_elem; /* Number of elements in selection */
+ unsigned v; /* Local counting variable */
+
+ /* decode the number of blocks */
+ switch(enc_size) {
+ case H5S_SELECT_INFO_ENC_SIZE_2:
+ UINT16DECODE(pp, num_elem);
+ break;
+
+ case H5S_SELECT_INFO_ENC_SIZE_4:
+ UINT32DECODE(pp, num_elem);
+ break;
+
+ case H5S_SELECT_INFO_ENC_SIZE_8:
+ UINT64DECODE(pp, num_elem);
+ break;
- /* Decode the number of blocks */
- UINT32DECODE(pp, block_count);
+ default:
+ HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unknown offset info size for hyperslab")
+ break;
+ } /* end switch */
/* Set the count & stride for all blocks */
stride = count = H5S_hyper_ones_g;
/* Retrieve the coordinates from the buffer */
- for(u = 0; u < block_count; u++) {
- /* Decode the starting points */
- for(tstart = start, v = 0; v < rank; v++, tstart++)
- UINT32DECODE(pp, *tstart);
+ for(u = 0; u < num_elem; u++) {
+ /* Decode the starting and ending points */
+ switch(enc_size) {
+ case H5S_SELECT_INFO_ENC_SIZE_2:
+ for(tstart = start, v = 0; v < rank; v++, tstart++)
+ UINT16DECODE(pp, *tstart);
+ for(tend = end, v = 0; v < rank; v++, tend++)
+ UINT16DECODE(pp, *tend);
+ break;
- /* Decode the ending points */
- for(tend = end, v = 0; v < rank; v++, tend++)
- UINT32DECODE(pp, *tend);
+ case H5S_SELECT_INFO_ENC_SIZE_4:
+ for(tstart = start,v = 0; v < rank; v++, tstart++)
+ UINT32DECODE(pp, *tstart);
+ for(tend = end, v = 0; v < rank; v++, tend++)
+ UINT32DECODE(pp, *tend);
+ break;
+
+ case H5S_SELECT_INFO_ENC_SIZE_8:
+ for(tstart = start, v = 0; v < rank; v++, tstart++)
+ UINT64DECODE(pp, *tstart);
+ for(tend = end, v = 0; v < rank; v++, tend++)
+ UINT64DECODE(pp, *tend);
+ break;
+
+ default:
+ HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unknown offset info size for hyperslab")
+ break;
+ } /* end switch */
/* Change the ending points into blocks */
for(tblock = block, tstart = start, tend = end, v = 0; v < rank; v++, tstart++, tend++, tblock++)
*tblock = (*tend - *tstart) + 1;
/* Select or add the hyperslab to the current selection */
- if((ret_value = H5S_select_hyperslab(space, (u == 0 ? H5S_SELECT_SET : H5S_SELECT_OR), start, stride, count, block)) < 0)
+ if((ret_value = H5S_select_hyperslab(tmp_space, (u == 0 ? H5S_SELECT_SET : H5S_SELECT_OR), start, stride, count, block)) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "can't change selection")
} /* end for */
} /* end else */
@@ -2396,7 +4437,16 @@ H5S__hyper_deserialize(H5S_t *space, uint32_t H5_ATTR_UNUSED version, uint8_t fl
/* Update decoding pointer */
*p = pp;
+ /* Return space to the caller if allocated */
+ if(!*space)
+ *space = tmp_space;
+
done:
+ /* Free temporary space if not passed to caller (only happens on error) */
+ if(!*space && tmp_space)
+ if(H5S_close(tmp_space) < 0)
+ HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "can't close dataspace")
+
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5S__hyper_deserialize() */
@@ -2440,14 +4490,13 @@ H5S__hyper_span_blocklist(const H5S_hyper_span_info_t *spans, hsize_t start[],
hsize_t **buf)
{
const H5S_hyper_span_t *curr; /* Pointer to current hyperslab span */
- hsize_t u; /* Index variable */
herr_t ret_value = SUCCEED; /* return value */
FUNC_ENTER_STATIC
/* Sanity checks */
HDassert(spans);
- HDassert(rank < H5O_LAYOUT_NDIMS);
+ HDassert(rank < H5S_MAX_RANK);
HDassert(start);
HDassert(end);
HDassert(startblock);
@@ -2478,19 +4527,19 @@ H5S__hyper_span_blocklist(const H5S_hyper_span_info_t *spans, hsize_t start[],
/* Encode all the previous dimensions starting & ending points */
/* Copy previous starting points */
- for(u = 0; u < rank; u++, (*buf)++)
- HDmemcpy(*buf, &start[u], sizeof(hsize_t));
+ H5MM_memcpy(*buf, start, rank * sizeof(hsize_t));
+ (*buf) += rank;
/* Copy starting point for this span */
- HDmemcpy(*buf, &curr->low, sizeof(hsize_t));
+ **buf = curr->low;
(*buf)++;
/* Copy previous ending points */
- for(u = 0; u < rank; u++, (*buf)++)
- HDmemcpy(*buf, &end[u], sizeof(hsize_t));
+ H5MM_memcpy(*buf, end, rank * sizeof(hsize_t));
+ (*buf) += rank;
- /* Copy starting point for this span */
- HDmemcpy(*buf, &curr->high, sizeof(hsize_t));
+ /* Copy ending point for this span */
+ **buf = curr->high;
(*buf)++;
/* Decrement the number of blocks processed */
@@ -2538,7 +4587,8 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
-H5S__get_select_hyper_blocklist(H5S_t *space, hbool_t internal, hsize_t startblock, hsize_t numblocks, hsize_t *buf)
+H5S__get_select_hyper_blocklist(H5S_t *space, hsize_t startblock,
+ hsize_t numblocks, hsize_t *buf)
{
herr_t ret_value = SUCCEED; /* Return value */
@@ -2548,11 +4598,18 @@ H5S__get_select_hyper_blocklist(H5S_t *space, hbool_t internal, hsize_t startblo
HDassert(buf);
HDassert(space->select.sel_info.hslab->unlim_dim < 0);
+ /* Attempt to rebuild diminfo if it is invalid and has not been confirmed
+ * to be impossible.
+ */
+ if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_NO)
+ H5S__hyper_rebuild(space);
+
/* Check for a "regular" hyperslab selection */
- if(space->select.sel_info.hslab->diminfo_valid) {
+ if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) {
const H5S_hyper_dim_t *diminfo; /* Alias for dataspace's diminfo information */
- hsize_t tmp_count[H5O_LAYOUT_NDIMS]; /* Temporary hyperslab counts */
- hsize_t offset[H5O_LAYOUT_NDIMS]; /* Offset of element in dataspace */
+ hsize_t tmp_count[H5S_MAX_RANK]; /* Temporary hyperslab counts */
+ hsize_t offset[H5S_MAX_RANK]; /* Offset of element in dataspace */
+ hsize_t end[H5S_MAX_RANK]; /* End of elements in dataspace */
unsigned fast_dim; /* Rank of the fastest changing dimension for the dataspace */
unsigned ndims; /* Rank of the dataspace */
hbool_t done; /* Whether we are done with the iteration */
@@ -2563,31 +4620,25 @@ H5S__get_select_hyper_blocklist(H5S_t *space, hbool_t internal, hsize_t startblo
fast_dim = ndims - 1;
/* Check which set of dimension information to use */
- if(internal)
+ if(space->select.sel_info.hslab->unlim_dim >= 0)
/*
- * Use the "optimized dimension information" to pass back information
- * on the blocks set, not the "application information".
+ * There is an unlimited dimension so we must use diminfo.opt as
+ * it has been "clipped" to the current extent.
*/
- diminfo = space->select.sel_info.hslab->opt_diminfo;
+ diminfo = space->select.sel_info.hslab->diminfo.opt;
else
- if(space->select.sel_info.hslab->unlim_dim >= 0)
- /*
- * There is an unlimited dimension so we must use opt_diminfo as
- * it has been "clipped" to the current extent.
- */
- diminfo = space->select.sel_info.hslab->opt_diminfo;
- else
- /*
- * Use the "application dimension information" to pass back to
- * the user the blocks they set, not the optimized, internal
- * information.
- */
- diminfo = space->select.sel_info.hslab->app_diminfo;
+ /*
+ * Use the "application dimension information" to pass back to
+ * the user the blocks they set, not the optimized, internal
+ * information.
+ */
+ diminfo = space->select.sel_info.hslab->diminfo.app;
/* Build the tables of count sizes as well as the initial offset */
for(u = 0; u < ndims; u++) {
tmp_count[u] = diminfo[u].count;
offset[u] = diminfo[u].start;
+ end[u] = diminfo[u].start + (diminfo[u].block - 1);
} /* end for */
/* We're not done with the iteration */
@@ -2595,31 +4646,45 @@ H5S__get_select_hyper_blocklist(H5S_t *space, hbool_t internal, hsize_t startblo
/* Go iterate over the hyperslabs */
while(!done && numblocks > 0) {
- hsize_t temp_off; /* Offset in a given dimension */
+ /* Skip over initial blocks */
+ if(startblock > 0) {
+ /* Skip all blocks in row */
+ if(startblock >= tmp_count[fast_dim]) {
+ startblock -= tmp_count[fast_dim];
+ tmp_count[fast_dim] = 0;
+ } /* end if */
+ else {
+ /* Move the offset to the next sequence to start */
+ offset[fast_dim] += diminfo[fast_dim].stride * startblock;
+ end[fast_dim] += diminfo[fast_dim].stride * startblock;
+
+ /* Decrement the block count */
+ tmp_count[fast_dim] -= startblock;
+
+ /* Done with starting blocks */
+ startblock = 0;
+ } /* end else */
+ } /* end if */
/* Iterate over the blocks in the fastest dimension */
while(tmp_count[fast_dim] > 0 && numblocks > 0) {
+ /* Sanity check */
+ HDassert(startblock == 0);
- /* Check if we should copy this block information */
- if(startblock == 0) {
- /* Copy the starting location */
- HDmemcpy(buf, offset, sizeof(hsize_t) * ndims);
- buf += ndims;
+ /* Copy the starting location */
+ H5MM_memcpy(buf, offset, sizeof(hsize_t) * ndims);
+ buf += ndims;
- /* Compute the ending location */
- HDmemcpy(buf, offset, sizeof(hsize_t) * ndims);
- for(u = 0; u < ndims; u++)
- buf[u] += (diminfo[u].block - 1);
- buf += ndims;
+ /* Compute the ending location */
+ H5MM_memcpy(buf, end, sizeof(hsize_t) * ndims);
+ buf += ndims;
- /* Decrement the number of blocks to retrieve */
- numblocks--;
- } /* end if */
- else
- startblock--;
+ /* Decrement the number of blocks to retrieve */
+ numblocks--;
/* Move the offset to the next sequence to start */
offset[fast_dim] += diminfo[fast_dim].stride;
+ end[fast_dim] += diminfo[fast_dim].stride;
/* Decrement the block count */
tmp_count[fast_dim]--;
@@ -2642,28 +4707,29 @@ H5S__get_select_hyper_blocklist(H5S_t *space, hbool_t internal, hsize_t startblo
if(tmp_count[temp_dim] > 0)
break;
+ /* Reset the block count in this dimension */
+ tmp_count[temp_dim] = diminfo[temp_dim].count;
+
/* Check for getting out of iterator */
if(temp_dim == 0)
done = TRUE;
- /* Reset the block count in this dimension */
- tmp_count[temp_dim] = diminfo[temp_dim].count;
-
/* Wrapped a dimension, go up to next dimension */
temp_dim--;
} /* end while */
} /* end if */
- /* Re-compute offset array */
- for(u = 0; u < ndims; u++) {
- temp_off = diminfo[u].start + diminfo[u].stride * (diminfo[u].count - tmp_count[u]);
- offset[u] = temp_off;
- } /* end for */
+ /* Re-compute offset & end arrays */
+ if(!done)
+ for(u = 0; u < ndims; u++) {
+ offset[u] = diminfo[u].start + diminfo[u].stride * (diminfo[u].count - tmp_count[u]);
+ end[u] = offset[u] + (diminfo[u].block - 1);
+ } /* end for */
} /* end while */
} /* end if */
else {
- hsize_t start[H5O_LAYOUT_NDIMS]; /* Location of start of hyperslab */
- hsize_t end[H5O_LAYOUT_NDIMS]; /* Location of end of hyperslab */
+ hsize_t start[H5S_MAX_RANK]; /* Location of start of hyperslab */
+ hsize_t end[H5S_MAX_RANK]; /* Location of end of hyperslab */
ret_value = H5S__hyper_span_blocklist(space->select.sel_info.hslab->span_lst, start, end, (hsize_t)0, &startblock, &numblocks, &buf);
} /* end else */
@@ -2684,7 +4750,7 @@ H5S__get_select_hyper_blocklist(H5S_t *space, hbool_t internal, hsize_t startblo
hsize_t numblocks; IN: Number of hyperslab blocks to get
hsize_t buf[]; OUT: List of hyperslab blocks selected
RETURNS
- Non-negative on success, negative on failure
+ Non-negative on success/Negative on failure
DESCRIPTION
Puts a list of the hyperslab blocks into the user's buffer. The blocks
start with the 'startblock'th block in the list of blocks and put
@@ -2724,7 +4790,7 @@ H5Sget_select_hyper_blocklist(hid_t spaceid, hsize_t startblock,
/* Go get the correct number of blocks */
if(numblocks > 0)
- ret_value = H5S__get_select_hyper_blocklist(space, 0, startblock, numblocks, buf);
+ ret_value = H5S__get_select_hyper_blocklist(space, startblock, numblocks, buf);
else
ret_value = SUCCEED; /* Successfully got 0 blocks... */
@@ -2735,76 +4801,6 @@ done:
/*--------------------------------------------------------------------------
NAME
- H5S_hyper_bounds_helper
- PURPOSE
- Gets the bounding box containing the selection.
- USAGE
- htri_t H5S_hyper_bounds_helper(spans, offset, rank);
- const H5S_hyper_span_info_t *spans; IN: Pointer to current hyperslab span tree
- const hssize_t *offset; IN: Pointer to offset array
- hsize_t rank; IN: Current rank looking at
- hsize_t *start; OUT: Start array bounds
- hsize_t *end; OUT: End array bounds
- RETURNS
- Non-negative on success, negative on failure
- DESCRIPTION
- Retrieves the bounding box containing the current selection and places
- it into the user's buffers. The start and end buffers must be large
- enough to hold the dataspace rank number of coordinates. The bounding box
- exactly contains the selection, ie. if a 2-D element selection is currently
- defined with the following points: (4,5), (6,8) (10,7), the bounding box
- with be (4, 5), (10, 8).
- The bounding box calculations _does_ include the current offset of the
- selection within the dataspace extent.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-static herr_t
-H5S_hyper_bounds_helper(const H5S_hyper_span_info_t *spans, const hssize_t *offset, hsize_t rank, hsize_t *start, hsize_t *end)
-{
- H5S_hyper_span_t *curr; /* Hyperslab information nodes */
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI_NOINIT
-
- HDassert(spans);
- HDassert(offset);
- HDassert(rank < H5O_LAYOUT_NDIMS);
- HDassert(start);
- HDassert(end);
-
- /* Check each point to determine whether selection+offset is within extent */
- curr=spans->head;
- while(curr!=NULL) {
- /* Check for offset moving selection negative */
- if(((hssize_t)curr->low + offset[rank]) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "offset moves selection out of bounds")
-
- /* Check if the current span extends the bounding box */
- if((curr->low + (hsize_t)offset[rank]) < start[rank])
- start[rank] = curr->low + (hsize_t)offset[rank];
- if((curr->high + (hsize_t)offset[rank]) > end[rank])
- end[rank] = curr->high + (hsize_t)offset[rank];
-
- /* Recurse if this node has down spans */
- if(curr->down != NULL) {
- if(H5S_hyper_bounds_helper(curr->down, offset, (rank + 1), start, end) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_BADSELECT, FAIL, "failure in lower dimension")
- } /* end if */
-
- /* Advance to next node */
- curr = curr->next;
- } /* end while */
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5S_hyper_bounds_helper() */
-
-
-/*--------------------------------------------------------------------------
- NAME
H5S__hyper_bounds
PURPOSE
Gets the bounding box containing the selection.
@@ -2832,8 +4828,8 @@ done:
static herr_t
H5S__hyper_bounds(const H5S_t *space, hsize_t *start, hsize_t *end)
{
- unsigned rank; /* Dataspace rank */
- unsigned i; /* index variable */
+ const hsize_t *low_bounds, *high_bounds; /* Pointers to the correct pair of low & high bounds */
+ unsigned u; /* Local index variable */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
@@ -2843,37 +4839,32 @@ H5S__hyper_bounds(const H5S_t *space, hsize_t *start, hsize_t *end)
HDassert(start);
HDassert(end);
- /* Set the start and end arrays up */
- rank = space->extent.rank;
- for(i = 0; i < rank; i++) {
- start[i] = HSIZET_MAX;
- end[i] = 0;
- } /* end for */
-
- /* Check for a "regular" hyperslab selection */
- if(space->select.sel_info.hslab->diminfo_valid) {
- const H5S_hyper_dim_t *diminfo = space->select.sel_info.hslab->opt_diminfo; /* local alias for diminfo */
+ /* Check which set of low & high bounds we should be using */
+ if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) {
+ low_bounds = space->select.sel_info.hslab->diminfo.low_bounds;
+ high_bounds = space->select.sel_info.hslab->diminfo.high_bounds;
+ } /* end if */
+ else {
+ low_bounds = space->select.sel_info.hslab->span_lst->low_bounds;
+ high_bounds = space->select.sel_info.hslab->span_lst->high_bounds;
+ } /* end else */
- /* Check each dimension */
- for(i = 0; i < rank; i++) {
- /* Check for offset moving selection negative */
- if((space->select.offset[i] + (hssize_t)diminfo[i].start) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "offset moves selection out of bounds")
+ /* Loop over dimensions */
+ for(u = 0; u < space->extent.rank; u++) {
+ /* Sanity check */
+ HDassert(low_bounds[u] <= high_bounds[u]);
- /* Compute the smallest location in this dimension */
- start[i] = diminfo[i].start + (hsize_t)space->select.offset[i];
+ /* Check for offset moving selection negative */
+ if(((hssize_t)low_bounds[u] + space->select.offset[u]) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "offset moves selection out of bounds")
- /* Compute the largest location in this dimension */
- if((int)i == space->select.sel_info.hslab->unlim_dim)
- end[i] = H5S_UNLIMITED;
- else
- end[i] = diminfo[i].start + diminfo[i].stride * (diminfo[i].count - 1) + (diminfo[i].block - 1) + (hsize_t)space->select.offset[i];
- } /* end for */
- } /* end if */
- else {
- /* Call the recursive routine to get the bounds for the span tree */
- ret_value = H5S_hyper_bounds_helper(space->select.sel_info.hslab->span_lst, space->select.offset, (hsize_t)0, start, end);
- } /* end if */
+ /* Set the low & high bounds in this dimension */
+ start[u] = (hsize_t)((hssize_t)low_bounds[u] + space->select.offset[u]);
+ if((int)u == space->select.sel_info.hslab->unlim_dim)
+ end[u] = H5S_UNLIMITED;
+ else
+ end[u] = (hsize_t)((hssize_t)high_bounds[u] + space->select.offset[u]);
+ } /* end for */
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -2924,8 +4915,9 @@ H5S__hyper_offset(const H5S_t *space, hsize_t *offset)
dim_size = space->extent.size;
/* Check for a "regular" hyperslab selection */
- if(space->select.sel_info.hslab->diminfo_valid) {
- const H5S_hyper_dim_t *diminfo = space->select.sel_info.hslab->opt_diminfo; /* Local alias for diminfo */
+ /* (No need to rebuild the dimension info yet -QAK) */
+ if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) {
+ const H5S_hyper_dim_t *diminfo = space->select.sel_info.hslab->diminfo.opt; /* Local alias for diminfo */
/* Loop through starting coordinates, calculating the linear offset */
accum = 1;
@@ -3075,7 +5067,7 @@ done:
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-static htri_t
+static H5_ATTR_PURE htri_t
H5S__hyper_is_contiguous(const H5S_t *space)
{
hbool_t small_contiguous, /* Flag for small contiguous block */
@@ -3088,8 +5080,9 @@ H5S__hyper_is_contiguous(const H5S_t *space)
HDassert(space);
/* Check for a "regular" hyperslab selection */
- if(space->select.sel_info.hslab->diminfo_valid) {
- const H5S_hyper_dim_t *diminfo=space->select.sel_info.hslab->opt_diminfo; /* local alias for diminfo */
+ /* (No need to rebuild the dimension info yet -QAK) */
+ if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) {
+ const H5S_hyper_dim_t *diminfo=space->select.sel_info.hslab->diminfo.opt; /* local alias for diminfo */
/*
* For a regular hyperslab to be contiguous, it must have only one
@@ -3145,10 +5138,10 @@ H5S__hyper_is_contiguous(const H5S_t *space)
/*
* For a hyperslab to be contiguous, it must have only one block and
- * (either it's size must be the same as the dataspace extent's in all
- * but the slowest changing dimension
- * OR
- * block size must be 1 in all but the fastest changing dimension).
+ * either it's size must be the same as the dataspace extent's in all
+ * but the slowest changing dimension
+ * OR
+ * block size must be 1 in all but the fastest changing dimension.
*/
/* Initialize flags */
large_contiguous = TRUE; /* assume true and reset if the dimensions don't match */
@@ -3260,7 +5253,7 @@ H5S__hyper_is_contiguous(const H5S_t *space)
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-static htri_t
+static H5_ATTR_PURE htri_t
H5S__hyper_is_single(const H5S_t *space)
{
htri_t ret_value = TRUE; /* return value */
@@ -3270,7 +5263,10 @@ H5S__hyper_is_single(const H5S_t *space)
HDassert(space);
/* Check for a "single" hyperslab selection */
- if(space->select.sel_info.hslab->diminfo_valid) {
+ /* (No need to rebuild the dimension info yet, since the span-tree
+ * algorithm is fast -QAK)
+ */
+ if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) {
unsigned u; /* index variable */
/*
@@ -3280,7 +5276,7 @@ H5S__hyper_is_single(const H5S_t *space)
/* Check for a single block */
for(u = 0; u < space->extent.rank; u++)
- if(space->select.sel_info.hslab->opt_diminfo[u].count > 1)
+ if(space->select.sel_info.hslab->diminfo.opt[u].count > 1)
HGOTO_DONE(FALSE)
} /* end if */
else {
@@ -3328,7 +5324,6 @@ done:
This is primarily used for reading the entire selection in one swoop.
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
- Doesn't check for "regular" hyperslab selections composed of spans
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
@@ -3342,8 +5337,14 @@ H5S__hyper_is_regular(const H5S_t *space)
/* Check args */
HDassert(space);
+ /* Attempt to rebuild diminfo if it is invalid and has not been confirmed
+ * to be impossible.
+ */
+ if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_NO)
+ H5S__hyper_rebuild((H5S_t *)space); /* Casting away const OK -NAF */
+
/* Only simple check for regular hyperslabs for now... */
- if(space->select.sel_info.hslab->diminfo_valid)
+ if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES)
ret_value = TRUE;
else
ret_value = FALSE;
@@ -3354,93 +5355,395 @@ H5S__hyper_is_regular(const H5S_t *space)
/*--------------------------------------------------------------------------
NAME
- H5S__hyper_release
+ H5S__hyper_spans_shape_same_helper
PURPOSE
- Release hyperslab selection information for a dataspace
+ Helper routine to check if two hyperslab span trees are the same shape
USAGE
- herr_t H5S__hyper_release(space)
- H5S_t *space; IN: Pointer to dataspace
+ hbool_t H5S__hyper_spans_shape_same_helper(span1, span2, offset, rest_zeros)
+ H5S_hyper_span_info_t *span_info1; IN: First span tree to compare
+ H5S_hyper_span_info_t *span_info2; IN: Second span tree to compare
+ hssize_t offset[]; IN: Offset between the span trees
+ hbool_t rest_zeros[]; IN: Array of flags which indicate
+ the rest of the offset[] array
+ is zero values.
RETURNS
- Non-negative on success/Negative on failure
+ TRUE (1) or FALSE (0) on success, can't fail
DESCRIPTION
- Releases all hyperslab selection information for a dataspace
+ Compare two hyperslab span trees to determine if they refer to a selection
+ with the same shape, with a possible (constant) offset between their
+ elements. Very similar to H5S__hyper_cmp_spans, except the selected
+ elements can be offset by a vector.
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
EXAMPLES
REVISION LOG
- * Robb Matzke, 1998-08-25
- * The fields which are freed are set to NULL to prevent them from being
- * freed again later. This fixes some allocation problems where
- * changing the hyperslab selection of one dataspace causes a core dump
- * when closing some other dataspace.
--------------------------------------------------------------------------*/
-static herr_t
-H5S__hyper_release(H5S_t *space)
+static H5_ATTR_PURE hbool_t
+H5S__hyper_spans_shape_same_helper(const H5S_hyper_span_info_t *span_info1,
+ const H5S_hyper_span_info_t *span_info2, hssize_t offset[],
+ hbool_t rest_zeros[])
{
- herr_t ret_value = SUCCEED;
+ hbool_t ret_value = TRUE; /* Return value */
+
+ FUNC_ENTER_PACKAGE_NOERR
+
+ /* Sanity checks */
+ HDassert(span_info1);
+ HDassert(span_info2);
+ HDassert(offset);
+ HDassert(rest_zeros);
+
+ /* Compare low & high bounds for this span list */
+ /* (Could compare lower dimensions also, but not certain if
+ * that's worth it. - QAK, 2019/01/23)
+ */
+ if((hsize_t)((hssize_t)span_info1->low_bounds[0] + offset[0]) != span_info2->low_bounds[0])
+ HGOTO_DONE(FALSE)
+ else if((hsize_t)((hssize_t)span_info1->high_bounds[0] + offset[0]) != span_info2->high_bounds[0])
+ HGOTO_DONE(FALSE)
+ else {
+ const H5S_hyper_span_t *span1;
+ const H5S_hyper_span_t *span2;
+
+ /* Get the pointers to the actual lists of spans */
+ span1 = span_info1->head;
+ span2 = span_info2->head;
+
+ /* Sanity checking */
+ HDassert(span1);
+ HDassert(span2);
+
+ /* infinite loop which must be broken out of */
+ while(1) {
+ /* Check for both spans being NULL */
+ if(span1 == NULL && span2 == NULL)
+ HGOTO_DONE(TRUE)
+
+ /* Check for one span being NULL */
+ if(span1 == NULL || span2 == NULL)
+ HGOTO_DONE(FALSE)
+
+ /* Check if the actual low & high span information is the same */
+ if((hsize_t)((hssize_t)span1->low + offset[0]) != span2->low || (hsize_t)((hssize_t)span1->high + offset[0]) != span2->high)
+ HGOTO_DONE(FALSE)
+
+ /* Check for down tree for this span */
+ if(span1->down != NULL || span2->down != NULL) {
+ /* If the rest of the span trees have a zero offset, use the faster comparison routine */
+ if(rest_zeros[0]) {
+ if(!H5S__hyper_cmp_spans(span1->down, span2->down))
+ HGOTO_DONE(FALSE)
+ else {
+ /* Keep going... */
+ } /* end else */
+ } /* end if */
+ else {
+ if(!H5S__hyper_spans_shape_same_helper(span1->down, span2->down, &offset[1], &rest_zeros[1]))
+ HGOTO_DONE(FALSE)
+ else {
+ /* Keep going... */
+ } /* end else */
+ } /* end else */
+ } /* end if */
+ else {
+ /* Keep going... */
+ } /* end else */
+
+ /* Advance to the next nodes in the span list */
+ span1 = span1->next;
+ span2 = span2->next;
+ } /* end while */
+ } /* end else */
+
+ /* Fall through, with default return value of 'TRUE' if spans were already visited */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5S__hyper_spans_shape_same_helper() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S__hyper_spans_shape_same
+ PURPOSE
+ Check if two hyperslab span trees are the same shape
+ USAGE
+ hbool_t H5S__hyper_spans_shape_same(span1, span2)
+ H5S_hyper_span_info_t *span_info1; IN: First span tree to compare
+ H5S_hyper_span_info_t *span_info2; IN: Second span tree to compare
+ RETURNS
+ TRUE (1) or FALSE (0) on success, can't fail
+ DESCRIPTION
+ Compare two hyperslab span trees to determine if they refer to a selection
+ with the same shape. Very similar to H5S__hyper_cmp_spans, except the
+ selected elements can be offset by a vector.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+static H5_ATTR_PURE hbool_t
+H5S__hyper_spans_shape_same(const H5S_hyper_span_info_t *span_info1,
+ const H5S_hyper_span_info_t *span_info2, unsigned ndims)
+{
+ const H5S_hyper_span_t *span1; /* Pointer to spans in first span tree */
+ const H5S_hyper_span_t *span2; /* Pointer to spans in second span tree */
+ hssize_t offset[H5S_MAX_RANK]; /* Offset vector for selections */
+ hbool_t rest_zeros[H5S_MAX_RANK]; /* Vector of flags to indicate when remaining offset is all zero */
+ hbool_t zero_offset; /* Whether the two selections have a non-zero offset */
+ unsigned u; /* Local index variable */
+ hbool_t ret_value = TRUE; /* Return value */
+
+ FUNC_ENTER_STATIC_NOERR
+
+ /* Sanity check */
+ HDassert(span_info1);
+ HDassert(span_info2);
+ HDassert(ndims > 0);
+
+ /* Initialize arrays */
+ HDmemset(offset, 0, sizeof(offset));
+ HDmemset(rest_zeros, 0, sizeof(rest_zeros));
+
+ /* Check for an offset between the two selections */
+ span1 = span_info1->head;
+ span2 = span_info2->head;
+ zero_offset = TRUE;
+ for(u = 0; u < ndims; u++) {
+ /* Check for offset in this dimension */
+ if(span1->low != span2->low) {
+ offset[u] = (hssize_t)span2->low - (hssize_t)span1->low;
+
+ /* Indicate that the offset vector is not all zeros */
+ if(zero_offset)
+ zero_offset = FALSE;
+ } /* end if */
+
+ /* Sanity check */
+ /* (Both span trees must have the same depth) */
+ HDassert((span1->down && span2->down) || (NULL == span1->down && NULL == span2->down));
+
+ /* Advance to next dimension */
+ if(span1->down) {
+ span1 = span1->down->head;
+ span2 = span2->down->head;
+ } /* end if */
+ } /* end for */
+
+ /* Check if there's a "tail" of all zeros in a non-zero offset vector */
+ if(!zero_offset) {
+ int i; /* Local index variable */
+
+ /* Find first non-zero offset, from the fastest dimension up */
+ for(i = (int)(ndims - 1); i >= 0; i--)
+ if(offset[i]) {
+ rest_zeros[i] = TRUE;
+ break;
+ } /* end if */
+
+ /* Sanity check */
+ /* (Must eventually have found a non-zero offset) */
+ HDassert(i >= 0);
+ } /* end if */
+
+ /* If the offset vector is all zero, we can use the faster span tree
+ * comparison routine. Otherwise, use a generalized version of that
+ * routine.
+ */
+ if(zero_offset)
+ ret_value = H5S__hyper_cmp_spans(span_info1, span_info2);
+ else
+ ret_value = H5S__hyper_spans_shape_same_helper(span_info1, span_info2, offset, rest_zeros);
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5S__hyper_spans_shape_same() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S__hyper_shape_same
+ PURPOSE
+ Check if a two hyperslab selections are the same shape
+ USAGE
+ htri_t H5S__hyper_shape_same(space1, space2)
+ const H5S_t *space1; IN: First dataspace to check
+ const H5S_t *space2; IN: Second dataspace to check
+ RETURNS
+ TRUE / FALSE / FAIL
+ DESCRIPTION
+ Checks to see if the current selection in each dataspace are the same
+ shape.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ Handles when both are regular in an efficient way, otherwise converts
+ both to span tree form (if necessary) and compares efficiently them in
+ that form.
+
+ Rank of space1 must always be >= to rank of space2.
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+static htri_t
+H5S__hyper_shape_same(const H5S_t *space1, const H5S_t *space2)
+{
+ unsigned space1_rank; /* Number of dimensions of first dataspace */
+ unsigned space2_rank; /* Number of dimensions of second dataspace */
+ htri_t ret_value = TRUE; /* Return value */
FUNC_ENTER_STATIC
/* Check args */
- HDassert(space && H5S_SEL_HYPERSLABS == H5S_GET_SELECT_TYPE(space));
+ HDassert(space1);
+ HDassert(space2);
- /* Reset the number of points selected */
- space->select.num_elem = 0;
+ /* Get dataspace ranks */
+ space1_rank = space1->extent.rank;
+ space2_rank = space2->extent.rank;
- /* Release irregular hyperslab information */
- if(space->select.sel_info.hslab) {
- if(space->select.sel_info.hslab->span_lst != NULL)
- if(H5S__hyper_free_span_info(space->select.sel_info.hslab->span_lst) < 0)
- HGOTO_ERROR(H5E_INTERNAL, H5E_CANTFREE, FAIL, "failed to release hyperslab spans")
+ /* Sanity check */
+ HDassert(space1_rank >= space2_rank);
+ HDassert(space2_rank > 0);
+
+ /* Rebuild diminfo if it is invalid and has not been confirmed to be
+ * impossible */
+ if(space1->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_NO)
+ H5S__hyper_rebuild((H5S_t *)space1); /* Casting away const OK -QAK */
+ if(space2->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_NO)
+ H5S__hyper_rebuild((H5S_t *)space2); /* Casting away const OK -QAK */
+
+ /* If both are regular hyperslabs, compare their diminfo values */
+ if(space1->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES
+ && space2->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) {
+ int space1_dim; /* Current dimension in first dataspace */
+ int space2_dim; /* Current dimension in second dataspace */
+
+ /* Initialize dimensions */
+ space1_dim = (int)space1_rank - 1;
+ space2_dim = (int)space2_rank - 1;
+
+ /* Check that the shapes are the same in the common dimensions, and that
+ * block == 1 in all dimensions that appear only in space1.
+ */
+ while(space2_dim >= 0) {
+ if(space1->select.sel_info.hslab->diminfo.opt[space1_dim].stride !=
+ space2->select.sel_info.hslab->diminfo.opt[space2_dim].stride)
+ HGOTO_DONE(FALSE)
- /* Release space for the hyperslab selection information */
- space->select.sel_info.hslab = H5FL_FREE(H5S_hyper_sel_t, space->select.sel_info.hslab);
+ if(space1->select.sel_info.hslab->diminfo.opt[space1_dim].count !=
+ space2->select.sel_info.hslab->diminfo.opt[space2_dim].count)
+ HGOTO_DONE(FALSE)
+
+ if(space1->select.sel_info.hslab->diminfo.opt[space1_dim].block !=
+ space2->select.sel_info.hslab->diminfo.opt[space2_dim].block)
+ HGOTO_DONE(FALSE)
+
+ space1_dim--;
+ space2_dim--;
+ } /* end while */
+
+ while(space1_dim >= 0) {
+ if(space1->select.sel_info.hslab->diminfo.opt[space1_dim].block != 1)
+ HGOTO_DONE(FALSE)
+
+ space1_dim--;
+ } /* end while */
} /* end if */
+ /* If both aren't regular, use fast irregular comparison */
+ else {
+ H5S_hyper_span_info_t *spans1; /* Hyperslab spans for first dataspace */
+
+ /* Make certain that both selections have span trees */
+ if(NULL == space1->select.sel_info.hslab->span_lst)
+ if(H5S__hyper_generate_spans((H5S_t *)space1) < 0) /* Casting away const OK -QAK */
+ HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "can't construct span tree for hyperslab selection")
+ if(NULL == space2->select.sel_info.hslab->span_lst)
+ if(H5S__hyper_generate_spans((H5S_t *)space2) < 0) /* Casting away const OK -QAK */
+ HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "can't construct span tree for hyperslab selection")
+
+ /* If rank of space A is different (guaranteed greater) than
+ * rank of space B, walk down the span tree, verifying
+ * that the block size is 1 on the way down.
+ */
+ if(space1_rank > space2_rank) {
+ unsigned diff_rank = space1_rank - space2_rank; /* Difference in ranks */
+
+ /* Walk down the dimensions */
+ spans1 = space1->select.sel_info.hslab->span_lst;
+ while(diff_rank > 0) {
+ H5S_hyper_span_t *span; /* Span for this dimension */
+
+ /* Get pointer to first span in tree */
+ span = spans1->head;
+
+ /* Check for more spans in this dimension */
+ if(span->next)
+ HGOTO_DONE(FALSE)
+
+ /* Check for span size > 1 element */
+ if(span->low != span->high)
+ HGOTO_DONE(FALSE)
+
+ /* Walk down to the next dimension */
+ spans1 = span->down;
+ diff_rank--;
+ } /* end while */
+
+ /* Sanity check */
+ HDassert(spans1);
+ } /* end if */
+ else
+ spans1 = space1->select.sel_info.hslab->span_lst;
+
+ /* Compare the span trees */
+ ret_value = H5S__hyper_spans_shape_same(spans1, space2->select.sel_info.hslab->span_lst, space2_rank);
+ } /* end else */
+
+ /* Fall through with 'TRUE' value, if not set earlier */
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5S__hyper_release() */
+} /* end H5S__hyper_shape_same() */
/*--------------------------------------------------------------------------
NAME
- H5S__hyper_recover_span
+ H5S__hyper_release
PURPOSE
- Recover a generated span, if appropriate
+ Release hyperslab selection information for a dataspace
USAGE
- herr_t H5S__hyper_recover_span(recover, curr_span, next_span)
- unsigned *recover; IN/OUT: Pointer recover flag
- H5S_hyper_span_t **curr_span; IN/OUT: Pointer to current span in list
- H5S_hyper_span_t *next_span; IN: Pointer to next span
+ herr_t H5S__hyper_release(space)
+ H5S_t *space; IN: Pointer to dataspace
RETURNS
- Non-negative on success, negative on failure
+ Non-negative on success/Negative on failure
DESCRIPTION
- Check if the current span needs to be recovered and free it if so.
- Set the current span to the next span in any case.
+ Releases all hyperslab selection information for a dataspace
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
-H5S__hyper_recover_span(hbool_t *recover, H5S_hyper_span_t **curr_span, H5S_hyper_span_t *next_span)
+H5S__hyper_release(H5S_t *space)
{
FUNC_ENTER_STATIC_NOERR
- HDassert(recover);
- HDassert(curr_span);
+ /* Check args */
+ HDassert(space && H5S_SEL_HYPERSLABS == H5S_GET_SELECT_TYPE(space));
- /* Check if the span should be recovered */
- if(*recover) {
- H5S__hyper_free_span(*curr_span);
- *recover = FALSE;
- } /* end if */
+ /* Reset the number of points selected */
+ space->select.num_elem = 0;
- /* Set the current span to next span */
- *curr_span = next_span;
+ /* Release irregular hyperslab information */
+ if(space->select.sel_info.hslab) {
+ if(space->select.sel_info.hslab->span_lst != NULL)
+ H5S__hyper_free_span_info(space->select.sel_info.hslab->span_lst);
+
+ /* Release space for the hyperslab selection information */
+ space->select.sel_info.hslab = H5FL_FREE(H5S_hyper_sel_t, space->select.sel_info.hslab);
+ } /* end if */
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5S__hyper_recover_span() */
+} /* end H5S__hyper_release() */
/*--------------------------------------------------------------------------
@@ -3453,7 +5756,7 @@ H5S__hyper_recover_span(hbool_t *recover, H5S_hyper_span_t **curr_span, H5S_hype
unsigned rank; IN: Number of dimensions of coordinate
hsize_t *coords; IN: Location of element
RETURNS
- Non-negative on success, negative on failure
+ Non-NULL pointer to new span tree on success, NULL on failure
DESCRIPTION
Create a span tree for a single element
GLOBAL VARIABLES
@@ -3475,14 +5778,20 @@ H5S__hyper_coord_to_span(unsigned rank, const hsize_t *coords)
/* Search for location to insert new element in tree */
if(rank > 1) {
- /* Allocate a span info node */
- if(NULL == (down = H5FL_CALLOC(H5S_hyper_span_info_t)))
+ /* Allocate a span info node for coordinates below this one */
+ if(NULL == (down = H5S__hyper_new_span_info(rank - 1)))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate hyperslab span")
+ /* Set the low & high bounds for this span info node */
+ H5MM_memcpy(down->low_bounds, &coords[1], (rank - 1) * sizeof(hsize_t));
+ H5MM_memcpy(down->high_bounds, &coords[1], (rank - 1) * sizeof(hsize_t));
/* Build span tree for coordinates below this one */
if(NULL == (down->head = H5S__hyper_coord_to_span(rank - 1, &coords[1])))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate hyperslab span")
+
+ /* Update the tail pointer of the down dimension, and it's a single span element */
+ down->tail = down->head;
} /* end if */
/* Build span for this coordinate */
@@ -3504,12 +5813,13 @@ done:
NAME
H5S__hyper_add_span_element_helper
PURPOSE
- Add a single element to a span tree
+ Helper routine to add a single element to a span tree
USAGE
- herr_t H5S_hyper_add_span_element_helper(prev_span, span_tree, rank, coords)
+ herr_t H5S__hyper_add_span_element_helper(span_tree, rank, coords, first_dim_modified)
H5S_hyper_span_info_t *span_tree; IN/OUT: Pointer to span tree to append to
unsigned rank; IN: Number of dimensions of coordinates
- hsize_t *coords; IN: Location of element to add to span tree
+ hsize_t *coords; IN: Location of element to add to span tree
+ int *first_dim_modified; IN: Index of the first dimension modified
RETURNS
Non-negative on success, negative on failure
DESCRIPTION
@@ -3522,13 +5832,9 @@ done:
--------------------------------------------------------------------------*/
static herr_t
H5S__hyper_add_span_element_helper(H5S_hyper_span_info_t *span_tree,
- unsigned rank, const hsize_t *coords)
+ unsigned rank, const hsize_t *coords, int *first_dim_modified)
{
- H5S_hyper_span_info_t *tspan_info; /* Temporary pointer to span info */
- H5S_hyper_span_info_t *prev_span_info; /* Pointer to span info for level above current position */
- H5S_hyper_span_t *tmp_span; /* Temporary pointer to a span */
- H5S_hyper_span_t *tmp2_span; /* Another temporary pointer to a span */
- H5S_hyper_span_t *new_span; /* New span created for element */
+ H5S_hyper_span_t *tail_span; /* Pointer to the tail span of one dimension */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
@@ -3537,166 +5843,196 @@ H5S__hyper_add_span_element_helper(H5S_hyper_span_info_t *span_tree,
HDassert(span_tree);
HDassert(rank > 0);
HDassert(coords);
+ HDassert(first_dim_modified);
/* Get pointer to last span in span tree */
- tspan_info=span_tree;
- if(span_tree->scratch)
- tmp_span=(H5S_hyper_span_t *)span_tree->scratch;
- else {
- tmp_span=span_tree->head;
- HDassert(tmp_span);
- span_tree->scratch=(H5S_hyper_span_info_t *)tmp_span;
- } /* end else */
-
- /* Find last span tree which includes a portion of the coordinate */
- prev_span_info=NULL;
- while(coords[0]>=tmp_span->low && coords[0]<=tmp_span->high) {
- /* Move rank & coordinate offset down a dimension */
- rank--;
- coords++;
-
- /* Remember the span tree we are descending into */
- prev_span_info=tspan_info;
- tspan_info=tmp_span->down;
+ tail_span = span_tree->tail;
+
+ /* Determine if tail span includes a portion of the coordinate */
+ /* (Should never happen with the lowest level in the span tree) */
+ if(coords[0] >= tail_span->low && coords[0] <= tail_span->high) {
+ H5S_hyper_span_t *prev_down_tail_span; /* Pointer to previous down spans' tail pointer */
+ hsize_t prev_down_tail_span_high; /* Value of previous down spans' tail's high value */
+
+ /* Retain into about down spans' tail */
+ prev_down_tail_span = tail_span->down->tail;
+ prev_down_tail_span_high = tail_span->down->tail->high;
+
+ /* Drop down a dimension */
+ HDassert(rank > 1);
+ if(H5S__hyper_add_span_element_helper(tail_span->down, rank - 1, &coords[1], first_dim_modified) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "can't insert coordinate into span tree")
+
+ /* Check & update high bounds for lower dimensions */
+ if(*first_dim_modified >= 0) {
+ unsigned first_dim; /* First dimension modified, relative to this span tree */
+ hbool_t first_dim_set = FALSE; /* Whether first dimension modified is set */
+ unsigned u; /* Local index variable */
- /* Get the last span in this span's 'down' tree */
- if(tspan_info->scratch)
- tmp_span=(H5S_hyper_span_t *)tspan_info->scratch;
- else {
- tmp_span=tspan_info->head;
- HDassert(tmp_span);
- tspan_info->scratch=(H5S_hyper_span_info_t *)tmp_span;
- } /* end else */
- } /* end while */
+ /* Adjust first dimension modified to be relative to this span tree */
+ first_dim = (unsigned)(*first_dim_modified + 1);
- /* Check if we made it all the way to the bottom span in the tree */
- if(rank>1) {
- /* Before we create another span at this level in the tree, check if
- * the last span's "down tree" was equal to any other spans in this
- * list of spans in the span tree.
- *
- * If so, release last span information and make last span merge into
- * previous span (if possible), or at least share their "down tree"
- * information.
- */
- tmp2_span=tspan_info->head;
- while(tmp2_span!=tmp_span) {
- if(H5S__hyper_cmp_spans(tmp2_span->down,tmp_span->down)==TRUE) {
- /* Check for merging into previous span */
- if(tmp2_span->high+1==tmp_span->low) {
- /* Release last span created */
- H5S__hyper_free_span(tmp_span);
+ /* Reset modified dimension, in case no bounds in this span tree change */
+ *first_dim_modified = -1;
- /* Increase size of previous span */
- tmp2_span->high++;
- tmp2_span->nelem++;
+ /* Iterate through coordinates */
+ for(u = first_dim; u < rank; u++) {
+ /* Check if coordinate is outside the bounds for this span tree */
+ if(coords[u] > span_tree->high_bounds[u]) {
+ /* Update high bounds for this tree */
+ span_tree->high_bounds[u] = coords[u];
- /* Reset the 'tmp_span' for the rest of this block's algorithm */
- tmp_span=tmp2_span;
+ /* Need to signal to higher dimensions if high bounds changed */
+ if(!first_dim_set) {
+ *first_dim_modified = (int)u;
+ first_dim_set = TRUE;
+ } /* end if */
} /* end if */
- /* Span is disjoint, but has the same "down tree" selection */
- else {
- /* Release "down tree" information */
- H5S__hyper_free_span_info(tmp_span->down);
+ } /* end for */
+ } /* end if */
- /* Point at earlier span's "down tree" */
- tmp_span->down=tmp2_span->down;
+ /* Check if previous tail span in down spans is different than current
+ * tail span, or if its high value changed, in which case we should
+ * check if the updated node can share down spans with other nodes.
+ */
+ if(tail_span->down->tail != prev_down_tail_span ||
+ prev_down_tail_span_high != tail_span->down->tail->high) {
+ H5S_hyper_span_t *stop_span; /* Pointer to span to stop at */
+ H5S_hyper_span_t *tmp_span; /* Temporary pointer to a span */
+ uint64_t op_gen; /* Operation generation value */
+
+ /* Determine which span to stop at */
+ if(tail_span->down->tail != prev_down_tail_span) {
+ /* Sanity check */
+ HDassert(prev_down_tail_span->next == tail_span->down->tail);
+
+ /* Set the span to stop at */
+ stop_span = prev_down_tail_span;
+ } /* end if */
+ else {
+ /* Sanity check */
+ HDassert(prev_down_tail_span_high != tail_span->down->tail->high);
- /* Increment reference count on shared "down tree" */
- tmp_span->down->count++;
- } /* end else */
+ /* Set the span to stop at */
+ stop_span = tail_span->down->tail;
+ } /* end else */
- /* Found span to merge into, break out now */
- break;
- } /* end if */
+ /* Acquire an operation generation value for this operation */
+ op_gen = H5S__hyper_get_op_gen();
- /* Advance to next span to check */
- tmp2_span=tmp2_span->next;
- } /* end while */
+ /* Check if the 'stop' span in the "down tree" is equal to any other
+ * spans in the list of spans in the span tree.
+ *
+ * If so, release last span information and make last span merge into
+ * previous span (if possible), or at least share their "down tree"
+ * information.
+ */
+ tmp_span = tail_span->down->head;
+ while(tmp_span != stop_span) {
+ hbool_t attempt_merge_spans = FALSE; /* Whether to merge spans */
- /* Make span tree for current coordinates */
- if(NULL == (new_span = H5S__hyper_coord_to_span(rank, coords)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span")
+ /* Different tests for when to run the 'merge' algorithm,
+ * depending whether there's "down trees" or not.
+ */
+ if(NULL == tmp_span->down) {
+ /* Spin through spans until we find the one before the 'stop' span */
+ if(tmp_span->next == stop_span)
+ attempt_merge_spans = TRUE;
+ } /* end if */
+ else {
+ /* Check if we've compared the 'stop' span's "down tree" to
+ * this span's "down tree" already.
+ */
+ if(tmp_span->down->op_gen != op_gen) {
+ if(H5S__hyper_cmp_spans(tmp_span->down, stop_span->down))
+ attempt_merge_spans = TRUE;
+
+ /* Remember that we visited this span's "down tree" already */
+ /* (Because it wasn't the same as the 'stop' span's down tree
+ * and we don't need to compare it again)
+ */
+ tmp_span->down->op_gen = op_gen;
+ } /* end if */
+ } /* end else */
- /* Add new span tree as span */
- HDassert(tmp_span);
- tmp_span->next=new_span;
+ /* Check for merging into previous span */
+ if(attempt_merge_spans) {
+ if(tmp_span->high + 1 == stop_span->low) {
+ /* Increase size of previous span */
+ tmp_span->high++;
- /* Make scratch pointer point to last span in list */
- HDassert(tspan_info);
- tspan_info->scratch=(H5S_hyper_span_info_t *)new_span;
+ /* Update pointers appropriately */
+ if(stop_span == prev_down_tail_span) {
+ /* Sanity check */
+ HDassert(stop_span->next == tail_span->down->tail);
- /* Set the proper 'pstride' for new span */
- new_span->pstride=new_span->low-tmp_span->low;
- } /* end if */
- else {
- /* Does new node adjoin existing node? */
- if(tmp_span->high+1==coords[0]) {
- tmp_span->high++;
- tmp_span->nelem++;
-
- /* Check if this span tree should now be merged with a level higher in the tree */
- if(prev_span_info!=NULL) {
- /* Before we create another span at this level in the tree, check if
- * the last span's "down tree" was equal to any other spans in this
- * list of spans in the span tree.
- *
- * If so, release last span information and make last span merge into
- * previous span (if possible), or at least share their "down tree"
- * information.
- */
- tmp2_span=prev_span_info->head;
- tmp_span=(H5S_hyper_span_t *)prev_span_info->scratch;
- while(tmp2_span!=tmp_span) {
- if(H5S__hyper_cmp_spans(tmp2_span->down,tmp_span->down)==TRUE) {
- /* Check for merging into previous span */
- if(tmp2_span->high+1==tmp_span->low) {
- /* Release last span created */
- H5S__hyper_free_span(tmp_span);
-
- /* Increase size of previous span */
- tmp2_span->high++;
- tmp2_span->nelem++;
-
- /* Update pointers */
- tmp2_span->next=NULL;
- prev_span_info->scratch=(H5S_hyper_span_info_t *)tmp2_span;
+ tmp_span->next = stop_span->next;
} /* end if */
- /* Span is disjoint, but has the same "down tree" selection */
else {
- /* Release "down tree" information */
- H5S__hyper_free_span_info(tmp_span->down);
+ /* Sanity check */
+ HDassert(tmp_span->next == tail_span->down->tail);
- /* Point at earlier span's "down tree" */
- tmp_span->down=tmp2_span->down;
-
- /* Increment reference count on shared "down tree" */
- tmp_span->down->count++;
+ tmp_span->next = NULL;
+ tail_span->down->tail = tmp_span;
} /* end else */
- /* Found span to merge into, break out now */
- break;
+ /* Release last span created */
+ H5S__hyper_free_span(stop_span);
} /* end if */
+ /* Span is disjoint, but has the same "down tree" selection */
+ /* (If it has a "down tree") */
+ else if(stop_span->down) {
+ /* Release "down tree" information */
+ H5S__hyper_free_span_info(stop_span->down);
- /* Advance to next span to check */
- tmp2_span=tmp2_span->next;
- } /* end while */
- } /* end if */
+ /* Point at earlier span's "down tree" */
+ stop_span->down = tmp_span->down;
+
+ /* Increment reference count on shared "down tree" */
+ stop_span->down->count++;
+ } /* end else */
+
+ /* Found span to merge into, break out now */
+ break;
+ } /* end if */
+
+ /* Advance to next span to check */
+ tmp_span = tmp_span->next;
+ } /* end while */
} /* end if */
- else {
- if(NULL == (new_span = H5S__hyper_new_span(coords[0], coords[0], NULL, NULL)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span")
+ } /* end if */
+ else {
+ unsigned u; /* Local index variable */
- /* Add new span tree as span */
- HDassert(tmp_span);
- tmp_span->next=new_span;
+ /* Check if we made it all the way to the bottom span list in the tree
+ * and the new coordinate adjoins the current tail span.
+ */
+ if(rank == 1 && (tail_span->high + 1) == coords[0])
+ /* Append element to current tail span */
+ tail_span->high++;
+ else {
+ H5S_hyper_span_t *new_span; /* New span created for element */
- /* Make scratch pointer point to last span in list */
- tspan_info->scratch=(H5S_hyper_span_info_t *)new_span;
+ /* Make span tree for current coordinate(s) */
+ if(NULL == (new_span = H5S__hyper_coord_to_span(rank, coords)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab spans for coordinate")
- /* Set the proper 'pstride' for new span */
- new_span->pstride = new_span->low - tmp_span->low;
+ /* Add new span to span tree list */
+ tail_span->next = new_span;
+ span_tree->tail = new_span;
} /* end else */
+
+ /* Update high bound for current span tree */
+ HDassert(coords[0] > span_tree->high_bounds[0]);
+ span_tree->high_bounds[0] = coords[0];
+
+ /* Update high bounds for dimensions below this one */
+ for(u = 1; u < rank; u++)
+ if(coords[u] > span_tree->high_bounds[u])
+ span_tree->high_bounds[u] = coords[u];
+
+ /* Need to signal to higher dimensions that high bounds changed */
+ *first_dim_modified = 0;
} /* end else */
done:
@@ -3721,6 +6057,24 @@ done:
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
Assumes that the element is not already in the dataspace's selection
+
+ NOTE: There's also an assumption about the context of this function call -
+ This function is only called is only being called from H5D_chunk_mem_cb
+ in src/H5Dchunk.c, when the library is iterating over a memory
+ selection, so the coordinates passed to H5S_hyper_add_span_element will
+ always be in increasing order (according to a row-major (i.e. C, not
+ FORTRAN) scan) over the dataset. Therefore, for every input of
+ coordinates, only the last span element (i.e., the tail pointer) in
+ one dimension is checked against the input.
+
+ NOTE: This algorithm is definitely "correct" and tries to conserve memory
+ as much as possible, but it's doing a _lot_ of work that might be
+ better spent running a similar algorithm to "condense" the span tree
+ (possibly even back into a regular selection) just before the selection
+ is used for I/O on the chunk. I'm not going to spend the time on this
+ currently, but it does sound like a good direction to explore.
+ QAK, 2019/01/24
+
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
@@ -3740,9 +6094,13 @@ H5S_hyper_add_span_element(H5S_t *space, unsigned rank, const hsize_t *coords)
/* Check if this is the first element in the selection */
if(NULL == space->select.sel_info.hslab) {
/* Allocate a span info node */
- if(NULL == (head = H5FL_CALLOC(H5S_hyper_span_info_t)))
+ if(NULL == (head = H5S__hyper_new_span_info(rank)))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab span info")
+ /* Set the low & high bounds for this span info node */
+ H5MM_memcpy(head->low_bounds, coords, rank * sizeof(hsize_t));
+ H5MM_memcpy(head->high_bounds, coords, rank * sizeof(hsize_t));
+
/* Set the reference count */
head->count = 1;
@@ -3750,6 +6108,9 @@ H5S_hyper_add_span_element(H5S_t *space, unsigned rank, const hsize_t *coords)
if(NULL == (head->head = H5S__hyper_coord_to_span(rank, coords)))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab spans for coordinate")
+ /* Update the tail pointer of this newly created span in dimension "rank" */
+ head->tail = head->head;
+
/* Allocate selection info */
if(NULL == (space->select.sel_info.hslab = H5FL_MALLOC(H5S_hyper_sel_t)))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab selection")
@@ -3761,7 +6122,7 @@ H5S_hyper_add_span_element(H5S_t *space, unsigned rank, const hsize_t *coords)
space->select.type = H5S_sel_hyper;
/* Reset "regular" hyperslab flag */
- space->select.sel_info.hslab->diminfo_valid = FALSE;
+ space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_NO;
/* Set unlim_dim */
space->select.sel_info.hslab->unlim_dim = -1;
@@ -3770,7 +6131,10 @@ H5S_hyper_add_span_element(H5S_t *space, unsigned rank, const hsize_t *coords)
space->select.num_elem = 1;
} /* end if */
else {
- if(H5S__hyper_add_span_element_helper(space->select.sel_info.hslab->span_lst, rank, coords) < 0)
+ int first_dim_modified = -1; /* Index of first dimension modified */
+
+ /* Add the element to the current set of spans */
+ if(H5S__hyper_add_span_element_helper(space->select.sel_info.hslab->span_lst, rank, coords, &first_dim_modified) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert coordinate into span tree")
/* Increment # of elements in selection */
@@ -3788,236 +6152,16 @@ done:
/*--------------------------------------------------------------------------
NAME
- H5S_hyper_reset_scratch
- PURPOSE
- Reset the scratch information for span tree
- USAGE
- herr_t H5S_hyper_reset_scratch(space)
- H5S_t *space; IN/OUT: Pointer to dataspace to reset scratch pointers
- RETURNS
- Non-negative on success, negative on failure
- DESCRIPTION
- Resets the "scratch" pointers used for various tasks in computing hyperslab
- spans.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-herr_t
-H5S_hyper_reset_scratch(H5S_t *space)
-{
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(FAIL)
-
- HDassert(space);
-
- /* Check if there are spans in the span tree */
- if(space->select.sel_info.hslab->span_lst != NULL)
- /* Reset the scratch pointers for the next routine which needs them */
- H5S__hyper_span_scratch(space->select.sel_info.hslab->span_lst);
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5S_hyper_reset_scratch() */
-
-
-/*--------------------------------------------------------------------------
- NAME
- H5S_hyper_convert
- PURPOSE
- Convert a compatible selection to span tree form
- USAGE
- herr_t H5S_hyper_convert(space)
- H5S_t *space; IN/OUT: Pointer to dataspace to convert
- RETURNS
- Non-negative on success, negative on failure
- DESCRIPTION
- Converts a compatible selection (currently only "all" selections) to the
- span-tree form of a hyperslab selection. (Point and "none" selection aren't
- currently supported and hyperslab selection always have the span-tree form
- available).
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-herr_t
-H5S_hyper_convert(H5S_t *space)
-{
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(FAIL)
-
- HDassert(space);
-
- /* Check the type of selection */
- switch(H5S_GET_SELECT_TYPE(space)) {
- case H5S_SEL_ALL: /* All elements selected in dataspace */
- /* Convert current "all" selection to "real" hyperslab selection */
- {
- const hsize_t *tmp_start; /* Temporary start information */
- const hsize_t *tmp_stride; /* Temporary stride information */
- const hsize_t *tmp_count; /* Temporary count information */
- const hsize_t *tmp_block; /* Temporary block information */
-
- /* Set up temporary information for the dimensions */
- tmp_start = H5S_hyper_zeros_g;
- tmp_stride = tmp_count = H5S_hyper_ones_g;
- tmp_block = space->extent.size;
-
- /* Convert to hyperslab selection */
- if(H5S_select_hyperslab(space,H5S_SELECT_SET,tmp_start,tmp_stride,tmp_count,tmp_block)<0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "can't convert selection")
- } /* end case */
- break;
-
- case H5S_SEL_HYPERSLABS: /* Hyperslab selection */
- break;
-
- case H5S_SEL_NONE: /* No elements selected in dataspace */
- case H5S_SEL_POINTS: /* Point selection */
- case H5S_SEL_ERROR: /* Selection error */
- case H5S_SEL_N: /* Selection count */
- default:
- HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "can't convert to span tree selection")
- } /* end switch */
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5S_hyper_convert() */
-
-#ifdef LATER
-
-/*--------------------------------------------------------------------------
- NAME
- H5S_hyper_intersect_helper
- PURPOSE
- Helper routine to detect intersections in span trees
- USAGE
- htri_t H5S_hyper_intersect_helper(spans1, spans2)
- H5S_hyper_span_info_t *spans1; IN: First span tree to operate with
- H5S_hyper_span_info_t *spans2; IN: Second span tree to operate with
- RETURNS
- Non-negative on success, negative on failure
- DESCRIPTION
- Quickly detect intersections between two span trees
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-static htri_t
-H5S_hyper_intersect_helper (H5S_hyper_span_info_t *spans1, H5S_hyper_span_info_t *spans2)
-{
- H5S_hyper_span_t *curr1; /* Pointer to current span in 1st span tree */
- H5S_hyper_span_t *curr2; /* Pointer to current span in 2nd span tree */
- htri_t status; /* Status from recursive call */
- htri_t ret_value=FALSE; /* Return value */
-
- FUNC_ENTER_NOAPI_NOINIT
-
- /* Sanity check */
- HDassert((spans1 && spans2) || (spans1 == NULL && spans2 == NULL));
-
- /* "NULL" span trees compare as overlapping */
- if(spans1==NULL && spans2==NULL)
- HGOTO_DONE(TRUE);
-
- /* Get the span lists for each span in this tree */
- curr1=spans1->head;
- curr2=spans2->head;
-
- /* Iterate over the spans in each tree */
- while(curr1!=NULL && curr2!=NULL) {
- /* Check for 1st span entirely before 2nd span */
- if(curr1->high<curr2->low)
- curr1=curr1->next;
- /* Check for 2nd span entirely before 1st span */
- else if(curr2->high<curr1->low)
- curr2=curr2->next;
- /* Spans must overlap */
- else {
- /* Recursively check spans in next dimension down */
- if((status=H5S_hyper_intersect_helper(curr1->down,curr2->down))<0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_BADSELECT, FAIL, "can't perform hyperslab intersection check")
-
- /* If there is a span intersection in the down dimensions, the span trees overlap */
- if(status==TRUE)
- HGOTO_DONE(TRUE);
-
- /* No intersection in down dimensions, advance to next span */
- if(curr1->high<curr2->high)
- curr1=curr1->next;
- else
- curr2=curr2->next;
- } /* end else */
- } /* end while */
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_hyper_intersect_helper() */
-
-
-/*--------------------------------------------------------------------------
- NAME
- H5S_hyper_intersect
- PURPOSE
- Detect intersections in span trees
- USAGE
- htri_t H5S_hyper_intersect(space1, space2)
- H5S_t *space1; IN: First dataspace to operate on span tree
- H5S_t *space2; IN: Second dataspace to operate on span tree
- RETURNS
- Non-negative on success, negative on failure
- DESCRIPTION
- Quickly detect intersections between two span trees
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-htri_t
-H5S_hyper_intersect (H5S_t *space1, H5S_t *space2)
-{
- htri_t ret_value=FAIL; /* Return value */
-
- FUNC_ENTER_NOAPI_NOINIT
-
- /* Sanity check */
- HDassert(space1);
- HDassert(space2);
-
- /* Check that the space selections both have span trees */
- if(space1->select.sel_info.hslab->span_lst==NULL ||
- space2->select.sel_info.hslab->span_lst==NULL)
- HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "dataspace does not have span tree")
-
- /* Check that the dataspaces are both the same rank */
- if(space1->extent.rank!=space2->extent.rank)
- HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "dataspace ranks don't match")
-
- /* Perform the span-by-span intersection check */
- if((ret_value=H5S_hyper_intersect_helper(space1->select.sel_info.hslab->span_lst,space2->select.sel_info.hslab->span_lst))<0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_BADSELECT, FAIL, "can't perform hyperslab intersection check")
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_hyper_intersect() */
-#endif /* LATER */
-
-
-/*--------------------------------------------------------------------------
- NAME
H5S__hyper_intersect_block_helper
PURPOSE
Helper routine to detect intersections in span trees
USAGE
hbool_t H5S__hyper_intersect_block_helper(spans, start, end)
H5S_hyper_span_info_t *spans; IN: First span tree to operate with
+ unsigned rank; IN: Number of dimensions for span tree
hsize_t *start; IN: Starting coordinate for block
hsize_t *end; IN: Ending coordinate for block
+ uint64_t op_gen; IN: Operation generation
RETURN
Non-negative (TRUE/FALSE) on success, can't fail
DESCRIPTION
@@ -4028,10 +6172,9 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
static hbool_t
-H5S__hyper_intersect_block_helper(const H5S_hyper_span_info_t *spans,
- const hsize_t *start, const hsize_t *end)
+H5S__hyper_intersect_block_helper(H5S_hyper_span_info_t *spans,
+ unsigned rank, const hsize_t *start, const hsize_t *end, uint64_t op_gen)
{
- H5S_hyper_span_t *curr; /* Pointer to current span in 1st span tree */
hbool_t ret_value = FALSE; /* Return value */
FUNC_ENTER_STATIC_NOERR
@@ -4041,37 +6184,52 @@ H5S__hyper_intersect_block_helper(const H5S_hyper_span_info_t *spans,
HDassert(start);
HDassert(end);
- /* Get the span list for spans in this tree */
- curr = spans->head;
-
- /* Iterate over the spans in the tree */
- while(curr != NULL) {
- /* Check for span entirely before block */
- if(curr->high < *start)
- /* Advance to next span in this dimension */
- curr = curr->next;
- /* If this span is past the end of the block, then we're done in this dimension */
- else if(curr->low > *end)
- HGOTO_DONE(FALSE)
- /* block & span overlap */
- else {
- if(curr->down == NULL)
- HGOTO_DONE(TRUE)
- else {
- hbool_t status; /* Status from recursive call */
+ /* Check if we've already visited this span tree */
+ if(spans->op_gen != op_gen) {
+ H5S_hyper_span_t *curr; /* Pointer to current span in 1st span tree */
+ unsigned u; /* Local index variable */
- /* Recursively check spans in next dimension down */
- status = H5S__hyper_intersect_block_helper(curr->down, start + 1, end + 1);
+ /* Verify that there is a possibility of an overlap by checking the block
+ * against the low & high bounds for the span tree.
+ */
+ for(u = 0; u < rank; u++)
+ if(start[u] > spans->high_bounds[u] || end[u] < spans->low_bounds[u])
+ HGOTO_DONE(FALSE)
- /* If there is a span intersection in the down dimensions, the span trees overlap */
- if(status == TRUE)
- HGOTO_DONE(TRUE);
+ /* Get the span list for spans in this tree */
+ curr = spans->head;
- /* No intersection in down dimensions, advance to next span */
+ /* Iterate over the spans in the tree */
+ while(curr != NULL) {
+ /* Check for span entirely before block */
+ if(curr->high < *start)
+ /* Advance to next span in this dimension */
curr = curr->next;
+ /* If this span is past the end of the block, then we're done in this dimension */
+ else if(curr->low > *end)
+ HGOTO_DONE(FALSE)
+ /* block & span overlap */
+ else {
+ /* If this is the bottom dimension, then the span tree overlaps the block */
+ if(curr->down == NULL)
+ HGOTO_DONE(TRUE)
+ /* Recursively check spans in next dimension down */
+ else {
+ /* If there is an intersection in the "down" dimensions,
+ * the span trees overlap.
+ */
+ if(H5S__hyper_intersect_block_helper(curr->down, rank - 1, start + 1, end + 1, op_gen))
+ HGOTO_DONE(TRUE)
+
+ /* No intersection in down dimensions, advance to next span */
+ curr = curr->next;
+ } /* end else */
} /* end else */
- } /* end else */
- } /* end while */
+ } /* end while */
+
+ /* Set the tree's operation generation */
+ spans->op_gen = op_gen;
+ } /* end if */
/* Fall through with 'FALSE' return value */
@@ -4096,33 +6254,130 @@ done:
Quickly detect intersections between span tree and block
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
+ Does not use selection offset.
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
htri_t
H5S_hyper_intersect_block(H5S_t *space, const hsize_t *start, const hsize_t *end)
{
+ const hsize_t *low_bounds, *high_bounds; /* Pointers to the correct pair of low & high bounds */
+ unsigned u; /* Local index variable */
htri_t ret_value = FAIL; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
/* Sanity check */
HDassert(space);
+ HDassert(H5S_SEL_HYPERSLABS == H5S_GET_SELECT_TYPE(space));
HDassert(start);
HDassert(end);
- /* Check for 'all' selection, instead of a hyperslab selection */
- /* (Technically, this shouldn't be in the "hyperslab" routines...) */
- if(H5S_GET_SELECT_TYPE(space) == H5S_SEL_ALL)
- HGOTO_DONE(TRUE);
+ /* Attempt to rebuild diminfo if it is invalid and has not been confirmed
+ * to be impossible.
+ */
+ if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_NO)
+ H5S__hyper_rebuild(space);
- /* Check that the space selection has a span tree */
- if(NULL == space->select.sel_info.hslab->span_lst)
- if(H5S__hyper_generate_spans(space) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "dataspace does not have span tree")
+ /* Check which set of low & high bounds we should be using */
+ if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) {
+ low_bounds = space->select.sel_info.hslab->diminfo.low_bounds;
+ high_bounds = space->select.sel_info.hslab->diminfo.high_bounds;
+ } /* end if */
+ else {
+ low_bounds = space->select.sel_info.hslab->span_lst->low_bounds;
+ high_bounds = space->select.sel_info.hslab->span_lst->high_bounds;
+ } /* end else */
- /* Perform the span-by-span intersection check */
- ret_value = H5S__hyper_intersect_block_helper(space->select.sel_info.hslab->span_lst, start, end);
+ /* Loop over selection bounds and block, checking for overlap */
+ for(u = 0; u < space->extent.rank; u++)
+ /* If selection bounds & block don't overlap, can leave now */
+ if(!H5S_RANGE_OVERLAP(low_bounds[u], high_bounds[u], start[u], end[u]))
+ HGOTO_DONE(FALSE)
+
+ /* Check for regular hyperslab intersection */
+ if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) {
+ hbool_t single_block; /* Whether the regular selection is a single block */
+
+ /* Check for a single block */
+ /* For a regular hyperslab to be single, it must have only one block
+ * (i.e. count == 1 in all dimensions).
+ */
+ single_block = TRUE;
+ for(u = 0; u < space->extent.rank; u++)
+ if(space->select.sel_info.hslab->diminfo.opt[u].count > 1)
+ single_block = FALSE;
+
+ /* Single blocks have already been "compared" above, in the low / high
+ * bound checking, so just return TRUE if we've reached here - they
+ * would have been rejected earlier, if they didn't intersect.
+ */
+ if(single_block)
+ HGOTO_DONE(TRUE)
+ else {
+ /* Loop over the dimensions, checking for an intersection */
+ for(u = 0; u < space->extent.rank; u++) {
+ /* If the block's start is <= the hyperslab start, they intersect */
+ /* (So, if the start is > the hyperslab start, check more conditions) */
+ if(start[u] > space->select.sel_info.hslab->diminfo.opt[u].start) {
+ hsize_t adj_start; /* Start coord, adjusted for hyperslab selection parameters */
+ hsize_t nstride; /* Number of strides into the selection */
+
+ /* Adjust start coord for selection's 'start' offset */
+ adj_start = start[u] - space->select.sel_info.hslab->diminfo.opt[u].start;
+
+ /* Compute # of strides into the selection */
+ if(space->select.sel_info.hslab->diminfo.opt[u].count > 1)
+ nstride = adj_start / space->select.sel_info.hslab->diminfo.opt[u].stride;
+ else
+ nstride = 0;
+
+ /* Sanity check */
+ HDassert(nstride <= space->select.sel_info.hslab->diminfo.opt[u].count);
+
+ /* "Rebase" the adjusted start coord into the same range
+ * range of values as the selections's first block.
+ */
+ adj_start -= nstride * space->select.sel_info.hslab->diminfo.opt[u].stride;
+
+ /* If the adjusted start doesn't fall within the first hyperslab
+ * span, check for the block overlapping with the next one.
+ */
+ if(adj_start >= space->select.sel_info.hslab->diminfo.opt[u].block) {
+ hsize_t adj_end; /* End coord, adjusted for hyperslab selection parameters */
+
+ /* Adjust end coord for selection's 'start' offset */
+ adj_end = end[u] - space->select.sel_info.hslab->diminfo.opt[u].start;
+
+ /* "Rebase" the adjusted end coord into the same range
+ * range of values as the selections's first block.
+ */
+ adj_end -= nstride * space->select.sel_info.hslab->diminfo.opt[u].stride;
+
+ /* If block doesn't extend over beginning of next span,
+ * it doesn't intersect.
+ */
+ if(adj_end < space->select.sel_info.hslab->diminfo.opt[u].stride)
+ HGOTO_DONE(FALSE)
+ } /* end if */
+ } /* end if */
+ } /* end for */
+
+ /* If we've looped through all dimensions and none of them didn't
+ * overlap, then all of them do, so we report TRUE.
+ */
+ HGOTO_DONE(TRUE)
+ } /* end else */
+ } /* end if */
+ else {
+ uint64_t op_gen; /* Operation generation value */
+
+ /* Acquire an operation generation value for this operation */
+ op_gen = H5S__hyper_get_op_gen();
+
+ /* Perform the span-by-span intersection check */
+ ret_value = H5S__hyper_intersect_block_helper(space->select.sel_info.hslab->span_lst, space->extent.rank, start, end, op_gen);
+ } /* end else */
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -4137,7 +6392,9 @@ done:
USAGE
void H5S__hyper_adjust_u_helper(spans, offset)
H5S_hyper_span_info_t *spans; IN: Span tree to operate with
+ unsigned rank; IN: Number of dimensions for span tree
const hsize_t *offset; IN: Offset to subtract
+ uint64_t op_gen; IN: Operation generation
RETURNS
None
DESCRIPTION
@@ -4148,23 +6405,26 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
static void
-H5S__hyper_adjust_u_helper(H5S_hyper_span_info_t *spans,
- const hsize_t *offset)
+H5S__hyper_adjust_u_helper(H5S_hyper_span_info_t *spans, unsigned rank,
+ const hsize_t *offset, uint64_t op_gen)
{
FUNC_ENTER_STATIC_NOERR
/* Sanity checks */
HDassert(spans);
- HDassert(spans->scratch == (H5S_hyper_span_info_t *)~((size_t)NULL) ||
- spans->scratch == NULL);
HDassert(offset);
- /* Check if we've already set this down span tree */
- if(spans->scratch != (H5S_hyper_span_info_t *)~((size_t)NULL)) {
+ /* Check if we've already set this span tree */
+ if(spans->op_gen != op_gen) {
H5S_hyper_span_t *span; /* Pointer to current span in span tree */
+ unsigned u; /* Local index variable */
- /* Set the tree's scratch pointer */
- spans->scratch = (H5S_hyper_span_info_t *)~((size_t)NULL);
+ /* Adjust the span tree's low & high bounds */
+ for(u = 0; u < rank; u++) {
+ HDassert(spans->low_bounds[u] >= offset[u]);
+ spans->low_bounds[u] -= offset[u];
+ spans->high_bounds[u] -= offset[u];
+ } /* end for */
/* Iterate over the spans in tree */
span = spans->head;
@@ -4176,11 +6436,14 @@ H5S__hyper_adjust_u_helper(H5S_hyper_span_info_t *spans,
/* Recursively adjust spans in next dimension down */
if(span->down != NULL)
- H5S__hyper_adjust_u_helper(span->down, offset + 1);
+ H5S__hyper_adjust_u_helper(span->down, rank - 1, offset + 1, op_gen);
/* Advance to next span in this dimension */
span = span->next;
} /* end while */
+
+ /* Set the tree's operation generation */
+ spans->op_gen = op_gen;
} /* end if */
FUNC_LEAVE_NOAPI_VOID
@@ -4215,21 +6478,29 @@ H5S__hyper_adjust_u(H5S_t *space, const hsize_t *offset)
HDassert(offset);
/* Subtract the offset from the "regular" coordinates, if they exist */
- if(space->select.sel_info.hslab->diminfo_valid) {
+ /* (No need to rebuild the dimension info yet -QAK) */
+ if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) {
unsigned u; /* Local index variable */
for(u = 0; u < space->extent.rank; u++) {
- HDassert(space->select.sel_info.hslab->opt_diminfo[u].start >= offset[u]);
- space->select.sel_info.hslab->opt_diminfo[u].start -= offset[u];
+ HDassert(space->select.sel_info.hslab->diminfo.opt[u].start >= offset[u]);
+ space->select.sel_info.hslab->diminfo.opt[u].start -= offset[u];
+
+ /* Adjust the low & high bounds */
+ HDassert(space->select.sel_info.hslab->diminfo.low_bounds[u] >= offset[u]);
+ space->select.sel_info.hslab->diminfo.low_bounds[u] -= offset[u];
+ space->select.sel_info.hslab->diminfo.high_bounds[u] -= offset[u];
} /* end for */
} /* end if */
/* Subtract the offset from the span tree coordinates, if they exist */
if(space->select.sel_info.hslab->span_lst) {
- H5S__hyper_adjust_u_helper(space->select.sel_info.hslab->span_lst, offset);
+ uint64_t op_gen; /* Operation generation value */
+
+ /* Acquire an operation generation value for this operation */
+ op_gen = H5S__hyper_get_op_gen();
- /* Reset the scratch pointers for the next routine which needs them */
- H5S__hyper_span_scratch(space->select.sel_info.hslab->span_lst);
+ H5S__hyper_adjust_u_helper(space->select.sel_info.hslab->span_lst, space->extent.rank, offset, op_gen);
} /* end if */
FUNC_LEAVE_NOAPI(SUCCEED)
@@ -4242,7 +6513,7 @@ H5S__hyper_adjust_u(H5S_t *space, const hsize_t *offset)
* Purpose: Projects a single element hyperslab selection into a scalar
* dataspace
*
- * Return: non-negative on success, negative on failure.
+ * Return: Non-negative on success, negative on failure.
*
* Programmer: Quincey Koziol
* Sunday, July 18, 2010
@@ -4261,12 +6532,20 @@ H5S__hyper_project_scalar(const H5S_t *space, hsize_t *offset)
HDassert(offset);
/* Check for a "regular" hyperslab selection */
- if(space->select.sel_info.hslab->diminfo_valid) {
- const H5S_hyper_dim_t *diminfo = space->select.sel_info.hslab->opt_diminfo; /* Alias for dataspace's diminfo information */
+ /* (No need to rebuild the dimension info yet -QAK) */
+ if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) {
+ const H5S_hyper_dim_t *diminfo = space->select.sel_info.hslab->diminfo.opt; /* Alias for dataspace's diminfo information */
unsigned u; /* Counter */
/* Build the table of the initial offset */
for(u = 0; u < space->extent.rank; u++) {
+ /* Sanity check diminfo */
+ HDassert(1 == diminfo[u].count);
+ HDassert(1 == diminfo[u].block);
+
+ /* Sanity check bounds, while we're here */
+ HDassert(diminfo[u].start == space->select.sel_info.hslab->diminfo.low_bounds[u]);
+
/* Keep the offset for later */
block[u] = diminfo[u].start;
} /* end for */
@@ -4278,17 +6557,22 @@ H5S__hyper_project_scalar(const H5S_t *space, hsize_t *offset)
/* Advance down selected spans */
curr = space->select.sel_info.hslab->span_lst->head;
curr_dim = 0;
- while(curr) {
- /* Sanity check for more than one span */
+ while(1) {
+ /* Sanity checks */
HDassert(NULL == curr->next);
HDassert(curr->low == curr->high);
+ HDassert(curr_dim < space->extent.rank);
/* Save the location of the selection in current dimension */
block[curr_dim] = curr->low;
/* Advance down to next dimension */
- curr = curr->down->head;
- curr_dim++;
+ if(curr->down) {
+ curr = curr->down->head;
+ curr_dim++;
+ } /* end if */
+ else
+ break;
} /* end while */
} /* end else */
@@ -4305,7 +6589,7 @@ H5S__hyper_project_scalar(const H5S_t *space, hsize_t *offset)
* Purpose: Projects a hyperslab selection onto/into a simple dataspace
* of a lower rank
*
- * Return: non-negative on success, negative on failure.
+ * Return: Non-negative on success, negative on failure.
*
* Programmer: Quincey Koziol
* Sunday, July 18, 2010
@@ -4352,7 +6636,7 @@ H5S__hyper_project_simple_lower(const H5S_t *base_space, H5S_t *new_space)
* Purpose: Projects a hyperslab selection onto/into a simple dataspace
* of a higher rank
*
- * Return: non-negative on success, negative on failure.
+ * Return: Non-negative on success, negative on failure.
*
* Programmer: Quincey Koziol
* Sunday, July 18, 2010
@@ -4365,6 +6649,7 @@ H5S__hyper_project_simple_higher(const H5S_t *base_space, H5S_t *new_space)
H5S_hyper_span_t *prev_span = NULL; /* Pointer to previous list of spans */
unsigned delta_rank; /* Difference in dataspace ranks */
unsigned curr_dim; /* Current dimension being operated on */
+ unsigned u; /* Local index variable */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
@@ -4383,10 +6668,9 @@ H5S__hyper_project_simple_higher(const H5S_t *base_space, H5S_t *new_space)
H5S_hyper_span_t *new_span; /* Temporary hyperslab span */
/* Allocate a new span_info node */
- if(NULL == (new_span_info = H5FL_CALLOC(H5S_hyper_span_info_t))) {
+ if(NULL == (new_span_info = H5S__hyper_new_span_info(new_space->extent.rank))) {
if(prev_span)
- if(H5S__hyper_free_span(prev_span) < 0)
- HERROR(H5E_DATASPACE, H5E_CANTFREE, "can't free hyperslab span");
+ H5S__hyper_free_span(prev_span);
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab span info")
} /* end if */
@@ -4398,13 +6682,24 @@ H5S__hyper_project_simple_higher(const H5S_t *base_space, H5S_t *new_space)
if(NULL == (new_span = H5S__hyper_new_span((hsize_t)0, (hsize_t)0, NULL, NULL))) {
HDassert(new_span_info);
if(!prev_span)
- (void)H5FL_FREE(H5S_hyper_span_info_t, new_span_info);
+ (void)H5FL_ARR_FREE(hbounds_t, new_span_info);
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab span")
} /* end if */
/* Set the span_info information */
new_span_info->count = 1;
new_span_info->head = new_span;
+ new_span_info->tail = new_span;
+
+ /* Set the bounding box */
+ for(u = 0; u < delta_rank; u++) {
+ new_span_info->low_bounds[u] = 0;
+ new_span_info->high_bounds[u] = 0;
+ } /* end for */
+ for(; u < new_space->extent.rank; u++) {
+ new_span_info->low_bounds[u] = base_space->select.sel_info.hslab->span_lst->low_bounds[u - delta_rank];
+ new_span_info->high_bounds[u] = base_space->select.sel_info.hslab->span_lst->high_bounds[u - delta_rank];
+ } /* end for */
/* Attach to new space, if top span info */
if(NULL == new_space->select.sel_info.hslab->span_lst)
@@ -4426,10 +6721,9 @@ H5S__hyper_project_simple_higher(const H5S_t *base_space, H5S_t *new_space)
done:
if(ret_value < 0 && new_space->select.sel_info.hslab->span_lst) {
if(new_space->select.sel_info.hslab->span_lst->head)
- if(H5S__hyper_free_span(new_space->select.sel_info.hslab->span_lst->head) < 0)
- HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "can't free hyperslab span")
+ H5S__hyper_free_span(new_space->select.sel_info.hslab->span_lst->head);
- new_space->select.sel_info.hslab->span_lst = H5FL_FREE(H5S_hyper_span_info_t, new_space->select.sel_info.hslab->span_lst);
+ new_space->select.sel_info.hslab->span_lst = (H5S_hyper_span_info_t *)H5FL_ARR_FREE(hbounds_t, new_space->select.sel_info.hslab->span_lst);
} /* end if */
FUNC_LEAVE_NOAPI(ret_value)
@@ -4442,7 +6736,7 @@ done:
* Purpose: Projects a hyperslab selection onto/into a simple dataspace
* of a different rank
*
- * Return: non-negative on success, negative on failure.
+ * Return: Non-negative on success, negative on failure.
*
* Programmer: Quincey Koziol
* Sunday, July 18, 2010
@@ -4450,7 +6744,8 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5S__hyper_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *offset)
+H5S__hyper_project_simple(const H5S_t *base_space, H5S_t *new_space,
+ hsize_t *offset)
{
herr_t ret_value = SUCCEED; /* Return value */
@@ -4473,15 +6768,16 @@ H5S__hyper_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *of
new_space->select.sel_info.hslab->unlim_dim = -1;
/* Check for a "regular" hyperslab selection */
- if(base_space->select.sel_info.hslab->diminfo_valid) {
+ /* (No need to rebuild the dimension info yet -QAK) */
+ if(base_space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) {
unsigned base_space_dim; /* Current dimension in the base dataspace */
unsigned new_space_dim; /* Current dimension in the new dataspace */
+ unsigned u; /* Local index variable */
/* Check if the new space's rank is < or > base space's rank */
if(new_space->extent.rank < base_space->extent.rank) {
- const H5S_hyper_dim_t *opt_diminfo = base_space->select.sel_info.hslab->opt_diminfo; /* Alias for dataspace's diminfo information */
+ const H5S_hyper_dim_t *opt_diminfo = base_space->select.sel_info.hslab->diminfo.opt; /* Alias for dataspace's diminfo information */
hsize_t block[H5S_MAX_RANK]; /* Block selected in base dataspace */
- unsigned u; /* Local index variable */
/* Compute the offset for the down-projection */
HDmemset(block, 0, sizeof(block));
@@ -4501,15 +6797,15 @@ H5S__hyper_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *of
/* Set the diminfo information for the higher dimensions */
for(new_space_dim = 0; new_space_dim < (new_space->extent.rank - base_space->extent.rank); new_space_dim++) {
- new_space->select.sel_info.hslab->app_diminfo[new_space_dim].start = 0;
- new_space->select.sel_info.hslab->app_diminfo[new_space_dim].stride = 1;
- new_space->select.sel_info.hslab->app_diminfo[new_space_dim].count = 1;
- new_space->select.sel_info.hslab->app_diminfo[new_space_dim].block = 1;
-
- new_space->select.sel_info.hslab->opt_diminfo[new_space_dim].start = 0;
- new_space->select.sel_info.hslab->opt_diminfo[new_space_dim].stride = 1;
- new_space->select.sel_info.hslab->opt_diminfo[new_space_dim].count = 1;
- new_space->select.sel_info.hslab->opt_diminfo[new_space_dim].block = 1;
+ new_space->select.sel_info.hslab->diminfo.app[new_space_dim].start = 0;
+ new_space->select.sel_info.hslab->diminfo.app[new_space_dim].stride = 1;
+ new_space->select.sel_info.hslab->diminfo.app[new_space_dim].count = 1;
+ new_space->select.sel_info.hslab->diminfo.app[new_space_dim].block = 1;
+
+ new_space->select.sel_info.hslab->diminfo.opt[new_space_dim].start = 0;
+ new_space->select.sel_info.hslab->diminfo.opt[new_space_dim].stride = 1;
+ new_space->select.sel_info.hslab->diminfo.opt[new_space_dim].count = 1;
+ new_space->select.sel_info.hslab->diminfo.opt[new_space_dim].block = 1;
} /* end for */
/* Start at beginning of base space's dimension info */
@@ -4518,31 +6814,37 @@ H5S__hyper_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *of
/* Copy the diminfo */
while(base_space_dim < base_space->extent.rank) {
- new_space->select.sel_info.hslab->app_diminfo[new_space_dim].start =
- base_space->select.sel_info.hslab->app_diminfo[base_space_dim].start;
- new_space->select.sel_info.hslab->app_diminfo[new_space_dim].stride =
- base_space->select.sel_info.hslab->app_diminfo[base_space_dim].stride;
- new_space->select.sel_info.hslab->app_diminfo[new_space_dim].count =
- base_space->select.sel_info.hslab->app_diminfo[base_space_dim].count;
- new_space->select.sel_info.hslab->app_diminfo[new_space_dim].block =
- base_space->select.sel_info.hslab->app_diminfo[base_space_dim].block;
-
- new_space->select.sel_info.hslab->opt_diminfo[new_space_dim].start =
- base_space->select.sel_info.hslab->opt_diminfo[base_space_dim].start;
- new_space->select.sel_info.hslab->opt_diminfo[new_space_dim].stride =
- base_space->select.sel_info.hslab->opt_diminfo[base_space_dim].stride;
- new_space->select.sel_info.hslab->opt_diminfo[new_space_dim].count =
- base_space->select.sel_info.hslab->opt_diminfo[base_space_dim].count;
- new_space->select.sel_info.hslab->opt_diminfo[new_space_dim].block =
- base_space->select.sel_info.hslab->opt_diminfo[base_space_dim].block;
+ new_space->select.sel_info.hslab->diminfo.app[new_space_dim].start =
+ base_space->select.sel_info.hslab->diminfo.app[base_space_dim].start;
+ new_space->select.sel_info.hslab->diminfo.app[new_space_dim].stride =
+ base_space->select.sel_info.hslab->diminfo.app[base_space_dim].stride;
+ new_space->select.sel_info.hslab->diminfo.app[new_space_dim].count =
+ base_space->select.sel_info.hslab->diminfo.app[base_space_dim].count;
+ new_space->select.sel_info.hslab->diminfo.app[new_space_dim].block =
+ base_space->select.sel_info.hslab->diminfo.app[base_space_dim].block;
+
+ new_space->select.sel_info.hslab->diminfo.opt[new_space_dim].start =
+ base_space->select.sel_info.hslab->diminfo.opt[base_space_dim].start;
+ new_space->select.sel_info.hslab->diminfo.opt[new_space_dim].stride =
+ base_space->select.sel_info.hslab->diminfo.opt[base_space_dim].stride;
+ new_space->select.sel_info.hslab->diminfo.opt[new_space_dim].count =
+ base_space->select.sel_info.hslab->diminfo.opt[base_space_dim].count;
+ new_space->select.sel_info.hslab->diminfo.opt[new_space_dim].block =
+ base_space->select.sel_info.hslab->diminfo.opt[base_space_dim].block;
/* Advance to next dimensions */
base_space_dim++;
new_space_dim++;
} /* end for */
+ /* Update the bounding box */
+ for(u = 0; u < new_space->extent.rank; u++) {
+ new_space->select.sel_info.hslab->diminfo.low_bounds[u] = new_space->select.sel_info.hslab->diminfo.opt[u].start;
+ new_space->select.sel_info.hslab->diminfo.high_bounds[u] = new_space->select.sel_info.hslab->diminfo.low_bounds[u] + new_space->select.sel_info.hslab->diminfo.opt[u].stride * (new_space->select.sel_info.hslab->diminfo.opt[u].count - 1) + (new_space->select.sel_info.hslab->diminfo.opt[u].block - 1);
+ } /* end for */
+
/* Indicate that the dimension information is valid */
- new_space->select.sel_info.hslab->diminfo_valid = TRUE;
+ new_space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_YES;
/* Indicate that there's no slab information */
new_space->select.sel_info.hslab->span_lst = NULL;
@@ -4587,8 +6889,8 @@ H5S__hyper_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *of
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't project hyperslab selection into less dimensions")
} /* end else */
- /* Indicate that the dimension information is not valid */
- new_space->select.sel_info.hslab->diminfo_valid = FALSE;
+ /* Copy the status of the dimension information */
+ new_space->select.sel_info.hslab->diminfo_valid = base_space->select.sel_info.hslab->diminfo_valid;
} /* end else */
/* Number of elements selected will be the same */
@@ -4610,7 +6912,9 @@ done:
USAGE
void H5S__hyper_adjust_s_helper(spans, offset)
H5S_hyper_span_info_t *spans; IN: Span tree to operate with
+ unsigned rank; IN: Number of dimensions for span tree
const hssize_t *offset; IN: Offset to subtract
+ uint64_t op_gen; IN: Operation generation
RETURNS
None
DESCRIPTION
@@ -4621,23 +6925,26 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
static void
-H5S__hyper_adjust_s_helper(H5S_hyper_span_info_t *spans,
- const hssize_t *offset)
+H5S__hyper_adjust_s_helper(H5S_hyper_span_info_t *spans, unsigned rank,
+ const hssize_t *offset, uint64_t op_gen)
{
FUNC_ENTER_STATIC_NOERR
/* Sanity checks */
HDassert(spans);
- HDassert(spans->scratch == (H5S_hyper_span_info_t *)~((size_t)NULL) ||
- spans->scratch == NULL);
HDassert(offset);
- /* Check if we've already set this down span tree */
- if(spans->scratch != (H5S_hyper_span_info_t *)~((size_t)NULL)) {
+ /* Check if we've already set this span tree */
+ if(spans->op_gen != op_gen) {
H5S_hyper_span_t *span; /* Pointer to current span in span tree */
+ unsigned u; /* Local index variable */
- /* Set the tree's scratch pointer */
- spans->scratch = (H5S_hyper_span_info_t *)~((size_t)NULL);
+ /* Adjust the span tree's low & high bounds */
+ for(u = 0; u < rank; u++) {
+ HDassert((hssize_t)spans->low_bounds[u] >= offset[u]);
+ spans->low_bounds[u] = (hsize_t)((hssize_t)spans->low_bounds[u] - offset[u]);
+ spans->high_bounds[u] = (hsize_t)((hssize_t)spans->high_bounds[u] - offset[u]);
+ } /* end for */
/* Iterate over the spans in tree */
span = spans->head;
@@ -4649,11 +6956,14 @@ H5S__hyper_adjust_s_helper(H5S_hyper_span_info_t *spans,
/* Recursively adjust spans in next dimension down */
if(span->down != NULL)
- H5S__hyper_adjust_s_helper(span->down, offset + 1);
+ H5S__hyper_adjust_s_helper(span->down, rank - 1, offset + 1, op_gen);
/* Advance to next span in this dimension */
span = span->next;
} /* end while */
+
+ /* Set the tree's operation generation */
+ spans->op_gen = op_gen;
} /* end if */
FUNC_LEAVE_NOAPI_VOID
@@ -4681,6 +6991,8 @@ H5S__hyper_adjust_s_helper(H5S_hyper_span_info_t *spans,
herr_t
H5S_hyper_adjust_s(H5S_t *space, const hssize_t *offset)
{
+ hbool_t non_zero_offset = FALSE; /* Whether any offset is non-zero */
+ unsigned u; /* Local index variable */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -4689,22 +7001,38 @@ H5S_hyper_adjust_s(H5S_t *space, const hssize_t *offset)
HDassert(space);
HDassert(offset);
- /* Subtract the offset from the "regular" coordinates, if they exist */
- if(space->select.sel_info.hslab->diminfo_valid) {
- unsigned u; /* Local index variable */
+ /* Check for an all-zero offset vector */
+ for(u = 0; u < space->extent.rank; u++)
+ if(0 != offset[u]) {
+ non_zero_offset = TRUE;
+ break;
+ } /* end if */
- for(u = 0; u < space->extent.rank; u++) {
- HDassert((hssize_t)space->select.sel_info.hslab->opt_diminfo[u].start >= offset[u]);
- space->select.sel_info.hslab->opt_diminfo[u].start = (hsize_t)((hssize_t)space->select.sel_info.hslab->opt_diminfo[u].start - offset[u]);
- } /* end for */
- } /* end if */
+ /* Only perform operation if the offset is non-zero */
+ if(non_zero_offset) {
+ /* Subtract the offset from the "regular" coordinates, if they exist */
+ /* (No need to rebuild the dimension info yet -QAK) */
+ if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) {
+ for(u = 0; u < space->extent.rank; u++) {
+ HDassert((hssize_t)space->select.sel_info.hslab->diminfo.opt[u].start >= offset[u]);
+ space->select.sel_info.hslab->diminfo.opt[u].start = (hsize_t)((hssize_t)space->select.sel_info.hslab->diminfo.opt[u].start - offset[u]);
- /* Subtract the offset from the span tree coordinates, if they exist */
- if(space->select.sel_info.hslab->span_lst) {
- H5S__hyper_adjust_s_helper(space->select.sel_info.hslab->span_lst, offset);
+ /* Adjust the low & high bounds */
+ HDassert((hssize_t)space->select.sel_info.hslab->diminfo.low_bounds[u] >= offset[u]);
+ space->select.sel_info.hslab->diminfo.low_bounds[u] = (hsize_t)((hssize_t)space->select.sel_info.hslab->diminfo.low_bounds[u] - offset[u]);
+ space->select.sel_info.hslab->diminfo.high_bounds[u] = (hsize_t)((hssize_t)space->select.sel_info.hslab->diminfo.high_bounds[u] - offset[u]);
+ } /* end for */
+ } /* end if */
+
+ /* Subtract the offset from the span tree coordinates, if they exist */
+ if(space->select.sel_info.hslab->span_lst) {
+ uint64_t op_gen; /* Operation generation value */
- /* Reset the scratch pointers for the next routine which needs them */
- H5S__hyper_span_scratch(space->select.sel_info.hslab->span_lst);
+ /* Acquire an operation generation value for this operation */
+ op_gen = H5S__hyper_get_op_gen();
+
+ H5S__hyper_adjust_s_helper(space->select.sel_info.hslab->span_lst, space->extent.rank, offset, op_gen);
+ } /* end if */
} /* end if */
done:
@@ -4807,7 +7135,7 @@ H5S_hyper_denormalize_offset(H5S_t *space, const hssize_t *old_offset)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "can't adjust selection")
/* Copy the selection offset over */
- HDmemcpy(space->select.offset, old_offset, sizeof(hssize_t) * space->extent.rank);
+ H5MM_memcpy(space->select.offset, old_offset, sizeof(hssize_t) * space->extent.rank);
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -4820,12 +7148,11 @@ done:
PURPOSE
Create a new span and append to span list
USAGE
- herr_t H5S__hyper_append_span(prev_span, span_tree, low, high, down, next)
- H5S_hyper_span_t **prev_span; IN/OUT: Pointer to previous span in list
+ herr_t H5S__hyper_append_span(span_tree, ndims, low, high, down)
H5S_hyper_span_info_t **span_tree; IN/OUT: Pointer to span tree to append to
- hsize_t low, high; IN: Low and high bounds for new span node
+ unsigned ndims; IN: Number of dimension for span
+ hsize_t low, high; IN: Low and high bounds for new span node
H5S_hyper_span_info_t *down; IN: Down span tree for new node
- H5S_hyper_span_t *next; IN: Next span for new node
RETURNS
Non-negative on success, negative on failure
DESCRIPTION
@@ -4837,81 +7164,117 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
-H5S__hyper_append_span(H5S_hyper_span_t **prev_span,
- H5S_hyper_span_info_t **span_tree, hsize_t low, hsize_t high, H5S_hyper_span_info_t *down, H5S_hyper_span_t *next)
+H5S__hyper_append_span(H5S_hyper_span_info_t **span_tree, unsigned ndims,
+ hsize_t low, hsize_t high, H5S_hyper_span_info_t *down)
{
H5S_hyper_span_t *new_span = NULL;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
- HDassert(prev_span);
+ /* Sanity check */
HDassert(span_tree);
/* Check for adding first node to merged spans */
- if(*prev_span == NULL) {
+ if(*span_tree == NULL) {
/* Allocate new span node to append to list */
- if(NULL == (new_span = H5S__hyper_new_span(low, high, down, next)))
+ if(NULL == (new_span = H5S__hyper_new_span(low, high, down, NULL)))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab span")
- /* Make first node in span list */
-
- /* Check that we haven't already allocated a span tree */
- HDassert(*span_tree == NULL);
+ /* Make new span the first node in span list */
/* Allocate a new span_info node */
- if(NULL == (*span_tree = H5FL_CALLOC(H5S_hyper_span_info_t)))
+ if(NULL == (*span_tree = H5S__hyper_new_span_info(ndims)))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab span")
/* Set the span tree's basic information */
(*span_tree)->count = 1;
(*span_tree)->head = new_span;
+ (*span_tree)->tail = new_span;
+
+ /* Set low & high bounds for new span tree */
+ (*span_tree)->low_bounds[0] = low;
+ (*span_tree)->high_bounds[0] = high;
+ if(down) {
+ /* Sanity check */
+ HDassert(ndims > 1);
- /* Update previous merged span */
- *prev_span = new_span;
+ H5MM_memcpy(&((*span_tree)->low_bounds[1]), down->low_bounds, sizeof(hsize_t) * (ndims - 1));
+ H5MM_memcpy(&((*span_tree)->high_bounds[1]), down->high_bounds, sizeof(hsize_t) * (ndims - 1));
+ } /* end if */
} /* end if */
/* Merge or append to existing merged spans list */
else {
+ htri_t down_cmp = (-1); /* Comparison value for down spans */
+
/* Check if span can just extend the previous merged span */
- if((((*prev_span)->high + 1) == low) &&
- H5S__hyper_cmp_spans(down, (*prev_span)->down)==TRUE) {
+ if((((*span_tree)->tail->high + 1) == low) &&
+ (down_cmp = H5S__hyper_cmp_spans(down, (*span_tree)->tail->down))) {
/* Extend previous merged span to include new high bound */
- (*prev_span)->high = high;
- (*prev_span)->nelem += (high - low) + 1;
+ (*span_tree)->tail->high = high;
+
+ /* Extend span tree's high bound in this dimension */
+ /* (No need to update lower dimensions, since this span shares them with previous span) */
+ (*span_tree)->high_bounds[0] = high;
} /* end if */
else {
- /* Allocate new span node to append to list */
- if(NULL == (new_span = H5S__hyper_new_span(low, high, down, next)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span")
+ H5S_hyper_span_info_t *new_down; /* Down pointer for new span node */
+
+ /* Sanity check */
+ /* (If down_cmp was set to TRUE above, we won't be in this branch) */
+ HDassert(down_cmp != TRUE);
/* Check if there is actually a down span */
- if(new_span->down) {
+ if(down) {
/* Check if the down spans for the new span node are the same as the previous span node */
- if(H5S__hyper_cmp_spans(new_span->down, (*prev_span)->down)) {
- /* Release the down span for the new node */
- H5S__hyper_free_span_info(new_span->down);
-
- /* Point the new node's down span at the previous node's down span */
- new_span->down = (*prev_span)->down;
+ /* (Uses the 'down span comparison' from earlier, if already computed) */
+ if(down_cmp < 0 && (down_cmp = H5S__hyper_cmp_spans(down, (*span_tree)->tail->down)))
+ /* Share the previous span's down span tree */
+ new_down = (*span_tree)->tail->down;
+ else
+ new_down = down;
+ } /* end if */
+ else
+ new_down = NULL;
- /* Increment the reference count to the shared down span */
- new_span->down->count++;
+ /* Allocate new span node to append to list */
+ if(NULL == (new_span = H5S__hyper_new_span(low, high, new_down, NULL)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab span")
+
+ /* Update the high bounds for current dimension */
+ (*span_tree)->high_bounds[0] = high;
+
+ /* Update low & high bounds in lower dimensions, if there are any */
+ if(down) {
+ /* Sanity checks */
+ HDassert(ndims > 1);
+ HDassert(down_cmp >= 0);
+
+ /* Check if we are sharing down spans with a previous node */
+ /* (Only need to check for bounds changing if down spans aren't shared) */
+ if(down_cmp == FALSE) {
+ unsigned u; /* Local index variable */
+
+ /* Loop over lower dimensions, checking & updating low & high bounds */
+ for(u = 0; u < (ndims - 1); u++) {
+ if(down->low_bounds[u] < (*span_tree)->low_bounds[u + 1])
+ (*span_tree)->low_bounds[u + 1] = down->low_bounds[u];
+ if(down->high_bounds[u] > (*span_tree)->high_bounds[u + 1])
+ (*span_tree)->high_bounds[u + 1] = down->high_bounds[u];
+ } /* end for */
} /* end if */
} /* end if */
- /* Indicate elements from previous span */
- new_span->pstride = low - (*prev_span)->low;
-
/* Append to end of merged spans list */
- (*prev_span)->next = new_span;
- *prev_span = new_span;
+ (*span_tree)->tail->next = new_span;
+ (*span_tree)->tail = new_span;
} /* end else */
} /* end else */
done:
if(ret_value < 0)
- if(new_span && H5S__hyper_free_span(new_span) < 0)
- HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "failed to release new hyperslab span")
+ if(new_span)
+ H5S__hyper_free_span(new_span);
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5S__hyper_append_span() */
@@ -4923,9 +7286,18 @@ done:
PURPOSE
Clip a new span tree against the current spans in the hyperslab selection
USAGE
- herr_t H5S__hyper_clip_spans(span_a, span_b, a_not_b, a_and_b, b_not_a)
+ herr_t H5S__hyper_clip_spans(span_a, span_b, selector, curr_dim, dim_size,
+ span_a_b_bounds[4], all_clips_bound,
+ a_not_b, a_and_b, b_not_a)
H5S_hyper_span_t *a_spans; IN: Span tree 'a' to clip with.
H5S_hyper_span_t *b_spans; IN: Span tree 'b' to clip with.
+ unsigned selector; IN: The parameter deciding which output is needed
+ (only considering the last three bits ABC:
+ If A is set, then a_not_b is needed;
+ If B is set, then a_and_b is needed;
+ If C is set, then b_not_a is needed;
+ )
+ unsigned ndims; IN: Number of dimensions of this span tree
H5S_hyper_span_t **a_not_b; OUT: Span tree of 'a' hyperslab spans which
doesn't overlap with 'b' hyperslab
spans.
@@ -4939,9 +7311,10 @@ done:
DESCRIPTION
Clip one span tree ('a') against another span tree ('b'). Creates span
trees for the area defined by the 'a' span tree which does not overlap the
- 'b' span tree, the area defined by the overlap of the 'a' hyperslab span
- tree and the 'b' span tree, and the area defined by the 'b' hyperslab span
- tree which does not overlap the 'a' span tree.
+ 'b' span tree ("a not b"), the area defined by the overlap of the 'a'
+ hyperslab span tree and the 'b' span tree ("a and b"), and the area defined
+ by the 'b' hyperslab span tree which does not overlap the 'a' span
+ tree ("b not a").
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
EXAMPLES
@@ -4949,20 +7322,14 @@ done:
--------------------------------------------------------------------------*/
static herr_t
H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_spans,
+ unsigned selector, unsigned ndims,
H5S_hyper_span_info_t **a_not_b, H5S_hyper_span_info_t **a_and_b,
H5S_hyper_span_info_t **b_not_a)
{
- H5S_hyper_span_t *span_a; /* Pointer to a node in span tree 'a' */
- H5S_hyper_span_t *span_b; /* Pointer to a node in span tree 'b' */
- H5S_hyper_span_t *tmp_span; /* Temporary pointer to new span */
- H5S_hyper_span_t *last_a_not_b; /* Pointer to previous node in span tree 'a_not_b' */
- H5S_hyper_span_t *last_a_and_b; /* Pointer to previous node in span tree 'a_and_b' */
- H5S_hyper_span_t *last_b_not_a; /* Pointer to previous node in span tree 'b_not_a' */
- H5S_hyper_span_info_t *down_a_not_b; /* Temporary pointer to a_not_b span tree of down spans for overlapping nodes */
- H5S_hyper_span_info_t *down_a_and_b; /* Temporary pointer to a_and_b span tree of down spans for overlapping nodes */
- H5S_hyper_span_info_t *down_b_not_a; /* Temporary pointer to b_and_a span tree of down spans for overlapping nodes */
- hbool_t recover_a, recover_b; /* Flags to indicate when to recover temporary spans */
- herr_t ret_value = SUCCEED; /* Return value */
+ hbool_t need_a_not_b; /* Whether to generate a_not_b list */
+ hbool_t need_a_and_b; /* Whether to generate a_and_b list */
+ hbool_t need_b_not_a; /* Whether to generate b_not_a list */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
@@ -4973,6 +7340,11 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s
HDassert(a_and_b);
HDassert(b_not_a);
+ /* Set which list(s) to be generated, based on selector */
+ need_a_not_b = ((selector & H5S_HYPER_COMPUTE_A_NOT_B) != 0);
+ need_a_and_b = ((selector & H5S_HYPER_COMPUTE_A_AND_B) != 0);
+ need_b_not_a = ((selector & H5S_HYPER_COMPUTE_B_NOT_A) != 0);
+
/* Check if both span trees are not defined */
if(a_spans == NULL && b_spans == NULL) {
*a_not_b = NULL;
@@ -4983,38 +7355,56 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s
else if(a_spans == NULL) {
*a_not_b = NULL;
*a_and_b = NULL;
- if(NULL == (*b_not_a = H5S__hyper_copy_span(b_spans)))
- HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOPY, FAIL, "can't copy hyperslab span tree")
+ if(need_b_not_a) {
+ if(NULL == (*b_not_a = H5S__hyper_copy_span(b_spans, ndims)))
+ HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOPY, FAIL, "can't copy hyperslab span tree")
+ } /* end if */
+ else
+ *b_not_a = NULL;
} /* end if */
/* If span 'b' is not defined, but 'a' is, copy 'a' and set the other return span trees to empty */
else if(b_spans == NULL) {
- if(NULL == (*a_not_b = H5S__hyper_copy_span(a_spans)) )
- HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOPY, FAIL, "can't copy hyperslab span tree")
*a_and_b = NULL;
*b_not_a = NULL;
+ if(need_a_not_b) {
+ if(NULL == (*a_not_b = H5S__hyper_copy_span(a_spans, ndims)))
+ HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOPY, FAIL, "can't copy hyperslab span tree")
+ } /* end if */
+ else
+ *a_not_b = NULL;
} /* end if */
/* If span 'a' and 'b' are both defined, calculate the proper span trees */
else {
/* Check if both span trees completely overlap */
if(H5S__hyper_cmp_spans(a_spans, b_spans)) {
*a_not_b = NULL;
- if(NULL == (*a_and_b = H5S__hyper_copy_span(a_spans)))
- HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOPY, FAIL, "can't copy hyperslab span tree")
*b_not_a = NULL;
+ if(need_a_and_b) {
+ if(NULL == (*a_and_b = H5S__hyper_copy_span(a_spans, ndims)))
+ HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOPY, FAIL, "can't copy hyperslab span tree")
+ } /* end if */
+ else
+ *a_and_b = NULL;
} /* end if */
else {
+ H5S_hyper_span_t *span_a; /* Pointer to a node in span tree 'a' */
+ H5S_hyper_span_t *span_b; /* Pointer to a node in span tree 'b' */
+ hbool_t recover_a, recover_b; /* Flags to indicate when to recover temporary spans */
+
/* Get the pointers to the new and old span lists */
span_a = a_spans->head;
span_b = b_spans->head;
- /* Reset the pointers to the previous spans */
- last_a_not_b = last_a_and_b = last_b_not_a = NULL;
-
/* No spans to recover yet */
recover_a = recover_b = FALSE;
/* Work through the list of spans in the new list */
while(span_a != NULL && span_b != NULL) {
+ H5S_hyper_span_info_t *down_a_not_b; /* Temporary pointer to a_not_b span tree of down spans for overlapping nodes */
+ H5S_hyper_span_info_t *down_a_and_b; /* Temporary pointer to a_and_b span tree of down spans for overlapping nodes */
+ H5S_hyper_span_info_t *down_b_not_a; /* Temporary pointer to b_and_a span tree of down spans for overlapping nodes */
+ H5S_hyper_span_t *tmp_span; /* Temporary pointer to new span */
+
/* Check if span 'a' is completely before span 'b' */
/* AAAAAAA */
/* <-----------------------------------> */
@@ -5023,11 +7413,12 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s
/* Copy span 'a' and add to a_not_b list */
/* Merge/add span 'a' with/to a_not_b list */
- if(H5S__hyper_append_span(&last_a_not_b, a_not_b, span_a->low, span_a->high, span_a->down, NULL) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
+ if(need_a_not_b)
+ if(H5S__hyper_append_span(a_not_b, ndims, span_a->low, span_a->high, span_a->down) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
/* Advance span 'a', leave span 'b' */
- H5S__hyper_recover_span(&recover_a, &span_a, span_a->next);
+ H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, span_a->next);
} /* end if */
/* Check if span 'a' overlaps only the lower bound */
/* of span 'b' , up to the upper bound of span 'b' */
@@ -5038,8 +7429,9 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s
/* Split span 'a' into two parts at the low bound of span 'b' */
/* Merge/add lower part of span 'a' with/to a_not_b list */
- if(H5S__hyper_append_span(&last_a_not_b, a_not_b, span_a->low, span_b->low - 1, span_a->down, NULL) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
+ if(need_a_not_b)
+ if(H5S__hyper_append_span(a_not_b, ndims, span_a->low, span_b->low - 1, span_a->down) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
/* Check for overlaps between upper part of span 'a' and lower part of span 'b' */
@@ -5049,8 +7441,9 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s
/* If there are no down spans, just add the overlapping area to the a_and_b list */
if(span_a->down == NULL) {
/* Merge/add overlapped part with/to a_and_b list */
- if(H5S__hyper_append_span(&last_a_and_b, a_and_b, span_b->low, span_a->high, NULL, NULL) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
+ if(need_a_and_b)
+ if(H5S__hyper_append_span(a_and_b, ndims, span_b->low, span_a->high, NULL) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
} /* end if */
/* If there are down spans, check for the overlap in them and add to each appropriate list */
else {
@@ -5060,14 +7453,20 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s
down_b_not_a = NULL;
/* Check for overlaps in the 'down spans' of span 'a' & 'b' */
- if(H5S__hyper_clip_spans(span_a->down,span_b->down,&down_a_not_b,&down_a_and_b,&down_b_not_a)<0)
+ /** Note: since the bound box of remaining dimensions
+ * has been updated in the following clip function (via
+ * all_clips_bounds), there's no need updating the bound box
+ * after each append call in the following codes */
+ if(H5S__hyper_clip_spans(span_a->down, span_b->down, selector, ndims - 1, &down_a_not_b, &down_a_and_b, &down_b_not_a) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't clip hyperslab information")
/* Check for additions to the a_not_b list */
if(down_a_not_b) {
+ HDassert(need_a_not_b == TRUE);
+
/* Merge/add overlapped part with/to a_not_b list */
- if(H5S__hyper_append_span(&last_a_not_b,a_not_b,span_b->low,span_a->high,down_a_not_b,NULL)==FAIL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
+ if(H5S__hyper_append_span(a_not_b, ndims, span_b->low, span_a->high, down_a_not_b) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
/* Release the down span tree generated */
H5S__hyper_free_span_info(down_a_not_b);
@@ -5075,9 +7474,11 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s
/* Check for additions to the a_and_b list */
if(down_a_and_b) {
+ HDassert(need_a_and_b == TRUE);
+
/* Merge/add overlapped part with/to a_and_b list */
- if(H5S__hyper_append_span(&last_a_and_b,a_and_b,span_b->low,span_a->high,down_a_and_b,NULL)==FAIL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
+ if(H5S__hyper_append_span(a_and_b, ndims, span_b->low, span_a->high, down_a_and_b) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
/* Release the down span tree generated */
H5S__hyper_free_span_info(down_a_and_b);
@@ -5085,9 +7486,11 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s
/* Check for additions to the b_not_a list */
if(down_b_not_a) {
+ HDassert(need_b_not_a == TRUE);
+
/* Merge/add overlapped part with/to b_not_a list */
- if(H5S__hyper_append_span(&last_b_not_a,b_not_a,span_b->low,span_a->high,down_b_not_a,NULL)==FAIL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
+ if(H5S__hyper_append_span(b_not_a, ndims, span_b->low, span_a->high, down_b_not_a) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
/* Release the down span tree generated */
H5S__hyper_free_span_info(down_b_not_a);
@@ -5103,17 +7506,17 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s
HGOTO_ERROR(H5E_DATASPACE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span")
/* Advance span 'a' */
- H5S__hyper_recover_span(&recover_a,&span_a,span_a->next);
+ H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, span_a->next);
/* Make upper part of span 'b' into new span 'b' */
- H5S__hyper_recover_span(&recover_b,&span_b,tmp_span);
+ H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, tmp_span);
recover_b = TRUE;
} /* end if */
/* No upper part of span 'b' to split */
else {
/* Advance both 'a' and 'b' */
- H5S__hyper_recover_span(&recover_a,&span_a,span_a->next);
- H5S__hyper_recover_span(&recover_b,&span_b,span_b->next);
+ H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, span_a->next);
+ H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next);
} /* end else */
} /* end if */
/* Check if span 'a' overlaps the lower & upper bound */
@@ -5125,8 +7528,9 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s
/* Split off lower part of span 'a' at lower span of span 'b' */
/* Merge/add lower part of span 'a' with/to a_not_b list */
- if(H5S__hyper_append_span(&last_a_not_b,a_not_b,span_a->low,span_b->low-1,span_a->down,NULL)==FAIL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
+ if(need_a_not_b)
+ if(H5S__hyper_append_span(a_not_b, ndims, span_a->low, span_b->low - 1, span_a->down) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
/* Check for overlaps between middle part of span 'a' and span 'b' */
@@ -5136,8 +7540,9 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s
/* If there are no down spans, just add the overlapping area to the a_and_b list */
if(span_a->down == NULL) {
/* Merge/add overlapped part with/to a_and_b list */
- if(H5S__hyper_append_span(&last_a_and_b,a_and_b,span_b->low,span_b->high,NULL,NULL)==FAIL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
+ if(need_a_and_b)
+ if(H5S__hyper_append_span(a_and_b, ndims, span_b->low, span_b->high, NULL) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
} /* end if */
/* If there are down spans, check for the overlap in them and add to each appropriate list */
else {
@@ -5147,14 +7552,16 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s
down_b_not_a = NULL;
/* Check for overlaps in the 'down spans' of span 'a' & 'b' */
- if(H5S__hyper_clip_spans(span_a->down,span_b->down,&down_a_not_b,&down_a_and_b,&down_b_not_a)<0)
+ if(H5S__hyper_clip_spans(span_a->down, span_b->down, selector, ndims - 1, &down_a_not_b, &down_a_and_b, &down_b_not_a) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't clip hyperslab information")
/* Check for additions to the a_not_b list */
if(down_a_not_b) {
+ HDassert(need_a_not_b == TRUE);
+
/* Merge/add overlapped part with/to a_not_b list */
- if(H5S__hyper_append_span(&last_a_not_b,a_not_b,span_b->low,span_b->high,down_a_not_b,NULL)==FAIL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
+ if(H5S__hyper_append_span(a_not_b, ndims, span_b->low, span_b->high, down_a_not_b) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
/* Release the down span tree generated */
H5S__hyper_free_span_info(down_a_not_b);
@@ -5162,9 +7569,11 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s
/* Check for additions to the a_and_b list */
if(down_a_and_b) {
+ HDassert(need_a_and_b == TRUE);
+
/* Merge/add overlapped part with/to a_and_b list */
- if(H5S__hyper_append_span(&last_a_and_b,a_and_b,span_b->low,span_b->high,down_a_and_b,NULL)==FAIL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
+ if(H5S__hyper_append_span(a_and_b, ndims, span_b->low, span_b->high, down_a_and_b) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
/* Release the down span tree generated */
H5S__hyper_free_span_info(down_a_and_b);
@@ -5172,9 +7581,11 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s
/* Check for additions to the b_not_a list */
if(down_b_not_a) {
+ HDassert(need_b_not_a == TRUE);
+
/* Merge/add overlapped part with/to b_not_a list */
- if(H5S__hyper_append_span(&last_b_not_a,b_not_a,span_b->low,span_b->high,down_b_not_a,NULL)==FAIL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
+ if(H5S__hyper_append_span(b_not_a, ndims, span_b->low, span_b->high, down_b_not_a) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
/* Release the down span tree generated */
H5S__hyper_free_span_info(down_b_not_a);
@@ -5188,11 +7599,11 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s
HGOTO_ERROR(H5E_DATASPACE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span")
/* Make upper part of span 'a' the new span 'a' */
- H5S__hyper_recover_span(&recover_a,&span_a,tmp_span);
+ H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, tmp_span);
recover_a = TRUE;
/* Advance span 'b' */
- H5S__hyper_recover_span(&recover_b,&span_b,span_b->next);
+ H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next);
} /* end if */
/* Check if span 'a' is entirely within span 'b' */
/* AAAAA */
@@ -5204,8 +7615,9 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s
/* Check if there is actually a lower part of span 'b' to split off */
if(span_a->low > span_b->low) {
/* Merge/add lower part of span 'b' with/to b_not_a list */
- if(H5S__hyper_append_span(&last_b_not_a,b_not_a,span_b->low,span_a->low-1,span_b->down,NULL)==FAIL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
+ if(need_b_not_a)
+ if(H5S__hyper_append_span(b_not_a, ndims, span_b->low, span_a->low - 1, span_b->down) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
} /* end if */
else {
/* Keep going, nothing to split off */
@@ -5219,8 +7631,9 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s
/* If there are no down spans, just add the overlapping area to the a_and_b list */
if(span_a->down == NULL) {
/* Merge/add overlapped part with/to a_and_b list */
- if(H5S__hyper_append_span(&last_a_and_b,a_and_b,span_a->low,span_a->high,NULL,NULL)==FAIL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
+ if(need_a_and_b)
+ if(H5S__hyper_append_span(a_and_b, ndims, span_a->low, span_a->high, NULL) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
} /* end if */
/* If there are down spans, check for the overlap in them and add to each appropriate list */
else {
@@ -5230,34 +7643,40 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s
down_b_not_a = NULL;
/* Check for overlaps in the 'down spans' of span 'a' & 'b' */
- if(H5S__hyper_clip_spans(span_a->down,span_b->down,&down_a_not_b,&down_a_and_b,&down_b_not_a)<0)
+ if(H5S__hyper_clip_spans(span_a->down, span_b->down, selector, ndims - 1, &down_a_not_b, &down_a_and_b, &down_b_not_a) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't clip hyperslab information")
/* Check for additions to the a_not_b list */
if(down_a_not_b) {
+ HDassert(need_a_not_b == TRUE);
+
/* Merge/add overlapped part with/to a_not_b list */
- if(H5S__hyper_append_span(&last_a_not_b,a_not_b,span_a->low,span_a->high,down_a_not_b,NULL)==FAIL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
+ if(H5S__hyper_append_span(a_not_b, ndims, span_a->low, span_a->high, down_a_not_b) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
/* Release the down span tree generated */
H5S__hyper_free_span_info(down_a_not_b);
} /* end if */
/* Check for additions to the a_and_b list */
- if(down_a_and_b!=NULL) {
+ if(down_a_and_b) {
+ HDassert(need_a_and_b == TRUE);
+
/* Merge/add overlapped part with/to a_and_b list */
- if(H5S__hyper_append_span(&last_a_and_b,a_and_b,span_a->low,span_a->high,down_a_and_b,NULL)==FAIL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
+ if(H5S__hyper_append_span(a_and_b, ndims, span_a->low, span_a->high, down_a_and_b) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
/* Release the down span tree generated */
H5S__hyper_free_span_info(down_a_and_b);
} /* end if */
/* Check for additions to the b_not_a list */
- if(down_b_not_a!=NULL) {
+ if(down_b_not_a) {
+ HDassert(need_b_not_a == TRUE);
+
/* Merge/add overlapped part with/to b_not_a list */
- if(H5S__hyper_append_span(&last_b_not_a,b_not_a,span_a->low,span_a->high,down_b_not_a,NULL)==FAIL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
+ if(H5S__hyper_append_span(b_not_a, ndims, span_a->low, span_a->high, down_b_not_a) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
/* Release the down span tree generated */
H5S__hyper_free_span_info(down_b_not_a);
@@ -5273,16 +7692,16 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab span")
/* And advance span 'a' */
- H5S__hyper_recover_span(&recover_a,&span_a,span_a->next);
+ H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, span_a->next);
/* Make upper part of span 'b' the new span 'b' */
- H5S__hyper_recover_span(&recover_b,&span_b,tmp_span);
- recover_b=1;
+ H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, tmp_span);
+ recover_b = TRUE;
} /* end if */
else {
/* Advance both span 'a' & span 'b' */
- H5S__hyper_recover_span(&recover_a,&span_a,span_a->next);
- H5S__hyper_recover_span(&recover_b,&span_b,span_b->next);
+ H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, span_a->next);
+ H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next);
} /* end else */
} /* end if */
/* Check if span 'a' overlaps only the upper bound */
@@ -5296,8 +7715,9 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s
/* Split off lower part of span 'b' at lower span of span 'a' */
/* Merge/add lower part of span 'b' with/to b_not_a list */
- if(H5S__hyper_append_span(&last_b_not_a,b_not_a,span_b->low,span_a->low-1,span_b->down,NULL)==FAIL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
+ if(need_b_not_a)
+ if(H5S__hyper_append_span(b_not_a, ndims, span_b->low, span_a->low - 1, span_b->down) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
} /* end if */
else {
/* Keep going, nothing to split off */
@@ -5311,8 +7731,9 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s
/* If there are no down spans, just add the overlapping area to the a_and_b list */
if(span_a->down == NULL) {
/* Merge/add overlapped part with/to a_and_b list */
- if(H5S__hyper_append_span(&last_a_and_b,a_and_b,span_a->low,span_b->high,NULL,NULL)==FAIL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
+ if(need_a_and_b)
+ if(H5S__hyper_append_span(a_and_b, ndims, span_a->low, span_b->high, NULL) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
} /* end if */
/* If there are down spans, check for the overlap in them and add to each appropriate list */
else {
@@ -5322,24 +7743,28 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s
down_b_not_a = NULL;
/* Check for overlaps in the 'down spans' of span 'a' & 'b' */
- if(H5S__hyper_clip_spans(span_a->down,span_b->down,&down_a_not_b,&down_a_and_b,&down_b_not_a)<0)
+ if(H5S__hyper_clip_spans(span_a->down, span_b->down, selector, ndims - 1, &down_a_not_b, &down_a_and_b, &down_b_not_a) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't clip hyperslab information")
/* Check for additions to the a_not_b list */
if(down_a_not_b) {
+ HDassert(need_a_not_b == TRUE);
+
/* Merge/add overlapped part with/to a_not_b list */
- if(H5S__hyper_append_span(&last_a_not_b,a_not_b,span_a->low,span_b->high,down_a_not_b,NULL)==FAIL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
+ if(H5S__hyper_append_span(a_not_b, ndims, span_a->low, span_b->high, down_a_not_b) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
/* Release the down span tree generated */
H5S__hyper_free_span_info(down_a_not_b);
} /* end if */
/* Check for additions to the a_and_b list */
- if(down_a_and_b!=NULL) {
+ if(down_a_and_b) {
+ HDassert(need_a_and_b == TRUE);
+
/* Merge/add overlapped part with/to a_and_b list */
- if(H5S__hyper_append_span(&last_a_and_b,a_and_b,span_a->low,span_b->high,down_a_and_b,NULL)==FAIL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
+ if(H5S__hyper_append_span(a_and_b, ndims, span_a->low, span_b->high, down_a_and_b) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
/* Release the down span tree generated */
H5S__hyper_free_span_info(down_a_and_b);
@@ -5347,9 +7772,11 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s
/* Check for additions to the b_not_a list */
if(down_b_not_a) {
+ HDassert(need_b_not_a == TRUE);
+
/* Merge/add overlapped part with/to b_not_a list */
- if(H5S__hyper_append_span(&last_b_not_a,b_not_a,span_a->low,span_b->high,down_b_not_a,NULL)==FAIL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
+ if(H5S__hyper_append_span(b_not_a, ndims, span_a->low, span_b->high, down_b_not_a) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
/* Release the down span tree generated */
H5S__hyper_free_span_info(down_b_not_a);
@@ -5363,11 +7790,11 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab span")
/* Make upper part of span 'a' into new span 'a' */
- H5S__hyper_recover_span(&recover_a,&span_a,tmp_span);
- recover_a=1;
+ H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, tmp_span);
+ recover_a = TRUE;
/* Advance span 'b' */
- H5S__hyper_recover_span(&recover_b,&span_b,span_b->next);
+ H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next);
} /* end if */
/* span 'a' must be entirely above span 'b' */
/* AAAAA */
@@ -5377,40 +7804,70 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s
/* Copy span 'b' and add to b_not_a list */
/* Merge/add span 'b' with/to b_not_a list */
- if(H5S__hyper_append_span(&last_b_not_a,b_not_a,span_b->low,span_b->high,span_b->down,NULL)==FAIL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
+ if(need_b_not_a)
+ if(H5S__hyper_append_span(b_not_a, ndims, span_b->low, span_b->high, span_b->down) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
/* Advance span 'b', leave span 'a' */
- H5S__hyper_recover_span(&recover_b,&span_b,span_b->next);
+ H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next);
} /* end else */
} /* end while */
/* Clean up 'a' spans which haven't been covered yet */
if(span_a != NULL && span_b == NULL) {
- while(span_a != NULL) {
- /* Copy span 'a' and add to a_not_b list */
-
- /* Merge/add span 'a' with/to a_not_b list */
- if(H5S__hyper_append_span(&last_a_not_b,a_not_b,span_a->low,span_a->high,span_a->down,NULL)==FAIL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
+ /* Check if need to merge/add 'a' spans with/to a_not_b list */
+ if(need_a_not_b) {
+ /* (This loop, and the similar one below for 'b' spans,
+ * could be replaced with an optimized routine that quickly
+ * appended the remaining spans to the 'not' list, but
+ * until it looks like it's taking a lot of time for an
+ * important use case, it's been left generic, and similar
+ * to other code above. -QAK, 2019/02/01)
+ */
+ while(span_a != NULL) {
+ /* Copy span 'a' and add to a_not_b list */
+ if(H5S__hyper_append_span(a_not_b, ndims, span_a->low, span_a->high, span_a->down) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
- /* Advance to the next 'a' span */
- H5S__hyper_recover_span(&recover_a,&span_a,span_a->next);
- } /* end while */
+ /* Advance to the next 'a' span */
+ H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, span_a->next);
+ } /* end while */
+ } /* end if */
+ else {
+ /* Free the span, if it's generated */
+ if(recover_a)
+ H5S__hyper_free_span(span_a);
+ } /* end else */
} /* end if */
/* Clean up 'b' spans which haven't been covered yet */
else if(span_a == NULL && span_b != NULL) {
- while(span_b != NULL) {
- /* Copy span 'b' and add to b_not_a list */
-
- /* Merge/add span 'b' with/to b_not_a list */
- if(H5S__hyper_append_span(&last_b_not_a,b_not_a,span_b->low,span_b->high,span_b->down,NULL)==FAIL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
+ /* Check if need to merge/add 'b' spans with/to b_not_a list */
+ if(need_b_not_a) {
+ /* (This loop, and the similar one above for 'a' spans,
+ * could be replaced with an optimized routine that quickly
+ * appended the remaining spans to the 'not' list, but
+ * until it looks like it's taking a lot of time for an
+ * important use case, it's been left generic, and similar
+ * to other code above. -QAK, 2019/02/01)
+ */
+ while(span_b != NULL) {
+ /* Copy span 'b' and add to b_not_a list */
+ if(H5S__hyper_append_span(b_not_a, ndims, span_b->low, span_b->high, span_b->down) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
- /* Advance to the next 'b' span */
- H5S__hyper_recover_span(&recover_b,&span_b,span_b->next);
- } /* end while */
+ /* Advance to the next 'b' span */
+ H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next);
+ } /* end while */
+ } /* end if */
+ else {
+ /* Free the span, if it's generated */
+ if(recover_b)
+ H5S__hyper_free_span(span_b);
+ } /* end else */
} /* end if */
+ else
+ /* Sanity check */
+ HDassert(span_a == NULL && span_b == NULL);
} /* end else */
} /* end else */
@@ -5430,6 +7887,7 @@ done:
together
H5S_hyper_span_info_t *b_spans; IN: Second hyperslab spans to merge
together
+ unsigned ndims; IN: Number of dimensions of this span tree
RETURNS
Pointer to span tree containing the merged spans on success, NULL on failure
DESCRIPTION
@@ -5437,11 +7895,13 @@ done:
the merged set.
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
+ Handles merging span trees that overlap.
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
static H5S_hyper_span_info_t *
-H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_spans)
+H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_spans,
+ unsigned ndims)
{
H5S_hyper_span_info_t *merged_spans = NULL; /* Pointer to the merged span tree */
H5S_hyper_span_info_t *ret_value = NULL; /* Return value */
@@ -5457,23 +7917,19 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf
merged_spans = NULL;
else {
/* Copy one of the span trees to return */
- if(NULL == (merged_spans = H5S__hyper_copy_span(a_spans)))
+ if(NULL == (merged_spans = H5S__hyper_copy_span(a_spans, ndims)))
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOPY, NULL, "can't copy hyperslab span tree")
} /* end else */
} /* end if */
else {
H5S_hyper_span_t *span_a; /* Pointer to current span 'a' working on */
H5S_hyper_span_t *span_b; /* Pointer to current span 'b' working on */
- H5S_hyper_span_t *prev_span_merge; /* Pointer to previous merged span */
hbool_t recover_a, recover_b; /* Flags to indicate when to recover temporary spans */
/* Get the pointers to the 'a' and 'b' span lists */
span_a = a_spans->head;
span_b = b_spans->head;
- /* Set the pointer to the previous spans */
- prev_span_merge = NULL;
-
/* No spans to recover yet */
recover_a = recover_b = FALSE;
@@ -5488,11 +7944,11 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf
/* BBBBBBBBBB */
if(span_a->high < span_b->low) {
/* Merge/add span 'a' with/to the merged spans */
- if(H5S__hyper_append_span(&prev_span_merge,&merged_spans,span_a->low,span_a->high,span_a->down,NULL)==FAIL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span")
+ if(H5S__hyper_append_span(&merged_spans, ndims, span_a->low, span_a->high, span_a->down) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span")
/* Advance span 'a' */
- H5S__hyper_recover_span(&recover_a,&span_a,span_a->next);
+ H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, span_a->next);
} /* end if */
/* Check if span 'a' overlaps only the lower bound */
/* of span 'b', up to the upper bound of span 'b' */
@@ -5503,20 +7959,20 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf
/* Check if span 'a' and span 'b' down spans are equal */
if(H5S__hyper_cmp_spans(span_a->down, span_b->down)) {
/* Merge/add copy of span 'a' with/to merged spans */
- if(H5S__hyper_append_span(&prev_span_merge,&merged_spans,span_a->low,span_a->high,span_a->down,NULL)==FAIL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span")
+ if(H5S__hyper_append_span(&merged_spans, ndims, span_a->low, span_a->high, span_a->down) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span")
} /* end if */
else {
/* Merge/add lower part of span 'a' with/to merged spans */
- if(H5S__hyper_append_span(&prev_span_merge,&merged_spans,span_a->low,span_b->low-1,span_a->down,NULL)==FAIL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span")
+ if(H5S__hyper_append_span(&merged_spans, ndims, span_a->low, span_b->low - 1, span_a->down) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span")
/* Get merged span tree for overlapped section */
- tmp_spans = H5S__hyper_merge_spans_helper(span_a->down,span_b->down);
+ tmp_spans = H5S__hyper_merge_spans_helper(span_a->down, span_b->down, ndims - 1);
/* Merge/add overlapped section to merged spans */
- if(H5S__hyper_append_span(&prev_span_merge,&merged_spans,span_b->low,span_a->high,tmp_spans,NULL)==FAIL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span")
+ if(H5S__hyper_append_span(&merged_spans, ndims, span_b->low, span_a->high, tmp_spans) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span")
/* Release merged span tree for overlapped section */
H5S__hyper_free_span_info(tmp_spans);
@@ -5527,20 +7983,20 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf
/* Copy upper part of span 'b' as new span 'b' */
/* Allocate new span node to append to list */
- if((tmp_span = H5S__hyper_new_span(span_a->high+1,span_b->high,span_b->down,span_b->next))==NULL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate hyperslab span")
+ if(NULL == (tmp_span = H5S__hyper_new_span(span_a->high + 1, span_b->high, span_b->down, span_b->next)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate hyperslab span")
/* Advance span 'a' */
- H5S__hyper_recover_span(&recover_a,&span_a,span_a->next);
+ H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, span_a->next);
/* Set new span 'b' to tmp_span */
- H5S__hyper_recover_span(&recover_b,&span_b,tmp_span);
+ H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, tmp_span);
recover_b = TRUE;
} /* end if */
else {
/* Advance both span 'a' & 'b' */
- H5S__hyper_recover_span(&recover_a,&span_a,span_a->next);
- H5S__hyper_recover_span(&recover_b,&span_b,span_b->next);
+ H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, span_a->next);
+ H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next);
} /* end else */
} /* end if */
/* Check if span 'a' overlaps the lower & upper bound */
@@ -5552,20 +8008,20 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf
/* Check if span 'a' and span 'b' down spans are equal */
if(H5S__hyper_cmp_spans(span_a->down, span_b->down)) {
/* Merge/add copy of lower & middle parts of span 'a' to merged spans */
- if(H5S__hyper_append_span(&prev_span_merge,&merged_spans,span_a->low,span_b->high,span_a->down,NULL)==FAIL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span")
+ if(H5S__hyper_append_span(&merged_spans, ndims, span_a->low, span_b->high, span_a->down) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span")
} /* end if */
else {
/* Merge/add lower part of span 'a' to merged spans */
- if(H5S__hyper_append_span(&prev_span_merge,&merged_spans,span_a->low,span_b->low-1,span_a->down,NULL)==FAIL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span")
+ if(H5S__hyper_append_span(&merged_spans, ndims, span_a->low, span_b->low - 1, span_a->down) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span")
/* Get merged span tree for overlapped section */
- tmp_spans = H5S__hyper_merge_spans_helper(span_a->down,span_b->down);
+ tmp_spans = H5S__hyper_merge_spans_helper(span_a->down, span_b->down, ndims - 1);
/* Merge/add overlapped section to merged spans */
- if(H5S__hyper_append_span(&prev_span_merge,&merged_spans,span_b->low,span_b->high,tmp_spans,NULL)==FAIL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span")
+ if(H5S__hyper_append_span(&merged_spans, ndims, span_b->low, span_b->high, tmp_spans) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span")
/* Release merged span tree for overlapped section */
H5S__hyper_free_span_info(tmp_spans);
@@ -5578,11 +8034,11 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate hyperslab span")
/* Set new span 'a' to tmp_span */
- H5S__hyper_recover_span(&recover_a,&span_a,tmp_span);
+ H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, tmp_span);
recover_a = TRUE;
/* Advance span 'b' */
- H5S__hyper_recover_span(&recover_b,&span_b,span_b->next);
+ H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next);
} /* end if */
/* Check if span 'a' is entirely within span 'b' */
/* AAAAA */
@@ -5592,26 +8048,26 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf
/* Check if span 'a' and span 'b' down spans are equal */
if(H5S__hyper_cmp_spans(span_a->down, span_b->down)) {
/* Merge/add copy of lower & middle parts of span 'b' to merged spans */
- if(H5S__hyper_append_span(&prev_span_merge,&merged_spans,span_b->low,span_a->high,span_a->down,NULL)==FAIL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span")
+ if(H5S__hyper_append_span(&merged_spans, ndims, span_b->low, span_a->high, span_a->down) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span")
} /* end if */
else {
/* Check if there is a lower part of span 'b' */
if(span_a->low > span_b->low) {
/* Merge/add lower part of span 'b' to merged spans */
- if(H5S__hyper_append_span(&prev_span_merge,&merged_spans,span_b->low,span_a->low-1,span_b->down,NULL)==FAIL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span")
+ if(H5S__hyper_append_span(&merged_spans, ndims, span_b->low, span_a->low - 1, span_b->down) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span")
} /* end if */
else {
/* No lower part of span 'b' , keep going... */
} /* end else */
/* Get merged span tree for overlapped section */
- tmp_spans = H5S__hyper_merge_spans_helper(span_a->down,span_b->down);
+ tmp_spans = H5S__hyper_merge_spans_helper(span_a->down, span_b->down, ndims - 1);
/* Merge/add overlapped section to merged spans */
- if(H5S__hyper_append_span(&prev_span_merge,&merged_spans,span_a->low,span_a->high,tmp_spans,NULL)==FAIL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span")
+ if(H5S__hyper_append_span(&merged_spans, ndims, span_a->low, span_a->high, tmp_spans) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span")
/* Release merged span tree for overlapped section */
H5S__hyper_free_span_info(tmp_spans);
@@ -5626,16 +8082,16 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate hyperslab span")
/* Advance span 'a' */
- H5S__hyper_recover_span(&recover_a,&span_a,span_a->next);
+ H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, span_a->next);
/* Set new span 'b' to tmp_span */
- H5S__hyper_recover_span(&recover_b,&span_b,tmp_span);
+ H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, tmp_span);
recover_b = TRUE;
} /* end if */
else {
/* Advance both spans */
- H5S__hyper_recover_span(&recover_a,&span_a,span_a->next);
- H5S__hyper_recover_span(&recover_b,&span_b,span_b->next);
+ H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, span_a->next);
+ H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next);
} /* end else */
} /* end if */
/* Check if span 'a' overlaps only the upper bound */
@@ -5647,26 +8103,26 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf
/* Check if span 'a' and span 'b' down spans are equal */
if(H5S__hyper_cmp_spans(span_a->down, span_b->down)) {
/* Merge/add copy of span 'b' to merged spans if so */
- if(H5S__hyper_append_span(&prev_span_merge,&merged_spans,span_b->low,span_b->high,span_b->down,NULL)==FAIL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span")
+ if(H5S__hyper_append_span(&merged_spans, ndims, span_b->low, span_b->high, span_b->down) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span")
} /* end if */
else {
/* Check if there is a lower part of span 'b' */
if(span_a->low > span_b->low) {
/* Merge/add lower part of span 'b' to merged spans */
- if(H5S__hyper_append_span(&prev_span_merge,&merged_spans,span_b->low,span_a->low-1,span_b->down,NULL)==FAIL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span")
+ if(H5S__hyper_append_span(&merged_spans, ndims, span_b->low, span_a->low - 1, span_b->down) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span")
} /* end if */
else {
/* No lower part of span 'b' , keep going... */
} /* end else */
/* Get merged span tree for overlapped section */
- tmp_spans = H5S__hyper_merge_spans_helper(span_a->down,span_b->down);
+ tmp_spans = H5S__hyper_merge_spans_helper(span_a->down, span_b->down, ndims - 1);
/* Merge/add overlapped section to merged spans */
- if(H5S__hyper_append_span(&prev_span_merge,&merged_spans,span_a->low,span_b->high,tmp_spans,NULL)==FAIL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span")
+ if(H5S__hyper_append_span(&merged_spans, ndims, span_a->low, span_b->high, tmp_spans) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span")
/* Release merged span tree for overlapped section */
H5S__hyper_free_span_info(tmp_spans);
@@ -5679,11 +8135,11 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate hyperslab span")
/* Set new span 'a' to tmp_span */
- H5S__hyper_recover_span(&recover_a,&span_a,tmp_span);
+ H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, tmp_span);
recover_a = TRUE;
/* Advance span 'b' */
- H5S__hyper_recover_span(&recover_b,&span_b,span_b->next);
+ H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next);
} /* end if */
/* Span 'a' must be entirely above span 'b' */
/* AAAAA */
@@ -5691,11 +8147,11 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf
/* BBBBBBBBBB */
else {
/* Merge/add span 'b' with the merged spans */
- if(H5S__hyper_append_span(&prev_span_merge,&merged_spans,span_b->low,span_b->high,span_b->down,NULL)==FAIL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span")
+ if(H5S__hyper_append_span(&merged_spans, ndims, span_b->low, span_b->high, span_b->down) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span")
/* Advance span 'b' */
- H5S__hyper_recover_span(&recover_b,&span_b,span_b->next);
+ H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next);
} /* end else */
} /* end while */
@@ -5703,11 +8159,11 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf
if(span_a != NULL && span_b == NULL) {
while(span_a != NULL) {
/* Merge/add all 'a' spans into the merged spans */
- if(H5S__hyper_append_span(&prev_span_merge,&merged_spans,span_a->low,span_a->high,span_a->down,NULL)==FAIL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span")
+ if(H5S__hyper_append_span(&merged_spans, ndims, span_a->low, span_a->high, span_a->down) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span")
/* Advance to next 'a' span, until all processed */
- H5S__hyper_recover_span(&recover_a,&span_a,span_a->next);
+ H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, span_a->next);
} /* end while */
} /* end if */
@@ -5715,11 +8171,11 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf
if(span_a == NULL && span_b != NULL) {
while(span_b != NULL) {
/* Merge/add all 'b' spans into the merged spans */
- if(H5S__hyper_append_span(&prev_span_merge,&merged_spans,span_b->low,span_b->high,span_b->down,NULL)==FAIL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span")
+ if(H5S__hyper_append_span(&merged_spans, ndims, span_b->low, span_b->high, span_b->down) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span")
/* Advance to next 'b' span, until all processed */
- H5S__hyper_recover_span(&recover_b,&span_b,span_b->next);
+ H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next);
} /* end while */
} /* end if */
} /* end else */
@@ -5729,8 +8185,8 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf
done:
if(ret_value == NULL)
- if(merged_spans && H5S__hyper_free_span_info(merged_spans) < 0)
- HDONE_ERROR(H5E_INTERNAL, H5E_CANTFREE, NULL, "failed to release merged hyperslab spans")
+ if(merged_spans)
+ H5S__hyper_free_span_info(merged_spans);
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5S__hyper_merge_spans_helper() */
@@ -5747,44 +8203,37 @@ done:
selection.
H5S_hyper_span_t *new_spans; IN: Span tree of new spans to add to
hyperslab selection
- hbool_t can_own; IN: Flag to indicate that it is OK to point
- directly to the new spans, instead of
- copying them.
RETURNS
non-negative on success, negative on failure
DESCRIPTION
- Add a set of hyperslab spans to an existing hyperslab selection. The
- new spans are required to be non-overlapping with the existing spans in
- the dataspace's current hyperslab selection.
+ Add a set of hyperslab spans to an existing hyperslab selection.
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
-H5S__hyper_merge_spans(H5S_t *space, H5S_hyper_span_info_t *new_spans, hbool_t can_own)
+H5S__hyper_merge_spans(H5S_t *space, H5S_hyper_span_info_t *new_spans)
{
- FUNC_ENTER_STATIC_NOERR
+ herr_t ret_value = SUCCEED; /* Return value */
- /* Check args */
+ FUNC_ENTER_STATIC
+
+ /* Sanity checks */
HDassert(space);
HDassert(new_spans);
/* If this is the first span tree in the hyperslab selection, just use it */
if(space->select.sel_info.hslab->span_lst == NULL) {
- if(can_own)
- space->select.sel_info.hslab->span_lst = new_spans;
- else
- space->select.sel_info.hslab->span_lst = H5S__hyper_copy_span(new_spans);
+ space->select.sel_info.hslab->span_lst = new_spans;
+ space->select.sel_info.hslab->span_lst->count++;
} /* end if */
else {
H5S_hyper_span_info_t *merged_spans;
/* Get the merged spans */
- merged_spans = H5S__hyper_merge_spans_helper(space->select.sel_info.hslab->span_lst, new_spans);
-
- /* Sanity checking since we started with some spans, we should still have some after the merge */
- HDassert(merged_spans);
+ if(NULL == (merged_spans = H5S__hyper_merge_spans_helper(space->select.sel_info.hslab->span_lst, new_spans, space->extent.rank)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTMERGE, FAIL, "can't merge hyperslab spans")
/* Free the previous spans */
H5S__hyper_free_span_info(space->select.sel_info.hslab->span_lst);
@@ -5793,18 +8242,20 @@ H5S__hyper_merge_spans(H5S_t *space, H5S_hyper_span_info_t *new_spans, hbool_t c
space->select.sel_info.hslab->span_lst = merged_spans;
} /* end else */
- FUNC_LEAVE_NOAPI(SUCCEED)
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5S__hyper_merge_spans() */
/*--------------------------------------------------------------------------
NAME
- H5S__hyper_spans_nelem
+ H5S__hyper_spans_nelem_helper
PURPOSE
Count the number of elements in a span tree
USAGE
- hsize_t H5S__hyper_spans_nelem(spans)
+ hsize_t H5S__hyper_spans_nelem_helper(spans, op_gen)
const H5S_hyper_span_info_t *spans; IN: Hyperslan span tree to count elements of
+ uint64_t op_gen; IN: Operation generation
RETURNS
Number of elements in span tree on success; negative on failure
DESCRIPTION
@@ -5815,47 +8266,158 @@ H5S__hyper_merge_spans(H5S_t *space, H5S_hyper_span_info_t *new_spans, hbool_t c
REVISION LOG
--------------------------------------------------------------------------*/
static hsize_t
-H5S__hyper_spans_nelem(const H5S_hyper_span_info_t *spans)
+H5S__hyper_spans_nelem_helper(H5S_hyper_span_info_t *spans, uint64_t op_gen)
{
hsize_t ret_value = 0; /* Return value */
FUNC_ENTER_STATIC_NOERR
- /* Count the number of elements in the span tree */
- if(spans != NULL) {
+ /* Sanity check */
+ HDassert(spans);
+
+ /* Check if the span tree was already counted */
+ if(spans->op_gen == op_gen)
+ /* Just return the # of elements in the already counted span tree */
+ ret_value = spans->u.nelmts;
+ else { /* Count the number of elements in the span tree */
const H5S_hyper_span_t *span; /* Hyperslab span */
span = spans->head;
- while(span != NULL) {
- /* If there are down spans, multiply the size of this span by the total down span elements */
- if(span->down != NULL)
- ret_value += span->nelem * H5S__hyper_spans_nelem(span->down);
- /* If there are no down spans, just count the elements in this span */
- else
- ret_value += span->nelem;
+ if(NULL == span->down) {
+ while(span != NULL) {
+ /* Compute # of elements covered */
+ ret_value += (span->high - span->low) + 1;
- /* Advance to next span */
- span = span->next;
- } /* end while */
+ /* Advance to next span */
+ span = span->next;
+ } /* end while */
+ } /* end if */
+ else {
+ while(span != NULL) {
+ hsize_t nelmts; /* # of elements covered by current span */
+
+ /* Compute # of elements covered */
+ nelmts = (span->high - span->low) + 1;
+
+ /* Multiply the size of this span by the total down span elements */
+ ret_value += nelmts * H5S__hyper_spans_nelem_helper(span->down, op_gen);
+
+ /* Advance to next span */
+ span = span->next;
+ } /* end while */
+ } /* end else */
+
+ /* Set the operation generation for this span tree, to avoid re-computing */
+ spans->op_gen = op_gen;
+
+ /* Hold a copy of the # of elements */
+ spans->u.nelmts = ret_value;
} /* end else */
FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5S__hyper_spans_nelem_helper() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S__hyper_spans_nelem
+ PURPOSE
+ Count the number of elements in a span tree
+ USAGE
+ hsize_t H5S__hyper_spans_nelem(spans)
+ const H5S_hyper_span_info_t *spans; IN: Hyperslan span tree to count elements of
+ RETURNS
+ Number of elements in span tree on success; negative on failure
+ DESCRIPTION
+ Counts the number of elements described by the spans in a span tree.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+static hsize_t
+H5S__hyper_spans_nelem(H5S_hyper_span_info_t *spans)
+{
+ uint64_t op_gen; /* Operation generation value */
+ hsize_t ret_value = 0; /* Return value */
+
+ FUNC_ENTER_STATIC_NOERR
+
+ /* Sanity check */
+ HDassert(spans);
+
+ /* Acquire an operation generation value for this operation */
+ op_gen = H5S__hyper_get_op_gen();
+
+ /* Count the number of elements in the span tree */
+ ret_value = H5S__hyper_spans_nelem_helper(spans, op_gen);
+
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5S__hyper_spans_nelem() */
/*--------------------------------------------------------------------------
NAME
+ H5S__hyper_add_disjoint_spans
+ PURPOSE
+ Add new hyperslab spans to existing hyperslab selection in the case the
+ new hyperslab spans don't overlap with the existing hyperslab selection
+ USAGE
+ herr_t H5S__hyper_add_disjoint_spans(space, new_spans)
+ H5S_t *space; IN: Dataspace to add new spans to hyperslab
+ selection.
+ H5S_hyper_span_t *new_spans; IN: Span tree of new spans to add to
+ hyperslab selection
+ RETURNS
+ Non-negative on success, negative on failure
+ DESCRIPTION
+ Add a set of hyperslab spans to an existing hyperslab selection. The
+ new spans are required not to overlap with the existing spans in the
+ dataspace's current hyperslab selection in terms of bound box.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+static herr_t
+H5S__hyper_add_disjoint_spans(H5S_t *space, H5S_hyper_span_info_t *new_spans)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_STATIC
+
+ /* Check args */
+ HDassert(space);
+ HDassert(new_spans);
+
+ /* Update the number of elements in the selection */
+ space->select.num_elem += H5S__hyper_spans_nelem(new_spans);
+
+ /* Add the new spans to the existing selection in the dataspace */
+ if(H5S__hyper_merge_spans(space, new_spans) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't merge hyperslabs")
+
+ /* Free the memory space for new spans */
+ H5S__hyper_free_span_info(new_spans);
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5S__hyper_add_disjoint_spans */
+
+
+/*--------------------------------------------------------------------------
+ NAME
H5S__hyper_make_spans
PURPOSE
Create a span tree
USAGE
H5S_hyper_span_t *H5S__hyper_make_spans(rank, start, stride, count, block)
- unsigned rank; IN: # of dimensions of the space
- const hsize_t *start; IN: Starting location of the hyperslabs
- const hsize_t *stride; IN: Stride from the beginning of one block to
+ unsigned rank; IN: # of dimensions of the space
+ const hsize_t *start; IN: Starting location of the hyperslabs
+ const hsize_t *stride; IN: Stride from the beginning of one block to
the next
- const hsize_t *count; IN: Number of blocks
- const hsize_t *block; IN: Size of hyperslab block
+ const hsize_t *count; IN: Number of blocks
+ const hsize_t *block; IN: Size of hyperslab block
RETURNS
Pointer to new span tree on success, NULL on failure
DESCRIPTION
@@ -5875,9 +8437,7 @@ H5S__hyper_make_spans(unsigned rank, const hsize_t *start, const hsize_t *stride
H5S_hyper_span_info_t *down = NULL; /* Pointer to spans in next dimension down */
H5S_hyper_span_t *last_span; /* Current position in hyperslab span list */
H5S_hyper_span_t *head = NULL; /* Head of new hyperslab span list */
- hsize_t stride_iter; /* Iterator over the stride values */
int i; /* Counters */
- unsigned u; /* Counters */
H5S_hyper_span_info_t *ret_value = NULL; /* Return value */
FUNC_ENTER_STATIC
@@ -5891,6 +8451,9 @@ H5S__hyper_make_spans(unsigned rank, const hsize_t *start, const hsize_t *stride
/* Start creating spans in fastest changing dimension */
for(i = (int)(rank - 1); i >= 0; i--) {
+ hsize_t curr_low, curr_high; /* Current low & high values */
+ hsize_t dim_stride; /* Current dim's stride */
+ unsigned u; /* Local index variable */
/* Sanity check */
if(0 == count[i])
@@ -5901,8 +8464,10 @@ H5S__hyper_make_spans(unsigned rank, const hsize_t *start, const hsize_t *stride
last_span = NULL;
/* Generate all the span segments for this dimension */
- for(u = 0, stride_iter = 0; u < count[i]; u++, stride_iter += stride[i])
- {
+ curr_low = start[i];
+ curr_high = start[i] + (block[i] - 1);
+ dim_stride = stride[i];
+ for(u = 0; u < count[i]; u++, curr_low += dim_stride, curr_high += dim_stride) {
H5S_hyper_span_t *span; /* New hyperslab span */
/* Allocate a span node */
@@ -5910,12 +8475,14 @@ H5S__hyper_make_spans(unsigned rank, const hsize_t *start, const hsize_t *stride
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate hyperslab span")
/* Set the span's basic information */
- span->low = start[i] + stride_iter;
- span->high = span->low + (block[i] - 1);
- span->nelem = block[i];
- span->pstride = stride[i];
+ span->low = curr_low;
+ span->high = curr_high;
span->next = NULL;
+ /* Set the information for the next dimension down's spans */
+ /* (Will be NULL for fastest changing dimension) */
+ span->down = down;
+
/* Append to the list of spans in this dimension */
if(head == NULL)
head = span;
@@ -5924,23 +8491,32 @@ H5S__hyper_make_spans(unsigned rank, const hsize_t *start, const hsize_t *stride
/* Move current pointer */
last_span = span;
-
- /* Set the information for the next dimension down's spans, if appropriate */
- if(down != NULL) {
- span->down = down;
- down->count++; /* Increment reference count for shared span */
- } /* end if */
- else
- span->down = NULL;
} /* end for */
+ /* Increment ref. count of shared span */
+ if(down != NULL)
+ down->count = (unsigned)count[i];
+
/* Allocate a span info node */
- if(NULL == (down = H5FL_CALLOC(H5S_hyper_span_info_t)))
+ if(NULL == (down = H5S__hyper_new_span_info(rank)))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate hyperslab span")
/* Keep the pointer to the next dimension down's completed list */
down->head = head;
+ /* Keep the tail pointer to the next dimension down's completed list */
+ down->tail = last_span;
+
+ /* Set the low & high bounds for this dimension */
+ down->low_bounds[0] = down->head->low;
+ down->high_bounds[0] = down->tail->high;
+
+ /* Copy bounds from lower dimensions */
+ /* (head & tail pointers share lower dimensions, so using either is OK) */
+ if(head->down) {
+ H5MM_memcpy(&down->low_bounds[1], &head->down->low_bounds[0], sizeof(hsize_t) * ((rank - 1) - (unsigned)i));
+ H5MM_memcpy(&down->high_bounds[1], &head->down->high_bounds[0], sizeof(hsize_t) * ((rank - 1) - (unsigned)i));
+ } /* end if */
} /* end for */
/* Indicate that there is a pointer to this tree */
@@ -5961,7 +8537,7 @@ done:
do {
if(down) {
head = down->head;
- down = H5FL_FREE(H5S_hyper_span_info_t, down);
+ down = (H5S_hyper_span_info_t *)H5FL_ARR_FREE(hbounds_t, down);
} /* end if */
down = head->down;
@@ -5980,6 +8556,224 @@ done:
/*--------------------------------------------------------------------------
NAME
+ H5S__hyper_update_diminfo
+ PURPOSE
+ Attempt to update optimized hyperslab information quickly. (It can be
+ recovered with regular selection). If this algorithm cannot determine
+ the optimized dimension info quickly, this function will simply mark it
+ as invalid and unknown if it can be built (H5S_DIMINFO_VALID_NO), so
+ H5S__hyper_rebuild can be run later to determine for sure.
+ USAGE
+ herr_t H5S__hyper_update_diminfo(space, op, new_hyper_diminfo)
+ H5S_t *space; IN: Dataspace to check
+ H5S_seloper_t op; IN: The operation being performed on the
+ selection
+ const H5S_hyper_dim_t new_hyper_diminfo; IN: The new selection that
+ is being combined with
+ the current
+ RETURNS
+ >=0 on success, <0 on failure
+ DESCRIPTION
+ Examine the span tree for a hyperslab selection and rebuild
+ the start/stride/count/block information for the selection, if possible.
+
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+static herr_t
+H5S__hyper_update_diminfo(H5S_t *space, H5S_seloper_t op,
+ const H5S_hyper_dim_t *new_hyper_diminfo)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_STATIC_NOERR
+
+ /* Check args */
+ HDassert(space);
+ HDassert(new_hyper_diminfo);
+
+ /* Check for conditions that prevent us from using the fast algorithm here */
+ /* (and instead require H5S__hyper_rebuild) */
+ if(!((op == H5S_SELECT_OR) || (op == H5S_SELECT_XOR))
+ || space->select.sel_info.hslab->diminfo_valid != H5S_DIMINFO_VALID_YES
+ || !space->select.sel_info.hslab->span_lst->head)
+ space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_NO;
+ else {
+ H5S_hyper_dim_t tmp_diminfo[H5S_MAX_RANK]; /* Temporary dimension info */
+ hbool_t found_nonidentical_dim = FALSE;
+ unsigned curr_dim;
+
+ /* Copy current diminfo.opt values */
+ H5MM_memcpy(tmp_diminfo, space->select.sel_info.hslab->diminfo.opt, sizeof(tmp_diminfo));
+
+ /* Loop over dimensions */
+ for(curr_dim = 0; curr_dim < space->extent.rank; curr_dim++) {
+ /* Check for this being identical */
+ if((tmp_diminfo[curr_dim].start != new_hyper_diminfo[curr_dim].start)
+ || (tmp_diminfo[curr_dim].stride != new_hyper_diminfo[curr_dim].stride)
+ || (tmp_diminfo[curr_dim].count != new_hyper_diminfo[curr_dim].count)
+ || (tmp_diminfo[curr_dim].block != new_hyper_diminfo[curr_dim].block)) {
+ hsize_t high_start, high_count, high_block; /* The start, count & block values for the higher block */
+
+ /* Dimension is not identical */
+ /* Check if we already found a nonidentical dim - only one is
+ * allowed */
+ if(found_nonidentical_dim) {
+ space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_NO;
+ break;
+ } /* end if */
+
+ /* Check that strides are the same, or count is 1 for one of the
+ * slabs */
+ if((tmp_diminfo[curr_dim].stride != new_hyper_diminfo[curr_dim].stride)
+ && (tmp_diminfo[curr_dim].count > 1)
+ && (new_hyper_diminfo[curr_dim].count > 1)) {
+ space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_NO;
+ break;
+ } /* end if */
+
+ /* Patch tmp_diminfo.stride if its count is 1 */
+ if((tmp_diminfo[curr_dim].count == 1)
+ && (new_hyper_diminfo[curr_dim].count > 1))
+ tmp_diminfo[curr_dim].stride = new_hyper_diminfo[curr_dim].stride;
+
+ /* Determine lowest start, and set tmp_diminfo.start, count and
+ * block to use the lowest, and high_start, high_count and
+ * high_block to use the highest
+ */
+ if(tmp_diminfo[curr_dim].start < new_hyper_diminfo[curr_dim].start) {
+ high_start = new_hyper_diminfo[curr_dim].start;
+ high_count = new_hyper_diminfo[curr_dim].count;
+ high_block = new_hyper_diminfo[curr_dim].block;
+ } /* end if */
+ else {
+ high_start = tmp_diminfo[curr_dim].start;
+ tmp_diminfo[curr_dim].start = new_hyper_diminfo[curr_dim].start;
+ high_count = tmp_diminfo[curr_dim].count;
+ tmp_diminfo[curr_dim].count = new_hyper_diminfo[curr_dim].count;
+ high_block = tmp_diminfo[curr_dim].block;
+ tmp_diminfo[curr_dim].block = new_hyper_diminfo[curr_dim].block;
+ } /* end else */
+
+ /* If count is 1 for both slabs, take different actions */
+ if((tmp_diminfo[curr_dim].count == 1) && (high_count == 1)) {
+ /* Check for overlap */
+ if((tmp_diminfo[curr_dim].start + tmp_diminfo[curr_dim].block)
+ > high_start) {
+ /* Check operation type */
+ if(op == H5S_SELECT_OR)
+ /* Merge blocks */
+ tmp_diminfo[curr_dim].block = ((high_start + high_block)
+ >= (tmp_diminfo[curr_dim].start + tmp_diminfo[curr_dim].block))
+ ? (high_start + high_block - tmp_diminfo[curr_dim].start)
+ : tmp_diminfo[curr_dim].block;
+ else {
+ /* Block values must be the same */
+ if(tmp_diminfo[curr_dim].block != high_block) {
+ space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_NO;
+ break;
+ } /* end if */
+
+ /* XOR - overlap creates 2 blocks */
+ tmp_diminfo[curr_dim].stride = high_block;
+ tmp_diminfo[curr_dim].count = 2;
+ tmp_diminfo[curr_dim].block = high_start - tmp_diminfo[curr_dim].start;
+ } /* end else */
+ } /* end if */
+ else if((tmp_diminfo[curr_dim].start + tmp_diminfo[curr_dim].block)
+ == high_start)
+ /* Blocks border, merge them */
+ tmp_diminfo[curr_dim].block += high_block;
+ else {
+ /* Distinct blocks */
+ /* Block values must be the same */
+ if(tmp_diminfo[curr_dim].block != high_block) {
+ space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_NO;
+ break;
+ } /* end if */
+
+ /* Create strided selection */
+ tmp_diminfo[curr_dim].stride = high_start - tmp_diminfo[curr_dim].start;
+ tmp_diminfo[curr_dim].count = 2;
+ } /* end else */
+ } /* end if */
+ else {
+ /* Check if block values are the same */
+ if(tmp_diminfo[curr_dim].block != new_hyper_diminfo[curr_dim].block) {
+ space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_NO;
+ break;
+ } /* end if */
+
+ /* Check phase of strides */
+ if((tmp_diminfo[curr_dim].start % tmp_diminfo[curr_dim].stride)
+ != (new_hyper_diminfo[curr_dim].start % tmp_diminfo[curr_dim].stride)) {
+ space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_NO;
+ break;
+ } /* end if */
+
+ /* Check operation type */
+ if(op == H5S_SELECT_OR) {
+ /* Make sure the slabs border or overlap */
+ if(high_start > (tmp_diminfo[curr_dim].start
+ + (tmp_diminfo[curr_dim].count
+ * tmp_diminfo[curr_dim].stride))) {
+ space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_NO;
+ break;
+ } /* end if */
+ } /* end if */
+ else
+ /* XOR: Make sure the slabs border */
+ if(high_start != (tmp_diminfo[curr_dim].start
+ + (tmp_diminfo[curr_dim].count
+ * tmp_diminfo[curr_dim].stride))) {
+ space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_NO;
+ break;
+ } /* end if */
+
+ /* Set count for combined selection */
+ tmp_diminfo[curr_dim].count = ((high_start
+ - tmp_diminfo[curr_dim].start)
+ / tmp_diminfo[curr_dim].stride) + high_count;
+ } /* end else */
+
+ /* Indicate that we found a nonidentical dim */
+ found_nonidentical_dim = TRUE;
+ } /* end if */
+ } /* end for */
+
+ /* Check if we succeeded, if so, set the new diminfo values */
+ if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES)
+ for(curr_dim = 0; curr_dim < space->extent.rank; curr_dim++) {
+ hsize_t tmp_high_bound;
+
+ /* Set the new diminfo values */
+ space->select.sel_info.hslab->diminfo.app[curr_dim].start = space->select.sel_info.hslab->diminfo.opt[curr_dim].start = tmp_diminfo[curr_dim].start;
+ HDassert(tmp_diminfo[curr_dim].stride > 0);
+ space->select.sel_info.hslab->diminfo.app[curr_dim].stride = space->select.sel_info.hslab->diminfo.opt[curr_dim].stride = tmp_diminfo[curr_dim].stride;
+ HDassert(tmp_diminfo[curr_dim].count > 0);
+ space->select.sel_info.hslab->diminfo.app[curr_dim].count = space->select.sel_info.hslab->diminfo.opt[curr_dim].count = tmp_diminfo[curr_dim].count;
+ HDassert(tmp_diminfo[curr_dim].block > 0);
+ space->select.sel_info.hslab->diminfo.app[curr_dim].block = space->select.sel_info.hslab->diminfo.opt[curr_dim].block = tmp_diminfo[curr_dim].block;
+
+ /* Check for updating the low & high bounds */
+ if(tmp_diminfo[curr_dim].start < space->select.sel_info.hslab->diminfo.low_bounds[curr_dim])
+ space->select.sel_info.hslab->diminfo.low_bounds[curr_dim] = tmp_diminfo[curr_dim].start;
+ tmp_high_bound = tmp_diminfo[curr_dim].start +
+ (tmp_diminfo[curr_dim].block - 1) +
+ (tmp_diminfo[curr_dim].stride * (tmp_diminfo[curr_dim].count - 1));
+ if(tmp_high_bound > space->select.sel_info.hslab->diminfo.low_bounds[curr_dim])
+ space->select.sel_info.hslab->diminfo.high_bounds[curr_dim] = tmp_high_bound;
+ } /* end for */
+ } /* end else */
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5S__hyper_update_diminfo() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
H5S__hyper_rebuild_helper
PURPOSE
Helper routine to rebuild optimized hyperslab information if possible.
@@ -5989,6 +8783,7 @@ done:
const H5S_hyper_span_t *span; IN: Portion of span tree to check
H5S_hyper_dim_t span_slab[]; OUT: Rebuilt section of hyperslab description
unsigned rank; IN: Current dimension to work on
+ uint64_t op_gen; IN: Operation generation
RETURNS
TRUE/FALSE for hyperslab selection rebuilt
DESCRIPTION
@@ -6003,108 +8798,85 @@ done:
KY, 2005/9/22
--------------------------------------------------------------------------*/
static hbool_t
-H5S__hyper_rebuild_helper(const H5S_hyper_span_t *span, H5S_hyper_dim_t span_slab_info[],
- unsigned rank)
+H5S__hyper_rebuild_helper(const H5S_hyper_span_info_t *spans, H5S_hyper_dim_t span_slab_info[])
{
+ const H5S_hyper_span_t *span; /* Hyperslab span */
+ const H5S_hyper_span_t *prev_span; /* Previous span in list */
+ hsize_t start; /* Starting element for this dimension */
+ hsize_t stride; /* Stride for this dimension */
+ hsize_t block; /* Block size for this dimension */
+ hsize_t prev_low; /* Low bound for previous span */
+ size_t spancount; /* Number of spans encountered in this dimension */
hbool_t ret_value = TRUE; /* Return value */
FUNC_ENTER_STATIC_NOERR
- if(span) {
- const H5S_hyper_span_t *prev_span = NULL; /* Previous span in list */
- H5S_hyper_dim_t canon_down_span_slab_info[H5S_MAX_RANK];
- hsize_t curr_stride;
- hsize_t curr_block;
- hsize_t curr_start;
- hsize_t curr_low;
- size_t outcount; /* Number of spans encountered in this dimension */
-
- /* Initialization */
- curr_stride = 1;
- curr_low = 0;
- outcount = 0;
-
- /* Get "canonical" down span information */
- if(span->down) {
- HDassert(span->down->head);
-
- /* Go to the next down span and check whether the selection can be rebuilt */
- if(!H5S__hyper_rebuild_helper(span->down->head, span_slab_info, rank - 1))
- HGOTO_DONE(FALSE)
-
- HDmemcpy(canon_down_span_slab_info, span_slab_info, sizeof(H5S_hyper_dim_t) * rank);
- } /* end if */
+ /* Sanity check */
+ HDassert(spans);
- /* Assign the initial starting point & block size */
- curr_start = span->low;
- curr_block = (span->high - span->low) + 1;
+ /* Initialization */
+ span = spans->head;
+ stride = 1;
+ prev_low = 0;
+ spancount = 0;
- /* Loop the spans */
- while(span) {
- if(outcount > 0) {
- hsize_t next_stride; /* Stride from previous span */
- hsize_t next_block; /* Block size of current span */
+ /* Get "canonical" down span information */
+ if(span->down)
+ /* Go to the next down span and check whether the selection can be rebuilt */
+ if(!H5S__hyper_rebuild_helper(span->down, &span_slab_info[1]))
+ HGOTO_DONE(FALSE)
- /* Check that down spans match current slab info */
- /* (Can skip check if previous span's down pointer is same as current one) */
- if(span->down && (NULL == prev_span || prev_span->down != span->down)) {
- H5S_hyper_dim_t *curr_down_span_slab_info;
- unsigned u; /* Local index variable */
+ /* Assign the initial starting point & block size for this dimension */
+ start = span->low;
+ block = (span->high - span->low) + 1;
- HDassert(span->down->head);
+ /* Loop the spans */
+ prev_span = NULL;
+ while(span) {
+ if(spancount > 0) {
+ hsize_t curr_stride; /* Current stride from previous span */
+ hsize_t curr_block; /* Block size of current span */
- /* Go to the next down span and check whether the selection can be rebuilt.*/
- if(!H5S__hyper_rebuild_helper(span->down->head, span_slab_info, rank - 1))
- HGOTO_DONE(FALSE)
+ /* Sanity check */
+ HDassert(prev_span);
- /* Compare the slab information of the adjacent spans in the down span tree.
- We have to compare all the sub-tree slab information with the canon_down_span_slab_info.*/
- for(u = 0; u < rank - 1; u++) {
- curr_down_span_slab_info = &span_slab_info[u];
-
- if(curr_down_span_slab_info->count > 0 && canon_down_span_slab_info[u].count > 0) {
- if(curr_down_span_slab_info->start != canon_down_span_slab_info[u].start
- || curr_down_span_slab_info->stride != canon_down_span_slab_info[u].stride
- || curr_down_span_slab_info->block != canon_down_span_slab_info[u].block
- || curr_down_span_slab_info->count != canon_down_span_slab_info[u].count)
- HGOTO_DONE(FALSE)
- } /* end if */
- else if(!((curr_down_span_slab_info->count == 0) && (canon_down_span_slab_info[u].count == 0)))
- HGOTO_DONE(FALSE)
- } /* end for */
- } /* end if */
+ /* Check that down spans match current slab info */
+ /* (Can skip check if previous span's down pointer is same as current one) */
+ if(span->down && prev_span->down != span->down)
+ if(!H5S__hyper_cmp_spans(span->down, prev_span->down))
+ HGOTO_DONE(FALSE)
- /* Obtain values for stride and block */
- next_stride = span->low - curr_low;
- next_block = (span->high - span->low) + 1;
+ /* Obtain values for stride and block */
+ curr_stride = span->low - prev_low;
+ curr_block = (span->high - span->low) + 1;
- /* Compare stride and block in this span, to compare stride,
- * three spans are needed. Account for the first two spans.
- */
- if(next_block != curr_block)
- HGOTO_DONE(FALSE)
- if(outcount > 1 && curr_stride != next_stride)
+ /* Compare stride and block for this span. To compare stride,
+ * three spans are needed. Account for the first two spans.
+ */
+ if(curr_block != block)
+ HGOTO_DONE(FALSE)
+ if(spancount > 1) {
+ if(stride != curr_stride)
HGOTO_DONE(FALSE)
-
- /* Keep the isolated stride to be 1 */
- curr_stride = next_stride;
} /* end if */
+ else
+ stride = curr_stride;
+ } /* end if */
- /* Keep current starting point */
- curr_low = span->low;
+ /* Keep current starting point */
+ prev_low = span->low;
- /* Advance to next span */
- prev_span = span;
- span = span->next;
- outcount++;
- } /* end while */
+ /* Advance to next span */
+ prev_span = span;
+ span = span->next;
+ spancount++;
+ } /* end while */
- /* Save the span information. */
- span_slab_info[rank - 1].start = curr_start;
- span_slab_info[rank - 1].count = outcount;
- span_slab_info[rank - 1].block = curr_block;
- span_slab_info[rank - 1].stride = curr_stride;
- } /* end if */
+ /* Save the span information. */
+ span_slab_info[0].start = start;
+ span_slab_info[0].count = spancount;
+ span_slab_info[0].block = block;
+ span_slab_info[0].stride = stride;
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -6118,65 +8890,46 @@ done:
Rebuild optimized hyperslab information if possible.
(It can be recovered with regular selection)
USAGE
- hbool_t H5S__hyper_rebuild(space)
- const H5S_t *space; IN: Dataspace to check
+ void H5S__hyper_rebuild(space)
+ H5S_t *space; IN: Dataspace to check
RETURNS
- TRUE/FALSE for hyperslab selection rebuilt
+ None
DESCRIPTION
- Examine the span tree for a hyperslab selection and rebuild
- the start/stride/count/block information for the selection, if possible.
+ Examine the span tree for a hyperslab selection and rebuild a regular
+ start/stride/count/block hyperslab selection, if possible.
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
To be able to recover the optimized information, the span tree must conform
to span tree able to be generated from a single H5S_SELECT_SET operation.
EXAMPLES
REVISION LOG
- This routine is the optimization of the old version. The previous version
- can only detect a singluar selection. This version is general enough to
- detect any regular selection.
- KY, 2005/9/22
--------------------------------------------------------------------------*/
-static hbool_t
+void
H5S__hyper_rebuild(H5S_t *space)
{
- H5S_hyper_dim_t top_span_slab_info[H5O_LAYOUT_NDIMS];
- unsigned rank, curr_dim;
- hbool_t ret_value = TRUE; /* Return value */
+ H5S_hyper_dim_t rebuilt_slab_info[H5S_MAX_RANK];
- FUNC_ENTER_STATIC_NOERR
+ FUNC_ENTER_PACKAGE_NOERR
/* Check args */
HDassert(space);
HDassert(space->select.sel_info.hslab->span_lst);
- /* Check the rank of space */
- rank = space->extent.rank;
-
- /* Check whether the slab can be rebuilt. Only regular selection can be rebuilt. If yes, fill in correct values.*/
- if(!H5S__hyper_rebuild_helper(space->select.sel_info.hslab->span_lst->head, top_span_slab_info, rank)) {
- HGOTO_DONE(FALSE)
- } /* end if */
+ /* Check whether the slab can be rebuilt */
+ /* (Only regular selection can be rebuilt. If yes, fill in correct values) */
+ if(FALSE == H5S__hyper_rebuild_helper(space->select.sel_info.hslab->span_lst, rebuilt_slab_info))
+ space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_IMPOSSIBLE;
else {
- H5S_hyper_dim_t *diminfo;
- H5S_hyper_dim_t *app_diminfo;
-
- diminfo = space->select.sel_info.hslab->opt_diminfo;
- app_diminfo = space->select.sel_info.hslab->app_diminfo;
-
- for(curr_dim = 0; curr_dim < rank; curr_dim++) {
+ /* Set the dimension info & bounds for the dataspace, from the rebuilt info */
+ H5MM_memcpy(space->select.sel_info.hslab->diminfo.app, rebuilt_slab_info, sizeof(rebuilt_slab_info));
+ H5MM_memcpy(space->select.sel_info.hslab->diminfo.opt, rebuilt_slab_info, sizeof(rebuilt_slab_info));
+ H5MM_memcpy(space->select.sel_info.hslab->diminfo.low_bounds, space->select.sel_info.hslab->span_lst->low_bounds, sizeof(hsize_t) * space->extent.rank);
+ H5MM_memcpy(space->select.sel_info.hslab->diminfo.high_bounds, space->select.sel_info.hslab->span_lst->high_bounds, sizeof(hsize_t) * space->extent.rank);
- app_diminfo[(rank - curr_dim) - 1].start = diminfo[(rank - curr_dim) - 1].start = top_span_slab_info[curr_dim].start;
- app_diminfo[(rank - curr_dim) - 1].stride = diminfo[(rank - curr_dim) - 1].stride = top_span_slab_info[curr_dim].stride;
- app_diminfo[(rank - curr_dim) - 1].count = diminfo[(rank - curr_dim) - 1].count = top_span_slab_info[curr_dim].count;
- app_diminfo[(rank - curr_dim) - 1].block = diminfo[(rank - curr_dim) - 1].block = top_span_slab_info[curr_dim].block;
-
- } /* end for */
-
- space->select.sel_info.hslab->diminfo_valid = TRUE;
+ space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_YES;
} /* end else */
-done:
- FUNC_LEAVE_NOAPI(ret_value)
+ FUNC_LEAVE_NOAPI_VOID
} /* end H5S__hyper_rebuild() */
@@ -6201,12 +8954,12 @@ done:
static herr_t
H5S__hyper_generate_spans(H5S_t *space)
{
- hsize_t tmp_start[H5O_LAYOUT_NDIMS]; /* Temporary start information */
- hsize_t tmp_stride[H5O_LAYOUT_NDIMS]; /* Temporary stride information */
- hsize_t tmp_count[H5O_LAYOUT_NDIMS]; /* Temporary count information */
- hsize_t tmp_block[H5O_LAYOUT_NDIMS]; /* Temporary block information */
- unsigned u; /* Local index variable */
- herr_t ret_value = SUCCEED; /* Return value */
+ hsize_t tmp_start[H5S_MAX_RANK]; /* Temporary start information */
+ hsize_t tmp_stride[H5S_MAX_RANK]; /* Temporary stride information */
+ hsize_t tmp_count[H5S_MAX_RANK]; /* Temporary count information */
+ hsize_t tmp_block[H5S_MAX_RANK]; /* Temporary block information */
+ unsigned u; /* Local index variable */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
@@ -6219,15 +8972,15 @@ H5S__hyper_generate_spans(H5S_t *space)
/* These should be able to be converted to assertions once everything
* that calls this function checks for unlimited selections first
* (especially the new hyperslab API) -NAF */
- if(space->select.sel_info.hslab->opt_diminfo[u].count == H5S_UNLIMITED)
+ if(space->select.sel_info.hslab->diminfo.opt[u].count == H5S_UNLIMITED)
HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "can't generate spans with unlimited count")
- if(space->select.sel_info.hslab->opt_diminfo[u].block == H5S_UNLIMITED)
+ if(space->select.sel_info.hslab->diminfo.opt[u].block == H5S_UNLIMITED)
HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "can't generate spans with unlimited block")
- tmp_start[u]=space->select.sel_info.hslab->opt_diminfo[u].start;
- tmp_stride[u]=space->select.sel_info.hslab->opt_diminfo[u].stride;
- tmp_count[u]=space->select.sel_info.hslab->opt_diminfo[u].count;
- tmp_block[u]=space->select.sel_info.hslab->opt_diminfo[u].block;
+ tmp_start[u] = space->select.sel_info.hslab->diminfo.opt[u].start;
+ tmp_stride[u] = space->select.sel_info.hslab->diminfo.opt[u].stride;
+ tmp_count[u] = space->select.sel_info.hslab->diminfo.opt[u].count;
+ tmp_block[u] = space->select.sel_info.hslab->diminfo.opt[u].block;
} /* end for */
/* Build the hyperslab information also */
@@ -6238,7 +8991,386 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5S__hyper_generate_spans() */
-#ifndef NEW_HYPERSLAB_API
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S__check_spans_overlap
+ PURPOSE
+ Check if two selections' bounds overlap.
+ USAGE
+ hbool_t H5S__check_spans_overlap(spans1, spans2)
+ const H5S_hyper_span_info_t *spans1; IN: Second span list
+ const H5S_hyper_span_info_t *spans2; IN: Second span list
+ RETURNS
+ TRUE for overlap, FALSE for no overlap
+ PROGRAMMER
+ Quincey Koziol - January 24, 2019
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+static H5_ATTR_PURE hbool_t
+H5S__check_spans_overlap(const H5S_hyper_span_info_t *spans1,
+ const H5S_hyper_span_info_t *spans2)
+{
+ hbool_t ret_value = FALSE; /* Return value */
+
+ FUNC_ENTER_STATIC_NOERR
+
+ /* Sanity checks */
+ HDassert(spans1);
+ HDassert(spans2);
+
+ /* Use low & high bounds to try to avoid spinning through the span lists */
+ if(H5S_RANGE_OVERLAP(spans1->low_bounds[0], spans1->high_bounds[0],
+ spans2->low_bounds[0], spans2->high_bounds[0])) {
+ H5S_hyper_span_t *span1, *span2; /* Hyperslab spans */
+
+ /* Walk over spans, comparing them for overlap */
+ span1 = spans1->head;
+ span2 = spans2->head;
+ while(span1 && span2) {
+ /* Check current two spans for overlap */
+ if(H5S_RANGE_OVERLAP(span1->low, span1->high, span2->low, span2->high)) {
+ /* Check for spans in lowest dimension already */
+ if(span1->down) {
+ /* Sanity check */
+ HDassert(span2->down);
+
+ /* Check lower dimensions for overlap */
+ if(H5S__check_spans_overlap(span1->down, span2->down))
+ HGOTO_DONE(TRUE);
+ } /* end if */
+ else
+ HGOTO_DONE(TRUE);
+ } /* end if */
+
+ /* Advance one of the spans */
+ if(span1->high <= span2->high) {
+ /* Advance span1, unless it would be off the list and span2 has more nodes */
+ if(NULL == span1->next && NULL != span2->next)
+ span2 = span2->next;
+ else
+ span1 = span1->next;
+ } /* end if */
+ else {
+ /* Advance span2, unless it would be off the list and span1 has more nodes */
+ if(NULL == span2->next && NULL != span1->next)
+ span1 = span1->next;
+ else
+ span2 = span2->next;
+ } /* end else */
+ } /* end while */
+
+ /* Make certain we've exhausted our comparisons */
+ HDassert((NULL == span1 && (NULL != span2 && NULL == span2->next)) ||
+ ((NULL != span1 && NULL == span1->next) && NULL == span2));
+ } /* end of */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5S__check_spans_overlap() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S__fill_in_new_space
+ PURPOSE
+ Combine two span lists, one from an existing dataspace and the
+ other from input arguments, into a new selection depending on the
+ selection operator. The new selection is put into a resulting dataspace
+ which could be allocated inside the function.
+ USAGE
+ herr_t H5S__fill_in_new_space(space1, op, space2_span_lst, can_own_span2,
+ span2_owned, result)
+ H5S_t *space1; IN: Dataspace containing the first span list
+ H5S_seloper_t op; IN: Selection operation
+ H5S_hyper_span_info_t *space2_span_lst; IN: Second span list
+ hbool_t can_own_span2; IN: Indicates whether the 2nd span list could be
+ owned by the result. If not, the 2nd span list
+ has to be copied.
+ hbool_t *span2_owned; OUT: Indicates if the 2nd span list is actually owned
+ H5S_t **result; OUT: The dataspace containing the the new selection. It
+ could be same with the 1st dataspace.
+ RETURNS
+ Non-negative on success, negative on failure
+ PROGRAMMER
+ Chao Mei July 8, 2011
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+static herr_t
+H5S__fill_in_new_space(H5S_t *space1, H5S_seloper_t op,
+ H5S_hyper_span_info_t *space2_span_lst, hbool_t can_own_span2,
+ hbool_t *span2_owned, hbool_t *updated_spans, H5S_t **result)
+{
+ H5S_hyper_span_info_t *a_not_b = NULL; /* Span tree for hyperslab spans in old span tree and not in new span tree */
+ H5S_hyper_span_info_t *a_and_b = NULL; /* Span tree for hyperslab spans in both old and new span trees */
+ H5S_hyper_span_info_t *b_not_a = NULL; /* Span tree for hyperslab spans in new span tree and not in old span tree */
+ hbool_t overlapped = FALSE; /* Whether selections overlap */
+ hbool_t is_result_new = FALSE;
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_STATIC
+
+ HDassert(space1);
+ HDassert(space2_span_lst);
+ HDassert(op >= H5S_SELECT_OR && op <= H5S_SELECT_NOTA);
+ /* The result is either a to-be-created space or an empty one */
+ HDassert(*result == NULL || *result == space1);
+ HDassert(space1->select.sel_info.hslab->span_lst);
+ HDassert(span2_owned);
+
+ /* Reset flags to return */
+ *span2_owned = FALSE;
+ *updated_spans = FALSE;
+
+ /* The result shares the same info from space1 */
+ if(*result == NULL) {
+ if(NULL == ((*result) = H5S_copy(space1, TRUE, TRUE)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to copy dataspace")
+ space1->select.sel_info.hslab->span_lst->count--;
+ (*result)->select.sel_info.hslab->span_lst = NULL;
+ is_result_new = TRUE;
+ } /* end if */
+
+ /* Check both spaces to see if they overlap */
+ overlapped = H5S__check_spans_overlap(space1->select.sel_info.hslab->span_lst, space2_span_lst);
+
+ if(!overlapped) {
+ switch(op) {
+ case H5S_SELECT_OR:
+ case H5S_SELECT_XOR:
+ /* Add the new disjoint spans to the space */
+ /* Copy of space1's spans to *result, and another copy of space2's spans */
+ if(is_result_new)
+ (*result)->select.sel_info.hslab->span_lst = H5S__hyper_copy_span(space1->select.sel_info.hslab->span_lst, space1->extent.rank);
+ if(!can_own_span2) {
+ b_not_a = H5S__hyper_copy_span(space2_span_lst, space1->extent.rank);
+ if(H5S__hyper_add_disjoint_spans(*result, b_not_a) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't append hyperslabs")
+
+ /* The new_spans are now owned by 'space', so they should not be released */
+ b_not_a = NULL;
+ } /* end if */
+ else {
+ if(H5S__hyper_add_disjoint_spans(*result, space2_span_lst) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't append hyperslabs")
+ *span2_owned = TRUE;
+ } /* end else */
+
+ /* Indicate that the spans changed */
+ *updated_spans = TRUE;
+ break;
+
+ case H5S_SELECT_AND:
+ /* Convert *result to "none" selection */
+ if(H5S_select_none(*result) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't convert selection")
+ HGOTO_DONE(SUCCEED);
+
+ case H5S_SELECT_NOTB:
+ /* Copy space1's spans to *result */
+ if(is_result_new)
+ (*result)->select.sel_info.hslab->span_lst = H5S__hyper_copy_span(space1->select.sel_info.hslab->span_lst, space1->extent.rank);
+
+ /* Indicate that the spans changed */
+ *updated_spans = TRUE;
+ break;
+
+ case H5S_SELECT_NOTA:
+ if(!is_result_new) {
+ HDassert(space1 == *result);
+
+ /* Free the current selection */
+ H5S__hyper_free_span_info(space1->select.sel_info.hslab->span_lst);
+ space1->select.sel_info.hslab->span_lst = NULL;
+ } /* end if */
+
+ /* Copy space2's spans to *result */
+ if(!can_own_span2)
+ (*result)->select.sel_info.hslab->span_lst = H5S__hyper_copy_span(space2_span_lst, space1->extent.rank);
+ else {
+ (*result)->select.sel_info.hslab->span_lst = space2_span_lst;
+ *span2_owned = TRUE;
+ } /* end else */
+
+ /* Reset the number of items in selection */
+ (*result)->select.num_elem = H5S__hyper_spans_nelem(space2_span_lst);
+
+ /* Indicate that the spans changed */
+ *updated_spans = TRUE;
+ break;
+
+ case H5S_SELECT_NOOP:
+ case H5S_SELECT_SET:
+ case H5S_SELECT_APPEND:
+ case H5S_SELECT_PREPEND:
+ case H5S_SELECT_INVALID:
+ default:
+ HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation")
+ } /* end switch */
+ } /* end if */
+ else {
+ unsigned selector = 0; /* Select which clipping spans to generate */
+
+ /* Generate mask for clip operation depending on the op */
+ switch(op) {
+ case H5S_SELECT_OR: /* a + b_not_a */
+ selector = H5S_HYPER_COMPUTE_B_NOT_A;
+ break;
+
+ case H5S_SELECT_XOR: /* a_not_b + b_not_a */
+ selector = H5S_HYPER_COMPUTE_A_NOT_B | H5S_HYPER_COMPUTE_B_NOT_A;
+ break;
+
+ case H5S_SELECT_AND: /* a_and_b */
+ selector = H5S_HYPER_COMPUTE_A_AND_B;
+ break;
+
+ case H5S_SELECT_NOTB: /* a_not_b */
+ selector = H5S_HYPER_COMPUTE_A_NOT_B;
+ break;
+
+ case H5S_SELECT_NOTA: /* b_not_a */
+ selector = H5S_HYPER_COMPUTE_B_NOT_A;
+ break;
+
+ case H5S_SELECT_NOOP:
+ case H5S_SELECT_SET:
+ case H5S_SELECT_APPEND:
+ case H5S_SELECT_PREPEND:
+ case H5S_SELECT_INVALID:
+ default:
+ HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation")
+ } /* end switch */
+
+ /* Generate lists of spans which overlap and don't overlap */
+ if(H5S__hyper_clip_spans(space1->select.sel_info.hslab->span_lst,
+ space2_span_lst, selector, space1->extent.rank,
+ &a_not_b, &a_and_b, &b_not_a) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't clip hyperslab information")
+ switch(op) {
+ case H5S_SELECT_OR:
+ if(is_result_new)
+ (*result)->select.sel_info.hslab->span_lst = H5S__hyper_copy_span(space1->select.sel_info.hslab->span_lst, space1->extent.rank);
+ break;
+
+ case H5S_SELECT_AND:
+ case H5S_SELECT_XOR:
+ case H5S_SELECT_NOTB:
+ case H5S_SELECT_NOTA:
+ if(!is_result_new) {
+ HDassert(space1 == *result);
+
+ /* Free the current selection */
+ H5S__hyper_free_span_info(space1->select.sel_info.hslab->span_lst);
+ space1->select.sel_info.hslab->span_lst = NULL;
+ } /* end if */
+
+ /* Reset the number of items in selection */
+ /* (Will be set below) */
+ (*result)->select.num_elem = 0;
+ break;
+
+ case H5S_SELECT_NOOP:
+ case H5S_SELECT_SET:
+ case H5S_SELECT_APPEND:
+ case H5S_SELECT_PREPEND:
+ case H5S_SELECT_INVALID:
+ default:
+ HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation")
+ } /* end switch */
+
+ /* Check if there are any non-overlapped selections */
+ if(a_not_b) {
+ /* Other than OR, the span_lst is set to NULL. And in OR,
+ * a_not_b is not needed
+ */
+ HDassert(NULL == (*result)->select.sel_info.hslab->span_lst);
+
+ /* The results dataspace takes ownership of the spans */
+ /* (Since it must be NULL) */
+ (*result)->select.sel_info.hslab->span_lst = a_not_b;
+
+ /* Update the number of elements in current selection */
+ (*result)->select.num_elem = H5S__hyper_spans_nelem(a_not_b);
+
+ /* Indicate that the spans were updated */
+ *updated_spans = TRUE;
+
+ /* Indicate that the a_not_b spans are owned */
+ a_not_b = NULL;
+ } /* end if */
+
+ if(a_and_b) {
+ /**
+ * 1. Other than OR, the span_lst is set to NULL. And in OR,
+ * a_and_b is not needed
+ * 2. a_not_b will never be computed together with a_and_b
+ * because merging these two equals to a.
+ */
+ HDassert(NULL == (*result)->select.sel_info.hslab->span_lst);
+
+ /* The results dataspace takes ownership of the spans */
+ /* (Since it must be NULL) */
+ (*result)->select.sel_info.hslab->span_lst = a_and_b;
+
+ /* Update the number of elements in current selection */
+ (*result)->select.num_elem = H5S__hyper_spans_nelem(a_and_b);
+
+ /* Indicate that the spans were updated */
+ *updated_spans = TRUE;
+
+ /* Indicate that the a_and_b spans are owned */
+ a_and_b = NULL;
+ } /* end if */
+
+ if(b_not_a) {
+ /* Merge the b_not_a spans into the result dataspace */
+ if(H5S__hyper_merge_spans(*result, b_not_a) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert hyperslabs")
+
+ /* Update the number of elements in current selection */
+ (*result)->select.num_elem += H5S__hyper_spans_nelem(b_not_a);
+
+ /* Indicate that the spans were updated */
+ *updated_spans = TRUE;
+ } /* end if */
+ } /* end else for the case the new span overlaps with the old (i.e. space) */
+
+ /* Check if the spans weren't updated, and reset selection if so */
+ if(!*updated_spans) {
+ /* If updated_spans remains FALSE as in this branch, it means the
+ * result has been cleared in XOR / AND / NOTB / NOTA cases, and the
+ * result is a copy of the dataspace in the OR case.
+ *
+ * If two dataspaces have generated any of the three clipped
+ * span trees (i.e. a_not_b, a_and_b, and b_not_a), the
+ * updated_spans must be TRUE.
+ */
+ if(H5S_SELECT_OR != op) {
+ /* Convert *result to "none" selection */
+ if(H5S_select_none(*result) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't convert selection")
+ } /* end else */
+ } /* end if */
+
+done:
+ /* Free resources */
+ if(a_not_b)
+ H5S__hyper_free_span_info(a_not_b);
+ if(a_and_b)
+ H5S__hyper_free_span_info(a_and_b);
+ if(b_not_a)
+ H5S__hyper_free_span_info(b_not_a);
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5S__fill_in_new_space() */
+
/*-------------------------------------------------------------------------
* Function: H5S__generate_hyperlab
@@ -6247,24 +9379,16 @@ done:
*
* Return: Non-negative on success/Negative on failure
*
- * Programmer: Quincey Koziol (split from HS_select_hyperslab()).
+ * Programmer: Quincey Koziol
* Tuesday, September 12, 2000
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static herr_t
-H5S__generate_hyperslab (H5S_t *space, H5S_seloper_t op,
- const hsize_t start[],
- const hsize_t stride[],
- const hsize_t count[],
- const hsize_t block[])
+H5S__generate_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[],
+ const hsize_t stride[], const hsize_t count[], const hsize_t block[])
{
- H5S_hyper_span_info_t *new_spans=NULL; /* Span tree for new hyperslab */
- H5S_hyper_span_info_t *a_not_b = NULL; /* Span tree for hyperslab spans in old span tree and not in new span tree */
- H5S_hyper_span_info_t *a_and_b = NULL; /* Span tree for hyperslab spans in both old and new span trees */
- H5S_hyper_span_info_t *b_not_a = NULL; /* Span tree for hyperslab spans in new span tree and not in old span tree */
+ H5S_hyper_span_info_t *new_spans = NULL; /* Span tree for new hyperslab */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
@@ -6282,206 +9406,390 @@ H5S__generate_hyperslab (H5S_t *space, H5S_seloper_t op,
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't create hyperslab information")
/* Generate list of blocks to add/remove based on selection operation */
- if(op==H5S_SELECT_SET) {
- /* Add new spans to current selection */
- if(H5S__hyper_merge_spans(space,new_spans,TRUE)<0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert hyperslabs")
+ if(op == H5S_SELECT_SET) {
+ /* Free current selection */
+ if(NULL != space->select.sel_info.hslab->span_lst)
+ H5S__hyper_free_span_info(space->select.sel_info.hslab->span_lst);
+
+ /* Set the hyperslab selection to the new span tree */
+ space->select.sel_info.hslab->span_lst = new_spans;
/* Set the number of elements in current selection */
space->select.num_elem = H5S__hyper_spans_nelem(new_spans);
/* Indicate that the new_spans are owned */
- new_spans=NULL;
+ new_spans = NULL;
} /* end if */
else {
- hbool_t updated_spans = FALSE; /* Whether the spans in the selection were modified */
+ hbool_t new_spans_owned = FALSE;
+ hbool_t updated_spans = FALSE;
- /* Generate lists of spans which overlap and don't overlap */
- if(H5S__hyper_clip_spans(space->select.sel_info.hslab->span_lst,new_spans,&a_not_b,&a_and_b,&b_not_a)<0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't clip hyperslab information")
+ /* Generate new spans for space */
+ if(H5S__fill_in_new_space(space, op, new_spans, TRUE, &new_spans_owned, &updated_spans, &space) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't generate the specified hyperslab")
- switch(op) {
- case H5S_SELECT_OR:
- /* Add any new spans from b_not_a to current selection */
- if(b_not_a!=NULL) {
- if(H5S__hyper_merge_spans(space,b_not_a,FALSE)<0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert hyperslabs")
+ /* Check if the spans were updated by H5S__fill_in_new_space */
+ if(updated_spans) {
+ H5S_hyper_dim_t new_hyper_diminfo[H5S_MAX_RANK];
+ unsigned u; /* Local index variable */
- /* Update the number of elements in current selection */
- space->select.num_elem += H5S__hyper_spans_nelem(b_not_a);
+ /* Sanity check */
+ HDassert(space->select.sel_info.hslab->span_lst->head);
+
+ /* Build diminfo struct */
+ for(u = 0; u <space->extent.rank; u++) {
+ new_hyper_diminfo[u].start = start[u];
+ new_hyper_diminfo[u].stride = stride[u];
+ new_hyper_diminfo[u].count = count[u];
+ new_hyper_diminfo[u].block = block[u];
+ } /* end for */
- /* Indicate that the spans were updated */
- updated_spans = TRUE;
- } /* end if */
- break;
+ /* Update space's dim info */
+ if(H5S__hyper_update_diminfo(space, op, new_hyper_diminfo) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOUNT, FAIL, "can't update hyperslab info")
+ } /* end if */
- case H5S_SELECT_AND:
- /* Free the current selection */
- if(H5S__hyper_free_span_info(space->select.sel_info.hslab->span_lst)<0)
- HGOTO_ERROR(H5E_INTERNAL, H5E_CANTFREE, FAIL, "failed to release hyperslab spans")
- space->select.sel_info.hslab->span_lst=NULL;
+ /* Indicate that the new_spans are owned, there's no need to free */
+ if(new_spans_owned)
+ new_spans = NULL;
+ } /* end else */
- /* Reset the number of items in selection */
- space->select.num_elem=0;
+done:
+ if(new_spans)
+ H5S__hyper_free_span_info(new_spans);
- /* Check if there are any overlapped selections */
- if(a_and_b!=NULL) {
- if(H5S__hyper_merge_spans(space,a_and_b,TRUE)<0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert hyperslabs")
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5S__generate_hyperslab() */
- /* Update the number of elements in current selection */
- space->select.num_elem = H5S__hyper_spans_nelem(a_and_b);
+
+/*-------------------------------------------------------------------------
+ * Function: H5S__set_regular_hyperslab
+ *
+ * Purpose: Set a regular hyperslab
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, October 2, 2014
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5S__set_regular_hyperslab(H5S_t *space, const hsize_t start[],
+ const hsize_t *app_stride, const hsize_t app_count[], const hsize_t *app_block,
+ const hsize_t *opt_stride, const hsize_t opt_count[], const hsize_t *opt_block)
+{
+ unsigned u; /* Local index variable */
+ herr_t ret_value = SUCCEED; /* Return value */
- /* Indicate that the a_and_b spans are owned */
- a_and_b=NULL;
+ FUNC_ENTER_STATIC
- /* Indicate that the spans were updated */
- updated_spans = TRUE;
- } /* end if */
- break;
+ /* Check args */
+ HDassert(space);
+ HDassert(start);
+ HDassert(app_stride);
+ HDassert(app_count);
+ HDassert(app_block);
+ HDassert(opt_stride);
+ HDassert(opt_count);
+ HDassert(opt_block);
+
+ /* If we are setting a new selection, remove current selection first */
+ if(H5S_SELECT_RELEASE(space) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release selection")
- case H5S_SELECT_XOR:
- /* Free the current selection */
- if(H5S__hyper_free_span_info(space->select.sel_info.hslab->span_lst)<0)
- HGOTO_ERROR(H5E_INTERNAL, H5E_CANTFREE, FAIL, "failed to release hyperslab spans")
- space->select.sel_info.hslab->span_lst=NULL;
+ /* Allocate space for the hyperslab selection information */
+ if(NULL == (space->select.sel_info.hslab = H5FL_MALLOC(H5S_hyper_sel_t)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab info")
- /* Reset the number of items in selection */
- space->select.num_elem=0;
+ /* Set the diminfo */
+ space->select.num_elem = 1;
+ space->select.sel_info.hslab->unlim_dim = -1;
+ for(u = 0; u < space->extent.rank; u++) {
+ /* Set application and optimized hyperslab info */
+ space->select.sel_info.hslab->diminfo.app[u].start = start[u];
+ space->select.sel_info.hslab->diminfo.app[u].stride = app_stride[u];
+ space->select.sel_info.hslab->diminfo.app[u].count = app_count[u];
+ space->select.sel_info.hslab->diminfo.app[u].block = app_block[u];
+
+ space->select.sel_info.hslab->diminfo.opt[u].start = start[u];
+ space->select.sel_info.hslab->diminfo.opt[u].stride = opt_stride[u];
+ space->select.sel_info.hslab->diminfo.opt[u].count = opt_count[u];
+ space->select.sel_info.hslab->diminfo.opt[u].block = opt_block[u];
+
+ /* Update # of elements selected */
+ space->select.num_elem *= (opt_count[u] * opt_block[u]);
+
+ /* Set low bound of bounding box for the hyperslab selection */
+ space->select.sel_info.hslab->diminfo.low_bounds[u] = start[u];
+
+ /* Check for unlimited dimension & set high bound */
+ if((app_count[u] == H5S_UNLIMITED) || (app_block[u] == H5S_UNLIMITED)) {
+ space->select.sel_info.hslab->unlim_dim = (int)u;
+ space->select.sel_info.hslab->diminfo.high_bounds[u] = H5S_UNLIMITED;
+ } /* end if */
+ else
+ space->select.sel_info.hslab->diminfo.high_bounds[u] = start[u] + opt_stride[u] * (opt_count[u] - 1) + (opt_block[u] - 1);
+ } /* end for */
- /* Check if there are any non-overlapped selections */
- if(a_not_b!=NULL) {
- if(H5S__hyper_merge_spans(space,a_not_b,FALSE)<0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert hyperslabs")
+ /* Handle unlimited selections */
+ if(space->select.sel_info.hslab->unlim_dim >= 0) {
+ /* Calculate num_elem_non_unlim */
+ space->select.sel_info.hslab->num_elem_non_unlim = (hsize_t)1;
+ for(u = 0; u < space->extent.rank; u++)
+ if((int)u != space->select.sel_info.hslab->unlim_dim)
+ space->select.sel_info.hslab->num_elem_non_unlim *= (opt_count[u] * opt_block[u]);
- /* Update the number of elements in current selection */
- space->select.num_elem = H5S__hyper_spans_nelem(a_not_b);
+ /* Update num_elem */
+ space->select.num_elem = H5S_UNLIMITED;
+ } /* end if */
- /* Indicate that the spans were updated */
- updated_spans = TRUE;
- } /* end if */
- if(b_not_a!=NULL) {
- if(H5S__hyper_merge_spans(space,b_not_a,FALSE)<0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert hyperslabs")
+ /* Indicate that the dimension information is valid */
+ space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_YES;
- /* Update the number of elements in current selection */
- space->select.num_elem += H5S__hyper_spans_nelem(b_not_a);
+ /* Indicate that there's no slab information */
+ space->select.sel_info.hslab->span_lst = NULL;
- /* Indicate that the spans were updated */
- updated_spans = TRUE;
- } /* end if */
- break;
+ /* Set selection type */
+ space->select.type = H5S_sel_hyper;
- case H5S_SELECT_NOTB:
- /* Free the current selection */
- if(H5S__hyper_free_span_info(space->select.sel_info.hslab->span_lst)<0)
- HGOTO_ERROR(H5E_INTERNAL, H5E_CANTFREE, FAIL, "failed to release hyperslab spans")
- space->select.sel_info.hslab->span_lst=NULL;
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5S__set_regular_hyperslab() */
- /* Reset the number of items in selection */
- space->select.num_elem=0;
+
+/*-------------------------------------------------------------------------
+ * Function: H5S__hyper_regular_and_single_block
+ *
+ * Purpose: Optimized routine to perform "AND" operation of a single
+ * block against a regular hyperslab selection.
+ *
+ * Note: This algorithm is invoked when constructing the chunk map
+ * and a regular hyperslab is selected in the file's dataspace.
+ *
+ * Return: Non-negative on success / Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * Saturday, February 9, 2019
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5S__hyper_regular_and_single_block(H5S_t *space, const hsize_t start[],
+ const hsize_t block[])
+{
+ hsize_t select_end, block_end; /* End of block & selection */
+ hbool_t single_block; /* Whether the selection is a single block */
+ hbool_t overlap; /* Whether block & selection overlap */
+ unsigned u; /* Local index variable */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* Check args */
+ HDassert(space);
+ HDassert(start);
+ HDassert(block);
- /* Check if there are any non-overlapped selections */
- if(a_not_b!=NULL) {
- if(H5S__hyper_merge_spans(space,a_not_b,TRUE)<0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert hyperslabs")
+ /* Check for single block selection in dataspace */
+ single_block = TRUE;
+ for(u = 0; u < space->extent.rank; u++)
+ if(1 != space->select.sel_info.hslab->diminfo.opt[u].count) {
+ single_block = FALSE;
+ break;
+ } /* end if */
- /* Update the number of elements in current selection */
- space->select.num_elem = H5S__hyper_spans_nelem(a_not_b);
+ /* Perform different optimizations, based on type of regular selection */
+ if(single_block) {
+ hsize_t new_start[H5S_MAX_RANK]; /* New starting coordinate */
+ hsize_t new_block[H5S_MAX_RANK]; /* New block size */
- /* Indicate that the a_not_b are owned */
- a_not_b=NULL;
+ /* Check for overlap and compute new start offset & block sizes */
+ overlap = TRUE;
+ for(u = 0; u < space->extent.rank; u++) {
+ /* Compute the end of the selection & block in this dimension */
+ select_end = space->select.sel_info.hslab->diminfo.high_bounds[u];
+ block_end = (start[u] + block[u]) - 1;
- /* Indicate that the spans were updated */
- updated_spans = TRUE;
- } /* end if */
+ /* Check for overlap */
+ if(!H5S_RANGE_OVERLAP(space->select.sel_info.hslab->diminfo.opt[u].start, select_end, start[u], block_end)) {
+ overlap = FALSE;
break;
+ } /* end if */
- case H5S_SELECT_NOTA:
- /* Free the current selection */
- if(H5S__hyper_free_span_info(space->select.sel_info.hslab->span_lst)<0)
- HGOTO_ERROR(H5E_INTERNAL, H5E_CANTFREE, FAIL, "failed to release hyperslab spans")
- space->select.sel_info.hslab->span_lst=NULL;
+ /* Set new start & block size in this dimension */
+ new_start[u] = MAX(space->select.sel_info.hslab->diminfo.opt[u].start, start[u]);
+ new_block[u] = (MIN(select_end, block_end) - new_start[u]) + 1;
+ } /* end for */
- /* Reset the number of items in selection */
- space->select.num_elem=0;
+ /* Check for overlap of selection & block */
+ if(overlap) {
+ /* Set selection to regular hyperslab */
+ if(H5S__set_regular_hyperslab(space, new_start, H5S_hyper_ones_g, H5S_hyper_ones_g, new_block,
+ H5S_hyper_ones_g, H5S_hyper_ones_g, new_block) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "can't set regular hyperslab selection")
+ } /* end if */
+ else
+ /* Selection & block don't overlap, set to "none" selection */
+ if(H5S_select_none(space) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't convert selection")
+ } /* end if */
+ else {
+ hsize_t new_start[H5S_MAX_RANK]; /* New start for hyperslab selection */
+ hsize_t new_count[H5S_MAX_RANK]; /* New count for hyperslab selection */
+ hsize_t stride[H5S_MAX_RANK]; /* Stride for hyperslab selection */
+ hsize_t new_block[H5S_MAX_RANK]; /* New block for hyperslab selection */
+ hbool_t partial_first_span; /* Whether first span in intersection is partial */
+ hbool_t partial_last_span; /* Whether last span in intersection is partial */
+
+ /* Iterate over selection, checking for overlap and computing first / last
+ * span that intersects with the block.
+ */
+ overlap = TRUE;
+ partial_first_span = FALSE;
+ partial_last_span = FALSE;
+ for(u = 0; u < space->extent.rank; u++) {
+ hsize_t first_span_start, first_span_end; /* Start / end of first span */
+ hsize_t last_span_start, last_span_end; /* Start / end of last span */
+ hsize_t nstride; /* Number of strides into the selection */
+
+ /* Compute the end of the selection & block in this dimension */
+ select_end = space->select.sel_info.hslab->diminfo.high_bounds[u];
+ block_end = (start[u] + block[u]) - 1;
+
+ /* Check for overlap */
+ if(!H5S_RANGE_OVERLAP(space->select.sel_info.hslab->diminfo.opt[u].start, select_end, start[u], block_end)) {
+ overlap = FALSE;
+ break;
+ } /* end if */
+
+ /* Find first span that is before or overlaps with start of block */
+ if(space->select.sel_info.hslab->diminfo.opt[u].start >= start[u]) {
+ /* Calculate start & end of first span */
+ first_span_start = space->select.sel_info.hslab->diminfo.opt[u].start;
+ first_span_end = (first_span_start +
+ space->select.sel_info.hslab->diminfo.opt[u].block) - 1;
+
+ /* Check if first span overlaps _end_ of block */
+ if(block_end >= first_span_start && block_end <= first_span_end)
+ partial_first_span = TRUE;
+ } /* end if */
+ else {
+ hsize_t adj_start; /* Start coord, adjusted for hyperslab selection parameters */
- /* Check if there are any non-overlapped selections */
- if(b_not_a!=NULL) {
- if(H5S__hyper_merge_spans(space,b_not_a,TRUE)<0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert hyperslabs")
+ /* Adjust start coord for selection's 'start' offset */
+ adj_start = start[u] - space->select.sel_info.hslab->diminfo.opt[u].start;
- /* Update the number of elements in current selection */
- space->select.num_elem = H5S__hyper_spans_nelem(b_not_a);
+ /* Compute # of strides into the selection */
+ if(space->select.sel_info.hslab->diminfo.opt[u].count > 1)
+ nstride = adj_start / space->select.sel_info.hslab->diminfo.opt[u].stride;
+ else
+ nstride = 0;
+
+ /* Calculate start & end of first span */
+ first_span_start = space->select.sel_info.hslab->diminfo.opt[u].start +
+ (nstride * space->select.sel_info.hslab->diminfo.opt[u].stride);
+ first_span_end = (first_span_start +
+ space->select.sel_info.hslab->diminfo.opt[u].block) - 1;
- /* Indicate that the b_not_a are owned */
- b_not_a=NULL;
+ /* Check if first span overlaps start of block */
+ if(first_span_start < start[u] && first_span_end >= start[u])
+ partial_first_span = TRUE;
- /* Indicate that the spans were updated */
- updated_spans = TRUE;
+ /* Advance first span to start higher than block's start,
+ * if it's not partial.
+ */
+ if(first_span_end < start[u]) {
+ first_span_start += space->select.sel_info.hslab->diminfo.opt[u].stride;
+ first_span_end += space->select.sel_info.hslab->diminfo.opt[u].stride;
} /* end if */
- break;
+ } /* end else */
- case H5S_SELECT_NOOP:
- case H5S_SELECT_SET:
- case H5S_SELECT_APPEND:
- case H5S_SELECT_PREPEND:
- case H5S_SELECT_INVALID:
- default:
- HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation")
- } /* end switch */
+ /* Find last span that is before or overlaps with end of block */
+ if(select_end < block_end) {
+ /* Calculate start & end of last span */
+ last_span_start = (select_end -
+ space->select.sel_info.hslab->diminfo.opt[u].block) + 1;
+ last_span_end = select_end;
+
+ /* Check if last span overlaps _start_ of block */
+ if(start[u] >= last_span_start && start[u] <= last_span_end)
+ partial_last_span = TRUE;
+ } /* end if */
+ else {
+ hsize_t adj_end; /* End coord, adjusted for hyperslab selection parameters */
+
+ /* Adjust end coord for selection's 'start' offset */
+ adj_end = block_end - space->select.sel_info.hslab->diminfo.opt[u].start;
+
+ /* Compute # of strides into the selection */
+ if(space->select.sel_info.hslab->diminfo.opt[u].count > 1)
+ nstride = adj_end / space->select.sel_info.hslab->diminfo.opt[u].stride;
+ else
+ nstride = 0;
- /* Check if the resulting hyperslab span tree is empty */
- if(space->select.sel_info.hslab->span_lst==NULL) {
- H5S_hyper_span_info_t *spans; /* Empty hyperslab span tree */
+ /* Calculate start & end of last span */
+ last_span_start = space->select.sel_info.hslab->diminfo.opt[u].start +
+ (nstride * space->select.sel_info.hslab->diminfo.opt[u].stride);
+ last_span_end = (last_span_start +
+ space->select.sel_info.hslab->diminfo.opt[u].block) - 1;
+
+ /* Check if last span overlaps end of block */
+ if(block_end >= last_span_start && block_end <= last_span_end)
+ partial_last_span = TRUE;
+ } /* end else */
+
+ /* Check if no spans are inside block */
+ /* (Can happen when block falls in "gap" between spans) */
+ if(last_span_end < start[u]) {
+ overlap = FALSE;
+ break;
+ } /* end if */
/* Sanity check */
- HDassert(space->select.num_elem == 0);
+ HDassert(first_span_start <= last_span_start);
- /* Allocate a span info node */
- if((spans = H5FL_MALLOC(H5S_hyper_span_info_t))==NULL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span")
+ /* Compute new start / count / block values */
+ new_start[u] = first_span_start;
+ if(last_span_start != first_span_start)
+ new_count[u] = ((last_span_start - first_span_start) /
+ space->select.sel_info.hslab->diminfo.opt[u].stride) + 1;
+ else
+ new_count[u] = 1;
+ new_block[u] = space->select.sel_info.hslab->diminfo.opt[u].block;
- /* Set the reference count */
- spans->count=1;
+ /* Keep same stride */
+ stride[u] = space->select.sel_info.hslab->diminfo.opt[u].stride;
+ } /* end for */
- /* Reset the scratch pad space */
- spans->scratch=0;
+ /* Check for overlap of selection & block */
+ if(overlap) {
+ /* Set selection to regular hyperslab */
+ if(H5S__set_regular_hyperslab(space, new_start, stride, new_count, new_block,
+ stride, new_count, new_block) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "can't set regular hyperslab selection")
- /* Set to empty tree */
- spans->head=NULL;
+ /* If there's a partial first or last span, have to 'AND' against selection */
+ if(partial_first_span || partial_last_span) {
+ /* Generate span tree for regular selection */
+ if(H5S__hyper_generate_spans(space) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "dataspace does not have span tree")
- /* Set pointer to empty span tree */
- space->select.sel_info.hslab->span_lst=spans;
+ /* 'AND' against block */
+ if(H5S__generate_hyperslab(space, H5S_SELECT_AND, start, H5S_hyper_ones_g, H5S_hyper_ones_g, block) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't generate hyperslabs")
+ } /* end if */
} /* end if */
else {
- /* Check if we updated the spans */
- if(updated_spans) {
- /* Attempt to rebuild "optimized" start/stride/count/block information.
- * from resulting hyperslab span tree
- */
- H5S__hyper_rebuild(space);
- } /* end if */
+ /* Selection & block don't overlap, set to "none" selection */
+ if(H5S_select_none(space) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't convert selection")
} /* end else */
} /* end else */
done:
- /* Free resources */
- if(a_not_b)
- if(H5S__hyper_free_span_info(a_not_b) < 0)
- HDONE_ERROR(H5E_INTERNAL, H5E_CANTFREE, FAIL, "failed to release temporary hyperslab spans")
- if(a_and_b)
- if(H5S__hyper_free_span_info(a_and_b) < 0)
- HDONE_ERROR(H5E_INTERNAL, H5E_CANTFREE, FAIL, "failed to release temporary hyperslab spans")
- if(b_not_a)
- if(H5S__hyper_free_span_info(b_not_a) < 0)
- HDONE_ERROR(H5E_INTERNAL, H5E_CANTFREE, FAIL, "failed to release temporary hyperslab spans")
- if(new_spans)
- if(H5S__hyper_free_span_info(new_spans) < 0)
- HDONE_ERROR(H5E_INTERNAL, H5E_CANTFREE, FAIL, "failed to release temporary hyperslab spans")
-
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5S__generate_hyperslab() */
+} /* end H5S__hyper_regular_and_single_block() */
/*-------------------------------------------------------------------------
@@ -6500,9 +9808,9 @@ herr_t
H5S_select_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[],
const hsize_t *stride, const hsize_t count[], const hsize_t *block)
{
- hsize_t int_stride[H5O_LAYOUT_NDIMS]; /* Internal storage for stride information */
- hsize_t int_count[H5O_LAYOUT_NDIMS]; /* Internal storage for count information */
- hsize_t int_block[H5O_LAYOUT_NDIMS]; /* Internal storage for block information */
+ hsize_t int_stride[H5S_MAX_RANK]; /* Internal storage for stride information */
+ hsize_t int_count[H5S_MAX_RANK]; /* Internal storage for count information */
+ hsize_t int_block[H5S_MAX_RANK]; /* Internal storage for block information */
const hsize_t *opt_stride; /* Optimized stride information */
const hsize_t *opt_count; /* Optimized count information */
const hsize_t *opt_block; /* Optimized block information */
@@ -6526,9 +9834,7 @@ H5S_select_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[],
if(block == NULL)
block = H5S_hyper_ones_g;
- /*
- * Check new selection.
- */
+ /* Check new selection */
for(u = 0; u < space->extent.rank; u++) {
/* Check for overlapping hyperslab blocks in new selection. */
if(count[u] > 1 && stride[u] < block[u])
@@ -6564,7 +9870,7 @@ H5S_select_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[],
if(unlim_dim >= 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "cannot have more than one unlimited dimension in selection")
else {
- if(count[u] == block[u] /* == H5S_UNLIMITED */)
+ if(count[u] == block[u]) /* Both are H5S_UNLIMITED */
HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "count and block cannot both be unlimited")
unlim_dim = (int)u;
} /* end else */
@@ -6714,6 +10020,7 @@ H5S_select_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[],
if(op == H5S_SELECT_SET) /* Allow only "set" operation to proceed */
break;
/* Else fall through to error */
+ H5_ATTR_FALLTHROUGH
case H5S_SEL_ERROR:
case H5S_SEL_N:
@@ -6722,56 +10029,13 @@ H5S_select_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[],
} /* end switch */
if(op == H5S_SELECT_SET) {
- /* If we are setting a new selection, remove current selection first */
- if(H5S_SELECT_RELEASE(space) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release selection")
-
- /* Allocate space for the hyperslab selection information */
- if(NULL == (space->select.sel_info.hslab = H5FL_MALLOC(H5S_hyper_sel_t)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab info")
-
- /* Save the diminfo */
- space->select.num_elem = 1;
- for(u = 0; u < space->extent.rank; u++) {
- space->select.sel_info.hslab->app_diminfo[u].start = start[u];
- space->select.sel_info.hslab->app_diminfo[u].stride = stride[u];
- space->select.sel_info.hslab->app_diminfo[u].count = count[u];
- space->select.sel_info.hslab->app_diminfo[u].block = block[u];
-
- space->select.sel_info.hslab->opt_diminfo[u].start = start[u];
- space->select.sel_info.hslab->opt_diminfo[u].stride = opt_stride[u];
- space->select.sel_info.hslab->opt_diminfo[u].count = opt_count[u];
- space->select.sel_info.hslab->opt_diminfo[u].block = opt_block[u];
-
- space->select.num_elem *= (opt_count[u] * opt_block[u]);
- } /* end for */
-
- /* Save unlim_dim */
- space->select.sel_info.hslab->unlim_dim = unlim_dim;
-
- /* Indicate that the dimension information is valid */
- space->select.sel_info.hslab->diminfo_valid = TRUE;
-
- /* Indicate that there's no slab information */
- space->select.sel_info.hslab->span_lst = NULL;
-
- /* Handle unlimited selections */
- if(unlim_dim >= 0) {
- /* Calculate num_elem_non_unlim */
- space->select.sel_info.hslab->num_elem_non_unlim = (hsize_t)1;
- for(u = 0; u < space->extent.rank; u++)
- if((int)u != unlim_dim)
- space->select.sel_info.hslab->num_elem_non_unlim *= (opt_count[u] * opt_block[u]);
-
- /* Set num_elem */
- if(space->select.num_elem != (hsize_t)0)
- space->select.num_elem = H5S_UNLIMITED;
- } /* end if */
-
- /* Set selection type */
- space->select.type = H5S_sel_hyper;
+ /* Set selection to regular hyperslab */
+ if(H5S__set_regular_hyperslab(space, start, stride, count, block, opt_stride, opt_count, opt_block) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "can't set regular hyperslab selection")
} /* end if */
else if(op >= H5S_SELECT_OR && op <= H5S_SELECT_NOTA) {
+ hbool_t single_block; /* Whether the selection is a single block */
+
/* Sanity check */
HDassert(H5S_GET_SELECT_TYPE(space) == H5S_SEL_HYPERSLABS);
@@ -6793,7 +10057,8 @@ H5S_select_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[],
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get selection bounds")
/* Patch count and block to remove unlimited and include the
- * existing selection */
+ * existing selection.
+ */
H5S__hyper_get_clip_diminfo(start[unlim_dim], opt_stride[unlim_dim], &tmp_count, &tmp_block, bounds_end[unlim_dim] + (hsize_t)1);
HDassert((tmp_count == 1) || (opt_count != H5S_hyper_ones_g));
HDassert((tmp_block == 1) || (opt_block != H5S_hyper_ones_g));
@@ -6807,21 +10072,35 @@ H5S_select_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[],
} /* end if */
} /* end if */
- /* Check if there's no hyperslab span information currently */
- if(NULL == space->select.sel_info.hslab->span_lst)
- if(H5S__hyper_generate_spans(space) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "dataspace does not have span tree")
+ /* Check for a single block selected */
+ single_block = TRUE;
+ for(u = 0; u < space->extent.rank; u++)
+ if(1 != opt_count[u]) {
+ single_block = FALSE;
+ break;
+ } /* end if */
- /* Indicate that the regular dimensions are no longer valid */
- space->select.sel_info.hslab->diminfo_valid = FALSE;
+ /* Check for single block "AND" operation on a regular hyperslab, which
+ * is used for constructing chunk maps and can be optimized for.
+ */
+ if(H5S_SELECT_AND == op && single_block &&
+ space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) {
+ if(H5S__hyper_regular_and_single_block(space, start, opt_block) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTOPERATE, FAIL, "can't 'AND' single block against regular hyperslab")
+ } /* end if */
+ else {
+ /* Check if there's no hyperslab span information currently */
+ if(NULL == space->select.sel_info.hslab->span_lst)
+ if(H5S__hyper_generate_spans(space) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "dataspace does not have span tree")
- /* Set selection type */
- /* (Could be overridden by resetting selection to 'none', below) */
- space->select.type = H5S_sel_hyper;
+ /* Set selection type */
+ space->select.type = H5S_sel_hyper;
- /* Add in the new hyperslab information */
- if(H5S__generate_hyperslab(space, op, start, opt_stride, opt_count, opt_block) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't generate hyperslabs")
+ /* Add in the new hyperslab information */
+ if(H5S__generate_hyperslab(space, op, start, opt_stride, opt_count, opt_block) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't generate hyperslabs")
+ } /* end else */
} /* end if */
else
HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation")
@@ -6893,690 +10172,265 @@ H5Sselect_hyperslab(hid_t space_id, H5S_seloper_t op, const hsize_t start[],
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Sselect_hyperslab() */
-#else /* NEW_HYPERSLAB_API */ /* Works */
-
-/*-------------------------------------------------------------------------
- * Function: H5S_operate_hyperslab
- *
- * Purpose: Combines two hyperslabs with an operation, putting the
- * result into a third hyperslab selection
- *
- * Return: non-negative on success/NULL on failure
- *
- * Programmer: Quincey Koziol
- * Tuesday, October 30, 2001
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5S_operate_hyperslab (H5S_t *result, H5S_hyper_span_info_t *spans1, H5S_seloper_t op, H5S_hyper_span_info_t *spans2,
- hbool_t can_own_span2, hbool_t *span2_owned)
-{
- H5S_hyper_span_info_t *a_not_b=NULL; /* Span tree for hyperslab spans in old span tree and not in new span tree */
- H5S_hyper_span_info_t *a_and_b=NULL; /* Span tree for hyperslab spans in both old and new span trees */
- H5S_hyper_span_info_t *b_not_a=NULL; /* Span tree for hyperslab spans in new span tree and not in old span tree */
- herr_t ret_value=SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI_NOINIT
-
- /* Check args */
- HDassert(result);
- HDassert(spans2);
- HDassert(op > H5S_SELECT_NOOP && op < H5S_SELECT_INVALID);
-
- /* Just copy the selection from spans2 if we are setting the selection */
- /* ('space1' to 'result' aliasing happens at the next layer up) */
- if(op==H5S_SELECT_SET) {
- if(H5S__hyper_merge_spans(result,spans2,can_own_span2)<0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert hyperslabs")
-
- /* Update the number of elements in current selection */
- result->select.num_elem = H5S__hyper_spans_nelem(spans2);
-
- /* Indicate that we took ownership of span2, if allowed */
- if(can_own_span2)
- *span2_owned=TRUE;
- } /* end if */
- else {
- hbool_t updated_spans = FALSE; /* Whether the spans in the selection were modified */
-
- HDassert(spans1);
-
- /* Generate lists of spans which overlap and don't overlap */
- if(H5S__hyper_clip_spans(spans1,spans2,&a_not_b,&a_and_b,&b_not_a)<0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't clip hyperslab information")
-
- /* Switch on the operation */
- switch(op) {
- case H5S_SELECT_OR:
- /* Copy spans from spans1 to current selection */
- if(spans1!=NULL) {
- if(H5S__hyper_merge_spans(result,spans1,FALSE)<0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert hyperslabs")
-
- /* Update the number of elements in current selection */
- result->select.num_elem = H5S__hyper_spans_nelem(spans1);
- } /* end if */
-
- /* Add any new spans from spans2 to current selection */
- if(b_not_a!=NULL) {
- if(H5S__hyper_merge_spans(result,b_not_a,FALSE)<0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert hyperslabs")
-
- /* Update the number of elements in current selection */
- result->select.num_elem += H5S__hyper_spans_nelem(b_not_a);
-
- /* Indicate that the spans were updated */
- updated_spans = TRUE;
- } /* end if */
- break;
-
- case H5S_SELECT_AND:
- /* Check if there are any overlapped selections */
- if(a_and_b!=NULL) {
- if(H5S__hyper_merge_spans(result,a_and_b,TRUE)<0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert hyperslabs")
-
- /* Update the number of elements in current selection */
- result->select.num_elem = H5S__hyper_spans_nelem(a_and_b);
-
- /* Indicate that the result owns the a_and_b spans */
- a_and_b=NULL;
-
- /* Indicate that the spans were updated */
- updated_spans = TRUE;
- } /* end if */
- break;
-
- case H5S_SELECT_XOR:
- /* Check if there are any non-overlapped selections */
- if(a_not_b!=NULL) {
- if(H5S__hyper_merge_spans(result,a_not_b,FALSE)<0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert hyperslabs")
-
- /* Update the number of elements in current selection */
- result->select.num_elem = H5S__hyper_spans_nelem(a_not_b);
-
- /* Indicate that the spans were updated */
- updated_spans = TRUE;
- } /* end if */
- if(b_not_a!=NULL) {
- if(H5S__hyper_merge_spans(result,b_not_a,FALSE)<0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert hyperslabs")
-
- /* Update the number of elements in current selection */
- result->select.num_elem += H5S__hyper_spans_nelem(b_not_a);
-
- /* Indicate that the spans were updated */
- updated_spans = TRUE;
- } /* end if */
- break;
-
- case H5S_SELECT_NOTB:
- /* Check if there are any non-overlapped selections */
- if(a_not_b!=NULL) {
- if(H5S__hyper_merge_spans(result,a_not_b,TRUE)<0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert hyperslabs")
-
- /* Update the number of elements in current selection */
- result->select.num_elem = H5S__hyper_spans_nelem(a_not_b);
-
- /* Indicate that the result owns the a_not_b spans */
- a_not_b=NULL;
-
- /* Indicate that the spans were updated */
- updated_spans = TRUE;
- } /* end if */
- break;
-
- case H5S_SELECT_NOTA:
- /* Check if there are any non-overlapped selections */
- if(b_not_a!=NULL) {
- if(H5S__hyper_merge_spans(result,b_not_a,TRUE)<0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert hyperslabs")
-
- /* Update the number of elements in current selection */
- result->select.num_elem = H5S__hyper_spans_nelem(b_not_a);
-
- /* Indicate that the result owns the b_not_a spans */
- b_not_a=NULL;
-
- /* Indicate that the spans were updated */
- updated_spans = TRUE;
- } /* end if */
- break;
-
- default:
- HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation")
- } /* end switch */
-
- /* Free the hyperslab trees generated from the clipping algorithm */
- if(a_not_b)
- H5S__hyper_free_span_info(a_not_b);
- if(a_and_b)
- H5S__hyper_free_span_info(a_and_b);
- if(b_not_a)
- H5S__hyper_free_span_info(b_not_a);
-
- /* Check if the resulting hyperslab span tree is empty */
- if(result->select.sel_info.hslab->span_lst==NULL) {
- H5S_hyper_span_info_t *spans; /* Empty hyperslab span tree */
-
- /* Sanity check */
- HDassert(result->select.num_elem == 0);
-
- /* Allocate a span info node */
- if((spans = H5FL_MALLOC(H5S_hyper_span_info_t))==NULL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate hyperslab span")
-
- /* Set the reference count */
- spans->count=1;
-
- /* Reset the scratch pad space */
- spans->scratch=0;
-
- /* Set to empty tree */
- spans->head=NULL;
-
- /* Set pointer to empty span tree */
- result->select.sel_info.hslab->span_lst=spans;
- } /* end if */
- else {
- /* Check if we updated the spans */
- if(updated_spans) {
- /* Attempt to rebuild "optimized" start/stride/count/block information.
- * from resulting hyperslab span tree
- */
- H5S__hyper_rebuild(result);
- } /* end if */
- } /* end else */
- } /* end else */
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5S_operate_hyperslab() */
-/*-------------------------------------------------------------------------
- * Function: H5S_generate_hyperlab
- *
- * Purpose: Generate hyperslab information from H5S_select_hyperslab()
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Quincey Koziol (split from HS_select_hyperslab()).
- * Tuesday, September 12, 2000
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5S__generate_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[],
- const hsize_t stride[], const hsize_t count[], const hsize_t block[])
-{
- H5S_hyper_span_info_t *new_spans=NULL; /* Span tree for new hyperslab */
- H5S_hyper_span_info_t *tmp_spans=NULL; /* Temporary copy of selection */
- hbool_t span2_owned=FALSE; /* Flag to indicate that span2 was used in H5S_operate_hyperslab() */
- herr_t ret_value=SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI_NOINIT
-
- /* Check args */
- HDassert(space);
- HDassert(op > H5S_SELECT_NOOP && op < H5S_SELECT_INVALID);
- HDassert(start);
- HDassert(stride);
- HDassert(count);
- HDassert(block);
-
- /* Generate span tree for new hyperslab information */
- if(NULL == (new_spans = H5S__hyper_make_spans(space->extent.rank, start, stride, count, block)))
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't create hyperslab information")
-
- /* Copy the original dataspace */
- if(space->select.sel_info.hslab->span_lst!=NULL) {
- /* Take ownership of the dataspace's hyperslab spans */
- /* (These are freed later) */
- tmp_spans=space->select.sel_info.hslab->span_lst;
- space->select.sel_info.hslab->span_lst=NULL;
-
- /* Reset the other dataspace selection information */
- if(H5S_SELECT_RELEASE(space)<0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release selection")
-
- /* Allocate space for the hyperslab selection information */
- if((space->select.sel_info.hslab=H5FL_MALLOC(H5S_hyper_sel_t))==NULL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab info")
-
- /* Set unlim_dim */
- space->select.sel_info.hslab->unlim_dim = -1;
- } /* end if */
-
- /* Combine tmp_space (really space) & new_space, with the result in space */
- if(H5S_operate_hyperslab(space,tmp_spans,op,new_spans,TRUE,&span2_owned)<0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't clip hyperslab information")
-
-done:
- /* Free temporary data structures */
- if(tmp_spans!=NULL)
- if(H5S__hyper_free_span_info(tmp_spans)<0)
- HDONE_ERROR(H5E_INTERNAL, H5E_CANTFREE, FAIL, "failed to release temporary hyperslab spans")
- if(new_spans!=NULL && span2_owned==FALSE)
- if(H5S__hyper_free_span_info(new_spans)<0)
- HDONE_ERROR(H5E_INTERNAL, H5E_CANTFREE, FAIL, "failed to release temporary hyperslab spans")
-
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5S__generate_hyperslab() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5S_select_hyperslab
- *
- * Purpose: Internal version of H5Sselect_hyperslab().
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Quincey Koziol
- * Wednesday, January 10, 2001
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
+/*--------------------------------------------------------------------------
+ NAME
+ H5S_combine_hyperslab
+ PURPOSE
+ Specify a hyperslab to combine with the current hyperslab selection, and
+ store the result in the new hyperslab selection.
+ USAGE
+ herr_t H5S_combine_hyperslab(new_space, old_space, op, start, stride, count, block)
+ H5S_t *old_space; IN: The old space the selection is performed on
+ H5S_seloper_t op; IN: Operation to perform on current selection
+ const hsize_t start[]; IN: Offset of start of hyperslab
+ const hsize_t *stride; IN: Hyperslab stride
+ const hsize_t count[]; IN: Number of blocks included in hyperslab
+ const hsize_t *block; IN: Size of block in hyperslab
+ H5S_t **new_space; OUT: The new dataspace to store the selection result
+ RETURNS
+ Non-negative on success/Negative on failure
+ DESCRIPTION
+ Combines a hyperslab selection with the current selection for a dataspace.
+ If STRIDE or BLOCK is NULL, they are assumed to be set to all '1'.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ In some cases, copying the whole span tree from old_space to new_space
+ can be avoided. Deal with such cases directly, otherwise this function
+ is equivalent to:
+ 1. Copy the whole span tree from old_space into new_space
+ 2. Call H5S_select_hyperslab with the new_space.
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
herr_t
-H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op,
- const hsize_t start[],
- const hsize_t *stride,
- const hsize_t count[],
- const hsize_t *block)
+H5S_combine_hyperslab(H5S_t *old_space, H5S_seloper_t op, const hsize_t start[],
+ const hsize_t *stride, const hsize_t count[], const hsize_t *block,
+ H5S_t **new_space)
{
- hsize_t int_stride[H5O_LAYOUT_NDIMS]; /* Internal storage for stride information */
- hsize_t int_count[H5O_LAYOUT_NDIMS]; /* Internal storage for count information */
- hsize_t int_block[H5O_LAYOUT_NDIMS]; /* Internal storage for block information */
- const hsize_t *opt_stride; /* Optimized stride information */
- const hsize_t *opt_count; /* Optimized count information */
- const hsize_t *opt_block; /* Optimized block information */
- unsigned u; /* Counters */
- int unlim_dim = -1; /* Unlimited dimension in selection, of -1 if none */
- herr_t ret_value=SUCCEED; /* Return value */
+ unsigned u; /* Local index variable */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
/* Check args */
- HDassert(space);
+ HDassert(old_space);
HDassert(start);
HDassert(count);
- HDassert(op > H5S_SELECT_NOOP && op < H5S_SELECT_INVALID);
+ HDassert(op >= H5S_SELECT_SET && op <= H5S_SELECT_NOTA);
+ HDassert(new_space);
+ HDassert(*new_space == NULL);
/* Point to the correct stride values */
- if(stride==NULL)
+ if(stride == NULL)
stride = H5S_hyper_ones_g;
/* Point to the correct block values */
- if(block==NULL)
+ if(block == NULL)
block = H5S_hyper_ones_g;
- /* Check for unlimited dimension */
- for(u = 0; u<space->extent.rank; u++)
- if((count[u] == H5S_UNLIMITED) || (block[u] == H5S_UNLIMITED)) {
- if(unlim_dim >= 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "cannot have more than one unlimited dimension in selection")
- else {
- if(count[u] == block[u] /* == H5S_UNLIMITED */)
- HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "count and block cannot both be unlimited")
- unlim_dim = (int)u;
- } /* end else */
- } /* end if */
-
- /*
- * Check new selection.
- */
- for(u=0; u<space->extent.rank; u++) {
+ /* Check new selection. */
+ for(u = 0; u < old_space->extent.rank; u++) {
/* Check for overlapping hyperslab blocks in new selection. */
- if(count[u]>1 && stride[u]<block[u])
+ if(count[u] > 1 && stride[u] < block[u])
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hyperslab blocks overlap")
/* Detect zero-sized hyperslabs in new selection */
if(count[u] == 0 || block[u] == 0) {
switch(op) {
- case H5S_SELECT_SET: /* Select "set" operation */
case H5S_SELECT_AND: /* Binary "and" operation for hyperslabs */
case H5S_SELECT_NOTA: /* Binary "B not A" operation for hyperslabs */
/* Convert to "none" selection */
- if(H5S_select_none(space)<0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't convert selection")
+ /* Copy the first dataspace without sharing the list of spans */
+ if(NULL == ((*new_space) = H5S_copy(old_space, TRUE, TRUE)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to copy dataspace")
+ if(H5S_select_none((*new_space)) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't convert selection")
HGOTO_DONE(SUCCEED);
case H5S_SELECT_OR: /* Binary "or" operation for hyperslabs */
case H5S_SELECT_XOR: /* Binary "xor" operation for hyperslabs */
case H5S_SELECT_NOTB: /* Binary "A not B" operation for hyperslabs */
+ /* Copy the first dataspace with sharing the list of spans */
+ if(NULL == ((*new_space) = H5S_copy(old_space, FALSE, TRUE)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to copy dataspace")
HGOTO_DONE(SUCCEED); /* Selection stays same */
+ case H5S_SELECT_NOOP:
+ case H5S_SELECT_SET:
+ case H5S_SELECT_APPEND:
+ case H5S_SELECT_PREPEND:
+ case H5S_SELECT_INVALID:
default:
HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation")
} /* end switch */
} /* end if */
} /* end for */
- /* Optimize hyperslab parameters to merge contiguous blocks, etc. */
- if(stride == H5S_hyper_ones_g && block == H5S_hyper_ones_g) {
- /* Point to existing arrays */
- opt_stride = H5S_hyper_ones_g;
- opt_count = H5S_hyper_ones_g;
- opt_block = count;
- } /* end if */
- else {
- /* Point to local arrays */
- opt_stride = int_stride;
- opt_count = int_count;
- opt_block = int_block;
- for(u=0; u<space->extent.rank; u++) {
- /* contiguous hyperslabs have the block size equal to the stride */
- if((stride[u] == block[u]) && (count[u] != H5S_UNLIMITED)) {
- int_count[u]=1;
- int_stride[u]=1;
- if(block[u]==1)
- int_block[u]=count[u];
- else
- int_block[u]=block[u]*count[u];
- } /* end if */
- else {
- if(count[u]==1)
- int_stride[u]=1;
- else {
- HDassert((stride[u] > block[u]) || ((stride[u] == block[u])
- && (count[u] == H5S_UNLIMITED)));
- int_stride[u]=stride[u];
- } /* end else */
- int_count[u]=count[u];
- int_block[u]=block[u];
- } /* end else */
- } /* end for */
- } /* end else */
-
- /* Check for operating on unlimited selection */
- if((H5S_GET_SELECT_TYPE(space) == H5S_SEL_HYPERSLABS)
- && (space->select.sel_info.hslab->unlim_dim >= 0)
- && (op != H5S_SELECT_SET))
- {
- /* Check for invalid operation */
- if(unlim_dim >= 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "cannot modify unlimited selection with another unlimited selection")
- if(!((op == H5S_SELECT_AND) || (op == H5S_SELECT_NOTA)))
- HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unsupported operation on unlimited selection")
- HDassert(space->select.sel_info.hslab->diminfo_valid);
+ if(H5S_GET_SELECT_TYPE(old_space) == H5S_SEL_HYPERSLABS) {
+ hsize_t *old_low_bounds; /* Pointer to old space's low & high bounds */
+ hsize_t *old_high_bounds;
+ hsize_t new_low_bounds[H5S_MAX_RANK]; /* New space's low & high bounds */
+ hsize_t new_high_bounds[H5S_MAX_RANK];
+ hbool_t overlapped = FALSE;
+
+ /* Set up old space's low & high bounds */
+ if(old_space->select.sel_info.hslab->span_lst) {
+ old_low_bounds = old_space->select.sel_info.hslab->span_lst->low_bounds;
+ old_high_bounds = old_space->select.sel_info.hslab->span_lst->high_bounds;
+ } /* end if */
+ else {
+ old_low_bounds = old_space->select.sel_info.hslab->diminfo.low_bounds;
+ old_high_bounds = old_space->select.sel_info.hslab->diminfo.high_bounds;
+ } /* end else */
- /* Clip unlimited selection to include new selection */
- if(H5S_hyper_clip_unlim(space,
- start[space->select.sel_info.hslab->unlim_dim]
- + ((opt_count[space->select.sel_info.hslab->unlim_dim]
- - (hsize_t)1)
- * opt_stride[space->select.sel_info.hslab->unlim_dim])
- + opt_block[space->select.sel_info.hslab->unlim_dim]) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "failed to clip unlimited selection")
+ /* Generate bounding box for hyperslab parameters */
+ for(u = 0; u < old_space->extent.rank; u++) {
+ new_low_bounds[u] = start[u];
+ new_high_bounds[u] = start[u] + stride[u] * (count[u] - 1) + (block[u] - 1);
+ } /* end for */
- /* If an empty space was returned it must be "none" */
- HDassert((space->select.num_elem > (hsize_t)0)
- || (space->select.type->type == H5S_SEL_NONE));
- } /* end if */
+ /* Check bound box of both spaces to see if they overlap */
+ if(H5S_RANGE_OVERLAP(old_low_bounds[0], old_high_bounds[0],
+ new_low_bounds[0], new_high_bounds[0]))
+ overlapped = TRUE;
+
+ /* Non-overlapping situations can be handled in special ways */
+ if(!overlapped) {
+ H5S_hyper_span_info_t *new_spans = NULL;
+ H5S_hyper_dim_t new_hyper_diminfo[H5S_MAX_RANK];
+
+ if(NULL == ((*new_space) = H5S_copy(old_space, TRUE, TRUE)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy dataspace")
+ if(NULL != (*new_space)->select.sel_info.hslab->span_lst) {
+ old_space->select.sel_info.hslab->span_lst->count--;
+ (*new_space)->select.sel_info.hslab->span_lst = NULL;
+ } /* end if */
- /* Fixup operation for non-hyperslab selections */
- switch(H5S_GET_SELECT_TYPE(space)) {
- case H5S_SEL_NONE: /* No elements selected in dataspace */
+ /* Generate hyperslab info for new space */
switch(op) {
- case H5S_SELECT_SET: /* Select "set" operation */
- /* Change "none" selection to hyperslab selection */
- break;
+ case H5S_SELECT_OR:
+ case H5S_SELECT_XOR:
+ /* Add the new space to the space */
+ if(NULL == (new_spans = H5S__hyper_make_spans(old_space->extent.rank, start, stride, count, block)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't create hyperslab information")
+ if(NULL != old_space->select.sel_info.hslab->span_lst)
+ (*new_space)->select.sel_info.hslab->span_lst = H5S__hyper_copy_span(old_space->select.sel_info.hslab->span_lst, old_space->extent.rank);
+ if(H5S__hyper_add_disjoint_spans(*new_space, new_spans) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't append hyperslabs")
+
+ /* Build diminfo struct */
+ for(u = 0; u < (*new_space)->extent.rank; u++) {
+ new_hyper_diminfo[u].start = start[u];
+ new_hyper_diminfo[u].stride = stride[u];
+ new_hyper_diminfo[u].count = count[u];
+ new_hyper_diminfo[u].block = block[u];
+ } /* end for */
- case H5S_SELECT_OR: /* Binary "or" operation for hyperslabs */
- case H5S_SELECT_XOR: /* Binary "xor" operation for hyperslabs */
- case H5S_SELECT_NOTA: /* Binary "B not A" operation for hyperslabs */
- op=H5S_SELECT_SET; /* Maps to "set" operation when applied to "none" selection */
+ /* Update space's dim info */
+ if(H5S__hyper_update_diminfo(*new_space, op, new_hyper_diminfo) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOUNT, FAIL, "can't update hyperslab info")
break;
- case H5S_SELECT_AND: /* Binary "and" operation for hyperslabs */
- case H5S_SELECT_NOTB: /* Binary "A not B" operation for hyperslabs */
- HGOTO_DONE(SUCCEED); /* Selection stays "none" */
-
- default:
- HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation")
- } /* end switch */
- break;
-
- case H5S_SEL_ALL: /* All elements selected in dataspace */
- switch(op) {
- case H5S_SELECT_SET: /* Select "set" operation */
- /* Change "all" selection to hyperslab selection */
+ case H5S_SELECT_AND:
+ if(H5S_select_none((*new_space)) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't convert selection")
break;
- case H5S_SELECT_OR: /* Binary "or" operation for hyperslabs */
- HGOTO_DONE(SUCCEED); /* Selection stays "all" */
-
- case H5S_SELECT_AND: /* Binary "and" operation for hyperslabs */
- op=H5S_SELECT_SET; /* Maps to "set" operation when applied to "none" selection */
+ case H5S_SELECT_NOTB:
+ if(NULL != old_space->select.sel_info.hslab->span_lst) {
+ if(NULL == ((*new_space)->select.sel_info.hslab->span_lst = H5S__hyper_copy_span(old_space->select.sel_info.hslab->span_lst, old_space->extent.rank)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy dataspace")
+ } /* end if */
+ else {
+ if(H5S_select_none((*new_space)) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't convert selection")
+ } /* end else */
break;
- case H5S_SELECT_XOR: /* Binary "xor" operation for hyperslabs */
- case H5S_SELECT_NOTB: /* Binary "A not B" operation for hyperslabs */
- /* Convert current "all" selection to "real" hyperslab selection */
- /* Then allow operation to proceed */
- {
- hsize_t tmp_start[H5O_LAYOUT_NDIMS]; /* Temporary start information */
- hsize_t tmp_stride[H5O_LAYOUT_NDIMS]; /* Temporary stride information */
- hsize_t tmp_count[H5O_LAYOUT_NDIMS]; /* Temporary count information */
- hsize_t tmp_block[H5O_LAYOUT_NDIMS]; /* Temporary block information */
-
- /* Fill in temporary information for the dimensions */
- for(u=0; u<space->extent.rank; u++) {
- tmp_start[u]=0;
- tmp_stride[u]=1;
- tmp_count[u]=1;
- tmp_block[u]=space->extent.size[u];
- } /* end for */
-
- /* Convert to hyperslab selection */
- if(H5S_select_hyperslab(space,H5S_SELECT_SET,tmp_start,tmp_stride,tmp_count,tmp_block)<0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't convert selection")
- } /* end case */
+ case H5S_SELECT_NOTA:
+ if(H5S__set_regular_hyperslab(*new_space, start, stride, count, block, stride, count, block) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "can't set regular selection")
break;
- case H5S_SELECT_NOTA: /* Binary "B not A" operation for hyperslabs */
- /* Convert to "none" selection */
- if(H5S_select_none(space)<0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't convert selection")
- HGOTO_DONE(SUCCEED);
-
+ case H5S_SELECT_NOOP:
+ case H5S_SELECT_SET:
+ case H5S_SELECT_APPEND:
+ case H5S_SELECT_PREPEND:
+ case H5S_SELECT_INVALID:
default:
HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation")
} /* end switch */
- break;
-
- case H5S_SEL_HYPERSLABS:
- /* Hyperslab operation on hyperslab selection, OK */
- break;
-
- case H5S_SEL_POINTS: /* Can't combine hyperslab operations and point selections currently */
- if(op==H5S_SELECT_SET) /* Allow only "set" operation to proceed */
- break;
- /* Else fall through to error */
-
- default:
- HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation")
- } /* end switch */
-
-
- if(op==H5S_SELECT_SET) {
- /* If we are setting a new selection, remove current selection first */
- if(H5S_SELECT_RELEASE(space)<0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release hyperslab")
-
- /* Allocate space for the hyperslab selection information */
- if(NULL == (space->select.sel_info.hslab = H5FL_MALLOC(H5S_hyper_sel_t)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab info")
-
- /* Save the diminfo */
- space->select.num_elem=1;
- for(u=0; u<space->extent.rank; u++) {
- space->select.sel_info.hslab->app_diminfo[u].start = start[u];
- space->select.sel_info.hslab->app_diminfo[u].stride = stride[u];
- space->select.sel_info.hslab->app_diminfo[u].count = count[u];
- space->select.sel_info.hslab->app_diminfo[u].block = block[u];
-
- space->select.sel_info.hslab->opt_diminfo[u].start = start[u];
- space->select.sel_info.hslab->opt_diminfo[u].stride = opt_stride[u];
- space->select.sel_info.hslab->opt_diminfo[u].count = opt_count[u];
- space->select.sel_info.hslab->opt_diminfo[u].block = opt_block[u];
-
- space->select.num_elem*=(opt_count[u]*opt_block[u]);
- } /* end for */
-
- /* Save unlim_dim */
- space->select.sel_info.hslab->unlim_dim = unlim_dim;
-
- /* Indicate that the dimension information is valid */
- space->select.sel_info.hslab->diminfo_valid = TRUE;
-
- /* Indicate that there's no slab information */
- space->select.sel_info.hslab->span_lst = NULL;
- /* Handle unlimited selections */
- if(unlim_dim >= 0) {
- /* Calculate num_elem_non_unlim */
- space->select.sel_info.hslab->num_elem_non_unlim = (hsize_t)1;
- for(u = 0; u < space->extent.rank; u++)
- if((int)u != unlim_dim)
- space->select.sel_info.hslab->num_elem_non_unlim *= (opt_count[u] * opt_block[u]);
-
- /* Set num_elem */
- if(space->select.num_elem != (hsize_t)0)
- space->select.num_elem = H5S_UNLIMITED;
- } /* end if */
- } /* end if */
- else if(op>=H5S_SELECT_OR && op<=H5S_SELECT_NOTA) {
- /* Sanity check */
- HDassert(H5S_GET_SELECT_TYPE(space) == H5S_SEL_HYPERSLABS);
-
- /* Handle unlimited selections */
- if(unlim_dim >= 0) {
- hsize_t bounds_start[H5S_MAX_RANK];
- hsize_t bounds_end[H5S_MAX_RANK];
- hsize_t tmp_count = opt_count[unlim_dim];
- hsize_t tmp_block = opt_block[unlim_dim];
-
- /* Check for invalid operation */
- if(space->select.sel_info.hslab->unlim_dim >= 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "cannot modify unlimited selection with another unlimited selection")
- if(!((op == H5S_SELECT_AND) || (op == H5S_SELECT_NOTB)))
- HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unsupported operation with unlimited selection")
-
- /* Get bounds of existing selection */
- if(H5S_hyper_bounds(space, bounds_start, bounds_end) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get selection bounds")
-
- /* Patch count and block to remove unlimited and include the
- * existing selection */
- H5S__hyper_get_clip_diminfo(start[unlim_dim], opt_stride[unlim_dim], &tmp_count, &tmp_block, bounds_end[unlim_dim] + (hsize_t)1);
- HDassert((tmp_count == 1) || (opt_count != H5S_hyper_ones_g));
- HDassert((tmp_block == 1) || (opt_block != H5S_hyper_ones_g));
- if(opt_count != H5S_hyper_ones_g) {
- HDassert(opt_count == int_count);
- int_count[unlim_dim] = tmp_count;
- } /* end if */
- if(opt_block != H5S_hyper_ones_g) {
- HDassert(opt_block == int_block);
- int_block[unlim_dim] = tmp_block;
- } /* end if */
- } /* end if */
+ HGOTO_DONE(SUCCEED);
+ } /* end if(!overlapped) */
+ } /* end if the selection of old space is H5S_SEL_HYPERSLABS */
- /* Check if there's no hyperslab span information currently */
- if(NULL == space->select.sel_info.hslab->span_lst)
- if(H5S__hyper_generate_spans(space) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "dataspace does not have span tree")
+ /* Copy the first dataspace with sharing the list of spans */
+ if(NULL == ((*new_space) = H5S_copy(old_space, TRUE, TRUE)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to copy dataspace")
- /* Indicate that the regular dimensions are no longer valid */
- space->select.sel_info.hslab->diminfo_valid = FALSE;
-
- /* Add in the new hyperslab information */
- if(H5S__generate_hyperslab (space, op, start, opt_stride, opt_count, opt_block)<0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't generate hyperslabs")
- } /* end if */
- else
- HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation")
-
- /* Set selection type */
- space->select.type = H5S_sel_hyper;
+ /* Note: a little overhead in calling the function as some conditions are checked again */
+ if(H5S_select_hyperslab(*new_space, op, start, stride, count, block) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to set hyperslab selection")
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5S_select_hyperslab() */
+} /* end H5S_combine_hyperslab() */
-/*--------------------------------------------------------------------------
- NAME
- H5Sselect_hyperslab
- PURPOSE
- Specify a hyperslab to combine with the current hyperslab selection
- USAGE
- herr_t H5Sselect_hyperslab(dsid, op, start, stride, count, block)
- hid_t dsid; IN: Dataspace ID of selection to modify
- H5S_seloper_t op; IN: Operation to perform on current selection
- const hsize_t *start; IN: Offset of start of hyperslab
- const hsize_t *stride; IN: Hyperslab stride
- const hsize_t *count; IN: Number of blocks included in hyperslab
- const hsize_t *block; IN: Size of block in hyperslab
- RETURNS
- Non-negative on success/Negative on failure
- DESCRIPTION
- Combines a hyperslab selection with the current selection for a dataspace.
- If the current selection is not a hyperslab, it is freed and the hyperslab
- parameters passed in are combined with the H5S_SEL_ALL hyperslab (ie. a
- selection composing the entire current extent). If STRIDE or BLOCK is
- NULL, they are assumed to be set to all '1'.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-herr_t
-H5Sselect_hyperslab(hid_t space_id, H5S_seloper_t op, const hsize_t start[],
- const hsize_t stride[], const hsize_t count[], const hsize_t block[])
+/*-------------------------------------------------------------------------
+ * Function: H5S__fill_in_select
+ *
+ * Purpose: Combines two hyperslabs with an operation, putting the
+ * result into a third hyperslab selection
+ *
+ * Return: Non-negative on success/negative on failure
+ *
+ * Programmer: Chao Mei
+ * Tuesday, July 5, 2011
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5S__fill_in_select(H5S_t *space1, H5S_seloper_t op, H5S_t *space2, H5S_t **result)
{
- H5S_t *space = NULL; /* Dataspace to modify selection of */
- herr_t ret_value=SUCCEED; /* Return value */
-
- FUNC_ENTER_API(FAIL)
- H5TRACE6("e", "iSs*h*h*h*h", space_id, op, start, stride, count, block);
+ hbool_t span2_owned;
+ hbool_t updated_spans;
+ herr_t ret_value = SUCCEED; /* Return value */
- /* Check args */
- if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace")
- if (H5S_SCALAR==H5S_GET_EXTENT_TYPE(space))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hyperslab doesn't support H5S_SCALAR space")
- if (H5S_NULL==H5S_GET_EXTENT_TYPE(space))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hyperslab doesn't support H5S_NULL space")
- if(start==NULL || count==NULL)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hyperslab not specified")
- if(!(op>H5S_SELECT_NOOP && op<H5S_SELECT_INVALID))
- HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation")
- if(stride!=NULL) {
- unsigned u; /* Local index variable */
+ FUNC_ENTER_STATIC
- /* Check for 0-sized strides */
- for(u=0; u<space->extent.rank; u++) {
- if(stride[u]==0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid stride==0 value")
- } /* end for */
+ /* Sanity check */
+ HDassert(space1);
+ HDassert(space2);
+ HDassert(op >= H5S_SELECT_OR && op <= H5S_SELECT_NOTA);
+ HDassert(space1->extent.rank == space2->extent.rank);
+ /* The result is either a to-be-created space or an empty one */
+ HDassert(NULL == *result || *result == space1);
+ HDassert(space1->select.sel_info.hslab->span_lst);
+ HDassert(space2->select.sel_info.hslab->span_lst);
+
+ /* Note: the offset of space2 is not considered here for bounding box */
+ if(H5S__fill_in_new_space(space1, op, space2->select.sel_info.hslab->span_lst, FALSE, &span2_owned, &updated_spans, result) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't create the specified selection")
+
+ /* Update diminfo if space2's diminfo was valid, otherwise just mark it as
+ * invalid if the spans were updated */
+ HDassert(result);
+ if(updated_spans) {
+ if(space2->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) {
+ if(H5S__hyper_update_diminfo(*result, op, space2->select.sel_info.hslab->diminfo.opt) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOUNT, FAIL, "can't update hyperslab info")
+ } /* end if */
+ else
+ (*result)->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_NO;
} /* end if */
- if (H5S_select_hyperslab(space, op, start, stride, count, block)<0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to set hyperslab selection")
-
done:
- FUNC_LEAVE_API(ret_value)
-} /* end H5Sselect_hyperslab() */
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5S__fill_in_select() */
/*--------------------------------------------------------------------------
@@ -7587,7 +10441,7 @@ done:
return a new dataspace with the combined selection as the selection in the
new dataspace.
USAGE
- hid_t H5Srefine_hyperslab(dsid, op, start, stride, count, block)
+ hid_t H5Scombine_hyperslab(dsid, op, start, stride, count, block)
hid_t dsid; IN: Dataspace ID of selection to use
H5S_seloper_t op; IN: Operation to perform on current selection
const hsize_t *start; IN: Offset of start of hyperslab
@@ -7595,7 +10449,7 @@ done:
const hsize_t *count; IN: Number of blocks included in hyperslab
const hsize_t *block; IN: Size of block in hyperslab
RETURNS
- Dataspace ID on success/Negative on failure
+ Dataspace ID on success / H5I_INVALID_HID on failure
DESCRIPTION
Combines a hyperslab selection with the current selection for a dataspace,
creating a new dataspace to return the generated selection.
@@ -7616,28 +10470,24 @@ H5Scombine_hyperslab(hid_t space_id, H5S_seloper_t op, const hsize_t start[],
H5S_t *new_space = NULL; /* New dataspace created */
hid_t ret_value; /* Return value */
- FUNC_ENTER_API(FAIL)
+ FUNC_ENTER_API(H5I_INVALID_HID)
H5TRACE6("i", "iSs*h*h*h*h", space_id, op, start, stride, count, block);
/* Check args */
if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a dataspace")
if(start == NULL || count == NULL)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hyperslab not specified")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "hyperslab not specified")
if(!(op >= H5S_SELECT_SET && op <= H5S_SELECT_NOTA))
- HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation")
+ HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, H5I_INVALID_HID, "invalid selection operation")
- /* Copy the first dataspace */
- if (NULL == (new_space = H5S_copy (space, TRUE, TRUE)))
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, NULL, "unable to copy dataspace")
-
- /* Go modify the selection in the new dataspace */
- if (H5S_select_hyperslab(new_space, op, start, stride, count, block)<0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to set hyperslab selection")
+ /* Generate new space, with combination of selections */
+ if(H5S_combine_hyperslab(space, op, start, stride, count, block, &new_space) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, H5I_INVALID_HID, "unable to set hyperslab selection")
/* Atomize */
if((ret_value = H5I_register(H5I_DATASPACE, new_space, TRUE)) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace atom")
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataspace atom")
done:
if(ret_value < 0 && new_space)
@@ -7657,17 +10507,13 @@ done:
* Programmer: Quincey Koziol
* Tuesday, October 30, 2001
*
- * Chao Mei
- * Wednesday, June 29, 2011
- *
*-------------------------------------------------------------------------
*/
static H5S_t *
H5S__combine_select(H5S_t *space1, H5S_seloper_t op, H5S_t *space2)
{
H5S_t *new_space = NULL; /* New dataspace generated */
- hbool_t span2_owned=FALSE; /* Flag to indicate that span2 was used in H5S_operate_hyperslab() */
- H5S_t *ret_value; /* return value */
+ H5S_t *ret_value = NULL; /* Return value */
FUNC_ENTER_STATIC
@@ -7676,33 +10522,38 @@ H5S__combine_select(H5S_t *space1, H5S_seloper_t op, H5S_t *space2)
HDassert(space2);
HDassert(op >= H5S_SELECT_OR && op <= H5S_SELECT_NOTA);
- /* Check that the space selections both have span trees */
- if(space1->select.sel_info.hslab->span_lst==NULL)
- if(H5S__hyper_generate_spans(space1)<0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, NULL, "dataspace does not have span tree")
- if(space2->select.sel_info.hslab->span_lst==NULL)
- if(H5S__hyper_generate_spans(space2)<0)
+ /* Check if space1 selections has span trees */
+ if(NULL == space1->select.sel_info.hslab->span_lst)
+ if(H5S__hyper_generate_spans(space1) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, NULL, "dataspace does not have span tree")
- /* Copy the first dataspace */
- if (NULL == (new_space = H5S_copy (space1, TRUE, TRUE)))
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, NULL, "unable to copy dataspace")
-
- /* Free the current selection for the new dataspace */
- if(H5S_SELECT_RELEASE(new_space)<0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, NULL, "can't release selection")
+ if(NULL == space2->select.sel_info.hslab->span_lst) {
+ hsize_t tmp_start[H5S_MAX_RANK];
+ hsize_t tmp_stride[H5S_MAX_RANK];
+ hsize_t tmp_count[H5S_MAX_RANK];
+ hsize_t tmp_block[H5S_MAX_RANK];
+ unsigned u;
+
+ for(u = 0; u < space2->extent.rank; u++) {
+ tmp_start[u] = space2->select.sel_info.hslab->diminfo.opt[u].start;
+ tmp_stride[u] = space2->select.sel_info.hslab->diminfo.opt[u].stride;
+ tmp_count[u] = space2->select.sel_info.hslab->diminfo.opt[u].count;
+ tmp_block[u] = space2->select.sel_info.hslab->diminfo.opt[u].block;
+ } /* end for */
- /* Allocate space for the hyperslab selection information */
- if((new_space->select.sel_info.hslab=H5FL_CALLOC(H5S_hyper_sel_t))==NULL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate hyperslab info")
+ /* Combine hyperslab selection with regular selection directly */
+ if(H5S_combine_hyperslab(space1, op, tmp_start, tmp_stride, tmp_count, tmp_block, &new_space) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, NULL, "unable to set hyperslab selection")
+ } /* end if */
+ else{
+ /* Combine new_space (a copy of space 1) & space2, with the result in new_space */
+ if(H5S__fill_in_select(space1, op, space2, &new_space) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, NULL, "can't clip hyperslab information")
+ } /* end else */
/* Set unlim_dim */
new_space->select.sel_info.hslab->unlim_dim = -1;
- /* Combine space1 & space2, with the result in new_space */
- if(H5S_operate_hyperslab(new_space,space1->select.sel_info.hslab->span_lst,op,space2->select.sel_info.hslab->span_lst,FALSE,&span2_owned)<0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, NULL, "can't clip hyperslab information")
-
/* Set return value */
ret_value = new_space;
@@ -7726,7 +10577,7 @@ done:
H5S_seloper_t op; IN: Selection operation
hid_t space2; IN: Second Dataspace ID
RETURNS
- Dataspace ID on success/Negative on failure
+ Dataspace ID on success / H5I_INVALID_HID on failure
DESCRIPTION
Combine two existing hyperslab selections with an operation, returning
a new dataspace with the resulting selection. The dataspace extent from
@@ -7744,32 +10595,42 @@ H5Scombine_select(hid_t space1_id, H5S_seloper_t op, hid_t space2_id)
H5S_t *new_space = NULL; /* New Dataspace */
hid_t ret_value; /* Return value */
- FUNC_ENTER_API(FAIL)
+ FUNC_ENTER_API(H5I_INVALID_HID)
H5TRACE3("i", "iSsi", space1_id, op, space2_id);
/* Check args */
if(NULL == (space1 = (H5S_t *)H5I_object_verify(space1_id, H5I_DATASPACE)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a dataspace")
if(NULL == (space2 = (H5S_t *)H5I_object_verify(space2_id, H5I_DATASPACE)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a dataspace")
if(!(op >= H5S_SELECT_OR && op <= H5S_SELECT_NOTA))
- HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation")
+ HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, H5I_INVALID_HID, "invalid selection operation")
/* Check that both dataspaces have the same rank */
if(space1->extent.rank != space2->extent.rank)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dataspaces not same rank")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "dataspaces not same rank")
+
+ /* Note: currently, the offset of each dataspace is ignored */
+#if 0
+ /* Check that both dataspaces have the same offset */
+ /* Same note as in H5Smodify_select */
+ for(u=0; u<space1->extent.rank; u++) {
+ if(space1->select.offset[u] != space2->select.offset[u])
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "dataspaces not same offset")
+ } /* end for */
+#endif
/* Check that both dataspaces have hyperslab selections */
if(H5S_GET_SELECT_TYPE(space1) != H5S_SEL_HYPERSLABS || H5S_GET_SELECT_TYPE(space2) != H5S_SEL_HYPERSLABS)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dataspaces don't have hyperslab selections")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "dataspaces don't have hyperslab selections")
/* Go combine the dataspaces */
if(NULL == (new_space = H5S__combine_select(space1, op, space2)))
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to create hyperslab selection")
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, H5I_INVALID_HID, "unable to create hyperslab selection")
/* Atomize */
if((ret_value = H5I_register(H5I_DATASPACE, new_space, TRUE)) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace atom")
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataspace atom")
done:
if(ret_value < 0 && new_space)
@@ -7780,77 +10641,73 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5S_select_select
+ * Function: H5S__modify_select
*
- * Purpose: Internal version of H5Sselect_select().
+ * Purpose: Internal version of H5Smodify_select().
*
* Return: New dataspace on success/NULL on failure
*
* Programmer: Quincey Koziol
* Tuesday, October 30, 2001
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
-static herr_t
-H5S_select_select (H5S_t *space1, H5S_seloper_t op, H5S_t *space2)
+herr_t
+H5S__modify_select(H5S_t *space1, H5S_seloper_t op, H5S_t *space2)
{
- H5S_hyper_span_info_t *tmp_spans=NULL; /* Temporary copy of selection */
- hbool_t span2_owned=FALSE; /* Flag to indicate that span2 was used in H5S_operate_hyperslab() */
- herr_t ret_value=SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_PACKAGE
/* Check args */
HDassert(space1);
HDassert(space2);
- HDassert(op > H5S_SELECT_NOOP && op < H5S_SELECT_INVALID);
+ HDassert(op >= H5S_SELECT_OR && op <= H5S_SELECT_NOTA);
/* Check that the space selections both have span trees */
- if(space1->select.sel_info.hslab->span_lst==NULL)
- if(H5S__hyper_generate_spans(space1)<0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "dataspace does not have span tree")
- if(space2->select.sel_info.hslab->span_lst==NULL)
- if(H5S__hyper_generate_spans(space2)<0)
+ if(NULL == space1->select.sel_info.hslab->span_lst)
+ if(H5S__hyper_generate_spans(space1) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "dataspace does not have span tree")
- /* Take ownership of the dataspace's hyperslab spans */
- /* (These are freed later) */
- tmp_spans=space1->select.sel_info.hslab->span_lst;
- space1->select.sel_info.hslab->span_lst=NULL;
-
- /* Reset the other dataspace selection information */
- if(H5S_SELECT_RELEASE(space1)<0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release selection")
-
- /* Allocate space for the hyperslab selection information */
- if((space1->select.sel_info.hslab=H5FL_CALLOC(H5S_hyper_sel_t))==NULL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab info")
-
/* Set unlim_dim */
space1->select.sel_info.hslab->unlim_dim = -1;
- /* Combine tmp_spans (from space1) & spans from space2, with the result in space1 */
- if(H5S_operate_hyperslab(space1,tmp_spans,op,space2->select.sel_info.hslab->span_lst,FALSE,&span2_owned)<0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't clip hyperslab information")
+ if(NULL == space2->select.sel_info.hslab->span_lst) {
+ hsize_t tmp_start[H5S_MAX_RANK];
+ hsize_t tmp_stride[H5S_MAX_RANK];
+ hsize_t tmp_count[H5S_MAX_RANK];
+ hsize_t tmp_block[H5S_MAX_RANK];
+ unsigned u;
+
+ for(u = 0; u < space2->extent.rank; u++) {
+ tmp_start[u] = space2->select.sel_info.hslab->diminfo.opt[u].start;
+ tmp_stride[u] = space2->select.sel_info.hslab->diminfo.opt[u].stride;
+ tmp_count[u] = space2->select.sel_info.hslab->diminfo.opt[u].count;
+ tmp_block[u] = space2->select.sel_info.hslab->diminfo.opt[u].block;
+ } /* end for */
-done:
- if(tmp_spans!=NULL)
- H5S__hyper_free_span_info(tmp_spans);
+ /* Call H5S_select_hyperslab directly */
+ if(H5S_select_hyperslab(space1, op, tmp_start, tmp_stride, tmp_count, tmp_block) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to set hyperslab selection")
+ } /* end if */
+ else
+ /* Combine spans from space1 & spans from space2, with the result in space1 */
+ if(H5S__fill_in_select(space1, op, space2, &space1) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't perform operation on two selections")
+done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5S_select_select() */
+} /* end H5S__modify_select() */
/*--------------------------------------------------------------------------
NAME
- H5Sselect_select
+ H5Smodify_select
PURPOSE
Refine a hyperslab selection with an operation using a second hyperslab
- to modify it.
+ to modify it
USAGE
- herr_t H5Sselect_select(space1, op, space2)
+ herr_t H5Smodify_select(space1, op, space2)
hid_t space1; IN/OUT: First Dataspace ID
H5S_seloper_t op; IN: Selection operation
hid_t space2; IN: Second Dataspace ID
@@ -7866,7 +10723,7 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
herr_t
-H5Sselect_select(hid_t space1_id, H5S_seloper_t op, hid_t space2_id)
+H5Smodify_select(hid_t space1_id, H5S_seloper_t op, hid_t space2_id)
{
H5S_t *space1; /* First Dataspace */
H5S_t *space2; /* Second Dataspace */
@@ -7887,1348 +10744,615 @@ H5Sselect_select(hid_t space1_id, H5S_seloper_t op, hid_t space2_id)
if(space1->extent.rank != space2->extent.rank)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dataspaces not same rank")
+ /* Check that both dataspaces have the same offset */
+ /** Note that this is a tricky part of this function. It's
+ * possible that two dataspaces have different "offset". If the
+ * space2 has smaller offset value than that of space1 in a
+ * dimension, then the span elements of this dimension in
+ * space2 could have negative "low" and "high" values relative
+ * to the offset in space1. In other words, if the bounds of
+ * span elements in space2 are adjusted relative to the offset
+ * in space1, then every span element's bound is computed as
+ * "origin_bound+offset2-offset1". Therefore, if offset2 (the
+ * offset of space2) is smaller, then
+ * "origin_bound+offset2-offset1" could be negative which is
+ * not allowed by the bound type declaration as hsize_t!
+ * As a result, if the op is an OR selection, then the final
+ * result may contain span elements that have negative bound!
+ * So right now, the difference in the offset is totally
+ * ignored!!
+ */
+#if 0
+ for(u=0; u<space1->extent.rank; u++) {
+ if(space1->select.offset[u] != space2->select.offset[u])
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dataspaces not same offset")
+ } /* end for */
+#endif
+
/* Check that both dataspaces have hyperslab selections */
if(H5S_GET_SELECT_TYPE(space1) != H5S_SEL_HYPERSLABS || H5S_GET_SELECT_TYPE(space2) != H5S_SEL_HYPERSLABS)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dataspaces don't have hyperslab selections")
/* Go refine the first selection */
- if (H5S_select_select(space1, op, space2)<0)
+ if(H5S__modify_select(space1, op, space2) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to modify hyperslab selection")
done:
FUNC_LEAVE_API(ret_value)
-} /* end H5Sselect_select() */
-#endif /* NEW_HYPERSLAB_API */ /* Works */
+} /* end H5Smodify_select() */
/*--------------------------------------------------------------------------
NAME
- H5S__hyper_get_seq_list_gen
+ H5S__hyper_proj_int_build_proj
PURPOSE
- Create a list of offsets & lengths for a selection
+ Secondary iteration routine for H5S__hyper_project_intersection
USAGE
- herr_t H5S_select_hyper_get_file_list_gen(space,iter,maxseq,maxelem,nseq,nelem,off,len)
- H5S_t *space; IN: Dataspace containing selection to use.
- H5S_sel_iter_t *iter; IN/OUT: Selection iterator describing last
- position of interest in selection.
- size_t maxseq; IN: Maximum number of sequences to generate
- size_t maxelem; IN: Maximum number of elements to include in the
- generated sequences
- size_t *nseq; OUT: Actual number of sequences generated
- size_t *nelem; OUT: Actual number of elements in sequences generated
- hsize_t *off; OUT: Array of offsets
- size_t *len; OUT: Array of lengths
+ herr_t H5S__hyper_proj_int_build_proj(udata)
+ H5S_hyper_project_intersect_ud_t *udata; IN/OUT: Persistent shared data for iteration
RETURNS
Non-negative on success/Negative on failure.
DESCRIPTION
- Use the selection in the dataspace to generate a list of byte offsets and
- lengths for the region(s) selected. Start/Restart from the position in the
- ITER parameter. The number of sequences generated is limited by the MAXSEQ
- parameter and the number of sequences actually generated is stored in the
- NSEQ parameter.
+ Takes the skip and nelem amounts listed in udata and converts them to
+ span trees in the projected space, using the destination space. This
+ is a non-recursive algorithm by necessity, it saves the current state
+ of iteration in udata and resumes in the same location on subsequent
+ calls.
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
-H5S__hyper_get_seq_list_gen(const H5S_t *space, H5S_sel_iter_t *iter,
- size_t maxseq, size_t maxelem, size_t *nseq, size_t *nelem,
- hsize_t *off, size_t *len)
-{
- H5S_hyper_span_t *curr_span; /* Current hyperslab span node */
- H5S_hyper_span_t **ispan; /* Iterator's hyperslab span nodes */
- hsize_t slab[H5O_LAYOUT_NDIMS]; /* Cumulative size of each dimension in bytes */
- hsize_t acc; /* Accumulator for computing cumulative sizes */
- hsize_t loc_off; /* Element offset in the dataspace */
- hsize_t last_span_end = 0; /* The offset of the end of the last span */
- hsize_t *abs_arr; /* Absolute hyperslab span position */
- const hssize_t *off_arr; /* Offset within the dataspace extent */
- size_t span_size = 0; /* Number of bytes in current span to actually process */
- size_t io_left; /* Number of elements left to process */
- size_t io_bytes_left; /* Number of bytes left to process */
- size_t io_used; /* Number of elements processed */
- size_t curr_seq = 0; /* Number of sequence/offsets stored in the arrays */
- size_t elem_size; /* Size of each element iterating over */
- unsigned ndims; /* Number of dimensions of dataset */
- unsigned fast_dim; /* Rank of the fastest changing dimension for the dataspace */
- int curr_dim; /* Current dimension being operated on */
- unsigned u; /* Index variable */
- int i; /* Index variable */
-
- FUNC_ENTER_STATIC_NOERR
-
- /* Check args */
- HDassert(space);
- HDassert(iter);
- HDassert(maxseq > 0);
- HDassert(maxelem > 0);
- HDassert(nseq);
- HDassert(nelem);
- HDassert(off);
- HDassert(len);
-
- /* Set the rank of the fastest changing dimension */
- ndims = space->extent.rank;
- fast_dim = (ndims - 1);
-
- /* Get the pointers to the current span info and span nodes */
- curr_span = iter->u.hyp.span[fast_dim];
- abs_arr = iter->u.hyp.off;
- off_arr = space->select.offset;
- ispan = iter->u.hyp.span;
- elem_size = iter->elmt_size;
-
- /* Set the amount of elements to perform I/O on, etc. */
- H5_CHECK_OVERFLOW(iter->elmt_left, hsize_t, size_t);
- io_left = MIN(maxelem, (size_t)iter->elmt_left);
- io_bytes_left = io_left * elem_size;
-
- /* Compute the cumulative size of dataspace dimensions */
- for(i = (int)fast_dim, acc = elem_size; i >= 0; i--) {
- slab[i] = acc;
- acc *= space->extent.size[i];
- } /* end for */
-
- /* Set the offset of the first element iterated on */
- for(u = 0, loc_off = 0; u < ndims; u++)
- /* Compute the sequential element offset */
- loc_off += ((hsize_t)((hssize_t)abs_arr[u] + off_arr[u])) * slab[u];
-
- /* Range check against number of elements left in selection */
- HDassert(io_bytes_left <= (iter->elmt_left * elem_size));
-
- /* Take care of any partial spans leftover from previous I/Os */
- if(abs_arr[fast_dim]!=curr_span->low) {
-
- /* Finish the span in the fastest changing dimension */
-
- /* Compute the number of bytes to attempt in this span */
- H5_CHECKED_ASSIGN(span_size, size_t, ((curr_span->high-abs_arr[fast_dim])+1)*elem_size, hsize_t);
-
- /* Check number of bytes against upper bounds allowed */
- if(span_size>io_bytes_left)
- span_size=io_bytes_left;
-
- /* Add the partial span to the list of sequences */
- off[curr_seq]=loc_off;
- len[curr_seq]=span_size;
-
- /* Increment sequence count */
- curr_seq++;
-
- /* Set the location of the last span's end */
- last_span_end=loc_off+span_size;
-
- /* Decrement I/O left to perform */
- io_bytes_left-=span_size;
+H5S__hyper_proj_int_build_proj(H5S_hyper_project_intersect_ud_t *udata) {
+ herr_t ret_value = SUCCEED; /* Return value */
- /* Advance the hyperslab iterator */
- /* Check if we are done */
- if(io_bytes_left > 0) {
- /* Move to next span in fastest changing dimension */
- curr_span = curr_span->next;
+ FUNC_ENTER_STATIC
- if(NULL != curr_span) {
- /* Move location offset of destination */
- loc_off += (curr_span->low - abs_arr[fast_dim]) * elem_size;
+ HDassert(udata->nelem > 0);
- /* Move iterator for fastest changing dimension */
- abs_arr[fast_dim] = curr_span->low;
- } /* end if */
- } /* end if */
- else {
- abs_arr[fast_dim] += span_size / elem_size;
+ /*
+ * Skip over skipped elements
+ */
+ if(udata->skip > 0) {
+ /* Work upwards, finishing each span tree before moving up */
+ HDassert(udata->ds_span[udata->depth]);
+ do {
+ /* Check for lowest dimension */
+ if(udata->ds_span[udata->depth]->down) {
+ if(udata->ds_low[udata->depth] <= udata->ds_span[udata->depth]->high) {
+ /* If we will run out of elements to skip in this span,
+ * advance to the first not fully skipped span and break
+ * out of this loop (start moving downwards) */
+ if(udata->skip < H5S__hyper_spans_nelem_helper(udata->ds_span[udata->depth]->down, udata->op_gen)
+ * (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1)) {
+ udata->ds_low[udata->depth] += udata->skip / udata->ds_span[udata->depth]->down->u.nelmts;
+ udata->skip %= udata->ds_span[udata->depth]->down->u.nelmts;
+ break;
+ } /* end if */
- /* Check if we are still within the span */
- if(abs_arr[fast_dim] <= curr_span->high) {
- iter->u.hyp.span[fast_dim] = curr_span;
+ /* Skip over this entire span */
+ udata->skip -= udata->ds_span[udata->depth]->down->u.nelmts
+ * (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1);
+ } /* end if */
} /* end if */
- /* If we walked off that span, advance to the next span */
else {
- /* Advance span in this dimension */
- curr_span = curr_span->next;
-
- /* Check if we have a valid span in this dimension still */
- if(NULL != curr_span) {
- /* Reset absolute position */
- abs_arr[fast_dim] = curr_span->low;
- iter->u.hyp.span[fast_dim] = curr_span;
- } /* end if */
- } /* end else */
- } /* end else */
-
- /* Adjust iterator pointers */
-
- if(NULL == curr_span) {
-/* Same as code in main loop */
- /* Start at the next fastest dim */
- curr_dim = (int)(fast_dim - 1);
-
- /* Work back up through the dimensions */
- while(curr_dim >= 0) {
- /* Reset the current span */
- curr_span = iter->u.hyp.span[curr_dim];
-
- /* Increment absolute position */
- abs_arr[curr_dim]++;
-
- /* Check if we are still within the span */
- if(abs_arr[curr_dim] <= curr_span->high) {
+ HDassert(udata->ds_rank - udata->depth == 1);
+
+ /* If we will run out of elements to skip in this span,
+ * skip the remainder of the skipped elements and break out */
+ HDassert(udata->ds_low[udata->depth] <= udata->ds_span[udata->depth]->high);
+ if(udata->skip < (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1)) {
+ udata->ds_low[udata->depth] += udata->skip;
+ udata->skip = 0;
break;
} /* end if */
- /* If we walked off that span, advance to the next span */
- else {
- /* Advance span in this dimension */
- curr_span = curr_span->next;
- /* Check if we have a valid span in this dimension still */
- if(NULL != curr_span) {
- /* Reset the span in the current dimension */
- ispan[curr_dim] = curr_span;
+ /* Skip over this entire span */
+ udata->skip -= udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1;
+ } /* end else */
- /* Reset absolute position */
- abs_arr[curr_dim] = curr_span->low;
+ /* Advance to next span */
+ udata->ds_span[udata->depth] = udata->ds_span[udata->depth]->next;
+ if(udata->ds_span[udata->depth])
+ udata->ds_low[udata->depth] = udata->ds_span[udata->depth]->low;
+ else if(udata->depth > 0) {
+ /* If present, append this span tree to the higher dimension's,
+ * and release ownership of it */
+ if(udata->ps_span_info[udata->depth]) {
+ if(H5S__hyper_append_span(&udata->ps_span_info[udata->depth - 1],
+ udata->ds_rank - udata->depth + 1, udata->ds_low[udata->depth - 1],
+ udata->ds_low[udata->depth - 1],
+ udata->ps_span_info[udata->depth]) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
+ H5S__hyper_free_span_info(udata->ps_span_info[udata->depth]);
+ udata->ps_span_info[udata->depth] = NULL;
+ } /* end if */
+ /* Ran out of spans, move up one dimension */
+ udata->depth--;
+ HDassert(udata->ds_span[udata->depth]);
+ udata->ds_low[udata->depth]++;
+ } /* end if */
+ else
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "insufficient elements in destination selection")
+ } while((udata->skip > 0)
+ || (udata->ds_low[udata->depth] > udata->ds_span[udata->depth]->high));
+
+ /* Work downwards until skip is 0 */
+ HDassert(udata->ds_span[udata->depth]);
+ while(udata->skip > 0) {
+ HDassert(udata->ds_span[udata->depth]->down);
+ udata->depth++;
+ udata->ds_span[udata->depth] = udata->ds_span[udata->depth - 1]->down->head;
+ udata->ds_low[udata->depth] = udata->ds_span[udata->depth]->low;
+ if(udata->ds_span[udata->depth]->down) {
+ do {
+ /* If we will run out of elements to skip in this span,
+ * advance to the first not fully skipped span and
+ * continue down */
+ if(udata->skip < H5S__hyper_spans_nelem_helper(udata->ds_span[udata->depth]->down, udata->op_gen)
+ * (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1)) {
+ udata->ds_low[udata->depth] += udata->skip / udata->ds_span[udata->depth]->down->u.nelmts;
+ udata->skip %= udata->ds_span[udata->depth]->down->u.nelmts;
break;
} /* end if */
- else {
- /* If we finished the span list in this dimension, decrement the dimension worked on and loop again */
- curr_dim--;
- } /* end else */
- } /* end else */
- } /* end while */
-
- /* Check if we have more spans in the tree */
- if(curr_dim >= 0) {
- /* Walk back down the iterator positions, resetting them */
- while((unsigned)curr_dim < fast_dim) {
- HDassert(curr_span);
- HDassert(curr_span->down);
- HDassert(curr_span->down->head);
-
- /* Increment current dimension */
- curr_dim++;
-
- /* Set the new span_info & span for this dimension */
- iter->u.hyp.span[curr_dim] = curr_span->down->head;
-
- /* Advance span down the tree */
- curr_span = curr_span->down->head;
-
- /* Reset the absolute offset for the dim */
- abs_arr[curr_dim] = curr_span->low;
- } /* end while */
-
- /* Verify that the curr_span points to the fastest dim */
- HDassert(curr_span == iter->u.hyp.span[fast_dim]);
-
- /* Reset the buffer offset */
- for(u = 0, loc_off = 0; u < ndims; u++)
- loc_off += ((hsize_t)((hssize_t)abs_arr[u] + off_arr[u])) * slab[u];
- } /* end else */
- else
- /* We had better be done with I/O or bad things are going to happen... */
- HDassert(io_bytes_left == 0);
- } /* end if */
- } /* end if */
-
- /* Perform the I/O on the elements, based on the position of the iterator */
- while(io_bytes_left > 0 && curr_seq < maxseq) {
- /* Sanity check */
- HDassert(curr_span);
-
- /* Adjust location offset of destination to compensate for initial increment below */
- loc_off -= curr_span->pstride;
- /* Loop over all the spans in the fastest changing dimension */
- while(curr_span != NULL) {
- /* Move location offset of destination */
- loc_off += curr_span->pstride;
-
- /* Compute the number of elements to attempt in this span */
- H5_CHECKED_ASSIGN(span_size, size_t, curr_span->nelem, hsize_t);
-
- /* Check number of elements against upper bounds allowed */
- if(span_size >= io_bytes_left) {
- /* Trim the number of bytes to output */
- span_size = io_bytes_left;
- io_bytes_left = 0;
-
-/* COMMON */
- /* Store the I/O information for the span */
+ /* Skip over this entire span */
+ udata->skip -= udata->ds_span[udata->depth]->down->u.nelmts
+ * (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1);
- /* Check if this is appending onto previous sequence */
- if(curr_seq > 0 && last_span_end == loc_off)
- len[curr_seq - 1] += span_size;
- else {
- off[curr_seq] = loc_off;
- len[curr_seq] = span_size;
-
- /* Increment the number of sequences in arrays */
- curr_seq++;
- } /* end else */
-
- /* Set the location of the last span's end */
- last_span_end = loc_off + span_size;
-/* end COMMON */
-
- /* Break out now, we are finished with I/O */
- break;
+ /* Advance to next span */
+ udata->ds_span[udata->depth] = udata->ds_span[udata->depth]->next;
+ HDassert(udata->ds_span[udata->depth]);
+ udata->ds_low[udata->depth] = udata->ds_span[udata->depth]->low;
+ } while(udata->skip > 0);
} /* end if */
else {
- /* Decrement I/O left to perform */
- io_bytes_left -= span_size;
-
-/* COMMON */
- /* Store the I/O information for the span */
-
- /* Check if this is appending onto previous sequence */
- if(curr_seq > 0 && last_span_end == loc_off)
- len[curr_seq-1]+=span_size;
- else {
- off[curr_seq] = loc_off;
- len[curr_seq] = span_size;
-
- /* Increment the number of sequences in arrays */
- curr_seq++;
- } /* end else */
+ do {
+ /* If we will run out of elements to skip in this span,
+ * skip the remainder of the skipped elements */
+ if(udata->skip < (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1)) {
+ udata->ds_low[udata->depth] += udata->skip;
+ udata->skip = 0;
+ break;
+ } /* end if */
- /* Set the location of the last span's end */
- last_span_end = loc_off + span_size;
-/* end COMMON */
+ /* Skip over this entire span */
+ udata->skip -= udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1;
- /* If the sequence & offset arrays are full, do what? */
- if(curr_seq >= maxseq) {
- /* Break out now, we are finished with sequences */
- break;
- } /* end else */
+ /* Advance to next span */
+ udata->ds_span[udata->depth] = udata->ds_span[udata->depth]->next;
+ HDassert(udata->ds_span[udata->depth]);
+ udata->ds_low[udata->depth] = udata->ds_span[udata->depth]->low;
+ } while(udata->skip > 0);
} /* end else */
-
- /* Move to next span in fastest changing dimension */
- curr_span=curr_span->next;
} /* end while */
+ } /* end if */
- /* Check if we are done */
- if(io_bytes_left==0 || curr_seq>=maxseq) {
- HDassert(curr_span);
- abs_arr[fast_dim]=curr_span->low+(span_size/elem_size);
-
- /* Check if we are still within the span */
- if(abs_arr[fast_dim]<=curr_span->high) {
- iter->u.hyp.span[fast_dim]=curr_span;
- break;
- } /* end if */
- /* If we walked off that span, advance to the next span */
- else {
- /* Advance span in this dimension */
- curr_span=curr_span->next;
-
- /* Check if we have a valid span in this dimension still */
- if(curr_span!=NULL) {
- /* Reset absolute position */
- abs_arr[fast_dim]=curr_span->low;
- iter->u.hyp.span[fast_dim]=curr_span;
+ /*
+ * Add requested number of elements to projected space
+ */
+ /* Work upwards, adding all elements of each span tree until it can't fit
+ * all elements */
+ HDassert(udata->ds_span[udata->depth]);
+ do {
+ /* Check for lowest dimension */
+ if(udata->ds_span[udata->depth]->down) {
+ if(udata->ds_low[udata->depth] <= udata->ds_span[udata->depth]->high) {
+ /* If we will run out of elements to add in this span, add
+ * any complete spans, advance to the first not fully added
+ * span, and break out of this loop (start moving downwards)
+ */
+ if(udata->nelem < H5S__hyper_spans_nelem_helper(udata->ds_span[udata->depth]->down, udata->op_gen)
+ * (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1)) {
+ if(udata->nelem >= udata->ds_span[udata->depth]->down->u.nelmts) {
+ if(H5S__hyper_append_span(&udata->ps_span_info[udata->depth],
+ udata->ds_rank - udata->depth, udata->ds_low[udata->depth],
+ udata->ds_low[udata->depth] + (udata->nelem / udata->ds_span[udata->depth]->down->u.nelmts) - 1,
+ udata->ds_span[udata->depth]->down) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
+ udata->ds_low[udata->depth] += udata->nelem / udata->ds_span[udata->depth]->down->u.nelmts;
+ udata->nelem %= udata->ds_span[udata->depth]->down->u.nelmts;
+ } /* end if */
break;
} /* end if */
- } /* end else */
- } /* end if */
-
- /* Adjust iterator pointers */
-
- /* Start at the next fastest dim */
- curr_dim = (int)(fast_dim - 1);
- /* Work back up through the dimensions */
- while(curr_dim >= 0) {
- /* Reset the current span */
- curr_span=iter->u.hyp.span[curr_dim];
-
- /* Increment absolute position */
- abs_arr[curr_dim]++;
-
- /* Check if we are still within the span */
- if(abs_arr[curr_dim]<=curr_span->high) {
+ /* Append span tree for entire span */
+ if(H5S__hyper_append_span(&udata->ps_span_info[udata->depth],
+ udata->ds_rank - udata->depth, udata->ds_low[udata->depth],
+ udata->ds_span[udata->depth]->high,
+ udata->ds_span[udata->depth]->down) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
+ udata->nelem -= udata->ds_span[udata->depth]->down->u.nelmts
+ * (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1);
+ } /* end if */
+ } /* end if */
+ else {
+ HDassert(udata->ds_rank - udata->depth == 1);
+
+ /* If we will run out of elements to add in this span, add the
+ * remainder of the elements and break out */
+ HDassert(udata->ds_low[udata->depth] <= udata->ds_span[udata->depth]->high);
+ if(udata->nelem < (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1)) {
+ if(H5S__hyper_append_span(&udata->ps_span_info[udata->depth], 1,
+ udata->ds_low[udata->depth], udata->ds_low[udata->depth] + udata->nelem - 1, NULL) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
+ udata->ds_low[udata->depth] += udata->nelem;
+ udata->nelem = 0;
break;
} /* end if */
- /* If we walked off that span, advance to the next span */
- else {
- /* Advance span in this dimension */
- curr_span=curr_span->next;
- /* Check if we have a valid span in this dimension still */
- if(curr_span!=NULL) {
- /* Reset the span in the current dimension */
- ispan[curr_dim]=curr_span;
+ /* Append span tree for entire span */
+ if(H5S__hyper_append_span(&udata->ps_span_info[udata->depth], 1,
+ udata->ds_low[udata->depth], udata->ds_span[udata->depth]->high, NULL) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
+ udata->nelem -= udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1;
+ } /* end else */
- /* Reset absolute position */
- abs_arr[curr_dim]=curr_span->low;
+ /* Advance to next span */
+ udata->ds_span[udata->depth] = udata->ds_span[udata->depth]->next;
+ if(udata->ds_span[udata->depth])
+ udata->ds_low[udata->depth] = udata->ds_span[udata->depth]->low;
+ else if(udata->depth > 0) {
+ /* Append this span tree to the higher dimension's, and release
+ * ownership of it */
+ HDassert(udata->ps_span_info[udata->depth]);
+ if(H5S__hyper_append_span(&udata->ps_span_info[udata->depth - 1],
+ udata->ds_rank - udata->depth + 1, udata->ds_low[udata->depth - 1],
+ udata->ds_low[udata->depth - 1],
+ udata->ps_span_info[udata->depth]) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
+ H5S__hyper_free_span_info(udata->ps_span_info[udata->depth]);
+ udata->ps_span_info[udata->depth] = NULL;
+ /* Ran out of spans, move up one dimension */
+ udata->depth--;
+ HDassert(udata->ds_span[udata->depth]);
+ udata->ds_low[udata->depth]++;
+ } /* end if */
+ else {
+ /* We have finished the entire destination span tree. If there are
+ * still elements to add, issue an error. */
+ if(udata->nelem > 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "insufficient elements in destination selection")
+ break;
+ } /* end else */
+ } while((udata->nelem > 0)
+ || (udata->ds_low[udata->depth] > udata->ds_span[udata->depth]->high));
+
+ /* Work downwards until nelem is 0 */
+ HDassert(udata->ds_span[udata->depth] || (udata->nelem == 0));
+ while(udata->nelem > 0) {
+ HDassert(udata->ds_span[udata->depth]->down);
+ udata->depth++;
+ udata->ds_span[udata->depth] = udata->ds_span[udata->depth - 1]->down->head;
+ udata->ds_low[udata->depth] = udata->ds_span[udata->depth]->low;
+ if(udata->ds_span[udata->depth]->down) {
+ do {
+ /* If we will run out of elements to add in this span, add
+ * any complete spans, advance to the first not fully added
+ * span and continue down
+ */
+ HDassert(udata->ds_low[udata->depth] <= udata->ds_span[udata->depth]->high);
+ if(udata->nelem < H5S__hyper_spans_nelem_helper(udata->ds_span[udata->depth]->down, udata->op_gen)
+ * (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1)) {
+ if(udata->nelem >= udata->ds_span[udata->depth]->down->u.nelmts) {
+ if(H5S__hyper_append_span(&udata->ps_span_info[udata->depth],
+ udata->ds_rank - udata->depth, udata->ds_low[udata->depth],
+ udata->ds_low[udata->depth] + (udata->nelem / udata->ds_span[udata->depth]->down->u.nelmts) - 1,
+ udata->ds_span[udata->depth]->down) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
+ udata->ds_low[udata->depth] += udata->nelem / udata->ds_span[udata->depth]->down->u.nelmts;
+ udata->nelem %= udata->ds_span[udata->depth]->down->u.nelmts;
+ } /* end if */
break;
} /* end if */
- else {
- /* If we finished the span list in this dimension, decrement the dimension worked on and loop again */
- curr_dim--;
- } /* end else */
- } /* end else */
- } /* end while */
- /* Check if we are finished with the spans in the tree */
- if(curr_dim < 0) {
- /* We had better be done with I/O or bad things are going to happen... */
- HDassert(io_bytes_left == 0);
- break;
+ /* Append span tree for entire span */
+ if(H5S__hyper_append_span(&udata->ps_span_info[udata->depth],
+ udata->ds_rank - udata->depth, udata->ds_low[udata->depth],
+ udata->ds_span[udata->depth]->high,
+ udata->ds_span[udata->depth]->down) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
+ udata->nelem -= udata->ds_span[udata->depth]->down->u.nelmts
+ * (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1);
+
+ /* Advance to next span */
+ udata->ds_span[udata->depth] = udata->ds_span[udata->depth]->next;
+ HDassert(udata->ds_span[udata->depth]);
+ udata->ds_low[udata->depth] = udata->ds_span[udata->depth]->low;
+ } while(udata->nelem > 0);
} /* end if */
else {
- /* Walk back down the iterator positions, resetting them */
- while((unsigned)curr_dim < fast_dim) {
- HDassert(curr_span);
- HDassert(curr_span->down);
- HDassert(curr_span->down->head);
-
- /* Increment current dimension to the next dimension down */
- curr_dim++;
-
- /* Set the new span for the next dimension down */
- iter->u.hyp.span[curr_dim] = curr_span->down->head;
-
- /* Advance span down the tree */
- curr_span = curr_span->down->head;
-
- /* Reset the absolute offset for the dim */
- abs_arr[curr_dim] = curr_span->low;
- } /* end while */
+ HDassert(udata->ds_rank - udata->depth == 1);
+ do {
+ /* If we will run out of elements to add in this span, add
+ * the remainder of the elements and break out */
+ HDassert(udata->ds_low[udata->depth] <= udata->ds_span[udata->depth]->high);
+ if(udata->nelem < (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1)) {
+ if(H5S__hyper_append_span(&udata->ps_span_info[udata->depth], 1,
+ udata->ds_low[udata->depth], udata->ds_low[udata->depth] + udata->nelem - 1, NULL) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
+ udata->ds_low[udata->depth] += udata->nelem;
+ udata->nelem = 0;
+ break;
+ } /* end if */
- /* Verify that the curr_span points to the fastest dim */
- HDassert(curr_span == iter->u.hyp.span[fast_dim]);
+ /* Append span tree for entire span */
+ if(H5S__hyper_append_span(&udata->ps_span_info[udata->depth], 1,
+ udata->ds_low[udata->depth], udata->ds_span[udata->depth]->high, NULL) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
+ udata->nelem -= udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1;
+
+ /* Advance to next span */
+ udata->ds_span[udata->depth] = udata->ds_span[udata->depth]->next;
+ HDassert(udata->ds_span[udata->depth]);
+ udata->ds_low[udata->depth] = udata->ds_span[udata->depth]->low;
+ } while(udata->nelem > 0);
} /* end else */
-
- /* Reset the buffer offset */
- for(u = 0, loc_off = 0; u < ndims; u++)
- loc_off += ((hsize_t)((hssize_t)abs_arr[u] + off_arr[u])) * slab[u];
} /* end while */
- /* Decrement number of elements left in iterator */
- io_used = (io_left - (io_bytes_left / elem_size));
- iter->elmt_left -= io_used;
-
- /* Set the number of sequences generated */
- *nseq = curr_seq;
+ HDassert(udata->skip == 0);
+ HDassert(udata->nelem == 0);
- /* Set the number of elements used */
- *nelem = io_used;
+ /* Mark projected space as changed (for all ranks) */
+ udata->ps_clean_bitmap = 0;
- FUNC_LEAVE_NOAPI(SUCCEED)
-} /* end H5S__hyper_get_seq_list_gen() */
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5S__hyper_proj_int_build_proj() */
/*--------------------------------------------------------------------------
NAME
- H5S__hyper_get_seq_list_opt
+ H5S__hyper_proj_int_iterate
PURPOSE
- Create a list of offsets & lengths for a selection
+ Main iteration routine for H5S__hyper_project_intersection
USAGE
- herr_t H5S_select_hyper_get_file_list_opt(space,iter,maxseq,maxelem,nseq,nelem,off,len)
- H5S_t *space; IN: Dataspace containing selection to use.
- H5S_sel_iter_t *iter; IN/OUT: Selection iterator describing last
- position of interest in selection.
- size_t maxseq; IN: Maximum number of sequences to generate
- size_t maxelem; IN: Maximum number of elements to include in the
- generated sequences
- size_t *nseq; OUT: Actual number of sequences generated
- size_t *nelem; OUT: Actual number of elements in sequences generated
- hsize_t *off; OUT: Array of offsets
- size_t *len; OUT: Array of lengths
+ herr_t H5S__hyper_proj_int_iterate(ss_span_info,sis_span_info,count,depth,udata)
+ const H5S_hyper_span_info_t *ss_span_info; IN: Span tree for source selection
+ const H5S_hyper_span_info_t *sis_span_info; IN: Span tree for source intersect selection
+ hsize_t count; IN: Number of times to compute the intersection of ss_span_info and sis_span_info
+ unsigned depth; IN: Depth of iteration (in terms of rank)
+ H5S_hyper_project_intersect_ud_t *udata; IN/OUT: Persistent shared data for iteration
RETURNS
Non-negative on success/Negative on failure.
DESCRIPTION
- Use the selection in the dataspace to generate a list of byte offsets and
- lengths for the region(s) selected. Start/Restart from the position in the
- ITER parameter. The number of sequences generated is limited by the MAXSEQ
- parameter and the number of sequences actually generated is stored in the
- NSEQ parameter.
+ Computes the intersection of ss_span_info and sis_span_info and projects it
+ to the projected space (held in udata). It accomplishes this by iterating
+ over both spaces and computing the number of elements to skip (in
+ ss_span_info) and the number of elements to add (the intersection) in a
+ sequential fashion (similar to run length encoding). As necessary, this
+ function both recurses into lower dimensions and calls
+ H5S__hyper_proj_int_build_proj to convert the skip/nelem pairs to the
+ projected span tree.
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
-H5S__hyper_get_seq_list_opt(const H5S_t *space, H5S_sel_iter_t *iter,
- size_t maxseq, size_t maxelem, size_t *nseq, size_t *nelem,
- hsize_t *off, size_t *len)
+H5S__hyper_proj_int_iterate(const H5S_hyper_span_info_t *ss_span_info,
+ const H5S_hyper_span_info_t *sis_span_info, hsize_t count, unsigned depth,
+ H5S_hyper_project_intersect_ud_t *udata)
{
- hsize_t *mem_size; /* Size of the source buffer */
- hsize_t slab[H5O_LAYOUT_NDIMS]; /* Hyperslab size */
- const hssize_t *sel_off; /* Selection offset in dataspace */
- hsize_t offset[H5O_LAYOUT_NDIMS]; /* Coordinate offset in dataspace */
- hsize_t tmp_count[H5O_LAYOUT_NDIMS];/* Temporary block count */
- hsize_t tmp_block[H5O_LAYOUT_NDIMS];/* Temporary block offset */
- hsize_t wrap[H5O_LAYOUT_NDIMS]; /* Bytes to wrap around at the end of a row */
- hsize_t skip[H5O_LAYOUT_NDIMS]; /* Bytes to skip between blocks */
- const H5S_hyper_dim_t *tdiminfo; /* Temporary pointer to diminfo information */
- hsize_t fast_dim_start, /* Local copies of fastest changing dimension info */
- fast_dim_stride,
- fast_dim_block,
- fast_dim_offset;
- size_t fast_dim_buf_off; /* Local copy of amount to move fastest dimension buffer offset */
- size_t fast_dim_count; /* Number of blocks left in fastest changing dimension */
- size_t tot_blk_count; /* Total number of blocks left to output */
- size_t act_blk_count; /* Actual number of blocks to output */
- size_t total_rows; /* Total number of entire rows to output */
- size_t curr_rows; /* Current number of entire rows to output */
- unsigned fast_dim; /* Rank of the fastest changing dimension for the dataspace */
- unsigned ndims; /* Number of dimensions of dataset */
- int temp_dim; /* Temporary rank holder */
- hsize_t acc; /* Accumulator */
- hsize_t loc; /* Coordinate offset */
- size_t curr_seq = 0; /* Current sequence being operated on */
- size_t actual_elem; /* The actual number of elements to count */
- size_t actual_bytes;/* The actual number of bytes to copy */
- size_t io_left; /* The number of elements left in I/O operation */
- size_t start_io_left; /* The initial number of elements left in I/O operation */
- size_t elem_size; /* Size of each element iterating over */
- unsigned u; /* Local index variable */
- int i; /* Local index variable */
-
- FUNC_ENTER_STATIC_NOERR
-
- /* Check args */
- HDassert(space);
- HDassert(iter);
- HDassert(maxseq > 0);
- HDassert(maxelem > 0);
- HDassert(nseq);
- HDassert(nelem);
- HDassert(off);
- HDassert(len);
-
- /* Set the local copy of the diminfo pointer */
- tdiminfo = iter->u.hyp.diminfo;
-
- /* Check if this is a "flattened" regular hyperslab selection */
- if(iter->u.hyp.iter_rank != 0 && iter->u.hyp.iter_rank < space->extent.rank) {
- /* Set the aliases for a few important dimension ranks */
- ndims = iter->u.hyp.iter_rank;
- fast_dim = ndims - 1;
-
- /* Set the local copy of the selection offset */
- sel_off = iter->u.hyp.sel_off;
-
- /* Set up the pointer to the size of the memory space */
- mem_size = iter->u.hyp.size;
- } /* end if */
- else {
- /* Set the aliases for a few important dimension ranks */
- ndims = space->extent.rank;
- fast_dim = ndims - 1;
-
- /* Set the local copy of the selection offset */
- sel_off = space->select.offset;
-
- /* Set up the pointer to the size of the memory space */
- mem_size = space->extent.size;
- } /* end else */
-
- /* initialize row sizes for each dimension */
- elem_size = iter->elmt_size;
- for(i = (int)fast_dim, acc = elem_size; i >= 0; i--) {
- slab[i] = acc;
- acc *= mem_size[i];
- } /* end for */
-
- /* Calculate the number of elements to sequence through */
- H5_CHECK_OVERFLOW(iter->elmt_left, hsize_t, size_t);
- io_left = MIN((size_t)iter->elmt_left, maxelem);
-
- /* Sanity check that there aren't any "remainder" sequences in process */
- HDassert(!((iter->u.hyp.off[fast_dim] - tdiminfo[fast_dim].start) % tdiminfo[fast_dim].stride != 0 ||
- ((iter->u.hyp.off[fast_dim] != tdiminfo[fast_dim].start) && tdiminfo[fast_dim].count == 1)));
-
- /* We've cleared the "remainder" of the previous fastest dimension
- * sequence before calling this routine, so we must be at the beginning of
- * a sequence. Use the fancy algorithm to compute the offsets and run
- * through as many as possible, until the buffer fills up.
- */
-
- /* Keep the number of elements we started with */
- start_io_left = io_left;
-
- /* Compute the arrays to perform I/O on */
+ const H5S_hyper_span_t *ss_span; /* Current span in source space */
+ const H5S_hyper_span_t *sis_span; /* Current span in source intersect space */
+ hsize_t ss_low; /* Current low bounds of source span */
+ hsize_t sis_low; /* Current low bounds of source intersect span */
+ hsize_t high; /* High bounds of current intersection */
+ hsize_t low; /* Low bounds of current intersection */
+ hsize_t old_skip; /* Value of udata->skip before main loop */
+ hsize_t old_nelem; /* Value of udata->nelem before main loop */
+ hbool_t check_intersect; /* Whether to check for intersecting elements */
+ unsigned u; /* Local index variable */
+ herr_t ret_value = SUCCEED; /* Return value */
- /* Copy the location of the point to get */
- /* (Add in the selection offset) */
- for(u = 0; u < ndims; u++)
- offset[u] = (hsize_t)((hssize_t)iter->u.hyp.off[u] + sel_off[u]);
+ FUNC_ENTER_STATIC
- /* Compute the current "counts" for this location */
- for(u = 0; u < ndims; u++) {
- if(tdiminfo[u].count == 1) {
- tmp_count[u] = 0;
- tmp_block[u] = iter->u.hyp.off[u] - tdiminfo[u].start;
+ /* Check for non-overlapping bounds */
+ check_intersect = TRUE;
+ for(u = 0; u < (udata->ss_rank - depth); u++)
+ if(!H5S_RANGE_OVERLAP(ss_span_info->low_bounds[u],
+ ss_span_info->high_bounds[u],
+ sis_span_info->low_bounds[u],
+ sis_span_info->high_bounds[u])) {
+ check_intersect = FALSE;
+ break;
} /* end if */
- else {
- tmp_count[u] = (iter->u.hyp.off[u] - tdiminfo[u].start) / tdiminfo[u].stride;
- tmp_block[u] = (iter->u.hyp.off[u] - tdiminfo[u].start) % tdiminfo[u].stride;
- } /* end else */
- } /* end for */
-
- /* Compute the initial buffer offset */
- for(u = 0, loc = 0; u < ndims; u++)
- loc += offset[u] * slab[u];
-
- /* Set the number of elements to write each time */
- H5_CHECKED_ASSIGN(actual_elem, size_t, tdiminfo[fast_dim].block, hsize_t);
-
- /* Set the number of actual bytes */
- actual_bytes = actual_elem * elem_size;
-
- /* Set local copies of information for the fastest changing dimension */
- fast_dim_start = tdiminfo[fast_dim].start;
- fast_dim_stride = tdiminfo[fast_dim].stride;
- fast_dim_block = tdiminfo[fast_dim].block;
- H5_CHECKED_ASSIGN(fast_dim_buf_off, size_t, slab[fast_dim] * fast_dim_stride, hsize_t);
- fast_dim_offset = (hsize_t)((hssize_t)fast_dim_start + sel_off[fast_dim]);
-
- /* Compute the number of blocks which would fit into the buffer */
- H5_CHECK_OVERFLOW(io_left / fast_dim_block, hsize_t, size_t);
- tot_blk_count = (size_t)(io_left / fast_dim_block);
-
- /* Don't go over the maximum number of sequences allowed */
- tot_blk_count = MIN(tot_blk_count, (maxseq - curr_seq));
-
- /* Compute the amount to wrap at the end of each row */
- for(u = 0; u < ndims; u++)
- wrap[u] = (mem_size[u] - (tdiminfo[u].stride * tdiminfo[u].count)) * slab[u];
-
- /* Compute the amount to skip between blocks */
- for(u = 0; u < ndims; u++)
- skip[u] = (tdiminfo[u].stride - tdiminfo[u].block) * slab[u];
- /* Check if there is a partial row left (with full blocks) */
- if(tmp_count[fast_dim] > 0) {
- /* Get number of blocks in fastest dimension */
- H5_CHECKED_ASSIGN(fast_dim_count, size_t, tdiminfo[fast_dim].count - tmp_count[fast_dim], hsize_t);
+ /* Only enter main loop if there's something to do */
+ if(check_intersect) {
+ /* Set ps_clean_bitmap */
+ udata->ps_clean_bitmap |= (((uint32_t)1) << depth);
- /* Make certain this entire row will fit into buffer */
- fast_dim_count = MIN(fast_dim_count, tot_blk_count);
+ /* Save old skip and nelem */
+ old_skip = udata->skip;
+ old_nelem = udata->nelem;
- /* Number of blocks to sequence over */
- act_blk_count = fast_dim_count;
-
- /* Loop over all the blocks in the fastest changing dimension */
- while(fast_dim_count > 0) {
- /* Store the sequence information */
- off[curr_seq] = loc;
- len[curr_seq] = actual_bytes;
-
- /* Increment sequence count */
- curr_seq++;
+ /* Intersect spaces once per count */
+ for(u = 0; u < count; u++) {
+ ss_span = ss_span_info->head;
+ sis_span = sis_span_info->head;
+ HDassert(ss_span && sis_span);
+ ss_low = ss_span->low;
+ sis_low = sis_span->low;
- /* Increment information to reflect block just processed */
- loc += fast_dim_buf_off;
-
- /* Decrement number of blocks */
- fast_dim_count--;
- } /* end while */
-
- /* Decrement number of elements left */
- io_left -= actual_elem * act_blk_count;
-
- /* Decrement number of blocks left */
- tot_blk_count -= act_blk_count;
-
- /* Increment information to reflect block just processed */
- tmp_count[fast_dim] += act_blk_count;
+ /* Main loop */
+ do {
+ /* Check if spans overlap */
+ if(H5S_RANGE_OVERLAP(ss_low, ss_span->high,
+ sis_low, sis_span->high)) {
+ high = MIN(ss_span->high, sis_span->high);
+ if(ss_span->down) {
+ /* Add skipped elements if there's a pre-gap */
+ if(ss_low < sis_low) {
+ low = sis_low;
+ H5S_HYPER_PROJ_INT_ADD_SKIP(udata, H5S__hyper_spans_nelem_helper(ss_span->down, udata->op_gen) * (sis_low - ss_low), FAIL);
+ } /* end if */
+ else
+ low = ss_low;
- /* Check if we finished the entire row of blocks */
- if(tmp_count[fast_dim] >= tdiminfo[fast_dim].count) {
- /* Increment offset in destination buffer */
- loc += wrap[fast_dim];
+ /* Recurse into next dimension down */
+ if(H5S__hyper_proj_int_iterate(ss_span->down, sis_span->down, high - low + 1, depth + 1, udata) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOMPARE, FAIL, "can't iterate over source selections")
+ } /* end if */
+ else {
+ HDassert(depth == udata->ss_rank - 1);
- /* Increment information to reflect block just processed */
- offset[fast_dim] = fast_dim_offset; /* reset the offset in the fastest dimension */
- tmp_count[fast_dim] = 0;
+ /* Add skipped elements if there's a pre-gap */
+ if(ss_low < sis_low) {
+ low = sis_low;
+ H5S_HYPER_PROJ_INT_ADD_SKIP(udata, sis_low - ss_low, FAIL);
+ } /* end if */
+ else
+ low = ss_low;
- /* Increment the offset and count for the other dimensions */
- temp_dim = (int)fast_dim - 1;
- while(temp_dim >= 0) {
- /* Move to the next row in the curent dimension */
- offset[temp_dim]++;
- tmp_block[temp_dim]++;
+ /* Add overlapping elements */
+ udata->nelem += high - low + 1;
+ } /* end else */
- /* If this block is still in the range of blocks to output for the dimension, break out of loop */
- if(tmp_block[temp_dim] < tdiminfo[temp_dim].block)
- break;
+ /* Advance spans */
+ if(ss_span->high == sis_span->high) {
+ /* Advance both spans */
+ ss_span = ss_span->next;
+ if(ss_span)
+ ss_low = ss_span->low;
+ sis_span = sis_span->next;
+ if(sis_span)
+ sis_low = sis_span->low;
+ } /* end if */
+ else if(ss_span->high == high) {
+ /* Advance source span */
+ HDassert(ss_span->high < sis_span->high);
+ sis_low = high + 1;
+ ss_span = ss_span->next;
+ if(ss_span)
+ ss_low = ss_span->low;
+ } /* end if */
+ else {
+ /* Advance source intersect span */
+ HDassert(ss_span->high > sis_span->high);
+ ss_low = high + 1;
+ sis_span = sis_span->next;
+ if(sis_span)
+ sis_low = sis_span->low;
+ } /* end else */
+ } /* end if */
else {
- /* Move to the next block in the current dimension */
- offset[temp_dim] += (tdiminfo[temp_dim].stride - tdiminfo[temp_dim].block);
- loc += skip[temp_dim];
- tmp_block[temp_dim] = 0;
- tmp_count[temp_dim]++;
+ /* Advance spans */
+ if(ss_span->high < sis_low) {
+ /* Add skipped elements */
+ if(ss_span->down)
+ H5S_HYPER_PROJ_INT_ADD_SKIP(udata, H5S__hyper_spans_nelem_helper(ss_span->down, udata->op_gen) * (ss_span->high - ss_low + 1), FAIL);
+ else
+ H5S_HYPER_PROJ_INT_ADD_SKIP(udata, ss_span->high - ss_low + 1, FAIL);
- /* If this block is still in the range of blocks to output for the dimension, break out of loop */
- if(tmp_count[temp_dim] < tdiminfo[temp_dim].count)
- break;
+ /* Advance source span */
+ ss_span = ss_span->next;
+ if(ss_span)
+ ss_low = ss_span->low;
+ } /* end if */
else {
- offset[temp_dim] = (hsize_t)((hssize_t)tdiminfo[temp_dim].start + sel_off[temp_dim]);
- loc += wrap[temp_dim];
- tmp_count[temp_dim] = 0; /* reset back to the beginning of the line */
- tmp_block[temp_dim] = 0;
+ /* Advance source intersect span */
+ HDassert(ss_low > sis_span->high);
+ sis_span = sis_span->next;
+ if(sis_span)
+ sis_low = sis_span->low;
} /* end else */
} /* end else */
-
- /* Decrement dimension count */
- temp_dim--;
- } /* end while */
- } /* end if */
- else {
- /* Update the offset in the fastest dimension */
- offset[fast_dim] += (fast_dim_stride * act_blk_count);
- } /* end else */
- } /* end if */
-
- /* Compute the number of entire rows to read in */
- H5_CHECK_OVERFLOW(tot_blk_count / tdiminfo[fast_dim].count, hsize_t, size_t);
- curr_rows = total_rows = (size_t)(tot_blk_count / tdiminfo[fast_dim].count);
-
- /* Reset copy of number of blocks in fastest dimension */
- H5_CHECKED_ASSIGN(fast_dim_count, size_t, tdiminfo[fast_dim].count, hsize_t);
-
- /* Read in data until an entire sequence can't be written out any longer */
- while(curr_rows > 0) {
-
-#define DUFF_GUTS \
-/* Store the sequence information */ \
-off[curr_seq] = loc; \
-len[curr_seq] = actual_bytes; \
- \
-/* Increment sequence count */ \
-curr_seq++; \
- \
-/* Increment information to reflect block just processed */ \
-loc += fast_dim_buf_off;
-
-#ifdef NO_DUFFS_DEVICE
- /* Loop over all the blocks in the fastest changing dimension */
- while(fast_dim_count > 0) {
- DUFF_GUTS
-
- /* Decrement number of blocks */
- fast_dim_count--;
- } /* end while */
-#else /* NO_DUFFS_DEVICE */
- {
- size_t duffs_index; /* Counting index for Duff's device */
-
- duffs_index = (fast_dim_count + 7) / 8;
- switch (fast_dim_count % 8) {
- default:
- HDassert(0 && "This Should never be executed!");
- break;
- case 0:
- do
- {
- DUFF_GUTS
- case 7:
- DUFF_GUTS
- case 6:
- DUFF_GUTS
- case 5:
- DUFF_GUTS
- case 4:
- DUFF_GUTS
- case 3:
- DUFF_GUTS
- case 2:
- DUFF_GUTS
- case 1:
- DUFF_GUTS
- } while (--duffs_index > 0);
- } /* end switch */
- }
-#endif /* NO_DUFFS_DEVICE */
-#undef DUFF_GUTS
-
- /* Increment offset in destination buffer */
- loc += wrap[fast_dim];
-
- /* Increment the offset and count for the other dimensions */
- temp_dim = (int)fast_dim - 1;
- while(temp_dim >= 0) {
- /* Move to the next row in the curent dimension */
- offset[temp_dim]++;
- tmp_block[temp_dim]++;
-
- /* If this block is still in the range of blocks to output for the dimension, break out of loop */
- if(tmp_block[temp_dim] < tdiminfo[temp_dim].block)
- break;
- else {
- /* Move to the next block in the current dimension */
- offset[temp_dim] += (tdiminfo[temp_dim].stride - tdiminfo[temp_dim].block);
- loc += skip[temp_dim];
- tmp_block[temp_dim] = 0;
- tmp_count[temp_dim]++;
-
- /* If this block is still in the range of blocks to output for the dimension, break out of loop */
- if(tmp_count[temp_dim] < tdiminfo[temp_dim].count)
- break;
+ } while(ss_span && sis_span);
+
+ if(ss_span && !((depth == 0) && (u == count - 1))) {
+ /* Count remaining elements in ss_span_info */
+ if(ss_span->down) {
+ H5S_HYPER_PROJ_INT_ADD_SKIP(udata, H5S__hyper_spans_nelem_helper(ss_span->down, udata->op_gen) * (ss_span->high - ss_low + 1), FAIL);
+ ss_span = ss_span->next;
+ while(ss_span) {
+ H5S_HYPER_PROJ_INT_ADD_SKIP(udata, H5S__hyper_spans_nelem_helper(ss_span->down, udata->op_gen) * (ss_span->high - ss_span->low + 1), FAIL);
+ ss_span = ss_span->next;
+ } /* end while */
+ } /* end if */
else {
- offset[temp_dim] = (hsize_t)((hssize_t)tdiminfo[temp_dim].start + sel_off[temp_dim]);
- loc += wrap[temp_dim];
- tmp_count[temp_dim] = 0; /* reset back to the beginning of the line */
- tmp_block[temp_dim] = 0;
+ H5S_HYPER_PROJ_INT_ADD_SKIP(udata, ss_span->high - ss_low + 1, FAIL);
+ ss_span = ss_span->next;
+ while(ss_span) {
+ H5S_HYPER_PROJ_INT_ADD_SKIP(udata, ss_span->high - ss_span->low + 1, FAIL);
+ ss_span = ss_span->next;
+ } /* end while */
} /* end else */
- } /* end else */
-
- /* Decrement dimension count */
- temp_dim--;
- } /* end while */
-
- /* Decrement the number of rows left */
- curr_rows--;
- } /* end while */
-
- /* Adjust the number of blocks & elements left to transfer */
-
- /* Decrement number of elements left */
- H5_CHECK_OVERFLOW(actual_elem * (total_rows * tdiminfo[fast_dim].count), hsize_t, size_t);
- io_left -= (size_t)(actual_elem * (total_rows * tdiminfo[fast_dim].count));
-
- /* Decrement number of blocks left */
- H5_CHECK_OVERFLOW((total_rows * tdiminfo[fast_dim].count), hsize_t, size_t);
- tot_blk_count -= (size_t)(total_rows * tdiminfo[fast_dim].count);
-
- /* Read in partial row of blocks */
- if(io_left > 0 && curr_seq < maxseq) {
- /* Get remaining number of blocks left to output */
- fast_dim_count = tot_blk_count;
-
- /* Loop over all the blocks in the fastest changing dimension */
- while(fast_dim_count > 0) {
- /* Store the sequence information */
- off[curr_seq] = loc;
- len[curr_seq] = actual_bytes;
-
- /* Increment sequence count */
- curr_seq++;
-
- /* Increment information to reflect block just processed */
- loc += fast_dim_buf_off;
-
- /* Decrement number of blocks */
- fast_dim_count--;
- } /* end while */
-
- /* Decrement number of elements left */
- io_left -= actual_elem * tot_blk_count;
-
- /* Increment information to reflect block just processed */
- offset[fast_dim] += (fast_dim_stride * tot_blk_count); /* move the offset in the fastest dimension */
-
- /* Handle any leftover, partial blocks in this row */
- if(io_left > 0 && curr_seq < maxseq) {
- actual_elem = io_left;
- actual_bytes = actual_elem * elem_size;
-
- /* Store the sequence information */
- off[curr_seq] = loc;
- len[curr_seq] = actual_bytes;
-
- /* Increment sequence count */
- curr_seq++;
-
- /* Decrement the number of elements left */
- io_left -= actual_elem;
-
- /* Increment buffer correctly */
- offset[fast_dim] += actual_elem;
- } /* end if */
-
- /* don't bother checking slower dimensions */
- HDassert(io_left == 0 || curr_seq == maxseq);
- } /* end if */
-
- /* Update the iterator */
-
- /* Update the iterator with the location we stopped */
- /* (Subtract out the selection offset) */
- for(u = 0; u < ndims; u++)
- iter->u.hyp.off[u] = (hsize_t)((hssize_t)offset[u] - sel_off[u]);
-
- /* Decrement the number of elements left in selection */
- iter->elmt_left -= (start_io_left - io_left);
-
- /* Increment the number of sequences generated */
- *nseq += curr_seq;
-
- /* Increment the number of elements used */
- *nelem += start_io_left - io_left;
-
- FUNC_LEAVE_NOAPI(SUCCEED)
-} /* end H5S__hyper_get_seq_list_opt() */
-
-
-/*--------------------------------------------------------------------------
- NAME
- H5S__hyper_get_seq_list_single
- PURPOSE
- Create a list of offsets & lengths for a selection
- USAGE
- herr_t H5S__hyper_get_seq_list_single(space, flags, iter, maxseq, maxelem, nseq, nelem, off, len)
- H5S_t *space; IN: Dataspace containing selection to use.
- unsigned flags; IN: Flags for extra information about operation
- H5S_sel_iter_t *iter; IN/OUT: Selection iterator describing last
- position of interest in selection.
- size_t maxseq; IN: Maximum number of sequences to generate
- size_t maxelem; IN: Maximum number of elements to include in the
- generated sequences
- size_t *nseq; OUT: Actual number of sequences generated
- size_t *nelem; OUT: Actual number of elements in sequences generated
- hsize_t *off; OUT: Array of offsets
- size_t *len; OUT: Array of lengths
- RETURNS
- Non-negative on success/Negative on failure.
- DESCRIPTION
- Use the selection in the dataspace to generate a list of byte offsets and
- lengths for the region(s) selected. Start/Restart from the position in the
- ITER parameter. The number of sequences generated is limited by the MAXSEQ
- parameter and the number of sequences actually generated is stored in the
- NSEQ parameter.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-static herr_t
-H5S__hyper_get_seq_list_single(const H5S_t *space, H5S_sel_iter_t *iter,
- size_t maxseq, size_t maxelem, size_t *nseq, size_t *nelem,
- hsize_t *off, size_t *len)
-{
- const H5S_hyper_dim_t *tdiminfo; /* Temporary pointer to diminfo information */
- const hssize_t *sel_off; /* Selection offset in dataspace */
- hsize_t *mem_size; /* Size of the source buffer */
- hsize_t base_offset[H5O_LAYOUT_NDIMS]; /* Base coordinate offset in dataspace */
- hsize_t offset[H5O_LAYOUT_NDIMS]; /* Coordinate offset in dataspace */
- hsize_t slab[H5O_LAYOUT_NDIMS]; /* Hyperslab size */
- hsize_t fast_dim_block; /* Local copies of fastest changing dimension info */
- hsize_t acc; /* Accumulator */
- hsize_t loc; /* Coordinate offset */
- size_t tot_blk_count; /* Total number of blocks left to output */
- size_t elem_size; /* Size of each element iterating over */
- size_t io_left; /* The number of elements left in I/O operation */
- size_t actual_elem; /* The actual number of elements to count */
- unsigned ndims; /* Number of dimensions of dataset */
- unsigned fast_dim; /* Rank of the fastest changing dimension for the dataspace */
- unsigned skip_dim; /* Rank of the dimension to skip along */
- unsigned u; /* Local index variable */
- int i; /* Local index variable */
-
- FUNC_ENTER_STATIC_NOERR
-
- /* Check args */
- HDassert(space);
- HDassert(iter);
- HDassert(maxseq > 0);
- HDassert(maxelem > 0);
- HDassert(nseq);
- HDassert(nelem);
- HDassert(off);
- HDassert(len);
-
- /* Set a local copy of the diminfo pointer */
- tdiminfo = iter->u.hyp.diminfo;
-
- /* Check if this is a "flattened" regular hyperslab selection */
- if(iter->u.hyp.iter_rank != 0 && iter->u.hyp.iter_rank < space->extent.rank) {
- /* Set the aliases for a few important dimension ranks */
- ndims = iter->u.hyp.iter_rank;
-
- /* Set the local copy of the selection offset */
- sel_off = iter->u.hyp.sel_off;
-
- /* Set up the pointer to the size of the memory space */
- mem_size = iter->u.hyp.size;
- } /* end if */
- else {
- /* Set the aliases for a few important dimension ranks */
- ndims = space->extent.rank;
-
- /* Set the local copy of the selection offset */
- sel_off = space->select.offset;
-
- /* Set up the pointer to the size of the memory space */
- mem_size = space->extent.size;
- } /* end else */
- fast_dim = ndims - 1;
-
- /* initialize row sizes for each dimension */
- elem_size = iter->elmt_size;
- for(i = (int)fast_dim, acc = elem_size; i >= 0; i--) {
- slab[i] = acc;
- acc *= mem_size[i];
- } /* end for */
-
- /* Copy the base location of the block */
- /* (Add in the selection offset) */
- for(u = 0; u < ndims; u++)
- base_offset[u] = (hsize_t)((hssize_t)tdiminfo[u].start + sel_off[u]);
-
- /* Copy the location of the point to get */
- /* (Add in the selection offset) */
- for(u = 0; u < ndims; u++)
- offset[u] = (hsize_t)((hssize_t)iter->u.hyp.off[u] + sel_off[u]);
-
- /* Compute the initial buffer offset */
- for(u = 0, loc = 0; u < ndims; u++)
- loc += offset[u] * slab[u];
-
- /* Set local copies of information for the fastest changing dimension */
- fast_dim_block = tdiminfo[fast_dim].block;
-
- /* Calculate the number of elements to sequence through */
- H5_CHECK_OVERFLOW(iter->elmt_left, hsize_t, size_t);
- io_left = MIN((size_t)iter->elmt_left, maxelem);
-
- /* Compute the number of blocks which would fit into the buffer */
- H5_CHECK_OVERFLOW(io_left / fast_dim_block, hsize_t, size_t);
- tot_blk_count = (size_t)(io_left / fast_dim_block);
-
- /* Don't go over the maximum number of sequences allowed */
- tot_blk_count = MIN(tot_blk_count, maxseq);
-
- /* Set the number of elements to write each time */
- H5_CHECKED_ASSIGN(actual_elem, size_t, fast_dim_block, hsize_t);
-
- /* Check for blocks to operate on */
- if(tot_blk_count > 0) {
- size_t actual_bytes; /* The actual number of bytes to copy */
-
- /* Set the number of actual bytes */
- actual_bytes = actual_elem * elem_size;
-
- /* Check for 1-dim selection */
- if(0 == fast_dim) {
- /* Sanity checks */
- HDassert(1 == tot_blk_count);
- HDassert(io_left == actual_elem);
-
- /* Store the sequence information */
- *off++ = loc;
- *len++ = actual_bytes;
- } /* end if */
- else {
- hsize_t skip_slab; /* Temporary copy of slab[fast_dim - 1] */
- size_t blk_count; /* Total number of blocks left to output */
+ } /* end if */
- /* Find first dimension w/block >1 */
- skip_dim = fast_dim;
- for(i = (int)(fast_dim - 1); i >= 0; i--)
- if(tdiminfo[i].block > 1) {
- skip_dim = (unsigned)i;
- break;
+ /* Check if the projected space was not changed since we started the
+ * first iteration of the loop, if so we do not need to continue
+ * looping and can just copy the result */
+ if(udata->ps_clean_bitmap & (((uint32_t)1) << depth)) {
+ HDassert(u == 0);
+ if(udata->skip == old_skip) {
+ /* First case: algorithm added only elements */
+ HDassert(udata->nelem >= old_nelem);
+ udata->nelem += (count - 1) * (udata->nelem - old_nelem);
} /* end if */
- skip_slab = slab[skip_dim];
-
- /* Check for being able to use fast algorithm for 1-D */
- if(0 == skip_dim) {
- /* Create sequences until an entire row can't be used */
- blk_count = tot_blk_count;
- while(blk_count > 0) {
- /* Store the sequence information */
- *off++ = loc;
- *len++ = actual_bytes;
-
- /* Increment offset in destination buffer */
- loc += skip_slab;
-
- /* Decrement block count */
- blk_count--;
- } /* end while */
+ else if(udata->nelem == 0) {
+ /* Second case: algorithm added only skip. In this case,
+ * nelem must be 0 since otherwise adding skip would have
+ * triggered a change in the projected space */
+ HDassert(old_nelem == 0);
+ HDassert(udata->skip > old_skip);
+ udata->skip += (count - 1) * (udata->skip - old_skip);
+ } /* end if */
+ else {
+ /* Third case: agorithm added skip and nelem (in that
+ * order). Add the same skip and nelem once for each item
+ * remaining in count. */
+ hsize_t skip_add;
+ hsize_t nelem_add;
+
+ HDassert(udata->nelem > 0);
+ HDassert(udata->skip > old_skip);
+ HDassert(old_nelem == 0);
+
+ skip_add = udata->skip - old_skip;
+ nelem_add = udata->nelem - old_nelem;
+ for(u = 1; u < count; u++) {
+ H5S_HYPER_PROJ_INT_ADD_SKIP(udata, skip_add, FAIL);
+ udata->nelem += nelem_add;
+ } /* end for */
+ } /* end else */
- /* Move to the next location */
- offset[skip_dim] += tot_blk_count;
+ /* End loop since we already took care of it */
+ break;
} /* end if */
- else {
- hsize_t tmp_block[H5O_LAYOUT_NDIMS];/* Temporary block offset */
- hsize_t skip[H5O_LAYOUT_NDIMS]; /* Bytes to skip between blocks */
- int temp_dim; /* Temporary rank holder */
-
- /* Set the starting block location */
- for(u = 0; u < ndims; u++)
- tmp_block[u] = iter->u.hyp.off[u] - tdiminfo[u].start;
-
- /* Compute the amount to skip between sequences */
- for(u = 0; u < ndims; u++)
- skip[u] = (mem_size[u] - tdiminfo[u].block) * slab[u];
-
- /* Create sequences until an entire row can't be used */
- blk_count = tot_blk_count;
- while(blk_count > 0) {
- /* Store the sequence information */
- *off++ = loc;
- *len++ = actual_bytes;
-
- /* Set temporary dimension for advancing offsets */
- temp_dim = (int)skip_dim;
-
- /* Increment offset in destination buffer */
- loc += skip_slab;
-
- /* Increment the offset and count for the other dimensions */
- while(temp_dim >= 0) {
- /* Move to the next row in the curent dimension */
- offset[temp_dim]++;
- tmp_block[temp_dim]++;
-
- /* If this block is still in the range of blocks to output for the dimension, break out of loop */
- if(tmp_block[temp_dim] < tdiminfo[temp_dim].block)
- break;
- else {
- offset[temp_dim] = base_offset[temp_dim];
- loc += skip[temp_dim];
- tmp_block[temp_dim] = 0;
- } /* end else */
-
- /* Decrement dimension count */
- temp_dim--;
- } /* end while */
-
- /* Decrement block count */
- blk_count--;
- } /* end while */
- } /* end else */
- } /* end else */
-
- /* Update the iterator, if there were any blocks used */
-
- /* Decrement the number of elements left in selection */
- iter->elmt_left -= tot_blk_count * actual_elem;
-
- /* Check if there are elements left in iterator */
- if(iter->elmt_left > 0) {
- /* Update the iterator with the location we stopped */
- /* (Subtract out the selection offset) */
- for(u = 0; u < ndims; u++)
- iter->u.hyp.off[u] = (hsize_t)((hssize_t)offset[u] - sel_off[u]);
- } /* end if */
-
- /* Increment the number of sequences generated */
- *nseq += tot_blk_count;
-
- /* Increment the number of elements used */
- *nelem += tot_blk_count * actual_elem;
- } /* end if */
-
- /* Check for partial block, with room for another sequence */
- if(io_left > (tot_blk_count * actual_elem) && tot_blk_count < maxseq) {
- size_t elmt_remainder; /* Elements remaining */
-
- /* Compute elements left */
- elmt_remainder = io_left - (tot_blk_count * actual_elem);
- HDassert(elmt_remainder < fast_dim_block);
- HDassert(elmt_remainder > 0);
-
- /* Store the sequence information */
- *off++ = loc;
- *len++ = elmt_remainder * elem_size;
-
- /* Update the iterator with the location we stopped */
- iter->u.hyp.off[fast_dim] += (hsize_t)elmt_remainder;
-
- /* Decrement the number of elements left in selection */
- iter->elmt_left -= elmt_remainder;
-
- /* Increment the number of sequences generated */
- (*nseq)++;
-
- /* Increment the number of elements used */
- *nelem += elmt_remainder;
+ } /* end for */
} /* end if */
-
- /* Sanity check */
- HDassert(*nseq > 0);
- HDassert(*nelem > 0);
-
- FUNC_LEAVE_NOAPI(SUCCEED)
-} /* end H5S__hyper_get_seq_list_single() */
-
-
-/*--------------------------------------------------------------------------
- NAME
- H5S__hyper_get_seq_list
- PURPOSE
- Create a list of offsets & lengths for a selection
- USAGE
- herr_t H5S__hyper_get_seq_list(space,flags,iter,maxseq,maxelem,nseq,nelem,off,len)
- H5S_t *space; IN: Dataspace containing selection to use.
- unsigned flags; IN: Flags for extra information about operation
- H5S_sel_iter_t *iter; IN/OUT: Selection iterator describing last
- position of interest in selection.
- size_t maxseq; IN: Maximum number of sequences to generate
- size_t maxelem; IN: Maximum number of elements to include in the
- generated sequences
- size_t *nseq; OUT: Actual number of sequences generated
- size_t *nelem; OUT: Actual number of elements in sequences generated
- hsize_t *off; OUT: Array of offsets
- size_t *len; OUT: Array of lengths
- RETURNS
- Non-negative on success/Negative on failure.
- DESCRIPTION
- Use the selection in the dataspace to generate a list of byte offsets and
- lengths for the region(s) selected. Start/Restart from the position in the
- ITER parameter. The number of sequences generated is limited by the MAXSEQ
- parameter and the number of sequences actually generated is stored in the
- NSEQ parameter.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-static herr_t
-H5S__hyper_get_seq_list(const H5S_t *space, unsigned H5_ATTR_UNUSED flags, H5S_sel_iter_t *iter,
- size_t maxseq, size_t maxelem, size_t *nseq, size_t *nelem,
- hsize_t *off, size_t *len)
-{
- herr_t ret_value = FAIL; /* return value */
-
- FUNC_ENTER_STATIC_NOERR
-
- /* Check args */
- HDassert(space);
- HDassert(iter);
- HDassert(iter->elmt_left > 0);
- HDassert(maxseq > 0);
- HDassert(maxelem > 0);
- HDassert(nseq);
- HDassert(nelem);
- HDassert(off);
- HDassert(len);
- HDassert(space->select.sel_info.hslab->unlim_dim < 0);
-
- /* Check for the special case of just one H5Sselect_hyperslab call made */
- if(space->select.sel_info.hslab->diminfo_valid) {
- const H5S_hyper_dim_t *tdiminfo; /* Temporary pointer to diminfo information */
- const hssize_t *sel_off; /* Selection offset in dataspace */
- hsize_t *mem_size; /* Size of the source buffer */
- unsigned ndims; /* Number of dimensions of dataset */
- unsigned fast_dim; /* Rank of the fastest changing dimension for the dataspace */
- hbool_t single_block; /* Whether the selection is a single block */
- unsigned u; /* Local index variable */
-
- /* Set a local copy of the diminfo pointer */
- tdiminfo = iter->u.hyp.diminfo;
-
- /* Check if this is a "flattened" regular hyperslab selection */
- if(iter->u.hyp.iter_rank != 0 && iter->u.hyp.iter_rank < space->extent.rank) {
- /* Set the aliases for a few important dimension ranks */
- ndims = iter->u.hyp.iter_rank;
-
- /* Set the local copy of the selection offset */
- sel_off = iter->u.hyp.sel_off;
-
- /* Set up the pointer to the size of the memory space */
- mem_size = iter->u.hyp.size;
- } /* end if */
- else {
- /* Set the aliases for a few important dimension ranks */
- ndims = space->extent.rank;
-
- /* Set the local copy of the selection offset */
- sel_off = space->select.offset;
-
- /* Set up the pointer to the size of the memory space */
- mem_size = space->extent.size;
- } /* end else */
- fast_dim = ndims - 1;
-
- /* Check if we stopped in the middle of a sequence of elements */
- if((iter->u.hyp.off[fast_dim] - tdiminfo[fast_dim].start) % tdiminfo[fast_dim].stride != 0 ||
- ((iter->u.hyp.off[fast_dim] != tdiminfo[fast_dim].start) && tdiminfo[fast_dim].count == 1)) {
- hsize_t slab[H5O_LAYOUT_NDIMS]; /* Hyperslab size */
- hsize_t loc; /* Coordinate offset */
- hsize_t acc; /* Accumulator */
- size_t leftover; /* The number of elements left over from the last sequence */
- size_t actual_elem; /* The actual number of elements to count */
- size_t elem_size; /* Size of each element iterating over */
- int i; /* Local index variable */
-
-
- /* Calculate the number of elements left in the sequence */
- if(tdiminfo[fast_dim].count == 1) {
- H5_CHECKED_ASSIGN(leftover, size_t, tdiminfo[fast_dim].block - (iter->u.hyp.off[fast_dim] - tdiminfo[fast_dim].start), hsize_t);
+ else if(depth > 0)
+ /* Just count skipped elements */
+ H5S_HYPER_PROJ_INT_ADD_SKIP(udata, H5S__hyper_spans_nelem_helper((H5S_hyper_span_info_t *)ss_span_info, udata->op_gen) * count, FAIL); /* Casting away const OK -NAF */
+
+ /* Clean up if we are done */
+ if(depth == 0) {
+ /* Add remaining elements */
+ if(udata->nelem > 0)
+ if(H5S__hyper_proj_int_build_proj(udata) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't add elements to projected selection")
+
+ /* Append remaining span trees */
+ for(u = udata->ds_rank - 1; u > 0; u--)
+ if(udata->ps_span_info[u]) {
+ if(H5S__hyper_append_span(&udata->ps_span_info[u - 1],
+ udata->ds_rank - u + 1, udata->ds_low[u - 1],
+ udata->ds_low[u - 1],
+ udata->ps_span_info[u]) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
+ H5S__hyper_free_span_info(udata->ps_span_info[u]);
+ udata->ps_span_info[u] = NULL;
} /* end if */
- else {
- H5_CHECKED_ASSIGN(leftover, size_t, tdiminfo[fast_dim].block - ((iter->u.hyp.off[fast_dim] - tdiminfo[fast_dim].start) % tdiminfo[fast_dim].stride), hsize_t);
- } /* end else */
-
- /* Make certain that we don't write too many */
- actual_elem = MIN3(leftover, (size_t)iter->elmt_left, maxelem);
-
- /* Initialize row sizes for each dimension */
- elem_size = iter->elmt_size;
- for(i = (int)fast_dim, acc = elem_size; i >= 0; i--) {
- slab[i] = acc;
- acc *= mem_size[i];
- } /* end for */
-
- /* Compute the initial buffer offset */
- for(u = 0, loc = 0; u < ndims; u++)
- loc += ((hsize_t)((hssize_t)iter->u.hyp.off[u] + sel_off[u])) * slab[u];
-
- /* Add a new sequence */
- off[0] = loc;
- H5_CHECKED_ASSIGN(len[0], size_t, actual_elem * elem_size, hsize_t);
-
- /* Increment sequence array locations */
- off++;
- len++;
-
- /* Advance the hyperslab iterator */
- H5S__hyper_iter_next(iter, actual_elem);
-
- /* Decrement the number of elements left in selection */
- iter->elmt_left -= actual_elem;
-
- /* Decrement element/sequence limits */
- maxelem -= actual_elem;
- maxseq--;
-
- /* Set the number of sequences generated and elements used */
- *nseq = 1;
- *nelem = actual_elem;
-
- /* Check for using up all the sequences/elements */
- if(0 == iter->elmt_left || 0 == maxelem || 0 == maxseq)
- return(SUCCEED);
- } /* end if */
- else {
- /* Reset the number of sequences generated and elements used */
- *nseq = 0;
- *nelem = 0;
- } /* end else */
-
- /* Check for a single block selected */
- single_block = TRUE;
- for(u = 0; u < ndims; u++)
- if(1 != tdiminfo[u].count) {
- single_block = FALSE;
- break;
- } /* end if */
-
- /* Check for single block selection */
- if(single_block)
- /* Use single-block optimized call to generate sequence list */
- ret_value = H5S__hyper_get_seq_list_single(space, iter, maxseq, maxelem, nseq, nelem, off, len);
- else
- /* Use optimized call to generate sequence list */
- ret_value = H5S__hyper_get_seq_list_opt(space, iter, maxseq, maxelem, nseq, nelem, off, len);
} /* end if */
- else
- /* Call the general sequence generator routine */
- ret_value = H5S__hyper_get_seq_list_gen(space, iter, maxseq, maxelem, nseq, nelem, off, len);
+done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5S__hyper_get_seq_list() */
+} /* end H5S__hyper_proj_int_iterate() */
/*--------------------------------------------------------------------------
@@ -9249,11 +11373,12 @@ H5S__hyper_get_seq_list(const H5S_t *space, unsigned H5_ATTR_UNUSED flags, H5S_s
DESCRIPTION
Projects the intersection of of the selections of src_space and
src_intersect_space within the selection of src_space as a selection
- within the selection of dst_space. The result is placed in the
- selection of proj_space. Note src_space, dst_space, and
- src_intersect_space do not need to use hyperslab selections, but they
- cannot use point selections. The result is always a hyperslab
- selection.
+ within the selection of dst_space. The result is placed in the selection
+ of proj_space. Note src_space, dst_space, and src_intersect_space do not
+ need to use hyperslab selections, but they cannot use point selections.
+ The result is always a hyperslab or none selection. Note also that
+ proj_space can share some span trees with dst_space, so proj_space
+ must not be subsequently modified if dst_space must be preserved.
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
EXAMPLES
@@ -9263,46 +11388,11 @@ herr_t
H5S__hyper_project_intersection(const H5S_t *src_space, const H5S_t *dst_space,
const H5S_t *src_intersect_space, H5S_t *proj_space)
{
- hsize_t ss_off[H5S_PROJECT_INTERSECT_NSEQS]; /* Offset array for src_space */
- size_t ss_len[H5S_PROJECT_INTERSECT_NSEQS]; /* Length array for src_space */
- size_t ss_nseq; /* Number of sequences for src_space */
- size_t ss_nelem; /* Number of elements for src_space */
- size_t ss_i = (size_t)0; /* Index into offset/length arrays for src_space */
- hbool_t advance_ss = FALSE; /* Whether to advance ss_i on the next iteration */
- H5S_sel_iter_t *ss_iter = NULL; /* Selection iterator for src_space */
- hbool_t ss_iter_init = FALSE; /* Whether ss_iter is initialized */
- hsize_t ss_sel_off = (hsize_t)0; /* Offset within src_space selection */
- hsize_t ds_off[H5S_PROJECT_INTERSECT_NSEQS]; /* Offset array for dst_space */
- size_t ds_len[H5S_PROJECT_INTERSECT_NSEQS]; /* Length array for dst_space */
- size_t ds_nseq; /* Number of sequences for dst_space */
- size_t ds_nelem; /* Number of elements for dst_space */
- size_t ds_i = (size_t)0; /* Index into offset/length arrays for dst_space */
- H5S_sel_iter_t *ds_iter = NULL; /* Selection iterator for dst_space */
- hbool_t ds_iter_init = FALSE; /* Whether ds_iter is initialized */
- hsize_t ds_sel_off = (hsize_t)0; /* Offset within dst_space selection */
- hsize_t sis_off[H5S_PROJECT_INTERSECT_NSEQS]; /* Offset array for src_intersect_space */
- size_t sis_len[H5S_PROJECT_INTERSECT_NSEQS]; /* Length array for src_intersect_space */
- size_t sis_nseq; /* Number of sequences for src_intersect_space */
- size_t sis_nelem; /* Number of elements for src_intersect_space */
- size_t sis_i = (size_t)0; /* Index into offset/length arrays for src_intersect_space */
- hbool_t advance_sis = FALSE; /* Whether to advance sis_i on the next iteration */
- H5S_sel_iter_t *sis_iter = NULL; /* Selection iterator for src_intersect_space */
- hbool_t sis_iter_init = FALSE; /* Whether sis_iter is initialized */
- hsize_t int_sel_off; /* Offset within intersected selections (ss/sis and ds/ps) */
- size_t int_len; /* Length of segment in intersected selections */
- hsize_t proj_off; /* Segment offset in proj_space */
- size_t proj_len; /* Segment length in proj_space */
- size_t proj_len_rem; /* Remaining length in proj_space for segment */
- hsize_t proj_down_dims[H5S_MAX_RANK]; /* "Down" dimensions in proj_space */
- H5S_hyper_span_info_t *curr_span_tree[H5S_MAX_RANK]; /* Current span tree being built (in each dimension) */
- H5S_hyper_span_t *prev_span[H5S_MAX_RANK]; /* Previous span in tree (in each dimension) */
- hsize_t curr_span_up_dim[H5S_MAX_RANK]; /* "Up" dimensions for current span */
- unsigned proj_rank; /* Rank of proj_space */
- hsize_t low; /* Low value of span */
- hsize_t high; /* High value of span */
- size_t span_len; /* Length of span */
- size_t nelem; /* Number of elements returned for get_seq_list op */
- unsigned i; /* Local index variable */
+ H5S_hyper_project_intersect_ud_t udata; /* User data for subroutines */
+ const H5S_hyper_span_info_t *ss_span_info;
+ const H5S_hyper_span_info_t *ds_span_info;
+ H5S_hyper_span_info_t *ss_span_info_buf = NULL;
+ H5S_hyper_span_info_t *ds_span_info_buf = NULL;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
@@ -9312,295 +11402,99 @@ H5S__hyper_project_intersection(const H5S_t *src_space, const H5S_t *dst_space,
HDassert(dst_space);
HDassert(src_intersect_space);
HDassert(proj_space);
-
+
/* Assert that src_space and src_intersect_space have same extent and there
* are no point selections */
HDassert(H5S_GET_EXTENT_NDIMS(src_space) == H5S_GET_EXTENT_NDIMS(src_intersect_space));
- HDassert(!HDmemcmp(src_space->extent.size, src_intersect_space->extent.size,
- (size_t)H5S_GET_EXTENT_NDIMS(src_space) * sizeof(src_space->extent.size[0])));
+ HDassert(H5S_GET_SELECT_NPOINTS(src_space) == H5S_GET_SELECT_NPOINTS(dst_space));
HDassert(H5S_GET_SELECT_TYPE(src_space) != H5S_SEL_POINTS);
HDassert(H5S_GET_SELECT_TYPE(dst_space) != H5S_SEL_POINTS);
- HDassert(H5S_GET_SELECT_TYPE(src_intersect_space) != H5S_SEL_POINTS);
-
- /* Initialize prev_space, curr_span_tree, and curr_span_up_dim */
- HDmemset(curr_span_tree, 0, sizeof(curr_span_tree));
- HDmemset(prev_span, 0, sizeof(prev_span));
- HDmemset(curr_span_up_dim, 0, sizeof(curr_span_up_dim));
-
- /* Save rank of projected space */
- proj_rank = proj_space->extent.rank;
- HDassert(proj_rank > 0);
+ HDassert(H5S_GET_SELECT_TYPE(src_intersect_space) == H5S_SEL_HYPERSLABS);
- /* Get numbers of elements */
- ss_nelem = (size_t)H5S_GET_SELECT_NPOINTS(src_space);
- ds_nelem = (size_t)H5S_GET_SELECT_NPOINTS(dst_space);
- sis_nelem = (size_t)H5S_GET_SELECT_NPOINTS(src_intersect_space);
- HDassert(ss_nelem == ds_nelem);
+ /* Set up ss_span_info */
+ if(H5S_GET_SELECT_TYPE(src_space) == H5S_SEL_HYPERSLABS) {
+ /* Make certain the selection has a span tree */
+ if(NULL == src_space->select.sel_info.hslab->span_lst)
+ if(H5S__hyper_generate_spans((H5S_t *)src_space) < 0) /* Casting away const OK -NAF */
+ HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "can't construct span tree for source hyperslab selection")
- /* Calculate proj_down_dims */
- if(H5VM_array_down(proj_rank, proj_space->extent.size, proj_down_dims) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "can't compute 'down' chunk size value")
-
- /* Remove current selection from proj_space */
- if(H5S_SELECT_RELEASE(proj_space) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release selection")
-
- /* If any selections are empty, skip to the end so "none" is selected */
- if((ss_nelem == 0) || (ds_nelem == 0) || (sis_nelem == 0))
- goto loop_end;
-
- /* Allocate space for the hyperslab selection information (note this sets
- * diminfo_valid to FALSE, diminfo arrays to 0, and span list to NULL) */
- if(NULL == (proj_space->select.sel_info.hslab = H5FL_CALLOC(H5S_hyper_sel_t)))
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab info")
-
- /* Set selection type */
- proj_space->select.type = H5S_sel_hyper;
-
- /* Set unlim_dim */
- proj_space->select.sel_info.hslab->unlim_dim = -1;
-
- /* Allocate the source selection iterator */
- if(NULL == (ss_iter = H5FL_MALLOC(H5S_sel_iter_t)))
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate source selection iterator")
-
- /* Initialize source space iterator */
- if(H5S_select_iter_init(ss_iter, src_space, (size_t)1) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator")
- ss_iter_init = TRUE;
-
- /* Get sequence list for source space */
- if(H5S_SELECT_GET_SEQ_LIST(src_space, 0u, ss_iter, H5S_PROJECT_INTERSECT_NSEQS, ss_nelem, &ss_nseq, &nelem, ss_off, ss_len) < 0)
- HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed")
- ss_nelem -= nelem;
- HDassert(ss_nseq > 0);
-
- /* Allocate the destination selection iterator */
- if(NULL == (ds_iter = H5FL_MALLOC(H5S_sel_iter_t)))
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate destination selection iterator")
-
- /* Initialize destination space iterator */
- if(H5S_select_iter_init(ds_iter, dst_space, (size_t)1) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator")
- ds_iter_init = TRUE;
-
- /* Get sequence list for destination space */
- if(H5S_SELECT_GET_SEQ_LIST(dst_space, 0u, ds_iter, H5S_PROJECT_INTERSECT_NSEQS, ds_nelem, &ds_nseq, &nelem, ds_off, ds_len) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator")
- ds_nelem -= nelem;
- HDassert(ds_nseq > 0);
-
- /* Allocate the source intersect space iterator */
- if(NULL == (sis_iter = H5FL_MALLOC(H5S_sel_iter_t)))
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate source intersect space iterator")
-
- /* Initialize source intersect space iterator */
- if(H5S_select_iter_init(sis_iter, src_intersect_space, (size_t)1) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator")
- sis_iter_init = TRUE;
-
- /* Get sequence list for source intersect space */
- if(H5S_SELECT_GET_SEQ_LIST(src_intersect_space, 0u, sis_iter, H5S_PROJECT_INTERSECT_NSEQS, sis_nelem, &sis_nseq, &nelem, sis_off, sis_len) < 0)
- HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed")
- sis_nelem -= nelem;
- HDassert(sis_nseq > 0);
-
- /* Loop until we run out of sequences in either the source or source
- * intersect space */
- while(1) {
- while(advance_ss || (ss_off[ss_i] + ss_len[ss_i] <= sis_off[sis_i])) {
- /* Either we finished the current source sequence or the
- * sequences do not intersect. Advance source space. */
- ss_sel_off += (hsize_t)ss_len[ss_i];
- if(++ss_i == ss_nseq) {
- if(ss_nelem > 0) {
- /* Try to grab more sequences from src_space */
- if(H5S_SELECT_GET_SEQ_LIST(src_space, 0u, ss_iter, H5S_PROJECT_INTERSECT_NSEQS, ss_nelem, &ss_nseq, &nelem, ss_off, ss_len) < 0)
- HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed")
- HDassert(ss_len[0] > 0);
-
- /* Update ss_nelem */
- HDassert(nelem > 0);
- HDassert(nelem <= ss_nelem);
- ss_nelem -= nelem;
-
- /* Reset source space index */
- ss_i = 0;
- } /* end if */
- else
- /* There are no more sequences in src_space, so we can exit
- * the loop. Use goto instead of break so we exit the outer
- * loop. */
- goto loop_end;
- } /* end if */
-
- /* Reset advance_ss */
- advance_ss = FALSE;
- } /* end while */
- if(advance_sis || (sis_off[sis_i] + sis_len[sis_i] <= ss_off[ss_i])) {
- do {
- /* Either we finished the current source intersect sequence or
- * the sequences do not intersect. Advance source intersect
- * space. */
- if(++sis_i == sis_nseq) {
- if(sis_nelem > 0) {
- /* Try to grab more sequences from src_intersect_space
- */
- if(H5S_SELECT_GET_SEQ_LIST(src_intersect_space, 0u, sis_iter, H5S_PROJECT_INTERSECT_NSEQS, sis_nelem, &sis_nseq, &nelem, sis_off, sis_len) < 0)
- HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed")
- HDassert(sis_len[0] > 0);
-
- /* Update ss_nelem */
- HDassert(nelem > 0);
- HDassert(nelem <= sis_nelem);
- sis_nelem -= nelem;
-
- /* Reset source space index */
- sis_i = 0;
- } /* end if */
- else
- /* There are no more sequences in src_intersect_space,
- * so we can exit the loop. Use goto instead of break
- * so we exit the outer loop. */
- goto loop_end;
- } /* end if */
- } while(sis_off[sis_i] + sis_len[sis_i] <= ss_off[ss_i]);
+ /* Simply point to existing span tree */
+ ss_span_info = src_space->select.sel_info.hslab->span_lst;
+ } /* end if */
+ else {
+ /* Create temporary span tree from all selection */
+ HDassert(H5S_GET_SELECT_TYPE(src_space) == H5S_SEL_ALL);
- /* Reset advance_sis */
- advance_sis = FALSE;
- } /* end if */
- else {
- /* Sequences intersect, add intersection to projected space */
- /* Calculate intersection sequence in terms of offset within source
- * selection and advance any sequences we complete */
- if(ss_off[ss_i] >= sis_off[sis_i])
- int_sel_off = ss_sel_off;
- else
- int_sel_off = sis_off[sis_i] - ss_off[ss_i] + ss_sel_off;
- if((ss_off[ss_i] + (hsize_t)ss_len[ss_i]) <= (sis_off[sis_i]
- + (hsize_t)sis_len[sis_i])) {
- int_len = (size_t)((hsize_t)ss_len[ss_i] + ss_sel_off - int_sel_off);
- advance_ss = TRUE;
- } /* end if */
- else
- int_len = (size_t)(sis_off[sis_i] + (hsize_t)sis_len[sis_i] - ss_off[ss_i] + ss_sel_off - int_sel_off);
- if((ss_off[ss_i] + (hsize_t)ss_len[ss_i]) >= (sis_off[sis_i]
- + (hsize_t)sis_len[sis_i]))
- advance_sis = TRUE;
-
- /* Project intersection sequence to destination selection */
- while(int_len > (size_t)0) {
- while(ds_sel_off + (hsize_t)ds_len[ds_i] <= int_sel_off) {
- /* Intersection is not projected to this destination
- * sequence, advance destination space */
- ds_sel_off += (hsize_t)ds_len[ds_i];
- if(++ds_i == ds_nseq) {
- HDassert(ds_nelem > 0);
-
- /* Try to grab more sequences from dst_space */
- if(H5S_SELECT_GET_SEQ_LIST(dst_space, 0u, ds_iter, H5S_PROJECT_INTERSECT_NSEQS, ds_nelem, &ds_nseq, &nelem, ds_off, ds_len) < 0)
- HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed")
- HDassert(ds_len[0] > 0);
-
- /* Update ss_nelem */
- HDassert(nelem > 0);
- HDassert(nelem <= ds_nelem);
- ds_nelem -= nelem;
-
- /* Reset source space index */
- ds_i = 0;
- } /* end if */
- } /* end while */
+ if(NULL == (ss_span_info_buf = H5S__hyper_make_spans(H5S_GET_EXTENT_NDIMS(src_space),
+ H5S_hyper_zeros_g, H5S_hyper_zeros_g, H5S_hyper_ones_g, src_space->extent.size)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't create span tree for ALL source space")
+ ss_span_info = ss_span_info_buf;
+ } /* end else */
- /* Add sequence to projected space */
- HDassert(ds_sel_off <= int_sel_off);
- proj_off = ds_off[ds_i] + int_sel_off - ds_sel_off;
- proj_len = proj_len_rem = (size_t)MIN(int_len,
- (size_t)(ds_sel_off + (hsize_t)ds_len[ds_i] - int_sel_off));
-
- /* Add to span tree */
- while(proj_len_rem > (size_t)0) {
- /* Check for more than one full row (in every dim) and
- * append multiple spans at once? -NAF */
- /* Append spans in higher dimensions if we're going ouside
- * the plane of the span currently being built (i.e. it's
- * finished being built) */
- for(i = proj_rank - 1; ((i > 0)
- && ((proj_off / proj_down_dims[i - 1])
- != curr_span_up_dim[i - 1])); i--) {
- if(curr_span_tree[i]) {
- HDassert(prev_span[i]);
-
- /* Append complete lower dimension span tree to
- * current dimension */
- low = curr_span_up_dim[i - 1] % proj_space->extent.size[i - 1];
- if(H5S__hyper_append_span(&prev_span[i - 1], &curr_span_tree[i - 1], low, low, curr_span_tree[i], NULL) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
+ /* Set up ds_span_info */
+ if(H5S_GET_SELECT_TYPE(dst_space) == H5S_SEL_HYPERSLABS) {
+ /* Make certain the selection has a span tree */
+ if(NULL == dst_space->select.sel_info.hslab->span_lst)
+ if(H5S__hyper_generate_spans((H5S_t *)dst_space) < 0) /* Casting away const OK -NAF */
+ HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "can't construct span tree for dsetination hyperslab selection")
- /* Reset lower dimension's span tree and previous
- * span since we just committed it and will start
- * over with a new one */
- if(H5S__hyper_free_span_info(curr_span_tree[i]) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "can't free span info")
- curr_span_tree[i] = NULL;
- prev_span[i] = NULL;
- } /* end if */
+ /* Simply point to existing span tree */
+ ds_span_info = dst_space->select.sel_info.hslab->span_lst;
+ } /* end if */
+ else {
+ /* Create temporary span tree from all selection */
+ HDassert(H5S_GET_SELECT_TYPE(dst_space) == H5S_SEL_ALL);
- /* Update curr_span_up_dim */
- curr_span_up_dim[i - 1] = proj_off / proj_down_dims[i - 1];
- } /* end for */
+ if(NULL == (ds_span_info_buf = H5S__hyper_make_spans(H5S_GET_EXTENT_NDIMS(dst_space),
+ H5S_hyper_zeros_g, H5S_hyper_zeros_g, H5S_hyper_ones_g, dst_space->extent.size)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't create span tree for ALL destination space")
+ ds_span_info = ds_span_info_buf;
+ } /* end else */
- /* Compute bounds for new span in lowest dimension */
- low = proj_off % proj_space->extent.size[proj_rank - 1];
- span_len = MIN(proj_len_rem,
- (size_t)(proj_space->extent.size[proj_rank - 1]
- - low));
- HDassert(proj_len_rem >= span_len);
- high = (low + (hsize_t)span_len) - (hsize_t)1;
+ /* Make certain the source intersect selection has a span tree */
+ if(NULL == src_intersect_space->select.sel_info.hslab->span_lst)
+ if(H5S__hyper_generate_spans((H5S_t *)src_intersect_space) < 0) /* Casting away const OK -NAF */
+ HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "can't construct span tree for source intersect hyperslab selection")
- /* Append span in lowest dimension */
- if(H5S__hyper_append_span(&prev_span[proj_rank - 1], &curr_span_tree[proj_rank - 1], low, high, NULL, NULL) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
+ /* Initialize udata */
+ HDmemset(&udata, 0, sizeof(udata));
+ udata.ds_span[0] = ds_span_info->head;
+ udata.ds_low[0] = udata.ds_span[0]->low;
+ udata.ss_rank = H5S_GET_EXTENT_NDIMS(src_space);
+ udata.ds_rank = H5S_GET_EXTENT_NDIMS(dst_space);
+ udata.op_gen = H5S__hyper_get_op_gen();
- /* Update remaining offset and length */
- proj_off += (hsize_t)span_len;
- proj_len_rem -= span_len;
- } /* end while */
+ /* Iterate over selections and build projected span tree */
+ if(H5S__hyper_proj_int_iterate(ss_span_info, src_intersect_space->select.sel_info.hslab->span_lst, 1, 0, &udata) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOMPARE, FAIL, "selection iteration failed")
- /* Update intersection sequence */
- int_sel_off += (hsize_t)proj_len;
- int_len -= proj_len;
- } /* end while */
- } /* end else */
- } /* end while */
+ /* Remove current selection from proj_space */
+ if(H5S_SELECT_RELEASE(proj_space) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release selection")
-loop_end:
- /* Add remaining spans to span tree */
- for(i = proj_rank - 1; i > 0; i--)
- if(curr_span_tree[i]) {
- HDassert(prev_span[i]);
+ /* Check for elements in projected space */
+ if(udata.ps_span_info[0]) {
+ /* Allocate space for the hyperslab selection information (note this sets
+ * diminfo_valid to FALSE, diminfo arrays to 0, and span list to NULL) */
+ if(NULL == (proj_space->select.sel_info.hslab = H5FL_CALLOC(H5S_hyper_sel_t)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab info")
- /* Append remaining span tree to higher dimension */
- low = curr_span_up_dim[i - 1] % proj_space->extent.size[i - 1];
- if(H5S__hyper_append_span(&prev_span[i - 1], &curr_span_tree[i - 1], low, low, curr_span_tree[i], NULL) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span")
+ /* Set selection type */
+ proj_space->select.type = H5S_sel_hyper;
- /* Reset span tree */
- if(H5S__hyper_free_span_info(curr_span_tree[i]) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "can't free span info")
- curr_span_tree[i] = NULL;
- } /* end if */
+ /* Set unlim_dim */
+ proj_space->select.sel_info.hslab->unlim_dim = -1;
- /* Add span tree to proj_space */
- if(curr_span_tree[0]) {
- proj_space->select.sel_info.hslab->span_lst = curr_span_tree[0];
- curr_span_tree[0] = NULL;
+ /* Set span tree */
+ proj_space->select.sel_info.hslab->span_lst = udata.ps_span_info[0];
+ udata.ps_span_info[0] = NULL;
/* Set the number of elements in current selection */
proj_space->select.num_elem = H5S__hyper_spans_nelem(proj_space->select.sel_info.hslab->span_lst);
- /* Attempt to rebuild "optimized" start/stride/count/block information.
- * from resulting hyperslab span tree */
+ /* Attempt to build "optimized" start/stride/count/block information
+ * from resulting hyperslab span tree.
+ */
H5S__hyper_rebuild(proj_space);
} /* end if */
else
@@ -9609,153 +11503,42 @@ loop_end:
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't convert selection")
done:
- /* Release source selection iterator */
- if(ss_iter_init && H5S_SELECT_ITER_RELEASE(ss_iter) < 0)
- HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator")
- if(ss_iter)
- ss_iter = H5FL_FREE(H5S_sel_iter_t, ss_iter);
-
- /* Release destination selection iterator */
- if(ds_iter_init && H5S_SELECT_ITER_RELEASE(ds_iter) < 0)
- HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator")
- if(ds_iter)
- ds_iter = H5FL_FREE(H5S_sel_iter_t, ds_iter);
-
- /* Release source intersect selection iterator */
- if(sis_iter_init && H5S_SELECT_ITER_RELEASE(sis_iter) < 0)
- HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator")
- if(sis_iter)
- sis_iter = H5FL_FREE(H5S_sel_iter_t, sis_iter);
+ /* Free ss_span_info_buf */
+ if(ss_span_info_buf) {
+ H5S__hyper_free_span_info(ss_span_info_buf);
+ ss_span_info_buf = NULL;
+ } /* end if */
+
+ /* Free ds_span_info_buf */
+ if(ds_span_info_buf) {
+ H5S__hyper_free_span_info(ds_span_info_buf);
+ ds_span_info_buf = NULL;
+ } /* end if */
/* Cleanup on error */
if(ret_value < 0) {
- /* Remove current selection from proj_space */
- if(H5S_SELECT_RELEASE(proj_space) < 0)
- HDONE_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release selection")
+ unsigned u;
/* Free span trees */
- for(i = 0; i < proj_rank; i++)
- if(curr_span_tree[i]) {
- if(H5S__hyper_free_span_info(curr_span_tree[i]) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "can't free span info")
- curr_span_tree[i] = NULL;
+ for(u = 0; u < udata.ds_rank; u++)
+ if(udata.ps_span_info[u]) {
+ H5S__hyper_free_span_info(udata.ps_span_info[u]);
+ udata.ps_span_info[u] = NULL;
} /* end if */
} /* end if */
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5S__hyper_project_intersection() */
-
-
-/*--------------------------------------------------------------------------
- NAME
- H5S__hyper_subtract
- PURPOSE
- Subtract one hyperslab selection from another
- USAGE
- herr_t H5S__hyper_subtract(space,subtract_space)
- H5S_t *space; IN/OUT: Selection to be operated on
- H5S_t *subtract_space; IN: Selection that will be subtracted from space
- RETURNS
- Non-negative on success/Negative on failure.
- DESCRIPTION
- Removes any and all portions of space that are also present in
- subtract_space. In essence, performs an A_NOT_B operation with the
- two selections.
-
- Note this function basically duplicates a subset of the functionality
- of H5S_select_select(). It should probably be removed when that
- function is enabled.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-herr_t
-H5S__hyper_subtract(H5S_t *space, H5S_t *subtract_space)
-{
- H5S_hyper_span_info_t *a_not_b = NULL; /* Span tree for hyperslab spans in old span tree and not in new span tree */
- H5S_hyper_span_info_t *a_and_b = NULL; /* Span tree for hyperslab spans in both old and new span trees */
- H5S_hyper_span_info_t *b_not_a = NULL; /* Span tree for hyperslab spans in new span tree and not in old span tree */
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI_NOINIT
-
- /* Check args */
- HDassert(space);
- HDassert(subtract_space);
-
- /* Check that the space selections both have span trees */
- if(space->select.sel_info.hslab->span_lst == NULL)
- if(H5S__hyper_generate_spans(space) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "dataspace does not have span tree")
- if(subtract_space->select.sel_info.hslab->span_lst == NULL)
- if(H5S__hyper_generate_spans(subtract_space) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "dataspace does not have span tree")
-
- /* Generate lists of spans which overlap and don't overlap */
- if(H5S__hyper_clip_spans(space->select.sel_info.hslab->span_lst, subtract_space->select.sel_info.hslab->span_lst, &a_not_b, &a_and_b, &b_not_a)<0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't clip hyperslab information")
-
- /* Reset the other dataspace selection information */
- if(H5S_SELECT_RELEASE(space) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release selection")
-
- /* Allocate space for the hyperslab selection information */
- if((space->select.sel_info.hslab = H5FL_CALLOC(H5S_hyper_sel_t)) == NULL)
- HGOTO_ERROR(H5E_DATASPACE, H5E_NOSPACE, FAIL, "can't allocate hyperslab info")
-
- /* Set unlim_dim */
- space->select.sel_info.hslab->unlim_dim = -1;
-
- /* Check for anything returned in a_not_b */
- if(a_not_b) {
- /* Update spans in space */
- space->select.sel_info.hslab->span_lst = a_not_b;
- a_not_b = NULL;
-
- /* Update number of elements */
- space->select.num_elem = H5S__hyper_spans_nelem(space->select.sel_info.hslab->span_lst);
-
- /* Attempt to rebuild "optimized" start/stride/count/block information.
- * from resulting hyperslab span tree */
- H5S__hyper_rebuild(space);
- } /* end if */
- else {
- H5S_hyper_span_info_t *spans; /* Empty hyperslab span tree */
-
- /* Set number of elements */
- space->select.num_elem = 0;
+#ifndef NDEBUG
+ /* Verify there are no more span trees */
+ {
+ unsigned u;
- /* Allocate a span info node */
- if(NULL == (spans = H5FL_MALLOC(H5S_hyper_span_info_t)))
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab span")
-
- /* Set the reference count */
- spans->count = 1;
-
- /* Reset the scratch pad space */
- spans->scratch = 0;
-
- /* Set to empty tree */
- spans->head = NULL;
-
- /* Set pointer to empty span tree */
- space->select.sel_info.hslab->span_lst = spans;
- } /* end if */
-
-done:
- /* Free span trees */
- if(a_and_b)
- H5S__hyper_free_span_info(a_and_b);
- if(b_not_a)
- H5S__hyper_free_span_info(b_not_a);
- if(a_not_b) {
- HDassert(ret_value < 0);
- H5S__hyper_free_span_info(b_not_a);
- } /* end if */
+ for(u = 0; u < H5S_MAX_RANK; u++)
+ HDassert(!udata.ps_span_info[u]);
+ } /* end block */
+#endif /* NDEBUG */
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5S__hyper_subtract() */
+} /* end H5S__hyper_project_intersection() */
/*--------------------------------------------------------------------------
@@ -9826,7 +11609,7 @@ H5S__hyper_get_clip_diminfo(hsize_t start, hsize_t stride, hsize_t *count,
RETURNS
Non-negative on success/Negative on failure.
DESCRIPTION
- This function changes the unlimited selection into a limited selection
+ This function changes the unlimited selection into a fixed-dimension selection
with the extent of the formerly unlimited dimension specified by clip_size.
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
@@ -9837,11 +11620,11 @@ H5S__hyper_get_clip_diminfo(hsize_t start, hsize_t stride, hsize_t *count,
herr_t
H5S_hyper_clip_unlim(H5S_t *space, hsize_t clip_size)
{
- H5S_hyper_sel_t *hslab; /* Convenience pointer to hyperslab info */
- hsize_t orig_count; /* Original count in unlimited dimension */
- int orig_unlim_dim; /* Original unliminted dimension */
- H5S_hyper_dim_t *diminfo; /* Convenience pointer to opt_diminfo in unlimited dimension */
- herr_t ret_value = SUCCEED;
+ H5S_hyper_sel_t *hslab = NULL; /* Convenience pointer to hyperslab info */
+ hsize_t orig_count; /* Original count in unlimited dimension */
+ int orig_unlim_dim; /* Original unliminted dimension */
+ H5S_hyper_dim_t *diminfo = NULL; /* Convenience pointer to diminfo.opt in unlimited dimension */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -9855,7 +11638,8 @@ H5S_hyper_clip_unlim(H5S_t *space, hsize_t clip_size)
/* Save original unlimited dimension */
orig_unlim_dim = hslab->unlim_dim;
- diminfo = &hslab->opt_diminfo[orig_unlim_dim];
+ /* Set up convenience pointer */
+ diminfo = &hslab->diminfo.opt[orig_unlim_dim];
/* Save original count in unlimited dimension */
orig_count = diminfo->count;
@@ -9871,14 +11655,18 @@ H5S_hyper_clip_unlim(H5S_t *space, hsize_t clip_size)
/* Convert to "none" selection */
if(H5S_select_none(space) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't convert selection")
+
+ /* Reset the convenience pointers */
+ hslab = NULL;
+ diminfo = NULL;
} /* end if */
/* Check for single block in unlimited dimension */
else if(orig_count == (hsize_t)1) {
/* Calculate number of elements */
space->select.num_elem = diminfo->block * hslab->num_elem_non_unlim;
- /* Mark that opt_diminfo is valid */
- hslab->diminfo_valid = TRUE;
+ /* Mark that diminfo.opt is valid */
+ hslab->diminfo_valid = H5S_DIMINFO_VALID_YES;
} /* end if */
else {
/* Calculate number of elements */
@@ -9891,7 +11679,7 @@ H5S_hyper_clip_unlim(H5S_t *space, hsize_t clip_size)
> (clip_size - diminfo->start)) {
hsize_t start[H5S_MAX_RANK];
hsize_t block[H5S_MAX_RANK];
- unsigned i;
+ unsigned u;
/* Last block is partial, need to construct compound selection */
/* Fill start with zeros */
@@ -9899,11 +11687,11 @@ H5S_hyper_clip_unlim(H5S_t *space, hsize_t clip_size)
/* Set block to clip_size in unlimited dimension, H5S_MAX_SIZE in
* others so only unlimited dimension is clipped */
- for(i = 0; i < space->extent.rank; i++)
- if((int)i == orig_unlim_dim)
- block[i] = clip_size;
+ for(u = 0; u < space->extent.rank; u++)
+ if((int)u == orig_unlim_dim)
+ block[u] = clip_size;
else
- block[i] = H5S_MAX_SIZE;
+ block[u] = H5S_MAX_SIZE;
/* Generate span tree in selection */
if(!hslab->span_lst)
@@ -9911,17 +11699,24 @@ H5S_hyper_clip_unlim(H5S_t *space, hsize_t clip_size)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to generate span tree")
/* Indicate that the regular dimensions are no longer valid */
- hslab->diminfo_valid = FALSE;
+ hslab->diminfo_valid = H5S_DIMINFO_VALID_NO;
/* "And" selection with calculated block to perform clip operation */
if(H5S__generate_hyperslab(space, H5S_SELECT_AND, start, H5S_hyper_ones_g, H5S_hyper_ones_g, block) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't generate hyperslabs")
} /* end if */
else
- /* Last block is complete, simply mark that opt_diminfo is valid */
- hslab->diminfo_valid = TRUE;
+ /* Last block is complete, simply mark that diminfo.opt is valid */
+ hslab->diminfo_valid = H5S_DIMINFO_VALID_YES;
} /* end else */
+ /* Update the upper bound, if the diminfo is valid */
+ if(hslab && (H5S_DIMINFO_VALID_YES == hslab->diminfo_valid))
+ hslab->diminfo.high_bounds[orig_unlim_dim] =
+ hslab->diminfo.opt[orig_unlim_dim].start +
+ hslab->diminfo.opt[orig_unlim_dim].stride * (hslab->diminfo.opt[orig_unlim_dim].count - 1) +
+ (hslab->diminfo.opt[orig_unlim_dim].block - 1);
+
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5S_hyper_clip_unlim() */
@@ -9970,7 +11765,7 @@ H5S__hyper_get_clip_extent_real(const H5S_t *clip_space, hsize_t num_slices,
HDassert(clip_space->select.sel_info.hslab);
HDassert(clip_space->select.sel_info.hslab->unlim_dim >= 0);
- diminfo = &clip_space->select.sel_info.hslab->opt_diminfo[clip_space->select.sel_info.hslab->unlim_dim];
+ diminfo = &clip_space->select.sel_info.hslab->diminfo.opt[clip_space->select.sel_info.hslab->unlim_dim];
if(num_slices == 0)
ret_value = incl_trail ? diminfo->start : 0;
@@ -10124,7 +11919,7 @@ H5S_hyper_get_clip_extent_match(const H5S_t *clip_space,
HDassert(clip_space->select.sel_info.hslab->num_elem_non_unlim
== match_space->select.sel_info.hslab->num_elem_non_unlim);
- match_diminfo = &match_space->select.sel_info.hslab->opt_diminfo[match_space->select.sel_info.hslab->unlim_dim];
+ match_diminfo = &match_space->select.sel_info.hslab->diminfo.opt[match_space->select.sel_info.hslab->unlim_dim];
/* Get initial count and block */
count = match_diminfo->count;
@@ -10188,13 +11983,13 @@ H5S_t *
H5S_hyper_get_unlim_block(const H5S_t *space, hsize_t block_index)
{
H5S_hyper_sel_t *hslab; /* Convenience pointer to hyperslab info */
- H5S_t *space_out = NULL;
- hsize_t start[H5S_MAX_RANK];
+ H5S_t *space_out = NULL; /* Dataspace to return */
+ hsize_t start[H5S_MAX_RANK];/* Hyperslab selection info for unlim. selection */
hsize_t stride[H5S_MAX_RANK];
hsize_t count[H5S_MAX_RANK];
hsize_t block[H5S_MAX_RANK];
- unsigned i;
- H5S_t *ret_value = NULL;
+ unsigned u; /* Local index variable */
+ H5S_t *ret_value = NULL; /* Return value */
FUNC_ENTER_NOAPI(NULL)
@@ -10203,29 +11998,29 @@ H5S_hyper_get_unlim_block(const H5S_t *space, hsize_t block_index)
hslab = space->select.sel_info.hslab;
HDassert(hslab);
HDassert(hslab->unlim_dim >= 0);
- HDassert(hslab->opt_diminfo[hslab->unlim_dim].count == H5S_UNLIMITED);
+ HDassert(hslab->diminfo.opt[hslab->unlim_dim].count == H5S_UNLIMITED);
/* Set start to select block_indexth block in unlimited dimension and set
* count to 1 in that dimension to only select that block. Copy all other
* diminfo parameters. */
- for(i = 0; i < space->extent.rank; i++) {
- if((int)i == hslab->unlim_dim){
- start[i] = hslab->opt_diminfo[i].start + (block_index
- * hslab->opt_diminfo[i].stride);
- count[i] = (hsize_t)1;
+ for(u = 0; u < space->extent.rank; u++) {
+ if((int)u == hslab->unlim_dim){
+ start[u] = hslab->diminfo.opt[u].start + (block_index
+ * hslab->diminfo.opt[u].stride);
+ count[u] = (hsize_t)1;
} /* end if */
else {
- start[i] = hslab->opt_diminfo[i].start;
- count[i] = hslab->opt_diminfo[i].count;
+ start[u] = hslab->diminfo.opt[u].start;
+ count[u] = hslab->diminfo.opt[u].count;
} /* end else */
- stride[i] = hslab->opt_diminfo[i].stride;
- block[i] = hslab->opt_diminfo[i].block;
+ stride[u] = hslab->diminfo.opt[u].stride;
+ block[u] = hslab->diminfo.opt[u].block;
} /* end for */
/* Create output space, copy extent */
if(NULL == (space_out = H5S_create(H5S_SIMPLE)))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, NULL, "unable to create output dataspace")
- if(H5S_extent_copy_real(&space_out->extent, &space->extent, TRUE) < 0)
+ if(H5S__extent_copy_real(&space_out->extent, &space->extent, TRUE) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "unable to copy destination space extent")
/* Select block as defined by start/stride/count/block computed above */
@@ -10274,7 +12069,7 @@ H5S_hyper_get_first_inc_block(const H5S_t *space, hsize_t clip_size,
hbool_t *partial)
{
H5S_hyper_sel_t *hslab; /* Convenience pointer to hyperslab info */
- H5S_hyper_dim_t *diminfo; /* Convenience pointer to opt_diminfo in unlimited dimension */
+ H5S_hyper_dim_t *diminfo; /* Convenience pointer to diminfo.opt in unlimited dimension */
hsize_t ret_value = 0;
FUNC_ENTER_NOAPI(0)
@@ -10284,9 +12079,9 @@ H5S_hyper_get_first_inc_block(const H5S_t *space, hsize_t clip_size,
hslab = space->select.sel_info.hslab;
HDassert(hslab);
HDassert(hslab->unlim_dim >= 0);
- HDassert(hslab->opt_diminfo[hslab->unlim_dim].count == H5S_UNLIMITED);
+ HDassert(hslab->diminfo.opt[hslab->unlim_dim].count == H5S_UNLIMITED);
- diminfo = &hslab->opt_diminfo[hslab->unlim_dim];
+ diminfo = &hslab->diminfo.opt[hslab->unlim_dim];
/* Check for selection outside of clip_size */
if(diminfo->start >= clip_size) {
@@ -10352,7 +12147,7 @@ H5Sis_regular_hyperslab(hid_t spaceid)
done:
FUNC_LEAVE_API(ret_value)
-} /* H5Sis_regular_hyperslab() */
+} /* end H5Sis_regular_hyperslab() */
/*--------------------------------------------------------------------------
@@ -10403,18 +12198,18 @@ H5Sget_regular_hyperslab(hid_t spaceid, hsize_t start[], hsize_t stride[],
/* Retrieve hyperslab parameters */
if(start)
for(u = 0; u < space->extent.rank; u++)
- start[u] = space->select.sel_info.hslab->app_diminfo[u].start;
+ start[u] = space->select.sel_info.hslab->diminfo.app[u].start;
if(stride)
for(u = 0; u < space->extent.rank; u++)
- stride[u] = space->select.sel_info.hslab->app_diminfo[u].stride;
+ stride[u] = space->select.sel_info.hslab->diminfo.app[u].stride;
if(count)
for(u = 0; u < space->extent.rank; u++)
- count[u] = space->select.sel_info.hslab->app_diminfo[u].count;
+ count[u] = space->select.sel_info.hslab->diminfo.app[u].count;
if(block)
for(u = 0; u < space->extent.rank; u++)
- block[u] = space->select.sel_info.hslab->app_diminfo[u].block;
+ block[u] = space->select.sel_info.hslab->diminfo.app[u].block;
done:
FUNC_LEAVE_API(ret_value)
-} /* H5Sget_regular_hyperslab() */
+} /* end H5Sget_regular_hyperslab() */
diff --git a/src/H5Smpio.c b/src/H5Smpio.c
index fce075e..35daed1 100644
--- a/src/H5Smpio.c
+++ b/src/H5Smpio.c
@@ -14,60 +14,104 @@
/*
* Programmer: rky 980813
*
- * Purpose: Functions to read/write directly between app buffer and file.
+ * Purpose: Create MPI data types for HDF5 selections.
*
- * Beware of the ifdef'ed print statements.
- * I didn't make them portable.
*/
+/****************/
+/* Module Setup */
+/****************/
+
#include "H5Smodule.h" /* This source code file is part of the H5S module */
+/***********/
+/* Headers */
+/***********/
#include "H5private.h" /* Generic Functions */
#include "H5Dprivate.h" /* Datasets */
#include "H5Eprivate.h" /* Error handling */
-#include "H5Fprivate.h" /* File access */
-#include "H5FDprivate.h" /* File drivers */
-#include "H5Iprivate.h" /* IDs */
+#include "H5FLprivate.h" /* Free Lists */
#include "H5MMprivate.h" /* Memory management */
-#include "H5Oprivate.h" /* Object headers */
-#include "H5Pprivate.h" /* Property lists */
#include "H5Spkg.h" /* Dataspaces */
#include "H5VMprivate.h" /* Vector and array functions */
#ifdef H5_HAVE_PARALLEL
-static herr_t H5S_mpio_all_type(const H5S_t *space, size_t elmt_size,
+/****************/
+/* Local Macros */
+/****************/
+#define H5S_MPIO_INITIAL_ALLOC_COUNT 256
+#define TWO_GIG_LIMIT 2147483648
+#ifndef H5S_MAX_MPI_COUNT
+#define H5S_MAX_MPI_COUNT 536870911 /* (2^29)-1 */
+#endif
+
+
+/******************/
+/* Local Typedefs */
+/******************/
+
+/* Node in linked list of MPI data types created during traversal of irregular hyperslab selection */
+typedef struct H5S_mpio_mpitype_node_t {
+ MPI_Datatype type; /* MPI Datatype */
+ struct H5S_mpio_mpitype_node_t *next; /* Pointer to next node in list */
+} H5S_mpio_mpitype_node_t;
+
+/* List to track MPI data types generated during traversal of irregular hyperslab selection */
+typedef struct H5S_mpio_mpitype_list_t {
+ H5S_mpio_mpitype_node_t *head; /* Pointer to head of list */
+ H5S_mpio_mpitype_node_t *tail; /* Pointer to tail of list */
+} H5S_mpio_mpitype_list_t;
+
+
+/********************/
+/* Local Prototypes */
+/********************/
+static herr_t H5S__mpio_all_type(const H5S_t *space, size_t elmt_size,
MPI_Datatype *new_type, int *count, hbool_t *is_derived_type);
-static herr_t H5S_mpio_none_type(MPI_Datatype *new_type, int *count,
+static herr_t H5S__mpio_none_type(MPI_Datatype *new_type, int *count,
hbool_t *is_derived_type);
-static herr_t H5S_mpio_create_point_datatype(size_t elmt_size, hsize_t num_points,
+static herr_t H5S__mpio_create_point_datatype(size_t elmt_size, hsize_t num_points,
MPI_Aint *disp, MPI_Datatype *new_type);
-static herr_t H5S_mpio_point_type(const H5S_t *space, size_t elmt_size,
+static herr_t H5S__mpio_point_type(const H5S_t *space, size_t elmt_size,
MPI_Datatype *new_type, int *count, hbool_t *is_derived_type,
hbool_t do_permute, hsize_t **permute_map, hbool_t *is_permuted);
-static herr_t H5S_mpio_permute_type(const H5S_t *space, size_t elmt_size,
+static herr_t H5S__mpio_permute_type(const H5S_t *space, size_t elmt_size,
hsize_t **permute_map, MPI_Datatype *new_type, int *count,
hbool_t *is_derived_type);
-static herr_t H5S_mpio_hyper_type(const H5S_t *space, size_t elmt_size,
+static herr_t H5S__mpio_reg_hyper_type(const H5S_t *space, size_t elmt_size,
MPI_Datatype *new_type, int *count, hbool_t *is_derived_type);
-static herr_t H5S_mpio_span_hyper_type(const H5S_t *space, size_t elmt_size,
+static herr_t H5S__mpio_span_hyper_type(const H5S_t *space, size_t elmt_size,
MPI_Datatype *new_type, int *count, hbool_t *is_derived_type);
-static herr_t H5S_obtain_datatype(const hsize_t down[], H5S_hyper_span_t* span,
- const MPI_Datatype *elmt_type, MPI_Datatype *span_type, size_t elmt_size);
-static herr_t H5S_mpio_create_large_type (hsize_t, MPI_Aint, MPI_Datatype , MPI_Datatype *);
+static herr_t H5S__release_datatype(H5S_mpio_mpitype_list_t *type_list);
+static herr_t H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down,
+ size_t elmt_size, const MPI_Datatype *elmt_type, MPI_Datatype *span_type,
+ H5S_mpio_mpitype_list_t *type_list, uint64_t op_gen);
+static herr_t H5S__mpio_create_large_type(hsize_t num_elements, MPI_Aint stride_bytes,
+ MPI_Datatype old_type, MPI_Datatype *new_type);
-#define H5S_MPIO_INITIAL_ALLOC_COUNT 256
+/*****************************/
+/* Library Private Variables */
+/*****************************/
-#define TWO_GIG_LIMIT 2147483648
-#ifndef H5S_MAX_MPI_COUNT
-#define H5S_MAX_MPI_COUNT 536870911 /* (2^29)-1 */
-#endif
+/*********************/
+/* Package Variables */
+/*********************/
+
+/*******************/
+/* Local Variables */
+/*******************/
static hsize_t bigio_count = H5S_MAX_MPI_COUNT;
+/* Declare a free list to manage the H5S_mpio_mpitype_node_t struct */
+H5FL_DEFINE_STATIC(H5S_mpio_mpitype_node_t);
+
+
+
/*-------------------------------------------------------------------------
* Function: H5S_mpio_set_bigio_count
*
@@ -75,7 +119,7 @@ static hsize_t bigio_count = H5S_MAX_MPI_COUNT;
* when we utilize derived datatypes. This is of
* particular interest for allowing nightly testing
*
- * Return: the current/previous value of bigio_count.
+ * Return: The current/previous value of bigio_count.
*
* Programmer: Richard Warren, March 10, 2017
*
@@ -85,19 +129,20 @@ hsize_t
H5S_mpio_set_bigio_count(hsize_t new_count)
{
hsize_t orig_count = bigio_count;
- if ((new_count > 0) && (new_count < TWO_GIG_LIMIT)) {
+
+ if((new_count > 0) && (new_count < TWO_GIG_LIMIT))
bigio_count = new_count;
- }
+
return orig_count;
-}
+} /* end H5S_mpio_set_bigio_count() */
/*-------------------------------------------------------------------------
- * Function: H5S_mpio_all_type
+ * Function: H5S__mpio_all_type
*
* Purpose: Translate an HDF5 "all" selection into an MPI type.
*
- * Return: non-negative on success, negative on failure.
+ * Return: Non-negative on success, negative on failure.
*
* Outputs: *new_type the MPI type corresponding to the selection
* *count how many objects of the new_type in selection
@@ -105,16 +150,11 @@ H5S_mpio_set_bigio_count(hsize_t new_count)
* *is_derived_type 0 if MPI primitive type, 1 if derived
*
* Programmer: rky 980813
- * Modifications:
- * Mohamad Chaarawi
- * Adding support for large datatypes (beyond the limit of a
- * 32 bit integer.
- *
*
*-------------------------------------------------------------------------
*/
static herr_t
-H5S_mpio_all_type(const H5S_t *space, size_t elmt_size,
+H5S__mpio_all_type(const H5S_t *space, size_t elmt_size,
MPI_Datatype *new_type, int *count, hbool_t *is_derived_type)
{
hsize_t total_bytes;
@@ -122,7 +162,7 @@ H5S_mpio_all_type(const H5S_t *space, size_t elmt_size,
hsize_t nelmts; /* Total number of elmts */
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_STATIC
/* Check args */
HDassert(space);
@@ -133,34 +173,33 @@ H5S_mpio_all_type(const H5S_t *space, size_t elmt_size,
H5_CHECKED_ASSIGN(nelmts, hsize_t, snelmts, hssize_t);
total_bytes = (hsize_t)elmt_size * nelmts;
+
/* Verify that the size can be expressed as a 32 bit integer */
if(bigio_count >= total_bytes) {
- /* fill in the return values */
- *new_type = MPI_BYTE;
- H5_CHECKED_ASSIGN(*count, int, total_bytes, hsize_t);
- *is_derived_type = FALSE;
- }
+ /* fill in the return values */
+ *new_type = MPI_BYTE;
+ H5_CHECKED_ASSIGN(*count, int, total_bytes, hsize_t);
+ *is_derived_type = FALSE;
+ } /* end if */
else {
- /* Create a LARGE derived datatype for this transfer */
- if (H5S_mpio_create_large_type (total_bytes, 0, MPI_BYTE, new_type) < 0) {
- HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL,
- "couldn't create a large datatype from the all selection")
- }
- *count = 1;
- *is_derived_type = TRUE;
- }
+ /* Create a LARGE derived datatype for this transfer */
+ if(H5S__mpio_create_large_type(total_bytes, 0, MPI_BYTE, new_type) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't create a large datatype from the all selection")
+ *count = 1;
+ *is_derived_type = TRUE;
+ } /* end else */
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_mpio_all_type() */
+} /* H5S__mpio_all_type() */
/*-------------------------------------------------------------------------
- * Function: H5S_mpio_none_type
+ * Function: H5S__mpio_none_type
*
* Purpose: Translate an HDF5 "none" selection into an MPI type.
*
- * Return: non-negative on success, negative on failure.
+ * Return: Non-negative on success, negative on failure.
*
* Outputs: *new_type the MPI type corresponding to the selection
* *count how many objects of the new_type in selection
@@ -172,9 +211,9 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5S_mpio_none_type(MPI_Datatype *new_type, int *count, hbool_t *is_derived_type)
+H5S__mpio_none_type(MPI_Datatype *new_type, int *count, hbool_t *is_derived_type)
{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
/* fill in the return values */
*new_type = MPI_BYTE;
@@ -182,15 +221,15 @@ H5S_mpio_none_type(MPI_Datatype *new_type, int *count, hbool_t *is_derived_type)
*is_derived_type = FALSE;
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5S_mpio_none_type() */
+} /* H5S__mpio_none_type() */
/*-------------------------------------------------------------------------
- * Function: H5S_mpio_create_point_datatype
+ * Function: H5S__mpio_create_point_datatype
*
* Purpose: Create a derived datatype for point selections.
*
- * Return: non-negative on success, negative on failure.
+ * Return: Non-negative on success, negative on failure.
*
* Outputs: *new_type the MPI type corresponding to the selection
*
@@ -198,18 +237,23 @@ H5S_mpio_none_type(MPI_Datatype *new_type, int *count, hbool_t *is_derived_type)
*
*-------------------------------------------------------------------------
*/
-static herr_t
-H5S_mpio_create_point_datatype (size_t elmt_size, hsize_t num_points,
- MPI_Aint *disp, MPI_Datatype *new_type)
+static herr_t
+H5S__mpio_create_point_datatype(size_t elmt_size, hsize_t num_points,
+ MPI_Aint *disp, MPI_Datatype *new_type)
{
MPI_Datatype elmt_type; /* MPI datatype for individual element */
hbool_t elmt_type_created = FALSE; /* Whether the element MPI datatype was created */
- int mpi_code; /* MPI error code */
+ int *inner_blocks = NULL; /* Arrays for MPI datatypes when "large" datatype needed */
+ MPI_Aint *inner_disps = NULL;
+ MPI_Datatype *inner_types = NULL;
+#if MPI_VERSION < 3
int *blocks = NULL; /* Array of block sizes for MPI hindexed create call */
hsize_t u; /* Local index variable */
+#endif
+ int mpi_code; /* MPI error code */
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_STATIC
/* Create an MPI datatype for an element */
if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous((int)elmt_size, MPI_BYTE, &elmt_type)))
@@ -219,146 +263,127 @@ H5S_mpio_create_point_datatype (size_t elmt_size, hsize_t num_points,
/* Check whether standard or BIGIO processing will be employeed */
if(bigio_count >= num_points) {
#if MPI_VERSION >= 3
- /* Create an MPI datatype for the whole point selection */
- if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed_block((int)num_points, 1, disp, elmt_type, new_type)))
- HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_indexed_block failed", mpi_code)
+ /* Create an MPI datatype for the whole point selection */
+ if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed_block((int)num_points, 1, disp, elmt_type, new_type)))
+ HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_indexed_block failed", mpi_code)
#else
- /* Allocate block sizes for MPI datatype call */
- if(NULL == (blocks = (int *)H5MM_malloc(sizeof(int) * num_points)))
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of blocks")
+ /* Allocate block sizes for MPI datatype call */
+ if(NULL == (blocks = (int *)H5MM_malloc(sizeof(int) * num_points)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of blocks")
- for(u = 0; u < num_points; u++)
- blocks[u] = 1;
+ for(u = 0; u < num_points; u++)
+ blocks[u] = 1;
- /* Create an MPI datatype for the whole point selection */
- if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed((int)num_points, blocks, disp, elmt_type, new_type)))
- HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed failed", mpi_code)
+ /* Create an MPI datatype for the whole point selection */
+ if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed((int)num_points, blocks, disp, elmt_type, new_type)))
+ HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed failed", mpi_code)
#endif
- /* Commit MPI datatype for later use */
- if(MPI_SUCCESS != (mpi_code = MPI_Type_commit(new_type)))
- HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code)
- }
- else {
- /* use LARGE_DATATYPE::
- * We'll create an hindexed_block type for every 2G point count and then combine
- * those and any remaining points into a single large datatype.
- */
- int total_types, i;
- int remaining_points;
- int num_big_types;
- hsize_t leftover;
-
- int *inner_blocks;
- MPI_Aint *inner_disps;
- MPI_Datatype *inner_types = NULL;
+ /* Commit MPI datatype for later use */
+ if(MPI_SUCCESS != (mpi_code = MPI_Type_commit(new_type)))
+ HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code)
+ } /* end if */
+ else {
+ /* use LARGE_DATATYPE::
+ * We'll create an hindexed_block type for every 2G point count and then combine
+ * those and any remaining points into a single large datatype.
+ */
+ int total_types, i;
+ int remaining_points;
+ int num_big_types;
+ hsize_t leftover;
- /* Calculate how many Big MPI datatypes are needed to represent the buffer */
- num_big_types = (int)(num_points/bigio_count);
+ /* Calculate how many Big MPI datatypes are needed to represent the buffer */
+ num_big_types = (int)(num_points / bigio_count);
- leftover = (hsize_t)num_points - (hsize_t)num_big_types * (hsize_t)bigio_count;
- H5_CHECKED_ASSIGN(remaining_points, int, leftover, hsize_t);
+ leftover = (hsize_t)num_points - (hsize_t)num_big_types * (hsize_t)bigio_count;
+ H5_CHECKED_ASSIGN(remaining_points, int, leftover, hsize_t);
- total_types = (int)(remaining_points) ? (num_big_types + 1) : num_big_types;
+ total_types = (int)(remaining_points) ? (num_big_types + 1) : num_big_types;
- /* Allocate array if MPI derived types needed */
- if(NULL == (inner_types = (MPI_Datatype *)H5MM_malloc((sizeof(MPI_Datatype) * (size_t)total_types))))
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of blocks")
+ /* Allocate array if MPI derived types needed */
+ if(NULL == (inner_types = (MPI_Datatype *)H5MM_malloc((sizeof(MPI_Datatype) * (size_t)total_types))))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of blocks")
- if(NULL == (inner_blocks = (int *)H5MM_malloc(sizeof(int) * (size_t)total_types)))
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of blocks")
+ if(NULL == (inner_blocks = (int *)H5MM_malloc(sizeof(int) * (size_t)total_types)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of blocks")
- if(NULL == (inner_disps = (MPI_Aint *)H5MM_malloc(sizeof(MPI_Aint) * (size_t)total_types)))
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of blocks")
+ if(NULL == (inner_disps = (MPI_Aint *)H5MM_malloc(sizeof(MPI_Aint) * (size_t)total_types)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of blocks")
#if MPI_VERSION < 3
- /* Allocate block sizes for MPI datatype call */
- if(NULL == (blocks = (int *)H5MM_malloc(sizeof(int) * bigio_count)))
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of blocks")
+ /* Allocate block sizes for MPI datatype call */
+ if(NULL == (blocks = (int *)H5MM_malloc(sizeof(int) * bigio_count)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of blocks")
- for(u = 0; u < bigio_count; u++)
- blocks[u] = 1;
+ for(u = 0; u < bigio_count; u++)
+ blocks[u] = 1;
#endif
- for(i=0 ; i<num_big_types ; i++) {
+ for(i = 0; i < num_big_types; i++) {
#if MPI_VERSION >= 3
- if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed_block(bigio_count,
- 1,
- &disp[i*bigio_count],
- elmt_type,
- &inner_types[i]))) {
- HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed_block failed", mpi_code);
- }
+ if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed_block(bigio_count,
+ 1, &disp[i*bigio_count], elmt_type, &inner_types[i])))
+ HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed_block failed", mpi_code)
#else
- if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed((int)bigio_count,
- blocks,
- &disp[i*bigio_count],
- elmt_type,
- &inner_types[i]))) {
- HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed failed", mpi_code)
- }
+ if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed((int)bigio_count,
+ blocks, &disp[i*bigio_count], elmt_type, &inner_types[i])))
+ HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed failed", mpi_code)
#endif
- inner_blocks[i] = 1;
- inner_disps[i] = 0;
- }
+ inner_blocks[i] = 1;
+ inner_disps[i] = 0;
+ } /* end for*/
- if(remaining_points) {
+ if(remaining_points) {
#if MPI_VERSION >= 3
- if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed_block(remaining_points,
- 1,
- &disp[num_big_types*bigio_count],
- elmt_type,
- &inner_types[num_big_types]))) {
- HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed_block failed", mpi_code);
- }
+ if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed_block(remaining_points,
+ 1, &disp[num_big_types*bigio_count], elmt_type, &inner_types[num_big_types])))
+ HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed_block failed", mpi_code)
#else
- if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed((int)remaining_points,
- blocks,
- &disp[num_big_types*bigio_count],
- elmt_type,
- &inner_types[num_big_types]))) {
- HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed failed", mpi_code)
- }
+ if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed((int)remaining_points,
+ blocks, &disp[num_big_types*bigio_count], elmt_type, &inner_types[num_big_types])))
+ HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed failed", mpi_code)
#endif
- inner_blocks[num_big_types] = 1;
- inner_disps[num_big_types] = 0;
- }
-
- if(MPI_SUCCESS != (mpi_code = MPI_Type_create_struct(total_types,
- inner_blocks,
- inner_disps,
- inner_types,
- new_type))) {
- HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_struct", mpi_code);
- }
- for(i=0 ; i<total_types ; i++)
- MPI_Type_free(&inner_types[i]);
-
- H5MM_free(inner_types);
- H5MM_free(inner_blocks);
- H5MM_free(inner_disps);
-
- /* Commit MPI datatype for later use */
- if(MPI_SUCCESS != (mpi_code = MPI_Type_commit(new_type)))
- HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code)
- }
+ inner_blocks[num_big_types] = 1;
+ inner_disps[num_big_types] = 0;
+ } /* end if */
+
+ if(MPI_SUCCESS != (mpi_code = MPI_Type_create_struct(total_types,
+ inner_blocks, inner_disps, inner_types, new_type)))
+ HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_struct", mpi_code)
+ for(i = 0; i < total_types; i++)
+ MPI_Type_free(&inner_types[i]);
+
+ /* Commit MPI datatype for later use */
+ if(MPI_SUCCESS != (mpi_code = MPI_Type_commit(new_type)))
+ HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code)
+ } /* end else */
+
done:
if(elmt_type_created)
MPI_Type_free(&elmt_type);
+#if MPI_VERSION < 3
if(blocks)
H5MM_free(blocks);
+#endif
+ if(inner_types)
+ H5MM_free(inner_types);
+ if(inner_blocks)
+ H5MM_free(inner_blocks);
+ if(inner_disps)
+ H5MM_free(inner_disps);
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_mpio_create_point_datatype() */
+} /* H5S__mpio_create_point_datatype() */
/*-------------------------------------------------------------------------
- * Function: H5S_mpio_point_type
+ * Function: H5S__mpio_point_type
*
* Purpose: Translate an HDF5 "point" selection into an MPI type.
* Create a permutation array to handle out-of-order point selections.
*
- * Return: non-negative on success, negative on failure.
+ * Return: Non-negative on success, negative on failure.
*
* Outputs: *new_type the MPI type corresponding to the selection
* *count how many objects of the new_type in selection
@@ -373,7 +398,7 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5S_mpio_point_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type,
+H5S__mpio_point_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type,
int *count, hbool_t *is_derived_type, hbool_t do_permute, hsize_t **permute,
hbool_t *is_permuted)
{
@@ -384,7 +409,7 @@ H5S_mpio_point_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type
hsize_t u; /* Local index variable */
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_STATIC
/* Check args */
HDassert(space);
@@ -406,23 +431,23 @@ H5S_mpio_point_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type
/* Iterate through list of elements */
curr = space->select.sel_info.pnt_lst->head;
for(u = 0 ; u < num_points ; u++) {
- /* calculate the displacement of the current point */
+ /* Calculate the displacement of the current point */
disp[u] = H5VM_array_offset(space->extent.rank, space->extent.size, curr->pnt);
disp[u] *= elmt_size;
- /* This is a File Space used to set the file view, so adjust the displacements
+ /* This is a File Space used to set the file view, so adjust the displacements
* to have them monotonically non-decreasing.
- * Generate the permutation array by indicating at each point being selected,
- * the position it will shifted in the new displacement. Example:
- * Suppose 4 points with corresponding are selected
- * Pt 1: disp=6 ; Pt 2: disp=3 ; Pt 3: disp=0 ; Pt 4: disp=4
+ * Generate the permutation array by indicating at each point being selected,
+ * the position it will shifted in the new displacement. Example:
+ * Suppose 4 points with corresponding are selected
+ * Pt 1: disp=6 ; Pt 2: disp=3 ; Pt 3: disp=0 ; Pt 4: disp=4
* The permute map to sort the displacements in order will be:
* point 1: map[0] = L, indicating that this point is not moved (1st point selected)
- * point 2: map[1] = 0, indicating that this point is moved to the first position,
+ * point 2: map[1] = 0, indicating that this point is moved to the first position,
* since disp_pt1(6) > disp_pt2(3)
- * point 3: map[2] = 0, move to position 0, bec it has the lowest disp between
+ * point 3: map[2] = 0, move to position 0, bec it has the lowest disp between
* the points selected so far.
- * point 4: map[3] = 2, move the 2nd position since point 1 has a higher disp,
+ * point 4: map[3] = 2, move the 2nd position since point 1 has a higher disp,
* but points 2 and 3 have lower displacements.
*/
if(do_permute) {
@@ -447,7 +472,7 @@ H5S_mpio_point_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type
HDmemmove(disp + m + 1, disp + m, (u - m) * sizeof(MPI_Aint));
disp[m] = temp;
} /* end if */
- (*permute)[u] = m;
+ (*permute)[u] = m;
} /* end if */
else
(*permute)[u] = num_points;
@@ -455,7 +480,7 @@ H5S_mpio_point_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type
/* this is a memory space, and no permutation is necessary to create
the derived datatype */
else {
- ;/* do nothing */
+ ; /* do nothing */
} /* end else */
/* get the next point */
@@ -463,7 +488,7 @@ H5S_mpio_point_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type
} /* end for */
/* Create the MPI datatype for the set of element displacements */
- if(H5S_mpio_create_point_datatype(elmt_size, num_points, disp, new_type) < 0)
+ if(H5S__mpio_create_point_datatype(elmt_size, num_points, disp, new_type) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't create an MPI Datatype from point selection")
/* Set values about MPI datatype created */
@@ -481,11 +506,11 @@ done:
} /* end if */
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_mpio_point_type() */
+} /* H5S__mpio_point_type() */
/*-------------------------------------------------------------------------
- * Function: H5S_mpio_permute_type
+ * Function: H5S__mpio_permute_type
*
* Purpose: Translate an HDF5 "all/hyper/point" selection into an MPI type,
* while applying the permutation map. This function is called if
@@ -496,7 +521,7 @@ done:
* Note: This routine is called from H5S_mpio_space_type(), which is
* called first for the file dataspace and creates
*
- * Return: non-negative on success, negative on failure.
+ * Return: Non-negative on success, negative on failure.
*
* Outputs: *new_type the MPI type corresponding to the selection
* *count how many objects of the new_type in selection
@@ -508,7 +533,7 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5S_mpio_permute_type(const H5S_t *space, size_t elmt_size, hsize_t **permute,
+H5S__mpio_permute_type(const H5S_t *space, size_t elmt_size, hsize_t **permute,
MPI_Datatype *new_type, int *count, hbool_t *is_derived_type)
{
MPI_Aint *disp = NULL; /* Datatype displacement for each point*/
@@ -520,7 +545,7 @@ H5S_mpio_permute_type(const H5S_t *space, size_t elmt_size, hsize_t **permute,
hsize_t u; /* Local index variable */
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_STATIC
/* Check args */
HDassert(space);
@@ -535,7 +560,7 @@ H5S_mpio_permute_type(const H5S_t *space, size_t elmt_size, hsize_t **permute,
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of displacements")
/* Initialize selection iterator */
- if(H5S_select_iter_init(&sel_iter, space, elmt_size) < 0)
+ if(H5S_select_iter_init(&sel_iter, space, elmt_size, 0) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator")
sel_iter_init = TRUE; /* Selection iteration info has been initialized */
@@ -552,7 +577,7 @@ H5S_mpio_permute_type(const H5S_t *space, size_t elmt_size, hsize_t **permute,
size_t curr_seq; /* Current sequence being worked on */
/* Get the sequences of bytes */
- if(H5S_SELECT_GET_SEQ_LIST(space, 0, &sel_iter, (size_t)H5D_IO_VECTOR_SIZE, max_elem, &nseq, &nelem, off, len) < 0)
+ if(H5S_SELECT_ITER_GET_SEQ_LIST(&sel_iter, (size_t)H5D_IO_VECTOR_SIZE, max_elem, &nseq, &nelem, off, len) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "sequence length generation failed")
/* Loop, while sequences left to process */
@@ -571,12 +596,12 @@ H5S_mpio_permute_type(const H5S_t *space, size_t elmt_size, hsize_t **permute,
/* Set the displacement of the current point */
disp[u] = curr_off;
- /* This is a memory displacement, so for each point selected,
+ /* This is a memory displacement, so for each point selected,
* apply the map that was generated by the file selection */
if((*permute)[u] != num_points) {
MPI_Aint temp = disp[u];
- HDmemmove(disp + (*permute)[u] + 1, disp + (*permute)[u],
+ HDmemmove(disp + (*permute)[u] + 1, disp + (*permute)[u],
(u - (*permute)[u]) * sizeof(MPI_Aint));
disp[(*permute)[u]] = temp;
} /* end if */
@@ -597,7 +622,7 @@ H5S_mpio_permute_type(const H5S_t *space, size_t elmt_size, hsize_t **permute,
} /* end while */
/* Create the MPI datatype for the set of element displacements */
- if(H5S_mpio_create_point_datatype(elmt_size, num_points, disp, new_type) < 0)
+ if(H5S__mpio_create_point_datatype(elmt_size, num_points, disp, new_type) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't create an MPI Datatype from point selection")
/* Set values about MPI datatype created */
@@ -619,15 +644,15 @@ done:
} /* end if */
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_mpio_permute_type() */
+} /* H5S__mpio_permute_type() */
/*-------------------------------------------------------------------------
- * Function: H5S_mpio_hyper_type
+ * Function: H5S__mpio_reg_hyper_type
*
- * Purpose: Translate an HDF5 hyperslab selection into an MPI type.
+ * Purpose: Translate a regular HDF5 hyperslab selection into an MPI type.
*
- * Return: non-negative on success, negative on failure.
+ * Return: Non-negative on success, negative on failure.
*
* Outputs: *new_type the MPI type corresponding to the selection
* *count how many objects of the new_type in selection
@@ -635,14 +660,11 @@ done:
* *is_derived_type 0 if MPI primitive type, 1 if derived
*
* Programmer: rky 980813
- * Modifications:
- * Mohamad Chaarawi
- * Adding support for large datatypes (beyond the limit of a
- * 32 bit integer.
+ *
*-------------------------------------------------------------------------
*/
static herr_t
-H5S_mpio_hyper_type(const H5S_t *space, size_t elmt_size,
+H5S__mpio_reg_hyper_type(const H5S_t *space, size_t elmt_size,
MPI_Datatype *new_type, int *count, hbool_t *is_derived_type)
{
H5S_sel_iter_t sel_iter; /* Selection iteration info */
@@ -668,14 +690,14 @@ H5S_mpio_hyper_type(const H5S_t *space, size_t elmt_size,
int mpi_code; /* MPI return code */
herr_t ret_value = SUCCEED;
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_STATIC
/* Check args */
HDassert(space);
HDassert(sizeof(MPI_Aint) >= sizeof(elmt_size));
/* Initialize selection iterator */
- if(H5S_select_iter_init(&sel_iter, space, elmt_size) < 0)
+ if(H5S_select_iter_init(&sel_iter, space, elmt_size, 0) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator")
sel_iter_init = TRUE; /* Selection iteration info has been initialized */
@@ -683,16 +705,15 @@ H5S_mpio_hyper_type(const H5S_t *space, size_t elmt_size,
diminfo = sel_iter.u.hyp.diminfo;
HDassert(diminfo);
- /* make a local copy of the dimension info so we can operate with them */
+ /* Make a local copy of the dimension info so we can operate with them */
/* Check if this is a "flattened" regular hyperslab selection */
if(sel_iter.u.hyp.iter_rank != 0 && sel_iter.u.hyp.iter_rank < space->extent.rank) {
/* Flattened selection */
rank = sel_iter.u.hyp.iter_rank;
- HDassert(rank <= H5S_MAX_RANK); /* within array bounds */
#ifdef H5S_DEBUG
- if(H5DEBUG(S))
- HDfprintf(H5DEBUG(S), "%s: Flattened selection\n",FUNC);
+if(H5DEBUG(S))
+ HDfprintf(H5DEBUG(S), "%s: Flattened selection\n",FUNC);
#endif
for(u = 0; u < rank; ++u) {
H5_CHECK_OVERFLOW(diminfo[u].start, hsize_t, hssize_t)
@@ -701,33 +722,30 @@ H5S_mpio_hyper_type(const H5S_t *space, size_t elmt_size,
d[u].block = diminfo[u].block;
d[u].count = diminfo[u].count;
d[u].xtent = sel_iter.u.hyp.size[u];
+
#ifdef H5S_DEBUG
- if(H5DEBUG(S)){
- HDfprintf(H5DEBUG(S), "%s: start=%Hd stride=%Hu count=%Hu block=%Hu xtent=%Hu",
- FUNC, d[u].start, d[u].strid, d[u].count, d[u].block, d[u].xtent );
- if (u==0)
- HDfprintf(H5DEBUG(S), " rank=%u\n", rank );
- else
- HDfprintf(H5DEBUG(S), "\n" );
- }
+if(H5DEBUG(S)) {
+ HDfprintf(H5DEBUG(S), "%s: start=%Hd stride=%Hu count=%Hu block=%Hu xtent=%Hu",
+ FUNC, d[u].start, d[u].strid, d[u].count, d[u].block, d[u].xtent);
+ if(u == 0)
+ HDfprintf(H5DEBUG(S), " rank=%u\n", rank);
+ else
+ HDfprintf(H5DEBUG(S), "\n");
+}
#endif
- if(0 == d[u].block)
- goto empty;
- if(0 == d[u].count)
- goto empty;
- if(0 == d[u].xtent)
- goto empty;
+
+ /* Sanity check */
+ HDassert(d[u].block > 0);
+ HDassert(d[u].count > 0);
+ HDassert(d[u].xtent > 0);
} /* end for */
} /* end if */
else {
/* Non-flattened selection */
rank = space->extent.rank;
- HDassert(rank <= H5S_MAX_RANK); /* within array bounds */
- if(0 == rank)
- goto empty;
#ifdef H5S_DEBUG
- if(H5DEBUG(S))
- HDfprintf(H5DEBUG(S),"%s: Non-flattened selection\n",FUNC);
+if(H5DEBUG(S))
+ HDfprintf(H5DEBUG(S),"%s: Non-flattened selection\n",FUNC);
#endif
for(u = 0; u < rank; ++u) {
H5_CHECK_OVERFLOW(diminfo[u].start, hsize_t, hssize_t)
@@ -736,22 +754,22 @@ H5S_mpio_hyper_type(const H5S_t *space, size_t elmt_size,
d[u].block = diminfo[u].block;
d[u].count = diminfo[u].count;
d[u].xtent = space->extent.size[u];
+
#ifdef H5S_DEBUG
- if(H5DEBUG(S)){
+if(H5DEBUG(S)) {
HDfprintf(H5DEBUG(S), "%s: start=%Hd stride=%Hu count=%Hu block=%Hu xtent=%Hu",
- FUNC, d[u].start, d[u].strid, d[u].count, d[u].block, d[u].xtent );
- if (u==0)
- HDfprintf(H5DEBUG(S), " rank=%u\n", rank );
+ FUNC, d[u].start, d[u].strid, d[u].count, d[u].block, d[u].xtent);
+ if(u == 0)
+ HDfprintf(H5DEBUG(S), " rank=%u\n", rank);
else
- HDfprintf(H5DEBUG(S), "\n" );
- }
+ HDfprintf(H5DEBUG(S), "\n");
+}
#endif
- if(0 == d[u].block)
- goto empty;
- if(0 == d[u].count)
- goto empty;
- if(0 == d[u].xtent)
- goto empty;
+
+ /* Sanity check */
+ HDassert(d[u].block > 0);
+ HDassert(d[u].count > 0);
+ HDassert(d[u].xtent > 0);
} /* end for */
} /* end else */
@@ -762,56 +780,52 @@ H5S_mpio_hyper_type(const H5S_t *space, size_t elmt_size,
offset[rank - 1] = 1;
max_xtent[rank - 1] = d[rank - 1].xtent;
#ifdef H5S_DEBUG
- if(H5DEBUG(S)) {
- i = ((int)rank) - 1;
- HDfprintf(H5DEBUG(S), " offset[%2d]=%Hu; max_xtent[%2d]=%Hu\n",
- i, offset[i], i, max_xtent[i]);
- }
+if(H5DEBUG(S)) {
+ i = ((int)rank) - 1;
+ HDfprintf(H5DEBUG(S), " offset[%2d]=%Hu; max_xtent[%2d]=%Hu\n", i, offset[i], i, max_xtent[i]);
+}
#endif
for(i = ((int)rank) - 2; i >= 0; --i) {
offset[i] = offset[i + 1] * d[i + 1].xtent;
max_xtent[i] = max_xtent[i + 1] * d[i].xtent;
#ifdef H5S_DEBUG
- if(H5DEBUG(S))
- HDfprintf(H5DEBUG(S), " offset[%2d]=%Hu; max_xtent[%2d]=%Hu\n",
- i, offset[i], i, max_xtent[i]);
+if(H5DEBUG(S))
+ HDfprintf(H5DEBUG(S), " offset[%2d]=%Hu; max_xtent[%2d]=%Hu\n", i, offset[i], i, max_xtent[i]);
#endif
} /* end for */
/* Create a type covering the selected hyperslab.
* Multidimensional dataspaces are stored in row-major order.
* The type is built from the inside out, going from the
- * fastest-changing (i.e., inner) dimension * to the slowest (outer). */
+ * fastest-changing (i.e., inner) dimension * to the slowest (outer).
+ */
/*******************************************************
* Construct contig type for inner contig dims:
*******************************************************/
#ifdef H5S_DEBUG
- if(H5DEBUG(S)) {
+if(H5DEBUG(S)) {
HDfprintf(H5DEBUG(S), "%s: Making contig type %Zu MPI_BYTEs\n", FUNC, elmt_size);
for(i = ((int)rank) - 1; i >= 0; --i)
HDfprintf(H5DEBUG(S), "d[%d].xtent=%Hu \n", i, d[i].xtent);
- }
+}
#endif
/* LARGE_DATATYPE::
- * Check if the number of elements to form the inner type fits into a 32 bit integer.
+ * Check if the number of elements to form the inner type fits into a 32 bit integer.
* If yes then just create the innertype with MPI_Type_contiguous.
* Otherwise create a compound datatype by iterating as many times as needed
* for the innertype to be created.
*/
if(bigio_count >= elmt_size) {
- /* Use a single MPI datatype that has a 32 bit size */
- if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous((int)elmt_size, MPI_BYTE, &inner_type)))
- HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code)
- }
- else {
- /* Create the compound datatype for this operation (> 2GB) */
- if (H5S_mpio_create_large_type (elmt_size, 0, MPI_BYTE, &inner_type) < 0) {
- HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL,
- "couldn't ccreate a large inner datatype in hyper selection")
- }
- }
+ /* Use a single MPI datatype that has a 32 bit size */
+ if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous((int)elmt_size, MPI_BYTE, &inner_type)))
+ HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code)
+ } /* end if */
+ else
+ /* Create the compound datatype for this operation (> 2GB) */
+ if(H5S__mpio_create_large_type(elmt_size, 0, MPI_BYTE, &inner_type) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't create a large inner datatype in hyper selection")
/*******************************************************
* Construct the type by walking the hyperslab dims
@@ -819,64 +833,57 @@ H5S_mpio_hyper_type(const H5S_t *space, size_t elmt_size,
*******************************************************/
for(i = ((int)rank) - 1; i >= 0; --i) {
#ifdef H5S_DEBUG
- if(H5DEBUG(S))
- HDfprintf(H5DEBUG(S), "%s: Dimension i=%d \n"
- "start=%Hd count=%Hu block=%Hu stride=%Hu, xtent=%Hu max_xtent=%d\n",
- FUNC, i, d[i].start, d[i].count, d[i].block, d[i].strid, d[i].xtent, max_xtent[i]);
+if(H5DEBUG(S))
+ HDfprintf(H5DEBUG(S), "%s: Dimension i=%d \n"
+ "start=%Hd count=%Hu block=%Hu stride=%Hu, xtent=%Hu max_xtent=%d\n",
+ FUNC, i, d[i].start, d[i].count, d[i].block, d[i].strid, d[i].xtent, max_xtent[i]);
#endif
#ifdef H5S_DEBUG
- if(H5DEBUG(S))
- HDfprintf(H5DEBUG(S), "%s: i=%d Making vector-type \n", FUNC,i);
+if(H5DEBUG(S))
+ HDfprintf(H5DEBUG(S), "%s: i=%d Making vector-type \n", FUNC,i);
#endif
/****************************************
- * Build vector type of the selection.
- ****************************************/
- if (bigio_count >= d[i].count &&
- bigio_count >= d[i].block &&
- bigio_count >= d[i].strid) {
-
- /* All the parameters fit into 32 bit integers so create the vector type normally */
- mpi_code = MPI_Type_vector((int)(d[i].count), /* count */
- (int)(d[i].block), /* blocklength */
- (int)(d[i].strid), /* stride */
- inner_type, /* old type */
- &outer_type); /* new type */
-
- MPI_Type_free(&inner_type);
- if(mpi_code != MPI_SUCCESS)
- HMPI_GOTO_ERROR(FAIL, "couldn't create MPI vector type", mpi_code)
- }
+ * Build vector type of the selection.
+ ****************************************/
+ if(bigio_count >= d[i].count &&
+ bigio_count >= d[i].block && bigio_count >= d[i].strid) {
+ /* All the parameters fit into 32 bit integers so create the vector type normally */
+ mpi_code = MPI_Type_vector((int)(d[i].count), /* count */
+ (int)(d[i].block), /* blocklength */
+ (int)(d[i].strid), /* stride */
+ inner_type, /* old type */
+ &outer_type); /* new type */
+
+ MPI_Type_free(&inner_type);
+ if(mpi_code != MPI_SUCCESS)
+ HMPI_GOTO_ERROR(FAIL, "couldn't create MPI vector type", mpi_code)
+ } /* end if */
else {
- /* Things get a bit more complicated and require LARGE_DATATYPE processing
- * There are two MPI datatypes that need to be created:
- * 1) an internal contiguous block; and
- * 2) a collection of elements where an element is a contiguous block(1).
- * Remember that the input arguments to the MPI-IO functions use integer
- * values to represent element counts. We ARE allowed however, in the
- * more recent MPI implementations to use constructed datatypes whereby
- * the total number of bytes in a transfer could be :
- * (2GB-1)number_of_blocks * the_datatype_extent.
- */
+ /* Things get a bit more complicated and require LARGE_DATATYPE processing
+ * There are two MPI datatypes that need to be created:
+ * 1) an internal contiguous block; and
+ * 2) a collection of elements where an element is a contiguous block(1).
+ * Remember that the input arguments to the MPI-IO functions use integer
+ * values to represent element counts. We ARE allowed however, in the
+ * more recent MPI implementations to use constructed datatypes whereby
+ * the total number of bytes in a transfer could be :
+ * (2GB-1)number_of_blocks * the_datatype_extent.
+ */
+
MPI_Aint stride_in_bytes, inner_extent;
MPI_Datatype block_type;
- /* create a contiguous datatype inner_type x number of BLOCKS.
- * Again we need to check that the number of BLOCKS can fit into
+ /* Create a contiguous datatype inner_type x number of BLOCKS.
+ * Again we need to check that the number of BLOCKS can fit into
* a 32 bit integer */
- if (bigio_count < d[i].block) {
- if (H5S_mpio_create_large_type(d[i].block, 0, inner_type,
- &block_type) < 0) {
- HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL,
- "couldn't ccreate a large block datatype in hyper selection")
- }
- }
- else {
- if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous((int)d[i].block,
- inner_type,
- &block_type)))
+ if(bigio_count < d[i].block) {
+ if(H5S__mpio_create_large_type(d[i].block, 0, inner_type, &block_type) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't create a large block datatype in hyper selection")
+ } /* end if */
+ else
+ if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous((int)d[i].block, inner_type, &block_type)))
HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code)
- }
/* As of version 4.0, OpenMPI now turns off MPI-1 API calls by default,
* so we're using the MPI-2 version even though we don't need the lb
@@ -891,40 +898,38 @@ H5S_mpio_hyper_type(const H5S_t *space, size_t elmt_size,
/* If the element count is larger than what a 32 bit integer can hold,
* we call the large type creation function to handle that
*/
- if (bigio_count < d[i].count) {
- if (H5S_mpio_create_large_type (d[i].count, stride_in_bytes, block_type,
- &outer_type) < 0) {
- HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL,
- "couldn't create a large outer datatype in hyper selection")
- }
- }
+ if(bigio_count < d[i].count) {
+ if(H5S__mpio_create_large_type(d[i].count, stride_in_bytes, block_type, &outer_type) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't create a large outer datatype in hyper selection")
+ } /* end if */
/* otherwise a regular create_hvector will do */
- else {
- mpi_code = MPI_Type_create_hvector((int)d[i].count, /* count */
- 1, /* blocklength */
- stride_in_bytes, /* stride in bytes*/
- block_type, /* old type */
- &outer_type); /* new type */
- if(MPI_SUCCESS != mpi_code)
+ else
+ if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hvector((int)d[i].count, /* count */
+ 1, /* blocklength */
+ stride_in_bytes, /* stride in bytes*/
+ block_type, /* old type */
+ &outer_type))) /* new type */
HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hvector failed", mpi_code)
- }
+
MPI_Type_free(&block_type);
MPI_Type_free(&inner_type);
- }
- /****************************************
- * Then build the dimension type as (start, vector type, xtent).
- ****************************************/
- /* calculate start and extent values of this dimension */
+ } /* end else */
+
+ /****************************************
+ * Then build the dimension type as (start, vector type, xtent).
+ ****************************************/
+
+ /* Calculate start and extent values of this dimension */
start_disp = d[i].start * offset[i] * elmt_size;
new_extent = (MPI_Aint)elmt_size * max_xtent[i];
if(MPI_SUCCESS != (mpi_code = MPI_Type_get_extent(outer_type, &lb, &extent_len)))
HMPI_GOTO_ERROR(FAIL, "MPI_Type_get_extent failed", mpi_code)
/*************************************************
- * Restructure this datatype ("outer_type")
- * so that it still starts at 0, but its extent
- * is the full extent in this dimension.
- *************************************************/
+ * Restructure this datatype ("outer_type")
+ * so that it still starts at 0, but its extent
+ * is the full extent in this dimension.
+ *************************************************/
if(start_disp > 0 || extent_len < new_extent) {
MPI_Datatype interm_type;
int block_len = 1;
@@ -956,13 +961,6 @@ H5S_mpio_hyper_type(const H5S_t *space, size_t elmt_size,
/* fill in the remaining return values */
*count = 1; /* only have to move one of these suckers! */
*is_derived_type = TRUE;
- HGOTO_DONE(SUCCEED);
-
-empty:
- /* special case: empty hyperslab */
- *new_type = MPI_BYTE;
- *count = 0;
- *is_derived_type = FALSE;
done:
/* Release selection iterator */
@@ -971,21 +969,20 @@ done:
HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator")
#ifdef H5S_DEBUG
- if(H5DEBUG(S))
- HDfprintf(H5DEBUG(S), "Leave %s, count=%ld is_derived_type=%t\n",
- FUNC, *count, *is_derived_type );
+if(H5DEBUG(S))
+ HDfprintf(H5DEBUG(S), "Leave %s, count=%ld is_derived_type=%t\n", FUNC, *count, *is_derived_type);
#endif
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5S_mpio_hyper_type() */
+} /* end H5S__mpio_reg_hyper_type() */
/*-------------------------------------------------------------------------
- * Function: H5S_mpio_span_hyper_type
+ * Function: H5S__mpio_span_hyper_type
*
* Purpose: Translate an HDF5 irregular hyperslab selection into an
MPI type.
*
- * Return: non-negative on success, negative on failure.
+ * Return: Non-negative on success, negative on failure.
*
* Outputs: *new_type the MPI type corresponding to the selection
* *count how many objects of the new_type in selection
@@ -994,24 +991,22 @@ done:
*
* Programmer: kyang
*
- * Modifications:
- * Mohamad Chaarawi
- * Adding support for large datatypes (beyond the limit of a
- * 32 bit integer.
*-------------------------------------------------------------------------
*/
static herr_t
-H5S_mpio_span_hyper_type(const H5S_t *space, size_t elmt_size,
+H5S__mpio_span_hyper_type(const H5S_t *space, size_t elmt_size,
MPI_Datatype *new_type, int *count, hbool_t *is_derived_type)
{
+ H5S_mpio_mpitype_list_t type_list; /* List to track MPI data types created */
MPI_Datatype elmt_type; /* MPI datatype for an element */
hbool_t elmt_type_is_derived = FALSE; /* Whether the element type has been created */
MPI_Datatype span_type; /* MPI datatype for overall span tree */
hsize_t down[H5S_MAX_RANK]; /* 'down' sizes for each dimension */
+ uint64_t op_gen; /* Operation generation value */
int mpi_code; /* MPI return code */
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_STATIC
/* Check args */
HDassert(space);
@@ -1020,29 +1015,34 @@ H5S_mpio_span_hyper_type(const H5S_t *space, size_t elmt_size,
HDassert(space->select.sel_info.hslab->span_lst->head);
/* Create the base type for an element */
- if (bigio_count >= elmt_size) {
- if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous((int)elmt_size, MPI_BYTE, &elmt_type))) {
- HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code)
- }
- }
- else {
- if (H5S_mpio_create_large_type (elmt_size, 0, MPI_BYTE, &elmt_type) < 0) {
- HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL,
- "couldn't create a large element datatype in span_hyper selection")
- }
- }
+ if(bigio_count >= elmt_size) {
+ if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous((int)elmt_size, MPI_BYTE, &elmt_type)))
+ HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code)
+ } /* end if */
+ else
+ if(H5S__mpio_create_large_type(elmt_size, 0, MPI_BYTE, &elmt_type) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't create a large element datatype in span_hyper selection")
elmt_type_is_derived = TRUE;
/* Compute 'down' sizes for each dimension */
if(H5VM_array_down(space->extent.rank, space->extent.size, down) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGETSIZE, FAIL, "couldn't compute 'down' dimension sizes")
- /* Obtain derived data type */
- if(H5S_obtain_datatype(down, space->select.sel_info.hslab->span_lst->head, &elmt_type, &span_type, elmt_size) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't obtain MPI derived data type")
- if(MPI_SUCCESS != (mpi_code = MPI_Type_commit(&span_type)))
+ /* Acquire an operation generation value for creating MPI datatypes */
+ op_gen = H5S__hyper_get_op_gen();
+
+ /* Obtain derived MPI data type */
+ type_list.head = type_list.tail = NULL;
+ if(H5S__obtain_datatype(space->select.sel_info.hslab->span_lst, down, elmt_size, &elmt_type, &span_type, &type_list, op_gen) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't obtain MPI derived data type")
+ if(MPI_SUCCESS != (mpi_code = MPI_Type_dup(span_type, new_type)))
HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code)
- *new_type = span_type;
+ if(MPI_SUCCESS != (mpi_code = MPI_Type_commit(new_type)))
+ HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code)
+
+ /* Release MPI data types generated during span tree traversal */
+ if(H5S__release_datatype(&type_list) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "couldn't release MPI derived data type")
/* fill in the remaining return values */
*count = 1;
@@ -1055,16 +1055,62 @@ done:
HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code)
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5S_mpio_span_hyper_type() */
+} /* end H5S__mpio_span_hyper_type() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5S__release_datatype
+ *
+ * Purpose: Release the MPI derived datatypes for span-tree hyperslab selection
+ *
+ * Return: Non-negative on success, negative on failure.
+ *
+ * Programmer: Quincey Koziol, February 2, 2019
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5S__release_datatype(H5S_mpio_mpitype_list_t *type_list)
+{
+ H5S_mpio_mpitype_node_t *curr; /* Pointer to head of list */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_STATIC
+
+ /* Sanity check */
+ HDassert(type_list);
+
+ /* Iterate over the list, freeing the MPI data types */
+ curr = type_list->head;
+ while(curr) {
+ H5S_mpio_mpitype_node_t *next; /* Pointer to next node in list */
+ int mpi_code; /* MPI return status code */
+
+ /* Release the MPI data type for this span tree */
+ if(MPI_SUCCESS != (mpi_code = MPI_Type_free(&curr->type)))
+ HMPI_GOTO_ERROR(FAIL, "MPI_Type_free failed", mpi_code)
+
+ /* Get pointer to next node in list */
+ next = curr->next;
+
+ /* Free the current node */
+ curr = H5FL_FREE(H5S_mpio_mpitype_node_t, curr);
+
+ /* Advance to next node */
+ curr = next;
+ } /* end while */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5S__release_datatype() */
/*-------------------------------------------------------------------------
- * Function: H5S_obtain_datatype
+ * Function: H5S__obtain_datatype
*
- * Purpose: Obtain an MPI derived datatype based on span-tree
- * implementation
+ * Purpose: Obtain an MPI derived datatype for span-tree hyperslab selection
*
- * Return: non-negative on success, negative on failure.
+ * Return: Non-negative on success, negative on failure.
*
* Outputs: *span_type the MPI type corresponding to the selection
*
@@ -1073,208 +1119,219 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5S_obtain_datatype(const hsize_t *down, H5S_hyper_span_t *span,
- const MPI_Datatype *elmt_type, MPI_Datatype *span_type, size_t elmt_size)
+H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down,
+ size_t elmt_size, const MPI_Datatype *elmt_type, MPI_Datatype *span_type,
+ H5S_mpio_mpitype_list_t *type_list, uint64_t op_gen)
{
+ H5S_hyper_span_t *span; /* Hyperslab span to iterate with */
size_t alloc_count = 0; /* Number of span tree nodes allocated at this level */
- size_t outercount = 0; /* Number of span tree nodes at this level */
+ size_t outercount; /* Number of span tree nodes at this level */
MPI_Datatype *inner_type = NULL;
hbool_t inner_types_freed = FALSE; /* Whether the inner_type MPI datatypes have been freed */
- hbool_t span_type_valid = FALSE; /* Whether the span_type MPI datatypes is valid */
- hbool_t large_block = FALSE; /* Wether the block length is larger than 32 bit integer */
int *blocklen = NULL;
MPI_Aint *disp = NULL;
- H5S_hyper_span_t *tspan = NULL; /* Temporary pointer to span tree node */
+ size_t u; /* Local index variable */
int mpi_code; /* MPI return status code */
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_STATIC
/* Sanity check */
- HDassert(span);
+ HDassert(spans);
+ HDassert(type_list);
+
+ /* Check if we've visited this span tree before */
+ if(spans->op_gen != op_gen) {
+ H5S_mpio_mpitype_node_t *type_node; /* Pointer to new node in MPI data type list */
+
+ /* Allocate the initial displacement & block length buffers */
+ alloc_count = H5S_MPIO_INITIAL_ALLOC_COUNT;
+ if(NULL == (disp = (MPI_Aint *)H5MM_malloc(alloc_count * sizeof(MPI_Aint))))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of displacements")
+ if(NULL == (blocklen = (int *)H5MM_malloc(alloc_count * sizeof(int))))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of block lengths")
+
+ /* If this is the fastest changing dimension, it is the base case for derived datatype. */
+ span = spans->head;
+ if(NULL == span->down) {
+ hbool_t large_block = FALSE; /* Wether the block length is larger than 32 bit integer */
+
+ outercount = 0;
+ while(span) {
+ hsize_t nelmts; /* # of elements covered by current span */
+
+ /* Check if we need to increase the size of the buffers */
+ if(outercount >= alloc_count) {
+ MPI_Aint *tmp_disp; /* Temporary pointer to new displacement buffer */
+ int *tmp_blocklen; /* Temporary pointer to new block length buffer */
+
+ /* Double the allocation count */
+ alloc_count *= 2;
+
+ /* Re-allocate the buffers */
+ if(NULL == (tmp_disp = (MPI_Aint *)H5MM_realloc(disp, alloc_count * sizeof(MPI_Aint))))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of displacements")
+ disp = tmp_disp;
+ if(NULL == (tmp_blocklen = (int *)H5MM_realloc(blocklen, alloc_count * sizeof(int))))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of block lengths")
+ blocklen = tmp_blocklen;
+ } /* end if */
- /* Allocate the initial displacement & block length buffers */
- alloc_count = H5S_MPIO_INITIAL_ALLOC_COUNT;
- if(NULL == (disp = (MPI_Aint *)H5MM_malloc(alloc_count * sizeof(MPI_Aint))))
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of displacements")
- if(NULL == (blocklen = (int *)H5MM_malloc(alloc_count * sizeof(int))))
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of block lengths")
-
- /* if this is the fastest changing dimension, it is the base case for derived datatype. */
- if(NULL == span->down) {
- tspan = span;
- outercount = 0;
- while(tspan) {
- /* Check if we need to increase the size of the buffers */
- if(outercount >= alloc_count) {
- MPI_Aint *tmp_disp; /* Temporary pointer to new displacement buffer */
- int *tmp_blocklen; /* Temporary pointer to new block length buffer */
-
- /* Double the allocation count */
- alloc_count *= 2;
-
- /* Re-allocate the buffers */
- if(NULL == (tmp_disp = (MPI_Aint *)H5MM_realloc(disp, alloc_count * sizeof(MPI_Aint))))
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of displacements")
- disp = tmp_disp;
- if(NULL == (tmp_blocklen = (int *)H5MM_realloc(blocklen, alloc_count * sizeof(int))))
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of block lengths")
- blocklen = tmp_blocklen;
- } /* end if */
+ /* Compute the number of elements to attempt in this span */
+ nelmts = (span->high - span->low) + 1;
- /* Store displacement & block length */
- disp[outercount] = (MPI_Aint)elmt_size * tspan->low;
- H5_CHECK_OVERFLOW(tspan->nelem, hsize_t, int)
- blocklen[outercount] = (int)tspan->nelem;
- tspan = tspan->next;
+ /* Store displacement & block length */
+ disp[outercount] = (MPI_Aint)elmt_size * span->low;
+ H5_CHECK_OVERFLOW(nelmts, hsize_t, int)
+ blocklen[outercount] = (int)nelmts;
- if (bigio_count < blocklen[outercount]) {
- large_block = TRUE; /* at least one block type is large, so set this flag to true */
- }
+ if(bigio_count < blocklen[outercount])
+ large_block = TRUE; /* at least one block type is large, so set this flag to true */
- outercount++;
- } /* end while */
+ span = span->next;
+ outercount++;
+ } /* end while */
- /* Everything fits into integers, so cast them and use hindexed */
- if (bigio_count >= outercount && large_block == FALSE) {
+ /* Everything fits into integers, so cast them and use hindexed */
+ if(bigio_count >= outercount && large_block == FALSE) {
+ if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed((int)outercount, blocklen, disp, *elmt_type, &spans->u.down_type)))
+ HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed failed", mpi_code)
+ } /* end if */
+ else { /* LARGE_DATATYPE:: Something doesn't fit into a 32 bit integer */
+ for(u = 0 ; u < outercount; u++) {
+ MPI_Datatype temp_type = MPI_DATATYPE_NULL;
+
+ /* create the block type from elmt_type while checking the 32 bit int limit */
+ if(blocklen[u] > bigio_count) {
+ if(H5S__mpio_create_large_type(blocklen[u], 0, *elmt_type, &temp_type) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't create a large element datatype in span_hyper selection")
+ } /* end if */
+ else
+ if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous((int)blocklen[u], *elmt_type, &temp_type)))
+ HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code)
+
+ /* Combine the current datatype that is created with this current block type */
+ if(0 == u) /* first iteration, there is no combined datatype yet */
+ spans->u.down_type = temp_type;
+ else {
+ int bl[2] = {1, 1};
+ MPI_Aint ds[2] = {disp[u - 1], disp[u]};
+ MPI_Datatype dt[2] = {spans->u.down_type, temp_type};
+
+ if(MPI_SUCCESS != (mpi_code = MPI_Type_create_struct(2, /* count */
+ bl, /* blocklength */
+ ds, /* stride in bytes*/
+ dt, /* old type */
+ &spans->u.down_type))) /* new type */
+ HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_struct failed", mpi_code)
+
+ /* Release previous temporary datatype */
+ if(MPI_SUCCESS != (mpi_code = MPI_Type_free(&temp_type)))
+ HMPI_GOTO_ERROR(FAIL, "MPI_Type_free failed", mpi_code)
+ } /* end else */
+ } /* end for */
+ } /* end else (LARGE_DATATYPE::) */
+ } /* end if */
+ else {
+ MPI_Aint stride; /* Distance between inner MPI datatypes */
- if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed((int)outercount, blocklen, disp, *elmt_type, span_type)))
- HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed failed", mpi_code)
- span_type_valid = TRUE;
- }
- else { /* LARGE_DATATYPE:: Something doesn't fit into a 32 bit integer */
- size_t i;
-
- for (i=0 ; i<outercount ; i++) {
- MPI_Datatype temp_type = MPI_DATATYPE_NULL, outer_type = MPI_DATATYPE_NULL;
- /* create the block type from elmt_type while checking the 32 bit int limit */
- if (blocklen[i] > bigio_count) {
- if (H5S_mpio_create_large_type (blocklen[i], 0, *elmt_type, &temp_type) < 0) {
- HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL,
- "couldn't create a large element datatype in span_hyper selection")
- }
- }
- else {
- if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous((int)blocklen[i],
- *elmt_type,
- &temp_type)))
- HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code)
- }
-
- /* combine the current datatype that is created with this current block type */
- if (0 == i) { /* first iteration, there is no combined datatype yet */
- *span_type = temp_type;
- }
- else {
- int bl[2] = {1,1};
- MPI_Aint ds[2] = {disp[i-1],disp[i]};
- MPI_Datatype dt[2] = {*span_type, temp_type};
-
- if (MPI_SUCCESS != (mpi_code = MPI_Type_create_struct (2, /* count */
- bl, /* blocklength */
- ds, /* stride in bytes*/
- dt, /* old type */
- &outer_type))){ /* new type */
- HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_struct failed", mpi_code)
- }
- *span_type = outer_type;
- }
-
- if (outer_type != MPI_DATATYPE_NULL)
- MPI_Type_free(&outer_type);
- /* temp_type shouldn't be freed here...
- * Note that we have simply copied it above (not MPI_Type_dup)
- * into the 'span_type' argument of the caller.
- * The caller needs to deal with it there!
- */
- }
- } /* end (LARGE_DATATYPE::) */
+ if(NULL == (inner_type = (MPI_Datatype *)H5MM_malloc(alloc_count * sizeof(MPI_Datatype))))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of inner MPI datatypes")
- } /* end if */
- else {
- size_t u; /* Local index variable */
+ /* Calculate the total bytes of the lower dimension */
+ stride = (*down) * elmt_size;
- if(NULL == (inner_type = (MPI_Datatype *)H5MM_malloc(alloc_count * sizeof(MPI_Datatype))))
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of inner MPI datatypes")
+ /* Loop over span nodes */
+ outercount = 0;
+ while(span) {
+ MPI_Datatype down_type; /* Temporary MPI datatype for a span tree node's children */
+ hsize_t nelmts; /* # of elements covered by current span */
+
+ /* Check if we need to increase the size of the buffers */
+ if(outercount >= alloc_count) {
+ MPI_Aint *tmp_disp; /* Temporary pointer to new displacement buffer */
+ int *tmp_blocklen; /* Temporary pointer to new block length buffer */
+ MPI_Datatype *tmp_inner_type; /* Temporary pointer to inner MPI datatype buffer */
+
+ /* Double the allocation count */
+ alloc_count *= 2;
+
+ /* Re-allocate the buffers */
+ if(NULL == (tmp_disp = (MPI_Aint *)H5MM_realloc(disp, alloc_count * sizeof(MPI_Aint))))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of displacements")
+ disp = tmp_disp;
+ if(NULL == (tmp_blocklen = (int *)H5MM_realloc(blocklen, alloc_count * sizeof(int))))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of block lengths")
+ blocklen = tmp_blocklen;
+ if(NULL == (tmp_inner_type = (MPI_Datatype *)H5MM_realloc(inner_type, alloc_count * sizeof(MPI_Datatype))))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of inner MPI datatypes")
+ inner_type = tmp_inner_type;
+ } /* end if */
- tspan = span;
- outercount = 0;
- while(tspan) {
- MPI_Datatype down_type; /* Temporary MPI datatype for a span tree node's children */
- MPI_Aint stride; /* Distance between inner MPI datatypes */
+ /* Displacement should be in byte and should have dimension information */
+ /* First using MPI Type vector to build derived data type for this span only */
+ /* Need to calculate the disp in byte for this dimension. */
+ disp[outercount] = span->low * stride;
+ blocklen[outercount] = 1;
- /* Check if we need to increase the size of the buffers */
- if(outercount >= alloc_count) {
- MPI_Aint *tmp_disp; /* Temporary pointer to new displacement buffer */
- int *tmp_blocklen; /* Temporary pointer to new block length buffer */
- MPI_Datatype *tmp_inner_type; /* Temporary pointer to inner MPI datatype buffer */
-
- /* Double the allocation count */
- alloc_count *= 2;
-
- /* Re-allocate the buffers */
- if(NULL == (tmp_disp = (MPI_Aint *)H5MM_realloc(disp, alloc_count * sizeof(MPI_Aint))))
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of displacements")
- disp = tmp_disp;
- if(NULL == (tmp_blocklen = (int *)H5MM_realloc(blocklen, alloc_count * sizeof(int))))
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of block lengths")
- blocklen = tmp_blocklen;
- if(NULL == (tmp_inner_type = (MPI_Datatype *)H5MM_realloc(inner_type, alloc_count * sizeof(MPI_Datatype))))
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of inner MPI datatypes")
- inner_type = tmp_inner_type;
- } /* end if */
+ /* Generate MPI datatype for next dimension down */
+ if(H5S__obtain_datatype(span->down, down + 1, elmt_size, elmt_type, &down_type, type_list, op_gen) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't obtain MPI derived data type")
- /* Displacement should be in byte and should have dimension information */
- /* First using MPI Type vector to build derived data type for this span only */
- /* Need to calculate the disp in byte for this dimension. */
- /* Calculate the total bytes of the lower dimension */
- disp[outercount] = tspan->low * (*down) * elmt_size;
- blocklen[outercount] = 1;
+ /* Compute the number of elements to attempt in this span */
+ nelmts = (span->high - span->low) + 1;
+
+ /* Build the MPI datatype for this node */
+ H5_CHECK_OVERFLOW(nelmts, hsize_t, int)
+ if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hvector((int)nelmts, 1, stride, down_type, &inner_type[outercount])))
+ HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hvector failed", mpi_code)
- /* Generate MPI datatype for next dimension down */
- if(H5S_obtain_datatype(down + 1, tspan->down->head, elmt_type, &down_type, elmt_size) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't obtain MPI derived data type")
+ span = span->next;
+ outercount++;
+ } /* end while */
- /* Build the MPI datatype for this node */
- stride = (*down) * elmt_size;
- H5_CHECK_OVERFLOW(tspan->nelem, hsize_t, int)
- if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hvector((int)tspan->nelem, 1, stride, down_type, &inner_type[outercount]))) {
- MPI_Type_free(&down_type);
- HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hvector failed", mpi_code)
- } /* end if */
+ /* Building the whole vector datatype */
+ H5_CHECK_OVERFLOW(outercount, size_t, int)
+ if(MPI_SUCCESS != (mpi_code = MPI_Type_create_struct((int)outercount, blocklen, disp, inner_type, &spans->u.down_type)))
+ HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_struct failed", mpi_code)
+
+ /* Release inner node types */
+ for(u = 0; u < outercount; u++)
+ if(MPI_SUCCESS != (mpi_code = MPI_Type_free(&inner_type[u])))
+ HMPI_GOTO_ERROR(FAIL, "MPI_Type_free failed", mpi_code)
+ inner_types_freed = TRUE;
+ } /* end else */
- /* Release MPI datatype for next dimension down */
- if(MPI_SUCCESS != (mpi_code = MPI_Type_free(&down_type)))
- HMPI_GOTO_ERROR(FAIL, "MPI_Type_free failed", mpi_code)
+ /* Allocate space for the MPI data type list node */
+ if(NULL == (type_node = H5FL_MALLOC(H5S_mpio_mpitype_node_t)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate MPI data type list node")
- tspan = tspan->next;
- outercount++;
- } /* end while */
+ /* Set up MPI type node */
+ type_node->type = spans->u.down_type;
+ type_node->next = NULL;
- /* building the whole vector datatype */
- H5_CHECK_OVERFLOW(outercount, size_t, int)
- if(MPI_SUCCESS != (mpi_code = MPI_Type_create_struct((int)outercount, blocklen, disp, inner_type, span_type)))
- HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_struct failed", mpi_code)
- span_type_valid = TRUE;
+ /* Add MPI type node to list */
+ if(type_list->head == NULL)
+ type_list->head = type_list->tail = type_node;
+ else {
+ type_list->tail->next = type_node;
+ type_list->tail = type_node;
+ } /* end else */
- /* Release inner node types */
- for(u = 0; u < outercount; u++)
- if(MPI_SUCCESS != (mpi_code = MPI_Type_free(&inner_type[u])))
- HMPI_GOTO_ERROR(FAIL, "MPI_Type_free failed", mpi_code)
- inner_types_freed = TRUE;
+ /* Remember that we've visited this span tree */
+ spans->op_gen = op_gen;
} /* end else */
+ /* Return MPI data type for span tree */
+ *span_type = spans->u.down_type;
+
done:
/* General cleanup */
if(inner_type != NULL) {
- if(!inner_types_freed) {
- size_t u; /* Local index variable */
-
+ if(!inner_types_freed)
for(u = 0; u < outercount; u++)
if(MPI_SUCCESS != (mpi_code = MPI_Type_free(&inner_type[u])))
HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code)
- } /* end if */
-
H5MM_free(inner_type);
} /* end if */
if(blocklen != NULL)
@@ -1282,15 +1339,8 @@ done:
if(disp != NULL)
H5MM_free(disp);
- /* Error cleanup */
- if(ret_value < 0) {
- if(span_type_valid)
- if(MPI_SUCCESS != (mpi_code = MPI_Type_free(span_type)))
- HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code)
- } /* end if */
-
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5S_obtain_datatype() */
+} /* end H5S__obtain_datatype() */
/*-------------------------------------------------------------------------
@@ -1299,7 +1349,7 @@ done:
* Purpose: Translate an HDF5 dataspace selection into an MPI type.
* Currently handle only hyperslab and "all" selections.
*
- * Return: non-negative on success, negative on failure.
+ * Return: Non-negative on success, negative on failure.
*
* Outputs: *new_type the MPI type corresponding to the selection
* *count how many objects of the new_type in selection
@@ -1311,7 +1361,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5S_mpio_space_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type,
+H5S_mpio_space_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type,
int *count, hbool_t *is_derived_type, hbool_t do_permute, hsize_t **permute_map,
hbool_t *is_permuted)
{
@@ -1332,10 +1382,10 @@ H5S_mpio_space_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type
* out-of-order point selection, then permute this selection which
* should be a memory selection to match the file space permutation.
*/
- if(TRUE == *is_permuted) {
+ if(TRUE == *is_permuted) {
switch(H5S_GET_SELECT_TYPE(space)) {
case H5S_SEL_NONE:
- if(H5S_mpio_none_type(new_type, count, is_derived_type) < 0)
+ if(H5S__mpio_none_type(new_type, count, is_derived_type) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't convert 'none' selection to MPI type")
break;
@@ -1345,7 +1395,7 @@ H5S_mpio_space_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type
/* Sanity check */
HDassert(!do_permute);
- if(H5S_mpio_permute_type(space, elmt_size, permute_map, new_type, count, is_derived_type) < 0)
+ if(H5S__mpio_permute_type(space, elmt_size, permute_map, new_type, count, is_derived_type) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't convert 'all' selection to MPI type")
break;
@@ -1360,29 +1410,28 @@ H5S_mpio_space_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type
else {
switch(H5S_GET_SELECT_TYPE(space)) {
case H5S_SEL_NONE:
- if(H5S_mpio_none_type(new_type, count, is_derived_type) < 0)
+ if(H5S__mpio_none_type(new_type, count, is_derived_type) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL,"couldn't convert 'none' selection to MPI type")
break;
case H5S_SEL_ALL:
- if(H5S_mpio_all_type(space, elmt_size, new_type, count, is_derived_type) < 0)
+ if(H5S__mpio_all_type(space, elmt_size, new_type, count, is_derived_type) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL,"couldn't convert 'all' selection to MPI type")
break;
case H5S_SEL_POINTS:
- if(H5S_mpio_point_type(space, elmt_size, new_type, count, is_derived_type, do_permute, permute_map, is_permuted) < 0)
+ if(H5S__mpio_point_type(space, elmt_size, new_type, count, is_derived_type, do_permute, permute_map, is_permuted) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't convert 'point' selection to MPI type")
break;
case H5S_SEL_HYPERSLABS:
if((H5S_SELECT_IS_REGULAR(space) == TRUE)) {
- if(H5S_mpio_hyper_type(space, elmt_size, new_type, count, is_derived_type) < 0)
+ if(H5S__mpio_reg_hyper_type(space, elmt_size, new_type, count, is_derived_type) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL,"couldn't convert regular 'hyperslab' selection to MPI type")
} /* end if */
- else {
- if(H5S_mpio_span_hyper_type(space, elmt_size, new_type, count, is_derived_type) < 0)
+ else
+ if(H5S__mpio_span_hyper_type(space, elmt_size, new_type, count, is_derived_type) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL,"couldn't convert irregular 'hyperslab' selection to MPI type")
- } /* end else */
break;
case H5S_SEL_ERROR:
@@ -1406,12 +1455,12 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5S_mpio_create_large_type
+ * Function: H5S__mpio_create_large_type
*
- * Purpose: Create a large datatype of size larger than what a 32 bit integer
+ * Purpose: Create a large datatype of size larger than what a 32 bit integer
* can hold.
*
- * Return: non-negative on success, negative on failure.
+ * Return: Non-negative on success, negative on failure.
*
* *new_type the new datatype created
*
@@ -1419,10 +1468,9 @@ done:
*
*-------------------------------------------------------------------------
*/
-static herr_t H5S_mpio_create_large_type (hsize_t num_elements,
- MPI_Aint stride_bytes,
- MPI_Datatype old_type,
- MPI_Datatype *new_type)
+static herr_t
+H5S__mpio_create_large_type(hsize_t num_elements, MPI_Aint stride_bytes,
+ MPI_Datatype old_type, MPI_Datatype *new_type)
{
int num_big_types; /* num times the 2G datatype will be repeated */
int remaining_bytes; /* the number of bytes left that can be held in an int value */
@@ -1434,7 +1482,7 @@ static herr_t H5S_mpio_create_large_type (hsize_t num_elements,
MPI_Aint disp[2], old_extent;
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_STATIC
/* Calculate how many Big MPI datatypes are needed to represent the buffer */
num_big_types = (int)(num_elements/bigio_count);
@@ -1447,41 +1495,23 @@ static herr_t H5S_mpio_create_large_type (hsize_t num_elements,
* use type_hvector to create the type with the displacement provided
*/
if (0 == stride_bytes) {
- if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous(bigio_count,
- old_type,
- &inner_type))) {
+ if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous(bigio_count, old_type, &inner_type)))
HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code)
- }
- }
- else {
- if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hvector (bigio_count,
- 1,
- stride_bytes,
- old_type,
- &inner_type))) {
+ } /* end if */
+ else
+ if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hvector(bigio_count, 1, stride_bytes, old_type, &inner_type)))
HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hvector failed", mpi_code)
- }
- }
/* Create a contiguous datatype of the buffer (minus the remaining < 2GB part)
* If a stride is present, use hvector type
*/
- if (0 == stride_bytes) {
- if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous(num_big_types,
- inner_type,
- &outer_type))) {
+ if(0 == stride_bytes) {
+ if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous(num_big_types, inner_type, &outer_type)))
HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code)
- }
- }
- else {
- if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hvector (num_big_types,
- 1,
- stride_bytes,
- inner_type,
- &outer_type))) {
+ } /* end if */
+ else
+ if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hvector(num_big_types, 1, stride_bytes, inner_type, &outer_type)))
HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hvector failed", mpi_code)
- }
- }
MPI_Type_free(&inner_type);
@@ -1489,23 +1519,13 @@ static herr_t H5S_mpio_create_large_type (hsize_t num_elements,
* use a struct datatype to encapsulate everything.
*/
if(remaining_bytes) {
- if (stride_bytes == 0) {
- if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous (remaining_bytes,
- old_type,
- &leftover_type))) {
+ if(stride_bytes == 0) {
+ if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous(remaining_bytes, old_type, &leftover_type)))
HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code)
- }
- }
- else {
- if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hvector
- ((int)(num_elements - (hsize_t)num_big_types*bigio_count),
- 1,
- stride_bytes,
- old_type,
- &leftover_type))) {
+ } /* end if */
+ else
+ if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hvector((int)(num_elements - (hsize_t)num_big_types * bigio_count), 1, stride_bytes, old_type, &leftover_type)))
HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hvector failed", mpi_code)
- }
- }
/* As of version 4.0, OpenMPI now turns off MPI-1 API calls by default,
* so we're using the MPI-2 version even though we don't need the lb
@@ -1522,28 +1542,25 @@ static herr_t H5S_mpio_create_large_type (hsize_t num_elements,
block_len[0] = 1;
block_len[1] = 1;
disp[0] = 0;
- disp[1] = (old_extent+stride_bytes)*num_big_types*(MPI_Aint)bigio_count;
+ disp[1] = (old_extent + stride_bytes) * num_big_types * (MPI_Aint)bigio_count;
- if(MPI_SUCCESS != (mpi_code =
- MPI_Type_create_struct(2, block_len, disp, type, new_type))) {
+ if(MPI_SUCCESS != (mpi_code = MPI_Type_create_struct(2, block_len, disp, type, new_type)))
HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_struct failed", mpi_code)
- }
MPI_Type_free(&outer_type);
MPI_Type_free(&leftover_type);
- }
- else {
+ } /* end if */
+ else
/* There are no remaining bytes so just set the new type to
* the outer type created */
*new_type = outer_type;
- }
if(MPI_SUCCESS != (mpi_code = MPI_Type_commit(new_type)))
HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code)
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5S_mpio_create_large_type */
+} /* end H5S__mpio_create_large_type() */
#endif /* H5_HAVE_PARALLEL */
diff --git a/src/H5Snone.c b/src/H5Snone.c
index a8aaf7e..9d64e9d 100644
--- a/src/H5Snone.c
+++ b/src/H5Snone.c
@@ -18,166 +18,197 @@
* Purpose: "None" selection dataspace I/O functions.
*/
+/****************/
+/* Module Setup */
+/****************/
+
#include "H5Smodule.h" /* This source code file is part of the H5S module */
-#include "H5private.h"
-#include "H5Eprivate.h"
-#include "H5Iprivate.h"
-#include "H5Spkg.h"
-#include "H5VMprivate.h"
-#include "H5Dprivate.h"
+/***********/
+/* Headers */
+/***********/
+#include "H5private.h" /* Generic Functions */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5Iprivate.h" /* ID Functions */
+#include "H5Spkg.h" /* Dataspace functions */
+#include "H5VMprivate.h" /* Vector functions */
+
+
+/****************/
+/* Local Macros */
+/****************/
+
+
+/******************/
+/* Local Typedefs */
+/******************/
+
-/* Static function prototypes */
+/********************/
+/* Local Prototypes */
+/********************/
/* Selection callbacks */
-static herr_t H5S_none_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection);
-static herr_t H5S_none_get_seq_list(const H5S_t *space, unsigned flags,
- H5S_sel_iter_t *iter, size_t maxseq, size_t maxbytes,
- size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len);
-static herr_t H5S_none_release(H5S_t *space);
-static htri_t H5S_none_is_valid(const H5S_t *space);
-static hssize_t H5S_none_serial_size(const H5S_t *space);
-static herr_t H5S_none_serialize(const H5S_t *space, uint8_t **p);
-static herr_t H5S_none_deserialize(H5S_t *space, uint32_t version, uint8_t flags,
- const uint8_t **p);
-static herr_t H5S_none_bounds(const H5S_t *space, hsize_t *start, hsize_t *end);
-static herr_t H5S_none_offset(const H5S_t *space, hsize_t *off);
+static herr_t H5S__none_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection);
+static herr_t H5S__none_release(H5S_t *space);
+static htri_t H5S__none_is_valid(const H5S_t *space);
+static hssize_t H5S__none_serial_size(const H5S_t *space);
+static herr_t H5S__none_serialize(const H5S_t *space, uint8_t **p);
+static herr_t H5S__none_deserialize(H5S_t **space, const uint8_t **p);
+static herr_t H5S__none_bounds(const H5S_t *space, hsize_t *start, hsize_t *end);
+static herr_t H5S__none_offset(const H5S_t *space, hsize_t *off);
static int H5S__none_unlim_dim(const H5S_t *space);
-static htri_t H5S_none_is_contiguous(const H5S_t *space);
-static htri_t H5S_none_is_single(const H5S_t *space);
-static htri_t H5S_none_is_regular(const H5S_t *space);
-static herr_t H5S_none_adjust_u(H5S_t *space, const hsize_t *offset);
-static herr_t H5S_none_project_scalar(const H5S_t *space, hsize_t *offset);
-static herr_t H5S_none_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset);
-static herr_t H5S_none_iter_init(H5S_sel_iter_t *iter, const H5S_t *space);
+static htri_t H5S__none_is_contiguous(const H5S_t *space);
+static htri_t H5S__none_is_single(const H5S_t *space);
+static htri_t H5S__none_is_regular(const H5S_t *space);
+static htri_t H5S__none_shape_same(const H5S_t *space1, const H5S_t *space2);
+static herr_t H5S__none_adjust_u(H5S_t *space, const hsize_t *offset);
+static herr_t H5S__none_project_scalar(const H5S_t *space, hsize_t *offset);
+static herr_t H5S__none_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset);
+static herr_t H5S__none_iter_init(const H5S_t *space, H5S_sel_iter_t *iter);
/* Selection iteration callbacks */
-static herr_t H5S_none_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords);
-static herr_t H5S_none_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end);
-static hsize_t H5S_none_iter_nelmts(const H5S_sel_iter_t *iter);
-static htri_t H5S_none_iter_has_next_block(const H5S_sel_iter_t *iter);
-static herr_t H5S_none_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem);
-static herr_t H5S_none_iter_next_block(H5S_sel_iter_t *sel_iter);
-static herr_t H5S_none_iter_release(H5S_sel_iter_t *sel_iter);
+static herr_t H5S__none_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords);
+static herr_t H5S__none_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end);
+static hsize_t H5S__none_iter_nelmts(const H5S_sel_iter_t *iter);
+static htri_t H5S__none_iter_has_next_block(const H5S_sel_iter_t *iter);
+static herr_t H5S__none_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem);
+static herr_t H5S__none_iter_next_block(H5S_sel_iter_t *sel_iter);
+static herr_t H5S__none_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq,
+ size_t maxbytes, size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len);
+static herr_t H5S__none_iter_release(H5S_sel_iter_t *sel_iter);
+
+
+/*****************************/
+/* Library Private Variables */
+/*****************************/
+
+
+/*********************/
+/* Package Variables */
+/*********************/
/* Selection properties for "none" selections */
const H5S_select_class_t H5S_sel_none[1] = {{
H5S_SEL_NONE,
/* Methods on selection */
- H5S_none_copy,
- H5S_none_get_seq_list,
- H5S_none_release,
- H5S_none_is_valid,
- H5S_none_serial_size,
- H5S_none_serialize,
- H5S_none_deserialize,
- H5S_none_bounds,
- H5S_none_offset,
+ H5S__none_copy,
+ H5S__none_release,
+ H5S__none_is_valid,
+ H5S__none_serial_size,
+ H5S__none_serialize,
+ H5S__none_deserialize,
+ H5S__none_bounds,
+ H5S__none_offset,
H5S__none_unlim_dim,
NULL,
- H5S_none_is_contiguous,
- H5S_none_is_single,
- H5S_none_is_regular,
- H5S_none_adjust_u,
- H5S_none_project_scalar,
- H5S_none_project_simple,
- H5S_none_iter_init,
+ H5S__none_is_contiguous,
+ H5S__none_is_single,
+ H5S__none_is_regular,
+ H5S__none_shape_same,
+ H5S__none_adjust_u,
+ H5S__none_project_scalar,
+ H5S__none_project_simple,
+ H5S__none_iter_init,
}};
+
+/*******************/
+/* Local Variables */
+/*******************/
+
/* Iteration properties for "none" selections */
static const H5S_sel_iter_class_t H5S_sel_iter_none[1] = {{
H5S_SEL_NONE,
/* Methods on selection iterator */
- H5S_none_iter_coords,
- H5S_none_iter_block,
- H5S_none_iter_nelmts,
- H5S_none_iter_has_next_block,
- H5S_none_iter_next,
- H5S_none_iter_next_block,
- H5S_none_iter_release,
+ H5S__none_iter_coords,
+ H5S__none_iter_block,
+ H5S__none_iter_nelmts,
+ H5S__none_iter_has_next_block,
+ H5S__none_iter_next,
+ H5S__none_iter_next_block,
+ H5S__none_iter_get_seq_list,
+ H5S__none_iter_release,
}};
+
/*-------------------------------------------------------------------------
- * Function: H5S_none_iter_init
+ * Function: H5S__none_iter_init
*
* Purpose: Initializes iteration information for "none" selection.
*
- * Return: non-negative on success, negative on failure.
+ * Return: Non-negative on success, negative on failure.
*
* Programmer: Quincey Koziol
* Tuesday, June 16, 1998
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static herr_t
-H5S_none_iter_init(H5S_sel_iter_t *iter, const H5S_t H5_ATTR_UNUSED *space)
+H5S__none_iter_init(const H5S_t H5_ATTR_UNUSED *space, H5S_sel_iter_t *iter)
{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
/* Check args */
- HDassert(space && H5S_SEL_NONE==H5S_GET_SELECT_TYPE(space));
+ HDassert(space && H5S_SEL_NONE == H5S_GET_SELECT_TYPE(space));
HDassert(iter);
/* Initialize type of selection iterator */
iter->type = H5S_sel_iter_none;
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5S_none_iter_init() */
+} /* end H5S__none_iter_init() */
/*-------------------------------------------------------------------------
- * Function: H5S_none_iter_coords
+ * Function: H5S__none_iter_coords
*
* Purpose: Retrieve the current coordinates of iterator for current
* selection
*
- * Return: non-negative on success, negative on failure
+ * Return: Non-negative on success, negative on failure
*
* Programmer: Quincey Koziol
* Tuesday, April 22, 2003
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static herr_t
-H5S_none_iter_coords(const H5S_sel_iter_t H5_ATTR_UNUSED *iter, hsize_t H5_ATTR_UNUSED *coords)
+H5S__none_iter_coords(const H5S_sel_iter_t H5_ATTR_UNUSED *iter,
+ hsize_t H5_ATTR_UNUSED *coords)
{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
/* Check args */
HDassert(iter);
HDassert(coords);
FUNC_LEAVE_NOAPI(FAIL)
-} /* H5S_none_iter_coords() */
+} /* end H5S__none_iter_coords() */
/*-------------------------------------------------------------------------
- * Function: H5S_none_iter_block
+ * Function: H5S__none_iter_block
*
* Purpose: Retrieve the current block of iterator for current
* selection
*
- * Return: non-negative on success, negative on failure
+ * Return: Non-negative on success, negative on failure
*
* Programmer: Quincey Koziol
* Monday, June 2, 2003
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static herr_t
-H5S_none_iter_block(const H5S_sel_iter_t H5_ATTR_UNUSED *iter, hsize_t H5_ATTR_UNUSED *start, hsize_t H5_ATTR_UNUSED *end)
+H5S__none_iter_block(const H5S_sel_iter_t H5_ATTR_UNUSED *iter,
+ hsize_t H5_ATTR_UNUSED *start, hsize_t H5_ATTR_UNUSED *end)
{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
/* Check args */
HDassert(iter);
@@ -185,42 +216,40 @@ H5S_none_iter_block(const H5S_sel_iter_t H5_ATTR_UNUSED *iter, hsize_t H5_ATTR_U
HDassert(end);
FUNC_LEAVE_NOAPI(FAIL)
-} /* H5S_none_iter_block() */
+} /* end H5S__none_iter_block() */
/*-------------------------------------------------------------------------
- * Function: H5S_none_iter_nelmts
+ * Function: H5S__none_iter_nelmts
*
* Purpose: Return number of elements left to process in iterator
*
- * Return: non-negative number of elements on success, zero on failure
+ * Return: Non-negative number of elements on success, zero on failure
*
* Programmer: Quincey Koziol
* Tuesday, June 16, 1998
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static hsize_t
-H5S_none_iter_nelmts(const H5S_sel_iter_t H5_ATTR_UNUSED *iter)
+H5S__none_iter_nelmts(const H5S_sel_iter_t H5_ATTR_UNUSED *iter)
{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
/* Check args */
HDassert(iter);
FUNC_LEAVE_NOAPI(0)
-} /* H5S_none_iter_nelmts() */
+} /* end H5S__none_iter_nelmts() */
/*--------------------------------------------------------------------------
NAME
- H5S_none_iter_has_next_block
+ H5S__none_iter_has_next_block
PURPOSE
Check if there is another block left in the current iterator
USAGE
- htri_t H5S_none_iter_has_next_block(iter)
+ htri_t H5S__none_iter_has_next_block(iter)
const H5S_sel_iter_t *iter; IN: Pointer to selection iterator
RETURNS
Non-negative (TRUE/FALSE) on success/Negative on failure
@@ -232,24 +261,24 @@ H5S_none_iter_nelmts(const H5S_sel_iter_t H5_ATTR_UNUSED *iter)
REVISION LOG
--------------------------------------------------------------------------*/
static htri_t
-H5S_none_iter_has_next_block(const H5S_sel_iter_t H5_ATTR_UNUSED *iter)
+H5S__none_iter_has_next_block(const H5S_sel_iter_t H5_ATTR_UNUSED *iter)
{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
/* Check args */
HDassert(iter);
FUNC_LEAVE_NOAPI(FAIL)
-} /* H5S_none_iter_has_next_block() */
+} /* end H5S__none_iter_has_next_block() */
/*--------------------------------------------------------------------------
NAME
- H5S_none_iter_next
+ H5S__none_iter_next
PURPOSE
Increment selection iterator
USAGE
- herr_t H5S_none_iter_next(iter, nelem)
+ herr_t H5S__none_iter_next(iter, nelem)
H5S_sel_iter_t *iter; IN: Pointer to selection iterator
size_t nelem; IN: Number of elements to advance by
RETURNS
@@ -262,25 +291,25 @@ H5S_none_iter_has_next_block(const H5S_sel_iter_t H5_ATTR_UNUSED *iter)
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
-H5S_none_iter_next(H5S_sel_iter_t H5_ATTR_UNUSED *iter, size_t H5_ATTR_UNUSED nelem)
+H5S__none_iter_next(H5S_sel_iter_t H5_ATTR_UNUSED *iter, size_t H5_ATTR_UNUSED nelem)
{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
/* Check args */
HDassert(iter);
- HDassert(nelem>0);
+ HDassert(nelem > 0);
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5S_none_iter_next() */
+} /* end H5S__none_iter_next() */
/*--------------------------------------------------------------------------
NAME
- H5S_none_iter_next_block
+ H5S__none_iter_next_block
PURPOSE
Increment selection iterator to next block
USAGE
- herr_t H5S_none_iter_next(iter)
+ herr_t H5S__none_iter_next(iter)
H5S_sel_iter_t *iter; IN: Pointer to selection iterator
RETURNS
Non-negative on success/Negative on failure
@@ -292,24 +321,79 @@ H5S_none_iter_next(H5S_sel_iter_t H5_ATTR_UNUSED *iter, size_t H5_ATTR_UNUSED ne
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
-H5S_none_iter_next_block(H5S_sel_iter_t H5_ATTR_UNUSED *iter)
+H5S__none_iter_next_block(H5S_sel_iter_t H5_ATTR_UNUSED *iter)
{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
/* Check args */
HDassert(iter);
FUNC_LEAVE_NOAPI(FAIL)
-} /* H5S_none_iter_next_block() */
+} /* end H5S__none_iter_next_block() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S__none_iter_get_seq_list
+ PURPOSE
+ Create a list of offsets & lengths for a selection
+ USAGE
+ herr_t H5S__none_iter_get_seq_list(iter,maxseq,maxelem,nseq,nelem,off,len)
+ H5S_sel_iter_t *iter; IN/OUT: Selection iterator describing last
+ position of interest in selection.
+ size_t maxseq; IN: Maximum number of sequences to generate
+ size_t maxelem; IN: Maximum number of elements to include in the
+ generated sequences
+ size_t *nseq; OUT: Actual number of sequences generated
+ size_t *nelem; OUT: Actual number of elements in sequences generated
+ hsize_t *off; OUT: Array of offsets
+ size_t *len; OUT: Array of lengths
+ RETURNS
+ Non-negative on success/Negative on failure.
+ DESCRIPTION
+ Use the selection in the dataspace to generate a list of byte offsets and
+ lengths for the region(s) selected. Start/Restart from the position in the
+ ITER parameter. The number of sequences generated is limited by the MAXSEQ
+ parameter and the number of sequences actually generated is stored in the
+ NSEQ parameter.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+static herr_t
+H5S__none_iter_get_seq_list(H5S_sel_iter_t H5_ATTR_UNUSED *iter,
+ size_t H5_ATTR_UNUSED maxseq, size_t H5_ATTR_UNUSED maxelem, size_t *nseq,
+ size_t *nelem, hsize_t H5_ATTR_UNUSED *off, size_t H5_ATTR_UNUSED *len)
+{
+ FUNC_ENTER_STATIC_NOERR
+
+ /* Check args */
+ HDassert(iter);
+ HDassert(maxseq > 0);
+ HDassert(maxelem > 0);
+ HDassert(nseq);
+ HDassert(nelem);
+ HDassert(off);
+ HDassert(len);
+
+ /* "none" selections don't generate sequences of bytes */
+ *nseq = 0;
+
+ /* They don't use any elements, either */
+ *nelem = 0;
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5S__none_iter_get_seq_list() */
/*--------------------------------------------------------------------------
NAME
- H5S_none_iter_release
+ H5S__none_iter_release
PURPOSE
Release "none" selection iterator information for a dataspace
USAGE
- herr_t H5S_none_iter_release(iter)
+ herr_t H5S__none_iter_release(iter)
H5S_sel_iter_t *iter; IN: Pointer to selection iterator
RETURNS
Non-negative on success/Negative on failure
@@ -321,24 +405,24 @@ H5S_none_iter_next_block(H5S_sel_iter_t H5_ATTR_UNUSED *iter)
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
-H5S_none_iter_release(H5S_sel_iter_t H5_ATTR_UNUSED * iter)
+H5S__none_iter_release(H5S_sel_iter_t H5_ATTR_UNUSED *iter)
{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
/* Check args */
HDassert(iter);
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5S_none_iter_release() */
+} /* end H5S__none_iter_release() */
/*--------------------------------------------------------------------------
NAME
- H5S_none_release
+ H5S__none_release
PURPOSE
Release none selection information for a dataspace
USAGE
- herr_t H5S_none_release(space)
+ herr_t H5S__none_release(space)
H5S_t *space; IN: Pointer to dataspace
RETURNS
Non-negative on success/Negative on failure
@@ -350,26 +434,27 @@ H5S_none_iter_release(H5S_sel_iter_t H5_ATTR_UNUSED * iter)
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
-H5S_none_release(H5S_t H5_ATTR_UNUSED * space)
+H5S__none_release(H5S_t H5_ATTR_UNUSED *space)
{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
/* Check args */
HDassert(space);
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5S_none_release() */
+} /* end H5S__none_release() */
/*--------------------------------------------------------------------------
NAME
- H5S_none_copy
+ H5S__none_copy
PURPOSE
Copy a selection from one dataspace to another
USAGE
- herr_t H5S_none_copy(dst, src)
+ herr_t H5S__none_copy(dst, src, share_selection)
H5S_t *dst; OUT: Pointer to the destination dataspace
H5S_t *src; IN: Pointer to the source dataspace
+ hbool_t; IN: Whether to share the selection between the dataspaces
RETURNS
Non-negative on success/Negative on failure
DESCRIPTION
@@ -381,9 +466,10 @@ H5S_none_release(H5S_t H5_ATTR_UNUSED * space)
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
-H5S_none_copy(H5S_t *dst, const H5S_t H5_ATTR_UNUSED *src, hbool_t H5_ATTR_UNUSED share_selection)
+H5S__none_copy(H5S_t *dst, const H5S_t H5_ATTR_UNUSED *src,
+ hbool_t H5_ATTR_UNUSED share_selection)
{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
HDassert(src);
HDassert(dst);
@@ -392,17 +478,17 @@ H5S_none_copy(H5S_t *dst, const H5S_t H5_ATTR_UNUSED *src, hbool_t H5_ATTR_UNUSE
dst->select.num_elem = 0;
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* end H5S_none_copy() */
+} /* end H5S__none_copy() */
/*--------------------------------------------------------------------------
NAME
- H5S_none_is_valid
+ H5S__none_is_valid
PURPOSE
Check whether the selection fits within the extent, with the current
offset defined.
USAGE
- htri_t H5S_none_is_valid(space);
+ htri_t H5S__none_is_valid(space);
H5S_t *space; IN: Dataspace pointer to query
RETURNS
TRUE if the selection fits within the extent, FALSE if it does not and
@@ -416,24 +502,24 @@ H5S_none_copy(H5S_t *dst, const H5S_t H5_ATTR_UNUSED *src, hbool_t H5_ATTR_UNUSE
REVISION LOG
--------------------------------------------------------------------------*/
static htri_t
-H5S_none_is_valid(const H5S_t H5_ATTR_UNUSED *space)
+H5S__none_is_valid(const H5S_t H5_ATTR_UNUSED *space)
{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
HDassert(space);
FUNC_LEAVE_NOAPI(TRUE)
-} /* end H5S_none_is_valid() */
+} /* end H5S__none_is_valid() */
/*--------------------------------------------------------------------------
NAME
- H5S_none_serial_size
+ H5S__none_serial_size
PURPOSE
Determine the number of bytes needed to store the serialized "none"
selection information.
USAGE
- hssize_t H5S_none_serial_size(space)
+ hssize_t H5S__none_serial_size(space)
H5S_t *space; IN: Dataspace pointer to query
RETURNS
The number of bytes required on success, negative on an error.
@@ -446,9 +532,9 @@ H5S_none_is_valid(const H5S_t H5_ATTR_UNUSED *space)
REVISION LOG
--------------------------------------------------------------------------*/
static hssize_t
-H5S_none_serial_size(const H5S_t H5_ATTR_UNUSED *space)
+H5S__none_serial_size(const H5S_t H5_ATTR_UNUSED *space)
{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
HDassert(space);
@@ -457,16 +543,16 @@ H5S_none_serial_size(const H5S_t H5_ATTR_UNUSED *space)
* <length (4 bytes)> = 16 bytes
*/
FUNC_LEAVE_NOAPI(16)
-} /* end H5S_none_serial_size() */
+} /* end H5S__none_serial_size() */
/*--------------------------------------------------------------------------
NAME
- H5S_none_serialize
+ H5S__none_serialize
PURPOSE
Serialize the current selection into a user-provided buffer.
USAGE
- herr_t H5S_none_serialize(space, p)
+ herr_t H5S__none_serialize(space, p)
const H5S_t *space; IN: Dataspace with selection to serialize
uint8_t **p; OUT: Pointer to buffer to put serialized
selection. Will be advanced to end of
@@ -482,11 +568,11 @@ H5S_none_serial_size(const H5S_t H5_ATTR_UNUSED *space)
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
-H5S_none_serialize(const H5S_t *space, uint8_t **p)
+H5S__none_serialize(const H5S_t *space, uint8_t **p)
{
uint8_t *pp = (*p); /* Local pointer for decoding */
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
/* Check args */
HDassert(space);
@@ -495,7 +581,7 @@ H5S_none_serialize(const H5S_t *space, uint8_t **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)H5S_NONE_VERSION_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 */
@@ -503,20 +589,18 @@ H5S_none_serialize(const H5S_t *space, uint8_t **p)
*p = pp;
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5S_none_serialize() */
+} /* end H5S__none_serialize() */
/*--------------------------------------------------------------------------
NAME
- H5S_none_deserialize
+ H5S__none_deserialize
PURPOSE
Deserialize the current selection from a user-provided buffer.
USAGE
- herr_t H5S_none_deserialize(space, version, flags, p)
- H5S_t *space; IN/OUT: Dataspace pointer to place
+ herr_t H5S__none_deserialize(space, version, flags, p)
+ H5S_t **space; IN/OUT: Dataspace pointer to place
selection into
- uint32_t version IN: Selection version
- uint8_t flags IN: Selection flags
uint8 **p; OUT: Pointer to buffer holding serialized
selection. Will be advanced to end of
serialized selection.
@@ -531,33 +615,61 @@ H5S_none_serialize(const H5S_t *space, uint8_t **p)
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
-H5S_none_deserialize(H5S_t *space, uint32_t H5_ATTR_UNUSED version, uint8_t H5_ATTR_UNUSED flags,
- const uint8_t H5_ATTR_UNUSED **p)
+H5S__none_deserialize(H5S_t **space, const uint8_t **p)
{
- herr_t ret_value = SUCCEED; /* return value */
+ H5S_t *tmp_space = NULL; /* Pointer to actual dataspace to use,
+ either *space or a newly allocated one */
+ uint32_t version; /* Version number */
+ herr_t ret_value = SUCCEED; /* return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_STATIC
- HDassert(space);
HDassert(p);
HDassert(*p);
+ /* As part of the efforts to push all selection-type specific coding
+ to the callbacks, the coding for the allocation of a null dataspace
+ is moved from H5S_select_deserialize() in H5Sselect.c to here.
+ This is needed for decoding virtual layout in H5O__layout_decode() */
+ /* Allocate space if not provided */
+ if(!*space) {
+ if(NULL == (tmp_space = H5S_create(H5S_SIMPLE)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create dataspace")
+ } /* end if */
+ else
+ tmp_space = *space;
+
+ /* Decode version */
+ UINT32DECODE(*p, version);
+
+ /* Skip over the remainder of the header */
+ *p += 8;
+
/* Change to "none" selection */
- if(H5S_select_none(space) < 0)
+ if(H5S_select_none(tmp_space) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection")
+ /* Return space to the caller if allocated */
+ if(!*space)
+ *space = tmp_space;
+
done:
+ /* Free temporary space if not passed to caller (only happens on error) */
+ if(!*space && tmp_space)
+ if(H5S_close(tmp_space) < 0)
+ HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "can't close dataspace")
+
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_none_deserialize() */
+} /* end H5S__none_deserialize() */
/*--------------------------------------------------------------------------
NAME
- H5S_none_bounds
+ H5S__none_bounds
PURPOSE
Gets the bounding box containing the selection.
USAGE
- herr_t H5S_none_bounds(space, start, end)
+ herr_t H5S__none_bounds(space, start, end)
H5S_t *space; IN: Dataspace pointer of selection to query
hsize_t *start; OUT: Starting coordinate of bounding box
hsize_t *end; OUT: Opposite coordinate of bounding box
@@ -577,25 +689,26 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
-H5S_none_bounds(const H5S_t H5_ATTR_UNUSED *space, hsize_t H5_ATTR_UNUSED *start, hsize_t H5_ATTR_UNUSED *end)
+H5S__none_bounds(const H5S_t H5_ATTR_UNUSED *space, hsize_t H5_ATTR_UNUSED *start,
+ hsize_t H5_ATTR_UNUSED *end)
{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
HDassert(space);
HDassert(start);
HDassert(end);
FUNC_LEAVE_NOAPI(FAIL)
-} /* H5Sget_none_bounds() */
+} /* end H5Sget_none_bounds() */
/*--------------------------------------------------------------------------
NAME
- H5S_none_offset
+ H5S__none_offset
PURPOSE
Gets the linear offset of the first element for the selection.
USAGE
- herr_t H5S_none_offset(space, offset)
+ herr_t H5S__none_offset(space, offset)
const H5S_t *space; IN: Dataspace pointer of selection to query
hsize_t *offset; OUT: Linear offset of first element in selection
RETURNS
@@ -610,15 +723,15 @@ H5S_none_bounds(const H5S_t H5_ATTR_UNUSED *space, hsize_t H5_ATTR_UNUSED *start
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
-H5S_none_offset(const H5S_t H5_ATTR_UNUSED *space, hsize_t H5_ATTR_UNUSED *offset)
+H5S__none_offset(const H5S_t H5_ATTR_UNUSED *space, hsize_t H5_ATTR_UNUSED *offset)
{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
HDassert(space);
HDassert(offset);
FUNC_LEAVE_NOAPI(FAIL)
-} /* H5S_none_offset() */
+} /* end H5S__none_offset() */
/*--------------------------------------------------------------------------
@@ -651,11 +764,11 @@ H5S__none_unlim_dim(const H5S_t H5_ATTR_UNUSED *space)
/*--------------------------------------------------------------------------
NAME
- H5S_none_is_contiguous
+ H5S__none_is_contiguous
PURPOSE
Check if a "none" selection is contiguous within the dataspace extent.
USAGE
- htri_t H5S_none_is_contiguous(space)
+ htri_t H5S__none_is_contiguous(space)
H5S_t *space; IN: Dataspace pointer to check
RETURNS
TRUE/FALSE/FAIL
@@ -668,23 +781,23 @@ H5S__none_unlim_dim(const H5S_t H5_ATTR_UNUSED *space)
REVISION LOG
--------------------------------------------------------------------------*/
static htri_t
-H5S_none_is_contiguous(const H5S_t H5_ATTR_UNUSED *space)
+H5S__none_is_contiguous(const H5S_t H5_ATTR_UNUSED *space)
{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
HDassert(space);
FUNC_LEAVE_NOAPI(FALSE)
-} /* H5S_none_is_contiguous() */
+} /* end H5S__none_is_contiguous() */
/*--------------------------------------------------------------------------
NAME
- H5S_none_is_single
+ H5S__none_is_single
PURPOSE
Check if a "none" selection is a single block within the dataspace extent.
USAGE
- htri_t H5S_none_is_single(space)
+ htri_t H5S__none_is_single(space)
H5S_t *space; IN: Dataspace pointer to check
RETURNS
TRUE/FALSE/FAIL
@@ -697,23 +810,23 @@ H5S_none_is_contiguous(const H5S_t H5_ATTR_UNUSED *space)
REVISION LOG
--------------------------------------------------------------------------*/
static htri_t
-H5S_none_is_single(const H5S_t H5_ATTR_UNUSED *space)
+H5S__none_is_single(const H5S_t H5_ATTR_UNUSED *space)
{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
HDassert(space);
FUNC_LEAVE_NOAPI(FALSE)
-} /* H5S_none_is_single() */
+} /* end H5S__none_is_single() */
/*--------------------------------------------------------------------------
NAME
- H5S_none_is_regular
+ H5S__none_is_regular
PURPOSE
Check if a "none" selection is "regular"
USAGE
- htri_t H5S_none_is_regular(space)
+ htri_t H5S__none_is_regular(space)
const H5S_t *space; IN: Dataspace pointer to check
RETURNS
TRUE/FALSE/FAIL
@@ -727,24 +840,57 @@ H5S_none_is_single(const H5S_t H5_ATTR_UNUSED *space)
REVISION LOG
--------------------------------------------------------------------------*/
static htri_t
-H5S_none_is_regular(const H5S_t H5_ATTR_UNUSED *space)
+H5S__none_is_regular(const H5S_t H5_ATTR_UNUSED *space)
{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
/* Check args */
HDassert(space);
FUNC_LEAVE_NOAPI(TRUE)
-} /* H5S_none_is_regular() */
+} /* end H5S__none_is_regular() */
/*--------------------------------------------------------------------------
NAME
- H5S_none_adjust_u
+ H5S__none_shape_same
+ PURPOSE
+ Check if a two "none" selections are the same shape
+ USAGE
+ htri_t H5S__none_shape_same(space1, space2)
+ const H5S_t *space1; IN: First dataspace to check
+ const H5S_t *space2; IN: Second dataspace to check
+ RETURNS
+ TRUE / FALSE / FAIL
+ DESCRIPTION
+ Checks to see if the current selection in each dataspace are the same
+ shape.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+static htri_t
+H5S__none_shape_same(const H5S_t H5_ATTR_UNUSED *space1,
+ const H5S_t H5_ATTR_UNUSED *space2)
+{
+ FUNC_ENTER_STATIC_NOERR
+
+ /* Check args */
+ HDassert(space1);
+ HDassert(space2);
+
+ FUNC_LEAVE_NOAPI(TRUE)
+} /* end H5S__none_shape_same() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S__none_adjust_u
PURPOSE
Adjust an "none" selection by subtracting an offset
USAGE
- herr_t H5S_none_adjust_u(space, offset)
+ herr_t H5S__none_adjust_u(space, offset)
H5S_t *space; IN/OUT: Pointer to dataspace to adjust
const hsize_t *offset; IN: Offset to subtract
RETURNS
@@ -757,24 +903,24 @@ H5S_none_is_regular(const H5S_t H5_ATTR_UNUSED *space)
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
-H5S_none_adjust_u(H5S_t H5_ATTR_UNUSED *space, const hsize_t H5_ATTR_UNUSED *offset)
+H5S__none_adjust_u(H5S_t H5_ATTR_UNUSED *space, const hsize_t H5_ATTR_UNUSED *offset)
{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
/* Check args */
HDassert(space);
HDassert(offset);
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5S_none_adjust_u() */
+} /* end H5S__none_adjust_u() */
/*-------------------------------------------------------------------------
- * Function: H5S_none_project_scalar
+ * Function: H5S__none_project_scalar
*
* Purpose: Projects a 'none' selection into a scalar dataspace
*
- * Return: non-negative on success, negative on failure.
+ * Return: Non-negative on success, negative on failure.
*
* Programmer: Quincey Koziol
* Sunday, July 18, 2010
@@ -782,25 +928,25 @@ H5S_none_adjust_u(H5S_t H5_ATTR_UNUSED *space, const hsize_t H5_ATTR_UNUSED *off
*-------------------------------------------------------------------------
*/
static herr_t
-H5S_none_project_scalar(const H5S_t H5_ATTR_UNUSED *space, hsize_t H5_ATTR_UNUSED *offset)
+H5S__none_project_scalar(const H5S_t H5_ATTR_UNUSED *space, hsize_t H5_ATTR_UNUSED *offset)
{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
/* Check args */
HDassert(space && H5S_SEL_NONE == H5S_GET_SELECT_TYPE(space));
HDassert(offset);
FUNC_LEAVE_NOAPI(FAIL)
-} /* H5S_none_project_scalar() */
+} /* end H5S__none_project_scalar() */
/*-------------------------------------------------------------------------
- * Function: H5S_none_project_simple
+ * Function: H5S__none_project_simple
*
* Purpose: Projects an 'none' selection onto/into a simple dataspace
* of a different rank
*
- * Return: non-negative on success, negative on failure.
+ * Return: Non-negative on success, negative on failure.
*
* Programmer: Quincey Koziol
* Sunday, July 18, 2010
@@ -808,11 +954,12 @@ H5S_none_project_scalar(const H5S_t H5_ATTR_UNUSED *space, hsize_t H5_ATTR_UNUSE
*-------------------------------------------------------------------------
*/
static herr_t
-H5S_none_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *offset)
+H5S__none_project_simple(const H5S_t H5_ATTR_UNUSED *base_space,
+ H5S_t *new_space, hsize_t H5_ATTR_UNUSED *offset)
{
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_STATIC
/* Check args */
HDassert(base_space && H5S_SEL_NONE == H5S_GET_SELECT_TYPE(base_space));
@@ -825,7 +972,7 @@ H5S_none_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *offs
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_none_project_simple() */
+} /* end H5S__none_project_simple() */
/*--------------------------------------------------------------------------
@@ -867,7 +1014,7 @@ H5S_select_none(H5S_t *space)
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_select_none() */
+} /* end H5S_select_none() */
/*--------------------------------------------------------------------------
@@ -906,63 +1053,5 @@ H5Sselect_none(hid_t spaceid)
done:
FUNC_LEAVE_API(ret_value)
-} /* H5Sselect_none() */
-
-
-/*--------------------------------------------------------------------------
- NAME
- H5S_none_get_seq_list
- PURPOSE
- Create a list of offsets & lengths for a selection
- USAGE
- herr_t H5S_none_get_seq_list(space,flags,iter,maxseq,maxelem,nseq,nelem,off,len)
- H5S_t *space; IN: Dataspace containing selection to use.
- unsigned flags; IN: Flags for extra information about operation
- H5S_sel_iter_t *iter; IN/OUT: Selection iterator describing last
- position of interest in selection.
- size_t maxseq; IN: Maximum number of sequences to generate
- size_t maxelem; IN: Maximum number of elements to include in the
- generated sequences
- size_t *nseq; OUT: Actual number of sequences generated
- size_t *nelem; OUT: Actual number of elements in sequences generated
- hsize_t *off; OUT: Array of offsets
- size_t *len; OUT: Array of lengths
- RETURNS
- Non-negative on success/Negative on failure.
- DESCRIPTION
- Use the selection in the dataspace to generate a list of byte offsets and
- lengths for the region(s) selected. Start/Restart from the position in the
- ITER parameter. The number of sequences generated is limited by the MAXSEQ
- parameter and the number of sequences actually generated is stored in the
- NSEQ parameter.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-static herr_t
-H5S_none_get_seq_list(const H5S_t H5_ATTR_UNUSED *space, unsigned H5_ATTR_UNUSED flags, H5S_sel_iter_t H5_ATTR_UNUSED *iter,
- size_t H5_ATTR_UNUSED maxseq, size_t H5_ATTR_UNUSED maxelem, size_t *nseq, size_t *nelem,
- hsize_t H5_ATTR_UNUSED *off, size_t H5_ATTR_UNUSED *len)
-{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
-
- /* Check args */
- HDassert(space);
- HDassert(iter);
- HDassert(maxseq > 0);
- HDassert(maxelem > 0);
- HDassert(nseq);
- HDassert(nelem);
- HDassert(off);
- HDassert(len);
-
- /* "none" selections don't generate sequences of bytes */
- *nseq = 0;
-
- /* They don't use any elements, either */
- *nelem = 0;
-
- FUNC_LEAVE_NOAPI(SUCCEED)
-} /* end H5S_none_get_seq_list() */
+} /* end H5Sselect_none() */
diff --git a/src/H5Spkg.h b/src/H5Spkg.h
index 9ad97dc..4752c59 100644
--- a/src/H5Spkg.h
+++ b/src/H5Spkg.h
@@ -26,19 +26,53 @@
#ifndef _H5Spkg_H
#define _H5Spkg_H
+/* Get package's private header */
#include "H5Sprivate.h"
+/* Other private headers needed by this file */
+#include "H5Oprivate.h" /* Object headers */
+
/* Flags to indicate special dataspace features are active */
#define H5S_VALID_MAX 0x01
#define H5S_VALID_PERM 0x02
/* Flags for serialization of selections */
-#define H5S_SELECT_FLAG_UNLIM 0x01
-#define H5S_SELECT_FLAG_BITS (H5S_SELECT_FLAG_UNLIM)
+#define H5S_HYPER_REGULAR 0x01
+#define H5S_SELECT_FLAG_BITS (H5S_HYPER_REGULAR)
+
+/* Versions for H5S_SEL_HYPER selection info */
+#define H5S_HYPER_VERSION_1 1
+#define H5S_HYPER_VERSION_2 2
+#define H5S_HYPER_VERSION_3 3
+
+/* Versions for H5S_SEL_POINTS selection info */
+#define H5S_POINT_VERSION_1 1
+#define H5S_POINT_VERSION_2 2
+
+/* Versions for H5S_SEL_NONE selection info */
+#define H5S_NONE_VERSION_1 1
+
+/* Versions for H5S_SEL_ALL selection info */
+#define H5S_ALL_VERSION_1 1
+
+/* Encoded size of selection info for H5S_SEL_POINTS/H5S_SEL_HYPER */
+#define H5S_SELECT_INFO_ENC_SIZE_2 0x02 /* 2 bytes: 16 bits */
+#define H5S_SELECT_INFO_ENC_SIZE_4 0x04 /* 4 bytes: 32 bits */
+#define H5S_SELECT_INFO_ENC_SIZE_8 0x08 /* 8 bytes: 64 bits */
+#define H5S_SELECT_INFO_ENC_SIZE_BITS ( H5S_SELECT_INFO_ENC_SIZE_2 | \
+ H5S_SELECT_INFO_ENC_SIZE_4 | \
+ H5S_SELECT_INFO_ENC_SIZE_8 )
+
+#define H5S_UINT16_MAX 0x0000FFFF /* 2^16 - 1 = 65,535 */
+#define H5S_UINT32_MAX 0xFFFFFFFF /* 2^32 - 1 = 4,294,967,295 */
+#define H5S_UINT64_MAX ((hsize_t)(-1L)) /* 2^64 - 1 = 18,446,744,073,709,551,615 */
/* Length of stack-allocated sequences for "project intersect" routines */
#define H5S_PROJECT_INTERSECT_NSEQS 256
+/* Internal flags for initializing selection iterators */
+#define H5S_SEL_ITER_API_CALL 0x1000 /* Selection iterator created from API call */
+
/* Initial version of the dataspace information */
#define H5O_SDSPACE_VERSION_1 1
@@ -77,51 +111,100 @@ struct H5S_extent_t {
/*
* Dataspace selection information
*/
+
/* Node in point selection list (typedef'd in H5Sprivate.h) */
struct H5S_pnt_node_t {
- hsize_t *pnt; /* Pointer to a selected point */
- struct H5S_pnt_node_t *next; /* pointer to next point in list */
+ struct H5S_pnt_node_t *next; /* Pointer to next point in list */
+ hsize_t pnt[]; /* Selected point */
+ /* (NOTE: This uses the C99 "flexible array member" feature) */
};
-/* Information about point selection list */
-typedef struct {
+/* Information about point selection list (typedef'd in H5Sprivate.h) */
+struct H5S_pnt_list_t {
+ /* The following two fields defines the bounding box of the whole set of points, relative to the offset */
+ hsize_t low_bounds[H5S_MAX_RANK]; /* The smallest element selected in each dimension */
+ hsize_t high_bounds[H5S_MAX_RANK]; /* The largest element selected in each dimension */
+
H5S_pnt_node_t *head; /* Pointer to head of point list */
-} H5S_pnt_list_t;
+ H5S_pnt_node_t *tail; /* Pointer to tail of point list */
+};
-/* Information about new-style hyperslab spans */
+/* Information about hyperslab spans */
-/* Information a particular hyperslab span */
+/* Information a particular hyperslab span (typedef'd in H5Sprivate.h) */
struct H5S_hyper_span_t {
- hsize_t low, high; /* Low & high bounds of span */
- hsize_t nelem; /* Number of elements in span (only needed during I/O) */
- hsize_t pstride; /* Pseudo-stride from start of previous span (only used during I/O) */
- struct H5S_hyper_span_info_t *down; /* Pointer to list of spans in next dimension down */
- struct H5S_hyper_span_t *next; /* Pointer to next span in list */
+ hsize_t low, high; /* Low & high bounds of elements selected for span, inclusive */
+ struct H5S_hyper_span_info_t *down; /* Pointer to list of spans in next dimension down */
+ struct H5S_hyper_span_t *next; /* Pointer to next span in list */
};
-/* Information about a list of hyperslab spans in one dimension */
+/* Information about a list of hyperslab spans in one dimension (typedef'd in H5Sprivate.h) */
struct H5S_hyper_span_info_t {
- unsigned count; /* Ref. count of number of spans which share this span */
- struct H5S_hyper_span_info_t *scratch; /* Scratch pointer
- * (used during copies, as mark
- * during precomputes for I/O &
- * to point to the last span in a
- * list during single element adds)
- */
- struct H5S_hyper_span_t *head; /* Pointer to list of spans in next dimension down */
+ unsigned count; /* Ref. count of number of spans which share this span */
+
+ /* The following two fields define the bounding box of this set of spans
+ * and all lower dimensions, relative to the offset.
+ */
+ /* (NOTE: The bounds arrays are _relative_ to the depth of the span_info
+ * node in the span tree, so the top node in a 5-D span tree will
+ * use indices 0-4 in the arrays to store it's bounds information,
+ * but the next level down in the span tree will use indices 0-3.
+ * So, each level in the span tree will have the 0th index in the
+ * arrays correspond to the bounds in "this" dimension, even if
+ * it's not the highest level in the span tree.
+ */
+ hsize_t *low_bounds; /* The smallest element selected in each dimension */
+ hsize_t *high_bounds; /* The largest element selected in each dimension */
+
+ /* "Operation generation" fields */
+ /* (Used during copies, 'adjust', 'nelem', and 'rebuild' operations) */
+ uint64_t op_gen; /* Generation of the scratch info */
+ union {
+ struct H5S_hyper_span_info_t *copied; /* Pointer to already copied span tree */
+ hsize_t nelmts; /* # of elements */
+ hsize_t nblocks; /* # of blocks */
+#ifdef H5_HAVE_PARALLEL
+ MPI_Datatype down_type; /* MPI datatype for span tree */
+#endif /* H5_HAVE_PARALLEL */
+ }u;
+
+ struct H5S_hyper_span_t *head; /* Pointer to the first span of list of spans in the current dimension */
+ struct H5S_hyper_span_t *tail; /* Pointer to the last span of list of spans in the current dimension */
+ hsize_t bounds[]; /* Array for storing low & high bounds */
+ /* (NOTE: This uses the C99 "flexible array member" feature) */
};
-/* Information about new-style hyperslab selection */
+/* Enum for diminfo_valid field in H5S_hyper_sel_t */
+typedef enum {
+ H5S_DIMINFO_VALID_IMPOSSIBLE, /* 0: diminfo is not valid and can never be valid with the current selection */
+ H5S_DIMINFO_VALID_NO, /* 1: diminfo is not valid but may or may not be possible to constuct */
+ H5S_DIMINFO_VALID_YES /* 2: diminfo is valid */
+} H5S_diminfo_valid_t;
+
+/* Information about 'diminfo' form of hyperslab selection */
typedef struct {
- hbool_t diminfo_valid; /* Whether the dataset has valid diminfo */
- H5S_hyper_dim_t opt_diminfo[H5S_MAX_RANK]; /* per-dim selection info */
- H5S_hyper_dim_t app_diminfo[H5S_MAX_RANK]; /* per-dim selection info */
- /* 'opt_diminfo' points to a [potentially] optimized version of the user's
- * hyperslab information. 'app_diminfo' points to the actual parameters
- * that the application used for setting the hyperslab selection. These
- * are only used for re-gurgitating the original values used to set the
- * hyperslab to the application when it queries the hyperslab selection
- * information. */
+ /* 'opt' points to a [potentially] optimized version of the user's
+ * regular hyperslab information. 'app' points to the actual parameters
+ * that the application used for setting the hyperslab selection.
+ *
+ * The 'app' values are only used for regurgitating the original values
+ * used to set the hyperslab to the application when it queries the
+ * hyperslab selection information.
+ */
+ H5S_hyper_dim_t app[H5S_MAX_RANK]; /* Application-set per-dim selection info */
+ H5S_hyper_dim_t opt[H5S_MAX_RANK]; /* Optimized per-dim selection info */
+
+ /* The following two fields defines the bounding box of the diminfo selection */
+ /* (relative to the offset) */
+ hsize_t low_bounds[H5S_MAX_RANK]; /* The smallest element selected in each dimension */
+ hsize_t high_bounds[H5S_MAX_RANK]; /* The largest element selected in each dimension */
+} H5S_hyper_diminfo_t;
+
+/* Information about hyperslab selection */
+typedef struct {
+ H5S_diminfo_valid_t diminfo_valid; /* Whether the dataset has valid diminfo */
+
+ H5S_hyper_diminfo_t diminfo; /* Dimension info form of hyperslab selection */
int unlim_dim; /* Dimension where selection is unlimited, or -1 if none */
hsize_t num_elem_non_unlim; /* # of elements in a "slice" excluding the unlimited dimension */
H5S_hyper_span_info_t *span_lst; /* List of hyperslab span information of all dimensions */
@@ -130,10 +213,6 @@ typedef struct {
/* Selection information methods */
/* Method to copy a selection */
typedef herr_t (*H5S_sel_copy_func_t)(H5S_t *dst, const H5S_t *src, hbool_t share_selection);
-/* Method to retrieve a list of offset/length sequences for selection */
-typedef herr_t (*H5S_sel_get_seq_list_func_t)(const H5S_t *space, unsigned flags,
- H5S_sel_iter_t *iter, size_t maxseq, size_t maxbytes,
- size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len);
/* Method to release current selection */
typedef herr_t (*H5S_sel_release_func_t)(H5S_t *space);
/* Method to determine if current selection is valid for dataspace */
@@ -143,8 +222,7 @@ typedef hssize_t (*H5S_sel_serial_size_func_t)(const H5S_t *space);
/* Method to store current selection in "serialized" form (a byte sequence suitable for storing on disk) */
typedef herr_t (*H5S_sel_serialize_func_t)(const H5S_t *space, uint8_t **p);
/* Method to create selection from "serialized" form (a byte sequence suitable for storing on disk) */
-typedef herr_t (*H5S_sel_deserialize_func_t)(H5S_t *space, uint32_t version, uint8_t flags,
- const uint8_t **p);
+typedef herr_t (*H5S_sel_deserialize_func_t)(H5S_t **space, const uint8_t **p);
/* Method to determine smallest n-D bounding box containing the current selection */
typedef herr_t (*H5S_sel_bounds_func_t)(const H5S_t *space, hsize_t *start, hsize_t *end);
/* Method to determine linear offset of initial element in selection within dataspace */
@@ -160,6 +238,8 @@ typedef htri_t (*H5S_sel_is_contiguous_func_t)(const H5S_t *space);
typedef htri_t (*H5S_sel_is_single_func_t)(const H5S_t *space);
/* Method to determine if current selection is "regular" */
typedef htri_t (*H5S_sel_is_regular_func_t)(const H5S_t *space);
+/* Method to determine if two dataspaces' selections are the same shape */
+typedef htri_t (*H5S_sel_shape_same_func_t)(const H5S_t *space1, const H5S_t *space2);
/* Method to adjust a selection by an offset */
typedef herr_t (*H5S_sel_adjust_u_func_t)(H5S_t *space, const hsize_t *offset);
/* Method to construct single element projection onto scalar dataspace */
@@ -167,7 +247,7 @@ typedef herr_t (*H5S_sel_project_scalar)(const H5S_t *space, hsize_t *offset);
/* Method to construct selection projection onto/into simple dataspace */
typedef herr_t (*H5S_sel_project_simple)(const H5S_t *space, H5S_t *new_space, hsize_t *offset);
/* Method to initialize iterator for current selection */
-typedef herr_t (*H5S_sel_iter_init_func_t)(H5S_sel_iter_t *sel_iter, const H5S_t *space);
+typedef herr_t (*H5S_sel_iter_init_func_t)(const H5S_t *space, H5S_sel_iter_t *sel_iter);
/* Selection class information */
typedef struct {
@@ -175,7 +255,6 @@ typedef struct {
/* Methods */
H5S_sel_copy_func_t copy; /* Method to make a copy of a selection */
- H5S_sel_get_seq_list_func_t get_seq_list; /* Method to retrieve a list of offset/length sequences for selection */
H5S_sel_release_func_t release; /* Method to release current selection */
H5S_sel_is_valid_func_t is_valid; /* Method to determine if current selection is valid for dataspace */
H5S_sel_serial_size_func_t serial_size; /* Method to determine number of bytes required to store current selection */
@@ -188,6 +267,7 @@ typedef struct {
H5S_sel_is_contiguous_func_t is_contiguous; /* Method to determine if current selection is contiguous */
H5S_sel_is_single_func_t is_single; /* Method to determine if current selection is a single block */
H5S_sel_is_regular_func_t is_regular; /* Method to determine if current selection is "regular" */
+ H5S_sel_shape_same_func_t shape_same; /* Method to determine if two dataspaces' selections are the same shape */
H5S_sel_adjust_u_func_t adjust_u; /* Method to adjust a selection by an offset */
H5S_sel_project_scalar project_scalar; /* Method to construct scalar dataspace projection */
H5S_sel_project_simple project_simple; /* Method to construct simple dataspace projection */
@@ -217,9 +297,11 @@ struct H5S_t {
/* Selection iteration methods */
/* Method to retrieve the current coordinates of iterator for current selection */
-typedef herr_t (*H5S_sel_iter_coords_func_t)(const H5S_sel_iter_t *iter, hsize_t *coords);
+typedef herr_t (*H5S_sel_iter_coords_func_t)(const H5S_sel_iter_t *iter,
+ hsize_t *coords);
/* Method to retrieve the current block of iterator for current selection */
-typedef herr_t (*H5S_sel_iter_block_func_t)(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end);
+typedef herr_t (*H5S_sel_iter_block_func_t)(const H5S_sel_iter_t *iter,
+ hsize_t *start, hsize_t *end);
/* Method to determine number of elements left in iterator for current selection */
typedef hsize_t (*H5S_sel_iter_nelmts_func_t)(const H5S_sel_iter_t *iter);
/* Method to determine if there are more blocks left in the current selection */
@@ -228,6 +310,10 @@ typedef htri_t (*H5S_sel_iter_has_next_block_func_t)(const H5S_sel_iter_t *iter)
typedef herr_t (*H5S_sel_iter_next_func_t)(H5S_sel_iter_t *iter, size_t nelem);
/* Method to move selection iterator to the next block in the selection */
typedef herr_t (*H5S_sel_iter_next_block_func_t)(H5S_sel_iter_t *iter);
+/* Method to retrieve a list of offset/length sequences for selection iterator */
+typedef herr_t (*H5S_sel_iter_get_seq_list_func_t)(H5S_sel_iter_t *iter,
+ size_t maxseq, size_t maxbytes, size_t *nseq, size_t *nbytes, hsize_t *off,
+ size_t *len);
/* Method to release iterator for current selection */
typedef herr_t (*H5S_sel_iter_release_func_t)(H5S_sel_iter_t *iter);
@@ -242,6 +328,7 @@ typedef struct H5S_sel_iter_class_t {
H5S_sel_iter_has_next_block_func_t iter_has_next_block; /* Method to query if there is another block left in the selection */
H5S_sel_iter_next_func_t iter_next; /* Method to move selection iterator to the next element in the selection */
H5S_sel_iter_next_block_func_t iter_next_block; /* Method to move selection iterator to the next block in the selection */
+ H5S_sel_iter_get_seq_list_func_t iter_get_seq_list; /* Method to retrieve a list of offset/length sequences for selection iterator */
H5S_sel_iter_release_func_t iter_release; /* Method to release iterator for current selection */
} H5S_sel_iter_class_t;
@@ -269,19 +356,25 @@ H5_DLLVAR const H5S_select_class_t H5S_sel_point[1];
H5_DLLVAR const unsigned H5O_sdspace_ver_bounds[H5F_LIBVER_NBOUNDS];
/* Extent functions */
-H5_DLL herr_t H5S_extent_release(H5S_extent_t *extent);
-H5_DLL herr_t H5S_extent_copy_real(H5S_extent_t *dst, const H5S_extent_t *src,
+H5_DLL herr_t H5S__extent_release(H5S_extent_t *extent);
+H5_DLL herr_t H5S__extent_copy_real(H5S_extent_t *dst, const H5S_extent_t *src,
hbool_t copy_max);
-/* Operations on selections */
+/* Operations on hyperslab selections */
+H5_DLL uint64_t H5S__hyper_get_op_gen(void);
+H5_DLL void H5S__hyper_rebuild(H5S_t *space);
+H5_DLL herr_t H5S__modify_select(H5S_t *space1, H5S_seloper_t op, H5S_t *space2);
H5_DLL herr_t H5S__hyper_project_intersection(const H5S_t *src_space,
const H5S_t *dst_space, const H5S_t *src_intersect_space, H5S_t *proj_space);
-H5_DLL herr_t H5S__hyper_subtract(H5S_t *space, H5S_t *subtract_space);
/* Testing functions */
#ifdef H5S_TESTING
-H5_DLL htri_t H5S_select_shape_same_test(hid_t sid1, hid_t sid2);
-H5_DLL htri_t H5S_get_rebuild_status_test(hid_t space_id);
+H5_DLL htri_t H5S__select_shape_same_test(hid_t sid1, hid_t sid2);
+H5_DLL herr_t H5S__get_rebuild_status_test(hid_t space_id,
+ H5S_diminfo_valid_t *status1, H5S_diminfo_valid_t *status2);
+H5_DLL herr_t H5S__get_diminfo_status_test(hid_t space_id,
+ H5S_diminfo_valid_t *status);
+H5_DLL htri_t H5S__internal_consistency_test(hid_t space_id);
#endif /* H5S_TESTING */
#endif /*_H5Spkg_H*/
diff --git a/src/H5Spoint.c b/src/H5Spoint.c
index aea7d5c..875c018 100644
--- a/src/H5Spoint.c
+++ b/src/H5Spoint.c
@@ -18,182 +18,252 @@
* Purpose: Point selection dataspace I/O functions.
*/
+/****************/
+/* Module Setup */
+/****************/
+
#include "H5Smodule.h" /* This source code file is part of the H5S module */
-#include "H5private.h" /* Generic Functions */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5FLprivate.h" /* Free Lists */
-#include "H5Iprivate.h" /* ID Functions */
-#include "H5MMprivate.h" /* Memory Management functions */
-#include "H5Spkg.h" /* Dataspace functions */
-#include "H5VMprivate.h" /* Vector functions */
+/***********/
+/* Headers */
+/***********/
+#include "H5private.h" /* Generic Functions */
+#include "H5CXprivate.h" /* API Contexts */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5FLprivate.h" /* Free Lists */
+#include "H5Iprivate.h" /* ID Functions */
+#include "H5MMprivate.h" /* Memory management */
+#include "H5Spkg.h" /* Dataspace functions */
+#include "H5VMprivate.h" /* Vector functions */
+
+
+/****************/
+/* Local Macros */
+/****************/
+
-/* Static function prototypes */
+/******************/
+/* Local Typedefs */
+/******************/
+
+/* Define alias for hsize_t, for allocating H5S_pnt_node_t + point objects */
+/* (Makes it easier to understand the alloc / free calls) */
+typedef hsize_t hcoords_t;
+
+
+/********************/
+/* Local Prototypes */
+/********************/
+static herr_t H5S__point_add(H5S_t *space, H5S_seloper_t op, size_t num_elem,
+ const hsize_t *coord);
+static H5S_pnt_list_t *H5S__copy_pnt_list(const H5S_pnt_list_t *src,
+ unsigned rank);
+static void H5S__free_pnt_list(H5S_pnt_list_t *pnt_lst);
/* Selection callbacks */
-static herr_t H5S_point_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection);
-static herr_t H5S_point_get_seq_list(const H5S_t *space, unsigned flags,
- H5S_sel_iter_t *iter, size_t maxseq, size_t maxbytes,
- size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len);
-static herr_t H5S_point_release(H5S_t *space);
-static htri_t H5S_point_is_valid(const H5S_t *space);
-static hssize_t H5S_point_serial_size(const H5S_t *space);
-static herr_t H5S_point_serialize(const H5S_t *space, uint8_t **p);
-static herr_t H5S_point_deserialize(H5S_t *space, uint32_t version, uint8_t flags,
- const uint8_t **p);
-static herr_t H5S_point_bounds(const H5S_t *space, hsize_t *start, hsize_t *end);
-static herr_t H5S_point_offset(const H5S_t *space, hsize_t *off);
+static herr_t H5S__point_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection);
+static herr_t H5S__point_release(H5S_t *space);
+static htri_t H5S__point_is_valid(const H5S_t *space);
+static hssize_t H5S__point_serial_size(const H5S_t *space);
+static herr_t H5S__point_serialize(const H5S_t *space, uint8_t **p);
+static herr_t H5S__point_deserialize(H5S_t **space, const uint8_t **p);
+static herr_t H5S__point_bounds(const H5S_t *space, hsize_t *start, hsize_t *end);
+static herr_t H5S__point_offset(const H5S_t *space, hsize_t *off);
static int H5S__point_unlim_dim(const H5S_t *space);
-static htri_t H5S_point_is_contiguous(const H5S_t *space);
-static htri_t H5S_point_is_single(const H5S_t *space);
-static htri_t H5S_point_is_regular(const H5S_t *space);
-static herr_t H5S_point_adjust_u(H5S_t *space, const hsize_t *offset);
-static herr_t H5S_point_project_scalar(const H5S_t *space, hsize_t *offset);
-static herr_t H5S_point_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset);
-static herr_t H5S_point_iter_init(H5S_sel_iter_t *iter, const H5S_t *space);
+static htri_t H5S__point_is_contiguous(const H5S_t *space);
+static htri_t H5S__point_is_single(const H5S_t *space);
+static htri_t H5S__point_is_regular(const H5S_t *space);
+static htri_t H5S__point_shape_same(const H5S_t *space1, const H5S_t *space2);
+static herr_t H5S__point_adjust_u(H5S_t *space, const hsize_t *offset);
+static herr_t H5S__point_project_scalar(const H5S_t *space, hsize_t *offset);
+static herr_t H5S__point_project_simple(const H5S_t *space, H5S_t *new_space,
+ hsize_t *offset);
+static herr_t H5S__point_iter_init(const H5S_t *space, H5S_sel_iter_t *iter);
+static herr_t H5S__point_get_version_enc_size(const H5S_t *space,
+ uint32_t *version, uint8_t *enc_size);
/* Selection iteration callbacks */
-static herr_t H5S_point_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords);
-static herr_t H5S_point_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end);
-static hsize_t H5S_point_iter_nelmts(const H5S_sel_iter_t *iter);
-static htri_t H5S_point_iter_has_next_block(const H5S_sel_iter_t *iter);
-static herr_t H5S_point_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem);
-static herr_t H5S_point_iter_next_block(H5S_sel_iter_t *sel_iter);
-static herr_t H5S_point_iter_release(H5S_sel_iter_t *sel_iter);
+static herr_t H5S__point_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords);
+static herr_t H5S__point_iter_block(const H5S_sel_iter_t *iter, hsize_t *start,
+ hsize_t *end);
+static hsize_t H5S__point_iter_nelmts(const H5S_sel_iter_t *iter);
+static htri_t H5S__point_iter_has_next_block(const H5S_sel_iter_t *iter);
+static herr_t H5S__point_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem);
+static herr_t H5S__point_iter_next_block(H5S_sel_iter_t *sel_iter);
+static herr_t H5S__point_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq,
+ size_t maxbytes, size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len);
+static herr_t H5S__point_iter_release(H5S_sel_iter_t *sel_iter);
+
+
+/*****************************/
+/* Library Private Variables */
+/*****************************/
+
+
+/*********************/
+/* Package Variables */
+/*********************/
/* Selection properties for point selections */
const H5S_select_class_t H5S_sel_point[1] = {{
H5S_SEL_POINTS,
/* Methods on selection */
- H5S_point_copy,
- H5S_point_get_seq_list,
- H5S_point_release,
- H5S_point_is_valid,
- H5S_point_serial_size,
- H5S_point_serialize,
- H5S_point_deserialize,
- H5S_point_bounds,
- H5S_point_offset,
+ H5S__point_copy,
+ H5S__point_release,
+ H5S__point_is_valid,
+ H5S__point_serial_size,
+ H5S__point_serialize,
+ H5S__point_deserialize,
+ H5S__point_bounds,
+ H5S__point_offset,
H5S__point_unlim_dim,
NULL,
- H5S_point_is_contiguous,
- H5S_point_is_single,
- H5S_point_is_regular,
- H5S_point_adjust_u,
- H5S_point_project_scalar,
- H5S_point_project_simple,
- H5S_point_iter_init,
+ H5S__point_is_contiguous,
+ H5S__point_is_single,
+ H5S__point_is_regular,
+ H5S__point_shape_same,
+ H5S__point_adjust_u,
+ H5S__point_project_scalar,
+ H5S__point_project_simple,
+ H5S__point_iter_init,
}};
+/* Format version bounds for dataspace hyperslab selection */
+const unsigned H5O_sds_point_ver_bounds[] = {
+ H5S_POINT_VERSION_1, /* H5F_LIBVER_EARLIEST */
+ H5S_POINT_VERSION_1, /* H5F_LIBVER_V18 */
+ H5S_POINT_VERSION_1, /* H5F_LIBVER_V110 */
+ H5S_POINT_VERSION_2 /* H5F_LIBVER_LATEST */
+};
+
+/*******************/
+/* Local Variables */
+/*******************/
+
/* Iteration properties for point selections */
static const H5S_sel_iter_class_t H5S_sel_iter_point[1] = {{
H5S_SEL_POINTS,
/* Methods on selection iterator */
- H5S_point_iter_coords,
- H5S_point_iter_block,
- H5S_point_iter_nelmts,
- H5S_point_iter_has_next_block,
- H5S_point_iter_next,
- H5S_point_iter_next_block,
- H5S_point_iter_release,
+ H5S__point_iter_coords,
+ H5S__point_iter_block,
+ H5S__point_iter_nelmts,
+ H5S__point_iter_has_next_block,
+ H5S__point_iter_next,
+ H5S__point_iter_next_block,
+ H5S__point_iter_get_seq_list,
+ H5S__point_iter_release,
}};
-/* Declare a free list to manage the H5S_pnt_node_t struct */
-H5FL_DEFINE_STATIC(H5S_pnt_node_t);
+/* Declare a free list to manage the H5S_pnt_node_t + hcoords_t array struct */
+H5FL_BARR_DEFINE_STATIC(H5S_pnt_node_t, hcoords_t, H5S_MAX_RANK);
/* Declare a free list to manage the H5S_pnt_list_t struct */
H5FL_DEFINE_STATIC(H5S_pnt_list_t);
+
/*-------------------------------------------------------------------------
- * Function: H5S_point_iter_init
+ * Function: H5S__point_iter_init
*
* Purpose: Initializes iteration information for point selection.
*
- * Return: non-negative on success, negative on failure.
+ * Return: Non-negative on success, negative on failure.
*
* Programmer: Quincey Koziol
* Tuesday, June 16, 1998
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static herr_t
-H5S_point_iter_init(H5S_sel_iter_t *iter, const H5S_t *space)
+H5S__point_iter_init(const H5S_t *space, H5S_sel_iter_t *iter)
{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_STATIC
/* Check args */
- HDassert(space && H5S_SEL_POINTS==H5S_GET_SELECT_TYPE(space));
+ HDassert(space && H5S_SEL_POINTS == H5S_GET_SELECT_TYPE(space));
HDassert(iter);
- /* Initialize the number of points to iterate over */
- iter->elmt_left=space->select.num_elem;
+ /* If this iterator is created from an API call, by default we clone the
+ * selection now, as the dataspace could be modified or go out of scope.
+ *
+ * However, if the H5S_SEL_ITER_SHARE_WITH_DATASPACE flag is given,
+ * the selection is shared between the selection iterator and the
+ * dataspace. In this case, the application _must_not_ modify or
+ * close the dataspace that the iterator is operating on, or undefined
+ * behavior will occur.
+ */
+ if((iter->flags & H5S_SEL_ITER_API_CALL) &&
+ !(iter->flags & H5S_SEL_ITER_SHARE_WITH_DATASPACE)) {
+ /* Copy the point list */
+ if(NULL == (iter->u.pnt.pnt_lst = H5S__copy_pnt_list(space->select.sel_info.pnt_lst, space->extent.rank)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy point list")
+ } /* end if */
+ else
+ /* OK to share point list for internal iterations */
+ iter->u.pnt.pnt_lst = space->select.sel_info.pnt_lst;
/* Start at the head of the list of points */
- iter->u.pnt.curr=space->select.sel_info.pnt_lst->head;
+ iter->u.pnt.curr = iter->u.pnt.pnt_lst->head;
/* Initialize type of selection iterator */
- iter->type=H5S_sel_iter_point;
+ iter->type = H5S_sel_iter_point;
- FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5S_point_iter_init() */
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5S__point_iter_init() */
/*-------------------------------------------------------------------------
- * Function: H5S_point_iter_coords
+ * Function: H5S__point_iter_coords
*
* Purpose: Retrieve the current coordinates of iterator for current
* selection
*
- * Return: non-negative on success, negative on failure
+ * Return: Non-negative on success, negative on failure
*
* Programmer: Quincey Koziol
* Tuesday, April 22, 2003
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static herr_t
-H5S_point_iter_coords (const H5S_sel_iter_t *iter, hsize_t *coords)
+H5S__point_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords)
{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
/* Check args */
HDassert(iter);
HDassert(coords);
/* Copy the offset of the current point */
- HDmemcpy(coords,iter->u.pnt.curr->pnt,sizeof(hsize_t)*iter->rank);
+ H5MM_memcpy(coords, iter->u.pnt.curr->pnt, sizeof(hsize_t) * iter->rank);
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5S_point_iter_coords() */
+} /* end H5S__point_iter_coords() */
/*-------------------------------------------------------------------------
- * Function: H5S_point_iter_block
+ * Function: H5S__point_iter_block
*
* Purpose: Retrieve the current block of iterator for current
* selection
*
- * Return: non-negative on success, negative on failure
+ * Return: Non-negative on success, negative on failure
*
* Programmer: Quincey Koziol
* Monday, June 2, 2003
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static herr_t
-H5S_point_iter_block (const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end)
+H5S__point_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end)
{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
/* Check args */
HDassert(iter);
@@ -201,46 +271,44 @@ H5S_point_iter_block (const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end)
HDassert(end);
/* Copy the current point as a block */
- HDmemcpy(start,iter->u.pnt.curr->pnt,sizeof(hsize_t)*iter->rank);
- HDmemcpy(end,iter->u.pnt.curr->pnt,sizeof(hsize_t)*iter->rank);
+ H5MM_memcpy(start, iter->u.pnt.curr->pnt, sizeof(hsize_t) * iter->rank);
+ H5MM_memcpy(end, iter->u.pnt.curr->pnt, sizeof(hsize_t) * iter->rank);
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5S_point_iter_block() */
+} /* end H5S__point_iter_block() */
/*-------------------------------------------------------------------------
- * Function: H5S_point_iter_nelmts
+ * Function: H5S__point_iter_nelmts
*
* Purpose: Return number of elements left to process in iterator
*
- * Return: non-negative number of elements on success, zero on failure
+ * Return: Non-negative number of elements on success, zero on failure
*
* Programmer: Quincey Koziol
* Tuesday, June 16, 1998
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static hsize_t
-H5S_point_iter_nelmts (const H5S_sel_iter_t *iter)
+H5S__point_iter_nelmts(const H5S_sel_iter_t *iter)
{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
/* Check args */
HDassert(iter);
FUNC_LEAVE_NOAPI(iter->elmt_left)
-} /* H5S_point_iter_nelmts() */
+} /* end H5S__point_iter_nelmts() */
/*--------------------------------------------------------------------------
NAME
- H5S_point_iter_has_next_block
+ H5S__point_iter_has_next_block
PURPOSE
Check if there is another block left in the current iterator
USAGE
- htri_t H5S_point_iter_has_next_block(iter)
+ htri_t H5S__point_iter_has_next_block(iter)
const H5S_sel_iter_t *iter; IN: Pointer to selection iterator
RETURNS
Non-negative (TRUE/FALSE) on success/Negative on failure
@@ -252,31 +320,31 @@ H5S_point_iter_nelmts (const H5S_sel_iter_t *iter)
REVISION LOG
--------------------------------------------------------------------------*/
static htri_t
-H5S_point_iter_has_next_block(const H5S_sel_iter_t *iter)
+H5S__point_iter_has_next_block(const H5S_sel_iter_t *iter)
{
- htri_t ret_value=TRUE; /* Return value */
+ htri_t ret_value = TRUE; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
/* Check args */
HDassert(iter);
/* Check if there is another point in the list */
- if(iter->u.pnt.curr->next==NULL)
+ if(iter->u.pnt.curr->next == NULL)
HGOTO_DONE(FALSE);
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_point_iter_has_next_block() */
+} /* end H5S__point_iter_has_next_block() */
/*--------------------------------------------------------------------------
NAME
- H5S_point_iter_next
+ H5S__point_iter_next
PURPOSE
Increment selection iterator
USAGE
- herr_t H5S_point_iter_next(iter, nelem)
+ herr_t H5S__point_iter_next(iter, nelem)
H5S_sel_iter_t *iter; IN: Pointer to selection iterator
size_t nelem; IN: Number of elements to advance by
RETURNS
@@ -289,31 +357,31 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
-H5S_point_iter_next(H5S_sel_iter_t *iter, size_t nelem)
+H5S__point_iter_next(H5S_sel_iter_t *iter, size_t nelem)
{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
/* Check args */
HDassert(iter);
- HDassert(nelem>0);
+ HDassert(nelem > 0);
/* Increment the iterator */
- while(nelem>0) {
- iter->u.pnt.curr=iter->u.pnt.curr->next;
+ while(nelem > 0) {
+ iter->u.pnt.curr = iter->u.pnt.curr->next;
nelem--;
} /* end while */
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5S_point_iter_next() */
+} /* end H5S__point_iter_next() */
/*--------------------------------------------------------------------------
NAME
- H5S_point_iter_next_block
+ H5S__point_iter_next_block
PURPOSE
Increment selection iterator to next block
USAGE
- herr_t H5S_point_iter_next_block(iter)
+ herr_t H5S__point_iter_next_block(iter)
H5S_sel_iter_t *iter; IN: Pointer to selection iterator
RETURNS
Non-negative on success/Negative on failure
@@ -325,27 +393,158 @@ H5S_point_iter_next(H5S_sel_iter_t *iter, size_t nelem)
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
-H5S_point_iter_next_block(H5S_sel_iter_t *iter)
+H5S__point_iter_next_block(H5S_sel_iter_t *iter)
{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
/* Check args */
HDassert(iter);
/* Increment the iterator */
- iter->u.pnt.curr=iter->u.pnt.curr->next;
+ iter->u.pnt.curr = iter->u.pnt.curr->next;
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5S_point_iter_next_block() */
+} /* end H5S__point_iter_next_block() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S__point_iter_get_seq_list
+ PURPOSE
+ Create a list of offsets & lengths for a selection
+ USAGE
+ herr_t H5S__point_iter_get_seq_list(iter,maxseq,maxelem,nseq,nelem,off,len)
+ H5S_sel_iter_t *iter; IN/OUT: Selection iterator describing last
+ position of interest in selection.
+ size_t maxseq; IN: Maximum number of sequences to generate
+ size_t maxelem; IN: Maximum number of elements to include in the
+ generated sequences
+ size_t *nseq; OUT: Actual number of sequences generated
+ size_t *nelem; OUT: Actual number of elements in sequences generated
+ hsize_t *off; OUT: Array of offsets (in bytes)
+ size_t *len; OUT: Array of lengths (in bytes)
+ RETURNS
+ Non-negative on success/Negative on failure.
+ DESCRIPTION
+ Use the selection in the dataspace to generate a list of byte offsets and
+ lengths for the region(s) selected. Start/Restart from the position in the
+ ITER parameter. The number of sequences generated is limited by the MAXSEQ
+ parameter and the number of sequences actually generated is stored in the
+ NSEQ parameter.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+static herr_t
+H5S__point_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelem,
+ size_t *nseq, size_t *nelem, hsize_t *off, size_t *len)
+{
+ size_t io_left; /* The number of bytes left in the selection */
+ size_t start_io_left; /* The initial number of bytes left in the selection */
+ H5S_pnt_node_t *node; /* Point node */
+ unsigned ndims; /* Dimensionality of dataspace*/
+ hsize_t acc; /* Coordinate accumulator */
+ hsize_t loc; /* Coordinate offset */
+ size_t curr_seq; /* Current sequence being operated on */
+ int i; /* Local index variable */
+ herr_t ret_value = SUCCEED; /* return value */
+
+ FUNC_ENTER_STATIC_NOERR
+
+ /* Check args */
+ HDassert(iter);
+ HDassert(maxseq > 0);
+ HDassert(maxelem > 0);
+ HDassert(nseq);
+ HDassert(nelem);
+ HDassert(off);
+ HDassert(len);
+
+ /* Choose the minimum number of bytes to sequence through */
+ H5_CHECK_OVERFLOW(iter->elmt_left, hsize_t, size_t);
+ start_io_left = io_left = (size_t)MIN(iter->elmt_left, maxelem);
+
+ /* Get the dataspace's rank */
+ ndims = iter->rank;
+
+ /* Walk through the points in the selection, starting at the current */
+ /* location in the iterator */
+ node = iter->u.pnt.curr;
+ curr_seq = 0;
+ while(NULL != node) {
+ /* Compute the offset of each selected point in the buffer */
+ for(i = (int)(ndims - 1), acc = iter->elmt_size, loc = 0; i >= 0; i--) {
+ loc += (hsize_t)((hssize_t)node->pnt[i] + iter->sel_off[i]) * acc;
+ acc *= iter->dims[i];
+ } /* end for */
+
+ /* Check if this is a later point in the selection */
+ if(curr_seq > 0) {
+ /* If a sorted sequence is requested, make certain we don't go backwards in the offset */
+ if((iter->flags & H5S_SEL_ITER_GET_SEQ_LIST_SORTED) && loc < off[curr_seq - 1])
+ break;
+
+ /* Check if this point extends the previous sequence */
+ /* (Unlikely, but possible) */
+ if(loc == (off[curr_seq - 1] + len[curr_seq - 1])) {
+ /* Extend the previous sequence */
+ len[curr_seq - 1] += iter->elmt_size;
+ } /* end if */
+ else {
+ /* Add a new sequence */
+ off[curr_seq] = loc;
+ len[curr_seq] = iter->elmt_size;
+
+ /* Increment sequence count */
+ curr_seq++;
+ } /* end else */
+ } /* end if */
+ else {
+ /* Add a new sequence */
+ off[curr_seq] = loc;
+ len[curr_seq] = iter->elmt_size;
+
+ /* Increment sequence count */
+ curr_seq++;
+ } /* end else */
+
+ /* Decrement number of elements left to process */
+ io_left--;
+
+ /* Move the iterator */
+ iter->u.pnt.curr = node->next;
+ iter->elmt_left--;
+
+ /* Check if we're finished with all sequences */
+ if(curr_seq == maxseq)
+ break;
+
+ /* Check if we're finished with all the elements available */
+ if(io_left == 0)
+ break;
+
+ /* Advance to the next point */
+ node = node->next;
+ } /* end while */
+
+ /* Set the number of sequences generated */
+ *nseq = curr_seq;
+
+ /* Set the number of elements used */
+ *nelem = start_io_left - io_left;
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5S__point_iter_get_seq_list() */
/*--------------------------------------------------------------------------
NAME
- H5S_point_iter_release
+ H5S__point_iter_release
PURPOSE
Release point selection iterator information for a dataspace
USAGE
- herr_t H5S_point_iter_release(iter)
+ herr_t H5S__point_iter_release(iter)
H5S_sel_iter_t *iter; IN: Pointer to selection iterator
RETURNS
Non-negative on success/Negative on failure
@@ -357,24 +556,29 @@ H5S_point_iter_next_block(H5S_sel_iter_t *iter)
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
-H5S_point_iter_release (H5S_sel_iter_t H5_ATTR_UNUSED * iter)
+H5S__point_iter_release(H5S_sel_iter_t * iter)
{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
/* Check args */
HDassert(iter);
+ /* If this iterator copied the point list, we must free it */
+ if((iter->flags & H5S_SEL_ITER_API_CALL) &&
+ !(iter->flags & H5S_SEL_ITER_SHARE_WITH_DATASPACE))
+ H5S__free_pnt_list(iter->u.pnt.pnt_lst);
+
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5S_point_iter_release() */
+} /* end H5S__point_iter_release() */
/*--------------------------------------------------------------------------
NAME
- H5S_point_add
+ H5S__point_add
PURPOSE
Add a series of elements to a point selection
USAGE
- herr_t H5S_point_add(space, num_elem, coord)
+ herr_t H5S__point_add(space, num_elem, coord)
H5S_t *space; IN: Dataspace of selection to modify
size_t num_elem; IN: Number of elements in COORD array.
const hsize_t *coord[]; IN: The location of each element selected
@@ -388,31 +592,32 @@ H5S_point_iter_release (H5S_sel_iter_t H5_ATTR_UNUSED * iter)
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
-H5S_point_add(H5S_t *space, H5S_seloper_t op, size_t num_elem, const hsize_t *coord)
+H5S__point_add(H5S_t *space, H5S_seloper_t op, size_t num_elem, const hsize_t *coord)
{
H5S_pnt_node_t *top = NULL, *curr = NULL, *new_node = NULL; /* Point selection nodes */
unsigned u; /* Counter */
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_STATIC
+ /* Sanity checks */
HDassert(space);
HDassert(num_elem > 0);
HDassert(coord);
HDassert(op == H5S_SELECT_SET || op == H5S_SELECT_APPEND || op == H5S_SELECT_PREPEND);
for(u = 0; u < num_elem; u++) {
+ unsigned dim; /* Counter for dimensions */
+
/* Allocate space for the new node */
- if(NULL == (new_node = H5FL_MALLOC(H5S_pnt_node_t)))
+ if(NULL == (new_node = (H5S_pnt_node_t *)H5FL_ARR_MALLOC(hcoords_t, space->extent.rank)))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate point node")
/* Initialize fields in node */
new_node->next = NULL;
- if(NULL == (new_node->pnt = (hsize_t *)H5MM_malloc(space->extent.rank * sizeof(hsize_t))))
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate coordinate information")
/* Copy over the coordinates */
- HDmemcpy(new_node->pnt, coord + (u * space->extent.rank), (space->extent.rank * sizeof(hsize_t)));
+ H5MM_memcpy(new_node->pnt, coord + (u * space->extent.rank), (space->extent.rank * sizeof(hsize_t)));
/* Link into list */
if(top == NULL)
@@ -420,6 +625,17 @@ H5S_point_add(H5S_t *space, H5S_seloper_t op, size_t num_elem, const hsize_t *co
else
curr->next = new_node;
curr = new_node;
+
+ /* Update bound box */
+ /* (Note: when op is H5S_SELECT_SET, the bound box has been reset
+ * inside H5S_select_elements, the only caller of this function.
+ * So the following bound box update procedure works correctly
+ * for the SET operation)
+ */
+ for(dim = 0; dim < space->extent.rank; dim++) {
+ space->select.sel_info.pnt_lst->low_bounds[dim] = MIN(space->select.sel_info.pnt_lst->low_bounds[dim], curr->pnt[dim]);
+ space->select.sel_info.pnt_lst->high_bounds[dim] = MAX(space->select.sel_info.pnt_lst->high_bounds[dim], curr->pnt[dim]);
+ } /* end for */
} /* end for */
new_node = NULL;
@@ -431,20 +647,22 @@ H5S_point_add(H5S_t *space, H5S_seloper_t op, size_t num_elem, const hsize_t *co
/* Put new list in point selection */
space->select.sel_info.pnt_lst->head = top;
+
+ /* Change the tail pointer if tail has not been set */
+ if(NULL == space->select.sel_info.pnt_lst->tail)
+ space->select.sel_info.pnt_lst->tail = curr;
} /* end if */
else { /* op==H5S_SELECT_APPEND */
H5S_pnt_node_t *tmp_node; /* Temporary point selection node */
tmp_node = space->select.sel_info.pnt_lst->head;
if(tmp_node != NULL) {
- while(tmp_node->next != NULL)
- tmp_node = tmp_node->next;
-
- /* Append new list to point selection */
- tmp_node->next = top;
+ HDassert(space->select.sel_info.pnt_lst->tail);
+ space->select.sel_info.pnt_lst->tail->next = top;
} /* end if */
else
space->select.sel_info.pnt_lst->head = top;
+ space->select.sel_info.pnt_lst->tail = curr;
} /* end else */
/* Set the number of elements in the new selection */
@@ -457,28 +675,27 @@ done:
if(ret_value < 0) {
/* Release possibly partially initialized new node */
if(new_node)
- new_node = H5FL_FREE(H5S_pnt_node_t, new_node);
+ new_node = (H5S_pnt_node_t *)H5FL_ARR_FREE(hcoords_t, new_node);
/* Release possible linked list of nodes */
while(top) {
- curr = top->next;
- H5MM_xfree(top->pnt);
- top = H5FL_FREE(H5S_pnt_node_t, top);
+ curr = top->next;
+ top = (H5S_pnt_node_t *)H5FL_ARR_FREE(hcoords_t, top);
top = curr;
} /* end while */
} /* end if */
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_point_add() */
+} /* end H5S__point_add() */
/*--------------------------------------------------------------------------
NAME
- H5S_point_release
+ H5S__point_release
PURPOSE
Release point selection information for a dataspace
USAGE
- herr_t H5S_point_release(space)
+ herr_t H5S__point_release(space)
H5S_t *space; IN: Pointer to dataspace
RETURNS
Non-negative on success/Negative on failure
@@ -490,32 +707,24 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
-H5S_point_release (H5S_t *space)
+H5S__point_release(H5S_t *space)
{
- H5S_pnt_node_t *curr, *next; /* Point selection nodes */
-
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
/* Check args */
HDassert(space);
- /* Delete all the nodes from the list */
- curr = space->select.sel_info.pnt_lst->head;
- while(curr != NULL) {
- next = curr->next;
- H5MM_xfree(curr->pnt);
- curr = H5FL_FREE(H5S_pnt_node_t, curr);
- curr = next;
- } /* end while */
+ /* Free the point list */
+ H5S__free_pnt_list(space->select.sel_info.pnt_lst);
- /* Free & reset the point list header */
- space->select.sel_info.pnt_lst = H5FL_FREE(H5S_pnt_list_t, space->select.sel_info.pnt_lst);
+ /* Reset the point list header */
+ space->select.sel_info.pnt_lst = NULL;
/* Reset the number of elements in the selection */
space->select.num_elem = 0;
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5S_point_release() */
+} /* end H5S__point_release() */
/*--------------------------------------------------------------------------
@@ -539,10 +748,7 @@ H5S_point_release (H5S_t *space)
array elements are iterated through when I/O is performed. Duplicate
coordinates are not checked for. The selection operator, OP, determines
how the new selection is to be combined with the existing selection for
- the dataspace. Currently, only H5S_SELECT_SET is supported, which replaces
- the existing selection with the one defined in this call. When operators
- other than H5S_SELECT_SET are used to combine a new selection with an
- existing selection, the selection ordering is reset to 'C' array ordering.
+ the dataspace.
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
EXAMPLES
@@ -552,9 +758,9 @@ herr_t
H5S_select_elements(H5S_t *space, H5S_seloper_t op, size_t num_elem,
const hsize_t *coord)
{
- herr_t ret_value = SUCCEED; /* return value */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_NOAPI(FAIL)
/* Check args */
HDassert(space);
@@ -568,12 +774,19 @@ H5S_select_elements(H5S_t *space, H5S_seloper_t op, size_t num_elem,
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release point selection")
/* Allocate space for the point selection information if necessary */
- if(H5S_GET_SELECT_TYPE(space) != H5S_SEL_POINTS || space->select.sel_info.pnt_lst == NULL)
+ if(H5S_GET_SELECT_TYPE(space) != H5S_SEL_POINTS || space->select.sel_info.pnt_lst == NULL) {
+ hsize_t tmp = HSIZET_MAX;
+
if(NULL == (space->select.sel_info.pnt_lst = H5FL_CALLOC(H5S_pnt_list_t)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate element information")
+ /* Set the bound box to the default value */
+ H5VM_array_fill(space->select.sel_info.pnt_lst->low_bounds, &tmp, sizeof(hsize_t), space->extent.rank);
+ HDmemset(space->select.sel_info.pnt_lst->high_bounds, 0, sizeof(hsize_t) * space->extent.rank);
+ } /* end if */
+
/* Add points to selection */
- if(H5S_point_add(space, op, num_elem, coord) < 0)
+ if(H5S__point_add(space, op, num_elem, coord) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert elements")
/* Set selection type */
@@ -581,61 +794,61 @@ H5S_select_elements(H5S_t *space, H5S_seloper_t op, size_t num_elem,
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_select_elements() */
+} /* end H5S_select_elements() */
/*--------------------------------------------------------------------------
NAME
- H5S_point_copy
+ H5S__copy_pnt_list
PURPOSE
- Copy a selection from one dataspace to another
+ Copy a point selection list
USAGE
- herr_t H5S_point_copy(dst, src)
- H5S_t *dst; OUT: Pointer to the destination dataspace
- H5S_t *src; IN: Pointer to the source dataspace
+ H5S_pnt_list_t *H5S__copy_pnt_list(src)
+ const H5S_pnt_list_t *src; IN: Pointer to the source point list
+ unsigned rank; IN: # of dimensions for points
RETURNS
- Non-negative on success/Negative on failure
+ Non-NULL pointer to new point list on success / NULL on failure
DESCRIPTION
- Copies all the point selection information from the source
- dataspace to the destination dataspace.
+ Copies point selection information from the source point list to newly
+ created point list.
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-static herr_t
-H5S_point_copy(H5S_t *dst, const H5S_t *src, hbool_t H5_ATTR_UNUSED share_selection)
+static H5S_pnt_list_t *
+H5S__copy_pnt_list(const H5S_pnt_list_t *src, unsigned rank)
{
- H5S_pnt_node_t *curr, *new_node, *new_tail; /* Point information nodes */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5S_pnt_list_t *dst = NULL; /* New point list */
+ H5S_pnt_node_t *curr, *new_tail; /* Point information nodes */
+ H5S_pnt_list_t *ret_value = NULL; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_STATIC
+ /* Sanity checks */
HDassert(src);
- HDassert(dst);
+ HDassert(rank > 0);
/* Allocate room for the head of the point list */
- if(NULL == (dst->select.sel_info.pnt_lst = H5FL_MALLOC(H5S_pnt_list_t)))
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate point list node")
+ if(NULL == (dst = H5FL_MALLOC(H5S_pnt_list_t)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate point list node")
- curr = src->select.sel_info.pnt_lst->head;
+ curr = src->head;
new_tail = NULL;
while(curr) {
+ H5S_pnt_node_t *new_node; /* New point information node */
+
/* Create new point */
- if(NULL == (new_node = H5FL_MALLOC(H5S_pnt_node_t)))
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate point node")
+ if(NULL == (new_node = (H5S_pnt_node_t *)H5FL_ARR_MALLOC(hcoords_t, rank)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate point node")
new_node->next = NULL;
- if(NULL == (new_node->pnt = (hsize_t *)H5MM_malloc(src->extent.rank * sizeof(hsize_t)))) {
- new_node = H5FL_FREE(H5S_pnt_node_t, new_node);
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate coordinate information")
- } /* end if */
/* Copy over the point's coordinates */
- HDmemcpy(new_node->pnt, curr->pnt, (src->extent.rank * sizeof(hsize_t)));
+ H5MM_memcpy(new_node->pnt, curr->pnt, (rank * sizeof(hsize_t)));
/* Keep the order the same when copying */
if(NULL == new_tail)
- new_tail = dst->select.sel_info.pnt_lst->head = new_node;
+ new_tail = dst->head = new_node;
else {
new_tail->next = new_node;
new_tail = new_node;
@@ -643,35 +856,114 @@ H5S_point_copy(H5S_t *dst, const H5S_t *src, hbool_t H5_ATTR_UNUSED share_select
curr = curr->next;
} /* end while */
+ dst->tail = new_tail;
+
+ /* Copy the selection bounds */
+ H5MM_memcpy(dst->high_bounds, src->high_bounds, (rank * sizeof(hsize_t)));
+ H5MM_memcpy(dst->low_bounds, src->low_bounds, (rank * sizeof(hsize_t)));
+
+ /* Set return value */
+ ret_value = dst;
done:
- if(ret_value < 0 && dst->select.sel_info.pnt_lst) {
- /* Traverse the (incomplete?) dst list, freeing all memory */
- curr = dst->select.sel_info.pnt_lst->head;
- while(curr) {
- H5S_pnt_node_t *tmp_node = curr;
-
- curr->pnt = (hsize_t *)H5MM_xfree(curr->pnt);
- curr = curr->next;
- tmp_node = H5FL_FREE(H5S_pnt_node_t, tmp_node);
- } /* end while */
+ if(NULL == ret_value && dst)
+ H5S__free_pnt_list(dst);
- dst->select.sel_info.pnt_lst = H5FL_FREE(H5S_pnt_list_t, dst->select.sel_info.pnt_lst);
- } /* end if */
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5S__copy_pnt_list() */
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S__free_pnt_list
+ PURPOSE
+ Free a point selection list
+ USAGE
+ void H5S__free_pnt_list(pnt_lst)
+ H5S_pnt_list_t *pnt_lst; IN: Pointer to the point list to free
+ RETURNS
+ None
+ DESCRIPTION
+ Frees point selection information from the point list
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+static void
+H5S__free_pnt_list(H5S_pnt_list_t *pnt_lst)
+{
+ H5S_pnt_node_t *curr; /* Point information nodes */
+
+ FUNC_ENTER_STATIC_NOERR
+
+ /* Sanity checks */
+ HDassert(pnt_lst);
+
+ /* Traverse the list, freeing all memory */
+ curr = pnt_lst->head;
+ while(curr) {
+ H5S_pnt_node_t *tmp_node = curr;
+
+ curr = curr->next;
+ tmp_node = (H5S_pnt_node_t *)H5FL_ARR_FREE(hcoords_t, tmp_node);
+ } /* end while */
+
+ H5FL_FREE(H5S_pnt_list_t, pnt_lst);
+
+ FUNC_LEAVE_NOAPI_VOID
+} /* end H5S__free_pnt_list() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S__point_copy
+ PURPOSE
+ Copy a selection from one dataspace to another
+ USAGE
+ herr_t H5S__point_copy(dst, src, share_selection)
+ H5S_t *dst; OUT: Pointer to the destination dataspace
+ H5S_t *src; IN: Pointer to the source dataspace
+ hbool_t share_selection; IN: Whether to share the selection between the dataspaces
+ RETURNS
+ Non-negative on success/Negative on failure
+ DESCRIPTION
+ Copies all the point selection information from the source
+ dataspace to the destination dataspace.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+static herr_t
+H5S__point_copy(H5S_t *dst, const H5S_t *src, hbool_t H5_ATTR_UNUSED share_selection)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_STATIC
+
+ /* Sanity check */
+ HDassert(src);
+ HDassert(dst);
+
+ /* Allocate room for the head of the point list */
+ if(NULL == (dst->select.sel_info.pnt_lst = H5S__copy_pnt_list(src->select.sel_info.pnt_lst, src->extent.rank)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy point list")
+
+done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5S_point_copy() */
+} /* end H5S__point_copy() */
/*--------------------------------------------------------------------------
NAME
- H5S_point_is_valid
+ H5S__point_is_valid
PURPOSE
Check whether the selection fits within the extent, with the current
offset defined.
USAGE
- htri_t H5S_point_is_valid(space);
- H5S_t *space; IN: Dataspace pointer to query
+ htri_t H5S__point_is_valid(space);
+ const H5S_t *space; IN: Dataspace pointer to query
RETURNS
TRUE if the selection fits within the extent, FALSE if it does not and
Negative on an error.
@@ -684,34 +976,27 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
static htri_t
-H5S_point_is_valid (const H5S_t *space)
+H5S__point_is_valid(const H5S_t *space)
{
- H5S_pnt_node_t *curr; /* Point information nodes */
unsigned u; /* Counter */
htri_t ret_value = TRUE; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
HDassert(space);
- /* Check each point to determine whether selection+offset is within extent */
- curr = space->select.sel_info.pnt_lst->head;
- while(curr != NULL) {
- /* Check each dimension */
- for(u = 0; u < space->extent.rank; u++) {
- /* Check if an offset has been defined */
- /* Bounds check the selected point + offset against the extent */
- if(((curr->pnt[u] + (hsize_t)space->select.offset[u]) > space->extent.size[u])
- || (((hssize_t)curr->pnt[u] + space->select.offset[u]) < 0))
- HGOTO_DONE(FALSE)
- } /* end for */
-
- curr = curr->next;
- } /* end while */
+ /* Check each dimension */
+ for(u = 0; u < space->extent.rank; u++) {
+ /* Bounds check the selected point + offset against the extent */
+ if((space->select.sel_info.pnt_lst->high_bounds[u] + (hsize_t)space->select.offset[u]) > space->extent.size[u])
+ HGOTO_DONE(FALSE)
+ if(((hssize_t)space->select.sel_info.pnt_lst->low_bounds[u] + space->select.offset[u]) < 0)
+ HGOTO_DONE(FALSE)
+ } /* end for */
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5S_point_is_valid() */
+} /* end H5S__point_is_valid() */
/*--------------------------------------------------------------------------
@@ -750,18 +1035,136 @@ H5Sget_select_elem_npoints(hid_t spaceid)
done:
FUNC_LEAVE_API(ret_value)
-} /* H5Sget_select_elem_npoints() */
+} /* end H5Sget_select_elem_npoints() */
/*--------------------------------------------------------------------------
NAME
- H5S_point_serial_size
+ H5S__point_get_version_enc_size
+ PURPOSE
+ Determine the version and the size (2, 4 or 8 bytes) to encode point selection info
+ USAGE
+ hssize_t H5S__point_set_enc_size(space, version, enc_size)
+ const H5S_t *space: IN: Dataspace ID of selection to query
+ uint32_t *version: OUT: The version to use for encoding
+ uint8_t *enc_size: OUT: The size to use for encoding
+ RETURNS
+ The version and the size to encode point selection info
+ DESCRIPTION
+ Determine the version to use for encoding points selection info based
+ on the following:
+ (1) the low/high bounds setting in fapl
+ (2) whether the number of points or selection high bounds exceeds H5S_UINT32_MAX or not
+
+ Determine the encoded size based on version:
+ --For version 2, the encoded size of point selection info is determined
+ by the maximum size for:
+ (a) storing the number of points
+ (b) storing the selection high bounds
+
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+static herr_t
+H5S__point_get_version_enc_size(const H5S_t *space, uint32_t *version, uint8_t *enc_size)
+{
+ hbool_t count_up_version = FALSE; /* Whether number of points exceed H5S_UINT32_MAX */
+ hbool_t bound_up_version = FALSE; /* Whether high bounds exceed H5S_UINT32_MAX */
+ H5F_libver_t low_bound; /* The 'low' bound of library format versions */
+ H5F_libver_t high_bound; /* The 'high' bound of library format versions */
+ uint32_t tmp_version; /* Local temporary version */
+ hsize_t bounds_start[H5S_MAX_RANK]; /* Starting coordinate of bounding box */
+ hsize_t bounds_end[H5S_MAX_RANK]; /* Opposite coordinate of bounding box */
+ hsize_t max_size = 0; /* Maximum selection size */
+ unsigned u; /* Local index veriable */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_STATIC
+
+ /* Get bounding box for the selection */
+ HDmemset(bounds_end, 0, sizeof(bounds_end));
+ if(H5S__point_bounds(space, bounds_start, bounds_end) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get selection bounds")
+
+ /* Determine whether number of points or high bounds exceeds (2^32 - 1) */
+ if(space->select.num_elem > H5S_UINT32_MAX)
+ count_up_version = TRUE;
+ else
+ for(u = 0; u < space->extent.rank; u++)
+ if(bounds_end[u] > H5S_UINT32_MAX) {
+ bound_up_version = TRUE;
+ break;
+ } /* end if */
+
+ /* If exceed (2^32 -1) */
+ if(count_up_version || bound_up_version)
+ tmp_version = H5S_POINT_VERSION_2;
+ else
+ tmp_version = H5S_POINT_VERSION_1;
+
+ /* Get the file's low/high bounds */
+ if(H5CX_get_libver_bounds(&low_bound, &high_bound) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get low/high bounds from API context")
+
+ /* Upgrade to the version indicated by the file's low bound if higher */
+ tmp_version = MAX(tmp_version, H5O_sds_point_ver_bounds[low_bound]);
+
+ /* Version bounds check */
+ if(tmp_version > H5O_sds_point_ver_bounds[high_bound]) {
+ if(count_up_version)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "The number of points in point selection exceeds 2^32")
+ else if(bound_up_version)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "The end of bounding box in point selection exceeds 2^32")
+ else
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "Dataspace point selection version out of bounds")
+ } /* end if */
+
+ /* Set the version to return */
+ *version = tmp_version;
+
+ /* Get the encoded size use based on version */
+ switch(tmp_version) {
+ case H5S_POINT_VERSION_1:
+ *enc_size = H5S_SELECT_INFO_ENC_SIZE_4;
+ break;
+
+ case H5S_POINT_VERSION_2:
+ /* Find max for num_elem and bounds_end[] */
+ max_size = space->select.num_elem;
+ for(u = 0; u < space->extent.rank; u++)
+ if(bounds_end[u] > max_size)
+ max_size = bounds_end[u];
+
+ /* Determine the encoding size */
+ if(max_size > H5S_UINT32_MAX)
+ *enc_size = H5S_SELECT_INFO_ENC_SIZE_8;
+ else if(max_size > H5S_UINT16_MAX)
+ *enc_size = H5S_SELECT_INFO_ENC_SIZE_4;
+ else
+ *enc_size = H5S_SELECT_INFO_ENC_SIZE_2;
+ break;
+
+ default:
+ HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unknown point info size")
+ break;
+ } /* end switch */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5S__point_get_version_enc_size() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S__point_serial_size
PURPOSE
Determine the number of bytes needed to store the serialized point selection
information.
USAGE
- hssize_t H5S_point_serial_size(space)
- H5S_t *space; IN: Dataspace pointer to query
+ hssize_t H5S__point_serial_size(space)
+ const H5S_t *space; IN: Dataspace pointer to query
RETURNS
The number of bytes required on success, negative on an error.
DESCRIPTION
@@ -773,35 +1176,52 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
static hssize_t
-H5S_point_serial_size (const H5S_t *space)
+H5S__point_serial_size(const H5S_t *space)
{
+ uint32_t version; /* Version number */
+ uint8_t enc_size; /* Encoded size of point selection info */
hssize_t ret_value = -1; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC
HDassert(space);
- /* Basic number of bytes required to serialize point selection:
- * <type (4 bytes)> + <version (4 bytes)> + <padding (4 bytes)> +
- * <length (4 bytes)> + <rank (4 bytes)> + <# of points (4 bytes)> = 24 bytes
- */
- ret_value = 24;
+ /* Determine the version and encoded size for point selection */
+ if(H5S__point_get_version_enc_size(space, &version, &enc_size) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't determine hyper version")
+
+ /* Basic number of bytes required to serialize point selection: */
+ if(version >= H5S_POINT_VERSION_2)
+ /*
+ * <type (4 bytes)> + <version (4 bytes)> +
+ * <size of point info (1 byte)> + rank (4 bytes)>
+ */
+ ret_value=13;
+ else
+ /*
+ * <type (4 bytes)> + <version (4 bytes)> + <padding (4 bytes)> +
+ * <length (4 bytes)> + <rank (4 bytes)>
+ */
+ ret_value = 20;
+
+ /* <num points (depend on enc_size)> */
+ ret_value += enc_size;
/* Count points in selection */
- /* (Add 4 bytes times the rank for each element selected) */
- ret_value += (4 * space->extent.rank) * (hssize_t)H5S_GET_SELECT_NPOINTS(space);
+ ret_value += (hssize_t) (enc_size * space->extent.rank * space->select.num_elem);
+done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5S_point_serial_size() */
+} /* end H5S__point_serial_size() */
/*--------------------------------------------------------------------------
NAME
- H5S_point_serialize
+ H5S__point_serialize
PURPOSE
Serialize the current selection into a user-provided buffer.
USAGE
- herr_t H5S_point_serialize(space, p)
+ herr_t H5S__point_serialize(space, p)
const H5S_t *space; IN: Dataspace with selection to serialize
uint8_t **p; OUT: Pointer to buffer to put serialized
selection. Will be advanced to end of
@@ -817,70 +1237,126 @@ H5S_point_serial_size (const H5S_t *space)
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
-H5S_point_serialize (const H5S_t *space, uint8_t **p)
+H5S__point_serialize(const H5S_t *space, uint8_t **p)
{
H5S_pnt_node_t *curr; /* Point information nodes */
- uint8_t *pp = (*p); /* Local pointer for decoding */
- uint8_t *lenp; /* pointer to length location for later storage */
+ uint8_t *pp; /* Local pointer for decoding */
+ uint8_t *lenp = NULL; /* pointer to length location for later storage */
uint32_t len=0; /* number of bytes used */
unsigned u; /* local counting variable */
+ uint32_t version; /* Version number */
+ uint8_t enc_size; /* Encoded size of point selection info */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC
/* Check args */
HDassert(space);
HDassert(p);
+ pp = (*p);
HDassert(pp);
+ /* Determine the version and encoded size for point selection info */
+ if(H5S__point_get_version_enc_size(space, &version, &enc_size) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't determine hyper version")
+
/* 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 */
- lenp = pp; /* Keep the pointer to the length location for later */
- pp += 4; /* Skip over space for length */
+
+ UINT32ENCODE(pp, version); /* Store the version number */
+ if(version >= 2) {
+ *(pp)++ = enc_size; /* Store size of point info */
+ } else {
+ HDassert(version == H5S_POINT_VERSION_1);
+ 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 */
+ len += 8; /* Add in advance # of bytes for num of dimensions and num elements */
+ }
/* Encode number of dimensions */
UINT32ENCODE(pp, (uint32_t)space->extent.rank);
- len+=4;
- /* Encode number of elements */
- UINT32ENCODE(pp, (uint32_t)space->select.num_elem);
- len+=4;
+ switch(enc_size) {
+ case H5S_SELECT_INFO_ENC_SIZE_2:
+ HDassert(version == H5S_POINT_VERSION_2);
+
+ /* Encode number of elements */
+ UINT16ENCODE(pp, (uint16_t)space->select.num_elem);
+
+ /* Encode each point in selection */
+ curr=space->select.sel_info.pnt_lst->head;
+ while(curr!=NULL) {
+ /* Encode each point */
+ for(u=0; u<space->extent.rank; u++)
+ UINT16ENCODE(pp, (uint16_t)curr->pnt[u]);
+ curr=curr->next;
+ } /* end while */
+ break;
+
+ case H5S_SELECT_INFO_ENC_SIZE_4:
+ HDassert(version == H5S_POINT_VERSION_1 || version == H5S_POINT_VERSION_2);
- /* Encode each point in selection */
- curr=space->select.sel_info.pnt_lst->head;
- while(curr!=NULL) {
- /* Add 4 bytes times the rank for each element selected */
- len+=4*space->extent.rank;
+ /* Encode number of elements */
+ UINT32ENCODE(pp, (uint32_t)space->select.num_elem);
- /* Encode each point */
- for(u=0; u<space->extent.rank; u++)
- UINT32ENCODE(pp, (uint32_t)curr->pnt[u]);
+ /* Encode each point in selection */
+ curr=space->select.sel_info.pnt_lst->head;
+ while(curr!=NULL) {
+ /* Encode each point */
+ for(u=0; u<space->extent.rank; u++)
+ UINT32ENCODE(pp, (uint32_t)curr->pnt[u]);
+ curr=curr->next;
+ } /* end while */
- curr=curr->next;
- } /* end while */
+ /* Add 4 bytes times the rank for each element selected */
+ if(version == H5S_POINT_VERSION_1)
+ len += (uint32_t)space->select.num_elem * 4 * space->extent.rank;
+ break;
+
+ case H5S_SELECT_INFO_ENC_SIZE_8:
+ HDassert(version == H5S_POINT_VERSION_2);
+
+ /* Encode number of elements */
+ UINT64ENCODE(pp, space->select.num_elem);
+
+ /* Encode each point in selection */
+ curr=space->select.sel_info.pnt_lst->head;
+ while(curr!=NULL) {
+ /* Encode each point */
+ for(u=0; u<space->extent.rank; u++)
+ UINT64ENCODE(pp, curr->pnt[u]);
+ curr=curr->next;
+ } /* end while */
+ break;
+
+ default:
+ HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unknown point info size")
+ break;
+
+ } /* end switch */
- /* Encode length */
- UINT32ENCODE(lenp, (uint32_t)len); /* Store the length of the extra information */
+ if(version == H5S_POINT_VERSION_1)
+ UINT32ENCODE(lenp, (uint32_t)len); /* Store the length of the extra information */
/* Update encoding pointer */
*p = pp;
- FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5S_point_serialize() */
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5S__point_serialize() */
+
/*--------------------------------------------------------------------------
NAME
- H5S_point_deserialize
+ H5S__point_deserialize
PURPOSE
Deserialize the current selection from a user-provided buffer.
USAGE
- herr_t H5S_point_deserialize(space, p)
- H5S_t *space; IN/OUT: Dataspace pointer to place
+ herr_t H5S__point_deserialize(space, p)
+ H5S_t **space; IN/OUT: Dataspace pointer to place
selection into
- uint32_t version IN: Selection version
- uint8_t flags IN: Selection flags
uint8 **p; OUT: Pointer to buffer holding serialized
selection. Will be advanced to end of
serialized selection.
@@ -895,28 +1371,85 @@ H5S_point_serialize (const H5S_t *space, uint8_t **p)
REVISION LOG
--------------------------------------------------------------------------*/
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__point_deserialize(H5S_t **space, const uint8_t **p)
{
- H5S_seloper_t op = H5S_SELECT_SET; /* Selection operation */
+ H5S_t *tmp_space = NULL; /* Pointer to actual dataspace to use,
+ either *space or a newly allocated one */
+ hsize_t dims[H5S_MAX_RANK]; /* Dimension sizes */
+ uint32_t version; /* Version number */
+ uint8_t enc_size = 0; /* Encoded size of selection info */
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 */
+ const uint8_t *pp; /* Local pointer for decoding */
+ uint64_t num_elem = 0; /* Number of elements in selection */
unsigned rank; /* Rank of points */
unsigned i, j; /* local counting variables */
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_STATIC
/* Check args */
- HDassert(space);
HDassert(p);
+ pp = (*p);
HDassert(pp);
- /* 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 */
+ /* As part of the efforts to push all selection-type specific coding
+ to the callbacks, the coding for the allocation of a null dataspace
+ is moved from H5S_select_deserialize() in H5Sselect.c to here.
+ This is needed for decoding virtual layout in H5O__layout_decode() */
+ /* Allocate space if not provided */
+ if(!*space) {
+ if(NULL == (tmp_space = H5S_create(H5S_SIMPLE)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create dataspace")
+ } /* end if */
+ else
+ tmp_space = *space;
+
+ /* Decode version */
+ UINT32DECODE(pp, version);
+
+ if(version >= (uint32_t)H5S_POINT_VERSION_2)
+ /* Decode size of point info */
+ enc_size = *(pp)++;
+ else {
+ /* Skip over the remainder of the header */
+ pp += 8;
+ enc_size = H5S_SELECT_INFO_ENC_SIZE_4;
+ }
+
+ /* Check encoded size */
+ if(enc_size & ~H5S_SELECT_INFO_ENC_SIZE_BITS)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTLOAD, FAIL, "unknown size of point/offset info for selection")
+
+ /* Decode the rank of the point selection */
+ UINT32DECODE(pp,rank);
+
+ if(!*space) {
+ /* Patch the rank of the allocated dataspace */
+ (void)HDmemset(dims, 0, (size_t)rank * sizeof(dims[0]));
+ if(H5S_set_extent_simple(tmp_space, rank, dims, NULL) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't set dimensions")
+ } /* end if */
+ else
+ /* Verify the rank of the provided dataspace */
+ if(rank != tmp_space->extent.rank)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "rank of serialized selection does not match dataspace")
+
+ /* decode the number of points */
+ switch(enc_size) {
+ case H5S_SELECT_INFO_ENC_SIZE_2:
+ UINT16DECODE(pp, num_elem);
+ break;
+ case H5S_SELECT_INFO_ENC_SIZE_4:
+ UINT32DECODE(pp, num_elem);
+ break;
+ case H5S_SELECT_INFO_ENC_SIZE_8:
+ UINT64DECODE(pp, num_elem);
+ break;
+ default:
+ HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unknown point info size")
+ break;
+ } /* end switch */
+
/* Allocate space for the coordinates */
if(NULL == (coord = (hsize_t *)H5MM_malloc(num_elem * rank * sizeof(hsize_t))))
@@ -925,32 +1458,56 @@ 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);
+ switch(enc_size) {
+ case H5S_SELECT_INFO_ENC_SIZE_2:
+ UINT16DECODE(pp, *tcoord);
+ break;
+
+ case H5S_SELECT_INFO_ENC_SIZE_4:
+ UINT32DECODE(pp, *tcoord);
+ break;
+
+ case H5S_SELECT_INFO_ENC_SIZE_8:
+ UINT64DECODE(pp, *tcoord);
+ break;
+ default:
+ HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unknown point info size")
+ break;
+ } /* end switch */
/* Select points */
- if(H5S_select_elements(space, op, num_elem, (const hsize_t *)coord) < 0)
+ if(H5S_select_elements(tmp_space, H5S_SELECT_SET, num_elem, (const hsize_t *)coord) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection")
/* Update decoding pointer */
*p = pp;
+ /* Return space to the caller if allocated */
+ if(!*space)
+ *space = tmp_space;
+
done:
+ /* Free temporary space if not passed to caller (only happens on error) */
+ if(!*space && tmp_space)
+ if(H5S_close(tmp_space) < 0)
+ HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "can't close dataspace")
+
/* Free the coordinate array if necessary */
if(coord != NULL)
H5MM_xfree(coord);
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_point_deserialize() */
+} /* end H5S__point_deserialize() */
/*--------------------------------------------------------------------------
NAME
- H5S_get_select_elem_pointlist
+ H5S__get_select_elem_pointlist
PURPOSE
Get the list of element points currently selected
USAGE
- herr_t H5S_get_select_elem_pointlist(space, hsize_t *buf)
- H5S_t *space; IN: Dataspace pointer of selection to query
+ herr_t H5S__get_select_elem_pointlist(space, hsize_t *buf)
+ const H5S_t *space; IN: Dataspace pointer of selection to query
hsize_t startpoint; IN: Element point to start with
hsize_t numpoints; IN: Number of element points to get
hsize_t *buf; OUT: List of element points selected
@@ -973,12 +1530,13 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
-H5S_get_select_elem_pointlist(H5S_t *space, hsize_t startpoint, hsize_t numpoints, hsize_t *buf)
+H5S__get_select_elem_pointlist(const H5S_t *space, hsize_t startpoint,
+ hsize_t numpoints, hsize_t *buf)
{
H5S_pnt_node_t *node; /* Point node */
unsigned rank; /* Dataspace rank */
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
HDassert(space);
HDassert(buf);
@@ -997,14 +1555,14 @@ H5S_get_select_elem_pointlist(H5S_t *space, hsize_t startpoint, hsize_t numpoint
/* Iterate through the node, copying each point's information */
while(node != NULL && numpoints > 0) {
- HDmemcpy(buf, node->pnt, sizeof(hsize_t) * rank);
+ H5MM_memcpy(buf, node->pnt, sizeof(hsize_t) * rank);
buf += rank;
numpoints--;
node = node->next;
} /* end while */
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5S_get_select_elem_pointlist() */
+} /* end H5S__get_select_elem_pointlist() */
/*--------------------------------------------------------------------------
@@ -1054,20 +1612,20 @@ H5Sget_select_elem_pointlist(hid_t spaceid, hsize_t startpoint,
if(H5S_GET_SELECT_TYPE(space) != H5S_SEL_POINTS)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a point selection")
- ret_value = H5S_get_select_elem_pointlist(space, startpoint, numpoints, buf);
+ ret_value = H5S__get_select_elem_pointlist(space, startpoint, numpoints, buf);
done:
FUNC_LEAVE_API(ret_value)
-} /* H5Sget_select_elem_pointlist() */
+} /* end H5Sget_select_elem_pointlist() */
/*--------------------------------------------------------------------------
NAME
- H5S_point_bounds
+ H5S__point_bounds
PURPOSE
Gets the bounding box containing the selection.
USAGE
- herr_t H5S_point_bounds(space, start, end)
+ herr_t H5S__point_bounds(space, start, end)
H5S_t *space; IN: Dataspace pointer of selection to query
hsize_t *start; OUT: Starting coordinate of bounding box
hsize_t *end; OUT: Opposite coordinate of bounding box
@@ -1088,57 +1646,44 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
-H5S_point_bounds(const H5S_t *space, hsize_t *start, hsize_t *end)
+H5S__point_bounds(const H5S_t *space, hsize_t *start, hsize_t *end)
{
- H5S_pnt_node_t *node; /* Point node */
- unsigned rank; /* Dataspace rank */
unsigned u; /* Local index variable */
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_STATIC
/* Sanity check */
HDassert(space);
HDassert(start);
HDassert(end);
- /* Get the dataspace extent rank */
- rank = space->extent.rank;
-
- /* Set the start and end arrays up */
- for(u = 0; u < rank; u++) {
- start[u] = HSIZET_MAX;
- end[u] = 0;
- } /* end for */
+ /* Loop over dimensions */
+ for(u = 0; u < space->extent.rank; u++) {
+ /* Sanity check */
+ HDassert(space->select.sel_info.pnt_lst->low_bounds[u] <= space->select.sel_info.pnt_lst->high_bounds[u]);
- /* Iterate through the node, checking the bounds on each element */
- node = space->select.sel_info.pnt_lst->head;
- while(node != NULL) {
- for(u = 0; u < rank; u++) {
- /* Check for offset moving selection negative */
- if(((hssize_t)node->pnt[u] + space->select.offset[u]) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "offset moves selection out of bounds")
+ /* Check for offset moving selection negative */
+ if(((hssize_t)space->select.sel_info.pnt_lst->low_bounds[u] + space->select.offset[u]) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "offset moves selection out of bounds")
- if(start[u] > (hsize_t)((hssize_t)node->pnt[u] + space->select.offset[u]))
- start[u] = (hsize_t)((hssize_t)node->pnt[u] + space->select.offset[u]);
- if(end[u] < (hsize_t)((hssize_t)node->pnt[u] + space->select.offset[u]))
- end[u] = (hsize_t)((hssize_t)node->pnt[u] + space->select.offset[u]);
- } /* end for */
- node = node->next;
- } /* end while */
+ /* Set the low & high bounds in this dimension */
+ start[u] = (hsize_t)((hssize_t)space->select.sel_info.pnt_lst->low_bounds[u] + space->select.offset[u]);
+ end[u] = (hsize_t)((hssize_t)space->select.sel_info.pnt_lst->high_bounds[u] + space->select.offset[u]);
+ } /* end for */
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_point_bounds() */
+} /* end H5S__point_bounds() */
/*--------------------------------------------------------------------------
NAME
- H5S_point_offset
+ H5S__point_offset
PURPOSE
Gets the linear offset of the first element for the selection.
USAGE
- herr_t H5S_point_offset(space, offset)
+ herr_t H5S__point_offset(space, offset)
const H5S_t *space; IN: Dataspace pointer of selection to query
hsize_t *offset; OUT: Linear offset of first element in selection
RETURNS
@@ -1153,7 +1698,7 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
-H5S_point_offset(const H5S_t *space, hsize_t *offset)
+H5S__point_offset(const H5S_t *space, hsize_t *offset)
{
const hsize_t *pnt; /* Pointer to a selected point's coordinates */
const hssize_t *sel_offset; /* Pointer to the selection's offset */
@@ -1162,7 +1707,7 @@ H5S_point_offset(const H5S_t *space, hsize_t *offset)
int i; /* index variable */
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(FAIL)
+ FUNC_ENTER_STATIC
HDassert(space);
HDassert(offset);
@@ -1193,7 +1738,7 @@ H5S_point_offset(const H5S_t *space, hsize_t *offset)
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_point_offset() */
+} /* end H5S__point_offset() */
/*--------------------------------------------------------------------------
@@ -1227,11 +1772,11 @@ H5S__point_unlim_dim(const H5S_t H5_ATTR_UNUSED *space)
/*--------------------------------------------------------------------------
NAME
- H5S_point_is_contiguous
+ H5S__point_is_contiguous
PURPOSE
Check if a point selection is contiguous within the dataspace extent.
USAGE
- htri_t H5S_point_is_contiguous(space)
+ htri_t H5S__point_is_contiguous(space)
H5S_t *space; IN: Dataspace pointer to check
RETURNS
TRUE/FALSE/FAIL
@@ -1247,31 +1792,31 @@ H5S__point_unlim_dim(const H5S_t H5_ATTR_UNUSED *space)
REVISION LOG
--------------------------------------------------------------------------*/
static htri_t
-H5S_point_is_contiguous(const H5S_t *space)
+H5S__point_is_contiguous(const H5S_t *space)
{
htri_t ret_value = FAIL; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
HDassert(space);
/* One point is definitely contiguous */
- if(space->select.num_elem==1)
- ret_value=TRUE;
+ if(space->select.num_elem == 1)
+ ret_value = TRUE;
else /* More than one point might be contiguous, but it's complex to check and we don't need it right now */
- ret_value=FALSE;
+ ret_value = FALSE;
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_point_is_contiguous() */
+} /* end H5S__point_is_contiguous() */
/*--------------------------------------------------------------------------
NAME
- H5S_point_is_single
+ H5S__point_is_single
PURPOSE
Check if a point selection is single within the dataspace extent.
USAGE
- htri_t H5S_point_is_single(space)
+ htri_t H5S__point_is_single(space)
H5S_t *space; IN: Dataspace pointer to check
RETURNS
TRUE/FALSE/FAIL
@@ -1284,31 +1829,31 @@ H5S_point_is_contiguous(const H5S_t *space)
REVISION LOG
--------------------------------------------------------------------------*/
static htri_t
-H5S_point_is_single(const H5S_t *space)
+H5S__point_is_single(const H5S_t *space)
{
htri_t ret_value = FAIL; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
HDassert(space);
/* One point is definitely 'single' :-) */
- if(space->select.num_elem==1)
- ret_value=TRUE;
+ if(space->select.num_elem == 1)
+ ret_value = TRUE;
else
- ret_value=FALSE;
+ ret_value = FALSE;
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_point_is_single() */
+} /* end H5S__point_is_single() */
/*--------------------------------------------------------------------------
NAME
- H5S_point_is_regular
+ H5S__point_is_regular
PURPOSE
Check if a point selection is "regular"
USAGE
- htri_t H5S_point_is_regular(space)
+ htri_t H5S__point_is_regular(space)
const H5S_t *space; IN: Dataspace pointer to check
RETURNS
TRUE/FALSE/FAIL
@@ -1324,32 +1869,140 @@ H5S_point_is_single(const H5S_t *space)
REVISION LOG
--------------------------------------------------------------------------*/
static htri_t
-H5S_point_is_regular(const H5S_t *space)
+H5S__point_is_regular(const H5S_t *space)
{
htri_t ret_value = FAIL; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
/* Check args */
HDassert(space);
/* Only simple check for regular points for now... */
- if(space->select.num_elem==1)
- ret_value=TRUE;
+ if(space->select.num_elem == 1)
+ ret_value = TRUE;
else
- ret_value=FALSE;
+ ret_value = FALSE;
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_point_is_regular() */
+} /* end H5S__point_is_regular() */
/*--------------------------------------------------------------------------
NAME
- H5S_point_adjust_u
+ H5S__point_shape_same
+ PURPOSE
+ Check if a two "point" selections are the same shape
+ USAGE
+ htri_t H5S__point_shape_same(space1, space2)
+ const H5S_t *space1; IN: First dataspace to check
+ const H5S_t *space2; IN: Second dataspace to check
+ RETURNS
+ TRUE / FALSE / FAIL
+ DESCRIPTION
+ Checks to see if the current selection in each dataspace are the same
+ shape.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+static htri_t
+H5S__point_shape_same(const H5S_t *space1, const H5S_t *space2)
+{
+ H5S_pnt_node_t *pnt1, *pnt2; /* Point information nodes */
+ hssize_t offset[H5S_MAX_RANK]; /* Offset between the selections */
+ unsigned space1_rank; /* Number of dimensions of first dataspace */
+ unsigned space2_rank; /* Number of dimensions of second dataspace */
+ int space1_dim; /* Current dimension in first dataspace */
+ int space2_dim; /* Current dimension in second dataspace */
+ htri_t ret_value = TRUE; /* Return value */
+
+ FUNC_ENTER_STATIC_NOERR
+
+ /* Check args */
+ HDassert(space1);
+ HDassert(space2);
+
+ /* Get dataspace ranks */
+ space1_rank = space1->extent.rank;
+ space2_rank = space2->extent.rank;
+
+ /* Sanity check */
+ HDassert(space1_rank >= space2_rank);
+ HDassert(space2_rank > 0);
+
+ /* Initialize dimensions */
+ space1_dim = (int)space1_rank - 1;
+ space2_dim = (int)space2_rank - 1;
+
+ /* Look at first point in each selection to compute the offset for common
+ * dimensions.
+ */
+ pnt1 = space1->select.sel_info.pnt_lst->head;
+ pnt2 = space2->select.sel_info.pnt_lst->head;
+ while(space2_dim >= 0) {
+ /* Set the relative locations of the selections */
+ offset[space1_dim] = (hssize_t)pnt2->pnt[space2_dim] - (hssize_t)pnt1->pnt[space1_dim];
+
+ space1_dim--;
+ space2_dim--;
+ } /* end while */
+
+ /* For dimensions that appear only in space1: */
+ while(space1_dim >= 0) {
+ /* Set the absolute offset of the remaining dimensions */
+ offset[space1_dim] = (hssize_t)pnt1->pnt[space1_dim];
+
+ space1_dim--;
+ } /* end while */
+
+ /* Advance to next point */
+ pnt1 = pnt1->next;
+ pnt2 = pnt2->next;
+
+ /* Loop over remaining points */
+ while(pnt1 && pnt2) {
+ /* Initialize dimensions */
+ space1_dim = (int)space1_rank - 1;
+ space2_dim = (int)space2_rank - 1;
+
+ /* Compare locations in common dimensions, including relative offset */
+ while(space2_dim >= 0) {
+ if((hsize_t)((hssize_t)pnt1->pnt[space1_dim] + offset[space1_dim]) != pnt2->pnt[space2_dim])
+ HGOTO_DONE(FALSE)
+
+ space1_dim--;
+ space2_dim--;
+ } /* end while */
+
+ /* For dimensions that appear only in space1: */
+ while(space1_dim >= 0) {
+ /* Compare the absolute offset in the remaining dimensions */
+ if((hssize_t)pnt1->pnt[space1_dim] != offset[space1_dim])
+ HGOTO_DONE(FALSE)
+
+ space1_dim--;
+ } /* end while */
+
+
+ /* Advance to next point */
+ pnt1 = pnt1->next;
+ pnt2 = pnt2->next;
+ } /* end while */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5S__point_shape_same() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S__point_adjust_u
PURPOSE
Adjust a "point" selection by subtracting an offset
USAGE
- herr_t H5S_point_adjust_u(space, offset)
+ herr_t H5S__point_adjust_u(space, offset)
H5S_t *space; IN/OUT: Pointer to dataspace to adjust
const hsize_t *offset; IN: Offset to subtract
RETURNS
@@ -1362,12 +2015,13 @@ H5S_point_is_regular(const H5S_t *space)
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
-H5S_point_adjust_u(H5S_t *space, const hsize_t *offset)
+H5S__point_adjust_u(H5S_t *space, const hsize_t *offset)
{
H5S_pnt_node_t *node; /* Point node */
unsigned rank; /* Dataspace rank */
+ unsigned u; /* Local index variable */
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
HDassert(space);
HDassert(offset);
@@ -1376,8 +2030,6 @@ H5S_point_adjust_u(H5S_t *space, const hsize_t *offset)
node = space->select.sel_info.pnt_lst->head;
rank = space->extent.rank;
while(node) {
- unsigned u; /* Local index variable */
-
/* Adjust each coordinate for point node */
for(u = 0; u < rank; u++) {
/* Check for offset moving selection negative */
@@ -1391,17 +2043,23 @@ H5S_point_adjust_u(H5S_t *space, const hsize_t *offset)
node = node->next;
} /* end while */
+ /* update the bound box of the selection */
+ for(u = 0; u < rank; u++) {
+ space->select.sel_info.pnt_lst->low_bounds[u] -= offset[u];
+ space->select.sel_info.pnt_lst->high_bounds[u] -= offset[u];
+ } /* end for */
+
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5S_point_adjust_u() */
+} /* end H5S__point_adjust_u() */
/*-------------------------------------------------------------------------
- * Function: H5S_point_project_scalar
+ * Function: H5S__point_project_scalar
*
* Purpose: Projects a single element point selection into a scalar
* dataspace
*
- * Return: non-negative on success, negative on failure.
+ * Return: Non-negative on success, negative on failure.
*
* Programmer: Quincey Koziol
* Sunday, July 18, 2010
@@ -1409,12 +2067,12 @@ H5S_point_adjust_u(H5S_t *space, const hsize_t *offset)
*-------------------------------------------------------------------------
*/
static herr_t
-H5S_point_project_scalar(const H5S_t *space, hsize_t *offset)
+H5S__point_project_scalar(const H5S_t *space, hsize_t *offset)
{
const H5S_pnt_node_t *node; /* Point node */
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_STATIC
/* Check args */
HDassert(space && H5S_SEL_POINTS == H5S_GET_SELECT_TYPE(space));
@@ -1428,20 +2086,20 @@ H5S_point_project_scalar(const H5S_t *space, hsize_t *offset)
HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "point selection of one element has more than one node!")
/* Calculate offset of selection in projected buffer */
- *offset = H5VM_array_offset(space->extent.rank, space->extent.size, node->pnt);
+ *offset = H5VM_array_offset(space->extent.rank, space->extent.size, node->pnt);
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_point_project_scalar() */
+} /* end H5S__point_project_scalar() */
/*-------------------------------------------------------------------------
- * Function: H5S_point_project_simple
+ * Function: H5S__point_project_simple
*
* Purpose: Projects a point selection onto/into a simple dataspace
* of a different rank
*
- * Return: non-negative on success, negative on failure.
+ * Return: Non-negative on success, negative on failure.
*
* Programmer: Quincey Koziol
* Sunday, July 18, 2010
@@ -1449,15 +2107,16 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5S_point_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *offset)
+H5S__point_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *offset)
{
const H5S_pnt_node_t *base_node; /* Point node in base space */
H5S_pnt_node_t *new_node; /* Point node in new space */
H5S_pnt_node_t *prev_node; /* Previous point node in new space */
unsigned rank_diff; /* Difference in ranks between spaces */
+ unsigned u; /* Local index variable */
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_STATIC
/* Check args */
HDassert(base_space && H5S_SEL_POINTS == H5S_GET_SELECT_TYPE(base_space));
@@ -1481,24 +2140,20 @@ H5S_point_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *off
/* Calculate offset of selection in projected buffer */
HDmemset(block, 0, sizeof(block));
- HDmemcpy(block, base_space->select.sel_info.pnt_lst->head->pnt, sizeof(hsize_t) * rank_diff);
- *offset = H5VM_array_offset(base_space->extent.rank, base_space->extent.size, block);
+ H5MM_memcpy(block, base_space->select.sel_info.pnt_lst->head->pnt, sizeof(hsize_t) * rank_diff);
+ *offset = H5VM_array_offset(base_space->extent.rank, base_space->extent.size, block);
/* Iterate through base space's point nodes, copying the point information */
base_node = base_space->select.sel_info.pnt_lst->head;
prev_node = NULL;
while(base_node) {
/* Create new point */
- if(NULL == (new_node = H5FL_MALLOC(H5S_pnt_node_t)))
+ if(NULL == (new_node = (H5S_pnt_node_t *)H5FL_ARR_MALLOC(hcoords_t, new_space->extent.rank)))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate point node")
new_node->next = NULL;
- if(NULL == (new_node->pnt = (hsize_t *)H5MM_malloc(new_space->extent.rank * sizeof(hsize_t)))) {
- new_node = H5FL_FREE(H5S_pnt_node_t, new_node);
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate coordinate information")
- } /* end if */
/* Copy over the point's coordinates */
- HDmemcpy(new_node->pnt, &base_node->pnt[rank_diff], (new_space->extent.rank * sizeof(hsize_t)));
+ H5MM_memcpy(new_node->pnt, &base_node->pnt[rank_diff], (new_space->extent.rank * sizeof(hsize_t)));
/* Keep the order the same when copying */
if(NULL == prev_node)
@@ -1511,6 +2166,12 @@ H5S_point_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *off
/* Advance to next node */
base_node = base_node->next;
} /* end while */
+
+ /* Update the bounding box */
+ for(u = 0; u < new_space->extent.rank; u++) {
+ new_space->select.sel_info.pnt_lst->low_bounds[u] = base_space->select.sel_info.pnt_lst->low_bounds[u + rank_diff];
+ new_space->select.sel_info.pnt_lst->high_bounds[u] = base_space->select.sel_info.pnt_lst->high_bounds[u + rank_diff];
+ } /* end for */
} /* end if */
else {
HDassert(new_space->extent.rank > base_space->extent.rank);
@@ -1526,17 +2187,13 @@ H5S_point_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *off
prev_node = NULL;
while(base_node) {
/* Create new point */
- if(NULL == (new_node = H5FL_MALLOC(H5S_pnt_node_t)))
+ if(NULL == (new_node = (H5S_pnt_node_t *)H5FL_ARR_MALLOC(hcoords_t, new_space->extent.rank)))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate point node")
new_node->next = NULL;
- if(NULL == (new_node->pnt = (hsize_t *)H5MM_malloc(new_space->extent.rank * sizeof(hsize_t)))) {
- new_node = H5FL_FREE(H5S_pnt_node_t, new_node);
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate coordinate information")
- } /* end if */
/* Copy over the point's coordinates */
HDmemset(new_node->pnt, 0, sizeof(hsize_t) * rank_diff);
- HDmemcpy(&new_node->pnt[rank_diff], base_node->pnt, (new_space->extent.rank * sizeof(hsize_t)));
+ H5MM_memcpy(&new_node->pnt[rank_diff], base_node->pnt, (new_space->extent.rank * sizeof(hsize_t)));
/* Keep the order the same when copying */
if(NULL == prev_node)
@@ -1549,6 +2206,16 @@ H5S_point_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *off
/* Advance to next node */
base_node = base_node->next;
} /* end while */
+
+ /* Update the bounding box */
+ for(u = 0; u < rank_diff; u++) {
+ new_space->select.sel_info.pnt_lst->low_bounds[u] = 0;
+ new_space->select.sel_info.pnt_lst->high_bounds[u] = 0;
+ } /* end for */
+ for(; u < new_space->extent.rank; u++) {
+ new_space->select.sel_info.pnt_lst->low_bounds[u] = base_space->select.sel_info.pnt_lst->low_bounds[u - rank_diff];
+ new_space->select.sel_info.pnt_lst->high_bounds[u] = base_space->select.sel_info.pnt_lst->high_bounds[u - rank_diff];
+ } /* end for */
} /* end else */
/* Number of elements selected will be the same */
@@ -1559,7 +2226,7 @@ H5S_point_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *off
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_point_project_simple() */
+} /* end H5S__point_project_simple() */
/*--------------------------------------------------------------------------
@@ -1620,143 +2287,5 @@ H5Sselect_elements(hid_t spaceid, H5S_seloper_t op, size_t num_elem,
done:
FUNC_LEAVE_API(ret_value)
-} /* H5Sselect_elements() */
-
-
-/*--------------------------------------------------------------------------
- NAME
- H5S_point_get_seq_list
- PURPOSE
- Create a list of offsets & lengths for a selection
- USAGE
- herr_t H5S_point_get_seq_list(space,flags,iter,maxseq,maxelem,nseq,nelem,off,len)
- H5S_t *space; IN: Dataspace containing selection to use.
- unsigned flags; IN: Flags for extra information about operation
- H5S_sel_iter_t *iter; IN/OUT: Selection iterator describing last
- position of interest in selection.
- size_t maxseq; IN: Maximum number of sequences to generate
- size_t maxelem; IN: Maximum number of elements to include in the
- generated sequences
- size_t *nseq; OUT: Actual number of sequences generated
- size_t *nelem; OUT: Actual number of elements in sequences generated
- hsize_t *off; OUT: Array of offsets
- size_t *len; OUT: Array of lengths
- RETURNS
- Non-negative on success/Negative on failure.
- DESCRIPTION
- Use the selection in the dataspace to generate a list of byte offsets and
- lengths for the region(s) selected. Start/Restart from the position in the
- ITER parameter. The number of sequences generated is limited by the MAXSEQ
- parameter and the number of sequences actually generated is stored in the
- NSEQ parameter.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-static herr_t
-H5S_point_get_seq_list(const H5S_t *space, unsigned flags, H5S_sel_iter_t *iter,
- size_t maxseq, size_t maxelem, size_t *nseq, size_t *nelem,
- hsize_t *off, size_t *len)
-{
- size_t io_left; /* The number of bytes left in the selection */
- size_t start_io_left; /* The initial number of bytes left in the selection */
- H5S_pnt_node_t *node; /* Point node */
- hsize_t dims[H5O_LAYOUT_NDIMS]; /* Total size of memory buf */
- int ndims; /* Dimensionality of space*/
- hsize_t acc; /* Coordinate accumulator */
- hsize_t loc; /* Coordinate offset */
- size_t curr_seq; /* Current sequence being operated on */
- int i; /* Local index variable */
- herr_t ret_value=SUCCEED; /* return value */
-
- FUNC_ENTER_NOAPI_NOINIT
-
- /* Check args */
- HDassert(space);
- HDassert(iter);
- HDassert(maxseq > 0);
- HDassert(maxelem > 0);
- HDassert(nseq);
- HDassert(nelem);
- HDassert(off);
- HDassert(len);
-
- /* Choose the minimum number of bytes to sequence through */
- H5_CHECK_OVERFLOW(iter->elmt_left, hsize_t, size_t);
- start_io_left = io_left = (size_t)MIN(iter->elmt_left, maxelem);
-
- /* Get the dataspace dimensions */
- if((ndims = H5S_get_simple_extent_dims (space, dims, NULL)) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to retrieve dataspace dimensions")
-
- /* Walk through the points in the selection, starting at the current */
- /* location in the iterator */
- node = iter->u.pnt.curr;
- curr_seq = 0;
- while(NULL != node) {
- /* Compute the offset of each selected point in the buffer */
- for(i = ndims - 1, acc = iter->elmt_size, loc = 0; i >= 0; i--) {
- loc += (hsize_t)((hssize_t)node->pnt[i] + space->select.offset[i]) * acc;
- acc *= dims[i];
- } /* end for */
-
- /* Check if this is a later point in the selection */
- if(curr_seq>0) {
- /* If a sorted sequence is requested, make certain we don't go backwards in the offset */
- if((flags&H5S_GET_SEQ_LIST_SORTED) && loc<off[curr_seq-1])
- break;
-
- /* Check if this point extends the previous sequence */
- /* (Unlikely, but possible) */
- if(loc==(off[curr_seq-1]+len[curr_seq-1])) {
- /* Extend the previous sequence */
- len[curr_seq-1]+=iter->elmt_size;
- } /* end if */
- else {
- /* Add a new sequence */
- off[curr_seq]=loc;
- len[curr_seq]=iter->elmt_size;
-
- /* Increment sequence count */
- curr_seq++;
- } /* end else */
- } /* end if */
- else {
- /* Add a new sequence */
- off[curr_seq]=loc;
- len[curr_seq]=iter->elmt_size;
-
- /* Increment sequence count */
- curr_seq++;
- } /* end else */
-
- /* Decrement number of elements left to process */
- io_left--;
-
- /* Move the iterator */
- iter->u.pnt.curr=node->next;
- iter->elmt_left--;
-
- /* Check if we're finished with all sequences */
- if(curr_seq==maxseq)
- break;
-
- /* Check if we're finished with all the elements available */
- if(io_left==0)
- break;
-
- /* Advance to the next point */
- node=node->next;
- } /* end while */
-
- /* Set the number of sequences generated */
- *nseq=curr_seq;
-
- /* Set the number of elements used */
- *nelem=start_io_left-io_left;
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5S_point_get_seq_list() */
+} /* end H5Sselect_elements() */
diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h
index 32ac51a..6646f84 100644
--- a/src/H5Sprivate.h
+++ b/src/H5Sprivate.h
@@ -17,9 +17,6 @@
#ifndef _H5Sprivate_H
#define _H5Sprivate_H
-/* Early typedefs to avoid circular dependencies */
-typedef struct H5S_t H5S_t;
-
/* Include package's public header */
#include "H5Spublic.h"
@@ -30,7 +27,6 @@ typedef struct H5S_t H5S_t;
#include "H5private.h" /* Generic Functions */
#include "H5Fprivate.h" /* Files */
#include "H5Gprivate.h" /* Groups */
-#include "H5Oprivate.h" /* Object headers */
#include "H5Pprivate.h" /* Property lists */
#include "H5Tprivate.h" /* Datatypes */
@@ -43,12 +39,10 @@ typedef struct H5S_t H5S_t;
#define H5S_CONV_STORAGE_CHUNKED 0x0004 /* i.e. '2' */
#define H5S_CONV_STORAGE_MASK 0x0006
-/* Flags for "get_seq_list" methods */
-#define H5S_GET_SEQ_LIST_SORTED 0x0001
-
/* Forward references of package typedefs */
typedef struct H5S_extent_t H5S_extent_t;
typedef struct H5S_pnt_node_t H5S_pnt_node_t;
+typedef struct H5S_pnt_list_t H5S_pnt_list_t;
typedef struct H5S_hyper_span_t H5S_hyper_span_t;
typedef struct H5S_hyper_span_info_t H5S_hyper_span_info_t;
@@ -62,20 +56,22 @@ typedef struct H5S_hyper_dim_t {
/* Point selection iteration container */
typedef struct {
- H5S_pnt_node_t *curr; /* Pointer to next node to output */
+ H5S_pnt_list_t *pnt_lst; /* Pointer to point list */
+ H5S_pnt_node_t *curr; /* Pointer to next node to output */
} H5S_point_iter_t;
/* Hyperslab selection iteration container */
typedef struct {
/* Common fields for all hyperslab selections */
- hsize_t off[H5S_MAX_RANK]; /* Offset in span node (used as position for regular hyperslabs) */
+ hsize_t off[H5S_MAX_RANK]; /* Offset in span node (used as position for regular hyperslabs) */
+ hsize_t slab[H5S_MAX_RANK]; /* Cumulative size of each dimension in bytes */
unsigned iter_rank; /* Rank of iterator information */
/* (This should always be the same as the dataspace
- * rank, except for regular hyperslab selections in
- * which there are contiguous regions in the lower
- * dimensions which have been "flattened" out
+ * rank, except for regular hyperslab selections in
+ * which there are contiguous regions in the lower
+ * dimensions that have been "flattened")
*/
- hbool_t diminfo_valid; /* Whether the dimension information is valid */
+ hbool_t diminfo_valid; /* Whether the dimension information is valid */
/* "Flattened" regular hyperslab selection fields */
H5S_hyper_dim_t diminfo[H5S_MAX_RANK]; /* "Flattened" regular selection information */
@@ -84,6 +80,7 @@ typedef struct {
hbool_t flattened[H5S_MAX_RANK]; /* Whether this dimension has been flattened */
/* Irregular hyperslab selection fields */
+ hsize_t loc_off[H5S_MAX_RANK]; /* Byte offset in buffer, for each dimension's current offset */
H5S_hyper_span_info_t *spans; /* Pointer to copy of the span tree */
H5S_hyper_span_t *span[H5S_MAX_RANK];/* Array of pointers to span nodes */
} H5S_hyper_iter_t;
@@ -104,9 +101,11 @@ typedef struct H5S_sel_iter_t {
/* Information common to all iterators */
unsigned rank; /* Rank of dataspace the selection iterator is operating on */
- hsize_t *dims; /* Dimensions of dataspace the selection is operating on */
+ hsize_t dims[H5S_MAX_RANK]; /* Dimensions of dataspace the selection is operating on */
+ hssize_t sel_off[H5S_MAX_RANK]; /* Selection offset in dataspace */
hsize_t elmt_left; /* Number of elements left to iterate over */
size_t elmt_size; /* Size of elements to iterate over */
+ unsigned flags; /* Flags controlling iterator behavior */
/* Information specific to each type of iterator */
union {
@@ -146,7 +145,6 @@ typedef struct H5S_sel_iter_op_t {
#define H5S_GET_EXTENT_NPOINTS(S) ((S)->extent.nelem)
#define H5S_GET_SELECT_NPOINTS(S) ((S)->select.num_elem)
#define H5S_GET_SELECT_TYPE(S) ((S)->select.type->type)
-#define H5S_SELECT_GET_SEQ_LIST(S,FLAGS,ITER,MAXSEQ,MAXBYTES,NSEQ,NBYTES,OFF,LEN) ((*(S)->select.type->get_seq_list)(S,FLAGS,ITER,MAXSEQ,MAXBYTES,NSEQ,NBYTES,OFF,LEN))
#define H5S_SELECT_VALID(S) ((*(S)->select.type->is_valid)(S))
#define H5S_SELECT_SERIAL_SIZE(S) ((*(S)->select.type->serial_size)(S))
#define H5S_SELECT_SERIALIZE(S,BUF) ((*(S)->select.type->serialize)(S,BUF))
@@ -164,6 +162,7 @@ typedef struct H5S_sel_iter_op_t {
#define H5S_SELECT_ITER_HAS_NEXT_BLOCK(ITER) ((*(ITER)->type->iter_has_next_block)(ITER))
#define H5S_SELECT_ITER_NEXT(ITER,NELEM)((*(ITER)->type->iter_next)(ITER,NELEM))
#define H5S_SELECT_ITER_NEXT_BLOCK(ITER) ((*(ITER)->type->iter_next_block)(ITER))
+#define H5S_SELECT_ITER_GET_SEQ_LIST(ITER,MAXSEQ,MAXBYTES,NSEQ,NBYTES,OFF,LEN) ((*(ITER)->type->iter_get_seq_list)(ITER,MAXSEQ,MAXBYTES,NSEQ,NBYTES,OFF,LEN))
#define H5S_SELECT_ITER_RELEASE(ITER) ((*(ITER)->type->iter_release)(ITER))
#else /* H5S_MODULE */
#define H5S_GET_EXTENT_TYPE(S) (H5S_get_simple_extent_type(S))
@@ -171,7 +170,6 @@ typedef struct H5S_sel_iter_op_t {
#define H5S_GET_EXTENT_NPOINTS(S) (H5S_get_simple_extent_npoints(S))
#define H5S_GET_SELECT_NPOINTS(S) (H5S_get_select_npoints(S))
#define H5S_GET_SELECT_TYPE(S) (H5S_get_select_type(S))
-#define H5S_SELECT_GET_SEQ_LIST(S,FLAGS,ITER,MAXSEQ,MAXBYTES,NSEQ,NBYTES,OFF,LEN) (H5S_select_get_seq_list(S,FLAGS,ITER,MAXSEQ,MAXBYTES,NSEQ,NBYTES,OFF,LEN))
#define H5S_SELECT_VALID(S) (H5S_select_valid(S))
#define H5S_SELECT_SERIAL_SIZE(S) (H5S_select_serial_size(S))
#define H5S_SELECT_SERIALIZE(S,BUF) (H5S_select_serialize(S,BUF))
@@ -189,6 +187,7 @@ typedef struct H5S_sel_iter_op_t {
#define H5S_SELECT_ITER_HAS_NEXT_BLOCK(ITER) (H5S_select_iter_has_next_block(ITER))
#define H5S_SELECT_ITER_NEXT(ITER,NELEM)(H5S_select_iter_next(ITER,NELEM))
#define H5S_SELECT_ITER_NEXT_BLOCK(ITER) (H5S_select_iter_next_block(ITER))
+#define H5S_SELECT_ITER_GET_SEQ_LIST(ITER,MAXSEQ,MAXBYTES,NSEQ,NBYTES,OFF,LEN) (H5S_select_iter_get_seq_list(ITER,MAXSEQ,MAXBYTES,NSEQ,NBYTES,OFF,LEN))
#define H5S_SELECT_ITER_RELEASE(ITER) (H5S_select_iter_release(ITER))
#endif /* H5S_MODULE */
/* Handle these callbacks in a special way, since they have prologs that need to be executed */
@@ -196,6 +195,12 @@ typedef struct H5S_sel_iter_op_t {
#define H5S_SELECT_RELEASE(S) (H5S_select_release(S))
#define H5S_SELECT_DESERIALIZE(S,BUF) (H5S_select_deserialize(S,BUF))
+/* Forward declaration of structs used below */
+struct H5O_t;
+struct H5O_loc_t;
+
+/* Early typedef to avoid circular dependencies */
+typedef struct H5S_t H5S_t;
/* Operations on dataspaces */
H5_DLL H5S_t *H5S_copy(const H5S_t *src, hbool_t share_selection, hbool_t copy_max);
@@ -207,7 +212,7 @@ H5_DLL hbool_t H5S_has_extent(const H5S_t *ds);
H5_DLL int H5S_get_simple_extent_ndims(const H5S_t *ds);
H5_DLL int H5S_get_simple_extent_dims(const H5S_t *ds, hsize_t dims[]/*out*/,
hsize_t max_dims[]/*out*/);
-H5_DLL herr_t H5S_write(H5F_t *f, H5O_t *oh, unsigned update_flags, H5S_t *ds);
+H5_DLL herr_t H5S_write(H5F_t *f, struct H5O_t *oh, unsigned update_flags, H5S_t *ds);
H5_DLL herr_t H5S_append(H5F_t *f, struct H5O_t *oh, H5S_t *ds);
H5_DLL H5S_t *H5S_read(const struct H5O_loc_t *loc);
H5_DLL htri_t H5S_set_extent(H5S_t *space, const hsize_t *size);
@@ -251,9 +256,6 @@ H5_DLL herr_t H5S_select_construct_projection(const H5S_t *base_space,
H5S_t **new_space_ptr, unsigned new_space_rank, const void *buf,
void const **adj_buf_ptr, hsize_t element_size);
H5_DLL herr_t H5S_select_release(H5S_t *ds);
-H5_DLL herr_t H5S_select_get_seq_list(const H5S_t *space, unsigned flags,
- H5S_sel_iter_t *iter, size_t maxseq, size_t maxbytes,
- size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len);
H5_DLL hssize_t H5S_select_serial_size(const H5S_t *space);
H5_DLL herr_t H5S_select_serialize(const H5S_t *space, uint8_t **p);
H5_DLL htri_t H5S_select_is_contiguous(const H5S_t *space);
@@ -280,13 +282,11 @@ H5_DLL herr_t H5S_select_elements(H5S_t *space, H5S_seloper_t op,
/* Operations on hyperslab selections */
H5_DLL herr_t H5S_select_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[],
const hsize_t *stride, const hsize_t count[], const hsize_t *block);
+H5_DLL herr_t H5S_combine_hyperslab(H5S_t *old_space, H5S_seloper_t op,
+ const hsize_t start[], const hsize_t *stride, const hsize_t count[],
+ const hsize_t *block, H5S_t **new_space);
H5_DLL herr_t H5S_hyper_add_span_element(H5S_t *space, unsigned rank,
const hsize_t *coords);
-H5_DLL herr_t H5S_hyper_reset_scratch(H5S_t *space);
-H5_DLL herr_t H5S_hyper_convert(H5S_t *space);
-#ifdef LATER
-H5_DLL htri_t H5S_hyper_intersect (H5S_t *space1, H5S_t *space2);
-#endif /* LATER */
H5_DLL htri_t H5S_hyper_intersect_block(H5S_t *space, const hsize_t *start, const hsize_t *end);
H5_DLL herr_t H5S_hyper_adjust_s(H5S_t *space, const hssize_t *offset);
H5_DLL htri_t H5S_hyper_normalize_offset(H5S_t *space, hssize_t *old_offset);
@@ -302,11 +302,15 @@ H5_DLL hsize_t H5S_hyper_get_first_inc_block(const H5S_t *space,
hsize_t clip_size, hbool_t *partial);
/* Operations on selection iterators */
-H5_DLL herr_t H5S_select_iter_init(H5S_sel_iter_t *iter, const H5S_t *space, size_t elmt_size);
+H5_DLL herr_t H5S_select_iter_init(H5S_sel_iter_t *iter, const H5S_t *space,
+ size_t elmt_size, unsigned flags);
H5_DLL herr_t H5S_select_iter_coords(const H5S_sel_iter_t *sel_iter, hsize_t *coords);
H5_DLL hsize_t H5S_select_iter_nelmts(const H5S_sel_iter_t *sel_iter);
H5_DLL herr_t H5S_select_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem);
+H5_DLL herr_t H5S_select_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq,
+ size_t maxbytes, size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len);
H5_DLL herr_t H5S_select_iter_release(H5S_sel_iter_t *sel_iter);
+H5_DLL herr_t H5S_sel_iter_close(H5S_sel_iter_t *sel_iter);
#ifdef H5_HAVE_PARALLEL
H5_DLL hsize_t H5S_mpio_set_bigio_count(hsize_t new_count);
@@ -314,7 +318,7 @@ H5_DLL herr_t H5S_mpio_space_type(const H5S_t *space, size_t elmt_size,
/* out: */ MPI_Datatype *new_type,
int *count,
hbool_t *is_derived_type,
- hbool_t do_permute,
+ hbool_t do_permute,
hsize_t **permute_map,
hbool_t * is_permuted);
#endif /* H5_HAVE_PARALLEL */
diff --git a/src/H5Spublic.h b/src/H5Spublic.h
index d7a5d29..23e6846 100644
--- a/src/H5Spublic.h
+++ b/src/H5Spublic.h
@@ -28,6 +28,35 @@
/* Define user-level maximum number of dimensions */
#define H5S_MAX_RANK 32
+/* Flags for selection iterators */
+#define H5S_SEL_ITER_GET_SEQ_LIST_SORTED 0x0001 /* Retrieve elements from iterator
+ * in increasing offset order, for
+ * each call to retrieve sequences.
+ * Currently, this only applies to
+ * point selections, as hyperslab
+ * selections are always returned
+ * in increasing offset order.
+ *
+ * Note that the order is only
+ * increasing for each call to
+ * get_seq_list, the next set of
+ * sequences could start with an
+ * earlier offset than the previous
+ * one.
+ */
+#define H5S_SEL_ITER_SHARE_WITH_DATASPACE 0x0002 /* Don't copy the dataspace
+ * selection when creating the
+ * selection iterator.
+ *
+ * This can improve performance
+ * of creating the iterator, but
+ * the dataspace _MUST_NOT_ be
+ * modified or closed until the
+ * selection iterator is closed
+ * or the iterator's behavior
+ * will be undefined.
+ */
+
/* Different types of dataspaces */
typedef enum H5S_class_t {
H5S_NO_CLASS = -1, /*error */
@@ -79,75 +108,81 @@ typedef enum H5S_seloper_t {
typedef enum {
H5S_SEL_ERROR = -1, /* Error */
H5S_SEL_NONE = 0, /* Nothing selected */
- H5S_SEL_POINTS = 1, /* Sequence of points selected */
- H5S_SEL_HYPERSLABS = 2, /* "New-style" hyperslab selection defined */
+ H5S_SEL_POINTS = 1, /* Points / elements selected */
+ H5S_SEL_HYPERSLABS = 2, /* Hyperslab selected */
H5S_SEL_ALL = 3, /* Entire extent selected */
H5S_SEL_N /*THIS MUST BE LAST */
-}H5S_sel_type;
+} H5S_sel_type;
#ifdef __cplusplus
extern "C" {
#endif
-/* Functions in H5S.c */
+/* Operations on dataspaces */
H5_DLL hid_t H5Screate(H5S_class_t type);
H5_DLL hid_t H5Screate_simple(int rank, const hsize_t dims[],
- const hsize_t maxdims[]);
+ const hsize_t maxdims[]);
H5_DLL herr_t H5Sset_extent_simple(hid_t space_id, int rank,
- const hsize_t dims[],
- const hsize_t max[]);
+ const hsize_t dims[], const hsize_t max[]);
H5_DLL hid_t H5Scopy(hid_t space_id);
H5_DLL herr_t H5Sclose(hid_t space_id);
-H5_DLL herr_t H5Sencode(hid_t obj_id, void *buf, size_t *nalloc);
+H5_DLL herr_t H5Sencode2(hid_t obj_id, void *buf, size_t *nalloc, hid_t fapl);
H5_DLL hid_t H5Sdecode(const void *buf);
H5_DLL hssize_t H5Sget_simple_extent_npoints(hid_t space_id);
H5_DLL int H5Sget_simple_extent_ndims(hid_t space_id);
H5_DLL int H5Sget_simple_extent_dims(hid_t space_id, hsize_t dims[],
- hsize_t maxdims[]);
+ hsize_t maxdims[]);
H5_DLL htri_t H5Sis_simple(hid_t space_id);
-H5_DLL hssize_t H5Sget_select_npoints(hid_t spaceid);
-H5_DLL herr_t H5Sselect_hyperslab(hid_t space_id, H5S_seloper_t op,
- const hsize_t start[],
- const hsize_t _stride[],
- const hsize_t count[],
- const hsize_t _block[]);
-/* #define NEW_HYPERSLAB_API */
-/* Note that these haven't been working for a while and were never
- * publicly released - QAK */
-#ifdef NEW_HYPERSLAB_API
-H5_DLL hid_t H5Scombine_hyperslab(hid_t space_id, H5S_seloper_t op,
- const hsize_t start[],
- const hsize_t _stride[],
- const hsize_t count[],
- const hsize_t _block[]);
-H5_DLL herr_t H5Sselect_select(hid_t space1_id, H5S_seloper_t op,
- hid_t space2_id);
-H5_DLL hid_t H5Scombine_select(hid_t space1_id, H5S_seloper_t op,
- hid_t space2_id);
-#endif /* NEW_HYPERSLAB_API */
-H5_DLL herr_t H5Sselect_elements(hid_t space_id, H5S_seloper_t op,
- size_t num_elem, const hsize_t *coord);
H5_DLL H5S_class_t H5Sget_simple_extent_type(hid_t space_id);
H5_DLL herr_t H5Sset_extent_none(hid_t space_id);
H5_DLL herr_t H5Sextent_copy(hid_t dst_id,hid_t src_id);
H5_DLL htri_t H5Sextent_equal(hid_t sid1, hid_t sid2);
+
+/* Operations on dataspace selections */
+H5_DLL H5S_sel_type H5Sget_select_type(hid_t spaceid);
+H5_DLL hssize_t H5Sget_select_npoints(hid_t spaceid);
H5_DLL herr_t H5Sselect_copy(hid_t dst_id, hid_t src_id);
+H5_DLL htri_t H5Sselect_valid(hid_t spaceid);
+H5_DLL herr_t H5Sget_select_bounds(hid_t spaceid, hsize_t start[],
+ hsize_t end[]);
+H5_DLL herr_t H5Soffset_simple(hid_t space_id, const hssize_t *offset);
H5_DLL herr_t H5Sselect_all(hid_t spaceid);
H5_DLL herr_t H5Sselect_none(hid_t spaceid);
-H5_DLL herr_t H5Soffset_simple(hid_t space_id, const hssize_t *offset);
-H5_DLL htri_t H5Sselect_valid(hid_t spaceid);
+H5_DLL herr_t H5Sselect_elements(hid_t space_id, H5S_seloper_t op,
+ size_t num_elem, const hsize_t *coord);
+H5_DLL hssize_t H5Sget_select_elem_npoints(hid_t spaceid);
+H5_DLL herr_t H5Sget_select_elem_pointlist(hid_t spaceid, hsize_t startpoint,
+ hsize_t numpoints, hsize_t buf[/*numpoints*/]);
+H5_DLL herr_t H5Sselect_hyperslab(hid_t space_id, H5S_seloper_t op,
+ const hsize_t start[], const hsize_t _stride[], const hsize_t count[],
+ const hsize_t _block[]);
+H5_DLL hid_t H5Scombine_hyperslab(hid_t space_id, H5S_seloper_t op,
+ const hsize_t start[], const hsize_t _stride[], const hsize_t count[],
+ const hsize_t _block[]);
+H5_DLL herr_t H5Smodify_select(hid_t space1_id, H5S_seloper_t op, hid_t space2_id);
+H5_DLL hid_t H5Scombine_select(hid_t space1_id, H5S_seloper_t op, hid_t space2_id);
H5_DLL htri_t H5Sis_regular_hyperslab(hid_t spaceid);
H5_DLL htri_t H5Sget_regular_hyperslab(hid_t spaceid, hsize_t start[],
hsize_t stride[], hsize_t count[], hsize_t block[]);
H5_DLL hssize_t H5Sget_select_hyper_nblocks(hid_t spaceid);
-H5_DLL hssize_t H5Sget_select_elem_npoints(hid_t spaceid);
H5_DLL herr_t H5Sget_select_hyper_blocklist(hid_t spaceid, hsize_t startblock,
hsize_t numblocks, hsize_t buf[/*numblocks*/]);
-H5_DLL herr_t H5Sget_select_elem_pointlist(hid_t spaceid, hsize_t startpoint,
- hsize_t numpoints, hsize_t buf[/*numpoints*/]);
-H5_DLL herr_t H5Sget_select_bounds(hid_t spaceid, hsize_t start[],
- hsize_t end[]);
-H5_DLL H5S_sel_type H5Sget_select_type(hid_t spaceid);
+
+/* Operations on dataspace selection iterators */
+H5_DLL hid_t H5Ssel_iter_create(hid_t spaceid, size_t elmt_size, unsigned flags);
+H5_DLL herr_t H5Ssel_iter_get_seq_list(hid_t sel_iter_id, size_t maxseq,
+ size_t maxbytes, size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len);
+H5_DLL herr_t H5Ssel_iter_close(hid_t sel_iter_id);
+
+/* Symbols defined for compatibility with previous versions of the HDF5 API.
+ *
+ * Use of these symbols is deprecated.
+ */
+#ifndef H5_NO_DEPRECATED_SYMBOLS
+/* Function prototypes */
+H5_DLL herr_t H5Sencode1(hid_t obj_id, void *buf, size_t *nalloc);
+
+#endif /* H5_NO_DEPRECATED_SYMBOLS */
#ifdef __cplusplus
}
diff --git a/src/H5Sselect.c b/src/H5Sselect.c
index 6e6ca76..fdd897c 100644
--- a/src/H5Sselect.c
+++ b/src/H5Sselect.c
@@ -17,26 +17,59 @@
* Purpose: Dataspace selection functions.
*/
+/****************/
+/* Module Setup */
+/****************/
+
#include "H5Smodule.h" /* This source code file is part of the H5S module */
+/***********/
+/* Headers */
+/***********/
#include "H5private.h" /* Generic Functions */
#include "H5Dprivate.h" /* Datasets */
#include "H5Eprivate.h" /* Error handling */
#include "H5FLprivate.h" /* Free Lists */
#include "H5Iprivate.h" /* IDs */
-#include "H5MMprivate.h" /* Memory management */
#include "H5Spkg.h" /* Dataspaces */
-#include "H5VMprivate.h" /* Vector and array functions */
-#include "H5WBprivate.h" /* Wrapped Buffers */
+#include "H5VMprivate.h" /* Vector and array functions */
+
+
+/****************/
+/* Local Macros */
+/****************/
+
+/* All the valid public flags to H5Ssel_iter_create() */
+#define H5S_SEL_ITER_ALL_PUBLIC_FLAGS (H5S_SEL_ITER_GET_SEQ_LIST_SORTED | \
+ H5S_SEL_ITER_SHARE_WITH_DATASPACE)
+
+
+/******************/
+/* Local Typedefs */
+/******************/
+
+
+/********************/
+/* Local Prototypes */
+/********************/
-/* Local functions */
#ifdef LATER
static herr_t H5S_select_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end);
static htri_t H5S_select_iter_has_next_block(const H5S_sel_iter_t *iter);
static herr_t H5S_select_iter_next_block(H5S_sel_iter_t *iter);
#endif /* LATER */
+
+/*****************************/
+/* Library Private Variables */
+/*****************************/
+
+
+/*********************/
+/* Package Variables */
+/*********************/
+
/* Declare a free list to manage the H5S_sel_iter_t struct */
H5FL_DEFINE(H5S_sel_iter_t);
@@ -47,6 +80,11 @@ H5FL_SEQ_EXTERN(size_t);
H5FL_SEQ_EXTERN(hsize_t);
+/*******************/
+/* Local Variables */
+/*******************/
+
+
/*--------------------------------------------------------------------------
NAME
@@ -78,13 +116,56 @@ H5S_select_offset(H5S_t *space, const hssize_t *offset)
HDassert(offset);
/* Copy the offset over */
- HDmemcpy(space->select.offset, offset, sizeof(hssize_t)*space->extent.rank);
+ H5MM_memcpy(space->select.offset, offset, sizeof(hssize_t) * space->extent.rank);
/* Indicate that the offset was changed */
space->select.offset_changed = TRUE;
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5S_select_offset() */
+} /* end H5S_select_offset() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5Soffset_simple
+ PURPOSE
+ Changes the offset of a selection within a simple dataspace extent
+ USAGE
+ herr_t H5Soffset_simple(space_id, offset)
+ hid_t space_id; IN: Dataspace object to reset
+ const hssize_t *offset; IN: Offset to position the selection at
+ RETURNS
+ Non-negative on success/Negative on failure
+ DESCRIPTION
+ This function creates an offset for the selection within an extent, allowing
+ the same shaped selection to be moved to different locations within a
+ dataspace without requiring it to be re-defined.
+--------------------------------------------------------------------------*/
+herr_t
+H5Soffset_simple(hid_t space_id, const hssize_t *offset)
+{
+ H5S_t *space; /* Dataspace to query */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE2("e", "i*Hs", space_id, offset);
+
+ /* Check args */
+ if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a dataspace")
+ if(space->extent.rank == 0 || (H5S_GET_EXTENT_TYPE(space) == H5S_SCALAR
+ || H5S_GET_EXTENT_TYPE(space) == H5S_NULL))
+ HGOTO_ERROR(H5E_ATOM, H5E_UNSUPPORTED, FAIL, "can't set offset on scalar or null dataspace")
+ if(offset == NULL)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no offset specified")
+
+ /* Set the selection offset */
+ if(H5S_select_offset(space, offset) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't set offset")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Soffset_simple() */
/*--------------------------------------------------------------------------
@@ -139,9 +220,10 @@ done:
PURPOSE
Copy a selection from one dataspace to another
USAGE
- herr_t H5S_select_copy(dst, src)
+ herr_t H5S_select_copy(dst, src, share_selection)
H5S_t *dst; OUT: Pointer to the destination dataspace
H5S_t *src; IN: Pointer to the source dataspace
+ hbool_t; IN: Whether to share the selection between the dataspaces
RETURNS
Non-negative on success/Negative on failure
DESCRIPTION
@@ -177,7 +259,7 @@ H5S_select_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection)
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_select_copy() */
+} /* end H5S_select_copy() */
/*-------------------------------------------------------------------------
@@ -211,44 +293,7 @@ H5S_select_release(H5S_t *ds)
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5S_select_release() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5S_select_get_seq_list
- *
- * Purpose: Retrieves the next sequence of offset/length pairs for an
- * iterator on a dataspace
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Quincey Koziol
- * Tuesday, May 18, 2004
- *
- * Note: This routine participates in the "Inlining C function pointers"
- * pattern, don't call it directly, use the appropriate macro
- * defined in H5Sprivate.h.
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5S_select_get_seq_list(const H5S_t *space, unsigned flags,
- H5S_sel_iter_t *iter, size_t maxseq, size_t maxbytes,
- size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len)
-{
- herr_t ret_value = FAIL; /* Return value */
-
- FUNC_ENTER_NOAPI_NOINIT
-
- HDassert(space);
-
- /* Call the selection type's get_seq_list function */
- if((ret_value = (*space->select.type->get_seq_list)(space, flags, iter, maxseq, maxbytes, nseq, nbytes, off, len)) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get selection sequence list")
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5S_select_get_seq_list() */
+} /* end H5S_select_release() */
/*-------------------------------------------------------------------------
@@ -278,10 +323,10 @@ H5S_select_serial_size(const H5S_t *space)
HDassert(space);
/* Call the selection type's serial_size function */
- ret_value=(*space->select.type->serial_size)(space);
+ ret_value = (*space->select.type->serial_size)(space);
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5S_select_serial_size() */
+} /* end H5S_select_serial_size() */
/*--------------------------------------------------------------------------
@@ -311,7 +356,7 @@ H5S_select_serial_size(const H5S_t *space)
herr_t
H5S_select_serialize(const H5S_t *space, uint8_t **p)
{
- herr_t ret_value=SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT_NOERR
@@ -319,10 +364,10 @@ H5S_select_serialize(const H5S_t *space, uint8_t **p)
HDassert(p);
/* Call the selection type's serialize function */
- ret_value=(*space->select.type->serialize)(space,p);
+ ret_value = (*space->select.type->serialize)(space, p);
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5S_select_serialize() */
+} /* end H5S_select_serialize() */
/*--------------------------------------------------------------------------
@@ -359,7 +404,7 @@ H5Sget_select_npoints(hid_t spaceid)
done:
FUNC_LEAVE_API(ret_value)
-} /* H5Sget_select_npoints() */
+} /* H5Sget_select_npoints() */
/*--------------------------------------------------------------------------
@@ -382,7 +427,7 @@ done:
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-hssize_t
+H5_ATTR_PURE hssize_t
H5S_get_select_npoints(const H5S_t *space)
{
FUNC_ENTER_NOAPI_NOINIT_NOERR
@@ -391,7 +436,7 @@ H5S_get_select_npoints(const H5S_t *space)
HDassert(space);
FUNC_LEAVE_NOAPI((hssize_t)space->select.num_elem)
-} /* H5S_get_select_npoints() */
+} /* end H5S_get_select_npoints() */
/*--------------------------------------------------------------------------
@@ -413,8 +458,6 @@ H5S_get_select_npoints(const H5S_t *space)
COMMENTS, BUGS, ASSUMPTIONS
EXAMPLES
REVISION LOG
- Christian Chilan 01/17/2007
- Changed the error return value from 0 to FAIL.
--------------------------------------------------------------------------*/
htri_t
H5Sselect_valid(hid_t spaceid)
@@ -433,7 +476,7 @@ H5Sselect_valid(hid_t spaceid)
done:
FUNC_LEAVE_API(ret_value)
-} /* H5Sselect_valid() */
+} /* end H5Sselect_valid() */
/*--------------------------------------------------------------------------
@@ -471,7 +514,7 @@ H5S_select_valid(const H5S_t *space)
ret_value = (*space->select.type->is_valid)(space);
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_select_valid() */
+} /* end H5S_select_valid() */
/*--------------------------------------------------------------------------
@@ -503,103 +546,46 @@ H5S_select_valid(const H5S_t *space)
herr_t
H5S_select_deserialize(H5S_t **space, const uint8_t **p)
{
- H5S_t *tmp_space = NULL; /* Pointer to actual dataspace to use, either
- *space or a newly allocated one */
uint32_t sel_type; /* Pointer to the selection type */
- uint32_t version; /* Version number */
- uint8_t flags = 0; /* Flags */
herr_t ret_value = FAIL; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
HDassert(space);
- /* Allocate space if not provided */
- if(!*space) {
- if(NULL == (tmp_space = H5S_create(H5S_SIMPLE)))
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create dataspace")
- } /* end if */
- else
- tmp_space = *space;
+ /* Selection-type specific coding is moved to the callbacks. */
/* Decode selection type */
UINT32DECODE(*p, sel_type);
- /* Decode version */
- UINT32DECODE(*p, version);
-
- if(version >= (uint32_t)2) {
- /* Decode flags */
- flags = *(*p)++;
-
- /* Check for unknown flags */
- if(flags & ~H5S_SELECT_FLAG_BITS)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTLOAD, FAIL, "unknown flag for selection")
-
- /* Skip over the remainder of the header */
- *p += 4;
- } /* end if */
- else
- /* Skip over the remainder of the header */
- *p += 8;
-
- /* Decode and check or patch rank for point and hyperslab selections */
- if((sel_type == H5S_SEL_POINTS) || (sel_type == H5S_SEL_HYPERSLABS)) {
- uint32_t rank; /* Rank of dataspace */
-
- /* Decode the rank of the point selection */
- UINT32DECODE(*p,rank);
-
- if(!*space) {
- hsize_t dims[H5S_MAX_RANK];
-
- /* Patch the rank of the allocated dataspace */
- (void)HDmemset(dims, 0, (size_t)rank * sizeof(dims[0]));
- if(H5S_set_extent_simple(tmp_space, rank, dims, NULL) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't set dimensions")
- } /* end if */
- else
- /* Verify the rank of the provided dataspace */
- if(rank != tmp_space->extent.rank)
- HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "rank of serialized selection does not match dataspace")
- } /* end if */
-
/* Make routine for selection type */
switch(sel_type) {
case H5S_SEL_POINTS: /* Sequence of points selected */
- ret_value = (*H5S_sel_point->deserialize)(tmp_space, version, flags, p);
+ ret_value = (*H5S_sel_point->deserialize)(space, p);
break;
case H5S_SEL_HYPERSLABS: /* Hyperslab selection defined */
- ret_value = (*H5S_sel_hyper->deserialize)(tmp_space, version, flags, p);
+ ret_value = (*H5S_sel_hyper->deserialize)(space, p);
break;
case H5S_SEL_ALL: /* Entire extent selected */
- ret_value = (*H5S_sel_all->deserialize)(tmp_space, version, flags, p);
+ ret_value = (*H5S_sel_all->deserialize)(space, p);
break;
case H5S_SEL_NONE: /* Nothing selected */
- ret_value = (*H5S_sel_none->deserialize)(tmp_space, version, flags, p);
+ ret_value = (*H5S_sel_none->deserialize)(space, p);
break;
default:
break;
- }
+ } /* end switch */
+
if(ret_value < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTLOAD, FAIL, "can't deserialize selection")
- /* Return space to the caller if allocated */
- if(!*space)
- *space = tmp_space;
-
done:
- /* Free temporary space if not passed to caller (only happens on error) */
- if(!*space && tmp_space)
- if(H5S_close(tmp_space) < 0)
- HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "can't close dataspace")
-
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_select_deserialize() */
+} /* end H5S_select_deserialize() */
/*--------------------------------------------------------------------------
@@ -651,7 +637,7 @@ H5Sget_select_bounds(hid_t spaceid, hsize_t start[], hsize_t end[])
done:
FUNC_LEAVE_API(ret_value)
-} /* H5Sget_select_bounds() */
+} /* end H5Sget_select_bounds() */
/*--------------------------------------------------------------------------
@@ -693,10 +679,10 @@ H5S_get_select_bounds(const H5S_t *space, hsize_t *start, hsize_t *end)
HDassert(start);
HDassert(end);
- ret_value = (*space->select.type->bounds)(space,start,end);
+ ret_value = (*space->select.type->bounds)(space, start, end);
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_get_select_bounds() */
+} /* end H5S_get_select_bounds() */
/*--------------------------------------------------------------------------
@@ -736,7 +722,7 @@ H5S_get_select_offset(const H5S_t *space, hsize_t *offset)
ret_value = (*space->select.type->offset)(space, offset);
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_get_select_offset() */
+} /* end H5S_get_select_offset() */
/*--------------------------------------------------------------------------
@@ -774,7 +760,7 @@ H5S_get_select_unlim_dim(const H5S_t *space)
ret_value = (*space->select.type->unlim_dim)(space);
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_get_select_unlim_dim() */
+} /* end H5S_get_select_unlim_dim() */
/*--------------------------------------------------------------------------
@@ -819,7 +805,7 @@ H5S_get_select_num_elem_non_unlim(const H5S_t *space,
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_get_select_unlim_dim() */
+} /* end H5S_get_select_unlim_dim() */
/*--------------------------------------------------------------------------
@@ -856,7 +842,7 @@ H5S_select_is_contiguous(const H5S_t *space)
ret_value = (*space->select.type->is_contiguous)(space);
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_select_is_contiguous() */
+} /* end H5S_select_is_contiguous() */
/*--------------------------------------------------------------------------
@@ -893,7 +879,7 @@ H5S_select_is_single(const H5S_t *space)
ret_value = (*space->select.type->is_single)(space);
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_select_is_single() */
+} /* end H5S_select_is_single() */
/*--------------------------------------------------------------------------
@@ -930,7 +916,7 @@ H5S_select_is_regular(const H5S_t *space)
ret_value = (*space->select.type->is_regular)(space);
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_select_is_regular() */
+} /* end H5S_select_is_regular() */
/*--------------------------------------------------------------------------
@@ -957,7 +943,9 @@ H5S_select_is_regular(const H5S_t *space)
herr_t
H5S_select_adjust_u(H5S_t *space, const hsize_t *offset)
{
- herr_t ret_value = FAIL; /* Return value */
+ hbool_t non_zero_offset = FALSE; /* Whether any offset is non-zero */
+ unsigned u; /* Local index variable */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT_NOERR
@@ -965,10 +953,19 @@ H5S_select_adjust_u(H5S_t *space, const hsize_t *offset)
HDassert(space);
HDassert(offset);
- ret_value = (*space->select.type->adjust_u)(space, offset);
+ /* Check for an all-zero offset vector */
+ for(u = 0; u < space->extent.rank; u++)
+ if(0 != offset[u]) {
+ non_zero_offset = TRUE;
+ break;
+ } /* end if */
+
+ /* Only perform operation if the offset is non-zero */
+ if(non_zero_offset)
+ ret_value = (*space->select.type->adjust_u)(space, offset);
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_select_adjust_u() */
+} /* end H5S_select_adjust_u() */
/*--------------------------------------------------------------------------
@@ -1007,7 +1004,7 @@ H5S_select_project_scalar(const H5S_t *space, hsize_t *offset)
ret_value = (*space->select.type->project_scalar)(space, offset);
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_select_project_scalar() */
+} /* end H5S_select_project_scalar() */
/*--------------------------------------------------------------------------
@@ -1048,7 +1045,7 @@ H5S_select_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset)
ret_value = (*space->select.type->project_simple)(space, new_space, offset);
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_select_project_simple() */
+} /* end H5S_select_project_simple() */
/*--------------------------------------------------------------------------
@@ -1057,11 +1054,12 @@ H5S_select_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset)
PURPOSE
Initializes iteration information for a selection.
USAGE
- herr_t H5S_select_iter_init(sel_iter, space, elmt_size)
+ herr_t H5S_select_iter_init(sel_iter, space, elmt_size, flags)
H5S_sel_iter_t *sel_iter; OUT: Selection iterator to initialize.
H5S_t *space; IN: Dataspace object containing selection to
iterate over
size_t elmt_size; IN: Size of elements in the selection
+ unsigned flags; IN: Flags to control iteration behavior
RETURNS
Non-negative on success, negative on failure.
DESCRIPTION
@@ -1069,7 +1067,8 @@ H5S_select_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset)
in the dataspace's selection.
--------------------------------------------------------------------------*/
herr_t
-H5S_select_iter_init(H5S_sel_iter_t *sel_iter, const H5S_t *space, size_t elmt_size)
+H5S_select_iter_init(H5S_sel_iter_t *sel_iter, const H5S_t *space,
+ size_t elmt_size, unsigned flags)
{
herr_t ret_value = FAIL; /* Return value */
@@ -1084,21 +1083,27 @@ H5S_select_iter_init(H5S_sel_iter_t *sel_iter, const H5S_t *space, size_t elmt_s
/* Save the dataspace's rank */
sel_iter->rank = space->extent.rank;
- /* Point to the dataspace dimensions, if there are any */
- if(sel_iter->rank > 0)
- sel_iter->dims = space->extent.size;
- else
- sel_iter->dims = NULL;
+ /* If dims > 0, copy the dataspace dimensions & selection offset */
+ if(sel_iter->rank > 0) {
+ H5MM_memcpy(sel_iter->dims, space->extent.size, sizeof(hsize_t) * space->extent.rank);
+ H5MM_memcpy(sel_iter->sel_off, space->select.offset, sizeof(hsize_t) * space->extent.rank);
+ } /* end if */
/* Save the element size */
sel_iter->elmt_size = elmt_size;
+ /* Initialize the number of elements to iterate over */
+ sel_iter->elmt_left = space->select.num_elem;
+
+ /* Set the flags for the iterator */
+ sel_iter->flags = flags;
+
/* Call initialization routine for selection type */
- ret_value = (*space->select.type->iter_init)(sel_iter, space);
+ ret_value = (*space->select.type->iter_init)(space, sel_iter);
HDassert(sel_iter->type);
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_select_iter_init() */
+} /* end H5S_select_iter_init() */
/*--------------------------------------------------------------------------
@@ -1135,10 +1140,10 @@ H5S_select_iter_coords(const H5S_sel_iter_t *sel_iter, hsize_t *coords)
HDassert(coords);
/* Call iter_coords routine for selection type */
- ret_value = (*sel_iter->type->iter_coords)(sel_iter,coords);
+ ret_value = (*sel_iter->type->iter_coords)(sel_iter, coords);
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_select_iter_coords() */
+} /* end H5S_select_iter_coords() */
#ifdef LATER
@@ -1170,7 +1175,7 @@ H5S_select_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end)
{
herr_t ret_value; /* return value */
- FUNC_ENTER_NOAPI_NOINIT_NOINIT_NOERR
+ FUNC_ENTER_NOAPI_NOINIT_NOERR
/* Check args */
HDassert(iter);
@@ -1178,10 +1183,10 @@ H5S_select_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end)
HDassert(end);
/* Call iter_block routine for selection type */
- ret_value = (*iter->type->iter_block)(iter,start,end);
+ ret_value = (*iter->type->iter_block)(iter, start, end);
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_select_iter_block() */
+} /* end H5S_select_iter_block() */
#endif /* LATER */
@@ -1219,7 +1224,7 @@ H5S_select_iter_nelmts(const H5S_sel_iter_t *sel_iter)
ret_value = (*sel_iter->type->iter_nelmts)(sel_iter);
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_select_iter_nelmts() */
+} /* end H5S_select_iter_nelmts() */
#ifdef LATER
@@ -1249,7 +1254,7 @@ H5S_select_iter_has_next_block(const H5S_sel_iter_t *iter)
{
herr_t ret_value; /* return value */
- FUNC_ENTER_NOAPI_NOINIT_NOINIT_NOERR
+ FUNC_ENTER_NOAPI_NOINIT_NOERR
/* Check args */
HDassert(iter);
@@ -1258,7 +1263,7 @@ H5S_select_iter_has_next_block(const H5S_sel_iter_t *iter)
ret_value = (*iter->type->iter_has_next_block)(iter);
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_select_iter_has_next_block() */
+} /* end H5S_select_iter_has_next_block() */
#endif /* LATER */
@@ -1296,13 +1301,13 @@ H5S_select_iter_next(H5S_sel_iter_t *iter, size_t nelem)
HDassert(nelem>0);
/* Call iter_next routine for selection type */
- ret_value = (*iter->type->iter_next)(iter,nelem);
+ ret_value = (*iter->type->iter_next)(iter, nelem);
/* Decrement the number of elements left in selection */
iter->elmt_left-=nelem;
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_select_iter_next() */
+} /* end H5S_select_iter_next() */
#ifdef LATER
@@ -1343,17 +1348,54 @@ H5S_select_iter_next_block(H5S_sel_iter_t *iter)
ret_value = (*iter->type->iter_next_block)(iter);
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_select_iter_next_block() */
+} /* end H5S_select_iter_next_block() */
#endif /* LATER */
+/*-------------------------------------------------------------------------
+ * Function: H5S_select_iter_get_seq_list
+ *
+ * Purpose: Retrieves the next sequence of offset/length pairs for an
+ * iterator on a dataspace
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, May 18, 2004
+ *
+ * Note: This routine participates in the "Inlining C function pointers"
+ * pattern, don't call it directly, use the appropriate macro
+ * defined in H5Sprivate.h.
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5S_select_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelmts,
+ size_t *nseq, size_t *nelmts, hsize_t *off, size_t *len)
+{
+ herr_t ret_value = FAIL; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ /* Sanity check */
+ HDassert(iter);
+
+ /* Call the selection type's get_seq_list function */
+ if((ret_value = (*iter->type->iter_get_seq_list)(iter, maxseq, maxelmts, nseq, nelmts, off, len)) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get selection sequence list")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5S_select_iter_get_seq_list() */
+
+
/*--------------------------------------------------------------------------
NAME
H5S_select_iter_release
PURPOSE
Release a selection iterator's resources.
USAGE
- hssize_t H5S_select_iter_release(sel_iter)
+ herr_t H5S_select_iter_release(sel_iter)
H5S_sel_iter_t *sel_iter; IN: Selection iterator to query
RETURNS
The number of elements in selection on success, 0 on failure
@@ -1381,7 +1423,7 @@ H5S_select_iter_release(H5S_sel_iter_t *sel_iter)
ret_value = (*sel_iter->type->iter_release)(sel_iter);
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_select_iter_release() */
+} /* end H5S_select_iter_release() */
/*--------------------------------------------------------------------------
@@ -1421,7 +1463,7 @@ H5S_select_iterate(void *buf, const H5T_t *type, const H5S_t *space,
hsize_t *off = NULL; /* Array to store sequence offsets */
size_t *len = NULL; /* Array to store sequence lengths */
hssize_t nelmts; /* Number of elements in selection */
- hsize_t space_size[H5O_LAYOUT_NDIMS]; /* Dataspace size */
+ hsize_t space_size[H5S_MAX_RANK]; /* Dataspace size */
size_t max_elem; /* Maximum number of elements allowed in sequences */
size_t elmt_size; /* Datatype size */
unsigned ndims; /* Number of dimensions in dataspace */
@@ -1445,7 +1487,7 @@ H5S_select_iterate(void *buf, const H5T_t *type, const H5S_t *space,
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate selection iterator")
/* Initialize iterator */
- if(H5S_select_iter_init(iter, space, elmt_size) < 0)
+ if(H5S_select_iter_init(iter, space, elmt_size, 0) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator")
iter_init = TRUE; /* Selection iteration info has been initialized */
@@ -1459,7 +1501,7 @@ H5S_select_iterate(void *buf, const H5T_t *type, const H5S_t *space,
if(ndims > 0) {
/* Copy the size of the space */
HDassert(space->extent.size);
- HDmemcpy(space_size, space->extent.size, ndims * sizeof(hsize_t));
+ H5MM_memcpy(space_size, space->extent.size, ndims * sizeof(hsize_t));
} /* end if */
space_size[ndims] = elmt_size;
@@ -1479,7 +1521,7 @@ H5S_select_iterate(void *buf, const H5T_t *type, const H5S_t *space,
size_t curr_seq; /* Current sequence being worked on */
/* Get the sequences of bytes */
- if(H5S_SELECT_GET_SEQ_LIST(space, 0, iter, (size_t)H5D_IO_VECTOR_SIZE, max_elem, &nseq, &nelem, off, len) < 0)
+ if(H5S_SELECT_ITER_GET_SEQ_LIST(iter, (size_t)H5D_IO_VECTOR_SIZE, max_elem, &nseq, &nelem, off, len) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed")
/* Loop, while sequences left to process */
@@ -1495,7 +1537,7 @@ H5S_select_iterate(void *buf, const H5T_t *type, const H5S_t *space,
/* Loop, while bytes left in sequence */
while(curr_len > 0 && user_ret == 0) {
- hsize_t coords[H5O_LAYOUT_NDIMS]; /* Coordinates of element in dataspace */
+ hsize_t coords[H5S_MAX_RANK]; /* Coordinates of element in dataspace */
hsize_t tmp_off; /* Temporary offset within sequence */
uint8_t *loc; /* Current element location in buffer */
int i; /* Local Index variable */
@@ -1558,7 +1600,7 @@ done:
iter = H5FL_FREE(H5S_sel_iter_t, iter);
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5S_select_iterate() */
+} /* end H5S_select_iterate() */
/*--------------------------------------------------------------------------
@@ -1594,7 +1636,7 @@ H5Sget_select_type(hid_t space_id)
done:
FUNC_LEAVE_API(ret_value)
-} /* end H5Sget_select_type() */
+} /* end H5Sget_select_type() */
/*--------------------------------------------------------------------------
@@ -1616,7 +1658,7 @@ done:
pattern, don't call it directly, use the appropriate macro
defined in H5Sprivate.h.
--------------------------------------------------------------------------*/
-H5S_sel_type
+H5_ATTR_PURE H5S_sel_type
H5S_get_select_type(const H5S_t *space)
{
H5S_sel_type ret_value = H5S_SEL_ERROR; /* Return value */
@@ -1627,10 +1669,10 @@ H5S_get_select_type(const H5S_t *space)
HDassert(space);
/* Set return value */
- ret_value=H5S_GET_SELECT_TYPE(space);
+ ret_value = H5S_GET_SELECT_TYPE(space);
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5S_get_select_type() */
+} /* end H5S_get_select_type() */
/*--------------------------------------------------------------------------
@@ -1650,20 +1692,17 @@ H5S_get_select_type(const H5S_t *space)
This is primarily used for reading the entire selection in one swoop.
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
- Assumes that there is only a single "block" for hyperslab selections.
EXAMPLES
REVISION LOG
- Modified function to view identical shapes with different dimensions
- as being the same under some circumstances.
--------------------------------------------------------------------------*/
htri_t
H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2)
{
H5S_sel_iter_t *iter_a = NULL; /* Selection a iteration info */
H5S_sel_iter_t *iter_b = NULL; /* Selection b iteration info */
- hbool_t iter_a_init = FALSE; /* Selection a iteration info has been initialized */
- hbool_t iter_b_init = FALSE; /* Selection b iteration info has been initialized */
- htri_t ret_value = TRUE; /* Return value */
+ hbool_t iter_a_init = FALSE; /* Selection a iteration info has been initialized */
+ hbool_t iter_b_init = FALSE; /* Selection b iteration info has been initialized */
+ htri_t ret_value = TRUE; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -1684,124 +1723,98 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2)
const H5S_t *space_b; /* Dataspace with smaller rank */
unsigned space_a_rank; /* Number of dimensions of dataspace A */
unsigned space_b_rank; /* Number of dimensions of dataspace B */
+ int space_a_dim; /* Current dimension in dataspace A */
+ int space_b_dim; /* Current dimension in dataspace B */
+ H5S_sel_type sel_a_type; /* Selection type for dataspace A */
+ H5S_sel_type sel_b_type; /* Selection type for dataspace B */
- /* need to be able to handle spaces of different rank:
+ /* Need to be able to handle spaces of different rank:
*
* To simplify logic, let space_a point to the element of the set
- * {space1, space2} with the largest rank or space1 if the ranks
+ * {space1, space2} with the largest rank or space1 if the ranks
* are identical.
*
* Similarly, let space_b point to the element of {space1, space2}
* with the smallest rank, or space2 if they are identical.
*
- * Let: space_a_rank be the rank of space_a,
+ * Let: space_a_rank be the rank of space_a,
* space_b_rank be the rank of space_b,
- * delta_rank = space_a_rank - space_b_rank.
*
- * Set all this up below.
+ * Set all this up here.
*/
if(space1->extent.rank >= space2->extent.rank) {
space_a = space1;
- space_a_rank = space_a->extent.rank;
-
space_b = space2;
- space_b_rank = space_b->extent.rank;
} /* end if */
else {
space_a = space2;
- space_a_rank = space_a->extent.rank;
-
space_b = space1;
- space_b_rank = space_b->extent.rank;
} /* end else */
+ space_a_rank = space_a->extent.rank;
+ space_b_rank = space_b->extent.rank;
HDassert(space_a_rank >= space_b_rank);
HDassert(space_b_rank > 0);
- /* Check for "easy" cases before getting into generalized block iteration code */
- if((H5S_GET_SELECT_TYPE(space_a) == H5S_SEL_ALL) && (H5S_GET_SELECT_TYPE(space_b) == H5S_SEL_ALL)) {
- hsize_t dims1[H5O_LAYOUT_NDIMS]; /* End point of selection block in dataspace #1 */
- hsize_t dims2[H5O_LAYOUT_NDIMS]; /* End point of selection block in dataspace #2 */
- int space_a_dim; /* Current dimension in dataspace A */
- int space_b_dim; /* Current dimension in dataspace B */
+ /* Get selection type for both dataspaces */
+ sel_a_type = H5S_GET_SELECT_TYPE(space_a);
+ sel_b_type = H5S_GET_SELECT_TYPE(space_b);
- if(H5S_get_simple_extent_dims(space_a, dims1, NULL) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get dimensionality")
- if(H5S_get_simple_extent_dims(space_b, dims2, NULL) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get dimensionality")
+ /* If selections aren't "none", compare their bounds */
+ if(sel_a_type != H5S_SEL_NONE && sel_b_type != H5S_SEL_NONE) {
+ hsize_t low_a[H5S_MAX_RANK]; /* Low bound of selection in dataspace a */
+ hsize_t low_b[H5S_MAX_RANK]; /* Low bound of selection in dataspace b */
+ hsize_t high_a[H5S_MAX_RANK]; /* High bound of selection in dataspace a */
+ hsize_t high_b[H5S_MAX_RANK]; /* High bound of selection in dataspace b */
- space_a_dim = (int)space_a_rank - 1;
- space_b_dim = (int)space_b_rank - 1;
-
- /* recall that space_a_rank >= space_b_rank.
- *
- * In the following while loop, we test to see if space_a and space_b
- * have identical size in all dimensions they have in common.
- */
- while(space_b_dim >= 0) {
- if(dims1[space_a_dim] != dims2[space_b_dim])
- HGOTO_DONE(FALSE)
-
- space_a_dim--;
- space_b_dim--;
- } /* end while */
-
- /* Since we are selecting the entire space, we must also verify that space_a
- * has size 1 in all dimensions that it does not share with space_b.
- */
- while(space_a_dim >= 0) {
- if(dims1[space_a_dim] != 1)
- HGOTO_DONE(FALSE)
-
- space_a_dim--;
- } /* end while */
- } /* end if */
- else if((H5S_GET_SELECT_TYPE(space1) == H5S_SEL_NONE) || (H5S_GET_SELECT_TYPE(space2) == H5S_SEL_NONE)) {
- /* (Both must be, at this point, if one is) */
- HGOTO_DONE(TRUE)
- } /* end if */
- else if((H5S_GET_SELECT_TYPE(space_a) == H5S_SEL_HYPERSLABS && space_a->select.sel_info.hslab->diminfo_valid)
- && (H5S_GET_SELECT_TYPE(space_b) == H5S_SEL_HYPERSLABS && space_b->select.sel_info.hslab->diminfo_valid)) {
- int space_a_dim; /* Current dimension in dataspace A */
- int space_b_dim; /* Current dimension in dataspace B */
+ /* Get low & high bounds for both dataspaces */
+ if(H5S_SELECT_BOUNDS(space_a, low_a, high_a) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get selection bounds for first dataspace")
+ if(H5S_SELECT_BOUNDS(space_b, low_b, high_b) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get selection bounds for second dataspace")
+ /* Check that the range between the low & high bounds are the same */
space_a_dim = (int)space_a_rank - 1;
space_b_dim = (int)space_b_rank - 1;
-
- /* check that the shapes are the same in the common dimensions, and that
- * block == 1 in all dimensions that appear only in space_a.
- */
while(space_b_dim >= 0) {
- if(space_a->select.sel_info.hslab->opt_diminfo[space_a_dim].stride !=
- space_b->select.sel_info.hslab->opt_diminfo[space_b_dim].stride)
- HGOTO_DONE(FALSE)
+ /* Sanity check */
+ HDassert(low_a[space_a_dim] <= high_a[space_a_dim]);
+ HDassert(low_a[space_b_dim] <= high_a[space_b_dim]);
- if(space_a->select.sel_info.hslab->opt_diminfo[space_a_dim].count !=
- space_b->select.sel_info.hslab->opt_diminfo[space_b_dim].count)
- HGOTO_DONE(FALSE)
-
- if(space_a->select.sel_info.hslab->opt_diminfo[space_a_dim].block !=
- space_b->select.sel_info.hslab->opt_diminfo[space_b_dim].block)
+ /* Verify that the ranges are the same */
+ if((high_a[space_a_dim] - low_a[space_a_dim])
+ != (high_b[space_b_dim] - low_b[space_b_dim]))
HGOTO_DONE(FALSE)
+ /* Go to next dimension */
space_a_dim--;
space_b_dim--;
} /* end while */
+ /* Check that the rest of the ranges in space a are "flat" */
while(space_a_dim >= 0) {
- if(space_a->select.sel_info.hslab->opt_diminfo[space_a_dim].block != 1)
+ /* Sanity check */
+ HDassert(low_a[space_a_dim] <= high_a[space_a_dim]);
+
+ /* This range should be flat to be the same in a lower dimension */
+ if(low_a[space_a_dim] != high_a[space_a_dim])
HGOTO_DONE(FALSE)
space_a_dim--;
} /* end while */
} /* end if */
- /* Iterate through all the blocks in the selection */
+
+ /* If the dataspaces have the same selection type, use the selection's
+ * shape_same operator.
+ */
+ if(sel_a_type == sel_b_type)
+ ret_value = (*space_a->select.type->shape_same)(space_a, space_b);
+ /* Otherwise, iterate through all the blocks in the selection */
else {
hsize_t start_a[H5S_MAX_RANK]; /* Start point of selection block in dataspace a */
hsize_t start_b[H5S_MAX_RANK]; /* Start point of selection block in dataspace b */
hsize_t end_a[H5S_MAX_RANK]; /* End point of selection block in dataspace a */
hsize_t end_b[H5S_MAX_RANK]; /* End point of selection block in dataspace b */
- hsize_t off_a[H5S_MAX_RANK]; /* Offset of selection a blocks */
- hsize_t off_b[H5S_MAX_RANK]; /* Offset of selection b blocks */
+ hssize_t offset[H5S_MAX_RANK]; /* Offset of selection b blocks relative to selection a blocks */
hbool_t first_block = TRUE; /* Flag to indicate the first block */
/* Allocate the selection iterators */
@@ -1815,17 +1828,15 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2)
* that the selection iterator shouldn't be "flattened", since we
* aren't actually going to be doing I/O with the iterators.
*/
- if(H5S_select_iter_init(iter_a, space_a, (size_t)0) < 0)
+ if(H5S_select_iter_init(iter_a, space_a, (size_t)0, 0) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator a")
iter_a_init = TRUE;
- if(H5S_select_iter_init(iter_b, space_b, (size_t)0) < 0)
+ if(H5S_select_iter_init(iter_b, space_b, (size_t)0, 0) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator b")
iter_b_init = TRUE;
/* Iterate over all the blocks in each selection */
while(1) {
- int space_a_dim; /* Current dimension in dataspace A */
- int space_b_dim; /* Current dimension in dataspace B */
htri_t status_a, status_b; /* Status from next block checks */
/* Get the current block for each selection iterator */
@@ -1837,11 +1848,11 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2)
space_a_dim = (int)space_a_rank - 1;
space_b_dim = (int)space_b_rank - 1;
- /* The first block only compares the sizes and sets the
- * relative offsets for later blocks
+ /* The first block only compares the sizes and sets the
+ * relative offsets for later blocks
*/
if(first_block) {
- /* If the block sizes in the common dimensions from
+ /* If the block sizes in the common dimensions from
* each selection don't match, get out
*/
while(space_b_dim >= 0) {
@@ -1850,23 +1861,19 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2)
HGOTO_DONE(FALSE)
/* Set the relative locations of the selections */
- off_a[space_a_dim] = start_a[space_a_dim];
- off_b[space_b_dim] = start_b[space_b_dim];
+ offset[space_a_dim] = (hssize_t)start_b[space_b_dim] - (hssize_t)start_a[space_a_dim];
space_a_dim--;
space_b_dim--;
} /* end while */
- /* similarly, if the block size in any dimension that appears only
+ /* Similarly, if the block size in any dimension that appears only
* in space_a is not equal to 1, get out.
*/
while(space_a_dim >= 0) {
- if((end_a[space_a_dim] - start_a[space_a_dim]) != 0)
+ if(start_a[space_a_dim] != end_a[space_a_dim])
HGOTO_DONE(FALSE)
- /* Set the relative locations of the selections */
- off_a[space_a_dim] = start_a[space_a_dim];
-
space_a_dim--;
} /* end while */
@@ -1875,11 +1882,10 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2)
} /* end if */
/* Check over the blocks for each selection */
else {
- /* for dimensions that space_a and space_b have in common: */
+ /* For dimensions that space_a and space_b have in common: */
while(space_b_dim >= 0) {
/* Check if the blocks are in the same relative location */
- if((start_a[space_a_dim] - off_a[space_a_dim]) !=
- (start_b[space_b_dim] - off_b[space_b_dim]))
+ if((hsize_t)((hssize_t)start_a[space_a_dim] + offset[space_a_dim]) != start_b[space_b_dim])
HGOTO_DONE(FALSE)
/* If the block sizes from each selection doesn't match, get out */
@@ -1894,7 +1900,7 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2)
/* For dimensions that appear only in space_a: */
while(space_a_dim >= 0) {
/* If the block size isn't 1, get out */
- if((end_a[space_a_dim] - start_a[space_a_dim]) != 0)
+ if(start_a[space_a_dim] != end_a[space_a_dim])
HGOTO_DONE(FALSE)
space_a_dim--;
@@ -1936,7 +1942,7 @@ done:
iter_b = H5FL_FREE(H5S_sel_iter_t, iter_b);
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_select_shape_same() */
+} /* end H5S_select_shape_same() */
/*--------------------------------------------------------------------------
@@ -1945,24 +1951,24 @@ done:
PURPOSE
Given a dataspace a of rank n with some selection, construct a new
- dataspace b of rank m (m != n), with the selection in a being
- topologically identical to that in b (as verified by
+ dataspace b of rank m (m != n), with the selection in a being
+ topologically identical to that in b (as verified by
H5S_select_shape_same().
- This function exists, as some I/O code chokes on topologically
- identical selections with different ranks. At least to begin
+ This function exists, as some I/O code chokes on topologically
+ identical selections with different ranks. At least to begin
with, we will deal with the issue by constructing projections
- of the memory dataspace with ranks equaling those of the file
+ of the memory dataspace with ranks equaling those of the file
dataspace.
- Note that if m > n, it is possible that the starting point in the
- buffer associated with the memory dataspace will have to be
+ Note that if m > n, it is possible that the starting point in the
+ buffer associated with the memory dataspace will have to be
adjusted to match the projected dataspace. If the buf parameter
is not NULL, the function must return an adjusted buffer base
address in *adj_buf_ptr.
USAGE
- htri_t H5S_select_construct_projection(base_space,
+ htri_t H5S_select_construct_projection(base_space,
new_space_ptr,
new_space_rank,
buf,
@@ -1971,30 +1977,30 @@ done:
H5S_t ** new_space_ptr; OUT: Ptr to location in which to return
the address of the projected space
int new_space_rank; IN: Rank of the projected space.
- const void * buf; IN: Base address of the buffer
+ const void * buf; IN: Base address of the buffer
associated with the base space.
May be NULL.
void ** adj_buf_ptr; OUT: If buf != NULL, store the base
- address of the section of buf
+ address of the section of buf
that is described by *new_space_ptr
in *adj_buf_ptr.
-
+
RETURNS
Non-negative on success/Negative on failure.
DESCRIPTION
- Construct a new dataspace and associated selection which is a
- projection of the supplied dataspace and associated selection into
+ Construct a new dataspace and associated selection which is a
+ projection of the supplied dataspace and associated selection into
the specified rank. Return it in *new_space_ptr.
- If buf is supplied, computes the base address of the projected
+ If buf is supplied, computes the base address of the projected
selection in buf, and stores the base address in *adj_buf_ptr.
-
+
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
- The selection in the supplied base_space has thickness 1 in all
+ The selection in the supplied base_space has thickness 1 in all
dimensions greater than new_space_rank. Note that here we count
- dimensions from the fastest changing coordinate to the slowest
+ dimensions from the fastest changing coordinate to the slowest
changing changing coordinate.
EXAMPLES
REVISION LOG
@@ -2040,28 +2046,28 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr,
/* Create new scalar dataspace */
if(NULL == (new_space = H5S_create(H5S_SCALAR)))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "unable to create scalar dataspace")
-
+
/* No need to register the dataspace(i.e. get an ID) as
* we will just be discarding it shortly.
*/
- /* Selection for the new space will be either all or
+ /* Selection for the new space will be either all or
* none, depending on whether the base space has 0 or
* 1 elements selected.
*
- * Observe that the base space can't have more than
+ * Observe that the base space can't have more than
* one selected element, since its selection has the
- * same shape as the file dataspace, and that data
+ * same shape as the file dataspace, and that data
* space is scalar.
*/
if(1 == npoints) {
/* Assuming that the selection in the base dataspace is not
- * empty, we must compute the offset of the selected item in
+ * empty, we must compute the offset of the selected item in
* the buffer associated with the base dataspace.
*
- * Since the new space rank is zero, we know that the
- * the base space must have rank at least 1 -- and
- * hence it is a simple dataspace. However, the
+ * Since the new space rank is zero, we know that the
+ * the base space must have rank at least 1 -- and
+ * hence it is a simple dataspace. However, the
* selection, may be either point, hyperspace, or all.
*
*/
@@ -2079,25 +2085,25 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr,
hsize_t new_space_dims[H5S_MAX_RANK]; /* Current dimensions for new dataspace */
hsize_t new_space_maxdims[H5S_MAX_RANK];/* Maximum dimensions for new dataspace */
unsigned rank_diff; /* Difference in ranks */
-
+
/* Set up the dimensions of the new, projected dataspace.
*
- * How we do this depends on whether we are projecting up into
- * increased dimensions, or down into a reduced number of
+ * How we do this depends on whether we are projecting up into
+ * increased dimensions, or down into a reduced number of
* dimensions.
*
- * If we are projecting up (the first half of the following
- * if statement), we copy the dimensions of the base data
- * space into the fastest changing dimensions of the new
+ * If we are projecting up (the first half of the following
+ * if statement), we copy the dimensions of the base data
+ * space into the fastest changing dimensions of the new
* projected dataspace, and set the remaining dimensions to
* one.
*
* If we are projecting down (the second half of the following
- * if statement), we just copy the dimensions with the most
+ * if statement), we just copy the dimensions with the most
* quickly changing dimensions into the dims for the projected
* data set.
*
- * This works, because H5S_select_shape_same() will return
+ * This works, because H5S_select_shape_same() will return
* true on selections of different rank iff:
*
* 1) the selection in the lower rank dataspace matches that
@@ -2105,37 +2111,37 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr,
* the larger rank dataspace, and
*
* 2) the selection has thickness 1 in all ranks that appear
- * only in the higher rank dataspace (i.e. those with
+ * only in the higher rank dataspace (i.e. those with
* more slowly changing indicies).
- */
+ */
if(new_space_rank > base_space_rank) {
hsize_t tmp_dim_size = 1; /* Temporary dimension value, for filling arrays */
- /* we must copy the dimensions of the base space into
+ /* we must copy the dimensions of the base space into
* the fastest changing dimensions of the new space,
* and set the remaining dimensions to 1
*/
rank_diff = new_space_rank - base_space_rank;
H5VM_array_fill(new_space_dims, &tmp_dim_size, sizeof(tmp_dim_size), rank_diff);
H5VM_array_fill(new_space_maxdims, &tmp_dim_size, sizeof(tmp_dim_size), rank_diff);
- HDmemcpy(&new_space_dims[rank_diff], base_space_dims, sizeof(new_space_dims[0]) * base_space_rank);
- HDmemcpy(&new_space_maxdims[rank_diff], base_space_maxdims, sizeof(new_space_maxdims[0]) * base_space_rank);
+ H5MM_memcpy(&new_space_dims[rank_diff], base_space_dims, sizeof(new_space_dims[0]) * base_space_rank);
+ H5MM_memcpy(&new_space_maxdims[rank_diff], base_space_maxdims, sizeof(new_space_maxdims[0]) * base_space_rank);
} /* end if */
else { /* new_space_rank < base_space_rank */
- /* we must copy the fastest changing dimension of the
+ /* we must copy the fastest changing dimension of the
* base space into the dimensions of the new space.
*/
rank_diff = base_space_rank - new_space_rank;
- HDmemcpy(new_space_dims, &base_space_dims[rank_diff], sizeof(new_space_dims[0]) * new_space_rank);
- HDmemcpy(new_space_maxdims, &base_space_maxdims[rank_diff], sizeof(new_space_maxdims[0]) * new_space_rank);
+ H5MM_memcpy(new_space_dims, &base_space_dims[rank_diff], sizeof(new_space_dims[0]) * new_space_rank);
+ H5MM_memcpy(new_space_maxdims, &base_space_maxdims[rank_diff], sizeof(new_space_maxdims[0]) * new_space_rank);
} /* end else */
- /* now have the new space rank and dimensions set up --
+ /* now have the new space rank and dimensions set up --
* so we can create the new simple dataspace.
*/
if(NULL == (new_space = H5S_create_simple(new_space_rank, new_space_dims, new_space_maxdims)))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create simple dataspace")
-
+
/* No need to register the dataspace(i.e. get an ID) as
* we will just be discarding it shortly.
*/
@@ -2146,22 +2152,22 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr,
*/
if(H5S_SELECT_PROJECT_SIMPLE(base_space, new_space, &projected_space_element_offset) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "unable to project simple selection")
-
+
/* If we get this far, we have created the new dataspace, and projected
* the selection in the base dataspace into the new dataspace.
*
- * If the base dataspace is simple, check to see if the
- * offset_changed flag on the base selection has been set -- if so,
- * project the offset into the new dataspace and set the
+ * If the base dataspace is simple, check to see if the
+ * offset_changed flag on the base selection has been set -- if so,
+ * project the offset into the new dataspace and set the
* offset_changed flag.
*/
if(H5S_GET_EXTENT_TYPE(base_space) == H5S_SIMPLE && base_space->select.offset_changed) {
if(new_space_rank > base_space_rank) {
HDmemset(new_space->select.offset, 0, sizeof(new_space->select.offset[0]) * rank_diff);
- HDmemcpy(&new_space->select.offset[rank_diff], base_space->select.offset, sizeof(new_space->select.offset[0]) * base_space_rank);
+ H5MM_memcpy(&new_space->select.offset[rank_diff], base_space->select.offset, sizeof(new_space->select.offset[0]) * base_space_rank);
} /* end if */
else
- HDmemcpy(new_space->select.offset, &base_space->select.offset[rank_diff], sizeof(new_space->select.offset[0]) * new_space_rank);
+ H5MM_memcpy(new_space->select.offset, &base_space->select.offset[rank_diff], sizeof(new_space->select.offset[0]) * new_space_rank);
/* Propagate the offset changed flag into the new dataspace. */
new_space->select.offset_changed = TRUE;
@@ -2184,12 +2190,12 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr,
* Since we can't do pointer arithmetic on void pointers, we first
* cast buf to a pointer to byte -- i.e. uint8_t.
*
- * We then multiply the projected space element offset we
- * calculated earlier by the supplied element size, add this
- * value to the type cast buf pointer, cast the result back
+ * We then multiply the projected space element offset we
+ * calculated earlier by the supplied element size, add this
+ * value to the type cast buf pointer, cast the result back
* to a pointer to void, and assign the result to *adj_buf_ptr.
*/
- *adj_buf_ptr = (const void *)(((const uint8_t *)buf) +
+ *adj_buf_ptr = (const void *)(((const uint8_t *)buf) +
((size_t)(projected_space_element_offset * element_size)));
} /* end if */
else
@@ -2204,7 +2210,7 @@ done:
HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace")
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_select_construct_projection() */
+} /* end H5S_select_construct_projection() */
/*--------------------------------------------------------------------------
@@ -2235,7 +2241,7 @@ herr_t
H5S_select_fill(const void *fill, size_t fill_size, const H5S_t *space, void *_buf)
{
H5S_sel_iter_t *iter = NULL; /* Selection iteration info */
- hbool_t iter_init = 0; /* Selection iteration info has been initialized */
+ hbool_t iter_init = FALSE; /* Selection iteration info has been initialized */
hsize_t *off = NULL; /* Array to store sequence offsets */
size_t *len = NULL; /* Array to store sequence lengths */
hssize_t nelmts; /* Number of elements in selection */
@@ -2255,9 +2261,9 @@ H5S_select_fill(const void *fill, size_t fill_size, const H5S_t *space, void *_b
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate selection iterator")
/* Initialize iterator */
- if(H5S_select_iter_init(iter, space, fill_size) < 0)
+ if(H5S_select_iter_init(iter, space, fill_size, 0) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator")
- iter_init = 1; /* Selection iteration info has been initialized */
+ iter_init = TRUE; /* Selection iteration info has been initialized */
/* Get the number of elements in selection */
if((nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS(space)) < 0)
@@ -2279,7 +2285,7 @@ H5S_select_fill(const void *fill, size_t fill_size, const H5S_t *space, void *_b
size_t nelem; /* Number of elements used in sequences */
/* Get the sequences of bytes */
- if(H5S_SELECT_GET_SEQ_LIST(space, 0, iter, (size_t)H5D_IO_VECTOR_SIZE, max_elem, &nseq, &nelem, off, len) < 0)
+ if(H5S_SELECT_ITER_GET_SEQ_LIST(iter, (size_t)H5D_IO_VECTOR_SIZE, max_elem, &nseq, &nelem, off, len) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed")
/* Loop over sequences */
@@ -2312,7 +2318,7 @@ done:
iter = H5FL_FREE(H5S_sel_iter_t, iter);
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_select_fill() */
+} /* end H5S_select_fill() */
/*--------------------------------------------------------------------------
@@ -2339,7 +2345,7 @@ done:
src_intersect_space within the selection of src_space as a selection
within the selection of dst_space. The result is placed in the
selection of new_space_ptr.
-
+
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
EXAMPLES
@@ -2363,7 +2369,7 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space,
/* Create new space, using dst extent. Start with "all" selection. */
if(NULL == (new_space = H5S_create(H5S_SIMPLE)))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "unable to create output dataspace")
- if(H5S_extent_copy_real(&new_space->extent, &dst_space->extent, TRUE) < 0)
+ if(H5S__extent_copy_real(&new_space->extent, &dst_space->extent, TRUE) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy destination space extent")
/* If the intersecting space is "all", the intersection must be equal to the
@@ -2373,22 +2379,25 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space,
if(H5S_select_copy(new_space, dst_space, FALSE) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy destination space selection")
} /* end if */
- /* If any of the spaces are "none", the projection must also be "none" */
- else if((src_intersect_space->select.type->type == H5S_SEL_NONE)
- || (src_space->select.type->type == H5S_SEL_NONE)
- || (dst_space->select.type->type == H5S_SEL_NONE)) {
+ /* If any of the selections contain no elements, the projection must be
+ * "none" */
+ else if((H5S_GET_SELECT_NPOINTS(src_intersect_space) == 0)
+ || (H5S_GET_SELECT_NPOINTS(src_space) == 0)
+ || (H5S_GET_SELECT_NPOINTS(dst_space) == 0)) {
/* Change to "none" selection */
if(H5S_select_none(new_space) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection")
} /* end if */
- /* If any of the spaces use point selection, fall back to general algorithm
- */
+ /* If any of the spaces use point selection, fall back to general algorithm */
else if((src_intersect_space->select.type->type == H5S_SEL_POINTS)
|| (src_space->select.type->type == H5S_SEL_POINTS)
|| (dst_space->select.type->type == H5S_SEL_POINTS))
HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "point selections not currently supported")
else {
HDassert(src_intersect_space->select.type->type == H5S_SEL_HYPERSLABS);
+ HDassert(src_space->select.type->type != H5S_SEL_NONE);
+ HDassert(dst_space->select.type->type != H5S_SEL_NONE);
+
/* Intersecting space is hyperslab selection. Call the hyperslab
* routine to project to another hyperslab selection. */
if(H5S__hyper_project_intersection(src_space, dst_space, src_intersect_space, new_space) < 0)
@@ -2405,7 +2414,7 @@ done:
HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace")
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_select_project_intersection() */
+} /* end H5S_select_project_intersection() */
/*--------------------------------------------------------------------------
@@ -2427,7 +2436,7 @@ done:
Removes any and all portions of space that are also present in
subtract_space. In essence, performs an A_NOT_B operation with the
two selections.
-
+
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
EXAMPLES
@@ -2454,12 +2463,13 @@ H5S_select_subtract(H5S_t *space, H5S_t *subtract_space)
if(H5S_select_none(space) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection")
} /* end if */
+ /* If either selection is a point selection, fail currently */
+ else if((subtract_space->select.type->type == H5S_SEL_POINTS) ||
+ (space->select.type->type == H5S_SEL_POINTS)) {
+ HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "point selections not currently supported")
+ } /* end if */
else {
- /* Check for point selection in subtract_space, convert to hyperslab */
- if(subtract_space->select.type->type == H5S_SEL_POINTS)
- HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "point selections not currently supported")
-
- /* Check for point or all selection in space, convert to hyperslab */
+ /* Check for all selection in space, convert to hyperslab */
if(space->select.type->type == H5S_SEL_ALL) {
/* Convert current "all" selection to "real" hyperslab selection */
/* Then allow operation to proceed */
@@ -2481,19 +2491,231 @@ H5S_select_subtract(H5S_t *space, H5S_t *subtract_space)
if(H5S_select_hyperslab(space, H5S_SELECT_SET, tmp_start, tmp_stride, tmp_count, tmp_block) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't convert selection")
} /* end if */
- else if(space->select.type->type == H5S_SEL_POINTS)
- HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "point selections not currently supported")
HDassert(space->select.type->type == H5S_SEL_HYPERSLABS);
HDassert(subtract_space->select.type->type == H5S_SEL_HYPERSLABS);
/* Both spaces are now hyperslabs, perform the operation */
- if(H5S__hyper_subtract(space, subtract_space) < 0)
+ if(H5S__modify_select(space, H5S_SELECT_NOTB, subtract_space) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't subtract hyperslab")
} /* end else */
} /* end if */
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_select_subtract() */
+} /* end H5S_select_subtract() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5Ssel_iter_create
+ PURPOSE
+ Create a dataspace selection iterator for a dataspace's selection
+ USAGE
+ hid_t H5Ssel_iter_create(space)
+ hid_t space; IN: ID of the dataspace with selection to iterate over
+ RETURNS
+ Valid dataspace selection iterator ID on success, H5I_INVALID_HID on failure
+ DESCRIPTION
+ Creates a selection iterator and initializes it to start at the first
+ element selected in the dataspace.
+ PROGRAMMER
+ Quincey Koziol - February 11, 2019
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+hid_t
+H5Ssel_iter_create(hid_t space_id, size_t elmt_size, unsigned flags)
+{
+ H5S_t *space; /* Dataspace with selection to iterate over */
+ H5S_sel_iter_t *sel_iter; /* Selection iterator created */
+ hid_t ret_value; /* Return value */
+
+ FUNC_ENTER_API(H5I_INVALID_HID)
+ H5TRACE3("i", "izIu", space_id, elmt_size, flags);
+
+ /* Check args */
+ if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, H5I_INVALID_HID, "not a dataspace")
+ if(elmt_size == 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, H5I_INVALID_HID, "element size must be greater than 0")
+ if(flags != (flags & H5S_SEL_ITER_ALL_PUBLIC_FLAGS))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, H5I_INVALID_HID, "invalid selection iterator flag")
+
+ /* Allocate the iterator */
+ if(NULL == (sel_iter = H5FL_MALLOC(H5S_sel_iter_t)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, H5I_INVALID_HID, "can't allocate selection iterator")
+
+ /* Add flag to indicate that this iterator is from an API call */
+ flags |= H5S_SEL_ITER_API_CALL;
+
+ /* Initialize the selection iterator */
+ if(H5S_select_iter_init(sel_iter, space, elmt_size, flags) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, H5I_INVALID_HID, "unable to initialize selection iterator")
+
+ /* Atomize */
+ if((ret_value = H5I_register(H5I_SPACE_SEL_ITER, sel_iter, TRUE)) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataspace selection iterator atom")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Ssel_iter_create() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5Ssel_iter_get_seq_list
+ PURPOSE
+ Retrieve a list of offset / length sequences for the elements in an iterator
+ USAGE
+ herr_t H5Ssel_iter_get_seq_list(sel_iter_id, maxseq, maxbytes, nseq, nbytes, off, len)
+ hid_t sel_iter_id; IN: ID of the dataspace selection iterator to retrieve sequence from
+ size_t maxseq; IN: Max. # of sequences to retrieve
+ size_t maxbytes; IN: Max. # of bytes to retrieve in sequences
+ size_t *nseq; OUT: # of sequences retrieved
+ size_t *nbytes; OUT: # of bytes retrieved, in all sequences
+ hsize_t *off; OUT: Array of sequence offsets
+ size_t *len; OUT: Array of sequence lengths
+ RETURNS
+ Non-negative on success / Negative on failure
+ DESCRIPTION
+ Retrieve a list of offset / length pairs (a list of "sequences") matching
+ the selected elements for an iterator, according to the iteration order for
+ the iterator. The lengths returned are in _bytes_, not elements.
+
+ Note that the iteration order for "all" and "hyperslab" selections is
+ row-major (i.e. "C-ordered"), but the iteration order for "point"
+ selections is "in order selected", unless the H5S_SEL_ITER_GET_SEQ_LIST_SORTED
+ flag is passed to H5Sset_iter_create for a point selection.
+
+ MAXSEQ and MAXBYTES specify the most sequences or bytes possible to
+ place into the OFF and LEN arrays. *NSEQ and *NBYTES return the actual
+ number of sequences and bytes put into the arrays.
+
+ Each call to H5Ssel_iter_get_seq_list() will retrieve the next set
+ of sequences for the selection being iterated over.
+
+ The total number of bytes possible to retrieve from a selection iterator
+ is the 'elmt_size' passed to H5Ssel_iter_create multiplied by the number
+ of elements selected in the dataspace the iterator was created from
+ (which can be retrieved with H5Sget_select_npoints). When there are no
+ further sequences of elements to retrieve, calls to this routine will
+ set *NSEQ and *NBYTES to zero.
+ PROGRAMMER
+ Quincey Koziol - February 11, 2019
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+herr_t
+H5Ssel_iter_get_seq_list(hid_t sel_iter_id, size_t maxseq, size_t maxbytes,
+ size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len)
+{
+ H5S_sel_iter_t *sel_iter; /* Dataspace selection iterator to operate on */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE7("e", "izz*z*z*h*z", sel_iter_id, maxseq, maxbytes, nseq, nbytes, off,
+ len);
+
+ /* Check args */
+ if(NULL == (sel_iter = (H5S_sel_iter_t *)H5I_object_verify(sel_iter_id, H5I_SPACE_SEL_ITER)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "not a dataspace selection iterator")
+ if(NULL == nseq)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "'nseq' pointer is NULL")
+ if(NULL == nbytes)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "'nbytes' pointer is NULL")
+ if(NULL == off)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "offset array pointer is NULL")
+ if(NULL == len)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "length array pointer is NULL")
+
+ /* Get the sequences of bytes */
+ if(maxseq > 0 && maxbytes > 0) {
+ if(H5S_SELECT_ITER_GET_SEQ_LIST(sel_iter, maxseq, maxbytes, nseq, nbytes, off, len) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "sequence length generation failed")
+ } /* end if */
+ else
+ *nseq = *nbytes = 0;
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Ssel_iter_get_seq_list() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5S_sel_iter_close
+ *
+ * Purpose: Releases a dataspace selection iterator and its memory.
+ *
+ * Return: Non-negative on success / Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * Monday, February 11, 2019
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5S_sel_iter_close(H5S_sel_iter_t *sel_iter)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* Sanity check */
+ HDassert(sel_iter);
+
+ /* Call selection type-specific release routine */
+ if(H5S_SELECT_ITER_RELEASE(sel_iter) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "problem releasing a selection iterator's type-specific info")
+
+ /* Release the structure */
+ sel_iter = H5FL_FREE(H5S_sel_iter_t, sel_iter);
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5S_sel_iter_close() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5Ssel_iter_close
+ PURPOSE
+ Close a dataspace selection iterator
+ USAGE
+ herr_t H5Ssel_iter_close(sel_iter_id)
+ hid_t sel_iter_id; IN: ID of the dataspace selection iterator to close
+ RETURNS
+ Non-negative on success / Negative on failure
+ DESCRIPTION
+ Close a dataspace selection iterator, releasing its state.
+ PROGRAMMER
+ Quincey Koziol - February 11, 2019
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+herr_t
+H5Ssel_iter_close(hid_t sel_iter_id)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE1("e", "i", sel_iter_id);
+
+ /* Check args */
+ if(NULL == H5I_object_verify(sel_iter_id, H5I_SPACE_SEL_ITER))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "not a dataspace selection iterator")
+
+ /* When the reference count reaches zero the resources are freed */
+ if(H5I_dec_app_ref(sel_iter_id) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDEC, FAIL, "problem freeing dataspace selection iterator ID")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Ssel_iter_close() */
diff --git a/src/H5Stest.c b/src/H5Stest.c
index a7bee2b..2c42713 100644
--- a/src/H5Stest.c
+++ b/src/H5Stest.c
@@ -17,23 +17,60 @@
* Purpose: Dataspace selection testing functions.
*/
+/****************/
+/* Module Setup */
+/****************/
+
#include "H5Smodule.h" /* This source code file is part of the H5S module */
#define H5S_TESTING /*suppress warning about H5S testing funcs*/
+/***********/
+/* Headers */
+/***********/
#include "H5private.h" /* Generic Functions */
#include "H5Eprivate.h" /* Error handling */
#include "H5Iprivate.h" /* IDs */
#include "H5Spkg.h" /* Dataspaces */
+/****************/
+/* Local Macros */
+/****************/
+
+
+/******************/
+/* Local Typedefs */
+/******************/
+
+
+/********************/
+/* Local Prototypes */
+/********************/
+
+
+/*****************************/
+/* Library Private Variables */
+/*****************************/
+
+
+/*********************/
+/* Package Variables */
+/*********************/
+
+
+/*******************/
+/* Local Variables */
+/*******************/
+
+
/*--------------------------------------------------------------------------
NAME
- H5S_select_shape_same_test
+ H5S__select_shape_same_test
PURPOSE
Determine if two dataspace selections are the same shape
USAGE
- htri_t H5S_select_shape_same_test(sid1, sid2)
+ htri_t H5S__select_shape_same_test(sid1, sid2)
hid_t sid1; IN: 1st dataspace to compare
hid_t sid2; IN: 2nd dataspace to compare
RETURNS
@@ -48,13 +85,13 @@
REVISION LOG
--------------------------------------------------------------------------*/
htri_t
-H5S_select_shape_same_test(hid_t sid1, hid_t sid2)
+H5S__select_shape_same_test(hid_t sid1, hid_t sid2)
{
H5S_t *space1; /* Pointer to 1st dataspace */
H5S_t *space2; /* Pointer to 2nd dataspace */
htri_t ret_value = FAIL; /* Return value */
- FUNC_ENTER_NOAPI(FAIL)
+ FUNC_ENTER_PACKAGE
/* Get dataspace structures */
if(NULL == (space1 = (H5S_t *)H5I_object_verify(sid1, H5I_DATASPACE)))
@@ -68,19 +105,25 @@ H5S_select_shape_same_test(hid_t sid1, hid_t sid2)
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_select_shape_same_test() */
+} /* H5S__select_shape_same_test() */
/*--------------------------------------------------------------------------
NAME
- H5S_get_rebuild_status_test
+ H5S__get_rebuild_status_test
PURPOSE
- Determine the status of hyperslab rebuild
+ Determine the status of the diminfo_valid field (whether we know the
+ selection information for an equivalent single hyperslab selection)
+ before and after calling H5S__hyper_rebuild.
USAGE
- htri_t H5S_inquiry_rebuild_status(hid_t space_id)
+ herr_t H5S__get_rebuild_status_test(space_id, status1, status2)
hid_t space_id; IN: dataspace id
+ H5S_diminfo_valid_t *status1; OUT: status before calling
+ H5S__hyper_rebuild
+ H5S_diminfo_valid_t *status2; OUT: status after calling
+ H5S__hyper_rebuild
RETURNS
- Non-negative TRUE/FALSE on success, negative on failure
+ Non-negative on success, negative on failure
DESCRIPTION
Query the status of rebuilding the hyperslab
GLOBAL VARIABLES
@@ -89,21 +132,283 @@ done:
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
+herr_t
+H5S__get_rebuild_status_test(hid_t space_id, H5S_diminfo_valid_t *status1,
+ H5S_diminfo_valid_t *status2)
+{
+ H5S_t *space; /* Pointer to 1st dataspace */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_PACKAGE
+
+ HDassert(status1);
+ HDassert(status2);
+
+ /* Get dataspace structures */
+ if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace")
+
+ *status1 = space->select.sel_info.hslab->diminfo_valid;
+
+ /* Fully rebuild diminfo, if necessary */
+ if(*status1 == H5S_DIMINFO_VALID_NO)
+ H5S__hyper_rebuild(space);
+
+ *status2 = space->select.sel_info.hslab->diminfo_valid;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5S__get_rebuild_status_test() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S__get_diminfo_status_test
+ PURPOSE
+ Determine the status of the diminfo_valid field (whether we know the
+ selection information for an equivalent single hyperslab selection)
+ USAGE
+ herr_t H5S__get_diminfo_status_test(space_id, status)
+ hid_t space_id; IN: dataspace id
+ H5S_diminfo_valid_t *status; OUT: status of diminfo_valid
+ RETURNS
+ Non-negative on success, negative on failure
+ DESCRIPTION
+ Query the status of rebuilding the hyperslab
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ DO NOT USE THIS FUNCTION FOR ANYTHING EXCEPT TESTING
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+herr_t
+H5S__get_diminfo_status_test(hid_t space_id, H5S_diminfo_valid_t *status)
+{
+ H5S_t *space; /* Pointer to 1st dataspace */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_PACKAGE
+
+ HDassert(status);
+
+ /* Get dataspace structures */
+ if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace")
+
+ *status = space->select.sel_info.hslab->diminfo_valid;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5S__get_diminfo_status_test() */
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S__check_spans_tail_ptr
+ PURPOSE
+ Determine if the tail pointer of the spans are correctly set
+ USAGE
+ herr_t H5S__check_spans_tail_ptr(span_lst)
+ const H5S_hyper_span_info_t *span_lst; IN: the spans to check for taill pointers
+ RETURNS
+ SUCCEED/FAIL
+ DESCRIPTION
+ Checks to see if the current selection in the dataspaces has tail pointers of each
+ dimension correctly set.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ Only check the hyperslab selection
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+static herr_t
+H5S__check_spans_tail_ptr(const H5S_hyper_span_info_t *span_lst)
+{
+ H5S_hyper_span_t *cur_elem;
+ H5S_hyper_span_t *actual_tail = NULL;
+ htri_t ret_value = TRUE; /* Return value */
+
+ FUNC_ENTER_STATIC
+
+ HDassert(span_lst);
+
+ cur_elem = span_lst->head;
+ while(cur_elem) {
+ actual_tail = cur_elem;
+
+ /* check the next dimension of lower order */
+ if(NULL != cur_elem->down)
+ if((ret_value = H5S__check_spans_tail_ptr(cur_elem->down)) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, "the seletion has inconsistent tail pointers")
+
+ cur_elem = cur_elem->next;
+ } /* end while */
+ if(actual_tail != span_lst->tail)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, "the seletion has inconsistent tail pointers")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5S__check_spans_tail_ptr */
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S__check_points_tail_ptr
+ PURPOSE
+ Determine if the tail pointer of the points list are correctly set
+ USAGE
+ herr_t H5S__check_points_tail_ptr(pnt_lst)
+ const H5S_pnt_list_t *pnt_lst; IN: the points list to check for taill pointers
+ RETURNS
+ SUCCEED/FAIL
+ DESCRIPTION
+ Checks to see if the current selection in the dataspaces has tail pointers correctly set.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ Only check the points selection
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+static herr_t
+H5S__check_points_tail_ptr(const H5S_pnt_list_t *pnt_lst)
+{
+ H5S_pnt_node_t *cur_elem;
+ H5S_pnt_node_t *actual_tail = NULL;
+ htri_t ret_value = TRUE; /* Return value */
+
+ FUNC_ENTER_STATIC
+
+ HDassert(pnt_lst);
+
+ cur_elem = pnt_lst->head;
+ while(cur_elem) {
+ actual_tail = cur_elem;
+ cur_elem = cur_elem->next;
+ } /* end while */
+ if(actual_tail != pnt_lst->tail)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, "the seletion has inconsistent tail pointers")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5S__check_points_tail_ptr */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S__check_internal_consistency
+ PURPOSE
+ Determine if internal data structures are consistent
+ USAGE
+ herr_t H5S__check_internal_consistency(space)
+ const H5S_t *space; IN: 1st Dataspace pointer to compare
+ RETURNS
+ SUCCEED/FAIL
+ DESCRIPTION
+ Checks to see if the current selection in the dataspaces has consistent
+ state of internal data structure.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ Currently only check the hyperslab selection
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+static herr_t
+H5S__check_internal_consistency(const H5S_t *space)
+{
+ hsize_t low_bounds[H5S_MAX_RANK];
+ hsize_t high_bounds[H5S_MAX_RANK];
+ unsigned u;
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_STATIC
+
+ /* Check args */
+ HDassert(space);
+
+ if(space->select.type->type == H5S_SEL_NONE)
+ HGOTO_DONE(ret_value);
+
+ /* Initialize the inputs */
+ for(u = 0; u < space->extent.rank; u++) {
+ low_bounds[u] = HSIZET_MAX;
+ high_bounds[u] = 0;
+ } /* end for */
+
+ /* Check the bound box */
+ if(H5S_get_select_bounds(space, low_bounds, high_bounds) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, "the bound box could not be retrieved")
+
+ if(space->select.type->type == H5S_SEL_HYPERSLABS) {
+ H5S_hyper_sel_t *hslab = space->select.sel_info.hslab;
+
+ if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) {
+ for(u = 0; u < space->extent.rank; u++) {
+ if((hsize_t)((hssize_t)hslab->diminfo.low_bounds[u] + space->select.offset[u]) != low_bounds[u])
+ HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, "the lower bound box of the selection is inconsistent")
+ if((hsize_t)((hssize_t)hslab->diminfo.high_bounds[u] + space->select.offset[u]) != high_bounds[u])
+ HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, "the higher bound box of the selection is inconsistent")
+ } /* end for */
+ } /* end if */
+ else {
+ for(u = 0; u < space->extent.rank; u++) {
+ if((hsize_t)((hssize_t)hslab->span_lst->low_bounds[u] + space->select.offset[u]) != low_bounds[u])
+ HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, "the lower bound box of the selection is inconsistent")
+ if((hsize_t)((hssize_t)hslab->span_lst->high_bounds[u] + space->select.offset[u]) != high_bounds[u])
+ HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, "the higher bound box of the selection is inconsistent")
+ } /* end for */
+ } /* end else */
+
+ /* check the tail pointer */
+ if((NULL != hslab) && (NULL != hslab->span_lst))
+ if(H5S__check_spans_tail_ptr(hslab->span_lst) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, "the seletion has inconsistent tail pointers")
+ } /* end if */
+ else if(space->select.type->type == H5S_SEL_POINTS) {
+ H5S_pnt_list_t *pnt_lst = space->select.sel_info.pnt_lst;
+
+ if(NULL != pnt_lst)
+ if(H5S__check_points_tail_ptr(pnt_lst) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, "the seletion has inconsistent tail pointers")
+ } /* end else-if */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5S__check_internal_consistency */
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S__internal_consistency_test
+ PURPOSE
+ Determine if states of internal data structures are consistent
+ USAGE
+ htri_t H5S__internal_consistency_test(hid_t space_id)
+ hid_t space_id; IN: dataspace id
+ RETURNS
+ Non-negative TRUE/FALSE on success, negative on failure
+ DESCRIPTION
+ Check the states of internal data structures of the hyperslab, and see
+ whether they are consistent or not
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ DO NOT USE THIS FUNCTION FOR ANYTHING EXCEPT TESTING
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
htri_t
-H5S_get_rebuild_status_test(hid_t space_id)
+H5S__internal_consistency_test(hid_t space_id)
{
H5S_t *space; /* Pointer to 1st dataspace */
- htri_t ret_value = FAIL; /* Return value */
+ htri_t ret_value = TRUE; /* Return value */
- FUNC_ENTER_NOAPI(FAIL)
+ FUNC_ENTER_PACKAGE
/* Get dataspace structures */
if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace")
- ret_value = (htri_t)space->select.sel_info.hslab->diminfo_valid;
+ /* Check if the dataspace selections are the same shape */
+ if(FAIL == H5S__check_internal_consistency(space))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, "The dataspace has inconsistent internal state")
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_get_rebuild_status_test() */
+} /* H5S__internal_consistency_test() */
diff --git a/src/H5T.c b/src/H5T.c
index 9544488..6fe291e 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -513,6 +513,7 @@ H5FL_DEFINE(H5T_shared_t);
const unsigned H5O_dtype_ver_bounds[] = {
H5O_DTYPE_VERSION_1, /* H5F_LIBVER_EARLIEST */
H5O_DTYPE_VERSION_3, /* H5F_LIBVER_V18 */
+ H5O_DTYPE_VERSION_3, /* H5F_LIBVER_V110 */
H5O_DTYPE_VERSION_LATEST /* H5F_LIBVER_LATEST */
};
@@ -1397,7 +1398,7 @@ H5T_top_term_package(void)
if((path->conv.u.lib_func)((hid_t)FAIL, (hid_t)FAIL, &(path->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL) < 0) {
#ifdef H5T_DEBUG
if (H5DEBUG(T)) {
- fprintf(H5DEBUG(T), "H5T: conversion function "
+ HDfprintf(H5DEBUG(T), "H5T: conversion function "
"0x%08lx failed to free private data for "
"%s (ignored)\n",
(unsigned long)(path->conv.u.lib_func), path->name);
@@ -1696,33 +1697,42 @@ done:
*-------------------------------------------------------------------------
*/
hid_t
-H5Tcopy(hid_t type_id)
+H5Tcopy(hid_t obj_id)
{
- H5T_t *dt = NULL; /* Pointer to the datatype to copy */
- H5T_t *new_dt = NULL;
- hid_t ret_value = H5I_INVALID_HID; /* Return value */
+ H5T_t *dt = NULL; /* Pointer to the datatype to copy */
+ H5T_t *new_dt = NULL; /* Pointer to the new datatype */
+ hid_t dset_tid = H5I_INVALID_HID; /* Datatype ID from dataset */
+ hid_t ret_value = H5I_INVALID_HID; /* Return value */
FUNC_ENTER_API(H5I_INVALID_HID)
- H5TRACE1("i", "i", type_id);
+ H5TRACE1("i", "i", obj_id);
- switch(H5I_get_type(type_id)) {
+ switch(H5I_get_type(obj_id)) {
case H5I_DATATYPE:
- /* The argument is a datatype handle */
- if(NULL == (dt = (H5T_t *)H5I_object(type_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a datatype")
+ if(NULL == (dt = (H5T_t *)H5I_object(obj_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "type_id is not a datatype ID")
break;
case H5I_DATASET:
- {
- H5D_t *dset; /* Dataset for datatype */
+ {
+ H5VL_object_t *vol_obj = NULL; /* Dataset structure */
+
+ /* Check args */
+ if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(obj_id, H5I_DATASET)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "type_id is not a dataset ID")
+
+ /* Get the datatype from the dataset
+ * NOTE: This will have to be closed after we're done with it.
+ */
+ if(H5VL_dataset_get(vol_obj, H5VL_DATASET_GET_TYPE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &dset_tid) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, H5I_INVALID_HID, "unable to get datatype from the dataset")
+
+ /* Unwrap the type ID */
+ if(NULL == (dt = (H5T_t *)H5I_object(dset_tid)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, H5I_INVALID_HID, "received invalid datatype from the dataset")
- /* The argument is a dataset handle */
- if(NULL == (dset = (H5D_t *)H5VL_object(type_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a dataset")
- if(NULL == (dt = H5D_typeof(dset)))
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, H5I_INVALID_HID, "unable to get the dataset datatype")
- }
break;
+ }
case H5I_UNINIT:
case H5I_BADID:
@@ -1737,6 +1747,7 @@ H5Tcopy(hid_t type_id)
case H5I_ERROR_CLASS:
case H5I_ERROR_MSG:
case H5I_ERROR_STACK:
+ case H5I_SPACE_SEL_ITER:
case H5I_NTYPES:
default:
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a datatype or dataset")
@@ -1746,11 +1757,18 @@ H5Tcopy(hid_t type_id)
if(NULL == (new_dt = H5T_copy(dt, H5T_COPY_TRANSIENT)))
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5I_INVALID_HID, "unable to copy")
- /* Atomize result */
+ /* Get an ID for the copied datatype */
if((ret_value = H5I_register(H5I_DATATYPE, new_dt, TRUE)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register datatype atom")
done:
+
+ /* If we got a type ID from a passed-in dataset, we need to close that */
+ if(dset_tid != H5I_INVALID_HID)
+ if(H5I_dec_app_ref(dset_tid) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_BADATOM, FAIL, "problem freeing temporary dataset type ID")
+
+ /* Close the new datatype on errors */
if(H5I_INVALID_HID == ret_value)
if(new_dt && H5T_close_real(new_dt) < 0)
HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, H5I_INVALID_HID, "unable to release datatype info")
@@ -3338,7 +3356,7 @@ H5T_copy(H5T_t *old_dt, H5T_copy_t method)
if (NULL == new_dt->shared->u.compnd.memb)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
- HDmemcpy(new_dt->shared->u.compnd.memb, old_dt->shared->u.compnd.memb,
+ H5MM_memcpy(new_dt->shared->u.compnd.memb, old_dt->shared->u.compnd.memb,
new_dt->shared->u.compnd.nmembs * sizeof(H5T_cmemb_t));
} /* end if */
@@ -3404,7 +3422,7 @@ H5T_copy(H5T_t *old_dt, H5T_copy_t method)
(uint8_t *)H5MM_malloc(new_dt->shared->u.enumer.nalloc * new_dt->shared->size);
if(NULL == new_dt->shared->u.enumer.value)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
- HDmemcpy(new_dt->shared->u.enumer.value, old_dt->shared->u.enumer.value,
+ H5MM_memcpy(new_dt->shared->u.enumer.value, old_dt->shared->u.enumer.value,
new_dt->shared->u.enumer.nmembs * new_dt->shared->size);
for(i = 0; i < new_dt->shared->u.enumer.nmembs; i++) {
s = old_dt->shared->u.enumer.name[i];
diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c
index 712b264..c6b85a5 100644
--- a/src/H5Tcommit.c
+++ b/src/H5Tcommit.c
@@ -1211,7 +1211,7 @@ H5T_save_refresh_state(hid_t tid, H5O_shared_t *cached_H5O_shared)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINC, FAIL, "can't increment object count")
/* Cache the H5O_shared_t data */
- HDmemcpy(cached_H5O_shared, &(vol_dt->sh_loc), sizeof(H5O_shared_t));
+ H5MM_memcpy(cached_H5O_shared, &(vol_dt->sh_loc), sizeof(H5O_shared_t));
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -1245,7 +1245,7 @@ H5T_restore_refresh_state(hid_t tid, H5O_shared_t *cached_H5O_shared)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "tid is not not a named datatype ID")
/* Restore the H5O_shared_t data */
- HDmemcpy(&(vol_dt->sh_loc), cached_H5O_shared, sizeof(H5O_shared_t));
+ H5MM_memcpy(&(vol_dt->sh_loc), cached_H5O_shared, sizeof(H5O_shared_t));
/* Decrement the ref. count for this object in the top file */
if(H5FO_top_decr(vol_dt->sh_loc.file, vol_dt->sh_loc.u.loc.oh_addr) < 0)
diff --git a/src/H5Tconv.c b/src/H5Tconv.c
index e6d83bb..7d47483 100644
--- a/src/H5Tconv.c
+++ b/src/H5Tconv.c
@@ -828,7 +828,7 @@ done: \
/* Macro defining action on source data which needs to be aligned (before main action) */
#define H5T_CONV_LOOP_PRE_SALIGN(ST) { \
- HDmemcpy(&src_aligned, src, sizeof(ST)); \
+ H5MM_memcpy(&src_aligned, src, sizeof(ST)); \
}
/* Macro defining action on source data which doesn't need to be aligned (before main action) */
@@ -854,7 +854,7 @@ done: \
/* Macro defining action on destination data which needs to be aligned (after main action) */
#define H5T_CONV_LOOP_POST_DALIGN(DT) { \
- HDmemcpy(dst, &dst_aligned, sizeof(DT)); \
+ H5MM_memcpy(dst, &dst_aligned, sizeof(DT)); \
}
/* Macro defining action on destination data which doesn't need to be aligned (after main action) */
@@ -1797,7 +1797,7 @@ H5T__conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
* should copy the value to the true destination buffer.
*/
if(d == dbuf)
- HDmemcpy(dp, d, dst->shared->size);
+ H5MM_memcpy(dp, d, dst->shared->size);
if(buf_stride) {
sp += direction * (ssize_t)buf_stride; /* Note that cast is checked with H5_CHECK_OVERFLOW, above */
dp += direction * (ssize_t)buf_stride; /* Note that cast is checked with H5_CHECK_OVERFLOW, above */
@@ -2771,7 +2771,7 @@ H5T__conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
case H5T_CONV_FREE:
#ifdef H5T_DEBUG
if (H5DEBUG(T)) {
- fprintf(H5DEBUG(T), " Using %s mapping function%s\n",
+ HDfprintf(H5DEBUG(T), " Using %s mapping function%s\n",
priv->length?"O(1)":"O(log N)",
priv->length?"":", where N is the number of enum members");
}
@@ -2852,7 +2852,7 @@ H5T__conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
else if(except_ret == H5T_CONV_ABORT)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception")
} else
- HDmemcpy(d,
+ H5MM_memcpy(d,
dst->shared->u.enumer.value + (unsigned)priv->src2dst[n] * dst->shared->size,
dst->shared->size);
} /* end if */
@@ -2888,7 +2888,7 @@ H5T__conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
} /* end if */
else {
HDassert(priv->src2dst[md] >= 0);
- HDmemcpy(d,
+ H5MM_memcpy(d,
dst->shared->u.enumer.value + (unsigned)priv->src2dst[md] * dst->shared->size,
dst->shared->size);
} /* end else */
@@ -3846,7 +3846,7 @@ H5T__conv_i_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
* should copy the value to the true destination buffer.
*/
if(d==dbuf)
- HDmemcpy(dp, d, dst->shared->size);
+ H5MM_memcpy(dp, d, dst->shared->size);
/* Advance source & destination pointers by delta amounts */
sp += src_delta;
@@ -4432,7 +4432,7 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
*/
next:
if(d == dbuf)
- HDmemcpy(dp, d, dst_p->shared->size);
+ H5MM_memcpy(dp, d, dst_p->shared->size);
/* Advance source & destination pointers by delta amounts */
sp += src_delta;
@@ -4604,7 +4604,7 @@ H5T__conv_s_s(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
--nchars;
nchars = MIN(dst->shared->size, nchars);
if(d != s)
- HDmemcpy(d, s, nchars);
+ H5MM_memcpy(d, s, nchars);
break;
case H5T_STR_RESERVED_3:
@@ -4666,7 +4666,7 @@ H5T__conv_s_s(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
* should copy the value to the true destination buffer.
*/
if(d == dbuf)
- HDmemcpy(dp, d, dst->shared->size);
+ H5MM_memcpy(dp, d, dst->shared->size);
/* Advance source & destination pointers by delta amounts */
sp += src_delta;
@@ -8825,7 +8825,7 @@ H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
* should copy the value to the true destination buffer.
*/
if (d==dbuf)
- HDmemcpy (dp, d, dst_p->shared->size);
+ H5MM_memcpy (dp, d, dst_p->shared->size);
if (buf_stride) {
sp += direction * (ssize_t) buf_stride;
dp += direction * (ssize_t) buf_stride;
@@ -9235,7 +9235,7 @@ H5T__conv_i_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
* should copy the value to the true destination buffer.
*/
if (d==dbuf)
- HDmemcpy (dp, d, dst_p->shared->size);
+ H5MM_memcpy (dp, d, dst_p->shared->size);
if (buf_stride) {
sp += direction * (ssize_t) buf_stride;
dp += direction * (ssize_t) buf_stride;
diff --git a/src/H5Tenum.c b/src/H5Tenum.c
index 0ed1775..ff88fab 100644
--- a/src/H5Tenum.c
+++ b/src/H5Tenum.c
@@ -223,7 +223,7 @@ H5T__enum_insert(const H5T_t *dt, const char *name, const void *value)
dt->shared->u.enumer.sorted = H5T_SORT_NONE;
i = dt->shared->u.enumer.nmembs++;
dt->shared->u.enumer.name[i] = H5MM_xstrdup(name);
- HDmemcpy(dt->shared->u.enumer.value+i*dt->shared->size, value, dt->shared->size);
+ H5MM_memcpy(dt->shared->u.enumer.value+i*dt->shared->size, value, dt->shared->size);
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -298,7 +298,7 @@ H5T__get_member_value(const H5T_t *dt, unsigned membno, void *value/*out*/)
HDassert(dt);
HDassert(value);
- HDmemcpy(value, dt->shared->u.enumer.value + membno*dt->shared->size, dt->shared->size);
+ H5MM_memcpy(value, dt->shared->u.enumer.value + membno*dt->shared->size, dt->shared->size);
FUNC_LEAVE_NOAPI(SUCCEED)
}
@@ -569,7 +569,7 @@ H5T_enum_valueof(const H5T_t *dt, const char *name, void *value/*out*/)
if (cmp!=0)
HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, FAIL, "string doesn't exist in the enumeration type")
- HDmemcpy(value, copied_dt->shared->u.enumer.value+md*copied_dt->shared->size, copied_dt->shared->size);
+ H5MM_memcpy(value, copied_dt->shared->u.enumer.value+md*copied_dt->shared->size, copied_dt->shared->size);
done:
if(copied_dt)
diff --git a/src/H5Tfields.c b/src/H5Tfields.c
index be62d85..8202c2c 100644
--- a/src/H5Tfields.c
+++ b/src/H5Tfields.c
@@ -351,10 +351,10 @@ H5T__sort_value(const H5T_t *dt, int *map)
dt->shared->u.enumer.name[j + 1] = tmp;
/* Swap values */
- HDmemcpy(tbuf, dt->shared->u.enumer.value + (j * size), size);
- HDmemcpy(dt->shared->u.enumer.value + (j * size),
+ H5MM_memcpy(tbuf, dt->shared->u.enumer.value + (j * size), size);
+ H5MM_memcpy(dt->shared->u.enumer.value + (j * size),
dt->shared->u.enumer.value + ((j + 1) * size), size);
- HDmemcpy(dt->shared->u.enumer.value + ((j + 1) * size), tbuf, size);
+ H5MM_memcpy(dt->shared->u.enumer.value + ((j + 1) * size), tbuf, size);
/* Swap map */
if(map) {
@@ -457,10 +457,10 @@ H5T__sort_name(const H5T_t *dt, int *map)
dt->shared->u.enumer.name[j+1] = tmp;
/* Swap values */
- HDmemcpy(tbuf, dt->shared->u.enumer.value+j*size, size);
- HDmemcpy(dt->shared->u.enumer.value+j*size,
+ H5MM_memcpy(tbuf, dt->shared->u.enumer.value+j*size, size);
+ H5MM_memcpy(dt->shared->u.enumer.value+j*size,
dt->shared->u.enumer.value+(j+1)*size, size);
- HDmemcpy(dt->shared->u.enumer.value+(j+1)*size, tbuf, size);
+ H5MM_memcpy(dt->shared->u.enumer.value+(j+1)*size, tbuf, size);
/* Swap map */
if (map) {
diff --git a/src/H5Tnative.c b/src/H5Tnative.c
index c9ad01a..d213c45 100644
--- a/src/H5Tnative.c
+++ b/src/H5Tnative.c
@@ -369,7 +369,7 @@ H5T__get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_ali
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot get member name")
if(H5T__get_member_value(dtype, u, tmp_memb_value) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot get member value")
- HDmemcpy(memb_value, tmp_memb_value, H5T_get_size(super_type));
+ H5MM_memcpy(memb_value, tmp_memb_value, H5T_get_size(super_type));
if(H5T_convert(tpath, super_type_id, nat_super_type_id, (size_t)1, (size_t)0, (size_t)0, memb_value, NULL) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot get member value")
@@ -515,6 +515,9 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T__get_native_type() */
+/* Disable warning for intentional identical branches here -QAK */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wduplicated-branches"
/*-------------------------------------------------------------------------
* Function: H5T__get_native_integer
@@ -655,7 +658,11 @@ H5T__get_native_integer(size_t prec, H5T_sign_t sign, H5T_direction_t direction,
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T__get_native_integer() */
+#pragma GCC diagnostic pop
+/* Disable warning for intentional identical branches here -QAK */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wduplicated-branches"
/*-------------------------------------------------------------------------
* Function: H5T__get_native_float
@@ -780,7 +787,11 @@ H5T__get_native_float(size_t size, H5T_direction_t direction, size_t *struct_ali
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T__get_native_float() */
+#pragma GCC diagnostic pop
+/* Disable warning for intentional identical branches here -QAK */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wduplicated-branches"
/*-------------------------------------------------------------------------
* Function: H5T__get_native_bitfield
@@ -866,6 +877,7 @@ H5T__get_native_bitfield(size_t prec, H5T_direction_t direction,
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T__get_native_bitfield() */
+#pragma GCC diagnostic pop
/*-------------------------------------------------------------------------
diff --git a/src/H5Torder.c b/src/H5Torder.c
index d687d03..62662d6 100644
--- a/src/H5Torder.c
+++ b/src/H5Torder.c
@@ -100,11 +100,11 @@ H5Tget_order(hid_t type_id)
/* Check args */
if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
- HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, H5T_ORDER_ERROR, "not a datatype")
+ HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, H5T_ORDER_ERROR, "not a datatype")
/* Get order */
if(H5T_ORDER_ERROR == (ret_value = H5T_get_order(dt)))
- HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, H5T_ORDER_ERROR, "cant't get order for specified datatype")
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, H5T_ORDER_ERROR, "can't get order for specified datatype")
done:
FUNC_LEAVE_API(ret_value)
diff --git a/src/H5Tvlen.c b/src/H5Tvlen.c
index 841637d..bafb47f 100644
--- a/src/H5Tvlen.c
+++ b/src/H5Tvlen.c
@@ -302,7 +302,7 @@ H5T_vlen_seq_mem_getlen(const void *_vl)
FUNC_LEAVE_NOAPI((ssize_t)vl->len)
#else
HDassert(_vl);
- HDmemcpy(&vl, _vl, sizeof(hvl_t));
+ H5MM_memcpy(&vl, _vl, sizeof(hvl_t));
FUNC_LEAVE_NOAPI((ssize_t)vl.len)
#endif
@@ -339,7 +339,7 @@ H5T_vlen_seq_mem_getptr(void *_vl)
FUNC_LEAVE_NOAPI(vl->p)
#else
HDassert(_vl);
- HDmemcpy(&vl, _vl, sizeof(hvl_t));
+ H5MM_memcpy(&vl, _vl, sizeof(hvl_t));
FUNC_LEAVE_NOAPI(vl.p)
#endif
@@ -376,7 +376,7 @@ H5T_vlen_seq_mem_isnull(const H5F_t H5_ATTR_UNUSED *f, void *_vl)
FUNC_LEAVE_NOAPI((vl->len==0 || vl->p==NULL) ? TRUE : FALSE)
#else
HDassert(_vl);
- HDmemcpy(&vl, _vl, sizeof(hvl_t));
+ H5MM_memcpy(&vl, _vl, sizeof(hvl_t));
FUNC_LEAVE_NOAPI((vl.len==0 || vl.p==NULL) ? TRUE : FALSE)
#endif
@@ -411,13 +411,13 @@ H5T_vlen_seq_mem_read(H5F_t H5_ATTR_UNUSED *f, void *_vl, void *buf, size_t len)
#ifdef H5_NO_ALIGNMENT_RESTRICTIONS
HDassert(vl && vl->p);
- HDmemcpy(buf,vl->p,len);
+ H5MM_memcpy(buf,vl->p,len);
#else
HDassert(_vl);
- HDmemcpy(&vl, _vl, sizeof(hvl_t));
+ H5MM_memcpy(&vl, _vl, sizeof(hvl_t));
HDassert(vl.p);
- HDmemcpy(buf,vl.p,len);
+ H5MM_memcpy(buf,vl.p,len);
#endif
FUNC_LEAVE_NOAPI(SUCCEED)
@@ -463,7 +463,7 @@ H5T_vlen_seq_mem_write(H5F_t H5_ATTR_UNUSED *f, const H5T_vlen_alloc_info_t *vl_
} /* end else */
/* Copy the data into the newly allocated buffer */
- HDmemcpy(vl.p,buf,len);
+ H5MM_memcpy(vl.p,buf,len);
} /* end if */
else
@@ -473,7 +473,7 @@ H5T_vlen_seq_mem_write(H5F_t H5_ATTR_UNUSED *f, const H5T_vlen_alloc_info_t *vl_
vl.len=seq_len;
/* Set pointer in user's buffer with memcpy, to avoid alignment issues */
- HDmemcpy(_vl,&vl,sizeof(hvl_t));
+ H5MM_memcpy(_vl,&vl,sizeof(hvl_t));
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -507,7 +507,7 @@ H5T_vlen_seq_mem_setnull(H5F_t H5_ATTR_UNUSED *f, void *_vl, void H5_ATTR_UNUSED
vl.p=NULL;
/* Set pointer in user's buffer with memcpy, to avoid alignment issues */
- HDmemcpy(_vl,&vl,sizeof(hvl_t));
+ H5MM_memcpy(_vl,&vl,sizeof(hvl_t));
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5T_vlen_seq_mem_setnull() */
@@ -541,7 +541,7 @@ H5T_vlen_str_mem_getlen(const void *_vl)
HDassert(s);
#else
HDassert(_vl);
- HDmemcpy(&s, _vl, sizeof(char *));
+ H5MM_memcpy(&s, _vl, sizeof(char *));
#endif
FUNC_LEAVE_NOAPI((ssize_t)HDstrlen(s))
@@ -576,7 +576,7 @@ H5T_vlen_str_mem_getptr(void *_vl)
HDassert(s);
#else
HDassert(_vl);
- HDmemcpy(&s, _vl, sizeof(char *));
+ H5MM_memcpy(&s, _vl, sizeof(char *));
#endif
FUNC_LEAVE_NOAPI(s)
@@ -607,7 +607,7 @@ H5T_vlen_str_mem_isnull(const H5F_t H5_ATTR_UNUSED *f, void *_vl)
FUNC_ENTER_NOAPI_NOINIT_NOERR
#ifndef H5_NO_ALIGNMENT_RESTRICTIONS
- HDmemcpy(&s, _vl, sizeof(char *));
+ H5MM_memcpy(&s, _vl, sizeof(char *));
#endif
FUNC_LEAVE_NOAPI(s==NULL ? TRUE : FALSE)
@@ -644,10 +644,10 @@ H5T_vlen_str_mem_read(H5F_t H5_ATTR_UNUSED *f, void *_vl, void *buf, size_t len)
HDassert(s);
#else
HDassert(_vl);
- HDmemcpy(&s, _vl, sizeof(char *));
+ H5MM_memcpy(&s, _vl, sizeof(char *));
#endif
- HDmemcpy(buf,s,len);
+ H5MM_memcpy(buf,s,len);
} /* end if */
FUNC_LEAVE_NOAPI(SUCCEED)
@@ -690,11 +690,11 @@ H5T_vlen_str_mem_write(H5F_t H5_ATTR_UNUSED *f, const H5T_vlen_alloc_info_t *vl_
} /* end else */
len=(seq_len*base_size);
- HDmemcpy(t,buf,len);
+ H5MM_memcpy(t,buf,len);
t[len]='\0';
/* Set pointer in user's buffer with memcpy, to avoid alignment issues */
- HDmemcpy(_vl,&t,sizeof(char *));
+ H5MM_memcpy(_vl,&t,sizeof(char *));
done:
FUNC_LEAVE_NOAPI(ret_value) /*lint !e429 The pointer in 't' has been copied */
@@ -721,7 +721,7 @@ H5T_vlen_str_mem_setnull(H5F_t H5_ATTR_UNUSED *f, void *_vl, void H5_ATTR_UNUSED
FUNC_ENTER_NOAPI_NOINIT_NOERR
/* Set pointer in user's buffer with memcpy, to avoid alignment issues */
- HDmemcpy(_vl,&t,sizeof(char *));
+ H5MM_memcpy(_vl,&t,sizeof(char *));
FUNC_LEAVE_NOAPI(SUCCEED) /*lint !e429 The pointer in 't' has been copied */
} /* end H5T_vlen_str_mem_setnull() */
diff --git a/src/H5VL.c b/src/H5VL.c
index 37ad187..5c62f6f 100644
--- a/src/H5VL.c
+++ b/src/H5VL.c
@@ -29,13 +29,13 @@
/***********/
#include "H5private.h" /* Generic Functions */
-#include "H5Aprivate.h" /* Attributes */
#include "H5Eprivate.h" /* Error handling */
#include "H5Iprivate.h" /* IDs */
-#include "H5MMprivate.h" /* Memory management */
-#include "H5PLprivate.h" /* Plugins */
+#include "H5Pprivate.h" /* Property lists */
#include "H5VLpkg.h" /* Virtual Object Layer */
+/* VOL connectors */
+#include "H5VLnative.h" /* Native VOL connector */
/****************/
/* Local Macros */
@@ -46,29 +46,10 @@
/* Local Typedefs */
/******************/
-/* Information needed for iterating over the registered VOL connector hid_t IDs.
- * The name or value of the new VOL connector that is being registered is
- * stored in the name (or value) field and the found_id field is initialized to
- * H5I_INVALID_HID (-1). If we find a VOL connector with the same name / value,
- * we set the found_id field to the existing ID for return to the function.
- */
-typedef struct {
- /* IN */
- H5VL_get_connector_kind_t kind; /* Which kind of connector search to make */
- union {
- const char *name; /* The name of the VOL connector to check */
- H5VL_class_value_t value; /* The value of the VOL connector to check */
- } u;
-
- /* OUT */
- hid_t found_id; /* The connector ID, if we found a match */
-} H5VL_get_connector_ud_t;
-
/********************/
/* Local Prototypes */
/********************/
-static int H5VL__get_connector_cb(void *obj, hid_t id, void *_op_data);
/*********************/
@@ -88,50 +69,14 @@ static int H5VL__get_connector_cb(void *obj, hid_t id, void *_op_data);
/*-------------------------------------------------------------------------
- * Function: H5VL__get_connector_cb
- *
- * Purpose: Callback routine to search through registered VOLs
- *
- * Return: Success: H5_ITER_STOP if the class and op_data name
- * members match. H5_ITER_CONT otherwise.
- *
- * Failure: Can't fail
- *
- *-------------------------------------------------------------------------
- */
-static int
-H5VL__get_connector_cb(void *obj, hid_t id, void *_op_data)
-{
- H5VL_get_connector_ud_t *op_data = (H5VL_get_connector_ud_t *)_op_data; /* User data for callback */
- H5VL_class_t *cls = (H5VL_class_t *)obj;
- int ret_value = H5_ITER_CONT; /* Callback return value */
-
- FUNC_ENTER_STATIC_NOERR
-
- if(H5VL_GET_CONNECTOR_BY_NAME == op_data->kind) {
- if(0 == HDstrcmp(cls->name, op_data->u.name)) {
- op_data->found_id = id;
- ret_value = H5_ITER_STOP;
- } /* end if */
- } /* end if */
- else {
- HDassert(H5VL_GET_CONNECTOR_BY_VALUE == op_data->kind);
- if(cls->value == op_data->u.value) {
- op_data->found_id = id;
- ret_value = H5_ITER_STOP;
- } /* end if */
- } /* end else */
-
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5VL__get_connector_cb() */
-
-
-/*-------------------------------------------------------------------------
* Function: H5VLregister_connector
*
* Purpose: Registers a new VOL connector as a member of the virtual object
* layer class.
*
+ * VIPL_ID is a VOL initialization property list which must be
+ * created with H5Pcreate(H5P_VOL_INITIALIZE) (or H5P_DEFAULT).
+ *
* Return: Success: A VOL connector ID which is good until the
* library is closed or the connector is
* unregistered.
@@ -143,8 +88,7 @@ H5VL__get_connector_cb(void *obj, hid_t id, void *_op_data)
hid_t
H5VLregister_connector(const H5VL_class_t *cls, hid_t vipl_id)
{
- H5VL_get_connector_ud_t op_data; /* Callback info for connector search */
- hid_t ret_value = H5I_INVALID_HID;
+ hid_t ret_value = H5I_INVALID_HID; /* Return value */
FUNC_ENTER_API(H5I_INVALID_HID)
H5TRACE2("i", "*xi", cls, vipl_id);
@@ -156,30 +100,21 @@ H5VLregister_connector(const H5VL_class_t *cls, hid_t vipl_id)
HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "VOL connector class name cannot be the NULL pointer")
if (0 == HDstrlen(cls->name))
HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "VOL connector class name cannot be the empty string")
- if (cls->info_copy && !cls->info_free)
+ if (cls->info_cls.copy && !cls->info_cls.free)
HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "VOL connector must provide free callback for VOL info objects when a copy callback is provided")
- if (cls->get_wrap_ctx && !cls->free_wrap_ctx)
+ if (cls->wrap_cls.get_wrap_ctx && !cls->wrap_cls.free_wrap_ctx)
HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "VOL connector must provide free callback for object wrapping contexts when a get callback is provided")
- op_data.kind = H5VL_GET_CONNECTOR_BY_NAME;
- op_data.u.name = cls->name;
- op_data.found_id = H5I_INVALID_HID;
-
- /* check if connector is already registered */
- if (H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_BADITER, H5I_INVALID_HID, "can't iterate over VOL IDs")
-
- /* Increment the ref count on the existing VOL connector ID, if it's already registered */
- if(op_data.found_id != H5I_INVALID_HID) {
- if (H5I_inc_ref(op_data.found_id, TRUE) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTINC, H5I_INVALID_HID, "unable to increment ref count on VOL connector")
- ret_value = op_data.found_id;
- } /* end if */
- else {
- /* Create a new class ID */
- if ((ret_value = H5VL_register_connector(cls, TRUE, vipl_id)) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VOL connector")
- } /* end else */
+ /* Check VOL initialization property list */
+ if(H5P_DEFAULT == vipl_id)
+ vipl_id = H5P_VOL_INITIALIZE_DEFAULT;
+ else
+ if(TRUE != H5P_isa_class(vipl_id, H5P_VOL_INITIALIZE))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a VOL initialize property list")
+
+ /* Register connector */
+ if((ret_value = H5VL__register_connector(cls, TRUE, vipl_id)) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VOL connector")
done:
FUNC_LEAVE_API(ret_value)
@@ -192,6 +127,9 @@ done:
* Purpose: Registers a new VOL connector as a member of the virtual object
* layer class.
*
+ * VIPL_ID is a VOL initialization property list which must be
+ * created with H5Pcreate(H5P_VOL_INITIALIZE) (or H5P_DEFAULT).
+ *
* Return: Success: A VOL connector ID which is good until the
* library is closed or the connector is
* unregistered.
@@ -203,8 +141,7 @@ done:
hid_t
H5VLregister_connector_by_name(const char *name, hid_t vipl_id)
{
- H5VL_get_connector_ud_t op_data; /* Callback info for connector search */
- hid_t ret_value = H5I_INVALID_HID;
+ hid_t ret_value = H5I_INVALID_HID; /* Return value */
FUNC_ENTER_API(H5I_INVALID_HID)
H5TRACE2("i", "*si", name, vipl_id);
@@ -215,34 +152,16 @@ H5VLregister_connector_by_name(const char *name, hid_t vipl_id)
if (0 == HDstrlen(name))
HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, "zero-length VOL connector name is disallowed")
- op_data.kind = H5VL_GET_CONNECTOR_BY_NAME;
- op_data.u.name = name;
- op_data.found_id = H5I_INVALID_HID;
-
- /* Check if connector is already registered */
- if(H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_BADITER, H5I_INVALID_HID, "can't iterate over VOL ids")
-
- /* If connector alread registered, increment ref count on ID and return ID */
- if(op_data.found_id != H5I_INVALID_HID) {
- if(H5I_inc_ref(op_data.found_id, TRUE) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTINC, H5I_INVALID_HID, "unable to increment ref count on VOL connector")
- ret_value = op_data.found_id;
- } /* end if */
- else {
- H5PL_key_t key;
- const H5VL_class_t *cls;
-
- /* Try loading the connector */
- key.vol.kind = H5VL_GET_CONNECTOR_BY_NAME;
- key.vol.u.name = name;
- if(NULL == (cls = (const H5VL_class_t *)H5PL_load(H5PL_TYPE_VOL, &key)))
- HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, H5I_INVALID_HID, "unable to load VOL connector")
-
- /* Register the connector we loaded */
- if((ret_value = H5VL_register_connector(cls, TRUE, vipl_id)) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VOL connector ID")
- } /* end else */
+ /* Check VOL initialization property list */
+ if(H5P_DEFAULT == vipl_id)
+ vipl_id = H5P_VOL_INITIALIZE_DEFAULT;
+ else
+ if(TRUE != H5P_isa_class(vipl_id, H5P_VOL_INITIALIZE))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a VOL initialize property list")
+
+ /* Register connector */
+ if((ret_value = H5VL__register_connector_by_name(name, TRUE, vipl_id)) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VOL connector")
done:
FUNC_LEAVE_API(ret_value)
@@ -255,6 +174,9 @@ done:
* Purpose: Registers a new VOL connector as a member of the virtual object
* layer class.
*
+ * VIPL_ID is a VOL initialization property list which must be
+ * created with H5Pcreate(H5P_VOL_INITIALIZE) (or H5P_DEFAULT).
+ *
* Return: Success: A VOL connector ID which is good until the
* library is closed or the connector is
* unregistered.
@@ -266,8 +188,7 @@ done:
hid_t
H5VLregister_connector_by_value(H5VL_class_value_t value, hid_t vipl_id)
{
- H5VL_get_connector_ud_t op_data; /* Callback info for connector search */
- hid_t ret_value = H5I_INVALID_HID;
+ hid_t ret_value = H5I_INVALID_HID; /* Return value */
FUNC_ENTER_API(H5I_INVALID_HID)
H5TRACE2("i", "VCi", value, vipl_id);
@@ -276,34 +197,16 @@ H5VLregister_connector_by_value(H5VL_class_value_t value, hid_t vipl_id)
if(value < 0)
HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, "negative VOL connector value is disallowed")
- op_data.kind = H5VL_GET_CONNECTOR_BY_VALUE;
- op_data.u.value = value;
- op_data.found_id = H5I_INVALID_HID;
-
- /* Check if connector is already registered */
- if(H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_BADITER, H5I_INVALID_HID, "can't iterate over VOL ids")
-
- /* If connector alread registered, increment ref count on ID and return ID */
- if(op_data.found_id != H5I_INVALID_HID) {
- if(H5I_inc_ref(op_data.found_id, TRUE) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTINC, H5I_INVALID_HID, "unable to increment ref count on VOL connector")
- ret_value = op_data.found_id;
- } /* end if */
- else {
- H5PL_key_t key;
- const H5VL_class_t *cls;
-
- /* Try loading the connector */
- key.vol.kind = H5VL_GET_CONNECTOR_BY_VALUE;
- key.vol.u.value = value;
- if(NULL == (cls = (const H5VL_class_t *)H5PL_load(H5PL_TYPE_VOL, &key)))
- HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, H5I_INVALID_HID, "unable to load VOL connector")
-
- /* Register the connector we loaded */
- if((ret_value = H5VL_register_connector(cls, TRUE, vipl_id)) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VOL connector ID")
- } /* end else */
+ /* Check VOL initialization property list */
+ if(H5P_DEFAULT == vipl_id)
+ vipl_id = H5P_VOL_INITIALIZE_DEFAULT;
+ else
+ if(TRUE != H5P_isa_class(vipl_id, H5P_VOL_INITIALIZE))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a VOL initialize property list")
+
+ /* Register connector */
+ if((ret_value = H5VL__register_connector_by_value(value, TRUE, vipl_id)) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VOL connector")
done:
FUNC_LEAVE_API(ret_value)
@@ -315,33 +218,26 @@ done:
*
* Purpose: Tests whether a VOL class has been registered or not
*
- * Return: Positive if the VOL class has been registered
- *
- * Zero if it is unregistered
+ * Return: >0 if a VOL connector with that name has been registered
+ * 0 if a VOL connector with that name has NOT been registered
+ * <0 on errors
*
- * Negative on error (if the class is not a valid class ID)
+ * Programmer: Dana Robinson
+ * June 17, 2017
*
*-------------------------------------------------------------------------
*/
htri_t
H5VLis_connector_registered(const char *name)
{
- H5VL_get_connector_ud_t op_data; /* Callback info for connector search */
htri_t ret_value = FALSE; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE1("t", "*s", name);
- op_data.kind = H5VL_GET_CONNECTOR_BY_NAME;
- op_data.u.name = name;
- op_data.found_id = H5I_INVALID_HID;
-
- /* Check arguments */
- if (H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_BADITER, FAIL, "can't iterate over VOL ids")
-
- if (op_data.found_id != H5I_INVALID_HID)
- ret_value = TRUE;
+ /* Check if connector with this name is registered */
+ if((ret_value = H5VL__is_connector_registered(name)) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't check for VOL")
done:
FUNC_LEAVE_API(ret_value)
@@ -353,33 +249,29 @@ done:
*
* Purpose: Retrieves the ID for a registered VOL connector.
*
- * Return: Positive if the VOL class has been registered
- * Negative on error (if the class is not a valid class or not registered)
+ * Return: A valid VOL connector ID if a connector by that name has
+ * been registered. This ID will need to be closed using
+ * H5VLclose().
+ *
+ * H5I_INVALID_HID on error or if a VOL connector of that
+ * name has not been registered.
+ *
+ * Programmer: Dana Robinson
+ * June 17, 2017
*
*-------------------------------------------------------------------------
*/
hid_t
H5VLget_connector_id(const char *name)
{
- H5VL_get_connector_ud_t op_data; /* Callback info for connector search */
hid_t ret_value = H5I_INVALID_HID; /* Return value */
FUNC_ENTER_API(H5I_INVALID_HID)
H5TRACE1("i", "*s", name);
- op_data.kind = H5VL_GET_CONNECTOR_BY_NAME;
- op_data.u.name = name;
- op_data.found_id = H5I_INVALID_HID;
-
- /* Check arguments */
- if (H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_BADITER, H5I_INVALID_HID, "can't iterate over VOL connector IDs")
-
- if (op_data.found_id != H5I_INVALID_HID) {
- if (H5I_inc_ref(op_data.found_id, TRUE) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTINC, H5I_INVALID_HID, "unable to increment ref count on VOL connector")
- ret_value = op_data.found_id;
- } /* end if */
+ /* Get connector ID with this name */
+ if((ret_value = H5VL__get_connector_id(name, TRUE)) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL id")
done:
FUNC_LEAVE_API(ret_value)
@@ -390,7 +282,12 @@ done:
* Function: H5VLget_connector_name
*
* Purpose: Returns the connector name for the VOL associated with the
- * object or file ID
+ * object or file ID.
+ *
+ * This works like other calls where the caller must provide a
+ * buffer of the appropriate size for the library to fill in.
+ * i.e., passing in a NULL pointer for NAME will return the
+ * required size of the buffer.
*
* Return: Success: The length of the connector name
*
@@ -406,7 +303,8 @@ H5VLget_connector_name(hid_t obj_id, char *name/*out*/, size_t size)
FUNC_ENTER_API(FAIL)
H5TRACE3("Zs", "ixz", obj_id, name, size);
- if ((ret_value = H5VL_get_connector_name(obj_id, name, size)) < 0)
+ /* Call internal routine */
+ if((ret_value = H5VL__get_connector_name(obj_id, name, size)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "Can't get connector name")
done:
@@ -456,6 +354,9 @@ done:
* this VOL connector or files which are already opened under with
* this connector.
*
+ * The native VOL connector cannot be unregistered and attempts
+ * to do so are considered an error.
+ *
* Return: Success: Non-negative
*
* Failure: Negative
@@ -465,6 +366,7 @@ done:
herr_t
H5VLunregister_connector(hid_t vol_id)
{
+ hid_t native_id = H5I_INVALID_HID;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -472,13 +374,23 @@ H5VLunregister_connector(hid_t vol_id)
/* Check arguments */
if(NULL == H5I_object_verify(vol_id, H5I_VOL))
- HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "not a VOL connector")
+ HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "not a VOL connector ID")
+
+ /* For the time being, we disallow unregistering the native VOL connector */
+ if(H5I_INVALID_HID == (native_id = H5VL__get_connector_id(H5VL_NATIVE_NAME, FALSE)))
+ HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to find the native VOL connector ID")
+ if(vol_id == native_id)
+ HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, FAIL, "unregistering the native VOL connector is not allowed")
/* The H5VL_class_t struct will be freed by this function */
- if (H5I_dec_app_ref(vol_id) < 0)
+ if(H5I_dec_app_ref(vol_id) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to unregister VOL connector")
done:
+ if(native_id != H5I_INVALID_HID)
+ if(H5I_dec_ref(native_id) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to decrement count on native_id")
+
FUNC_LEAVE_API(ret_value)
} /* end H5VLunregister_connector() */
@@ -488,6 +400,9 @@ done:
*
* Purpose: Compares two connector classes (based on their value field)
*
+ * Note: This routine is _only_ for HDF5 VOL connector authors! It is
+ * _not_ part of the public API for HDF5 application developers.
+ *
* Return: Success: Non-negative, *cmp set to a value like strcmp
*
* Failure: Negative, *cmp unset
@@ -522,11 +437,11 @@ done:
* Function: H5VLwrap_register
*
* Purpose: Wrap an internal object with a "wrap context" and register an
- * hid_t for the resulting object.
+ * hid_t for the resulting object.
*
- * Note: This routine is mainly targeted toward wrapping objects for
- * iteration routine callbacks (i.e. the callbacks from H5Aiterate*,
- * H5Literate* / H5Lvisit*, and H5Ovisit* ).
+ * Note: This routine is mainly targeted toward wrapping objects for
+ * iteration routine callbacks (i.e. the callbacks from H5Aiterate*,
+ * H5Literate* / H5Lvisit*, and H5Ovisit* ).
*
* Return: Success: Non-negative hid_t for the object.
* Failure: Negative (H5I_INVALID_HID)
@@ -561,10 +476,10 @@ done:
* Function: H5VLobject
*
* Purpose: Retrieve the object pointer associated with an hid_t for a.
- * VOL object.
+ * VOL object.
*
- * Note: This routine is mainly targeted toward unwrapping objects for
- * testing.
+ * Note: This routine is mainly targeted toward unwrapping objects for
+ * testing.
*
* Return: Success: Object pointer
* Failure: NULL
@@ -587,3 +502,159 @@ done:
FUNC_LEAVE_API(ret_value)
} /* H5VLobject() */
+
+/*---------------------------------------------------------------------------
+ * Function: H5VLretrieve_lib_state
+ *
+ * Purpose: Retrieves a copy of the internal state of the HDF5 library,
+ * so that it can be restored later.
+ *
+ * Note: This routine is _only_ for HDF5 VOL connector authors! It is
+ * _not_ part of the public API for HDF5 application developers.
+ *
+ * Return: Success: Non-negative, *state set
+ * Failure: Negative, *state unset
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, January 10, 2019
+ *
+ *---------------------------------------------------------------------------
+ */
+herr_t
+H5VLretrieve_lib_state(void **state)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ /* Must use this, to avoid modifying the API context stack in FUNC_ENTER */
+ FUNC_ENTER_API_NOINIT
+ H5TRACE1("e", "**x", state);
+
+ /* Check args */
+ if(NULL == state)
+ HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, FAIL, "invalid state pointer")
+
+ /* Retrieve the library state */
+ if(H5VL_retrieve_lib_state(state) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't retrieve library state")
+
+done:
+ FUNC_LEAVE_API_NOINIT(ret_value)
+} /* H5VLretrieve_lib_state() */
+
+
+/*---------------------------------------------------------------------------
+ * Function: H5VLrestore_lib_state
+ *
+ * Purpose: Restores the internal state of the HDF5 library.
+ *
+ * Note: This routine is _only_ for HDF5 VOL connector authors! It is
+ * _not_ part of the public API for HDF5 application developers.
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, January 10, 2019
+ *
+ *---------------------------------------------------------------------------
+ */
+herr_t
+H5VLrestore_lib_state(const void *state)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ /* Must use this, to avoid modifying the API context stack in FUNC_ENTER */
+ FUNC_ENTER_API_NOINIT
+ H5TRACE1("e", "*x", state);
+
+ /* Check args */
+ if(NULL == state)
+ HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, FAIL, "invalid state pointer")
+
+ /* Restore the library state */
+ if(H5VL_restore_lib_state(state) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't restore library state")
+
+done:
+ FUNC_LEAVE_API_NOINIT(ret_value)
+} /* H5VLrestore_lib_state() */
+
+
+/*---------------------------------------------------------------------------
+ * Function: H5VLreset_lib_state
+ *
+ * Purpose: Resets the internal state of the HDF5 library, undoing the
+ * affects of H5VLrestore_lib_state.
+ *
+ * Note: This routine is _only_ for HDF5 VOL connector authors! It is
+ * _not_ part of the public API for HDF5 application developers.
+ *
+ * Note: This routine must be called as a "pair" with
+ * H5VLrestore_lib_state. It can be called before / after /
+ * independently of H5VLfree_lib_state.
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * Saturday, February 23, 2019
+ *
+ *---------------------------------------------------------------------------
+ */
+herr_t
+H5VLreset_lib_state(void)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ /* Must use this, to avoid modifying the API context stack in FUNC_ENTER */
+ FUNC_ENTER_API_NOINIT
+ H5TRACE0("e","");
+
+ /* Reset the library state */
+ if(H5VL_reset_lib_state() < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset library state")
+
+done:
+ FUNC_LEAVE_API_NOINIT(ret_value)
+} /* H5VLreset_lib_state() */
+
+
+/*---------------------------------------------------------------------------
+ * Function: H5VLfree_lib_state
+ *
+ * Purpose: Free a retrieved library state.
+ *
+ * Note: This routine is _only_ for HDF5 VOL connector authors! It is
+ * _not_ part of the public API for HDF5 application developers.
+ *
+ * Note: This routine must be called as a "pair" with
+ * H5VLretrieve_lib_state.
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, January 10, 2019
+ *
+ *---------------------------------------------------------------------------
+ */
+herr_t
+H5VLfree_lib_state(void *state)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE1("e", "*x", state);
+
+ /* Check args */
+ if(NULL == state)
+ HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, FAIL, "invalid state pointer")
+
+ /* Free the library state */
+ if(H5VL_free_lib_state(state) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "can't free library state")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* H5VLfree_lib_state() */
+
diff --git a/src/H5VLcallback.c b/src/H5VLcallback.c
index 2d6ac33..696ccab 100644
--- a/src/H5VLcallback.c
+++ b/src/H5VLcallback.c
@@ -57,8 +57,8 @@
/* Local Prototypes */
/********************/
static void *H5VL__attr_create(void *obj, const H5VL_loc_params_t *loc_params,
- const H5VL_class_t *cls, const char *name, hid_t acpl_id, hid_t aapl_id,
- hid_t dxpl_id, void **req);
+ const H5VL_class_t *cls, const char *name, hid_t type_id, hid_t space_id,
+ hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req);
static void *H5VL__attr_open(void *obj, const H5VL_loc_params_t *loc_params,
const H5VL_class_t *cls, const char *name, hid_t aapl_id, hid_t dxpl_id,
void **req);
@@ -76,8 +76,8 @@ static herr_t H5VL__attr_optional(void *obj, const H5VL_class_t *cls, hid_t dxpl
static herr_t H5VL__attr_close(void *obj, const H5VL_class_t *cls, hid_t dxpl_id,
void **req);
static void *H5VL__dataset_create(void *obj, const H5VL_loc_params_t *loc_params,
- const H5VL_class_t *cls, const char *name, hid_t dcpl_id, hid_t dapl_id,
- hid_t dxpl_id, void **req);
+ const H5VL_class_t *cls, const char *name, hid_t lcpl_id, hid_t type_id,
+ hid_t space_id, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req);
static void *H5VL__dataset_open(void *obj, const H5VL_loc_params_t *loc_params,
const H5VL_class_t *cls, const char *name, hid_t dapl_id, hid_t dxpl_id,
void **req);
@@ -108,8 +108,8 @@ static herr_t H5VL__file_optional(void *obj, const H5VL_class_t *cls, hid_t dxpl
static herr_t H5VL__file_close(void *obj, const H5VL_class_t *cls, hid_t dxpl_id,
void **req);
static void *H5VL__group_create(void *obj, const H5VL_loc_params_t *loc_params,
- const H5VL_class_t *cls, const char *name, hid_t gcpl_id, hid_t gapl_id,
- hid_t dxpl_id, void **req);
+ const H5VL_class_t *cls, const char *name, hid_t lcpl_id, hid_t gcpl_id,
+ hid_t gapl_id, hid_t dxpl_id, void **req);
static void *H5VL__group_open(void *obj, const H5VL_loc_params_t *loc_params,
const H5VL_class_t *cls, const char *name, hid_t gapl_id, hid_t dxpl_id,
void **req);
@@ -123,7 +123,7 @@ static herr_t H5VL__group_close(void *obj, const H5VL_class_t *cls,
hid_t dxpl_id, void **req);
static herr_t H5VL__link_create(H5VL_link_create_type_t create_type, void *obj,
const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, hid_t lcpl_id,
- hid_t lapl_id, hid_t dxpl_id, void **req);
+ hid_t lapl_id, hid_t dxpl_id, void **req, va_list arguments);
static herr_t H5VL__link_copy(void *src_obj, const H5VL_loc_params_t *loc_params1,
void *dst_obj, const H5VL_loc_params_t *loc_params2, const H5VL_class_t *cls,
hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req);
@@ -348,14 +348,14 @@ H5VL_copy_connector_info(const H5VL_class_t *connector, void **dst_info,
/* Check for actual source info */
if(src_info) {
/* Allow the connector to copy or do it ourselves */
- if(connector->info_copy) {
- if(NULL == (new_connector_info = (connector->info_copy)(src_info)))
+ if(connector->info_cls.copy) {
+ if(NULL == (new_connector_info = (connector->info_cls.copy)(src_info)))
HGOTO_ERROR(H5E_VOL, H5E_CANTCOPY, FAIL, "connector info copy callback failed")
} /* end if */
- else if(connector->info_size > 0) {
- if(NULL == (new_connector_info = H5MM_malloc(connector->info_size)))
+ else if(connector->info_cls.size > 0) {
+ if(NULL == (new_connector_info = H5MM_malloc(connector->info_cls.size)))
HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, FAIL, "connector info allocation failed")
- HDmemcpy(new_connector_info, src_info, connector->info_size);
+ H5MM_memcpy(new_connector_info, src_info, connector->info_cls.size);
} /* end else-if */
else
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "no way to copy connector info")
@@ -444,13 +444,13 @@ H5VL_cmp_connector_info(const H5VL_class_t *connector, int *cmp_value,
* if there is a a callback, otherwise just compare the info objects as
* memory buffers
*/
- if(connector->info_cmp) {
- if((connector->info_cmp)(cmp_value, info1, info2) < 0)
+ if(connector->info_cls.cmp) {
+ if((connector->info_cls.cmp)(cmp_value, info1, info2) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTCOMPARE, FAIL, "can't compare connector info")
} /* end if */
else {
- HDassert(connector->info_size > 0);
- *cmp_value = HDmemcmp(info1, info2, connector->info_size);
+ HDassert(connector->info_cls.size > 0);
+ *cmp_value = HDmemcmp(info1, info2, connector->info_cls.size);
} /* end else */
done:
@@ -506,20 +506,25 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5VL_free_connector_info(const H5VL_class_t *connector, void *info)
+H5VL_free_connector_info(hid_t connector_id, void *info)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ H5VL_class_t *cls; /* VOL connector's class struct */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
- /* Sanity checks */
- HDassert(connector);
+ /* Sanity check */
+ HDassert(connector_id > 0);
+
+ /* Check args and get class pointer */
+ if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL)))
+ HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "not a VOL connector ID")
/* Only free info object, if it's non-NULL */
if(info) {
/* Allow the connector to free info or do it ourselves */
- if(connector->info_free) {
- if((connector->info_free)(info) < 0)
+ if(cls->info_cls.free) {
+ if((cls->info_cls.free)(info) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "connector info free request failed")
} /* end if */
else
@@ -544,18 +549,13 @@ done:
herr_t
H5VLfree_connector_info(hid_t connector_id, void *info)
{
- H5VL_class_t *cls; /* VOL connector's class struct */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API_NOINIT
H5TRACE2("e", "i*x", connector_id, info);
- /* Check args and get class pointer */
- if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID")
-
/* Free the VOL connector info object */
- if(H5VL_free_connector_info(cls, info) < 0)
+ if(H5VL_free_connector_info(connector_id, info) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to release VOL connector info object")
done:
@@ -590,8 +590,8 @@ H5VLconnector_info_to_str(const void *info, hid_t connector_id, char **str)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID")
/* Allow the connector to serialize info */
- if(cls->info_to_str) {
- if((cls->info_to_str)(info, str) < 0)
+ if(cls->info_cls.to_str) {
+ if((cls->info_cls.to_str)(info, str) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTSERIALIZE, FAIL, "can't serialize connector info")
} /* end if */
else
@@ -623,24 +623,9 @@ H5VLconnector_str_to_info(const char *str, hid_t connector_id, void **info)
FUNC_ENTER_API_NOINIT
H5TRACE3("e", "*si**x", str, connector_id, info);
- /* Only deserialize string, if it's non-NULL */
- if(str) {
- H5VL_class_t *cls; /* VOL connector's class struct */
-
- /* Check args and get class pointer */
- if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID")
-
- /* Allow the connector to deserialize info */
- if(cls->str_to_info) {
- if((cls->str_to_info)(str, info) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTUNSERIALIZE, FAIL, "can't deserialize connector info")
- } /* end if */
- else
- *info = NULL;
- } /* end if */
- else
- *info = NULL;
+ /* Call internal routine */
+ if(H5VL__connector_str_to_info(str, connector_id, info) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTDECODE, FAIL, "can't deserialize connector info")
done:
FUNC_LEAVE_API_NOINIT(ret_value)
@@ -673,8 +658,8 @@ H5VLget_object(void *obj, hid_t connector_id)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID")
/* Check for 'get_object' callback in connector */
- if(cls->get_object)
- ret_value = (cls->get_object)(obj);
+ if(cls->wrap_cls.get_object)
+ ret_value = (cls->wrap_cls.get_object)(obj);
else
ret_value = obj;
@@ -706,12 +691,12 @@ H5VL_get_wrap_ctx(const H5VL_class_t *connector, void *obj, void **wrap_ctx)
HDassert(wrap_ctx);
/* Allow the connector to copy or do it ourselves */
- if(connector->get_wrap_ctx) {
+ if(connector->wrap_cls.get_wrap_ctx) {
/* Sanity check */
- HDassert(connector->free_wrap_ctx);
+ HDassert(connector->wrap_cls.free_wrap_ctx);
/* Invoke connector's callback */
- if((connector->get_wrap_ctx)(obj, wrap_ctx) < 0)
+ if((connector->wrap_cls.get_wrap_ctx)(obj, wrap_ctx) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "connector wrap context callback failed")
} /* end if */
else
@@ -755,84 +740,89 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5VL_free_wrap_ctx
+ * Function: H5VL_wrap_object
*
- * Purpose: Free object wrapping context for a connector
+ * Purpose: Wrap an object with connector
*
- * Return: Success: Non-negative
- * Failure: Negative
+ * Return: Success: Non-NULL
+ * Failure: NULL
*
*-------------------------------------------------------------------------
*/
-herr_t
-H5VL_free_wrap_ctx(const H5VL_class_t *connector, void *wrap_ctx)
+void *
+H5VL_wrap_object(const H5VL_class_t *connector, void *wrap_ctx, void *obj,
+ H5I_type_t obj_type)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ void *ret_value = NULL; /* Return value */
- FUNC_ENTER_NOAPI(FAIL)
+ FUNC_ENTER_NOAPI(NULL)
/* Sanity checks */
HDassert(connector);
+ HDassert(obj);
- /* Only free wrap context, if it's non-NULL */
+ /* Only wrap object if there's a wrap context */
if(wrap_ctx) {
- /* Free the connector's object wrapping context */
- if((connector->free_wrap_ctx)(wrap_ctx) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "connector wrap context free request failed")
+ /* Ask the connector to wrap the object */
+ if(NULL == (ret_value = (connector->wrap_cls.wrap_object)(obj, obj_type, wrap_ctx)))
+ HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "can't wrap object")
} /* end if */
+ else
+ ret_value = obj;
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5VL_free_wrap_ctx() */
+} /* end H5VL_wrap_object() */
/*---------------------------------------------------------------------------
- * Function: H5VLfree_wrap_ctx
+ * Function: H5VLwrap_object
*
- * Purpose: Release a VOL connector's object wrapping context
+ * Purpose: Asks a connector to wrap an underlying object.
*
- * Return: Success: Non-negative
- * Failure: Negative
+ * Return: Success: Non-NULL
+ * Failure: NULL
*
*---------------------------------------------------------------------------
*/
-herr_t
-H5VLfree_wrap_ctx(void *wrap_ctx, hid_t connector_id)
+void *
+H5VLwrap_object(void *obj, H5I_type_t obj_type, hid_t connector_id, void *wrap_ctx)
{
- H5VL_class_t *cls; /* VOL connector's class struct */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5VL_class_t *cls; /* VOL connector's class struct */
+ void *ret_value = NULL; /* Return value */
FUNC_ENTER_API_NOINIT
- H5TRACE2("e", "*xi", wrap_ctx, connector_id);
+ H5TRACE4("*x", "*xIti*x", obj, obj_type, connector_id, wrap_ctx);
/* Check args and get class pointer */
+ if(NULL == obj)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object")
if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID")
- /* Release the VOL connector's object wrapper */
- if(H5VL_free_wrap_ctx(cls, wrap_ctx) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to release VOL connector object wrap context")
+ /* Wrap the object */
+ if(NULL == (ret_value = H5VL_wrap_object(cls, wrap_ctx, obj, obj_type)))
+ HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "unable to wrap object")
done:
FUNC_LEAVE_API_NOINIT(ret_value)
-} /* H5VLfree_wrap_ctx() */
+} /* H5VLwrap_object */
/*-------------------------------------------------------------------------
- * Function: H5VL_wrap_object
+ * Function: H5VL_unwrap_object
*
- * Purpose: Wrap an object with connector
+ * Purpose: Unwrap an object from connector
*
- * Return: Success: Non-negative
- * Failure: Negative
+ * Return: Success: Non-NULL
+ * Failure: NULL
*
*-------------------------------------------------------------------------
*/
void *
-H5VL_wrap_object(const H5VL_class_t *connector, void *wrap_ctx, void *obj,
- H5I_type_t obj_type)
+H5VL_unwrap_object(const H5VL_class_t *connector, void *obj)
{
- void *ret_value = SUCCEED; /* Return value */
+ void *ret_value = NULL; /* Return value */
FUNC_ENTER_NOAPI(NULL)
@@ -840,24 +830,24 @@ H5VL_wrap_object(const H5VL_class_t *connector, void *wrap_ctx, void *obj,
HDassert(connector);
HDassert(obj);
- /* Only wrap object if there's a wrap context */
- if(wrap_ctx) {
- /* Ask the connector to wrap the object */
- if(NULL == (ret_value = (connector->wrap_object)(obj, obj_type, wrap_ctx)))
- HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "can't wrap object")
+ /* Only unwrap object if there's an unwrap callback */
+ if(connector->wrap_cls.wrap_object) {
+ /* Ask the connector to unwrap the object */
+ if(NULL == (ret_value = (connector->wrap_cls.unwrap_object)(obj)))
+ HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "can't unwrap object")
} /* end if */
else
ret_value = obj;
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5VL_wrap_object() */
+} /* end H5VL_unwrap_object() */
/*---------------------------------------------------------------------------
- * Function: H5VLwrap_object
+ * Function: H5VLunwrap_object
*
- * Purpose: Asks a connector to wrap an underlying object.
+ * Purpose: Unwrap an object from connector
*
* Return: Success: Non-NULL
* Failure: NULL
@@ -865,13 +855,13 @@ done:
*---------------------------------------------------------------------------
*/
void *
-H5VLwrap_object(void *obj, H5I_type_t obj_type, hid_t connector_id, void *wrap_ctx)
+H5VLunwrap_object(void *obj, hid_t connector_id)
{
H5VL_class_t *cls; /* VOL connector's class struct */
void *ret_value = NULL; /* Return value */
FUNC_ENTER_API_NOINIT
- H5TRACE4("*x", "*xIti*x", obj, obj_type, connector_id, wrap_ctx);
+ H5TRACE2("*x", "*xi", obj, connector_id);
/* Check args and get class pointer */
if(NULL == obj)
@@ -879,13 +869,77 @@ H5VLwrap_object(void *obj, H5I_type_t obj_type, hid_t connector_id, void *wrap_c
if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID")
- /* Wrap the object */
- if(NULL == (ret_value = H5VL_wrap_object(cls, wrap_ctx, obj, obj_type)))
- HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "unable to wrap object")
+ /* Unwrap the object */
+ if(NULL == (ret_value = H5VL_unwrap_object(cls, obj)))
+ HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "unable to unwrap object")
done:
FUNC_LEAVE_API_NOINIT(ret_value)
-} /* H5VLwrap_object */
+} /* H5VLunwrap_object */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5VL_free_wrap_ctx
+ *
+ * Purpose: Free object wrapping context for a connector
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5VL_free_wrap_ctx(const H5VL_class_t *connector, void *wrap_ctx)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* Sanity checks */
+ HDassert(connector);
+
+ /* Only free wrap context, if it's non-NULL */
+ if(wrap_ctx) {
+ /* Free the connector's object wrapping context */
+ if((connector->wrap_cls.free_wrap_ctx)(wrap_ctx) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "connector wrap context free request failed")
+ } /* end if */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5VL_free_wrap_ctx() */
+
+
+/*---------------------------------------------------------------------------
+ * Function: H5VLfree_wrap_ctx
+ *
+ * Purpose: Release a VOL connector's object wrapping context
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ *---------------------------------------------------------------------------
+ */
+herr_t
+H5VLfree_wrap_ctx(void *wrap_ctx, hid_t connector_id)
+{
+ H5VL_class_t *cls; /* VOL connector's class struct */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_API_NOINIT
+ H5TRACE2("e", "*xi", wrap_ctx, connector_id);
+
+ /* Check args and get class pointer */
+ if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID")
+
+ /* Release the VOL connector's object wrapper */
+ if(H5VL_free_wrap_ctx(cls, wrap_ctx) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to release VOL connector object wrap context")
+
+done:
+ FUNC_LEAVE_API_NOINIT(ret_value)
+} /* H5VLfree_wrap_ctx() */
/*-------------------------------------------------------------------------
@@ -900,7 +954,8 @@ done:
*/
static void *
H5VL__attr_create(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls,
- const char *name, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req)
+ const char *name, hid_t type_id, hid_t space_id, hid_t acpl_id,
+ hid_t aapl_id, hid_t dxpl_id, void **req)
{
void *ret_value = NULL; /* Return value */
@@ -911,12 +966,12 @@ H5VL__attr_create(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_cla
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL connector has no 'attr create' method")
/* Call the corresponding VOL callback */
- if(NULL == (ret_value = (cls->attr_cls.create)(obj, loc_params, name, acpl_id, aapl_id, dxpl_id, req)))
+ if(NULL == (ret_value = (cls->attr_cls.create)(obj, loc_params, name, type_id, space_id, acpl_id, aapl_id, dxpl_id, req)))
HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "attribute create failed")
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5VL_attr_create() */
+} /* end H5VL__attr_create() */
/*-------------------------------------------------------------------------
@@ -931,7 +986,8 @@ done:
*/
void *
H5VL_attr_create(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params,
- const char *name, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req)
+ const char *name, hid_t type_id, hid_t space_id, hid_t acpl_id,
+ hid_t aapl_id, hid_t dxpl_id, void **req)
{
hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */
void *ret_value = NULL; /* Return value */
@@ -944,7 +1000,7 @@ H5VL_attr_create(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_para
vol_wrapper_set = TRUE;
/* Call the corresponding internal VOL routine */
- if(NULL == (ret_value = H5VL__attr_create(vol_obj->data, loc_params, vol_obj->connector->cls, name, acpl_id, aapl_id, dxpl_id, req)))
+ if(NULL == (ret_value = H5VL__attr_create(vol_obj->data, loc_params, vol_obj->connector->cls, name, type_id, space_id, acpl_id, aapl_id, dxpl_id, req)))
HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "attribute create failed")
done:
@@ -968,14 +1024,15 @@ done:
*/
void *
H5VLattr_create(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id,
- const char *name, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req)
+ const char *name, hid_t type_id, hid_t space_id, hid_t acpl_id,
+ hid_t aapl_id, hid_t dxpl_id, void **req)
{
H5VL_class_t *cls; /* VOL connector's class struct */
void *ret_value = NULL; /* Return value */
FUNC_ENTER_API_NOINIT
- H5TRACE8("*x", "*x*xi*siii**x", obj, loc_params, connector_id, name, acpl_id,
- aapl_id, dxpl_id, req);
+ H5TRACE10("*x", "*x*xi*siiiii**x", obj, loc_params, connector_id, name,
+ type_id, space_id, acpl_id, aapl_id, dxpl_id, req);
/* Check args and get class pointer */
if(NULL == obj)
@@ -984,7 +1041,7 @@ H5VLattr_create(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID")
/* Call the corresponding internal VOL routine */
- if(NULL == (ret_value = H5VL__attr_create(obj, loc_params, cls, name, acpl_id, aapl_id, dxpl_id, req)))
+ if(NULL == (ret_value = H5VL__attr_create(obj, loc_params, cls, name, type_id, space_id, acpl_id, aapl_id, dxpl_id, req)))
HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "unable to create attribute")
done:
@@ -1740,7 +1797,8 @@ done:
*/
static void *
H5VL__dataset_create(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls,
- const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req)
+ const char *name, hid_t lcpl_id, hid_t type_id, hid_t space_id,
+ hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req)
{
void *ret_value = NULL; /* Return value */
@@ -1751,7 +1809,7 @@ H5VL__dataset_create(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL connector has no 'dataset create' method")
/* Call the corresponding VOL callback */
- if(NULL == (ret_value = (cls->dataset_cls.create)(obj, loc_params, name, dcpl_id, dapl_id, dxpl_id, req)))
+ if(NULL == (ret_value = (cls->dataset_cls.create)(obj, loc_params, name, lcpl_id, type_id, space_id, dcpl_id, dapl_id, dxpl_id, req)))
HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "dataset create failed")
done:
@@ -1771,7 +1829,8 @@ done:
*/
void *
H5VL_dataset_create(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params,
- const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req)
+ const char *name, hid_t lcpl_id, hid_t type_id, hid_t space_id,
+ hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req)
{
hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */
void *ret_value = NULL; /* Return value */
@@ -1784,7 +1843,7 @@ H5VL_dataset_create(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_p
vol_wrapper_set = TRUE;
/* Call the corresponding internal VOL routine */
- if(NULL == (ret_value = H5VL__dataset_create(vol_obj->data, loc_params, vol_obj->connector->cls, name, dcpl_id, dapl_id, dxpl_id, req)))
+ if(NULL == (ret_value = H5VL__dataset_create(vol_obj->data, loc_params, vol_obj->connector->cls, name, lcpl_id, type_id, space_id, dcpl_id, dapl_id, dxpl_id, req)))
HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "dataset create failed")
done:
@@ -1808,14 +1867,15 @@ done:
*/
void *
H5VLdataset_create(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id,
- const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req)
+ const char *name, hid_t lcpl_id, hid_t type_id, hid_t space_id,
+ hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req)
{
H5VL_class_t *cls; /* VOL connector's class struct */
void *ret_value = NULL; /* Return value */
FUNC_ENTER_API_NOINIT
- H5TRACE8("*x", "*x*xi*siii**x", obj, loc_params, connector_id, name, dcpl_id,
- dapl_id, dxpl_id, req);
+ H5TRACE11("*x", "*x*xi*siiiiii**x", obj, loc_params, connector_id, name,
+ lcpl_id, type_id, space_id, dcpl_id, dapl_id, dxpl_id, req);
/* Check args and get class pointer */
if(NULL == obj)
@@ -1824,7 +1884,7 @@ H5VLdataset_create(void *obj, const H5VL_loc_params_t *loc_params, hid_t connect
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID")
/* Call the corresponding internal VOL routine */
- if(NULL == (ret_value = H5VL__dataset_create(obj, loc_params, cls, name, dcpl_id, dapl_id, dxpl_id, req)))
+ if(NULL == (ret_value = H5VL__dataset_create(obj, loc_params, cls, name, lcpl_id, type_id, space_id, dcpl_id, dapl_id, dxpl_id, req)))
HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "unable to create dataset")
done:
@@ -2981,7 +3041,7 @@ H5VL_file_specific(const H5VL_object_t *vol_obj, H5VL_file_specific_t specific_t
arg_started = TRUE;
/* Special treatment of file access check */
- if(specific_type == H5VL_FILE_IS_ACCESSIBLE) {
+ if(specific_type == H5VL_FILE_IS_ACCESSIBLE || specific_type == H5VL_FILE_DELETE) {
H5P_genplist_t *plist; /* Property list pointer */
H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */
va_list tmp_args; /* argument list passed from the API call */
@@ -2989,7 +3049,7 @@ H5VL_file_specific(const H5VL_object_t *vol_obj, H5VL_file_specific_t specific_t
/* Get the file access property list to access the file */
HDva_copy(tmp_args, arguments);
- fapl_id = va_arg(tmp_args, hid_t);
+ fapl_id = HDva_arg(tmp_args, hid_t);
HDva_end(tmp_args);
/* Get the VOL info from the FAPL */
@@ -3294,7 +3354,8 @@ done:
*/
static void *
H5VL__group_create(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls,
- const char *name, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req)
+ const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id,
+ hid_t dxpl_id, void **req)
{
void *ret_value = NULL; /* Return value */
@@ -3305,7 +3366,7 @@ H5VL__group_create(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_cl
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL connector has no 'group create' method")
/* Call the corresponding VOL callback */
- if(NULL == (ret_value = (cls->group_cls.create)(obj, loc_params, name, gcpl_id, gapl_id, dxpl_id, req)))
+ if(NULL == (ret_value = (cls->group_cls.create)(obj, loc_params, name, lcpl_id, gcpl_id, gapl_id, dxpl_id, req)))
HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "group create failed")
done:
@@ -3325,7 +3386,8 @@ done:
*/
void *
H5VL_group_create(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params,
- const char *name, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req)
+ const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id,
+ void **req)
{
hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */
void *ret_value = NULL; /* Return value */
@@ -3338,7 +3400,7 @@ H5VL_group_create(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_par
vol_wrapper_set = TRUE;
/* Call the corresponding internal VOL routine */
- if(NULL == (ret_value = H5VL__group_create(vol_obj->data, loc_params, vol_obj->connector->cls, name, gcpl_id, gapl_id, dxpl_id, req)))
+ if(NULL == (ret_value = H5VL__group_create(vol_obj->data, loc_params, vol_obj->connector->cls, name, lcpl_id, gcpl_id, gapl_id, dxpl_id, req)))
HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "group create failed")
done:
@@ -3361,15 +3423,16 @@ done:
*-------------------------------------------------------------------------
*/
void *
-H5VLgroup_create(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name,
- hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req)
+H5VLgroup_create(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id,
+ const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id,hid_t dxpl_id,
+ void **req)
{
H5VL_class_t *cls; /* VOL connector's class struct */
void *ret_value = NULL; /* Return value */
FUNC_ENTER_API_NOINIT
- H5TRACE8("*x", "*x*xi*siii**x", obj, loc_params, connector_id, name, gcpl_id,
- gapl_id, dxpl_id, req);
+ H5TRACE9("*x", "*x*xi*siiii**x", obj, loc_params, connector_id, name, lcpl_id,
+ gcpl_id, gapl_id, dxpl_id, req);
/* Check args and get class pointer */
if(NULL == obj)
@@ -3378,7 +3441,7 @@ H5VLgroup_create(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID")
/* Call the corresponding internal VOL routine */
- if(NULL == (ret_value = H5VL__group_create(obj, loc_params, cls, name, gcpl_id, gapl_id, dxpl_id, req)))
+ if(NULL == (ret_value = H5VL__group_create(obj, loc_params, cls, name, lcpl_id, gcpl_id, gapl_id, dxpl_id, req)))
HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "unable to create group")
done:
@@ -3942,7 +4005,8 @@ done:
*/
static herr_t
H5VL__link_create(H5VL_link_create_type_t create_type, void *obj, const H5VL_loc_params_t *loc_params,
- const H5VL_class_t *cls, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req)
+ const H5VL_class_t *cls, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req,
+ va_list arguments)
{
herr_t ret_value = SUCCEED; /* Return value */
@@ -3953,7 +4017,7 @@ H5VL__link_create(H5VL_link_create_type_t create_type, void *obj, const H5VL_loc
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'link create' method")
/* Call the corresponding VOL callback */
- if((cls->link_cls.create)(create_type, obj, loc_params, lcpl_id, lapl_id, dxpl_id, req) < 0)
+ if((cls->link_cls.create)(create_type, obj, loc_params, lcpl_id, lapl_id, dxpl_id, req, arguments) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, FAIL, "link create failed")
done:
@@ -3974,23 +4038,28 @@ done:
herr_t
H5VL_link_create(H5VL_link_create_type_t create_type, const H5VL_object_t *vol_obj,
const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id,
- void **req)
+ void **req, ...)
{
H5VL_object_t tmp_vol_obj; /* Temporary object token of */
+ va_list arguments; /* Argument list passed from the API call */
+ hbool_t arg_started = FALSE; /* Whether the va_list has been started */
hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
+ /* Start the varargs, so they can be copied */
+ HDva_start(arguments, req);
+ arg_started = TRUE;
+
/* Special case for hard links */
if(H5VL_LINK_CREATE_HARD == create_type && NULL == vol_obj->data) {
- H5P_genplist_t *plist; /* Property list pointer */
+ va_list tmp_arguments; /* Copy of argument list passed in */
- /* Get the VOL data pointer from the fapl */
- if(NULL == (plist = (H5P_genplist_t *)H5I_object(lcpl_id)))
- HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "not a file access property list")
- if(H5P_peek(plist, H5VL_PROP_LINK_TARGET, &tmp_vol_obj.data) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get VOL connector info")
+ /* Get the VOL data pointer from the varargs */
+ HDva_copy(tmp_arguments, arguments);
+ tmp_vol_obj.data = HDva_arg(tmp_arguments, void *);
+ HDva_end(tmp_arguments);
} /* end if */
else
/* Use the VOL object passed in */
@@ -4003,10 +4072,14 @@ H5VL_link_create(H5VL_link_create_type_t create_type, const H5VL_object_t *vol_o
vol_wrapper_set = TRUE;
/* Call the corresponding internal VOL routine */
- if(H5VL__link_create(create_type, vol_obj->data, loc_params, vol_obj->connector->cls, lcpl_id, lapl_id, dxpl_id, req) < 0)
+ if(H5VL__link_create(create_type, vol_obj->data, loc_params, vol_obj->connector->cls, lcpl_id, lapl_id, dxpl_id, req, arguments) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, FAIL, "link create failed")
done:
+ /* End access to the va_list, if we started it */
+ if(arg_started)
+ HDva_end(arguments);
+
/* Reset object wrapping info in API context */
if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0)
HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info")
@@ -4029,21 +4102,22 @@ done:
*/
herr_t
H5VLlink_create(H5VL_link_create_type_t create_type, void *obj, const H5VL_loc_params_t *loc_params,
- hid_t connector_id, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req)
+ hid_t connector_id, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req,
+ va_list arguments)
{
H5VL_class_t *cls; /* VOL connector's class struct */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API_NOINIT
- H5TRACE8("e", "Vk*x*xiiii**x", create_type, obj, loc_params, connector_id,
- lcpl_id, lapl_id, dxpl_id, req);
+ H5TRACE9("e", "Vk*x*xiiii**xx", create_type, obj, loc_params, connector_id,
+ lcpl_id, lapl_id, dxpl_id, req, arguments);
/* Get class pointer */
if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID")
/* Call the corresponding internal VOL routine */
- if(H5VL__link_create(create_type, obj, loc_params, cls, lcpl_id, lapl_id, dxpl_id, req) < 0)
+ if(H5VL__link_create(create_type, obj, loc_params, cls, lcpl_id, lapl_id, dxpl_id, req, arguments) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, FAIL, "unable to create link")
done:
diff --git a/src/H5VLconnector.h b/src/H5VLconnector.h
new file mode 100644
index 0000000..9de518f
--- /dev/null
+++ b/src/H5VLconnector.h
@@ -0,0 +1,417 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * This file contains public declarations for authoring VOL connectors.
+ */
+
+#ifndef _H5VLconnector_H
+#define _H5VLconnector_H
+
+/* Public headers needed by this file */
+#include "H5public.h" /* Generic Functions */
+#include "H5Apublic.h" /* Attributes */
+#include "H5ESpublic.h" /* Event Stack */
+#include "H5Fpublic.h" /* Files */
+#include "H5Ipublic.h" /* IDs */
+#include "H5Lpublic.h" /* Links */
+#include "H5Opublic.h" /* Objects */
+#include "H5Rpublic.h" /* References */
+#include "H5VLpublic.h" /* Virtual Object Layer */
+
+
+/*****************/
+/* Public Macros */
+/*****************/
+
+/* Capability flags for connector */
+#define H5VL_CAP_FLAG_NONE 0 /* No special connector capabilities */
+#define H5VL_CAP_FLAG_THREADSAFE 0x01 /* Connector is threadsafe */
+
+
+/*******************/
+/* Public Typedefs */
+/*******************/
+
+/* types for attribute GET callback */
+typedef enum H5VL_attr_get_t {
+ H5VL_ATTR_GET_ACPL, /* creation property list */
+ H5VL_ATTR_GET_INFO, /* info */
+ H5VL_ATTR_GET_NAME, /* access property list */
+ H5VL_ATTR_GET_SPACE, /* dataspace */
+ H5VL_ATTR_GET_STORAGE_SIZE, /* storage size */
+ H5VL_ATTR_GET_TYPE /* datatype */
+} H5VL_attr_get_t;
+
+/* types for attribute SPECFIC callback */
+typedef enum H5VL_attr_specific_t {
+ H5VL_ATTR_DELETE, /* H5Adelete(_by_name/idx) */
+ H5VL_ATTR_EXISTS, /* H5Aexists(_by_name) */
+ H5VL_ATTR_ITER, /* H5Aiterate(_by_name) */
+ H5VL_ATTR_RENAME /* H5Arename(_by_name) */
+} H5VL_attr_specific_t;
+
+/* types for dataset GET callback */
+typedef enum H5VL_dataset_get_t {
+ H5VL_DATASET_GET_DAPL, /* access property list */
+ H5VL_DATASET_GET_DCPL, /* creation property list */
+ H5VL_DATASET_GET_OFFSET, /* offset */
+ H5VL_DATASET_GET_SPACE, /* dataspace */
+ H5VL_DATASET_GET_SPACE_STATUS, /* space status */
+ H5VL_DATASET_GET_STORAGE_SIZE, /* storage size */
+ H5VL_DATASET_GET_TYPE /* datatype */
+} H5VL_dataset_get_t;
+
+/* types for dataset SPECFIC callback */
+typedef enum H5VL_dataset_specific_t {
+ H5VL_DATASET_SET_EXTENT, /* H5Dset_extent */
+ H5VL_DATASET_FLUSH, /* H5Dflush */
+ H5VL_DATASET_REFRESH /* H5Drefresh */
+} H5VL_dataset_specific_t;
+
+/* types for datatype GET callback */
+typedef enum H5VL_datatype_get_t {
+ H5VL_DATATYPE_GET_BINARY, /* get serialized form of transient type */
+ H5VL_DATATYPE_GET_TCPL /* datatype creation property list */
+} H5VL_datatype_get_t;
+
+/* types for datatype SPECFIC callback */
+typedef enum H5VL_datatype_specific_t {
+ H5VL_DATATYPE_FLUSH,
+ H5VL_DATATYPE_REFRESH
+} H5VL_datatype_specific_t;
+
+/* types for file GET callback */
+typedef enum H5VL_file_get_t {
+ H5VL_FILE_GET_FAPL, /* file access property list */
+ H5VL_FILE_GET_FCPL, /* file creation property list */
+ H5VL_FILE_GET_INTENT, /* file intent */
+ H5VL_FILE_GET_FILENO, /* file number */
+ H5VL_FILE_GET_NAME, /* file name */
+ H5VL_FILE_GET_OBJ_COUNT, /* object count in file */
+ H5VL_FILE_GET_OBJ_IDS /* object ids in file */
+} H5VL_file_get_t;
+
+/* types for file SPECIFIC callback */
+typedef enum H5VL_file_specific_t {
+ H5VL_FILE_FLUSH, /* Flush file */
+ H5VL_FILE_REOPEN, /* Reopen the file */
+ H5VL_FILE_MOUNT, /* Mount a file */
+ H5VL_FILE_UNMOUNT, /* Unmount a file */
+ H5VL_FILE_IS_ACCESSIBLE, /* Check if a file is accessible */
+ H5VL_FILE_DELETE /* Delete a file */
+} H5VL_file_specific_t;
+
+/* types for group GET callback */
+typedef enum H5VL_group_get_t {
+ H5VL_GROUP_GET_GCPL, /* group creation property list */
+ H5VL_GROUP_GET_INFO /* group info */
+} H5VL_group_get_t;
+
+/* types for group SPECFIC callback */
+typedef enum H5VL_group_specific_t {
+ H5VL_GROUP_FLUSH,
+ H5VL_GROUP_REFRESH
+} H5VL_group_specific_t;
+
+/* link create types for VOL */
+typedef enum H5VL_link_create_type_t {
+ H5VL_LINK_CREATE_HARD,
+ H5VL_LINK_CREATE_SOFT,
+ H5VL_LINK_CREATE_UD
+} H5VL_link_create_type_t;
+
+/* types for link GET callback */
+typedef enum H5VL_link_get_t {
+ H5VL_LINK_GET_INFO, /* link info */
+ H5VL_LINK_GET_NAME, /* link name */
+ H5VL_LINK_GET_VAL /* link value */
+} H5VL_link_get_t;
+
+/* types for link SPECIFIC callback */
+typedef enum H5VL_link_specific_t {
+ H5VL_LINK_DELETE, /* H5Ldelete(_by_idx) */
+ H5VL_LINK_EXISTS, /* link existence */
+ H5VL_LINK_ITER /* H5Literate/visit(_by_name) */
+} H5VL_link_specific_t;
+
+/* types for object GET callback */
+typedef enum H5VL_object_get_t {
+ H5VL_REF_GET_NAME, /* object name, for reference */
+ H5VL_REF_GET_REGION, /* dataspace of region */
+ H5VL_REF_GET_TYPE, /* type of object */
+ H5VL_OBJECT_GET_NAME /* object name */
+} H5VL_object_get_t;
+
+/* types for object SPECIFIC callback */
+typedef enum H5VL_object_specific_t {
+ H5VL_OBJECT_CHANGE_REF_COUNT, /* H5Oincr/decr_refcount */
+ H5VL_OBJECT_EXISTS, /* H5Oexists_by_name */
+ H5VL_OBJECT_VISIT, /* H5Ovisit(_by_name) */
+ H5VL_REF_CREATE, /* H5Rcreate */
+ H5VL_OBJECT_FLUSH, /* H5{D|G|O|T}flush */
+ H5VL_OBJECT_REFRESH /* H5{D|G|O|T}refresh */
+} H5VL_object_specific_t;
+
+/* types for async request SPECIFIC callback */
+typedef enum H5VL_request_specific_t {
+ H5VL_REQUEST_WAITANY, /* Wait until any request completes */
+ H5VL_REQUEST_WAITSOME, /* Wait until at least one requesst completes */
+ H5VL_REQUEST_WAITALL /* Wait until all requests complete */
+} H5VL_request_specific_t;
+
+/* types for different ways that objects are located in an HDF5 container */
+typedef enum H5VL_loc_type_t {
+ H5VL_OBJECT_BY_SELF,
+ H5VL_OBJECT_BY_NAME,
+ H5VL_OBJECT_BY_IDX,
+ H5VL_OBJECT_BY_ADDR,
+ H5VL_OBJECT_BY_REF
+} H5VL_loc_type_t;
+
+struct H5VL_loc_by_name {
+ const char *name;
+ hid_t lapl_id;
+};
+
+struct H5VL_loc_by_idx {
+ const char *name;
+ H5_index_t idx_type;
+ H5_iter_order_t order;
+ hsize_t n;
+ hid_t lapl_id;
+};
+
+struct H5VL_loc_by_addr {
+ haddr_t addr;
+};
+
+struct H5VL_loc_by_ref {
+ H5R_type_t ref_type;
+ const void *_ref;
+ hid_t lapl_id;
+};
+
+/* Structure to hold parameters for object locations.
+ * either: BY_ADDR, BY_ID, BY_NAME, BY_IDX, BY_REF
+ *
+ * Note: Leave loc_by_addr as the first union member so we
+ * can perform the simplest initialization of the struct
+ * without raising warnings.
+ */
+typedef struct H5VL_loc_params_t {
+ H5I_type_t obj_type;
+ H5VL_loc_type_t type;
+ union{
+ struct H5VL_loc_by_addr loc_by_addr;
+ struct H5VL_loc_by_name loc_by_name;
+ struct H5VL_loc_by_idx loc_by_idx;
+ struct H5VL_loc_by_ref loc_by_ref;
+ } loc_data;
+} H5VL_loc_params_t;
+
+/* VOL connector info fields & callbacks */
+typedef struct H5VL_info_class_t {
+ size_t size; /* Size of the VOL info */
+ void * (*copy)(const void *info); /* Callback to create a copy of the VOL info */
+ herr_t (*cmp)(int *cmp_value, const void *info1, const void *info2); /* Callback to compare VOL info */
+ herr_t (*free)(void *info); /* Callback to release a VOL info */
+ herr_t (*to_str)(const void *info, char **str); /* Callback to serialize connector's info into a string */
+ herr_t (*from_str)(const char *str, void **info); /* Callback to deserialize a string into connector's info */
+} H5VL_info_class_t;
+
+/* VOL object wrap / retrieval callbacks */
+/* (These only need to be implemented by "pass through" VOL connectors) */
+typedef struct H5VL_wrap_class_t {
+ void * (*get_object)(const void *obj); /* Callback to retrieve underlying object */
+ herr_t (*get_wrap_ctx)(const void *obj, void **wrap_ctx); /* Callback to retrieve the object wrapping context for the connector */
+ void * (*wrap_object)(void *obj, H5I_type_t obj_type, void *wrap_ctx); /* Callback to wrap a library object */
+ void * (*unwrap_object)(void *obj); /* Callback to unwrap a library object */
+ herr_t (*free_wrap_ctx)(void *wrap_ctx); /* Callback to release the object wrapping context for the connector */
+} H5VL_wrap_class_t;
+
+/* H5A routines */
+typedef struct H5VL_attr_class_t {
+ void *(*create)(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name,
+ hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t aapl_id,
+ hid_t dxpl_id, void **req);
+ void *(*open)(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name,
+ hid_t aapl_id, hid_t dxpl_id, void **req);
+ herr_t (*read)(void *attr, hid_t mem_type_id, void *buf, hid_t dxpl_id, void **req);
+ herr_t (*write)(void *attr, hid_t mem_type_id, const void *buf, hid_t dxpl_id, void **req);
+ herr_t (*get)(void *obj, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, va_list arguments);
+ herr_t (*specific)(void *obj, const H5VL_loc_params_t *loc_params, H5VL_attr_specific_t specific_type,
+ hid_t dxpl_id, void **req, va_list arguments);
+ herr_t (*optional)(void *obj, hid_t dxpl_id, void **req, va_list arguments);
+ herr_t (*close) (void *attr, hid_t dxpl_id, void **req);
+} H5VL_attr_class_t;
+
+/* H5D routines */
+typedef struct H5VL_dataset_class_t {
+ void *(*create)(void *obj, const H5VL_loc_params_t *loc_params, const char *name,
+ hid_t lcpl_id, hid_t type_id, hid_t space_id, hid_t dcpl_id,
+ hid_t dapl_id, hid_t dxpl_id, void **req);
+ void *(*open)(void *obj, const H5VL_loc_params_t *loc_params, const char *name,
+ hid_t dapl_id, hid_t dxpl_id, void **req);
+ herr_t (*read)(void *dset, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id,
+ hid_t xfer_plist_id, void * buf, void **req);
+ herr_t (*write)(void *dset, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id,
+ hid_t xfer_plist_id, const void * buf, void **req);
+ herr_t (*get)(void *obj, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, va_list arguments);
+ herr_t (*specific)(void *obj, H5VL_dataset_specific_t specific_type,
+ hid_t dxpl_id, void **req, va_list arguments);
+ herr_t (*optional)(void *obj, hid_t dxpl_id, void **req, va_list arguments);
+ herr_t (*close) (void *dset, hid_t dxpl_id, void **req);
+} H5VL_dataset_class_t;
+
+/* H5T routines*/
+typedef struct H5VL_datatype_class_t {
+ void *(*commit)(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t type_id,
+ hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, void **req);
+ void *(*open)(void *obj, const H5VL_loc_params_t *loc_params, const char * name,
+ hid_t tapl_id, hid_t dxpl_id, void **req);
+ herr_t (*get) (void *obj, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, va_list arguments);
+ herr_t (*specific)(void *obj, H5VL_datatype_specific_t specific_type,
+ hid_t dxpl_id, void **req, va_list arguments);
+ herr_t (*optional)(void *obj, hid_t dxpl_id, void **req, va_list arguments);
+ herr_t (*close) (void *dt, hid_t dxpl_id, void **req);
+} H5VL_datatype_class_t;
+
+/* H5F routines */
+typedef struct H5VL_file_class_t {
+ void *(*create)(const char *name, unsigned flags, hid_t fcpl_id,
+ hid_t fapl_id, hid_t dxpl_id, void **req);
+ void *(*open)(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req);
+ herr_t (*get)(void *obj, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, va_list arguments);
+ herr_t (*specific)(void *obj, H5VL_file_specific_t specific_type,
+ hid_t dxpl_id, void **req, va_list arguments);
+ herr_t (*optional)(void *obj, hid_t dxpl_id, void **req, va_list arguments);
+ herr_t (*close) (void *file, hid_t dxpl_id, void **req);
+} H5VL_file_class_t;
+
+/* H5G routines */
+typedef struct H5VL_group_class_t {
+ void *(*create)(void *obj, const H5VL_loc_params_t *loc_params, const char *name,
+ hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req);
+ void *(*open)(void *obj, const H5VL_loc_params_t *loc_params, const char *name,
+ hid_t gapl_id, hid_t dxpl_id, void **req);
+ herr_t (*get)(void *obj, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, va_list arguments);
+ herr_t (*specific)(void *obj, H5VL_group_specific_t specific_type,
+ hid_t dxpl_id, void **req, va_list arguments);
+ herr_t (*optional)(void *obj, hid_t dxpl_id, void **req, va_list arguments);
+ herr_t (*close) (void *grp, hid_t dxpl_id, void **req);
+} H5VL_group_class_t;
+
+/* H5L routines */
+typedef struct H5VL_link_class_t {
+ herr_t (*create)(H5VL_link_create_type_t create_type, void *obj, const H5VL_loc_params_t *loc_params,
+ hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req, va_list argumenmts);
+ herr_t (*copy)(void *src_obj, const H5VL_loc_params_t *loc_params1,
+ void *dst_obj, const H5VL_loc_params_t *loc_params2,
+ hid_t lcpl, hid_t lapl, hid_t dxpl_id, void **req);
+ herr_t (*move)(void *src_obj, const H5VL_loc_params_t *loc_params1,
+ void *dst_obj, const H5VL_loc_params_t *loc_params2,
+ hid_t lcpl, hid_t lapl, hid_t dxpl_id, void **req);
+ herr_t (*get)(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_t get_type,
+ hid_t dxpl_id, void **req, va_list arguments);
+ herr_t (*specific)(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_specific_t specific_type,
+ hid_t dxpl_id, void **req, va_list arguments);
+ herr_t (*optional)(void *obj, hid_t dxpl_id, void **req, va_list arguments);
+} H5VL_link_class_t;
+
+/* H5O routines */
+typedef struct H5VL_object_class_t {
+ void *(*open)(void *obj, const H5VL_loc_params_t *loc_params, H5I_type_t *opened_type,
+ hid_t dxpl_id, void **req);
+ herr_t (*copy)(void *src_obj, const H5VL_loc_params_t *loc_params1, const char *src_name,
+ void *dst_obj, const H5VL_loc_params_t *loc_params2, const char *dst_name,
+ hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req);
+ herr_t (*get)(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_get_t get_type,
+ hid_t dxpl_id, void **req, va_list arguments);
+ herr_t (*specific)(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_specific_t specific_type,
+ hid_t dxpl_id, void **req, va_list arguments);
+ herr_t (*optional)(void *obj, hid_t dxpl_id, void **req, va_list arguments);
+} H5VL_object_class_t;
+
+/* Asynchronous request 'notify' callback */
+typedef herr_t (*H5VL_request_notify_t)(void *ctx, H5ES_status_t status);
+
+/* Async request operation routines */
+typedef struct H5VL_request_class_t {
+ herr_t (*wait)(void *req, uint64_t timeout, H5ES_status_t *status);
+ herr_t (*notify)(void *req, H5VL_request_notify_t cb, void *ctx);
+ herr_t (*cancel)(void *req);
+ herr_t (*specific)(void *req, H5VL_request_specific_t specific_type, va_list arguments);
+ herr_t (*optional)(void *req, va_list arguments);
+ herr_t (*free)(void *req);
+} H5VL_request_class_t;
+
+/*
+ * VOL connector identifiers. Values 0 through 255 are for connectors defined
+ * by the HDF5 library. Values 256 through 511 are available for testing new
+ * filters. Subsequent values should be obtained from the HDF5 development
+ * team at help@hdfgroup.org.
+ */
+typedef int H5VL_class_value_t;
+
+/* Class information for each VOL connector */
+typedef struct H5VL_class_t {
+ /* Overall connector fields & callbacks */
+ unsigned int version; /* VOL connector class struct version # */
+ H5VL_class_value_t value; /* Value to identify connector */
+ const char *name; /* Connector name (MUST be unique!) */
+ unsigned cap_flags; /* Capability flags for connector */
+ herr_t (*initialize)(hid_t vipl_id); /* Connector initialization callback */
+ herr_t (*terminate)(void); /* Connector termination callback */
+
+ /* VOL framework */
+ H5VL_info_class_t info_cls; /* VOL info fields & callbacks */
+ H5VL_wrap_class_t wrap_cls; /* VOL object wrap / retrieval callbacks */
+
+ /* Data Model */
+ H5VL_attr_class_t attr_cls; /* Attribute (H5A*) class callbacks */
+ H5VL_dataset_class_t dataset_cls; /* Dataset (H5D*) class callbacks */
+ H5VL_datatype_class_t datatype_cls; /* Datatype (H5T*) class callbacks */
+ H5VL_file_class_t file_cls; /* File (H5F*) class callbacks */
+ H5VL_group_class_t group_cls; /* Group (H5G*) class callbacks */
+ H5VL_link_class_t link_cls; /* Link (H5L*) class callbacks */
+ H5VL_object_class_t object_cls; /* Object (H5O*) class callbacks */
+
+ /* Services */
+ H5VL_request_class_t request_cls; /* Asynchronous request class callbacks */
+
+ /* Catch-all */
+ herr_t (*optional)(void *obj, hid_t dxpl_id, void **req, va_list arguments); /* Optional callback */
+} H5VL_class_t;
+
+
+/********************/
+/* Public Variables */
+/********************/
+
+/*********************/
+/* Public Prototypes */
+/*********************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Helper routines for VOL connector authors */
+H5_DLL void *H5VLobject(hid_t obj_id);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _H5VLconnector_H */
+
diff --git a/src/H5VLconnector_passthru.h b/src/H5VLconnector_passthru.h
new file mode 100644
index 0000000..9a2bd52
--- /dev/null
+++ b/src/H5VLconnector_passthru.h
@@ -0,0 +1,166 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * This file contains public declarations for authoring VOL connectors
+ * which act as "passthrough" connectors that forward their API calls to
+ * an underlying connector.
+ *
+ * An example of this might be a logging connector, which creates log messages
+ * and then passes the call on to an underlying VOL connector.
+ *
+ * The functionality required to implement such a connector is specialized
+ * and non-trivial so it has been split into this header in an effort to keep
+ * the H5VLconnector.h header easier to understand.
+ */
+
+#ifndef _H5VLconnector_passthru_H
+#define _H5VLconnector_passthru_H
+
+/* Public headers needed by this file */
+#include "H5public.h" /* Generic Functions */
+#include "H5Ipublic.h" /* IDs */
+#include "H5VLpublic.h" /* Virtual Object Layer */
+
+/* Semi-public headers mainly for VOL connector authors */
+#include "H5VLconnector.h"
+
+
+/*****************/
+/* Public Macros */
+/*****************/
+
+/*******************/
+/* Public Typedefs */
+/*******************/
+
+/********************/
+/* Public Variables */
+/********************/
+
+/*********************/
+/* Public Prototypes */
+/*********************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Helper routines for VOL connector authors */
+H5_DLL herr_t H5VLcmp_connector_cls(int *cmp, hid_t connector_id1, hid_t connector_id2);
+H5_DLL hid_t H5VLwrap_register(void *obj, H5I_type_t type);
+H5_DLL herr_t H5VLretrieve_lib_state(void **state);
+H5_DLL herr_t H5VLrestore_lib_state(const void *state);
+H5_DLL herr_t H5VLreset_lib_state(void);
+H5_DLL herr_t H5VLfree_lib_state(void *state);
+
+/* Pass-through callbacks */
+H5_DLL void *H5VLget_object(void *obj, hid_t connector_id);
+H5_DLL herr_t H5VLget_wrap_ctx(void *obj, hid_t connector_id, void **wrap_ctx);
+H5_DLL void *H5VLwrap_object(void *obj, H5I_type_t obj_type, hid_t connector_id,
+ void *wrap_ctx);
+H5_DLL void *H5VLunwrap_object(void *obj, hid_t connector_id);
+H5_DLL herr_t H5VLfree_wrap_ctx(void *wrap_ctx, hid_t connector_id);
+
+/* Public wrappers for generic callbacks */
+H5_DLL herr_t H5VLinitialize(hid_t connector_id, hid_t vipl_id);
+H5_DLL herr_t H5VLterminate(hid_t connector_id);
+H5_DLL herr_t H5VLget_cap_flags(hid_t connector_id, unsigned *cap_flags);
+H5_DLL herr_t H5VLget_value(hid_t connector_id, H5VL_class_value_t *conn_value);
+
+/* Public wrappers for info fields and callbacks */
+H5_DLL herr_t H5VLcopy_connector_info(hid_t connector_id, void **dst_vol_info, void *src_vol_info);
+H5_DLL herr_t H5VLcmp_connector_info(int *cmp, hid_t connector_id, const void *info1,
+ const void *info2);
+H5_DLL herr_t H5VLfree_connector_info(hid_t connector_id, void *vol_info);
+H5_DLL herr_t H5VLconnector_info_to_str(const void *info, hid_t connector_id, char **str);
+H5_DLL herr_t H5VLconnector_str_to_info(const char *str, hid_t connector_id, void **info);
+
+/* Public wrappers for attribute callbacks */
+H5_DLL void *H5VLattr_create(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *attr_name, hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req);
+H5_DLL void *H5VLattr_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, hid_t aapl_id, hid_t dxpl_id, void **req);
+H5_DLL herr_t H5VLattr_read(void *attr, hid_t connector_id, hid_t dtype_id, void *buf, hid_t dxpl_id, void **req);
+H5_DLL herr_t H5VLattr_write(void *attr, hid_t connector_id, hid_t dtype_id, const void *buf, hid_t dxpl_id, void **req);
+H5_DLL herr_t H5VLattr_get(void *obj, hid_t connector_id, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, va_list arguments);
+H5_DLL herr_t H5VLattr_specific(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments);
+H5_DLL herr_t H5VLattr_optional(void *obj, hid_t connector_id, hid_t dxpl_id, void **req, va_list arguments);
+H5_DLL herr_t H5VLattr_close(void *attr, hid_t connector_id, hid_t dxpl_id, void **req);
+
+/* Public wrappers for dataset callbacks */
+H5_DLL void *H5VLdataset_create(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, hid_t lcpl_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req);
+H5_DLL void *H5VLdataset_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, hid_t dapl_id, hid_t dxpl_id, void **req);
+H5_DLL herr_t H5VLdataset_read(void *dset, hid_t connector_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, void *buf, void **req);
+H5_DLL herr_t H5VLdataset_write(void *dset, hid_t connector_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, const void *buf, void **req);
+H5_DLL herr_t H5VLdataset_get(void *dset, hid_t connector_id, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, va_list arguments);
+H5_DLL herr_t H5VLdataset_specific(void *obj, hid_t connector_id, H5VL_dataset_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments);
+H5_DLL herr_t H5VLdataset_optional(void *obj, hid_t connector_id, hid_t dxpl_id, void **req, va_list arguments);
+H5_DLL herr_t H5VLdataset_close(void *dset, hid_t connector_id, hid_t dxpl_id, void **req);
+
+/* Public wrappers for file callbacks */
+H5_DLL void *H5VLfile_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req);
+H5_DLL void *H5VLfile_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req);
+H5_DLL herr_t H5VLfile_get(void *file, hid_t connector_id, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, va_list arguments);
+H5_DLL herr_t H5VLfile_specific(void *obj, hid_t connector_id, H5VL_file_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments);
+H5_DLL herr_t H5VLfile_optional(void *obj, hid_t connector_id, hid_t dxpl_id, void **req, va_list arguments);
+H5_DLL herr_t H5VLfile_close(void *file, hid_t connector_id, hid_t dxpl_id, void **req);
+
+/* Public wrappers for group callbacks */
+H5_DLL void *H5VLgroup_create(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req);
+H5_DLL void *H5VLgroup_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, hid_t gapl_id, hid_t dxpl_id, void **req);
+H5_DLL herr_t H5VLgroup_get(void *obj, hid_t connector_id, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, va_list arguments);
+H5_DLL herr_t H5VLgroup_specific(void *obj, hid_t connector_id, H5VL_group_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments);
+H5_DLL herr_t H5VLgroup_optional(void *obj, hid_t connector_id, hid_t dxpl_id, void **req, va_list arguments);
+H5_DLL herr_t H5VLgroup_close(void *grp, hid_t connector_id, hid_t dxpl_id, void **req);
+
+/* Public wrappers for link callbacks */
+H5_DLL herr_t H5VLlink_create(H5VL_link_create_type_t create_type, void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req, va_list arguments);
+H5_DLL herr_t H5VLlink_copy(void *src_obj, const H5VL_loc_params_t *loc_params1,
+ void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t connector_id,
+ hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req);
+H5_DLL herr_t H5VLlink_move(void *src_obj, const H5VL_loc_params_t *loc_params1,
+ void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t connector_id,
+ hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req);
+H5_DLL herr_t H5VLlink_get(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, H5VL_link_get_t get_type, hid_t dxpl_id, void **req, va_list arguments);
+H5_DLL herr_t H5VLlink_specific(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments);
+H5_DLL herr_t H5VLlink_optional(void *obj, hid_t connector_id, hid_t dxpl_id, void **req, va_list arguments);
+
+/* Public wrappers for object callbacks */
+H5_DLL void *H5VLobject_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, H5I_type_t *opened_type, hid_t dxpl_id, void **req);
+H5_DLL herr_t H5VLobject_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, const char *src_name,
+ void *dst_obj, const H5VL_loc_params_t *loc_params2, const char *dst_name,
+ hid_t connector_id, hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req);
+H5_DLL herr_t H5VLobject_get(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, H5VL_object_get_t get_type, hid_t dxpl_id, void **req, va_list arguments);
+H5_DLL herr_t H5VLobject_specific(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments);
+H5_DLL herr_t H5VLobject_optional(void *obj, hid_t connector_id, hid_t dxpl_id, void **req, va_list arguments);
+
+/* Public wrappers for named datatype callbacks */
+H5_DLL void *H5VLdatatype_commit(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, void **req);
+H5_DLL void *H5VLdatatype_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, hid_t tapl_id, hid_t dxpl_id, void **req);
+H5_DLL herr_t H5VLdatatype_get(void *dt, hid_t connector_id, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, va_list arguments);
+H5_DLL herr_t H5VLdatatype_specific(void *obj, hid_t connector_id, H5VL_datatype_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments);
+H5_DLL herr_t H5VLdatatype_optional(void *obj, hid_t connector_id, hid_t dxpl_id, void **req, va_list arguments);
+H5_DLL herr_t H5VLdatatype_close(void *dt, hid_t connector_id, hid_t dxpl_id, void **req);
+
+/* Public wrappers for asynchronous request callbacks */
+H5_DLL herr_t H5VLrequest_wait(void *req, hid_t connector_id, uint64_t timeout, H5ES_status_t *status);
+H5_DLL herr_t H5VLrequest_notify(void *req, hid_t connector_id, H5VL_request_notify_t cb, void *ctx);
+H5_DLL herr_t H5VLrequest_cancel(void *req, hid_t connector_id);
+H5_DLL herr_t H5VLrequest_specific(void *req, hid_t connector_id, H5VL_request_specific_t specific_type, va_list arguments);
+H5_DLL herr_t H5VLrequest_optional(void *req, hid_t connector_id, va_list arguments);
+H5_DLL herr_t H5VLrequest_free(void *req, hid_t connector_id);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _H5VLconnector_passthru_H */
+
diff --git a/src/H5VLint.c b/src/H5VLint.c
index f22fdb6..884b2f6 100644
--- a/src/H5VLint.c
+++ b/src/H5VLint.c
@@ -29,14 +29,19 @@
/* Headers */
/***********/
-#include "H5private.h" /* Generic Functions */
-#include "H5CXprivate.h" /* API Contexts */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5FLprivate.h" /* Free lists */
-#include "H5Iprivate.h" /* IDs */
-#include "H5MMprivate.h" /* Memory management */
-#include "H5Tprivate.h" /* Datatypes */
-#include "H5VLpkg.h" /* Virtual Object Layer */
+#include "H5private.h" /* Generic Functions */
+#include "H5CXprivate.h" /* API Contexts */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5FLprivate.h" /* Free lists */
+#include "H5Iprivate.h" /* IDs */
+#include "H5MMprivate.h" /* Memory management */
+#include "H5PLprivate.h" /* Plugins */
+#include "H5Tprivate.h" /* Datatypes */
+#include "H5VLpkg.h" /* Virtual Object Layer */
+
+/* VOL connectors */
+#include "H5VLnative.h" /* Native VOL connector */
+#include "H5VLpassthru.h" /* Pass-through VOL connector */
/****************/
@@ -51,10 +56,28 @@
/* Object wrapping context info */
typedef struct H5VL_wrap_ctx_t {
unsigned rc; /* Ref. count for the # of times the context was set / reset */
- const H5VL_t *connector; /* VOL connector for "outermost" class to start wrap */
+ H5VL_t *connector; /* VOL connector for "outermost" class to start wrap */
void *obj_wrap_ctx; /* "wrap context" for outermost connector */
} H5VL_wrap_ctx_t;
+/* Information needed for iterating over the registered VOL connector hid_t IDs.
+ * The name or value of the new VOL connector that is being registered is
+ * stored in the name (or value) field and the found_id field is initialized to
+ * H5I_INVALID_HID (-1). If we find a VOL connector with the same name / value,
+ * we set the found_id field to the existing ID for return to the function.
+ */
+typedef struct {
+ /* IN */
+ H5VL_get_connector_kind_t kind; /* Which kind of connector search to make */
+ union {
+ const char *name; /* The name of the VOL connector to check */
+ H5VL_class_value_t value; /* The value of the VOL connector to check */
+ } u;
+
+ /* OUT */
+ hid_t found_id; /* The connector ID, if we found a match */
+} H5VL_get_connector_ud_t;
+
/********************/
/* Package Typedefs */
@@ -65,10 +88,15 @@ typedef struct H5VL_wrap_ctx_t {
/* Local Prototypes */
/********************/
static herr_t H5VL__free_cls(H5VL_class_t *cls);
+static int H5VL__get_connector_cb(void *obj, hid_t id, void *_op_data);
+static herr_t H5VL__set_def_conn(void);
static void *H5VL__wrap_obj(void *obj, H5I_type_t obj_type);
static H5VL_object_t *H5VL__new_vol_obj(H5I_type_t type, void *object,
H5VL_t *vol_connector, hbool_t wrap_obj);
+static int64_t H5VL__conn_inc_rc(H5VL_t *connector);
+static int64_t H5VL__conn_dec_rc(H5VL_t *connector);
static void *H5VL__object(hid_t id, H5I_type_t obj_type);
+static herr_t H5VL__free_vol_wrapper(H5VL_wrap_ctx_t *vol_wrap_ctx);
/*********************/
@@ -83,6 +111,7 @@ hbool_t H5_PKG_INIT_VAR = FALSE;
/* Library Private Variables */
/*****************************/
+
/*******************/
/* Local Variables */
/*******************/
@@ -107,21 +136,27 @@ H5FL_DEFINE(H5VL_object_t);
/* Declare a free list to manage the H5VL_wrap_ctx_t struct */
H5FL_DEFINE_STATIC(H5VL_wrap_ctx_t);
+/* Default VOL connector */
+static H5VL_connector_prop_t H5VL_def_conn_s = {-1, NULL};
+
/*-------------------------------------------------------------------------
- * Function: H5VL_init
+ * Function: H5VL_init_phase1
*
- * Purpose: Initialize the interface from some other package
+ * Purpose: Initialize the interface from some other package. This should
+ * be followed with a call to H5VL_init_phase2 after the H5P
+ * interface is completely set up, finish setting up the H5VL
+ * information.
*
- * Return: Success: Non-negative
*
+ * Return: Success: Non-negative
* Failure: Negative
*
*-------------------------------------------------------------------------
*/
herr_t
-H5VL_init(void)
+H5VL_init_phase1(void)
{
herr_t ret_value = SUCCEED; /* Return value */
@@ -131,7 +166,36 @@ H5VL_init(void)
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5VL_init() */
+} /* end H5VL_init_phase1() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5VL_init_phase2
+ *
+ * Purpose: Finish initializing the interface from some other package.
+ *
+ * Note: This is broken out as a separate routine to avoid a circular
+ * reference with the H5P package.
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5VL_init_phase2(void)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* Set up the default VOL connector in the default FAPL */
+ if(H5VL__set_def_conn() < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "unable to set default VOL connector")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5VL_init_phase2() */
/*-------------------------------------------------------------------------
@@ -148,12 +212,12 @@ done:
herr_t
H5VL__init_package(void)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
/* Initialize the atom group for the VL IDs */
- if (H5I_register_type(H5I_VOL_CLS) < 0)
+ if(H5I_register_type(H5I_VOL_CLS) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to initialize H5VL interface")
done:
@@ -180,17 +244,27 @@ H5VL_term_package(void)
FUNC_ENTER_NOAPI_NOINIT_NOERR
if(H5_PKG_INIT_VAR) {
- if (H5I_nmembers(H5I_VOL) > 0) {
- (void)H5I_clear_type(H5I_VOL, FALSE, FALSE);
+ if(H5VL_def_conn_s.connector_id > 0) {
+ /* Release the default VOL connector */
+ (void)H5VL_conn_free(&H5VL_def_conn_s);
+ H5VL_def_conn_s.connector_id = -1;
+ H5VL_def_conn_s.connector_info = NULL;
n++;
} /* end if */
else {
- /* Destroy the VOL connector ID group */
- n += (H5I_dec_type_ref(H5I_VOL) > 0);
-
- /* Mark interface as closed */
- if (0 == n)
- H5_PKG_INIT_VAR = FALSE;
+ if(H5I_nmembers(H5I_VOL) > 0) {
+ /* Unregister all VOL connectors */
+ (void)H5I_clear_type(H5I_VOL, FALSE, FALSE);
+ n++;
+ } /* end if */
+ else {
+ /* Destroy the VOL connector ID group */
+ n += (H5I_dec_type_ref(H5I_VOL) > 0);
+
+ /* Mark interface as closed */
+ if(0 == n)
+ H5_PKG_INIT_VAR = FALSE;
+ } /* end else */
} /* end else */
} /* end if */
@@ -234,6 +308,182 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5VL__get_connector_cb
+ *
+ * Purpose: Callback routine to search through registered VOLs
+ *
+ * Return: Success: H5_ITER_STOP if the class and op_data name
+ * members match. H5_ITER_CONT otherwise.
+ * Failure: Can't fail
+ *
+ * Programmer: Dana Robinson
+ * June 22, 2017
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+H5VL__get_connector_cb(void *obj, hid_t id, void *_op_data)
+{
+ H5VL_get_connector_ud_t *op_data = (H5VL_get_connector_ud_t *)_op_data; /* User data for callback */
+ H5VL_class_t *cls = (H5VL_class_t *)obj;
+ int ret_value = H5_ITER_CONT; /* Callback return value */
+
+ FUNC_ENTER_STATIC_NOERR
+
+ if(H5VL_GET_CONNECTOR_BY_NAME == op_data->kind) {
+ if(0 == HDstrcmp(cls->name, op_data->u.name)) {
+ op_data->found_id = id;
+ ret_value = H5_ITER_STOP;
+ } /* end if */
+ } /* end if */
+ else {
+ HDassert(H5VL_GET_CONNECTOR_BY_VALUE == op_data->kind);
+ if(cls->value == op_data->u.value) {
+ op_data->found_id = id;
+ ret_value = H5_ITER_STOP;
+ } /* end if */
+ } /* end else */
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5VL__get_connector_cb() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5VL__set_def_conn
+ *
+ * Purpose: Parses a string that contains the default VOL connector for
+ * the library.
+ *
+ * Note: Usually from the environment variable "HDF5_VOL_CONNECTOR",
+ * but could be from elsewhere.
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Jordan Henderson
+ * November 2018
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5VL__set_def_conn(void)
+{
+ H5P_genplist_t *def_fapl; /* Default file access property list */
+ H5P_genclass_t *def_fapclass; /* Default file access property class */
+ const char *env_var; /* Environment variable for default VOL connector */
+ char *buf = NULL; /* Buffer for tokenizing string */
+ hid_t connector_id = -1; /* VOL conntector ID */
+ void *vol_info = NULL; /* VOL connector info */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_STATIC
+
+ /* Sanity check */
+ HDassert(H5VL_def_conn_s.connector_id == (-1));
+ HDassert(H5VL_def_conn_s.connector_info == NULL);
+
+ /* Check for environment variable set */
+ env_var = HDgetenv("HDF5_VOL_CONNECTOR");
+
+ /* Only parse the string if it's set */
+ if(env_var && *env_var) {
+ char *lasts = NULL; /* Context pointer for strtok_r() call */
+ const char *tok = NULL; /* Token from strtok_r call */
+ htri_t connector_is_registered; /* Whether connector is already registered */
+
+ /* Duplicate the string to parse, as it is modified as we go */
+ if(NULL == (buf = H5MM_strdup(env_var)))
+ HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, FAIL, "can't allocate memory for environment variable string")
+
+ /* Get the first 'word' of the environment variable.
+ * If it's nothing (environment variable was whitespace) return error.
+ */
+ if(NULL == (tok = HDstrtok_r(buf, " \t\n\r", &lasts)))
+ HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, FAIL, "VOL connector environment variable set empty?")
+
+ /* First, check to see if the connector is already registered */
+ if((connector_is_registered = H5VL__is_connector_registered(tok)) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't check if VOL connector already registered")
+ else if(connector_is_registered) {
+ /* Retrieve the ID of the already-registered VOL connector */
+ if((connector_id = H5VL__get_connector_id(tok, FALSE)) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get VOL connector ID")
+ } /* end else-if */
+ else {
+ /* Check for VOL connectors that ship with the library */
+ if(!HDstrcmp(tok, "native")) {
+ connector_id = H5VL_NATIVE;
+ if(H5I_inc_ref(connector_id, FALSE) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINC, FAIL, "can't increment VOL connector refcount")
+ } /* end if */
+ else if(!HDstrcmp(tok, "pass_through")) {
+ connector_id = H5VL_PASSTHRU;
+ if(H5I_inc_ref(connector_id, FALSE) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINC, FAIL, "can't increment VOL connector refcount")
+ } /* end else-if */
+ else {
+ /* Register the VOL connector */
+ /* (NOTE: No provisions for vipl_id currently) */
+ if((connector_id = H5VL__register_connector_by_name(tok, FALSE, H5P_DEFAULT)) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, FAIL, "can't register connector")
+ } /* end else */
+ } /* end else */
+
+ /* Was there any connector info specified in the environment variable? */
+ if(NULL != (tok = HDstrtok_r(NULL, " \t\n\r", &lasts)))
+ if(H5VL__connector_str_to_info(tok, connector_id, &vol_info) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTDECODE, FAIL, "can't deserialize connector info")
+
+ /* Set the default VOL connector */
+ H5VL_def_conn_s.connector_id = connector_id;
+ H5VL_def_conn_s.connector_info = vol_info;
+ } /* end if */
+ else {
+ /* Set the default VOL connector */
+ H5VL_def_conn_s.connector_id = H5_DEFAULT_VOL;
+ H5VL_def_conn_s.connector_info = NULL;
+
+ /* Increment the ref count on the default connector */
+ if(H5I_inc_ref(H5VL_def_conn_s.connector_id, FALSE) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINC, FAIL, "can't increment VOL connector refcount")
+ } /* end else */
+
+ /* Get default file access pclass */
+ if(NULL == (def_fapclass = (H5P_genclass_t *)H5I_object(H5P_FILE_ACCESS)))
+ HGOTO_ERROR(H5E_VOL, H5E_BADATOM, FAIL, "can't find object for default file access property class ID")
+
+ /* Change the default VOL for the default file access pclass */
+ if(H5P_reset_vol_class(def_fapclass, &H5VL_def_conn_s) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set default VOL connector for default file access property class")
+
+ /* Get default file access plist */
+ if(NULL == (def_fapl = (H5P_genplist_t *)H5I_object(H5P_FILE_ACCESS_DEFAULT)))
+ HGOTO_ERROR(H5E_VOL, H5E_BADATOM, FAIL, "can't find object for default fapl ID")
+
+ /* Change the default VOL for the default FAPL */
+ if(H5P_set_vol(def_fapl, H5VL_def_conn_s.connector_id, H5VL_def_conn_s.connector_info) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set default VOL connector for default FAPL")
+
+done:
+ /* Clean up on error */
+ if(ret_value < 0) {
+ if(vol_info)
+ if(H5VL_free_connector_info(connector_id, vol_info) < 0)
+ HDONE_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "can't free VOL connector info")
+ if(connector_id >= 0)
+ /* The H5VL_class_t struct will be freed by this function */
+ if(H5I_dec_ref(connector_id) < 0)
+ HDONE_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to unregister VOL connector")
+ } /* end if */
+
+ /* Clean up */
+ H5MM_xfree(buf);
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5VL__set_def_conn() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5VL__wrap_obj
*
* Purpose: Wraps a library object with possible VOL connector wrappers, to
@@ -317,7 +567,7 @@ H5VL__new_vol_obj(H5I_type_t type, void *object, H5VL_t *vol_connector, hbool_t
new_vol_obj->data = object;
/* Bump the reference count on the VOL connector */
- vol_connector->nrefs++;
+ H5VL__conn_inc_rc(vol_connector);
/* If this is a datatype, we have to hide the VOL object under the H5T_t pointer */
if(H5I_DATATYPE == type) {
@@ -393,29 +643,22 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5VL_conn_free(const H5VL_connector_prop_t *info)
+H5VL_conn_free(const H5VL_connector_prop_t *connector_prop)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
- if(info) {
+ if(connector_prop) {
/* Free the connector info (if it exists) and decrement the ID */
- if(info->connector_id > 0) {
- if(info->connector_info) {
- H5VL_class_t *connector; /* Pointer to connector */
-
- /* Retrieve the connector for the ID */
- if(NULL == (connector = (H5VL_class_t *)H5I_object(info->connector_id)))
- HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "not a VOL connector ID")
-
+ if(connector_prop->connector_id > 0) {
+ if(connector_prop->connector_info)
/* Free the connector info */
- if(H5VL_free_connector_info(connector, (void *)info->connector_info) < 0) /* Casting away const OK - QAK */
+ if(H5VL_free_connector_info(connector_prop->connector_id, (void *)connector_prop->connector_info) < 0) /* Casting away const OK - QAK */
HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to release VOL connector info object")
- } /* end if */
/* Decrement reference count for connector ID */
- if(H5I_dec_ref(info->connector_id) < 0)
+ if(H5I_dec_ref(connector_prop->connector_id) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "can't decrement reference count for connector ID")
} /* end if */
} /* end if */
@@ -550,6 +793,76 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5VL__conn_inc_rc
+ *
+ * Purpose: Wrapper to increment the ref. count on a connector.
+ *
+ * Return: Current ref. count (can't fail)
+ *
+ * Programmer: Quincey Koziol
+ * February 23, 2019
+ *
+ *-------------------------------------------------------------------------
+ */
+static int64_t
+H5VL__conn_inc_rc(H5VL_t *connector)
+{
+ FUNC_ENTER_STATIC_NOERR
+
+ /* Check arguments */
+ HDassert(connector);
+
+ /* Increment refcount for connector */
+ connector->nrefs++;
+
+ FUNC_LEAVE_NOAPI(connector->nrefs)
+} /* end H5VL__conn_inc_rc() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5VL__conn_dec_rc
+ *
+ * Purpose: Wrapper to decrement the ref. count on a connector.
+ *
+ * Return: Current ref. count (>=0) on success, <0 on failure
+ *
+ * Programmer: Quincey Koziol
+ * February 23, 2019
+ *
+ *-------------------------------------------------------------------------
+ */
+static int64_t
+H5VL__conn_dec_rc(H5VL_t *connector)
+{
+ int64_t ret_value = -1; /* Return value */
+
+ FUNC_ENTER_STATIC
+
+ /* Check arguments */
+ HDassert(connector);
+
+ /* Decrement refcount for connector */
+ connector->nrefs--;
+
+ /* Check for last reference */
+ if(0 == connector->nrefs) {
+ if(H5I_dec_ref(connector->id) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to decrement ref count on VOL connector")
+ H5FL_FREE(H5VL_t, connector);
+
+ /* Set return value */
+ ret_value = 0;
+ } /* end if */
+ else
+ /* Set return value */
+ ret_value = connector->nrefs;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5VL__conn_dec_rc() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5VL_free_object
*
* Purpose: Wrapper to unregister an object ID with a VOL aux struct
@@ -562,20 +875,16 @@ done:
herr_t
H5VL_free_object(H5VL_object_t *vol_obj)
{
- herr_t ret_value = SUCCEED;
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(SUCCEED)
+ FUNC_ENTER_NOAPI(FAIL)
/* Check arguments */
HDassert(vol_obj);
- vol_obj->connector->nrefs --;
-
- if(0 == vol_obj->connector->nrefs) {
- if(H5I_dec_ref(vol_obj->connector->id) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to decrement ref count on VOL connector")
- vol_obj->connector = H5FL_FREE(H5VL_t, vol_obj->connector);
- } /* end if */
+ /* Decrement refcount on connector */
+ if(H5VL__conn_dec_rc(vol_obj->connector) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to decrement ref count on VOL connector")
vol_obj = H5FL_FREE(H5VL_object_t, vol_obj);
@@ -595,6 +904,9 @@ done:
*
* Failure: H5I_INVALID_HID
*
+ * Programmer: Dana Robinson
+ * June 22, 2017
+ *
*-------------------------------------------------------------------------
*/
hid_t
@@ -610,9 +922,9 @@ H5VL_register_connector(const void *_cls, hbool_t app_ref, hid_t vipl_id)
HDassert(cls);
/* Copy the class structure so the caller can reuse or free it */
- if (NULL == (saved = H5FL_CALLOC(H5VL_class_t)))
+ if(NULL == (saved = H5FL_MALLOC(H5VL_class_t)))
HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, H5I_INVALID_HID, "memory allocation failed for VOL connector class struct")
- HDmemcpy(saved, cls, sizeof(H5VL_class_t));
+ H5MM_memcpy(saved, cls, sizeof(H5VL_class_t));
if(NULL == (saved->name = H5MM_strdup(cls->name)))
HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, H5I_INVALID_HID, "memory allocation failed for VOL connector name")
@@ -621,23 +933,319 @@ H5VL_register_connector(const void *_cls, hbool_t app_ref, hid_t vipl_id)
HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, H5I_INVALID_HID, "unable to init VOL connector")
/* Create the new class ID */
- if ((ret_value = H5I_register(H5I_VOL, saved, app_ref)) < 0)
+ if((ret_value = H5I_register(H5I_VOL, saved, app_ref)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VOL connector ID")
done:
- if (ret_value < 0 && saved) {
- if (saved->name)
+ if(ret_value < 0 && saved) {
+ if(saved->name)
H5MM_xfree((void *)(saved->name)); /* Casting away const OK -QAK */
H5FL_FREE(H5VL_class_t, saved);
- }
+ } /* end if */
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_register_connector() */
/*-------------------------------------------------------------------------
- * Function: H5VL_get_connector_name
+ * Function: H5VL__register_connector
+ *
+ * Purpose: Registers a new VOL connector as a member of the virtual object
+ * layer class.
+ *
+ * Return: Success: A VOL connector ID which is good until the
+ * library is closed or the connector is
+ * unregistered.
+ *
+ * Failure: H5I_INVALID_HID
+ *
+ * Programmer: Dana Robinson
+ * June 22, 2017
+ *
+ *-------------------------------------------------------------------------
+ */
+hid_t
+H5VL__register_connector(const H5VL_class_t *cls, hbool_t app_ref, hid_t vipl_id)
+{
+ H5VL_get_connector_ud_t op_data; /* Callback info for connector search */
+ hid_t ret_value = H5I_INVALID_HID; /* Return value */
+
+ FUNC_ENTER_PACKAGE
+
+ /* Set up op data for iteration */
+ op_data.kind = H5VL_GET_CONNECTOR_BY_NAME;
+ op_data.u.name = cls->name;
+ op_data.found_id = H5I_INVALID_HID;
+
+ /* Check if connector is already registered */
+ if(H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_BADITER, H5I_INVALID_HID, "can't iterate over VOL IDs")
+
+ /* Increment the ref count on the existing VOL connector ID, if it's already registered */
+ if(op_data.found_id != H5I_INVALID_HID) {
+ if(H5I_inc_ref(op_data.found_id, app_ref) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINC, H5I_INVALID_HID, "unable to increment ref count on VOL connector")
+ ret_value = op_data.found_id;
+ } /* end if */
+ else {
+ /* Create a new class ID */
+ if((ret_value = H5VL_register_connector(cls, app_ref, vipl_id)) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VOL connector")
+ } /* end else */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5VL__register_connector() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5VL__register_connector_by_name
+ *
+ * Purpose: Registers a new VOL connector as a member of the virtual object
+ * layer class.
+ *
+ * Return: Success: A VOL connector ID which is good until the
+ * library is closed or the connector is
+ * unregistered.
+ *
+ * Failure: H5I_INVALID_HID
+ *
+ * Programmer: Dana Robinson
+ * June 22, 2017
+ *
+ *-------------------------------------------------------------------------
+ */
+hid_t
+H5VL__register_connector_by_name(const char *name, hbool_t app_ref, hid_t vipl_id)
+{
+ H5VL_get_connector_ud_t op_data; /* Callback info for connector search */
+ hid_t ret_value = H5I_INVALID_HID; /* Return value */
+
+ FUNC_ENTER_PACKAGE
+
+ /* Set up op data for iteration */
+ op_data.kind = H5VL_GET_CONNECTOR_BY_NAME;
+ op_data.u.name = name;
+ op_data.found_id = H5I_INVALID_HID;
+
+ /* Check if connector is already registered */
+ if(H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_BADITER, H5I_INVALID_HID, "can't iterate over VOL ids")
+
+ /* If connector alread registered, increment ref count on ID and return ID */
+ if(op_data.found_id != H5I_INVALID_HID) {
+ if(H5I_inc_ref(op_data.found_id, app_ref) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINC, H5I_INVALID_HID, "unable to increment ref count on VOL connector")
+ ret_value = op_data.found_id;
+ } /* end if */
+ else {
+ H5PL_key_t key;
+ const H5VL_class_t *cls;
+
+ /* Try loading the connector */
+ key.vol.kind = H5VL_GET_CONNECTOR_BY_NAME;
+ key.vol.u.name = name;
+ if(NULL == (cls = (const H5VL_class_t *)H5PL_load(H5PL_TYPE_VOL, &key)))
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, H5I_INVALID_HID, "unable to load VOL connector")
+
+ /* Register the connector we loaded */
+ if((ret_value = H5VL_register_connector(cls, app_ref, vipl_id)) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VOL connector ID")
+ } /* end else */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5VL__register_connector_by_name() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5VL__register_connector_by_value
+ *
+ * Purpose: Registers a new VOL connector as a member of the virtual object
+ * layer class.
+ *
+ * Return: Success: A VOL connector ID which is good until the
+ * library is closed or the connector is
+ * unregistered.
+ *
+ * Failure: H5I_INVALID_HID
+ *
+ * Programmer: Dana Robinson
+ * June 22, 2017
+ *
+ *-------------------------------------------------------------------------
+ */
+hid_t
+H5VL__register_connector_by_value(H5VL_class_value_t value, hbool_t app_ref, hid_t vipl_id)
+{
+ H5VL_get_connector_ud_t op_data; /* Callback info for connector search */
+ hid_t ret_value = H5I_INVALID_HID; /* Return value */
+
+ FUNC_ENTER_PACKAGE
+
+ /* Set up op data for iteration */
+ op_data.kind = H5VL_GET_CONNECTOR_BY_VALUE;
+ op_data.u.value = value;
+ op_data.found_id = H5I_INVALID_HID;
+
+ /* Check if connector is already registered */
+ if(H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_BADITER, H5I_INVALID_HID, "can't iterate over VOL ids")
+
+ /* If connector alread registered, increment ref count on ID and return ID */
+ if(op_data.found_id != H5I_INVALID_HID) {
+ if(H5I_inc_ref(op_data.found_id, app_ref) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINC, H5I_INVALID_HID, "unable to increment ref count on VOL connector")
+ ret_value = op_data.found_id;
+ } /* end if */
+ else {
+ H5PL_key_t key;
+ const H5VL_class_t *cls;
+
+ /* Try loading the connector */
+ key.vol.kind = H5VL_GET_CONNECTOR_BY_VALUE;
+ key.vol.u.value = value;
+ if(NULL == (cls = (const H5VL_class_t *)H5PL_load(H5PL_TYPE_VOL, &key)))
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, H5I_INVALID_HID, "unable to load VOL connector")
+
+ /* Register the connector we loaded */
+ if((ret_value = H5VL_register_connector(cls, app_ref, vipl_id)) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VOL connector ID")
+ } /* end else */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5VL__register_connector_by_value() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5VL__is_connector_registered
+ *
+ * Purpose: Checks if a connector with a particular name is registered.
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Dana Robinson
+ * June 17, 2017
+ *
+ *-------------------------------------------------------------------------
+ */
+htri_t
+H5VL__is_connector_registered(const char *name)
+{
+ H5VL_get_connector_ud_t op_data; /* Callback info for connector search */
+ htri_t ret_value = FALSE; /* Return value */
+
+ FUNC_ENTER_PACKAGE
+
+ /* Set up op data for iteration */
+ op_data.kind = H5VL_GET_CONNECTOR_BY_NAME;
+ op_data.u.name = name;
+ op_data.found_id = H5I_INVALID_HID;
+
+ /* Find connector with name */
+ if(H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_BADITER, FAIL, "can't iterate over VOL connectors")
+
+ /* Found a connector with that name */
+ if(op_data.found_id != H5I_INVALID_HID)
+ ret_value = TRUE;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5VL__is_connector_registered() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5VL__get_connector_id
+ *
+ * Purpose: Retrieves the ID for a registered VOL connector.
+ *
+ * Return: Positive if the VOL class has been registered
+ * Negative on error (if the class is not a valid class or not registered)
+ *
+ * Programmer: Dana Robinson
+ * June 17, 2017
+ *
+ *-------------------------------------------------------------------------
+ */
+hid_t
+H5VL__get_connector_id(const char *name, hbool_t is_api)
+{
+ H5VL_get_connector_ud_t op_data; /* Callback info for connector search */
+ hid_t ret_value = H5I_INVALID_HID; /* Return value */
+
+ FUNC_ENTER_PACKAGE
+
+ /* Set up op data for iteration */
+ op_data.kind = H5VL_GET_CONNECTOR_BY_NAME;
+ op_data.u.name = name;
+ op_data.found_id = H5I_INVALID_HID;
+
+ /* Find connector with name */
+ if(H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_BADITER, H5I_INVALID_HID, "can't iterate over VOL connectors")
+
+ /* Found a connector with that name */
+ if(op_data.found_id != H5I_INVALID_HID) {
+ if(H5I_inc_ref(op_data.found_id, is_api) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINC, H5I_INVALID_HID, "unable to increment ref count on VOL connector")
+ ret_value = op_data.found_id;
+ } /* end if */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5VL__get_connector_id() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5VL__connector_str_to_info
+ *
+ * Purpose: Deserializes a string into a connector's info object
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * March 2, 2019
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5VL__connector_str_to_info(const char *str, hid_t connector_id, void **info)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_PACKAGE
+
+ /* Only deserialize string, if it's non-NULL */
+ if(str) {
+ H5VL_class_t *cls; /* VOL connector's class struct */
+
+ /* Check args and get class pointer */
+ if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL)))
+ HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "not a VOL connector ID")
+
+ /* Allow the connector to deserialize info */
+ if(cls->info_cls.from_str) {
+ if((cls->info_cls.from_str)(str, info) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTUNSERIALIZE, FAIL, "can't deserialize connector info")
+ } /* end if */
+ else
+ *info = NULL;
+ } /* end if */
+ else
+ *info = NULL;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5VL__connector_str_to_info() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5VL__get_connector_name
*
* Purpose: Private version of H5VLget_connector_name
*
@@ -647,14 +1255,14 @@ done:
*-------------------------------------------------------------------------
*/
ssize_t
-H5VL_get_connector_name(hid_t id, char *name /*out*/, size_t size)
+H5VL__get_connector_name(hid_t id, char *name /*out*/, size_t size)
{
H5VL_object_t *vol_obj;
const H5VL_class_t *cls;
size_t len;
ssize_t ret_value = -1;
- FUNC_ENTER_NOAPI(FAIL)
+ FUNC_ENTER_PACKAGE
/* get the object pointer */
if (NULL == (vol_obj = H5VL_vol_object(id)))
@@ -674,7 +1282,7 @@ H5VL_get_connector_name(hid_t id, char *name /*out*/, size_t size)
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5VL_get_connector_name() */
+} /* end H5VL__get_connector_name() */
/*-------------------------------------------------------------------------
@@ -740,8 +1348,8 @@ H5VL_object_data(const H5VL_object_t *vol_obj)
FUNC_ENTER_NOAPI_NOINIT_NOERR
/* Check for 'get_object' callback in connector */
- if(vol_obj->connector->cls->get_object)
- ret_value = (vol_obj->connector->cls->get_object)(vol_obj->data);
+ if(vol_obj->connector->cls->wrap_cls.get_object)
+ ret_value = (vol_obj->connector->cls->wrap_cls.get_object)(vol_obj->data);
else
ret_value = vol_obj->data;
@@ -750,6 +1358,32 @@ H5VL_object_data(const H5VL_object_t *vol_obj)
/*-------------------------------------------------------------------------
+ * Function: H5VL_object_unwrap
+ *
+ * Purpose: Correctly unwrap the 'data' field for a VOL object (H5VL_object),
+ * even for nested / stacked VOL connectors.
+ *
+ * Return: Success: Object pointer
+ * Failure: NULL
+ *
+ *-------------------------------------------------------------------------
+ */
+void *
+H5VL_object_unwrap(const H5VL_object_t *vol_obj)
+{
+ void *ret_value = NULL;
+
+ FUNC_ENTER_NOAPI(NULL)
+
+ if(NULL == (ret_value = H5VL_unwrap_object(vol_obj->connector->cls, vol_obj->data)))
+ HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "can't unwrap object")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5VL_object_unwrap() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5VL__object
*
* Purpose: Internal function to return the VOL object pointer associated
@@ -803,6 +1437,7 @@ H5VL__object(hid_t id, H5I_type_t obj_type)
case H5I_ERROR_CLASS:
case H5I_ERROR_MSG:
case H5I_ERROR_STACK:
+ case H5I_SPACE_SEL_ITER:
case H5I_NTYPES:
default:
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unknown data object type")
@@ -836,7 +1471,7 @@ H5VL_object(hid_t id)
/* Get the underlying object */
if(NULL == (ret_value = H5VL__object(id, H5I_get_type(id))))
- HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, NULL, "can't retrieve object for ID")
+ HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "can't retrieve object for ID")
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -933,15 +1568,15 @@ H5VL_cmp_connector_cls(int *cmp_value, const H5VL_class_t *cls1, const H5VL_clas
HDassert(cls1->version == cls2->version);
/* Compare connector info */
- if(cls1->info_size < cls2->info_size) {
+ if(cls1->info_cls.size < cls2->info_cls.size) {
*cmp_value = -1;
HGOTO_DONE(SUCCEED)
} /* end if */
- if(cls1->info_size > cls2->info_size) {
+ if(cls1->info_cls.size > cls2->info_cls.size) {
*cmp_value = 1;
HGOTO_DONE(SUCCEED)
} /* end if */
- HDassert(cls1->info_size == cls2->info_size);
+ HDassert(cls1->info_cls.size == cls2->info_cls.size);
/* Set comparison value to 'equal' */
*cmp_value = 0;
@@ -952,6 +1587,189 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5VL_retrieve_lib_state
+ *
+ * Purpose: Retrieve the state of the library.
+ *
+ * Note: Currently just retrieves the API context state, but could be
+ * expanded in the future.
+ *
+ * Return: Success: Non-negative, *state set
+ * Failure: Negative, *state unset
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5VL_retrieve_lib_state(void **state)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* Sanity checks */
+ HDassert(state);
+
+ /* Retrieve the API context state */
+ if(H5CX_retrieve_state((H5CX_state_t **)state) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get API context state")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5VL_retrieve_lib_state() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5VL_restore_lib_state
+ *
+ * Purpose: Restore the state of the library.
+ *
+ * Note: Currently just restores the API context state, but could be
+ * expanded in the future.
+ *
+ * Return: SUCCEED / FAIL
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, January 10, 2019
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5VL_restore_lib_state(const void *state)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* Sanity checks */
+ HDassert(state);
+
+ /* Push a new API context on the stack */
+ if(H5CX_push() < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't push API context")
+
+ /* Restore the API context state */
+ if(H5CX_restore_state((const H5CX_state_t *)state) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set API context state")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5VL_restore_lib_state() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5VL_reset_lib_state
+ *
+ * Purpose: Reset the state of the library, undoing affects of
+ * H5VL_restore_lib_state.
+ *
+ * Note: Currently just resets the API context state, but could be
+ * expanded in the future.
+ *
+ * Note: This routine must be called as a "pair" with
+ * H5VL_restore_lib_state. It can be called before / after /
+ * independently of H5VL_free_lib_state.
+ *
+ * Return: SUCCEED / FAIL
+ *
+ * Programmer: Quincey Koziol
+ * Saturday, February 23, 2019
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5VL_reset_lib_state(void)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* Pop the API context off the stack */
+ if(H5CX_pop() < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't pop API context")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5VL_reset_lib_state() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5VL_free_lib_state
+ *
+ * Purpose: Free a library state.
+ *
+ * Note: This routine must be called as a "pair" with
+ * H5VL_retrieve_lib_state.
+ *
+ * Return: SUCCEED / FAIL
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, January 10, 2019
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5VL_free_lib_state(void *state)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* Sanity checks */
+ HDassert(state);
+
+ /* Free the API context state */
+ if(H5CX_free_state((H5CX_state_t *)state) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "can't free API context state")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5VL_free_lib_state() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5VL__free_vol_wrapper
+ *
+ * Purpose: Free object wrapping context for VOL connector
+ *
+ * Return: SUCCEED / FAIL
+ *
+ * Programmer: Quincey Koziol
+ * Wednesday, January 9, 2019
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5VL__free_vol_wrapper(H5VL_wrap_ctx_t *vol_wrap_ctx)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_STATIC
+
+ /* Sanity check */
+ HDassert(vol_wrap_ctx);
+ HDassert(0 == vol_wrap_ctx->rc);
+ HDassert(vol_wrap_ctx->connector);
+ HDassert(vol_wrap_ctx->connector->cls);
+
+ /* If there is a VOL connector object wrapping context, release it */
+ if(vol_wrap_ctx->obj_wrap_ctx)
+ /* Release the VOL connector's object wrapping context */
+ if((*vol_wrap_ctx->connector->cls->wrap_cls.free_wrap_ctx)(vol_wrap_ctx->obj_wrap_ctx) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to release connector's object wrapping context")
+
+ /* Decrement refcount on connector */
+ if(H5VL__conn_dec_rc(vol_wrap_ctx->connector) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to decrement ref count on VOL connector")
+
+ /* Release object wrapping context */
+ H5FL_FREE(H5VL_wrap_ctx_t, vol_wrap_ctx);
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5VL__free_vol_wrapper() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5VL_set_vol_wrapper
*
* Purpose: Set up object wrapping context for current VOL connector
@@ -961,7 +1779,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5VL_set_vol_wrapper(void *obj, const H5VL_t *connector)
+H5VL_set_vol_wrapper(void *obj, H5VL_t *connector)
{
H5VL_wrap_ctx_t *vol_wrap_ctx = NULL; /* Object wrapping context */
void *obj_wrap_ctx = NULL; /* VOL connector's wrapping context */
@@ -980,12 +1798,12 @@ H5VL_set_vol_wrapper(void *obj, const H5VL_t *connector)
/* Check for existing wrapping context */
if(NULL == vol_wrap_ctx) {
/* Check if the connector can create a wrap context */
- if(connector->cls->get_wrap_ctx) {
+ if(connector->cls->wrap_cls.get_wrap_ctx) {
/* Sanity check */
- HDassert(connector->cls->free_wrap_ctx);
+ HDassert(connector->cls->wrap_cls.free_wrap_ctx);
/* Get the wrap context from the connector */
- if((connector->cls->get_wrap_ctx)(obj, &obj_wrap_ctx) < 0)
+ if((connector->cls->wrap_cls.get_wrap_ctx)(obj, &obj_wrap_ctx) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't retrieve VOL connector's object wrap context")
} /* end if */
@@ -993,8 +1811,11 @@ H5VL_set_vol_wrapper(void *obj, const H5VL_t *connector)
if(NULL == (vol_wrap_ctx = H5FL_MALLOC(H5VL_wrap_ctx_t)))
HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, FAIL, "can't allocate VOL wrap context")
+ /* Increment the outstanding objects that are using the connector */
+ H5VL__conn_inc_rc(connector);
+
/* Set up VOL object wrapper context */
- vol_wrap_ctx->rc = 1;;
+ vol_wrap_ctx->rc = 1;
vol_wrap_ctx->connector = connector;
vol_wrap_ctx->obj_wrap_ctx = obj_wrap_ctx;
} /* end if */
@@ -1016,6 +1837,80 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5VL_inc_vol_wrapper
+ *
+ * Purpose: Increment refcount on object wrapping context
+ *
+ * Return: SUCCEED / FAIL
+ *
+ * Programmer: Quincey Koziol
+ * Wednesday, January 9, 2019
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5VL_inc_vol_wrapper(void *_vol_wrap_ctx)
+{
+ H5VL_wrap_ctx_t *vol_wrap_ctx = (H5VL_wrap_ctx_t *)_vol_wrap_ctx; /* VOL object wrapping context */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* Check for valid, active VOL object wrap context */
+ if(NULL == vol_wrap_ctx)
+ HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, FAIL, "no VOL object wrap context?")
+ if(0 == vol_wrap_ctx->rc)
+ HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, FAIL, "bad VOL object wrap context refcount?")
+
+ /* Increment ref count on wrapping context */
+ vol_wrap_ctx->rc++;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5VL_inc_vol_wrapper() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5VL_dec_vol_wrapper
+ *
+ * Purpose: Decrement refcount on object wrapping context, releasing it
+ * if the refcount drops to zero.
+ *
+ * Return: SUCCEED / FAIL
+ *
+ * Programmer: Quincey Koziol
+ * Wednesday, January 9, 2019
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5VL_dec_vol_wrapper(void *_vol_wrap_ctx)
+{
+ H5VL_wrap_ctx_t *vol_wrap_ctx = (H5VL_wrap_ctx_t *)_vol_wrap_ctx; /* VOL object wrapping context */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* Check for valid, active VOL object wrap context */
+ if(NULL == vol_wrap_ctx)
+ HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, FAIL, "no VOL object wrap context?")
+ if(0 == vol_wrap_ctx->rc)
+ HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, FAIL, "bad VOL object wrap context refcount?")
+
+ /* Decrement ref count on wrapping context */
+ vol_wrap_ctx->rc--;
+
+ /* Release context if the ref count drops to zero */
+ if(0 == vol_wrap_ctx->rc)
+ if(H5VL__free_vol_wrapper(vol_wrap_ctx) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to release VOL object wrapping context")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5VL_dec_vol_wrapper() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5VL_reset_vol_wrapper
*
* Purpose: Reset object wrapping context for current VOL connector
@@ -1045,25 +1940,18 @@ H5VL_reset_vol_wrapper(void)
/* Release context if the ref count drops to zero */
if(0 == vol_wrap_ctx->rc) {
- /* If there is a VOL connector object wrapping context, release it */
- if(vol_wrap_ctx->obj_wrap_ctx) {
- /* Release the VOL connector's object wrapping context */
- if((*vol_wrap_ctx->connector->cls->free_wrap_ctx)(vol_wrap_ctx->obj_wrap_ctx) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to release connector's object wrapping context")
- } /* end if */
-
/* Release object wrapping context */
- H5FL_FREE(H5VL_wrap_ctx_t, vol_wrap_ctx);
+ if(H5VL__free_vol_wrapper(vol_wrap_ctx) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to release VOL object wrapping context")
/* Reset the wrapper context */
if(H5CX_set_vol_wrap_ctx(NULL) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL object wrap context")
} /* end if */
- else {
+ else
/* Save the updated wrapper context */
if(H5CX_set_vol_wrap_ctx(vol_wrap_ctx) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL object wrap context")
- } /* end else */
done:
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5VLnative.c b/src/H5VLnative.c
index fe0fd4e..7848c5d 100644
--- a/src/H5VLnative.c
+++ b/src/H5VLnative.c
@@ -38,16 +38,21 @@ static H5VL_class_t H5VL_native_cls_g = {
0, /* capability flags */
NULL, /* initialize */
H5VL__native_term, /* terminate */
- (size_t)0, /* info size */
- NULL, /* info copy */
- NULL, /* info compare */
- NULL, /* info free */
- NULL, /* info to str */
- NULL, /* str to info */
- NULL, /* get_object */
- NULL, /* get_wrap_ctx */
- NULL, /* wrap_object */
- NULL, /* free_wrap_ctx */
+ { /* info_cls */
+ (size_t)0, /* info size */
+ NULL, /* info copy */
+ NULL, /* info compare */
+ NULL, /* info free */
+ NULL, /* info to str */
+ NULL /* str to info */
+ },
+ { /* wrap_cls */
+ NULL, /* get_object */
+ NULL, /* get_wrap_ctx */
+ NULL, /* wrap_object */
+ NULL, /* unwrap_object */
+ NULL /* free_wrap_ctx */
+ },
{ /* attribute_cls */
H5VL__native_attr_create, /* create */
H5VL__native_attr_open, /* open */
diff --git a/src/H5VLnative_attr.c b/src/H5VLnative_attr.c
index 7d9f0ac..85af320 100644
--- a/src/H5VLnative_attr.c
+++ b/src/H5VLnative_attr.c
@@ -44,14 +44,12 @@
*/
void *
H5VL__native_attr_create(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name,
- hid_t acpl_id, hid_t H5_ATTR_UNUSED aapl_id, hid_t H5_ATTR_UNUSED dxpl_id,
- void H5_ATTR_UNUSED **req)
+ hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t H5_ATTR_UNUSED aapl_id,
+ hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req)
{
H5G_loc_t loc; /* Object location */
H5G_loc_t obj_loc; /* Location used to open group */
hbool_t loc_found = FALSE;
- H5P_genplist_t *plist; /* Property list pointer */
- hid_t type_id, space_id;
H5T_t *type, *dt; /* Datatype to use for attribute */
H5S_t *space; /* Dataspace to use for attribute */
H5A_t *attr = NULL;
@@ -59,16 +57,6 @@ H5VL__native_attr_create(void *obj, const H5VL_loc_params_t *loc_params, const c
FUNC_ENTER_PACKAGE
- /* Get the plist structure */
- if(NULL == (plist = (H5P_genplist_t *)H5I_object(acpl_id)))
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID")
-
- /* get creation properties */
- if(H5P_get(plist, H5VL_PROP_ATTR_TYPE_ID, &type_id) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for datatype id")
- if(H5P_get(plist, H5VL_PROP_ATTR_SPACE_ID, &space_id) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for space id")
-
if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object")
if(0 == (H5F_INTENT(loc.oloc->file) & H5F_ACC_RDWR))
diff --git a/src/H5VLnative_dataset.c b/src/H5VLnative_dataset.c
index 8f7351c..1e3d263 100644
--- a/src/H5VLnative_dataset.c
+++ b/src/H5VLnative_dataset.c
@@ -43,32 +43,17 @@
*/
void *
H5VL__native_dataset_create(void *obj, const H5VL_loc_params_t *loc_params,
- const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t H5_ATTR_UNUSED dxpl_id,
+ const char *name, hid_t lcpl_id, hid_t type_id, hid_t space_id,
+ hid_t dcpl_id, hid_t dapl_id, hid_t H5_ATTR_UNUSED dxpl_id,
void H5_ATTR_UNUSED **req)
{
- H5P_genplist_t *plist; /* Property list pointer */
H5G_loc_t loc; /* Object location to insert dataset into */
- hid_t type_id = H5I_INVALID_HID;
- hid_t space_id = H5I_INVALID_HID;
- hid_t lcpl_id = H5I_INVALID_HID;
H5D_t *dset = NULL; /* New dataset's info */
const H5S_t *space; /* Dataspace for dataset */
void *ret_value;
FUNC_ENTER_PACKAGE
- /* Get the plist structure */
- if(NULL == (plist = (H5P_genplist_t *)H5I_object(dcpl_id)))
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID")
-
- /* Get creation properties */
- if(H5P_get(plist, H5VL_PROP_DSET_TYPE_ID, &type_id) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for datatype id")
- if(H5P_get(plist, H5VL_PROP_DSET_SPACE_ID, &space_id) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for space id")
- if(H5P_get(plist, H5VL_PROP_DSET_LCPL_ID, &lcpl_id) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for lcpl id")
-
/* Check arguments */
if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object")
diff --git a/src/H5VLnative_file.c b/src/H5VLnative_file.c
index e7f27e1..eeaade6 100644
--- a/src/H5VLnative_file.c
+++ b/src/H5VLnative_file.c
@@ -228,6 +228,19 @@ H5VL__native_file_get(void *obj, H5VL_file_get_t get_type,
break;
}
+ /* H5Fget_fileno */
+ case H5VL_FILE_GET_FILENO:
+ {
+ unsigned long *fileno = HDva_arg(arguments, unsigned long *);
+ unsigned long my_fileno = 0;
+
+ f = (H5F_t *)obj;
+ H5F_GET_FILENO(f, my_fileno);
+ *fileno = my_fileno; /* sigh */
+
+ break;
+ }
+
/* H5Fget_name */
case H5VL_FILE_GET_NAME:
{
@@ -373,10 +386,16 @@ H5VL__native_file_specific(void *obj, H5VL_file_specific_t specific_type,
/* Call private routine */
if((*ret = H5F__is_hdf5(name, fapl_id)) < 0)
- HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "error in HDF5 file check")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "error in HDF5 file check")
break;
}
+ /* H5Fdelete */
+ case H5VL_FILE_DELETE:
+ {
+ HGOTO_ERROR(H5E_FILE, H5E_UNSUPPORTED, FAIL, "H5Fdelete() is currently not supported in the native VOL connector")
+ break;
+ }
default:
@@ -755,7 +774,7 @@ H5VL__native_file_optional(void *obj, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR
/* H5Fget_dset_no_attrs_hint */
case H5VL_NATIVE_FILE_GET_MIN_DSET_OHDR_FLAG:
{
- hbool_t *minimize = va_arg(arguments, hbool_t *);
+ hbool_t *minimize = HDva_arg(arguments, hbool_t *);
*minimize = H5F_GET_MIN_DSET_OHDR(f);
break;
}
@@ -763,7 +782,7 @@ H5VL__native_file_optional(void *obj, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR
/* H5Fset_dset_no_attrs_hint */
case H5VL_NATIVE_FILE_SET_MIN_DSET_OHDR_FLAG:
{
- int minimize = va_arg(arguments, int);
+ int minimize = HDva_arg(arguments, int);
if(H5F_set_min_dset_ohdr(f, (hbool_t)minimize) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "cannot set file's dataset object header minimization flag")
break;
diff --git a/src/H5VLnative_group.c b/src/H5VLnative_group.c
index 9c07b3d..b6bef7f 100644
--- a/src/H5VLnative_group.c
+++ b/src/H5VLnative_group.c
@@ -41,25 +41,15 @@
*/
void *
H5VL__native_group_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name,
- hid_t gcpl_id, hid_t H5_ATTR_UNUSED gapl_id, hid_t H5_ATTR_UNUSED dxpl_id,
- void H5_ATTR_UNUSED **req)
+ hid_t lcpl_id, hid_t gcpl_id, hid_t H5_ATTR_UNUSED gapl_id,
+ hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req)
{
- H5P_genplist_t *plist; /* Property list pointer */
H5G_loc_t loc; /* Location to create group */
H5G_t *grp = NULL; /* New group created */
- hid_t lcpl_id;
void *ret_value;
FUNC_ENTER_PACKAGE
- /* Get the property list structure */
- if(NULL == (plist = (H5P_genplist_t *)H5I_object(gcpl_id)))
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID")
-
- /* Get creation properties */
- if(H5P_get(plist, H5VL_PROP_GRP_LCPL_ID, &lcpl_id) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for lcpl id")
-
/* Set up the location */
if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object")
diff --git a/src/H5VLnative_link.c b/src/H5VLnative_link.c
index 98d2ccd..4709eb3 100644
--- a/src/H5VLnative_link.c
+++ b/src/H5VLnative_link.c
@@ -41,7 +41,7 @@
herr_t
H5VL__native_link_create(H5VL_link_create_type_t create_type, void *obj,
const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t H5_ATTR_UNUSED lapl_id,
- hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req)
+ hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments)
{
H5P_genplist_t *plist; /* Property list pointer */
herr_t ret_value = SUCCEED; /* Return value */
@@ -57,13 +57,8 @@ H5VL__native_link_create(H5VL_link_create_type_t create_type, void *obj,
{
H5G_loc_t cur_loc;
H5G_loc_t link_loc;
- void *cur_obj;
- H5VL_loc_params_t cur_params;
-
- if(H5P_get(plist, H5VL_PROP_LINK_TARGET, &cur_obj) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for current location id")
- if(H5P_get(plist, H5VL_PROP_LINK_TARGET_LOC_PARAMS, &cur_params) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for current name")
+ void *cur_obj = HDva_arg(arguments, void *);
+ H5VL_loc_params_t cur_params = HDva_arg(arguments, H5VL_loc_params_t);
if(NULL != cur_obj && H5G_loc_real(cur_obj, cur_params.obj_type, &cur_loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
@@ -99,15 +94,12 @@ H5VL__native_link_create(H5VL_link_create_type_t create_type, void *obj,
case H5VL_LINK_CREATE_SOFT:
{
- char *target_name;
+ char *target_name = HDva_arg(arguments, char *);
H5G_loc_t link_loc; /* Group location for new link */
if(H5G_loc_real(obj, loc_params->obj_type, &link_loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
- if(H5P_get(plist, H5VL_PROP_LINK_TARGET_NAME, &target_name) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for targe name")
-
/* Create the link */
if((ret_value = H5L_create_soft(target_name, &link_loc, loc_params->loc_data.loc_by_name.name, lcpl_id)) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link")
@@ -117,23 +109,15 @@ H5VL__native_link_create(H5VL_link_create_type_t create_type, void *obj,
case H5VL_LINK_CREATE_UD:
{
H5G_loc_t link_loc; /* Group location for new link */
- H5L_type_t link_type;
- void *udata;
- size_t udata_size;
+ H5L_type_t link_type = (H5L_type_t)HDva_arg(arguments, int);
+ void *udata = HDva_arg(arguments, void *);
+ size_t udata_size = HDva_arg(arguments, size_t);
if(H5G_loc_real(obj, loc_params->obj_type, &link_loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
- if(H5P_get(plist, H5VL_PROP_LINK_TYPE, &link_type) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for link type")
- if(H5P_get(plist, H5VL_PROP_LINK_UDATA, &udata) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for udata")
- if(H5P_get(plist, H5VL_PROP_LINK_UDATA_SIZE, &udata_size) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for udata size")
-
/* Create link */
- if(H5L__create_ud(&link_loc, loc_params->loc_data.loc_by_name.name, udata, udata_size,
- link_type, lcpl_id) < 0)
+ if(H5L__create_ud(&link_loc, loc_params->loc_data.loc_by_name.name, udata, udata_size, link_type, lcpl_id) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link")
break;
}
diff --git a/src/H5VLnative_object.c b/src/H5VLnative_object.c
index 0b1d73a..de2a8a5 100644
--- a/src/H5VLnative_object.c
+++ b/src/H5VLnative_object.c
@@ -213,17 +213,32 @@ H5VL__native_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_obj
break;
}
- /* H5Iget_name */
- case H5VL_ID_GET_NAME:
+ /* Object name */
+ case H5VL_OBJECT_GET_NAME:
{
ssize_t *ret = HDva_arg(arguments, ssize_t *);
char *name = HDva_arg(arguments, char *);
size_t size = HDva_arg(arguments, size_t);
- /* Retrieve object's name */
- if((*ret = H5G_get_name(&loc, name, size, NULL)) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't retrieve object name")
+ if(loc_params->type == H5VL_OBJECT_BY_SELF) {
+ /* Retrieve object's name */
+ if((*ret = H5G_get_name(&loc, name, size, NULL)) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't retrieve object name")
+ } /* end if */
+ else if(loc_params->type == H5VL_OBJECT_BY_ADDR) {
+ H5O_loc_t obj_oloc; /* Object location */
+
+ /* Initialize the object location */
+ H5O_loc_reset(&obj_oloc);
+ obj_oloc.file = loc.oloc->file;
+ obj_oloc.addr = loc_params->loc_data.loc_by_addr.addr;
+ /* Retrieve object's name */
+ if((*ret = H5G_get_name_by_addr(loc.oloc->file, &obj_oloc, name, size)) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't determine object name")
+ } /* end else-if */
+ else
+ HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown get_name parameters")
break;
}
diff --git a/src/H5VLnative_private.h b/src/H5VLnative_private.h
index 1bf4da2..714b73c 100644
--- a/src/H5VLnative_private.h
+++ b/src/H5VLnative_private.h
@@ -24,7 +24,7 @@ extern "C" {
#endif
/* Atrribute callbacks */
-H5_DLL void *H5VL__native_attr_create(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req);
+H5_DLL void *H5VL__native_attr_create(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req);
void *H5VL__native_attr_open(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, hid_t aapl_id, hid_t dxpl_id, void **req);
H5_DLL herr_t H5VL__native_attr_read(void *attr, hid_t dtype_id, void *buf, hid_t dxpl_id, void **req);
H5_DLL herr_t H5VL__native_attr_write(void *attr, hid_t dtype_id, const void *buf, hid_t dxpl_id, void **req);
@@ -34,7 +34,7 @@ H5_DLL herr_t H5VL__native_attr_optional(void *obj, hid_t dxpl_id, void **req, v
H5_DLL herr_t H5VL__native_attr_close(void *attr, hid_t dxpl_id, void **req);
/* Dataset callbacks */
-H5_DLL void *H5VL__native_dataset_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req);
+H5_DLL void *H5VL__native_dataset_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t lcpl_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req);
H5_DLL void *H5VL__native_dataset_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t dapl_id, hid_t dxpl_id, void **req);
H5_DLL herr_t H5VL__native_dataset_read(void *dset, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, void *buf, void **req);
H5_DLL herr_t H5VL__native_dataset_write(void *dset, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, const void *buf, void **req);
@@ -52,7 +52,7 @@ H5_DLL herr_t H5VL__native_file_optional(void *file, hid_t dxpl_id, void **req,
H5_DLL herr_t H5VL__native_file_close(void *file, hid_t dxpl_id, void **req);
/* Group callbacks */
-H5_DLL void *H5VL__native_group_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req);
+H5_DLL void *H5VL__native_group_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req);
H5_DLL void *H5VL__native_group_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t gapl_id, hid_t dxpl_id, void **req);
H5_DLL herr_t H5VL__native_group_get(void *obj, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, va_list arguments);
H5_DLL herr_t H5VL__native_group_specific(void *obj, H5VL_group_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments);
@@ -60,7 +60,7 @@ H5_DLL herr_t H5VL__native_group_optional(void *obj, hid_t dxpl_id, void **req,
H5_DLL herr_t H5VL__native_group_close(void *grp, hid_t dxpl_id, void **req);
/* Link callbacks */
-H5_DLL herr_t H5VL__native_link_create(H5VL_link_create_type_t create_type, void *obj, const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req);
+H5_DLL herr_t H5VL__native_link_create(H5VL_link_create_type_t create_type, void *obj, const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req, va_list arguments);
H5_DLL herr_t H5VL__native_link_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req);
H5_DLL herr_t H5VL__native_link_move(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req);
H5_DLL herr_t H5VL__native_link_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_t get_type, hid_t dxpl_id, void **req, va_list arguments);
diff --git a/src/H5VLpassthru.c b/src/H5VLpassthru.c
index f7f9058..eecdac2 100644
--- a/src/H5VLpassthru.c
+++ b/src/H5VLpassthru.c
@@ -20,17 +20,26 @@
* include _any_ private HDF5 header files. This connector should
* therefore only make public HDF5 API calls and use standard C /
* POSIX calls.
+ *
+ * Note that the HDF5 error stack must be preserved on code paths
+ * that could be invoked when the underlying VOL connector's
+ * callback can fail.
+ *
*/
/* Header files needed */
-/* (Public HDF5 and standard C / POSIX only) */
+/* Do NOT include private HDF5 files here! */
#include <assert.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+
+/* Public HDF5 file */
#include "hdf5.h"
+
+/* This connector's header */
#include "H5VLpassthru.h"
@@ -75,6 +84,9 @@ static herr_t H5VL_pass_through_file_specific_reissue(void *obj, hid_t connector
H5VL_file_specific_t specific_type, hid_t dxpl_id, void **req, ...);
static herr_t H5VL_pass_through_request_specific_reissue(void *obj, hid_t connector_id,
H5VL_request_specific_t specific_type, ...);
+static herr_t H5VL_pass_through_link_create_reissue(H5VL_link_create_type_t create_type,
+ void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id,
+ hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req, ...);
static H5VL_pass_through_t *H5VL_pass_through_new_obj(void *under_obj,
hid_t under_vol_id);
static herr_t H5VL_pass_through_free_obj(H5VL_pass_through_t *obj);
@@ -82,19 +94,24 @@ static herr_t H5VL_pass_through_free_obj(H5VL_pass_through_t *obj);
/* "Management" callbacks */
static herr_t H5VL_pass_through_init(hid_t vipl_id);
static herr_t H5VL_pass_through_term(void);
+
+/* VOL info callbacks */
static void *H5VL_pass_through_info_copy(const void *info);
static herr_t H5VL_pass_through_info_cmp(int *cmp_value, const void *info1, const void *info2);
static herr_t H5VL_pass_through_info_free(void *info);
static herr_t H5VL_pass_through_info_to_str(const void *info, char **str);
static herr_t H5VL_pass_through_str_to_info(const char *str, void **info);
+
+/* VOL object wrap / retrieval callbacks */
static void *H5VL_pass_through_get_object(const void *obj);
static herr_t H5VL_pass_through_get_wrap_ctx(const void *obj, void **wrap_ctx);
-static herr_t H5VL_pass_through_free_wrap_ctx(void *obj);
static void *H5VL_pass_through_wrap_object(void *obj, H5I_type_t obj_type,
void *wrap_ctx);
+static void *H5VL_pass_through_unwrap_object(void *obj);
+static herr_t H5VL_pass_through_free_wrap_ctx(void *obj);
/* Attribute callbacks */
-static void *H5VL_pass_through_attr_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req);
+static void *H5VL_pass_through_attr_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req);
static void *H5VL_pass_through_attr_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t aapl_id, hid_t dxpl_id, void **req);
static herr_t H5VL_pass_through_attr_read(void *attr, hid_t mem_type_id, void *buf, hid_t dxpl_id, void **req);
static herr_t H5VL_pass_through_attr_write(void *attr, hid_t mem_type_id, const void *buf, hid_t dxpl_id, void **req);
@@ -104,7 +121,7 @@ static herr_t H5VL_pass_through_attr_optional(void *obj, hid_t dxpl_id, void **r
static herr_t H5VL_pass_through_attr_close(void *attr, hid_t dxpl_id, void **req);
/* Dataset callbacks */
-static void *H5VL_pass_through_dataset_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req);
+static void *H5VL_pass_through_dataset_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t lcpl_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req);
static void *H5VL_pass_through_dataset_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t dapl_id, hid_t dxpl_id, void **req);
static herr_t H5VL_pass_through_dataset_read(void *dset, hid_t mem_type_id, hid_t mem_space_id,
hid_t file_space_id, hid_t plist_id, void *buf, void **req);
@@ -131,7 +148,7 @@ static herr_t H5VL_pass_through_file_optional(void *file, hid_t dxpl_id, void **
static herr_t H5VL_pass_through_file_close(void *file, hid_t dxpl_id, void **req);
/* Group callbacks */
-static void *H5VL_pass_through_group_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req);
+static void *H5VL_pass_through_group_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req);
static void *H5VL_pass_through_group_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t gapl_id, hid_t dxpl_id, void **req);
static herr_t H5VL_pass_through_group_get(void *obj, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, va_list arguments);
static herr_t H5VL_pass_through_group_specific(void *obj, H5VL_group_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments);
@@ -139,7 +156,7 @@ static herr_t H5VL_pass_through_group_optional(void *obj, hid_t dxpl_id, void **
static herr_t H5VL_pass_through_group_close(void *grp, hid_t dxpl_id, void **req);
/* Link callbacks */
-static herr_t H5VL_pass_through_link_create(H5VL_link_create_type_t create_type, void *obj, const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req);
+static herr_t H5VL_pass_through_link_create(H5VL_link_create_type_t create_type, void *obj, const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req, va_list arguments);
static herr_t H5VL_pass_through_link_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req);
static herr_t H5VL_pass_through_link_move(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req);
static herr_t H5VL_pass_through_link_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_t get_type, hid_t dxpl_id, void **req, va_list arguments);
@@ -173,82 +190,87 @@ static const H5VL_class_t H5VL_pass_through_g = {
0, /* capability flags */
H5VL_pass_through_init, /* initialize */
H5VL_pass_through_term, /* terminate */
- sizeof(H5VL_pass_through_info_t), /* info size */
- H5VL_pass_through_info_copy, /* info copy */
- H5VL_pass_through_info_cmp, /* info compare */
- H5VL_pass_through_info_free, /* info free */
- H5VL_pass_through_info_to_str, /* info to str */
- H5VL_pass_through_str_to_info, /* str to info */
- H5VL_pass_through_get_object, /* get_object */
- H5VL_pass_through_get_wrap_ctx, /* get_wrap_ctx */
- H5VL_pass_through_wrap_object, /* wrap_object */
- H5VL_pass_through_free_wrap_ctx, /* free_wrap_ctx */
+ { /* info_cls */
+ sizeof(H5VL_pass_through_info_t), /* size */
+ H5VL_pass_through_info_copy, /* copy */
+ H5VL_pass_through_info_cmp, /* compare */
+ H5VL_pass_through_info_free, /* free */
+ H5VL_pass_through_info_to_str, /* to_str */
+ H5VL_pass_through_str_to_info, /* from_str */
+ },
+ { /* wrap_cls */
+ H5VL_pass_through_get_object, /* get_object */
+ H5VL_pass_through_get_wrap_ctx, /* get_wrap_ctx */
+ H5VL_pass_through_wrap_object, /* wrap_object */
+ H5VL_pass_through_unwrap_object, /* unwrap_object */
+ H5VL_pass_through_free_wrap_ctx, /* free_wrap_ctx */
+ },
{ /* attribute_cls */
- H5VL_pass_through_attr_create, /* create */
- H5VL_pass_through_attr_open, /* open */
- H5VL_pass_through_attr_read, /* read */
- H5VL_pass_through_attr_write, /* write */
- H5VL_pass_through_attr_get, /* get */
- H5VL_pass_through_attr_specific, /* specific */
- H5VL_pass_through_attr_optional, /* optional */
- H5VL_pass_through_attr_close /* close */
+ H5VL_pass_through_attr_create, /* create */
+ H5VL_pass_through_attr_open, /* open */
+ H5VL_pass_through_attr_read, /* read */
+ H5VL_pass_through_attr_write, /* write */
+ H5VL_pass_through_attr_get, /* get */
+ H5VL_pass_through_attr_specific, /* specific */
+ H5VL_pass_through_attr_optional, /* optional */
+ H5VL_pass_through_attr_close /* close */
},
{ /* dataset_cls */
- H5VL_pass_through_dataset_create, /* create */
- H5VL_pass_through_dataset_open, /* open */
- H5VL_pass_through_dataset_read, /* read */
- H5VL_pass_through_dataset_write, /* write */
- H5VL_pass_through_dataset_get, /* get */
- H5VL_pass_through_dataset_specific, /* specific */
- H5VL_pass_through_dataset_optional, /* optional */
- H5VL_pass_through_dataset_close /* close */
+ H5VL_pass_through_dataset_create, /* create */
+ H5VL_pass_through_dataset_open, /* open */
+ H5VL_pass_through_dataset_read, /* read */
+ H5VL_pass_through_dataset_write, /* write */
+ H5VL_pass_through_dataset_get, /* get */
+ H5VL_pass_through_dataset_specific, /* specific */
+ H5VL_pass_through_dataset_optional, /* optional */
+ H5VL_pass_through_dataset_close /* close */
},
- { /* datatype_cls */
- H5VL_pass_through_datatype_commit, /* commit */
- H5VL_pass_through_datatype_open, /* open */
- H5VL_pass_through_datatype_get, /* get_size */
- H5VL_pass_through_datatype_specific, /* specific */
- H5VL_pass_through_datatype_optional, /* optional */
- H5VL_pass_through_datatype_close /* close */
+ { /* datatype_cls */
+ H5VL_pass_through_datatype_commit, /* commit */
+ H5VL_pass_through_datatype_open, /* open */
+ H5VL_pass_through_datatype_get, /* get_size */
+ H5VL_pass_through_datatype_specific, /* specific */
+ H5VL_pass_through_datatype_optional, /* optional */
+ H5VL_pass_through_datatype_close /* close */
},
{ /* file_cls */
- H5VL_pass_through_file_create, /* create */
- H5VL_pass_through_file_open, /* open */
- H5VL_pass_through_file_get, /* get */
- H5VL_pass_through_file_specific, /* specific */
- H5VL_pass_through_file_optional, /* optional */
- H5VL_pass_through_file_close /* close */
+ H5VL_pass_through_file_create, /* create */
+ H5VL_pass_through_file_open, /* open */
+ H5VL_pass_through_file_get, /* get */
+ H5VL_pass_through_file_specific, /* specific */
+ H5VL_pass_through_file_optional, /* optional */
+ H5VL_pass_through_file_close /* close */
},
{ /* group_cls */
- H5VL_pass_through_group_create, /* create */
- H5VL_pass_through_group_open, /* open */
- H5VL_pass_through_group_get, /* get */
- H5VL_pass_through_group_specific, /* specific */
- H5VL_pass_through_group_optional, /* optional */
- H5VL_pass_through_group_close /* close */
+ H5VL_pass_through_group_create, /* create */
+ H5VL_pass_through_group_open, /* open */
+ H5VL_pass_through_group_get, /* get */
+ H5VL_pass_through_group_specific, /* specific */
+ H5VL_pass_through_group_optional, /* optional */
+ H5VL_pass_through_group_close /* close */
},
{ /* link_cls */
- H5VL_pass_through_link_create, /* create */
- H5VL_pass_through_link_copy, /* copy */
- H5VL_pass_through_link_move, /* move */
- H5VL_pass_through_link_get, /* get */
- H5VL_pass_through_link_specific, /* specific */
- H5VL_pass_through_link_optional, /* optional */
+ H5VL_pass_through_link_create, /* create */
+ H5VL_pass_through_link_copy, /* copy */
+ H5VL_pass_through_link_move, /* move */
+ H5VL_pass_through_link_get, /* get */
+ H5VL_pass_through_link_specific, /* specific */
+ H5VL_pass_through_link_optional, /* optional */
},
{ /* object_cls */
- H5VL_pass_through_object_open, /* open */
- H5VL_pass_through_object_copy, /* copy */
- H5VL_pass_through_object_get, /* get */
- H5VL_pass_through_object_specific, /* specific */
- H5VL_pass_through_object_optional, /* optional */
+ H5VL_pass_through_object_open, /* open */
+ H5VL_pass_through_object_copy, /* copy */
+ H5VL_pass_through_object_get, /* get */
+ H5VL_pass_through_object_specific, /* specific */
+ H5VL_pass_through_object_optional, /* optional */
},
{ /* request_cls */
- H5VL_pass_through_request_wait, /* wait */
- H5VL_pass_through_request_notify, /* notify */
- H5VL_pass_through_request_cancel, /* cancel */
- H5VL_pass_through_request_specific, /* specific */
- H5VL_pass_through_request_optional, /* optional */
- H5VL_pass_through_request_free /* free */
+ H5VL_pass_through_request_wait, /* wait */
+ H5VL_pass_through_request_notify, /* notify */
+ H5VL_pass_through_request_cancel, /* cancel */
+ H5VL_pass_through_request_specific, /* specific */
+ H5VL_pass_through_request_optional, /* optional */
+ H5VL_pass_through_request_free /* free */
},
NULL /* optional */
};
@@ -289,6 +311,9 @@ H5VL_pass_through_new_obj(void *under_obj, hid_t under_vol_id)
*
* Purpose: Release a pass through object
*
+ * Note: Take care to preserve the current HDF5 error stack
+ * when calling HDF5 API calls.
+ *
* Return: Success: 0
* Failure: -1
*
@@ -300,7 +325,14 @@ H5VL_pass_through_new_obj(void *under_obj, hid_t under_vol_id)
static herr_t
H5VL_pass_through_free_obj(H5VL_pass_through_t *obj)
{
+ hid_t err_id;
+
+ err_id = H5Eget_current_stack();
+
H5Idec_ref(obj->under_vol_id);
+
+ H5Eset_current_stack(err_id);
+
free(obj);
return 0;
@@ -324,11 +356,8 @@ H5VL_pass_through_free_obj(H5VL_pass_through_t *obj)
hid_t
H5VL_pass_through_register(void)
{
- /* Clear the error stack */
- H5Eclear2(H5E_DEFAULT);
-
/* Singleton register the pass-through VOL connector ID */
- if(H5I_VOL != H5Iget_type(H5VL_PASSTHRU_g))
+ if(H5VL_PASSTHRU_g < 0)
H5VL_PASSTHRU_g = H5VLregister_connector(&H5VL_pass_through_g, H5P_DEFAULT);
return H5VL_PASSTHRU_g;
@@ -468,6 +497,9 @@ H5VL_pass_through_info_cmp(int *cmp_value, const void *_info1, const void *_info
*
* Purpose: Release an info object for the connector.
*
+ * Note: Take care to preserve the current HDF5 error stack
+ * when calling HDF5 API calls.
+ *
* Return: Success: 0
* Failure: -1
*
@@ -477,16 +509,21 @@ static herr_t
H5VL_pass_through_info_free(void *_info)
{
H5VL_pass_through_info_t *info = (H5VL_pass_through_info_t *)_info;
+ hid_t err_id;
#ifdef ENABLE_PASSTHRU_LOGGING
printf("------- PASS THROUGH VOL INFO Free\n");
#endif
+ err_id = H5Eget_current_stack();
+
/* Release underlying VOL ID and info */
if(info->under_vol_info)
H5VLfree_connector_info(info->under_vol_id, info->under_vol_info);
H5Idec_ref(info->under_vol_id);
+ H5Eset_current_stack(err_id);
+
/* Free pass through info object itself */
free(info);
@@ -655,8 +692,8 @@ H5VL_pass_through_get_wrap_ctx(const void *obj, void **wrap_ctx)
*
* Purpose: Use a "wrapper context" to wrap a data object
*
- * Return: Success: 0
- * Failure: -1
+ * Return: Success: Pointer to wrapped object
+ * Failure: NULL
*
*---------------------------------------------------------------------------
*/
@@ -683,10 +720,44 @@ H5VL_pass_through_wrap_object(void *obj, H5I_type_t obj_type, void *_wrap_ctx)
/*---------------------------------------------------------------------------
+ * Function: H5VL_pass_through_unwrap_object
+ *
+ * Purpose: Unwrap a wrapped object, discarding the wrapper, but returning
+ * underlying object.
+ *
+ * Return: Success: Pointer to unwrapped object
+ * Failure: NULL
+ *
+ *---------------------------------------------------------------------------
+ */
+static void *
+H5VL_pass_through_unwrap_object(void *obj)
+{
+ H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj;
+ void *under;
+
+#ifdef ENABLE_PASSTHRU_LOGGING
+ printf("------- PASS THROUGH VOL UNWRAP Object\n");
+#endif
+
+ /* Unrap the object with the underlying VOL */
+ under = H5VLunwrap_object(o->under_object, o->under_vol_id);
+
+ if(under)
+ H5VL_pass_through_free_obj(o);
+
+ return under;
+} /* end H5VL_pass_through_unwrap_object() */
+
+
+/*---------------------------------------------------------------------------
* Function: H5VL_pass_through_free_wrap_ctx
*
* Purpose: Release a "wrapper context" for an object
*
+ * Note: Take care to preserve the current HDF5 error stack
+ * when calling HDF5 API calls.
+ *
* Return: Success: 0
* Failure: -1
*
@@ -696,16 +767,21 @@ static herr_t
H5VL_pass_through_free_wrap_ctx(void *_wrap_ctx)
{
H5VL_pass_through_wrap_ctx_t *wrap_ctx = (H5VL_pass_through_wrap_ctx_t *)_wrap_ctx;
+ hid_t err_id;
#ifdef ENABLE_PASSTHRU_LOGGING
printf("------- PASS THROUGH VOL WRAP CTX Free\n");
#endif
+ err_id = H5Eget_current_stack();
+
/* Release underlying VOL ID and wrap context */
if(wrap_ctx->under_wrap_ctx)
H5VLfree_wrap_ctx(wrap_ctx->under_wrap_ctx, wrap_ctx->under_vol_id);
H5Idec_ref(wrap_ctx->under_vol_id);
+ H5Eset_current_stack(err_id);
+
/* Free pass through wrap context object itself */
free(wrap_ctx);
@@ -725,7 +801,8 @@ H5VL_pass_through_free_wrap_ctx(void *_wrap_ctx)
*/
static void *
H5VL_pass_through_attr_create(void *obj, const H5VL_loc_params_t *loc_params,
- const char *name, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req)
+ const char *name, hid_t type_id, hid_t space_id, hid_t acpl_id,
+ hid_t aapl_id, hid_t dxpl_id, void **req)
{
H5VL_pass_through_t *attr;
H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj;
@@ -735,7 +812,7 @@ H5VL_pass_through_attr_create(void *obj, const H5VL_loc_params_t *loc_params,
printf("------- PASS THROUGH VOL ATTRIBUTE Create\n");
#endif
- under = H5VLattr_create(o->under_object, loc_params, o->under_vol_id, name, acpl_id, aapl_id, dxpl_id, req);
+ under = H5VLattr_create(o->under_object, loc_params, o->under_vol_id, name, type_id, space_id, acpl_id, aapl_id, dxpl_id, req);
if(under) {
attr = H5VL_pass_through_new_obj(under, o->under_vol_id);
@@ -988,7 +1065,8 @@ H5VL_pass_through_attr_close(void *attr, hid_t dxpl_id, void **req)
*/
static void *
H5VL_pass_through_dataset_create(void *obj, const H5VL_loc_params_t *loc_params,
- const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req)
+ const char *name, hid_t lcpl_id, hid_t type_id, hid_t space_id,
+ hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req)
{
H5VL_pass_through_t *dset;
H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj;
@@ -998,7 +1076,7 @@ H5VL_pass_through_dataset_create(void *obj, const H5VL_loc_params_t *loc_params,
printf("------- PASS THROUGH VOL DATASET Create\n");
#endif
- under = H5VLdataset_create(o->under_object, loc_params, o->under_vol_id, name, dcpl_id, dapl_id, dxpl_id, req);
+ under = H5VLdataset_create(o->under_object, loc_params, o->under_vol_id, name, lcpl_id, type_id, space_id, dcpl_id, dapl_id, dxpl_id, req);
if(under) {
dset = H5VL_pass_through_new_obj(under, o->under_vol_id);
@@ -1158,17 +1236,22 @@ H5VL_pass_through_dataset_specific(void *obj, H5VL_dataset_specific_t specific_t
hid_t dxpl_id, void **req, va_list arguments)
{
H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj;
+ hid_t under_vol_id;
herr_t ret_value;
#ifdef ENABLE_PASSTHRU_LOGGING
printf("------- PASS THROUGH VOL H5Dspecific\n");
#endif
+ // Save copy of underlying VOL connector ID and prov helper, in case of
+ // refresh destroying the current object
+ under_vol_id = o->under_vol_id;
+
ret_value = H5VLdataset_specific(o->under_object, o->under_vol_id, specific_type, dxpl_id, req, arguments);
/* Check for async request */
if(req && *req)
- *req = H5VL_pass_through_new_obj(*req, o->under_vol_id);
+ *req = H5VL_pass_through_new_obj(*req, under_vol_id);
return ret_value;
} /* end H5VL_pass_through_dataset_specific() */
@@ -1360,17 +1443,22 @@ H5VL_pass_through_datatype_specific(void *obj, H5VL_datatype_specific_t specific
hid_t dxpl_id, void **req, va_list arguments)
{
H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj;
+ hid_t under_vol_id;
herr_t ret_value;
#ifdef ENABLE_PASSTHRU_LOGGING
printf("------- PASS THROUGH VOL DATATYPE Specific\n");
#endif
+ // Save copy of underlying VOL connector ID and prov helper, in case of
+ // refresh destroying the current object
+ under_vol_id = o->under_vol_id;
+
ret_value = H5VLdatatype_specific(o->under_object, o->under_vol_id, specific_type, dxpl_id, req, arguments);
/* Check for async request */
if(req && *req)
- *req = H5VL_pass_through_new_obj(*req, o->under_vol_id);
+ *req = H5VL_pass_through_new_obj(*req, under_vol_id);
return ret_value;
} /* end H5VL_pass_through_datatype_specific() */
@@ -1649,7 +1737,7 @@ H5VL_pass_through_file_specific(void *file, H5VL_file_specific_t specific_type,
/* Re-issue 'file specific' call, using the unwrapped pieces */
ret_value = H5VL_pass_through_file_specific_reissue(o->under_object, o->under_vol_id, specific_type, dxpl_id, req, (int)loc_type, name, child_file->under_object, plist_id);
} /* end if */
- else if(specific_type == H5VL_FILE_IS_ACCESSIBLE) {
+ else if(specific_type == H5VL_FILE_IS_ACCESSIBLE || specific_type == H5VL_FILE_DELETE) {
H5VL_pass_through_info_t *info;
hid_t fapl_id, under_fapl_id;
const char *name;
@@ -1792,7 +1880,8 @@ H5VL_pass_through_file_close(void *file, hid_t dxpl_id, void **req)
*/
static void *
H5VL_pass_through_group_create(void *obj, const H5VL_loc_params_t *loc_params,
- const char *name, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req)
+ const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id,
+ hid_t dxpl_id, void **req)
{
H5VL_pass_through_t *group;
H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj;
@@ -1802,7 +1891,7 @@ H5VL_pass_through_group_create(void *obj, const H5VL_loc_params_t *loc_params,
printf("------- PASS THROUGH VOL GROUP Create\n");
#endif
- under = H5VLgroup_create(o->under_object, loc_params, o->under_vol_id, name, gcpl_id, gapl_id, dxpl_id, req);
+ under = H5VLgroup_create(o->under_object, loc_params, o->under_vol_id, name, lcpl_id, gcpl_id, gapl_id, dxpl_id, req);
if(under) {
group = H5VL_pass_through_new_obj(under, o->under_vol_id);
@@ -1900,17 +1989,22 @@ H5VL_pass_through_group_specific(void *obj, H5VL_group_specific_t specific_type,
hid_t dxpl_id, void **req, va_list arguments)
{
H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj;
+ hid_t under_vol_id;
herr_t ret_value;
#ifdef ENABLE_PASSTHRU_LOGGING
printf("------- PASS THROUGH VOL GROUP Specific\n");
#endif
+ // Save copy of underlying VOL connector ID and prov helper, in case of
+ // refresh destroying the current object
+ under_vol_id = o->under_vol_id;
+
ret_value = H5VLgroup_specific(o->under_object, o->under_vol_id, specific_type, dxpl_id, req, arguments);
/* Check for async request */
if(req && *req)
- *req = H5VL_pass_through_new_obj(*req, o->under_vol_id);
+ *req = H5VL_pass_through_new_obj(*req, under_vol_id);
return ret_value;
} /* end H5VL_pass_through_group_specific() */
@@ -1982,6 +2076,32 @@ H5VL_pass_through_group_close(void *grp, hid_t dxpl_id, void **req)
/*-------------------------------------------------------------------------
+ * Function: H5VL_pass_through_link_create_reissue
+ *
+ * Purpose: Re-wrap vararg arguments into a va_list and reissue the
+ * link create callback to the underlying VOL connector.
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5VL_pass_through_link_create_reissue(H5VL_link_create_type_t create_type,
+ void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id,
+ hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req, ...)
+{
+ va_list arguments;
+ herr_t ret_value;
+
+ va_start(arguments, req);
+ ret_value = H5VLlink_create(create_type, obj, loc_params, connector_id, lcpl_id, lapl_id, dxpl_id, req, arguments);
+ va_end(arguments);
+
+ return ret_value;
+} /* end H5VL_pass_through_link_create_reissue() */
+
+/*-------------------------------------------------------------------------
* Function: H5VL_pass_through_link_create
*
* Purpose: Creates a hard / soft / UD / external link.
@@ -1992,7 +2112,9 @@ H5VL_pass_through_group_close(void *grp, hid_t dxpl_id, void **req)
*-------------------------------------------------------------------------
*/
static herr_t
-H5VL_pass_through_link_create(H5VL_link_create_type_t create_type, void *obj, const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req)
+H5VL_pass_through_link_create(H5VL_link_create_type_t create_type, void *obj,
+ const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t lapl_id,
+ hid_t dxpl_id, void **req, va_list arguments)
{
H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj;
hid_t under_vol_id = -1;
@@ -2009,9 +2131,11 @@ H5VL_pass_through_link_create(H5VL_link_create_type_t create_type, void *obj, co
/* Fix up the link target object for hard link creation */
if(H5VL_LINK_CREATE_HARD == create_type) {
void *cur_obj;
+ H5VL_loc_params_t cur_params;
- /* Retrieve the object for the link target */
- H5Pget(lcpl_id, H5VL_PROP_LINK_TARGET, &cur_obj);
+ /* Retrieve the object & loc params for the link target */
+ cur_obj = va_arg(arguments, void *);
+ cur_params = va_arg(arguments, H5VL_loc_params_t);
/* If it's a non-NULL pointer, find the 'under object' and re-set the property */
if(cur_obj) {
@@ -2020,11 +2144,14 @@ H5VL_pass_through_link_create(H5VL_link_create_type_t create_type, void *obj, co
under_vol_id = ((H5VL_pass_through_t *)cur_obj)->under_vol_id;
/* Set the object for the link target */
- H5Pset(lcpl_id, H5VL_PROP_LINK_TARGET, &(((H5VL_pass_through_t *)cur_obj)->under_object));
+ cur_obj = ((H5VL_pass_through_t *)cur_obj)->under_object;
} /* end if */
- } /* end if */
- ret_value = H5VLlink_create(create_type, (o ? o->under_object : NULL), loc_params, under_vol_id, lcpl_id, lapl_id, dxpl_id, req);
+ /* Re-issue 'link create' call, using the unwrapped pieces */
+ ret_value = H5VL_pass_through_link_create_reissue(create_type, (o ? o->under_object : NULL), loc_params, under_vol_id, lcpl_id, lapl_id, dxpl_id, req, cur_obj, cur_params);
+ } /* end if */
+ else
+ ret_value = H5VLlink_create(create_type, (o ? o->under_object : NULL), loc_params, under_vol_id, lcpl_id, lapl_id, dxpl_id, req, arguments);
/* Check for async request */
if(req && *req)
@@ -2336,17 +2463,22 @@ H5VL_pass_through_object_specific(void *obj, const H5VL_loc_params_t *loc_params
va_list arguments)
{
H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj;
+ hid_t under_vol_id;
herr_t ret_value;
#ifdef ENABLE_PASSTHRU_LOGGING
printf("------- PASS THROUGH VOL OBJECT Specific\n");
#endif
+ // Save copy of underlying VOL connector ID and prov helper, in case of
+ // refresh destroying the current object
+ under_vol_id = o->under_vol_id;
+
ret_value = H5VLobject_specific(o->under_object, loc_params, o->under_vol_id, specific_type, dxpl_id, req, arguments);
/* Check for async request */
if(req && *req)
- *req = H5VL_pass_through_new_obj(*req, o->under_vol_id);
+ *req = H5VL_pass_through_new_obj(*req, under_vol_id);
return ret_value;
} /* end H5VL_pass_through_object_specific() */
diff --git a/src/H5VLpkg.h b/src/H5VLpkg.h
index bbdb0cc..69e51c2 100644
--- a/src/H5VLpkg.h
+++ b/src/H5VLpkg.h
@@ -28,21 +28,36 @@
/* Other private headers needed by this file */
+
/**************************/
/* Package Private Macros */
/**************************/
+
/****************************/
/* Package Private Typedefs */
/****************************/
+
/*****************************/
/* Package Private Variables */
/*****************************/
+
/******************************/
/* Package Private Prototypes */
/******************************/
+H5_DLL hid_t H5VL__register_connector(const H5VL_class_t *cls, hbool_t app_ref,
+ hid_t vipl_id);
+H5_DLL hid_t H5VL__register_connector_by_name(const char *name, hbool_t app_ref,
+ hid_t vipl_id);
+H5_DLL hid_t H5VL__register_connector_by_value(H5VL_class_value_t value,
+ hbool_t app_ref, hid_t vipl_id);
+H5_DLL htri_t H5VL__is_connector_registered(const char *name);
+H5_DLL hid_t H5VL__get_connector_id(const char *name, hbool_t is_api);
+H5_DLL herr_t H5VL__connector_str_to_info(const char *str, hid_t connector_id,
+ void **info);
+H5_DLL ssize_t H5VL__get_connector_name(hid_t id, char *name/*out*/, size_t size);
#endif /* _H5VLpkg_H */
diff --git a/src/H5VLprivate.h b/src/H5VLprivate.h
index 283c77a..91fa762 100644
--- a/src/H5VLprivate.h
+++ b/src/H5VLprivate.h
@@ -18,10 +18,12 @@
/* Private headers needed by this file */
+
/**************************/
/* Library Private Macros */
/**************************/
+
/****************************/
/* Library Private Typedefs */
/****************************/
@@ -41,8 +43,8 @@ typedef struct H5VL_object_t {
/* Internal structure to hold the connector ID & info for FAPLs */
typedef struct H5VL_connector_prop_t {
- hid_t connector_id; /* VOL connector's ID */
- const void *connector_info; /* VOL connector info, for open callbacks */
+ hid_t connector_id; /* VOL connector's ID */
+ void *connector_info; /* VOL connector info, for open callbacks */
} H5VL_connector_prop_t;
/* Which kind of VOL connector field to use for searching */
@@ -62,14 +64,14 @@ typedef enum H5VL_get_connector_kind_t {
/******************************/
/* Utility functions */
-H5_DLL herr_t H5VL_init(void);
+H5_DLL herr_t H5VL_init_phase1(void);
+H5_DLL herr_t H5VL_init_phase2(void);
H5_DLL herr_t H5VL_cmp_connector_cls(int *cmp_value, const H5VL_class_t *cls1, const H5VL_class_t *cls2);
H5_DLL herr_t H5VL_conn_copy(H5VL_connector_prop_t *value);
H5_DLL herr_t H5VL_conn_free(const H5VL_connector_prop_t *info);
/* Functions that deal with VOL connectors */
H5_DLL hid_t H5VL_register_connector(const void *cls, hbool_t app_ref, hid_t vipl_id);
-H5_DLL ssize_t H5VL_get_connector_name(hid_t id, char *name/*out*/, size_t size);
/* NOTE: The object and ID functions below deal in VOL objects (i.e.;
* H5VL_object_t). Similar non-VOL calls exist in H5Iprivate.h. Use
@@ -84,6 +86,7 @@ H5_DLL ssize_t H5VL_get_connector_name(hid_t id, char *name/*out*/, size_t size)
/* Functions that manipulate VOL objects */
H5_DLL void *H5VL_object(hid_t id);
H5_DLL void *H5VL_object_data(const H5VL_object_t *vol_obj);
+H5_DLL void *H5VL_object_unwrap(const H5VL_object_t *vol_obj);
H5_DLL void *H5VL_object_verify(hid_t id, H5I_type_t obj_type);
H5_DLL H5VL_object_t *H5VL_vol_object(hid_t id);
H5_DLL herr_t H5VL_free_object(H5VL_object_t *obj);
@@ -91,11 +94,20 @@ H5_DLL herr_t H5VL_free_object(H5VL_object_t *obj);
/* Functions that wrap / unwrap VOL objects */
H5_DLL herr_t H5VL_get_wrap_ctx(const H5VL_class_t *connector, void *obj,
void **wrap_ctx);
-H5_DLL herr_t H5VL_free_wrap_ctx(const H5VL_class_t *connector, void *wrap_ctx);
-H5_DLL herr_t H5VL_set_vol_wrapper(void *obj, const H5VL_t *vol_connector);
-H5_DLL herr_t H5VL_reset_vol_wrapper(void);
H5_DLL void * H5VL_wrap_object(const H5VL_class_t *connector, void *wrap_ctx,
void *obj, H5I_type_t obj_type);
+H5_DLL void * H5VL_unwrap_object(const H5VL_class_t *connector, void *obj);
+H5_DLL herr_t H5VL_free_wrap_ctx(const H5VL_class_t *connector, void *wrap_ctx);
+H5_DLL herr_t H5VL_set_vol_wrapper(void *obj, H5VL_t *vol_connector);
+H5_DLL herr_t H5VL_inc_vol_wrapper(void *vol_wrap_ctx);
+H5_DLL herr_t H5VL_dec_vol_wrapper(void *vol_wrap_ctx);
+H5_DLL herr_t H5VL_reset_vol_wrapper(void);
+
+/* Library state functions */
+H5_DLL herr_t H5VL_retrieve_lib_state(void **state);
+H5_DLL herr_t H5VL_restore_lib_state(const void *state);
+H5_DLL herr_t H5VL_reset_lib_state(void);
+H5_DLL herr_t H5VL_free_lib_state(void *state);
/* ID registration functions */
H5_DLL hid_t H5VL_register(H5I_type_t type, void *object, H5VL_t *vol_connector, hbool_t app_ref);
@@ -112,10 +124,10 @@ H5_DLL int H5VL_copy_connector_info(const H5VL_class_t *connector, void **dst_in
const void *src_info);
H5_DLL herr_t H5VL_cmp_connector_info(const H5VL_class_t *connector, int *cmp_value,
const void *info1, const void *info2);
-H5_DLL herr_t H5VL_free_connector_info(const H5VL_class_t *connector, void *info);
+H5_DLL herr_t H5VL_free_connector_info(hid_t connector_id, void *info);
/* Attribute functions */
-H5_DLL void *H5VL_attr_create(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, const char *attr_name, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req);
+H5_DLL void *H5VL_attr_create(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, const char *attr_name, hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req);
H5_DLL void *H5VL_attr_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t aapl_id, hid_t dxpl_id, void **req);
H5_DLL herr_t H5VL_attr_read(const H5VL_object_t *vol_obj, hid_t dtype_id, void *buf, hid_t dxpl_id, void **req);
H5_DLL herr_t H5VL_attr_write(const H5VL_object_t *vol_obj, hid_t dtype_id, const void *buf, hid_t dxpl_id, void **req);
@@ -125,7 +137,7 @@ H5_DLL herr_t H5VL_attr_optional(const H5VL_object_t *vol_obj, hid_t dxpl_id, vo
H5_DLL herr_t H5VL_attr_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req);
/* Dataset functions */
-H5_DLL void *H5VL_dataset_create(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req);
+H5_DLL void *H5VL_dataset_create(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t lcpl_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req);
H5_DLL void *H5VL_dataset_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t dapl_id, hid_t dxpl_id, void **req);
H5_DLL herr_t H5VL_dataset_read(const H5VL_object_t *vol_obj, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, void *buf, void **req);
H5_DLL herr_t H5VL_dataset_write(const H5VL_object_t *vol_obj, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, const void *buf, void **req);
@@ -143,7 +155,7 @@ H5_DLL herr_t H5VL_file_optional(const H5VL_object_t *vol_obj, hid_t dxpl_id, vo
H5_DLL herr_t H5VL_file_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req);
/* Group functions */
-H5_DLL void *H5VL_group_create(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req);
+H5_DLL void *H5VL_group_create(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req);
H5_DLL void *H5VL_group_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t gapl_id, hid_t dxpl_id, void **req);
H5_DLL herr_t H5VL_group_get(const H5VL_object_t *vol_obj, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, ...);
H5_DLL herr_t H5VL_group_specific(const H5VL_object_t *vol_obj, H5VL_group_specific_t specific_type, hid_t dxpl_id, void **req, ...);
@@ -151,7 +163,7 @@ H5_DLL herr_t H5VL_group_optional(const H5VL_object_t *vol_obj, hid_t dxpl_id, v
H5_DLL herr_t H5VL_group_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req);
/* Link functions */
-H5_DLL herr_t H5VL_link_create(H5VL_link_create_type_t create_type, const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req);
+H5_DLL herr_t H5VL_link_create(H5VL_link_create_type_t create_type, const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req, ...);
H5_DLL herr_t H5VL_link_copy(const H5VL_object_t *src_vol_obj, const H5VL_loc_params_t *loc_params1, const H5VL_object_t *dst_vol_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req);
H5_DLL herr_t H5VL_link_move(const H5VL_object_t *src_vol_obj, const H5VL_loc_params_t *loc_params1, const H5VL_object_t *dst_vol_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req);
H5_DLL herr_t H5VL_link_get(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_t get_type, hid_t dxpl_id, void **req, ...);
diff --git a/src/H5VLpublic.h b/src/H5VLpublic.h
index 6ea9fc1..12448b6 100644
--- a/src/H5VLpublic.h
+++ b/src/H5VLpublic.h
@@ -19,390 +19,29 @@
/* Public headers needed by this file */
#include "H5public.h" /* Generic Functions */
-#include "H5Apublic.h" /* Attributes */
-#include "H5ESpublic.h" /* Event Stack */
-#include "H5Fpublic.h" /* Files */
-#include "H5Ipublic.h" /* IDs */
-#include "H5Lpublic.h" /* Links */
-#include "H5Opublic.h" /* Objects */
-#include "H5Rpublic.h" /* References */
+#include "H5Ipublic.h" /* IDs */
+
+/* Semi-public headers mainly for VOL connector authors */
+#include "H5VLconnector.h"
+#include "H5VLconnector_passthru.h"
/*****************/
/* Public Macros */
/*****************/
-/* Dataset creation property names */
-#define H5VL_PROP_DSET_TYPE_ID "dataset_type_id"
-#define H5VL_PROP_DSET_SPACE_ID "dataset_space_id"
-#define H5VL_PROP_DSET_LCPL_ID "dataset_lcpl_id"
-
-/* Attribute creation property names */
-#define H5VL_PROP_ATTR_TYPE_ID "attr_type_id"
-#define H5VL_PROP_ATTR_SPACE_ID "attr_space_id"
-#define H5VL_PROP_ATTR_LOC_PARAMS "attr_location"
-
-/* Link creation property names */
-#define H5VL_PROP_LINK_TARGET "target_location_object"
-#define H5VL_PROP_LINK_TARGET_LOC_PARAMS "target_params"
-#define H5VL_PROP_LINK_TARGET_NAME "target_name"
-#define H5VL_PROP_LINK_TYPE "link type"
-#define H5VL_PROP_LINK_UDATA "udata"
-#define H5VL_PROP_LINK_UDATA_SIZE "udata size"
-
-/* Group creation property names */
-#define H5VL_PROP_GRP_LCPL_ID "group_lcpl_id"
-
-/* Default VOL connector value */
-#define H5VL_VOL_DEFAULT 0
-
-
-/*******************/
-/* Public Typedefs */
-/*******************/
-
-/* types for attribute GET callback */
-typedef enum H5VL_attr_get_t {
- H5VL_ATTR_GET_ACPL, /* creation property list */
- H5VL_ATTR_GET_INFO, /* info */
- H5VL_ATTR_GET_NAME, /* access property list */
- H5VL_ATTR_GET_SPACE, /* dataspace */
- H5VL_ATTR_GET_STORAGE_SIZE, /* storage size */
- H5VL_ATTR_GET_TYPE /* datatype */
-} H5VL_attr_get_t;
-
-/* types for attribute SPECFIC callback */
-typedef enum H5VL_attr_specific_t {
- H5VL_ATTR_DELETE, /* H5Adelete(_by_name/idx) */
- H5VL_ATTR_EXISTS, /* H5Aexists(_by_name) */
- H5VL_ATTR_ITER, /* H5Aiterate(_by_name) */
- H5VL_ATTR_RENAME /* H5Arename(_by_name) */
-} H5VL_attr_specific_t;
-
-/* types for dataset GET callback */
-typedef enum H5VL_dataset_get_t {
- H5VL_DATASET_GET_DAPL, /* access property list */
- H5VL_DATASET_GET_DCPL, /* creation property list */
- H5VL_DATASET_GET_OFFSET, /* offset */
- H5VL_DATASET_GET_SPACE, /* dataspace */
- H5VL_DATASET_GET_SPACE_STATUS, /* space status */
- H5VL_DATASET_GET_STORAGE_SIZE, /* storage size */
- H5VL_DATASET_GET_TYPE /* datatype */
-} H5VL_dataset_get_t;
-
-/* types for dataset SPECFIC callback */
-typedef enum H5VL_dataset_specific_t {
- H5VL_DATASET_SET_EXTENT, /* H5Dset_extent */
- H5VL_DATASET_FLUSH, /* H5Dflush */
- H5VL_DATASET_REFRESH /* H5Drefresh */
-} H5VL_dataset_specific_t;
-
-/* types for datatype GET callback */
-typedef enum H5VL_datatype_get_t {
- H5VL_DATATYPE_GET_BINARY, /* get serialized form of transient type */
- H5VL_DATATYPE_GET_TCPL /* datatype creation property list */
-} H5VL_datatype_get_t;
-
-/* types for datatype SPECFIC callback */
-typedef enum H5VL_datatype_specific_t {
- H5VL_DATATYPE_FLUSH,
- H5VL_DATATYPE_REFRESH
-} H5VL_datatype_specific_t;
-
-/* types for file GET callback */
-typedef enum H5VL_file_get_t {
- H5VL_FILE_GET_FAPL, /* file access property list */
- H5VL_FILE_GET_FCPL, /* file creation property list */
- H5VL_FILE_GET_INTENT, /* file intent */
- H5VL_FILE_GET_NAME, /* file name */
- H5VL_FILE_GET_OBJ_COUNT, /* object count in file */
- H5VL_FILE_GET_OBJ_IDS /* object ids in file */
-} H5VL_file_get_t;
-
-/* types for file SPECIFIC callback */
-typedef enum H5VL_file_specific_t {
- H5VL_FILE_FLUSH, /* Flush file */
- H5VL_FILE_REOPEN, /* Reopen the file */
- H5VL_FILE_MOUNT, /* Mount a file */
- H5VL_FILE_UNMOUNT, /* Unmount a file */
- H5VL_FILE_IS_ACCESSIBLE /* Check if a file is accessible */
-} H5VL_file_specific_t;
-
-/* types for group GET callback */
-typedef enum H5VL_group_get_t {
- H5VL_GROUP_GET_GCPL, /* group creation property list */
- H5VL_GROUP_GET_INFO /* group info */
-} H5VL_group_get_t;
-
-/* types for group SPECFIC callback */
-typedef enum H5VL_group_specific_t {
- H5VL_GROUP_FLUSH,
- H5VL_GROUP_REFRESH
-} H5VL_group_specific_t;
-
-/* link create types for VOL */
-typedef enum H5VL_link_create_type_t {
- H5VL_LINK_CREATE_HARD,
- H5VL_LINK_CREATE_SOFT,
- H5VL_LINK_CREATE_UD
-} H5VL_link_create_type_t;
-
-/* types for link GET callback */
-typedef enum H5VL_link_get_t {
- H5VL_LINK_GET_INFO, /* link info */
- H5VL_LINK_GET_NAME, /* link name */
- H5VL_LINK_GET_VAL /* link value */
-} H5VL_link_get_t;
-
-/* types for link SPECIFIC callback */
-typedef enum H5VL_link_specific_t {
- H5VL_LINK_DELETE, /* H5Ldelete(_by_idx) */
- H5VL_LINK_EXISTS, /* link existence */
- H5VL_LINK_ITER /* H5Literate/visit(_by_name) */
-} H5VL_link_specific_t;
-
-/* types for object GET callback */
-typedef enum H5VL_object_get_t {
- H5VL_REF_GET_NAME, /* object name, for reference */
- H5VL_REF_GET_REGION, /* dataspace of region */
- H5VL_REF_GET_TYPE, /* type of object */
- H5VL_ID_GET_NAME /* object name, for hid_t */
-} H5VL_object_get_t;
-
-/* types for object SPECIFIC callback */
-typedef enum H5VL_object_specific_t {
- H5VL_OBJECT_CHANGE_REF_COUNT, /* H5Oincr/decr_refcount */
- H5VL_OBJECT_EXISTS, /* H5Oexists_by_name */
- H5VL_OBJECT_VISIT, /* H5Ovisit(_by_name) */
- H5VL_REF_CREATE, /* H5Rcreate */
- H5VL_OBJECT_FLUSH, /* H5{D|G|O|T}flush */
- H5VL_OBJECT_REFRESH /* H5{D|G|O|T}refresh */
-} H5VL_object_specific_t;
-
-/* types for async request SPECIFIC callback */
-typedef enum H5VL_request_specific_t {
- H5VL_REQUEST_WAITANY, /* Wait until any request completes */
- H5VL_REQUEST_WAITSOME, /* Wait until at least one requesst completes */
- H5VL_REQUEST_WAITALL /* Wait until all requests complete */
-} H5VL_request_specific_t;
-
-/* types for different ways that objects are located in an HDF5 container */
-typedef enum H5VL_loc_type_t {
- H5VL_OBJECT_BY_SELF,
- H5VL_OBJECT_BY_NAME,
- H5VL_OBJECT_BY_IDX,
- H5VL_OBJECT_BY_ADDR,
- H5VL_OBJECT_BY_REF
-} H5VL_loc_type_t;
-
-struct H5VL_loc_by_name {
- const char *name;
- hid_t lapl_id;
-};
-
-struct H5VL_loc_by_idx {
- const char *name;
- H5_index_t idx_type;
- H5_iter_order_t order;
- hsize_t n;
- hid_t lapl_id;
-};
-
-struct H5VL_loc_by_addr {
- haddr_t addr;
-};
-
-struct H5VL_loc_by_ref {
- H5R_type_t ref_type;
- const void *_ref;
- hid_t lapl_id;
-};
-
-/* Structure to hold parameters for object locations.
- * either: BY_ADDR, BY_ID, BY_NAME, BY_IDX, BY_REF
- *
- * Note: Leave loc_by_addr as the first union member so we
- * can perform the simplest initialization of the struct
- * without raising warnings.
- */
-typedef struct H5VL_loc_params_t {
- H5I_type_t obj_type;
- H5VL_loc_type_t type;
- union{
- struct H5VL_loc_by_addr loc_by_addr;
- struct H5VL_loc_by_name loc_by_name;
- struct H5VL_loc_by_idx loc_by_idx;
- struct H5VL_loc_by_ref loc_by_ref;
- } loc_data;
-} H5VL_loc_params_t;
-
-/* H5A routines */
-typedef struct H5VL_attr_class_t {
- void *(*create)(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name,
- hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req);
- void *(*open)(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name,
- hid_t aapl_id, hid_t dxpl_id, void **req);
- herr_t (*read)(void *attr, hid_t mem_type_id, void *buf, hid_t dxpl_id, void **req);
- herr_t (*write)(void *attr, hid_t mem_type_id, const void *buf, hid_t dxpl_id, void **req);
- herr_t (*get)(void *obj, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, va_list arguments);
- herr_t (*specific)(void *obj, const H5VL_loc_params_t *loc_params, H5VL_attr_specific_t specific_type,
- hid_t dxpl_id, void **req, va_list arguments);
- herr_t (*optional)(void *obj, hid_t dxpl_id, void **req, va_list arguments);
- herr_t (*close) (void *attr, hid_t dxpl_id, void **req);
-} H5VL_attr_class_t;
-
-/* H5D routines */
-typedef struct H5VL_dataset_class_t {
- void *(*create)(void *obj, const H5VL_loc_params_t *loc_params, const char *name,
- hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req);
- void *(*open)(void *obj, const H5VL_loc_params_t *loc_params, const char *name,
- hid_t dapl_id, hid_t dxpl_id, void **req);
- herr_t (*read)(void *dset, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id,
- hid_t xfer_plist_id, void * buf, void **req);
- herr_t (*write)(void *dset, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id,
- hid_t xfer_plist_id, const void * buf, void **req);
- herr_t (*get)(void *obj, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, va_list arguments);
- herr_t (*specific)(void *obj, H5VL_dataset_specific_t specific_type,
- hid_t dxpl_id, void **req, va_list arguments);
- herr_t (*optional)(void *obj, hid_t dxpl_id, void **req, va_list arguments);
- herr_t (*close) (void *dset, hid_t dxpl_id, void **req);
-} H5VL_dataset_class_t;
-
-/* H5T routines*/
-typedef struct H5VL_datatype_class_t {
- void *(*commit)(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t type_id,
- hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, void **req);
- void *(*open)(void *obj, const H5VL_loc_params_t *loc_params, const char * name,
- hid_t tapl_id, hid_t dxpl_id, void **req);
- herr_t (*get) (void *obj, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, va_list arguments);
- herr_t (*specific)(void *obj, H5VL_datatype_specific_t specific_type,
- hid_t dxpl_id, void **req, va_list arguments);
- herr_t (*optional)(void *obj, hid_t dxpl_id, void **req, va_list arguments);
- herr_t (*close) (void *dt, hid_t dxpl_id, void **req);
-} H5VL_datatype_class_t;
-
-/* H5F routines */
-typedef struct H5VL_file_class_t {
- void *(*create)(const char *name, unsigned flags, hid_t fcpl_id,
- hid_t fapl_id, hid_t dxpl_id, void **req);
- void *(*open)(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req);
- herr_t (*get)(void *obj, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, va_list arguments);
- herr_t (*specific)(void *obj, H5VL_file_specific_t specific_type,
- hid_t dxpl_id, void **req, va_list arguments);
- herr_t (*optional)(void *obj, hid_t dxpl_id, void **req, va_list arguments);
- herr_t (*close) (void *file, hid_t dxpl_id, void **req);
-} H5VL_file_class_t;
-
-/* H5G routines */
-typedef struct H5VL_group_class_t {
- void *(*create)(void *obj, const H5VL_loc_params_t *loc_params, const char *name,
- hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req);
- void *(*open)(void *obj, const H5VL_loc_params_t *loc_params, const char *name,
- hid_t gapl_id, hid_t dxpl_id, void **req);
- herr_t (*get)(void *obj, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, va_list arguments);
- herr_t (*specific)(void *obj, H5VL_group_specific_t specific_type,
- hid_t dxpl_id, void **req, va_list arguments);
- herr_t (*optional)(void *obj, hid_t dxpl_id, void **req, va_list arguments);
- herr_t (*close) (void *grp, hid_t dxpl_id, void **req);
-} H5VL_group_class_t;
-
-/* H5L routines */
-typedef struct H5VL_link_class_t {
- herr_t (*create)(H5VL_link_create_type_t create_type, void *obj, const H5VL_loc_params_t *loc_params,
- hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req);
- herr_t (*copy)(void *src_obj, const H5VL_loc_params_t *loc_params1,
- void *dst_obj, const H5VL_loc_params_t *loc_params2,
- hid_t lcpl, hid_t lapl, hid_t dxpl_id, void **req);
- herr_t (*move)(void *src_obj, const H5VL_loc_params_t *loc_params1,
- void *dst_obj, const H5VL_loc_params_t *loc_params2,
- hid_t lcpl, hid_t lapl, hid_t dxpl_id, void **req);
- herr_t (*get)(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_t get_type,
- hid_t dxpl_id, void **req, va_list arguments);
- herr_t (*specific)(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_specific_t specific_type,
- hid_t dxpl_id, void **req, va_list arguments);
- herr_t (*optional)(void *obj, hid_t dxpl_id, void **req, va_list arguments);
-} H5VL_link_class_t;
-
-/* H5O routines */
-typedef struct H5VL_object_class_t {
- void *(*open)(void *obj, const H5VL_loc_params_t *loc_params, H5I_type_t *opened_type,
- hid_t dxpl_id, void **req);
- herr_t (*copy)(void *src_obj, const H5VL_loc_params_t *loc_params1, const char *src_name,
- void *dst_obj, const H5VL_loc_params_t *loc_params2, const char *dst_name,
- hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req);
- herr_t (*get)(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_get_t get_type,
- hid_t dxpl_id, void **req, va_list arguments);
- herr_t (*specific)(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_specific_t specific_type,
- hid_t dxpl_id, void **req, va_list arguments);
- herr_t (*optional)(void *obj, hid_t dxpl_id, void **req, va_list arguments);
-} H5VL_object_class_t;
-
-/* Asynchronous request 'notify' callback */
-typedef herr_t (*H5VL_request_notify_t)(void *ctx, H5ES_status_t status);
-
-/* Async request operation routines */
-typedef struct H5VL_request_class_t {
- herr_t (*wait)(void *req, uint64_t timeout, H5ES_status_t *status);
- herr_t (*notify)(void *req, H5VL_request_notify_t cb, void *ctx);
- herr_t (*cancel)(void *req);
- herr_t (*specific)(void *req, H5VL_request_specific_t specific_type, va_list arguments);
- herr_t (*optional)(void *req, va_list arguments);
- herr_t (*free)(void *req);
-} H5VL_request_class_t;
-
-/*
- * VOL connector identifiers. Values 0 through 255 are for connectors defined
- * by the HDF5 library. Values 256 through 511 are available for testing new
- * filters. Subsequent values should be obtained from the HDF5 development
- * team at help@hdfgroup.org.
+/* VOL connector identifier values
+ * These are H5VL_class_value_t values, NOT hid_t values!
*/
-typedef int H5VL_class_value_t;
-
-/* VOL connector identifier values */
#define H5_VOL_INVALID (-1) /* Invalid ID for VOL connector iD */
-#define H5_VOL_NATIVE 0 /* Native HDF5 file formnat VOL connector */
+#define H5_VOL_NATIVE 0 /* Native HDF5 file format VOL connector */
#define H5_VOL_RESERVED 256 /* VOL connector IDs below this value are reserved for library use */
-#define H5_VOL_MAX 65535 /* Maximum VOL connector ID */
-
-/* Capability flags for connector */
-#define H5VL_CAP_FLAG_NONE 0 /* No special connector capabilities */
-#define H5VL_CAP_FLAG_THREADSAFE 0x01 /* Connector is threadsafe */
+#define H5_VOL_MAX 65535 /* Maximum VOL connector ID */
-/* Class information for each VOL connector */
-typedef struct H5VL_class_t {
- unsigned int version; /* VOL connector class struct version # */
- H5VL_class_value_t value; /* Value to identify connector */
- const char *name; /* Connector name (MUST be unique!) */
- unsigned cap_flags; /* Capability flags for connector */
- herr_t (*initialize)(hid_t vipl_id); /* Connector initialization callback */
- herr_t (*terminate)(void); /* Connector termination callback */
- size_t info_size; /* Size of the VOL info */
- void * (*info_copy)(const void *info); /* Callback to create a copy of the VOL info */
- herr_t (*info_cmp)(int *cmp_value, const void *info1, const void *info2); /* Callback to compare VOL info */
- herr_t (*info_free)(void *info); /* Callback to release the VOL info copy */
- herr_t (*info_to_str)(const void *info, char **str); /* Callback to serialize connector's info into a string */
- herr_t (*str_to_info)(const char *str, void **info); /* Callback to deserialize a string into connector's info */
- void * (*get_object)(const void *obj); /* Callback to retrieve underlying object */
- herr_t (*get_wrap_ctx)(const void *obj, void **wrap_ctx); /* Callback to retrieve the object wrapping context for the connector */
- void* (*wrap_object)(void *obj, H5I_type_t obj_type, void *wrap_ctx); /* Callback to wrap a library object */
- herr_t (*free_wrap_ctx)(void *wrap_ctx); /* Callback to release the object wrapping context for the connector */
-
- /* Data Model */
- H5VL_attr_class_t attr_cls; /* attribute class callbacks */
- H5VL_dataset_class_t dataset_cls; /* dataset class callbacks */
- H5VL_datatype_class_t datatype_cls; /* datatype class callbacks */
- H5VL_file_class_t file_cls; /* file class callbacks */
- H5VL_group_class_t group_cls; /* group class callbacks */
- H5VL_link_class_t link_cls; /* link class callbacks */
- H5VL_object_class_t object_cls; /* object class callbacks */
-
- /* Services */
- H5VL_request_class_t request_cls; /* asynchronous request class callbacks */
-
- /* Catch-all */
- herr_t (*optional)(void *obj, hid_t dxpl_id, void **req, va_list arguments); /* Optional callback */
-} H5VL_class_t;
+/*******************/
+/* Public Typedefs */
+/*******************/
/********************/
/* Public Variables */
@@ -416,7 +55,10 @@ typedef struct H5VL_class_t {
extern "C" {
#endif
-/* VOL Connector Functionality */
+/* The H5VL types uses in the API calls are not opaque - they are defined in
+ * H5VLconnector.h, which is included at the top of this file.
+ */
+
H5_DLL hid_t H5VLregister_connector(const H5VL_class_t *cls, hid_t vipl_id);
H5_DLL hid_t H5VLregister_connector_by_name(const char *connector_name, hid_t vipl_id);
H5_DLL hid_t H5VLregister_connector_by_value(H5VL_class_value_t connector_value, hid_t vipl_id);
@@ -427,107 +69,6 @@ H5_DLL herr_t H5VLclose(hid_t connector_id);
H5_DLL herr_t H5VLunregister_connector(hid_t connector_id);
-/*****************************************************************************
- * VOL callback wrappers and helper routines, for _VOL_connector_ authors only! *
- * (Not part of the public API for _application_ developers) *
- *****************************************************************************/
-
-/* Helper routines for VOL connector authors */
-H5_DLL herr_t H5VLcmp_connector_cls(int *cmp, hid_t connector_id1, hid_t connector_id2);
-H5_DLL hid_t H5VLwrap_register(void *obj, H5I_type_t type);
-H5_DLL void *H5VLobject(hid_t obj_id);
-
-
-/* Public wrappers for generic callbacks */
-H5_DLL herr_t H5VLinitialize(hid_t connector_id, hid_t vipl_id);
-H5_DLL herr_t H5VLterminate(hid_t connector_id);
-H5_DLL herr_t H5VLget_cap_flags(hid_t connector_id, unsigned *cap_flags);
-H5_DLL herr_t H5VLget_value(hid_t connector_id, H5VL_class_value_t *conn_value);
-H5_DLL herr_t H5VLcopy_connector_info(hid_t connector_id, void **dst_vol_info, void *src_vol_info);
-H5_DLL herr_t H5VLcmp_connector_info(int *cmp, hid_t connector_id, const void *info1,
- const void *info2);
-H5_DLL herr_t H5VLfree_connector_info(hid_t connector_id, void *vol_info);
-H5_DLL herr_t H5VLconnector_info_to_str(const void *info, hid_t connector_id, char **str);
-H5_DLL herr_t H5VLconnector_str_to_info(const char *str, hid_t connector_id, void **info);
-H5_DLL void *H5VLget_object(void *obj, hid_t connector_id);
-H5_DLL herr_t H5VLget_wrap_ctx(void *obj, hid_t connector_id, void **wrap_ctx);
-H5_DLL void *H5VLwrap_object(void *obj, H5I_type_t obj_type, hid_t connector_id,
- void *wrap_ctx);
-H5_DLL herr_t H5VLfree_wrap_ctx(void *wrap_ctx, hid_t connector_id);
-
-/* Public wrappers for attribute callbacks */
-H5_DLL void *H5VLattr_create(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *attr_name, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req);
-H5_DLL void *H5VLattr_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, hid_t aapl_id, hid_t dxpl_id, void **req);
-H5_DLL herr_t H5VLattr_read(void *attr, hid_t connector_id, hid_t dtype_id, void *buf, hid_t dxpl_id, void **req);
-H5_DLL herr_t H5VLattr_write(void *attr, hid_t connector_id, hid_t dtype_id, const void *buf, hid_t dxpl_id, void **req);
-H5_DLL herr_t H5VLattr_get(void *obj, hid_t connector_id, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, va_list arguments);
-H5_DLL herr_t H5VLattr_specific(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments);
-H5_DLL herr_t H5VLattr_optional(void *obj, hid_t connector_id, hid_t dxpl_id, void **req, va_list arguments);
-H5_DLL herr_t H5VLattr_close(void *attr, hid_t connector_id, hid_t dxpl_id, void **req);
-
-/* Public wrappers for dataset callbacks */
-H5_DLL void *H5VLdataset_create(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req);
-H5_DLL void *H5VLdataset_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, hid_t dapl_id, hid_t dxpl_id, void **req);
-H5_DLL herr_t H5VLdataset_read(void *dset, hid_t connector_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, void *buf, void **req);
-H5_DLL herr_t H5VLdataset_write(void *dset, hid_t connector_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, const void *buf, void **req);
-H5_DLL herr_t H5VLdataset_get(void *dset, hid_t connector_id, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, va_list arguments);
-H5_DLL herr_t H5VLdataset_specific(void *obj, hid_t connector_id, H5VL_dataset_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments);
-H5_DLL herr_t H5VLdataset_optional(void *obj, hid_t connector_id, hid_t dxpl_id, void **req, va_list arguments);
-H5_DLL herr_t H5VLdataset_close(void *dset, hid_t connector_id, hid_t dxpl_id, void **req);
-
-/* Public wrappers for file callbacks */
-H5_DLL void *H5VLfile_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req);
-H5_DLL void *H5VLfile_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req);
-H5_DLL herr_t H5VLfile_get(void *file, hid_t connector_id, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, va_list arguments);
-H5_DLL herr_t H5VLfile_specific(void *obj, hid_t connector_id, H5VL_file_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments);
-H5_DLL herr_t H5VLfile_optional(void *obj, hid_t connector_id, hid_t dxpl_id, void **req, va_list arguments);
-H5_DLL herr_t H5VLfile_close(void *file, hid_t connector_id, hid_t dxpl_id, void **req);
-
-/* Public wrappers for group callbacks */
-H5_DLL void *H5VLgroup_create(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req);
-H5_DLL void *H5VLgroup_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, hid_t gapl_id, hid_t dxpl_id, void **req);
-H5_DLL herr_t H5VLgroup_get(void *obj, hid_t connector_id, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, va_list arguments);
-H5_DLL herr_t H5VLgroup_specific(void *obj, hid_t connector_id, H5VL_group_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments);
-H5_DLL herr_t H5VLgroup_optional(void *obj, hid_t connector_id, hid_t dxpl_id, void **req, va_list arguments);
-H5_DLL herr_t H5VLgroup_close(void *grp, hid_t connector_id, hid_t dxpl_id, void **req);
-
-/* Public wrappers for link callbacks */
-H5_DLL herr_t H5VLlink_create(H5VL_link_create_type_t create_type, void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req);
-H5_DLL herr_t H5VLlink_copy(void *src_obj, const H5VL_loc_params_t *loc_params1,
- void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t connector_id,
- hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req);
-H5_DLL herr_t H5VLlink_move(void *src_obj, const H5VL_loc_params_t *loc_params1,
- void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t connector_id,
- hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req);
-H5_DLL herr_t H5VLlink_get(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, H5VL_link_get_t get_type, hid_t dxpl_id, void **req, va_list arguments);
-H5_DLL herr_t H5VLlink_specific(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments);
-H5_DLL herr_t H5VLlink_optional(void *obj, hid_t connector_id, hid_t dxpl_id, void **req, va_list arguments);
-
-/* Public wrappers for object callbacks */
-H5_DLL void *H5VLobject_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, H5I_type_t *opened_type, hid_t dxpl_id, void **req);
-H5_DLL herr_t H5VLobject_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, const char *src_name,
- void *dst_obj, const H5VL_loc_params_t *loc_params2, const char *dst_name,
- hid_t connector_id, hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req);
-H5_DLL herr_t H5VLobject_get(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, H5VL_object_get_t get_type, hid_t dxpl_id, void **req, va_list arguments);
-H5_DLL herr_t H5VLobject_specific(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments);
-H5_DLL herr_t H5VLobject_optional(void *obj, hid_t connector_id, hid_t dxpl_id, void **req, va_list arguments);
-
-/* Public wrappers for named datatype callbacks */
-H5_DLL void *H5VLdatatype_commit(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, void **req);
-H5_DLL void *H5VLdatatype_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, hid_t tapl_id, hid_t dxpl_id, void **req);
-H5_DLL herr_t H5VLdatatype_get(void *dt, hid_t connector_id, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, va_list arguments);
-H5_DLL herr_t H5VLdatatype_specific(void *obj, hid_t connector_id, H5VL_datatype_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments);
-H5_DLL herr_t H5VLdatatype_optional(void *obj, hid_t connector_id, hid_t dxpl_id, void **req, va_list arguments);
-H5_DLL herr_t H5VLdatatype_close(void *dt, hid_t connector_id, hid_t dxpl_id, void **req);
-
-/* Public wrappers for asynchronous request callbacks */
-H5_DLL herr_t H5VLrequest_wait(void *req, hid_t connector_id, uint64_t timeout, H5ES_status_t *status);
-H5_DLL herr_t H5VLrequest_notify(void *req, hid_t connector_id, H5VL_request_notify_t cb, void *ctx);
-H5_DLL herr_t H5VLrequest_cancel(void *req, hid_t connector_id);
-H5_DLL herr_t H5VLrequest_specific(void *req, hid_t connector_id, H5VL_request_specific_t specific_type, va_list arguments);
-H5_DLL herr_t H5VLrequest_optional(void *req, hid_t connector_id, va_list arguments);
-H5_DLL herr_t H5VLrequest_free(void *req, hid_t connector_id);
-
#ifdef __cplusplus
}
#endif
diff --git a/src/H5VM.c b/src/H5VM.c
index 452d378..f78da96 100644
--- a/src/H5VM.c
+++ b/src/H5VM.c
@@ -19,6 +19,7 @@
#include "H5private.h"
#include "H5Eprivate.h"
+#include "H5MMprivate.h" /* Memory management */
#include "H5Oprivate.h"
#include "H5VMprivate.h"
@@ -732,7 +733,7 @@ H5VM_stride_copy(unsigned n, hsize_t elmt_size, const hsize_t *size,
/* Copy an element */
H5_CHECK_OVERFLOW(elmt_size,hsize_t,size_t);
- HDmemcpy(dst, src, (size_t)elmt_size); /*lint !e671 The elmt_size will be OK */
+ H5MM_memcpy(dst, src, (size_t)elmt_size); /*lint !e671 The elmt_size will be OK */
/* Decrement indices and advance pointers */
for (j=(int)(n-1), carry=TRUE; j>=0 && carry; --j) {
@@ -749,7 +750,7 @@ H5VM_stride_copy(unsigned n, hsize_t elmt_size, const hsize_t *size,
}
} else {
H5_CHECK_OVERFLOW(elmt_size,hsize_t,size_t);
- HDmemcpy (dst, src, (size_t)elmt_size); /*lint !e671 The elmt_size will be OK */
+ H5MM_memcpy (dst, src, (size_t)elmt_size); /*lint !e671 The elmt_size will be OK */
}
FUNC_LEAVE_NOAPI(SUCCEED)
@@ -801,7 +802,7 @@ H5VM_stride_copy_s(unsigned n, hsize_t elmt_size, const hsize_t *size,
/* Copy an element */
H5_CHECK_OVERFLOW(elmt_size,hsize_t,size_t);
- HDmemcpy(dst, src, (size_t)elmt_size); /*lint !e671 The elmt_size will be OK */
+ H5MM_memcpy(dst, src, (size_t)elmt_size); /*lint !e671 The elmt_size will be OK */
/* Decrement indices and advance pointers */
for (j=(int)(n-1), carry=TRUE; j>=0 && carry; --j) {
@@ -818,7 +819,7 @@ H5VM_stride_copy_s(unsigned n, hsize_t elmt_size, const hsize_t *size,
}
} else {
H5_CHECK_OVERFLOW(elmt_size,hsize_t,size_t);
- HDmemcpy (dst, src, (size_t)elmt_size); /*lint !e671 The elmt_size will be OK */
+ H5MM_memcpy (dst, src, (size_t)elmt_size); /*lint !e671 The elmt_size will be OK */
}
FUNC_LEAVE_NOAPI(SUCCEED)
@@ -877,7 +878,7 @@ H5VM_stride_copy2(hsize_t nelmts, hsize_t elmt_size,
/* Copy an element */
H5_CHECK_OVERFLOW(elmt_size,hsize_t,size_t);
- HDmemcpy(dst, src, (size_t)elmt_size); /*lint !e671 The elmt_size will be OK */
+ H5MM_memcpy(dst, src, (size_t)elmt_size); /*lint !e671 The elmt_size will be OK */
/* Decrement indices and advance pointers */
for (j=(int)(dst_n-1), carry=TRUE; j>=0 && carry; --j) {
@@ -936,7 +937,7 @@ H5VM_array_fill(void *_dst, const void *src, size_t size, size_t count)
HDassert(size < SIZET_MAX && size > 0);
HDassert(count < SIZET_MAX && count > 0);
- HDmemcpy(dst, src, size); /* copy first item */
+ H5MM_memcpy(dst, src, size); /* copy first item */
/* Initialize counters, etc. while compensating for first element copied */
copy_size = size;
@@ -947,7 +948,7 @@ H5VM_array_fill(void *_dst, const void *src, size_t size, size_t count)
/* copy until we've copied at least half of the items */
while (items_left >= copy_items)
{
- HDmemcpy(dst, _dst, copy_size); /* copy the current chunk */
+ H5MM_memcpy(dst, _dst, copy_size); /* copy the current chunk */
dst += copy_size; /* move the offset for the next chunk */
items_left -= copy_items; /* decrement the number of items left */
@@ -955,7 +956,7 @@ H5VM_array_fill(void *_dst, const void *src, size_t size, size_t count)
copy_items *= 2; /* increase the count of items we are copying */
} /* end while */
if (items_left > 0) /* if there are any items left to copy */
- HDmemcpy(dst, _dst, items_left * size);
+ H5MM_memcpy(dst, _dst, items_left * size);
FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5VM_array_fill() */
@@ -1623,7 +1624,7 @@ src_smaller:
acc_len = 0;
do {
/* Copy data */
- HDmemcpy(dst, src, tmp_src_len);
+ H5MM_memcpy(dst, src, tmp_src_len);
/* Accumulate number of bytes copied */
acc_len += tmp_src_len;
@@ -1666,7 +1667,7 @@ dst_smaller:
acc_len = 0;
do {
/* Copy data */
- HDmemcpy(dst, src, tmp_dst_len);
+ H5MM_memcpy(dst, src, tmp_dst_len);
/* Accumulate number of bytes copied */
acc_len += tmp_dst_len;
@@ -1709,7 +1710,7 @@ equal:
acc_len = 0;
do {
/* Copy data */
- HDmemcpy(dst, src, tmp_dst_len);
+ H5MM_memcpy(dst, src, tmp_dst_len);
/* Accumulate number of bytes copied */
acc_len += tmp_dst_len;
diff --git a/src/H5VMprivate.h b/src/H5VMprivate.h
index decac7e..26f59e2 100644
--- a/src/H5VMprivate.h
+++ b/src/H5VMprivate.h
@@ -21,6 +21,7 @@
/* Private headers needed by this file */
#include "H5private.h" /* Generic Functions */
#include "H5Eprivate.h" /* Error handling */
+#include "H5MMprivate.h" /* Memory management */
/* Vector-Vector sequence operation callback */
typedef herr_t (*H5VM_opvv_func_t)(hsize_t dst_off, hsize_t src_off,
@@ -41,7 +42,7 @@ typedef herr_t (*H5VM_opvv_func_t)(hsize_t dst_off, hsize_t src_off,
/* Other functions */
#define H5VM_vector_cpy(N,DST,SRC) { \
HDassert(sizeof(*(DST))==sizeof(*(SRC))); \
- if (SRC) HDmemcpy (DST, SRC, (N)*sizeof(*(DST))); \
+ if (SRC) H5MM_memcpy (DST, SRC, (N)*sizeof(*(DST))); \
else HDmemset (DST, 0, (N)*sizeof(*(DST))); \
}
diff --git a/src/H5Z.c b/src/H5Z.c
index f41588f..b703958 100644
--- a/src/H5Z.c
+++ b/src/H5Z.c
@@ -322,7 +322,7 @@ H5Z_register (const H5Z_class2_t *cls)
/* Initialize */
i = H5Z_table_used_g++;
- HDmemcpy(H5Z_table_g+i, cls, sizeof(H5Z_class2_t));
+ H5MM_memcpy(H5Z_table_g+i, cls, sizeof(H5Z_class2_t));
#ifdef H5Z_DEBUG
HDmemset(H5Z_stat_table_g+i, 0, sizeof(H5Z_stats_t));
#endif /* H5Z_DEBUG */
@@ -330,7 +330,7 @@ H5Z_register (const H5Z_class2_t *cls)
/* Filter already registered */
else {
/* Replace old contents */
- HDmemcpy(H5Z_table_g+i, cls, sizeof(H5Z_class2_t));
+ H5MM_memcpy(H5Z_table_g+i, cls, sizeof(H5Z_class2_t));
} /* end else */
done:
@@ -611,7 +611,7 @@ H5Z__flush_file_cb(void *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, void *key)
/* Sanity check for collectively calling H5Zunregister, if requested */
/* (Sanity check assumes that a barrier on one file's comm
* is sufficient (i.e. that there aren't different comms for
- * different files). -QAK, 2018/02/14
+ * different files). -QAK, 2018/02/14)
*/
if(H5_coll_api_sanity_check_g && !object->sanity_checked) {
MPI_Comm mpi_comm; /* File's communicator */
diff --git a/src/H5Zfletcher32.c b/src/H5Zfletcher32.c
index 4cd77ef..4d75d14 100644
--- a/src/H5Zfletcher32.c
+++ b/src/H5Zfletcher32.c
@@ -108,7 +108,7 @@ H5Z_filter_fletcher32 (unsigned flags, size_t H5_ATTR_UNUSED cd_nelmts, const un
* system. We'll check both the correct checksum and the wrong
* checksum to be consistent with Release 1.6.2 and before.
*/
- HDmemcpy(c, &fletcher, (size_t)4);
+ H5MM_memcpy(c, &fletcher, (size_t)4);
tmp = c[1];
c[1] = c[0];
@@ -118,7 +118,7 @@ H5Z_filter_fletcher32 (unsigned flags, size_t H5_ATTR_UNUSED cd_nelmts, const un
c[3] = c[2];
c[2] = tmp;
- HDmemcpy(&reversed_fletcher, c, (size_t)4);
+ H5MM_memcpy(&reversed_fletcher, c, (size_t)4);
/* Verify computed checksum matches stored checksum */
if(stored_fletcher != fletcher && stored_fletcher != reversed_fletcher)
@@ -140,7 +140,7 @@ H5Z_filter_fletcher32 (unsigned flags, size_t H5_ATTR_UNUSED cd_nelmts, const un
dst = (unsigned char *) outbuf;
/* Copy raw data */
- HDmemcpy((void*)dst, (void*)(*buf), nbytes);
+ H5MM_memcpy((void*)dst, (void*)(*buf), nbytes);
/* Append checksum to raw data for storage */
dst += nbytes;
diff --git a/src/H5Zscaleoffset.c b/src/H5Zscaleoffset.c
index cdf31a4..d3e8fc0 100644
--- a/src/H5Zscaleoffset.c
+++ b/src/H5Zscaleoffset.c
@@ -141,7 +141,7 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{
} /* end if */ \
\
/* Copy the value */ \
- HDmemcpy(&_cd_value, _fv_p, _copy_size); \
+ H5MM_memcpy(&_cd_value, _fv_p, _copy_size); \
(cd_values)[_i] = (unsigned)_cd_value; \
\
/* Next field */ \
@@ -158,7 +158,7 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{
_fv_p = ((char *)&(fill_val)) + sizeof(type) - MIN(4, _size_rem); \
while(_size_rem >= 4) { \
/* Copy the value */ \
- HDmemcpy(&_cd_value, _fv_p, _copy_size); \
+ H5MM_memcpy(&_cd_value, _fv_p, _copy_size); \
(cd_values)[_i] = (unsigned)_cd_value; \
\
/* Next field */ \
@@ -176,7 +176,7 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{
* _cd_value as it will not be fully overwritten and copy to the end \
* of _cd value as it is BE. */ \
_cd_value = (uint32_t)0; \
- HDmemcpy((char *)&_cd_value + 4 - _size_rem, _fv_p, _size_rem); \
+ H5MM_memcpy((char *)&_cd_value + 4 - _size_rem, _fv_p, _size_rem); \
(cd_values)[_i] = (unsigned)_cd_value; \
} /* end if */ \
} /* end else */ \
@@ -269,7 +269,7 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{
\
/* Copy the value */ \
_cd_value = (uint32_t)(cd_values)[_i]; \
- HDmemcpy(_fv_p, &_cd_value, _copy_size); \
+ H5MM_memcpy(_fv_p, &_cd_value, _copy_size); \
\
/* Next field */ \
_i++; \
@@ -286,7 +286,7 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{
while(_size_rem >= 4) { \
/* Copy the value */ \
_cd_value = (uint32_t)(cd_values)[_i]; \
- HDmemcpy(_fv_p, &_cd_value, _copy_size); \
+ H5MM_memcpy(_fv_p, &_cd_value, _copy_size); \
\
/* Next field */ \
_i++; \
@@ -303,7 +303,7 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{
* _cd_value as it will not be fully overwritten and copy to the end \
* of _cd value as it is BE. */ \
_cd_value = (uint32_t)(cd_values)[_i]; \
- HDmemcpy(_fv_p, (char *)&_cd_value + 4 - _size_rem, _size_rem); \
+ H5MM_memcpy(_fv_p, (char *)&_cd_value + 4 - _size_rem, _size_rem); \
} /* end if */ \
} /* end else */ \
}
@@ -529,10 +529,10 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{
* account for offset in BE if sizes differ \
*/ \
if(H5T_native_order_g == H5T_ORDER_LE) \
- HDmemcpy(minval, &min, sizeof(type)); \
+ H5MM_memcpy(minval, &min, sizeof(type)); \
else { \
HDassert(H5T_native_order_g == H5T_ORDER_BE); \
- HDmemcpy(((char *)minval) + (sizeof(long long) - sizeof(type)), \
+ H5MM_memcpy(((char *)minval) + (sizeof(long long) - sizeof(type)), \
&min, sizeof(type)); \
} /* end else */ \
else \
@@ -604,10 +604,10 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{
* account for offset in BE if sizes differ \
*/ \
if(H5T_native_order_g == H5T_ORDER_LE) \
- HDmemcpy(&min, &minval, sizeof(type)); \
+ H5MM_memcpy(&min, &minval, sizeof(type)); \
else { \
HDassert(H5T_native_order_g == H5T_ORDER_BE); \
- HDmemcpy(&min, ((char *)&minval) + (sizeof(long long) \
+ H5MM_memcpy(&min, ((char *)&minval) + (sizeof(long long) \
- sizeof(type)), sizeof(type)); \
} /* end else */ \
else \
@@ -1173,7 +1173,9 @@ H5Z_filter_scaleoffset(unsigned flags, size_t cd_nelmts, const unsigned cd_value
/* special case: minbits equal to full precision */
if(minbits == p.size * 8) {
- HDmemcpy(outbuf, (unsigned char*)(*buf)+buf_offset, size_out);
+ H5MM_memcpy(outbuf, (unsigned char*)(*buf)+buf_offset, size_out);
+ /* free the original buffer */
+ H5MM_xfree(*buf);
/* convert to dataset datatype endianness order if needed */
if(need_convert)
@@ -1271,7 +1273,10 @@ H5Z_filter_scaleoffset(unsigned flags, size_t cd_nelmts, const unsigned cd_value
/* special case: minbits equal to full precision */
if(minbits == p.size * 8) {
- HDmemcpy(outbuf + buf_offset, *buf, nbytes);
+ H5MM_memcpy(outbuf + buf_offset, *buf, nbytes);
+ /* free the original buffer */
+ H5MM_xfree(*buf);
+
*buf = outbuf;
outbuf = NULL;
*buf_size = size_out;
diff --git a/src/H5Zshuffle.c b/src/H5Zshuffle.c
index 1fef1c1..b1d0722 100644
--- a/src/H5Zshuffle.c
+++ b/src/H5Zshuffle.c
@@ -185,18 +185,25 @@ H5Z_filter_shuffle(unsigned flags, size_t cd_nelmts, const unsigned cd_values[],
do
{
DUFF_GUTS
+ H5_ATTR_FALLTHROUGH
case 7:
DUFF_GUTS
+ H5_ATTR_FALLTHROUGH
case 6:
DUFF_GUTS
+ H5_ATTR_FALLTHROUGH
case 5:
DUFF_GUTS
+ H5_ATTR_FALLTHROUGH
case 4:
DUFF_GUTS
+ H5_ATTR_FALLTHROUGH
case 3:
DUFF_GUTS
+ H5_ATTR_FALLTHROUGH
case 2:
DUFF_GUTS
+ H5_ATTR_FALLTHROUGH
case 1:
DUFF_GUTS
} while (--duffs_index > 0);
@@ -210,7 +217,7 @@ H5Z_filter_shuffle(unsigned flags, size_t cd_nelmts, const unsigned cd_values[],
if(leftover>0) {
/* Adjust back to end of shuffled bytes */
_dest -= (bytesoftype - 1); /*lint !e794 _dest is initialized */
- HDmemcpy((void*)_dest, (void*)_src, leftover);
+ H5MM_memcpy((void*)_dest, (void*)_src, leftover);
}
} /* end if */
else {
@@ -243,18 +250,25 @@ H5Z_filter_shuffle(unsigned flags, size_t cd_nelmts, const unsigned cd_values[],
do
{
DUFF_GUTS
+ H5_ATTR_FALLTHROUGH
case 7:
DUFF_GUTS
+ H5_ATTR_FALLTHROUGH
case 6:
DUFF_GUTS
+ H5_ATTR_FALLTHROUGH
case 5:
DUFF_GUTS
+ H5_ATTR_FALLTHROUGH
case 4:
DUFF_GUTS
+ H5_ATTR_FALLTHROUGH
case 3:
DUFF_GUTS
+ H5_ATTR_FALLTHROUGH
case 2:
DUFF_GUTS
+ H5_ATTR_FALLTHROUGH
case 1:
DUFF_GUTS
} while (--duffs_index > 0);
@@ -268,7 +282,7 @@ H5Z_filter_shuffle(unsigned flags, size_t cd_nelmts, const unsigned cd_values[],
if(leftover>0) {
/* Adjust back to end of shuffled bytes */
_src -= (bytesoftype - 1); /*lint !e794 _src is initialized */
- HDmemcpy((void*)_dest, (void*)_src, leftover);
+ H5MM_memcpy((void*)_dest, (void*)_src, leftover);
}
} /* end else */
diff --git a/src/H5Ztrans.c b/src/H5Ztrans.c
index 67646a0..6d07513 100644
--- a/src/H5Ztrans.c
+++ b/src/H5Ztrans.c
@@ -850,7 +850,7 @@ H5Z_parse_factor(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers)
if (!factor)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Unable to allocate new node")
- sscanf(current->tok_begin, "%ld", &factor->value.int_val);
+ HDsscanf(current->tok_begin, "%ld", &factor->value.int_val);
break;
case H5Z_XFORM_FLOAT:
@@ -858,7 +858,7 @@ H5Z_parse_factor(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers)
if (!factor)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Unable to allocate new node")
- sscanf(current->tok_begin, "%lf", &factor->value.float_val);
+ HDsscanf(current->tok_begin, "%lf", &factor->value.float_val);
break;
case H5Z_XFORM_SYMBOL:
@@ -1078,7 +1078,7 @@ H5Z_xform_eval(H5Z_data_xform_t *data_xform_prop, void* array, size_t array_size
if(NULL == (data_xform_prop->dat_val_pointers->ptr_dat_val[i] = (void*)H5MM_malloc(array_size * H5T_get_size((H5T_t *)H5I_object(array_type)))))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "Ran out of memory trying to allocate space for data in data transform")
- HDmemcpy(data_xform_prop->dat_val_pointers->ptr_dat_val[i], array, array_size * H5T_get_size((H5T_t *)H5I_object(array_type)));
+ H5MM_memcpy(data_xform_prop->dat_val_pointers->ptr_dat_val[i], array, array_size * H5T_get_size((H5T_t *)H5I_object(array_type)));
} /* end for */
} /* end else */
@@ -1086,7 +1086,7 @@ H5Z_xform_eval(H5Z_data_xform_t *data_xform_prop, void* array, size_t array_size
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "error while performing data transform")
if(data_xform_prop->dat_val_pointers->num_ptrs > 1)
- HDmemcpy(array, res.value.dat_val, array_size * H5T_get_size((H5T_t *)H5I_object(array_type)));
+ H5MM_memcpy(array, res.value.dat_val, array_size * H5T_get_size((H5T_t *)H5I_object(array_type)));
/* Free the temporary arrays we used */
if(data_xform_prop->dat_val_pointers->num_ptrs > 1)
diff --git a/src/H5checksum.c b/src/H5checksum.c
index 64d527e..4e98976 100644
--- a/src/H5checksum.c
+++ b/src/H5checksum.c
@@ -407,16 +407,27 @@ H5_checksum_lookup3(const void *key, size_t length, uint32_t initval)
switch(length) /* all the case statements fall through */
{
case 12: c+=((uint32_t)k[11])<<24;
+ H5_ATTR_FALLTHROUGH
case 11: c+=((uint32_t)k[10])<<16;
+ H5_ATTR_FALLTHROUGH
case 10: c+=((uint32_t)k[9])<<8;
+ H5_ATTR_FALLTHROUGH
case 9 : c+=k[8];
+ H5_ATTR_FALLTHROUGH
case 8 : b+=((uint32_t)k[7])<<24;
+ H5_ATTR_FALLTHROUGH
case 7 : b+=((uint32_t)k[6])<<16;
+ H5_ATTR_FALLTHROUGH
case 6 : b+=((uint32_t)k[5])<<8;
+ H5_ATTR_FALLTHROUGH
case 5 : b+=k[4];
+ H5_ATTR_FALLTHROUGH
case 4 : a+=((uint32_t)k[3])<<24;
+ H5_ATTR_FALLTHROUGH
case 3 : a+=((uint32_t)k[2])<<16;
+ H5_ATTR_FALLTHROUGH
case 2 : a+=((uint32_t)k[1])<<8;
+ H5_ATTR_FALLTHROUGH
case 1 : a+=k[0];
break;
case 0 : goto done;
diff --git a/src/H5dbg.c b/src/H5dbg.c
index dd50034..4939bca 100644
--- a/src/H5dbg.c
+++ b/src/H5dbg.c
@@ -113,7 +113,7 @@ H5_buffer_dump(FILE *stream, int indent, const uint8_t *buf,
} /* end else */
} /* end if */
else
- fprintf(stream, " ");
+ HDfprintf(stream, " ");
if(7 == v)
HDfputc(' ', stream);
} /* end for */
diff --git a/src/H5err.txt b/src/H5err.txt
index 93a3abd..d4edfba 100644
--- a/src/H5err.txt
+++ b/src/H5err.txt
@@ -134,6 +134,7 @@ MINOR, FILEACC, H5E_NOTHDF5, Not an HDF5 file
MINOR, FILEACC, H5E_BADFILE, Bad file ID accessed
MINOR, FILEACC, H5E_TRUNCATED, File has been truncated
MINOR, FILEACC, H5E_MOUNT, File mount error
+MINOR, FILEACC, H5E_CANTDELETEFILE, Unable to delete file
# Generic low-level file I/O errors
MINOR, FILE, H5E_SEEKERROR, Seek failed
@@ -226,6 +227,7 @@ MINOR, DSPACE, H5E_CANTSELECT, Can't select hyperslab
MINOR, DSPACE, H5E_CANTNEXT, Can't move to next iterator location
MINOR, DSPACE, H5E_BADSELECT, Invalid selection
MINOR, DSPACE, H5E_CANTCOMPARE, Can't compare objects
+MINOR, DSPACE, H5E_INCONSISTENTSTATE, Internal states are inconsistent
MINOR, DSPACE, H5E_CANTAPPEND, Can't append object
# Property list errors
diff --git a/src/H5private.h b/src/H5private.h
index 8b6253d..86cd615 100644
--- a/src/H5private.h
+++ b/src/H5private.h
@@ -309,6 +309,7 @@
# define H5_ATTR_NORETURN /*void*/
# define H5_ATTR_CONST /*void*/
# define H5_ATTR_PURE /*void*/
+# define H5_ATTR_FALLTHROUGH /*void*/
#else /* __cplusplus */
#if defined(H5_HAVE_ATTRIBUTE) && !defined(__SUNPRO_C)
# define H5_ATTR_FORMAT(X,Y,Z) __attribute__((format(X, Y, Z)))
@@ -316,12 +317,14 @@
# define H5_ATTR_NORETURN __attribute__((noreturn))
# define H5_ATTR_CONST __attribute__((const))
# define H5_ATTR_PURE __attribute__((pure))
+# define H5_ATTR_FALLTHROUGH __attribute__((fallthrough));
#else
# define H5_ATTR_FORMAT(X,Y,Z) /*void*/
# define H5_ATTR_UNUSED /*void*/
# define H5_ATTR_NORETURN /*void*/
# define H5_ATTR_CONST /*void*/
# define H5_ATTR_PURE /*void*/
+# define H5_ATTR_FALLTHROUGH /*void*/
#endif
#endif /* __cplusplus */
@@ -1104,12 +1107,8 @@ typedef off_t h5_stat_size_t;
#ifndef HDmemcmp
#define HDmemcmp(X,Y,Z) memcmp(X,Y,Z)
#endif /* HDmemcmp */
-/*
- * The (char*) casts are required for the DEC when optimizations are turned
- * on and the source and/or destination are not aligned.
- */
#ifndef HDmemcpy
- #define HDmemcpy(X,Y,Z) memcpy((char*)(X),(const char*)(Y),Z)
+ #define HDmemcpy(X,Y,Z) memcpy(X,Y,Z)
#endif /* HDmemcpy */
#ifndef HDmemmove
#define HDmemmove(X,Y,Z) memmove((char*)(X),(const char*)(Y),Z)
@@ -1340,8 +1339,9 @@ typedef off_t h5_stat_size_t;
#define HDsrandom(S) srand(S)
#endif /* HDsrandom */
#endif /* H5_HAVE_RAND_R */
-/* sscanf() variable arguments */
-
+#ifndef HDsscanf
+ #define HDsscanf(S,FMT,...) sscanf(S,FMT,__VA_ARGS__)
+#endif /* HDsscanf */
#ifndef HDstrcat
#define HDstrcat(X,Y) strcat(X,Y)
#endif /* HDstrcat */
diff --git a/src/H5public.h b/src/H5public.h
index 353ff16..a7e21f6 100644
--- a/src/H5public.h
+++ b/src/H5public.h
@@ -93,10 +93,10 @@ extern "C" {
/* Version numbers */
#define H5_VERS_MAJOR 1 /* For major interface/format changes */
#define H5_VERS_MINOR 11 /* For minor interface/format changes */
-#define H5_VERS_RELEASE 4 /* For tweaks, bug-fixes, or development */
+#define H5_VERS_RELEASE 6 /* For tweaks, bug-fixes, or development */
#define H5_VERS_SUBRELEASE "" /* For pre-releases like snap0 */
/* Empty string for real releases. */
-#define H5_VERS_INFO "HDF5 library version: 1.11.4" /* Full version string */
+#define H5_VERS_INFO "HDF5 library version: 1.11.6" /* Full version string */
#define H5check() H5check_version(H5_VERS_MAJOR,H5_VERS_MINOR, \
H5_VERS_RELEASE)
diff --git a/src/H5system.c b/src/H5system.c
index f47d057..35123db 100644
--- a/src/H5system.c
+++ b/src/H5system.c
@@ -985,6 +985,132 @@ Wroundf(float arg)
return (float)(arg < 0.0F ? HDceil(arg - 0.5F) : HDfloor(arg + 0.5F));
}
+/*-------------------------------------------------------------------------
+* Function: H5_get_utf16_str
+*
+* Purpose: Gets a UTF-16 string from an UTF-8 (or ASCII) string.
+*
+* Return: Success: A pointer to a UTF-16 string
+* This must be freed by the caller using H5MM_xfree()
+* Failure: NULL
+*
+* Programmer: Dana Robinson
+* Spring 2019
+*
+*-------------------------------------------------------------------------
+*/
+const wchar_t *
+H5_get_utf16_str(const char *s)
+{
+ int nwchars = -1; /* Length of the UTF-16 buffer */
+ wchar_t *ret_s = NULL; /* UTF-16 version of the string */
+
+ /* Get the number of UTF-16 characters needed */
+ if(0 == (nwchars = MultiByteToWideChar(CP_UTF8, 0, s, -1, NULL, 0)))
+ goto error;
+
+ /* Allocate a buffer for the UTF-16 string */
+ if(NULL == (ret_s = (wchar_t *)H5MM_calloc(sizeof(wchar_t) * (size_t)nwchars)))
+ goto error;
+
+ /* Convert the input UTF-8 string to UTF-16 */
+ if(0 == MultiByteToWideChar(CP_UTF8, 0, s, -1, ret_s, nwchars))
+ goto error;
+
+ return ret_s;
+
+error:
+ if(ret_s)
+ H5MM_xfree((void *)ret_s);
+ return NULL;
+} /* end H5_get_utf16_str() */
+
+/*-------------------------------------------------------------------------
+ * Function: Wopen_utf8
+ *
+ * Purpose: UTF-8 equivalent of open(2) for use on Windows.
+ * Converts a UTF-8 input path to UTF-16 and then opens the
+ * file via _wopen() under the hood
+ *
+ * Return: Success: A POSIX file descriptor
+ * Failure: -1
+ *
+ * Programmer: Dana Robinson
+ * Spring 2019
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+Wopen_utf8(const char *path, int oflag, ...)
+{
+ int fd = -1; /* POSIX file descriptor to be returned */
+ wchar_t *wpath = NULL; /* UTF-16 version of the path */
+ int pmode = 0; /* mode (optionally set via variable args) */
+
+ /* Convert the input UTF-8 path to UTF-16 */
+ if(NULL == (wpath = H5_get_utf16_str(path)))
+ goto done;
+
+ /* _O_BINARY must be set in Windows to avoid CR-LF <-> LF EOL
+ * transformations when performing I/O. Note that this will
+ * produce Unix-style text files, though.
+ */
+ oflag |= _O_BINARY;
+
+ /* Get the mode, if O_CREAT was specified */
+ if(oflag & O_CREAT) {
+ va_list vl;
+
+ HDva_start(vl, oflag);
+ pmode = HDva_arg(vl, int);
+ HDva_end(vl);
+ }
+
+ /* Open the file */
+ fd = _wopen(wpath, oflag, pmode);
+
+done:
+ if(wpath)
+ H5MM_xfree((void *)wpath);
+
+ return fd;
+} /* end Wopen_utf8() */
+
+/*-------------------------------------------------------------------------
+ * Function: Wremove_utf8
+ *
+ * Purpose: UTF-8 equivalent of remove(3) for use on Windows.
+ * Converts a UTF-8 input path to UTF-16 and then opens the
+ * file via _wremove() under the hood
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Dana Robinson
+ * Spring 2019
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+Wremove_utf8(const char *path)
+{
+ wchar_t *wpath = NULL; /* UTF-16 version of the path */
+ int ret;
+
+ /* Convert the input UTF-8 path to UTF-16 */
+ if(NULL == (wpath = H5_get_utf16_str(path)))
+ goto done;
+
+ /* Open the file */
+ ret = _wremove(wpath);
+
+done:
+ if(wpath)
+ H5MM_xfree((void *)wpath);
+
+ return ret;
+} /* end Wremove_utf8() */
+
#endif /* H5_HAVE_WIN32_API */
@@ -1130,13 +1256,13 @@ H5_combine_path(const char* path1, const char* path2, char **full_name /*out*/)
FUNC_ENTER_NOAPI_NOINIT
- HDassert(path1);
HDassert(path2);
- path1_len = HDstrlen(path1);
+ if(path1)
+ path1_len = HDstrlen(path1);
path2_len = HDstrlen(path2);
- if(*path1 == '\0' || H5_CHECK_ABSOLUTE(path2)) {
+ if(path1 == NULL || *path1 == '\0' || H5_CHECK_ABSOLUTE(path2)) {
/* If path1 is empty or path2 is absolute, simply use path2 */
if(NULL == (*full_name = (char *)H5MM_strdup(path2)))
diff --git a/src/H5timer.c b/src/H5timer.c
index 0ba8bd1..4b1ec06 100644
--- a/src/H5timer.c
+++ b/src/H5timer.c
@@ -213,26 +213,26 @@ H5_bandwidth(char *buf/*out*/, double nbytes, double nseconds)
if(H5_DBL_ABS_EQUAL(bw, (double)0.0F))
HDstrcpy(buf, "0.000 B/s");
else if(bw < (double)1.0F)
- sprintf(buf, "%10.4e", bw);
+ HDsprintf(buf, "%10.4e", bw);
else if(bw < (double)H5_KB) {
- sprintf(buf, "%05.4f", bw);
+ HDsprintf(buf, "%05.4f", bw);
HDstrcpy(buf+5, " B/s");
} else if(bw < (double)H5_MB) {
- sprintf(buf, "%05.4f", bw / (double)H5_KB);
+ HDsprintf(buf, "%05.4f", bw / (double)H5_KB);
HDstrcpy(buf+5, " kB/s");
} else if(bw < (double)H5_GB) {
- sprintf(buf, "%05.4f", bw / (double)H5_MB);
+ HDsprintf(buf, "%05.4f", bw / (double)H5_MB);
HDstrcpy(buf+5, " MB/s");
} else if(bw < (double)H5_TB) {
- sprintf(buf, "%05.4f", bw / (double)H5_GB);
+ HDsprintf(buf, "%05.4f", bw / (double)H5_GB);
HDstrcpy(buf+5, " GB/s");
} else if(bw < (double)H5_PB) {
- sprintf(buf, "%05.4f", bw / (double)H5_TB);
+ HDsprintf(buf, "%05.4f", bw / (double)H5_TB);
HDstrcpy(buf+5, " TB/s");
} else {
- sprintf(buf, "%10.4e", bw);
+ HDsprintf(buf, "%10.4e", bw);
if(HDstrlen(buf) > 10)
- sprintf(buf, "%10.3e", bw);
+ HDsprintf(buf, "%10.3e", bw);
}
}
} /* end H5_bandwidth() */
diff --git a/src/H5trace.c b/src/H5trace.c
index 9a13193..c5d14f5 100644
--- a/src/H5trace.c
+++ b/src/H5trace.c
@@ -173,7 +173,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
if(current_depth < last_call_depth) {
/* We are at the beginning of a line */
if(H5_debug_g.ttimes) {
- char tmp[128];
+ char tmp[320];
HDsprintf(tmp, "%.6f", event_time.etime-first_time.etime);
HDfprintf(out, " %*s ", (int)HDstrlen(tmp), "");
@@ -1054,7 +1054,11 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
break;
case H5F_LIBVER_V110:
- HDcompile_assert(H5F_LIBVER_LATEST == H5F_LIBVER_V110);
+ HDfprintf(out, "H5F_LIBVER_V110");
+ break;
+
+ case H5F_LIBVER_V112:
+ HDcompile_assert(H5F_LIBVER_LATEST == H5F_LIBVER_V112);
HDfprintf(out, "H5F_LIBVER_LATEST");
break;
@@ -1383,6 +1387,10 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
HDfprintf(out, "%ld (err stack)", (long)obj);
break;
+ case H5I_SPACE_SEL_ITER:
+ HDfprintf(out, "%ld (dataspace selection iterator)", (long)obj);
+ break;
+
case H5I_NTYPES:
HDfprintf (out, "%ld (ntypes - error)", (long)obj);
break;
@@ -1564,6 +1572,10 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
HDfprintf(out, "H5I_ERROR_STACK");
break;
+ case H5I_SPACE_SEL_ITER:
+ HDfprintf(out, "H5I_SPACE_SEL_ITER");
+ break;
+
case H5I_NTYPES:
HDfprintf(out, "H5I_NTYPES");
break;
@@ -2710,6 +2722,9 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
case H5VL_FILE_GET_INTENT:
HDfprintf(out, "H5VL_FILE_GET_INTENT");
break;
+ case H5VL_FILE_GET_FILENO:
+ HDfprintf(out, "H5VL_FILE_GET_FILENO");
+ break;
case H5VL_FILE_GET_NAME:
HDfprintf(out, "H5VL_FILE_GET_NAME");
break;
@@ -2751,6 +2766,9 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
case H5VL_FILE_IS_ACCESSIBLE:
HDfprintf(out, "H5VL_FILE_IS_ACCESSIBLE");
break;
+ case H5VL_FILE_DELETE:
+ HDfprintf(out, "H5VL_FILE_DELETE");
+ break;
default:
HDfprintf(out, "%ld", (long)specific);
break;
@@ -2901,8 +2919,8 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
case H5VL_REF_GET_NAME:
HDfprintf(out, "H5VL_REF_GET_NAME");
break;
- case H5VL_ID_GET_NAME:
- HDfprintf(out, "H5VL_ID_GET_NAME");
+ case H5VL_OBJECT_GET_NAME:
+ HDfprintf(out, "H5VL_OBJECT_GET_NAME");
break;
default:
HDfprintf(out, "%ld", (long)get);
diff --git a/src/H5vers.txt b/src/H5vers.txt
index 914c30e..22117c3 100644
--- a/src/H5vers.txt
+++ b/src/H5vers.txt
@@ -61,12 +61,14 @@ FUNCTION: H5Oget_info_by_name; ; v18, v112
FUNCTION: H5Oget_info_by_idx; ; v18, v112
FUNCTION: H5Ovisit; ; v18, v112
FUNCTION: H5Ovisit_by_name; ; v18, v112
+FUNCTION: H5Pencode; ; v110, v112
FUNCTION: H5Pget_filter; ; v10, v18
FUNCTION: H5Pget_filter_by_id; ; v16, v18
FUNCTION: H5Pinsert; ; v14, v18
FUNCTION: H5Pregister; ; v14, v18
FUNCTION: H5Rdereference; ; v10, v110
FUNCTION: H5Rget_obj_type; ; v16, v18
+FUNCTION: H5Sencode; ; v18, v112
FUNCTION: H5Tarray_create; ; v14, v18
FUNCTION: H5Tcommit; ; v10, v18
FUNCTION: H5Tget_array_dims; ; v14, v18
diff --git a/src/H5win32defs.h b/src/H5win32defs.h
index 140afc3..2ae2575 100644
--- a/src/H5win32defs.h
+++ b/src/H5win32defs.h
@@ -34,6 +34,7 @@ typedef __int64 h5_stat_size_t;
#define HDaccess(F,M) _access(F,M)
#define HDchdir(S) _chdir(S)
#define HDclose(F) _close(F)
+#define HDcreat(S,M) Wopen_utf8(S,O_CREAT|O_TRUNC|O_RDWR,M)
#define HDdup(F) _dup(F)
#define HDfdopen(N,S) _fdopen(N,S)
#define HDfileno(F) _fileno(F)
@@ -47,15 +48,13 @@ typedef __int64 h5_stat_size_t;
#define HDmkdir(S,M) _mkdir(S)
#define HDnanosleep(N, O) Wnanosleep(N, O)
#define HDoff_t __int64
-/* _O_BINARY must be set in Windows to avoid CR-LF <-> LF EOL
- * transformations when performing I/O. Note that this will
- * produce Unix-style text files, though.
- *
- * Also note that the variadic macro is using a VC++ extension
+
+/* Note that the variadic HDopen macro is using a VC++ extension
* where the comma is dropped if nothing is passed to the ellipsis.
*/
-#define HDopen(S,F,...) _open(S, F | _O_BINARY, __VA_ARGS__)
+#define HDopen(S,F,...) Wopen_utf8(S,F,__VA_ARGS__)
#define HDread(F,M,Z) _read(F,M,Z)
+#define HDremove(S) Wremove_utf8(S)
#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)
@@ -128,6 +127,9 @@ extern "C" {
H5_DLL int c99_vsnprintf(char* str, size_t size, const char* format, va_list ap);
H5_DLL int Wnanosleep(const struct timespec *req, struct timespec *rem);
H5_DLL herr_t H5_expand_windows_env_vars(char **env_var);
+ H5_DLL const wchar_t *H5_get_utf16_str(const char *s);
+ H5_DLL int Wopen_utf8(const char *path, int oflag, ...);
+ H5_DLL int Wremove_utf8(const char *path);
/* Round functions only needed for VS2012 and earlier.
* They are always built to ensure they don't go stale and
diff --git a/src/Makefile.am b/src/Makefile.am
index 5532655..0eaae1a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -102,7 +102,7 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \
H5R.c H5Rint.c H5Rdeprec.c \
H5UC.c \
H5RS.c \
- H5S.c H5Sall.c H5Sdbg.c H5Shyper.c H5Snone.c H5Spoint.c \
+ H5S.c H5Sall.c H5Sdbg.c H5Sdeprec.c H5Shyper.c H5Snone.c H5Spoint.c \
H5Sselect.c H5Stest.c \
H5SL.c \
H5SM.c H5SMbtree2.c H5SMcache.c H5SMmessage.c H5SMtest.c \
@@ -115,9 +115,9 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \
H5Torder.c \
H5Tpad.c H5Tprecis.c H5Tstrpad.c H5Tvisit.c H5Tvlen.c H5TS.c \
H5VL.c H5VLcallback.c H5VLint.c H5VLnative.c \
- H5VLnative_attr.c H5VLnative_dataset.c H5VLnative_datatype.c \
- H5VLnative_file.c H5VLnative_group.c H5VLnative_link.c H5VLnative_object.c \
- H5VLpassthru.c \
+ H5VLnative_attr.c H5VLnative_dataset.c H5VLnative_datatype.c \
+ H5VLnative_file.c H5VLnative_group.c H5VLnative_link.c H5VLnative_object.c \
+ H5VLpassthru.c \
H5VM.c H5WB.c H5Z.c \
H5Zdeflate.c H5Zfletcher32.c H5Znbit.c H5Zshuffle.c \
H5Zscaleoffset.c H5Zszip.c H5Ztrans.c
@@ -144,7 +144,9 @@ include_HEADERS = hdf5.h H5api_adpt.h H5overflow.h H5pubconf.h H5public.h H5vers
H5MMpublic.h H5Opublic.h H5Ppublic.h \
H5PLextern.h H5PLpublic.h \
H5Rpublic.h H5Spublic.h H5Tpublic.h \
- H5VLnative.h H5VLpassthru.h H5VLpublic.h H5Zpublic.h
+ H5VLconnector.h H5VLconnector_passthru.h \
+ H5VLnative.h H5VLpassthru.h H5VLpublic.h \
+ H5Zpublic.h
# install libhdf5.settings in lib directory
settingsdir=$(libdir)
@@ -209,3 +211,4 @@ trace: $(libhdf5_la_SOURCES)
done
include $(top_srcdir)/config/conclude.am
+
diff --git a/src/libhdf5.settings.in b/src/libhdf5.settings.in
index 9d0e29f..37957a2 100644
--- a/src/libhdf5.settings.in
+++ b/src/libhdf5.settings.in
@@ -71,6 +71,8 @@ Features:
Parallel Filtered Dataset Writes: @PARALLEL_FILTERED_WRITES@
Large Parallel I/O: @LARGE_PARALLEL_IO@
High-level library: @HDF5_HL@
+ Build HDF5 Tests: @HDF5_TESTS@
+ Build HDF5 TOOLS: @HDF5_TOOLS@
Threadsafety: @THREADSAFE@
Default API mapping: @DEFAULT_API_VERSION@
With deprecated public symbols: @DEPRECATED_SYMBOLS@