summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDana Robinson <43805+derobins@users.noreply.github.com>2022-03-31 07:56:29 (GMT)
committerGitHub <noreply@github.com>2022-03-31 07:56:29 (GMT)
commitbc62da7eb911727497475d1cc90991230f33fa3d (patch)
treed2bd03b84b8e97d21dbcdfaa04199c898b6ae291
parentfbb532cd633e216f47ce846493b38af02cfbb43a (diff)
downloadhdf5-bc62da7eb911727497475d1cc90991230f33fa3d.zip
hdf5-bc62da7eb911727497475d1cc90991230f33fa3d.tar.gz
hdf5-bc62da7eb911727497475d1cc90991230f33fa3d.tar.bz2
VFD SWMR: Normalization with develop and cleanup (#1559)
* Brought over plugin and test script changes * Removes remaining register keywords (#1481) * Fixed warnings in the aux process code * Minor fixes from develop * Minor changes from develop, fixed format warnings * Formatted source * Added HD prefix to timespec_get * Cleanup in new files * Removes the MANIFEST file and unused release files (#1497) * Removes the MANIFEST file and unused release files * Updated tar command * checkposix corrections * More checkposix fixes * Ripped out unused instrumentation functionality * Brought over cache tagging changes from develop * Changes to tagged metadata expulsion iteration * Fixed typo * Brought over H5O__free() changes from develop * Brings (unused) parallel page buffer test in line with develop * Moved the functionality in supervise.subr to test_vfd_swmr.sh * Tools VFD parameter updates * Committing clang-format changes * H5F VFD SWMR refactoring * Committing clang-format changes * Misc changes * Acceptance test cleanup * HD prefix * H5_get_option instead of getopt * Some bool fixes * Changes to VFD SWMR acceptance tests * Minor cleanup * Use AC_MSG_RESULT/AC_MSG_ERROR/AC_MSG_WARN instead of echo (#1532) * Merges from develop Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
-rw-r--r--config/apple67
-rw-r--r--configure.ac51
-rw-r--r--src/CMakeLists.txt27
-rw-r--r--src/H5AC.c5
-rw-r--r--src/H5ACpublic.h7
-rw-r--r--src/H5C.c3
-rw-r--r--src/H5CSprivate.h4
-rw-r--r--src/H5CXprivate.h5
-rw-r--r--src/H5Cpublic.h7
-rw-r--r--src/H5EAprivate.h5
-rw-r--r--src/H5FAprivate.h5
-rw-r--r--src/H5FDvfd_swmr.c58
-rw-r--r--src/H5FLprivate.h18
-rw-r--r--src/H5Fvfd_swmr.c6
-rw-r--r--src/H5HP.c904
-rw-r--r--src/H5HPprivate.h68
-rw-r--r--src/H5MP.c443
-rw-r--r--src/H5MPmodule.h32
-rw-r--r--src/H5MPpkg.h99
-rw-r--r--src/H5MPprivate.h57
-rw-r--r--src/H5MPtest.c213
-rw-r--r--src/H5PBprivate.h4
-rw-r--r--src/H5Spublic.h16
-rw-r--r--src/H5TSprivate.h6
-rw-r--r--src/H5module.h6
-rw-r--r--src/H5private.h6
-rw-r--r--src/Makefile.am3
-rw-r--r--test/CMakeLists.txt2
-rw-r--r--test/CMakeTests.cmake8
-rw-r--r--test/Makefile.am4
-rw-r--r--test/pool.c794
-rw-r--r--test/testhdf5.c1
-rw-r--r--test/testhdf5.h1
-rw-r--r--test/theap.c1081
-rw-r--r--test/vfd_swmr.c421
-rw-r--r--test/vfd_swmr_attrdset_writer.c400
-rw-r--r--test/vfd_swmr_bigset_writer.c103
-rw-r--r--test/vfd_swmr_common.c31
-rw-r--r--test/vfd_swmr_dsetchks_writer.c92
-rw-r--r--test/vfd_swmr_dsetops_writer.c76
-rw-r--r--test/vfd_swmr_group_writer.c1260
-rw-r--r--test/vfd_swmr_indep_rw_writer.c180
-rw-r--r--test/vfd_swmr_vlstr_reader.c80
-rw-r--r--test/vfd_swmr_vlstr_writer.c123
-rw-r--r--test/vfd_swmr_writer.c75
-rw-r--r--test/vfd_swmr_zoo_writer.c54
46 files changed, 1538 insertions, 5373 deletions
diff --git a/config/apple b/config/apple
index 98dede2..2da7e93 100644
--- a/config/apple
+++ b/config/apple
@@ -27,8 +27,14 @@ if test "X-" = "X-$CC"; then
CC_BASENAME=gcc
;;
*)
- CC=clang
- CC_BASENAME=clang
+ if test "X-$enable_parallel" = "X-yes"; then
+ # default to use mpicc which is the defacto MPI compiler name
+ CC=mpicc
+ CC_BASENAME=mpicc
+ else
+ CC=clang
+ CC_BASENAME=clang
+ fi
# Production
PROD_CFLAGS="-O3"
@@ -47,9 +53,11 @@ if test "X-" = "X-$CC"; then
esac
fi
-# Figure out compiler flags
+# Figure out C compiler flags
. $srcdir/config/gnu-flags
. $srcdir/config/clang-flags
+. $srcdir/config/intel-flags
+
# temp patch: if GCC 4.2.1 is used in Lion or Mountain Lion systems, do not
# use -O option as it causes failures in test/dt_arith.
case "$host_os" in
@@ -65,15 +73,9 @@ case "$host_os" in
esac
;;
esac
-
-. $srcdir/config/intel-flags
+
if test "X-" = "X-$FC"; then
case $CC_BASENAME in
- clang)
- # clang has no fortran compiler. Use gfortran.
- FC=gfortran
- FC_BASENAME=gfortran
- ;;
gcc*)
FC=gfortran
FC_BASENAME=gfortran
@@ -82,15 +84,26 @@ if test "X-" = "X-$FC"; then
FC=ifort
FC_BASENAME=ifort
;;
+ mpicc*)
+ FC=mpif90
+ FC_BASENAME=mpif90
+ ;;
+ clang)
+ # clang has no fortran compiler. Use gfortran.
+ FC=gfortran
+ FC_BASENAME=gfortran
+ ;;
esac
fi
+# Figure out FORTRAN compiler flags
+. $srcdir/config/gnu-fflags
+. $srcdir/config/intel-fflags
+
+
+# The default C++ compiler is `clang++'.
if test "X-" = "X-$CXX"; then
case $CC_BASENAME in
- clang)
- CXX=clang++
- CXX_BASENAME=clang++
- ;;
gcc)
CXX=g++
CXX_BASENAME=g++
@@ -99,18 +112,21 @@ if test "X-" = "X-$CXX"; then
CXX=icpc
CXX_BASENAME=icpc
;;
+ mpicc*)
+ FC=mpif90
+ FC_BASENAME=mpif90
+ ;;
+ clang)
+ CXX=clang++
+ CXX_BASENAME=clang++
+ ;;
esac
fi
-case $CXX_BASENAME in
- clang++)
- PROD_CXXFLAGS="-O3"
- DEBUG_CXXFLAGS="-g -O0"
- # Use this for profiling with gprof
- # Just "-g" for now. More later.
- PROFILE_CXXFLAGS="-g"
- ;;
-esac
+# Figure out C++ compiler flags
+. $srcdir/config/intel-cxxflags # Do this ahead of GNU to avoid icpc being detected as g++
+. $srcdir/config/gnu-cxxflags
+. $srcdir/config/clang-cxxflags
# compiler version strings
case $CC in
@@ -133,16 +149,15 @@ case $CC in
echo "No match to get cc_version_info for $CC"
;;
esac
+
# Figure out Fortran compiler flags and version strings
case $FC in
*gfortran*)
- . $srcdir/config/gnu-fflags
fc_version_info=`$FC $FCFLAGS $H5_FCFLAGS --version 2>&1 |\
grep 'GCC' | sed 's/\(.*(GCC) [-a-z0-9\. ]*\).*/\1/'`
;;
*ifc*|*ifort*)
- . $srcdir/config/intel-fflags
fc_version_info=`$FC $FCFLAGS $H5_FCFLAGS -V 2>&1 | grep 'Version' |\
sed 's/\(Intel.* Compiler\).*\( Version [a-z0-9\.]*\).*\( Build [0-9]*\)/\1\2\3/'`
;;
@@ -156,13 +171,11 @@ esac
# get c++ version info
case $CXX in
clang++)
- . $srcdir/config/clang-cxxflags
cxx_version_info=`$CXX $CXXFLAGS $H5_CXXFLAGS --version 2>&1 |\
grep 'Apple' | sed 's/(.*//'`
;;
*g++*)
- . $srcdir/config/gnu-cxxflags
cxx_version_info=`$CXX $CXXFLAGS $H5_CXXFLAGS --version 2>&1 |\
grep 'GCC' | sed 's/.*\((GCC) [-a-z0-9\. ]*.*\)/\1/'`
;;
diff --git a/configure.ac b/configure.ac
index 9b685c6..66fc225 100644
--- a/configure.ac
+++ b/configure.ac
@@ -231,9 +231,10 @@ AC_CACHE_CHECK([for cached host], [hdf5_cv_host], [hdf5_cv_host="none"]);
if test $hdf5_cv_host = "none"; then
hdf5_cv_host=$host
elif test $hdf5_cv_host != $host; then
- echo "The config.cache file was generated on $hdf5_cv_host but"
- echo "this is $host. Please remove that file and try again."
- AC_MSG_ERROR([config.cache file is invalid])
+ AC_MSG_ERROR([
+ The config.cache file was generated on $hdf5_cv_host but
+ this is $host. Please remove that file and try again.
+ config.cache file is invalid])
fi
## ----------------------------------------------------------------------
@@ -567,11 +568,7 @@ AC_ARG_ENABLE([fortran],
[Compile the Fortran interface [default=no]])],
[HDF_FORTRAN=$enableval])
-if test "X$HDF_FORTRAN" = "Xyes"; then
- echo "yes"
-else
- echo "no"
-fi
+AC_MSG_RESULT([$HDF_FORTRAN])
if test "X$HDF_FORTRAN" = "Xyes"; then
@@ -794,9 +791,9 @@ AC_ARG_ENABLE([cxx],
[AS_HELP_STRING([--enable-cxx],
[Compile the C++ interface [default=no]])],
[HDF_CXX=$enableval])
+AC_MSG_RESULT([$HDF_CXX])
if test "X$HDF_CXX" = "Xyes"; then
- echo "yes"
HDF5_INTERFACES="$HDF5_INTERFACES c++"
## Expose the compiler for *.in files
@@ -806,7 +803,6 @@ if test "X$HDF_CXX" = "Xyes"; then
AC_LANG_PUSH(C++)
else
- AC_MSG_RESULT([no])
CXX="no"
fi
@@ -1022,7 +1018,7 @@ AC_ARG_ENABLE([java],
if test "X$HDF_JAVA" = "Xyes"; then
if test "X${enable_shared}" != "Xno"; then
- echo "yes"
+ AC_MSG_RESULT([yes])
if test "X$CLASSPATH" = "X"; then
H5_CLASSPATH=".:$srcdir/java/lib"
else
@@ -1115,12 +1111,7 @@ AC_ARG_ENABLE([tests],
[Compile the HDF5 tests [default=yes]])],
[HDF5_TESTS=$enableval])
-if test "X$HDF5_TESTS" = "Xno"; then
- AC_MSG_RESULT([yes])
- echo "Building HDF5 tests is disabled"
-else
- AC_MSG_RESULT([no])
-fi
+AC_MSG_RESULT([$HDF5_TESTS])
## These need to be exposed for some tests.
AC_SUBST([H5_UTILS_TEST_BUILDDIR])
@@ -1145,12 +1136,7 @@ AC_ARG_ENABLE([tools],
[Compile the HDF5 tools [default=yes]])],
[HDF5_TOOLS=$enableval])
-if test "X$HDF5_TOOLS" = "Xno"; then
- AC_MSG_RESULT([yes])
- echo "Building HDF5 tools is disabled"
-else
- AC_MSG_RESULT([no])
-fi
+AC_MSG_RESULT([$HDF5_TOOLS])
## ----------------------------------------------------------------------
## Check if they would like to enable building doxygen files
@@ -1169,8 +1155,9 @@ AC_ARG_ENABLE([doxygen],
[Compile the HDF5 doxygen files [default=no]])],
[HDF5_DOXYGEN=$enableval])
+AC_MSG_RESULT([$HDF5_DOXYGEN])
+
if test "X$HDF5_DOXYGEN" = "Xyes"; then
- AC_MSG_RESULT([yes])
DX_DOXYGEN_FEATURE(ON)
DX_DOT_FEATURE(OFF)
DX_HTML_FEATURE(ON)
@@ -1230,10 +1217,6 @@ if test "X$HDF5_DOXYGEN" = "Xyes"; then
DOXYGEN_PREDEFINED='H5_HAVE_DIRECT H5_HAVE_LIBHDFS H5_HAVE_MAP_API H5_HAVE_PARALLEL H5_HAVE_ROS3_VFD'
DX_INIT_DOXYGEN([HDF5], [./doxygen/Doxyfile], [hdf5lib_docs])
-
-else
- AC_MSG_RESULT([no])
- echo "Doxygen support is disabled"
fi
@@ -1263,18 +1246,17 @@ AC_ARG_ENABLE([static_exec],
[Install only statically linked executables
[default=no]])],
[STATIC_EXEC=$enableval])
+AC_MSG_RESULT([$STATIC_EXEC])
if test "X$STATIC_EXEC" = "Xyes"; then
- echo "yes"
## Issue a warning if -static flag is not supported.
if test "X$lt_cv_prog_compiler_static_works" = "Xno"; then
- echo " warning: -static flag not supported on this system; executable won't statically link shared system libraries."
+ AC_MSG_WARN([-static flag not supported on this system; executable won't statically link shared system libraries.])
LT_STATIC_EXEC=""
else
LT_STATIC_EXEC="-all-static"
fi
else
- echo "no"
LT_STATIC_EXEC=""
fi
AM_CONDITIONAL([USE_PLUGINS_CONDITIONAL], [test "X$LT_STATIC_EXEC" = X])
@@ -3873,12 +3855,7 @@ AC_ARG_ENABLE([build-all],
[Build helper programs that only developers should need [default=no]])],
[BUILD_ALL=$enableval],
[BUILD_ALL=no])
-
-if test "X$BUILD_ALL" = "Xyes"; then
- echo "yes"
-else
- echo "no"
-fi
+AC_MSG_RESULT([$BUILD_ALL])
AM_CONDITIONAL([BUILD_ALL_CONDITIONAL], [test "X$BUILD_ALL" = "Xyes"])
## ----------------------------------------------------------------------
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 4ebc8bc..538655b 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -380,14 +380,6 @@ set (H5HL_HDRS
IDE_GENERATED_PROPERTIES ("H5HL" "${H5HL_HDRS}" "${H5HL_SOURCES}" )
-set (H5HP_SOURCES
- ${HDF5_SRC_DIR}/H5HP.c
-)
-set (H5HP_HDRS
-)
-IDE_GENERATED_PROPERTIES ("H5HP" "${H5HP_HDRS}" "${H5HP_SOURCES}" )
-
-
set (H5I_SOURCES
${HDF5_SRC_DIR}/H5I.c
${HDF5_SRC_DIR}/H5Idbg.c
@@ -444,15 +436,6 @@ set (H5MM_HDRS
IDE_GENERATED_PROPERTIES ("H5MM" "${H5MM_HDRS}" "${H5MM_SOURCES}" )
-set (H5MP_SOURCES
- ${HDF5_SRC_DIR}/H5MP.c
- ${HDF5_SRC_DIR}/H5MPtest.c
-)
-
-set (H5MP_HDRS
-)
-IDE_GENERATED_PROPERTIES ("H5MP" "${H5MP_HDRS}" "${H5MP_SOURCES}" )
-
set (H5MV_SOURCES
${HDF5_SRC_DIR}/H5MV.c
${HDF5_SRC_DIR}/H5MVsection.c
@@ -461,6 +444,7 @@ set (H5MV_HDRS
)
IDE_GENERATED_PROPERTIES ("H5MV" "${H5MV_HDRS}" "${H5MV_SOURCES}" )
+
set (H5O_SOURCES
${HDF5_SRC_DIR}/H5O.c
${HDF5_SRC_DIR}/H5Oainfo.c
@@ -759,7 +743,6 @@ set (H5_MODULE_HEADERS
${HDF5_SRC_DIR}/H5Lmodule.h
${HDF5_SRC_DIR}/H5Mmodule.h
${HDF5_SRC_DIR}/H5MFmodule.h
- ${HDF5_SRC_DIR}/H5MPmodule.h
${HDF5_SRC_DIR}/H5Omodule.h
${HDF5_SRC_DIR}/H5Pmodule.h
${HDF5_SRC_DIR}/H5PBmodule.h
@@ -797,13 +780,11 @@ set (common_SRCS
${H5HF_SOURCES}
${H5HG_SOURCES}
${H5HL_SOURCES}
- ${H5HP_SOURCES}
${H5I_SOURCES}
${H5L_SOURCES}
${H5M_SOURCES}
${H5MF_SOURCES}
${H5MM_SOURCES}
- ${H5MP_SOURCES}
${H5MV_SOURCES}
${H5O_SOURCES}
${H5P_SOURCES}
@@ -847,7 +828,6 @@ set (H5_PUBLIC_HEADERS
${H5M_HDRS}
${H5MF_HDRS}
${H5MM_HDRS}
- ${H5MP_HDRS}
${H5MV_HDRS}
${H5O_HDRS}
${H5P_HDRS}
@@ -931,8 +911,6 @@ set (H5_PRIVATE_HEADERS
${HDF5_SRC_DIR}/H5HLpkg.h
${HDF5_SRC_DIR}/H5HLprivate.h
- ${HDF5_SRC_DIR}/H5HPprivate.h
-
${HDF5_SRC_DIR}/H5Ipkg.h
${HDF5_SRC_DIR}/H5Iprivate.h
@@ -947,9 +925,6 @@ set (H5_PRIVATE_HEADERS
${HDF5_SRC_DIR}/H5MMprivate.h
- ${HDF5_SRC_DIR}/H5MPpkg.h
- ${HDF5_SRC_DIR}/H5MPprivate.h
-
${HDF5_SRC_DIR}/H5MVpkg.h
${HDF5_SRC_DIR}/H5MVprivate.h
diff --git a/src/H5AC.c b/src/H5AC.c
index 0e94791..0171956 100644
--- a/src/H5AC.c
+++ b/src/H5AC.c
@@ -2508,7 +2508,7 @@ H5AC_expunge_all_tagged_metadata(H5F_t *f, haddr_t tag, int type_id, unsigned fl
HDassert(f);
HDassert(f->shared);
- /* Call cache level function to expunge all tagged entries */
+ /* Call cache-level function to expunge all tagged entries */
if (H5C_expunge_all_tagged_metadata(f, tag, type_id, flags) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Cannot expunge all entries")
@@ -2856,7 +2856,8 @@ done:
*
* Return: SUCCEED on success, and FAIL on failure.
*
- * Programmer: Vailin Choi; Dec 2021
+ * Programmer: Vailin Choi
+ * Dec 2021
*
*-------------------------------------------------------------------------
*/
diff --git a/src/H5ACpublic.h b/src/H5ACpublic.h
index c853794..42bc090 100644
--- a/src/H5ACpublic.h
+++ b/src/H5ACpublic.h
@@ -28,10 +28,6 @@
#include "H5public.h"
#include "H5Cpublic.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/****************************************************************************
*
* structure H5AC_cache_config_t
@@ -783,7 +779,4 @@ typedef struct H5AC_cache_image_config_t {
//! <!-- [H5AC_cache_image_config_t_snip] -->
-#ifdef __cplusplus
-}
-#endif
#endif
diff --git a/src/H5C.c b/src/H5C.c
index 2370bbf..8052b3d 100644
--- a/src/H5C.c
+++ b/src/H5C.c
@@ -3495,7 +3495,6 @@ H5C_set_vfd_swmr_reader(H5C_t *cache_ptr, hbool_t vfd_swmr_reader, hsize_t page_
FUNC_ENTER_NOAPI(FAIL)
if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC))
-
HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr on entry")
cache_ptr->vfd_swmr_reader = vfd_swmr_reader;
@@ -7653,7 +7652,7 @@ H5C__load_entry(H5F_t *f,
h5_retry_t retry;
/*
- * This do/while loop performs the following till the metadata checksum
+ * This for loop performs the following till the metadata checksum
* is correct or the file's number of allowed read attempts are reached.
* --read the metadata
* --determine the actual size of the metadata
diff --git a/src/H5CSprivate.h b/src/H5CSprivate.h
index a238ec7..2dc28f5 100644
--- a/src/H5CSprivate.h
+++ b/src/H5CSprivate.h
@@ -17,10 +17,6 @@
#ifndef H5CSprivate_H
#define H5CSprivate_H
-#ifdef NOT_YET
-#include "H5CSpublic.h"
-#endif /* NOT_YET */
-
/* Private headers needed by this file */
#include "H5private.h"
diff --git a/src/H5CXprivate.h b/src/H5CXprivate.h
index 8ec1c59..878bcf6 100644
--- a/src/H5CXprivate.h
+++ b/src/H5CXprivate.h
@@ -16,11 +16,6 @@
#ifndef H5CXprivate_H
#define H5CXprivate_H
-/* Include package's public header */
-#ifdef NOT_YET
-#include "H5CXpublic.h"
-#endif /* NOT_YET */
-
/* Private headers needed by this file */
#include "H5private.h" /* Generic Functions */
#include "H5ACprivate.h" /* Metadata cache */
diff --git a/src/H5Cpublic.h b/src/H5Cpublic.h
index 79ece10..c65dc7c 100644
--- a/src/H5Cpublic.h
+++ b/src/H5Cpublic.h
@@ -27,10 +27,6 @@
/* Public headers needed by this file */
#include "H5public.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
enum H5C_cache_incr_mode {
H5C_incr__off,
/**<Automatic cache size increase is disabled, and the remaining increment fields are ignored.*/
@@ -61,7 +57,4 @@ enum H5C_cache_decr_mode {
/**<Automatic cache size decrease is enabled using the ageout with hit rate threshold algorithm.*/
};
-#ifdef __cplusplus
-}
-#endif
#endif
diff --git a/src/H5EAprivate.h b/src/H5EAprivate.h
index 19dabd9..9481559f 100644
--- a/src/H5EAprivate.h
+++ b/src/H5EAprivate.h
@@ -26,11 +26,6 @@
#ifndef H5EAprivate_H
#define H5EAprivate_H
-/* Include package's public header */
-#ifdef NOT_YET
-#include "H5EApublic.h"
-#endif /* NOT_YET */
-
/* Private headers needed by this file */
#include "H5ACprivate.h" /* Metadata cache */
#include "H5Fprivate.h" /* File access */
diff --git a/src/H5FAprivate.h b/src/H5FAprivate.h
index 59d3652..745c129 100644
--- a/src/H5FAprivate.h
+++ b/src/H5FAprivate.h
@@ -24,11 +24,6 @@
#ifndef H5FAprivate_H
#define H5FAprivate_H
-/* Include package's public header */
-#ifdef NOT_YET
-#include "H5FApublic.h"
-#endif /* NOT_YET */
-
/* Private headers needed by this file */
#include "H5ACprivate.h" /* Metadata cache */
#include "H5Fprivate.h" /* File access */
diff --git a/src/H5FDvfd_swmr.c b/src/H5FDvfd_swmr.c
index cd1a02e..c79a357 100644
--- a/src/H5FDvfd_swmr.c
+++ b/src/H5FDvfd_swmr.c
@@ -142,9 +142,6 @@ H5FL_SEQ_DEFINE(H5FD_vfd_swmr_idx_entry_t);
* Return: Success: The driver ID for the VFD SWMR driver.
* Failure: Negative
*
- * Programmer: Robb Matzke
- * Thursday, July 29, 1999
- *
*-------------------------------------------------------------------------
*/
hid_t
@@ -170,9 +167,6 @@ H5FD_vfd_swmr_init(void)
*
* Returns: SUCCEED (Can't fail)
*
- * Programmer: Quincey Koziol
- * Friday, Jan 30, 2004
- *
*---------------------------------------------------------------------------
*/
static herr_t
@@ -214,9 +208,16 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Pset_fapl_vfd_swmr() */
-/* Perform the reader-only aspects of opening in VFD SWMR mode:
- * initialize histogram of ticks spent in API calls, wait for the
- * shadow file to appear, load the header and index.
+/*-------------------------------------------------------------------------
+ * Function: H5FD__swmr_reader_open
+ *
+ * Purpose: Perform the reader-only aspects of opening in VFD SWMR mode:
+ * initialize histogram of ticks spent in API calls, wait for
+ * the shadow file to appear, load the header and index.
+ *
+ * Return: SUCCEED/FAIL
+ *
+ *-------------------------------------------------------------------------
*/
static herr_t
H5FD__swmr_reader_open(H5FD_vfd_swmr_t *file)
@@ -351,24 +352,38 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FD__vfd_swmr_open() */
-/* Perform the reader-only aspects of closing in VFD SWMR mode: optionally
- * log and always release the histogram of ticks spent in API calls,
- * close the shadow file, release the shadow index.
+/*-------------------------------------------------------------------------
+ * Function: H5FD__swmr_reader_close
+ *
+ * Purpose: Perform the reader-only aspects of closing in VFD SWMR mode:
+ * optionally log and always release the histogram of ticks spent
+ * in API calls, close the shadow file, release the shadow index.
+ *
+ * Return: void
+ *
+ *-------------------------------------------------------------------------
*/
-static void
+static herr_t
H5FD__swmr_reader_close(H5FD_vfd_swmr_t *file)
{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_STATIC
+
if (file->api_elapsed_ticks != NULL)
H5MM_xfree(file->api_elapsed_ticks);
/* Close the metadata file */
if (file->md_fd >= 0 && HDclose(file->md_fd) < 0)
/* Push error, but keep going */
- HERROR(H5E_VFL, H5E_CANTCLOSEFILE, "unable to close the metadata file");
+ HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, "unable to close the metadata file");
/* Free the index entries */
if (file->md_index.num_entries && file->md_index.entries)
file->md_index.entries = H5FL_SEQ_FREE(H5FD_vfd_swmr_idx_entry_t, file->md_index.entries);
+
+ FUNC_LEAVE_NOAPI(ret_value)
+
} /* end H5FD__swmr_reader_close() */
/*-------------------------------------------------------------------------
@@ -1188,7 +1203,7 @@ done:
} /* H5FD__vfd_swmr_header_deserialize() */
-/*
+/*-------------------------------------------------------------------------
* Function: H5FD__vfd_swmr_index_deserialize()
*
* Purpose: Load and decode the index in the metadata file
@@ -1199,10 +1214,8 @@ done:
* --Decode the index entries if the tick number in the header and
* the index match
*
- * Return: Success: TRUE
- * Failure: FAIL
- * Retry: FALSE
- *
+ * Return: TRUE/FALSE/FAIL
+ *-------------------------------------------------------------------------
*/
static htri_t
H5FD__vfd_swmr_index_deserialize(const H5FD_vfd_swmr_t *file, H5FD_vfd_swmr_md_index *md_index,
@@ -1342,8 +1355,7 @@ done:
* --Return tick_num, num_entries and index from the VFD's
* local copies.
*
- * Return: Success: SUCCEED
- * Failure: FAIL
+ * Return: SUCCEED/FAIL
*
* Programmer: Vailin Choi
*
@@ -1392,8 +1404,7 @@ done:
* Purpose: Dump a variety of information about the vfd swmr reader
* vfd to stderr for debugging purposes.
*
- * Return: Success: SUCCEED
- * Failure: FAIL
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
@@ -1476,7 +1487,6 @@ H5FD_vfd_swmr_set_pb_configured(H5FD_t *_file)
* Programmer: JRM -- 1/29/19
*
*-------------------------------------------------------------------------
- *
*/
void
H5FD_vfd_swmr_record_elapsed_ticks(H5FD_t *_file, uint64_t elapsed)
diff --git a/src/H5FLprivate.h b/src/H5FLprivate.h
index 6519551..8e9d0d4 100644
--- a/src/H5FLprivate.h
+++ b/src/H5FLprivate.h
@@ -50,6 +50,11 @@
*/
/* #define H5FL_TRACK */
#ifdef H5FL_TRACK
+
+#ifndef H5_HAVE_CODESTACK
+#error "Free list tracking requires code stack to be enabled"
+#endif
+
/* Macro for inclusion in the free list allocation calls */
#define H5FL_TRACK_INFO , __FILE__, __func__, __LINE__
@@ -273,16 +278,17 @@ typedef struct H5FL_arr_head_t {
#define H5FL_BARR_DEFINE_STATIC(b, t, m) static H5FL_ARR_DEFINE_COMMON(sizeof(b), t, m)
/* Allocate an array of type 't' */
-#define H5FL_ARR_MALLOC(t, elem) H5FL_arr_malloc(&(H5FL_ARR_NAME(t)), elem)
+#define H5FL_ARR_MALLOC(t, elem) H5FL_arr_malloc(&(H5FL_ARR_NAME(t)), elem H5FL_TRACK_INFO)
/* Allocate an array of type 't' and clear it to all zeros */
-#define H5FL_ARR_CALLOC(t, elem) H5FL_arr_calloc(&(H5FL_ARR_NAME(t)), elem)
+#define H5FL_ARR_CALLOC(t, elem) H5FL_arr_calloc(&(H5FL_ARR_NAME(t)), elem H5FL_TRACK_INFO)
/* Free an array of type 't' */
#define H5FL_ARR_FREE(t, obj) (t *)H5FL_arr_free(&(H5FL_ARR_NAME(t)), obj)
/* Re-allocate an array of type 't' */
-#define H5FL_ARR_REALLOC(t, obj, new_elem) H5FL_arr_realloc(&(H5FL_ARR_NAME(t)), obj, new_elem)
+#define H5FL_ARR_REALLOC(t, obj, new_elem) \
+ H5FL_arr_realloc(&(H5FL_ARR_NAME(t)), obj, new_elem H5FL_TRACK_INFO)
#else /* H5_NO_ARR_FREE_LISTS */
/* Common macro for H5FL_ARR_DEFINE & H5FL_ARR_DEFINE_STATIC (and H5FL_BARR variants) */
@@ -405,10 +411,10 @@ H5_DLL void *H5FL_reg_calloc(H5FL_reg_head_t *head H5FL_TRACK_PARAMS);
H5_DLL void *H5FL_reg_free(H5FL_reg_head_t *head, void *obj);
/* Array free lists */
-H5_DLL void *H5FL_arr_malloc(H5FL_arr_head_t *head, size_t elem);
-H5_DLL void *H5FL_arr_calloc(H5FL_arr_head_t *head, size_t elem);
+H5_DLL void *H5FL_arr_malloc(H5FL_arr_head_t *head, size_t elem H5FL_TRACK_PARAMS);
+H5_DLL void *H5FL_arr_calloc(H5FL_arr_head_t *head, size_t elem H5FL_TRACK_PARAMS);
H5_DLL void *H5FL_arr_free(H5FL_arr_head_t *head, void *obj);
-H5_DLL void *H5FL_arr_realloc(H5FL_arr_head_t *head, void *obj, size_t new_elem);
+H5_DLL void *H5FL_arr_realloc(H5FL_arr_head_t *head, void *obj, size_t new_elem H5FL_TRACK_PARAMS);
/* Sequence free lists */
H5_DLL void *H5FL_seq_malloc(H5FL_seq_head_t *head, size_t elem H5FL_TRACK_PARAMS);
diff --git a/src/H5Fvfd_swmr.c b/src/H5Fvfd_swmr.c
index 84beefc..64cc378 100644
--- a/src/H5Fvfd_swmr.c
+++ b/src/H5Fvfd_swmr.c
@@ -157,8 +157,7 @@ H5FL_DEFINE(eot_queue_entry_t);
* --set f->shared->tick_num to the current tick read from the
* metadata file
*
- * Return: Success: SUCCEED
- * Failure: FAIL
+ * Return: SUCCEED/FAIL
*-------------------------------------------------------------------------
*/
herr_t
@@ -298,8 +297,7 @@ done:
* --start a new tick (??check with JM for sure)
* ??update end_of_tick
*
- * Return: Success: SUCCEED
- * Failure: FAIL
+ * Return: SUCCEED/FAIL
*-------------------------------------------------------------------------
*/
herr_t
diff --git a/src/H5HP.c b/src/H5HP.c
deleted file mode 100644
index d164223..0000000
--- a/src/H5HP.c
+++ /dev/null
@@ -1,904 +0,0 @@
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * 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. *
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
-/*
- * Purpose: Provides a heap abstract data type.
- *
- * (See chapter 11 - "Priority Queues" of _Algorithms_, by
- * Sedgewick for additional information)
- *
- */
-
-/* Private headers needed */
-#include "H5private.h" /* Generic Functions */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5HPprivate.h" /* Heap routines */
-#include "H5FLprivate.h" /* Memory management functions */
-
-/* Local Macros */
-#define H5HP_START_SIZE 16 /* Initial number of entries for heaps */
-
-/* Private typedefs & structs */
-
-/* Data structure for entries in the internal heap array */
-typedef struct {
- int val; /* Value to be used for heap condition */
- H5HP_info_t *obj; /* Pointer to object stored in heap */
-} H5HP_ent_t;
-
-/* Main heap data structure */
-struct H5HP_t {
- H5HP_type_t type; /* Type of heap (minimum or maximum value at "top") */
- size_t nobjs; /* Number of active objects in heap array */
- size_t nalloc; /* Number of allocated locations in heap array */
- H5HP_ent_t *heap; /* Pointer to array containing heap entries */
-};
-
-/* Static functions */
-static herr_t H5HP__swim_max(H5HP_t *heap, size_t loc);
-static herr_t H5HP__swim_min(H5HP_t *heap, size_t loc);
-static herr_t H5HP__sink_max(H5HP_t *heap, size_t loc);
-static herr_t H5HP__sink_min(H5HP_t *heap, size_t loc);
-
-/* Declare a free list to manage the H5HP_t struct */
-H5FL_DEFINE_STATIC(H5HP_t);
-
-/* Declare a free list to manage sequences of H5HP_ent_t */
-H5FL_SEQ_DEFINE_STATIC(H5HP_ent_t);
-
-/*--------------------------------------------------------------------------
- NAME
- H5HP__swim_max
- PURPOSE
- Restore heap condition by moving an object upward
- USAGE
- herr_t H5HP__swim_max(heap, loc)
- H5HP_t *heap; IN/OUT: Pointer to heap to modify
- size_t loc; IN: Location to start from
-
- RETURNS
- Returns non-negative on success, negative on failure.
- DESCRIPTION
- Restore the heap condition for the heap's array by "swimming" the object
- at a location upward.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- This routine is for "maximum" value heaps.
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-static herr_t
-H5HP__swim_max(H5HP_t *heap, size_t loc)
-{
- int val; /* Temporary copy value of object to move in heap */
- H5HP_info_t *obj; /* Temporary pointer to object to move in heap */
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_STATIC_NOERR
-
- /* Get copies of the information about the object to move in the heap */
- val = heap->heap[loc].val;
- obj = heap->heap[loc].obj;
-
- /* Move object up in heap until it's reached the maximum location possible */
- while (heap->heap[loc / 2].val < val) {
- /* Move object "above" current location in heap down */
- heap->heap[loc].val = heap->heap[loc / 2].val;
- heap->heap[loc].obj = heap->heap[loc / 2].obj;
-
- /* Update heap location for object which moved */
- heap->heap[loc].obj->heap_loc = loc;
-
- /* Move to location "above" current location */
- loc = loc / 2;
- } /* end while */
-
- /* Put object into heap at correct location */
- heap->heap[loc].val = val;
- heap->heap[loc].obj = obj;
-
- /* Update heap location for object */
- heap->heap[loc].obj->heap_loc = loc;
-
- FUNC_LEAVE_NOAPI(ret_value);
-} /* end H5HP__swim_max() */
-
-/*--------------------------------------------------------------------------
- NAME
- H5HP__swim_min
- PURPOSE
- Restore heap condition by moving an object upward
- USAGE
- herr_t H5HP__swim_min(heap, loc)
- H5HP_t *heap; IN/OUT: Pointer to heap to modify
- size_t loc; IN: Location to start from
-
- RETURNS
- Returns non-negative on success, negative on failure.
- DESCRIPTION
- Restore the heap condition for the heap's array by "swimming" the object
- at a location upward.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- This routine is for "minimum" value heaps.
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-static herr_t
-H5HP__swim_min(H5HP_t *heap, size_t loc)
-{
- int val; /* Temporary copy value of object to move in heap */
- H5HP_info_t *obj; /* Temporary pointer to object to move in heap */
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_STATIC_NOERR
-
- /* Get copies of the information about the object to move in the heap */
- val = heap->heap[loc].val;
- obj = heap->heap[loc].obj;
-
- /* Move object up in heap until it's reached the minimum location possible */
- while (heap->heap[loc / 2].val > val) {
- /* Move object "above" current location in heap down */
- heap->heap[loc].val = heap->heap[loc / 2].val;
- heap->heap[loc].obj = heap->heap[loc / 2].obj;
-
- /* Update heap location for object which moved */
- heap->heap[loc].obj->heap_loc = loc;
-
- /* Move to location "above" current location */
- loc = loc / 2;
- } /* end while */
-
- /* Put object into heap at correct location */
- heap->heap[loc].val = val;
- heap->heap[loc].obj = obj;
-
- /* Update heap location for object */
- heap->heap[loc].obj->heap_loc = loc;
-
- FUNC_LEAVE_NOAPI(ret_value);
-} /* end H5HP__swim_min() */
-
-/*--------------------------------------------------------------------------
- NAME
- H5HP__sink_max
- PURPOSE
- Restore heap condition by moving an object downward
- USAGE
- herr_t H5HP__sink_max(heap, loc)
- H5HP_t *heap; IN/OUT: Pointer to heap to modify
- size_t loc; IN: Location to start from
-
- RETURNS
- Returns non-negative on success, negative on failure.
- DESCRIPTION
- Restore the heap condition for the heap's array by "sinking" the object
- at a location downward.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- This routine is for "maximum" value heaps.
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-static herr_t
-H5HP__sink_max(H5HP_t *heap, size_t loc)
-{
- int val; /* Temporary copy value of object to move in heap */
- void * obj; /* Temporary pointer to object to move in heap */
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_STATIC_NOERR
-
- /* Get copies of the information about the object to move in the heap */
- val = heap->heap[loc].val;
- obj = heap->heap[loc].obj;
-
- /* Move object up in heap until it's reached the maximum location possible */
- while ((2 * loc) <= heap->nobjs) {
- size_t new_loc = loc * 2; /* New object's potential location area */
-
- /* Get the greater of the two objects below the location in heap */
- if (new_loc < heap->nobjs && (heap->heap[new_loc].val < heap->heap[new_loc + 1].val))
- new_loc++;
-
- /* Check if the object is smaller than the larger of the objects below it */
- /* If so, its in the correct location now, and we can get out */
- if (val >= heap->heap[new_loc].val)
- break;
-
- /* Move the greater of the two objects below the current location up */
- heap->heap[loc].val = heap->heap[new_loc].val;
- heap->heap[loc].obj = heap->heap[new_loc].obj;
-
- /* Update heap location for object which moved */
- heap->heap[loc].obj->heap_loc = loc;
-
- /* Move to location "below" current location */
- loc = new_loc;
- } /* end while */
-
- /* Put object into heap at correct location */
- heap->heap[loc].val = val;
- heap->heap[loc].obj = (H5HP_info_t *)obj;
-
- /* Update heap location for object */
- heap->heap[loc].obj->heap_loc = loc;
-
- FUNC_LEAVE_NOAPI(ret_value);
-} /* end H5HP__sink_max() */
-
-/*--------------------------------------------------------------------------
- NAME
- H5HP__sink_min
- PURPOSE
- Restore heap condition by moving an object downward
- USAGE
- herr_t H5HP__sink_min(heap, loc)
- H5HP_t *heap; IN/OUT: Pointer to heap to modify
- size_t loc; IN: Location to start from
-
- RETURNS
- Returns non-negative on success, negative on failure.
- DESCRIPTION
- Restore the heap condition for the heap's array by "sinking" the object
- at a location downward.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- This routine is for "minimum" value heaps.
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-static herr_t
-H5HP__sink_min(H5HP_t *heap, size_t loc)
-{
- int val; /* Temporary copy value of object to move in heap */
- void * obj; /* Temporary pointer to object to move in heap */
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_STATIC_NOERR
-
- /* Get copies of the information about the object to move in the heap */
- val = heap->heap[loc].val;
- obj = heap->heap[loc].obj;
-
- /* Move object up in heap until it's reached the maximum location possible */
- while ((2 * loc) <= heap->nobjs) {
- size_t new_loc = loc * 2; /* New object's potential location area */
-
- /* Get the lesser of the two objects below the location in heap */
- if (new_loc < heap->nobjs && (heap->heap[new_loc].val > heap->heap[new_loc + 1].val))
- new_loc++;
-
- /* Check if the object is greater than the larger of the objects below it */
- /* If so, its in the correct location now, and we can get out */
- if (val <= heap->heap[new_loc].val)
- break;
-
- /* Move the greater of the two objects below the current location up */
- heap->heap[loc].val = heap->heap[new_loc].val;
- heap->heap[loc].obj = heap->heap[new_loc].obj;
-
- /* Update heap location for object which moved */
- heap->heap[loc].obj->heap_loc = loc;
-
- /* Move to location "below" current location */
- loc = new_loc;
- } /* end while */
-
- /* Put object into heap at correct location */
- heap->heap[loc].val = val;
- heap->heap[loc].obj = (H5HP_info_t *)obj;
-
- /* Update heap location for object */
- heap->heap[loc].obj->heap_loc = loc;
-
- FUNC_LEAVE_NOAPI(ret_value);
-} /* end H5HP__sink_min() */
-
-/*--------------------------------------------------------------------------
- NAME
- H5HP_create
- PURPOSE
- Create a heap
- USAGE
- H5HP_t *H5HP_create(heap_type)
- H5HP_type_t heap_type; IN: Type of heap to create
-
- RETURNS
- Returns a pointer to a heap on success, NULL on failure.
- DESCRIPTION
- Create a priority queue. The SIZE is used to set the initial number of
- entries allocated.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-H5HP_t *
-H5HP_create(H5HP_type_t heap_type)
-{
- H5HP_t *new_heap = NULL; /* Pointer to new heap object created */
- H5HP_t *ret_value; /* Return value */
-
- FUNC_ENTER_NOAPI(NULL)
-
- /* Check args */
- HDassert(heap_type == H5HP_MIN_HEAP || heap_type == H5HP_MAX_HEAP);
-
- /* Allocate ref-counted string structure */
- if ((new_heap = H5FL_MALLOC(H5HP_t)) == NULL)
- HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, NULL, "memory allocation failed");
-
- /* Allocate the array to store the heap entries */
- if ((new_heap->heap = H5FL_SEQ_MALLOC(H5HP_ent_t, (size_t)(H5HP_START_SIZE + 1))) == NULL)
- HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, NULL, "memory allocation failed");
-
- /* Set the internal fields */
- new_heap->type = heap_type;
- new_heap->nobjs = 0;
- new_heap->nalloc = H5HP_START_SIZE + 1;
-
- /* Set the information in the 0'th location based on the type of heap */
- if (heap_type == H5HP_MIN_HEAP) {
- /* Set the value in the '0' location to be the minimum value, to
- * simplify the algorithms
- */
- new_heap->heap[0].val = INT_MIN;
- new_heap->heap[0].obj = NULL;
- } /* end if */
- else {
- /* Set the value in the '0' location to be the maximum value, to
- * simplify the algorithms
- */
- new_heap->heap[0].val = INT_MAX;
- new_heap->heap[0].obj = NULL;
- } /* end else */
-
- /* Set the return value */
- ret_value = new_heap;
-
-done:
- /* Error cleanup */
- if (NULL == ret_value) {
- if (NULL != new_heap) {
- if (NULL != new_heap->heap)
- new_heap->heap = H5FL_SEQ_FREE(H5HP_ent_t, new_heap->heap);
- new_heap = H5FL_FREE(H5HP_t, new_heap);
- } /* end if */
- } /* end if */
-
- FUNC_LEAVE_NOAPI(ret_value);
-} /* end H5HP_create() */
-
-/*--------------------------------------------------------------------------
- NAME
- H5HP_count
- PURPOSE
- Check the number of elements in a heap
- USAGE
- ssize_t H5HP_count(heap)
- const H5HP_t *heap; IN: Pointer to heap to query
-
- RETURNS
- Returns non-negative on success, negative on failure.
- DESCRIPTION
- Checks the number of elements in heap
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-ssize_t
-H5HP_count(const H5HP_t *heap)
-{
- ssize_t ret_value; /* Return value */
-
- FUNC_ENTER_NOAPI_NOINIT_NOERR
-
- /* Check args */
- HDassert(heap);
-
- /* Check internal consistency */
- /* (Pre-condition) */
- HDassert(heap->nobjs < heap->nalloc);
- HDassert(heap->heap);
- HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) ||
- (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN));
- HDassert(heap->heap[0].obj == NULL);
-
- /* Return the number of objects in the heap */
- H5_CHECK_OVERFLOW(heap->nobjs, size_t, ssize_t);
- ret_value = (ssize_t)heap->nobjs;
-
- /* No post-condition check necessary, since heap is constant */
- FUNC_LEAVE_NOAPI(ret_value);
-} /* end H5HP_count() */
-
-/*--------------------------------------------------------------------------
- NAME
- H5HP_insert
- PURPOSE
- Insert an object into a heap, with an initial value
- USAGE
- herr_t H5HP_insert(heap, val, obj)
- H5HP_t *heap; IN/OUT: Pointer to heap to modify
- int val; IN: Initial value for object in heap
- void *obj; IN: Pointer to object to insert into heap
-
- RETURNS
- Returns non-negative on success, negative on failure.
- DESCRIPTION
- Inserts a OBJ into a HEAP, with an initial VALue.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-herr_t
-H5HP_insert(H5HP_t *heap, int val, void *obj)
-{
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(FAIL)
-
- /* Check args */
- HDassert(heap);
- HDassert(obj);
-
- /* Check internal consistency */
- /* (Pre-condition) */
- HDassert(heap->nobjs < heap->nalloc);
- HDassert(heap->heap);
- HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) ||
- (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN));
- HDassert(heap->heap[0].obj == NULL);
-
- /* Increment number of objects in heap */
- heap->nobjs++;
-
- /* Check if we need to allocate more room for heap array */
- if (heap->nobjs >= heap->nalloc) {
- size_t n = MAX(H5HP_START_SIZE, 2 * (heap->nalloc - 1)) + 1;
- H5HP_ent_t *new_heap = H5FL_SEQ_REALLOC(H5HP_ent_t, heap->heap, n);
-
- if (!new_heap)
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to extend heap array");
- heap->heap = new_heap;
- heap->nalloc = n;
- } /* end if */
-
- /* Insert new object at end of heap */
- heap->heap[heap->nobjs].val = val;
- heap->heap[heap->nobjs].obj = (H5HP_info_t *)obj;
- heap->heap[heap->nobjs].obj->heap_loc = heap->nobjs;
-
- /* Restore heap condition */
- if (heap->type == H5HP_MAX_HEAP) {
- if (H5HP__swim_max(heap, heap->nobjs) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTINSERT, FAIL, "unable to restore heap condition");
- } /* end if */
- else {
- if (H5HP__swim_min(heap, heap->nobjs) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTINSERT, FAIL, "unable to restore heap condition");
- } /* end else */
-
-done:
-
- /* Check internal consistency */
- /* (Post-condition) */
- HDassert(heap->nobjs < heap->nalloc);
- HDassert(heap->heap);
- HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) ||
- (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN));
- HDassert(heap->heap[0].obj == NULL);
-
- FUNC_LEAVE_NOAPI(ret_value);
-} /* end H5HP_insert() */
-
-/*--------------------------------------------------------------------------
- NAME
- H5HP_top
- PURPOSE
- Check the value of the top object in the heap
- USAGE
- herr_t H5HP_top(heap, val)
- const H5HP_t *heap; IN: Pointer to heap to modify
- int val; IN/OUT: Initial value for object in heap
-
- RETURNS
- Returns non-negative on success, negative on failure.
- DESCRIPTION
- Checks the value of the top object in a heap
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-herr_t
-H5HP_top(const H5HP_t *heap, int *val)
-{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
-
- /* Check args */
- HDassert(heap);
- HDassert(val);
-
- /* Check internal consistency */
- /* (Pre-condition) */
- HDassert(heap->nobjs < heap->nalloc);
- HDassert(heap->heap);
- HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) ||
- (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN));
- HDassert(heap->heap[0].obj == NULL);
-
- /* Get value of the top object in the heap */
- *val = heap->heap[1].val;
-
- /* No post-condition check necessary, since heap is constant */
- FUNC_LEAVE_NOAPI(SUCCEED);
-} /* end H5HP_top() */
-
-/*--------------------------------------------------------------------------
- NAME
- H5HP_remove
- PURPOSE
- Remove an object into a heap
- USAGE
- herr_t H5HP_remove(heap, val, obj)
- H5HP_t *heap; IN/OUT: Pointer to heap to modify
- int *val; OUT: Pointer to value of object removed from heap
- void **obj; OUT: Pointer to object removed from heap
-
- RETURNS
- Returns non-negative on success, negative on failure.
- DESCRIPTION
- Removes the top object on a heap, returning its value and object pointer
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-herr_t
-H5HP_remove(H5HP_t *heap, int *val, void **obj)
-{
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(FAIL)
-
- /* Check args */
- HDassert(heap);
- HDassert(val);
- HDassert(obj);
-
- /* Check internal consistency */
- /* (Pre-condition) */
- HDassert(heap->nobjs < heap->nalloc);
- HDassert(heap->heap);
- HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) ||
- (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN));
- HDassert(heap->heap[0].obj == NULL);
-
- /* Check if there are any objects on the heap to remove */
- if (heap->nobjs == 0)
- HGOTO_ERROR(H5E_HEAP, H5E_NOTFOUND, FAIL, "heap is empty");
-
- /* Get the information for the top object on the heap */
- HDassert(heap->heap[1].obj->heap_loc == 1);
- *val = heap->heap[1].val;
- *obj = heap->heap[1].obj;
-
- /* Move the last element in the heap to the top */
- heap->heap[1].val = heap->heap[heap->nobjs].val;
- heap->heap[1].obj = heap->heap[heap->nobjs].obj;
- heap->heap[1].obj->heap_loc = 1;
-
- /* Decrement number of objects in heap */
- heap->nobjs--;
-
- /* Restore heap condition, if there are objects on the heap */
- if (heap->nobjs > 0) {
- if (heap->type == H5HP_MAX_HEAP) {
- if (H5HP__sink_max(heap, (size_t)1) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTDELETE, FAIL, "unable to restore heap condition");
- } /* end if */
- else {
- if (H5HP__sink_min(heap, (size_t)1) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTDELETE, FAIL, "unable to restore heap condition");
- } /* end else */
- } /* end if */
-
-done:
-
- /* Check internal consistency */
- /* (Post-condition) */
- HDassert(heap->nobjs < heap->nalloc);
- HDassert(heap->heap);
- HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) ||
- (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN));
- HDassert(heap->heap[0].obj == NULL);
-
- FUNC_LEAVE_NOAPI(ret_value);
-} /* end H5HP_remove() */
-
-/*--------------------------------------------------------------------------
- NAME
- H5HP_change
- PURPOSE
- Change the priority of an object on a heap
- USAGE
- herr_t H5HP_change(heap, val, obj)
- H5HP_t *heap; IN/OUT: Pointer to heap to modify
- int val; IN: New priority value for object
- void *obj; IN: Pointer to object to modify
-
- RETURNS
- Returns non-negative on success, negative on failure.
- DESCRIPTION
- Changes the priority of an object on a heap.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-herr_t
-H5HP_change(H5HP_t *heap, int val, void *_obj)
-{
- H5HP_info_t *obj = (H5HP_info_t *)_obj; /* Alias for object */
- size_t obj_loc; /* Location of object in heap */
- int old_val; /* Object's old priority value */
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(FAIL)
-
- /* Check args */
- HDassert(heap);
- HDassert(obj);
-
- /* Check internal consistency */
- /* (Pre-condition) */
- HDassert(heap->nobjs < heap->nalloc);
- HDassert(heap->heap);
- HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) ||
- (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN));
- HDassert(heap->heap[0].obj == NULL);
-
- /* Get the location of the object in the heap */
- obj_loc = obj->heap_loc;
- HDassert(obj_loc > 0 && obj_loc <= heap->nobjs);
-
- /* Change the heap object's priority */
- old_val = heap->heap[obj_loc].val;
- heap->heap[obj_loc].val = val;
-
- /* Restore heap condition */
- if (val < old_val) {
- if (heap->type == H5HP_MAX_HEAP) {
- if (H5HP__sink_max(heap, obj_loc) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition");
- } /* end if */
- else {
- if (H5HP__swim_min(heap, obj_loc) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition");
- } /* end else */
- } /* end if */
- else {
- if (heap->type == H5HP_MAX_HEAP) {
- if (H5HP__swim_max(heap, obj_loc) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition");
- } /* end if */
- else {
- if (H5HP__sink_min(heap, obj_loc) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition");
- } /* end else */
- } /* end else */
-
-done:
-
- /* Check internal consistency */
- /* (Post-condition) */
- HDassert(heap->nobjs < heap->nalloc);
- HDassert(heap->heap);
- HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) ||
- (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN));
- HDassert(heap->heap[0].obj == NULL);
-
- FUNC_LEAVE_NOAPI(ret_value);
-} /* end H5HP_change() */
-
-/*--------------------------------------------------------------------------
- NAME
- H5HP_incr
- PURPOSE
- Increment the priority of an object on a heap
- USAGE
- herr_t H5HP_incr(heap, amt, obj)
- H5HP_t *heap; IN/OUT: Pointer to heap to modify
- unsigned amt; IN: Amount to increase priority by
- void *obj; IN: Pointer to object to modify
-
- RETURNS
- Returns non-negative on success, negative on failure.
- DESCRIPTION
- Increments the priority of an object on a heap by one.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-herr_t
-H5HP_incr(H5HP_t *heap, unsigned amt, void *_obj)
-{
- H5HP_info_t *obj = (H5HP_info_t *)_obj; /* Alias for object */
- size_t obj_loc; /* Location of object in heap */
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(FAIL)
-
- /* Check args */
- HDassert(heap);
- HDassert(obj);
-
- /* Check internal consistency */
- /* (Pre-condition) */
- HDassert(heap->nobjs < heap->nalloc);
- HDassert(heap->heap);
- HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) ||
- (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN));
- HDassert(heap->heap[0].obj == NULL);
-
- /* Get the location of the object in the heap */
- obj_loc = obj->heap_loc;
- HDassert(obj_loc > 0 && obj_loc <= heap->nobjs);
-
- /* Change the heap object's priority */
- heap->heap[obj_loc].val += (int)amt;
-
- /* Restore heap condition */
- if (H5HP_MAX_HEAP == heap->type) {
- if (H5HP__swim_max(heap, obj_loc) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition")
- } /* end if */
- else {
- if (H5HP__sink_min(heap, obj_loc) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition")
- } /* end else */
-
-done:
-
- /* Check internal consistency */
- /* (Post-condition) */
- HDassert(heap->nobjs < heap->nalloc);
- HDassert(heap->heap);
- HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) ||
- (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN));
- HDassert(heap->heap[0].obj == NULL);
-
- FUNC_LEAVE_NOAPI(ret_value);
-} /* end H5HP_incr() */
-
-/*--------------------------------------------------------------------------
- NAME
- H5HP_decr
- PURPOSE
- Decrement the priority of an object on a heap
- USAGE
- herr_t H5HP_dec(heap, amt, obj)
- H5HP_t *heap; IN/OUT: Pointer to heap to modify
- unsigned amt; IN: Amount to decrease priority by
- void *obj; IN: Pointer to object to modify
-
- RETURNS
- Returns non-negative on success, negative on failure.
- DESCRIPTION
- Decrements the priority of an object on a heap by one.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-herr_t
-H5HP_decr(H5HP_t *heap, unsigned amt, void *_obj)
-{
- H5HP_info_t *obj = (H5HP_info_t *)_obj; /* Alias for object */
- size_t obj_loc; /* Location of object in heap */
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(FAIL)
-
- /* Check args */
- HDassert(heap);
- HDassert(obj);
-
- /* Check internal consistency */
- /* (Pre-condition) */
- HDassert(heap->nobjs < heap->nalloc);
- HDassert(heap->heap);
- HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) ||
- (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN));
- HDassert(heap->heap[0].obj == NULL);
-
- /* Get the location of the object in the heap */
- obj_loc = obj->heap_loc;
- HDassert(obj_loc > 0 && obj_loc <= heap->nobjs);
-
- /* Change the heap object's priority */
- H5_CHECK_OVERFLOW(amt, unsigned, int);
- heap->heap[obj_loc].val -= (int)amt;
-
- /* Restore heap condition */
- if (heap->type == H5HP_MAX_HEAP) {
- if (H5HP__sink_max(heap, obj_loc) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition");
- } /* end if */
- else {
- if (H5HP__swim_min(heap, obj_loc) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition");
- } /* end else */
-
-done:
-
- /* Check internal consistency */
- /* (Post-condition) */
- HDassert(heap->nobjs < heap->nalloc);
- HDassert(heap->heap);
- HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) ||
- (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN));
- HDassert(heap->heap[0].obj == NULL);
-
- FUNC_LEAVE_NOAPI(ret_value);
-} /* end H5HP_decr() */
-
-/*--------------------------------------------------------------------------
- NAME
- H5HP_close
- PURPOSE
- Close a heap, deallocating it.
- USAGE
- herr_t H5HP_close(heap)
- H5HP_t *heap; IN/OUT: Pointer to heap to close
-
- RETURNS
- Returns non-negative on success, negative on failure.
- DESCRIPTION
- Close a heap, freeing all internal information. Any objects left in
- the heap are not deallocated.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-herr_t
-H5HP_close(H5HP_t *heap)
-{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
-
- /* Check args */
- HDassert(heap);
-
- /* Check internal consistency */
- /* (Pre-condition) */
- HDassert(heap->nobjs < heap->nalloc);
- HDassert(heap->heap);
- HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) ||
- (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN));
- HDassert(NULL == heap->heap[0].obj);
-
- /* Free internal structures for heap */
- heap->heap = H5FL_SEQ_FREE(H5HP_ent_t, heap->heap);
-
- /* Free actual heap object */
- heap = H5FL_FREE(H5HP_t, heap);
-
- FUNC_LEAVE_NOAPI(SUCCEED)
-} /* end H5HP_close() */
diff --git a/src/H5HPprivate.h b/src/H5HPprivate.h
deleted file mode 100644
index 50020bc..0000000
--- a/src/H5HPprivate.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * 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. *
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
-/*
- * This file contains private information about the H5HP module
- */
-#ifndef H5HPprivate_H
-#define H5HPprivate_H
-
-/**************************************/
-/* Public headers needed by this file */
-/**************************************/
-#ifdef LATER
-#include "H5HPpublic.h"
-#endif /* LATER */
-
-/***************************************/
-/* Private headers needed by this file */
-/***************************************/
-#include "H5private.h"
-
-/************/
-/* Typedefs */
-/************/
-
-/* Typedef for heap struct (defined in H5HP.c) */
-typedef struct H5HP_t H5HP_t;
-
-/* Typedef for objects which can be inserted into heaps */
-/* This _must_ be the first field in objects which can be inserted into heaps */
-typedef struct H5HP_info_t {
- size_t heap_loc; /* Location of object in heap */
-} H5HP_info_t;
-
-/* Typedef for type of heap to create */
-typedef enum {
- H5HP_MIN_HEAP, /* Minimum values in heap are at the "top" */
- H5HP_MAX_HEAP /* Maximum values in heap are at the "top" */
-} H5HP_type_t;
-
-/**********/
-/* Macros */
-/**********/
-
-/********************/
-/* Private routines */
-/********************/
-H5_DLL H5HP_t *H5HP_create(H5HP_type_t heap_type);
-H5_DLL herr_t H5HP_insert(H5HP_t *heap, int val, void *obj);
-H5_DLL ssize_t H5HP_count(const H5HP_t *heap);
-H5_DLL herr_t H5HP_top(const H5HP_t *heap, int *val);
-H5_DLL herr_t H5HP_remove(H5HP_t *heap, int *val, void **ptr);
-H5_DLL herr_t H5HP_change(H5HP_t *heap, int val, void *obj);
-H5_DLL herr_t H5HP_incr(H5HP_t *heap, unsigned amt, void *obj);
-H5_DLL herr_t H5HP_decr(H5HP_t *heap, unsigned amt, void *obj);
-H5_DLL herr_t H5HP_close(H5HP_t *heap);
-
-#endif /* H5HPprivate_H */
diff --git a/src/H5MP.c b/src/H5MP.c
deleted file mode 100644
index 397d26b..0000000
--- a/src/H5MP.c
+++ /dev/null
@@ -1,443 +0,0 @@
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * 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. *
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
-/*-------------------------------------------------------------------------
- *
- * Created: H5MP.c
- * May 2 2005
- * Quincey Koziol
- *
- * Purpose: Implements memory pools. (Similar to Apache's APR
- * memory pools)
- *
- * Please see the documentation in:
- * doc/html/TechNotes/MemoryPools.html for a full description
- * of how they work, etc.
- *
- *-------------------------------------------------------------------------
- */
-
-#include "H5MPmodule.h" /* This source code file is part of the H5MP module */
-
-/* Private headers */
-#include "H5private.h" /* Generic Functions */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5MMprivate.h" /* Memory management */
-#include "H5MPpkg.h" /* Memory Pools */
-
-/****************/
-/* Local Macros */
-/****************/
-
-/* Minimum sized block */
-#define H5MP_MIN_BLOCK (H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t)) + H5MP_BLOCK_ALIGNMENT)
-
-/* First block in page */
-#define H5MP_PAGE_FIRST_BLOCK(p) \
- (H5MP_page_blk_t *)((void *)((unsigned char *)(p) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t))))
-
-/******************/
-/* Local Typedefs */
-/******************/
-
-/********************/
-/* Local Prototypes */
-/********************/
-
-/********************************/
-/* Package Variable Definitions */
-/********************************/
-
-/********************/
-/* Static Variables */
-/********************/
-
-/* Declare a free list to manage the H5MP_pool_t struct */
-H5FL_DEFINE(H5MP_pool_t);
-
-/*-------------------------------------------------------------------------
- * Function: H5MP_create
- *
- * Purpose: Create a new memory pool
- *
- * Return: Pointer to the memory pool "header" on success/NULL on failure
- *
- * Programmer: Quincey Koziol
- * May 2 2005
- *
- *-------------------------------------------------------------------------
- */
-H5MP_pool_t *
-H5MP_create(size_t page_size, unsigned flags)
-{
- H5MP_pool_t *mp = NULL; /* New memory pool header */
- H5MP_pool_t *ret_value = NULL; /* Return value */
-
- FUNC_ENTER_NOAPI(NULL)
-
- /* Allocate space for the pool header */
- if (NULL == (mp = H5FL_MALLOC(H5MP_pool_t)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for memory pool header")
-
- /* Assign information */
- mp->page_size = H5MP_BLOCK_ALIGN(page_size);
- mp->flags = flags;
-
- /* Initialize information */
- mp->free_size = 0;
- mp->first = NULL;
- mp->max_size = mp->page_size - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t));
-
- /* Create factory for pool pages */
- if (NULL == (mp->page_fac = H5FL_fac_init(page_size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, NULL, "can't create page factory")
-
- /* Set return value */
- ret_value = mp;
-
-done:
- if (NULL == ret_value && mp)
- if (H5MP_close(mp) < 0)
- HDONE_ERROR(H5E_RESOURCE, H5E_CANTFREE, NULL, "unable to free memory pool header")
-
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5MP_create() */
-
-/*-------------------------------------------------------------------------
- * Function: H5MP__new_page
- *
- * Purpose: Allocate new page for a memory pool
- *
- * Return: Pointer to the page allocated on success/NULL on failure
- *
- * Programmer: Quincey Koziol
- * May 4 2005
- *
- *-------------------------------------------------------------------------
- */
-static H5MP_page_t *
-H5MP__new_page(H5MP_pool_t *mp, size_t page_size)
-{
- H5MP_page_t * new_page; /* New page created */
- H5MP_page_blk_t *first_blk; /* Pointer to first block in page */
- H5MP_page_t * ret_value = NULL; /* Return value */
-
- FUNC_ENTER_STATIC
-
- /* Sanity check */
- HDassert(mp);
- HDassert(page_size >= mp->page_size);
-
- /* Allocate page */
- if (page_size > mp->page_size) {
- if (NULL == (new_page = (H5MP_page_t *)H5MM_malloc(page_size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for page")
- new_page->free_size = page_size - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t));
- new_page->fac_alloc = FALSE;
- } /* end if */
- else {
- if (NULL == (new_page = (H5MP_page_t *)H5FL_FAC_MALLOC(mp->page_fac)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for page")
- new_page->free_size = mp->max_size;
- new_page->fac_alloc = TRUE;
- } /* end else */
-
- /* Initialize page information */
- first_blk = H5MP_PAGE_FIRST_BLOCK(new_page);
- first_blk->size = new_page->free_size;
- first_blk->page = new_page;
- first_blk->is_free = TRUE;
- first_blk->prev = NULL;
- first_blk->next = NULL;
-
- /* Insert into page list */
- new_page->prev = NULL;
- new_page->next = mp->first;
- if (mp->first)
- mp->first->prev = new_page;
- mp->first = new_page;
-
- /* Account for new free space */
- new_page->free_blk = first_blk;
- mp->free_size += new_page->free_size;
-
- /* Assign return value */
- ret_value = new_page;
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5MP__new_page() */
-
-/*-------------------------------------------------------------------------
- * Function: H5MP_malloc
- *
- * Purpose: Allocate space in a memory pool
- *
- * Return: Pointer to the space allocated on success/NULL on failure
- *
- * Programmer: Quincey Koziol
- * May 2 2005
- *
- *-------------------------------------------------------------------------
- */
-void *
-H5MP_malloc(H5MP_pool_t *mp, size_t request)
-{
- H5MP_page_t * alloc_page = NULL; /* Page to allocate space from */
- H5MP_page_blk_t *alloc_free; /* Pointer to free space in page */
- size_t needed; /* Size requested, plus block header and alignment */
- void * ret_value = NULL; /* Return value */
-
- FUNC_ENTER_NOAPI(NULL)
-
- /* Sanity check */
- HDassert(mp);
- HDassert(request > 0);
-
- /* Compute actual size needed */
- needed = H5MP_BLOCK_ALIGN(request) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t));
-
- /* See if the request can be handled by existing free space */
- if (needed <= mp->free_size) {
- size_t pool_free_avail; /* Amount of free space possibly available in pool */
-
- /* Locate page with enough free space */
- alloc_page = mp->first;
- pool_free_avail = mp->free_size;
- while (alloc_page && pool_free_avail >= needed) {
- /* If we found a page with enough free space, search for large
- * enough free block on that page */
- if (alloc_page->free_size >= needed) {
- size_t page_free_avail; /* Amount of free space possibly available */
-
- /* Locate large enough block */
- alloc_free = alloc_page->free_blk;
- page_free_avail = alloc_page->free_size;
- while (alloc_free && page_free_avail >= needed) {
- if (alloc_free->is_free) {
- /* If we found a large enough block, leave now */
- if (alloc_free->size >= needed)
- goto found; /* Needed to escape double "while" loop */
-
- /* Decrement amount of potential space left */
- page_free_avail -= alloc_free->size;
- } /* end if */
-
- /* Go to next block */
- alloc_free = alloc_free->next;
- } /* end while */
- } /* end if */
-
- /* Decrement amount of potential space left */
- pool_free_avail -= alloc_page->free_size;
-
- /* Go to next page */
- alloc_page = alloc_page->next;
- } /* end while */
- } /* end if */
-
- {
- size_t page_size; /* Size of page needed */
-
- /* Check if the request is too large for a standard page */
- page_size =
- (needed > mp->max_size) ? (needed + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t))) : mp->page_size;
-
- /* Allocate new page */
- if (NULL == (alloc_page = H5MP__new_page(mp, page_size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for page")
-
- /* Set the block to allocate from */
- alloc_free = alloc_page->free_blk;
- } /* end block */
-
- /* Allocate space in page */
-found:
-
- /* Sanity check */
- HDassert(alloc_page);
- HDassert(alloc_free);
-
- /* Check if we can subdivide the free space */
- if (alloc_free->size > (needed + H5MP_MIN_BLOCK)) {
- H5MP_page_blk_t *new_free; /* New free block created */
-
- /* Carve out new free block after block to allocate */
- new_free = (H5MP_page_blk_t *)((void *)(((unsigned char *)alloc_free) + needed));
-
- /* Link into existing lists */
- new_free->next = alloc_free->next;
- if (alloc_free->next)
- alloc_free->next->prev = new_free;
- new_free->prev = alloc_free;
- alloc_free->next = new_free;
-
- /* Set blocks' information */
- new_free->size = alloc_free->size - needed;
- new_free->is_free = TRUE;
- new_free->page = alloc_free->page;
- alloc_free->size = needed;
- alloc_free->is_free = FALSE;
- } /* end if */
- else {
- /* Use whole free space block for new block */
- alloc_free->is_free = FALSE;
- } /* end else */
-
- /* Update page & pool's free size information */
- alloc_page->free_size -= alloc_free->size;
- if (alloc_page->free_blk == alloc_free)
- alloc_page->free_blk = alloc_free->next;
- mp->free_size -= alloc_free->size;
-
- /* Set new space pointer for the return value */
- ret_value = ((unsigned char *)alloc_free) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t));
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5MP_malloc() */
-
-/*-------------------------------------------------------------------------
- * Function: H5MP_free
- *
- * Purpose: Release space in a memory pool
- *
- * Return: NULL on success/NULL on failure
- *
- * Programmer: Quincey Koziol
- * May 3 2005
- *
- * Note: Should we release pages that have no used blocks?
- *
- *-------------------------------------------------------------------------
- */
-void *
-H5MP_free(H5MP_pool_t *mp, void *spc)
-{
- H5MP_page_blk_t *spc_blk; /* Block for space to free */
- H5MP_page_t * spc_page; /* Page containing block to free */
- void * ret_value = NULL; /* Return value */
-
- FUNC_ENTER_NOAPI_NOINIT_NOERR
-
- /* Sanity check */
- HDassert(mp);
- HDassert(spc);
-
- /* Get block header for space to free */
- spc_blk =
- (H5MP_page_blk_t *)((void *)(((unsigned char *)spc) - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t))));
-
- /* Mark block as free */
- HDassert(spc_blk->is_free == FALSE);
- spc_blk->is_free = TRUE;
-
- /* Add it's space to the amount of free space in the page & pool */
- spc_page = spc_blk->page;
- spc_page->free_size += spc_blk->size;
- mp->free_size += spc_blk->size;
-
- /* Move page with newly freed space to front of list of pages in pool */
- if (spc_page != mp->first) {
- /* Remove page from list */
- spc_page->prev->next = spc_page->next;
- if (spc_page->next)
- spc_page->next->prev = spc_page->prev;
-
- /* Insert page at beginning of list */
- spc_page->prev = NULL;
- spc_page->next = mp->first;
- mp->first->prev = spc_page;
- mp->first = spc_page;
- } /* end if */
-
- /* Check if block can be merged with free space after it on page */
- if (spc_blk->next != NULL) {
- H5MP_page_blk_t *next_blk; /* Block following space to free */
-
- next_blk = spc_blk->next;
- HDassert(next_blk->prev == spc_blk);
- if (next_blk->is_free) {
- spc_blk->size += next_blk->size;
- spc_blk->next = next_blk->next;
- } /* end if */
- } /* end if */
-
- /* Check if block can be merged with free space before it on page */
- if (spc_blk->prev != NULL) {
- H5MP_page_blk_t *prev_blk; /* Block before space to free */
-
- prev_blk = spc_blk->prev;
- HDassert(prev_blk->next == spc_blk);
- if (prev_blk->is_free) {
- prev_blk->size += spc_blk->size;
- prev_blk->next = spc_blk->next;
- } /* end if */
- } /* end if */
-
- /* Check if the block freed becomes the first free block on the page */
- if (spc_page->free_blk == NULL || spc_blk < spc_page->free_blk)
- spc_page->free_blk = spc_blk;
-
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5MP_free() */
-
-/*-------------------------------------------------------------------------
- * Function: H5MP_close
- *
- * Purpose: Release all memory for a pool and destroy pool
- *
- * Return: Non-negative on success/negative on failure
- *
- * Programmer: Quincey Koziol
- * May 3 2005
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5MP_close(H5MP_pool_t *mp)
-{
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(FAIL)
-
- /* Release memory for pool pages */
- if (mp->first != NULL) {
- H5MP_page_t *page, *next_page; /* Pointer to pages in pool */
-
- /* Iterate through pages, releasing them */
- page = mp->first;
- while (page) {
- next_page = page->next;
-
- /* Free the page appropriately */
- if (page->fac_alloc)
- page = (H5MP_page_t *)H5FL_FAC_FREE(mp->page_fac, page);
- else
- page = (H5MP_page_t *)H5MM_xfree(page);
-
- page = next_page;
- } /* end while */
- } /* end if */
-
- /* Release page factory */
- if (mp->page_fac)
- if (H5FL_fac_term(mp->page_fac) < 0)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't destroy page factory")
-
-done:
- /* Free the memory pool itself */
- mp = H5FL_FREE(H5MP_pool_t, mp);
-
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5MP_close() */
diff --git a/src/H5MPmodule.h b/src/H5MPmodule.h
deleted file mode 100644
index 8e34598..0000000
--- a/src/H5MPmodule.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * Copyright by The HDF Group. *
- * All rights reserved. *
- * *
- * This file is part of HDF5. The full HDF5 copyright notice, including *
- * terms governing use, modification, and redistribution, is contained in *
- * the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://www.hdfgroup.org/licenses. *
- * If you do not have access to either file, you may request a copy from *
- * help@hdfgroup.org. *
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
-/*
- * Programmer: Quincey Koziol
- * Saturday, September 12, 2015
- *
- * Purpose: This file contains declarations which define macros for the
- * H5MP package. Including this header means that the source file
- * is part of the H5MP package.
- */
-#ifndef H5MPmodule_H
-#define H5MPmodule_H
-
-/* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error
- * reporting macros.
- */
-#define H5MP_MODULE
-#define H5_MY_PKG H5MP
-#define H5_MY_PKG_ERR H5E_RESOURCE
-#define H5_MY_PKG_INIT NO
-
-#endif /* H5MPmodule_H */
diff --git a/src/H5MPpkg.h b/src/H5MPpkg.h
deleted file mode 100644
index 64c5293..0000000
--- a/src/H5MPpkg.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * 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. *
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
-/*
- * Programmer: Quincey Koziol
- * Monday, May 2, 2005
- *
- * Purpose: This file contains declarations which are visible only within
- * the H5MP package. Source files outside the H5MP package should
- * include H5MPprivate.h instead.
- */
-#if !(defined H5MP_FRIEND || defined H5MP_MODULE)
-#error "Do not include this file outside the H5MP package!"
-#endif
-
-#ifndef H5MPpkg_H
-#define H5MPpkg_H
-
-/* Get package's private header */
-#include "H5MPprivate.h" /* Memory Pools */
-
-/* Other private headers needed by this file */
-#include "H5FLprivate.h" /* Free Lists */
-
-/**************************/
-/* Package Private Macros */
-/**************************/
-
-/* Alignment macros */
-/* (Ideas from Apache APR :-) */
-
-/* Default alignment necessary */
-#define H5MP_BLOCK_ALIGNMENT 8
-
-/* General alignment macro */
-/* (this only works for aligning to power of 2 boundary) */
-#define H5MP_ALIGN(x, a) (((x) + ((size_t)(a)) - 1) & ~(((size_t)(a)) - 1))
-
-/* Default alignment */
-#define H5MP_BLOCK_ALIGN(x) H5MP_ALIGN(x, H5MP_BLOCK_ALIGNMENT)
-
-/****************************/
-/* Package Private Typedefs */
-/****************************/
-
-/* Free block in pool */
-typedef struct H5MP_page_blk_t {
- size_t size; /* Size of block (includes this H5MP_page_blk_t info) */
- unsigned is_free : 1; /* Flag to indicate the block is free */
- struct H5MP_page_t * page; /* Pointer to page block is located in */
- struct H5MP_page_blk_t *prev; /* Pointer to previous block in page */
- struct H5MP_page_blk_t *next; /* Pointer to next block in page */
-} H5MP_page_blk_t;
-
-/* Memory pool page */
-typedef struct H5MP_page_t {
- size_t free_size; /* Total amount of free space in page */
- unsigned fac_alloc : 1; /* Flag to indicate the page was allocated by the pool's factory */
- H5MP_page_blk_t * free_blk; /* Pointer to first free block in page */
- struct H5MP_page_t *next; /* Pointer to next page in pool */
- struct H5MP_page_t *prev; /* Pointer to previous page in pool */
-} H5MP_page_t;
-
-/* Memory pool header */
-struct H5MP_pool_t {
- H5FL_fac_head_t *page_fac; /* Free-list factory for pages */
- size_t page_size; /* Page size for pool */
- size_t free_size; /* Total amount of free space in pool */
- size_t max_size; /* Maximum block that will fit in a standard page */
- H5MP_page_t * first; /* Pointer to first page in pool */
- unsigned flags; /* Bit flags for pool settings */
-};
-
-/*****************************************/
-/* Package Private Variable Declarations */
-/*****************************************/
-
-/******************************/
-/* Package Private Prototypes */
-/******************************/
-#ifdef H5MP_TESTING
-H5_DLL herr_t H5MP_get_pool_free_size(const H5MP_pool_t *mp, size_t *free_size);
-H5_DLL htri_t H5MP_pool_is_free_size_correct(const H5MP_pool_t *mp);
-H5_DLL herr_t H5MP_get_pool_first_page(const H5MP_pool_t *mp, H5MP_page_t **page);
-H5_DLL herr_t H5MP_get_page_free_size(const H5MP_page_t *mp, size_t *page);
-H5_DLL herr_t H5MP_get_page_next_page(const H5MP_page_t *page, H5MP_page_t **next_page);
-#endif /* H5MP_TESTING */
-
-#endif /* H5MPpkg_H */
diff --git a/src/H5MPprivate.h b/src/H5MPprivate.h
deleted file mode 100644
index 2b06650..0000000
--- a/src/H5MPprivate.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * 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. *
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
-/*-------------------------------------------------------------------------
- *
- * Created: H5MPprivate.h
- * May 2 2005
- * Quincey Koziol
- *
- * Purpose: Private header for memory pool routines.
- *
- *-------------------------------------------------------------------------
- */
-
-#ifndef H5MPprivate_H
-#define H5MPprivate_H
-
-/* Include package's public header (not yet) */
-/* #include "H5MPpublic.h" */
-
-/* Private headers needed by this file */
-
-/**************************/
-/* Library Private Macros */
-/**************************/
-
-/* Pool creation flags */
-/* Default settings */
-#define H5MP_FLG_DEFAULT 0
-#define H5MP_PAGE_SIZE_DEFAULT 4096 /* (bytes) */
-
-/****************************/
-/* Library Private Typedefs */
-/****************************/
-
-/* Memory pool header (defined in H5MPpkg.c) */
-typedef struct H5MP_pool_t H5MP_pool_t;
-
-/***************************************/
-/* Library-private Function Prototypes */
-/***************************************/
-H5_DLL H5MP_pool_t *H5MP_create(size_t page_size, unsigned flags);
-H5_DLL void * H5MP_malloc(H5MP_pool_t *mp, size_t request);
-H5_DLL void * H5MP_free(H5MP_pool_t *mp, void *spc);
-H5_DLL herr_t H5MP_close(H5MP_pool_t *mp);
-
-#endif /* H5MPprivate_H */
diff --git a/src/H5MPtest.c b/src/H5MPtest.c
deleted file mode 100644
index 27e7bbe..0000000
--- a/src/H5MPtest.c
+++ /dev/null
@@ -1,213 +0,0 @@
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * 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. *
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
-/* Programmer: Quincey Koziol
- * Tuesday, May 3, 2005
- *
- * Purpose: Memory pool testing functions.
- */
-
-#include "H5MPmodule.h" /* This source code file is part of the H5MP module */
-#define H5MP_TESTING /*include H5MP testing funcs*/
-
-/* Private headers */
-#include "H5private.h" /* Generic Functions */
-#include "H5MPpkg.h" /* Memory Pools */
-#include "H5Eprivate.h" /* Error handling */
-
-/* Static Prototypes */
-
-/* Package variables */
-
-/*-------------------------------------------------------------------------
- * Function: H5MP_get_pool_free_size
- *
- * Purpose: Retrieve the total amount of free space in entire pool
- *
- * Return: Success: non-negative
- *
- * Failure: negative
- *
- * Programmer: Quincey Koziol
- * Tuesday, May 3, 2005
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5MP_get_pool_free_size(const H5MP_pool_t *mp, size_t *free_size)
-{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
-
- /* Check arguments. */
- HDassert(mp);
- HDassert(free_size);
-
- /* Get memory pool's free space */
- *free_size = mp->free_size;
-
- FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5MP_get_pool_free_size() */
-
-/*-------------------------------------------------------------------------
- * Function: H5MP_get_pool_first_page
- *
- * Purpose: Retrieve the first page in a memory pool
- *
- * Return: Success: non-negative
- *
- * Failure: negative
- *
- * Programmer: Quincey Koziol
- * Tuesday, May 3, 2005
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5MP_get_pool_first_page(const H5MP_pool_t *mp, H5MP_page_t **page)
-{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
-
- /* Check arguments. */
- HDassert(mp);
- HDassert(page);
-
- /* Get memory pool's first page */
- *page = mp->first;
-
- FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5MP_get_pool_first_page() */
-
-/*-------------------------------------------------------------------------
- * Function: H5MP_pool_is_free_size_correct
- *
- * Purpose: Check that the free space reported in each page corresponds
- * to the free size in each page and that the free space in the
- * free blocks for a page corresponds with the free space for
- * the page.
- *
- * Return: Success: non-negative
- *
- * Failure: negative
- *
- * Programmer: Quincey Koziol
- * Wednesday, May 3, 2005
- *
- *-------------------------------------------------------------------------
- */
-htri_t
-H5MP_pool_is_free_size_correct(const H5MP_pool_t *mp)
-{
- H5MP_page_t *page; /* Pointer to current page */
- size_t pool_free; /* Size of pages' free space */
- htri_t ret_value = TRUE; /* Return value */
-
- FUNC_ENTER_NOAPI_NOINIT_NOERR
-
- /* Check arguments. */
- HDassert(mp);
-
- /* Iterate through pages, checking the free size & accumulating the
- * free space for all the pages */
- page = mp->first;
- pool_free = 0;
- while (page != NULL) {
- H5MP_page_blk_t *blk; /* Pointer to current free block */
- size_t page_free; /* Size of blocks on free list */
-
- /* Iterate through the blocks in page, accumulating free space */
- blk = (H5MP_page_blk_t *)((void *)((unsigned char *)page + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t))));
- page_free = 0;
- while (blk != NULL) {
- if (blk->is_free)
- page_free += blk->size;
- blk = blk->next;
- } /* end while */
-
- /* Check that the free space from the blocks on the free list
- * corresponds to space in page */
- if (page_free != page->free_size)
- HGOTO_DONE(FALSE)
-
- /* Increment the amount of free space in pool */
- pool_free += page->free_size;
-
- /* Advance to next page */
- page = page->next;
- } /* end while */
-
- /* Check that the free space from the pages
- * corresponds to free space in pool */
- if (pool_free != mp->free_size)
- HGOTO_DONE(FALSE)
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* H5MP_pool_is_free_size_correct() */
-
-/*-------------------------------------------------------------------------
- * Function: H5MP_get_page_free_size
- *
- * Purpose: Retrieve the amount of free space in given page
- *
- * Return: Success: non-negative
- *
- * Failure: negative
- *
- * Programmer: Quincey Koziol
- * Tuesday, May 3, 2005
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5MP_get_page_free_size(const H5MP_page_t *page, size_t *free_size)
-{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
-
- /* Check arguments. */
- HDassert(page);
- HDassert(free_size);
-
- /* Get memory page's free space */
- *free_size = page->free_size;
-
- FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5MP_get_page_free_size() */
-
-/*-------------------------------------------------------------------------
- * Function: H5MP_get_page_next_page
- *
- * Purpose: Retrieve the next page in the pool
- *
- * Return: Success: non-negative
- *
- * Failure: negative
- *
- * Programmer: Quincey Koziol
- * Tuesday, May 3, 2005
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5MP_get_page_next_page(const H5MP_page_t *page, H5MP_page_t **next_page)
-{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
-
- /* Check arguments. */
- HDassert(page);
- HDassert(next_page);
-
- /* Get next memory page */
- *next_page = page->next;
-
- FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5MP_get_page_next_page() */
diff --git a/src/H5PBprivate.h b/src/H5PBprivate.h
index c23336e..ad59150 100644
--- a/src/H5PBprivate.h
+++ b/src/H5PBprivate.h
@@ -24,10 +24,6 @@
#ifndef H5PBprivate_H
#define H5PBprivate_H
-/* Include package's public header */
-
-/* no H5PBpublic.h at present */
-
/* Private headers needed by this header */
#include "H5private.h" /* Generic Functions */
diff --git a/src/H5Spublic.h b/src/H5Spublic.h
index 30ca813..536f290 100644
--- a/src/H5Spublic.h
+++ b/src/H5Spublic.h
@@ -171,7 +171,7 @@ H5_DLL herr_t H5Sclose(hid_t space_id);
* composing the entire current extent). If either \p stride or
* \p block is NULL, then it will be set to \p 1.
*
- * \since 1.12.0
+ * \since 1.10.6
*
*/
H5_DLL hid_t H5Scombine_hyperslab(hid_t space_id, H5S_seloper_t op, const hsize_t start[],
@@ -194,7 +194,7 @@ H5_DLL hid_t H5Scombine_hyperslab(hid_t space_id, H5S_seloper_t op, const hsize_
* from \p space1_id is copied for the dataspace extent of the
* newly created dataspace.
*
- * \since 1.12.0
+ * \since 1.10.6
*
*/
H5_DLL hid_t H5Scombine_select(hid_t space1_id, H5S_seloper_t op, hid_t space2_id);
@@ -795,7 +795,7 @@ H5_DLL htri_t H5Sis_simple(hid_t space_id);
* \p space2_id. The first selection is modified to contain the
* result of \p space1_id operated on by \p space2_id.
*
- * \since 1.12.0
+ * \since 1.10.6
*
*/
H5_DLL herr_t H5Smodify_select(hid_t space1_id, H5S_seloper_t op, hid_t space2_id);
@@ -940,7 +940,7 @@ H5_DLL herr_t H5Ssel_iter_reset(hid_t sel_iter_id, hid_t space_id);
*
* \note This can be useful for VOL developers to implement chunked datasets.
*
- * \since 1.12.0
+ * \since 1.10.6
*/
H5_DLL herr_t H5Sselect_adjust(hid_t spaceid, const hssize_t *offset);
/**
@@ -977,7 +977,7 @@ H5_DLL herr_t H5Sselect_all(hid_t spaceid);
* offset) from the source dataspace \p src_id to the destination
* dataspace \p dst_id.
*
- * \since 1.12.0
+ * \since 1.10.6
*
*/
H5_DLL herr_t H5Sselect_copy(hid_t dst_id, hid_t src_id);
@@ -1205,7 +1205,7 @@ H5_DLL herr_t H5Sselect_hyperslab(hid_t space_id, H5S_seloper_t op, const hsize_
* \note Assumes that \p start & \p end block bounds are inclusive, so
* \p start == \p end value is OK.
*
- * \since 1.12.0
+ * \since 1.10.6
*
*/
H5_DLL htri_t H5Sselect_intersect_block(hid_t space_id, const hsize_t *start, const hsize_t *end);
@@ -1244,7 +1244,7 @@ H5_DLL herr_t H5Sselect_none(hid_t spaceid);
* into a third selection.This can be useful for VOL developers to
* implement chunked or virtual datasets.
*
- * \since 1.12.0
+ * \since 1.10.6
*
*/
H5_DLL hid_t H5Sselect_project_intersection(hid_t src_space_id, hid_t dst_space_id,
@@ -1265,7 +1265,7 @@ H5_DLL hid_t H5Sselect_project_intersection(hid_t src_space_id, hid_t dst_space_
* This is primarily used for reading the entire selection in
* one swoop.
*
- * \since 1.12.0
+ * \since 1.10.6
*
*/
H5_DLL htri_t H5Sselect_shape_same(hid_t space1_id, hid_t space2_id);
diff --git a/src/H5TSprivate.h b/src/H5TSprivate.h
index 3150f59..5d69854 100644
--- a/src/H5TSprivate.h
+++ b/src/H5TSprivate.h
@@ -13,11 +13,9 @@
/*-------------------------------------------------------------------------
*
- * Created: H5TSprivate.h
- * May 2 2000
- * Chee Wai LEE
+ * Created: H5TSprivate.h
*
- * Purpose: Private non-prototype header.
+ * Purpose: Thread-safety abstractions used by the library
*
*-------------------------------------------------------------------------
*/
diff --git a/src/H5module.h b/src/H5module.h
index 6d3cba8..f7d3cd6 100644
--- a/src/H5module.h
+++ b/src/H5module.h
@@ -11,9 +11,9 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
- * Purpose: This file contains declarations which define macros for the
- * H5 package. Including this header means that the source file
- * is part of the H5 package.
+ * Purpose: This file contains declarations which define macros for the
+ * H5 package. Including this header means that the source file
+ * is part of the H5 package.
*/
#ifndef H5module_H
#define H5module_H
diff --git a/src/H5private.h b/src/H5private.h
index bee2afc..b9bbe3b 100644
--- a/src/H5private.h
+++ b/src/H5private.h
@@ -1330,6 +1330,9 @@ H5_DLL H5_ATTR_CONST int Nflock(int fd, int operation);
#ifndef HDsigsetjmp
#define HDsigsetjmp(J, N) sigsetjmp(J, N)
#endif
+#ifndef HDsigtimedwait
+#define HDsigtimedwait(S, I, T) sigtimedwait(S, I, T)
+#endif
#ifndef HDsigsuspend
#define HDsigsuspend(S) sigsuspend(S)
#endif
@@ -1408,6 +1411,9 @@ H5_DLL H5_ATTR_CONST int Nflock(int fd, int operation);
#ifndef HDstrrchr
#define HDstrrchr(S, C) strrchr(S, C)
#endif
+#ifndef HDstrsignal
+#define HDstrsignal(S) strsignal(S)
+#endif
#ifndef HDstrspn
#define HDstrspn(X, Y) strspn(X, Y)
#endif
diff --git a/src/Makefile.am b/src/Makefile.am
index f39afc7..931d335 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -75,13 +75,12 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5lib_settings.c H5system.c \
H5HFspace.c H5HFstat.c H5HFtest.c H5HFtiny.c \
H5HG.c H5HGcache.c H5HGdbg.c H5HGquery.c \
H5HL.c H5HLcache.c H5HLdbg.c H5HLint.c H5HLprfx.c H5HLdblk.c \
- H5HP.c \
H5I.c H5Idbg.c H5Iint.c H5Itest.c \
H5L.c H5Ldeprec.c H5Lexternal.c H5Lint.c \
H5M.c \
H5MF.c H5MFaggr.c H5MFdbg.c H5MFsection.c \
+ H5MM.c \
H5MV.c H5MVsection.c \
- H5MM.c H5MP.c H5MPtest.c \
H5O.c H5Odeprec.c H5Oainfo.c H5Oalloc.c H5Oattr.c H5Oattribute.c \
H5Obogus.c H5Obtreek.c H5Ocache.c H5Ocache_image.c H5Ochunk.c \
H5Ocont.c H5Ocopy.c H5Ocopy_ref.c H5Odbg.c H5Odrvinfo.c H5Odtype.c \
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 22034c8..839248f 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -277,7 +277,6 @@ set (testhdf5_SOURCES
${HDF5_TEST_SOURCE_DIR}/tgenprop.c
${HDF5_TEST_SOURCE_DIR}/th5o.c
${HDF5_TEST_SOURCE_DIR}/th5s.c
- ${HDF5_TEST_SOURCE_DIR}/theap.c
${HDF5_TEST_SOURCE_DIR}/tid.c
${HDF5_TEST_SOURCE_DIR}/titerate.c
${HDF5_TEST_SOURCE_DIR}/tmeta.c
@@ -339,7 +338,6 @@ set (H5_TESTS
earray
btree2
fheap
- pool
accum
hyperslab
istore
diff --git a/test/CMakeTests.cmake b/test/CMakeTests.cmake
index 6abef3b..a534e60 100644
--- a/test/CMakeTests.cmake
+++ b/test/CMakeTests.cmake
@@ -205,18 +205,12 @@ add_test (
)
set_tests_properties (H5TEST-testhdf5-clear-objects PROPERTIES FIXTURES_SETUP clear_testhdf5)
-add_test (NAME H5TEST-testhdf5-base COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:testhdf5> -x heap -x file -x select)
+add_test (NAME H5TEST-testhdf5-base COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:testhdf5> -x file -x select)
set_tests_properties (H5TEST-testhdf5-base PROPERTIES
FIXTURES_REQUIRED clear_testhdf5
ENVIRONMENT "HDF5_ALARM_SECONDS=3600;srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST"
WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST
)
-add_test (NAME H5TEST-testhdf5-heap COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:testhdf5> -o heap)
-set_tests_properties (H5TEST-testhdf5-heap PROPERTIES
- FIXTURES_REQUIRED clear_testhdf5
- ENVIRONMENT "HDF5_ALARM_SECONDS=3600;srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST"
- WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST
-)
add_test (NAME H5TEST-testhdf5-file COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:testhdf5> -o file)
set_tests_properties (H5TEST-testhdf5-file PROPERTIES
FIXTURES_REQUIRED clear_testhdf5
diff --git a/test/Makefile.am b/test/Makefile.am
index 2b62cf0..350cba6 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -75,7 +75,7 @@ check_SCRIPTS = $(TEST_SCRIPT)
TEST_PROG= testhdf5 \
cache cache_api cache_image cache_tagging lheap ohdr \
stab gheap evict_on_close farray earray btree2 fheap \
- pool accum hyperslab istore bittests dt_arith page_buffer vfd_swmr \
+ accum hyperslab istore bittests dt_arith page_buffer vfd_swmr \
dtypes dsets chunk_info cmpd_dset cmpd_dtransform filter_fail extend direct_chunk \
external efc objcopy objcopy_ref links unlink twriteorder big mtime \
fillval mount \
@@ -273,7 +273,7 @@ CHECK_CLEANFILES+=accum.h5 cmpd_dset.h5 compact_dataset.h5 dataset.h5 dset_offse
# Sources for testhdf5 executable
testhdf5_SOURCES=testhdf5.c tarray.c tattr.c tchecksum.c tconfig.c tfile.c \
- tgenprop.c th5o.c th5s.c tcoords.c theap.c tid.c titerate.c tmeta.c tmisc.c \
+ tgenprop.c th5o.c th5s.c tcoords.c tid.c titerate.c tmeta.c tmisc.c \
trefer.c trefer_deprec.c trefstr.c tselect.c tskiplist.c tsohm.c ttime.c tunicode.c \
tvlstr.c tvltypes.c
diff --git a/test/pool.c b/test/pool.c
deleted file mode 100644
index c508025..0000000
--- a/test/pool.c
+++ /dev/null
@@ -1,794 +0,0 @@
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * 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. *
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
-/* Programmer: Quincey Koziol
- * Tuesday, May 3, 2005
- */
-#include "h5test.h"
-
-/*
- * This file needs to access private datatypes from the H5MP package.
- * This file also needs to access the memory pool testing code.
- */
-#define H5MP_FRIEND /*suppress error about including H5MPpkg */
-#define H5MP_TESTING
-#include "H5MPpkg.h" /* Memory Pools */
-
-/* Other private headers that this test requires */
-
-/* Local macros */
-#define MPOOL_PAGE_SIZE H5MP_PAGE_SIZE_DEFAULT
-#define MPOOL_FLAGS H5MP_FLG_DEFAULT
-#define MPOOL_NUM_NORMAL_BLOCKS 15
-#define MPOOL_NORMAL_BLOCK 512
-#define MPOOL_LARGE_BLOCK (MPOOL_PAGE_SIZE * 3)
-#define MPOOL_NUM_SMALL_BLOCKS 64
-#define MPOOL_SMALL_BLOCK 1
-#define MPOOL_NUM_RANDOM (10 * 1024)
-#define MPOOL_RANDOM_MAX_SIZE (MPOOL_PAGE_SIZE * 2)
-
-/*-------------------------------------------------------------------------
- * Function: test_create
- *
- * Purpose: Test trivial creating & closing memory pool
- *
- * Return: Success: 0
- * Failure: 1
- *
- * Programmer: Quincey Koziol
- * Tuesday, May 3, 2005
- *
- *-------------------------------------------------------------------------
- */
-static int
-test_create(void)
-{
- H5MP_pool_t *mp; /* Memory pool */
- H5MP_page_t *page; /* Memory pool page */
- size_t free_size; /* Free size in pool */
-
- /*
- * Test memory pool creation
- */
- TESTING("memory pool creation");
-
- /* Create a memory pool */
- if (NULL == (mp = H5MP_create((size_t)MPOOL_PAGE_SIZE, MPOOL_FLAGS)))
- TEST_ERROR
-
- /* Check free space */
- if (H5MP_get_pool_free_size(mp, &free_size) < 0)
- TEST_ERROR
- if (free_size != 0)
- TEST_ERROR
-
- /* Check first page */
- if (H5MP_get_pool_first_page(mp, &page) < 0)
- TEST_ERROR
- if (page != NULL)
- TEST_ERROR
-
- /* Close the memory pool */
- if (H5MP_close(mp) < 0)
- TEST_ERROR
-
- PASSED();
-
- return 0;
-
-error:
- H5E_BEGIN_TRY
- {
- if (mp)
- H5MP_close(mp);
- }
- H5E_END_TRY;
-
- return 1;
-} /* test_create() */
-
-/*-------------------------------------------------------------------------
- * Function: test_close_one
- *
- * Purpose: Tests closing pool with one block allocated
- *
- * Return: Success: 0
- * Failure: 1
- *
- * Programmer: Quincey Koziol
- * Friday, May 6, 2005
- *
- *-------------------------------------------------------------------------
- */
-static int
-test_close_one(void)
-{
- H5MP_pool_t *mp; /* Memory pool */
-
- /*
- * Test memory pool closing
- */
- TESTING("closing pool with blocks still allocated in one page");
-
- /* Create a memory pool */
- if (NULL == (mp = H5MP_create((size_t)MPOOL_PAGE_SIZE, MPOOL_FLAGS)))
- TEST_ERROR
-
- /* Allocate space in pool */
- if (NULL == H5MP_malloc(mp, (size_t)MPOOL_NORMAL_BLOCK))
- TEST_ERROR
-
- /* Close the memory pool */
- if (H5MP_close(mp) < 0)
- TEST_ERROR
-
- PASSED();
-
- return 0;
-
-error:
- H5E_BEGIN_TRY
- {
- if (mp)
- H5MP_close(mp);
- }
- H5E_END_TRY;
-
- return 1;
-} /* test_close_one() */
-
-/*-------------------------------------------------------------------------
- * Function: test_allocate_first
- *
- * Purpose: Tests allocating first block in pool
- *
- * Return: Success: 0
- * Failure: 1
- *
- * Programmer: Quincey Koziol
- * Tuesday, May 3, 2005
- *
- *-------------------------------------------------------------------------
- */
-static int
-test_allocate_first(void)
-{
- H5MP_pool_t *mp; /* Memory pool */
- H5MP_page_t *page; /* Memory pool page */
- size_t free_size; /* Free size in pool */
- void * spc; /* Pointer to space allocated */
-
- /*
- * Test memory pool allocation
- */
- TESTING("allocating first block in pool");
-
- /* Create a memory pool */
- if (NULL == (mp = H5MP_create((size_t)MPOOL_PAGE_SIZE, MPOOL_FLAGS)))
- TEST_ERROR
-
- /* Allocate space in pool */
- if (NULL == (spc = H5MP_malloc(mp, (size_t)MPOOL_NORMAL_BLOCK)))
- TEST_ERROR
-
- /* Check pool's free space */
- if (H5MP_get_pool_free_size(mp, &free_size) < 0)
- TEST_ERROR
- if (free_size !=
- MPOOL_PAGE_SIZE - (H5MP_BLOCK_ALIGN(MPOOL_NORMAL_BLOCK) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t)) +
- H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t))))
- TEST_ERROR
-
- /* Get first page */
- if (H5MP_get_pool_first_page(mp, &page) < 0)
- TEST_ERROR
- if (page == NULL)
- TEST_ERROR
-
- /* Check page's free space */
- if (H5MP_get_page_free_size(page, &free_size) < 0)
- TEST_ERROR
- if (free_size !=
- MPOOL_PAGE_SIZE - (H5MP_BLOCK_ALIGN(MPOOL_NORMAL_BLOCK) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t)) +
- H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t))))
- TEST_ERROR
-
- /* Check that free space totals match */
- if (H5MP_pool_is_free_size_correct(mp) <= 0)
- TEST_ERROR
-
- /* Check next page */
- if (H5MP_get_page_next_page(page, &page) < 0)
- TEST_ERROR
- if (page != NULL)
- TEST_ERROR
-
- /* Free space in pool */
- H5MP_free(mp, spc);
-
- /* Check pool's free space */
- if (H5MP_get_pool_free_size(mp, &free_size) < 0)
- TEST_ERROR
- if (free_size != MPOOL_PAGE_SIZE - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t)))
- TEST_ERROR
-
- /* Check that free space totals match */
- if (H5MP_pool_is_free_size_correct(mp) <= 0)
- TEST_ERROR
-
- /* Close the memory pool */
- if (H5MP_close(mp) < 0)
- TEST_ERROR
-
- PASSED();
-
- TESTING("allocating large first block in pool");
-
- /* Create a memory pool */
- if (NULL == (mp = H5MP_create((size_t)MPOOL_PAGE_SIZE, MPOOL_FLAGS)))
- TEST_ERROR
-
- /* Allocate space in pool */
- if (NULL == (spc = H5MP_malloc(mp, (size_t)MPOOL_LARGE_BLOCK)))
- TEST_ERROR
-
- /* Check pool's free space */
- if (H5MP_get_pool_free_size(mp, &free_size) < 0)
- TEST_ERROR
- if (free_size != 0)
- TEST_ERROR
-
- /* Get first page */
- if (H5MP_get_pool_first_page(mp, &page) < 0)
- TEST_ERROR
- if (page == NULL)
- TEST_ERROR
-
- /* Check page's free space */
- if (H5MP_get_page_free_size(page, &free_size) < 0)
- TEST_ERROR
- if (free_size != 0)
- TEST_ERROR
-
- /* Check that free space totals match */
- if (H5MP_pool_is_free_size_correct(mp) <= 0)
- TEST_ERROR
-
- /* Check next page */
- if (H5MP_get_page_next_page(page, &page) < 0)
- TEST_ERROR
- if (page != NULL)
- TEST_ERROR
-
- /* Free space in pool */
- H5MP_free(mp, spc);
-
- /* Check pool's free space */
- if (H5MP_get_pool_free_size(mp, &free_size) < 0)
- TEST_ERROR
- if (free_size != MPOOL_LARGE_BLOCK + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t)))
- TEST_ERROR
-
- /* Check that free space totals match */
- if (H5MP_pool_is_free_size_correct(mp) <= 0)
- TEST_ERROR
-
- /* Close the memory pool */
- if (H5MP_close(mp) < 0)
- TEST_ERROR
-
- PASSED();
-
- return 0;
-
-error:
- H5E_BEGIN_TRY
- {
- if (mp)
- H5MP_close(mp);
- }
- H5E_END_TRY;
-
- return 1;
-} /* test_allocate_first() */
-
-/*-------------------------------------------------------------------------
- * Function: test_allocate_split
- *
- * Purpose: Tests allocating block in pool that requires splitting
- * existing block
- *
- * Return: Success: 0
- * Failure: 1
- *
- * Programmer: Quincey Koziol
- * Tuesday, May 3, 2005
- *
- *-------------------------------------------------------------------------
- */
-static int
-test_allocate_split(void)
-{
- H5MP_pool_t *mp; /* Memory pool */
- size_t free_size; /* Free size in pool */
- void * spc1; /* Pointer to space allocated */
- void * spc2; /* Pointer to space allocated */
-
- /*
- * Test memory pool allocation
- */
- TESTING("splitting block in pool");
-
- /* Create a memory pool */
- if (NULL == (mp = H5MP_create((size_t)MPOOL_PAGE_SIZE, MPOOL_FLAGS)))
- TEST_ERROR
-
- /* Allocate space in pool */
- if (NULL == (spc1 = H5MP_malloc(mp, (size_t)MPOOL_NORMAL_BLOCK)))
- TEST_ERROR
-
- /* Check pool's free space */
- if (H5MP_get_pool_free_size(mp, &free_size) < 0)
- TEST_ERROR
- if (free_size !=
- MPOOL_PAGE_SIZE - (H5MP_BLOCK_ALIGN(MPOOL_NORMAL_BLOCK) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t)) +
- H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t))))
- TEST_ERROR
-
- /* Check that free space totals match */
- if (H5MP_pool_is_free_size_correct(mp) <= 0)
- TEST_ERROR
-
- /* Allocate more space in pool */
- if (NULL == (spc2 = H5MP_malloc(mp, (size_t)MPOOL_NORMAL_BLOCK)))
- TEST_ERROR
-
- /* Check pool's free space */
- if (H5MP_get_pool_free_size(mp, &free_size) < 0)
- TEST_ERROR
- if (free_size !=
- MPOOL_PAGE_SIZE -
- (((H5MP_BLOCK_ALIGN(MPOOL_NORMAL_BLOCK) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t))) * 2) +
- H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t))))
- TEST_ERROR
-
- /* Check that free space totals match */
- if (H5MP_pool_is_free_size_correct(mp) <= 0)
- TEST_ERROR
-
- /* Free first block in pool */
- H5MP_free(mp, spc1);
-
- /* Check pool's free space */
- if (H5MP_get_pool_free_size(mp, &free_size) < 0)
- TEST_ERROR
- if (free_size !=
- MPOOL_PAGE_SIZE - (H5MP_BLOCK_ALIGN(MPOOL_NORMAL_BLOCK) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t)) +
- H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t))))
- TEST_ERROR
-
- /* Check that free space totals match */
- if (H5MP_pool_is_free_size_correct(mp) <= 0)
- TEST_ERROR
-
- /* Free second block in pool (should merge with first block) */
- H5MP_free(mp, spc2);
-
- /* Check pool's free space */
- if (H5MP_get_pool_free_size(mp, &free_size) < 0)
- TEST_ERROR
- if (free_size != MPOOL_PAGE_SIZE - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t)))
- TEST_ERROR
-
- /* Check that free space totals match */
- if (H5MP_pool_is_free_size_correct(mp) <= 0)
- TEST_ERROR
-
- /* Close the memory pool */
- if (H5MP_close(mp) < 0)
- TEST_ERROR
-
- PASSED();
-
- return 0;
-
-error:
- H5E_BEGIN_TRY
- {
- if (mp)
- H5MP_close(mp);
- }
- H5E_END_TRY;
-
- return 1;
-} /* test_allocate_split() */
-
-/*-------------------------------------------------------------------------
- * Function: test_allocate_many_small
- *
- * Purpose: Tests allocating many small blocks in a pool
- *
- * Return: Success: 0
- * Failure: 1
- *
- * Programmer: Quincey Koziol
- * Tuesday, May 6, 2005
- *
- *-------------------------------------------------------------------------
- */
-static int
-test_allocate_many_small(void)
-{
- H5MP_pool_t *mp; /* Memory pool */
- size_t free_size; /* Free size in pool */
- void * spc[MPOOL_NUM_SMALL_BLOCKS]; /* Pointers to space allocated */
- int i; /* Local index variable */
-
- /*
- * Test memory pool allocation
- */
- TESTING("allocating many small blocks");
-
- /* Create a memory pool */
- if (NULL == (mp = H5MP_create((size_t)MPOOL_PAGE_SIZE, MPOOL_FLAGS)))
- TEST_ERROR
-
- /* Allocate space in pool */
- for (i = 0; i < MPOOL_NUM_SMALL_BLOCKS; i++)
- if (NULL == (spc[i] = H5MP_malloc(mp, (size_t)MPOOL_SMALL_BLOCK)))
- TEST_ERROR
-
- /* Check pool's free space */
- if (H5MP_get_pool_free_size(mp, &free_size) < 0)
- TEST_ERROR
- if (free_size != MPOOL_PAGE_SIZE -
- (((H5MP_BLOCK_ALIGN(MPOOL_SMALL_BLOCK) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t))) *
- MPOOL_NUM_SMALL_BLOCKS) +
- H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t))))
- TEST_ERROR
-
- /* Check that free space totals match */
- if (H5MP_pool_is_free_size_correct(mp) <= 0)
- TEST_ERROR
-
- /* Free blocks in pool */
- /* (Tests free block merging with block after it */
- for (i = (MPOOL_NUM_SMALL_BLOCKS - 1); i >= 0; i--)
- H5MP_free(mp, spc[i]);
-
- /* Check pool's free space */
- if (H5MP_get_pool_free_size(mp, &free_size) < 0)
- TEST_ERROR
- if (free_size != MPOOL_PAGE_SIZE - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t)))
- TEST_ERROR
-
- /* Check that free space totals match */
- if (H5MP_pool_is_free_size_correct(mp) <= 0)
- TEST_ERROR
-
- /* Close the memory pool */
- if (H5MP_close(mp) < 0)
- TEST_ERROR
-
- PASSED();
-
- return 0;
-
-error:
- H5E_BEGIN_TRY
- {
- if (mp)
- H5MP_close(mp);
- }
- H5E_END_TRY;
-
- return 1;
-} /* test_allocate_many_small() */
-
-/*-------------------------------------------------------------------------
- * Function: test_allocate_new_page
- *
- * Purpose: Tests allocating block in pool that requires allocating
- * new page
- *
- * Return: Success: 0
- * Failure: 1
- *
- * Programmer: Quincey Koziol
- * Friday, May 6, 2005
- *
- *-------------------------------------------------------------------------
- */
-static int
-test_allocate_new_page(void)
-{
- H5MP_pool_t *mp; /* Memory pool */
- size_t free_size; /* Free size in pool */
- size_t u; /* Local index variable */
- void * spc[MPOOL_NUM_NORMAL_BLOCKS]; /* Pointer to space allocated */
- void * spc1; /* Pointer to space allocated */
- void * spc2; /* Pointer to space allocated */
-
- /*
- * Test memory pool allocation
- */
- TESTING("allocate normal-sized block in new page");
-
- /* Create a memory pool */
- if (NULL == (mp = H5MP_create((size_t)MPOOL_PAGE_SIZE, MPOOL_FLAGS)))
- TEST_ERROR
-
- /* Allocate space in pool */
- for (u = 0; u < MPOOL_NUM_NORMAL_BLOCKS; u++)
- if (NULL == (spc[u] = H5MP_malloc(mp, (size_t)MPOOL_NORMAL_BLOCK)))
- TEST_ERROR
-
- /* Check pool's free space */
- if (H5MP_get_pool_free_size(mp, &free_size) < 0)
- TEST_ERROR
- if (free_size != (MPOOL_PAGE_SIZE * 3) - (((H5MP_BLOCK_ALIGN(MPOOL_NORMAL_BLOCK) +
- H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t))) *
- MPOOL_NUM_NORMAL_BLOCKS) +
- (H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t)) * 3)))
- TEST_ERROR
-
- /* Check that free space totals match */
- if (H5MP_pool_is_free_size_correct(mp) <= 0)
- TEST_ERROR
-
- /* Free blocks in pool */
- /* (Free alternating blocks, in two passes, which tests block merging w/both neighbors) */
- for (u = 0; u < MPOOL_NUM_NORMAL_BLOCKS; u += 2)
- H5MP_free(mp, spc[u]);
- for (u = 1; u < MPOOL_NUM_NORMAL_BLOCKS; u += 2)
- H5MP_free(mp, spc[u]);
-
- /* Check pool's free space */
- if (H5MP_get_pool_free_size(mp, &free_size) < 0)
- TEST_ERROR
- if (free_size != ((MPOOL_PAGE_SIZE - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t))) * 3))
- TEST_ERROR
-
- /* Check that free space totals match */
- if (H5MP_pool_is_free_size_correct(mp) <= 0)
- TEST_ERROR
-
- /* Close the memory pool */
- if (H5MP_close(mp) < 0)
- TEST_ERROR
-
- PASSED();
-
- TESTING("allocate large-sized block in new page");
-
- /* Create a memory pool */
- if (NULL == (mp = H5MP_create((size_t)MPOOL_PAGE_SIZE, MPOOL_FLAGS)))
- TEST_ERROR
-
- /* Allocate space in pool */
- /* (Normal sized block) */
- if (NULL == (spc1 = H5MP_malloc(mp, (size_t)MPOOL_NORMAL_BLOCK)))
- TEST_ERROR
- /* (Larger sized block) */
- if (NULL == (spc2 = H5MP_malloc(mp, (size_t)MPOOL_LARGE_BLOCK)))
- TEST_ERROR
-
- /* Check pool's free space */
- if (H5MP_get_pool_free_size(mp, &free_size) < 0)
- TEST_ERROR
- if (free_size !=
- MPOOL_PAGE_SIZE - (H5MP_BLOCK_ALIGN(MPOOL_NORMAL_BLOCK) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t)) +
- H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t))))
- TEST_ERROR
-
- /* Check that free space totals match */
- if (H5MP_pool_is_free_size_correct(mp) <= 0)
- TEST_ERROR
-
- /* Free blocks in pool */
- H5MP_free(mp, spc1);
- H5MP_free(mp, spc2);
-
- /* Check pool's free space */
- if (H5MP_get_pool_free_size(mp, &free_size) < 0)
- TEST_ERROR
- if (free_size != ((MPOOL_PAGE_SIZE - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t))) + MPOOL_LARGE_BLOCK +
- H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t))))
- TEST_ERROR
-
- /* Check that free space totals match */
- if (H5MP_pool_is_free_size_correct(mp) <= 0)
- TEST_ERROR
-
- /* Close the memory pool */
- if (H5MP_close(mp) < 0)
- TEST_ERROR
-
- PASSED();
-
- return 0;
-
-error:
- H5E_BEGIN_TRY
- {
- if (mp)
- H5MP_close(mp);
- }
- H5E_END_TRY;
-
- return 1;
-} /* test_allocate_new_page() */
-
-/*-------------------------------------------------------------------------
- * Function: test_allocate_random
- *
- * Purpose: Tests allocating random sized blocks in pool
- *
- * Return: Success: 0
- * Failure: 1
- *
- * Programmer: Quincey Koziol
- * Friday, May 6, 2005
- *
- *-------------------------------------------------------------------------
- */
-static int
-test_allocate_random(void)
-{
- H5MP_pool_t *mp; /* Memory pool */
- size_t u; /* Local index variable */
- time_t curr_time; /* Current time, for seeding random number generator */
- size_t * blk_size = NULL; /* Pointer to block sizes */
- void ** spc = NULL; /* Pointer to space allocated */
- size_t swap_idx; /* Location to swap with when shuffling */
- void * swap_ptr; /* Pointer to swap when shuffling */
-
- /*
- * Test memory pool allocation
- */
- TESTING("allocate many random sized blocks");
-
- /* Initialize random number seed */
- curr_time = HDtime(NULL);
-#if 0
-curr_time=1115412944;
-HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time);
-#endif
- HDsrandom((unsigned)curr_time);
-
- /* Create a memory pool */
- if (NULL == (mp = H5MP_create((size_t)MPOOL_PAGE_SIZE, MPOOL_FLAGS)))
- TEST_ERROR
-
- /* Allocate space for the block sizes */
- if (NULL == (blk_size = (size_t *)HDmalloc(sizeof(size_t) * MPOOL_NUM_RANDOM)))
- TEST_ERROR
-
- /* Allocate space for the block pointers */
- if (NULL == (spc = (void **)HDmalloc(sizeof(void *) * MPOOL_NUM_RANDOM)))
- TEST_ERROR
-
- /* Initialize the block sizes with random values */
- for (u = 0; u < MPOOL_NUM_RANDOM; u++)
- blk_size[u] = (size_t)(HDrandom() % MPOOL_RANDOM_MAX_SIZE) + 1;
-
- /* Allocate space in pool */
- for (u = 0; u < MPOOL_NUM_RANDOM; u++)
- if (NULL == (spc[u] = H5MP_malloc(mp, blk_size[u])))
- TEST_ERROR
-
- /* Check that free space totals match */
- if (H5MP_pool_is_free_size_correct(mp) <= 0)
- TEST_ERROR
-
- /* Shuffle pointers to free */
- for (u = 0; u < MPOOL_NUM_RANDOM; u++) {
- swap_idx = (size_t)(HDrandom() % (int)(MPOOL_NUM_RANDOM - u)) + u;
- swap_ptr = spc[u];
- spc[u] = spc[swap_idx];
- spc[swap_idx] = swap_ptr;
- } /* end for */
-
- /* Free blocks in pool */
- for (u = 0; u < MPOOL_NUM_RANDOM; u++)
- H5MP_free(mp, spc[u]);
-
- /* Check that free space totals match */
- if (H5MP_pool_is_free_size_correct(mp) <= 0)
- TEST_ERROR
-
- /* Initialize the block sizes with random values */
- for (u = 0; u < MPOOL_NUM_RANDOM; u++)
- blk_size[u] = (size_t)(HDrandom() % MPOOL_RANDOM_MAX_SIZE) + 1;
-
- /* Allocate space in pool (again) */
- /* (Leave allocated to test closing pool with many blocks still allocated) */
- for (u = 0; u < MPOOL_NUM_RANDOM; u++)
- if (NULL == (spc[u] = H5MP_malloc(mp, blk_size[u])))
- TEST_ERROR
-
- /* Check that free space totals match */
- if (H5MP_pool_is_free_size_correct(mp) <= 0)
- TEST_ERROR
-
- /* Close the memory pool */
- if (H5MP_close(mp) < 0)
- TEST_ERROR
-
- /* Free memory for block sizes & pointers */
- HDfree(blk_size);
- HDfree(spc);
-
- PASSED();
-
- return 0;
-
-error:
- if (blk_size)
- HDfree(blk_size);
- if (spc)
- HDfree(spc);
- H5E_BEGIN_TRY
- {
- if (mp)
- H5MP_close(mp);
- }
- H5E_END_TRY;
-
- return 1;
-} /* test_allocate_random() */
-
-/*-------------------------------------------------------------------------
- * Function: main
- *
- * Purpose: Test the memory pool code
- *
- * Return: Success:
- * Failure:
- *
- * Programmer: Quincey Koziol
- * Tuesday, May 3, 2005
- *
- *-------------------------------------------------------------------------
- */
-int
-main(void)
-{
- int nerrors = 0;
-
- /* Reset library */
- h5_reset();
-
- /* Test memory pool creation */
- nerrors += test_create();
-
- /* Test memory pool space closing */
- nerrors += test_close_one();
-
- /* Test memory pool space allocation */
- nerrors += test_allocate_first();
- nerrors += test_allocate_split();
- nerrors += test_allocate_many_small();
- nerrors += test_allocate_new_page();
- nerrors += test_allocate_random();
-
- if (nerrors)
- goto error;
- HDputs("All memory pool tests passed.");
-
- return 0;
-
-error:
- HDputs("*** TESTS FAILED ***");
- return 1;
-}
diff --git a/test/testhdf5.c b/test/testhdf5.c
index dc5f0aa..b5db71b 100644
--- a/test/testhdf5.c
+++ b/test/testhdf5.c
@@ -45,7 +45,6 @@ main(int argc, char *argv[])
AddTest("config", test_configure, cleanup_configure, "Configure definitions", NULL);
AddTest("metadata", test_metadata, cleanup_metadata, "Encoding/decoding metadata", NULL);
AddTest("checksum", test_checksum, cleanup_checksum, "Checksum algorithm", NULL);
- AddTest("heap", test_heap, NULL, "Memory Heaps", NULL);
AddTest("skiplist", test_skiplist, NULL, "Skip Lists", NULL);
AddTest("refstr", test_refstr, NULL, "Reference Counted Strings", NULL);
AddTest("file", test_file, cleanup_file, "Low-Level File I/O", NULL);
diff --git a/test/testhdf5.h b/test/testhdf5.h
index ba5fa71..c5b8246 100644
--- a/test/testhdf5.h
+++ b/test/testhdf5.h
@@ -203,7 +203,6 @@ extern "C" {
/* Prototypes for the test routines */
void test_metadata(void);
void test_checksum(void);
-void test_heap(void);
void test_refstr(void);
void test_file(void);
void test_h5o(void);
diff --git a/test/theap.c b/test/theap.c
deleted file mode 100644
index 9d5787b..0000000
--- a/test/theap.c
+++ /dev/null
@@ -1,1081 +0,0 @@
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * 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. *
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
-/*
- Test HDF Heap routines.
-
- REMARKS
-
- DESIGN
-
- BUGS/LIMITATIONS
-
- EXPORTED ROUTINES
-
- AUTHOR
- Quincey Koziol
-
- MODIFICATION HISTORY
- 2/18/03 - Started coding
- */
-
-#include "testhdf5.h"
-#include "H5HPprivate.h"
-
-/* The number of elements in testing arrays */
-#define NUM_ELEMS 1000
-
-/* Objects for testing in heaps */
-typedef struct test_obj {
- H5HP_info_t heap_info; /* Information required for heap. _MUST_ be first */
- int val; /* Actual information for object */
-} test_obj;
-
-/* Array of random element values */
-static test_obj *rand_num;
-
-/* Array of random elements values, sorted in increasing order */
-static test_obj *inc_sort_num;
-
-/* Array of random elements values, sorted in decreasing order */
-static test_obj *dec_sort_num;
-
-static int
-tst_dec_sort(const void *_i1, const void *_i2)
-{
- const test_obj *i1 = (const test_obj *)_i1;
- const test_obj *i2 = (const test_obj *)_i2;
-
- if (i1->val < i2->val)
- return (1);
- else if (i1->val > i2->val)
- return (-1);
- return (0);
-}
-
-static int
-tst_inc_sort(const void *_i1, const void *_i2)
-{
- const test_obj *i1 = (const test_obj *)_i1;
- const test_obj *i2 = (const test_obj *)_i2;
-
- if (i1->val < i2->val)
- return (-1);
- else if (i1->val > i2->val)
- return (1);
- return (0);
-}
-
-/****************************************************************
-**
-** test_heap_init(): Test H5HP (heap) code.
-** Initialize data for Heap testing
-**
-****************************************************************/
-static void
-test_heap_init(void)
-{
- time_t curr_time; /* Current time, for seeding random number generator */
- size_t u; /* Local index variables */
-
- /* Allocate arrays */
- rand_num = (test_obj *)HDmalloc(sizeof(test_obj) * NUM_ELEMS);
- CHECK_PTR(rand_num, "HDmalloc");
- inc_sort_num = (test_obj *)HDmalloc(sizeof(test_obj) * NUM_ELEMS);
- CHECK_PTR(inc_sort_num, "HDmalloc");
- dec_sort_num = (test_obj *)HDmalloc(sizeof(test_obj) * NUM_ELEMS);
- CHECK_PTR(dec_sort_num, "HDmalloc");
-
- /* Create randomized set of numbers */
- curr_time = HDtime(NULL);
- HDsrandom((unsigned)curr_time);
- for (u = 0; u < NUM_ELEMS; u++)
- /* Generate random numbers from -1000 to 1000 */
- rand_num[u].val = (int)(HDrandom() % 2001) - 1001;
-
- /* Sort random numbers into increasing order */
- HDmemcpy(inc_sort_num, rand_num, sizeof(test_obj) * NUM_ELEMS);
- HDqsort(inc_sort_num, (size_t)NUM_ELEMS, sizeof(test_obj), tst_inc_sort);
-
- /* Sort random numbers into decreasing order */
- HDmemcpy(dec_sort_num, rand_num, sizeof(test_obj) * NUM_ELEMS);
- HDqsort(dec_sort_num, (size_t)NUM_ELEMS, sizeof(test_obj), tst_dec_sort);
-} /* end test_heap_init() */
-
-/****************************************************************
-**
-** test_heap_create(): Test basic H5HP (heap) code.
-** Tests creating and closing heaps.
-**
-****************************************************************/
-static void
-test_heap_create(void)
-{
- H5HP_t *heap; /* Heap created */
- herr_t ret; /* Generic return value */
-
- /* Output message about test being performed */
- MESSAGE(6, ("Testing Creating & Closing Heaps\n"));
-
- /* Try creating a maximum Heap */
- heap = H5HP_create(H5HP_MAX_HEAP);
- CHECK_PTR(heap, "H5HP_create");
-
- /* Try closing the heap */
- ret = H5HP_close(heap);
- CHECK(ret, FAIL, "H5HP_close");
-
- /* Try creating a minimum Heap */
- heap = H5HP_create(H5HP_MIN_HEAP);
- CHECK_PTR(heap, "H5HP_create");
-
- /* Try closing the heap */
- ret = H5HP_close(heap);
- CHECK(ret, FAIL, "H5HP_close");
-
-} /* end test_heap_create() */
-
-/****************************************************************
-**
-** test_heap_insert_min(): Test H5HP (heap) code.
-** Tests basic inserting objects into minimum heaps.
-**
-****************************************************************/
-static void
-test_heap_insert_min(void)
-{
- H5HP_t * heap; /* Heap created */
- ssize_t num; /* Number of elements in heap */
- int val; /* Value of object on heap */
- test_obj obj1, obj2, obj3; /* Test objects to insert */
- herr_t ret; /* Generic return value */
-
- /* Output message about test being performed */
- MESSAGE(7, ("Testing Inserting Into Minimum Heaps\n"));
-
- /* Create a Heap */
- heap = H5HP_create(H5HP_MIN_HEAP);
- CHECK_PTR(heap, "H5HP_create");
-
- /* Check that the heap has no elements */
- num = H5HP_count(heap);
- VERIFY(num, 0, "H5HP_count");
-
- /* Insert an object into the heap */
- obj1.val = 100;
- ret = H5HP_insert(heap, 10, &obj1);
- CHECK(ret, FAIL, "H5HP_insert");
-
- /* Check that the heap has one element */
- num = H5HP_count(heap);
- VERIFY(num, 1, "H5HP_count");
-
- /* Check the minimum value on the heap */
- ret = H5HP_top(heap, &val);
- CHECK(ret, FAIL, "H5HP_top");
- VERIFY(val, 10, "H5HP_top");
-
- /* Insert another object into the heap, with value less than top element */
- obj2.val = 50;
- ret = H5HP_insert(heap, 5, &obj2);
- CHECK(ret, FAIL, "H5HP_insert");
-
- /* Check that the heap has two elements */
- num = H5HP_count(heap);
- VERIFY(num, 2, "H5HP_count");
-
- /* Check the minimum value on the heap */
- ret = H5HP_top(heap, &val);
- CHECK(ret, FAIL, "H5HP_top");
- VERIFY(val, 5, "H5HP_top");
-
- /* Insert third object into the heap, with value greater than top element */
- obj3.val = 200;
- ret = H5HP_insert(heap, 20, &obj3);
- CHECK(ret, FAIL, "H5HP_insert");
-
- /* Check that the heap has three elements */
- num = H5HP_count(heap);
- VERIFY(num, 3, "H5HP_count");
-
- /* Check the minimum value on the heap */
- ret = H5HP_top(heap, &val);
- CHECK(ret, FAIL, "H5HP_top");
- VERIFY(val, 5, "H5HP_top");
-
- /* Close the heap */
- ret = H5HP_close(heap);
- CHECK(ret, FAIL, "H5HP_close");
-
-} /* end test_heap_insert_min() */
-
-/****************************************************************
-**
-** test_heap_insert(): Test H5HP (heap) code.
-** Tests basic inserting objects into maximum heaps.
-**
-****************************************************************/
-static void
-test_heap_insert_max(void)
-{
- H5HP_t * heap; /* Heap created */
- ssize_t num; /* Number of elements in heap */
- int val; /* Value of object on heap */
- test_obj obj1, obj2, obj3; /* Test objects to insert */
- herr_t ret; /* Generic return value */
-
- /* Output message about test being performed */
- MESSAGE(7, ("Testing Inserting Into Maximum Heaps\n"));
-
- /* Create a Heap */
- heap = H5HP_create(H5HP_MAX_HEAP);
- CHECK_PTR(heap, "H5HP_create");
-
- /* Check that the heap has no elements */
- num = H5HP_count(heap);
- VERIFY(num, 0, "H5HP_count");
-
- /* Insert an object into the heap */
- obj1.val = 100;
- ret = H5HP_insert(heap, 10, &obj1);
- CHECK(ret, FAIL, "H5HP_insert");
-
- /* Check that the heap has one element */
- num = H5HP_count(heap);
- VERIFY(num, 1, "H5HP_count");
-
- /* Check the maximum value on the heap */
- ret = H5HP_top(heap, &val);
- CHECK(ret, FAIL, "H5HP_top");
- VERIFY(val, 10, "H5HP_top");
-
- /* Insert another object into the heap, with value less than top element */
- obj2.val = 50;
- ret = H5HP_insert(heap, 5, &obj2);
- CHECK(ret, FAIL, "H5HP_insert");
-
- /* Check that the heap has two elements */
- num = H5HP_count(heap);
- VERIFY(num, 2, "H5HP_count");
-
- /* Check the maximum value on the heap */
- ret = H5HP_top(heap, &val);
- CHECK(ret, FAIL, "H5HP_top");
- VERIFY(val, 10, "H5HP_top");
-
- /* Insert third object into the heap, with value greater than top element */
- obj3.val = 200;
- ret = H5HP_insert(heap, 20, &obj3);
- CHECK(ret, FAIL, "H5HP_insert");
-
- /* Check that the heap has three elements */
- num = H5HP_count(heap);
- VERIFY(num, 3, "H5HP_count");
-
- /* Check the maximum value on the heap */
- ret = H5HP_top(heap, &val);
- CHECK(ret, FAIL, "H5HP_top");
- VERIFY(val, 20, "H5HP_top");
-
- /* Close the heap */
- ret = H5HP_close(heap);
- CHECK(ret, FAIL, "H5HP_close");
-
-} /* end test_heap_insert_max() */
-
-/****************************************************************
-**
-** test_heap_insert(): Test H5HP (heap) code.
-** Tests basic inserting objects into heaps.
-**
-****************************************************************/
-static void
-test_heap_insert(void)
-{
- /* Output message about test being performed */
- MESSAGE(6, ("Testing Inserting Into Heaps\n"));
-
- /* Test insertions into minimum & maximum heaps */
- test_heap_insert_max();
- test_heap_insert_min();
-} /* end test_heap_insert() */
-
-/****************************************************************
-**
-** test_heap_insert_many_core (): Tests H5HP (heap) code.
-** "Core" routine called by test_heap_insert_many() routine.
-**
-****************************************************************/
-static void
-test_heap_insert_many_core(H5HP_type_t heap_type, test_obj *arr, size_t nelem, int top_val)
-{
- H5HP_t *heap; /* Heap created */
- ssize_t num; /* Number of elements in heap */
- int val; /* Value of object on heap */
- size_t u; /* Local index variable */
- herr_t ret; /* Generic return value */
-
- /* Create a Heap */
- heap = H5HP_create(heap_type);
- CHECK_PTR(heap, "H5HP_create");
-
- /* Check that the heap has no elements */
- num = H5HP_count(heap);
- VERIFY(num, 0, "H5HP_count");
-
- /* Insert the array elements into the heap */
- for (u = 0; u < nelem; u++) {
- ret = H5HP_insert(heap, arr[u].val, &arr[u]);
- CHECK(ret, FAIL, "H5HP_insert");
- } /* end for */
-
- /* Check that the heap has correct number of elements */
- num = H5HP_count(heap);
- CHECK(num, FAIL, "H5HP_count");
- VERIFY((size_t)num, nelem, "H5HP_count");
-
- /* Check the maximum value on the heap */
- ret = H5HP_top(heap, &val);
- CHECK(ret, FAIL, "H5HP_top");
- VERIFY(val, top_val, "H5HP_top");
-
- /* Close the heap */
- ret = H5HP_close(heap);
- CHECK(ret, FAIL, "H5HP_close");
-} /* end test_heap_insert_many_core() */
-
-/****************************************************************
-**
-** test_heap_insert_many (): Test H5HP (heap) code.
-** Tests inserting many objects into heaps.
-**
-****************************************************************/
-static void
-test_heap_insert_many(void)
-{
- /* Output message about test being performed */
- MESSAGE(6, ("Testing Inserting Many Objects Into Heaps\n"));
-
- /* Test creating a heap from random elements */
- test_heap_insert_many_core(H5HP_MAX_HEAP, rand_num, (size_t)NUM_ELEMS, dec_sort_num[0].val);
-
- /* Test creating a heap from elements in increasing order */
- test_heap_insert_many_core(H5HP_MAX_HEAP, inc_sort_num, (size_t)NUM_ELEMS, dec_sort_num[0].val);
-
- /* Test creating a heap from elements in decreasing order */
- test_heap_insert_many_core(H5HP_MAX_HEAP, dec_sort_num, (size_t)NUM_ELEMS, dec_sort_num[0].val);
-
- /* Test creating a heap from random elements */
- test_heap_insert_many_core(H5HP_MIN_HEAP, rand_num, (size_t)NUM_ELEMS, inc_sort_num[0].val);
-
- /* Test creating a heap from elements in increasing order */
- test_heap_insert_many_core(H5HP_MIN_HEAP, inc_sort_num, (size_t)NUM_ELEMS, inc_sort_num[0].val);
-
- /* Test creating a heap from elements in decreasing order */
- test_heap_insert_many_core(H5HP_MIN_HEAP, dec_sort_num, (size_t)NUM_ELEMS, inc_sort_num[0].val);
-
-} /* end test_heap_insert_many() */
-
-/****************************************************************
-**
-** test_heap_remove_min(): Test H5HP (heap) code.
-** Tests basic removal of objects from minimum heaps.
-**
-****************************************************************/
-static void
-test_heap_remove_min(void)
-{
- H5HP_t * heap; /* Heap created */
- ssize_t num; /* Number of elements in heap */
- int val; /* Value of object on heap */
- void * ptr; /* Pointer for object on heap */
- test_obj obj1, obj2, obj3; /* Test objects to insert */
- herr_t ret; /* Generic return value */
-
- /* Output message about test being performed */
- MESSAGE(7, ("Testing Removing From Minimum Heaps\n"));
-
- /* Create a Heap */
- heap = H5HP_create(H5HP_MIN_HEAP);
- CHECK_PTR(heap, "H5HP_create");
-
- /* Check that the heap has no elements */
- num = H5HP_count(heap);
- VERIFY(num, 0, "H5HP_count");
-
- /* Try removing an object from an empty heap */
- ret = H5HP_remove(heap, &val, &ptr);
- VERIFY(ret, FAIL, "H5HP_remove");
-
- /* Insert an object into the heap */
- obj1.val = 100;
- ret = H5HP_insert(heap, 10, &obj1);
- CHECK(ret, FAIL, "H5HP_insert");
-
- /* Insert another object into the heap, with value less than top element */
- obj2.val = 50;
- ret = H5HP_insert(heap, 5, &obj2);
- CHECK(ret, FAIL, "H5HP_insert");
-
- /* Insert third object into the heap, with value greater than top element */
- obj3.val = 200;
- ret = H5HP_insert(heap, 20, &obj3);
- CHECK(ret, FAIL, "H5HP_insert");
-
- /* Remove first maximum value from heap */
- ret = H5HP_remove(heap, &val, &ptr);
- CHECK(ret, FAIL, "H5HP_remove");
- VERIFY(val, 5, "H5HP_remove");
- CHECK_PTR_EQ(ptr, &obj2, "H5HP_remove");
-
- /* Remove second maximum value from heap */
- ret = H5HP_remove(heap, &val, &ptr);
- CHECK(ret, FAIL, "H5HP_remove");
- VERIFY(val, 10, "H5HP_remove");
- CHECK_PTR_EQ(ptr, &obj1, "H5HP_remove");
-
- /* Remove third maximum value from heap */
- ret = H5HP_remove(heap, &val, &ptr);
- CHECK(ret, FAIL, "H5HP_remove");
- VERIFY(val, 20, "H5HP_remove");
- CHECK_PTR_EQ(ptr, &obj3, "H5HP_remove");
-
- /* Try removing an object from an empty heap */
- ret = H5HP_remove(heap, &val, &ptr);
- VERIFY(ret, FAIL, "H5HP_remove");
-
- /* Close the heap */
- ret = H5HP_close(heap);
- CHECK(ret, FAIL, "H5HP_close");
-
-} /* end test_heap_remove_min() */
-
-/****************************************************************
-**
-** test_heap_remove_max(): Test H5HP (heap) code.
-** Tests basic removal of objects from maximum heaps.
-**
-****************************************************************/
-static void
-test_heap_remove_max(void)
-{
- H5HP_t * heap; /* Heap created */
- ssize_t num; /* Number of elements in heap */
- int val; /* Value of object on heap */
- void * ptr; /* Pointer for object on heap */
- test_obj obj1, obj2, obj3; /* Test objects to insert */
- herr_t ret; /* Generic return value */
-
- /* Output message about test being performed */
- MESSAGE(7, ("Testing Removing From Maximum Heaps\n"));
-
- /* Create a Heap */
- heap = H5HP_create(H5HP_MAX_HEAP);
- CHECK_PTR(heap, "H5HP_create");
-
- /* Check that the heap has no elements */
- num = H5HP_count(heap);
- VERIFY(num, 0, "H5HP_count");
-
- /* Try removing an object from an empty heap */
- ret = H5HP_remove(heap, &val, &ptr);
- VERIFY(ret, FAIL, "H5HP_remove");
-
- /* Insert an object into the heap */
- obj1.val = 100;
- ret = H5HP_insert(heap, 10, &obj1);
- CHECK(ret, FAIL, "H5HP_insert");
-
- /* Insert another object into the heap, with value less than top element */
- obj2.val = 50;
- ret = H5HP_insert(heap, 5, &obj2);
- CHECK(ret, FAIL, "H5HP_insert");
-
- /* Insert third object into the heap, with value greater than top element */
- obj3.val = 200;
- ret = H5HP_insert(heap, 20, &obj3);
- CHECK(ret, FAIL, "H5HP_insert");
-
- /* Remove first maximum value from heap */
- ret = H5HP_remove(heap, &val, &ptr);
- CHECK(ret, FAIL, "H5HP_remove");
- VERIFY(val, 20, "H5HP_remove");
- CHECK_PTR_EQ(ptr, &obj3, "H5HP_remove");
-
- /* Remove second maximum value from heap */
- ret = H5HP_remove(heap, &val, &ptr);
- CHECK(ret, FAIL, "H5HP_remove");
- VERIFY(val, 10, "H5HP_remove");
- CHECK_PTR_EQ(ptr, &obj1, "H5HP_remove");
-
- /* Remove third maximum value from heap */
- ret = H5HP_remove(heap, &val, &ptr);
- CHECK(ret, FAIL, "H5HP_remove");
- VERIFY(val, 5, "H5HP_remove");
- CHECK_PTR_EQ(ptr, &obj2, "H5HP_remove");
-
- /* Try removing an object from an empty heap */
- ret = H5HP_remove(heap, &val, &ptr);
- VERIFY(ret, FAIL, "H5HP_remove");
-
- /* Close the heap */
- ret = H5HP_close(heap);
- CHECK(ret, FAIL, "H5HP_close");
-
-} /* end test_heap_remove_max() */
-
-/****************************************************************
-**
-** test_heap_remove(): Test H5HP (heap) code.
-** Tests basic removal of objects from minimum & maximum heaps.
-**
-****************************************************************/
-static void
-test_heap_remove(void)
-{
- /* Output message about test being performed */
- MESSAGE(6, ("Testing Removing From Heaps\n"));
-
- /* Test removals from minimum & maximum heaps */
- test_heap_remove_max();
- test_heap_remove_min();
-} /* end test_heap_remove() */
-
-/****************************************************************
-**
-** test_heap_remove_many_core (): Tests H5HP (heap) code.
-** "Core" routine called by test_heap_remove_many() routine.
-**
-****************************************************************/
-static void
-test_heap_remove_many_core(H5HP_type_t heap_type, test_obj *arr, size_t nelem)
-{
- H5HP_t * heap; /* Heap created */
- ssize_t num; /* Number of elements in heap */
- int last_val; /* Last value from the heap */
- int val; /* Value of object on heap */
- test_obj *ptr; /* Pointer for object on heap */
- size_t u; /* Local index variable */
- herr_t ret; /* Generic return value */
-
- /* Create a Heap */
- heap = H5HP_create(heap_type);
- CHECK_PTR(heap, "H5HP_create");
-
- /* Check that the heap has no elements */
- num = H5HP_count(heap);
- VERIFY(num, 0, "H5HP_count");
-
- /* Insert the array elements into the heap */
- for (u = 0; u < nelem; u++) {
- ret = H5HP_insert(heap, arr[u].val, &arr[u]);
- CHECK(ret, FAIL, "H5HP_insert");
- } /* end for */
-
- /* Check that the heap has correct number of elements */
- num = H5HP_count(heap);
- CHECK(num, FAIL, "H5HP_count");
- VERIFY((size_t)num, nelem, "H5HP_count");
-
- /* Set an appropriate starting value for the "last" value from heap */
- if (heap_type == H5HP_MAX_HEAP)
- last_val = INT_MAX;
- else
- last_val = INT_MIN;
-
- /* Remove the objects from the heap */
- for (u = 0; u < nelem; u++) {
- ret = H5HP_remove(heap, &val, (void **)&ptr);
- CHECK(ret, FAIL, "H5HP_remove");
- VERIFY(val, ptr->val, "H5HP_remove");
-
- /* Check that the value is correct, based on the heap type */
- if (heap_type == H5HP_MAX_HEAP) {
- if (val > last_val)
- TestErrPrintf("Error on line %d: incorrect value from heap=%d, last_val=%d\n", __LINE__, val,
- last_val);
- } /* end if */
- else {
- if (val < last_val)
- TestErrPrintf("Error on line %d: incorrect value from heap=%d, last_val=%d\n", __LINE__, val,
- last_val);
- } /* end else */
-
- /* Update last value */
- last_val = val;
- } /* end for */
-
- /* Check that the heap has no elements */
- num = H5HP_count(heap);
- VERIFY(num, 0, "H5HP_count");
-
- /* Insert & remove again, to check that completely empty heaps can be added again */
-
- /* Set an appropriate starting value for the "last" value from heap */
- if (heap_type == H5HP_MAX_HEAP)
- last_val = INT_MAX;
- else
- last_val = INT_MIN;
-
- /* Insert the array elements into the heap */
- for (u = 0; u < nelem; u++) {
- ret = H5HP_insert(heap, arr[u].val, &arr[u]);
- CHECK(ret, FAIL, "H5HP_insert");
- } /* end for */
-
- /* Check that the heap has correct number of elements */
- num = H5HP_count(heap);
- CHECK(num, FAIL, "H5HP_count");
- VERIFY((size_t)num, nelem, "H5HP_count");
-
- /* Remove the objects from the heap */
- for (u = 0; u < nelem; u++) {
- ret = H5HP_remove(heap, &val, (void **)&ptr);
- CHECK(ret, FAIL, "H5HP_remove");
- VERIFY(val, ptr->val, "H5HP_remove");
-
- /* Check that the value is correct, based on the heap type */
- if (heap_type == H5HP_MAX_HEAP) {
- if (val > last_val)
- TestErrPrintf("Error on line %d: incorrect value from heap=%d, last_val=%d\n", __LINE__, val,
- last_val);
- } /* end if */
- else {
- if (val < last_val)
- TestErrPrintf("Error on line %d: incorrect value from heap=%d, last_val=%d\n", __LINE__, val,
- last_val);
- } /* end else */
-
- /* Update last value */
- last_val = val;
- } /* end for */
-
- /* Check that the heap has no elements */
- num = H5HP_count(heap);
- VERIFY(num, 0, "H5HP_count");
-
- /* Close the heap */
- ret = H5HP_close(heap);
- CHECK(ret, FAIL, "H5HP_close");
-} /* end test_heap_remove_many_core() */
-
-/****************************************************************
-**
-** test_heap_remove_many (): Test H5HP (heap) code.
-** Tests removing many objects into heaps.
-**
-****************************************************************/
-static void
-test_heap_remove_many(void)
-{
- /* Output message about test being performed */
- MESSAGE(6, ("Testing Removing Many Objects From Heaps\n"));
-
- /* Test removing objects from maximum heap with random elements */
- test_heap_remove_many_core(H5HP_MAX_HEAP, rand_num, (size_t)NUM_ELEMS);
-
- /* Test removing objects from maximum heap with elements already sorted in increasing order */
- test_heap_remove_many_core(H5HP_MAX_HEAP, inc_sort_num, (size_t)NUM_ELEMS);
-
- /* Test removing objects from maximum heap with elements already sorted in decreasing order */
- test_heap_remove_many_core(H5HP_MAX_HEAP, dec_sort_num, (size_t)NUM_ELEMS);
-
- /* Test removing objects from minimum heap with random elements */
- test_heap_remove_many_core(H5HP_MIN_HEAP, rand_num, (size_t)NUM_ELEMS);
-
- /* Test removing objects from minimum heap with elements already sorted in increasing order */
- test_heap_remove_many_core(H5HP_MIN_HEAP, inc_sort_num, (size_t)NUM_ELEMS);
-
- /* Test removing objects from minimum heap with elements already sorted in decreasing order */
- test_heap_remove_many_core(H5HP_MIN_HEAP, dec_sort_num, (size_t)NUM_ELEMS);
-
-} /* end test_heap_remove_many() */
-
-/****************************************************************
-**
-** test_heap_change_min (): Test H5HP (heap) code.
-** Tests changing the priority of an object in a minimum heap
-**
-****************************************************************/
-static void
-test_heap_change_min(void)
-{
- H5HP_t * heap; /* Heap created */
- ssize_t num; /* Number of elements in heap */
- int val; /* Value of object on heap */
- test_obj obj1, obj2, obj3; /* Test objects to insert */
- herr_t ret; /* Generic return value */
-
- /* Output message about test being performed */
- MESSAGE(7, ("Testing Changing Priority of Objects in Minimum Heaps\n"));
-
- /* Create a Heap */
- heap = H5HP_create(H5HP_MIN_HEAP);
- CHECK_PTR(heap, "H5HP_create");
-
- /* Check that the heap has no elements */
- num = H5HP_count(heap);
- VERIFY(num, 0, "H5HP_count");
-
- /* Insert an object into the heap */
- obj1.val = 100;
- ret = H5HP_insert(heap, 10, &obj1);
- CHECK(ret, FAIL, "H5HP_insert");
-
- /* Insert another object into the heap, with value less than top element */
- obj2.val = 50;
- ret = H5HP_insert(heap, 5, &obj2);
- CHECK(ret, FAIL, "H5HP_insert");
-
- /* Insert third object into the heap, with value greater than top element */
- obj3.val = 200;
- ret = H5HP_insert(heap, 20, &obj3);
- CHECK(ret, FAIL, "H5HP_insert");
-
- /* Change priority of first object on heap in way which shouldn't affect heap order */
- ret = H5HP_change(heap, 11, &obj1);
- CHECK(ret, FAIL, "H5HP_change");
-
- /* Check the minimum value on the heap */
- ret = H5HP_top(heap, &val);
- CHECK(ret, FAIL, "H5HP_top");
- VERIFY(val, 5, "H5HP_top");
-
- /* Change priority of first object on heap to be the top object on the heap */
- ret = H5HP_change(heap, 3, &obj1);
- CHECK(ret, FAIL, "H5HP_change");
-
- /* Check the maximum value on the heap */
- ret = H5HP_top(heap, &val);
- CHECK(ret, FAIL, "H5HP_top");
- VERIFY(val, 3, "H5HP_top");
-
- /* Change priority of first object on heap to not be the top object on the heap */
- ret = H5HP_change(heap, 10, &obj1);
- CHECK(ret, FAIL, "H5HP_change");
-
- /* Check the maximum value on the heap */
- ret = H5HP_top(heap, &val);
- CHECK(ret, FAIL, "H5HP_top");
- VERIFY(val, 5, "H5HP_top");
-
- /* Close the heap */
- ret = H5HP_close(heap);
- CHECK(ret, FAIL, "H5HP_close");
-
-} /* end test_heap_change_min() */
-
-/****************************************************************
-**
-** test_heap_change_max (): Test H5HP (heap) code.
-** Tests changing the priority of an object in a maximumheap
-**
-****************************************************************/
-static void
-test_heap_change_max(void)
-{
- H5HP_t * heap; /* Heap created */
- ssize_t num; /* Number of elements in heap */
- int val; /* Value of object on heap */
- test_obj obj1, obj2, obj3; /* Test objects to insert */
- herr_t ret; /* Generic return value */
-
- /* Output message about test being performed */
- MESSAGE(7, ("Testing Changing Priority of Objects in Maximum Heaps\n"));
-
- /* Create a Heap */
- heap = H5HP_create(H5HP_MAX_HEAP);
- CHECK_PTR(heap, "H5HP_create");
-
- /* Check that the heap has no elements */
- num = H5HP_count(heap);
- VERIFY(num, 0, "H5HP_count");
-
- /* Insert an object into the heap */
- obj1.val = 100;
- ret = H5HP_insert(heap, 10, &obj1);
- CHECK(ret, FAIL, "H5HP_insert");
-
- /* Insert another object into the heap, with value less than top element */
- obj2.val = 50;
- ret = H5HP_insert(heap, 5, &obj2);
- CHECK(ret, FAIL, "H5HP_insert");
-
- /* Insert third object into the heap, with value greater than top element */
- obj3.val = 200;
- ret = H5HP_insert(heap, 20, &obj3);
- CHECK(ret, FAIL, "H5HP_insert");
-
- /* Change priority of first object on heap in way which shouldn't affect heap order */
- ret = H5HP_change(heap, 11, &obj1);
- CHECK(ret, FAIL, "H5HP_change");
-
- /* Check the maximum value on the heap */
- ret = H5HP_top(heap, &val);
- CHECK(ret, FAIL, "H5HP_top");
- VERIFY(val, 20, "H5HP_top");
-
- /* Change priority of first object on heap to be the top object on the heap */
- ret = H5HP_change(heap, 21, &obj1);
- CHECK(ret, FAIL, "H5HP_change");
-
- /* Check the maximum value on the heap */
- ret = H5HP_top(heap, &val);
- CHECK(ret, FAIL, "H5HP_top");
- VERIFY(val, 21, "H5HP_top");
-
- /* Change priority of first object on heap to not be the top object on the heap */
- ret = H5HP_change(heap, 10, &obj1);
- CHECK(ret, FAIL, "H5HP_change");
-
- /* Check the maximum value on the heap */
- ret = H5HP_top(heap, &val);
- CHECK(ret, FAIL, "H5HP_top");
- VERIFY(val, 20, "H5HP_top");
-
- /* Close the heap */
- ret = H5HP_close(heap);
- CHECK(ret, FAIL, "H5HP_close");
-
-} /* end test_heap_change() */
-
-/****************************************************************
-**
-** test_heap_change (): Test H5HP (heap) code.
-** Tests changing the priority of an object in maximum & minimum heaps
-**
-****************************************************************/
-static void
-test_heap_change(void)
-{
- /* Output message about test being performed */
- MESSAGE(6, ("Testing Changing Priority of Objects in Heaps\n"));
-
- /* Test removals from minimum & maximum heaps */
- test_heap_change_max();
- test_heap_change_min();
-} /* end test_heap_change() */
-
-/****************************************************************
-**
-** test_heap_incdec_min (): Test H5HP (heap) code.
-** Tests incrementing & decrementing priority of objects on
-** a minimum heap.
-**
-****************************************************************/
-static void
-test_heap_incdec_min(void)
-{
- H5HP_t * heap; /* Heap created */
- ssize_t num; /* Number of elements in heap */
- int val; /* Value of object on heap */
- test_obj obj1, obj2, obj3; /* Test objects to insert */
- herr_t ret; /* Generic return value */
-
- /* Output message about test being performed */
- MESSAGE(7, ("Testing Incrementing & Decrementing Priority of Objects in Minimum Heaps\n"));
-
- /* Create a Heap */
- heap = H5HP_create(H5HP_MIN_HEAP);
- CHECK_PTR(heap, "H5HP_create");
-
- /* Check that the heap has no elements */
- num = H5HP_count(heap);
- VERIFY(num, 0, "H5HP_count");
-
- /* Insert an object into the heap */
- obj1.val = 100;
- ret = H5HP_insert(heap, 6, &obj1);
- CHECK(ret, FAIL, "H5HP_insert");
-
- /* Insert another object into the heap, with value less than top element */
- obj2.val = 50;
- ret = H5HP_insert(heap, 5, &obj2);
- CHECK(ret, FAIL, "H5HP_insert");
-
- /* Insert third object into the heap, with value greater than top element */
- obj3.val = 200;
- ret = H5HP_insert(heap, 20, &obj3);
- CHECK(ret, FAIL, "H5HP_insert");
-
- /* Decrement object one's priority by two to put it on top of the heap */
- ret = H5HP_decr(heap, 2, &obj1);
- CHECK(ret, FAIL, "H5HP_change");
-
- /* Check the minimum value on the heap */
- ret = H5HP_top(heap, &val);
- CHECK(ret, FAIL, "H5HP_top");
- VERIFY(val, 4, "H5HP_top");
-
- /* Decrement object two's priority by two to put it back on top of the heap */
- ret = H5HP_decr(heap, 2, &obj2);
- CHECK(ret, FAIL, "H5HP_change");
-
- /* Check the minimum value on the heap */
- ret = H5HP_top(heap, &val);
- CHECK(ret, FAIL, "H5HP_top");
- VERIFY(val, 3, "H5HP_top");
-
- /* Increment object two's priority by two to return object one to the top */
- ret = H5HP_incr(heap, 2, &obj2);
- CHECK(ret, FAIL, "H5HP_change");
-
- /* Check the minimum value on the heap */
- ret = H5HP_top(heap, &val);
- CHECK(ret, FAIL, "H5HP_top");
- VERIFY(val, 4, "H5HP_top");
-
- /* Close the heap */
- ret = H5HP_close(heap);
- CHECK(ret, FAIL, "H5HP_close");
-
-} /* end test_heap_incdec_min() */
-
-/****************************************************************
-**
-** test_heap_incdec_max (): Test H5HP (heap) code.
-** Tests incrementing & decrementing priority of objects on
-** a maximum heap.
-**
-****************************************************************/
-static void
-test_heap_incdec_max(void)
-{
- H5HP_t * heap; /* Heap created */
- ssize_t num; /* Number of elements in heap */
- int val; /* Value of object on heap */
- test_obj obj1, obj2, obj3; /* Test objects to insert */
- herr_t ret; /* Generic return value */
-
- /* Output message about test being performed */
- MESSAGE(7, ("Testing Incrementing & Decrementing Priority of Objects in Maximum Heaps\n"));
-
- /* Create a Heap */
- heap = H5HP_create(H5HP_MAX_HEAP);
- CHECK_PTR(heap, "H5HP_create");
-
- /* Check that the heap has no elements */
- num = H5HP_count(heap);
- VERIFY(num, 0, "H5HP_count");
-
- /* Insert an object into the heap */
- obj1.val = 100;
- ret = H5HP_insert(heap, 19, &obj1);
- CHECK(ret, FAIL, "H5HP_insert");
-
- /* Insert another object into the heap, with value less than top element */
- obj2.val = 50;
- ret = H5HP_insert(heap, 5, &obj2);
- CHECK(ret, FAIL, "H5HP_insert");
-
- /* Insert third object into the heap, with value greater than top element */
- obj3.val = 200;
- ret = H5HP_insert(heap, 20, &obj3);
- CHECK(ret, FAIL, "H5HP_insert");
-
- /* Increment object one's priority by two to put it on top of the heap */
- ret = H5HP_incr(heap, 2, &obj1);
- CHECK(ret, FAIL, "H5HP_change");
-
- /* Check the maximum value on the heap */
- ret = H5HP_top(heap, &val);
- CHECK(ret, FAIL, "H5HP_top");
- VERIFY(val, 21, "H5HP_top");
-
- /* Increment object three's priority by two to put it back on top of the heap */
- ret = H5HP_incr(heap, 2, &obj3);
- CHECK(ret, FAIL, "H5HP_change");
-
- /* Check the maximum value on the heap */
- ret = H5HP_top(heap, &val);
- CHECK(ret, FAIL, "H5HP_top");
- VERIFY(val, 22, "H5HP_top");
-
- /* Decrement object three's priority by two to return object one to the top */
- ret = H5HP_decr(heap, 2, &obj3);
- CHECK(ret, FAIL, "H5HP_change");
-
- /* Check the maximum value on the heap */
- ret = H5HP_top(heap, &val);
- CHECK(ret, FAIL, "H5HP_top");
- VERIFY(val, 21, "H5HP_top");
-
- /* Close the heap */
- ret = H5HP_close(heap);
- CHECK(ret, FAIL, "H5HP_close");
-
-} /* end test_heap_incdec_max() */
-
-/****************************************************************
-**
-** test_heap_incdec (): Test H5HP (heap) code.
-** Tests incrementing & decrementing priority of objects on
-** maximum & minimum heaps.
-**
-****************************************************************/
-static void
-test_heap_incdec(void)
-{
- /* Output message about test being performed */
- MESSAGE(6, ("Testing Incrementing & Decrementing Priority of Objects in Heaps\n"));
-
- /* Test increments & decrements in minimum & maximum heaps */
- test_heap_incdec_max();
- test_heap_incdec_min();
-} /* end test_heap_incdec() */
-
-/****************************************************************
-**
-** test_heap_term(): Test H5HP (heap) code.
-** Release data for Heap testing
-**
-****************************************************************/
-static void
-test_heap_term(void)
-{
- /* Release arrays */
- if (rand_num)
- HDfree(rand_num);
- if (inc_sort_num)
- HDfree(inc_sort_num);
- if (dec_sort_num)
- HDfree(dec_sort_num);
-} /* end test_heap_term() */
-
-/****************************************************************
-**
-** test_heap(): Main H5HP testing routine.
-**
-****************************************************************/
-void
-test_heap(void)
-{
- /* Output message about test being performed */
- MESSAGE(5, ("Testing Heaps\n"));
-
- /* Initialize Heap testing data */
- test_heap_init();
-
- /* Actual Heap tests */
- test_heap_create(); /* Test Heap creation */
- test_heap_insert(); /* Test basic Heap insertion */
- test_heap_insert_many(); /* Test Heap insertion of many items */
- test_heap_remove(); /* Test basic Heap removal */
- test_heap_remove_many(); /* Test Heap removal of many items */
- test_heap_change(); /* Test changing priority of objects on Heap */
- test_heap_incdec(); /* Test incrementing & decrementing priority of objects on Heap */
-
- /* Release Heap testing data */
- test_heap_term();
-
-} /* end test_heap() */
diff --git a/test/vfd_swmr.c b/test/vfd_swmr.c
index c61a065..e7eb3da 100644
--- a/test/vfd_swmr.c
+++ b/test/vfd_swmr.c
@@ -122,9 +122,9 @@ static unsigned test_updater_generate_md_checksums(hbool_t file_create);
static unsigned
test_fapl(void)
{
- hid_t fapl = -1; /* File access property list */
- H5F_vfd_swmr_config_t *my_config = NULL; /* Configuration for VFD SWMR */
- herr_t ret; /* Return value */
+ hid_t fapl = H5I_INVALID_HID; /* File access property list */
+ H5F_vfd_swmr_config_t *my_config = NULL; /* Configuration for VFD SWMR */
+ herr_t ret; /* Return value */
TESTING("Configure VFD SWMR with fapl");
@@ -276,8 +276,7 @@ test_fapl(void)
if (H5Pclose(fapl) < 0)
FAIL_STACK_ERROR;
- if (my_config)
- HDfree(my_config);
+ HDfree(my_config);
PASSED();
return 0;
@@ -288,8 +287,9 @@ error:
H5Pclose(fapl);
}
H5E_END_TRY;
- if (my_config)
- HDfree(my_config);
+
+ HDfree(my_config);
+
return 1;
} /* test_fapl() */
@@ -316,12 +316,12 @@ error:
static unsigned
test_file_fapl(void)
{
- hid_t fid = -1; /* File ID */
- hid_t fid2 = -1; /* File ID */
- hid_t fcpl = -1; /* File creation property list ID */
- hid_t fapl1 = -1; /* File access property list ID */
- hid_t fapl2 = -1; /* File access property list ID */
- hid_t file_fapl = -1; /* File access property list ID associated with the file */
+ hid_t fid = H5I_INVALID_HID; /* File ID */
+ hid_t fid2 = H5I_INVALID_HID; /* File ID */
+ hid_t fcpl = H5I_INVALID_HID; /* File creation property list ID */
+ hid_t fapl1 = H5I_INVALID_HID; /* File access property list ID */
+ hid_t fapl2 = H5I_INVALID_HID; /* File access property list ID */
+ hid_t file_fapl = H5I_INVALID_HID; /* File access property list ID associated with the file */
H5F_vfd_swmr_config_t *config1 = NULL; /* Configuration for VFD SWMR */
H5F_vfd_swmr_config_t *config2 = NULL; /* Configuration for VFD SWMR */
H5F_vfd_swmr_config_t *file_config = NULL; /* Configuration for VFD SWMR */
@@ -602,12 +602,9 @@ test_file_fapl(void)
FAIL_STACK_ERROR;
/* Free buffers */
- if (config1)
- HDfree(config1);
- if (config2)
- HDfree(config2);
- if (file_config)
- HDfree(file_config);
+ HDfree(config1);
+ HDfree(config2);
+ HDfree(file_config);
PASSED();
return 0;
@@ -623,12 +620,11 @@ error:
H5Fclose(fid2);
}
H5E_END_TRY;
- if (config1)
- HDfree(config1);
- if (config2)
- HDfree(config2);
- if (file_config)
- HDfree(file_config);
+
+ HDfree(config1);
+ HDfree(config2);
+ HDfree(file_config);
+
return 1;
} /* test_file_fapl() */
@@ -830,12 +826,9 @@ test_file_end_tick(void)
FAIL_STACK_ERROR;
/* Free buffers */
- if (config1)
- HDfree(config1);
- if (config2)
- HDfree(config2);
- if (config3)
- HDfree(config3);
+ HDfree(config1);
+ HDfree(config2);
+ HDfree(config3);
PASSED();
return 0;
@@ -853,12 +846,9 @@ error:
}
H5E_END_TRY;
- if (config1)
- HDfree(config1);
- if (config2)
- HDfree(config2);
- if (config3)
- HDfree(config3);
+ HDfree(config1);
+ HDfree(config2);
+ HDfree(config3);
return 1;
} /* test_file_end_tick() */
@@ -956,15 +946,12 @@ test_writer_create_open_flush(void)
if (H5Pclose(fcpl) < 0)
FAIL_STACK_ERROR;
- if (my_config)
- HDfree(my_config);
+ HDfree(my_config);
PASSED();
return 0;
error:
- if (my_config)
- HDfree(my_config);
H5E_BEGIN_TRY
{
@@ -974,6 +961,8 @@ error:
}
H5E_END_TRY;
+ HDfree(my_config);
+
return 1;
} /* test_writer_create_open_flush() */
@@ -1003,15 +992,15 @@ error:
static unsigned
test_writer_md(void)
{
- hid_t fid = -1; /* File ID */
- hid_t fapl = -1; /* File access property list */
- hid_t fcpl = -1; /* File creation property list */
+ hid_t fid = H5I_INVALID_HID; /* File ID */
+ hid_t fapl = H5I_INVALID_HID; /* File access property list */
+ hid_t fcpl = H5I_INVALID_HID; /* File creation property list */
const unsigned num_entries = 10; /* index size */
unsigned i = 0; /* Local index variables */
uint8_t * buf = NULL; /* Data page from the page buffer */
- hid_t dcpl = -1; /* Dataset creation property list */
- hid_t sid = -1; /* Dataspace ID */
- hid_t did = -1; /* Dataset ID */
+ hid_t dcpl = H5I_INVALID_HID; /* Dataset creation property list */
+ hid_t sid = H5I_INVALID_HID; /* Dataspace ID */
+ hid_t did = H5I_INVALID_HID; /* Dataset ID */
int * rwbuf = NULL; /* Data buffer for writing */
H5O_info2_t oinfo; /* Object metadata information */
char dname[100]; /* Name of dataset */
@@ -1202,28 +1191,15 @@ test_writer_md(void)
FAIL_STACK_ERROR;
/* Free resources */
- if (my_config)
- HDfree(my_config);
- if (buf)
- HDfree(buf);
- if (rwbuf)
- HDfree(rwbuf);
- if (index)
- HDfree(index);
+ HDfree(my_config);
+ HDfree(buf);
+ HDfree(rwbuf);
+ HDfree(index);
PASSED();
return 0;
error:
- if (my_config)
- HDfree(my_config);
- if (buf)
- HDfree(buf);
- if (rwbuf)
- HDfree(rwbuf);
- if (index)
- HDfree(index);
-
H5E_BEGIN_TRY
{
H5Dclose(did);
@@ -1235,6 +1211,11 @@ error:
}
H5E_END_TRY;
+ HDfree(my_config);
+ HDfree(buf);
+ HDfree(rwbuf);
+ HDfree(index);
+
return 1;
} /* test_writer__md() */
@@ -1306,30 +1287,30 @@ test_file_end_tick_concur(void)
static unsigned
test_reader_md_concur(void)
{
- unsigned i = 0; /* Local index variables */
- uint8_t * buf = NULL; /* Data page from the page buffer */
- hid_t dcpl = -1; /* Dataset creation property list */
- hid_t sid = -1; /* Dataspace ID */
- hid_t did = -1; /* Dataset ID */
- int * rwbuf = NULL; /* Data buffer for writing */
- H5O_info2_t oinfo; /* Object metadata information */
- char dname[100]; /* Name of dataset */
- hsize_t dims[2] = {50, 20}; /* Dataset dimension sizes */
- hsize_t max_dims[2] = /* Dataset maximum dimension sizes */
+ unsigned i = 0; /* Local index variables */
+ uint8_t * buf = NULL; /* Data page from the page buffer */
+ hid_t dcpl = H5I_INVALID_HID; /* Dataset creation property list */
+ hid_t sid = H5I_INVALID_HID; /* Dataspace ID */
+ hid_t did = H5I_INVALID_HID; /* Dataset ID */
+ int * rwbuf = NULL; /* Data buffer for writing */
+ H5O_info2_t oinfo; /* Object metadata information */
+ char dname[100]; /* Name of dataset */
+ hsize_t dims[2] = {50, 20}; /* Dataset dimension sizes */
+ hsize_t max_dims[2] = /* Dataset maximum dimension sizes */
{H5S_UNLIMITED, H5S_UNLIMITED};
hsize_t chunk_dims[2] = {2, 5}; /* Dataset chunked dimension sizes */
unsigned num_entries = 0; /* Number of entries in the index */
H5FD_vfd_swmr_idx_entry_t *index = NULL; /* Pointer to the index entries */
- hid_t fcpl = -1; /* File creation property list */
- hid_t fid_writer = -1; /* File ID for writer */
- hid_t fapl_writer = -1; /* File access property list for writer */
- H5F_vfd_swmr_config_t *config_writer = NULL; /* VFD SWMR Configuration for writer */
- pid_t tmppid; /* Child process ID returned by waitpid */
- pid_t childpid = 0; /* Child process ID */
- int child_status; /* Status passed to waitpid */
- int child_wait_option = 0; /* Options passed to waitpid */
- int child_exit_val; /* Exit status of the child */
+ hid_t fcpl = H5I_INVALID_HID; /* File creation property list */
+ hid_t fid_writer = H5I_INVALID_HID; /* File ID for writer */
+ hid_t fapl_writer = H5I_INVALID_HID; /* File access property list for writer */
+ H5F_vfd_swmr_config_t *config_writer = NULL; /* VFD SWMR Configuration for writer */
+ pid_t tmppid; /* Child process ID returned by waitpid */
+ pid_t childpid = 0; /* Child process ID */
+ int child_status; /* Status passed to waitpid */
+ int child_wait_option = 0; /* Options passed to waitpid */
+ int child_exit_val; /* Exit status of the child */
int parent_pfd[2]; /* Pipe for parent process as writer */
int child_pfd[2]; /* Pipe for child process as reader */
@@ -1383,13 +1364,13 @@ test_reader_md_concur(void)
* Child process as reader
*/
if (childpid == 0) {
- int child_notify = 0; /* Notification between child and parent */
- hid_t fid_reader = -1; /* File ID for reader */
- hid_t fapl_reader = -1; /* File access property list for reader */
- H5F_t * file_reader; /* File pointer for reader */
- H5F_vfd_swmr_config_t * config_reader = NULL; /* VFD SWMR configuration for reader */
- unsigned child_num_entries = 0; /* Number of entries passed to reader */
- H5FD_vfd_swmr_idx_entry_t *child_index = NULL; /* Index passed to reader */
+ int child_notify = 0; /* Notification between child and parent */
+ hid_t fid_reader = H5I_INVALID_HID; /* File ID for reader */
+ hid_t fapl_reader = H5I_INVALID_HID; /* File access property list for reader */
+ H5F_t * file_reader; /* File pointer for reader */
+ H5F_vfd_swmr_config_t * config_reader = NULL; /* VFD SWMR configuration for reader */
+ unsigned child_num_entries = 0; /* Number of entries passed to reader */
+ H5FD_vfd_swmr_idx_entry_t *child_index = NULL; /* Index passed to reader */
/* Close unused write end for writer pipe */
if (HDclose(parent_pfd[1]) < 0)
@@ -1589,10 +1570,8 @@ test_reader_md_concur(void)
HDexit(EXIT_FAILURE);
/* Free resources */
- if (child_index)
- HDfree(child_index);
- if (config_reader)
- HDfree(config_reader);
+ HDfree(child_index);
+ HDfree(config_reader);
/* Closing */
if (H5Fclose(fid_reader) < 0)
@@ -1905,27 +1884,19 @@ test_reader_md_concur(void)
FAIL_STACK_ERROR;
/* Free resources */
- if (config_writer)
- HDfree(config_writer);
- if (buf)
- HDfree(buf);
- if (rwbuf)
- HDfree(rwbuf);
- if (index)
- HDfree(index);
+ HDfree(config_writer);
+ HDfree(buf);
+ HDfree(rwbuf);
+ HDfree(index);
PASSED();
return 0;
error:
- if (config_writer)
- HDfree(config_writer);
- if (buf)
- HDfree(buf);
- if (rwbuf)
- HDfree(rwbuf);
- if (index)
- HDfree(index);
+ HDfree(config_writer);
+ HDfree(buf);
+ HDfree(rwbuf);
+ HDfree(index);
H5E_BEGIN_TRY
{
@@ -1962,9 +1933,11 @@ test_multiple_file_opens_concur(void)
int child_exit_val; /* Exit status of the child */
int parent_pfd[2]; /* Pipe for parent process as writer */
int child_pfd[2]; /* Pipe for child process as reader */
- int notify = 0; /* Notification between parent and child */
- hid_t fid1 = H5I_INVALID_HID, fid2 = H5I_INVALID_HID;
- hid_t fapl1 = H5I_INVALID_HID, fapl2 = H5I_INVALID_HID;
+ int notify = 0; /* Notification between parent and child */
+ hid_t fid1 = H5I_INVALID_HID;
+ hid_t fid2 = H5I_INVALID_HID;
+ hid_t fapl1 = H5I_INVALID_HID;
+ hid_t fapl2 = H5I_INVALID_HID;
H5F_vfd_swmr_config_t *config1 = NULL; /* VFD SWMR configuration */
H5F_vfd_swmr_config_t *config2 = NULL; /* VFD SWMR configuration */
H5F_t * f1, *f2; /* File pointer */
@@ -2008,10 +1981,10 @@ test_multiple_file_opens_concur(void)
* Child process
*/
if (childpid == 0) {
- int child_notify = 0; /* Notification between child and parent */
- hid_t fid_writer = -1; /* File ID for writer */
- hid_t fapl_writer = -1; /* File access property list for writer */
- H5F_vfd_swmr_config_t *config_writer = NULL; /* VFD SWMR configuration for reader */
+ int child_notify = 0; /* Notification between child and parent */
+ hid_t fid_writer = H5I_INVALID_HID; /* File ID for writer */
+ hid_t fapl_writer = H5I_INVALID_HID; /* File access property list for writer */
+ H5F_vfd_swmr_config_t *config_writer = NULL; /* VFD SWMR configuration for reader */
/* Close unused write end for writer pipe */
if (HDclose(parent_pfd[1]) < 0)
@@ -2062,8 +2035,7 @@ test_multiple_file_opens_concur(void)
HDexit(EXIT_FAILURE);
}
- if (config_writer)
- HDfree(config_writer);
+ HDfree(config_writer);
/* Close the file */
if (H5Fclose(fid_writer) < 0)
@@ -2221,19 +2193,15 @@ test_multiple_file_opens_concur(void)
FAIL_STACK_ERROR;
/* Free resources */
- if (config1)
- HDfree(config1);
- if (config2)
- HDfree(config2);
+ HDfree(config1);
+ HDfree(config2);
PASSED();
return 0;
error:
- if (config1)
- HDfree(config1);
- if (config2)
- HDfree(config2);
+ HDfree(config1);
+ HDfree(config2);
H5E_BEGIN_TRY
{
@@ -2267,15 +2235,15 @@ error:
static unsigned
test_disable_enable_eot_concur(void)
{
- hid_t fcpl = -1; /* File creation property list */
- hid_t fid_writer = -1; /* File ID for writer */
- hid_t fapl_writer = -1; /* File access property list for writer */
- H5F_vfd_swmr_config_t *config_writer = NULL; /* VFD SWMR Configuration for writer */
- pid_t tmppid; /* Child process ID returned by waitpid */
- pid_t childpid = 0; /* Child process ID */
- int child_status; /* Status passed to waitpid */
- int child_wait_option = 0; /* Options passed to waitpid */
- int child_exit_val; /* Exit status of the child */
+ hid_t fcpl = H5I_INVALID_HID; /* File creation property list */
+ hid_t fid_writer = H5I_INVALID_HID; /* File ID for writer */
+ hid_t fapl_writer = H5I_INVALID_HID; /* File access property list for writer */
+ H5F_vfd_swmr_config_t *config_writer = NULL; /* VFD SWMR Configuration for writer */
+ pid_t tmppid; /* Child process ID returned by waitpid */
+ pid_t childpid = 0; /* Child process ID */
+ int child_status; /* Status passed to waitpid */
+ int child_wait_option = 0; /* Options passed to waitpid */
+ int child_exit_val; /* Exit status of the child */
int parent_pfd[2]; /* Pipe for parent process as writer */
int child_pfd[2]; /* Pipe for child process as reader */
@@ -2452,8 +2420,8 @@ test_disable_enable_eot_concur(void)
HDexit(EXIT_FAILURE);
if (H5Pclose(fapl_reader) < 0)
HDexit(EXIT_FAILURE);
- if (config_reader)
- HDfree(config_reader);
+
+ HDfree(config_reader);
/* Close the pipes */
if (HDclose(parent_pfd[0]) < 0)
@@ -2521,15 +2489,13 @@ test_disable_enable_eot_concur(void)
FAIL_STACK_ERROR;
/* Free resources */
- if (config_writer)
- HDfree(config_writer);
+ HDfree(config_writer);
PASSED();
return 0;
error:
- if (config_writer)
- HDfree(config_writer);
+ HDfree(config_writer);
H5E_BEGIN_TRY
{
@@ -2559,15 +2525,15 @@ error:
static unsigned
test_file_end_tick_concur(void)
{
- hid_t fcpl = -1; /* File creation property list */
- hid_t fid_writer = -1; /* File ID for writer */
- hid_t fapl_writer = -1; /* File access property list for writer */
- H5F_vfd_swmr_config_t *config_writer = NULL; /* VFD SWMR Configuration for writer */
- pid_t tmppid; /* Child process ID returned by waitpid */
- pid_t childpid = 0; /* Child process ID */
- int child_status; /* Status passed to waitpid */
- int child_wait_option = 0; /* Options passed to waitpid */
- int child_exit_val; /* Exit status of the child */
+ hid_t fcpl = H5I_INVALID_HID; /* File creation property list */
+ hid_t fid_writer = H5I_INVALID_HID; /* File ID for writer */
+ hid_t fapl_writer = H5I_INVALID_HID; /* File access property list for writer */
+ H5F_vfd_swmr_config_t *config_writer = NULL; /* VFD SWMR Configuration for writer */
+ pid_t tmppid; /* Child process ID returned by waitpid */
+ pid_t childpid = 0; /* Child process ID */
+ int child_status; /* Status passed to waitpid */
+ int child_wait_option = 0; /* Options passed to waitpid */
+ int child_exit_val; /* Exit status of the child */
int parent_pfd[2]; /* Pipe for parent process as writer */
int child_pfd[2]; /* Pipe for child process as reader */
@@ -2726,8 +2692,8 @@ test_file_end_tick_concur(void)
if (H5Pclose(fapl_reader) < 0)
HDexit(EXIT_FAILURE);
- if (config_reader)
- HDfree(config_reader);
+
+ HDfree(config_reader);
/* Close the pipes */
if (HDclose(parent_pfd[0]) < 0)
@@ -2795,15 +2761,13 @@ test_file_end_tick_concur(void)
FAIL_STACK_ERROR;
/* Free resources */
- if (config_writer)
- HDfree(config_writer);
+ HDfree(config_writer);
PASSED();
return 0;
error:
- if (config_writer)
- HDfree(config_writer);
+ HDfree(config_writer);
H5E_BEGIN_TRY
{
@@ -2835,15 +2799,15 @@ error:
static unsigned
test_multiple_file_opens(void)
{
- hid_t fid1 = -1; /* File ID */
- hid_t fid2 = -1; /* File ID */
- hid_t fid = -1; /* File ID */
- hid_t fcpl = -1; /* File creation property list ID */
- hid_t fapl1 = -1; /* File access property list ID */
- hid_t fapl2 = -1; /* File access property list ID */
- H5F_t * f1, *f2, *f; /* File pointer */
- H5F_vfd_swmr_config_t *config1 = NULL; /* Configuration for VFD SWMR */
- H5F_vfd_swmr_config_t *config2 = NULL; /* Configuration for VFD SWMR */
+ hid_t fid1 = H5I_INVALID_HID; /* File ID */
+ hid_t fid2 = H5I_INVALID_HID; /* File ID */
+ hid_t fid = H5I_INVALID_HID; /* File ID */
+ hid_t fcpl = H5I_INVALID_HID; /* File creation property list ID */
+ hid_t fapl1 = H5I_INVALID_HID; /* File access property list ID */
+ hid_t fapl2 = H5I_INVALID_HID; /* File access property list ID */
+ H5F_t * f1, *f2, *f; /* File pointer */
+ H5F_vfd_swmr_config_t *config1 = NULL; /* Configuration for VFD SWMR */
+ H5F_vfd_swmr_config_t *config2 = NULL; /* Configuration for VFD SWMR */
eot_queue_entry_t * curr;
TESTING("EOT queue entries when opening files with/without VFD SWMR");
@@ -2967,10 +2931,8 @@ test_multiple_file_opens(void)
FAIL_STACK_ERROR;
/* Free buffers */
- if (config1)
- HDfree(config1);
- if (config2)
- HDfree(config2);
+ HDfree(config1);
+ HDfree(config2);
PASSED();
return 0;
@@ -2986,10 +2948,9 @@ error:
H5Fclose(fid2);
}
H5E_END_TRY;
- if (config1)
- HDfree(config1);
- if (config2)
- HDfree(config2);
+
+ HDfree(config1);
+ HDfree(config2);
return 1;
} /* test_multiple_file_opens() */
@@ -3027,13 +2988,13 @@ error:
static unsigned
test_same_file_opens(void)
{
- hid_t fid = -1; /* File ID */
- hid_t fid2 = -1; /* File ID */
- hid_t fcpl = -1; /* File creation property list ID */
- hid_t fapl1 = -1; /* File access property list ID */
- hid_t fapl2 = -1; /* File access property list ID */
- H5F_vfd_swmr_config_t *config1 = NULL; /* Configuration for VFD SWMR */
- H5F_vfd_swmr_config_t *config2 = NULL; /* Configuration for VFD SWMR */
+ hid_t fid = H5I_INVALID_HID; /* File ID */
+ hid_t fid2 = H5I_INVALID_HID; /* File ID */
+ hid_t fcpl = H5I_INVALID_HID; /* File creation property list ID */
+ hid_t fapl1 = H5I_INVALID_HID; /* File access property list ID */
+ hid_t fapl2 = H5I_INVALID_HID; /* File access property list ID */
+ H5F_vfd_swmr_config_t *config1 = NULL; /* Configuration for VFD SWMR */
+ H5F_vfd_swmr_config_t *config2 = NULL; /* Configuration for VFD SWMR */
TESTING("Multiple opens of the same file with VFD SWMR configuration");
@@ -3297,10 +3258,8 @@ test_same_file_opens(void)
FAIL_STACK_ERROR;
/* Free buffers */
- if (config1)
- HDfree(config1);
- if (config2)
- HDfree(config2);
+ HDfree(config1);
+ HDfree(config2);
PASSED();
return 0;
@@ -3315,10 +3274,10 @@ error:
H5Fclose(fid2);
}
H5E_END_TRY;
- if (config1)
- HDfree(config1);
- if (config2)
- HDfree(config2);
+
+ HDfree(config1);
+ HDfree(config2);
+
return 1;
} /* test_same_file_opens() */
@@ -3654,12 +3613,9 @@ test_enable_disable_eot(void)
FAIL_STACK_ERROR;
/* Free buffers */
- if (config1)
- HDfree(config1);
- if (config2)
- HDfree(config2);
- if (config3)
- HDfree(config3);
+ HDfree(config1);
+ HDfree(config2);
+ HDfree(config3);
PASSED();
return 0;
@@ -3677,12 +3633,10 @@ error:
H5Fclose(fid3);
}
H5E_END_TRY;
- if (config1)
- HDfree(config1);
- if (config2)
- HDfree(config2);
- if (config3)
- HDfree(config3);
+
+ HDfree(config1);
+ HDfree(config2);
+ HDfree(config3);
return 1;
} /* test_enable_disable_eot() */
@@ -3693,8 +3647,7 @@ error:
* Purpose: This is the helper routine used to verify whether
* "flags" in the updater file is as expected.
*
- * Return: 0 if test is successful
- * 1 if test fails
+ * Return: SUCCEED/FAIL
*
* Programmer: Vailin Choi; October 2021
*
@@ -3724,10 +3677,10 @@ verify_updater_flags(char *ud_name, uint16_t expected_flags)
if (HDfclose(ud_fp) < 0)
FAIL_STACK_ERROR;
- return 0;
+ return SUCCEED;
error:
- return 1;
+ return FAIL;
} /* verify_updater_flags() */
@@ -3747,10 +3700,10 @@ error:
static unsigned
test_updater_flags(void)
{
- hid_t fid = -1; /* File ID */
- hid_t fcpl = -1; /* File creation property list ID */
- hid_t fapl = -1; /* File access property list ID */
- hid_t file_fapl = -1; /* File access property list ID associated with the file */
+ hid_t fid = H5I_INVALID_HID; /* File ID */
+ hid_t fcpl = H5I_INVALID_HID; /* File creation property list ID */
+ hid_t fapl = H5I_INVALID_HID; /* File access property list ID */
+ hid_t file_fapl = H5I_INVALID_HID; /* File access property list ID associated with the file */
H5F_vfd_swmr_config_t *config = NULL; /* Configuration for VFD SWMR */
H5F_vfd_swmr_config_t *file_config = NULL; /* Configuration for VFD SWMR */
uint64_t seq_num = 0; /* Sequence number for updater file */
@@ -3849,10 +3802,8 @@ test_updater_flags(void)
}
/* Free buffers */
- if (config)
- HDfree(config);
- if (file_config)
- HDfree(file_config);
+ HDfree(config);
+ HDfree(file_config);
PASSED();
return 0;
@@ -3866,10 +3817,9 @@ error:
H5Fclose(fid);
}
H5E_END_TRY;
- if (config)
- HDfree(config);
- if (file_config)
- HDfree(file_config);
+
+ HDfree(config);
+ HDfree(file_config);
return 1;
} /* test_updater_flags() */
@@ -3890,10 +3840,10 @@ error:
static unsigned
test_updater_flags_same_file_opens(void)
{
- hid_t fid = -1; /* File ID */
- hid_t fid2 = -1; /* File ID */
- hid_t fcpl = -1; /* File creation property list ID */
- hid_t fapl1 = -1; /* File access property list ID */
+ hid_t fid = H5I_INVALID_HID; /* File ID */
+ hid_t fid2 = H5I_INVALID_HID; /* File ID */
+ hid_t fcpl = H5I_INVALID_HID; /* File creation property list ID */
+ hid_t fapl1 = H5I_INVALID_HID; /* File access property list ID */
H5F_vfd_swmr_config_t *config1 = NULL; /* Configuration for VFD SWMR */
uint64_t seq_num = 0; /* Sequence number for updater file */
uint64_t i = 0; /* Local index variable */
@@ -3999,8 +3949,7 @@ test_updater_flags_same_file_opens(void)
FAIL_STACK_ERROR;
/* Free buffers */
- if (config1)
- HDfree(config1);
+ HDfree(config1);
PASSED();
return 0;
@@ -4014,8 +3963,9 @@ error:
H5Fclose(fid2);
}
H5E_END_TRY;
- if (config1)
- HDfree(config1);
+
+ HDfree(config1);
+
return 1;
} /* test_updater_flags_same_file_opens() */
@@ -4174,7 +4124,7 @@ verify_ud_chk(char *md_file_path, char *ud_file_path)
return 0;
error:
- return (-1);
+ return -1;
} /* verify_ud_chk() */
@@ -4260,14 +4210,13 @@ md_ck_cb(char *md_file_path, uint64_t updater_seq_num)
if (chk_fp && HDfclose(chk_fp) != 0)
FAIL_STACK_ERROR;
- if (buf)
- HDfree(buf);
+ HDfree(buf);
return 0;
error:
- if (buf)
- HDfree(buf);
+ HDfree(buf);
+
if (md_fp)
HDfclose(md_fp);
if (chk_fp)
@@ -4299,11 +4248,11 @@ error:
static unsigned
test_updater_generate_md_checksums(hbool_t file_create)
{
- hid_t fid = -1; /* File ID */
- hid_t fcpl = -1; /* File creation property list ID */
- hid_t fapl = -1; /* File access property list ID */
- H5F_vfd_swmr_config_t config; /* Configuration for VFD SWMR */
- H5F_generate_md_ck_cb_t cb_info; /* Callback */
+ hid_t fid = H5I_INVALID_HID; /* File ID */
+ hid_t fcpl = H5I_INVALID_HID; /* File creation property list ID */
+ hid_t fapl = H5I_INVALID_HID; /* File access property list ID */
+ H5F_vfd_swmr_config_t config; /* Configuration for VFD SWMR */
+ H5F_generate_md_ck_cb_t cb_info; /* Callback */
if (file_create) {
TESTING("VFD SWMR updater generate checksums for metadata file with H5Fcreate");
@@ -4398,7 +4347,7 @@ error:
int
main(void)
{
- hid_t fapl = -1; /* File access property list for */
+ hid_t fapl = H5I_INVALID_HID; /* File access property list for */
/* data files */
unsigned nerrors = 0; /* Cumulative error count */
char * lock_env_var = NULL; /* File locking env var pointer */
diff --git a/test/vfd_swmr_attrdset_writer.c b/test/vfd_swmr_attrdset_writer.c
index 6524b8b..37c4c72 100644
--- a/test/vfd_swmr_attrdset_writer.c
+++ b/test/vfd_swmr_attrdset_writer.c
@@ -37,9 +37,6 @@
* compact<->dense storage and with/without continuation block.
*
*/
-#include <err.h>
-#include <libgen.h>
-#include <unistd.h> /* getopt(3) */
#include "hdf5.h"
#include "testhdf5.h"
@@ -60,13 +57,13 @@ typedef struct {
unsigned int asteps; /* For -a <nattrs> option */
unsigned int csteps; /* For -c <csteps> option */
unsigned int dattrs; /* For -d <dattrs> option */
- bool compact; /* For -p option */
- bool contig; /* For -g option */
- bool chunked; /* For -k option */
- bool vl_attr; /* For -v option */
- bool mod_attr; /* For -m option */
- bool use_np; /* For -N option */
- bool use_vfd_swmr; /* For -S option */
+ hbool_t compact; /* For -p option */
+ hbool_t contig; /* For -g option */
+ hbool_t chunked; /* For -k option */
+ hbool_t vl_attr; /* For -v option */
+ hbool_t mod_attr; /* For -m option */
+ hbool_t use_np; /* For -N option */
+ hbool_t use_vfd_swmr; /* For -S option */
} state_t;
/* Initializations for state_t */
@@ -74,9 +71,9 @@ typedef struct {
(state_t) \
{ \
.file = H5I_INVALID_HID, .one_by_one_sid = H5I_INVALID_HID, .filename = "", \
- .filetype = H5T_NATIVE_UINT32, .asteps = 0, .csteps = 1, .dattrs = 0, .use_np = true, \
- .use_vfd_swmr = true, .compact = false, .contig = false, .chunked = false, .vl_attr = false, \
- .mod_attr = false, .update_interval = READER_WAIT_TICKS \
+ .filetype = H5T_NATIVE_UINT32, .asteps = 0, .csteps = 1, .dattrs = 0, .use_np = TRUE, \
+ .use_vfd_swmr = TRUE, .compact = FALSE, .contig = FALSE, .chunked = FALSE, .vl_attr = FALSE, \
+ .mod_attr = FALSE, .update_interval = READER_WAIT_TICKS \
}
/* Structure to hold info for different dataset types */
@@ -133,42 +130,40 @@ typedef struct {
.fd_reader_to_writer = -1, .notify = 0, .verify = 0 \
}
-static bool state_init(state_t *, int, char **);
-
-static bool np_init(np_state_t *np, bool writer);
-static bool np_close(np_state_t *np, bool writer);
-static bool np_writer(bool result, unsigned step, const state_t *s, np_state_t *np,
- H5F_vfd_swmr_config_t *config);
-static bool np_reader(bool result, unsigned step, const state_t *s, np_state_t *np);
-static bool np_confirm_verify_notify(int fd, unsigned step, const state_t *s, np_state_t *np);
-static bool np_reader_no_verification(const state_t *s, np_state_t *np, H5F_vfd_swmr_config_t *config);
-
-static bool create_dsets(const state_t *s, dsets_state_t *ds);
-static bool open_dsets(const state_t *s, dsets_state_t *ds);
-static bool open_dset_real(hid_t fid, hid_t *did, const char *name, unsigned *max_compact,
- unsigned *min_dense);
-static bool close_dsets(const dsets_state_t *ds);
-
-static bool perform_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *config,
- np_state_t *np);
-static bool attr_dsets_action(unsigned action, const state_t *s, const dsets_state_t *ds, unsigned which);
-static bool attr_action(unsigned action, const state_t *s, hid_t did, unsigned which);
-static bool add_attr(const state_t *s, hid_t did, unsigned int which);
-static bool modify_attr(const state_t *s, hid_t did, unsigned int which);
-static bool delete_attr(hid_t did, unsigned int which);
-
-static bool verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *config,
- np_state_t *np);
-static bool verify_attr_dsets_action(unsigned action, const state_t *s, const dsets_state_t *ds,
- unsigned which);
-static bool verify_attr_action(unsigned action, hid_t did, unsigned which);
-static bool verify_add_or_modify_attr(unsigned action, hid_t did, char *attr_name, unsigned int which);
-static bool verify_delete_attr(hid_t did, char *attr_name);
-static bool verify_storage_cont(unsigned action, hid_t did, unsigned int which, unsigned max_compact,
- unsigned min_dense, unsigned asteps);
-static bool verify_storage_cont_real(hid_t did, unsigned int which, unsigned cut_point);
-
-static const hid_t badhid = H5I_INVALID_HID;
+static herr_t state_init(state_t *s, int argc, const char *const *argv);
+
+static herr_t np_init(np_state_t *np, hbool_t writer);
+static herr_t np_close(np_state_t *np, hbool_t writer);
+static herr_t np_writer(hbool_t result, unsigned step, const state_t *s, np_state_t *np,
+ H5F_vfd_swmr_config_t *config);
+static herr_t np_reader(hbool_t result, unsigned step, const state_t *s, np_state_t *np);
+static herr_t np_confirm_verify_notify(int fd, unsigned step, const state_t *s, np_state_t *np);
+static herr_t np_reader_no_verification(const state_t *s, np_state_t *np, H5F_vfd_swmr_config_t *config);
+
+static herr_t create_dsets(const state_t *s, dsets_state_t *ds);
+static herr_t open_dsets(const state_t *s, dsets_state_t *ds);
+static herr_t open_dset_real(hid_t fid, hid_t *did, const char *name, unsigned *max_compact,
+ unsigned *min_dense);
+static herr_t close_dsets(const dsets_state_t *ds);
+
+static herr_t perform_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *config,
+ np_state_t *np);
+static herr_t attr_dsets_action(unsigned action, const state_t *s, const dsets_state_t *ds, unsigned which);
+static herr_t attr_action(unsigned action, const state_t *s, hid_t did, unsigned which);
+static herr_t add_attr(const state_t *s, hid_t did, unsigned int which);
+static herr_t modify_attr(const state_t *s, hid_t did, unsigned int which);
+static herr_t delete_attr(hid_t did, unsigned int which);
+
+static herr_t verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *config,
+ np_state_t *np);
+static herr_t verify_attr_dsets_action(unsigned action, const state_t *s, const dsets_state_t *ds,
+ unsigned which);
+static herr_t verify_attr_action(unsigned action, hid_t did, unsigned which);
+static herr_t verify_add_or_modify_attr(unsigned action, hid_t did, char *attr_name, unsigned int which);
+static herr_t verify_delete_attr(hid_t did, char *attr_name);
+static herr_t verify_storage_cont(unsigned action, hid_t did, unsigned int which, unsigned max_compact,
+ unsigned min_dense, unsigned asteps);
+static herr_t verify_storage_cont_real(hid_t did, unsigned int which, unsigned cut_point);
/* Names for datasets */
#define DSET_COMPACT_NAME "compact_dset"
@@ -220,14 +215,16 @@ usage(const char *progname)
/*
* Initialize option info in state_t
*/
-static bool
-state_init(state_t *s, int argc, char **argv)
+static herr_t
+state_init(state_t *s, int argc, const char *const *argv)
{
- unsigned long tmp;
- int ch;
- const hsize_t dims = 1;
- char * tfile = NULL;
- char * end;
+ unsigned long tmp;
+ int opt;
+ const hsize_t dims = 1;
+ char * tfile = NULL;
+ char * end;
+ const char * s_opts = "pgkvmbqSNa:d:u:c:";
+ struct h5_long_options l_opts[] = {{NULL, 0, '\0'}};
*s = ALL_HID_INITIALIZER;
@@ -243,27 +240,27 @@ state_init(state_t *s, int argc, char **argv)
tfile = NULL;
}
- while ((ch = getopt(argc, argv, "pgkvmbqSNa:d:u:c:")) != -1) {
- switch (ch) {
+ while ((opt = H5_get_option(argc, argv, s_opts, l_opts)) != EOF) {
+ switch (opt) {
case 'p':
- s->compact = true;
+ s->compact = TRUE;
break;
case 'g':
- s->contig = true;
+ s->contig = TRUE;
break;
case 'k':
- s->chunked = true;
+ s->chunked = TRUE;
break;
case 'v':
- s->vl_attr = true;
+ s->vl_attr = TRUE;
break;
case 'm':
- s->mod_attr = true;
+ s->mod_attr = TRUE;
break;
case 'b':
s->filetype = H5T_STD_U32BE;
@@ -272,37 +269,37 @@ state_init(state_t *s, int argc, char **argv)
verbosity = 0;
break;
case 'S':
- s->use_vfd_swmr = false;
+ s->use_vfd_swmr = FALSE;
break;
case 'N':
- s->use_np = false;
+ s->use_np = FALSE;
break;
case 'a':
case 'd':
case 'u':
case 'c':
errno = 0;
- tmp = HDstrtoul(optarg, &end, 0);
- if (end == optarg || *end != '\0') {
- HDprintf("couldn't parse `-%c` argument `%s`\n", ch, optarg);
+ tmp = HDstrtoul(H5_optarg, &end, 0);
+ if (end == H5_optarg || *end != '\0') {
+ HDprintf("couldn't parse `-%c` argument `%s`\n", opt, H5_optarg);
TEST_ERROR;
}
else if (errno != 0) {
- HDprintf("couldn't parse `-%c` argument `%s`\n", ch, optarg);
+ HDprintf("couldn't parse `-%c` argument `%s`\n", opt, H5_optarg);
TEST_ERROR;
}
else if (tmp > UINT_MAX) {
- HDprintf("`-%c` argument `%lu` too large\n", ch, tmp);
+ HDprintf("`-%c` argument `%lu` too large\n", opt, tmp);
TEST_ERROR;
}
- if (ch == 'a')
+ if (opt == 'a')
s->asteps = (unsigned)tmp;
- else if (ch == 'd')
+ else if (opt == 'd')
s->dattrs = (unsigned)tmp;
- else if (ch == 'u')
+ else if (opt == 'u')
s->update_interval = (unsigned)tmp;
- else if (ch == 'c')
+ else if (opt == 'c')
s->csteps = (unsigned)tmp;
break;
@@ -312,8 +309,8 @@ state_init(state_t *s, int argc, char **argv)
break;
}
}
- argc -= optind;
- argv += optind;
+ argc -= H5_optind;
+ argv += H5_optind;
/* Require to specify at least -p, -g or -k option */
if (!s->compact && !s->contig && !s->chunked) {
@@ -350,29 +347,29 @@ state_init(state_t *s, int argc, char **argv)
/* The test file name */
esnprintf(s->filename, sizeof(s->filename), "vfd_swmr_attrdset.h5");
- return true;
+ return SUCCEED;
error:
if (tfile)
HDfree(tfile);
- return false;
+ return FAIL;
} /* state_init() */
/*
* Create the datasets as specified on the command line.
*/
-static bool
+static herr_t
create_dsets(const state_t *s, dsets_state_t *ds)
{
- hid_t dcpl = badhid;
- hid_t dtid = badhid;
- hid_t tmp_did = badhid;
- hid_t cmpd_tid = badhid;
- hid_t array_tid = badhid;
- hid_t vl_tid = badhid;
- hid_t sid = badhid;
+ hid_t dcpl = H5I_INVALID_HID;
+ hid_t dtid = H5I_INVALID_HID;
+ hid_t tmp_did = H5I_INVALID_HID;
+ hid_t cmpd_tid = H5I_INVALID_HID;
+ hid_t array_tid = H5I_INVALID_HID;
+ hid_t vl_tid = H5I_INVALID_HID;
+ hid_t sid = H5I_INVALID_HID;
*ds = DSETS_INITIALIZER;
@@ -722,7 +719,7 @@ create_dsets(const state_t *s, dsets_state_t *ds)
}
}
- return true;
+ return SUCCEED;
error:
H5E_BEGIN_TRY
@@ -744,14 +741,14 @@ error:
}
H5E_END_TRY;
- return false;
+ return FAIL;
} /* create_dsets() */
/*
* Open the datasets as specified.
*/
-static bool
+static herr_t
open_dsets(const state_t *s, dsets_state_t *ds)
{
*ds = DSETS_INITIALIZER;
@@ -799,10 +796,10 @@ open_dsets(const state_t *s, dsets_state_t *ds)
}
}
- return true;
+ return SUCCEED;
error:
- return false;
+ return FAIL;
} /* open_dsets() */
@@ -810,10 +807,10 @@ error:
* Do the real work of opening the dataset.
* Retrieve the max_compact and min_dense values for the dataset.
*/
-static bool
+static herr_t
open_dset_real(hid_t fid, hid_t *did, const char *name, unsigned *max_compact, unsigned *min_dense)
{
- hid_t dcpl = badhid;
+ hid_t dcpl = H5I_INVALID_HID;
if ((*did = H5Dopen2(fid, name, H5P_DEFAULT)) < 0) {
HDprintf("H5Dopen dataset failed\n");
@@ -835,7 +832,7 @@ open_dset_real(hid_t fid, hid_t *did, const char *name, unsigned *max_compact, u
TEST_ERROR;
}
- return true;
+ return SUCCEED;
error:
H5E_BEGIN_TRY
@@ -845,31 +842,31 @@ error:
}
H5E_END_TRY;
- return false;
+ return FAIL;
} /* open_dset_real() */
/*
* Close all the datasets as specified.
*/
-static bool
+static herr_t
close_dsets(const dsets_state_t *ds)
{
- if (ds->compact_did != badhid && H5Dclose(ds->compact_did) < 0) {
+ if (ds->compact_did != H5I_INVALID_HID && H5Dclose(ds->compact_did) < 0) {
HDprintf("H5Dclose compact dataset failed\n");
TEST_ERROR;
}
- if (ds->contig_did != badhid && H5Dclose(ds->contig_did) < 0) {
+ if (ds->contig_did != H5I_INVALID_HID && H5Dclose(ds->contig_did) < 0) {
HDprintf("H5Dclose contig dataset failed\n");
TEST_ERROR;
}
- if (ds->single_did != badhid && H5Dclose(ds->single_did) < 0) {
+ if (ds->single_did != H5I_INVALID_HID && H5Dclose(ds->single_did) < 0) {
HDprintf("H5Dclose chunked dataset: single index failed\n");
TEST_ERROR;
}
- if (ds->implicit_did != badhid && H5Dclose(ds->implicit_did) < 0) {
+ if (ds->implicit_did != H5I_INVALID_HID && H5Dclose(ds->implicit_did) < 0) {
HDprintf("H5Dclose chunked dataset: implicit index failed\n");
TEST_ERROR;
}
@@ -889,7 +886,7 @@ close_dsets(const dsets_state_t *ds)
TEST_ERROR;
}
- return true;
+ return SUCCEED;
error:
H5E_BEGIN_TRY
@@ -904,7 +901,7 @@ error:
}
H5E_END_TRY;
- return false;
+ return FAIL;
} /* close_dsets() */
/*
@@ -917,11 +914,11 @@ error:
* MODIFY_ATTR : -m option
* DELETE_ATTR : -d <dattrs> option
*/
-static bool
+static herr_t
perform_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *config, np_state_t *np)
{
unsigned step;
- bool result;
+ hbool_t result;
unsigned dd;
for (step = 0; step < s->asteps; step++) {
@@ -938,7 +935,7 @@ perform_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *c
if (s->mod_attr) {
/* Need to sync up writer/reader before moving onto the next phase */
- if (s->use_np && !np_writer(true, 0, s, np, config)) {
+ if (s->use_np && !np_writer(TRUE, 0, s, np, config)) {
HDprintf("np_writer() for modification failed\n");
TEST_ERROR;
}
@@ -959,7 +956,7 @@ perform_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *c
if (s->dattrs) {
/* Need to sync up writer/reader before moving onto the next phase */
- if (s->use_np && !np_writer(true, 0, s, np, config)) {
+ if (s->use_np && !np_writer(TRUE, 0, s, np, config)) {
HDprintf("np_writer() for deletion failed\n");
TEST_ERROR;
}
@@ -977,10 +974,10 @@ perform_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *c
}
}
- return true;
+ return SUCCEED;
error:
- return false;
+ return FAIL;
} /* perform_dsets_operations() */
@@ -990,55 +987,55 @@ error:
* -g: contiguous dataset
* -k: 5 chunked datasets with 5 indexing types
*/
-static bool
+static herr_t
attr_dsets_action(unsigned action, const state_t *s, const dsets_state_t *ds, unsigned which)
{
- int nerrors = 0;
- bool ret = true;
+ int nerrors = 0;
+ hbool_t ret = TRUE;
if (s->compact) {
- HDassert(ds->compact_did != badhid);
+ HDassert(ds->compact_did != H5I_INVALID_HID);
dbgf(2, "to compact dataset\n");
if (!attr_action(action, s, ds->compact_did, which))
++nerrors;
}
if (s->contig) {
- HDassert(ds->contig_did != badhid);
+ HDassert(ds->contig_did != H5I_INVALID_HID);
dbgf(2, "to contiguous dataset\n");
if (!attr_action(action, s, ds->contig_did, which))
++nerrors;
}
if (s->chunked) {
- HDassert(ds->single_did != badhid);
+ HDassert(ds->single_did != H5I_INVALID_HID);
dbgf(2, "to chunked dataset: single index\n");
if (!attr_action(action, s, ds->single_did, which))
++nerrors;
- HDassert(ds->implicit_did != badhid);
+ HDassert(ds->implicit_did != H5I_INVALID_HID);
dbgf(2, "to chunked dataset: implicit index\n");
if (!attr_action(action, s, ds->implicit_did, which))
++nerrors;
- HDassert(ds->fa_did != badhid);
+ HDassert(ds->fa_did != H5I_INVALID_HID);
dbgf(2, "to chunked dataset: fixed array index\n");
if (!attr_action(action, s, ds->fa_did, which))
++nerrors;
- HDassert(ds->ea_did != badhid);
+ HDassert(ds->ea_did != H5I_INVALID_HID);
dbgf(2, "to chunked dataset: extensible array index\n");
if (!attr_action(action, s, ds->ea_did, which))
++nerrors;
- HDassert(ds->bt2_did != badhid);
+ HDassert(ds->bt2_did != H5I_INVALID_HID);
dbgf(2, "to chunked dataset: version 2 btree index\n");
if (!attr_action(action, s, ds->bt2_did, which))
++nerrors;
}
if (nerrors)
- ret = false;
+ ret = FALSE;
return (ret);
@@ -1050,10 +1047,10 @@ attr_dsets_action(unsigned action, const state_t *s, const dsets_state_t *ds, un
* MODIFY_ATTR : modify `which` attribute
* DELETE_ATTR : delete `which` attribute
*/
-static bool
+static herr_t
attr_action(unsigned action, const state_t *s, hid_t did, unsigned which)
{
- bool ret;
+ hbool_t ret;
switch (action) {
case ADD_ATTR:
@@ -1083,12 +1080,12 @@ attr_action(unsigned action, const state_t *s, hid_t did, unsigned which)
* H5T_NATIVE_UINT32 (-b) or
* H5T_NATIVE_UINT32 (default)
*/
-static bool
+static herr_t
add_attr(const state_t *s, hid_t did, unsigned int which)
{
- hid_t aid = badhid;
- hid_t tid = badhid;
- hid_t vl_tid = badhid;
+ hid_t aid = H5I_INVALID_HID;
+ hid_t tid = H5I_INVALID_HID;
+ hid_t vl_tid = H5I_INVALID_HID;
char name[sizeof("attr-9999999999")];
char *val = NULL;
@@ -1143,7 +1140,7 @@ add_attr(const state_t *s, hid_t did, unsigned int which)
if (val)
HDfree(val);
- return true;
+ return SUCCEED;
error:
H5E_BEGIN_TRY
@@ -1156,19 +1153,19 @@ error:
if (val)
HDfree(val);
- return false;
+ return FAIL;
} /* add_attr() */
/*
* Modify the attribute data.
*/
-static bool
+static herr_t
modify_attr(const state_t *s, hid_t did, unsigned int which)
{
- hid_t aid = badhid;
- hid_t tid = badhid;
- hid_t vl_tid = badhid;
+ hid_t aid = H5I_INVALID_HID;
+ hid_t tid = H5I_INVALID_HID;
+ hid_t vl_tid = H5I_INVALID_HID;
char name[sizeof("attr-9999999999")];
char * val = NULL;
unsigned tmp_val = 0;
@@ -1227,7 +1224,7 @@ modify_attr(const state_t *s, hid_t did, unsigned int which)
if (val)
HDfree(val);
- return true;
+ return SUCCEED;
error:
H5E_BEGIN_TRY
{
@@ -1239,13 +1236,13 @@ error:
if (val)
HDfree(val);
- return false;
+ return FAIL;
} /* modify_attr() */
/*
* Delete the attribute
*/
-static bool
+static herr_t
delete_attr(hid_t did, unsigned int which)
{
char name[sizeof("attr-9999999999")];
@@ -1258,10 +1255,10 @@ delete_attr(hid_t did, unsigned int which)
TEST_ERROR;
}
- return true;
+ return SUCCEED;
error:
- return false;
+ return FAIL;
} /* delete_attr() */
@@ -1279,11 +1276,11 @@ error:
* --[-c <csteps>] is 1
* --not applicable for -m option
*/
-static bool
+static herr_t
verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *config, np_state_t *np)
{
unsigned step;
- bool result;
+ hbool_t result;
unsigned dd;
/* Start verifying addition */
@@ -1363,11 +1360,11 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co
}
}
- return true;
+ return SUCCEED;
error:
- return false;
+ return FAIL;
} /* verify_dsets_operations() */
/*
@@ -1376,14 +1373,14 @@ error:
* -g: contiguous dataset
* -k: 5 chunked datasets with 5 indexing types
*/
-static bool
+static herr_t
verify_attr_dsets_action(unsigned action, const state_t *s, const dsets_state_t *ds, unsigned which)
{
- int nerrors = 0;
- bool ret = true;
+ int nerrors = 0;
+ hbool_t ret = TRUE;
if (s->compact) {
- HDassert(ds->compact_did != badhid);
+ HDassert(ds->compact_did != H5I_INVALID_HID);
dbgf(2, "Verifying attribute to compact dataset\n");
if (!verify_attr_action(action, ds->compact_did, which))
++nerrors;
@@ -1395,7 +1392,7 @@ verify_attr_dsets_action(unsigned action, const state_t *s, const dsets_state_t
}
if (s->contig) {
- HDassert(ds->contig_did != badhid);
+ HDassert(ds->contig_did != H5I_INVALID_HID);
dbgf(2, "Verifying attribute to contiguous dataset\n");
if (!verify_attr_action(action, ds->contig_did, which))
++nerrors;
@@ -1407,7 +1404,7 @@ verify_attr_dsets_action(unsigned action, const state_t *s, const dsets_state_t
}
if (s->chunked) {
- HDassert(ds->single_did != badhid);
+ HDassert(ds->single_did != H5I_INVALID_HID);
dbgf(2, "Verifying attribute to chunked dataset: single indedx\n");
if (!verify_attr_action(action, ds->single_did, which))
++nerrors;
@@ -1417,7 +1414,7 @@ verify_attr_dsets_action(unsigned action, const state_t *s, const dsets_state_t
++nerrors;
}
- HDassert(ds->implicit_did != badhid);
+ HDassert(ds->implicit_did != H5I_INVALID_HID);
dbgf(2, "Verifying attribute to chunked dataset: implicit index\n");
if (!verify_attr_action(action, ds->implicit_did, which))
++nerrors;
@@ -1427,7 +1424,7 @@ verify_attr_dsets_action(unsigned action, const state_t *s, const dsets_state_t
++nerrors;
}
- HDassert(ds->fa_did != badhid);
+ HDassert(ds->fa_did != H5I_INVALID_HID);
dbgf(2, "Verifying attribute to chunked dataset: fa index\n");
if (!verify_attr_action(action, ds->fa_did, which))
++nerrors;
@@ -1437,7 +1434,7 @@ verify_attr_dsets_action(unsigned action, const state_t *s, const dsets_state_t
++nerrors;
}
- HDassert(ds->ea_did != badhid);
+ HDassert(ds->ea_did != H5I_INVALID_HID);
dbgf(2, "Verifying attribute to chunked dataset: ea index\n");
if (!verify_attr_action(action, ds->ea_did, which))
++nerrors;
@@ -1447,7 +1444,7 @@ verify_attr_dsets_action(unsigned action, const state_t *s, const dsets_state_t
++nerrors;
}
- HDassert(ds->bt2_did != badhid);
+ HDassert(ds->bt2_did != H5I_INVALID_HID);
dbgf(2, "Verifying attribute to chunked dataset: bt2 index\n");
if (!verify_attr_action(action, ds->bt2_did, which))
++nerrors;
@@ -1459,7 +1456,7 @@ verify_attr_dsets_action(unsigned action, const state_t *s, const dsets_state_t
}
if (nerrors)
- ret = false;
+ ret = FALSE;
return (ret);
@@ -1468,11 +1465,11 @@ verify_attr_dsets_action(unsigned action, const state_t *s, const dsets_state_t
/*
* Verify the attribute action on the specified dataset.
*/
-static bool
+static herr_t
verify_attr_action(unsigned action, hid_t did, unsigned which)
{
- char name[sizeof("attr-9999999999")];
- bool ret;
+ char name[sizeof("attr-9999999999")];
+ hbool_t ret;
esnprintf(name, sizeof(name), "attr-%u", which);
@@ -1499,19 +1496,19 @@ verify_attr_action(unsigned action, hid_t did, unsigned which)
/*
* Verify the attribute is added or modified
*/
-static bool
+static herr_t
verify_add_or_modify_attr(unsigned action, hid_t did, char *attr_name, unsigned int which)
{
unsigned int read_which;
unsigned int tmp_val;
char tmp_vl_val[sizeof("attr-9999999999")];
char * read_vl_which;
- bool is_vl = false;
+ hbool_t is_vl = FALSE;
hid_t aid = H5I_INVALID_HID;
hid_t atid = H5I_INVALID_HID;
- bool ret = FALSE;
+ hbool_t ret = FALSE;
- HDassert(did != badhid);
+ HDassert(did != H5I_INVALID_HID);
HDassert(action == ADD_ATTR || action == MODIFY_ATTR);
if ((aid = H5Aopen(did, attr_name, H5P_DEFAULT)) < 0) {
@@ -1555,7 +1552,7 @@ verify_add_or_modify_attr(unsigned action, hid_t did, char *attr_name, unsigned
if (is_vl) {
dbgf(2, "read_vl_which = %s, tmp_vl_val= %s\n", read_vl_which, tmp_vl_val);
if (!HDstrcmp(read_vl_which, tmp_vl_val))
- ret = true;
+ ret = TRUE;
}
else {
dbgf(2, "read_which = %u, tmp_val = %u\n", read_which, tmp_val);
@@ -1578,14 +1575,14 @@ error:
if (is_vl)
H5free_memory(read_vl_which);
- return false;
+ return FAIL;
} /* verify_add_or_modify_attr() */
/*
* Verify the attribute does not exist.
*/
-static bool
+static herr_t
verify_delete_attr(hid_t did, char *attr_name)
{
int ret;
@@ -1595,14 +1592,14 @@ verify_delete_attr(hid_t did, char *attr_name)
TEST_ERROR;
}
else if (!ret) /* attribute does not exist */
- ret = true;
+ ret = TRUE;
else /* attribute exist */
- ret = false;
+ ret = FALSE;
return ret;
error:
- return false;
+ return FAIL;
} /* verify_delete_attr() */
@@ -1620,11 +1617,11 @@ error:
* --`which` is at min_dense: dense storage, no continuation block
* --`which` is at (min_dense - 1): compact storage, continuation block exists
*/
-static bool
+static herr_t
verify_storage_cont(unsigned action, hid_t did, unsigned int which, unsigned max_compact, unsigned min_dense,
unsigned asteps)
{
- bool ret = true;
+ hbool_t ret = TRUE;
HDassert(action == ADD_ATTR || action == DELETE_ATTR);
@@ -1663,7 +1660,7 @@ verify_storage_cont(unsigned action, hid_t did, unsigned int which, unsigned max
/*
* Verify the storage condition at the specific checkpoint
*/
-static bool
+static herr_t
verify_storage_cont_real(hid_t did, unsigned int which, unsigned cut_point)
{
H5O_native_info_t ninfo;
@@ -1690,7 +1687,7 @@ verify_storage_cont_real(hid_t did, unsigned int which, unsigned cut_point)
}
error:
- return false;
+ return FAIL;
} /* verify_storage_cont_real() */
@@ -1701,8 +1698,8 @@ error:
/*
* Initialize the named pipes for test synchronization.
*/
-static bool
-np_init(np_state_t *np, bool writer)
+static herr_t
+np_init(np_state_t *np, hbool_t writer)
{
*np = NP_INITIALIZER;
@@ -1749,18 +1746,18 @@ np_init(np_state_t *np, bool writer)
TEST_ERROR;
}
- return true;
+ return SUCCEED;
error:
- return false;
+ return FAIL;
} /* np_init() */
/*
* Close the named pipes.
*/
-static bool
-np_close(np_state_t *np, bool writer)
+static herr_t
+np_close(np_state_t *np, hbool_t writer)
{
/* Both the writer and reader close the named pipes */
if (HDclose(np->fd_writer_to_reader) < 0) {
@@ -1785,17 +1782,17 @@ np_close(np_state_t *np, bool writer)
TEST_ERROR;
}
}
- return true;
+ return SUCCEED;
error:
- return false;
+ return FAIL;
} /* np_close() */
/*
* Writer synchronization depending on the result from the attribute action performed.
*/
-static bool
-np_writer(bool result, unsigned step, const state_t *s, np_state_t *np, H5F_vfd_swmr_config_t *config)
+static herr_t
+np_writer(hbool_t result, unsigned step, const state_t *s, np_state_t *np, H5F_vfd_swmr_config_t *config)
{
unsigned int i;
@@ -1808,7 +1805,10 @@ np_writer(bool result, unsigned step, const state_t *s, np_state_t *np, H5F_vfd_
/* At communication interval, notify the reader about the failure and quit */
if (step % s->csteps == 0) {
np->notify = -1;
- HDwrite(np->fd_writer_to_reader, &np->notify, sizeof(int));
+ if (HDwrite(np->fd_writer_to_reader, &np->notify, sizeof(int)) < 0) {
+ HDprintf("HDwrite failed\n");
+ TEST_ERROR;
+ }
goto error;
}
/* The action succeeds */
@@ -1841,10 +1841,10 @@ np_writer(bool result, unsigned step, const state_t *s, np_state_t *np, H5F_vfd_
}
}
}
- return true;
+ return SUCCEED;
error:
- return false;
+ return FAIL;
} /* np_writer() */
@@ -1852,8 +1852,8 @@ error:
*
* Reader synchronization depending on the result from the verification.
*/
-static bool
-np_reader(bool result, unsigned step, const state_t *s, np_state_t *np)
+static herr_t
+np_reader(hbool_t result, unsigned step, const state_t *s, np_state_t *np)
{
/* The verification fails */
if (!result) {
@@ -1864,7 +1864,10 @@ np_reader(bool result, unsigned step, const state_t *s, np_state_t *np)
/* At communication interval, tell the writer about the failure and exit */
if (step % s->csteps == 0) {
np->notify = -1;
- HDwrite(np->fd_reader_to_writer, &np->notify, sizeof(int));
+ if (HDwrite(np->fd_reader_to_writer, &np->notify, sizeof(int)) < 0) {
+ HDprintf("HDwrite failed\n");
+ TEST_ERROR;
+ }
goto error;
}
/* The verification succeeds */
@@ -1879,10 +1882,10 @@ np_reader(bool result, unsigned step, const state_t *s, np_state_t *np)
}
}
}
- return true;
+ return SUCCEED;
error:
- return false;
+ return FAIL;
} /* np_reader() */
@@ -1890,7 +1893,7 @@ error:
* Handshake between writer and reader:
* Confirm `verify` is same as `notify`.
*/
-static bool
+static herr_t
np_confirm_verify_notify(int fd, unsigned step, const state_t *s, np_state_t *np)
{
if (step % s->csteps == 0) {
@@ -1911,17 +1914,17 @@ np_confirm_verify_notify(int fd, unsigned step, const state_t *s, np_state_t *np
}
}
- return true;
+ return SUCCEED;
error:
- return false;
+ return FAIL;
} /* confirm_verify_notify() */
/*
* Synchronization done by the reader before moving onto the
* next verification phase.
*/
-static bool
+static herr_t
np_reader_no_verification(const state_t *s, np_state_t *np, H5F_vfd_swmr_config_t *config)
{
if (s->use_np) {
@@ -1943,10 +1946,10 @@ np_reader_no_verification(const state_t *s, np_state_t *np, H5F_vfd_swmr_config_
}
}
- return true;
+ return SUCCEED;
error:
- return false;
+ return FAIL;
} /* np_reader_no_verification() */
@@ -1955,14 +1958,14 @@ main(int argc, char **argv)
{
hid_t fapl = H5I_INVALID_HID;
hid_t fcpl = H5I_INVALID_HID;
- bool writer = FALSE;
+ hbool_t writer = FALSE;
state_t s;
const char * personality;
H5F_vfd_swmr_config_t config;
np_state_t np;
dsets_state_t ds;
- if (!state_init(&s, argc, argv)) {
+ if (!state_init(&s, argc, (const char *const *)argv)) {
HDprintf("state_init() failed\n");
TEST_ERROR;
}
@@ -1970,20 +1973,21 @@ main(int argc, char **argv)
personality = HDstrstr(s.progname, "vfd_swmr_attrdset_");
if (personality != NULL && HDstrcmp(personality, "vfd_swmr_attrdset_writer") == 0)
- writer = true;
+ writer = TRUE;
else if (personality != NULL && HDstrcmp(personality, "vfd_swmr_attrdset_reader") == 0)
- writer = false;
+ writer = FALSE;
else {
HDprintf("unknown personality, expected vfd_swmr_attrdset_{reader,writer}\n");
TEST_ERROR;
}
/* config, tick_len, max_lag, writer, maintain_metadata_file, generate_updater_files,
- flush_raw_data, md_pages_reserved, md_file_path, updater_file_path */
+ * flush_raw_data, md_pages_reserved, md_file_path, updater_file_path
+ */
init_vfd_swmr_config(&config, 4, 7, writer, TRUE, FALSE, TRUE, 128, "./attrdset-shadow", NULL);
/* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */
- if ((fapl = vfd_swmr_create_fapl(true, s.use_vfd_swmr, true, 4096, &config)) < 0) {
+ if ((fapl = vfd_swmr_create_fapl(TRUE, s.use_vfd_swmr, TRUE, 4096, &config)) < 0) {
HDprintf("vfd_swmr_create_fapl() failed\n");
TEST_ERROR;
}
diff --git a/test/vfd_swmr_bigset_writer.c b/test/vfd_swmr_bigset_writer.c
index 3540c61..71bd730 100644
--- a/test/vfd_swmr_bigset_writer.c
+++ b/test/vfd_swmr_bigset_writer.c
@@ -238,8 +238,6 @@ state_initializer(void)
static bool state_init(state_t *, int, char **);
-static const hid_t badhid = H5I_INVALID_HID;
-
static hsize_t two_dee_max_dims[RANK2], three_dee_max_dims[RANK3];
static void
@@ -322,7 +320,7 @@ static bool
state_init(state_t *s, int argc, char **argv)
{
unsigned long tmp;
- int ch;
+ int opt;
unsigned i;
const hsize_t dims = 1;
char * tfile = NULL;
@@ -331,7 +329,9 @@ state_init(state_t *s, int argc, char **argv)
double rdcc_w0;
quadrant_t *const ul = &s->quadrants.ul, *const ur = &s->quadrants.ur, *const bl = &s->quadrants.bl,
*const br = &s->quadrants.br, *const src = &s->quadrants.src;
- const char *personality;
+ const char * personality;
+ const char * s_opts = "ACFMNPRSTVa:bc:d:e:f:g:j:k:l:m:n:o:p:qr:s:tu:v:w:";
+ struct h5_long_options l_opts[] = {{NULL, 0, '\0'}};
*s = state_initializer();
@@ -345,8 +345,8 @@ state_init(state_t *s, int argc, char **argv)
if (tfile)
HDfree(tfile);
- while ((ch = getopt(argc, argv, "ACFMNPRSTVa:bc:d:e:f:g:j:k:l:m:n:o:p:qr:s:tu:v:w:")) != -1) {
- switch (ch) {
+ while ((opt = H5_get_option(argc, (const char *const *)argv, s_opts, l_opts)) != EOF) {
+ switch (opt) {
case 'A':
s->use_aux_proc = true;
break;
@@ -382,13 +382,13 @@ state_init(state_t *s, int argc, char **argv)
s->use_named_pipe = false;
break;
case 'd':
- if (HDstrcmp(optarg, "1") == 0 || HDstrcmp(optarg, "one") == 0)
+ if (HDstrcmp(H5_optarg, "1") == 0 || HDstrcmp(H5_optarg, "one") == 0)
s->expand_2d = false;
- else if (HDstrcmp(optarg, "2") == 0 || HDstrcmp(optarg, "two") == 0 ||
- HDstrcmp(optarg, "both") == 0)
+ else if (HDstrcmp(H5_optarg, "2") == 0 || HDstrcmp(H5_optarg, "two") == 0 ||
+ HDstrcmp(H5_optarg, "both") == 0)
s->expand_2d = true;
else {
- HDfprintf(stderr, "bad -d argument %s\n", optarg);
+ HDfprintf(stderr, "bad -d argument %s\n", H5_optarg);
TEST_ERROR;
}
break;
@@ -410,40 +410,40 @@ state_init(state_t *s, int argc, char **argv)
case 'v':
case 'w':
errno = 0;
- tmp = HDstrtoul(optarg, &end, 0);
- if (end == optarg || *end != '\0') {
- HDfprintf(stderr, "couldn't parse -%c argument %s\n", ch, optarg);
+ tmp = HDstrtoul(H5_optarg, &end, 0);
+ if (end == H5_optarg || *end != '\0') {
+ HDfprintf(stderr, "couldn't parse -%c argument %s\n", opt, H5_optarg);
TEST_ERROR;
}
else if (errno != 0) {
- HDfprintf(stderr, "couldn't parse -%c argument %s\n", ch, optarg);
+ HDfprintf(stderr, "couldn't parse -%c argument %s\n", opt, H5_optarg);
TEST_ERROR;
}
else if (tmp > UINT_MAX) {
- HDfprintf(stderr, "-%c argument %lu too large", ch, tmp);
+ HDfprintf(stderr, "-%c argument %lu too large", opt, tmp);
TEST_ERROR;
}
- if ((ch == 'c' || ch == 'r') && tmp == 0) {
- HDfprintf(stderr, "-%c argument %lu must be >= 1", ch, tmp);
+ if ((opt == 'c' || opt == 'r') && tmp == 0) {
+ HDfprintf(stderr, "-%c argument %lu must be >= 1", opt, tmp);
TEST_ERROR;
}
- if (ch == 'a')
+ if (opt == 'a')
s->asteps = (unsigned)tmp;
- else if (ch == 'c')
+ else if (opt == 'c')
s->cols = (unsigned)tmp;
- else if (ch == 'e')
+ else if (opt == 'e')
s->depth = (unsigned)tmp;
- else if (ch == 'f')
+ else if (opt == 'f')
s->tick_len = (unsigned)tmp;
- else if (ch == 'g')
+ else if (opt == 'g')
s->max_lag = (unsigned)tmp;
- else if (ch == 'j')
+ else if (opt == 'j')
s->skip_chunk = (unsigned)tmp;
- else if (ch == 'k')
+ else if (opt == 'k')
s->part_chunk = (unsigned)tmp;
- else if (ch == 'l') {
+ else if (opt == 'l') {
/* Translate the tick number to time represented by the timespec struct */
float time = (float)(((unsigned)tmp * TICK_LEN) / 10.0);
unsigned sec = (unsigned)time;
@@ -452,21 +452,21 @@ state_init(state_t *s, int argc, char **argv)
s->ival.tv_sec = sec;
s->ival.tv_nsec = nsec;
}
- else if (ch == 'm')
+ else if (opt == 'm')
s->mdc_init_size = (unsigned)tmp;
- else if (ch == 'n')
+ else if (opt == 'n')
s->nsteps = (unsigned)tmp;
- else if (ch == 'o')
+ else if (opt == 'o')
s->page_buf_size = (unsigned)tmp;
- else if (ch == 'p')
+ else if (opt == 'p')
s->fsp_size = (unsigned)tmp;
- else if (ch == 'r')
+ else if (opt == 'r')
s->rows = (unsigned)tmp;
- else if (ch == 'u')
+ else if (opt == 'u')
s->over_extend = (unsigned)tmp;
- else if (ch == 'v')
+ else if (opt == 'v')
s->chunk_cache_size = (unsigned)tmp;
- else if (ch == 'w')
+ else if (opt == 'w')
s->deflate_level = (unsigned)tmp;
else
s->ndatasets = (unsigned)tmp;
@@ -486,8 +486,8 @@ state_init(state_t *s, int argc, char **argv)
break;
}
}
- argc -= optind;
- argv += optind;
+ argc -= H5_optind;
+ argv += H5_optind;
if (argc > 0) {
HDfprintf(stderr, "unexpected command-line arguments\n");
@@ -664,8 +664,8 @@ state_init(state_t *s, int argc, char **argv)
}
for (i = 0; i < s->ndatasets; i++) {
- s->dataset[i] = badhid;
- s->sources[i].ul = s->sources[i].ur = s->sources[i].bl = s->sources[i].br = badhid;
+ s->dataset[i] = H5I_INVALID_HID;
+ s->sources[i].ul = s->sources[i].ur = s->sources[i].bl = s->sources[i].br = H5I_INVALID_HID;
}
if (s->test_3d) {
@@ -879,7 +879,7 @@ state_destroy(state_t *s)
for (i = 0; i < NELMTS(s->file); i++) {
hid_t fid = s->file[i];
- s->file[i] = badhid;
+ s->file[i] = H5I_INVALID_HID;
if (s->vds != vds_multi && i > 0)
continue;
@@ -1173,6 +1173,7 @@ error:
*
*-------------------------------------------------------------------------
*/
+#ifdef TMP
static herr_t
md_ck_cb(char *md_file_path, uint64_t updater_seq_num)
{
@@ -1253,6 +1254,7 @@ error:
return -1;
} /* md_ck_cb() */
+#endif
static bool
create_extensible_dset(state_t *s, unsigned int which)
@@ -1422,7 +1424,7 @@ close_extensible_dset(state_t *s, unsigned int which)
TEST_ERROR;
}
- s->dataset[which] = badhid;
+ s->dataset[which] = H5I_INVALID_HID;
if (s->vds != vds_off && s->writer) {
sources_t *const srcs = &s->sources[which];
@@ -1452,7 +1454,9 @@ open_extensible_dset(state_t *s)
hsize_t dims2[RANK2], maxdims2[RANK2];
hsize_t dims3[RANK3], maxdims3[RANK3];
char dname[sizeof("/dataset-9999999999")];
- hid_t dset_id, filespace, dtype;
+ hid_t dset_id = H5I_INVALID_HID;
+ hid_t filespace = H5I_INVALID_HID;
+ hid_t dtype = H5I_INVALID_HID;
int rank;
unsigned int which, i;
@@ -2543,13 +2547,12 @@ error:
int
main(int argc, char **argv)
{
- mat_t * mat = NULL;
- hid_t fcpl = H5I_INVALID_HID;
- unsigned which;
- state_t s;
- np_state_t np;
- size_t i;
- H5F_generate_md_ck_cb_t cb_info; /* Callback */
+ mat_t * mat = NULL;
+ hid_t fcpl = H5I_INVALID_HID;
+ unsigned which;
+ state_t s;
+ np_state_t np;
+ size_t i;
if (!state_init(&s, argc, argv)) {
HDfprintf(stderr, "state_init failed\n");
@@ -2625,6 +2628,8 @@ main(int argc, char **argv)
/* This part is for debugging only */
#ifdef TMP
{
+ H5F_generate_md_ck_cb_t cb_info;
+
/* Set up callback to generate checksums for updater's metadata files */
cb_info.func = md_ck_cb;
@@ -2636,7 +2641,7 @@ main(int argc, char **argv)
s.file[i] = s.writer ? H5Fcreate(s.filename[i], H5F_ACC_TRUNC, fcpl, fapl)
: H5Fopen(s.filename[i], H5F_ACC_RDONLY, fapl);
- if (s.file[i] == badhid) {
+ if (s.file[i] == H5I_INVALID_HID) {
HDfprintf(stderr, s.writer ? "H5Fcreate failed" : "H5Fopen failed");
TEST_ERROR;
}
@@ -2801,6 +2806,6 @@ main(void)
{
HDfprintf(stderr, "Non-POSIX platform. Skipping.\n");
return EXIT_SUCCESS;
-} /* end main() */
+}
#endif /* H5_HAVE_WIN32_API */
diff --git a/test/vfd_swmr_common.c b/test/vfd_swmr_common.c
index c89b078..931b49b 100644
--- a/test/vfd_swmr_common.c
+++ b/test/vfd_swmr_common.c
@@ -167,12 +167,12 @@ block_signals(sigset_t *oldset)
{
sigset_t fullset;
- if (sigfillset(&fullset) == -1) {
+ if (HDsigfillset(&fullset) == -1) {
HDfprintf(stderr, "%s.%d: could not initialize signal masks", __func__, __LINE__);
HDexit(EXIT_FAILURE);
}
- if (sigprocmask(SIG_BLOCK, &fullset, oldset) == -1) {
+ if (HDsigprocmask(SIG_BLOCK, &fullset, oldset) == -1) {
HDfprintf(stderr, "%s.%d: sigprocmask", __func__, __LINE__);
HDexit(EXIT_FAILURE);
}
@@ -182,29 +182,12 @@ block_signals(sigset_t *oldset)
void
restore_signals(sigset_t *oldset)
{
- if (sigprocmask(SIG_SETMASK, oldset, NULL) == -1) {
+ if (HDsigprocmask(SIG_SETMASK, oldset, NULL) == -1) {
HDfprintf(stderr, "%s.%d: sigprocmask", __func__, __LINE__);
HDexit(EXIT_FAILURE);
}
}
-#if 0
-static const char *
-strsignal(int signum)
-{
- switch (signum) {
- case SIGUSR1:
- return "SIGUSR1";
- case SIGINT:
- return "SIGINT";
- case SIGPIPE:
- return "SIGPIPE";
- default:
- return "<unknown>";
- }
-}
-#endif
-
#ifndef H5_HAVE_SIGTIMEDWAIT
typedef struct timer_params_t {
@@ -223,7 +206,7 @@ timer_function(void *arg)
hbool_t done = FALSE;
/* Ignore any signals */
- sigfillset(&sleepset);
+ HDsigfillset(&sleepset);
pthread_sigmask(SIG_SETMASK, &sleepset, NULL);
for (;;) {
@@ -265,7 +248,7 @@ await_signal(hid_t fid)
struct timespec tick = {.tv_sec = 0, .tv_nsec = 1000000000 / 100};
sigset_t sleepset;
- if (sigfillset(&sleepset) == -1) {
+ if (HDsigfillset(&sleepset) == -1) {
HDfprintf(stderr, "%s.%d: could not initialize signal mask", __func__, __LINE__);
HDexit(EXIT_FAILURE);
}
@@ -313,10 +296,10 @@ await_signal(hid_t fid)
#else
for (;;) {
/* Linux and other systems */
- const int rc = sigtimedwait(&sleepset, NULL, &tick);
+ const int rc = HDsigtimedwait(&sleepset, NULL, &tick);
if (rc != -1) {
- HDfprintf(stderr, "Received %s, wrapping things up.\n", strsignal(rc));
+ HDfprintf(stderr, "Received %s, wrapping things up.\n", HDstrsignal(rc));
break;
}
else if (rc == -1 && errno == EAGAIN) {
diff --git a/test/vfd_swmr_dsetchks_writer.c b/test/vfd_swmr_dsetchks_writer.c
index 5c1f30d..caaad1b 100644
--- a/test/vfd_swmr_dsetchks_writer.c
+++ b/test/vfd_swmr_dsetchks_writer.c
@@ -185,8 +185,6 @@ static bool verify_dset_single(unsigned action, const state_t *s, const dsets_st
static bool verify_dsets_extent(unsigned action, const state_t *s, const dsets_state_t *ds, unsigned which);
static bool verify_dset_extent_real(unsigned action, hid_t did, unsigned rows, unsigned cols, unsigned which);
-static const hid_t badhid = H5I_INVALID_HID;
-
static void
usage(const char *progname)
{
@@ -263,10 +261,12 @@ usage(const char *progname)
static bool
state_init(state_t *s, int argc, char **argv)
{
- unsigned long tmp;
- int ch;
- char * tfile = NULL;
- char * end;
+ unsigned long tmp;
+ int opt;
+ char * tfile = NULL;
+ char * end;
+ const char * s_opts = "siferom:n:x:y:g:p:t:l:bqSNUu:c:";
+ struct h5_long_options l_opts[] = {{NULL, 0, '\0'}};
*s = ALL_HID_INITIALIZER;
@@ -282,8 +282,8 @@ state_init(state_t *s, int argc, char **argv)
tfile = NULL;
}
- while ((ch = getopt(argc, argv, "siferom:n:x:y:g:p:t:l:bqSNUu:c:")) != -1) {
- switch (ch) {
+ while ((opt = H5_get_option(argc, (const char *const *)argv, s_opts, l_opts)) != EOF) {
+ switch (opt) {
case 's': /* A chunked dataset with single index */
s->single_index = true;
@@ -340,39 +340,39 @@ state_init(state_t *s, int argc, char **argv)
case 'u': /* Ticks for reader to wait before verification */
case 'c': /* Communication interval */
errno = 0;
- tmp = HDstrtoul(optarg, &end, 0);
- if (end == optarg || *end != '\0') {
- HDprintf("couldn't parse `-%c` argument `%s`\n", ch, optarg);
+ tmp = HDstrtoul(H5_optarg, &end, 0);
+ if (end == H5_optarg || *end != '\0') {
+ HDprintf("couldn't parse `-%c` argument `%s`\n", opt, H5_optarg);
TEST_ERROR;
}
else if (errno != 0) {
- HDprintf("couldn't parse `-%c` argument `%s`\n", ch, optarg);
+ HDprintf("couldn't parse `-%c` argument `%s`\n", opt, H5_optarg);
TEST_ERROR;
}
else if (tmp > UINT_MAX) {
- HDprintf("`-%c` argument `%lu` too large\n", ch, tmp);
+ HDprintf("`-%c` argument `%lu` too large\n", opt, tmp);
TEST_ERROR;
}
- if (ch == 'm')
+ if (opt == 'm')
s->rows = (unsigned)tmp;
- else if (ch == 'n')
+ else if (opt == 'n')
s->cols = (unsigned)tmp;
- else if (ch == 'x')
+ else if (opt == 'x')
s->xincrs = (unsigned)tmp;
- else if (ch == 'y')
+ else if (opt == 'y')
s->ydecrs = (unsigned)tmp;
- else if (ch == 'g')
+ else if (opt == 'g')
s->gwrites = (unsigned)tmp;
- else if (ch == 'p')
+ else if (opt == 'p')
s->pwrites = (unsigned)tmp;
- else if (ch == 't')
+ else if (opt == 't')
s->twrites = (unsigned)tmp;
- else if (ch == 'l')
+ else if (opt == 'l')
s->lwrites = (unsigned)tmp;
- else if (ch == 'u')
+ else if (opt == 'u')
s->update_interval = (unsigned)tmp;
- else if (ch == 'c')
+ else if (opt == 'c')
s->csteps = (unsigned)tmp;
break;
@@ -383,8 +383,8 @@ state_init(state_t *s, int argc, char **argv)
break;
}
}
- argc -= optind;
- argv += optind;
+ argc -= H5_optind;
+ argv += H5_optind;
/* Require to specify at least -s or -i or -f or -e or -r option */
if (!s->single_index && !s->implicit_index && !s->fa_index && !s->ea_index && !s->bt2_index) {
@@ -475,9 +475,9 @@ error:
static bool
create_dsets(const state_t *s, dsets_state_t *ds)
{
- hid_t dcpl = badhid;
- hid_t dcpl2 = badhid;
- hid_t sid = badhid;
+ hid_t dcpl = H5I_INVALID_HID;
+ hid_t dcpl2 = H5I_INVALID_HID;
+ hid_t sid = H5I_INVALID_HID;
hsize_t dims[2];
unsigned fillval = FILL_INIT;
@@ -782,31 +782,31 @@ static bool
close_dsets(const dsets_state_t *ds)
{
/* Close dataset with single index */
- if (ds->single_did != badhid && H5Dclose(ds->single_did) < 0) {
+ if (ds->single_did != H5I_INVALID_HID && H5Dclose(ds->single_did) < 0) {
HDprintf("close_dset_real() dataset: single index failed\n");
TEST_ERROR;
}
/* Close dataset with implicit index */
- if (ds->implicit_did != badhid && H5Dclose(ds->implicit_did) < 0) {
+ if (ds->implicit_did != H5I_INVALID_HID && H5Dclose(ds->implicit_did) < 0) {
HDprintf("close_dset_real() dataset: implicit index failed\n");
TEST_ERROR;
}
/* Close dataset with fixed array index */
- if (ds->fa_did != badhid && H5Dclose(ds->fa_did) < 0) {
+ if (ds->fa_did != H5I_INVALID_HID && H5Dclose(ds->fa_did) < 0) {
HDprintf("close_dset_real() dataset: fa index failed\n");
TEST_ERROR;
}
/* Close dataset with extensible array index */
- if (ds->ea_did != badhid && H5Dclose(ds->ea_did) < 0) {
+ if (ds->ea_did != H5I_INVALID_HID && H5Dclose(ds->ea_did) < 0) {
HDprintf("close_dset_real() : ea index failed\n");
TEST_ERROR;
}
/* Close dataset with v2 btree index */
- if (ds->bt2_did != badhid && H5Dclose(ds->bt2_did) < 0) {
+ if (ds->bt2_did != H5I_INVALID_HID && H5Dclose(ds->bt2_did) < 0) {
HDprintf("close_dset_real() dataset: bt2 index failed\n");
TEST_ERROR;
}
@@ -1184,8 +1184,8 @@ static bool
write_chunks(unsigned action, hid_t did, hid_t tid, hsize_t *start, hsize_t *stride, hsize_t *count,
hsize_t *block)
{
- hid_t sid = badhid;
- hid_t mem_sid = badhid;
+ hid_t sid = H5I_INVALID_HID;
+ hid_t mem_sid = H5I_INVALID_HID;
hsize_t mem_dims[2];
unsigned int *buf = NULL;
unsigned i;
@@ -1299,7 +1299,7 @@ dset_extent_real(unsigned action, hid_t did, const hsize_t *chunk_dims)
hsize_t dims[2];
hsize_t max_dims[2];
hsize_t new[2];
- hid_t sid = badhid;
+ hid_t sid = H5I_INVALID_HID;
if ((sid = H5Dget_space(did)) < 0) {
HDprintf("H5Sget_space failed\n");
@@ -1721,8 +1721,8 @@ static bool
verify_chunks(unsigned action, hid_t did, hid_t tid, hsize_t *start, hsize_t *stride, hsize_t *count,
hsize_t *block, bool fileclosed, bool flush_raw_data)
{
- hid_t mem_sid = badhid;
- hid_t sid = badhid;
+ hid_t mem_sid = H5I_INVALID_HID;
+ hid_t sid = H5I_INVALID_HID;
hsize_t mem_dims[2];
unsigned int *rbuf = NULL;
unsigned i;
@@ -1882,7 +1882,7 @@ static bool
verify_dset_extent_real(unsigned action, hid_t did, unsigned rows, unsigned cols, unsigned which)
{
hsize_t dims[2];
- hid_t sid = badhid;
+ hid_t sid = H5I_INVALID_HID;
/* Refresh the dataset */
if (H5Drefresh(did) < 0) {
@@ -2079,7 +2079,10 @@ np_writer(bool result, unsigned step, const state_t *s, np_state_t *np, H5F_vfd_
/* At communication interval, notify the reader about the failure and quit */
if (step % s->csteps == 0) {
np->notify = -1;
- HDwrite(np->fd_writer_to_reader, &np->notify, sizeof(int));
+ if (HDwrite(np->fd_writer_to_reader, &np->notify, sizeof(int)) < 0) {
+ HDprintf("HDwrite failed\n");
+ TEST_ERROR;
+ }
goto error;
}
/* The action succeeds */
@@ -2135,7 +2138,10 @@ np_reader(bool result, unsigned step, const state_t *s, np_state_t *np)
/* At communication interval, tell the writer about the failure and exit */
if (step % s->csteps == 0) {
np->notify = -1;
- HDwrite(np->fd_reader_to_writer, &np->notify, sizeof(int));
+ if (HDwrite(np->fd_reader_to_writer, &np->notify, sizeof(int)) < 0) {
+ HDprintf("HDwrite failed\n");
+ TEST_ERROR;
+ }
goto error;
}
/* The verification succeeds */
@@ -2423,7 +2429,7 @@ error:
}
return EXIT_FAILURE;
-} /* main */
+}
#else /* H5_HAVE_WIN32_API */
@@ -2432,6 +2438,6 @@ main(void)
{
HDfprintf(stderr, "Non-POSIX platform. Skipping.\n");
return EXIT_SUCCESS;
-} /* end main() */
+}
#endif /* H5_HAVE_WIN32_API */
diff --git a/test/vfd_swmr_dsetops_writer.c b/test/vfd_swmr_dsetops_writer.c
index 7760dab..8ef0962 100644
--- a/test/vfd_swmr_dsetops_writer.c
+++ b/test/vfd_swmr_dsetops_writer.c
@@ -192,8 +192,6 @@ static bool verify_dset_compact(const state_t *s, const dsets_state_t *ds, bool
static bool closing_on_noflush(bool writer, state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *config,
np_state_t *np);
-static const hid_t badhid = H5I_INVALID_HID;
-
/* Names for datasets */
#define DSET_COMPACT_NAME "compact_dset"
#define DSET_CONTIG_NAME "contig_dset"
@@ -265,10 +263,12 @@ usage(const char *progname)
static bool
state_init(state_t *s, int argc, char **argv)
{
- unsigned long tmp;
- int ch;
- char * tfile = NULL;
- char * end;
+ unsigned long tmp;
+ int opt;
+ char * tfile = NULL;
+ char * end;
+ const char * s_opts = "pte:gkm:n:s:r:l:w:bqSNUORu:c:";
+ struct h5_long_options l_opts[] = {{NULL, 0, '\0'}};
*s = ALL_HID_INITIALIZER;
@@ -284,8 +284,8 @@ state_init(state_t *s, int argc, char **argv)
tfile = NULL;
}
- while ((ch = getopt(argc, argv, "pte:gkm:n:s:r:l:w:bqSNUORu:c:")) != -1) {
- switch (ch) {
+ while ((opt = H5_get_option(argc, (const char *const *)argv, s_opts, l_opts)) != EOF) {
+ switch (opt) {
case 'p': /* compact dataset */
s->compact = true;
@@ -341,37 +341,37 @@ state_init(state_t *s, int argc, char **argv)
case 'u': /* ticks for raeder to wait before verification */
case 'c': /* communication interval */
errno = 0;
- tmp = HDstrtoul(optarg, &end, 0);
- if (end == optarg || *end != '\0') {
- HDprintf("couldn't parse `-%c` argument `%s`\n", ch, optarg);
+ tmp = HDstrtoul(H5_optarg, &end, 0);
+ if (end == H5_optarg || *end != '\0') {
+ HDprintf("couldn't parse `-%c` argument `%s`\n", opt, H5_optarg);
TEST_ERROR;
}
else if (errno != 0) {
- HDprintf("couldn't parse `-%c` argument `%s`\n", ch, optarg);
+ HDprintf("couldn't parse `-%c` argument `%s`\n", opt, H5_optarg);
TEST_ERROR;
}
else if (tmp > UINT_MAX) {
- HDprintf("`-%c` argument `%lu` too large\n", ch, tmp);
+ HDprintf("`-%c` argument `%lu` too large\n", opt, tmp);
TEST_ERROR;
}
- if (ch == 'e')
+ if (opt == 'e')
s->compact_elmts = (unsigned)tmp;
- else if (ch == 'm')
+ else if (opt == 'm')
s->rows = (unsigned)tmp;
- else if (ch == 'n')
+ else if (opt == 'n')
s->cols = (unsigned)tmp;
- else if (ch == 's')
+ else if (opt == 's')
s->swrites = (unsigned)tmp;
- else if (ch == 'r')
+ else if (opt == 'r')
s->rwrites = (unsigned)tmp;
- else if (ch == 'l')
+ else if (opt == 'l')
s->lwrites = (unsigned)tmp;
- else if (ch == 'w')
+ else if (opt == 'w')
s->wwrites = (unsigned)tmp;
- else if (ch == 'u')
+ else if (opt == 'u')
s->update_interval = (unsigned)tmp;
- else if (ch == 'c')
+ else if (opt == 'c')
s->csteps = (unsigned)tmp;
break;
@@ -382,8 +382,8 @@ state_init(state_t *s, int argc, char **argv)
break;
}
}
- argc -= optind;
- argv += optind;
+ argc -= H5_optind;
+ argv += H5_optind;
/* Require to specify at least -p or -g or -k option */
if (!s->compact && !s->contig && !s->chunked) {
@@ -476,11 +476,11 @@ error:
static bool
create_dsets(const state_t *s, dsets_state_t *ds)
{
- hid_t dcpl = badhid;
- hid_t dtid = badhid;
+ hid_t dcpl = H5I_INVALID_HID;
+ hid_t dtid = H5I_INVALID_HID;
unsigned i;
H5R_ref_t *obj_buf = NULL; /* Buffer for object references */
- hid_t sid = badhid;
+ hid_t sid = H5I_INVALID_HID;
hsize_t obj_dims = OBJ_REF_DIMS; /* Dimension for object reference dataset */
hsize_t reg_dims = REG_REF_DIMS; /* Dimension for region reference dataset */
@@ -1095,12 +1095,12 @@ error:
static bool
close_dset_real(hid_t did, hid_t sid)
{
- if (did != badhid && H5Dclose(did) < 0) {
+ if (did != H5I_INVALID_HID && H5Dclose(did) < 0) {
HDprintf("H5Dclose dataset failed\n");
TEST_ERROR;
}
- if (sid != badhid && H5Sclose(sid) < 0) {
+ if (sid != H5I_INVALID_HID && H5Sclose(sid) < 0) {
HDprintf("H5Sclose dataspace for dataset failed\n");
TEST_ERROR;
}
@@ -1783,7 +1783,7 @@ verify_dset(hid_t did, hid_t tid, hid_t sid, hid_t mem_sid, hsize_t *start, hsiz
/* If region reference is enabled, obtain the dataset selection from the reference buffer */
if (reg_buf != NULL) { /* Imply region reference is enabled */
- hid_t temp_sid = badhid;
+ hid_t temp_sid = H5I_INVALID_HID;
H5E_BEGIN_TRY
{
@@ -1841,7 +1841,7 @@ error:
static bool
verify_dset_compact(const state_t *s, const dsets_state_t *ds, bool fileclosed, bool flush_raw_data)
{
- unsigned int *rbuf;
+ unsigned int *rbuf = NULL;
unsigned i;
/* Refresh the dataset */
@@ -1999,7 +1999,10 @@ np_writer(bool result, unsigned step, const state_t *s, np_state_t *np, H5F_vfd_
/* At communication interval, notify the reader about the failure and quit */
if (step % s->csteps == 0) {
np->notify = -1;
- HDwrite(np->fd_writer_to_reader, &np->notify, sizeof(int));
+ if (HDwrite(np->fd_writer_to_reader, &np->notify, sizeof(int)) < 0) {
+ HDprintf("HDwrite failed\n");
+ TEST_ERROR;
+ }
goto error;
}
}
@@ -2054,7 +2057,10 @@ np_reader(bool result, unsigned step, const state_t *s, np_state_t *np)
/* At communication interval, tell the writer about the failure and exit */
if (step % s->csteps == 0) {
np->notify = -1;
- HDwrite(np->fd_reader_to_writer, &np->notify, sizeof(int));
+ if (HDwrite(np->fd_reader_to_writer, &np->notify, sizeof(int)) < 0) {
+ HDprintf("HDwrite failed\n");
+ TEST_ERROR;
+ }
goto error;
}
/* The verification succeeds */
@@ -2337,7 +2343,7 @@ error:
}
return EXIT_FAILURE;
-} /* main */
+}
#else /* H5_HAVE_WIN32_API */
@@ -2346,6 +2352,6 @@ main(void)
{
HDfprintf(stderr, "Non-POSIX platform. Skipping.\n");
return EXIT_SUCCESS;
-} /* end main() */
+}
#endif /* H5_HAVE_WIN32_API */
diff --git a/test/vfd_swmr_group_writer.c b/test/vfd_swmr_group_writer.c
index 00387ce..53c9cec 100644
--- a/test/vfd_swmr_group_writer.c
+++ b/test/vfd_swmr_group_writer.c
@@ -34,13 +34,13 @@ typedef struct {
unsigned int csteps;
unsigned int nsteps;
unsigned int update_interval;
- bool use_vfd_swmr;
- bool old_style_grp;
- bool use_named_pipes;
+ hbool_t use_vfd_swmr;
+ hbool_t old_style_grp;
+ hbool_t use_named_pipes;
char grp_op_pattern;
- bool grp_op_test;
+ hbool_t grp_op_test;
char at_pattern;
- bool attr_test;
+ hbool_t attr_test;
uint32_t max_lag;
uint32_t tick_len;
uint32_t ps;
@@ -56,9 +56,9 @@ typedef struct {
{ \
.file = H5I_INVALID_HID, .one_by_one_sid = H5I_INVALID_HID, .filename = "", \
.filetype = H5T_NATIVE_UINT32, .asteps = 10, .csteps = 10, .nsteps = 100, \
- .update_interval = READER_WAIT_TICKS, .use_vfd_swmr = true, .old_style_grp = false, \
- .use_named_pipes = true, .grp_op_pattern = ' ', .grp_op_test = false, .at_pattern = ' ', \
- .attr_test = false, .tick_len = 4, .max_lag = 7, .ps = 4096, .pbs = 4096, .np_fd_w_to_r = -1, \
+ .update_interval = READER_WAIT_TICKS, .use_vfd_swmr = TRUE, .old_style_grp = FALSE, \
+ .use_named_pipes = TRUE, .grp_op_pattern = ' ', .grp_op_test = FALSE, .at_pattern = ' ', \
+ .attr_test = FALSE, .tick_len = 4, .max_lag = 7, .ps = 4096, .pbs = 4096, .np_fd_w_to_r = -1, \
.np_fd_r_to_w = -1, .np_notify = 0, .np_verify = 0 \
}
@@ -144,14 +144,16 @@ usage(const char *progname)
HDexit(EXIT_FAILURE);
}
-static bool
+static hbool_t
state_init(state_t *s, int argc, char **argv)
{
- unsigned long tmp;
- int ch;
- const hsize_t dims = 1;
- char * tfile = NULL;
- char * end;
+ unsigned long tmp;
+ int opt;
+ const hsize_t dims = 1;
+ char * tfile = NULL;
+ char * end;
+ const char * s_opts = "SGa:bc:n:Nqu:t:m:B:s:A:O:";
+ struct h5_long_options l_opts[] = {{NULL, 0, '\0'}};
*s = ALL_HID_INITIALIZER;
@@ -167,13 +169,13 @@ state_init(state_t *s, int argc, char **argv)
tfile = NULL;
}
- while ((ch = getopt(argc, argv, "SGa:bc:n:Nqu:t:m:B:s:A:O:")) != -1) {
- switch (ch) {
+ while ((opt = H5_get_option(argc, (const char *const *)argv, s_opts, l_opts)) != EOF) {
+ switch (opt) {
case 'S':
- s->use_vfd_swmr = false;
+ s->use_vfd_swmr = FALSE;
break;
case 'G':
- s->old_style_grp = true;
+ s->old_style_grp = TRUE;
break;
case 'a':
case 'c':
@@ -184,90 +186,90 @@ state_init(state_t *s, int argc, char **argv)
case 'B':
case 's':
errno = 0;
- tmp = HDstrtoul(optarg, &end, 0);
- if (end == optarg || *end != '\0') {
- HDprintf("couldn't parse `-%c` argument `%s`\n", ch, optarg);
+ tmp = HDstrtoul(H5_optarg, &end, 0);
+ if (end == H5_optarg || *end != '\0') {
+ HDprintf("couldn't parse `-%c` argument `%s`\n", opt, H5_optarg);
TEST_ERROR;
}
else if (errno != 0) {
- HDprintf("couldn't parse `-%c` argument `%s`\n", ch, optarg);
+ HDprintf("couldn't parse `-%c` argument `%s`\n", opt, H5_optarg);
TEST_ERROR;
}
else if (tmp > UINT_MAX) {
- HDprintf("`-%c` argument `%lu` too large\n", ch, tmp);
+ HDprintf("`-%c` argument `%lu` too large\n", opt, tmp);
TEST_ERROR;
}
- if (ch == 'a')
+ if (opt == 'a')
s->asteps = (unsigned)tmp;
- else if (ch == 'c')
+ else if (opt == 'c')
s->csteps = (unsigned)tmp;
- else if (ch == 'n')
+ else if (opt == 'n')
s->nsteps = (unsigned)tmp;
- else if (ch == 'u')
+ else if (opt == 'u')
s->update_interval = (unsigned)tmp;
- else if (ch == 't')
+ else if (opt == 't')
s->tick_len = (unsigned)tmp;
- else if (ch == 'm')
+ else if (opt == 'm')
s->max_lag = (unsigned)tmp;
- else if (ch == 'B')
+ else if (opt == 'B')
s->pbs = (unsigned)tmp;
- else if (ch == 's')
+ else if (opt == 's')
s->ps = (unsigned)tmp;
break;
case 'b':
s->filetype = H5T_STD_U32BE;
break;
case 'N':
- s->use_named_pipes = false;
+ s->use_named_pipes = FALSE;
break;
case 'O':
- if (HDstrcmp(optarg, "grp-creation") == 0)
+ if (HDstrcmp(H5_optarg, "grp-creation") == 0)
s->grp_op_pattern = 'c';
- else if (HDstrcmp(optarg, "grp-deletion") == 0)
+ else if (HDstrcmp(H5_optarg, "grp-deletion") == 0)
s->grp_op_pattern = 'd';
- else if (HDstrcmp(optarg, "grp-move") == 0)
+ else if (HDstrcmp(H5_optarg, "grp-move") == 0)
s->grp_op_pattern = 'm';
- else if (HDstrcmp(optarg, "grp-ins-links") == 0)
+ else if (HDstrcmp(H5_optarg, "grp-ins-links") == 0)
s->grp_op_pattern = 'i';
- else if (HDstrcmp(optarg, "grp-del-links") == 0)
+ else if (HDstrcmp(H5_optarg, "grp-del-links") == 0)
s->grp_op_pattern = 'D';
- else if (HDstrcmp(optarg, "grp-compact-t-dense") == 0)
+ else if (HDstrcmp(H5_optarg, "grp-compact-t-dense") == 0)
s->grp_op_pattern = 't';
- else if (HDstrcmp(optarg, "grp-dense-t-compact") == 0)
+ else if (HDstrcmp(H5_optarg, "grp-dense-t-compact") == 0)
s->grp_op_pattern = 'T';
else {
- HDprintf("Invalid -O argument \"%s\"", optarg);
+ HDprintf("Invalid -O argument \"%s\"", H5_optarg);
TEST_ERROR;
}
break;
case 'A':
- if (HDstrcmp(optarg, "compact") == 0)
+ if (HDstrcmp(H5_optarg, "compact") == 0)
s->at_pattern = 'c';
- else if (HDstrcmp(optarg, "dense") == 0)
+ else if (HDstrcmp(H5_optarg, "dense") == 0)
s->at_pattern = 'd';
- else if (HDstrcmp(optarg, "compact-add-to-dense") == 0)
+ else if (HDstrcmp(H5_optarg, "compact-add-to-dense") == 0)
s->at_pattern = 't';
- else if (HDstrcmp(optarg, "compact-del") == 0)
+ else if (HDstrcmp(H5_optarg, "compact-del") == 0)
s->at_pattern = 'C';
- else if (HDstrcmp(optarg, "dense-del") == 0)
+ else if (HDstrcmp(H5_optarg, "dense-del") == 0)
s->at_pattern = 'D';
- else if (HDstrcmp(optarg, "dense-del-to-compact") == 0)
+ else if (HDstrcmp(H5_optarg, "dense-del-to-compact") == 0)
s->at_pattern = 'T';
- else if (HDstrcmp(optarg, "modify") == 0)
+ else if (HDstrcmp(H5_optarg, "modify") == 0)
s->at_pattern = 'M';
- else if (HDstrcmp(optarg, "add-vstr") == 0)
+ else if (HDstrcmp(H5_optarg, "add-vstr") == 0)
s->at_pattern = 'v';
- else if (HDstrcmp(optarg, "remove-vstr") == 0)
+ else if (HDstrcmp(H5_optarg, "remove-vstr") == 0)
s->at_pattern = 'r';
- else if (HDstrcmp(optarg, "modify-vstr") == 0)
+ else if (HDstrcmp(H5_optarg, "modify-vstr") == 0)
s->at_pattern = 'm';
- else if (HDstrcmp(optarg, "add-ohr-block") == 0)
+ else if (HDstrcmp(H5_optarg, "add-ohr-block") == 0)
s->at_pattern = 'a';
- else if (HDstrcmp(optarg, "del-ohr-block") == 0)
+ else if (HDstrcmp(H5_optarg, "del-ohr-block") == 0)
s->at_pattern = 'R';
else {
- HDprintf("Invalid -A argument \"%s\"", optarg);
+ HDprintf("Invalid -A argument \"%s\"", H5_optarg);
TEST_ERROR;
}
break;
@@ -280,13 +282,13 @@ state_init(state_t *s, int argc, char **argv)
break;
}
}
- argc -= optind;
- argv += optind;
+ argc -= H5_optind;
+ argv += H5_optind;
if (s->grp_op_pattern != ' ')
- s->grp_op_test = true;
+ s->grp_op_test = TRUE;
if (s->at_pattern != ' ')
- s->attr_test = true;
+ s->attr_test = TRUE;
if (!s->grp_op_test) {
if (s->asteps < 1 || s->asteps > s->nsteps) {
@@ -322,12 +324,12 @@ state_init(state_t *s, int argc, char **argv)
esnprintf(s->filename, sizeof(s->filename), "vfd_swmr_group.h5");
- return true;
+ return TRUE;
error:
if (tfile)
HDfree(tfile);
- return false;
+ return FALSE;
}
/* Named Pipe Subroutine: np_wr_send_receive
@@ -342,7 +344,7 @@ error:
* notification number from the message sent
* by the reader.
*/
-static bool
+static hbool_t
np_wr_send_receive(state_t *s)
{
@@ -383,10 +385,10 @@ np_wr_send_receive(state_t *s)
TEST_ERROR;
}
- return true;
+ return TRUE;
error:
- return false;
+ return FALSE;
}
/* Named Pipe Subroutine: np_rd_receive
@@ -401,7 +403,7 @@ error:
* notification number from the message sent
* by the writer.
*/
-static bool
+static hbool_t
np_rd_receive(state_t *s)
{
@@ -425,10 +427,10 @@ np_rd_receive(state_t *s)
TEST_ERROR;
}
- return true;
+ return TRUE;
error:
- return false;
+ return FALSE;
}
/* Named Pipe Subroutine: np_rd_send
@@ -438,7 +440,7 @@ error:
* True if succeed
* False if an error occurs in sending the message.
*/
-static bool
+static hbool_t
np_rd_send(state_t *s)
{
@@ -446,10 +448,10 @@ np_rd_send(state_t *s)
H5_FAILED();
AT();
HDprintf("HDwrite failed\n");
- return false;
+ return FALSE;
}
else
- return true;
+ return TRUE;
}
/* Named Pipe Subroutine: np_send_error
@@ -462,7 +464,7 @@ np_rd_send(state_t *s)
* None
*/
static void
-np_send_error(state_t *s, bool writer)
+np_send_error(state_t *s, hbool_t writer)
{
s->np_notify = -1;
if (writer)
@@ -479,19 +481,19 @@ np_send_error(state_t *s, bool writer)
* Parameters: hid_t oid
* HDF5 object ID (in this file: means group ID)
*
- * bool one_chunk_ohr
+ * hbool_t one_chunk_ohr
* flag to indicate if the object header chunk is 1 or greater
- * 1: true
- * greater than 1: false
+ * 1: TRUE
+ * greater than 1: FALSE
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
*-------------------------------------------------------------------------
*/
-static bool
-check_ohr_num_chunk(hid_t g, bool one_chunk_ohr)
+static hbool_t
+check_ohr_num_chunk(hid_t g, hbool_t one_chunk_ohr)
{
H5O_native_info_t ninfo;
@@ -502,7 +504,7 @@ check_ohr_num_chunk(hid_t g, bool one_chunk_ohr)
TEST_ERROR;
}
- if (true == one_chunk_ohr) {
+ if (TRUE == one_chunk_ohr) {
if (ninfo.hdr.nchunks != 1) {
HDprintf("Object header should have only one chunk,but it is not.\n");
TEST_ERROR;
@@ -515,10 +517,10 @@ check_ohr_num_chunk(hid_t g, bool one_chunk_ohr)
}
}
- return true;
+ return TRUE;
error:
- return false;
+ return FALSE;
}
/*-------------------------------------------------------------------------
@@ -547,13 +549,13 @@ error:
* This parameter is used to generate correct group name in a key
* debugging message.
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
add_attr(state_t *s, hid_t oid, unsigned int which, unsigned num_attrs, const char *aname_fmt,
unsigned int g_which)
{
@@ -601,7 +603,7 @@ add_attr(state_t *s, hid_t oid, unsigned int which, unsigned num_attrs, const ch
/* If coming to an "object header continuation block" test,
* we need to check if this test behaves as expected. */
if (s->at_pattern == 'a' || s->at_pattern == 'R') {
- if (false == check_ohr_num_chunk(oid, false)) {
+ if (FALSE == check_ohr_num_chunk(oid, FALSE)) {
HDprintf("An object header continuation block should be created. \n");
HDprintf("But it is not.\n");
TEST_ERROR;
@@ -610,9 +612,9 @@ add_attr(state_t *s, hid_t oid, unsigned int which, unsigned num_attrs, const ch
/* Writer sends a message to reader: an attribute is successfully generated.
then wait for the reader to verify and send an acknowledgement message back.*/
- if (s->use_named_pipes && s->attr_test == true) {
+ if (s->use_named_pipes && s->attr_test == TRUE) {
dbgf(2, "writer: write attr - ready to send/receive message: %d\n", s->np_notify + 1);
- if (np_wr_send_receive(s) == false) {
+ if (np_wr_send_receive(s) == FALSE) {
H5_FAILED();
AT();
dbgf(2, "writer: write attr - verification failed.\n");
@@ -629,12 +631,12 @@ add_attr(state_t *s, hid_t oid, unsigned int which, unsigned num_attrs, const ch
TEST_ERROR;
}
- return true;
+ return TRUE;
error:
/* Writer needs to send an error message to the reader to stop the test*/
- if (s->use_named_pipes && s->attr_test == true)
- np_send_error(s, true);
+ if (s->use_named_pipes && s->attr_test == TRUE)
+ np_send_error(s, TRUE);
error2:
H5E_BEGIN_TRY
@@ -644,7 +646,7 @@ error2:
}
H5E_END_TRY;
- return false;
+ return FALSE;
}
/*-------------------------------------------------------------------------
@@ -666,8 +668,8 @@ error2:
* is "attr-which".
*
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This function is used for the "dense" storage test.
* It is also used by the group-only, "add-ohr-block"
@@ -675,7 +677,7 @@ error2:
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
add_default_group_attr(state_t *s, hid_t g, unsigned int which)
{
@@ -705,14 +707,14 @@ add_default_group_attr(state_t *s, hid_t g, unsigned int which)
* is "attr-which".
*
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This is for the "vstr" test.
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
add_vlstr_attr(state_t *s, hid_t g, unsigned int which)
{
@@ -770,9 +772,9 @@ add_vlstr_attr(state_t *s, hid_t g, unsigned int which)
/* Writer sends a message to reader: a VL string attribute is successfully generated.
then wait for the reader to verify and send an acknowledgement message back. */
- if (s->use_named_pipes && s->attr_test == true) {
+ if (s->use_named_pipes && s->attr_test == TRUE) {
dbgf(2, "writer: write attr - ready to send the message: %d\n", s->np_notify + 1);
- if (np_wr_send_receive(s) == false) {
+ if (np_wr_send_receive(s) == FALSE) {
H5_FAILED();
AT();
dbgf(2, "writer: write attr - verification failed.\n");
@@ -780,12 +782,12 @@ add_vlstr_attr(state_t *s, hid_t g, unsigned int which)
}
}
- return true;
+ return TRUE;
error:
/* Writer needs to send an error message to the reader to stop the test*/
- if (s->use_named_pipes && s->attr_test == true)
- np_send_error(s, true);
+ if (s->use_named_pipes && s->attr_test == TRUE)
+ np_send_error(s, TRUE);
H5E_BEGIN_TRY
{
H5Aclose(aid);
@@ -797,7 +799,7 @@ error:
HDfree(astr_val);
error2:
- return false;
+ return FALSE;
}
/*-------------------------------------------------------------------------
@@ -812,10 +814,10 @@ error2:
* hid_t obj_id
* HDF5 object ID (in this file: means group ID)
*
- * bool is_dense
+ * hbool_t is_dense
* if the deleted attribute is for checking the dense storage
*
- * bool is_vl_or_ohrc
+ * hbool_t is_vl_or_ohrc
* if the deleted attribute is a VL string or for object header
* continuation check test
*
@@ -828,14 +830,14 @@ error2:
* compact.
*
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
*-------------------------------------------------------------------------
*/
-static bool
-del_one_attr(state_t *s, hid_t obj_id, bool is_dense, bool is_vl_or_ohrc, unsigned int which)
+static hbool_t
+del_one_attr(state_t *s, hid_t obj_id, hbool_t is_dense, hbool_t is_vl_or_ohrc, unsigned int which)
{
char attrname[VS_ATTR_NAME_LEN];
@@ -853,9 +855,9 @@ del_one_attr(state_t *s, hid_t obj_id, bool is_dense, bool is_vl_or_ohrc, unsign
dbgf(2, "writer: coming to delete the attribute.\n");
/* Construct the attribute name */
- if (is_dense == true)
+ if (is_dense == TRUE)
HDsprintf(attrname, aname_format_d, which, 0);
- else if (is_vl_or_ohrc == true)
+ else if (is_vl_or_ohrc == TRUE)
HDsprintf(attrname, aname_format_vl, which, 0);
else
HDsprintf(attrname, aname_format, which, 0);
@@ -869,16 +871,16 @@ del_one_attr(state_t *s, hid_t obj_id, bool is_dense, bool is_vl_or_ohrc, unsign
/* If coming to an "object header continuation block" test,
* we need to check if this test behaves as expected. */
if (s->at_pattern == 'R') {
- if (false == check_ohr_num_chunk(obj_id, true)) {
+ if (FALSE == check_ohr_num_chunk(obj_id, TRUE)) {
HDprintf("The object header chunk should not continue. \n");
TEST_ERROR;
}
}
/* Writer sends a message to reader: an attribute is successfully generated.
then wait for the reader to verify and send an acknowledgement message back. */
- if (s->use_named_pipes && s->attr_test == true) {
+ if (s->use_named_pipes && s->attr_test == TRUE) {
dbgf(2, "writer: delete attr - ready to send the message: %d\n", s->np_notify + 1);
- if (np_wr_send_receive(s) == false) {
+ if (np_wr_send_receive(s) == FALSE) {
H5_FAILED();
AT();
dbgf(2, "writer: delete attr - verification failed.\n");
@@ -886,14 +888,14 @@ del_one_attr(state_t *s, hid_t obj_id, bool is_dense, bool is_vl_or_ohrc, unsign
}
}
- return true;
+ return TRUE;
error:
- if (s->use_named_pipes && s->attr_test == true)
- np_send_error(s, true);
+ if (s->use_named_pipes && s->attr_test == TRUE)
+ np_send_error(s, TRUE);
error2:
- return false;
+ return FALSE;
}
/*-------------------------------------------------------------------------
@@ -916,23 +918,23 @@ error2:
* is "attr-which".
*
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This is for the "remove-vstr" test.
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
add_del_vlstr_attr(state_t *s, hid_t g, unsigned int which)
{
- bool ret_value = false;
+ hbool_t ret_value = FALSE;
/* Add a VL string attribute then delete it. */
ret_value = add_vlstr_attr(s, g, which);
- if (ret_value == true)
- ret_value = del_one_attr(s, g, false, true, which);
+ if (ret_value == TRUE)
+ ret_value = del_one_attr(s, g, FALSE, TRUE, which);
return ret_value;
}
@@ -957,13 +959,13 @@ add_del_vlstr_attr(state_t *s, hid_t g, unsigned int which)
* newly created group name. The group name is "group-which".
*
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
modify_attr(state_t *s, hid_t g, const char *aname_fmt, unsigned int which)
{
@@ -1001,9 +1003,9 @@ modify_attr(state_t *s, hid_t g, const char *aname_fmt, unsigned int which)
/* Writer sends a message to reader: an attribute is successfully modified.
then wait for the reader to verify and send an acknowledgement message back.*/
- if (s->use_named_pipes && s->attr_test == true) {
+ if (s->use_named_pipes && s->attr_test == TRUE) {
dbgf(2, "writer: modify attr - ready to send the message: %d\n", s->np_notify + 1);
- if (np_wr_send_receive(s) == false) {
+ if (np_wr_send_receive(s) == FALSE) {
H5_FAILED();
AT();
dbgf(2, "writer: write attr - verification failed.\n");
@@ -1014,11 +1016,11 @@ modify_attr(state_t *s, hid_t g, const char *aname_fmt, unsigned int which)
}
}
- return true;
+ return TRUE;
error:
/* Writer needs to send an error message to the reader to stop the test*/
- if (s->use_named_pipes && s->attr_test == true)
- np_send_error(s, true);
+ if (s->use_named_pipes && s->attr_test == TRUE)
+ np_send_error(s, TRUE);
H5E_BEGIN_TRY
{
H5Aclose(aid);
@@ -1027,7 +1029,7 @@ error:
H5E_END_TRY;
error2:
- return false;
+ return FALSE;
}
/*-------------------------------------------------------------------------
@@ -1047,13 +1049,13 @@ error2:
* newly created group name. The group name is "group-which".
*
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
modify_vlstr_attr(state_t *s, hid_t g, unsigned int which)
{
@@ -1112,9 +1114,9 @@ modify_vlstr_attr(state_t *s, hid_t g, unsigned int which)
/* Writer sends a message to reader: a VL string attribute is successfully generated.
then wait for the reader to verify and send an acknowledgement message back. */
- if (s->use_named_pipes && s->attr_test == true) {
+ if (s->use_named_pipes && s->attr_test == TRUE) {
dbgf(2, "writer: modify vl attr - ready to send the message: %d\n", s->np_notify + 1);
- if (np_wr_send_receive(s) == false) {
+ if (np_wr_send_receive(s) == FALSE) {
H5_FAILED();
AT();
dbgf(2, "writer: write attr - verification failed.\n");
@@ -1122,7 +1124,7 @@ modify_vlstr_attr(state_t *s, hid_t g, unsigned int which)
}
}
- return true;
+ return TRUE;
error:
H5E_BEGIN_TRY
@@ -1135,11 +1137,11 @@ error:
if (astr_val)
HDfree(astr_val);
- if (s->use_named_pipes && s->attr_test == true)
- np_send_error(s, true);
+ if (s->use_named_pipes && s->attr_test == TRUE)
+ np_send_error(s, TRUE);
error2:
- return false;
+ return FALSE;
}
/*-------------------------------------------------------------------------
@@ -1162,20 +1164,20 @@ error2:
* is "attr-which".
*
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This is for the "modify-vstr" test.
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
add_modify_vlstr_attr(state_t *s, hid_t g, unsigned int which)
{
- bool ret_value = false;
- ret_value = add_vlstr_attr(s, g, which);
- if (true == ret_value)
+ hbool_t ret_value = FALSE;
+ ret_value = add_vlstr_attr(s, g, which);
+ if (TRUE == ret_value)
ret_value = modify_vlstr_attr(s, g, which);
return ret_value;
@@ -1205,8 +1207,8 @@ add_modify_vlstr_attr(state_t *s, hid_t g, unsigned int which)
* is "attr-which".
*
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This is for the "modify-vstr" test.
* For attribute compact/dense storage, check the reference
@@ -1214,7 +1216,7 @@ add_modify_vlstr_attr(state_t *s, hid_t g, unsigned int which)
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
add_attrs_compact(state_t *s, hid_t g, hid_t gcpl, unsigned int which)
{
@@ -1239,9 +1241,9 @@ add_attrs_compact(state_t *s, hid_t g, hid_t gcpl, unsigned int which)
return add_attr(s, g, which, max_compact, aname_format, which);
error:
- if (s->use_named_pipes && s->attr_test == true)
- np_send_error(s, true);
- return false;
+ if (s->use_named_pipes && s->attr_test == TRUE)
+ np_send_error(s, TRUE);
+ return FALSE;
}
/*-------------------------------------------------------------------------
@@ -1266,8 +1268,8 @@ error:
* The number of iterations for group creation, use to generate
* newly created group and attribute names.
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This is for the "compact-to-dense" test.
* For attribute compact/dense storage, check the reference
@@ -1275,14 +1277,14 @@ error:
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
add_attrs_compact_dense(state_t *s, hid_t g, hid_t gcpl, unsigned int which)
{
unsigned max_compact = 0;
unsigned min_dense = 0;
const char *aname_format = "attr-d-%u-%u";
- bool ret_value = false;
+ hbool_t ret_value = FALSE;
if (H5Pget_attr_phase_change(gcpl, &max_compact, &min_dense) < 0) {
HDprintf("H5Pget_attr_phase_change failed\n");
@@ -1293,15 +1295,15 @@ add_attrs_compact_dense(state_t *s, hid_t g, hid_t gcpl, unsigned int which)
ret_value = add_attrs_compact(s, g, gcpl, which);
/* Add another attribute, the storage becomes dense. */
- if (ret_value == true)
+ if (ret_value == TRUE)
ret_value = add_attr(s, g, which + max_compact, 1, aname_format, which);
return ret_value;
error:
- if (s->use_named_pipes && s->attr_test == true)
- np_send_error(s, true);
- return false;
+ if (s->use_named_pipes && s->attr_test == TRUE)
+ np_send_error(s, TRUE);
+ return FALSE;
}
/*-------------------------------------------------------------------------
@@ -1326,8 +1328,8 @@ error:
* The number of iterations for group creation, use to generate
* newly created group and attribute names.
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This is an internal function used by the
* "dense-del-to-compact" test.
@@ -1336,7 +1338,7 @@ error:
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
del_attrs_compact_dense_compact(state_t *s, hid_t obj_id, hid_t gcpl, unsigned int which)
{
@@ -1369,9 +1371,9 @@ del_attrs_compact_dense_compact(state_t *s, hid_t obj_id, hid_t gcpl, unsigned i
* from the reader.
* So writer sends a message to reader: an attribute is successfully deleted.
then wait for reader to verify and send an acknowledgement message back. */
- if (s->use_named_pipes && s->attr_test == true) {
+ if (s->use_named_pipes && s->attr_test == TRUE) {
dbgf(2, "writer: delete attr - ready to send the message: %d\n", s->np_notify + 1);
- if (np_wr_send_receive(s) == false) {
+ if (np_wr_send_receive(s) == FALSE) {
H5_FAILED();
AT();
dbgf(2, "writer: delete attr - verification failed.\n");
@@ -1394,9 +1396,9 @@ del_attrs_compact_dense_compact(state_t *s, hid_t obj_id, hid_t gcpl, unsigned i
TEST_ERROR;
}
/* Again we need to notify the reader via Named pipe. */
- if (s->use_named_pipes && s->attr_test == true) {
+ if (s->use_named_pipes && s->attr_test == TRUE) {
dbgf(2, "writer: delete attr - ready to send the message: %d\n", s->np_notify + 1);
- if (np_wr_send_receive(s) == false) {
+ if (np_wr_send_receive(s) == FALSE) {
H5_FAILED();
AT();
dbgf(2, "writer: delete attr - verification failed.\n");
@@ -1404,24 +1406,14 @@ del_attrs_compact_dense_compact(state_t *s, hid_t obj_id, hid_t gcpl, unsigned i
}
}
- /* The following comments are left here in case in the future we want to
- * use HDF5 function to verify the attribute storage */
-#if 0
- // May H5Oget_info3 -- obtain the number of attributes.
- //Check the number of attributes >=min_dense.
- //We may use the internal function
- //is_dense = H5O__is_attr_dense_test(dataset) to check if it is dense in the future.
- //
-#endif
-
- return true;
+ return TRUE;
error:
- if (s->use_named_pipes && s->attr_test == true)
- np_send_error(s, true);
+ if (s->use_named_pipes && s->attr_test == TRUE)
+ np_send_error(s, TRUE);
error2:
- return false;
+ return FALSE;
}
/*-------------------------------------------------------------------------
@@ -1446,8 +1438,8 @@ error2:
* The number of iterations for group creation, use to generate
* newly created group and attribute names.
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This is for the "compact-del" test.
* For attribute compact/dense storage, check the reference
@@ -1455,15 +1447,15 @@ error2:
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
add_del_attrs_compact(state_t *s, hid_t g, hid_t gcpl, unsigned int which)
{
- bool ret_value = false;
- ret_value = add_attrs_compact(s, g, gcpl, which);
- if (ret_value == true) {
+ hbool_t ret_value = FALSE;
+ ret_value = add_attrs_compact(s, g, gcpl, which);
+ if (ret_value == TRUE) {
dbgf(2, "writer: before deleting the attribute.\n");
- ret_value = del_one_attr(s, g, false, false, which);
+ ret_value = del_one_attr(s, g, FALSE, FALSE, which);
}
return ret_value;
@@ -1492,8 +1484,8 @@ add_del_attrs_compact(state_t *s, hid_t g, hid_t gcpl, unsigned int which)
* The number of iterations for group creation, use to generate
* newly created group and attribute names.
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This is for the "dense-del" test.
* For attribute compact/dense storage, check the reference
@@ -1501,11 +1493,11 @@ add_del_attrs_compact(state_t *s, hid_t g, hid_t gcpl, unsigned int which)
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
add_del_attrs_compact_dense(state_t *s, hid_t g, hid_t gcpl, unsigned int which)
{
- bool ret_value = false;
+ hbool_t ret_value = FALSE;
unsigned max_compact = 0;
unsigned min_dense = 0;
@@ -1515,15 +1507,15 @@ add_del_attrs_compact_dense(state_t *s, hid_t g, hid_t gcpl, unsigned int which)
}
ret_value = add_attrs_compact_dense(s, g, gcpl, which);
- if (ret_value == true)
- ret_value = del_one_attr(s, g, true, false, which + max_compact);
+ if (ret_value == TRUE)
+ ret_value = del_one_attr(s, g, TRUE, FALSE, which + max_compact);
return ret_value;
error:
- if (s->use_named_pipes && s->attr_test == true)
- np_send_error(s, true);
- return false;
+ if (s->use_named_pipes && s->attr_test == TRUE)
+ np_send_error(s, TRUE);
+ return FALSE;
}
/*-------------------------------------------------------------------------
@@ -1550,8 +1542,8 @@ error:
* The number of iterations for group creation, use to generate
* newly created group and attribute names.
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This is for the "dense-del-to-compact" test.
* For attribute compact/dense storage, check the reference
@@ -1559,13 +1551,13 @@ error:
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
add_del_attrs_compact_dense_compact(state_t *s, hid_t g, hid_t gcpl, unsigned int which)
{
- bool ret_value = false;
- ret_value = add_attrs_compact_dense(s, g, gcpl, which);
- if (ret_value == true)
+ hbool_t ret_value = FALSE;
+ ret_value = add_attrs_compact_dense(s, g, gcpl, which);
+ if (ret_value == TRUE)
ret_value = del_attrs_compact_dense_compact(s, g, gcpl, which);
return ret_value;
@@ -1590,21 +1582,21 @@ add_del_attrs_compact_dense_compact(state_t *s, hid_t g, hid_t gcpl, unsigned in
* is "attr-which".
*
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This function is used for the "modify" test.
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
add_modify_default_group_attr(state_t *s, hid_t g, unsigned int which)
{
- bool ret_value = false;
+ hbool_t ret_value = FALSE;
const char *aname_format = "attr-%u";
ret_value = add_default_group_attr(s, g, which);
- if (ret_value == true)
+ if (ret_value == TRUE)
ret_value = modify_attr(s, g, aname_format, which);
return ret_value;
}
@@ -1630,22 +1622,22 @@ add_modify_default_group_attr(state_t *s, hid_t g, unsigned int which)
* is "attr-which".
*
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This function is used for the
* "deletion of object header continuation block" test.
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
del_ohr_block_attr(state_t *s, hid_t g, unsigned int which)
{
- bool ret_value = false;
- ret_value = add_default_group_attr(s, g, which);
- if (ret_value == true)
- ret_value = del_one_attr(s, g, false, true, which);
+ hbool_t ret_value = FALSE;
+ ret_value = add_default_group_attr(s, g, which);
+ if (ret_value == TRUE)
+ ret_value = del_one_attr(s, g, FALSE, TRUE, which);
return ret_value;
}
/*-------------------------------------------------------------------------
@@ -1669,19 +1661,19 @@ del_ohr_block_attr(state_t *s, hid_t g, unsigned int which)
* newly created group and attribute names.
*
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This is called by the write_group() function.
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
add_group_attribute(state_t *s, hid_t g, hid_t gcpl, unsigned int which)
{
- bool ret_value = false;
- char test_pattern = s->at_pattern;
+ hbool_t ret_value = FALSE;
+ char test_pattern = s->at_pattern;
switch (test_pattern) {
case 'c':
@@ -1738,21 +1730,21 @@ add_group_attribute(state_t *s, hid_t g, hid_t gcpl, unsigned int which)
* The number of iterations for group creation
*
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This is called by the main() function.
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
write_group(state_t *s, unsigned int which)
{
char name[sizeof("/group-9999999999")];
hid_t g = H5I_INVALID_HID;
hid_t dummy_d = H5I_INVALID_HID;
hid_t gcpl = H5I_INVALID_HID;
- bool result = true;
+ hbool_t result = TRUE;
H5G_info_t group_info;
if (which >= s->nsteps) {
@@ -1816,7 +1808,7 @@ write_group(state_t *s, unsigned int which)
/* If coming to an "object header continuation block" test,
* we need to check if this test behaves as expected. */
if (s->at_pattern == 'a' || s->at_pattern == 'R') {
- if (false == check_ohr_num_chunk(g, true)) {
+ if (FALSE == check_ohr_num_chunk(g, TRUE)) {
HDprintf("An object header continuation block should NOT be created. \n");
HDprintf("But it is created.\n");
TEST_ERROR;
@@ -1829,9 +1821,9 @@ write_group(state_t *s, unsigned int which)
* group creation error.
* Writer sends a message to reader: an attribute is successfully generated.
* then wait for the reader to verify and send an acknowledgement message back.*/
- if (s->use_named_pipes && s->attr_test == true) {
+ if (s->use_named_pipes && s->attr_test == TRUE) {
dbgf(2, "writer: ready to send the message: %d\n", s->np_notify + 1);
- if (np_wr_send_receive(s) == false) {
+ if (np_wr_send_receive(s) == FALSE) {
H5_FAILED();
AT();
/* Note: This is (mostly) because the verification failure message
@@ -1865,8 +1857,8 @@ write_group(state_t *s, unsigned int which)
error:
/* Writer needs to send an error message to the reader to stop the test*/
- if (s->use_named_pipes && s->attr_test == true)
- np_send_error(s, true);
+ if (s->use_named_pipes && s->attr_test == TRUE)
+ np_send_error(s, TRUE);
error2:
@@ -1880,7 +1872,7 @@ error2:
}
H5E_END_TRY;
- return false;
+ return FALSE;
}
/*-------------------------------------------------------------------------
* Function: check_attr_storage_type
@@ -1890,19 +1882,19 @@ error2:
* Parameters: hid_t oid
* HDF5 object ID (in this file: means group ID)
*
- * bool is_compact
- * true if the attribute is stored in compact storage
- * false if the attribute is stored in dense storage
+ * hbool_t is_compact
+ * TRUE if the attribute is stored in compact storage
+ * FALSE if the attribute is stored in dense storage
*
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
*-------------------------------------------------------------------------
*/
-static bool
-check_attr_storage_type(hid_t g, bool is_compact)
+static hbool_t
+check_attr_storage_type(hid_t g, hbool_t is_compact)
{
H5O_native_info_t ninfo;
@@ -1926,10 +1918,10 @@ check_attr_storage_type(hid_t g, bool is_compact)
}
}
- return true;
+ return TRUE;
error:
- return false;
+ return FALSE;
}
/*-------------------------------------------------------------------------
@@ -1955,25 +1947,25 @@ error:
* This parameter is used to generate correct group name in a key
* debugging message.
*
- * bool check_storage
+ * hbool_t check_storage
* a flag to indicate if the storage check is on
*
- * bool is_compact
- * true if the attribute storage should be in compact
- * false if the attribute storage should be in dense
+ * hbool_t is_compact
+ * TRUE if the attribute storage should be in compact
+ * FALSE if the attribute storage should be in dense
* Note: this parameter is not used if the check_storage
- * is set to false.
+ * is set to FALSE.
*
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
vrfy_attr(state_t *s, hid_t g, unsigned int which, const char *aname, unsigned int g_which,
- bool check_storage, bool is_compact)
+ hbool_t check_storage, hbool_t is_compact)
{
unsigned int read_which;
@@ -1984,8 +1976,8 @@ vrfy_attr(state_t *s, hid_t g, unsigned int which, const char *aname, unsigned i
* for a few ticks or stop the test if receiving an error
* message.
*/
- if (s->use_named_pipes && true == s->attr_test) {
- if (false == np_rd_receive(s)) {
+ if (s->use_named_pipes && TRUE == s->attr_test) {
+ if (FALSE == np_rd_receive(s)) {
H5_FAILED();
AT();
/* Since receiving the error message from the writer,
@@ -2026,8 +2018,8 @@ vrfy_attr(state_t *s, hid_t g, unsigned int which, const char *aname, unsigned i
TEST_ERROR;
}
- if (!s->old_style_grp && check_storage == true) {
- if (false == check_attr_storage_type(g, is_compact)) {
+ if (!s->old_style_grp && check_storage == TRUE) {
+ if (FALSE == check_attr_storage_type(g, is_compact)) {
HDprintf("The attribute storage type is wrong. \n");
TEST_ERROR;
}
@@ -2037,7 +2029,7 @@ vrfy_attr(state_t *s, hid_t g, unsigned int which, const char *aname, unsigned i
/* If coming to an "object header continuation block" test,
* we need to check if this test behaves as expected. */
if (s->at_pattern == 'a' || s->at_pattern == 'R') {
- if (false == check_ohr_num_chunk(g, false)) {
+ if (FALSE == check_ohr_num_chunk(g, FALSE)) {
HDprintf("An object header continuation block should be created. \n");
HDprintf("But it is not.\n");
HDprintf("Verification of 'object header continuation block test' failed.\n");
@@ -2046,14 +2038,14 @@ vrfy_attr(state_t *s, hid_t g, unsigned int which, const char *aname, unsigned i
}
/* If the read value is expected, send back an OK message to the writer. */
- if (s->use_named_pipes && s->attr_test == true) {
- if (np_rd_send(s) == false) {
+ if (s->use_named_pipes && s->attr_test == TRUE) {
+ if (np_rd_send(s) == FALSE) {
HDprintf("named pipe reader send message error\n");
TEST_ERROR;
}
dbgf(2, "reader: finish sending back the message: %d\n", s->np_notify);
}
- return true;
+ return TRUE;
error:
H5E_BEGIN_TRY
@@ -2064,10 +2056,10 @@ error:
H5E_END_TRY;
/* Send back an error message to the writer so that the writer can stop. */
- if (s->use_named_pipes && s->attr_test == true)
- np_send_error(s, false);
+ if (s->use_named_pipes && s->attr_test == TRUE)
+ np_send_error(s, FALSE);
error2:
- return false;
+ return FALSE;
}
/*-------------------------------------------------------------------------
@@ -2087,8 +2079,8 @@ error2:
* The expected attribute value. It is also used to construct the
* group name.
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This function is used for the "dense" storage test.
* It is also used by the group-only, "add-ohr-block"
@@ -2096,13 +2088,13 @@ error2:
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
verify_default_group_attr(state_t *s, hid_t g, unsigned int which)
{
char attrname[VS_ATTR_NAME_LEN];
const char *aname_format = "attr-%u";
HDsprintf(attrname, aname_format, which);
- return vrfy_attr(s, g, which, attrname, which, false, true);
+ return vrfy_attr(s, g, which, attrname, which, FALSE, TRUE);
}
/*-------------------------------------------------------------------------
@@ -2124,18 +2116,18 @@ verify_default_group_attr(state_t *s, hid_t g, unsigned int which)
* group name. The modified attribute value can be derived from
* the expected attribute value.
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This function is used for the "modified" test.
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
verify_modify_attr(state_t *s, hid_t g, unsigned int which)
{
- bool ret = false;
+ hbool_t ret = FALSE;
const char * aname_fmt = "attr-%u";
unsigned int read_which;
hid_t aid = H5I_INVALID_HID;
@@ -2146,14 +2138,14 @@ verify_modify_attr(state_t *s, hid_t g, unsigned int which)
ret = verify_default_group_attr(s, g, which);
/* Then the modified value */
- if (ret == true) {
+ if (ret == TRUE) {
/* The reader receives a message from the writer.Then sleep
* for a few ticks or stop the test if receiving an error
* message.
*/
- if (s->use_named_pipes && true == s->attr_test) {
- if (false == np_rd_receive(s)) {
+ if (s->use_named_pipes && TRUE == s->attr_test) {
+ if (FALSE == np_rd_receive(s)) {
H5_FAILED();
AT();
goto error2;
@@ -2198,14 +2190,14 @@ verify_modify_attr(state_t *s, hid_t g, unsigned int which)
}
/* The reader sends an OK message back to the writer. */
- if (s->use_named_pipes && s->attr_test == true) {
- if (np_rd_send(s) == false)
+ if (s->use_named_pipes && s->attr_test == TRUE) {
+ if (np_rd_send(s) == FALSE)
goto error2;
dbgf(2, "reader: modify_attr finish sending back the message: %d\n", s->np_notify);
}
- return true;
+ return TRUE;
}
- return false;
+ return FALSE;
error:
H5E_BEGIN_TRY
@@ -2216,12 +2208,12 @@ error:
H5E_END_TRY;
/* The reader needs to send an error message back to the writer to stop the test.*/
- if (s->use_named_pipes && s->attr_test == true)
- np_send_error(s, false);
+ if (s->use_named_pipes && s->attr_test == TRUE)
+ np_send_error(s, FALSE);
error2:
- return false;
+ return FALSE;
}
/*-------------------------------------------------------------------------
@@ -2241,20 +2233,20 @@ error2:
* Use to derieve the expected attribute value. It is also used
* to construct the group name.
*
- * bool vrfy_mod
- * true if this function is used for the modified VL string test.
- * false if this function is just used for the VL string test.
+ * hbool_t vrfy_mod
+ * TRUE if this function is used for the modified VL string test.
+ * FALSE if this function is just used for the VL string test.
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This function is an internal function used by
* both the "vlstr" and the "modify-vstr" tests.
*-------------------------------------------------------------------------
*/
-static bool
-verify_group_vlstr_attr(state_t *s, hid_t g, unsigned int which, bool vrfy_mod)
+static hbool_t
+verify_group_vlstr_attr(state_t *s, hid_t g, unsigned int which, hbool_t vrfy_mod)
{
hid_t aid = H5I_INVALID_HID;
hid_t atype = H5I_INVALID_HID;
@@ -2267,8 +2259,8 @@ verify_group_vlstr_attr(state_t *s, hid_t g, unsigned int which, bool vrfy_mod)
* for a few ticks or stop the test if the received message
* is an error message.
*/
- if (s->use_named_pipes && true == s->attr_test) {
- if (false == np_rd_receive(s)) {
+ if (s->use_named_pipes && TRUE == s->attr_test) {
+ if (FALSE == np_rd_receive(s)) {
H5_FAILED();
AT();
goto error2;
@@ -2288,7 +2280,7 @@ verify_group_vlstr_attr(state_t *s, hid_t g, unsigned int which, bool vrfy_mod)
/* Construct the expected VL string value,depending if
* it is the modified value or the original value. */
- if (vrfy_mod == true)
+ if (vrfy_mod == TRUE)
HDsprintf(astr_val_exp, "%u%c", which, 'A');
else
HDsprintf(astr_val_exp, "%u", which);
@@ -2340,13 +2332,13 @@ verify_group_vlstr_attr(state_t *s, hid_t g, unsigned int which, bool vrfy_mod)
HDfree(astr_val_exp);
/* Reader sends an OK message back to the reader */
- if (s->use_named_pipes && s->attr_test == true) {
- if (np_rd_send(s) == false)
+ if (s->use_named_pipes && s->attr_test == TRUE) {
+ if (np_rd_send(s) == FALSE)
goto error2;
dbgf(2, "reader: finish sending back the message: %d\n", s->np_notify);
}
- return true;
+ return TRUE;
error:
H5E_BEGIN_TRY
@@ -2361,12 +2353,12 @@ error:
HDfree(astr_val_exp);
/* The reader sends an error message to the writer to stop the test.*/
- if (s->use_named_pipes && s->attr_test == true)
- np_send_error(s, false);
+ if (s->use_named_pipes && s->attr_test == TRUE)
+ np_send_error(s, FALSE);
error2:
- return false;
+ return FALSE;
}
/*-------------------------------------------------------------------------
@@ -2384,26 +2376,26 @@ error2:
* const char* aname
* The name of the attribute to be deleted.
*
- * bool check_storage
+ * hbool_t check_storage
* a flag to indicate if the storage check is on
*
- * bool is_compact
- * true if after this attribute is deleted,
- * the storage should still be in compact, false
+ * hbool_t is_compact
+ * TRUE if after this attribute is deleted,
+ * the storage should still be in compact, FALSE
* if the storage should be in dense.
* Note: this parameter is not used if the check_storage
- * is set to false.
+ * is set to FALSE.
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This is an internal function used by "remove-vlstr",
* "compact-del","dense-del",dense-del-to-compact" tests.
*-------------------------------------------------------------------------
*/
-static bool
-verify_del_one_attr(state_t *s, hid_t g, const char *aname, bool check_storage, bool is_compact)
+static hbool_t
+verify_del_one_attr(state_t *s, hid_t g, const char *aname, hbool_t check_storage, hbool_t is_compact)
{
htri_t attr_exists = FALSE;
@@ -2412,8 +2404,8 @@ verify_del_one_attr(state_t *s, hid_t g, const char *aname, bool check_storage,
* for a few ticks or stop the test if the received message
* is an error message.
*/
- if (s->use_named_pipes && true == s->attr_test) {
- if (false == np_rd_receive(s)) {
+ if (s->use_named_pipes && TRUE == s->attr_test) {
+ if (FALSE == np_rd_receive(s)) {
H5_FAILED();
AT();
goto error2;
@@ -2438,8 +2430,8 @@ verify_del_one_attr(state_t *s, hid_t g, const char *aname, bool check_storage,
TEST_ERROR;
}
- if (!s->old_style_grp && check_storage == true) {
- if (false == check_attr_storage_type(g, is_compact)) {
+ if (!s->old_style_grp && check_storage == TRUE) {
+ if (FALSE == check_attr_storage_type(g, is_compact)) {
HDprintf("The attribute storage type is wrong. \n");
TEST_ERROR;
}
@@ -2449,7 +2441,7 @@ verify_del_one_attr(state_t *s, hid_t g, const char *aname, bool check_storage,
/* If coming to an "object header continuation block" test,
* we need to check if this test behaves as expected. */
if (s->at_pattern == 'R') {
- if (false == check_ohr_num_chunk(g, true)) {
+ if (FALSE == check_ohr_num_chunk(g, TRUE)) {
HDprintf("An object header continuation block should be removed. \n");
HDprintf("But it is NOT.\n");
HDprintf("Verification of an 'object header continuation block test' failed.\n");
@@ -2458,20 +2450,20 @@ verify_del_one_attr(state_t *s, hid_t g, const char *aname, bool check_storage,
}
/* Reader sends an OK message back to the reader */
- if (s->use_named_pipes && s->attr_test == true) {
- if (np_rd_send(s) == false)
+ if (s->use_named_pipes && s->attr_test == TRUE) {
+ if (np_rd_send(s) == FALSE)
TEST_ERROR;
dbgf(2, "reader: finish sending back the message: %d\n", s->np_notify);
}
- return true;
+ return TRUE;
error:
/* The reader sends an error message to the writer to stop the test.*/
- if (s->use_named_pipes && s->attr_test == true)
- np_send_error(s, false);
+ if (s->use_named_pipes && s->attr_test == TRUE)
+ np_send_error(s, FALSE);
error2:
- return false;
+ return FALSE;
}
/*-------------------------------------------------------------------------
@@ -2493,8 +2485,8 @@ error2:
* the attribute name.
*
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This function is for the "remove-vstr" test.
* Also note this function first verifies if
@@ -2503,17 +2495,17 @@ error2:
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
verify_remove_vlstr_attr(state_t *s, hid_t g, unsigned int which)
{
- bool ret = false;
+ hbool_t ret = FALSE;
char attrname[VS_ATTR_NAME_LEN];
const char *aname_format = "attr-%u";
- ret = verify_group_vlstr_attr(s, g, which, false);
- if (ret == true) {
+ ret = verify_group_vlstr_attr(s, g, which, FALSE);
+ if (ret == TRUE) {
HDsprintf(attrname, aname_format, which);
- ret = verify_del_one_attr(s, g, attrname, false, false);
+ ret = verify_del_one_attr(s, g, attrname, FALSE, FALSE);
}
return ret;
}
@@ -2537,8 +2529,8 @@ verify_remove_vlstr_attr(state_t *s, hid_t g, unsigned int which)
* the attribute name.
*
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This function is for the "modify-vstr" test.
* Also note this function first verifies if
@@ -2547,15 +2539,15 @@ verify_remove_vlstr_attr(state_t *s, hid_t g, unsigned int which)
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
verify_modify_vlstr_attr(state_t *s, hid_t g, unsigned int which)
{
- bool ret = false;
+ hbool_t ret = FALSE;
- ret = verify_group_vlstr_attr(s, g, which, false);
- if (ret == true)
- ret = verify_group_vlstr_attr(s, g, which, true);
+ ret = verify_group_vlstr_attr(s, g, which, FALSE);
+ if (ret == TRUE)
+ ret = verify_group_vlstr_attr(s, g, which, TRUE);
return ret;
}
@@ -2582,19 +2574,19 @@ verify_modify_vlstr_attr(state_t *s, hid_t g, unsigned int which)
* attribute names.
*
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This function is used by the "compact" test.
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
verify_attrs_compact(state_t *s, hid_t g, unsigned max_c, unsigned int which)
{
unsigned u;
- bool ret = true;
+ hbool_t ret = TRUE;
const char *aname_format = "attr-%u-%u";
char attrname[VS_ATTR_NAME_LEN];
@@ -2602,8 +2594,8 @@ verify_attrs_compact(state_t *s, hid_t g, unsigned max_c, unsigned int which)
for (u = 0; u < max_c; u++) {
HDsprintf(attrname, aname_format, which, u);
- if (false == vrfy_attr(s, g, u + which, attrname, which, true, true)) {
- ret = false;
+ if (FALSE == vrfy_attr(s, g, u + which, attrname, which, TRUE, TRUE)) {
+ ret = FALSE;
break;
}
}
@@ -2633,28 +2625,28 @@ verify_attrs_compact(state_t *s, hid_t g, unsigned max_c, unsigned int which)
* attribute names.
*
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This function is used by the "compact-dense" test.
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
verify_attrs_compact_dense(state_t *s, hid_t g, unsigned max_c, unsigned int which)
{
const char *aname_format = "attr-d-%u-%u";
char attrname[VS_ATTR_NAME_LEN];
- bool ret = verify_attrs_compact(s, g, max_c, which);
+ hbool_t ret = verify_attrs_compact(s, g, max_c, which);
- if (ret == true) {
+ if (ret == TRUE) {
/* Now the storage is in dense. Verify if the
* retrieved value is correct. */
HDsprintf(attrname, aname_format, max_c + which, 0);
- ret = vrfy_attr(s, g, which + max_c, attrname, which, true, false);
+ ret = vrfy_attr(s, g, which + max_c, attrname, which, TRUE, FALSE);
}
return ret;
}
@@ -2682,8 +2674,8 @@ verify_attrs_compact_dense(state_t *s, hid_t g, unsigned max_c, unsigned int whi
* attribute names.
*
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This function is used by the "compact-del" test.
* Also note this function first verifies if
@@ -2692,19 +2684,19 @@ verify_attrs_compact_dense(state_t *s, hid_t g, unsigned max_c, unsigned int whi
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
verify_del_attrs_compact(state_t *s, hid_t g, unsigned max_c, unsigned int which)
{
const char *aname_format = "attr-%u-%u";
char attrname[VS_ATTR_NAME_LEN];
- bool ret = verify_attrs_compact(s, g, max_c, which);
+ hbool_t ret = verify_attrs_compact(s, g, max_c, which);
- if (ret == true) {
+ if (ret == TRUE) {
/* The writer only deletes the attribute attr-which-0 */
HDsprintf(attrname, aname_format, which, 0);
- ret = verify_del_one_attr(s, g, attrname, true, true);
+ ret = verify_del_one_attr(s, g, attrname, TRUE, TRUE);
}
return ret;
@@ -2733,8 +2725,8 @@ verify_del_attrs_compact(state_t *s, hid_t g, unsigned max_c, unsigned int which
* attribute names.
*
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This function is used by the "dense-del" test.
* Also note this function first verifies if
@@ -2744,19 +2736,19 @@ verify_del_attrs_compact(state_t *s, hid_t g, unsigned max_c, unsigned int which
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
verify_del_attrs_compact_dense(state_t *s, hid_t g, unsigned max_c, unsigned int which)
{
const char *aname_format = "attr-d-%u-%u";
char attrname[VS_ATTR_NAME_LEN];
- bool ret = verify_attrs_compact_dense(s, g, max_c, which);
+ hbool_t ret = verify_attrs_compact_dense(s, g, max_c, which);
- if (ret == true) {
+ if (ret == TRUE) {
/* The writer only deletes the attribute attr-d-which-0 */
HDsprintf(attrname, aname_format, max_c + which, 0);
- ret = verify_del_one_attr(s, g, attrname, true, false);
+ ret = verify_del_one_attr(s, g, attrname, TRUE, FALSE);
}
return ret;
@@ -2790,8 +2782,8 @@ verify_del_attrs_compact_dense(state_t *s, hid_t g, unsigned max_c, unsigned int
* attribute names.
*
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This function is used by the "dense-del-to-compact" test.
* Also note this function first verifies if
@@ -2802,7 +2794,7 @@ verify_del_attrs_compact_dense(state_t *s, hid_t g, unsigned max_c, unsigned int
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
verify_del_attrs_compact_dense_compact(state_t *s, hid_t g, unsigned max_c, unsigned min_d,
unsigned int which)
{
@@ -2813,9 +2805,9 @@ verify_del_attrs_compact_dense_compact(state_t *s, hid_t g, unsigned max_c, unsi
/* Verify the attributes are added correctly from
* compact to dense storage*/
- bool ret = verify_attrs_compact_dense(s, g, max_c, which);
+ hbool_t ret = verify_attrs_compact_dense(s, g, max_c, which);
- if (ret == true) {
+ if (ret == TRUE) {
/* Then verify the deletion of attributes
* from dense to compact.
@@ -2824,15 +2816,15 @@ verify_del_attrs_compact_dense_compact(state_t *s, hid_t g, unsigned max_c, unsi
for (u--; u >= (min_d - 1); u--) {
HDsprintf(attrname, aname_format, which, max_c - u);
if (u == (min_d - 1))
- ret = verify_del_one_attr(s, g, attrname, true, true);
+ ret = verify_del_one_attr(s, g, attrname, TRUE, TRUE);
else
- ret = verify_del_one_attr(s, g, attrname, true, false);
+ ret = verify_del_one_attr(s, g, attrname, TRUE, FALSE);
}
/* Just verify one more deleted attribute by the writer.
The storage is still compact. */
HDsprintf(attrname, aname_format, max_c + which, 0);
- ret = verify_del_one_attr(s, g, attrname, true, true);
+ ret = verify_del_one_attr(s, g, attrname, TRUE, TRUE);
}
return ret;
@@ -2857,25 +2849,25 @@ verify_del_attrs_compact_dense_compact(state_t *s, hid_t g, unsigned max_c, unsi
* group and attribute names.
*
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This is called by the verify_group() function.
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
verify_del_ohr_block_attr(state_t *s, hid_t g, unsigned int which)
{
- bool ret_value = false;
+ hbool_t ret_value = FALSE;
char attrname[VS_ATTR_NAME_LEN];
const char *aname_format = "attr-%u";
ret_value = verify_default_group_attr(s, g, which);
- if (ret_value == true) {
+ if (ret_value == TRUE) {
HDsprintf(attrname, aname_format, which);
- ret_value = verify_del_one_attr(s, g, attrname, false, true);
+ ret_value = verify_del_one_attr(s, g, attrname, FALSE, TRUE);
}
return ret_value;
}
@@ -2897,18 +2889,18 @@ verify_del_ohr_block_attr(state_t *s, hid_t g, unsigned int which)
* group and attribute names.
*
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This is called by the verify_group() function.
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
verify_group_attribute(state_t *s, hid_t g, unsigned int which)
{
char test_pattern = s->at_pattern;
- bool ret = false;
+ hbool_t ret = FALSE;
unsigned max_compact = 0;
unsigned min_dense = 0;
hid_t gcpl = H5I_INVALID_HID;
@@ -2976,7 +2968,7 @@ verify_group_attribute(state_t *s, hid_t g, unsigned int which)
ret = verify_modify_attr(s, g, which);
break;
case 'v':
- ret = verify_group_vlstr_attr(s, g, which, false);
+ ret = verify_group_vlstr_attr(s, g, which, FALSE);
break;
case 'r':
ret = verify_remove_vlstr_attr(s, g, which);
@@ -2999,11 +2991,11 @@ verify_group_attribute(state_t *s, hid_t g, unsigned int which)
error:
/* Still to finish the handshaking */
- if (s->use_named_pipes && s->attr_test == true) {
+ if (s->use_named_pipes && s->attr_test == TRUE) {
np_rd_receive(s);
- np_send_error(s, false);
+ np_send_error(s, FALSE);
}
- return false;
+ return FALSE;
}
/*-------------------------------------------------------------------------
@@ -3021,28 +3013,28 @@ error:
* The number of iterations for group creation
*
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This is called by the main() function.
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
verify_group(state_t *s, unsigned int which)
{
char name[sizeof("/group-9999999999")];
hid_t g = H5I_INVALID_HID;
- bool result = true;
+ hbool_t result = TRUE;
H5G_info_t group_info;
/* The reader receives a message from the writer.Then sleep
* for a few ticks or stop the test if the received message
* is an error message.
*/
- if (s->use_named_pipes && true == s->attr_test) {
+ if (s->use_named_pipes && TRUE == s->attr_test) {
- if (false == np_rd_receive(s)) {
+ if (FALSE == np_rd_receive(s)) {
H5_FAILED();
AT();
goto error2;
@@ -3087,7 +3079,7 @@ verify_group(state_t *s, unsigned int which)
/* If coming to an "object header continuation block" test,
* we need to check if this test behaves as expected. */
if (s->at_pattern == 'a' || s->at_pattern == 'R') {
- if (false == check_ohr_num_chunk(g, true)) {
+ if (FALSE == check_ohr_num_chunk(g, TRUE)) {
HDprintf("An object header continuation block should NOT be created. \n");
HDprintf("But it is created.\n");
HDprintf("Verification of an 'object header continuation block test' failed.\n");
@@ -3096,9 +3088,9 @@ verify_group(state_t *s, unsigned int which)
}
/* Reader sends an OK message back to the writer */
- if (s->use_named_pipes && s->attr_test == true) {
+ if (s->use_named_pipes && s->attr_test == TRUE) {
- if (np_rd_send(s) == false)
+ if (np_rd_send(s) == FALSE)
TEST_ERROR;
dbgf(1, "Reader: finish sending back the message: %d\n", s->np_notify);
}
@@ -3107,7 +3099,7 @@ verify_group(state_t *s, unsigned int which)
if (s->asteps != 0 && which % s->asteps == 0)
result = verify_group_attribute(s, g, which);
else
- result = true;
+ result = TRUE;
if (H5Gclose(g) < 0) {
HDprintf("H5Gclose failed\n");
@@ -3125,12 +3117,12 @@ error:
H5E_END_TRY;
/* The reader sends an error message to the writer to stop the test.*/
- if (s->use_named_pipes && s->attr_test == true)
- np_send_error(s, false);
+ if (s->use_named_pipes && s->attr_test == TRUE)
+ np_send_error(s, FALSE);
error2:
- return false;
+ return FALSE;
}
/*-------------------------------------------------------------------------
@@ -3146,9 +3138,9 @@ error2:
* The number of iterations for group creation
* This is used to generate the group name.
*
- * bool dense_to_compact
- * true if this function is used to test the transition from dense to
- * compact, false if the test is from compact to dense.
+ * hbool_t dense_to_compact
+ * TRUE if this function is used to test the transition from dense to
+ * compact, FALSE if the test is from compact to dense.
*
* Return: Success: the group ID
* Failure: -1
@@ -3158,7 +3150,7 @@ error2:
*/
static hid_t
-create_group_id(state_t *s, unsigned int which, bool dense_to_compact)
+create_group_id(state_t *s, unsigned int which, hbool_t dense_to_compact)
{
char name[sizeof("/group-9999999999")];
@@ -3217,9 +3209,9 @@ create_group_id(state_t *s, unsigned int which, bool dense_to_compact)
* the writer should send and receive messages after the group creation.
* Writer sends a message to reader: a group is successfully created.
* then wait for the reader to verify and send an acknowledgement message back.*/
- if (s->use_named_pipes && s->grp_op_test == true) {
+ if (s->use_named_pipes && s->grp_op_test == TRUE) {
dbgf(2, "Writer: ready to send the message: %d\n", s->np_notify + 1);
- if (np_wr_send_receive(s) == false) {
+ if (np_wr_send_receive(s) == FALSE) {
H5_FAILED();
AT();
/* Note: This is (mostly) because the verification failure message
@@ -3233,8 +3225,8 @@ create_group_id(state_t *s, unsigned int which, bool dense_to_compact)
error:
/* Writer needs to send an error message to the reader to stop the test*/
- if (s->use_named_pipes && s->grp_op_test == true)
- np_send_error(s, true);
+ if (s->use_named_pipes && s->grp_op_test == TRUE)
+ np_send_error(s, TRUE);
error2:
@@ -3259,14 +3251,14 @@ error2:
* hid_t g
* The ID of the group to be closed.
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This is used by the link storage transit functions.
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
close_group_id(state_t *s, hid_t g)
{
@@ -3279,25 +3271,25 @@ close_group_id(state_t *s, hid_t g)
* link storage test,
* Writer sends a message to reader: the group is successfully closed.
* then wait for the reader to verify and send an acknowledgement message back.*/
- if (s->use_named_pipes && s->grp_op_test == true) {
+ if (s->use_named_pipes && s->grp_op_test == TRUE) {
dbgf(2, "Writer: ready to send the message: %d\n", s->np_notify + 1);
- if (np_wr_send_receive(s) == false) {
+ if (np_wr_send_receive(s) == FALSE) {
H5_FAILED();
AT();
goto error2;
}
}
- return true;
+ return TRUE;
error:
/* Writer needs to send an error message to the reader to stop the test*/
- if (s->use_named_pipes && s->grp_op_test == true)
- np_send_error(s, true);
+ if (s->use_named_pipes && s->grp_op_test == TRUE)
+ np_send_error(s, TRUE);
error2:
- return false;
+ return FALSE;
}
/*-------------------------------------------------------------------------
@@ -3313,14 +3305,14 @@ error2:
* The number of iterations for group creation
* This is used to generate the group name.
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This is called by the main() function.
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
create_group(state_t *s, unsigned int which)
{
@@ -3366,21 +3358,21 @@ create_group(state_t *s, unsigned int which)
/* Writer sends a message to reader,
* then wait for the reader to verify and send an acknowledgement message back.*/
- if (s->use_named_pipes && s->grp_op_test == true) {
+ if (s->use_named_pipes && s->grp_op_test == TRUE) {
dbgf(2, "Writer: ready to send the message: %d\n", s->np_notify + 1);
- if (np_wr_send_receive(s) == false) {
+ if (np_wr_send_receive(s) == FALSE) {
H5_FAILED();
AT();
goto error2;
}
}
- return true;
+ return TRUE;
error:
/* Writer needs to send an error message to the reader to stop the test*/
- if (s->use_named_pipes && s->grp_op_test == true)
- np_send_error(s, true);
+ if (s->use_named_pipes && s->grp_op_test == TRUE)
+ np_send_error(s, TRUE);
error2:
@@ -3390,7 +3382,7 @@ error2:
}
H5E_END_TRY;
- return false;
+ return FALSE;
}
/*-------------------------------------------------------------------------
@@ -3418,14 +3410,14 @@ error2:
* The number of iterations for group creation
*
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This is used by delete_groups() and delete_links() functions.
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
delete_one_link(state_t *s, hid_t obj_id, const char *name, short link_storage, unsigned int which)
{
@@ -3471,25 +3463,25 @@ delete_one_link(state_t *s, hid_t obj_id, const char *name, short link_storage,
/* Writer sends a message to reader:
* then wait for the reader to verify and send an acknowledgement message back.*/
- if (s->use_named_pipes && s->grp_op_test == true) {
+ if (s->use_named_pipes && s->grp_op_test == TRUE) {
dbgf(2, "writer: ready to send the message: %d\n", s->np_notify + 1);
- if (np_wr_send_receive(s) == false) {
+ if (np_wr_send_receive(s) == FALSE) {
H5_FAILED();
AT();
goto error2;
}
}
- return true;
+ return TRUE;
error:
/* Writer needs to send an error message to the reader to stop the test*/
- if (s->use_named_pipes && s->grp_op_test == true)
- np_send_error(s, true);
+ if (s->use_named_pipes && s->grp_op_test == TRUE)
+ np_send_error(s, TRUE);
error2:
- return false;
+ return FALSE;
}
/*-------------------------------------------------------------------------
@@ -3507,20 +3499,20 @@ error2:
* This is used to generate the group name
*
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This is called by the group_operations() function.
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
delete_group(state_t *s, unsigned int which)
{
- char name[sizeof("/group-9999999999")];
- bool ret_value = create_group(s, which);
- if (ret_value == true) {
+ char name[sizeof("/group-9999999999")];
+ hbool_t ret_value = create_group(s, which);
+ if (ret_value == TRUE) {
esnprintf(name, sizeof(name), "/group-%u", which);
ret_value = delete_one_link(s, s->file, name, 0, which);
}
@@ -3550,14 +3542,14 @@ delete_group(state_t *s, unsigned int which)
* The number of iterations for group creation
*
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This is called by the move_group() function.
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
move_one_group(state_t *s, hid_t obj_id, const char *name, const char *newname, unsigned int which)
{
@@ -3573,25 +3565,25 @@ move_one_group(state_t *s, hid_t obj_id, const char *name, const char *newname,
/* Writer sends a message to reader:
* then wait for the reader to verify and send an acknowledgement message back.*/
- if (s->use_named_pipes && s->grp_op_test == true) {
+ if (s->use_named_pipes && s->grp_op_test == TRUE) {
dbgf(2, "writer: ready to send the message: %d\n", s->np_notify + 1);
- if (np_wr_send_receive(s) == false) {
+ if (np_wr_send_receive(s) == FALSE) {
H5_FAILED();
AT();
goto error2;
}
}
- return true;
+ return TRUE;
error:
/* Writer needs to send an error message to the reader to stop the test*/
- if (s->use_named_pipes && s->grp_op_test == true)
- np_send_error(s, true);
+ if (s->use_named_pipes && s->grp_op_test == TRUE)
+ np_send_error(s, TRUE);
error2:
- return false;
+ return FALSE;
}
/*-------------------------------------------------------------------------
@@ -3607,21 +3599,21 @@ error2:
* The number of iterations for group creation
* used to generate the group name.
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This is called by the group_operations() function.
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
move_group(state_t *s, unsigned int which)
{
- char name[sizeof("/group-9999999999")];
- char new_name[sizeof("/new-group-9999999999")];
- bool ret_value = create_group(s, which);
- if (ret_value == true) {
+ char name[sizeof("/group-9999999999")];
+ char new_name[sizeof("/new-group-9999999999")];
+ hbool_t ret_value = create_group(s, which);
+ if (ret_value == TRUE) {
esnprintf(name, sizeof(name), "/group-%u", which);
esnprintf(new_name, sizeof(new_name), "/new-group-%u", which);
ret_value = move_one_group(s, s->file, name, new_name, which);
@@ -3648,9 +3640,9 @@ move_group(state_t *s, unsigned int which)
* const char *newname
* The name of the linked objects
*
- * bool is_hard
- * true if inserting a hard link
- * false if inserting a soft link
+ * hbool_t is_hard
+ * TRUE if inserting a hard link
+ * FALSE if inserting a soft link
*
* short link_storage
* <=0: link storage is ignored.
@@ -3660,16 +3652,16 @@ move_group(state_t *s, unsigned int which)
* unsigned int which
* The number of iterations for group creation
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This is called by the insert_links and link storage transit functions.
* For link storage, we test at both the writer and the reader.
*-------------------------------------------------------------------------
*/
-static bool
-insert_one_link(state_t *s, hid_t obj_id, const char *name, const char *newname, bool is_hard,
+static hbool_t
+insert_one_link(state_t *s, hid_t obj_id, const char *name, const char *newname, hbool_t is_hard,
short link_storage, unsigned int which)
{
@@ -3740,25 +3732,25 @@ insert_one_link(state_t *s, hid_t obj_id, const char *name, const char *newname,
/* Writer sends a message to reader,
* then wait for the reader to verify and send an acknowledgement message back.*/
- if (s->use_named_pipes && s->grp_op_test == true) {
+ if (s->use_named_pipes && s->grp_op_test == TRUE) {
dbgf(2, "writer: ready to send the message: %d\n", s->np_notify + 1);
- if (np_wr_send_receive(s) == false) {
+ if (np_wr_send_receive(s) == FALSE) {
H5_FAILED();
AT();
goto error2;
}
}
- return true;
+ return TRUE;
error:
/* Writer needs to send an error message to the reader to stop the test*/
- if (s->use_named_pipes && s->grp_op_test == true)
- np_send_error(s, true);
+ if (s->use_named_pipes && s->grp_op_test == TRUE)
+ np_send_error(s, TRUE);
error2:
- return false;
+ return FALSE;
}
/*-------------------------------------------------------------------------
@@ -3774,14 +3766,14 @@ error2:
* The number of iterations
* used to generate the group name.
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This is called by the group_operations() function.
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
insert_links(state_t *s, unsigned int which)
{
@@ -3789,14 +3781,14 @@ insert_links(state_t *s, unsigned int which)
char hd_name[sizeof("/hd-group-9999999999")];
char st_name[sizeof("/st-group-9999999999")];
- bool ret_value = create_group(s, which);
- if (ret_value == true) {
+ hbool_t ret_value = create_group(s, which);
+ if (ret_value == TRUE) {
esnprintf(name, sizeof(name), "/group-%u", which);
esnprintf(hd_name, sizeof(hd_name), "/hd-group-%u", which);
esnprintf(st_name, sizeof(st_name), "/st-group-%u", which);
- ret_value = insert_one_link(s, s->file, name, hd_name, true, 0, which);
- if (ret_value == true)
- ret_value = insert_one_link(s, s->file, name, st_name, false, 0, which);
+ ret_value = insert_one_link(s, s->file, name, hd_name, TRUE, 0, which);
+ if (ret_value == TRUE)
+ ret_value = insert_one_link(s, s->file, name, st_name, FALSE, 0, which);
}
return ret_value;
@@ -3815,14 +3807,14 @@ insert_links(state_t *s, unsigned int which)
* The number of iterations
* used to generate the group name.
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This is called by the group_operations() function.
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
delete_links(state_t *s, unsigned int which)
{
@@ -3830,13 +3822,13 @@ delete_links(state_t *s, unsigned int which)
char hd_name[sizeof("/hd-group-9999999999")];
char st_name[sizeof("/st-group-9999999999")];
- bool ret_value = insert_links(s, which);
- if (ret_value == true) {
+ hbool_t ret_value = insert_links(s, which);
+ if (ret_value == TRUE) {
esnprintf(name, sizeof(name), "/group-%u", which);
esnprintf(hd_name, sizeof(hd_name), "/hd-group-%u", which);
esnprintf(st_name, sizeof(st_name), "/st-group-%u", which);
ret_value = delete_one_link(s, s->file, hd_name, 0, which);
- if (ret_value == true)
+ if (ret_value == TRUE)
ret_value = delete_one_link(s, s->file, st_name, 0, which);
}
@@ -3856,14 +3848,14 @@ delete_links(state_t *s, unsigned int which)
* unsigned int which
* The number of iterations used to generate the group name.
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This is called by the group_operations() function.
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
transit_storage_compact_to_dense(state_t *s, unsigned int which)
{
@@ -3871,7 +3863,7 @@ transit_storage_compact_to_dense(state_t *s, unsigned int which)
char hd_name[sizeof("/hd-group-9999999999")];
char st_name[sizeof("/st-group-9999999999")];
- hid_t g = create_group_id(s, which, false);
+ hid_t g = create_group_id(s, which, FALSE);
if (g < 0) {
HDprintf("create_group_id failed\n");
TEST_ERROR;
@@ -3880,24 +3872,24 @@ transit_storage_compact_to_dense(state_t *s, unsigned int which)
/* First insert a hard link, compact storage. */
esnprintf(name, sizeof(name), "/group-%u", which);
esnprintf(hd_name, sizeof(hd_name), "hd-group-%u", which);
- if (insert_one_link(s, g, name, hd_name, true, 1, which) == false) {
+ if (insert_one_link(s, g, name, hd_name, TRUE, 1, which) == FALSE) {
HDprintf("insert_one_link for compact storage failed\n");
TEST_ERROR;
}
/* Then insert a soft link, the storage becomes dense. */
esnprintf(st_name, sizeof(st_name), "st-group-%u", which);
- if (insert_one_link(s, g, name, st_name, false, 2, which) == false) {
+ if (insert_one_link(s, g, name, st_name, FALSE, 2, which) == FALSE) {
HDprintf("insert_one_link for dense storage failed\n");
TEST_ERROR;
}
- if (close_group_id(s, g) == false) {
+ if (close_group_id(s, g) == FALSE) {
HDprintf("insert_one_link for dense storage failed\n");
TEST_ERROR;
}
- return true;
+ return TRUE;
error:
H5E_BEGIN_TRY
@@ -3906,7 +3898,7 @@ error:
}
H5E_END_TRY;
- return false;
+ return FALSE;
}
/*-------------------------------------------------------------------------
@@ -3922,14 +3914,14 @@ error:
* unsigned int which
* The number of iterations used to generate the group name.
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This is called by the group_operations() function.
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
transit_storage_dense_to_compact(state_t *s, unsigned int which)
{
@@ -3938,7 +3930,7 @@ transit_storage_dense_to_compact(state_t *s, unsigned int which)
char st_name[sizeof("st-group-9999999999")];
char st2_name[sizeof("st2-group-9999999999")];
- hid_t g = create_group_id(s, which, true);
+ hid_t g = create_group_id(s, which, TRUE);
if (g < 0) {
HDprintf("create_group_id failed\n");
TEST_ERROR;
@@ -3947,43 +3939,43 @@ transit_storage_dense_to_compact(state_t *s, unsigned int which)
/* Insert a link, storage is compact. */
esnprintf(name, sizeof(name), "/group-%u", which);
esnprintf(hd_name, sizeof(hd_name), "hd-group-%u", which);
- if (insert_one_link(s, g, name, hd_name, true, 1, which) == false) {
+ if (insert_one_link(s, g, name, hd_name, TRUE, 1, which) == FALSE) {
HDprintf("insert_one_link for compact storage failed\n");
TEST_ERROR;
}
/* Insert a link, storage is still compact. */
esnprintf(st_name, sizeof(st_name), "st-group-%u", which);
- if (insert_one_link(s, g, name, st_name, false, 1, which) == false) {
+ if (insert_one_link(s, g, name, st_name, FALSE, 1, which) == FALSE) {
HDprintf("insert_one_link for compact storage failed\n");
TEST_ERROR;
}
/* Insert a link, storage becomes dense. */
esnprintf(st2_name, sizeof(st2_name), "st2-group-%u", which);
- if (insert_one_link(s, g, name, st2_name, false, 2, which) == false) {
+ if (insert_one_link(s, g, name, st2_name, FALSE, 2, which) == FALSE) {
HDprintf("insert_one_link for dense storage failed\n");
TEST_ERROR;
}
/* Delete a link, storage is still dense */
- if (delete_one_link(s, g, st_name, 2, which) == false) {
+ if (delete_one_link(s, g, st_name, 2, which) == FALSE) {
HDprintf("delete_one_link for dense storage failed\n");
TEST_ERROR;
}
/* Delete another link, storage becomes compact */
- if (delete_one_link(s, g, st2_name, 1, which) == false) {
+ if (delete_one_link(s, g, st2_name, 1, which) == FALSE) {
HDprintf("delete_one_link for compact storage failed\n");
TEST_ERROR;
}
- if (close_group_id(s, g) == false) {
+ if (close_group_id(s, g) == FALSE) {
HDprintf("insert_one_link for dense storage failed\n");
TEST_ERROR;
}
- return true;
+ return TRUE;
error:
H5E_BEGIN_TRY
@@ -3992,7 +3984,7 @@ error:
}
H5E_END_TRY;
- return false;
+ return FALSE;
}
/*-------------------------------------------------------------------------
@@ -4009,19 +4001,19 @@ error:
* The number of iterations for group creation
*
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This is called by the main() function. The check of attribute
* operations is inside the write_group() function.
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
group_operations(state_t *s, unsigned int which)
{
- bool ret_value = false;
- char test_pattern = s->grp_op_pattern;
+ hbool_t ret_value = FALSE;
+ char test_pattern = s->grp_op_pattern;
switch (test_pattern) {
case 'c':
@@ -4066,14 +4058,14 @@ group_operations(state_t *s, unsigned int which)
* The number of iterations for group creation
* used to generate the group name.
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This is called by the verify_group_operations() function.
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
vrfy_create_group(state_t *s, unsigned int which)
{
@@ -4087,9 +4079,9 @@ vrfy_create_group(state_t *s, unsigned int which)
* for a few ticks or stop the test if the received message
* is an error message.
*/
- if (s->use_named_pipes && true == s->grp_op_test) {
+ if (s->use_named_pipes && TRUE == s->grp_op_test) {
- if (false == np_rd_receive(s)) {
+ if (FALSE == np_rd_receive(s)) {
H5_FAILED();
AT();
goto error2;
@@ -4137,14 +4129,14 @@ vrfy_create_group(state_t *s, unsigned int which)
}
/* Reader sends an OK message back to the writer */
- if (s->use_named_pipes && s->grp_op_test == true) {
+ if (s->use_named_pipes && s->grp_op_test == TRUE) {
- if (np_rd_send(s) == false)
+ if (np_rd_send(s) == FALSE)
TEST_ERROR;
dbgf(1, "Reader: finish sending back the message: %d\n", s->np_notify);
}
- return true;
+ return TRUE;
error:
@@ -4155,12 +4147,12 @@ error:
H5E_END_TRY;
/* The reader sends an error message to the writer to stop the test.*/
- if (s->use_named_pipes && s->grp_op_test == true)
- np_send_error(s, false);
+ if (s->use_named_pipes && s->grp_op_test == TRUE)
+ np_send_error(s, FALSE);
error2:
- return false;
+ return FALSE;
}
/*-------------------------------------------------------------------------
@@ -4177,9 +4169,9 @@ error2:
* The number of iterations for group creation
* used to generate the group name.
*
- * bool dense_to_compact
- * true if this function is used to test the transition from dense to
- * compact, false if the test is from compact to dense.
+ * hbool_t dense_to_compact
+ * TRUE if this function is used to test the transition from dense to
+ * compact, FALSE if the test is from compact to dense.
*
* Return: Success: the group ID
* Failure: -1
@@ -4189,7 +4181,7 @@ error2:
*/
static hid_t
-vrfy_create_group_id(state_t *s, unsigned int which, bool dense_to_compact)
+vrfy_create_group_id(state_t *s, unsigned int which, hbool_t dense_to_compact)
{
char name[sizeof("/group-9999999999")];
@@ -4204,9 +4196,9 @@ vrfy_create_group_id(state_t *s, unsigned int which, bool dense_to_compact)
* for a few ticks or stop the test if the received message
* is an error message.
*/
- if (s->use_named_pipes && true == s->grp_op_test) {
+ if (s->use_named_pipes && TRUE == s->grp_op_test) {
- if (false == np_rd_receive(s)) {
+ if (FALSE == np_rd_receive(s)) {
H5_FAILED();
AT();
goto error2;
@@ -4285,9 +4277,9 @@ vrfy_create_group_id(state_t *s, unsigned int which, bool dense_to_compact)
dbgf(2, "Storage info is %d\n", group_info.storage_type);
/* Reader sends an OK message back to the reader */
- if (s->use_named_pipes && s->grp_op_test == true) {
+ if (s->use_named_pipes && s->grp_op_test == TRUE) {
- if (np_rd_send(s) == false)
+ if (np_rd_send(s) == FALSE)
TEST_ERROR;
dbgf(1, "Reader: finish sending back the message: %d\n", s->np_notify);
}
@@ -4304,8 +4296,8 @@ error:
H5E_END_TRY;
/* The reader sends an error message to the writer to stop the test.*/
- if (s->use_named_pipes && s->grp_op_test == true)
- np_send_error(s, false);
+ if (s->use_named_pipes && s->grp_op_test == TRUE)
+ np_send_error(s, FALSE);
error2:
@@ -4324,14 +4316,14 @@ error2:
* hid_t g
* The ID of the group to be closed.
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This is used by the link storage transit functions.
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
vrfy_close_group_id(state_t *s, hid_t g)
{
@@ -4339,9 +4331,9 @@ vrfy_close_group_id(state_t *s, hid_t g)
* for a few ticks or stop the test if the received message
* is an error message.
*/
- if (s->use_named_pipes && true == s->grp_op_test) {
+ if (s->use_named_pipes && TRUE == s->grp_op_test) {
- if (false == np_rd_receive(s)) {
+ if (FALSE == np_rd_receive(s)) {
H5_FAILED();
AT();
goto error2;
@@ -4356,23 +4348,23 @@ vrfy_close_group_id(state_t *s, hid_t g)
}
/* Reader sends an OK message back to the reader */
- if (s->use_named_pipes && s->grp_op_test == true) {
+ if (s->use_named_pipes && s->grp_op_test == TRUE) {
- if (np_rd_send(s) == false)
+ if (np_rd_send(s) == FALSE)
TEST_ERROR;
dbgf(1, "Reader: finish sending back the message: %d\n", s->np_notify);
}
- return true;
+ return TRUE;
error:
/* The reader sends an error message to the writer to stop the test.*/
- if (s->use_named_pipes && s->grp_op_test == true)
- np_send_error(s, false);
+ if (s->use_named_pipes && s->grp_op_test == TRUE)
+ np_send_error(s, FALSE);
error2:
- return false;
+ return FALSE;
}
/*-------------------------------------------------------------------------
@@ -4388,7 +4380,7 @@ error2:
* hid_t obj_id
* The ID of the object the link is attached to
*
- * bool expect_exist
+ * hbool_t expect_exist
* A flag that indicates if this link is expected to exist
*
* short link_storage
@@ -4396,16 +4388,16 @@ error2:
* 1: link storage is expected to be compact.
* >1: link storage is expected to be dense.
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: Helper function to check if links are inserted or deleted.
* The link storage is also checked.
*-------------------------------------------------------------------------
*/
-static bool
-vrfy_one_link_exist(state_t *s, hid_t obj_id, const char *name, bool expect_exist, short link_storage)
+static hbool_t
+vrfy_one_link_exist(state_t *s, hid_t obj_id, const char *name, hbool_t expect_exist, short link_storage)
{
int link_exists = 0;
@@ -4416,9 +4408,9 @@ vrfy_one_link_exist(state_t *s, hid_t obj_id, const char *name, bool expect_exis
* for a few ticks or stop the test if the received message
* is an error message.
*/
- if (s->use_named_pipes && true == s->grp_op_test) {
+ if (s->use_named_pipes && TRUE == s->grp_op_test) {
- if (false == np_rd_receive(s)) {
+ if (FALSE == np_rd_receive(s)) {
H5_FAILED();
AT();
goto error2;
@@ -4434,13 +4426,13 @@ vrfy_one_link_exist(state_t *s, hid_t obj_id, const char *name, bool expect_exis
TEST_ERROR;
}
else if (link_exists == 1) {
- if (expect_exist == false) {
+ if (expect_exist == FALSE) {
HDprintf("This link should be moved or deleted but it still exists.\n");
TEST_ERROR;
}
}
else if (link_exists == 0) {
- if (expect_exist == true) {
+ if (expect_exist == TRUE) {
HDprintf("This link should exist but it is moved or deleted.\n");
TEST_ERROR;
}
@@ -4473,24 +4465,24 @@ vrfy_one_link_exist(state_t *s, hid_t obj_id, const char *name, bool expect_exis
}
/* Reader sends an OK message back to the reader */
- if (s->use_named_pipes && s->grp_op_test == true) {
- if (np_rd_send(s) == false) {
+ if (s->use_named_pipes && s->grp_op_test == TRUE) {
+ if (np_rd_send(s) == FALSE) {
TEST_ERROR;
}
dbgf(1, "Reader: finish sending back the message: %d\n", s->np_notify);
}
- return true;
+ return TRUE;
error:
/* The reader sends an error message to the writer to stop the test.*/
- if (s->use_named_pipes && s->grp_op_test == true)
- np_send_error(s, false);
+ if (s->use_named_pipes && s->grp_op_test == TRUE)
+ np_send_error(s, FALSE);
error2:
- return false;
+ return FALSE;
}
/*-------------------------------------------------------------------------
@@ -4506,24 +4498,24 @@ error2:
* The number of iterations for group creation
* used to generate the group name.
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This is called by the verify_group_operations() function.
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
vrfy_delete_group(state_t *s, unsigned int which)
{
- bool ret_value = false;
- char name[sizeof("/group-9999999999")];
+ hbool_t ret_value = FALSE;
+ char name[sizeof("/group-9999999999")];
ret_value = vrfy_create_group(s, which);
- if (ret_value == true) {
+ if (ret_value == TRUE) {
esnprintf(name, sizeof(name), "/group-%u", which);
- ret_value = vrfy_one_link_exist(s, s->file, name, false, 0);
+ ret_value = vrfy_one_link_exist(s, s->file, name, FALSE, 0);
}
return ret_value;
@@ -4550,14 +4542,14 @@ vrfy_delete_group(state_t *s, unsigned int which)
* unsigned int which
* The number of iterations for group creation
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This is called by the verify_move_group() function.
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
vrfy_move_one_group(state_t *s, hid_t obj_id, const char *name, const char *newname, unsigned int which)
{
@@ -4570,9 +4562,9 @@ vrfy_move_one_group(state_t *s, hid_t obj_id, const char *name, const char *newn
* for a few ticks or stop the test if the received message
* is an error message.
*/
- if (s->use_named_pipes && true == s->grp_op_test) {
+ if (s->use_named_pipes && TRUE == s->grp_op_test) {
- if (false == np_rd_receive(s)) {
+ if (FALSE == np_rd_receive(s)) {
H5_FAILED();
AT();
goto error2;
@@ -4628,15 +4620,15 @@ vrfy_move_one_group(state_t *s, hid_t obj_id, const char *name, const char *newn
}
/* Reader sends an OK message back to the reader */
- if (s->use_named_pipes && s->grp_op_test == true) {
+ if (s->use_named_pipes && s->grp_op_test == TRUE) {
- if (np_rd_send(s) == false) {
+ if (np_rd_send(s) == FALSE) {
TEST_ERROR;
}
dbgf(1, "Reader: finish sending back the message: %d\n", s->np_notify);
}
- return true;
+ return TRUE;
error:
@@ -4647,12 +4639,12 @@ error:
H5E_END_TRY;
/* The reader sends an error message to the writer to stop the test.*/
- if (s->use_named_pipes && s->grp_op_test == true)
- np_send_error(s, false);
+ if (s->use_named_pipes && s->grp_op_test == TRUE)
+ np_send_error(s, FALSE);
error2:
- return false;
+ return FALSE;
}
/*-------------------------------------------------------------------------
@@ -4668,21 +4660,21 @@ error2:
* The number of iterations for group creation
* used to generate the group name.
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This is called by the verify_group_operations() function.
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
vrfy_move_group(state_t *s, unsigned int which)
{
- char name[sizeof("/group-9999999999")];
- char new_name[sizeof("/new-group-9999999999")];
- bool ret_value = vrfy_create_group(s, which);
- if (ret_value == true) {
+ char name[sizeof("/group-9999999999")];
+ char new_name[sizeof("/new-group-9999999999")];
+ hbool_t ret_value = vrfy_create_group(s, which);
+ if (ret_value == TRUE) {
esnprintf(name, sizeof(name), "/group-%u", which);
esnprintf(new_name, sizeof(new_name), "/new-group-%u", which);
ret_value = vrfy_move_one_group(s, s->file, name, new_name, which);
@@ -4704,29 +4696,29 @@ vrfy_move_group(state_t *s, unsigned int which)
* The number of iterations for group creation
* used to generate the group name.
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This is called by the verify_group_operations() function.
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
vrfy_insert_links(state_t *s, unsigned int which)
{
- bool ret_value = false;
- char hd_name[sizeof("/hd-group-9999999999")];
- char st_name[sizeof("/st-group-9999999999")];
+ hbool_t ret_value = FALSE;
+ char hd_name[sizeof("/hd-group-9999999999")];
+ char st_name[sizeof("/st-group-9999999999")];
ret_value = vrfy_create_group(s, which);
- if (ret_value == true) {
+ if (ret_value == TRUE) {
esnprintf(hd_name, sizeof(hd_name), "/hd-group-%u", which);
esnprintf(st_name, sizeof(st_name), "/st-group-%u", which);
- ret_value = vrfy_one_link_exist(s, s->file, hd_name, true, 0);
- if (ret_value == true)
- ret_value = vrfy_one_link_exist(s, s->file, st_name, true, 0);
+ ret_value = vrfy_one_link_exist(s, s->file, hd_name, TRUE, 0);
+ if (ret_value == TRUE)
+ ret_value = vrfy_one_link_exist(s, s->file, st_name, TRUE, 0);
}
return ret_value;
@@ -4745,31 +4737,31 @@ vrfy_insert_links(state_t *s, unsigned int which)
* The number of iterations for group creation
* used to generate the group name.
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This is called by the verify_group_operations() function.
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
vrfy_delete_links(state_t *s, unsigned int which)
{
- bool ret_value = false;
- char hd_name[sizeof("/hd-group-9999999999")];
- char st_name[sizeof("/st-group-9999999999")];
+ hbool_t ret_value = FALSE;
+ char hd_name[sizeof("/hd-group-9999999999")];
+ char st_name[sizeof("/st-group-9999999999")];
/* First verify if the links are inserted correctly */
ret_value = vrfy_insert_links(s, which);
/* Then if these links are deleted correctly. */
- if (ret_value == true) {
+ if (ret_value == TRUE) {
esnprintf(hd_name, sizeof(hd_name), "/hd-group-%u", which);
esnprintf(st_name, sizeof(st_name), "/st-group-%u", which);
- ret_value = vrfy_one_link_exist(s, s->file, hd_name, false, 0);
- if (ret_value == true)
- ret_value = vrfy_one_link_exist(s, s->file, st_name, false, 0);
+ ret_value = vrfy_one_link_exist(s, s->file, hd_name, FALSE, 0);
+ if (ret_value == TRUE)
+ ret_value = vrfy_one_link_exist(s, s->file, st_name, FALSE, 0);
}
return ret_value;
@@ -4789,14 +4781,14 @@ vrfy_delete_links(state_t *s, unsigned int which)
* The number of iterations for group creation
* used to generate the group name.
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This is called by the verify_group_operations() function.
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
vrfy_transit_storage_compact_to_dense(state_t *s, unsigned int which)
{
@@ -4804,29 +4796,29 @@ vrfy_transit_storage_compact_to_dense(state_t *s, unsigned int which)
char hd_name[sizeof("hd-group-9999999999")];
char st_name[sizeof("st-group-9999999999")];
- g = vrfy_create_group_id(s, which, false);
+ g = vrfy_create_group_id(s, which, FALSE);
if (g < 0) {
HDprintf("verify create_group_id failed\n");
TEST_ERROR;
}
esnprintf(hd_name, sizeof(hd_name), "hd-group-%u", which);
- if (vrfy_one_link_exist(s, g, hd_name, true, 1) == false) {
+ if (vrfy_one_link_exist(s, g, hd_name, TRUE, 1) == FALSE) {
HDprintf("verify the compact storage failed for 'link compact to dense' test\n");
TEST_ERROR;
}
esnprintf(st_name, sizeof(st_name), "st-group-%u", which);
- if (vrfy_one_link_exist(s, g, st_name, true, 2) == false) {
+ if (vrfy_one_link_exist(s, g, st_name, TRUE, 2) == FALSE) {
HDprintf("verify the dense link storage failed for 'link compact to dense' test\n");
TEST_ERROR;
}
- if (vrfy_close_group_id(s, g) == false) {
+ if (vrfy_close_group_id(s, g) == FALSE) {
HDprintf("verify the group close for 'link compact to dense' test\n");
TEST_ERROR;
}
- return true;
+ return TRUE;
error:
H5E_BEGIN_TRY
@@ -4834,7 +4826,7 @@ error:
H5Gclose(g);
}
H5E_END_TRY;
- return false;
+ return FALSE;
}
/*-------------------------------------------------------------------------
@@ -4851,14 +4843,14 @@ error:
* The number of iterations for group creation
* used to generate the group name.
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This is called by the verify_group_operations() function.
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
vrfy_transit_storage_dense_to_compact(state_t *s, unsigned int which)
{
@@ -4867,7 +4859,7 @@ vrfy_transit_storage_dense_to_compact(state_t *s, unsigned int which)
char st_name[sizeof("st-group-9999999999")];
char st2_name[sizeof("st2-group-9999999999")];
- g = vrfy_create_group_id(s, which, true);
+ g = vrfy_create_group_id(s, which, TRUE);
if (g < 0) {
HDprintf("verify create_group_id failed\n");
TEST_ERROR;
@@ -4875,42 +4867,42 @@ vrfy_transit_storage_dense_to_compact(state_t *s, unsigned int which)
/* Add a link, verify it is still the compact storage */
esnprintf(hd_name, sizeof(hd_name), "hd-group-%u", which);
- if (vrfy_one_link_exist(s, g, hd_name, true, 1) == false) {
+ if (vrfy_one_link_exist(s, g, hd_name, TRUE, 1) == FALSE) {
HDprintf("verify the compact storage failed for 'link compact to dense' test\n");
TEST_ERROR;
}
/* Add another link, verify it is still the compact storage */
esnprintf(st_name, sizeof(st_name), "st-group-%u", which);
- if (vrfy_one_link_exist(s, g, st_name, true, 1) == false) {
+ if (vrfy_one_link_exist(s, g, st_name, TRUE, 1) == FALSE) {
HDprintf("verify the compact link storage failed for 'link compact to dense' test\n");
TEST_ERROR;
}
/* Add the third link, verify it becomes the dense storage */
esnprintf(st2_name, sizeof(st2_name), "st2-group-%u", which);
- if (vrfy_one_link_exist(s, g, st2_name, true, 2) == false) {
+ if (vrfy_one_link_exist(s, g, st2_name, TRUE, 2) == FALSE) {
HDprintf("verify the dense link storage failed for 'link compact to dense' test\n");
TEST_ERROR;
}
/* Remove a link, verify the link doesn't exist and still dense storage */
- if (vrfy_one_link_exist(s, g, st_name, false, 2) == false) {
+ if (vrfy_one_link_exist(s, g, st_name, FALSE, 2) == FALSE) {
HDprintf("verify the dense link storage failed for 'link compact to dense' test\n");
TEST_ERROR;
}
/* Remove a link, verify the link doesn't exist and it becomes compact storage */
- if (vrfy_one_link_exist(s, g, st2_name, false, 1) == false) {
+ if (vrfy_one_link_exist(s, g, st2_name, FALSE, 1) == FALSE) {
HDprintf("verify the compact link storage failed for 'link compact to dense' test\n");
TEST_ERROR;
}
- if (vrfy_close_group_id(s, g) == false) {
+ if (vrfy_close_group_id(s, g) == FALSE) {
HDprintf("verify the group close for 'link compact to dense' test\n");
TEST_ERROR;
}
- return true;
+ return TRUE;
error:
H5E_BEGIN_TRY
@@ -4918,7 +4910,7 @@ error:
H5Gclose(g);
}
H5E_END_TRY;
- return false;
+ return FALSE;
}
/*-------------------------------------------------------------------------
@@ -4936,18 +4928,18 @@ error:
* The number of iterations for group creation
*
*
- * Return: Success: true
- * Failure: false
+ * Return: Success: TRUE
+ * Failure: FALSE
*
* Note: This is called by the main() function.
*-------------------------------------------------------------------------
*/
-static bool
+static hbool_t
verify_group_operations(state_t *s, unsigned int which)
{
- bool ret_value = false;
- char test_pattern = s->grp_op_pattern;
+ hbool_t ret_value = FALSE;
+ char test_pattern = s->grp_op_pattern;
switch (test_pattern) {
case 'c':
@@ -4984,7 +4976,7 @@ main(int argc, char **argv)
{
hid_t fapl = H5I_INVALID_HID, fcpl = H5I_INVALID_HID;
unsigned step;
- bool writer = false;
+ hbool_t writer = FALSE;
state_t s;
const char * personality;
H5F_vfd_swmr_config_t config;
@@ -4992,8 +4984,8 @@ main(int argc, char **argv)
const char * fifo_reader_to_writer = "./fifo_group_reader_to_writer";
int fd_writer_to_reader = -1, fd_reader_to_writer = -1;
int notify = 0, verify = 0;
- bool wg_ret = false;
- bool vg_ret = false;
+ hbool_t wg_ret = FALSE;
+ hbool_t vg_ret = FALSE;
if (!state_init(&s, argc, argv)) {
HDprintf("state_init failed\n");
@@ -5003,9 +4995,9 @@ main(int argc, char **argv)
personality = HDstrstr(s.progname, "vfd_swmr_group_");
if (personality != NULL && HDstrcmp(personality, "vfd_swmr_group_writer") == 0)
- writer = true;
+ writer = TRUE;
else if (personality != NULL && HDstrcmp(personality, "vfd_swmr_group_reader") == 0)
- writer = false;
+ writer = FALSE;
else {
HDprintf("unknown personality, expected vfd_swmr_group_{reader,writer}\n");
TEST_ERROR;
@@ -5021,7 +5013,7 @@ main(int argc, char **argv)
* vfd_swmr_create_fapl. Otherwise, the latest file format(H5F_LIBVER_LATEST)
* should be used as the second parameter of H5Pset_libver_bound().
* Also pass the use_vfd_swmr, only_meta_page, page_buf_size, config to vfd_swmr_create_fapl().*/
- if ((fapl = vfd_swmr_create_fapl(!s.old_style_grp, s.use_vfd_swmr, true, s.pbs, &config)) < 0) {
+ if ((fapl = vfd_swmr_create_fapl(!s.old_style_grp, s.use_vfd_swmr, TRUE, s.pbs, &config)) < 0) {
HDprintf("vfd_swmr_create_fapl failed\n");
TEST_ERROR;
}
@@ -5096,21 +5088,21 @@ main(int argc, char **argv)
wg_ret = group_operations(&s, step);
- if (wg_ret == false) {
+ if (wg_ret == FALSE) {
/* At communication interval, notifies the reader about the failure and quit */
- if (s.use_named_pipes && s.attr_test != true && s.grp_op_test != true && step % s.csteps == 0)
- np_send_error(&s, true);
+ if (s.use_named_pipes && s.attr_test != TRUE && s.grp_op_test != TRUE && step % s.csteps == 0)
+ np_send_error(&s, TRUE);
HDprintf("write_group failed at step %d\n", step);
TEST_ERROR;
}
else {
/* At communication interval, notifies the reader and waits for its response */
- if (s.use_named_pipes && s.attr_test != true && s.grp_op_test != true &&
+ if (s.use_named_pipes && s.attr_test != TRUE && s.grp_op_test != TRUE &&
step % s.csteps == 0) {
- if (np_wr_send_receive(&s) == false) {
+ if (np_wr_send_receive(&s) == FALSE) {
HDprintf("writer: write group - verification failed.\n");
TEST_ERROR;
}
@@ -5124,34 +5116,34 @@ main(int argc, char **argv)
/* At communication interval, waits for the writer to finish creation before starting verification
*/
- if (s.use_named_pipes && s.attr_test != true && s.grp_op_test != true && step % s.csteps == 0) {
- if (false == np_rd_receive(&s)) {
+ if (s.use_named_pipes && s.attr_test != TRUE && s.grp_op_test != TRUE && step % s.csteps == 0) {
+ if (FALSE == np_rd_receive(&s)) {
TEST_ERROR;
}
}
/* For the default test, wait for a few ticks for the update to happen */
- if (s.use_named_pipes && s.attr_test == false)
+ if (s.use_named_pipes && s.attr_test == FALSE)
decisleep(config.tick_len * s.update_interval);
vg_ret = verify_group_operations(&s, step);
- if (vg_ret == false) {
+ if (vg_ret == FALSE) {
HDprintf("verify_group_operations failed\n");
/* At communication interval, tell the writer about the failure and exit */
- if (s.use_named_pipes && s.attr_test != true && s.grp_op_test != true && step % s.csteps == 0)
- np_send_error(&s, false);
+ if (s.use_named_pipes && s.attr_test != TRUE && s.grp_op_test != TRUE && step % s.csteps == 0)
+ np_send_error(&s, FALSE);
TEST_ERROR;
}
else {
/* Send back the same notify value for acknowledgement to tell the writer
* move to the next step. */
- if (s.use_named_pipes && s.attr_test != true && s.grp_op_test != true &&
+ if (s.use_named_pipes && s.attr_test != TRUE && s.grp_op_test != TRUE &&
step % s.csteps == 0) {
- if (np_rd_send(&s) == false) {
+ if (np_rd_send(&s) == FALSE) {
TEST_ERROR;
}
}
@@ -5236,6 +5228,6 @@ main(void)
{
HDfprintf(stderr, "Non-POSIX platform. Skipping.\n");
return EXIT_SUCCESS;
-} /* end main() */
+}
#endif /* H5_HAVE_WIN32_API */
diff --git a/test/vfd_swmr_indep_rw_writer.c b/test/vfd_swmr_indep_rw_writer.c
index 9d004bc..fae4d82 100644
--- a/test/vfd_swmr_indep_rw_writer.c
+++ b/test/vfd_swmr_indep_rw_writer.c
@@ -66,8 +66,8 @@ typedef struct {
uint32_t ps;
uint32_t pbs;
uint32_t check_interval;
- bool use_vfd_swmr;
- bool first_proc;
+ hbool_t use_vfd_swmr;
+ hbool_t first_proc;
} state_t;
/* Assign the initialized values to struct state_t declared above */
@@ -89,8 +89,8 @@ state_initializer(void)
.ps = 4096,
.pbs = 4096,
.check_interval = 1,
- .use_vfd_swmr = true,
- .first_proc = true};
+ .use_vfd_swmr = TRUE,
+ .first_proc = TRUE};
}
/* Obtain the data value at index [i][j] for the 2D matrix.
@@ -102,7 +102,7 @@ matget(const mat_t *mat, unsigned i, unsigned j)
}
/* Set the data value at index [i][j] for the 2D matrix. */
-static bool
+static hbool_t
matset(mat_t *mat, unsigned i, unsigned j, uint32_t v)
{
if (i >= mat->rows || j >= mat->cols) {
@@ -112,10 +112,10 @@ matset(mat_t *mat, unsigned i, unsigned j, uint32_t v)
mat->elt[i * mat->cols + j] = v;
- return true;
+ return TRUE;
error:
- return false;
+ return FALSE;
}
/* Allocate memory for the 2-D matrix. */
@@ -140,7 +140,7 @@ error:
}
/* Write or verify the dataset test pattern in the matrix `mat`.
- * If `do_set` is true, write the pattern; otherwise, verify.
+ * If `do_set` is TRUE, write the pattern; otherwise, verify.
*
* The basic test pattern consists of increasing
* integers written in nested corners of the dataset
@@ -163,11 +163,11 @@ error:
* In an actual pattern, the dataset number, `which`, is added to each integer.
*
*/
-static bool
-set_or_verify_matrix(mat_t *mat, unsigned int which, bool do_set)
+static hbool_t
+set_or_verify_matrix(mat_t *mat, unsigned int which, hbool_t do_set)
{
unsigned row, col;
- bool ret = true;
+ hbool_t ret = TRUE;
for (row = 0; row < mat->rows; row++) {
for (col = 0; col < mat->cols; col++) {
@@ -183,17 +183,17 @@ set_or_verify_matrix(mat_t *mat, unsigned int which, bool do_set)
if (do_set) {
if (!matset(mat, row, col, v)) {
HDfprintf(stderr, "data initialization failed\n");
- ret = false;
+ ret = FALSE;
break;
}
}
else if (matget(mat, row, col) != v) {
- /* If the data doesn't match, return false
+ /* If the data doesn't match, return FALSE
*/
dbgf(1, "vrfy_matrix failed at row %u,col %u\n", row, col);
dbgf(1, "real value is %u\n", matget(mat, row, col));
dbgf(1, "expected value is %u\n", v);
- ret = false;
+ ret = FALSE;
break;
}
}
@@ -203,17 +203,17 @@ set_or_verify_matrix(mat_t *mat, unsigned int which, bool do_set)
}
/* Initialize the matrix values. The parameter 'which' determines the data value. */
-static bool
+static hbool_t
init_matrix(mat_t *mat, unsigned int which)
{
- return set_or_verify_matrix(mat, which, true);
+ return set_or_verify_matrix(mat, which, TRUE);
}
/* Verify the matrix values at each point. The parameter 'which" determines the data value. */
-static bool
+static hbool_t
verify_matrix(mat_t *mat, unsigned int which)
{
- return set_or_verify_matrix(mat, which, false);
+ return set_or_verify_matrix(mat, which, FALSE);
}
/* Usage of this program when running with the -h option */
@@ -243,14 +243,16 @@ usage(const char *progname)
}
/* Initialize the state_t with different options specified by the user. */
-static bool
+static hbool_t
state_init(state_t *s, int argc, char **argv)
{
- unsigned long tmp;
- int ch;
- char * tfile = NULL;
- char * end;
- const char * personality;
+ unsigned long tmp;
+ int opt;
+ char * tfile = NULL;
+ char * end;
+ const char * personality;
+ const char * s_opts = "Sqc:r:t:m:B:s:u:";
+ struct h5_long_options l_opts[] = {{NULL, 0, '\0'}};
*s = state_initializer();
@@ -266,10 +268,10 @@ state_init(state_t *s, int argc, char **argv)
tfile = NULL;
}
- while ((ch = getopt(argc, argv, "Sqc:r:t:m:B:s:u:")) != -1) {
- switch (ch) {
+ while ((opt = H5_get_option(argc, (const char *const *)argv, s_opts, l_opts)) != EOF) {
+ switch (opt) {
case 'S':
- s->use_vfd_swmr = false;
+ s->use_vfd_swmr = FALSE;
break;
case 'c':
case 'r':
@@ -279,37 +281,37 @@ state_init(state_t *s, int argc, char **argv)
case 's':
case 'u':
errno = 0;
- tmp = HDstrtoul(optarg, &end, 0);
- if (end == optarg || *end != '\0') {
- HDfprintf(stderr, "couldn't parse -%c argument %s\n", ch, optarg);
+ tmp = HDstrtoul(H5_optarg, &end, 0);
+ if (end == H5_optarg || *end != '\0') {
+ HDfprintf(stderr, "couldn't parse -%c argument %s\n", opt, H5_optarg);
TEST_ERROR;
}
else if (errno != 0) {
- HDfprintf(stderr, "couldn't parse -%c argument %s\n", ch, optarg);
+ HDfprintf(stderr, "couldn't parse -%c argument %s\n", opt, H5_optarg);
TEST_ERROR;
}
else if (tmp > UINT_MAX) {
- HDfprintf(stderr, "-%c argument %lu too large", ch, tmp);
+ HDfprintf(stderr, "-%c argument %lu too large", opt, tmp);
TEST_ERROR;
}
- if ((ch == 'c' || ch == 'r') && tmp == 0) {
- HDfprintf(stderr, "-%c argument %lu must be >= 1", ch, tmp);
+ if ((opt == 'c' || opt == 'r') && tmp == 0) {
+ HDfprintf(stderr, "-%c argument %lu must be >= 1", opt, tmp);
TEST_ERROR;
}
- if (ch == 'c')
+ if (opt == 'c')
s->cols = (unsigned)tmp;
- else if (ch == 'r')
+ else if (opt == 'r')
s->rows = (unsigned)tmp;
- else if (ch == 't')
+ else if (opt == 't')
s->tick_len = (unsigned)tmp;
- else if (ch == 'm')
+ else if (opt == 'm')
s->max_lag = (unsigned)tmp;
- else if (ch == 'B')
+ else if (opt == 'B')
s->pbs = (unsigned)tmp;
- else if (ch == 's')
+ else if (opt == 's')
s->ps = (unsigned)tmp;
- else if (ch == 'u')
+ else if (opt == 'u')
s->check_interval = (unsigned)tmp;
break;
case 'q':
@@ -321,8 +323,8 @@ state_init(state_t *s, int argc, char **argv)
break;
}
}
- argc -= optind;
- argv += optind;
+ argc -= H5_optind;
+ argv += H5_optind;
if (argc > 0) {
HDprintf("unexpected command-line arguments\n");
@@ -337,27 +339,27 @@ state_init(state_t *s, int argc, char **argv)
personality = HDstrstr(s->progname, "vfd_swmr_indep_wr");
if (personality != NULL && HDstrcmp(personality, "vfd_swmr_indep_wr_p0") == 0)
- s->first_proc = true;
+ s->first_proc = TRUE;
else if (personality != NULL && HDstrcmp(personality, "vfd_swmr_indep_wr_p1") == 0)
- s->first_proc = false;
+ s->first_proc = FALSE;
else {
HDprintf("unknown personality, expected vfd_swmr_indep_wr_{p0,p1}\n");
TEST_ERROR;
}
- return true;
+ return TRUE;
error:
if (tfile)
HDfree(tfile);
- return false;
+ return FALSE;
}
/* Initialize the configuration and the file creation and access property lists
* for the VFD SMWR independence of the reader/writer test.
*/
-static bool
-indep_init_vfd_swmr_config_plist(state_t *s, bool writer, const char *mdf_path)
+static hbool_t
+indep_init_vfd_swmr_config_plist(state_t *s, hbool_t writer, const char *mdf_path)
{
H5F_vfd_swmr_config_t config;
@@ -367,7 +369,7 @@ indep_init_vfd_swmr_config_plist(state_t *s, bool writer, const char *mdf_path)
init_vfd_swmr_config(&config, s->tick_len, s->max_lag, writer, TRUE, FALSE, TRUE, 128, mdf_path, NULL);
/* Pass the use_vfd_swmr, only_meta_page, page buffer size, config to vfd_swmr_create_fapl().*/
- if ((s->fapl = vfd_swmr_create_fapl(true, s->use_vfd_swmr, true, s->pbs, &config)) < 0) {
+ if ((s->fapl = vfd_swmr_create_fapl(TRUE, s->use_vfd_swmr, TRUE, s->pbs, &config)) < 0) {
HDprintf("vfd_swmr_create_fapl failed\n");
TEST_ERROR;
}
@@ -378,14 +380,14 @@ indep_init_vfd_swmr_config_plist(state_t *s, bool writer, const char *mdf_path)
TEST_ERROR;
}
- return true;
+ return TRUE;
error:
- return false;
+ return FALSE;
}
/* Write the matrix mat to a dataset. The dataset name depends on the process it runs. */
-static bool
+static hbool_t
write_dataset(const state_t *s, mat_t *mat)
{
@@ -438,7 +440,7 @@ write_dataset(const state_t *s, mat_t *mat)
else
dbgf(1, "Process 1: Successfully write the dataset %s for file %s.\n", dname, s->filename[which]);
- return true;
+ return TRUE;
error:
H5E_BEGIN_TRY
@@ -448,12 +450,12 @@ error:
}
H5E_END_TRY;
- return false;
+ return FALSE;
}
/* Open the dataset according to the dataset name related to the process.
The dataset ID is saved in the state_t s */
-static bool
+static hbool_t
open_dset(state_t *s)
{
@@ -500,16 +502,16 @@ open_dset(state_t *s)
dbgf(1, "Process 0: Successfully open the dataset %s for file %s.\n", dname, s->filename[fopen_idx]);
else
dbgf(1, "Process 1: Successfully open the dataset %s for file %s.\n", dname, s->filename[fopen_idx]);
- return true;
+ return TRUE;
error:
- return false;
+ return FALSE;
}
/* Verify a dataset, this routine must be called after the open_dset().
* It will use the dataset ID assigned by open_dset().
*/
-static bool
+static hbool_t
vrfy_dset(const state_t *s, mat_t *mat)
{
@@ -546,7 +548,7 @@ vrfy_dset(const state_t *s, mat_t *mat)
if (s->first_proc)
which = 1;
- if (verify_matrix(mat, which) == false) {
+ if (verify_matrix(mat, which) == FALSE) {
HDfprintf(stderr, "dataset verification failed\n");
TEST_ERROR;
}
@@ -556,22 +558,22 @@ vrfy_dset(const state_t *s, mat_t *mat)
else
dbgf(1, "Process 1: Successfully verify a dataset.\n");
- return true;
+ return TRUE;
error:
- return false;
+ return FALSE;
}
/* The wrapper routine of open_dset() and vrfy_dset() for readers to verify a dataset. */
-static bool
+static hbool_t
read_vrfy_dataset(state_t *s, mat_t *mat)
{
- if (false == open_dset(s)) {
+ if (FALSE == open_dset(s)) {
HDfprintf(stderr, "Reader: open_dataset() failed\n");
TEST_ERROR;
}
- if (false == vrfy_dset(s, mat)) {
+ if (FALSE == vrfy_dset(s, mat)) {
HDfprintf(stderr, "Reader: vrfy_dataset() failed\n");
TEST_ERROR;
}
@@ -580,7 +582,7 @@ read_vrfy_dataset(state_t *s, mat_t *mat)
HDfprintf(stderr, "Reader: H5Dclose() failed\n");
TEST_ERROR;
}
- return true;
+ return TRUE;
error:
@@ -589,11 +591,11 @@ error:
H5Dclose(s->r_dsetid);
}
H5E_END_TRY;
- return false;
+ return FALSE;
}
/* Close the file access and creation property lists. */
-static bool
+static hbool_t
close_pl(const state_t *s)
{
@@ -607,7 +609,7 @@ close_pl(const state_t *s)
TEST_ERROR;
}
- return true;
+ return TRUE;
error:
H5E_BEGIN_TRY
@@ -617,15 +619,15 @@ error:
}
H5E_END_TRY;
- return false;
+ return FALSE;
}
int
main(int argc, char **argv)
{
- bool writer = true;
+ hbool_t writer = TRUE;
state_t s;
- bool ret = false;
+ hbool_t ret = FALSE;
unsigned i;
mat_t * mat = NULL;
@@ -642,8 +644,8 @@ main(int argc, char **argv)
/* The first process writes a dataset in the first file and then reads a dataset from the second file.*/
if (s.first_proc) {
- writer = true;
- if (false == indep_init_vfd_swmr_config_plist(&s, writer, "./file1-shadow")) {
+ writer = TRUE;
+ if (FALSE == indep_init_vfd_swmr_config_plist(&s, writer, "./file1-shadow")) {
HDfprintf(stderr, "Writer: Cannot initialize file property lists for file %s\n", s.filename[0]);
TEST_ERROR;
}
@@ -654,7 +656,7 @@ main(int argc, char **argv)
}
ret = write_dataset(&s, mat);
- if (ret == false) {
+ if (ret == FALSE) {
HDfprintf(stderr, "write_dataset failed for the file %s\n", s.filename[0]);
TEST_ERROR;
}
@@ -670,13 +672,13 @@ main(int argc, char **argv)
H5E_END_TRY;
}
- if (false == close_pl(&s)) {
+ if (FALSE == close_pl(&s)) {
HDfprintf(stderr, "Fail to close file property lists for writing the file %s.\n", s.filename[0]);
TEST_ERROR;
}
- writer = false;
- if (false == indep_init_vfd_swmr_config_plist(&s, writer, "./file2-shadow")) {
+ writer = FALSE;
+ if (FALSE == indep_init_vfd_swmr_config_plist(&s, writer, "./file2-shadow")) {
HDfprintf(stderr, "Reader: Cannot initialize file property lists for file %s\n", s.filename[1]);
TEST_ERROR;
}
@@ -687,12 +689,12 @@ main(int argc, char **argv)
}
ret = read_vrfy_dataset(&s, mat);
- if (ret == false) {
+ if (ret == FALSE) {
HDfprintf(stderr, "read and verify dataset failed for file %s\n", s.filename[1]);
TEST_ERROR;
}
- if (false == close_pl(&s)) {
+ if (FALSE == close_pl(&s)) {
HDfprintf(stderr, "Fail to close file property lists for reading the file %s.\n", s.filename[1]);
TEST_ERROR;
}
@@ -712,8 +714,8 @@ main(int argc, char **argv)
/* The second process reads the dataset of the first file generated by the first process,
* then writes a dataset in the second file for the first process to read.
*/
- writer = false;
- if (false == indep_init_vfd_swmr_config_plist(&s, writer, "./file1-shadow")) {
+ writer = FALSE;
+ if (FALSE == indep_init_vfd_swmr_config_plist(&s, writer, "./file1-shadow")) {
HDfprintf(stderr, "Reader: Cannot initialize file property lists for file %s\n", s.filename[0]);
TEST_ERROR;
}
@@ -724,18 +726,18 @@ main(int argc, char **argv)
TEST_ERROR;
}
ret = read_vrfy_dataset(&s, mat);
- if (ret == false) {
+ if (ret == FALSE) {
HDfprintf(stderr, "read and verify dataset failed for file %s\n", s.filename[0]);
TEST_ERROR;
}
- if (false == close_pl(&s)) {
+ if (FALSE == close_pl(&s)) {
HDfprintf(stderr, "Fail to close file property lists for reading the file %s.\n", s.filename[0]);
TEST_ERROR;
}
- writer = true;
- if (false == indep_init_vfd_swmr_config_plist(&s, writer, "./file2-shadow")) {
+ writer = TRUE;
+ if (FALSE == indep_init_vfd_swmr_config_plist(&s, writer, "./file2-shadow")) {
HDfprintf(stderr, "writer: Cannot initialize file property lists for file %s\n", s.filename[1]);
TEST_ERROR;
}
@@ -746,7 +748,7 @@ main(int argc, char **argv)
TEST_ERROR;
}
ret = write_dataset(&s, mat);
- if (ret == false) {
+ if (ret == FALSE) {
HDfprintf(stderr, "write_dataset failed for the file %s\n", s.filename[1]);
TEST_ERROR;
}
@@ -762,7 +764,7 @@ main(int argc, char **argv)
H5E_END_TRY;
}
- if (false == close_pl(&s)) {
+ if (FALSE == close_pl(&s)) {
HDfprintf(stderr, "Fail to close file property lists for writing the file %s.\n", s.filename[1]);
TEST_ERROR;
}
@@ -806,6 +808,6 @@ main(void)
{
HDfprintf(stderr, "Non-POSIX platform. Skipping.\n");
return EXIT_SUCCESS;
-} /* end main() */
+}
#endif /* H5_HAVE_WIN32_API */
diff --git a/test/vfd_swmr_vlstr_reader.c b/test/vfd_swmr_vlstr_reader.c
index 050b14d..cbcc6c0 100644
--- a/test/vfd_swmr_vlstr_reader.c
+++ b/test/vfd_swmr_vlstr_reader.c
@@ -27,21 +27,20 @@
typedef enum _step { CREATE = 0, LENGTHEN, SHORTEN, DELETE, NSTEPS } step_t;
-static const hid_t badhid = H5I_INVALID_HID; // abbreviate
-static bool caught_out_of_bounds = false;
-static bool read_null = false;
+static hbool_t caught_out_of_bounds = FALSE;
+static hbool_t read_null = FALSE;
-static bool
+static hbool_t
read_vl_dset(hid_t dset, hid_t type, char **data)
{
- bool success;
+ hbool_t success;
estack_state_t es;
es = disable_estack();
success = H5Dread(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) >= 0;
if (*data == NULL) {
- read_null = true;
- return false;
+ read_null = TRUE;
+ return FALSE;
}
restore_estack(es);
@@ -62,33 +61,34 @@ usage(const char *progname)
int
main(int argc, char **argv)
{
- hid_t fapl, fid, space, type;
- hid_t dset[2];
- char * content[2];
- char name[2][96];
- int ch, i, ntimes = 100;
- unsigned long tmp;
- bool use_vfd_swmr = true;
- char * end;
- const long millisec_in_nanosecs = 1000 * 1000;
- const struct timespec delay = {.tv_sec = 0, .tv_nsec = millisec_in_nanosecs * 11 / 10};
- testsel_t sel = TEST_NONE;
- H5F_vfd_swmr_config_t config;
-
- HDassert(H5T_C_S1 != badhid);
-
- while ((ch = getopt(argc, argv, "Sn:qt:")) != -1) {
- switch (ch) {
+ hid_t fapl, fid, space, type;
+ hid_t dset[2];
+ char * content[2];
+ char name[2][96];
+ int opt, i, ntimes = 100;
+ unsigned long tmp;
+ hbool_t use_vfd_swmr = TRUE;
+ char * end;
+ const uint64_t delay_ns = 1100 * 1000; /* 1.1 ms */
+ testsel_t sel = TEST_NONE;
+ H5F_vfd_swmr_config_t config;
+ const char * s_opts = "Sn:qt:";
+ struct h5_long_options l_opts[] = {{NULL, 0, '\0'}};
+
+ HDassert(H5T_C_S1 != H5I_INVALID_HID);
+
+ while ((opt = H5_get_option(argc, (const char *const *)argv, s_opts, l_opts)) != EOF) {
+ switch (opt) {
case 'S':
- use_vfd_swmr = false;
+ use_vfd_swmr = FALSE;
break;
case 'n':
errno = 0;
- tmp = HDstrtoul(optarg, &end, 0);
+ tmp = HDstrtoul(H5_optarg, &end, 0);
if (end == optarg || *end != '\0')
- errx(EXIT_FAILURE, "couldn't parse `-n` argument `%s`", optarg);
+ errx(EXIT_FAILURE, "couldn't parse `-n` argument `%s`", H5_optarg);
else if (errno != 0)
- err(EXIT_FAILURE, "couldn't parse `-n` argument `%s`", optarg);
+ err(EXIT_FAILURE, "couldn't parse `-n` argument `%s`", H5_optarg);
else if (tmp > INT_MAX)
errx(EXIT_FAILURE, "`-n` argument `%lu` too large", tmp);
ntimes = (int)tmp;
@@ -97,9 +97,9 @@ main(int argc, char **argv)
verbosity = 1;
break;
case 't':
- if (HDstrcmp(optarg, "oob") == 0)
+ if (HDstrcmp(H5_optarg, "oob") == 0)
sel = TEST_OOB;
- else if (HDstrcmp(optarg, "null") == 0)
+ else if (HDstrcmp(H5_optarg, "null") == 0)
sel = TEST_NULL;
else
usage(argv[0]);
@@ -109,18 +109,18 @@ main(int argc, char **argv)
break;
}
}
- argv += optind;
- argc -= optind;
+ argv += H5_optind;
+ argc -= H5_optind;
if (argc > 0)
errx(EXIT_FAILURE, "unexpected command-line arguments");
/* config, tick_len, max_lag, writer, maintain_metadata_file, generate_updater_files,
* flush_raw_data, md_pages_reserved, md_file_path, updater_file_path */
- init_vfd_swmr_config(&config, 4, 7, false, TRUE, FALSE, TRUE, 128, "./vlstr-shadow", NULL);
+ init_vfd_swmr_config(&config, 4, 7, FALSE, TRUE, FALSE, TRUE, 128, "./vlstr-shadow", NULL);
/* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */
- fapl = vfd_swmr_create_fapl(true, use_vfd_swmr, sel == TEST_OOB, 4096, &config);
+ fapl = vfd_swmr_create_fapl(TRUE, use_vfd_swmr, sel == TEST_OOB, 4096, &config);
if (fapl < 0)
errx(EXIT_FAILURE, "vfd_swmr_create_fapl");
@@ -128,24 +128,24 @@ main(int argc, char **argv)
fid = H5Fopen("vfd_swmr_vlstr.h5", H5F_ACC_RDONLY, fapl);
/* Create the VL string datatype and a scalar dataspace */
- if ((type = H5Tcopy(H5T_C_S1)) == badhid)
+ if ((type = H5Tcopy(H5T_C_S1)) == H5I_INVALID_HID)
errx(EXIT_FAILURE, "H5Tcopy");
if (H5Tset_size(type, H5T_VARIABLE) < 0)
errx(EXIT_FAILURE, "H5Tset_size");
space = H5Screate(H5S_SCALAR);
- if (space == badhid)
+ if (space == H5I_INVALID_HID)
errx(EXIT_FAILURE, "H5Screate");
- if (fid == badhid)
+ if (fid == H5I_INVALID_HID)
errx(EXIT_FAILURE, "H5Fcreate");
/* content 0 seq 1 short
* content 1 seq 1 long long long long long long long long
* content 1 seq 1 medium medium medium
*/
- for (i = 0; !caught_out_of_bounds && i < ntimes; (i % 2 == 0) ? nanosleep(&delay, NULL) : 0, i++) {
+ for (i = 0; !caught_out_of_bounds && i < ntimes; (i % 2 == 0) ? H5_nanosleep(delay_ns) : 0, i++) {
estack_state_t es;
const int ndsets = 2;
const int which = i % ndsets;
@@ -161,7 +161,7 @@ main(int argc, char **argv)
es = disable_estack();
dset[which] = H5Dopen2(fid, name[which], H5P_DEFAULT);
restore_estack(es);
- if (caught_out_of_bounds || dset[which] == badhid) {
+ if (caught_out_of_bounds || dset[which] == H5I_INVALID_HID) {
dbgf(2, ": couldn't open\n");
continue;
}
@@ -219,6 +219,6 @@ main(void)
{
HDfprintf(stderr, "Non-POSIX platform. Skipping.\n");
return EXIT_SUCCESS;
-} /* end main() */
+}
#endif /* H5_HAVE_WIN32_API */
diff --git a/test/vfd_swmr_vlstr_writer.c b/test/vfd_swmr_vlstr_writer.c
index 1d18271..682e86a 100644
--- a/test/vfd_swmr_vlstr_writer.c
+++ b/test/vfd_swmr_vlstr_writer.c
@@ -28,8 +28,7 @@
enum _step { CREATE = 0, LENGTHEN, SHORTEN, DELETE, NSTEPS } step_t;
-static const hid_t badhid = H5I_INVALID_HID; // abbreviate
-static bool caught_out_of_bounds = false;
+static hbool_t caught_out_of_bounds = FALSE;
static void
write_vl_dset(hid_t dset, hid_t type, hid_t space, char *data)
@@ -40,38 +39,6 @@ write_vl_dset(hid_t dset, hid_t type, hid_t space, char *data)
errx(EXIT_FAILURE, "%s: H5Dflush", __func__);
}
-#if 0
-static hid_t
-initialize_dset(hid_t file, hid_t type, hid_t space, const char *name,
- void *data)
-{
- hid_t dset;
-
- dset = H5Dcreate2(file, name, type, space, H5P_DEFAULT, H5P_DEFAULT,
- H5P_DEFAULT);
-
- if (dset == badhid)
- errx(EXIT_FAILURE, "H5Dcreate2");
-
- if (H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0)
- errx(EXIT_FAILURE, "H5Dwrite");
-
- if (H5Dflush(dset) < 0)
- errx(EXIT_FAILURE, "%s: H5Dflush", __func__);
-
- return dset;
-}
-
-static void
-rewrite_dset(hid_t dset, hid_t type, char *data)
-{
- if (H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0)
- errx(EXIT_FAILURE, "%s: H5Dwrite", __func__);
- if (H5Dflush(dset) < 0)
- errx(EXIT_FAILURE, "%s: H5Dflush", __func__);
-}
-#endif
-
static hid_t
create_vl_dset(hid_t file, hid_t type, hid_t space, const char *name)
{
@@ -79,7 +46,7 @@ create_vl_dset(hid_t file, hid_t type, hid_t space, const char *name)
dset = H5Dcreate2(file, name, type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- if (dset == badhid)
+ if (dset == H5I_INVALID_HID)
errx(EXIT_FAILURE, "H5Dcreate2");
return dset;
@@ -120,44 +87,45 @@ usage(const char *progname)
int
main(int argc, char **argv)
{
- hid_t fapl, fcpl, fid, space, type;
- hid_t dset[2];
- char content[2][96];
- char name[2][96];
- H5F_t * f;
- H5C_t * cache;
- sigset_t oldsigs;
- herr_t ret;
- bool variable = true, wait_for_signal = true;
- const hsize_t dims = 1;
- int ch, i, ntimes = 100;
- unsigned long tmp;
- char * end;
- bool use_vfd_swmr = true;
- const struct timespec delay = {.tv_sec = 0, .tv_nsec = 1000 * 1000 * 1000 / 10};
- testsel_t sel = TEST_NONE;
- H5F_vfd_swmr_config_t config;
-
- HDassert(H5T_C_S1 != badhid);
-
- while ((ch = getopt(argc, argv, "SWfn:qt:")) != -1) {
- switch (ch) {
+ hid_t fapl, fcpl, fid, space, type;
+ hid_t dset[2];
+ char content[2][96];
+ char name[2][96];
+ H5F_t * f;
+ H5C_t * cache;
+ sigset_t oldsigs;
+ hbool_t variable = TRUE, wait_for_signal = TRUE;
+ const hsize_t dims = 1;
+ int opt, i, ntimes = 100;
+ unsigned long tmp;
+ char * end;
+ hbool_t use_vfd_swmr = TRUE;
+ const uint64_t delay_ns = 100 * 1000 * 1000; /* 100 ms */
+ testsel_t sel = TEST_NONE;
+ H5F_vfd_swmr_config_t config;
+ const char * s_opts = "SWfn:qt:";
+ struct h5_long_options l_opts[] = {{NULL, 0, '\0'}};
+
+ HDassert(H5T_C_S1 != H5I_INVALID_HID);
+
+ while ((opt = H5_get_option(argc, (const char *const *)argv, s_opts, l_opts)) != EOF) {
+ switch (opt) {
case 'S':
- use_vfd_swmr = false;
+ use_vfd_swmr = FALSE;
break;
case 'W':
- wait_for_signal = false;
+ wait_for_signal = FALSE;
break;
case 'f':
- variable = false;
+ variable = FALSE;
break;
case 'n':
errno = 0;
- tmp = HDstrtoul(optarg, &end, 0);
- if (end == optarg || *end != '\0')
- errx(EXIT_FAILURE, "couldn't parse `-n` argument `%s`", optarg);
+ tmp = HDstrtoul(H5_optarg, &end, 0);
+ if (end == H5_optarg || *end != '\0')
+ errx(EXIT_FAILURE, "couldn't parse `-n` argument `%s`", H5_optarg);
else if (errno != 0)
- err(EXIT_FAILURE, "couldn't parse `-n` argument `%s`", optarg);
+ err(EXIT_FAILURE, "couldn't parse `-n` argument `%s`", H5_optarg);
else if (tmp > INT_MAX)
errx(EXIT_FAILURE, "`-n` argument `%lu` too large", tmp);
ntimes = (int)tmp;
@@ -166,9 +134,9 @@ main(int argc, char **argv)
verbosity = 1;
break;
case 't':
- if (HDstrcmp(optarg, "oob") == 0)
+ if (HDstrcmp(H5_optarg, "oob") == 0)
sel = TEST_OOB;
- else if (HDstrcmp(optarg, "null") == 0)
+ else if (HDstrcmp(H5_optarg, "null") == 0)
sel = TEST_NULL;
else
usage(argv[0]);
@@ -178,18 +146,19 @@ main(int argc, char **argv)
break;
}
}
- argv += optind;
- argc -= optind;
+ argv += H5_optind;
+ argc -= H5_optind;
if (argc > 0)
errx(EXIT_FAILURE, "unexpected command-line arguments");
/* config, tick_len, max_lag, writer, maintain_metadata_file, generate_updater_files,
- * flush_raw_data, md_pages_reserved, md_file_path, updater_file_path */
- init_vfd_swmr_config(&config, 4, 7, true, TRUE, FALSE, TRUE, 128, "./vlstr-shadow", NULL);
+ * flush_raw_data, md_pages_reserved, md_file_path, updater_file_path
+ */
+ init_vfd_swmr_config(&config, 4, 7, TRUE, TRUE, FALSE, TRUE, 128, "./vlstr-shadow", NULL);
/* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */
- fapl = vfd_swmr_create_fapl(true, use_vfd_swmr, sel == TEST_OOB, 4096, &config);
+ fapl = vfd_swmr_create_fapl(TRUE, use_vfd_swmr, sel == TEST_OOB, 4096, &config);
if (fapl < 0)
errx(EXIT_FAILURE, "vfd_swmr_create_fapl");
@@ -203,7 +172,7 @@ main(int argc, char **argv)
/* Create the VL string datatype and a scalar dataspace, or a
* fixed-length string datatype and a simple dataspace.
*/
- if ((type = H5Tcopy(H5T_C_S1)) == badhid)
+ if ((type = H5Tcopy(H5T_C_S1)) == H5I_INVALID_HID)
errx(EXIT_FAILURE, "H5Tcopy");
if (!variable) {
@@ -217,7 +186,7 @@ main(int argc, char **argv)
space = H5Screate(H5S_SCALAR);
}
- if (space == badhid)
+ if (space == H5I_INVALID_HID)
errx(EXIT_FAILURE, "H5Screate");
if ((f = H5VL_object_verify(fid, H5I_FILE)) == NULL)
@@ -225,7 +194,7 @@ main(int argc, char **argv)
cache = f->shared->cache;
- if (fid == badhid)
+ if (fid == H5I_INVALID_HID)
errx(EXIT_FAILURE, "H5Fcreate");
block_signals(&oldsigs);
@@ -270,11 +239,13 @@ main(int argc, char **argv)
default:
errx(EXIT_FAILURE, "%s: unknown step %d", __func__, step);
}
+
if (caught_out_of_bounds) {
HDfprintf(stderr, "caught out of bounds\n");
break;
}
- nanosleep(&delay, NULL);
+
+ H5_nanosleep(delay_ns);
}
if (use_vfd_swmr && wait_for_signal)
@@ -307,6 +278,6 @@ main(void)
{
HDfprintf(stderr, "Non-POSIX platform. Skipping.\n");
return EXIT_SUCCESS;
-} /* end main() */
+}
#endif /* H5_HAVE_WIN32_API */
diff --git a/test/vfd_swmr_writer.c b/test/vfd_swmr_writer.c
index a076be0..eeceb49 100644
--- a/test/vfd_swmr_writer.c
+++ b/test/vfd_swmr_writer.c
@@ -32,7 +32,6 @@
#include "vfd_swmr_common.h"
#include "swmr_common.h"
-/* Uses getopt */
#ifndef H5_HAVE_WIN32_API
/********************/
@@ -102,7 +101,7 @@ open_skeleton(const char *filename, hbool_t verbose, FILE *verbose_file, unsigne
HDsnprintf(verbose_name, sizeof(verbose_name), "vfd_swmr_writer.log.%u", random_seed);
H5Pset_fapl_log(fapl, verbose_name, H5FD_LOG_ALL, (size_t)(512 * 1024 * 1024));
- } /* end if */
+ }
/* Open the file with VFD SWMR configured */
if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
@@ -227,9 +226,9 @@ add_records(hid_t fid, hbool_t verbose, FILE *verbose_file, unsigned long nrecor
if (0 == rec_to_flush) {
/* Reset flush counter */
rec_to_flush = flush_count;
- } /* end if */
- } /* end if */
- } /* end for */
+ }
+ }
+ }
/* Close the memory dataspace */
if (H5Sclose(mem_sid) < 0)
@@ -269,31 +268,33 @@ usage(void)
HDprintf("Defaults to verbose (no '-q' given), latest format when opening file (no '-o' given),\n");
HDprintf("flushing every 10000 records ('-f 10000'), and will generate a random seed (no -r given).\n");
HDprintf("\n");
- HDexit(1);
+ HDexit(EXIT_FAILURE);
}
int
main(int argc, char *const *argv)
{
- sigset_t oldset;
- hid_t fid; /* File ID for file opened */
- long nrecords = 0; /* # of records to append */
- long flush_count = 10000; /* # of records to write between flushing file */
- hbool_t verbose = TRUE; /* Whether to emit some informational messages */
- FILE * verbose_file = NULL; /* File handle for verbose output */
- hbool_t old = FALSE; /* Whether to use non-latest-format when opening file */
- hbool_t use_seed = FALSE; /* Set to TRUE if a seed was set on the command line */
- hbool_t wait_for_signal = TRUE;
- unsigned random_seed = 0; /* Random # seed */
- int ch, temp;
+ sigset_t oldset;
+ hid_t fid; /* File ID for file opened */
+ long nrecords = 0; /* # of records to append */
+ long flush_count = 10000; /* # of records to write between flushing file */
+ hbool_t verbose = TRUE; /* Whether to emit some informational messages */
+ FILE * verbose_file = NULL; /* File handle for verbose output */
+ hbool_t old = FALSE; /* Whether to use non-latest-format when opening file */
+ hbool_t use_seed = FALSE; /* Set to TRUE if a seed was set on the command line */
+ hbool_t wait_for_signal = TRUE;
+ unsigned random_seed = 0; /* Random # seed */
+ int opt, temp;
+ const char * s_opts = "Wf:qr:o";
+ struct h5_long_options l_opts[] = {{NULL, 0, '\0'}};
block_signals(&oldset);
- while ((ch = getopt(argc, argv, "Wf:qr:o")) != -1) {
- switch (ch) {
+ while ((opt = H5_get_option(argc, (const char *const *)argv, s_opts, l_opts)) != EOF) {
+ switch (opt) {
/* # of records to write between flushing file */
case 'f':
- flush_count = HDatol(optarg);
+ flush_count = HDatol(H5_optarg);
if (flush_count < 0)
usage();
break;
@@ -306,7 +307,7 @@ main(int argc, char *const *argv)
/* Random # seed */
case 'r':
use_seed = TRUE;
- temp = HDatoi(optarg);
+ temp = HDatoi(H5_optarg);
random_seed = (unsigned)temp;
break;
@@ -324,8 +325,8 @@ main(int argc, char *const *argv)
break;
}
}
- argv += optind;
- argc -= optind;
+ argv += H5_optind;
+ argc -= H5_optind;
/* Parse command line options */
if (argc < 1)
usage();
@@ -340,7 +341,7 @@ main(int argc, char *const *argv)
HDgettimeofday(&t, NULL);
random_seed = (unsigned)(t.tv_usec);
- } /* end if */
+ }
HDsrandom(random_seed);
/* Open output file */
@@ -350,16 +351,16 @@ main(int argc, char *const *argv)
HDsnprintf(verbose_name, sizeof(verbose_name), "vfd_swmr_writer.out.%u", random_seed);
if (NULL == (verbose_file = HDfopen(verbose_name, "w"))) {
HDfprintf(stderr, "WRITER: Can't open verbose output file!\n");
- HDexit(1);
+ HDexit(EXIT_FAILURE);
}
- } /* end if */
+ }
/* Emit informational message */
if (verbose) {
HDfprintf(verbose_file, "WRITER: Parameters:\n");
HDfprintf(verbose_file, "\t# of records between flushes = %ld\n", flush_count);
HDfprintf(verbose_file, "\t# of records to write = %ld\n", nrecords);
- } /* end if */
+ }
/* ALWAYS emit the random seed for possible debugging */
HDfprintf(stdout, "Using writer random seed: %u\n", random_seed);
@@ -380,8 +381,8 @@ main(int argc, char *const *argv)
/* Open file skeleton */
if ((fid = open_skeleton(VFD_SWMR_FILENAME, verbose, verbose_file, random_seed, old)) < 0) {
HDfprintf(stderr, "WRITER: Error opening skeleton file!\n");
- HDexit(1);
- } /* end if */
+ HDexit(EXIT_FAILURE);
+ }
/* Send a message to indicate "H5Fopen" is complete--releasing the file lock */
h5_send_message(VFD_SWMR_WRITER_MESSAGE, NULL, NULL);
@@ -393,8 +394,8 @@ main(int argc, char *const *argv)
/* Append records to datasets */
if (add_records(fid, verbose, verbose_file, (unsigned long)nrecords, (unsigned long)flush_count) < 0) {
HDfprintf(stderr, "WRITER: Error appending records to datasets!\n");
- HDexit(1);
- } /* end if */
+ HDexit(EXIT_FAILURE);
+ }
/* Emit informational message */
if (verbose)
@@ -403,8 +404,8 @@ main(int argc, char *const *argv)
/* Clean up the symbols */
if (shutdown_symbols() < 0) {
HDfprintf(stderr, "WRITER: Error releasing symbols!\n");
- HDexit(1);
- } /* end if */
+ HDexit(EXIT_FAILURE);
+ }
if (wait_for_signal)
await_signal(fid);
@@ -418,10 +419,10 @@ main(int argc, char *const *argv)
/* Close objects opened */
if (H5Fclose(fid) < 0) {
HDfprintf(stderr, "WRITER: Error closing file!\n");
- HDexit(1);
- } /* end if */
+ HDexit(EXIT_FAILURE);
+ }
- return 0;
+ return EXIT_SUCCESS;
}
#else /* H5_HAVE_WIN32_API */
@@ -431,6 +432,6 @@ main(void)
{
HDfprintf(stderr, "Non-POSIX platform. Skipping.\n");
return EXIT_SUCCESS;
-} /* end main() */
+}
#endif /* H5_HAVE_WIN32_API */
diff --git a/test/vfd_swmr_zoo_writer.c b/test/vfd_swmr_zoo_writer.c
index 3efab61..32726f7 100644
--- a/test/vfd_swmr_zoo_writer.c
+++ b/test/vfd_swmr_zoo_writer.c
@@ -36,16 +36,16 @@ typedef struct _shared_ticks {
int fd_writer_to_reader = -1, fd_reader_to_writer = -1;
const char * fifo_writer_to_reader = "./fifo_writer_to_reader";
const char * fifo_reader_to_writer = "./fifo_reader_to_writer";
-bool use_vfd_swmr = true;
-bool use_named_pipe = true;
-bool print_estack = false;
+hbool_t use_vfd_swmr = TRUE;
+hbool_t use_named_pipe = TRUE;
+hbool_t print_estack = FALSE;
static H5F_vfd_swmr_config_t swmr_config;
-static bool writer;
+static hbool_t writer;
struct timespec ival = {MAX_READ_LEN_IN_SECONDS, 0}; /* Expected maximal time for reader's validation */
zoo_config_t config = {.proc_num = 0,
- .skip_compact = false,
- .skip_varlen = true,
+ .skip_compact = FALSE,
+ .skip_varlen = TRUE,
.max_pause_msecs = 0,
.msgival = {.tv_sec = 0, .tv_nsec = 0}};
@@ -97,36 +97,38 @@ usage(const char *progname)
static int
parse_command_line_options(int argc, char **argv)
{
- int ch;
- unsigned long tmpl;
- char * end;
-
- while ((ch = getopt(argc, argv, "CSael:Nqv")) != -1) {
- switch (ch) {
+ int opt;
+ unsigned long tmpl;
+ char * end;
+ const char * s_opts = "CSael:Nqv";
+ struct h5_long_options l_opts[] = {{NULL, 0, '\0'}};
+
+ while ((opt = H5_get_option(argc, (const char *const *)argv, s_opts, l_opts)) != EOF) {
+ switch (opt) {
case 'C':
- config.skip_compact = true;
+ config.skip_compact = TRUE;
break;
case 'S':
- use_vfd_swmr = false;
+ use_vfd_swmr = FALSE;
break;
case 'a':
- config.skip_varlen = false;
+ config.skip_varlen = FALSE;
break;
case 'e':
- print_estack = true;
+ print_estack = TRUE;
break;
case 'l':
/* Expected maximal number of ticks from the writer's finishing zoo creation or deletion
* to the reader's finishing validation of zoo creation or deletion */
errno = 0;
- tmpl = HDstrtoul(optarg, &end, 0);
+ tmpl = HDstrtoul(H5_optarg, &end, 0);
- if (end == optarg || *end != '\0') {
- HDprintf("couldn't parse `-l` argument `%s`", optarg);
+ if (end == H5_optarg || *end != '\0') {
+ HDprintf("couldn't parse `-l` argument `%s`", H5_optarg);
goto error;
}
else if (errno != 0) {
- HDprintf("couldn't parse `-l` argument `%s`", optarg);
+ HDprintf("couldn't parse `-l` argument `%s`", H5_optarg);
goto error;
}
else if (tmpl > UINT_MAX) {
@@ -146,7 +148,7 @@ parse_command_line_options(int argc, char **argv)
break;
case 'N':
/* Disable named pipes, mainly for running the writer and reader separately */
- use_named_pipe = false;
+ use_named_pipe = FALSE;
break;
case 'q':
verbosity = 1;
@@ -159,8 +161,8 @@ parse_command_line_options(int argc, char **argv)
break;
}
}
- argv += optind;
- argc -= optind;
+ argv += H5_optind;
+ argc -= H5_optind;
if (argc > 0) {
H5_FAILED();
@@ -461,9 +463,9 @@ main(int argc, char **argv)
personality = HDstrstr(progname, "vfd_swmr_zoo_");
if (personality != NULL && HDstrcmp(personality, "vfd_swmr_zoo_writer") == 0)
- writer = true;
+ writer = TRUE;
else if (personality != NULL && HDstrcmp(personality, "vfd_swmr_zoo_reader") == 0)
- writer = false;
+ writer = FALSE;
else {
H5_FAILED();
AT();
@@ -479,7 +481,7 @@ main(int argc, char **argv)
/* ? turn off use latest format argument via 1st argument? since later on it reset to early format */
/* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */
- if ((fapl = vfd_swmr_create_fapl(true, use_vfd_swmr, true, 4096, &vfd_swmr_config)) < 0) {
+ if ((fapl = vfd_swmr_create_fapl(TRUE, use_vfd_swmr, TRUE, 4096, &vfd_swmr_config)) < 0) {
H5_FAILED();
AT();
HDprintf("vfd_swmr_create_fapl");