From 17ac0b623d1558779066d4625f5bb2b5b1500e0b Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Mon, 2 Dec 2024 08:36:47 -0800 Subject: [PATCH 01/14] Add an H5Iregister_type1 call * Add the function call (copy of existing H5Iregister_type) * Add H5Ideprec.c * Remove the hash_size parameter from H5Iregister_type * Copy the basic test in tid.c and use the register1 call instead * No make_vers changes at this time --- doxygen/examples/H5I_examples.c | 8 +- hl/src/H5PT.c | 8 +- java/src/hdf/hdf5lib/H5.java | 2 +- src/CMakeLists.txt | 1 + src/H5I.c | 2 +- src/H5Ideprec.c | 144 +++++++++++++++++++ src/H5Ipublic.h | 55 +++++-- src/Makefile.am | 2 +- test/tid.c | 245 ++++++++++++++++++++++++++++++-- 9 files changed, 436 insertions(+), 31 deletions(-) create mode 100644 src/H5Ideprec.c diff --git a/doxygen/examples/H5I_examples.c b/doxygen/examples/H5I_examples.c index 657e1b53d8d..9c1a8472dab 100644 --- a/doxygen/examples/H5I_examples.c +++ b/doxygen/examples/H5I_examples.c @@ -133,7 +133,7 @@ fail_dcpl:; hid_t obj_id; // register a new ID type - if ((type = H5Iregister_type(128, 1024, &free_func)) < 0) { + if ((type = H5Iregister_type(1024, &free_func)) < 0) { ret_val = EXIT_FAILURE; goto fail_register; } @@ -167,7 +167,7 @@ fail_register:; hsize_t count; // register a new ID type - if ((type = H5Iregister_type(128, 1024, NULL)) < 0) { + if ((type = H5Iregister_type(1024, NULL)) < 0) { ret_val = EXIT_FAILURE; goto fail_register; } @@ -194,7 +194,7 @@ fail_register:; hid_t obj_id; // register a new ID type - if ((type = H5Iregister_type(128, 1024, NULL)) < 0) { + if ((type = H5Iregister_type(1024, NULL)) < 0) { ret_val = EXIT_FAILURE; goto fail_register; } @@ -224,7 +224,7 @@ fail_register:; H5I_type_t type; // register a new ID type - if ((type = H5Iregister_type(128, 1024, NULL)) < 0) { + if ((type = H5Iregister_type(1024, NULL)) < 0) { ret_val = EXIT_FAILURE; goto fail_register; } diff --git a/hl/src/H5PT.c b/hl/src/H5PT.c index c8cefd3a324..77fec0c9742 100644 --- a/hl/src/H5PT.c +++ b/hl/src/H5PT.c @@ -25,8 +25,6 @@ typedef struct { static hsize_t H5PT_ptable_count = 0; static H5I_type_t H5PT_ptable_id_type = H5I_UNINIT; -#define H5PT_HASH_TABLE_SIZE 64 - /* Packet Table private functions */ static herr_t H5PT_free_id(void *id, void **_ctx); static herr_t H5PT_close(htbl_t *table); @@ -74,7 +72,7 @@ H5PTcreate(hid_t loc_id, const char *dset_name, hid_t dtype_id, hsize_t chunk_si /* Register the packet table ID type if this is the first table created */ if (H5PT_ptable_id_type < 0) if ((H5PT_ptable_id_type = - H5Iregister_type((size_t)H5PT_HASH_TABLE_SIZE, 0, (H5I_free_t)H5PT_free_id)) < 0) + H5Iregister_type(0, (H5I_free_t)H5PT_free_id)) < 0) goto error; /* Get memory for the table identifier */ @@ -188,7 +186,7 @@ H5PTcreate_fl(hid_t loc_id, const char *dset_name, hid_t dtype_id, hsize_t chunk /* Register the packet table ID type if this is the first table created */ if (H5PT_ptable_id_type < 0) if ((H5PT_ptable_id_type = - H5Iregister_type((size_t)H5PT_HASH_TABLE_SIZE, 0, (H5I_free_t)H5PT_free_id)) < 0) + H5Iregister_type(0, (H5I_free_t)H5PT_free_id)) < 0) goto error; /* Get memory for the table identifier */ @@ -288,7 +286,7 @@ H5PTopen(hid_t loc_id, const char *dset_name) /* Register the packet table ID type if this is the first table created */ if (H5PT_ptable_id_type < 0) if ((H5PT_ptable_id_type = - H5Iregister_type((size_t)H5PT_HASH_TABLE_SIZE, 0, (H5I_free_t)H5PT_free_id)) < 0) + H5Iregister_type(0, (H5I_free_t)H5PT_free_id)) < 0) goto error; table = (htbl_t *)malloc(sizeof(htbl_t)); diff --git a/java/src/hdf/hdf5lib/H5.java b/java/src/hdf/hdf5lib/H5.java index fe475611bc8..fe51f4e511d 100644 --- a/java/src/hdf/hdf5lib/H5.java +++ b/java/src/hdf/hdf5lib/H5.java @@ -6306,7 +6306,7 @@ public synchronized static native void H5Iclear_type(int type_id, boolean force) // hid_t H5Iregister(H5I_type_t type, const void *object); // typedef herr_t (*H5I_free_t)(void *); - // H5I_type_t H5Iregister_type(size_t hash_size, unsigned reserved, H5I_free_t free_func); + // H5I_type_t H5Iregister_type2(unsigned reserved, H5I_free_t free_func); // void *H5Iremove_verify(hid_t id, H5I_type_t id_type); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2cdaa575c43..8900bae7528 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -387,6 +387,7 @@ IDE_GENERATED_PROPERTIES ("H5HL" "${H5HL_HDRS}" "${H5HL_SOURCES}" ) set (H5I_SOURCES ${HDF5_SRC_DIR}/H5I.c ${HDF5_SRC_DIR}/H5Idbg.c + ${HDF5_SRC_DIR}/H5Ideprec.c ${HDF5_SRC_DIR}/H5Iint.c ${HDF5_SRC_DIR}/H5Itest.c ) diff --git a/src/H5I.c b/src/H5I.c index 731f0f31c56..42c5554d490 100644 --- a/src/H5I.c +++ b/src/H5I.c @@ -90,7 +90,7 @@ static int H5I__iterate_pub_cb(void *obj, hid_t id, void *udata); *------------------------------------------------------------------------- */ H5I_type_t -H5Iregister_type(size_t H5_ATTR_UNUSED hash_size, unsigned reserved, H5I_free_t free_func) +H5Iregister_type(unsigned reserved, H5I_free_t free_func) { H5I_class_t *cls = NULL; /* New ID class */ H5I_type_t new_type = H5I_BADID; /* New ID type value */ diff --git a/src/H5Ideprec.c b/src/H5Ideprec.c new file mode 100644 index 00000000000..5d88f4acd95 --- /dev/null +++ b/src/H5Ideprec.c @@ -0,0 +1,144 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 LICENSE 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: H5Ideprec.c + * + * Purpose: Deprecated functions from the H5I interface. These + * functions are here for compatibility purposes and may be + * removed in the future. Applications should switch to the + * newer APIs. + * + *------------------------------------------------------------------------- + */ + +/****************/ +/* Module Setup */ +/****************/ + +#include "H5Imodule.h" /* This source code file is part of the H5I module */ + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Ipkg.h" /* File access */ + +/****************/ +/* Local Macros */ +/****************/ + +/******************/ +/* Local Typedefs */ +/******************/ + +/********************/ +/* Package Typedefs */ +/********************/ + +/********************/ +/* Local Prototypes */ +/********************/ + +/*********************/ +/* Package Variables */ +/*********************/ + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/*******************/ +/* Local Variables */ +/*******************/ + +#ifndef H5_NO_DEPRECATED_SYMBOLS +/*------------------------------------------------------------------------- + * Function: H5Iregister_type1 + * + * Purpose: Public interface to H5I_register_type. Creates a new type + * of ID's to give out. A specific number (RESERVED) of type + * entries may be reserved to enable "constant" values to be handed + * out which are valid IDs in the type, but which do not map to any + * data structures and are not allocated dynamically later. HASH_SIZE is + * the minimum hash table size to use for the type. FREE_FUNC is + * called with an object pointer when the object is removed from + * the type. + * + * Return: Success: Type ID of the new type + * Failure: H5I_BADID + * + *------------------------------------------------------------------------- + */ +H5I_type_t +H5Iregister_type1(size_t H5_ATTR_UNUSED hash_size, unsigned reserved, H5I_free_t free_func) +{ + H5I_class_t *cls = NULL; /* New ID class */ + H5I_type_t new_type = H5I_BADID; /* New ID type value */ + H5I_type_t ret_value = H5I_BADID; /* Return value */ + + FUNC_ENTER_API(H5I_BADID) + + /* Generate a new H5I_type_t value */ + + /* Increment the number of types */ + if (H5I_next_type_g < H5I_MAX_NUM_TYPES) { + new_type = (H5I_type_t)H5I_next_type_g; + H5I_next_type_g++; + } + else { + bool done; /* Indicate that search was successful */ + int i; + + /* Look for a free type to give out */ + done = false; + for (i = H5I_NTYPES; i < H5I_MAX_NUM_TYPES && done == false; i++) { + if (NULL == H5I_type_info_array_g[i]) { + /* Found a free type ID */ + new_type = (H5I_type_t)i; + done = true; + } + } + + /* Verify that we found a type to give out */ + if (done == false) + HGOTO_ERROR(H5E_ID, H5E_NOSPACE, H5I_BADID, "Maximum number of ID types exceeded"); + } + + /* Allocate new ID class */ + if (NULL == (cls = H5MM_calloc(sizeof(H5I_class_t)))) + HGOTO_ERROR(H5E_ID, H5E_CANTALLOC, H5I_BADID, "ID class allocation failed"); + + /* Initialize class fields */ + cls->type = new_type; + cls->flags = H5I_CLASS_IS_APPLICATION; + cls->reserved = reserved; + cls->free_func = free_func; + + /* Register the new ID class */ + if (H5I_register_type(cls) < 0) + HGOTO_ERROR(H5E_ID, H5E_CANTINIT, H5I_BADID, "can't initialize ID class"); + + /* Set return value */ + ret_value = new_type; + +done: + /* Clean up on error */ + if (ret_value < 0) + if (cls) + cls = H5MM_xfree(cls); + + FUNC_LEAVE_API(ret_value) +} /* end H5Iregister_type1() */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ diff --git a/src/H5Ipublic.h b/src/H5Ipublic.h index 9a28dac9094..48a021b1e3d 100644 --- a/src/H5Ipublic.h +++ b/src/H5Ipublic.h @@ -394,8 +394,6 @@ H5_DLL int H5Iget_ref(hid_t id); * * \brief Creates and returns a new ID type * - * \param[in] hash_size Minimum hash table size (in entries) used to store IDs - * for the new type (unused in 1.8.13 and later) * \param[in] reserved Number of reserved IDs for the new type * \param[in] free_func Function used to deallocate space for a single ID * @@ -404,10 +402,6 @@ H5_DLL int H5Iget_ref(hid_t id); * \details H5Iregister_type() allocates space for a new ID type and returns an * identifier for it. * - * The \p hash_size parameter indicates the minimum size of the hash - * table used to store IDs in the new type. This parameter is unused - * in 1.8.13 and later, when the implementation of ID storage changed. - * * The \p reserved parameter indicates the number of IDs in this new * type to be reserved. Reserved IDs are valid IDs which are not * associated with any storage within the library. @@ -420,10 +414,10 @@ H5_DLL int H5Iget_ref(hid_t id); * pointer which was passed in to the H5Iregister() function. The \p * free_func function should return 0 on success and -1 on failure. * - * \since 1.8.0 + * \since 2.0.0 * */ -H5_DLL H5I_type_t H5Iregister_type(size_t hash_size, unsigned reserved, H5I_free_t free_func); +H5_DLL H5I_type_t H5Iregister_type(unsigned reserved, H5I_free_t free_func); /** * \ingroup H5IUD * @@ -683,6 +677,51 @@ H5_DLL htri_t H5Itype_exists(H5I_type_t type); */ H5_DLL htri_t H5Iis_valid(hid_t id); +/* Symbols defined for compatibility with previous versions of the HDF5 API. + * + * Use of these symbols is deprecated. + */ +#ifndef H5_NO_DEPRECATED_SYMBOLS + +/** + * \ingroup H5IUD + * + * \brief Creates and returns a new ID type + * + * \param[in] hash_size Minimum hash table size (in entries) used to store IDs + * for the new type (unused in 1.8.13 and later) + * \param[in] reserved Number of reserved IDs for the new type + * \param[in] free_func Function used to deallocate space for a single ID + * + * \return Returns the type identifier on success, negative on failure. + * + * \details H5Iregister_type() allocates space for a new ID type and returns an + * identifier for it. + * + * The \p hash_size parameter indicates the minimum size of the hash + * table used to store IDs in the new type. This parameter is unused + * in 1.8.13 and later, when the implementation of ID storage changed. + * + * The \p reserved parameter indicates the number of IDs in this new + * type to be reserved. Reserved IDs are valid IDs which are not + * associated with any storage within the library. + * + * The \p free_func parameter is a function pointer to a function + * which returns an herr_t and accepts a \c void*. The purpose of this + * function is to deallocate memory for a single ID. It will be called + * by H5Iclear_type() and H5Idestroy_type() on each ID. This function + * is NOT called by H5Iremove_verify(). The \c void* will be the same + * pointer which was passed in to the H5Iregister() function. The \p + * free_func function should return 0 on success and -1 on failure. + * + * \since 1.8.0 + * \deprecated 2.0.0 Deprecated in favor of the function H5Iregister_type2() + * + */ +H5_DLL H5I_type_t H5Iregister_type1(size_t hash_size, unsigned reserved, H5I_free_t free_func); + +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + #ifdef __cplusplus } #endif diff --git a/src/Makefile.am b/src/Makefile.am index a2166af110f..ae27987aa30 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -67,7 +67,7 @@ libhdf5_la_SOURCES= H5.c H5build_settings.c H5checksum.c H5dbg.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 \ - H5I.c H5Idbg.c H5Iint.c H5Itest.c \ + H5I.c H5Idbg.c H5Ideprec.c H5Iint.c H5Itest.c \ H5L.c H5Ldeprec.c H5Lexternal.c H5Lint.c \ H5M.c \ H5MF.c H5MFaggr.c H5MFdbg.c H5MFsection.c \ diff --git a/test/tid.c b/test/tid.c index c4ec0d8ea40..d003b77f9f5 100644 --- a/test/tid.c +++ b/test/tid.c @@ -79,7 +79,7 @@ basic_id_test(void) goto out; /* Register a type */ - myType = H5Iregister_type((size_t)64, 0, free_wrapper); + myType = H5Iregister_type(0, free_wrapper); CHECK(myType, H5I_BADID, "H5Iregister_type"); if (myType == H5I_BADID) @@ -173,7 +173,7 @@ basic_id_test(void) H5E_END_TRY /* Register another type and another object in that type */ - myType = H5Iregister_type((size_t)64, 0, free_wrapper); + myType = H5Iregister_type(0, free_wrapper); CHECK(myType, H5I_BADID, "H5Iregister_type"); if (myType == H5I_BADID) @@ -246,6 +246,225 @@ basic_id_test(void) return -1; } +#ifndef H5_NO_DEPRECATED_SYMBOLS +/* Test that H5Iregister_type1() works correctly (just a copy of the basic test) */ +static int +H5Iregister_type1_test(void) +{ + H5I_type_t myType = H5I_BADID; + hid_t arrayID = H5I_INVALID_HID; + void *testObj = NULL; + void *testPtr = NULL; + char nameString[10]; + hid_t testID; + ssize_t testSize = -1; + herr_t err; + int num_ref; + hsize_t num_members; + + /* Try to register an ID with fictitious types */ + H5E_BEGIN_TRY + arrayID = H5Iregister((H5I_type_t)420, testObj); + H5E_END_TRY + + VERIFY(arrayID, H5I_INVALID_HID, "H5Iregister"); + if (arrayID != H5I_INVALID_HID) + goto out; + + H5E_BEGIN_TRY + arrayID = H5Iregister((H5I_type_t)-1, testObj); + H5E_END_TRY + + VERIFY(arrayID, H5I_INVALID_HID, "H5Iregister"); + if (arrayID != H5I_INVALID_HID) + goto out; + + /* Try to access IDs with fictitious types */ + H5E_BEGIN_TRY + testPtr = H5Iobject_verify((hid_t)100, (H5I_type_t)0); + H5E_END_TRY + + CHECK_PTR_NULL(testPtr, "H5Iobject_verify"); + if (testPtr != NULL) + goto out; + + H5E_BEGIN_TRY + testPtr = H5Iobject_verify((hid_t)700, (H5I_type_t)700); + H5E_END_TRY + + CHECK_PTR_NULL(testPtr, "H5Iobject_verify"); + if (testPtr != NULL) + goto out; + + /* Register a type */ + myType = H5Iregister_type1(64, 0, free_wrapper); + + CHECK(myType, H5I_BADID, "H5Iregister_type1"); + if (myType == H5I_BADID) + goto out; + + /* Register an ID and retrieve the object it points to. + * Once the ID has been registered, testObj will be freed when + * its ID type is destroyed. + */ + testObj = malloc(7 * sizeof(int)); + arrayID = H5Iregister(myType, testObj); + + CHECK(arrayID, H5I_INVALID_HID, "H5Iregister"); + if (arrayID == H5I_INVALID_HID) { + free(testObj); + goto out; + } + + testPtr = (int *)H5Iobject_verify(arrayID, myType); + + CHECK_PTR_EQ(testPtr, testObj, "H5Iobject_verify"); + if (testPtr != testObj) + goto out; + + /* Ensure that H5Iget_file_id and H5Iget_name() fail, since this + * is an hid_t for the wrong kind of object + */ + H5E_BEGIN_TRY + testID = H5Iget_file_id(arrayID); + H5E_END_TRY + + VERIFY(testID, H5I_INVALID_HID, "H5Iget_file_id"); + if (testID != H5I_INVALID_HID) + goto out; + + H5E_BEGIN_TRY + testSize = H5Iget_name(arrayID, nameString, (size_t)9); + H5E_END_TRY + + VERIFY(testSize, -1, "H5Iget_name"); + if (testSize != -1) + goto out; + + /* Make sure H5Iremove_verify catches objects of the wrong type */ + H5E_BEGIN_TRY + testPtr = (int *)H5Iremove_verify(arrayID, (H5I_type_t)0); + H5E_END_TRY + + CHECK_PTR_NULL(testPtr, "H5Iremove_verify"); + if (testPtr != NULL) + goto out; + + H5E_BEGIN_TRY + testPtr = (int *)H5Iremove_verify(arrayID, (H5I_type_t)((int)myType - 1)); + H5E_END_TRY + + CHECK_PTR_NULL(testPtr, "H5Iremove_verify"); + if (testPtr != NULL) + goto out; + + /* Remove an ID and make sure we can't access it */ + testPtr = (int *)H5Iremove_verify(arrayID, myType); + + CHECK_PTR(testPtr, "H5Iremove_verify"); + if (testPtr == NULL) + goto out; + + H5E_BEGIN_TRY + testPtr = (int *)H5Iobject_verify(arrayID, myType); + H5E_END_TRY + + CHECK_PTR_NULL(testPtr, "H5Iobject_verify"); + if (testPtr != NULL) + goto out; + + /* Delete the type and make sure we can't access objects within it */ + arrayID = H5Iregister(myType, testObj); + + err = H5Idestroy_type(myType); + VERIFY(err, 0, "H5Idestroy_type"); + if (err != 0) + goto out; + VERIFY(H5Itype_exists(myType), 0, "H5Itype_exists"); + if (H5Itype_exists(myType) != 0) + goto out; + + H5E_BEGIN_TRY + VERIFY(H5Inmembers(myType, NULL), -1, "H5Inmembers"); + if (H5Inmembers(myType, NULL) != -1) + goto out; + H5E_END_TRY + + /* Register another type and another object in that type */ + myType = H5Iregister_type1(64, 0, free_wrapper); + + CHECK(myType, H5I_BADID, "H5Iregister_type1"); + if (myType == H5I_BADID) + goto out; + + /* The memory that testObj pointed to should already have been + * freed when the previous type was destroyed. Allocate new + * memory for it. + */ + testObj = malloc(7 * sizeof(int)); + arrayID = H5Iregister(myType, testObj); + + CHECK(arrayID, H5I_INVALID_HID, "H5Iregister"); + if (arrayID == H5I_INVALID_HID) { + free(testObj); + goto out; + } + + err = H5Inmembers(myType, &num_members); + CHECK(err, -1, "H5Inmembers"); + if (err < 0) + goto out; + VERIFY(num_members, 1, "H5Inmembers"); + if (num_members != 1) + goto out; + + /* Increment references to type and ensure that dec_type_ref + * doesn't destroy the type + */ + num_ref = H5Iinc_type_ref(myType); + VERIFY(num_ref, 2, "H5Iinc_type_ref"); + if (num_ref != 2) + goto out; + num_ref = H5Idec_type_ref(myType); + VERIFY(num_ref, 1, "H5Idec_type_ref"); + if (num_ref != 1) + goto out; + err = H5Inmembers(myType, &num_members); + CHECK(err, -1, "H5Inmembers"); + if (err < 0) + goto out; + VERIFY(num_members, 1, "H5Inmembers"); + if (num_members != 1) + goto out; + + /* This call to dec_type_ref should destroy the type */ + num_ref = H5Idec_type_ref(myType); + VERIFY(num_ref, 0, "H5Idec_type_ref"); + if (num_ref != 0) + goto out; + VERIFY(H5Itype_exists(myType), 0, "H5Itype_exists"); + if (H5Itype_exists(myType) != 0) + goto out; + + H5E_BEGIN_TRY + err = H5Inmembers(myType, &num_members); + if (err >= 0) + goto out; + H5E_END_TRY + + return 0; + +out: + /* Clean up type if it has been allocated and free memory used + * by testObj + */ + if (myType >= 0) + H5Idestroy_type(myType); + + return -1; +} +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + /* A dummy search function for the next test */ static int test_search_func(void H5_ATTR_UNUSED *ptr1, hid_t H5_ATTR_UNUSED id, void H5_ATTR_UNUSED *ptr2) @@ -508,7 +727,7 @@ test_id_type_list(void) H5I_type_t testType; int i; /* Just a counter variable */ - startType = H5Iregister_type((size_t)8, 0, free_wrapper); + startType = H5Iregister_type(0, free_wrapper); CHECK(startType, H5I_BADID, "H5Iregister_type"); if (startType == H5I_BADID) goto out; @@ -521,7 +740,7 @@ test_id_type_list(void) } /* Create types up to H5I_MAX_NUM_TYPES */ for (i = startType + 1; i < H5I_MAX_NUM_TYPES; i++) { - currentType = H5Iregister_type((size_t)8, 0, free_wrapper); + currentType = H5Iregister_type(0, free_wrapper); CHECK(currentType, H5I_BADID, "H5Iregister_type"); if (currentType == H5I_BADID) goto out; @@ -529,7 +748,7 @@ test_id_type_list(void) /* Wrap around to low type ID numbers */ for (i = H5I_NTYPES; i < startType; i++) { - currentType = H5Iregister_type((size_t)8, 0, free_wrapper); + currentType = H5Iregister_type(0, free_wrapper); CHECK(currentType, H5I_BADID, "H5Iregister_type"); if (currentType == H5I_BADID) goto out; @@ -537,7 +756,7 @@ test_id_type_list(void) /* There should be no room at the inn for a new ID type*/ H5E_BEGIN_TRY - testType = H5Iregister_type((size_t)8, 0, free_wrapper); + testType = H5Iregister_type(0, free_wrapper); H5E_END_TRY VERIFY(testType, H5I_BADID, "H5Iregister_type"); @@ -546,7 +765,7 @@ test_id_type_list(void) /* Now delete a type and try to insert again */ H5Idestroy_type(H5I_NTYPES); - testType = H5Iregister_type((size_t)8, 0, free_wrapper); + testType = H5Iregister_type(0, free_wrapper); VERIFY(testType, H5I_NTYPES, "H5Iregister_type"); if (testType != H5I_NTYPES) @@ -700,7 +919,7 @@ test_remove_clear_type(void) herr_t ret; /* return value */ /* Register a user-defined type with our custom ID-deleting callback */ - obj_type = H5Iregister_type((size_t)8, 0, rct_free_cb); + obj_type = H5Iregister_type(0, rct_free_cb); CHECK(obj_type, H5I_BADID, "H5Iregister_type"); if (obj_type == H5I_BADID) goto error; @@ -994,7 +1213,7 @@ test_future_ids(void) herr_t ret; /* Return value */ /* Register a user-defined type with our custom ID-deleting callback */ - obj_type = H5Iregister_type((size_t)15, 0, free_actual_object); + obj_type = H5Iregister_type(0, free_actual_object); CHECK(obj_type, H5I_BADID, "H5Iregister_type"); if (H5I_BADID == obj_type) goto error; @@ -1054,7 +1273,7 @@ test_future_ids(void) goto error; /* Re-register a user-defined type with our custom ID-deleting callback */ - obj_type = H5Iregister_type((size_t)15, 0, free_actual_object); + obj_type = H5Iregister_type(0, free_actual_object); CHECK(obj_type, H5I_BADID, "H5Iregister_type"); if (H5I_BADID == obj_type) goto error; @@ -1094,7 +1313,7 @@ test_future_ids(void) goto error; /* Re-register a user-defined type with our custom ID-deleting callback */ - obj_type = H5Iregister_type((size_t)15, 0, free_actual_object); + obj_type = H5Iregister_type(0, free_actual_object); CHECK(obj_type, H5I_BADID, "H5Iregister_type"); if (H5I_BADID == obj_type) goto error; @@ -1502,6 +1721,10 @@ test_ids(const void H5_ATTR_UNUSED *params) if (basic_id_test() < 0) TestErrPrintf("Basic ID test failed\n"); +#ifndef H5_NO_DEPRECATED_SYMBOLS + if (H5Iregister_type1_test() < 0) + TestErrPrintf("H5Iregister_type1() test failed\n"); +#endif /* H5_NO_DEPRECATED_SYMBOLS */ if (id_predefined_test() < 0) TestErrPrintf("Predefined ID type test failed\n"); if (test_is_valid() < 0) From be3e06d6ccb1930f3307cb7702153ee5be041af6 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Sat, 7 Dec 2024 22:04:39 -0800 Subject: [PATCH 02/14] Fixes make_vers to work with v200 * Update bin/make_vers to handle v200 * H5Iregister_type() --> H5Iregister_type2() The bin/make_vers script could still use some cleanup regarding the hash table / index magic, which seems over-complicated. Also, H5Iregister_type1/2 should have common code extracted. --- bin/make_vers | 75 ++++++++---- c++/src/C2Cppfunction_map.htm | 2 +- doxygen/examples/H5I_examples.c | 8 +- hl/src/H5PT.c | 6 +- src/H5I.c | 8 +- src/H5Ipublic.h | 6 +- src/H5vers.txt | 5 +- src/H5version.h | 211 +++++++++++++++++++++++++++++++- test/tid.c | 46 +++---- 9 files changed, 302 insertions(+), 65 deletions(-) diff --git a/bin/make_vers b/bin/make_vers index ba335cae27e..85a5ef2a602 100755 --- a/bin/make_vers +++ b/bin/make_vers @@ -4,13 +4,24 @@ use warnings; # Global settings # (The max_idx parameter is the only thing that needs to be changed when adding -# support for a new major release. If support for a prior major release -# is added (like support for 1.4, etc), the min_sup_idx parameter will -# need to be decremented.) +# support for a new major release. If support for a prior major release is +# added (like support for 1.4, etc), the min_sup_idx parameter will need to +# be decremented.) + +# Supported version strings. "16" = HDF5 1.6.0, "200" = HDF5 2.0.0, etc. +# Note that the scheme changed with 2.0.0, when we went to semantic versioning. +# We use 200 instead of 20 so that HDF5 11.0.0 will get 1100 instead of 110, +# which would conflict with HDF5 1.10. +@versions = ("16", "18", "110", "112", "114", "200"); # Max. library "index" (0 = v1.0, 1 = 1.2, 2 = 1.4, 3 = 1.6, 4 = 1.8, 5 = 1.10, 6 = 1.12, 7 = 1.14, 8 = 2.0, etc) $max_idx = 8; +# Last index where we used 1. for the version number (i.e., 1.14). This +# creates symbols with numbers like "114". After this version, the symbols have +# numbers like "200" (for v2.0.0). +$pre200_max_idx = 7; + # Min. supported previous library version "index" (0 = v1.0, 1 = 1.2, etc) $min_sup_idx = 3; @@ -91,9 +102,12 @@ sub print_checkoptions ($) { # Print the #ifdef print $fh "#if ("; - for $curr_idx ($min_sup_idx .. ($max_idx - 1)) { - print $fh "defined(H5_USE_1", ($curr_idx * 2), "_API)"; - if($curr_idx < ($max_idx - 1)) { + $curr_idx = 0; + foreach my $api_vers (@versions) { + print $fh "defined(H5_USE_", $api_vers, "_API)"; + + $curr_idx++; + if($curr_idx < @versions) { print $fh " || "; } } @@ -104,9 +118,12 @@ sub print_checkoptions ($) { # Print the #endif print $fh "#endif /* ("; - for $curr_idx ($min_sup_idx .. ($max_idx - 1)) { - print $fh "defined(H5_USE_1", ($curr_idx * 2), "_API)"; - if($curr_idx < ($max_idx - 1)) { + $curr_idx = 0; + foreach my $api_vers (@versions) { + print $fh "defined(H5_USE_", $api_vers, "_API)"; + + $curr_idx++; + if($curr_idx < @versions) { print $fh " || "; } } @@ -118,7 +135,6 @@ sub print_checkoptions ($) { # sub print_globalapidefvers ($) { my $fh = shift; # File handle for output file - my $curr_idx; # Current API version index # Print the descriptive comment print $fh "\n\n/* If a particular default \"global\" version of the library's interfaces is\n"; @@ -126,13 +142,13 @@ sub print_globalapidefvers ($) { print $fh " *\n"; print $fh " */\n"; - for $curr_idx ($min_sup_idx .. ($max_idx - 1)) { + for my $api_vers (@versions) { # Print API version ifdef - print $fh "\n#if defined(H5_USE_1", ($curr_idx * 2), "_API_DEFAULT) && !defined(H5_USE_1", ($curr_idx * 2), "_API)\n"; + print $fh "\n#if defined(H5_USE_", $api_vers, "_API_DEFAULT) && !defined(H5_USE_", $api_vers, "_API)\n"; # Print API version definition - print $fh " " x $indent, "#define H5_USE_1", ($curr_idx * 2), "_API 1\n"; + print $fh " " x $indent, "#define H5_USE_", $api_vers, "_API 1\n"; # Print API version endif - print $fh "#endif /* H5_USE_1", ($curr_idx * 2), "_API_DEFAULT && !H5_USE_1", ($curr_idx * 2), "_API */\n"; + print $fh "#endif /* H5_USE_", $api_vers, "_API_DEFAULT && !H5_USE_", $api_vers, "_API */\n"; } } @@ -152,9 +168,17 @@ sub print_globalapisymbolvers ($) { print $fh " */\n"; # Loop over supported older library APIs and define the appropriate macros - for $curr_idx ($min_sup_idx .. ($max_idx - 1)) { + for $curr_idx ($min_sup_idx .. $max_idx) { + # Get the API version string from the index + my $api_vers; + if ($curr_idx <= $pre200_max_idx) { + $api_vers = "1" . ($curr_idx * 2); + } else { + $api_vers = (1 + $curr_idx - $pre200_max_idx) * 100; + } + # Print API version ifdef - print $fh "\n#ifdef H5_USE_1", ($curr_idx * 2), "_API\n"; + print $fh "\n#ifdef H5_USE_", $api_vers, "_API\n"; # Print the version macro info for each function that is defined for # this API version @@ -179,7 +203,7 @@ sub print_globalapisymbolvers ($) { } # Print API version endif - print $fh "\n#endif /* H5_USE_1", ($curr_idx * 2), "_API */\n"; + print $fh "\n#endif /* H5_USE_", $api_vers, "_API */\n"; } } @@ -301,7 +325,7 @@ sub parse_line ($) { my $line = shift; # Get the line to parse # Parse API function lines -#print "line=$line\n"; +#print "line=$line"; if($line =~ /^\s*FUNCTION:/ || $line =~ /^\s*TYPEDEF:/) { my $name; # The name of the function my $params; # Typedefs for function parameters @@ -361,7 +385,7 @@ sub parse_line ($) { # (the default api version for 1.12). Allowing a v111 entry and # incrementing its index 13 lines below allows a version 2 that is # never accessed via the H5O function macros. - if(!( $_ =~ /v1[02468]/ || $_ =~ /v11[02468]/ || $_ =~ /v111/ )) { + if(!( $_ =~ /v1[02468]/ || $_ =~ /v11[02468]/ || $_ =~ /v111/ || $_ =~ /v200/ )) { die "bad version information: $name"; } if(exists($sym_versions{$_})) { @@ -373,11 +397,15 @@ sub parse_line ($) { #print "parse_line: _=$_\n"; # Get the index of the version - ($vers_idx) = ($_ =~ /v1(\d+)/); - if($vers_idx == 11) { - $vers_idx++; + if (($vers_idx) = ($_ =~ /v1(\d+)/)) { + if($vers_idx == 11) { + $vers_idx++; + } + $vers_idx /= 2; + } else { + ($vers_idx) = ($_ =~ /v(\d+)/); + $vers_idx = ($vers_idx / 100) + ($pre200_max_idx - 1); } - $vers_idx /= 2; #print "parse_line: vers_idx='$vers_idx'\n"; push(@vers_nums, $vers_idx); } @@ -444,6 +472,7 @@ sub parse_line ($) { } else { die "unknown line type: $line"; } +#print "\n"; } # Unknown keyword else { diff --git a/c++/src/C2Cppfunction_map.htm b/c++/src/C2Cppfunction_map.htm index 4ea67544efe..791892ee006 100644 --- a/c++/src/C2Cppfunction_map.htm +++ b/c++/src/C2Cppfunction_map.htm @@ -9992,7 +9992,7 @@ none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; padding:0in 5.4pt 0in 5.4pt'>

H5Iregister_type

+ normal'>H5Iregister_type2

= H5I_MAX_NUM_TYPES || startType < H5I_NTYPES) { /* Error condition, throw an error */ - ERROR("H5Iregister_type"); + ERROR("H5Iregister_type2"); goto out; } /* Create types up to H5I_MAX_NUM_TYPES */ for (i = startType + 1; i < H5I_MAX_NUM_TYPES; i++) { - currentType = H5Iregister_type(0, free_wrapper); - CHECK(currentType, H5I_BADID, "H5Iregister_type"); + currentType = H5Iregister_type2(0, free_wrapper); + CHECK(currentType, H5I_BADID, "H5Iregister_type2"); if (currentType == H5I_BADID) goto out; } /* Wrap around to low type ID numbers */ for (i = H5I_NTYPES; i < startType; i++) { - currentType = H5Iregister_type(0, free_wrapper); - CHECK(currentType, H5I_BADID, "H5Iregister_type"); + currentType = H5Iregister_type2(0, free_wrapper); + CHECK(currentType, H5I_BADID, "H5Iregister_type2"); if (currentType == H5I_BADID) goto out; } /* There should be no room at the inn for a new ID type*/ H5E_BEGIN_TRY - testType = H5Iregister_type(0, free_wrapper); + testType = H5Iregister_type2(0, free_wrapper); H5E_END_TRY - VERIFY(testType, H5I_BADID, "H5Iregister_type"); + VERIFY(testType, H5I_BADID, "H5Iregister_type2"); if (testType != H5I_BADID) goto out; /* Now delete a type and try to insert again */ H5Idestroy_type(H5I_NTYPES); - testType = H5Iregister_type(0, free_wrapper); + testType = H5Iregister_type2(0, free_wrapper); - VERIFY(testType, H5I_NTYPES, "H5Iregister_type"); + VERIFY(testType, H5I_NTYPES, "H5Iregister_type2"); if (testType != H5I_NTYPES) goto out; @@ -919,8 +919,8 @@ test_remove_clear_type(void) herr_t ret; /* return value */ /* Register a user-defined type with our custom ID-deleting callback */ - obj_type = H5Iregister_type(0, rct_free_cb); - CHECK(obj_type, H5I_BADID, "H5Iregister_type"); + obj_type = H5Iregister_type2(0, rct_free_cb); + CHECK(obj_type, H5I_BADID, "H5Iregister_type2"); if (obj_type == H5I_BADID) goto error; @@ -1213,8 +1213,8 @@ test_future_ids(void) herr_t ret; /* Return value */ /* Register a user-defined type with our custom ID-deleting callback */ - obj_type = H5Iregister_type(0, free_actual_object); - CHECK(obj_type, H5I_BADID, "H5Iregister_type"); + obj_type = H5Iregister_type2(0, free_actual_object); + CHECK(obj_type, H5I_BADID, "H5Iregister_type2"); if (H5I_BADID == obj_type) goto error; @@ -1273,8 +1273,8 @@ test_future_ids(void) goto error; /* Re-register a user-defined type with our custom ID-deleting callback */ - obj_type = H5Iregister_type(0, free_actual_object); - CHECK(obj_type, H5I_BADID, "H5Iregister_type"); + obj_type = H5Iregister_type2(0, free_actual_object); + CHECK(obj_type, H5I_BADID, "H5Iregister_type2"); if (H5I_BADID == obj_type) goto error; @@ -1313,8 +1313,8 @@ test_future_ids(void) goto error; /* Re-register a user-defined type with our custom ID-deleting callback */ - obj_type = H5Iregister_type(0, free_actual_object); - CHECK(obj_type, H5I_BADID, "H5Iregister_type"); + obj_type = H5Iregister_type2(0, free_actual_object); + CHECK(obj_type, H5I_BADID, "H5Iregister_type2"); if (H5I_BADID == obj_type) goto error; From bfb50581f11f18818e3655048391c7adecbd140d Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Sat, 7 Dec 2024 22:24:35 -0800 Subject: [PATCH 03/14] Extract common H5Iregister_type1/2 functionality --- src/H5I.c | 58 ++++------------------------------------ src/H5Ideprec.c | 51 ++--------------------------------- src/H5Iint.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++ src/H5Ipkg.h | 1 + 4 files changed, 78 insertions(+), 102 deletions(-) diff --git a/src/H5I.c b/src/H5I.c index ba63dbb5a89..201a6fb8e83 100644 --- a/src/H5I.c +++ b/src/H5I.c @@ -79,10 +79,9 @@ static int H5I__iterate_pub_cb(void *obj, hid_t id, void *udata); * of ID's to give out. A specific number (RESERVED) of type * entries may be reserved to enable "constant" values to be handed * out which are valid IDs in the type, but which do not map to any - * data structures and are not allocated dynamically later. HASH_SIZE is - * the minimum hash table size to use for the type. FREE_FUNC is - * called with an object pointer when the object is removed from - * the type. + * data structures and are not allocated dynamically later. + * FREE_FUNC is called with an object pointer when the object is + * removed from the type. * * Return: Success: Type ID of the new type * Failure: H5I_BADID @@ -92,61 +91,14 @@ static int H5I__iterate_pub_cb(void *obj, hid_t id, void *udata); H5I_type_t H5Iregister_type2(unsigned reserved, H5I_free_t free_func) { - H5I_class_t *cls = NULL; /* New ID class */ - H5I_type_t new_type = H5I_BADID; /* New ID type value */ - H5I_type_t ret_value = H5I_BADID; /* Return value */ + H5I_type_t ret_value = H5I_BADID; FUNC_ENTER_API(H5I_BADID) - /* Generate a new H5I_type_t value */ - - /* Increment the number of types */ - if (H5I_next_type_g < H5I_MAX_NUM_TYPES) { - new_type = (H5I_type_t)H5I_next_type_g; - H5I_next_type_g++; - } - else { - bool done; /* Indicate that search was successful */ - int i; - - /* Look for a free type to give out */ - done = false; - for (i = H5I_NTYPES; i < H5I_MAX_NUM_TYPES && done == false; i++) { - if (NULL == H5I_type_info_array_g[i]) { - /* Found a free type ID */ - new_type = (H5I_type_t)i; - done = true; - } - } - - /* Verify that we found a type to give out */ - if (done == false) - HGOTO_ERROR(H5E_ID, H5E_NOSPACE, H5I_BADID, "Maximum number of ID types exceeded"); - } - - /* Allocate new ID class */ - if (NULL == (cls = H5MM_calloc(sizeof(H5I_class_t)))) - HGOTO_ERROR(H5E_ID, H5E_CANTALLOC, H5I_BADID, "ID class allocation failed"); - - /* Initialize class fields */ - cls->type = new_type; - cls->flags = H5I_CLASS_IS_APPLICATION; - cls->reserved = reserved; - cls->free_func = free_func; - - /* Register the new ID class */ - if (H5I_register_type(cls) < 0) + if (H5I_BADID == (ret_value = H5I__register_type_common(reserved, free_func))) HGOTO_ERROR(H5E_ID, H5E_CANTINIT, H5I_BADID, "can't initialize ID class"); - /* Set return value */ - ret_value = new_type; - done: - /* Clean up on error */ - if (ret_value < 0) - if (cls) - cls = H5MM_xfree(cls); - FUNC_LEAVE_API(ret_value) } /* end H5Iregister_type2() */ diff --git a/src/H5Ideprec.c b/src/H5Ideprec.c index 5d88f4acd95..a174a1137aa 100644 --- a/src/H5Ideprec.c +++ b/src/H5Ideprec.c @@ -84,61 +84,14 @@ H5I_type_t H5Iregister_type1(size_t H5_ATTR_UNUSED hash_size, unsigned reserved, H5I_free_t free_func) { - H5I_class_t *cls = NULL; /* New ID class */ - H5I_type_t new_type = H5I_BADID; /* New ID type value */ - H5I_type_t ret_value = H5I_BADID; /* Return value */ + H5I_type_t ret_value = H5I_BADID; FUNC_ENTER_API(H5I_BADID) - /* Generate a new H5I_type_t value */ - - /* Increment the number of types */ - if (H5I_next_type_g < H5I_MAX_NUM_TYPES) { - new_type = (H5I_type_t)H5I_next_type_g; - H5I_next_type_g++; - } - else { - bool done; /* Indicate that search was successful */ - int i; - - /* Look for a free type to give out */ - done = false; - for (i = H5I_NTYPES; i < H5I_MAX_NUM_TYPES && done == false; i++) { - if (NULL == H5I_type_info_array_g[i]) { - /* Found a free type ID */ - new_type = (H5I_type_t)i; - done = true; - } - } - - /* Verify that we found a type to give out */ - if (done == false) - HGOTO_ERROR(H5E_ID, H5E_NOSPACE, H5I_BADID, "Maximum number of ID types exceeded"); - } - - /* Allocate new ID class */ - if (NULL == (cls = H5MM_calloc(sizeof(H5I_class_t)))) - HGOTO_ERROR(H5E_ID, H5E_CANTALLOC, H5I_BADID, "ID class allocation failed"); - - /* Initialize class fields */ - cls->type = new_type; - cls->flags = H5I_CLASS_IS_APPLICATION; - cls->reserved = reserved; - cls->free_func = free_func; - - /* Register the new ID class */ - if (H5I_register_type(cls) < 0) + if (H5I_BADID == (ret_value = H5I__register_type_common(reserved, free_func))) HGOTO_ERROR(H5E_ID, H5E_CANTINIT, H5I_BADID, "can't initialize ID class"); - /* Set return value */ - ret_value = new_type; - done: - /* Clean up on error */ - if (ret_value < 0) - if (cls) - cls = H5MM_xfree(cls); - FUNC_LEAVE_API(ret_value) } /* end H5Iregister_type1() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ diff --git a/src/H5Iint.c b/src/H5Iint.c index 785dd9f0e86..21c4bfc280a 100644 --- a/src/H5Iint.c +++ b/src/H5Iint.c @@ -156,6 +156,76 @@ H5I_term_package(void) FUNC_LEAVE_NOAPI(in_use) } /* end H5I_term_package() */ +/*------------------------------------------------------------------------- + * Function: H5I__register_type_common + * + * Purpose: Common functionality for H5Iregister_type(1|2) + * + * Return: Success: Type ID of the new type + * Failure: H5I_BADID + *------------------------------------------------------------------------- + */ +H5I_type_t +H5I__register_type_common(unsigned reserved, H5I_free_t free_func) +{ + H5I_class_t *cls = NULL; /* New ID class */ + H5I_type_t new_type = H5I_BADID; /* New ID type value */ + H5I_type_t ret_value = H5I_BADID; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Generate a new H5I_type_t value */ + + /* Increment the number of types */ + if (H5I_next_type_g < H5I_MAX_NUM_TYPES) { + new_type = (H5I_type_t)H5I_next_type_g; + H5I_next_type_g++; + } + else { + bool done; /* Indicate that search was successful */ + int i; + + /* Look for a free type to give out */ + done = false; + for (i = H5I_NTYPES; i < H5I_MAX_NUM_TYPES && done == false; i++) { + if (NULL == H5I_type_info_array_g[i]) { + /* Found a free type ID */ + new_type = (H5I_type_t)i; + done = true; + } + } + + /* Verify that we found a type to give out */ + if (done == false) + HGOTO_ERROR(H5E_ID, H5E_NOSPACE, H5I_BADID, "Maximum number of ID types exceeded"); + } + + /* Allocate new ID class */ + if (NULL == (cls = H5MM_calloc(sizeof(H5I_class_t)))) + HGOTO_ERROR(H5E_ID, H5E_CANTALLOC, H5I_BADID, "ID class allocation failed"); + + /* Initialize class fields */ + cls->type = new_type; + cls->flags = H5I_CLASS_IS_APPLICATION; + cls->reserved = reserved; + cls->free_func = free_func; + + /* Register the new ID class */ + if (H5I_register_type(cls) < 0) + HGOTO_ERROR(H5E_ID, H5E_CANTINIT, H5I_BADID, "can't initialize ID class"); + + /* Set return value */ + ret_value = new_type; + +done: + /* Clean up on error */ + if (ret_value == H5I_BADID) + if (cls) + cls = H5MM_xfree(cls); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I__register_type_common() */ + /*------------------------------------------------------------------------- * Function: H5I_register_type * diff --git a/src/H5Ipkg.h b/src/H5Ipkg.h index 852ab151dc5..5393c3d2b39 100644 --- a/src/H5Ipkg.h +++ b/src/H5Ipkg.h @@ -106,6 +106,7 @@ H5_DLLVAR int H5I_next_type_g; H5_DLL hid_t H5I__register(H5I_type_t type, const void *object, bool app_ref, H5I_future_realize_func_t realize_cb, H5I_future_discard_func_t discard_cb); +H5_DLL H5I_type_t H5I__register_type_common(unsigned reserved, H5I_free_t free_func); H5_DLL int H5I__destroy_type(H5I_type_t type); H5_DLL void *H5I__remove_verify(hid_t id, H5I_type_t type); H5_DLL int H5I__inc_type_ref(H5I_type_t type); From 2b8c39bc68335686ae99be72c9caae1ea1af912b Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Sun, 8 Dec 2024 01:44:37 -0800 Subject: [PATCH 04/14] Move line validation code to a new function --- bin/make_vers | 86 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 53 insertions(+), 33 deletions(-) diff --git a/bin/make_vers b/bin/make_vers index 85a5ef2a602..3f95b7ac1f5 100755 --- a/bin/make_vers +++ b/bin/make_vers @@ -317,6 +317,58 @@ sub print_endprotect ($$) { print $fh "#endif /* ${file}_H */\n\n"; } +############################################################################## +# Validate a line from H5vers.txt +# +sub validate_line { + my $name = $_[0]; + my $params = $_[1]; + my $vers = $_[2]; + + my @vers_list; # Version strings ("v18", etc.) + my %sym_versions; # Versions already seen (for duplicate checks) + + # Check if the name already exists in the list of symbols + if(exists($functions{$name}) || exists($typedefs{$name})) { + die "duplicated symbol: $name"; + } + + # Check for no version info given + if($vers eq "") { + die "no version information: $name"; + } + + # Separate the versions on commas (produces string elements like "v18") + @vers_list = split(/\s*,\s*/, $vers); + + # Check for invalid version data + foreach(@vers_list) { + # Note: v111 is allowed because H5O functions were prematurely versioned + # in HDF5 1.10. Because users were affected by this, the versioning + # was rescinded but the H5O version 2 functions were kept to be + # called directly. Now that the version macros are added in 1.12, + # along with a 3rd version of the H5O functions, the H5O function + # version for default api=v110 should be version 1 to work correctly + # with 1.10 applications that were using unversioned H5O functions, + # and the H5O function version should be version 3 for default api=v112 + # (the default api version for 1.12). Allowing a v111 entry and + # incrementing its index 13 lines below allows a version 2 that is + # never accessed via the H5O function macros. + if(!( $_ =~ /v1[02468]/ || $_ =~ /v11[02468]/ || $_ =~ /v111/ || $_ =~ /v200/ )) { + die "bad version information: $name"; + } + + # Make sure we didn't specify duplicate versions on this line + if(exists($sym_versions{$_})) { + die "duplicate version information: $name"; + } + + # Store the versions for the function in a local hash table, indexed by the version + # (this is only used to check for duplicates) + $sym_versions{$_}=$_; + } +} + ############################################################################## # Parse a meaningful line (not a comment or blank line) into the appropriate # data structure @@ -333,7 +385,6 @@ sub parse_line ($) { my @vers_list; # Version info, as a list my @vers_nums; # Version info, as a numeric list my $num_versions; # Number of versions for function - my %sym_versions; # Versions for a symbol my $last_idx; # The previous version index seen for a function my $last_vers; # The previous version # seen for a function my $line_type; # Type of line we are parsing @@ -355,15 +406,7 @@ sub parse_line ($) { #print "parse_line: line_type='$line_type'\n"; - # Check if the name already exists in the list of symbols - if(exists($functions{$name}) || exists($typedefs{$name})) { - die "duplicated symbol: $name"; - } - - # Check for no version info given - if($vers eq "") { - die "no version information: $name"; - } + validate_line($name, $params, $vers); # Split up version info @vers_list = split(/\s*,\s*/, $vers); @@ -373,28 +416,6 @@ sub parse_line ($) { foreach(@vers_list) { my $vers_idx; # Index of version in array - # Do some validation on the input - # Note: v111 is allowed because H5O functions were prematurely versioned - # in HDF5 1.10. Because users were affected by this, the versioning - # was rescinded but the H5O version 2 functions were kept to be - # called directly. Now that the version macros are added in 1.12, - # along with a 3rd version of the H5O functions, the H5O function - # version for default api=v110 should be version 1 to work correctly - # with 1.10 applications that were using unversioned H5O functions, - # and the H5O function version should be version 3 for default api=v112 - # (the default api version for 1.12). Allowing a v111 entry and - # incrementing its index 13 lines below allows a version 2 that is - # never accessed via the H5O function macros. - if(!( $_ =~ /v1[02468]/ || $_ =~ /v11[02468]/ || $_ =~ /v111/ || $_ =~ /v200/ )) { - die "bad version information: $name"; - } - if(exists($sym_versions{$_})) { - die "duplicate version information: $name"; - } - - # Store the versions for the function in a local hash table, indexed by the version - $sym_versions{$_}=$_; - #print "parse_line: _=$_\n"; # Get the index of the version if (($vers_idx) = ($_ =~ /v1(\d+)/)) { @@ -411,7 +432,6 @@ sub parse_line ($) { } #print "parse_line: vers_nums=(@vers_nums)\n"; - # Check for invalid version info given $last_idx = -1; $last_vers = 1; foreach(sort(@vers_nums)) { From f0790e4dd4180b86f436d275865e22f8eb1f4573 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Sun, 8 Dec 2024 01:54:04 -0800 Subject: [PATCH 05/14] Added global definitions to avoid mysteries --- bin/make_vers | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/bin/make_vers b/bin/make_vers index 3f95b7ac1f5..57dd2246ea3 100755 --- a/bin/make_vers +++ b/bin/make_vers @@ -28,6 +28,21 @@ $min_sup_idx = 3; # Number of spaces to indent preprocessor commands inside ifdefs $indent = 2; +# Global hash of functions ==> # symbol versions parsed from H5vers.txt +$functions = {}; + +# Global hash of functions ==> versioned function params parsed from H5vers.txt +$func_params = {}; + +# Global hash of typedefs ==> # symbol versions parsed from H5vers.txt +$typedefs = {}; + +# Array of {func name ==> symbol version} hashes. One hash per API version. +@func_vers = map { {} } 1..($max_idx + 1); + +# Array of {type name ==> symbol version} hashes. One hash per API version. +@type_vers = map { {} } 1..($max_idx + 1); + # # Copyright by The HDF Group. # All rights reserved. From 7597e8e0d1154685add383f31585de31cfc0409c Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Sun, 8 Dec 2024 03:09:00 -0800 Subject: [PATCH 06/14] Clean up make_vers Replaces the overly complicated file parse with something a LOT simpler. --- bin/make_vers | 213 ++++++++++++++++---------------------------------- 1 file changed, 69 insertions(+), 144 deletions(-) diff --git a/bin/make_vers b/bin/make_vers index 57dd2246ea3..9acf0a9f4d2 100755 --- a/bin/make_vers +++ b/bin/make_vers @@ -3,28 +3,17 @@ require 5.003; use warnings; # Global settings -# (The max_idx parameter is the only thing that needs to be changed when adding -# support for a new major release. If support for a prior major release is -# added (like support for 1.4, etc), the min_sup_idx parameter will need to -# be decremented.) # Supported version strings. "16" = HDF5 1.6.0, "200" = HDF5 2.0.0, etc. +# # Note that the scheme changed with 2.0.0, when we went to semantic versioning. # We use 200 instead of 20 so that HDF5 11.0.0 will get 1100 instead of 110, # which would conflict with HDF5 1.10. +# +# Also, note that this scheme started at the 1.6/1.8 transition, so earlier +# versions of the API aren't versioned. @versions = ("16", "18", "110", "112", "114", "200"); -# Max. library "index" (0 = v1.0, 1 = 1.2, 2 = 1.4, 3 = 1.6, 4 = 1.8, 5 = 1.10, 6 = 1.12, 7 = 1.14, 8 = 2.0, etc) -$max_idx = 8; - -# Last index where we used 1. for the version number (i.e., 1.14). This -# creates symbols with numbers like "114". After this version, the symbols have -# numbers like "200" (for v2.0.0). -$pre200_max_idx = 7; - -# Min. supported previous library version "index" (0 = v1.0, 1 = 1.2, etc) -$min_sup_idx = 3; - # Number of spaces to indent preprocessor commands inside ifdefs $indent = 2; @@ -37,11 +26,25 @@ $func_params = {}; # Global hash of typedefs ==> # symbol versions parsed from H5vers.txt $typedefs = {}; -# Array of {func name ==> symbol version} hashes. One hash per API version. -@func_vers = map { {} } 1..($max_idx + 1); +# Hash of API versions to a hash of (API call name --> symbol version) +# +# There is one hash for each version in @versions and the (API call name +# --> symbol version) hash maps an API name like H5Dopen to the symbol version +# (e.g. H5Dopen --> 1 or 2). +# +# So... +# +# 200 --> {H5Dopen --> 2, H5Iregister_type --> 2, etc.} +my %api_vers_to_function_vers; +foreach my $key (@versions) { + $api_vers_to_function_vers{$key} = {}; +} -# Array of {type name ==> symbol version} hashes. One hash per API version. -@type_vers = map { {} } 1..($max_idx + 1); +# Hash of API versions to a hash of (typedef name --> symbol version) +my %api_vers_to_type_vers; +foreach my $key (@versions) { + $api_vers_to_type_vers{$key} = {}; +} # # Copyright by The HDF Group. @@ -122,7 +125,7 @@ sub print_checkoptions ($) { print $fh "defined(H5_USE_", $api_vers, "_API)"; $curr_idx++; - if($curr_idx < @versions) { + if ($curr_idx < @versions) { print $fh " || "; } } @@ -138,7 +141,7 @@ sub print_checkoptions ($) { print $fh "defined(H5_USE_", $api_vers, "_API)"; $curr_idx++; - if($curr_idx < @versions) { + if ($curr_idx < @versions) { print $fh " || "; } } @@ -183,15 +186,7 @@ sub print_globalapisymbolvers ($) { print $fh " */\n"; # Loop over supported older library APIs and define the appropriate macros - for $curr_idx ($min_sup_idx .. $max_idx) { - # Get the API version string from the index - my $api_vers; - if ($curr_idx <= $pre200_max_idx) { - $api_vers = "1" . ($curr_idx * 2); - } else { - $api_vers = (1 + $curr_idx - $pre200_max_idx) * 100; - } - + foreach my $api_vers (@versions) { # Print API version ifdef print $fh "\n#ifdef H5_USE_", $api_vers, "_API\n"; @@ -200,9 +195,9 @@ sub print_globalapisymbolvers ($) { print $fh "\n/*************/\n"; print $fh "/* Functions */\n"; print $fh "/*************/\n"; - for $name (sort keys %{$func_vers[$curr_idx]}) { + for $name (sort keys %{$api_vers_to_function_vers{$api_vers}}) { print $fh "\n#if !defined(", $name, "_vers)\n"; - print $fh " " x $indent, "#define ", $name, "_vers $func_vers[$curr_idx]{$name}\n"; + print $fh " " x $indent, "#define ", $name, "_vers $api_vers_to_function_vers{$api_vers}{$name}\n"; print $fh "#endif /* !defined(", $name, "_vers) */\n"; } @@ -211,9 +206,9 @@ sub print_globalapisymbolvers ($) { print $fh "\n/************/\n"; print $fh "/* Typedefs */\n"; print $fh "/************/\n"; - for $name (sort keys %{$type_vers[$curr_idx]}) { + for $name (sort keys %{$api_vers_to_type_vers{$api_vers}}) { print $fh "\n#if !defined(", $name, "_t_vers)\n"; - print $fh " " x $indent, "#define ", $name, "_t_vers $type_vers[$curr_idx]{$name}\n"; + print $fh " " x $indent, "#define ", $name, "_t_vers $api_vers_to_type_vers{$api_vers}{$name}\n"; print $fh "#endif /* !defined(", $name, "_t_vers) */\n"; } @@ -261,7 +256,7 @@ sub print_defaultapivers ($) { print $fh " " x $indent, "#define $curr_name $curr_name$curr_vers\n"; # Print function's dependent parameter types - foreach(sort(@param_list)) { + foreach (sort (@param_list)) { print $fh " " x $indent, "#define ${_}_t $_${curr_vers}_t\n"; } @@ -272,7 +267,7 @@ sub print_defaultapivers ($) { print $fh " " x $indent, "#define $curr_name $curr_name$curr_vers\n"; # Print function's dependent parameter types - foreach(sort(@param_list)) { + foreach (sort (@param_list)) { print $fh " " x $indent, "#define ${_}_t $_${curr_vers}_t\n"; } @@ -306,7 +301,7 @@ sub print_defaultapivers ($) { # Loop to print earlier version name mappings $curr_vers--; - while($curr_vers > 0) { + while ($curr_vers > 0) { print $fh "#elif $curr_vers_name == $curr_vers\n"; print $fh " " x $indent, "#define ${curr_name}_t $curr_name${curr_vers}_t\n"; $curr_vers--; @@ -344,20 +339,20 @@ sub validate_line { my %sym_versions; # Versions already seen (for duplicate checks) # Check if the name already exists in the list of symbols - if(exists($functions{$name}) || exists($typedefs{$name})) { + if (exists ($functions{$name}) || exists($typedefs{$name})) { die "duplicated symbol: $name"; } # Check for no version info given - if($vers eq "") { + if ($vers eq "") { die "no version information: $name"; } # Separate the versions on commas (produces string elements like "v18") - @vers_list = split(/\s*,\s*/, $vers); + @vers_list = split (/\s*,\s*/, $vers); # Check for invalid version data - foreach(@vers_list) { + foreach (@vers_list) { # Note: v111 is allowed because H5O functions were prematurely versioned # in HDF5 1.10. Because users were affected by this, the versioning # was rescinded but the H5O version 2 functions were kept to be @@ -369,12 +364,12 @@ sub validate_line { # (the default api version for 1.12). Allowing a v111 entry and # incrementing its index 13 lines below allows a version 2 that is # never accessed via the H5O function macros. - if(!( $_ =~ /v1[02468]/ || $_ =~ /v11[02468]/ || $_ =~ /v111/ || $_ =~ /v200/ )) { + if (!( $_ =~ /v1[02468]/ || $_ =~ /v11[02468]/ || $_ =~ /v111/ || $_ =~ /v200/ )) { die "bad version information: $name"; } # Make sure we didn't specify duplicate versions on this line - if(exists($sym_versions{$_})) { + if (exists($sym_versions{$_})) { die "duplicate version information: $name"; } @@ -393,119 +388,64 @@ sub parse_line ($) { # Parse API function lines #print "line=$line"; - if($line =~ /^\s*FUNCTION:/ || $line =~ /^\s*TYPEDEF:/) { + if ($line =~ /^\s*FUNCTION:/ || $line =~ /^\s*TYPEDEF:/) { my $name; # The name of the function my $params; # Typedefs for function parameters - my $vers; # The version info for the function - my @vers_list; # Version info, as a list - my @vers_nums; # Version info, as a numeric list - my $num_versions; # Number of versions for function - my $last_idx; # The previous version index seen for a function - my $last_vers; # The previous version # seen for a function + my $vers_string; # The version info for the function + my @vers_list; # Version info, as a list (e.g., "112", "200", etc. my $line_type; # Type of line we are parsing # Determine the type of the line to parse - if($line =~ /^\s*FUNCTION:/) { + if ($line =~ /^\s*FUNCTION:/) { $line_type = 1; # Get the function's name & version info - ($name, $params, $vers) = ($line =~ /^\s*FUNCTION:\s*(\w*);\s*(.*?)\s*;\s*(.*?)\s*$/); -#print "parse_line: name='$name', params='$params', vers='$vers'\n"; + ($name, $params, $vers_string) = ($line =~ /^\s*FUNCTION:\s*(\w*);\s*(.*?)\s*;\s*(.*?)\s*$/); +#print "parse_line: name='$name', params='$params', vers_string='$vers_string'\n"; } - elsif($line =~ /^\s*TYPEDEF:/) { + elsif ($line =~ /^\s*TYPEDEF:/) { $line_type = 2; # Get the typedefs's name & version info - ($name, $vers) = ($line =~ /^\s*TYPEDEF:\s*(\w*);\s*(.*?)\s*$/); -#print "parse_line: name='$name', vers='$vers'\n"; + ($name, $vers_string) = ($line =~ /^\s*TYPEDEF:\s*(\w*);\s*(.*?)\s*$/); +#print "parse_line: name='$name', vers_string='$vers_string'\n"; + } else { + die "unknown line type: $line"; } #print "parse_line: line_type='$line_type'\n"; + validate_line($name, $params, $vers_string); - validate_line($name, $params, $vers); - - # Split up version info - @vers_list = split(/\s*,\s*/, $vers); + # Split the version info and strip off the leading "v" + @vers_list = split(/\s*,\s*/, $vers_string); + @vers_list = map { substr($_, 1) } @vers_list; #print "parse_line: vers_list=(@vers_list)\n"; - # Parse the version list into numbers, checking for invalid input - foreach(@vers_list) { - my $vers_idx; # Index of version in array - -#print "parse_line: _=$_\n"; - # Get the index of the version - if (($vers_idx) = ($_ =~ /v1(\d+)/)) { - if($vers_idx == 11) { - $vers_idx++; - } - $vers_idx /= 2; - } else { - ($vers_idx) = ($_ =~ /v(\d+)/); - $vers_idx = ($vers_idx / 100) + ($pre200_max_idx - 1); - } -#print "parse_line: vers_idx='$vers_idx'\n"; - push(@vers_nums, $vers_idx); - } -#print "parse_line: vers_nums=(@vers_nums)\n"; - - $last_idx = -1; - $last_vers = 1; - foreach(sort(@vers_nums)) { -#print "parse_line: _=$_ last_idx='$last_idx'\n"; - # Update intermediate versions of the library that included the API routine - if($last_idx >= 0) { -#print "parse_line: name='$name'\n"; -#print "parse_line: last_vers='$last_vers'\n"; -#print "parse_line: last_idx='$last_idx'\n"; - - # Add the function to the list of API routines available in - # different versions of the library - while($last_idx <= $_) { - if($line_type == 1) { - $func_vers[$last_idx]{$name} = $last_vers; - } elsif($line_type == 2) { - $type_vers[$last_idx]{$name} = $last_vers; + # Parse the version list into the hashes of version and type info + my $curr_sym_number = 1; + foreach my $vers (@vers_list) { + foreach my $hash_vers (@versions) { + if ($vers > $hash_vers) { + next; + } else { + if ($line_type == 1) { + $api_vers_to_function_vers{$hash_vers}{$name} = $curr_sym_number; } else { - die "unknown line type: $line"; + $api_vers_to_type_vers{$hash_vers}{$name} = $curr_sym_number; } - $last_idx++; } - - # Increment the version # of the function - $last_vers++; } - # Keep track of last version index seen - $last_idx = $_; - } - - # Finish updating versions of the library that included the API routine - if($last_idx >= 0) { -#print "parse_line: max_idx='$max_idx'\n"; - - # Add the function to the list of API routines available in - # different versions of the library - while($last_idx <= $max_idx) { - if($line_type == 1) { - $func_vers[$last_idx]{$name} = $last_vers; - } elsif($line_type == 2) { - $type_vers[$last_idx]{$name} = $last_vers; - } else { - die "unknown line type: $line"; - } - $last_idx++; - } + $curr_sym_number++; } # Store the number of symbol versions in a hash table, indexed by the name - if($line_type == 1) { + if ($line_type == 1) { $functions{$name} = $#vers_list + 1; # Store the function's parameter types for later $func_params{$name} = $params; - } elsif($line_type == 2) { + } elsif ($line_type == 2) { $typedefs{$name} = $#vers_list + 1; - } else { - die "unknown line type: $line"; } #print "\n"; } @@ -552,7 +492,7 @@ for $file (@ARGV) { #print "file = '$file'\n"; # Check for directory prefix on input file - if($file =~ /\//) { + if ($file =~ /\//) { ($prefix) = ($file =~ /(^.*\/)/); } else { @@ -561,9 +501,9 @@ for $file (@ARGV) { #print "prefix = '$prefix'\n"; # Read in the entire file open SOURCE, $file or die "$file: $!\n"; - while ( defined ($line=) ) { + while ( defined ($line = ) ) { # Skip blank lines and those lines whose first character is a '#' - if(!($line =~ /(^\s*#.*$)|(^\s*$)/)) { + if (!($line =~ /(^\s*#.*$)|(^\s*$)/)) { # Construct data structures for later printing parse_line($line); } @@ -573,20 +513,5 @@ for $file (@ARGV) { # Create header files print "Generating 'H5version.h'\n"; create_public($prefix); - -#for $name (sort keys %functions) { -# print "functions{$name} = $functions{$name}\n"; -#} - -#for $i (0 .. $#func_vers) { -# my $vers_name; # Name of indexed version -# $vers_name = "v1." . ($i * 2); -# print "$vers_name functions: "; -# for $name (sort keys %{$func_vers[$i]}) { -# print "$name$func_vers[$i]{$name} "; -# } -# print "\n"; -#} - } From 134d14e78bd964ac77221a63b1057ea860566e1b Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Sun, 8 Dec 2024 03:27:10 -0800 Subject: [PATCH 07/14] Add a release note --- release_docs/RELEASE.txt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index a0b2c2d6210..7491902a226 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -156,6 +156,24 @@ New Features Library: -------- + - The H5Iregister_type() signature has changed + + The hash_size parameter has not been used since early versions of HDF5 + 1.8, so it has been removed and the API call has been versioned. + + The old signature has been renamed to H5Iregister_type1() and is considered + deprecated: + + H5I_type_t H5Iregister_type1(size_t hash_size, unsigned reserved, H5I_free_t free_func); + + The new signature is H5Iregister_type2(). New code should use this + version: + + H5I_type_t H5Iregister_type2(unsigned reserved, H5I_free_t free_func); + + H5Iregister_type() will map to the new signature unless the library is + explicitly configured to use an older version of the API. + - H5F_LIBVER_LATEST is now an enum value This was previously #defined to the latest H5F_libver_t API version, but From c9d019abd8faf50450b6a413587b11ef80c0f0ab Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Sun, 8 Dec 2024 03:30:17 -0800 Subject: [PATCH 08/14] Format source --- hl/src/H5PT.c | 9 +++------ src/H5Ideprec.c | 6 +++--- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/hl/src/H5PT.c b/hl/src/H5PT.c index d5118b7bc4d..89e6a20d69d 100644 --- a/hl/src/H5PT.c +++ b/hl/src/H5PT.c @@ -71,8 +71,7 @@ H5PTcreate(hid_t loc_id, const char *dset_name, hid_t dtype_id, hsize_t chunk_si /* Register the packet table ID type if this is the first table created */ if (H5PT_ptable_id_type < 0) - if ((H5PT_ptable_id_type = - H5Iregister_type2(0, (H5I_free_t)H5PT_free_id)) < 0) + if ((H5PT_ptable_id_type = H5Iregister_type2(0, (H5I_free_t)H5PT_free_id)) < 0) goto error; /* Get memory for the table identifier */ @@ -185,8 +184,7 @@ H5PTcreate_fl(hid_t loc_id, const char *dset_name, hid_t dtype_id, hsize_t chunk /* Register the packet table ID type if this is the first table created */ if (H5PT_ptable_id_type < 0) - if ((H5PT_ptable_id_type = - H5Iregister_type2(0, (H5I_free_t)H5PT_free_id)) < 0) + if ((H5PT_ptable_id_type = H5Iregister_type2(0, (H5I_free_t)H5PT_free_id)) < 0) goto error; /* Get memory for the table identifier */ @@ -285,8 +283,7 @@ H5PTopen(hid_t loc_id, const char *dset_name) /* Register the packet table ID type if this is the first table created */ if (H5PT_ptable_id_type < 0) - if ((H5PT_ptable_id_type = - H5Iregister_type2(0, (H5I_free_t)H5PT_free_id)) < 0) + if ((H5PT_ptable_id_type = H5Iregister_type2(0, (H5I_free_t)H5PT_free_id)) < 0) goto error; table = (htbl_t *)malloc(sizeof(htbl_t)); diff --git a/src/H5Ideprec.c b/src/H5Ideprec.c index a174a1137aa..0d172f668bd 100644 --- a/src/H5Ideprec.c +++ b/src/H5Ideprec.c @@ -31,9 +31,9 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Ipkg.h" /* File access */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Ipkg.h" /* File access */ /****************/ /* Local Macros */ From 4145a4c6adec1474e983868e6327d84d16bc5de1 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Sun, 8 Dec 2024 03:32:11 -0800 Subject: [PATCH 09/14] Remove unused variable --- bin/make_vers | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/make_vers b/bin/make_vers index 9acf0a9f4d2..547543596a9 100755 --- a/bin/make_vers +++ b/bin/make_vers @@ -175,7 +175,6 @@ sub print_globalapidefvers ($) { # sub print_globalapisymbolvers ($) { my $fh = shift; # File handle for output file - my $curr_idx; # Current API version index # Print the descriptive comment print $fh "\n\n/* If a particular \"global\" version of the library's interfaces is chosen,\n"; From aec84684b60ec1a4de82a124bd57fea16b822d22 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Sun, 8 Dec 2024 04:19:22 -0800 Subject: [PATCH 10/14] Fix for no deprecated symbols --- bin/make_vers | 13 +++++++------ src/H5version.h | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/bin/make_vers b/bin/make_vers index 547543596a9..b286bbb2f79 100755 --- a/bin/make_vers +++ b/bin/make_vers @@ -121,11 +121,12 @@ sub print_checkoptions ($) { # Print the #ifdef print $fh "#if ("; $curr_idx = 0; - foreach my $api_vers (@versions) { - print $fh "defined(H5_USE_", $api_vers, "_API)"; + for my $i (0 .. $#versions - 1) { + + print $fh "defined(H5_USE_", $versions[$i], "_API)"; $curr_idx++; - if ($curr_idx < @versions) { + if ($curr_idx < @versions - 1) { print $fh " || "; } } @@ -137,11 +138,11 @@ sub print_checkoptions ($) { # Print the #endif print $fh "#endif /* ("; $curr_idx = 0; - foreach my $api_vers (@versions) { - print $fh "defined(H5_USE_", $api_vers, "_API)"; + for my $i (0 .. $#versions - 1) { + print $fh "defined(H5_USE_", $versions[$i], "_API)"; $curr_idx++; - if ($curr_idx < @versions) { + if ($curr_idx < @versions - 1) { print $fh " || "; } } diff --git a/src/H5version.h b/src/H5version.h index 7c9b3e63c21..9fe80159695 100644 --- a/src/H5version.h +++ b/src/H5version.h @@ -50,9 +50,9 @@ /* Issue error if contradicting macros have been defined. */ /* (Can't use an older (deprecated) API version if deprecated symbols have been disabled) */ -#if (defined(H5_USE_16_API) || defined(H5_USE_18_API) || defined(H5_USE_110_API) || defined(H5_USE_112_API) || defined(H5_USE_114_API) || defined(H5_USE_200_API)) && defined(H5_NO_DEPRECATED_SYMBOLS) +#if (defined(H5_USE_16_API) || defined(H5_USE_18_API) || defined(H5_USE_110_API) || defined(H5_USE_112_API) || defined(H5_USE_114_API)) && defined(H5_NO_DEPRECATED_SYMBOLS) #error "Can't choose old API versions when deprecated APIs are disabled" -#endif /* (defined(H5_USE_16_API) || defined(H5_USE_18_API) || defined(H5_USE_110_API) || defined(H5_USE_112_API) || defined(H5_USE_114_API) || defined(H5_USE_200_API)) && defined(H5_NO_DEPRECATED_SYMBOLS) */ +#endif /* (defined(H5_USE_16_API) || defined(H5_USE_18_API) || defined(H5_USE_110_API) || defined(H5_USE_112_API) || defined(H5_USE_114_API)) && defined(H5_NO_DEPRECATED_SYMBOLS) */ /* If a particular "global" version of the library's interfaces is chosen, From 1a28272e4d87012cf250918c813d41384e446d2a Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Sun, 8 Dec 2024 04:33:44 -0800 Subject: [PATCH 11/14] Remove extraneous variable --- bin/make_vers | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/bin/make_vers b/bin/make_vers index b286bbb2f79..041aa45dad4 100755 --- a/bin/make_vers +++ b/bin/make_vers @@ -112,7 +112,6 @@ sub print_startprotect ($$) { # sub print_checkoptions ($) { my $fh = shift; # File handle for output file - my $curr_idx; # Current API version index # Print the option checking print $fh "\n\n/* Issue error if contradicting macros have been defined. */\n"; @@ -120,13 +119,13 @@ sub print_checkoptions ($) { # Print the #ifdef print $fh "#if ("; - $curr_idx = 0; for my $i (0 .. $#versions - 1) { print $fh "defined(H5_USE_", $versions[$i], "_API)"; - $curr_idx++; - if ($curr_idx < @versions - 1) { + # -2 because we're ignoring the last version in the loop, and the + # last version we DO write out can't have an || after it + if ($i < @versions - 2) { print $fh " || "; } } @@ -137,12 +136,10 @@ sub print_checkoptions ($) { # Print the #endif print $fh "#endif /* ("; - $curr_idx = 0; for my $i (0 .. $#versions - 1) { print $fh "defined(H5_USE_", $versions[$i], "_API)"; - $curr_idx++; - if ($curr_idx < @versions - 1) { + if ($i < @versions - 2) { print $fh " || "; } } From c1834946c2f0e5798ecfd52ace8ed0042d22a591 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Sun, 8 Dec 2024 04:34:52 -0800 Subject: [PATCH 12/14] Remove blank line --- bin/make_vers | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/make_vers b/bin/make_vers index 041aa45dad4..4ce8f6ea66c 100755 --- a/bin/make_vers +++ b/bin/make_vers @@ -120,7 +120,6 @@ sub print_checkoptions ($) { # Print the #ifdef print $fh "#if ("; for my $i (0 .. $#versions - 1) { - print $fh "defined(H5_USE_", $versions[$i], "_API)"; # -2 because we're ignoring the last version in the loop, and the From 558d5cb84eb6e17c7224891e7772589cd57d8939 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Sun, 8 Dec 2024 04:36:17 -0800 Subject: [PATCH 13/14] Fix typo --- bin/make_vers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/make_vers b/bin/make_vers index 4ce8f6ea66c..eab3c4feb9e 100755 --- a/bin/make_vers +++ b/bin/make_vers @@ -122,7 +122,7 @@ sub print_checkoptions ($) { for my $i (0 .. $#versions - 1) { print $fh "defined(H5_USE_", $versions[$i], "_API)"; - # -2 because we're ignoring the last version in the loop, and the + # -2 because we're ignoring the last version in the array, and the # last version we DO write out can't have an || after it if ($i < @versions - 2) { print $fh " || "; From e6c61130c82e7f8fc04027af43b2d77d9c58b591 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Sun, 8 Dec 2024 04:43:26 -0800 Subject: [PATCH 14/14] Fix v111 comment --- bin/make_vers | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/bin/make_vers b/bin/make_vers index eab3c4feb9e..6f93b20510d 100755 --- a/bin/make_vers +++ b/bin/make_vers @@ -357,9 +357,8 @@ sub validate_line { # version for default api=v110 should be version 1 to work correctly # with 1.10 applications that were using unversioned H5O functions, # and the H5O function version should be version 3 for default api=v112 - # (the default api version for 1.12). Allowing a v111 entry and - # incrementing its index 13 lines below allows a version 2 that is - # never accessed via the H5O function macros. + # (the default api version for 1.12). Allowing a v111 entry allows + # a version 2 that is never accessed via the H5O function macros. if (!( $_ =~ /v1[02468]/ || $_ =~ /v11[02468]/ || $_ =~ /v111/ || $_ =~ /v200/ )) { die "bad version information: $name"; }