From 7dded355b89ea66451955ee188841dcd14860c82 Mon Sep 17 00:00:00 2001 From: Dana Robinson <43805+derobins@users.noreply.github.com> Date: Tue, 1 Jun 2021 09:05:56 -0700 Subject: VFD SWMR: Sync with develop (#711) * Brings CMake updates from develop * Brings reduction in pedantic casts from develop * Purges UFAIL from the library (#637) * Committing clang-format changes * Purges UFAIL from the library * H5HL_insert change requested in PR Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Removes gratuitous (double)x.yF casts (#632) * Committing clang-format changes * Removes gratuitous (double)x.yF casts * Committing clang-format changes Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Committing clang-format changes * Cleans up a const warning left over from previous constification (#633) * Committing clang-format changes * Adds consts to a few global variables * Cleans up a const warning left over from previous constification Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Formatted source * Bring over some VOL registration changes * VOL cleanup * H5VL_request_status_t substitutions * H5F.c cleanup * Minor API tweaks from develop * Moves H5G package init/teardown to H5Gint.c * H5G cleanup * H5M cleanup * H5SM cleanup * H5T cleanup * H5R cleanup * H5Lpublic.h cleanup * H5L cleanup * H5O cleanup * H5A, H5CS, and H5AC cleanup * Moved H5A init/teardown code to H5Aint.c * Moves H5D I/O functions to H5D.c * H5D cleanup * Misc minor cleanup * H5P close cleanup * H5Tpublic.h cleanup * Fixes err_compat test * H5PLpublic.h cleanup * Updates H5Ppublic.h * H5Fpublic.h updates * H5A.c cleanup * Brings over H5Aexists and related changes * Brings CMake shell testing changes from develop * Close callback changes * H5R and H5Tcommit normalization * err_compat test works now * H5O tweaks * Updates VOL registration code * Brings over H5VL_create_object * H5Tconv.c reformatting * H5T.c tweaks * Brings datatype and reference updates from develop * Brings VOL plugin loading changes from develop * Brings event sets from develop * Brings async functions over * Tools changes * Brings over many tools changes from develop * Brings VOL flags from develop * Fixes h5dump double/float tests * Updates h5repack tests * Brings h5diff test changes from develop * Last h5dump changes * Brings test changes from develop * Committing clang-format changes * Tidied h5_testing() * Brings chunk iteration code + misc from develop * Updates vds test * Enables external link parallel test * Brings updated property lists from develop * H5G changes from develop * H5MF cleanup * Brings vfd_swmr test back into CMake * Updates threadsafe test * Updates plist test * Brings recent changes from develop * Require a C++11 compiler to build the C++ wrappers (#693) * Committing clang-format changes * Requires a C++11 compiler to build the C++ wrappers Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Fix H5FD_mpio_Debug="rw" can report MPI_count instead of bytes (#699) * Removes pre-C99 build and header cruft (#700) * Assumes ANSI C headers exist * Assumes stdbool.h, stdint.h, and inttypes.h are present * Assumes the C++ compiler can handle stdint.h * Removes all work-arounds for missing functionality, especially stdbool.h Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Updates release documents * Brings parallel changes from develop * Adds a VFD/parallel check program for the VFD SWMR shell test * Updates MANIFEST * Disable building VFD SWMR acceptance tests on CMake * Removes err.h from genall5.c * Partial cleanup of H5Cpkg.h * Fixes printf specifiers in H5Cdbg.c * Java and fortran cmake changes (#694) * OESS-98 convert plugin option to FetchContent, add tests * Fixes for pkcfg files because of plugin option * OESS-98 fix tools test for plugins * Keep doxygen comments under 100 chars long - format hint * Whitespace * HDFFV-11144 - Reclassify CMake messages * HDFFV-11099/11100 added help text * Reworked switch statement to compare string instead * Fix typo * Update CDash mode * Correct name of threadsafe * Correct option name * Undo accidental commit * Note LLVM 10 to 11 format default changes * Update format plugin * Undo clang-format version 11 changes * One more correction * Update supported platforms * Revert whitespace changes * Correct whitespace * Changes from PR#3 * HDFFV-11213 added option to control gcc10 warnings diagnostics * HDFFV-11212 Use the new references correctly in JNI utility and tests * format source * Fix typo * Add new test file * HDFFV-11212 - update test and remove unused arg * Minor non-space formatting changes * Use H5I_INVALID_ID instead of "-1" * source formatting * add missing testfile, update jni function * Undo commit of debug code * remove mislocated file * Fix h5repack test for handling of fapls and id close * Update h5diff test files usage text * HDFFV-11212 add new ref tests for JNI export dataset * src format update * Remove blank line typo * src format typo * long double requires %Lg * Another long double foramt specifer S.B. %Lg * issue with t128bit test * Windows issue with h5dump and type. * Fix review issues * refactor function nesting and fix error checks * format fixes * Remove untested functions and javadoc quiet comments * Restore TRY block. * Change string append errors to memory exception * revert to H5_JNI_FATAL_ERROR - support functions need work * Add assertion error for h5util functions * remove duplicate function * format fix * Revert HD function error handling * Update copyright comments * GH #386 java folder copyright corrections * Whitespace * GH #359 implement and fix tools 1.6 API usage * remove excessive comments * Flip inits to correct ifdef section * rework ifdef to be simpler * format issue * Reformat ifdef inits * remove static attribute * format compliance * Update names * Revert because logic relies on float not being int * Changes noticed from creating merge of #412 * Double underscore change * Correct compiler version variable used * Remove header guard underscores * Whitespace cleanup * Split format source and commit changes on repo push * remove pre-split setting * Change windows TS to use older VS. * correct window os name * HDFFV-11212 JNI export util and Javadoc * Suggested review changes * Another change found * Committing clang-format changes * HDFFV-11113 long double in tools * HDFFV-11113 add note * Disable long double tests for now * HDFFV-11228 remove arbitrary CMake warning groups. * Make each flag a string * Some Javadoc warning fixes * Updated javadoc fixes * # WARNING: head commit changed in the meantime HDFFV-11229 Fix long double usage in tools and java Changed h5dump and h5ls to just print 128-bit for long double type. Added test and file for dataset and attributes with all three float types. * Committing clang-format changes * HDFFV-11229 Add release note * HDFFV-11229 windows testfile needed * fix typo * Remove non supported message text * HDFFV-11229 - change ldouble test to check both native and general * HDFFV-11229 add second file compare * HDFFV-11229 fix reference file * HDFFV-11229 autotools check two refs * HDFFV-11229 revert back to removal of NATIVE_LDOUBLE in tools output * Committing clang-format changes * Update release note * Update attribute type of ref file * Change source of ninja for macs * try port instead of brew * Recommended is to use brew. * Undo non long double changes * remove unneeded file * Fix perl and doxygen CMake code * Add "option" command for clang options * Rework CMake add_custom to use the BYPRODUCTS argument * Add stamp files to BYPRODUCTS * Only one copy of file exists * Fix custom cmmand depends targets * Fix fortran custom command DEPENDS * Add LD_LIBRARY_PATH to tests * Add custom target for DEPENDS * Add h5detect conditionaly to generated target DEPENDS * Correct DEPENDS targets * Parallel builds need the mpi compiler for pkgconfig scripts. * install only if MPI build * Fortran target depends * Remove incorrect source attribute * doxygen adjustments * doxygen build updates * Correct version * Correct function version - function has been merged to 1.12 * Correct version string for map functions * Cleanup warnings for tools debug builds * TRILAB-227 - fix indexing for h5diff selections * Correct location of pos to index function call * TRILAB-227 Enable test * Quote subset args * Use MATCHES because of AppleClang * if blocks needed for build modes * Update list of DT platforms * VS2019 correctly displays float values * revert VS2019 change * Issue #669 remove version from pkgcfg filename * remove version from h5cc script * Java reference functions updated enabled fortran in cmake gcc action yaml file java reference test changed to correctly test refs jni reference functions that create ids changed to use jni id logging * Correct BYPRODUCTS argument * Correct more genereated files BYPRODUCTS * BYPRODUCTS must have unique locations * Fix typo Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Removes alternative function enter/leave macro scheme (#678) * Committing clang-format changes * Converted BEGIN_FUNC, etc. macros to FUNC_ENTER * Rips out the BEGIN_FUNC, etc. macros * Removes 'end if', etc. comments from H5HL package * Committing clang-format changes * Fixes an H5EA iterate issue * Fixes an issue in the H5FA iterator code * Further cleanup in bin/trace after macro removal * Iterator changes in H5EA and H5FA Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Split H5L.c internal code to H5Lint.c (#691) * Committing clang-format changes * Splits internal parts of H5L.c to H5Lint.c Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Clean up type size checks in configure.ac (#702) * Committing clang-format changes Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> --- .github/workflows/main.yml | 2 +- .github/workflows/pr-check.yml | 2 +- MANIFEST | 1 + bin/trace | 31 +- configure.ac | 39 +- fortran/src/CMakeLists.txt | 10 +- fortran/test/CMakeLists.txt | 4 +- hl/fortran/src/CMakeLists.txt | 4 +- java/src/hdf/hdf5lib/H5.java | 39 +- java/src/jni/h5rImp.c | 6 +- java/src/jni/h5rImp.h | 6 +- java/test/TestH5Rref.java | 136 +- src/CMakeLists.txt | 1 + src/H5.c | 4 - src/H5Cdbg.c | 6 +- src/H5Cpkg.h | 5835 +++++++++++++++++++++------------------- src/H5EA.c | 410 +-- src/H5EAcache.c | 699 ++--- src/H5EAdbg.c | 145 +- src/H5EAdblkpage.c | 126 +- src/H5EAdblock.c | 177 +- src/H5EAhdr.c | 317 ++- src/H5EAiblock.c | 169 +- src/H5EAint.c | 32 +- src/H5EAsblock.c | 164 +- src/H5EAstat.c | 14 +- src/H5EAtest.c | 183 +- src/H5Eprivate.h | 47 - src/H5FA.c | 337 +-- src/H5FAcache.c | 398 +-- src/H5FAdbg.c | 79 +- src/H5FAdblkpage.c | 121 +- src/H5FAdblock.c | 155 +- src/H5FAhdr.c | 263 +- src/H5FAint.c | 32 +- src/H5FAstat.c | 14 +- src/H5FAtest.c | 129 +- src/H5HL.c | 392 +-- src/H5HLcache.c | 24 +- src/H5HLdbg.c | 28 +- src/H5HLdblk.c | 82 +- src/H5HLint.c | 60 +- src/H5HLpkg.h | 2 +- src/H5HLprfx.c | 33 +- src/H5HLprivate.h | 2 +- src/H5L.c | 2176 +-------------- src/H5Lint.c | 2240 +++++++++++++++ src/H5Lprivate.h | 1 + src/H5private.h | 243 +- src/Makefile.am | 2 +- tools/lib/h5tools_error.h | 26 +- 51 files changed, 8169 insertions(+), 7279 deletions(-) create mode 100644 src/H5Lint.c diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d147d28..b0ebed0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -36,7 +36,7 @@ jobs: os: ubuntu-latest build_type: "Release" cpp: ON - fortran: OFF + fortran: ON java: ON ts: OFF hl: ON diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index eeb807d..d6081f4 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -31,7 +31,7 @@ jobs: os: ubuntu-latest build_type: "Release" cpp: ON - fortran: OFF + fortran: ON java: ON ts: OFF hl: ON diff --git a/MANIFEST b/MANIFEST index 9984fb4..4aee966 100644 --- a/MANIFEST +++ b/MANIFEST @@ -915,6 +915,7 @@ ./src/H5L.c ./src/H5Ldeprec.c ./src/H5Lexternal.c +./src/H5Lint.c ./src/H5Lmodule.h ./src/H5Lpkg.h ./src/H5Lprivate.h diff --git a/bin/trace b/bin/trace index a2052ce..0eef8ce 100755 --- a/bin/trace +++ b/bin/trace @@ -283,8 +283,8 @@ my $file_api = 0; my $file_args = 0; my $total_api = 0; my $total_args = 0; -sub rewrite_func ($$$$$$$$) { - my ($file, $begin, $type, $aftertype, $name, $args, $close, $body) = @_; +sub rewrite_func ($$$$$) { + my ($file, $type, $name, $args, $body) = @_; my ($arg, $trace, $argtrace); my (@arg_name, @arg_str, @arg_type); local $_; @@ -459,7 +459,7 @@ sub rewrite_func ($$$$$$$$) { } error: - return "\n$begin$type$aftertype$name($orig_args)$close$body"; + return "\n$type\n$name($orig_args)\n$body"; } ############################################################################## @@ -481,25 +481,12 @@ for $file (@ARGV) { # Make a copy of the original data my $original = $Source; - # Check which style of function declaration is used in this file - if ( $Source =~ /BEGIN_FUNC/ ) { - # Make modifications - $Source =~ s/\n(BEGIN_FUNC.*?\n) #begin - ([A-Za-z]\w*(\s+[A-Za-z]\w*)*\s*\**) #type - (.*?\n) #aftertype - (H5[A-Z]{0,2}_?[a-zA-Z0-9_]\w*) #name - \s*\((.*?)\)\s* #args - (\)) #close - (\n.*?\nEND_FUNC\([^\n]*) #body - /rewrite_func($file,$1,$2,$4,$5,$6,$7,$8)/segx; - } else { - # Make modifications - $Source =~ s/\n([A-Za-z]\w*(\s+[A-Za-z]\w*)*\s*\**)\n #type - (H5[A-Z]{0,2}_?[a-zA-Z0-9_]\w*) #name - \s*\((.*?)\)\s* #args - (\{.*?\n\}[^\n]*) #body - /rewrite_func($file,"",$1,"\n",$3,$4,"\n",$5)/segx; - } + # Make modifications + $Source =~ s/\n([A-Za-z]\w*(\s+[A-Za-z]\w*)*\s*\**)\n #type + (H5[A-Z]{0,2}_?[a-zA-Z0-9_]\w*) #name + \s*\((.*?)\)\s* #args + (\{.*?\n\}[^\n]*) #body + /rewrite_func($file,$1,$3,$4,$5)/segx; # If the source changed then print out the new version if ($original ne $Source) { diff --git a/configure.ac b/configure.ac index 09da906..50d0cea 100644 --- a/configure.ac +++ b/configure.ac @@ -1365,16 +1365,15 @@ CFLAGS="$H5_CFLAGS $AM_CFLAGS $CFLAGS" ## Checkpoint the cache AC_CACHE_SAVE -## Posix.1g types (C9x) +## Write the confdefs.h header for checking sizes cat >>confdefs.h <<\EOF -#include -EOF - -if test "X$C9x" = "Xyes"; then - cat >>confdefs.h <<\EOF +#include #include +#ifdef HAVE_UNISTD_H +#include +#endif +#include EOF -fi AC_CHECK_SIZEOF( [int8_t]) AC_CHECK_SIZEOF( [uint8_t]) @@ -1404,30 +1403,12 @@ AC_CHECK_SIZEOF([uint_least64_t]) AC_CHECK_SIZEOF( [int_fast64_t]) AC_CHECK_SIZEOF( [uint_fast64_t]) +AC_CHECK_SIZEOF([bool]) +AC_CHECK_SIZEOF([off_t]) +AC_CHECK_SIZEOF([ptrdiff_t]) AC_CHECK_SIZEOF([size_t]) AC_CHECK_SIZEOF([ssize_t]) -AC_CHECK_SIZEOF([ptrdiff_t]) - -cat >>confdefs.h <<\EOF -#include /*for off_t definition*/ -EOF -AC_CHECK_SIZEOF([off_t]) - -if test "X$C9x" = "Xyes"; then - cat >>confdefs.h <<\EOF -#include -EOF -AC_CHECK_SIZEOF([bool]) -fi - -AC_CHECK_SIZEOF(time_t, [], [ -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_TIME_H -#include -#endif -]) +AC_CHECK_SIZEOF([time_t]) ## Checkpoint the cache AC_CACHE_SAVE diff --git a/fortran/src/CMakeLists.txt b/fortran/src/CMakeLists.txt index d849086..e59a829 100644 --- a/fortran/src/CMakeLists.txt +++ b/fortran/src/CMakeLists.txt @@ -74,7 +74,7 @@ add_executable (H5match_types target_include_directories (H5match_types PRIVATE "${HDF5_SRC_BINARY_DIR};${HDF5_SRC_DIR};${HDF5_F90_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") add_custom_command (TARGET H5match_types POST_BUILD - BYPRODUCTS H5f90i_gen.h H5fortran_types.F90 + BYPRODUCTS ${HDF5_F90_BINARY_DIR}/H5f90i_gen.h ${HDF5_F90_BINARY_DIR}/H5fortran_types.F90 COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ WORKING_DIRECTORY ${HDF5_F90_BINARY_DIR} DEPENDS H5match_types @@ -82,7 +82,7 @@ add_custom_command (TARGET H5match_types POST_BUILD if (NOT ONLY_SHARED_LIBS) add_custom_command (TARGET H5match_types POST_BUILD - BYPRODUCTS H5f90i_gen.h H5fortran_types.F90 + BYPRODUCTS ${HDF5_F90_BINARY_DIR}/static/H5f90i_gen.h ${HDF5_F90_BINARY_DIR}/static/H5fortran_types.F90 COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${HDF5_F90_BINARY_DIR}/H5f90i_gen.h ${HDF5_F90_BINARY_DIR}/static/H5f90i_gen.h COMMAND ${CMAKE_COMMAND} @@ -95,7 +95,7 @@ if (NOT ONLY_SHARED_LIBS) endif () if (BUILD_SHARED_LIBS) add_custom_command (TARGET H5match_types POST_BUILD - BYPRODUCTS H5f90i_gen.h H5fortran_types.F90 + BYPRODUCTS ${HDF5_F90_BINARY_DIR}/shared/H5f90i_gen.h ${HDF5_F90_BINARY_DIR}/shared/H5fortran_types.F90 COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${HDF5_F90_BINARY_DIR}/H5f90i_gen.h ${HDF5_F90_BINARY_DIR}/shared/H5f90i_gen.h COMMAND ${CMAKE_COMMAND} @@ -235,7 +235,7 @@ add_custom_command (TARGET H5_buildiface POST_BUILD ) if (NOT ONLY_SHARED_LIBS) add_custom_command (TARGET H5_buildiface POST_BUILD - BYPRODUCTS H5_gen.F90 + BYPRODUCTS ${HDF5_F90_BINARY_DIR}/static/H5_gen.F90 COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${HDF5_F90_BINARY_DIR}/H5_gen.F90 ${HDF5_F90_BINARY_DIR}/static/H5_gen.F90 WORKING_DIRECTORY ${HDF5_F90_BINARY_DIR}/static @@ -250,7 +250,7 @@ endif () if (BUILD_SHARED_LIBS) add_custom_command (TARGET H5_buildiface POST_BUILD - BYPRODUCTS H5_gen.F90 + BYPRODUCTS ${HDF5_F90_BINARY_DIR}/shared/H5_gen.F90 COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${HDF5_F90_BINARY_DIR}/H5_gen.F90 ${HDF5_F90_BINARY_DIR}/shared/H5_gen.F90 WORKING_DIRECTORY ${HDF5_F90_BINARY_DIR}/shared diff --git a/fortran/test/CMakeLists.txt b/fortran/test/CMakeLists.txt index 147746c..1e879e7 100644 --- a/fortran/test/CMakeLists.txt +++ b/fortran/test/CMakeLists.txt @@ -92,7 +92,7 @@ endif () if (NOT BUILD_SHARED_LIBS) add_custom_command (TARGET H5_test_buildiface POST_BUILD - BYPRODUCTS tf_gen.F90 + BYPRODUCTS ${HDF5_FORTRAN_TESTS_BINARY_DIR}/static/tf_gen.F90 COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ WORKING_DIRECTORY ${HDF5_FORTRAN_TESTS_BINARY_DIR}/static DEPENDS H5_test_buildiface @@ -104,7 +104,7 @@ if (NOT BUILD_SHARED_LIBS) set_source_files_properties (${HDF5_FORTRAN_TESTS_BINARY_DIR}/static/tf_gen.F90 PROPERTIES GENERATED TRUE) else () add_custom_command (TARGET H5_test_buildiface POST_BUILD - BYPRODUCTS tf_gen.F90 + BYPRODUCTS ${HDF5_FORTRAN_TESTS_BINARY_DIR}/shared/tf_gen.F90 COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ WORKING_DIRECTORY ${HDF5_FORTRAN_TESTS_BINARY_DIR}/shared DEPENDS H5_test_buildiface diff --git a/hl/fortran/src/CMakeLists.txt b/hl/fortran/src/CMakeLists.txt index 6c97886..973299f 100644 --- a/hl/fortran/src/CMakeLists.txt +++ b/hl/fortran/src/CMakeLists.txt @@ -115,7 +115,7 @@ set (HDF5_HL_F90_F_BASE_SOURCES if (NOT ONLY_SHARED_LIBS) add_custom_command (TARGET H5HL_buildiface POST_BUILD - BYPRODUCTS $H5LTff_gen.F90 H5TBff_gen.F90 + BYPRODUCTS ${HDF5_HL_F90_BINARY_DIR}/static/H5LTff_gen.F90 ${HDF5_HL_F90_BINARY_DIR}/static/H5TBff_gen.F90 COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ WORKING_DIRECTORY ${HDF5_HL_F90_BINARY_DIR}/static DEPENDS ${HDF5_HL_F90_F_BASE_SOURCES} @@ -132,7 +132,7 @@ if (NOT ONLY_SHARED_LIBS) endif () if (BUILD_SHARED_LIBS) add_custom_command (TARGET H5HL_buildiface POST_BUILD - BYPRODUCTS H5LTff_gen.F90 H5TBff_gen.F90 + BYPRODUCTS ${HDF5_HL_F90_BINARY_DIR}/shared/H5LTff_gen.F90 ${HDF5_HL_F90_BINARY_DIR}/shared/H5TBff_gen.F90 COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ WORKING_DIRECTORY ${HDF5_HL_F90_BINARY_DIR}/shared DEPENDS ${HDF5_HL_F90_F_BASE_SOURCES} diff --git a/java/src/hdf/hdf5lib/H5.java b/java/src/hdf/hdf5lib/H5.java index aef0ba1..63547df 100644 --- a/java/src/hdf/hdf5lib/H5.java +++ b/java/src/hdf/hdf5lib/H5.java @@ -10726,7 +10726,18 @@ public class H5 implements java.io.Serializable { * @exception IllegalArgumentException * - an input array is invalid. **/ - public synchronized static native long H5Ropen_object(byte[] ref_ptr, long rapl_id, long oapl_id) + public static long H5Ropen_object(byte[] ref_ptr, long rapl_id, long oapl_id) + throws HDF5LibraryException, NullPointerException, IllegalArgumentException { + long id = _H5Ropen_object(ref_ptr, rapl_id, oapl_id); + if (id > 0) { + log.trace("OPEN_IDS: H5Ropen_object add {}", id); + OPEN_IDS.add(id); + log.trace("OPEN_IDS: {}", OPEN_IDS.size()); + } + return id; + } + + private synchronized static native long _H5Ropen_object(byte[] ref_ptr, long rapl_id, long oapl_id) throws HDF5LibraryException, NullPointerException, IllegalArgumentException; /** @@ -10754,7 +10765,18 @@ public class H5 implements java.io.Serializable { * @exception IllegalArgumentException * - an input array is invalid. **/ - public synchronized static native long H5Ropen_region(byte[] ref_ptr, long rapl_id, long oapl_id) + public static long H5Ropen_region(byte[] ref_ptr, long rapl_id, long oapl_id) + throws HDF5LibraryException, NullPointerException, IllegalArgumentException { + long id = _H5Ropen_region(ref_ptr, rapl_id, oapl_id); + if (id > 0) { + log.trace("OPEN_IDS: H5Ropen_region add {}", id); + OPEN_IDS.add(id); + log.trace("OPEN_IDS: {}", OPEN_IDS.size()); + } + return id; + } + + private synchronized static native long _H5Ropen_region(byte[] ref_ptr, long rapl_id, long oapl_id) throws HDF5LibraryException, NullPointerException, IllegalArgumentException; /** @@ -10782,7 +10804,18 @@ public class H5 implements java.io.Serializable { * @exception IllegalArgumentException * - an input array is invalid. **/ - public synchronized static native long H5Ropen_attr(byte[] ref_ptr, long rapl_id, long aapl_id) + public static long H5Ropen_attr(byte[] ref_ptr, long rapl_id, long aapl_id) + throws HDF5LibraryException, NullPointerException, IllegalArgumentException { + long id = _H5Ropen_attr(ref_ptr, rapl_id, aapl_id); + if (id > 0) { + log.trace("OPEN_IDS: H5Ropen_attr add {}", id); + OPEN_IDS.add(id); + log.trace("OPEN_IDS: {}", OPEN_IDS.size()); + } + return id; + } + + private synchronized static native long _H5Ropen_attr(byte[] ref_ptr, long rapl_id, long aapl_id) throws HDF5LibraryException, NullPointerException, IllegalArgumentException; // Get type // diff --git a/java/src/jni/h5rImp.c b/java/src/jni/h5rImp.c index c08f5de..9fe0701 100644 --- a/java/src/jni/h5rImp.c +++ b/java/src/jni/h5rImp.c @@ -336,7 +336,7 @@ done: * Signature: ([BJJ)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Ropen_1object(JNIEnv *env, jclass clss, jbyteArray ref, jlong rapl_id, jlong oapl_id) +Java_hdf_hdf5lib_H5__1H5Ropen_1object(JNIEnv *env, jclass clss, jbyteArray ref, jlong rapl_id, jlong oapl_id) { jboolean isCopy; jbyte * refBuf = NULL; @@ -371,7 +371,7 @@ done: * Signature: ([BJJ)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Ropen_1region(JNIEnv *env, jclass clss, jbyteArray ref, jlong rapl_id, jlong oapl_id) +Java_hdf_hdf5lib_H5__1H5Ropen_1region(JNIEnv *env, jclass clss, jbyteArray ref, jlong rapl_id, jlong oapl_id) { jboolean isCopy; jbyte * refBuf = NULL; @@ -406,7 +406,7 @@ done: * Signature: ([BJJ)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Ropen_1attr(JNIEnv *env, jclass clss, jbyteArray ref, jlong rapl_id, jlong aapl_id) +Java_hdf_hdf5lib_H5__1H5Ropen_1attr(JNIEnv *env, jclass clss, jbyteArray ref, jlong rapl_id, jlong aapl_id) { jboolean isCopy; jbyte * refBuf = NULL; diff --git a/java/src/jni/h5rImp.h b/java/src/jni/h5rImp.h index cdfdd8e..ffd7737 100644 --- a/java/src/jni/h5rImp.h +++ b/java/src/jni/h5rImp.h @@ -78,21 +78,21 @@ JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_H5_H5Rcopy(JNIEnv *, jclass, jbyte * Method: H5Ropen_object * Signature: ([BJJ)J */ -JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Ropen_1object(JNIEnv *, jclass, jbyteArray, jlong, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Ropen_1object(JNIEnv *, jclass, jbyteArray, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Ropen_region * Signature: ([BJJ)J */ -JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Ropen_1region(JNIEnv *, jclass, jbyteArray, jlong, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Ropen_1region(JNIEnv *, jclass, jbyteArray, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Ropen_attr * Signature: ([BJJ)J */ -JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Ropen_1attr(JNIEnv *, jclass, jbyteArray, jlong, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Ropen_1attr(JNIEnv *, jclass, jbyteArray, jlong, jlong); /* * Class: hdf_hdf5lib_H5 diff --git a/java/test/TestH5Rref.java b/java/test/TestH5Rref.java index cbdabdd..5733aae 100644 --- a/java/test/TestH5Rref.java +++ b/java/test/TestH5Rref.java @@ -134,7 +134,7 @@ public class TestH5Rref { try {H5.H5Tclose(f_type);} catch (Exception ex) {} } try { - ndims = H5.H5Sget_simple_extent_ndims(H5dsid); + ndims = (int)H5.H5Sget_simple_extent_npoints(H5dsid); } catch (Throwable err) { err.printStackTrace(); @@ -209,7 +209,7 @@ public class TestH5Rref { try {H5.H5Tclose(f_type);} catch (Exception ex) {} } try { - ndims = H5.H5Sget_simple_extent_ndims(H5dsid); + ndims = (int)H5.H5Sget_simple_extent_npoints(H5dsid); } catch (Throwable err) { err.printStackTrace(); @@ -286,7 +286,7 @@ public class TestH5Rref { try {H5.H5Tclose(f_type);} catch (Exception ex) {} } try { - ndims = H5.H5Sget_simple_extent_ndims(H5dsid); + ndims = (int)H5.H5Sget_simple_extent_npoints(H5dsid); } catch (Throwable err) { err.printStackTrace(); @@ -305,80 +305,81 @@ public class TestH5Rref { } for (int i = 0; i < ndims; i++) { try { - ret_val = H5.H5Rget_type(refbuf[i]); + try { + ret_val = H5.H5Rget_type(refbuf[i]); + } + catch (Throwable err) { + err.printStackTrace(); + fail("testH5Rget_region_dataset: H5Rget_type["+i+"]: " + err); + } assertTrue("testH5Rget_region_dataset: H5Rget_type["+i+"]="+ret_val, ret_val == ref_type); try { loc_id = H5.H5Ropen_object(refbuf[i], HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT); assertTrue(loc_id >= 0); - boolean regionzero = byteArrayCheck(refbuf[i]); - if (i > 1) - assertTrue(regionzero); - else { + try { + loc_sid = H5.H5Ropen_region(refbuf[i], HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT); + assertTrue(loc_sid >= 0); + int region_type = -1; try { - loc_sid = H5.H5Ropen_region(refbuf[i], HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT); - assertTrue(loc_sid >= 0); - int region_type = -1; - try { - int reg_ndims = H5.H5Sget_simple_extent_ndims(loc_sid); - region_type = H5.H5Sget_select_type(loc_sid); - if (i == 1) - assertTrue(region_type == HDF5Constants.H5S_SEL_POINTS); - else - assertTrue(region_type == HDF5Constants.H5S_SEL_HYPERSLABS); - if (region_type == HDF5Constants.H5S_SEL_POINTS) { - long reg_npoints = H5.H5Sget_select_elem_npoints(loc_sid); - // Coordinates for get point selection - long getcoord[] = new long[reg_ndims * (int)reg_npoints]; - // Known coordinates for point selection - long coord[][] = {{6,9},{2,2},{8,4},{1,6},{2,8},{3,2}, - {0,4},{9,0},{7,1},{3,3}}; - try { - H5.H5Sget_select_elem_pointlist(loc_sid, 0, reg_npoints, getcoord); - assertTrue("H5.H5Sget_select_elem_pointlist", coord[0][0] == getcoord[0]); - assertTrue("H5.H5Sget_select_elem_pointlist", coord[0][1] == getcoord[1]); - assertTrue("H5.H5Sget_select_elem_pointlist", coord[1][0] == getcoord[2]); - assertTrue("H5.H5Sget_select_elem_pointlist", coord[1][1] == getcoord[3]); - assertTrue("H5.H5Sget_select_elem_pointlist", coord[2][0] == getcoord[4]); - assertTrue("H5.H5Sget_select_elem_pointlist", coord[2][1] == getcoord[5]); - } - catch (Throwable err3) { - err3.printStackTrace(); - fail("H5.H5Sget_select_elem_pointlist: " + err3); - } + int reg_ndims = H5.H5Sget_simple_extent_ndims(loc_sid); + region_type = H5.H5Sget_select_type(loc_sid); + if (i == 1) + assertTrue(region_type == HDF5Constants.H5S_SEL_POINTS); + else + assertTrue(region_type == HDF5Constants.H5S_SEL_HYPERSLABS); + if (region_type == HDF5Constants.H5S_SEL_POINTS) { + long reg_npoints = H5.H5Sget_select_elem_npoints(loc_sid); + // Coordinates for get point selection + long getcoord[] = new long[reg_ndims * (int)reg_npoints]; + // Known coordinates for point selection + long coord[][] = {{6,9},{2,2},{8,4},{1,6},{2,8},{3,2}, + {0,4},{9,0},{7,1},{3,3}}; + try { + H5.H5Sget_select_elem_pointlist(loc_sid, 0, reg_npoints, getcoord); + assertTrue("H5.H5Sget_select_elem_pointlist", coord[0][0] == getcoord[0]); + assertTrue("H5.H5Sget_select_elem_pointlist", coord[0][1] == getcoord[1]); + assertTrue("H5.H5Sget_select_elem_pointlist", coord[1][0] == getcoord[2]); + assertTrue("H5.H5Sget_select_elem_pointlist", coord[1][1] == getcoord[3]); + assertTrue("H5.H5Sget_select_elem_pointlist", coord[2][0] == getcoord[4]); + assertTrue("H5.H5Sget_select_elem_pointlist", coord[2][1] == getcoord[5]); } - else if (region_type == HDF5Constants.H5S_SEL_HYPERSLABS) { - long reg_nblocks = H5.H5Sget_select_hyper_nblocks(loc_sid); - assertTrue("H5Sget_select_hyper_nblocks", reg_nblocks == 1); - // Coordinates for get block selection - long getblocks[] = new long[reg_ndims * (int)reg_nblocks * 2]; - long start[] = {2,2}; - long block[] = {8,8}; - try { - H5.H5Sget_select_hyper_blocklist(loc_sid, 0, reg_nblocks, getblocks); - assertTrue("H5.H5Sget_select_hyper_blocklist", start[0] == getblocks[0]); - assertTrue("H5.H5Sget_select_hyper_blocklist", start[1] == getblocks[1]); - assertTrue("H5.H5Sget_select_hyper_blocklist", (block[0]-1) == getblocks[2]); - assertTrue("H5.H5Sget_select_hyper_blocklist", (block[1]-1) == getblocks[3]); - } - catch (Throwable err3) { - err3.printStackTrace(); - fail("H5.H5Sget_select_hyper_blocklist: " + err3); - } + catch (Throwable err3) { + err3.printStackTrace(); + fail("H5.H5Sget_select_elem_pointlist: " + err3); } } - catch (Throwable err2) { - err2.printStackTrace(); - fail("testH5Rget_region_dataset: H5Sget_select_type: " + err2); + else if (region_type == HDF5Constants.H5S_SEL_HYPERSLABS) { + long reg_nblocks = H5.H5Sget_select_hyper_nblocks(loc_sid); + assertTrue("H5Sget_select_hyper_nblocks", reg_nblocks == 1); + // Coordinates for get block selection + long getblocks[] = new long[reg_ndims * (int)reg_nblocks * 2]; + long start[] = {2,2}; + long block[] = {8,8}; + try { + H5.H5Sget_select_hyper_blocklist(loc_sid, 0, reg_nblocks, getblocks); + assertTrue("H5.H5Sget_select_hyper_blocklist", start[0] == getblocks[0]); + assertTrue("H5.H5Sget_select_hyper_blocklist", start[1] == getblocks[1]); + assertTrue("H5.H5Sget_select_hyper_blocklist", (block[0]-1) == getblocks[2]); + assertTrue("H5.H5Sget_select_hyper_blocklist", (block[1]-1) == getblocks[3]); + } + catch (Throwable err3) { + err3.printStackTrace(); + fail("H5.H5Sget_select_hyper_blocklist: " + err3); + } } } - catch (Throwable err1) { - err1.printStackTrace(); - fail("testH5Rget_region_dataset: " + err1); - } - finally { - try {H5.H5Sclose(loc_sid);} catch (Exception ex) {} + catch (Throwable err2) { + err2.printStackTrace(); + assertTrue("testH5Rget_region_dataset: H5Sget_select_type: " + err2, i > 1); } } + catch (Throwable err1) { + err1.printStackTrace(); + fail("testH5Rget_region_dataset: " + err1); + } + finally { + try {H5.H5Sclose(loc_sid);} catch (Exception ex) {} + } } catch (Throwable err0) { err0.printStackTrace(); @@ -432,7 +433,7 @@ public class TestH5Rref { try {H5.H5Tclose(f_type);} catch (Exception ex) {} } try { - ndims = H5.H5Sget_simple_extent_ndims(H5dsid); + ndims = (int)H5.H5Sget_simple_extent_npoints(H5dsid); } catch (Throwable err) { err.printStackTrace(); @@ -473,7 +474,8 @@ public class TestH5Rref { } catch (Throwable err0) { err0.printStackTrace(); - fail("testH5Rget_region_attribute: " + err0); + // second attribute is null + assertTrue("testH5Rget_region_attribute: " + err0, i == 1); } finally { try {H5.H5Aclose(loc_id);} catch (Exception ex) {} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 79b695f..5ad2bae 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -403,6 +403,7 @@ set (H5L_SOURCES ${HDF5_SRC_DIR}/H5L.c ${HDF5_SRC_DIR}/H5Ldeprec.c ${HDF5_SRC_DIR}/H5Lexternal.c + ${HDF5_SRC_DIR}/H5Lint.c ) set (H5L_HDRS ${HDF5_SRC_DIR}/H5Lpublic.h diff --git a/src/H5.c b/src/H5.c index dca10f9..3454786 100644 --- a/src/H5.c +++ b/src/H5.c @@ -70,10 +70,6 @@ hbool_t H5_PKG_INIT_VAR = FALSE; /* Library Private Variables */ /*****************************/ -/* HDF5 API Entered variable */ -/* (move to H5.c when new FUNC_ENTER macros in actual use -QAK) */ -hbool_t H5_api_entered_g = FALSE; - /* statically initialize block for pthread_once call used in initializing */ /* the first global mutex */ #ifdef H5_HAVE_THREADSAFE diff --git a/src/H5Cdbg.c b/src/H5Cdbg.c index 7de25d4..4835727 100644 --- a/src/H5Cdbg.c +++ b/src/H5Cdbg.c @@ -381,7 +381,7 @@ H5C_dump_coll_write_list(H5C_t *cache_ptr, char *calling_fcn) list_len = (int)H5SL_count(cache_ptr->coll_write_list); HDfprintf(stdout, "\n\nDumping MDC coll write list from %d:%s.\n", aux_ptr->mpi_rank, calling_fcn); - HDfprintf(stdout, " slist len = %u.\n", cache_ptr->slist_len); + HDfprintf(stdout, " slist len = %" PRIu32 ".\n", cache_ptr->slist_len); if (list_len > 0) { @@ -983,8 +983,8 @@ H5C__dump_entry(H5C_t *cache_ptr, const H5C_cache_entry_t *entry_ptr, hbool_t du HDassert(cache_ptr); HDassert(entry_ptr); - HDfprintf(stderr, "%*s%s: entry_ptr = (%a, '%s', %a, %t, %u, %u/%u)\n", indent, "", prefix, - entry_ptr->addr, entry_ptr->type->name, + HDfprintf(stderr, "%*s%s: entry_ptr = (%" PRIxHADDR ", '%s', %" PRIxHADDR ", %d, %u, %u/%u)\n", indent, + "", prefix, entry_ptr->addr, entry_ptr->type->name, entry_ptr->tag_info ? entry_ptr->tag_info->tag : HADDR_UNDEF, entry_ptr->is_dirty, entry_ptr->flush_dep_nparents, entry_ptr->flush_dep_nchildren, entry_ptr->flush_dep_ndirty_children); diff --git a/src/H5Cpkg.h b/src/H5Cpkg.h index 99ba4bd..1cb4550 100644 --- a/src/H5Cpkg.h +++ b/src/H5Cpkg.h @@ -165,46 +165,83 @@ #if H5C_DO_SANITY_CHECKS -#define H5C__DLL_PRE_REMOVE_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ - if (((head_ptr) == NULL) || ((tail_ptr) == NULL) || ((entry_ptr) == NULL) || ((len) <= 0) || \ - ((Size) < (entry_ptr)->size) || (((entry_ptr)->prev == NULL) && ((head_ptr) != (entry_ptr))) || \ - (((entry_ptr)->next == NULL) && ((tail_ptr) != (entry_ptr))) || \ - (((len) == 1) && \ - (!(((head_ptr) == (entry_ptr)) && ((tail_ptr) == (entry_ptr)) && ((entry_ptr)->next == NULL) && \ - ((entry_ptr)->prev == NULL) && ((Size) == (entry_ptr)->size))))) { \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "DLL pre remove SC failed") \ - } - -#define H5C__DLL_SC(head_ptr, tail_ptr, len, Size, fv) \ - if (((((head_ptr) == NULL) || ((tail_ptr) == NULL)) && ((head_ptr) != (tail_ptr))) || ((len) < 0) || \ - ((Size) < 0) || \ - (((len) == 1) && \ - (((head_ptr) != (tail_ptr)) || ((head_ptr) == NULL) || ((head_ptr)->size != (Size)))) || \ - (((len) >= 1) && (((head_ptr) == NULL) || ((head_ptr)->prev != NULL) || ((tail_ptr) == NULL) || \ - ((tail_ptr)->next != NULL)))) { \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "DLL sanity check failed") \ - } - -#define H5C__DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ - if (((entry_ptr) == NULL) || ((entry_ptr)->next != NULL) || ((entry_ptr)->prev != NULL) || \ - ((((head_ptr) == NULL) || ((tail_ptr) == NULL)) && ((head_ptr) != (tail_ptr))) || \ - (((len) == 1) && \ - (((head_ptr) != (tail_ptr)) || ((head_ptr) == NULL) || ((head_ptr)->size != (Size)))) || \ - (((len) >= 1) && (((head_ptr) == NULL) || ((head_ptr)->prev != NULL) || ((tail_ptr) == NULL) || \ - ((tail_ptr)->next != NULL)))) { \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "DLL pre insert SC failed") \ - } - -#define H5C__DLL_PRE_SIZE_UPDATE_SC(dll_len, dll_size, old_size, new_size) \ - if (((dll_len) <= 0) || ((dll_size) <= 0) || ((old_size) <= 0) || ((old_size) > (dll_size)) || \ - ((new_size) <= 0) || (((dll_len) == 1) && ((old_size) != (dll_size)))) { \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "DLL pre size update SC failed") \ - } - -#define H5C__DLL_POST_SIZE_UPDATE_SC(dll_len, dll_size, old_size, new_size) \ - if (((new_size) > (dll_size)) || (((dll_len) == 1) && ((new_size) != (dll_size)))) { \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "DLL post size update SC failed") \ - } +#define H5C__DLL_PRE_REMOVE_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ +if ( ( (head_ptr) == NULL ) || \ + ( (tail_ptr) == NULL ) || \ + ( (entry_ptr) == NULL ) || \ + ( (len) <= 0 ) || \ + ( (Size) < (entry_ptr)->size ) || \ + ( ( (entry_ptr)->prev == NULL ) && ( (head_ptr) != (entry_ptr) ) ) || \ + ( ( (entry_ptr)->next == NULL ) && ( (tail_ptr) != (entry_ptr) ) ) || \ + ( ( (len) == 1 ) && \ + ( ! ( ( (head_ptr) == (entry_ptr) ) && \ + ( (tail_ptr) == (entry_ptr) ) && \ + ( (entry_ptr)->next == NULL ) && \ + ( (entry_ptr)->prev == NULL ) && \ + ( (Size) == (entry_ptr)->size ) \ + ) \ + ) \ + ) \ + ) { \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "DLL pre remove SC failed") \ +} + +#define H5C__DLL_SC(head_ptr, tail_ptr, len, Size, fv) \ +if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ + ( (head_ptr) != (tail_ptr) ) \ + ) || \ + ( (len) < 0 ) || \ + ( (Size) < 0 ) || \ + ( ( (len) == 1 ) && \ + ( ( (head_ptr) != (tail_ptr) ) || \ + ( (head_ptr) == NULL ) || ( (head_ptr)->size != (Size) ) \ + ) \ + ) || \ + ( ( (len) >= 1 ) && \ + ( ( (head_ptr) == NULL ) || ( (head_ptr)->prev != NULL ) || \ + ( (tail_ptr) == NULL ) || ( (tail_ptr)->next != NULL ) \ + ) \ + ) \ + ) { \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "DLL sanity check failed") \ +} + +#define H5C__DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ +if ( ( (entry_ptr) == NULL ) || \ + ( (entry_ptr)->next != NULL ) || \ + ( (entry_ptr)->prev != NULL ) || \ + ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ + ( (head_ptr) != (tail_ptr) ) \ + ) || \ + ( ( (len) == 1 ) && \ + ( ( (head_ptr) != (tail_ptr) ) || \ + ( (head_ptr) == NULL ) || ( (head_ptr)->size != (Size) ) \ + ) \ + ) || \ + ( ( (len) >= 1 ) && \ + ( ( (head_ptr) == NULL ) || ( (head_ptr)->prev != NULL ) || \ + ( (tail_ptr) == NULL ) || ( (tail_ptr)->next != NULL ) \ + ) \ + ) \ + ) { \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "DLL pre insert SC failed") \ +} + +#define H5C__DLL_PRE_SIZE_UPDATE_SC(dll_len, dll_size, old_size, new_size) \ +if ( ( (dll_len) <= 0 ) || \ + ( (dll_size) <= 0 ) || \ + ( (old_size) <= 0 ) || \ + ( (old_size) > (dll_size) ) || \ + ( (new_size) <= 0 ) || \ + ( ( (dll_len) == 1 ) && ( (old_size) != (dll_size) ) ) ) { \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "DLL pre size update SC failed") \ +} + +#define H5C__DLL_POST_SIZE_UPDATE_SC(dll_len, dll_size, old_size, new_size) \ +if ( ( (new_size) > (dll_size) ) || \ + ( ( (dll_len) == 1 ) && ( (new_size) != (dll_size) ) ) ) { \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "DLL post size update SC failed") \ +} #else /* H5C_DO_SANITY_CHECKS */ @@ -216,103 +253,144 @@ #endif /* H5C_DO_SANITY_CHECKS */ -#define H5C__DLL_APPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ - { \ - H5C__DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ - if ((head_ptr) == NULL) { \ - (head_ptr) = (entry_ptr); \ - (tail_ptr) = (entry_ptr); \ - } \ - else { \ - (tail_ptr)->next = (entry_ptr); \ - (entry_ptr)->prev = (tail_ptr); \ - (tail_ptr) = (entry_ptr); \ - } \ - (len)++; \ - (Size) += (entry_ptr)->size; \ - } /* H5C__DLL_APPEND() */ -#define H5C__DLL_PREPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ - { \ - H5C__DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ - if ((head_ptr) == NULL) { \ - (head_ptr) = (entry_ptr); \ - (tail_ptr) = (entry_ptr); \ - } \ - else { \ - (head_ptr)->prev = (entry_ptr); \ - (entry_ptr)->next = (head_ptr); \ - (head_ptr) = (entry_ptr); \ - } \ - (len)++; \ - (Size) += entry_ptr->size; \ - } /* H5C__DLL_PREPEND() */ - -#define H5C__DLL_REMOVE(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ - { \ - H5C__DLL_PRE_REMOVE_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ - { \ - if ((head_ptr) == (entry_ptr)) { \ - (head_ptr) = (entry_ptr)->next; \ - if ((head_ptr) != NULL) \ - (head_ptr)->prev = NULL; \ - } \ - else \ - (entry_ptr)->prev->next = (entry_ptr)->next; \ - if ((tail_ptr) == (entry_ptr)) { \ - (tail_ptr) = (entry_ptr)->prev; \ - if ((tail_ptr) != NULL) \ - (tail_ptr)->next = NULL; \ - } \ - else \ - (entry_ptr)->next->prev = (entry_ptr)->prev; \ - entry_ptr->next = NULL; \ - entry_ptr->prev = NULL; \ - (len)--; \ - (Size) -= entry_ptr->size; \ - } \ - } /* H5C__DLL_REMOVE() */ - -#define H5C__DLL_UPDATE_FOR_SIZE_CHANGE(dll_len, dll_size, old_size, new_size) \ - { \ - H5C__DLL_PRE_SIZE_UPDATE_SC(dll_len, dll_size, old_size, new_size) \ - (dll_size) -= (old_size); \ - (dll_size) += (new_size); \ - H5C__DLL_POST_SIZE_UPDATE_SC(dll_len, dll_size, old_size, new_size) \ - } /* H5C__DLL_UPDATE_FOR_SIZE_CHANGE() */ +#define H5C__DLL_APPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ +{ \ + H5C__DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, \ + fail_val) \ + if ( (head_ptr) == NULL ) \ + { \ + (head_ptr) = (entry_ptr); \ + (tail_ptr) = (entry_ptr); \ + } \ + else \ + { \ + (tail_ptr)->next = (entry_ptr); \ + (entry_ptr)->prev = (tail_ptr); \ + (tail_ptr) = (entry_ptr); \ + } \ + (len)++; \ + (Size) += (entry_ptr)->size; \ +} /* H5C__DLL_APPEND() */ + +#define H5C__DLL_PREPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ +{ \ + H5C__DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, \ + fail_val) \ + if ( (head_ptr) == NULL ) \ + { \ + (head_ptr) = (entry_ptr); \ + (tail_ptr) = (entry_ptr); \ + } \ + else \ + { \ + (head_ptr)->prev = (entry_ptr); \ + (entry_ptr)->next = (head_ptr); \ + (head_ptr) = (entry_ptr); \ + } \ + (len)++; \ + (Size) += entry_ptr->size; \ +} /* H5C__DLL_PREPEND() */ + +#define H5C__DLL_REMOVE(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ +{ \ + H5C__DLL_PRE_REMOVE_SC(entry_ptr, head_ptr, tail_ptr, len, Size, \ + fail_val) \ + { \ + if ( (head_ptr) == (entry_ptr) ) \ + { \ + (head_ptr) = (entry_ptr)->next; \ + if ( (head_ptr) != NULL ) \ + (head_ptr)->prev = NULL; \ + } \ + else \ + (entry_ptr)->prev->next = (entry_ptr)->next; \ + if ( (tail_ptr) == (entry_ptr) ) \ + { \ + (tail_ptr) = (entry_ptr)->prev; \ + if ( (tail_ptr) != NULL ) \ + (tail_ptr)->next = NULL; \ + } \ + else \ + (entry_ptr)->next->prev = (entry_ptr)->prev; \ + entry_ptr->next = NULL; \ + entry_ptr->prev = NULL; \ + (len)--; \ + (Size) -= entry_ptr->size; \ + } \ +} /* H5C__DLL_REMOVE() */ + +#define H5C__DLL_UPDATE_FOR_SIZE_CHANGE(dll_len, dll_size, old_size, new_size) \ +{ \ + H5C__DLL_PRE_SIZE_UPDATE_SC(dll_len, dll_size, old_size, new_size) \ + (dll_size) -= (old_size); \ + (dll_size) += (new_size); \ + H5C__DLL_POST_SIZE_UPDATE_SC(dll_len, dll_size, old_size, new_size) \ +} /* H5C__DLL_UPDATE_FOR_SIZE_CHANGE() */ #if H5C_DO_SANITY_CHECKS -#define H5C__AUX_DLL_PRE_REMOVE_SC(entry_ptr, hd_ptr, tail_ptr, len, Size, fv) \ - if (((hd_ptr) == NULL) || ((tail_ptr) == NULL) || ((entry_ptr) == NULL) || ((len) <= 0) || \ - ((Size) < (entry_ptr)->size) || (((Size) == (entry_ptr)->size) && (!((len) == 1))) || \ - (((entry_ptr)->aux_prev == NULL) && ((hd_ptr) != (entry_ptr))) || \ - (((entry_ptr)->aux_next == NULL) && ((tail_ptr) != (entry_ptr))) || \ - (((len) == 1) && \ - (!(((hd_ptr) == (entry_ptr)) && ((tail_ptr) == (entry_ptr)) && ((entry_ptr)->aux_next == NULL) && \ - ((entry_ptr)->aux_prev == NULL) && ((Size) == (entry_ptr)->size))))) { \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "aux DLL pre remove SC failed") \ - } - -#define H5C__AUX_DLL_SC(head_ptr, tail_ptr, len, Size, fv) \ - if (((((head_ptr) == NULL) || ((tail_ptr) == NULL)) && ((head_ptr) != (tail_ptr))) || ((len) < 0) || \ - ((Size) < 0) || \ - (((len) == 1) && (((head_ptr) != (tail_ptr)) || ((Size) <= 0) || ((head_ptr) == NULL) || \ - ((head_ptr)->size != (Size)))) || \ - (((len) >= 1) && (((head_ptr) == NULL) || ((head_ptr)->aux_prev != NULL) || ((tail_ptr) == NULL) || \ - ((tail_ptr)->aux_next != NULL)))) { \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "AUX DLL sanity check failed") \ - } - -#define H5C__AUX_DLL_PRE_INSERT_SC(entry_ptr, hd_ptr, tail_ptr, len, Size, fv) \ - if (((entry_ptr) == NULL) || ((entry_ptr)->aux_next != NULL) || ((entry_ptr)->aux_prev != NULL) || \ - ((((hd_ptr) == NULL) || ((tail_ptr) == NULL)) && ((hd_ptr) != (tail_ptr))) || \ - (((len) == 1) && \ - (((hd_ptr) != (tail_ptr)) || ((Size) <= 0) || ((hd_ptr) == NULL) || ((hd_ptr)->size != (Size)))) || \ - (((len) >= 1) && (((hd_ptr) == NULL) || ((hd_ptr)->aux_prev != NULL) || ((tail_ptr) == NULL) || \ - ((tail_ptr)->aux_next != NULL)))) { \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "AUX DLL pre insert SC failed") \ - } +#define H5C__AUX_DLL_PRE_REMOVE_SC(entry_ptr, hd_ptr, tail_ptr, len, Size, fv) \ +if ( ( (hd_ptr) == NULL ) || \ + ( (tail_ptr) == NULL ) || \ + ( (entry_ptr) == NULL ) || \ + ( (len) <= 0 ) || \ + ( (Size) < (entry_ptr)->size ) || \ + ( ( (Size) == (entry_ptr)->size ) && ( ! ( (len) == 1 ) ) ) || \ + ( ( (entry_ptr)->aux_prev == NULL ) && ( (hd_ptr) != (entry_ptr) ) ) || \ + ( ( (entry_ptr)->aux_next == NULL ) && ( (tail_ptr) != (entry_ptr) ) ) || \ + ( ( (len) == 1 ) && \ + ( ! ( ( (hd_ptr) == (entry_ptr) ) && ( (tail_ptr) == (entry_ptr) ) && \ + ( (entry_ptr)->aux_next == NULL ) && \ + ( (entry_ptr)->aux_prev == NULL ) && \ + ( (Size) == (entry_ptr)->size ) \ + ) \ + ) \ + ) \ + ) { \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "aux DLL pre remove SC failed") \ +} + +#define H5C__AUX_DLL_SC(head_ptr, tail_ptr, len, Size, fv) \ +if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ + ( (head_ptr) != (tail_ptr) ) \ + ) || \ + ( (len) < 0 ) || \ + ( (Size) < 0 ) || \ + ( ( (len) == 1 ) && \ + ( ( (head_ptr) != (tail_ptr) ) || ( (Size) <= 0 ) || \ + ( (head_ptr) == NULL ) || ( (head_ptr)->size != (Size) ) \ + ) \ + ) || \ + ( ( (len) >= 1 ) && \ + ( ( (head_ptr) == NULL ) || ( (head_ptr)->aux_prev != NULL ) || \ + ( (tail_ptr) == NULL ) || ( (tail_ptr)->aux_next != NULL ) \ + ) \ + ) \ + ) { \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "AUX DLL sanity check failed") \ +} + +#define H5C__AUX_DLL_PRE_INSERT_SC(entry_ptr, hd_ptr, tail_ptr, len, Size, fv) \ +if ( ( (entry_ptr) == NULL ) || \ + ( (entry_ptr)->aux_next != NULL ) || \ + ( (entry_ptr)->aux_prev != NULL ) || \ + ( ( ( (hd_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ + ( (hd_ptr) != (tail_ptr) ) \ + ) || \ + ( ( (len) == 1 ) && \ + ( ( (hd_ptr) != (tail_ptr) ) || ( (Size) <= 0 ) || \ + ( (hd_ptr) == NULL ) || ( (hd_ptr)->size != (Size) ) \ + ) \ + ) || \ + ( ( (len) >= 1 ) && \ + ( ( (hd_ptr) == NULL ) || ( (hd_ptr)->aux_prev != NULL ) || \ + ( (tail_ptr) == NULL ) || ( (tail_ptr)->aux_next != NULL ) \ + ) \ + ) \ + ) { \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "AUX DLL pre insert SC failed") \ +} #else /* H5C_DO_SANITY_CHECKS */ @@ -322,97 +400,135 @@ #endif /* H5C_DO_SANITY_CHECKS */ -#define H5C__AUX_DLL_APPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ - { \ - H5C__AUX_DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ - if ((head_ptr) == NULL) { \ - (head_ptr) = (entry_ptr); \ - (tail_ptr) = (entry_ptr); \ - } \ - else { \ - (tail_ptr)->aux_next = (entry_ptr); \ - (entry_ptr)->aux_prev = (tail_ptr); \ - (tail_ptr) = (entry_ptr); \ - } \ - (len)++; \ - (Size) += entry_ptr->size; \ - } /* H5C__AUX_DLL_APPEND() */ -#define H5C__AUX_DLL_PREPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ - { \ - H5C__AUX_DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ - if ((head_ptr) == NULL) { \ - (head_ptr) = (entry_ptr); \ - (tail_ptr) = (entry_ptr); \ - } \ - else { \ - (head_ptr)->aux_prev = (entry_ptr); \ - (entry_ptr)->aux_next = (head_ptr); \ - (head_ptr) = (entry_ptr); \ - } \ - (len)++; \ - (Size) += entry_ptr->size; \ - } /* H5C__AUX_DLL_PREPEND() */ - -#define H5C__AUX_DLL_REMOVE(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ - { \ - H5C__AUX_DLL_PRE_REMOVE_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ - { \ - if ((head_ptr) == (entry_ptr)) { \ - (head_ptr) = (entry_ptr)->aux_next; \ - if ((head_ptr) != NULL) \ - (head_ptr)->aux_prev = NULL; \ - } \ - else \ - (entry_ptr)->aux_prev->aux_next = (entry_ptr)->aux_next; \ - if ((tail_ptr) == (entry_ptr)) { \ - (tail_ptr) = (entry_ptr)->aux_prev; \ - if ((tail_ptr) != NULL) \ - (tail_ptr)->aux_next = NULL; \ - } \ - else \ - (entry_ptr)->aux_next->aux_prev = (entry_ptr)->aux_prev; \ - entry_ptr->aux_next = NULL; \ - entry_ptr->aux_prev = NULL; \ - (len)--; \ - (Size) -= entry_ptr->size; \ - } \ - } /* H5C__AUX_DLL_REMOVE() */ +#define H5C__AUX_DLL_APPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val)\ +{ \ + H5C__AUX_DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, \ + fail_val) \ + if ( (head_ptr) == NULL ) \ + { \ + (head_ptr) = (entry_ptr); \ + (tail_ptr) = (entry_ptr); \ + } \ + else \ + { \ + (tail_ptr)->aux_next = (entry_ptr); \ + (entry_ptr)->aux_prev = (tail_ptr); \ + (tail_ptr) = (entry_ptr); \ + } \ + (len)++; \ + (Size) += entry_ptr->size; \ +} /* H5C__AUX_DLL_APPEND() */ + +#define H5C__AUX_DLL_PREPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ +{ \ + H5C__AUX_DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ + if ( (head_ptr) == NULL ) \ + { \ + (head_ptr) = (entry_ptr); \ + (tail_ptr) = (entry_ptr); \ + } \ + else \ + { \ + (head_ptr)->aux_prev = (entry_ptr); \ + (entry_ptr)->aux_next = (head_ptr); \ + (head_ptr) = (entry_ptr); \ + } \ + (len)++; \ + (Size) += entry_ptr->size; \ +} /* H5C__AUX_DLL_PREPEND() */ + +#define H5C__AUX_DLL_REMOVE(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ +{ \ + H5C__AUX_DLL_PRE_REMOVE_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ + { \ + if ( (head_ptr) == (entry_ptr) ) \ + { \ + (head_ptr) = (entry_ptr)->aux_next; \ + if ( (head_ptr) != NULL ) \ + (head_ptr)->aux_prev = NULL; \ + } \ + else \ + (entry_ptr)->aux_prev->aux_next = (entry_ptr)->aux_next; \ + if ( (tail_ptr) == (entry_ptr) ) \ + { \ + (tail_ptr) = (entry_ptr)->aux_prev; \ + if ( (tail_ptr) != NULL ) \ + (tail_ptr)->aux_next = NULL; \ + } \ + else \ + (entry_ptr)->aux_next->aux_prev = (entry_ptr)->aux_prev; \ + entry_ptr->aux_next = NULL; \ + entry_ptr->aux_prev = NULL; \ + (len)--; \ + (Size) -= entry_ptr->size; \ + } \ +} /* H5C__AUX_DLL_REMOVE() */ #if H5C_DO_SANITY_CHECKS -#define H5C__IL_DLL_PRE_REMOVE_SC(entry_ptr, hd_ptr, tail_ptr, len, Size, fv) \ - if (((hd_ptr) == NULL) || ((tail_ptr) == NULL) || ((entry_ptr) == NULL) || ((len) <= 0) || \ - ((Size) < (entry_ptr)->size) || (((Size) == (entry_ptr)->size) && (!((len) == 1))) || \ - (((entry_ptr)->il_prev == NULL) && ((hd_ptr) != (entry_ptr))) || \ - (((entry_ptr)->il_next == NULL) && ((tail_ptr) != (entry_ptr))) || \ - (((len) == 1) && \ - (!(((hd_ptr) == (entry_ptr)) && ((tail_ptr) == (entry_ptr)) && ((entry_ptr)->il_next == NULL) && \ - ((entry_ptr)->il_prev == NULL) && ((Size) == (entry_ptr)->size))))) { \ - HDassert(0 && "il DLL pre remove SC failed"); \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "il DLL pre remove SC failed") \ - } - -#define H5C__IL_DLL_PRE_INSERT_SC(entry_ptr, hd_ptr, tail_ptr, len, Size, fv) \ - if (((entry_ptr) == NULL) || ((entry_ptr)->il_next != NULL) || ((entry_ptr)->il_prev != NULL) || \ - ((((hd_ptr) == NULL) || ((tail_ptr) == NULL)) && ((hd_ptr) != (tail_ptr))) || \ - (((len) == 1) && \ - (((hd_ptr) != (tail_ptr)) || ((Size) <= 0) || ((hd_ptr) == NULL) || ((hd_ptr)->size != (Size)))) || \ - (((len) >= 1) && (((hd_ptr) == NULL) || ((hd_ptr)->il_prev != NULL) || ((tail_ptr) == NULL) || \ - ((tail_ptr)->il_next != NULL)))) { \ - HDassert(0 && "IL DLL pre insert SC failed"); \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "IL DLL pre insert SC failed") \ - } - -#define H5C__IL_DLL_SC(head_ptr, tail_ptr, len, Size, fv) \ - if (((((head_ptr) == NULL) || ((tail_ptr) == NULL)) && ((head_ptr) != (tail_ptr))) || \ - (((len) == 1) && \ - (((head_ptr) != (tail_ptr)) || ((head_ptr) == NULL) || ((head_ptr)->size != (Size)))) || \ - (((len) >= 1) && (((head_ptr) == NULL) || ((head_ptr)->il_prev != NULL) || ((tail_ptr) == NULL) || \ - ((tail_ptr)->il_next != NULL)))) { \ - HDassert(0 && "IL DLL sanity check failed"); \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "IL DLL sanity check failed") \ - } +#define H5C__IL_DLL_PRE_REMOVE_SC(entry_ptr, hd_ptr, tail_ptr, len, Size, fv) \ +if ( ( (hd_ptr) == NULL ) || \ + ( (tail_ptr) == NULL ) || \ + ( (entry_ptr) == NULL ) || \ + ( (len) <= 0 ) || \ + ( (Size) < (entry_ptr)->size ) || \ + ( ( (Size) == (entry_ptr)->size ) && ( ! ( (len) == 1 ) ) ) || \ + ( ( (entry_ptr)->il_prev == NULL ) && ( (hd_ptr) != (entry_ptr) ) ) || \ + ( ( (entry_ptr)->il_next == NULL ) && ( (tail_ptr) != (entry_ptr) ) ) || \ + ( ( (len) == 1 ) && \ + ( ! ( ( (hd_ptr) == (entry_ptr) ) && ( (tail_ptr) == (entry_ptr) ) && \ + ( (entry_ptr)->il_next == NULL ) && \ + ( (entry_ptr)->il_prev == NULL ) && \ + ( (Size) == (entry_ptr)->size ) \ + ) \ + ) \ + ) \ + ) { \ + HDassert(0 && "il DLL pre remove SC failed"); \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "il DLL pre remove SC failed") \ +} + +#define H5C__IL_DLL_PRE_INSERT_SC(entry_ptr, hd_ptr, tail_ptr, len, Size, fv) \ +if ( ( (entry_ptr) == NULL ) || \ + ( (entry_ptr)->il_next != NULL ) || \ + ( (entry_ptr)->il_prev != NULL ) || \ + ( ( ( (hd_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ + ( (hd_ptr) != (tail_ptr) ) \ + ) || \ + ( ( (len) == 1 ) && \ + ( ( (hd_ptr) != (tail_ptr) ) || ( (Size) <= 0 ) || \ + ( (hd_ptr) == NULL ) || ( (hd_ptr)->size != (Size) ) \ + ) \ + ) || \ + ( ( (len) >= 1 ) && \ + ( ( (hd_ptr) == NULL ) || ( (hd_ptr)->il_prev != NULL ) || \ + ( (tail_ptr) == NULL ) || ( (tail_ptr)->il_next != NULL ) \ + ) \ + ) \ + ) { \ + HDassert(0 && "IL DLL pre insert SC failed"); \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "IL DLL pre insert SC failed") \ +} + +#define H5C__IL_DLL_SC(head_ptr, tail_ptr, len, Size, fv) \ +if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ + ( (head_ptr) != (tail_ptr) ) \ + ) || \ + ( ( (len) == 1 ) && \ + ( ( (head_ptr) != (tail_ptr) ) || \ + ( (head_ptr) == NULL ) || ( (head_ptr)->size != (Size) ) \ + ) \ + ) || \ + ( ( (len) >= 1 ) && \ + ( ( (head_ptr) == NULL ) || ( (head_ptr)->il_prev != NULL ) || \ + ( (tail_ptr) == NULL ) || ( (tail_ptr)->il_next != NULL ) \ + ) \ + ) \ + ) { \ + HDassert(0 && "IL DLL sanity check failed"); \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "IL DLL sanity check failed") \ +} #else /* H5C_DO_SANITY_CHECKS */ @@ -422,48 +538,55 @@ #endif /* H5C_DO_SANITY_CHECKS */ -#define H5C__IL_DLL_APPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ - { \ - H5C__IL_DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ - if ((head_ptr) == NULL) { \ - (head_ptr) = (entry_ptr); \ - (tail_ptr) = (entry_ptr); \ - } \ - else { \ - (tail_ptr)->il_next = (entry_ptr); \ - (entry_ptr)->il_prev = (tail_ptr); \ - (tail_ptr) = (entry_ptr); \ - } \ - (len)++; \ - (Size) += entry_ptr->size; \ - H5C__IL_DLL_SC(head_ptr, tail_ptr, len, Size, fail_val) \ - } /* H5C__IL_DLL_APPEND() */ -#define H5C__IL_DLL_REMOVE(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ - { \ - H5C__IL_DLL_PRE_REMOVE_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ - { \ - if ((head_ptr) == (entry_ptr)) { \ - (head_ptr) = (entry_ptr)->il_next; \ - if ((head_ptr) != NULL) \ - (head_ptr)->il_prev = NULL; \ - } \ - else \ - (entry_ptr)->il_prev->il_next = (entry_ptr)->il_next; \ - if ((tail_ptr) == (entry_ptr)) { \ - (tail_ptr) = (entry_ptr)->il_prev; \ - if ((tail_ptr) != NULL) \ - (tail_ptr)->il_next = NULL; \ - } \ - else \ - (entry_ptr)->il_next->il_prev = (entry_ptr)->il_prev; \ - entry_ptr->il_next = NULL; \ - entry_ptr->il_prev = NULL; \ - (len)--; \ - (Size) -= entry_ptr->size; \ - } \ - H5C__IL_DLL_SC(head_ptr, tail_ptr, len, Size, fv) \ - } /* H5C__IL_DLL_REMOVE() */ +#define H5C__IL_DLL_APPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val)\ +{ \ + H5C__IL_DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, \ + fail_val) \ + if ( (head_ptr) == NULL ) \ + { \ + (head_ptr) = (entry_ptr); \ + (tail_ptr) = (entry_ptr); \ + } \ + else \ + { \ + (tail_ptr)->il_next = (entry_ptr); \ + (entry_ptr)->il_prev = (tail_ptr); \ + (tail_ptr) = (entry_ptr); \ + } \ + (len)++; \ + (Size) += entry_ptr->size; \ + H5C__IL_DLL_SC(head_ptr, tail_ptr, len, Size, fail_val) \ +} /* H5C__IL_DLL_APPEND() */ + +#define H5C__IL_DLL_REMOVE(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ +{ \ + H5C__IL_DLL_PRE_REMOVE_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ + { \ + if ( (head_ptr) == (entry_ptr) ) \ + { \ + (head_ptr) = (entry_ptr)->il_next; \ + if ( (head_ptr) != NULL ) \ + (head_ptr)->il_prev = NULL; \ + } \ + else \ + (entry_ptr)->il_prev->il_next = (entry_ptr)->il_next; \ + if ( (tail_ptr) == (entry_ptr) ) \ + { \ + (tail_ptr) = (entry_ptr)->il_prev; \ + if ( (tail_ptr) != NULL ) \ + (tail_ptr)->il_next = NULL; \ + } \ + else \ + (entry_ptr)->il_next->il_prev = (entry_ptr)->il_prev; \ + entry_ptr->il_next = NULL; \ + entry_ptr->il_prev = NULL; \ + (len)--; \ + (Size) -= entry_ptr->size; \ + } \ + H5C__IL_DLL_SC(head_ptr, tail_ptr, len, Size, fv) \ +} /* H5C__IL_DLL_REMOVE() */ + /*********************************************************************** * @@ -478,297 +601,323 @@ * ***********************************************************************/ -#define H5C__UPDATE_CACHE_HIT_RATE_STATS(cache_ptr, hit) \ - (cache_ptr->cache_accesses)++; \ - if (hit) { \ - (cache_ptr->cache_hits)++; \ - } +#define H5C__UPDATE_CACHE_HIT_RATE_STATS(cache_ptr, hit) \ + (cache_ptr->cache_accesses)++; \ + if ( hit ) { \ + (cache_ptr->cache_hits)++; \ + } \ #if H5C_COLLECT_CACHE_STATS -#define H5C__UPDATE_MAX_INDEX_SIZE_STATS(cache_ptr) \ - if ((cache_ptr)->index_size > (cache_ptr)->max_index_size) \ - (cache_ptr)->max_index_size = (cache_ptr)->index_size; \ - if ((cache_ptr)->clean_index_size > (cache_ptr)->max_clean_index_size) \ - (cache_ptr)->max_clean_index_size = (cache_ptr)->clean_index_size; \ - if ((cache_ptr)->dirty_index_size > (cache_ptr)->max_dirty_index_size) \ - (cache_ptr)->max_dirty_index_size = (cache_ptr)->dirty_index_size; - -#define H5C__UPDATE_STATS_FOR_DIRTY_PIN(cache_ptr, entry_ptr) \ +#define H5C__UPDATE_MAX_INDEX_SIZE_STATS(cache_ptr) \ + if ( (cache_ptr)->index_size > (cache_ptr)->max_index_size ) \ + (cache_ptr)->max_index_size = (cache_ptr)->index_size; \ + if ( (cache_ptr)->clean_index_size > \ + (cache_ptr)->max_clean_index_size ) \ + (cache_ptr)->max_clean_index_size = \ + (cache_ptr)->clean_index_size; \ + if ( (cache_ptr)->dirty_index_size > \ + (cache_ptr)->max_dirty_index_size ) \ + (cache_ptr)->max_dirty_index_size = \ + (cache_ptr)->dirty_index_size; + +#define H5C__UPDATE_STATS_FOR_DIRTY_PIN(cache_ptr, entry_ptr) \ (((cache_ptr)->dirty_pins)[(entry_ptr)->type->id])++; -#define H5C__UPDATE_STATS_FOR_UNPROTECT(cache_ptr) \ - if ((cache_ptr)->slist_len > (cache_ptr)->max_slist_len) \ - (cache_ptr)->max_slist_len = (cache_ptr)->slist_len; \ - if ((cache_ptr)->slist_size > (cache_ptr)->max_slist_size) \ - (cache_ptr)->max_slist_size = (cache_ptr)->slist_size; \ - if ((cache_ptr)->pel_len > (cache_ptr)->max_pel_len) \ - (cache_ptr)->max_pel_len = (cache_ptr)->pel_len; \ - if ((cache_ptr)->pel_size > (cache_ptr)->max_pel_size) \ +#define H5C__UPDATE_STATS_FOR_UNPROTECT(cache_ptr) \ + if ( (cache_ptr)->slist_len > (cache_ptr)->max_slist_len ) \ + (cache_ptr)->max_slist_len = (cache_ptr)->slist_len; \ + if ( (cache_ptr)->slist_size > (cache_ptr)->max_slist_size ) \ + (cache_ptr)->max_slist_size = (cache_ptr)->slist_size; \ + if ( (cache_ptr)->pel_len > (cache_ptr)->max_pel_len ) \ + (cache_ptr)->max_pel_len = (cache_ptr)->pel_len; \ + if ( (cache_ptr)->pel_size > (cache_ptr)->max_pel_size ) \ (cache_ptr)->max_pel_size = (cache_ptr)->pel_size; -#define H5C__UPDATE_STATS_FOR_MOVE(cache_ptr, entry_ptr) \ - if (cache_ptr->flush_in_progress) \ - ((cache_ptr)->cache_flush_moves[(entry_ptr)->type->id])++; \ - if (entry_ptr->flush_in_progress) \ - ((cache_ptr)->entry_flush_moves[(entry_ptr)->type->id])++; \ - (((cache_ptr)->moves)[(entry_ptr)->type->id])++; \ - (cache_ptr)->entries_relocated_counter++; - -#define H5C__UPDATE_STATS_FOR_ENTRY_SIZE_CHANGE(cache_ptr, entry_ptr, new_size) \ - if (cache_ptr->flush_in_progress) \ - ((cache_ptr)->cache_flush_size_changes[(entry_ptr)->type->id])++; \ - if (entry_ptr->flush_in_progress) \ - ((cache_ptr)->entry_flush_size_changes[(entry_ptr)->type->id])++; \ - if ((entry_ptr)->size < (new_size)) { \ - ((cache_ptr)->size_increases[(entry_ptr)->type->id])++; \ - H5C__UPDATE_MAX_INDEX_SIZE_STATS(cache_ptr) \ - if ((cache_ptr)->slist_size > (cache_ptr)->max_slist_size) \ - (cache_ptr)->max_slist_size = (cache_ptr)->slist_size; \ - if ((cache_ptr)->pl_size > (cache_ptr)->max_pl_size) \ - (cache_ptr)->max_pl_size = (cache_ptr)->pl_size; \ - } \ - else if ((entry_ptr)->size > (new_size)) { \ - ((cache_ptr)->size_decreases[(entry_ptr)->type->id])++; \ - } - -#define H5C__UPDATE_STATS_FOR_HT_INSERTION(cache_ptr) (cache_ptr)->total_ht_insertions++; - -#define H5C__UPDATE_STATS_FOR_HT_DELETION(cache_ptr) (cache_ptr)->total_ht_deletions++; - -#define H5C__UPDATE_STATS_FOR_HT_SEARCH(cache_ptr, success, depth) \ - if (success) { \ - (cache_ptr)->successful_ht_searches++; \ - (cache_ptr)->total_successful_ht_search_depth += depth; \ - } \ - else { \ - (cache_ptr)->failed_ht_searches++; \ - (cache_ptr)->total_failed_ht_search_depth += depth; \ - } - -#define H5C__UPDATE_STATS_FOR_UNPIN(cache_ptr, entry_ptr) ((cache_ptr)->unpins)[(entry_ptr)->type->id]++; - -#define H5C__UPDATE_STATS_FOR_SLIST_SCAN_RESTART(cache_ptr) ((cache_ptr)->slist_scan_restarts)++; - -#define H5C__UPDATE_STATS_FOR_LRU_SCAN_RESTART(cache_ptr) ((cache_ptr)->LRU_scan_restarts)++; - -#define H5C__UPDATE_STATS_FOR_INDEX_SCAN_RESTART(cache_ptr) ((cache_ptr)->index_scan_restarts)++; - -#define H5C__UPDATE_STATS_FOR_CACHE_IMAGE_CREATE(cache_ptr) \ - { \ - (cache_ptr)->images_created++; \ +#define H5C__UPDATE_STATS_FOR_MOVE(cache_ptr, entry_ptr) \ + if ( cache_ptr->flush_in_progress ) \ + ((cache_ptr)->cache_flush_moves[(entry_ptr)->type->id])++; \ + if ( entry_ptr->flush_in_progress ) \ + ((cache_ptr)->entry_flush_moves[(entry_ptr)->type->id])++; \ + (((cache_ptr)->moves)[(entry_ptr)->type->id])++; \ + (cache_ptr)->entries_relocated_counter++; + +#define H5C__UPDATE_STATS_FOR_ENTRY_SIZE_CHANGE(cache_ptr, entry_ptr, new_size)\ + if ( cache_ptr->flush_in_progress ) \ + ((cache_ptr)->cache_flush_size_changes[(entry_ptr)->type->id])++; \ + if ( entry_ptr->flush_in_progress ) \ + ((cache_ptr)->entry_flush_size_changes[(entry_ptr)->type->id])++; \ + if ( (entry_ptr)->size < (new_size) ) { \ + ((cache_ptr)->size_increases[(entry_ptr)->type->id])++; \ + H5C__UPDATE_MAX_INDEX_SIZE_STATS(cache_ptr) \ + if ( (cache_ptr)->slist_size > (cache_ptr)->max_slist_size ) \ + (cache_ptr)->max_slist_size = (cache_ptr)->slist_size; \ + if ( (cache_ptr)->pl_size > (cache_ptr)->max_pl_size ) \ + (cache_ptr)->max_pl_size = (cache_ptr)->pl_size; \ + } else if ( (entry_ptr)->size > (new_size) ) { \ + ((cache_ptr)->size_decreases[(entry_ptr)->type->id])++; \ } -#define H5C__UPDATE_STATS_FOR_CACHE_IMAGE_READ(cache_ptr) \ - { \ - /* make sure image len is still good */ \ - HDassert((cache_ptr)->image_len > 0); \ - (cache_ptr)->images_read++; \ - } +#define H5C__UPDATE_STATS_FOR_HT_INSERTION(cache_ptr) \ + (cache_ptr)->total_ht_insertions++; -#define H5C__UPDATE_STATS_FOR_CACHE_IMAGE_LOAD(cache_ptr) \ - { \ - /* make sure image len is still good */ \ - HDassert((cache_ptr)->image_len > 0); \ - (cache_ptr)->images_loaded++; \ - (cache_ptr)->last_image_size = (cache_ptr)->image_len; \ - } +#define H5C__UPDATE_STATS_FOR_HT_DELETION(cache_ptr) \ + (cache_ptr)->total_ht_deletions++; -#define H5C__UPDATE_STATS_FOR_PREFETCH(cache_ptr, dirty) \ - { \ - (cache_ptr)->prefetches++; \ - if (dirty) \ - (cache_ptr)->dirty_prefetches++; \ +#define H5C__UPDATE_STATS_FOR_HT_SEARCH(cache_ptr, success, depth) \ + if ( success ) { \ + (cache_ptr)->successful_ht_searches++; \ + (cache_ptr)->total_successful_ht_search_depth += depth; \ + } else { \ + (cache_ptr)->failed_ht_searches++; \ + (cache_ptr)->total_failed_ht_search_depth += depth; \ } -#define H5C__UPDATE_STATS_FOR_PREFETCH_HIT(cache_ptr) \ - { \ - (cache_ptr)->prefetch_hits++; \ - } +#define H5C__UPDATE_STATS_FOR_UNPIN(cache_ptr, entry_ptr) \ + ((cache_ptr)->unpins)[(entry_ptr)->type->id]++; + +#define H5C__UPDATE_STATS_FOR_SLIST_SCAN_RESTART(cache_ptr) \ + ((cache_ptr)->slist_scan_restarts)++; + +#define H5C__UPDATE_STATS_FOR_LRU_SCAN_RESTART(cache_ptr) \ + ((cache_ptr)->LRU_scan_restarts)++; + +#define H5C__UPDATE_STATS_FOR_INDEX_SCAN_RESTART(cache_ptr) \ + ((cache_ptr)->index_scan_restarts)++; + +#define H5C__UPDATE_STATS_FOR_CACHE_IMAGE_CREATE(cache_ptr) \ +{ \ + (cache_ptr)->images_created++; \ +} + +#define H5C__UPDATE_STATS_FOR_CACHE_IMAGE_READ(cache_ptr) \ +{ \ + /* make sure image len is still good */ \ + HDassert((cache_ptr)->image_len > 0); \ + (cache_ptr)->images_read++; \ +} + +#define H5C__UPDATE_STATS_FOR_CACHE_IMAGE_LOAD(cache_ptr) \ +{ \ + /* make sure image len is still good */ \ + HDassert((cache_ptr)->image_len > 0); \ + (cache_ptr)->images_loaded++; \ + (cache_ptr)->last_image_size = (cache_ptr)->image_len; \ +} + +#define H5C__UPDATE_STATS_FOR_PREFETCH(cache_ptr, dirty) \ +{ \ + (cache_ptr)->prefetches++; \ + if ( dirty ) \ + (cache_ptr)->dirty_prefetches++; \ +} + +#define H5C__UPDATE_STATS_FOR_PREFETCH_HIT(cache_ptr) \ +{ \ + (cache_ptr)->prefetch_hits++; \ +} #if H5C_COLLECT_CACHE_ENTRY_STATS -#define H5C__RESET_CACHE_ENTRY_STATS(entry_ptr) \ - { \ - (entry_ptr)->accesses = 0; \ - (entry_ptr)->clears = 0; \ - (entry_ptr)->flushes = 0; \ - (entry_ptr)->pins = 0; \ - } - -#define H5C__UPDATE_STATS_FOR_CLEAR(cache_ptr, entry_ptr) \ - { \ - (((cache_ptr)->clears)[(entry_ptr)->type->id])++; \ - if ((entry_ptr)->is_pinned) \ - (((cache_ptr)->pinned_clears)[(entry_ptr)->type->id])++; \ - ((entry_ptr)->clears)++; \ - } - -#define H5C__UPDATE_STATS_FOR_FLUSH(cache_ptr, entry_ptr) \ - { \ - (((cache_ptr)->flushes)[(entry_ptr)->type->id])++; \ - if ((entry_ptr)->is_pinned) \ - (((cache_ptr)->pinned_flushes)[(entry_ptr)->type->id])++; \ - ((entry_ptr)->flushes)++; \ - } - -#define H5C__UPDATE_STATS_FOR_EVICTION(cache_ptr, entry_ptr, take_ownership) \ - { \ - if (take_ownership) \ - (((cache_ptr)->take_ownerships)[(entry_ptr)->type->id])++; \ - else \ - (((cache_ptr)->evictions)[(entry_ptr)->type->id])++; \ - if ((entry_ptr)->accesses > ((cache_ptr)->max_accesses)[(entry_ptr)->type->id]) \ - ((cache_ptr)->max_accesses)[(entry_ptr)->type->id] = (entry_ptr)->accesses; \ - if ((entry_ptr)->accesses < ((cache_ptr)->min_accesses)[(entry_ptr)->type->id]) \ - ((cache_ptr)->min_accesses)[(entry_ptr)->type->id] = (entry_ptr)->accesses; \ - if ((entry_ptr)->clears > ((cache_ptr)->max_clears)[(entry_ptr)->type->id]) \ - ((cache_ptr)->max_clears)[(entry_ptr)->type->id] = (entry_ptr)->clears; \ - if ((entry_ptr)->flushes > ((cache_ptr)->max_flushes)[(entry_ptr)->type->id]) \ - ((cache_ptr)->max_flushes)[(entry_ptr)->type->id] = (entry_ptr)->flushes; \ - if ((entry_ptr)->size > ((cache_ptr)->max_size)[(entry_ptr)->type->id]) \ - ((cache_ptr)->max_size)[(entry_ptr)->type->id] = (entry_ptr)->size; \ - if ((entry_ptr)->pins > ((cache_ptr)->max_pins)[(entry_ptr)->type->id]) \ - ((cache_ptr)->max_pins)[(entry_ptr)->type->id] = (entry_ptr)->pins; \ - } - -#define H5C__UPDATE_STATS_FOR_INSERTION(cache_ptr, entry_ptr) \ - { \ - (((cache_ptr)->insertions)[(entry_ptr)->type->id])++; \ - if ((entry_ptr)->is_pinned) { \ - (((cache_ptr)->pinned_insertions)[(entry_ptr)->type->id])++; \ - ((cache_ptr)->pins)[(entry_ptr)->type->id]++; \ - (entry_ptr)->pins++; \ - if ((cache_ptr)->pel_len > (cache_ptr)->max_pel_len) \ - (cache_ptr)->max_pel_len = (cache_ptr)->pel_len; \ - if ((cache_ptr)->pel_size > (cache_ptr)->max_pel_size) \ - (cache_ptr)->max_pel_size = (cache_ptr)->pel_size; \ - } \ - if ((cache_ptr)->index_len > (cache_ptr)->max_index_len) \ - (cache_ptr)->max_index_len = (cache_ptr)->index_len; \ - H5C__UPDATE_MAX_INDEX_SIZE_STATS(cache_ptr) \ - if ((cache_ptr)->slist_len > (cache_ptr)->max_slist_len) \ - (cache_ptr)->max_slist_len = (cache_ptr)->slist_len; \ - if ((cache_ptr)->slist_size > (cache_ptr)->max_slist_size) \ - (cache_ptr)->max_slist_size = (cache_ptr)->slist_size; \ - if ((entry_ptr)->size > ((cache_ptr)->max_size)[(entry_ptr)->type->id]) \ - ((cache_ptr)->max_size)[(entry_ptr)->type->id] = (entry_ptr)->size; \ - cache_ptr->entries_inserted_counter++; \ - } - -#define H5C__UPDATE_STATS_FOR_PROTECT(cache_ptr, entry_ptr, hit) \ - { \ - if (hit) \ - ((cache_ptr)->hits)[(entry_ptr)->type->id]++; \ - else \ - ((cache_ptr)->misses)[(entry_ptr)->type->id]++; \ - if (!((entry_ptr)->is_read_only)) { \ - ((cache_ptr)->write_protects)[(entry_ptr)->type->id]++; \ - } \ - else { \ - ((cache_ptr)->read_protects)[(entry_ptr)->type->id]++; \ - if (((entry_ptr)->ro_ref_count) > ((cache_ptr)->max_read_protects)[(entry_ptr)->type->id]) \ - ((cache_ptr)->max_read_protects)[(entry_ptr)->type->id] = ((entry_ptr)->ro_ref_count); \ - } \ - if ((cache_ptr)->index_len > (cache_ptr)->max_index_len) \ - (cache_ptr)->max_index_len = (cache_ptr)->index_len; \ - H5C__UPDATE_MAX_INDEX_SIZE_STATS(cache_ptr) \ - if ((cache_ptr)->pl_len > (cache_ptr)->max_pl_len) \ - (cache_ptr)->max_pl_len = (cache_ptr)->pl_len; \ - if ((cache_ptr)->pl_size > (cache_ptr)->max_pl_size) \ - (cache_ptr)->max_pl_size = (cache_ptr)->pl_size; \ - if ((entry_ptr)->size > ((cache_ptr)->max_size)[(entry_ptr)->type->id]) \ - ((cache_ptr)->max_size)[(entry_ptr)->type->id] = (entry_ptr)->size; \ - ((entry_ptr)->accesses)++; \ - } - -#define H5C__UPDATE_STATS_FOR_PIN(cache_ptr, entry_ptr) \ - { \ - ((cache_ptr)->pins)[(entry_ptr)->type->id]++; \ - (entry_ptr)->pins++; \ - if ((cache_ptr)->pel_len > (cache_ptr)->max_pel_len) \ - (cache_ptr)->max_pel_len = (cache_ptr)->pel_len; \ - if ((cache_ptr)->pel_size > (cache_ptr)->max_pel_size) \ - (cache_ptr)->max_pel_size = (cache_ptr)->pel_size; \ - } +#define H5C__RESET_CACHE_ENTRY_STATS(entry_ptr) \ +{ \ + (entry_ptr)->accesses = 0; \ + (entry_ptr)->clears = 0; \ + (entry_ptr)->flushes = 0; \ + (entry_ptr)->pins = 0; \ +} + +#define H5C__UPDATE_STATS_FOR_CLEAR(cache_ptr, entry_ptr) \ +{ \ + (((cache_ptr)->clears)[(entry_ptr)->type->id])++; \ + if((entry_ptr)->is_pinned) \ + (((cache_ptr)->pinned_clears)[(entry_ptr)->type->id])++; \ + ((entry_ptr)->clears)++; \ +} + +#define H5C__UPDATE_STATS_FOR_FLUSH(cache_ptr, entry_ptr) \ +{ \ + (((cache_ptr)->flushes)[(entry_ptr)->type->id])++; \ + if((entry_ptr)->is_pinned) \ + (((cache_ptr)->pinned_flushes)[(entry_ptr)->type->id])++; \ + ((entry_ptr)->flushes)++; \ +} + +#define H5C__UPDATE_STATS_FOR_EVICTION(cache_ptr, entry_ptr, take_ownership) \ +{ \ + if ( take_ownership ) \ + (((cache_ptr)->take_ownerships)[(entry_ptr)->type->id])++; \ + else \ + (((cache_ptr)->evictions)[(entry_ptr)->type->id])++; \ + if ( (entry_ptr)->accesses > \ + ((cache_ptr)->max_accesses)[(entry_ptr)->type->id] ) \ + ((cache_ptr)->max_accesses)[(entry_ptr)->type->id] = \ + (entry_ptr)->accesses; \ + if ( (entry_ptr)->accesses < \ + ((cache_ptr)->min_accesses)[(entry_ptr)->type->id] ) \ + ((cache_ptr)->min_accesses)[(entry_ptr)->type->id] = \ + (entry_ptr)->accesses; \ + if ( (entry_ptr)->clears > \ + ((cache_ptr)->max_clears)[(entry_ptr)->type->id] ) \ + ((cache_ptr)->max_clears)[(entry_ptr)->type->id] \ + = (entry_ptr)->clears; \ + if ( (entry_ptr)->flushes > \ + ((cache_ptr)->max_flushes)[(entry_ptr)->type->id] ) \ + ((cache_ptr)->max_flushes)[(entry_ptr)->type->id] \ + = (entry_ptr)->flushes; \ + if ( (entry_ptr)->size > \ + ((cache_ptr)->max_size)[(entry_ptr)->type->id] ) \ + ((cache_ptr)->max_size)[(entry_ptr)->type->id] \ + = (entry_ptr)->size; \ + if ( (entry_ptr)->pins > \ + ((cache_ptr)->max_pins)[(entry_ptr)->type->id] ) \ + ((cache_ptr)->max_pins)[(entry_ptr)->type->id] \ + = (entry_ptr)->pins; \ +} + +#define H5C__UPDATE_STATS_FOR_INSERTION(cache_ptr, entry_ptr) \ +{ \ + (((cache_ptr)->insertions)[(entry_ptr)->type->id])++; \ + if ( (entry_ptr)->is_pinned ) { \ + (((cache_ptr)->pinned_insertions)[(entry_ptr)->type->id])++; \ + ((cache_ptr)->pins)[(entry_ptr)->type->id]++; \ + (entry_ptr)->pins++; \ + if ( (cache_ptr)->pel_len > (cache_ptr)->max_pel_len ) \ + (cache_ptr)->max_pel_len = (cache_ptr)->pel_len; \ + if ( (cache_ptr)->pel_size > (cache_ptr)->max_pel_size ) \ + (cache_ptr)->max_pel_size = (cache_ptr)->pel_size; \ + } \ + if ( (cache_ptr)->index_len > (cache_ptr)->max_index_len ) \ + (cache_ptr)->max_index_len = (cache_ptr)->index_len; \ + H5C__UPDATE_MAX_INDEX_SIZE_STATS(cache_ptr) \ + if ( (cache_ptr)->slist_len > (cache_ptr)->max_slist_len ) \ + (cache_ptr)->max_slist_len = (cache_ptr)->slist_len; \ + if ( (cache_ptr)->slist_size > (cache_ptr)->max_slist_size ) \ + (cache_ptr)->max_slist_size = (cache_ptr)->slist_size; \ + if ( (entry_ptr)->size > \ + ((cache_ptr)->max_size)[(entry_ptr)->type->id] ) \ + ((cache_ptr)->max_size)[(entry_ptr)->type->id] \ + = (entry_ptr)->size; \ + cache_ptr->entries_inserted_counter++; \ +} + +#define H5C__UPDATE_STATS_FOR_PROTECT(cache_ptr, entry_ptr, hit) \ +{ \ + if ( hit ) \ + ((cache_ptr)->hits)[(entry_ptr)->type->id]++; \ + else \ + ((cache_ptr)->misses)[(entry_ptr)->type->id]++; \ + if ( ! ((entry_ptr)->is_read_only) ) { \ + ((cache_ptr)->write_protects)[(entry_ptr)->type->id]++; \ + } else { \ + ((cache_ptr)->read_protects)[(entry_ptr)->type->id]++; \ + if ( ((entry_ptr)->ro_ref_count) > \ + ((cache_ptr)->max_read_protects)[(entry_ptr)->type->id] ) \ + ((cache_ptr)->max_read_protects)[(entry_ptr)->type->id] = \ + ((entry_ptr)->ro_ref_count); \ + } \ + if ( (cache_ptr)->index_len > (cache_ptr)->max_index_len ) \ + (cache_ptr)->max_index_len = (cache_ptr)->index_len; \ + H5C__UPDATE_MAX_INDEX_SIZE_STATS(cache_ptr) \ + if ( (cache_ptr)->pl_len > (cache_ptr)->max_pl_len ) \ + (cache_ptr)->max_pl_len = (cache_ptr)->pl_len; \ + if ( (cache_ptr)->pl_size > (cache_ptr)->max_pl_size ) \ + (cache_ptr)->max_pl_size = (cache_ptr)->pl_size; \ + if ( (entry_ptr)->size > \ + ((cache_ptr)->max_size)[(entry_ptr)->type->id] ) \ + ((cache_ptr)->max_size)[(entry_ptr)->type->id] = (entry_ptr)->size; \ + ((entry_ptr)->accesses)++; \ +} + +#define H5C__UPDATE_STATS_FOR_PIN(cache_ptr, entry_ptr) \ +{ \ + ((cache_ptr)->pins)[(entry_ptr)->type->id]++; \ + (entry_ptr)->pins++; \ + if ( (cache_ptr)->pel_len > (cache_ptr)->max_pel_len ) \ + (cache_ptr)->max_pel_len = (cache_ptr)->pel_len; \ + if ( (cache_ptr)->pel_size > (cache_ptr)->max_pel_size ) \ + (cache_ptr)->max_pel_size = (cache_ptr)->pel_size; \ +} #else /* H5C_COLLECT_CACHE_ENTRY_STATS */ #define H5C__RESET_CACHE_ENTRY_STATS(entry_ptr) -#define H5C__UPDATE_STATS_FOR_CLEAR(cache_ptr, entry_ptr) \ - { \ - (((cache_ptr)->clears)[(entry_ptr)->type->id])++; \ - if ((entry_ptr)->is_pinned) \ - (((cache_ptr)->pinned_clears)[(entry_ptr)->type->id])++; \ - } - -#define H5C__UPDATE_STATS_FOR_FLUSH(cache_ptr, entry_ptr) \ - { \ - (((cache_ptr)->flushes)[(entry_ptr)->type->id])++; \ - if ((entry_ptr)->is_pinned) \ - (((cache_ptr)->pinned_flushes)[(entry_ptr)->type->id])++; \ - } - -#define H5C__UPDATE_STATS_FOR_EVICTION(cache_ptr, entry_ptr, take_ownership) \ - { \ - if (take_ownership) \ - (((cache_ptr)->take_ownerships)[(entry_ptr)->type->id])++; \ - else \ - (((cache_ptr)->evictions)[(entry_ptr)->type->id])++; \ - } - -#define H5C__UPDATE_STATS_FOR_INSERTION(cache_ptr, entry_ptr) \ - { \ - (((cache_ptr)->insertions)[(entry_ptr)->type->id])++; \ - if ((entry_ptr)->is_pinned) { \ - (((cache_ptr)->pinned_insertions)[(entry_ptr)->type->id])++; \ - ((cache_ptr)->pins)[(entry_ptr)->type->id]++; \ - if ((cache_ptr)->pel_len > (cache_ptr)->max_pel_len) \ - (cache_ptr)->max_pel_len = (cache_ptr)->pel_len; \ - if ((cache_ptr)->pel_size > (cache_ptr)->max_pel_size) \ - (cache_ptr)->max_pel_size = (cache_ptr)->pel_size; \ - } \ - if ((cache_ptr)->index_len > (cache_ptr)->max_index_len) \ - (cache_ptr)->max_index_len = (cache_ptr)->index_len; \ - H5C__UPDATE_MAX_INDEX_SIZE_STATS(cache_ptr) \ - if ((cache_ptr)->slist_len > (cache_ptr)->max_slist_len) \ - (cache_ptr)->max_slist_len = (cache_ptr)->slist_len; \ - if ((cache_ptr)->slist_size > (cache_ptr)->max_slist_size) \ - (cache_ptr)->max_slist_size = (cache_ptr)->slist_size; \ - cache_ptr->entries_inserted_counter++; \ - } - -#define H5C__UPDATE_STATS_FOR_PROTECT(cache_ptr, entry_ptr, hit) \ - { \ - if (hit) \ - ((cache_ptr)->hits)[(entry_ptr)->type->id]++; \ - else \ - ((cache_ptr)->misses)[(entry_ptr)->type->id]++; \ - if (!((entry_ptr)->is_read_only)) \ - ((cache_ptr)->write_protects)[(entry_ptr)->type->id]++; \ - else { \ - ((cache_ptr)->read_protects)[(entry_ptr)->type->id]++; \ - if (((entry_ptr)->ro_ref_count) > ((cache_ptr)->max_read_protects)[(entry_ptr)->type->id]) \ - ((cache_ptr)->max_read_protects)[(entry_ptr)->type->id] = ((entry_ptr)->ro_ref_count); \ - } \ - if ((cache_ptr)->index_len > (cache_ptr)->max_index_len) \ - (cache_ptr)->max_index_len = (cache_ptr)->index_len; \ - H5C__UPDATE_MAX_INDEX_SIZE_STATS(cache_ptr) \ - if ((cache_ptr)->pl_len > (cache_ptr)->max_pl_len) \ - (cache_ptr)->max_pl_len = (cache_ptr)->pl_len; \ - if ((cache_ptr)->pl_size > (cache_ptr)->max_pl_size) \ - (cache_ptr)->max_pl_size = (cache_ptr)->pl_size; \ - } - -#define H5C__UPDATE_STATS_FOR_PIN(cache_ptr, entry_ptr) \ - { \ - ((cache_ptr)->pins)[(entry_ptr)->type->id]++; \ - if ((cache_ptr)->pel_len > (cache_ptr)->max_pel_len) \ - (cache_ptr)->max_pel_len = (cache_ptr)->pel_len; \ - if ((cache_ptr)->pel_size > (cache_ptr)->max_pel_size) \ - (cache_ptr)->max_pel_size = (cache_ptr)->pel_size; \ - } +#define H5C__UPDATE_STATS_FOR_CLEAR(cache_ptr, entry_ptr) \ +{ \ + (((cache_ptr)->clears)[(entry_ptr)->type->id])++; \ + if((entry_ptr)->is_pinned) \ + (((cache_ptr)->pinned_clears)[(entry_ptr)->type->id])++; \ +} + +#define H5C__UPDATE_STATS_FOR_FLUSH(cache_ptr, entry_ptr) \ +{ \ + (((cache_ptr)->flushes)[(entry_ptr)->type->id])++; \ + if ( (entry_ptr)->is_pinned ) \ + (((cache_ptr)->pinned_flushes)[(entry_ptr)->type->id])++; \ +} + +#define H5C__UPDATE_STATS_FOR_EVICTION(cache_ptr, entry_ptr, take_ownership) \ +{ \ + if ( take_ownership ) \ + (((cache_ptr)->take_ownerships)[(entry_ptr)->type->id])++; \ + else \ + (((cache_ptr)->evictions)[(entry_ptr)->type->id])++; \ +} + +#define H5C__UPDATE_STATS_FOR_INSERTION(cache_ptr, entry_ptr) \ +{ \ + (((cache_ptr)->insertions)[(entry_ptr)->type->id])++; \ + if ( (entry_ptr)->is_pinned ) { \ + (((cache_ptr)->pinned_insertions)[(entry_ptr)->type->id])++; \ + ((cache_ptr)->pins)[(entry_ptr)->type->id]++; \ + if ( (cache_ptr)->pel_len > (cache_ptr)->max_pel_len ) \ + (cache_ptr)->max_pel_len = (cache_ptr)->pel_len; \ + if ( (cache_ptr)->pel_size > (cache_ptr)->max_pel_size ) \ + (cache_ptr)->max_pel_size = (cache_ptr)->pel_size; \ + } \ + if ( (cache_ptr)->index_len > (cache_ptr)->max_index_len ) \ + (cache_ptr)->max_index_len = (cache_ptr)->index_len; \ + H5C__UPDATE_MAX_INDEX_SIZE_STATS(cache_ptr) \ + if ( (cache_ptr)->slist_len > (cache_ptr)->max_slist_len ) \ + (cache_ptr)->max_slist_len = (cache_ptr)->slist_len; \ + if ( (cache_ptr)->slist_size > (cache_ptr)->max_slist_size ) \ + (cache_ptr)->max_slist_size = (cache_ptr)->slist_size; \ + cache_ptr->entries_inserted_counter++; \ +} + +#define H5C__UPDATE_STATS_FOR_PROTECT(cache_ptr, entry_ptr, hit) \ +{ \ + if ( hit ) \ + ((cache_ptr)->hits)[(entry_ptr)->type->id]++; \ + else \ + ((cache_ptr)->misses)[(entry_ptr)->type->id]++; \ + if ( ! ((entry_ptr)->is_read_only) ) \ + ((cache_ptr)->write_protects)[(entry_ptr)->type->id]++; \ + else { \ + ((cache_ptr)->read_protects)[(entry_ptr)->type->id]++; \ + if ( ((entry_ptr)->ro_ref_count) > \ + ((cache_ptr)->max_read_protects)[(entry_ptr)->type->id] ) \ + ((cache_ptr)->max_read_protects)[(entry_ptr)->type->id] = \ + ((entry_ptr)->ro_ref_count); \ + } \ + if ( (cache_ptr)->index_len > (cache_ptr)->max_index_len ) \ + (cache_ptr)->max_index_len = (cache_ptr)->index_len; \ + H5C__UPDATE_MAX_INDEX_SIZE_STATS(cache_ptr) \ + if ( (cache_ptr)->pl_len > (cache_ptr)->max_pl_len ) \ + (cache_ptr)->max_pl_len = (cache_ptr)->pl_len; \ + if ( (cache_ptr)->pl_size > (cache_ptr)->max_pl_size ) \ + (cache_ptr)->max_pl_size = (cache_ptr)->pl_size; \ +} + +#define H5C__UPDATE_STATS_FOR_PIN(cache_ptr, entry_ptr) \ +{ \ + ((cache_ptr)->pins)[(entry_ptr)->type->id]++; \ + if ( (cache_ptr)->pel_len > (cache_ptr)->max_pel_len ) \ + (cache_ptr)->max_pel_len = (cache_ptr)->pel_len; \ + if ( (cache_ptr)->pel_size > (cache_ptr)->max_pel_size ) \ + (cache_ptr)->max_pel_size = (cache_ptr)->pel_size; \ +} #endif /* H5C_COLLECT_CACHE_ENTRY_STATS */ @@ -845,9 +994,9 @@ /* H5C__HASH_TABLE_LEN is defined in H5Cpkg.h. It must be a power of two. */ -#define H5C__HASH_MASK ((size_t)(H5C__HASH_TABLE_LEN - 1) << 3) +#define H5C__HASH_MASK ((size_t)(H5C__HASH_TABLE_LEN - 1) << 3) -#define H5C__HASH_FCN(x) (int)((unsigned)((x)&H5C__HASH_MASK) >> 3) +#define H5C__HASH_FCN(x) (int)((unsigned)((x) & H5C__HASH_MASK) >> 3) /* H5C__PAGE_HASH_TABLE_LEN is defined in H5Cpkg.h. * It must ve a power of two. @@ -859,234 +1008,234 @@ #if H5C_DO_SANITY_CHECKS #define H5C__PRE_HT_INSERT_SC(cache_ptr, entry_ptr, fail_val) \ - if (((cache_ptr) == NULL) || ((cache_ptr)->magic != H5C__H5C_T_MAGIC) || ((entry_ptr) == NULL) || \ - (!H5F_addr_defined((entry_ptr)->addr)) || ((entry_ptr)->ht_next != NULL) || \ - ((entry_ptr)->ht_prev != NULL) || ((entry_ptr)->pi_next != NULL) || \ - ((entry_ptr)->pi_prev != NULL) || ((entry_ptr)->size <= 0) || \ - (H5C__HASH_FCN((entry_ptr)->addr) < 0) || \ - (H5C__HASH_FCN((entry_ptr)->addr) >= H5C__HASH_TABLE_LEN) || \ - ((cache_ptr)->index_size != ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size)) || \ - ((cache_ptr)->index_size < ((cache_ptr)->clean_index_size)) || \ - ((cache_ptr)->index_size < ((cache_ptr)->dirty_index_size)) || \ - ((entry_ptr)->ring <= H5C_RING_UNDEFINED) || ((entry_ptr)->ring >= H5C_RING_NTYPES) || \ - ((cache_ptr)->index_ring_len[(entry_ptr)->ring] > (cache_ptr)->index_len) || \ - ((cache_ptr)->index_ring_size[(entry_ptr)->ring] > (cache_ptr)->index_size) || \ - ((cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ - ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ - (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring])) || \ - ((cache_ptr)->index_len != (cache_ptr)->il_len) || \ - ((cache_ptr)->index_size != (cache_ptr)->il_size)) { \ - HDassert(FALSE); \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, fail_val, "pre HT insert SC failed") \ - } +if (((cache_ptr) == NULL) || ((cache_ptr)->magic != H5C__H5C_T_MAGIC) || ((entry_ptr) == NULL) || \ + (!H5F_addr_defined((entry_ptr)->addr)) || ((entry_ptr)->ht_next != NULL) || \ + ((entry_ptr)->ht_prev != NULL) || ((entry_ptr)->pi_next != NULL) || \ + ((entry_ptr)->pi_prev != NULL) || ((entry_ptr)->size <= 0) || \ + (H5C__HASH_FCN((entry_ptr)->addr) < 0) || \ + (H5C__HASH_FCN((entry_ptr)->addr) >= H5C__HASH_TABLE_LEN) || \ + ((cache_ptr)->index_size != ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size)) || \ + ((cache_ptr)->index_size < ((cache_ptr)->clean_index_size)) || \ + ((cache_ptr)->index_size < ((cache_ptr)->dirty_index_size)) || \ + ((entry_ptr)->ring <= H5C_RING_UNDEFINED) || ((entry_ptr)->ring >= H5C_RING_NTYPES) || \ + ((cache_ptr)->index_ring_len[(entry_ptr)->ring] > (cache_ptr)->index_len) || \ + ((cache_ptr)->index_ring_size[(entry_ptr)->ring] > (cache_ptr)->index_size) || \ + ((cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ + ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ + (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring])) || \ + ((cache_ptr)->index_len != (cache_ptr)->il_len) || \ + ((cache_ptr)->index_size != (cache_ptr)->il_size)) { \ + HDassert(FALSE); \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, fail_val, "pre HT insert SC failed") \ +} #define H5C__POST_HT_INSERT_SC(cache_ptr, entry_ptr, fail_val) \ - if (((cache_ptr) == NULL) || ((cache_ptr)->magic != H5C__H5C_T_MAGIC) || \ - ((cache_ptr)->index_size != ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size)) || \ - ((cache_ptr)->index_size < ((cache_ptr)->clean_index_size)) || \ - ((cache_ptr)->index_size < ((cache_ptr)->dirty_index_size)) || \ - ((cache_ptr)->index_ring_len[(entry_ptr)->ring] == 0) || \ - ((cache_ptr)->index_ring_len[(entry_ptr)->ring] > (cache_ptr)->index_len) || \ - ((cache_ptr)->index_ring_size[(entry_ptr)->ring] > (cache_ptr)->index_size) || \ - ((cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ - ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ - (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring])) || \ - ((cache_ptr)->index_len != (cache_ptr)->il_len) || \ - ((cache_ptr)->index_size != (cache_ptr)->il_size)) { \ - HDassert(FALSE); \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, fail_val, "post HT insert SC failed") \ - } +if (((cache_ptr) == NULL) || ((cache_ptr)->magic != H5C__H5C_T_MAGIC) || \ + ((cache_ptr)->index_size != ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size)) || \ + ((cache_ptr)->index_size < ((cache_ptr)->clean_index_size)) || \ + ((cache_ptr)->index_size < ((cache_ptr)->dirty_index_size)) || \ + ((cache_ptr)->index_ring_len[(entry_ptr)->ring] == 0) || \ + ((cache_ptr)->index_ring_len[(entry_ptr)->ring] > (cache_ptr)->index_len) || \ + ((cache_ptr)->index_ring_size[(entry_ptr)->ring] > (cache_ptr)->index_size) || \ + ((cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ + ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ + (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring])) || \ + ((cache_ptr)->index_len != (cache_ptr)->il_len) || \ + ((cache_ptr)->index_size != (cache_ptr)->il_size)) { \ + HDassert(FALSE); \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, fail_val, "post HT insert SC failed") \ +} #define H5C__PRE_HT_REMOVE_SC(cache_ptr, entry_ptr) \ - if (((cache_ptr) == NULL) || ((cache_ptr)->magic != H5C__H5C_T_MAGIC) || ((cache_ptr)->index_len < 1) || \ - ((entry_ptr) == NULL) || ((cache_ptr)->index_size < (entry_ptr)->size) || \ - (!H5F_addr_defined((entry_ptr)->addr)) || ((entry_ptr)->size <= 0) || \ - (H5C__HASH_FCN((entry_ptr)->addr) < 0) || \ - (H5C__HASH_FCN((entry_ptr)->addr) >= H5C__HASH_TABLE_LEN) || \ - (((cache_ptr)->index)[(H5C__HASH_FCN((entry_ptr)->addr))] == NULL) || \ - ((((cache_ptr)->index)[(H5C__HASH_FCN((entry_ptr)->addr))] != (entry_ptr)) && \ - ((entry_ptr)->ht_prev == NULL)) || \ - ((((cache_ptr)->index)[(H5C__HASH_FCN((entry_ptr)->addr))] == (entry_ptr)) && \ - ((entry_ptr)->ht_prev != NULL)) || \ - ((cache_ptr)->index_size != ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size)) || \ - (((cache_ptr)->vfd_swmr_reader) && \ - ((((cache_ptr)->page_index[(H5C__PI_HASH_FCN((entry_ptr)->page))] != (entry_ptr)) && \ - ((entry_ptr)->pi_prev == NULL)) || \ - (((cache_ptr)->page_index[(H5C__PI_HASH_FCN((entry_ptr)->page))] == (entry_ptr)) && \ - ((entry_ptr)->pi_prev != NULL)))) || \ - ((cache_ptr)->index_size < ((cache_ptr)->clean_index_size)) || \ - ((cache_ptr)->index_size < ((cache_ptr)->dirty_index_size)) || \ - ((entry_ptr)->ring <= H5C_RING_UNDEFINED) || ((entry_ptr)->ring >= H5C_RING_NTYPES) || \ - ((cache_ptr)->index_ring_len[(entry_ptr)->ring] <= 0) || \ - ((cache_ptr)->index_ring_len[(entry_ptr)->ring] > (cache_ptr)->index_len) || \ - ((cache_ptr)->index_ring_size[(entry_ptr)->ring] < (entry_ptr)->size) || \ - ((cache_ptr)->index_ring_size[(entry_ptr)->ring] > (cache_ptr)->index_size) || \ - ((cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ - ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ - (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring])) || \ - ((cache_ptr)->index_len != (cache_ptr)->il_len) || \ - ((cache_ptr)->index_size != (cache_ptr)->il_size)) { \ - HDassert(FALSE && "pre HT remove SC failed"); \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "pre HT remove SC failed") \ - } +if (((cache_ptr) == NULL) || ((cache_ptr)->magic != H5C__H5C_T_MAGIC) || ((cache_ptr)->index_len < 1) || \ + ((entry_ptr) == NULL) || ((cache_ptr)->index_size < (entry_ptr)->size) || \ + (!H5F_addr_defined((entry_ptr)->addr)) || ((entry_ptr)->size <= 0) || \ + (H5C__HASH_FCN((entry_ptr)->addr) < 0) || \ + (H5C__HASH_FCN((entry_ptr)->addr) >= H5C__HASH_TABLE_LEN) || \ + (((cache_ptr)->index)[(H5C__HASH_FCN((entry_ptr)->addr))] == NULL) || \ + ((((cache_ptr)->index)[(H5C__HASH_FCN((entry_ptr)->addr))] != (entry_ptr)) && \ + ((entry_ptr)->ht_prev == NULL)) || \ + ((((cache_ptr)->index)[(H5C__HASH_FCN((entry_ptr)->addr))] == (entry_ptr)) && \ + ((entry_ptr)->ht_prev != NULL)) || \ + ((cache_ptr)->index_size != ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size)) || \ + (((cache_ptr)->vfd_swmr_reader) && \ + ((((cache_ptr)->page_index[(H5C__PI_HASH_FCN((entry_ptr)->page))] != (entry_ptr)) && \ + ((entry_ptr)->pi_prev == NULL)) || \ + (((cache_ptr)->page_index[(H5C__PI_HASH_FCN((entry_ptr)->page))] == (entry_ptr)) && \ + ((entry_ptr)->pi_prev != NULL)))) || \ + ((cache_ptr)->index_size < ((cache_ptr)->clean_index_size)) || \ + ((cache_ptr)->index_size < ((cache_ptr)->dirty_index_size)) || \ + ((entry_ptr)->ring <= H5C_RING_UNDEFINED) || ((entry_ptr)->ring >= H5C_RING_NTYPES) || \ + ((cache_ptr)->index_ring_len[(entry_ptr)->ring] <= 0) || \ + ((cache_ptr)->index_ring_len[(entry_ptr)->ring] > (cache_ptr)->index_len) || \ + ((cache_ptr)->index_ring_size[(entry_ptr)->ring] < (entry_ptr)->size) || \ + ((cache_ptr)->index_ring_size[(entry_ptr)->ring] > (cache_ptr)->index_size) || \ + ((cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ + ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ + (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring])) || \ + ((cache_ptr)->index_len != (cache_ptr)->il_len) || \ + ((cache_ptr)->index_size != (cache_ptr)->il_size)) { \ + HDassert(FALSE && "pre HT remove SC failed"); \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "pre HT remove SC failed") \ +} #define H5C__POST_HT_REMOVE_SC(cache_ptr, entry_ptr) \ - if (((cache_ptr) == NULL) || ((cache_ptr)->magic != H5C__H5C_T_MAGIC) || ((entry_ptr) == NULL) || \ - (!H5F_addr_defined((entry_ptr)->addr)) || ((entry_ptr)->size <= 0) || \ - ((entry_ptr)->ht_prev != NULL) || ((entry_ptr)->ht_next != NULL) || \ - ((entry_ptr)->pi_prev != NULL) || ((entry_ptr)->pi_next != NULL) || \ - ((cache_ptr)->index_size != ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size)) || \ - ((cache_ptr)->index_size < ((cache_ptr)->clean_index_size)) || \ - ((cache_ptr)->index_size < ((cache_ptr)->dirty_index_size)) || \ - ((cache_ptr)->index_ring_len[(entry_ptr)->ring] > (cache_ptr)->index_len) || \ - ((cache_ptr)->index_ring_size[(entry_ptr)->ring] > (cache_ptr)->index_size) || \ - ((cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ - ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ - (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring])) || \ - ((cache_ptr)->index_len != (cache_ptr)->il_len) || \ - ((cache_ptr)->index_size != (cache_ptr)->il_size)) { \ - HDassert(FALSE && "post HT remove SC failed"); \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "post HT remove SC failed") \ - } +if (((cache_ptr) == NULL) || ((cache_ptr)->magic != H5C__H5C_T_MAGIC) || ((entry_ptr) == NULL) || \ + (!H5F_addr_defined((entry_ptr)->addr)) || ((entry_ptr)->size <= 0) || \ + ((entry_ptr)->ht_prev != NULL) || ((entry_ptr)->ht_next != NULL) || \ + ((entry_ptr)->pi_prev != NULL) || ((entry_ptr)->pi_next != NULL) || \ + ((cache_ptr)->index_size != ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size)) || \ + ((cache_ptr)->index_size < ((cache_ptr)->clean_index_size)) || \ + ((cache_ptr)->index_size < ((cache_ptr)->dirty_index_size)) || \ + ((cache_ptr)->index_ring_len[(entry_ptr)->ring] > (cache_ptr)->index_len) || \ + ((cache_ptr)->index_ring_size[(entry_ptr)->ring] > (cache_ptr)->index_size) || \ + ((cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ + ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ + (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring])) || \ + ((cache_ptr)->index_len != (cache_ptr)->il_len) || \ + ((cache_ptr)->index_size != (cache_ptr)->il_size)) { \ + HDassert(FALSE && "post HT remove SC failed"); \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "post HT remove SC failed") \ +} /* (Keep in sync w/H5C_TEST__PRE_HT_SEARCH_SC macro in test/cache_common.h -QAK) */ #define H5C__PRE_HT_SEARCH_SC(cache_ptr, Addr, fail_val) \ - if (((cache_ptr) == NULL) || ((cache_ptr)->magic != H5C__H5C_T_MAGIC) || \ - ((cache_ptr)->index_size != ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size)) || \ - (!H5F_addr_defined(Addr)) || (H5C__HASH_FCN(Addr) < 0) || \ - (H5C__HASH_FCN(Addr) >= H5C__HASH_TABLE_LEN)) { \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, fail_val, "pre HT search SC failed") \ - } +if (((cache_ptr) == NULL) || ((cache_ptr)->magic != H5C__H5C_T_MAGIC) || \ + ((cache_ptr)->index_size != ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size)) || \ + (!H5F_addr_defined(Addr)) || (H5C__HASH_FCN(Addr) < 0) || \ + (H5C__HASH_FCN(Addr) >= H5C__HASH_TABLE_LEN)) { \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, fail_val, "pre HT search SC failed") \ +} /* (Keep in sync w/H5C_TEST__POST_SUC_HT_SEARCH_SC macro in - * test/cache_common.h -QAK) - */ +* test/cache_common.h -QAK) +*/ #define H5C__POST_SUC_HT_SEARCH_SC(cache_ptr, entry_ptr, k, fail_val) \ - if (((cache_ptr) == NULL) || ((cache_ptr)->magic != H5C__H5C_T_MAGIC) || ((cache_ptr)->index_len < 1) || \ - ((entry_ptr) == NULL) || ((cache_ptr)->index_size < (entry_ptr)->size) || \ - ((cache_ptr)->index_size != ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size)) || \ - ((entry_ptr)->size <= 0) || (((cache_ptr)->index)[k] == NULL) || \ - ((((cache_ptr)->index)[k] != (entry_ptr)) && ((entry_ptr)->ht_prev == NULL)) || \ - ((((cache_ptr)->index)[k] == (entry_ptr)) && ((entry_ptr)->ht_prev != NULL)) || \ - (((entry_ptr)->ht_prev != NULL) && ((entry_ptr)->ht_prev->ht_next != (entry_ptr))) || \ - (((entry_ptr)->ht_next != NULL) && ((entry_ptr)->ht_next->ht_prev != (entry_ptr)))) { \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, fail_val, "post successful HT search SC failed") \ - } +if (((cache_ptr) == NULL) || ((cache_ptr)->magic != H5C__H5C_T_MAGIC) || ((cache_ptr)->index_len < 1) || \ + ((entry_ptr) == NULL) || ((cache_ptr)->index_size < (entry_ptr)->size) || \ + ((cache_ptr)->index_size != ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size)) || \ + ((entry_ptr)->size <= 0) || (((cache_ptr)->index)[k] == NULL) || \ + ((((cache_ptr)->index)[k] != (entry_ptr)) && ((entry_ptr)->ht_prev == NULL)) || \ + ((((cache_ptr)->index)[k] == (entry_ptr)) && ((entry_ptr)->ht_prev != NULL)) || \ + (((entry_ptr)->ht_prev != NULL) && ((entry_ptr)->ht_prev->ht_next != (entry_ptr))) || \ + (((entry_ptr)->ht_next != NULL) && ((entry_ptr)->ht_next->ht_prev != (entry_ptr)))) { \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, fail_val, "post successful HT search SC failed") \ +} /* (Keep in sync w/H5C_TEST__POST_HT_SHIFT_TO_FRONT macro in - * test/cache_common.h -QAK) - */ +* test/cache_common.h -QAK) +*/ #define H5C__POST_HT_SHIFT_TO_FRONT(cache_ptr, entry_ptr, k, fail_val) \ - if (((cache_ptr) == NULL) || (((cache_ptr)->index)[k] != (entry_ptr)) || \ - ((entry_ptr)->ht_prev != NULL)) { \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, fail_val, "post HT shift to front SC failed") \ - } +if (((cache_ptr) == NULL) || (((cache_ptr)->index)[k] != (entry_ptr)) || \ + ((entry_ptr)->ht_prev != NULL)) { \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, fail_val, "post HT shift to front SC failed") \ +} #define H5C__PRE_HT_ENTRY_SIZE_CHANGE_SC(cache_ptr, old_size, new_size, entry_ptr, was_clean) \ - if (((cache_ptr) == NULL) || ((cache_ptr)->index_len <= 0) || ((cache_ptr)->index_size <= 0) || \ - ((new_size) <= 0) || ((old_size) > (cache_ptr)->index_size) || \ - (((cache_ptr)->index_len == 1) && ((cache_ptr)->index_size != (old_size))) || \ - ((cache_ptr)->index_size != ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size)) || \ - ((cache_ptr)->index_size < ((cache_ptr)->clean_index_size)) || \ - ((cache_ptr)->index_size < ((cache_ptr)->dirty_index_size)) || \ - ((!(was_clean) || ((cache_ptr)->clean_index_size < (old_size))) && \ - (((was_clean)) || ((cache_ptr)->dirty_index_size < (old_size)))) || \ - ((entry_ptr) == NULL) || ((entry_ptr)->ring <= H5C_RING_UNDEFINED) || \ - ((entry_ptr)->ring >= H5C_RING_NTYPES) || ((cache_ptr)->index_ring_len[(entry_ptr)->ring] <= 0) || \ - ((cache_ptr)->index_ring_len[(entry_ptr)->ring] > (cache_ptr)->index_len) || \ - ((cache_ptr)->index_ring_size[(entry_ptr)->ring] > (cache_ptr)->index_size) || \ - ((cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ - ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ - (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring])) || \ - ((cache_ptr)->index_len != (cache_ptr)->il_len) || \ - ((cache_ptr)->index_size != (cache_ptr)->il_size)) { \ - HDassert(FALSE); \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "pre HT entry size change SC failed") \ - } +if (((cache_ptr) == NULL) || ((cache_ptr)->index_len <= 0) || ((cache_ptr)->index_size <= 0) || \ + ((new_size) <= 0) || ((old_size) > (cache_ptr)->index_size) || \ + (((cache_ptr)->index_len == 1) && ((cache_ptr)->index_size != (old_size))) || \ + ((cache_ptr)->index_size != ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size)) || \ + ((cache_ptr)->index_size < ((cache_ptr)->clean_index_size)) || \ + ((cache_ptr)->index_size < ((cache_ptr)->dirty_index_size)) || \ + ((!(was_clean) || ((cache_ptr)->clean_index_size < (old_size))) && \ + (((was_clean)) || ((cache_ptr)->dirty_index_size < (old_size)))) || \ + ((entry_ptr) == NULL) || ((entry_ptr)->ring <= H5C_RING_UNDEFINED) || \ + ((entry_ptr)->ring >= H5C_RING_NTYPES) || ((cache_ptr)->index_ring_len[(entry_ptr)->ring] <= 0) || \ + ((cache_ptr)->index_ring_len[(entry_ptr)->ring] > (cache_ptr)->index_len) || \ + ((cache_ptr)->index_ring_size[(entry_ptr)->ring] > (cache_ptr)->index_size) || \ + ((cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ + ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ + (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring])) || \ + ((cache_ptr)->index_len != (cache_ptr)->il_len) || \ + ((cache_ptr)->index_size != (cache_ptr)->il_size)) { \ + HDassert(FALSE); \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "pre HT entry size change SC failed") \ +} #define H5C__POST_HT_ENTRY_SIZE_CHANGE_SC(cache_ptr, old_size, new_size, entry_ptr) \ - if (((cache_ptr) == NULL) || ((cache_ptr)->index_len <= 0) || ((cache_ptr)->index_size <= 0) || \ - ((new_size) > (cache_ptr)->index_size) || \ - ((cache_ptr)->index_size != ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size)) || \ - ((cache_ptr)->index_size < ((cache_ptr)->clean_index_size)) || \ - ((cache_ptr)->index_size < ((cache_ptr)->dirty_index_size)) || \ - ((!((entry_ptr)->is_dirty) || ((cache_ptr)->dirty_index_size < (new_size))) && \ - ((((entry_ptr)->is_dirty)) || ((cache_ptr)->clean_index_size < (new_size)))) || \ - (((cache_ptr)->index_len == 1) && ((cache_ptr)->index_size != (new_size))) || \ - ((cache_ptr)->index_ring_len[(entry_ptr)->ring] > (cache_ptr)->index_len) || \ - ((cache_ptr)->index_ring_size[(entry_ptr)->ring] > (cache_ptr)->index_size) || \ - ((cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ - ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ - (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring])) || \ - ((cache_ptr)->index_len != (cache_ptr)->il_len) || \ - ((cache_ptr)->index_size != (cache_ptr)->il_size)) { \ - HDassert(FALSE); \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "post HT entry size change SC failed") \ - } +if (((cache_ptr) == NULL) || ((cache_ptr)->index_len <= 0) || ((cache_ptr)->index_size <= 0) || \ + ((new_size) > (cache_ptr)->index_size) || \ + ((cache_ptr)->index_size != ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size)) || \ + ((cache_ptr)->index_size < ((cache_ptr)->clean_index_size)) || \ + ((cache_ptr)->index_size < ((cache_ptr)->dirty_index_size)) || \ + ((!((entry_ptr)->is_dirty) || ((cache_ptr)->dirty_index_size < (new_size))) && \ + ((((entry_ptr)->is_dirty)) || ((cache_ptr)->clean_index_size < (new_size)))) || \ + (((cache_ptr)->index_len == 1) && ((cache_ptr)->index_size != (new_size))) || \ + ((cache_ptr)->index_ring_len[(entry_ptr)->ring] > (cache_ptr)->index_len) || \ + ((cache_ptr)->index_ring_size[(entry_ptr)->ring] > (cache_ptr)->index_size) || \ + ((cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ + ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ + (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring])) || \ + ((cache_ptr)->index_len != (cache_ptr)->il_len) || \ + ((cache_ptr)->index_size != (cache_ptr)->il_size)) { \ + HDassert(FALSE); \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "post HT entry size change SC failed") \ +} #define H5C__PRE_HT_UPDATE_FOR_ENTRY_CLEAN_SC(cache_ptr, entry_ptr) \ - if (((cache_ptr) == NULL) || ((cache_ptr)->magic != H5C__H5C_T_MAGIC) || \ - ((cache_ptr)->index_len <= 0) || ((entry_ptr) == NULL) || ((entry_ptr)->is_dirty != FALSE) || \ - ((cache_ptr)->index_size < (entry_ptr)->size) || \ - ((cache_ptr)->dirty_index_size < (entry_ptr)->size) || \ - ((cache_ptr)->index_size != ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size)) || \ - ((cache_ptr)->index_size < ((cache_ptr)->clean_index_size)) || \ - ((cache_ptr)->index_size < ((cache_ptr)->dirty_index_size)) || \ - ((entry_ptr)->ring <= H5C_RING_UNDEFINED) || ((entry_ptr)->ring >= H5C_RING_NTYPES) || \ - ((cache_ptr)->index_ring_len[(entry_ptr)->ring] <= 0) || \ - ((cache_ptr)->index_ring_len[(entry_ptr)->ring] > (cache_ptr)->index_len) || \ - ((cache_ptr)->index_ring_size[(entry_ptr)->ring] > (cache_ptr)->index_size) || \ - ((cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ - ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ - (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring]))) { \ - HDassert(FALSE); \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "pre HT update for entry clean SC failed") \ - } +if (((cache_ptr) == NULL) || ((cache_ptr)->magic != H5C__H5C_T_MAGIC) || \ + ((cache_ptr)->index_len <= 0) || ((entry_ptr) == NULL) || ((entry_ptr)->is_dirty != FALSE) || \ + ((cache_ptr)->index_size < (entry_ptr)->size) || \ + ((cache_ptr)->dirty_index_size < (entry_ptr)->size) || \ + ((cache_ptr)->index_size != ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size)) || \ + ((cache_ptr)->index_size < ((cache_ptr)->clean_index_size)) || \ + ((cache_ptr)->index_size < ((cache_ptr)->dirty_index_size)) || \ + ((entry_ptr)->ring <= H5C_RING_UNDEFINED) || ((entry_ptr)->ring >= H5C_RING_NTYPES) || \ + ((cache_ptr)->index_ring_len[(entry_ptr)->ring] <= 0) || \ + ((cache_ptr)->index_ring_len[(entry_ptr)->ring] > (cache_ptr)->index_len) || \ + ((cache_ptr)->index_ring_size[(entry_ptr)->ring] > (cache_ptr)->index_size) || \ + ((cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ + ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ + (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring]))) { \ + HDassert(FALSE); \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "pre HT update for entry clean SC failed") \ +} #define H5C__PRE_HT_UPDATE_FOR_ENTRY_DIRTY_SC(cache_ptr, entry_ptr) \ - if (((cache_ptr) == NULL) || ((cache_ptr)->magic != H5C__H5C_T_MAGIC) || \ - ((cache_ptr)->index_len <= 0) || ((entry_ptr) == NULL) || ((entry_ptr)->is_dirty != TRUE) || \ - ((cache_ptr)->index_size < (entry_ptr)->size) || \ - ((cache_ptr)->clean_index_size < (entry_ptr)->size) || \ - ((cache_ptr)->index_size != ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size)) || \ - ((cache_ptr)->index_size < ((cache_ptr)->clean_index_size)) || \ - ((cache_ptr)->index_size < ((cache_ptr)->dirty_index_size)) || \ - ((entry_ptr)->ring <= H5C_RING_UNDEFINED) || ((entry_ptr)->ring >= H5C_RING_NTYPES) || \ - ((cache_ptr)->index_ring_len[(entry_ptr)->ring] <= 0) || \ - ((cache_ptr)->index_ring_len[(entry_ptr)->ring] > (cache_ptr)->index_len) || \ - ((cache_ptr)->index_ring_size[(entry_ptr)->ring] > (cache_ptr)->index_size) || \ - ((cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ - ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ - (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring]))) { \ - HDassert(FALSE); \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "pre HT update for entry dirty SC failed") \ - } +if (((cache_ptr) == NULL) || ((cache_ptr)->magic != H5C__H5C_T_MAGIC) || \ + ((cache_ptr)->index_len <= 0) || ((entry_ptr) == NULL) || ((entry_ptr)->is_dirty != TRUE) || \ + ((cache_ptr)->index_size < (entry_ptr)->size) || \ + ((cache_ptr)->clean_index_size < (entry_ptr)->size) || \ + ((cache_ptr)->index_size != ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size)) || \ + ((cache_ptr)->index_size < ((cache_ptr)->clean_index_size)) || \ + ((cache_ptr)->index_size < ((cache_ptr)->dirty_index_size)) || \ + ((entry_ptr)->ring <= H5C_RING_UNDEFINED) || ((entry_ptr)->ring >= H5C_RING_NTYPES) || \ + ((cache_ptr)->index_ring_len[(entry_ptr)->ring] <= 0) || \ + ((cache_ptr)->index_ring_len[(entry_ptr)->ring] > (cache_ptr)->index_len) || \ + ((cache_ptr)->index_ring_size[(entry_ptr)->ring] > (cache_ptr)->index_size) || \ + ((cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ + ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ + (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring]))) { \ + HDassert(FALSE); \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "pre HT update for entry dirty SC failed") \ +} #define H5C__POST_HT_UPDATE_FOR_ENTRY_CLEAN_SC(cache_ptr, entry_ptr) \ - if (((cache_ptr)->index_size != ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size)) || \ - ((cache_ptr)->index_size < ((cache_ptr)->clean_index_size)) || \ - ((cache_ptr)->index_size < ((cache_ptr)->dirty_index_size)) || \ - ((cache_ptr)->index_ring_len[(entry_ptr)->ring] > (cache_ptr)->index_len) || \ - ((cache_ptr)->index_ring_size[(entry_ptr)->ring] > (cache_ptr)->index_size) || \ - ((cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ - ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ - (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring]))) { \ - HDassert(FALSE); \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "post HT update for entry clean SC failed") \ - } +if (((cache_ptr)->index_size != ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size)) || \ + ((cache_ptr)->index_size < ((cache_ptr)->clean_index_size)) || \ + ((cache_ptr)->index_size < ((cache_ptr)->dirty_index_size)) || \ + ((cache_ptr)->index_ring_len[(entry_ptr)->ring] > (cache_ptr)->index_len) || \ + ((cache_ptr)->index_ring_size[(entry_ptr)->ring] > (cache_ptr)->index_size) || \ + ((cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ + ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ + (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring]))) { \ + HDassert(FALSE); \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "post HT update for entry clean SC failed") \ +} #define H5C__POST_HT_UPDATE_FOR_ENTRY_DIRTY_SC(cache_ptr, entry_ptr) \ - if (((cache_ptr)->index_size != ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size)) || \ - ((cache_ptr)->index_size < ((cache_ptr)->clean_index_size)) || \ - ((cache_ptr)->index_size < ((cache_ptr)->dirty_index_size)) || \ - ((cache_ptr)->index_ring_len[(entry_ptr)->ring] > (cache_ptr)->index_len) || \ - ((cache_ptr)->index_ring_size[(entry_ptr)->ring] > (cache_ptr)->index_size) || \ - ((cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ - ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ - (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring]))) { \ - HDassert(FALSE); \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "post HT update for entry dirty SC failed") \ - } +if (((cache_ptr)->index_size != ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size)) || \ + ((cache_ptr)->index_size < ((cache_ptr)->clean_index_size)) || \ + ((cache_ptr)->index_size < ((cache_ptr)->dirty_index_size)) || \ + ((cache_ptr)->index_ring_len[(entry_ptr)->ring] > (cache_ptr)->index_len) || \ + ((cache_ptr)->index_ring_size[(entry_ptr)->ring] > (cache_ptr)->index_size) || \ + ((cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ + ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ + (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring]))) { \ + HDassert(FALSE); \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "post HT update for entry dirty SC failed") \ +} #else /* H5C_DO_SANITY_CHECKS */ @@ -1099,8 +1248,10 @@ #define H5C__POST_HT_SHIFT_TO_FRONT(cache_ptr, entry_ptr, k, fail_val) #define H5C__PRE_HT_UPDATE_FOR_ENTRY_CLEAN_SC(cache_ptr, entry_ptr) #define H5C__PRE_HT_UPDATE_FOR_ENTRY_DIRTY_SC(cache_ptr, entry_ptr) -#define H5C__PRE_HT_ENTRY_SIZE_CHANGE_SC(cache_ptr, old_size, new_size, entry_ptr, was_clean) -#define H5C__POST_HT_ENTRY_SIZE_CHANGE_SC(cache_ptr, old_size, new_size, entry_ptr) +#define H5C__PRE_HT_ENTRY_SIZE_CHANGE_SC(cache_ptr, old_size, new_size, \ + entry_ptr, was_clean) +#define H5C__POST_HT_ENTRY_SIZE_CHANGE_SC(cache_ptr, old_size, new_size, \ + entry_ptr) #define H5C__POST_HT_UPDATE_FOR_ENTRY_CLEAN_SC(cache_ptr, entry_ptr) #define H5C__POST_HT_UPDATE_FOR_ENTRY_DIRTY_SC(cache_ptr, entry_ptr) @@ -1147,158 +1298,166 @@ } #define H5C__DELETE_FROM_INDEX(cache_ptr, entry_ptr, fail_val) \ - { \ - int k; \ - H5C__PRE_HT_REMOVE_SC(cache_ptr, entry_ptr) \ - if (cache_ptr->vfd_swmr_reader) { \ - k = H5C__PI_HASH_FCN((entry_ptr)->page); \ - if ((entry_ptr)->pi_next) { \ - (entry_ptr)->pi_next->pi_prev = (entry_ptr)->pi_prev; \ - } \ - if ((entry_ptr)->pi_prev) { \ - (entry_ptr)->pi_prev->pi_next = (entry_ptr)->pi_next; \ - } \ - if (((cache_ptr)->page_index)[k] == (entry_ptr)) { \ - ((cache_ptr)->page_index)[k] = (entry_ptr)->pi_next; \ - } \ - (entry_ptr)->pi_next = NULL; \ - (entry_ptr)->pi_prev = NULL; \ - } \ - k = H5C__HASH_FCN((entry_ptr)->addr); \ - if ((entry_ptr)->ht_next) { \ - (entry_ptr)->ht_next->ht_prev = (entry_ptr)->ht_prev; \ - } \ - if ((entry_ptr)->ht_prev) { \ - (entry_ptr)->ht_prev->ht_next = (entry_ptr)->ht_next; \ - } \ - if (((cache_ptr)->index)[k] == (entry_ptr)) { \ - ((cache_ptr)->index)[k] = (entry_ptr)->ht_next; \ - } \ - (entry_ptr)->ht_next = NULL; \ - (entry_ptr)->ht_prev = NULL; \ - (cache_ptr)->index_len--; \ - (cache_ptr)->index_size -= (entry_ptr)->size; \ - ((cache_ptr)->index_ring_len[entry_ptr->ring])--; \ - ((cache_ptr)->index_ring_size[entry_ptr->ring]) -= (entry_ptr)->size; \ - if ((entry_ptr)->is_dirty) { \ - (cache_ptr)->dirty_index_size -= (entry_ptr)->size; \ - ((cache_ptr)->dirty_index_ring_size[entry_ptr->ring]) -= (entry_ptr)->size; \ - } \ - else { \ - (cache_ptr)->clean_index_size -= (entry_ptr)->size; \ - ((cache_ptr)->clean_index_ring_size[entry_ptr->ring]) -= (entry_ptr)->size; \ - } \ - if ((entry_ptr)->flush_me_last) { \ - (cache_ptr)->num_last_entries--; \ - HDassert((cache_ptr)->num_last_entries <= 1); \ - } \ - H5C__IL_DLL_REMOVE((entry_ptr), (cache_ptr)->il_head, (cache_ptr)->il_tail, (cache_ptr)->il_len, \ - (cache_ptr)->il_size, fail_val) \ - H5C__UPDATE_STATS_FOR_HT_DELETION(cache_ptr) \ - H5C__POST_HT_REMOVE_SC(cache_ptr, entry_ptr) \ - } +{ \ + int k; \ + H5C__PRE_HT_REMOVE_SC(cache_ptr, entry_ptr) \ + if (cache_ptr->vfd_swmr_reader) { \ + k = H5C__PI_HASH_FCN((entry_ptr)->page); \ + if ((entry_ptr)->pi_next) { \ + (entry_ptr)->pi_next->pi_prev = (entry_ptr)->pi_prev; \ + } \ + if ((entry_ptr)->pi_prev) { \ + (entry_ptr)->pi_prev->pi_next = (entry_ptr)->pi_next; \ + } \ + if (((cache_ptr)->page_index)[k] == (entry_ptr)) { \ + ((cache_ptr)->page_index)[k] = (entry_ptr)->pi_next; \ + } \ + (entry_ptr)->pi_next = NULL; \ + (entry_ptr)->pi_prev = NULL; \ + } \ + k = H5C__HASH_FCN((entry_ptr)->addr); \ + if ((entry_ptr)->ht_next) { \ + (entry_ptr)->ht_next->ht_prev = (entry_ptr)->ht_prev; \ + } \ + if ((entry_ptr)->ht_prev) { \ + (entry_ptr)->ht_prev->ht_next = (entry_ptr)->ht_next; \ + } \ + if (((cache_ptr)->index)[k] == (entry_ptr)) { \ + ((cache_ptr)->index)[k] = (entry_ptr)->ht_next; \ + } \ + (entry_ptr)->ht_next = NULL; \ + (entry_ptr)->ht_prev = NULL; \ + (cache_ptr)->index_len--; \ + (cache_ptr)->index_size -= (entry_ptr)->size; \ + ((cache_ptr)->index_ring_len[entry_ptr->ring])--; \ + ((cache_ptr)->index_ring_size[entry_ptr->ring]) -= (entry_ptr)->size; \ + if ((entry_ptr)->is_dirty) { \ + (cache_ptr)->dirty_index_size -= (entry_ptr)->size; \ + ((cache_ptr)->dirty_index_ring_size[entry_ptr->ring]) -= (entry_ptr)->size; \ + } \ + else { \ + (cache_ptr)->clean_index_size -= (entry_ptr)->size; \ + ((cache_ptr)->clean_index_ring_size[entry_ptr->ring]) -= (entry_ptr)->size; \ + } \ + if ((entry_ptr)->flush_me_last) { \ + (cache_ptr)->num_last_entries--; \ + HDassert((cache_ptr)->num_last_entries <= 1); \ + } \ + H5C__IL_DLL_REMOVE((entry_ptr), (cache_ptr)->il_head, (cache_ptr)->il_tail, (cache_ptr)->il_len, \ + (cache_ptr)->il_size, fail_val) \ + H5C__UPDATE_STATS_FOR_HT_DELETION(cache_ptr) \ + H5C__POST_HT_REMOVE_SC(cache_ptr, entry_ptr) \ +} #define H5C__SEARCH_INDEX(cache_ptr, Addr, entry_ptr, fail_val) \ - { \ - int k; \ - int depth = 0; \ - H5C__PRE_HT_SEARCH_SC(cache_ptr, Addr, fail_val) \ - k = H5C__HASH_FCN(Addr); \ - entry_ptr = ((cache_ptr)->index)[k]; \ - while (entry_ptr) { \ - if (H5F_addr_eq(Addr, (entry_ptr)->addr)) { \ - H5C__POST_SUC_HT_SEARCH_SC(cache_ptr, entry_ptr, k, fail_val) \ - if (entry_ptr != ((cache_ptr)->index)[k]) { \ - if ((entry_ptr)->ht_next) \ - (entry_ptr)->ht_next->ht_prev = (entry_ptr)->ht_prev; \ - HDassert((entry_ptr)->ht_prev != NULL); \ - (entry_ptr)->ht_prev->ht_next = (entry_ptr)->ht_next; \ - ((cache_ptr)->index)[k]->ht_prev = (entry_ptr); \ - (entry_ptr)->ht_next = ((cache_ptr)->index)[k]; \ - (entry_ptr)->ht_prev = NULL; \ - ((cache_ptr)->index)[k] = (entry_ptr); \ - H5C__POST_HT_SHIFT_TO_FRONT(cache_ptr, entry_ptr, k, fail_val) \ - } \ - break; \ - } \ - (entry_ptr) = (entry_ptr)->ht_next; \ - (depth)++; \ - } \ - H5C__UPDATE_STATS_FOR_HT_SEARCH(cache_ptr, (entry_ptr != NULL), depth) \ - } +{ \ + int k; \ + int depth = 0; \ + H5C__PRE_HT_SEARCH_SC(cache_ptr, Addr, fail_val) \ + k = H5C__HASH_FCN(Addr); \ + entry_ptr = ((cache_ptr)->index)[k]; \ + while (entry_ptr) { \ + if (H5F_addr_eq(Addr, (entry_ptr)->addr)) { \ + H5C__POST_SUC_HT_SEARCH_SC(cache_ptr, entry_ptr, k, fail_val) \ + if (entry_ptr != ((cache_ptr)->index)[k]) { \ + if ((entry_ptr)->ht_next) \ + (entry_ptr)->ht_next->ht_prev = (entry_ptr)->ht_prev; \ + HDassert((entry_ptr)->ht_prev != NULL); \ + (entry_ptr)->ht_prev->ht_next = (entry_ptr)->ht_next; \ + ((cache_ptr)->index)[k]->ht_prev = (entry_ptr); \ + (entry_ptr)->ht_next = ((cache_ptr)->index)[k]; \ + (entry_ptr)->ht_prev = NULL; \ + ((cache_ptr)->index)[k] = (entry_ptr); \ + H5C__POST_HT_SHIFT_TO_FRONT(cache_ptr, entry_ptr, k, fail_val) \ + } \ + break; \ + } \ + (entry_ptr) = (entry_ptr)->ht_next; \ + (depth)++; \ + } \ + H5C__UPDATE_STATS_FOR_HT_SEARCH(cache_ptr, (entry_ptr != NULL), depth) \ +} #define H5C__SEARCH_INDEX_NO_STATS(cache_ptr, Addr, entry_ptr, fail_val) \ - { \ - int k; \ - H5C__PRE_HT_SEARCH_SC(cache_ptr, Addr, fail_val) \ - k = H5C__HASH_FCN(Addr); \ - entry_ptr = ((cache_ptr)->index)[k]; \ - while (entry_ptr) { \ - if (H5F_addr_eq(Addr, (entry_ptr)->addr)) { \ - H5C__POST_SUC_HT_SEARCH_SC(cache_ptr, entry_ptr, k, fail_val) \ - if (entry_ptr != ((cache_ptr)->index)[k]) { \ - if ((entry_ptr)->ht_next) \ - (entry_ptr)->ht_next->ht_prev = (entry_ptr)->ht_prev; \ - HDassert((entry_ptr)->ht_prev != NULL); \ - (entry_ptr)->ht_prev->ht_next = (entry_ptr)->ht_next; \ - ((cache_ptr)->index)[k]->ht_prev = (entry_ptr); \ - (entry_ptr)->ht_next = ((cache_ptr)->index)[k]; \ - (entry_ptr)->ht_prev = NULL; \ - ((cache_ptr)->index)[k] = (entry_ptr); \ - H5C__POST_HT_SHIFT_TO_FRONT(cache_ptr, entry_ptr, k, fail_val) \ - } \ - break; \ - } \ - (entry_ptr) = (entry_ptr)->ht_next; \ - } \ - } +{ \ + int k; \ + H5C__PRE_HT_SEARCH_SC(cache_ptr, Addr, fail_val) \ + k = H5C__HASH_FCN(Addr); \ + entry_ptr = ((cache_ptr)->index)[k]; \ + while (entry_ptr) { \ + if (H5F_addr_eq(Addr, (entry_ptr)->addr)) { \ + H5C__POST_SUC_HT_SEARCH_SC(cache_ptr, entry_ptr, k, fail_val) \ + if (entry_ptr != ((cache_ptr)->index)[k]) { \ + if ((entry_ptr)->ht_next) \ + (entry_ptr)->ht_next->ht_prev = (entry_ptr)->ht_prev; \ + HDassert((entry_ptr)->ht_prev != NULL); \ + (entry_ptr)->ht_prev->ht_next = (entry_ptr)->ht_next; \ + ((cache_ptr)->index)[k]->ht_prev = (entry_ptr); \ + (entry_ptr)->ht_next = ((cache_ptr)->index)[k]; \ + (entry_ptr)->ht_prev = NULL; \ + ((cache_ptr)->index)[k] = (entry_ptr); \ + H5C__POST_HT_SHIFT_TO_FRONT(cache_ptr, entry_ptr, k, fail_val) \ + } \ + break; \ + } \ + (entry_ptr) = (entry_ptr)->ht_next; \ + } \ +} + +#define H5C__UPDATE_INDEX_FOR_ENTRY_CLEAN(cache_ptr, entry_ptr) \ +{ \ + H5C__PRE_HT_UPDATE_FOR_ENTRY_CLEAN_SC(cache_ptr, entry_ptr); \ + (cache_ptr)->dirty_index_size -= (entry_ptr)->size; \ + ((cache_ptr)->dirty_index_ring_size[entry_ptr->ring]) \ + -= (entry_ptr)->size; \ + (cache_ptr)->clean_index_size += (entry_ptr)->size; \ + ((cache_ptr)->clean_index_ring_size[entry_ptr->ring]) \ + += (entry_ptr)->size; \ + H5C__POST_HT_UPDATE_FOR_ENTRY_CLEAN_SC(cache_ptr, entry_ptr); \ +} + +#define H5C__UPDATE_INDEX_FOR_ENTRY_DIRTY(cache_ptr, entry_ptr) \ +{ \ + H5C__PRE_HT_UPDATE_FOR_ENTRY_DIRTY_SC(cache_ptr, entry_ptr); \ + (cache_ptr)->clean_index_size -= (entry_ptr)->size; \ + ((cache_ptr)->clean_index_ring_size[entry_ptr->ring]) \ + -= (entry_ptr)->size; \ + (cache_ptr)->dirty_index_size += (entry_ptr)->size; \ + ((cache_ptr)->dirty_index_ring_size[entry_ptr->ring]) \ + += (entry_ptr)->size; \ + H5C__POST_HT_UPDATE_FOR_ENTRY_DIRTY_SC(cache_ptr, entry_ptr); \ +} + +#define H5C__UPDATE_INDEX_FOR_SIZE_CHANGE(cache_ptr, old_size, new_size, \ + entry_ptr, was_clean) \ +{ \ + H5C__PRE_HT_ENTRY_SIZE_CHANGE_SC(cache_ptr, old_size, new_size, \ + entry_ptr, was_clean) \ + (cache_ptr)->index_size -= (old_size); \ + (cache_ptr)->index_size += (new_size); \ + ((cache_ptr)->index_ring_size[entry_ptr->ring]) -= (old_size); \ + ((cache_ptr)->index_ring_size[entry_ptr->ring]) += (new_size); \ + if(was_clean) { \ + (cache_ptr)->clean_index_size -= (old_size); \ + ((cache_ptr)->clean_index_ring_size[entry_ptr->ring])-= (old_size); \ + } else { \ + (cache_ptr)->dirty_index_size -= (old_size); \ + ((cache_ptr)->dirty_index_ring_size[entry_ptr->ring])-= (old_size); \ + } \ + if((entry_ptr)->is_dirty) { \ + (cache_ptr)->dirty_index_size += (new_size); \ + ((cache_ptr)->dirty_index_ring_size[entry_ptr->ring])+= (new_size); \ + } else { \ + (cache_ptr)->clean_index_size += (new_size); \ + ((cache_ptr)->clean_index_ring_size[entry_ptr->ring])+= (new_size); \ + } \ + H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->il_len, \ + (cache_ptr)->il_size, \ + (old_size), (new_size)) \ + H5C__POST_HT_ENTRY_SIZE_CHANGE_SC(cache_ptr, old_size, new_size, \ + entry_ptr) \ +} -#define H5C__UPDATE_INDEX_FOR_ENTRY_CLEAN(cache_ptr, entry_ptr) \ - { \ - H5C__PRE_HT_UPDATE_FOR_ENTRY_CLEAN_SC(cache_ptr, entry_ptr); \ - (cache_ptr)->dirty_index_size -= (entry_ptr)->size; \ - ((cache_ptr)->dirty_index_ring_size[entry_ptr->ring]) -= (entry_ptr)->size; \ - (cache_ptr)->clean_index_size += (entry_ptr)->size; \ - ((cache_ptr)->clean_index_ring_size[entry_ptr->ring]) += (entry_ptr)->size; \ - H5C__POST_HT_UPDATE_FOR_ENTRY_CLEAN_SC(cache_ptr, entry_ptr); \ - } - -#define H5C__UPDATE_INDEX_FOR_ENTRY_DIRTY(cache_ptr, entry_ptr) \ - { \ - H5C__PRE_HT_UPDATE_FOR_ENTRY_DIRTY_SC(cache_ptr, entry_ptr); \ - (cache_ptr)->clean_index_size -= (entry_ptr)->size; \ - ((cache_ptr)->clean_index_ring_size[entry_ptr->ring]) -= (entry_ptr)->size; \ - (cache_ptr)->dirty_index_size += (entry_ptr)->size; \ - ((cache_ptr)->dirty_index_ring_size[entry_ptr->ring]) += (entry_ptr)->size; \ - H5C__POST_HT_UPDATE_FOR_ENTRY_DIRTY_SC(cache_ptr, entry_ptr); \ - } - -#define H5C__UPDATE_INDEX_FOR_SIZE_CHANGE(cache_ptr, old_size, new_size, entry_ptr, was_clean) \ - { \ - H5C__PRE_HT_ENTRY_SIZE_CHANGE_SC(cache_ptr, old_size, new_size, entry_ptr, was_clean) \ - (cache_ptr)->index_size -= (old_size); \ - (cache_ptr)->index_size += (new_size); \ - ((cache_ptr)->index_ring_size[entry_ptr->ring]) -= (old_size); \ - ((cache_ptr)->index_ring_size[entry_ptr->ring]) += (new_size); \ - if (was_clean) { \ - (cache_ptr)->clean_index_size -= (old_size); \ - ((cache_ptr)->clean_index_ring_size[entry_ptr->ring]) -= (old_size); \ - } \ - else { \ - (cache_ptr)->dirty_index_size -= (old_size); \ - ((cache_ptr)->dirty_index_ring_size[entry_ptr->ring]) -= (old_size); \ - } \ - if ((entry_ptr)->is_dirty) { \ - (cache_ptr)->dirty_index_size += (new_size); \ - ((cache_ptr)->dirty_index_ring_size[entry_ptr->ring]) += (new_size); \ - } \ - else { \ - (cache_ptr)->clean_index_size += (new_size); \ - ((cache_ptr)->clean_index_ring_size[entry_ptr->ring]) += (new_size); \ - } \ - H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->il_len, (cache_ptr)->il_size, (old_size), (new_size)) \ - H5C__POST_HT_ENTRY_SIZE_CHANGE_SC(cache_ptr, old_size, new_size, entry_ptr) \ - } /************************************************************************** * @@ -1311,11 +1470,11 @@ /*------------------------------------------------------------------------- * - * Macro: H5C__INSERT_ENTRY_IN_SLIST + * Macro: H5C__INSERT_ENTRY_IN_SLIST * * Purpose: Insert the specified instance of H5C_cache_entry_t into - * the skip list in the specified instance of H5C_t. Update - * the associated length and size fields. + * the skip list in the specified instance of H5C_t. Update + * the associated length and size fields. * * Return: N/A * @@ -1323,130 +1482,137 @@ * * Modifications: * - * JRM -- 7/21/04 - * Updated function to set the in_tree flag when inserting - * an entry into the tree. Also modified the function to - * update the tree size and len fields instead of the similar - * index fields. + * JRM -- 7/21/04 + * Updated function to set the in_tree flag when inserting + * an entry into the tree. Also modified the function to + * update the tree size and len fields instead of the similar + * index fields. * - * All of this is part of the modifications to support the - * hash table. + * All of this is part of the modifications to support the + * hash table. * - * JRM -- 7/27/04 - * Converted the function H5C_insert_entry_in_tree() into - * the macro H5C__INSERT_ENTRY_IN_TREE in the hopes of - * wringing a little more speed out of the cache. + * JRM -- 7/27/04 + * Converted the function H5C_insert_entry_in_tree() into + * the macro H5C__INSERT_ENTRY_IN_TREE in the hopes of + * wringing a little more speed out of the cache. * - * Note that we don't bother to check if the entry is already - * in the tree -- if it is, H5SL_insert() will fail. + * Note that we don't bother to check if the entry is already + * in the tree -- if it is, H5SL_insert() will fail. * - * QAK -- 11/27/04 - * Switched over to using skip list routines. + * QAK -- 11/27/04 + * Switched over to using skip list routines. * - * JRM -- 6/27/06 - * Added fail_val parameter. + * JRM -- 6/27/06 + * Added fail_val parameter. * - * JRM -- 8/25/06 - * Added the H5C_DO_SANITY_CHECKS version of the macro. + * JRM -- 8/25/06 + * Added the H5C_DO_SANITY_CHECKS version of the macro. * - * This version maintains the slist_len_increase and - * slist_size_increase fields that are used in sanity - * checks in the flush routines. + * This version maintains the slist_len_increase and + * slist_size_increase fields that are used in sanity + * checks in the flush routines. * - * All this is needed as the fractal heap needs to be - * able to dirty, resize and/or move entries during the - * flush. + * All this is needed as the fractal heap needs to be + * able to dirty, resize and/or move entries during the + * flush. * - * JRM -- 12/13/14 - * Added code to set cache_ptr->slist_changed to TRUE - * when an entry is inserted in the slist. + * JRM -- 12/13/14 + * Added code to set cache_ptr->slist_changed to TRUE + * when an entry is inserted in the slist. * - * JRM -- 9/1/15 - * Added code to maintain the cache_ptr->slist_ring_len - * and cache_ptr->slist_ring_size arrays. + * JRM -- 9/1/15 + * Added code to maintain the cache_ptr->slist_ring_len + * and cache_ptr->slist_ring_size arrays. * *------------------------------------------------------------------------- */ #if H5C_DO_SLIST_SANITY_CHECKS -#define ENTRY_IN_SLIST(cache_ptr, entry_ptr) H5C_entry_in_skip_list((cache_ptr), (entry_ptr)) + +#define ENTRY_IN_SLIST(cache_ptr, entry_ptr) \ + H5C_entry_in_skip_list((cache_ptr), (entry_ptr)) + #else /* H5C_DO_SLIST_SANITY_CHECKS */ + #define ENTRY_IN_SLIST(cache_ptr, entry_ptr) FALSE + #endif /* H5C_DO_SLIST_SANITY_CHECKS */ + #if H5C_DO_SANITY_CHECKS #define H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, fail_val) \ - { \ - HDassert((cache_ptr)); \ - HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ - HDassert((entry_ptr)); \ - HDassert((entry_ptr)->size > 0); \ - HDassert(H5F_addr_defined((entry_ptr)->addr)); \ - HDassert(!((entry_ptr)->in_slist)); \ - HDassert(!ENTRY_IN_SLIST((cache_ptr), (entry_ptr))); \ - HDassert((entry_ptr)->ring > H5C_RING_UNDEFINED); \ - HDassert((entry_ptr)->ring < H5C_RING_NTYPES); \ - HDassert((cache_ptr)->slist_ring_len[(entry_ptr)->ring] <= (cache_ptr)->slist_len); \ - HDassert((cache_ptr)->slist_ring_size[(entry_ptr)->ring] <= (cache_ptr)->slist_size); \ - \ - if (H5SL_insert((cache_ptr)->slist_ptr, entry_ptr, &(entry_ptr)->addr) < 0) \ - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, (fail_val), "can't insert entry in skip list") \ - \ - (entry_ptr)->in_slist = TRUE; \ - (cache_ptr)->slist_changed = TRUE; \ - (cache_ptr)->slist_len++; \ - (cache_ptr)->slist_size += (entry_ptr)->size; \ - ((cache_ptr)->slist_ring_len[(entry_ptr)->ring])++; \ - ((cache_ptr)->slist_ring_size[(entry_ptr)->ring]) += (entry_ptr)->size; \ - (cache_ptr)->slist_len_increase++; \ - (cache_ptr)->slist_size_increase += (int64_t)((entry_ptr)->size); \ - \ - HDassert((cache_ptr)->slist_len > 0); \ - HDassert((cache_ptr)->slist_size > 0); \ - \ - } /* H5C__INSERT_ENTRY_IN_SLIST */ +{ \ + HDassert((cache_ptr)); \ + HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ + HDassert((entry_ptr)); \ + HDassert((entry_ptr)->size > 0); \ + HDassert(H5F_addr_defined((entry_ptr)->addr)); \ + HDassert(!((entry_ptr)->in_slist)); \ + HDassert(!ENTRY_IN_SLIST((cache_ptr), (entry_ptr))); \ + HDassert((entry_ptr)->ring > H5C_RING_UNDEFINED); \ + HDassert((entry_ptr)->ring < H5C_RING_NTYPES); \ + HDassert((cache_ptr)->slist_ring_len[(entry_ptr)->ring] <= (cache_ptr)->slist_len); \ + HDassert((cache_ptr)->slist_ring_size[(entry_ptr)->ring] <= (cache_ptr)->slist_size); \ + \ + if (H5SL_insert((cache_ptr)->slist_ptr, entry_ptr, &(entry_ptr)->addr) < 0) \ + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, (fail_val), "can't insert entry in skip list") \ + \ + (entry_ptr)->in_slist = TRUE; \ + (cache_ptr)->slist_changed = TRUE; \ + (cache_ptr)->slist_len++; \ + (cache_ptr)->slist_size += (entry_ptr)->size; \ + ((cache_ptr)->slist_ring_len[(entry_ptr)->ring])++; \ + ((cache_ptr)->slist_ring_size[(entry_ptr)->ring]) += (entry_ptr)->size; \ + (cache_ptr)->slist_len_increase++; \ + (cache_ptr)->slist_size_increase += (int64_t)((entry_ptr)->size); \ + \ + HDassert((cache_ptr)->slist_len > 0); \ + HDassert((cache_ptr)->slist_size > 0); \ + \ +} /* H5C__INSERT_ENTRY_IN_SLIST */ #else /* H5C_DO_SANITY_CHECKS */ #define H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, fail_val) \ - { \ - HDassert((cache_ptr)); \ - HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ - HDassert((entry_ptr)); \ - HDassert((entry_ptr)->size > 0); \ - HDassert(H5F_addr_defined((entry_ptr)->addr)); \ - HDassert(!((entry_ptr)->in_slist)); \ - HDassert(!ENTRY_IN_SLIST((cache_ptr), (entry_ptr))); \ - HDassert((entry_ptr)->ring > H5C_RING_UNDEFINED); \ - HDassert((entry_ptr)->ring < H5C_RING_NTYPES); \ - HDassert((cache_ptr)->slist_ring_len[(entry_ptr)->ring] <= (cache_ptr)->slist_len); \ - HDassert((cache_ptr)->slist_ring_size[(entry_ptr)->ring] <= (cache_ptr)->slist_size); \ - \ - if (H5SL_insert((cache_ptr)->slist_ptr, entry_ptr, &(entry_ptr)->addr) < 0) \ - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, (fail_val), "can't insert entry in skip list") \ - \ - (entry_ptr)->in_slist = TRUE; \ - (cache_ptr)->slist_changed = TRUE; \ - (cache_ptr)->slist_len++; \ - (cache_ptr)->slist_size += (entry_ptr)->size; \ - ((cache_ptr)->slist_ring_len[(entry_ptr)->ring])++; \ - ((cache_ptr)->slist_ring_size[(entry_ptr)->ring]) += (entry_ptr)->size; \ - \ - HDassert((cache_ptr)->slist_len > 0); \ - HDassert((cache_ptr)->slist_size > 0); \ - \ - } /* H5C__INSERT_ENTRY_IN_SLIST */ +{ \ + HDassert((cache_ptr)); \ + HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ + HDassert((entry_ptr)); \ + HDassert((entry_ptr)->size > 0); \ + HDassert(H5F_addr_defined((entry_ptr)->addr)); \ + HDassert(!((entry_ptr)->in_slist)); \ + HDassert(!ENTRY_IN_SLIST((cache_ptr), (entry_ptr))); \ + HDassert((entry_ptr)->ring > H5C_RING_UNDEFINED); \ + HDassert((entry_ptr)->ring < H5C_RING_NTYPES); \ + HDassert((cache_ptr)->slist_ring_len[(entry_ptr)->ring] <= (cache_ptr)->slist_len); \ + HDassert((cache_ptr)->slist_ring_size[(entry_ptr)->ring] <= (cache_ptr)->slist_size); \ + \ + if (H5SL_insert((cache_ptr)->slist_ptr, entry_ptr, &(entry_ptr)->addr) < 0) \ + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, (fail_val), "can't insert entry in skip list") \ + \ + (entry_ptr)->in_slist = TRUE; \ + (cache_ptr)->slist_changed = TRUE; \ + (cache_ptr)->slist_len++; \ + (cache_ptr)->slist_size += (entry_ptr)->size; \ + ((cache_ptr)->slist_ring_len[(entry_ptr)->ring])++; \ + ((cache_ptr)->slist_ring_size[(entry_ptr)->ring]) += (entry_ptr)->size; \ + \ + HDassert((cache_ptr)->slist_len > 0); \ + HDassert((cache_ptr)->slist_size > 0); \ + \ +} /* H5C__INSERT_ENTRY_IN_SLIST */ #endif /* H5C_DO_SANITY_CHECKS */ + /*------------------------------------------------------------------------- * * Function: H5C__REMOVE_ENTRY_FROM_SLIST * * Purpose: Remove the specified instance of H5C_cache_entry_t from the - * index skip list in the specified instance of H5C_t. Update - * the associated length and size fields. + * index skip list in the specified instance of H5C_t. Update + * the associated length and size fields. * * Return: N/A * @@ -1457,75 +1623,76 @@ #if H5C_DO_SANITY_CHECKS #define H5C__REMOVE_ENTRY_FROM_SLIST(cache_ptr, entry_ptr, during_flush) \ - { \ - HDassert((cache_ptr)); \ - HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ - HDassert((entry_ptr)); \ - HDassert(!((entry_ptr)->is_read_only)); \ - HDassert(((entry_ptr)->ro_ref_count) == 0); \ - HDassert((entry_ptr)->size > 0); \ - HDassert((entry_ptr)->in_slist); \ - HDassert((cache_ptr)->slist_ptr); \ - HDassert((entry_ptr)->ring > H5C_RING_UNDEFINED); \ - HDassert((entry_ptr)->ring < H5C_RING_NTYPES); \ - HDassert((cache_ptr)->slist_ring_len[(entry_ptr)->ring] <= (cache_ptr)->slist_len); \ - HDassert((cache_ptr)->slist_ring_size[(entry_ptr)->ring] <= (cache_ptr)->slist_size); \ - \ - if (H5SL_remove((cache_ptr)->slist_ptr, &(entry_ptr)->addr) != (entry_ptr)) \ - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "can't delete entry from skip list") \ - \ - HDassert((cache_ptr)->slist_len > 0); \ - if (!(during_flush)) \ - (cache_ptr)->slist_changed = TRUE; \ - (cache_ptr)->slist_len--; \ - HDassert((cache_ptr)->slist_size >= (entry_ptr)->size); \ - (cache_ptr)->slist_size -= (entry_ptr)->size; \ - ((cache_ptr)->slist_ring_len[(entry_ptr)->ring])--; \ - HDassert((cache_ptr)->slist_ring_size[(entry_ptr->ring)] >= (entry_ptr)->size); \ - ((cache_ptr)->slist_ring_size[(entry_ptr)->ring]) -= (entry_ptr)->size; \ - (cache_ptr)->slist_len_increase--; \ - (cache_ptr)->slist_size_increase -= (int64_t)((entry_ptr)->size); \ - (entry_ptr)->in_slist = FALSE; \ - } /* H5C__REMOVE_ENTRY_FROM_SLIST */ +{ \ + HDassert((cache_ptr)); \ + HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ + HDassert((entry_ptr)); \ + HDassert(!((entry_ptr)->is_read_only)); \ + HDassert(((entry_ptr)->ro_ref_count) == 0); \ + HDassert((entry_ptr)->size > 0); \ + HDassert((entry_ptr)->in_slist); \ + HDassert((cache_ptr)->slist_ptr); \ + HDassert((entry_ptr)->ring > H5C_RING_UNDEFINED); \ + HDassert((entry_ptr)->ring < H5C_RING_NTYPES); \ + HDassert((cache_ptr)->slist_ring_len[(entry_ptr)->ring] <= (cache_ptr)->slist_len); \ + HDassert((cache_ptr)->slist_ring_size[(entry_ptr)->ring] <= (cache_ptr)->slist_size); \ + \ + if (H5SL_remove((cache_ptr)->slist_ptr, &(entry_ptr)->addr) != (entry_ptr)) \ + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "can't delete entry from skip list") \ + \ + HDassert((cache_ptr)->slist_len > 0); \ + if (!(during_flush)) \ + (cache_ptr)->slist_changed = TRUE; \ + (cache_ptr)->slist_len--; \ + HDassert((cache_ptr)->slist_size >= (entry_ptr)->size); \ + (cache_ptr)->slist_size -= (entry_ptr)->size; \ + ((cache_ptr)->slist_ring_len[(entry_ptr)->ring])--; \ + HDassert((cache_ptr)->slist_ring_size[(entry_ptr->ring)] >= (entry_ptr)->size); \ + ((cache_ptr)->slist_ring_size[(entry_ptr)->ring]) -= (entry_ptr)->size; \ + (cache_ptr)->slist_len_increase--; \ + (cache_ptr)->slist_size_increase -= (int64_t)((entry_ptr)->size); \ + (entry_ptr)->in_slist = FALSE; \ +} /* H5C__REMOVE_ENTRY_FROM_SLIST */ #else /* H5C_DO_SANITY_CHECKS */ #define H5C__REMOVE_ENTRY_FROM_SLIST(cache_ptr, entry_ptr, during_flush) \ - { \ - HDassert((cache_ptr)); \ - HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ - HDassert((entry_ptr)); \ - HDassert(!((entry_ptr)->is_read_only)); \ - HDassert(((entry_ptr)->ro_ref_count) == 0); \ - HDassert((entry_ptr)->in_slist); \ - HDassert((cache_ptr)->slist_ptr); \ - HDassert((entry_ptr)->ring > H5C_RING_UNDEFINED); \ - HDassert((entry_ptr)->ring < H5C_RING_NTYPES); \ - HDassert((cache_ptr)->slist_ring_len[(entry_ptr)->ring] <= (cache_ptr)->slist_len); \ - HDassert((cache_ptr)->slist_ring_size[(entry_ptr)->ring] <= (cache_ptr)->slist_size); \ - \ - if (H5SL_remove((cache_ptr)->slist_ptr, &(entry_ptr)->addr) != (entry_ptr)) \ - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "can't delete entry from skip list") \ - \ - HDassert((cache_ptr)->slist_len > 0); \ - if (!(during_flush)) \ - (cache_ptr)->slist_changed = TRUE; \ - (cache_ptr)->slist_len--; \ - HDassert((cache_ptr)->slist_size >= (entry_ptr)->size); \ - (cache_ptr)->slist_size -= (entry_ptr)->size; \ - ((cache_ptr)->slist_ring_len[(entry_ptr)->ring])--; \ - HDassert((cache_ptr)->slist_ring_size[(entry_ptr->ring)] >= (entry_ptr)->size); \ - ((cache_ptr)->slist_ring_size[(entry_ptr)->ring]) -= (entry_ptr)->size; \ - (entry_ptr)->in_slist = FALSE; \ - } /* H5C__REMOVE_ENTRY_FROM_SLIST */ +{ \ + HDassert((cache_ptr)); \ + HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ + HDassert((entry_ptr)); \ + HDassert(!((entry_ptr)->is_read_only)); \ + HDassert(((entry_ptr)->ro_ref_count) == 0); \ + HDassert((entry_ptr)->in_slist); \ + HDassert((cache_ptr)->slist_ptr); \ + HDassert((entry_ptr)->ring > H5C_RING_UNDEFINED); \ + HDassert((entry_ptr)->ring < H5C_RING_NTYPES); \ + HDassert((cache_ptr)->slist_ring_len[(entry_ptr)->ring] <= (cache_ptr)->slist_len); \ + HDassert((cache_ptr)->slist_ring_size[(entry_ptr)->ring] <= (cache_ptr)->slist_size); \ + \ + if (H5SL_remove((cache_ptr)->slist_ptr, &(entry_ptr)->addr) != (entry_ptr)) \ + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "can't delete entry from skip list") \ + \ + HDassert((cache_ptr)->slist_len > 0); \ + if (!(during_flush)) \ + (cache_ptr)->slist_changed = TRUE; \ + (cache_ptr)->slist_len--; \ + HDassert((cache_ptr)->slist_size >= (entry_ptr)->size); \ + (cache_ptr)->slist_size -= (entry_ptr)->size; \ + ((cache_ptr)->slist_ring_len[(entry_ptr)->ring])--; \ + HDassert((cache_ptr)->slist_ring_size[(entry_ptr->ring)] >= (entry_ptr)->size); \ + ((cache_ptr)->slist_ring_size[(entry_ptr)->ring]) -= (entry_ptr)->size; \ + (entry_ptr)->in_slist = FALSE; \ +} /* H5C__REMOVE_ENTRY_FROM_SLIST */ #endif /* H5C_DO_SANITY_CHECKS */ + /*------------------------------------------------------------------------- * * Function: H5C__UPDATE_SLIST_FOR_SIZE_CHANGE * * Purpose: Update cache_ptr->slist_size for a change in the size of - * and entry in the slist. + * and entry in the slist. * * Return: N/A * @@ -1533,24 +1700,30 @@ * * Modifications: * - * JRM -- 8/27/06 - * Added the H5C_DO_SANITY_CHECKS version of the macro. + * JRM -- 8/27/06 + * Added the H5C_DO_SANITY_CHECKS version of the macro. + * + * This version maintains the slist_size_increase field + * that are used in sanity checks in the flush routines. * - * This version maintains the slist_size_increase field - * that are used in sanity checks in the flush routines. + * All this is needed as the fractal heap needs to be + * able to dirty, resize and/or move entries during the + * flush. * - * All this is needed as the fractal heap needs to be - * able to dirty, resize and/or move entries during the - * flush. + * JRM -- 12/13/14 + * Note that we do not set cache_ptr->slist_changed to TRUE + * in this case, as the structure of the slist is not + * modified. * - * JRM -- 12/13/14 - * Note that we do not set cache_ptr->slist_changed to TRUE - * in this case, as the structure of the slist is not - * modified. + * JRM -- 9/1/15 + * Added code to maintain the cache_ptr->slist_ring_len + * and cache_ptr->slist_ring_size arrays. * - * JRM -- 9/1/15 - * Added code to maintain the cache_ptr->slist_ring_len - * and cache_ptr->slist_ring_size arrays. + * JRM -- 4/29/20 + * Reworked macro to support the slist_enabled field + * of H5C_t. If slist_enabled == TRUE, the macro + * functions as before. Otherwise, the macro is a no-op, + * and the slist must be empty. * *------------------------------------------------------------------------- */ @@ -1558,62 +1731,63 @@ #if H5C_DO_SANITY_CHECKS #define H5C__UPDATE_SLIST_FOR_SIZE_CHANGE(cache_ptr, old_size, new_size) \ - { \ - HDassert((cache_ptr)); \ - HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ - HDassert((old_size) > 0); \ - HDassert((new_size) > 0); \ - HDassert((old_size) <= (cache_ptr)->slist_size); \ - HDassert((cache_ptr)->slist_len > 0); \ - HDassert(((cache_ptr)->slist_len > 1) || ((cache_ptr)->slist_size == (old_size))); \ - HDassert((entry_ptr)->ring > H5C_RING_UNDEFINED); \ - HDassert((entry_ptr)->ring < H5C_RING_NTYPES); \ - HDassert((cache_ptr)->slist_ring_len[(entry_ptr)->ring] <= (cache_ptr)->slist_len); \ - HDassert((cache_ptr)->slist_ring_size[(entry_ptr)->ring] <= (cache_ptr)->slist_size); \ - \ - (cache_ptr)->slist_size -= (old_size); \ - (cache_ptr)->slist_size += (new_size); \ - \ - HDassert((cache_ptr)->slist_ring_size[(entry_ptr->ring)] >= (old_size)); \ - ((cache_ptr)->slist_ring_size[(entry_ptr)->ring]) -= (old_size); \ - ((cache_ptr)->slist_ring_size[(entry_ptr)->ring]) += (new_size); \ - \ - (cache_ptr)->slist_size_increase -= (int64_t)(old_size); \ - (cache_ptr)->slist_size_increase += (int64_t)(new_size); \ - \ - HDassert((new_size) <= (cache_ptr)->slist_size); \ - HDassert(((cache_ptr)->slist_len > 1) || ((cache_ptr)->slist_size == (new_size))); \ - } /* H5C__UPDATE_SLIST_FOR_SIZE_CHANGE */ +{ \ + HDassert((cache_ptr)); \ + HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ + HDassert((old_size) > 0); \ + HDassert((new_size) > 0); \ + HDassert((old_size) <= (cache_ptr)->slist_size); \ + HDassert((cache_ptr)->slist_len > 0); \ + HDassert(((cache_ptr)->slist_len > 1) || ((cache_ptr)->slist_size == (old_size))); \ + HDassert((entry_ptr)->ring > H5C_RING_UNDEFINED); \ + HDassert((entry_ptr)->ring < H5C_RING_NTYPES); \ + HDassert((cache_ptr)->slist_ring_len[(entry_ptr)->ring] <= (cache_ptr)->slist_len); \ + HDassert((cache_ptr)->slist_ring_size[(entry_ptr)->ring] <= (cache_ptr)->slist_size); \ + \ + (cache_ptr)->slist_size -= (old_size); \ + (cache_ptr)->slist_size += (new_size); \ + \ + HDassert((cache_ptr)->slist_ring_size[(entry_ptr->ring)] >= (old_size)); \ + ((cache_ptr)->slist_ring_size[(entry_ptr)->ring]) -= (old_size); \ + ((cache_ptr)->slist_ring_size[(entry_ptr)->ring]) += (new_size); \ + \ + (cache_ptr)->slist_size_increase -= (int64_t)(old_size); \ + (cache_ptr)->slist_size_increase += (int64_t)(new_size); \ + \ + HDassert((new_size) <= (cache_ptr)->slist_size); \ + HDassert(((cache_ptr)->slist_len > 1) || ((cache_ptr)->slist_size == (new_size))); \ +} /* H5C__UPDATE_SLIST_FOR_SIZE_CHANGE */ #else /* H5C_DO_SANITY_CHECKS */ #define H5C__UPDATE_SLIST_FOR_SIZE_CHANGE(cache_ptr, old_size, new_size) \ - { \ - HDassert((cache_ptr)); \ - HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ - HDassert((old_size) > 0); \ - HDassert((new_size) > 0); \ - HDassert((old_size) <= (cache_ptr)->slist_size); \ - HDassert((cache_ptr)->slist_len > 0); \ - HDassert(((cache_ptr)->slist_len > 1) || ((cache_ptr)->slist_size == (old_size))); \ - HDassert((entry_ptr)->ring > H5C_RING_UNDEFINED); \ - HDassert((entry_ptr)->ring < H5C_RING_NTYPES); \ - HDassert((cache_ptr)->slist_ring_len[(entry_ptr)->ring] <= (cache_ptr)->slist_len); \ - HDassert((cache_ptr)->slist_ring_size[(entry_ptr)->ring] <= (cache_ptr)->slist_size); \ - \ - (cache_ptr)->slist_size -= (old_size); \ - (cache_ptr)->slist_size += (new_size); \ - \ - HDassert((cache_ptr)->slist_ring_size[(entry_ptr->ring)] >= (old_size)); \ - ((cache_ptr)->slist_ring_size[(entry_ptr)->ring]) -= (old_size); \ - ((cache_ptr)->slist_ring_size[(entry_ptr)->ring]) += (new_size); \ - \ - HDassert((new_size) <= (cache_ptr)->slist_size); \ - HDassert(((cache_ptr)->slist_len > 1) || ((cache_ptr)->slist_size == (new_size))); \ - } /* H5C__UPDATE_SLIST_FOR_SIZE_CHANGE */ +{ \ + HDassert((cache_ptr)); \ + HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ + HDassert((old_size) > 0); \ + HDassert((new_size) > 0); \ + HDassert((old_size) <= (cache_ptr)->slist_size); \ + HDassert((cache_ptr)->slist_len > 0); \ + HDassert(((cache_ptr)->slist_len > 1) || ((cache_ptr)->slist_size == (old_size))); \ + HDassert((entry_ptr)->ring > H5C_RING_UNDEFINED); \ + HDassert((entry_ptr)->ring < H5C_RING_NTYPES); \ + HDassert((cache_ptr)->slist_ring_len[(entry_ptr)->ring] <= (cache_ptr)->slist_len); \ + HDassert((cache_ptr)->slist_ring_size[(entry_ptr)->ring] <= (cache_ptr)->slist_size); \ + \ + (cache_ptr)->slist_size -= (old_size); \ + (cache_ptr)->slist_size += (new_size); \ + \ + HDassert((cache_ptr)->slist_ring_size[(entry_ptr->ring)] >= (old_size)); \ + ((cache_ptr)->slist_ring_size[(entry_ptr)->ring]) -= (old_size); \ + ((cache_ptr)->slist_ring_size[(entry_ptr)->ring]) += (new_size); \ + \ + HDassert((new_size) <= (cache_ptr)->slist_size); \ + HDassert(((cache_ptr)->slist_len > 1) || ((cache_ptr)->slist_size == (new_size))); \ +} /* H5C__UPDATE_SLIST_FOR_SIZE_CHANGE */ #endif /* H5C_DO_SANITY_CHECKS */ + /************************************************************************** * * Replacement policy update macros: @@ -1625,18 +1799,18 @@ /*------------------------------------------------------------------------- * - * Macro: H5C__FAKE_RP_FOR_MOST_RECENT_ACCESS + * Macro: H5C__FAKE_RP_FOR_MOST_RECENT_ACCESS * * Purpose: For efficiency, we sometimes change the order of flushes -- - * but doing so can confuse the replacement policy. This - * macro exists to allow us to specify an entry as the - * most recently touched so we can repair any such - * confusion. + * but doing so can confuse the replacement policy. This + * macro exists to allow us to specify an entry as the + * most recently touched so we can repair any such + * confusion. * - * At present, we only support the modified LRU policy, so - * this function deals with that case unconditionally. If - * we ever support other replacement policies, the macro - * should switch on the current policy and act accordingly. + * At present, we only support the modified LRU policy, so + * this function deals with that case unconditionally. If + * we ever support other replacement policies, the macro + * should switch on the current policy and act accordingly. * * Return: N/A * @@ -1644,113 +1818,129 @@ * * Modifications: * - * JRM -- 3/20/06 - * Modified macro to ignore pinned entries. Pinned entries - * do not appear in the data structures maintained by the - * replacement policy code, and thus this macro has nothing - * to do if called for such an entry. + * JRM -- 3/20/06 + * Modified macro to ignore pinned entries. Pinned entries + * do not appear in the data structures maintained by the + * replacement policy code, and thus this macro has nothing + * to do if called for such an entry. * - * JRM -- 3/28/07 - * Added sanity checks using the new is_read_only and - * ro_ref_count fields of struct H5C_cache_entry_t. + * JRM -- 3/28/07 + * Added sanity checks using the new is_read_only and + * ro_ref_count fields of struct H5C_cache_entry_t. * *------------------------------------------------------------------------- */ #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS -#define H5C__FAKE_RP_FOR_MOST_RECENT_ACCESS(cache_ptr, entry_ptr, fail_val) \ - { \ - HDassert((cache_ptr)); \ - HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ - HDassert((entry_ptr)); \ - HDassert(!((entry_ptr)->is_protected)); \ - HDassert(!((entry_ptr)->is_read_only)); \ - HDassert(((entry_ptr)->ro_ref_count) == 0); \ - HDassert((entry_ptr)->size > 0); \ - \ - if (!((entry_ptr)->is_pinned)) { \ - \ - /* modified LRU specific code */ \ - \ - /* remove the entry from the LRU list, and re-insert it at the head. \ - */ \ - \ - H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - /* Use the dirty flag to infer whether the entry is on the clean or \ - * dirty LRU list, and remove it. Then insert it at the head of \ - * the same LRU list. \ - * \ - * At least initially, all entries should be clean. That may \ - * change, so we may as well deal with both cases now. \ - */ \ - \ - if ((entry_ptr)->is_dirty) { \ - H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->dLRU_head_ptr, (cache_ptr)->dLRU_tail_ptr, \ - (cache_ptr)->dLRU_list_len, (cache_ptr)->dLRU_list_size, (fail_val)) \ - \ - H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->dLRU_head_ptr, (cache_ptr)->dLRU_tail_ptr, \ - (cache_ptr)->dLRU_list_len, (cache_ptr)->dLRU_list_size, (fail_val)) \ - } \ - else { \ - H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->cLRU_head_ptr, (cache_ptr)->cLRU_tail_ptr, \ - (cache_ptr)->cLRU_list_len, (cache_ptr)->cLRU_list_size, (fail_val)) \ - \ - H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->cLRU_head_ptr, (cache_ptr)->cLRU_tail_ptr, \ - (cache_ptr)->cLRU_list_len, (cache_ptr)->cLRU_list_size, (fail_val)) \ - } \ - \ - /* End modified LRU specific code. */ \ - } \ - } /* H5C__FAKE_RP_FOR_MOST_RECENT_ACCESS */ +#define H5C__FAKE_RP_FOR_MOST_RECENT_ACCESS(cache_ptr, entry_ptr, fail_val) \ +{ \ + HDassert( (cache_ptr) ); \ + HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ + HDassert( (entry_ptr) ); \ + HDassert( !((entry_ptr)->is_protected) ); \ + HDassert( !((entry_ptr)->is_read_only) ); \ + HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ + HDassert( (entry_ptr)->size > 0 ); \ + \ + if ( ! ((entry_ptr)->is_pinned) ) { \ + \ + /* modified LRU specific code */ \ + \ + /* remove the entry from the LRU list, and re-insert it at the head.\ + */ \ + \ + H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ + (cache_ptr)->LRU_tail_ptr, \ + (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ + (cache_ptr)->LRU_tail_ptr, \ + (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + /* Use the dirty flag to infer whether the entry is on the clean or \ + * dirty LRU list, and remove it. Then insert it at the head of \ + * the same LRU list. \ + * \ + * At least initially, all entries should be clean. That may \ + * change, so we may as well deal with both cases now. \ + */ \ + \ + if ( (entry_ptr)->is_dirty ) { \ + H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->dLRU_head_ptr, \ + (cache_ptr)->dLRU_tail_ptr, \ + (cache_ptr)->dLRU_list_len, \ + (cache_ptr)->dLRU_list_size, (fail_val)) \ + \ + H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->dLRU_head_ptr, \ + (cache_ptr)->dLRU_tail_ptr, \ + (cache_ptr)->dLRU_list_len, \ + (cache_ptr)->dLRU_list_size, (fail_val)) \ + } else { \ + H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->cLRU_head_ptr, \ + (cache_ptr)->cLRU_tail_ptr, \ + (cache_ptr)->cLRU_list_len, \ + (cache_ptr)->cLRU_list_size, (fail_val)) \ + \ + H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->cLRU_head_ptr, \ + (cache_ptr)->cLRU_tail_ptr, \ + (cache_ptr)->cLRU_list_len, \ + (cache_ptr)->cLRU_list_size, (fail_val)) \ + } \ + \ + /* End modified LRU specific code. */ \ + } \ +} /* H5C__FAKE_RP_FOR_MOST_RECENT_ACCESS */ #else /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ -#define H5C__FAKE_RP_FOR_MOST_RECENT_ACCESS(cache_ptr, entry_ptr, fail_val) \ - { \ - HDassert((cache_ptr)); \ - HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ - HDassert((entry_ptr)); \ - HDassert(!((entry_ptr)->is_protected)); \ - HDassert(!((entry_ptr)->is_read_only)); \ - HDassert(((entry_ptr)->ro_ref_count) == 0); \ - HDassert((entry_ptr)->size > 0); \ - \ - if (!((entry_ptr)->is_pinned)) { \ - \ - /* modified LRU specific code */ \ - \ - /* remove the entry from the LRU list, and re-insert it at the head \ - */ \ - \ - H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - /* End modified LRU specific code. */ \ - } \ - } /* H5C__FAKE_RP_FOR_MOST_RECENT_ACCESS */ +#define H5C__FAKE_RP_FOR_MOST_RECENT_ACCESS(cache_ptr, entry_ptr, fail_val) \ +{ \ + HDassert( (cache_ptr) ); \ + HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ + HDassert( (entry_ptr) ); \ + HDassert( !((entry_ptr)->is_protected) ); \ + HDassert( !((entry_ptr)->is_read_only) ); \ + HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ + HDassert( (entry_ptr)->size > 0 ); \ + \ + if ( ! ((entry_ptr)->is_pinned) ) { \ + \ + /* modified LRU specific code */ \ + \ + /* remove the entry from the LRU list, and re-insert it at the head \ + */ \ + \ + H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ + (cache_ptr)->LRU_tail_ptr, \ + (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ + (cache_ptr)->LRU_tail_ptr, \ + (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + /* End modified LRU specific code. */ \ + } \ +} /* H5C__FAKE_RP_FOR_MOST_RECENT_ACCESS */ #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ + /*------------------------------------------------------------------------- * - * Macro: H5C__UPDATE_RP_FOR_EVICTION + * Macro: H5C__UPDATE_RP_FOR_EVICTION * * Purpose: Update the replacement policy data structures for an - * eviction of the specified cache entry. + * eviction of the specified cache entry. * - * At present, we only support the modified LRU policy, so - * this function deals with that case unconditionally. If - * we ever support other replacement policies, the function - * should switch on the current policy and act accordingly. + * At present, we only support the modified LRU policy, so + * this function deals with that case unconditionally. If + * we ever support other replacement policies, the function + * should switch on the current policy and act accordingly. * * Return: Non-negative on success/Negative on failure. * @@ -1758,104 +1948,110 @@ * * Modifications: * - * JRM - 7/27/04 - * Converted the function H5C_update_rp_for_eviction() to the - * macro H5C__UPDATE_RP_FOR_EVICTION in an effort to squeeze - * a bit more performance out of the cache. + * JRM - 7/27/04 + * Converted the function H5C_update_rp_for_eviction() to the + * macro H5C__UPDATE_RP_FOR_EVICTION in an effort to squeeze + * a bit more performance out of the cache. * - * At least for the first cut, I am leaving the comments and - * white space in the macro. If they cause difficulties with - * the pre-processor, I'll have to remove them. + * At least for the first cut, I am leaving the comments and + * white space in the macro. If they cause difficulties with + * the pre-processor, I'll have to remove them. * - * JRM - 7/28/04 - * Split macro into two version, one supporting the clean and - * dirty LRU lists, and the other not. Yet another attempt - * at optimization. + * JRM - 7/28/04 + * Split macro into two version, one supporting the clean and + * dirty LRU lists, and the other not. Yet another attempt + * at optimization. * - * JRM - 3/20/06 - * Pinned entries can't be evicted, so this entry should never - * be called on a pinned entry. Added assert to verify this. + * JRM - 3/20/06 + * Pinned entries can't be evicted, so this entry should never + * be called on a pinned entry. Added assert to verify this. * - * JRM -- 3/28/07 - * Added sanity checks for the new is_read_only and - * ro_ref_count fields of struct H5C_cache_entry_t. + * JRM -- 3/28/07 + * Added sanity checks for the new is_read_only and + * ro_ref_count fields of struct H5C_cache_entry_t. * *------------------------------------------------------------------------- */ #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS -#define H5C__UPDATE_RP_FOR_EVICTION(cache_ptr, entry_ptr, fail_val) \ - { \ - HDassert((cache_ptr)); \ - HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ - HDassert((entry_ptr)); \ - HDassert(!((entry_ptr)->is_protected)); \ - HDassert(!((entry_ptr)->is_read_only)); \ - HDassert(((entry_ptr)->ro_ref_count) == 0); \ - HDassert(!((entry_ptr)->is_pinned)); \ - HDassert((entry_ptr)->size > 0); \ - \ - /* modified LRU specific code */ \ - \ - /* remove the entry from the LRU list. */ \ - \ - H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - /* If the entry is clean when it is evicted, it should be on the \ - * clean LRU list, if it was dirty, it should be on the dirty LRU list. \ - * Remove it from the appropriate list according to the value of the \ - * dirty flag. \ - */ \ - \ - if ((entry_ptr)->is_dirty) { \ - \ - H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->dLRU_head_ptr, (cache_ptr)->dLRU_tail_ptr, \ - (cache_ptr)->dLRU_list_len, (cache_ptr)->dLRU_list_size, (fail_val)) \ - } \ - else { \ - H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->cLRU_head_ptr, (cache_ptr)->cLRU_tail_ptr, \ - (cache_ptr)->cLRU_list_len, (cache_ptr)->cLRU_list_size, (fail_val)) \ - } \ - \ - } /* H5C__UPDATE_RP_FOR_EVICTION */ +#define H5C__UPDATE_RP_FOR_EVICTION(cache_ptr, entry_ptr, fail_val) \ +{ \ + HDassert( (cache_ptr) ); \ + HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ + HDassert( (entry_ptr) ); \ + HDassert( !((entry_ptr)->is_protected) ); \ + HDassert( !((entry_ptr)->is_read_only) ); \ + HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ + HDassert( !((entry_ptr)->is_pinned) ); \ + HDassert( (entry_ptr)->size > 0 ); \ + \ + /* modified LRU specific code */ \ + \ + /* remove the entry from the LRU list. */ \ + \ + H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ + (cache_ptr)->LRU_tail_ptr, (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + /* If the entry is clean when it is evicted, it should be on the \ + * clean LRU list, if it was dirty, it should be on the dirty LRU list. \ + * Remove it from the appropriate list according to the value of the \ + * dirty flag. \ + */ \ + \ + if ( (entry_ptr)->is_dirty ) { \ + \ + H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->dLRU_head_ptr, \ + (cache_ptr)->dLRU_tail_ptr, \ + (cache_ptr)->dLRU_list_len, \ + (cache_ptr)->dLRU_list_size, (fail_val)) \ + } else { \ + H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->cLRU_head_ptr, \ + (cache_ptr)->cLRU_tail_ptr, \ + (cache_ptr)->cLRU_list_len, \ + (cache_ptr)->cLRU_list_size, (fail_val)) \ + } \ + \ +} /* H5C__UPDATE_RP_FOR_EVICTION */ #else /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ -#define H5C__UPDATE_RP_FOR_EVICTION(cache_ptr, entry_ptr, fail_val) \ - { \ - HDassert((cache_ptr)); \ - HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ - HDassert((entry_ptr)); \ - HDassert(!((entry_ptr)->is_protected)); \ - HDassert(!((entry_ptr)->is_read_only)); \ - HDassert(((entry_ptr)->ro_ref_count) == 0); \ - HDassert(!((entry_ptr)->is_pinned)); \ - HDassert((entry_ptr)->size > 0); \ - \ - /* modified LRU specific code */ \ - \ - /* remove the entry from the LRU list. */ \ - \ - H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - } /* H5C__UPDATE_RP_FOR_EVICTION */ +#define H5C__UPDATE_RP_FOR_EVICTION(cache_ptr, entry_ptr, fail_val) \ +{ \ + HDassert( (cache_ptr) ); \ + HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ + HDassert( (entry_ptr) ); \ + HDassert( !((entry_ptr)->is_protected) ); \ + HDassert( !((entry_ptr)->is_read_only) ); \ + HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ + HDassert( !((entry_ptr)->is_pinned) ); \ + HDassert( (entry_ptr)->size > 0 ); \ + \ + /* modified LRU specific code */ \ + \ + /* remove the entry from the LRU list. */ \ + \ + H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ + (cache_ptr)->LRU_tail_ptr, (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_size, (fail_val)) \ + \ +} /* H5C__UPDATE_RP_FOR_EVICTION */ #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ + /*------------------------------------------------------------------------- * - * Macro: H5C__UPDATE_RP_FOR_FLUSH + * Macro: H5C__UPDATE_RP_FOR_FLUSH * * Purpose: Update the replacement policy data structures for a flush - * of the specified cache entry. + * of the specified cache entry. * - * At present, we only support the modified LRU policy, so - * this function deals with that case unconditionally. If - * we ever support other replacement policies, the function - * should switch on the current policy and act accordingly. + * At present, we only support the modified LRU policy, so + * this function deals with that case unconditionally. If + * we ever support other replacement policies, the function + * should switch on the current policy and act accordingly. * * Return: N/A * @@ -1863,137 +2059,151 @@ * * Modifications: * - * JRM - 7/27/04 - * Converted the function H5C_update_rp_for_flush() to the - * macro H5C__UPDATE_RP_FOR_FLUSH in an effort to squeeze - * a bit more performance out of the cache. + * JRM - 7/27/04 + * Converted the function H5C_update_rp_for_flush() to the + * macro H5C__UPDATE_RP_FOR_FLUSH in an effort to squeeze + * a bit more performance out of the cache. * - * At least for the first cut, I am leaving the comments and - * white space in the macro. If they cause difficulties with - * pre-processor, I'll have to remove them. + * At least for the first cut, I am leaving the comments and + * white space in the macro. If they cause difficulties with + * pre-processor, I'll have to remove them. * - * JRM - 7/28/04 - * Split macro into two versions, one supporting the clean and - * dirty LRU lists, and the other not. Yet another attempt - * at optimization. + * JRM - 7/28/04 + * Split macro into two versions, one supporting the clean and + * dirty LRU lists, and the other not. Yet another attempt + * at optimization. * - * JRM - 3/20/06 - * While pinned entries can be flushed, they don't reside in - * the replacement policy data structures when unprotected. - * Thus I modified this macro to do nothing if the entry is - * pinned. + * JRM - 3/20/06 + * While pinned entries can be flushed, they don't reside in + * the replacement policy data structures when unprotected. + * Thus I modified this macro to do nothing if the entry is + * pinned. * - * JRM - 3/28/07 - * Added sanity checks based on the new is_read_only and - * ro_ref_count fields of struct H5C_cache_entry_t. + * JRM - 3/28/07 + * Added sanity checks based on the new is_read_only and + * ro_ref_count fields of struct H5C_cache_entry_t. * *------------------------------------------------------------------------- */ #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS -#define H5C__UPDATE_RP_FOR_FLUSH(cache_ptr, entry_ptr, fail_val) \ - { \ - HDassert((cache_ptr)); \ - HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ - HDassert((entry_ptr)); \ - HDassert(!((entry_ptr)->is_protected)); \ - HDassert(!((entry_ptr)->is_read_only)); \ - HDassert(((entry_ptr)->ro_ref_count) == 0); \ - HDassert((entry_ptr)->size > 0); \ - \ - if (!((entry_ptr)->is_pinned)) { \ - \ - /* modified LRU specific code */ \ - \ - /* remove the entry from the LRU list, and re-insert it at the \ - * head. \ - */ \ - \ - H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - /* since the entry is being flushed or cleared, one would think \ - * that it must be dirty -- but that need not be the case. Use the \ - * dirty flag to infer whether the entry is on the clean or dirty \ - * LRU list, and remove it. Then insert it at the head of the \ - * clean LRU list. \ - * \ - * The function presumes that a dirty entry will be either cleared \ - * or flushed shortly, so it is OK if we put a dirty entry on the \ - * clean LRU list. \ - */ \ - \ - if ((entry_ptr)->is_dirty) { \ - H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->dLRU_head_ptr, (cache_ptr)->dLRU_tail_ptr, \ - (cache_ptr)->dLRU_list_len, (cache_ptr)->dLRU_list_size, (fail_val)) \ - } \ - else { \ - H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->cLRU_head_ptr, (cache_ptr)->cLRU_tail_ptr, \ - (cache_ptr)->cLRU_list_len, (cache_ptr)->cLRU_list_size, (fail_val)) \ - } \ - \ - H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->cLRU_head_ptr, (cache_ptr)->cLRU_tail_ptr, \ - (cache_ptr)->cLRU_list_len, (cache_ptr)->cLRU_list_size, (fail_val)) \ - \ - /* End modified LRU specific code. */ \ - } \ - } /* H5C__UPDATE_RP_FOR_FLUSH */ - -#else /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ - -#define H5C__UPDATE_RP_FOR_FLUSH(cache_ptr, entry_ptr, fail_val) \ - { \ - HDassert((cache_ptr)); \ - HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ - HDassert((entry_ptr)); \ - HDassert(!((entry_ptr)->is_protected)); \ - HDassert(!((entry_ptr)->is_read_only)); \ - HDassert(((entry_ptr)->ro_ref_count) == 0); \ - HDassert((entry_ptr)->size > 0); \ - \ - if (!((entry_ptr)->is_pinned)) { \ - \ - /* modified LRU specific code */ \ - \ - /* remove the entry from the LRU list, and re-insert it at the \ - * head. \ - */ \ - \ - H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - /* End modified LRU specific code. */ \ - } \ - } /* H5C__UPDATE_RP_FOR_FLUSH */ - +#define H5C__UPDATE_RP_FOR_FLUSH(cache_ptr, entry_ptr, fail_val) \ +{ \ + HDassert( (cache_ptr) ); \ + HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ + HDassert( (entry_ptr) ); \ + HDassert( !((entry_ptr)->is_protected) ); \ + HDassert( !((entry_ptr)->is_read_only) ); \ + HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ + HDassert( (entry_ptr)->size > 0 ); \ + \ + if ( ! ((entry_ptr)->is_pinned) ) { \ + \ + /* modified LRU specific code */ \ + \ + /* remove the entry from the LRU list, and re-insert it at the \ + * head. \ + */ \ + \ + H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ + (cache_ptr)->LRU_tail_ptr, \ + (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ + (cache_ptr)->LRU_tail_ptr, \ + (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + /* since the entry is being flushed or cleared, one would think \ + * that it must be dirty -- but that need not be the case. Use the \ + * dirty flag to infer whether the entry is on the clean or dirty \ + * LRU list, and remove it. Then insert it at the head of the \ + * clean LRU list. \ + * \ + * The function presumes that a dirty entry will be either cleared \ + * or flushed shortly, so it is OK if we put a dirty entry on the \ + * clean LRU list. \ + */ \ + \ + if ( (entry_ptr)->is_dirty ) { \ + H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->dLRU_head_ptr, \ + (cache_ptr)->dLRU_tail_ptr, \ + (cache_ptr)->dLRU_list_len, \ + (cache_ptr)->dLRU_list_size, (fail_val)) \ + } else { \ + H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->cLRU_head_ptr, \ + (cache_ptr)->cLRU_tail_ptr, \ + (cache_ptr)->cLRU_list_len, \ + (cache_ptr)->cLRU_list_size, (fail_val)) \ + } \ + \ + H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->cLRU_head_ptr, \ + (cache_ptr)->cLRU_tail_ptr, \ + (cache_ptr)->cLRU_list_len, \ + (cache_ptr)->cLRU_list_size, (fail_val)) \ + \ + /* End modified LRU specific code. */ \ + } \ +} /* H5C__UPDATE_RP_FOR_FLUSH */ + +#else /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ + +#define H5C__UPDATE_RP_FOR_FLUSH(cache_ptr, entry_ptr, fail_val) \ +{ \ + HDassert( (cache_ptr) ); \ + HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ + HDassert( (entry_ptr) ); \ + HDassert( !((entry_ptr)->is_protected) ); \ + HDassert( !((entry_ptr)->is_read_only) ); \ + HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ + HDassert( (entry_ptr)->size > 0 ); \ + \ + if ( ! ((entry_ptr)->is_pinned) ) { \ + \ + /* modified LRU specific code */ \ + \ + /* remove the entry from the LRU list, and re-insert it at the \ + * head. \ + */ \ + \ + H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ + (cache_ptr)->LRU_tail_ptr, \ + (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ + (cache_ptr)->LRU_tail_ptr, \ + (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + /* End modified LRU specific code. */ \ + } \ +} /* H5C__UPDATE_RP_FOR_FLUSH */ + #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ + /*------------------------------------------------------------------------- * - * Macro: H5C__UPDATE_RP_FOR_INSERT_APPEND + * Macro: H5C__UPDATE_RP_FOR_INSERT_APPEND * * Purpose: Update the replacement policy data structures for an - * insertion of the specified cache entry. + * insertion of the specified cache entry. * - * Unlike H5C__UPDATE_RP_FOR_INSERTION below, mark the - * new entry as the LEAST recently used entry, not the - * most recently used. + * Unlike H5C__UPDATE_RP_FOR_INSERTION below, mark the + * new entry as the LEAST recently used entry, not the + * most recently used. * - * For now at least, this macro should only be used in - * the reconstruction of the metadata cache from a cache - * image block. + * For now at least, this macro should only be used in + * the reconstruction of the metadata cache from a cache + * image block. * - * At present, we only support the modified LRU policy, so - * this function deals with that case unconditionally. If - * we ever support other replacement policies, the function - * should switch on the current policy and act accordingly. + * At present, we only support the modified LRU policy, so + * this function deals with that case unconditionally. If + * we ever support other replacement policies, the function + * should switch on the current policy and act accordingly. * * Return: N/A * @@ -2004,90 +2214,102 @@ #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS -#define H5C__UPDATE_RP_FOR_INSERT_APPEND(cache_ptr, entry_ptr, fail_val) \ - { \ - HDassert((cache_ptr)); \ - HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ - HDassert((entry_ptr)); \ - HDassert(!((entry_ptr)->is_protected)); \ - HDassert(!((entry_ptr)->is_read_only)); \ - HDassert(((entry_ptr)->ro_ref_count) == 0); \ - HDassert((entry_ptr)->size > 0); \ - \ - if ((entry_ptr)->is_pinned) { \ - \ - H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->pel_head_ptr, (cache_ptr)->pel_tail_ptr, \ - (cache_ptr)->pel_len, (cache_ptr)->pel_size, (fail_val)) \ - } \ - else { \ - \ - /* modified LRU specific code */ \ - \ - /* insert the entry at the tail of the LRU list. */ \ - \ - H5C__DLL_APPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - /* insert the entry at the tail of the clean or dirty LRU list as \ - * appropriate. \ - */ \ - \ - if (entry_ptr->is_dirty) { \ - H5C__AUX_DLL_APPEND((entry_ptr), (cache_ptr)->dLRU_head_ptr, (cache_ptr)->dLRU_tail_ptr, \ - (cache_ptr)->dLRU_list_len, (cache_ptr)->dLRU_list_size, (fail_val)) \ - } \ - else { \ - H5C__AUX_DLL_APPEND((entry_ptr), (cache_ptr)->cLRU_head_ptr, (cache_ptr)->cLRU_tail_ptr, \ - (cache_ptr)->cLRU_list_len, (cache_ptr)->cLRU_list_size, (fail_val)) \ - } \ - \ - /* End modified LRU specific code. */ \ - } \ - } +#define H5C__UPDATE_RP_FOR_INSERT_APPEND(cache_ptr, entry_ptr, fail_val) \ +{ \ + HDassert( (cache_ptr) ); \ + HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ + HDassert( (entry_ptr) ); \ + HDassert( !((entry_ptr)->is_protected) ); \ + HDassert( !((entry_ptr)->is_read_only) ); \ + HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ + HDassert( (entry_ptr)->size > 0 ); \ + \ + if ( (entry_ptr)->is_pinned ) { \ + \ + H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->pel_head_ptr, \ + (cache_ptr)->pel_tail_ptr, \ + (cache_ptr)->pel_len, \ + (cache_ptr)->pel_size, (fail_val)) \ + \ + } else { \ + \ + /* modified LRU specific code */ \ + \ + /* insert the entry at the tail of the LRU list. */ \ + \ + H5C__DLL_APPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ + (cache_ptr)->LRU_tail_ptr, \ + (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + /* insert the entry at the tail of the clean or dirty LRU list as \ + * appropriate. \ + */ \ + \ + if ( entry_ptr->is_dirty ) { \ + H5C__AUX_DLL_APPEND((entry_ptr), (cache_ptr)->dLRU_head_ptr, \ + (cache_ptr)->dLRU_tail_ptr, \ + (cache_ptr)->dLRU_list_len, \ + (cache_ptr)->dLRU_list_size, (fail_val)) \ + } else { \ + H5C__AUX_DLL_APPEND((entry_ptr), (cache_ptr)->cLRU_head_ptr, \ + (cache_ptr)->cLRU_tail_ptr, \ + (cache_ptr)->cLRU_list_len, \ + (cache_ptr)->cLRU_list_size, (fail_val)) \ + } \ + \ + /* End modified LRU specific code. */ \ + } \ +} #else /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ -#define H5C__UPDATE_RP_FOR_INSERT_APPEND(cache_ptr, entry_ptr, fail_val) \ - { \ - HDassert((cache_ptr)); \ - HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ - HDassert((entry_ptr)); \ - HDassert(!((entry_ptr)->is_protected)); \ - HDassert(!((entry_ptr)->is_read_only)); \ - HDassert(((entry_ptr)->ro_ref_count) == 0); \ - HDassert((entry_ptr)->size > 0); \ - \ - if ((entry_ptr)->is_pinned) { \ - \ - H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->pel_head_ptr, (cache_ptr)->pel_tail_ptr, \ - (cache_ptr)->pel_len, (cache_ptr)->pel_size, (fail_val)) \ - } \ - else { \ - \ - /* modified LRU specific code */ \ - \ - /* insert the entry at the tail of the LRU list. */ \ - \ - H5C__DLL_APPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - /* End modified LRU specific code. */ \ - } \ - } +#define H5C__UPDATE_RP_FOR_INSERT_APPEND(cache_ptr, entry_ptr, fail_val) \ +{ \ + HDassert( (cache_ptr) ); \ + HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ + HDassert( (entry_ptr) ); \ + HDassert( !((entry_ptr)->is_protected) ); \ + HDassert( !((entry_ptr)->is_read_only) ); \ + HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ + HDassert( (entry_ptr)->size > 0 ); \ + \ + if ( (entry_ptr)->is_pinned ) { \ + \ + H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->pel_head_ptr, \ + (cache_ptr)->pel_tail_ptr, \ + (cache_ptr)->pel_len, \ + (cache_ptr)->pel_size, (fail_val)) \ + \ + } else { \ + \ + /* modified LRU specific code */ \ + \ + /* insert the entry at the tail of the LRU list. */ \ + \ + H5C__DLL_APPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ + (cache_ptr)->LRU_tail_ptr, \ + (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + /* End modified LRU specific code. */ \ + } \ +} #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ + /*------------------------------------------------------------------------- * - * Macro: H5C__UPDATE_RP_FOR_INSERTION + * Macro: H5C__UPDATE_RP_FOR_INSERTION * * Purpose: Update the replacement policy data structures for an - * insertion of the specified cache entry. + * insertion of the specified cache entry. * - * At present, we only support the modified LRU policy, so - * this function deals with that case unconditionally. If - * we ever support other replacement policies, the function - * should switch on the current policy and act accordingly. + * At present, we only support the modified LRU policy, so + * this function deals with that case unconditionally. If + * we ever support other replacement policies, the function + * should switch on the current policy and act accordingly. * * Return: N/A * @@ -2095,125 +2317,137 @@ * * Modifications: * - * JRM - 7/27/04 - * Converted the function H5C_update_rp_for_insertion() to the - * macro H5C__UPDATE_RP_FOR_INSERTION in an effort to squeeze - * a bit more performance out of the cache. + * JRM - 7/27/04 + * Converted the function H5C_update_rp_for_insertion() to the + * macro H5C__UPDATE_RP_FOR_INSERTION in an effort to squeeze + * a bit more performance out of the cache. * - * At least for the first cut, I am leaving the comments and - * white space in the macro. If they cause difficulties with - * pre-processor, I'll have to remove them. + * At least for the first cut, I am leaving the comments and + * white space in the macro. If they cause difficulties with + * pre-processor, I'll have to remove them. * - * JRM - 7/28/04 - * Split macro into two version, one supporting the clean and - * dirty LRU lists, and the other not. Yet another attempt - * at optimization. + * JRM - 7/28/04 + * Split macro into two version, one supporting the clean and + * dirty LRU lists, and the other not. Yet another attempt + * at optimization. * - * JRM - 3/10/06 - * This macro should never be called on a pinned entry. - * Inserted an assert to verify this. + * JRM - 3/10/06 + * This macro should never be called on a pinned entry. + * Inserted an assert to verify this. * - * JRM - 8/9/06 - * Not any more. We must now allow insertion of pinned - * entries. Updated macro to support this. + * JRM - 8/9/06 + * Not any more. We must now allow insertion of pinned + * entries. Updated macro to support this. * - * JRM - 3/28/07 - * Added sanity checks using the new is_read_only and - * ro_ref_count fields of struct H5C_cache_entry_t. + * JRM - 3/28/07 + * Added sanity checks using the new is_read_only and + * ro_ref_count fields of struct H5C_cache_entry_t. * *------------------------------------------------------------------------- */ #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS -#define H5C__UPDATE_RP_FOR_INSERTION(cache_ptr, entry_ptr, fail_val) \ - { \ - HDassert((cache_ptr)); \ - HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ - HDassert((entry_ptr)); \ - HDassert(!((entry_ptr)->is_protected)); \ - HDassert(!((entry_ptr)->is_read_only)); \ - HDassert(((entry_ptr)->ro_ref_count) == 0); \ - HDassert((entry_ptr)->size > 0); \ - \ - if ((entry_ptr)->is_pinned) { \ - \ - H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->pel_head_ptr, (cache_ptr)->pel_tail_ptr, \ - (cache_ptr)->pel_len, (cache_ptr)->pel_size, (fail_val)) \ - } \ - else { \ - \ - /* modified LRU specific code */ \ - \ - /* insert the entry at the head of the LRU list. */ \ - \ - H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - /* insert the entry at the head of the clean or dirty LRU list as \ - * appropriate. \ - */ \ - \ - if (entry_ptr->is_dirty) { \ - H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->dLRU_head_ptr, (cache_ptr)->dLRU_tail_ptr, \ - (cache_ptr)->dLRU_list_len, (cache_ptr)->dLRU_list_size, (fail_val)) \ - } \ - else { \ - H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->cLRU_head_ptr, (cache_ptr)->cLRU_tail_ptr, \ - (cache_ptr)->cLRU_list_len, (cache_ptr)->cLRU_list_size, (fail_val)) \ - } \ - \ - /* End modified LRU specific code. */ \ - } \ - } +#define H5C__UPDATE_RP_FOR_INSERTION(cache_ptr, entry_ptr, fail_val) \ +{ \ + HDassert( (cache_ptr) ); \ + HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ + HDassert( (entry_ptr) ); \ + HDassert( !((entry_ptr)->is_protected) ); \ + HDassert( !((entry_ptr)->is_read_only) ); \ + HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ + HDassert( (entry_ptr)->size > 0 ); \ + \ + if ( (entry_ptr)->is_pinned ) { \ + \ + H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->pel_head_ptr, \ + (cache_ptr)->pel_tail_ptr, \ + (cache_ptr)->pel_len, \ + (cache_ptr)->pel_size, (fail_val)) \ + \ + } else { \ + \ + /* modified LRU specific code */ \ + \ + /* insert the entry at the head of the LRU list. */ \ + \ + H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ + (cache_ptr)->LRU_tail_ptr, \ + (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + /* insert the entry at the head of the clean or dirty LRU list as \ + * appropriate. \ + */ \ + \ + if ( entry_ptr->is_dirty ) { \ + H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->dLRU_head_ptr, \ + (cache_ptr)->dLRU_tail_ptr, \ + (cache_ptr)->dLRU_list_len, \ + (cache_ptr)->dLRU_list_size, (fail_val)) \ + } else { \ + H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->cLRU_head_ptr, \ + (cache_ptr)->cLRU_tail_ptr, \ + (cache_ptr)->cLRU_list_len, \ + (cache_ptr)->cLRU_list_size, (fail_val)) \ + } \ + \ + /* End modified LRU specific code. */ \ + } \ +} #else /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ -#define H5C__UPDATE_RP_FOR_INSERTION(cache_ptr, entry_ptr, fail_val) \ - { \ - HDassert((cache_ptr)); \ - HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ - HDassert((entry_ptr)); \ - HDassert(!((entry_ptr)->is_protected)); \ - HDassert(!((entry_ptr)->is_read_only)); \ - HDassert(((entry_ptr)->ro_ref_count) == 0); \ - HDassert((entry_ptr)->size > 0); \ - \ - if ((entry_ptr)->is_pinned) { \ - \ - H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->pel_head_ptr, (cache_ptr)->pel_tail_ptr, \ - (cache_ptr)->pel_len, (cache_ptr)->pel_size, (fail_val)) \ - } \ - else { \ - \ - /* modified LRU specific code */ \ - \ - /* insert the entry at the head of the LRU list. */ \ - \ - H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - /* End modified LRU specific code. */ \ - } \ - } +#define H5C__UPDATE_RP_FOR_INSERTION(cache_ptr, entry_ptr, fail_val) \ +{ \ + HDassert( (cache_ptr) ); \ + HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ + HDassert( (entry_ptr) ); \ + HDassert( !((entry_ptr)->is_protected) ); \ + HDassert( !((entry_ptr)->is_read_only) ); \ + HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ + HDassert( (entry_ptr)->size > 0 ); \ + \ + if ( (entry_ptr)->is_pinned ) { \ + \ + H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->pel_head_ptr, \ + (cache_ptr)->pel_tail_ptr, \ + (cache_ptr)->pel_len, \ + (cache_ptr)->pel_size, (fail_val)) \ + \ + } else { \ + \ + /* modified LRU specific code */ \ + \ + /* insert the entry at the head of the LRU list. */ \ + \ + H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ + (cache_ptr)->LRU_tail_ptr, \ + (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + /* End modified LRU specific code. */ \ + } \ +} #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ + /*------------------------------------------------------------------------- * - * Macro: H5C__UPDATE_RP_FOR_PROTECT + * Macro: H5C__UPDATE_RP_FOR_PROTECT * * Purpose: Update the replacement policy data structures for a - * protect of the specified cache entry. + * protect of the specified cache entry. * - * To do this, unlink the specified entry from any data - * structures used by the replacement policy, and add the - * entry to the protected list. + * To do this, unlink the specified entry from any data + * structures used by the replacement policy, and add the + * entry to the protected list. * - * At present, we only support the modified LRU policy, so - * this function deals with that case unconditionally. If - * we ever support other replacement policies, the function - * should switch on the current policy and act accordingly. + * At present, we only support the modified LRU policy, so + * this function deals with that case unconditionally. If + * we ever support other replacement policies, the function + * should switch on the current policy and act accordingly. * * Return: N/A * @@ -2221,134 +2455,151 @@ * * Modifications: * - * JRM - 7/27/04 - * Converted the function H5C_update_rp_for_protect() to the - * macro H5C__UPDATE_RP_FOR_PROTECT in an effort to squeeze - * a bit more performance out of the cache. + * JRM - 7/27/04 + * Converted the function H5C_update_rp_for_protect() to the + * macro H5C__UPDATE_RP_FOR_PROTECT in an effort to squeeze + * a bit more performance out of the cache. * - * At least for the first cut, I am leaving the comments and - * white space in the macro. If they cause difficulties with - * pre-processor, I'll have to remove them. + * At least for the first cut, I am leaving the comments and + * white space in the macro. If they cause difficulties with + * pre-processor, I'll have to remove them. * - * JRM - 7/28/04 - * Split macro into two version, one supporting the clean and - * dirty LRU lists, and the other not. Yet another attempt - * at optimization. + * JRM - 7/28/04 + * Split macro into two version, one supporting the clean and + * dirty LRU lists, and the other not. Yet another attempt + * at optimization. * - * JRM - 3/17/06 - * Modified macro to attempt to remove pinned entriese from - * the pinned entry list instead of from the data structures - * maintained by the replacement policy. + * JRM - 3/17/06 + * Modified macro to attempt to remove pinned entriese from + * the pinned entry list instead of from the data structures + * maintained by the replacement policy. * - * JRM - 3/28/07 - * Added sanity checks based on the new is_read_only and - * ro_ref_count fields of struct H5C_cache_entry_t. + * JRM - 3/28/07 + * Added sanity checks based on the new is_read_only and + * ro_ref_count fields of struct H5C_cache_entry_t. * *------------------------------------------------------------------------- */ #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS -#define H5C__UPDATE_RP_FOR_PROTECT(cache_ptr, entry_ptr, fail_val) \ - { \ - HDassert((cache_ptr)); \ - HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ - HDassert((entry_ptr)); \ - HDassert(!((entry_ptr)->is_protected)); \ - HDassert(!((entry_ptr)->is_read_only)); \ - HDassert(((entry_ptr)->ro_ref_count) == 0); \ - HDassert((entry_ptr)->size > 0); \ - \ - if ((entry_ptr)->is_pinned) { \ - \ - H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->pel_head_ptr, (cache_ptr)->pel_tail_ptr, \ - (cache_ptr)->pel_len, (cache_ptr)->pel_size, (fail_val)) \ - } \ - else { \ - \ - /* modified LRU specific code */ \ - \ - /* remove the entry from the LRU list. */ \ - \ - H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - /* Similarly, remove the entry from the clean or dirty LRU list \ - * as appropriate. \ - */ \ - \ - if ((entry_ptr)->is_dirty) { \ - \ - H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->dLRU_head_ptr, (cache_ptr)->dLRU_tail_ptr, \ - (cache_ptr)->dLRU_list_len, (cache_ptr)->dLRU_list_size, (fail_val)) \ - } \ - else { \ - \ - H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->cLRU_head_ptr, (cache_ptr)->cLRU_tail_ptr, \ - (cache_ptr)->cLRU_list_len, (cache_ptr)->cLRU_list_size, (fail_val)) \ - } \ - \ - /* End modified LRU specific code. */ \ - } \ - \ - /* Regardless of the replacement policy, or whether the entry is \ - * pinned, now add the entry to the protected list. \ - */ \ - \ - H5C__DLL_APPEND((entry_ptr), (cache_ptr)->pl_head_ptr, (cache_ptr)->pl_tail_ptr, \ - (cache_ptr)->pl_len, (cache_ptr)->pl_size, (fail_val)) \ - } /* H5C__UPDATE_RP_FOR_PROTECT */ +#define H5C__UPDATE_RP_FOR_PROTECT(cache_ptr, entry_ptr, fail_val) \ +{ \ + HDassert( (cache_ptr) ); \ + HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ + HDassert( (entry_ptr) ); \ + HDassert( !((entry_ptr)->is_protected) ); \ + HDassert( !((entry_ptr)->is_read_only) ); \ + HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ + HDassert( (entry_ptr)->size > 0 ); \ + \ + if ( (entry_ptr)->is_pinned ) { \ + \ + H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->pel_head_ptr, \ + (cache_ptr)->pel_tail_ptr, \ + (cache_ptr)->pel_len, \ + (cache_ptr)->pel_size, (fail_val)) \ + \ + } else { \ + \ + /* modified LRU specific code */ \ + \ + /* remove the entry from the LRU list. */ \ + \ + H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ + (cache_ptr)->LRU_tail_ptr, \ + (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + /* Similarly, remove the entry from the clean or dirty LRU list \ + * as appropriate. \ + */ \ + \ + if ( (entry_ptr)->is_dirty ) { \ + \ + H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->dLRU_head_ptr, \ + (cache_ptr)->dLRU_tail_ptr, \ + (cache_ptr)->dLRU_list_len, \ + (cache_ptr)->dLRU_list_size, (fail_val)) \ + \ + } else { \ + \ + H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->cLRU_head_ptr, \ + (cache_ptr)->cLRU_tail_ptr, \ + (cache_ptr)->cLRU_list_len, \ + (cache_ptr)->cLRU_list_size, (fail_val)) \ + } \ + \ + /* End modified LRU specific code. */ \ + } \ + \ + /* Regardless of the replacement policy, or whether the entry is \ + * pinned, now add the entry to the protected list. \ + */ \ + \ + H5C__DLL_APPEND((entry_ptr), (cache_ptr)->pl_head_ptr, \ + (cache_ptr)->pl_tail_ptr, \ + (cache_ptr)->pl_len, \ + (cache_ptr)->pl_size, (fail_val)) \ +} /* H5C__UPDATE_RP_FOR_PROTECT */ #else /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ -#define H5C__UPDATE_RP_FOR_PROTECT(cache_ptr, entry_ptr, fail_val) \ - { \ - HDassert((cache_ptr)); \ - HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ - HDassert((entry_ptr)); \ - HDassert(!((entry_ptr)->is_protected)); \ - HDassert(!((entry_ptr)->is_read_only)); \ - HDassert(((entry_ptr)->ro_ref_count) == 0); \ - HDassert((entry_ptr)->size > 0); \ - \ - if ((entry_ptr)->is_pinned) { \ - \ - H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->pel_head_ptr, (cache_ptr)->pel_tail_ptr, \ - (cache_ptr)->pel_len, (cache_ptr)->pel_size, (fail_val)) \ - } \ - else { \ - \ - /* modified LRU specific code */ \ - \ - /* remove the entry from the LRU list. */ \ - \ - H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - /* End modified LRU specific code. */ \ - } \ - \ - /* Regardless of the replacement policy, or whether the entry is \ - * pinned, now add the entry to the protected list. \ - */ \ - \ - H5C__DLL_APPEND((entry_ptr), (cache_ptr)->pl_head_ptr, (cache_ptr)->pl_tail_ptr, \ - (cache_ptr)->pl_len, (cache_ptr)->pl_size, (fail_val)) \ - } /* H5C__UPDATE_RP_FOR_PROTECT */ +#define H5C__UPDATE_RP_FOR_PROTECT(cache_ptr, entry_ptr, fail_val) \ +{ \ + HDassert( (cache_ptr) ); \ + HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ + HDassert( (entry_ptr) ); \ + HDassert( !((entry_ptr)->is_protected) ); \ + HDassert( !((entry_ptr)->is_read_only) ); \ + HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ + HDassert( (entry_ptr)->size > 0 ); \ + \ + if ( (entry_ptr)->is_pinned ) { \ + \ + H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->pel_head_ptr, \ + (cache_ptr)->pel_tail_ptr, \ + (cache_ptr)->pel_len, \ + (cache_ptr)->pel_size, (fail_val)) \ + \ + } else { \ + \ + /* modified LRU specific code */ \ + \ + /* remove the entry from the LRU list. */ \ + \ + H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ + (cache_ptr)->LRU_tail_ptr, \ + (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + /* End modified LRU specific code. */ \ + } \ + \ + /* Regardless of the replacement policy, or whether the entry is \ + * pinned, now add the entry to the protected list. \ + */ \ + \ + H5C__DLL_APPEND((entry_ptr), (cache_ptr)->pl_head_ptr, \ + (cache_ptr)->pl_tail_ptr, \ + (cache_ptr)->pl_len, \ + (cache_ptr)->pl_size, (fail_val)) \ +} /* H5C__UPDATE_RP_FOR_PROTECT */ #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ + /*------------------------------------------------------------------------- * - * Macro: H5C__UPDATE_RP_FOR_MOVE + * Macro: H5C__UPDATE_RP_FOR_MOVE * * Purpose: Update the replacement policy data structures for a - * move of the specified cache entry. + * move of the specified cache entry. * - * At present, we only support the modified LRU policy, so - * this function deals with that case unconditionally. If - * we ever support other replacement policies, the function - * should switch on the current policy and act accordingly. + * At present, we only support the modified LRU policy, so + * this function deals with that case unconditionally. If + * we ever support other replacement policies, the function + * should switch on the current policy and act accordingly. * * Return: N/A * @@ -2359,109 +2610,134 @@ #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS -#define H5C__UPDATE_RP_FOR_MOVE(cache_ptr, entry_ptr, was_dirty, fail_val) \ - { \ - HDassert((cache_ptr)); \ - HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ - HDassert((entry_ptr)); \ - HDassert(!((entry_ptr)->is_read_only)); \ - HDassert(((entry_ptr)->ro_ref_count) == 0); \ - HDassert((entry_ptr)->size > 0); \ - \ - if (!((entry_ptr)->is_pinned) && !((entry_ptr->is_protected))) { \ - \ - /* modified LRU specific code */ \ - \ - /* remove the entry from the LRU list, and re-insert it at the head. \ - */ \ - \ - H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - /* remove the entry from either the clean or dirty LUR list as \ - * indicated by the was_dirty parameter \ - */ \ - if (was_dirty) { \ - \ - H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->dLRU_head_ptr, (cache_ptr)->dLRU_tail_ptr, \ - (cache_ptr)->dLRU_list_len, (cache_ptr)->dLRU_list_size, (fail_val)) \ - } \ - else { \ - \ - H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->cLRU_head_ptr, (cache_ptr)->cLRU_tail_ptr, \ - (cache_ptr)->cLRU_list_len, (cache_ptr)->cLRU_list_size, (fail_val)) \ - } \ - \ - /* insert the entry at the head of either the clean or dirty \ - * LRU list as appropriate. \ - */ \ - \ - if ((entry_ptr)->is_dirty) { \ - \ - H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->dLRU_head_ptr, (cache_ptr)->dLRU_tail_ptr, \ - (cache_ptr)->dLRU_list_len, (cache_ptr)->dLRU_list_size, (fail_val)) \ - } \ - else { \ - \ - H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->cLRU_head_ptr, (cache_ptr)->cLRU_tail_ptr, \ - (cache_ptr)->cLRU_list_len, (cache_ptr)->cLRU_list_size, (fail_val)) \ - } \ - \ - /* End modified LRU specific code. */ \ - } \ - } /* H5C__UPDATE_RP_FOR_MOVE */ +#define H5C__UPDATE_RP_FOR_MOVE(cache_ptr, entry_ptr, was_dirty, fail_val) \ +{ \ + HDassert( (cache_ptr) ); \ + HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ + HDassert( (entry_ptr) ); \ + HDassert( !((entry_ptr)->is_read_only) ); \ + HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ + HDassert( (entry_ptr)->size > 0 ); \ + \ + if ( ! ( (entry_ptr)->is_pinned ) && ! ( (entry_ptr->is_protected ) ) ) { \ + \ + /* modified LRU specific code */ \ + \ + /* remove the entry from the LRU list, and re-insert it at the head. \ + */ \ + \ + H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ + (cache_ptr)->LRU_tail_ptr, \ + (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ + (cache_ptr)->LRU_tail_ptr, \ + (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + /* remove the entry from either the clean or dirty LUR list as \ + * indicated by the was_dirty parameter \ + */ \ + if ( was_dirty ) { \ + \ + H5C__AUX_DLL_REMOVE((entry_ptr), \ + (cache_ptr)->dLRU_head_ptr, \ + (cache_ptr)->dLRU_tail_ptr, \ + (cache_ptr)->dLRU_list_len, \ + (cache_ptr)->dLRU_list_size, \ + (fail_val)) \ + \ + } else { \ + \ + H5C__AUX_DLL_REMOVE((entry_ptr), \ + (cache_ptr)->cLRU_head_ptr, \ + (cache_ptr)->cLRU_tail_ptr, \ + (cache_ptr)->cLRU_list_len, \ + (cache_ptr)->cLRU_list_size, \ + (fail_val)) \ + } \ + \ + /* insert the entry at the head of either the clean or dirty \ + * LRU list as appropriate. \ + */ \ + \ + if ( (entry_ptr)->is_dirty ) { \ + \ + H5C__AUX_DLL_PREPEND((entry_ptr), \ + (cache_ptr)->dLRU_head_ptr, \ + (cache_ptr)->dLRU_tail_ptr, \ + (cache_ptr)->dLRU_list_len, \ + (cache_ptr)->dLRU_list_size, \ + (fail_val)) \ + \ + } else { \ + \ + H5C__AUX_DLL_PREPEND((entry_ptr), \ + (cache_ptr)->cLRU_head_ptr, \ + (cache_ptr)->cLRU_tail_ptr, \ + (cache_ptr)->cLRU_list_len, \ + (cache_ptr)->cLRU_list_size, \ + (fail_val)) \ + } \ + \ + /* End modified LRU specific code. */ \ + } \ +} /* H5C__UPDATE_RP_FOR_MOVE */ #else /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ -#define H5C__UPDATE_RP_FOR_MOVE(cache_ptr, entry_ptr, was_dirty, fail_val) \ - { \ - HDassert((cache_ptr)); \ - HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ - HDassert((entry_ptr)); \ - HDassert(!((entry_ptr)->is_read_only)); \ - HDassert(((entry_ptr)->ro_ref_count) == 0); \ - HDassert((entry_ptr)->size > 0); \ - \ - if (!((entry_ptr)->is_pinned) && !((entry_ptr->is_protected))) { \ - \ - /* modified LRU specific code */ \ - \ - /* remove the entry from the LRU list, and re-insert it at the head. \ - */ \ - \ - H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - /* End modified LRU specific code. */ \ - } \ - } /* H5C__UPDATE_RP_FOR_MOVE */ +#define H5C__UPDATE_RP_FOR_MOVE(cache_ptr, entry_ptr, was_dirty, fail_val) \ +{ \ + HDassert( (cache_ptr) ); \ + HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ + HDassert( (entry_ptr) ); \ + HDassert( !((entry_ptr)->is_read_only) ); \ + HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ + HDassert( (entry_ptr)->size > 0 ); \ + \ + if ( ! ( (entry_ptr)->is_pinned ) && ! ( (entry_ptr->is_protected ) ) ) { \ + \ + /* modified LRU specific code */ \ + \ + /* remove the entry from the LRU list, and re-insert it at the head. \ + */ \ + \ + H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ + (cache_ptr)->LRU_tail_ptr, \ + (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ + (cache_ptr)->LRU_tail_ptr, \ + (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + /* End modified LRU specific code. */ \ + } \ +} /* H5C__UPDATE_RP_FOR_MOVE */ #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ + /*------------------------------------------------------------------------- * - * Macro: H5C__UPDATE_RP_FOR_SIZE_CHANGE + * Macro: H5C__UPDATE_RP_FOR_SIZE_CHANGE * * Purpose: Update the replacement policy data structures for a - * size change of the specified cache entry. + * size change of the specified cache entry. * - * To do this, determine if the entry is pinned. If it is, - * update the size of the pinned entry list. + * To do this, determine if the entry is pinned. If it is, + * update the size of the pinned entry list. * - * If it isn't pinned, the entry must handled by the - * replacement policy. Update the appropriate replacement - * policy data structures. + * If it isn't pinned, the entry must handled by the + * replacement policy. Update the appropriate replacement + * policy data structures. * - * At present, we only support the modified LRU policy, so - * this function deals with that case unconditionally. If - * we ever support other replacement policies, the function - * should switch on the current policy and act accordingly. + * At present, we only support the modified LRU policy, so + * this function deals with that case unconditionally. If + * we ever support other replacement policies, the function + * should switch on the current policy and act accordingly. * * Return: N/A * @@ -2469,116 +2745,132 @@ * * Modifications: * - * JRM -- 3/28/07 - * Added sanity checks based on the new is_read_only and - * ro_ref_count fields of struct H5C_cache_entry_t. + * JRM -- 3/28/07 + * Added sanity checks based on the new is_read_only and + * ro_ref_count fields of struct H5C_cache_entry_t. * *------------------------------------------------------------------------- */ #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS -#define H5C__UPDATE_RP_FOR_SIZE_CHANGE(cache_ptr, entry_ptr, new_size) \ - { \ - HDassert((cache_ptr)); \ - HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ - HDassert((entry_ptr)); \ - HDassert(!((entry_ptr)->is_protected)); \ - HDassert(!((entry_ptr)->is_read_only)); \ - HDassert(((entry_ptr)->ro_ref_count) == 0); \ - HDassert((entry_ptr)->size > 0); \ - HDassert(new_size > 0); \ - \ - if ((entry_ptr)->coll_access) { \ - \ - H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->coll_list_len, (cache_ptr)->coll_list_size, \ - (entry_ptr)->size, (new_size)); \ - } \ - \ - if ((entry_ptr)->is_pinned) { \ - \ - H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->pel_len, (cache_ptr)->pel_size, (entry_ptr)->size, \ - (new_size)); \ - } \ - else { \ - \ - /* modified LRU specific code */ \ - \ - /* Update the size of the LRU list */ \ - \ - H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, \ - (entry_ptr)->size, (new_size)); \ - \ - /* Similarly, update the size of the clean or dirty LRU list as \ - * appropriate. At present, the entry must be clean, but that \ - * could change. \ - */ \ - \ - if ((entry_ptr)->is_dirty) { \ - \ - H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->dLRU_list_len, (cache_ptr)->dLRU_list_size, \ - (entry_ptr)->size, (new_size)); \ - } \ - else { \ - \ - H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->cLRU_list_len, (cache_ptr)->cLRU_list_size, \ - (entry_ptr)->size, (new_size)); \ - } \ - \ - /* End modified LRU specific code. */ \ - } \ - \ - } /* H5C__UPDATE_RP_FOR_SIZE_CHANGE */ +#define H5C__UPDATE_RP_FOR_SIZE_CHANGE(cache_ptr, entry_ptr, new_size) \ +{ \ + HDassert( (cache_ptr) ); \ + HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ + HDassert( (entry_ptr) ); \ + HDassert( !((entry_ptr)->is_protected) ); \ + HDassert( !((entry_ptr)->is_read_only) ); \ + HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ + HDassert( (entry_ptr)->size > 0 ); \ + HDassert( new_size > 0 ); \ + \ + if ( (entry_ptr)->coll_access ) { \ + \ + H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->coll_list_len, \ + (cache_ptr)->coll_list_size, \ + (entry_ptr)->size, \ + (new_size)); \ + \ + } \ + \ + if ( (entry_ptr)->is_pinned ) { \ + \ + H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->pel_len, \ + (cache_ptr)->pel_size, \ + (entry_ptr)->size, \ + (new_size)); \ + \ + } else { \ + \ + /* modified LRU specific code */ \ + \ + /* Update the size of the LRU list */ \ + \ + H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_size, \ + (entry_ptr)->size, \ + (new_size)); \ + \ + /* Similarly, update the size of the clean or dirty LRU list as \ + * appropriate. At present, the entry must be clean, but that \ + * could change. \ + */ \ + \ + if ( (entry_ptr)->is_dirty ) { \ + \ + H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->dLRU_list_len, \ + (cache_ptr)->dLRU_list_size, \ + (entry_ptr)->size, \ + (new_size)); \ + \ + } else { \ + \ + H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->cLRU_list_len, \ + (cache_ptr)->cLRU_list_size, \ + (entry_ptr)->size, \ + (new_size)); \ + } \ + \ + /* End modified LRU specific code. */ \ + } \ + \ +} /* H5C__UPDATE_RP_FOR_SIZE_CHANGE */ #else /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ -#define H5C__UPDATE_RP_FOR_SIZE_CHANGE(cache_ptr, entry_ptr, new_size) \ - { \ - HDassert((cache_ptr)); \ - HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ - HDassert((entry_ptr)); \ - HDassert(!((entry_ptr)->is_protected)); \ - HDassert(!((entry_ptr)->is_read_only)); \ - HDassert(((entry_ptr)->ro_ref_count) == 0); \ - HDassert((entry_ptr)->size > 0); \ - HDassert(new_size > 0); \ - \ - if ((entry_ptr)->is_pinned) { \ - \ - H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->pel_len, (cache_ptr)->pel_size, (entry_ptr)->size, \ - (new_size)); \ - } \ - else { \ - \ - /* modified LRU specific code */ \ - \ - /* Update the size of the LRU list */ \ - \ - H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, \ - (entry_ptr)->size, (new_size)); \ - \ - /* End modified LRU specific code. */ \ - } \ - \ - } /* H5C__UPDATE_RP_FOR_SIZE_CHANGE */ +#define H5C__UPDATE_RP_FOR_SIZE_CHANGE(cache_ptr, entry_ptr, new_size) \ +{ \ + HDassert( (cache_ptr) ); \ + HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ + HDassert( (entry_ptr) ); \ + HDassert( !((entry_ptr)->is_protected) ); \ + HDassert( !((entry_ptr)->is_read_only) ); \ + HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ + HDassert( (entry_ptr)->size > 0 ); \ + HDassert( new_size > 0 ); \ + \ + if ( (entry_ptr)->is_pinned ) { \ + \ + H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->pel_len, \ + (cache_ptr)->pel_size, \ + (entry_ptr)->size, \ + (new_size)); \ + \ + } else { \ + \ + /* modified LRU specific code */ \ + \ + /* Update the size of the LRU list */ \ + \ + H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_size, \ + (entry_ptr)->size, \ + (new_size)); \ + \ + /* End modified LRU specific code. */ \ + } \ + \ +} /* H5C__UPDATE_RP_FOR_SIZE_CHANGE */ #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ + /*------------------------------------------------------------------------- * - * Macro: H5C__UPDATE_RP_FOR_UNPIN + * Macro: H5C__UPDATE_RP_FOR_UNPIN * * Purpose: Update the replacement policy data structures for an - * unpin of the specified cache entry. + * unpin of the specified cache entry. * - * To do this, unlink the specified entry from the protected - * entry list, and re-insert it in the data structures used - * by the current replacement policy. + * To do this, unlink the specified entry from the protected + * entry list, and re-insert it in the data structures used + * by the current replacement policy. * - * At present, we only support the modified LRU policy, so - * this function deals with that case unconditionally. If - * we ever support other replacement policies, the macro - * should switch on the current policy and act accordingly. + * At present, we only support the modified LRU policy, so + * this function deals with that case unconditionally. If + * we ever support other replacement policies, the macro + * should switch on the current policy and act accordingly. * * Return: N/A * @@ -2586,105 +2878,120 @@ * * Modifications: * - * JRM -- 3/28/07 - * Added sanity checks based on the new is_read_only and - * ro_ref_count fields of struct H5C_cache_entry_t. + * JRM -- 3/28/07 + * Added sanity checks based on the new is_read_only and + * ro_ref_count fields of struct H5C_cache_entry_t. * *------------------------------------------------------------------------- */ #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS -#define H5C__UPDATE_RP_FOR_UNPIN(cache_ptr, entry_ptr, fail_val) \ - { \ - HDassert((cache_ptr)); \ - HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ - HDassert((entry_ptr)); \ - HDassert(!((entry_ptr)->is_protected)); \ - HDassert(!((entry_ptr)->is_read_only)); \ - HDassert(((entry_ptr)->ro_ref_count) == 0); \ - HDassert((entry_ptr)->is_pinned); \ - HDassert((entry_ptr)->size > 0); \ - \ - /* Regardless of the replacement policy, remove the entry from the \ - * pinned entry list. \ - */ \ - H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->pel_head_ptr, (cache_ptr)->pel_tail_ptr, \ - (cache_ptr)->pel_len, (cache_ptr)->pel_size, (fail_val)) \ - \ - /* modified LRU specific code */ \ - \ - /* insert the entry at the head of the LRU list. */ \ - \ - H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - /* Similarly, insert the entry at the head of either the clean \ - * or dirty LRU list as appropriate. \ - */ \ - \ - if ((entry_ptr)->is_dirty) { \ - \ - H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->dLRU_head_ptr, (cache_ptr)->dLRU_tail_ptr, \ - (cache_ptr)->dLRU_list_len, (cache_ptr)->dLRU_list_size, (fail_val)) \ - } \ - else { \ - \ - H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->cLRU_head_ptr, (cache_ptr)->cLRU_tail_ptr, \ - (cache_ptr)->cLRU_list_len, (cache_ptr)->cLRU_list_size, (fail_val)) \ - } \ - \ - /* End modified LRU specific code. */ \ - \ - } /* H5C__UPDATE_RP_FOR_UNPIN */ +#define H5C__UPDATE_RP_FOR_UNPIN(cache_ptr, entry_ptr, fail_val) \ +{ \ + HDassert( (cache_ptr) ); \ + HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ + HDassert( (entry_ptr) ); \ + HDassert( !((entry_ptr)->is_protected) ); \ + HDassert( !((entry_ptr)->is_read_only) ); \ + HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ + HDassert( (entry_ptr)->is_pinned); \ + HDassert( (entry_ptr)->size > 0 ); \ + \ + /* Regardless of the replacement policy, remove the entry from the \ + * pinned entry list. \ + */ \ + H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->pel_head_ptr, \ + (cache_ptr)->pel_tail_ptr, (cache_ptr)->pel_len, \ + (cache_ptr)->pel_size, (fail_val)) \ + \ + /* modified LRU specific code */ \ + \ + /* insert the entry at the head of the LRU list. */ \ + \ + H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ + (cache_ptr)->LRU_tail_ptr, \ + (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + /* Similarly, insert the entry at the head of either the clean \ + * or dirty LRU list as appropriate. \ + */ \ + \ + if ( (entry_ptr)->is_dirty ) { \ + \ + H5C__AUX_DLL_PREPEND((entry_ptr), \ + (cache_ptr)->dLRU_head_ptr, \ + (cache_ptr)->dLRU_tail_ptr, \ + (cache_ptr)->dLRU_list_len, \ + (cache_ptr)->dLRU_list_size, \ + (fail_val)) \ + \ + } else { \ + \ + H5C__AUX_DLL_PREPEND((entry_ptr), \ + (cache_ptr)->cLRU_head_ptr, \ + (cache_ptr)->cLRU_tail_ptr, \ + (cache_ptr)->cLRU_list_len, \ + (cache_ptr)->cLRU_list_size, \ + (fail_val)) \ + } \ + \ + /* End modified LRU specific code. */ \ + \ +} /* H5C__UPDATE_RP_FOR_UNPIN */ #else /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ -#define H5C__UPDATE_RP_FOR_UNPIN(cache_ptr, entry_ptr, fail_val) \ - { \ - HDassert((cache_ptr)); \ - HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ - HDassert((entry_ptr)); \ - HDassert(!((entry_ptr)->is_protected)); \ - HDassert(!((entry_ptr)->is_read_only)); \ - HDassert(((entry_ptr)->ro_ref_count) == 0); \ - HDassert((entry_ptr)->is_pinned); \ - HDassert((entry_ptr)->size > 0); \ - \ - /* Regardless of the replacement policy, remove the entry from the \ - * pinned entry list. \ - */ \ - H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->pel_head_ptr, (cache_ptr)->pel_tail_ptr, \ - (cache_ptr)->pel_len, (cache_ptr)->pel_size, (fail_val)) \ - \ - /* modified LRU specific code */ \ - \ - /* insert the entry at the head of the LRU list. */ \ - \ - H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - /* End modified LRU specific code. */ \ - \ - } /* H5C__UPDATE_RP_FOR_UNPIN */ +#define H5C__UPDATE_RP_FOR_UNPIN(cache_ptr, entry_ptr, fail_val) \ +{ \ + HDassert( (cache_ptr) ); \ + HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ + HDassert( (entry_ptr) ); \ + HDassert( !((entry_ptr)->is_protected) ); \ + HDassert( !((entry_ptr)->is_read_only) ); \ + HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ + HDassert( (entry_ptr)->is_pinned); \ + HDassert( (entry_ptr)->size > 0 ); \ + \ + /* Regardless of the replacement policy, remove the entry from the \ + * pinned entry list. \ + */ \ + H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->pel_head_ptr, \ + (cache_ptr)->pel_tail_ptr, (cache_ptr)->pel_len, \ + (cache_ptr)->pel_size, (fail_val)) \ + \ + /* modified LRU specific code */ \ + \ + /* insert the entry at the head of the LRU list. */ \ + \ + H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ + (cache_ptr)->LRU_tail_ptr, \ + (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + /* End modified LRU specific code. */ \ + \ +} /* H5C__UPDATE_RP_FOR_UNPIN */ #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ + /*------------------------------------------------------------------------- * - * Macro: H5C__UPDATE_RP_FOR_UNPROTECT + * Macro: H5C__UPDATE_RP_FOR_UNPROTECT * * Purpose: Update the replacement policy data structures for an - * unprotect of the specified cache entry. + * unprotect of the specified cache entry. * - * To do this, unlink the specified entry from the protected - * list, and re-insert it in the data structures used by the - * current replacement policy. + * To do this, unlink the specified entry from the protected + * list, and re-insert it in the data structures used by the + * current replacement policy. * - * At present, we only support the modified LRU policy, so - * this function deals with that case unconditionally. If - * we ever support other replacement policies, the function - * should switch on the current policy and act accordingly. + * At present, we only support the modified LRU policy, so + * this function deals with that case unconditionally. If + * we ever support other replacement policies, the function + * should switch on the current policy and act accordingly. * * Return: N/A * @@ -2692,111 +2999,125 @@ * * Modifications: * - * JRM - 7/27/04 - * Converted the function H5C_update_rp_for_unprotect() to - * the macro H5C__UPDATE_RP_FOR_UNPROTECT in an effort to - * squeeze a bit more performance out of the cache. + * JRM - 7/27/04 + * Converted the function H5C_update_rp_for_unprotect() to + * the macro H5C__UPDATE_RP_FOR_UNPROTECT in an effort to + * squeeze a bit more performance out of the cache. * - * At least for the first cut, I am leaving the comments and - * white space in the macro. If they cause difficulties with - * pre-processor, I'll have to remove them. + * At least for the first cut, I am leaving the comments and + * white space in the macro. If they cause difficulties with + * pre-processor, I'll have to remove them. * - * JRM - 7/28/04 - * Split macro into two version, one supporting the clean and - * dirty LRU lists, and the other not. Yet another attempt - * at optimization. + * JRM - 7/28/04 + * Split macro into two version, one supporting the clean and + * dirty LRU lists, and the other not. Yet another attempt + * at optimization. * - * JRM - 3/17/06 - * Modified macro to put pinned entries on the pinned entry - * list instead of inserting them in the data structures - * maintained by the replacement policy. + * JRM - 3/17/06 + * Modified macro to put pinned entries on the pinned entry + * list instead of inserting them in the data structures + * maintained by the replacement policy. * *------------------------------------------------------------------------- */ #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS -#define H5C__UPDATE_RP_FOR_UNPROTECT(cache_ptr, entry_ptr, fail_val) \ - { \ - HDassert((cache_ptr)); \ - HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ - HDassert((entry_ptr)); \ - HDassert((entry_ptr)->is_protected); \ - HDassert((entry_ptr)->size > 0); \ - \ - /* Regardless of the replacement policy, remove the entry from the \ - * protected list. \ - */ \ - H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->pl_head_ptr, (cache_ptr)->pl_tail_ptr, \ - (cache_ptr)->pl_len, (cache_ptr)->pl_size, (fail_val)) \ - \ - if ((entry_ptr)->is_pinned) { \ - \ - H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->pel_head_ptr, (cache_ptr)->pel_tail_ptr, \ - (cache_ptr)->pel_len, (cache_ptr)->pel_size, (fail_val)) \ - } \ - else { \ - \ - /* modified LRU specific code */ \ - \ - /* insert the entry at the head of the LRU list. */ \ - \ - H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - /* Similarly, insert the entry at the head of either the clean or \ - * dirty LRU list as appropriate. \ - */ \ - \ - if ((entry_ptr)->is_dirty) { \ - \ - H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->dLRU_head_ptr, (cache_ptr)->dLRU_tail_ptr, \ - (cache_ptr)->dLRU_list_len, (cache_ptr)->dLRU_list_size, (fail_val)) \ - } \ - else { \ - \ - H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->cLRU_head_ptr, (cache_ptr)->cLRU_tail_ptr, \ - (cache_ptr)->cLRU_list_len, (cache_ptr)->cLRU_list_size, (fail_val)) \ - } \ - \ - /* End modified LRU specific code. */ \ - } \ - \ - } /* H5C__UPDATE_RP_FOR_UNPROTECT */ +#define H5C__UPDATE_RP_FOR_UNPROTECT(cache_ptr, entry_ptr, fail_val) \ +{ \ + HDassert( (cache_ptr) ); \ + HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ + HDassert( (entry_ptr) ); \ + HDassert( (entry_ptr)->is_protected); \ + HDassert( (entry_ptr)->size > 0 ); \ + \ + /* Regardless of the replacement policy, remove the entry from the \ + * protected list. \ + */ \ + H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->pl_head_ptr, \ + (cache_ptr)->pl_tail_ptr, (cache_ptr)->pl_len, \ + (cache_ptr)->pl_size, (fail_val)) \ + \ + if ( (entry_ptr)->is_pinned ) { \ + \ + H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->pel_head_ptr, \ + (cache_ptr)->pel_tail_ptr, \ + (cache_ptr)->pel_len, \ + (cache_ptr)->pel_size, (fail_val)) \ + \ + } else { \ + \ + /* modified LRU specific code */ \ + \ + /* insert the entry at the head of the LRU list. */ \ + \ + H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ + (cache_ptr)->LRU_tail_ptr, \ + (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + /* Similarly, insert the entry at the head of either the clean or \ + * dirty LRU list as appropriate. \ + */ \ + \ + if ( (entry_ptr)->is_dirty ) { \ + \ + H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->dLRU_head_ptr, \ + (cache_ptr)->dLRU_tail_ptr, \ + (cache_ptr)->dLRU_list_len, \ + (cache_ptr)->dLRU_list_size, (fail_val)) \ + \ + } else { \ + \ + H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->cLRU_head_ptr, \ + (cache_ptr)->cLRU_tail_ptr, \ + (cache_ptr)->cLRU_list_len, \ + (cache_ptr)->cLRU_list_size, (fail_val)) \ + } \ + \ + /* End modified LRU specific code. */ \ + } \ + \ +} /* H5C__UPDATE_RP_FOR_UNPROTECT */ #else /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ -#define H5C__UPDATE_RP_FOR_UNPROTECT(cache_ptr, entry_ptr, fail_val) \ - { \ - HDassert((cache_ptr)); \ - HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ - HDassert((entry_ptr)); \ - HDassert((entry_ptr)->is_protected); \ - HDassert((entry_ptr)->size > 0); \ - \ - /* Regardless of the replacement policy, remove the entry from the \ - * protected list. \ - */ \ - H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->pl_head_ptr, (cache_ptr)->pl_tail_ptr, \ - (cache_ptr)->pl_len, (cache_ptr)->pl_size, (fail_val)) \ - \ - if ((entry_ptr)->is_pinned) { \ - \ - H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->pel_head_ptr, (cache_ptr)->pel_tail_ptr, \ - (cache_ptr)->pel_len, (cache_ptr)->pel_size, (fail_val)) \ - } \ - else { \ - \ - /* modified LRU specific code */ \ - \ - /* insert the entry at the head of the LRU list. */ \ - \ - H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - /* End modified LRU specific code. */ \ - } \ - } /* H5C__UPDATE_RP_FOR_UNPROTECT */ +#define H5C__UPDATE_RP_FOR_UNPROTECT(cache_ptr, entry_ptr, fail_val) \ +{ \ + HDassert( (cache_ptr) ); \ + HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ + HDassert( (entry_ptr) ); \ + HDassert( (entry_ptr)->is_protected); \ + HDassert( (entry_ptr)->size > 0 ); \ + \ + /* Regardless of the replacement policy, remove the entry from the \ + * protected list. \ + */ \ + H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->pl_head_ptr, \ + (cache_ptr)->pl_tail_ptr, (cache_ptr)->pl_len, \ + (cache_ptr)->pl_size, (fail_val)) \ + \ + if ( (entry_ptr)->is_pinned ) { \ + \ + H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->pel_head_ptr, \ + (cache_ptr)->pel_tail_ptr, \ + (cache_ptr)->pel_len, \ + (cache_ptr)->pel_size, (fail_val)) \ + \ + } else { \ + \ + /* modified LRU specific code */ \ + \ + /* insert the entry at the head of the LRU list. */ \ + \ + H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ + (cache_ptr)->LRU_tail_ptr, \ + (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + /* End modified LRU specific code. */ \ + } \ +} /* H5C__UPDATE_RP_FOR_UNPROTECT */ #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ @@ -2804,39 +3125,70 @@ #if H5C_DO_SANITY_CHECKS -#define H5C__COLL_DLL_PRE_REMOVE_SC(entry_ptr, hd_ptr, tail_ptr, len, Size, fv) \ - if (((hd_ptr) == NULL) || ((tail_ptr) == NULL) || ((entry_ptr) == NULL) || ((len) <= 0) || \ - ((Size) < (entry_ptr)->size) || (((Size) == (entry_ptr)->size) && (!((len) == 1))) || \ - (((entry_ptr)->coll_prev == NULL) && ((hd_ptr) != (entry_ptr))) || \ - (((entry_ptr)->coll_next == NULL) && ((tail_ptr) != (entry_ptr))) || \ - (((len) == 1) && \ - (!(((hd_ptr) == (entry_ptr)) && ((tail_ptr) == (entry_ptr)) && ((entry_ptr)->coll_next == NULL) && \ - ((entry_ptr)->coll_prev == NULL) && ((Size) == (entry_ptr)->size))))) { \ - HDassert(0 && "coll DLL pre remove SC failed"); \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "coll DLL pre remove SC failed") \ - } - -#define H5C__COLL_DLL_SC(head_ptr, tail_ptr, len, Size, fv) \ - if (((((head_ptr) == NULL) || ((tail_ptr) == NULL)) && ((head_ptr) != (tail_ptr))) || ((len) < 0) || \ - ((Size) < 0) || \ - (((len) == 1) && (((head_ptr) != (tail_ptr)) || ((Size) <= 0) || ((head_ptr) == NULL) || \ - ((head_ptr)->size != (Size)))) || \ - (((len) >= 1) && (((head_ptr) == NULL) || ((head_ptr)->coll_prev != NULL) || ((tail_ptr) == NULL) || \ - ((tail_ptr)->coll_next != NULL)))) { \ - HDassert(0 && "COLL DLL sanity check failed"); \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "COLL DLL sanity check failed") \ - } - -#define H5C__COLL_DLL_PRE_INSERT_SC(entry_ptr, hd_ptr, tail_ptr, len, Size, fv) \ - if (((entry_ptr) == NULL) || ((entry_ptr)->coll_next != NULL) || ((entry_ptr)->coll_prev != NULL) || \ - ((((hd_ptr) == NULL) || ((tail_ptr) == NULL)) && ((hd_ptr) != (tail_ptr))) || \ - (((len) == 1) && \ - (((hd_ptr) != (tail_ptr)) || ((Size) <= 0) || ((hd_ptr) == NULL) || ((hd_ptr)->size != (Size)))) || \ - (((len) >= 1) && (((hd_ptr) == NULL) || ((hd_ptr)->coll_prev != NULL) || ((tail_ptr) == NULL) || \ - ((tail_ptr)->coll_next != NULL)))) { \ - HDassert(0 && "COLL DLL pre insert SC failed"); \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "COLL DLL pre insert SC failed") \ - } +#define H5C__COLL_DLL_PRE_REMOVE_SC(entry_ptr, hd_ptr, tail_ptr, len, Size, fv) \ +if ( ( (hd_ptr) == NULL ) || \ + ( (tail_ptr) == NULL ) || \ + ( (entry_ptr) == NULL ) || \ + ( (len) <= 0 ) || \ + ( (Size) < (entry_ptr)->size ) || \ + ( ( (Size) == (entry_ptr)->size ) && ( ! ( (len) == 1 ) ) ) || \ + ( ( (entry_ptr)->coll_prev == NULL ) && ( (hd_ptr) != (entry_ptr) ) ) || \ + ( ( (entry_ptr)->coll_next == NULL ) && ( (tail_ptr) != (entry_ptr) ) ) || \ + ( ( (len) == 1 ) && \ + ( ! ( ( (hd_ptr) == (entry_ptr) ) && ( (tail_ptr) == (entry_ptr) ) && \ + ( (entry_ptr)->coll_next == NULL ) && \ + ( (entry_ptr)->coll_prev == NULL ) && \ + ( (Size) == (entry_ptr)->size ) \ + ) \ + ) \ + ) \ + ) { \ + HDassert(0 && "coll DLL pre remove SC failed"); \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "coll DLL pre remove SC failed") \ +} + +#define H5C__COLL_DLL_SC(head_ptr, tail_ptr, len, Size, fv) \ +if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ + ( (head_ptr) != (tail_ptr) ) \ + ) || \ + ( (len) < 0 ) || \ + ( (Size) < 0 ) || \ + ( ( (len) == 1 ) && \ + ( ( (head_ptr) != (tail_ptr) ) || ( (Size) <= 0 ) || \ + ( (head_ptr) == NULL ) || ( (head_ptr)->size != (Size) ) \ + ) \ + ) || \ + ( ( (len) >= 1 ) && \ + ( ( (head_ptr) == NULL ) || ( (head_ptr)->coll_prev != NULL ) || \ + ( (tail_ptr) == NULL ) || ( (tail_ptr)->coll_next != NULL ) \ + ) \ + ) \ + ) { \ + HDassert(0 && "COLL DLL sanity check failed"); \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "COLL DLL sanity check failed") \ +} + +#define H5C__COLL_DLL_PRE_INSERT_SC(entry_ptr, hd_ptr, tail_ptr, len, Size, fv) \ +if ( ( (entry_ptr) == NULL ) || \ + ( (entry_ptr)->coll_next != NULL ) || \ + ( (entry_ptr)->coll_prev != NULL ) || \ + ( ( ( (hd_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ + ( (hd_ptr) != (tail_ptr) ) \ + ) || \ + ( ( (len) == 1 ) && \ + ( ( (hd_ptr) != (tail_ptr) ) || ( (Size) <= 0 ) || \ + ( (hd_ptr) == NULL ) || ( (hd_ptr)->size != (Size) ) \ + ) \ + ) || \ + ( ( (len) >= 1 ) && \ + ( ( (hd_ptr) == NULL ) || ( (hd_ptr)->coll_prev != NULL ) || \ + ( (tail_ptr) == NULL ) || ( (tail_ptr)->coll_next != NULL ) \ + ) \ + ) \ + ) { \ + HDassert(0 && "COLL DLL pre insert SC failed"); \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "COLL DLL pre insert SC failed") \ +} #else /* H5C_DO_SANITY_CHECKS */ @@ -2846,67 +3198,77 @@ #endif /* H5C_DO_SANITY_CHECKS */ -#define H5C__COLL_DLL_APPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ - { \ - H5C__COLL_DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ - if ((head_ptr) == NULL) { \ - (head_ptr) = (entry_ptr); \ - (tail_ptr) = (entry_ptr); \ - } \ - else { \ - (tail_ptr)->coll_next = (entry_ptr); \ - (entry_ptr)->coll_prev = (tail_ptr); \ - (tail_ptr) = (entry_ptr); \ - } \ - (len)++; \ - (Size) += entry_ptr->size; \ - } /* H5C__COLL_DLL_APPEND() */ -#define H5C__COLL_DLL_PREPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ - { \ - H5C__COLL_DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ - if ((head_ptr) == NULL) { \ - (head_ptr) = (entry_ptr); \ - (tail_ptr) = (entry_ptr); \ - } \ - else { \ - (head_ptr)->coll_prev = (entry_ptr); \ - (entry_ptr)->coll_next = (head_ptr); \ - (head_ptr) = (entry_ptr); \ - } \ - (len)++; \ - (Size) += entry_ptr->size; \ - } /* H5C__COLL_DLL_PREPEND() */ +#define H5C__COLL_DLL_APPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ +{ \ + H5C__COLL_DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, \ + fail_val) \ + if ( (head_ptr) == NULL ) \ + { \ + (head_ptr) = (entry_ptr); \ + (tail_ptr) = (entry_ptr); \ + } \ + else \ + { \ + (tail_ptr)->coll_next = (entry_ptr); \ + (entry_ptr)->coll_prev = (tail_ptr); \ + (tail_ptr) = (entry_ptr); \ + } \ + (len)++; \ + (Size) += entry_ptr->size; \ +} /* H5C__COLL_DLL_APPEND() */ + +#define H5C__COLL_DLL_PREPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ +{ \ + H5C__COLL_DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fv)\ + if ( (head_ptr) == NULL ) \ + { \ + (head_ptr) = (entry_ptr); \ + (tail_ptr) = (entry_ptr); \ + } \ + else \ + { \ + (head_ptr)->coll_prev = (entry_ptr); \ + (entry_ptr)->coll_next = (head_ptr); \ + (head_ptr) = (entry_ptr); \ + } \ + (len)++; \ + (Size) += entry_ptr->size; \ +} /* H5C__COLL_DLL_PREPEND() */ + +#define H5C__COLL_DLL_REMOVE(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ +{ \ + H5C__COLL_DLL_PRE_REMOVE_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fv)\ + { \ + if ( (head_ptr) == (entry_ptr) ) \ + { \ + (head_ptr) = (entry_ptr)->coll_next; \ + if ( (head_ptr) != NULL ) \ + (head_ptr)->coll_prev = NULL; \ + } \ + else \ + { \ + (entry_ptr)->coll_prev->coll_next = (entry_ptr)->coll_next; \ + } \ + if ( (tail_ptr) == (entry_ptr) ) \ + { \ + (tail_ptr) = (entry_ptr)->coll_prev; \ + if ( (tail_ptr) != NULL ) \ + (tail_ptr)->coll_next = NULL; \ + } \ + else \ + (entry_ptr)->coll_next->coll_prev = (entry_ptr)->coll_prev; \ + entry_ptr->coll_next = NULL; \ + entry_ptr->coll_prev = NULL; \ + (len)--; \ + (Size) -= entry_ptr->size; \ + } \ +} /* H5C__COLL_DLL_REMOVE() */ -#define H5C__COLL_DLL_REMOVE(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ - { \ - H5C__COLL_DLL_PRE_REMOVE_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ - { \ - if ((head_ptr) == (entry_ptr)) { \ - (head_ptr) = (entry_ptr)->coll_next; \ - if ((head_ptr) != NULL) \ - (head_ptr)->coll_prev = NULL; \ - } \ - else { \ - (entry_ptr)->coll_prev->coll_next = (entry_ptr)->coll_next; \ - } \ - if ((tail_ptr) == (entry_ptr)) { \ - (tail_ptr) = (entry_ptr)->coll_prev; \ - if ((tail_ptr) != NULL) \ - (tail_ptr)->coll_next = NULL; \ - } \ - else \ - (entry_ptr)->coll_next->coll_prev = (entry_ptr)->coll_prev; \ - entry_ptr->coll_next = NULL; \ - entry_ptr->coll_prev = NULL; \ - (len)--; \ - (Size) -= entry_ptr->size; \ - } \ - } /* H5C__COLL_DLL_REMOVE() */ /*------------------------------------------------------------------------- * - * Macro: H5C__INSERT_IN_COLL_LIST + * Macro: H5C__INSERT_IN_COLL_LIST * * Purpose: Insert entry into collective entries list * @@ -2917,22 +3279,26 @@ *------------------------------------------------------------------------- */ -#define H5C__INSERT_IN_COLL_LIST(cache_ptr, entry_ptr, fail_val) \ - { \ - HDassert((cache_ptr)); \ - HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ - HDassert((entry_ptr)); \ - \ - /* insert the entry at the head of the list. */ \ - \ - H5C__COLL_DLL_PREPEND((entry_ptr), (cache_ptr)->coll_head_ptr, (cache_ptr)->coll_tail_ptr, \ - (cache_ptr)->coll_list_len, (cache_ptr)->coll_list_size, (fail_val)) \ - \ - } /* H5C__INSERT_IN_COLL_LIST */ +#define H5C__INSERT_IN_COLL_LIST(cache_ptr, entry_ptr, fail_val) \ +{ \ + HDassert( (cache_ptr) ); \ + HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ + HDassert( (entry_ptr) ); \ + \ + /* insert the entry at the head of the list. */ \ + \ + H5C__COLL_DLL_PREPEND((entry_ptr), (cache_ptr)->coll_head_ptr, \ + (cache_ptr)->coll_tail_ptr, \ + (cache_ptr)->coll_list_len, \ + (cache_ptr)->coll_list_size, \ + (fail_val)) \ + \ +} /* H5C__INSERT_IN_COLL_LIST */ + /*------------------------------------------------------------------------- * - * Macro: H5C__REMOVE_FROM_COLL_LIST + * Macro: H5C__REMOVE_FROM_COLL_LIST * * Purpose: Remove entry from collective entries list * @@ -2943,22 +3309,26 @@ *------------------------------------------------------------------------- */ -#define H5C__REMOVE_FROM_COLL_LIST(cache_ptr, entry_ptr, fail_val) \ - { \ - HDassert((cache_ptr)); \ - HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ - HDassert((entry_ptr)); \ - \ - /* remove the entry from the list. */ \ - \ - H5C__COLL_DLL_REMOVE((entry_ptr), (cache_ptr)->coll_head_ptr, (cache_ptr)->coll_tail_ptr, \ - (cache_ptr)->coll_list_len, (cache_ptr)->coll_list_size, (fail_val)) \ - \ - } /* H5C__REMOVE_FROM_COLL_LIST */ +#define H5C__REMOVE_FROM_COLL_LIST(cache_ptr, entry_ptr, fail_val) \ +{ \ + HDassert( (cache_ptr) ); \ + HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ + HDassert( (entry_ptr) ); \ + \ + /* remove the entry from the list. */ \ + \ + H5C__COLL_DLL_REMOVE((entry_ptr), (cache_ptr)->coll_head_ptr, \ + (cache_ptr)->coll_tail_ptr, \ + (cache_ptr)->coll_list_len, \ + (cache_ptr)->coll_list_size, \ + (fail_val)) \ + \ +} /* H5C__REMOVE_FROM_COLL_LIST */ + /*------------------------------------------------------------------------- * - * Macro: H5C__MOVE_TO_TOP_IN_COLL_LIST + * Macro: H5C__MOVE_TO_TOP_IN_COLL_LIST * * Purpose: Update entry position in collective entries list * @@ -2969,20 +3339,26 @@ *------------------------------------------------------------------------- */ -#define H5C__MOVE_TO_TOP_IN_COLL_LIST(cache_ptr, entry_ptr, fail_val) \ - { \ - HDassert((cache_ptr)); \ - HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ - HDassert((entry_ptr)); \ - \ - /* Remove entry and insert at the head of the list. */ \ - H5C__COLL_DLL_REMOVE((entry_ptr), (cache_ptr)->coll_head_ptr, (cache_ptr)->coll_tail_ptr, \ - (cache_ptr)->coll_list_len, (cache_ptr)->coll_list_size, (fail_val)) \ - \ - H5C__COLL_DLL_PREPEND((entry_ptr), (cache_ptr)->coll_head_ptr, (cache_ptr)->coll_tail_ptr, \ - (cache_ptr)->coll_list_len, (cache_ptr)->coll_list_size, (fail_val)) \ - \ - } /* H5C__MOVE_TO_TOP_IN_COLL_LIST */ +#define H5C__MOVE_TO_TOP_IN_COLL_LIST(cache_ptr, entry_ptr, fail_val) \ +{ \ + HDassert( (cache_ptr) ); \ + HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ + HDassert( (entry_ptr) ); \ + \ + /* Remove entry and insert at the head of the list. */ \ + H5C__COLL_DLL_REMOVE((entry_ptr), (cache_ptr)->coll_head_ptr, \ + (cache_ptr)->coll_tail_ptr, \ + (cache_ptr)->coll_list_len, \ + (cache_ptr)->coll_list_size, \ + (fail_val)) \ + \ + H5C__COLL_DLL_PREPEND((entry_ptr), (cache_ptr)->coll_head_ptr, \ + (cache_ptr)->coll_tail_ptr, \ + (cache_ptr)->coll_list_len, \ + (cache_ptr)->coll_list_size, \ + (fail_val)) \ + \ +} /* H5C__MOVE_TO_TOP_IN_COLL_LIST */ #endif /* H5_HAVE_PARALLEL */ /***************************************/ @@ -3098,7 +3474,7 @@ * * The fields of this structure are discussed individually below: * - * tag: Address (i.e. "tag") of the object header for all the entries + * tag: Address (i.e. "tag") of the object header for all the entries * corresponding to parts of that object. * * head: Head of doubly-linked list of all entries belonging to the tag. @@ -3106,16 +3482,17 @@ * entry_cnt: Number of entries on linked list of entries for this tag. * * corked: Boolean flag indicating whether entries for this object can be - * evicted. + * evicted. * ****************************************************************************/ typedef struct H5C_tag_info_t { - haddr_t tag; /* Tag (address) of the entries (must be first, for skiplist) */ - H5C_cache_entry_t *head; /* Head of the list of entries for this tag */ - size_t entry_cnt; /* Number of entries on list */ - hbool_t corked; /* Whether this object is corked */ + haddr_t tag; /* Tag (address) of the entries (must be first, for skiplist) */ + H5C_cache_entry_t *head; /* Head of the list of entries for this tag */ + size_t entry_cnt; /* Number of entries on list */ + hbool_t corked; /* Whether this object is corked */ } H5C_tag_info_t; + /**************************************************************************** * * structure H5C_t @@ -3147,32 +3524,32 @@ typedef struct H5C_tag_info_t { * Note that index_size and index_len now refer to the total size of * and number of entries in the hash table. * - * JRM - 7/19/04 + * JRM - 7/19/04 * * The TBBT has since been replaced with a skip list. This change * greatly predates this note. * - * JRM - 9/26/05 + * JRM - 9/26/05 * - * magic: Unsigned 32 bit integer always set to H5C__H5C_T_MAGIC. - * This field is used to validate pointers to instances of - * H5C_t. + * magic: Unsigned 32 bit integer always set to H5C__H5C_T_MAGIC. + * This field is used to validate pointers to instances of + * H5C_t. * * flush_in_progress: Boolean flag indicating whether a flush is in - * progress. + * progress. * * log_info: Information used by the MDC logging functionality. * Described in H5Clog.h. * - * aux_ptr: Pointer to void used to allow wrapper code to associate - * its data with an instance of H5C_t. The H5C cache code - * sets this field to NULL, and otherwise leaves it alone. + * aux_ptr: Pointer to void used to allow wrapper code to associate + * its data with an instance of H5C_t. The H5C cache code + * sets this field to NULL, and otherwise leaves it alone. * - * max_type_id: Integer field containing the maximum type id number assigned - * to a type of entry in the cache. All type ids from 0 to - * max_type_id inclusive must be defined. The names of the - * types are stored in the type_name_table discussed below, and - * indexed by the ids. + * max_type_id: Integer field containing the maximum type id number assigned + * to a type of entry in the cache. All type ids from 0 to + * max_type_id inclusive must be defined. The names of the + * types are stored in the type_name_table discussed below, and + * indexed by the ids. * * class_table_ptr: Pointer to an array of H5C_class_t of length * max_type_id + 1. Entry classes for the cache. @@ -3188,19 +3565,19 @@ typedef struct H5C_tag_info_t { * to reduce its size as entries are unprotected. * * b) When running in parallel mode, the cache may not be - * permitted to flush a dirty entry in response to a read. - * If there are no clean entries available to evict, the - * cache will exceed its maximum size. Again the cache + * permitted to flush a dirty entry in response to a read. + * If there are no clean entries available to evict, the + * cache will exceed its maximum size. Again the cache * will attempt to reduce its size to the max_cache_size * limit on the next cache write. * - * c) When an entry increases in size, the cache may exceed - * the max_cache_size limit until the next time the cache - * attempts to load or insert an entry. + * c) When an entry increases in size, the cache may exceed + * the max_cache_size limit until the next time the cache + * attempts to load or insert an entry. * - * d) When the evictions_enabled field is false (see below), - * the cache size will increase without limit until the - * field is set to true. + * d) When the evictions_enabled field is false (see below), + * the cache size will increase without limit until the + * field is set to true. * * min_clean_size: Nominal minimum number of clean bytes in the cache. * The cache attempts to maintain this number of bytes of @@ -3208,7 +3585,7 @@ typedef struct H5C_tag_info_t { * a soft limit. * * close_warning_received: Boolean flag indicating that a file closing - * warning has been received. + * warning has been received. * * * In addition to the call back functions required for each entry, the @@ -3216,19 +3593,19 @@ typedef struct H5C_tag_info_t { * the cache as a whole: * * check_write_permitted: In certain applications, the cache may not - * be allowed to write to disk at certain time. If specified, - * the check_write_permitted function is used to determine if - * a write is permissible at any given point in time. + * be allowed to write to disk at certain time. If specified, + * the check_write_permitted function is used to determine if + * a write is permissible at any given point in time. * - * If no such function is specified (i.e. this field is NULL), - * the cache uses the following write_permitted field to - * determine whether writes are permitted. + * If no such function is specified (i.e. this field is NULL), + * the cache uses the following write_permitted field to + * determine whether writes are permitted. * * write_permitted: If check_write_permitted is NULL, this boolean flag - * indicates whether writes are permitted. + * indicates whether writes are permitted. * - * log_flush: If provided, this function is called whenever a dirty - * entry is flushed to disk. + * log_flush: If provided, this function is called whenever a dirty + * entry is flushed to disk. * * * In cases where memory is plentiful, and performance is an issue, it may @@ -3236,11 +3613,11 @@ typedef struct H5C_tag_info_t { * writes. The following field is used to implement this. * * evictions_enabled: Boolean flag that is initialized to TRUE. When - * this flag is set to FALSE, the metadata cache will not - * attempt to evict entries to make space for newly protected - * entries, and instead the will grow without limit. + * this flag is set to FALSE, the metadata cache will not + * attempt to evict entries to make space for newly protected + * entries, and instead the will grow without limit. * - * Needless to say, this feature must be used with care. + * Needless to say, this feature must be used with care. * * * The cache requires an index to facilitate searching for entries. The @@ -3258,7 +3635,7 @@ typedef struct H5C_tag_info_t { * index, and must have the same length and size as the index proper. * * index_len: Number of entries currently in the hash table used to index - * the cache. + * the cache. * * index_size: Number of bytes of cache entries currently stored in the * hash table used to index the cache. @@ -3270,84 +3647,84 @@ typedef struct H5C_tag_info_t { * of the cache's memory footprint. * * index_ring_len: Array of integer of length H5C_RING_NTYPES used to - * maintain a count of entries in the index by ring. Note - * that the sum of all the cells in this array must equal - * the value stored in index_len above. + * maintain a count of entries in the index by ring. Note + * that the sum of all the cells in this array must equal + * the value stored in index_len above. * * index_ring_size: Array of size_t of length H5C_RING_NTYPES used to - * maintain the sum of the sizes of all entries in the index - * by ring. Note that the sum of all cells in this array must - * equal the value stored in index_size above. + * maintain the sum of the sizes of all entries in the index + * by ring. Note that the sum of all cells in this array must + * equal the value stored in index_size above. * * clean_index_size: Number of bytes of clean entries currently stored in - * the hash table. Note that the index_size field (above) - * is also the sum of the sizes of all entries in the cache. - * Thus we should have the invariant that clean_index_size + - * dirty_index_size == index_size. + * the hash table. Note that the index_size field (above) + * is also the sum of the sizes of all entries in the cache. + * Thus we should have the invariant that clean_index_size + + * dirty_index_size == index_size. * - * WARNING: + * WARNING: * - * The value of the clean_index_size must not be mistaken - * for the current clean size of the cache. Rather, the - * clean size of the cache is the current value of - * clean_index_size plus the amount of empty space (if any) + * The value of the clean_index_size must not be mistaken + * for the current clean size of the cache. Rather, the + * clean size of the cache is the current value of + * clean_index_size plus the amount of empty space (if any) * in the cache. * * clean_index_ring_size: Array of size_t of length H5C_RING_NTYPES used to - * maintain the sum of the sizes of all clean entries in the - * index by ring. Note that the sum of all cells in this array - * must equal the value stored in clean_index_size above. + * maintain the sum of the sizes of all clean entries in the + * index by ring. Note that the sum of all cells in this array + * must equal the value stored in clean_index_size above. * * dirty_index_size: Number of bytes of dirty entries currently stored in - * the hash table. Note that the index_size field (above) - * is also the sum of the sizes of all entries in the cache. - * Thus we should have the invariant that clean_index_size + - * dirty_index_size == index_size. + * the hash table. Note that the index_size field (above) + * is also the sum of the sizes of all entries in the cache. + * Thus we should have the invariant that clean_index_size + + * dirty_index_size == index_size. * * dirty_index_ring_size: Array of size_t of length H5C_RING_NTYPES used to - * maintain the sum of the sizes of all dirty entries in the - * index by ring. Note that the sum of all cells in this array - * must equal the value stored in dirty_index_size above. - * - * index: Array of pointer to H5C_cache_entry_t of size - * H5C__HASH_TABLE_LEN. At present, this value is a power - * of two, not the usual prime number. - * - * I hope that the variable size of cache elements, the large - * hash table size, and the way in which HDF5 allocates space - * will combine to avoid problems with periodicity. If so, we - * can use a trivial hash function (a bit-and and a 3 bit left - * shift) with some small savings. - * - * If not, it will become evident in the statistics. Changing - * to the usual prime number length hash table will require - * changing the H5C__HASH_FCN macro and the deletion of the - * H5C__HASH_MASK #define. No other changes should be required. - * - * il_len: Number of entries on the index list. - * - * This must always be equal to index_len. As such, this - * field is redundant. However, the existing linked list - * management macros expect to maintain a length field, so - * this field exists primarily to avoid adding complexity to - * these macros. - * - * il_size: Number of bytes of cache entries currently stored in the - * index list. - * - * This must always be equal to index_size. As such, this - * field is redundant. However, the existing linked list - * management macros expect to maintain a size field, so - * this field exists primarily to avoid adding complexity to - * these macros. - * - * il_head: Pointer to the head of the doubly linked list of entries in + * maintain the sum of the sizes of all dirty entries in the + * index by ring. Note that the sum of all cells in this array + * must equal the value stored in dirty_index_size above. + * + * index: Array of pointer to H5C_cache_entry_t of size + * H5C__HASH_TABLE_LEN. At present, this value is a power + * of two, not the usual prime number. + * + * I hope that the variable size of cache elements, the large + * hash table size, and the way in which HDF5 allocates space + * will combine to avoid problems with periodicity. If so, we + * can use a trivial hash function (a bit-and and a 3 bit left + * shift) with some small savings. + * + * If not, it will become evident in the statistics. Changing + * to the usual prime number length hash table will require + * changing the H5C__HASH_FCN macro and the deletion of the + * H5C__HASH_MASK #define. No other changes should be required. + * + * il_len: Number of entries on the index list. + * + * This must always be equal to index_len. As such, this + * field is redundant. However, the existing linked list + * management macros expect to maintain a length field, so + * this field exists primarily to avoid adding complexity to + * these macros. + * + * il_size: Number of bytes of cache entries currently stored in the + * index list. + * + * This must always be equal to index_size. As such, this + * field is redundant. However, the existing linked list + * management macros expect to maintain a size field, so + * this field exists primarily to avoid adding complexity to + * these macros. + * + * il_head: Pointer to the head of the doubly linked list of entries in * the index list. Note that cache entries on this list are - * linked by their il_next and il_prev fields. + * linked by their il_next and il_prev fields. * * This field is NULL if the index is empty. * - * il_tail: Pointer to the tail of the doubly linked list of entries in + * il_tail: Pointer to the tail of the doubly linked list of entries in * the index list. Note that cache entries on this list are * linked by their il_next and il_prev fields. * @@ -3394,32 +3771,33 @@ typedef struct H5C_tag_info_t { * * The following fields are maintained to facilitate this. * - * entries_removed_counter: Counter that is incremented each time an - * entry is removed from the cache by any means (eviction, - * expungement, or take ownership at this point in time). - * Functions that perform scans on lists may set this field - * to zero prior to calling H5C__flush_single_entry(). - * Unexpected changes to the counter indicate that an entry - * was removed from the cache as a side effect of the flush. - * - * last_entry_removed_ptr: Pointer to the instance of H5C_cache_entry_t - * which contained the last entry to be removed from the cache, - * or NULL if there either is no such entry, or if a function - * performing a scan of a list has set this field to NULL prior - * to calling H5C__flush_single_entry(). - * - * WARNING!!! This field must NEVER be dereferenced. It is - * maintained to allow functions that perform scans of lists - * to compare this pointer with their pointers to next, thus - * allowing them to avoid unnecessary restarts of scans if the - * pointers don't match, and if entries_removed_counter is - * one. - * - * entry_watched_for_removal: Pointer to an instance of H5C_cache_entry_t - * which contains the 'next' entry for an iteration. Removing + * entries_removed_counter: Counter that is incremented each time an + * entry is removed from the cache by any means (eviction, + * expungement, or take ownership at this point in time). + * Functions that perform scans on lists may set this field + * to zero prior to calling H5C__flush_single_entry(). + * Unexpected changes to the counter indicate that an entry + * was removed from the cache as a side effect of the flush. + * + * last_entry_removed_ptr: Pointer to the instance of H5C_cache_entry_t + * which contained the last entry to be removed from the cache, + * or NULL if there either is no such entry, or if a function + * performing a scan of a list has set this field to NULL prior + * to calling H5C__flush_single_entry(). + * + * WARNING!!! This field must NEVER be dereferenced. It is + * maintained to allow functions that perform scans of lists + * to compare this pointer with their pointers to next, thus + * allowing them to avoid unnecessary restarts of scans if the + * pointers don't match, and if entries_removed_counter is + * one. + * + * entry_watched_for_removal: Pointer to an instance of H5C_cache_entry_t + * which contains the 'next' entry for an iteration. Removing * this entry must trigger a rescan of the iteration, so each * entry removed from the cache is compared against this pointer - * and the pointer is reset to NULL if the watched entry is removed. + * and the pointer is reset to NULL if the watched entry is + * removed. * (This functions similarly to a "dead man's switch") * * @@ -3434,11 +3812,11 @@ typedef struct H5C_tag_info_t { * the skip list as they are flushed. JRM - 10/25/05) * * slist_changed: Boolean flag used to indicate whether the contents of - * the slist has changed since the last time this flag was - * reset. This is used in the cache flush code to detect - * conditions in which pre-serialize or serialize callbacks - * have modified the slist -- which obliges us to restart - * the scan of the slist from the beginning. + * the slist has changed since the last time this flag was + * reset. This is used in the cache flush code to detect + * conditions in which pre-serialize or serialize callbacks + * have modified the slist -- which obliges us to restart + * the scan of the slist from the beginning. * * slist_len: Number of entries currently in the skip list * used to maintain a sorted list of dirty entries in the @@ -3449,14 +3827,14 @@ typedef struct H5C_tag_info_t { * dirty entries in the cache. * * slist_ring_len: Array of integer of length H5C_RING_NTYPES used to - * maintain a count of entries in the slist by ring. Note - * that the sum of all the cells in this array must equal - * the value stored in slist_len above. + * maintain a count of entries in the slist by ring. Note + * that the sum of all the cells in this array must equal + * the value stored in slist_len above. * * slist_ring_size: Array of size_t of length H5C_RING_NTYPES used to * maintain the sum of the sizes of all entries in the - * slist by ring. Note that the sum of all cells in this - * array must equal the value stored in slist_size above. + * slist by ring. Note that the sum of all cells in this + * array must equal the value stored in slist_size above. * * slist_ptr: pointer to the instance of H5SL_t used maintain a sorted * list of dirty entries in the cache. This sorted list has @@ -3471,7 +3849,7 @@ typedef struct H5C_tag_info_t { * some optimizations when I get to it. * * num_last_entries: The number of entries in the cache that can only be - * flushed after all other entries in the cache have + * flushed after all other entries in the cache have * been flushed. At this time, this will only ever be * one entry (the superblock), and the code has been * protected with HDasserts to enforce this. This restraint @@ -3480,10 +3858,10 @@ typedef struct H5C_tag_info_t { * explicit tests for that case should be added when said * HDasserts are removed. * - * Update: There are now two possible last entries - * (superblock and file driver info message). This - * number will probably increase as we add superblock - * messages. JRM -- 11/18/14 + * Update: There are now two possible last entries + * (superblock and file driver info message). This + * number will probably increase as we add superblock + * messages. JRM -- 11/18/14 * * With the addition of the fractal heap, the cache must now deal with * the case in which entries may be dirtied, moved, or have their sizes @@ -3492,12 +3870,12 @@ typedef struct H5C_tag_info_t { * H5C_DO_SANITY_CHECKS is TRUE. * * slist_len_increase: Number of entries that have been added to the - * slist since the last time this field was set to zero. - * Note that this value can be negative. + * slist since the last time this field was set to zero. + * Note that this value can be negative. * * slist_size_increase: Total size of all entries that have been added - * to the slist since the last time this field was set to - * zero. Note that this value can be negative. + * to the slist since the last time this field was set to + * zero. Note that this value can be negative. * * Cache entries belonging to a particular object are "tagged" with that * object's base object header address. @@ -3514,7 +3892,7 @@ typedef struct H5C_tag_info_t { * freelist, as well as shared entries like global * heaps and shared object header messages, are not tagged. * - * ignore_tags: Boolean flag to disable tag validation during entry insertion. + * ignore_tags: Boolean flag to disable tag validation during entry insertion. * * num_objs_corked: Unsigned integer field containing the number of objects * that are "corked". The "corked" status of an object is @@ -3553,15 +3931,15 @@ typedef struct H5C_tag_info_t { * * Pinning an entry has the following implications: * - * 1) A pinned entry cannot be evicted. Thus unprotected + * 1) A pinned entry cannot be evicted. Thus unprotected * pinned entries reside in the pinned entry list, instead * of the LRU list(s) (or other lists maintained by the current * replacement policy code). * * 2) A pinned entry can be accessed or modified at any time. * This places an additional burden on the associated pre-serialize - * and serialize callbacks, which must ensure the the entry is in - * a consistent state before creating an image of it. + * and serialize callbacks, which must ensure the the entry is in + * a consistent state before creating an image of it. * * 3) A pinned entry can be marked as dirty (and possibly * change size) while it is unprotected. @@ -3576,21 +3954,21 @@ typedef struct H5C_tag_info_t { * * Maintaining the pinned entry list requires the following fields: * - * pel_len: Number of entries currently residing on the pinned - * entry list. + * pel_len: Number of entries currently residing on the pinned + * entry list. * - * pel_size: Number of bytes of cache entries currently residing on - * the pinned entry list. + * pel_size: Number of bytes of cache entries currently residing on + * the pinned entry list. * * pel_head_ptr: Pointer to the head of the doubly linked list of pinned - * but not protected entries. Note that cache entries on - * this list are linked by their next and prev fields. + * but not protected entries. Note that cache entries on + * this list are linked by their next and prev fields. * * This field is NULL if the list is empty. * * pel_tail_ptr: Pointer to the tail of the doubly linked list of pinned - * but not protected entries. Note that cache entries on - * this list are linked by their next and prev fields. + * but not protected entries. Note that cache entries on + * this list are linked by their next and prev fields. * * This field is NULL if the list is empty. * @@ -3648,13 +4026,13 @@ typedef struct H5C_tag_info_t { * LRU_list_len: Number of cache entries currently on the LRU list. * * Observe that LRU_list_len + pl_len + pel_len must always - * equal index_len. + * equal index_len. * * LRU_list_size: Number of bytes of cache entries currently residing on the * LRU list. * * Observe that LRU_list_size + pl_size + pel_size must always - * equal index_size. + * equal index_size. * * LRU_head_ptr: Pointer to the head of the doubly linked LRU list. Cache * entries on this list are linked by their next and prev fields. @@ -3723,10 +4101,10 @@ typedef struct H5C_tag_info_t { * the structure described below: * * size_increase_possible: Depending on the configuration data given - * in the resize_ctl field, it may or may not be possible - * to increase the size of the cache. Rather than test for - * all the ways this can happen, we simply set this flag when - * we receive a new configuration. + * in the resize_ctl field, it may or may not be possible + * to increase the size of the cache. Rather than test for + * all the ways this can happen, we simply set this flag when + * we receive a new configuration. * * flash_size_increase_possible: Depending on the configuration data given * in the resize_ctl field, it may or may not be possible @@ -3747,37 +4125,37 @@ typedef struct H5C_tag_info_t { * we receive a new configuration. * * resize_enabled: This is another convenience flag which is set whenever - * a new set of values for resize_ctl are provided. Very - * simply, + * a new set of values for resize_ctl are provided. Very + * simply, * - * resize_enabled = size_increase_possible || + * resize_enabled = size_increase_possible || * size_decrease_possible; * - * cache_full: Boolean flag used to keep track of whether the cache is - * full, so we can refrain from increasing the size of a - * cache which hasn't used up the space allotted to it. + * cache_full: Boolean flag used to keep track of whether the cache is + * full, so we can refrain from increasing the size of a + * cache which hasn't used up the space allotted to it. * - * The field is initialized to FALSE, and then set to TRUE - * whenever we attempt to make space in the cache. + * The field is initialized to FALSE, and then set to TRUE + * whenever we attempt to make space in the cache. * * size_decreased: Boolean flag set to TRUE whenever the maximum cache - * size is decreased. The flag triggers a call to - * H5C__make_space_in_cache() on the next call to H5C_protect(). + * size is decreased. The flag triggers a call to + * H5C__make_space_in_cache() on the next call to H5C_protect(). * * resize_in_progress: As the metadata cache has become re-entrant, it is - * possible that a protect may trigger a call to - * H5C__auto_adjust_cache_size(), which may trigger a flush, - * which may trigger a protect, which will result in another - * call to H5C__auto_adjust_cache_size(). + * possible that a protect may trigger a call to + * H5C__auto_adjust_cache_size(), which may trigger a flush, + * which may trigger a protect, which will result in another + * call to H5C__auto_adjust_cache_size(). * - * The resize_in_progress boolean flag is used to detect this, - * and to prevent the infinite recursion that would otherwise - * occur. + * The resize_in_progress boolean flag is used to detect this, + * and to prevent the infinite recursion that would otherwise + * occur. * - * Note that this issue is not hypothetical -- this field - * was added 12/29/15 to fix a bug exposed in the testing - * of changes to the file driver info superblock extension - * management code needed to support rings. + * Note that this issue is not hypothetical -- this field + * was added 12/29/15 to fix a bug exposed in the testing + * of changes to the file driver info superblock extension + * management code needed to support rings. * * msic_in_progress: As the metadata cache has become re-entrant, and as * the free space manager code has become more tightly @@ -3796,62 +4174,62 @@ typedef struct H5C_tag_info_t { * exposed by modifications to test/fheap.c to cause it to * use paged allocation. * - * resize_ctl: Instance of H5C_auto_size_ctl_t containing configuration - * data for automatic cache resizing. + * resize_ctl: Instance of H5C_auto_size_ctl_t containing configuration + * data for automatic cache resizing. * * epoch_markers_active: Integer field containing the number of epoch - * markers currently in use in the LRU list. This value - * must be in the range [0, H5C__MAX_EPOCH_MARKERS - 1]. + * markers currently in use in the LRU list. This value + * must be in the range [0, H5C__MAX_EPOCH_MARKERS - 1]. * * epoch_marker_active: Array of boolean of length H5C__MAX_EPOCH_MARKERS. - * This array is used to track which epoch markers are currently - * in use. + * This array is used to track which epoch markers are currently + * in use. * * epoch_marker_ringbuf: Array of int of length H5C__MAX_EPOCH_MARKERS + 1. * - * To manage the epoch marker cache entries, it is necessary - * to track their order in the LRU list. This is done with - * epoch_marker_ringbuf. When markers are inserted at the - * head of the LRU list, the index of the marker in the - * epoch_markers array is inserted at the tail of the ring - * buffer. When it becomes the epoch_marker_active'th marker - * in the LRU list, it will have worked its way to the head - * of the ring buffer as well. This allows us to remove it - * without scanning the LRU list if such is required. + * To manage the epoch marker cache entries, it is necessary + * to track their order in the LRU list. This is done with + * epoch_marker_ringbuf. When markers are inserted at the + * head of the LRU list, the index of the marker in the + * epoch_markers array is inserted at the tail of the ring + * buffer. When it becomes the epoch_marker_active'th marker + * in the LRU list, it will have worked its way to the head + * of the ring buffer as well. This allows us to remove it + * without scanning the LRU list if such is required. * * epoch_marker_ringbuf_first: Integer field containing the index of the - * first entry in the ring buffer. + * first entry in the ring buffer. * * epoch_marker_ringbuf_last: Integer field containing the index of the - * last entry in the ring buffer. + * last entry in the ring buffer. * * epoch_marker_ringbuf_size: Integer field containing the number of entries - * in the ring buffer. + * in the ring buffer. * * epoch_markers: Array of instances of H5C_cache_entry_t of length - * H5C__MAX_EPOCH_MARKERS. The entries are used as markers - * in the LRU list to identify cache entries that haven't - * been accessed for some (small) specified number of - * epochs. These entries (if any) can then be evicted and - * the cache size reduced -- ideally without evicting any - * of the current working set. Needless to say, the epoch - * length and the number of epochs before an unused entry - * must be chosen so that all, or almost all, the working - * set will be accessed before the limit. - * - * Epoch markers only appear in the LRU list, never in - * the index or slist. While they are of type - * H5C__EPOCH_MARKER_TYPE, and have associated class - * functions, these functions should never be called. - * - * The addr fields of these instances of H5C_cache_entry_t - * are set to the index of the instance in the epoch_markers - * array, the size is set to 0, and the type field points - * to the constant structure epoch_marker_class defined - * in H5C.c. The next and prev fields are used as usual - * to link the entry into the LRU list. - * - * All other fields are unused. + * H5C__MAX_EPOCH_MARKERS. The entries are used as markers + * in the LRU list to identify cache entries that haven't + * been accessed for some (small) specified number of + * epochs. These entries (if any) can then be evicted and + * the cache size reduced -- ideally without evicting any + * of the current working set. Needless to say, the epoch + * length and the number of epochs before an unused entry + * must be chosen so that all, or almost all, the working + * set will be accessed before the limit. + * + * Epoch markers only appear in the LRU list, never in + * the index or slist. While they are of type + * H5C__EPOCH_MARKER_TYPE, and have associated class + * functions, these functions should never be called. + * + * The addr fields of these instances of H5C_cache_entry_t + * are set to the index of the instance in the epoch_markers + * array, the size is set to 0, and the type field points + * to the constant structure epoch_marker_class defined + * in H5C.c. The next and prev fields are used as usual + * to link the entry into the LRU list. + * + * All other fields are unused. * * * Cache hit rate collection fields: @@ -3861,62 +4239,62 @@ typedef struct H5C_tag_info_t { * collection is enabled. The following fields support this capability. * * cache_hits: Number of cache hits since the last time the cache hit - * rate statistics were reset. Note that when automatic cache - * re-sizing is enabled, this field will be reset every automatic - * resize epoch. + * rate statistics were reset. Note that when automatic cache + * re-sizing is enabled, this field will be reset every automatic + * resize epoch. * * cache_accesses: Number of times the cache has been accessed while - * since the last since the last time the cache hit rate statistics - * were reset. Note that when automatic cache re-sizing is enabled, - * this field will be reset every automatic resize epoch. + * since the last since the last time the cache hit rate statistics + * were reset. Note that when automatic cache re-sizing is enabled, + * this field will be reset every automatic resize epoch. * * * Metadata cache image management related fields. * - * image_ctl: Instance of H5C_cache_image_ctl_t containing configuration - * data for generation of a cache image on file close. + * image_ctl: Instance of H5C_cache_image_ctl_t containing configuration + * data for generation of a cache image on file close. * * serialization_in_progress: Boolean field that is set to TRUE iff - * the cache is in the process of being serialized. This - * field is needed to support the H5C_serialization_in_progress() - * call, which is in turn required for sanity checks in some - * cache clients. + * the cache is in the process of being serialized. This + * field is needed to support the H5C_serialization_in_progress() + * call, which is in turn required for sanity checks in some + * cache clients. * - * load_image: Boolean flag indicating that the metadata cache image - * superblock extension message exists and should be - * read, and the image block read and decoded on the next - * call to H5C_protect(). + * load_image: Boolean flag indicating that the metadata cache image + * superblock extension message exists and should be + * read, and the image block read and decoded on the next + * call to H5C_protect(). * * image_loaded: Boolean flag indicating that the metadata cache has * loaded the metadata cache image as directed by the * MDC cache image superblock extension message. * * delete_image: Boolean flag indicating whether the metadata cache image - * superblock message should be deleted and the cache image - * file space freed after they have been read and decoded. + * superblock message should be deleted and the cache image + * file space freed after they have been read and decoded. * - * This flag should be set to TRUE iff the file is opened - * R/W and there is a cache image to be read. + * This flag should be set to TRUE iff the file is opened + * R/W and there is a cache image to be read. * * image_addr: haddr_t containing the base address of the on disk - * metadata cache image, or HADDR_UNDEF if that value is - * undefined. Note that this field is used both in the - * construction and write, and the read and decode of - * metadata cache image blocks. + * metadata cache image, or HADDR_UNDEF if that value is + * undefined. Note that this field is used both in the + * construction and write, and the read and decode of + * metadata cache image blocks. * - * image_len: hsize_t containing the size of the on disk metadata cache - * image, or zero if that value is undefined. Note that this - * field is used both in the construction and write, and the - * read and decode of metadata cache image blocks. + * image_len: hsize_t containing the size of the on disk metadata cache + * image, or zero if that value is undefined. Note that this + * field is used both in the construction and write, and the + * read and decode of metadata cache image blocks. * * image_data_len: size_t containing the number of bytes of data in the - * on disk metadata cache image, or zero if that value is - * undefined. + * on disk metadata cache image, or zero if that value is + * undefined. * - * In most cases, this value is the same as the image_len - * above. It exists to allow for metadata cache image blocks - * that are larger than the actual image. Thus in all - * cases image_data_len <= image_len. + * In most cases, this value is the same as the image_len + * above. It exists to allow for metadata cache image blocks + * that are larger than the actual image. Thus in all + * cases image_data_len <= image_len. * * To create the metadata cache image, we must first serialize all the * entries in the metadata cache. This is done by a scan of the index. @@ -3943,35 +4321,35 @@ typedef struct H5C_tag_info_t { * Note that all these new fields would work just as well as booleans. * * entries_loaded_counter: Number of entries loaded into the cache - * since the last time this field was reset. + * since the last time this field was reset. * * entries_inserted_counter: Number of entries inserted into the cache - * since the last time this field was reset. + * since the last time this field was reset. * * entries relocated_counter: Number of entries whose base address has - * been changed since the last time this field was reset. + * been changed since the last time this field was reset. * * entry_fd_height_change_counter: Number of entries whose flush dependency - * height has changed since the last time this field was reset. + * height has changed since the last time this field was reset. * * The following fields are used assemble the cache image prior to * writing it to disk. * * num_entries_in_image: Unsigned integer field containing the number of entries - * to be copied into the metadata cache image. Note that - * this value will be less than the number of entries in - * the cache, and the superblock and its related entries - * are not written to the metadata cache image. + * to be copied into the metadata cache image. Note that + * this value will be less than the number of entries in + * the cache, and the superblock and its related entries + * are not written to the metadata cache image. * * image_entries: Pointer to a dynamically allocated array of instance of - * H5C_image_entry_t of length num_entries_in_image, or NULL - * if that array does not exist. This array is used to - * assemble entry data to be included in the image, and to - * sort them by flush dependency height and LRU rank. + * H5C_image_entry_t of length num_entries_in_image, or NULL + * if that array does not exist. This array is used to + * assemble entry data to be included in the image, and to + * sort them by flush dependency height and LRU rank. * * image_buffer: Pointer to the dynamically allocated buffer of length - * image_len in which the metadata cache image is assembled, - * or NULL if that buffer does not exist. + * image_len in which the metadata cache image is assembled, + * or NULL if that buffer does not exist. * * * Free Space Manager Related fields: @@ -3993,13 +4371,13 @@ typedef struct H5C_tag_info_t { * flush is complete. * * rdfsm_settled: Boolean flag indicating whether the raw data free space - * manager is settled -- i.e. whether the correct space has - * been allocated for it in the file. + * manager is settled -- i.e. whether the correct space has + * been allocated for it in the file. * - * Note that the name of this field is deceptive. In the - * multi file case, the flag applies to all free space - * managers that are not involved in allocating space for - * free space manager metadata. + * Note that the name of this field is deceptive. In the + * multi file case, the flag applies to all free space + * managers that are not involved in allocating space for + * free space manager metadata. * * mdfsm_settled: Boolean flag indicating whether the meta data free space * manager is settled -- i.e. whether the correct space has @@ -4007,8 +4385,8 @@ typedef struct H5C_tag_info_t { * * Note that the name of this field is deceptive. In the * multi file case, the flag applies only to free space - * managers that are involved in allocating space for free - * space managers. + * managers that are involved in allocating space for free + * space managers. * * Page Buffer Related Fields: * @@ -4059,144 +4437,144 @@ typedef struct H5C_tag_info_t { * is true. * * hits: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The cells - * are used to record the number of times an entry with type id - * equal to the array index has been in cache when requested in - * the current epoch. + * are used to record the number of times an entry with type id + * equal to the array index has been in cache when requested in + * the current epoch. * * misses: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The cells - * are used to record the number of times an entry with type id - * equal to the array index has not been in cache when - * requested in the current epoch. + * are used to record the number of times an entry with type id + * equal to the array index has not been in cache when + * requested in the current epoch. * * write_protects: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The - * cells are used to record the number of times an entry with - * type id equal to the array index has been write protected - * in the current epoch. + * cells are used to record the number of times an entry with + * type id equal to the array index has been write protected + * in the current epoch. * - * Observe that (hits + misses) = (write_protects + read_protects). + * Observe that (hits + misses) = (write_protects + read_protects). * * read_protects: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The - * cells are used to record the number of times an entry with - * type id equal to the array index has been read protected in - * the current epoch. + * cells are used to record the number of times an entry with + * type id equal to the array index has been read protected in + * the current epoch. * * Observe that (hits + misses) = (write_protects + read_protects). * * max_read_protects: Array of int32 of length H5C__MAX_NUM_TYPE_IDS + 1. - * The cells are used to maximum number of simultaneous read - * protects on any entry with type id equal to the array index - * in the current epoch. + * The cells are used to maximum number of simultaneous read + * protects on any entry with type id equal to the array index + * in the current epoch. * * insertions: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The cells - * are used to record the number of times an entry with type - * id equal to the array index has been inserted into the - * cache in the current epoch. + * are used to record the number of times an entry with type + * id equal to the array index has been inserted into the + * cache in the current epoch. * * pinned_insertions: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. - * The cells are used to record the number of times an entry - * with type id equal to the array index has been inserted - * pinned into the cache in the current epoch. + * The cells are used to record the number of times an entry + * with type id equal to the array index has been inserted + * pinned into the cache in the current epoch. * * clears: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The cells - * are used to record the number of times a dirty entry with type - * id equal to the array index has been cleared in the current - * epoch. + * are used to record the number of times a dirty entry with type + * id equal to the array index has been cleared in the current + * epoch. * * flushes: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The cells - * are used to record the number of times an entry with type id - * equal to the array index has been written to disk in the + * are used to record the number of times an entry with type id + * equal to the array index has been written to disk in the * current epoch. * * evictions: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The cells - * are used to record the number of times an entry with type id - * equal to the array index has been evicted from the cache in - * the current epoch. + * are used to record the number of times an entry with type id + * equal to the array index has been evicted from the cache in + * the current epoch. * * take_ownerships: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The - * cells are used to record the number of times an entry with - * type id equal to the array index has been removed from the - * cache via the H5C__TAKE_OWNERSHIP_FLAG in the current epoch. + * cells are used to record the number of times an entry with + * type id equal to the array index has been removed from the + * cache via the H5C__TAKE_OWNERSHIP_FLAG in the current epoch. * * moves: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The cells - * are used to record the number of times an entry with type - * id equal to the array index has been moved in the current - * epoch. + * are used to record the number of times an entry with type + * id equal to the array index has been moved in the current + * epoch. * * entry_flush_moves: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. - * The cells are used to record the number of times an entry - * with type id equal to the array index has been moved - * during its pre-serialize callback in the current epoch. + * The cells are used to record the number of times an entry + * with type id equal to the array index has been moved + * during its pre-serialize callback in the current epoch. * * cache_flush_moves: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. - * The cells are used to record the number of times an entry - * with type id equal to the array index has been moved - * during a cache flush in the current epoch. + * The cells are used to record the number of times an entry + * with type id equal to the array index has been moved + * during a cache flush in the current epoch. * * pins: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The cells - * are used to record the number of times an entry with type - * id equal to the array index has been pinned in the current - * epoch. + * are used to record the number of times an entry with type + * id equal to the array index has been pinned in the current + * epoch. * * unpins: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The cells - * are used to record the number of times an entry with type - * id equal to the array index has been unpinned in the current - * epoch. + * are used to record the number of times an entry with type + * id equal to the array index has been unpinned in the current + * epoch. * - * dirty_pins: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The cells - * are used to record the number of times an entry with type - * id equal to the array index has been marked dirty while pinned - * in the current epoch. + * dirty_pins: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The cells + * are used to record the number of times an entry with type + * id equal to the array index has been marked dirty while pinned + * in the current epoch. * * pinned_flushes: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The - * cells are used to record the number of times an entry - * with type id equal to the array index has been flushed while - * pinned in the current epoch. + * cells are used to record the number of times an entry + * with type id equal to the array index has been flushed while + * pinned in the current epoch. * * pinned_clears: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The - * cells are used to record the number of times an entry - * with type id equal to the array index has been cleared while - * pinned in the current epoch. + * cells are used to record the number of times an entry + * with type id equal to the array index has been cleared while + * pinned in the current epoch. * * size_increases: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. - * The cells are used to record the number of times an entry - * with type id equal to the array index has increased in - * size in the current epoch. + * The cells are used to record the number of times an entry + * with type id equal to the array index has increased in + * size in the current epoch. * * size_decreases: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. - * The cells are used to record the number of times an entry - * with type id equal to the array index has decreased in - * size in the current epoch. + * The cells are used to record the number of times an entry + * with type id equal to the array index has decreased in + * size in the current epoch. * * entry_flush_size_changes: Array of int64 of length - * H5C__MAX_NUM_TYPE_IDS + 1. The cells are used to record - * the number of times an entry with type id equal to the - * array index has changed size while in its pre-serialize - * callback. + * H5C__MAX_NUM_TYPE_IDS + 1. The cells are used to record + * the number of times an entry with type id equal to the + * array index has changed size while in its pre-serialize + * callback. * * cache_flush_size_changes: Array of int64 of length - * H5C__MAX_NUM_TYPE_IDS + 1. The cells are used to record - * the number of times an entry with type id equal to the - * array index has changed size during a cache flush + * H5C__MAX_NUM_TYPE_IDS + 1. The cells are used to record + * the number of times an entry with type id equal to the + * array index has changed size during a cache flush * * total_ht_insertions: Number of times entries have been inserted into the - * hash table in the current epoch. + * hash table in the current epoch. * * total_ht_deletions: Number of times entries have been deleted from the * hash table in the current epoch. * * successful_ht_searches: int64 containing the total number of successful - * searches of the hash table in the current epoch. + * searches of the hash table in the current epoch. * * total_successful_ht_search_depth: int64 containing the total number of - * entries other than the targets examined in successful - * searches of the hash table in the current epoch. + * entries other than the targets examined in successful + * searches of the hash table in the current epoch. * * failed_ht_searches: int64 containing the total number of unsuccessful * searches of the hash table in the current epoch. * * total_failed_ht_search_depth: int64 containing the total number of * entries examined in unsuccessful searches of the hash - * table in the current epoch. + * table in the current epoch. * * max_index_len: Largest value attained by the index_len field in the * current epoch. @@ -4205,10 +4583,10 @@ typedef struct H5C_tag_info_t { * current epoch. * * max_clean_index_size: Largest value attained by the clean_index_size field - * in the current epoch. + * in the current epoch. * * max_dirty_index_size: Largest value attained by the dirty_index_size field - * in the current epoch. + * in the current epoch. * * max_slist_len: Largest value attained by the slist_len field in the * current epoch. @@ -4259,11 +4637,11 @@ typedef struct H5C_tag_info_t { * The following fields track statistics on cache images. * * images_created: Integer field containing the number of cache images - * created since the last time statistics were reset. + * created since the last time statistics were reset. * - * At present, this field must always be either 0 or 1. - * Further, since cache images are only created at file - * close, this field should only be set at that time. + * At present, this field must always be either 0 or 1. + * Further, since cache images are only created at file + * close, this field should only be set at that time. * * images_read: Integer field containing the number of cache images * read from file. Note that reading an image is different @@ -4278,12 +4656,12 @@ typedef struct H5C_tag_info_t { * from process 0. * * images_loaded: Integer field containing the number of cache images - * loaded since the last time statistics were reset. + * loaded since the last time statistics were reset. * - * At present, this field must always be either 0 or 1. - * Further, since cache images are only loaded at the - * time of the first protect or on file close, this value - * should only change on those events. + * At present, this field must always be either 0 or 1. + * Further, since cache images are only loaded at the + * time of the first protect or on file close, this value + * should only change on those events. * * last_image_size: Size of the most recently loaded metadata cache image * loaded into the cache, or zero if no image has been @@ -4299,11 +4677,11 @@ typedef struct H5C_tag_info_t { * of prefetched entries are tracked in the flushes and evictions arrays * discused above. * - * prefetches: Number of prefetched entries that are loaded to the - * cache. + * prefetches: Number of prefetched entries that are loaded to the + * cache. * * dirty_prefetches: Number of dirty prefetched entries that are loaded - * into the cache. + * into the cache. * * prefetch_hits: Number of prefetched entries that are actually used. * @@ -4319,9 +4697,9 @@ typedef struct H5C_tag_info_t { * obtain estimates of how frequently these restarts occur. * * slist_scan_restarts: Number of times a scan of the slist (that contains - * calls to H5C__flush_single_entry()) has been restarted to - * avoid potential issues with change of status of the next - * entry in the scan. + * calls to H5C__flush_single_entry()) has been restarted to + * avoid potential issues with change of status of the next + * entry in the scan. * * LRU_scan_restarts: Number of times a scan of the LRU list (that contains * calls to H5C__flush_single_entry()) has been restarted to @@ -4329,43 +4707,43 @@ typedef struct H5C_tag_info_t { * entry in the scan. * * index_scan_restarts: Number of times a scan of the index has been - * restarted to avoid potential issues with load, insertion - * or change in flush dependency height of an entry other - * than the target entry as the result of call(s) to the - * pre_serialize or serialize callbacks. + * restarted to avoid potential issues with load, insertion + * or change in flush dependency height of an entry other + * than the target entry as the result of call(s) to the + * pre_serialize or serialize callbacks. * - * Note that at present, this condition can only be triggered - * by a call to H5C_serialize_single_entry(). + * Note that at present, this condition can only be triggered + * by a call to H5C_serialize_single_entry(). * * The remaining stats are collected only when both H5C_COLLECT_CACHE_STATS * and H5C_COLLECT_CACHE_ENTRY_STATS are true. * * max_accesses: Array of int32 of length H5C__MAX_NUM_TYPE_IDS + 1. The cells - * are used to record the maximum number of times any single - * entry with type id equal to the array index has been - * accessed in the current epoch. + * are used to record the maximum number of times any single + * entry with type id equal to the array index has been + * accessed in the current epoch. * * min_accesses: Array of int32 of length H5C__MAX_NUM_TYPE_IDS + 1. The cells - * are used to record the minimum number of times any single - * entry with type id equal to the array index has been - * accessed in the current epoch. + * are used to record the minimum number of times any single + * entry with type id equal to the array index has been + * accessed in the current epoch. * * max_clears: Array of int32 of length H5C__MAX_NUM_TYPE_IDS + 1. The cells - * are used to record the maximum number of times any single - * entry with type id equal to the array index has been cleared - * in the current epoch. + * are used to record the maximum number of times any single + * entry with type id equal to the array index has been cleared + * in the current epoch. * * max_flushes: Array of int32 of length H5C__MAX_NUM_TYPE_IDS + 1. The cells - * are used to record the maximum number of times any single - * entry with type id equal to the array index has been - * flushed in the current epoch. + * are used to record the maximum number of times any single + * entry with type id equal to the array index has been + * flushed in the current epoch. * - * max_size: Array of size_t of length H5C__MAX_NUM_TYPE_IDS + 1. The cells + * max_size: Array of size_t of length H5C__MAX_NUM_TYPE_IDS + 1. The cells * are used to record the maximum size of any single entry - * with type id equal to the array index that has resided in - * the cache in the current epoch. + * with type id equal to the array index that has resided in + * the cache in the current epoch. * - * max_pins: Array of size_t of length H5C__MAX_NUM_TYPE_IDS + 1. The cells + * max_pins: Array of size_t of length H5C__MAX_NUM_TYPE_IDS + 1. The cells * are used to record the maximum number of times that any single * entry with type id equal to the array index that has been * marked as pinned in the cache in the current epoch. @@ -4373,9 +4751,9 @@ typedef struct H5C_tag_info_t { * * Fields supporting testing: * - * prefix Array of char used to prefix debugging output. The - * field is intended to allow marking of output of with - * the processes mpi rank. + * prefix Array of char used to prefix debugging output. The + * field is intended to allow marking of output of with + * the processes mpi rank. * * get_entry_ptr_from_addr_counter: Counter used to track the number of * times the H5C_get_entry_ptr_from_addr() function has been @@ -4405,35 +4783,36 @@ typedef struct H5C_tag_info_t { * behaviour elsewhere. * ****************************************************************************/ + struct H5C_t { - uint32_t magic; - hbool_t flush_in_progress; - H5C_log_info_t * log_info; - void * aux_ptr; - int32_t max_type_id; - const H5C_class_t *const * class_table_ptr; - size_t max_cache_size; - size_t min_clean_size; - H5C_write_permitted_func_t check_write_permitted; - hbool_t write_permitted; - H5C_log_flush_func_t log_flush; - hbool_t evictions_enabled; - hbool_t close_warning_received; - - /* Fields for maintaining [hash table] index of entries */ - uint32_t index_len; - size_t index_size; - uint32_t index_ring_len[H5C_RING_NTYPES]; - size_t index_ring_size[H5C_RING_NTYPES]; + uint32_t magic; + hbool_t flush_in_progress; + H5C_log_info_t *log_info; + void * aux_ptr; + int32_t max_type_id; + const H5C_class_t * const *class_table_ptr; + size_t max_cache_size; + size_t min_clean_size; + H5C_write_permitted_func_t check_write_permitted; + hbool_t write_permitted; + H5C_log_flush_func_t log_flush; + hbool_t evictions_enabled; + hbool_t close_warning_received; + + /* Fields for maintaining the [hash table] index of entries */ + uint32_t index_len; + size_t index_size; + uint32_t index_ring_len[H5C_RING_NTYPES]; + size_t index_ring_size[H5C_RING_NTYPES]; size_t clean_index_size; - size_t clean_index_ring_size[H5C_RING_NTYPES]; - size_t dirty_index_size; - size_t dirty_index_ring_size[H5C_RING_NTYPES]; - H5C_cache_entry_t *index[H5C__HASH_TABLE_LEN]; - uint32_t il_len; - size_t il_size; - H5C_cache_entry_t *il_head; - H5C_cache_entry_t *il_tail; + size_t clean_index_ring_size[H5C_RING_NTYPES]; + size_t dirty_index_size; + size_t dirty_index_ring_size[H5C_RING_NTYPES]; + H5C_cache_entry_t * index[H5C__HASH_TABLE_LEN]; + uint32_t il_len; + size_t il_size; + H5C_cache_entry_t * il_head; + H5C_cache_entry_t * il_tail; /* Fields supporting VFD SWMR */ hbool_t vfd_swmr_reader; @@ -4442,115 +4821,115 @@ struct H5C_t { /* Fields to detect entries removed during scans */ int64_t entries_removed_counter; - H5C_cache_entry_t *last_entry_removed_ptr; - H5C_cache_entry_t *entry_watched_for_removal; + H5C_cache_entry_t * last_entry_removed_ptr; + H5C_cache_entry_t * entry_watched_for_removal; /* Fields for maintaining list of in-order entries, for flushing */ - hbool_t slist_changed; - uint32_t slist_len; - size_t slist_size; - uint32_t slist_ring_len[H5C_RING_NTYPES]; - size_t slist_ring_size[H5C_RING_NTYPES]; - H5SL_t * slist_ptr; - uint32_t num_last_entries; + hbool_t slist_changed; + uint32_t slist_len; + size_t slist_size; + uint32_t slist_ring_len[H5C_RING_NTYPES]; + size_t slist_ring_size[H5C_RING_NTYPES]; + H5SL_t * slist_ptr; + uint32_t num_last_entries; #if H5C_DO_SANITY_CHECKS - int32_t slist_len_increase; - int64_t slist_size_increase; + int32_t slist_len_increase; + int64_t slist_size_increase; #endif /* H5C_DO_SANITY_CHECKS */ /* Fields for maintaining list of tagged entries */ - H5SL_t * tag_list; - hbool_t ignore_tags; - uint32_t num_objs_corked; + H5SL_t * tag_list; + hbool_t ignore_tags; + uint32_t num_objs_corked; /* Fields for tracking protected entries */ - uint32_t pl_len; - size_t pl_size; - H5C_cache_entry_t *pl_head_ptr; - H5C_cache_entry_t *pl_tail_ptr; + uint32_t pl_len; + size_t pl_size; + H5C_cache_entry_t * pl_head_ptr; + H5C_cache_entry_t * pl_tail_ptr; /* Fields for tracking pinned entries */ - uint32_t pel_len; - size_t pel_size; - H5C_cache_entry_t *pel_head_ptr; - H5C_cache_entry_t *pel_tail_ptr; + uint32_t pel_len; + size_t pel_size; + H5C_cache_entry_t * pel_head_ptr; + H5C_cache_entry_t * pel_tail_ptr; /* Fields for complete LRU list of entries */ - uint32_t LRU_list_len; - size_t LRU_list_size; - H5C_cache_entry_t *LRU_head_ptr; - H5C_cache_entry_t *LRU_tail_ptr; + uint32_t LRU_list_len; + size_t LRU_list_size; + H5C_cache_entry_t * LRU_head_ptr; + H5C_cache_entry_t * LRU_tail_ptr; #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS /* Fields for clean LRU list of entries */ - uint32_t cLRU_list_len; - size_t cLRU_list_size; - H5C_cache_entry_t *cLRU_head_ptr; - H5C_cache_entry_t *cLRU_tail_ptr; + uint32_t cLRU_list_len; + size_t cLRU_list_size; + H5C_cache_entry_t * cLRU_head_ptr; + H5C_cache_entry_t * cLRU_tail_ptr; /* Fields for dirty LRU list of entries */ - uint32_t dLRU_list_len; - size_t dLRU_list_size; - H5C_cache_entry_t *dLRU_head_ptr; - H5C_cache_entry_t *dLRU_tail_ptr; + uint32_t dLRU_list_len; + size_t dLRU_list_size; + H5C_cache_entry_t * dLRU_head_ptr; + H5C_cache_entry_t * dLRU_tail_ptr; #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ #ifdef H5_HAVE_PARALLEL /* Fields for collective metadata reads */ - uint32_t coll_list_len; - size_t coll_list_size; - H5C_cache_entry_t *coll_head_ptr; - H5C_cache_entry_t *coll_tail_ptr; + uint32_t coll_list_len; + size_t coll_list_size; + H5C_cache_entry_t * coll_head_ptr; + H5C_cache_entry_t * coll_tail_ptr; /* Fields for collective metadata writes */ - H5SL_t *coll_write_list; + H5SL_t * coll_write_list; #endif /* H5_HAVE_PARALLEL */ /* Fields for automatic cache size adjustment */ - hbool_t size_increase_possible; - hbool_t flash_size_increase_possible; - size_t flash_size_increase_threshold; - hbool_t size_decrease_possible; - hbool_t resize_enabled; - hbool_t cache_full; - hbool_t size_decreased; - hbool_t resize_in_progress; - hbool_t msic_in_progress; - H5C_auto_size_ctl_t resize_ctl; + hbool_t size_increase_possible; + hbool_t flash_size_increase_possible; + size_t flash_size_increase_threshold; + hbool_t size_decrease_possible; + hbool_t resize_enabled; + hbool_t cache_full; + hbool_t size_decreased; + hbool_t resize_in_progress; + hbool_t msic_in_progress; + H5C_auto_size_ctl_t resize_ctl; /* Fields for epoch markers used in automatic cache size adjustment */ - int32_t epoch_markers_active; - hbool_t epoch_marker_active[H5C__MAX_EPOCH_MARKERS]; - int32_t epoch_marker_ringbuf[H5C__MAX_EPOCH_MARKERS + 1]; - int32_t epoch_marker_ringbuf_first; - int32_t epoch_marker_ringbuf_last; - int32_t epoch_marker_ringbuf_size; - H5C_cache_entry_t epoch_markers[H5C__MAX_EPOCH_MARKERS]; + int32_t epoch_markers_active; + hbool_t epoch_marker_active[H5C__MAX_EPOCH_MARKERS]; + int32_t epoch_marker_ringbuf[H5C__MAX_EPOCH_MARKERS+1]; + int32_t epoch_marker_ringbuf_first; + int32_t epoch_marker_ringbuf_last; + int32_t epoch_marker_ringbuf_size; + H5C_cache_entry_t epoch_markers[H5C__MAX_EPOCH_MARKERS]; /* Fields for cache hit rate collection */ - int64_t cache_hits; - int64_t cache_accesses; + int64_t cache_hits; + int64_t cache_accesses; /* fields supporting generation of a cache image on file close */ - H5C_cache_image_ctl_t image_ctl; - hbool_t serialization_in_progress; - hbool_t load_image; - hbool_t image_loaded; - hbool_t delete_image; - haddr_t image_addr; - hsize_t image_len; - hsize_t image_data_len; - int64_t entries_loaded_counter; - int64_t entries_inserted_counter; - int64_t entries_relocated_counter; - int64_t entry_fd_height_change_counter; - uint32_t num_entries_in_image; - H5C_image_entry_t * image_entries; - void * image_buffer; + H5C_cache_image_ctl_t image_ctl; + hbool_t serialization_in_progress; + hbool_t load_image; + hbool_t image_loaded; + hbool_t delete_image; + haddr_t image_addr; + hsize_t image_len; + hsize_t image_data_len; + int64_t entries_loaded_counter; + int64_t entries_inserted_counter; + int64_t entries_relocated_counter; + int64_t entry_fd_height_change_counter; + uint32_t num_entries_in_image; + H5C_image_entry_t * image_entries; + void * image_buffer; /* Free Space Manager Related fields */ - hbool_t rdfsm_settled; - hbool_t mdfsm_settled; + hbool_t rdfsm_settled; + hbool_t mdfsm_settled; /* Fields supporting page buffer hints */ const H5C_class_t *curr_io_type; @@ -4558,126 +4937,132 @@ struct H5C_t { #if H5C_COLLECT_CACHE_STATS /* stats fields */ - int64_t hits[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t misses[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t write_protects[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t read_protects[H5C__MAX_NUM_TYPE_IDS + 1]; - int32_t max_read_protects[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t insertions[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t pinned_insertions[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t clears[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t flushes[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t evictions[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t take_ownerships[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t moves[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t entry_flush_moves[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t cache_flush_moves[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t pins[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t unpins[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t dirty_pins[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t pinned_flushes[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t pinned_clears[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t size_increases[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t size_decreases[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t entry_flush_size_changes[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t cache_flush_size_changes[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t hits[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t misses[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t write_protects[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t read_protects[H5C__MAX_NUM_TYPE_IDS + 1]; + int32_t max_read_protects[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t insertions[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t pinned_insertions[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t clears[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t flushes[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t evictions[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t take_ownerships[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t moves[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t entry_flush_moves[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t cache_flush_moves[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t pins[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t unpins[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t dirty_pins[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t pinned_flushes[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t pinned_clears[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t size_increases[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t size_decreases[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t entry_flush_size_changes[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t cache_flush_size_changes[H5C__MAX_NUM_TYPE_IDS + 1]; /* Fields for hash table operations */ - int64_t total_ht_insertions; - int64_t total_ht_deletions; - int64_t successful_ht_searches; - int64_t total_successful_ht_search_depth; - int64_t failed_ht_searches; - int64_t total_failed_ht_search_depth; - uint32_t max_index_len; - size_t max_index_size; - size_t max_clean_index_size; - size_t max_dirty_index_size; + int64_t total_ht_insertions; + int64_t total_ht_deletions; + int64_t successful_ht_searches; + int64_t total_successful_ht_search_depth; + int64_t failed_ht_searches; + int64_t total_failed_ht_search_depth; + uint32_t max_index_len; + size_t max_index_size; + size_t max_clean_index_size; + size_t max_dirty_index_size; /* Fields for in-order skip list */ - uint32_t max_slist_len; - size_t max_slist_size; + uint32_t max_slist_len; + size_t max_slist_size; /* Fields for protected entry list */ - uint32_t max_pl_len; - size_t max_pl_size; + uint32_t max_pl_len; + size_t max_pl_size; /* Fields for pinned entry list */ - uint32_t max_pel_len; - size_t max_pel_size; + uint32_t max_pel_len; + size_t max_pel_size; /* Fields for tracking 'make space in cache' (msic) operations */ - int64_t calls_to_msic; - int64_t total_entries_skipped_in_msic; - int64_t total_dirty_pf_entries_skipped_in_msic; - int64_t total_entries_scanned_in_msic; - int32_t max_entries_skipped_in_msic; - int32_t max_dirty_pf_entries_skipped_in_msic; - int32_t max_entries_scanned_in_msic; - int64_t entries_scanned_to_make_space; + int64_t calls_to_msic; + int64_t total_entries_skipped_in_msic; + int64_t total_dirty_pf_entries_skipped_in_msic; + int64_t total_entries_scanned_in_msic; + int32_t max_entries_skipped_in_msic; + int32_t max_dirty_pf_entries_skipped_in_msic; + int32_t max_entries_scanned_in_msic; + int64_t entries_scanned_to_make_space; /* Fields for tracking skip list scan restarts */ - int64_t slist_scan_restarts; - int64_t LRU_scan_restarts; - int64_t index_scan_restarts; + int64_t slist_scan_restarts; + int64_t LRU_scan_restarts; + int64_t index_scan_restarts; /* Fields for tracking cache image operations */ - int32_t images_created; - int32_t images_read; - int32_t images_loaded; - hsize_t last_image_size; + int32_t images_created; + int32_t images_read; + int32_t images_loaded; + hsize_t last_image_size; /* Fields for tracking prefetched entries */ - int64_t prefetches; - int64_t dirty_prefetches; - int64_t prefetch_hits; + int64_t prefetches; + int64_t dirty_prefetches; + int64_t prefetch_hits; #if H5C_COLLECT_CACHE_ENTRY_STATS - int32_t max_accesses[H5C__MAX_NUM_TYPE_IDS + 1]; - int32_t min_accesses[H5C__MAX_NUM_TYPE_IDS + 1]; - int32_t max_clears[H5C__MAX_NUM_TYPE_IDS + 1]; - int32_t max_flushes[H5C__MAX_NUM_TYPE_IDS + 1]; - size_t max_size[H5C__MAX_NUM_TYPE_IDS + 1]; - int32_t max_pins[H5C__MAX_NUM_TYPE_IDS + 1]; + int32_t max_accesses[H5C__MAX_NUM_TYPE_IDS + 1]; + int32_t min_accesses[H5C__MAX_NUM_TYPE_IDS + 1]; + int32_t max_clears[H5C__MAX_NUM_TYPE_IDS + 1]; + int32_t max_flushes[H5C__MAX_NUM_TYPE_IDS + 1]; + size_t max_size[H5C__MAX_NUM_TYPE_IDS + 1]; + int32_t max_pins[H5C__MAX_NUM_TYPE_IDS + 1]; #endif /* H5C_COLLECT_CACHE_ENTRY_STATS */ #endif /* H5C_COLLECT_CACHE_STATS */ - char prefix[H5C__PREFIX_LEN]; + char prefix[H5C__PREFIX_LEN]; #ifndef NDEBUG - int64_t get_entry_ptr_from_addr_counter; + int64_t get_entry_ptr_from_addr_counter; #endif /* NDEBUG */ -}; + +}; /* H5C_t */ /* Define typedef for tagged cache entry iteration callbacks */ typedef int (*H5C_tag_iter_cb_t)(H5C_cache_entry_t *entry, void *ctx); + /*****************************/ /* Package Private Variables */ /*****************************/ + /******************************/ /* Package Private Prototypes */ /******************************/ H5_DLL herr_t H5C__prep_image_for_file_close(H5F_t *f, hbool_t *image_generated); -H5_DLL herr_t H5C__deserialize_prefetched_entry(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t **entry_ptr_ptr, - const H5C_class_t *type, haddr_t addr, void *udata); +H5_DLL herr_t H5C__deserialize_prefetched_entry(H5F_t *f, H5C_t * cache_ptr, + H5C_cache_entry_t** entry_ptr_ptr, const H5C_class_t * type, haddr_t addr, + void * udata); /* General routines */ -H5_DLL herr_t H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags); +H5_DLL herr_t H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, + unsigned flags); H5_DLL herr_t H5C__generate_cache_image(H5F_t *f, H5C_t *cache_ptr); H5_DLL herr_t H5C__load_cache_image(H5F_t *f); -H5_DLL herr_t H5C__mark_flush_dep_serialized(H5C_cache_entry_t *entry_ptr); -H5_DLL herr_t H5C__mark_flush_dep_unserialized(H5C_cache_entry_t *entry_ptr); -H5_DLL herr_t H5C__make_space_in_cache(H5F_t *f, size_t space_needed, hbool_t write_permitted); -H5_DLL herr_t H5C__flush_marked_entries(H5F_t *f); +H5_DLL herr_t H5C__mark_flush_dep_serialized(H5C_cache_entry_t * entry_ptr); +H5_DLL herr_t H5C__mark_flush_dep_unserialized(H5C_cache_entry_t * entry_ptr); +H5_DLL herr_t H5C__make_space_in_cache(H5F_t * f, size_t space_needed, + hbool_t write_permitted); +H5_DLL herr_t H5C__flush_marked_entries(H5F_t * f); H5_DLL herr_t H5C__generate_image(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr); H5_DLL herr_t H5C__serialize_cache(H5F_t *f); -H5_DLL herr_t H5C__iter_tagged_entries(H5C_t *cache, haddr_t tag, hbool_t match_global, H5C_tag_iter_cb_t cb, - void *cb_ctx); +H5_DLL herr_t H5C__iter_tagged_entries(H5C_t *cache, haddr_t tag, hbool_t match_global, + H5C_tag_iter_cb_t cb, void *cb_ctx); /* Routines for operating on entry tags */ -H5_DLL herr_t H5C__tag_entry(H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr); +H5_DLL herr_t H5C__tag_entry(H5C_t * cache_ptr, H5C_cache_entry_t * entry_ptr); H5_DLL herr_t H5C__untag_entry(H5C_t *cache, H5C_cache_entry_t *entry); /* Testing functions */ diff --git a/src/H5EA.c b/src/H5EA.c index 4d6b7c1..8f9a4b6 100644 --- a/src/H5EA.c +++ b/src/H5EA.c @@ -116,39 +116,40 @@ H5FL_BLK_DEFINE(ea_native_elmt); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, H5EA_t *, NULL, NULL, - H5EA__new(H5F_t *f, haddr_t ea_addr, hbool_t from_open, void *ctx_udata)) +static H5EA_t * +H5EA__new(H5F_t *f, haddr_t ea_addr, hbool_t from_open, void *ctx_udata) +{ + H5EA_t * ea = NULL; /* Pointer to new extensible array */ + H5EA_hdr_t *hdr = NULL; /* The extensible array header information */ + H5EA_t * ret_value = NULL; - /* Local variables */ - H5EA_t * ea = NULL; /* Pointer to new extensible array */ - H5EA_hdr_t *hdr = NULL; /* The extensible array header information */ + FUNC_ENTER_STATIC - /* - * Check arguments. - */ + /* Check arguments */ HDassert(f); HDassert(H5F_addr_defined(ea_addr)); /* Allocate extensible array wrapper */ if (NULL == (ea = H5FL_CALLOC(H5EA_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array info") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, "memory allocation failed for extensible array info") /* Lock the array header into memory */ if (NULL == (hdr = H5EA__hdr_protect(f, ea_addr, ctx_udata, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to load extensible array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, NULL, "unable to load extensible array header") /* Check for pending array deletion */ if (from_open && hdr->pending_delete) - H5E_THROW(H5E_CANTOPENOBJ, "can't open extensible array pending deletion") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTOPENOBJ, NULL, "can't open extensible array pending deletion") /* Point extensible array wrapper at header and bump it's ref count */ ea->hdr = hdr; if (H5EA__hdr_incr(ea->hdr) < 0) - H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINC, NULL, "can't increment reference count on shared array header") /* Increment # of files using this array header */ if (H5EA__hdr_fuse_incr(ea->hdr) < 0) - H5E_THROW(H5E_CANTINC, "can't increment file reference count on shared array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINC, NULL, + "can't increment file reference count on shared array header") /* Set file pointer for this array open context */ ea->f = f; @@ -156,15 +157,16 @@ BEGIN_FUNC(STATIC, ERR, H5EA_t *, NULL, NULL, /* Set the return value */ ret_value = ea; - CATCH +done: if (hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array header") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, NULL, "unable to release extensible array header") if (!ret_value) if (ea && H5EA_close(ea) < 0) - H5E_THROW(H5E_CLOSEERROR, "unable to close extensible array") + HDONE_ERROR(H5E_EARRAY, H5E_CLOSEERROR, NULL, "unable to close extensible array") -END_FUNC(STATIC) /* end H5EA__new() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__new() */ /*------------------------------------------------------------------------- * Function: H5EA_create @@ -179,16 +181,16 @@ END_FUNC(STATIC) /* end H5EA__new() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, H5EA_t *, NULL, NULL, - H5EA_create(H5F_t *f, const H5EA_create_t *cparam, void *ctx_udata)) - - /* Local variables */ +H5EA_t * +H5EA_create(H5F_t *f, const H5EA_create_t *cparam, void *ctx_udata) +{ H5EA_t *ea = NULL; /* Pointer to new extensible array */ haddr_t ea_addr; /* Array header address */ + H5EA_t *ret_value = NULL; - /* - * Check arguments. - */ + FUNC_ENTER_NOAPI(NULL) + + /* Check arguments */ HDassert(f); HDassert(cparam); @@ -197,22 +199,23 @@ BEGIN_FUNC(PRIV, ERR, H5EA_t *, NULL, NULL, /* Create extensible array header */ if (HADDR_UNDEF == (ea_addr = H5EA__hdr_create(f, cparam, ctx_udata))) - H5E_THROW(H5E_CANTINIT, "can't create extensible array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINIT, NULL, "can't create extensible array header") /* Allocate and initialize new extensible array wrapper */ if (NULL == (ea = H5EA__new(f, ea_addr, FALSE, ctx_udata))) - H5E_THROW(H5E_CANTINIT, "allocation and/or initialization failed for extensible array wrapper") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINIT, NULL, + "allocation and/or initialization failed for extensible array wrapper") /* Set the return value */ ret_value = ea; - CATCH - +done: if (!ret_value) if (ea && H5EA_close(ea) < 0) - H5E_THROW(H5E_CLOSEERROR, "unable to close extensible array") + HDONE_ERROR(H5E_EARRAY, H5E_CLOSEERROR, NULL, "unable to close extensible array") -END_FUNC(PRIV) /* end H5EA_create() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA_create() */ /*------------------------------------------------------------------------- * Function: H5EA_open @@ -227,31 +230,33 @@ END_FUNC(PRIV) /* end H5EA_create() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, H5EA_t *, NULL, NULL, H5EA_open(H5F_t *f, haddr_t ea_addr, void *ctx_udata)) +H5EA_t * +H5EA_open(H5F_t *f, haddr_t ea_addr, void *ctx_udata) +{ + H5EA_t *ea = NULL; /* Pointer to new extensible array wrapper */ + H5EA_t *ret_value = NULL; - /* Local variables */ - H5EA_t *ea = NULL; /* Pointer to new extensible array wrapper */ + FUNC_ENTER_NOAPI(NULL) - /* - * Check arguments. - */ + /* Check arguments */ HDassert(f); HDassert(H5F_addr_defined(ea_addr)); /* Allocate and initialize new extensible array wrapper */ if (NULL == (ea = H5EA__new(f, ea_addr, TRUE, ctx_udata))) - H5E_THROW(H5E_CANTINIT, "allocation and/or initialization failed for extensible array wrapper") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINIT, NULL, + "allocation and/or initialization failed for extensible array wrapper") /* Set the return value */ ret_value = ea; - CATCH - +done: if (!ret_value) if (ea && H5EA_close(ea) < 0) - H5E_THROW(H5E_CLOSEERROR, "unable to close extensible array") + HDONE_ERROR(H5E_EARRAY, H5E_CLOSEERROR, NULL, "unable to close extensible array") -END_FUNC(PRIV) /* end H5EA_open() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA_open() */ /*------------------------------------------------------------------------- * Function: H5EA_get_nelmts @@ -265,20 +270,20 @@ END_FUNC(PRIV) /* end H5EA_open() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5EA_get_nelmts(const H5EA_t *ea, hsize_t *nelmts)) - - /* Local variables */ +herr_t +H5EA_get_nelmts(const H5EA_t *ea, hsize_t *nelmts) +{ + FUNC_ENTER_NOAPI_NOERR - /* - * Check arguments. - */ + /* Check arguments */ HDassert(ea); HDassert(nelmts); /* Retrieve the max. index set */ *nelmts = ea->hdr->stats.stored.max_idx_set; -END_FUNC(PRIV) /* end H5EA_get_nelmts() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA_get_nelmts() */ /*------------------------------------------------------------------------- * Function: H5EA_get_addr @@ -292,13 +297,12 @@ END_FUNC(PRIV) /* end H5EA_get_nelmts() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5EA_get_addr(const H5EA_t *ea, haddr_t *addr)) - - /* Local variables */ +herr_t +H5EA_get_addr(const H5EA_t *ea, haddr_t *addr) +{ + FUNC_ENTER_NOAPI_NOERR - /* - * Check arguments. - */ + /* Check arguments */ HDassert(ea); HDassert(ea->hdr); HDassert(addr); @@ -306,7 +310,8 @@ BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5EA_get_addr(const H5EA_t *ea, hadd /* Retrieve the address of the extensible array's header */ *addr = ea->hdr->addr; -END_FUNC(PRIV) /* end H5EA_get_addr() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA_get_addr() */ /*------------------------------------------------------------------------- * Function: H5EA__lookup_elmt @@ -321,12 +326,11 @@ END_FUNC(PRIV) /* end H5EA_get_addr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, - H5EA__lookup_elmt(const H5EA_t *ea, hsize_t idx, hbool_t will_extend, unsigned thing_acc, - void **thing, uint8_t **thing_elmt_buf, hsize_t *thing_elmt_idx, - H5EA__unprotect_func_t *thing_unprot_func)) - - /* Local variables */ +static herr_t +H5EA__lookup_elmt(const H5EA_t *ea, hsize_t idx, hbool_t will_extend, unsigned thing_acc, void **thing, + uint8_t **thing_elmt_buf, hsize_t *thing_elmt_idx, + H5EA__unprotect_func_t *thing_unprot_func) +{ H5EA_hdr_t * hdr = ea->hdr; /* Header for EA */ H5EA_iblock_t * iblock = NULL; /* Pointer to index block for EA */ H5EA_sblock_t * sblock = NULL; /* Pointer to super block for EA */ @@ -336,10 +340,11 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, unsigned sblock_cache_flags = H5AC__NO_FLAGS_SET; /* Flags to unprotecting super block */ hbool_t stats_changed = FALSE; /* Whether array statistics changed */ hbool_t hdr_dirty = FALSE; /* Whether the array header changed */ + herr_t ret_value = SUCCEED; - /* - * Check arguments. - */ + FUNC_ENTER_STATIC + + /* Check arguments */ HDassert(ea); HDassert(hdr); HDassert(thing); @@ -365,17 +370,18 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Create the index block */ hdr->idx_blk_addr = H5EA__iblock_create(hdr, &stats_changed); if (!H5F_addr_defined(hdr->idx_blk_addr)) - H5E_THROW(H5E_CANTCREATE, "unable to create index block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTCREATE, FAIL, "unable to create index block") hdr_dirty = TRUE; } /* end if */ else - H5_LEAVE(SUCCEED) + HGOTO_DONE(SUCCEED) } /* end if */ /* Protect index block */ if (NULL == (iblock = H5EA__iblock_protect(hdr, thing_acc))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array index block, address = %llu", - (unsigned long long)hdr->idx_blk_addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect extensible array index block, address = %llu", + (unsigned long long)hdr->idx_blk_addr) /* Check if element is in index block */ if (idx < hdr->cparam.idx_blk_elmts) { @@ -416,21 +422,23 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, dblk_addr = H5EA__dblock_create(hdr, iblock, &stats_changed, dblk_off, hdr->sblk_info[sblk_idx].dblk_nelmts); if (!H5F_addr_defined(dblk_addr)) - H5E_THROW(H5E_CANTCREATE, "unable to create extensible array data block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTCREATE, FAIL, + "unable to create extensible array data block") /* Set data block address in index block */ iblock->dblk_addrs[dblk_idx] = dblk_addr; iblock_cache_flags |= H5AC__DIRTIED_FLAG; } /* end if */ else - H5_LEAVE(SUCCEED) + HGOTO_DONE(SUCCEED) } /* end if */ /* Protect data block */ if (NULL == (dblock = H5EA__dblock_protect(hdr, iblock, iblock->dblk_addrs[dblk_idx], hdr->sblk_info[sblk_idx].dblk_nelmts, thing_acc))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array data block, address = %llu", - (unsigned long long)iblock->dblk_addrs[dblk_idx]) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect extensible array data block, address = %llu", + (unsigned long long)iblock->dblk_addrs[dblk_idx]) /* Adjust index to offset in data block */ elmt_idx %= hdr->sblk_info[sblk_idx].dblk_nelmts; @@ -438,9 +446,10 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Check if there is already a dependency on the header */ if (will_extend && !dblock->has_hdr_depend) { if (H5EA__create_flush_depend((H5AC_info_t *)hdr, (H5AC_info_t *)dblock) < 0) - H5E_THROW(H5E_CANTDEPEND, - "unable to create flush dependency between data block and header, index = %llu", - (unsigned long long)idx) + HGOTO_ERROR( + H5E_EARRAY, H5E_CANTDEPEND, FAIL, + "unable to create flush dependency between data block and header, index = %llu", + (unsigned long long)idx) dblock->has_hdr_depend = TRUE; } /* end if */ @@ -465,21 +474,23 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Create super block */ sblk_addr = H5EA__sblock_create(hdr, iblock, &stats_changed, sblk_idx); if (!H5F_addr_defined(sblk_addr)) - H5E_THROW(H5E_CANTCREATE, "unable to create extensible array super block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTCREATE, FAIL, + "unable to create extensible array super block") /* Set super block address in index block */ iblock->sblk_addrs[sblk_off] = sblk_addr; iblock_cache_flags |= H5AC__DIRTIED_FLAG; } /* end if */ else - H5_LEAVE(SUCCEED) + HGOTO_DONE(SUCCEED) } /* end if */ /* Protect super block */ if (NULL == (sblock = H5EA__sblock_protect(hdr, iblock, iblock->sblk_addrs[sblk_off], sblk_idx, thing_acc))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array super block, address = %llu", - (unsigned long long)iblock->sblk_addrs[sblk_off]) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect extensible array super block, address = %llu", + (unsigned long long)iblock->sblk_addrs[sblk_off]) /* Compute the data block index in super block */ dblk_idx = (size_t)(elmt_idx / sblock->dblk_nelmts); @@ -498,7 +509,8 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, dblk_addr = H5EA__dblock_create(hdr, sblock, &stats_changed, dblk_off, sblock->dblk_nelmts); if (!H5F_addr_defined(dblk_addr)) - H5E_THROW(H5E_CANTCREATE, "unable to create extensible array data block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTCREATE, FAIL, + "unable to create extensible array data block") /* Set data block address in index block */ sblock->dblk_addrs[dblk_idx] = dblk_addr; @@ -508,8 +520,8 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, */ if (will_extend && !sblock->has_hdr_depend) { if (H5EA__create_flush_depend((H5AC_info_t *)sblock->hdr, (H5AC_info_t *)sblock) < 0) - H5E_THROW( - H5E_CANTDEPEND, + HGOTO_ERROR( + H5E_EARRAY, H5E_CANTDEPEND, FAIL, "unable to create flush dependency between super block and header, address " "= %llu", (unsigned long long)sblock->addr) @@ -517,7 +529,7 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, } /* end if */ } /* end if */ else - H5_LEAVE(SUCCEED) + HGOTO_DONE(SUCCEED) } /* end if */ /* Adjust index to offset in data block */ @@ -548,29 +560,29 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, if (0 == (thing_acc & H5AC__READ_ONLY_FLAG)) { /* i.e. r/w access */ /* Create the data block page */ if (H5EA__dblk_page_create(hdr, sblock, dblk_page_addr) < 0) - H5E_THROW(H5E_CANTCREATE, "unable to create data block page") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTCREATE, FAIL, "unable to create data block page") /* Mark data block page as initialized in super block */ H5VM_bit_set(sblock->page_init, page_init_idx, TRUE); sblock_cache_flags |= H5AC__DIRTIED_FLAG; } /* end if */ else - H5_LEAVE(SUCCEED) + HGOTO_DONE(SUCCEED) } /* end if */ /* Protect data block page */ if (NULL == (dblk_page = H5EA__dblk_page_protect(hdr, sblock, dblk_page_addr, thing_acc))) - H5E_THROW(H5E_CANTPROTECT, - "unable to protect extensible array data block page, address = %llu", - (unsigned long long)dblk_page_addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect extensible array data block page, address = %llu", + (unsigned long long)dblk_page_addr) /* Check if there is already a dependency on the header */ if (will_extend && !dblk_page->has_hdr_depend) { if (H5EA__create_flush_depend((H5AC_info_t *)hdr, (H5AC_info_t *)dblk_page) < 0) - H5E_THROW(H5E_CANTDEPEND, - "unable to create flush dependency between data block page and header, " - "index = %llu", - (unsigned long long)idx) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDEPEND, FAIL, + "unable to create flush dependency between data block page and header, " + "index = %llu", + (unsigned long long)idx) dblk_page->has_hdr_depend = TRUE; } /* end if */ @@ -584,15 +596,15 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Protect data block */ if (NULL == (dblock = H5EA__dblock_protect(hdr, sblock, sblock->dblk_addrs[dblk_idx], sblock->dblk_nelmts, thing_acc))) - H5E_THROW(H5E_CANTPROTECT, - "unable to protect extensible array data block, address = %llu", - (unsigned long long)sblock->dblk_addrs[dblk_idx]) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect extensible array data block, address = %llu", + (unsigned long long)sblock->dblk_addrs[dblk_idx]) /* Check if there is already a dependency on the header */ if (will_extend && !dblock->has_hdr_depend) { if (H5EA__create_flush_depend((H5AC_info_t *)hdr, (H5AC_info_t *)dblock) < 0) - H5E_THROW( - H5E_CANTDEPEND, + HGOTO_ERROR( + H5E_EARRAY, H5E_CANTDEPEND, FAIL, "unable to create flush dependency between data block and header, index = %llu", (unsigned long long)idx) dblock->has_hdr_depend = TRUE; @@ -611,7 +623,7 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, HDassert(*thing != NULL); HDassert(*thing_unprot_func != NULL); - CATCH +done: /* Reset 'thing' info on error */ if (ret_value < 0) { *thing = NULL; @@ -627,20 +639,22 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Check for header modified */ if (hdr_dirty) if (H5EA__hdr_modified(hdr) < 0) - H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark extensible array header as modified") + HDONE_ERROR(H5E_EARRAY, H5E_CANTMARKDIRTY, FAIL, + "unable to mark extensible array header as modified") /* Release resources */ if (iblock && *thing != iblock && H5EA__iblock_unprotect(iblock, iblock_cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array index block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array index block") /* (Note: super blocks don't contain elements, so don't have a '*thing != sblock' check) */ if (sblock && H5EA__sblock_unprotect(sblock, sblock_cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array super block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array super block") if (dblock && *thing != dblock && H5EA__dblock_unprotect(dblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array data block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array data block") if (dblk_page && *thing != dblk_page && H5EA__dblk_page_unprotect(dblk_page, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array data block page") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array data block page") -END_FUNC(STATIC) /* end H5EA__lookup_elmt() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__lookup_elmt() */ /*------------------------------------------------------------------------- * Function: H5EA_set @@ -654,9 +668,9 @@ END_FUNC(STATIC) /* end H5EA__lookup_elmt() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_set(const H5EA_t *ea, hsize_t idx, const void *elmt)) - - /* Local variables */ +herr_t +H5EA_set(const H5EA_t *ea, hsize_t idx, const void *elmt) +{ H5EA_hdr_t *hdr = ea->hdr; /* Header for EA */ void * thing = NULL; /* Pointer to the array metadata containing the array index we are interested in */ uint8_t *thing_elmt_buf; /* Pointer to the element buffer for the array metadata */ @@ -664,10 +678,11 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_set(const H5EA_t *ea, hsize_t H5EA__unprotect_func_t thing_unprot_func; /* Function pointer for unprotecting the array metadata */ hbool_t will_extend; /* Flag indicating if setting the element will extend the array */ unsigned thing_cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting array metadata */ + herr_t ret_value = SUCCEED; - /* - * Check arguments. - */ + FUNC_ENTER_NOAPI(FAIL) + + /* Check arguments */ HDassert(ea); HDassert(hdr); @@ -678,7 +693,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_set(const H5EA_t *ea, hsize_t will_extend = (idx >= hdr->stats.stored.max_idx_set); if (H5EA__lookup_elmt(ea, idx, will_extend, H5AC__NO_FLAGS_SET, &thing, &thing_elmt_buf, &thing_elmt_idx, &thing_unprot_func) < 0) - H5E_THROW(H5E_CANTPROTECT, "unable to protect array metadata") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, "unable to protect array metadata") /* Sanity check */ HDassert(thing); @@ -695,15 +710,17 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_set(const H5EA_t *ea, hsize_t /* Update the max index for the array */ hdr->stats.stored.max_idx_set = idx + 1; if (H5EA__hdr_modified(hdr) < 0) - H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark extensible array header as modified") - } /* end if */ + HGOTO_ERROR(H5E_EARRAY, H5E_CANTMARKDIRTY, FAIL, + "unable to mark extensible array header as modified") + } - CATCH +done: /* Release resources */ if (thing && (thing_unprot_func)(thing, thing_cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array metadata") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array metadata") -END_FUNC(PRIV) /* end H5EA_set() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA_set() */ /*------------------------------------------------------------------------- * Function: H5EA_get @@ -717,17 +734,18 @@ END_FUNC(PRIV) /* end H5EA_set() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_get(const H5EA_t *ea, hsize_t idx, void *elmt)) - - /* Local variables */ +herr_t +H5EA_get(const H5EA_t *ea, hsize_t idx, void *elmt) +{ H5EA_hdr_t *hdr = ea->hdr; /* Header for EA */ void *thing = NULL; /* Pointer to the array metadata containing the array index we are interested in */ H5EA__unprotect_func_t thing_unprot_func = NULL; /* Function pointer for unprotecting the array metadata */ + herr_t ret_value = SUCCEED; - /* - * Check arguments. - */ + FUNC_ENTER_NOAPI(FAIL) + + /* Check arguments */ HDassert(ea); HDassert(hdr); @@ -735,7 +753,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_get(const H5EA_t *ea, hsize_t if (idx >= hdr->stats.stored.max_idx_set) { /* Call the class's 'fill' callback */ if ((hdr->cparam.cls->fill)(elmt, (size_t)1) < 0) - H5E_THROW(H5E_CANTSET, "can't set element to class's fill value") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTSET, FAIL, "can't set element to class's fill value") } /* end if */ else { uint8_t *thing_elmt_buf; /* Pointer to the element buffer for the array metadata */ @@ -747,13 +765,13 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_get(const H5EA_t *ea, hsize_t /* Look up the array metadata containing the element we want to set */ if (H5EA__lookup_elmt(ea, idx, FALSE, H5AC__READ_ONLY_FLAG, &thing, &thing_elmt_buf, &thing_elmt_idx, &thing_unprot_func) < 0) - H5E_THROW(H5E_CANTPROTECT, "unable to protect array metadata") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, "unable to protect array metadata") /* Check if the thing holding the element has been created yet */ if (NULL == thing) { /* Call the class's 'fill' callback */ if ((hdr->cparam.cls->fill)(elmt, (size_t)1) < 0) - H5E_THROW(H5E_CANTSET, "can't set element to class's fill value") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTSET, FAIL, "can't set element to class's fill value") } /* end if */ else /* Get element from thing's element buffer */ @@ -761,12 +779,13 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_get(const H5EA_t *ea, hsize_t hdr->cparam.cls->nat_elmt_size); } /* end else */ - CATCH +done: /* Release thing */ if (thing && (thing_unprot_func)(thing, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array metadata") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array metadata") -END_FUNC(PRIV) /* end H5EA_get() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA_get() */ /*------------------------------------------------------------------------- * Function: H5EA_depend @@ -781,14 +800,15 @@ END_FUNC(PRIV) /* end H5EA_get() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_depend(H5EA_t *ea, H5AC_proxy_entry_t *parent)) +herr_t +H5EA_depend(H5EA_t *ea, H5AC_proxy_entry_t *parent) +{ + H5EA_hdr_t *hdr = ea->hdr; /* Header for EA */ + herr_t ret_value = SUCCEED; - /* Local variables */ - H5EA_hdr_t *hdr = ea->hdr; /* Header for EA */ + FUNC_ENTER_NOAPI(FAIL) - /* - * Check arguments. - */ + /* Check arguments */ HDassert(ea); HDassert(hdr); HDassert(parent); @@ -807,13 +827,13 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_depend(H5EA_t *ea, H5AC_proxy_ /* Add the extensible array as a child of the parent (proxy) */ if (H5AC_proxy_entry_add_child(parent, hdr->f, hdr->top_proxy) < 0) - H5E_THROW(H5E_CANTSET, "unable to add extensible array as child of proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTSET, FAIL, "unable to add extensible array as child of proxy") hdr->parent = parent; - } /* end if */ - - CATCH + } -END_FUNC(PRIV) /* end H5EA_depend() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA_depend() */ /*------------------------------------------------------------------------- * Function: H5EA_close @@ -827,15 +847,16 @@ END_FUNC(PRIV) /* end H5EA_depend() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_close(H5EA_t *ea)) - - /* Local variables */ +herr_t +H5EA_close(H5EA_t *ea) +{ hbool_t pending_delete = FALSE; /* Whether the array is pending deletion */ haddr_t ea_addr = HADDR_UNDEF; /* Address of array (for deletion) */ + herr_t ret_value = SUCCEED; - /* - * Check arguments. - */ + FUNC_ENTER_NOAPI(FAIL) + + /* Check arguments */ HDassert(ea); /* Close the header, if it was set */ @@ -868,8 +889,8 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_close(H5EA_t *ea)) /* Check the header's status in the metadata cache */ if (H5AC_get_entry_status(ea->f, ea_addr, &hdr_status) < 0) - H5E_THROW(H5E_CANTGET, - "unable to check metadata cache status for extensible array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTGET, FAIL, + "unable to check metadata cache status for extensible array header") /* Sanity checks on header */ HDassert(hdr_status & H5AC_ES__IN_CACHE); @@ -881,7 +902,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_close(H5EA_t *ea)) /* Lock the array header into memory */ /* (OK to pass in NULL for callback context, since we know the header must be in the cache) */ if (NULL == (hdr = H5EA__hdr_protect(ea->f, ea_addr, NULL, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTLOAD, "unable to load extensible array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTLOAD, FAIL, "unable to load extensible array header") /* Set the shared array header's file context for this operation */ hdr->f = ea->f; @@ -891,11 +912,12 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_close(H5EA_t *ea)) * immediately -QAK) */ if (H5EA__hdr_decr(ea->hdr) < 0) - H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDEC, FAIL, + "can't decrement reference count on shared array header") /* Delete array, starting with header (unprotects header) */ if (H5EA__hdr_delete(hdr) < 0) - H5E_THROW(H5E_CANTDELETE, "unable to delete extensible array") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDELETE, FAIL, "unable to delete extensible array") } /* end if */ else { /* Decrement the reference count on the array header */ @@ -903,16 +925,17 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_close(H5EA_t *ea)) * immediately -QAK) */ if (H5EA__hdr_decr(ea->hdr) < 0) - H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDEC, FAIL, + "can't decrement reference count on shared array header") } /* end else */ } /* end if */ /* Release the extensible array wrapper */ ea = (H5EA_t *)H5FL_FREE(H5EA_t, ea); - CATCH - -END_FUNC(PRIV) /* end H5EA_close() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA_close() */ /*------------------------------------------------------------------------- * Function: H5EA_delete @@ -926,21 +949,22 @@ END_FUNC(PRIV) /* end H5EA_close() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_delete(H5F_t *f, haddr_t ea_addr, void *ctx_udata)) +herr_t +H5EA_delete(H5F_t *f, haddr_t ea_addr, void *ctx_udata) +{ + H5EA_hdr_t *hdr = NULL; /* The fractal heap header information */ + herr_t ret_value = SUCCEED; - /* Local variables */ - H5EA_hdr_t *hdr = NULL; /* The fractal heap header information */ + FUNC_ENTER_NOAPI(FAIL) - /* - * Check arguments. - */ + /* Check arguments */ HDassert(f); HDassert(H5F_addr_defined(ea_addr)); /* Lock the array header into memory */ if (NULL == (hdr = H5EA__hdr_protect(f, ea_addr, ctx_udata, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array header, address = %llu", - (unsigned long long)ea_addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect extensible array header, address = %llu", (unsigned long long)ea_addr) /* Check for files using shared array header */ if (hdr->file_rc) @@ -951,17 +975,17 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_delete(H5F_t *f, haddr_t ea_ad /* Delete array now, starting with header (unprotects header) */ if (H5EA__hdr_delete(hdr) < 0) - H5E_THROW(H5E_CANTDELETE, "unable to delete extensible array") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDELETE, FAIL, "unable to delete extensible array") hdr = NULL; - } /* end if */ + } - CATCH - - /* Unprotect the header, if an error occurred */ +done: + /* Unprotect the header if an error occurred */ if (hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array header") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array header") -END_FUNC(PRIV) /* end H5EA_delete() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA_delete() */ /*------------------------------------------------------------------------- * Function: H5EA_iterate @@ -975,13 +999,14 @@ END_FUNC(PRIV) /* end H5EA_delete() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, int, H5_ITER_CONT, H5_ITER_ERROR, - H5EA_iterate(H5EA_t *ea, H5EA_operator_t op, void *udata)) - - /* Local variables */ +int +H5EA_iterate(H5EA_t *ea, H5EA_operator_t op, void *udata) +{ uint8_t *elmt = NULL; hsize_t u; - int cb_ret = H5_ITER_CONT; /* Return value from callback */ + int ret_value = H5_ITER_CONT; + + FUNC_ENTER_NOAPI(H5_ITER_ERROR) /* Check arguments */ HDassert(ea); @@ -990,27 +1015,28 @@ BEGIN_FUNC(PRIV, ERR, int, H5_ITER_CONT, H5_ITER_ERROR, /* Allocate space for a native array element */ if (NULL == (elmt = H5FL_BLK_MALLOC(ea_native_elmt, ea->hdr->cparam.cls->nat_elmt_size))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array element") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, H5_ITER_ERROR, + "memory allocation failed for extensible array element") /* Iterate over all elements in array */ - for (u = 0; u < ea->hdr->stats.stored.max_idx_set && cb_ret == H5_ITER_CONT; u++) { + for (u = 0; u < ea->hdr->stats.stored.max_idx_set && ret_value == H5_ITER_CONT; u++) { /* Get array element */ if (H5EA_get(ea, u, elmt) < 0) - H5E_THROW(H5E_CANTGET, "unable to delete fixed array") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTGET, H5_ITER_ERROR, "unable to delete fixed array") /* Make callback */ - if ((cb_ret = (*op)(u, elmt, udata)) < 0) { - H5E_PRINTF(H5E_BADITER, "iterator function failed"); - H5_LEAVE(cb_ret) - } /* end if */ - } /* end for */ - - CATCH + if ((ret_value = (*op)(u, elmt, udata)) < 0) { + HERROR(H5E_EARRAY, H5E_BADITER, "iteration callback error"); + break; + } + } +done: if (elmt) elmt = H5FL_BLK_FREE(ea_native_elmt, elmt); -END_FUNC(PRIV) /* end H5EA_iterate() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA_iterate() */ /*------------------------------------------------------------------------- * Function: H5EA_patch_file @@ -1024,17 +1050,17 @@ END_FUNC(PRIV) /* end H5EA_iterate() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5EA_patch_file(H5EA_t *ea, H5F_t *f)) - - /* Local variables */ +herr_t +H5EA_patch_file(H5EA_t *ea, H5F_t *f) +{ + FUNC_ENTER_NOAPI_NOERR - /* - * Check arguments. - */ + /* Check arguments */ HDassert(ea); HDassert(f); if (ea->f != f || ea->hdr->f != f) ea->f = ea->hdr->f = f; -END_FUNC(PRIV) /* end H5EA_patch_file() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA_patch_file() */ diff --git a/src/H5EAcache.c b/src/H5EAcache.c index 7e89592..ae1cfcc 100644 --- a/src/H5EAcache.c +++ b/src/H5EAcache.c @@ -226,12 +226,13 @@ const H5AC_class_t H5AC_EARRAY_DBLK_PAGE[1] = {{ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5EA__cache_hdr_get_initial_load_size(void *_udata, size_t *image_len)) - - /* Local variables */ +static herr_t +H5EA__cache_hdr_get_initial_load_size(void *_udata, size_t *image_len) +{ H5EA_hdr_cache_ud_t *udata = (H5EA_hdr_cache_ud_t *)_udata; /* User data for callback */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(udata); HDassert(udata->f); @@ -240,7 +241,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Set the image length size */ *image_len = (size_t)H5EA_HEADER_SIZE_FILE(udata->f); -END_FUNC(STATIC) /* end H5EA__cache_hdr_get_initial_load_size() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__cache_hdr_get_initial_load_size() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_hdr_verify_chksum @@ -255,13 +257,15 @@ END_FUNC(STATIC) /* end H5EA__cache_hdr_get_initial_load_size() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, - H5EA__cache_hdr_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata)) - - /* Local variables */ +static htri_t +H5EA__cache_hdr_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata) +{ const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ uint32_t computed_chksum; /* Computed metadata checksum value */ + htri_t ret_value = TRUE; + + FUNC_ENTER_STATIC_NOERR /* Check arguments */ HDassert(image); @@ -272,7 +276,8 @@ BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, if (stored_chksum != computed_chksum) ret_value = FALSE; -END_FUNC(STATIC) /* end H5EA__cache_hdr_verify_chksum() */ + FUNC_LEAVE_NOAPI(ret_value); +} /* end H5EA__cache_hdr_verify_chksum() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_hdr_deserialize @@ -287,16 +292,17 @@ END_FUNC(STATIC) /* end H5EA__cache_hdr_verify_chksum() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, - H5EA__cache_hdr_deserialize(const void *_image, size_t len, void *_udata, - hbool_t H5_ATTR_UNUSED *dirty)) - - /* Local variables */ +static void * +H5EA__cache_hdr_deserialize(const void *_image, size_t len, void *_udata, hbool_t H5_ATTR_UNUSED *dirty) +{ H5EA_cls_id_t id; /* ID of extensible array class, as found in file */ H5EA_hdr_t * hdr = NULL; /* Extensible array info */ H5EA_hdr_cache_ud_t *udata = (H5EA_hdr_cache_ud_t *)_udata; const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ + void * ret_value = NULL; + + FUNC_ENTER_STATIC /* Check arguments */ HDassert(image); @@ -306,24 +312,25 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Allocate space for the extensible array data structure */ if (NULL == (hdr = H5EA__hdr_alloc(udata->f))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array shared header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for extensible array shared header") /* Set the extensible array header's address */ hdr->addr = udata->addr; /* Magic number */ if (HDmemcmp(image, H5EA_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC) != 0) - H5E_THROW(H5E_BADVALUE, "wrong extensible array header signature") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, NULL, "wrong extensible array header signature") image += H5_SIZEOF_MAGIC; /* Version */ if (*image++ != H5EA_HDR_VERSION) - H5E_THROW(H5E_VERSION, "wrong extensible array header version") + HGOTO_ERROR(H5E_EARRAY, H5E_VERSION, NULL, "wrong extensible array header version") /* Extensible array class */ id = (H5EA_cls_id_t)*image++; if (id >= H5EA_NUM_CLS_ID) - H5E_THROW(H5E_BADTYPE, "incorrect extensible array class") + HGOTO_ERROR(H5E_EARRAY, H5E_BADTYPE, NULL, "incorrect extensible array class") hdr->cparam.cls = H5EA_client_class_g[id]; /* General array creation/configuration information */ @@ -384,20 +391,20 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Finish initializing extensible array header */ if (H5EA__hdr_init(hdr, udata->ctx_udata) < 0) - H5E_THROW(H5E_CANTINIT, "initialization failed for extensible array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINIT, NULL, "initialization failed for extensible array header") HDassert(hdr->size == len); /* Set return value */ ret_value = hdr; - CATCH - +done: /* Release resources */ if (!ret_value) if (hdr && H5EA__hdr_dest(hdr) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array header") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array header") -END_FUNC(STATIC) /* end H5EA__cache_hdr_deserialize() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_hdr_deserialize() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_hdr_image_len @@ -411,12 +418,13 @@ END_FUNC(STATIC) /* end H5EA__cache_hdr_deserialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5EA__cache_hdr_image_len(const void *_thing, size_t *image_len)) - - /* Local variables */ +static herr_t +H5EA__cache_hdr_image_len(const void *_thing, size_t *image_len) +{ const H5EA_hdr_t *hdr = (const H5EA_hdr_t *)_thing; /* Pointer to the object */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(hdr); HDassert(image_len); @@ -424,7 +432,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Set the image length size */ *image_len = hdr->size; -END_FUNC(STATIC) /* end H5EA__cache_hdr_image_len() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__cache_hdr_image_len() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_hdr_serialize @@ -438,14 +447,15 @@ END_FUNC(STATIC) /* end H5EA__cache_hdr_image_len() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5EA__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, void *_thing)) - - /* Local variables */ +static herr_t +H5EA__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, void *_thing) +{ H5EA_hdr_t *hdr = (H5EA_hdr_t *)_thing; /* Pointer to the extensible array header */ uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t metadata_chksum; /* Computed metadata checksum value */ + FUNC_ENTER_STATIC_NOERR + /* check arguments */ HDassert(f); HDassert(image); @@ -493,7 +503,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Sanity check */ HDassert((size_t)(image - (uint8_t *)_image) == len); -END_FUNC(STATIC) /* end H5EA__cache_hdr_serialize() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__cache_hdr_serialize() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_hdr_notify @@ -507,11 +518,13 @@ END_FUNC(STATIC) /* end H5EA__cache_hdr_serialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, - H5EA__cache_hdr_notify(H5AC_notify_action_t action, void *_thing)) +static herr_t +H5EA__cache_hdr_notify(H5AC_notify_action_t action, void *_thing) +{ + H5EA_hdr_t *hdr = (H5EA_hdr_t *)_thing; /* Pointer to the object */ + herr_t ret_value = SUCCEED; - /* Local variables */ - H5EA_hdr_t *hdr = (H5EA_hdr_t *)_thing; /* Pointer to the object */ + FUNC_ENTER_STATIC /* Sanity check */ HDassert(hdr); @@ -543,23 +556,24 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Destroy flush dependency on object header proxy */ if (H5AC_proxy_entry_remove_child((H5AC_proxy_entry_t *)hdr->parent, (void *)hdr->top_proxy) < 0) - H5E_THROW(H5E_CANTUNDEPEND, - "unable to destroy flush dependency between extensible array and proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between extensible array and proxy") hdr->parent = NULL; } /* end if */ /* Detach from 'top' proxy for extensible array */ if (hdr->top_proxy) { if (H5AC_proxy_entry_remove_child(hdr->top_proxy, hdr) < 0) - H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between header and " - "extensible array 'top' proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between header and " + "extensible array 'top' proxy") /* Don't reset hdr->top_proxy here, it's destroyed when the header is freed -QAK */ } /* end if */ break; default: #ifdef NDEBUG - H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, FAIL, "unknown action from metadata cache") #else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); #endif /* NDEBUG */ @@ -568,9 +582,9 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, else HDassert(NULL == hdr->parent); - CATCH - -END_FUNC(STATIC) /* end H5EA__cache_hdr_notify() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_hdr_notify() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_hdr_free_icr @@ -585,18 +599,23 @@ END_FUNC(STATIC) /* end H5EA__cache_hdr_notify() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5EA__cache_hdr_free_icr(void *thing)) +static herr_t +H5EA__cache_hdr_free_icr(void *thing) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC /* Check arguments */ HDassert(thing); /* Release the extensible array header */ if (H5EA__hdr_dest((H5EA_hdr_t *)thing) < 0) - H5E_THROW(H5E_CANTFREE, "can't free extensible array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTFREE, FAIL, "can't free extensible array header") - CATCH - -END_FUNC(STATIC) /* end H5EA__cache_hdr_free_icr() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_hdr_free_icr() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_iblock_get_initial_load_size @@ -610,13 +629,14 @@ END_FUNC(STATIC) /* end H5EA__cache_hdr_free_icr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5EA__cache_iblock_get_initial_load_size(void *_udata, size_t *image_len)) - - /* Local variables */ +static herr_t +H5EA__cache_iblock_get_initial_load_size(void *_udata, size_t *image_len) +{ H5EA_hdr_t * hdr = (H5EA_hdr_t *)_udata; /* User data for callback */ H5EA_iblock_t iblock; /* Fake index block for computing size */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(hdr); HDassert(image_len); @@ -631,7 +651,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Set the image length size */ *image_len = (size_t)H5EA_IBLOCK_SIZE(&iblock); -END_FUNC(STATIC) /* end H5EA__cache_iblock_get_initial_load_size() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__cache_iblock_get_initial_load_size() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_iblock_verify_chksum @@ -646,13 +667,15 @@ END_FUNC(STATIC) /* end H5EA__cache_iblock_get_initial_load_size() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, - H5EA__cache_iblock_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata)) - - /* Local variables */ +static htri_t +H5EA__cache_iblock_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata) +{ const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ uint32_t computed_chksum; /* Computed metadata checksum value */ + htri_t ret_value = TRUE; + + FUNC_ENTER_STATIC_NOERR /* Check arguments */ HDassert(image); @@ -663,7 +686,8 @@ BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, if (stored_chksum != computed_chksum) ret_value = FALSE; -END_FUNC(STATIC) /* end H5EA__cache_iblock_verify_chksum() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_iblock_verify_chksum() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_iblock_deserialize @@ -678,17 +702,18 @@ END_FUNC(STATIC) /* end H5EA__cache_iblock_verify_chksum() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, - H5EA__cache_iblock_deserialize(const void *_image, size_t len, void *_udata, - hbool_t H5_ATTR_UNUSED *dirty)) - - /* Local variables */ +static void * +H5EA__cache_iblock_deserialize(const void *_image, size_t len, void *_udata, hbool_t H5_ATTR_UNUSED *dirty) +{ H5EA_iblock_t *iblock = NULL; /* Index block info */ H5EA_hdr_t * hdr = (H5EA_hdr_t *)_udata; /* User data for callback */ const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ haddr_t arr_addr; /* Address of array header in the file */ size_t u; /* Local index variable */ + void * ret_value = NULL; + + FUNC_ENTER_STATIC /* Check arguments */ HDassert(image); @@ -696,28 +721,29 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Allocate the extensible array index block */ if (NULL == (iblock = H5EA__iblock_alloc(hdr))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array index block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for extensible array index block") /* Set the extensible array index block's address */ iblock->addr = hdr->idx_blk_addr; /* Magic number */ if (HDmemcmp(image, H5EA_IBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC) != 0) - H5E_THROW(H5E_BADVALUE, "wrong extensible array index block signature") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, NULL, "wrong extensible array index block signature") image += H5_SIZEOF_MAGIC; /* Version */ if (*image++ != H5EA_IBLOCK_VERSION) - H5E_THROW(H5E_VERSION, "wrong extensible array index block version") + HGOTO_ERROR(H5E_EARRAY, H5E_VERSION, NULL, "wrong extensible array index block version") /* Extensible array type */ if (*image++ != (uint8_t)hdr->cparam.cls->id) - H5E_THROW(H5E_BADTYPE, "incorrect extensible array class") + HGOTO_ERROR(H5E_EARRAY, H5E_BADTYPE, NULL, "incorrect extensible array class") /* Address of header for array that owns this block (just for file integrity checks) */ H5F_addr_decode(hdr->f, &image, &arr_addr); if (H5F_addr_ne(arr_addr, hdr->addr)) - H5E_THROW(H5E_BADVALUE, "wrong extensible array header address") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, NULL, "wrong extensible array header address") /* Internal information */ @@ -726,7 +752,7 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Convert from raw elements on disk into native elements in memory */ if ((hdr->cparam.cls->decode)(image, iblock->elmts, (size_t)hdr->cparam.idx_blk_elmts, hdr->cb_ctx) < 0) - H5E_THROW(H5E_CANTDECODE, "can't decode extensible array index elements") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDECODE, NULL, "can't decode extensible array index elements") image += (hdr->cparam.idx_blk_elmts * hdr->cparam.raw_elmt_size); } /* end if */ @@ -762,14 +788,14 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Set return value */ ret_value = iblock; - CATCH - +done: /* Release resources */ if (!ret_value) if (iblock && H5EA__iblock_dest(iblock) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array index block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array index block") -END_FUNC(STATIC) /* end H5EA__cache_iblock_deserialize() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_iblock_deserialize() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_iblock_image_len @@ -783,12 +809,13 @@ END_FUNC(STATIC) /* end H5EA__cache_iblock_deserialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5EA__cache_iblock_image_len(const void *_thing, size_t *image_len)) - - /* Local variables */ +static herr_t +H5EA__cache_iblock_image_len(const void *_thing, size_t *image_len) +{ const H5EA_iblock_t *iblock = (const H5EA_iblock_t *)_thing; /* Pointer to the object */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(iblock); HDassert(image_len); @@ -796,7 +823,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Set the image length size */ *image_len = iblock->size; -END_FUNC(STATIC) /* end H5EA__cache_iblock_image_len() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__cache_iblock_image_len() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_iblock_serialize @@ -810,14 +838,15 @@ END_FUNC(STATIC) /* end H5EA__cache_iblock_image_len() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, - H5EA__cache_iblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, - void *_thing)) - - /* Local variables */ +static herr_t +H5EA__cache_iblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, void *_thing) +{ H5EA_iblock_t *iblock = (H5EA_iblock_t *)_thing; /* Pointer to the object to serialize */ uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t metadata_chksum; /* Computed metadata checksum value */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC /* check arguments */ HDassert(f); @@ -848,7 +877,7 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Convert from native elements in memory into raw elements on disk */ if ((iblock->hdr->cparam.cls->encode)(image, iblock->elmts, (size_t)iblock->hdr->cparam.idx_blk_elmts, iblock->hdr->cb_ctx) < 0) - H5E_THROW(H5E_CANTENCODE, "can't encode extensible array index elements") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTENCODE, FAIL, "can't encode extensible array index elements") image += (iblock->hdr->cparam.idx_blk_elmts * iblock->hdr->cparam.raw_elmt_size); } /* end if */ @@ -879,9 +908,9 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Sanity check */ HDassert((size_t)(image - (uint8_t *)_image) == len); - CATCH - -END_FUNC(STATIC) /* end H5EA__cache_iblock_serialize() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_iblock_serialize() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_iblock_notify @@ -895,11 +924,13 @@ END_FUNC(STATIC) /* end H5EA__cache_iblock_serialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, - H5EA__cache_iblock_notify(H5AC_notify_action_t action, void *_thing)) +static herr_t +H5EA__cache_iblock_notify(H5AC_notify_action_t action, void *_thing) +{ + H5EA_iblock_t *iblock = (H5EA_iblock_t *)_thing; /* Pointer to the object */ + herr_t ret_value = SUCCEED; - /* Local variables */ - H5EA_iblock_t *iblock = (H5EA_iblock_t *)_thing; /* Pointer to the object */ + FUNC_ENTER_STATIC /* Sanity check */ HDassert(iblock); @@ -910,9 +941,10 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, case H5AC_NOTIFY_ACTION_AFTER_LOAD: /* Create flush dependency on extensible array header */ if (H5EA__create_flush_depend((H5AC_info_t *)iblock->hdr, (H5AC_info_t *)iblock) < 0) - H5E_THROW(H5E_CANTDEPEND, - "unable to create flush dependency between index block and header, address = %llu", - (unsigned long long)iblock->addr) + HGOTO_ERROR( + H5E_EARRAY, H5E_CANTDEPEND, FAIL, + "unable to create flush dependency between index block and header, address = %llu", + (unsigned long long)iblock->addr) break; case H5AC_NOTIFY_ACTION_AFTER_FLUSH: @@ -928,30 +960,32 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, case H5AC_NOTIFY_ACTION_BEFORE_EVICT: /* Destroy flush dependency on extensible array header */ if (H5EA__destroy_flush_depend((H5AC_info_t *)iblock->hdr, (H5AC_info_t *)iblock) < 0) - H5E_THROW(H5E_CANTUNDEPEND, - "unable to destroy flush dependency between index block and header, address = %llu", - (unsigned long long)iblock->addr) + HGOTO_ERROR( + H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between index block and header, address = %llu", + (unsigned long long)iblock->addr) /* Detach from 'top' proxy for extensible array */ if (iblock->top_proxy) { if (H5AC_proxy_entry_remove_child(iblock->top_proxy, iblock) < 0) - H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between index block and " - "extensible array 'top' proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between index block and " + "extensible array 'top' proxy") iblock->top_proxy = NULL; } /* end if */ break; default: #ifdef NDEBUG - H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, FAIL, "unknown action from metadata cache") #else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); #endif /* NDEBUG */ } /* end switch */ - CATCH - -END_FUNC(STATIC) /* end H5EA__cache_iblock_notify() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_iblock_notify() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_iblock_free_icr @@ -966,18 +1000,23 @@ END_FUNC(STATIC) /* end H5EA__cache_iblock_notify() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5EA__cache_iblock_free_icr(void *thing)) +static herr_t +H5EA__cache_iblock_free_icr(void *thing) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC /* Check arguments */ HDassert(thing); /* Release the extensible array index block */ if (H5EA__iblock_dest((H5EA_iblock_t *)thing) < 0) - H5E_THROW(H5E_CANTFREE, "can't free extensible array index block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTFREE, FAIL, "can't free extensible array index block") - CATCH - -END_FUNC(STATIC) /* end H5EA__cache_iblock_free_icr() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_iblock_free_icr() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_sblock_get_initial_load_size @@ -991,13 +1030,14 @@ END_FUNC(STATIC) /* end H5EA__cache_iblock_free_icr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5EA__cache_sblock_get_initial_load_size(void *_udata, size_t *image_len)) - - /* Local variables */ +static herr_t +H5EA__cache_sblock_get_initial_load_size(void *_udata, size_t *image_len) +{ H5EA_sblock_cache_ud_t *udata = (H5EA_sblock_cache_ud_t *)_udata; /* User data */ H5EA_sblock_t sblock; /* Fake super block for computing size */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(udata); HDassert(udata->hdr); @@ -1031,7 +1071,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Set the image length size */ *image_len = (size_t)H5EA_SBLOCK_SIZE(&sblock); -END_FUNC(STATIC) /* end H5EA__cache_sblock_get_initial_load_size() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__cache_sblock_get_initial_load_size() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_sblock_verify_chksum @@ -1046,13 +1087,15 @@ END_FUNC(STATIC) /* end H5EA__cache_sblock_get_initial_load_size() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, - H5EA__cache_sblock_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata)) - - /* Local variables */ +static htri_t +H5EA__cache_sblock_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata) +{ const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ uint32_t computed_chksum; /* Computed metadata checksum value */ + htri_t ret_value = TRUE; + + FUNC_ENTER_STATIC_NOERR /* Check arguments */ HDassert(image); @@ -1063,7 +1106,8 @@ BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, if (stored_chksum != computed_chksum) ret_value = FALSE; -END_FUNC(STATIC) /* end H5EA__cache_sblock_verify_chksum() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_sblock_verify_chksum() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_sblock_deserialize @@ -1078,17 +1122,18 @@ END_FUNC(STATIC) /* end H5EA__cache_sblock_verify_chksum() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, - H5EA__cache_sblock_deserialize(const void *_image, size_t len, void *_udata, - hbool_t H5_ATTR_UNUSED *dirty)) - - /* Local variables */ +static void * +H5EA__cache_sblock_deserialize(const void *_image, size_t len, void *_udata, hbool_t H5_ATTR_UNUSED *dirty) +{ H5EA_sblock_t * sblock = NULL; /* Super block info */ H5EA_sblock_cache_ud_t *udata = (H5EA_sblock_cache_ud_t *)_udata; /* User data */ const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ haddr_t arr_addr; /* Address of array header in the file */ size_t u; /* Local index variable */ + void * ret_value = NULL; + + FUNC_ENTER_STATIC /* Sanity check */ HDassert(udata); @@ -1099,28 +1144,29 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Allocate the extensible array super block */ if (NULL == (sblock = H5EA__sblock_alloc(udata->hdr, udata->parent, udata->sblk_idx))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array super block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for extensible array super block") /* Set the extensible array super block's address */ sblock->addr = udata->sblk_addr; /* Magic number */ if (HDmemcmp(image, H5EA_SBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC) != 0) - H5E_THROW(H5E_BADVALUE, "wrong extensible array super block signature") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, NULL, "wrong extensible array super block signature") image += H5_SIZEOF_MAGIC; /* Version */ if (*image++ != H5EA_SBLOCK_VERSION) - H5E_THROW(H5E_VERSION, "wrong extensible array super block version") + HGOTO_ERROR(H5E_EARRAY, H5E_VERSION, NULL, "wrong extensible array super block version") /* Extensible array type */ if (*image++ != (uint8_t)udata->hdr->cparam.cls->id) - H5E_THROW(H5E_BADTYPE, "incorrect extensible array class") + HGOTO_ERROR(H5E_EARRAY, H5E_BADTYPE, NULL, "incorrect extensible 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 extensible array header address") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, NULL, "wrong extensible array header address") /* Offset of block within the array's address space */ UINT64DECODE_VAR(image, sblock->block_off, udata->hdr->arr_off_size); @@ -1159,14 +1205,14 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Set return value */ ret_value = sblock; - CATCH - +done: /* Release resources */ if (!ret_value) if (sblock && H5EA__sblock_dest(sblock) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array super block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array super block") -END_FUNC(STATIC) /* end H5EA__cache_sblock_deserialize() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_sblock_deserialize() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_sblock_image_len @@ -1180,12 +1226,13 @@ END_FUNC(STATIC) /* end H5EA__cache_sblock_deserialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5EA__cache_sblock_image_len(const void *_thing, size_t *image_len)) - - /* Local variables */ +static herr_t +H5EA__cache_sblock_image_len(const void *_thing, size_t *image_len) +{ const H5EA_sblock_t *sblock = (const H5EA_sblock_t *)_thing; /* Pointer to the object */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(sblock); HDassert(image_len); @@ -1193,7 +1240,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Set the image length size */ *image_len = sblock->size; -END_FUNC(STATIC) /* end H5EA__cache_sblock_image_len() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__cache_sblock_image_len() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_sblock_serialize @@ -1207,16 +1255,16 @@ END_FUNC(STATIC) /* end H5EA__cache_sblock_image_len() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5EA__cache_sblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, - void *_thing)) - - /* Local variables */ +static herr_t +H5EA__cache_sblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, void *_thing) +{ H5EA_sblock_t *sblock = (H5EA_sblock_t *)_thing; /* Pointer to the object to serialize */ uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t metadata_chksum; /* Computed metadata checksum value */ size_t u; /* Local index variable */ + FUNC_ENTER_STATIC_NOERR + /* check arguments */ HDassert(f); HDassert(image); @@ -1265,7 +1313,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Sanity check */ HDassert((size_t)(image - (uint8_t *)_image) == len); -END_FUNC(STATIC) /* end H5EA__cache_sblock_serialize() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__cache_sblock_serialize() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_sblock_notify @@ -1279,11 +1328,13 @@ END_FUNC(STATIC) /* end H5EA__cache_sblock_serialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, - H5EA__cache_sblock_notify(H5AC_notify_action_t action, void *_thing)) +static herr_t +H5EA__cache_sblock_notify(H5AC_notify_action_t action, void *_thing) +{ + H5EA_sblock_t *sblock = (H5EA_sblock_t *)_thing; /* Pointer to the object */ + herr_t ret_value = SUCCEED; - /* Local variables */ - H5EA_sblock_t *sblock = (H5EA_sblock_t *)_thing; /* Pointer to the object */ + FUNC_ENTER_STATIC /* Sanity check */ HDassert(sblock); @@ -1294,8 +1345,8 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, case H5AC_NOTIFY_ACTION_AFTER_LOAD: /* Create flush dependency on index block */ if (H5EA__create_flush_depend((H5AC_info_t *)sblock->parent, (H5AC_info_t *)sblock) < 0) - H5E_THROW( - H5E_CANTDEPEND, + HGOTO_ERROR( + H5E_EARRAY, H5E_CANTDEPEND, FAIL, "unable to create flush dependency between super block and index block, address = %llu", (unsigned long long)sblock->addr) break; @@ -1304,8 +1355,8 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Destroy flush dependency on extensible array header, if set */ if (sblock->has_hdr_depend) { if (H5EA__destroy_flush_depend((H5AC_info_t *)sblock->hdr, (H5AC_info_t *)sblock) < 0) - H5E_THROW( - H5E_CANTUNDEPEND, + HGOTO_ERROR( + H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency between super block and header, address = %llu", (unsigned long long)sblock->addr) sblock->has_hdr_depend = FALSE; @@ -1315,16 +1366,16 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, case H5AC_NOTIFY_ACTION_BEFORE_EVICT: /* Destroy flush dependency on index block */ if (H5EA__destroy_flush_depend((H5AC_info_t *)sblock->parent, (H5AC_info_t *)sblock) < 0) - H5E_THROW( - H5E_CANTUNDEPEND, + HGOTO_ERROR( + H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency between super block and index block, address = %llu", (unsigned long long)sblock->addr) /* Destroy flush dependency on extensible array header, if set */ if (sblock->has_hdr_depend) { if (H5EA__destroy_flush_depend((H5AC_info_t *)sblock->hdr, (H5AC_info_t *)sblock) < 0) - H5E_THROW( - H5E_CANTUNDEPEND, + HGOTO_ERROR( + H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency between super block and header, address = %llu", (unsigned long long)sblock->addr) sblock->has_hdr_depend = FALSE; @@ -1333,8 +1384,9 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Detach from 'top' proxy for extensible array */ if (sblock->top_proxy) { if (H5AC_proxy_entry_remove_child(sblock->top_proxy, sblock) < 0) - H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between super block and " - "extensible array 'top' proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between super block and " + "extensible array 'top' proxy") sblock->top_proxy = NULL; } /* end if */ break; @@ -1350,15 +1402,15 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, default: #ifdef NDEBUG - H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, FAIL, "unknown action from metadata cache") #else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); #endif /* NDEBUG */ } /* end switch */ - CATCH - -END_FUNC(STATIC) /* end H5EA__cache_sblock_notify() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_sblock_notify() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_sblock_free_icr @@ -1373,18 +1425,23 @@ END_FUNC(STATIC) /* end H5EA__cache_sblock_notify() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5EA__cache_sblock_free_icr(void *thing)) +static herr_t +H5EA__cache_sblock_free_icr(void *thing) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC /* Check arguments */ HDassert(thing); /* Release the extensible array super block */ if (H5EA__sblock_dest((H5EA_sblock_t *)thing) < 0) - H5E_THROW(H5E_CANTFREE, "can't free extensible array super block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTFREE, FAIL, "can't free extensible array super block") - CATCH - -END_FUNC(STATIC) /* end H5EA__cache_sblock_free_icr() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_sblock_free_icr() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_dblock_get_initial_load_size @@ -1398,13 +1455,14 @@ END_FUNC(STATIC) /* end H5EA__cache_sblock_free_icr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5EA__cache_dblock_get_initial_load_size(void *_udata, size_t *image_len)) - - /* Local variables */ +static herr_t +H5EA__cache_dblock_get_initial_load_size(void *_udata, size_t *image_len) +{ H5EA_dblock_cache_ud_t *udata = (H5EA_dblock_cache_ud_t *)_udata; /* User data */ H5EA_dblock_t dblock; /* Fake data block for computing size */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(udata); HDassert(udata->hdr); @@ -1439,7 +1497,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, else *image_len = H5EA_DBLOCK_PREFIX_SIZE(&dblock); -END_FUNC(STATIC) /* end H5EA__cache_dblock_get_initial_load_size() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__cache_dblock_get_initial_load_size() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_dblock_verify_chksum @@ -1454,13 +1513,15 @@ END_FUNC(STATIC) /* end H5EA__cache_dblock_get_initial_load_size() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, - H5EA__cache_dblock_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata)) - - /* Local variables */ +static htri_t +H5EA__cache_dblock_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata) +{ const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ uint32_t computed_chksum; /* Computed metadata checksum value */ + htri_t ret_value = TRUE; + + FUNC_ENTER_STATIC_NOERR /* Check arguments */ HDassert(image); @@ -1471,7 +1532,8 @@ BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, if (stored_chksum != computed_chksum) ret_value = FALSE; -END_FUNC(STATIC) /* end H5EA__cache_sblock_verify_chksum() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_sblock_verify_chksum() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_dblock_deserialize @@ -1486,16 +1548,18 @@ END_FUNC(STATIC) /* end H5EA__cache_sblock_verify_chksum() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, - H5EA__cache_dblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, - hbool_t H5_ATTR_UNUSED *dirty)) - - /* Local variables */ +static void * +H5EA__cache_dblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, + hbool_t H5_ATTR_UNUSED *dirty) +{ H5EA_dblock_t * dblock = NULL; /* Data block info */ H5EA_dblock_cache_ud_t *udata = (H5EA_dblock_cache_ud_t *)_udata; /* User data */ const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ haddr_t arr_addr; /* Address of array header in the file */ + void * ret_value = NULL; + + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(udata); @@ -1506,7 +1570,8 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Allocate the extensible array data block */ if (NULL == (dblock = H5EA__dblock_alloc(udata->hdr, udata->parent, udata->nelmts))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array data block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for extensible array data block") HDassert(((!dblock->npages) && (len == H5EA_DBLOCK_SIZE(dblock))) || (len == H5EA_DBLOCK_PREFIX_SIZE(dblock))); @@ -1516,21 +1581,21 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Magic number */ if (HDmemcmp(image, H5EA_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC) != 0) - H5E_THROW(H5E_BADVALUE, "wrong extensible array data block signature") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, NULL, "wrong extensible array data block signature") image += H5_SIZEOF_MAGIC; /* Version */ if (*image++ != H5EA_DBLOCK_VERSION) - H5E_THROW(H5E_VERSION, "wrong extensible array data block version") + HGOTO_ERROR(H5E_EARRAY, H5E_VERSION, NULL, "wrong extensible array data block version") /* Extensible array type */ if (*image++ != (uint8_t)udata->hdr->cparam.cls->id) - H5E_THROW(H5E_BADTYPE, "incorrect extensible array class") + HGOTO_ERROR(H5E_EARRAY, H5E_BADTYPE, NULL, "incorrect extensible 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 extensible array header address") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, NULL, "wrong extensible array header address") /* Offset of block within the array's address space */ UINT64DECODE_VAR(image, dblock->block_off, udata->hdr->arr_off_size); @@ -1542,7 +1607,7 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Decode elements in data block */ /* Convert from raw elements on disk into native elements in memory */ if ((udata->hdr->cparam.cls->decode)(image, dblock->elmts, udata->nelmts, udata->hdr->cb_ctx) < 0) - H5E_THROW(H5E_CANTDECODE, "can't decode extensible array data elements") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDECODE, NULL, "can't decode extensible array data elements") image += (udata->nelmts * udata->hdr->cparam.raw_elmt_size); } /* end if */ @@ -1565,14 +1630,15 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Set return value */ ret_value = dblock; - CATCH +done: /* Release resources */ if (!ret_value) if (dblock && H5EA__dblock_dest(dblock) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array data block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array data block") -END_FUNC(STATIC) /* end H5EA__cache_dblock_deserialize() */ + FUNC_LEAVE_NOAPI(ret_value); +} /* end H5EA__cache_dblock_deserialize() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_dblock_image_len @@ -1586,12 +1652,13 @@ END_FUNC(STATIC) /* end H5EA__cache_dblock_deserialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5EA__cache_dblock_image_len(const void *_thing, size_t *image_len)) - - /* Local variables */ +static herr_t +H5EA__cache_dblock_image_len(const void *_thing, size_t *image_len) +{ const H5EA_dblock_t *dblock = (const H5EA_dblock_t *)_thing; /* Pointer to the object */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(dblock); HDassert(image_len); @@ -1602,7 +1669,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, else *image_len = (size_t)H5EA_DBLOCK_PREFIX_SIZE(dblock); -END_FUNC(STATIC) /* end H5EA__cache_dblock_image_len() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__cache_dblock_image_len() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_dblock_serialize @@ -1616,14 +1684,15 @@ END_FUNC(STATIC) /* end H5EA__cache_dblock_image_len() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, - H5EA__cache_dblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, - void *_thing)) - - /* Local variables */ +static herr_t +H5EA__cache_dblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, void *_thing) +{ H5EA_dblock_t *dblock = (H5EA_dblock_t *)_thing; /* Pointer to the object to serialize */ uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t metadata_chksum; /* Computed metadata checksum value */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC /* check arguments */ HDassert(f); @@ -1656,7 +1725,7 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Convert from native elements in memory into raw elements on disk */ if ((dblock->hdr->cparam.cls->encode)(image, dblock->elmts, dblock->nelmts, dblock->hdr->cb_ctx) < 0) - H5E_THROW(H5E_CANTENCODE, "can't encode extensible array data elements") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTENCODE, FAIL, "can't encode extensible array data elements") image += (dblock->nelmts * dblock->hdr->cparam.raw_elmt_size); } /* end if */ @@ -1669,9 +1738,9 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Sanity check */ HDassert((size_t)(image - (uint8_t *)_image) == len); - CATCH - -END_FUNC(STATIC) /* end H5EA__cache_dblock_serialize() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_dblock_serialize() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_dblock_notify @@ -1685,11 +1754,13 @@ END_FUNC(STATIC) /* end H5EA__cache_dblock_serialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, - H5EA__cache_dblock_notify(H5AC_notify_action_t action, void *_thing)) +static herr_t +H5EA__cache_dblock_notify(H5AC_notify_action_t action, void *_thing) +{ + H5EA_dblock_t *dblock = (H5EA_dblock_t *)_thing; /* Pointer to the object */ + herr_t ret_value = SUCCEED; - /* Local variables */ - H5EA_dblock_t *dblock = (H5EA_dblock_t *)_thing; /* Pointer to the object */ + FUNC_ENTER_STATIC /* Check arguments */ HDassert(dblock); @@ -1700,17 +1771,17 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, case H5AC_NOTIFY_ACTION_AFTER_LOAD: /* Create flush dependency on parent */ if (H5EA__create_flush_depend((H5AC_info_t *)dblock->parent, (H5AC_info_t *)dblock) < 0) - H5E_THROW(H5E_CANTDEPEND, - "unable to create flush dependency between data block and parent, address = %llu", - (unsigned long long)dblock->addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDEPEND, FAIL, + "unable to create flush dependency between data block and parent, address = %llu", + (unsigned long long)dblock->addr) break; case H5AC_NOTIFY_ACTION_AFTER_FLUSH: /* Destroy flush dependency on extensible array header, if set */ if (dblock->has_hdr_depend) { if (H5EA__destroy_flush_depend((H5AC_info_t *)dblock->hdr, (H5AC_info_t *)dblock) < 0) - H5E_THROW( - H5E_CANTUNDEPEND, + HGOTO_ERROR( + H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency between direct block and header, address = %llu", (unsigned long long)dblock->addr) dblock->has_hdr_depend = FALSE; @@ -1720,15 +1791,16 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, case H5AC_NOTIFY_ACTION_BEFORE_EVICT: /* Destroy flush dependency on parent */ if (H5EA__destroy_flush_depend((H5AC_info_t *)dblock->parent, (H5AC_info_t *)dblock) < 0) - H5E_THROW(H5E_CANTUNDEPEND, - "unable to destroy flush dependency between data block and parent, address = %llu", - (unsigned long long)dblock->addr) + HGOTO_ERROR( + H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between data block and parent, address = %llu", + (unsigned long long)dblock->addr) /* Destroy flush dependency on extensible array header, if set */ if (dblock->has_hdr_depend) { if (H5EA__destroy_flush_depend((H5AC_info_t *)dblock->hdr, (H5AC_info_t *)dblock) < 0) - H5E_THROW( - H5E_CANTUNDEPEND, + HGOTO_ERROR( + H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency between data block and header, address = %llu", (unsigned long long)dblock->addr) dblock->has_hdr_depend = FALSE; @@ -1737,8 +1809,9 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Detach from 'top' proxy for extensible array */ if (dblock->top_proxy) { if (H5AC_proxy_entry_remove_child(dblock->top_proxy, dblock) < 0) - H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between data block and " - "extensible array 'top' proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between data block and " + "extensible array 'top' proxy") dblock->top_proxy = NULL; } /* end if */ break; @@ -1754,15 +1827,15 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, default: #ifdef NDEBUG - H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, FAIL, "unknown action from metadata cache") #else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); #endif /* NDEBUG */ } /* end switch */ - CATCH - -END_FUNC(STATIC) /* end H5EA__cache_dblock_notify() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_dblock_notify() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_dblock_free_icr @@ -1777,18 +1850,23 @@ END_FUNC(STATIC) /* end H5EA__cache_dblock_notify() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5EA__cache_dblock_free_icr(void *thing)) +static herr_t +H5EA__cache_dblock_free_icr(void *thing) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC /* Check arguments */ HDassert(thing); /* Release the extensible array data block */ if (H5EA__dblock_dest((H5EA_dblock_t *)thing) < 0) - H5E_THROW(H5E_CANTFREE, "can't free extensible array data block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTFREE, FAIL, "can't free extensible array data block") - CATCH - -END_FUNC(STATIC) /* end H5EA__cache_dblock_free_icr() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_dblock_free_icr() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_dblock_fsf_size @@ -1819,12 +1897,13 @@ END_FUNC(STATIC) /* end H5EA__cache_dblock_free_icr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5EA__cache_dblock_fsf_size(const void *_thing, hsize_t *fsf_size)) - - /* Local variables */ +static herr_t +H5EA__cache_dblock_fsf_size(const void *_thing, hsize_t *fsf_size) +{ const H5EA_dblock_t *dblock = (const H5EA_dblock_t *)_thing; /* Pointer to the object */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(dblock); HDassert(dblock->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); @@ -1833,7 +1912,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, *fsf_size = dblock->size; -END_FUNC(STATIC) /* end H5EA__cache_dblock_fsf_size() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__cache_dblock_fsf_size() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_dblk_page_get_initial_load_size @@ -1847,12 +1927,13 @@ END_FUNC(STATIC) /* end H5EA__cache_dblock_fsf_size() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5EA__cache_dblk_page_get_initial_load_size(void *_udata, size_t *image_len)) - - /* Local variables */ +static herr_t +H5EA__cache_dblk_page_get_initial_load_size(void *_udata, size_t *image_len) +{ H5EA_dblk_page_cache_ud_t *udata = (H5EA_dblk_page_cache_ud_t *)_udata; /* User data */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(udata); HDassert(udata->hdr); @@ -1861,7 +1942,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Set the image length size */ *image_len = (size_t)H5EA_DBLK_PAGE_SIZE(udata->hdr); -END_FUNC(STATIC) /* end H5EA__cache_dblk_page_get_initial_load_size() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__cache_dblk_page_get_initial_load_size() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_dblk_page_verify_chksum @@ -1876,13 +1958,15 @@ END_FUNC(STATIC) /* end H5EA__cache_dblk_page_get_initial_load_size() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, - H5EA__cache_dblk_page_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata)) - - /* Local variables */ +static htri_t +H5EA__cache_dblk_page_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata) +{ const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ uint32_t computed_chksum; /* Computed metadata checksum value */ + htri_t ret_value = TRUE; + + FUNC_ENTER_STATIC_NOERR /* Check arguments */ HDassert(image); @@ -1893,7 +1977,8 @@ BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, if (stored_chksum != computed_chksum) ret_value = FALSE; -END_FUNC(STATIC) /* end H5EA__cache_dblk_page_verify_chksum() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_dblk_page_verify_chksum() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_dblk_page_deserialize @@ -1908,16 +1993,17 @@ END_FUNC(STATIC) /* end H5EA__cache_dblk_page_verify_chksum() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, - H5EA__cache_dblk_page_deserialize(const void *_image, size_t len, void *_udata, - hbool_t H5_ATTR_UNUSED *dirty)) - - /* Local variables */ +static void * +H5EA__cache_dblk_page_deserialize(const void *_image, size_t len, void *_udata, hbool_t H5_ATTR_UNUSED *dirty) +{ H5EA_dblk_page_t * dblk_page = NULL; /* Data block page info */ H5EA_dblk_page_cache_ud_t *udata = (H5EA_dblk_page_cache_ud_t *)_udata; /* User data for loading data block page */ const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ + void * ret_value = NULL; + + FUNC_ENTER_STATIC /* Sanity check */ HDassert(udata); @@ -1927,7 +2013,8 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Allocate the extensible array data block page */ if (NULL == (dblk_page = H5EA__dblk_page_alloc(udata->hdr, udata->parent))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array data block page") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for extensible array data block page") /* Set the extensible array data block page's information */ dblk_page->addr = udata->dblk_page_addr; @@ -1938,7 +2025,7 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Convert from raw elements on disk into native elements in memory */ if ((udata->hdr->cparam.cls->decode)(image, dblk_page->elmts, udata->hdr->dblk_page_nelmts, udata->hdr->cb_ctx) < 0) - H5E_THROW(H5E_CANTDECODE, "can't decode extensible array data elements") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDECODE, NULL, "can't decode extensible array data elements") image += (udata->hdr->dblk_page_nelmts * udata->hdr->cparam.raw_elmt_size); /* Sanity check */ @@ -1959,14 +2046,13 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Set return value */ ret_value = dblk_page; - CATCH - +done: /* Release resources */ if (!ret_value) if (dblk_page && H5EA__dblk_page_dest(dblk_page) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array data block page") - -END_FUNC(STATIC) /* end H5EA__cache_dblk_page_deserialize() */ + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array data block page") + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_dblk_page_deserialize() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_dblk_page_image_len @@ -1980,12 +2066,13 @@ END_FUNC(STATIC) /* end H5EA__cache_dblk_page_deserialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5EA__cache_dblk_page_image_len(const void *_thing, size_t *image_len)) - - /* Local variables */ +static herr_t +H5EA__cache_dblk_page_image_len(const void *_thing, size_t *image_len) +{ const H5EA_dblk_page_t *dblk_page = (const H5EA_dblk_page_t *)_thing; /* Pointer to the object */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(dblk_page); HDassert(image_len); @@ -1993,7 +2080,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Set the image length size */ *image_len = dblk_page->size; -END_FUNC(STATIC) /* end H5EA__cache_dblk_page_image_len() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__cache_dblk_page_image_len() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_dblk_page_serialize @@ -2007,14 +2095,16 @@ END_FUNC(STATIC) /* end H5EA__cache_dblk_page_image_len() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, - H5EA__cache_dblk_page_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *_image, - size_t H5_ATTR_UNUSED len, void *_thing)) - - /* Local variables */ +static herr_t +H5EA__cache_dblk_page_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *_image, size_t H5_ATTR_UNUSED len, + void *_thing) +{ H5EA_dblk_page_t *dblk_page = (H5EA_dblk_page_t *)_thing; /* Pointer to the object to serialize */ uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t metadata_chksum; /* Computed metadata checksum value */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC /* Check arguments */ HDassert(f); @@ -2029,7 +2119,7 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Convert from native elements in memory into raw elements on disk */ if ((dblk_page->hdr->cparam.cls->encode)(image, dblk_page->elmts, dblk_page->hdr->dblk_page_nelmts, dblk_page->hdr->cb_ctx) < 0) - H5E_THROW(H5E_CANTENCODE, "can't encode extensible array data elements") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTENCODE, FAIL, "can't encode extensible array data elements") image += (dblk_page->hdr->dblk_page_nelmts * dblk_page->hdr->cparam.raw_elmt_size); /* Compute metadata checksum */ @@ -2041,9 +2131,9 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Sanity check */ HDassert((size_t)(image - (uint8_t *)_image) == len); - CATCH - -END_FUNC(STATIC) /* end H5EA__cache_dblk_page_serialize() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_dblk_page_serialize() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_dblk_page_notify @@ -2057,11 +2147,13 @@ END_FUNC(STATIC) /* end H5EA__cache_dblk_page_serialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, - H5EA__cache_dblk_page_notify(H5AC_notify_action_t action, void *_thing)) - - /* Local variables */ +static herr_t +H5EA__cache_dblk_page_notify(H5AC_notify_action_t action, void *_thing) +{ H5EA_dblk_page_t *dblk_page = (H5EA_dblk_page_t *)_thing; /* Pointer to the object */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC /* Sanity check */ HDassert(dblk_page); @@ -2072,8 +2164,8 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, case H5AC_NOTIFY_ACTION_AFTER_LOAD: /* Create flush dependency on parent */ if (H5EA__create_flush_depend((H5AC_info_t *)dblk_page->parent, (H5AC_info_t *)dblk_page) < 0) - H5E_THROW( - H5E_CANTDEPEND, + HGOTO_ERROR( + H5E_EARRAY, H5E_CANTDEPEND, FAIL, "unable to create flush dependency between data block page and parent, address = %llu", (unsigned long long)dblk_page->addr) break; @@ -2082,10 +2174,10 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Destroy flush dependency on extensible array header, if set */ if (dblk_page->has_hdr_depend) { if (H5EA__destroy_flush_depend((H5AC_info_t *)dblk_page->hdr, (H5AC_info_t *)dblk_page) < 0) - H5E_THROW(H5E_CANTUNDEPEND, - "unable to destroy flush dependency between data block page and header, " - "address = %llu", - (unsigned long long)dblk_page->addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between data block page and header, " + "address = %llu", + (unsigned long long)dblk_page->addr) dblk_page->has_hdr_depend = FALSE; } /* end if */ break; @@ -2093,27 +2185,27 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, case H5AC_NOTIFY_ACTION_BEFORE_EVICT: /* Destroy flush dependency on parent */ if (H5EA__destroy_flush_depend((H5AC_info_t *)dblk_page->parent, (H5AC_info_t *)dblk_page) < 0) - H5E_THROW( - H5E_CANTUNDEPEND, + HGOTO_ERROR( + H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency between data block page and parent, address = %llu", (unsigned long long)dblk_page->addr) /* Destroy flush dependency on extensible array header, if set */ if (dblk_page->has_hdr_depend) { if (H5EA__destroy_flush_depend((H5AC_info_t *)dblk_page->hdr, (H5AC_info_t *)dblk_page) < 0) - H5E_THROW(H5E_CANTUNDEPEND, - "unable to destroy flush dependency between data block page and header, " - "address = %llu", - (unsigned long long)dblk_page->addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between data block page and header, " + "address = %llu", + (unsigned long long)dblk_page->addr) dblk_page->has_hdr_depend = FALSE; } /* end if */ /* Detach from 'top' proxy for extensible array */ if (dblk_page->top_proxy) { if (H5AC_proxy_entry_remove_child(dblk_page->top_proxy, dblk_page) < 0) - H5E_THROW(H5E_CANTUNDEPEND, - "unable to destroy flush dependency between data block page and " - "extensible array 'top' proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between data block page and " + "extensible array 'top' proxy") dblk_page->top_proxy = NULL; } /* end if */ break; @@ -2129,15 +2221,15 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, default: #ifdef NDEBUG - H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, FAIL, "unknown action from metadata cache") #else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); #endif /* NDEBUG */ } /* end switch */ - CATCH - -END_FUNC(STATIC) /* end H5EA__cache_dblk_page_notify() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_dblk_page_notify() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_dblk_page_free_icr @@ -2152,15 +2244,20 @@ END_FUNC(STATIC) /* end H5EA__cache_dblk_page_notify() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5EA__cache_dblk_page_free_icr(void *thing)) +static herr_t +H5EA__cache_dblk_page_free_icr(void *thing) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC /* Check arguments */ HDassert(thing); /* Release the extensible array data block page */ if (H5EA__dblk_page_dest((H5EA_dblk_page_t *)thing) < 0) - H5E_THROW(H5E_CANTFREE, "can't free extensible array data block page") - - CATCH + HGOTO_ERROR(H5E_EARRAY, H5E_CANTFREE, FAIL, "can't free extensible array data block page") -END_FUNC(STATIC) /* end H5EA__cache_dblk_page_free_icr() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_dblk_page_free_icr() */ diff --git a/src/H5EAdbg.c b/src/H5EAdbg.c index 72d2f38..b0e564c 100644 --- a/src/H5EAdbg.c +++ b/src/H5EAdbg.c @@ -79,13 +79,16 @@ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5EA__hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, - const H5EA_class_t *cls, haddr_t obj_addr)) - +herr_t +H5EA__hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, const H5EA_class_t *cls, + haddr_t obj_addr) +{ /* Local variables */ - H5EA_hdr_t *hdr = NULL; /* Shared extensible array header */ - void * dbg_ctx = NULL; /* Extensible array debugging context */ + H5EA_hdr_t *hdr = NULL; /* Shared extensible array header */ + void * dbg_ctx = NULL; /* Extensible array debugging context */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(f); @@ -100,11 +103,11 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, if (cls->crt_dbg_ctx) /* Create debugging context */ if (NULL == (dbg_ctx = cls->crt_dbg_ctx(f, obj_addr))) - H5E_THROW(H5E_CANTGET, "unable to create fixed array debugging context") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTGET, FAIL, "unable to create fixed array debugging context") /* Load the extensible array header */ if (NULL == (hdr = H5EA__hdr_protect(f, addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to load extensible array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, "unable to load extensible array header") /* Print opening message */ HDfprintf(stream, "%*sExtensible Array Header...\n", indent, ""); @@ -137,13 +140,14 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, "Index Block Address:", hdr->idx_blk_addr); - CATCH +done: if (dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) - H5E_THROW(H5E_CANTRELEASE, "unable to release extensible array debugging context") + HDONE_ERROR(H5E_EARRAY, H5E_CANTRELEASE, FAIL, "unable to release extensible array debugging context") if (hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array header") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array header") -END_FUNC(PKG) /* end H5EA__hdr_debug() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__hdr_debug() */ /*------------------------------------------------------------------------- * Function: H5EA__iblock_debug @@ -157,14 +161,17 @@ END_FUNC(PKG) /* end H5EA__hdr_debug() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5EA__iblock_debug(H5F_t *f, haddr_t H5_ATTR_UNUSED addr, FILE *stream, int indent, int fwidth, - const H5EA_class_t *cls, haddr_t hdr_addr, haddr_t obj_addr)) - +herr_t +H5EA__iblock_debug(H5F_t *f, haddr_t H5_ATTR_UNUSED addr, FILE *stream, int indent, int fwidth, + const H5EA_class_t *cls, haddr_t hdr_addr, haddr_t obj_addr) +{ /* Local variables */ - H5EA_hdr_t * hdr = NULL; /* Shared extensible array header */ - H5EA_iblock_t *iblock = NULL; /* Extensible array index block */ - void * dbg_ctx = NULL; /* Extensible array context */ + H5EA_hdr_t * hdr = NULL; /* Shared extensible array header */ + H5EA_iblock_t *iblock = NULL; /* Extensible array index block */ + void * dbg_ctx = NULL; /* Extensible array context */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(f); @@ -180,19 +187,20 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, if (cls->crt_dbg_ctx) /* Create debugging context */ if (NULL == (dbg_ctx = cls->crt_dbg_ctx(f, obj_addr))) - H5E_THROW(H5E_CANTGET, "unable to create extensible array debugging context") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTGET, FAIL, "unable to create extensible array debugging context") /* Load the extensible array header */ if (NULL == (hdr = H5EA__hdr_protect(f, hdr_addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to load extensible array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, "unable to load extensible array header") /* Sanity check */ HDassert(H5F_addr_eq(hdr->idx_blk_addr, addr)); /* Protect index block */ if (NULL == (iblock = H5EA__iblock_protect(hdr, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array index block, address = %llu", - (unsigned long long)hdr->idx_blk_addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect extensible array index block, address = %llu", + (unsigned long long)hdr->idx_blk_addr) /* Print opening message */ HDfprintf(stream, "%*sExtensible Array Index Block...\n", indent, ""); @@ -216,7 +224,7 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, if ((hdr->cparam.cls->debug)(stream, (indent + 3), MAX(0, (fwidth - 3)), (hsize_t)u, ((uint8_t *)iblock->elmts) + (hdr->cparam.cls->nat_elmt_size * u)) < 0) - H5E_THROW(H5E_CANTGET, "can't get element for debugging") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTGET, FAIL, "can't get element for debugging") } /* end for */ } /* end if */ @@ -250,15 +258,16 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, } /* end for */ } /* end if */ - CATCH +done: if (dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) - H5E_THROW(H5E_CANTRELEASE, "unable to release extensible array debugging context") + HDONE_ERROR(H5E_EARRAY, H5E_CANTRELEASE, FAIL, "unable to release extensible array debugging context") if (iblock && H5EA__iblock_unprotect(iblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array index block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array index block") if (hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array header") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array header") -END_FUNC(PKG) /* end H5EA__iblock_debug() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__iblock_debug() */ /*------------------------------------------------------------------------- * Function: H5EA__sblock_debug @@ -272,14 +281,17 @@ END_FUNC(PKG) /* end H5EA__iblock_debug() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5EA__sblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, - const H5EA_class_t *cls, haddr_t hdr_addr, unsigned sblk_idx, haddr_t obj_addr)) - +herr_t +H5EA__sblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, const H5EA_class_t *cls, + haddr_t hdr_addr, unsigned sblk_idx, haddr_t obj_addr) +{ /* Local variables */ - H5EA_hdr_t * hdr = NULL; /* Shared extensible array header */ - H5EA_sblock_t *sblock = NULL; /* Extensible array super block */ - void * dbg_ctx = NULL; /* Extensible array context */ + H5EA_hdr_t * hdr = NULL; /* Shared extensible array header */ + H5EA_sblock_t *sblock = NULL; /* Extensible array super block */ + void * dbg_ctx = NULL; /* Extensible array context */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(f); @@ -295,18 +307,19 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, if (cls->crt_dbg_ctx) /* Create debugging context */ if (NULL == (dbg_ctx = cls->crt_dbg_ctx(f, obj_addr))) - H5E_THROW(H5E_CANTGET, "unable to create extensible array debugging context") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTGET, FAIL, "unable to create extensible array debugging context") /* Load the extensible array header */ if (NULL == (hdr = H5EA__hdr_protect(f, hdr_addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to load extensible array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, "unable to load extensible array header") /* Protect super block */ /* (Note: setting parent of super block to 'hdr' for this operation should be OK -QAK) */ if (NULL == (sblock = H5EA__sblock_protect(hdr, (H5EA_iblock_t *)hdr, addr, sblk_idx, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array super block, address = %llu", - (unsigned long long)addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect extensible array super block, address = %llu", + (unsigned long long)addr) /* Print opening message */ HDfprintf(stream, "%*sExtensible Array Super Block...\n", indent, ""); @@ -334,15 +347,16 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, } /* end for */ } /* end if */ - CATCH +done: if (dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) - H5E_THROW(H5E_CANTRELEASE, "unable to release extensible array debugging context") + HDONE_ERROR(H5E_EARRAY, H5E_CANTRELEASE, FAIL, "unable to release extensible array debugging context") if (sblock && H5EA__sblock_unprotect(sblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array super block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array super block") if (hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array header") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array header") -END_FUNC(PKG) /* end H5EA__sblock_debug() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__sblock_debug() */ /*------------------------------------------------------------------------- * Function: H5EA__dblock_debug @@ -356,16 +370,18 @@ END_FUNC(PKG) /* end H5EA__sblock_debug() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5EA__dblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, - const H5EA_class_t *cls, haddr_t hdr_addr, size_t dblk_nelmts, - haddr_t obj_addr)) - +herr_t +H5EA__dblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, const H5EA_class_t *cls, + haddr_t hdr_addr, size_t dblk_nelmts, haddr_t obj_addr) +{ /* Local variables */ - H5EA_hdr_t * hdr = NULL; /* Shared extensible array header */ - H5EA_dblock_t *dblock = NULL; /* Extensible array data block */ - void * dbg_ctx = NULL; /* Extensible array context */ - size_t u; /* Local index variable */ + H5EA_hdr_t * hdr = NULL; /* Shared extensible array header */ + H5EA_dblock_t *dblock = NULL; /* Extensible array data block */ + void * dbg_ctx = NULL; /* Extensible array context */ + size_t u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(f); @@ -382,17 +398,17 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, if (cls->crt_dbg_ctx) /* Create debugging context */ if (NULL == (dbg_ctx = cls->crt_dbg_ctx(f, obj_addr))) - H5E_THROW(H5E_CANTGET, "unable to create extensible array debugging context") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTGET, FAIL, "unable to create extensible array debugging context") /* Load the extensible array header */ if (NULL == (hdr = H5EA__hdr_protect(f, hdr_addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to load extensible array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, "unable to load extensible array header") /* Protect data block */ /* (Note: setting parent of data block to 'hdr' for this operation should be OK -QAK) */ if (NULL == (dblock = H5EA__dblock_protect(hdr, hdr, addr, dblk_nelmts, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array data block, address = %" PRIuHADDR, - addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect extensible array data block, address = %" PRIuHADDR, addr) /* Print opening message */ HDfprintf(stream, "%*sExtensible Array data Block...\n", indent, ""); @@ -407,15 +423,16 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, /* 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") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTGET, FAIL, "can't get element for debugging") } /* end for */ - CATCH +done: if (dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) - H5E_THROW(H5E_CANTRELEASE, "unable to release extensible array debugging context") + HDONE_ERROR(H5E_EARRAY, H5E_CANTRELEASE, FAIL, "unable to release extensible array debugging context") if (dblock && H5EA__dblock_unprotect(dblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array data block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array data block") if (hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array header") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array header") -END_FUNC(PKG) /* end H5EA__dblock_debug() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__dblock_debug() */ diff --git a/src/H5EAdblkpage.c b/src/H5EAdblkpage.c index b42599c..c0a92f0 100644 --- a/src/H5EAdblkpage.c +++ b/src/H5EAdblkpage.c @@ -84,22 +84,25 @@ H5FL_DEFINE_STATIC(H5EA_dblk_page_t); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5EA_dblk_page_t *, NULL, NULL, - H5EA__dblk_page_alloc(H5EA_hdr_t *hdr, H5EA_sblock_t *parent)) - - /* Local variables */ +H5EA_dblk_page_t * +H5EA__dblk_page_alloc(H5EA_hdr_t *hdr, H5EA_sblock_t *parent) +{ H5EA_dblk_page_t *dblk_page = NULL; /* Extensible array data block page */ + H5EA_dblk_page_t *ret_value = NULL; + + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(hdr); /* Allocate memory for the data block */ if (NULL == (dblk_page = H5FL_CALLOC(H5EA_dblk_page_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array data block page") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for extensible array data block page") /* Share common array information */ if (H5EA__hdr_incr(hdr) < 0) - H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINC, NULL, "can't increment reference count on shared array header") dblk_page->hdr = hdr; /* Set non-zero internal fields */ @@ -107,17 +110,19 @@ BEGIN_FUNC(PKG, ERR, H5EA_dblk_page_t *, NULL, NULL, /* Allocate buffer for elements in data block page */ if (NULL == (dblk_page->elmts = H5EA__hdr_alloc_elmts(hdr, hdr->dblk_page_nelmts))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for data block page element buffer") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for data block page element buffer") /* Set the return value */ ret_value = dblk_page; - CATCH +done: if (!ret_value) if (dblk_page && H5EA__dblk_page_dest(dblk_page) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array data block page") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array data block page") -END_FUNC(PKG) /* end H5EA__dblk_page_alloc() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__dblk_page_alloc() */ /*------------------------------------------------------------------------- * Function: H5EA__dblk_page_create @@ -131,19 +136,22 @@ END_FUNC(PKG) /* end H5EA__dblk_page_alloc() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5EA__dblk_page_create(H5EA_hdr_t *hdr, H5EA_sblock_t *parent, haddr_t addr)) - - /* Local variables */ +herr_t +H5EA__dblk_page_create(H5EA_hdr_t *hdr, H5EA_sblock_t *parent, haddr_t addr) +{ H5EA_dblk_page_t *dblk_page = NULL; /* Extensible array data block page */ hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); /* Allocate the data block page */ if (NULL == (dblk_page = H5EA__dblk_page_alloc(hdr, parent))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array data block page") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, FAIL, + "memory allocation failed for extensible array data block page") /* Set info about data block page on disk */ dblk_page->addr = addr; @@ -151,34 +159,39 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, /* Clear any elements in data block page to fill value */ if ((hdr->cparam.cls->fill)(dblk_page->elmts, (size_t)hdr->dblk_page_nelmts) < 0) - H5E_THROW(H5E_CANTSET, "can't set extensible array data block page elements to class's fill value") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTSET, FAIL, + "can't set extensible array data block page elements to class's fill value") /* Cache the new extensible array data block page */ if (H5AC_insert_entry(hdr->f, H5AC_EARRAY_DBLK_PAGE, dblk_page->addr, dblk_page, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTINSERT, "can't add extensible array data block page to cache") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINSERT, FAIL, "can't add extensible array data block page to cache") inserted = TRUE; /* Add data block page as child of 'top' proxy */ if (hdr->top_proxy) { if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, dblk_page) < 0) - H5E_THROW(H5E_CANTSET, "unable to add extensible array entry as child of array proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTSET, FAIL, + "unable to add extensible array entry as child of array proxy") dblk_page->top_proxy = hdr->top_proxy; } /* end if */ - CATCH +done: if (ret_value < 0) if (dblk_page) { /* Remove from cache, if inserted */ if (inserted) if (H5AC_remove_entry(dblk_page) < 0) - H5E_THROW(H5E_CANTREMOVE, "unable to remove extensible array data block page from cache") + HDONE_ERROR(H5E_EARRAY, H5E_CANTREMOVE, FAIL, + "unable to remove extensible array data block page from cache") /* Destroy data block page */ if (H5EA__dblk_page_dest(dblk_page) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array data block page") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, FAIL, + "unable to destroy extensible array data block page") } /* end if */ -END_FUNC(PKG) /* end H5EA__dblk_page_create() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__dblk_page_create() */ /*------------------------------------------------------------------------- * Function: H5EA__dblk_page_protect @@ -193,13 +206,14 @@ END_FUNC(PKG) /* end H5EA__dblk_page_create() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5EA_dblk_page_t *, NULL, NULL, - H5EA__dblk_page_protect(H5EA_hdr_t *hdr, H5EA_sblock_t *parent, haddr_t dblk_page_addr, - unsigned flags)) - - /* Local variables */ +H5EA_dblk_page_t * +H5EA__dblk_page_protect(H5EA_hdr_t *hdr, H5EA_sblock_t *parent, haddr_t dblk_page_addr, unsigned flags) +{ H5EA_dblk_page_t * dblk_page = NULL; /* Extensible array data block page */ H5EA_dblk_page_cache_ud_t udata; /* Information needed for loading data block page */ + H5EA_dblk_page_t * ret_value = NULL; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -216,32 +230,34 @@ BEGIN_FUNC(PKG, ERR, H5EA_dblk_page_t *, NULL, NULL, /* Protect the data block page */ if (NULL == (dblk_page = (H5EA_dblk_page_t *)H5AC_protect(hdr->f, H5AC_EARRAY_DBLK_PAGE, dblk_page_addr, &udata, flags))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array data block page, address = %llu", - (unsigned long long)dblk_page_addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, NULL, + "unable to protect extensible array data block page, address = %llu", + (unsigned long long)dblk_page_addr) /* Create top proxy, if it doesn't exist */ if (hdr->top_proxy && NULL == dblk_page->top_proxy) { /* Add data block page as child of 'top' proxy */ if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, dblk_page) < 0) - H5E_THROW(H5E_CANTSET, "unable to add extensible array entry as child of array proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTSET, NULL, + "unable to add extensible array entry as child of array proxy") dblk_page->top_proxy = hdr->top_proxy; } /* end if */ /* Set return value */ ret_value = dblk_page; - CATCH +done: /* Clean up on error */ if (!ret_value) { /* Release the data block page, if it was protected */ if (dblk_page && H5AC_unprotect(hdr->f, H5AC_EARRAY_DBLK_PAGE, dblk_page->addr, dblk_page, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, - "unable to unprotect extensible array data block page, address = %llu", - (unsigned long long)dblk_page->addr) + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, NULL, + "unable to unprotect extensible array data block page, address = %llu", + (unsigned long long)dblk_page->addr) } /* end if */ - -END_FUNC(PKG) /* end H5EA__dblk_page_protect() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__dblk_page_protect() */ /*------------------------------------------------------------------------- * Function: H5EA__dblk_page_unprotect @@ -256,22 +272,25 @@ END_FUNC(PKG) /* end H5EA__dblk_page_protect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5EA__dblk_page_unprotect(H5EA_dblk_page_t *dblk_page, unsigned cache_flags)) +herr_t +H5EA__dblk_page_unprotect(H5EA_dblk_page_t *dblk_page, unsigned cache_flags) +{ + herr_t ret_value = SUCCEED; - /* Local variables */ + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(dblk_page); /* Unprotect the data block page */ if (H5AC_unprotect(dblk_page->hdr->f, H5AC_EARRAY_DBLK_PAGE, dblk_page->addr, dblk_page, cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect extensible array data block page, address = %llu", - (unsigned long long)dblk_page->addr) - - CATCH + HGOTO_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, + "unable to unprotect extensible array data block page, address = %llu", + (unsigned long long)dblk_page->addr) -END_FUNC(PKG) /* end H5EA__dblk_page_unprotect() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__dblk_page_unprotect() */ /*------------------------------------------------------------------------- * Function: H5EA__dblk_page_dest @@ -285,7 +304,12 @@ END_FUNC(PKG) /* end H5EA__dblk_page_unprotect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__dblk_page_dest(H5EA_dblk_page_t *dblk_page)) +herr_t +H5EA__dblk_page_dest(H5EA_dblk_page_t *dblk_page) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(dblk_page); @@ -297,13 +321,15 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__dblk_page_dest(H5EA_dblk_page_ if (dblk_page->elmts) { /* Free buffer for data block page elements */ if (H5EA__hdr_free_elmts(dblk_page->hdr, dblk_page->hdr->dblk_page_nelmts, dblk_page->elmts) < 0) - H5E_THROW(H5E_CANTFREE, "unable to free extensible array data block element buffer") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTFREE, FAIL, + "unable to free extensible array data block element buffer") dblk_page->elmts = NULL; } /* end if */ /* Decrement reference count on shared info */ if (H5EA__hdr_decr(dblk_page->hdr) < 0) - H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDEC, FAIL, + "can't decrement reference count on shared array header") dblk_page->hdr = NULL; } /* end if */ @@ -313,6 +339,6 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__dblk_page_dest(H5EA_dblk_page_ /* Free the data block page itself */ dblk_page = H5FL_FREE(H5EA_dblk_page_t, dblk_page); - CATCH - -END_FUNC(PKG) /* end H5EA__dblk_page_dest() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__dblk_page_dest() */ diff --git a/src/H5EAdblock.c b/src/H5EAdblock.c index 45696c7..f17aae3 100644 --- a/src/H5EAdblock.c +++ b/src/H5EAdblock.c @@ -85,11 +85,13 @@ H5FL_DEFINE_STATIC(H5EA_dblock_t); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5EA_dblock_t *, NULL, NULL, - H5EA__dblock_alloc(H5EA_hdr_t *hdr, void *parent, size_t nelmts)) +H5EA_dblock_t * +H5EA__dblock_alloc(H5EA_hdr_t *hdr, void *parent, size_t nelmts) +{ + H5EA_dblock_t *dblock = NULL; /* Extensible array data block */ + H5EA_dblock_t *ret_value = NULL; - /* Local variables */ - H5EA_dblock_t *dblock = NULL; /* Extensible array data block */ + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(hdr); @@ -98,11 +100,12 @@ BEGIN_FUNC(PKG, ERR, H5EA_dblock_t *, NULL, NULL, /* Allocate memory for the data block */ if (NULL == (dblock = H5FL_CALLOC(H5EA_dblock_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array data block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for extensible array data block") /* Share common array information */ if (H5EA__hdr_incr(hdr) < 0) - H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINC, NULL, "can't increment reference count on shared array header") dblock->hdr = hdr; /* Set non-zero internal fields */ @@ -118,18 +121,20 @@ BEGIN_FUNC(PKG, ERR, H5EA_dblock_t *, NULL, NULL, else { /* Allocate buffer for elements in data block */ if (NULL == (dblock->elmts = H5EA__hdr_alloc_elmts(hdr, nelmts))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for data block element buffer") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for data block element buffer") } /* end else */ /* Set the return value */ ret_value = dblock; - CATCH +done: if (!ret_value) if (dblock && H5EA__dblock_dest(dblock) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array data block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array data block") -END_FUNC(PKG) /* end H5EA__dblock_alloc() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__dblock_alloc() */ /*------------------------------------------------------------------------- * Function: H5EA__dblock_create @@ -143,14 +148,15 @@ END_FUNC(PKG) /* end H5EA__dblock_alloc() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, - H5EA__dblock_create(H5EA_hdr_t *hdr, void *parent, hbool_t *stats_changed, hsize_t dblk_off, - size_t nelmts)) +haddr_t +H5EA__dblock_create(H5EA_hdr_t *hdr, void *parent, hbool_t *stats_changed, hsize_t dblk_off, size_t nelmts) +{ + H5EA_dblock_t *dblock = NULL; /* Extensible array data block */ + haddr_t dblock_addr; /* Extensible array data block address */ + hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + haddr_t ret_value = HADDR_UNDEF; - /* Local variables */ - H5EA_dblock_t *dblock = NULL; /* Extensible array data block */ - haddr_t dblock_addr; /* Extensible array data block address */ - hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -159,7 +165,8 @@ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, /* Allocate the data block */ if (NULL == (dblock = H5EA__dblock_alloc(hdr, parent, nelmts))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array data block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, HADDR_UNDEF, + "memory allocation failed for extensible array data block") /* Set size of data block on disk */ dblock->size = H5EA_DBLOCK_SIZE(dblock); @@ -169,24 +176,27 @@ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, /* Allocate space for the data block on disk */ if (HADDR_UNDEF == (dblock_addr = H5MF_alloc(hdr->f, H5FD_MEM_EARRAY_DBLOCK, (hsize_t)dblock->size))) - H5E_THROW(H5E_CANTALLOC, "file allocation failed for extensible array data block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, HADDR_UNDEF, + "file allocation failed for extensible array data block") dblock->addr = dblock_addr; /* Don't initialize elements if paged */ if (!dblock->npages) /* Clear any elements in data block to fill value */ if ((hdr->cparam.cls->fill)(dblock->elmts, (size_t)dblock->nelmts) < 0) - H5E_THROW(H5E_CANTSET, "can't set extensible array data block elements to class's fill value") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTSET, HADDR_UNDEF, + "can't set extensible array data block elements to class's fill value") /* Cache the new extensible array data block */ if (H5AC_insert_entry(hdr->f, H5AC_EARRAY_DBLOCK, dblock_addr, dblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTINSERT, "can't add extensible array data block to cache") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINSERT, HADDR_UNDEF, "can't add extensible array data block to cache") inserted = TRUE; /* Add data block as child of 'top' proxy */ if (hdr->top_proxy) { if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, dblock) < 0) - H5E_THROW(H5E_CANTSET, "unable to add extensible array entry as child of array proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTSET, HADDR_UNDEF, + "unable to add extensible array entry as child of array proxy") dblock->top_proxy = hdr->top_proxy; } /* end if */ @@ -203,25 +213,29 @@ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, /* Set address of data block to return */ ret_value = dblock_addr; - CATCH +done: if (!H5F_addr_defined(ret_value)) if (dblock) { /* Remove from cache, if inserted */ if (inserted) if (H5AC_remove_entry(dblock) < 0) - H5E_THROW(H5E_CANTREMOVE, "unable to remove extensible array data block from cache") + HDONE_ERROR(H5E_EARRAY, H5E_CANTREMOVE, HADDR_UNDEF, + "unable to remove extensible array data block from cache") /* Release data block's disk space */ if (H5F_addr_defined(dblock->addr) && H5MF_xfree(hdr->f, H5FD_MEM_EARRAY_DBLOCK, dblock->addr, (hsize_t)dblock->size) < 0) - H5E_THROW(H5E_CANTFREE, "unable to release extensible array data block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, HADDR_UNDEF, + "unable to release extensible array data block") /* Destroy data block */ if (H5EA__dblock_dest(dblock) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array data block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, HADDR_UNDEF, + "unable to destroy extensible array data block") } /* end if */ -END_FUNC(PKG) /* end H5EA__dblock_create() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__dblock_create() */ /*------------------------------------------------------------------------- * Function: H5EA__dblock_sblk_idx @@ -236,10 +250,12 @@ END_FUNC(PKG) /* end H5EA__dblock_create() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, NOERR, unsigned, 0, -, H5EA__dblock_sblk_idx(const H5EA_hdr_t *hdr, hsize_t idx)) +unsigned +H5EA__dblock_sblk_idx(const H5EA_hdr_t *hdr, hsize_t idx) +{ + unsigned sblk_idx = 0; /* Which superblock does this index fall in? */ - /* Local variables */ - unsigned sblk_idx; /* Which superblock does this index fall in? */ + FUNC_ENTER_PACKAGE_NOERR /* Sanity check */ HDassert(hdr); @@ -252,10 +268,8 @@ BEGIN_FUNC(PKG, NOERR, unsigned, 0, -, H5EA__dblock_sblk_idx(const H5EA_hdr_t *h H5_CHECK_OVERFLOW(idx, /*From:*/ hsize_t, /*To:*/ uint64_t); sblk_idx = H5VM_log2_gen((uint64_t)((idx / hdr->cparam.data_blk_min_elmts) + 1)); - /* Set return value */ - ret_value = sblk_idx; - -END_FUNC(PKG) /* end H5EA__dblock_sblk_idx() */ + FUNC_LEAVE_NOAPI(sblk_idx) +} /* end H5EA__dblock_sblk_idx() */ /*------------------------------------------------------------------------- * Function: H5EA__dblock_protect @@ -269,13 +283,14 @@ END_FUNC(PKG) /* end H5EA__dblock_sblk_idx() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5EA_dblock_t *, NULL, NULL, - H5EA__dblock_protect(H5EA_hdr_t *hdr, void *parent, haddr_t dblk_addr, size_t dblk_nelmts, - unsigned flags)) - - /* Local variables */ +H5EA_dblock_t * +H5EA__dblock_protect(H5EA_hdr_t *hdr, void *parent, haddr_t dblk_addr, size_t dblk_nelmts, unsigned flags) +{ H5EA_dblock_t * dblock; /* Extensible array data block */ H5EA_dblock_cache_ud_t udata; /* Information needed for loading data block */ + H5EA_dblock_t * ret_value = NULL; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -294,32 +309,36 @@ BEGIN_FUNC(PKG, ERR, H5EA_dblock_t *, NULL, NULL, /* Protect the data block */ if (NULL == (dblock = (H5EA_dblock_t *)H5AC_protect(hdr->f, H5AC_EARRAY_DBLOCK, dblk_addr, &udata, flags))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array data block, address = %llu", - (unsigned long long)dblk_addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, NULL, + "unable to protect extensible array data block, address = %llu", + (unsigned long long)dblk_addr) /* Create top proxy, if it doesn't exist */ if (hdr->top_proxy && NULL == dblock->top_proxy) { /* Add data block as child of 'top' proxy */ if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, dblock) < 0) - H5E_THROW(H5E_CANTSET, "unable to add extensible array entry as child of array proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTSET, NULL, + "unable to add extensible array entry as child of array proxy") dblock->top_proxy = hdr->top_proxy; - } /* end if */ + } /* Set return value */ ret_value = dblock; - CATCH +done: /* Clean up on error */ if (!ret_value) { /* Release the data block, if it was protected */ if (dblock && H5AC_unprotect(hdr->f, H5AC_EARRAY_DBLOCK, dblock->addr, dblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect extensible array data block, address = %llu", - (unsigned long long)dblock->addr) - } /* end if */ + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, NULL, + "unable to unprotect extensible array data block, address = %llu", + (unsigned long long)dblock->addr) + } -END_FUNC(PKG) /* end H5EA__dblock_protect() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__dblock_protect() */ /*------------------------------------------------------------------------- * Function: H5EA__dblock_unprotect @@ -333,22 +352,26 @@ END_FUNC(PKG) /* end H5EA__dblock_protect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5EA__dblock_unprotect(H5EA_dblock_t *dblock, unsigned cache_flags)) +herr_t +H5EA__dblock_unprotect(H5EA_dblock_t *dblock, unsigned cache_flags) +{ + herr_t ret_value = SUCCEED; - /* Local variables */ + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(dblock); /* Unprotect the data block */ if (H5AC_unprotect(dblock->hdr->f, H5AC_EARRAY_DBLOCK, dblock->addr, dblock, cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect extensible array data block, address = %llu", - (unsigned long long)dblock->addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, + "unable to unprotect extensible array data block, address = %llu", + (unsigned long long)dblock->addr) - CATCH +done: -END_FUNC(PKG) /* end H5EA__dblock_unprotect() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__dblock_unprotect() */ /*------------------------------------------------------------------------- * Function: H5EA__dblock_delete @@ -362,11 +385,13 @@ END_FUNC(PKG) /* end H5EA__dblock_unprotect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5EA__dblock_delete(H5EA_hdr_t *hdr, void *parent, haddr_t dblk_addr, size_t dblk_nelmts)) +herr_t +H5EA__dblock_delete(H5EA_hdr_t *hdr, void *parent, haddr_t dblk_addr, size_t dblk_nelmts) +{ + H5EA_dblock_t *dblock = NULL; /* Pointer to data block */ + herr_t ret_value = SUCCEED; - /* Local variables */ - H5EA_dblock_t *dblock = NULL; /* Pointer to data block */ + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -376,8 +401,9 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, /* Protect data block */ if (NULL == (dblock = H5EA__dblock_protect(hdr, parent, dblk_addr, dblk_nelmts, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array data block, address = %llu", - (unsigned long long)dblk_addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect extensible array data block, address = %llu", + (unsigned long long)dblk_addr) /* Check if this is a paged data block */ if (dblk_nelmts > hdr->dblk_page_nelmts) { @@ -395,20 +421,22 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, /* Evict the data block page from the metadata cache */ /* (OK to call if it doesn't exist in the cache) */ if (H5AC_expunge_entry(hdr->f, H5AC_EARRAY_DBLK_PAGE, dblk_page_addr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTEXPUNGE, "unable to remove array data block page from metadata cache") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTEXPUNGE, FAIL, + "unable to remove array data block page from metadata cache") /* Advance to next page address */ dblk_page_addr += dblk_page_size; } /* end for */ } /* end if */ - CATCH +done: /* Finished deleting data block in metadata cache */ if (dblock && H5EA__dblock_unprotect(dblock, H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array data block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array data block") -END_FUNC(PKG) /* end H5EA__dblock_delete() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__dblock_delete() */ /*------------------------------------------------------------------------- * Function: H5EA__dblock_dest @@ -422,7 +450,12 @@ END_FUNC(PKG) /* end H5EA__dblock_delete() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__dblock_dest(H5EA_dblock_t *dblock)) +herr_t +H5EA__dblock_dest(H5EA_dblock_t *dblock) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(dblock); @@ -435,14 +468,16 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__dblock_dest(H5EA_dblock_t *dbl /* Free buffer for data block elements */ HDassert(dblock->nelmts > 0); if (H5EA__hdr_free_elmts(dblock->hdr, dblock->nelmts, dblock->elmts) < 0) - H5E_THROW(H5E_CANTFREE, "unable to free extensible array data block element buffer") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTFREE, FAIL, + "unable to free extensible array data block element buffer") dblock->elmts = NULL; dblock->nelmts = 0; } /* end if */ /* Decrement reference count on shared info */ if (H5EA__hdr_decr(dblock->hdr) < 0) - H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDEC, FAIL, + "can't decrement reference count on shared array header") dblock->hdr = NULL; } /* end if */ @@ -452,6 +487,6 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__dblock_dest(H5EA_dblock_t *dbl /* Free the data block itself */ dblock = H5FL_FREE(H5EA_dblock_t, dblock); - CATCH - -END_FUNC(PKG) /* end H5EA__dblock_dest() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__dblock_dest() */ diff --git a/src/H5EAhdr.c b/src/H5EAhdr.c index 7f142af..2c68949 100644 --- a/src/H5EAhdr.c +++ b/src/H5EAhdr.c @@ -102,17 +102,21 @@ H5FL_SEQ_DEFINE_STATIC(H5EA_sblk_info_t); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5EA_hdr_t *, NULL, NULL, H5EA__hdr_alloc(H5F_t *f)) +H5EA_hdr_t * +H5EA__hdr_alloc(H5F_t *f) +{ + H5EA_hdr_t *hdr = NULL; /* Shared extensible array header */ + H5EA_hdr_t *ret_value = NULL; - /* Local variables */ - H5EA_hdr_t *hdr = NULL; /* Shared extensible array header */ + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(f); /* Allocate space for the shared information */ if (NULL == (hdr = H5FL_CALLOC(H5EA_hdr_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array shared header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for extensible array shared header") /* Set non-zero internal fields */ hdr->addr = HADDR_UNDEF; @@ -126,12 +130,13 @@ BEGIN_FUNC(PKG, ERR, H5EA_hdr_t *, NULL, NULL, H5EA__hdr_alloc(H5F_t *f)) /* Set the return value */ ret_value = hdr; - CATCH +done: if (!ret_value) if (hdr && H5EA__hdr_dest(hdr) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array header") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array header") -END_FUNC(PKG) /* end H5EA__hdr_alloc() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__hdr_alloc() */ /*------------------------------------------------------------------------- * Function: H5EA__hdr_init @@ -168,12 +173,15 @@ END_FUNC(PKG) /* end H5EA__hdr_alloc() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_init(H5EA_hdr_t *hdr, void *ctx_udata)) - - /* Local variables */ +herr_t +H5EA__hdr_init(H5EA_hdr_t *hdr, void *ctx_udata) +{ hsize_t start_idx; /* First element index for each super block */ hsize_t start_dblk; /* First data block index for each super block */ size_t u; /* Local index variable */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -188,7 +196,7 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_init(H5EA_hdr_t *hdr, void /* Allocate information for each super block */ if (NULL == (hdr->sblk_info = H5FL_SEQ_MALLOC(H5EA_sblk_info_t, hdr->nsblks))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for super block info array") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, FAIL, "memory allocation failed for super block info array") /* Compute information about each super block */ start_idx = 0; @@ -202,7 +210,7 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_init(H5EA_hdr_t *hdr, void /* Advance starting indices for next super block */ start_idx += (hsize_t)hdr->sblk_info[u].ndblks * (hsize_t)hdr->sblk_info[u].dblk_nelmts; start_dblk += (hsize_t)hdr->sblk_info[u].ndblks; - } /* end for */ + } /* Set size of header on disk (locally and in statistics) */ hdr->stats.computed.hdr_size = hdr->size = H5EA_HEADER_SIZE_HDR(hdr); @@ -210,12 +218,13 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_init(H5EA_hdr_t *hdr, void /* Create the callback context, if there's one */ if (hdr->cparam.cls->crt_context) { if (NULL == (hdr->cb_ctx = (*hdr->cparam.cls->crt_context)(ctx_udata))) - H5E_THROW(H5E_CANTCREATE, "unable to create extensible array client callback context") - } /* end if */ - - CATCH + HGOTO_ERROR(H5E_EARRAY, H5E_CANTCREATE, FAIL, + "unable to create extensible array client callback context") + } -END_FUNC(PKG) /* end H5EA__hdr_init() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__hdr_init() */ /*------------------------------------------------------------------------- * Function: H5EA__hdr_alloc_elmts @@ -229,11 +238,14 @@ END_FUNC(PKG) /* end H5EA__hdr_init() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, void *, NULL, NULL, H5EA__hdr_alloc_elmts(H5EA_hdr_t *hdr, size_t nelmts)) - - /* Local variables */ +void * +H5EA__hdr_alloc_elmts(H5EA_hdr_t *hdr, size_t nelmts) +{ void * elmts = NULL; /* Element buffer allocated */ unsigned idx; /* Index of element buffer factory in header */ + void * ret_value = NULL; + + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(hdr); @@ -251,8 +263,8 @@ BEGIN_FUNC(PKG, ERR, void *, NULL, NULL, H5EA__hdr_alloc_elmts(H5EA_hdr_t *hdr, /* Re-allocate array of element factories */ if (NULL == (new_fac = H5FL_SEQ_REALLOC(H5FL_fac_head_ptr_t, hdr->elmt_fac.fac, new_nalloc))) - H5E_THROW(H5E_CANTALLOC, - "memory allocation failed for data block data element buffer factory array") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for data block data element buffer factory array") /* Zero out new elements allocated */ HDmemset(new_fac + hdr->elmt_fac.nalloc, 0, @@ -266,22 +278,24 @@ BEGIN_FUNC(PKG, ERR, void *, NULL, NULL, H5EA__hdr_alloc_elmts(H5EA_hdr_t *hdr, /* Check for un-initialized factory at index */ if (NULL == hdr->elmt_fac.fac[idx]) { if (NULL == (hdr->elmt_fac.fac[idx] = H5FL_fac_init(nelmts * (size_t)hdr->cparam.cls->nat_elmt_size))) - H5E_THROW(H5E_CANTINIT, "can't create data block data element buffer factory") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINIT, NULL, "can't create data block data element buffer factory") } /* end if */ /* Allocate buffer for elements in index block */ if (NULL == (elmts = H5FL_FAC_MALLOC(hdr->elmt_fac.fac[idx]))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for data block data element buffer") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for data block data element buffer") /* Set the return value */ ret_value = elmts; - CATCH +done: if (!ret_value) if (elmts) elmts = H5FL_FAC_FREE(hdr->elmt_fac.fac[idx], elmts); -END_FUNC(PKG) /* end H5EA__hdr_alloc_elmts() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__hdr_alloc_elmts() */ /*------------------------------------------------------------------------- * Function: H5EA__hdr_free_elmts @@ -295,11 +309,13 @@ END_FUNC(PKG) /* end H5EA__hdr_alloc_elmts() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, NOERR, herr_t, SUCCEED, -, H5EA__hdr_free_elmts(H5EA_hdr_t *hdr, size_t nelmts, void *elmts)) - - /* Local variables */ +herr_t +H5EA__hdr_free_elmts(H5EA_hdr_t *hdr, size_t nelmts, void *elmts) +{ unsigned idx; /* Index of element buffer factory in header */ + FUNC_ENTER_PACKAGE_NOERR + /* Check arguments */ HDassert(hdr); HDassert(nelmts > 0); @@ -314,26 +330,30 @@ BEGIN_FUNC(PKG, NOERR, herr_t, SUCCEED, -, H5EA__hdr_free_elmts(H5EA_hdr_t *hdr, HDassert(hdr->elmt_fac.fac[idx]); elmts = H5FL_FAC_FREE(hdr->elmt_fac.fac[idx], elmts); -END_FUNC(PKG) /* end H5EA__hdr_free_elmts() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__hdr_free_elmts() */ /*------------------------------------------------------------------------- * Function: H5EA__hdr_create * * Purpose: Creates a new extensible array header in the file * - * Return: SUCCEED/FAIL + * Return: Success: Address of new header in the file + * Failure: HADDR_UNDEF * * Programmer: Quincey Koziol * Jun 17 2008 * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, - H5EA__hdr_create(H5F_t *f, const H5EA_create_t *cparam, void *ctx_udata)) +haddr_t +H5EA__hdr_create(H5F_t *f, const H5EA_create_t *cparam, void *ctx_udata) +{ + H5EA_hdr_t *hdr = NULL; /* Extensible array header */ + hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + haddr_t ret_value = HADDR_UNDEF; - /* Local variables */ - H5EA_hdr_t *hdr = NULL; /* Extensible array header */ - hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(f); @@ -347,39 +367,45 @@ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, /* Check for valid parameters */ if (cparam->raw_elmt_size == 0) - H5E_THROW(H5E_BADVALUE, "element size must be greater than zero") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, HADDR_UNDEF, "element size must be greater than zero") if (cparam->max_nelmts_bits == 0) - H5E_THROW(H5E_BADVALUE, "max. # of elements bits must be greater than zero") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, HADDR_UNDEF, + "max. # of elements bits must be greater than zero") if (cparam->max_nelmts_bits > H5EA_MAX_NELMTS_IDX_MAX) - H5E_THROW(H5E_BADVALUE, "max. # of elements bits must be <= %u", - (unsigned)H5EA_MAX_NELMTS_IDX_MAX) + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, HADDR_UNDEF, "max. # of elements bits must be <= %u", + (unsigned)H5EA_MAX_NELMTS_IDX_MAX) if (cparam->sup_blk_min_data_ptrs < 2) - H5E_THROW(H5E_BADVALUE, "min # of data block pointers in super block must be >= two") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, HADDR_UNDEF, + "min # of data block pointers in super block must be >= two") if (!POWER_OF_TWO(cparam->sup_blk_min_data_ptrs)) - H5E_THROW(H5E_BADVALUE, "min # of data block pointers in super block must be power of two") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, HADDR_UNDEF, + "min # of data block pointers in super block must be power of two") if (!POWER_OF_TWO(cparam->data_blk_min_elmts)) - H5E_THROW(H5E_BADVALUE, "min # of elements per data block must be power of two") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, HADDR_UNDEF, + "min # of elements per data block must be power of two") dblk_page_nelmts = (size_t)1 << cparam->max_dblk_page_nelmts_bits; if (dblk_page_nelmts < cparam->idx_blk_elmts) - H5E_THROW(H5E_BADVALUE, - "# of elements per data block page must be greater than # of elements in index block") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, HADDR_UNDEF, + "# of elements per data block page must be greater than # of elements in index block") /* Compute the number of elements in data blocks for first actual super block */ sblk_idx = H5EA_SBLK_FIRST_IDX(cparam->sup_blk_min_data_ptrs); dblk_nelmts = H5EA_SBLK_DBLK_NELMTS(sblk_idx, cparam->data_blk_min_elmts); if (dblk_page_nelmts < dblk_nelmts) - H5E_THROW(H5E_BADVALUE, "max. # of elements per data block page bits must be > # of elements in " - "first data block from super block") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, HADDR_UNDEF, + "max. # of elements per data block page bits must be > # of elements in " + "first data block from super block") if (cparam->max_dblk_page_nelmts_bits > cparam->max_nelmts_bits) - H5E_THROW(H5E_BADVALUE, - "max. # of elements per data block page bits must be <= max. # of elements bits") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, HADDR_UNDEF, + "max. # of elements per data block page bits must be <= max. # of elements bits") } #endif /* NDEBUG */ /* Allocate space for the shared information */ if (NULL == (hdr = H5EA__hdr_alloc(f))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array shared header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, HADDR_UNDEF, + "memory allocation failed for extensible array shared header") /* Set the internal parameters for the array */ hdr->idx_blk_addr = HADDR_UNDEF; @@ -389,49 +415,55 @@ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, /* Finish initializing extensible array header */ if (H5EA__hdr_init(hdr, ctx_udata) < 0) - H5E_THROW(H5E_CANTINIT, "initialization failed for extensible array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINIT, HADDR_UNDEF, + "initialization failed for extensible array header") /* Allocate space for the header on disk */ if (HADDR_UNDEF == (hdr->addr = H5MF_alloc(f, H5FD_MEM_EARRAY_HDR, (hsize_t)hdr->size))) - H5E_THROW(H5E_CANTALLOC, "file allocation failed for extensible array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, HADDR_UNDEF, + "file allocation failed for extensible array header") /* Create 'top' proxy for extensible array entries */ if (hdr->swmr_write) if (NULL == (hdr->top_proxy = H5AC_proxy_entry_create())) - H5E_THROW(H5E_CANTCREATE, "can't create extensible array entry proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTCREATE, HADDR_UNDEF, "can't create extensible array entry proxy") /* Cache the new extensible array header */ if (H5AC_insert_entry(f, H5AC_EARRAY_HDR, hdr->addr, hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTINSERT, "can't add extensible array header to cache") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINSERT, HADDR_UNDEF, "can't add extensible array header to cache") inserted = TRUE; /* Add header as child of 'top' proxy */ if (hdr->top_proxy) if (H5AC_proxy_entry_add_child(hdr->top_proxy, f, hdr) < 0) - H5E_THROW(H5E_CANTSET, "unable to add extensible array entry as child of array proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTSET, HADDR_UNDEF, + "unable to add extensible array entry as child of array proxy") /* Set address of array header to return */ ret_value = hdr->addr; - CATCH +done: if (!H5F_addr_defined(ret_value)) if (hdr) { /* Remove from cache, if inserted */ if (inserted) if (H5AC_remove_entry(hdr) < 0) - H5E_THROW(H5E_CANTREMOVE, "unable to remove extensible array header from cache") + HDONE_ERROR(H5E_EARRAY, H5E_CANTREMOVE, HADDR_UNDEF, + "unable to remove extensible array header from cache") /* Release header's disk space */ if (H5F_addr_defined(hdr->addr) && H5MF_xfree(f, H5FD_MEM_EARRAY_HDR, hdr->addr, (hsize_t)hdr->size) < 0) - H5E_THROW(H5E_CANTFREE, "unable to free extensible array header") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, HADDR_UNDEF, "unable to free extensible array header") /* Destroy header */ if (H5EA__hdr_dest(hdr) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array header") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, HADDR_UNDEF, + "unable to destroy extensible array header") } /* end if */ -END_FUNC(PKG) /* end H5EA__hdr_create() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__hdr_create() */ /*------------------------------------------------------------------------- * Function: H5EA__hdr_incr @@ -445,7 +477,12 @@ END_FUNC(PKG) /* end H5EA__hdr_create() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_incr(H5EA_hdr_t *hdr)) +herr_t +H5EA__hdr_incr(H5EA_hdr_t *hdr) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -453,14 +490,14 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_incr(H5EA_hdr_t *hdr)) /* Mark header as un-evictable when something is depending on it */ if (hdr->rc == 0) if (H5AC_pin_protected_entry(hdr) < 0) - H5E_THROW(H5E_CANTPIN, "unable to pin extensible array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPIN, FAIL, "unable to pin extensible array header") /* Increment reference count on shared header */ hdr->rc++; - CATCH - -END_FUNC(PKG) /* end H5EA__hdr_incr() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__hdr_incr() */ /*------------------------------------------------------------------------- * Function: H5EA__hdr_decr @@ -474,7 +511,12 @@ END_FUNC(PKG) /* end H5EA__hdr_incr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_decr(H5EA_hdr_t *hdr)) +herr_t +H5EA__hdr_decr(H5EA_hdr_t *hdr) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -487,12 +529,12 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_decr(H5EA_hdr_t *hdr)) if (hdr->rc == 0) { HDassert(hdr->file_rc == 0); if (H5AC_unpin_entry(hdr) < 0) - H5E_THROW(H5E_CANTUNPIN, "unable to unpin extensible array header") - } /* end if */ - - CATCH + HGOTO_ERROR(H5E_EARRAY, H5E_CANTUNPIN, FAIL, "unable to unpin extensible array header") + } -END_FUNC(PKG) /* end H5EA__hdr_decr() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__hdr_decr() */ /*------------------------------------------------------------------------- * Function: H5EA__hdr_fuse_incr @@ -506,7 +548,10 @@ END_FUNC(PKG) /* end H5EA__hdr_decr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, NOERR, herr_t, SUCCEED, -, H5EA__hdr_fuse_incr(H5EA_hdr_t *hdr)) +herr_t +H5EA__hdr_fuse_incr(H5EA_hdr_t *hdr) +{ + FUNC_ENTER_PACKAGE_NOERR /* Sanity check */ HDassert(hdr); @@ -514,21 +559,28 @@ BEGIN_FUNC(PKG, NOERR, herr_t, SUCCEED, -, H5EA__hdr_fuse_incr(H5EA_hdr_t *hdr)) /* Increment file reference count on shared header */ hdr->file_rc++; -END_FUNC(PKG) /* end H5EA__hdr_fuse_incr() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__hdr_fuse_incr() */ /*------------------------------------------------------------------------- * Function: H5EA__hdr_fuse_decr * * Purpose: Decrement file reference count on shared array header * - * Return: Non-negative on success/Negative on failure + * Return: Success: The reference count of the header + * Failure: Can't fail * * Programmer: Quincey Koziol * Aug 26 2008 * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, NOERR, size_t, 0, -, H5EA__hdr_fuse_decr(H5EA_hdr_t *hdr)) +size_t +H5EA__hdr_fuse_decr(H5EA_hdr_t *hdr) +{ + size_t ret_value = 0; + + FUNC_ENTER_PACKAGE_NOERR /* Sanity check */ HDassert(hdr); @@ -540,7 +592,8 @@ BEGIN_FUNC(PKG, NOERR, size_t, 0, -, H5EA__hdr_fuse_decr(H5EA_hdr_t *hdr)) /* Set return value */ ret_value = hdr->file_rc; -END_FUNC(PKG) /* end H5EA__hdr_fuse_decr() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__hdr_fuse_decr() */ /*------------------------------------------------------------------------- * Function: H5EA__hdr_modified @@ -554,7 +607,12 @@ END_FUNC(PKG) /* end H5EA__hdr_fuse_decr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_modified(H5EA_hdr_t *hdr)) +herr_t +H5EA__hdr_modified(H5EA_hdr_t *hdr) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -562,11 +620,11 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_modified(H5EA_hdr_t *hdr)) /* Mark header as dirty in cache */ if (H5AC_mark_entry_dirty(hdr) < 0) - H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark extensible array header as dirty") - - CATCH + HGOTO_ERROR(H5E_EARRAY, H5E_CANTMARKDIRTY, FAIL, "unable to mark extensible array header as dirty") -END_FUNC(PKG) /* end H5EA__hdr_modified() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__hdr_modified() */ /*------------------------------------------------------------------------- * Function: H5EA__hdr_protect @@ -580,12 +638,14 @@ END_FUNC(PKG) /* end H5EA__hdr_modified() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5EA_hdr_t *, NULL, NULL, - H5EA__hdr_protect(H5F_t *f, haddr_t ea_addr, void *ctx_udata, unsigned flags)) - - /* Local variables */ +H5EA_hdr_t * +H5EA__hdr_protect(H5F_t *f, haddr_t ea_addr, void *ctx_udata, unsigned flags) +{ H5EA_hdr_t * hdr; /* Extensible array header */ H5EA_hdr_cache_ud_t udata; /* User data for cache callbacks */ + H5EA_hdr_t * ret_value = NULL; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(f); @@ -601,27 +661,28 @@ BEGIN_FUNC(PKG, ERR, H5EA_hdr_t *, NULL, NULL, /* Protect the header */ if (NULL == (hdr = (H5EA_hdr_t *)H5AC_protect(f, H5AC_EARRAY_HDR, ea_addr, &udata, flags))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array header, address = %llu", - (unsigned long long)ea_addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, NULL, + "unable to protect extensible array header, address = %llu", (unsigned long long)ea_addr) hdr->f = f; /* (Must be set again here, in case the header was already in the cache -QAK) */ /* Create top proxy, if it doesn't exist */ if (hdr->swmr_write && NULL == hdr->top_proxy) { /* Create 'top' proxy for extensible array entries */ if (NULL == (hdr->top_proxy = H5AC_proxy_entry_create())) - H5E_THROW(H5E_CANTCREATE, "can't create extensible array entry proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTCREATE, NULL, "can't create extensible array entry proxy") /* Add header as child of 'top' proxy */ if (H5AC_proxy_entry_add_child(hdr->top_proxy, f, hdr) < 0) - H5E_THROW(H5E_CANTSET, "unable to add extensible array entry as child of array proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTSET, NULL, + "unable to add extensible array entry as child of array proxy") } /* end if */ /* Set return value */ ret_value = hdr; - CATCH - -END_FUNC(PKG) /* end H5EA__hdr_protect() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__hdr_protect() */ /*------------------------------------------------------------------------- * Function: H5EA__hdr_unprotect @@ -635,21 +696,24 @@ END_FUNC(PKG) /* end H5EA__hdr_protect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_unprotect(H5EA_hdr_t *hdr, unsigned cache_flags)) +herr_t +H5EA__hdr_unprotect(H5EA_hdr_t *hdr, unsigned cache_flags) +{ + herr_t ret_value = SUCCEED; - /* Local variables */ + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); /* Unprotect the header */ if (H5AC_unprotect(hdr->f, H5AC_EARRAY_HDR, hdr->addr, hdr, cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect extensible array hdr, address = %llu", - (unsigned long long)hdr->addr) - - CATCH + HGOTO_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, + "unable to unprotect extensible array hdr, address = %llu", (unsigned long long)hdr->addr) -END_FUNC(PKG) /* end H5EA__hdr_unprotect() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__hdr_unprotect() */ /*------------------------------------------------------------------------- * Function: H5EA__hdr_delete @@ -663,46 +727,48 @@ END_FUNC(PKG) /* end H5EA__hdr_unprotect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_delete(H5EA_hdr_t *hdr)) - - /* Local variables */ +herr_t +H5EA__hdr_delete(H5EA_hdr_t *hdr) +{ unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting header */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); HDassert(!hdr->file_rc); #ifndef NDEBUG - { - unsigned hdr_status = 0; /* Array header's status in the metadata cache */ + unsigned hdr_status = 0; /* Array header's status in the metadata cache */ - /* Check the array header's status in the metadata cache */ - if (H5AC_get_entry_status(hdr->f, hdr->addr, &hdr_status) < 0) - H5E_THROW(H5E_CANTGET, "unable to check metadata cache status for array header") + /* Check the array header's status in the metadata cache */ + if (H5AC_get_entry_status(hdr->f, hdr->addr, &hdr_status) < 0) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTGET, FAIL, "unable to check metadata cache status for array header") - /* Sanity checks on array header */ - HDassert(hdr_status & H5AC_ES__IN_CACHE); - HDassert(hdr_status & H5AC_ES__IS_PROTECTED); - } /* end block */ + /* Sanity checks on array header */ + HDassert(hdr_status & H5AC_ES__IN_CACHE); + HDassert(hdr_status & H5AC_ES__IS_PROTECTED); #endif /* NDEBUG */ /* Check for index block */ if (H5F_addr_defined(hdr->idx_blk_addr)) { /* Delete index block */ if (H5EA__iblock_delete(hdr) < 0) - H5E_THROW(H5E_CANTDELETE, "unable to delete extensible array index block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDELETE, FAIL, "unable to delete extensible array index block") } /* end if */ /* Set flags to finish deleting header on unprotect */ cache_flags |= H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG; - CATCH +done: /* Unprotect the header, deleting it if an error hasn't occurred */ if (H5EA__hdr_unprotect(hdr, cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array header") -END_FUNC(PKG) /* end H5EA__hdr_delete() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__hdr_delete() */ /*------------------------------------------------------------------------- * Function: H5EA__hdr_dest @@ -716,7 +782,12 @@ END_FUNC(PKG) /* end H5EA__hdr_delete() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_dest(H5EA_hdr_t *hdr)) +herr_t +H5EA__hdr_dest(H5EA_hdr_t *hdr) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(hdr); @@ -725,7 +796,8 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_dest(H5EA_hdr_t *hdr)) /* Destroy the callback context */ if (hdr->cb_ctx) { if ((*hdr->cparam.cls->dst_context)(hdr->cb_ctx) < 0) - H5E_THROW(H5E_CANTRELEASE, "unable to destroy extensible array client callback context") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTRELEASE, FAIL, + "unable to destroy extensible array client callback context") } /* end if */ hdr->cb_ctx = NULL; @@ -741,7 +813,8 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_dest(H5EA_hdr_t *hdr)) /* Check if this factory has been initialized */ if (hdr->elmt_fac.fac[u]) { if (H5FL_fac_term(hdr->elmt_fac.fac[u]) < 0) - H5E_THROW(H5E_CANTRELEASE, "unable to destroy extensible array header factory") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTRELEASE, FAIL, + "unable to destroy extensible array header factory") hdr->elmt_fac.fac[u] = NULL; } /* end if */ } /* end for */ @@ -757,13 +830,13 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_dest(H5EA_hdr_t *hdr)) /* Destroy the 'top' proxy */ if (hdr->top_proxy) { if (H5AC_proxy_entry_dest(hdr->top_proxy) < 0) - H5E_THROW(H5E_CANTRELEASE, "unable to destroy extensible array 'top' proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTRELEASE, FAIL, "unable to destroy extensible array 'top' proxy") hdr->top_proxy = NULL; } /* end if */ /* Free the shared info itself */ hdr = H5FL_FREE(H5EA_hdr_t, hdr); - CATCH - -END_FUNC(PKG) /* end H5EA__hdr_dest() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__hdr_dest() */ diff --git a/src/H5EAiblock.c b/src/H5EAiblock.c index 1ef7980..5afb28a 100644 --- a/src/H5EAiblock.c +++ b/src/H5EAiblock.c @@ -91,21 +91,25 @@ H5FL_SEQ_DEFINE_STATIC(haddr_t); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5EA_iblock_t *, NULL, NULL, H5EA__iblock_alloc(H5EA_hdr_t *hdr)) +H5EA_iblock_t * +H5EA__iblock_alloc(H5EA_hdr_t *hdr) +{ + H5EA_iblock_t *iblock = NULL; /* Extensible array index block */ + H5EA_iblock_t *ret_value = NULL; - /* Local variables */ - H5EA_iblock_t *iblock = NULL; /* Extensible array index block */ + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(hdr); /* Allocate memory for the index block */ if (NULL == (iblock = H5FL_CALLOC(H5EA_iblock_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array index block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for extensible array index block") /* Share common array information */ if (H5EA__hdr_incr(hdr) < 0) - H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINC, NULL, "can't increment reference count on shared array header") iblock->hdr = hdr; /* Set non-zero internal fields */ @@ -121,27 +125,30 @@ BEGIN_FUNC(PKG, ERR, H5EA_iblock_t *, NULL, NULL, H5EA__iblock_alloc(H5EA_hdr_t if (NULL == (iblock->elmts = H5FL_BLK_MALLOC( idx_blk_elmt_buf, (size_t)(hdr->cparam.idx_blk_elmts * hdr->cparam.cls->nat_elmt_size)))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for index block data element buffer") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for index block data element buffer") /* Allocate buffer for data block addresses in index block */ if (iblock->ndblk_addrs > 0) if (NULL == (iblock->dblk_addrs = H5FL_SEQ_MALLOC(haddr_t, iblock->ndblk_addrs))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for index block data block addresses") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for index block data block addresses") /* Allocate buffer for super block addresses in index block */ if (iblock->nsblk_addrs > 0) if (NULL == (iblock->sblk_addrs = H5FL_SEQ_MALLOC(haddr_t, iblock->nsblk_addrs))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for index block super block addresses") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for index block super block addresses") /* Set the return value */ ret_value = iblock; - CATCH +done: if (!ret_value) if (iblock && H5EA__iblock_dest(iblock) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array index block") - -END_FUNC(PKG) /* end H5EA__iblock_alloc() */ + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array index block") + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__iblock_alloc() */ /*------------------------------------------------------------------------- * Function: H5EA__iblock_create @@ -155,13 +162,15 @@ END_FUNC(PKG) /* end H5EA__iblock_alloc() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, - H5EA__iblock_create(H5EA_hdr_t *hdr, hbool_t *stats_changed)) +haddr_t +H5EA__iblock_create(H5EA_hdr_t *hdr, hbool_t *stats_changed) +{ + H5EA_iblock_t *iblock = NULL; /* Extensible array index block */ + haddr_t iblock_addr; /* Extensible array index block address */ + hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + haddr_t ret_value = HADDR_UNDEF; - /* Local variables */ - H5EA_iblock_t *iblock = NULL; /* Extensible array index block */ - haddr_t iblock_addr; /* Extensible array index block address */ - hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -169,21 +178,24 @@ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, /* Allocate the index block */ if (NULL == (iblock = H5EA__iblock_alloc(hdr))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array index block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, HADDR_UNDEF, + "memory allocation failed for extensible array index block") /* Set size of index block on disk */ iblock->size = H5EA_IBLOCK_SIZE(iblock); /* Allocate space for the index block on disk */ if (HADDR_UNDEF == (iblock_addr = H5MF_alloc(hdr->f, H5FD_MEM_EARRAY_IBLOCK, (hsize_t)iblock->size))) - H5E_THROW(H5E_CANTALLOC, "file allocation failed for extensible array index block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, HADDR_UNDEF, + "file allocation failed for extensible array index block") iblock->addr = iblock_addr; /* Clear any elements in index block to fill value */ if (hdr->cparam.idx_blk_elmts > 0) { /* Call the class's 'fill' callback */ if ((hdr->cparam.cls->fill)(iblock->elmts, (size_t)hdr->cparam.idx_blk_elmts) < 0) - H5E_THROW(H5E_CANTSET, "can't set extensible array index block elements to class's fill value") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTSET, HADDR_UNDEF, + "can't set extensible array index block elements to class's fill value") } /* end if */ /* Reset any data block addresses in the index block */ @@ -204,13 +216,15 @@ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, /* Cache the new extensible array index block */ if (H5AC_insert_entry(hdr->f, H5AC_EARRAY_IBLOCK, iblock_addr, iblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTINSERT, "can't add extensible array index block to cache") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINSERT, HADDR_UNDEF, + "can't add extensible array index block to cache") inserted = TRUE; /* Add index block as child of 'top' proxy */ if (hdr->top_proxy) { if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, iblock) < 0) - H5E_THROW(H5E_CANTSET, "unable to add extensible array entry as child of array proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTSET, HADDR_UNDEF, + "unable to add extensible array entry as child of array proxy") iblock->top_proxy = hdr->top_proxy; } /* end if */ @@ -229,25 +243,29 @@ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, /* Set address of index block to return */ ret_value = iblock_addr; - CATCH +done: if (!H5F_addr_defined(ret_value)) if (iblock) { /* Remove from cache, if inserted */ if (inserted) if (H5AC_remove_entry(iblock) < 0) - H5E_THROW(H5E_CANTREMOVE, "unable to remove extensible array index block from cache") + HDONE_ERROR(H5E_EARRAY, H5E_CANTREMOVE, HADDR_UNDEF, + "unable to remove extensible array index block from cache") /* Release index block's disk space */ if (H5F_addr_defined(iblock->addr) && H5MF_xfree(hdr->f, H5FD_MEM_EARRAY_IBLOCK, iblock->addr, (hsize_t)iblock->size) < 0) - H5E_THROW(H5E_CANTFREE, "unable to release file space for extensible array index block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, HADDR_UNDEF, + "unable to release file space for extensible array index block") /* Destroy index block */ if (H5EA__iblock_dest(iblock) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array index block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, HADDR_UNDEF, + "unable to destroy extensible array index block") } /* end if */ -END_FUNC(PKG) /* end H5EA__iblock_create() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__iblock_create() */ /*------------------------------------------------------------------------- * Function: H5EA__iblock_protect @@ -261,10 +279,13 @@ END_FUNC(PKG) /* end H5EA__iblock_create() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5EA_iblock_t *, NULL, NULL, H5EA__iblock_protect(H5EA_hdr_t *hdr, unsigned flags)) +H5EA_iblock_t * +H5EA__iblock_protect(H5EA_hdr_t *hdr, unsigned flags) +{ + H5EA_iblock_t *iblock = NULL; /* Pointer to index block */ + H5EA_iblock_t *ret_value = NULL; - /* Local variables */ - H5EA_iblock_t *iblock = NULL; /* Pointer to index block */ + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -275,31 +296,35 @@ BEGIN_FUNC(PKG, ERR, H5EA_iblock_t *, NULL, NULL, H5EA__iblock_protect(H5EA_hdr_ /* Protect the index block */ if (NULL == (iblock = (H5EA_iblock_t *)H5AC_protect(hdr->f, H5AC_EARRAY_IBLOCK, hdr->idx_blk_addr, hdr, flags))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array index block, address = %llu", - (unsigned long long)hdr->idx_blk_addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, NULL, + "unable to protect extensible array index block, address = %llu", + (unsigned long long)hdr->idx_blk_addr) /* Create top proxy, if it doesn't exist */ if (hdr->top_proxy && NULL == iblock->top_proxy) { /* Add index block as child of 'top' proxy */ if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, iblock) < 0) - H5E_THROW(H5E_CANTSET, "unable to add extensible array entry as child of array proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTSET, NULL, + "unable to add extensible array entry as child of array proxy") iblock->top_proxy = hdr->top_proxy; } /* end if */ /* Set return value */ ret_value = iblock; - CATCH +done: /* Clean up on error */ if (!ret_value) { /* Release the index block, if it was protected */ if (iblock && H5AC_unprotect(hdr->f, H5AC_EARRAY_IBLOCK, iblock->addr, iblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect extensible array index block, address = %llu", - (unsigned long long)iblock->addr) + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, NULL, + "unable to unprotect extensible array index block, address = %llu", + (unsigned long long)iblock->addr) } /* end if */ -END_FUNC(PKG) /* end H5EA__iblock_protect() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__iblock_protect() */ /*------------------------------------------------------------------------- * Function: H5EA__iblock_unprotect @@ -313,22 +338,25 @@ END_FUNC(PKG) /* end H5EA__iblock_protect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5EA__iblock_unprotect(H5EA_iblock_t *iblock, unsigned cache_flags)) +herr_t +H5EA__iblock_unprotect(H5EA_iblock_t *iblock, unsigned cache_flags) +{ + herr_t ret_value = SUCCEED; - /* Local variables */ + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(iblock); /* Unprotect the index block */ if (H5AC_unprotect(iblock->hdr->f, H5AC_EARRAY_IBLOCK, iblock->addr, iblock, cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect extensible array index block, address = %llu", - (unsigned long long)iblock->addr) - - CATCH + HGOTO_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, + "unable to unprotect extensible array index block, address = %llu", + (unsigned long long)iblock->addr) -END_FUNC(PKG) /* end H5EA__iblock_unprotect() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__iblock_unprotect() */ /*------------------------------------------------------------------------- * Function: H5EA__iblock_delete @@ -342,10 +370,13 @@ END_FUNC(PKG) /* end H5EA__iblock_unprotect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__iblock_delete(H5EA_hdr_t *hdr)) +herr_t +H5EA__iblock_delete(H5EA_hdr_t *hdr) +{ + H5EA_iblock_t *iblock = NULL; /* Pointer to index block */ + herr_t ret_value = SUCCEED; - /* Local variables */ - H5EA_iblock_t *iblock = NULL; /* Pointer to index block */ + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -353,8 +384,9 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__iblock_delete(H5EA_hdr_t *hdr) /* Protect index block */ if (NULL == (iblock = H5EA__iblock_protect(hdr, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array index block, address = %llu", - (unsigned long long)hdr->idx_blk_addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect extensible array index block, address = %llu", + (unsigned long long)hdr->idx_blk_addr) /* Check for index block having data block pointers */ if (iblock->ndblk_addrs > 0) { @@ -370,7 +402,8 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__iblock_delete(H5EA_hdr_t *hdr) /* Delete data block */ if (H5EA__dblock_delete(hdr, iblock, iblock->dblk_addrs[u], hdr->sblk_info[sblk_idx].dblk_nelmts) < 0) - H5E_THROW(H5E_CANTDELETE, "unable to delete extensible array data block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDELETE, FAIL, + "unable to delete extensible array data block") iblock->dblk_addrs[u] = HADDR_UNDEF; } /* end if */ @@ -396,19 +429,21 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__iblock_delete(H5EA_hdr_t *hdr) /* Delete super block */ if (H5EA__sblock_delete(hdr, iblock, iblock->sblk_addrs[u], (unsigned)(u + iblock->nsblks)) < 0) - H5E_THROW(H5E_CANTDELETE, "unable to delete extensible array super block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDELETE, FAIL, + "unable to delete extensible array super block") iblock->sblk_addrs[u] = HADDR_UNDEF; - } /* end if */ - } /* end for */ - } /* end if */ + } + } + } - CATCH +done: /* Finished deleting index block in metadata cache */ if (iblock && H5EA__iblock_unprotect(iblock, H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array index block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array index block") -END_FUNC(PKG) /* end H5EA__iblock_delete() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__iblock_delete() */ /*------------------------------------------------------------------------- * Function: H5EA__iblock_dest @@ -422,7 +457,12 @@ END_FUNC(PKG) /* end H5EA__iblock_delete() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__iblock_dest(H5EA_iblock_t *iblock)) +herr_t +H5EA__iblock_dest(H5EA_iblock_t *iblock) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(iblock); @@ -454,7 +494,8 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__iblock_dest(H5EA_iblock_t *ibl /* Decrement reference count on shared info */ if (H5EA__hdr_decr(iblock->hdr) < 0) - H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDEC, FAIL, + "can't decrement reference count on shared array header") iblock->hdr = NULL; } /* end if */ @@ -464,6 +505,6 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__iblock_dest(H5EA_iblock_t *ibl /* Free the index block itself */ iblock = H5FL_FREE(H5EA_iblock_t, iblock); - CATCH - -END_FUNC(PKG) /* end H5EA__iblock_dest() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__iblock_dest() */ diff --git a/src/H5EAint.c b/src/H5EAint.c index 472cfb4..af7ff4c 100644 --- a/src/H5EAint.c +++ b/src/H5EAint.c @@ -79,8 +79,12 @@ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5EA__create_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry)) +herr_t +H5EA__create_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(parent_entry); @@ -88,11 +92,11 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, /* Create a flush dependency between parent and child entry */ if (H5AC_create_flush_dependency(parent_entry, child_entry) < 0) - H5E_THROW(H5E_CANTDEPEND, "unable to create flush dependency") - - CATCH + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") -END_FUNC(PKG) /* end H5EA__create_flush_depend() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__create_flush_depend() */ /*------------------------------------------------------------------------- * Function: H5EA__destroy_flush_depend @@ -106,8 +110,12 @@ END_FUNC(PKG) /* end H5EA__create_flush_depend() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5EA__destroy_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry)) +herr_t +H5EA__destroy_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(parent_entry); @@ -115,8 +123,8 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, /* Destroy a flush dependency between parent and child entry */ if (H5AC_destroy_flush_dependency(parent_entry, child_entry) < 0) - H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency") - - CATCH + HGOTO_ERROR(H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") -END_FUNC(PKG) /* end H5EA__destroy_flush_depend() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__destroy_flush_depend() */ diff --git a/src/H5EAsblock.c b/src/H5EAsblock.c index 8639217..30cb220 100644 --- a/src/H5EAsblock.c +++ b/src/H5EAsblock.c @@ -91,22 +91,25 @@ H5FL_BLK_DEFINE(page_init); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5EA_sblock_t *, NULL, NULL, - H5EA__sblock_alloc(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, unsigned sblk_idx)) +H5EA_sblock_t * +H5EA__sblock_alloc(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, unsigned sblk_idx) +{ + H5EA_sblock_t *sblock = NULL; /* Extensible array super block */ + H5EA_sblock_t *ret_value = NULL; - /* Local variables */ - H5EA_sblock_t *sblock = NULL; /* Extensible array super block */ + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(hdr); /* Allocate memory for the index block */ if (NULL == (sblock = H5FL_CALLOC(H5EA_sblock_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array super block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for extensible array super block") /* Share common array information */ if (H5EA__hdr_incr(hdr) < 0) - H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINC, NULL, "can't increment reference count on shared array header") sblock->hdr = hdr; /* Set non-zero internal fields */ @@ -121,7 +124,8 @@ BEGIN_FUNC(PKG, ERR, H5EA_sblock_t *, NULL, NULL, /* Allocate buffer for data block addresses in super block */ if (NULL == (sblock->dblk_addrs = H5FL_SEQ_MALLOC(haddr_t, sblock->ndblks))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for super block data block addresses") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for super block data block addresses") /* Check if # of elements in data blocks requires paging */ if (sblock->dblk_nelmts > hdr->dblk_page_nelmts) { @@ -141,7 +145,8 @@ BEGIN_FUNC(PKG, ERR, H5EA_sblock_t *, NULL, NULL, /* Allocate buffer for all 'page init' bitmasks in super block */ if (NULL == (sblock->page_init = H5FL_BLK_CALLOC(page_init, sblock->ndblks * sblock->dblk_page_init_size))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for super block page init bitmask") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for super block page init bitmask") /* Compute data block page size */ sblock->dblk_page_size = (hdr->dblk_page_nelmts * hdr->cparam.raw_elmt_size) + H5EA_SIZEOF_CHKSUM; @@ -150,12 +155,13 @@ BEGIN_FUNC(PKG, ERR, H5EA_sblock_t *, NULL, NULL, /* Set the return value */ ret_value = sblock; - CATCH +done: if (!ret_value) if (sblock && H5EA__sblock_dest(sblock) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array super block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array super block") -END_FUNC(PKG) /* end H5EA__sblock_alloc() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__sblock_alloc() */ /*------------------------------------------------------------------------- * Function: H5EA__sblock_create @@ -169,15 +175,16 @@ END_FUNC(PKG) /* end H5EA__sblock_alloc() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, - H5EA__sblock_create(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, hbool_t *stats_changed, - unsigned sblk_idx)) +haddr_t +H5EA__sblock_create(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, hbool_t *stats_changed, unsigned sblk_idx) +{ + H5EA_sblock_t *sblock = NULL; /* Extensible array super block */ + haddr_t sblock_addr; /* Extensible array super block address */ + haddr_t tmp_addr = HADDR_UNDEF; /* Address value to fill data block addresses with */ + hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + haddr_t ret_value = HADDR_UNDEF; - /* Local variables */ - H5EA_sblock_t *sblock = NULL; /* Extensible array super block */ - haddr_t sblock_addr; /* Extensible array super block address */ - haddr_t tmp_addr = HADDR_UNDEF; /* Address value to fill data block addresses with */ - hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -185,7 +192,8 @@ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, /* Allocate the super block */ if (NULL == (sblock = H5EA__sblock_alloc(hdr, parent, sblk_idx))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array super block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, HADDR_UNDEF, + "memory allocation failed for extensible array super block") /* Set size of super block on disk */ sblock->size = H5EA_SBLOCK_SIZE(sblock); @@ -195,7 +203,8 @@ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, /* Allocate space for the super block on disk */ if (HADDR_UNDEF == (sblock_addr = H5MF_alloc(hdr->f, H5FD_MEM_EARRAY_SBLOCK, (hsize_t)sblock->size))) - H5E_THROW(H5E_CANTALLOC, "file allocation failed for extensible array super block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, HADDR_UNDEF, + "file allocation failed for extensible array super block") sblock->addr = sblock_addr; /* Reset data block addresses to "undefined" address value */ @@ -203,13 +212,15 @@ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, /* Cache the new extensible array super block */ if (H5AC_insert_entry(hdr->f, H5AC_EARRAY_SBLOCK, sblock_addr, sblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTINSERT, "can't add extensible array super block to cache") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINSERT, HADDR_UNDEF, + "can't add extensible array super block to cache") inserted = TRUE; /* Add super block as child of 'top' proxy */ if (hdr->top_proxy) { if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, sblock) < 0) - H5E_THROW(H5E_CANTSET, "unable to add extensible array entry as child of array proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTSET, HADDR_UNDEF, + "unable to add extensible array entry as child of array proxy") sblock->top_proxy = hdr->top_proxy; } /* end if */ @@ -223,25 +234,29 @@ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, /* Set address of super block to return */ ret_value = sblock_addr; - CATCH +done: if (!H5F_addr_defined(ret_value)) if (sblock) { /* Remove from cache, if inserted */ if (inserted) if (H5AC_remove_entry(sblock) < 0) - H5E_THROW(H5E_CANTREMOVE, "unable to remove extensible array super block from cache") + HDONE_ERROR(H5E_EARRAY, H5E_CANTREMOVE, HADDR_UNDEF, + "unable to remove extensible array super block from cache") /* Release super block's disk space */ if (H5F_addr_defined(sblock->addr) && H5MF_xfree(hdr->f, H5FD_MEM_EARRAY_SBLOCK, sblock->addr, (hsize_t)sblock->size) < 0) - H5E_THROW(H5E_CANTFREE, "unable to release extensible array super block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, HADDR_UNDEF, + "unable to release extensible array super block") /* Destroy super block */ if (H5EA__sblock_dest(sblock) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array super block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, HADDR_UNDEF, + "unable to destroy extensible array super block") } /* end if */ -END_FUNC(PKG) /* end H5EA__sblock_create() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__sblock_create() */ /*------------------------------------------------------------------------- * Function: H5EA__sblock_protect @@ -255,13 +270,15 @@ END_FUNC(PKG) /* end H5EA__sblock_create() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5EA_sblock_t *, NULL, NULL, - H5EA__sblock_protect(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, haddr_t sblk_addr, unsigned sblk_idx, - unsigned flags)) - - /* Local variables */ +H5EA_sblock_t * +H5EA__sblock_protect(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, haddr_t sblk_addr, unsigned sblk_idx, + unsigned flags) +{ H5EA_sblock_t * sblock = NULL; /* Pointer to super block */ H5EA_sblock_cache_ud_t udata; /* Information needed for loading super block */ + H5EA_sblock_t * ret_value = NULL; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -279,31 +296,35 @@ BEGIN_FUNC(PKG, ERR, H5EA_sblock_t *, NULL, NULL, /* Protect the super block */ if (NULL == (sblock = (H5EA_sblock_t *)H5AC_protect(hdr->f, H5AC_EARRAY_SBLOCK, sblk_addr, &udata, flags))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array super block, address = %llu", - (unsigned long long)sblk_addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, NULL, + "unable to protect extensible array super block, address = %llu", + (unsigned long long)sblk_addr) /* Create top proxy, if it doesn't exist */ if (hdr->top_proxy && NULL == sblock->top_proxy) { /* Add super block as child of 'top' proxy */ if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, sblock) < 0) - H5E_THROW(H5E_CANTSET, "unable to add extensible array entry as child of array proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTSET, NULL, + "unable to add extensible array entry as child of array proxy") sblock->top_proxy = hdr->top_proxy; - } /* end if */ + } /* Set return value */ ret_value = sblock; - CATCH +done: /* Clean up on error */ if (!ret_value) { /* Release the super block, if it was protected */ if (sblock && H5AC_unprotect(hdr->f, H5AC_EARRAY_SBLOCK, sblock->addr, sblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect extensible array super block, address = %llu", - (unsigned long long)sblock->addr) - } /* end if */ + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, NULL, + "unable to unprotect extensible array super block, address = %llu", + (unsigned long long)sblock->addr) + } -END_FUNC(PKG) /* end H5EA__sblock_protect() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__sblock_protect() */ /*------------------------------------------------------------------------- * Function: H5EA__sblock_unprotect @@ -317,22 +338,25 @@ END_FUNC(PKG) /* end H5EA__sblock_protect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5EA__sblock_unprotect(H5EA_sblock_t *sblock, unsigned cache_flags)) +herr_t +H5EA__sblock_unprotect(H5EA_sblock_t *sblock, unsigned cache_flags) +{ + herr_t ret_value = SUCCEED; - /* Local variables */ + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(sblock); /* Unprotect the super block */ if (H5AC_unprotect(sblock->hdr->f, H5AC_EARRAY_SBLOCK, sblock->addr, sblock, cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect extensible array super block, address = %llu", - (unsigned long long)sblock->addr) - - CATCH + HGOTO_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, + "unable to unprotect extensible array super block, address = %llu", + (unsigned long long)sblock->addr) -END_FUNC(PKG) /* end H5EA__sblock_unprotect() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__sblock_unprotect() */ /*------------------------------------------------------------------------- * Function: H5EA__sblock_delete @@ -346,12 +370,14 @@ END_FUNC(PKG) /* end H5EA__sblock_unprotect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5EA__sblock_delete(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, haddr_t sblk_addr, unsigned sblk_idx)) - - /* Local variables */ +herr_t +H5EA__sblock_delete(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, haddr_t sblk_addr, unsigned sblk_idx) +{ H5EA_sblock_t *sblock = NULL; /* Pointer to super block */ size_t u; /* Local index variable */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -359,8 +385,9 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, /* Protect super block */ if (NULL == (sblock = H5EA__sblock_protect(hdr, parent, sblk_addr, sblk_idx, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array super block, address = %llu", - (unsigned long long)sblk_addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect extensible array super block, address = %llu", + (unsigned long long)sblk_addr) /* Iterate over data blocks */ for (u = 0; u < sblock->ndblks; u++) { @@ -368,18 +395,19 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, if (H5F_addr_defined(sblock->dblk_addrs[u])) { /* Delete data block */ if (H5EA__dblock_delete(hdr, sblock, sblock->dblk_addrs[u], sblock->dblk_nelmts) < 0) - H5E_THROW(H5E_CANTDELETE, "unable to delete extensible array data block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDELETE, FAIL, "unable to delete extensible array data block") sblock->dblk_addrs[u] = HADDR_UNDEF; } /* end if */ } /* end for */ - CATCH +done: /* Finished deleting super block in metadata cache */ if (sblock && H5EA__sblock_unprotect(sblock, H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array super block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array super block") -END_FUNC(PKG) /* end H5EA__sblock_delete() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__sblock_delete() */ /*------------------------------------------------------------------------- * Function: H5EA__sblock_dest @@ -393,7 +421,12 @@ END_FUNC(PKG) /* end H5EA__sblock_delete() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__sblock_dest(H5EA_sblock_t *sblock)) +herr_t +H5EA__sblock_dest(H5EA_sblock_t *sblock) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(sblock); @@ -413,7 +446,8 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__sblock_dest(H5EA_sblock_t *sbl /* Decrement reference count on shared info */ if (H5EA__hdr_decr(sblock->hdr) < 0) - H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDEC, FAIL, + "can't decrement reference count on shared array header") sblock->hdr = NULL; } /* end if */ @@ -423,6 +457,6 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__sblock_dest(H5EA_sblock_t *sbl /* Free the super block itself */ sblock = H5FL_FREE(H5EA_sblock_t, sblock); - CATCH - -END_FUNC(PKG) /* end H5EA__sblock_dest() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__sblock_dest() */ diff --git a/src/H5EAstat.c b/src/H5EAstat.c index 47b9a86..5705cb8 100644 --- a/src/H5EAstat.c +++ b/src/H5EAstat.c @@ -80,17 +80,17 @@ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5EA_get_stats(const H5EA_t *ea, H5EA_stat_t *stats)) +herr_t +H5EA_get_stats(const H5EA_t *ea, H5EA_stat_t *stats) +{ + FUNC_ENTER_NOAPI_NOERR - /* Local variables */ - - /* - * Check arguments. - */ + /* Check arguments */ HDassert(ea); HDassert(stats); /* Copy extensible array statistics */ H5MM_memcpy(stats, &ea->hdr->stats, sizeof(ea->hdr->stats)); -END_FUNC(PRIV) /* end H5EA_get_stats() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA_get_stats() */ diff --git a/src/H5EAtest.c b/src/H5EAtest.c index dd669fc..7924eaa 100644 --- a/src/H5EAtest.c +++ b/src/H5EAtest.c @@ -119,17 +119,19 @@ H5FL_DEFINE_STATIC(H5EA__ctx_cb_t); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, H5EA__test_crt_context(void *_udata)) +static void * +H5EA__test_crt_context(void *_udata) +{ + H5EA__test_ctx_t *ctx; /* Context for callbacks */ + H5EA__ctx_cb_t * udata = (H5EA__ctx_cb_t *)_udata; /* User data for context */ + void * ret_value = NULL; - /* Local variables */ - H5EA__test_ctx_t *ctx; /* Context for callbacks */ - H5EA__ctx_cb_t * udata = (H5EA__ctx_cb_t *)_udata; /* User data for context */ - - /* Sanity checks */ + FUNC_ENTER_STATIC /* Allocate new context structure */ if (NULL == (ctx = H5FL_MALLOC(H5EA__test_ctx_t))) - H5E_THROW(H5E_CANTALLOC, "can't allocate extensible array client callback context") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "can't allocate extensible array client callback context") /* Initialize the context */ ctx->bogus = H5EA__TEST_BOGUS_VAL; @@ -138,9 +140,9 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, H5EA__test_crt_context(void *_udata) /* Set return value */ ret_value = ctx; - CATCH - -END_FUNC(STATIC) /* end H5EA__test_crt_context() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__test_crt_context() */ /*------------------------------------------------------------------------- * Function: H5EA__test_dst_context @@ -155,18 +157,21 @@ END_FUNC(STATIC) /* end H5EA__test_crt_context() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, H5EA__test_dst_context(void *_ctx)) - - /* Local variables */ +static herr_t +H5EA__test_dst_context(void *_ctx) +{ H5EA__test_ctx_t *ctx = (H5EA__test_ctx_t *)_ctx; /* Callback context to destroy */ + FUNC_ENTER_STATIC_NOERR + /* Sanity checks */ HDassert(H5EA__TEST_BOGUS_VAL == ctx->bogus); /* Release context structure */ ctx = H5FL_FREE(H5EA__test_ctx_t, ctx); -END_FUNC(STATIC) /* end H5EA__test_dst_context() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__test_dst_context() */ /*------------------------------------------------------------------------- * Function: H5EA__test_fill @@ -181,18 +186,21 @@ END_FUNC(STATIC) /* end H5EA__test_dst_context() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, H5EA__test_fill(void *nat_blk, size_t nelmts)) - - /* Local variables */ +static herr_t +H5EA__test_fill(void *nat_blk, size_t nelmts) +{ uint64_t fill_val = H5EA_TEST_FILL; /* Value to fill elements with */ + FUNC_ENTER_STATIC_NOERR + /* Sanity checks */ HDassert(nat_blk); HDassert(nelmts); H5VM_array_fill(nat_blk, &fill_val, sizeof(uint64_t), nelmts); -END_FUNC(STATIC) /* end H5EA__test_fill() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__test_fill() */ /*------------------------------------------------------------------------- * Function: H5EA__test_encode @@ -207,12 +215,14 @@ END_FUNC(STATIC) /* end H5EA__test_fill() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, - H5EA__test_encode(void *raw, const void *_elmt, size_t nelmts, void *_ctx)) +static herr_t +H5EA__test_encode(void *raw, const void *_elmt, size_t nelmts, void *_ctx) +{ + H5EA__test_ctx_t *ctx = (H5EA__test_ctx_t *)_ctx; /* Callback context to destroy */ + const uint64_t * elmt = (const uint64_t *)_elmt; /* Convenience pointer to native elements */ + herr_t ret_value = SUCCEED; - /* Local variables */ - H5EA__test_ctx_t *ctx = (H5EA__test_ctx_t *)_ctx; /* Callback context to destroy */ - const uint64_t * elmt = (const uint64_t *)_elmt; /* Convenience pointer to native elements */ + FUNC_ENTER_STATIC /* Sanity checks */ HDassert(raw); @@ -223,13 +233,12 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Check for callback action */ if (ctx->cb) { if ((*ctx->cb->encode)(elmt, nelmts, ctx->cb->udata) < 0) - H5E_THROW(H5E_BADVALUE, "extensible array testing callback action failed") - } /* end if */ + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, FAIL, "extensible array testing callback action failed") + } /* Encode native elements into raw elements */ while (nelmts) { - /* Encode element */ - /* (advances 'raw' pointer) */ + /* Encode element - advances 'raw' pointer */ UINT64ENCODE(raw, *elmt); /* Advance native element pointer */ @@ -237,11 +246,11 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Decrement # of elements to encode */ nelmts--; - } /* end while */ + } - CATCH - -END_FUNC(STATIC) /* end H5EA__test_encode() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__test_encode() */ /*------------------------------------------------------------------------- * Function: H5EA__test_decode @@ -256,16 +265,17 @@ END_FUNC(STATIC) /* end H5EA__test_encode() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5EA__test_decode(const void *_raw, void *_elmt, size_t nelmts, void H5_ATTR_NDEBUG_UNUSED *_ctx)) - -/* Local variables */ +static herr_t +H5EA__test_decode(const void *_raw, void *_elmt, size_t nelmts, void H5_ATTR_NDEBUG_UNUSED *_ctx) +{ #ifndef NDEBUG H5EA__test_ctx_t *ctx = (H5EA__test_ctx_t *)_ctx; /* Callback context to destroy */ #endif /* NDEBUG */ uint64_t * elmt = (uint64_t *)_elmt; /* Convenience pointer to native elements */ const uint8_t *raw = (const uint8_t *)_raw; /* Convenience pointer to raw elements */ + FUNC_ENTER_STATIC_NOERR + /* Sanity checks */ HDassert(raw); HDassert(elmt); @@ -274,8 +284,7 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Decode raw elements into native elements */ while (nelmts) { - /* Decode element */ - /* (advances 'raw' pointer) */ + /* Decode element - advances 'raw' pointer */ UINT64DECODE(raw, *elmt); /* Advance native element pointer */ @@ -283,9 +292,10 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Decrement # of elements to decode */ nelmts--; - } /* end while */ + } -END_FUNC(STATIC) /* end H5EA__test_decode() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__test_decode() */ /*------------------------------------------------------------------------- * Function: H5EA__test_debug @@ -300,12 +310,13 @@ END_FUNC(STATIC) /* end H5EA__test_decode() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5EA__test_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void *elmt)) - - /* Local variables */ +static herr_t +H5EA__test_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void *elmt) +{ char temp_str[128]; /* Temporary string, for formatting */ + FUNC_ENTER_STATIC_NOERR + /* Sanity checks */ HDassert(stream); HDassert(elmt); @@ -315,7 +326,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, HDfprintf(stream, "%*s%-*s %llu\n", indent, "", fwidth, temp_str, (unsigned long long)*(const uint64_t *)elmt); -END_FUNC(STATIC) /* end H5EA__test_debug() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__test_debug() */ /*------------------------------------------------------------------------- * Function: H5EA__test_crt_dbg_context @@ -329,22 +341,25 @@ END_FUNC(STATIC) /* end H5EA__test_debug() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, - H5EA__test_crt_dbg_context(H5F_t H5_ATTR_UNUSED *f, haddr_t H5_ATTR_UNUSED obj_addr)) - - /* Local variables */ +static void * +H5EA__test_crt_dbg_context(H5F_t H5_ATTR_UNUSED *f, haddr_t H5_ATTR_UNUSED obj_addr) +{ H5EA__ctx_cb_t *ctx; /* Context for callbacks */ + void * ret_value = NULL; + + FUNC_ENTER_STATIC /* Allocate new context structure */ if (NULL == (ctx = H5FL_MALLOC(H5EA__ctx_cb_t))) - H5E_THROW(H5E_CANTALLOC, "can't allocate extensible array client callback context") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "can't allocate extensible array client callback context") /* Set return value */ ret_value = ctx; - CATCH - -END_FUNC(STATIC) /* end H5EA__test_crt_dbg_context() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__test_crt_dbg_context() */ /*------------------------------------------------------------------------- * Function: H5EA__test_dst_dbg_context @@ -358,17 +373,20 @@ END_FUNC(STATIC) /* end H5EA__test_crt_dbg_context() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, H5EA__test_dst_dbg_context(void *_ctx)) - - /* Local variables */ +static herr_t +H5EA__test_dst_dbg_context(void *_ctx) +{ H5EA__ctx_cb_t *ctx = (H5EA__ctx_cb_t *)_ctx; /* Callback context to destroy */ + FUNC_ENTER_STATIC_NOERR + HDassert(_ctx); /* Release context structure */ ctx = H5FL_FREE(H5EA__ctx_cb_t, ctx); -END_FUNC(STATIC) /* end H5EA__test_dst_dbg_context() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__test_dst_dbg_context() */ /*------------------------------------------------------------------------- * Function: H5EA__get_cparam_test @@ -383,7 +401,10 @@ END_FUNC(STATIC) /* end H5EA__test_dst_dbg_context() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, NOERR, herr_t, SUCCEED, -, H5EA__get_cparam_test(const H5EA_t *ea, H5EA_create_t *cparam)) +herr_t +H5EA__get_cparam_test(const H5EA_t *ea, H5EA_create_t *cparam) +{ + FUNC_ENTER_PACKAGE_NOERR /* Check arguments. */ HDassert(ea); @@ -397,7 +418,8 @@ BEGIN_FUNC(PKG, NOERR, herr_t, SUCCEED, -, H5EA__get_cparam_test(const H5EA_t *e cparam->data_blk_min_elmts = ea->hdr->cparam.data_blk_min_elmts; cparam->max_dblk_page_nelmts_bits = ea->hdr->cparam.max_dblk_page_nelmts_bits; -END_FUNC(PKG) /* end H5EA__get_cparam_test() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__get_cparam_test() */ /*------------------------------------------------------------------------- * Function: H5EA__cmp_cparam_test @@ -412,39 +434,48 @@ END_FUNC(PKG) /* end H5EA__get_cparam_test() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERRCATCH, int, 0, -, - H5EA__cmp_cparam_test(const H5EA_create_t *cparam1, const H5EA_create_t *cparam2)) +int +H5EA__cmp_cparam_test(const H5EA_create_t *cparam1, const H5EA_create_t *cparam2) +{ + int ret_value = 0; - /* Check arguments. */ + FUNC_ENTER_PACKAGE_NOERR + + /* Check arguments */ HDassert(cparam1); HDassert(cparam2); /* Compare creation parameters for array */ if (cparam1->raw_elmt_size < cparam2->raw_elmt_size) - H5_LEAVE(-1) + HGOTO_DONE(-1) else if (cparam1->raw_elmt_size > cparam2->raw_elmt_size) - H5_LEAVE(1) + HGOTO_DONE(1) + if (cparam1->max_nelmts_bits < cparam2->max_nelmts_bits) - H5_LEAVE(-1) + HGOTO_DONE(-1) else if (cparam1->max_nelmts_bits > cparam2->max_nelmts_bits) - H5_LEAVE(1) + HGOTO_DONE(1) + if (cparam1->idx_blk_elmts < cparam2->idx_blk_elmts) - H5_LEAVE(-1) + HGOTO_DONE(-1) else if (cparam1->idx_blk_elmts > cparam2->idx_blk_elmts) - H5_LEAVE(1) + HGOTO_DONE(1) + if (cparam1->sup_blk_min_data_ptrs < cparam2->sup_blk_min_data_ptrs) - H5_LEAVE(-1) + HGOTO_DONE(-1) else if (cparam1->sup_blk_min_data_ptrs > cparam2->sup_blk_min_data_ptrs) - H5_LEAVE(1) + HGOTO_DONE(1) + if (cparam1->data_blk_min_elmts < cparam2->data_blk_min_elmts) - H5_LEAVE(-1) + HGOTO_DONE(-1) else if (cparam1->data_blk_min_elmts > cparam2->data_blk_min_elmts) - H5_LEAVE(1) + HGOTO_DONE(1) + if (cparam1->max_dblk_page_nelmts_bits < cparam2->max_dblk_page_nelmts_bits) - H5_LEAVE(-1) + HGOTO_DONE(-1) else if (cparam1->max_dblk_page_nelmts_bits > cparam2->max_dblk_page_nelmts_bits) - H5_LEAVE(1) - - CATCH + HGOTO_DONE(1) -END_FUNC(PKG) /* end H5EA__cmp_cparam_test() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cmp_cparam_test() */ diff --git a/src/H5Eprivate.h b/src/H5Eprivate.h index 4cd8b70..cd567aa 100644 --- a/src/H5Eprivate.h +++ b/src/H5Eprivate.h @@ -180,53 +180,6 @@ extern int H5E_mpi_error_str_len; } #endif /* H5_HAVE_PARALLEL */ -/******************************************************************************/ -/* Revisions to Error Macros, to go with Revisions to FUNC_ENTER/LEAVE Macros */ -/******************************************************************************/ - -/* - * H5E_PRINTF macro, used to facilitate error reporting between a BEGIN_FUNC() - * and an END_FUNC() within a function body. The arguments are the minor - * error number, a description of the error (as a printf-like format string), - * and an optional set of arguments for the printf format arguments. - */ -#define H5E_PRINTF(...) \ - H5E_printf_stack(NULL, __FILE__, FUNC, __LINE__, H5E_ERR_CLS_g, H5_MY_PKG_ERR, __VA_ARGS__) - -/* - * H5_LEAVE macro, used to facilitate control flow between a - * BEGIN_FUNC() and an END_FUNC() within a function body. The argument is - * the return value. - * The return value is assigned to a variable `ret_value' and control branches - * to the `catch_except' label, if we're not already past it. - */ -#define H5_LEAVE(v) \ - { \ - ret_value = v; \ - if (!past_catch) \ - goto catch_except; \ - } - -/* - * H5E_THROW macro, used to facilitate error reporting between a - * FUNC_ENTER() and a FUNC_LEAVE() within a function body. The arguments are - * the minor error number, and an error string. - * The return value is assigned to a variable `ret_value' and control branches - * to the `catch_except' label, if we're not already past it. - */ -#define H5E_THROW(...) \ - { \ - H5E_PRINTF(__VA_ARGS__); \ - H5_LEAVE(fail_value) \ - } - -/* Macro for "catching" flow of control when an error occurs. Note that the - * H5_LEAVE macro won't jump back here once it's past this point. - */ -#define CATCH \ -catch_except:; \ - past_catch = TRUE; - /* Library-private functions defined in H5E package */ H5_DLL herr_t H5E_init(void); H5_DLL herr_t H5E_printf_stack(H5E_t *estack, const char *file, const char *func, unsigned line, hid_t cls_id, diff --git a/src/H5FA.c b/src/H5FA.c index 05b0bd8..ad69ee2 100644 --- a/src/H5FA.c +++ b/src/H5FA.c @@ -105,39 +105,40 @@ H5FL_BLK_DEFINE(fa_native_elmt); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, H5FA_t *, NULL, NULL, - H5FA__new(H5F_t *f, haddr_t fa_addr, hbool_t from_open, void *ctx_udata)) +static H5FA_t * +H5FA__new(H5F_t *f, haddr_t fa_addr, hbool_t from_open, void *ctx_udata) +{ + H5FA_t * fa = NULL; /* Pointer to new fixed array */ + H5FA_hdr_t *hdr = NULL; /* The fixed array header information */ + H5FA_t * ret_value = NULL; - /* Local variables */ - H5FA_t * fa = NULL; /* Pointer to new fixed array */ - H5FA_hdr_t *hdr = NULL; /* The fixed array header information */ + FUNC_ENTER_STATIC - /* - * Check arguments. - */ + /* Check arguments */ HDassert(f); HDassert(H5F_addr_defined(fa_addr)); /* Allocate fixed array wrapper */ if (NULL == (fa = H5FL_CALLOC(H5FA_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array info") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, NULL, "memory allocation failed for fixed array info") /* Lock the array header into memory */ if (NULL == (hdr = H5FA__hdr_protect(f, fa_addr, ctx_udata, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to load fixed array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPROTECT, NULL, "unable to load fixed array header") /* Check for pending array deletion */ if (from_open && hdr->pending_delete) - H5E_THROW(H5E_CANTOPENOBJ, "can't open fixed array pending deletion") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTOPENOBJ, NULL, "can't open fixed array pending deletion") /* 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") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTINC, NULL, "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") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTINC, NULL, + "can't increment file reference count on shared array header") /* Set file pointer for this array open context */ fa->f = f; @@ -145,15 +146,15 @@ BEGIN_FUNC(STATIC, ERR, H5FA_t *, NULL, NULL, /* Set the return value */ ret_value = fa; - CATCH - +done: if (hdr && H5FA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array header") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, NULL, "unable to release fixed array header") if (!ret_value) if (fa && H5FA_close(fa) < 0) - H5E_THROW(H5E_CLOSEERROR, "unable to close fixed array") + HDONE_ERROR(H5E_FARRAY, H5E_CLOSEERROR, NULL, "unable to close fixed array") -END_FUNC(STATIC) /* end H5FA__new() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__new() */ /*------------------------------------------------------------------------- * Function: H5FA_create @@ -168,16 +169,16 @@ END_FUNC(STATIC) /* end H5FA__new() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, H5FA_t *, NULL, NULL, - H5FA_create(H5F_t *f, const H5FA_create_t *cparam, void *ctx_udata)) - - /* Local variables */ +H5FA_t * +H5FA_create(H5F_t *f, const H5FA_create_t *cparam, void *ctx_udata) +{ H5FA_t *fa = NULL; /* Pointer to new fixed array */ haddr_t fa_addr; /* Fixed array header address */ + H5FA_t *ret_value = NULL; - /* - * Check arguments. - */ + FUNC_ENTER_NOAPI(NULL) + + /* Check arguments */ HDassert(f); HDassert(cparam); @@ -186,22 +187,23 @@ BEGIN_FUNC(PRIV, ERR, H5FA_t *, NULL, NULL, /* Create fixed array header */ if (HADDR_UNDEF == (fa_addr = H5FA__hdr_create(f, cparam, ctx_udata))) - H5E_THROW(H5E_CANTINIT, "can't create fixed array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTINIT, NULL, "can't create fixed array header") /* Allocate and initialize new fixed array wrapper */ if (NULL == (fa = H5FA__new(f, fa_addr, FALSE, ctx_udata))) - H5E_THROW(H5E_CANTINIT, "allocation and/or initialization failed for fixed array wrapper") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTINIT, NULL, + "allocation and/or initialization failed for fixed array wrapper") /* Set the return value */ ret_value = fa; - CATCH - +done: if (!ret_value) if (fa && H5FA_close(fa) < 0) - H5E_THROW(H5E_CLOSEERROR, "unable to close fixed array") + HDONE_ERROR(H5E_FARRAY, H5E_CLOSEERROR, NULL, "unable to close fixed array") -END_FUNC(PRIV) /* end H5FA_create() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA_create() */ /*------------------------------------------------------------------------- * Function: H5FA_open @@ -216,31 +218,33 @@ END_FUNC(PRIV) /* end H5FA_create() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, H5FA_t *, NULL, NULL, H5FA_open(H5F_t *f, haddr_t fa_addr, void *ctx_udata)) +H5FA_t * +H5FA_open(H5F_t *f, haddr_t fa_addr, void *ctx_udata) +{ + H5FA_t *fa = NULL; /* Pointer to new fixed array wrapper */ + H5FA_t *ret_value = NULL; - /* Local variables */ - H5FA_t *fa = NULL; /* Pointer to new fixed array wrapper */ + FUNC_ENTER_NOAPI(NULL) - /* - * Check arguments. - */ + /* Check arguments */ HDassert(f); HDassert(H5F_addr_defined(fa_addr)); /* Allocate and initialize new fixed array wrapper */ if (NULL == (fa = H5FA__new(f, fa_addr, TRUE, ctx_udata))) - H5E_THROW(H5E_CANTINIT, "allocation and/or initialization failed for fixed array wrapper") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTINIT, NULL, + "allocation and/or initialization failed for fixed array wrapper") /* Set the return value */ ret_value = fa; - CATCH - +done: if (!ret_value) if (fa && H5FA_close(fa) < 0) - H5E_THROW(H5E_CLOSEERROR, "unable to close fixed array") + HDONE_ERROR(H5E_FARRAY, H5E_CLOSEERROR, NULL, "unable to close fixed array") -END_FUNC(PRIV) /* end H5FA_open() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA_open() */ /*------------------------------------------------------------------------- * Function: H5FA_get_nelmts @@ -254,20 +258,20 @@ END_FUNC(PRIV) /* end H5FA_open() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5FA_get_nelmts(const H5FA_t *fa, hsize_t *nelmts)) - - /* Local variables */ +herr_t +H5FA_get_nelmts(const H5FA_t *fa, hsize_t *nelmts) +{ + FUNC_ENTER_NOAPI_NOERR - /* - * Check arguments. - */ + /* Check arguments */ HDassert(fa); HDassert(nelmts); /* Retrieve the current number of elements in the fixed array */ *nelmts = fa->hdr->stats.nelmts; -END_FUNC(PRIV) /* end H5FA_get_nelmts() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA_get_nelmts() */ /*------------------------------------------------------------------------- * Function: H5FA_get_addr @@ -281,13 +285,12 @@ END_FUNC(PRIV) /* end H5FA_get_nelmts() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5FA_get_addr(const H5FA_t *fa, haddr_t *addr)) - - /* Local variables */ +herr_t +H5FA_get_addr(const H5FA_t *fa, haddr_t *addr) +{ + FUNC_ENTER_NOAPI_NOERR - /* - * Check arguments. - */ + /* Check arguments */ HDassert(fa); HDassert(fa->hdr); HDassert(addr); @@ -295,7 +298,8 @@ BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5FA_get_addr(const H5FA_t *fa, hadd /* Retrieve the address of the fixed array's header */ *addr = fa->hdr->addr; -END_FUNC(PRIV) /* end H5FA_get_addr() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA_get_addr() */ /*------------------------------------------------------------------------- * Function: H5FA_set @@ -309,9 +313,9 @@ END_FUNC(PRIV) /* end H5FA_get_addr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_set(const H5FA_t *fa, hsize_t idx, const void *elmt)) - - /* Local variables */ +herr_t +H5FA_set(const H5FA_t *fa, hsize_t idx, const void *elmt) +{ H5FA_hdr_t * hdr = fa->hdr; /* Header for fixed array */ H5FA_dblock_t * dblock = NULL; /* Pointer to fixed array Data block */ H5FA_dblk_page_t *dblk_page = NULL; /* Pointer to fixed array Data block page */ @@ -319,10 +323,11 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_set(const H5FA_t *fa, hsize_t unsigned dblk_page_cache_flags = H5AC__NO_FLAGS_SET; /* Flags to unprotecting FIxed Array Data block page */ hbool_t hdr_dirty = FALSE; /* Whether header information changed */ + herr_t ret_value = SUCCEED; - /* - * Check arguments. - */ + FUNC_ENTER_NOAPI(FAIL) + + /* Check arguments */ HDassert(fa); HDassert(fa->hdr); @@ -334,15 +339,16 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_set(const H5FA_t *fa, hsize_t /* Create the data block */ hdr->dblk_addr = H5FA__dblock_create(hdr, &hdr_dirty); if (!H5F_addr_defined(hdr->dblk_addr)) - H5E_THROW(H5E_CANTCREATE, "unable to create fixed array data block") - } /* end if */ + HGOTO_ERROR(H5E_FARRAY, H5E_CANTCREATE, FAIL, "unable to create fixed array data block") + } HDassert(idx < hdr->cparam.nelmts); /* Protect data block */ if (NULL == (dblock = H5FA__dblock_protect(hdr, 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) + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect fixed array data block, address = %llu", + (unsigned long long)hdr->dblk_addr) /* Check for paging data block */ if (!dblock->npages) { @@ -375,7 +381,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_set(const H5FA_t *fa, hsize_t if (!H5VM_bit_get(dblock->dblk_page_init, page_idx)) { /* Create the data block page */ if (H5FA__dblk_page_create(hdr, dblk_page_addr, dblk_page_nelmts) < 0) - H5E_THROW(H5E_CANTCREATE, "unable to create data block page") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTCREATE, FAIL, "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); @@ -385,8 +391,9 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_set(const H5FA_t *fa, hsize_t /* Protect the data block page */ if (NULL == (dblk_page = H5FA__dblk_page_protect(hdr, dblk_page_addr, dblk_page_nelmts, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block page, address = %llu", - (unsigned long long)dblk_page_addr) + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect fixed array data block page, address = %llu", + (unsigned long long)dblk_page_addr) /* Set the element in the data block page */ H5MM_memcpy(((uint8_t *)dblk_page->elmts) + (hdr->cparam.cls->nat_elmt_size * elmt_idx), elmt, @@ -394,19 +401,20 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_set(const H5FA_t *fa, hsize_t dblk_page_cache_flags |= H5AC__DIRTIED_FLAG; } /* end else */ - CATCH +done: /* Check for header modified */ if (hdr_dirty) if (H5FA__hdr_modified(hdr) < 0) - H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark fixed array header as modified") + HDONE_ERROR(H5E_FARRAY, H5E_CANTMARKDIRTY, FAIL, "unable to mark fixed array header as modified") /* Release resources */ if (dblock && H5FA__dblock_unprotect(dblock, dblock_cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array data block") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array data block") if (dblk_page && H5FA__dblk_page_unprotect(dblk_page, dblk_page_cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array data block page") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array data block page") -END_FUNC(PRIV) /* end H5FA_set() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA_set() */ /*------------------------------------------------------------------------- * Function: H5FA_get @@ -420,16 +428,17 @@ END_FUNC(PRIV) /* end H5FA_set() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_get(const H5FA_t *fa, hsize_t idx, void *elmt)) - - /* Local variables */ +herr_t +H5FA_get(const H5FA_t *fa, hsize_t idx, void *elmt) +{ H5FA_hdr_t * hdr = fa->hdr; /* Header for FA */ H5FA_dblock_t * dblock = NULL; /* Pointer to data block for FA */ H5FA_dblk_page_t *dblk_page = NULL; /* Pointer to data block page for FA */ + herr_t ret_value = SUCCEED; - /* - * Check arguments. - */ + FUNC_ENTER_NOAPI(FAIL) + + /* Check arguments */ HDassert(fa); HDassert(fa->hdr); @@ -440,14 +449,15 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_get(const H5FA_t *fa, hsize_t if (!H5F_addr_defined(hdr->dblk_addr)) { /* Call the class's 'fill' callback */ if ((hdr->cparam.cls->fill)(elmt, (size_t)1) < 0) - H5E_THROW(H5E_CANTSET, "can't set element to class's fill value") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTSET, FAIL, "can't set element to class's fill value") } /* end if */ else { /* Get the data block */ HDassert(H5F_addr_defined(hdr->dblk_addr)); if (NULL == (dblock = H5FA__dblock_protect(hdr, hdr->dblk_addr, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block, address = %llu", - (unsigned long long)hdr->dblk_addr) + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect fixed array data block, address = %llu", + (unsigned long long)hdr->dblk_addr) /* Check for paged data block */ if (!dblock->npages) @@ -464,10 +474,10 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_get(const H5FA_t *fa, hsize_t if (!H5VM_bit_get(dblock->dblk_page_init, page_idx)) { /* Call the class's 'fill' callback */ if ((hdr->cparam.cls->fill)(elmt, (size_t)1) < 0) - H5E_THROW(H5E_CANTSET, "can't set element to class's fill value") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTSET, FAIL, "can't set element to class's fill value") /* We've retrieved the value, leave now */ - H5_LEAVE(SUCCEED) + HGOTO_DONE(SUCCEED) } /* end if */ else { /* get the page */ size_t dblk_page_nelmts; /* # of elements in a data block page */ @@ -490,9 +500,9 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_get(const H5FA_t *fa, hsize_t /* Protect the data block page */ if (NULL == (dblk_page = H5FA__dblk_page_protect(hdr, 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) + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect fixed array data block page, address = %llu", + (unsigned long long)dblk_page_addr) /* Retrieve element from data block */ H5MM_memcpy(elmt, ((uint8_t *)dblk_page->elmts) + (hdr->cparam.cls->nat_elmt_size * elmt_idx), @@ -501,13 +511,14 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_get(const H5FA_t *fa, hsize_t } /* end else */ } /* end else */ - CATCH +done: if (dblock && H5FA__dblock_unprotect(dblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array data block") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array data block") if (dblk_page && H5FA__dblk_page_unprotect(dblk_page, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array data block page") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array data block page") -END_FUNC(PRIV) /* end H5FA_get() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA_get() */ /*------------------------------------------------------------------------- * Function: H5FA_close @@ -521,18 +532,19 @@ END_FUNC(PRIV) /* end H5FA_get() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_close(H5FA_t *fa)) - - /* Local variables */ +herr_t +H5FA_close(H5FA_t *fa) +{ hbool_t pending_delete = FALSE; /* Whether the array is pending deletion */ haddr_t fa_addr = HADDR_UNDEF; /* Address of array (for deletion) */ + herr_t ret_value = SUCCEED; - /* - * Check arguments. - */ + FUNC_ENTER_NOAPI(FAIL) + + /* Check arguments */ HDassert(fa); - /* Close the header, if it was set */ + /* Close the header if it was set */ if (fa->hdr) { /* Decrement file reference & check if this is the last open fixed array using the shared array header */ @@ -562,7 +574,8 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_close(H5FA_t *fa)) /* Check the header's status in the metadata cache */ if (H5AC_get_entry_status(fa->f, fa_addr, &hdr_status) < 0) - H5E_THROW(H5E_CANTGET, "unable to check metadata cache status for fixed array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTGET, FAIL, + "unable to check metadata cache status for fixed array header") /* Sanity checks on header */ HDassert(hdr_status & H5AC_ES__IN_CACHE); @@ -574,7 +587,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_close(H5FA_t *fa)) /* Lock the array header into memory */ /* (OK to pass in NULL for callback context, since we know the header must be in the cache) */ if (NULL == (hdr = H5FA__hdr_protect(fa->f, fa_addr, NULL, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTLOAD, "unable to load fixed array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTLOAD, FAIL, "unable to load fixed array header") /* Set the shared array header's file context for this operation */ hdr->f = fa->f; @@ -584,11 +597,12 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_close(H5FA_t *fa)) * immediately -QAK) */ if (H5FA__hdr_decr(fa->hdr) < 0) - H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTDEC, FAIL, + "can't decrement reference count on shared array header") /* Delete array, starting with header (unprotects header) */ if (H5FA__hdr_delete(hdr) < 0) - H5E_THROW(H5E_CANTDELETE, "unable to delete fixed array") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTDELETE, FAIL, "unable to delete fixed array") } /* end if */ else { /* Decrement the reference count on the array header */ @@ -596,16 +610,17 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_close(H5FA_t *fa)) * immediately -QAK) */ if (H5FA__hdr_decr(fa->hdr) < 0) - H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTDEC, FAIL, + "can't decrement reference count on shared array header") } /* end else */ } /* end if */ /* Release the fixed array wrapper */ fa = H5FL_FREE(H5FA_t, fa); - CATCH - -END_FUNC(PRIV) /* end H5FA_close() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA_close() */ /*------------------------------------------------------------------------- * Function: H5FA_delete @@ -619,21 +634,22 @@ END_FUNC(PRIV) /* end H5FA_close() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_delete(H5F_t *f, haddr_t fa_addr, void *ctx_udata)) +herr_t +H5FA_delete(H5F_t *f, haddr_t fa_addr, void *ctx_udata) +{ + H5FA_hdr_t *hdr = NULL; /* The fixed array header information */ + herr_t ret_value = SUCCEED; - /* Local variables */ - H5FA_hdr_t *hdr = NULL; /* The fixed array header information */ + FUNC_ENTER_NOAPI(FAIL) - /* - * Check arguments. - */ + /* Check arguments */ HDassert(f); HDassert(H5F_addr_defined(fa_addr)); /* Lock the array header into memory */ if (NULL == (hdr = H5FA__hdr_protect(f, fa_addr, ctx_udata, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array header, address = %llu", - (unsigned long long)fa_addr) + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPROTECT, FAIL, "unable to protect fixed array header, address = %llu", + (unsigned long long)fa_addr) /* Check for files using shared array header */ if (hdr->file_rc) @@ -644,17 +660,17 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_delete(H5F_t *f, haddr_t fa_ad /* Delete array now, starting with header (unprotects header) */ if (H5FA__hdr_delete(hdr) < 0) - H5E_THROW(H5E_CANTDELETE, "unable to delete fixed array") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTDELETE, FAIL, "unable to delete fixed array") hdr = NULL; - } /* end if */ - - CATCH + } - /* Unprotect the header, if an error occurred */ +done: + /* Unprotect the header if an error occurred */ if (hdr && H5FA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array header") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array header") -END_FUNC(PRIV) /* end H5FA_delete() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA_delete() */ /*------------------------------------------------------------------------- * Function: H5FA_iterate @@ -671,44 +687,44 @@ END_FUNC(PRIV) /* end H5FA_delete() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, int, H5_ITER_CONT, H5_ITER_ERROR, - H5FA_iterate(H5FA_t *fa, H5FA_operator_t op, void *udata)) - - /* Local variables */ +int +H5FA_iterate(H5FA_t *fa, H5FA_operator_t op, void *udata) +{ uint8_t *elmt = NULL; hsize_t u; - int cb_ret = H5_ITER_CONT; /* Return value from callback */ + int ret_value = H5_ITER_CONT; - /* - * Check arguments. - */ + FUNC_ENTER_NOAPI(H5_ITER_ERROR) + + /* Check arguments */ HDassert(fa); HDassert(op); HDassert(udata); /* Allocate space for a native 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") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, H5_ITER_ERROR, + "memory allocation failed for fixed array element") /* Iterate over all elements in array */ - for (u = 0; u < fa->hdr->stats.nelmts && cb_ret == H5_ITER_CONT; u++) { + for (u = 0; u < fa->hdr->stats.nelmts && ret_value == H5_ITER_CONT; u++) { /* Get array element */ if (H5FA_get(fa, u, elmt) < 0) - H5E_THROW(H5E_CANTGET, "unable to delete fixed array") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTGET, H5_ITER_ERROR, "unable to delete fixed array") - /* Make callback */ - if ((cb_ret = (*op)(u, elmt, udata)) < 0) { - H5E_PRINTF(H5E_BADITER, "iterator function failed"); - H5_LEAVE(cb_ret) - } /* end if */ - } /* end for */ - - CATCH + /* Invoke callback */ + if ((ret_value = (*op)(u, elmt, udata)) < 0) { + HERROR(H5E_FARRAY, H5E_BADITER, "iteration callback error"); + break; + } + } +done: if (elmt) elmt = H5FL_BLK_FREE(fa_native_elmt, elmt); -END_FUNC(PRIV) /* end H5FA_iterate() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA_iterate() */ /*------------------------------------------------------------------------- * Function: H5FA_depend @@ -723,14 +739,15 @@ END_FUNC(PRIV) /* end H5FA_iterate() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_depend(H5FA_t *fa, H5AC_proxy_entry_t *parent)) +herr_t +H5FA_depend(H5FA_t *fa, H5AC_proxy_entry_t *parent) +{ + H5FA_hdr_t *hdr = fa->hdr; /* Header for FA */ + herr_t ret_value = SUCCEED; - /* Local variables */ - H5FA_hdr_t *hdr = fa->hdr; /* Header for FA */ + FUNC_ENTER_NOAPI(FAIL) - /* - * Check arguments. - */ + /* Check arguments */ HDassert(fa); HDassert(hdr); HDassert(parent); @@ -749,13 +766,13 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_depend(H5FA_t *fa, H5AC_proxy_ /* Add the fixed array as a child of the parent (proxy) */ if (H5AC_proxy_entry_add_child(parent, hdr->f, hdr->top_proxy) < 0) - H5E_THROW(H5E_CANTSET, "unable to add fixed array as child of proxy") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTSET, FAIL, "unable to add fixed array as child of proxy") hdr->parent = parent; - } /* end if */ - - CATCH + } -END_FUNC(PRIV) /* end H5FA_depend() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA_depend() */ /*------------------------------------------------------------------------- * Function: H5FA_patch_file @@ -769,17 +786,17 @@ END_FUNC(PRIV) /* end H5FA_depend() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5FA_patch_file(H5FA_t *fa, H5F_t *f)) +herr_t +H5FA_patch_file(H5FA_t *fa, H5F_t *f) +{ + FUNC_ENTER_NOAPI_NOERR - /* Local variables */ - - /* - * Check arguments. - */ + /* Check arguments */ HDassert(fa); HDassert(f); if (fa->f != f || fa->hdr->f != f) fa->f = fa->hdr->f = f; -END_FUNC(PRIV) /* end H5FA_patch_file() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA_patch_file() */ diff --git a/src/H5FAcache.c b/src/H5FAcache.c index 171f4e8..6975d3d 100644 --- a/src/H5FAcache.c +++ b/src/H5FAcache.c @@ -170,12 +170,13 @@ const H5AC_class_t H5AC_FARRAY_DBLK_PAGE[1] = {{ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5FA__cache_hdr_get_initial_load_size(void *_udata, size_t *image_len)) - - /* Local variables */ +static herr_t +H5FA__cache_hdr_get_initial_load_size(void *_udata, size_t *image_len) +{ H5FA_hdr_cache_ud_t *udata = (H5FA_hdr_cache_ud_t *)_udata; /* User data for callback */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(udata); HDassert(udata->f); @@ -184,7 +185,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Set the image length size */ *image_len = (size_t)H5FA_HEADER_SIZE_FILE(udata->f); -END_FUNC(STATIC) /* end H5FA__cache_hdr_get_initial_load_size() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA__cache_hdr_get_initial_load_size() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_hdr_verify_chksum @@ -199,13 +201,15 @@ END_FUNC(STATIC) /* end H5FA__cache_hdr_get_initial_load_size() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, - H5FA__cache_hdr_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata)) - - /* Local variables */ +static htri_t +H5FA__cache_hdr_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata) +{ const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ uint32_t computed_chksum; /* Computed metadata checksum value */ + htri_t ret_value = TRUE; + + FUNC_ENTER_STATIC_NOERR /* Check arguments */ HDassert(image); @@ -216,7 +220,8 @@ BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, if (stored_chksum != computed_chksum) ret_value = FALSE; -END_FUNC(STATIC) /* end H5FA__cache_hdr_verify_chksum() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__cache_hdr_verify_chksum() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_hdr_deserialize @@ -231,16 +236,18 @@ END_FUNC(STATIC) /* end H5FA__cache_hdr_verify_chksum() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, - H5FA__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, - hbool_t H5_ATTR_UNUSED *dirty)) - - /* Local variables */ +static void * +H5FA__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, + hbool_t H5_ATTR_UNUSED *dirty) +{ H5FA_cls_id_t id; /* ID of fixed array class, as found in file */ H5FA_hdr_t * hdr = NULL; /* Fixed array info */ H5FA_hdr_cache_ud_t *udata = (H5FA_hdr_cache_ud_t *)_udata; const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ + void * ret_value = NULL; + + FUNC_ENTER_STATIC /* Check arguments */ HDassert(udata); @@ -249,24 +256,24 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* 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") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, NULL, "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) != 0) - H5E_THROW(H5E_BADVALUE, "wrong fixed array header signature") + HGOTO_ERROR(H5E_FARRAY, H5E_BADVALUE, NULL, "wrong fixed array header signature") image += H5_SIZEOF_MAGIC; /* Version */ if (*image++ != H5FA_HDR_VERSION) - H5E_THROW(H5E_VERSION, "wrong fixed array header version") + HGOTO_ERROR(H5E_FARRAY, H5E_VERSION, NULL, "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") + HGOTO_ERROR(H5E_FARRAY, H5E_BADTYPE, NULL, "incorrect fixed array class") hdr->cparam.cls = H5FA_client_class_g[id]; /* General array creation/configuration information */ @@ -314,20 +321,20 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Finish initializing fixed array header */ if (H5FA__hdr_init(hdr, udata->ctx_udata) < 0) - H5E_THROW(H5E_CANTINIT, "initialization failed for fixed array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTINIT, NULL, "initialization failed for fixed array header") HDassert(hdr->size == len); /* Set return value */ ret_value = hdr; - CATCH - +done: /* Release resources */ if (!ret_value) if (hdr && H5FA__hdr_dest(hdr) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy fixed array header") + HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, NULL, "unable to destroy fixed array header") -END_FUNC(STATIC) /* end H5FA__cache_hdr_deserialize() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__cache_hdr_deserialize() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_hdr_image_len @@ -341,12 +348,13 @@ END_FUNC(STATIC) /* end H5FA__cache_hdr_deserialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5FA__cache_hdr_image_len(const void *_thing, size_t *image_len)) - - /* Local variables */ +static herr_t +H5FA__cache_hdr_image_len(const void *_thing, size_t *image_len) +{ const H5FA_hdr_t *hdr = (const H5FA_hdr_t *)_thing; /* Pointer to the object */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(hdr); HDassert(image_len); @@ -354,7 +362,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Set the image length size */ *image_len = hdr->size; -END_FUNC(STATIC) /* end H5FA__cache_hdr_image_len() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA__cache_hdr_image_len() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_hdr_serialize @@ -368,15 +377,16 @@ END_FUNC(STATIC) /* end H5FA__cache_hdr_image_len() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5FA__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, void *_thing)) - - /* Local variables */ +static herr_t +H5FA__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, void *_thing) +{ H5FA_hdr_t *hdr = (H5FA_hdr_t *)_thing; /* Pointer to the fixed array header */ uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t metadata_chksum; /* Computed metadata checksum value */ - /* check arguments */ + FUNC_ENTER_STATIC_NOERR + + /* Check arguments */ HDassert(f); HDassert(image); HDassert(hdr); @@ -413,7 +423,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Sanity check */ HDassert((size_t)(image - (uint8_t *)_image) == len); -END_FUNC(STATIC) /* end H5FA__cache_hdr_serialize() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA__cache_hdr_serialize() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_hdr_notify @@ -427,11 +438,13 @@ END_FUNC(STATIC) /* end H5FA__cache_hdr_serialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, - H5FA__cache_hdr_notify(H5AC_notify_action_t action, void *_thing)) +static herr_t +H5FA__cache_hdr_notify(H5AC_notify_action_t action, void *_thing) +{ + H5FA_hdr_t *hdr = (H5FA_hdr_t *)_thing; /* Pointer to the object */ + herr_t ret_value = SUCCEED; - /* Local variables */ - H5FA_hdr_t *hdr = (H5FA_hdr_t *)_thing; /* Pointer to the object */ + FUNC_ENTER_STATIC /* Sanity check */ HDassert(hdr); @@ -463,16 +476,16 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Destroy flush dependency on object header proxy */ if (H5AC_proxy_entry_remove_child((H5AC_proxy_entry_t *)hdr->parent, (void *)hdr->top_proxy) < 0) - H5E_THROW(H5E_CANTUNDEPEND, - "unable to destroy flush dependency between fixed array and proxy") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between fixed array and proxy") hdr->parent = NULL; } /* end if */ /* Detach from 'top' proxy for fixed array */ if (hdr->top_proxy) { if (H5AC_proxy_entry_remove_child(hdr->top_proxy, hdr) < 0) - H5E_THROW( - H5E_CANTUNDEPEND, + HGOTO_ERROR( + H5E_FARRAY, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency between header and fixed array 'top' proxy") /* Don't reset hdr->top_proxy here, it's destroyed when the header is freed -QAK */ } /* end if */ @@ -480,7 +493,7 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, default: #ifdef NDEBUG - H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") + HGOTO_ERROR(H5E_FARRAY, H5E_BADVALUE, FAIL, "unknown action from metadata cache") #else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); #endif /* NDEBUG */ @@ -489,9 +502,10 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, else HDassert(NULL == hdr->parent); - CATCH +done: -END_FUNC(STATIC) /* end H5FA__cache_hdr_notify() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__cache_hdr_notify() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_hdr_free_icr @@ -506,18 +520,23 @@ END_FUNC(STATIC) /* end H5FA__cache_hdr_notify() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5FA__cache_hdr_free_icr(void *thing)) +static herr_t +H5FA__cache_hdr_free_icr(void *thing) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC /* Check arguments */ HDassert(thing); /* Release the extensible array header */ if (H5FA__hdr_dest((H5FA_hdr_t *)thing) < 0) - H5E_THROW(H5E_CANTFREE, "can't free fixed array header") - - CATCH + HGOTO_ERROR(H5E_FARRAY, H5E_CANTFREE, FAIL, "can't free fixed array header") -END_FUNC(STATIC) /* end H5FA__cache_hdr_free_icr() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__cache_hdr_free_icr() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_dblock_get_initial_load_size @@ -531,14 +550,15 @@ END_FUNC(STATIC) /* end H5FA__cache_hdr_free_icr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5FA__cache_dblock_get_initial_load_size(void *_udata, size_t *image_len)) - - /* Local variables */ +static herr_t +H5FA__cache_dblock_get_initial_load_size(void *_udata, size_t *image_len) +{ H5FA_dblock_cache_ud_t *udata = (H5FA_dblock_cache_ud_t *)_udata; /* User data */ H5FA_dblock_t dblock; /* Fake data block for computing size */ size_t dblk_page_nelmts; /* # of elements per data block page */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(udata); HDassert(udata->hdr); @@ -567,7 +587,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, else *image_len = (size_t)H5FA_DBLOCK_PREFIX_SIZE(&dblock); -END_FUNC(STATIC) /* end H5FA__cache_dblock_get_initial_load_size() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA__cache_dblock_get_initial_load_size() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_dblock_verify_chksum @@ -582,13 +603,15 @@ END_FUNC(STATIC) /* end H5FA__cache_dblock_get_initial_load_size() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, - H5FA__cache_dblock_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata)) - - /* Local variables */ +static htri_t +H5FA__cache_dblock_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata) +{ const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ uint32_t computed_chksum; /* Computed metadata checksum value */ + htri_t ret_value = TRUE; + + FUNC_ENTER_STATIC_NOERR /* Check arguments */ HDassert(image); @@ -599,7 +622,8 @@ BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, if (stored_chksum != computed_chksum) ret_value = FALSE; -END_FUNC(STATIC) /* end H5FA__cache_dblock_verify_chksum() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__cache_dblock_verify_chksum() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_dblock_deserialize @@ -614,16 +638,18 @@ END_FUNC(STATIC) /* end H5FA__cache_dblock_verify_chksum() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, - H5FA__cache_dblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, - hbool_t H5_ATTR_UNUSED *dirty)) - - /* Local variables */ +static void * +H5FA__cache_dblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, + hbool_t H5_ATTR_UNUSED *dirty) +{ H5FA_dblock_t * dblock = NULL; /* Data block info */ H5FA_dblock_cache_ud_t *udata = (H5FA_dblock_cache_ud_t *)_udata; /* User data for loading data block */ const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ haddr_t arr_addr; /* Address of array header in the file */ + void * ret_value = NULL; + + FUNC_ENTER_STATIC /* Sanity check */ HDassert(udata); @@ -631,7 +657,7 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* 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") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, NULL, "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))); @@ -641,27 +667,27 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Magic number */ if (HDmemcmp(image, H5FA_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC) != 0) - H5E_THROW(H5E_BADVALUE, "wrong fixed array data block signature") + HGOTO_ERROR(H5E_FARRAY, H5E_BADVALUE, NULL, "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") + HGOTO_ERROR(H5E_FARRAY, H5E_VERSION, NULL, "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") + HGOTO_ERROR(H5E_FARRAY, H5E_BADTYPE, NULL, "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") + HGOTO_ERROR(H5E_FARRAY, H5E_BADVALUE, NULL, "wrong fixed array header address") /* Page initialization flags */ if (dblock->npages > 0) { H5MM_memcpy(dblock->dblk_page_init, image, dblock->dblk_page_init_size); image += dblock->dblk_page_init_size; - } /* end if */ + } /* Only decode elements if the data block is not paged */ if (!dblock->npages) { @@ -669,9 +695,9 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Convert from raw elements on disk into native elements in memory */ if ((udata->hdr->cparam.cls->decode)(image, dblock->elmts, (size_t)udata->hdr->cparam.nelmts, udata->hdr->cb_ctx) < 0) - H5E_THROW(H5E_CANTDECODE, "can't decode fixed array data elements") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTDECODE, NULL, "can't decode fixed array data elements") image += (udata->hdr->cparam.nelmts * udata->hdr->cparam.raw_elmt_size); - } /* end if */ + } /* Sanity check */ /* (allow for checksum not decoded yet) */ @@ -691,14 +717,14 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Set return value */ ret_value = dblock; - CATCH - +done: /* Release resources */ if (!ret_value) if (dblock && H5FA__dblock_dest(dblock) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy fixed array data block") + HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, NULL, "unable to destroy fixed array data block") -END_FUNC(STATIC) /* end H5FA__cache_dblock_deserialize() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__cache_dblock_deserialize() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_dblock_image_len @@ -712,12 +738,13 @@ END_FUNC(STATIC) /* end H5FA__cache_dblock_deserialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5FA__cache_dblock_image_len(const void *_thing, size_t *image_len)) - - /* Local variables */ +static herr_t +H5FA__cache_dblock_image_len(const void *_thing, size_t *image_len) +{ const H5FA_dblock_t *dblock = (const H5FA_dblock_t *)_thing; /* Pointer to the object */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(dblock); HDassert(image_len); @@ -728,7 +755,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, else *image_len = H5FA_DBLOCK_PREFIX_SIZE(dblock); -END_FUNC(STATIC) /* end H5FA__cache_dblock_image_len() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA__cache_dblock_image_len() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_dblock_serialize @@ -742,14 +770,15 @@ END_FUNC(STATIC) /* end H5FA__cache_dblock_image_len() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, - H5FA__cache_dblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, - void *_thing)) - - /* Local variables */ +static herr_t +H5FA__cache_dblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, void *_thing) +{ H5FA_dblock_t *dblock = (H5FA_dblock_t *)_thing; /* Pointer to the object to serialize */ uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t metadata_chksum; /* Computed metadata checksum value */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC /* Check arguments */ HDassert(f); @@ -776,7 +805,7 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Store the 'page init' bitmasks */ H5MM_memcpy(image, dblock->dblk_page_init, dblock->dblk_page_init_size); image += dblock->dblk_page_init_size; - } /* end if */ + } /* Only encode elements if the data block is not paged */ if (!dblock->npages) { @@ -786,9 +815,9 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5_CHECK_OVERFLOW(dblock->hdr->cparam.nelmts, /* From: */ hsize_t, /* To: */ size_t); if ((dblock->hdr->cparam.cls->encode)(image, dblock->elmts, (size_t)dblock->hdr->cparam.nelmts, dblock->hdr->cb_ctx) < 0) - H5E_THROW(H5E_CANTENCODE, "can't encode fixed array data elements") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTENCODE, FAIL, "can't encode fixed array data elements") image += (dblock->hdr->cparam.nelmts * dblock->hdr->cparam.raw_elmt_size); - } /* end if */ + } /* Compute metadata checksum */ metadata_chksum = H5_checksum_metadata(_image, (size_t)(image - (uint8_t *)_image), 0); @@ -799,9 +828,9 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Sanity check */ HDassert((size_t)(image - (uint8_t *)_image) == len); - CATCH - -END_FUNC(STATIC) /* end H5FA__cache_dblock_serialize() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__cache_dblock_serialize() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_dblock_notify @@ -815,11 +844,13 @@ END_FUNC(STATIC) /* end H5FA__cache_dblock_serialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, - H5FA__cache_dblock_notify(H5AC_notify_action_t action, void *_thing)) +static herr_t +H5FA__cache_dblock_notify(H5AC_notify_action_t action, void *_thing) +{ + H5FA_dblock_t *dblock = (H5FA_dblock_t *)_thing; + herr_t ret_value = SUCCEED; - /* Local variables */ - H5FA_dblock_t *dblock = (H5FA_dblock_t *)_thing; + FUNC_ENTER_STATIC /* Sanity check */ HDassert(dblock); @@ -832,8 +863,8 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, case H5AC_NOTIFY_ACTION_AFTER_LOAD: /* Create flush dependency on parent */ if (H5FA__create_flush_depend((H5AC_info_t *)dblock->hdr, (H5AC_info_t *)dblock) < 0) - H5E_THROW( - H5E_CANTDEPEND, + HGOTO_ERROR( + H5E_FARRAY, H5E_CANTDEPEND, FAIL, "unable to create flush dependency between data block and header, address = %llu", (unsigned long long)dblock->addr) break; @@ -845,35 +876,35 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, case H5AC_NOTIFY_ACTION_CHILD_CLEANED: case H5AC_NOTIFY_ACTION_CHILD_UNSERIALIZED: case H5AC_NOTIFY_ACTION_CHILD_SERIALIZED: - /* do nothing */ break; case H5AC_NOTIFY_ACTION_BEFORE_EVICT: /* Destroy flush dependency on parent */ if (H5FA__destroy_flush_depend((H5AC_info_t *)dblock->hdr, (H5AC_info_t *)dblock) < 0) - H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") /* Detach from 'top' proxy for fixed array */ if (dblock->top_proxy) { if (H5AC_proxy_entry_remove_child(dblock->top_proxy, dblock) < 0) - H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between data block " - "and fixed array 'top' proxy") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between data block " + "and fixed array 'top' proxy") dblock->top_proxy = NULL; - } /* end if */ + } break; default: #ifdef NDEBUG - H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") -#else /* NDEBUG */ + HGOTO_ERROR(H5E_FARRAY, H5E_BADVALUE, FAIL, "unknown action from metadata cache") +#else HDassert(0 && "Unknown action?!?"); -#endif /* NDEBUG */ +#endif } /* end switch */ } /* end if */ - CATCH - -END_FUNC(STATIC) /* end H5FA__cache_dblock_notify() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__cache_dblock_notify() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_dblock_free_icr @@ -888,20 +919,24 @@ END_FUNC(STATIC) /* end H5FA__cache_dblock_notify() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5FA__cache_dblock_free_icr(void *_thing)) +static herr_t +H5FA__cache_dblock_free_icr(void *_thing) +{ + H5FA_dblock_t *dblock = (H5FA_dblock_t *)_thing; /* Pointer to the object */ + herr_t ret_value = SUCCEED; - H5FA_dblock_t *dblock = (H5FA_dblock_t *)_thing; /* Pointer to the object */ + FUNC_ENTER_STATIC /* Check arguments */ HDassert(dblock); /* Release the fixed array data block */ if (H5FA__dblock_dest(dblock) < 0) - H5E_THROW(H5E_CANTFREE, "can't free fixed array data block") - - CATCH + HGOTO_ERROR(H5E_FARRAY, H5E_CANTFREE, FAIL, "can't free fixed array data block") -END_FUNC(STATIC) /* end H5FA__cache_dblock_free_icr() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__cache_dblock_free_icr() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_dblock_fsf_size @@ -932,11 +967,13 @@ END_FUNC(STATIC) /* end H5FA__cache_dblock_free_icr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5FA__cache_dblock_fsf_size(const void *_thing, hsize_t *fsf_size)) - +static herr_t +H5FA__cache_dblock_fsf_size(const void *_thing, hsize_t *fsf_size) +{ const H5FA_dblock_t *dblock = (const H5FA_dblock_t *)_thing; /* Pointer to the object */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(dblock); HDassert(dblock->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); @@ -945,7 +982,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, *fsf_size = dblock->size; -END_FUNC(STATIC) /* end H5FA__cache_dblock_fsf_size() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA__cache_dblock_fsf_size() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_dblk_page_get_initial_load_size @@ -959,12 +997,13 @@ END_FUNC(STATIC) /* end H5FA__cache_dblock_fsf_size() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5FA__cache_dblk_page_get_initial_load_size(void *_udata, size_t *image_len)) - - /* Local variables */ +static herr_t +H5FA__cache_dblk_page_get_initial_load_size(void *_udata, size_t *image_len) +{ H5FA_dblk_page_cache_ud_t *udata = (H5FA_dblk_page_cache_ud_t *)_udata; /* User data */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(udata); HDassert(udata->hdr); @@ -974,7 +1013,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Set the image length size */ *image_len = (size_t)H5FA_DBLK_PAGE_SIZE(udata->hdr, udata->nelmts); -END_FUNC(STATIC) /* end H5FA__cache_dblk_page_get_initial_load_size() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA__cache_dblk_page_get_initial_load_size() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_dblk_page_verify_chksum @@ -989,13 +1029,15 @@ END_FUNC(STATIC) /* end H5FA__cache_dblk_page_get_initial_load_size() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, - H5FA__cache_dblk_page_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata)) - - /* Local variables */ +static htri_t +H5FA__cache_dblk_page_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata) +{ const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ uint32_t computed_chksum; /* Computed metadata checksum value */ + htri_t ret_value = TRUE; + + FUNC_ENTER_STATIC_NOERR /* Check arguments */ HDassert(image); @@ -1006,7 +1048,8 @@ BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, if (stored_chksum != computed_chksum) ret_value = FALSE; -END_FUNC(STATIC) /* end H5FA__cache_dblk_page_verify_chksum() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__cache_dblk_page_verify_chksum() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_dblk_page_deserialize @@ -1021,18 +1064,19 @@ END_FUNC(STATIC) /* end H5FA__cache_dblk_page_verify_chksum() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, - H5FA__cache_dblk_page_deserialize(const void *_image, size_t len, void *_udata, - hbool_t H5_ATTR_UNUSED *dirty)) - - /* Local variables */ +static void * +H5FA__cache_dblk_page_deserialize(const void *_image, size_t len, void *_udata, hbool_t H5_ATTR_UNUSED *dirty) +{ H5FA_dblk_page_t * dblk_page = NULL; /* Data block page info */ H5FA_dblk_page_cache_ud_t *udata = (H5FA_dblk_page_cache_ud_t *)_udata; /* User data for loading data block page */ const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ + void * ret_value = NULL; /* Sanity check */ + FUNC_ENTER_STATIC + HDassert(udata); HDassert(udata->hdr); HDassert(udata->nelmts > 0); @@ -1040,7 +1084,8 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Allocate the fixed array data block page */ if (NULL == (dblk_page = H5FA__dblk_page_alloc(udata->hdr, udata->nelmts))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array data block page") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for fixed array data block page") /* Set the fixed array data block's information */ dblk_page->addr = udata->dblk_page_addr; @@ -1050,7 +1095,7 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Decode elements in data block page */ /* Convert from raw elements on disk into native elements in memory */ if ((udata->hdr->cparam.cls->decode)(image, dblk_page->elmts, udata->nelmts, udata->hdr->cb_ctx) < 0) - H5E_THROW(H5E_CANTDECODE, "can't decode fixed array data elements") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTDECODE, NULL, "can't decode fixed array data elements") image += (udata->nelmts * udata->hdr->cparam.raw_elmt_size); /* Sanity check */ @@ -1071,14 +1116,15 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Set return value */ ret_value = dblk_page; - CATCH +done: /* Release resources */ if (!ret_value) if (dblk_page && H5FA__dblk_page_dest(dblk_page) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy fixed array data block page") + HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, NULL, "unable to destroy fixed array data block page") -END_FUNC(STATIC) /* end H5FA__cache_dblk_page_deserialize() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__cache_dblk_page_deserialize() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_dblk_page_image_len @@ -1092,12 +1138,13 @@ END_FUNC(STATIC) /* end H5FA__cache_dblk_page_deserialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5FA__cache_dblk_page_image_len(const void *_thing, size_t *image_len)) - - /* Local variables */ +static herr_t +H5FA__cache_dblk_page_image_len(const void *_thing, size_t *image_len) +{ const H5FA_dblk_page_t *dblk_page = (const H5FA_dblk_page_t *)_thing; /* Pointer to the object */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(dblk_page); HDassert(image_len); @@ -1105,7 +1152,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Set the image length size */ *image_len = dblk_page->size; -END_FUNC(STATIC) /* end H5FA__cache_dblk_page_image_len() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA__cache_dblk_page_image_len() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_dblk_page_serialize @@ -1119,14 +1167,16 @@ END_FUNC(STATIC) /* end H5FA__cache_dblk_page_image_len() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, - H5FA__cache_dblk_page_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *_image, - size_t H5_ATTR_UNUSED len, void *_thing)) - - /* Local variables */ +static herr_t +H5FA__cache_dblk_page_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *_image, size_t H5_ATTR_UNUSED len, + void *_thing) +{ H5FA_dblk_page_t *dblk_page = (H5FA_dblk_page_t *)_thing; /* Pointer to the object to serialize */ uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t metadata_chksum; /* Computed metadata checksum value */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC /* Sanity check */ HDassert(f); @@ -1141,7 +1191,7 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Convert from native elements in memory into raw elements on disk */ if ((dblk_page->hdr->cparam.cls->encode)(image, dblk_page->elmts, dblk_page->nelmts, dblk_page->hdr->cb_ctx) < 0) - H5E_THROW(H5E_CANTENCODE, "can't encode fixed array data elements") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTENCODE, FAIL, "can't encode fixed array data elements") image += (dblk_page->nelmts * dblk_page->hdr->cparam.raw_elmt_size); /* Compute metadata checksum */ @@ -1153,9 +1203,9 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Sanity check */ HDassert((size_t)(image - (uint8_t *)_image) == len); - CATCH - -END_FUNC(STATIC) /* end H5FA__cache_dblk_page_serialize() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__cache_dblk_page_serialize() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_dblk_page_notify @@ -1169,11 +1219,13 @@ END_FUNC(STATIC) /* end H5FA__cache_dblk_page_serialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, - H5FA__cache_dblk_page_notify(H5AC_notify_action_t action, void *_thing)) - - /* Local variables */ +static herr_t +H5FA__cache_dblk_page_notify(H5AC_notify_action_t action, void *_thing) +{ H5FA_dblk_page_t *dblk_page = (H5FA_dblk_page_t *)_thing; /* Pointer to the object */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC /* Sanity check */ HDassert(dblk_page); @@ -1190,8 +1242,9 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Detach from 'top' proxy for fixed array */ if (dblk_page->top_proxy) { if (H5AC_proxy_entry_remove_child(dblk_page->top_proxy, dblk_page) < 0) - H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between data block page " - "and fixed array 'top' proxy") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between data block page " + "and fixed array 'top' proxy") dblk_page->top_proxy = NULL; } /* end if */ break; @@ -1207,15 +1260,15 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, default: #ifdef NDEBUG - H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") + HGOTO_ERROR(H5E_FARRAY, H5E_BADVALUE, FAIL, "unknown action from metadata cache") #else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); #endif /* NDEBUG */ } /* end switch */ - CATCH - -END_FUNC(STATIC) /* end H5FA__cache_dblk_page_notify() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__cache_dblk_page_notify() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_dblk_page_free_icr @@ -1230,15 +1283,20 @@ END_FUNC(STATIC) /* end H5FA__cache_dblk_page_notify() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5FA__cache_dblk_page_free_icr(void *thing)) +static herr_t +H5FA__cache_dblk_page_free_icr(void *thing) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC /* Check arguments */ HDassert(thing); /* Release the fixed array data block page */ if (H5FA__dblk_page_dest((H5FA_dblk_page_t *)thing) < 0) - H5E_THROW(H5E_CANTFREE, "can't free fixed array data block page") - - CATCH + HGOTO_ERROR(H5E_FARRAY, H5E_CANTFREE, FAIL, "can't free fixed array data block page") -END_FUNC(STATIC) /* end H5FA__cache_dblk_page_free_icr() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__cache_dblk_page_free_icr() */ diff --git a/src/H5FAdbg.c b/src/H5FAdbg.c index 8c2c9a8..a69c078 100644 --- a/src/H5FAdbg.c +++ b/src/H5FAdbg.c @@ -79,13 +79,16 @@ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5FA__hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, - const H5FA_class_t *cls, haddr_t obj_addr)) - +herr_t +H5FA__hdr_debug(H5F_t *f, 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 */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(f); @@ -100,11 +103,11 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, if (cls->crt_dbg_ctx) /* Create debugging context */ if (NULL == (dbg_ctx = cls->crt_dbg_ctx(f, obj_addr))) - H5E_THROW(H5E_CANTGET, "unable to create fixed array debugging context") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTGET, FAIL, "unable to create fixed array debugging context") /* Load the fixed array header */ if (NULL == (hdr = H5FA__hdr_protect(f, addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to load fixed array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPROTECT, FAIL, "unable to load fixed array header") /* Print opening message */ HDfprintf(stream, "%*sFixed Array Header...\n", indent, ""); @@ -126,13 +129,14 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, "Fixed Array Data Block Address:", hdr->dblk_addr); - CATCH +done: if (dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) - H5E_THROW(H5E_CANTRELEASE, "unable to release fixed array debugging context") + HDONE_ERROR(H5E_FARRAY, H5E_CANTRELEASE, FAIL, "unable to release fixed array debugging context") if (hdr && H5FA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array header") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array header") -END_FUNC(PKG) /* end H5FA__hdr_debug() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__hdr_debug() */ /*------------------------------------------------------------------------- * Function: H5FA__dblock_debug @@ -146,15 +150,18 @@ END_FUNC(PKG) /* end H5FA__hdr_debug() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5FA__dblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, - const H5FA_class_t *cls, haddr_t hdr_addr, haddr_t obj_addr)) - +herr_t +H5FA__dblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, const H5FA_class_t *cls, + haddr_t hdr_addr, haddr_t obj_addr) +{ /* 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 */ - size_t u; /* Local index variable */ + 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 */ + size_t u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(f); @@ -170,16 +177,16 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, if (cls->crt_dbg_ctx) /* Create debugging context */ if (NULL == (dbg_ctx = cls->crt_dbg_ctx(f, obj_addr))) - H5E_THROW(H5E_CANTGET, "unable to create fixed array debugging context") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTGET, FAIL, "unable to create fixed array debugging context") /* Load the fixed array header */ if (NULL == (hdr = H5FA__hdr_protect(f, hdr_addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to load fixed array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPROTECT, FAIL, "unable to load fixed array header") /* Protect data block */ if (NULL == (dblock = H5FA__dblock_protect(hdr, addr, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block, address = %llu", - (unsigned long long)addr) + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect fixed array data block, address = %llu", (unsigned long long)addr) /* Print opening message */ HDfprintf(stream, "%*sFixed Array data Block...\n", indent, ""); @@ -222,9 +229,9 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, if (NULL == (dblk_page = H5FA__dblk_page_protect(hdr, 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) + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPROTECT, FAIL, + "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++) { @@ -232,10 +239,11 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, 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") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTGET, FAIL, "can't get element for debugging") } /* end for */ if (H5FA__dblk_page_unprotect(dblk_page, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array data block page") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, + "unable to release fixed array data block page") /* Advance to next page address */ dblk_page_addr += dblock->dblk_page_size; @@ -250,16 +258,17 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, 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") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTGET, FAIL, "can't get element for debugging") } /* end for */ } /* end else */ - CATCH +done: if (dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) - H5E_THROW(H5E_CANTRELEASE, "unable to release fixed array debugging context") + HDONE_ERROR(H5E_FARRAY, H5E_CANTRELEASE, FAIL, "unable to release fixed array debugging context") if (dblock && H5FA__dblock_unprotect(dblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array data block") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array data block") if (hdr && H5FA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array header") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array header") -END_FUNC(PKG) /* end H5FA__dblock_debug() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__dblock_debug() */ diff --git a/src/H5FAdblkpage.c b/src/H5FAdblkpage.c index 0f5ee29..1dca0fb 100644 --- a/src/H5FAdblkpage.c +++ b/src/H5FAdblkpage.c @@ -84,21 +84,25 @@ H5FL_BLK_DEFINE(page_elmts); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5FA_dblk_page_t *, NULL, NULL, H5FA__dblk_page_alloc(H5FA_hdr_t *hdr, size_t nelmts)) - - /* Local variables */ +H5FA_dblk_page_t * +H5FA__dblk_page_alloc(H5FA_hdr_t *hdr, size_t nelmts) +{ H5FA_dblk_page_t *dblk_page = NULL; /* Fixed array data block page */ + H5FA_dblk_page_t *ret_value = NULL; + + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(hdr); /* 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") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, NULL, + "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") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTINC, NULL, "can't increment reference count on shared array header") dblk_page->hdr = hdr; /* Set non-zero internal fields */ @@ -106,37 +110,41 @@ BEGIN_FUNC(PKG, ERR, H5FA_dblk_page_t *, NULL, NULL, H5FA__dblk_page_alloc(H5FA_ /* Allocate buffer for elements in data block page */ if (NULL == (dblk_page->elmts = H5FL_BLK_MALLOC(page_elmts, nelmts * hdr->cparam.cls->nat_elmt_size))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for data block page element buffer") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for data block page element buffer") /* Set the return value */ ret_value = dblk_page; - CATCH +done: if (!ret_value) if (dblk_page && H5FA__dblk_page_dest(dblk_page) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy fixed array data block page") + HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, NULL, "unable to destroy fixed array data block page") -END_FUNC(PKG) /* end H5FA__dblk_page_alloc() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__dblk_page_alloc() */ /*------------------------------------------------------------------------- * Function: H5FA__dblk_page_create * * Purpose: Creates a new fixed array data block page in the file * - * Return: Valid file address on success/HADDR_UNDEF on failure + * Return: SUCCEED/FAIL * * Programmer: Vailin Choi * Thursday, April 30, 2009 * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5FA__dblk_page_create(H5FA_hdr_t *hdr, haddr_t addr, size_t nelmts)) - - /* Local variables */ +herr_t +H5FA__dblk_page_create(H5FA_hdr_t *hdr, haddr_t addr, size_t nelmts) +{ H5FA_dblk_page_t *dblk_page = NULL; /* Fixed array data block page */ hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE #ifdef H5FA_DEBUG HDfprintf(stderr, "%s: Called, addr = %a\n", FUNC, addr); @@ -147,7 +155,8 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, /* 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") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, FAIL, + "memory allocation failed for fixed array data block page") /* Set info about data block page on disk */ dblk_page->addr = addr; @@ -158,34 +167,38 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, /* Clear any elements in data block page to fill value */ if ((hdr->cparam.cls->fill)(dblk_page->elmts, nelmts) < 0) - H5E_THROW(H5E_CANTSET, "can't set fixed array data block page elements to class's fill value") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTSET, FAIL, + "can't set fixed array data block page elements to class's fill value") /* Cache the new fixed array data block page */ if (H5AC_insert_entry(hdr->f, 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") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTINSERT, FAIL, "can't add fixed array data block page to cache") inserted = TRUE; /* Add data block page as child of 'top' proxy */ if (hdr->top_proxy) { if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, dblk_page) < 0) - H5E_THROW(H5E_CANTSET, "unable to add fixed array entry as child of array proxy") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTSET, FAIL, + "unable to add fixed array entry as child of array proxy") dblk_page->top_proxy = hdr->top_proxy; } /* end if */ - CATCH +done: if (ret_value < 0) if (dblk_page) { /* Remove from cache, if inserted */ if (inserted) if (H5AC_remove_entry(dblk_page) < 0) - H5E_THROW(H5E_CANTREMOVE, "unable to remove fixed array data block page from cache") + HDONE_ERROR(H5E_FARRAY, H5E_CANTREMOVE, FAIL, + "unable to remove fixed array data block page from cache") /* Destroy data block page */ if (H5FA__dblk_page_dest(dblk_page) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy fixed array data block page") + HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, FAIL, "unable to destroy fixed array data block page") } /* end if */ -END_FUNC(PKG) /* end H5FA__dblk_page_create() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__dblk_page_create() */ /*------------------------------------------------------------------------- * Function: H5FA__dblk_page_protect @@ -200,13 +213,14 @@ END_FUNC(PKG) /* end H5FA__dblk_page_create() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5FA_dblk_page_t *, NULL, NULL, - H5FA__dblk_page_protect(H5FA_hdr_t *hdr, haddr_t dblk_page_addr, size_t dblk_page_nelmts, - unsigned flags)) - - /* Local variables */ +H5FA_dblk_page_t * +H5FA__dblk_page_protect(H5FA_hdr_t *hdr, haddr_t dblk_page_addr, size_t dblk_page_nelmts, unsigned flags) +{ H5FA_dblk_page_t * dblk_page = NULL; /* Fixed array data block page */ H5FA_dblk_page_cache_ud_t udata; /* Information needed for loading data block page */ + H5FA_dblk_page_t * ret_value = NULL; + + FUNC_ENTER_PACKAGE #ifdef H5FA_DEBUG HDfprintf(stderr, "%s: Called\n", FUNC); @@ -227,32 +241,36 @@ BEGIN_FUNC(PKG, ERR, H5FA_dblk_page_t *, NULL, NULL, /* Protect the data block page */ if (NULL == (dblk_page = (H5FA_dblk_page_t *)H5AC_protect(hdr->f, H5AC_FARRAY_DBLK_PAGE, dblk_page_addr, &udata, flags))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block page, address = %llu", - (unsigned long long)dblk_page_addr) + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPROTECT, NULL, + "unable to protect fixed array data block page, address = %llu", + (unsigned long long)dblk_page_addr) /* Create top proxy, if it doesn't exist */ if (hdr->top_proxy && NULL == dblk_page->top_proxy) { /* Add data block page as child of 'top' proxy */ if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, dblk_page) < 0) - H5E_THROW(H5E_CANTSET, "unable to add fixed array entry as child of array proxy") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTSET, NULL, + "unable to add fixed array entry as child of array proxy") dblk_page->top_proxy = hdr->top_proxy; } /* end if */ /* Set return value */ ret_value = dblk_page; - CATCH +done: /* Clean up on error */ if (!ret_value) { /* Release the data block page, if it was protected */ if (dblk_page && H5AC_unprotect(hdr->f, H5AC_FARRAY_DBLK_PAGE, dblk_page->addr, dblk_page, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect fixed array data block page, address = %llu", - (unsigned long long)dblk_page->addr) + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, NULL, + "unable to unprotect fixed array data block page, address = %llu", + (unsigned long long)dblk_page->addr) } /* end if */ -END_FUNC(PKG) /* end H5FA__dblk_page_protect() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__dblk_page_protect() */ /*------------------------------------------------------------------------- * Function: H5FA__dblk_page_unprotect @@ -267,10 +285,12 @@ END_FUNC(PKG) /* end H5FA__dblk_page_protect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5FA__dblk_page_unprotect(H5FA_dblk_page_t *dblk_page, unsigned cache_flags)) +herr_t +H5FA__dblk_page_unprotect(H5FA_dblk_page_t *dblk_page, unsigned cache_flags) +{ + herr_t ret_value = SUCCEED; -/* Local variables */ + FUNC_ENTER_PACKAGE #ifdef H5FA_DEBUG HDfprintf(stderr, "%s: Called\n", FUNC); @@ -281,12 +301,13 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, /* Unprotect the data block page */ if (H5AC_unprotect(dblk_page->hdr->f, H5AC_FARRAY_DBLK_PAGE, dblk_page->addr, dblk_page, cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect fixed array data block page, address = %llu", - (unsigned long long)dblk_page->addr) - - CATCH + HGOTO_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, + "unable to unprotect fixed array data block page, address = %llu", + (unsigned long long)dblk_page->addr) -END_FUNC(PKG) /* end H5FA__dblk_page_unprotect() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__dblk_page_unprotect() */ /*------------------------------------------------------------------------- * Function: H5FA__dblk_page_dest @@ -300,7 +321,12 @@ END_FUNC(PKG) /* end H5FA__dblk_page_unprotect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__dblk_page_dest(H5FA_dblk_page_t *dblk_page)) +herr_t +H5FA__dblk_page_dest(H5FA_dblk_page_t *dblk_page) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(dblk_page); @@ -315,7 +341,8 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__dblk_page_dest(H5FA_dblk_page_ /* Decrement reference count on shared info */ if (H5FA__hdr_decr(dblk_page->hdr) < 0) - H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTDEC, FAIL, + "can't decrement reference count on shared array header") dblk_page->hdr = NULL; } /* end if */ @@ -325,6 +352,6 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__dblk_page_dest(H5FA_dblk_page_ /* Free the data block page itself */ dblk_page = H5FL_FREE(H5FA_dblk_page_t, dblk_page); - CATCH - -END_FUNC(PKG) /* end H5FA__dblk_page_dest() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__dblk_page_dest() */ diff --git a/src/H5FAdblock.c b/src/H5FAdblock.c index 21e2e03..1ccc97d 100644 --- a/src/H5FAdblock.c +++ b/src/H5FAdblock.c @@ -88,10 +88,13 @@ H5FL_BLK_DEFINE(fa_page_init); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5FA_dblock_t *, NULL, NULL, H5FA__dblock_alloc(H5FA_hdr_t *hdr)) +H5FA_dblock_t * +H5FA__dblock_alloc(H5FA_hdr_t *hdr) +{ + H5FA_dblock_t *dblock = NULL; /* fixed array data block */ + H5FA_dblock_t *ret_value = NULL; - /* Local variables */ - H5FA_dblock_t *dblock = NULL; /* fixed array data block */ + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(hdr); @@ -99,11 +102,11 @@ BEGIN_FUNC(PKG, ERR, H5FA_dblock_t *, NULL, NULL, H5FA__dblock_alloc(H5FA_hdr_t /* 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") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, NULL, "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") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTINC, NULL, "can't increment reference count on shared array header") dblock->hdr = hdr; /* Set non-zero internal fields */ @@ -126,7 +129,7 @@ BEGIN_FUNC(PKG, ERR, H5FA_dblock_t *, NULL, NULL, H5FA__dblock_alloc(H5FA_hdr_t /* 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") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, NULL, "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; @@ -143,19 +146,20 @@ BEGIN_FUNC(PKG, ERR, H5FA_dblock_t *, NULL, NULL, H5FA__dblock_alloc(H5FA_hdr_t /* 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") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for data block element buffer") } /* end else */ /* Set the return value */ ret_value = dblock; - CATCH - +done: if (!ret_value) if (dblock && H5FA__dblock_dest(dblock) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy fixed array data block") + HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, NULL, "unable to destroy fixed array data block") -END_FUNC(PKG) /* end H5FA__dblock_alloc() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__dblock_alloc() */ /*------------------------------------------------------------------------- * Function: H5FA__dblock_create @@ -169,13 +173,15 @@ END_FUNC(PKG) /* end H5FA__dblock_alloc() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, - H5FA__dblock_create(H5FA_hdr_t *hdr, hbool_t *hdr_dirty)) +haddr_t +H5FA__dblock_create(H5FA_hdr_t *hdr, hbool_t *hdr_dirty) +{ + H5FA_dblock_t *dblock = NULL; /* Fixed array data block */ + haddr_t dblock_addr; /* Fixed array data block address */ + hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + haddr_t ret_value = HADDR_UNDEF; - /* Local variables */ - H5FA_dblock_t *dblock = NULL; /* Fixed array data block */ - haddr_t dblock_addr; /* Fixed array data block address */ - hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -183,31 +189,35 @@ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, /* Allocate the data block */ if (NULL == (dblock = H5FA__dblock_alloc(hdr))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array data block") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, HADDR_UNDEF, + "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); /* Allocate space for the data block on disk */ if (HADDR_UNDEF == (dblock_addr = H5MF_alloc(hdr->f, H5FD_MEM_FARRAY_DBLOCK, (hsize_t)dblock->size))) - H5E_THROW(H5E_CANTALLOC, "file allocation failed for fixed array data block") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, HADDR_UNDEF, + "file allocation failed for fixed array data block") dblock->addr = dblock_addr; /* Don't initialize elements if paged */ if (!dblock->npages) /* Clear any elements in data block to fill value */ if ((hdr->cparam.cls->fill)(dblock->elmts, (size_t)hdr->cparam.nelmts) < 0) - H5E_THROW(H5E_CANTSET, "can't set fixed array data block elements to class's fill value") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTSET, HADDR_UNDEF, + "can't set fixed array data block elements to class's fill value") /* Cache the new fixed array data block */ if (H5AC_insert_entry(hdr->f, H5AC_FARRAY_DBLOCK, dblock_addr, dblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTINSERT, "can't add fixed array data block to cache") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTINSERT, HADDR_UNDEF, "can't add fixed array data block to cache") inserted = TRUE; /* Add data block as child of 'top' proxy */ if (hdr->top_proxy) { if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, dblock) < 0) - H5E_THROW(H5E_CANTSET, "unable to add fixed array entry as child of array proxy") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTSET, HADDR_UNDEF, + "unable to add fixed array entry as child of array proxy") dblock->top_proxy = hdr->top_proxy; } /* end if */ @@ -217,26 +227,28 @@ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, /* Set address of data block to return */ ret_value = dblock_addr; - CATCH +done: if (!H5F_addr_defined(ret_value)) if (dblock) { /* Remove from cache, if inserted */ if (inserted) if (H5AC_remove_entry(dblock) < 0) - H5E_THROW(H5E_CANTREMOVE, "unable to remove fixed array data block from cache") + HDONE_ERROR(H5E_FARRAY, H5E_CANTREMOVE, HADDR_UNDEF, + "unable to remove fixed array data block from cache") /* Release data block's disk space */ if (H5F_addr_defined(dblock->addr) && H5MF_xfree(hdr->f, H5FD_MEM_FARRAY_DBLOCK, dblock->addr, (hsize_t)dblock->size) < 0) - H5E_THROW(H5E_CANTFREE, "unable to release fixed array data block") + HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, HADDR_UNDEF, "unable to release fixed array data block") /* Destroy data block */ if (H5FA__dblock_dest(dblock) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy fixed array data block") + HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, HADDR_UNDEF, "unable to destroy fixed array data block") } /* end if */ -END_FUNC(PKG) /* end H5FA__dblock_create() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__dblock_create() */ /*------------------------------------------------------------------------- * Function: H5FA__dblock_protect @@ -250,12 +262,14 @@ END_FUNC(PKG) /* end H5FA__dblock_create() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5FA_dblock_t *, NULL, NULL, - H5FA__dblock_protect(H5FA_hdr_t *hdr, haddr_t dblk_addr, unsigned flags)) +H5FA_dblock_t * +H5FA__dblock_protect(H5FA_hdr_t *hdr, haddr_t dblk_addr, unsigned flags) +{ + H5FA_dblock_t * dblock = NULL; /* Fixed array data block */ + H5FA_dblock_cache_ud_t udata; /* Information needed for loading data block */ + H5FA_dblock_t * ret_value = NULL; - /* Local variables */ - H5FA_dblock_t * dblock; /* Fixed array data block */ - H5FA_dblock_cache_ud_t udata; /* Information needed for loading data block */ + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -271,31 +285,33 @@ BEGIN_FUNC(PKG, ERR, H5FA_dblock_t *, NULL, NULL, /* Protect the data block */ if (NULL == (dblock = (H5FA_dblock_t *)H5AC_protect(hdr->f, H5AC_FARRAY_DBLOCK, dblk_addr, &udata, flags))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block, address = %llu", - (unsigned long long)dblk_addr) + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPROTECT, NULL, + "unable to protect fixed array data block, address = %llu", (unsigned long long)dblk_addr) /* Create top proxy, if it doesn't exist */ if (hdr->top_proxy && NULL == dblock->top_proxy) { /* Add data block as child of 'top' proxy */ if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, dblock) < 0) - H5E_THROW(H5E_CANTSET, "unable to add fixed array entry as child of array proxy") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTSET, NULL, + "unable to add fixed array entry as child of array proxy") dblock->top_proxy = hdr->top_proxy; } /* end if */ /* Set return value */ ret_value = dblock; - CATCH - +done: /* Clean up on error */ if (!ret_value) /* Release the data block, if it was protected */ if (dblock && H5AC_unprotect(hdr->f, H5AC_FARRAY_DBLOCK, dblock->addr, dblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect fixed array data block, address = %llu", - (unsigned long long)dblock->addr) + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, NULL, + "unable to unprotect fixed array data block, address = %llu", + (unsigned long long)dblock->addr) -END_FUNC(PKG) /* end H5FA__dblock_protect() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__dblock_protect() */ /*------------------------------------------------------------------------- * Function: H5FA__dblock_unprotect @@ -309,22 +325,25 @@ END_FUNC(PKG) /* end H5FA__dblock_protect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5FA__dblock_unprotect(H5FA_dblock_t *dblock, unsigned cache_flags)) +herr_t +H5FA__dblock_unprotect(H5FA_dblock_t *dblock, unsigned cache_flags) +{ + herr_t ret_value = SUCCEED; - /* Local variables */ + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(dblock); /* Unprotect the data block */ if (H5AC_unprotect(dblock->hdr->f, H5AC_FARRAY_DBLOCK, dblock->addr, dblock, cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect fixed array data block, address = %llu", - (unsigned long long)dblock->addr) - - CATCH + HGOTO_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, + "unable to unprotect fixed array data block, address = %llu", + (unsigned long long)dblock->addr) -END_FUNC(PKG) /* end H5FA__dblock_unprotect() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__dblock_unprotect() */ /*------------------------------------------------------------------------- * Function: H5FA__dblock_delete @@ -338,10 +357,13 @@ END_FUNC(PKG) /* end H5FA__dblock_unprotect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__dblock_delete(H5FA_hdr_t *hdr, haddr_t dblk_addr)) +herr_t +H5FA__dblock_delete(H5FA_hdr_t *hdr, haddr_t dblk_addr) +{ + H5FA_dblock_t *dblock = NULL; /* Pointer to data block */ + herr_t ret_value = SUCCEED; - /* Local variables */ - H5FA_dblock_t *dblock = NULL; /* Pointer to data block */ + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -349,8 +371,8 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__dblock_delete(H5FA_hdr_t *hdr, /* Protect data block */ if (NULL == (dblock = H5FA__dblock_protect(hdr, dblk_addr, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block, address = %llu", - (unsigned long long)dblk_addr) + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect fixed array data block, address = %llu", (unsigned long long)dblk_addr) /* Check if data block is paged */ if (dblock->npages) { @@ -365,21 +387,22 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__dblock_delete(H5FA_hdr_t *hdr, /* Evict the data block page from the metadata cache */ /* (OK to call if it doesn't exist in the cache) */ if (H5AC_expunge_entry(hdr->f, H5AC_FARRAY_DBLK_PAGE, dblk_page_addr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTEXPUNGE, "unable to remove array data block page from metadata cache") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTEXPUNGE, FAIL, + "unable to remove array data block page from metadata cache") /* Advance to next page address */ dblk_page_addr += dblock->dblk_page_size; } /* end for */ } /* end if */ - CATCH - +done: /* Finished deleting data block in metadata cache */ if (dblock && H5FA__dblock_unprotect(dblock, H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array data block") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array data block") -END_FUNC(PKG) /* end H5FA__dblock_delete() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__dblock_delete() */ /*------------------------------------------------------------------------- * Function: H5FA__dblock_dest @@ -393,7 +416,12 @@ END_FUNC(PKG) /* end H5FA__dblock_delete() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__dblock_dest(H5FA_dblock_t *dblock)) +herr_t +H5FA__dblock_dest(H5FA_dblock_t *dblock) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(dblock); @@ -417,7 +445,8 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__dblock_dest(H5FA_dblock_t *dbl /* Decrement reference count on shared info */ if (H5FA__hdr_decr(dblock->hdr) < 0) - H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTDEC, FAIL, + "can't decrement reference count on shared array header") dblock->hdr = NULL; } /* end if */ @@ -427,6 +456,6 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__dblock_dest(H5FA_dblock_t *dbl /* Free the data block itself */ dblock = H5FL_FREE(H5FA_dblock_t, dblock); - CATCH - -END_FUNC(PKG) /* end H5FA__dblock_dest() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__dblock_dest() */ diff --git a/src/H5FAhdr.c b/src/H5FAhdr.c index 867160f..aeb3fb1 100644 --- a/src/H5FAhdr.c +++ b/src/H5FAhdr.c @@ -82,17 +82,20 @@ H5FL_DEFINE_STATIC(H5FA_hdr_t); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5FA_hdr_t *, NULL, NULL, H5FA__hdr_alloc(H5F_t *f)) +H5FA_hdr_t * +H5FA__hdr_alloc(H5F_t *f) +{ + H5FA_hdr_t *hdr = NULL; /* Shared Fixed Array header */ + H5FA_hdr_t *ret_value = NULL; - /* Local variables */ - H5FA_hdr_t *hdr = NULL; /* Shared Fixed Array header */ + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(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") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, NULL, "memory allocation failed for Fixed Array shared header") /* Set non-zero internal fields */ hdr->addr = HADDR_UNDEF; @@ -106,13 +109,12 @@ BEGIN_FUNC(PKG, ERR, H5FA_hdr_t *, NULL, NULL, H5FA__hdr_alloc(H5F_t *f)) /* Set the return value */ ret_value = hdr; - CATCH - +done: if (!ret_value) if (hdr && H5FA__hdr_dest(hdr) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy fixed array header") - -END_FUNC(PKG) /* end H5FA__hdr_alloc() */ + HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, NULL, "unable to destroy fixed array header") + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__hdr_alloc() */ /*------------------------------------------------------------------------- * Function: H5FA__hdr_init @@ -126,9 +128,12 @@ END_FUNC(PKG) /* end H5FA__hdr_alloc() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__hdr_init(H5FA_hdr_t *hdr, void *ctx_udata)) +herr_t +H5FA__hdr_init(H5FA_hdr_t *hdr, void *ctx_udata) +{ + herr_t ret_value = SUCCEED; - /* Local variables */ + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(hdr); @@ -140,33 +145,36 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__hdr_init(H5FA_hdr_t *hdr, void hdr->stats.nelmts = hdr->cparam.nelmts; /* Create the callback context, if there's one */ - if (hdr->cparam.cls->crt_context) { + if (hdr->cparam.cls->crt_context) if (NULL == (hdr->cb_ctx = (*hdr->cparam.cls->crt_context)(ctx_udata))) - H5E_THROW(H5E_CANTCREATE, "unable to create fixed array client callback context") - } /* end if */ + HGOTO_ERROR(H5E_FARRAY, H5E_CANTCREATE, FAIL, + "unable to create fixed array client callback context") - CATCH - -END_FUNC(PKG) /* end H5FA__hdr_init() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__hdr_init() */ /*------------------------------------------------------------------------- * Function: H5FA__hdr_create * * Purpose: Creates a new Fixed Array header in the file * - * Return: SUCCEED/FAIL + * Return: Success: Address of new header in the file + * Failure: HADDR_UNDEF * * Programmer: Vailin Choi * Thursday, April 30, 2009 * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, - H5FA__hdr_create(H5F_t *f, const H5FA_create_t *cparam, void *ctx_udata)) +haddr_t +H5FA__hdr_create(H5F_t *f, const H5FA_create_t *cparam, void *ctx_udata) +{ + H5FA_hdr_t *hdr = NULL; /* Fixed array header */ + hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + haddr_t ret_value = HADDR_UNDEF; - /* Local variables */ - H5FA_hdr_t *hdr = NULL; /* Fixed array header */ - hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(f); @@ -176,17 +184,19 @@ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, { /* Check for valid parameters */ if (cparam->raw_elmt_size == 0) - H5E_THROW(H5E_BADVALUE, "element size must be greater than zero") + HGOTO_ERROR(H5E_FARRAY, H5E_BADVALUE, HADDR_UNDEF, "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") + HGOTO_ERROR(H5E_FARRAY, H5E_BADVALUE, HADDR_UNDEF, + "max. # of elements bits must be greater than zero") if (cparam->nelmts == 0) - H5E_THROW(H5E_BADVALUE, "# of elements must be greater than zero") + HGOTO_ERROR(H5E_FARRAY, H5E_BADVALUE, HADDR_UNDEF, "# 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") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, HADDR_UNDEF, + "memory allocation failed for Fixed Array shared header") hdr->dblk_addr = HADDR_UNDEF; @@ -195,50 +205,52 @@ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, /* Finish initializing fixed array header */ if (H5FA__hdr_init(hdr, ctx_udata) < 0) - H5E_THROW(H5E_CANTINIT, "initialization failed for fixed array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTINIT, HADDR_UNDEF, "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, (hsize_t)hdr->size))) - H5E_THROW(H5E_CANTALLOC, "file allocation failed for Fixed Array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, HADDR_UNDEF, "file allocation failed for Fixed Array header") /* Create 'top' proxy for extensible array entries */ if (hdr->swmr_write) if (NULL == (hdr->top_proxy = H5AC_proxy_entry_create())) - H5E_THROW(H5E_CANTCREATE, "can't create fixed array entry proxy") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTCREATE, HADDR_UNDEF, "can't create fixed array entry proxy") /* Cache the new Fixed Array header */ if (H5AC_insert_entry(f, H5AC_FARRAY_HDR, hdr->addr, hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTINSERT, "can't add fixed array header to cache") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTINSERT, HADDR_UNDEF, "can't add fixed array header to cache") inserted = TRUE; /* Add header as child of 'top' proxy */ if (hdr->top_proxy) if (H5AC_proxy_entry_add_child(hdr->top_proxy, f, hdr) < 0) - H5E_THROW(H5E_CANTSET, "unable to add fixed array entry as child of array proxy") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTSET, HADDR_UNDEF, + "unable to add fixed array entry as child of array proxy") /* Set address of array header to return */ ret_value = hdr->addr; - CATCH - +done: if (!H5F_addr_defined(ret_value)) if (hdr) { /* Remove from cache, if inserted */ if (inserted) if (H5AC_remove_entry(hdr) < 0) - H5E_THROW(H5E_CANTREMOVE, "unable to remove fixed array header from cache") + HDONE_ERROR(H5E_FARRAY, H5E_CANTREMOVE, HADDR_UNDEF, + "unable to remove fixed array header from cache") /* Release header's disk space */ if (H5F_addr_defined(hdr->addr) && H5MF_xfree(f, H5FD_MEM_FARRAY_HDR, hdr->addr, (hsize_t)hdr->size) < 0) - H5E_THROW(H5E_CANTFREE, "unable to free Fixed Array header") + HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, HADDR_UNDEF, "unable to free Fixed Array header") /* Destroy header */ if (H5FA__hdr_dest(hdr) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy Fixed Array header") - } /* end if */ + HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, HADDR_UNDEF, "unable to destroy Fixed Array header") + } -END_FUNC(PKG) /* end H5FA__hdr_create() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__hdr_create() */ /*------------------------------------------------------------------------- * Function: H5FA__hdr_incr @@ -252,7 +264,12 @@ END_FUNC(PKG) /* end H5FA__hdr_create() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__hdr_incr(H5FA_hdr_t *hdr)) +herr_t +H5FA__hdr_incr(H5FA_hdr_t *hdr) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -260,14 +277,14 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__hdr_incr(H5FA_hdr_t *hdr)) /* Mark header as un-evictable when something is depending on it */ if (hdr->rc == 0) if (H5AC_pin_protected_entry(hdr) < 0) - H5E_THROW(H5E_CANTPIN, "unable to pin fixed array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPIN, FAIL, "unable to pin fixed array header") /* Increment reference count on shared header */ hdr->rc++; - CATCH - -END_FUNC(PKG) /* end H5FA__hdr_incr() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__hdr_incr() */ /*------------------------------------------------------------------------- * Function: H5FA__hdr_decr @@ -281,7 +298,12 @@ END_FUNC(PKG) /* end H5FA__hdr_incr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__hdr_decr(H5FA_hdr_t *hdr)) +herr_t +H5FA__hdr_decr(H5FA_hdr_t *hdr) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -294,12 +316,12 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__hdr_decr(H5FA_hdr_t *hdr)) if (hdr->rc == 0) { HDassert(hdr->file_rc == 0); if (H5AC_unpin_entry(hdr) < 0) - H5E_THROW(H5E_CANTUNPIN, "unable to unpin fixed array header") - } /* end if */ - - CATCH + HGOTO_ERROR(H5E_FARRAY, H5E_CANTUNPIN, FAIL, "unable to unpin fixed array header") + } -END_FUNC(PKG) /* end H5FA__hdr_decr() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__hdr_decr() */ /*------------------------------------------------------------------------- * Function: H5FA__hdr_fuse_incr @@ -313,7 +335,10 @@ END_FUNC(PKG) /* end H5FA__hdr_decr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, NOERR, herr_t, SUCCEED, -, H5FA__hdr_fuse_incr(H5FA_hdr_t *hdr)) +herr_t +H5FA__hdr_fuse_incr(H5FA_hdr_t *hdr) +{ + FUNC_ENTER_PACKAGE_NOERR /* Sanity check */ HDassert(hdr); @@ -321,21 +346,28 @@ BEGIN_FUNC(PKG, NOERR, herr_t, SUCCEED, -, H5FA__hdr_fuse_incr(H5FA_hdr_t *hdr)) /* Increment file reference count on shared header */ hdr->file_rc++; -END_FUNC(PKG) /* end H5FA__hdr_fuse_incr() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA__hdr_fuse_incr() */ /*------------------------------------------------------------------------- * Function: H5FA__hdr_fuse_decr * * Purpose: Decrement file reference count on shared array header * - * Return: SUCCEED/FAIL + * Return: Success: The reference count of the header + * Failure: Can't fail * * Programmer: Vailin Choi * Thursday, April 30, 2009 * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, NOERR, size_t, 0, -, H5FA__hdr_fuse_decr(H5FA_hdr_t *hdr)) +size_t +H5FA__hdr_fuse_decr(H5FA_hdr_t *hdr) +{ + size_t ret_value = 0; + + FUNC_ENTER_PACKAGE_NOERR /* Sanity check */ HDassert(hdr); @@ -347,7 +379,8 @@ BEGIN_FUNC(PKG, NOERR, size_t, 0, -, H5FA__hdr_fuse_decr(H5FA_hdr_t *hdr)) /* Set return value */ ret_value = hdr->file_rc; -END_FUNC(PKG) /* end H5FA__hdr_fuse_decr() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__hdr_fuse_decr() */ /*------------------------------------------------------------------------- * Function: H5FA__hdr_modified @@ -361,18 +394,23 @@ END_FUNC(PKG) /* end H5FA__hdr_fuse_decr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__hdr_modified(H5FA_hdr_t *hdr)) +herr_t +H5FA__hdr_modified(H5FA_hdr_t *hdr) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); /* Mark header as dirty in cache */ if (H5AC_mark_entry_dirty(hdr) < 0) - H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark fixed array header as dirty") - - CATCH + HGOTO_ERROR(H5E_FARRAY, H5E_CANTMARKDIRTY, FAIL, "unable to mark fixed array header as dirty") -END_FUNC(PKG) /* end H5FA__hdr_modified() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__hdr_modified() */ /*------------------------------------------------------------------------- * Function: H5FA__hdr_protect @@ -386,12 +424,14 @@ END_FUNC(PKG) /* end H5FA__hdr_modified() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5FA_hdr_t *, NULL, NULL, - H5FA__hdr_protect(H5F_t *f, haddr_t fa_addr, void *ctx_udata, unsigned flags)) - - /* Local variables */ +H5FA_hdr_t * +H5FA__hdr_protect(H5F_t *f, haddr_t fa_addr, void *ctx_udata, unsigned flags) +{ H5FA_hdr_t * hdr; /* Fixed array header */ H5FA_hdr_cache_ud_t udata; /* User data for cache callbacks */ + H5FA_hdr_t * ret_value = NULL; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(f); @@ -407,27 +447,28 @@ BEGIN_FUNC(PKG, ERR, H5FA_hdr_t *, NULL, NULL, /* Protect the header */ if (NULL == (hdr = (H5FA_hdr_t *)H5AC_protect(f, H5AC_FARRAY_HDR, fa_addr, &udata, flags))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array header, address = %llu", - (unsigned long long)fa_addr) + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPROTECT, NULL, "unable to protect fixed array header, address = %llu", + (unsigned long long)fa_addr) hdr->f = f; /* (Must be set again here, in case the header was already in the cache -QAK) */ /* Create top proxy, if it doesn't exist */ if (hdr->swmr_write && NULL == hdr->top_proxy) { /* Create 'top' proxy for fixed array entries */ if (NULL == (hdr->top_proxy = H5AC_proxy_entry_create())) - H5E_THROW(H5E_CANTCREATE, "can't create fixed array entry proxy") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTCREATE, NULL, "can't create fixed array entry proxy") /* Add header as child of 'top' proxy */ if (H5AC_proxy_entry_add_child(hdr->top_proxy, f, hdr) < 0) - H5E_THROW(H5E_CANTSET, "unable to add fixed array entry as child of array proxy") - } /* end if */ + HGOTO_ERROR(H5E_FARRAY, H5E_CANTSET, NULL, + "unable to add fixed array entry as child of array proxy") + } /* Set return value */ ret_value = hdr; - CATCH - -END_FUNC(PKG) /* end H5FA__hdr_protect() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__hdr_protect() */ /*------------------------------------------------------------------------- * Function: H5FA__hdr_unprotect @@ -441,21 +482,24 @@ END_FUNC(PKG) /* end H5FA__hdr_protect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__hdr_unprotect(H5FA_hdr_t *hdr, unsigned cache_flags)) +herr_t +H5FA__hdr_unprotect(H5FA_hdr_t *hdr, unsigned cache_flags) +{ + herr_t ret_value = SUCCEED; - /* Local variables */ + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); /* Unprotect the header */ if (H5AC_unprotect(hdr->f, H5AC_FARRAY_HDR, hdr->addr, hdr, cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect fixed array hdr, address = %llu", - (unsigned long long)hdr->addr) - - CATCH + HGOTO_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, + "unable to unprotect fixed array hdr, address = %llu", (unsigned long long)hdr->addr) -END_FUNC(PKG) /* end H5FA__hdr_unprotect() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__hdr_unprotect() */ /*------------------------------------------------------------------------- * Function: H5FA__hdr_delete @@ -469,46 +513,49 @@ END_FUNC(PKG) /* end H5FA__hdr_unprotect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__hdr_delete(H5FA_hdr_t *hdr)) - - /* Local variables */ +herr_t +H5FA__hdr_delete(H5FA_hdr_t *hdr) +{ unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting header */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); HDassert(!hdr->file_rc); #ifndef NDEBUG - { - unsigned hdr_status = 0; /* Array header's status in the metadata cache */ - /* Check the array header's status in the metadata cache */ - if (H5AC_get_entry_status(hdr->f, hdr->addr, &hdr_status) < 0) - H5E_THROW(H5E_CANTGET, "unable to check metadata cache status for array header") + unsigned hdr_status = 0; /* Array header's status in the metadata cache */ + + /* Check the array header's status in the metadata cache */ + if (H5AC_get_entry_status(hdr->f, hdr->addr, &hdr_status) < 0) + HGOTO_ERROR(H5E_FARRAY, H5E_CANTGET, FAIL, "unable to check metadata cache status for array header") + + /* Sanity checks on array header */ + HDassert(hdr_status & H5AC_ES__IN_CACHE); + HDassert(hdr_status & H5AC_ES__IS_PROTECTED); - /* Sanity checks on array header */ - HDassert(hdr_status & H5AC_ES__IN_CACHE); - HDassert(hdr_status & H5AC_ES__IS_PROTECTED); - } /* end block */ #endif /* NDEBUG */ /* Check for Fixed Array Data block */ if (H5F_addr_defined(hdr->dblk_addr)) { /* Delete Fixed Array Data block */ if (H5FA__dblock_delete(hdr, hdr->dblk_addr) < 0) - H5E_THROW(H5E_CANTDELETE, "unable to delete fixed array data block") - } /* end if */ + HGOTO_ERROR(H5E_FARRAY, H5E_CANTDELETE, FAIL, "unable to delete fixed array data block") + } /* Set flags to finish deleting header on unprotect */ cache_flags |= H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG; - CATCH - +done: /* Unprotect the header, deleting it if an error hasn't occurred */ if (H5AC_unprotect(hdr->f, H5AC_FARRAY_HDR, hdr->addr, hdr, cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array header") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array header") -END_FUNC(PKG) /* end H5FA__hdr_delete() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__hdr_delete() */ /*------------------------------------------------------------------------- * Function: H5FA__hdr_dest @@ -522,7 +569,12 @@ END_FUNC(PKG) /* end H5FA__hdr_delete() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__hdr_dest(H5FA_hdr_t *hdr)) +herr_t +H5FA__hdr_dest(H5FA_hdr_t *hdr) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(hdr); @@ -531,20 +583,21 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__hdr_dest(H5FA_hdr_t *hdr)) /* Destroy the callback context */ if (hdr->cb_ctx) { if ((*hdr->cparam.cls->dst_context)(hdr->cb_ctx) < 0) - H5E_THROW(H5E_CANTRELEASE, "unable to destroy fixed array client callback context") - } /* end if */ + HGOTO_ERROR(H5E_FARRAY, H5E_CANTRELEASE, FAIL, + "unable to destroy fixed array client callback context") + } hdr->cb_ctx = NULL; /* Destroy the 'top' proxy */ if (hdr->top_proxy) { if (H5AC_proxy_entry_dest(hdr->top_proxy) < 0) - H5E_THROW(H5E_CANTRELEASE, "unable to destroy fixed array 'top' proxy") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTRELEASE, FAIL, "unable to destroy fixed array 'top' proxy") hdr->top_proxy = NULL; - } /* end if */ + } /* Free the shared info itself */ hdr = H5FL_FREE(H5FA_hdr_t, hdr); - CATCH - -END_FUNC(PKG) /* end H5FA__hdr_dest() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__hdr_dest() */ diff --git a/src/H5FAint.c b/src/H5FAint.c index 864c7ee..2206901 100644 --- a/src/H5FAint.c +++ b/src/H5FAint.c @@ -79,8 +79,12 @@ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5FA__create_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry)) +herr_t +H5FA__create_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(parent_entry); @@ -88,11 +92,11 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, /* Create a flush dependency between parent and child entry */ if (H5AC_create_flush_dependency(parent_entry, child_entry) < 0) - H5E_THROW(H5E_CANTDEPEND, "unable to create flush dependency") - - CATCH + HGOTO_ERROR(H5E_FARRAY, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") -END_FUNC(PKG) /* end H5FA__create_flush_depend() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__create_flush_depend() */ /*------------------------------------------------------------------------- * Function: H5FA__destroy_flush_depend @@ -106,8 +110,12 @@ END_FUNC(PKG) /* end H5FA__create_flush_depend() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5FA__destroy_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry)) +herr_t +H5FA__destroy_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(parent_entry); @@ -115,8 +123,8 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, /* Destroy a flush dependency between parent and child entry */ if (H5AC_destroy_flush_dependency(parent_entry, child_entry) < 0) - H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency") - - CATCH + HGOTO_ERROR(H5E_FARRAY, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") -END_FUNC(PKG) /* end H5FA__destroy_flush_depend() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__destroy_flush_depend() */ diff --git a/src/H5FAstat.c b/src/H5FAstat.c index 1fdf47f..98f7195 100644 --- a/src/H5FAstat.c +++ b/src/H5FAstat.c @@ -78,21 +78,21 @@ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5FA_get_stats(const H5FA_t *fa, H5FA_stat_t *stats)) - -/* Local variables */ +herr_t +H5FA_get_stats(const H5FA_t *fa, H5FA_stat_t *stats) +{ + FUNC_ENTER_NOAPI_NOERR #ifdef H5FA_DEBUG HDfprintf(stderr, "%s: Called\n", FUNC); #endif /* H5FA_DEBUG */ - /* - * Check arguments. - */ + /* Check arguments */ HDassert(fa); HDassert(stats); /* Copy fixed array statistics */ H5MM_memcpy(stats, &fa->hdr->stats, sizeof(fa->hdr->stats)); -END_FUNC(PRIV) /* end H5FA_get_stats() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA_get_stats() */ diff --git a/src/H5FAtest.c b/src/H5FAtest.c index 6dd6e00..384a657 100644 --- a/src/H5FAtest.c +++ b/src/H5FAtest.c @@ -112,14 +112,17 @@ H5FL_DEFINE_STATIC(H5FA__test_ctx_t); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, H5FA__test_crt_context(void H5_ATTR_UNUSED *udata)) - - /* Local variables */ +static void * +H5FA__test_crt_context(void H5_ATTR_UNUSED *udata) +{ H5FA__test_ctx_t *ctx; /* Context for callbacks */ + void * ret_value = NULL; + + FUNC_ENTER_STATIC /* 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") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, NULL, "can't allocate fixed array client callback context") /* Initialize the context */ ctx->bogus = H5FA__TEST_BOGUS_VAL; @@ -127,9 +130,9 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, H5FA__test_crt_context(void H5_ATTR_ /* Set return value */ ret_value = ctx; - CATCH - -END_FUNC(STATIC) /* end H5FA__test_crt_context() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__test_crt_context() */ /*------------------------------------------------------------------------- * Function: H5FA__test_dst_context @@ -143,18 +146,21 @@ END_FUNC(STATIC) /* end H5FA__test_crt_context() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, H5FA__test_dst_context(void *_ctx)) - - /* Local variables */ +static herr_t +H5FA__test_dst_context(void *_ctx) +{ H5FA__test_ctx_t *ctx = (H5FA__test_ctx_t *)_ctx; /* Callback context to destroy */ + FUNC_ENTER_STATIC_NOERR + /* Sanity checks */ HDassert(H5FA__TEST_BOGUS_VAL == ctx->bogus); /* Release context structure */ ctx = H5FL_FREE(H5FA__test_ctx_t, ctx); -END_FUNC(STATIC) /* end H5FA__test_dst_context() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA__test_dst_context() */ /*------------------------------------------------------------------------- * Function: H5FA__test_fill @@ -168,18 +174,21 @@ END_FUNC(STATIC) /* end H5FA__test_dst_context() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, H5FA__test_fill(void *nat_blk, size_t nelmts)) - - /* Local variables */ +static herr_t +H5FA__test_fill(void *nat_blk, size_t nelmts) +{ uint64_t fill_val = H5FA_TEST_FILL; /* Value to fill elements with */ + FUNC_ENTER_STATIC_NOERR + /* Sanity checks */ HDassert(nat_blk); HDassert(nelmts); H5VM_array_fill(nat_blk, &fill_val, sizeof(uint64_t), nelmts); -END_FUNC(STATIC) /* end H5FA__test_fill() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA__test_fill() */ /*------------------------------------------------------------------------- * Function: H5FA__test_encode @@ -193,14 +202,15 @@ END_FUNC(STATIC) /* end H5FA__test_fill() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5FA__test_encode(void *raw, const void *_elmt, size_t nelmts, void H5_ATTR_UNUSED *_ctx)) - -/* Local variables */ +static herr_t +H5FA__test_encode(void *raw, const void *_elmt, size_t nelmts, void H5_ATTR_UNUSED *_ctx) +{ #ifndef NDEBUG H5FA__test_ctx_t *ctx = (H5FA__test_ctx_t *)_ctx; /* Callback context to destroy */ -#endif /* NDEBUG */ - const uint64_t *elmt = (const uint64_t *)_elmt; /* Convenience pointer to native elements */ +#endif + const uint64_t *elmt = (const uint64_t *)_elmt; /* Convenience pointer to native elements */ + + FUNC_ENTER_STATIC_NOERR /* Sanity checks */ HDassert(raw); @@ -221,7 +231,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, nelmts--; } /* end while */ -END_FUNC(STATIC) /* end H5FA__test_encode() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA__test_encode() */ /*------------------------------------------------------------------------- * Function: H5FA__test_decode @@ -235,15 +246,16 @@ END_FUNC(STATIC) /* end H5FA__test_encode() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5FA__test_decode(const void *_raw, void *_elmt, size_t nelmts, void H5_ATTR_UNUSED *_ctx)) - -/* Local variables */ +static herr_t +H5FA__test_decode(const void *_raw, void *_elmt, size_t nelmts, void H5_ATTR_UNUSED *_ctx) +{ #ifndef NDEBUG H5FA__test_ctx_t *ctx = (H5FA__test_ctx_t *)_ctx; /* Callback context to destroy */ -#endif /* NDEBUG */ - uint64_t * elmt = (uint64_t *)_elmt; /* Convenience pointer to native elements */ - const uint8_t *raw = (const uint8_t *)_raw; /* Convenience pointer to raw elements */ +#endif + uint64_t * elmt = (uint64_t *)_elmt; /* Convenience pointer to native elements */ + const uint8_t *raw = (const uint8_t *)_raw; /* Convenience pointer to raw elements */ + + FUNC_ENTER_STATIC_NOERR /* Sanity checks */ HDassert(raw); @@ -264,7 +276,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, nelmts--; } /* end while */ -END_FUNC(STATIC) /* end H5FA__test_decode() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA__test_decode() */ /*------------------------------------------------------------------------- * Function: H5FA__test_debug @@ -278,12 +291,13 @@ END_FUNC(STATIC) /* end H5FA__test_decode() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5FA__test_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void *elmt)) - - /* Local variables */ +static herr_t +H5FA__test_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void *elmt) +{ char temp_str[128]; /* Temporary string, for formatting */ + FUNC_ENTER_STATIC_NOERR + /* Sanity checks */ HDassert(stream); HDassert(elmt); @@ -293,7 +307,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, HDfprintf(stream, "%*s%-*s %llu\n", indent, "", fwidth, temp_str, (unsigned long long)*(const uint64_t *)elmt); -END_FUNC(STATIC) /* end H5FA__test_debug() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA__test_debug() */ /*------------------------------------------------------------------------- * Function: H5FA__test_crt_dbg_context @@ -308,15 +323,17 @@ END_FUNC(STATIC) /* end H5FA__test_debug() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, - H5FA__test_crt_dbg_context(H5F_t H5_ATTR_UNUSED *f, haddr_t H5_ATTR_UNUSED obj_addr)) - - /* Local variables */ +static void * +H5FA__test_crt_dbg_context(H5F_t H5_ATTR_UNUSED *f, haddr_t H5_ATTR_UNUSED obj_addr) +{ H5FA__test_ctx_t *ctx; /* Context for callbacks */ + void * ret_value = NULL; + + FUNC_ENTER_STATIC /* 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") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, NULL, "can't allocate fixed array client callback context") /* Initialize the context */ ctx->bogus = H5FA__TEST_BOGUS_VAL; @@ -324,9 +341,9 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Set return value */ ret_value = ctx; - CATCH - -END_FUNC(STATIC) /* end H5FA__test_crt_dbg_context() */ +done: + FUNC_LEAVE_NOAPI(ret_value); +} /* end H5FA__test_crt_dbg_context() */ /*------------------------------------------------------------------------- * Function: H5FA__get_cparam_test @@ -340,7 +357,10 @@ END_FUNC(STATIC) /* end H5FA__test_crt_dbg_context() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, NOERR, herr_t, SUCCEED, -, H5FA__get_cparam_test(const H5FA_t *fa, H5FA_create_t *cparam)) +herr_t +H5FA__get_cparam_test(const H5FA_t *fa, H5FA_create_t *cparam) +{ + FUNC_ENTER_PACKAGE_NOERR /* Check arguments. */ HDassert(fa); @@ -350,22 +370,27 @@ BEGIN_FUNC(PKG, NOERR, herr_t, SUCCEED, -, H5FA__get_cparam_test(const H5FA_t *f cparam->raw_elmt_size = fa->hdr->cparam.raw_elmt_size; cparam->nelmts = fa->hdr->cparam.nelmts; -END_FUNC(PKG) /* end H5FA__get_cparam_test() */ + FUNC_LEAVE_NOAPI(SUCCEED); +} /* end H5FA__get_cparam_test() */ /*------------------------------------------------------------------------- * Function: H5FA__cmp_cparam_test * * Purpose: Compare the parameters used to create the fixed array * - * Return: SUCCEED/FAIL + * Return: An integer value like strcmp * * Programmer: Vailin Choi * Thursday, April 30, 2009 * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERRCATCH, int, 0, -, - H5FA__cmp_cparam_test(const H5FA_create_t *cparam1, const H5FA_create_t *cparam2)) +int +H5FA__cmp_cparam_test(const H5FA_create_t *cparam1, const H5FA_create_t *cparam2) +{ + int ret_value = 0; + + FUNC_ENTER_PACKAGE_NOERR /* Check arguments. */ HDassert(cparam1); @@ -373,10 +398,10 @@ BEGIN_FUNC(PKG, ERRCATCH, int, 0, -, /* Compare creation parameters for array */ if (cparam1->raw_elmt_size < cparam2->raw_elmt_size) - H5_LEAVE(-1) + ret_value = -1; else if (cparam1->raw_elmt_size > cparam2->raw_elmt_size) - H5_LEAVE(1) + ret_value = 1; - CATCH + FUNC_LEAVE_NOAPI(ret_value) -END_FUNC(PKG) /* end H5FA__cmp_cparam_test() */ +} /* end H5FA__cmp_cparam_test() */ diff --git a/src/H5HL.c b/src/H5HL.c index ca83445..1f2369a 100644 --- a/src/H5HL.c +++ b/src/H5HL.c @@ -98,11 +98,15 @@ H5FL_BLK_DEFINE(lheap_chunk); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_create(H5F_t *f, size_t size_hint, haddr_t *addr_p /*out*/)) - +herr_t +H5HL_create(H5F_t *f, 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; + + FUNC_ENTER_NOAPI(FAIL) /* check arguments */ HDassert(f); @@ -115,12 +119,12 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_create(H5F_t *f, size_t size_h /* Allocate new heap structure */ 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"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "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, total_size))) - H5E_THROW(H5E_CANTALLOC, "unable to allocate file memory"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "unable to allocate file memory"); /* Initialize info */ heap->single_cache_obj = TRUE; @@ -128,52 +132,52 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_create(H5F_t *f, size_t size_h heap->dblk_size = size_hint; if (size_hint) if (NULL == (heap->dblk_image = H5FL_BLK_CALLOC(lheap_chunk, size_hint))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "memory allocation failed"); /* free list */ if (size_hint) { if (NULL == (heap->freelist = H5FL_MALLOC(H5HL_free_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed"); + 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; heap->free_block = 0; - } /* end if */ + } else { heap->freelist = NULL; heap->free_block = H5HL_FREE_NULL; - } /* end else */ + } /* Allocate the heap prefix */ if (NULL == (prfx = H5HL__prfx_new(heap))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "memory allocation failed"); /* Add to cache */ if (FAIL == H5AC_insert_entry(f, H5AC_LHEAP_PRFX, heap->prfx_addr, prfx, H5AC__NO_FLAGS_SET)) - H5E_THROW(H5E_CANTINIT, "unable to cache local heap prefix"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "unable to cache local heap prefix"); /* Set address to return */ *addr_p = heap->prfx_addr; - CATCH +done: if (ret_value < 0) { *addr_p = HADDR_UNDEF; if (prfx) { if (FAIL == H5HL__prfx_dest(prfx)) - H5E_THROW(H5E_CANTFREE, "unable to destroy local heap prefix"); - } /* end if */ + HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy local heap prefix"); + } else { if (heap) { if (H5F_addr_defined(heap->prfx_addr)) if (FAIL == H5MF_xfree(f, H5FD_MEM_LHEAP, heap->prfx_addr, total_size)) - H5E_THROW(H5E_CANTFREE, "can't release heap data?"); + HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "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 */ - -END_FUNC(PRIV) /* end H5HL_create() */ + HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy local heap"); + } + } + } + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL_create() */ /*------------------------------------------------------------------------- * Function: H5HL__minimize_heap_space @@ -188,16 +192,19 @@ END_FUNC(PRIV) /* end H5HL_create() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5HL__minimize_heap_space(H5F_t *f, H5HL_t *heap)) - +static herr_t +H5HL__minimize_heap_space(H5F_t *f, H5HL_t *heap) +{ size_t new_heap_size = heap->dblk_size; /* New size of heap */ + herr_t ret_value = SUCCEED; - /* check args */ + FUNC_ENTER_STATIC + + /* Check args */ HDassert(f); HDassert(heap); - /* - * Check to see if we can reduce the size of the heap in memory by + /* Check to see if we can reduce the size of the heap in memory by * eliminating free blocks at the tail of the buffer before flushing the * buffer out. */ @@ -211,29 +218,25 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5HL__minimize_heap_space(H5F_t * if (tmp_fl->offset + tmp_fl->size == heap->dblk_size) { last_fl = tmp_fl; break; - } /* end if */ + } - /* - * Found free block at the end of the buffer, decide what to do + /* Found free block at the end of the buffer, decide what to do * about it */ if (last_fl) { - /* - * If the last free block's size is more than half the memory + /* If the last free block's size is more than half the memory * buffer size (and the memory buffer is larger than the * minimum size), reduce or eliminate it. */ if (last_fl->size >= (heap->dblk_size / 2) && heap->dblk_size > H5HL_MIN_HEAP) { - /* - * Reduce size of buffer until it's too small or would + /* Reduce size of buffer until it's too small or would * eliminate the free block */ while (new_heap_size > H5HL_MIN_HEAP && new_heap_size >= (last_fl->offset + H5HL_SIZEOF_FREE(f))) new_heap_size /= 2; - /* - * Check if reducing the memory buffer size would + /* Check if reducing the memory buffer size would * eliminate the free block */ if (new_heap_size < (last_fl->offset + H5HL_SIZEOF_FREE(f))) { @@ -246,31 +249,29 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5HL__minimize_heap_space(H5F_t * last_fl->size = H5HL_ALIGN(new_heap_size - last_fl->offset); new_heap_size = last_fl->offset + last_fl->size; HDassert(last_fl->size >= H5HL_SIZEOF_FREE(f)); - } /* end if */ + } else { - /* - * Set the size of the memory buffer to the start + /* Set the size of the memory buffer to the start * of the free list */ new_heap_size = last_fl->offset; /* Eliminate the free block from the list */ last_fl = H5HL__remove_free(heap, last_fl); - } /* end else */ - } /* end if */ + } + } else { /* Truncate the free block */ last_fl->size = H5HL_ALIGN(new_heap_size - last_fl->offset); new_heap_size = last_fl->offset + last_fl->size; HDassert(last_fl->size >= H5HL_SIZEOF_FREE(f)); HDassert(last_fl->size == H5HL_ALIGN(last_fl->size)); - } /* end else */ - } /* end if */ - } /* end if */ - } /* end if */ + } + } + } + } - /* - * If the heap grew smaller than disk storage then move the + /* If the heap grew smaller than disk storage then move the * data segment of the heap to another contiguous block of disk * storage. */ @@ -279,17 +280,16 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5HL__minimize_heap_space(H5F_t * /* Resize the memory buffer */ if (NULL == (heap->dblk_image = H5FL_BLK_REALLOC(lheap_chunk, heap->dblk_image, new_heap_size))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "memory allocation failed"); /* Reallocate data block in file */ if (FAIL == H5HL__dblk_realloc(f, heap, new_heap_size)) - H5E_THROW(H5E_CANTRESIZE, "reallocating data block failed"); - } /* end if */ - - CATCH - /* No special processing on errors */ + HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, FAIL, "reallocating data block failed"); + } -END_FUNC(STATIC) /* H5HL__minimize_heap_space() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5HL__minimize_heap_space() */ /*------------------------------------------------------------------------- * Function: H5HL_protect @@ -304,20 +304,24 @@ END_FUNC(STATIC) /* H5HL__minimize_heap_space() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, H5HL_t *, NULL, NULL, H5HL_protect(H5F_t *f, haddr_t addr, unsigned flags)) - +H5HL_t * +H5HL_protect(H5F_t *f, 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; - /* check arguments */ + FUNC_ENTER_NOAPI(NULL) + + /* Check arguments */ HDassert(f); HDassert(H5F_addr_defined(addr)); - /* only the H5AC__READ_ONLY_FLAG may appear in flags */ + /* Only the H5AC__READ_ONLY_FLAG may appear in flags */ HDassert((flags & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0); /* Construct the user data for protect callback */ @@ -328,7 +332,7 @@ BEGIN_FUNC(PRIV, ERR, H5HL_t *, NULL, NULL, H5HL_protect(H5F_t *f, haddr_t addr, /* Protect the local heap prefix */ if (NULL == (prfx = (H5HL_prfx_t *)H5AC_protect(f, H5AC_LHEAP_PRFX, addr, &prfx_udata, flags))) - H5E_THROW(H5E_CANTPROTECT, "unable to load heap prefix"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, NULL, "unable to load heap prefix"); /* Get the pointer to the heap */ heap = prfx->heap; @@ -344,12 +348,12 @@ BEGIN_FUNC(PRIV, ERR, H5HL_t *, NULL, NULL, H5HL_protect(H5F_t *f, haddr_t addr, /* Protect the local heap data block */ if (NULL == (dblk = (H5HL_dblk_t *)H5AC_protect(f, H5AC_LHEAP_DBLK, heap->dblk_addr, heap, flags))) - H5E_THROW(H5E_CANTPROTECT, "unable to load heap data block"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, NULL, "unable to load heap data block"); /* Set the flag for pinning the data block when unprotecting it */ dblk_cache_flags |= H5AC__PIN_ENTRY_FLAG; - } /* end if */ - } /* end if */ + } + } /* Increment # of times heap is protected */ heap->prots++; @@ -357,16 +361,17 @@ BEGIN_FUNC(PRIV, ERR, H5HL_t *, NULL, NULL, H5HL_protect(H5F_t *f, haddr_t addr, /* Set return value */ ret_value = heap; - CATCH +done: /* Release the prefix from the cache, now pinned */ if (prfx && heap && H5AC_unprotect(f, H5AC_LHEAP_PRFX, heap->prfx_addr, prfx, prfx_cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release local heap prefix"); + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, NULL, "unable to release local heap prefix"); /* Release the data block from the cache, now pinned */ if (dblk && heap && H5AC_unprotect(f, H5AC_LHEAP_DBLK, heap->dblk_addr, dblk, dblk_cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release local heap data block"); + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, NULL, "unable to release local heap data block"); -END_FUNC(PRIV) /* end H5HL_protect() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL_protect() */ /*------------------------------------------------------------------------- * Function: H5HL_offset_into @@ -374,26 +379,31 @@ END_FUNC(PRIV) /* end H5HL_protect() */ * Purpose: Called directly after the call to H5HL_protect so that * a pointer to the object in the heap can be obtained. * - * Return: Success: Valid pointer. - * Failure: Can't fail + * Return: Success: Valid pointer + * Failure: NULL * * Programmer: Bill Wendling * Sept. 17, 2003 * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, void *, NULL, NULL, H5HL_offset_into(const H5HL_t *heap, size_t offset)) +void * +H5HL_offset_into(const H5HL_t *heap, size_t offset) +{ + void *ret_value = NULL; + + FUNC_ENTER_NOAPI(NULL) /* Sanity check */ HDassert(heap); if (offset >= heap->dblk_size) - H5E_THROW(H5E_CANTGET, "unable to offset into local heap data block"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, NULL, "unable to offset into local heap data block"); ret_value = heap->dblk_image + offset; - CATCH -/* No special processing on errors */ -END_FUNC(PRIV) /* end H5HL_offset_into() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL_offset_into() */ /*------------------------------------------------------------------------- * Function: H5HL_unprotect @@ -407,9 +417,14 @@ END_FUNC(PRIV) /* end H5HL_offset_into() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_unprotect(H5HL_t *heap)) +herr_t +H5HL_unprotect(H5HL_t *heap) +{ + herr_t ret_value = SUCCEED; - /* check arguments */ + FUNC_ENTER_NOAPI(FAIL) + + /* Check arguments */ HDassert(heap); /* Decrement # of times heap is protected */ @@ -421,8 +436,8 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_unprotect(H5HL_t *heap)) if (heap->single_cache_obj) { /* Mark local heap prefix as evictable again */ if (FAIL == H5AC_unpin_entry(heap->prfx)) - H5E_THROW(H5E_CANTUNPIN, "unable to unpin local heap data block"); - } /* end if */ + HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPIN, FAIL, "unable to unpin local heap data block"); + } else { /* Sanity check */ HDassert(heap->dblk); @@ -430,14 +445,13 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_unprotect(H5HL_t *heap)) /* Mark local heap data block as evictable again */ /* (data block still pins prefix) */ if (FAIL == H5AC_unpin_entry(heap->dblk)) - H5E_THROW(H5E_CANTUNPIN, "unable to unpin local heap data block"); - } /* end else */ - } /* end if */ - - CATCH - /* No special processing on errors */ + HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPIN, FAIL, "unable to unpin local heap data block"); + } + } -END_FUNC(PRIV) /* end H5HL_unprotect() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL_unprotect() */ /*------------------------------------------------------------------------- * Function: H5HL__remove_free @@ -452,7 +466,12 @@ END_FUNC(PRIV) /* end H5HL_unprotect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, H5HL_free_t *, NULL, -, H5HL__remove_free(H5HL_t *heap, H5HL_free_t *fl)) +static H5HL_free_t * +H5HL__remove_free(H5HL_t *heap, H5HL_free_t *fl) +{ + H5HL_free_t *ret_value = NULL; + + FUNC_ENTER_STATIC_NOERR if (fl->prev) fl->prev->next = fl->next; @@ -465,7 +484,8 @@ BEGIN_FUNC(STATIC, NOERR, H5HL_free_t *, NULL, -, H5HL__remove_free(H5HL_t *heap /* 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() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL__remove_free() */ /*------------------------------------------------------------------------- * Function: H5HL__dirty @@ -479,9 +499,14 @@ END_FUNC(STATIC) /* end H5HL__remove_free() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5HL__dirty(H5HL_t *heap)) +static herr_t +H5HL__dirty(H5HL_t *heap) +{ + herr_t ret_value = SUCCEED; - /* check arguments */ + FUNC_ENTER_STATIC + + /* Check arguments */ HDassert(heap); HDassert(heap->prfx); @@ -491,17 +516,16 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5HL__dirty(H5HL_t *heap)) HDassert(heap->dblk); if (FAIL == H5AC_mark_entry_dirty(heap->dblk)) - H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark heap data block as dirty"); - } /* end if */ + HGOTO_ERROR(H5E_HEAP, H5E_CANTMARKDIRTY, FAIL, "unable to mark heap data block as dirty"); + } /* Mark heap prefix as dirty */ if (FAIL == H5AC_mark_entry_dirty(heap->prfx)) - H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark heap prefix as dirty"); - - CATCH - /* No special processing on errors */ + HGOTO_ERROR(H5E_HEAP, H5E_CANTMARKDIRTY, FAIL, "unable to mark heap prefix as dirty"); -END_FUNC(STATIC) /* end H5HL__dirty() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL__dirty() */ /*------------------------------------------------------------------------- * Function: H5HL_insert @@ -519,13 +543,16 @@ END_FUNC(STATIC) /* end H5HL__dirty() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, - H5HL_insert(H5F_t *f, H5HL_t *heap, size_t buf_size, const void *buf, size_t *offset_out)) - +herr_t +H5HL_insert(H5F_t *f, H5HL_t *heap, size_t buf_size, const void *buf, size_t *offset_out) +{ H5HL_free_t *fl = NULL, *last_fl = NULL; size_t need_size; size_t offset = 0; hbool_t found; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) /* Check arguments */ HDassert(f); @@ -541,7 +568,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, * if an error occurs -QAK) */ if (FAIL == H5HL__dirty(heap)) - H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark heap as dirty"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTMARKDIRTY, FAIL, "unable to mark heap as dirty"); /* In order to keep the free list descriptors aligned on word boundaries, * whatever that might mean, we round the size up to the next multiple of @@ -574,7 +601,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, /* Track free space that's closest to end of heap */ last_fl = fl; } - } /* end for */ + } /* If no free chunk was large enough, then allocate more space and * add it to the free list. If the heap ends with a free chunk, we @@ -612,7 +639,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, was_extended = H5MF_try_extend(f, 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"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTEXTEND, FAIL, "error trying to extend heap"); /* Check if we extended the heap data block in file */ if (was_extended == TRUE) { @@ -620,22 +647,22 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, if (heap->single_cache_obj) { /* Resize prefix+data block */ 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 */ + HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, FAIL, "unable to resize heap prefix in cache"); + } else { /* Resize 'standalone' data block */ 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 */ + HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, FAIL, "unable to resize heap data block in cache"); + } /* Note new size */ heap->dblk_size = new_dblk_size; - } /* end if */ + } else { /* ...if we can't, allocate a new chunk & release the old */ /* Reallocate data block in file */ if (FAIL == H5HL__dblk_realloc(f, heap, new_dblk_size)) - H5E_THROW(H5E_CANTRESIZE, "reallocating data block failed"); - } /* end if */ + HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, FAIL, "reallocating data block failed"); + } /* 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) { @@ -657,7 +684,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, #endif 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. @@ -665,7 +692,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, 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"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "memory allocation failed"); fl->offset = old_dblk_size + need_size; fl->size = need_more - need_size; HDassert(fl->offset == H5HL_ALIGN(fl->offset)); @@ -682,7 +709,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, (unsigned long)(need_more - need_size), __LINE__); #endif } - } /* end else */ + } #ifdef H5HL_DEBUG if (H5DEBUG(HL)) { @@ -691,22 +718,21 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, } #endif if (NULL == (heap->dblk_image = H5FL_BLK_REALLOC(lheap_chunk, heap->dblk_image, heap->dblk_size))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "memory allocation failed"); /* 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))); - } /* end if */ + } /* Copy the data into the heap */ H5MM_memcpy(heap->dblk_image + offset, buf, buf_size); *offset_out = offset; - CATCH - /* No special processing on exit */ - -END_FUNC(PRIV) /* H5HL_insert() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5HL_insert() */ /*------------------------------------------------------------------------- * Function: H5HL_remove @@ -731,11 +757,15 @@ END_FUNC(PRIV) /* H5HL_insert() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_remove(H5F_t *f, H5HL_t *heap, size_t offset, size_t size)) +herr_t +H5HL_remove(H5F_t *f, H5HL_t *heap, size_t offset, size_t size) +{ + H5HL_free_t *fl = NULL; + herr_t ret_value = SUCCEED; - H5HL_free_t *fl = NULL; + FUNC_ENTER_NOAPI(FAIL) - /* check arguments */ + /* Check arguments */ HDassert(f); HDassert(heap); HDassert(size > 0); @@ -746,17 +776,17 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_remove(H5F_t *f, H5HL_t *heap, HDassert(offset < heap->dblk_size); HDassert(offset + size <= heap->dblk_size); - /* Mark heap as dirty in cache */ - /* (A bit early in the process, but it's difficult to determine in the + /* Mark heap as dirty in cache + * + * (A bit early in the process, but it's difficult to determine in the * code below where to mark the heap as dirty, especially in error cases, * so we just accept that an extra flush of the heap info could occur * if an error occurs -QAK) */ if (FAIL == H5HL__dirty(heap)) - H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark heap as dirty"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTMARKDIRTY, FAIL, "unable to mark heap as dirty"); - /* - * Check if this chunk can be prepended or appended to an already + /* Check if this chunk can be prepended or appended to an already * free chunk. It might also fall between two chunks in such a way * that all three chunks can be combined into one. */ @@ -779,17 +809,17 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_remove(H5F_t *f, H5HL_t *heap, 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, heap)) - H5E_THROW(H5E_CANTFREE, "heap size minimization failed"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "heap size minimization failed"); } - H5_LEAVE(SUCCEED); + HGOTO_DONE(SUCCEED) } fl2 = fl2->next; } if (((fl->offset + fl->size) == heap->dblk_size) && ((2 * fl->size) > heap->dblk_size)) { if (FAIL == H5HL__minimize_heap_space(f, heap)) - H5E_THROW(H5E_CANTFREE, "heap size minimization failed"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "heap size minimization failed"); } - H5_LEAVE(SUCCEED); + HGOTO_DONE(SUCCEED) } else if (fl->offset + fl->size == offset) { fl->size += size; @@ -802,20 +832,20 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_remove(H5F_t *f, H5HL_t *heap, 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, heap)) - H5E_THROW(H5E_CANTFREE, "heap size minimization failed"); - } /* end if */ - H5_LEAVE(SUCCEED); - } /* end if */ + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "heap size minimization failed"); + } + HGOTO_DONE(SUCCEED) + } fl2 = fl2->next; - } /* end while */ + } if (((fl->offset + fl->size) == heap->dblk_size) && ((2 * fl->size) > heap->dblk_size)) { if (FAIL == H5HL__minimize_heap_space(f, heap)) - H5E_THROW(H5E_CANTFREE, "heap size minimization failed"); - } /* end if */ - H5_LEAVE(SUCCEED); - } /* end if */ + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "heap size minimization failed"); + } + HGOTO_DONE(SUCCEED) + } fl = fl->next; - } /* end while */ + } /* * The amount which is being removed must be large enough to @@ -828,14 +858,12 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_remove(H5F_t *f, H5HL_t *heap, HDfprintf(H5DEBUG(HL), "H5HL: lost %lu bytes\n", (unsigned long)size); } #endif - H5_LEAVE(SUCCEED); - } /* end if */ + HGOTO_DONE(SUCCEED) + } - /* - * Add an entry to the free list. - */ + /* Add an entry to the free list */ if (NULL == (fl = H5FL_MALLOC(H5HL_free_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "memory allocation failed"); fl->offset = offset; fl->size = size; HDassert(fl->offset == H5HL_ALIGN(fl->offset)); @@ -848,12 +876,11 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_remove(H5F_t *f, H5HL_t *heap, if (((fl->offset + fl->size) == heap->dblk_size) && ((2 * fl->size) > heap->dblk_size)) if (FAIL == H5HL__minimize_heap_space(f, heap)) - H5E_THROW(H5E_CANTFREE, "heap size minimization failed"); - - CATCH - /* No special processing on exit */ + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "heap size minimization failed"); -END_FUNC(PRIV) /* end H5HL_remove() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL_remove() */ /*------------------------------------------------------------------------- * Function: H5HL_delete @@ -867,15 +894,19 @@ END_FUNC(PRIV) /* end H5HL_remove() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_delete(H5F_t *f, haddr_t addr)) - +herr_t +H5HL_delete(H5F_t *f, 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; - /* check arguments */ + FUNC_ENTER_NOAPI(FAIL) + + /* Check arguments */ HDassert(f); HDassert(H5F_addr_defined(addr)); @@ -888,7 +919,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_delete(H5F_t *f, haddr_t addr) /* Protect the local heap prefix */ if (NULL == (prfx = (H5HL_prfx_t *)H5AC_protect(f, H5AC_LHEAP_PRFX, addr, &prfx_udata, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTPROTECT, "unable to load heap prefix"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to load heap prefix"); /* Get the pointer to the heap */ heap = prfx->heap; @@ -898,21 +929,22 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_delete(H5F_t *f, haddr_t addr) /* Protect the local heap data block */ if (NULL == (dblk = (H5HL_dblk_t *)H5AC_protect(f, H5AC_LHEAP_DBLK, heap->dblk_addr, heap, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTPROTECT, "unable to load heap data block"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to load heap data block"); /* Set the flags for releasing the prefix and data block */ cache_flags |= H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG; - CATCH +done: /* Release the data block from the cache, now deleted */ if (dblk && heap && H5AC_unprotect(f, H5AC_LHEAP_DBLK, heap->dblk_addr, dblk, cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release local heap data block"); + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release local heap data block"); /* Release the prefix from the cache, now deleted */ if (prfx && heap && H5AC_unprotect(f, H5AC_LHEAP_PRFX, heap->prfx_addr, prfx, cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release local heap prefix"); + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release local heap prefix"); -END_FUNC(PRIV) /* end H5HL_delete() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL_delete() */ /*------------------------------------------------------------------------- * Function: H5HL_get_size @@ -926,13 +958,17 @@ END_FUNC(PRIV) /* end H5HL_delete() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_get_size(H5F_t *f, haddr_t addr, size_t *size)) +herr_t +H5HL_get_size(H5F_t *f, 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 = NULL; /* Heap data structure */ + herr_t ret_value = SUCCEED; - 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 = NULL; /* Heap data structure */ + FUNC_ENTER_NOAPI(FAIL) - /* check arguments */ + /* Check arguments */ HDassert(f); HDassert(H5F_addr_defined(addr)); HDassert(size); @@ -946,7 +982,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_get_size(H5F_t *f, haddr_t add /* Protect the local heap prefix */ if (NULL == (prfx = (H5HL_prfx_t *)H5AC_protect(f, H5AC_LHEAP_PRFX, addr, &prfx_udata, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to load heap prefix"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to load heap prefix"); /* Get the pointer to the heap */ heap = prfx->heap; @@ -954,11 +990,12 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_get_size(H5F_t *f, haddr_t add /* Set the size to return */ *size = heap->dblk_size; - CATCH +done: if (prfx && FAIL == H5AC_unprotect(f, H5AC_LHEAP_PRFX, heap->prfx_addr, prfx, H5AC__NO_FLAGS_SET)) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release local heap prefix"); + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release local heap prefix"); -END_FUNC(PRIV) /* end H5HL_get_size() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL_get_size() */ /*------------------------------------------------------------------------- * Function: H5HL_heapsize @@ -973,13 +1010,17 @@ END_FUNC(PRIV) /* end H5HL_get_size() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_heapsize(H5F_t *f, haddr_t addr, hsize_t *heap_size)) +herr_t +H5HL_heapsize(H5F_t *f, 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 = NULL; /* Heap data structure */ + herr_t ret_value = SUCCEED; - 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 = NULL; /* Heap data structure */ + FUNC_ENTER_NOAPI(FAIL) - /* check arguments */ + /* Check arguments */ HDassert(f); HDassert(H5F_addr_defined(addr)); HDassert(heap_size); @@ -993,7 +1034,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_heapsize(H5F_t *f, haddr_t add /* Protect the local heap prefix */ if (NULL == (prfx = (H5HL_prfx_t *)H5AC_protect(f, H5AC_LHEAP_PRFX, addr, &prfx_udata, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to load heap prefix"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to load heap prefix"); /* Get the pointer to the heap */ heap = prfx->heap; @@ -1001,8 +1042,9 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_heapsize(H5F_t *f, haddr_t add /* Accumulate the size of the local heap */ *heap_size += (hsize_t)(heap->prfx_size + heap->dblk_size); - CATCH +done: if (prfx && FAIL == H5AC_unprotect(f, H5AC_LHEAP_PRFX, heap->prfx_addr, prfx, H5AC__NO_FLAGS_SET)) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release local heap prefix"); + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release local heap prefix"); -END_FUNC(PRIV) /* end H5HL_heapsize() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL_heapsize() */ diff --git a/src/H5HLcache.c b/src/H5HLcache.c index 989a4f5..bcc8b2c 100644 --- a/src/H5HLcache.c +++ b/src/H5HLcache.c @@ -252,7 +252,7 @@ H5HL__fl_deserialize(H5HL_t *heap) heap->freelist = fl; tail = fl; fl = NULL; - } /* end while */ + } done: if (ret_value < 0) @@ -298,7 +298,7 @@ H5HL__fl_serialize(const H5HL_t *heap) H5F_ENCODE_LENGTH_LEN(image, H5HL_FREE_NULL, heap->sizeof_size) H5F_ENCODE_LENGTH_LEN(image, fl->size, heap->sizeof_size) - } /* end for */ + } FUNC_LEAVE_NOAPI_VOID @@ -452,13 +452,13 @@ H5HL__cache_prefix_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED /* Build free list */ if (H5HL__fl_deserialize(heap) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, NULL, "can't initialize free list") - } /* end if */ + } else /* Note that the heap should _NOT_ be a single * object in the cache */ heap->single_cache_obj = FALSE; - } /* end if */ + } /* Set return value */ ret_value = prfx; @@ -469,12 +469,12 @@ done: if (prfx) { if (FAIL == H5HL__prfx_dest(prfx)) HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, NULL, "unable to destroy local heap prefix"); - } /* end if */ + } else { if (heap && FAIL == H5HL__dest(heap)) HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, NULL, "unable to destroy local heap"); - } /* end else */ - } /* end if */ + } + } FUNC_LEAVE_NOAPI(ret_value) } /* end H5HL__cache_prefix_deserialize() */ @@ -590,7 +590,7 @@ H5HL__cache_prefix_serialize(const H5_ATTR_NDEBUG_UNUSED H5F_t *f, void *_image, gap = heap->prfx_size - (size_t)(image - (uint8_t *)_image); HDmemset(image, 0, gap); image += gap; - } /* end if */ + } /* Serialize the free list into the heap data's image */ H5HL__fl_serialize(heap); @@ -600,14 +600,14 @@ H5HL__cache_prefix_serialize(const H5_ATTR_NDEBUG_UNUSED H5F_t *f, void *_image, /* Sanity check */ HDassert((size_t)(image - (uint8_t *)_image) + heap->dblk_size == len); - } /* end if */ + } else { /* Sanity check */ HDassert((size_t)(image - (uint8_t *)_image) <= len); /* Clear rest of local heap */ HDmemset(image, 0, len - (size_t)(image - (uint8_t *)_image)); - } /* end else */ + } FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HL__cache_prefix_serialize() */ @@ -738,7 +738,7 @@ H5HL__cache_datablock_deserialize(const void *image, size_t len, void *_udata, h /* Build free list */ if (FAIL == H5HL__fl_deserialize(heap)) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, NULL, "can't initialize free list"); - } /* end if */ + } /* Set return value */ ret_value = dblk; @@ -894,7 +894,7 @@ H5HL__cache_datablock_notify(H5C_notify_action_t action, void *_thing) default: HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unknown action from metadata cache") break; - } /* end switch */ + } done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5HLdbg.c b/src/H5HLdbg.c index 76e4ec0..305014b 100644 --- a/src/H5HLdbg.c +++ b/src/H5HLdbg.c @@ -44,14 +44,17 @@ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, - H5HL_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth)) - +herr_t +H5HL_debug(H5F_t *f, 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); @@ -61,7 +64,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, HDassert(fwidth >= 0); if (NULL == (h = (H5HL_t *)H5HL_protect(f, addr, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to load/protect local heap"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to load/protect local heap") HDfprintf(stream, "%*sLocal Heap...\n", indent, ""); HDfprintf(stream, "%*s%-*s %zu\n", indent, "", fwidth, "Header size (in bytes):", h->prfx_size); @@ -73,7 +76,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, * the heap. */ if (NULL == (marker = (uint8_t *)H5MM_calloc(h->dblk_size))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "memory allocation failed") HDfprintf(stream, "%*sFree Blocks (offset, size):\n", indent, ""); for (free_block = 0, freelist = h->freelist; freelist; freelist = freelist->next, free_block++) { @@ -92,13 +95,13 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, if (marker[freelist->offset + i]) overlap++; marker[freelist->offset + i] = 1; - } /* end for */ + } if (overlap) HDfprintf(stream, "***THAT FREE BLOCK OVERLAPPED A PREVIOUS ONE!\n"); else amount_free += freelist->size; - } /* end else */ - } /* end for */ + } + } if (h->dblk_size) HDfprintf(stream, "%*s%-*s %.2f%%\n", indent, "", fwidth, "Percent of heap used:", @@ -107,11 +110,12 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, /* Print the data in a VMS-style octal dump */ H5_buffer_dump(stream, indent, h->dblk_image, marker, (size_t)0, h->dblk_size); - CATCH +done: if (h && FAIL == H5HL_unprotect(h)) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release/unprotect local heap"); + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release/unprotect local heap") if (marker && NULL != (marker = (uint8_t *)H5MM_xfree(marker))) - H5E_THROW(H5E_CANTFREE, "can't free marker buffer"); + HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "can't free marker buffer") -END_FUNC(PRIV) /* end H5HL_debug() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL_debug() */ diff --git a/src/H5HLdblk.c b/src/H5HLdblk.c index f771de5..9e6fc4a 100644 --- a/src/H5HLdblk.c +++ b/src/H5HLdblk.c @@ -81,20 +81,24 @@ H5FL_DEFINE_STATIC(H5HL_dblk_t); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5HL_dblk_t *, NULL, NULL, H5HL__dblk_new(H5HL_t *heap)) +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; - H5HL_dblk_t *dblk = NULL; /* New local heap data block */ + FUNC_ENTER_PACKAGE /* 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") + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "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") + HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment heap ref. count") /* Link the heap & the data block */ dblk->heap = heap; @@ -103,13 +107,14 @@ BEGIN_FUNC(PKG, ERR, H5HL_dblk_t *, NULL, NULL, H5HL__dblk_new(H5HL_t *heap)) /* Set the return value */ ret_value = dblk; - CATCH +done: /* 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() */ + FUNC_LEAVE_NOAPI(ret_value); +} /* end H5HL__dblk_new() */ /*------------------------------------------------------------------------- * Function: H5HL__dblk_dest @@ -123,7 +128,12 @@ END_FUNC(PKG) /* end H5HL__dblk_new() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5HL__dblk_dest(H5HL_dblk_t *dblk)) +herr_t +H5HL__dblk_dest(H5HL_dblk_t *dblk) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* check arguments */ HDassert(dblk); @@ -135,18 +145,19 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5HL__dblk_dest(H5HL_dblk_t *dblk)) /* Decrement ref. count on heap data structure */ if (FAIL == H5HL__dec_rc(dblk->heap)) - H5E_THROW(H5E_CANTDEC, "can't decrement heap ref. count") + HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement heap ref. count") /* Unlink heap from data block */ dblk->heap = NULL; - } /* end if */ + } - CATCH +done: /* 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() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL__dblk_dest() */ /*------------------------------------------------------------------------- * Function: H5HL__dblk_realloc @@ -160,14 +171,18 @@ END_FUNC(PKG) /* end H5HL__dblk_dest() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5HL__dblk_realloc(H5F_t *f, H5HL_t *heap, size_t new_heap_size)) - +herr_t +H5HL__dblk_realloc(H5F_t *f, 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; - /* check arguments */ + FUNC_ENTER_PACKAGE + + /* Check arguments */ HDassert(heap); HDassert(new_heap_size > 0); @@ -176,12 +191,12 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5HL__dblk_realloc(H5F_t *f, H5HL_t old_heap_size = heap->dblk_size; H5_CHECK_OVERFLOW(old_heap_size, size_t, hsize_t); if (FAIL == H5MF_xfree(f, H5FD_MEM_LHEAP, old_addr, (hsize_t)old_heap_size)) - H5E_THROW(H5E_CANTFREE, "can't free old local heap data"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "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, (hsize_t)new_heap_size))) - H5E_THROW(H5E_CANTALLOC, "unable to allocate file space for local heap"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "unable to allocate file space for local heap"); /* Update heap info*/ heap->dblk_addr = new_addr; @@ -197,8 +212,8 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5HL__dblk_realloc(H5F_t *f, H5HL_t /* 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 */ + HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, FAIL, "unable to resize heap in cache"); + } else { /* Sanity check */ HDassert(H5F_addr_ne(heap->prfx_addr + heap->prfx_size, old_addr)); @@ -206,50 +221,49 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5HL__dblk_realloc(H5F_t *f, H5HL_t /* 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 */ + HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, FAIL, "unable to resize heap (data block) in cache"); + } + } 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"); + 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 (FAIL == H5AC_resize_entry(heap->prfx, (size_t)heap->prfx_size)) - H5E_THROW(H5E_CANTRESIZE, "unable to resize heap prefix in cache"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, FAIL, "unable to resize heap prefix in cache"); /* Insert data block into cache (pinned) */ if (FAIL == H5AC_insert_entry(f, H5AC_LHEAP_DBLK, new_addr, dblk, H5AC__PIN_ENTRY_FLAG)) - H5E_THROW(H5E_CANTINIT, "unable to cache local heap data block"); + 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 (FAIL == H5AC_resize_entry(heap->dblk, (size_t)new_heap_size)) - H5E_THROW(H5E_CANTRESIZE, "unable to resize heap data block in cache"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, FAIL, "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 */ + HGOTO_ERROR(H5E_HEAP, H5E_CANTMOVE, FAIL, "unable to move heap data block in cache"); + } + } - CATCH +done: /* 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() */ + } + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL__dblk_realloc() */ diff --git a/src/H5HLint.c b/src/H5HLint.c index 069bad8..42d6744 100644 --- a/src/H5HLint.c +++ b/src/H5HLint.c @@ -80,10 +80,13 @@ H5FL_DEFINE_STATIC(H5HL_t); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5HL_t *, NULL, NULL, - H5HL__new(size_t sizeof_size, size_t sizeof_addr, size_t prfx_size)) +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; - H5HL_t *heap = NULL; /* New local heap */ + FUNC_ENTER_PACKAGE /* check arguments */ HDassert(sizeof_size > 0); @@ -92,7 +95,7 @@ BEGIN_FUNC(PKG, ERR, H5HL_t *, NULL, NULL, /* Allocate new local heap structure */ if (NULL == (heap = H5FL_CALLOC(H5HL_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "memory allocation failed") /* Initialize non-zero fields */ heap->sizeof_size = sizeof_size; @@ -102,12 +105,13 @@ BEGIN_FUNC(PKG, ERR, H5HL_t *, NULL, NULL, /* Set the return value */ ret_value = heap; - CATCH +done: if (!ret_value && heap != NULL) if (NULL == (heap = H5FL_FREE(H5HL_t, heap))) - H5E_THROW(H5E_CANTFREE, "can't free heap memory"); + HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, NULL, "can't free heap memory") -END_FUNC(PKG) /* end H5HL__new() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL__new() */ /*------------------------------------------------------------------------- * Function: H5HL__inc_rc @@ -121,7 +125,10 @@ END_FUNC(PKG) /* end H5HL__new() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, NOERR, herr_t, SUCCEED, -, H5HL__inc_rc(H5HL_t *heap)) +herr_t +H5HL__inc_rc(H5HL_t *heap) +{ + FUNC_ENTER_PACKAGE_NOERR /* check arguments */ HDassert(heap); @@ -129,7 +136,8 @@ BEGIN_FUNC(PKG, NOERR, herr_t, SUCCEED, -, H5HL__inc_rc(H5HL_t *heap)) /* Increment heap's ref. count */ heap->rc++; -END_FUNC(PKG) /* end H5HL__inc_rc() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5HL__inc_rc() */ /*------------------------------------------------------------------------- * Function: H5HL__dec_rc @@ -143,7 +151,12 @@ END_FUNC(PKG) /* end H5HL__inc_rc() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5HL__dec_rc(H5HL_t *heap)) +herr_t +H5HL__dec_rc(H5HL_t *heap) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* check arguments */ HDassert(heap); @@ -151,12 +164,13 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, 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 && FAIL == H5HL__dest(heap)) - H5E_THROW(H5E_CANTFREE, "unable to destroy local heap"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy local heap"); -END_FUNC(PKG) /* end H5HL__dec_rc() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL__dec_rc() */ /*------------------------------------------------------------------------- * Function: H5HL__dest @@ -170,7 +184,12 @@ END_FUNC(PKG) /* end H5HL__dec_rc() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5HL__dest(H5HL_t *heap)) +herr_t +H5HL__dest(H5HL_t *heap) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* check arguments */ HDassert(heap); @@ -181,20 +200,21 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5HL__dest(H5HL_t *heap)) HDassert(heap->prfx == NULL); HDassert(heap->dblk == NULL); - CATCH + /* Use DONE errors here to try to free as much as possible */ if (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"); + HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free local heap data block image"); while (heap->freelist) { H5HL_free_t *fl; fl = heap->freelist; heap->freelist = fl->next; if (NULL != (fl = H5FL_FREE(H5HL_free_t, fl))) - H5E_THROW(H5E_CANTFREE, "unable to free local heap free list"); - } /* end while */ + HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free local heap free list"); + } if (NULL != (heap = H5FL_FREE(H5HL_t, heap))) - H5E_THROW(H5E_CANTFREE, "unable to free local heap"); + HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free local heap"); -END_FUNC(PKG) /* end H5HL__dest() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL__dest() */ diff --git a/src/H5HLpkg.h b/src/H5HLpkg.h index dbac1b9..0ba3b1c 100644 --- a/src/H5HLpkg.h +++ b/src/H5HLpkg.h @@ -54,7 +54,7 @@ H5FL_BLK_EXTERN(lheap_chunk); #define H5_MY_PKG H5HL #define H5_MY_PKG_ERR H5E_HEAP #define H5_MY_PKG_INIT NO -#endif /* H5HL_PACKAGE */ +#endif #define H5HL_SIZEOF_HDR(F) \ H5HL_ALIGN(H5_SIZEOF_MAGIC + /* heap signature */ \ diff --git a/src/H5HLprfx.c b/src/H5HLprfx.c index 90f6c74..03e3999 100644 --- a/src/H5HLprfx.c +++ b/src/H5HLprfx.c @@ -80,20 +80,24 @@ H5FL_DEFINE_STATIC(H5HL_prfx_t); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5HL_prfx_t *, NULL, NULL, H5HL__prfx_new(H5HL_t *heap)) +H5HL_prfx_t * +H5HL__prfx_new(H5HL_t *heap) +{ + H5HL_prfx_t *prfx = NULL; /* New local heap prefix */ + H5HL_prfx_t *ret_value = NULL; - H5HL_prfx_t *prfx = NULL; /* New local heap prefix */ + FUNC_ENTER_PACKAGE /* 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") + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "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") + HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment heap ref. count") /* Link the heap & the prefix */ prfx->heap = heap; @@ -102,13 +106,14 @@ BEGIN_FUNC(PKG, ERR, H5HL_prfx_t *, NULL, NULL, H5HL__prfx_new(H5HL_t *heap)) /* Set the return value */ ret_value = prfx; - CATCH +done: /* 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() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL__prfx_new() */ /*------------------------------------------------------------------------- * Function: H5HL__prfx_dest @@ -122,7 +127,12 @@ END_FUNC(PKG) /* end H5HL__prfx_new() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5HL__prfx_dest(H5HL_prfx_t *prfx)) +herr_t +H5HL__prfx_dest(H5HL_prfx_t *prfx) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* check arguments */ HDassert(prfx); @@ -134,15 +144,16 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5HL__prfx_dest(H5HL_prfx_t *prfx)) /* Decrement ref. count on heap data structure */ if (FAIL == H5HL__dec_rc(prfx->heap)) - H5E_THROW(H5E_CANTDEC, "can't decrement heap ref. count") + HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement heap ref. count") /* Unlink heap from prefix */ prfx->heap = NULL; - } /* end if */ + } - CATCH +done: /* 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() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL__prfx_dest() */ diff --git a/src/H5HLprivate.h b/src/H5HLprivate.h index 5c98846..02e07eb 100644 --- a/src/H5HLprivate.h +++ b/src/H5HLprivate.h @@ -66,4 +66,4 @@ H5_DLL herr_t H5HL_unprotect(H5HL_t *heap); /* Debugging routines for dumping file structures */ H5_DLL herr_t H5HL_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth); -#endif +#endif /* H5HLprivate_H */ diff --git a/src/H5L.c b/src/H5L.c index 982813b..d3c0fe3 100644 --- a/src/H5L.c +++ b/src/H5L.c @@ -21,17 +21,13 @@ /* Headers */ /***********/ #include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ #include "H5CXprivate.h" /* API Contexts */ -#include "H5Dprivate.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5ESprivate.h" /* Event Sets */ -#include "H5Fprivate.h" /* File access */ #include "H5Gprivate.h" /* Groups */ #include "H5Iprivate.h" /* IDs */ #include "H5Lpkg.h" /* Links */ #include "H5MMprivate.h" /* Memory management */ -#include "H5Oprivate.h" /* File objects */ #include "H5Pprivate.h" /* Property lists */ #include "H5VLprivate.h" /* Virtual Object Layer */ #include "H5VLnative_private.h" /* Native VOL */ @@ -40,96 +36,14 @@ /* Local Macros */ /****************/ -#define H5L_MIN_TABLE_SIZE 32 /* Minimum size of the user-defined link type table if it is allocated */ - /******************/ /* Local Typedefs */ /******************/ -/* User data for path traversal routine for getting link info by name */ -typedef struct { - H5L_info2_t *linfo; /* Buffer to return to user */ -} H5L_trav_gi_t; - -/* User data for path traversal callback to creating a link */ -typedef struct { - H5F_t * file; /* Pointer to the file */ - H5P_genplist_t * lc_plist; /* Link creation property list */ - H5G_name_t * path; /* Path to object being linked */ - H5O_obj_create_t *ocrt_info; /* Pointer to object creation info */ - H5O_link_t * lnk; /* Pointer to link information to insert */ -} H5L_trav_cr_t; - -/* User data for path traversal routine for moving and renaming a link */ -typedef struct { - const char * dst_name; /* Destination name for moving object */ - H5T_cset_t cset; /* Char set for new name */ - const H5G_loc_t *dst_loc; /* Destination location for moving object */ - unsigned dst_target_flags; /* Target flags for destination object */ - hbool_t copy; /* TRUE if this is a copy operation */ - size_t orig_nlinks; /* The original value for the # of soft / UD links that can be traversed */ -} H5L_trav_mv_t; - -/* User data for path traversal routine for moving and renaming an object */ -typedef struct { - H5F_t * file; /* Pointer to the file */ - H5O_link_t *lnk; /* Pointer to link information to insert */ - hbool_t copy; /* TRUE if this is a copy operation */ -} H5L_trav_mv2_t; - -/* User data for path traversal routine for checking if a link exists */ -typedef struct { - /* Down */ - char *sep; /* Pointer to next separator in the string */ - - /* Up */ - hbool_t *exists; /* Whether the link exists or not */ -} H5L_trav_le_t; - -/* User data for path traversal routine for getting link value */ -typedef struct { - size_t size; /* Size of user buffer */ - void * buf; /* User buffer */ -} H5L_trav_gv_t; - /********************/ /* Local Prototypes */ /********************/ -static int H5L__find_class_idx(H5L_type_t id); -static herr_t H5L__link_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, - H5G_loc_t *obj_loc, void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/); -static herr_t H5L__create_real(const H5G_loc_t *link_loc, const char *link_name, H5G_name_t *obj_path, - H5F_t *obj_file, H5O_link_t *lnk, H5O_obj_create_t *ocrt_info, hid_t lcpl_id); -static herr_t H5L__get_val_real(const H5O_link_t *lnk, void *buf, size_t size); -static herr_t H5L__get_val_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, - H5G_loc_t *obj_loc, void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/); -static herr_t H5L__get_val_by_idx_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, - H5G_loc_t *obj_loc, void *_udata /*in,out*/, - H5G_own_loc_t *own_loc /*out*/); -static herr_t H5L__delete_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, - H5G_loc_t *obj_loc, void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/); -static herr_t H5L__delete_by_idx_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, - H5G_loc_t *obj_loc, void *_udata /*in,out*/, - H5G_own_loc_t *own_loc /*out*/); -static herr_t H5L__move_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, - H5G_loc_t *obj_loc, void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/); -static herr_t H5L__move_dest_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, - H5G_loc_t *obj_loc, void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/); -static herr_t H5L__exists_final_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, - H5G_loc_t *obj_loc, void *_udata /*in,out*/, - H5G_own_loc_t *own_loc /*out*/); -static herr_t H5L__exists_inter_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, - H5G_loc_t *obj_loc, void *_udata /*in,out*/, - H5G_own_loc_t *own_loc /*out*/); -static herr_t H5L__get_info_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, - H5G_loc_t *obj_loc, void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/); -static herr_t H5L__get_info_by_idx_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, - H5G_loc_t *obj_loc, void *_udata /*in,out*/, - H5G_own_loc_t *own_loc /*out*/); -static herr_t H5L__get_name_by_idx_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, - H5G_loc_t *obj_loc, void *_udata /*in,out*/, - H5G_own_loc_t *own_loc /*out*/); static herr_t H5L__create_soft_api_common(const char *link_target, hid_t link_loc_id, const char *link_name, hid_t lcpl_id, hid_t lapl_id, void **token_ptr, H5VL_object_t **_vol_obj_ptr); @@ -151,9 +65,6 @@ static herr_t H5L__iterate_api_common(hid_t group_id, H5_index_t idx_type, H5_it /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ @@ -162,99 +73,6 @@ hbool_t H5_PKG_INIT_VAR = FALSE; /* Local Variables */ /*******************/ -/* Information about user-defined links */ -static size_t H5L_table_alloc_g = 0; -static size_t H5L_table_used_g = 0; -static H5L_class_t *H5L_table_g = NULL; - -/*------------------------------------------------------------------------- - * Function: H5L_init - * - * Purpose: Initialize the interface from some other package. - * - * Return: Success: non-negative - * - * Failure: negative - * - * Programmer: James Laird - * Thursday, July 13, 2006 - * - *------------------------------------------------------------------------- - */ -herr_t -H5L_init(void) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - /* FUNC_ENTER() does all the work */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5L_init() */ - -/*------------------------------------------------------------------------- - * Function: H5L__init_package - * - * Purpose: Initialize information specific to H5L interface. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: James Laird - * Tuesday, January 24, 2006 - * - *------------------------------------------------------------------------- - */ -herr_t -H5L__init_package(void) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* Initialize user-defined link classes */ - if (H5L_register_external() < 0) - HGOTO_ERROR(H5E_LINK, H5E_NOTREGISTERED, FAIL, "unable to register external link class") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5L_init_package() */ - -/*------------------------------------------------------------------------- - * Function: H5L_term_package - * - * Purpose: Terminate any resources allocated in H5L__init_package. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: James Laird - * Tuesday, January 24, 2006 - * - *------------------------------------------------------------------------- - */ -int -H5L_term_package(void) -{ - int n = 0; - - FUNC_ENTER_NOAPI_NOINIT_NOERR - - if (H5_PKG_INIT_VAR) { - /* Free the table of link types */ - if (H5L_table_g) { - H5L_table_g = (H5L_class_t *)H5MM_xfree(H5L_table_g); - H5L_table_used_g = H5L_table_alloc_g = 0; - n++; - } /* end if */ - - /* Mark the interface as uninitialized */ - if (0 == n) - H5_PKG_INIT_VAR = FALSE; - } /* end if */ - - FUNC_LEAVE_NOAPI(n) -} /* H5L_term_package() */ - /*------------------------------------------------------------------------- * Function: H5Lmove * @@ -1603,8 +1421,8 @@ done: htri_t H5Lis_registered(H5L_type_t id) { - size_t i; /* Local index variable */ - htri_t ret_value = FALSE; /* Return value */ + hbool_t is_registered = FALSE; + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("t", "Ll", id); @@ -1614,11 +1432,10 @@ H5Lis_registered(H5L_type_t id) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid link type id number") /* Is the link class already registered? */ - for (i = 0; i < H5L_table_used_g; i++) - if (H5L_table_g[i].id == id) { - ret_value = TRUE; - break; - } /* end if */ + if (H5L_is_registered(id, &is_registered) < 0) + HGOTO_ERROR(H5E_LINK, H5E_BADTYPE, FAIL, "could not determine registration status of UD link type") + + ret_value = is_registered ? TRUE : FALSE; done: FUNC_LEAVE_API(ret_value) @@ -2110,1984 +1927,3 @@ H5Lunpack_elink_val(const void *_ext_linkval, size_t link_size, unsigned *flags, done: FUNC_LEAVE_API(ret_value) } /* end H5Lunpack_elink_val() */ - -/* - *------------------------------------------------------------------------- - *------------------------------------------------------------------------- - * N O A P I F U N C T I O N S B E Y O N D T H I S P O I N T - *------------------------------------------------------------------------- - *------------------------------------------------------------------------- - */ - -/*------------------------------------------------------------------------- - * Function: H5L__find_class_idx - * - * Purpose: Given a link class ID, return the offset in the global array - * that holds all the registered link classes. - * - * Return: Success: Non-negative index of entry in global - * link class table. - * Failure: Negative - * - * Programmer: James Laird - * Monday, July 10, 2006 - * - *------------------------------------------------------------------------- - */ -static int -H5L__find_class_idx(H5L_type_t id) -{ - size_t i; /* Local index variable */ - int ret_value = FAIL; /* Return value */ - - FUNC_ENTER_STATIC_NOERR - - for (i = 0; i < H5L_table_used_g; i++) - if (H5L_table_g[i].id == id) - HGOTO_DONE((int)i) - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5L__find_class_idx */ - -/*------------------------------------------------------------------------- - * Function: H5L_find_class - * - * Purpose: Given a link class ID return a pointer to a global struct that - * defines the link class. - * - * Return: Success: Ptr to entry in global link class table. - * Failure: NULL - * - * Programmer: James Laird - * Monday, July 10, 2006 - * - *------------------------------------------------------------------------- - */ -const H5L_class_t * -H5L_find_class(H5L_type_t id) -{ - int idx; /* Filter index in global table */ - H5L_class_t *ret_value = NULL; /* Return value */ - - FUNC_ENTER_NOAPI(NULL) - - /* Get the index in the global table */ - if ((idx = H5L__find_class_idx(id)) < 0) - HGOTO_ERROR(H5E_LINK, H5E_NOTREGISTERED, NULL, "unable to find link class") - - /* Set return value */ - ret_value = H5L_table_g + idx; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5L_find_class */ - -/*------------------------------------------------------------------------- - * Function: H5L_register - * - * Purpose: Registers a class of user-defined links, or changes the - * behavior of an existing class. - * - * See H5Lregister for full documentation. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: James Laird - * Monday, July 10, 2006 - * - *------------------------------------------------------------------------- - */ -herr_t -H5L_register(const H5L_class_t *cls) -{ - size_t i; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - HDassert(cls); - HDassert(cls->id >= 0 && cls->id <= H5L_TYPE_MAX); - - /* Is the link type already registered? */ - for (i = 0; i < H5L_table_used_g; i++) - if (H5L_table_g[i].id == cls->id) - break; - - /* Filter not already registered */ - if (i >= H5L_table_used_g) { - if (H5L_table_used_g >= H5L_table_alloc_g) { - size_t n = MAX(H5L_MIN_TABLE_SIZE, (2 * H5L_table_alloc_g)); - H5L_class_t *table = (H5L_class_t *)H5MM_realloc(H5L_table_g, (n * sizeof(H5L_class_t))); - if (!table) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to extend link type table") - H5L_table_g = table; - H5L_table_alloc_g = n; - } /* end if */ - - /* Initialize */ - i = H5L_table_used_g++; - } /* end if */ - - /* Copy link class info into table */ - H5MM_memcpy(H5L_table_g + i, cls, sizeof(H5L_class_t)); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5L_register */ - -/*------------------------------------------------------------------------- - * Function: H5L_unregister - * - * Purpose: Unregisters a class of user-defined links. - * - * See H5Lunregister for full documentation. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: James Laird - * Monday, July 10, 2006 - * - *------------------------------------------------------------------------- - */ -herr_t -H5L_unregister(H5L_type_t id) -{ - size_t i; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - HDassert(id >= 0 && id <= H5L_TYPE_MAX); - - /* Is the filter already registered? */ - for (i = 0; i < H5L_table_used_g; i++) - if (H5L_table_g[i].id == id) - break; - - /* Fail if filter not found */ - if (i >= H5L_table_used_g) - HGOTO_ERROR(H5E_LINK, H5E_NOTREGISTERED, FAIL, "link class is not registered") - - /* Remove filter from table */ - /* Don't worry about shrinking table size (for now) */ - HDmemmove(&H5L_table_g[i], &H5L_table_g[i + 1], sizeof(H5L_class_t) * ((H5L_table_used_g - 1) - i)); - H5L_table_used_g--; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5L_unregister() */ - -/*------------------------------------------------------------------------- - * Function: H5L_link - * - * Purpose: Creates a link from OBJ_ID to CUR_NAME. See H5Olink() for - * full documentation. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: James Laird - * Tuesday, December 13, 2005 - * - *------------------------------------------------------------------------- - */ -herr_t -H5L_link(const H5G_loc_t *new_loc, const char *new_name, H5G_loc_t *obj_loc, hid_t lcpl_id) -{ - H5O_link_t lnk; /* Link to insert */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - /* Check args */ - HDassert(new_loc); - HDassert(obj_loc); - HDassert(new_name && *new_name); - - /* The link callback will check that the object isn't being hard linked - * into a different file, so we don't need to do it here (there could be - * external links along the path). - */ - - /* Construct link information for eventual insertion */ - lnk.type = H5L_TYPE_HARD; - lnk.u.hard.addr = obj_loc->oloc->addr; - - /* Create the link */ - if (H5L__create_real(new_loc, new_name, obj_loc->path, obj_loc->oloc->file, &lnk, NULL, lcpl_id) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create new link to object") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5L_link() */ - -/*------------------------------------------------------------------------- - * Function: H5L_link_object - * - * Purpose: Creates a new object and a link to it. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * Monday, April 9, 2007 - * - *------------------------------------------------------------------------- - */ -herr_t -H5L_link_object(const H5G_loc_t *new_loc, const char *new_name, H5O_obj_create_t *ocrt_info, hid_t lcpl_id) -{ - H5O_link_t lnk; /* Link to insert */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - /* Check args */ - HDassert(new_loc); - HDassert(new_name && *new_name); - HDassert(ocrt_info); - - /* The link callback will check that the object isn't being hard linked - * into a different file, so we don't need to do it here (there could be - * external links along the path). - */ - - /* Construct link information for eventual insertion */ - lnk.type = H5L_TYPE_HARD; - - /* Create the link */ - if (H5L__create_real(new_loc, new_name, NULL, NULL, &lnk, ocrt_info, lcpl_id) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create new link to object") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5L_link_object() */ - -/*------------------------------------------------------------------------- - * Function: H5L__link_cb - * - * Purpose: Callback for creating a link to an object. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * Monday, September 19, 2005 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5L__link_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t H5_ATTR_UNUSED *lnk, - H5G_loc_t *obj_loc, void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/) -{ - H5L_trav_cr_t *udata = (H5L_trav_cr_t *)_udata; /* User data passed in */ - H5G_t * grp = NULL; /* H5G_t for this group, opened to pass to user callback */ - hid_t grp_id = FAIL; /* Id for this group (passed to user callback */ - H5G_loc_t temp_loc; /* For UD callback */ - hbool_t temp_loc_init = FALSE; /* Temporary location for UD callback (temp_loc) has been initialized */ - hbool_t obj_created = FALSE; /* Whether an object was created (through a hard link) */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - /* Check if the name in this group resolved to a valid location */ - /* (which is not what we want) */ - if (obj_loc != NULL) - HGOTO_ERROR(H5E_LINK, H5E_EXISTS, FAIL, "name already exists") - - /* Check for crossing file boundaries with a new hard link */ - if (udata->lnk->type == H5L_TYPE_HARD) { - /* Check for creating an object */ - /* (only for hard links) */ - if (udata->ocrt_info) { - H5G_loc_t new_loc; /* Group location for new object */ - - /* Create new object at this location */ - if (NULL == - (udata->ocrt_info->new_obj = H5O_obj_create(grp_loc->oloc->file, udata->ocrt_info->obj_type, - udata->ocrt_info->crt_info, &new_loc))) - HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create object") - - /* Set address for hard link */ - udata->lnk->u.hard.addr = new_loc.oloc->addr; - - /* Set object path to use for setting object name (below) */ - udata->path = new_loc.path; - - /* Indicate that an object was created */ - obj_created = TRUE; - } /* end if */ - else { - /* Check that both objects are in same file */ - if (!H5F_SAME_SHARED(grp_loc->oloc->file, udata->file)) - HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, "interfile hard links are not allowed") - } /* end else */ - } /* end if */ - - /* Set 'standard' aspects of link */ - udata->lnk->corder = - 0; /* Will be re-written during group insertion, if the group is tracking creation order */ - udata->lnk->corder_valid = FALSE; /* Creation order not valid (yet) */ - - /* Check for non-default link creation properties */ - if (udata->lc_plist) { - /* Get character encoding property */ - if (H5CX_get_encoding(&udata->lnk->cset) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't get 'character set' property") - } /* end if */ - else - udata->lnk->cset = H5F_DEFAULT_CSET; /* Default character encoding for link */ - - /* Set the link's name correctly */ - /* Casting away const OK -QAK */ - udata->lnk->name = (char *)name; - - /* Insert link into group */ - if (H5G_obj_insert(grp_loc->oloc, name, udata->lnk, TRUE, - udata->ocrt_info ? udata->ocrt_info->obj_type : H5O_TYPE_UNKNOWN, - udata->ocrt_info ? udata->ocrt_info->crt_info : NULL) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create new link for object") - - /* Set object's path if it has been passed in and is not set */ - if (udata->path != NULL && udata->path->user_path_r == NULL) - if (H5G_name_set(grp_loc->path, udata->path, name) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "cannot set name") - - /* If link is a user-defined link, trigger its creation callback if it has one */ - if (udata->lnk->type >= H5L_TYPE_UD_MIN) { - const H5L_class_t *link_class; /* User-defined link class */ - - /* Get the link class for this type of link. */ - if (NULL == (link_class = H5L_find_class(udata->lnk->type))) - HGOTO_ERROR(H5E_LINK, H5E_NOTREGISTERED, FAIL, "unable to get class of UD link") - - if (link_class->create_func != NULL) { - H5O_loc_t temp_oloc; - H5G_name_t temp_path; - - /* Create a temporary location (or else H5G_open will do a shallow - * copy and wipe out grp_loc) - */ - H5G_name_reset(&temp_path); - if (H5O_loc_copy_deep(&temp_oloc, grp_loc->oloc) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTCOPY, FAIL, "unable to copy object location") - - temp_loc.oloc = &temp_oloc; - temp_loc.path = &temp_path; - temp_loc_init = TRUE; - - /* Set up location for user-defined callback */ - if (NULL == (grp = H5G_open(&temp_loc))) - HGOTO_ERROR(H5E_LINK, H5E_CANTOPENOBJ, FAIL, "unable to open group") - if ((grp_id = H5VL_wrap_register(H5I_GROUP, grp, TRUE)) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTREGISTER, FAIL, "unable to register ID for group") - - /* Make callback */ - if ((link_class->create_func)(name, grp_id, udata->lnk->u.ud.udata, udata->lnk->u.ud.size, - H5P_DEFAULT) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CALLBACK, FAIL, "link creation callback failed") - } /* end if */ - } /* end if */ - -done: - /* Check if an object was created */ - if (obj_created) { - H5O_loc_t oloc; /* Object location for created object */ - - /* Set up object location */ - HDmemset(&oloc, 0, sizeof(oloc)); - oloc.file = grp_loc->oloc->file; - oloc.addr = udata->lnk->u.hard.addr; - - /* Decrement refcount on new object's object header in memory */ - if (H5O_dec_rc_by_loc(&oloc) < 0) - HDONE_ERROR(H5E_LINK, H5E_CANTDEC, FAIL, "unable to decrement refcount on newly created object") - } /* end if */ - - /* Close the location given to the user callback if it was created */ - if (grp_id >= 0) { - if (H5I_dec_app_ref(grp_id) < 0) - HDONE_ERROR(H5E_LINK, H5E_CANTRELEASE, FAIL, "unable to close ID from UD callback") - } /* end if */ - else if (grp != NULL) { - if (H5G_close(grp) < 0) - HDONE_ERROR(H5E_LINK, H5E_CANTRELEASE, FAIL, "unable to close group given to UD callback") - } /* end if */ - else if (temp_loc_init) - H5G_loc_free(&temp_loc); - - /* Indicate that this callback didn't take ownership of the group * - * location for the object */ - *own_loc = H5G_OWN_NONE; - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5L__link_cb() */ - -/*------------------------------------------------------------------------- - * Function: H5L__create_real - * - * Purpose: Creates a link at a path location - * - * lnk should have linkclass-specific information already - * set, but this function will take care of setting name. - * - * obj_path can be NULL if the object's path doesn't need to - * be set, and obj_file can be NULL if the object is not a - * hard link. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * Monday, December 5, 2005 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5L__create_real(const H5G_loc_t *link_loc, const char *link_name, H5G_name_t *obj_path, H5F_t *obj_file, - H5O_link_t *lnk, H5O_obj_create_t *ocrt_info, hid_t lcpl_id) -{ - char * norm_link_name = NULL; /* Pointer to normalized link name */ - unsigned target_flags = H5G_TARGET_NORMAL; /* Flags to pass to group traversal function */ - H5P_genplist_t *lc_plist = NULL; /* Link creation property list */ - H5L_trav_cr_t udata; /* User data for callback */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - /* Check args */ - HDassert(link_loc); - HDassert(link_name && *link_name); - HDassert(lnk); - HDassert(lnk->type >= H5L_TYPE_HARD && lnk->type <= H5L_TYPE_MAX); - - /* Get normalized link name */ - if ((norm_link_name = H5G_normalize(link_name)) == NULL) - HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, "can't normalize name") - - /* Check for flags present in creation property list */ - if (lcpl_id != H5P_DEFAULT) { - unsigned crt_intmd_group; - - /* Get link creation property list */ - if (NULL == (lc_plist = (H5P_genplist_t *)H5I_object(lcpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") - - /* Get intermediate group creation property */ - if (H5CX_get_intermediate_group(&crt_intmd_group) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't get 'create intermediate group' property") - - if (crt_intmd_group > 0) - target_flags |= H5G_CRT_INTMD_GROUP; - } /* end if */ - - /* Set up user data - * FILE is used to make sure that hard links don't cross files, and - * should be NULL for other link types. - * LC_PLIST is a pointer to the link creation property list. - * PATH is a pointer to the path of the object being inserted if this is - * a hard link; this is used to set the paths to objects when they are - * created. For other link types, this is NULL. - * OCRT_INFO is a pointer to the structure for object creation. - * LNK is the link struct passed into this function. At this point all - * of its fields should be populated except for name, which is set when - * inserting it in the callback. - */ - udata.file = obj_file; - udata.lc_plist = lc_plist; - udata.path = obj_path; - udata.ocrt_info = ocrt_info; - udata.lnk = lnk; - - /* Traverse the destination path & create new link */ - if (H5G_traverse(link_loc, link_name, target_flags, H5L__link_cb, &udata) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTINSERT, FAIL, "can't insert link") - -done: - /* Free the normalized path name */ - if (norm_link_name) - H5MM_xfree(norm_link_name); - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5L__create_real() */ - -/*------------------------------------------------------------------------- - * Function: H5L__create_hard - * - * Purpose: Creates a hard link from NEW_NAME to CUR_NAME. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Robb Matzke - * Monday, April 6, 1998 - * - *------------------------------------------------------------------------- - */ -herr_t -H5L__create_hard(H5G_loc_t *cur_loc, const char *cur_name, const H5G_loc_t *link_loc, const char *link_name, - hid_t lcpl_id) -{ - char * norm_cur_name = NULL; /* Pointer to normalized current name */ - H5F_t * link_file = NULL; /* Pointer to file to link to */ - H5O_link_t lnk; /* Link to insert */ - H5G_loc_t obj_loc; /* Location of object to link to */ - H5G_name_t path; /* obj_loc's path*/ - H5O_loc_t oloc; /* obj_loc's oloc */ - hbool_t loc_valid = FALSE; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* Check args */ - HDassert(cur_loc); - HDassert(cur_name && *cur_name); - HDassert(link_loc); - HDassert(link_name && *link_name); - - /* Get normalized copy of the current name */ - if ((norm_cur_name = H5G_normalize(cur_name)) == NULL) - HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, "can't normalize name") - - /* Set up link data specific to hard links */ - lnk.type = H5L_TYPE_HARD; - - /* Get object location for object pointed to */ - obj_loc.path = &path; - obj_loc.oloc = &oloc; - H5G_loc_reset(&obj_loc); - if (H5G_loc_find(cur_loc, norm_cur_name, &obj_loc) < 0) - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "source object not found") - loc_valid = TRUE; - - /* Construct link information for eventual insertion */ - lnk.u.hard.addr = obj_loc.oloc->addr; - - /* Set destination's file information */ - link_file = obj_loc.oloc->file; - - /* Create actual link to the object. Pass in NULL for the path, since this - * function shouldn't change an object's user path. */ - if (H5L__create_real(link_loc, link_name, NULL, link_file, &lnk, NULL, lcpl_id) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create new link to object") - -done: - /* Free the object header location */ - if (loc_valid) - if (H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_LINK, H5E_CANTRELEASE, FAIL, "unable to free location") - - /* Free the normalized path name */ - if (norm_cur_name) - H5MM_xfree(norm_cur_name); - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5L__create_hard() */ - -/*------------------------------------------------------------------------- - * Function: H5L__create_soft - * - * Purpose: Creates a soft link from LINK_NAME to TARGET_PATH. - * - * Return: SUCCEED/FAIL - * - * Programmer: Robb Matzke - * Monday, April 6, 1998 - * - *------------------------------------------------------------------------- - */ -herr_t -H5L__create_soft(const char *target_path, const H5G_loc_t *link_loc, const char *link_name, hid_t lcpl_id) -{ - char * norm_target = NULL; /* Pointer to normalized current name */ - H5O_link_t lnk; /* Link to insert */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* Check args */ - HDassert(link_loc); - HDassert(target_path && *target_path); - HDassert(link_name && *link_name); - - /* Get normalized copy of the link target */ - if ((norm_target = H5G_normalize(target_path)) == NULL) - HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, "can't normalize name") - - /* Set up link data specific to soft links */ - lnk.type = H5L_TYPE_SOFT; - lnk.u.soft.name = norm_target; - - /* Create actual link to the object */ - if (H5L__create_real(link_loc, link_name, NULL, NULL, &lnk, NULL, lcpl_id) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create new link to object") - -done: - /* Free the normalized target name */ - if (norm_target) - H5MM_xfree(norm_target); - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5L__create_soft() */ - -/*------------------------------------------------------------------------- - * Function: H5L__create_ud - * - * Purpose: Creates a user-defined link. See H5Lcreate_ud for - * full documentation. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: James Laird - * Friday, May 19, 2006 - * - *------------------------------------------------------------------------- - */ -herr_t -H5L__create_ud(const H5G_loc_t *link_loc, const char *link_name, const void *ud_data, size_t ud_data_size, - H5L_type_t type, hid_t lcpl_id) -{ - H5O_link_t lnk; /* Link to insert */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* Check args */ - HDassert(type >= H5L_TYPE_UD_MIN && type <= H5L_TYPE_MAX); - HDassert(link_loc); - HDassert(link_name && *link_name); - HDassert(ud_data_size == 0 || ud_data); - - /* Initialize the link struct's pointer to its udata buffer */ - lnk.u.ud.udata = NULL; - - /* Make sure that this link class is registered */ - if (H5L__find_class_idx(type) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "link class has not been registered with library") - - /* Fill in UD link-specific information in the link struct*/ - if (ud_data_size > 0) { - lnk.u.ud.udata = H5MM_malloc((size_t)ud_data_size); - H5MM_memcpy(lnk.u.ud.udata, ud_data, (size_t)ud_data_size); - } /* end if */ - else - lnk.u.ud.udata = NULL; - - lnk.u.ud.size = ud_data_size; - lnk.type = type; - - /* Create actual link to the object */ - if (H5L__create_real(link_loc, link_name, NULL, NULL, &lnk, NULL, lcpl_id) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to register new name for object") - -done: - /* Free the link's udata buffer if it's been allocated */ - H5MM_xfree(lnk.u.ud.udata); - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5L__create_ud() */ - -/*------------------------------------------------------------------------- - * Function: H5L__get_val_real - * - * Purpose: Retrieve link value from a link object - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * Monday, November 13 2006 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5L__get_val_real(const H5O_link_t *lnk, void *buf, size_t size) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - /* Sanity check */ - HDassert(lnk); - - /* Check for soft link */ - if (H5L_TYPE_SOFT == lnk->type) { - /* Copy to output buffer */ - if (size > 0 && buf) { - HDstrncpy((char *)buf, lnk->u.soft.name, size); - if (HDstrlen(lnk->u.soft.name) >= size) - ((char *)buf)[size - 1] = '\0'; - } /* end if */ - } /* end if */ - /* Check for user-defined link */ - else if (lnk->type >= H5L_TYPE_UD_MIN) { - const H5L_class_t *link_class; /* User-defined link class */ - - /* Get the link class for this type of link. It's okay if the class - * isn't registered, though--we just can't give any more information - * about it - */ - link_class = H5L_find_class(lnk->type); - - if (link_class != NULL && link_class->query_func != NULL) { - if ((link_class->query_func)(lnk->name, lnk->u.ud.udata, lnk->u.ud.size, buf, size) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CALLBACK, FAIL, "query callback returned failure") - } /* end if */ - else if (buf && size > 0) - ((char *)buf)[0] = '\0'; - } /* end if */ - else - HGOTO_ERROR(H5E_LINK, H5E_BADTYPE, FAIL, "object is not a symbolic or user-defined link") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5L__get_val_real() */ - -/*------------------------------------------------------------------------- - * Function: H5L__get_val_cb - * - * Purpose: Callback for retrieving link value or udata. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * Tuesday, September 20, 2005 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5L__get_val_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, - H5G_loc_t H5_ATTR_UNUSED *obj_loc, void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/) -{ - H5L_trav_gv_t *udata = (H5L_trav_gv_t *)_udata; /* User data passed in */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - /* Check if the name in this group resolved to a valid link */ - if (lnk == NULL) - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "'%s' doesn't exist", name) - - /* Retrieve the value for the link */ - if (H5L__get_val_real(lnk, udata->buf, udata->size) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't retrieve link value") - -done: - /* Indicate that this callback didn't take ownership of the group * - * location for the object */ - *own_loc = H5G_OWN_NONE; - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5L__get_val_cb() */ - -/*------------------------------------------------------------------------- - * Function: H5L__get_val - * - * Purpose: Returns the value of a symbolic link or the udata for a - * user-defined link. - * - * Return: Success: Non-negative, with at most SIZE bytes of the - * link value copied into the BUF buffer. If the - * link value is larger than SIZE characters - * counting the null terminator then the BUF - * result will not be null terminated. - * - * Failure: Negative - * - * Programmer: Robb Matzke - * Monday, April 13, 1998 - * - *------------------------------------------------------------------------- - */ -herr_t -H5L__get_val(const H5G_loc_t *loc, const char *name, void *buf /*out*/, size_t size) -{ - H5L_trav_gv_t udata; /* User data for callback */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* Sanity check */ - HDassert(loc); - HDassert(name && *name); - - /* Set up user data for retrieving information */ - udata.size = size; - udata.buf = buf; - - /* Traverse the group hierarchy to locate the object to get info about */ - if (H5G_traverse(loc, name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L__get_val_cb, &udata) < 0) - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "name doesn't exist") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5L__get_val() */ - -/*------------------------------------------------------------------------- - * Function: H5L__get_val_by_idx_cb - * - * Purpose: Callback for retrieving a link's value according to an - * index's order. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * Monday, November 13 2006 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5L__get_val_by_idx_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ATTR_UNUSED *name, - const H5O_link_t H5_ATTR_UNUSED *lnk, H5G_loc_t *obj_loc, void *_udata /*in,out*/, - H5G_own_loc_t *own_loc /*out*/) -{ - H5L_trav_gvbi_t *udata = (H5L_trav_gvbi_t *)_udata; /* User data passed in */ - H5O_link_t fnd_lnk; /* Link within group */ - hbool_t lnk_copied = FALSE; /* Whether the link was copied */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - /* Check if the name of the group resolved to a valid object */ - if (obj_loc == NULL) - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "group doesn't exist") - - /* Query link */ - if (H5G_obj_lookup_by_idx(obj_loc->oloc, udata->idx_type, udata->order, udata->n, &fnd_lnk) < 0) - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "link not found") - lnk_copied = TRUE; - - /* Retrieve the value for the link */ - if (H5L__get_val_real(&fnd_lnk, udata->buf, udata->size) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't retrieve link value") - -done: - /* Reset the link information, if we have a copy */ - if (lnk_copied) - H5O_msg_reset(H5O_LINK_ID, &fnd_lnk); - - /* Indicate that this callback didn't take ownership of the group * - * location for the object */ - *own_loc = H5G_OWN_NONE; - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5L__get_val_by_idx_cb() */ - -/*------------------------------------------------------------------------- - * Function: H5L__get_val_by_idx - * - * Purpose: Internal routine to query a link value according to the - * index within a group - * - * Return: SUCCEED/FAIL - * - * Programmer: Quincey Koziol - * December 27, 2017 - * - *------------------------------------------------------------------------- - */ -herr_t -H5L__get_val_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, H5_iter_order_t order, - hsize_t n, void *buf /*out*/, size_t size) -{ - H5L_trav_gvbi_t udata; /* User data for callback */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* Check arguments */ - HDassert(loc); - HDassert(name && *name); - - /* Set up user data for retrieving information */ - udata.idx_type = idx_type; - udata.order = order; - udata.n = n; - udata.buf = buf; - udata.size = size; - - /* Traverse the group hierarchy to locate the object to get info about */ - if (H5G_traverse(loc, name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L__get_val_by_idx_cb, &udata) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't get link info for index: %llu", (unsigned long long)n) - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5L__get_val_by_idx() */ - -/*------------------------------------------------------------------------- - * Function: H5L__delete_cb - * - * Purpose: Callback for deleting a link. This routine - * actually deletes the link - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * Monday, September 19, 2005 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5L__delete_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, - H5G_loc_t H5_ATTR_UNUSED *obj_loc, void H5_ATTR_UNUSED *_udata /*in,out*/, - H5G_own_loc_t *own_loc /*out*/) -{ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_STATIC - - /* Check if the group resolved to a valid link */ - if (grp_loc == NULL) - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "group doesn't exist") - - /* Check if the name in this group resolved to a valid link */ - if (name == NULL) - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "name doesn't exist") - - /* Check for non-existent (NULL) link. - * Note that this can also occur when attempting to remove '.' - */ - if (lnk == NULL) - HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, - "callback link pointer is NULL (specified link may be '.' or not exist)") - - /* Remove the link from the group */ - if (H5G_obj_remove(grp_loc->oloc, grp_loc->path->full_path_r, name) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to remove link from group") - -done: - /* Indicate that this callback didn't take ownership of the group * - * location for the object */ - *own_loc = H5G_OWN_NONE; - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5L__delete_cb() */ - -/*------------------------------------------------------------------------- - * Function: H5L__delete - * - * Purpose: Delete a link from a group. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Robb Matzke - * Thursday, September 17, 1998 - * - *------------------------------------------------------------------------- - */ -herr_t -H5L__delete(const H5G_loc_t *loc, const char *name) -{ - char * norm_name = NULL; /* Pointer to normalized name */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* Sanity check */ - HDassert(loc); - HDassert(name && *name); - - /* Get normalized copy of the name */ - if ((norm_name = H5G_normalize(name)) == NULL) - HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, "can't normalize name") - - /* Set up user data for unlink operation */ - if (H5G_traverse(loc, norm_name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK | H5G_TARGET_MOUNT, H5L__delete_cb, - NULL) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTREMOVE, FAIL, "can't unlink object") - -done: - /* Free the normalized path name */ - if (norm_name) - H5MM_xfree(norm_name); - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5L__delete() */ - -/*------------------------------------------------------------------------- - * Function: H5L__delete_by_idx_cb - * - * Purpose: Callback for removing a link according to an index's order. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * Monday, November 13 2006 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5L__delete_by_idx_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ATTR_UNUSED *name, - const H5O_link_t H5_ATTR_UNUSED *lnk, H5G_loc_t *obj_loc, void *_udata /*in,out*/, - H5G_own_loc_t *own_loc /*out*/) -{ - H5L_trav_gvbi_t *udata = (H5L_trav_gvbi_t *)_udata; /* User data passed in */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC_TAG((obj_loc) ? (obj_loc->oloc->addr) : HADDR_UNDEF) - - /* Check if the name of the group resolved to a valid object */ - if (obj_loc == NULL) - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "group doesn't exist") - - /* Delete link */ - if (H5G_obj_remove_by_idx(obj_loc->oloc, obj_loc->path->full_path_r, udata->idx_type, udata->order, - udata->n) < 0) - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "link not found") - -done: - /* Indicate that this callback didn't take ownership of the group * - * location for the object */ - *own_loc = H5G_OWN_NONE; - - FUNC_LEAVE_NOAPI_TAG(ret_value) -} /* end H5L__delete_by_idx_cb() */ - -/*------------------------------------------------------------------------- - * Function: H5L__delete_by_idx - * - * Purpose: Internal routine to delete a link according to its index - * within a group. - * - * Return: SUCCEED/FAIL - * - * Programmer: Quincey Koziol - * December 27, 2017 - * - *------------------------------------------------------------------------- - */ -herr_t -H5L__delete_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, H5_iter_order_t order, - hsize_t n) -{ - H5L_trav_rmbi_t udata; /* User data for callback */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* Sanity check */ - HDassert(loc); - HDassert(name && *name); - - /* Set up user data for unlink operation */ - udata.idx_type = idx_type; - udata.order = order; - udata.n = n; - - /* Traverse the group hierarchy to remove the link */ - if (H5G_traverse(loc, name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK | H5G_TARGET_MOUNT, - H5L__delete_by_idx_cb, &udata) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "link doesn't exist") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5L__delete_by_idx() */ - -/*------------------------------------------------------------------------- - * Function: H5L__move_dest_cb - * - * Purpose: Second callback for moving and renaming an object. This routine - * inserts a new link into the group returned by the traversal. - * It is called by H5L__move_cb. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: James Laird - * Monday, April 3, 2006 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5L__move_dest_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t H5_ATTR_UNUSED *lnk, - H5G_loc_t *obj_loc, void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/) -{ - H5L_trav_mv2_t *udata = (H5L_trav_mv2_t *)_udata; /* User data passed in */ - H5G_t * grp = NULL; /* H5G_t for this group, opened to pass to user callback */ - hid_t grp_id = FAIL; /* ID for this group (passed to user callback */ - H5G_loc_t temp_loc; /* For UD callback */ - hbool_t temp_loc_init = FALSE; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - /* Make sure an object with this name doesn't already exist */ - if (obj_loc != NULL) - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "an object with that name already exists") - - /* Check for crossing file boundaries with a new hard link */ - if (udata->lnk->type == H5L_TYPE_HARD) - /* Check that both objects are in same file */ - if (!H5F_SAME_SHARED(grp_loc->oloc->file, udata->file)) - HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "moving a link across files is not allowed") - - /* Give the object its new name */ - /* Casting away const okay -JML */ - HDassert(udata->lnk->name == NULL); - udata->lnk->name = (char *)name; - - /* Insert the link into the group */ - if (H5G_obj_insert(grp_loc->oloc, name, udata->lnk, TRUE, H5O_TYPE_UNKNOWN, NULL) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create new link to object") - - /* If the link was a user-defined link, call its move callback if it has one */ - if (udata->lnk->type >= H5L_TYPE_UD_MIN) { - const H5L_class_t *link_class; /* User-defined link class */ - - /* Get the link class for this type of link. */ - if (NULL == (link_class = H5L_find_class(udata->lnk->type))) - HGOTO_ERROR(H5E_LINK, H5E_NOTREGISTERED, FAIL, "link class is not registered") - - if ((!udata->copy && link_class->move_func) || (udata->copy && link_class->copy_func)) { - H5O_loc_t temp_oloc; - H5G_name_t temp_path; - - /* Create a temporary location (or else H5G_open will do a shallow - * copy and wipe out grp_loc) - */ - H5G_name_reset(&temp_path); - if (H5O_loc_copy_deep(&temp_oloc, grp_loc->oloc) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTCOPY, FAIL, "unable to copy object location") - - temp_loc.oloc = &temp_oloc; - temp_loc.path = &temp_path; - temp_loc_init = TRUE; - - /* Set up location for user-defined callback */ - if (NULL == (grp = H5G_open(&temp_loc))) - HGOTO_ERROR(H5E_LINK, H5E_CANTOPENOBJ, FAIL, "unable to open group") - if ((grp_id = H5VL_wrap_register(H5I_GROUP, grp, TRUE)) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTREGISTER, FAIL, "unable to register group ID") - - if (udata->copy) { - if ((link_class->copy_func)(udata->lnk->name, grp_id, udata->lnk->u.ud.udata, - udata->lnk->u.ud.size) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CALLBACK, FAIL, "UD copy callback returned error") - } /* end if */ - else { - if ((link_class->move_func)(udata->lnk->name, grp_id, udata->lnk->u.ud.udata, - udata->lnk->u.ud.size) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CALLBACK, FAIL, "UD move callback returned error") - } /* end else */ - } /* end if */ - } /* end if */ - -done: - /* Close the location given to the user callback if it was created */ - if (grp_id >= 0) { - if (H5I_dec_app_ref(grp_id) < 0) - HDONE_ERROR(H5E_LINK, H5E_CANTRELEASE, FAIL, "unable to close ID from UD callback") - } /* end if */ - else if (grp != NULL) { - if (H5G_close(grp) < 0) - HDONE_ERROR(H5E_LINK, H5E_CANTRELEASE, FAIL, "unable to close group given to UD callback") - } /* end if */ - else if (temp_loc_init) - H5G_loc_free(&temp_loc); - - /* Indicate that this callback didn't take ownership of the group * - * location for the object */ - *own_loc = H5G_OWN_NONE; - - /* Reset the "name" field in udata->lnk because it is owned by traverse() - * and must not be manipulated after traverse closes */ - udata->lnk->name = NULL; - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5L__move_dest_cb() */ - -/*------------------------------------------------------------------------- - * Function: H5L__move_cb - * - * Purpose: Callback for moving and renaming an object. This routine - * replaces the names of open objects with the moved object - * in the path - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: James Laird - * Friday, April 3, 2006 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5L__move_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, H5G_loc_t *obj_loc, - void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/) -{ - H5L_trav_mv_t *udata = (H5L_trav_mv_t *)_udata; /* User data passed in */ - H5L_trav_mv2_t udata_out; /* User data for H5L__move_dest_cb traversal */ - char * orig_name = NULL; /* The name of the link in this group */ - hbool_t link_copied = FALSE; /* Has udata_out.lnk been allocated? */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - /* Check if the name in this group resolved to a valid link */ - if (obj_loc == NULL) - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "name doesn't exist") - - /* Check for operations on '.' */ - if (lnk == NULL) - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "the name of a link must be supplied to move or copy") - - /* Set up user data for move_dest_cb */ - if (NULL == (udata_out.lnk = (H5O_link_t *)H5O_msg_copy(H5O_LINK_ID, lnk, NULL))) - HGOTO_ERROR(H5E_LINK, H5E_CANTCOPY, FAIL, "unable to copy link to be moved") - - /* In this special case, the link's name is going to be replaced at its - * destination, so we should free it here. - */ - udata_out.lnk->name = (char *)H5MM_xfree(udata_out.lnk->name); - link_copied = TRUE; - - udata_out.lnk->cset = udata->cset; - udata_out.file = grp_loc->oloc->file; - udata_out.copy = udata->copy; - - /* Keep a copy of link's name (it's "owned" by the H5G_traverse() routine) */ - orig_name = H5MM_xstrdup(name); - - /* Reset the # of soft / UD links that can be traversed, so that the second - * (destination) traversal has the correct value - */ - if (H5CX_set_nlinks(udata->orig_nlinks) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't reset # of soft / UD links to traverse") - - /* Insert the link into its new location */ - if (H5G_traverse(udata->dst_loc, udata->dst_name, udata->dst_target_flags, H5L__move_dest_cb, - &udata_out) < 0) - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to follow symbolic link") - - /* If this is a move and not a copy operation, change the object's name and remove the old link */ - if (!udata->copy) { - H5RS_str_t *dst_name_r; /* Ref-counted version of dest name */ - - /* Make certain that the destination name is a full (not relative) path */ - if (*(udata->dst_name) != '/') { - HDassert(udata->dst_loc->path->full_path_r); - - /* Create reference counted string for full dst path */ - if ((dst_name_r = H5G_build_fullpath_refstr_str(udata->dst_loc->path->full_path_r, - udata->dst_name)) == NULL) - HGOTO_ERROR(H5E_LINK, H5E_PATH, FAIL, "can't build destination path name") - } /* end if */ - else - dst_name_r = H5RS_wrap(udata->dst_name); - HDassert(dst_name_r); - - /* Fix names up */ - if (H5G_name_replace(lnk, H5G_NAME_MOVE, obj_loc->oloc->file, obj_loc->path->full_path_r, - udata->dst_loc->oloc->file, dst_name_r) < 0) { - H5RS_decr(dst_name_r); - HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to replace name") - } /* end if */ - - /* Remove the old link */ - if (H5G_obj_remove(grp_loc->oloc, grp_loc->path->full_path_r, orig_name) < 0) { - H5RS_decr(dst_name_r); - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to remove old name") - } /* end if */ - - H5RS_decr(dst_name_r); - } /* end if */ - -done: - /* Cleanup */ - if (orig_name) - H5MM_xfree(orig_name); - - /* If udata_out.lnk was copied, free any memory allocated - * In this special case, the H5L__move_dest_cb callback resets the name - * so H5O_msg_free shouldn't try to free it - */ - if (link_copied) - H5O_msg_free(H5O_LINK_ID, udata_out.lnk); - - /* Indicate that this callback didn't take ownership of the group * - * location for the object */ - *own_loc = H5G_OWN_NONE; - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5L__move_cb() */ - -/*------------------------------------------------------------------------- - * Function: H5L__move - * - * Purpose: Atomically move or copy a link. - * - * Creates a copy of a link in a new destination with a new name. - * SRC_LOC and SRC_NAME together define the link's original - * location, while DST_LOC and DST_NAME together define its - * final location. - * - * If copy_flag is FALSE, the original link is removed - * (effectively moving the link). - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: James Laird - * Monday, May 1, 2006 - * - *------------------------------------------------------------------------- - */ -herr_t -H5L__move(const H5G_loc_t *src_loc, const char *src_name, const H5G_loc_t *dst_loc, const char *dst_name, - hbool_t copy_flag, hid_t lcpl_id) -{ - unsigned dst_target_flags = H5G_TARGET_NORMAL; - H5T_cset_t char_encoding = H5F_DEFAULT_CSET; /* Character encoding for link */ - H5P_genplist_t *lc_plist; /* Link creation property list */ - H5L_trav_mv_t udata; /* User data for traversal */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* Sanity check */ - HDassert(src_loc); - HDassert(dst_loc); - HDassert(src_name && *src_name); - HDassert(dst_name && *dst_name); - - /* Check for flags present in creation property list */ - if (lcpl_id != H5P_DEFAULT) { - unsigned crt_intmd_group; - - if (NULL == (lc_plist = (H5P_genplist_t *)H5I_object(lcpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") - - /* Get intermediate group creation property */ - if (H5CX_get_intermediate_group(&crt_intmd_group) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for creating missing groups") - - /* Set target flags for source and destination */ - if (crt_intmd_group > 0) - dst_target_flags |= H5G_CRT_INTMD_GROUP; - - /* Get character encoding property */ - if (H5CX_get_encoding(&char_encoding) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for character encoding") - } /* end if */ - - /* Set up user data */ - udata.dst_loc = dst_loc; - udata.dst_name = dst_name; - udata.dst_target_flags = dst_target_flags; - udata.cset = char_encoding; - udata.copy = copy_flag; - - /* Retrieve the original # of soft / UD links that can be traversed, so - * that the countdown can be reset after the first path is traversed. - */ - if (H5CX_get_nlinks(&udata.orig_nlinks) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to retrieve # of soft / UD links to traverse") - - /* Do the move */ - if (H5G_traverse(src_loc, src_name, H5G_TARGET_MOUNT | H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L__move_cb, - &udata) < 0) - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to find link") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5L__move() */ - -/*------------------------------------------------------------------------- - * Function: H5L__exists_final_cb - * - * Purpose: Callback for checking whether a link exists, as the final - * component of a path - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * Friday, March 16 2007 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5L__exists_final_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ATTR_UNUSED *name, - const H5O_link_t *lnk, H5G_loc_t H5_ATTR_UNUSED *obj_loc, void *_udata /*in,out*/, - H5G_own_loc_t *own_loc /*out*/) -{ - H5L_trav_le_t *udata = (H5L_trav_le_t *)_udata; /* User data passed in */ - - FUNC_ENTER_STATIC_NOERR - - /* Check if the name in this group resolved to a valid link */ - *udata->exists = (hbool_t)(lnk != NULL); - - /* Indicate that this callback didn't take ownership of the group * - * location for the object */ - *own_loc = H5G_OWN_NONE; - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5L__exists_final_cb() */ - -/*------------------------------------------------------------------------- - * Function: H5L__exists_inter_cb - * - * Purpose: Callback for checking whether a link exists, as an intermediate - * component of a path - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * Thursday, December 31 2015 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5L__exists_inter_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ATTR_UNUSED *name, - const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata /*in,out*/, - H5G_own_loc_t *own_loc /*out*/) -{ - H5L_trav_le_t *udata = (H5L_trav_le_t *)_udata; /* User data passed in */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - /* Check if the name in this group resolved to a valid link */ - if (lnk != NULL) { - /* Check for more components to the path */ - if (udata->sep) { - H5G_traverse_t cb_func; /* Callback function for tranversal */ - char * next; /* Pointer to next component name */ - - /* Look for another separator */ - next = udata->sep; - if (NULL == (udata->sep = HDstrchr(udata->sep, '/'))) - cb_func = H5L__exists_final_cb; - else { - /* Chew through adjacent separators, if present */ - do { - *udata->sep = '\0'; - udata->sep++; - } while ('/' == *udata->sep); - cb_func = H5L__exists_inter_cb; - } /* end else */ - if (H5G_traverse(obj_loc, next, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, cb_func, udata) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't determine if link exists") - } /* end if */ - else - *udata->exists = TRUE; - } /* end if */ - else - *udata->exists = FALSE; - - /* Indicate that this callback didn't take ownership of the group * - * location for the object */ - *own_loc = H5G_OWN_NONE; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5L__exists_inter_cb() */ - -/*------------------------------------------------------------------------- - * Function: H5L_exists_tolerant - * - * Purpose: Returns whether a link exists in a group - * - * Note: Same as H5L__exists, except that missing links are reported - * as 'FALSE' instead of causing failures - * - * Return: Non-negative (TRUE/FALSE) on success/Negative on failure - * - * Programmer: Quincey Koziol - * Thursday, December 31 2015 - * - *------------------------------------------------------------------------- - */ -herr_t -H5L_exists_tolerant(const H5G_loc_t *loc, const char *name, hbool_t *exists) -{ - H5L_trav_le_t udata; /* User data for traversal */ - H5G_traverse_t cb_func; /* Callback function for tranversal */ - char * name_copy = NULL; /* Duplicate of name */ - char * name_trav; /* Name to traverse */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - HDassert(loc); - HDassert(name); - HDassert(exists); - - /* Copy the name and skip leading '/'s */ - name_trav = name_copy = H5MM_strdup(name); - while ('/' == *name_trav) - name_trav++; - - /* A path of "/" will always exist in a file */ - if ('\0' == *name_trav) - *exists = TRUE; - else { - /* Set up user data & correct callback */ - udata.exists = exists; - if (NULL == (udata.sep = HDstrchr(name_trav, '/'))) - cb_func = H5L__exists_final_cb; - else { - /* Chew through adjacent separators, if present */ - do { - *udata.sep = '\0'; - udata.sep++; - } while ('/' == *udata.sep); - cb_func = H5L__exists_inter_cb; - } /* end else */ - - /* Traverse the group hierarchy to locate the link to check */ - if (H5G_traverse(loc, name_trav, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, cb_func, &udata) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't determine if link exists") - } - -done: - /* Release duplicated string */ - H5MM_xfree(name_copy); - - FUNC_LEAVE_NOAPI(ret_value) -} /* H5L_exists_tolerant() */ - -/*------------------------------------------------------------------------- - * Function: H5L__exists - * - * Purpose: Returns whether a link exists in a group - * - * Note: Same as H5L_exists_tolerant, except that missing links are reported - * as failures - * - * Return: Non-negative on success, with *exists set/Negative on failure - * - * Programmer: Quincey Koziol - * Friday, March 16 2007 - * - *------------------------------------------------------------------------- - */ -herr_t -H5L__exists(const H5G_loc_t *loc, const char *name, hbool_t *exists) -{ - H5L_trav_le_t udata; /* User data for traversal */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* Sanity checks */ - HDassert(loc); - HDassert(name); - HDassert(exists); - - /* A path of "/" will always exist in a file */ - if (0 == HDstrcmp(name, "/")) - *exists = TRUE; - else { - /* Traverse the group hierarchy to locate the object to get info about */ - udata.exists = exists; - if (H5G_traverse(loc, name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L__exists_final_cb, &udata) < 0) - HGOTO_ERROR(H5E_LINK, H5E_EXISTS, FAIL, "link doesn't exist") - } - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5L__exists() */ - -/*------------------------------------------------------------------------- - * Function: H5L__get_info_cb - * - * Purpose: Callback for retrieving a link's metadata - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: James Laird - * Monday, April 17 2006 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5L__get_info_cb(H5G_loc_t *grp_loc /*in*/, const char H5_ATTR_UNUSED *name, const H5O_link_t *lnk, - H5G_loc_t H5_ATTR_UNUSED *obj_loc, void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/) -{ - H5L_trav_gi_t *udata = (H5L_trav_gi_t *)_udata; /* User data passed in */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - /* Check if the name in this group resolved to a valid link */ - if (lnk == NULL) - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "name doesn't exist") - - /* Get information from the link */ - if (H5G_link_to_info(grp_loc->oloc, lnk, udata->linfo) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't get link info") - -done: - /* Indicate that this callback didn't take ownership of the group * - * location for the object */ - *own_loc = H5G_OWN_NONE; - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5L__get_info_cb() */ - -/*------------------------------------------------------------------------- - * Function: H5L_get_info - * - * Purpose: Returns metadata about a link. - * - * Return: SUCCEED/FAIL - * - * Programmer: James Laird - * Monday, April 17 2006 - * - *------------------------------------------------------------------------- - */ -herr_t -H5L_get_info(const H5G_loc_t *loc, const char *name, H5L_info2_t *linfo /*out*/) -{ - H5L_trav_gi_t udata; /* User data for callback */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - udata.linfo = linfo; - - /* Traverse the group hierarchy to locate the object to get info about */ - if (H5G_traverse(loc, name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L__get_info_cb, &udata) < 0) - HGOTO_ERROR(H5E_LINK, H5E_EXISTS, FAIL, "name doesn't exist") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5L_get_info() */ - -/*------------------------------------------------------------------------- - * Function: H5L__get_info_by_idx_cb - * - * Purpose: Callback for retrieving a link's metadata according to an - * index's order. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * Monday, November 6 2006 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5L__get_info_by_idx_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ATTR_UNUSED *name, - const H5O_link_t H5_ATTR_UNUSED *lnk, H5G_loc_t *obj_loc, void *_udata /*in,out*/, - H5G_own_loc_t *own_loc /*out*/) -{ - H5L_trav_gibi_t *udata = (H5L_trav_gibi_t *)_udata; /* User data passed in */ - H5O_link_t fnd_lnk; /* Link within group */ - hbool_t lnk_copied = FALSE; /* Whether the link was copied */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - /* Check if the name of the group resolved to a valid object */ - if (obj_loc == NULL) - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "group doesn't exist") - - /* Query link */ - if (H5G_obj_lookup_by_idx(obj_loc->oloc, udata->idx_type, udata->order, udata->n, &fnd_lnk) < 0) - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "link not found") - lnk_copied = TRUE; - - /* Get information from the link */ - if (H5G_link_to_info(obj_loc->oloc, &fnd_lnk, udata->linfo) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't get link info") - -done: - /* Reset the link information, if we have a copy */ - if (lnk_copied) - H5O_msg_reset(H5O_LINK_ID, &fnd_lnk); - - /* Indicate that this callback didn't take ownership of the group * - * location for the object */ - *own_loc = H5G_OWN_NONE; - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5L__get_info_by_idx_cb() */ - -/*------------------------------------------------------------------------- - * Function: H5L__get_info_by_idx - * - * Purpose: Internal routine to retrieve link info according to an - * index's order. - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -herr_t -H5L__get_info_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, H5_iter_order_t order, - hsize_t n, H5L_info2_t *linfo /*out*/) -{ - H5L_trav_gibi_t udata; /* User data for callback */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* Check arguments */ - HDassert(loc); - HDassert(name && *name); - HDassert(linfo); - - /* Set up user data for callback */ - udata.idx_type = idx_type; - udata.order = order; - udata.n = n; - udata.linfo = linfo; - - /* Traverse the group hierarchy to locate the object to get info about */ - if (H5G_traverse(loc, name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L__get_info_by_idx_cb, &udata) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to get link info") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5L__get_info_by_idx() */ - -/*------------------------------------------------------------------------- - * Function: H5L__get_name_by_idx_cb - * - * Purpose: Callback for retrieving a link's name according to an - * index's order. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * Saturday, November 11 2006 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5L__get_name_by_idx_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ATTR_UNUSED *name, - const H5O_link_t H5_ATTR_UNUSED *lnk, H5G_loc_t *obj_loc, void *_udata /*in,out*/, - H5G_own_loc_t *own_loc /*out*/) -{ - H5L_trav_gnbi_t *udata = (H5L_trav_gnbi_t *)_udata; /* User data passed in */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - /* Check if the name of the group resolved to a valid object */ - if (obj_loc == NULL) - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "group doesn't exist") - - /* Query link */ - if ((udata->name_len = H5G_obj_get_name_by_idx(obj_loc->oloc, udata->idx_type, udata->order, udata->n, - udata->name, udata->size)) < 0) - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "link not found") - -done: - /* Indicate that this callback didn't take ownership of the group * - * location for the object */ - *own_loc = H5G_OWN_NONE; - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5L__get_name_by_idx_cb() */ - -/*------------------------------------------------------------------------- - * Function: H5L__get_name_by_idx - * - * Purpose: Internal routine to retrieve link name according to an - * index's order. - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -ssize_t -H5L__get_name_by_idx(const H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, - hsize_t n, char *name /*out*/, size_t size) -{ - H5L_trav_gnbi_t udata; /* User data for callback */ - ssize_t ret_value = FAIL; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* Check arguments */ - HDassert(loc); - HDassert(group_name && *group_name); - - /* Set up user data for callback */ - udata.idx_type = idx_type; - udata.order = order; - udata.n = n; - udata.name = name; - udata.size = size; - udata.name_len = -1; - - /* Traverse the group hierarchy to locate the link to get name of */ - if (H5G_traverse(loc, group_name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L__get_name_by_idx_cb, &udata) < - 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't get name") - - /* Set the return value */ - ret_value = udata.name_len; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5L__get_name_by_idx() */ - -/*------------------------------------------------------------------------- - * Function: H5L__link_copy_file - * - * Purpose: Copy a link and the object it points to from one file to - * another. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * Sep 29 2006 - * - *------------------------------------------------------------------------- - */ -herr_t -H5L__link_copy_file(H5F_t *dst_file, const H5O_link_t *_src_lnk, const H5O_loc_t *src_oloc, - H5O_link_t *dst_lnk, H5O_copy_t *cpy_info) -{ - H5O_link_t tmp_src_lnk; /* Temporary copy of src link, when needed */ - const H5O_link_t *src_lnk = _src_lnk; /* Source link */ - hbool_t dst_lnk_init = FALSE; /* Whether the destination link is initialized */ - hbool_t expanded_link_open = FALSE; /* Whether the target location has been opened */ - H5G_loc_t tmp_src_loc; /* Group location holding target object */ - H5G_name_t tmp_src_path; /* Path for target object */ - H5O_loc_t tmp_src_oloc; /* Object location for target object */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* check arguments */ - HDassert(dst_file); - HDassert(src_lnk); - HDassert(dst_lnk); - HDassert(cpy_info); - - /* Expand soft or external link, if requested */ - if ((H5L_TYPE_SOFT == src_lnk->type && cpy_info->expand_soft_link) || - (H5L_TYPE_EXTERNAL == src_lnk->type && cpy_info->expand_ext_link)) { - H5G_loc_t lnk_grp_loc; /* Group location holding link */ - H5G_name_t lnk_grp_path; /* Path for link */ - htri_t tar_exists; /* Whether the target object exists */ - - /* Set up group location for link */ - H5G_name_reset(&lnk_grp_path); - lnk_grp_loc.path = &lnk_grp_path; - lnk_grp_loc.oloc = (H5O_loc_t *)src_oloc; /* Casting away const OK -QAK */ - - /* Check if the target object exists */ - if ((tar_exists = H5G_loc_exists(&lnk_grp_loc, src_lnk->name)) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTCOPY, FAIL, "unable to check if target object exists") - - if (tar_exists) { - /* Make a temporary copy of the link, so that it will not change the - * info in the cache when we change it to a hard link */ - if (NULL == H5O_msg_copy(H5O_LINK_ID, src_lnk, &tmp_src_lnk)) - HGOTO_ERROR(H5E_LINK, H5E_CANTCOPY, FAIL, "unable to copy message") - - /* Set up group location for target object. Let H5G_traverse expand - * the link. */ - tmp_src_loc.path = &tmp_src_path; - tmp_src_loc.oloc = &tmp_src_oloc; - if (H5G_loc_reset(&tmp_src_loc) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTCOPY, FAIL, "unable to reset location") - - /* Find the target object */ - if (H5G_loc_find(&lnk_grp_loc, src_lnk->name, &tmp_src_loc) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTCOPY, FAIL, "unable to find target object") - expanded_link_open = TRUE; - - /* Convert symbolic link to hard link */ - if (tmp_src_lnk.type == H5L_TYPE_SOFT) - tmp_src_lnk.u.soft.name = (char *)H5MM_xfree(tmp_src_lnk.u.soft.name); - else if (tmp_src_lnk.u.ud.size > 0) - tmp_src_lnk.u.ud.udata = H5MM_xfree(tmp_src_lnk.u.ud.udata); - tmp_src_lnk.type = H5L_TYPE_HARD; - tmp_src_lnk.u.hard.addr = tmp_src_oloc.addr; - src_lnk = &tmp_src_lnk; - } /* end if */ - } /* end if */ - - /* Copy src link information to dst link information */ - if (NULL == H5O_msg_copy(H5O_LINK_ID, src_lnk, dst_lnk)) - HGOTO_ERROR(H5E_LINK, H5E_CANTCOPY, FAIL, "unable to copy message") - dst_lnk_init = TRUE; - - /* Check if object in source group is a hard link & copy it */ - if (H5L_TYPE_HARD == src_lnk->type) { - H5O_loc_t new_dst_oloc; /* Copied object location in destination */ - - /* Set up copied object location to fill in */ - H5O_loc_reset(&new_dst_oloc); - new_dst_oloc.file = dst_file; - - if (!expanded_link_open) { - /* Build temporary object location for source */ - H5O_loc_reset(&tmp_src_oloc); - tmp_src_oloc.file = src_oloc->file; - tmp_src_oloc.addr = src_lnk->u.hard.addr; - } /* end if */ - HDassert(H5F_addr_defined(tmp_src_oloc.addr)); - - /* Copy the shared object from source to destination */ - /* Don't care about obj_type or udata because those are only important - * for old style groups */ - if (H5O_copy_header_map(&tmp_src_oloc, &new_dst_oloc, cpy_info, TRUE, NULL, NULL) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTCOPY, FAIL, "unable to copy object") - - /* Copy new destination object's information for eventual insertion */ - dst_lnk->u.hard.addr = new_dst_oloc.addr; - } /* end if */ - -done: - /* Check if we used a temporary src link */ - if (src_lnk != _src_lnk) { - HDassert(src_lnk == &tmp_src_lnk); - H5O_msg_reset(H5O_LINK_ID, &tmp_src_lnk); - } /* end if */ - if (ret_value < 0) - if (dst_lnk_init) - H5O_msg_reset(H5O_LINK_ID, dst_lnk); - /* Check if we need to free the temp source oloc */ - if (expanded_link_open) - if (H5G_loc_free(&tmp_src_loc) < 0) - HDONE_ERROR(H5E_LINK, H5E_CANTFREE, FAIL, "unable to free object") - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5L__link_copy_file() */ - -/*------------------------------------------------------------------------- - * Function: H5L_iterate - * - * Purpose: Iterates through links in a group - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -herr_t -H5L_iterate(H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, - hsize_t *idx_p, H5L_iterate2_t op, void *op_data) -{ - H5G_link_iterate_t lnk_op; /* Link operator */ - hsize_t last_lnk; /* Index of last object looked at */ - hsize_t idx; /* Internal location to hold index */ - herr_t ret_value = FAIL; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - /* Sanity checks */ - HDassert(loc); - HDassert(group_name); - HDassert(op); - - /* Set up iteration beginning/end info */ - idx = (idx_p == NULL ? 0 : *idx_p); - last_lnk = 0; - - /* Build link operator info */ - lnk_op.op_type = H5G_LINK_OP_NEW; - lnk_op.op_func.op_new = op; - - /* Iterate over the links */ - if ((ret_value = H5G_iterate(loc, group_name, idx_type, order, idx, &last_lnk, &lnk_op, op_data)) < 0) - HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link iteration failed") - - /* Set the index we stopped at */ - if (idx_p) - *idx_p = last_lnk; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5L_iterate() */ diff --git a/src/H5Lint.c b/src/H5Lint.c new file mode 100644 index 0000000..a8e9ba2 --- /dev/null +++ b/src/H5Lint.c @@ -0,0 +1,2240 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://www.hdfgroup.org/licenses. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/****************/ +/* Module Setup */ +/****************/ + +#include "H5Lmodule.h" /* This source code file is part of the H5L module */ + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lpkg.h" /* Links */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Oprivate.h" /* File objects */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5VLprivate.h" /* Virtual Object Layer */ + +/****************/ +/* Local Macros */ +/****************/ + +#define H5L_MIN_TABLE_SIZE 32 /* Minimum size of the user-defined link type table if it is allocated */ + +/******************/ +/* Local Typedefs */ +/******************/ + +/* User data for path traversal routine for getting link info by name */ +typedef struct { + H5L_info2_t *linfo; /* Buffer to return to user */ +} H5L_trav_gi_t; + +/* User data for path traversal callback to creating a link */ +typedef struct { + H5F_t * file; /* Pointer to the file */ + H5P_genplist_t * lc_plist; /* Link creation property list */ + H5G_name_t * path; /* Path to object being linked */ + H5O_obj_create_t *ocrt_info; /* Pointer to object creation info */ + H5O_link_t * lnk; /* Pointer to link information to insert */ +} H5L_trav_cr_t; + +/* User data for path traversal routine for moving and renaming a link */ +typedef struct { + const char * dst_name; /* Destination name for moving object */ + H5T_cset_t cset; /* Char set for new name */ + const H5G_loc_t *dst_loc; /* Destination location for moving object */ + unsigned dst_target_flags; /* Target flags for destination object */ + hbool_t copy; /* TRUE if this is a copy operation */ + size_t orig_nlinks; /* The original value for the # of soft / UD links that can be traversed */ +} H5L_trav_mv_t; + +/* User data for path traversal routine for moving and renaming an object */ +typedef struct { + H5F_t * file; /* Pointer to the file */ + H5O_link_t *lnk; /* Pointer to link information to insert */ + hbool_t copy; /* TRUE if this is a copy operation */ +} H5L_trav_mv2_t; + +/* User data for path traversal routine for checking if a link exists */ +typedef struct { + /* Down */ + char *sep; /* Pointer to next separator in the string */ + + /* Up */ + hbool_t *exists; /* Whether the link exists or not */ +} H5L_trav_le_t; + +/* User data for path traversal routine for getting link value */ +typedef struct { + size_t size; /* Size of user buffer */ + void * buf; /* User buffer */ +} H5L_trav_gv_t; + +/********************/ +/* Local Prototypes */ +/********************/ + +static int H5L__find_class_idx(H5L_type_t id); +static herr_t H5L__link_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/); +static herr_t H5L__create_real(const H5G_loc_t *link_loc, const char *link_name, H5G_name_t *obj_path, + H5F_t *obj_file, H5O_link_t *lnk, H5O_obj_create_t *ocrt_info, hid_t lcpl_id); +static herr_t H5L__get_val_real(const H5O_link_t *lnk, void *buf, size_t size); +static herr_t H5L__get_val_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/); +static herr_t H5L__get_val_by_idx_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/); +static herr_t H5L__delete_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/); +static herr_t H5L__delete_by_idx_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/); +static herr_t H5L__move_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/); +static herr_t H5L__move_dest_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/); +static herr_t H5L__exists_final_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/); +static herr_t H5L__exists_inter_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/); +static herr_t H5L__get_info_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/); +static herr_t H5L__get_info_by_idx_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/); +static herr_t H5L__get_name_by_idx_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/); + +/*********************/ +/* Package Variables */ +/*********************/ + +/* Package initialization variable */ +hbool_t H5_PKG_INIT_VAR = FALSE; + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/*******************/ +/* Local Variables */ +/*******************/ + +/* Information about user-defined links */ +static size_t H5L_table_alloc_g = 0; +static size_t H5L_table_used_g = 0; +static H5L_class_t *H5L_table_g = NULL; + +/*------------------------------------------------------------------------- + * Function: H5L_init + * + * Purpose: Initialize the interface from some other package. + * + * Return: Success: non-negative + * + * Failure: negative + * + * Programmer: James Laird + * Thursday, July 13, 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5L_init(void) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + /* FUNC_ENTER() does all the work */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5L_init() */ + +/*------------------------------------------------------------------------- + * Function: H5L__init_package + * + * Purpose: Initialize information specific to H5L interface. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: James Laird + * Tuesday, January 24, 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5L__init_package(void) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Initialize user-defined link classes */ + if (H5L_register_external() < 0) + HGOTO_ERROR(H5E_LINK, H5E_NOTREGISTERED, FAIL, "unable to register external link class") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5L_init_package() */ + +/*------------------------------------------------------------------------- + * Function: H5L_term_package + * + * Purpose: Terminate any resources allocated in H5L__init_package. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: James Laird + * Tuesday, January 24, 2006 + * + *------------------------------------------------------------------------- + */ +int +H5L_term_package(void) +{ + int n = 0; + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + if (H5_PKG_INIT_VAR) { + /* Free the table of link types */ + if (H5L_table_g) { + H5L_table_g = (H5L_class_t *)H5MM_xfree(H5L_table_g); + H5L_table_used_g = H5L_table_alloc_g = 0; + n++; + } /* end if */ + + /* Mark the interface as uninitialized */ + if (0 == n) + H5_PKG_INIT_VAR = FALSE; + } /* end if */ + + FUNC_LEAVE_NOAPI(n) +} /* H5L_term_package() */ + +/*------------------------------------------------------------------------- + * Function: H5L__find_class_idx + * + * Purpose: Given a link class ID, return the offset in the global array + * that holds all the registered link classes. + * + * Return: Success: Non-negative index of entry in global + * link class table. + * Failure: Negative + * + * Programmer: James Laird + * Monday, July 10, 2006 + * + *------------------------------------------------------------------------- + */ +static int +H5L__find_class_idx(H5L_type_t id) +{ + size_t i; /* Local index variable */ + int ret_value = FAIL; /* Return value */ + + FUNC_ENTER_STATIC_NOERR + + for (i = 0; i < H5L_table_used_g; i++) + if (H5L_table_g[i].id == id) + HGOTO_DONE((int)i) + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5L__find_class_idx */ + +/*------------------------------------------------------------------------- + * Function: H5L_find_class + * + * Purpose: Given a link class ID return a pointer to a global struct that + * defines the link class. + * + * Return: Success: Ptr to entry in global link class table. + * Failure: NULL + * + * Programmer: James Laird + * Monday, July 10, 2006 + * + *------------------------------------------------------------------------- + */ +const H5L_class_t * +H5L_find_class(H5L_type_t id) +{ + int idx; /* Filter index in global table */ + H5L_class_t *ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* Get the index in the global table */ + if ((idx = H5L__find_class_idx(id)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_NOTREGISTERED, NULL, "unable to find link class") + + /* Set return value */ + ret_value = H5L_table_g + idx; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5L_find_class */ + +/*------------------------------------------------------------------------- + * Function: H5L_register + * + * Purpose: Registers a class of user-defined links, or changes the + * behavior of an existing class. + * + * See H5Lregister for full documentation. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: James Laird + * Monday, July 10, 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5L_register(const H5L_class_t *cls) +{ + size_t i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + HDassert(cls); + HDassert(cls->id >= 0 && cls->id <= H5L_TYPE_MAX); + + /* Is the link type already registered? */ + for (i = 0; i < H5L_table_used_g; i++) + if (H5L_table_g[i].id == cls->id) + break; + + /* Filter not already registered */ + if (i >= H5L_table_used_g) { + if (H5L_table_used_g >= H5L_table_alloc_g) { + size_t n = MAX(H5L_MIN_TABLE_SIZE, (2 * H5L_table_alloc_g)); + H5L_class_t *table = (H5L_class_t *)H5MM_realloc(H5L_table_g, (n * sizeof(H5L_class_t))); + if (!table) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to extend link type table") + H5L_table_g = table; + H5L_table_alloc_g = n; + } /* end if */ + + /* Initialize */ + i = H5L_table_used_g++; + } /* end if */ + + /* Copy link class info into table */ + H5MM_memcpy(H5L_table_g + i, cls, sizeof(H5L_class_t)); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5L_register */ + +/*------------------------------------------------------------------------- + * Function: H5L_unregister + * + * Purpose: Unregisters a class of user-defined links. + * + * See H5Lunregister for full documentation. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: James Laird + * Monday, July 10, 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5L_unregister(H5L_type_t id) +{ + size_t i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + HDassert(id >= 0 && id <= H5L_TYPE_MAX); + + /* Is the filter already registered? */ + for (i = 0; i < H5L_table_used_g; i++) + if (H5L_table_g[i].id == id) + break; + + /* Fail if filter not found */ + if (i >= H5L_table_used_g) + HGOTO_ERROR(H5E_LINK, H5E_NOTREGISTERED, FAIL, "link class is not registered") + + /* Remove filter from table */ + /* Don't worry about shrinking table size (for now) */ + HDmemmove(&H5L_table_g[i], &H5L_table_g[i + 1], sizeof(H5L_class_t) * ((H5L_table_used_g - 1) - i)); + H5L_table_used_g--; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5L_unregister() */ + +/*------------------------------------------------------------------------- + * Function: H5L_is_registered + * + * Purpose: Tests whether a user-defined link class has been registered + * or not. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5L_is_registered(H5L_type_t id, hbool_t *is_registered) +{ + size_t i; /* Local index variable */ + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + /* Check args */ + HDassert(is_registered); + + /* Is the link class already registered? */ + *is_registered = FALSE; + for (i = 0; i < H5L_table_used_g; i++) + if (H5L_table_g[i].id == id) { + *is_registered = TRUE; + break; + } + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5L_is_registered() */ + +/*------------------------------------------------------------------------- + * Function: H5L_link + * + * Purpose: Creates a link from OBJ_ID to CUR_NAME. See H5Olink() for + * full documentation. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: James Laird + * Tuesday, December 13, 2005 + * + *------------------------------------------------------------------------- + */ +herr_t +H5L_link(const H5G_loc_t *new_loc, const char *new_name, H5G_loc_t *obj_loc, hid_t lcpl_id) +{ + H5O_link_t lnk; /* Link to insert */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* Check args */ + HDassert(new_loc); + HDassert(obj_loc); + HDassert(new_name && *new_name); + + /* The link callback will check that the object isn't being hard linked + * into a different file, so we don't need to do it here (there could be + * external links along the path). + */ + + /* Construct link information for eventual insertion */ + lnk.type = H5L_TYPE_HARD; + lnk.u.hard.addr = obj_loc->oloc->addr; + + /* Create the link */ + if (H5L__create_real(new_loc, new_name, obj_loc->path, obj_loc->oloc->file, &lnk, NULL, lcpl_id) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create new link to object") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5L_link() */ + +/*------------------------------------------------------------------------- + * Function: H5L_link_object + * + * Purpose: Creates a new object and a link to it. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Monday, April 9, 2007 + * + *------------------------------------------------------------------------- + */ +herr_t +H5L_link_object(const H5G_loc_t *new_loc, const char *new_name, H5O_obj_create_t *ocrt_info, hid_t lcpl_id) +{ + H5O_link_t lnk; /* Link to insert */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* Check args */ + HDassert(new_loc); + HDassert(new_name && *new_name); + HDassert(ocrt_info); + + /* The link callback will check that the object isn't being hard linked + * into a different file, so we don't need to do it here (there could be + * external links along the path). + */ + + /* Construct link information for eventual insertion */ + lnk.type = H5L_TYPE_HARD; + + /* Create the link */ + if (H5L__create_real(new_loc, new_name, NULL, NULL, &lnk, ocrt_info, lcpl_id) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create new link to object") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5L_link_object() */ + +/*------------------------------------------------------------------------- + * Function: H5L__link_cb + * + * Purpose: Callback for creating a link to an object. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Monday, September 19, 2005 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5L__link_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t H5_ATTR_UNUSED *lnk, + H5G_loc_t *obj_loc, void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/) +{ + H5L_trav_cr_t *udata = (H5L_trav_cr_t *)_udata; /* User data passed in */ + H5G_t * grp = NULL; /* H5G_t for this group, opened to pass to user callback */ + hid_t grp_id = FAIL; /* Id for this group (passed to user callback */ + H5G_loc_t temp_loc; /* For UD callback */ + hbool_t temp_loc_init = FALSE; /* Temporary location for UD callback (temp_loc) has been initialized */ + hbool_t obj_created = FALSE; /* Whether an object was created (through a hard link) */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the name in this group resolved to a valid location */ + /* (which is not what we want) */ + if (obj_loc != NULL) + HGOTO_ERROR(H5E_LINK, H5E_EXISTS, FAIL, "name already exists") + + /* Check for crossing file boundaries with a new hard link */ + if (udata->lnk->type == H5L_TYPE_HARD) { + /* Check for creating an object */ + /* (only for hard links) */ + if (udata->ocrt_info) { + H5G_loc_t new_loc; /* Group location for new object */ + + /* Create new object at this location */ + if (NULL == + (udata->ocrt_info->new_obj = H5O_obj_create(grp_loc->oloc->file, udata->ocrt_info->obj_type, + udata->ocrt_info->crt_info, &new_loc))) + HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create object") + + /* Set address for hard link */ + udata->lnk->u.hard.addr = new_loc.oloc->addr; + + /* Set object path to use for setting object name (below) */ + udata->path = new_loc.path; + + /* Indicate that an object was created */ + obj_created = TRUE; + } /* end if */ + else { + /* Check that both objects are in same file */ + if (!H5F_SAME_SHARED(grp_loc->oloc->file, udata->file)) + HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, "interfile hard links are not allowed") + } /* end else */ + } /* end if */ + + /* Set 'standard' aspects of link */ + udata->lnk->corder = + 0; /* Will be re-written during group insertion, if the group is tracking creation order */ + udata->lnk->corder_valid = FALSE; /* Creation order not valid (yet) */ + + /* Check for non-default link creation properties */ + if (udata->lc_plist) { + /* Get character encoding property */ + if (H5CX_get_encoding(&udata->lnk->cset) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't get 'character set' property") + } /* end if */ + else + udata->lnk->cset = H5F_DEFAULT_CSET; /* Default character encoding for link */ + + /* Set the link's name correctly */ + /* Casting away const OK -QAK */ + udata->lnk->name = (char *)name; + + /* Insert link into group */ + if (H5G_obj_insert(grp_loc->oloc, name, udata->lnk, TRUE, + udata->ocrt_info ? udata->ocrt_info->obj_type : H5O_TYPE_UNKNOWN, + udata->ocrt_info ? udata->ocrt_info->crt_info : NULL) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create new link for object") + + /* Set object's path if it has been passed in and is not set */ + if (udata->path != NULL && udata->path->user_path_r == NULL) + if (H5G_name_set(grp_loc->path, udata->path, name) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "cannot set name") + + /* If link is a user-defined link, trigger its creation callback if it has one */ + if (udata->lnk->type >= H5L_TYPE_UD_MIN) { + const H5L_class_t *link_class; /* User-defined link class */ + + /* Get the link class for this type of link. */ + if (NULL == (link_class = H5L_find_class(udata->lnk->type))) + HGOTO_ERROR(H5E_LINK, H5E_NOTREGISTERED, FAIL, "unable to get class of UD link") + + if (link_class->create_func != NULL) { + H5O_loc_t temp_oloc; + H5G_name_t temp_path; + + /* Create a temporary location (or else H5G_open will do a shallow + * copy and wipe out grp_loc) + */ + H5G_name_reset(&temp_path); + if (H5O_loc_copy_deep(&temp_oloc, grp_loc->oloc) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTCOPY, FAIL, "unable to copy object location") + + temp_loc.oloc = &temp_oloc; + temp_loc.path = &temp_path; + temp_loc_init = TRUE; + + /* Set up location for user-defined callback */ + if (NULL == (grp = H5G_open(&temp_loc))) + HGOTO_ERROR(H5E_LINK, H5E_CANTOPENOBJ, FAIL, "unable to open group") + if ((grp_id = H5VL_wrap_register(H5I_GROUP, grp, TRUE)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTREGISTER, FAIL, "unable to register ID for group") + + /* Make callback */ + if ((link_class->create_func)(name, grp_id, udata->lnk->u.ud.udata, udata->lnk->u.ud.size, + H5P_DEFAULT) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CALLBACK, FAIL, "link creation callback failed") + } /* end if */ + } /* end if */ + +done: + /* Check if an object was created */ + if (obj_created) { + H5O_loc_t oloc; /* Object location for created object */ + + /* Set up object location */ + HDmemset(&oloc, 0, sizeof(oloc)); + oloc.file = grp_loc->oloc->file; + oloc.addr = udata->lnk->u.hard.addr; + + /* Decrement refcount on new object's object header in memory */ + if (H5O_dec_rc_by_loc(&oloc) < 0) + HDONE_ERROR(H5E_LINK, H5E_CANTDEC, FAIL, "unable to decrement refcount on newly created object") + } /* end if */ + + /* Close the location given to the user callback if it was created */ + if (grp_id >= 0) { + if (H5I_dec_app_ref(grp_id) < 0) + HDONE_ERROR(H5E_LINK, H5E_CANTRELEASE, FAIL, "unable to close ID from UD callback") + } /* end if */ + else if (grp != NULL) { + if (H5G_close(grp) < 0) + HDONE_ERROR(H5E_LINK, H5E_CANTRELEASE, FAIL, "unable to close group given to UD callback") + } /* end if */ + else if (temp_loc_init) + H5G_loc_free(&temp_loc); + + /* Indicate that this callback didn't take ownership of the group * + * location for the object */ + *own_loc = H5G_OWN_NONE; + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5L__link_cb() */ + +/*------------------------------------------------------------------------- + * Function: H5L__create_real + * + * Purpose: Creates a link at a path location + * + * lnk should have linkclass-specific information already + * set, but this function will take care of setting name. + * + * obj_path can be NULL if the object's path doesn't need to + * be set, and obj_file can be NULL if the object is not a + * hard link. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Monday, December 5, 2005 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5L__create_real(const H5G_loc_t *link_loc, const char *link_name, H5G_name_t *obj_path, H5F_t *obj_file, + H5O_link_t *lnk, H5O_obj_create_t *ocrt_info, hid_t lcpl_id) +{ + char * norm_link_name = NULL; /* Pointer to normalized link name */ + unsigned target_flags = H5G_TARGET_NORMAL; /* Flags to pass to group traversal function */ + H5P_genplist_t *lc_plist = NULL; /* Link creation property list */ + H5L_trav_cr_t udata; /* User data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check args */ + HDassert(link_loc); + HDassert(link_name && *link_name); + HDassert(lnk); + HDassert(lnk->type >= H5L_TYPE_HARD && lnk->type <= H5L_TYPE_MAX); + + /* Get normalized link name */ + if ((norm_link_name = H5G_normalize(link_name)) == NULL) + HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, "can't normalize name") + + /* Check for flags present in creation property list */ + if (lcpl_id != H5P_DEFAULT) { + unsigned crt_intmd_group; + + /* Get link creation property list */ + if (NULL == (lc_plist = (H5P_genplist_t *)H5I_object(lcpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") + + /* Get intermediate group creation property */ + if (H5CX_get_intermediate_group(&crt_intmd_group) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't get 'create intermediate group' property") + + if (crt_intmd_group > 0) + target_flags |= H5G_CRT_INTMD_GROUP; + } /* end if */ + + /* Set up user data + * FILE is used to make sure that hard links don't cross files, and + * should be NULL for other link types. + * LC_PLIST is a pointer to the link creation property list. + * PATH is a pointer to the path of the object being inserted if this is + * a hard link; this is used to set the paths to objects when they are + * created. For other link types, this is NULL. + * OCRT_INFO is a pointer to the structure for object creation. + * LNK is the link struct passed into this function. At this point all + * of its fields should be populated except for name, which is set when + * inserting it in the callback. + */ + udata.file = obj_file; + udata.lc_plist = lc_plist; + udata.path = obj_path; + udata.ocrt_info = ocrt_info; + udata.lnk = lnk; + + /* Traverse the destination path & create new link */ + if (H5G_traverse(link_loc, link_name, target_flags, H5L__link_cb, &udata) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTINSERT, FAIL, "can't insert link") + +done: + /* Free the normalized path name */ + if (norm_link_name) + H5MM_xfree(norm_link_name); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5L__create_real() */ + +/*------------------------------------------------------------------------- + * Function: H5L__create_hard + * + * Purpose: Creates a hard link from NEW_NAME to CUR_NAME. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Robb Matzke + * Monday, April 6, 1998 + * + *------------------------------------------------------------------------- + */ +herr_t +H5L__create_hard(H5G_loc_t *cur_loc, const char *cur_name, const H5G_loc_t *link_loc, const char *link_name, + hid_t lcpl_id) +{ + char * norm_cur_name = NULL; /* Pointer to normalized current name */ + H5F_t * link_file = NULL; /* Pointer to file to link to */ + H5O_link_t lnk; /* Link to insert */ + H5G_loc_t obj_loc; /* Location of object to link to */ + H5G_name_t path; /* obj_loc's path*/ + H5O_loc_t oloc; /* obj_loc's oloc */ + hbool_t loc_valid = FALSE; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Check args */ + HDassert(cur_loc); + HDassert(cur_name && *cur_name); + HDassert(link_loc); + HDassert(link_name && *link_name); + + /* Get normalized copy of the current name */ + if ((norm_cur_name = H5G_normalize(cur_name)) == NULL) + HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, "can't normalize name") + + /* Set up link data specific to hard links */ + lnk.type = H5L_TYPE_HARD; + + /* Get object location for object pointed to */ + obj_loc.path = &path; + obj_loc.oloc = &oloc; + H5G_loc_reset(&obj_loc); + if (H5G_loc_find(cur_loc, norm_cur_name, &obj_loc) < 0) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "source object not found") + loc_valid = TRUE; + + /* Construct link information for eventual insertion */ + lnk.u.hard.addr = obj_loc.oloc->addr; + + /* Set destination's file information */ + link_file = obj_loc.oloc->file; + + /* Create actual link to the object. Pass in NULL for the path, since this + * function shouldn't change an object's user path. */ + if (H5L__create_real(link_loc, link_name, NULL, link_file, &lnk, NULL, lcpl_id) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create new link to object") + +done: + /* Free the object header location */ + if (loc_valid) + if (H5G_loc_free(&obj_loc) < 0) + HDONE_ERROR(H5E_LINK, H5E_CANTRELEASE, FAIL, "unable to free location") + + /* Free the normalized path name */ + if (norm_cur_name) + H5MM_xfree(norm_cur_name); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5L__create_hard() */ + +/*------------------------------------------------------------------------- + * Function: H5L__create_soft + * + * Purpose: Creates a soft link from LINK_NAME to TARGET_PATH. + * + * Return: SUCCEED/FAIL + * + * Programmer: Robb Matzke + * Monday, April 6, 1998 + * + *------------------------------------------------------------------------- + */ +herr_t +H5L__create_soft(const char *target_path, const H5G_loc_t *link_loc, const char *link_name, hid_t lcpl_id) +{ + char * norm_target = NULL; /* Pointer to normalized current name */ + H5O_link_t lnk; /* Link to insert */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Check args */ + HDassert(link_loc); + HDassert(target_path && *target_path); + HDassert(link_name && *link_name); + + /* Get normalized copy of the link target */ + if ((norm_target = H5G_normalize(target_path)) == NULL) + HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, "can't normalize name") + + /* Set up link data specific to soft links */ + lnk.type = H5L_TYPE_SOFT; + lnk.u.soft.name = norm_target; + + /* Create actual link to the object */ + if (H5L__create_real(link_loc, link_name, NULL, NULL, &lnk, NULL, lcpl_id) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create new link to object") + +done: + /* Free the normalized target name */ + if (norm_target) + H5MM_xfree(norm_target); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5L__create_soft() */ + +/*------------------------------------------------------------------------- + * Function: H5L__create_ud + * + * Purpose: Creates a user-defined link. See H5Lcreate_ud for + * full documentation. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: James Laird + * Friday, May 19, 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5L__create_ud(const H5G_loc_t *link_loc, const char *link_name, const void *ud_data, size_t ud_data_size, + H5L_type_t type, hid_t lcpl_id) +{ + H5O_link_t lnk; /* Link to insert */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Check args */ + HDassert(type >= H5L_TYPE_UD_MIN && type <= H5L_TYPE_MAX); + HDassert(link_loc); + HDassert(link_name && *link_name); + HDassert(ud_data_size == 0 || ud_data); + + /* Initialize the link struct's pointer to its udata buffer */ + lnk.u.ud.udata = NULL; + + /* Make sure that this link class is registered */ + if (H5L__find_class_idx(type) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "link class has not been registered with library") + + /* Fill in UD link-specific information in the link struct*/ + if (ud_data_size > 0) { + lnk.u.ud.udata = H5MM_malloc((size_t)ud_data_size); + H5MM_memcpy(lnk.u.ud.udata, ud_data, (size_t)ud_data_size); + } /* end if */ + else + lnk.u.ud.udata = NULL; + + lnk.u.ud.size = ud_data_size; + lnk.type = type; + + /* Create actual link to the object */ + if (H5L__create_real(link_loc, link_name, NULL, NULL, &lnk, NULL, lcpl_id) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to register new name for object") + +done: + /* Free the link's udata buffer if it's been allocated */ + H5MM_xfree(lnk.u.ud.udata); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5L__create_ud() */ + +/*------------------------------------------------------------------------- + * Function: H5L__get_val_real + * + * Purpose: Retrieve link value from a link object + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Monday, November 13 2006 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5L__get_val_real(const H5O_link_t *lnk, void *buf, size_t size) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(lnk); + + /* Check for soft link */ + if (H5L_TYPE_SOFT == lnk->type) { + /* Copy to output buffer */ + if (size > 0 && buf) { + HDstrncpy((char *)buf, lnk->u.soft.name, size); + if (HDstrlen(lnk->u.soft.name) >= size) + ((char *)buf)[size - 1] = '\0'; + } /* end if */ + } /* end if */ + /* Check for user-defined link */ + else if (lnk->type >= H5L_TYPE_UD_MIN) { + const H5L_class_t *link_class; /* User-defined link class */ + + /* Get the link class for this type of link. It's okay if the class + * isn't registered, though--we just can't give any more information + * about it + */ + link_class = H5L_find_class(lnk->type); + + if (link_class != NULL && link_class->query_func != NULL) { + if ((link_class->query_func)(lnk->name, lnk->u.ud.udata, lnk->u.ud.size, buf, size) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CALLBACK, FAIL, "query callback returned failure") + } /* end if */ + else if (buf && size > 0) + ((char *)buf)[0] = '\0'; + } /* end if */ + else + HGOTO_ERROR(H5E_LINK, H5E_BADTYPE, FAIL, "object is not a symbolic or user-defined link") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5L__get_val_real() */ + +/*------------------------------------------------------------------------- + * Function: H5L__get_val_cb + * + * Purpose: Callback for retrieving link value or udata. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Tuesday, September 20, 2005 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5L__get_val_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, + H5G_loc_t H5_ATTR_UNUSED *obj_loc, void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/) +{ + H5L_trav_gv_t *udata = (H5L_trav_gv_t *)_udata; /* User data passed in */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the name in this group resolved to a valid link */ + if (lnk == NULL) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "'%s' doesn't exist", name) + + /* Retrieve the value for the link */ + if (H5L__get_val_real(lnk, udata->buf, udata->size) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't retrieve link value") + +done: + /* Indicate that this callback didn't take ownership of the group * + * location for the object */ + *own_loc = H5G_OWN_NONE; + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5L__get_val_cb() */ + +/*------------------------------------------------------------------------- + * Function: H5L__get_val + * + * Purpose: Returns the value of a symbolic link or the udata for a + * user-defined link. + * + * Return: Success: Non-negative, with at most SIZE bytes of the + * link value copied into the BUF buffer. If the + * link value is larger than SIZE characters + * counting the null terminator then the BUF + * result will not be null terminated. + * + * Failure: Negative + * + * Programmer: Robb Matzke + * Monday, April 13, 1998 + * + *------------------------------------------------------------------------- + */ +herr_t +H5L__get_val(const H5G_loc_t *loc, const char *name, void *buf /*out*/, size_t size) +{ + H5L_trav_gv_t udata; /* User data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Sanity check */ + HDassert(loc); + HDassert(name && *name); + + /* Set up user data for retrieving information */ + udata.size = size; + udata.buf = buf; + + /* Traverse the group hierarchy to locate the object to get info about */ + if (H5G_traverse(loc, name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L__get_val_cb, &udata) < 0) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "name doesn't exist") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5L__get_val() */ + +/*------------------------------------------------------------------------- + * Function: H5L__get_val_by_idx_cb + * + * Purpose: Callback for retrieving a link's value according to an + * index's order. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Monday, November 13 2006 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5L__get_val_by_idx_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ATTR_UNUSED *name, + const H5O_link_t H5_ATTR_UNUSED *lnk, H5G_loc_t *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/) +{ + H5L_trav_gvbi_t *udata = (H5L_trav_gvbi_t *)_udata; /* User data passed in */ + H5O_link_t fnd_lnk; /* Link within group */ + hbool_t lnk_copied = FALSE; /* Whether the link was copied */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the name of the group resolved to a valid object */ + if (obj_loc == NULL) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "group doesn't exist") + + /* Query link */ + if (H5G_obj_lookup_by_idx(obj_loc->oloc, udata->idx_type, udata->order, udata->n, &fnd_lnk) < 0) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "link not found") + lnk_copied = TRUE; + + /* Retrieve the value for the link */ + if (H5L__get_val_real(&fnd_lnk, udata->buf, udata->size) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't retrieve link value") + +done: + /* Reset the link information, if we have a copy */ + if (lnk_copied) + H5O_msg_reset(H5O_LINK_ID, &fnd_lnk); + + /* Indicate that this callback didn't take ownership of the group * + * location for the object */ + *own_loc = H5G_OWN_NONE; + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5L__get_val_by_idx_cb() */ + +/*------------------------------------------------------------------------- + * Function: H5L__get_val_by_idx + * + * Purpose: Internal routine to query a link value according to the + * index within a group + * + * Return: SUCCEED/FAIL + * + * Programmer: Quincey Koziol + * December 27, 2017 + * + *------------------------------------------------------------------------- + */ +herr_t +H5L__get_val_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, H5_iter_order_t order, + hsize_t n, void *buf /*out*/, size_t size) +{ + H5L_trav_gvbi_t udata; /* User data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Check arguments */ + HDassert(loc); + HDassert(name && *name); + + /* Set up user data for retrieving information */ + udata.idx_type = idx_type; + udata.order = order; + udata.n = n; + udata.buf = buf; + udata.size = size; + + /* Traverse the group hierarchy to locate the object to get info about */ + if (H5G_traverse(loc, name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L__get_val_by_idx_cb, &udata) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't get link info for index: %llu", (unsigned long long)n) + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5L__get_val_by_idx() */ + +/*------------------------------------------------------------------------- + * Function: H5L__delete_cb + * + * Purpose: Callback for deleting a link. This routine + * actually deletes the link + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Monday, September 19, 2005 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5L__delete_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, + H5G_loc_t H5_ATTR_UNUSED *obj_loc, void H5_ATTR_UNUSED *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Check if the group resolved to a valid link */ + if (grp_loc == NULL) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "group doesn't exist") + + /* Check if the name in this group resolved to a valid link */ + if (name == NULL) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "name doesn't exist") + + /* Check for non-existent (NULL) link. + * Note that this can also occur when attempting to remove '.' + */ + if (lnk == NULL) + HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, + "callback link pointer is NULL (specified link may be '.' or not exist)") + + /* Remove the link from the group */ + if (H5G_obj_remove(grp_loc->oloc, grp_loc->path->full_path_r, name) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to remove link from group") + +done: + /* Indicate that this callback didn't take ownership of the group * + * location for the object */ + *own_loc = H5G_OWN_NONE; + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5L__delete_cb() */ + +/*------------------------------------------------------------------------- + * Function: H5L__delete + * + * Purpose: Delete a link from a group. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Robb Matzke + * Thursday, September 17, 1998 + * + *------------------------------------------------------------------------- + */ +herr_t +H5L__delete(const H5G_loc_t *loc, const char *name) +{ + char * norm_name = NULL; /* Pointer to normalized name */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Sanity check */ + HDassert(loc); + HDassert(name && *name); + + /* Get normalized copy of the name */ + if ((norm_name = H5G_normalize(name)) == NULL) + HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, "can't normalize name") + + /* Set up user data for unlink operation */ + if (H5G_traverse(loc, norm_name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK | H5G_TARGET_MOUNT, H5L__delete_cb, + NULL) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTREMOVE, FAIL, "can't unlink object") + +done: + /* Free the normalized path name */ + if (norm_name) + H5MM_xfree(norm_name); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5L__delete() */ + +/*------------------------------------------------------------------------- + * Function: H5L__delete_by_idx_cb + * + * Purpose: Callback for removing a link according to an index's order. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Monday, November 13 2006 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5L__delete_by_idx_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ATTR_UNUSED *name, + const H5O_link_t H5_ATTR_UNUSED *lnk, H5G_loc_t *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/) +{ + H5L_trav_gvbi_t *udata = (H5L_trav_gvbi_t *)_udata; /* User data passed in */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC_TAG((obj_loc) ? (obj_loc->oloc->addr) : HADDR_UNDEF) + + /* Check if the name of the group resolved to a valid object */ + if (obj_loc == NULL) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "group doesn't exist") + + /* Delete link */ + if (H5G_obj_remove_by_idx(obj_loc->oloc, obj_loc->path->full_path_r, udata->idx_type, udata->order, + udata->n) < 0) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "link not found") + +done: + /* Indicate that this callback didn't take ownership of the group * + * location for the object */ + *own_loc = H5G_OWN_NONE; + + FUNC_LEAVE_NOAPI_TAG(ret_value) +} /* end H5L__delete_by_idx_cb() */ + +/*------------------------------------------------------------------------- + * Function: H5L__delete_by_idx + * + * Purpose: Internal routine to delete a link according to its index + * within a group. + * + * Return: SUCCEED/FAIL + * + * Programmer: Quincey Koziol + * December 27, 2017 + * + *------------------------------------------------------------------------- + */ +herr_t +H5L__delete_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, H5_iter_order_t order, + hsize_t n) +{ + H5L_trav_rmbi_t udata; /* User data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Sanity check */ + HDassert(loc); + HDassert(name && *name); + + /* Set up user data for unlink operation */ + udata.idx_type = idx_type; + udata.order = order; + udata.n = n; + + /* Traverse the group hierarchy to remove the link */ + if (H5G_traverse(loc, name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK | H5G_TARGET_MOUNT, + H5L__delete_by_idx_cb, &udata) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "link doesn't exist") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5L__delete_by_idx() */ + +/*------------------------------------------------------------------------- + * Function: H5L__move_dest_cb + * + * Purpose: Second callback for moving and renaming an object. This routine + * inserts a new link into the group returned by the traversal. + * It is called by H5L__move_cb. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: James Laird + * Monday, April 3, 2006 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5L__move_dest_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t H5_ATTR_UNUSED *lnk, + H5G_loc_t *obj_loc, void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/) +{ + H5L_trav_mv2_t *udata = (H5L_trav_mv2_t *)_udata; /* User data passed in */ + H5G_t * grp = NULL; /* H5G_t for this group, opened to pass to user callback */ + hid_t grp_id = FAIL; /* ID for this group (passed to user callback */ + H5G_loc_t temp_loc; /* For UD callback */ + hbool_t temp_loc_init = FALSE; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Make sure an object with this name doesn't already exist */ + if (obj_loc != NULL) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "an object with that name already exists") + + /* Check for crossing file boundaries with a new hard link */ + if (udata->lnk->type == H5L_TYPE_HARD) + /* Check that both objects are in same file */ + if (!H5F_SAME_SHARED(grp_loc->oloc->file, udata->file)) + HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "moving a link across files is not allowed") + + /* Give the object its new name */ + /* Casting away const okay -JML */ + HDassert(udata->lnk->name == NULL); + udata->lnk->name = (char *)name; + + /* Insert the link into the group */ + if (H5G_obj_insert(grp_loc->oloc, name, udata->lnk, TRUE, H5O_TYPE_UNKNOWN, NULL) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create new link to object") + + /* If the link was a user-defined link, call its move callback if it has one */ + if (udata->lnk->type >= H5L_TYPE_UD_MIN) { + const H5L_class_t *link_class; /* User-defined link class */ + + /* Get the link class for this type of link. */ + if (NULL == (link_class = H5L_find_class(udata->lnk->type))) + HGOTO_ERROR(H5E_LINK, H5E_NOTREGISTERED, FAIL, "link class is not registered") + + if ((!udata->copy && link_class->move_func) || (udata->copy && link_class->copy_func)) { + H5O_loc_t temp_oloc; + H5G_name_t temp_path; + + /* Create a temporary location (or else H5G_open will do a shallow + * copy and wipe out grp_loc) + */ + H5G_name_reset(&temp_path); + if (H5O_loc_copy_deep(&temp_oloc, grp_loc->oloc) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTCOPY, FAIL, "unable to copy object location") + + temp_loc.oloc = &temp_oloc; + temp_loc.path = &temp_path; + temp_loc_init = TRUE; + + /* Set up location for user-defined callback */ + if (NULL == (grp = H5G_open(&temp_loc))) + HGOTO_ERROR(H5E_LINK, H5E_CANTOPENOBJ, FAIL, "unable to open group") + if ((grp_id = H5VL_wrap_register(H5I_GROUP, grp, TRUE)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTREGISTER, FAIL, "unable to register group ID") + + if (udata->copy) { + if ((link_class->copy_func)(udata->lnk->name, grp_id, udata->lnk->u.ud.udata, + udata->lnk->u.ud.size) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CALLBACK, FAIL, "UD copy callback returned error") + } /* end if */ + else { + if ((link_class->move_func)(udata->lnk->name, grp_id, udata->lnk->u.ud.udata, + udata->lnk->u.ud.size) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CALLBACK, FAIL, "UD move callback returned error") + } /* end else */ + } /* end if */ + } /* end if */ + +done: + /* Close the location given to the user callback if it was created */ + if (grp_id >= 0) { + if (H5I_dec_app_ref(grp_id) < 0) + HDONE_ERROR(H5E_LINK, H5E_CANTRELEASE, FAIL, "unable to close ID from UD callback") + } /* end if */ + else if (grp != NULL) { + if (H5G_close(grp) < 0) + HDONE_ERROR(H5E_LINK, H5E_CANTRELEASE, FAIL, "unable to close group given to UD callback") + } /* end if */ + else if (temp_loc_init) + H5G_loc_free(&temp_loc); + + /* Indicate that this callback didn't take ownership of the group * + * location for the object */ + *own_loc = H5G_OWN_NONE; + + /* Reset the "name" field in udata->lnk because it is owned by traverse() + * and must not be manipulated after traverse closes */ + udata->lnk->name = NULL; + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5L__move_dest_cb() */ + +/*------------------------------------------------------------------------- + * Function: H5L__move_cb + * + * Purpose: Callback for moving and renaming an object. This routine + * replaces the names of open objects with the moved object + * in the path + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: James Laird + * Friday, April 3, 2006 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5L__move_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, H5G_loc_t *obj_loc, + void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/) +{ + H5L_trav_mv_t *udata = (H5L_trav_mv_t *)_udata; /* User data passed in */ + H5L_trav_mv2_t udata_out; /* User data for H5L__move_dest_cb traversal */ + char * orig_name = NULL; /* The name of the link in this group */ + hbool_t link_copied = FALSE; /* Has udata_out.lnk been allocated? */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the name in this group resolved to a valid link */ + if (obj_loc == NULL) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "name doesn't exist") + + /* Check for operations on '.' */ + if (lnk == NULL) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "the name of a link must be supplied to move or copy") + + /* Set up user data for move_dest_cb */ + if (NULL == (udata_out.lnk = (H5O_link_t *)H5O_msg_copy(H5O_LINK_ID, lnk, NULL))) + HGOTO_ERROR(H5E_LINK, H5E_CANTCOPY, FAIL, "unable to copy link to be moved") + + /* In this special case, the link's name is going to be replaced at its + * destination, so we should free it here. + */ + udata_out.lnk->name = (char *)H5MM_xfree(udata_out.lnk->name); + link_copied = TRUE; + + udata_out.lnk->cset = udata->cset; + udata_out.file = grp_loc->oloc->file; + udata_out.copy = udata->copy; + + /* Keep a copy of link's name (it's "owned" by the H5G_traverse() routine) */ + orig_name = H5MM_xstrdup(name); + + /* Reset the # of soft / UD links that can be traversed, so that the second + * (destination) traversal has the correct value + */ + if (H5CX_set_nlinks(udata->orig_nlinks) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't reset # of soft / UD links to traverse") + + /* Insert the link into its new location */ + if (H5G_traverse(udata->dst_loc, udata->dst_name, udata->dst_target_flags, H5L__move_dest_cb, + &udata_out) < 0) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to follow symbolic link") + + /* If this is a move and not a copy operation, change the object's name and remove the old link */ + if (!udata->copy) { + H5RS_str_t *dst_name_r; /* Ref-counted version of dest name */ + + /* Make certain that the destination name is a full (not relative) path */ + if (*(udata->dst_name) != '/') { + HDassert(udata->dst_loc->path->full_path_r); + + /* Create reference counted string for full dst path */ + if ((dst_name_r = H5G_build_fullpath_refstr_str(udata->dst_loc->path->full_path_r, + udata->dst_name)) == NULL) + HGOTO_ERROR(H5E_LINK, H5E_PATH, FAIL, "can't build destination path name") + } /* end if */ + else + dst_name_r = H5RS_wrap(udata->dst_name); + HDassert(dst_name_r); + + /* Fix names up */ + if (H5G_name_replace(lnk, H5G_NAME_MOVE, obj_loc->oloc->file, obj_loc->path->full_path_r, + udata->dst_loc->oloc->file, dst_name_r) < 0) { + H5RS_decr(dst_name_r); + HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to replace name") + } /* end if */ + + /* Remove the old link */ + if (H5G_obj_remove(grp_loc->oloc, grp_loc->path->full_path_r, orig_name) < 0) { + H5RS_decr(dst_name_r); + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to remove old name") + } /* end if */ + + H5RS_decr(dst_name_r); + } /* end if */ + +done: + /* Cleanup */ + if (orig_name) + H5MM_xfree(orig_name); + + /* If udata_out.lnk was copied, free any memory allocated + * In this special case, the H5L__move_dest_cb callback resets the name + * so H5O_msg_free shouldn't try to free it + */ + if (link_copied) + H5O_msg_free(H5O_LINK_ID, udata_out.lnk); + + /* Indicate that this callback didn't take ownership of the group * + * location for the object */ + *own_loc = H5G_OWN_NONE; + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5L__move_cb() */ + +/*------------------------------------------------------------------------- + * Function: H5L__move + * + * Purpose: Atomically move or copy a link. + * + * Creates a copy of a link in a new destination with a new name. + * SRC_LOC and SRC_NAME together define the link's original + * location, while DST_LOC and DST_NAME together define its + * final location. + * + * If copy_flag is FALSE, the original link is removed + * (effectively moving the link). + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: James Laird + * Monday, May 1, 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5L__move(const H5G_loc_t *src_loc, const char *src_name, const H5G_loc_t *dst_loc, const char *dst_name, + hbool_t copy_flag, hid_t lcpl_id) +{ + unsigned dst_target_flags = H5G_TARGET_NORMAL; + H5T_cset_t char_encoding = H5F_DEFAULT_CSET; /* Character encoding for link */ + H5P_genplist_t *lc_plist; /* Link creation property list */ + H5L_trav_mv_t udata; /* User data for traversal */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Sanity check */ + HDassert(src_loc); + HDassert(dst_loc); + HDassert(src_name && *src_name); + HDassert(dst_name && *dst_name); + + /* Check for flags present in creation property list */ + if (lcpl_id != H5P_DEFAULT) { + unsigned crt_intmd_group; + + if (NULL == (lc_plist = (H5P_genplist_t *)H5I_object(lcpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") + + /* Get intermediate group creation property */ + if (H5CX_get_intermediate_group(&crt_intmd_group) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for creating missing groups") + + /* Set target flags for source and destination */ + if (crt_intmd_group > 0) + dst_target_flags |= H5G_CRT_INTMD_GROUP; + + /* Get character encoding property */ + if (H5CX_get_encoding(&char_encoding) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for character encoding") + } /* end if */ + + /* Set up user data */ + udata.dst_loc = dst_loc; + udata.dst_name = dst_name; + udata.dst_target_flags = dst_target_flags; + udata.cset = char_encoding; + udata.copy = copy_flag; + + /* Retrieve the original # of soft / UD links that can be traversed, so + * that the countdown can be reset after the first path is traversed. + */ + if (H5CX_get_nlinks(&udata.orig_nlinks) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to retrieve # of soft / UD links to traverse") + + /* Do the move */ + if (H5G_traverse(src_loc, src_name, H5G_TARGET_MOUNT | H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L__move_cb, + &udata) < 0) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to find link") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5L__move() */ + +/*------------------------------------------------------------------------- + * Function: H5L__exists_final_cb + * + * Purpose: Callback for checking whether a link exists, as the final + * component of a path + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Friday, March 16 2007 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5L__exists_final_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ATTR_UNUSED *name, + const H5O_link_t *lnk, H5G_loc_t H5_ATTR_UNUSED *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/) +{ + H5L_trav_le_t *udata = (H5L_trav_le_t *)_udata; /* User data passed in */ + + FUNC_ENTER_STATIC_NOERR + + /* Check if the name in this group resolved to a valid link */ + *udata->exists = (hbool_t)(lnk != NULL); + + /* Indicate that this callback didn't take ownership of the group * + * location for the object */ + *own_loc = H5G_OWN_NONE; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5L__exists_final_cb() */ + +/*------------------------------------------------------------------------- + * Function: H5L__exists_inter_cb + * + * Purpose: Callback for checking whether a link exists, as an intermediate + * component of a path + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Thursday, December 31 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5L__exists_inter_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ATTR_UNUSED *name, + const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/) +{ + H5L_trav_le_t *udata = (H5L_trav_le_t *)_udata; /* User data passed in */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the name in this group resolved to a valid link */ + if (lnk != NULL) { + /* Check for more components to the path */ + if (udata->sep) { + H5G_traverse_t cb_func; /* Callback function for tranversal */ + char * next; /* Pointer to next component name */ + + /* Look for another separator */ + next = udata->sep; + if (NULL == (udata->sep = HDstrchr(udata->sep, '/'))) + cb_func = H5L__exists_final_cb; + else { + /* Chew through adjacent separators, if present */ + do { + *udata->sep = '\0'; + udata->sep++; + } while ('/' == *udata->sep); + cb_func = H5L__exists_inter_cb; + } /* end else */ + if (H5G_traverse(obj_loc, next, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, cb_func, udata) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't determine if link exists") + } /* end if */ + else + *udata->exists = TRUE; + } /* end if */ + else + *udata->exists = FALSE; + + /* Indicate that this callback didn't take ownership of the group * + * location for the object */ + *own_loc = H5G_OWN_NONE; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5L__exists_inter_cb() */ + +/*------------------------------------------------------------------------- + * Function: H5L_exists_tolerant + * + * Purpose: Returns whether a link exists in a group + * + * Note: Same as H5L__exists, except that missing links are reported + * as 'FALSE' instead of causing failures + * + * Return: Non-negative (TRUE/FALSE) on success/Negative on failure + * + * Programmer: Quincey Koziol + * Thursday, December 31 2015 + * + *------------------------------------------------------------------------- + */ +herr_t +H5L_exists_tolerant(const H5G_loc_t *loc, const char *name, hbool_t *exists) +{ + H5L_trav_le_t udata; /* User data for traversal */ + H5G_traverse_t cb_func; /* Callback function for tranversal */ + char * name_copy = NULL; /* Duplicate of name */ + char * name_trav; /* Name to traverse */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(loc); + HDassert(name); + HDassert(exists); + + /* Copy the name and skip leading '/'s */ + name_trav = name_copy = H5MM_strdup(name); + while ('/' == *name_trav) + name_trav++; + + /* A path of "/" will always exist in a file */ + if ('\0' == *name_trav) + *exists = TRUE; + else { + /* Set up user data & correct callback */ + udata.exists = exists; + if (NULL == (udata.sep = HDstrchr(name_trav, '/'))) + cb_func = H5L__exists_final_cb; + else { + /* Chew through adjacent separators, if present */ + do { + *udata.sep = '\0'; + udata.sep++; + } while ('/' == *udata.sep); + cb_func = H5L__exists_inter_cb; + } /* end else */ + + /* Traverse the group hierarchy to locate the link to check */ + if (H5G_traverse(loc, name_trav, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, cb_func, &udata) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't determine if link exists") + } + +done: + /* Release duplicated string */ + H5MM_xfree(name_copy); + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5L_exists_tolerant() */ + +/*------------------------------------------------------------------------- + * Function: H5L__exists + * + * Purpose: Returns whether a link exists in a group + * + * Note: Same as H5L_exists_tolerant, except that missing links are reported + * as failures + * + * Return: Non-negative on success, with *exists set/Negative on failure + * + * Programmer: Quincey Koziol + * Friday, March 16 2007 + * + *------------------------------------------------------------------------- + */ +herr_t +H5L__exists(const H5G_loc_t *loc, const char *name, hbool_t *exists) +{ + H5L_trav_le_t udata; /* User data for traversal */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Sanity checks */ + HDassert(loc); + HDassert(name); + HDassert(exists); + + /* A path of "/" will always exist in a file */ + if (0 == HDstrcmp(name, "/")) + *exists = TRUE; + else { + /* Traverse the group hierarchy to locate the object to get info about */ + udata.exists = exists; + if (H5G_traverse(loc, name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L__exists_final_cb, &udata) < 0) + HGOTO_ERROR(H5E_LINK, H5E_EXISTS, FAIL, "link doesn't exist") + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5L__exists() */ + +/*------------------------------------------------------------------------- + * Function: H5L__get_info_cb + * + * Purpose: Callback for retrieving a link's metadata + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: James Laird + * Monday, April 17 2006 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5L__get_info_cb(H5G_loc_t *grp_loc /*in*/, const char H5_ATTR_UNUSED *name, const H5O_link_t *lnk, + H5G_loc_t H5_ATTR_UNUSED *obj_loc, void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/) +{ + H5L_trav_gi_t *udata = (H5L_trav_gi_t *)_udata; /* User data passed in */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the name in this group resolved to a valid link */ + if (lnk == NULL) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "name doesn't exist") + + /* Get information from the link */ + if (H5G_link_to_info(grp_loc->oloc, lnk, udata->linfo) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't get link info") + +done: + /* Indicate that this callback didn't take ownership of the group * + * location for the object */ + *own_loc = H5G_OWN_NONE; + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5L__get_info_cb() */ + +/*------------------------------------------------------------------------- + * Function: H5L_get_info + * + * Purpose: Returns metadata about a link. + * + * Return: SUCCEED/FAIL + * + * Programmer: James Laird + * Monday, April 17 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5L_get_info(const H5G_loc_t *loc, const char *name, H5L_info2_t *linfo /*out*/) +{ + H5L_trav_gi_t udata; /* User data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + udata.linfo = linfo; + + /* Traverse the group hierarchy to locate the object to get info about */ + if (H5G_traverse(loc, name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L__get_info_cb, &udata) < 0) + HGOTO_ERROR(H5E_LINK, H5E_EXISTS, FAIL, "name doesn't exist") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5L_get_info() */ + +/*------------------------------------------------------------------------- + * Function: H5L__get_info_by_idx_cb + * + * Purpose: Callback for retrieving a link's metadata according to an + * index's order. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Monday, November 6 2006 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5L__get_info_by_idx_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ATTR_UNUSED *name, + const H5O_link_t H5_ATTR_UNUSED *lnk, H5G_loc_t *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/) +{ + H5L_trav_gibi_t *udata = (H5L_trav_gibi_t *)_udata; /* User data passed in */ + H5O_link_t fnd_lnk; /* Link within group */ + hbool_t lnk_copied = FALSE; /* Whether the link was copied */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the name of the group resolved to a valid object */ + if (obj_loc == NULL) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "group doesn't exist") + + /* Query link */ + if (H5G_obj_lookup_by_idx(obj_loc->oloc, udata->idx_type, udata->order, udata->n, &fnd_lnk) < 0) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "link not found") + lnk_copied = TRUE; + + /* Get information from the link */ + if (H5G_link_to_info(obj_loc->oloc, &fnd_lnk, udata->linfo) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't get link info") + +done: + /* Reset the link information, if we have a copy */ + if (lnk_copied) + H5O_msg_reset(H5O_LINK_ID, &fnd_lnk); + + /* Indicate that this callback didn't take ownership of the group * + * location for the object */ + *own_loc = H5G_OWN_NONE; + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5L__get_info_by_idx_cb() */ + +/*------------------------------------------------------------------------- + * Function: H5L__get_info_by_idx + * + * Purpose: Internal routine to retrieve link info according to an + * index's order. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5L__get_info_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, H5_iter_order_t order, + hsize_t n, H5L_info2_t *linfo /*out*/) +{ + H5L_trav_gibi_t udata; /* User data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Check arguments */ + HDassert(loc); + HDassert(name && *name); + HDassert(linfo); + + /* Set up user data for callback */ + udata.idx_type = idx_type; + udata.order = order; + udata.n = n; + udata.linfo = linfo; + + /* Traverse the group hierarchy to locate the object to get info about */ + if (H5G_traverse(loc, name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L__get_info_by_idx_cb, &udata) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to get link info") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5L__get_info_by_idx() */ + +/*------------------------------------------------------------------------- + * Function: H5L__get_name_by_idx_cb + * + * Purpose: Callback for retrieving a link's name according to an + * index's order. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Saturday, November 11 2006 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5L__get_name_by_idx_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ATTR_UNUSED *name, + const H5O_link_t H5_ATTR_UNUSED *lnk, H5G_loc_t *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/) +{ + H5L_trav_gnbi_t *udata = (H5L_trav_gnbi_t *)_udata; /* User data passed in */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the name of the group resolved to a valid object */ + if (obj_loc == NULL) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "group doesn't exist") + + /* Query link */ + if ((udata->name_len = H5G_obj_get_name_by_idx(obj_loc->oloc, udata->idx_type, udata->order, udata->n, + udata->name, udata->size)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "link not found") + +done: + /* Indicate that this callback didn't take ownership of the group * + * location for the object */ + *own_loc = H5G_OWN_NONE; + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5L__get_name_by_idx_cb() */ + +/*------------------------------------------------------------------------- + * Function: H5L__get_name_by_idx + * + * Purpose: Internal routine to retrieve link name according to an + * index's order. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +ssize_t +H5L__get_name_by_idx(const H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, + hsize_t n, char *name /*out*/, size_t size) +{ + H5L_trav_gnbi_t udata; /* User data for callback */ + ssize_t ret_value = FAIL; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Check arguments */ + HDassert(loc); + HDassert(group_name && *group_name); + + /* Set up user data for callback */ + udata.idx_type = idx_type; + udata.order = order; + udata.n = n; + udata.name = name; + udata.size = size; + udata.name_len = -1; + + /* Traverse the group hierarchy to locate the link to get name of */ + if (H5G_traverse(loc, group_name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L__get_name_by_idx_cb, &udata) < + 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't get name") + + /* Set the return value */ + ret_value = udata.name_len; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5L__get_name_by_idx() */ + +/*------------------------------------------------------------------------- + * Function: H5L__link_copy_file + * + * Purpose: Copy a link and the object it points to from one file to + * another. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Sep 29 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5L__link_copy_file(H5F_t *dst_file, const H5O_link_t *_src_lnk, const H5O_loc_t *src_oloc, + H5O_link_t *dst_lnk, H5O_copy_t *cpy_info) +{ + H5O_link_t tmp_src_lnk; /* Temporary copy of src link, when needed */ + const H5O_link_t *src_lnk = _src_lnk; /* Source link */ + hbool_t dst_lnk_init = FALSE; /* Whether the destination link is initialized */ + hbool_t expanded_link_open = FALSE; /* Whether the target location has been opened */ + H5G_loc_t tmp_src_loc; /* Group location holding target object */ + H5G_name_t tmp_src_path; /* Path for target object */ + H5O_loc_t tmp_src_oloc; /* Object location for target object */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* check arguments */ + HDassert(dst_file); + HDassert(src_lnk); + HDassert(dst_lnk); + HDassert(cpy_info); + + /* Expand soft or external link, if requested */ + if ((H5L_TYPE_SOFT == src_lnk->type && cpy_info->expand_soft_link) || + (H5L_TYPE_EXTERNAL == src_lnk->type && cpy_info->expand_ext_link)) { + H5G_loc_t lnk_grp_loc; /* Group location holding link */ + H5G_name_t lnk_grp_path; /* Path for link */ + htri_t tar_exists; /* Whether the target object exists */ + + /* Set up group location for link */ + H5G_name_reset(&lnk_grp_path); + lnk_grp_loc.path = &lnk_grp_path; + lnk_grp_loc.oloc = (H5O_loc_t *)src_oloc; /* Casting away const OK -QAK */ + + /* Check if the target object exists */ + if ((tar_exists = H5G_loc_exists(&lnk_grp_loc, src_lnk->name)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTCOPY, FAIL, "unable to check if target object exists") + + if (tar_exists) { + /* Make a temporary copy of the link, so that it will not change the + * info in the cache when we change it to a hard link */ + if (NULL == H5O_msg_copy(H5O_LINK_ID, src_lnk, &tmp_src_lnk)) + HGOTO_ERROR(H5E_LINK, H5E_CANTCOPY, FAIL, "unable to copy message") + + /* Set up group location for target object. Let H5G_traverse expand + * the link. */ + tmp_src_loc.path = &tmp_src_path; + tmp_src_loc.oloc = &tmp_src_oloc; + if (H5G_loc_reset(&tmp_src_loc) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTCOPY, FAIL, "unable to reset location") + + /* Find the target object */ + if (H5G_loc_find(&lnk_grp_loc, src_lnk->name, &tmp_src_loc) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTCOPY, FAIL, "unable to find target object") + expanded_link_open = TRUE; + + /* Convert symbolic link to hard link */ + if (tmp_src_lnk.type == H5L_TYPE_SOFT) + tmp_src_lnk.u.soft.name = (char *)H5MM_xfree(tmp_src_lnk.u.soft.name); + else if (tmp_src_lnk.u.ud.size > 0) + tmp_src_lnk.u.ud.udata = H5MM_xfree(tmp_src_lnk.u.ud.udata); + tmp_src_lnk.type = H5L_TYPE_HARD; + tmp_src_lnk.u.hard.addr = tmp_src_oloc.addr; + src_lnk = &tmp_src_lnk; + } /* end if */ + } /* end if */ + + /* Copy src link information to dst link information */ + if (NULL == H5O_msg_copy(H5O_LINK_ID, src_lnk, dst_lnk)) + HGOTO_ERROR(H5E_LINK, H5E_CANTCOPY, FAIL, "unable to copy message") + dst_lnk_init = TRUE; + + /* Check if object in source group is a hard link & copy it */ + if (H5L_TYPE_HARD == src_lnk->type) { + H5O_loc_t new_dst_oloc; /* Copied object location in destination */ + + /* Set up copied object location to fill in */ + H5O_loc_reset(&new_dst_oloc); + new_dst_oloc.file = dst_file; + + if (!expanded_link_open) { + /* Build temporary object location for source */ + H5O_loc_reset(&tmp_src_oloc); + tmp_src_oloc.file = src_oloc->file; + tmp_src_oloc.addr = src_lnk->u.hard.addr; + } /* end if */ + HDassert(H5F_addr_defined(tmp_src_oloc.addr)); + + /* Copy the shared object from source to destination */ + /* Don't care about obj_type or udata because those are only important + * for old style groups */ + if (H5O_copy_header_map(&tmp_src_oloc, &new_dst_oloc, cpy_info, TRUE, NULL, NULL) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTCOPY, FAIL, "unable to copy object") + + /* Copy new destination object's information for eventual insertion */ + dst_lnk->u.hard.addr = new_dst_oloc.addr; + } /* end if */ + +done: + /* Check if we used a temporary src link */ + if (src_lnk != _src_lnk) { + HDassert(src_lnk == &tmp_src_lnk); + H5O_msg_reset(H5O_LINK_ID, &tmp_src_lnk); + } /* end if */ + if (ret_value < 0) + if (dst_lnk_init) + H5O_msg_reset(H5O_LINK_ID, dst_lnk); + /* Check if we need to free the temp source oloc */ + if (expanded_link_open) + if (H5G_loc_free(&tmp_src_loc) < 0) + HDONE_ERROR(H5E_LINK, H5E_CANTFREE, FAIL, "unable to free object") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5L__link_copy_file() */ + +/*------------------------------------------------------------------------- + * Function: H5L_iterate + * + * Purpose: Iterates through links in a group + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5L_iterate(H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, + hsize_t *idx_p, H5L_iterate2_t op, void *op_data) +{ + H5G_link_iterate_t lnk_op; /* Link operator */ + hsize_t last_lnk; /* Index of last object looked at */ + hsize_t idx; /* Internal location to hold index */ + herr_t ret_value = FAIL; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* Sanity checks */ + HDassert(loc); + HDassert(group_name); + HDassert(op); + + /* Set up iteration beginning/end info */ + idx = (idx_p == NULL ? 0 : *idx_p); + last_lnk = 0; + + /* Build link operator info */ + lnk_op.op_type = H5G_LINK_OP_NEW; + lnk_op.op_func.op_new = op; + + /* Iterate over the links */ + if ((ret_value = H5G_iterate(loc, group_name, idx_type, order, idx, &last_lnk, &lnk_op, op_data)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link iteration failed") + + /* Set the index we stopped at */ + if (idx_p) + *idx_p = last_lnk; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5L_iterate() */ diff --git a/src/H5Lprivate.h b/src/H5Lprivate.h index 740fc1e..b114c17 100644 --- a/src/H5Lprivate.h +++ b/src/H5Lprivate.h @@ -123,6 +123,7 @@ H5_DLL herr_t H5L_iterate(H5G_loc_t *loc, const char *group_name, H5_index_t idx /* User-defined link functions */ H5_DLL herr_t H5L_register(const H5L_class_t *cls); H5_DLL herr_t H5L_unregister(H5L_type_t id); +H5_DLL herr_t H5L_is_registered(H5L_type_t id, hbool_t *is_registered); H5_DLL const H5L_class_t *H5L_find_class(H5L_type_t id); #endif /* H5Lprivate_H */ diff --git a/src/H5private.h b/src/H5private.h index 2d8d437..ae8f886 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -2666,257 +2666,26 @@ H5_DLL herr_t H5CX_pop(hbool_t update_dxpl_props); return (ret_value); \ } /*end scope from beginning of FUNC_ENTER*/ -/****************************************/ -/* Revisions to FUNC_ENTER/LEAVE Macros */ -/****************************************/ - -/* Macros to check if a package is initialized */ -#define H5_CHECK_PACKAGE_INIT_REG_YES(asrt) HDassert(H5_PACKAGE_INIT_VAR(pkg)); -#define H5_CHECK_PACKAGE_INIT_REG_NO(asrt) -#define H5_CHECK_PACKAGE_INIT_INIT_YES(asrt) -#define H5_CHECK_PACKAGE_INIT_INIT_NO(asrt) -#define H5_CHECK_PACKAGE_INIT(pkg, pkg_init, init) H5_GLUE4(H5_CHECK_PACKAGE_INIT_, init, _, pkg_init)(pkg) - -/* Macros to initialize package, if a package initialization routine is defined */ -#define H5_PKG_YES_INIT(pkg) \ - if (!H5_PACKAGE_INIT_VAR(pkg) && !H5_TERM_GLOBAL) { \ - H5_PACKAGE_INIT_VAR(pkg) = TRUE; \ - if (H5_PACKAGE_INIT_FUNC(pkg)() < 0) { \ - H5_PACKAGE_INIT_VAR(pkg) = FALSE; \ - /* (Can't use H5E_THROW here) */ \ - H5E_PRINTF(H5E_CANTINIT, "interface initialization failed"); \ - ret_value = fail_value; \ - goto func_init_failed; \ - } /* end if */ \ - } /* end if */ -#define H5_PKG_NO_INIT(pkg) \ - if (!H5_PACKAGE_INIT_VAR(pkg) && !H5_TERM_GLOBAL) \ - H5_PACKAGE_INIT_VAR(pkg) = TRUE; -#define H5_PKG_INIT(pkg_init, pkg) H5_GLUE3(H5_PKG_, pkg_init, _INIT)(pkg) - /* Macros to declare package initialization function, if a package initialization routine is defined */ #ifdef H5_PKG_SINGLE_SOURCE #define H5_PKG_DECLARE_YES_FUNC(pkg) static herr_t H5_PACKAGE_INIT_FUNC(pkg)(void); -#else /* H5_PKG_SINGLE_SOURCE */ +#else #define H5_PKG_DECLARE_YES_FUNC(pkg) extern herr_t H5_PACKAGE_INIT_FUNC(pkg)(void); -#endif /* H5_PKG_SINGLE_SOURCE */ +#endif #define H5_PKG_DECLARE_NO_FUNC(pkg) /* Declare package initialization symbols (if in a package) */ #ifdef H5_PKG_SINGLE_SOURCE #define H5_PKG_DECLARE_VAR(pkg) static hbool_t H5_PACKAGE_INIT_VAR(pkg); -#else /* H5_PKG_SINGLE_SOURCE */ +#else #define H5_PKG_DECLARE_VAR(pkg) extern hbool_t H5_PACKAGE_INIT_VAR(pkg); -#endif /* H5_PKG_SINGLE_SOURCE */ +#endif #define H5_PKG_DECLARE_FUNC(pkg_init, pkg) H5_GLUE3(H5_PKG_DECLARE_, pkg_init, _FUNC)(pkg) + #ifdef H5_MY_PKG H5_PKG_DECLARE_VAR(H5_MY_PKG) H5_PKG_DECLARE_FUNC(H5_MY_PKG_INIT, H5_MY_PKG) -#endif /* H5_MY_PKG */ - -/* API re-entrance variable */ -extern hbool_t H5_api_entered_g; /* Has library already been entered through API? */ - -/* Macros for entering different scopes of routines */ -#define H5_PACKAGE_ENTER(pkg, pkg_init, init) \ - FUNC_ENTER_CHECK_NAME(H5_IS_PKG(FUNC)) \ - \ - /* The library should be initialized already */ \ - HDassert(H5_INIT_GLOBAL); \ - \ - /* This interface should be initialized already */ \ - /* (except for package initialization routines :-) */ \ - H5_CHECK_PACKAGE_INIT(pkg, pkg_init, init) \ - \ - /* Push the name of this function on the function stack */ \ - H5_PUSH_FUNC \ - \ - /* Enter scope for this type of function */ \ - { - -#define H5_PRIVATE_ENTER(pkg, pkg_init) \ - FUNC_ENTER_CHECK_NAME(H5_IS_PRIV(FUNC)) \ - \ - /* The library should be initialized already */ \ - HDassert(H5_INIT_GLOBAL); \ - \ - /* Initialize this interface if desired */ \ - H5_PKG_INIT(pkg_init, pkg) \ - \ - /* Push the name of this function on the function stack */ \ - H5_PUSH_FUNC \ - \ - /* Enter scope for this type of function */ \ - { \ - { - -#define H5_PUBLIC_ENTER(pkg, pkg_init) \ - FUNC_ENTER_API_VARS \ - FUNC_ENTER_API_THREADSAFE; \ - FUNC_ENTER_CHECK_NAME(H5_IS_PUB(FUNC)) \ - \ - /* Clear thread error stack when entering public functions */ \ - H5E_clear_stack(NULL); \ - \ - /* Initialize the library or bust */ \ - if (!H5_INIT_GLOBAL && !H5_TERM_GLOBAL) { \ - H5_INIT_GLOBAL = TRUE; \ - if (H5_init_library() < 0) { \ - /* (Can't use H5E_THROW here) */ \ - H5E_PRINTF(H5E_CANTINIT, "interface initialization failed"); \ - ret_value = fail_value; \ - goto func_init_failed; \ - } /* end if */ \ - } /* end if */ \ - \ - /* Initialize this interface if desired */ \ - H5_PKG_INIT(pkg_init, pkg) \ - \ - /* Check for re-entering API routine */ \ - HDassert(!H5_api_entered_g); \ - H5_api_entered_g = TRUE; \ - \ - /* Start logging MPI's MPE information */ \ - BEGIN_MPE_LOG \ - \ - /* Push the name of this function on the function stack */ \ - H5_PUSH_FUNC \ - \ - /* Enter scope for this type of function */ \ - { \ - { \ - { - -/* Macros for substituting the package name */ -#define FUNC_ENT_STATIC(pkg, pkg_init) H5_PACKAGE_ENTER(pkg, pkg_init, REG) -#define FUNC_ENT_PKGINIT(pkg, pkg_init) H5_PACKAGE_ENTER(pkg, pkg_init, INIT) -#define FUNC_ENT_PKG(pkg, pkg_init) H5_PACKAGE_ENTER(pkg, pkg_init, REG) -#define FUNC_ENT_PRIV(pkg, pkg_init) H5_PRIVATE_ENTER(pkg, pkg_init) -#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_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 */ -#define BEGIN_FUNC(scope, use_err, ret_typ, ret_init, err, func) \ - H5_GLUE(FUNC_PREFIX_, scope) \ - ret_typ func \ - /* Open function */ \ - { \ - ret_typ ret_value = ret_init; \ - 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 -#define H5_PRIV_FUNC_INIT_FAILED(pkg_init) H5_GLUE3(H5_PRIV_, pkg_init, _FUNC_INIT_FAILED) - -/* Macros for leaving different scopes of routines */ -#define FUNC_LEAVE_PKGINIT \ - /* Leave scope for this type of function */ \ - } \ - \ - /* Pop the name of this function off the function stack */ \ - H5_POP_FUNC - -#define FUNC_LEAVE_STATIC \ - /* Leave scope for this type of function */ \ - } \ - \ - /* Pop the name of this function off the function stack */ \ - H5_POP_FUNC - -#define FUNC_LEAVE_PKG \ - /* Leave scope for this type of function */ \ - } \ - \ - /* Pop the name of this function off the function stack */ \ - H5_POP_FUNC - -#define FUNC_LEAVE_PRIV \ - /* Leave scope for this type of function */ \ - } \ - } \ - \ - /* Label for errors during FUNC_ENTER */ \ - H5_PRIV_FUNC_INIT_FAILED(H5_MY_PKG_INIT) \ - \ - /* Pop the name of this function off the function stack */ \ - H5_POP_FUNC - -#define FUNC_LEAVE_PUB \ - /* Leave scope for this type of function */ \ - } \ - } \ - } \ - \ - /* Label for errors during FUNC_ENTER */ \ -func_init_failed: \ - \ - /* Dump error stack if an error occurred during API routine */ \ - if (ret_value == fail_value) \ - (void)H5E_dump_api_stack(TRUE); \ - \ - /* Finish the API tracing info */ \ - H5TRACE_RETURN(ret_value); \ - \ - /* Pop the name of this function off the function stack */ \ - H5_POP_FUNC \ - \ - /* Finish the MPE tracing info */ \ - FINISH_MPE_LOG \ - \ - /* Check for leaving API routine */ \ - HDassert(H5_api_entered_g); \ - H5_api_entered_g = FALSE; \ - \ - /* Release thread-safety semaphore */ \ - FUNC_LEAVE_API_THREADSAFE - -/* Use this macro when leaving all functions */ -#define END_FUNC(scope) \ - /* Scope-specific function conclusion */ \ - H5_GLUE(FUNC_LEAVE_, scope) \ - \ - /* Leave routine */ \ - return (ret_value); \ - \ - /* 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 */ \ - } +#endif /* 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! */ diff --git a/src/Makefile.am b/src/Makefile.am index deda22b..f171c60 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -78,7 +78,7 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5lib_settings.c H5system.c \ H5HL.c H5HLcache.c H5HLdbg.c H5HLint.c H5HLprfx.c H5HLdblk.c \ H5HP.c \ H5I.c H5Idbg.c H5Iint.c H5Itest.c \ - H5L.c H5Ldeprec.c H5Lexternal.c \ + H5L.c H5Ldeprec.c H5Lexternal.c H5Lint.c \ H5M.c \ H5MF.c H5MFaggr.c H5MFdbg.c H5MFsection.c \ H5MV.c H5MVsection.c \ diff --git a/tools/lib/h5tools_error.h b/tools/lib/h5tools_error.h index 8fd33bb..5840a98 100644 --- a/tools/lib/h5tools_error.h +++ b/tools/lib/h5tools_error.h @@ -220,22 +220,22 @@ H5TOOLS_DLLVAR hid_t H5E_tools_min_dbg_id_g; /* Macro for "catching" flow of control when an error occurs. Note that the * H5_LEAVE macro won't jump back here once it's past this point. */ -/* #define CATCH catch_except:; past_catch = TRUE; defined in H5Eprivate.h */ +#define CATCH \ +catch_except:; \ + past_catch = TRUE; /* - * H5_LEAVE macro, used to facilitate control flow between a - * BEGIN_FUNC() and an END_FUNC() within a function body. The argument is - * the return value. - * The return value is assigned to a variable `ret_value' and control branches - * to the `catch_except' label, if we're not already past it. + * H5_LEAVE macro, used to facilitate control flow in a function. The argument + * is the return value. The return value is assigned to a variable `ret_value' + * and control branches to the `catch_except' label, if we're not already past + * it. */ -/* - * #define H5_LEAVE(v) { \ - * ret_value = v; \ - * if(!past_catch) \ - * goto catch_except; \ - * } - * defined in H5Eprivate.h */ +#define H5_LEAVE(v) \ + { \ + ret_value = v; \ + if (!past_catch) \ + goto catch_except; \ + } /* * H5TOOLS_THROW macro, used to facilitate error reporting within a function body. -- cgit v0.12