summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMohamad Chaarawi <chaarawi@hdfgroup.org>2015-12-14 15:22:29 (GMT)
committerMohamad Chaarawi <chaarawi@hdfgroup.org>2015-12-14 15:22:29 (GMT)
commit7a0cdfbbacc86aa73e91dedc4d89e3e59214d50a (patch)
tree6bd24199653eff3e99f312d748ba4909686bef61 /src
parent8e9b142d9cd347432d400b4f9b3b88a3f047c06d (diff)
parent2cb441c507dfbd4437ccf29e232a9b730e6e1003 (diff)
downloadhdf5-7a0cdfbbacc86aa73e91dedc4d89e3e59214d50a.zip
hdf5-7a0cdfbbacc86aa73e91dedc4d89e3e59214d50a.tar.gz
hdf5-7a0cdfbbacc86aa73e91dedc4d89e3e59214d50a.tar.bz2
[svn-r28636] merge from trunk.
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt105
-rw-r--r--src/H5AC.c32
-rw-r--r--src/H5ACpkg.h1
-rw-r--r--src/H5ACprivate.h1
-rw-r--r--src/H5ACpublic.h1
-rw-r--r--src/H5Abtree2.c20
-rw-r--r--src/H5B.c5
-rw-r--r--src/H5B2cache.c2
-rw-r--r--src/H5B2dbg.c48
-rw-r--r--src/H5B2int.c7
-rw-r--r--src/H5B2private.h4
-rw-r--r--src/H5B2test.c50
-rw-r--r--src/H5Cpkg.h2
-rw-r--r--src/H5Cprivate.h5
-rw-r--r--src/H5D.c4
-rw-r--r--src/H5Dbtree.c54
-rw-r--r--src/H5Dchunk.c109
-rw-r--r--src/H5Dint.c83
-rw-r--r--src/H5Dlayout.c6
-rw-r--r--src/H5Doh.c39
-rw-r--r--src/H5Dpkg.h6
-rw-r--r--src/H5Dvirtual.c18
-rw-r--r--src/H5FA.c138
-rw-r--r--src/H5FAcache.c34
-rw-r--r--src/H5FAdbg.c132
-rw-r--r--src/H5FAdblkpage.c62
-rw-r--r--src/H5FAdblock.c108
-rw-r--r--src/H5FAhdr.c106
-rw-r--r--src/H5FApkg.h110
-rw-r--r--src/H5FAprivate.h45
-rw-r--r--src/H5FAstat.c18
-rw-r--r--src/H5FAtest.c91
-rw-r--r--src/H5FD.c125
-rw-r--r--src/H5FDcore.c90
-rw-r--r--src/H5FDdirect.c87
-rw-r--r--src/H5FDfamily.c82
-rw-r--r--src/H5FDlog.c81
-rw-r--r--src/H5FDmulti.c107
-rw-r--r--src/H5FDpkg.h3
-rw-r--r--src/H5FDprivate.h2
-rw-r--r--src/H5FDpublic.h24
-rw-r--r--src/H5FDsec2.c73
-rw-r--r--src/H5FDstdio.c97
-rw-r--r--src/H5FL.c3
-rw-r--r--src/H5FS.c290
-rw-r--r--src/H5FScache.c26
-rw-r--r--src/H5FSdbg.c121
-rw-r--r--src/H5FSpkg.h16
-rw-r--r--src/H5FSprivate.h18
-rw-r--r--src/H5FSpublic.h2
-rw-r--r--src/H5FSsection.c360
-rw-r--r--src/H5FSstat.c12
-rw-r--r--src/H5FStest.c27
-rw-r--r--src/H5Fint.c10
-rw-r--r--src/H5Fsuper.c1
-rw-r--r--src/H5G.c95
-rw-r--r--src/H5Gbtree2.c20
-rw-r--r--src/H5Gdense.c8
-rw-r--r--src/H5Gent.c6
-rw-r--r--src/H5Gint.c94
-rw-r--r--src/H5Gloc.c10
-rw-r--r--src/H5Gnode.c2
-rw-r--r--src/H5Goh.c20
-rw-r--r--src/H5Gpkg.h1
-rw-r--r--src/H5Gprivate.h1
-rw-r--r--src/H5Gstab.c10
-rw-r--r--src/H5Gtraverse.c10
-rw-r--r--src/H5HFbtree2.c449
-rw-r--r--src/H5HFdblock.c6
-rw-r--r--src/H5HFhdr.c19
-rw-r--r--src/H5HFhuge.c58
-rw-r--r--src/H5HFiblock.c8
-rw-r--r--src/H5HFpkg.h76
-rw-r--r--src/H5HFsection.c36
-rw-r--r--src/H5HFtest.c4
-rw-r--r--src/H5HFtiny.c12
-rw-r--r--src/H5HL.c880
-rw-r--r--src/H5HLcache.c99
-rw-r--r--src/H5HLdbg.c72
-rw-r--r--src/H5HLdblk.c282
-rw-r--r--src/H5HLint.c317
-rw-r--r--src/H5HLpkg.h98
-rw-r--r--src/H5HLprfx.c166
-rw-r--r--src/H5HLprivate.h45
-rw-r--r--src/H5HLpublic.h2
-rw-r--r--src/H5MM.c35
-rw-r--r--src/H5O.c2
-rw-r--r--src/H5Ocopy.c12
-rw-r--r--src/H5Odtype.c2
-rw-r--r--src/H5Oefl.c4
-rw-r--r--src/H5Olayout.c166
-rw-r--r--src/H5Omtime.c56
-rw-r--r--src/H5Opkg.h4
-rw-r--r--src/H5Oprivate.h6
-rw-r--r--src/H5Otest.c4
-rw-r--r--src/H5Pdcpl.c26
-rw-r--r--src/H5Pfapl.c6
-rw-r--r--src/H5Pgcpl.c2
-rw-r--r--src/H5Pint.c14
-rw-r--r--src/H5Pocpl.c1
-rw-r--r--src/H5Ppublic.h1
-rw-r--r--src/H5Ptest.c2
-rw-r--r--src/H5SM.c4
-rw-r--r--src/H5SMbtree2.c99
-rw-r--r--src/H5SMcache.c6
-rw-r--r--src/H5SMmessage.c26
-rw-r--r--src/H5SMpkg.h6
-rw-r--r--src/H5Shyper.c2
-rw-r--r--src/H5T.c20
-rw-r--r--src/H5VMprivate.h4
-rw-r--r--src/H5Zscaleoffset.c2
-rw-r--r--src/H5Ztrans.c1
-rw-r--r--src/H5private.h108
-rw-r--r--src/H5public.h15
-rw-r--r--src/H5system.c214
-rw-r--r--src/H5trace.c7
-rw-r--r--src/H5win32defs.h4
-rw-r--r--src/Makefile.am2
118 files changed, 3973 insertions, 2899 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index ef3e760..2c9ca8a 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -165,13 +165,13 @@ IDE_GENERATED_PROPERTIES ("H5EA" "${H5EA_HDRS}" "${H5EA_SRCS}" )
set (H5F_SRCS
${HDF5_SRC_DIR}/H5F.c
- ${HDF5_SRC_DIR}/H5Fint.c
${HDF5_SRC_DIR}/H5Faccum.c
${HDF5_SRC_DIR}/H5Fcwfs.c
${HDF5_SRC_DIR}/H5Fdbg.c
${HDF5_SRC_DIR}/H5Fdeprec.c
${HDF5_SRC_DIR}/H5Fefc.c
${HDF5_SRC_DIR}/H5Ffake.c
+ ${HDF5_SRC_DIR}/H5Fint.c
${HDF5_SRC_DIR}/H5Fio.c
${HDF5_SRC_DIR}/H5Fmount.c
${HDF5_SRC_DIR}/H5Fmpi.c
@@ -193,8 +193,8 @@ set (H5FA_SRCS
${HDF5_SRC_DIR}/H5FA.c
${HDF5_SRC_DIR}/H5FAcache.c
${HDF5_SRC_DIR}/H5FAdbg.c
- ${HDF5_SRC_DIR}/H5FAdblock.c
${HDF5_SRC_DIR}/H5FAdblkpage.c
+ ${HDF5_SRC_DIR}/H5FAdblock.c
${HDF5_SRC_DIR}/H5FAhdr.c
${HDF5_SRC_DIR}/H5FAstat.c
${HDF5_SRC_DIR}/H5FAtest.c
@@ -338,7 +338,9 @@ set (H5HL_SRCS
${HDF5_SRC_DIR}/H5HL.c
${HDF5_SRC_DIR}/H5HLcache.c
${HDF5_SRC_DIR}/H5HLdbg.c
+ ${HDF5_SRC_DIR}/H5HLdblk.c
${HDF5_SRC_DIR}/H5HLint.c
+ ${HDF5_SRC_DIR}/H5HLprfx.c
)
set (H5HL_HDRS
@@ -501,14 +503,6 @@ set (H5R_HDRS
IDE_GENERATED_PROPERTIES ("H5R" "${H5R_HDRS}" "${H5R_SRCS}" )
-set (H5UC_SRCS
- ${HDF5_SRC_DIR}/H5UC.c
-)
-set (H5UC_HDRS
-)
-IDE_GENERATED_PROPERTIES ("H5UC" "${H5UC_HDRS}" "${H5UC_SRCS}" )
-
-
set (H5RS_SRCS
${HDF5_SRC_DIR}/H5RS.c
)
@@ -607,6 +601,14 @@ set (H5TS_HDRS
IDE_GENERATED_PROPERTIES ("H5TS" "${H5TS_HDRS}" "${H5TS_SRCS}" )
+set (H5UC_SRCS
+ ${HDF5_SRC_DIR}/H5UC.c
+)
+set (H5UC_HDRS
+)
+IDE_GENERATED_PROPERTIES ("H5UC" "${H5UC_HDRS}" "${H5UC_SRCS}" )
+
+
set (H5VM_SRCS
${HDF5_SRC_DIR}/H5VM.c
)
@@ -780,38 +782,21 @@ set (H5_GENERATED_HEADERS
option (HDF5_GENERATE_HEADERS "Rebuild Generated Files" ON)
mark_as_advanced (HDF5_GENERATE_HEADERS)
if (HDF5_GENERATE_HEADERS)
+ set_source_files_properties(${H5_GENERATED_HEADERS} PROPERTIES GENERATED TRUE)
find_package (Perl)
if (PERL_FOUND)
- add_custom_command (
- OUTPUT ${HDF5_SRC_DIR}/H5Edefin.h ${HDF5_SRC_DIR}/H5Einit.h ${HDF5_SRC_DIR}/H5Epubgen.h ${HDF5_SRC_DIR}/H5Eterm.h
- PRE_BUILD
- COMMAND ${PERL_EXECUTABLE}
- ARGS ${HDF5_SOURCE_DIR}/bin/make_err ${HDF5_SRC_DIR}/H5err.txt
- DEPENDS ${HDF5_SRC_DIR}/H5err.txt
- COMMENT " Creating err header"
+ execute_process (
+ COMMAND ${PERL_EXECUTABLE} ${HDF5_SOURCE_DIR}/bin/make_err ${HDF5_SRC_DIR}/H5err.txt OUTPUT_VARIABLE SCRIPT_OUTPUT
)
-
- add_custom_command (
- OUTPUT ${HDF5_SRC_DIR}/H5version.h
- PRE_BUILD
- COMMAND ${PERL_EXECUTABLE}
- ARGS ${HDF5_SOURCE_DIR}/bin/make_vers ${HDF5_SRC_DIR}/H5vers.txt
- DEPENDS ${HDF5_SRC_DIR}/H5vers.txt
- COMMENT " Creating API version macro"
- )
-
- add_custom_command (
- OUTPUT ${HDF5_SRC_DIR}/H5overflow.h
- PRE_BUILD
- COMMAND ${PERL_EXECUTABLE}
- ARGS ${HDF5_SOURCE_DIR}/bin/make_overflow ${HDF5_SRC_DIR}/H5overflow.txt
- DEPENDS ${HDF5_SRC_DIR}/H5overflow.txt
- COMMENT " Creating Assignment overflow macro"
+ message(STATUS ${SCRIPT_OUTPUT})
+ execute_process (
+ COMMAND ${PERL_EXECUTABLE} ${HDF5_SOURCE_DIR}/bin/make_vers ${HDF5_SRC_DIR}/H5vers.txt OUTPUT_VARIABLE SCRIPT_OUTPUT
)
-
- add_custom_target(run_perl_scripts ALL
- DEPENDS ${HDF5_SRC_DIR}/H5Edefin.h ${HDF5_SRC_DIR}/H5Einit.h ${HDF5_SRC_DIR}/H5Epubgen.h ${HDF5_SRC_DIR}/H5Eterm.h ${HDF5_SRC_DIR}/H5version.h ${HDF5_SRC_DIR}/H5overflow.h
+ message(STATUS ${SCRIPT_OUTPUT})
+ execute_process (
+ COMMAND ${PERL_EXECUTABLE} ${HDF5_SOURCE_DIR}/bin/make_overflow ${HDF5_SRC_DIR}/H5overflow.txt OUTPUT_VARIABLE SCRIPT_OUTPUT
)
+ message(STATUS ${SCRIPT_OUTPUT})
else (PERL_FOUND)
message (STATUS "Cannot generate headers - perl not found")
endif (PERL_FOUND)
@@ -826,11 +811,6 @@ TARGET_C_PROPERTIES (H5detect STATIC " " " ")
if (MSVC OR MINGW)
target_link_libraries (H5detect "ws2_32.lib")
endif (MSVC OR MINGW)
-if (HDF5_GENERATE_HEADERS)
- add_dependencies(H5detect run_perl_scripts)
-else (HDF5_GENERATE_HEADERS)
- add_dependencies(H5detect "${H5_GENERATED_HEADERS}")
-endif (HDF5_GENERATE_HEADERS)
set (CMD $<TARGET_FILE:H5detect>)
add_custom_command (
@@ -845,11 +825,6 @@ TARGET_C_PROPERTIES (H5make_libsettings STATIC " " " ")
if (MSVC OR MINGW)
target_link_libraries (H5make_libsettings "ws2_32.lib")
endif (MSVC OR MINGW)
-if (HDF5_GENERATE_HEADERS)
- add_dependencies(H5make_libsettings run_perl_scripts)
-else (HDF5_GENERATE_HEADERS)
- add_dependencies(H5make_libsettings "${H5_GENERATED_HEADERS}")
-endif (HDF5_GENERATE_HEADERS)
set (CMD $<TARGET_FILE:H5make_libsettings>)
add_custom_command (
@@ -863,10 +838,9 @@ add_custom_command (
#-----------------------------------------------------------------------------
# Add H5Tinit source to build - generated by H5Detect/CMake at configure time
#-----------------------------------------------------------------------------
-set (common_SRCS ${common_SRCS} ${HDF5_BINARY_DIR}/H5Tinit.c)
-set (common_SRCS ${common_SRCS} ${HDF5_BINARY_DIR}/H5lib_settings.c)
+set (gen_SRCS ${HDF5_BINARY_DIR}/H5Tinit.c ${HDF5_BINARY_DIR}/H5lib_settings.c)
-add_library (${HDF5_LIB_TARGET} STATIC ${common_SRCS} ${H5_PUBLIC_HEADERS} ${H5_PRIVATE_HEADERS} ${H5_GENERATED_HEADERS})
+add_library (${HDF5_LIB_TARGET} STATIC ${common_SRCS} ${gen_SRCS} ${H5_PUBLIC_HEADERS} ${H5_PRIVATE_HEADERS} ${H5_GENERATED_HEADERS})
TARGET_C_PROPERTIES (${HDF5_LIB_TARGET} STATIC " " " ")
target_link_libraries (${HDF5_LIB_TARGET} ${LINK_LIBS})
if (NOT WIN32)
@@ -881,11 +855,6 @@ set_target_properties (${HDF5_LIB_TARGET} PROPERTIES
FOLDER libraries
INTERFACE_INCLUDE_DIRECTORIES "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
)
-if (HDF5_GENERATE_HEADERS)
- add_dependencies(${HDF5_LIB_TARGET} run_perl_scripts)
-else (HDF5_GENERATE_HEADERS)
- add_dependencies(${HDF5_LIB_TARGET} "${HDF5_SRC_DIR}/H5Edefin.h;${HDF5_SRC_DIR}/H5Einit.h;${HDF5_SRC_DIR}/H5Epubgen.h;${HDF5_SRC_DIR}/H5Eterm.h")
-endif (HDF5_GENERATE_HEADERS)
option (HDF5_ENABLE_DEBUG_APIS "Turn on debugging in all packages" OFF)
if (HDF5_ENABLE_DEBUG_APIS)
@@ -897,7 +866,25 @@ endif (HDF5_ENABLE_DEBUG_APIS)
set (install_targets ${HDF5_LIB_TARGET})
if (BUILD_SHARED_LIBS)
- add_library (${HDF5_LIBSH_TARGET} SHARED ${common_SRCS} ${H5_PUBLIC_HEADERS} ${H5_PRIVATE_HEADERS} ${H5_GENERATED_HEADERS})
+ file (MAKE_DIRECTORY "${HDF5_BINARY_DIR}/shared")
+ set (CMD $<TARGET_FILE:H5detect>)
+ add_custom_command (
+ OUTPUT ${HDF5_BINARY_DIR}/shared/H5Tinit.c
+ COMMAND ${CMD}
+ ARGS > ${HDF5_BINARY_DIR}/shared/H5Tinit.c
+ DEPENDS H5detect
+ WORKING_DIRECTORY ${HDF5_BINARY_DIR}/shared
+ )
+ set (CMD $<TARGET_FILE:H5make_libsettings>)
+ add_custom_command (
+ OUTPUT ${HDF5_BINARY_DIR}/shared/H5lib_settings.c
+ COMMAND ${CMD}
+ ARGS > ${HDF5_BINARY_DIR}/shared/H5lib_settings.c
+ DEPENDS H5make_libsettings
+ WORKING_DIRECTORY ${HDF5_BINARY_DIR}
+ )
+ set (shared_gen_SRCS ${HDF5_BINARY_DIR}/shared/H5Tinit.c ${HDF5_BINARY_DIR}/shared/H5lib_settings.c)
+ add_library (${HDF5_LIBSH_TARGET} SHARED ${common_SRCS} ${shared_gen_SRCS} ${H5_PUBLIC_HEADERS} ${H5_PRIVATE_HEADERS} ${H5_GENERATED_HEADERS})
TARGET_C_PROPERTIES (${HDF5_LIBSH_TARGET} SHARED " " " ")
target_link_libraries (${HDF5_LIBSH_TARGET} ${LINK_SHARED_LIBS})
if (NOT WIN32)
@@ -914,16 +901,12 @@ if (BUILD_SHARED_LIBS)
INTERFACE_INCLUDE_DIRECTORIES "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
INTERFACE_COMPILE_DEFINITIONS H5_BUILT_AS_DYNAMIC_LIB=1
)
- if (HDF5_GENERATE_HEADERS)
- add_dependencies(${HDF5_LIBSH_TARGET} run_perl_scripts)
- else (HDF5_GENERATE_HEADERS)
- add_dependencies(${HDF5_LIBSH_TARGET} "${HDF5_SRC_DIR}/H5Edefin.h;${HDF5_SRC_DIR}/H5Einit.h;${HDF5_SRC_DIR}/H5Epubgen.h;${HDF5_SRC_DIR}/H5Eterm.h")
- endif (HDF5_GENERATE_HEADERS)
if (HDF5_ENABLE_THREADSAFE)
set_property (TARGET ${HDF5_LIBSH_TARGET}
APPEND PROPERTY COMPILE_DEFINITIONS
"H5_HAVE_THREADSAFE"
)
+ target_link_libraries (${HDF5_LIBSH_TARGET} Threads::Threads)
endif (HDF5_ENABLE_THREADSAFE)
if (HDF5_ENABLE_DEBUG_APIS)
diff --git a/src/H5AC.c b/src/H5AC.c
index ea535dd..52e7e58 100644
--- a/src/H5AC.c
+++ b/src/H5AC.c
@@ -464,6 +464,7 @@ H5AC_create(const H5F_t *f, H5AC_cache_config_t *config_ptr)
HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "H5C_set_prefix() failed")
#endif /* H5_HAVE_PARALLEL */
+ /* Set the cache parameters */
if(H5AC_set_cache_auto_resize_config(f->shared->cache, config_ptr) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "auto resize configuration failed")
@@ -652,7 +653,7 @@ H5AC_flush(H5F_t *f, hid_t dxpl_id)
char trace[128] = "";
FILE * trace_file_ptr = NULL;
#endif /* H5AC__TRACE_FILE_ENABLED */
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -867,7 +868,7 @@ H5AC_mark_entry_dirty(void *thing)
char trace[128] = "";
FILE * trace_file_ptr = NULL;
#endif /* H5AC__TRACE_FILE_ENABLED */
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -935,7 +936,7 @@ H5AC_move_entry(H5F_t *f, const H5AC_class_t *type, haddr_t old_addr, haddr_t ne
#ifdef H5_HAVE_PARALLEL
H5AC_aux_t *aux_ptr;
#endif /* H5_HAVE_PARALLEL */
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -1020,6 +1021,7 @@ H5AC_pin_protected_entry(void *thing)
(unsigned long)(((H5C_cache_entry_t *)thing)->addr));
#endif /* H5AC__TRACE_FILE_ENABLED */
+ /* Pin entry */
if(H5C_pin_protected_entry(thing) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_CANTPIN, FAIL, "can't pin entry")
@@ -1068,6 +1070,7 @@ H5AC_create_flush_dependency(void * parent_thing, void * child_thing)
(unsigned long)(((H5C_cache_entry_t *)child_thing)->addr));
#endif /* H5AC__TRACE_FILE_ENABLED */
+ /* Create the flush dependency */
if(H5C_create_flush_dependency(parent_thing, child_thing) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_CANTDEPEND, FAIL, "H5C_create_flush_dependency() failed.")
@@ -1109,12 +1112,12 @@ void *
H5AC_protect(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr,
void *udata, unsigned flags)
{
- void * thing; /* Pointer to native data structure for entry */
#if H5AC__TRACE_FILE_ENABLED
char trace[128] = "";
size_t trace_entry_size = 0;
FILE * trace_file_ptr = NULL;
#endif /* H5AC__TRACE_FILE_ENABLED */
+ void * thing = NULL; /* Pointer to native data structure for entry */
void * ret_value = NULL; /* Return value */
FUNC_ENTER_NOAPI(NULL)
@@ -1194,7 +1197,7 @@ H5AC_resize_entry(void *thing, size_t new_size)
char trace[128] = "";
FILE * trace_file_ptr = NULL;
#endif /* H5AC__TRACE_FILE_ENABLED */
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -1212,6 +1215,7 @@ H5AC_resize_entry(void *thing, size_t new_size)
(int)new_size);
#endif /* H5AC__TRACE_FILE_ENABLED */
+ /* Resize the entry */
if(H5C_resize_entry(thing, new_size) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_CANTRESIZE, FAIL, "can't resize entry")
@@ -1274,6 +1278,7 @@ H5AC_unpin_entry(void *thing)
(unsigned long)(((H5C_cache_entry_t *)thing)->addr));
#endif /* H5AC__TRACE_FILE_ENABLED */
+ /* Unpin the entry */
if(H5C_unpin_entry(thing) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, "can't unpin entry")
@@ -1321,6 +1326,7 @@ H5AC_destroy_flush_dependency(void * parent_thing, void * child_thing)
(unsigned long long)(((H5C_cache_entry_t *)child_thing)->addr));
#endif /* H5AC__TRACE_FILE_ENABLED */
+ /* Destroy the flush dependency */
if(H5C_destroy_flush_dependency(parent_thing, child_thing) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, "H5C_destroy_flush_dependency() failed.")
@@ -1376,15 +1382,15 @@ herr_t
H5AC_unprotect(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr,
void *thing, unsigned flags)
{
+#if H5AC__TRACE_FILE_ENABLED
+ char trace[128] = "";
+ FILE * trace_file_ptr = NULL;
+#endif /* H5AC__TRACE_FILE_ENABLED */
hbool_t dirtied;
hbool_t deleted;
#ifdef H5_HAVE_PARALLEL
H5AC_aux_t * aux_ptr = NULL;
#endif /* H5_HAVE_PARALLEL */
-#if H5AC__TRACE_FILE_ENABLED
- char trace[128] = "";
- FILE * trace_file_ptr = NULL;
-#endif /* H5AC__TRACE_FILE_ENABLED */
herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -1718,12 +1724,12 @@ done:
herr_t
H5AC_set_cache_auto_resize_config(H5AC_t *cache_ptr, H5AC_cache_config_t *config_ptr)
{
- H5C_auto_size_ctl_t internal_config;
#if H5AC__TRACE_FILE_ENABLED
H5AC_cache_config_t trace_config = H5AC__DEFAULT_CACHE_CONFIG;
FILE * trace_file_ptr = NULL;
#endif /* H5AC__TRACE_FILE_ENABLED */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5C_auto_size_ctl_t internal_config;
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -2318,8 +2324,8 @@ done:
herr_t
H5AC_tag(hid_t dxpl_id, haddr_t metadata_tag, haddr_t *prev_tag)
{
- H5P_genplist_t *dxpl; /* dataset transfer property list */
- herr_t ret_value = SUCCEED;
+ H5P_genplist_t *dxpl; /* Dataset transfer property list */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
diff --git a/src/H5ACpkg.h b/src/H5ACpkg.h
index 050e21c..1051373 100644
--- a/src/H5ACpkg.h
+++ b/src/H5ACpkg.h
@@ -401,7 +401,6 @@ typedef struct H5AC_aux_t
void (* sync_point_done)(int num_writes,
haddr_t * written_entries_tbl);
-
} H5AC_aux_t; /* struct H5AC_aux_t */
/* Package scoped functions */
diff --git a/src/H5ACprivate.h b/src/H5ACprivate.h
index 8ebbb67..bd23fea 100644
--- a/src/H5ACprivate.h
+++ b/src/H5ACprivate.h
@@ -374,7 +374,6 @@ H5_DLL herr_t H5AC_set_ring(hid_t dxpl_id, H5AC_ring_t ring, H5P_genplist_t **dx
H5AC_ring_t *orig_ring);
H5_DLL herr_t H5AC_reset_ring(H5P_genplist_t *dxpl, H5AC_ring_t orig_ring);
-
#ifdef H5_HAVE_PARALLEL
H5_DLL herr_t H5AC_add_candidate(H5AC_t * cache_ptr, haddr_t addr);
#endif /* H5_HAVE_PARALLEL */
diff --git a/src/H5ACpublic.h b/src/H5ACpublic.h
index 598197f..4e5502d 100644
--- a/src/H5ACpublic.h
+++ b/src/H5ACpublic.h
@@ -506,3 +506,4 @@ typedef struct H5AC_cache_config_t
}
#endif
#endif
+
diff --git a/src/H5Abtree2.c b/src/H5Abtree2.c
index 28e49a6..972fb0b 100644
--- a/src/H5Abtree2.c
+++ b/src/H5Abtree2.c
@@ -85,7 +85,8 @@ static herr_t H5A__dense_btree2_corder_encode(uint8_t *raw, const void *native,
void *ctx);
static herr_t H5A__dense_btree2_corder_decode(const uint8_t *raw, void *native,
void *ctx);
-static herr_t H5A__dense_btree2_corder_debug(FILE *stream, int indent, int fwidth, const void *record);
+static herr_t H5A__dense_btree2_corder_debug(FILE *stream, int indent, int fwidth,
+ const void *record, const void *_udata);
/* v2 B-tree driver callbacks for 'name' index */
static herr_t H5A__dense_btree2_name_store(void *native, const void *udata);
@@ -94,7 +95,8 @@ static herr_t H5A__dense_btree2_name_encode(uint8_t *raw, const void *native,
void *ctx);
static herr_t H5A__dense_btree2_name_decode(const uint8_t *raw, void *native,
void *ctx);
-static herr_t H5A__dense_btree2_name_debug(FILE *stream, int indent, int fwidth, const void *record);
+static herr_t H5A__dense_btree2_name_debug(FILE *stream, int indent, int fwidth,
+ const void *record, const void *_udata);
/* Fractal heap function callbacks */
static herr_t H5A__dense_fh_name_cmp(const void *obj, size_t obj_len, void *op_data);
@@ -114,7 +116,9 @@ const H5B2_class_t H5A_BT2_NAME[1]={{ /* B-tree class information */
H5A__dense_btree2_name_compare, /* Record comparison callback */
H5A__dense_btree2_name_encode, /* Record encoding callback */
H5A__dense_btree2_name_decode, /* Record decoding callback */
- H5A__dense_btree2_name_debug /* Record debugging callback */
+ H5A__dense_btree2_name_debug, /* Record debugging callback */
+ NULL, /* Create debugging context */
+ NULL /* Destroy debugging context */
}};
/* v2 B-tree class for indexing 'creation order' field of attributes */
@@ -128,7 +132,9 @@ const H5B2_class_t H5A_BT2_CORDER[1]={{ /* B-tree class information */
H5A__dense_btree2_corder_compare, /* Record comparison callback */
H5A__dense_btree2_corder_encode, /* Record encoding callback */
H5A__dense_btree2_corder_decode, /* Record decoding callback */
- H5A__dense_btree2_corder_debug /* Record debugging callback */
+ H5A__dense_btree2_corder_debug, /* Record debugging callback */
+ NULL, /* Create debugging context */
+ NULL /* Destroy debugging context */
}};
@@ -375,7 +381,8 @@ H5A__dense_btree2_name_decode(const uint8_t *raw, void *_nrecord, void H5_ATTR_U
*-------------------------------------------------------------------------
*/
static herr_t
-H5A__dense_btree2_name_debug(FILE *stream, int indent, int fwidth, const void *_nrecord)
+H5A__dense_btree2_name_debug(FILE *stream, int indent, int fwidth,
+ const void *_nrecord, const void H5_ATTR_UNUSED *_udata)
{
const H5A_dense_bt2_name_rec_t *nrecord = (const H5A_dense_bt2_name_rec_t *)_nrecord;
@@ -532,7 +539,8 @@ H5A__dense_btree2_corder_decode(const uint8_t *raw, void *_nrecord, void H5_ATTR
*-------------------------------------------------------------------------
*/
static herr_t
-H5A__dense_btree2_corder_debug(FILE *stream, int indent, int fwidth, const void *_nrecord)
+H5A__dense_btree2_corder_debug(FILE *stream, int indent, int fwidth,
+ const void *_nrecord, const void H5_ATTR_UNUSED *_udata)
{
const H5A_dense_bt2_corder_rec_t *nrecord = (const H5A_dense_bt2_corder_rec_t *)_nrecord;
diff --git a/src/H5B.c b/src/H5B.c
index 48be703..7f933cd 100644
--- a/src/H5B.c
+++ b/src/H5B.c
@@ -531,6 +531,7 @@ H5B__split(H5F_t *f, hid_t dxpl_id, H5B_ins_ud_t *bt_ud, unsigned idx,
} /* end if */
bt_ud->bt->right = split_bt_ud->addr;
+ HDassert(bt_ud->cache_flags & H5AC__DIRTIED_FLAG);
done:
if(ret_value < 0) {
@@ -647,7 +648,7 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void
/* Unprotect the old root so we can move it. Also force it to be marked
* dirty so it is written to the new location. */
if(H5AC_unprotect(f, dxpl_id, H5AC_BT, bt_ud.addr, bt_ud.bt, H5AC__DIRTIED_FLAG) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release old root")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release old root")
bt_ud.bt = NULL; /* Make certain future references will be caught */
/* Move the location of the old root on the disk */
@@ -1060,7 +1061,7 @@ H5B__insert_helper(H5F_t *f, hid_t dxpl_id, H5B_ins_ud_t *bt_ud,
bt->child[idx] = new_child_bt_ud.addr;
bt_ud->cache_flags |= H5AC__DIRTIED_FLAG;
} else if(H5B_INS_LEFT == my_ins || H5B_INS_RIGHT == my_ins) {
- hbool_t *tmp_bt_flags_ptr = NULL;
+ unsigned *tmp_bt_flags_ptr = NULL;
H5B_t *tmp_bt;
/*
diff --git a/src/H5B2cache.c b/src/H5B2cache.c
index 421e24b..57f794b 100644
--- a/src/H5B2cache.c
+++ b/src/H5B2cache.c
@@ -517,7 +517,7 @@ H5B2__cache_int_deserialize(const void *_image, size_t H5_ATTR_UNUSED len,
/* Version */
if(*image++ != H5B2_INT_VERSION)
- HGOTO_ERROR(H5E_BTREE, H5E_BADRANGE, NULL, "wrong B-tree internal node version")
+ HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, NULL, "wrong B-tree internal node version")
/* B-tree type */
if(*image++ != (uint8_t)udata->hdr->cls->id)
diff --git a/src/H5B2dbg.c b/src/H5B2dbg.c
index f723d10..ad9f970 100644
--- a/src/H5B2dbg.c
+++ b/src/H5B2dbg.c
@@ -92,6 +92,7 @@ H5B2__hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent,
const H5B2_class_t *type, haddr_t obj_addr)
{
H5B2_hdr_t *hdr = NULL; /* B-tree header info */
+ void *dbg_ctx = NULL; /* v2 B-tree debugging context */
unsigned u; /* Local index variable */
char temp_str[128]; /* Temporary string, for formatting */
H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */
@@ -109,13 +110,22 @@ H5B2__hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent,
HDassert(indent >= 0);
HDassert(fwidth >= 0);
HDassert(type);
+ HDassert((type->crt_dbg_ctx && type->dst_dbg_ctx) ||
+ (NULL == type->crt_dbg_ctx && NULL == type->dst_dbg_ctx));
+
+ /* Check for debugging context callback available */
+ if(type->crt_dbg_ctx) {
+ /* Create debugging context */
+ if(NULL == (dbg_ctx = (type->crt_dbg_ctx)(f, dxpl_id, obj_addr)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "unable to create v2 B-tree debugging context")
+ } /* end if */
/*
* Load the B-tree header.
*/
cache_udata.f = f;
cache_udata.addr = addr;
- cache_udata.ctx_udata = f;
+ cache_udata.ctx_udata = dbg_ctx;
if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, &cache_udata, H5AC__READ_ONLY_FLAG)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree header")
@@ -168,6 +178,8 @@ H5B2__hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent,
} /* end for */
done:
+ if(dbg_ctx && (type->dst_dbg_ctx)(dbg_ctx) < 0)
+ HDONE_ERROR(H5E_BTREE, H5E_CANTRELEASE, FAIL, "unable to release v2 B-tree debugging context")
if(hdr) {
hdr->f = NULL;
if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, addr, hdr, H5AC__NO_FLAGS_SET) < 0)
@@ -197,6 +209,7 @@ H5B2__int_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent,
{
H5B2_hdr_t *hdr = NULL; /* B-tree header */
H5B2_internal_t *internal = NULL; /* B-tree internal node */
+ void *dbg_ctx = NULL; /* v2 B-tree debugging context */
unsigned u; /* Local index variable */
char temp_str[128]; /* Temporary string, for formatting */
H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */
@@ -213,16 +226,25 @@ H5B2__int_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent,
HDassert(indent >= 0);
HDassert(fwidth >= 0);
HDassert(type);
+ HDassert((type->crt_dbg_ctx && type->dst_dbg_ctx) ||
+ (NULL == type->crt_dbg_ctx && NULL == type->dst_dbg_ctx));
HDassert(H5F_addr_defined(hdr_addr));
HDassert(H5F_addr_defined(obj_addr));
HDassert(nrec > 0);
+ /* Check for debugging context callback available */
+ if(type->crt_dbg_ctx) {
+ /* Create debugging context */
+ if(NULL == (dbg_ctx = (type->crt_dbg_ctx)(f, dxpl_id, obj_addr)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "unable to create v2 B-tree debugging context")
+ } /* end if */
+
/*
* Load the B-tree header.
*/
cache_udata.f = f;
cache_udata.addr = hdr_addr;
- cache_udata.ctx_udata = f;
+ cache_udata.ctx_udata = dbg_ctx;
if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, &cache_udata, H5AC__READ_ONLY_FLAG)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree header")
@@ -273,8 +295,7 @@ H5B2__int_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent,
HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3),
temp_str);
HDassert(H5B2_INT_NREC(internal, hdr, u));
- (void)(type->debug)(stream, indent + 6, MAX (0, fwidth-6),
- H5B2_INT_NREC(internal, hdr, u));
+ (void)(type->debug)(stream, indent + 6, MAX (0, fwidth-6), H5B2_INT_NREC(internal, hdr, u), dbg_ctx);
} /* end for */
/* Print final node pointer */
@@ -286,6 +307,8 @@ H5B2__int_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent,
internal->node_ptrs[u].addr);
done:
+ if(dbg_ctx && (type->dst_dbg_ctx)(dbg_ctx) < 0)
+ HDONE_ERROR(H5E_BTREE, H5E_CANTRELEASE, FAIL, "unable to release v2 B-tree debugging context")
if(hdr) {
hdr->f = NULL;
if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, hdr, H5AC__NO_FLAGS_SET) < 0)
@@ -318,6 +341,7 @@ H5B2__leaf_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent
H5B2_hdr_t *hdr = NULL; /* B-tree header */
H5B2_leaf_t *leaf = NULL; /* B-tree leaf node */
H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */
+ void *dbg_ctx = NULL; /* v2 B-tree debugging context */
unsigned u; /* Local index variable */
char temp_str[128]; /* Temporary string, for formatting */
herr_t ret_value = SUCCEED; /* Return value */
@@ -333,16 +357,25 @@ H5B2__leaf_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent
HDassert(indent >= 0);
HDassert(fwidth >= 0);
HDassert(type);
+ HDassert((type->crt_dbg_ctx && type->dst_dbg_ctx) ||
+ (NULL == type->crt_dbg_ctx && NULL == type->dst_dbg_ctx));
HDassert(H5F_addr_defined(hdr_addr));
HDassert(H5F_addr_defined(obj_addr));
HDassert(nrec > 0);
+ /* Check for debugging context callback available */
+ if(type->crt_dbg_ctx) {
+ /* Create debugging context */
+ if(NULL == (dbg_ctx = (type->crt_dbg_ctx)(f, dxpl_id, obj_addr)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "unable to create v2 B-tree debugging context")
+ } /* end if */
+
/*
* Load the B-tree header.
*/
cache_udata.f = f;
cache_udata.addr = hdr_addr;
- cache_udata.ctx_udata = f;
+ cache_udata.ctx_udata = dbg_ctx;
if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, &cache_udata, H5AC__READ_ONLY_FLAG)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree header")
@@ -384,11 +417,12 @@ H5B2__leaf_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent
HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3),
temp_str);
HDassert(H5B2_LEAF_NREC(leaf, hdr, u));
- (void)(type->debug)(stream, indent + 6, MAX (0, fwidth-6),
- H5B2_LEAF_NREC(leaf, hdr, u));
+ (void)(type->debug)(stream, indent + 6, MAX (0, fwidth-6), H5B2_LEAF_NREC(leaf, hdr, u), dbg_ctx);
} /* end for */
done:
+ if(dbg_ctx && (type->dst_dbg_ctx)(dbg_ctx) < 0)
+ HDONE_ERROR(H5E_BTREE, H5E_CANTRELEASE, FAIL, "unable to release v2 B-tree debugging context")
if(hdr) {
hdr->f = NULL;
if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, hdr, H5AC__NO_FLAGS_SET) < 0)
diff --git a/src/H5B2int.c b/src/H5B2int.c
index f412260..b8c9634 100644
--- a/src/H5B2int.c
+++ b/src/H5B2int.c
@@ -76,8 +76,8 @@ static herr_t H5B2__merge3(H5B2_hdr_t *hdr, hid_t dxpl_id, uint16_t depth,
H5B2_node_ptr_t *curr_node_ptr, unsigned *parent_cache_info_flags_ptr,
H5B2_internal_t *internal, unsigned *internal_flags_ptr, unsigned idx);
static herr_t H5B2__swap_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id, uint16_t depth,
- H5B2_internal_t *internal, unsigned *internal_flags_ptr,
- unsigned idx, void *swap_loc);
+ H5B2_internal_t *internal, unsigned *internal_flags_ptr, unsigned idx,
+ void *swap_loc);
static herr_t H5B2__create_internal(H5B2_hdr_t *hdr, hid_t dxpl_id,
H5B2_node_ptr_t *node_ptr, uint16_t depth);
#ifdef H5B2_DEBUG
@@ -571,6 +571,9 @@ H5B2__redistribute2(H5B2_hdr_t *hdr, hid_t dxpl_id, uint16_t depth,
uint16_t new_left_nrec = (uint16_t)(*left_nrec + *right_nrec) / 2; /* New number of records for left child */
uint16_t move_nrec = (uint16_t)(*left_nrec - new_left_nrec); /* Number of records to move from left node to right */
+ /* Sanity check */
+ HDassert(*left_nrec > *right_nrec);
+
/* Slide records in right node up */
HDmemmove(H5B2_NAT_NREC(right_native, hdr, move_nrec),
H5B2_NAT_NREC(right_native, hdr, 0),
diff --git a/src/H5B2private.h b/src/H5B2private.h
index 45b6737..9e3c2d7 100644
--- a/src/H5B2private.h
+++ b/src/H5B2private.h
@@ -93,7 +93,9 @@ struct H5B2_class_t {
herr_t (*encode)(uint8_t *raw, const void *record, void *ctx); /* Encode record from native form to disk storage form */
herr_t (*decode)(const uint8_t *raw, void *record, void *ctx); /* Decode record from disk storage form to native form */
herr_t (*debug)(FILE *stream, int indent, int fwidth, /* Print a record for debugging */
- const void *record);
+ const void *record, const void *ctx);
+ void *(*crt_dbg_ctx)(H5F_t *f, hid_t dxpl_id, haddr_t obj_addr); /* Create debugging context */
+ herr_t (*dst_dbg_ctx)(void *dbg_ctx); /* Destroy debugging context */
};
/* v2 B-tree creation parameters */
diff --git a/src/H5B2test.c b/src/H5B2test.c
index 8ed364e..87fddf7 100644
--- a/src/H5B2test.c
+++ b/src/H5B2test.c
@@ -67,7 +67,9 @@ static herr_t H5B2__test_store(void *nrecord, const void *udata);
static herr_t H5B2__test_compare(const void *rec1, const void *rec2);
static herr_t H5B2__test_encode(uint8_t *raw, const void *nrecord, void *ctx);
static herr_t H5B2__test_decode(const uint8_t *raw, void *nrecord, void *ctx);
-static herr_t H5B2__test_debug(FILE *stream, int indent, int fwidth, const void *record);
+static herr_t H5B2__test_debug(FILE *stream, int indent, int fwidth,
+ const void *record, const void *_udata);
+static void *H5B2__test_crt_dbg_context(H5F_t *f, hid_t dxpl_id, haddr_t addr);
/*********************/
@@ -84,7 +86,9 @@ const H5B2_class_t H5B2_TEST[1]={{ /* B-tree class information */
H5B2__test_compare, /* Record comparison callback */
H5B2__test_encode, /* Record encoding callback */
H5B2__test_decode, /* Record decoding callback */
- H5B2__test_debug /* Record debugging callback */
+ H5B2__test_debug, /* Record debugging callback */
+ H5B2__test_crt_dbg_context, /* Create debugging context */
+ H5B2__test_dst_context /* Destroy debugging context */
}};
@@ -291,7 +295,8 @@ H5B2__test_decode(const uint8_t *raw, void *nrecord, void *_ctx)
*-------------------------------------------------------------------------
*/
static herr_t
-H5B2__test_debug(FILE *stream, int indent, int fwidth, const void *record)
+H5B2__test_debug(FILE *stream, int indent, int fwidth, const void *record,
+ const void H5_ATTR_UNUSED *_udata)
{
FUNC_ENTER_STATIC_NOERR
@@ -305,6 +310,45 @@ H5B2__test_debug(FILE *stream, int indent, int fwidth, const void *record)
/*-------------------------------------------------------------------------
+ * Function: H5B2__test_crt_dbg_context
+ *
+ * Purpose: Create context for debugging callback
+ *
+ * Return: Success: non-NULL
+ * Failure: NULL
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, December 1, 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+static void *
+H5B2__test_crt_dbg_context(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t H5_ATTR_UNUSED addr)
+{
+ H5B2_test_ctx_t *ctx; /* Callback context structure */
+ void *ret_value = NULL; /* Return value */
+
+ FUNC_ENTER_STATIC
+
+ /* Sanity check */
+ HDassert(f);
+
+ /* Allocate callback context */
+ if(NULL == (ctx = H5FL_MALLOC(H5B2_test_ctx_t)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "can't allocate callback context")
+
+ /* Determine the size of addresses & lengths in the file */
+ ctx->sizeof_size = H5F_SIZEOF_SIZE(f);
+
+ /* Set return value */
+ ret_value = ctx;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5B2__test_crt_dbg_context() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5B2_get_root_addr_test
*
* Purpose: Retrieve the root node's address
diff --git a/src/H5Cpkg.h b/src/H5Cpkg.h
index bf2e5a3..33d4abc 100644
--- a/src/H5Cpkg.h
+++ b/src/H5Cpkg.h
@@ -601,7 +601,7 @@ if ( ( (entry_ptr) == NULL ) || \
#define H5C__UPDATE_STATS_FOR_FLUSH(cache_ptr, entry_ptr) \
{ \
(((cache_ptr)->flushes)[(entry_ptr)->type->id])++; \
- if ( (entry_ptr)->is_pinned ) \
+ if((entry_ptr)->is_pinned) \
(((cache_ptr)->pinned_flushes)[(entry_ptr)->type->id])++; \
((entry_ptr)->flushes)++; \
}
diff --git a/src/H5Cprivate.h b/src/H5Cprivate.h
index a6ff106..b7b1d5b 100644
--- a/src/H5Cprivate.h
+++ b/src/H5Cprivate.h
@@ -149,7 +149,7 @@
#define H5C__MAX_AR_EPOCH_LENGTH 1000000
/* #defines of flags used in the flags parameters in some of the
- * cache calls. Note that not all flags are applicable
+ * following function calls. Note that not all flags are applicable
* to all function calls. Flags that don't apply to a particular
* function are ignored in that function.
*
@@ -1980,8 +1980,7 @@ H5_DLL void * H5C_protect(H5F_t *f, hid_t dxpl_id, const H5C_class_t *type,
haddr_t addr, void *udata, unsigned flags);
H5_DLL herr_t H5C_reset_cache_hit_rate_stats(H5C_t *cache_ptr);
H5_DLL herr_t H5C_resize_entry(void *thing, size_t new_size);
-H5_DLL herr_t H5C_set_cache_auto_resize_config(H5C_t *cache_ptr,
- H5C_auto_size_ctl_t *config_ptr);
+H5_DLL herr_t H5C_set_cache_auto_resize_config(H5C_t *cache_ptr, H5C_auto_size_ctl_t *config_ptr);
H5_DLL herr_t H5C_set_evictions_enabled(H5C_t *cache_ptr, hbool_t evictions_enabled);
H5_DLL herr_t H5C_set_prefix(H5C_t *cache_ptr, char *prefix);
H5_DLL herr_t H5C_set_trace_file_ptr(H5C_t *cache_ptr, FILE *trace_file_ptr);
diff --git a/src/H5D.c b/src/H5D.c
index 483171b..3bb20fb 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -336,10 +336,6 @@ H5Dclose(hid_t dset_id)
/*
* Decrement the counter on the dataset. It will be freed if the count
* reaches zero.
- *
- * Pass in TRUE for the 3rd parameter to tell the function to remove
- * dataset's ID even though the freeing function might fail. Please
- * see the comments in H5I_dec_ref for details. (SLU - 2010/9/7)
*/
if(H5I_dec_app_ref_always_close(dset_id) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "can't decrement count on dataset ID")
diff --git a/src/H5Dbtree.c b/src/H5Dbtree.c
index 762c252..30c3a28 100644
--- a/src/H5Dbtree.c
+++ b/src/H5Dbtree.c
@@ -153,21 +153,21 @@ static herr_t H5D__btree_idx_dest(const H5D_chk_idx_info_t *idx_info);
/* v1 B-tree indexed chunk I/O ops */
const H5D_chunk_ops_t H5D_COPS_BTREE[1] = {{
- H5D__btree_idx_init,
- H5D__btree_idx_create,
- H5D__btree_idx_is_space_alloc,
- H5D__btree_idx_insert,
- H5D__btree_idx_get_addr,
- NULL,
- H5D__btree_idx_iterate,
- H5D__btree_idx_remove,
- H5D__btree_idx_delete,
- H5D__btree_idx_copy_setup,
- H5D__btree_idx_copy_shutdown,
- H5D__btree_idx_size,
- H5D__btree_idx_reset,
- H5D__btree_idx_dump,
- H5D__btree_idx_dest
+ H5D__btree_idx_init, /* insert */
+ H5D__btree_idx_create, /* create */
+ H5D__btree_idx_is_space_alloc, /* is_space_alloc */
+ H5D__btree_idx_insert, /* insert */
+ H5D__btree_idx_get_addr, /* get_addr */
+ NULL, /* resize */
+ H5D__btree_idx_iterate, /* iterate */
+ H5D__btree_idx_remove, /* remove */
+ H5D__btree_idx_delete, /* delete */
+ H5D__btree_idx_copy_setup, /* copy_setup */
+ H5D__btree_idx_copy_shutdown, /* copy_shutdown */
+ H5D__btree_idx_size, /* size */
+ H5D__btree_idx_reset, /* reset */
+ H5D__btree_idx_dump, /* dump */
+ H5D__btree_idx_dest /* destroy */
}};
@@ -649,7 +649,7 @@ H5D__btree_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key /*in,out
/* Remove raw data chunk from file */
H5_CHECK_OVERFLOW(lt_key->nbytes, uint32_t, hsize_t);
if(H5MF_xfree(f, H5FD_MEM_DRAW, dxpl_id, addr, (hsize_t)lt_key->nbytes) < 0)
- HGOTO_ERROR(H5E_STORAGE, H5E_CANTFREE, H5B_INS_ERROR, "unable to free chunk")
+ HGOTO_ERROR(H5E_STORAGE, H5E_CANTFREE, H5B_INS_ERROR, "unable to free chunk")
/* Mark keys as unchanged */
*lt_key_changed = FALSE;
@@ -969,17 +969,12 @@ done:
static hbool_t
H5D__btree_idx_is_space_alloc(const H5O_storage_chunk_t *storage)
{
- hbool_t ret_value = FALSE; /* Return value */
-
FUNC_ENTER_STATIC_NOERR
/* Check args */
HDassert(storage);
- /* Set return value */
- ret_value = (hbool_t)H5F_addr_defined(storage->idx_addr);
-
- FUNC_LEAVE_NOAPI(ret_value)
+ FUNC_LEAVE_NOAPI((hbool_t)H5F_addr_defined(storage->idx_addr))
} /* end H5D__btree_idx_is_space_alloc() */
@@ -1353,9 +1348,8 @@ done:
static herr_t
H5D__btree_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *index_size)
{
- H5D_chunk_common_ud_t udata; /* User-data for loading B-tree nodes */
+ H5D_chunk_common_ud_t udata; /* User-data for loading B-tree nodes */
H5B_info_t bt_info; /* B-tree info */
- hbool_t shared_init = FALSE; /* Whether shared B-tree info is initialized */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
@@ -1368,11 +1362,6 @@ H5D__btree_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *index_size)
HDassert(idx_info->storage);
HDassert(index_size);
- /* Initialize the shared info for the B-tree traversal */
- if(H5D__btree_shared_create(idx_info->f, idx_info->storage, idx_info->layout) < 0)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create wrapper for shared B-tree info")
- shared_init = TRUE;
-
/* Initialize B-tree node user-data */
HDmemset(&udata, 0, sizeof udata);
udata.layout = idx_info->layout;
@@ -1386,13 +1375,6 @@ H5D__btree_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *index_size)
*index_size = bt_info.size;
done:
- if(shared_init) {
- if(NULL == idx_info->storage->u.btree.shared)
- HDONE_ERROR(H5E_IO, H5E_CANTFREE, FAIL, "ref-counted page nil")
- if(H5UC_DEC(idx_info->storage->u.btree.shared) < 0)
- HDONE_ERROR(H5E_IO, H5E_CANTFREE, FAIL, "unable to decrement ref-counted page")
- } /* end if */
-
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__btree_idx_size() */
diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c
index 4066733..e935f93 100644
--- a/src/H5Dchunk.c
+++ b/src/H5Dchunk.c
@@ -61,7 +61,7 @@
#include "H5Iprivate.h" /* IDs */
#include "H5MMprivate.h" /* Memory management */
#include "H5MFprivate.h" /* File memory management */
-#include "H5VMprivate.h" /* Vector and array functions */
+#include "H5VMprivate.h" /* Vector and array functions */
/****************/
@@ -2227,7 +2227,7 @@ H5D__chunk_dest(H5D_t *dset, hid_t dxpl_id)
FUNC_ENTER_STATIC_TAG(dxpl_id, dset->oloc.addr, FAIL)
- /* Sanity check */
+ /* Sanity checks */
HDassert(dset);
/* Fill the DXPL cache values for later use */
@@ -2651,7 +2651,7 @@ H5D__chunk_flush_entry(const H5D_t *dset, hid_t dxpl_id, const H5D_dxpl_cache_t
H5D_chk_idx_info_t idx_info; /* Chunked index info */
H5D_chunk_ud_t udata; /* pass through B-tree */
hbool_t must_alloc = FALSE; /* Whether the chunk must be allocated */
- hbool_t need_insert = FALSE; /* Whether the chunk needs to be inserted into the index */
+ hbool_t need_insert = FALSE; /* Whether the chunk needs to be inserted into the index */
/* Set up user data for index callbacks */
udata.common.layout = &dset->shared->layout.u.chunk;
@@ -4141,9 +4141,9 @@ done:
herr_t
H5D__chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, const hsize_t *old_dim)
{
- hsize_t min_mod_chunk_off[H5O_LAYOUT_NDIMS]; /* Scaled offset of first chunk to modify in each dimension */
- hsize_t max_mod_chunk_off[H5O_LAYOUT_NDIMS]; /* Scaled offset of last chunk to modify in each dimension */
- hssize_t max_fill_chunk_off[H5O_LAYOUT_NDIMS]; /* Scaled offset of last chunk that might be filled in each dimension */
+ hsize_t min_mod_chunk_sc[H5O_LAYOUT_NDIMS]; /* Scaled offset of first chunk to modify in each dimension */
+ hsize_t max_mod_chunk_sc[H5O_LAYOUT_NDIMS]; /* Scaled offset of last chunk to modify in each dimension */
+ hssize_t max_fill_chunk_sc[H5O_LAYOUT_NDIMS]; /* Scaled offset of last chunk that might be filled in each dimension */
hbool_t fill_dim[H5O_LAYOUT_NDIMS]; /* Whether the plane of edge chunks in this dimension needs to be filled */
H5D_chk_idx_info_t idx_info; /* Chunked index info */
H5D_io_info_t chk_io_info; /* Chunked I/O info object */
@@ -4247,19 +4247,19 @@ H5D__chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, const hsize_t *old_dim)
/*
* Determine the chunks which need to be filled or removed
*/
- HDmemset(min_mod_chunk_off, 0, sizeof(min_mod_chunk_off));
- HDmemset(max_mod_chunk_off, 0, sizeof(max_mod_chunk_off));
+ HDmemset(min_mod_chunk_sc, 0, sizeof(min_mod_chunk_sc));
+ HDmemset(max_mod_chunk_sc, 0, sizeof(max_mod_chunk_sc));
for(op_dim = 0; op_dim < (unsigned)space_ndims; op_dim++) {
/* Calculate the largest offset of chunks that might need to be
* modified in this dimension */
- max_mod_chunk_off[op_dim] = (old_dim[op_dim] - 1) / chunk_dim[op_dim];
+ max_mod_chunk_sc[op_dim] = (old_dim[op_dim] - 1) / chunk_dim[op_dim];
/* Calculate the largest offset of chunks that might need to be
* filled in this dimension */
if(0 == space_dim[op_dim])
- max_fill_chunk_off[op_dim] = -1;
+ max_fill_chunk_sc[op_dim] = -1;
else
- max_fill_chunk_off[op_dim] = (hssize_t)(((MIN(space_dim[op_dim], old_dim[op_dim]) - 1)
+ max_fill_chunk_sc[op_dim] = (hssize_t)(((MIN(space_dim[op_dim], old_dim[op_dim]) - 1)
/ chunk_dim[op_dim]));
if(shrunk_dim[op_dim]) {
@@ -4267,10 +4267,10 @@ H5D__chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, const hsize_t *old_dim)
* modified in this dimension. Note that this array contains
* garbage for all dimensions which are not shrunk. These locations
* must not be read from! */
- min_mod_chunk_off[op_dim] = space_dim[op_dim] / chunk_dim[op_dim];
+ min_mod_chunk_sc[op_dim] = space_dim[op_dim] / chunk_dim[op_dim];
/* Determine if we need to fill chunks in this dimension */
- if((hssize_t)min_mod_chunk_off[op_dim] == max_fill_chunk_off[op_dim])
+ if((hssize_t)min_mod_chunk_sc[op_dim] == max_fill_chunk_sc[op_dim])
fill_dim[op_dim] = TRUE;
else
fill_dim[op_dim] = FALSE;
@@ -4289,22 +4289,22 @@ H5D__chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, const hsize_t *old_dim)
if(!shrunk_dim[op_dim])
continue;
else {
- HDassert(max_mod_chunk_off[op_dim] >= min_mod_chunk_off[op_dim]);
+ HDassert(max_mod_chunk_sc[op_dim] >= min_mod_chunk_sc[op_dim]);
/* Reset the chunk offset indices */
HDmemset(scaled, 0, (space_ndims * sizeof(scaled[0])));
- scaled[op_dim] = min_mod_chunk_off[op_dim];
+ scaled[op_dim] = min_mod_chunk_sc[op_dim];
/* Initialize "dims_outside_fill" array */
ndims_outside_fill = 0;
for(u = 0; u < space_ndims; u++)
- if((hssize_t)scaled[u] > max_fill_chunk_off[u]) {
+ if((hssize_t)scaled[u] > max_fill_chunk_sc[u]) {
dims_outside_fill[u] = TRUE;
ndims_outside_fill++;
} /* end if */
else
dims_outside_fill[u] = FALSE;
- } /* end if */
+ } /* end if */
carry = FALSE;
while(!carry) {
@@ -4312,7 +4312,7 @@ H5D__chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, const hsize_t *old_dim)
if(0 == ndims_outside_fill) {
HDassert(fill_dim[op_dim]);
- HDassert(scaled[op_dim] == min_mod_chunk_off[op_dim]);
+ HDassert(scaled[op_dim] == min_mod_chunk_sc[op_dim]);
/* Fill the unused parts of the chunk */
if(H5D__chunk_prune_fill(&udata) < 0)
@@ -4360,11 +4360,11 @@ H5D__chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, const hsize_t *old_dim)
carry = TRUE;
for(i = (int)(space_ndims - 1); i >= 0; --i) {
scaled[i]++;
- if(scaled[i] > max_mod_chunk_off[i]) {
+ if(scaled[i] > max_mod_chunk_sc[i]) {
/* Left maximum dimensions, "wrap around" and check if this
* dimension is no longer outside the fill dimension */
if((unsigned)i == op_dim) {
- scaled[i] = min_mod_chunk_off[i];
+ scaled[i] = min_mod_chunk_sc[i];
if(dims_outside_fill[i] && fill_dim[i]) {
dims_outside_fill[i] = FALSE;
ndims_outside_fill--;
@@ -4372,7 +4372,7 @@ H5D__chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, const hsize_t *old_dim)
} /* end if */
else {
scaled[i] = 0;
- if(dims_outside_fill[i] && max_fill_chunk_off[i] >= 0) {
+ if(dims_outside_fill[i] && max_fill_chunk_sc[i] >= 0) {
dims_outside_fill[i] = FALSE;
ndims_outside_fill--;
} /* end if */
@@ -4380,7 +4380,7 @@ H5D__chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, const hsize_t *old_dim)
} /* end if */
else {
/* Check if we just went outside the fill dimension */
- if(!dims_outside_fill[i] && (hssize_t)scaled[i] > max_fill_chunk_off[i]) {
+ if(!dims_outside_fill[i] && (hssize_t)scaled[i] > max_fill_chunk_sc[i]) {
dims_outside_fill[i] = TRUE;
ndims_outside_fill++;
} /* end if */
@@ -4392,13 +4392,13 @@ H5D__chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, const hsize_t *old_dim)
} /* end for */
} /* end while(!carry) */
- /* Adjust max_mod_chunk_off so we don't modify the same chunk twice.
+ /* Adjust max_mod_chunk_sc so we don't modify the same chunk twice.
* Also check if this dimension started from 0 (and hence removed all
* of the chunks). */
- if(min_mod_chunk_off[op_dim] == 0)
+ if(min_mod_chunk_sc[op_dim] == 0)
break;
else
- max_mod_chunk_off[op_dim] = min_mod_chunk_off[op_dim] - 1;
+ max_mod_chunk_sc[op_dim] = min_mod_chunk_sc[op_dim] - 1;
} /* end for(op_dim=0...) */
/* Reset any cached chunk info for this dataset */
@@ -4698,7 +4698,7 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata)
const H5O_pline_t *pline = udata->pline; /* I/O pipeline for applying filters */
/* needed for commpressed variable length data */
- hbool_t has_filters = FALSE; /* Whether chunk has filters */
+ hbool_t must_filter = FALSE; /* Whether chunk must be filtered during copy */
size_t nbytes; /* Size of chunk in file (in bytes) */
H5Z_cb_t cb_struct; /* Filter failure callback struct */
@@ -4720,8 +4720,8 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata)
} /* end if */
/* Check for filtered chunks */
- if(pline && pline->nused) {
- has_filters = TRUE;
+ if((is_vlen || fix_ref) && pline && pline->nused) {
+ must_filter = TRUE;
cb_struct.func = NULL; /* no callback function when failed */
} /* end if */
@@ -4752,7 +4752,7 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata)
HGOTO_ERROR(H5E_IO, H5E_READERROR, H5_ITER_ERROR, "unable to read raw data chunk")
/* Need to uncompress variable-length & reference data elements */
- if(has_filters && (is_vlen || fix_ref)) {
+ if(must_filter) {
unsigned filter_mask = chunk_rec->filter_mask;
if(H5Z_pipeline(pline, H5Z_FLAG_REVERSE, &filter_mask, H5Z_NO_EDC, cb_struct, &nbytes, &buf_size, &buf) < 0)
@@ -4816,7 +4816,7 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata)
udata_dst.filter_mask = chunk_rec->filter_mask;
/* Need to compress variable-length & reference data elements before writing to file */
- if(has_filters && (is_vlen || fix_ref)) {
+ if(must_filter) {
if(H5Z_pipeline(pline, 0, &(udata_dst.filter_mask), H5Z_NO_EDC, cb_struct, &nbytes, &buf_size, &buf) < 0)
HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, H5_ITER_ERROR, "output pipeline failed")
#if H5_SIZEOF_SIZE_T > 4
@@ -5125,32 +5125,67 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5D__chunk_bh_info(H5F_t *f, hid_t dxpl_id, H5O_layout_t *layout,
- const H5O_pline_t *pline, hsize_t *index_size)
+H5D__chunk_bh_info(const H5O_loc_t *loc, hid_t dxpl_id, H5O_t *oh, H5O_layout_t *layout,
+ hsize_t *index_size)
{
H5D_chk_idx_info_t idx_info; /* Chunked index info */
+ H5S_t *space = NULL; /* Dataset's dataspace */
+ H5O_pline_t pline; /* I/O pipeline message */
+ htri_t exists; /* Flag if header message of interest exists */
+ hbool_t idx_info_init = FALSE; /* Whether the chunk index info has been initialized */
+ hbool_t pline_read = FALSE; /* Whether the I/O pipeline message was read */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
/* Check args */
- HDassert(f);
+ HDassert(loc);
+ HDassert(loc->file);
+ HDassert(H5F_addr_defined(loc->addr));
HDassert(layout);
- HDassert(pline);
HDassert(index_size);
+ /* Check for I/O pipeline message */
+ if((exists = H5O_msg_exists_oh(oh, H5O_PLINE_ID)) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to read object header")
+ else if(exists) {
+ if(NULL == H5O_msg_read_oh(loc->file, dxpl_id, oh, H5O_PLINE_ID, &pline))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't find I/O pipeline message")
+ pline_read = TRUE;
+ } /* end else if */
+ else
+ HDmemset(&pline, 0, sizeof(pline));
+
/* Compose chunked index info struct */
- idx_info.f = f;
+ idx_info.f = loc->file;
idx_info.dxpl_id = dxpl_id;
- idx_info.pline = pline;
+ idx_info.pline = &pline;
idx_info.layout = &layout->u.chunk;
idx_info.storage = &layout->storage.u.chunk;
+ /* Get the dataspace for the dataset */
+ if(NULL == (space = H5S_read(loc, dxpl_id)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to load dataspace info from dataset header")
+
+ /* Allocate any indexing structures */
+ if(layout->storage.u.chunk.ops->init && (layout->storage.u.chunk.ops->init)(&idx_info, space, loc->addr) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize indexing information")
+ idx_info_init = TRUE;
+
/* Get size of index structure */
- if((layout->storage.u.chunk.ops->size)(&idx_info, index_size) < 0)
+ if(layout->storage.u.chunk.ops->size && (layout->storage.u.chunk.ops->size)(&idx_info, index_size) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve chunk index info")
done:
+ /* Free resources, if they've been initialized */
+ if(idx_info_init && layout->storage.u.chunk.ops->dest &&
+ (layout->storage.u.chunk.ops->dest)(&idx_info) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to release chunk index info")
+ if(pline_read && H5O_msg_reset(H5O_PLINE_ID, &pline) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset I/O pipeline message")
+ if(space && H5S_close(space) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace")
+
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__chunk_bh_info() */
diff --git a/src/H5Dint.c b/src/H5Dint.c
index b0e31a6..b9899c8 100644
--- a/src/H5Dint.c
+++ b/src/H5Dint.c
@@ -1548,7 +1548,7 @@ herr_t
H5D_close(H5D_t *dataset)
{
hbool_t free_failed = FALSE;
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -2566,7 +2566,6 @@ done:
herr_t
H5D__flush_real(H5D_t *dataset, hid_t dxpl_id)
{
- H5O_t *oh = NULL; /* Pointer to dataset's object header */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE_TAG(dxpl_id, dataset->oloc.addr, FAIL)
@@ -2577,38 +2576,6 @@ H5D__flush_real(H5D_t *dataset, hid_t dxpl_id)
/* Avoid flushing the dataset (again) if it's closing */
if(!dataset->shared->closing) {
- /* Check for metadata changes that will require updating the object's modification time */
- if(dataset->shared->layout_dirty || dataset->shared->space_dirty) {
- unsigned update_flags = H5O_UPDATE_TIME; /* Modification time flag */
-
- /* Pin the object header */
- if(NULL == (oh = H5O_pin(&dataset->oloc, dxpl_id)))
- HGOTO_ERROR(H5E_DATASET, H5E_CANTPIN, FAIL, "unable to pin dataset object header")
-
- /* Update the layout on disk, if it's been changed */
- if(dataset->shared->layout_dirty) {
- if(H5D__layout_oh_write(dataset, dxpl_id, oh, update_flags) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to update layout/pline/efl info")
- dataset->shared->layout_dirty = FALSE;
-
- /* Reset the "update the modification time" flag, so we only do it once */
- update_flags = 0;
- } /* end if */
-
- /* Update the dataspace on disk, if it's been changed */
- if(dataset->shared->space_dirty) {
- if(H5S_write(dataset->oloc.file, dxpl_id, oh, update_flags, dataset->shared->space) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to update file with new dataspace")
- dataset->shared->space_dirty = FALSE;
-
- /* Reset the "update the modification time" flag, so we only do it once */
- update_flags = 0;
- } /* end if */
-
- /* _Somebody_ should have update the modification time! */
- HDassert(update_flags == 0);
- } /* end if */
-
/* Flush cached raw data for each kind of dataset layout */
if(dataset->shared->layout.ops->flush &&
(dataset->shared->layout.ops->flush)(dataset, dxpl_id) < 0)
@@ -2616,11 +2583,6 @@ H5D__flush_real(H5D_t *dataset, hid_t dxpl_id)
} /* end if */
done:
- /* Release pointer to object header */
- if(oh != NULL)
- if(H5O_unpin(oh) < 0)
- HDONE_ERROR(H5E_DATASET, H5E_CANTUNPIN, FAIL, "unable to unpin dataset object header")
-
FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL)
} /* end H5D__flush_real() */
@@ -2641,19 +2603,50 @@ done:
herr_t
H5D__mark(const H5D_t *dataset, hid_t H5_ATTR_UNUSED dxpl_id, unsigned flags)
{
+ H5O_t *oh = NULL; /* Pointer to dataset's object header */
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_PACKAGE_NOERR
+ FUNC_ENTER_PACKAGE
/* Check args */
HDassert(dataset);
HDassert(!(flags & (unsigned)~(H5D_MARK_SPACE | H5D_MARK_LAYOUT)));
/* Mark aspects of the dataset as dirty */
- if(flags & H5D_MARK_SPACE)
- dataset->shared->space_dirty = TRUE;
- if(flags & H5D_MARK_LAYOUT)
- dataset->shared->layout_dirty = TRUE;
+ if(flags) {
+ unsigned update_flags = H5O_UPDATE_TIME; /* Modification time flag */
+
+ /* Pin the object header */
+ if(NULL == (oh = H5O_pin(&dataset->oloc, dxpl_id)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTPIN, FAIL, "unable to pin dataset object header")
+
+ /* Update the layout on disk, if it's been changed */
+ if(flags & H5D_MARK_LAYOUT) {
+ if(H5D__layout_oh_write(dataset, dxpl_id, oh, update_flags) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to update layout/pline/efl info")
+
+ /* Reset the "update the modification time" flag, so we only do it once */
+ update_flags = 0;
+ } /* end if */
+
+ /* Update the dataspace on disk, if it's been changed */
+ if(flags & H5D_MARK_SPACE) {
+ if(H5S_write(dataset->oloc.file, dxpl_id, oh, update_flags, dataset->shared->space) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to update file with new dataspace")
+
+ /* Reset the "update the modification time" flag, so we only do it once */
+ update_flags = 0;
+ } /* end if */
+
+ /* _Somebody_ should have update the modification time! */
+ HDassert(update_flags == 0);
+ } /* end if */
+
+done:
+ /* Release pointer to object header */
+ if(oh != NULL)
+ if(H5O_unpin(oh) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CANTUNPIN, FAIL, "unable to unpin dataset object header")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__mark() */
@@ -2990,7 +2983,7 @@ hid_t
H5D_get_space(H5D_t *dset)
{
H5S_t *space = NULL;
- hid_t ret_value = FAIL;
+ hid_t ret_value = H5I_INVALID_HID;
FUNC_ENTER_NOAPI_NOINIT
diff --git a/src/H5Dlayout.c b/src/H5Dlayout.c
index ae478b2..8676d7c 100644
--- a/src/H5Dlayout.c
+++ b/src/H5Dlayout.c
@@ -153,7 +153,7 @@ H5D__layout_meta_size(const H5F_t *f, const H5O_layout_t *layout, hbool_t includ
/* Size of raw data */
ret_value += 2;
if(include_compact_data)
- ret_value += layout->storage.u.compact.size;/* data for compact dataset */
+ ret_value += layout->storage.u.compact.size; /* data for compact dataset */
break;
case H5D_CONTIGUOUS:
@@ -266,7 +266,7 @@ H5D__layout_oh_create(H5F_t *file, hid_t dxpl_id, H5O_t *oh, H5D_t *dset,
HGOTO_ERROR(H5E_DATASET, H5E_CANTPROTECT, FAIL, "unable to protect EFL file name heap")
/* Insert "empty" name first */
- if((size_t)(-1) == H5HL_insert(file, dxpl_id, heap, (size_t)1, "")) {
+ if(UFAIL == H5HL_insert(file, dxpl_id, heap, (size_t)1, "")) {
H5HL_unprotect(heap);
HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert file name into heap")
} /* end if */
@@ -275,7 +275,7 @@ H5D__layout_oh_create(H5F_t *file, hid_t dxpl_id, H5O_t *oh, H5D_t *dset,
size_t offset; /* Offset of file name in heap */
/* Insert file name into heap */
- if((size_t)(-1) == (offset = H5HL_insert(file, dxpl_id, heap,
+ if(UFAIL == (offset = H5HL_insert(file, dxpl_id, heap,
HDstrlen(efl->slot[u].name) + 1, efl->slot[u].name))) {
H5HL_unprotect(heap);
HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert file name into heap")
diff --git a/src/H5Doh.c b/src/H5Doh.c
index f8a733d..8b70362 100644
--- a/src/H5Doh.c
+++ b/src/H5Doh.c
@@ -53,7 +53,7 @@ static hid_t H5O__dset_open(const H5G_loc_t *obj_loc, hid_t lapl_id,
static void *H5O__dset_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc,
hid_t dxpl_id);
static H5O_loc_t *H5O__dset_get_oloc(hid_t obj_id);
-static herr_t H5O__dset_bh_info(H5F_t *f, hid_t dxpl_id, H5O_t *oh,
+static herr_t H5O__dset_bh_info(const H5O_loc_t *loc, hid_t dxpl_id, H5O_t *oh,
H5_ih_info_t *bh_info);
static herr_t H5O__dset_flush(H5G_loc_t *obj_loc, hid_t dxpl_id);
@@ -359,13 +359,11 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5O__dset_bh_info(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5_ih_info_t *bh_info)
+H5O__dset_bh_info(const H5O_loc_t *loc, hid_t dxpl_id, H5O_t *oh, H5_ih_info_t *bh_info)
{
H5O_layout_t layout; /* Data storage layout message */
- H5O_pline_t pline; /* I/O pipeline message */
H5O_efl_t efl; /* External File List message */
hbool_t layout_read = FALSE; /* Whether the layout message was read */
- hbool_t pline_read = FALSE; /* Whether the I/O pipeline message was read */
hbool_t efl_read = FALSE; /* Whether the external file list message was read */
htri_t exists; /* Flag if header message of interest exists */
herr_t ret_value = SUCCEED; /* Return value */
@@ -373,29 +371,21 @@ H5O__dset_bh_info(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5_ih_info_t *bh_info)
FUNC_ENTER_STATIC
/* Sanity check */
- HDassert(f);
+ HDassert(loc);
+ HDassert(loc->file);
+ HDassert(H5F_addr_defined(loc->addr));
HDassert(oh);
HDassert(bh_info);
/* Get the layout message from the object header */
- if(NULL == H5O_msg_read_oh(f, dxpl_id, oh, H5O_LAYOUT_ID, &layout))
+ if(NULL == H5O_msg_read_oh(loc->file, dxpl_id, oh, H5O_LAYOUT_ID, &layout))
HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't find layout message")
layout_read = TRUE;
/* Check for chunked dataset storage */
if(layout.type == H5D_CHUNKED && H5D__chunk_is_space_alloc(&layout.storage)) {
- /* Check for I/O pipeline message */
- if((exists = H5O_msg_exists_oh(oh, H5O_PLINE_ID)) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to read object header")
- else if(exists) {
- if(NULL == H5O_msg_read_oh(f, dxpl_id, oh, H5O_PLINE_ID, &pline))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't find I/O pipeline message")
- pline_read = TRUE;
- } /* end else if */
- else
- HDmemset(&pline, 0, sizeof(pline));
-
- if(H5D__chunk_bh_info(f, dxpl_id, &layout, &pline, &(bh_info->index_size)) < 0)
+ /* Get size of chunk index */
+ if(H5D__chunk_bh_info(loc, dxpl_id, oh, &layout, &(bh_info->index_size)) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't determine chunked dataset btree info")
} /* end if */
else if(layout.type == H5D_VIRTUAL
@@ -403,7 +393,7 @@ H5O__dset_bh_info(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5_ih_info_t *bh_info)
size_t virtual_heap_size;
/* Get size of global heap object for virtual dataset */
- if(H5HG_get_obj_size(f, dxpl_id, &(layout.storage.u.virt.serial_list_hobjid), &virtual_heap_size) < 0)
+ if(H5HG_get_obj_size(loc->file, dxpl_id, &(layout.storage.u.virt.serial_list_hobjid), &virtual_heap_size) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get global heap size for virtual dataset mapping")
/* Return heap size */
@@ -419,12 +409,12 @@ H5O__dset_bh_info(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5_ih_info_t *bh_info)
HDmemset(&efl, 0, sizeof(efl));
/* Get External File List message from the object header */
- if(NULL == H5O_msg_read_oh(f, dxpl_id, oh, H5O_EFL_ID, &efl))
+ if(NULL == H5O_msg_read_oh(loc->file, dxpl_id, oh, H5O_EFL_ID, &efl))
HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't find EFL message")
efl_read = TRUE;
/* Get size of local heap for EFL message's file list */
- if(H5D__efl_bh_info(f, dxpl_id, &efl, &(bh_info->heap_size)) < 0)
+ if(H5D__efl_bh_info(loc->file, dxpl_id, &efl, &(bh_info->heap_size)) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't determine EFL heap info")
} /* end if */
@@ -432,8 +422,6 @@ done:
/* Free messages, if they've been read in */
if(layout_read && H5O_msg_reset(H5O_LAYOUT_ID, &layout) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset data storage layout message")
- if(pline_read && H5O_msg_reset(H5O_PLINE_ID, &pline) < 0)
- HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset I/O pipeline message")
if(efl_read && H5O_msg_reset(H5O_EFL_ID, &efl) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset external file list message")
@@ -458,8 +446,8 @@ static herr_t
H5O__dset_flush(H5G_loc_t *obj_loc, hid_t dxpl_id)
{
H5D_t *dset = NULL; /* Dataset opened */
- H5O_type_t obj_type; /* Type of object at location */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5O_type_t obj_type; /* Type of object at location */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
@@ -469,7 +457,6 @@ H5O__dset_flush(H5G_loc_t *obj_loc, hid_t dxpl_id)
/* Check that the object found is the correct type */
if(H5O_obj_type(obj_loc->oloc, &obj_type, dxpl_id) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get object type")
-
if(obj_type != H5O_TYPE_DATASET)
HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a dataset")
diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h
index 552c61b..f391e8c 100644
--- a/src/H5Dpkg.h
+++ b/src/H5Dpkg.h
@@ -414,8 +414,6 @@ typedef struct H5D_shared_t {
hid_t type_id; /* ID for dataset's datatype */
H5T_t *type; /* Datatype for this dataset */
H5S_t *space; /* Dataspace of this dataset */
- hbool_t space_dirty; /* Whether the dataspace info needs to be flushed to the file */
- hbool_t layout_dirty; /* Whether the layout info needs to be flushed to the file */
hid_t dcpl_id; /* Dataset creation property id */
H5D_dcpl_cache_t dcpl_cache; /* Cached DCPL values */
H5O_layout_t layout; /* Data layout */
@@ -636,8 +634,8 @@ H5_DLL herr_t H5D__chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src,
H5O_layout_chunk_t *layout_src, H5F_t *f_dst, H5O_storage_chunk_t *storage_dst,
const H5S_extent_t *ds_extent_src, const H5T_t *dt_src,
const H5O_pline_t *pline_src, H5O_copy_t *cpy_info, hid_t dxpl_id);
-H5_DLL herr_t H5D__chunk_bh_info(H5F_t *f, hid_t dxpl_id, H5O_layout_t *layout,
- const H5O_pline_t *pline, hsize_t *btree_size);
+H5_DLL herr_t H5D__chunk_bh_info(const H5O_loc_t *loc, hid_t dxpl_id, H5O_t *oh,
+ H5O_layout_t *layout, hsize_t *btree_size);
H5_DLL herr_t H5D__chunk_dump_index(H5D_t *dset, hid_t dxpl_id, FILE *stream);
H5_DLL herr_t H5D__chunk_delete(H5F_t *f, hid_t dxpl_id, H5O_t *oh,
H5O_storage_t *store);
diff --git a/src/H5Dvirtual.c b/src/H5Dvirtual.c
index 316fcf7..7c5186d 100644
--- a/src/H5Dvirtual.c
+++ b/src/H5Dvirtual.c
@@ -132,6 +132,7 @@ const H5D_layout_ops_t H5D_LOPS_VIRTUAL[1] = {{
NULL,
NULL,
H5D__virtual_flush,
+ NULL,
NULL
}};
@@ -653,11 +654,10 @@ H5D__virtual_copy(H5F_t H5_ATTR_UNUSED *f_dst, H5O_layout_t *layout_dst,
{
herr_t ret_value = SUCCEED;
+#ifdef NOT_YET
FUNC_ENTER_PACKAGE
-
- /* Copy message in memory */
- if(H5D__virtual_copy_layout(layout_dst) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy virtual layout")
+#endif /* NOT_YET */
+ FUNC_ENTER_PACKAGE_NOERR
#ifdef NOT_YET
/* Check for copy to the same file */
@@ -675,7 +675,9 @@ H5D__virtual_copy(H5F_t H5_ATTR_UNUSED *f_dst, H5O_layout_t *layout_dst,
layout_dst->storage.u.virt.serial_list_hobjid.idx = (size_t)0;
} /* end block/else */
+#ifdef NOT_YET
done:
+#endif /* NOT_YET */
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__virtual_copy() */
@@ -1324,7 +1326,7 @@ H5D__virtual_set_extent_unlim(const H5D_t *dset, hid_t dxpl_id)
new_dims[i] = HSIZE_UNDEF;
/* Iterate over mappings */
- for(i = 0; i < storage->list_nalloc; i++)
+ for(i = 0; i < storage->list_nused; i++)
/* Check for unlimited dimension */
if(storage->list[i].unlim_dim_virtual >= 0) {
/* Check for "printf" source dataset resolution */
@@ -1566,7 +1568,7 @@ H5D__virtual_set_extent_unlim(const H5D_t *dset, hid_t dxpl_id)
if(changed || (!storage->init && (storage->view == H5D_VDS_FIRST_MISSING))) {
/* Iterate over mappings again to update source selections and virtual
* mapping extents */
- for(i = 0; i < storage->list_nalloc; i++) {
+ for(i = 0; i < storage->list_nused; i++) {
/* If there is an unlimited dimension, we are setting extent by the
* minimum of mappings, and the virtual extent in the unlimited
* dimension has changed since the last time the VDS extent/mapping
@@ -1746,7 +1748,7 @@ H5D__virtual_init_all(const H5D_t *dset, hid_t dxpl_id)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get VDS dimensions")
/* Iterate over mappings */
- for(i = 0; i < storage->list_nalloc; i++)
+ for(i = 0; i < storage->list_nused; i++)
/* Check for unlimited dimension */
if(storage->list[i].unlim_dim_virtual >= 0) {
/* Check for "printf" source dataset resolution */
@@ -2716,7 +2718,7 @@ H5D__virtual_flush(H5D_t *dset, hid_t dxpl_id)
if(storage->list[i].source_dset.dset)
/* Flush source dataset */
if(H5D__flush_real(storage->list[i].source_dset.dset, dxpl_id) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "unable to write to source dataset")
+ HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "unable to flush source dataset")
done:
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5FA.c b/src/H5FA.c
index b0d13ec..1be3f2e 100644
--- a/src/H5FA.c
+++ b/src/H5FA.c
@@ -15,12 +15,12 @@
/*-------------------------------------------------------------------------
*
- * Created: H5FA.c
- * April 2009
- * Vailin Choi <vchoi@hdfgroup.org>
+ * Created: H5FA.c
+ * April 2009
+ * Vailin Choi <vchoi@hdfgroup.org>
*
- * Purpose: Implements a Fixed Array for storing elements
- * of datasets with fixed dimensions
+ * Purpose: Implements a Fixed Array for storing elements
+ * of datasets with fixed dimensions.
*
*-------------------------------------------------------------------------
*/
@@ -96,19 +96,19 @@ const H5FA_class_t *const H5FA_client_class_g[] = {
H5FL_DEFINE_STATIC(H5FA_t);
/* Declare a PQ free list to manage the element */
-H5FL_BLK_DEFINE(native_elmt);
+H5FL_BLK_DEFINE(fa_native_elmt);
/*-------------------------------------------------------------------------
- * Function: H5FA_create
+ * Function: H5FA_create
*
- * Purpose: Creates a new fixed array (header) in the file.
+ * Purpose: Creates a new fixed array (header) in the file.
*
- * Return: Pointer to fixed array wrapper on success
+ * Return: Pointer to fixed array wrapper on success
* NULL on failure
*
- * Programmer: Vailin Choi
+ * Programmer: Vailin Choi
* Thursday, April 30, 2009
*
*-------------------------------------------------------------------------
@@ -137,24 +137,24 @@ HDfprintf(stderr, "%s: Called\n", FUNC);
/* Create fixed array header */
if(HADDR_UNDEF == (fa_addr = H5FA__hdr_create(f, dxpl_id, cparam, ctx_udata)))
- H5E_THROW(H5E_CANTINIT, "can't create fixed array header")
+ H5E_THROW(H5E_CANTINIT, "can't create fixed array header")
/* Allocate fixed array wrapper */
if(NULL == (fa = H5FL_MALLOC(H5FA_t)))
- H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array info")
+ H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array info")
/* Lock the array header into memory */
if(NULL == (hdr = H5FA__hdr_protect(f, dxpl_id, fa_addr, ctx_udata, H5AC__NO_FLAGS_SET)))
- H5E_THROW(H5E_CANTPROTECT, "unable to load fixed array header")
+ H5E_THROW(H5E_CANTPROTECT, "unable to load fixed array header")
/* Point fixed array wrapper at header and bump it's ref count */
fa->hdr = hdr;
if(H5FA__hdr_incr(fa->hdr) < 0)
- H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header")
+ H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header")
/* Increment # of files using this array header */
if(H5FA__hdr_fuse_incr(fa->hdr) < 0)
- H5E_THROW(H5E_CANTINC, "can't increment file reference count on shared array header")
+ H5E_THROW(H5E_CANTINC, "can't increment file reference count on shared array header")
/* Set file pointer for this array open context */
fa->f = f;
@@ -165,7 +165,7 @@ HDfprintf(stderr, "%s: Called\n", FUNC);
CATCH
if(hdr && H5FA__hdr_unprotect(hdr, dxpl_id, H5AC__NO_FLAGS_SET) < 0)
- H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array header")
+ H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array header")
if(!ret_value)
if(fa && H5FA_close(fa, dxpl_id) < 0)
H5E_THROW(H5E_CLOSEERROR, "unable to close fixed array")
@@ -174,14 +174,14 @@ END_FUNC(PRIV) /* end H5FA_create() */
/*-------------------------------------------------------------------------
- * Function: H5FA_open
+ * Function: H5FA_open
*
- * Purpose: Opens an existing fixed array in the file.
+ * Purpose: Opens an existing fixed array in the file.
*
- * Return: Pointer to array wrapper on success
+ * Return: Pointer to array wrapper on success
* NULL on failure
*
- * Programmer: Vailin Choi
+ * Programmer: Vailin Choi
* Thursday, April 30, 2009
*
*-------------------------------------------------------------------------
@@ -242,13 +242,13 @@ END_FUNC(PRIV) /* end H5FA_open() */
/*-------------------------------------------------------------------------
- * Function: H5FA_get_nelmts
+ * Function: H5FA_get_nelmts
*
- * Purpose: Query the current number of elements in array
+ * Purpose: Query the current number of elements in array
*
- * Return: SUCCEED/FAIL
+ * Return: SUCCEED/FAIL
*
- * Programmer: Vailin Choi
+ * Programmer: Vailin Choi
* Thursday, April 30, 2009
*
*-------------------------------------------------------------------------
@@ -276,13 +276,13 @@ END_FUNC(PRIV) /* end H5FA_get_nelmts() */
/*-------------------------------------------------------------------------
- * Function: H5FA_get_addr
+ * Function: H5FA_get_addr
*
- * Purpose: Query the address of the array
+ * Purpose: Query the address of the array
*
- * Return: SUCCEED/FAIL
+ * Return: SUCCEED/FAIL
*
- * Programmer: Vailin Choi
+ * Programmer: Vailin Choi
* Thursday, April 30, 2009
*
*-------------------------------------------------------------------------
@@ -311,13 +311,13 @@ END_FUNC(PRIV) /* end H5FA_get_addr() */
/*-------------------------------------------------------------------------
- * Function: H5FA_set
+ * Function: H5FA_set
*
- * Purpose: Set an element of a fixed array
+ * Purpose: Set an element of a fixed array
*
- * Return: SUCCEED/FAIL
+ * Return: SUCCEED/FAIL
*
- * Programmer: Vailin Choi
+ * Programmer: Vailin Choi
* Thursday, April 30, 2009
*
*-------------------------------------------------------------------------
@@ -363,13 +363,13 @@ HDfprintf(stderr, "%s: fixed array data block address not defined!\n", FUNC, idx
/* Protect data block */
if(NULL == (dblock = H5FA__dblock_protect(hdr, dxpl_id, hdr->dblk_addr, H5AC__NO_FLAGS_SET)))
- H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block, address = %llu", (unsigned long long)hdr->dblk_addr)
+ H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block, address = %llu", (unsigned long long)hdr->dblk_addr)
/* 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);
- dblock_cache_flags |= H5AC__DIRTIED_FLAG;
+ /* Set element in data block */
+ HDmemcpy(((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 */
size_t page_idx; /* Index of page within data block */
@@ -382,20 +382,20 @@ HDfprintf(stderr, "%s: fixed array data block address not defined!\n", FUNC, idx
elmt_idx = (size_t)(idx % dblock->dblk_page_nelmts);
/* Get the address of the data block page */
- dblk_page_addr = dblock->addr + H5FA_DBLOCK_PREFIX_SIZE(dblock) +
+ dblk_page_addr = dblock->addr + H5FA_DBLOCK_PREFIX_SIZE(dblock) +
((hsize_t)page_idx * dblock->dblk_page_size);
/* Check for using last page, to set the number of elements on the page */
- if((page_idx + 1) == dblock->npages)
- dblk_page_nelmts = dblock->last_page_nelmts;
- else
- dblk_page_nelmts = dblock->dblk_page_nelmts;
+ if((page_idx + 1) == dblock->npages)
+ dblk_page_nelmts = dblock->last_page_nelmts;
+ else
+ dblk_page_nelmts = dblock->dblk_page_nelmts;
/* Check if the page has been created yet */
if(!H5VM_bit_get(dblock->dblk_page_init, page_idx)) {
- /* Create the data block page */
- if(H5FA__dblk_page_create(hdr, dxpl_id, dblk_page_addr, dblk_page_nelmts) < 0)
- H5E_THROW(H5E_CANTCREATE, "unable to create data block page")
+ /* Create the data block page */
+ if(H5FA__dblk_page_create(hdr, dxpl_id, dblk_page_addr, dblk_page_nelmts) < 0)
+ H5E_THROW(H5E_CANTCREATE, "unable to create data block page")
/* Mark data block page as initialized in data block */
H5VM_bit_set(dblock->dblk_page_init, page_idx, TRUE);
@@ -407,8 +407,8 @@ HDfprintf(stderr, "%s: fixed array data block address not defined!\n", FUNC, idx
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);
- dblk_page_cache_flags |= H5AC__DIRTIED_FLAG;
+ HDmemcpy(((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 */
CATCH
@@ -427,13 +427,13 @@ END_FUNC(PRIV) /* end H5FA_set() */
/*-------------------------------------------------------------------------
- * Function: H5FA_get
+ * Function: H5FA_get
*
- * Purpose: Get an element of a fixed array
+ * Purpose: Get an element of a fixed array
*
- * Return: SUCCEED/FAIL
+ * Return: SUCCEED/FAIL
*
- * Programmer: Vailin Choi
+ * Programmer: Vailin Choi
* Thursday, April 30, 2009
*
*-------------------------------------------------------------------------
@@ -529,13 +529,13 @@ END_FUNC(PRIV) /* end H5FA_get() */
/*-------------------------------------------------------------------------
- * Function: H5FA_close
+ * Function: H5FA_close
*
- * Purpose: Close a fixed array
+ * Purpose: Close a fixed array
*
- * Return: SUCCEED/FAIL
+ * Return: SUCCEED/FAIL
*
- * Programmer: Vailin Choi
+ * Programmer: Vailin Choi
* Thursday, April 30, 2009
*
*-------------------------------------------------------------------------
@@ -630,13 +630,13 @@ END_FUNC(PRIV) /* end H5FA_close() */
/*-------------------------------------------------------------------------
- * Function: H5FA_delete
+ * Function: H5FA_delete
*
- * Purpose: Delete a fixed array
+ * Purpose: Delete a fixed array
*
- * Return: SUCCEED/FAIL
+ * Return: SUCCEED/FAIL
*
- * Programmer: Vailin Choi
+ * Programmer: Vailin Choi
* Thursday, April 30, 2009
*
*-------------------------------------------------------------------------
@@ -684,16 +684,16 @@ END_FUNC(PRIV) /* end H5FA_delete() */
/*-------------------------------------------------------------------------
- * Function: H5FA_iterate
+ * Function: H5FA_iterate
*
- * Purpose: Iterate over the elements of a fixed array
+ * Purpose: Iterate over the elements of a fixed array
*
- * Note: This is not very efficient, we should be iterating directly
- * over the fixed array's direct block [pages].
+ * Note: This is not very efficient, we should be iterating directly
+ * over the fixed array's direct block [pages].
*
- * Return: SUCCEED/FAIL
+ * Return: SUCCEED/FAIL
*
- * Programmer: Vailin Choi
+ * Programmer: Vailin Choi
* Thursday, April 30, 2009
*
*-------------------------------------------------------------------------
@@ -703,8 +703,8 @@ herr_t, SUCCEED, FAIL,
H5FA_iterate(H5FA_t *fa, hid_t dxpl_id, H5FA_operator_t op, void *udata))
/* Local variables */
- uint8_t *elmt = NULL;
- hsize_t u;
+ uint8_t *elmt = NULL;
+ hsize_t u;
/*
* Check arguments.
@@ -714,8 +714,8 @@ H5FA_iterate(H5FA_t *fa, hid_t dxpl_id, H5FA_operator_t op, void *udata))
HDassert(udata);
/* Allocate space for a native array element */
- if(NULL == (elmt = H5FL_BLK_MALLOC(native_elmt, fa->hdr->cparam.cls->nat_elmt_size)))
- H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array element")
+ if(NULL == (elmt = H5FL_BLK_MALLOC(fa_native_elmt, fa->hdr->cparam.cls->nat_elmt_size)))
+ H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array element")
/* Iterate over all elements in array */
for(u = 0; u < fa->hdr->stats.nelmts; u++) {
@@ -735,7 +735,7 @@ H5FA_iterate(H5FA_t *fa, hid_t dxpl_id, H5FA_operator_t op, void *udata))
CATCH
if(elmt)
- elmt = H5FL_BLK_FREE(native_elmt, elmt);
+ elmt = H5FL_BLK_FREE(fa_native_elmt, elmt);
END_FUNC(PRIV) /* end H5FA_iterate() */
diff --git a/src/H5FAcache.c b/src/H5FAcache.c
index f3396be..1d4afa4 100644
--- a/src/H5FAcache.c
+++ b/src/H5FAcache.c
@@ -15,11 +15,11 @@
/*-------------------------------------------------------------------------
*
- * Created: H5FAcache.c
- * Jul 2 2009
- * Quincey Koziol <koziol@hdfgroup.org>
+ * Created: H5FAcache.c
+ * Jul 2 2009
+ * Quincey Koziol <koziol@hdfgroup.org>
*
- * Purpose: Implement fixed array metadata cache methods.
+ * Purpose: Implement fixed array metadata cache methods.
*
*-------------------------------------------------------------------------
*/
@@ -205,7 +205,7 @@ END_FUNC(STATIC) /* end H5FA__cache_hdr_get_load_size() */
*
* Purpose: Loads a data structure from the disk.
*
- * Return: Success: Pointer to a new B-tree.
+ * Return: Success: Pointer to a new Fixed array
* Failure: NULL
*
* Programmer: Quincey Koziol
@@ -234,24 +234,24 @@ H5FA__cache_hdr_deserialize(const void *_image, size_t len,
/* Allocate space for the fixed array data structure */
if(NULL == (hdr = H5FA__hdr_alloc(udata->f)))
- H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array shared header")
+ H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array shared header")
/* Set the fixed array header's address */
hdr->addr = udata->addr;
/* Magic number */
if(HDmemcmp(image, H5FA_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC))
- H5E_THROW(H5E_BADVALUE, "wrong fixed array header signature")
+ H5E_THROW(H5E_BADVALUE, "wrong fixed array header signature")
image += H5_SIZEOF_MAGIC;
/* Version */
if(*image++ != H5FA_HDR_VERSION)
- H5E_THROW(H5E_VERSION, "wrong fixed array header version")
+ H5E_THROW(H5E_VERSION, "wrong fixed array header version")
/* Fixed array class */
id = (H5FA_cls_id_t)*image++;
if(id >= H5FA_NUM_CLS_ID)
- H5E_THROW(H5E_BADTYPE, "incorrect fixed array class")
+ H5E_THROW(H5E_BADTYPE, "incorrect fixed array class")
hdr->cparam.cls = H5FA_client_class_g[id];
/* General array creation/configuration information */
@@ -418,7 +418,7 @@ END_FUNC(STATIC) /* end H5FA__cache_hdr_serialize() */
* Purpose: Destroy/release an "in core representation" of a data
* structure
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
* Programmer: Quincey Koziol
* koziol@hdfgroup.org
@@ -529,7 +529,7 @@ H5FA__cache_dblock_deserialize(const void *_image, size_t len,
/* Allocate the fixed array data block */
if(NULL == (dblock = H5FA__dblock_alloc(udata->hdr)))
- H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array data block")
+ H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array data block")
HDassert(((!dblock->npages) && (len == (size_t)H5FA_DBLOCK_SIZE(dblock)))
|| (len == (size_t)H5FA_DBLOCK_PREFIX_SIZE(dblock)));
@@ -539,21 +539,21 @@ H5FA__cache_dblock_deserialize(const void *_image, size_t len,
/* Magic number */
if(HDmemcmp(image, H5FA_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC))
- H5E_THROW(H5E_BADVALUE, "wrong fixed array data block signature")
+ H5E_THROW(H5E_BADVALUE, "wrong fixed array data block signature")
image += H5_SIZEOF_MAGIC;
/* Version */
if(*image++ != H5FA_DBLOCK_VERSION)
- H5E_THROW(H5E_VERSION, "wrong fixed array data block version")
+ H5E_THROW(H5E_VERSION, "wrong fixed array data block version")
/* Fixed array type */
if(*image++ != (uint8_t)udata->hdr->cparam.cls->id)
- H5E_THROW(H5E_BADTYPE, "incorrect fixed array class")
+ H5E_THROW(H5E_BADTYPE, "incorrect fixed array class")
/* Address of header for array that owns this block (just for file integrity checks) */
H5F_addr_decode(udata->hdr->f, &image, &arr_addr);
if(H5F_addr_ne(arr_addr, udata->hdr->addr))
- H5E_THROW(H5E_BADVALUE, "wrong fixed array header address")
+ H5E_THROW(H5E_BADVALUE, "wrong fixed array header address")
/* Page initialization flags */
if(dblock->npages > 0) {
@@ -717,7 +717,7 @@ END_FUNC(STATIC) /* end H5FA__cache_dblock_serialize() */
* Purpose: Destroy/release an "in core representation" of a data
* structure
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
* Programmer: Quincey Koziol
* koziol@hdfgroup.org
@@ -936,7 +936,7 @@ END_FUNC(STATIC) /* end H5FA__cache_dblk_page_image_len() */
*
* Purpose: Flushes a dirty object to disk.
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
* Programmer: Quincey Koziol
* koziol@hdfgroup.org
diff --git a/src/H5FAdbg.c b/src/H5FAdbg.c
index 2f8fda2..2dc51c5 100644
--- a/src/H5FAdbg.c
+++ b/src/H5FAdbg.c
@@ -15,9 +15,9 @@
/*-------------------------------------------------------------------------
*
- * Created: H5FAdbg.c
+ * Created: H5FAdbg.c
*
- * Purpose: Dump debugging information about a fixed array.
+ * Purpose: Dump debugging information about a fixed array.
*
*-------------------------------------------------------------------------
*/
@@ -80,13 +80,13 @@
/*-------------------------------------------------------------------------
- * Function: H5FA__hdr_debug
+ * Function: H5FA__hdr_debug
*
- * Purpose: Prints debugging info about a fixed array header.
+ * Purpose: Prints debugging info about a fixed array header.
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
- * Programmer: Vailin Choi
+ * Programmer: Vailin Choi
* Thursday, April 30, 2009
*
*-------------------------------------------------------------------------
@@ -97,8 +97,8 @@ H5FA__hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent,
int fwidth, const H5FA_class_t *cls, haddr_t obj_addr))
/* Local variables */
- H5FA_hdr_t *hdr = NULL; /* Shared fixed array header */
- void *dbg_ctx = NULL; /* Fixed array debugging context */
+ H5FA_hdr_t *hdr = NULL; /* Shared fixed array header */
+ void *dbg_ctx = NULL; /* Fixed array debugging context */
/* Check arguments */
HDassert(f);
@@ -113,58 +113,58 @@ H5FA__hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent,
if(cls->crt_dbg_ctx) {
/* Create debugging context */
if(NULL == (dbg_ctx = cls->crt_dbg_ctx(f, dxpl_id, obj_addr)))
- H5E_THROW(H5E_CANTGET, "unable to create fixed array debugging context")
+ H5E_THROW(H5E_CANTGET, "unable to create fixed array debugging context")
} /* end if */
/* Load the fixed array header */
if(NULL == (hdr = H5FA__hdr_protect(f, dxpl_id, addr, dbg_ctx, H5AC__READ_ONLY_FLAG)))
- H5E_THROW(H5E_CANTPROTECT, "unable to load fixed array header")
+ H5E_THROW(H5E_CANTPROTECT, "unable to load fixed array header")
/* Print opening message */
HDfprintf(stream, "%*sFixed Array Header...\n", indent, "");
/* Print the values */
HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
- "Array class ID:", hdr->cparam.cls->name);
+ "Array class ID:", hdr->cparam.cls->name);
HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth,
- "Header size:",
- hdr->size);
+ "Header size:",
+ hdr->size);
HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
- "Raw Element Size:",
- (unsigned)hdr->cparam.raw_elmt_size);
+ "Raw Element Size:",
+ (unsigned)hdr->cparam.raw_elmt_size);
HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth,
- "Native Element Size (on this platform):",
- hdr->cparam.cls->nat_elmt_size);
+ "Native Element Size (on this platform):",
+ hdr->cparam.cls->nat_elmt_size);
HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
- "Max. # of elements in data block page:",
- (unsigned)((size_t)1 << hdr->cparam.max_dblk_page_nelmts_bits));
+ "Max. # of elements in data block page:",
+ (unsigned)((size_t)1 << hdr->cparam.max_dblk_page_nelmts_bits));
HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth,
- "Number of elements in Fixed Array:", hdr->stats.nelmts);
+ "Number of elements in Fixed Array:", hdr->stats.nelmts);
HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth,
- "Fixed Array Data Block Address:", hdr->dblk_addr);
+ "Fixed Array Data Block Address:", hdr->dblk_addr);
CATCH
if(dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0)
- H5E_THROW(H5E_CANTRELEASE, "unable to release fixed array debugging context")
+ H5E_THROW(H5E_CANTRELEASE, "unable to release fixed array debugging context")
if(hdr && H5FA__hdr_unprotect(hdr, dxpl_id, H5AC__NO_FLAGS_SET) < 0)
- H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array header")
+ H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array header")
END_FUNC(PKG) /* end H5FA__hdr_debug() */
/*-------------------------------------------------------------------------
- * Function: H5FA__dblock_debug
+ * Function: H5FA__dblock_debug
*
- * Purpose: Prints debugging info about a fixed array data block.
+ * Purpose: Prints debugging info about a fixed array data block.
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
- * Programmer: Vailin Choi
+ * Programmer: Vailin Choi
* Thursday, April 30, 2009
*
*-------------------------------------------------------------------------
@@ -177,7 +177,7 @@ H5FA__dblock_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int inde
/* Local variables */
H5FA_hdr_t *hdr = NULL; /* Shared fixed array header */
H5FA_dblock_t *dblock = NULL; /* Fixed array data block */
- void *dbg_ctx = NULL; /* Fixed array context */
+ void *dbg_ctx = NULL; /* Fixed array context */
size_t u; /* Local index variable */
/* Check arguments */
@@ -194,12 +194,12 @@ H5FA__dblock_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int inde
if(cls->crt_dbg_ctx) {
/* Create debugging context */
if(NULL == (dbg_ctx = cls->crt_dbg_ctx(f, dxpl_id, obj_addr)))
- H5E_THROW(H5E_CANTGET, "unable to create fixed array debugging context")
+ H5E_THROW(H5E_CANTGET, "unable to create fixed array debugging context")
} /* end if */
/* Load the fixed array header */
if(NULL == (hdr = H5FA__hdr_protect(f, dxpl_id, hdr_addr, dbg_ctx, H5AC__READ_ONLY_FLAG)))
- H5E_THROW(H5E_CANTPROTECT, "unable to load fixed array header")
+ H5E_THROW(H5E_CANTPROTECT, "unable to load fixed array header")
/* Protect data block */
if(NULL == (dblock = H5FA__dblock_protect(hdr, dxpl_id, addr, H5AC__READ_ONLY_FLAG)))
@@ -210,26 +210,26 @@ H5FA__dblock_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int inde
/* Print the values */
HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
- "Array class ID:", hdr->cparam.cls->name);
+ "Array class ID:", hdr->cparam.cls->name);
HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "Address of Data Block:", dblock->addr);
HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, "Data Block size:", dblock->size);
HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth,
- "Number of elements in Data Block:", hdr->cparam.nelmts);
+ "Number of elements in Data Block:", hdr->cparam.nelmts);
HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth,
- "Number of pages in Data Block:", dblock->npages);
+ "Number of pages in Data Block:", dblock->npages);
HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth,
- "Number of elements per Data Block page:", dblock->dblk_page_nelmts);
+ "Number of elements per Data Block page:", dblock->dblk_page_nelmts);
if(dblock->npages) { /* paging */
- size_t dblk_page_nelmts; /* # of elements in a data block page */
+ size_t dblk_page_nelmts; /* # of elements in a data block page */
haddr_t dblk_page_addr; /* Address of a data block page */
size_t page_idx; /* Page index within data block */
- HDfprintf(stream, "%*sPaging:\n", indent, "");
+ HDfprintf(stream, "%*sPaging:\n", indent, "");
- /* Iterate over the pages */
- dblk_page_addr = dblock->addr + H5FA_DBLOCK_PREFIX_SIZE(dblock);
- dblk_page_nelmts = dblock->dblk_page_nelmts;
+ /* Iterate over the pages */
+ dblk_page_addr = dblock->addr + H5FA_DBLOCK_PREFIX_SIZE(dblock);
+ dblk_page_nelmts = dblock->dblk_page_nelmts;
/* Read and print each page's elements in the data block */
for(page_idx = 0; page_idx < dblock->npages; page_idx++) {
@@ -237,51 +237,49 @@ H5FA__dblock_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int inde
HDfprintf(stream, "%*s%-*s %Hu %s\n", indent, "", fwidth,
"Page %Zu:", page_idx, "empty");
- } /* end if */
+ } /* end if */
else { /* get the page */
H5FA_dblk_page_t *dblk_page; /* Pointer to a data block page */
- hsize_t nelmts_left; /* Remaining elements in the last data block page */
+ hsize_t nelmts_left; /* Remaining elements in the last data block page */
/* Check for last page */
- if(((page_idx + 1) == dblock->npages) && (nelmts_left = hdr->cparam.nelmts % dblock->dblk_page_nelmts))
- dblk_page_nelmts = (size_t)nelmts_left;
+ if(((page_idx + 1) == dblock->npages) && (nelmts_left = hdr->cparam.nelmts % dblock->dblk_page_nelmts))
+ dblk_page_nelmts = (size_t)nelmts_left;
if(NULL == (dblk_page = H5FA__dblk_page_protect(hdr, dxpl_id, dblk_page_addr, dblk_page_nelmts, H5AC__READ_ONLY_FLAG)))
H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block page, address = %llu", (unsigned long long)dblk_page_addr)
- HDfprintf(stream, "%*sElements in page %Zu:\n", indent, "", page_idx);
- for(u = 0; u < dblk_page_nelmts; u++) {
- /* Call the class's 'debug' callback */
- if((hdr->cparam.cls->debug)(stream, (indent + 3), MAX(0, (fwidth - 3)), (hsize_t)u,
- ((uint8_t *)dblk_page->elmts) + (hdr->cparam.cls->nat_elmt_size * u)) < 0)
- H5E_THROW(H5E_CANTGET, "can't get element for debugging")
- } /* end for */
- if(H5FA__dblk_page_unprotect(dblk_page, dxpl_id, H5AC__NO_FLAGS_SET) < 0)
- H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array data block page")
-
- /* Advance to next page address */
- dblk_page_addr += dblock->dblk_page_size;
- } /* paging */
- } /* end for npages */
+ HDfprintf(stream, "%*sElements in page %Zu:\n", indent, "", page_idx);
+ for(u = 0; u < dblk_page_nelmts; u++) {
+ /* Call the class's 'debug' callback */
+ if((hdr->cparam.cls->debug)(stream, (indent + 3), MAX(0, (fwidth - 3)), (hsize_t)u, ((uint8_t *)dblk_page->elmts) + (hdr->cparam.cls->nat_elmt_size * u)) < 0)
+ H5E_THROW(H5E_CANTGET, "can't get element for debugging")
+ } /* end for */
+ if(H5FA__dblk_page_unprotect(dblk_page, dxpl_id, H5AC__NO_FLAGS_SET) < 0)
+ H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array data block page")
+
+ /* Advance to next page address */
+ dblk_page_addr += dblock->dblk_page_size;
+ } /* paging */
+ } /* end for npages */
} /* end if */
else { /* not paging */
- /* Print the elements in the data block */
- HDfprintf(stream, "%*sElements:\n", indent, "");
- for(u = 0; u < hdr->cparam.nelmts; u++) {
- /* Call the class's 'debug' callback */
- if((hdr->cparam.cls->debug)(stream, (indent + 3), MAX(0, (fwidth - 3)), (hsize_t)u,
- ((uint8_t *)dblock->elmts) + (hdr->cparam.cls->nat_elmt_size * u)) < 0)
- H5E_THROW(H5E_CANTGET, "can't get element for debugging")
- } /* end for */
+ /* Print the elements in the data block */
+ HDfprintf(stream, "%*sElements:\n", indent, "");
+ for(u = 0; u < hdr->cparam.nelmts; u++) {
+ /* Call the class's 'debug' callback */
+ if((hdr->cparam.cls->debug)(stream, (indent + 3), MAX(0, (fwidth - 3)), (hsize_t)u, ((uint8_t *)dblock->elmts) + (hdr->cparam.cls->nat_elmt_size * u)) < 0)
+ H5E_THROW(H5E_CANTGET, "can't get element for debugging")
+ } /* end for */
} /* end else */
CATCH
if(dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0)
- H5E_THROW(H5E_CANTRELEASE, "unable to release fixed array debugging context")
+ H5E_THROW(H5E_CANTRELEASE, "unable to release fixed array debugging context")
if(dblock && H5FA__dblock_unprotect(dblock, dxpl_id, H5AC__NO_FLAGS_SET) < 0)
H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array data block")
if(hdr && H5FA__hdr_unprotect(hdr, dxpl_id, H5AC__NO_FLAGS_SET) < 0)
- H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array header")
+ H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array header")
END_FUNC(PKG) /* end H5FA__dblock_debug() */
diff --git a/src/H5FAdblkpage.c b/src/H5FAdblkpage.c
index 00eb398..bba4439 100644
--- a/src/H5FAdblkpage.c
+++ b/src/H5FAdblkpage.c
@@ -15,9 +15,9 @@
/*-------------------------------------------------------------------------
*
- * Created: H5FAdblkpage.c
+ * Created: H5FAdblkpage.c
*
- * Purpose: Data block page routines for fixed array.
+ * Purpose: Data block page routines for fixed array.
*
*-------------------------------------------------------------------------
*/
@@ -37,10 +37,10 @@
/***********/
/* Headers */
/***********/
-#include "H5private.h" /* Generic Functions */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5FApkg.h" /* Fixed Arrays */
-#include "H5FLprivate.h" /* Free Lists */
+#include "H5private.h" /* Generic Functions */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5FApkg.h" /* Fixed Arrays */
+#include "H5FLprivate.h" /* Free Lists */
/****************/
@@ -86,13 +86,13 @@ H5FL_BLK_DEFINE(page_elmts);
/*-------------------------------------------------------------------------
- * Function: H5FA__dblk_page_alloc
+ * Function: H5FA__dblk_page_alloc
*
- * Purpose: Allocate fixed array data block page
+ * Purpose: Allocate fixed array data block page
*
- * Return: Non-NULL pointer to data block on success/NULL on failure
+ * Return: Non-NULL pointer to data block on success/NULL on failure
*
- * Programmer: Vailin Choi
+ * Programmer: Vailin Choi
* Thursday, April 30, 2009
*
*-------------------------------------------------------------------------
@@ -109,11 +109,11 @@ H5FA__dblk_page_alloc(H5FA_hdr_t *hdr, size_t nelmts))
/* Allocate memory for the data block */
if(NULL == (dblk_page = H5FL_CALLOC(H5FA_dblk_page_t)))
- H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array data block page")
+ H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array data block page")
/* Share common array information */
if(H5FA__hdr_incr(hdr) < 0)
- H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header")
+ H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header")
dblk_page->hdr = hdr;
/* Set non-zero internal fields */
@@ -136,13 +136,13 @@ END_FUNC(PKG) /* end H5FA__dblk_page_alloc() */
/*-------------------------------------------------------------------------
- * Function: H5FA__dblk_page_create
+ * Function: H5FA__dblk_page_create
*
- * Purpose: Creates a new fixed array data block page in the file
+ * Purpose: Creates a new fixed array data block page in the file
*
- * Return: Valid file address on success/HADDR_UNDEF on failure
+ * Return: Valid file address on success/HADDR_UNDEF on failure
*
- * Programmer: Vailin Choi
+ * Programmer: Vailin Choi
* Thursday, April 30, 2009
*
*-------------------------------------------------------------------------
@@ -163,7 +163,7 @@ HDfprintf(stderr, "%s: Called, addr = %a\n", FUNC, addr);
/* Allocate the data block page */
if(NULL == (dblk_page = H5FA__dblk_page_alloc(hdr, nelmts)))
- H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array data block page")
+ H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array data block page")
/* Set info about data block page on disk */
dblk_page->addr = addr;
@@ -178,7 +178,7 @@ HDfprintf(stderr, "%s: dblk_page->size = %Zu\n", FUNC, dblk_page->size);
/* Cache the new fixed array data block page */
if(H5AC_insert_entry(hdr->f, dxpl_id, H5AC_FARRAY_DBLK_PAGE, dblk_page->addr, dblk_page, H5AC__NO_FLAGS_SET) < 0)
- H5E_THROW(H5E_CANTINSERT, "can't add fixed array data block page to cache")
+ H5E_THROW(H5E_CANTINSERT, "can't add fixed array data block page to cache")
CATCH
if(ret_value < 0)
@@ -192,14 +192,14 @@ END_FUNC(PKG) /* end H5FA__dblk_page_create() */
/*-------------------------------------------------------------------------
- * Function: H5FA__dblk_page_protect
+ * Function: H5FA__dblk_page_protect
*
- * Purpose: Convenience wrapper around protecting fixed array data
+ * Purpose: Convenience wrapper around protecting fixed array data
* block page
*
- * Return: Non-NULL pointer to data block page on success/NULL on failure
+ * Return: Non-NULL pointer to data block page on success/NULL on failure
*
- * Programmer: Vailin Choi
+ * Programmer: Vailin Choi
* Thursday, April 30, 2009
*
*-------------------------------------------------------------------------
@@ -238,14 +238,14 @@ END_FUNC(PKG) /* end H5FA__dblk_page_protect() */
/*-------------------------------------------------------------------------
- * Function: H5FA__dblk_page_unprotect
+ * Function: H5FA__dblk_page_unprotect
*
- * Purpose: Convenience wrapper around unprotecting fixed array
+ * Purpose: Convenience wrapper around unprotecting fixed array
* data block page
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
- * Programmer: Vailin Choi
+ * Programmer: Vailin Choi
* Thursday, April 30, 2009
*
*-------------------------------------------------------------------------
@@ -274,13 +274,13 @@ END_FUNC(PKG) /* end H5FA__dblk_page_unprotect() */
/*-------------------------------------------------------------------------
- * Function: H5FA__dblk_page_dest
+ * Function: H5FA__dblk_page_dest
*
- * Purpose: Destroys a fixed array data block page in memory.
+ * Purpose: Destroys a fixed array data block page in memory.
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
- * Programmer: Vailin Choi
+ * Programmer: Vailin Choi
* Thursday, April 30, 2009
*
*-------------------------------------------------------------------------
@@ -297,7 +297,7 @@ H5FA__dblk_page_dest(H5FA_dblk_page_t *dblk_page))
/* Check if buffer for data block page elements has been initialized */
if(dblk_page->elmts) {
/* Free buffer for data block page elements */
- dblk_page->elmts = H5FL_BLK_FREE(page_elmts, dblk_page->elmts);
+ dblk_page->elmts = H5FL_BLK_FREE(page_elmts, dblk_page->elmts);
} /* end if */
/* Decrement reference count on shared info */
diff --git a/src/H5FAdblock.c b/src/H5FAdblock.c
index 71b618c..95419f8 100644
--- a/src/H5FAdblock.c
+++ b/src/H5FAdblock.c
@@ -15,9 +15,9 @@
/*-------------------------------------------------------------------------
*
- * Created: H5FAdblock.c
+ * Created: H5FAdblock.c
*
- * Purpose: Data block routines for fixed arrays.
+ * Purpose: Data block routines for fixed arrays.
*
*-------------------------------------------------------------------------
*/
@@ -37,11 +37,11 @@
/***********/
/* Headers */
/***********/
-#include "H5private.h" /* Generic Functions */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5FApkg.h" /* Fixed Arrays */
-#include "H5FLprivate.h" /* Free Lists */
-#include "H5MFprivate.h" /* File memory management */
+#include "H5private.h" /* Generic Functions */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5FApkg.h" /* Fixed Arrays */
+#include "H5FLprivate.h" /* Free Lists */
+#include "H5MFprivate.h" /* File memory management */
/****************/
@@ -89,13 +89,13 @@ H5FL_BLK_DEFINE(fa_page_init);
/*-------------------------------------------------------------------------
- * Function: H5FA__dblock_alloc
+ * Function: H5FA__dblock_alloc
*
- * Purpose: Allocate fixed array data block
+ * Purpose: Allocate fixed array data block
*
- * Return: Non-NULL pointer to data block on success/NULL on failure
+ * Return: Non-NULL pointer to data block on success/NULL on failure
*
- * Programmer: Vailin Choi
+ * Programmer: Vailin Choi
* Thursday, April 30, 2009
*
*-------------------------------------------------------------------------
@@ -113,11 +113,11 @@ H5FA__dblock_alloc(H5FA_hdr_t *hdr))
/* Allocate memory for the data block */
if(NULL == (dblock = H5FL_CALLOC(H5FA_dblock_t)))
- H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array data block")
+ H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array data block")
/* Share common array information */
if(H5FA__hdr_incr(hdr) < 0)
- H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header")
+ H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header")
dblock->hdr = hdr;
/* Set non-zero internal fields */
@@ -131,19 +131,19 @@ H5FA__dblock_alloc(H5FA_hdr_t *hdr))
/* Safely assign the number of pages */
H5_CHECKED_ASSIGN(dblock->npages, size_t, npages, hsize_t);
- /* Sanity check that we have at least 1 page */
- HDassert(dblock->npages > 0);
+ /* Sanity check that we have at least 1 page */
+ HDassert(dblock->npages > 0);
/* Compute size of 'page init' flag array, in bytes */
- dblock->dblk_page_init_size = (dblock->npages + 7) / 8;
- HDassert(dblock->dblk_page_init_size > 0);
+ dblock->dblk_page_init_size = (dblock->npages + 7) / 8;
+ HDassert(dblock->dblk_page_init_size > 0);
- /* Allocate space for 'page init' flags */
- if(NULL == (dblock->dblk_page_init = H5FL_BLK_CALLOC(fa_page_init, dblock->dblk_page_init_size)))
- H5E_THROW(H5E_CANTALLOC, "memory allocation failed for page init bitmask")
+ /* Allocate space for 'page init' flags */
+ if(NULL == (dblock->dblk_page_init = H5FL_BLK_CALLOC(fa_page_init, dblock->dblk_page_init_size)))
+ H5E_THROW(H5E_CANTALLOC, "memory allocation failed for page init bitmask")
- /* Compute data block page size */
- dblock->dblk_page_size = (dblock->dblk_page_nelmts * hdr->cparam.raw_elmt_size) + H5FA_SIZEOF_CHKSUM;
+ /* Compute data block page size */
+ dblock->dblk_page_size = (dblock->dblk_page_nelmts * hdr->cparam.raw_elmt_size) + H5FA_SIZEOF_CHKSUM;
/* Compute the # of elements on last page */
if(0 == hdr->cparam.nelmts % dblock->dblk_page_nelmts)
@@ -156,8 +156,8 @@ H5FA__dblock_alloc(H5FA_hdr_t *hdr))
/* Allocate buffer for elements in data block */
H5_CHECK_OVERFLOW(dblk_size, /* From: */hsize_t, /* To: */size_t);
- if(NULL == (dblock->elmts = H5FL_BLK_MALLOC(chunk_elmts, (size_t)dblk_size)))
- H5E_THROW(H5E_CANTALLOC, "memory allocation failed for data block element buffer")
+ if(NULL == (dblock->elmts = H5FL_BLK_MALLOC(chunk_elmts, (size_t)dblk_size)))
+ H5E_THROW(H5E_CANTALLOC, "memory allocation failed for data block element buffer")
} /* end else */
/* Set the return value */
@@ -173,13 +173,13 @@ END_FUNC(PKG) /* end H5FA__dblock_alloc() */
/*-------------------------------------------------------------------------
- * Function: H5FA__dblock_create
+ * Function: H5FA__dblock_create
*
- * Purpose: Creates a fixed array data block in the file
+ * Purpose: Creates a fixed array data block in the file
*
- * Return: Valid file address on success/HADDR_UNDEF on failure
+ * Return: Valid file address on success/HADDR_UNDEF on failure
*
- * Programmer: Vailin Choi
+ * Programmer: Vailin Choi
* Thursday, April 30, 2009
*
*-------------------------------------------------------------------------
@@ -202,7 +202,7 @@ HDfprintf(stderr, "%s: Called, hdr->stats.nelmts = %Zu, nelmts = %Zu\n", FUNC, h
/* Allocate the data block */
if(NULL == (dblock = H5FA__dblock_alloc(hdr)))
- H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array data block")
+ H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array data block")
/* Set size of data block on disk */
hdr->stats.dblk_size = dblock->size = H5FA_DBLOCK_SIZE(dblock);
@@ -213,7 +213,7 @@ HDfprintf(stderr, "%s: dblock->size = %Zu\n", FUNC, dblock->size);
/* Allocate space for the data block on disk */
if(HADDR_UNDEF == (dblock_addr = H5MF_alloc(hdr->f, H5FD_MEM_FARRAY_DBLOCK, dxpl_id, (hsize_t)dblock->size)))
- H5E_THROW(H5E_CANTALLOC, "file allocation failed for fixed array data block")
+ H5E_THROW(H5E_CANTALLOC, "file allocation failed for fixed array data block")
dblock->addr = dblock_addr;
/* Don't initialize elements if paged */
@@ -224,7 +224,7 @@ HDfprintf(stderr, "%s: dblock->size = %Zu\n", FUNC, dblock->size);
/* Cache the new fixed array data block */
if(H5AC_insert_entry(hdr->f, dxpl_id, H5AC_FARRAY_DBLOCK, dblock_addr, dblock, H5AC__NO_FLAGS_SET) < 0)
- H5E_THROW(H5E_CANTINSERT, "can't add fixed array data block to cache")
+ H5E_THROW(H5E_CANTINSERT, "can't add fixed array data block to cache")
/* Mark the header dirty (for updating statistics) */
*hdr_dirty = TRUE;
@@ -249,13 +249,13 @@ END_FUNC(PKG) /* end H5FA__dblock_create() */
/*-------------------------------------------------------------------------
- * Function: H5FA__dblock_protect
+ * Function: H5FA__dblock_protect
*
- * Purpose: Convenience wrapper around protecting fixed array data block
+ * Purpose: Convenience wrapper around protecting fixed array data block
*
- * Return: Non-NULL pointer to data block on success/NULL on failure
+ * Return: Non-NULL pointer to data block on success/NULL on failure
*
- * Programmer: Vailin Choi
+ * Programmer: Vailin Choi
* Thursday, April 30, 2009
*
*-------------------------------------------------------------------------
@@ -293,13 +293,13 @@ END_FUNC(PKG) /* end H5FA__dblock_protect() */
/*-------------------------------------------------------------------------
- * Function: H5FA__dblock_unprotect
+ * Function: H5FA__dblock_unprotect
*
- * Purpose: Convenience wrapper around unprotecting fixed array data block
+ * Purpose: Convenience wrapper around unprotecting fixed array data block
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
- * Programmer: Vailin Choi
+ * Programmer: Vailin Choi
* Thursday, April 30, 2009
*
*-------------------------------------------------------------------------
@@ -327,13 +327,13 @@ END_FUNC(PKG) /* end H5FA__dblock_unprotect() */
/*-------------------------------------------------------------------------
- * Function: H5FA__dblock_delete
+ * Function: H5FA__dblock_delete
*
- * Purpose: Delete a data block
+ * Purpose: Delete a data block
*
- * Return: SUCCEED/FAIL
+ * Return: SUCCEED/FAIL
*
- * Programmer: Vailin Choi
+ * Programmer: Vailin Choi
* Thursday, April 30, 2009
*
*-------------------------------------------------------------------------
@@ -393,13 +393,13 @@ END_FUNC(PKG) /* end H5FA__dblock_delete() */
/*-------------------------------------------------------------------------
- * Function: H5FA__dblock_dest
+ * Function: H5FA__dblock_dest
*
- * Purpose: Destroys a fixed array data block in memory.
+ * Purpose: Destroys a fixed array data block in memory.
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
- * Programmer: Vailin Choi
+ * Programmer: Vailin Choi
* Thursday, April 30, 2009
*
*-------------------------------------------------------------------------
@@ -417,16 +417,16 @@ H5FA__dblock_dest(H5FA_dblock_t *dblock))
if(dblock->elmts && !dblock->npages) {
/* Free buffer for data block elements */
HDassert(dblock->hdr->cparam.nelmts > 0);
- dblock->elmts = H5FL_BLK_FREE(chunk_elmts, dblock->elmts);
+ dblock->elmts = H5FL_BLK_FREE(chunk_elmts, dblock->elmts);
} /* end if */
/* Check if data block is paged */
- if(dblock->npages) {
- /* Free buffer for 'page init' bitmask, if there is one */
- HDassert(dblock->dblk_page_init_size > 0);
- if(dblock->dblk_page_init)
- dblock->dblk_page_init = H5FL_BLK_FREE(fa_page_init, dblock->dblk_page_init);
- } /* end if */
+ if(dblock->npages) {
+ /* Free buffer for 'page init' bitmask, if there is one */
+ HDassert(dblock->dblk_page_init_size > 0);
+ if(dblock->dblk_page_init)
+ dblock->dblk_page_init = H5FL_BLK_FREE(fa_page_init, dblock->dblk_page_init);
+ } /* end if */
/* Decrement reference count on shared info */
if(H5FA__hdr_decr(dblock->hdr) < 0)
diff --git a/src/H5FAhdr.c b/src/H5FAhdr.c
index 49d22f3..62b1837 100644
--- a/src/H5FAhdr.c
+++ b/src/H5FAhdr.c
@@ -15,9 +15,9 @@
/*-------------------------------------------------------------------------
*
- * Created: H5FAhdr.c
+ * Created: H5FAhdr.c
*
- * Purpose: Array header routines for Fixed Array.
+ * Purpose: Array header routines for Fixed Array.
*
*-------------------------------------------------------------------------
*/
@@ -37,10 +37,10 @@
/***********/
/* Headers */
/***********/
-#include "H5private.h" /* Generic Functions */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5FApkg.h" /* Fixed Arrays */
-#include "H5MFprivate.h" /* File memory management */
+#include "H5private.h" /* Generic Functions */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5FApkg.h" /* Fixed Arrays */
+#include "H5MFprivate.h" /* File memory management */
/****************/
@@ -82,13 +82,13 @@ H5FL_DEFINE_STATIC(H5FA_hdr_t);
/*-------------------------------------------------------------------------
- * Function: H5FA__hdr_alloc
+ * Function: H5FA__hdr_alloc
*
- * Purpose: Allocate shared Fixed Array header
+ * Purpose: Allocate shared Fixed Array header
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
- * Programmer: Vailin Choi
+ * Programmer: Vailin Choi
* Thursday, April 30, 2009
*
*-------------------------------------------------------------------------
@@ -105,7 +105,7 @@ H5FA__hdr_alloc(H5F_t *f))
/* Allocate space for the shared information */
if(NULL == (hdr = H5FL_CALLOC(H5FA_hdr_t)))
- H5E_THROW(H5E_CANTALLOC, "memory allocation failed for Fixed Array shared header")
+ H5E_THROW(H5E_CANTALLOC, "memory allocation failed for Fixed Array shared header")
/* Set non-zero internal fields */
hdr->addr = HADDR_UNDEF;
@@ -127,13 +127,13 @@ END_FUNC(PKG) /* end H5FA__hdr_alloc() */
/*-------------------------------------------------------------------------
- * Function: H5FA__hdr_init
+ * Function: H5FA__hdr_init
*
- * Purpose: Initialize shared fixed array header
+ * Purpose: Initialize shared fixed array header
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Sunday, November 15, 2009
*
*-------------------------------------------------------------------------
@@ -165,13 +165,13 @@ END_FUNC(PKG) /* end H5FA__hdr_init() */
/*-------------------------------------------------------------------------
- * Function: H5FA__hdr_create
+ * Function: H5FA__hdr_create
*
- * Purpose: Creates a new Fixed Array header in the file
+ * Purpose: Creates a new Fixed Array header in the file
*
- * Return: SUCCEED/FAIL
+ * Return: SUCCEED/FAIL
*
- * Programmer: Vailin Choi
+ * Programmer: Vailin Choi
* Thursday, April 30, 2009
*
*-------------------------------------------------------------------------
@@ -196,17 +196,17 @@ HDfprintf(stderr, "%s: Called\n", FUNC);
{
/* Check for valid parameters */
if(cparam->raw_elmt_size == 0)
- H5E_THROW(H5E_BADVALUE, "element size must be greater than zero")
+ H5E_THROW(H5E_BADVALUE, "element size must be greater than zero")
if(cparam->max_dblk_page_nelmts_bits == 0)
- H5E_THROW(H5E_BADVALUE, "max. # of elements bits must be greater than zero")
+ H5E_THROW(H5E_BADVALUE, "max. # of elements bits must be greater than zero")
if(cparam->nelmts == 0)
- H5E_THROW(H5E_BADVALUE, "# of elements must be greater than zero")
+ H5E_THROW(H5E_BADVALUE, "# of elements must be greater than zero")
}
#endif /* NDEBUG */
/* Allocate space for the shared information */
if(NULL == (hdr = H5FA__hdr_alloc(f)))
- H5E_THROW(H5E_CANTALLOC, "memory allocation failed for Fixed Array shared header")
+ H5E_THROW(H5E_CANTALLOC, "memory allocation failed for Fixed Array shared header")
hdr->dblk_addr = HADDR_UNDEF;
@@ -215,15 +215,15 @@ HDfprintf(stderr, "%s: Called\n", FUNC);
/* Finish initializing fixed array header */
if(H5FA__hdr_init(hdr, ctx_udata) < 0)
- H5E_THROW(H5E_CANTINIT, "initialization failed for fixed array header")
+ H5E_THROW(H5E_CANTINIT, "initialization failed for fixed array header")
/* Allocate space for the header on disk */
if(HADDR_UNDEF == (hdr->addr = H5MF_alloc(f, H5FD_MEM_FARRAY_HDR, dxpl_id, (hsize_t)hdr->size)))
- H5E_THROW(H5E_CANTALLOC, "file allocation failed for Fixed Array header")
+ H5E_THROW(H5E_CANTALLOC, "file allocation failed for Fixed Array header")
/* Cache the new Fixed Array header */
if(H5AC_insert_entry(f, dxpl_id, H5AC_FARRAY_HDR, hdr->addr, hdr, H5AC__NO_FLAGS_SET) < 0)
- H5E_THROW(H5E_CANTINSERT, "can't add fixed array header to cache")
+ H5E_THROW(H5E_CANTINSERT, "can't add fixed array header to cache")
/* Set address of array header to return */
ret_value = hdr->addr;
@@ -244,13 +244,13 @@ END_FUNC(PKG) /* end H5FA__hdr_create() */
/*-------------------------------------------------------------------------
- * Function: H5FA__hdr_incr
+ * Function: H5FA__hdr_incr
*
- * Purpose: Increment component reference count on shared array header
+ * Purpose: Increment component reference count on shared array header
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
- * Programmer: Vailin Choi
+ * Programmer: Vailin Choi
* Thursday, April 30, 2009
*
*-------------------------------------------------------------------------
@@ -276,13 +276,13 @@ END_FUNC(PKG) /* end H5FA__hdr_incr() */
/*-------------------------------------------------------------------------
- * Function: H5FA__hdr_decr
+ * Function: H5FA__hdr_decr
*
- * Purpose: Decrement component reference count on shared array header
+ * Purpose: Decrement component reference count on shared array header
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
- * Programmer: Vailin Choi
+ * Programmer: Vailin Choi
* Thursday, April 30, 2009
*
*-------------------------------------------------------------------------
@@ -311,13 +311,13 @@ END_FUNC(PKG) /* end H5FA__hdr_decr() */
/*-------------------------------------------------------------------------
- * Function: H5FA__hdr_fuse_incr
+ * Function: H5FA__hdr_fuse_incr
*
- * Purpose: Increment file reference count on shared array header
+ * Purpose: Increment file reference count on shared array header
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
- * Programmer: Vailin Choi
+ * Programmer: Vailin Choi
* Thursday, April 30, 2009
*
*-------------------------------------------------------------------------
@@ -336,13 +336,13 @@ END_FUNC(PKG) /* end H5FA__hdr_fuse_incr() */
/*-------------------------------------------------------------------------
- * Function: H5FA__hdr_fuse_decr
+ * Function: H5FA__hdr_fuse_decr
*
- * Purpose: Decrement file reference count on shared array header
+ * Purpose: Decrement file reference count on shared array header
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
- * Programmer: Vailin Choi
+ * Programmer: Vailin Choi
* Thursday, April 30, 2009
*
*-------------------------------------------------------------------------
@@ -365,13 +365,13 @@ END_FUNC(PKG) /* end H5FA__hdr_fuse_decr() */
/*-------------------------------------------------------------------------
- * Function: H5FA__hdr_modified
+ * Function: H5FA__hdr_modified
*
- * Purpose: Mark a fixed array as modified
+ * Purpose: Mark a fixed array as modified
*
- * Return: SUCCEED/FAIL
+ * Return: SUCCEED/FAIL
*
- * Programmer: Vailin Choi
+ * Programmer: Vailin Choi
* Thursday, April 30, 2009
*
*-------------------------------------------------------------------------
@@ -468,11 +468,11 @@ END_FUNC(PKG) /* end H5EA__hdr_unprotect() */
/*-------------------------------------------------------------------------
* Function: H5FA__hdr_delete
*
- * Purpose: Delete a fixed array, starting with the header
+ * Purpose: Delete a fixed array, starting with the header
*
- * Return: SUCCEED/FAIL
+ * Return: SUCCEED/FAIL
*
- * Programmer: Vailin Choi
+ * Programmer: Vailin Choi
* Thursday, April 30, 2009
*
*-------------------------------------------------------------------------
@@ -526,13 +526,13 @@ END_FUNC(PKG) /* end H5FA__hdr_delete() */
/*-------------------------------------------------------------------------
- * Function: H5FA__hdr_dest
+ * Function: H5FA__hdr_dest
*
- * Purpose: Destroys a fixed array header in memory.
+ * Purpose: Destroys a fixed array header in memory.
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
- * Programmer: Vailin Choi
+ * Programmer: Vailin Choi
* Thursday, April 30, 2009
*
*-------------------------------------------------------------------------
diff --git a/src/H5FApkg.h b/src/H5FApkg.h
index ddf3a07..c29322a 100644
--- a/src/H5FApkg.h
+++ b/src/H5FApkg.h
@@ -16,9 +16,9 @@
/*
* Programmer:
*
- * Purpose: This file contains declarations which are visible only within
- * the H5FA package. Source files outside the H5FA package should
- * include H5FAprivate.h instead.
+ * Purpose: This file contains declarations which are visible only within
+ * the H5FA package. Source files outside the H5FA package should
+ * include H5FAprivate.h instead.
*/
#if !(defined(H5FA_FRIEND) | defined(H5FA_MODULE))
#error "Do not include this file outside the H5FA package!"
@@ -31,8 +31,8 @@
#include "H5FAprivate.h"
/* Other private headers needed by this file */
-#include "H5ACprivate.h" /* Metadata cache */
-#include "H5FLprivate.h" /* Free Lists */
+#include "H5ACprivate.h" /* Metadata cache */
+#include "H5FLprivate.h" /* Free Lists */
/**************************/
@@ -52,11 +52,11 @@
#define H5FA_SIZEOF_CHKSUM 4
/* "Standard" size of prefix information for fixed array metadata */
-#define H5FA_METADATA_PREFIX_SIZE(c) ( \
- H5_SIZEOF_MAGIC /* Signature */ \
- + 1 /* Version */ \
- + 1 /* Array type */ \
- + ((c) ? H5FA_SIZEOF_CHKSUM : 0) /* Metadata checksum */ \
+#define H5FA_METADATA_PREFIX_SIZE(c) ( \
+ H5_SIZEOF_MAGIC /* Signature */ \
+ + 1 /* Version */ \
+ + 1 /* Array type */ \
+ + ((c) ? H5FA_SIZEOF_CHKSUM : 0) /* Metadata checksum */ \
)
/* Size of the Fixed Array header on disk */
@@ -86,25 +86,25 @@
)
/* Size of the Fixed Array data block prefix on disk */
-#define H5FA_DBLOCK_PREFIX_SIZE(d) ( \
- /* General metadata fields */ \
- H5FA_METADATA_PREFIX_SIZE(TRUE) \
- \
- /* Sanity-checking fields */ \
- + (d)->hdr->sizeof_addr /* File address of Fixed Array header owning the data block */ \
- \
- /* Fixed Array Data Block specific fields */ \
+#define H5FA_DBLOCK_PREFIX_SIZE(d) ( \
+ /* General metadata fields */ \
+ H5FA_METADATA_PREFIX_SIZE(TRUE) \
+ \
+ /* Sanity-checking fields */ \
+ + (d)->hdr->sizeof_addr /* File address of Fixed Array header owning the data block */ \
+ \
+ /* Fixed Array Data Block specific fields */ \
+ (d)->dblk_page_init_size /* Fixed array data block 'page init' bitmasks (can be 0 if no pages) */ \
)
/* Size of the Fixed Array data block on disk */
-#define H5FA_DBLOCK_SIZE(d) ( \
- /* Data block prefix size */ \
- H5FA_DBLOCK_PREFIX_SIZE(d) \
- \
- /* Fixed Array Elements|Pages of Elements*/ \
- + ((d)->hdr->cparam.nelmts * (size_t)(d)->hdr->cparam.raw_elmt_size) \
- + ((d)->npages * H5FA_SIZEOF_CHKSUM) /* Checksum */ \
+#define H5FA_DBLOCK_SIZE(d) ( \
+ /* Data block prefix size */ \
+ H5FA_DBLOCK_PREFIX_SIZE(d) \
+ \
+ /* Fixed Array Elements|Pages of Elements*/ \
+ + ((d)->hdr->cparam.nelmts * (size_t)(d)->hdr->cparam.raw_elmt_size) \
+ + ((d)->npages * H5FA_SIZEOF_CHKSUM) /* Checksum */ \
)
/* Size of the Fixed Array data block page on disk */
@@ -127,20 +127,20 @@ typedef struct H5FA_hdr_t {
H5FA_create_t cparam; /* Creation parameters for Fixed Array */
/* Fixed Array data block information (stored in header) */
- haddr_t dblk_addr; /* Address of Fixed Array Data block */
+ haddr_t dblk_addr; /* Address of Fixed Array Data block */
/* Statistics for Fixed Array (stored in header) */
H5FA_stat_t stats; /* Statistcs for Fixed Array */
/* Computed/cached values (not stored in header) */
- size_t rc; /* Reference count of the header */
- haddr_t addr; /* Address of header in file */
- size_t size; /* Size of header in file */
- H5F_t *f; /* Pointer to file for fixed array */
- size_t file_rc; /* Reference count of files using array header */
- hbool_t pending_delete; /* Array is pending deletion */
- size_t sizeof_addr; /* Size of file addresses */
- size_t sizeof_size; /* Size of file sizes */
+ size_t rc; /* Reference count of the header */
+ haddr_t addr; /* Address of header in file */
+ size_t size; /* Size of header in file */
+ H5F_t *f; /* Pointer to file for fixed array */
+ size_t file_rc; /* Reference count of files using array header */
+ hbool_t pending_delete; /* Array is pending deletion */
+ size_t sizeof_addr; /* Size of file addresses */
+ size_t sizeof_size; /* Size of file sizes */
/* Client information (not stored) */
void *cb_ctx; /* Callback context */
@@ -152,22 +152,22 @@ typedef struct H5FA_dblock_t {
H5AC_info_t cache_info;
/* Fixed array information (stored) */
- uint8_t *dblk_page_init;/* Bitmap of whether a data block page is initialized */
- void *elmts; /* Buffer for elements stored in data block */
+ uint8_t *dblk_page_init;/* Bitmap of whether a data block page is initialized */
+ void *elmts; /* Buffer for elements stored in data block */
/* Internal array information (not stored) */
- H5FA_hdr_t *hdr; /* Shared array header info */
+ H5FA_hdr_t *hdr; /* Shared array header info */
/* Computed/cached values (not stored) */
- haddr_t addr; /* Address of this data block on disk */
- hsize_t size; /* Size of data block on disk */
- size_t npages; /* Nummber of pages in data block (zero if not paged) */
- size_t last_page_nelmts; /* Nummber of elements in last page, if paged */
+ haddr_t addr; /* Address of this data block on disk */
+ hsize_t size; /* Size of data block on disk */
+ size_t npages; /* Nummber of pages in data block (zero if not paged) */
+ size_t last_page_nelmts; /* Nummber of elements in last page, if paged */
/* Fixed Array data block information (not stored) */
- size_t dblk_page_nelmts; /* # of elements per data block page */
- size_t dblk_page_size; /* Size of a data block page */
- size_t dblk_page_init_size; /* Size of 'page init' bitmask */
+ size_t dblk_page_nelmts; /* # of elements per data block page */
+ size_t dblk_page_size; /* Size of a data block page */
+ size_t dblk_page_init_size; /* Size of 'page init' bitmask */
} H5FA_dblock_t;
/* The fixed array data block page information */
@@ -179,18 +179,18 @@ typedef struct H5FA_dbk_page_t {
void *elmts; /* Buffer for elements stored in data block page */
/* Internal array information (not stored) */
- H5FA_hdr_t *hdr; /* Shared array header info */
+ H5FA_hdr_t *hdr; /* Shared array header info */
/* Computed/cached values (not stored) */
- haddr_t addr; /* Address of this data block page on disk */
- size_t size; /* Size of data block page on disk */
- size_t nelmts; /* Number of elements in data block page */
+ haddr_t addr; /* Address of this data block page on disk */
+ size_t size; /* Size of data block page on disk */
+ size_t nelmts; /* Number of elements in data block page */
} H5FA_dblk_page_t;
/* Fixed array */
struct H5FA_t {
- H5FA_hdr_t *hdr; /* Pointer to internal fixed array header info */
- H5F_t *f; /* Pointer to file for fixed array */
+ H5FA_hdr_t *hdr; /* Pointer to internal fixed array header info */
+ H5F_t *f; /* Pointer to file for fixed array */
};
@@ -205,14 +205,14 @@ typedef struct H5FA_hdr_cache_ud_t {
/* Info needed for loading data block */
typedef struct H5FA_dblock_cache_ud_t {
- H5FA_hdr_t *hdr; /* Shared fixed array information */
- haddr_t dblk_addr; /* Address of data block on disk */
+ H5FA_hdr_t *hdr; /* Shared fixed array information */
+ haddr_t dblk_addr; /* Address of data block on disk */
} H5FA_dblock_cache_ud_t;
/* Info needed for loading data block page */
typedef struct H5FA_dblk_page_cache_ud_t {
- H5FA_hdr_t *hdr; /* Shared fixed array information */
- size_t nelmts; /* Number of elements in data block page */
+ H5FA_hdr_t *hdr; /* Shared fixed array information */
+ size_t nelmts; /* Number of elements in data block page */
haddr_t dblk_page_addr; /* Address of data block page on disk */
} H5FA_dblk_page_cache_ud_t;
@@ -234,7 +234,7 @@ H5_DLLVAR const H5AC_class_t H5AC_FARRAY_DBLK_PAGE[1];
H5_DLLVAR const H5FA_class_t H5FA_CLS_TEST[1];
/* Array of fixed array client ID -> client class mappings */
-extern const H5FA_class_t *const H5FA_client_class_g[H5FA_NUM_CLS_ID];
+H5_DLLVAR const H5FA_class_t *const H5FA_client_class_g[H5FA_NUM_CLS_ID];
/******************************/
diff --git a/src/H5FAprivate.h b/src/H5FAprivate.h
index 71a68c0..aa88003 100644
--- a/src/H5FAprivate.h
+++ b/src/H5FAprivate.h
@@ -15,9 +15,9 @@
/*-------------------------------------------------------------------------
*
- * Created: H5FAprivate.h
+ * Created: H5FAprivate.h
*
- * Purpose: Private header for library accessible Fixed
+ * Purpose: Private header for library accessible Fixed
* Array routines.
*
*-------------------------------------------------------------------------
@@ -48,8 +48,8 @@
typedef enum H5FA_cls_id_t {
/* Start real class IDs at 0 -QAK */
/* (keep these last) */
- H5FA_CLS_TEST_ID, /* Fixed array is for testing (do not use for actual data) */
- H5FA_NUM_CLS_ID /* Number of Fixed Array class IDs (must be last) */
+ H5FA_CLS_TEST_ID, /* Fixed array is for testing (do not use for actual data) */
+ H5FA_NUM_CLS_ID /* Number of Fixed Array class IDs (must be last) */
} H5FA_cls_id_t;
/*
@@ -57,9 +57,9 @@ typedef enum H5FA_cls_id_t {
* variable of this type that contains class variables and methods.
*/
typedef struct H5FA_class_t {
- H5FA_cls_id_t id; /* ID of Fixed Array class, as found in file */
- const char *name; /* Name of class (for debugging) */
- size_t nat_elmt_size; /* Size of native (memory) element */
+ H5FA_cls_id_t id; /* ID of Fixed Array class, as found in file */
+ const char *name; /* Name of class (for debugging) */
+ size_t nat_elmt_size; /* Size of native (memory) element */
/* Fixed array client callback methods */
void *(*crt_context)(void *udata); /* Create context for other callbacks */
@@ -74,22 +74,23 @@ typedef struct H5FA_class_t {
/* Fixed array creation parameters */
typedef struct H5FA_create_t {
- const H5FA_class_t *cls; /* Class of Fixed Array to create */
- uint8_t raw_elmt_size; /* Element size in file (in bytes) */
+ const H5FA_class_t *cls; /* Class of Fixed Array to create */
+ uint8_t raw_elmt_size; /* Element size in file (in bytes) */
uint8_t max_dblk_page_nelmts_bits; /* Log2(Max. # of elements in a data block page) -
- i.e. # of bits needed to store max. # of elements
- in a data block page */
- hsize_t nelmts; /* # of elements in array */
+ * i.e. # of bits needed to store max. # of elements
+ * in a data block page
+ */
+ hsize_t nelmts; /* # of elements in array */
} H5FA_create_t;
/* Fixed array metadata statistics info */
typedef struct H5FA_stat_t {
/* Non-stored (i.e. computed) fields */
- hsize_t hdr_size; /* Size of header */
- hsize_t dblk_size; /* Size of data block */
+ hsize_t hdr_size; /* Size of header */
+ hsize_t dblk_size; /* Size of data block */
/* Stored fields */
- hsize_t nelmts; /* # of elements */
+ hsize_t nelmts; /* # of elements */
} H5FA_stat_t;
/* Fixed Array info (forward decl - defined in H5FApkg.h) */
@@ -111,14 +112,14 @@ typedef int (*H5FA_operator_t)(hsize_t idx, const void *_elmt, void *_udata);
/* General routines */
H5_DLL H5FA_t *H5FA_create(H5F_t *f, hid_t dxpl_id, const H5FA_create_t *cparam,
void *ctx_udata);
-H5_DLL H5FA_t *H5FA_open(H5F_t *f, hid_t dxpl_id, haddr_t ea_addr, void *ctx_udata);
-H5_DLL herr_t H5FA_get_nelmts(const H5FA_t *ea, hsize_t *nelmts);
-H5_DLL herr_t H5FA_get_addr(const H5FA_t *ea, haddr_t *addr);
-H5_DLL herr_t H5FA_set(const H5FA_t *ea, hid_t dxpl_id, hsize_t idx, const void *elmt);
-H5_DLL herr_t H5FA_get(const H5FA_t *ea, hid_t dxpl_id, hsize_t idx, void *elmt);
+H5_DLL H5FA_t *H5FA_open(H5F_t *f, hid_t dxpl_id, haddr_t fa_addr, void *ctx_udata);
+H5_DLL herr_t H5FA_get_nelmts(const H5FA_t *fa, hsize_t *nelmts);
+H5_DLL herr_t H5FA_get_addr(const H5FA_t *fa, haddr_t *addr);
+H5_DLL herr_t H5FA_set(const H5FA_t *fa, hid_t dxpl_id, hsize_t idx, const void *elmt);
+H5_DLL herr_t H5FA_get(const H5FA_t *fa, hid_t dxpl_id, hsize_t idx, void *elmt);
H5_DLL herr_t H5FA_iterate(H5FA_t *fa, hid_t dxpl_id, H5FA_operator_t op, void *udata);
-H5_DLL herr_t H5FA_close(H5FA_t *ea, hid_t dxpl_id);
-H5_DLL herr_t H5FA_delete(H5F_t *f, hid_t dxpl_id, haddr_t ea_addr, void *ctx_udata);
+H5_DLL herr_t H5FA_close(H5FA_t *fa, hid_t dxpl_id);
+H5_DLL herr_t H5FA_delete(H5F_t *f, hid_t dxpl_id, haddr_t fa_addr, void *ctx_udata);
/* Statistics routines */
H5_DLL herr_t H5FA_get_stats(const H5FA_t *ea, H5FA_stat_t *stats);
diff --git a/src/H5FAstat.c b/src/H5FAstat.c
index 4ded4c1..72fa0de 100644
--- a/src/H5FAstat.c
+++ b/src/H5FAstat.c
@@ -15,9 +15,9 @@
/*-------------------------------------------------------------------------
*
- * Created: H5FAstat.c
+ * Created: H5FAstat.c
*
- * Purpose: Fixed array metadata statistics functions.
+ * Purpose: Fixed array metadata statistics functions.
*
*-------------------------------------------------------------------------
*/
@@ -37,9 +37,9 @@
/***********/
/* Headers */
/***********/
-#include "H5private.h" /* Generic Functions */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5FApkg.h" /* Fixed Arrays */
+#include "H5private.h" /* Generic Functions */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5FApkg.h" /* Fixed Arrays */
/****************/
@@ -79,13 +79,13 @@
/*-------------------------------------------------------------------------
- * Function: H5FA_get_stats
+ * Function: H5FA_get_stats
*
- * Purpose: Query the metadata stats of an array
+ * Purpose: Query the metadata stats of an array
*
- * Return: SUCCEED/FAIL
+ * Return: SUCCEED/FAIL
*
- * Programmer: Vailin Choi
+ * Programmer: Vailin Choi
* Thursday, April 30, 2009
*
*-------------------------------------------------------------------------
diff --git a/src/H5FAtest.c b/src/H5FAtest.c
index 528f550..091f284 100644
--- a/src/H5FAtest.c
+++ b/src/H5FAtest.c
@@ -14,9 +14,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
- * Programmer:
- *
- * Purpose: Fixed array testing functions.
+ * Purpose: Fixed array testing functions.
*
*/
@@ -119,14 +117,14 @@ H5FL_DEFINE_STATIC(H5FA__test_ctx_t);
/*-------------------------------------------------------------------------
- * Function: H5FA__test_crt_context
+ * Function: H5FA__test_crt_context
*
- * Purpose: Create context for callbacks
+ * Purpose: Create context for callbacks
*
- * Return: Success: non-NULL
- * Failure: NULL
+ * Return: Success: non-NULL
+ * Failure: NULL
*
- * Programmer: Vailin Choi
+ * Programmer: Vailin Choi
* Thursday, April 30, 2009
*
*-------------------------------------------------------------------------
@@ -140,7 +138,7 @@ H5FA__test_crt_context(void H5_ATTR_UNUSED *udata))
/* Allocate new context structure */
if(NULL == (ctx = H5FL_MALLOC(H5FA__test_ctx_t)))
- H5E_THROW(H5E_CANTALLOC, "can't allocate fixed array client callback context")
+ H5E_THROW(H5E_CANTALLOC, "can't allocate fixed array client callback context")
/* Initialize the context */
ctx->bogus = H5FA__TEST_BOGUS_VAL;
@@ -154,14 +152,13 @@ END_FUNC(STATIC) /* end H5FA__test_crt_context() */
/*-------------------------------------------------------------------------
- * Function: H5FA__test_dst_context
+ * Function: H5FA__test_dst_context
*
- * Purpose: Destroy context for callbacks
+ * Purpose: Destroy context for callbacks
*
- * Return: Success: non-negative
- * Failure: negative
+ * Return: SUCCEED/FAIL
*
- * Programmer: Vailin Choi
+ * Programmer: Vailin Choi
* Thursday, April 30, 2009
*
*-------------------------------------------------------------------------
@@ -183,14 +180,13 @@ END_FUNC(STATIC) /* end H5FA__test_dst_context() */
/*-------------------------------------------------------------------------
- * Function: H5FA__test_fill
+ * Function: H5FA__test_fill
*
- * Purpose: Fill "missing elements" in block of elements
+ * Purpose: Fill "missing elements" in block of elements
*
- * Return: Success: non-negative
- * Failure: negative
+ * Return: SUCCEED/FAIL
*
- * Programmer: Vailin Choi
+ * Programmer: Vailin Choi
* Thursday, April 30, 2009
*
*-------------------------------------------------------------------------
@@ -212,14 +208,13 @@ END_FUNC(STATIC) /* end H5FA__test_fill() */
/*-------------------------------------------------------------------------
- * Function: H5FA__test_encode
+ * Function: H5FA__test_encode
*
- * Purpose: Encode an element from "native" to "raw" form
+ * Purpose: Encode an element from "native" to "raw" form
*
- * Return: Success: non-negative
- * Failure: negative
+ * Return: SUCCEED/FAIL
*
- * Programmer: Vailin Choi
+ * Programmer: Vailin Choi
* Thursday, April 30, 2009
*
*-------------------------------------------------------------------------
@@ -257,14 +252,13 @@ END_FUNC(STATIC) /* end H5FA__test_encode() */
/*-------------------------------------------------------------------------
- * Function: H5FA__test_decode
+ * Function: H5FA__test_decode
*
- * Purpose: Decode an element from "raw" to "native" form
+ * Purpose: Decode an element from "raw" to "native" form
*
- * Return: Success: non-negative
- * Failure: negative
+ * Return: SUCCEED/FAIL
*
- * Programmer: Vailin Choi
+ * Programmer: Vailin Choi
* Thursday, April 30, 2009
*
*-------------------------------------------------------------------------
@@ -303,14 +297,13 @@ END_FUNC(STATIC) /* end H5FA__test_decode() */
/*-------------------------------------------------------------------------
- * Function: H5FA__test_debug
+ * Function: H5FA__test_debug
*
- * Purpose: Display an element for debugging
+ * Purpose: Display an element for debugging
*
- * Return: Success: non-negative
- * Failure: negative
+ * Return: SUCCEED/FAIL
*
- * Programmer: Vailin Choi
+ * Programmer: Vailin Choi
* Thursday, April 30, 2009
*
*-------------------------------------------------------------------------
@@ -336,14 +329,14 @@ END_FUNC(STATIC) /* end H5FA__test_debug() */
/*-------------------------------------------------------------------------
- * Function: H5FA__test_crt_dbg_context
+ * Function: H5FA__test_crt_dbg_context
*
- * Purpose: Create context for debugging callback
+ * Purpose: Create context for debugging callback
*
- * Return: Success: non-NULL
- * Failure: NULL
+ * Return: Success: non-NULL
+ * Failure: NULL
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Tuesday, December 1, 2009
*
*-------------------------------------------------------------------------
@@ -357,7 +350,7 @@ H5FA__test_crt_dbg_context(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id
/* Allocate new context structure */
if(NULL == (ctx = H5FL_MALLOC(H5FA__test_ctx_t)))
- H5E_THROW(H5E_CANTALLOC, "can't allocate fixed array client callback context")
+ H5E_THROW(H5E_CANTALLOC, "can't allocate fixed array client callback context")
/* Initialize the context */
ctx->bogus = H5FA__TEST_BOGUS_VAL;
@@ -371,14 +364,13 @@ END_FUNC(STATIC) /* end H5FA__test_crt_dbg_context() */
/*-------------------------------------------------------------------------
- * Function: H5FA_get_cparam_test
+ * Function: H5FA_get_cparam_test
*
- * Purpose: Retrieve the parameters used to create the fixed array
+ * Purpose: Retrieve the parameters used to create the fixed array
*
- * Return: Success: non-negative
- * Failure: negative
+ * Return: SUCCEED/FAIL
*
- * Programmer: Vailin Choi
+ * Programmer: Vailin Choi
* Thursday, April 30, 2009
*
*-------------------------------------------------------------------------
@@ -399,14 +391,13 @@ END_FUNC(PRIV) /* end H5FA_get_cparam_test() */
/*-------------------------------------------------------------------------
- * Function: H5FA_cmp_cparam_test
+ * Function: H5FA_cmp_cparam_test
*
- * Purpose: Compare the parameters used to create the fixed array
+ * Purpose: Compare the parameters used to create the fixed array
*
- * Return: Success: non-negative
- * Failure: negative
+ * Return: SUCCEED/FAIL
*
- * Programmer: Vailin Choi
+ * Programmer: Vailin Choi
* Thursday, April 30, 2009
*
*-------------------------------------------------------------------------
diff --git a/src/H5FD.c b/src/H5FD.c
index 9e183bd..2a15fe8 100644
--- a/src/H5FD.c
+++ b/src/H5FD.c
@@ -1733,6 +1733,131 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5FDlock
+ *
+ * Purpose: Set a file lock
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Vailin Choi; March 2015
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5FDlock(H5FD_t *file, hbool_t rw)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE2("e", "*xb", file, rw);
+
+ /* Check args */
+ if(!file || !file->cls)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file pointer")
+
+ /* The real work */
+ if(H5FD_lock(file, rw) < 0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "file lock request failed")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5FDlock() */
+
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5FD_lock
+ *
+ * Purpose: Private version of H5FDlock()
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Vailin Choi; May 2013
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5FD_lock(H5FD_t *file, hbool_t rw)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ HDassert(file && file->cls);
+
+ if(file->cls->lock && (file->cls->lock)(file, rw) < 0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTUPDATE, FAIL, "driver lock request failed")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5FD_lock() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5FDunlock
+ *
+ * Purpose: Remove a file lock
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Vailin Choi; March 2015
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5FDunlock(H5FD_t *file)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE1("e", "*x", file);
+
+ /* Check args */
+ if(!file || !file->cls)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file pointer")
+
+ /* The real work */
+ if(H5FD_unlock(file) < 0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "file unlock request failed")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5FDunlock() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5FD_unlock
+ *
+ * Purpose: Private version of H5FDunlock()
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Vailin Choi; May 2013
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5FD_unlock(H5FD_t *file)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ HDassert(file && file->cls);
+
+ if(file->cls->unlock && (file->cls->unlock)(file) < 0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTUPDATE, FAIL, "driver unlock request failed")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5FD_unlock() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5FD_get_fileno
*
* Purpose: Quick and dirty routine to retrieve the file's 'fileno' value
diff --git a/src/H5FDcore.c b/src/H5FDcore.c
index 17ec07c..f4aa240 100644
--- a/src/H5FDcore.c
+++ b/src/H5FDcore.c
@@ -141,6 +141,8 @@ static herr_t H5FD__core_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, ha
size_t size, const void *buf);
static herr_t H5FD__core_flush(H5FD_t *_file, hid_t dxpl_id, unsigned closing);
static herr_t H5FD__core_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing);
+static herr_t H5FD_core_lock(H5FD_t *_file, hbool_t rw);
+static herr_t H5FD_core_unlock(H5FD_t *_file);
static const H5FD_class_t H5FD_core_g = {
"core", /* name */
@@ -172,8 +174,8 @@ static const H5FD_class_t H5FD_core_g = {
H5FD__core_write, /* write */
H5FD__core_flush, /* flush */
H5FD__core_truncate, /* truncate */
- NULL, /* lock */
- NULL, /* unlock */
+ H5FD_core_lock, /* lock */
+ H5FD_core_unlock, /* unlock */
H5FD_FLMAP_DICHOTOMY /* fl_map */
};
@@ -1016,12 +1018,12 @@ H5FD__core_query(const H5FD_t * _file, unsigned long *flags /* out */)
/* Set the VFL feature flags that this driver supports */
if(flags) {
*flags = 0;
- *flags |= H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */
- *flags |= H5FD_FEAT_ACCUMULATE_METADATA; /* OK to accumulate metadata for faster writes */
- *flags |= H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */
- *flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */
- *flags |= H5FD_FEAT_ALLOW_FILE_IMAGE; /* OK to use file image feature with this VFD */
- *flags |= H5FD_FEAT_CAN_USE_FILE_IMAGE_CALLBACKS; /* OK to use file image callbacks with this VFD */
+ *flags |= H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */
+ *flags |= H5FD_FEAT_ACCUMULATE_METADATA; /* OK to accumulate metadata for faster writes */
+ *flags |= H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */
+ *flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */
+ *flags |= H5FD_FEAT_ALLOW_FILE_IMAGE; /* OK to use file image feature with this VFD */
+ *flags |= H5FD_FEAT_CAN_USE_FILE_IMAGE_CALLBACKS; /* OK to use file image callbacks with this VFD */
/* If the backing store is open, a POSIX file handle is available */
if(file && file->fd >= 0 && file->backing_store)
@@ -1520,3 +1522,75 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FD__core_truncate() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5FD_core_lock
+ *
+ * Purpose: To place an advisory lock on a file.
+ * The lock type to apply depends on the parameter "rw":
+ * TRUE--opens for write: an exclusive lock
+ * FALSE--opens for read: a shared lock
+ *
+ * Return: SUCCEED/FAIL
+ *
+ * Programmer: Vailin Choi; May 2013
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5FD_core_lock(H5FD_t *_file, hbool_t rw)
+{
+ H5FD_core_t *file = (H5FD_core_t*)_file; /* VFD file struct */
+ int lock; /* The type of lock */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ HDassert(file);
+ if(file->fd >= 0) {
+
+ /* Determine the type of lock */
+ lock = rw ? LOCK_EX : LOCK_SH;
+
+ /* Place the lock with non-blocking */
+ if(HDflock(file->fd, lock | LOCK_NB) < 0)
+ HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to flock file")
+ }
+ /* Otherwise a noop */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5FD_core_lock() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5FD_core_unlock
+ *
+ * Purpose: To remove the existing lock on the file
+ *
+ * Return: SUCCEED/FAIL
+ *
+ * Programmer: Vailin Choi; May 2013
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5FD_core_unlock(H5FD_t *_file)
+{
+ H5FD_core_t *file = (H5FD_core_t*)_file; /* VFD file struct */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ HDassert(file);
+
+ if(file->fd >= 0) {
+
+ if(HDflock(file->fd, LOCK_UN) < 0)
+ HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to flock (unlock) file")
+ }
+ /* Otherwise a noop */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5FD_core_unlock() */
diff --git a/src/H5FDdirect.c b/src/H5FDdirect.c
index de64923..f88fb1e 100644
--- a/src/H5FDdirect.c
+++ b/src/H5FDdirect.c
@@ -93,6 +93,7 @@ typedef struct H5FD_direct_t {
DWORD fileindexlo;
DWORD fileindexhi;
#endif
+
} H5FD_direct_t;
/*
@@ -136,6 +137,9 @@ static herr_t H5FD_direct_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, ha
static herr_t H5FD_direct_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr,
size_t size, const void *buf);
static herr_t H5FD_direct_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing);
+static herr_t H5FD_direct_lock(H5FD_t *_file, hbool_t rw);
+static herr_t H5FD_direct_unlock(H5FD_t *_file);
+
static const H5FD_class_t H5FD_direct_g = {
"direct", /*name */
@@ -166,10 +170,10 @@ static const H5FD_class_t H5FD_direct_g = {
H5FD_direct_read, /*read */
H5FD_direct_write, /*write */
NULL, /*flush */
- H5FD_direct_truncate, /*truncate */
- NULL, /*lock */
- NULL, /*unlock */
- H5FD_FLMAP_DICHOTOMY /*fl_map */
+ H5FD_direct_truncate, /*truncate */
+ H5FD_direct_lock, /*lock */
+ H5FD_direct_unlock, /*unlock */
+ H5FD_FLMAP_DICHOTOMY /*fl_map */
};
/* Declare a free list to manage the H5FD_direct_t struct */
@@ -689,10 +693,10 @@ H5FD_direct_query(const H5FD_t H5_ATTR_UNUSED * _f, unsigned long *flags /* out
/* Set the VFL feature flags that this driver supports */
if(flags) {
*flags = 0;
- *flags|=H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */
- *flags|=H5FD_FEAT_ACCUMULATE_METADATA; /* OK to accumulate metadata for faster writes */
- *flags|=H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */
- *flags|=H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */
+ *flags |= H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */
+ *flags |= H5FD_FEAT_ACCUMULATE_METADATA; /* OK to accumulate metadata for faster writes */
+ *flags |= H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */
+ *flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */
}
FUNC_LEAVE_NOAPI(SUCCEED)
@@ -1307,5 +1311,72 @@ H5FD_direct_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATT
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FD_direct_truncate() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5FD_direct_lock
+ *
+ * Purpose: To place an advisory lock on a file.
+ * The lock type to apply depends on the parameter "rw":
+ * TRUE--opens for write: an exclusive lock
+ * FALSE--opens for read: a shared lock
+ *
+ * Return: SUCCEED/FAIL
+ *
+ * Programmer: Vailin Choi; May 2013
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5FD_direct_lock(H5FD_t *_file, hbool_t rw)
+{
+ H5FD_direct_t *file = (H5FD_direct_t*)_file; /* VFD file struct */
+ int lock; /* The type of lock */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ HDassert(file);
+
+ /* Determine the type of lock */
+ int lock = rw ? LOCK_EX : LOCK_SH;
+
+ /* Place the lock with non-blocking */
+ if(HDflock(file->fd, lock | LOCK_NB) < 0)
+ HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to flock file")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5FD_direct_lock() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5FD_direct_unlock
+ *
+ * Purpose: To remove the existing lock on the file
+ *
+ * Return: SUCCEED/FAIL
+ *
+ * Programmer: Vailin Choi; May 2013
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5FD_direct_unlock(H5FD_t *_file)
+{
+ H5FD_direct_t *file = (H5FD_direct_t*)_file; /* VFD file struct */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ HDassert(file);
+
+ if(HDflock(file->fd, LOCK_UN) < 0)
+ HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to flock (unlock) file")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5FD_direct_unlock() */
+
#endif /* H5_HAVE_DIRECT */
diff --git a/src/H5FDfamily.c b/src/H5FDfamily.c
index 7a35612..310b72f 100644
--- a/src/H5FDfamily.c
+++ b/src/H5FDfamily.c
@@ -106,6 +106,8 @@ static herr_t H5FD_family_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, h
size_t size, const void *_buf);
static herr_t H5FD_family_flush(H5FD_t *_file, hid_t dxpl_id, unsigned closing);
static herr_t H5FD_family_truncate(H5FD_t *_file, hid_t dxpl_id, unsigned closing);
+static herr_t H5FD_family_lock(H5FD_t *_file, hbool_t rw);
+static herr_t H5FD_family_unlock(H5FD_t *_file);
/* The class struct */
static const H5FD_class_t H5FD_family_g = {
@@ -138,8 +140,8 @@ static const H5FD_class_t H5FD_family_g = {
H5FD_family_write, /*write */
H5FD_family_flush, /*flush */
H5FD_family_truncate, /*truncate */
- NULL, /*lock */
- NULL, /*unlock */
+ H5FD_family_lock, /*lock */
+ H5FD_family_unlock, /*unlock */
H5FD_FLMAP_DICHOTOMY /*fl_map */
};
@@ -1302,3 +1304,79 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FD_family_truncate() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5FD_family_lock
+ *
+ * Purpose: To place an advisory lock on a file.
+ * The lock type to apply depends on the parameter "rw":
+ * TRUE--opens for write: an exclusive lock
+ * FALSE--opens for read: a shared lock
+ *
+ * Return: SUCCEED/FAIL
+ *
+ * Programmer: Vailin Choi; May 2013
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5FD_family_lock(H5FD_t *_file, hbool_t rw)
+{
+ H5FD_family_t *file = (H5FD_family_t *)_file; /* VFD file struct */
+ unsigned u, i; /* Local index variable */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ /* Place the lock on all the member files */
+ for(u = 0; u < file->nmembs; u++) {
+ if(file->memb[u]) {
+ if(H5FD_lock(file->memb[u], rw) < 0)
+ break;
+ } /* end if */
+ } /* end for */
+
+ if(u < file->nmembs) { /* Try to unlock the member files done before */
+ for(i = 0; i < u; i++) {
+ if(H5FD_unlock(file->memb[i]) < 0)
+ /* Push error, but keep going*/
+ HDONE_ERROR(H5E_IO, H5E_CANTUNLOCK, FAIL, "unable to unlock member files")
+ }
+ HGOTO_ERROR(H5E_IO, H5E_CANTLOCK, FAIL, "unable to lock member files")
+ } /* end if */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5FD_family_lock() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5FD_family_unlock
+ *
+ * Purpose: To remove the existing lock on the file
+ *
+ * Return: SUCCEED/FAIL
+ *
+ * Programmer: Vailin Choi; May 2013
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5FD_family_unlock(H5FD_t *_file)
+{
+ H5FD_family_t *file = (H5FD_family_t *)_file; /* VFD file struct */
+ unsigned u; /* Local index variable */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ /* Remove the lock on the member files */
+ for(u = 0; u < file->nmembs; u++) {
+ if(file->memb[u]) {
+ if(H5FD_unlock(file->memb[u]) < 0)
+ HGOTO_ERROR(H5E_IO, H5E_CANTUNLOCK, FAIL, "unable to unlock member files")
+ } /* end if */
+ } /* end for */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5FD_family_unlock() */
diff --git a/src/H5FDlog.c b/src/H5FDlog.c
index eb2c0e3..a8228e0 100644
--- a/src/H5FDlog.c
+++ b/src/H5FDlog.c
@@ -179,6 +179,8 @@ static herr_t H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr
static herr_t H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr,
size_t size, const void *buf);
static herr_t H5FD_log_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing);
+static herr_t H5FD_log_lock(H5FD_t *_file, hbool_t rw);
+static herr_t H5FD_log_unlock(H5FD_t *_file);
static const H5FD_class_t H5FD_log_g = {
"log", /*name */
@@ -210,8 +212,8 @@ static const H5FD_class_t H5FD_log_g = {
H5FD_log_write, /*write */
NULL, /*flush */
H5FD_log_truncate, /*truncate */
- NULL, /*lock */
- NULL, /*unlock */
+ H5FD_log_lock, /*lock */
+ H5FD_log_unlock, /*unlock */
H5FD_FLMAP_DICHOTOMY /*fl_map */
};
@@ -888,11 +890,11 @@ H5FD_log_query(const H5FD_t *_file, unsigned long *flags /* out */)
/* Set the VFL feature flags that this driver supports */
if(flags) {
*flags = 0;
- *flags |= H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */
- *flags |= H5FD_FEAT_ACCUMULATE_METADATA; /* OK to accumulate metadata for faster writes */
- *flags |= H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */
- *flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */
- *flags |= H5FD_FEAT_POSIX_COMPAT_HANDLE; /* VFD handle is POSIX I/O call compatible */
+ *flags |= H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */
+ *flags |= H5FD_FEAT_ACCUMULATE_METADATA; /* OK to accumulate metadata for faster writes */
+ *flags |= H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */
+ *flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */
+ *flags |= H5FD_FEAT_POSIX_COMPAT_HANDLE; /* VFD handle is POSIX I/O call compatible */
/* Check for flags that are set by h5repart */
if(file && file->fam_to_sec2)
@@ -1556,3 +1558,68 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FD_log_truncate() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5FD_log_lock
+ *
+ * Purpose: Place a lock on the file
+ *
+ * Return: Success: SUCCEED
+ * Failure: FAIL, file not locked.
+ *
+ * Programmer: Vailin Choi; May 2013
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5FD_log_lock(H5FD_t *_file, hbool_t rw)
+{
+ H5FD_log_t *file = (H5FD_log_t *)_file;
+ int lock;
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ /* Sanity check */
+ HDassert(file);
+
+ /* Determine the type of lock */
+ lock = rw ? LOCK_EX : LOCK_SH;
+
+ /* Place the lock with non-blocking */
+ if(HDflock(file->fd, lock | LOCK_NB) < 0)
+ HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to flock file")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5FD_log_lock() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5FD_log_unlock
+ *
+ * Purpose: Remove the existing lock on the file
+ *
+ * Return: SUCCEED/FAIL
+ *
+ * Programmer: Vailin Choi; May 2013
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5FD_log_unlock(H5FD_t *_file)
+{
+ H5FD_log_t *file = (H5FD_log_t *)_file; /* VFD file struct */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ HDassert(file);
+
+ if(HDflock(file->fd, LOCK_UN) < 0)
+ HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to flock (unlock) file")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5FD_log_unlock() */
+
diff --git a/src/H5FDmulti.c b/src/H5FDmulti.c
index bc61374..181ad39 100644
--- a/src/H5FDmulti.c
+++ b/src/H5FDmulti.c
@@ -46,14 +46,14 @@
/* Loop through all mapped files */
#define UNIQUE_MEMBERS(MAP,LOOPVAR) { \
H5FD_mem_t _unmapped, LOOPVAR; \
- hbool_t _seen[H5FD_MEM_NTYPES]; \
+ unsigned _seen[H5FD_MEM_NTYPES]; \
\
- memset(_seen, 0, sizeof _seen); \
+ memset(_seen, 0, sizeof _seen); \
for (_unmapped=H5FD_MEM_SUPER; _unmapped<H5FD_MEM_NTYPES; _unmapped=(H5FD_mem_t)(_unmapped+1)) { \
LOOPVAR = MAP[_unmapped]; \
if (H5FD_MEM_DEFAULT==LOOPVAR) LOOPVAR=_unmapped; \
assert(LOOPVAR>0 && LOOPVAR<H5FD_MEM_NTYPES); \
- if (_seen[LOOPVAR]++) continue;
+ if (_seen[LOOPVAR]++) continue; \
#define ALL_MEMBERS(LOOPVAR) { \
H5FD_mem_t LOOPVAR; \
@@ -135,6 +135,8 @@ static herr_t H5FD_multi_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, ha
size_t size, const void *_buf);
static herr_t H5FD_multi_flush(H5FD_t *_file, hid_t dxpl_id, unsigned closing);
static herr_t H5FD_multi_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing);
+static herr_t H5FD_multi_lock(H5FD_t *_file, hbool_t rw);
+static herr_t H5FD_multi_unlock(H5FD_t *_file);
/* The class struct */
static const H5FD_class_t H5FD_multi_g = {
@@ -167,8 +169,8 @@ static const H5FD_class_t H5FD_multi_g = {
H5FD_multi_write, /*write */
H5FD_multi_flush, /*flush */
H5FD_multi_truncate, /*truncate */
- NULL, /*lock */
- NULL, /*unlock */
+ H5FD_multi_lock, /*lock */
+ H5FD_multi_unlock, /*unlock */
H5FD_FLMAP_DEFAULT /*fl_map */
};
@@ -1786,6 +1788,101 @@ H5FD_multi_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing)
/*-------------------------------------------------------------------------
+ * Function: H5FD_multi_lock
+ *
+ * Purpose: Place a lock on all multi members.
+ * When there is error in locking a member file, it will not
+ * proceed further and will try to remove the locks of those
+ * member files that are locked before error is encountered.
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Vailin Choi; March 2015
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5FD_multi_lock(H5FD_t *_file, hbool_t rw)
+{
+ H5FD_multi_t *file = (H5FD_multi_t*)_file;
+ int nerrors = 0;
+ H5FD_mem_t out_mt;
+ static const char *func="H5FD_multi_unlock"; /* Function Name for error reporting */
+
+ /* Clear the error stack */
+ H5Eclear2(H5E_DEFAULT);
+
+ /* Lock all member files */
+ ALL_MEMBERS(mt) {
+ out_mt = mt;
+ if(file->memb[mt]) {
+ H5E_BEGIN_TRY {
+ if(H5FDlock(file->memb[mt], rw) < 0) {
+ nerrors++;
+ break;
+ } /* end if */
+ } H5E_END_TRY;
+ } /* end if */
+ } END_MEMBERS;
+
+ /* Try to unlock the member files that are locked before error is encountered */
+ if(nerrors) {
+ H5FD_mem_t k;
+
+ for(k = H5FD_MEM_DEFAULT; k < out_mt; k = (H5FD_mem_t)(k + 1)) {
+ H5E_BEGIN_TRY {
+ if(H5FDunlock(file->memb[k]) < 0)
+ nerrors++;
+ } H5E_END_TRY;
+ } /* end for */
+ } /* end if */
+
+ if(nerrors)
+ H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "error locking member files", -1)
+ return 0;
+
+} /* H5FD_multi_lock() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5FD_multi_unlock
+ *
+ * Purpose: Remove the lock on all multi members.
+ * It will try to unlock all member files but will record error
+ * encountered.
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Vailin Choi; March 2015
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5FD_multi_unlock(H5FD_t *_file)
+{
+ H5FD_multi_t *file = (H5FD_multi_t*)_file;
+ int nerrors=0;
+ static const char *func="H5FD_multi_unlock"; /* Function Name for error reporting */
+
+ /* Clear the error stack */
+ H5Eclear2(H5E_DEFAULT);
+
+ ALL_MEMBERS(mt) {
+ if(file->memb[mt])
+ if(H5FDunlock(file->memb[mt]) < 0)
+ nerrors++;
+ } END_MEMBERS;
+
+ if(nerrors)
+ H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "error unlocking member files", -1)
+
+ return 0;
+} /* H5FD_multi_unlock() */
+
+
+/*-------------------------------------------------------------------------
* Function: compute_next
*
* Purpose: Compute the memb_next[] values of the file based on the
diff --git a/src/H5FDpkg.h b/src/H5FDpkg.h
index ef33cf1..a0c1b3a 100644
--- a/src/H5FDpkg.h
+++ b/src/H5FDpkg.h
@@ -57,8 +57,7 @@ H5_DLL haddr_t H5FD_alloc_real(H5FD_t *file, hid_t dxpl_id, H5FD_mem_t type,
H5_DLL herr_t H5FD_free_real(H5FD_t *file, hid_t dxpl_id, H5FD_mem_t type,
haddr_t addr, hsize_t size);
-
-/* Testing routines */
+/* Testing functions */
#ifdef H5FD_TESTING
#endif /* H5FD_TESTING */
diff --git a/src/H5FDprivate.h b/src/H5FDprivate.h
index 412bbef..0f195ce 100644
--- a/src/H5FDprivate.h
+++ b/src/H5FDprivate.h
@@ -141,6 +141,8 @@ H5_DLL herr_t H5FD_write(H5FD_t *file, const H5P_genplist_t *dxpl, H5FD_mem_t ty
haddr_t addr, size_t size, const void *buf);
H5_DLL herr_t H5FD_flush(H5FD_t *file, hid_t dxpl_id, unsigned closing);
H5_DLL herr_t H5FD_truncate(H5FD_t *file, hid_t dxpl_id, hbool_t closing);
+H5_DLL herr_t H5FD_lock(H5FD_t *file, hbool_t rw);
+H5_DLL herr_t H5FD_unlock(H5FD_t *file);
H5_DLL herr_t H5FD_get_fileno(const H5FD_t *file, unsigned long *filenum);
H5_DLL herr_t H5FD_get_vfd_handle(H5FD_t *file, hid_t fapl, void** file_handle);
H5_DLL herr_t H5FD_set_base_addr(H5FD_t *file, haddr_t base_addr);
diff --git a/src/H5FDpublic.h b/src/H5FDpublic.h
index 58066cc..4183d14 100644
--- a/src/H5FDpublic.h
+++ b/src/H5FDpublic.h
@@ -156,13 +156,13 @@ typedef enum H5F_mem_t H5FD_mem_t;
/* Define VFL driver features that can be enabled on a per-driver basis */
/* These are returned with the 'query' function pointer in H5FD_class_t */
/*
- * Defining the H5FD_FEAT_AGGREGATE_METADATA for a VFL driver means that
+ * Defining H5FD_FEAT_AGGREGATE_METADATA for a VFL driver means that
* the library will attempt to allocate a larger block for metadata and
* then sub-allocate each metadata request from that larger block.
*/
#define H5FD_FEAT_AGGREGATE_METADATA 0x00000001
/*
- * Defining the H5FD_FEAT_ACCUMULATE_METADATA for a VFL driver means that
+ * Defining H5FD_FEAT_ACCUMULATE_METADATA for a VFL driver means that
* the library will attempt to cache metadata as it is written to the file
* and build up a larger block of metadata to eventually pass to the VFL
* 'write' routine.
@@ -177,7 +177,7 @@ typedef enum H5F_mem_t H5FD_mem_t;
#define H5FD_FEAT_ACCUMULATE_METADATA_READ 0x00000004
#define H5FD_FEAT_ACCUMULATE_METADATA (H5FD_FEAT_ACCUMULATE_METADATA_WRITE|H5FD_FEAT_ACCUMULATE_METADATA_READ)
/*
- * Defining the H5FD_FEAT_DATA_SIEVE for a VFL driver means that
+ * Defining H5FD_FEAT_DATA_SIEVE for a VFL driver means that
* the library will attempt to cache raw data as it is read from/written to
* a file in a "data seive" buffer. See Rajeev Thakur's papers:
* http://www.mcs.anl.gov/~thakur/papers/romio-coll.ps.gz
@@ -185,13 +185,13 @@ typedef enum H5F_mem_t H5FD_mem_t;
*/
#define H5FD_FEAT_DATA_SIEVE 0x00000008
/*
- * Defining the H5FD_FEAT_AGGREGATE_SMALLDATA for a VFL driver means that
+ * Defining H5FD_FEAT_AGGREGATE_SMALLDATA for a VFL driver means that
* the library will attempt to allocate a larger block for "small" raw data
* and then sub-allocate "small" raw data requests from that larger block.
*/
#define H5FD_FEAT_AGGREGATE_SMALLDATA 0x00000010
/*
- * Defining the H5FD_FEAT_IGNORE_DRVRINFO for a VFL driver means that
+ * Defining H5FD_FEAT_IGNORE_DRVRINFO for a VFL driver means that
* the library will ignore the driver info that is encoded in the file
* for the VFL driver. (This will cause the driver info to be eliminated
* from the file when it is flushed/closed, if the file is opened R/W).
@@ -205,13 +205,13 @@ typedef enum H5F_mem_t H5FD_mem_t;
*/
#define H5FD_FEAT_DIRTY_DRVRINFO_LOAD 0x00000040
/*
- * Defining the H5FD_FEAT_POSIX_COMPAT_HANDLE for a VFL driver means that
+ * Defining H5FD_FEAT_POSIX_COMPAT_HANDLE for a VFL driver means that
* the handle for the VFD (returned with the 'get_handle' callback) is
* of type 'int' and is compatible with POSIX I/O calls.
*/
#define H5FD_FEAT_POSIX_COMPAT_HANDLE 0x00000080
/*
- * Defining the H5FD_FEAT_HAS_MPI for a VFL driver means that
+ * Defining H5FD_FEAT_HAS_MPI for a VFL driver means that
* the driver makes use of MPI communication and code may retrieve
* communicator/rank information from it
*/
@@ -223,13 +223,13 @@ typedef enum H5F_mem_t H5FD_mem_t;
*/
#define H5FD_FEAT_ALLOCATE_EARLY 0x00000200
/*
- * Defining the H5FD_FEAT_ALLOW_FILE_IMAGE for a VFL driver means that
+ * Defining H5FD_FEAT_ALLOW_FILE_IMAGE for a VFL driver means that
* the driver is able to use a file image in the fapl as the initial
* contents of a file.
*/
#define H5FD_FEAT_ALLOW_FILE_IMAGE 0x00000400
/*
- * Defining the H5FD_FEAT_CAN_USE_FILE_IMAGE_CALLBACKS for a VFL driver
+ * Defining H5FD_FEAT_CAN_USE_FILE_IMAGE_CALLBACKS for a VFL driver
* means that the driver is able to use callbacks to make a copy of the
* image to store in memory.
*/
@@ -274,8 +274,8 @@ typedef struct H5FD_class_t {
haddr_t addr, size_t size, const void *buffer);
herr_t (*flush)(H5FD_t *file, hid_t dxpl_id, unsigned closing);
herr_t (*truncate)(H5FD_t *file, hid_t dxpl_id, hbool_t closing);
- herr_t (*lock)(H5FD_t *file, unsigned char *oid, unsigned lock_type, hbool_t last);
- herr_t (*unlock)(H5FD_t *file, unsigned char *oid, hbool_t last);
+ herr_t (*lock)(H5FD_t *file, hbool_t rw);
+ herr_t (*unlock)(H5FD_t *file);
H5FD_mem_t fl_map[H5FD_MEM_NTYPES];
} H5FD_class_t;
@@ -355,6 +355,8 @@ H5_DLL herr_t H5FDwrite(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id,
haddr_t addr, size_t size, const void *buf);
H5_DLL herr_t H5FDflush(H5FD_t *file, hid_t dxpl_id, unsigned closing);
H5_DLL herr_t H5FDtruncate(H5FD_t *file, hid_t dxpl_id, hbool_t closing);
+H5_DLL herr_t H5FDlock(H5FD_t *file, hbool_t rw);
+H5_DLL herr_t H5FDunlock(H5FD_t *file);
#ifdef __cplusplus
}
diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c
index 34527df..bb8f004 100644
--- a/src/H5FDsec2.c
+++ b/src/H5FDsec2.c
@@ -97,6 +97,7 @@ typedef struct H5FD_sec2_t {
* a single file.
*/
hbool_t fam_to_sec2;
+
} H5FD_sec2_t;
/*
@@ -137,6 +138,8 @@ static herr_t H5FD_sec2_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, hadd
static herr_t H5FD_sec2_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr,
size_t size, const void *buf);
static herr_t H5FD_sec2_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing);
+static herr_t H5FD_sec2_lock(H5FD_t *_file, hbool_t rw);
+static herr_t H5FD_sec2_unlock(H5FD_t *_file);
static const H5FD_class_t H5FD_sec2_g = {
"sec2", /* name */
@@ -168,8 +171,8 @@ static const H5FD_class_t H5FD_sec2_g = {
H5FD_sec2_write, /* write */
NULL, /* flush */
H5FD_sec2_truncate, /* truncate */
- NULL, /* lock */
- NULL, /* unlock */
+ H5FD_sec2_lock, /* lock */
+ H5FD_sec2_unlock, /* unlock */
H5FD_FLMAP_DICHOTOMY /* fl_map */
};
@@ -901,3 +904,69 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FD_sec2_truncate() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5FD_sec2_lock
+ *
+ * Purpose: To place an advisory lock on a file.
+ * The lock type to apply depends on the parameter "rw":
+ * TRUE--opens for write: an exclusive lock
+ * FALSE--opens for read: a shared lock
+ *
+ * Return: SUCCEED/FAIL
+ *
+ * Programmer: Vailin Choi; May 2013
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5FD_sec2_lock(H5FD_t *_file, hbool_t rw)
+{
+ H5FD_sec2_t *file = (H5FD_sec2_t *)_file; /* VFD file struct */
+ int lock; /* The type of lock */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ HDassert(file);
+
+ /* Determine the type of lock */
+ lock = rw ? LOCK_EX : LOCK_SH;
+
+ /* Place the lock with non-blocking */
+ if(HDflock(file->fd, lock | LOCK_NB) < 0)
+ HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to flock file")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5FD_sec2_lock() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5FD_sec2_unlock
+ *
+ * Purpose: To remove the existing lock on the file
+ *
+ * Return: SUCCEED/FAIL
+ *
+ * Programmer: Vailin Choi; May 2013
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5FD_sec2_unlock(H5FD_t *_file)
+{
+ H5FD_sec2_t *file = (H5FD_sec2_t *)_file; /* VFD file struct */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ HDassert(file);
+
+ if(HDflock(file->fd, LOCK_UN) < 0)
+ HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to flock (unlock) file")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5FD_sec2_unlock() */
+
diff --git a/src/H5FDstdio.c b/src/H5FDstdio.c
index 686e1fc..d5b3d40 100644
--- a/src/H5FDstdio.c
+++ b/src/H5FDstdio.c
@@ -31,6 +31,11 @@
#include "hdf5.h"
+#ifdef H5_HAVE_FLOCK
+/* Needed for lock type definitions (e.g., LOCK_EX) */
+#include <sys/file.h>
+#endif /* H5_HAVE_FLOCK */
+
#ifdef H5_HAVE_UNISTD_H
#include <unistd.h>
#endif
@@ -179,6 +184,8 @@ static herr_t H5FD_stdio_write(H5FD_t *lf, H5FD_mem_t type, hid_t fapl_id, haddr
size_t size, const void *buf);
static herr_t H5FD_stdio_flush(H5FD_t *_file, hid_t dxpl_id, unsigned closing);
static herr_t H5FD_stdio_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing);
+static herr_t H5FD_stdio_lock(H5FD_t *_file, hbool_t rw);
+static herr_t H5FD_stdio_unlock(H5FD_t *_file);
static const H5FD_class_t H5FD_stdio_g = {
"stdio", /* name */
@@ -210,8 +217,8 @@ static const H5FD_class_t H5FD_stdio_g = {
H5FD_stdio_write, /* write */
H5FD_stdio_flush, /* flush */
H5FD_stdio_truncate, /* truncate */
- NULL, /* lock */
- NULL, /* unlock */
+ H5FD_stdio_lock, /* lock */
+ H5FD_stdio_unlock, /* unlock */
H5FD_FLMAP_DICHOTOMY /* fl_map */
};
@@ -439,7 +446,7 @@ H5FD_stdio_open( const char *name, unsigned flags, hid_t /*UNUSED*/ fapl_id,
file->inode = sb.st_ino;
#endif /* H5_HAVE_WIN32_API */
- return (H5FD_t*)file;
+ return((H5FD_t*)file);
} /* end H5FD_stdio_open() */
@@ -704,6 +711,9 @@ H5FD_stdio_get_eof(const H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type)
/* Clear the error stack */
H5Eclear2(H5E_DEFAULT);
+ /* Quiet the compiler */
+ type = type;
+
return(file->eof);
} /* end H5FD_stdio_get_eof() */
@@ -1073,6 +1083,87 @@ H5FD_stdio_truncate(H5FD_t *_file, hid_t /*UNUSED*/ dxpl_id,
} /* end H5FD_stdio_truncate() */
+/*-------------------------------------------------------------------------
+ * Function: H5FD_stdio_lock
+ *
+ * Purpose: Lock a file via flock
+ *
+ * NOTE: This function is a no-op if flock() is not present.
+ * Errors:
+ * IO FCNTL flock failed.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Vailin Choi; March 2015
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5FD_stdio_lock(H5FD_t *_file, hbool_t rw)
+{
+#ifdef H5_HAVE_FLOCK
+ H5FD_stdio_t *file = (H5FD_stdio_t*)_file;
+ int lock; /* The type of lock */
+ static const char *func = "H5FD_stdio_lock"; /* Function Name for error reporting */
+
+ /* Clear the error stack */
+ H5Eclear2(H5E_DEFAULT);
+
+ assert(file);
+
+ /* Determine the type of lock */
+ lock = rw ? LOCK_EX : LOCK_SH;
+
+ /* Place the lock with non-blocking */
+ if(flock(file->fd, lock | LOCK_NB) < 0)
+ H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_FCNTL, "flock failed", -1)
+ if(fflush(file->fp) < 0)
+ H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_WRITEERROR, "fflush failed", -1)
+
+#endif /* H5_HAVE_FLOCK */
+
+ return 0;
+} /* end H5FD_stdio_lock() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5F_stdio_unlock
+ *
+ * Purpose: Unlock a file via flock
+ *
+ *
+ * NOTE: This function is a no-op if flock() is not present.
+ * Errors:
+ * IO FCNTL flock failed.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Vailin Choi; March 2015
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5FD_stdio_unlock(H5FD_t *_file)
+{
+#ifdef H5_HAVE_FLOCK
+ H5FD_stdio_t *file = (H5FD_stdio_t*)_file;
+ static const char *func = "H5FD_stdio_unlock"; /* Function Name for error reporting */
+
+ /* Clear the error stack */
+ H5Eclear2(H5E_DEFAULT);
+
+ assert(file);
+
+ if(fflush(file->fp) < 0)
+ H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_WRITEERROR, "fflush failed", -1)
+ if(flock(file->fd, LOCK_UN) < 0)
+ H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_FCNTL, "flock (unlock) failed", -1)
+
+#endif /* H5_HAVE_FLOCK */
+
+ return 0;
+} /* end H5FD_stdio_unlock() */
+
+
#ifdef _H5private_H
/*
* This is not related to the functionality of the driver code.
diff --git a/src/H5FL.c b/src/H5FL.c
index fb355ad..00cbf0c 100644
--- a/src/H5FL.c
+++ b/src/H5FL.c
@@ -314,8 +314,7 @@ done:
*
* Purpose: Release an object & put on free list
*
- * Return: Success: Non-negative
- * Failure: Negative
+ * Return: Always returns NULL
*
* Programmer: Quincey Koziol
* Friday, March 24, 2000
diff --git a/src/H5FS.c b/src/H5FS.c
index 8e5985f..90f04ac 100644
--- a/src/H5FS.c
+++ b/src/H5FS.c
@@ -14,12 +14,12 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
- * Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu>
+ * Programmer: Quincey Koziol <koziol@hdfgroup.org>
* Tuesday, May 2, 2006
*
- * Purpose: Free space tracking functions.
+ * Purpose: Free space tracking functions.
*
- * Note: (Used to be in the H5HFflist.c file, prior to the date above)
+ * Note: (Used to be in the H5HFflist.c file, prior to the date above)
*
*/
@@ -33,11 +33,11 @@
/***********/
/* Headers */
/***********/
-#include "H5private.h" /* Generic Functions */
-#include "H5ACprivate.h" /* Metadata cache */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5FSpkg.h" /* File free space */
-#include "H5MFprivate.h" /* File memory management */
+#include "H5private.h" /* Generic Functions */
+#include "H5ACprivate.h" /* Metadata cache */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5FSpkg.h" /* File free space */
+#include "H5MFprivate.h" /* File memory management */
/****************/
@@ -90,21 +90,16 @@ H5FL_DEFINE(H5FS_t);
/*-------------------------------------------------------------------------
- * Function: H5FS_create
+ * Function: H5FS_create
*
- * Purpose: Allocate & initialize file free space info
+ * Purpose: Allocate & initialize file free space info
*
- * Return: Success: Pointer to free space structure
+ * Return: Success: Pointer to free space structure
+ * Failure: NULL
*
- * Failure: NULL
- *
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Tuesday, March 7, 2006
*
- * Modifications:
- * Vailin Choi, July 29th, 2008
- * Add two more parameters for handling alignment: alignment & threshhold
- *
*-------------------------------------------------------------------------
*/
H5FS_t *
@@ -129,7 +124,7 @@ HDfprintf(stderr, "%s: Creating free space manager, nclasses = %Zu\n", FUNC, ncl
* Allocate free space structure
*/
if(NULL == (fspace = H5FS__new(f, nclasses, classes, cls_init_udata)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for free space free list")
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for free space free list")
/* Initialize creation information for free space manager */
fspace->client = fs_create->client;
@@ -177,31 +172,25 @@ HDfprintf(stderr, "%s: Leaving, ret_value = %d\n", FUNC, ret_value);
/*-------------------------------------------------------------------------
- * Function: H5FS_open
+ * Function: H5FS_open
*
- * Purpose: Open an existing file free space info structure on disk
+ * Purpose: Open an existing file free space info structure on disk
*
- * Return: Success: Pointer to free space structure
+ * Return: Success: Pointer to free space structure
+ * Failure: NULL
*
- * Failure: NULL
- *
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Tuesday, May 2, 2006
*
- * Modfications:
- *
- * Vailin Choi, July 29th, 2008
- * Add two more parameters for handling alignment: alignment & threshhold
- *
*-------------------------------------------------------------------------
*/
H5FS_t *
H5FS_open(H5F_t *f, hid_t dxpl_id, haddr_t fs_addr, uint16_t nclasses,
const H5FS_section_class_t *classes[], void *cls_init_udata, hsize_t alignment, hsize_t threshold)
{
- H5FS_t *fspace = NULL; /* New free space structure */
- H5FS_hdr_cache_ud_t cache_udata; /* User-data for metadata cache callback */
- H5FS_t *ret_value = NULL; /* Return value */
+ H5FS_t *fspace = NULL; /* New free space structure */
+ H5FS_hdr_cache_ud_t cache_udata; /* User-data for metadata cache callback */
+ H5FS_t *ret_value = NULL; /* Return value */
FUNC_ENTER_NOAPI_TAG(dxpl_id, H5AC__FREESPACE_TAG, NULL)
#ifdef H5FS_DEBUG
@@ -252,15 +241,13 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FS_delete
+ * Function: H5FS_delete
*
- * Purpose: Delete a free space manager on disk
+ * Purpose: Delete a free space manager on disk
*
- * Return: Success: non-negative
+ * Return: SUCCEED/FAIL
*
- * Failure: negative
- *
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Tuesday, May 30, 2006
*
*-------------------------------------------------------------------------
@@ -404,16 +391,14 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FS_close
+ * Function: H5FS_close
*
- * Purpose: Destroy & deallocate free list structure, serializing sections
+ * Purpose: Destroy & deallocate free list structure, serializing sections
* in the bins
*
- * Return: Success: non-negative
- *
- * Failure: negative
+ * Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Tuesday, March 7, 2006
*
*-------------------------------------------------------------------------
@@ -467,9 +452,9 @@ HDfprintf(stderr, "%s: Real sections to store in file\n", FUNC);
HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL, "unable to mark free space header as dirty")
} /* end if */
} /* end if */
- else
- /* Sanity check that section info has address */
- HDassert(H5F_addr_defined(fspace->sect_addr));
+ else
+ /* Sanity check that section info has address */
+ HDassert(H5F_addr_defined(fspace->sect_addr));
/* Cache the free space section info */
if(H5AC_insert_entry(f, dxpl_id, H5AC_FSPACE_SINFO, fspace->sect_addr, fspace->sinfo, H5AC__NO_FLAGS_SET) < 0)
@@ -591,12 +576,12 @@ HDfprintf(stderr, "%s: Leaving, ret_value = %d, fspace->rc = %u\n", FUNC, ret_va
/*-------------------------------------------------------------------------
* Function: H5FS__new
*
- * Purpose: Create new free space manager structure
+ * Purpose: Create new free space manager structure
*
- * Return: Success: non-NULL, pointer to new free space manager struct
- * Failure: NULL
+ * Return: Success: non-NULL, pointer to new free space manager struct
+ * Failure: NULL
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Monday, July 31, 2006
*
*-------------------------------------------------------------------------
@@ -618,7 +603,7 @@ H5FS__new(const H5F_t *f, uint16_t nclasses, const H5FS_section_class_t *classes
* Allocate free space structure
*/
if(NULL == (fspace = H5FL_CALLOC(H5FS_t)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for free space free list")
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for free space free list")
/* Set immutable free list parameters */
H5_CHECKED_ASSIGN(fspace->nclasses, unsigned, nclasses, size_t);
@@ -673,8 +658,7 @@ done:
*
* Purpose: Collect meta storage info used by the free space manager
*
- * Return: Success: non-negative
- * Failure: negative
+ * Return: SUCCEED (Can't fail)
*
* Programmer: Vailin Choi
* June 19, 2007
@@ -705,8 +689,7 @@ H5FS_size(const H5F_t *f, const H5FS_t *fspace, hsize_t *meta_size)
*
* Purpose: Increment reference count on free space header
*
- * Return: Success: non-negative
- * Failure: negative
+ * Return: SUCCEED/FAIL
*
* Programmer: Quincey Koziol
* February 7, 2008
@@ -746,8 +729,7 @@ done:
*
* Purpose: Decrement reference count on free space header
*
- * Return: Success: non-negative
- * Failure: negative
+ * Return: SUCCEED/FAIL
*
* Programmer: Quincey Koziol
* February 7, 2008
@@ -790,15 +772,14 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FS_dirty
+ * Function: H5FS_dirty
*
- * Purpose: Mark free space header as dirty
+ * Purpose: Mark free space header as dirty
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
- * koziol@hdfgroup.org
- * Feb 14 2008
+ * Programmer: Quincey Koziol
+ * Feb 14 2008
*
*-------------------------------------------------------------------------
*/
@@ -827,20 +808,21 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FS_alloc_hdr()
+ * Function: H5FS_alloc_hdr()
*
- * Purpose: Allocate space for the free-space manager header
+ * Purpose: Allocate space for the free-space manager header
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
- * Programmer: Vailin Choi; Feb 2009
+ * Programmer: Vailin Choi
+ * Feb 2009
*
*-------------------------------------------------------------------------
*/
herr_t
H5FS_alloc_hdr(H5F_t *f, H5FS_t *fspace, haddr_t *fs_addr, hid_t dxpl_id)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_TAG(dxpl_id, H5AC__FREESPACE_TAG, FAIL)
@@ -849,17 +831,17 @@ H5FS_alloc_hdr(H5F_t *f, H5FS_t *fspace, haddr_t *fs_addr, hid_t dxpl_id)
HDassert(fspace);
if(!H5F_addr_defined(fspace->addr)) {
- /* Allocate space for the free space header */
- if(HADDR_UNDEF == (fspace->addr = H5MF_alloc(f, H5FD_MEM_FSPACE_HDR, dxpl_id, (hsize_t)H5FS_HEADER_SIZE(f))))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for free space header")
+ /* Allocate space for the free space header */
+ if(HADDR_UNDEF == (fspace->addr = H5MF_alloc(f, H5FD_MEM_FSPACE_HDR, dxpl_id, (hsize_t)H5FS_HEADER_SIZE(f))))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for free space header")
- /* Cache the new free space header (pinned) */
- if(H5AC_insert_entry(f, dxpl_id, H5AC_FSPACE_HDR, fspace->addr, fspace, H5AC__PIN_ENTRY_FLAG) < 0)
- HGOTO_ERROR(H5E_FSPACE, H5E_CANTINIT, FAIL, "can't add free space header to cache")
+ /* Cache the new free space header (pinned) */
+ if(H5AC_insert_entry(f, dxpl_id, H5AC_FSPACE_HDR, fspace->addr, fspace, H5AC__PIN_ENTRY_FLAG) < 0)
+ HGOTO_ERROR(H5E_FSPACE, H5E_CANTINIT, FAIL, "can't add free space header to cache")
} /* end if */
if(fs_addr)
- *fs_addr = fspace->addr;
+ *fs_addr = fspace->addr;
done:
FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL)
@@ -867,20 +849,21 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FS_alloc_sect()
+ * Function: H5FS_alloc_sect()
*
- * Purpose: Allocate space for the free-space manager section info header
+ * Purpose: Allocate space for the free-space manager section info header
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
- * Programmer: Vailin Choi; Feb 2009
+ * Programmer: Vailin Choi
+ * Feb 2009
*
*-------------------------------------------------------------------------
*/
herr_t
H5FS_alloc_sect(H5F_t *f, H5FS_t *fspace, hid_t dxpl_id)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_TAG(dxpl_id, H5AC__FREESPACE_TAG, FAIL)
@@ -889,22 +872,22 @@ H5FS_alloc_sect(H5F_t *f, H5FS_t *fspace, hid_t dxpl_id)
HDassert(fspace);
if(!H5F_addr_defined(fspace->sect_addr) && fspace->sinfo && fspace->serial_sect_count > 0) {
- /* Allocate space for section info from aggregator/vfd (or temp. address space) */
+ /* Allocate space for section info from aggregator/vfd (or temp. address space) */
/* (The original version called H5MF_alloc(), but that may cause sect_size to change again) */
/* (This routine is only called during file close operations, so don't allocate from temp. address space) */
if(HADDR_UNDEF == (fspace->sect_addr = H5MF_aggr_vfd_alloc(f, H5FD_MEM_FSPACE_SINFO, dxpl_id, fspace->sect_size)))
HGOTO_ERROR(H5E_FSPACE, H5E_NOSPACE, FAIL, "file allocation failed for section info")
- fspace->alloc_sect_size = fspace->sect_size;
+ fspace->alloc_sect_size = fspace->sect_size;
- /* Mark free-space header as dirty */
- if(H5FS_dirty(fspace) < 0)
+ /* Mark free-space header as dirty */
+ if(H5FS_dirty(fspace) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL, "unable to mark free space header as dirty")
- /* Cache the free-space section info */
- if(H5AC_insert_entry(f, dxpl_id, H5AC_FSPACE_SINFO, fspace->sect_addr, fspace->sinfo, H5AC__NO_FLAGS_SET) < 0)
- HGOTO_ERROR(H5E_FSPACE, H5E_CANTINIT, FAIL, "can't add free space sections to cache")
+ /* Cache the free-space section info */
+ if(H5AC_insert_entry(f, dxpl_id, H5AC_FSPACE_SINFO, fspace->sect_addr, fspace->sinfo, H5AC__NO_FLAGS_SET) < 0)
+ HGOTO_ERROR(H5E_FSPACE, H5E_CANTINIT, FAIL, "can't add free space sections to cache")
- fspace->sinfo = NULL;
+ fspace->sinfo = NULL;
} /* end if */
done:
@@ -913,13 +896,14 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FS_free()
+ * Function: H5FS_free()
*
- * Purpose: Free space for free-space manager header and section info header
+ * Purpose: Free space for free-space manager header and section info header
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
- * Programmer: Vailin Choi; Feb 2009
+ * Programmer: Vailin Choi
+ * Feb 2009
*
*-------------------------------------------------------------------------
*/
@@ -927,7 +911,7 @@ herr_t
H5FS_free(H5F_t *f, H5FS_t *fspace, hid_t dxpl_id)
{
haddr_t saved_addr; /* Previous address of item */
- unsigned cache_flags; /* Flags for unprotecting cache entries */
+ unsigned cache_flags; /* Flags for unprotecting cache entries */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_TAG(dxpl_id, H5AC__FREESPACE_TAG, FAIL)
@@ -942,11 +926,11 @@ H5FS_free(H5F_t *f, H5FS_t *fspace, hid_t dxpl_id)
hsize_t saved_size; /* Size of previous section info */
unsigned sinfo_status = 0; /* Section info cache status */
- /* Check whether free-space manager section info is in cache or not */
- if(H5AC_get_entry_status(f, fspace->sect_addr, &sinfo_status) < 0)
- HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "unable to check metadata cache status for free-space section info")
+ /* Check whether free-space manager section info is in cache or not */
+ if(H5AC_get_entry_status(f, fspace->sect_addr, &sinfo_status) < 0)
+ HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "unable to check metadata cache status for free-space section info")
- /* Load free-space manager section info */
+ /* Load free-space manager section info */
if(sinfo_status & H5AC_ES__IN_CACHE || !fspace->sinfo) {
H5FS_sinfo_cache_ud_t cache_udata; /* User-data for cache callback */
@@ -957,39 +941,39 @@ H5FS_free(H5F_t *f, H5FS_t *fspace, hid_t dxpl_id)
if(NULL == (fspace->sinfo = (H5FS_sinfo_t *)H5AC_protect(f, dxpl_id, H5AC_FSPACE_SINFO, fspace->sect_addr, &cache_udata, H5AC__READ_ONLY_FLAG)))
HGOTO_ERROR(H5E_FSPACE, H5E_CANTPROTECT, FAIL, "unable to protect free space section info")
- /* Unload and release ownership of the free-space manager section info */
- if(H5AC_unprotect(f, dxpl_id, H5AC_FSPACE_SINFO, fspace->sect_addr, fspace->sinfo, cache_flags) < 0)
- HGOTO_ERROR(H5E_FSPACE, H5E_CANTUNPROTECT, FAIL, "unable to release free space section info")
- } /* end if */
+ /* Unload and release ownership of the free-space manager section info */
+ if(H5AC_unprotect(f, dxpl_id, H5AC_FSPACE_SINFO, fspace->sect_addr, fspace->sinfo, cache_flags) < 0)
+ HGOTO_ERROR(H5E_FSPACE, H5E_CANTUNPROTECT, FAIL, "unable to release free space section info")
+ } /* end if */
- saved_addr = fspace->sect_addr;
- saved_size = fspace->alloc_sect_size;
+ saved_addr = fspace->sect_addr;
+ saved_size = fspace->alloc_sect_size;
- fspace->sect_addr = HADDR_UNDEF;
- fspace->alloc_sect_size = 0;
+ fspace->sect_addr = HADDR_UNDEF;
+ fspace->alloc_sect_size = 0;
- /* Free space for the free-space manager section info */
+ /* Free space for the free-space manager section info */
if(!H5F_IS_TMP_ADDR(f, saved_addr)) {
if(H5MF_xfree(f, H5FD_MEM_FSPACE_SINFO, dxpl_id, saved_addr, saved_size) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "unable to release free space sections")
} /* end if */
- /* Mark free-space manager header as dirty */
- if(H5FS_dirty(fspace) < 0)
+ /* Mark free-space manager header as dirty */
+ if(H5FS_dirty(fspace) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL, "unable to mark free space header as dirty")
} /* end if */
if(H5F_addr_defined(fspace->addr)) {
unsigned hdr_status = 0; /* Header entry status */
- /* Check whether free-space manager header is in cache or not */
- if(H5AC_get_entry_status(f, fspace->addr, &hdr_status) < 0)
+ /* Check whether free-space manager header is in cache or not */
+ if(H5AC_get_entry_status(f, fspace->addr, &hdr_status) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "unable to check metadata cache status for free-space section info")
if(hdr_status & H5AC_ES__IN_CACHE) {
H5FS_hdr_cache_ud_t cache_udata; /* User-data for metadata cache callback */
- /* Protect the free-space manager header */
+ /* Protect the free-space manager header */
/* (no class information necessary since it's in the cache) */
cache_udata.f = f;
cache_udata.nclasses = 0;
@@ -998,21 +982,21 @@ H5FS_free(H5F_t *f, H5FS_t *fspace, hid_t dxpl_id)
if(NULL == (fspace = (H5FS_t *)H5AC_protect(f, dxpl_id, H5AC_FSPACE_HDR, fspace->addr, &cache_udata, H5AC__READ_ONLY_FLAG)))
HGOTO_ERROR(H5E_FSPACE, H5E_CANTPROTECT, FAIL, "unable to protect free space section info")
- /* Unpin the free-space manager header */
- if(H5AC_unpin_entry(fspace) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPIN, FAIL, "unable to unpin fractal heap header")
+ /* Unpin the free-space manager header */
+ if(H5AC_unpin_entry(fspace) < 0)
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPIN, FAIL, "unable to unpin fractal heap header")
- /* Unload and release ownership of the free-space header */
- if(H5AC_unprotect(f, dxpl_id, H5AC_FSPACE_HDR, fspace->addr, fspace, cache_flags) < 0)
- HGOTO_ERROR(H5E_FSPACE, H5E_CANTUNPROTECT, FAIL, "unable to release free space section info")
- } /* end if */
+ /* Unload and release ownership of the free-space header */
+ if(H5AC_unprotect(f, dxpl_id, H5AC_FSPACE_HDR, fspace->addr, fspace, cache_flags) < 0)
+ HGOTO_ERROR(H5E_FSPACE, H5E_CANTUNPROTECT, FAIL, "unable to release free space section info")
+ } /* end if */
- saved_addr = fspace->addr;
- fspace->addr = HADDR_UNDEF;
+ saved_addr = fspace->addr;
+ fspace->addr = HADDR_UNDEF;
- /* Free space for the free-space manager header */
- if(H5MF_xfree(f, H5FD_MEM_FSPACE_HDR, dxpl_id, saved_addr, (hsize_t)H5FS_HEADER_SIZE(f)) < 0)
- HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "unable to free free space header")
+ /* Free space for the free-space manager header */
+ if(H5MF_xfree(f, H5FD_MEM_FSPACE_HDR, dxpl_id, saved_addr, (hsize_t)H5FS_HEADER_SIZE(f)) < 0)
+ HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "unable to free free space header")
} /* end if */
done:
@@ -1021,15 +1005,14 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FS__hdr_dest
+ * Function: H5FS__hdr_dest
*
- * Purpose: Destroys a free space header in memory.
+ * Purpose: Destroys a free space header in memory.
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
- * koziol@ncsa.uiuc.edu
- * May 2 2006
+ * Programmer: Quincey Koziol
+ * May 2 2006
*
*-------------------------------------------------------------------------
*/
@@ -1067,14 +1050,13 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FS_sinfo_free_sect_cb
+ * Function: H5FS_sinfo_free_sect_cb
*
- * Purpose: Free a size-tracking node for a bin
+ * Purpose: Free a size-tracking node for a bin
*
- * Return: Success: non-negative
- * Failure: negative
+ * Return: SUCCEED (Can't fail)
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Saturday, March 11, 2006
*
*-------------------------------------------------------------------------
@@ -1093,20 +1075,18 @@ H5FS_sinfo_free_sect_cb(void *_sect, void H5_ATTR_UNUSED *key, void *op_data)
/* Call the section's class 'free' method on the section */
(*sinfo->fspace->sect_cls[sect->type].free)(sect);
- FUNC_LEAVE_NOAPI(0)
+ FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5FS_sinfo_free_sect_cb() */
/*-------------------------------------------------------------------------
- * Function: H5FS_sinfo_free_node_cb
- *
- * Purpose: Free a size-tracking node for a bin
+ * Function: H5FS_sinfo_free_node_cb
*
- * Return: Success: non-negative
+ * Purpose: Free a size-tracking node for a bin
*
- * Failure: negative
+ * Return: SUCCEED (Can't fail)
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Saturday, March 11, 2006
*
*-------------------------------------------------------------------------
@@ -1127,20 +1107,19 @@ H5FS_sinfo_free_node_cb(void *item, void H5_ATTR_UNUSED *key, void *op_data)
/* Release free space list node */
fspace_node = H5FL_FREE(H5FS_node_t, fspace_node);
- FUNC_LEAVE_NOAPI(0)
+ FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5FS_sinfo_free_node_cb() */
/*-------------------------------------------------------------------------
- * Function: H5FS_sinfo_dest
+ * Function: H5FS_sinfo_dest
*
- * Purpose: Destroys a free space section info in memory.
+ * Purpose: Destroys a free space section info in memory.
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
- * koziol@ncsa.uiuc.edu
- * July 31 2006
+ * Programmer: Quincey Koziol
+ * July 31 2006
*
*-------------------------------------------------------------------------
*/
@@ -1193,15 +1172,14 @@ done:
#ifdef H5FS_DEBUG_ASSERT
/*-------------------------------------------------------------------------
- * Function: H5FS_assert
+ * Function: H5FS_assert
*
- * Purpose: Verify that the free space manager is mostly sane
+ * Purpose: Verify that the free space manager is mostly sane
*
- * Return: Non-negative on success, negative on failure
+ * Return: SUCCEED (Can't fail)
*
- * Programmer: Quincey Koziol
- * koziol@hdfgroup.org
- * Jul 17 2006
+ * Programmer: Quincey Koziol
+ * Jul 17 2006
*
*-------------------------------------------------------------------------
*/
diff --git a/src/H5FScache.c b/src/H5FScache.c
index 25a16e0..2f7dda8 100644
--- a/src/H5FScache.c
+++ b/src/H5FScache.c
@@ -15,11 +15,11 @@
/*-------------------------------------------------------------------------
*
- * Created: H5FScache.c
- * May 2 2006
- * Quincey Koziol <koziol@ncsa.uiuc.edu>
+ * Created: H5FScache.c
+ * May 2 2006
+ * Quincey Koziol <koziol@hdfgroup.org>
*
- * Purpose: Implement file free space metadata cache methods.
+ * Purpose: Implement file free space metadata cache methods.
*
*-------------------------------------------------------------------------
*/
@@ -176,6 +176,8 @@ H5FS__cache_hdr_get_load_size(const void *_udata, size_t *image_len)
FUNC_ENTER_STATIC_NOERR
/* Check arguments */
+ HDassert(udata);
+ HDassert(udata->f);
HDassert(image_len);
/* Set the image length size */
@@ -223,24 +225,24 @@ H5FS__cache_hdr_deserialize(const void *_image, size_t len, void *_udata,
/* Allocate a new free space manager */
if(NULL == (fspace = H5FS__new(udata->f, udata->nclasses, udata->classes, udata->cls_init_udata)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
/* Set free space manager's internal information */
fspace->addr = udata->addr;
/* Magic number */
if(HDmemcmp(image, H5FS_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC))
- HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, NULL, "wrong free space header signature")
+ HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, NULL, "wrong free space header signature")
image += H5_SIZEOF_MAGIC;
/* Version */
if(*image++ != H5FS_HDR_VERSION)
- HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, NULL, "wrong free space header version")
+ HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, NULL, "wrong free space header version")
/* Client ID */
fspace->client = (H5FS_client_t)*image++;
if(fspace->client >= H5FS_NUM_CLIENT_ID)
- HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, NULL, "unknown client ID in free space header")
+ HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, NULL, "unknown client ID in free space header")
/* Total space tracked */
H5F_DECODE_LENGTH(udata->f, image, fspace->tot_space);
@@ -258,7 +260,7 @@ H5FS__cache_hdr_deserialize(const void *_image, size_t len, void *_udata,
/* (only check if we actually have some classes) */
UINT16DECODE(image, nclasses);
if(fspace->nclasses > 0 && fspace->nclasses != nclasses)
- HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, NULL, "section class count mismatch")
+ HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, NULL, "section class count mismatch")
/* Shrink percent */
UINT16DECODE(image, fspace->shrink_percent);
@@ -822,7 +824,6 @@ H5FS__cache_sinfo_get_load_size(const void *_udata, size_t *image_len)
* it with the data contained in the image, and return a pointer to
* the new instance.
*
- *
* Return: Success: Pointer to in core representation
* Failure: NULL
*
@@ -1235,7 +1236,7 @@ done:
* Purpose: Skip list iterator callback to serialize free space sections
* of a particular size
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
* Programmer: Quincey Koziol
* Monday, May 8, 2006
@@ -1291,7 +1292,7 @@ done:
* Purpose: Skip list iterator callback to serialize free space sections
* in a bin
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
* Programmer: Quincey Koziol
* Monday, May 8, 2006
@@ -1329,4 +1330,3 @@ H5FS__sinfo_serialize_node_cb(void *_item, void H5_ATTR_UNUSED *key, void *_udat
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5FS__sinfo_serialize_node_cb() */
-
diff --git a/src/H5FSdbg.c b/src/H5FSdbg.c
index 7303b73..fbdeb70 100644
--- a/src/H5FSdbg.c
+++ b/src/H5FSdbg.c
@@ -15,11 +15,11 @@
/*-------------------------------------------------------------------------
*
- * Created: H5FSdbg.c
- * May 9 2006
- * Quincey Koziol <koziol@ncsa.uiuc.edu>
+ * Created: H5FSdbg.c
+ * May 9 2006
+ * Quincey Koziol <koziol@hdfgroup.org>
*
- * Purpose: Dump debugging information about a free space manager
+ * Purpose: Dump debugging information about a free space manager
*
*-------------------------------------------------------------------------
*/
@@ -36,11 +36,11 @@
/***********/
/* Headers */
/***********/
-#include "H5private.h" /* Generic Functions */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5FSpkg.h" /* File free space */
-#include "H5HFprivate.h" /* Fractal heaps */
-#include "H5MFprivate.h" /* File memory management */
+#include "H5private.h" /* Generic Functions */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5FSpkg.h" /* File free space */
+#include "H5HFprivate.h" /* Fractal heaps */
+#include "H5MFprivate.h" /* File memory management */
/****************/
@@ -79,26 +79,21 @@
/*-------------------------------------------------------------------------
- * Function: H5FS_debug
+ * Function: H5FS_debug
*
- * Purpose: Prints debugging info about a free space manager.
+ * Purpose: Prints debugging info about a free space manager.
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
- * koziol@ncsa.uiuc.edu
- * May 9 2006
- *
- * Modifications:
- * Vailin Choi, July 29th, 2008
- * Add H5FS_CLIENT_FILE_ID for File Memory Management
+ * Programmer: Quincey Koziol
+ * May 9 2006
*
*-------------------------------------------------------------------------
*/
herr_t
H5FS_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int fwidth)
{
- H5FS_t *fspace = NULL; /* Free space header info */
+ H5FS_t *fspace = NULL; /* Free space header info */
H5FS_hdr_cache_ud_t cache_udata; /* User-data for cache callback */
herr_t ret_value = SUCCEED; /* Return value */
@@ -124,7 +119,7 @@ H5FS_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int
* Load the free space header.
*/
if(NULL == (fspace = (H5FS_t *)H5AC_protect(f, dxpl_id, H5AC_FSPACE_HDR, addr, &cache_udata, H5AC__READ_ONLY_FLAG)))
- HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, FAIL, "unable to load free space header")
+ HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, FAIL, "unable to load free space header")
/* Print opening message */
HDfprintf(stream, "%*sFree Space Header...\n", indent, "");
@@ -133,45 +128,45 @@ H5FS_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int
* Print the values.
*/
HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
- "Free space client:",
- (fspace->client == H5FS_CLIENT_FHEAP_ID ? "Fractal heap" :
- (fspace->client == H5FS_CLIENT_FILE_ID ? "File" : "Unknown")));
+ "Free space client:",
+ (fspace->client == H5FS_CLIENT_FHEAP_ID ? "Fractal heap" :
+ (fspace->client == H5FS_CLIENT_FILE_ID ? "File" : "Unknown")));
HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth,
- "Total free space tracked:",
- fspace->tot_space);
+ "Total free space tracked:",
+ fspace->tot_space);
HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth,
- "Total number of free space sections tracked:",
- fspace->tot_sect_count);
+ "Total number of free space sections tracked:",
+ fspace->tot_sect_count);
HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth,
- "Number of serializable free space sections tracked:",
- fspace->serial_sect_count);
+ "Number of serializable free space sections tracked:",
+ fspace->serial_sect_count);
HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth,
- "Number of ghost free space sections tracked:",
- fspace->ghost_sect_count);
+ "Number of ghost free space sections tracked:",
+ fspace->ghost_sect_count);
HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
- "Number of free space section classes:",
- (unsigned)fspace->nclasses);
+ "Number of free space section classes:",
+ (unsigned)fspace->nclasses);
HDfprintf(stream, "%*s%-*s %u%%\n", indent, "", fwidth,
- "Shrink percent:",
- fspace->shrink_percent);
+ "Shrink percent:",
+ fspace->shrink_percent);
HDfprintf(stream, "%*s%-*s %u%%\n", indent, "", fwidth,
- "Expand percent:",
- fspace->expand_percent);
+ "Expand percent:",
+ fspace->expand_percent);
HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
- "# of bits for section address space:",
- fspace->max_sect_addr);
+ "# of bits for section address space:",
+ fspace->max_sect_addr);
HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth,
- "Maximum section size:",
- fspace->max_sect_size);
+ "Maximum section size:",
+ fspace->max_sect_size);
HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth,
- "Serialized sections address:",
- fspace->sect_addr);
+ "Serialized sections address:",
+ fspace->sect_addr);
HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth,
- "Serialized sections size used:",
- fspace->sect_size);
+ "Serialized sections size used:",
+ fspace->sect_size);
HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth,
- "Serialized sections size allocated:",
- fspace->alloc_sect_size);
+ "Serialized sections size allocated:",
+ fspace->alloc_sect_size);
done:
if(fspace && H5AC_unprotect(f, dxpl_id, H5AC_FSPACE_HDR, addr, fspace, H5AC__NO_FLAGS_SET) < 0)
@@ -182,15 +177,14 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FS_sect_debug
+ * Function: H5FS_sect_debug
*
- * Purpose: Prints debugging info about a free space section.
+ * Purpose: Prints debugging info about a free space section.
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
- * koziol@ncsa.uiuc.edu
- * May 30 2006
+ * Programmer: Quincey Koziol
+ * May 30 2006
*
*-------------------------------------------------------------------------
*/
@@ -221,15 +215,14 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FS_sects_debug
+ * Function: H5FS_sects_debug
*
- * Purpose: Prints debugging info about the free space sections.
+ * Purpose: Prints debugging info about the free space sections.
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
- * koziol@ncsa.uiuc.edu
- * May 9 2006
+ * Programmer: Quincey Koziol
+ * May 9 2006
*
*-------------------------------------------------------------------------
*/
@@ -237,7 +230,7 @@ herr_t
H5FS_sects_debug(H5F_t *f, hid_t dxpl_id, haddr_t H5_ATTR_UNUSED addr, FILE *stream, int indent, int fwidth,
haddr_t fs_addr, haddr_t client_addr)
{
- H5FS_t *fspace = NULL; /* Free space header info */
+ H5FS_t *fspace = NULL; /* Free space header info */
H5FS_client_t client; /* The client of the free space */
H5FS_hdr_cache_ud_t cache_udata; /* User-data for cache callback */
herr_t ret_value = SUCCEED; /* Return value */
@@ -266,7 +259,7 @@ H5FS_sects_debug(H5F_t *f, hid_t dxpl_id, haddr_t H5_ATTR_UNUSED addr, FILE *str
* Load the free space header.
*/
if(NULL == (fspace = (H5FS_t *)H5AC_protect(f, dxpl_id, H5AC_FSPACE_HDR, fs_addr, &cache_udata, H5AC__READ_ONLY_FLAG)))
- HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, FAIL, "unable to load free space header")
+ HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, FAIL, "unable to load free space header")
/* Retrieve the client id */
client = fspace->client;
@@ -292,8 +285,8 @@ H5FS_sects_debug(H5F_t *f, hid_t dxpl_id, haddr_t H5_ATTR_UNUSED addr, FILE *str
break;
case H5FS_CLIENT_FILE_ID:
- if(H5MF_sects_debug(f, dxpl_id, fs_addr, stream, indent + 3, MAX(0, fwidth - 3)) < 0)
- HGOTO_ERROR(H5E_FSPACE, H5E_SYSTEM, FAIL, "unable to dump file free space sections")
+ if(H5MF_sects_debug(f, dxpl_id, fs_addr, stream, indent + 3, MAX(0, fwidth - 3)) < 0)
+ HGOTO_ERROR(H5E_FSPACE, H5E_SYSTEM, FAIL, "unable to dump file free space sections")
break;
case H5FS_NUM_CLIENT_ID:
diff --git a/src/H5FSpkg.h b/src/H5FSpkg.h
index b0df9e6..08c2529 100644
--- a/src/H5FSpkg.h
+++ b/src/H5FSpkg.h
@@ -14,12 +14,12 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
- * Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu>
- * Tuesday, May 2, 2006
+ * Programmer: Quincey Koziol <koziol@hdfgroup.org>
+ * Tuesday, May 2, 2006
*
- * Purpose: This file contains declarations which are visible only within
- * the H5FS package. Source files outside the H5FS package should
- * include H5FSprivate.h instead.
+ * Purpose: This file contains declarations which are visible only within
+ * the H5FS package. Source files outside the H5FS package should
+ * include H5FSprivate.h instead.
*/
#if !(defined H5FS_FRIEND || defined H5FS_MODULE)
#error "Do not include this file outside the H5FS package!"
@@ -38,11 +38,11 @@
/* #define H5FS_DEBUG_ASSERT */
/* Get package's private header */
-#include "H5FSprivate.h" /* File free space */
+#include "H5FSprivate.h" /* File free space */
/* Other private headers needed by this file */
-#include "H5ACprivate.h" /* Metadata cache */
-#include "H5SLprivate.h" /* Skip lists */
+#include "H5ACprivate.h" /* Metadata cache */
+#include "H5SLprivate.h" /* Skip lists */
/**************************/
/* Package Private Macros */
diff --git a/src/H5FSprivate.h b/src/H5FSprivate.h
index 37bc0ea..c5ad38f 100644
--- a/src/H5FSprivate.h
+++ b/src/H5FSprivate.h
@@ -15,11 +15,11 @@
/*-------------------------------------------------------------------------
*
- * Created: H5FSprivate.h
- * May 2 2006
- * Quincey Koziol <koziol@ncsa.uiuc.edu>
+ * Created: H5FSprivate.h
+ * May 2 2006
+ * Quincey Koziol <koziol@hdfgroup.org>
*
- * Purpose: Private header for library accessible file free space routines.
+ * Purpose: Private header for library accessible file free space routines.
*
*-------------------------------------------------------------------------
*/
@@ -127,8 +127,8 @@ struct H5FS_section_info_t {
/* Free space client IDs for identifying user of free space */
typedef enum H5FS_client_t {
- H5FS_CLIENT_FHEAP_ID = 0, /* Free space is used by fractal heap */
- H5FS_CLIENT_FILE_ID, /* Free space is used by file */
+ H5FS_CLIENT_FHEAP_ID = 0, /* Free space is used by fractal heap */
+ H5FS_CLIENT_FILE_ID, /* Free space is used by file */
H5FS_NUM_CLIENT_ID /* Number of free space client IDs (must be last) */
} H5FS_client_t;
@@ -147,11 +147,11 @@ typedef struct H5FS_stat_t {
hsize_t tot_sect_count; /* Total # of sections tracked */
hsize_t serial_sect_count; /* # of serializable sections tracked */
hsize_t ghost_sect_count; /* # of un-serializable sections tracked */
- haddr_t addr; /* Address of free space header on disk */
- hsize_t hdr_size; /* Size of the free-space header on disk */
+ haddr_t addr; /* Address of free space header on disk */
+ hsize_t hdr_size; /* Size of the free-space header on disk */
haddr_t sect_addr; /* Address of the section info in the file */
hsize_t alloc_sect_size; /* Allocated size of the section info in the file */
- hsize_t sect_size; /* Size of the section info in the file */
+ hsize_t sect_size; /* Size of the section info in the file */
} H5FS_stat_t;
/* Typedef for iteration operations */
diff --git a/src/H5FSpublic.h b/src/H5FSpublic.h
index d1bae94..87debe8 100644
--- a/src/H5FSpublic.h
+++ b/src/H5FSpublic.h
@@ -17,7 +17,7 @@
*
* Created: H5FSpublic.h
* May 2 2006
- * Quincey Koziol <koziol@ncsa.uiuc.edu>
+ * Quincey Koziol <koziol@hdfgroup.org>
*
* Purpose: Public declarations for the file free space package.
*
diff --git a/src/H5FSsection.c b/src/H5FSsection.c
index d447160..62500e7 100644
--- a/src/H5FSsection.c
+++ b/src/H5FSsection.c
@@ -14,10 +14,10 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
- * Programmer: Quincey Koziol <koziol@hdfgroup.org>
+ * Programmer: Quincey Koziol <koziol@hdfgroup.org>
* Monday, July 31, 2006
*
- * Purpose: Free space tracking functions.
+ * Purpose: Free space tracking functions.
*
*/
@@ -111,14 +111,14 @@ H5FL_DEFINE(H5FS_sinfo_t);
/*-------------------------------------------------------------------------
- * Function: H5FS_sinfo_new
+ * Function: H5FS_sinfo_new
*
- * Purpose: Create new section info structure
+ * Purpose: Create new section info structure
*
- * Return: Success: non-NULL, pointer to new section info struct
- * Failure: NULL
+ * Return: Success: non-NULL, pointer to new section info struct
+ * Failure: NULL
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Monday, July 31, 2006
*
*-------------------------------------------------------------------------
@@ -140,7 +140,7 @@ HDfprintf(stderr, "%s: fspace->addr = %a\n", FUNC, fspace->addr);
/* Allocate the free space header */
if(NULL == (sinfo = H5FL_CALLOC(H5FS_sinfo_t)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
/* Set non-zero values */
sinfo->nbins = H5VM_log2_gen(fspace->max_sect_size);
@@ -186,19 +186,18 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FS_sinfo_lock
+ * Function: H5FS_sinfo_lock
*
- * Purpose: Make certain the section info for the free space manager is
+ * Purpose: Make certain the section info for the free space manager is
* in memory.
*
* Either uses existing section info owned by the free space
* header, loads section info from disk, or creates new section
* info
*
- * Return: Success: non-negative
- * Failure: negative
+ * Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Thursday, February 7, 2008
*
*-------------------------------------------------------------------------
@@ -304,15 +303,14 @@ HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu, fspace->sect_size = %Hu\n"
/*-------------------------------------------------------------------------
- * Function: H5FS_sinfo_unlock
+ * Function: H5FS_sinfo_unlock
*
- * Purpose: Release the section info, either giving ownership back to
+ * Purpose: Release the section info, either giving ownership back to
* the cache or letting the free space header keep it.
*
- * Return: Success: non-negative
- * Failure: negative
+ * Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Thursday, February 7, 2008
*
*-------------------------------------------------------------------------
@@ -468,14 +466,13 @@ HDfprintf(stderr, "%s: Leaving, ret_value = %d\n", FUNC, ret_value);
/*-------------------------------------------------------------------------
- * Function: H5FS_sect_serialize_size
+ * Function: H5FS_sect_serialize_size
*
- * Purpose: Determine serialized size of all sections in free space manager
+ * Purpose: Determine serialized size of all sections in free space manager
*
- * Return: Success: non-negative
- * Failure: negative
+ * Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Monday, May 8, 2006
*
*-------------------------------------------------------------------------
@@ -532,15 +529,14 @@ HDfprintf(stderr, "%s: fspace->serial_sect_count = %Hu\n", "H5FS_sect_serialize_
/*-------------------------------------------------------------------------
- * Function: H5FS_sect_increase
+ * Function: H5FS_sect_increase
*
- * Purpose: Increase the size of the serialized free space section info
+ * Purpose: Increase the size of the serialized free space section info
* on disk
*
- * Return: Success: non-negative
- * Failure: negative
+ * Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Monday, May 8, 2006
*
*-------------------------------------------------------------------------
@@ -594,16 +590,14 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FS_sect_decrease
+ * Function: H5FS_sect_decrease
*
- * Purpose: Decrease the size of the serialized free space section info
+ * Purpose: Decrease the size of the serialized free space section info
* on disk
*
- * Return: Success: non-negative
- *
- * Failure: negative
+ * Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Monday, May 8, 2006
*
*-------------------------------------------------------------------------
@@ -653,14 +647,13 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FS_size_node_decr
+ * Function: H5FS_size_node_decr
*
- * Purpose: Decrement the number of sections of a particular size
+ * Purpose: Decrement the number of sections of a particular size
*
- * Return: Success: non-negative
- * Failure: negative
+ * Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Wednesday, May 17, 2006
*
*-------------------------------------------------------------------------
@@ -741,15 +734,14 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FS_sect_unlink_size
+ * Function: H5FS_sect_unlink_size
*
- * Purpose: Remove a section node from size tracking data structures for
+ * Purpose: Remove a section node from size tracking data structures for
* a free space manager
*
- * Return: Success: non-negative
- * Failure: negative
+ * Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Wednesday, May 17, 2006
*
*-------------------------------------------------------------------------
@@ -796,17 +788,15 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FS_sect_unlink_rest
+ * Function: H5FS_sect_unlink_rest
*
- * Purpose: Finish unlinking a section from the rest of the free space
+ * Purpose: Finish unlinking a section from the rest of the free space
* manager's data structures, after the section has been removed
* from the size tracking data structures
*
- * Return: Success: non-negative
- *
- * Failure: negative
+ * Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Wednesday, May 17, 2006
*
*-------------------------------------------------------------------------
@@ -853,14 +843,13 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FS_sect_remove_real
+ * Function: H5FS_sect_remove_real
*
- * Purpose: Remove a section from the free space manager
+ * Purpose: Remove a section from the free space manager
*
- * Return: Success: non-negative
- * Failure: negative
+ * Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Wednesday, May 17, 2006
*
*-------------------------------------------------------------------------
@@ -895,14 +884,13 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FS_sect_remove
+ * Function: H5FS_sect_remove
*
- * Purpose: Remove a section from the free space manager
+ * Purpose: Remove a section from the free space manager
*
- * Return: Success: non-negative
- * Failure: negative
+ * Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Wednesday, May 17, 2006
*
*-------------------------------------------------------------------------
@@ -940,14 +928,13 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FS_sect_link_size
+ * Function: H5FS_sect_link_size
*
- * Purpose: Add a section of free space to the free list bins
+ * Purpose: Add a section of free space to the free list bins
*
- * Return: Success: non-negative
- * Failure: negative
+ * Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Monday, March 20, 2006
*
*-------------------------------------------------------------------------
@@ -1048,16 +1035,14 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FS_sect_link_rest
+ * Function: H5FS_sect_link_rest
*
- * Purpose: Link a section into the rest of the non-size tracking
+ * Purpose: Link a section into the rest of the non-size tracking
* free space manager data structures
*
- * Return: Success: non-negative
- *
- * Failure: negative
+ * Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Wednesday, May 17, 2006
*
*-------------------------------------------------------------------------
@@ -1100,15 +1085,13 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FS_sect_link
+ * Function: H5FS_sect_link
*
- * Purpose: Link a section into the internal data structures
+ * Purpose: Link a section into the internal data structures
*
- * Return: Success: non-negative
- *
- * Failure: negative
+ * Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Wednesday, May 17, 2006
*
*-------------------------------------------------------------------------
@@ -1152,24 +1135,16 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FS_sect_merge
+ * Function: H5FS_sect_merge
*
- * Purpose: Attempt to merge a returned free space section with existing
+ * Purpose: Attempt to merge a returned free space section with existing
* free space.
*
- * Return: Success: non-negative
- * Failure: negative
+ * Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Wednesday, May 17, 2006
*
- * Modifications: Vailin Choi; Sept 25th 2008
- * Changes to the "shrinking" part--
- * 1. Get last section node in merge-list instead of "less-than"
- * node for further iteration
- * 2. Remove "can-be-shrunk" section from free-space instead of
- * "less-than" section
- *
*-------------------------------------------------------------------------
*/
static herr_t
@@ -1177,7 +1152,7 @@ H5FS_sect_merge(H5FS_t *fspace, H5FS_section_info_t **sect, void *op_data)
{
H5FS_section_class_t *sect_cls; /* Section's class */
hbool_t modified; /* Flag to indicate merge or shrink occurred */
- hbool_t remove_sect = FALSE; /* Whether a section should be removed before shrinking */
+ hbool_t remove_sect = FALSE; /* Whether a section should be removed before shrinking */
htri_t status; /* Status value */
herr_t ret_value = SUCCEED; /* Return value */
@@ -1309,13 +1284,13 @@ HDfprintf(stderr, "%s: Done merging, (*sect) = {%a, %Hu, %u, %s}\n", FUNC, (*sec
HDfprintf(stderr, "%s: Can shrink!\n", FUNC);
#endif /* QAK */
- /* Remove SECT from free-space manager */
+ /* Remove SECT from free-space manager */
/* (only possible to happen on second+ pass through loop) */
- if(remove_sect) {
- if(H5FS_sect_remove_real(fspace, *sect) < 0)
- HGOTO_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't remove section from internal data structures")
- remove_sect = FALSE;
- } /* end if */
+ if(remove_sect) {
+ if(H5FS_sect_remove_real(fspace, *sect) < 0)
+ HGOTO_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't remove section from internal data structures")
+ remove_sect = FALSE;
+ } /* end if */
/* Shrink the container */
/* (callback can indicate that it has discarded the section by setting *sect to NULL) */
@@ -1339,7 +1314,7 @@ HDfprintf(stderr, "%s: Can shrink!\n", FUNC);
remove_sect = TRUE;
} /* end if */
} /* end if */
- } /* end if */
+ } /* end if */
/* Indicate successful merge occurred */
modified = TRUE;
@@ -1349,7 +1324,7 @@ HDfprintf(stderr, "%s: Can shrink!\n", FUNC);
/* Check for section that was shrunk away and next section not shrinking */
if(remove_sect && (*sect != NULL))
- *sect = NULL;
+ *sect = NULL;
#ifdef QAK
HDfprintf(stderr, "%s: Done shrinking\n", FUNC);
@@ -1368,15 +1343,13 @@ HDfprintf(stderr, "%s: Leaving, ret_value = %d\n", FUNC, ret_value);
/*-------------------------------------------------------------------------
- * Function: H5FS_sect_add
+ * Function: H5FS_sect_add
*
- * Purpose: Add a section of free space to the free list
+ * Purpose: Add a section of free space to the free list
*
- * Return: Success: non-negative
- *
- * Failure: negative
+ * Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Tuesday, March 7, 2006
*
*-------------------------------------------------------------------------
@@ -1458,14 +1431,13 @@ HDfprintf(stderr, "%s: Leaving, ret_value = %d\n", FUNC, ret_value);
/*-------------------------------------------------------------------------
- * Function: H5FS_sect_try_extend
+ * Function: H5FS_sect_try_extend
*
- * Purpose: Try to extend a block using space from a section on the free list
+ * Purpose: Try to extend a block using space from a section on the free list
*
- * Return: Success: non-negative
- * Failure: negative
+ * Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Tuesday, January 8, 2008
*
*-------------------------------------------------------------------------
@@ -1589,15 +1561,16 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FS_sect_try_merge
+ * Function: H5FS_sect_try_merge
*
- * Purpose: Try to merge/shrink a block
+ * Purpose: Try to merge/shrink a block
*
- * Return: TRUE: merged/shrunk
- * FALSE: not merged/not shrunk
- * Failure: negative
+ * Return: TRUE: merged/shrunk
+ * FALSE: not merged/not shrunk
+ * Failure: negative
*
- * Programmer: Vailin Choi; June 10, 2009
+ * Programmer: Vailin Choi
+ * June 10, 2009
*
*-------------------------------------------------------------------------
*/
@@ -1607,7 +1580,7 @@ H5FS_sect_try_merge(H5F_t *f, hid_t dxpl_id, H5FS_t *fspace, H5FS_section_info_t
{
hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */
hbool_t sinfo_modified = FALSE; /* Whether the section info was modified */
- hsize_t saved_fs_size; /* copy the free-space section size */
+ hsize_t saved_fs_size; /* Copy of the free-space section size */
htri_t ret_value = FALSE; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -1621,18 +1594,18 @@ H5FS_sect_try_merge(H5F_t *f, hid_t dxpl_id, H5FS_t *fspace, H5FS_section_info_t
/* Get a pointer to the section info */
if(H5FS_sinfo_lock(f, dxpl_id, fspace, H5AC__NO_FLAGS_SET) < 0)
- HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "can't get section info")
+ HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "can't get section info")
sinfo_valid = TRUE;
saved_fs_size = sect->size;
/* Attempt to merge/shrink section with existing sections */
if(H5FS_sect_merge(fspace, &sect, op_data) < 0)
- HGOTO_ERROR(H5E_FSPACE, H5E_CANTMERGE, FAIL, "can't merge sections")
+ HGOTO_ERROR(H5E_FSPACE, H5E_CANTMERGE, FAIL, "can't merge sections")
/* Check if section is shrunk and/or merged away completely */
if(!sect) {
- sinfo_modified = TRUE;
- HGOTO_DONE(TRUE)
+ sinfo_modified = TRUE;
+ HGOTO_DONE(TRUE)
} /* end if */
else {
/* Check if section is merged */
@@ -1654,23 +1627,16 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FS_sect_find_node
+ * Function: H5FS_sect_find_node
*
- * Purpose: Locate a section of free space (in existing free space list
+ * Purpose: Locate a section of free space (in existing free space list
* bins) that is large enough to fulfill request.
*
- * Return: Success: non-negative
+ * Return: SUCCEED/FAIL
*
- * Failure: negative
- *
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Monday, March 20, 2006
*
- * Modifications:
- * Vailin Choi, July 29th, 2008
- * Modified to handle alignment by going through each bin to find
- * a section that is big enough to fulfill "request+fragment for alignment"
- *
*-------------------------------------------------------------------------
*/
static htri_t
@@ -1702,34 +1668,34 @@ HDfprintf(stderr, "%s: bin = %u\n", FUNC, bin);
#endif /* QAK */
alignment = fspace->alignment;
if(!((alignment > 1) && (request >= fspace->threshold)))
- alignment = 0; /* no alignment */
+ alignment = 0; /* no alignment */
do {
/* Check if there's any sections in this bin */
- if(fspace->sinfo->bins[bin].bin_list) {
-
- if (!alignment) { /* no alignment */
- /* Find the first free space section that is large enough to fulfill request */
- /* (Since the bins use skip lists to track the sizes of the address-ordered
- * lists, this is actually a "best fit" algorithm)
- */
- /* Look for large enough free space section in this bin */
- if((fspace_node = (H5FS_node_t *)H5SL_greater(fspace->sinfo->bins[bin].bin_list, &request))) {
- /* Take first node off of the list (ie. node w/lowest address) */
- if(NULL == (*node = (H5FS_section_info_t *)H5SL_remove_first(fspace_node->sect_list)))
- HGOTO_ERROR(H5E_FSPACE, H5E_CANTREMOVE, FAIL, "can't remove free space node from skip list")
-
- /* Get section's class */
- cls = &fspace->sect_cls[(*node)->type];
- /* Decrement # of sections in section size node */
- if(H5FS_size_node_decr(fspace->sinfo, bin, fspace_node, cls) < 0)
- HGOTO_ERROR(H5E_FSPACE, H5E_CANTREMOVE, FAIL, "can't remove free space size node from skip list")
- if(H5FS_sect_unlink_rest(fspace, cls, *node) < 0)
- HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "can't remove section from non-size tracking data structures")
- /* Indicate that we found a node for the request */
- HGOTO_DONE(TRUE)
- } /* end if */
- } /* end if */
+ if(fspace->sinfo->bins[bin].bin_list) {
+
+ if (!alignment) { /* no alignment */
+ /* Find the first free space section that is large enough to fulfill request */
+ /* (Since the bins use skip lists to track the sizes of the address-ordered
+ * lists, this is actually a "best fit" algorithm)
+ */
+ /* Look for large enough free space section in this bin */
+ if((fspace_node = (H5FS_node_t *)H5SL_greater(fspace->sinfo->bins[bin].bin_list, &request))) {
+ /* Take first node off of the list (ie. node w/lowest address) */
+ if(NULL == (*node = (H5FS_section_info_t *)H5SL_remove_first(fspace_node->sect_list)))
+ HGOTO_ERROR(H5E_FSPACE, H5E_CANTREMOVE, FAIL, "can't remove free space node from skip list")
+
+ /* Get section's class */
+ cls = &fspace->sect_cls[(*node)->type];
+ /* Decrement # of sections in section size node */
+ if(H5FS_size_node_decr(fspace->sinfo, bin, fspace_node, cls) < 0)
+ HGOTO_ERROR(H5E_FSPACE, H5E_CANTREMOVE, FAIL, "can't remove free space size node from skip list")
+ if(H5FS_sect_unlink_rest(fspace, cls, *node) < 0)
+ HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "can't remove section from non-size tracking data structures")
+ /* Indicate that we found a node for the request */
+ HGOTO_DONE(TRUE)
+ } /* end if */
+ } /* end if */
else { /* alignment is set */
/* get the first node of a certain size in this bin */
curr_size_node = H5SL_first(fspace->sinfo->bins[bin].bin_list);
@@ -1798,9 +1764,9 @@ HDfprintf(stderr, "%s: bin = %u\n", FUNC, bin);
/* Get the next size node in the bin */
curr_size_node = H5SL_next(curr_size_node);
} /* end while of curr_size_node */
- } /* else of alignment */
- } /* if bin_list */
- /* Advance to next larger bin */
+ } /* else of alignment */
+ } /* if bin_list */
+ /* Advance to next larger bin */
bin++;
} while(bin < fspace->sinfo->nbins);
@@ -1810,22 +1776,16 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FS_sect_find
+ * Function: H5FS_sect_find
*
- * Purpose: Locate a section of free space (in existing free space list) that
+ * Purpose: Locate a section of free space (in existing free space list) that
* is large enough to fulfill request.
*
- * Return: Success: non-negative
- *
- * Failure: negative
+ * Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Tuesday, March 7, 2006
*
- * Modifications:
- * Vailin Choi, July 29th 2008
- * Move H5FS_sect_unlink_rest() to H5FS_sect_find_node()
- *
*-------------------------------------------------------------------------
*/
htri_t
@@ -1871,7 +1831,7 @@ HDfprintf(stderr, "%s: fspace->ghost_sect_count = %Hu\n", FUNC, fspace->ghost_se
#ifdef QAK
HDfprintf(stderr, "%s: (*node)->size = %Hu, (*node)->addr = %a, (*node)->type = %u\n", FUNC, (*node)->size, (*node)->addr, (*node)->type);
#endif /* QAK */
- }
+ }
} /* end if */
done:
@@ -1887,16 +1847,14 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FS_iterate_sect_cb
+ * Function: H5FS_iterate_sect_cb
*
- * Purpose: Skip list iterator callback to iterate over free space sections
+ * Purpose: Skip list iterator callback to iterate over free space sections
* of a particular size
*
- * Return: Success: non-negative
+ * Return: SUCCEED/FAIL
*
- * Failure: negative
- *
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Saturday, May 13, 2006
*
*-------------------------------------------------------------------------
@@ -1925,16 +1883,14 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FS_iterate_node_cb
+ * Function: H5FS_iterate_node_cb
*
- * Purpose: Skip list iterator callback to iterate over free space sections
+ * Purpose: Skip list iterator callback to iterate over free space sections
* in a bin
*
- * Return: Success: non-negative
- *
- * Failure: negative
+ * Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Saturday, May 13, 2006
*
*-------------------------------------------------------------------------
@@ -1964,15 +1920,13 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FS_sect_iterate
+ * Function: H5FS_sect_iterate
*
- * Purpose: Iterate over all the sections managed
+ * Purpose: Iterate over all the sections managed
*
- * Return: Success: non-negative
+ * Return: SUCCEED/FAIL
*
- * Failure: negative
- *
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Saturday, May 13, 2006
*
*-------------------------------------------------------------------------
@@ -2032,14 +1986,13 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FS_sect_stats
+ * Function: H5FS_sect_stats
*
- * Purpose: Retrieve info about the sections managed
+ * Purpose: Retrieve info about the sections managed
*
- * Return: Success: non-negative
- * Failure: negative
+ * Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Tuesday, May 30, 2006
*
*-------------------------------------------------------------------------
@@ -2063,16 +2016,14 @@ H5FS_sect_stats(const H5FS_t *fspace, hsize_t *tot_space, hsize_t *nsects)
/*-------------------------------------------------------------------------
- * Function: H5FS_sect_change_class
+ * Function: H5FS_sect_change_class
*
- * Purpose: Make appropriate adjustments to internal data structures when
+ * Purpose: Make appropriate adjustments to internal data structures when
* a section changes class
*
- * Return: Success: non-negative
- *
- * Failure: negative
+ * Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Monday, July 10, 2006
*
*-------------------------------------------------------------------------
@@ -2235,15 +2186,14 @@ done:
#ifdef H5FS_DEBUG_ASSERT
/*-------------------------------------------------------------------------
- * Function: H5FS_sect_assert
+ * Function: H5FS_sect_assert
*
- * Purpose: Verify that the sections managed are mostly sane
+ * Purpose: Verify that the sections managed are mostly sane
*
- * Return: Non-negative on success, negative on failure
+ * Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
- * koziol@hdfgroup.org
- * Jul 17 2006
+ * Programmer: Quincey Koziol
+ * Jul 17 2006
*
*-------------------------------------------------------------------------
*/
diff --git a/src/H5FSstat.c b/src/H5FSstat.c
index 390eb9f..d2c0177 100644
--- a/src/H5FSstat.c
+++ b/src/H5FSstat.c
@@ -28,9 +28,9 @@
/***********/
/* Headers */
/***********/
-#include "H5private.h" /* Generic Functions */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5FSpkg.h" /* Free-space manager */
+#include "H5private.h" /* Generic Functions */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5FSpkg.h" /* Free-space manager */
/****************/
@@ -74,12 +74,10 @@
*
* Purpose: Retrieve metadata statistics for the free-space manager
*
- * Return: Success: non-negative
- *
- * Failure: does not fail
+ * Return: SUCCEED (Can't fail)
*
* Programmer: Vailin Choi
- * August 25th, 2008
+ * August 25th, 2008
*
*-------------------------------------------------------------------------
*/
diff --git a/src/H5FStest.c b/src/H5FStest.c
index f96ee75..06f5166 100644
--- a/src/H5FStest.c
+++ b/src/H5FStest.c
@@ -23,15 +23,15 @@
/****************/
#include "H5FSmodule.h" /* This source code file is part of the H5FS module */
-#define H5FS_TESTING /*suppress warning about H5FS testing funcs */
+#define H5FS_TESTING /* Suppress warning about H5FS testing funcs */
/***********/
/* Headers */
/***********/
-#include "H5private.h" /* Generic Functions */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5FSpkg.h" /* Free-space manager */
+#include "H5private.h" /* Generic Functions */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5FSpkg.h" /* Free-space manager */
/****************/
@@ -74,13 +74,12 @@
* Function: H5FS_get_cparam_test
*
* Purpose: Retrieve the parameters used to create the free-space manager
+ * similar to H5HF_get_cparam_test()
*
- * Return: Success: non-negative
+ * Return: SUCCEED/FAIL
*
- * Failure: negative
- *
- * Programmer: similar to H5HF_get_cparam_test()
- * Vailin Choi; August 25th, 2008
+ * Programmer: Vailin Choi
+ * August 25th, 2008
*
*-------------------------------------------------------------------------
*/
@@ -106,13 +105,13 @@ H5FS_get_cparam_test(const H5FS_t *frsp, H5FS_create_t *cparam)
/*-------------------------------------------------------------------------
* Function: H5FS_cmp_cparam_test
*
- * Purpose: Compare the parameters used to create the fractal heap
+ * Purpose: Compare the parameters used to create the free space manager
+ * similar to H5HF_cmp_cparam_test()
*
- * Return: Success: non-negative
- * Failure: negative
+ * Return: SUCCEED/FAIL
*
- * Programmer: similar to H5HF_cmp_cparam_test()
- * Vailin Choi; August 25th, 2008
+ * Programmer: Vailin Choi
+ * August 25th, 2008
*
*-------------------------------------------------------------------------
*/
diff --git a/src/H5Fint.c b/src/H5Fint.c
index f15b60b..33db083 100644
--- a/src/H5Fint.c
+++ b/src/H5Fint.c
@@ -388,8 +388,8 @@ static int
H5F_get_objects_cb(void *obj_ptr, hid_t obj_id, void *key)
{
H5F_olist_t *olist = (H5F_olist_t *)key; /* Alias for search info */
- int ret_value = H5_ITER_CONT; /* Return value */
hbool_t add_obj = FALSE;
+ int ret_value = H5_ITER_CONT; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -403,7 +403,7 @@ H5F_get_objects_cb(void *obj_ptr, hid_t obj_id, void *key)
|| (!olist->file_info.local &&
( !olist->file_info.ptr.shared || (olist->file_info.ptr.shared && ((H5F_t*)obj_ptr)->shared == olist->file_info.ptr.shared) ))) {
add_obj = TRUE;
- }
+ } /* end if */
} /* end if */
else { /* either count opened object IDs or put the IDs on the list */
H5O_loc_t *oloc; /* Group entry info for object */
@@ -456,7 +456,7 @@ H5F_get_objects_cb(void *obj_ptr, hid_t obj_id, void *key)
} /* end if */
} /* end else */
- if(TRUE==add_obj) {
+ if(add_obj) {
/* Add the object's ID to the ID list, if appropriate */
if(olist->obj_id_list) {
olist->obj_id_list[olist->list_index] = obj_id;
@@ -471,9 +471,9 @@ H5F_get_objects_cb(void *obj_ptr, hid_t obj_id, void *key)
* we have filled up the array. Otherwise return H5_ITER_CONT(RET_VALUE is
* preset to H5_ITER_CONT) because H5I_iterate needs the return value of
* H5_ITER_CONT to continue the iteration. */
- if(olist->max_nobjs>0 && olist->list_index>=olist->max_nobjs)
+ if(olist->max_nobjs > 0 && olist->list_index >= olist->max_nobjs)
HGOTO_DONE(H5_ITER_STOP) /* Indicate that the iterator should stop */
- }
+ } /* end if */
done:
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c
index 50f6b06..c6b1c83 100644
--- a/src/H5Fsuper.c
+++ b/src/H5Fsuper.c
@@ -934,6 +934,7 @@ H5F__super_init(H5F_t *f, hid_t dxpl_id)
HDassert(driver_size <= H5F_MAX_DRVINFOBLOCK_SIZE);
/* Encode driver-specific data */
+ HDmemset(dbuf, 0, sizeof(dbuf));
if(H5FD_sb_encode(f->shared->lf, info.name, dbuf) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to encode driver information")
diff --git a/src/H5G.c b/src/H5G.c
index 0e0c718..6a9342c 100644
--- a/src/H5G.c
+++ b/src/H5G.c
@@ -525,101 +525,6 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5G_get_create_plist
- *
- * Purpose: Private function for H5Gget_create_plist
- *
- * Return: Success: ID for a copy of the group creation
- * property list. The property list ID should be
- * released by calling H5Pclose().
- *
- * Failure: FAIL
- *
- * Programmer: Quincey Koziol
- * Tuesday, October 25, 2005
- *
- *-------------------------------------------------------------------------
- */
-hid_t
-H5G_get_create_plist(H5G_t *grp)
-{
- H5O_linfo_t linfo; /* Link info message */
- htri_t ginfo_exists;
- htri_t linfo_exists;
- htri_t pline_exists;
- H5P_genplist_t *gcpl_plist;
- H5P_genplist_t *new_plist;
- hid_t new_gcpl_id = FAIL;
- hid_t ret_value = FAIL;
-
- FUNC_ENTER_NOAPI(FAIL)
-
- /* Copy the default group creation property list */
- if(NULL == (gcpl_plist = (H5P_genplist_t *)H5I_object(H5P_LST_GROUP_CREATE_ID_g)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get default group creation property list")
- if((new_gcpl_id = H5P_copy_plist(gcpl_plist, TRUE)) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to copy the creation property list")
- if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(new_gcpl_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list")
-
- /* Retrieve any object creation properties */
- if(H5O_get_create_plist(&grp->oloc, H5AC_ind_dxpl_id, new_plist) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object creation info")
-
- /* Check for the group having a group info message */
- if((ginfo_exists = H5O_msg_exists(&(grp->oloc), H5O_GINFO_ID, H5AC_ind_dxpl_id)) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header")
- if(ginfo_exists) {
- H5O_ginfo_t ginfo; /* Group info message */
-
- /* Read the group info */
- if(NULL == H5O_msg_read(&(grp->oloc), H5O_GINFO_ID, &ginfo, H5AC_ind_dxpl_id))
- HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't get group info")
-
- /* Set the group info for the property list */
- if(H5P_set(new_plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set group info")
- } /* end if */
-
- /* Check for the group having a link info message */
- if((linfo_exists = H5G__obj_get_linfo(&(grp->oloc), &linfo, H5AC_ind_dxpl_id)) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header")
- if(linfo_exists) {
- /* Set the link info for the property list */
- if(H5P_set(new_plist, H5G_CRT_LINK_INFO_NAME, &linfo) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set link info")
- } /* end if */
-
- /* Check for the group having a pipeline message */
- if((pline_exists = H5O_msg_exists(&(grp->oloc), H5O_PLINE_ID, H5AC_ind_dxpl_id)) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to read object header")
- if(pline_exists) {
- H5O_pline_t pline; /* Pipeline message */
-
- /* Read the pipeline */
- if(NULL == H5O_msg_read(&(grp->oloc), H5O_PLINE_ID, &pline, H5AC_ind_dxpl_id))
- HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't get link pipeline")
-
- /* Set the pipeline for the property list */
- if(H5P_set(new_plist, H5O_CRT_PIPELINE_NAME, &pline) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set link pipeline")
- } /* end if */
-
- /* Set the return value */
- ret_value = new_gcpl_id;
-
-done:
- if(ret_value < 0) {
- if(new_gcpl_id > 0)
- if(H5I_dec_app_ref(new_gcpl_id) < 0)
- HDONE_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "can't free")
- } /* end if */
-
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5G_get_create_plist() */
-
-
-/*-------------------------------------------------------------------------
* Function: H5Gget_info
*
* Purpose: Retrieve information about a group.
diff --git a/src/H5Gbtree2.c b/src/H5Gbtree2.c
index 104e6b3..b464930 100644
--- a/src/H5Gbtree2.c
+++ b/src/H5Gbtree2.c
@@ -83,7 +83,8 @@ static herr_t H5G_dense_btree2_corder_encode(uint8_t *raw, const void *native,
void *ctx);
static herr_t H5G_dense_btree2_corder_decode(const uint8_t *raw, void *native,
void *ctx);
-static herr_t H5G_dense_btree2_corder_debug(FILE *stream, int indent, int fwidth, const void *record);
+static herr_t H5G_dense_btree2_corder_debug(FILE *stream, int indent, int fwidth,
+ const void *record, const void *_udata);
/* v2 B-tree driver callbacks for 'name' index */
static herr_t H5G_dense_btree2_name_store(void *native, const void *udata);
@@ -92,7 +93,8 @@ static herr_t H5G_dense_btree2_name_encode(uint8_t *raw, const void *native,
void *ctx);
static herr_t H5G_dense_btree2_name_decode(const uint8_t *raw, void *native,
void *ctx);
-static herr_t H5G_dense_btree2_name_debug(FILE *stream, int indent, int fwidth, const void *record);
+static herr_t H5G_dense_btree2_name_debug(FILE *stream, int indent, int fwidth,
+ const void *record, const void *_udata);
/* Fractal heap function callbacks */
static herr_t H5G_dense_fh_name_cmp(const void *obj, size_t obj_len, void *op_data);
@@ -112,7 +114,9 @@ const H5B2_class_t H5G_BT2_NAME[1]={{ /* B-tree class information */
H5G_dense_btree2_name_compare, /* Record comparison callback */
H5G_dense_btree2_name_encode, /* Record encoding callback */
H5G_dense_btree2_name_decode, /* Record decoding callback */
- H5G_dense_btree2_name_debug /* Record debugging callback */
+ H5G_dense_btree2_name_debug, /* Record debugging callback */
+ NULL, /* Create debugging context */
+ NULL /* Destroy debugging context */
}};
/* v2 B-tree class for indexing 'creation order' field of links */
@@ -126,7 +130,9 @@ const H5B2_class_t H5G_BT2_CORDER[1]={{ /* B-tree class information */
H5G_dense_btree2_corder_compare, /* Record comparison callback */
H5G_dense_btree2_corder_encode, /* Record encoding callback */
H5G_dense_btree2_corder_decode, /* Record decoding callback */
- H5G_dense_btree2_corder_debug /* Record debugging callback */
+ H5G_dense_btree2_corder_debug, /* Record debugging callback */
+ NULL, /* Create debugging context */
+ NULL /* Destroy debugging context */
}};
/*****************************/
@@ -356,7 +362,8 @@ H5G_dense_btree2_name_decode(const uint8_t *raw, void *_nrecord, void H5_ATTR_UN
*-------------------------------------------------------------------------
*/
static herr_t
-H5G_dense_btree2_name_debug(FILE *stream, int indent, int fwidth, const void *_nrecord)
+H5G_dense_btree2_name_debug(FILE *stream, int indent, int fwidth,
+ const void *_nrecord, const void H5_ATTR_UNUSED *_udata)
{
const H5G_dense_bt2_name_rec_t *nrecord = (const H5G_dense_bt2_name_rec_t *)_nrecord;
unsigned u; /* Local index variable */
@@ -520,7 +527,8 @@ H5G_dense_btree2_corder_decode(const uint8_t *raw, void *_nrecord, void H5_ATTR_
*-------------------------------------------------------------------------
*/
static herr_t
-H5G_dense_btree2_corder_debug(FILE *stream, int indent, int fwidth, const void *_nrecord)
+H5G_dense_btree2_corder_debug(FILE *stream, int indent, int fwidth,
+ const void *_nrecord, const void H5_ATTR_UNUSED *_udata)
{
const H5G_dense_bt2_corder_rec_t *nrecord = (const H5G_dense_bt2_corder_rec_t *)_nrecord;
unsigned u; /* Local index variable */
diff --git a/src/H5Gdense.c b/src/H5Gdense.c
index ab0547b..e8fa237 100644
--- a/src/H5Gdense.c
+++ b/src/H5Gdense.c
@@ -322,8 +322,9 @@ HDfprintf(stderr, "%s: fheap_id_len = %Zu\n", FUNC, fheap_id_len);
HDmemset(&bt2_cparam, 0, sizeof(bt2_cparam));
bt2_cparam.cls = H5G_BT2_NAME;
bt2_cparam.node_size = (size_t)H5G_NAME_BT2_NODE_SIZE;
+ H5_CHECK_OVERFLOW(fheap_id_len, /* From: */ hsize_t, /* To: */ uint32_t);
bt2_cparam.rrec_size = 4 + /* Name's hash value */
- fheap_id_len; /* Fractal heap ID */
+ (uint32_t)fheap_id_len; /* Fractal heap ID */
bt2_cparam.split_percent = H5G_NAME_BT2_SPLIT_PERC;
bt2_cparam.merge_percent = H5G_NAME_BT2_MERGE_PERC;
if(NULL == (bt2_name = H5B2_create(f, dxpl_id, &bt2_cparam, NULL)))
@@ -342,8 +343,9 @@ HDfprintf(stderr, "%s: linfo->name_bt2_addr = %a\n", FUNC, linfo->name_bt2_addr)
HDmemset(&bt2_cparam, 0, sizeof(bt2_cparam));
bt2_cparam.cls = H5G_BT2_CORDER;
bt2_cparam.node_size = (size_t)H5G_CORDER_BT2_NODE_SIZE;
- bt2_cparam.rrec_size = 8 + /* Creation order value */
- fheap_id_len; /* Fractal heap ID */
+ H5_CHECK_OVERFLOW(fheap_id_len, /* From: */ hsize_t, /* To: */ uint32_t);
+ bt2_cparam.rrec_size = 8 + /* Creation order value */
+ (uint32_t)fheap_id_len; /* Fractal heap ID */
bt2_cparam.split_percent = H5G_CORDER_BT2_SPLIT_PERC;
bt2_cparam.merge_percent = H5G_CORDER_BT2_MERGE_PERC;
if(NULL == (bt2_corder = H5B2_create(f, dxpl_id, &bt2_cparam, NULL)))
diff --git a/src/H5Gent.c b/src/H5Gent.c
index 8df8414..6020028 100644
--- a/src/H5Gent.c
+++ b/src/H5Gent.c
@@ -411,8 +411,8 @@ H5G__ent_convert(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, const char *name,
* Add the new name to the heap.
*/
name_offset = H5HL_insert(f, dxpl_id, heap, HDstrlen(name) + 1, name);
- if(0 == name_offset || (size_t)(-1) == name_offset)
- HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert symbol name into heap")
+ if(0 == name_offset || UFAIL == name_offset)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert symbol name into heap")
ent->name_off = name_offset;
/* Build correct information for symbol table entry based on link type */
@@ -505,7 +505,7 @@ H5G__ent_convert(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, const char *name,
size_t lnk_offset; /* Offset to sym-link value */
/* Insert link value into local heap */
- if((size_t)(-1) == (lnk_offset = H5HL_insert(f, dxpl_id, heap,
+ if(UFAIL == (lnk_offset = H5HL_insert(f, dxpl_id, heap,
HDstrlen(lnk->u.soft.name) + 1, lnk->u.soft.name)))
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to write link value to local heap")
diff --git a/src/H5Gint.c b/src/H5Gint.c
index ea8288c..cba4806 100644
--- a/src/H5Gint.c
+++ b/src/H5Gint.c
@@ -1160,3 +1160,97 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_visit() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5G_get_create_plist
+ *
+ * Purpose: Private function for H5Gget_create_plist
+ *
+ * Return: Success: ID for a copy of the group creation
+ * property list. The property list ID should be
+ * released by calling H5Pclose().
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, October 25, 2005
+ *
+ *-------------------------------------------------------------------------
+ */
+hid_t
+H5G_get_create_plist(H5G_t *grp)
+{
+ H5O_linfo_t linfo; /* Link info message */
+ htri_t ginfo_exists;
+ htri_t linfo_exists;
+ htri_t pline_exists;
+ H5P_genplist_t *gcpl_plist;
+ H5P_genplist_t *new_plist;
+ hid_t new_gcpl_id = FAIL;
+ hid_t ret_value = FAIL;
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* Copy the default group creation property list */
+ if(NULL == (gcpl_plist = (H5P_genplist_t *)H5I_object(H5P_LST_GROUP_CREATE_ID_g)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get default group creation property list")
+ if((new_gcpl_id = H5P_copy_plist(gcpl_plist, TRUE)) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to copy the creation property list")
+ if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(new_gcpl_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list")
+
+ /* Retrieve any object creation properties */
+ if(H5O_get_create_plist(&grp->oloc, H5AC_ind_dxpl_id, new_plist) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object creation info")
+
+ /* Check for the group having a group info message */
+ if((ginfo_exists = H5O_msg_exists(&(grp->oloc), H5O_GINFO_ID, H5AC_ind_dxpl_id)) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header")
+ if(ginfo_exists) {
+ H5O_ginfo_t ginfo; /* Group info message */
+
+ /* Read the group info */
+ if(NULL == H5O_msg_read(&(grp->oloc), H5O_GINFO_ID, &ginfo, H5AC_ind_dxpl_id))
+ HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't get group info")
+
+ /* Set the group info for the property list */
+ if(H5P_set(new_plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set group info")
+ } /* end if */
+
+ /* Check for the group having a link info message */
+ if((linfo_exists = H5G__obj_get_linfo(&(grp->oloc), &linfo, H5AC_ind_dxpl_id)) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header")
+ if(linfo_exists) {
+ /* Set the link info for the property list */
+ if(H5P_set(new_plist, H5G_CRT_LINK_INFO_NAME, &linfo) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set link info")
+ } /* end if */
+
+ /* Check for the group having a pipeline message */
+ if((pline_exists = H5O_msg_exists(&(grp->oloc), H5O_PLINE_ID, H5AC_ind_dxpl_id)) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to read object header")
+ if(pline_exists) {
+ H5O_pline_t pline; /* Pipeline message */
+
+ /* Read the pipeline */
+ if(NULL == H5O_msg_read(&(grp->oloc), H5O_PLINE_ID, &pline, H5AC_ind_dxpl_id))
+ HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't get link pipeline")
+
+ /* Set the pipeline for the property list */
+ if(H5P_poke(new_plist, H5O_CRT_PIPELINE_NAME, &pline) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set link pipeline")
+ } /* end if */
+
+ /* Set the return value */
+ ret_value = new_gcpl_id;
+
+done:
+ if(ret_value < 0) {
+ if(new_gcpl_id > 0)
+ if(H5I_dec_app_ref(new_gcpl_id) < 0)
+ HDONE_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "can't free")
+ } /* end if */
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5G_get_create_plist() */
diff --git a/src/H5Gloc.c b/src/H5Gloc.c
index eb8cd78..3fcbd09 100644
--- a/src/H5Gloc.c
+++ b/src/H5Gloc.c
@@ -259,7 +259,7 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5G__loc_copy
+ * Function: H5G_loc_copy
*
* Purpose: Copy over information for a location
*
@@ -271,11 +271,11 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5G__loc_copy(H5G_loc_t *dst, const H5G_loc_t *src, H5_copy_depth_t depth)
+H5G_loc_copy(H5G_loc_t *dst, const H5G_loc_t *src, H5_copy_depth_t depth)
{
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_PACKAGE
+ FUNC_ENTER_NOAPI(FAIL)
/* Check args. */
HDassert(dst);
@@ -289,7 +289,7 @@ H5G__loc_copy(H5G_loc_t *dst, const H5G_loc_t *src, H5_copy_depth_t depth)
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5G__loc_copy() */
+} /* end H5G_loc_copy() */
/*-------------------------------------------------------------------------
@@ -388,7 +388,7 @@ H5G_loc_find_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char *name,
/* (Group traversal callbacks are responsible for either taking ownership
* of the group location for the object, or freeing it. - QAK)
*/
- H5G__loc_copy(udata->loc, obj_loc, H5_COPY_SHALLOW);
+ H5G_loc_copy(udata->loc, obj_loc, H5_COPY_SHALLOW);
*own_loc = H5G_OWN_OBJ_LOC;
done:
diff --git a/src/H5Gnode.c b/src/H5Gnode.c
index e25a17e..4d299dc 100644
--- a/src/H5Gnode.c
+++ b/src/H5Gnode.c
@@ -119,7 +119,7 @@ H5B_class_t H5B_SNODE[1] = {{
H5G_node_remove, /*remove */
H5G_node_decode_key, /*decode */
H5G_node_encode_key, /*encode */
- H5G_node_debug_key, /*debug */
+ H5G_node_debug_key /*debug */
}};
/* Declare a free list to manage the H5G_node_t struct */
diff --git a/src/H5Goh.c b/src/H5Goh.c
index c516713..bde540c 100644
--- a/src/H5Goh.c
+++ b/src/H5Goh.c
@@ -53,7 +53,7 @@ static hid_t H5O_group_open(const H5G_loc_t *obj_loc, hid_t lapl_id,
static void *H5O_group_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc,
hid_t dxpl_id);
static H5O_loc_t *H5O_group_get_oloc(hid_t obj_id);
-static herr_t H5O_group_bh_info(H5F_t *f, hid_t dxpl_id, H5O_t *oh,
+static herr_t H5O_group_bh_info(const H5O_loc_t *loc, hid_t dxpl_id, H5O_t *oh,
H5_ih_info_t *bh_info);
@@ -333,7 +333,7 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_group_bh_info(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5_ih_info_t *bh_info)
+H5O_group_bh_info(const H5O_loc_t *loc, hid_t dxpl_id, H5O_t *oh, H5_ih_info_t *bh_info)
{
htri_t exists; /* Flag if header message of interest exists */
H5HF_t *fheap = NULL; /* Fractal heap handle */
@@ -344,7 +344,9 @@ H5O_group_bh_info(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5_ih_info_t *bh_info)
FUNC_ENTER_NOAPI_NOINIT_TAG(dxpl_id, oh->cache_info.addr, FAIL)
/* Sanity check */
- HDassert(f);
+ HDassert(loc);
+ HDassert(loc->file);
+ HDassert(H5F_addr_defined(loc->addr));
HDassert(oh);
HDassert(bh_info);
@@ -355,13 +357,13 @@ H5O_group_bh_info(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5_ih_info_t *bh_info)
H5O_linfo_t linfo; /* Link info message */
/* Get "new style" group info */
- if(NULL == H5O_msg_read_oh(f, dxpl_id, oh, H5O_LINFO_ID, &linfo))
+ if(NULL == H5O_msg_read_oh(loc->file, dxpl_id, oh, H5O_LINFO_ID, &linfo))
HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't read LINFO message")
/* Check if name index available */
if(H5F_addr_defined(linfo.name_bt2_addr)) {
/* Open the name index v2 B-tree */
- if(NULL == (bt2_name = H5B2_open(f, dxpl_id, linfo.name_bt2_addr, NULL)))
+ if(NULL == (bt2_name = H5B2_open(loc->file, dxpl_id, linfo.name_bt2_addr, NULL)))
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index")
/* Get name index B-tree size */
@@ -372,7 +374,7 @@ H5O_group_bh_info(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5_ih_info_t *bh_info)
/* Check if creation order index available */
if(H5F_addr_defined(linfo.corder_bt2_addr)) {
/* Open the creation order index v2 B-tree */
- if(NULL == (bt2_corder = H5B2_open(f, dxpl_id, linfo.corder_bt2_addr, NULL)))
+ if(NULL == (bt2_corder = H5B2_open(loc->file, dxpl_id, linfo.corder_bt2_addr, NULL)))
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index")
/* Get creation order index B-tree size */
@@ -383,7 +385,7 @@ H5O_group_bh_info(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5_ih_info_t *bh_info)
/* Get fractal heap size, if available */
if(H5F_addr_defined(linfo.fheap_addr)) {
/* Open the fractal heap for links */
- if(NULL == (fheap = H5HF_open(f, dxpl_id, linfo.fheap_addr)))
+ if(NULL == (fheap = H5HF_open(loc->file, dxpl_id, linfo.fheap_addr)))
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap")
/* Get heap storage size */
@@ -395,11 +397,11 @@ H5O_group_bh_info(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5_ih_info_t *bh_info)
H5O_stab_t stab; /* Info about symbol table */
/* Must be "old style" group, get symbol table message */
- if(NULL == H5O_msg_read_oh(f, dxpl_id, oh, H5O_STAB_ID, &stab))
+ if(NULL == H5O_msg_read_oh(loc->file, dxpl_id, oh, H5O_STAB_ID, &stab))
HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't find LINFO nor STAB messages")
/* Get symbol table size info */
- if(H5G__stab_bh_size(f, dxpl_id, &stab, bh_info) < 0)
+ if(H5G__stab_bh_size(loc->file, dxpl_id, &stab, bh_info) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve symbol table size info")
} /* end else */
diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h
index 1457e62..4cb6f9b 100644
--- a/src/H5Gpkg.h
+++ b/src/H5Gpkg.h
@@ -516,7 +516,6 @@ H5_DLL herr_t H5G__name_init(H5G_name_t *name, const char *path);
/*
* These functions operate on group "locations"
*/
-H5_DLL herr_t H5G__loc_copy(H5G_loc_t *dst, const H5G_loc_t *src, H5_copy_depth_t depth);
H5_DLL herr_t H5G__loc_insert(H5G_loc_t *grp_loc, const char *name,
H5G_loc_t *obj_loc, H5O_type_t obj_type, const void *crt_info, hid_t dxpl_id);
diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h
index baf4209..1ab5522 100644
--- a/src/H5Gprivate.h
+++ b/src/H5Gprivate.h
@@ -280,6 +280,7 @@ H5_DLL H5RS_str_t *H5G_build_fullpath_refstr_str(H5RS_str_t *path_r, const char
* These functions operate on group "locations"
*/
H5_DLL herr_t H5G_loc(hid_t loc_id, H5G_loc_t *loc);
+H5_DLL herr_t H5G_loc_copy(H5G_loc_t *dst, const H5G_loc_t *src, H5_copy_depth_t depth);
H5_DLL herr_t H5G_loc_find(const H5G_loc_t *loc, const char *name,
H5G_loc_t *obj_loc/*out*/, hid_t lapl_id, hid_t dxpl_id);
H5_DLL herr_t H5G_loc_find_by_idx(H5G_loc_t *loc, const char *group_name,
diff --git a/src/H5Gstab.c b/src/H5Gstab.c
index 7f4b8df..3a7cd9e 100644
--- a/src/H5Gstab.c
+++ b/src/H5Gstab.c
@@ -156,16 +156,16 @@ H5G__stab_create_components(H5F_t *f, H5O_stab_t *stab, size_t size_hint, hid_t
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create B-tree")
/* Create symbol table private heap */
- if(H5HL_create(f, dxpl_id, size_hint, &(stab->heap_addr)/*out*/) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create heap")
+ if(FAIL == H5HL_create(f, dxpl_id, size_hint, &(stab->heap_addr)/*out*/))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create heap")
/* Pin the heap down in memory */
if(NULL == (heap = H5HL_protect(f, dxpl_id, stab->heap_addr, H5AC__NO_FLAGS_SET)))
HGOTO_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to protect symbol table heap")
/* Insert name into the heap */
- if((size_t)(-1) == (name_offset = H5HL_insert(f, dxpl_id, heap, (size_t)1, "")))
- HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "can't insert name into heap")
+ if(UFAIL == (name_offset = H5HL_insert(f, dxpl_id, heap, (size_t)1, "")))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "can't insert name into heap")
/*
* B-tree's won't work if the first name isn't at the beginning
@@ -175,7 +175,7 @@ H5G__stab_create_components(H5F_t *f, H5O_stab_t *stab, size_t size_hint, hid_t
done:
/* Release resources */
- if(heap && H5HL_unprotect(heap) < 0)
+ if(heap && FAIL == H5HL_unprotect(heap))
HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap")
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5Gtraverse.c b/src/H5Gtraverse.c
index 5121f45..4d84e9f 100644
--- a/src/H5Gtraverse.c
+++ b/src/H5Gtraverse.c
@@ -201,7 +201,7 @@ H5G_traverse_ud(const H5G_loc_t *grp_loc/*in,out*/, const H5O_link_t *lnk,
grp_loc_copy.path = &grp_path_copy;
grp_loc_copy.oloc = &grp_oloc_copy;
H5G_loc_reset(&grp_loc_copy);
- if(H5G__loc_copy(&grp_loc_copy, grp_loc, H5_COPY_DEEP) < 0)
+ if(H5G_loc_copy(&grp_loc_copy, grp_loc, H5_COPY_DEEP) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, FAIL, "unable to copy object location")
/* Create a group ID to pass to the user-defined callback */
@@ -263,7 +263,7 @@ H5G_traverse_ud(const H5G_loc_t *grp_loc/*in,out*/, const H5O_link_t *lnk,
H5G_loc_free(obj_loc);
/* Copy new object's location information */
- H5G__loc_copy(obj_loc, &new_loc, H5_COPY_DEEP);
+ H5G_loc_copy(obj_loc, &new_loc, H5_COPY_DEEP);
/* Hold the file open until we free this object header (otherwise the
* object location will be invalidated when the file closes).
@@ -344,7 +344,7 @@ H5G_traverse_slink(const H5G_loc_t *grp_loc, const H5O_link_t *lnk,
/* ("tracking the names properly" means to ignore the effects of the
* link traversal on the object's & group's paths - QAK)
*/
- H5G__loc_copy(&tmp_grp_loc, grp_loc, H5_COPY_DEEP);
+ H5G_loc_copy(&tmp_grp_loc, grp_loc, H5_COPY_DEEP);
tmp_grp_loc_set = TRUE;
/* Hold the object's group hier. path to restore later */
@@ -544,7 +544,7 @@ H5G_traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target,
#endif /* H5_USING_MEMCHECKER */
/* Deep copy of the starting location to group location */
- if(H5G__loc_copy(&grp_loc, &loc, H5_COPY_DEEP) < 0)
+ if(H5G_loc_copy(&grp_loc, &loc, H5_COPY_DEEP) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to copy location")
group_copy = TRUE;
@@ -761,7 +761,7 @@ H5G_traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target,
/* Transfer "ownership" of the object's information to the group object */
H5G_loc_free(&grp_loc);
- H5G__loc_copy(&grp_loc, &obj_loc, H5_COPY_SHALLOW);
+ H5G_loc_copy(&grp_loc, &obj_loc, H5_COPY_SHALLOW);
H5G_loc_reset(&obj_loc);
obj_loc_valid = FALSE;
diff --git a/src/H5HFbtree2.c b/src/H5HFbtree2.c
index 2f3d0e4..d82de93 100644
--- a/src/H5HFbtree2.c
+++ b/src/H5HFbtree2.c
@@ -68,40 +68,50 @@ typedef struct H5HF_huge_bt2_ctx_t {
/* v2 B-tree driver callbacks */
-static void *H5HF_huge_bt2_crt_context(void *udata);
-static herr_t H5HF_huge_bt2_dst_context(void *ctx);
-
-static herr_t H5HF_huge_bt2_indir_store(void *native, const void *udata);
-static herr_t H5HF_huge_bt2_indir_compare(const void *rec1, const void *rec2);
-static herr_t H5HF_huge_bt2_indir_encode(uint8_t *raw, const void *native,
+/* Common callbacks */
+static void *H5HF__huge_bt2_crt_context(void *udata);
+static herr_t H5HF__huge_bt2_dst_context(void *ctx);
+static void *H5HF__huge_bt2_crt_dbg_context(H5F_t *f, hid_t dxpl_id, haddr_t addr);
+
+/* Callbacks for indirect objects */
+static herr_t H5HF__huge_bt2_indir_store(void *native, const void *udata);
+static herr_t H5HF__huge_bt2_indir_compare(const void *rec1, const void *rec2);
+static herr_t H5HF__huge_bt2_indir_encode(uint8_t *raw, const void *native,
void *ctx);
-static herr_t H5HF_huge_bt2_indir_decode(const uint8_t *raw, void *native,
+static herr_t H5HF__huge_bt2_indir_decode(const uint8_t *raw, void *native,
void *ctx);
-static herr_t H5HF_huge_bt2_indir_debug(FILE *stream, int indent, int fwidth, const void *record);
+static herr_t H5HF__huge_bt2_indir_debug(FILE *stream, int indent, int fwidth,
+ const void *record, const void *_udata);
-static herr_t H5HF_huge_bt2_filt_indir_store(void *native, const void *udata);
-static herr_t H5HF_huge_bt2_filt_indir_compare(const void *rec1, const void *rec2);
-static herr_t H5HF_huge_bt2_filt_indir_encode(uint8_t *raw, const void *native,
+/* Callbacks for filtered indirect objects */
+static herr_t H5HF__huge_bt2_filt_indir_store(void *native, const void *udata);
+static herr_t H5HF__huge_bt2_filt_indir_compare(const void *rec1, const void *rec2);
+static herr_t H5HF__huge_bt2_filt_indir_encode(uint8_t *raw, const void *native,
void *ctx);
-static herr_t H5HF_huge_bt2_filt_indir_decode(const uint8_t *raw, void *native,
+static herr_t H5HF__huge_bt2_filt_indir_decode(const uint8_t *raw, void *native,
void *ctx);
-static herr_t H5HF_huge_bt2_filt_indir_debug(FILE *stream, int indent, int fwidth, const void *record);
+static herr_t H5HF__huge_bt2_filt_indir_debug(FILE *stream, int indent, int fwidth,
+ const void *record, const void *_udata);
-static herr_t H5HF_huge_bt2_dir_store(void *native, const void *udata);
-static herr_t H5HF_huge_bt2_dir_compare(const void *rec1, const void *rec2);
-static herr_t H5HF_huge_bt2_dir_encode(uint8_t *raw, const void *native,
+/* Callbacks for direct objects */
+static herr_t H5HF__huge_bt2_dir_store(void *native, const void *udata);
+static herr_t H5HF__huge_bt2_dir_compare(const void *rec1, const void *rec2);
+static herr_t H5HF__huge_bt2_dir_encode(uint8_t *raw, const void *native,
void *ctx);
-static herr_t H5HF_huge_bt2_dir_decode(const uint8_t *raw, void *native,
+static herr_t H5HF__huge_bt2_dir_decode(const uint8_t *raw, void *native,
void *ctx);
-static herr_t H5HF_huge_bt2_dir_debug(FILE *stream, int indent, int fwidth, const void *record);
+static herr_t H5HF__huge_bt2_dir_debug(FILE *stream, int indent, int fwidth,
+ const void *record, const void *_udata);
-static herr_t H5HF_huge_bt2_filt_dir_store(void *native, const void *udata);
-static herr_t H5HF_huge_bt2_filt_dir_compare(const void *rec1, const void *rec2);
-static herr_t H5HF_huge_bt2_filt_dir_encode(uint8_t *raw, const void *native,
+/* Callbacks for filtered direct objects */
+static herr_t H5HF__huge_bt2_filt_dir_store(void *native, const void *udata);
+static herr_t H5HF__huge_bt2_filt_dir_compare(const void *rec1, const void *rec2);
+static herr_t H5HF__huge_bt2_filt_dir_encode(uint8_t *raw, const void *native,
void *ctx);
-static herr_t H5HF_huge_bt2_filt_dir_decode(const uint8_t *raw, void *native,
+static herr_t H5HF__huge_bt2_filt_dir_decode(const uint8_t *raw, void *native,
void *ctx);
-static herr_t H5HF_huge_bt2_filt_dir_debug(FILE *stream, int indent, int fwidth, const void *record);
+static herr_t H5HF__huge_bt2_filt_dir_debug(FILE *stream, int indent, int fwidth,
+ const void *record, const void *_udata);
/*********************/
/* Package Variables */
@@ -111,13 +121,15 @@ const H5B2_class_t H5HF_HUGE_BT2_INDIR[1]={{ /* B-tree class information */
H5B2_FHEAP_HUGE_INDIR_ID, /* Type of B-tree */
"H5B2_FHEAP_HUGE_INDIR_ID", /* Name of B-tree class */
sizeof(H5HF_huge_bt2_indir_rec_t), /* Size of native record */
- H5HF_huge_bt2_crt_context, /* Create client callback context */
- H5HF_huge_bt2_dst_context, /* Destroy client callback context */
- H5HF_huge_bt2_indir_store, /* Record storage callback */
- H5HF_huge_bt2_indir_compare, /* Record comparison callback */
- H5HF_huge_bt2_indir_encode, /* Record encoding callback */
- H5HF_huge_bt2_indir_decode, /* Record decoding callback */
- H5HF_huge_bt2_indir_debug /* Record debugging callback */
+ H5HF__huge_bt2_crt_context, /* Create client callback context */
+ H5HF__huge_bt2_dst_context, /* Destroy client callback context */
+ H5HF__huge_bt2_indir_store, /* Record storage callback */
+ H5HF__huge_bt2_indir_compare, /* Record comparison callback */
+ H5HF__huge_bt2_indir_encode, /* Record encoding callback */
+ H5HF__huge_bt2_indir_decode, /* Record decoding callback */
+ H5HF__huge_bt2_indir_debug, /* Record debugging callback */
+ H5HF__huge_bt2_crt_dbg_context, /* Create debugging context */
+ H5HF__huge_bt2_dst_context /* Destroy debugging context */
}};
/* v2 B-tree class for indirectly accessed, filtered 'huge' objects */
@@ -125,13 +137,15 @@ const H5B2_class_t H5HF_HUGE_BT2_FILT_INDIR[1]={{ /* B-tree class information */
H5B2_FHEAP_HUGE_FILT_INDIR_ID, /* Type of B-tree */
"H5B2_FHEAP_HUGE_FILT_INDIR_ID", /* Name of B-tree class */
sizeof(H5HF_huge_bt2_filt_indir_rec_t), /* Size of native record */
- H5HF_huge_bt2_crt_context, /* Create client callback context */
- H5HF_huge_bt2_dst_context, /* Destroy client callback context */
- H5HF_huge_bt2_filt_indir_store, /* Record storage callback */
- H5HF_huge_bt2_filt_indir_compare, /* Record comparison callback */
- H5HF_huge_bt2_filt_indir_encode, /* Record encoding callback */
- H5HF_huge_bt2_filt_indir_decode, /* Record decoding callback */
- H5HF_huge_bt2_filt_indir_debug /* Record debugging callback */
+ H5HF__huge_bt2_crt_context, /* Create client callback context */
+ H5HF__huge_bt2_dst_context, /* Destroy client callback context */
+ H5HF__huge_bt2_filt_indir_store, /* Record storage callback */
+ H5HF__huge_bt2_filt_indir_compare, /* Record comparison callback */
+ H5HF__huge_bt2_filt_indir_encode, /* Record encoding callback */
+ H5HF__huge_bt2_filt_indir_decode, /* Record decoding callback */
+ H5HF__huge_bt2_filt_indir_debug, /* Record debugging callback */
+ H5HF__huge_bt2_crt_dbg_context, /* Create debugging context */
+ H5HF__huge_bt2_dst_context /* Destroy debugging context */
}};
/* v2 B-tree class for directly accessed 'huge' objects */
@@ -139,13 +153,15 @@ const H5B2_class_t H5HF_HUGE_BT2_DIR[1]={{ /* B-tree class information */
H5B2_FHEAP_HUGE_DIR_ID, /* Type of B-tree */
"H5B2_FHEAP_HUGE_DIR_ID", /* Name of B-tree class */
sizeof(H5HF_huge_bt2_dir_rec_t), /* Size of native record */
- H5HF_huge_bt2_crt_context, /* Create client callback context */
- H5HF_huge_bt2_dst_context, /* Destroy client callback context */
- H5HF_huge_bt2_dir_store, /* Record storage callback */
- H5HF_huge_bt2_dir_compare, /* Record comparison callback */
- H5HF_huge_bt2_dir_encode, /* Record encoding callback */
- H5HF_huge_bt2_dir_decode, /* Record decoding callback */
- H5HF_huge_bt2_dir_debug /* Record debugging callback */
+ H5HF__huge_bt2_crt_context, /* Create client callback context */
+ H5HF__huge_bt2_dst_context, /* Destroy client callback context */
+ H5HF__huge_bt2_dir_store, /* Record storage callback */
+ H5HF__huge_bt2_dir_compare, /* Record comparison callback */
+ H5HF__huge_bt2_dir_encode, /* Record encoding callback */
+ H5HF__huge_bt2_dir_decode, /* Record decoding callback */
+ H5HF__huge_bt2_dir_debug, /* Record debugging callback */
+ H5HF__huge_bt2_crt_dbg_context, /* Create debugging context */
+ H5HF__huge_bt2_dst_context /* Destroy debugging context */
}};
/* v2 B-tree class for directly accessed, filtered 'huge' objects */
@@ -153,13 +169,15 @@ const H5B2_class_t H5HF_HUGE_BT2_FILT_DIR[1]={{ /* B-tree class information */
H5B2_FHEAP_HUGE_FILT_DIR_ID, /* Type of B-tree */
"H5B2_FHEAP_HUGE_FILT_DIR_ID", /* Name of B-tree class */
sizeof(H5HF_huge_bt2_filt_dir_rec_t), /* Size of native record */
- H5HF_huge_bt2_crt_context, /* Create client callback context */
- H5HF_huge_bt2_dst_context, /* Destroy client callback context */
- H5HF_huge_bt2_filt_dir_store, /* Record storage callback */
- H5HF_huge_bt2_filt_dir_compare, /* Record comparison callback */
- H5HF_huge_bt2_filt_dir_encode, /* Record encoding callback */
- H5HF_huge_bt2_filt_dir_decode, /* Record decoding callback */
- H5HF_huge_bt2_filt_dir_debug /* Record debugging callback */
+ H5HF__huge_bt2_crt_context, /* Create client callback context */
+ H5HF__huge_bt2_dst_context, /* Destroy client callback context */
+ H5HF__huge_bt2_filt_dir_store, /* Record storage callback */
+ H5HF__huge_bt2_filt_dir_compare, /* Record comparison callback */
+ H5HF__huge_bt2_filt_dir_encode, /* Record encoding callback */
+ H5HF__huge_bt2_filt_dir_decode, /* Record decoding callback */
+ H5HF__huge_bt2_filt_dir_debug, /* Record debugging callback */
+ H5HF__huge_bt2_crt_dbg_context, /* Create debugging context */
+ H5HF__huge_bt2_dst_context /* Destroy debugging context */
}};
/*****************************/
@@ -177,7 +195,7 @@ H5FL_DEFINE_STATIC(H5HF_huge_bt2_ctx_t);
/*-------------------------------------------------------------------------
- * Function: H5HF_huge_bt2_crt_context
+ * Function: H5HF__huge_bt2_crt_context
*
* Purpose: Create client callback context
*
@@ -192,13 +210,13 @@ H5FL_DEFINE_STATIC(H5HF_huge_bt2_ctx_t);
*-------------------------------------------------------------------------
*/
static void *
-H5HF_huge_bt2_crt_context(void *_f)
+H5HF__huge_bt2_crt_context(void *_f)
{
H5F_t *f = (H5F_t *)_f; /* User data for building callback context */
H5HF_huge_bt2_ctx_t *ctx; /* Callback context structure */
void *ret_value = NULL; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_STATIC
/* Sanity check */
HDassert(f);
@@ -216,11 +234,11 @@ H5HF_huge_bt2_crt_context(void *_f)
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5HF_huge_bt2_crt_context() */
+} /* H5HF__huge_bt2_crt_context() */
/*-------------------------------------------------------------------------
- * Function: H5HF_huge_bt2_dst_context
+ * Function: H5HF__huge_bt2_dst_context
*
* Purpose: Destroy client callback context
*
@@ -235,11 +253,11 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5HF_huge_bt2_dst_context(void *_ctx)
+H5HF__huge_bt2_dst_context(void *_ctx)
{
H5HF_huge_bt2_ctx_t *ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
/* Sanity check */
HDassert(ctx);
@@ -248,11 +266,51 @@ H5HF_huge_bt2_dst_context(void *_ctx)
ctx = H5FL_FREE(H5HF_huge_bt2_ctx_t, ctx);
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5HF_huge_bt2_dst_context() */
+} /* H5HF__huge_bt2_dst_context() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5HF__huge_bt2_crt_dbg_context
+ *
+ * Purpose: Create context for debugging callback
+ *
+ * Return: Success: non-NULL
+ * Failure: NULL
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, December 1, 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+static void *
+H5HF__huge_bt2_crt_dbg_context(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t H5_ATTR_UNUSED addr)
+{
+ H5HF_huge_bt2_ctx_t *ctx; /* Callback context structure */
+ void *ret_value = NULL; /* Return value */
+
+ FUNC_ENTER_STATIC
+
+ /* Sanity check */
+ HDassert(f);
+
+ /* Allocate callback context */
+ if(NULL == (ctx = H5FL_MALLOC(H5HF_huge_bt2_ctx_t)))
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "can't allocate callback context")
+
+ /* Determine the size of addresses & lengths in the file */
+ ctx->sizeof_addr = H5F_SIZEOF_ADDR(f);
+ ctx->sizeof_size = H5F_SIZEOF_SIZE(f);
+
+ /* Set return value */
+ ret_value = ctx;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5HF__huge_bt2_crt_dbg_context() */
/*-------------------------------------------------------------------------
- * Function: H5HF_huge_bt2_indir_found
+ * Function: H5HF__huge_bt2_indir_found
*
* Purpose: Retrieve record for indirectly accessed 'huge' object, when
* it's found in the v2 B-tree
@@ -266,24 +324,18 @@ H5HF_huge_bt2_dst_context(void *_ctx)
*-------------------------------------------------------------------------
*/
herr_t
-H5HF_huge_bt2_indir_found(const void *nrecord, void *op_data)
+H5HF__huge_bt2_indir_found(const void *nrecord, void *op_data)
{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
-
-#ifdef QAK
-HDfprintf(stderr, "%s: nrecord = {%a, %Hu, %Hu}\n", "H5HF_huge_bt2_indir_found",
- ((const H5HF_huge_bt2_indir_rec_t *)nrecord)->addr,
- ((const H5HF_huge_bt2_indir_rec_t *)nrecord)->len,
- ((const H5HF_huge_bt2_indir_rec_t *)nrecord)->id);
-#endif /* QAK */
+ FUNC_ENTER_PACKAGE_NOERR
+
*(H5HF_huge_bt2_indir_rec_t *)op_data = *(const H5HF_huge_bt2_indir_rec_t *)nrecord;
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5HF_huge_bt2_indir_found() */
+} /* H5HF__huge_bt2_indir_found() */
/*-------------------------------------------------------------------------
- * Function: H5HF_huge_bt2_indir_remove
+ * Function: H5HF__huge_bt2_indir_remove
*
* Purpose: Free space for indirectly accessed 'huge' object, as v2 B-tree
* is being deleted or v2 B-tree node is removed
@@ -297,12 +349,12 @@ HDfprintf(stderr, "%s: nrecord = {%a, %Hu, %Hu}\n", "H5HF_huge_bt2_indir_found",
*-------------------------------------------------------------------------
*/
herr_t
-H5HF_huge_bt2_indir_remove(const void *nrecord, void *_udata)
+H5HF__huge_bt2_indir_remove(const void *nrecord, void *_udata)
{
H5HF_huge_remove_ud_t *udata = (H5HF_huge_remove_ud_t *)_udata; /* User callback data */
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_PACKAGE
/* Free the space in the file for the object being removed */
if(H5MF_xfree(udata->hdr->f, H5FD_MEM_FHEAP_HUGE_OBJ, udata->dxpl_id, ((const H5HF_huge_bt2_indir_rec_t *)nrecord)->addr, ((const H5HF_huge_bt2_indir_rec_t *)nrecord)->len) < 0)
@@ -313,11 +365,11 @@ H5HF_huge_bt2_indir_remove(const void *nrecord, void *_udata)
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5HF_huge_bt2_indir_remove() */
+} /* H5HF__huge_bt2_indir_remove() */
/*-------------------------------------------------------------------------
- * Function: H5HF_huge_bt2_indir_store
+ * Function: H5HF__huge_bt2_indir_store
*
* Purpose: Store native information into record for v2 B-tree
*
@@ -330,18 +382,18 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5HF_huge_bt2_indir_store(void *nrecord, const void *udata)
+H5HF__huge_bt2_indir_store(void *nrecord, const void *udata)
{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
*(H5HF_huge_bt2_indir_rec_t *)nrecord = *(const H5HF_huge_bt2_indir_rec_t *)udata;
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5HF_huge_bt2_indir_store() */
+} /* H5HF__huge_bt2_indir_store() */
/*-------------------------------------------------------------------------
- * Function: H5HF_huge_bt2_indir_compare
+ * Function: H5HF__huge_bt2_indir_compare
*
* Purpose: Compare two native information records, according to some key
*
@@ -355,25 +407,16 @@ H5HF_huge_bt2_indir_store(void *nrecord, const void *udata)
*-------------------------------------------------------------------------
*/
static herr_t
-H5HF_huge_bt2_indir_compare(const void *_rec1, const void *_rec2)
-{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
-
-#ifdef QAK
+H5HF__huge_bt2_indir_compare(const void *_rec1, const void *_rec2)
{
-const H5HF_huge_bt2_indir_rec_t *rec1 = (const H5HF_huge_bt2_indir_rec_t *)_rec1;
-const H5HF_huge_bt2_indir_rec_t *rec2 = (const H5HF_huge_bt2_indir_rec_t *)_rec2;
+ FUNC_ENTER_STATIC_NOERR
-HDfprintf(stderr, "%s: rec1 = {%a, %Hu, %Hu}\n", "H5HF_huge_bt2_indir_compare", rec1->addr, rec1->len, rec1->id);
-HDfprintf(stderr, "%s: rec2 = {%a, %Hu, %Hu}\n", "H5HF_huge_bt2_indir_compare", rec2->addr, rec2->len, rec2->id);
-}
-#endif /* QAK */
FUNC_LEAVE_NOAPI((herr_t)(((const H5HF_huge_bt2_indir_rec_t *)_rec1)->id - ((const H5HF_huge_bt2_indir_rec_t *)_rec2)->id))
-} /* H5HF_huge_bt2_indir_compare() */
+} /* H5HF__huge_bt2_indir_compare() */
/*-------------------------------------------------------------------------
- * Function: H5HF_huge_bt2_indir_encode
+ * Function: H5HF__huge_bt2_indir_encode
*
* Purpose: Encode native information into raw form for storing on disk
*
@@ -386,12 +429,12 @@ HDfprintf(stderr, "%s: rec2 = {%a, %Hu, %Hu}\n", "H5HF_huge_bt2_indir_compare",
*-------------------------------------------------------------------------
*/
static herr_t
-H5HF_huge_bt2_indir_encode(uint8_t *raw, const void *_nrecord, void *_ctx)
+H5HF__huge_bt2_indir_encode(uint8_t *raw, const void *_nrecord, void *_ctx)
{
H5HF_huge_bt2_ctx_t *ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */
const H5HF_huge_bt2_indir_rec_t *nrecord = (const H5HF_huge_bt2_indir_rec_t *)_nrecord;
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
/* Sanity check */
HDassert(ctx);
@@ -402,11 +445,11 @@ H5HF_huge_bt2_indir_encode(uint8_t *raw, const void *_nrecord, void *_ctx)
H5F_ENCODE_LENGTH_LEN(raw, nrecord->id, ctx->sizeof_size);
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5HF_huge_bt2_indir_encode() */
+} /* H5HF__huge_bt2_indir_encode() */
/*-------------------------------------------------------------------------
- * Function: H5HF_huge_bt2_indir_decode
+ * Function: H5HF__huge_bt2_indir_decode
*
* Purpose: Decode raw disk form of record into native form
*
@@ -419,12 +462,12 @@ H5HF_huge_bt2_indir_encode(uint8_t *raw, const void *_nrecord, void *_ctx)
*-------------------------------------------------------------------------
*/
static herr_t
-H5HF_huge_bt2_indir_decode(const uint8_t *raw, void *_nrecord, void *_ctx)
+H5HF__huge_bt2_indir_decode(const uint8_t *raw, void *_nrecord, void *_ctx)
{
H5HF_huge_bt2_ctx_t *ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */
H5HF_huge_bt2_indir_rec_t *nrecord = (H5HF_huge_bt2_indir_rec_t *)_nrecord;
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
/* Sanity check */
HDassert(ctx);
@@ -435,11 +478,11 @@ H5HF_huge_bt2_indir_decode(const uint8_t *raw, void *_nrecord, void *_ctx)
H5F_DECODE_LENGTH_LEN(raw, nrecord->id, ctx->sizeof_size);
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5HF_huge_bt2_indir_decode() */
+} /* H5HF__huge_bt2_indir_decode() */
/*-------------------------------------------------------------------------
- * Function: H5HF_huge_bt2_indir_debug
+ * Function: H5HF__huge_bt2_indir_debug
*
* Purpose: Debug native form of record
*
@@ -452,21 +495,22 @@ H5HF_huge_bt2_indir_decode(const uint8_t *raw, void *_nrecord, void *_ctx)
*-------------------------------------------------------------------------
*/
static herr_t
-H5HF_huge_bt2_indir_debug(FILE *stream, int indent, int fwidth, const void *_nrecord)
+H5HF__huge_bt2_indir_debug(FILE *stream, int indent, int fwidth,
+ const void *_nrecord, const void H5_ATTR_UNUSED *_udata)
{
const H5HF_huge_bt2_indir_rec_t *nrecord = (const H5HF_huge_bt2_indir_rec_t *)_nrecord;
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
HDfprintf(stream, "%*s%-*s {%a, %Hu, %Hu}\n", indent, "", fwidth, "Record:",
nrecord->addr, nrecord->len, nrecord->id);
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5HF_huge_bt2_indir_debug() */
+} /* H5HF__huge_bt2_indir_debug() */
/*-------------------------------------------------------------------------
- * Function: H5HF_huge_bt2_filt_indir_found
+ * Function: H5HF__huge_bt2_filt_indir_found
*
* Purpose: Retrieve record for indirectly accessed, filtered 'huge' object,
* when it's found in the v2 B-tree
@@ -480,26 +524,18 @@ H5HF_huge_bt2_indir_debug(FILE *stream, int indent, int fwidth, const void *_nre
*-------------------------------------------------------------------------
*/
herr_t
-H5HF_huge_bt2_filt_indir_found(const void *nrecord, void *op_data)
+H5HF__huge_bt2_filt_indir_found(const void *nrecord, void *op_data)
{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
-
-#ifdef QAK
-HDfprintf(stderr, "%s: nrecord = {%a, %Hu, %x, %Hu, %Hu}\n", "H5HF_huge_bt2_filt_indir_found",
- ((const H5HF_huge_bt2_filt_indir_rec_t *)nrecord)->addr,
- ((const H5HF_huge_bt2_filt_indir_rec_t *)nrecord)->len,
- ((const H5HF_huge_bt2_filt_indir_rec_t *)nrecord)->filter_mask,
- ((const H5HF_huge_bt2_filt_indir_rec_t *)nrecord)->obj_size,
- ((const H5HF_huge_bt2_filt_indir_rec_t *)nrecord)->id);
-#endif /* QAK */
+ FUNC_ENTER_PACKAGE_NOERR
+
*(H5HF_huge_bt2_filt_indir_rec_t *)op_data = *(const H5HF_huge_bt2_filt_indir_rec_t *)nrecord;
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5HF_huge_bt2_filt_indir_found() */
+} /* H5HF__huge_bt2_filt_indir_found() */
/*-------------------------------------------------------------------------
- * Function: H5HF_huge_bt2_filt_indir_remove
+ * Function: H5HF__huge_bt2_filt_indir_remove
*
* Purpose: Free space for indirectly accessed, filtered 'huge' object, as
* v2 B-tree is being deleted or v2 B-tree node is removed
@@ -513,12 +549,12 @@ HDfprintf(stderr, "%s: nrecord = {%a, %Hu, %x, %Hu, %Hu}\n", "H5HF_huge_bt2_filt
*-------------------------------------------------------------------------
*/
herr_t
-H5HF_huge_bt2_filt_indir_remove(const void *nrecord, void *_udata)
+H5HF__huge_bt2_filt_indir_remove(const void *nrecord, void *_udata)
{
H5HF_huge_remove_ud_t *udata = (H5HF_huge_remove_ud_t *)_udata; /* User callback data */
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_PACKAGE
/* Free the space in the file for the object being removed */
if(H5MF_xfree(udata->hdr->f, H5FD_MEM_FHEAP_HUGE_OBJ, udata->dxpl_id, ((const H5HF_huge_bt2_filt_indir_rec_t *)nrecord)->addr, ((const H5HF_huge_bt2_filt_indir_rec_t *)nrecord)->len) < 0)
@@ -529,11 +565,11 @@ H5HF_huge_bt2_filt_indir_remove(const void *nrecord, void *_udata)
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5HF_huge_bt2_filt_indir_remove() */
+} /* H5HF__huge_bt2_filt_indir_remove() */
/*-------------------------------------------------------------------------
- * Function: H5HF_huge_bt2_filt_indir_store
+ * Function: H5HF__huge_bt2_filt_indir_store
*
* Purpose: Store native information into record for v2 B-tree
*
@@ -546,18 +582,18 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5HF_huge_bt2_filt_indir_store(void *nrecord, const void *udata)
+H5HF__huge_bt2_filt_indir_store(void *nrecord, const void *udata)
{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
*(H5HF_huge_bt2_filt_indir_rec_t *)nrecord = *(const H5HF_huge_bt2_filt_indir_rec_t *)udata;
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5HF_huge_bt2_filt_indir_store() */
+} /* H5HF__huge_bt2_filt_indir_store() */
/*-------------------------------------------------------------------------
- * Function: H5HF_huge_bt2_filt_indir_compare
+ * Function: H5HF__huge_bt2_filt_indir_compare
*
* Purpose: Compare two native information records, according to some key
*
@@ -571,25 +607,16 @@ H5HF_huge_bt2_filt_indir_store(void *nrecord, const void *udata)
*-------------------------------------------------------------------------
*/
static herr_t
-H5HF_huge_bt2_filt_indir_compare(const void *_rec1, const void *_rec2)
+H5HF__huge_bt2_filt_indir_compare(const void *_rec1, const void *_rec2)
{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
-#ifdef QAK
-{
-const H5HF_huge_bt2_filt_indir_rec_t *rec1 = (const H5HF_huge_bt2_filt_indir_rec_t *)_rec1;
-const H5HF_huge_bt2_filt_indir_rec_t *rec2 = (const H5HF_huge_bt2_filt_indir_rec_t *)_rec2;
-
-HDfprintf(stderr, "%s: rec1 = {%a, %Hu, %x, %Hu, %Hu}\n", "H5HF_huge_bt2_filt_indir_compare", rec1->addr, rec1->len, rec1->filter_mask, rec1->obj_size, rec1->id);
-HDfprintf(stderr, "%s: rec2 = {%a, %Hu, %x, %Hu, %Hu}\n", "H5HF_huge_bt2_filt_indir_compare", rec2->addr, rec2->len, rec2->filter_mask, rec2->obj_size, rec2->id);
-}
-#endif /* QAK */
FUNC_LEAVE_NOAPI((herr_t)(((const H5HF_huge_bt2_filt_indir_rec_t *)_rec1)->id - ((const H5HF_huge_bt2_filt_indir_rec_t *)_rec2)->id))
-} /* H5HF_huge_bt2_filt_indir_compare() */
+} /* H5HF__huge_bt2_filt_indir_compare() */
/*-------------------------------------------------------------------------
- * Function: H5HF_huge_bt2_filt_indir_encode
+ * Function: H5HF__huge_bt2_filt_indir_encode
*
* Purpose: Encode native information into raw form for storing on disk
*
@@ -602,12 +629,12 @@ HDfprintf(stderr, "%s: rec2 = {%a, %Hu, %x, %Hu, %Hu}\n", "H5HF_huge_bt2_filt_in
*-------------------------------------------------------------------------
*/
static herr_t
-H5HF_huge_bt2_filt_indir_encode(uint8_t *raw, const void *_nrecord, void *_ctx)
+H5HF__huge_bt2_filt_indir_encode(uint8_t *raw, const void *_nrecord, void *_ctx)
{
H5HF_huge_bt2_ctx_t *ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */
const H5HF_huge_bt2_filt_indir_rec_t *nrecord = (const H5HF_huge_bt2_filt_indir_rec_t *)_nrecord;
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
/* Sanity check */
HDassert(ctx);
@@ -620,11 +647,11 @@ H5HF_huge_bt2_filt_indir_encode(uint8_t *raw, const void *_nrecord, void *_ctx)
H5F_ENCODE_LENGTH_LEN(raw, nrecord->id, ctx->sizeof_size);
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5HF_huge_bt2_filt_indir_encode() */
+} /* H5HF__huge_bt2_filt_indir_encode() */
/*-------------------------------------------------------------------------
- * Function: H5HF_huge_bt2_filt_indir_decode
+ * Function: H5HF__huge_bt2_filt_indir_decode
*
* Purpose: Decode raw disk form of record into native form
*
@@ -637,12 +664,12 @@ H5HF_huge_bt2_filt_indir_encode(uint8_t *raw, const void *_nrecord, void *_ctx)
*-------------------------------------------------------------------------
*/
static herr_t
-H5HF_huge_bt2_filt_indir_decode(const uint8_t *raw, void *_nrecord, void *_ctx)
+H5HF__huge_bt2_filt_indir_decode(const uint8_t *raw, void *_nrecord, void *_ctx)
{
H5HF_huge_bt2_ctx_t *ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */
H5HF_huge_bt2_filt_indir_rec_t *nrecord = (H5HF_huge_bt2_filt_indir_rec_t *)_nrecord;
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
/* Sanity check */
HDassert(ctx);
@@ -655,11 +682,11 @@ H5HF_huge_bt2_filt_indir_decode(const uint8_t *raw, void *_nrecord, void *_ctx)
H5F_DECODE_LENGTH_LEN(raw, nrecord->id, ctx->sizeof_size);
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5HF_huge_bt2_filt_indir_decode() */
+} /* H5HF__huge_bt2_filt_indir_decode() */
/*-------------------------------------------------------------------------
- * Function: H5HF_huge_bt2_filt_indir_debug
+ * Function: H5HF__huge_bt2_filt_indir_debug
*
* Purpose: Debug native form of record
*
@@ -672,21 +699,22 @@ H5HF_huge_bt2_filt_indir_decode(const uint8_t *raw, void *_nrecord, void *_ctx)
*-------------------------------------------------------------------------
*/
static herr_t
-H5HF_huge_bt2_filt_indir_debug(FILE *stream, int indent, int fwidth, const void *_nrecord)
+H5HF__huge_bt2_filt_indir_debug(FILE *stream, int indent, int fwidth,
+ const void *_nrecord, const void H5_ATTR_UNUSED *_udata)
{
const H5HF_huge_bt2_filt_indir_rec_t *nrecord = (const H5HF_huge_bt2_filt_indir_rec_t *)_nrecord;
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
HDfprintf(stream, "%*s%-*s {%a, %Hu, %x, %Hu, %Hu}\n", indent, "", fwidth, "Record:",
nrecord->addr, nrecord->len, nrecord->filter_mask, nrecord->obj_size, nrecord->id);
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5HF_huge_bt2_filt_indir_debug() */
+} /* H5HF__huge_bt2_filt_indir_debug() */
/*-------------------------------------------------------------------------
- * Function: H5HF_huge_bt2_dir_remove
+ * Function: H5HF__huge_bt2_dir_remove
*
* Purpose: Free space for directly accessed 'huge' object, as v2 B-tree
* is being deleted or v2 B-tree node is being removed
@@ -700,12 +728,12 @@ H5HF_huge_bt2_filt_indir_debug(FILE *stream, int indent, int fwidth, const void
*-------------------------------------------------------------------------
*/
herr_t
-H5HF_huge_bt2_dir_remove(const void *nrecord, void *_udata)
+H5HF__huge_bt2_dir_remove(const void *nrecord, void *_udata)
{
H5HF_huge_remove_ud_t *udata = (H5HF_huge_remove_ud_t *)_udata; /* User callback data */
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_PACKAGE
/* Free the space in the file for the object being removed */
if(H5MF_xfree(udata->hdr->f, H5FD_MEM_FHEAP_HUGE_OBJ, udata->dxpl_id, ((const H5HF_huge_bt2_indir_rec_t *)nrecord)->addr, ((const H5HF_huge_bt2_indir_rec_t *)nrecord)->len) < 0)
@@ -716,11 +744,11 @@ H5HF_huge_bt2_dir_remove(const void *nrecord, void *_udata)
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5HF_huge_bt2_dir_remove() */
+} /* H5HF__huge_bt2_dir_remove() */
/*-------------------------------------------------------------------------
- * Function: H5HF_huge_bt2_dir_store
+ * Function: H5HF__huge_bt2_dir_store
*
* Purpose: Store native information into record for v2 B-tree
*
@@ -733,18 +761,18 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5HF_huge_bt2_dir_store(void *nrecord, const void *udata)
+H5HF__huge_bt2_dir_store(void *nrecord, const void *udata)
{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
*(H5HF_huge_bt2_dir_rec_t *)nrecord = *(const H5HF_huge_bt2_dir_rec_t *)udata;
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5HF_huge_bt2_dir_store() */
+} /* H5HF__huge_bt2_dir_store() */
/*-------------------------------------------------------------------------
- * Function: H5HF_huge_bt2_dir_compare
+ * Function: H5HF__huge_bt2_dir_compare
*
* Purpose: Compare two native information records, according to some key
*
@@ -758,18 +786,14 @@ H5HF_huge_bt2_dir_store(void *nrecord, const void *udata)
*-------------------------------------------------------------------------
*/
static herr_t
-H5HF_huge_bt2_dir_compare(const void *_rec1, const void *_rec2)
+H5HF__huge_bt2_dir_compare(const void *_rec1, const void *_rec2)
{
const H5HF_huge_bt2_dir_rec_t *rec1 = (const H5HF_huge_bt2_dir_rec_t *)_rec1;
const H5HF_huge_bt2_dir_rec_t *rec2 = (const H5HF_huge_bt2_dir_rec_t *)_rec2;
herr_t ret_value = FAIL; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
-#ifdef QAK
-HDfprintf(stderr, "%s: rec1 = {%a, %Hu}\n", "H5HF_huge_bt2_dir_compare", rec1->addr, rec1->len);
-HDfprintf(stderr, "%s: rec2 = {%a, %Hu}\n", "H5HF_huge_bt2_dir_compare", rec2->addr, rec2->len);
-#endif /* QAK */
if(rec1->addr < rec2->addr)
ret_value = -1;
else if(rec1->addr > rec2->addr)
@@ -782,11 +806,11 @@ HDfprintf(stderr, "%s: rec2 = {%a, %Hu}\n", "H5HF_huge_bt2_dir_compare", rec2->a
ret_value = 0;
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5HF_huge_bt2_dir_compare() */
+} /* H5HF__huge_bt2_dir_compare() */
/*-------------------------------------------------------------------------
- * Function: H5HF_huge_bt2_dir_encode
+ * Function: H5HF__huge_bt2_dir_encode
*
* Purpose: Encode native information into raw form for storing on disk
*
@@ -799,12 +823,12 @@ HDfprintf(stderr, "%s: rec2 = {%a, %Hu}\n", "H5HF_huge_bt2_dir_compare", rec2->a
*-------------------------------------------------------------------------
*/
static herr_t
-H5HF_huge_bt2_dir_encode(uint8_t *raw, const void *_nrecord, void *_ctx)
+H5HF__huge_bt2_dir_encode(uint8_t *raw, const void *_nrecord, void *_ctx)
{
H5HF_huge_bt2_ctx_t *ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */
const H5HF_huge_bt2_dir_rec_t *nrecord = (const H5HF_huge_bt2_dir_rec_t *)_nrecord;
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
/* Sanity check */
HDassert(ctx);
@@ -814,11 +838,11 @@ H5HF_huge_bt2_dir_encode(uint8_t *raw, const void *_nrecord, void *_ctx)
H5F_ENCODE_LENGTH_LEN(raw, nrecord->len, ctx->sizeof_size);
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5HF_huge_bt2_dir_encode() */
+} /* H5HF__huge_bt2_dir_encode() */
/*-------------------------------------------------------------------------
- * Function: H5HF_huge_bt2_dir_decode
+ * Function: H5HF__huge_bt2_dir_decode
*
* Purpose: Decode raw disk form of record into native form
*
@@ -831,12 +855,12 @@ H5HF_huge_bt2_dir_encode(uint8_t *raw, const void *_nrecord, void *_ctx)
*-------------------------------------------------------------------------
*/
static herr_t
-H5HF_huge_bt2_dir_decode(const uint8_t *raw, void *_nrecord, void *_ctx)
+H5HF__huge_bt2_dir_decode(const uint8_t *raw, void *_nrecord, void *_ctx)
{
H5HF_huge_bt2_ctx_t *ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */
H5HF_huge_bt2_dir_rec_t *nrecord = (H5HF_huge_bt2_dir_rec_t *)_nrecord;
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
/* Sanity check */
HDassert(ctx);
@@ -846,11 +870,11 @@ H5HF_huge_bt2_dir_decode(const uint8_t *raw, void *_nrecord, void *_ctx)
H5F_DECODE_LENGTH_LEN(raw, nrecord->len, ctx->sizeof_size);
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5HF_huge_bt2_dir_decode() */
+} /* H5HF__huge_bt2_dir_decode() */
/*-------------------------------------------------------------------------
- * Function: H5HF_huge_bt2_dir_debug
+ * Function: H5HF__huge_bt2_dir_debug
*
* Purpose: Debug native form of record
*
@@ -863,21 +887,22 @@ H5HF_huge_bt2_dir_decode(const uint8_t *raw, void *_nrecord, void *_ctx)
*-------------------------------------------------------------------------
*/
static herr_t
-H5HF_huge_bt2_dir_debug(FILE *stream, int indent, int fwidth, const void *_nrecord)
+H5HF__huge_bt2_dir_debug(FILE *stream, int indent, int fwidth,
+ const void *_nrecord, const void H5_ATTR_UNUSED *_udata)
{
const H5HF_huge_bt2_dir_rec_t *nrecord = (const H5HF_huge_bt2_dir_rec_t *)_nrecord;
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
HDfprintf(stream, "%*s%-*s {%a, %Hu}\n", indent, "", fwidth, "Record:",
nrecord->addr, nrecord->len);
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5HF_huge_bt2_dir_debug() */
+} /* H5HF__huge_bt2_dir_debug() */
/*-------------------------------------------------------------------------
- * Function: H5HF_huge_bt2_filt_dir_found
+ * Function: H5HF__huge_bt2_filt_dir_found
*
* Purpose: Retrieve record for directly accessed, filtered 'huge' object,
* when it's found in the v2 B-tree
@@ -891,25 +916,18 @@ H5HF_huge_bt2_dir_debug(FILE *stream, int indent, int fwidth, const void *_nreco
*-------------------------------------------------------------------------
*/
herr_t
-H5HF_huge_bt2_filt_dir_found(const void *nrecord, void *op_data)
+H5HF__huge_bt2_filt_dir_found(const void *nrecord, void *op_data)
{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
-
-#ifdef QAK
-HDfprintf(stderr, "%s: nrecord = {%a, %Hu, %x, %Hu}\n", "H5HF_huge_bt2_filt_dir_found",
- ((const H5HF_huge_bt2_filt_dir_rec_t *)nrecord)->addr,
- ((const H5HF_huge_bt2_filt_dir_rec_t *)nrecord)->len,
- ((const H5HF_huge_bt2_filt_dir_rec_t *)nrecord)->filter_mask,
- ((const H5HF_huge_bt2_filt_dir_rec_t *)nrecord)->obj_size);
-#endif /* QAK */
+ FUNC_ENTER_PACKAGE_NOERR
+
*(H5HF_huge_bt2_filt_dir_rec_t *)op_data = *(const H5HF_huge_bt2_filt_dir_rec_t *)nrecord;
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5HF_huge_bt2_filt_dir_found() */
+} /* H5HF__huge_bt2_filt_dir_found() */
/*-------------------------------------------------------------------------
- * Function: H5HF_huge_bt2_filt_dir_remove
+ * Function: H5HF__huge_bt2_filt_dir_remove
*
* Purpose: Free space for directly accessed, filtered 'huge' object, as
* v2 B-tree is being deleted or v2 B-tree node is removed
@@ -923,12 +941,12 @@ HDfprintf(stderr, "%s: nrecord = {%a, %Hu, %x, %Hu}\n", "H5HF_huge_bt2_filt_dir_
*-------------------------------------------------------------------------
*/
herr_t
-H5HF_huge_bt2_filt_dir_remove(const void *nrecord, void *_udata)
+H5HF__huge_bt2_filt_dir_remove(const void *nrecord, void *_udata)
{
H5HF_huge_remove_ud_t *udata = (H5HF_huge_remove_ud_t *)_udata; /* User callback data */
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_PACKAGE
/* Free the space in the file for the object being removed */
if(H5MF_xfree(udata->hdr->f, H5FD_MEM_FHEAP_HUGE_OBJ, udata->dxpl_id, ((const H5HF_huge_bt2_filt_dir_rec_t *)nrecord)->addr, ((const H5HF_huge_bt2_filt_dir_rec_t *)nrecord)->len) < 0)
@@ -939,11 +957,11 @@ H5HF_huge_bt2_filt_dir_remove(const void *nrecord, void *_udata)
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5HF_huge_bt2_filt_dir_remove() */
+} /* H5HF__huge_bt2_filt_dir_remove() */
/*-------------------------------------------------------------------------
- * Function: H5HF_huge_bt2_filt_dir_store
+ * Function: H5HF__huge_bt2_filt_dir_store
*
* Purpose: Store native information into record for v2 B-tree
*
@@ -956,18 +974,18 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5HF_huge_bt2_filt_dir_store(void *nrecord, const void *udata)
+H5HF__huge_bt2_filt_dir_store(void *nrecord, const void *udata)
{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
*(H5HF_huge_bt2_filt_dir_rec_t *)nrecord = *(const H5HF_huge_bt2_filt_dir_rec_t *)udata;
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5HF_huge_bt2_filt_dir_store() */
+} /* H5HF__huge_bt2_filt_dir_store() */
/*-------------------------------------------------------------------------
- * Function: H5HF_huge_bt2_filt_dir_compare
+ * Function: H5HF__huge_bt2_filt_dir_compare
*
* Purpose: Compare two native information records, according to some key
*
@@ -981,18 +999,14 @@ H5HF_huge_bt2_filt_dir_store(void *nrecord, const void *udata)
*-------------------------------------------------------------------------
*/
static herr_t
-H5HF_huge_bt2_filt_dir_compare(const void *_rec1, const void *_rec2)
+H5HF__huge_bt2_filt_dir_compare(const void *_rec1, const void *_rec2)
{
const H5HF_huge_bt2_filt_dir_rec_t *rec1 = (const H5HF_huge_bt2_filt_dir_rec_t *)_rec1;
const H5HF_huge_bt2_filt_dir_rec_t *rec2 = (const H5HF_huge_bt2_filt_dir_rec_t *)_rec2;
herr_t ret_value = FAIL; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
-#ifdef QAK
-HDfprintf(stderr, "%s: rec1 = {%a, %Hu, %x, %Hu}\n", "H5HF_huge_bt2_filt_dir_compare", rec1->addr, rec1->len, rec1->filter_mask, rec1->obj_size);
-HDfprintf(stderr, "%s: rec2 = {%a, %Hu, %x, %Hu}\n", "H5HF_huge_bt2_filt_dir_compare", rec2->addr, rec2->len, rec2->filter_mask, rec2->obj_size);
-#endif /* QAK */
if(rec1->addr < rec2->addr)
ret_value = -1;
else if(rec1->addr > rec2->addr)
@@ -1005,11 +1019,11 @@ HDfprintf(stderr, "%s: rec2 = {%a, %Hu, %x, %Hu}\n", "H5HF_huge_bt2_filt_dir_com
ret_value = 0;
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5HF_huge_bt2_filt_dir_compare() */
+} /* H5HF__huge_bt2_filt_dir_compare() */
/*-------------------------------------------------------------------------
- * Function: H5HF_huge_bt2_filt_dir_encode
+ * Function: H5HF__huge_bt2_filt_dir_encode
*
* Purpose: Encode native information into raw form for storing on disk
*
@@ -1022,12 +1036,12 @@ HDfprintf(stderr, "%s: rec2 = {%a, %Hu, %x, %Hu}\n", "H5HF_huge_bt2_filt_dir_com
*-------------------------------------------------------------------------
*/
static herr_t
-H5HF_huge_bt2_filt_dir_encode(uint8_t *raw, const void *_nrecord, void *_ctx)
+H5HF__huge_bt2_filt_dir_encode(uint8_t *raw, const void *_nrecord, void *_ctx)
{
H5HF_huge_bt2_ctx_t *ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */
const H5HF_huge_bt2_filt_dir_rec_t *nrecord = (const H5HF_huge_bt2_filt_dir_rec_t *)_nrecord;
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
/* Sanity check */
HDassert(ctx);
@@ -1039,11 +1053,11 @@ H5HF_huge_bt2_filt_dir_encode(uint8_t *raw, const void *_nrecord, void *_ctx)
H5F_ENCODE_LENGTH_LEN(raw, nrecord->obj_size, ctx->sizeof_size);
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5HF_huge_bt2_filt_dir_encode() */
+} /* H5HF__huge_bt2_filt_dir_encode() */
/*-------------------------------------------------------------------------
- * Function: H5HF_huge_bt2_filt_dir_decode
+ * Function: H5HF__huge_bt2_filt_dir_decode
*
* Purpose: Decode raw disk form of record into native form
*
@@ -1056,12 +1070,12 @@ H5HF_huge_bt2_filt_dir_encode(uint8_t *raw, const void *_nrecord, void *_ctx)
*-------------------------------------------------------------------------
*/
static herr_t
-H5HF_huge_bt2_filt_dir_decode(const uint8_t *raw, void *_nrecord, void *_ctx)
+H5HF__huge_bt2_filt_dir_decode(const uint8_t *raw, void *_nrecord, void *_ctx)
{
H5HF_huge_bt2_ctx_t *ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */
H5HF_huge_bt2_filt_dir_rec_t *nrecord = (H5HF_huge_bt2_filt_dir_rec_t *)_nrecord;
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
/* Sanity check */
HDassert(ctx);
@@ -1073,11 +1087,11 @@ H5HF_huge_bt2_filt_dir_decode(const uint8_t *raw, void *_nrecord, void *_ctx)
H5F_DECODE_LENGTH_LEN(raw, nrecord->obj_size, ctx->sizeof_size);
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5HF_huge_bt2_filt_dir_decode() */
+} /* H5HF__huge_bt2_filt_dir_decode() */
/*-------------------------------------------------------------------------
- * Function: H5HF_huge_bt2_filt_dir_debug
+ * Function: H5HF__huge_bt2_filt_dir_debug
*
* Purpose: Debug native form of record
*
@@ -1090,15 +1104,16 @@ H5HF_huge_bt2_filt_dir_decode(const uint8_t *raw, void *_nrecord, void *_ctx)
*-------------------------------------------------------------------------
*/
static herr_t
-H5HF_huge_bt2_filt_dir_debug(FILE *stream, int indent, int fwidth, const void *_nrecord)
+H5HF__huge_bt2_filt_dir_debug(FILE *stream, int indent, int fwidth,
+ const void *_nrecord, const void H5_ATTR_UNUSED *_udata)
{
const H5HF_huge_bt2_filt_dir_rec_t *nrecord = (const H5HF_huge_bt2_filt_dir_rec_t *)_nrecord;
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
HDfprintf(stream, "%*s%-*s {%a, %Hu, %x, %Hu}\n", indent, "", fwidth, "Record:",
nrecord->addr, nrecord->len, nrecord->filter_mask, nrecord->obj_size);
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5HF_huge_bt2_filt_dir_debug() */
+} /* H5HF__huge_bt2_filt_dir_debug() */
diff --git a/src/H5HFdblock.c b/src/H5HFdblock.c
index 9461fc0..73db840 100644
--- a/src/H5HFdblock.c
+++ b/src/H5HFdblock.c
@@ -368,7 +368,7 @@ H5HF_man_dblock_new(H5HF_hdr_t *hdr, hid_t dxpl_id, size_t request,
} /* end else */
/* Adjust the size of block needed to fulfill request, with overhead */
- if((min_dblock_size - request) < H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr))
+ if(min_dblock_size < H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr) + request)
min_dblock_size *= 2;
/* Check if this is the first block in the heap */
@@ -460,7 +460,7 @@ H5HF_man_dblock_protect(H5HF_hdr_t *hdr, hid_t dxpl_id, haddr_t dblock_addr,
HDassert(dblock_size > 0);
/* only H5AC__READ_ONLY_FLAG may appear in flags */
- HDassert((flags & (~H5AC__READ_ONLY_FLAG)) == 0);
+ HDassert((flags & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0);
/* Set up parent info */
udata.par_info.hdr = hdr;
@@ -543,7 +543,7 @@ H5HF_man_dblock_locate(H5HF_hdr_t *hdr, hid_t dxpl_id, hsize_t obj_off,
HDassert(ret_did_protect);
/* only H5AC__READ_ONLY_FLAG may appear in flags */
- HDassert((flags & (~H5AC__READ_ONLY_FLAG)) == 0);
+ HDassert((flags & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0);
/* Look up row & column for object */
if(H5HF_dtable_lookup(&hdr->man_dtable, obj_off, &row, &col) < 0)
diff --git a/src/H5HFhdr.c b/src/H5HFhdr.c
index 6560756..19ea14a 100644
--- a/src/H5HFhdr.c
+++ b/src/H5HFhdr.c
@@ -224,7 +224,7 @@ H5HF_hdr_finish_init_phase1(H5HF_hdr_t *hdr)
HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize doubling table info")
/* Set the size of heap IDs */
- hdr->heap_len_size = MIN(hdr->man_dtable.max_dir_blk_off_size,
+ hdr->heap_len_size = (uint8_t)MIN(hdr->man_dtable.max_dir_blk_off_size,
H5VM_limit_enc_size((uint64_t)hdr->max_man_size));
done:
@@ -382,7 +382,7 @@ H5HF_hdr_create(H5F_t *f, hid_t dxpl_id, const H5HF_create_t *cparam)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, "can't allocate space for shared heap info")
#ifndef NDEBUG
- if(cparam->managed.max_index > (8 * hdr->sizeof_size))
+ if(cparam->managed.max_index > (unsigned)(8 * hdr->sizeof_size))
HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, "max. heap size too large for file")
#endif /* NDEBUG */
@@ -433,7 +433,7 @@ H5HF_hdr_create(H5F_t *f, hid_t dxpl_id, const H5HF_create_t *cparam)
HGOTO_ERROR(H5E_HEAP, H5E_CANTSET, HADDR_UNDEF, "can't set latest version of I/O filter pipeline")
/* Compute the I/O filters' encoded size */
- if(0 == (hdr->filter_len = H5O_msg_raw_size(hdr->f, H5O_PLINE_ID, FALSE, &(hdr->pline))))
+ if(0 == (hdr->filter_len = (unsigned)H5O_msg_raw_size(hdr->f, H5O_PLINE_ID, FALSE, &(hdr->pline))))
HGOTO_ERROR(H5E_HEAP, H5E_CANTGETSIZE, HADDR_UNDEF, "can't get I/O filter pipeline size")
/* Compute size of header on disk */
@@ -462,13 +462,13 @@ H5HF_hdr_create(H5F_t *f, hid_t dxpl_id, const H5HF_create_t *cparam)
case 1: /* Set the length of heap IDs to just enough to hold the information needed to directly access 'huge' objects in the heap */
if(hdr->filter_len > 0)
- hdr->id_len = 1 /* ID flags */
+ hdr->id_len = (unsigned)1 /* ID flags */
+ hdr->sizeof_addr /* Address of filtered object */
+ hdr->sizeof_size /* Length of filtered object */
+ 4 /* Filter mask for filtered object */
+ hdr->sizeof_size; /* Size of de-filtered object in memory */
else
- hdr->id_len = 1 /* ID flags */
+ hdr->id_len = (unsigned)1 /* ID flags */
+ hdr->sizeof_addr /* Address of object */
+ hdr->sizeof_size; /* Length of object */
break;
@@ -764,7 +764,7 @@ H5HF_hdr_adj_free(H5HF_hdr_t *hdr, ssize_t amt)
/* Update heap header */
HDassert(amt > 0 || hdr->total_man_free >= (hsize_t)-amt);
- hdr->total_man_free += amt;
+ hdr->total_man_free = (hsize_t)((hssize_t)hdr->total_man_free + amt);
/* Mark heap header as modified */
if(H5HF_hdr_dirty(hdr) < 0)
@@ -804,7 +804,8 @@ H5HF_hdr_adjust_heap(H5HF_hdr_t *hdr, hsize_t new_size, hssize_t extra_free)
hdr->man_size = new_size;
/* Adjust the free space in direct blocks */
- hdr->total_man_free += extra_free;
+ HDassert(extra_free > 0 || hdr->total_man_free >= (hsize_t)-extra_free);
+ hdr->total_man_free = (hsize_t)((hssize_t)hdr->total_man_free + extra_free);
/* Mark heap header as modified */
if(H5HF_hdr_dirty(hdr) < 0)
@@ -1246,7 +1247,7 @@ H5HF_hdr_reverse_iter(H5HF_hdr_t *hdr, hid_t dxpl_id, haddr_t dblock_addr)
/* Walk backwards through entries, until we find one that has a child */
/* (Skip direct block that will be deleted, if we find it) */
- tmp_entry = curr_entry;
+ tmp_entry = (int)curr_entry;
while(tmp_entry >= 0 &&
(H5F_addr_eq(iblock->ents[tmp_entry].addr, dblock_addr) ||
!H5F_addr_defined(iblock->ents[tmp_entry].addr)))
@@ -1281,7 +1282,7 @@ H5HF_hdr_reverse_iter(H5HF_hdr_t *hdr, hid_t dxpl_id, haddr_t dblock_addr)
else {
unsigned row; /* Row for entry */
- curr_entry = tmp_entry;
+ curr_entry = (unsigned)tmp_entry;
/* Check if entry is for a direct block */
row = curr_entry / hdr->man_dtable.cparam.width;
diff --git a/src/H5HFhuge.c b/src/H5HFhuge.c
index 888af48..ccee89e 100644
--- a/src/H5HFhuge.c
+++ b/src/H5HFhuge.c
@@ -124,31 +124,31 @@ H5HF_huge_bt2_create(H5HF_hdr_t *hdr, hid_t dxpl_id)
*/
if(hdr->huge_ids_direct) {
if(hdr->filter_len > 0) {
- bt2_cparam.rrec_size = (size_t)(hdr->sizeof_addr /* Address of object */
- + hdr->sizeof_size /* Length of object */
- + 4 /* Filter mask for filtered object */
- + hdr->sizeof_size); /* Size of de-filtered object in memory */
+ bt2_cparam.rrec_size = (size_t)((unsigned)hdr->sizeof_addr /* Address of object */
+ + (unsigned)hdr->sizeof_size /* Length of object */
+ + (unsigned)4 /* Filter mask for filtered object */
+ + (unsigned)hdr->sizeof_size); /* Size of de-filtered object in memory */
bt2_cparam.cls = H5HF_HUGE_BT2_FILT_DIR;
} /* end if */
else {
- bt2_cparam.rrec_size = (size_t)(hdr->sizeof_addr /* Address of object */
- + hdr->sizeof_size); /* Length of object */
+ bt2_cparam.rrec_size = (size_t)((unsigned)hdr->sizeof_addr /* Address of object */
+ + (unsigned)hdr->sizeof_size); /* Length of object */
bt2_cparam.cls = H5HF_HUGE_BT2_DIR;
} /* end else */
} /* end if */
else {
if(hdr->filter_len > 0) {
- bt2_cparam.rrec_size = (size_t)(hdr->sizeof_addr /* Address of filtered object */
- + hdr->sizeof_size /* Length of filtered object */
- + 4 /* Filter mask for filtered object */
- + hdr->sizeof_size /* Size of de-filtered object in memory */
- + hdr->sizeof_size); /* Unique ID for object */
+ bt2_cparam.rrec_size = (size_t)((unsigned)hdr->sizeof_addr /* Address of filtered object */
+ + (unsigned)hdr->sizeof_size /* Length of filtered object */
+ + (unsigned)4 /* Filter mask for filtered object */
+ + (unsigned)hdr->sizeof_size /* Size of de-filtered object in memory */
+ + (unsigned)hdr->sizeof_size); /* Unique ID for object */
bt2_cparam.cls = H5HF_HUGE_BT2_FILT_INDIR;
} /* end if */
else {
- bt2_cparam.rrec_size = (size_t)(hdr->sizeof_addr /* Address of object */
- + hdr->sizeof_size /* Length of object */
- + hdr->sizeof_size); /* Unique ID for object */
+ bt2_cparam.rrec_size = (size_t)((unsigned)hdr->sizeof_addr /* Address of object */
+ + (unsigned)hdr->sizeof_size /* Length of object */
+ + (unsigned)hdr->sizeof_size); /* Unique ID for object */
bt2_cparam.cls = H5HF_HUGE_BT2_INDIR;
} /* end else */
} /* end else */
@@ -557,7 +557,7 @@ H5HF_huge_get_obj_len(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id,
UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size)
/* Look up object in v2 B-tree */
- if(H5B2_find(hdr->huge_bt2, dxpl_id, &search_rec, H5HF_huge_bt2_filt_indir_found, &found_rec) != TRUE)
+ if(H5B2_find(hdr->huge_bt2, dxpl_id, &search_rec, H5HF__huge_bt2_filt_indir_found, &found_rec) != TRUE)
HGOTO_ERROR(H5E_HEAP, H5E_NOTFOUND, FAIL, "can't find object in B-tree")
/* Retrieve the object's length */
@@ -571,7 +571,7 @@ H5HF_huge_get_obj_len(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id,
UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size)
/* Look up object in v2 B-tree */
- if(H5B2_find(hdr->huge_bt2, dxpl_id, &search_rec, H5HF_huge_bt2_indir_found, &found_rec) != TRUE)
+ if(H5B2_find(hdr->huge_bt2, dxpl_id, &search_rec, H5HF__huge_bt2_indir_found, &found_rec) != TRUE)
HGOTO_ERROR(H5E_HEAP, H5E_NOTFOUND, FAIL, "can't find object in B-tree")
/* Retrieve the object's length */
@@ -641,7 +641,7 @@ H5HF__huge_get_obj_off(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id,
UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size)
/* Look up object in v2 B-tree */
- if(H5B2_find(hdr->huge_bt2, dxpl_id, &search_rec, H5HF_huge_bt2_filt_indir_found, &found_rec) != TRUE)
+ if(H5B2_find(hdr->huge_bt2, dxpl_id, &search_rec, H5HF__huge_bt2_filt_indir_found, &found_rec) != TRUE)
HGOTO_ERROR(H5E_HEAP, H5E_NOTFOUND, FAIL, "can't find object in B-tree")
/* Retrieve the object's address & length */
@@ -655,7 +655,7 @@ H5HF__huge_get_obj_off(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id,
UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size)
/* Look up object in v2 B-tree */
- if(H5B2_find(hdr->huge_bt2, dxpl_id, &search_rec, H5HF_huge_bt2_indir_found, &found_rec) != TRUE)
+ if(H5B2_find(hdr->huge_bt2, dxpl_id, &search_rec, H5HF__huge_bt2_indir_found, &found_rec) != TRUE)
HGOTO_ERROR(H5E_HEAP, H5E_NOTFOUND, FAIL, "can't find object in B-tree")
/* Retrieve the object's address & length */
@@ -735,7 +735,7 @@ H5HF_huge_op_real(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id,
UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size)
/* Look up object in v2 B-tree */
- if(H5B2_find(hdr->huge_bt2, dxpl_id, &search_rec, H5HF_huge_bt2_filt_indir_found, &found_rec) != TRUE)
+ if(H5B2_find(hdr->huge_bt2, dxpl_id, &search_rec, H5HF__huge_bt2_filt_indir_found, &found_rec) != TRUE)
HGOTO_ERROR(H5E_HEAP, H5E_NOTFOUND, FAIL, "can't find object in B-tree")
/* Retrieve the object's address & length */
@@ -751,7 +751,7 @@ H5HF_huge_op_real(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id,
UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size)
/* Look up object in v2 B-tree */
- if(H5B2_find(hdr->huge_bt2, dxpl_id, &search_rec, H5HF_huge_bt2_indir_found, &found_rec) != TRUE)
+ if(H5B2_find(hdr->huge_bt2, dxpl_id, &search_rec, H5HF__huge_bt2_indir_found, &found_rec) != TRUE)
HGOTO_ERROR(H5E_HEAP, H5E_NOTFOUND, FAIL, "can't find object in B-tree")
/* Retrieve the object's address & length */
@@ -879,7 +879,7 @@ H5HF_huge_write(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id,
UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size)
/* Look up object in v2 B-tree */
- if(H5B2_find(hdr->huge_bt2, dxpl_id, &search_rec, H5HF_huge_bt2_indir_found, &found_rec) != TRUE)
+ if(H5B2_find(hdr->huge_bt2, dxpl_id, &search_rec, H5HF__huge_bt2_indir_found, &found_rec) != TRUE)
HGOTO_ERROR(H5E_HEAP, H5E_NOTFOUND, FAIL, "can't find object in B-tree")
/* Retrieve the object's address & length */
@@ -1024,7 +1024,7 @@ H5HF_huge_remove(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id)
/* Remove the record for tracking the 'huge' object from the v2 B-tree */
/* (space in the file for the object is freed in the 'remove' callback) */
- if(H5B2_remove(hdr->huge_bt2, dxpl_id, &search_rec, H5HF_huge_bt2_filt_dir_remove, &udata) < 0)
+ if(H5B2_remove(hdr->huge_bt2, dxpl_id, &search_rec, H5HF__huge_bt2_filt_dir_remove, &udata) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTREMOVE, FAIL, "can't remove object from B-tree")
} /* end if */
else {
@@ -1037,7 +1037,7 @@ H5HF_huge_remove(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id)
/* Remove the record for tracking the 'huge' object from the v2 B-tree */
/* (space in the file for the object is freed in the 'remove' callback) */
- if(H5B2_remove(hdr->huge_bt2, dxpl_id, &search_rec, H5HF_huge_bt2_dir_remove, &udata) < 0)
+ if(H5B2_remove(hdr->huge_bt2, dxpl_id, &search_rec, H5HF__huge_bt2_dir_remove, &udata) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTREMOVE, FAIL, "can't remove object from B-tree")
} /* end else */
} /* end if */
@@ -1050,7 +1050,7 @@ H5HF_huge_remove(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id)
/* Remove the record for tracking the 'huge' object from the v2 B-tree */
/* (space in the file for the object is freed in the 'remove' callback) */
- if(H5B2_remove(hdr->huge_bt2, dxpl_id, &search_rec, H5HF_huge_bt2_filt_indir_remove, &udata) < 0)
+ if(H5B2_remove(hdr->huge_bt2, dxpl_id, &search_rec, H5HF__huge_bt2_filt_indir_remove, &udata) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTREMOVE, FAIL, "can't remove object from B-tree")
} /* end if */
else {
@@ -1061,7 +1061,7 @@ H5HF_huge_remove(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id)
/* Remove the record for tracking the 'huge' object from the v2 B-tree */
/* (space in the file for the object is freed in the 'remove' callback) */
- if(H5B2_remove(hdr->huge_bt2, dxpl_id, &search_rec, H5HF_huge_bt2_indir_remove, &udata) < 0)
+ if(H5B2_remove(hdr->huge_bt2, dxpl_id, &search_rec, H5HF__huge_bt2_indir_remove, &udata) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTREMOVE, FAIL, "can't remove object from B-tree")
} /* end else */
} /* end else */
@@ -1180,15 +1180,15 @@ H5HF_huge_delete(H5HF_hdr_t *hdr, hid_t dxpl_id)
/* Set the v2 B-tree callback operator */
if(hdr->huge_ids_direct) {
if(hdr->filter_len > 0)
- op = H5HF_huge_bt2_filt_dir_remove;
+ op = H5HF__huge_bt2_filt_dir_remove;
else
- op = H5HF_huge_bt2_dir_remove;
+ op = H5HF__huge_bt2_dir_remove;
} /* end if */
else {
if(hdr->filter_len > 0)
- op = H5HF_huge_bt2_filt_indir_remove;
+ op = H5HF__huge_bt2_filt_indir_remove;
else
- op = H5HF_huge_bt2_indir_remove;
+ op = H5HF__huge_bt2_indir_remove;
} /* end else */
/* Delete the v2 B-tree */
diff --git a/src/H5HFiblock.c b/src/H5HFiblock.c
index 29f4662..f3ec78f 100644
--- a/src/H5HFiblock.c
+++ b/src/H5HFiblock.c
@@ -214,7 +214,7 @@ H5HF_iblock_unpin(H5HF_indirect_t *iblock)
} /* end if */
/* Indicate that the root indirect block is unpinned */
- iblock->hdr->root_iblock_flags &= ~(H5HF_ROOT_IBLOCK_PINNED);
+ iblock->hdr->root_iblock_flags &= (unsigned)(~(H5HF_ROOT_IBLOCK_PINNED));
} /* end if */
} /* end else */
@@ -649,7 +649,7 @@ H5HF_man_iblock_root_double(H5HF_hdr_t *hdr, hid_t dxpl_id, size_t min_dblock_si
/* Initialize new direct block entries in rows added */
acc_dblock_free = 0;
for(u = (old_nrows * hdr->man_dtable.cparam.width); u < (iblock->nrows * hdr->man_dtable.cparam.width); u++) {
- unsigned row = u / hdr->man_dtable.cparam.width; /* Row for current entry */
+ unsigned row = (unsigned)(u / hdr->man_dtable.cparam.width); /* Row for current entry */
iblock->ents[u].addr = HADDR_UNDEF;
acc_dblock_free += hdr->man_dtable.row_tot_dblock_free[row];
@@ -751,7 +751,7 @@ H5HF_man_iblock_root_halve(H5HF_indirect_t *iblock, hid_t dxpl_id)
max_child_row = iblock->max_child / hdr->man_dtable.cparam.width;
/* Compute new # of rows in root indirect block */
- new_nrows = 1 << (1 + H5VM_log2_gen((uint64_t)max_child_row));
+ new_nrows = (unsigned)1 << (1 + H5VM_log2_gen((uint64_t)max_child_row));
/* Check if the indirect block is NOT currently allocated in temp. file space */
/* (temp. file space does not need to be freed) */
@@ -1323,7 +1323,7 @@ H5HF_man_iblock_unprotect(H5HF_indirect_t *iblock, hid_t dxpl_id,
} /* end if */
/* Indicate that the root indirect block is unprotected */
- iblock->hdr->root_iblock_flags &= ~(H5HF_ROOT_IBLOCK_PROTECTED);
+ iblock->hdr->root_iblock_flags &= (unsigned)(~(H5HF_ROOT_IBLOCK_PROTECTED));
} /* end if */
/* Unprotect the indirect block */
diff --git a/src/H5HFpkg.h b/src/H5HFpkg.h
index 7a6794e..6253160 100644
--- a/src/H5HFpkg.h
+++ b/src/H5HFpkg.h
@@ -48,19 +48,19 @@
/* "Standard" size of prefix information for fractal heap metadata */
#define H5HF_METADATA_PREFIX_SIZE(c) ( \
H5_SIZEOF_MAGIC /* Signature */ \
- + 1 /* Version */ \
- + ((c) ? H5HF_SIZEOF_CHKSUM : 0) /* Metadata checksum */ \
+ + (unsigned)1 /* Version */ \
+ + ((c) ? (unsigned)H5HF_SIZEOF_CHKSUM : (unsigned)0) /* Metadata checksum */ \
)
/* Size of doubling-table information */
#define H5HF_DTABLE_INFO_SIZE(h) ( \
- 2 /* Width of table (i.e. # of columns) */ \
- + (h)->sizeof_size /* Starting block size */ \
- + (h)->sizeof_size /* Maximum direct block size */ \
- + 2 /* Max. size of heap (log2 of actual value - i.e. the # of bits) */ \
- + 2 /* Starting # of rows in root indirect block */ \
- + (h)->sizeof_addr /* File address of table managed */ \
- + 2 /* Current # of rows in root indirect block */ \
+ (unsigned)2 /* Width of table (i.e. # of columns) */ \
+ + (unsigned)(h)->sizeof_size /* Starting block size */ \
+ + (unsigned)(h)->sizeof_size /* Maximum direct block size */ \
+ + (unsigned)2 /* Max. size of heap (log2 of actual value - i.e. the # of bits) */ \
+ + (unsigned)2 /* Starting # of rows in root indirect block */ \
+ + (unsigned)(h)->sizeof_addr /* File address of table managed */ \
+ + (unsigned)2 /* Current # of rows in root indirect block */ \
)
/* Flags for status byte */
@@ -78,28 +78,28 @@
/* Fractal Heap Header specific fields */ \
\
/* General heap information */ \
- + 2 /* Heap ID len */ \
- + 2 /* I/O filters' encoded len */ \
- + 1 /* Status flags */ \
+ + (unsigned)2 /* Heap ID len */ \
+ + (unsigned)2 /* I/O filters' encoded len */ \
+ + (unsigned)1 /* Status flags */ \
\
/* "Huge" object fields */ \
- + 4 /* Max. size of "managed" object */ \
- + (h)->sizeof_size /* Next ID for "huge" object */ \
- + (h)->sizeof_addr /* File address of "huge" object tracker B-tree */ \
+ + (unsigned)4 /* Max. size of "managed" object */ \
+ + (unsigned)(h)->sizeof_size /* Next ID for "huge" object */ \
+ + (unsigned)(h)->sizeof_addr /* File address of "huge" object tracker B-tree */ \
\
/* "Managed" object free space fields */ \
- + (h)->sizeof_size /* Total man. free space */ \
- + (h)->sizeof_addr /* File address of free section header */ \
+ + (unsigned)(h)->sizeof_size /* Total man. free space */ \
+ + (unsigned)(h)->sizeof_addr /* File address of free section header */ \
\
/* Statistics fields */ \
- + (h)->sizeof_size /* Size of man. space in heap */ \
- + (h)->sizeof_size /* Size of man. space iterator offset in heap */ \
- + (h)->sizeof_size /* Size of alloacted man. space in heap */ \
- + (h)->sizeof_size /* Number of man. objects in heap */ \
- + (h)->sizeof_size /* Size of huge space in heap */ \
- + (h)->sizeof_size /* Number of huge objects in heap */ \
- + (h)->sizeof_size /* Size of tiny space in heap */ \
- + (h)->sizeof_size /* Number of tiny objects in heap */ \
+ + (unsigned)(h)->sizeof_size /* Size of man. space in heap */ \
+ + (unsigned)(h)->sizeof_size /* Size of man. space iterator offset in heap */ \
+ + (unsigned)(h)->sizeof_size /* Size of alloacted man. space in heap */ \
+ + (unsigned)(h)->sizeof_size /* Number of man. objects in heap */ \
+ + (unsigned)(h)->sizeof_size /* Size of huge space in heap */ \
+ + (unsigned)(h)->sizeof_size /* Number of huge objects in heap */ \
+ + (unsigned)(h)->sizeof_size /* Size of tiny space in heap */ \
+ + (unsigned)(h)->sizeof_size /* Number of tiny objects in heap */ \
\
/* "Managed" object doubling table info */ \
+ H5HF_DTABLE_INFO_SIZE(h) /* Size of managed obj. doubling-table info */ \
@@ -111,15 +111,15 @@
H5HF_METADATA_PREFIX_SIZE(h->checksum_dblocks) \
\
/* Fractal heap managed, absolutely mapped direct block specific fields */ \
- + (h)->sizeof_addr /* File address of heap owning the block */ \
- + (h)->heap_off_size /* Offset of the block in the heap */ \
+ + (unsigned)(h)->sizeof_addr /* File address of heap owning the block */ \
+ + (unsigned)(h)->heap_off_size /* Offset of the block in the heap */ \
)
/* Size of managed indirect block entry for a child direct block */
#define H5HF_MAN_INDIRECT_CHILD_DIR_ENTRY_SIZE(h) ( \
((h)->filter_len > 0 ? \
- ((h)->sizeof_addr + (h)->sizeof_size + 4) : /* Size of entries for filtered direct blocks */ \
- (h)->sizeof_addr) /* Size of entries for un-filtered direct blocks */ \
+ ((unsigned)(h)->sizeof_addr + (unsigned)(h)->sizeof_size + (unsigned)4) : /* Size of entries for filtered direct blocks */ \
+ (unsigned)(h)->sizeof_addr) /* Size of entries for un-filtered direct blocks */ \
)
/* Size of managed indirect block */
@@ -128,8 +128,8 @@
H5HF_METADATA_PREFIX_SIZE(TRUE) \
\
/* Fractal heap managed, absolutely mapped indirect block specific fields */ \
- + (h)->sizeof_addr /* File address of heap owning the block */ \
- + (h)->heap_off_size /* Offset of the block in the heap */ \
+ + (unsigned)(h)->sizeof_addr /* File address of heap owning the block */ \
+ + (unsigned)(h)->heap_off_size /* Offset of the block in the heap */ \
+ (MIN(r, (h)->man_dtable.max_direct_rows) * (h)->man_dtable.cparam.width * H5HF_MAN_INDIRECT_CHILD_DIR_ENTRY_SIZE(h)) /* Size of entries for direct blocks */ \
+ (((r > (h)->man_dtable.max_direct_rows) ? (r - (h)->man_dtable.max_direct_rows) : 0) * (h)->man_dtable.cparam.width * (h)->sizeof_addr) /* Size of entries for indirect blocks */ \
)
@@ -731,13 +731,13 @@ H5_DLL herr_t H5HF_huge_term(H5HF_hdr_t *hdr, hid_t dxpl_id);
H5_DLL herr_t H5HF_huge_delete(H5HF_hdr_t *hdr, hid_t dxpl_id);
/* 'Huge' object v2 B-tree function callbacks */
-H5_DLL herr_t H5HF_huge_bt2_indir_found(const void *nrecord, void *op_data);
-H5_DLL herr_t H5HF_huge_bt2_indir_remove(const void *nrecord, void *op_data);
-H5_DLL herr_t H5HF_huge_bt2_filt_indir_found(const void *nrecord, void *op_data);
-H5_DLL herr_t H5HF_huge_bt2_filt_indir_remove(const void *nrecord, void *op_data);
-H5_DLL herr_t H5HF_huge_bt2_dir_remove(const void *nrecord, void *op_data);
-H5_DLL herr_t H5HF_huge_bt2_filt_dir_found(const void *nrecord, void *op_data);
-H5_DLL herr_t H5HF_huge_bt2_filt_dir_remove(const void *nrecord, void *op_data);
+H5_DLL herr_t H5HF__huge_bt2_indir_found(const void *nrecord, void *op_data);
+H5_DLL herr_t H5HF__huge_bt2_indir_remove(const void *nrecord, void *op_data);
+H5_DLL herr_t H5HF__huge_bt2_filt_indir_found(const void *nrecord, void *op_data);
+H5_DLL herr_t H5HF__huge_bt2_filt_indir_remove(const void *nrecord, void *op_data);
+H5_DLL herr_t H5HF__huge_bt2_dir_remove(const void *nrecord, void *op_data);
+H5_DLL herr_t H5HF__huge_bt2_filt_dir_found(const void *nrecord, void *op_data);
+H5_DLL herr_t H5HF__huge_bt2_filt_dir_remove(const void *nrecord, void *op_data);
/* 'Tiny' object routines */
H5_DLL herr_t H5HF_tiny_init(H5HF_hdr_t *hdr);
diff --git a/src/H5HFsection.c b/src/H5HFsection.c
index 070bc3e..8699827 100644
--- a/src/H5HFsection.c
+++ b/src/H5HFsection.c
@@ -14,10 +14,10 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
- * Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu>
+ * Programmer: Quincey Koziol <koziol@hdfgroup.org>
* Monday, May 1, 2006
*
- * Purpose: Free space section routines for fractal heaps.
+ * Purpose: Free space section routines for fractal heaps
*
*/
@@ -43,10 +43,10 @@
/* Size of serialized indirect section information */
#define H5HF_SECT_INDIRECT_SERIAL_SIZE(h) ( \
- (h)->heap_off_size /* Indirect block's offset in "heap space" */ \
- + 2 /* Row */ \
- + 2 /* Column */ \
- + 2 /* # of entries */ \
+ (unsigned)(h)->heap_off_size /* Indirect block's offset in "heap space" */ \
+ + (unsigned)2 /* Row */ \
+ + (unsigned)2 /* Column */ \
+ + (unsigned)2 /* # of entries */ \
)
@@ -587,15 +587,15 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5HF_sect_single_revive
+ * Function: H5HF_sect_single_revive
*
- * Purpose: Update the memory information for a 'single' free section
+ * Purpose: Update the memory information for a 'single' free section
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
- * koziol@ncsa.uiuc.edu
- * May 8 2006
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * May 8 2006
*
*-------------------------------------------------------------------------
*/
@@ -636,15 +636,15 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5HF_sect_single_dblock_info
+ * Function: H5HF_sect_single_dblock_info
*
- * Purpose: Retrieve the direct block information for a single section
+ * Purpose: Retrieve the direct block information for a single section
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
- * koziol@hdfgroup.org
- * October 24 2006
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * October 24 2006
*
*-------------------------------------------------------------------------
*/
diff --git a/src/H5HFtest.c b/src/H5HFtest.c
index 4ec7149..4b97194 100644
--- a/src/H5HFtest.c
+++ b/src/H5HFtest.c
@@ -97,10 +97,10 @@ H5HF_get_cparam_test(const H5HF_t *fh, H5HF_create_t *cparam)
/* Get fractal heap creation parameters */
if(fh->hdr->id_len == (unsigned)(1 + fh->hdr->heap_off_size + fh->hdr->heap_len_size))
cparam->id_len = 0;
- else if(fh->hdr->id_len == (1 + fh->hdr->sizeof_size + fh->hdr->sizeof_addr))
+ else if(fh->hdr->id_len == (unsigned)(1 + fh->hdr->sizeof_size + fh->hdr->sizeof_addr))
cparam->id_len = 1;
else
- cparam->id_len = fh->hdr->id_len;
+ 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));
H5O_msg_copy(H5O_PLINE_ID, &(fh->hdr->pline), &(cparam->pline));
diff --git a/src/H5HFtiny.c b/src/H5HFtiny.c
index 8c321bc..bdfe30d 100644
--- a/src/H5HFtiny.c
+++ b/src/H5HFtiny.c
@@ -169,17 +169,17 @@ HDfprintf(stderr, "%s: obj_size = %Zu\n", FUNC, obj_size);
/* Encode object into ID */
if(!hdr->tiny_len_extended) {
- *id++ = H5HF_ID_VERS_CURR | H5HF_ID_TYPE_TINY |
- (enc_obj_size & H5HF_TINY_MASK_SHORT);
+ *id++ = (uint8_t)(H5HF_ID_VERS_CURR | H5HF_ID_TYPE_TINY |
+ (enc_obj_size & H5HF_TINY_MASK_SHORT));
} /* end if */
else {
- *id++ = H5HF_ID_VERS_CURR | H5HF_ID_TYPE_TINY |
- ((enc_obj_size & H5HF_TINY_MASK_EXT_1) >> 8);
+ *id++ = (uint8_t)(H5HF_ID_VERS_CURR | H5HF_ID_TYPE_TINY |
+ ((enc_obj_size & H5HF_TINY_MASK_EXT_1) >> 8));
*id++ = enc_obj_size & H5HF_TINY_MASK_EXT_2;
} /* end else */
HDmemcpy(id, obj, obj_size);
#ifdef H5_CLEAR_MEMORY
-HDmemset(id + obj_size, 0, (hdr->id_len - (1 + hdr->tiny_len_extended + obj_size)));
+HDmemset(id + obj_size, 0, (hdr->id_len - ((size_t)1 + (size_t)hdr->tiny_len_extended + obj_size)));
#endif /* H5_CLEAR_MEMORY */
/* Update statistics about heap */
@@ -229,7 +229,7 @@ H5HF_tiny_get_obj_len(H5HF_hdr_t *hdr, const uint8_t *id, size_t *obj_len_p)
/* (performed in this odd way to avoid compiler bug on tg-login3 with
* gcc 3.2.2 - QAK)
*/
- enc_obj_size = *(id + 1) | ((*id & H5HF_TINY_MASK_EXT_1) << 8);
+ enc_obj_size = (size_t)*(id + 1) | ((size_t)(*id & H5HF_TINY_MASK_EXT_1) << 8);
/* Set the object's length */
*obj_len_p = enc_obj_size + 1;
diff --git a/src/H5HL.c b/src/H5HL.c
index 80603dd..7ad2e3c 100644
--- a/src/H5HL.c
+++ b/src/H5HL.c
@@ -15,12 +15,12 @@
/*-------------------------------------------------------------------------
*
- * Created: H5HL.c
- * Jul 16 1997
- * Robb Matzke <matzke@llnl.gov>
+ * Created: H5HL.c
+ * Jul 16 1997
+ * Robb Matzke <matzke@llnl.gov>
*
- * Purpose: Heap functions for the local heaps used by symbol
- * tables to store names (among other things).
+ * Purpose: Heap functions for the local heaps used by symbol
+ * tables to store names (among other things).
*
*-------------------------------------------------------------------------
*/
@@ -35,18 +35,18 @@
/***********/
/* Headers */
/***********/
-#include "H5private.h" /* Generic Functions */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5Fprivate.h" /* File access */
-#include "H5HLpkg.h" /* Local Heaps */
-#include "H5MFprivate.h" /* File memory management */
+#include "H5private.h" /* Generic Functions */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5Fprivate.h" /* File access */
+#include "H5HLpkg.h" /* Local Heaps */
+#include "H5MFprivate.h" /* File memory management */
/****************/
/* Local Macros */
/****************/
-#define H5HL_MIN_HEAP 128 /* Minimum size to reduce heap buffer to */
+#define H5HL_MIN_HEAP 128 /* Minimum size to reduce heap buffer to */
/******************/
@@ -63,8 +63,9 @@
/* Local Prototypes */
/********************/
-static H5HL_free_t *H5HL_remove_free(H5HL_t *heap, H5HL_free_t *fl);
-static herr_t H5HL_minimize_heap_space(H5F_t *f, hid_t dxpl_id, H5HL_t *heap);
+static H5HL_free_t *H5HL__remove_free(H5HL_t *heap, H5HL_free_t *fl);
+static herr_t H5HL__minimize_heap_space(H5F_t *f, hid_t dxpl_id, H5HL_t *heap);
+static herr_t H5HL__dirty(H5HL_t *heap);
/*********************/
@@ -93,35 +94,29 @@ H5FL_BLK_DEFINE(lheap_chunk);
/*-------------------------------------------------------------------------
- * Function: H5HL_create
+ * Function: H5HL_create
*
- * Purpose: Creates a new heap data structure on disk and caches it
- * in memory. SIZE_HINT is a hint for the initial size of the
- * data area of the heap. If size hint is invalid then a
- * reasonable (but probably not optimal) size will be chosen.
- * If the heap ever has to grow, then REALLOC_HINT is the
- * minimum amount by which the heap will grow.
+ * Purpose: Creates a new heap data structure on disk and caches it
+ * in memory. SIZE_HINT is a hint for the initial size of the
+ * data area of the heap. If size hint is invalid then a
+ * reasonable (but probably not optimal) size will be chosen.
*
- * Return: Success: Non-negative. The file address of new heap is
- * returned through the ADDR argument.
+ * Return: Success: SUCCEED. The file address of new heap is
+ * returned through the ADDR argument.
+ * Failure: FAIL. addr_p will be HADDR_UNDEF.
*
- * Failure: Negative
- *
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jul 16 1997
+ * Programmer: Robb Matzke
+ * Jul 16 1997
*
*-------------------------------------------------------------------------
*/
-herr_t
-H5HL_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, haddr_t *addr_p/*out*/)
-{
- H5HL_t *heap = NULL; /* Heap created */
- H5HL_prfx_t *prfx = NULL; /* Heap prefix */
- hsize_t total_size = 0; /* Total heap size on disk */
- herr_t ret_value = SUCCEED; /* Return value */
+BEGIN_FUNC(PRIV, ERR,
+herr_t, SUCCEED, FAIL,
+H5HL_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, haddr_t *addr_p/*out*/))
- FUNC_ENTER_NOAPI(FAIL)
+ H5HL_t *heap = NULL; /* Heap created */
+ H5HL_prfx_t *prfx = NULL; /* Heap prefix */
+ hsize_t total_size = 0; /* Total heap size on disk */
/* check arguments */
HDassert(f);
@@ -129,17 +124,17 @@ H5HL_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, haddr_t *addr_p/*out*/)
/* Adjust size hint as necessary */
if(size_hint && size_hint < H5HL_SIZEOF_FREE(f))
- size_hint = H5HL_SIZEOF_FREE(f);
+ size_hint = H5HL_SIZEOF_FREE(f);
size_hint = H5HL_ALIGN(size_hint);
/* Allocate new heap structure */
- if(NULL == (heap = H5HL_new(H5F_SIZEOF_SIZE(f), H5F_SIZEOF_ADDR(f), H5HL_SIZEOF_HDR(f))))
- HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "can't allocate new heap struct")
+ if(NULL == (heap = H5HL__new(H5F_SIZEOF_SIZE(f), H5F_SIZEOF_ADDR(f), H5HL_SIZEOF_HDR(f))))
+ H5E_THROW(H5E_CANTALLOC, "can't allocate new heap struct");
/* Allocate file space */
total_size = heap->prfx_size + size_hint;
if(HADDR_UNDEF == (heap->prfx_addr = H5MF_alloc(f, H5FD_MEM_LHEAP, dxpl_id, total_size)))
- HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "unable to allocate file memory")
+ H5E_THROW(H5E_CANTALLOC, "unable to allocate file memory");
/* Initialize info */
heap->single_cache_obj = TRUE;
@@ -147,188 +142,72 @@ H5HL_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, haddr_t *addr_p/*out*/)
heap->dblk_size = size_hint;
if(size_hint)
if(NULL == (heap->dblk_image = H5FL_BLK_CALLOC(lheap_chunk, size_hint)))
- HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "memory allocation failed")
+ H5E_THROW(H5E_CANTALLOC, "memory allocation failed");
/* free list */
if(size_hint) {
- if(NULL == (heap->freelist = H5FL_MALLOC(H5HL_free_t)))
- HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "memory allocation failed")
- heap->freelist->offset = 0;
- heap->freelist->size = size_hint;
- heap->freelist->prev = heap->freelist->next = NULL;
+ if(NULL == (heap->freelist = H5FL_MALLOC(H5HL_free_t)))
+ H5E_THROW(H5E_CANTALLOC, "memory allocation failed");
+ heap->freelist->offset = 0;
+ heap->freelist->size = size_hint;
+ heap->freelist->prev = heap->freelist->next = NULL;
heap->free_block = 0;
} /* end if */
else {
- heap->freelist = NULL;
+ heap->freelist = NULL;
heap->free_block = H5HL_FREE_NULL;
} /* end else */
/* Allocate the heap prefix */
- if(NULL == (prfx = H5HL_prfx_new(heap)))
- HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "memory allocation failed")
+ if(NULL == (prfx = H5HL__prfx_new(heap)))
+ H5E_THROW(H5E_CANTALLOC, "memory allocation failed");
/* Add to cache */
- if(H5AC_insert_entry(f, dxpl_id, H5AC_LHEAP_PRFX, heap->prfx_addr, prfx, H5AC__NO_FLAGS_SET) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "unable to cache local heap prefix")
+ if(FAIL == H5AC_insert_entry(f, dxpl_id, H5AC_LHEAP_PRFX, heap->prfx_addr, prfx, H5AC__NO_FLAGS_SET))
+ H5E_THROW(H5E_CANTINIT, "unable to cache local heap prefix");
/* Set address to return */
*addr_p = heap->prfx_addr;
-done:
+CATCH
if(ret_value < 0) {
+ *addr_p = HADDR_UNDEF;
if(prfx) {
- if(H5HL_prfx_dest(prfx) < 0)
- HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy local heap prefix")
+ if(FAIL == H5HL__prfx_dest(prfx))
+ H5E_THROW(H5E_CANTFREE, "unable to destroy local heap prefix");
} /* end if */
else {
if(heap) {
if(H5F_addr_defined(heap->prfx_addr))
- if(H5MF_xfree(f, H5FD_MEM_LHEAP, dxpl_id, heap->prfx_addr, total_size) < 0)
- HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "can't release heap data?")
- if(H5HL_dest(heap) < 0)
- HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy local heap")
+ if(FAIL == H5MF_xfree(f, H5FD_MEM_LHEAP, dxpl_id, heap->prfx_addr, total_size))
+ H5E_THROW(H5E_CANTFREE, "can't release heap data?");
+ if(FAIL == H5HL__dest(heap))
+ H5E_THROW(H5E_CANTFREE, "unable to destroy local heap");
} /* end if */
} /* end else */
} /* end if */
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5HL_create() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5HL_dblk_realloc
- *
- * Purpose: Reallocate data block for heap
- *
- * Return: Success: Non-negative
- * Failure: Negative
- *
- * Programmer: Quincey Koziol
- * koziol@hdfgroup.org
- * Oct 12 2008
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5HL_dblk_realloc(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t new_heap_size)
-{
- H5HL_dblk_t *dblk; /* Local heap data block */
- haddr_t old_addr; /* Old location of heap data block */
- haddr_t new_addr; /* New location of heap data block */
- size_t old_heap_size; /* Old size of heap data block */
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI_NOINIT
-
- /* check arguments */
- HDassert(heap);
- HDassert(new_heap_size > 0);
-
- /* Release old space on disk */
- old_addr = heap->dblk_addr;
- old_heap_size = heap->dblk_size;
- H5_CHECK_OVERFLOW(old_heap_size, size_t, hsize_t);
- if(H5MF_xfree(f, H5FD_MEM_LHEAP, dxpl_id, old_addr, (hsize_t)old_heap_size) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "can't release old heap data?")
-
- /* Allocate new space on disk */
- H5_CHECK_OVERFLOW(new_heap_size, size_t, hsize_t);
- if(HADDR_UNDEF == (new_addr = H5MF_alloc(f, H5FD_MEM_LHEAP, dxpl_id, (hsize_t)new_heap_size)))
- HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "unable to allocate file space for heap")
-
- /* Update heap info*/
- heap->dblk_addr = new_addr;
- heap->dblk_size = new_heap_size;
-
- /* Check if heap data block actually moved in the file */
- if(H5F_addr_eq(old_addr, new_addr)) {
- /* Check if heap data block is contiguous w/prefix */
- if(heap->single_cache_obj) {
- /* Sanity check */
- HDassert(H5F_addr_eq(heap->prfx_addr + heap->prfx_size, old_addr));
- HDassert(heap->prfx);
-
- /* Resize the heap prefix in the cache */
- if(H5AC_resize_entry(heap->prfx, (size_t)(heap->prfx_size + new_heap_size)) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, FAIL, "unable to resize heap in cache")
- } /* end if */
- else {
- /* Sanity check */
- HDassert(H5F_addr_ne(heap->prfx_addr + heap->prfx_size, old_addr));
- HDassert(heap->dblk);
-
- /* Resize the heap data block in the cache */
- if(H5AC_resize_entry(heap->dblk, (size_t)new_heap_size) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, FAIL, "unable to resize heap in cache")
- } /* end else */
- } /* end if */
- else {
- /* Check if heap data block was contiguous w/prefix previously */
- if(heap->single_cache_obj) {
- /* Create new heap data block */
- if(NULL == (dblk = H5HL_dblk_new(heap)))
- HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "unable to allocate local heap data block")
-
- /* Resize current heap prefix */
- heap->prfx_size = H5HL_SIZEOF_HDR(f);
- if(H5AC_resize_entry(heap->prfx, (size_t)heap->prfx_size) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, FAIL, "unable to resize heap prefix in cache")
-
- /* Insert data block into cache (pinned) */
- if(H5AC_insert_entry(f, dxpl_id, H5AC_LHEAP_DBLK, new_addr, dblk, H5AC__PIN_ENTRY_FLAG) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "unable to cache local heap data block")
- dblk = NULL;
-
- /* Reset 'single cache object' flag */
- heap->single_cache_obj = FALSE;
- } /* end if */
- else {
- /* Resize the heap data block in the cache */
- /* (ignore [unlikely] case where heap data block ends up
- * contiguous w/heap prefix again.
- */
- if(H5AC_resize_entry(heap->dblk, (size_t)new_heap_size) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, FAIL, "unable to resize heap data block in cache")
-
- /* Relocate the heap data block in the cache */
- if(H5AC_move_entry(f, H5AC_LHEAP_DBLK, old_addr, new_addr) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTMOVE, FAIL, "unable to move heap data block in cache")
- } /* end else */
- } /* end else */
-
-done:
- if(ret_value < 0) {
- /* Restore old heap address & size */
- heap->dblk_addr = old_addr;
- heap->dblk_size = old_heap_size;
- } /* end if */
-
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5HL_dblk_realloc() */
+END_FUNC(PRIV) /* end H5HL_create() */
/*-------------------------------------------------------------------------
- * Function: H5HL_minimize_heap_space
+ * Function: H5HL__minimize_heap_space
*
* Purpose: Go through the heap's freelist and determine if we can
* eliminate the free blocks at the tail of the buffer.
*
- * Return: Success: SUCCEED
- * Failure: FAIL
+ * Return: SUCCEED/FAIL
*
* Programmer: Bill Wendling
- * wendling@ncsa.uiuc.edu
* Sept. 16, 2003
*
*-------------------------------------------------------------------------
*/
-static herr_t
-H5HL_minimize_heap_space(H5F_t *f, hid_t dxpl_id, H5HL_t *heap)
-{
- size_t new_heap_size = heap->dblk_size; /* New size of heap */
- herr_t ret_value = SUCCEED; /* Return value */
+BEGIN_FUNC(STATIC, ERR,
+herr_t, SUCCEED, FAIL,
+H5HL__minimize_heap_space(H5F_t *f, hid_t dxpl_id, H5HL_t *heap))
- FUNC_ENTER_NOAPI(FAIL)
+ size_t new_heap_size = heap->dblk_size; /* New size of heap */
/* check args */
HDassert(f);
@@ -393,7 +272,7 @@ H5HL_minimize_heap_space(H5F_t *f, hid_t dxpl_id, H5HL_t *heap)
new_heap_size = last_fl->offset;
/* Eliminate the free block from the list */
- last_fl = H5HL_remove_free(heap, last_fl);
+ last_fl = H5HL__remove_free(heap, last_fl);
} /* end else */
} /* end if */
else {
@@ -413,20 +292,21 @@ H5HL_minimize_heap_space(H5F_t *f, hid_t dxpl_id, H5HL_t *heap)
* storage.
*/
if(new_heap_size != heap->dblk_size) {
- HDassert(new_heap_size < heap->dblk_size);
+ HDassert(new_heap_size < heap->dblk_size);
/* Resize the memory buffer */
if(NULL == (heap->dblk_image = H5FL_BLK_REALLOC(lheap_chunk, heap->dblk_image, new_heap_size)))
- HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "memory allocation failed")
+ H5E_THROW(H5E_CANTALLOC, "memory allocation failed");
/* Reallocate data block in file */
- if(H5HL_dblk_realloc(f, dxpl_id, heap, new_heap_size) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, FAIL, "reallocating data block failed")
+ if(FAIL == H5HL__dblk_realloc(f, dxpl_id, heap, new_heap_size))
+ H5E_THROW(H5E_CANTRESIZE, "reallocating data block failed");
} /* end if */
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* H5HL_minimize_heap_space() */
+CATCH
+ /* No special processing on errors */
+
+END_FUNC(STATIC) /* H5HL__minimize_heap_space() */
/*-------------------------------------------------------------------------
@@ -438,23 +318,20 @@ done:
* Failure: NULL
*
* Programmer: Bill Wendling
- * wendling@ncsa.uiuc.edu
* Sept. 17, 2003
*
*-------------------------------------------------------------------------
*/
-H5HL_t *
-H5HL_protect(H5F_t *f, hid_t dxpl_id, haddr_t addr, unsigned flags)
-{
- H5HL_cache_prfx_ud_t prfx_udata; /* User data for protecting local heap prefix */
- H5HL_prfx_t *prfx = NULL; /* Local heap prefix */
- H5HL_dblk_t *dblk = NULL; /* Local heap data block */
- H5HL_t *heap = NULL; /* Heap data structure */
- unsigned prfx_cache_flags = H5AC__NO_FLAGS_SET; /* Cache flags for unprotecting prefix entry */
- unsigned dblk_cache_flags = H5AC__NO_FLAGS_SET; /* Cache flags for unprotecting data block entry */
- H5HL_t *ret_value = NULL; /* Return value */
-
- FUNC_ENTER_NOAPI(NULL)
+BEGIN_FUNC(PRIV, ERR,
+H5HL_t *, NULL, NULL,
+H5HL_protect(H5F_t *f, hid_t dxpl_id, haddr_t addr, unsigned flags))
+
+ H5HL_cache_prfx_ud_t prfx_udata; /* User data for protecting local heap prefix */
+ H5HL_prfx_t *prfx = NULL; /* Local heap prefix */
+ H5HL_dblk_t *dblk = NULL; /* Local heap data block */
+ H5HL_t *heap = NULL; /* Heap data structure */
+ unsigned prfx_cache_flags = H5AC__NO_FLAGS_SET; /* Cache flags for unprotecting prefix entry */
+ unsigned dblk_cache_flags = H5AC__NO_FLAGS_SET; /* Cache flags for unprotecting data block entry */
/* check arguments */
HDassert(f);
@@ -473,7 +350,7 @@ H5HL_protect(H5F_t *f, hid_t dxpl_id, haddr_t addr, unsigned flags)
/* Protect the local heap prefix */
if(NULL == (prfx = (H5HL_prfx_t *)H5AC_protect(f, dxpl_id, H5AC_LHEAP_PRFX, addr, &prfx_udata, flags)))
- HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, NULL, "unable to load heap prefix")
+ H5E_THROW(H5E_CANTPROTECT, "unable to load heap prefix");
/* Get the pointer to the heap */
heap = prfx->heap;
@@ -495,7 +372,7 @@ H5HL_protect(H5F_t *f, hid_t dxpl_id, haddr_t addr, unsigned flags)
/* Protect the local heap data block */
if(NULL == (dblk = (H5HL_dblk_t *)H5AC_protect(f, dxpl_id, H5AC_LHEAP_DBLK, heap->dblk_addr, &dblk_udata, flags)))
- HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, NULL, "unable to load heap data block")
+ H5E_THROW(H5E_CANTPROTECT, "unable to load heap data block");
/* Pin the prefix, if the data block was loaded from file */
if(dblk_udata.loaded)
@@ -512,49 +389,43 @@ H5HL_protect(H5F_t *f, hid_t dxpl_id, haddr_t addr, unsigned flags)
/* Set return value */
ret_value = heap;
-done:
+CATCH
/* Release the prefix from the cache, now pinned */
if(prfx && heap && H5AC_unprotect(f, dxpl_id, H5AC_LHEAP_PRFX, heap->prfx_addr, prfx, prfx_cache_flags) < 0)
- HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, NULL, "unable to release local heap prefix")
+ H5E_THROW(H5E_CANTUNPROTECT, "unable to release local heap prefix");
/* Release the data block from the cache, now pinned */
if(dblk && heap && H5AC_unprotect(f, dxpl_id, H5AC_LHEAP_DBLK, heap->dblk_addr, dblk, dblk_cache_flags) < 0)
- HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, NULL, "unable to release local heap data block")
+ H5E_THROW(H5E_CANTUNPROTECT, "unable to release local heap data block");
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5HL_protect() */
+END_FUNC(PRIV) /* end H5HL_protect() */
/*-------------------------------------------------------------------------
* Function: H5HL_offset_into
*
* Purpose: Called directly after the call to H5HL_protect so that
- * a pointer to the object in the heap can be got.
+ * a pointer to the object in the heap can be obtained.
*
* Return: Success: Valid pointer.
- * Failure: NULL
+ * Failure: Can't fail
*
* Programmer: Bill Wendling
- * wendling@ncsa.uiuc.edu
* Sept. 17, 2003
*
*-------------------------------------------------------------------------
*/
-void *
-H5HL_offset_into(const H5HL_t *heap, size_t offset)
-{
- /*
- * We need to have called some other function before this to get a
- * valid heap pointer. So, this can remain "FUNC_ENTER_NOAPI_NOINIT"
- */
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+BEGIN_FUNC(PRIV, NOERR,
+void *, NULL, -,
+H5HL_offset_into(const H5HL_t *heap, size_t offset))
/* Sanity check */
HDassert(heap);
HDassert(offset < heap->dblk_size);
- FUNC_LEAVE_NOAPI(heap->dblk_image + offset)
-} /* end H5HL_offset_into() */
+ ret_value = heap->dblk_image + offset;
+
+END_FUNC(PRIV) /* end H5HL_offset_into() */
/*-------------------------------------------------------------------------
@@ -562,21 +433,16 @@ H5HL_offset_into(const H5HL_t *heap, size_t offset)
*
* Purpose: Unprotect the data retrieved by the H5HL_protect call.
*
- * Return: Success: SUCCEED
- * Failure: FAIL
+ * Return: SUCCEED/FAIL
*
* Programmer: Bill Wendling
- * wendling@ncsa.uiuc.edu
* Sept. 17, 2003
*
*-------------------------------------------------------------------------
*/
-herr_t
-H5HL_unprotect(H5HL_t *heap)
-{
- herr_t ret_value = SUCCEED;
-
- FUNC_ENTER_NOAPI(FAIL)
+BEGIN_FUNC(PRIV, ERR,
+herr_t, SUCCEED, FAIL,
+H5HL_unprotect(H5HL_t *heap))
/* check arguments */
HDassert(heap);
@@ -589,8 +455,8 @@ H5HL_unprotect(H5HL_t *heap)
/* Check for separate heap data block */
if(heap->single_cache_obj) {
/* Mark local heap prefix as evictable again */
- if(H5AC_unpin_entry(heap->prfx) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPIN, FAIL, "unable to unpin local heap data block")
+ if(FAIL == H5AC_unpin_entry(heap->prfx))
+ H5E_THROW(H5E_CANTUNPIN, "unable to unpin local heap data block");
} /* end if */
else {
/* Sanity check */
@@ -598,34 +464,33 @@ H5HL_unprotect(H5HL_t *heap)
/* Mark local heap data block as evictable again */
/* (data block still pins prefix) */
- if(H5AC_unpin_entry(heap->dblk) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPIN, FAIL, "unable to unpin local heap data block")
+ if(FAIL == H5AC_unpin_entry(heap->dblk))
+ H5E_THROW(H5E_CANTUNPIN, "unable to unpin local heap data block");
} /* end else */
} /* end if */
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5HL_unprotect() */
+CATCH
+ /* No special processing on errors */
+
+END_FUNC(PRIV) /* end H5HL_unprotect() */
/*-------------------------------------------------------------------------
- * Function: H5HL_remove_free
+ * Function: H5HL__remove_free
*
- * Purpose: Removes free list element FL from the specified heap and
- * frees it.
+ * Purpose: Removes free list element FL from the specified heap and
+ * frees it.
*
- * Return: NULL
+ * Return: NULL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jul 17 1997
+ * Programmer: Robb Matzke
+ * Jul 17 1997
*
*-------------------------------------------------------------------------
*/
-static H5HL_free_t *
-H5HL_remove_free(H5HL_t *heap, H5HL_free_t *fl)
-{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+BEGIN_FUNC(STATIC, NOERR,
+H5HL_free_t *, NULL, -,
+H5HL__remove_free(H5HL_t *heap, H5HL_free_t *fl))
if(fl->prev)
fl->prev->next = fl->next;
@@ -635,30 +500,27 @@ H5HL_remove_free(H5HL_t *heap, H5HL_free_t *fl)
if(!fl->prev)
heap->freelist = fl->next;
- FUNC_LEAVE_NOAPI((H5HL_free_t *)H5FL_FREE(H5HL_free_t, fl))
-} /* end H5HL_remove_free() */
+ /* H5FL_FREE always returns NULL so we can't check for errors */
+ ret_value = (H5HL_free_t *)H5FL_FREE(H5HL_free_t, fl);
+
+END_FUNC(STATIC) /* end H5HL__remove_free() */
/*-------------------------------------------------------------------------
- * Function: H5HL_dirty
+ * Function: H5HL__dirty
*
- * Purpose: Mark heap as dirty
+ * Purpose: Mark heap as dirty
*
- * Return: Success: Non-negative
- * Failure: Negative
+ * Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
- * koziol@hdfgroup.org
- * Oct 12 2008
+ * Programmer: Quincey Koziol
+ * Oct 12 2008
*
*-------------------------------------------------------------------------
*/
-static herr_t
-H5HL_dirty(H5HL_t *heap)
-{
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI_NOINIT
+BEGIN_FUNC(STATIC, ERR,
+herr_t, SUCCEED, FAIL,
+H5HL__dirty(H5HL_t *heap))
/* check arguments */
HDassert(heap);
@@ -669,43 +531,41 @@ H5HL_dirty(H5HL_t *heap)
/* Sanity check */
HDassert(heap->dblk);
- if(H5AC_mark_entry_dirty(heap->dblk) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTMARKDIRTY, FAIL, "unable to mark heap data block as dirty")
+ if(FAIL == H5AC_mark_entry_dirty(heap->dblk))
+ H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark heap data block as dirty");
} /* end if */
/* Mark heap prefix as dirty */
- if(H5AC_mark_entry_dirty(heap->prfx) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTMARKDIRTY, FAIL, "unable to mark heap prefix as dirty")
+ if(FAIL == H5AC_mark_entry_dirty(heap->prfx))
+ H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark heap prefix as dirty");
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5HL_dirty() */
+CATCH
+ /* No special processing on errors */
+
+END_FUNC(STATIC) /* end H5HL__dirty() */
/*-------------------------------------------------------------------------
- * Function: H5HL_insert
+ * Function: H5HL_insert
*
- * Purpose: Inserts a new item into the heap.
+ * Purpose: Inserts a new item into the heap.
*
- * Return: Success: Offset of new item within heap.
- * Failure: UFAIL
+ * Return: Success: Offset of new item within heap.
+ * Failure: UFAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jul 17 1997
+ * Programmer: Robb Matzke
+ * Jul 17 1997
*
*-------------------------------------------------------------------------
*/
-size_t
-H5HL_insert(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t buf_size, const void *buf)
-{
- H5HL_free_t *fl = NULL, *last_fl = NULL;
- size_t offset = 0;
- size_t need_size;
- hbool_t found;
- size_t ret_value = 0; /* Return value */
+BEGIN_FUNC(PRIV, ERR,
+size_t, UFAIL, UFAIL,
+H5HL_insert(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t buf_size, const void *buf))
- FUNC_ENTER_NOAPI(UFAIL)
+ H5HL_free_t *fl = NULL, *last_fl = NULL;
+ size_t offset = 0;
+ size_t need_size;
+ hbool_t found;
/* check arguments */
HDassert(f);
@@ -719,8 +579,8 @@ H5HL_insert(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t buf_size, const void *
* so we just accept that an extra flush of the heap info could occur
* if an error occurs -QAK)
*/
- if(H5HL_dirty(heap) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTMARKDIRTY, UFAIL, "unable to mark heap as dirty")
+ if(FAIL == H5HL__dirty(heap))
+ H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark heap as dirty");
/*
* In order to keep the free list descriptors aligned on word boundaries,
@@ -734,26 +594,25 @@ H5HL_insert(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t buf_size, const void *
* leave zero or at least H5G_SIZEOF_FREE bytes left over.
*/
for(fl = heap->freelist, found = FALSE; fl; fl = fl->next) {
- if(fl->size > need_size &&
- fl->size - need_size >= H5HL_SIZEOF_FREE(f)) {
- /* a big enough free block was found */
- offset = fl->offset;
- fl->offset += need_size;
- fl->size -= need_size;
- HDassert(fl->offset == H5HL_ALIGN(fl->offset));
- HDassert(fl->size == H5HL_ALIGN(fl->size));
- found = TRUE;
- break;
- } else if(fl->size == need_size) {
- /* free block of exact size found */
- offset = fl->offset;
- fl = H5HL_remove_free(heap, fl);
- found = TRUE;
- break;
- } else if(!last_fl || last_fl->offset < fl->offset) {
- /* track free space that's closest to end of heap */
- last_fl = fl;
- }
+ if(fl->size > need_size && fl->size - need_size >= H5HL_SIZEOF_FREE(f)) {
+ /* a big enough free block was found */
+ offset = fl->offset;
+ fl->offset += need_size;
+ fl->size -= need_size;
+ HDassert(fl->offset == H5HL_ALIGN(fl->offset));
+ HDassert(fl->size == H5HL_ALIGN(fl->size));
+ found = TRUE;
+ break;
+ } else if(fl->size == need_size) {
+ /* free block of exact size found */
+ offset = fl->offset;
+ fl = H5HL__remove_free(heap, fl);
+ found = TRUE;
+ break;
+ } else if(!last_fl || last_fl->offset < fl->offset) {
+ /* track free space that's closest to end of heap */
+ last_fl = fl;
+ }
} /* end for */
/*
@@ -770,7 +629,7 @@ H5HL_insert(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t buf_size, const void *
/* At least double the heap's size, making certain there's enough room
* for the new object */
- need_more = MAX(need_size, heap->dblk_size);
+ need_more = MAX(need_size, heap->dblk_size);
/* If there is no last free block or it's not at the end of the heap,
* and the amount of space to allocate is not big enough to include at
@@ -778,106 +637,104 @@ H5HL_insert(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t buf_size, const void *
* space requested to just the amount of space needed. (Generally
* speaking, this only occurs when the heap is small -QAK)
*/
- if(!(last_fl && last_fl->offset + last_fl->size == heap->dblk_size)
+ if(!(last_fl && last_fl->offset + last_fl->size == heap->dblk_size)
&& (need_more < (need_size + H5HL_SIZEOF_FREE(f))))
need_more = need_size;
- new_dblk_size = heap->dblk_size + need_more;
- HDassert(heap->dblk_size < new_dblk_size);
+ new_dblk_size = heap->dblk_size + need_more;
+ HDassert(heap->dblk_size < new_dblk_size);
old_dblk_size = heap->dblk_size;
- H5_CHECK_OVERFLOW(heap->dblk_size, size_t, hsize_t);
- H5_CHECK_OVERFLOW(new_dblk_size, size_t, hsize_t);
+ H5_CHECK_OVERFLOW(heap->dblk_size, size_t, hsize_t);
+ H5_CHECK_OVERFLOW(new_dblk_size, size_t, hsize_t);
/* Extend current heap if possible */
- was_extended = H5MF_try_extend(f, dxpl_id, H5FD_MEM_LHEAP, heap->dblk_addr, (hsize_t)(heap->dblk_size), (hsize_t)need_more);
- if(was_extended < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTEXTEND, UFAIL, "error trying to extend heap")
+ was_extended = H5MF_try_extend(f, dxpl_id, H5FD_MEM_LHEAP, heap->dblk_addr, (hsize_t)(heap->dblk_size), (hsize_t)need_more);
+ if(FAIL == was_extended)
+ H5E_THROW(H5E_CANTEXTEND, "error trying to extend heap");
/* Check if we extended the heap data block in file */
if(was_extended == TRUE) {
/* Check for prefix & data block contiguous */
if(heap->single_cache_obj) {
/* Resize prefix+data block */
- if(H5AC_resize_entry(heap->prfx, (size_t)(heap->prfx_size + new_dblk_size)) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, UFAIL, "unable to resize heap prefix in cache")
+ if(FAIL == H5AC_resize_entry(heap->prfx, (size_t)(heap->prfx_size + new_dblk_size)))
+ H5E_THROW(H5E_CANTRESIZE, "unable to resize heap prefix in cache");
} /* end if */
else {
/* Resize 'standalone' data block */
- if(H5AC_resize_entry(heap->dblk, (size_t)new_dblk_size) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, UFAIL, "unable to resize heap data block in cache")
+ if(FAIL == H5AC_resize_entry(heap->dblk, (size_t)new_dblk_size))
+ H5E_THROW(H5E_CANTRESIZE, "unable to resize heap data block in cache");
} /* end else */
/* Note new size */
heap->dblk_size = new_dblk_size;
- } /* end if */
+ } /* end if */
else { /* ...if we can't, allocate a new chunk & release the old */
/* Reallocate data block in file */
- if(H5HL_dblk_realloc(f, dxpl_id, heap, new_dblk_size) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, UFAIL, "reallocating data block failed")
- } /* end if */
+ if(FAIL == H5HL__dblk_realloc(f, dxpl_id, heap, new_dblk_size))
+ H5E_THROW(H5E_CANTRESIZE, "reallocating data block failed");
+ } /* end if */
/* If the last free list in the heap is at the end of the heap, extend it */
- if(last_fl && last_fl->offset + last_fl->size == old_dblk_size) {
- /*
- * Increase the size of the last free block.
- */
- offset = last_fl->offset;
- last_fl->offset += need_size;
- last_fl->size += need_more - need_size;
- HDassert(last_fl->offset == H5HL_ALIGN(last_fl->offset));
- HDassert(last_fl->size == H5HL_ALIGN(last_fl->size));
-
- if (last_fl->size < H5HL_SIZEOF_FREE(f)) {
+ if(last_fl && last_fl->offset + last_fl->size == old_dblk_size) {
+ /*
+ * Increase the size of the last free block.
+ */
+ offset = last_fl->offset;
+ last_fl->offset += need_size;
+ last_fl->size += need_more - need_size;
+ HDassert(last_fl->offset == H5HL_ALIGN(last_fl->offset));
+ HDassert(last_fl->size == H5HL_ALIGN(last_fl->size));
+
+ if (last_fl->size < H5HL_SIZEOF_FREE(f)) {
#ifdef H5HL_DEBUG
- if (H5DEBUG(HL) && last_fl->size) {
- fprintf(H5DEBUG(HL), "H5HL: lost %lu bytes at line %d\n",
- (unsigned long)(last_fl->size), __LINE__);
- }
+ if (H5DEBUG(HL) && last_fl->size) {
+ HDfprintf(H5DEBUG(HL), "H5HL: lost %lu bytes at line %d\n",
+ (unsigned long)(last_fl->size), __LINE__);
+ }
#endif
- last_fl = H5HL_remove_free(heap, last_fl);
- }
- } /* end if */
+ last_fl = H5HL__remove_free(heap, last_fl);
+ }
+ } /* end if */
else {
- /*
- * Create a new free list element large enough that we can
- * take some space out of it right away.
- */
- offset = old_dblk_size;
- if(need_more - need_size >= H5HL_SIZEOF_FREE(f)) {
- if(NULL == (fl = H5FL_MALLOC(H5HL_free_t)))
- HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, UFAIL, "memory allocation failed")
- fl->offset = old_dblk_size + need_size;
- fl->size = need_more - need_size;
- HDassert(fl->offset == H5HL_ALIGN(fl->offset));
- HDassert(fl->size == H5HL_ALIGN(fl->size));
- fl->prev = NULL;
- fl->next = heap->freelist;
- if(heap->freelist)
+ /*
+ * Create a new free list element large enough that we can
+ * take some space out of it right away.
+ */
+ offset = old_dblk_size;
+ if(need_more - need_size >= H5HL_SIZEOF_FREE(f)) {
+ if(NULL == (fl = H5FL_MALLOC(H5HL_free_t)))
+ H5E_THROW(H5E_CANTALLOC, "memory allocation failed");
+ fl->offset = old_dblk_size + need_size;
+ fl->size = need_more - need_size;
+ HDassert(fl->offset == H5HL_ALIGN(fl->offset));
+ HDassert(fl->size == H5HL_ALIGN(fl->size));
+ fl->prev = NULL;
+ fl->next = heap->freelist;
+ if(heap->freelist)
heap->freelist->prev = fl;
- heap->freelist = fl;
+ heap->freelist = fl;
#ifdef H5HL_DEBUG
- } else if (H5DEBUG(HL) && need_more > need_size) {
- fprintf(H5DEBUG(HL),
- "H5HL_insert: lost %lu bytes at line %d\n",
- (unsigned long)(need_more - need_size), __LINE__);
+ } else if (H5DEBUG(HL) && need_more > need_size) {
+ HDfprintf(H5DEBUG(HL), "H5HL_insert: lost %lu bytes at line %d\n",
+ (unsigned long)(need_more - need_size), __LINE__);
#endif
- }
- } /* end else */
+ }
+ } /* end else */
#ifdef H5HL_DEBUG
- if (H5DEBUG(HL)) {
- fprintf(H5DEBUG(HL),
- "H5HL: resize mem buf from %lu to %lu bytes\n",
- (unsigned long)(old_dblk_size),
- (unsigned long)(old_dblk_size + need_more));
- }
+ if (H5DEBUG(HL)) {
+ HDfprintf(H5DEBUG(HL), "H5HL: resize mem buf from %lu to %lu bytes\n",
+ (unsigned long)(old_dblk_size),
+ (unsigned long)(old_dblk_size + need_more));
+ }
#endif
- if(NULL == (heap->dblk_image = H5FL_BLK_REALLOC(lheap_chunk, heap->dblk_image, heap->dblk_size)))
- HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, UFAIL, "memory allocation failed")
+ if(NULL == (heap->dblk_image = H5FL_BLK_REALLOC(lheap_chunk, heap->dblk_image, heap->dblk_size)))
+ H5E_THROW(H5E_CANTALLOC, "memory allocation failed");
- /* Clear new section so junk doesn't appear in the file */
+ /* Clear new section so junk doesn't appear in the file */
/* (Avoid clearing section which will be overwritten with newly inserted data) */
- HDmemset(heap->dblk_image + offset + buf_size, 0, (new_dblk_size - (offset + buf_size)));
+ HDmemset(heap->dblk_image + offset + buf_size, 0, (new_dblk_size - (offset + buf_size)));
} /* end if */
/* Copy the data into the heap */
@@ -886,42 +743,40 @@ H5HL_insert(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t buf_size, const void *
/* Set return value */
ret_value = offset;
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* H5HL_insert() */
+CATCH
+ /* No special processing on errors */
+
+END_FUNC(PRIV) /* H5HL_insert() */
/*-------------------------------------------------------------------------
- * Function: H5HL_remove
+ * Function: H5HL_remove
*
- * Purpose: Removes an object or part of an object from the heap at
- * address ADDR of file F. The object (or part) to remove
- * begins at byte OFFSET from the beginning of the heap and
- * continues for SIZE bytes.
+ * Purpose: Removes an object or part of an object from the heap at
+ * address ADDR of file F. The object (or part) to remove
+ * begins at byte OFFSET from the beginning of the heap and
+ * continues for SIZE bytes.
*
- * Once part of an object is removed, one must not attempt
- * to access that part. Removing the beginning of an object
- * results in the object OFFSET increasing by the amount
- * truncated. Removing the end of an object results in
- * object truncation. Removing the middle of an object results
- * in two separate objects, one at the original offset and
- * one at the first offset past the removed portion.
+ * Once part of an object is removed, one must not attempt
+ * to access that part. Removing the beginning of an object
+ * results in the object OFFSET increasing by the amount
+ * truncated. Removing the end of an object results in
+ * object truncation. Removing the middle of an object results
+ * in two separate objects, one at the original offset and
+ * one at the first offset past the removed portion.
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jul 16 1997
+ * Programmer: Robb Matzke
+ * Jul 16 1997
*
*-------------------------------------------------------------------------
*/
-herr_t
-H5HL_remove(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t offset, size_t size)
-{
- H5HL_free_t *fl = NULL;
- herr_t ret_value = SUCCEED; /* Return value */
+BEGIN_FUNC(PRIV, ERR,
+herr_t, SUCCEED, FAIL,
+H5HL_remove(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t offset, size_t size))
- FUNC_ENTER_NOAPI(FAIL)
+ H5HL_free_t *fl = NULL;
/* check arguments */
HDassert(f);
@@ -940,8 +795,8 @@ H5HL_remove(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t offset, size_t size)
* so we just accept that an extra flush of the heap info could occur
* if an error occurs -QAK)
*/
- if(H5HL_dirty(heap) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTMARKDIRTY, FAIL, "unable to mark heap as dirty")
+ if(FAIL == H5HL__dirty(heap))
+ H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark heap as dirty");
/*
* Check if this chunk can be prepended or appended to an already
@@ -952,60 +807,60 @@ H5HL_remove(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t offset, size_t size)
while(fl) {
H5HL_free_t *fl2 = NULL;
- if((offset + size) == fl->offset) {
- fl->offset = offset;
- fl->size += size;
- HDassert(fl->offset == H5HL_ALIGN(fl->offset));
- HDassert(fl->size == H5HL_ALIGN(fl->size));
- fl2 = fl->next;
- while(fl2) {
- if((fl2->offset + fl2->size) == fl->offset) {
- fl->offset = fl2->offset;
- fl->size += fl2->size;
- HDassert(fl->offset == H5HL_ALIGN(fl->offset));
- HDassert(fl->size == H5HL_ALIGN(fl->size));
- fl2 = H5HL_remove_free(heap, fl2);
- if(((fl->offset + fl->size) == heap->dblk_size) &&
+ if((offset + size) == fl->offset) {
+ fl->offset = offset;
+ fl->size += size;
+ HDassert(fl->offset == H5HL_ALIGN(fl->offset));
+ HDassert(fl->size == H5HL_ALIGN(fl->size));
+ fl2 = fl->next;
+ while(fl2) {
+ if((fl2->offset + fl2->size) == fl->offset) {
+ fl->offset = fl2->offset;
+ fl->size += fl2->size;
+ HDassert(fl->offset == H5HL_ALIGN(fl->offset));
+ HDassert(fl->size == H5HL_ALIGN(fl->size));
+ fl2 = H5HL__remove_free(heap, fl2);
+ if(((fl->offset + fl->size) == heap->dblk_size) &&
((2 * fl->size) > heap->dblk_size)) {
- if(H5HL_minimize_heap_space(f, dxpl_id, heap) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "heap size minimization failed")
+ if(FAIL == H5HL__minimize_heap_space(f, dxpl_id, heap))
+ H5E_THROW(H5E_CANTFREE, "heap size minimization failed");
}
- HGOTO_DONE(SUCCEED);
- }
- fl2 = fl2->next;
- }
- if(((fl->offset + fl->size) == heap->dblk_size) &&
+ H5_LEAVE(SUCCEED);
+ }
+ fl2 = fl2->next;
+ }
+ if(((fl->offset + fl->size) == heap->dblk_size) &&
((2 * fl->size) > heap->dblk_size)) {
- if(H5HL_minimize_heap_space(f, dxpl_id, heap) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "heap size minimization failed")
+ if(FAIL == H5HL__minimize_heap_space(f, dxpl_id, heap))
+ H5E_THROW(H5E_CANTFREE, "heap size minimization failed");
}
- HGOTO_DONE(SUCCEED);
- } else if(fl->offset + fl->size == offset) {
- fl->size += size;
- fl2 = fl->next;
- HDassert(fl->size == H5HL_ALIGN(fl->size));
- while(fl2) {
- if(fl->offset + fl->size == fl2->offset) {
- fl->size += fl2->size;
- HDassert(fl->size == H5HL_ALIGN(fl->size));
- fl2 = H5HL_remove_free(heap, fl2);
- if(((fl->offset + fl->size) == heap->dblk_size) &&
- ((2 * fl->size) > heap->dblk_size)) {
- if(H5HL_minimize_heap_space(f, dxpl_id, heap) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "heap size minimization failed")
+ H5_LEAVE(SUCCEED);
+ } else if(fl->offset + fl->size == offset) {
+ fl->size += size;
+ fl2 = fl->next;
+ HDassert(fl->size == H5HL_ALIGN(fl->size));
+ while(fl2) {
+ if(fl->offset + fl->size == fl2->offset) {
+ fl->size += fl2->size;
+ HDassert(fl->size == H5HL_ALIGN(fl->size));
+ fl2 = H5HL__remove_free(heap, fl2);
+ if(((fl->offset + fl->size) == heap->dblk_size) &&
+ ((2 * fl->size) > heap->dblk_size)) {
+ if(FAIL == H5HL__minimize_heap_space(f, dxpl_id, heap))
+ H5E_THROW(H5E_CANTFREE, "heap size minimization failed");
} /* end if */
- HGOTO_DONE(SUCCEED);
- } /* end if */
- fl2 = fl2->next;
- } /* end while */
- if(((fl->offset + fl->size) == heap->dblk_size) &&
+ H5_LEAVE(SUCCEED);
+ } /* end if */
+ fl2 = fl2->next;
+ } /* end while */
+ if(((fl->offset + fl->size) == heap->dblk_size) &&
((2 * fl->size) > heap->dblk_size)) {
- if(H5HL_minimize_heap_space(f, dxpl_id, heap) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "heap size minimization failed")
+ if(FAIL == H5HL__minimize_heap_space(f, dxpl_id, heap))
+ H5E_THROW(H5E_CANTFREE, "heap size minimization failed");
} /* end if */
- HGOTO_DONE(SUCCEED);
- } /* end if */
- fl = fl->next;
+ H5_LEAVE(SUCCEED);
+ } /* end if */
+ fl = fl->next;
} /* end while */
/*
@@ -1015,19 +870,18 @@ H5HL_remove(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t offset, size_t size)
*/
if(size < H5HL_SIZEOF_FREE(f)) {
#ifdef H5HL_DEBUG
- if(H5DEBUG(HL)) {
- fprintf(H5DEBUG(HL), "H5HL: lost %lu bytes\n",
- (unsigned long) size);
- }
+ if(H5DEBUG(HL)) {
+ HDfprintf(H5DEBUG(HL), "H5HL: lost %lu bytes\n", (unsigned long) size);
+ }
#endif
- HGOTO_DONE(SUCCEED);
+ H5_LEAVE(SUCCEED);
} /* end if */
/*
* Add an entry to the free list.
*/
if(NULL == (fl = H5FL_MALLOC(H5HL_free_t)))
- HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "memory allocation failed")
+ H5E_THROW(H5E_CANTALLOC, "memory allocation failed");
fl->offset = offset;
fl->size = size;
HDassert(fl->offset == H5HL_ALIGN(fl->offset));
@@ -1040,39 +894,37 @@ H5HL_remove(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t offset, size_t size)
if(((fl->offset + fl->size) == heap->dblk_size) &&
((2 * fl->size) > heap->dblk_size)) {
- if(H5HL_minimize_heap_space(f, dxpl_id, heap) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "heap size minimization failed")
+ if(FAIL == H5HL__minimize_heap_space(f, dxpl_id, heap))
+ H5E_THROW(H5E_CANTFREE, "heap size minimization failed");
} /* end if */
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5HL_remove() */
+CATCH
+ /* No special processing on exit */
+
+END_FUNC(PRIV) /* end H5HL_remove() */
/*-------------------------------------------------------------------------
- * Function: H5HL_delete
+ * Function: H5HL_delete
*
- * Purpose: Deletes a local heap from disk, freeing disk space used.
+ * Purpose: Deletes a local heap from disk, freeing disk space used.
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
- * koziol@ncsa.uiuc.edu
- * Mar 22 2003
+ * Programmer: Quincey Koziol
+ * Mar 22 2003
*
*-------------------------------------------------------------------------
*/
-herr_t
-H5HL_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr)
-{
- H5HL_t *heap = NULL; /* Local heap to delete */
+BEGIN_FUNC(PRIV, ERR,
+herr_t, SUCCEED, FAIL,
+H5HL_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr))
+
+ H5HL_t *heap = NULL; /* Local heap to delete */
H5HL_cache_prfx_ud_t prfx_udata; /* User data for protecting local heap prefix */
H5HL_prfx_t *prfx = NULL; /* Local heap prefix */
H5HL_dblk_t *dblk = NULL; /* Local heap data block */
unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting heap */
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(FAIL)
/* check arguments */
HDassert(f);
@@ -1088,7 +940,7 @@ H5HL_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr)
/* Protect the local heap prefix */
if(NULL == (prfx = (H5HL_prfx_t *)H5AC_protect(f, dxpl_id, H5AC_LHEAP_PRFX, addr, &prfx_udata, H5AC__NO_FLAGS_SET)))
- HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to load heap prefix")
+ H5E_THROW(H5E_CANTPROTECT, "unable to load heap prefix");
/* Get the pointer to the heap */
heap = prfx->heap;
@@ -1103,53 +955,49 @@ H5HL_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr)
/* Protect the local heap data block */
if(NULL == (dblk = (H5HL_dblk_t *)H5AC_protect(f, dxpl_id, H5AC_LHEAP_DBLK, heap->dblk_addr, &dblk_udata, H5AC__NO_FLAGS_SET)))
- HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to load heap data block")
+ H5E_THROW(H5E_CANTPROTECT, "unable to load heap data block");
/* Pin the prefix, if the data block was loaded from file */
if(dblk_udata.loaded) {
- if(H5AC_pin_protected_entry(prfx) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTPIN, FAIL, "unable to pin local heap prefix")
+ if(FAIL == H5AC_pin_protected_entry(prfx))
+ H5E_THROW(H5E_CANTPIN, "unable to pin local heap prefix");
} /* end if */
} /* end if */
/* Set the flags for releasing the prefix and data block */
cache_flags |= H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG;
-done:
+CATCH
/* Release the data block from the cache, now deleted */
if(dblk && heap && H5AC_unprotect(f, dxpl_id, H5AC_LHEAP_DBLK, heap->dblk_addr, dblk, cache_flags) < 0)
- HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release local heap data block")
+ H5E_THROW(H5E_CANTUNPROTECT, "unable to release local heap data block");
/* Release the prefix from the cache, now deleted */
if(prfx && heap && H5AC_unprotect(f, dxpl_id, H5AC_LHEAP_PRFX, heap->prfx_addr, prfx, cache_flags) < 0)
- HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release local heap prefix")
+ H5E_THROW(H5E_CANTUNPROTECT, "unable to release local heap prefix");
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5HL_delete() */
+END_FUNC(PRIV) /* end H5HL_delete() */
/*-------------------------------------------------------------------------
- * Function: H5HL_get_size
+ * Function: H5HL_get_size
*
- * Purpose: Retrieves the current size of a heap
+ * Purpose: Retrieves the current size of a heap
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
- * koziol@ncsa.uiuc.edu
- * Nov 7 2005
+ * Programmer: Quincey Koziol
+ * Nov 7 2005
*
*-------------------------------------------------------------------------
*/
-herr_t
-H5HL_get_size(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t *size)
-{
- H5HL_cache_prfx_ud_t prfx_udata; /* User data for protecting local heap prefix */
- H5HL_prfx_t *prfx = NULL; /* Local heap prefix */
- H5HL_t *heap; /* Heap data structure */
- herr_t ret_value = SUCCEED; /* Return value */
+BEGIN_FUNC(PRIV, ERR,
+herr_t, SUCCEED, FAIL,
+H5HL_get_size(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t *size))
- FUNC_ENTER_NOAPI(FAIL)
+ H5HL_cache_prfx_ud_t prfx_udata; /* User data for protecting local heap prefix */
+ H5HL_prfx_t *prfx = NULL; /* Local heap prefix */
+ H5HL_t *heap; /* Heap data structure */
/* check arguments */
HDassert(f);
@@ -1166,7 +1014,7 @@ H5HL_get_size(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t *size)
/* Protect the local heap prefix */
if(NULL == (prfx = (H5HL_prfx_t *)H5AC_protect(f, dxpl_id, H5AC_LHEAP_PRFX, addr, &prfx_udata, H5AC__READ_ONLY_FLAG)))
- HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to load heap prefix")
+ H5E_THROW(H5E_CANTPROTECT, "unable to load heap prefix");
/* Get the pointer to the heap */
heap = prfx->heap;
@@ -1174,12 +1022,11 @@ H5HL_get_size(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t *size)
/* Set the size to return */
*size = heap->dblk_size;
-done:
- if(prfx && H5AC_unprotect(f, dxpl_id, H5AC_LHEAP_PRFX, heap->prfx_addr, prfx, H5AC__NO_FLAGS_SET) < 0)
- HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release local heap prefix")
+CATCH
+ if(prfx && FAIL == H5AC_unprotect(f, dxpl_id, H5AC_LHEAP_PRFX, heap->prfx_addr, prfx, H5AC__NO_FLAGS_SET))
+ H5E_THROW(H5E_CANTUNPROTECT, "unable to release local heap prefix");
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5HL_get_size() */
+END_FUNC(PRIV) /* end H5HL_get_size() */
/*-------------------------------------------------------------------------
@@ -1188,22 +1035,20 @@ done:
* Purpose: Compute the size in bytes of the specified instance of
* H5HL_t via H5HL_size()
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
* Programmer: Vailin Choi
* June 19 2007
*
*-------------------------------------------------------------------------
*/
-herr_t
-H5HL_heapsize(H5F_t *f, hid_t dxpl_id, haddr_t addr, hsize_t *heap_size)
-{
- H5HL_cache_prfx_ud_t prfx_udata; /* User data for protecting local heap prefix */
- H5HL_prfx_t *prfx = NULL; /* Local heap prefix */
- H5HL_t *heap; /* Heap data structure */
- herr_t ret_value = SUCCEED; /* Return value */
+BEGIN_FUNC(PRIV, ERR,
+herr_t, SUCCEED, FAIL,
+H5HL_heapsize(H5F_t *f, hid_t dxpl_id, haddr_t addr, hsize_t *heap_size))
- FUNC_ENTER_NOAPI(FAIL)
+ H5HL_cache_prfx_ud_t prfx_udata; /* User data for protecting local heap prefix */
+ H5HL_prfx_t *prfx = NULL; /* Local heap prefix */
+ H5HL_t *heap; /* Heap data structure */
/* check arguments */
HDassert(f);
@@ -1220,7 +1065,7 @@ H5HL_heapsize(H5F_t *f, hid_t dxpl_id, haddr_t addr, hsize_t *heap_size)
/* Protect the local heap prefix */
if(NULL == (prfx = (H5HL_prfx_t *)H5AC_protect(f, dxpl_id, H5AC_LHEAP_PRFX, addr, &prfx_udata, H5AC__READ_ONLY_FLAG)))
- HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to load heap prefix")
+ H5E_THROW(H5E_CANTPROTECT, "unable to load heap prefix");
/* Get the pointer to the heap */
heap = prfx->heap;
@@ -1228,10 +1073,9 @@ H5HL_heapsize(H5F_t *f, hid_t dxpl_id, haddr_t addr, hsize_t *heap_size)
/* Accumulate the size of the local heap */
*heap_size += (hsize_t)(heap->prfx_size + heap->dblk_size);
-done:
- if(prfx && H5AC_unprotect(f, dxpl_id, H5AC_LHEAP_PRFX, heap->prfx_addr, prfx, H5AC__NO_FLAGS_SET) < 0)
- HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release local heap prefix")
+CATCH
+ if(prfx && FAIL == H5AC_unprotect(f, dxpl_id, H5AC_LHEAP_PRFX, heap->prfx_addr, prfx, H5AC__NO_FLAGS_SET))
+ H5E_THROW(H5E_CANTUNPROTECT, "unable to release local heap prefix");
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5HL_heapsize() */
+END_FUNC(PRIV) /* end H5HL_heapsize() */
diff --git a/src/H5HLcache.c b/src/H5HLcache.c
index 42fe1c7..faa5ff2 100644
--- a/src/H5HLcache.c
+++ b/src/H5HLcache.c
@@ -15,11 +15,11 @@
/*-------------------------------------------------------------------------
*
- * Created: H5HLcache.c
- * Feb 5 2008
- * Quincey Koziol <koziol@hdfgroup.org>
+ * Created: H5HLcache.c
+ * Feb 5 2008
+ * Quincey Koziol <koziol@hdfgroup.org>
*
- * Purpose: Implement local heap metadata cache methods.
+ * Purpose: Implement local heap metadata cache methods.
*
*-------------------------------------------------------------------------
*/
@@ -34,24 +34,25 @@
/***********/
/* Headers */
/***********/
-#include "H5private.h" /* Generic Functions */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5HLpkg.h" /* Local Heaps */
-#include "H5MFprivate.h" /* File memory management */
-#include "H5WBprivate.h" /* Wrapped Buffers */
+#include "H5private.h" /* Generic Functions */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5HLpkg.h" /* Local Heaps */
+#include "H5MFprivate.h" /* File memory management */
+#include "H5WBprivate.h" /* Wrapped Buffers */
/****************/
/* Local Macros */
/****************/
-#define H5HL_VERSION 0 /* Local heap collection version */
+#define H5HL_VERSION 0 /* Local heap collection version */
-/* Set the local heap size to speculatively read in */
-/* (needs to be more than the local heap prefix size to work at all and
+/* Set the local heap size to speculatively read in
+ * (needs to be more than the local heap prefix size to work at all and
* should be larger than the default local heap size to save the
- * extra I/O operations) */
-#define H5HL_SPEC_READ_SIZE 512
+ * extra I/O operations)
+ */
+#define H5HL_SPEC_READ_SIZE 512
/******************/
@@ -69,6 +70,7 @@
/********************/
/* Metadata cache callbacks */
+/* Local heap prefix */
static herr_t H5HL__cache_prefix_get_load_size(const void *udata, size_t *image_len);
static void *H5HL__cache_prefix_deserialize(const void *image, size_t len,
void *udata, hbool_t *dirty);
@@ -79,6 +81,7 @@ static herr_t H5HL__cache_prefix_serialize(const H5F_t *f, void *image,
size_t len, void *thing);
static herr_t H5HL__cache_prefix_free_icr(void *thing);
+/* Local heap data block */
static herr_t H5HL__cache_datablock_get_load_size(const void *udata,
size_t *image_len);
static void *H5HL__cache_datablock_deserialize(const void *image, size_t len,
@@ -90,6 +93,9 @@ static herr_t H5HL__cache_datablock_serialize(const H5F_t *f, void *image,
size_t len, void *thing);
static herr_t H5HL__cache_datablock_free_icr(void *thing);
+/* Free list de/serialization */
+static herr_t H5HL__fl_deserialize(H5HL_t *heap);
+static void H5HL__fl_serialize(const H5HL_t *heap);
/*********************/
/* Package Variables */
@@ -141,15 +147,14 @@ const H5AC_class_t H5AC_LHEAP_DBLK[1] = {{
/*-------------------------------------------------------------------------
- * Function: H5HL__fl_deserialize
+ * Function: H5HL__fl_deserialize
*
- * Purpose: Deserialize the free list for a heap data block
+ * Purpose: Deserialize the free list for a heap data block
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
- * koziol@hdfgroup.org
- * Oct 12 2008
+ * Programmer: Quincey Koziol
+ * Oct 12 2008
*
*-------------------------------------------------------------------------
*/
@@ -185,7 +190,7 @@ H5HL__fl_deserialize(H5HL_t *heap)
/* Decode offset of next free block */
image = heap->dblk_image + free_block;
H5F_DECODE_LENGTH_LEN(image, free_block, heap->sizeof_size);
- if(free_block == 0)
+ if(0 == free_block)
HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, FAIL, "free block size is zero?")
/* Decode length of this free block */
@@ -205,6 +210,7 @@ H5HL__fl_deserialize(H5HL_t *heap)
done:
if(ret_value < 0)
if(fl)
+ /* H5FL_FREE always returns NULL so we can't check for errors */
fl = H5FL_FREE(H5HL_free_t, fl);
FUNC_LEAVE_NOAPI(ret_value)
@@ -212,23 +218,21 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5HL__fl_serialize
+ * Function: H5HL__fl_serialize
*
- * Purpose: Serialize the free list for a heap data block
+ * Purpose: Serialize the free list for a heap data block
*
- * Return: Success: SUCCESS
- * Failure: FAIL
+ * Return: Nothing (void)
*
- * Programmer: Quincey Koziol
- * koziol@hdfgroup.org
- * Oct 12 2008
+ * Programmer: Quincey Koziol
+ * Oct 12 2008
*
*-------------------------------------------------------------------------
*/
static void
H5HL__fl_serialize(const H5HL_t *heap)
{
- H5HL_free_t *fl; /* Pointer to heap free list node */
+ H5HL_free_t *fl; /* Pointer to heap free list node */
FUNC_ENTER_STATIC_NOERR
@@ -251,6 +255,7 @@ H5HL__fl_serialize(const H5HL_t *heap)
} /* end for */
FUNC_LEAVE_NOAPI_VOID
+
} /* end H5HL__fl_serialize() */
@@ -338,12 +343,12 @@ H5HL__cache_prefix_deserialize(const void *_image, size_t len, void *_udata,
image += 3;
/* Allocate space in memory for the heap */
- if(NULL == (heap = H5HL_new(udata->sizeof_size, udata->sizeof_addr, udata->sizeof_prfx)))
- HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "can't allocate local heap structure")
+ if(NULL == (heap = H5HL__new(udata->sizeof_size, udata->sizeof_addr, udata->sizeof_prfx)))
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "can't allocate local heap structure");
/* Allocate the heap prefix */
- if(NULL == (prfx = H5HL_prfx_new(heap)))
- HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "can't allocate local heap prefix")
+ if(NULL == (prfx = H5HL__prfx_new(heap)))
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "can't allocate local heap prefix");
/* Store the prefix's address & length */
heap->prfx_addr = udata->prfx_addr;
@@ -422,12 +427,12 @@ done:
/* Release the [possibly partially initialized] local heap on errors */
if(!ret_value) {
if(prfx) {
- if(H5HL_prfx_dest(prfx) < 0)
- HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, NULL, "unable to destroy local heap prefix")
+ if(FAIL == H5HL__prfx_dest(prfx))
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, NULL, "unable to destroy local heap prefix");
} /* end if */
else {
- if(heap && H5HL_dest(heap) < 0)
- HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, NULL, "unable to destroy local heap")
+ if(heap && FAIL == H5HL__dest(heap))
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, NULL, "unable to destroy local heap");
} /* end else */
} /* end if */
@@ -472,7 +477,6 @@ H5HL__cache_prefix_image_len(const void *_thing, size_t *image_len,
if(prfx->heap->single_cache_obj)
*image_len += prfx->heap->dblk_size;
-
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5HL__cache_prefix_image_len() */
@@ -619,7 +623,7 @@ H5HL__cache_prefix_free_icr(void *_thing)
HDassert(H5F_addr_eq(prfx->cache_info.addr, prfx->heap->prfx_addr));
/* Destroy local heap prefix */
- if(H5HL_prfx_dest(prfx) < 0)
+ if(H5HL__prfx_dest(prfx) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't destroy local heap prefix")
done:
@@ -697,21 +701,21 @@ H5HL__cache_datablock_deserialize(const void *image, size_t len, void *_udata,
HDassert(dirty);
/* Allocate space in memory for the heap data block */
- if(NULL == (dblk = H5HL_dblk_new(udata->heap)))
- HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "memory allocation failed")
+ if(NULL == (dblk = H5HL__dblk_new(udata->heap)))
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "memory allocation failed");
/* Check for heap still retaining image */
if(NULL == udata->heap->dblk_image) {
/* Allocate space for the heap data image */
if(NULL == (udata->heap->dblk_image = H5FL_BLK_MALLOC(lheap_chunk, udata->heap->dblk_size)))
- HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "can't allocate data block image buffer")
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "can't allocate data block image buffer");
/* copy the datablock from the read buffer */
HDmemcpy(udata->heap->dblk_image, image, len);
/* Build free list */
- if(H5HL__fl_deserialize(udata->heap) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, NULL, "can't initialize free list")
+ if(FAIL == H5HL__fl_deserialize(udata->heap))
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, NULL, "can't initialize free list");
} /* end if */
/* Set flag to indicate data block from loaded from file */
@@ -723,8 +727,8 @@ H5HL__cache_datablock_deserialize(const void *image, size_t len, void *_udata,
done:
/* Release the [possibly partially initialized] local heap on errors */
if(!ret_value && dblk)
- if(H5HL_dblk_dest(dblk) < 0)
- HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, NULL, "unable to destroy local heap data block")
+ if(FAIL == H5HL__dblk_dest(dblk))
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, NULL, "unable to destroy local heap data block");
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HL__cache_datablock_deserialize() */
@@ -851,10 +855,9 @@ H5HL__cache_datablock_free_icr(void *_thing)
HDassert(dblk->cache_info.type == H5AC_LHEAP_DBLK);
/* Destroy the data block */
- if(H5HL_dblk_dest(dblk) < 0)
+ if(H5HL__dblk_dest(dblk) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy local heap data block")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HL__cache_datablock_free_icr() */
-
diff --git a/src/H5HLdbg.c b/src/H5HLdbg.c
index 3620511..fc8f5d3 100644
--- a/src/H5HLdbg.c
+++ b/src/H5HLdbg.c
@@ -13,55 +13,49 @@
* access to either file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-/* Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu>
+/* Programmer: Quincey Koziol <koziol@hdfgroup.org>
* Wednesday, July 9, 2003
*
- * Purpose: Local Heap object debugging functions.
+ * Purpose: Local Heap object debugging functions.
*/
+/****************/
+/* Module Setup */
+/****************/
+
#include "H5HLmodule.h" /* This source code file is part of the H5HL module */
+/***********/
+/* Headers */
+/***********/
-#include "H5private.h" /* Generic Functions */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5HLpkg.h" /* Local heaps */
-#include "H5Iprivate.h" /* ID Functions */
-#include "H5MMprivate.h" /* Memory management */
+#include "H5private.h" /* Generic Functions */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5HLpkg.h" /* Local heaps */
+#include "H5MMprivate.h" /* Memory management */
/*-------------------------------------------------------------------------
- * Function: H5HL_debug
- *
- * Purpose: Prints debugging information about a heap.
- *
- * Return: Non-negative on success/Negative on failure
+ * Function: H5HL_debug
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 1 1997
+ * Purpose: Prints debugging information about a heap.
*
- * Modifications:
- * Robb Matzke, 1999-07-28
- * The ADDR argument is passed by value.
+ * Return: SUCCEED/FAIL
*
- * John Mainzer, 6/17/05
- * Modified the function to use the new dirtied parameter of
- * of H5AC_unprotect() instead of modifying the is_dirty
- * field of the cache info.
+ * Programmer: Robb Matzke
+ * Aug 1 1997
*
*-------------------------------------------------------------------------
*/
-herr_t
-H5HL_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent, int fwidth)
-{
+BEGIN_FUNC(PRIV, ERR,
+herr_t, SUCCEED, FAIL,
+H5HL_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent, int fwidth))
+
H5HL_t *h = NULL;
int free_block;
H5HL_free_t *freelist;
uint8_t *marker = NULL;
size_t amount_free = 0;
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(FAIL)
/* check arguments */
HDassert(f);
@@ -71,17 +65,17 @@ H5HL_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent, int
HDassert(fwidth >= 0);
if(NULL == (h = (H5HL_t *)H5HL_protect(f, dxpl_id, addr, H5AC__READ_ONLY_FLAG)))
- HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap")
+ H5E_THROW(H5E_CANTPROTECT, "unable to load/protect local heap");
HDfprintf(stream, "%*sLocal Heap...\n", indent, "");
HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth,
"Header size (in bytes):",
(unsigned long)h->prfx_size);
HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth,
- "Address of heap data:",
- h->dblk_addr);
+ "Address of heap data:",
+ h->dblk_addr);
HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth,
- "Data bytes allocated for heap:",
+ "Data bytes allocated for heap:",
h->dblk_size);
/*
@@ -89,7 +83,7 @@ H5HL_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent, int
* the heap and that no two free blocks point to the same region of
* the heap. */
if(NULL == (marker = (uint8_t *)H5MM_calloc(h->dblk_size)))
- HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "memory allocation failed")
+ H5E_THROW(H5E_CANTALLOC, "memory allocation failed");
HDfprintf(stream, "%*sFree Blocks (offset, size):\n", indent, "");
for(free_block = 0, freelist = h->freelist; freelist; freelist = freelist->next, free_block++) {
@@ -127,11 +121,11 @@ H5HL_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent, int
*/
H5_buffer_dump(stream, indent, h->dblk_image, marker, (size_t)0, h->dblk_size);
-done:
- if(h && H5HL_unprotect(h) < 0)
- HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header")
- H5MM_xfree(marker);
+CATCH
+ if(h && FAIL == H5HL_unprotect(h))
+ H5E_THROW(H5E_CANTUNPROTECT, "unable to release/unprotect local heap");
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5HL_debug() */
+ if(marker && NULL != (marker = (uint8_t *)H5MM_xfree(marker)))
+ H5E_THROW(H5E_CANTFREE, "can't free marker buffer");
+END_FUNC(PRIV) /* end H5HL_debug() */
diff --git a/src/H5HLdblk.c b/src/H5HLdblk.c
new file mode 100644
index 0000000..6a4d8ce
--- /dev/null
+++ b/src/H5HLdblk.c
@@ -0,0 +1,282 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * 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 files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*-------------------------------------------------------------------------
+ *
+ * Created: H5HLdblk.c
+ * Summer 2012
+ * Dana Robinson <derobins@hdfgroup.org>
+ *
+ * Purpose: Data block routines for local heaps.
+ *
+ *-------------------------------------------------------------------------
+ */
+
+/****************/
+/* Module Setup */
+/****************/
+
+#include "H5HLmodule.h" /* This source code file is part of the H5HL module */
+
+
+/***********/
+/* Headers */
+/***********/
+#include "H5private.h" /* Generic Functions */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5FLprivate.h" /* Free lists */
+#include "H5HLpkg.h" /* Local Heaps */
+#include "H5MFprivate.h" /* File memory management */
+
+
+/****************/
+/* Local Macros */
+/****************/
+
+
+/******************/
+/* Local Typedefs */
+/******************/
+
+
+/********************/
+/* Package Typedefs */
+/********************/
+
+
+/********************/
+/* Local Prototypes */
+/********************/
+
+
+/*********************/
+/* Package Variables */
+/*********************/
+
+
+/*****************************/
+/* Library Private Variables */
+/*****************************/
+
+
+/*******************/
+/* Local Variables */
+/*******************/
+
+/* Declare a free list to manage the H5HL_dblk_t struct */
+H5FL_DEFINE_STATIC(H5HL_dblk_t);
+
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5HL__dblk_new
+ *
+ * Purpose: Create a new local heap data block object
+ *
+ * Return: Success: non-NULL pointer to new local heap data block
+ * Failure: NULL
+ *
+ * Programmer: Quincey Koziol
+ * Oct 12 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+BEGIN_FUNC(PKG, ERR,
+H5HL_dblk_t *, NULL, NULL,
+H5HL__dblk_new(H5HL_t *heap))
+
+ H5HL_dblk_t *dblk = NULL; /* New local heap data block */
+
+ /* check arguments */
+ HDassert(heap);
+
+ /* Allocate new local heap data block */
+ if(NULL == (dblk = H5FL_CALLOC(H5HL_dblk_t)))
+ H5E_THROW(H5E_CANTALLOC, "memory allocation failed for local heap data block")
+
+ /* Increment ref. count on heap data structure */
+ if(FAIL == H5HL__inc_rc(heap))
+ H5E_THROW(H5E_CANTINC, "can't increment heap ref. count")
+
+ /* Link the heap & the data block */
+ dblk->heap = heap;
+ heap->dblk = dblk;
+
+ /* Set the return value */
+ ret_value = dblk;
+
+CATCH
+ /* Ensure that the data block memory is deallocated on errors */
+ if(!ret_value && dblk != NULL) {
+ /* H5FL_FREE always returns NULL so we can't check for errors */
+ dblk = H5FL_FREE(H5HL_dblk_t, dblk);
+ }
+
+END_FUNC(PKG) /* end H5HL__dblk_new() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5HL__dblk_dest
+ *
+ * Purpose: Destroy a local heap data block object
+ *
+ * Return: SUCCEED/FAIL
+ *
+ * Programmer: Quincey Koziol
+ * Oct 12 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+BEGIN_FUNC(PKG, ERR,
+herr_t, SUCCEED, FAIL,
+H5HL__dblk_dest(H5HL_dblk_t *dblk))
+
+ /* check arguments */
+ HDassert(dblk);
+
+ /* Check if data block was initialized */
+ if(dblk->heap) {
+ /* Unlink data block from heap */
+ dblk->heap->dblk = NULL;
+
+ /* Unpin the local heap prefix */
+ if(FAIL == H5AC_unpin_entry(dblk->heap->prfx))
+ H5E_THROW(H5E_CANTUNPIN, "can't unpin local heap prefix")
+
+ /* Decrement ref. count on heap data structure */
+ if(FAIL == H5HL__dec_rc(dblk->heap))
+ H5E_THROW(H5E_CANTDEC, "can't decrement heap ref. count")
+
+ /* Unlink heap from data block */
+ dblk->heap = NULL;
+ } /* end if */
+
+CATCH
+ /* Free local heap data block */
+ /* H5FL_FREE always returns NULL so we can't check for errors */
+ dblk = H5FL_FREE(H5HL_dblk_t, dblk);
+
+END_FUNC(PKG) /* end H5HL__dblk_dest() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5HL__dblk_realloc
+ *
+ * Purpose: Reallocate data block for heap
+ *
+ * Return: SUCCEED/FAIL
+ *
+ * Programmer: Quincey Koziol
+ * Oct 12 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+BEGIN_FUNC(PKG, ERR,
+herr_t, SUCCEED, FAIL,
+H5HL__dblk_realloc(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t new_heap_size))
+
+ H5HL_dblk_t *dblk; /* Local heap data block */
+ haddr_t old_addr; /* Old location of heap data block */
+ haddr_t new_addr; /* New location of heap data block */
+ size_t old_heap_size; /* Old size of heap data block */
+
+ /* check arguments */
+ HDassert(heap);
+ HDassert(new_heap_size > 0);
+
+ /* Release old space on disk */
+ old_addr = heap->dblk_addr;
+ old_heap_size = heap->dblk_size;
+ H5_CHECK_OVERFLOW(old_heap_size, size_t, hsize_t);
+ if(FAIL == H5MF_xfree(f, H5FD_MEM_LHEAP, dxpl_id, old_addr, (hsize_t)old_heap_size))
+ H5E_THROW(H5E_CANTFREE, "can't free old local heap data");
+
+ /* Allocate new space on disk */
+ H5_CHECK_OVERFLOW(new_heap_size, size_t, hsize_t);
+ if(HADDR_UNDEF == (new_addr = H5MF_alloc(f, H5FD_MEM_LHEAP, dxpl_id, (hsize_t)new_heap_size)))
+ H5E_THROW(H5E_CANTALLOC, "unable to allocate file space for local heap");
+
+ /* Update heap info*/
+ heap->dblk_addr = new_addr;
+ heap->dblk_size = new_heap_size;
+
+ /* Check if heap data block actually moved in the file */
+ if(H5F_addr_eq(old_addr, new_addr)) {
+ /* Check if heap data block is contiguous w/prefix */
+ if(heap->single_cache_obj) {
+ /* Sanity check */
+ HDassert(H5F_addr_eq(heap->prfx_addr + heap->prfx_size, old_addr));
+ HDassert(heap->prfx);
+
+ /* Resize the heap prefix in the cache */
+ if(FAIL == H5AC_resize_entry(heap->prfx, (size_t)(heap->prfx_size + new_heap_size)))
+ H5E_THROW(H5E_CANTRESIZE, "unable to resize heap in cache");
+
+ } /* end if */
+ else {
+ /* Sanity check */
+ HDassert(H5F_addr_ne(heap->prfx_addr + heap->prfx_size, old_addr));
+ HDassert(heap->dblk);
+
+ /* Resize the heap data block in the cache */
+ if(H5AC_resize_entry(heap->dblk, (size_t)new_heap_size) < 0)
+ H5E_THROW(H5E_CANTRESIZE, "unable to resize heap (data block) in cache");
+
+ } /* end else */
+ } /* end if */
+ else {
+ /* Check if heap data block was contiguous w/prefix previously */
+ if(heap->single_cache_obj) {
+ /* Create new heap data block */
+ if(NULL == (dblk = H5HL__dblk_new(heap)))
+ H5E_THROW(H5E_CANTALLOC, "unable to allocate local heap data block");
+
+ /* Resize current heap prefix */
+ heap->prfx_size = H5HL_SIZEOF_HDR(f);
+ if(FAIL == H5AC_resize_entry(heap->prfx, (size_t)heap->prfx_size))
+ H5E_THROW(H5E_CANTRESIZE, "unable to resize heap prefix in cache");
+
+ /* Insert data block into cache (pinned) */
+ if(FAIL == H5AC_insert_entry(f, dxpl_id, H5AC_LHEAP_DBLK, new_addr, dblk, H5AC__PIN_ENTRY_FLAG))
+ H5E_THROW(H5E_CANTINIT, "unable to cache local heap data block");
+
+ dblk = NULL;
+
+ /* Reset 'single cache object' flag */
+ heap->single_cache_obj = FALSE;
+ } /* end if */
+ else {
+ /* Resize the heap data block in the cache */
+ /* (ignore [unlikely] case where heap data block ends up
+ * contiguous w/heap prefix again.
+ */
+ if(FAIL == H5AC_resize_entry(heap->dblk, (size_t)new_heap_size))
+ H5E_THROW(H5E_CANTRESIZE, "unable to resize heap data block in cache");
+
+ /* Relocate the heap data block in the cache */
+ if(FAIL == H5AC_move_entry(f, H5AC_LHEAP_DBLK, old_addr, new_addr))
+ H5E_THROW(H5E_CANTMOVE, "unable to move heap data block in cache");
+
+ } /* end else */
+ } /* end else */
+
+CATCH
+ /* Restore old heap address & size on errors */
+ if(FAIL == ret_value) {
+ heap->dblk_addr = old_addr;
+ heap->dblk_size = old_heap_size;
+ } /* end if */
+
+END_FUNC(PKG) /* end H5HL__dblk_realloc() */
diff --git a/src/H5HLint.c b/src/H5HLint.c
index bbf579d..5b547cf 100644
--- a/src/H5HLint.c
+++ b/src/H5HLint.c
@@ -15,11 +15,11 @@
/*-------------------------------------------------------------------------
*
- * Created: H5HLint.c
- * Oct 12 2008
- * Quincey Koziol <koziol@hdfgroup.org>
+ * Created: H5HLint.c
+ * Oct 12 2008
+ * Quincey Koziol <koziol@hdfgroup.org>
*
- * Purpose: Local heap internal routines.
+ * Purpose: Local heap internal routines.
*
*-------------------------------------------------------------------------
*/
@@ -34,9 +34,10 @@
/***********/
/* Headers */
/***********/
-#include "H5private.h" /* Generic Functions */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5HLpkg.h" /* Local Heaps */
+#include "H5private.h" /* Generic Functions */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5FLprivate.h" /* Free lists */
+#include "H5HLpkg.h" /* Local Heaps */
/****************/
@@ -76,35 +77,26 @@
/* Declare a free list to manage the H5HL_t struct */
H5FL_DEFINE_STATIC(H5HL_t);
-/* Declare a free list to manage the H5HL_dblk_t struct */
-H5FL_DEFINE_STATIC(H5HL_dblk_t);
-
-/* Declare a free list to manage the H5HL_prfx_t struct */
-H5FL_DEFINE_STATIC(H5HL_prfx_t);
-
/*-------------------------------------------------------------------------
- * Function: H5HL_new
+ * Function: H5HL__new
*
- * Purpose: Create a new local heap object
+ * Purpose: Create a new local heap object
*
- * Return: Success: non-NULL pointer to new local heap
- * Failure: NULL
+ * Return: Success: non-NULL pointer to new local heap
+ * Failure: NULL
*
- * Programmer: Quincey Koziol
- * koziol@hdfgroup.org
- * Jan 5 2010
+ * Programmer: Quincey Koziol
+ * Jan 5 2010
*
*-------------------------------------------------------------------------
*/
-H5HL_t *
-H5HL_new(size_t sizeof_size, size_t sizeof_addr, size_t prfx_size)
-{
- H5HL_t *heap = NULL; /* New local heap */
- H5HL_t *ret_value = NULL; /* Return value */
+BEGIN_FUNC(PKG, ERR,
+H5HL_t *, NULL, NULL,
+H5HL__new(size_t sizeof_size, size_t sizeof_addr, size_t prfx_size))
- FUNC_ENTER_NOAPI(NULL)
+ H5HL_t *heap = NULL; /* New local heap */
/* check arguments */
HDassert(sizeof_size > 0);
@@ -113,7 +105,7 @@ H5HL_new(size_t sizeof_size, size_t sizeof_addr, size_t prfx_size)
/* Allocate new local heap structure */
if(NULL == (heap = H5FL_CALLOC(H5HL_t)))
- HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "memory allocation failed")
+ H5E_THROW(H5E_CANTALLOC, "memory allocation failed");
/* Initialize non-zero fields */
heap->sizeof_size = sizeof_size;
@@ -123,29 +115,29 @@ H5HL_new(size_t sizeof_size, size_t sizeof_addr, size_t prfx_size)
/* Set the return value */
ret_value = heap;
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5HL_new() */
+CATCH
+ if(!ret_value && heap != NULL)
+ if (NULL == (heap = H5FL_FREE(H5HL_t, heap)))
+ H5E_THROW(H5E_CANTFREE, "can't free heap memory");
+
+END_FUNC(PKG) /* end H5HL__new() */
/*-------------------------------------------------------------------------
* Function: H5HL__inc_rc
*
- * Purpose: Increment ref. count on heap
+ * Purpose: Increment ref. count on heap
*
- * Return: Success: Non-negative
- * Failure: Negative
+ * Return: SUCCEED (Can't fail)
*
- * Programmer: Quincey Koziol
- * koziol@hdfgroup.org
- * Oct 12 2008
+ * Programmer: Quincey Koziol
+ * Oct 12 2008
*
*-------------------------------------------------------------------------
*/
-static herr_t
-H5HL__inc_rc(H5HL_t *heap)
-{
- FUNC_ENTER_STATIC_NOERR
+BEGIN_FUNC(PKG, NOERR,
+herr_t, SUCCEED, -,
+H5HL__inc_rc(H5HL_t *heap))
/* check arguments */
HDassert(heap);
@@ -153,28 +145,24 @@ H5HL__inc_rc(H5HL_t *heap)
/* Increment heap's ref. count */
heap->rc++;
- FUNC_LEAVE_NOAPI(SUCCEED)
-} /* end H5HL__inc_rc() */
+END_FUNC(PKG) /* end H5HL__inc_rc() */
/*-------------------------------------------------------------------------
* Function: H5HL__dec_rc
*
- * Purpose: Decrement ref. count on heap
+ * Purpose: Decrement ref. count on heap
*
- * Return: Success: Non-negative
- * Failure: Negative
+ * Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
- * koziol@hdfgroup.org
- * Oct 12 2008
+ * Programmer: Quincey Koziol
+ * Oct 12 2008
*
*-------------------------------------------------------------------------
*/
-static herr_t
-H5HL__dec_rc(H5HL_t *heap)
-{
- FUNC_ENTER_STATIC_NOERR
+BEGIN_FUNC(PKG, ERR,
+herr_t, SUCCEED, FAIL,
+H5HL__dec_rc(H5HL_t *heap))
/* check arguments */
HDassert(heap);
@@ -182,31 +170,29 @@ H5HL__dec_rc(H5HL_t *heap)
/* Decrement heap's ref. count */
heap->rc--;
+CATCH
/* Check if we should destroy the heap */
- if(heap->rc == 0)
- H5HL_dest(heap);
+ if(heap->rc == 0 && FAIL == H5HL__dest(heap))
+ H5E_THROW(H5E_CANTFREE, "unable to destroy local heap");
- FUNC_LEAVE_NOAPI(SUCCEED)
-} /* end H5HL__dec_rc() */
+END_FUNC(PKG) /* end H5HL__dec_rc() */
/*-------------------------------------------------------------------------
- * Function: H5HL_dest
+ * Function: H5HL__dest
*
- * Purpose: Destroys a heap in memory.
+ * Purpose: Destroys a heap in memory.
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
- * koziol@ncsa.uiuc.edu
- * Jan 15 2003
+ * Programmer: Quincey Koziol
+ * Jan 15 2003
*
*-------------------------------------------------------------------------
*/
-herr_t
-H5HL_dest(H5HL_t *heap)
-{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+BEGIN_FUNC(PKG, ERR,
+herr_t, SUCCEED, FAIL,
+H5HL__dest(H5HL_t *heap))
/* check arguments */
HDassert(heap);
@@ -217,201 +203,20 @@ H5HL_dest(H5HL_t *heap)
HDassert(heap->prfx == NULL);
HDassert(heap->dblk == NULL);
+CATCH
if(heap->dblk_image)
- heap->dblk_image = H5FL_BLK_FREE(lheap_chunk, heap->dblk_image);
+ if(NULL != (heap->dblk_image = H5FL_BLK_FREE(lheap_chunk, heap->dblk_image)))
+ H5E_THROW(H5E_CANTFREE, "unable to free local heap data block image");
while(heap->freelist) {
H5HL_free_t *fl;
fl = heap->freelist;
heap->freelist = fl->next;
- fl = H5FL_FREE(H5HL_free_t, fl);
+ if(NULL != (fl = H5FL_FREE(H5HL_free_t, fl)))
+ H5E_THROW(H5E_CANTFREE, "unable to free local heap free list");
} /* end while */
- heap = H5FL_FREE(H5HL_t, heap);
-
- FUNC_LEAVE_NOAPI(SUCCEED)
-} /* end H5HL_dest() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5HL_prfx_new
- *
- * Purpose: Create a new local heap prefix object
- *
- * Return: Success: non-NULL pointer to new local heap prefix
- * Failure: NULL
- *
- * Programmer: Quincey Koziol
- * koziol@hdfgroup.org
- * Oct 12 2008
- *
- *-------------------------------------------------------------------------
- */
-H5HL_prfx_t *
-H5HL_prfx_new(H5HL_t *heap)
-{
- H5HL_prfx_t *prfx = NULL; /* New local heap prefix */
- H5HL_prfx_t *ret_value = NULL; /* Return value */
-
- FUNC_ENTER_NOAPI(NULL)
-
- /* check arguments */
- HDassert(heap);
-
- /* Allocate new local heap prefix */
- if(NULL == (prfx = H5FL_CALLOC(H5HL_prfx_t)))
- HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "memory allocation failed")
-
- /* Increment ref. count on heap data structure */
- if(H5HL__inc_rc(heap) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment heap ref. count")
-
- /* Link the heap & the prefix */
- prfx->heap = heap;
- heap->prfx = prfx;
-
- /* Set the return value */
- ret_value = prfx;
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5HL_prfx_new() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5HL_prfx_dest
- *
- * Purpose: Destroy a local heap prefix object
- *
- * Return: Success: Non-negative
- * Failure: Negative
- *
- * Programmer: Quincey Koziol
- * koziol@hdfgroup.org
- * Oct 12 2008
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5HL_prfx_dest(H5HL_prfx_t *prfx)
-{
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(FAIL)
-
- /* check arguments */
- HDassert(prfx);
-
- /* Check if prefix was initialized */
- if(prfx->heap) {
- /* Unlink prefix from heap */
- prfx->heap->prfx = NULL;
-
- /* Decrement ref. count on heap data structure */
- if(H5HL__dec_rc(prfx->heap) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement heap ref. count")
-
- /* Unlink heap from prefix */
- prfx->heap = NULL;
- } /* end if */
-
- /* Free local heap prefix */
- prfx = H5FL_FREE(H5HL_prfx_t, prfx);
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5HL_prfx_dest() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5HL_dblk_new
- *
- * Purpose: Create a new local heap data block object
- *
- * Return: Success: non-NULL pointer to new local heap data block
- * Failure: NULL
- *
- * Programmer: Quincey Koziol
- * koziol@hdfgroup.org
- * Oct 12 2008
- *
- *-------------------------------------------------------------------------
- */
-H5HL_dblk_t *
-H5HL_dblk_new(H5HL_t *heap)
-{
- H5HL_dblk_t *dblk = NULL; /* New local heap data block */
- H5HL_dblk_t *ret_value = NULL; /* Return value */
-
- FUNC_ENTER_NOAPI(NULL)
-
- /* check arguments */
- HDassert(heap);
-
- /* Allocate new local heap data block */
- if(NULL == (dblk = H5FL_CALLOC(H5HL_dblk_t)))
- HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "memory allocation failed")
-
- /* Increment ref. count on heap data structure */
- if(H5HL__inc_rc(heap) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment heap ref. count")
-
- /* Link the heap & the data block */
- dblk->heap = heap;
- heap->dblk = dblk;
-
- /* Set the return value */
- ret_value = dblk;
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5HL_dblk_new() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5HL_dblk_dest
- *
- * Purpose: Destroy a local heap data block object
- *
- * Return: Success: Non-negative
- * Failure: Negative
- *
- * Programmer: Quincey Koziol
- * koziol@hdfgroup.org
- * Oct 12 2008
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5HL_dblk_dest(H5HL_dblk_t *dblk)
-{
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(FAIL)
-
- /* check arguments */
- HDassert(dblk);
-
- /* Check if data block was initialized */
- if(dblk->heap) {
- /* Unlink data block from heap */
- dblk->heap->dblk = NULL;
-
- /* Unpin the local heap prefix */
- if(H5AC_unpin_entry(dblk->heap->prfx) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPIN, FAIL, "can't unpin local heap prefix")
-
- /* Decrement ref. count on heap data structure */
- if(H5HL__dec_rc(dblk->heap) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement heap ref. count")
-
- /* Unlink heap from data block */
- dblk->heap = NULL;
- } /* end if */
-
- /* Free local heap data block */
- dblk = H5FL_FREE(H5HL_dblk_t, dblk);
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5HL_dblk_dest() */
+
+ if(NULL != (heap = H5FL_FREE(H5HL_t, heap)))
+ H5E_THROW(H5E_CANTFREE, "unable to free local heap");
+END_FUNC(PKG) /* end H5HL__dest() */
diff --git a/src/H5HLpkg.h b/src/H5HLpkg.h
index 6e35add..fb8667b 100644
--- a/src/H5HLpkg.h
+++ b/src/H5HLpkg.h
@@ -14,7 +14,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
- * Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu>
+ * Programmer: Quincey Koziol <koziol@hdfgroup.org>
* Wednesday, July 9, 2003
*
* Purpose: This file contains declarations which are visible
@@ -32,7 +32,7 @@
#include "H5HLprivate.h"
/* Other private headers needed by this file */
-#include "H5FLprivate.h" /* Free lists */
+#include "H5FLprivate.h" /* Free lists */
/*****************************/
@@ -56,16 +56,26 @@ H5FL_BLK_EXTERN(lheap_chunk);
/* Package Private Macros */
/**************************/
-#define H5HL_SIZEOF_HDR(F) \
- H5HL_ALIGN(H5_SIZEOF_MAGIC + /*heap signature */ \
- 1 + /*version */ \
- 3 + /*reserved */ \
- H5F_SIZEOF_SIZE(F) + /*data size */ \
- H5F_SIZEOF_SIZE(F) + /*free list head */ \
- H5F_SIZEOF_ADDR(F)) /*data address */
+/* If this package header is being included in one of the H5HL source files,
+ * define the proper control macros for the generic FUNC_ENTER/LEAVE and
+ * error reporting macros.
+ */
+#ifdef H5HL_PACKAGE
+#define H5_MY_PKG H5HL
+#define H5_MY_PKG_ERR H5E_HEAP
+#define H5_MY_PKG_INIT NO
+#endif /* H5HL_PACKAGE */
+
+#define H5HL_SIZEOF_HDR(F) \
+ H5HL_ALIGN(H5_SIZEOF_MAGIC + /* heap signature */ \
+ 1 + /* version */ \
+ 3 + /* reserved */ \
+ H5F_SIZEOF_SIZE(F) + /* data size */ \
+ H5F_SIZEOF_SIZE(F) + /* free list head */ \
+ H5F_SIZEOF_ADDR(F)) /* data address */
/* Value indicating end of free list on disk */
-#define H5HL_FREE_NULL 1
+#define H5HL_FREE_NULL 1
/****************************/
@@ -73,10 +83,10 @@ H5FL_BLK_EXTERN(lheap_chunk);
/****************************/
typedef struct H5HL_free_t {
- size_t offset; /*offset of free block */
- size_t size; /*size of free block */
- struct H5HL_free_t *prev; /*previous entry in free list */
- struct H5HL_free_t *next; /*next entry in free list */
+ size_t offset; /* offset of free block */
+ size_t size; /* size of free block */
+ struct H5HL_free_t *prev; /* previous entry in free list */
+ struct H5HL_free_t *next; /* next entry in free list */
} H5HL_free_t;
/* Forward declarations */
@@ -85,38 +95,38 @@ typedef struct H5HL_prfx_t H5HL_prfx_t;
struct H5HL_t {
/* General heap-management fields */
- size_t rc; /* Ref. count for prefix & data block using this struct */
- size_t prots; /* # of times the heap has been protected */
- size_t sizeof_size; /* Size of file sizes */
- size_t sizeof_addr; /* Size of file addresses */
- hbool_t single_cache_obj; /* Indicate if the heap is a single object in the cache */
- H5HL_free_t *freelist; /*the free list */
+ size_t rc; /* Ref. count for prefix & data block using this struct */
+ size_t prots; /* # of times the heap has been protected */
+ size_t sizeof_size; /* Size of file sizes */
+ size_t sizeof_addr; /* Size of file addresses */
+ hbool_t single_cache_obj; /* Indicate if the heap is a single object in the cache */
+ H5HL_free_t *freelist; /* the free list */
/* Prefix-specific fields */
- H5HL_prfx_t *prfx; /* The prefix object for the heap */
- haddr_t prfx_addr; /* address of heap prefix */
- size_t prfx_size; /* size of heap prefix */
- hsize_t free_block; /* Address of first free block */
+ H5HL_prfx_t *prfx; /* The prefix object for the heap */
+ haddr_t prfx_addr; /* address of heap prefix */
+ size_t prfx_size; /* size of heap prefix */
+ hsize_t free_block; /* Address of first free block */
/* Data block-specific fields */
- H5HL_dblk_t *dblk; /* The data block object for the heap */
- haddr_t dblk_addr; /* address of data block */
- size_t dblk_size; /* size of heap data block on disk and in mem */
- uint8_t *dblk_image; /* The data block image */
+ H5HL_dblk_t *dblk; /* The data block object for the heap */
+ haddr_t dblk_addr; /* address of data block */
+ size_t dblk_size; /* size of heap data block on disk and in mem */
+ uint8_t *dblk_image; /* The data block image */
};
/* Struct for heap data block */
struct H5HL_dblk_t {
- H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */
- /* first field in structure */
- H5HL_t *heap; /* Pointer to heap for data block */
+ H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */
+ /* first field in structure */
+ H5HL_t *heap; /* Pointer to heap for data block */
};
/* Struct for heap prefix */
struct H5HL_prfx_t {
- H5AC_info_t cache_info; /* Information for H5AC cache functions, */
- /* _must_ be first field in structure */
- H5HL_t *heap; /* Pointer to heap for prefix */
+ H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */
+ /* first field in structure */
+ H5HL_t *heap; /* Pointer to heap for prefix */
};
/* Callback information for loading local heap prefix from disk */
@@ -137,10 +147,10 @@ typedef struct H5HL_cache_prfx_ud_t {
/* Callback information for loading local heap data block from disk */
typedef struct H5HL_cache_dblk_ud_t {
/* Downwards */
- H5HL_t *heap; /* Local heap */
+ H5HL_t *heap; /* Local heap */
/* Upwards */
- hbool_t loaded; /* Whether data block was loaded from file */
+ hbool_t loaded; /* Whether data block was loaded from file */
} H5HL_cache_dblk_ud_t;
@@ -149,16 +159,18 @@ typedef struct H5HL_cache_dblk_ud_t {
/******************************/
/* Heap routines */
-H5_DLL H5HL_t *H5HL_new(size_t sizeof_size, size_t sizeof_addr, size_t prfx_size);
-H5_DLL herr_t H5HL_dest(H5HL_t *heap);
+H5_DLL H5HL_t *H5HL__new(size_t sizeof_size, size_t sizeof_addr, size_t prfx_size);
+H5_DLL herr_t H5HL__dest(H5HL_t *heap);
+H5_DLL herr_t H5HL__inc_rc(H5HL_t *heap);
+H5_DLL herr_t H5HL__dec_rc(H5HL_t *heap);
/* Heap prefix routines */
-H5_DLL H5HL_prfx_t *H5HL_prfx_new(H5HL_t *heap);
-H5_DLL herr_t H5HL_prfx_dest(H5HL_prfx_t *prfx);
+H5_DLL H5HL_prfx_t *H5HL__prfx_new(H5HL_t *heap);
+H5_DLL herr_t H5HL__prfx_dest(H5HL_prfx_t *prfx);
/* Heap data block routines */
-H5_DLL H5HL_dblk_t *H5HL_dblk_new(H5HL_t *heap);
-H5_DLL herr_t H5HL_dblk_dest(H5HL_dblk_t *dblk);
+H5_DLL H5HL_dblk_t *H5HL__dblk_new(H5HL_t *heap);
+H5_DLL herr_t H5HL__dblk_dest(H5HL_dblk_t *dblk);
+H5_DLL herr_t H5HL__dblk_realloc(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t new_heap_size);
#endif /* _H5HLpkg_H */
-
diff --git a/src/H5HLprfx.c b/src/H5HLprfx.c
new file mode 100644
index 0000000..66c4dad
--- /dev/null
+++ b/src/H5HLprfx.c
@@ -0,0 +1,166 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * 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 files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*-------------------------------------------------------------------------
+ *
+ * Created: H5HLprfx.c
+ * Summer 2012
+ * Dana Robinson <derobins@hdfgroup.org>
+ *
+ * Purpose: Prefix routines for local heaps.
+ *
+ *-------------------------------------------------------------------------
+ */
+
+/****************/
+/* Module Setup */
+/****************/
+
+#include "H5HLmodule.h" /* This source code file is part of the H5HL module */
+
+
+/***********/
+/* Headers */
+/***********/
+#include "H5private.h" /* Generic Functions */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5FLprivate.h" /* Free lists */
+#include "H5HLpkg.h" /* Local Heaps */
+
+
+/****************/
+/* Local Macros */
+/****************/
+
+
+/******************/
+/* Local Typedefs */
+/******************/
+
+
+/********************/
+/* Package Typedefs */
+/********************/
+
+
+/********************/
+/* Local Prototypes */
+/********************/
+
+
+/*********************/
+/* Package Variables */
+/*********************/
+
+
+/*****************************/
+/* Library Private Variables */
+/*****************************/
+
+
+/*******************/
+/* Local Variables */
+/*******************/
+
+/* Declare a free list to manage the H5HL_prfx_t struct */
+H5FL_DEFINE_STATIC(H5HL_prfx_t);
+
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5HL__prfx_new
+ *
+ * Purpose: Create a new local heap prefix object
+ *
+ * Return: Success: non-NULL pointer to new local heap prefix
+ * Failure: NULL
+ *
+ * Programmer: Quincey Koziol
+ * Oct 12 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+BEGIN_FUNC(PKG, ERR,
+H5HL_prfx_t *, NULL, NULL,
+H5HL__prfx_new(H5HL_t *heap))
+
+ H5HL_prfx_t *prfx = NULL; /* New local heap prefix */
+
+ /* check arguments */
+ HDassert(heap);
+
+ /* Allocate new local heap prefix */
+ if(NULL == (prfx = H5FL_CALLOC(H5HL_prfx_t)))
+ H5E_THROW(H5E_CANTALLOC, "memory allocation failed for local heap prefix")
+
+ /* Increment ref. count on heap data structure */
+ if(FAIL == H5HL__inc_rc(heap))
+ H5E_THROW(H5E_CANTINC, "can't increment heap ref. count")
+
+ /* Link the heap & the prefix */
+ prfx->heap = heap;
+ heap->prfx = prfx;
+
+ /* Set the return value */
+ ret_value = prfx;
+
+CATCH
+ /* Ensure that the prefix memory is deallocated on errors */
+ if(!ret_value && prfx != NULL) {
+ /* H5FL_FREE always returns NULL so we can't check for errors */
+ prfx = H5FL_FREE(H5HL_prfx_t, prfx);
+ }
+
+END_FUNC(PKG) /* end H5HL__prfx_new() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5HL__prfx_dest
+ *
+ * Purpose: Destroy a local heap prefix object
+ *
+ * Return: SUCCEED/FAIL
+ *
+ * Programmer: Quincey Koziol
+ * Oct 12 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+BEGIN_FUNC(PKG, ERR,
+herr_t, SUCCEED, FAIL,
+H5HL__prfx_dest(H5HL_prfx_t *prfx))
+
+ /* check arguments */
+ HDassert(prfx);
+
+ /* Check if prefix was initialized */
+ if(prfx->heap) {
+ /* Unlink prefix from heap */
+ prfx->heap->prfx = NULL;
+
+ /* Decrement ref. count on heap data structure */
+ if(FAIL == H5HL__dec_rc(prfx->heap))
+ H5E_THROW(H5E_CANTDEC, "can't decrement heap ref. count")
+
+ /* Unlink heap from prefix */
+ prfx->heap = NULL;
+ } /* end if */
+
+CATCH
+ /* Free prefix memory */
+ /* H5FL_FREE always returns NULL so we can't check for errors */
+ prfx = H5FL_FREE(H5HL_prfx_t, prfx);
+
+END_FUNC(PKG) /* end H5HL__prfx_dest() */
diff --git a/src/H5HLprivate.h b/src/H5HLprivate.h
index 3035689..e2bf29c 100644
--- a/src/H5HLprivate.h
+++ b/src/H5HLprivate.h
@@ -15,13 +15,11 @@
/*-------------------------------------------------------------------------
*
- * Created: H5HLprivate.h
- * Jul 16 1997
- * Robb Matzke <matzke@llnl.gov>
+ * Created: H5HLprivate.h
+ * Jul 16 1997
+ * Robb Matzke <matzke@llnl.gov>
*
- * Purpose:
- *
- * Modifications:
+ * Purpose: Private declarations for the H5HL (local heap) package.
*
*-------------------------------------------------------------------------
*/
@@ -32,23 +30,23 @@
#include "H5HLpublic.h"
/* Private headers needed by this file. */
-#include "H5private.h" /* Generic Functions */
-#include "H5ACprivate.h" /* Metadata cache */
-#include "H5Fprivate.h" /* File access */
+#include "H5private.h" /* Generic Functions */
+#include "H5ACprivate.h" /* Metadata cache */
+#include "H5Fprivate.h" /* File access */
/*
* Feature: Define H5HL_DEBUG on the compiler command line if you want to
- * diagnostic messages from this layer.
+ * enable diagnostic messages from this layer.
*/
#ifdef NDEBUG
# undef H5HL_DEBUG
#endif
-#define H5HL_ALIGN(X) ((((unsigned)X)+7)&(unsigned)(~0x07)) /*align on 8-byte boundary */
+#define H5HL_ALIGN(X) ((((unsigned)X)+7)&(unsigned)(~0x07)) /* align on 8-byte boundary */
-#define H5HL_SIZEOF_FREE(F) \
- H5HL_ALIGN(H5F_SIZEOF_SIZE (F) + /*ptr to next free block */ \
- H5F_SIZEOF_SIZE (F)) /*size of this free block */
+#define H5HL_SIZEOF_FREE(F) \
+ H5HL_ALIGN(H5F_SIZEOF_SIZE (F) + /* ptr to next free block */ \
+ H5F_SIZEOF_SIZE (F)) /* size of this free block */
/****************************/
/* Library Private Typedefs */
@@ -58,22 +56,23 @@
typedef struct H5HL_t H5HL_t;
/*
- * Library prototypes...
+ * Library prototypes
*/
H5_DLL herr_t H5HL_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, haddr_t *addr/*out*/);
-H5_DLL H5HL_t *H5HL_protect(H5F_t *f, hid_t dxpl_id, haddr_t addr, unsigned flags);
+H5_DLL herr_t H5HL_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr);
+H5_DLL herr_t H5HL_get_size(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t *size);
+H5_DLL herr_t H5HL_heapsize(H5F_t *f, hid_t dxpl_id, haddr_t addr, hsize_t *heap_size);
+H5_DLL size_t H5HL_insert(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t size,
+ const void *buf);
H5_DLL void *H5HL_offset_into(const H5HL_t *heap, size_t offset);
+H5_DLL H5HL_t *H5HL_protect(H5F_t *f, hid_t dxpl_id, haddr_t addr, unsigned flags);
H5_DLL herr_t H5HL_remove(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t offset,
size_t size);
H5_DLL herr_t H5HL_unprotect(H5HL_t *heap);
-H5_DLL size_t H5HL_insert(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t size,
- const void *buf);
-H5_DLL herr_t H5HL_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr);
-H5_DLL herr_t H5HL_get_size(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t *size);
-H5_DLL herr_t H5HL_heapsize(H5F_t *f, hid_t dxpl_id, haddr_t addr, hsize_t *heap_size);
-/* Debugging functions */
+/* Debugging routines for dumping file structures */
H5_DLL herr_t H5HL_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent,
- int fwidth);
+ int fwidth);
+
#endif
diff --git a/src/H5HLpublic.h b/src/H5HLpublic.h
index db00f51..6dc1828 100644
--- a/src/H5HLpublic.h
+++ b/src/H5HLpublic.h
@@ -21,8 +21,6 @@
*
* Purpose: Public declarations for the H5HL (local heap) package.
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
#ifndef _H5HLpublic_H
diff --git a/src/H5MM.c b/src/H5MM.c
index 534526f..a37bbff 100644
--- a/src/H5MM.c
+++ b/src/H5MM.c
@@ -15,13 +15,11 @@
/*-------------------------------------------------------------------------
*
- * Created: H5MM.c
- * Jul 10 1997
- * Robb Matzke <matzke@llnl.gov>
- *
- * Purpose: Memory management functions.
+ * Created: H5MM.c
+ * Jul 10 1997
+ * Robb Matzke <matzke@llnl.gov>
*
- * Modifications:
+ * Purpose: Memory management functions
*
*-------------------------------------------------------------------------
*/
@@ -168,7 +166,6 @@ H5MM_realloc(void *mem, size_t size)
* NULL is an acceptable value for the input string.
*
* Return: Success: Pointer to a new string (NULL if s is NULL).
- *
* Failure: abort()
*
* Programmer: Robb Matzke
@@ -179,7 +176,7 @@ H5MM_realloc(void *mem, size_t size)
char *
H5MM_xstrdup(const char *s)
{
- char *ret_value = NULL;
+ char *ret_value = NULL;
FUNC_ENTER_NOAPI(NULL)
@@ -204,7 +201,6 @@ done:
* an error will be raised.
*
* Return: Success: Pointer to a new string
- *
* Failure: abort()
*
* Programmer: Robb Matzke
@@ -231,21 +227,20 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5MM_xfree
+ * Function: H5MM_xfree
*
- * Purpose: Just like free(3) except null pointers are allowed as
- * arguments, and the return value (always NULL) can be
- * assigned to the pointer whose memory was just freed:
+ * Purpose: Just like free(3) except null pointers are allowed as
+ * arguments, and the return value (always NULL) can be
+ * assigned to the pointer whose memory was just freed:
*
- * thing = H5MM_xfree (thing);
+ * thing = H5MM_xfree (thing);
*
- * Return: Success: NULL
+ * Return: Success: NULL
+ * Failure: never fails
*
- * Failure: never fails
- *
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jul 10 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jul 10 1997
*
*-------------------------------------------------------------------------
*/
diff --git a/src/H5O.c b/src/H5O.c
index c0134d0..26204e5 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -2879,7 +2879,7 @@ H5O_get_info(const H5O_loc_t *loc, hid_t dxpl_id, hbool_t want_ih_info,
/* Check for 'bh_info' callback for this type of object */
if(obj_class->bh_info) {
/* Call the object's class 'bh_info' routine */
- if((obj_class->bh_info)(loc->file, dxpl_id, oh, &oinfo->meta_size.obj) < 0)
+ if((obj_class->bh_info)(loc, dxpl_id, oh, &oinfo->meta_size.obj) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object's btree & heap info")
} /* end if */
diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c
index e641d70..02c72e7 100644
--- a/src/H5Ocopy.c
+++ b/src/H5Ocopy.c
@@ -337,7 +337,7 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/,
size_t null_msgs; /* Number of NULL messages found in each loop */
size_t orig_dst_msgs; /* Original # of messages in dest. object */
H5O_mesg_t *mesg_src; /* Message in source object header */
- H5O_mesg_t *mesg_dst; /* Message in source object header */
+ H5O_mesg_t *mesg_dst; /* Message in destination object header */
const H5O_msg_class_t *copy_type; /* Type of message to use for copying */
const H5O_obj_class_t *obj_class = NULL; /* Type of object we are copying */
void *cpy_udata = NULL; /* User data for passing to message callbacks */
@@ -357,12 +357,11 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/,
HDassert(cpy_info);
/* Get pointer to object class for this object */
- if((obj_class = H5O_obj_class(oloc_src, dxpl_id)) == NULL)
+ if(NULL == (obj_class = H5O_obj_class(oloc_src, dxpl_id)))
HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to determine object type")
/* Check if the object at the address is already open in the file */
if(H5FO_opened(oloc_src->file, oloc_src->addr) != NULL) {
-
H5G_loc_t tmp_loc; /* Location of object */
H5O_loc_t tmp_oloc; /* Location of object */
H5G_name_t tmp_path; /* Object's path */
@@ -377,15 +376,14 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/,
/* Flush the object of this class */
if(obj_class->flush && obj_class->flush(&tmp_loc, dxpl_id) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to flush object")
- }
+ } /* end if */
/* Get source object header */
if(NULL == (oh_src = H5O_protect(oloc_src, dxpl_id, H5AC__READ_ONLY_FLAG)))
HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header")
/* Retrieve user data for particular type of object to copy */
- if(obj_class->get_copy_file_udata &&
- (NULL == (cpy_udata = (obj_class->get_copy_file_udata)())))
+ if(obj_class->get_copy_file_udata && (NULL == (cpy_udata = (obj_class->get_copy_file_udata)())))
HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to retrieve copy user data")
/* If we are merging committed datatypes, check for a match in the destination
@@ -468,7 +466,7 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/,
oh_dst->alloc_nchunks = oh_dst->nchunks = 0;
/* Allocate memory for the chunk array - always start with 1 chunk */
- if(NULL == (oh_dst->chunk = H5FL_SEQ_MALLOC(H5O_chunk_t, 1)))
+ if(NULL == (oh_dst->chunk = H5FL_SEQ_MALLOC(H5O_chunk_t, (size_t)1)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
/* Update number of allocated chunks. There are still no chunks used. */
diff --git a/src/H5Odtype.c b/src/H5Odtype.c
index cee6e1e..e51d319 100644
--- a/src/H5Odtype.c
+++ b/src/H5Odtype.c
@@ -263,7 +263,7 @@ H5O_dtype_decode_helper(H5F_t *f, unsigned *ioflags/*in,out*/, const uint8_t **p
unsigned offset_nbytes; /* Size needed to encode member offsets */
size_t max_memb_pos = 0; /* Maximum member covered, so far */
unsigned max_version = 0; /* Maximum member version */
- hbool_t upgrade_to = 0; /* Version number we can "soft" upgrade to */
+ unsigned upgrade_to = 0; /* Version number we can "soft" upgrade to */
unsigned j;
/* Compute the # of bytes required to store a member offset */
diff --git a/src/H5Oefl.c b/src/H5Oefl.c
index 25ab753..149c8b2 100644
--- a/src/H5Oefl.c
+++ b/src/H5Oefl.c
@@ -476,7 +476,7 @@ H5O_efl_copy_file(H5F_t H5_ATTR_UNUSED *file_src, void *mesg_src, H5F_t *file_ds
HGOTO_ERROR(H5E_EFL, H5E_PROTECT, NULL, "unable to protect EFL file name heap")
/* Insert "empty" name first */
- if((size_t)(-1) == (name_offset = H5HL_insert(file_dst, dxpl_id, heap, (size_t)1, "")))
+ if(UFAIL == (name_offset = H5HL_insert(file_dst, dxpl_id, heap, (size_t)1, "")))
HGOTO_ERROR(H5E_EFL, H5E_CANTINSERT, NULL, "can't insert file name into heap")
HDassert(0 == name_offset);
@@ -493,7 +493,7 @@ H5O_efl_copy_file(H5F_t H5_ATTR_UNUSED *file_src, void *mesg_src, H5F_t *file_ds
/* copy the name from the source */
for(idx = 0; idx < efl_src->nused; idx++) {
efl_dst->slot[idx].name = H5MM_xstrdup(efl_src->slot[idx].name);
- if((size_t)(-1) == (efl_dst->slot[idx].name_offset = H5HL_insert(file_dst, dxpl_id, heap,
+ if(UFAIL == (efl_dst->slot[idx].name_offset = H5HL_insert(file_dst, dxpl_id, heap,
HDstrlen(efl_dst->slot[idx].name) + 1, efl_dst->slot[idx].name)))
HGOTO_ERROR(H5E_EFL, H5E_CANTINSERT, NULL, "can't insert file name into heap")
} /* end for */
diff --git a/src/H5Olayout.c b/src/H5Olayout.c
index daffe48..0c13498 100644
--- a/src/H5Olayout.c
+++ b/src/H5Olayout.c
@@ -40,19 +40,19 @@
/* PRIVATE PROTOTYPES */
-static void *H5O_layout_decode(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh,
+static void *H5O__layout_decode(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh,
unsigned mesg_flags, unsigned *ioflags, const uint8_t *p);
-static herr_t H5O_layout_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg);
-static void *H5O_layout_copy(const void *_mesg, void *_dest);
-static size_t H5O_layout_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg);
-static herr_t H5O_layout_reset(void *_mesg);
-static herr_t H5O_layout_free(void *_mesg);
-static herr_t H5O_layout_delete(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh,
+static herr_t H5O__layout_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg);
+static void *H5O__layout_copy(const void *_mesg, void *_dest);
+static size_t H5O__layout_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg);
+static herr_t H5O__layout_reset(void *_mesg);
+static herr_t H5O__layout_free(void *_mesg);
+static herr_t H5O__layout_delete(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh,
void *_mesg);
-static void *H5O_layout_copy_file(H5F_t *file_src, void *mesg_src,
+static void *H5O__layout_copy_file(H5F_t *file_src, void *mesg_src,
H5F_t *file_dst, hbool_t *recompute_size, unsigned *mesg_flags,
H5O_copy_t *cpy_info, void *udata, hid_t dxpl_id);
-static herr_t H5O_layout_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE * stream,
+static herr_t H5O__layout_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE * stream,
int indent, int fwidth);
/* This message derives from H5O message class */
@@ -61,22 +61,22 @@ const H5O_msg_class_t H5O_MSG_LAYOUT[1] = {{
"layout", /*message name for debugging */
sizeof(H5O_layout_t), /*native message size */
0, /* messages are sharable? */
- H5O_layout_decode, /*decode message */
- H5O_layout_encode, /*encode message */
- H5O_layout_copy, /*copy the native value */
- H5O_layout_size, /*size of message on disk */
- H5O_layout_reset, /*reset method */
- H5O_layout_free, /*free the struct */
- H5O_layout_delete, /* file delete method */
+ H5O__layout_decode, /*decode message */
+ H5O__layout_encode, /*encode message */
+ H5O__layout_copy, /*copy the native value */
+ H5O__layout_size, /*size of message on disk */
+ H5O__layout_reset, /*reset method */
+ H5O__layout_free, /*free the struct */
+ H5O__layout_delete, /* file delete method */
NULL, /* link method */
NULL, /*set share method */
NULL, /*can share method */
NULL, /* pre copy native value to file */
- H5O_layout_copy_file, /* copy native value to file */
+ H5O__layout_copy_file, /* copy native value to file */
NULL, /* post copy native value to file */
NULL, /* get creation index */
NULL, /* set creation index */
- H5O_layout_debug /*debug the message */
+ H5O__layout_debug /*debug the message */
}};
@@ -85,7 +85,7 @@ H5FL_DEFINE(H5O_layout_t);
/*-------------------------------------------------------------------------
- * Function: H5O_layout_decode
+ * Function: H5O__layout_decode
*
* Purpose: Decode an data layout message and return a pointer to a
* new one created with malloc().
@@ -100,7 +100,7 @@ H5FL_DEFINE(H5O_layout_t);
*-------------------------------------------------------------------------
*/
static void *
-H5O_layout_decode(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_t H5_ATTR_UNUSED *open_oh,
+H5O__layout_decode(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_t H5_ATTR_UNUSED *open_oh,
unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, const uint8_t *p)
{
H5O_layout_t *mesg = NULL;
@@ -108,7 +108,7 @@ H5O_layout_decode(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_t H5_ATTR_UNUSED *
unsigned u;
void *ret_value = NULL; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_STATIC
/* check args */
HDassert(f);
@@ -117,6 +117,7 @@ H5O_layout_decode(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_t H5_ATTR_UNUSED *
/* decode */
if(NULL == (mesg = H5FL_CALLOC(H5O_layout_t)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
+ mesg->storage.type = H5D_LAYOUT_ERROR;
mesg->version = *p++;
if(mesg->version < H5O_LAYOUT_VERSION_1 || mesg->version > H5O_LAYOUT_VERSION_4)
@@ -134,6 +135,9 @@ H5O_layout_decode(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_t H5_ATTR_UNUSED *
mesg->type = (H5D_layout_t)*p++;
HDassert(H5D_CONTIGUOUS == mesg->type || H5D_CHUNKED == mesg->type || H5D_COMPACT == mesg->type);
+ /* Set the storage type */
+ mesg->storage.type = mesg->type;
+
/* Reserved bytes */
p += 5;
@@ -194,16 +198,21 @@ H5O_layout_decode(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_t H5_ATTR_UNUSED *
} /* end if */
} /* end if */
else {
- /* Layout class */
+ /* Layout & storage class */
mesg->type = mesg->storage.type = (H5D_layout_t)*p++;
/* Interpret the rest of the message according to the layout class */
switch(mesg->type) {
case H5D_COMPACT:
+ /* Compact data size */
UINT16DECODE(p, mesg->storage.u.compact.size);
+
if(mesg->storage.u.compact.size > 0) {
+ /* Allocate space for compact data */
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")
+ 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);
p += mesg->storage.u.compact.size;
} /* end if */
@@ -213,7 +222,10 @@ H5O_layout_decode(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_t H5_ATTR_UNUSED *
break;
case H5D_CONTIGUOUS:
+ /* Contiguous storage address */
H5F_addr_decode(f, &p, &(mesg->storage.u.contig.addr));
+
+ /* Contiguous storage size */
H5F_DECODE_LENGTH(f, p, mesg->storage.u.contig.size);
/* Set the layout operations */
@@ -409,11 +421,11 @@ done:
heap_block = (uint8_t *)H5MM_xfree(heap_block);
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_layout_decode() */
+} /* end H5O__layout_decode() */
/*-------------------------------------------------------------------------
- * Function: H5O_layout_encode
+ * Function: H5O__layout_encode
*
* Purpose: Encodes a message.
*
@@ -426,24 +438,10 @@ done:
* Quincey Koziol, 2004-5-21
* We write out version 3 messages by default now.
*
- * Modifications:
- * Robb Matzke, 1998-07-20
- * Rearranged the message to add a version number at the beginning.
- *
- * Raymond Lu, 2002-2-26
- * Added version number 2 case depends on if space has been allocated
- * at the moment when layout header message is updated.
- *
- * Quincey Koziol, 2004-5-21
- * Added version number 3 case to straighten out problems with contiguous
- * layout's sizes (was encoding them as 4-byte values when they were
- * really n-byte values (where n usually is 8)) and additionally clean up
- * the information written out.
- *
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_layout_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg)
+H5O__layout_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg)
{
const H5O_layout_t *mesg = (const H5O_layout_t *) _mesg;
uint8_t *heap_block = NULL;
@@ -451,7 +449,7 @@ H5O_layout_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, c
unsigned u;
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_STATIC
/* check args */
HDassert(f);
@@ -482,7 +480,10 @@ H5O_layout_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, c
break;
case H5D_CONTIGUOUS:
+ /* Contiguous storage address */
H5F_addr_encode(f, &p, mesg->storage.u.contig.addr);
+
+ /* Contiguous storage size */
H5F_ENCODE_LENGTH(f, p, mesg->storage.u.contig.size);
break;
@@ -613,11 +614,11 @@ done:
str_size = (size_t *)H5MM_xfree(str_size);
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_layout_encode() */
+} /* end H5O__layout_encode() */
/*-------------------------------------------------------------------------
- * Function: H5O_layout_copy
+ * Function: H5O__layout_copy
*
* Purpose: Copies a message from _MESG to _DEST, allocating _DEST if
* necessary.
@@ -632,13 +633,13 @@ done:
*-------------------------------------------------------------------------
*/
static void *
-H5O_layout_copy(const void *_mesg, void *_dest)
+H5O__layout_copy(const void *_mesg, void *_dest)
{
const H5O_layout_t *mesg = (const H5O_layout_t *) _mesg;
H5O_layout_t *dest = (H5O_layout_t *) _dest;
void *ret_value = NULL; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_STATIC
/* check args */
HDassert(mesg);
@@ -665,6 +666,8 @@ H5O_layout_copy(const void *_mesg, void *_dest)
/* Copy over the raw data */
HDmemcpy(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);
break;
case H5D_CONTIGUOUS:
@@ -697,11 +700,11 @@ done:
dest = H5FL_FREE(H5O_layout_t, dest);
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_layout_copy() */
+} /* end H5O__layout_copy() */
/*-------------------------------------------------------------------------
- * Function: H5O_layout_size
+ * Function: H5O__layout_size
*
* Purpose: Returns the size of the raw message in bytes. If it's
* compact dataset, the data part is also included.
@@ -717,12 +720,12 @@ done:
*-------------------------------------------------------------------------
*/
static size_t
-H5O_layout_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void *_mesg)
+H5O__layout_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void *_mesg)
{
const H5O_layout_t *mesg = (const H5O_layout_t *) _mesg;
size_t ret_value = 0; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
/* check args */
HDassert(f);
@@ -733,11 +736,11 @@ H5O_layout_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const voi
ret_value = H5D__layout_meta_size(f, mesg, TRUE);
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_layout_size() */
+} /* end H5O__layout_size() */
/*-------------------------------------------------------------------------
- * Function: H5O_layout_reset
+ * Function: H5O__layout_reset
*
* Purpose: Frees resources within a data type message, but doesn't free
* the message itself.
@@ -750,12 +753,12 @@ H5O_layout_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const voi
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_layout_reset(void *_mesg)
+H5O__layout_reset(void *_mesg)
{
H5O_layout_t *mesg = (H5O_layout_t *)_mesg;
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_STATIC
if(mesg) {
/* Free the compact storage buffer */
@@ -768,15 +771,16 @@ H5O_layout_reset(void *_mesg)
/* Reset the message */
mesg->type = H5D_CONTIGUOUS;
+ mesg->version = H5O_LAYOUT_VERSION_DEFAULT;
} /* end if */
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_layout_reset() */
+} /* end H5O__layout_reset() */
/*-------------------------------------------------------------------------
- * Function: H5O_layout_free
+ * Function: H5O__layout_free
*
* Purpose: Free's the message
*
@@ -788,28 +792,25 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_layout_free(void *_mesg)
+H5O__layout_free(void *_mesg)
{
H5O_layout_t *mesg = (H5O_layout_t *) _mesg;
- herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_STATIC_NOERR
HDassert(mesg);
/* Free resources within the message */
- if(H5O_layout_reset(mesg) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free message resources")
+ H5O__layout_reset(mesg);
- mesg = H5FL_FREE(H5O_layout_t, mesg);
+ (void)H5FL_FREE(H5O_layout_t, mesg);
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_layout_free() */
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5O__layout_free() */
/*-------------------------------------------------------------------------
- * Function: H5O_layout_delete
+ * Function: H5O__layout_delete
*
* Purpose: Free file space referenced by message
*
@@ -821,12 +822,12 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_layout_delete(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, void *_mesg)
+H5O__layout_delete(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, void *_mesg)
{
H5O_layout_t *mesg = (H5O_layout_t *) _mesg;
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_STATIC
/* check args */
HDassert(f);
@@ -865,11 +866,11 @@ H5O_layout_delete(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, void *_mesg)
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_layout_delete() */
+} /* end H5O__layout_delete() */
/*-------------------------------------------------------------------------
- * Function: H5O_layout_copy_file
+ * Function: H5O__layout_copy_file
*
* Purpose: Copies a message from _MESG to _DEST in file
*
@@ -883,7 +884,7 @@ done:
*-------------------------------------------------------------------------
*/
static void *
-H5O_layout_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst,
+H5O__layout_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst,
hbool_t H5_ATTR_UNUSED *recompute_size, unsigned H5_ATTR_UNUSED *mesg_flags,
H5O_copy_t *cpy_info, void *_udata, hid_t dxpl_id)
{
@@ -893,29 +894,26 @@ H5O_layout_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst,
hbool_t copied = FALSE; /* Whether the data was copied */
void *ret_value = NULL; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_STATIC
/* check args */
HDassert(file_src);
HDassert(layout_src);
HDassert(file_dst);
- /* Allocate space for the destination layout */
- if(NULL == (layout_dst = H5FL_MALLOC(H5O_layout_t)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, NULL, "memory allocation failed")
-
- /* Copy the "top level" information */
- *layout_dst = *layout_src;
+ /* Copy the layout information */
+ if(NULL == (layout_dst = (H5O_layout_t *)H5O__layout_copy(layout_src, NULL)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy layout")
/* Copy the layout type specific information */
switch(layout_src->type) {
case H5D_COMPACT:
- if(layout_src->storage.u.compact.buf) {
+ if(layout_src->storage.u.compact.buf) {
/* copy compact raw data */
if(H5D__compact_copy(file_src, &layout_src->storage.u.compact, file_dst, &layout_dst->storage.u.compact, udata->src_dtype, cpy_info, dxpl_id) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy chunked storage")
copied = TRUE;
- } /* end if */
+ } /* end if */
break;
case H5D_CONTIGUOUS:
@@ -970,11 +968,11 @@ done:
layout_dst = H5FL_FREE(H5O_layout_t, layout_dst);
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_layout_copy_file() */
+} /* end H5O__layout_copy_file() */
/*-------------------------------------------------------------------------
- * Function: H5O_layout_debug
+ * Function: H5O__layout_debug
*
* Purpose: Prints debugging info for a message.
*
@@ -986,13 +984,13 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_layout_debug(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, const void *_mesg,
+H5O__layout_debug(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, const void *_mesg,
FILE * stream, int indent, int fwidth)
{
const H5O_layout_t *mesg = (const H5O_layout_t *) _mesg;
size_t u;
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
/* check args */
HDassert(f);
@@ -1079,5 +1077,5 @@ H5O_layout_debug(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, const vo
} /* end switch */
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* end H5O_layout_debug() */
+} /* end H5O__layout_debug() */
diff --git a/src/H5Omtime.c b/src/H5Omtime.c
index 622d57d..c61fa66 100644
--- a/src/H5Omtime.c
+++ b/src/H5Omtime.c
@@ -42,7 +42,7 @@ static size_t H5O_mtime_size(const H5F_t *f, hbool_t disable_shared, const void
static herr_t H5O_mtime_reset(void *_mesg);
static herr_t H5O_mtime_free(void *_mesg);
static herr_t H5O_mtime_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE *stream,
- int indent, int fwidth);
+ int indent, int fwidth);
/* This message derives from H5O message class */
const H5O_msg_class_t H5O_MSG_MTIME[1] = {{
@@ -96,9 +96,6 @@ const H5O_msg_class_t H5O_MSG_MTIME_NEW[1] = {{
/* Current version of new mtime information */
#define H5O_MTIME_VERSION 1
-/* Track whether tzset routine was called */
-static hbool_t ntzset = FALSE;
-
/* Declare a free list to manage the time_t struct */
H5FL_DEFINE(time_t);
@@ -148,7 +145,7 @@ H5O_mtime_new_decode(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_
/* The return value */
if (NULL==(mesg = H5FL_MALLOC(time_t)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
*mesg = (time_t)tmp_time;
/* Set return value */
@@ -183,8 +180,8 @@ H5O_mtime_decode(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_t H5
unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, const uint8_t *p)
{
time_t *mesg, the_time;
- int i;
struct tm tm;
+ int i; /* Local index variable */
void *ret_value = NULL; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -193,51 +190,22 @@ H5O_mtime_decode(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_t H5
HDassert(f);
HDassert(p);
- /* Initialize time zone information */
- if(!ntzset) {
- HDtzset();
- ntzset = TRUE;
- } /* end if */
-
/* decode */
for(i = 0; i < 14; i++)
if(!HDisdigit(p[i]))
HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "badly formatted modification time message")
- /*
- * Convert YYYYMMDDhhmmss UTC to a time_t. This is a little problematic
- * because mktime() operates on local times. We convert to local time
- * and then figure out the adjustment based on the local time zone and
- * daylight savings setting.
- */
+ /* Convert YYYYMMDDhhmmss UTC to a time_t. */
HDmemset(&tm, 0, sizeof tm);
- tm.tm_year = (p[0]-'0')*1000 + (p[1]-'0')*100 +
- (p[2]-'0')*10 + (p[3]-'0') - 1900;
+ tm.tm_year = (p[0]-'0')*1000 + (p[1]-'0')*100 + (p[2]-'0')*10 + (p[3]-'0') - 1900;
tm.tm_mon = (p[4]-'0')*10 + (p[5]-'0') - 1;
tm.tm_mday = (p[6]-'0')*10 + (p[7]-'0');
tm.tm_hour = (p[8]-'0')*10 + (p[9]-'0');
tm.tm_min = (p[10]-'0')*10 + (p[11]-'0');
tm.tm_sec = (p[12]-'0')*10 + (p[13]-'0');
- tm.tm_isdst = -1; /*figure it out*/
- if((time_t)-1 == (the_time = HDmktime(&tm)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "badly formatted modification time message")
-
-#if defined(H5_HAVE_TM_GMTOFF)
- /* BSD-like systems */
- the_time += tm.tm_gmtoff;
-#elif defined(H5_HAVE_TIMEZONE)
- /* GNU/Linux systems */
- the_time -= timezone - (tm.tm_isdst ? 3600 : 0);
-#else
- /*
- * The catch-all. If we can't convert a character string universal
- * coordinated time to a time_t value reliably then we can't decode the
- * modification time message. This really isn't as bad as it sounds -- the
- * only way a user can get the modification time is from our internal
- * query routines, which can gracefully recover.
- */
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to obtain local timezone information")
-#endif
+ tm.tm_isdst = -1; /* (figure it out) */
+ if((time_t)-1 == (the_time = H5_make_time(&tm)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "can't construct time info")
/* The return value */
if(NULL == (mesg = H5FL_MALLOC(time_t)))
@@ -323,8 +291,8 @@ 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",
- 1900+tm->tm_year, 1+tm->tm_mon, tm->tm_mday,
- tm->tm_hour, tm->tm_min, tm->tm_sec);
+ 1900+tm->tm_year, 1+tm->tm_mon, tm->tm_mday,
+ tm->tm_hour, tm->tm_min, tm->tm_sec);
FUNC_LEAVE_NOAPI(SUCCEED)
}
@@ -507,7 +475,7 @@ H5O_mtime_free(void *mesg)
*/
static herr_t
H5O_mtime_debug(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, const void *_mesg, FILE *stream,
- int indent, int fwidth)
+ int indent, int fwidth)
{
const time_t *mesg = (const time_t *)_mesg;
struct tm *tm;
@@ -527,7 +495,7 @@ H5O_mtime_debug(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, const voi
HDstrftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S %Z", tm);
HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
- "Time:", buf);
+ "Time:", buf);
FUNC_LEAVE_NOAPI(SUCCEED)
}
diff --git a/src/H5Opkg.h b/src/H5Opkg.h
index ddcdb10..642e938 100644
--- a/src/H5Opkg.h
+++ b/src/H5Opkg.h
@@ -324,8 +324,8 @@ typedef struct H5O_obj_class_t {
hid_t (*open)(const H5G_loc_t *, hid_t, hid_t, hbool_t ); /*open an object of this class */
void *(*create)(H5F_t *, void *, H5G_loc_t *, hid_t ); /*create an object of this class */
H5O_loc_t *(*get_oloc)(hid_t ); /*get the object header location for an object */
- herr_t (*bh_info)(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5_ih_info_t *bh_info); /*get the index & heap info for an object */
- herr_t (*flush)(H5G_loc_t *loc, hid_t dxpl_id); /*flush an opened object of this class */
+ herr_t (*bh_info)(const H5O_loc_t *loc, hid_t dxpl_id, H5O_t *oh, H5_ih_info_t *bh_info); /*get the index & heap info for an object */
+ herr_t (*flush)(H5G_loc_t *loc, hid_t dxpl_id); /*flush an opened object of this class */
} H5O_obj_class_t;
/* Node in skip list to map addresses from one file to another during object header copy */
diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h
index 4586adb..0d77a83 100644
--- a/src/H5Oprivate.h
+++ b/src/H5Oprivate.h
@@ -382,11 +382,13 @@ typedef struct H5O_efl_t {
*/
#define H5O_LAYOUT_VERSION_4 4
+/* The default version of the format. (Earlier versions had bugs) */
+#define H5O_LAYOUT_VERSION_DEFAULT H5O_LAYOUT_VERSION_3
+
/* The latest version of the format. Look through the 'encode'
* and 'size' callbacks for places to change when updating this. */
#define H5O_LAYOUT_VERSION_LATEST H5O_LAYOUT_VERSION_4
-
/* Forward declaration of structs used below */
struct H5D_layout_ops_t; /* Defined in H5Dpkg.h */
struct H5D_chunk_ops_t; /* Defined in H5Dpkg.h */
@@ -406,7 +408,7 @@ typedef struct H5O_storage_chunk_t {
haddr_t idx_addr; /* File address of chunk index */
const struct H5D_chunk_ops_t *ops; /* Pointer to chunked storage operations */
union {
- H5O_storage_chunk_btree_t btree; /* Information for v1 B-tree index */
+ H5O_storage_chunk_btree_t btree; /* Information for v1 B-tree index */
} u;
} H5O_storage_chunk_t;
diff --git a/src/H5Otest.c b/src/H5Otest.c
index b5f728a..1c149e3 100644
--- a/src/H5Otest.c
+++ b/src/H5Otest.c
@@ -253,9 +253,9 @@ herr_t
H5O_num_attrs_test(hid_t oid, hsize_t *nattrs)
{
H5O_t *oh = NULL; /* Object header */
- H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */
+ H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */
H5O_ainfo_t ainfo; /* Attribute information for object */
- H5O_loc_t *loc; /* Pointer to object's location */
+ H5O_loc_t *loc; /* Pointer to object's location */
hsize_t obj_nattrs; /* Number of attributes */
herr_t ret_value = SUCCEED; /* Return value */
diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c
index 0677517..afef06b 100644
--- a/src/H5Pdcpl.c
+++ b/src/H5Pdcpl.c
@@ -769,12 +769,16 @@ H5P__dcrt_layout_cmp(const void *_layout1, const void *_layout2,
HDassert(size == sizeof(H5O_layout_t));
/* Check for different layout type */
- if(layout1->type < layout2->type) HGOTO_DONE(-1)
- if(layout1->type > layout2->type) HGOTO_DONE(1)
+ if(layout1->type < layout2->type)
+ HGOTO_DONE(-1)
+ if(layout1->type > layout2->type)
+ HGOTO_DONE(1)
/* Check for different layout version */
- if(layout1->version < layout2->version) HGOTO_DONE(-1)
- if(layout1->version > layout2->version) HGOTO_DONE(1)
+ if(layout1->version < layout2->version)
+ HGOTO_DONE(-1)
+ if(layout1->version > layout2->version)
+ HGOTO_DONE(1)
/* Compare non-dataset-specific fields in layout info */
switch(layout1->type) {
@@ -787,13 +791,17 @@ H5P__dcrt_layout_cmp(const void *_layout1, const void *_layout2,
unsigned u; /* Local index variable */
/* Check the number of dimensions */
- if(layout1->u.chunk.ndims < layout2->u.chunk.ndims) HGOTO_DONE(-1)
- if(layout1->u.chunk.ndims > layout2->u.chunk.ndims) HGOTO_DONE(1)
+ if(layout1->u.chunk.ndims < layout2->u.chunk.ndims)
+ HGOTO_DONE(-1)
+ if(layout1->u.chunk.ndims > layout2->u.chunk.ndims)
+ HGOTO_DONE(1)
/* Compare the chunk dims */
for(u = 0; u < layout1->u.chunk.ndims - 1; u++) {
- if(layout1->u.chunk.dim[u] < layout2->u.chunk.dim[u]) HGOTO_DONE(-1)
- if(layout1->u.chunk.dim[u] > layout2->u.chunk.dim[u]) HGOTO_DONE(1)
+ if(layout1->u.chunk.dim[u] < layout2->u.chunk.dim[u])
+ HGOTO_DONE(-1)
+ if(layout1->u.chunk.dim[u] > layout2->u.chunk.dim[u])
+ HGOTO_DONE(1)
} /* end for */
} /* end case */
break;
@@ -2133,7 +2141,6 @@ H5Pset_virtual(hid_t dcpl_id, hid_t vspace_id, const char *src_file_name,
H5O_storage_virtual_ent_t *old_list = NULL; /* List pointer previously on property list */
H5O_storage_virtual_ent_t *ent = NULL; /* Convenience pointer to new VDS entry */
hbool_t retrieved_layout = FALSE; /* Whether the layout has been retrieved */
- hbool_t adding_entry = FALSE; /* Whether we are in the middle of adding an entry */
hbool_t free_list = FALSE; /* Whether to free the list of virtual entries */
herr_t ret_value = SUCCEED; /* Return value */
@@ -2207,7 +2214,6 @@ H5Pset_virtual(hid_t dcpl_id, hid_t vspace_id, const char *src_file_name,
HDmemset(ent, 0, sizeof(H5O_storage_virtual_ent_t)); /* Clear before starting to set up */
if(NULL == (ent->source_dset.virtual_select = H5S_copy(vspace, FALSE, TRUE)))
HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to copy virtual selection")
- adding_entry = TRUE;
if(NULL == (ent->source_file_name = HDstrdup(src_file_name)))
HGOTO_ERROR(H5E_PLIST, H5E_RESOURCE, FAIL, "can't duplicate source file name")
if(NULL == (ent->source_dset_name = HDstrdup(src_dset_name)))
diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c
index 21bf4c8..7e1e0ee 100644
--- a/src/H5Pfapl.c
+++ b/src/H5Pfapl.c
@@ -1244,7 +1244,7 @@ H5Pget_family_offset(hid_t fapl_id, hsize_t *offset)
/* Get value */
if(offset) {
if(H5P_get(plist, H5F_ACS_FAMILY_OFFSET_NAME, offset) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set offset for family file")
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set offset for family file")
} /* end if */
done:
@@ -1324,7 +1324,7 @@ H5Pget_multi_type(hid_t fapl_id, H5FD_mem_t *type)
/* Get value */
if(type) {
if(H5P_get(plist, H5F_ACS_MULTI_TYPE_NAME, type) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't get type for multi driver")
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get type for multi driver")
} /* end if */
done:
@@ -3030,7 +3030,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), H5AC__MAX_TRACE_FILE_NAME_LEN + 1);
+ HDmemcpy(*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);
diff --git a/src/H5Pgcpl.c b/src/H5Pgcpl.c
index f84fa7b..f028f7a 100644
--- a/src/H5Pgcpl.c
+++ b/src/H5Pgcpl.c
@@ -594,6 +594,7 @@ H5P__gcrt_group_info_dec(const void **_pp, void *_value)
FUNC_ENTER_STATIC_NOERR
/* Set property to default value */
+ HDmemset(ginfo, 0, sizeof(H5O_ginfo_t));
*ginfo = H5G_def_ginfo_g;
UINT32DECODE(*pp, ginfo->lheap_size_hint)
@@ -692,6 +693,7 @@ H5P__gcrt_link_info_dec(const void **_pp, void *_value)
HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "unsigned value can't be decoded")
/* Set property to default value */
+ HDmemset(linfo, 0, sizeof(H5O_linfo_t));
*linfo = H5G_def_linfo_g;
H5_DECODE_UNSIGNED(*pp, crt_order_flags)
diff --git a/src/H5Pint.c b/src/H5Pint.c
index 539fe68..ca56f82 100644
--- a/src/H5Pint.c
+++ b/src/H5Pint.c
@@ -584,12 +584,12 @@ H5P_term_package(void)
/*--------------------------------------------------------------------------
NAME
- H5P_do_prop_cb1
+ H5P__do_prop_cb1
PURPOSE
Internal routine to call a property list callback routine and update
the property list accordingly.
USAGE
- herr_t H5P_do_prop_cb1(slist,prop,cb)
+ herr_t H5P__do_prop_cb1(slist,prop,cb)
H5SL_t *slist; IN/OUT: Skip list to hold changed properties
H5P_genprop_t *prop; IN: Property to call callback for
H5P_prp_cb1_t *cb; IN: Callback routine to call
@@ -605,13 +605,13 @@ H5P_term_package(void)
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
-H5P_do_prop_cb1(H5SL_t *slist, H5P_genprop_t *prop, H5P_prp_cb1_t cb)
+H5P__do_prop_cb1(H5SL_t *slist, H5P_genprop_t *prop, H5P_prp_cb1_t cb)
{
void *tmp_value = NULL; /* Temporary value buffer */
H5P_genprop_t *pcopy = NULL; /* Copy of property to insert into skip list */
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_STATIC
/* Sanity check */
HDassert(slist);
@@ -650,7 +650,7 @@ done:
H5P_free_prop(pcopy);
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5P_do_prop_cb1() */
+} /* end H5P__do_prop_cb1() */
/*--------------------------------------------------------------------------
@@ -876,7 +876,7 @@ H5P_copy_plist(const H5P_genplist_t *old_plist, hbool_t app_ref)
/* Call property copy callback, if it exists */
if(tmp->copy) {
/* Call the callback & insert changed value into skip list (if necessary) */
- if(H5P_do_prop_cb1(new_plist->props,tmp,tmp->copy) < 0)
+ if(H5P__do_prop_cb1(new_plist->props, tmp, tmp->copy) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL,"Can't create property")
} /* end if */
@@ -1729,7 +1729,7 @@ H5P_create(H5P_genclass_t *pclass)
/* Call property creation callback, if it exists */
if(tmp->create) {
/* Call the callback & insert changed value into skip list (if necessary) */
- if(H5P_do_prop_cb1(plist->props,tmp,tmp->create) < 0)
+ if(H5P__do_prop_cb1(plist->props, tmp, tmp->create) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, NULL,"Can't create property")
} /* end if */
diff --git a/src/H5Pocpl.c b/src/H5Pocpl.c
index 7ae5a6e..27044d5 100644
--- a/src/H5Pocpl.c
+++ b/src/H5Pocpl.c
@@ -1590,6 +1590,7 @@ H5P__ocrt_pipeline_dec(const void **_pp, void *_value)
nused = (size_t)enc_value;
/* Set property default value */
+ HDmemset(pline, 0, sizeof(H5O_pline_t));
*pline = H5O_def_pline_g;
for(u = 0; u < nused; u++) {
diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h
index f2f7da0..6a1dbad 100644
--- a/src/H5Ppublic.h
+++ b/src/H5Ppublic.h
@@ -349,7 +349,6 @@ H5_DLL herr_t H5Pset_file_image_callbacks(hid_t fapl_id,
H5FD_file_image_callbacks_t *callbacks_ptr);
H5_DLL herr_t H5Pget_file_image_callbacks(hid_t fapl_id,
H5FD_file_image_callbacks_t *callbacks_ptr);
-
H5_DLL herr_t H5Pset_core_write_tracking(hid_t fapl_id, hbool_t is_enabled, size_t page_size);
H5_DLL herr_t H5Pget_core_write_tracking(hid_t fapl_id, hbool_t *is_enabled, size_t *page_size);
#ifdef H5_HAVE_PARALLEL
diff --git a/src/H5Ptest.c b/src/H5Ptest.c
index 30a98a4..8240f6a 100644
--- a/src/H5Ptest.c
+++ b/src/H5Ptest.c
@@ -165,7 +165,7 @@ H5P_reset_external_file_test(hid_t dcpl_id)
/* set external file list */
if(H5P_poke(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external file list")
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set external file list")
done:
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5SM.c b/src/H5SM.c
index e25d780..4a562dd 100644
--- a/src/H5SM.c
+++ b/src/H5SM.c
@@ -1639,7 +1639,7 @@ H5SM_find_in_list(const H5SM_list_t *list, const H5SM_mesg_key_t *key, size_t *e
*/
for(x = 0; x < list->header->list_max; x++) {
if((list->messages[x].location != H5SM_NO_LOC) &&
- (0 == H5SM_message_compare(key, &(list->messages[x]))))
+ (0 == H5SM__message_compare(key, &(list->messages[x]))))
HGOTO_DONE(x)
else if(empty_pos && list->messages[x].location == H5SM_NO_LOC) {
/* Note position */
@@ -2672,8 +2672,6 @@ H5SM_list_debug(H5F_t *f, hid_t dxpl_id, haddr_t list_addr, FILE *stream,
"Location:", "in heap");
HDfprintf(stream, "%*s%-*s 0x%Zx\n", indent + 3, "", fwidth,
"Heap ID:", list->messages[x].u.heap_loc.fheap_id);
-H5HF_id_print(fh, dxpl_id,
- &(list->messages[x].u.heap_loc.fheap_id), stream, indent + 6, (fwidth - 3));
HDfprintf(stream, "%*s%-*s %u\n", indent + 3, "", fwidth,
"Reference count:", list->messages[x].u.heap_loc.ref_count);
} /* end if */
diff --git a/src/H5SMbtree2.c b/src/H5SMbtree2.c
index e24dbb7..e533ae8 100644
--- a/src/H5SMbtree2.c
+++ b/src/H5SMbtree2.c
@@ -45,11 +45,12 @@
/********************/
/* v2 B-tree callbacks */
-static void *H5SM_bt2_crt_context(void *udata);
-static herr_t H5SM_bt2_dst_context(void *ctx);
-static herr_t H5SM_bt2_store(void *native, const void *udata);
-static herr_t H5SM_bt2_debug(FILE *stream, int indent, int fwidth,
- const void *record);
+static void *H5SM__bt2_crt_context(void *udata);
+static herr_t H5SM__bt2_dst_context(void *ctx);
+static herr_t H5SM__bt2_store(void *native, const void *udata);
+static herr_t H5SM__bt2_debug(FILE *stream, int indent, int fwidth,
+ const void *record, const void *_udata);
+static void *H5SM__bt2_crt_dbg_context(H5F_t *f, hid_t dxpl_id, haddr_t addr);
/*****************************/
@@ -60,13 +61,15 @@ const H5B2_class_t H5SM_INDEX[1]={{ /* B-tree class information */
H5B2_SOHM_INDEX_ID, /* Type of B-tree */
"H5B2_SOHM_INDEX_ID", /* Name of B-tree class */
sizeof(H5SM_sohm_t), /* Size of native record */
- H5SM_bt2_crt_context, /* Create client callback context */
- H5SM_bt2_dst_context, /* Destroy client callback context */
- H5SM_bt2_store, /* Record storage callback */
- H5SM_message_compare, /* Record comparison callback */
- H5SM_message_encode, /* Record encoding callback */
- H5SM_message_decode, /* Record decoding callback */
- H5SM_bt2_debug /* Record debugging callback */
+ H5SM__bt2_crt_context, /* Create client callback context */
+ H5SM__bt2_dst_context, /* Destroy client callback context */
+ H5SM__bt2_store, /* Record storage callback */
+ H5SM__message_compare, /* Record comparison callback */
+ H5SM__message_encode, /* Record encoding callback */
+ H5SM__message_decode, /* Record decoding callback */
+ H5SM__bt2_debug, /* Record debugging callback */
+ H5SM__bt2_crt_dbg_context, /* Create debugging context */
+ H5SM__bt2_dst_context /* Destroy debugging context */
}};
@@ -80,7 +83,7 @@ H5FL_DEFINE_STATIC(H5SM_bt2_ctx_t);
/*-------------------------------------------------------------------------
- * Function: H5SM_bt2_crt_context
+ * Function: H5SM__bt2_crt_context
*
* Purpose: Create client callback context
*
@@ -93,13 +96,13 @@ H5FL_DEFINE_STATIC(H5SM_bt2_ctx_t);
*-------------------------------------------------------------------------
*/
static void *
-H5SM_bt2_crt_context(void *_f)
+H5SM__bt2_crt_context(void *_f)
{
H5F_t *f = (H5F_t *)_f; /* User data for building callback context */
H5SM_bt2_ctx_t *ctx; /* Callback context structure */
void *ret_value = NULL; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_STATIC
/* Sanity check */
HDassert(f);
@@ -116,11 +119,11 @@ H5SM_bt2_crt_context(void *_f)
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5SM_bt2_crt_context() */
+} /* H5SM__bt2_crt_context() */
/*-------------------------------------------------------------------------
- * Function: H5SM_bt2_dst_context
+ * Function: H5SM__bt2_dst_context
*
* Purpose: Destroy client callback context
*
@@ -133,11 +136,11 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5SM_bt2_dst_context(void *_ctx)
+H5SM__bt2_dst_context(void *_ctx)
{
H5SM_bt2_ctx_t *ctx = (H5SM_bt2_ctx_t *)_ctx; /* Callback context structure */
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
/* Sanity check */
HDassert(ctx);
@@ -146,11 +149,11 @@ H5SM_bt2_dst_context(void *_ctx)
ctx = H5FL_FREE(H5SM_bt2_ctx_t, ctx);
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5SM_bt2_dst_context() */
+} /* H5SM__bt2_dst_context() */
/*-------------------------------------------------------------------------
- * Function: H5SM_bt2_store
+ * Function: H5SM__bt2_store
*
* Purpose: Store a H5SM_sohm_t SOHM message in the B-tree. The message
* comes in UDATA as a H5SM_mesg_key_t* and is copied to
@@ -165,21 +168,21 @@ H5SM_bt2_dst_context(void *_ctx)
*-------------------------------------------------------------------------
*/
static herr_t
-H5SM_bt2_store(void *native, const void *udata)
+H5SM__bt2_store(void *native, const void *udata)
{
const H5SM_mesg_key_t *key = (const H5SM_mesg_key_t *)udata;
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
/* Copy the source message to the B-tree */
*(H5SM_sohm_t *)native = key->message;
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* end H5SM_bt2_store */
+} /* end H5SM__bt2_store */
/*-------------------------------------------------------------------------
- * Function: H5SM_bt2_debug
+ * Function: H5SM__bt2_debug
*
* Purpose: Print debugging information for a H5SM_sohm_t.
*
@@ -192,11 +195,12 @@ H5SM_bt2_store(void *native, const void *udata)
*-------------------------------------------------------------------------
*/
static herr_t
-H5SM_bt2_debug(FILE *stream, int indent, int fwidth, const void *record)
+H5SM__bt2_debug(FILE *stream, int indent, int fwidth,
+ const void *record, const void H5_ATTR_UNUSED *_udata)
{
const H5SM_sohm_t *sohm = (const H5SM_sohm_t *)record;
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
if(sohm->location == H5SM_IN_HEAP)
HDfprintf(stream, "%*s%-*s {%a, %lo, %Hx}\n", indent, "", fwidth,
@@ -210,7 +214,46 @@ H5SM_bt2_debug(FILE *stream, int indent, int fwidth, const void *record)
} /* end else */
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* end H5SM_bt2_debug */
+} /* end H5SM__bt2_debug */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5SM__bt2_crt_dbg_context
+ *
+ * Purpose: Create context for debugging callback
+ *
+ * Return: Success: non-NULL
+ * Failure: NULL
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, December 1, 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+static void *
+H5SM__bt2_crt_dbg_context(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t H5_ATTR_UNUSED addr)
+{
+ H5SM_bt2_ctx_t *ctx; /* Callback context structure */
+ void *ret_value = NULL; /* Return value */
+
+ FUNC_ENTER_STATIC
+
+ /* Sanity check */
+ HDassert(f);
+
+ /* Allocate callback context */
+ if(NULL == (ctx = H5FL_MALLOC(H5SM_bt2_ctx_t)))
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "can't allocate callback context")
+
+ /* Determine the size of addresses & lengths in the file */
+ ctx->sizeof_addr = H5F_SIZEOF_ADDR(f);
+
+ /* Set return value */
+ ret_value = ctx;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5SM__bt2_crt_dbg_context() */
/*-------------------------------------------------------------------------
diff --git a/src/H5SMcache.c b/src/H5SMcache.c
index 1bdd95a..bbd7e87 100644
--- a/src/H5SMcache.c
+++ b/src/H5SMcache.c
@@ -256,7 +256,7 @@ H5SM__cache_table_deserialize(const void *_image, size_t len, void *_udata,
/* Address of the index's heap */
H5F_addr_decode(f, &image, &(table->indexes[u].heap_addr));
- /* Compute the size of a list index for this SOHM index */
+ /* Compute the size of a list index for this SOHM index */
table->indexes[u].list_size = H5SM_LIST_SIZE(f, table->indexes[u].list_max);
} /* end for */
@@ -540,7 +540,7 @@ H5SM__cache_list_deserialize(const void *_image, size_t len, void *_udata,
/* Read messages into the list array */
ctx.sizeof_addr = H5F_SIZEOF_ADDR(udata->f);
for(u = 0; u < udata->header->num_messages; u++) {
- if(H5SM_message_decode(image, &(list->messages[u]), &ctx) < 0)
+ if(H5SM__message_decode(image, &(list->messages[u]), &ctx) < 0)
HGOTO_ERROR(H5E_SOHM, H5E_CANTLOAD, NULL, "can't decode shared message")
image += H5SM_SOHM_ENTRY_SIZE(udata->f);
@@ -661,7 +661,7 @@ H5SM__cache_list_serialize(const H5F_t *f, void *_image, size_t len,
ctx.sizeof_addr = H5F_SIZEOF_ADDR(f);
for(u = 0; ((u < list->header->list_max) && (mesgs_serialized < list->header->num_messages)); u++) {
if(list->messages[u].location != H5SM_NO_LOC) {
- if(H5SM_message_encode(image, &(list->messages[u]), &ctx) < 0)
+ if(H5SM__message_encode(image, &(list->messages[u]), &ctx) < 0)
HGOTO_ERROR(H5E_SOHM, H5E_CANTFLUSH, FAIL, "unable to serialize shared message")
image += H5SM_SOHM_ENTRY_SIZE(f);
diff --git a/src/H5SMmessage.c b/src/H5SMmessage.c
index 5dbe5cf..426ea20 100644
--- a/src/H5SMmessage.c
+++ b/src/H5SMmessage.c
@@ -74,7 +74,7 @@ static herr_t H5SM_compare_iter_op(H5O_t *oh, H5O_mesg_t *mesg, unsigned sequenc
/*-------------------------------------------------------------------------
* Function: H5SM_compare_cb
*
- * Purpose: Callback for H5HF_op, used in H5SM_message_compare below.
+ * Purpose: Callback for H5HF_op, used in H5SM__message_compare below.
* Determines whether the search key passed in in _UDATA is
* equal to OBJ or not.
*
@@ -170,7 +170,7 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5SM_message_compare
+ * Function: H5SM__message_compare
*
* Purpose: Determine whether the search key rec1 represents a shared
* message that is equal to rec2 or not, and if not, whether
@@ -186,13 +186,13 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5SM_message_compare(const void *rec1, const void *rec2)
+H5SM__message_compare(const void *rec1, const void *rec2)
{
const H5SM_mesg_key_t *key = (const H5SM_mesg_key_t *) rec1;
const H5SM_sohm_t *mesg = (const H5SM_sohm_t *) rec2;
herr_t ret_value = 0;
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_PACKAGE_NOERR
/* If the key has an fheap ID, we're looking for a message that's
* already in the index; if the fheap ID matches, we've found the message
@@ -269,11 +269,11 @@ H5SM_message_compare(const void *rec1, const void *rec2)
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5SM_message_compare */
+} /* end H5SM__message_compare */
/*-------------------------------------------------------------------------
- * Function: H5SM_message_encode
+ * Function: H5SM__message_encode
*
* Purpose: Serialize a H5SM_sohm_t struct into a buffer RAW.
*
@@ -286,12 +286,12 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5SM_message_encode(uint8_t *raw, const void *_nrecord, void *_ctx)
+H5SM__message_encode(uint8_t *raw, const void *_nrecord, void *_ctx)
{
H5SM_bt2_ctx_t *ctx = (H5SM_bt2_ctx_t *)_ctx; /* Callback context structure */
const H5SM_sohm_t *message = (const H5SM_sohm_t *)_nrecord;
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_PACKAGE_NOERR
/* Sanity check */
HDassert(ctx);
@@ -313,11 +313,11 @@ H5SM_message_encode(uint8_t *raw, const void *_nrecord, void *_ctx)
} /* end else */
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* end H5SM_message_encode */
+} /* end H5SM__message_encode */
/*-------------------------------------------------------------------------
- * Function: H5SM_message_decode
+ * Function: H5SM__message_decode
*
* Purpose: Read an encoded SOHM message from RAW into an H5SM_sohm_t struct.
*
@@ -330,12 +330,12 @@ H5SM_message_encode(uint8_t *raw, const void *_nrecord, void *_ctx)
*-------------------------------------------------------------------------
*/
herr_t
-H5SM_message_decode(const uint8_t *raw, void *_nrecord, void *_ctx)
+H5SM__message_decode(const uint8_t *raw, void *_nrecord, void *_ctx)
{
H5SM_bt2_ctx_t *ctx = (H5SM_bt2_ctx_t *)_ctx; /* Callback context structure */
H5SM_sohm_t *message = (H5SM_sohm_t *)_nrecord;
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_PACKAGE_NOERR
message->location = (H5SM_storage_loc_t)*raw++;
UINT32DECODE(raw, message->hash);
@@ -354,5 +354,5 @@ H5SM_message_decode(const uint8_t *raw, void *_nrecord, void *_ctx)
} /* end else */
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* end H5SM_message_decode */
+} /* end H5SM__message_decode */
diff --git a/src/H5SMpkg.h b/src/H5SMpkg.h
index ac2ba1b..f072741 100644
--- a/src/H5SMpkg.h
+++ b/src/H5SMpkg.h
@@ -268,9 +268,9 @@ H5_DLLVAR const H5B2_class_t H5SM_INDEX[1];
H5_DLL ssize_t H5SM_get_index(const H5SM_master_table_t *table, unsigned type_id);
/* Encode and decode routines, used for B-tree and cache encoding/decoding */
-H5_DLL herr_t H5SM_message_compare(const void *rec1, const void *rec2);
-H5_DLL herr_t H5SM_message_encode(uint8_t *raw, const void *native, void *ctx);
-H5_DLL herr_t H5SM_message_decode(const uint8_t *raw, void *native, void *ctx);
+H5_DLL herr_t H5SM__message_compare(const void *rec1, const void *rec2);
+H5_DLL herr_t H5SM__message_encode(uint8_t *raw, const void *native, void *ctx);
+H5_DLL herr_t H5SM__message_decode(const uint8_t *raw, void *native, void *ctx);
/* H5B2_remove_t callback to add messages to a list index */
H5_DLL herr_t H5SM_bt2_convert_to_list_op(const void * record, void *op_data);
diff --git a/src/H5Shyper.c b/src/H5Shyper.c
index 28cabf0..fe013a7 100644
--- a/src/H5Shyper.c
+++ b/src/H5Shyper.c
@@ -2038,7 +2038,7 @@ H5S_hyper_serialize_helper(const H5S_hyper_span_info_t *spans,
uint8_t *pp = (*p); /* Local pointer for decoding */
hsize_t u; /* Index variable */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_NOAPI_NOINIT_NOERR
/* Sanity checks */
HDassert(spans);
diff --git a/src/H5T.c b/src/H5T.c
index 1213bf7..fd362eb 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -801,7 +801,7 @@ H5T__init_package(void)
H5T_INIT_TYPE(OFFSET,H5T_NATIVE_HERR_g,COPY,native_int,SET,sizeof(herr_t))
/* hbool_t */
- H5T_INIT_TYPE(OFFSET,H5T_NATIVE_HBOOL_g,COPY,native_int,SET,sizeof(hbool_t))
+ H5T_INIT_TYPE(OFFSET,H5T_NATIVE_HBOOL_g,COPY,native_uint,SET,sizeof(hbool_t))
/*------------------------------------------------------------
* IEEE Types
@@ -3597,25 +3597,12 @@ done:
* Programmer: Robb Matzke
* Monday, December 8, 1997
*
- * Modifications:
- * Robb Matzke, 1999-04-27
- * This function fails if the datatype state is IMMUTABLE.
- *
- * Robb Matzke, 1999-05-20
- * Closes opaque types also.
- *
- * Pedro Vicente, <pvn@ncsa.uiuc.edu> 22 Aug 2002
- * Added "ID to name" support
- *
- * Quincey Koziol, 2003-01-06
- * Moved "guts" of function to H5T__free()
- *
*-------------------------------------------------------------------------
*/
herr_t
H5T_close(H5T_t *dt)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -3629,7 +3616,8 @@ H5T_close(H5T_t *dt)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "unable to free datatype");
dt->shared = H5FL_FREE(H5T_shared_t, dt->shared);
- } else {
+ } /* end if */
+ else {
/*
* If a named type is being closed then close the object header and
* remove from the list of open objects in the file.
diff --git a/src/H5VMprivate.h b/src/H5VMprivate.h
index bf4e3ca..7d3361b 100644
--- a/src/H5VMprivate.h
+++ b/src/H5VMprivate.h
@@ -403,7 +403,7 @@ static const unsigned MultiplyDeBruijnBitPosition[32] =
*
*-------------------------------------------------------------------------
*/
-static H5_INLINE unsigned H5_ATTR_UNUSED
+static H5_INLINE H5_ATTR_PURE unsigned
H5VM_log2_of2(uint32_t n)
{
#ifndef NDEBUG
@@ -424,7 +424,7 @@ H5VM_log2_of2(uint32_t n)
*
*-------------------------------------------------------------------------
*/
-static H5_INLINE hsize_t H5_ATTR_UNUSED
+static H5_INLINE H5_ATTR_CONST hsize_t
H5VM_power2up(hsize_t n)
{
hsize_t ret_value = 1; /* Return value */
diff --git a/src/H5Zscaleoffset.c b/src/H5Zscaleoffset.c
index 7de0060..0dc12a3 100644
--- a/src/H5Zscaleoffset.c
+++ b/src/H5Zscaleoffset.c
@@ -49,7 +49,7 @@ static herr_t H5Z_set_local_scaleoffset(hid_t dcpl_id, hid_t type_id, hid_t spac
static size_t H5Z_filter_scaleoffset(unsigned flags, size_t cd_nelmts,
const unsigned cd_values[], size_t nbytes, size_t *buf_size, void **buf);
static void H5Z_scaleoffset_convert(void *buf, unsigned d_nelmts, size_t dtype_size);
-static unsigned H5Z_scaleoffset_log2(unsigned long long num);
+static H5_ATTR_CONST unsigned H5Z_scaleoffset_log2(unsigned long long num);
static void H5Z_scaleoffset_precompress_i(void *data, unsigned d_nelmts,
enum H5Z_scaleoffset_t type, unsigned filavail, const unsigned cd_values[],
uint32_t *minbits, unsigned long long *minval);
diff --git a/src/H5Ztrans.c b/src/H5Ztrans.c
index 42d6ceb..0a9a4da 100644
--- a/src/H5Ztrans.c
+++ b/src/H5Ztrans.c
@@ -748,6 +748,7 @@ H5Z_parse_term(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers)
case H5Z_XFORM_ERROR:
default:
+ H5Z_xform_destroy_parse_tree(term);
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "bad transform type passed to data transform expression")
} /* end switch */
} /* end for */
diff --git a/src/H5private.h b/src/H5private.h
index 56061bf..c536566 100644
--- a/src/H5private.h
+++ b/src/H5private.h
@@ -119,6 +119,13 @@
#endif
/*
+ * flock() in sys/file.h is used for the implemention of file locking.
+ */
+#if defined(H5_HAVE_FLOCK) && defined(H5_HAVE_SYS_FILE_H)
+# include <sys/file.h>
+#endif
+
+/*
* Resource usage is not Posix.1 but HDF5 uses it anyway for some performance
* and debugging code if available.
*/
@@ -291,20 +298,30 @@
*
* Note that Solaris Studio supports attribute, but does not support the
* attributes we use.
+ *
+ * H5_ATTR_CONST is redefined in tools/h5repack/dynlib_rpk.c to quiet
+ * gcc warnings (it has to use the public API and can't include this
+ * file). Be sure to update that file if the #ifdefs change here.
*/
#ifdef __cplusplus
# define H5_ATTR_FORMAT(X,Y,Z) /*void*/
-# define H5_ATTR_UNUSED /*void*/
-# define H5_ATTR_NORETURN /*void*/
+# define H5_ATTR_UNUSED /*void*/
+# define H5_ATTR_NORETURN /*void*/
+# define H5_ATTR_CONST /*void*/
+# define H5_ATTR_PURE /*void*/
#else /* __cplusplus */
#if defined(H5_HAVE_ATTRIBUTE) && !defined(__SUNPRO_C)
# define H5_ATTR_FORMAT(X,Y,Z) __attribute__((format(X, Y, Z)))
-# define H5_ATTR_UNUSED __attribute__((unused))
-# define H5_ATTR_NORETURN __attribute__((noreturn))
+# define H5_ATTR_UNUSED __attribute__((unused))
+# define H5_ATTR_NORETURN __attribute__((noreturn))
+# define H5_ATTR_CONST __attribute__((const))
+# define H5_ATTR_PURE __attribute__((pure))
#else
# define H5_ATTR_FORMAT(X,Y,Z) /*void*/
-# define H5_ATTR_UNUSED /*void*/
-# define H5_ATTR_NORETURN /*void*/
+# define H5_ATTR_UNUSED /*void*/
+# define H5_ATTR_NORETURN /*void*/
+# define H5_ATTR_CONST /*void*/
+# define H5_ATTR_PURE /*void*/
#endif
#endif /* __cplusplus */
@@ -364,10 +381,10 @@
* HDF Boolean type.
*/
#ifndef FALSE
-# define FALSE 0
+ #define FALSE false
#endif
#ifndef TRUE
-# define TRUE 1
+ #define TRUE true
#endif
/*
@@ -495,7 +512,7 @@
#endif
/* Double constant wrapper
- *
+ *
* Quiets gcc warnings from -Wunsuffixed-float-constants.
*
* This is a really annoying warning since the standard specifies that
@@ -536,6 +553,18 @@
#define H5_TB (1024.0F * 1024.0F * 1024.0F * 1024.0F)
#define H5_EB (1024.0F * 1024.0F * 1024.0F * 1024.0F * 1024.0F)
+#ifndef H5_HAVE_FLOCK
+/* flock() operations. Used in the source so we have to define them when
+ * the call is not available (e.g.: Windows). These should NOT be used
+ * with system-provided flock() calls since the values will come from the
+ * header file.
+ */
+#define LOCK_SH 0x01
+#define LOCK_EX 0x02
+#define LOCK_NB 0x04
+#define LOCK_UN 0x08
+#endif /* H5_HAVE_FLOCK */
+
/*
* Data types and functions for timing certain parts of the library.
*/
@@ -740,7 +769,11 @@ typedef struct {
#ifndef HDfclose
#define HDfclose(F) fclose(F)
#endif /* HDfclose */
-/* fcntl() variable arguments */
+#ifdef H5_HAVE_FCNTL
+ #ifndef HDfcntl
+ #define HDfcntl(F,C,...) fcntl(F,C,__VA_ARGS__)
+ #endif /* HDfcntl */
+#endif /* H5_HAVE_FCNTL */
#ifndef HDfdopen
#define HDfdopen(N,S) fdopen(N,S)
#endif /* HDfdopen */
@@ -765,6 +798,27 @@ typedef struct {
#ifndef HDfileno
#define HDfileno(F) fileno(F)
#endif /* HDfileno */
+/* Since flock is so prevalent, always build these functions
+ * when possible to avoid them becoming dead code.
+ */
+#ifdef H5_HAVE_FCNTL
+H5_DLL int Pflock(int fd, int operation);
+#endif /* H5_HAVE_FCNTL */
+H5_DLL H5_ATTR_CONST int Nflock(int fd, int operation);
+#ifndef HDflock
+ /* NOTE: flock(2) is not present on all POSIX systems.
+ * If it is not present, we try a flock() equivalent based on
+ * fcntl(2), then fall back to a function that always fails if
+ * it is not present at all.
+ */
+ #if defined(H5_HAVE_FLOCK)
+ #define HDflock(F,L) flock(F,L)
+ #elif defined(H5_HAVE_FCNTL)
+ #define HDflock(F,L) Pflock(F,L)
+ #else
+ #define HDflock(F,L) Nflock(F,L)
+ #endif /* H5_HAVE_FLOCK */
+#endif /* HDflock */
#ifndef HDfloor
#define HDfloor(X) floor(X)
#endif /* HDfloor */
@@ -1157,6 +1211,9 @@ H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...);
#define HDrmdir(S) rmdir(S)
#endif /* HDrmdir */
/* scanf() variable arguments */
+#ifndef HDselect
+ #define HDselect(N,RD,WR,ER,T) select(N,RD,WR,ER,T)
+#endif /* HDsetbuf */
#ifndef HDsetbuf
#define HDsetbuf(F,S) setbuf(F,S)
#endif /* HDsetbuf */
@@ -2065,7 +2122,7 @@ extern hbool_t H5_MPEinit_g; /* Has the MPE Library been initialized? */
FUNC_ENTER_COMMON_NOERR(!H5_IS_API(FUNC)); \
if(H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) {
-/* Use the following two macros as replacements for the FUNC_ENTER_NOAPI
+/* Use the following two macros as replacements for the FUNC_ENTER_NOAPI
* and FUNC_ENTER_NOAPI_NOINIT macros when the function needs to set
* up a metadata tag. */
#define FUNC_ENTER_NOAPI_TAG(dxpl_id, tag, err) { \
@@ -2340,18 +2397,21 @@ extern hbool_t H5_api_entered_g; /* Has library already been entered through
#define FUNC_ENT_PUB(pkg, pkg_init) H5_PUBLIC_ENTER(pkg, pkg_init)
/* Macros for substituting a function prefix */
-#define FUNC_PREFIX_STATIC static
+#define FUNC_PREFIX_STATIC static
#define FUNC_PREFIX_PKGINIT
#define FUNC_PREFIX_PKG
#define FUNC_PREFIX_PRIV
#define FUNC_PREFIX_PUB
/* Macros for declaring error variables */
+/* Function can detect errors and has a specific error return value */
#define FUNC_ERR_VAR_ERR(ret_typ, err) \
hbool_t past_catch = FALSE; \
ret_typ fail_value = err;
+/* Function can detect errors but cannot return an error value (Cleanup only) */
#define FUNC_ERR_VAR_ERRCATCH(ret_typ, err) \
hbool_t past_catch = FALSE;
+/* Function has no need to detect or clean up from errors */
#define FUNC_ERR_VAR_NOERR(ret_typ, err)
/* Use this macro when entering all functions */
@@ -2365,6 +2425,16 @@ func \
H5_GLUE(FUNC_ERR_VAR_, use_err)(ret_typ, err) \
H5_GLUE(FUNC_ENT_, scope)(H5_MY_PKG, H5_MY_PKG_INIT)
+/* Use this macro when entering functions that have no return value */
+#define BEGIN_FUNC_VOID(scope, use_err, func) \
+H5_GLUE(FUNC_PREFIX_, scope) \
+void \
+func \
+/* Open function */ \
+{ \
+ H5_GLUE(FUNC_ERR_VAR_, use_err)(void, -, -) \
+ H5_GLUE(FUNC_ENT_, scope)
+
/* Macros for label when a function initialization can fail */
#define H5_PRIV_YES_FUNC_INIT_FAILED func_init_failed:
#define H5_PRIV_NO_FUNC_INIT_FAILED
@@ -2440,6 +2510,17 @@ func_init_failed: \
/* Close Function */ \
}
+/* Use this macro when leaving void functions */
+#define END_FUNC_VOID(scope) \
+ /* Scope-specific function conclusion */ \
+ H5_GLUE(FUNC_LEAVE_, scope) \
+ \
+ /* Leave routine */ \
+ return; \
+ \
+ /* Close Function */ \
+}
+
/* Macro to begin/end tagging (when FUNC_ENTER_*TAG macros are insufficient).
* Make sure to use HGOTO_ERROR_TAG and HGOTO_DONE_TAG between these macros! */
#define H5_BEGIN_TAG(dxpl, tag, err) { \
@@ -2497,6 +2578,9 @@ H5_DLL uint32_t H5_checksum_lookup3(const void *data, size_t len, uint32_t initv
H5_DLL uint32_t H5_checksum_metadata(const void *data, size_t len, uint32_t initval);
H5_DLL uint32_t H5_hash_string(const char *str);
+/* Time related routines */
+H5_DLL time_t H5_make_time(struct tm *tm);
+
/* Functions for building paths, etc. */
H5_DLL herr_t H5_build_extpath(const char *, char ** /*out*/ );
diff --git a/src/H5public.h b/src/H5public.h
index f7f70cf..5b95fb7 100644
--- a/src/H5public.h
+++ b/src/H5public.h
@@ -141,7 +141,20 @@ typedef int herr_t;
* printf("error determining whether data type is committed\n");
* }
*/
-typedef unsigned int hbool_t;
+#ifdef H5_HAVE_STDBOOL_H
+ #include <stdbool.h>
+#else /* H5_HAVE_STDBOOL_H */
+ #ifndef __cplusplus
+ #if defined(H5_SIZEOF_BOOL) && (H5_SIZEOF_BOOL != 0)
+ #define bool _Bool
+ #else
+ #define bool unsigned int
+ #endif
+ #define true 1
+ #define false 0
+ #endif /* __cplusplus */
+#endif /* H5_HAVE_STDBOOL_H */
+typedef bool hbool_t;
typedef int htri_t;
/* Define the ssize_t type if it not is defined */
diff --git a/src/H5system.c b/src/H5system.c
index e00e5a5..4baebc5 100644
--- a/src/H5system.c
+++ b/src/H5system.c
@@ -32,11 +32,10 @@
/***********/
/* Headers */
/***********/
-#include "H5private.h" /* Generic Functions */
-#include "H5Fprivate.h" /* File access */
-#include "H5MMprivate.h" /* Memory management */
-#include "H5Eprivate.h"
-
+#include "H5private.h" /* Generic Functions */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5Fprivate.h" /* File access */
+#include "H5MMprivate.h" /* Memory management */
/****************/
@@ -73,6 +72,9 @@
/* Local Variables */
/*******************/
+/* Track whether tzset routine was called */
+static hbool_t H5_ntzset = FALSE;
+
/*-------------------------------------------------------------------------
* Function: HDfprintf
@@ -584,7 +586,154 @@ void HDsrand(unsigned int seed)
}
#endif /* H5_HAVE_RAND_R */
+
+
+/*-------------------------------------------------------------------------
+ * Function: Pflock
+ *
+ * Purpose: Wrapper function for POSIX systems where flock(2) is not
+ * available.
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ *-------------------------------------------------------------------------
+ */
+/* NOTE: Compile this all the time on POSIX systems, even when flock(2) is
+ * present so that it's less likely to become dead code.
+ */
+#ifdef H5_HAVE_FCNTL
+int
+Pflock(int fd, int operation) {
+
+ struct flock flk;
+
+ /* Set the lock type */
+ if(operation & LOCK_UN)
+ flk.l_type = F_UNLCK;
+ else if(operation & LOCK_SH)
+ flk.l_type = F_RDLCK;
+ else
+ flk.l_type = F_WRLCK;
+
+ /* Set the other flock struct values */
+ flk.l_whence = SEEK_SET;
+ flk.l_start = 0;
+ flk.l_len = 0; /* to EOF */
+ flk.l_pid = 0; /* not used with set */
+
+ /* Lock or unlock */
+ if(HDfcntl(fd, F_SETLK, flk) < 0)
+ return -1;
+ return 0;
+
+} /* end Pflock() */
+#endif /* H5_HAVE_FCNTL */
+
+
+/*-------------------------------------------------------------------------
+ * Function: Nflock
+ *
+ * Purpose: Wrapper function for systems where no file locking is
+ * available.
+ *
+ * Return: Failure: -1 (always fails)
+ *
+ *-------------------------------------------------------------------------
+ */
+int H5_ATTR_CONST
+Nflock(int H5_ATTR_UNUSED fd, int H5_ATTR_UNUSED operation) {
+ /* just fail */
+ return -1;
+} /* end Nflock() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5_make_time
+ *
+ * Purpose: Portability routine to abstract converting a 'tm' struct into
+ * a time_t value.
+ *
+ * Note: This is a little problematic because mktime() operates on
+ * local times. We convert to local time and then figure out the
+ * adjustment based on the local time zone and daylight savings
+ * setting.
+ *
+ * Return: Success: The value of timezone
+ * Failure: -1
+ *
+ * Programmer: Quincey Koziol
+ * November 18, 2015
+ *
+ *-------------------------------------------------------------------------
+ */
+time_t
+H5_make_time(struct tm *tm)
+{
+ time_t the_time; /* The converted time */
+#if defined(H5_HAVE_VISUAL_STUDIO) && (_MSC_VER >= 1900) /* VS 2015 */
+ /* In gcc and in Visual Studio prior to VS 2015 'timezone' is a global
+ * variable declared in time.h. That variable was deprecated and in
+ * VS 2015 is removed, with _get_timezone replacing it.
+ */
+ long timezone = 0;
+#endif /* defined(H5_HAVE_VISUAL_STUDIO) && (_MSC_VER >= 1900) */
+ time_t ret_value; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ /* Sanity check */
+ HDassert(tm);
+
+ /* Initialize timezone information */
+ if(!H5_ntzset) {
+ HDtzset();
+ H5_ntzset = TRUE;
+ } /* end if */
+
+ /* Perform base conversion */
+ if((time_t)-1 == (the_time = HDmktime(tm)))
+ HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCONVERT, FAIL, "badly formatted modification time message")
+
+ /* Adjust for timezones */
+#if defined(H5_HAVE_TM_GMTOFF)
+ /* BSD-like systems */
+ the_time += tm->tm_gmtoff;
+#elif defined(H5_HAVE_TIMEZONE)
+#if defined(H5_HAVE_VISUAL_STUDIO) && (_MSC_VER >= 1900) /* VS 2015 */
+ /* In gcc and in Visual Studio prior to VS 2015 'timezone' is a global
+ * variable declared in time.h. That variable was deprecated and in
+ * VS 2015 is removed, with _get_timezone replacing it.
+ */
+ _get_timezone(&timezone);
+#endif /* defined(H5_HAVE_VISUAL_STUDIO) && (_MSC_VER >= 1900) */
+
+ the_time -= timezone - (tm->tm_isdst ? 3600 : 0);
+#else
+ /*
+ * The catch-all. If we can't convert a character string universal
+ * coordinated time to a time_t value reliably then we can't decode the
+ * modification time message. This really isn't as bad as it sounds -- the
+ * only way a user can get the modification time is from our internal
+ * query routines, which can gracefully recover.
+ */
+ HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "unable to obtain local timezone information")
+#endif
+
+ /* Set return value */
+ ret_value = the_time;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5_make_time() */
+
+#ifdef H5_HAVE_VISUAL_STUDIO
+
+/* Offset between 1/1/1601 and 1/1/1970 in 100 nanosecond units */
+#define _W32_FT_OFFSET (116444736000000000ULL)
+
+
/*-------------------------------------------------------------------------
* Function: Wgettimeofday
*
@@ -606,11 +755,6 @@ void HDsrand(unsigned int seed)
*
*-------------------------------------------------------------------------
*/
-#ifdef H5_HAVE_VISUAL_STUDIO
-
-/* Offset between 1/1/1601 and 1/1/1970 in 100 nanosecond units */
-#define _W32_FT_OFFSET (116444736000000000ULL)
-
int
Wgettimeofday(struct timeval *tv, struct timezone *tz)
{
@@ -685,7 +829,55 @@ int c99_vsnprintf(char* str, size_t size, const char* format, va_list ap)
return count;
}
-#endif
+
+/*-------------------------------------------------------------------------
+ * Function: Wflock
+ *
+ * Purpose: Wrapper function for flock on Windows systems
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+Wflock(int H5_ATTR_UNUSED fd, int H5_ATTR_UNUSED operation) {
+
+/* This is a no-op while we implement a Win32 VFD */
+#if 0
+int
+Wflock(int fd, int operation) {
+
+ HANDLE hFile;
+ DWORD dwFlags = LOCKFILE_FAIL_IMMEDIATELY;
+ DWORD dwReserved = 0;
+ /* MAXDWORD for entire file */
+ DWORD nNumberOfBytesToLockLow = MAXDWORD;
+ DWORD nNumberOfBytesToLockHigh = MAXDWORD;
+ /* Must initialize OVERLAPPED struct */
+ OVERLAPPED overlapped = {0};
+
+ /* Get Windows HANDLE */
+ hFile = _get_osfhandle(fd);
+
+ /* Convert to Windows flags */
+ if(operation & LOCK_EX)
+ dwFlags |= LOCKFILE_EXCLUSIVE_LOCK;
+
+ /* Lock or unlock */
+ if(operation & LOCK_UN)
+ if(0 == UnlockFileEx(hFile, dwReserved, nNumberOfBytesToLockLow,
+ nNumberOfBytesToLockHigh, &overlapped))
+ return -1;
+ else
+ if(0 == LockFileEx(hFile, dwFlags, dwReserved, nNumberOfBytesToLockLow,
+ nNumberOfBytesToLockHigh, &overlapped))
+ return -1;
+#endif /* 0 */
+ return 0;
+} /* end Wflock() */
+
+#endif /* H5_HAVE_VISUAL_STUDIO */
/*-------------------------------------------------------------------------
diff --git a/src/H5trace.c b/src/H5trace.c
index f212bef..2fd75ac 100644
--- a/src/H5trace.c
+++ b/src/H5trace.c
@@ -155,8 +155,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
} /* end if */
/* Get time for event */
- if(HDfabs(first_time.etime) < 0.0000000001F)
- /* That is == 0.0, but direct comparison between floats is bad */
+ if(H5_DBL_ABS_EQUAL(first_time.etime, H5_DOUBLE(0.0)))
H5_timer_begin(&first_time);
if(H5_debug_g.ttimes)
H5_timer_begin(&event_time);
@@ -269,8 +268,8 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
fprintf(out, "NULL");
} /* end if */
else {
- hbool_t bool_var = va_arg(ap, hbool_t); /*lint !e732 Loss of sign not really occuring */
-
+ /* Can't pass hbool_t to va_arg() */
+ hbool_t bool_var = (hbool_t)va_arg(ap, int);
if(TRUE == bool_var)
fprintf(out, "TRUE");
else if(!bool_var)
diff --git a/src/H5win32defs.h b/src/H5win32defs.h
index 185e9b4..e84def9 100644
--- a/src/H5win32defs.h
+++ b/src/H5win32defs.h
@@ -74,6 +74,7 @@ struct timezone {
extern "C" {
#endif /* __cplusplus */
H5_DLL int Wgettimeofday(struct timeval *tv, struct timezone *tz);
+ H5_DLL int Wflock(int fd, int operation);
H5_DLL char* Wgetlogin(void);
H5_DLL int c99_snprintf(char* str, size_t size, const char* format, ...);
H5_DLL int c99_vsnprintf(char* str, size_t size, const char* format, va_list ap);
@@ -81,10 +82,11 @@ struct timezone {
}
#endif /* __cplusplus */
#define HDgettimeofday(V,Z) Wgettimeofday(V,Z)
+#define HDflock(F,L) Wflock(F,L)
#define HDgetlogin() Wgetlogin()
#define HDsnprintf c99_snprintf /*varargs*/
#define HDvsnprintf c99_vsnprintf
-
+
#endif /* H5_HAVE_VISUAL_STUDIO */
/* Non-POSIX functions */
diff --git a/src/Makefile.am b/src/Makefile.am
index 86dad23..d6a5909 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -73,7 +73,7 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \
H5HFhdr.c H5HFhuge.c H5HFiblock.c H5HFiter.c H5HFman.c H5HFsection.c \
H5HFspace.c H5HFstat.c H5HFtest.c H5HFtiny.c \
H5HG.c H5HGcache.c H5HGdbg.c H5HGquery.c \
- H5HL.c H5HLcache.c H5HLdbg.c H5HLint.c \
+ H5HL.c H5HLcache.c H5HLdbg.c H5HLint.c H5HLprfx.c H5HLdblk.c\
H5HP.c H5I.c H5Itest.c H5L.c H5Lexternal.c H5lib_settings.c \
H5MF.c H5MFaggr.c H5MFdbg.c H5MFsection.c \
H5MM.c H5MP.c H5MPtest.c \