diff options
author | David Young <dyoung@hdfgroup.org> | 2021-11-08 21:08:07 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-08 21:08:07 (GMT) |
commit | a0445d806c480529e127d79fda257aa8bf70d594 (patch) | |
tree | 19cad85a7c0b2b1afdcbab4b913c25f6e9f62d55 | |
parent | e82d39ca0e4122facb87fe784e58a77f41a8814f (diff) | |
download | hdf5-a0445d806c480529e127d79fda257aa8bf70d594.zip hdf5-a0445d806c480529e127d79fda257aa8bf70d594.tar.gz hdf5-a0445d806c480529e127d79fda257aa8bf70d594.tar.bz2 |
Simplify function enter macros for performance benefits (#1024)
* Take a stab at using constructors to initialize instead of
function-entry macros. This is a work in progress. It's good enough to
run `many_dsets`.
* Committing clang-format changes
* Add the `many_dsets` benchmark and some scripts I used on jelly for
setting up the build/test environment and for recording/flame-graphing
profiles.
* Committing clang-format changes
* Change my Makefile and environment script to work both on jelly
and on mayll (and probably on Summit).
* Disable clang-format "fix."
* Replace the `if (!H5_TERM_GLOBAL)` test in each FUNC_ENTER_ macro with
`if (true)`.
* Fix bad grammar in a comment.
* Instead of labeling the H5*__init_package routines constructors, fold
each into an initialization routine, H5*_init(), and call each of
the H5*_init() routines. Call most of the H5*_init() routines from
H5_init_library() in an explicit order that I found out earlier by
instrumenting each __init_package routine and running the library
tests. Roll H5FD*__init_package routines into H5FD*_init() routines.
This change ends just-in-time initialization of package dependencies by
package initializers.
Don't track in per-package variables (H5_PKG_INIT_VAR) whether each
package has been initialized. Instead, track in a single library
variable whether the whole library is initialized or not.
Drive the initialization of packages by H5_init_library() with a table
of initializer routines. Also drive the termination of packages by
H5_term_library() with a table.
Perform initialization as needed from FUNC_ENTER_API_INIT(err). This
basically restores the old behavior of that macro.
Delete a bunch of #definitions in H5private.h that have fallen out of
use with these changes.
* Committing clang-format changes
* Undo the bad auto-formatting that appears to have occurred in spite
of my disabling it. Bracket some code in /* clang-format off */ /*
clang-format on */ to prevent a recurrence.
* Remove a diagnostic abort().
* Fix a logic error: print a comma between every package terminator run,
and don't print an initial comma.
* Complete the changes I started in H5_term_library() that undo the bad
auto-formatting.
Stop tracking whether package "tops" were initialized in per-package
variables H5*_top_package_initialize_s. H5_term_library() takes care of
that for them.
Remove H5R_top_term_package() and H5R_term_package(), they don't do
anything.
* Committing clang-format changes
* NFCI. Simplify macro text: replace `if (true) {` with `{`.
* Fix formatting and suppress clang-format on a longer range.
* Quiet some unused label, unused variable complaints that cropped up
after I simplified the FUNC_ENTER_ macros for the sake of performance.
* Committing clang-format changes
* Delete some programs and scripts that don't belong in the pull request.
* Use the right function-entry macro.
* Use a sensible format and disable auto-formatting.
* Stop calling do-nothing initializer H5FS_init(). Delete it.
* Document what changes to make if the default VFD changes.
* While I am here, change an `await_prior` flag on the terminator table
to `true` to match the previous, non-table-driven code that was here.
Found the oversight making the following changes:
NFCI: insert an empty line and copy over slightly-edited comments from
the previous version, where those comments still correctly explained how
library termination operated.
* NFCI: lower a staircase.
* Replace every occurrence of FUNC_ENTER_NOAPI_INIT(...) with H5_PUSH_FUNC
since that is all that that macro does any more.
Quiet a bunch of new warnings by changing FUNC_ENTER_NOAPI(...) to
FUNC_ENTER_NOAPI_NOERR and removing disused `done:` labels.
* NFCI: add curly braces around a multiline statement.
* Quiet a signed/unsigned comparison warning.
* Add some documentation about library initialization and shutdown.
* Make sure that the library is initialized, or else that initialization
is already underway, before performing any VFD's initialization.
* Committing clang-format changes
* Committing clang-format changes
* Reduce differences from `develop` branch.
* Always initialize `tot_init`.
* Committing clang-format changes
* Fix typo: H5SL_init initializes skip lists, not VOL.
* Remove H5_TERM_GLOBAL test in H5T_init. H5T_init was unusual in that
it tested H5_TERM_GLOBAL and exited early if it was set. No other
module initializers did that, and I cannot find any reason that should
be necessary. Tests still pass when I remove it, so away it goes.
* Use HD prefix.
* Add function header comments.
* Drop the intermediate variable, it's only used once.
* Extract subroutine `H5FDperform_init(hid_t (*init)(void))` that
initializes the library, if necessary, before calling its VFD-initializer
argument. Use H5FDperform_init in the definition of the symbols
H5FD_<vfd> (e.g., H5FD_SEC2), which may be evaluated before the library
is initialized, like so:
```
```
I implement H5FDperform_init in its own source file, H5FDperform.c,
and exclude that file from trace processing because the `bin/trace`
cannot deal with the function-pointer type.
* Straggler from last: add new source file src/H5FDperform.c.
* Committing clang-format changes
* Add a missing file to the MANIFEST.
* Switch to FUNC_ENTER_API_NOINIT in H5FDperform_init() and hbool_t in
H5_term_library().
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
82 files changed, 1115 insertions, 1989 deletions
@@ -207,6 +207,7 @@ ./doc/branches-explained.md ./doc/code-conventions.md ./doc/contributing.md +./doc/library-init-shutdown.md ./doxygen/aliases ./doxygen/CMakeLists.txt ./doxygen/Doxyfile.in @@ -807,6 +808,7 @@ ./src/H5FDmpio.h ./src/H5FDmulti.c ./src/H5FDmulti.h +./src/H5FDperform.c ./src/H5FDros3.c ./src/H5FDros3.h ./src/H5FDpkg.h @@ -498,7 +498,7 @@ for $file (@ARGV) { $file_args = 0; # Ignore some files that do not need tracing macros - unless ($file eq "H5FDmulti.c" or $file eq "src/H5FDmulti.c" or $file eq "H5FDstdio.c" or $file eq "src/H5FDstdio.c" or $file eq "src/H5TS.c") { + unless ($file eq "H5FDmulti.c" or $file eq "src/H5FDmulti.c" or $file eq "H5FDstdio.c" or $file eq "src/H5FDstdio.c" or $file eq "src/H5TS.c" or $file eq "src/H5FDperform.c") { # Snarf up the entire file open SOURCE, $file or die "$file: $!\n"; diff --git a/doc/library-init-shutdown.md b/doc/library-init-shutdown.md new file mode 100644 index 0000000..917d213 --- /dev/null +++ b/doc/library-init-shutdown.md @@ -0,0 +1,56 @@ +# HDF5 Library initialization and shutdown + +## Application perspective + +### Implicit initialization and shutdown + +When a developer exports a new symbol as part of the HDF5 library, +they should make sure that an application cannot enter the library in an +uninitialized state through a new API function, or read an uninitialized +value from a non-function HDF5 symbol. + +The HDF5 library initializes itself when an application either enters +the library through an API function call such as `H5Fopen`, or when +an application evaluates an HDF5 symbol that represents either a +property-list identifier such as `H5F_ACC_RDONLY` or `H5F_ACC_RDWR`, +a property-list class identifier such as `H5P_FILE_ACCESS`, a VFD +identifier such as `H5FD_FAMILY` or `H5FD_SEC2`, or a type identifier +such as `H5T_NATIVE_INT64`. + +The library sets a flag when initialization occurs and as long as the +flag is set, skips initialization. + +The library provides a couple of macros that initialize the library +as necessary. The library is initialized as a side-effect of the +`FUNC_ENTER_API*` macros used at the top of most API functions. HDF5 +library symbols other than functions are provided through `#define`s +that use `H5OPEN` to introduce a library-initialization call (`H5open`) +at each site where a non-function symbol is used. + +Ordinarily the library registers an `atexit(3)` handler to shut itself +down when the application exits. + +### Explicit initialization and shutdown + +An application may use an API call, `H5open`, to explicitly initialize +the library. `H5close` explicitly shuts down the library. + +## Library internals perspective + +No matter how library initializion begins, eventually the internal +function `H5_init_library` will be called. `H5_init_library` is +responsible for calling the initializers for every internal HDF5 +library module (aka "package") in the correct order so that no module is +initialized before its prerequisite modules. A table in `H5_init_library` +establishes the order of initialization. If a developer adds a +module to the library that it is appropriate to initialize with the rest +of the library, then they should insert its initializer into the right +place in the table. + +`H5_term_library` drives library shutdown. Library shutdown is +table-driven, too. If a developer adds a module that needs to release +resources during library shutdown, then they should add a call at the +right place to the shutdown table. Note that some entries in the shutdown +table are marked as "barriers," and if a new module should only be +shutdown *strictly after* the preceding modules, then it should be marked +as a barrier. See the comments in `H5_term_library` for more information. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cde36c9..4ed5f67 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -240,6 +240,7 @@ set (H5FD_SOURCES ${HDF5_SRC_DIR}/H5FDmpi.c ${HDF5_SRC_DIR}/H5FDmpio.c ${HDF5_SRC_DIR}/H5FDmulti.c + ${HDF5_SRC_DIR}/H5FDperform.c ${HDF5_SRC_DIR}/H5FDros3.c ${HDF5_SRC_DIR}/H5FDs3comms.c ${HDF5_SRC_DIR}/H5FDsec2.c @@ -32,6 +32,8 @@ #include "H5SLprivate.h" /* Skip lists */ #include "H5Tprivate.h" /* Datatypes */ +#include "H5FDsec2.h" /* for H5FD_sec2_init() */ + /****************/ /* Local Macros */ /****************/ @@ -63,9 +65,6 @@ static int H5__mpi_delete_cb(MPI_Comm comm, int keyval, void *attr_val, int *fla /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ @@ -101,32 +100,30 @@ static H5_atclose_node_t *H5_atclose_head = NULL; /* Declare a free list to manage the H5_atclose_node_t struct */ H5FL_DEFINE_STATIC(H5_atclose_node_t); -/*-------------------------------------------------------------------------- -NAME - H5__init_package -- Initialize interface-specific information -USAGE - herr_t H5__init_package() -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. ---------------------------------------------------------------------------*/ -herr_t -H5__init_package(void) +/*------------------------------------------------------------------------- + * Function: H5_default_vfd_init + * + * Purpose: Initialize the default VFD. + * + * Return: Success: non-negative + * Failure: negative + *------------------------------------------------------------------------- + */ +static herr_t +H5_default_vfd_init(void) { - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - /* Run the library initialization routine, if it hasn't already ran */ - if (!H5_INIT_GLOBAL && !H5_TERM_GLOBAL) { - if (H5_init_library() < 0) - HGOTO_ERROR(H5E_LIB, H5E_CANTINIT, FAIL, "unable to initialize library") - } /* end if */ + herr_t ret_value = SUCCEED; + FUNC_ENTER_NOAPI(FAIL) + /* Load the hid_t for the default VFD for the side effect + * it has of initializing the default VFD. + */ + if (H5FD_sec2_init() == H5I_INVALID_HID) { + HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to load default VFD ID") + } done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5__init_package() */ +} /*-------------------------------------------------------------------------- * NAME @@ -145,8 +142,13 @@ done: herr_t H5_init_library(void) { + size_t i; herr_t ret_value = SUCCEED; + /* Run the library initialization routine, if it hasn't already run */ + if (H5_INIT_GLOBAL || H5_TERM_GLOBAL) + HGOTO_DONE(SUCCEED) + /* Set the 'library initialized' flag as early as possible, to avoid * possible re-entrancy. */ @@ -257,26 +259,32 @@ H5_init_library(void) * The dataspace interface needs to be initialized so that future IDs for * dataspaces work. */ - if (H5E_init() < 0) - HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize error interface") - if (H5VL_init_phase1() < 0) - HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize vol interface") - if (H5P_init_phase1() < 0) - HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize property list interface") - if (H5AC_init() < 0) - HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize metadata caching interface") - if (H5L_init() < 0) - HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize link interface") - if (H5FS_init() < 0) - HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize FS interface") - if (H5S_init() < 0) - HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize dataspace interface") - + /* clang-format off */ + struct { + herr_t (*func)(void); + const char *descr; + } initializer[] = { + {H5E_init, "error"} + , {H5VL_init_phase1, "VOL"} + , {H5SL_init, "skip lists"} + , {H5FD_init, "VFD"} + , {H5_default_vfd_init, "default VFD"} + , {H5P_init_phase1, "property list"} + , {H5AC_init, "metadata caching"} + , {H5L_init, "link"} + , {H5S_init, "dataspace"} /* Finish initializing interfaces that depend on the interfaces above */ - if (H5P_init_phase2() < 0) - HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize property list interface") - if (H5VL_init_phase2() < 0) - HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize vol interface") + , {H5P_init_phase2, "property list"} + , {H5VL_init_phase2, "VOL"} + }; + + for (i = 0; i < NELMTS(initializer); i++) { + if (initializer[i].func() < 0) { + HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, + "unable to initialize %s interface", initializer[i].descr) + } + } + /* clang-format on */ /* Debugging? */ H5__debug_mask("-all"); @@ -300,9 +308,11 @@ done: void H5_term_library(void) { - int pending, ntries = 0, n; - size_t at = 0; - char loop[1024]; + int pending, ntries = 0; + char loop[1024], *next = loop; + size_t i; + size_t nleft = sizeof(loop); + int nprinted; H5E_auto2_t func; #ifdef H5_HAVE_THREADSAFE @@ -346,108 +356,137 @@ H5_term_library(void) H5_atclose_head = NULL; } /* end if */ + /* clang-format off */ + /* * Terminate each interface. The termination functions return a positive * value if they do something that might affect some other interface in a * way that would necessitate some cleanup work in the other interface. */ -#define DOWN(F) \ - (((n = H5##F##_term_package()) && (at + 8) < sizeof loop) \ - ? (HDsprintf(loop + at, "%s%s", (at ? "," : ""), #F), at += HDstrlen(loop + at), n) \ - : ((n > 0 && (at + 5) < sizeof loop) ? (HDsprintf(loop + at, "..."), at += HDstrlen(loop + at), n) \ - : n)) - do { - pending = 0; - - /* Try to organize these so the "higher" level components get shut - * down before "lower" level components that they might rely on. -QAK - */ +#define TERMINATOR(module, wait) { \ + .func = H5##module##_term_package \ + , .name = #module \ + , .completed = false \ + , .await_prior = wait \ + } + /* + * Termination is ordered by the `terminator` table so the "higher" level + * packages are shut down before "lower" level packages that they + * rely on: + */ + struct { + int (*func)(void); /* function to terminate the module; returns 0 + * on success, >0 if termination was not + * completed and we should try to terminate + * some dependent modules, first. + */ + const char *name; /* name of the module */ + hbool_t completed; /* true iff this terminator was already + * completed + */ + const hbool_t await_prior; /* true iff all prior terminators in the + * list must complete before this + * terminator is attempted + */ + } terminator[] = { /* Close the event sets first, so that all asynchronous operations - * complete before anything else attempts to shut down. + * complete before anything else attempts to shut down. */ - pending += DOWN(ES); - - /* Close down the user-facing interfaces, after the event sets */ - if (pending == 0) { - /* Close the interfaces dependent on others */ - pending += DOWN(L); - - /* Close the "top" of various interfaces (IDs, etc) but don't shut - * down the whole interface yet, so that the object header messages - * get serialized correctly for entries in the metadata cache and the - * symbol table entry in the superblock gets serialized correctly, etc. - * all of which is performed in the 'F' shutdown. - */ - pending += DOWN(A_top); - pending += DOWN(D_top); - pending += DOWN(G_top); - pending += DOWN(M_top); - pending += DOWN(R_top); - pending += DOWN(S_top); - pending += DOWN(T_top); - } /* end if */ - + TERMINATOR(ES, false) + /* Do not attempt to close down package L until after event sets + * have finished closing down. + */ + , TERMINATOR(L, true) + /* Close the "top" of various interfaces (IDs, etc) but don't shut + * down the whole interface yet, so that the object header messages + * get serialized correctly for entries in the metadata cache and the + * symbol table entry in the superblock gets serialized correctly, etc. + * all of which is performed in the 'F' shutdown. + * + * The tops of packages A, D, G, M, S, T do not need to wait for L + * or previous packages to finish closing down. + */ + , TERMINATOR(A_top, false) + , TERMINATOR(D_top, false) + , TERMINATOR(G_top, false) + , TERMINATOR(M_top, false) + , TERMINATOR(S_top, false) + , TERMINATOR(T_top, false) /* Don't shut down the file code until objects in files are shut down */ - if (pending == 0) - pending += DOWN(F); - + , TERMINATOR(F, true) /* Don't shut down the property list code until all objects that might - * use property lists are shut down */ - if (pending == 0) - pending += DOWN(P); - + * use property lists are shut down + */ + , TERMINATOR(P, true) /* Wait to shut down the "bottom" of various interfaces until the - * files are closed, so pieces of the file can be serialized - * correctly. + * files are closed, so pieces of the file can be serialized + * correctly. + * + * Shut down the "bottom" of the attribute, dataset, group, + * reference, dataspace, and datatype interfaces, fully closing + * out the interfaces now. */ - if (pending == 0) { - /* Shut down the "bottom" of the attribute, dataset, group, - * reference, dataspace, and datatype interfaces, fully closing - * out the interfaces now. - */ - pending += DOWN(A); - pending += DOWN(D); - pending += DOWN(G); - pending += DOWN(M); - pending += DOWN(R); - pending += DOWN(S); - pending += DOWN(T); - } /* end if */ - - /* Don't shut down "low-level" components until "high-level" components - * have successfully shut down. This prevents property lists and IDs - * from being closed "out from underneath" of the high-level objects - * that depend on them. -QAK + , TERMINATOR(A, true) + , TERMINATOR(D, false) + , TERMINATOR(G, false) + , TERMINATOR(M, false) + , TERMINATOR(S, false) + , TERMINATOR(T, false) + /* Wait to shut down low-level packages like AC until after + * the preceding high-level packages have shut down. This prevents + * low-level objects from closing "out from underneath" their + * reliant high-level objects. */ - if (pending == 0) { - pending += DOWN(AC); - /* Shut down the "pluggable" interfaces, before the plugin framework */ - pending += DOWN(Z); - pending += DOWN(FD); - pending += DOWN(VL); - /* Don't shut down the plugin code until all "pluggable" interfaces (Z, FD, PL) are shut down */ - if (pending == 0) - pending += DOWN(PL); - /* Don't shut down the error code until other APIs which use it are shut down */ - if (pending == 0) - pending += DOWN(E); - /* Don't shut down the ID code until other APIs which use them are shut down */ - if (pending == 0) - pending += DOWN(I); - /* Don't shut down the skip list code until everything that uses it is down */ - if (pending == 0) - pending += DOWN(SL); - /* Don't shut down the free list code until everything that uses it is down */ - if (pending == 0) - pending += DOWN(FL); - /* Don't shut down the API context code until _everything_ else is down */ - if (pending == 0) - pending += DOWN(CX); - } /* end if */ + , TERMINATOR(AC, true) + /* Shut down the "pluggable" interfaces, before the plugin framework */ + , TERMINATOR(Z, false) + , TERMINATOR(FD, false) + , TERMINATOR(VL, false) + /* Don't shut down the plugin code until all "pluggable" interfaces + * (Z, FD, PL) are shut down + */ + , TERMINATOR(PL, true) + /* Shut down the following packages in strictly the order given + * by the table. + */ + , TERMINATOR(E, true) + , TERMINATOR(I, true) + , TERMINATOR(SL, true) + , TERMINATOR(FL, true) + , TERMINATOR(CX, true) + }; + + do { + pending = 0; + for (i = 0; i < NELMTS(terminator); i++) { + if (terminator[i].completed) + continue; + if (pending != 0 && terminator[i].await_prior) + break; + if (terminator[i].func() == 0) { + terminator[i].completed = true; + continue; + } + + /* log a package when its terminator needs to be retried */ + pending++; + nprinted = HDsnprintf(next, nleft, "%s%s", + (next != loop) ? "," : "", terminator[i].name); + if (nprinted < 0) + continue; + if ((size_t)nprinted >= nleft) + nprinted = HDsnprintf(next, nleft, "..."); + if (nprinted < 0 || (size_t)nprinted >= nleft) + continue; + nleft -= (size_t)nprinted; + next += nprinted; + } } while (pending && ntries++ < 100); + /* clang-format on */ + if (pending) { /* Only display the error message if the user is interested in them. */ if (func) { @@ -70,9 +70,6 @@ static herr_t H5AC__verify_tag(const H5AC_class_t *type); /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ @@ -143,29 +140,7 @@ H5AC_init(void) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) - /* FUNC_ENTER() does all the work */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5AC_init() */ - -/*------------------------------------------------------------------------- - * Function: H5AC__init_package - * - * Purpose: Initialize interface-specific information - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * Thursday, July 18, 2002 - * - *------------------------------------------------------------------------- - */ -herr_t -H5AC__init_package(void) -{ - FUNC_ENTER_PACKAGE_NOERR + FUNC_ENTER_NOAPI_NOERR #ifdef H5_HAVE_PARALLEL /* check whether to enable strict collective function calling @@ -182,8 +157,8 @@ H5AC__init_package(void) } #endif /* H5_HAVE_PARALLEL */ - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5AC__init_package() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5AC_init() */ /*------------------------------------------------------------------------- * Function: H5AC_term_package @@ -204,10 +179,6 @@ H5AC_term_package(void) { FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5_PKG_INIT_VAR) - /* Reset interface initialization flag */ - H5_PKG_INIT_VAR = FALSE; - FUNC_LEAVE_NOAPI(0) } /* end H5AC_term_package() */ diff --git a/src/H5ACproxy_entry.c b/src/H5ACproxy_entry.c index b3d31b2..31d3224 100644 --- a/src/H5ACproxy_entry.c +++ b/src/H5ACproxy_entry.c @@ -421,7 +421,7 @@ H5AC_proxy_entry_dest(H5AC_proxy_entry_t *pentry) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR /* Sanity checks */ HDassert(pentry); @@ -433,7 +433,6 @@ H5AC_proxy_entry_dest(H5AC_proxy_entry_t *pentry) /* Free the proxy entry object */ pentry = H5FL_FREE(H5AC_proxy_entry_t, pentry); -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5AC_proxy_entry_dest() */ diff --git a/src/H5Aint.c b/src/H5Aint.c index 300d686..b0b91d0 100644 --- a/src/H5Aint.c +++ b/src/H5Aint.c @@ -99,9 +99,6 @@ static herr_t H5A__iterate_common(hid_t loc_id, H5_index_t idx_type, H5_iter_ord /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /* Format version bounds for attribute */ const unsigned H5O_attr_ver_bounds[] = { H5O_ATTR_VERSION_1, /* H5F_LIBVER_EARLIEST */ @@ -139,9 +136,6 @@ static const H5I_class_t H5I_ATTR_CLS[1] = {{ (H5I_free_t)H5A__close_cb /* Callback routine for closing objects of this class */ }}; -/* Flag indicating "top" of interface has been initialized */ -static hbool_t H5A_top_package_initialize_s = FALSE; - /*------------------------------------------------------------------------- * Function: H5A_init * @@ -158,30 +152,6 @@ H5A_init(void) herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - /* FUNC_ENTER() does all the work */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5A_init() */ - -/*-------------------------------------------------------------------------- -NAME - H5A__init_package -- Initialize interface-specific information -USAGE - herr_t H5A__init_package() - -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. - ---------------------------------------------------------------------------*/ -herr_t -H5A__init_package(void) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE /* * Create attribute ID type. @@ -189,12 +159,9 @@ H5A__init_package(void) if (H5I_register_type(H5I_ATTR_CLS) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to initialize interface") - /* Mark "top" of interface as initialized, too */ - H5A_top_package_initialize_s = TRUE; - done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5A__init_package() */ +} /* end H5A_init() */ /*-------------------------------------------------------------------------- NAME @@ -220,16 +187,10 @@ H5A_top_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5A_top_package_initialize_s) { - if (H5I_nmembers(H5I_ATTR) > 0) { - (void)H5I_clear_type(H5I_ATTR, FALSE, FALSE); - n++; /*H5I*/ - } /* end if */ - - /* Mark closed */ - if (0 == n) - H5A_top_package_initialize_s = FALSE; - } /* end if */ + if (H5I_nmembers(H5I_ATTR) > 0) { + (void)H5I_clear_type(H5I_ATTR, FALSE, FALSE); + n++; /*H5I*/ + } /* end if */ FUNC_LEAVE_NOAPI(n) } /* H5A_top_term_package() */ @@ -260,18 +221,11 @@ H5A_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5_PKG_INIT_VAR) { - /* Sanity checks */ - HDassert(0 == H5I_nmembers(H5I_ATTR)); - HDassert(FALSE == H5A_top_package_initialize_s); - - /* Destroy the attribute object id group */ - n += (H5I_dec_type_ref(H5I_ATTR) > 0); + /* Sanity checks */ + HDassert(0 == H5I_nmembers(H5I_ATTR)); - /* Mark closed */ - if (0 == n) - H5_PKG_INIT_VAR = FALSE; - } /* end if */ + /* Destroy the attribute object id group */ + n += (H5I_dec_type_ref(H5I_ATTR) > 0); FUNC_LEAVE_NOAPI(n) } /* H5A_term_package() */ @@ -1148,7 +1102,7 @@ H5A__get_info(const H5A_t *attr, H5A_info_t *ainfo) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR /* Check args */ HDassert(attr); @@ -1166,7 +1120,6 @@ H5A__get_info(const H5A_t *attr, H5A_info_t *ainfo) ainfo->corder = attr->shared->crt_idx; } /* end else */ -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__get_info() */ @@ -1383,14 +1336,13 @@ H5A_oloc(H5A_t *attr) { H5O_loc_t *ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI(NULL) + FUNC_ENTER_NOAPI_NOERR HDassert(attr); /* Set return value */ ret_value = &(attr->oloc); -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A_oloc() */ @@ -1414,14 +1366,13 @@ H5A_nameof(H5A_t *attr) { H5G_name_t *ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI(NULL) + FUNC_ENTER_NOAPI_NOERR HDassert(attr); /* Set return value */ ret_value = &(attr->path); -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A_nameof() */ @@ -1443,14 +1394,13 @@ H5A_type(const H5A_t *attr) { H5T_t *ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI(NULL) + FUNC_ENTER_NOAPI_NOERR HDassert(attr); /* Set return value */ ret_value = attr->shared->dt; -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A_type() */ @@ -157,9 +157,6 @@ static H5B_t *H5B__copy(const H5B_t *old_bt); /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /* Declare a free list to manage the haddr_t sequence information */ H5FL_SEQ_DEFINE(haddr_t); @@ -61,9 +61,6 @@ /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /* v2 B-tree client ID to class mapping */ /* Remember to add client ID to H5B2_subid_t in H5B2private.h when adding a new @@ -157,9 +157,6 @@ static void H5C__assert_flush_dep_nocycle(const H5C_cache_entry_t *entry, /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /* Declare a free list to manage the tag info struct */ H5FL_DEFINE(H5C_tag_info_t); @@ -428,9 +428,6 @@ static H5CX_node_t *H5CX__pop_common(hbool_t update_dxpl_props); /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /*******************/ /* Local Variables */ /*******************/ @@ -463,18 +460,17 @@ H5FL_DEFINE_STATIC(H5CX_node_t); /* Declare a static free list to manage H5CX_state_t structs */ H5FL_DEFINE_STATIC(H5CX_state_t); -/*-------------------------------------------------------------------------- -NAME - H5CX__init_package -- Initialize interface-specific information -USAGE - herr_t H5CX__init_package() -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. ---------------------------------------------------------------------------*/ +/*------------------------------------------------------------------------- + * Function: H5CX_init + * + * Purpose: Initialize the interface from some other layer. + * + * Return: Success: non-negative + * Failure: negative + *------------------------------------------------------------------------- + */ herr_t -H5CX__init_package(void) +H5CX_init(void) { H5P_genplist_t *dx_plist; /* Data transfer property list */ H5P_genplist_t *lc_plist; /* Link creation property list */ @@ -484,7 +480,7 @@ H5CX__init_package(void) H5P_genplist_t *fa_plist; /* File access property list */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC + FUNC_ENTER_NOAPI(FAIL) /* Reset the "default DXPL cache" information */ HDmemset(&H5CX_def_dxpl_cache, 0, sizeof(H5CX_dxpl_cache_t)); @@ -649,10 +645,9 @@ H5CX__init_package(void) if (H5P_get(fa_plist, H5F_ACS_LIBVER_HIGH_BOUND_NAME, &H5CX_def_fapl_cache.high_bound) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve dataset minimize flag") - done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5CX__init_package() */ +} /*------------------------------------------------------------------------- * Function: H5CX_term_package @@ -673,24 +668,20 @@ H5CX_term_package(void) { FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5_PKG_INIT_VAR) { - H5CX_node_t *cnode; /* Context node */ + H5CX_node_t *cnode; /* Context node */ - /* Pop the top context node from the stack */ - /* (Can't check for errors, as rest of library is shut down) */ - cnode = H5CX__pop_common(FALSE); + /* Pop the top context node from the stack */ + /* (Can't check for errors, as rest of library is shut down) */ + cnode = H5CX__pop_common(FALSE); - /* Free the context node */ - /* (Allocated with HDmalloc() in H5CX_push_special() ) */ - HDfree(cnode); + /* Free the context node */ + /* (Allocated with HDmalloc() in H5CX_push_special() ) */ + HDfree(cnode); #ifndef H5_HAVE_THREADSAFE - H5CX_head_g = NULL; + H5CX_head_g = NULL; #endif /* H5_HAVE_THREADSAFE */ - H5_PKG_INIT_VAR = FALSE; - } /* end if */ - FUNC_LEAVE_NOAPI(0) } /* end H5CX_term_package() */ @@ -1227,7 +1218,7 @@ H5CX_set_libver_bounds(H5F_t *f) H5CX_node_t **head = NULL; /* Pointer to head of API context list */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR /* Sanity check */ head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ @@ -1241,7 +1232,6 @@ H5CX_set_libver_bounds(H5F_t *f) (*head)->ctx.low_bound_valid = TRUE; (*head)->ctx.high_bound_valid = TRUE; -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_set_libver_bounds() */ @@ -1509,7 +1499,7 @@ H5CX_set_vol_wrap_ctx(void *vol_wrap_ctx) H5CX_node_t **head = NULL; /* Pointer to head of API context list */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR /* Sanity check */ head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ @@ -1521,7 +1511,6 @@ H5CX_set_vol_wrap_ctx(void *vol_wrap_ctx) /* Mark the value as valid */ (*head)->ctx.vol_wrap_ctx_valid = TRUE; -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_set_vol_wrap_ctx() */ @@ -1543,7 +1532,7 @@ H5CX_set_vol_connector_prop(const H5VL_connector_prop_t *vol_connector_prop) H5CX_node_t **head = NULL; /* Pointer to head of API context list */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR /* Sanity check */ head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ @@ -1555,7 +1544,6 @@ H5CX_set_vol_connector_prop(const H5VL_connector_prop_t *vol_connector_prop) /* Mark the value as valid */ (*head)->ctx.vol_connector_prop_valid = TRUE; -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_set_vol_connector_prop() */ @@ -1637,7 +1625,7 @@ H5CX_get_vol_wrap_ctx(void **vol_wrap_ctx) H5CX_node_t **head = NULL; /* Pointer to head of API context list */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR /* Sanity check */ HDassert(vol_wrap_ctx); @@ -1651,7 +1639,6 @@ H5CX_get_vol_wrap_ctx(void **vol_wrap_ctx) else *vol_wrap_ctx = NULL; -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_vol_wrap_ctx() */ @@ -1673,7 +1660,7 @@ H5CX_get_vol_connector_prop(H5VL_connector_prop_t *vol_connector_prop) H5CX_node_t **head = NULL; /* Pointer to head of API context list */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR /* Sanity check */ HDassert(vol_connector_prop); @@ -1687,7 +1674,6 @@ H5CX_get_vol_connector_prop(H5VL_connector_prop_t *vol_connector_prop) else HDmemset(vol_connector_prop, 0, sizeof(H5VL_connector_prop_t)); -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_vol_connector_prop() */ @@ -3135,7 +3121,7 @@ H5CX_set_vlen_alloc_info(H5MM_allocate_t alloc_func, void *alloc_info, H5MM_free H5CX_node_t **head = NULL; /* Pointer to head of API context list */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR /* Sanity check */ head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ @@ -3150,7 +3136,6 @@ H5CX_set_vlen_alloc_info(H5MM_allocate_t alloc_func, void *alloc_info, H5MM_free /* Mark the value as valid */ (*head)->ctx.vl_alloc_info_valid = TRUE; -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_set_vlen_alloc_info() */ @@ -3172,7 +3157,7 @@ H5CX_set_nlinks(size_t nlinks) H5CX_node_t **head = NULL; /* Pointer to head of API context list */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR /* Sanity check */ head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ @@ -3184,7 +3169,6 @@ H5CX_set_nlinks(size_t nlinks) /* Mark the value as valid */ (*head)->ctx.nlinks_valid = TRUE; -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_set_nlinks() */ diff --git a/src/H5CXprivate.h b/src/H5CXprivate.h index c500356..8ec1c59 100644 --- a/src/H5CXprivate.h +++ b/src/H5CXprivate.h @@ -160,6 +160,8 @@ H5_DLL herr_t H5CX_set_vlen_alloc_info(H5MM_allocate_t alloc_func, void *alloc_i /* "Setter" routines for LAPL properties cached in API context */ H5_DLL herr_t H5CX_set_nlinks(size_t nlinks); +H5_DLL herr_t H5CX_init(void); + /* "Setter" routines for cached DXPL properties that must be returned to application */ #ifdef H5_HAVE_PARALLEL H5_DLL void H5CX_set_mpio_actual_chunk_opt(H5D_mpio_actual_chunk_opt_mode_t chunk_opt); @@ -62,9 +62,6 @@ static herr_t H5D__set_extent_api_common(hid_t dset_id, const hsize_t size[], vo /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ diff --git a/src/H5Dint.c b/src/H5Dint.c index 6d3f4a3..8a09364 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -139,9 +139,6 @@ static const H5I_class_t H5I_DATASET_CLS[1] = {{ (H5I_free_t)H5D__close_cb /* Callback routine for closing objects of this class */ }}; -/* Flag indicating "top" of interface has been initialized */ -static hbool_t H5D_top_package_initialize_s = FALSE; - /* Prefixes of VDS and external file from the environment variables * HDF5_EXTFILE_PREFIX and HDF5_VDS_PREFIX */ static const char *H5D_prefix_ext_env = NULL; @@ -160,37 +157,10 @@ static const char *H5D_prefix_vds_env = NULL; herr_t H5D_init(void) { - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - /* FUNC_ENTER() does all the work */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5D_init() */ - -/*-------------------------------------------------------------------------- -NAME - H5D__init_package -- Initialize interface-specific information -USAGE - herr_t H5D__init_package() - -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. -NOTES - Care must be taken when using the H5P functions, since they can cause - a deadlock in the library when the library is attempting to terminate -QAK - ---------------------------------------------------------------------------*/ -herr_t -H5D__init_package(void) -{ H5P_genplist_t *def_dcpl; /* Default Dataset Creation Property list */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_PACKAGE + FUNC_ENTER_NOAPI(FAIL) /* Initialize the ID group for the dataset IDs */ if (H5I_register_type(H5I_DATASET_CLS) < 0) @@ -220,16 +190,13 @@ H5D__init_package(void) if (H5P_get(def_dcpl, H5O_CRT_PIPELINE_NAME, &H5D_def_dset.dcpl_cache.pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve pipeline filter") - /* Mark "top" of interface as initialized, too */ - H5D_top_package_initialize_s = TRUE; - /* Retrieve the prefixes of VDS and external file from the environment variable */ H5D_prefix_vds_env = HDgetenv("HDF5_VDS_PREFIX"); H5D_prefix_ext_env = HDgetenv("HDF5_EXTFILE_PREFIX"); done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5D__init_package() */ +} /* end H5D_init() */ /*------------------------------------------------------------------------- * Function: H5D_top_term_package @@ -248,38 +215,32 @@ H5D_top_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5D_top_package_initialize_s) { - if (H5I_nmembers(H5I_DATASET) > 0) { - /* The dataset API uses the "force" flag set to true because it - * is using the "file objects" (H5FO) API functions to track open - * objects in the file. Using the H5FO code means that dataset - * IDs can have reference counts >1, when an existing dataset is - * opened more than once. However, the H5I code does not attempt - * to close objects with reference counts>1 unless the "force" flag - * is set to true. - * - * At some point (probably after the group and datatypes use the - * the H5FO code), the H5FO code might need to be switched around - * to storing pointers to the objects being tracked (H5D_t, H5G_t, - * etc) and reference count those itself instead of relying on the - * reference counting in the H5I layer. Then, the "force" flag can - * be put back to false. - * - * Setting the "force" flag to true for all the interfaces won't - * work because the "file driver" (H5FD) APIs use the H5I reference - * counting to avoid closing a file driver out from underneath an - * open file... - * - * QAK - 5/13/03 - */ - (void)H5I_clear_type(H5I_DATASET, TRUE, FALSE); - n++; /*H5I*/ - } /* end if */ - - /* Mark closed */ - if (0 == n) - H5D_top_package_initialize_s = FALSE; - } /* end if */ + if (H5I_nmembers(H5I_DATASET) > 0) { + /* The dataset API uses the "force" flag set to true because it + * is using the "file objects" (H5FO) API functions to track open + * objects in the file. Using the H5FO code means that dataset + * IDs can have reference counts >1, when an existing dataset is + * opened more than once. However, the H5I code does not attempt + * to close objects with reference counts>1 unless the "force" flag + * is set to true. + * + * At some point (probably after the group and datatypes use the + * the H5FO code), the H5FO code might need to be switched around + * to storing pointers to the objects being tracked (H5D_t, H5G_t, + * etc) and reference count those itself instead of relying on the + * reference counting in the H5I layer. Then, the "force" flag can + * be put back to false. + * + * Setting the "force" flag to true for all the interfaces won't + * work because the "file driver" (H5FD) APIs use the H5I reference + * counting to avoid closing a file driver out from underneath an + * open file... + * + * QAK - 5/13/03 + */ + (void)H5I_clear_type(H5I_DATASET, TRUE, FALSE); + n++; /*H5I*/ + } FUNC_LEAVE_NOAPI(n) } /* end H5D_top_term_package() */ @@ -304,18 +265,11 @@ H5D_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5_PKG_INIT_VAR) { - /* Sanity checks */ - HDassert(0 == H5I_nmembers(H5I_DATASET)); - HDassert(FALSE == H5D_top_package_initialize_s); - - /* Destroy the dataset object id group */ - n += (H5I_dec_type_ref(H5I_DATASET) > 0); + /* Sanity checks */ + HDassert(0 == H5I_nmembers(H5I_DATASET)); - /* Mark closed */ - if (0 == n) - H5_PKG_INIT_VAR = FALSE; - } /* end if */ + /* Destroy the dataset object id group */ + n += (H5I_dec_type_ref(H5I_DATASET) > 0); FUNC_LEAVE_NOAPI(n) } /* end H5D_term_package() */ diff --git a/src/H5Dvirtual.c b/src/H5Dvirtual.c index 4012188..95c6056 100644 --- a/src/H5Dvirtual.c +++ b/src/H5Dvirtual.c @@ -1304,7 +1304,7 @@ H5D_virtual_free_parsed_name(H5O_storage_virtual_name_seg_t *name_seg) H5O_storage_virtual_name_seg_t *next_seg; herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR /* Walk name segments, freeing them */ while (name_seg) { @@ -1314,7 +1314,6 @@ H5D_virtual_free_parsed_name(H5O_storage_virtual_name_seg_t *name_seg) name_seg = next_seg; } /* end while */ -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_virtual_free_parsed_name() */ @@ -92,9 +92,6 @@ static herr_t H5E__append_stack(H5E_t *dst_estack, const H5E_t *src_stack); /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ @@ -141,46 +138,19 @@ static const H5I_class_t H5I_ERRSTK_CLS[1] = {{ * * Purpose: Initialize the interface from some other layer. * - * Return: SUCCEED/FAIL - * - * Programmer: Quincey Koziol - * Tuesday, June 29, 2004 - * + * Return: Success: non-negative + * Failure: negative *------------------------------------------------------------------------- */ herr_t H5E_init(void) { - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - /* FUNC_ENTER() does all the work */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5E_init() */ - -/*-------------------------------------------------------------------------- - * Function: H5E__init_package - * - * Purpose: Initialize interface-specific information - * - * Return: SUCCEED/FAIL - * - * Programmer: Raymond Lu - * Friday, July 11, 2003 - * - *-------------------------------------------------------------------------- - */ -herr_t -H5E__init_package(void) -{ H5E_cls_t *cls; /* Pointer to error class */ H5E_msg_t *msg; /* Pointer to new error message */ char lib_vers[128]; /* Buffer to constructu library version within */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_PACKAGE + FUNC_ENTER_NOAPI(FAIL) /* Initialize the ID group for the error class IDs */ if (H5I_register_type(H5I_ERRCLS_CLS) < 0) @@ -213,7 +183,7 @@ H5E__init_package(void) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5E__init_package() */ +} /*------------------------------------------------------------------------- * Function: H5E_term_package @@ -237,66 +207,61 @@ H5E_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5_PKG_INIT_VAR) { - int64_t ncls, nmsg, nstk; - - /* Check if there are any open error stacks, classes or messages */ - ncls = H5I_nmembers(H5I_ERROR_CLASS); - nmsg = H5I_nmembers(H5I_ERROR_MSG); - nstk = H5I_nmembers(H5I_ERROR_STACK); - - if ((ncls + nmsg + nstk) > 0) { - /* Clear the default error stack. Note that - * the following H5I_clear_type calls do not - * force the clears and will not be able to - * clear any error message IDs that are still - * in use by the default error stack unless we - * clear that stack manually. - * - * Error message IDs will typically still be - * in use by the default error stack when the - * application does H5E_BEGIN/END_TRY cleanup - * at the very end. - */ - H5E_clear_stack(NULL); - - /* Clear any outstanding error stacks */ - if (nstk > 0) - (void)H5I_clear_type(H5I_ERROR_STACK, FALSE, FALSE); - - /* Clear all the error classes */ - if (ncls > 0) { - (void)H5I_clear_type(H5I_ERROR_CLASS, FALSE, FALSE); - - /* Reset the HDF5 error class, if its been closed */ - if (H5I_nmembers(H5I_ERROR_CLASS) == 0) - H5E_ERR_CLS_g = -1; - } /* end if */ + int64_t ncls, nmsg, nstk; + + /* Check if there are any open error stacks, classes or messages */ + ncls = H5I_nmembers(H5I_ERROR_CLASS); + nmsg = H5I_nmembers(H5I_ERROR_MSG); + nstk = H5I_nmembers(H5I_ERROR_STACK); + + if ((ncls + nmsg + nstk) > 0) { + /* Clear the default error stack. Note that + * the following H5I_clear_type calls do not + * force the clears and will not be able to + * clear any error message IDs that are still + * in use by the default error stack unless we + * clear that stack manually. + * + * Error message IDs will typically still be + * in use by the default error stack when the + * application does H5E_BEGIN/END_TRY cleanup + * at the very end. + */ + H5E_clear_stack(NULL); + + /* Clear any outstanding error stacks */ + if (nstk > 0) + (void)H5I_clear_type(H5I_ERROR_STACK, FALSE, FALSE); + + /* Clear all the error classes */ + if (ncls > 0) { + (void)H5I_clear_type(H5I_ERROR_CLASS, FALSE, FALSE); - /* Clear all the error messages */ - if (nmsg > 0) { - (void)H5I_clear_type(H5I_ERROR_MSG, FALSE, FALSE); + /* Reset the HDF5 error class, if its been closed */ + if (H5I_nmembers(H5I_ERROR_CLASS) == 0) + H5E_ERR_CLS_g = -1; + } /* end if */ - /* Reset the HDF5 error messages, if they've been closed */ - if (H5I_nmembers(H5I_ERROR_MSG) == 0) { + /* Clear all the error messages */ + if (nmsg > 0) { + (void)H5I_clear_type(H5I_ERROR_MSG, FALSE, FALSE); + + /* Reset the HDF5 error messages, if they've been closed */ + if (H5I_nmembers(H5I_ERROR_MSG) == 0) { /* Include the automatically generated error code termination */ #include "H5Eterm.h" - } /* end if */ - } /* end if */ - - n++; /*H5I*/ - } /* end if */ - else { - /* Destroy the error class, message, and stack id groups */ - n += (H5I_dec_type_ref(H5I_ERROR_STACK) > 0); - n += (H5I_dec_type_ref(H5I_ERROR_CLASS) > 0); - n += (H5I_dec_type_ref(H5I_ERROR_MSG) > 0); - - /* Mark closed */ - if (0 == n) - H5_PKG_INIT_VAR = FALSE; - } /* end else */ - } /* end if */ + } /* end if */ + } /* end if */ + + n++; /*H5I*/ + } /* end if */ + else { + /* Destroy the error class, message, and stack id groups */ + n += (H5I_dec_type_ref(H5I_ERROR_STACK) > 0); + n += (H5I_dec_type_ref(H5I_ERROR_CLASS) > 0); + n += (H5I_dec_type_ref(H5I_ERROR_MSG) > 0); + + } /* end else */ FUNC_LEAVE_NOAPI(n) } /* end H5E_term_package() */ @@ -75,9 +75,6 @@ static H5EA_t *H5EA__new(H5F_t *f, haddr_t ea_addr, hbool_t from_open, void *ctx /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /* Extensible array client ID to class mapping */ /* Remember to add client ID to H5EA_cls_id_t in H5EAprivate.h when adding a new diff --git a/src/H5ESint.c b/src/H5ESint.c index 6f9efe9..c66be16 100644 --- a/src/H5ESint.c +++ b/src/H5ESint.c @@ -95,9 +95,6 @@ static int H5ES__close_failed_cb(H5ES_event_t *ev, void *_ctx); /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ @@ -118,23 +115,20 @@ static const H5I_class_t H5I_EVENTSET_CLS[1] = {{ H5FL_DEFINE_STATIC(H5ES_t); /*------------------------------------------------------------------------- - * Function: H5ES__init_package - * - * Purpose: Initializes any interface-specific data or routines. - * - * Return: Non-negative on success / Negative on failure + * Function: H5ES_init * - * Programmer: Quincey Koziol - * Monday, April 6, 2020 + * Purpose: Initialize the interface from some other layer. * + * Return: Success: non-negative + * Failure: negative *------------------------------------------------------------------------- */ herr_t -H5ES__init_package(void) +H5ES_init(void) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_PACKAGE + FUNC_ENTER_NOAPI(FAIL) /* Initialize the ID group for the event set IDs */ if (H5I_register_type(H5I_EVENTSET_CLS) < 0) @@ -142,7 +136,7 @@ H5ES__init_package(void) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5ES__init_package() */ +} /*------------------------------------------------------------------------- * Function: H5ES_term_package @@ -165,14 +159,8 @@ H5ES_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5_PKG_INIT_VAR) { - /* Destroy the event set ID group */ - n += (H5I_dec_type_ref(H5I_EVENTSET) > 0); - - /* Mark closed */ - if (0 == n) - H5_PKG_INIT_VAR = FALSE; - } /* end if */ + /* Destroy the event set ID group */ + n += (H5I_dec_type_ref(H5I_EVENTSET) > 0); FUNC_LEAVE_NOAPI(n) } /* end H5ES_term_package() */ diff --git a/src/H5ESprivate.h b/src/H5ESprivate.h index 3d9ce9f..153e3e3 100644 --- a/src/H5ESprivate.h +++ b/src/H5ESprivate.h @@ -51,5 +51,6 @@ typedef struct H5ES_t H5ES_t; /***************************************/ herr_t H5ES_insert(hid_t es_id, H5VL_t *connector, void *token, const char *caller, const char *caller_args, ...); +H5_DLL herr_t H5ES_init(void); #endif /* H5ESprivate_H */ diff --git a/src/H5Eint.c b/src/H5Eint.c index 6438cd9..d744db3 100644 --- a/src/H5Eint.c +++ b/src/H5Eint.c @@ -930,7 +930,7 @@ H5E_dump_api_stack(hbool_t is_api) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR /* Only dump the error stack during an API call */ if (is_api) { @@ -953,6 +953,5 @@ H5E_dump_api_stack(hbool_t is_api) #endif /* H5_NO_DEPRECATED_SYMBOLS */ } /* end if */ -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5E_dump_api_stack() */ @@ -64,9 +64,6 @@ static H5FA_t *H5FA__new(H5F_t *f, haddr_t fa_addr, hbool_t from_open, void *ctx /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /* Fixed array client ID to class mapping */ /* Remember to add client ID to H5FA_cls_id_t in H5FAprivate.h when adding a new @@ -61,9 +61,6 @@ static herr_t H5FD__query(const H5FD_t *f, unsigned long *flags /*out*/); /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ @@ -95,20 +92,20 @@ static const H5I_class_t H5I_VFL_CLS[1] = {{ }}; /*------------------------------------------------------------------------- - * Function: H5FD__init_package - * - * Purpose: Initialize the virtual file layer. + * Function: H5FD_init * - * Return: SUCCEED/FAIL + * Purpose: Initialize the interface from some other layer. * + * Return: Success: non-negative + * Failure: negative *------------------------------------------------------------------------- */ herr_t -H5FD__init_package(void) +H5FD_init(void) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_PACKAGE + FUNC_ENTER_NOAPI(FAIL) if (H5I_register_type(H5I_VFL_CLS) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize interface") @@ -118,7 +115,7 @@ H5FD__init_package(void) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD__init_package() */ +} /*------------------------------------------------------------------------- * Function: H5FD_term_package @@ -142,20 +139,14 @@ H5FD_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5_PKG_INIT_VAR) { - if (H5I_nmembers(H5I_VFL) > 0) { - (void)H5I_clear_type(H5I_VFL, FALSE, FALSE); - n++; /*H5I*/ - } /* end if */ - else { - /* Destroy the VFL driver ID group */ - n += (H5I_dec_type_ref(H5I_VFL) > 0); - - /* Mark closed */ - if (0 == n) - H5_PKG_INIT_VAR = FALSE; - } /* end else */ - } /* end if */ + if (H5I_nmembers(H5I_VFL) > 0) { + (void)H5I_clear_type(H5I_VFL, FALSE, FALSE); + n++; /*H5I*/ + } /* end if */ + else { + /* Destroy the VFL driver ID group */ + n += (H5I_dec_type_ref(H5I_VFL) > 0); + } /* end else */ FUNC_LEAVE_NOAPI(n) } /* end H5FD_term_package() */ @@ -165,7 +156,7 @@ H5FD_term_package(void) * * Purpose: Frees a file driver class struct and returns an indication of * success. This function is used as the free callback for the - * virtual file layer object identifiers (cf H5FD__init_package). + * virtual file layer object identifiers (cf H5FD_init). * * Return: SUCCEED/FAIL * @@ -454,7 +445,7 @@ H5FD_sb_size(H5FD_t *file) { hsize_t ret_value = 0; - FUNC_ENTER_NOAPI(0) + FUNC_ENTER_NOAPI_NOERR /* Sanity checks */ HDassert(file); @@ -464,7 +455,6 @@ H5FD_sb_size(H5FD_t *file) if (file->cls->sb_size) ret_value = (file->cls->sb_size)(file); -done: FUNC_LEAVE_NOAPI(ret_value) } @@ -592,7 +582,7 @@ H5FD_fapl_get(H5FD_t *file) { void *ret_value = NULL; - FUNC_ENTER_NOAPI(NULL) + FUNC_ENTER_NOAPI_NOERR /* Sanity checks */ HDassert(file); @@ -602,7 +592,6 @@ H5FD_fapl_get(H5FD_t *file) if (file->cls->fapl_get) ret_value = (file->cls->fapl_get)(file); -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_fapl_get() */ @@ -939,10 +928,9 @@ H5FD_cmp(const H5FD_t *f1, const H5FD_t *f2) { int ret_value = -1; /* Return value */ - FUNC_ENTER_NOAPI(-1) /* return value is arbitrary */ + FUNC_ENTER_NOAPI_NOERR /* return value is arbitrary */ - if ((!f1 || !f1->cls) && (!f2 || !f2->cls)) - HGOTO_DONE(0) + if ((!f1 || !f1->cls) && (!f2 || !f2->cls)) HGOTO_DONE(0) if (!f1 || !f1->cls) HGOTO_DONE(-1) if (!f2 || !f2->cls) @@ -1300,7 +1288,7 @@ H5FD_get_maxaddr(const H5FD_t *file) { haddr_t ret_value = HADDR_UNDEF; /* Return value */ - FUNC_ENTER_NOAPI(HADDR_UNDEF) + FUNC_ENTER_NOAPI_NOERR /* Sanity checks */ HDassert(file); @@ -1308,7 +1296,6 @@ H5FD_get_maxaddr(const H5FD_t *file) /* Set return value */ ret_value = file->maxaddr; -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_get_maxaddr() */ diff --git a/src/H5FDcore.c b/src/H5FDcore.c index 4b79de7..9d0d30a 100644 --- a/src/H5FDcore.c +++ b/src/H5FDcore.c @@ -442,39 +442,6 @@ H5FD__core_get_default_config(void) } /* end H5FD__core_get_default_config() */ /*------------------------------------------------------------------------- - * Function: H5FD__init_package - * - * Purpose: Initializes any interface-specific data or routines. - * - * Return: Non-negative on success/Negative on failure - * - *------------------------------------------------------------------------- - */ -static herr_t -H5FD__init_package(void) -{ - char * lock_env_var = NULL; /* Environment variable pointer */ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_STATIC - - /* Check the use disabled file locks environment variable */ - lock_env_var = HDgetenv(HDF5_USE_FILE_LOCKING); - if (lock_env_var && !HDstrcmp(lock_env_var, "BEST_EFFORT")) - ignore_disabled_file_locks_s = TRUE; /* Override: Ignore disabled locks */ - else if (lock_env_var && (!HDstrcmp(lock_env_var, "TRUE") || !HDstrcmp(lock_env_var, "1"))) - ignore_disabled_file_locks_s = FALSE; /* Override: Don't ignore disabled locks */ - else - ignore_disabled_file_locks_s = FAIL; /* Environment variable not set, or not set correctly */ - - if (H5FD_core_init() < 0) - HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize core VFD") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5FD__init_package() */ - -/*------------------------------------------------------------------------- * Function: H5FD_core_init * * Purpose: Initialize this driver by registering the driver with the @@ -491,10 +458,20 @@ done: hid_t H5FD_core_init(void) { - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + char *lock_env_var = NULL; /* Environment variable pointer */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(H5I_INVALID_HID) + /* Check the use disabled file locks environment variable */ + lock_env_var = HDgetenv(HDF5_USE_FILE_LOCKING); + if (lock_env_var && !HDstrcmp(lock_env_var, "BEST_EFFORT")) + ignore_disabled_file_locks_s = TRUE; /* Override: Ignore disabled locks */ + else if (lock_env_var && (!HDstrcmp(lock_env_var, "TRUE") || !HDstrcmp(lock_env_var, "1"))) + ignore_disabled_file_locks_s = FALSE; /* Override: Don't ignore disabled locks */ + else + ignore_disabled_file_locks_s = FAIL; /* Environment variable not set, or not set correctly */ + if (H5I_VFL != H5I_get_type(H5FD_CORE_g)) H5FD_CORE_g = H5FD_register(&H5FD_core_g, sizeof(H5FD_class_t), FALSE); diff --git a/src/H5FDcore.h b/src/H5FDcore.h index 590478e..4067980 100644 --- a/src/H5FDcore.h +++ b/src/H5FDcore.h @@ -20,7 +20,7 @@ #ifndef H5FDcore_H #define H5FDcore_H -#define H5FD_CORE (H5FD_core_init()) +#define H5FD_CORE (H5FDperform_init(H5FD_core_init)) #define H5FD_CORE_VALUE H5_VFD_CORE #ifdef __cplusplus diff --git a/src/H5FDdevelop.h b/src/H5FDdevelop.h index e897eb0..938f7f6 100644 --- a/src/H5FDdevelop.h +++ b/src/H5FDdevelop.h @@ -235,6 +235,7 @@ struct H5FD_t { extern "C" { #endif +H5_DLL hid_t H5FDperform_init(hid_t (*)(void)); H5_DLL hid_t H5FDregister(const H5FD_class_t *cls); H5_DLL htri_t H5FDis_driver_registered_by_name(const char *driver_name); H5_DLL htri_t H5FDis_driver_registered_by_value(H5FD_class_value_t driver_value); diff --git a/src/H5FDdirect.c b/src/H5FDdirect.c index 8c5001c..d07d909 100644 --- a/src/H5FDdirect.c +++ b/src/H5FDdirect.c @@ -182,42 +182,6 @@ static const H5FD_class_t H5FD_direct_g = { /* Declare a free list to manage the H5FD_direct_t struct */ H5FL_DEFINE_STATIC(H5FD_direct_t); -/*-------------------------------------------------------------------------- -NAME - H5FD__init_package -- Initialize interface-specific information -USAGE - herr_t H5FD__init_package() -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. (Just calls - H5FD_direct_init currently). - ---------------------------------------------------------------------------*/ -static herr_t -H5FD__init_package(void) -{ - char * lock_env_var = NULL; /* Environment variable pointer */ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_STATIC - - /* Check the use disabled file locks environment variable */ - lock_env_var = HDgetenv(HDF5_USE_FILE_LOCKING); - if (lock_env_var && !HDstrcmp(lock_env_var, "BEST_EFFORT")) - ignore_disabled_file_locks_s = TRUE; /* Override: Ignore disabled locks */ - else if (lock_env_var && (!HDstrcmp(lock_env_var, "TRUE") || !HDstrcmp(lock_env_var, "1"))) - ignore_disabled_file_locks_s = FALSE; /* Override: Don't ignore disabled locks */ - else - ignore_disabled_file_locks_s = FAIL; /* Environment variable not set, or not set correctly */ - - if (H5FD_direct_init() < 0) - HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize direct VFD") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5FD__init_package() */ - /*------------------------------------------------------------------------- * Function: H5FD_direct_init * @@ -235,10 +199,20 @@ done: hid_t H5FD_direct_init(void) { - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + char *lock_env_var = NULL; /* Environment variable pointer */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(H5I_INVALID_HID) + /* Check the use disabled file locks environment variable */ + lock_env_var = HDgetenv(HDF5_USE_FILE_LOCKING); + if (lock_env_var && !HDstrcmp(lock_env_var, "BEST_EFFORT")) + ignore_disabled_file_locks_s = TRUE; /* Override: Ignore disabled locks */ + else if (lock_env_var && (!HDstrcmp(lock_env_var, "TRUE") || !HDstrcmp(lock_env_var, "1"))) + ignore_disabled_file_locks_s = FALSE; /* Override: Don't ignore disabled locks */ + else + ignore_disabled_file_locks_s = FAIL; /* Environment variable not set, or not set correctly */ + if (H5I_VFL != H5I_get_type(H5FD_DIRECT_g)) H5FD_DIRECT_g = H5FD_register(&H5FD_direct_g, sizeof(H5FD_class_t), FALSE); diff --git a/src/H5FDdirect.h b/src/H5FDdirect.h index a439e55..bfad16a 100644 --- a/src/H5FDdirect.h +++ b/src/H5FDdirect.h @@ -21,7 +21,7 @@ #define H5FDdirect_H #ifdef H5_HAVE_DIRECT -#define H5FD_DIRECT (H5FD_direct_init()) +#define H5FD_DIRECT (H5FDperform_init(H5FD_direct_init)) #define H5FD_DIRECT_VALUE H5_VFD_DIRECT #else #define H5FD_DIRECT (H5I_INVALID_HID) diff --git a/src/H5FDfamily.c b/src/H5FDfamily.c index d187b7b..e51b6eb 100644 --- a/src/H5FDfamily.c +++ b/src/H5FDfamily.c @@ -265,32 +265,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__family_get_default_printf_filename() */ -/*-------------------------------------------------------------------------- -NAME - H5FD__init_package -- Initialize interface-specific information -USAGE - herr_t H5FD__init_package() -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. (Just calls - H5FD_family_init currently). - ---------------------------------------------------------------------------*/ -static herr_t -H5FD__init_package(void) -{ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_STATIC - - if (H5FD_family_init() < 0) - HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize family VFD") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5FD__init_package() */ - /*------------------------------------------------------------------------- * Function: H5FD_family_init * diff --git a/src/H5FDfamily.h b/src/H5FDfamily.h index 7b76a16..bd51f36 100644 --- a/src/H5FDfamily.h +++ b/src/H5FDfamily.h @@ -20,7 +20,7 @@ #ifndef H5FDfamily_H #define H5FDfamily_H -#define H5FD_FAMILY (H5FD_family_init()) +#define H5FD_FAMILY (H5FDperform_init(H5FD_family_init)) #define H5FD_FAMILY_VALUE H5_VFD_FAMILY #ifdef __cplusplus diff --git a/src/H5FDhdfs.c b/src/H5FDhdfs.c index bbaf42c..a101aa7 100644 --- a/src/H5FDhdfs.c +++ b/src/H5FDhdfs.c @@ -319,29 +319,6 @@ static const H5FD_class_t H5FD_hdfs_g = { H5FL_DEFINE_STATIC(H5FD_hdfs_t); /*------------------------------------------------------------------------- - * Function: H5FD__init_package - * - * Purpose: Initializes any interface-specific data or routines. - * - * Return: Non-negative on success/Negative on failure - * - *------------------------------------------------------------------------- - */ -static herr_t -H5FD__init_package(void) -{ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_STATIC - - if (H5FD_hdfs_init() < 0) - HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize hdfs VFD") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5FD__init_package() */ - -/*------------------------------------------------------------------------- * Function: H5FD_hdfs_init * * Purpose: Initialize this driver by registering the driver with the diff --git a/src/H5FDhdfs.h b/src/H5FDhdfs.h index a9f34a0..e401e81 100644 --- a/src/H5FDhdfs.h +++ b/src/H5FDhdfs.h @@ -22,7 +22,7 @@ #define H5FDhdfs_H #ifdef H5_HAVE_LIBHDFS -#define H5FD_HDFS (H5FD_hdfs_init()) +#define H5FD_HDFS (H5FDperform_init(H5FD_hdfs_init)) #define H5FD_HDFS_VALUE H5_VFD_HDFS #else /* H5_HAVE_LIBHDFS */ #define H5FD_HDFS (H5I_INVALID_HID) diff --git a/src/H5FDlog.c b/src/H5FDlog.c index 1828a88..8ea08bc 100644 --- a/src/H5FDlog.c +++ b/src/H5FDlog.c @@ -224,39 +224,6 @@ static const H5FD_log_fapl_t H5FD_log_default_config_g = {NULL, H5FD_LOG_LOC_IO H5FL_DEFINE_STATIC(H5FD_log_t); /*------------------------------------------------------------------------- - * Function: H5FD__init_package - * - * Purpose: Initializes any interface-specific data or routines. - * - * Return: Non-negative on success/Negative on failure - * - *------------------------------------------------------------------------- - */ -static herr_t -H5FD__init_package(void) -{ - char * lock_env_var = NULL; /* Environment variable pointer */ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_STATIC - - /* Check the use disabled file locks environment variable */ - lock_env_var = HDgetenv(HDF5_USE_FILE_LOCKING); - if (lock_env_var && !HDstrcmp(lock_env_var, "BEST_EFFORT")) - ignore_disabled_file_locks_s = TRUE; /* Override: Ignore disabled locks */ - else if (lock_env_var && (!HDstrcmp(lock_env_var, "TRUE") || !HDstrcmp(lock_env_var, "1"))) - ignore_disabled_file_locks_s = FALSE; /* Override: Don't ignore disabled locks */ - else - ignore_disabled_file_locks_s = FAIL; /* Environment variable not set, or not set correctly */ - - if (H5FD_log_init() < 0) - HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize log VFD") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5FD__init_package() */ - -/*------------------------------------------------------------------------- * Function: H5FD_log_init * * Purpose: Initialize this driver by registering the driver with the @@ -273,10 +240,20 @@ done: hid_t H5FD_log_init(void) { - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + char *lock_env_var = NULL; /* Environment variable pointer */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(H5I_INVALID_HID) + /* Check the use disabled file locks environment variable */ + lock_env_var = HDgetenv(HDF5_USE_FILE_LOCKING); + if (lock_env_var && !HDstrcmp(lock_env_var, "BEST_EFFORT")) + ignore_disabled_file_locks_s = TRUE; /* Override: Ignore disabled locks */ + else if (lock_env_var && (!HDstrcmp(lock_env_var, "TRUE") || !HDstrcmp(lock_env_var, "1"))) + ignore_disabled_file_locks_s = FALSE; /* Override: Don't ignore disabled locks */ + else + ignore_disabled_file_locks_s = FAIL; /* Environment variable not set, or not set correctly */ + if (H5I_VFL != H5I_get_type(H5FD_LOG_g)) H5FD_LOG_g = H5FD_register(&H5FD_log_g, sizeof(H5FD_class_t), FALSE); diff --git a/src/H5FDlog.h b/src/H5FDlog.h index bc96c52..a916fec 100644 --- a/src/H5FDlog.h +++ b/src/H5FDlog.h @@ -20,7 +20,7 @@ #ifndef H5FDlog_H #define H5FDlog_H -#define H5FD_LOG (H5FD_log_init()) +#define H5FD_LOG (H5FDperform_init(H5FD_log_init)) #define H5FD_LOG_VALUE H5_VFD_LOG /* Flags for H5Pset_fapl_log() */ diff --git a/src/H5FDmirror.c b/src/H5FDmirror.c index 738e9d5..52f07e6 100644 --- a/src/H5FDmirror.c +++ b/src/H5FDmirror.c @@ -206,30 +206,6 @@ H5FL_DEFINE_STATIC(H5FD_mirror_t); /* Declare a free list to manage the H5FD_mirror_xmit_open_t struct */ H5FL_DEFINE_STATIC(H5FD_mirror_xmit_open_t); -/*------------------------------------------------------------------------- - * Function: H5FD__init_package - * - * Purpose: Initializes any interface-specific data or routines. - * - * Return: Non-negative on success/Negative on failure - *------------------------------------------------------------------------- - */ -static herr_t -H5FD__init_package(void) -{ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_STATIC - - LOG_OP_CALL(__func__); - - if (H5FD_mirror_init() < 0) - HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize mirror VFD"); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5FD__init_package() */ - /* ------------------------------------------------------------------------- * Function: H5FD_mirror_init * diff --git a/src/H5FDmirror.h b/src/H5FDmirror.h index 66954b1..2fdf6c4 100644 --- a/src/H5FDmirror.h +++ b/src/H5FDmirror.h @@ -19,7 +19,7 @@ #ifdef H5_HAVE_MIRROR_VFD -#define H5FD_MIRROR (H5FD_mirror_init()) +#define H5FD_MIRROR (H5FDperform_init(H5FD_mirror_init)) #define H5FD_MIRROR_VALUE H5_VFD_MIRROR #ifdef __cplusplus diff --git a/src/H5FDmpio.c b/src/H5FDmpio.c index f4d3fed..f8ac610 100644 --- a/src/H5FDmpio.c +++ b/src/H5FDmpio.c @@ -155,35 +155,6 @@ static int H5FD_mpio_debug_rank_s = -1; (H5FD_mpio_debug_rank_s < 0 || H5FD_mpio_debug_rank_s == (file)->mpi_rank) #endif -/*-------------------------------------------------------------------------- -NAME - H5FD__init_package -- Initialize interface-specific information - -USAGE - herr_t H5FD__init_package() - -RETURNS - SUCCEED/FAIL - -DESCRIPTION - Initializes any interface-specific data or routines. (Just calls - H5FD_mpio_init currently). - ---------------------------------------------------------------------------*/ -static herr_t -H5FD__init_package(void) -{ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_STATIC - - if (H5FD_mpio_init() < 0) - HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize mpio VFD") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5FD__init_package() */ - #ifdef H5FDmpio_DEBUG /*--------------------------------------------------------------------------- diff --git a/src/H5FDmpio.h b/src/H5FDmpio.h index 8caf11c..00dea1b 100644 --- a/src/H5FDmpio.h +++ b/src/H5FDmpio.h @@ -23,7 +23,7 @@ /* Macros */ #ifdef H5_HAVE_PARALLEL -#define H5FD_MPIO (H5FD_mpio_init()) +#define H5FD_MPIO (H5FDperform_init(H5FD_mpio_init)) #else #define H5FD_MPIO (H5I_INVALID_HID) #endif /* H5_HAVE_PARALLEL */ diff --git a/src/H5FDmulti.h b/src/H5FDmulti.h index 62cc9c8..7a01f4c 100644 --- a/src/H5FDmulti.h +++ b/src/H5FDmulti.h @@ -20,7 +20,7 @@ #ifndef H5FDmulti_H #define H5FDmulti_H -#define H5FD_MULTI (H5FD_multi_init()) +#define H5FD_MULTI (H5FDperform_init(H5FD_multi_init)) #ifdef __cplusplus extern "C" { diff --git a/src/H5FDperform.c b/src/H5FDperform.c new file mode 100644 index 0000000..096fdd6 --- /dev/null +++ b/src/H5FDperform.c @@ -0,0 +1,58 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/****************/ +/* Module Setup */ +/****************/ + +#include "H5FDmodule.h" /* This source code file is part of the H5FD module */ + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FDpkg.h" /* File Drivers */ +#include "H5Iprivate.h" /* IDs */ + +/*------------------------------------------------------------------------- + * Function: H5FDperform_init + * + * Purpose: Ensure that the library is initialized and then call + * the provided VFD initializer. + * + * Return: Success: identifier for the VFD just initialized + * Failure: H5I_INVALID_HID + *------------------------------------------------------------------------- + */ +hid_t H5FDperform_init(hid_t (*init)(void)) +{ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_API_NOINIT + /*NO TRACE*/ + + /* It is possible that an application will evaluate an + * `H5FD_*` symbol (`H5FD_FAMILY`, `H5FD_MULTI`, `H5FD_SEC2`, et + * cetera) before the library has had an opportunity to initialize. + * Call H5_init_library() to make sure that the library has been + * initialized before `init` is run. + */ + if (H5_init_library() < 0) { + HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, H5I_INVALID_HID, "library initialization failed") + } + + ret_value = init(); +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} diff --git a/src/H5FDprivate.h b/src/H5FDprivate.h index fa562f9..61b4c60 100644 --- a/src/H5FDprivate.h +++ b/src/H5FDprivate.h @@ -152,6 +152,8 @@ H5_DLL herr_t H5FD_set_base_addr(H5FD_t *file, haddr_t base_addr); H5_DLL haddr_t H5FD_get_base_addr(const H5FD_t *file); H5_DLL herr_t H5FD_set_paged_aggr(H5FD_t *file, hbool_t paged); +H5_DLL herr_t H5FD_init(void); + /* Function prototypes for MPI based VFDs*/ #ifdef H5_HAVE_PARALLEL /* General routines */ diff --git a/src/H5FDros3.c b/src/H5FDros3.c index 2ffee17..b2c9d21 100644 --- a/src/H5FDros3.c +++ b/src/H5FDros3.c @@ -278,31 +278,6 @@ static const H5FD_class_t H5FD_ros3_g = { H5FL_DEFINE_STATIC(H5FD_ros3_t); /*------------------------------------------------------------------------- - * Function: H5FD__init_package - * - * Purpose: Initializes any interface-specific data or routines. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Jacob Smith 2017 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5FD__init_package(void) -{ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_STATIC - - if (H5FD_ros3_init() < 0) - HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize ros3 VFD") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD__init_package() */ - -/*------------------------------------------------------------------------- * Function: H5FD_ros3_init * * Purpose: Initialize this driver by registering the driver with the diff --git a/src/H5FDros3.h b/src/H5FDros3.h index d69ebe4..4a623c4 100644 --- a/src/H5FDros3.h +++ b/src/H5FDros3.h @@ -22,7 +22,7 @@ #define H5FDros3_H #ifdef H5_HAVE_ROS3_VFD -#define H5FD_ROS3 (H5FD_ros3_init()) +#define H5FD_ROS3 (H5FDperform_init(H5FD_ros3_init)) #define H5FD_ROS3_VALUE H5_VFD_ROS3 #else #define H5FD_ROS3 (H5I_INVALID_HID) diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c index 2dbdd6f..ca29eea 100644 --- a/src/H5FDsec2.c +++ b/src/H5FDsec2.c @@ -184,39 +184,6 @@ static const H5FD_class_t H5FD_sec2_g = { H5FL_DEFINE_STATIC(H5FD_sec2_t); /*------------------------------------------------------------------------- - * Function: H5FD__init_package - * - * Purpose: Initializes any interface-specific data or routines. - * - * Return: Non-negative on success/Negative on failure - * - *------------------------------------------------------------------------- - */ -static herr_t -H5FD__init_package(void) -{ - char * lock_env_var = NULL; /* Environment variable pointer */ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_STATIC - - /* Check the use disabled file locks environment variable */ - lock_env_var = HDgetenv(HDF5_USE_FILE_LOCKING); - if (lock_env_var && !HDstrcmp(lock_env_var, "BEST_EFFORT")) - ignore_disabled_file_locks_s = TRUE; /* Override: Ignore disabled locks */ - else if (lock_env_var && (!HDstrcmp(lock_env_var, "TRUE") || !HDstrcmp(lock_env_var, "1"))) - ignore_disabled_file_locks_s = FALSE; /* Override: Don't ignore disabled locks */ - else - ignore_disabled_file_locks_s = FAIL; /* Environment variable not set, or not set correctly */ - - if (H5FD_sec2_init() < 0) - HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize sec2 VFD") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5FD__init_package() */ - -/*------------------------------------------------------------------------- * Function: H5FD_sec2_init * * Purpose: Initialize this driver by registering the driver with the @@ -233,10 +200,20 @@ done: hid_t H5FD_sec2_init(void) { - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + char *lock_env_var = NULL; /* Environment variable pointer */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(H5I_INVALID_HID) + /* Check the use disabled file locks environment variable */ + lock_env_var = HDgetenv(HDF5_USE_FILE_LOCKING); + if (lock_env_var && !HDstrcmp(lock_env_var, "BEST_EFFORT")) + ignore_disabled_file_locks_s = TRUE; /* Override: Ignore disabled locks */ + else if (lock_env_var && (!HDstrcmp(lock_env_var, "TRUE") || !HDstrcmp(lock_env_var, "1"))) + ignore_disabled_file_locks_s = FALSE; /* Override: Don't ignore disabled locks */ + else + ignore_disabled_file_locks_s = FAIL; /* Environment variable not set, or not set correctly */ + if (H5I_VFL != H5I_get_type(H5FD_SEC2_g)) H5FD_SEC2_g = H5FD_register(&H5FD_sec2_g, sizeof(H5FD_class_t), FALSE); diff --git a/src/H5FDsec2.h b/src/H5FDsec2.h index 5c35677..df4d4d4 100644 --- a/src/H5FDsec2.h +++ b/src/H5FDsec2.h @@ -20,7 +20,7 @@ #ifndef H5FDsec2_H #define H5FDsec2_H -#define H5FD_SEC2 (H5FD_sec2_init()) +#define H5FD_SEC2 (H5FDperform_init(H5FD_sec2_init)) #define H5FD_SEC2_VALUE H5_VFD_SEC2 #ifdef __cplusplus diff --git a/src/H5FDsplitter.c b/src/H5FDsplitter.c index 321973e..98d4488 100644 --- a/src/H5FDsplitter.c +++ b/src/H5FDsplitter.c @@ -182,30 +182,6 @@ H5FL_DEFINE_STATIC(H5FD_splitter_t); H5FL_DEFINE_STATIC(H5FD_splitter_fapl_t); /*------------------------------------------------------------------------- - * Function: H5FD__init_package - * - * Purpose: Initializes any interface-specific data or routines. - * - * Return: SUCCEED/FAIL - *------------------------------------------------------------------------- - */ -static herr_t -H5FD__init_package(void) -{ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_STATIC - - H5FD_SPLITTER_LOG_CALL(__func__); - - if (H5FD_splitter_init() < 0) - HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize splitter VFD") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5FD__init_package() */ - -/*------------------------------------------------------------------------- * Function: H5FD_splitter_init * * Purpose: Initialize the splitter driver by registering it with the diff --git a/src/H5FDsplitter.h b/src/H5FDsplitter.h index 3a743e4..6463158 100644 --- a/src/H5FDsplitter.h +++ b/src/H5FDsplitter.h @@ -17,7 +17,7 @@ #ifndef H5FDsplitter_H #define H5FDsplitter_H -#define H5FD_SPLITTER (H5FD_splitter_init()) +#define H5FD_SPLITTER (H5FDperform_init(H5FD_splitter_init)) #define H5FD_SPLITTER_VALUE H5_VFD_SPLITTER /* The version of the H5FD_splitter_vfd_config_t structure used */ diff --git a/src/H5FDstdio.h b/src/H5FDstdio.h index 9db92ed..484c6ea 100644 --- a/src/H5FDstdio.h +++ b/src/H5FDstdio.h @@ -22,7 +22,7 @@ #include "H5Ipublic.h" -#define H5FD_STDIO (H5FD_stdio_init()) +#define H5FD_STDIO (H5FDperform_init(H5FD_stdio_init)) #ifdef __cplusplus extern "C" { @@ -114,9 +114,6 @@ struct H5FL_fac_node_t { struct H5FL_fac_node_t *next; /* Pointer to next block in free list */ }; -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /* The head of the list of factory things to garbage collect */ static H5FL_fac_gc_list_t H5FL_fac_gc_head = {0, NULL}; @@ -184,20 +181,15 @@ H5FL_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5_PKG_INIT_VAR) { /* Garbage collect any nodes on the free lists */ - (void)H5FL_garbage_coll(); - - /* Shut down the various kinds of free lists */ - n += H5FL__reg_term(); - n += H5FL__fac_term_all(); - n += H5FL__arr_term(); - n += H5FL__blk_term(); - - /* Mark interface closed */ - if (0 == n) - H5_PKG_INIT_VAR = FALSE; - } /* end if */ + (void) + H5FL_garbage_coll(); + + /* Shut down the various kinds of free lists */ + n += H5FL__reg_term(); + n += H5FL__fac_term_all(); + n += H5FL__arr_term(); + n += H5FL__blk_term(); #ifdef H5FL_TRACK /* If we haven't freed all the allocated memory, dump out the list now */ @@ -61,9 +61,6 @@ static herr_t H5FS__sinfo_free_node_cb(void *item, void *key, void *op_data); /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /* Declare a free list to manage the H5FS_section_class_t sequence information */ H5FL_SEQ_DEFINE(H5FS_section_class_t); diff --git a/src/H5FSint.c b/src/H5FSint.c index 0ab975b..d7950ab 100644 --- a/src/H5FSint.c +++ b/src/H5FSint.c @@ -68,31 +68,6 @@ /*******************/ /*------------------------------------------------------------------------- - * Function: H5FS_init - * - * Purpose: Initialize the interface in case it is unable to initialize - * itself soon enough. - * - * Return: Success: non-negative - * Failure: negative - * - * Programmer: Quincey Koziol - * Saturday, March 4, 2000 - * - *------------------------------------------------------------------------- - */ -herr_t -H5FS_init(void) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOERR - /* FUNC_ENTER() does all the work */ - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FS_init() */ - -/*------------------------------------------------------------------------- * Function: H5FS__create_flush_depend * * Purpose: Create a flush dependency between two data structure components diff --git a/src/H5FSprivate.h b/src/H5FSprivate.h index fdc5c91..718c4a7 100644 --- a/src/H5FSprivate.h +++ b/src/H5FSprivate.h @@ -186,9 +186,6 @@ H5FL_SEQ_EXTERN(H5FS_section_class_t); /* Library-private Function Prototypes */ /***************************************/ -/* Package initialization routine */ -H5_DLL herr_t H5FS_init(void); - /* Free space manager routines */ H5_DLL H5FS_t *H5FS_create(H5F_t *f, haddr_t *fs_addr, const H5FS_create_t *fs_create, uint16_t nclasses, const H5FS_section_class_t *classes[], void *cls_init_udata, hsize_t alignment, diff --git a/src/H5Fcwfs.c b/src/H5Fcwfs.c index d689737..43c8cf7 100644 --- a/src/H5Fcwfs.c +++ b/src/H5Fcwfs.c @@ -252,7 +252,7 @@ H5F_cwfs_advance_heap(H5F_t *f, H5HG_heap_t *heap, hbool_t add_heap) unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR /* Check args */ HDassert(f); @@ -272,7 +272,6 @@ H5F_cwfs_advance_heap(H5F_t *f, H5HG_heap_t *heap, hbool_t add_heap) f->shared->cwfs[f->shared->ncwfs - 1] = heap; } /* end if */ -done: FUNC_LEAVE_NOAPI(ret_value) } /* H5F_cwfs_advance_heap() */ @@ -295,7 +294,7 @@ H5F_cwfs_remove_heap(H5F_shared_t *shared, H5HG_heap_t *heap) unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR /* Check args */ HDassert(shared); @@ -310,6 +309,5 @@ H5F_cwfs_remove_heap(H5F_shared_t *shared, H5HG_heap_t *heap) } /* end if */ } /* end for */ -done: FUNC_LEAVE_NOAPI(ret_value) } /* H5F_cwfs_remove_heap() */ diff --git a/src/H5Fint.c b/src/H5Fint.c index d772088..b9be873 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -91,9 +91,6 @@ static herr_t H5F__flush_phase2(H5F_t *f, hbool_t closing); /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /* Based on the value of the HDF5_USE_FILE_LOCKING environment variable. * TRUE/FALSE have obvious meanings. FAIL means the environment variable was * not set, so the code should ignore it and use the fapl value instead. @@ -138,29 +135,6 @@ H5F_init(void) herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - /* FUNC_ENTER() does all the work */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5F_init() */ - -/*-------------------------------------------------------------------------- -NAME - H5F__init_package -- Initialize interface-specific information -USAGE - herr_t H5F__init_package() -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. - ---------------------------------------------------------------------------*/ -herr_t -H5F__init_package(void) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE /* Initialize the ID group for the file IDs */ if (H5I_register_type(H5I_FILE_CLS) < 0) @@ -172,7 +146,7 @@ H5F__init_package(void) done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5F__init_package() */ +} /* end H5F_init() */ /*------------------------------------------------------------------------- * Function: H5F_term_package @@ -196,23 +170,17 @@ H5F_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5_PKG_INIT_VAR) { - if (H5I_nmembers(H5I_FILE) > 0) { - (void)H5I_clear_type(H5I_FILE, FALSE, FALSE); - n++; /*H5I*/ - } /* end if */ - else { - /* Make certain we've cleaned up all the shared file objects */ - H5F_sfile_assert_num(0); - - /* Destroy the file object id group */ - n += (H5I_dec_type_ref(H5I_FILE) > 0); + if (H5I_nmembers(H5I_FILE) > 0) { + (void)H5I_clear_type(H5I_FILE, FALSE, FALSE); + n++; /*H5I*/ + } /* end if */ + else { + /* Make certain we've cleaned up all the shared file objects */ + H5F_sfile_assert_num(0); - /* Mark closed */ - if (0 == n) - H5_PKG_INIT_VAR = FALSE; - } /* end else */ - } /* end if */ + /* Destroy the file object id group */ + n += (H5I_dec_type_ref(H5I_FILE) > 0); + } /* end else */ FUNC_LEAVE_NOAPI(n) } /* end H5F_term_package() */ diff --git a/src/H5Gint.c b/src/H5Gint.c index 90a2c6b..ba0cb6d 100644 --- a/src/H5Gint.c +++ b/src/H5Gint.c @@ -91,9 +91,6 @@ static herr_t H5G__close_cb(H5VL_object_t *grp_vol_obj, void **request); /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /* Declare a free list to manage the H5G_t struct */ H5FL_DEFINE(H5G_t); H5FL_DEFINE(H5G_shared_t); @@ -117,9 +114,6 @@ static const H5I_class_t H5I_GROUP_CLS[1] = {{ (H5I_free_t)H5G__close_cb /* Callback routine for closing objects of this class */ }}; -/* Flag indicating "top" of interface has been initialized */ -static hbool_t H5G_top_package_initialize_s = FALSE; - /*------------------------------------------------------------------------- * Function: H5G_init * @@ -136,48 +130,13 @@ H5G_init(void) herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - /* FUNC_ENTER() does all the work */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_init() */ - -/*------------------------------------------------------------------------- - * Function: H5G__init_package - * - * Purpose: Initializes the H5G interface. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Robb Matzke - * Monday, January 5, 1998 - * - * Notes: The group creation properties are registered in the property - * list interface initialization routine (H5P_init_package) - * so that the file creation property class can inherit from it - * correctly. (Which allows the file creation property list to - * control the group creation properties of the root group of - * a file) QAK - 24/10/2005 - * - *------------------------------------------------------------------------- - */ -herr_t -H5G__init_package(void) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - /* Initialize the ID group for the group IDs */ if (H5I_register_type(H5I_GROUP_CLS) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to initialize interface") - /* Mark "top" of interface as initialized, too */ - H5G_top_package_initialize_s = TRUE; - done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G__init_package() */ +} /* end H5G_init() */ /*------------------------------------------------------------------------- * Function: H5G_top_term_package @@ -200,16 +159,10 @@ H5G_top_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5G_top_package_initialize_s) { - if (H5I_nmembers(H5I_GROUP) > 0) { - (void)H5I_clear_type(H5I_GROUP, FALSE, FALSE); - n++; /*H5I*/ - } /* end if */ - - /* Mark closed */ - if (0 == n) - H5G_top_package_initialize_s = FALSE; - } /* end if */ + if (H5I_nmembers(H5I_GROUP) > 0) { + (void)H5I_clear_type(H5I_GROUP, FALSE, FALSE); + n++; + } FUNC_LEAVE_NOAPI(n) } /* end H5G_top_term_package() */ @@ -238,18 +191,11 @@ H5G_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5_PKG_INIT_VAR) { - /* Sanity checks */ - HDassert(0 == H5I_nmembers(H5I_GROUP)); - HDassert(FALSE == H5G_top_package_initialize_s); - - /* Destroy the group object id group */ - n += (H5I_dec_type_ref(H5I_GROUP) > 0); + /* Sanity checks */ + HDassert(0 == H5I_nmembers(H5I_GROUP)); - /* Mark closed */ - if (0 == n) - H5_PKG_INIT_VAR = FALSE; - } /* end if */ + /* Destroy the group object id group */ + n += (H5I_dec_type_ref(H5I_GROUP) > 0); FUNC_LEAVE_NOAPI(n) } /* end H5G_term_package() */ @@ -63,9 +63,6 @@ /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ @@ -84,9 +84,6 @@ static size_t H5HG__alloc(H5F_t *f, H5HG_heap_t *heap, size_t size, unsigned *h /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /* Declare a free list to manage the H5HG_heap_t struct */ H5FL_DEFINE(H5HG_heap_t); @@ -64,9 +64,6 @@ static herr_t H5HL__dirty(H5HL_t *heap); /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /* Declare a free list to manage the H5HL_free_t struct */ H5FL_DEFINE(H5HL_free_t); diff --git a/src/H5Iint.c b/src/H5Iint.c index 86a2810..1ea2ad7 100644 --- a/src/H5Iint.c +++ b/src/H5Iint.c @@ -85,9 +85,6 @@ static int H5I__find_id_cb(void *_item, void *_key, void *_udata); /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /* Declared extern in H5Ipkg.h and documented there */ H5I_type_info_t *H5I_type_info_array_g[H5I_MAX_NUM_TYPES]; int H5I_next_type_g = (int)H5I_NTYPES; @@ -127,30 +124,24 @@ H5I_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5_PKG_INIT_VAR) { - H5I_type_info_t *type_info = NULL; /* Pointer to ID type */ - int i; - - /* Count the number of types still in use */ - for (i = 0; i < H5I_next_type_g; i++) - if ((type_info = H5I_type_info_array_g[i]) && type_info->hash_table) + H5I_type_info_t *type_info = NULL; /* Pointer to ID type */ + int i; + + /* Count the number of types still in use */ + for (i = 0; i < H5I_next_type_g; i++) + if ((type_info = H5I_type_info_array_g[i]) && type_info->hash_table) + in_use++; + + /* If no types are still being used then clean up */ + if (0 == in_use) { + for (i = 0; i < H5I_next_type_g; i++) { + type_info = H5I_type_info_array_g[i]; + if (type_info) { + HDassert(NULL == type_info->hash_table); + type_info = H5MM_xfree(type_info); + H5I_type_info_array_g[i] = NULL; in_use++; - - /* If no types are still being used then clean up */ - if (0 == in_use) { - for (i = 0; i < H5I_next_type_g; i++) { - type_info = H5I_type_info_array_g[i]; - if (type_info) { - HDassert(NULL == type_info->hash_table); - type_info = H5MM_xfree(type_info); - H5I_type_info_array_g[i] = NULL; - in_use++; - } } - - /* Mark interface closed */ - if (0 == in_use) - H5_PKG_INIT_VAR = FALSE; } } diff --git a/src/H5Lint.c b/src/H5Lint.c index 346c37d..9e45124 100644 --- a/src/H5Lint.c +++ b/src/H5Lint.c @@ -175,9 +175,6 @@ static herr_t H5L__get_name_by_idx_cb(H5G_loc_t *grp_loc /*in*/, const char *nam /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ @@ -211,30 +208,6 @@ H5L_init(void) herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - /* FUNC_ENTER() does all the work */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5L_init() */ - -/*------------------------------------------------------------------------- - * Function: H5L__init_package - * - * Purpose: Initialize information specific to H5L interface. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: James Laird - * Tuesday, January 24, 2006 - * - *------------------------------------------------------------------------- - */ -herr_t -H5L__init_package(void) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE /* Initialize user-defined link classes */ if (H5L_register_external() < 0) @@ -242,12 +215,12 @@ H5L__init_package(void) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5L_init_package() */ +} /* end H5L_init() */ /*------------------------------------------------------------------------- * Function: H5L_term_package * - * Purpose: Terminate any resources allocated in H5L__init_package. + * Purpose: Terminate any resources allocated in H5L_init. * * Return: Non-negative on success/Negative on failure * @@ -263,17 +236,11 @@ H5L_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5_PKG_INIT_VAR) { - /* Free the table of link types */ - if (H5L_table_g) { - H5L_table_g = (H5L_class_t *)H5MM_xfree(H5L_table_g); - H5L_table_used_g = H5L_table_alloc_g = 0; - n++; - } /* end if */ - - /* Mark the interface as uninitialized */ - if (0 == n) - H5_PKG_INIT_VAR = FALSE; + /* Free the table of link types */ + if (H5L_table_g) { + H5L_table_g = (H5L_class_t *)H5MM_xfree(H5L_table_g); + H5L_table_used_g = H5L_table_alloc_g = 0; + n++; } /* end if */ FUNC_LEAVE_NOAPI(n) @@ -58,9 +58,6 @@ static herr_t H5M__get_api_common(hid_t map_id, hid_t key_mem_type_id, const voi /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ @@ -77,9 +74,6 @@ static const H5I_class_t H5I_MAP_CLS[1] = {{ (H5I_free_t)H5M__close_cb /* Callback routine for closing objects of this class */ }}; -/* Flag indicating "top" of interface has been initialized */ -static hbool_t H5M_top_package_initialize_s = FALSE; - /*------------------------------------------------------------------------- * Function: H5M_init * @@ -96,41 +90,14 @@ H5M_init(void) herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - /* FUNC_ENTER() does all the work */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5M_init() */ - -/*------------------------------------------------------------------------- -NAME - H5M__init_package -- Initialize interface-specific information -USAGE - herr_t H5M__init_package() - -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. ---------------------------------------------------------------------------- -*/ -herr_t -H5M__init_package(void) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE /* Initialize the ID group for the map IDs */ if (H5I_register_type(H5I_MAP_CLS) < 0) HGOTO_ERROR(H5E_MAP, H5E_CANTINIT, FAIL, "unable to initialize interface") - /* Mark "top" of interface as initialized, too */ - H5M_top_package_initialize_s = TRUE; - done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5M__init_package() */ +} /* end H5M_init() */ /*------------------------------------------------------------------------- * Function: H5M_top_term_package @@ -149,16 +116,10 @@ H5M_top_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5M_top_package_initialize_s) { - if (H5I_nmembers(H5I_MAP) > 0) { - (void)H5I_clear_type(H5I_MAP, FALSE, FALSE); - n++; /*H5I*/ - } /* end if */ - - /* Mark closed */ - if (0 == n) - H5M_top_package_initialize_s = FALSE; - } /* end if */ + if (H5I_nmembers(H5I_MAP) > 0) { + (void)H5I_clear_type(H5I_MAP, FALSE, FALSE); + n++; + } FUNC_LEAVE_NOAPI(n) } /* end H5M_top_term_package() */ @@ -183,18 +144,11 @@ H5M_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5_PKG_INIT_VAR) { - /* Sanity checks */ - HDassert(0 == H5I_nmembers(H5I_MAP)); - HDassert(FALSE == H5M_top_package_initialize_s); + /* Sanity checks */ + HDassert(0 == H5I_nmembers(H5I_MAP)); - /* Destroy the dataset object id group */ - n += (H5I_dec_type_ref(H5I_MAP) > 0); - - /* Mark closed */ - if (0 == n) - H5_PKG_INIT_VAR = FALSE; - } /* end if */ + /* Destroy the dataset object id group */ + n += (H5I_dec_type_ref(H5I_MAP) > 0); FUNC_LEAVE_NOAPI(n) } /* end H5M_term_package() */ @@ -115,9 +115,6 @@ static herr_t H5MF__sects_cb(H5FS_section_info_t *_sect, void *_udata); /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ @@ -58,9 +58,6 @@ /* Package Variable Definitions */ /********************************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /********************/ /* Static Variables */ /********************/ diff --git a/src/H5Oint.c b/src/H5Oint.c index f24d0bb..ee79b0c 100644 --- a/src/H5Oint.c +++ b/src/H5Oint.c @@ -82,9 +82,6 @@ static herr_t H5O__reset_info2(H5O_info2_t *oinfo); /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /* Header message ID to class mapping * * Remember to increment H5O_MSG_TYPES in H5Opkg.h when adding a new @@ -178,21 +175,20 @@ static const H5O_obj_class_t *const H5O_obj_class_g[] = { }; /*------------------------------------------------------------------------- - * Function: H5O__init_package - * - * Purpose: Initialize information specific to H5O interface. - * - * Return: Non-negative on success/Negative on failure + * Function: H5O_init * - * Programmer: Quincey Koziol - * Thursday, January 18, 2007 + * Purpose: Initialize the interface from some other layer. * + * Return: Success: non-negative + * Failure: negative *------------------------------------------------------------------------- */ herr_t -H5O__init_package(void) +H5O_init(void) { - FUNC_ENTER_PACKAGE_NOERR + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOERR /* H5O interface sanity checks */ HDcompile_assert(H5O_MSG_TYPES == NELMTS(H5O_msg_class_g)); @@ -200,8 +196,8 @@ H5O__init_package(void) HDcompile_assert(H5O_UNKNOWN_ID < H5O_MSG_TYPES); - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5O__init_package() */ + FUNC_LEAVE_NOAPI(ret_value) +} /*------------------------------------------------------------------------- * Function: H5O__set_version @@ -567,7 +563,7 @@ H5O_open(H5O_loc_t *loc) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR /* Check args */ HDassert(loc); @@ -584,7 +580,6 @@ H5O_open(H5O_loc_t *loc) else H5F_INCR_NOPEN_OBJS(loc->file); -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_open() */ @@ -54,9 +54,6 @@ typedef struct { /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ @@ -131,9 +131,6 @@ static herr_t H5PB__write_entry(H5F_shared_t *f_sh, H5PB_entry_t *page_entry); /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ diff --git a/src/H5PLint.c b/src/H5PLint.c index 848bd1d..fe9d3c1 100644 --- a/src/H5PLint.c +++ b/src/H5PLint.c @@ -46,9 +46,6 @@ /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ @@ -123,22 +120,21 @@ H5PL__set_plugin_control_mask(unsigned int mask) } /* end H5PL__set_plugin_control_mask() */ /*------------------------------------------------------------------------- - * Function: H5PL__init_package - * - * Purpose: Initialize any package-specific data and call any init - * routines for the package. + * Function: H5PL_init * - * Return: SUCCEED/FAIL + * Purpose: Initialize the interface from some other layer. * + * Return: Success: non-negative + * Failure: negative *------------------------------------------------------------------------- */ herr_t -H5PL__init_package(void) +H5PL_init(void) { char * env_var = NULL; herr_t ret_value = SUCCEED; - FUNC_ENTER_PACKAGE + FUNC_ENTER_NOAPI(FAIL) /* Check the environment variable to determine if the user wants * to ignore plugins. The special symbol H5PL_NO_PLUGIN (defined in @@ -160,7 +156,7 @@ H5PL__init_package(void) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5PL__init_package() */ +} /*------------------------------------------------------------------------- * Function: H5PL_term_package @@ -183,24 +179,17 @@ H5PL_term_package(void) FUNC_ENTER_NOAPI_NOINIT - if (H5_PKG_INIT_VAR) { - - /* Close the plugin cache. - * We need to bump the return value if we did any real work here. - */ - if (H5PL__close_plugin_cache(&already_closed) < 0) - HGOTO_ERROR(H5E_PLUGIN, H5E_CANTFREE, (-1), "problem closing plugin cache") - if (!already_closed) - ret_value++; - - /* Close the search path table and free the paths */ - if (H5PL__close_path_table() < 0) - HGOTO_ERROR(H5E_PLUGIN, H5E_CANTFREE, (-1), "problem closing search path table") + /* Close the plugin cache. + * We need to bump the return value if we did any real work here. + */ + if (H5PL__close_plugin_cache(&already_closed) < 0) + HGOTO_ERROR(H5E_PLUGIN, H5E_CANTFREE, (-1), "problem closing plugin cache") + if (!already_closed) + ret_value++; - /* Mark the interface as uninitialized */ - if (0 == ret_value) - H5_PKG_INIT_VAR = FALSE; - } /* end if */ + /* Close the search path table and free the paths */ + if (H5PL__close_path_table() < 0) + HGOTO_ERROR(H5E_PLUGIN, H5E_CANTFREE, (-1), "problem closing search path table") done: FUNC_LEAVE_NOAPI(ret_value) @@ -510,10 +499,9 @@ H5PL_iterate(H5PL_iterate_type_t iter_type, H5PL_iterate_t iter_op, void *op_dat { herr_t ret_value = H5_ITER_CONT; - FUNC_ENTER_NOAPI(H5_ITER_ERROR) + FUNC_ENTER_NOAPI_NOERR ret_value = H5PL__path_table_iterate(iter_type, iter_op, op_data); -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL_iterate() */ diff --git a/src/H5PLprivate.h b/src/H5PLprivate.h index 7ff5c1a..83cc8a5 100644 --- a/src/H5PLprivate.h +++ b/src/H5PLprivate.h @@ -82,5 +82,6 @@ typedef herr_t (*H5PL_iterate_t)(H5PL_type_t plugin_type, const void *plugin_inf /* Internal API routines */ H5_DLL const void *H5PL_load(H5PL_type_t plugin_type, const H5PL_key_t *key); H5_DLL herr_t H5PL_iterate(H5PL_iterate_type_t iter_type, H5PL_iterate_t iter_op, void *op_data); +H5_DLL herr_t H5PL_init(void); #endif /* H5PLprivate_H */ diff --git a/src/H5Pint.c b/src/H5Pint.c index 9206d4c..7175fda 100644 --- a/src/H5Pint.c +++ b/src/H5Pint.c @@ -123,7 +123,7 @@ static herr_t H5P__free_del_name_cb(void *item, void H5_ATTR_UNUSED *key, void H /* * Predefined property list classes. These are initialized at runtime by - * H5P__init_package() in this source file. + * H5P_init() in this source file. */ hid_t H5P_CLS_ROOT_ID_g = H5I_INVALID_HID; H5P_genclass_t *H5P_CLS_ROOT_g = NULL; @@ -172,7 +172,7 @@ H5P_genclass_t *H5P_CLS_REFERENCE_ACCESS_g = NULL; /* * Predefined property lists for each predefined class. These are initialized - * at runtime by H5P__init_package() in this source file. + * at runtime by H5P_init() in this source file. */ hid_t H5P_LST_FILE_CREATE_ID_g = H5I_INVALID_HID; hid_t H5P_LST_FILE_ACCESS_ID_g = H5I_INVALID_HID; @@ -429,63 +429,12 @@ static const H5I_class_t H5I_GENPROPLST_CLS[1] = {{ herr_t H5P_init_phase1(void) { - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - /* FUNC_ENTER() does all the work */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_init_phase1() */ - -/*------------------------------------------------------------------------- - * Function: H5P_init_phase2 - * - * Purpose: Finish initializing the interface from some other package. - * - * Note: This is broken out as a separate routine so that the - * library's default VFL driver can be chosen and initialized - * after the entire H5P interface has been initialized. - * - * Return: Success: Non-negative - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5P_init_phase2(void) -{ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - /* Set up the default VFL driver */ - if (H5P__facc_set_def_driver() < 0) - HGOTO_ERROR(H5E_VFL, H5E_CANTSET, FAIL, "unable to set default VFL driver") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_init_phase2() */ - -/*-------------------------------------------------------------------------- -NAME - H5P__init_package -- Initialize interface-specific information -USAGE - herr_t H5P__init_package() -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. ---------------------------------------------------------------------------*/ -herr_t -H5P__init_package(void) -{ size_t tot_init = 0; /* Total # of classes initialized */ size_t pass_init; /* # of classes initialized in each pass */ size_t u; herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_PACKAGE + FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ HDcompile_assert(H5P_TYPE_REFERENCE_ACCESS == (H5P_TYPE_MAX_TYPE - 1)); @@ -576,7 +525,36 @@ done: } FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P__init_package() */ +} + +/*------------------------------------------------------------------------- + * Function: H5P_init_phase2 + * + * Purpose: Finish initializing the interface from some other package. + * + * Note: This is broken out as a separate routine so that the + * library's default VFL driver can be chosen and initialized + * after the entire H5P interface has been initialized. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5P_init_phase2(void) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Set up the default VFL driver */ + if (H5P__facc_set_def_driver() < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTSET, FAIL, "unable to set default VFL driver") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P_init_phase2() */ /*-------------------------------------------------------------------------- NAME @@ -602,77 +580,70 @@ H5P_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5_PKG_INIT_VAR) { - int64_t nlist, nclass; - - /* Destroy HDF5 library property classes & lists */ - - /* Check if there are any open property list classes or lists */ - nclass = H5I_nmembers(H5I_GENPROP_CLS); - nlist = H5I_nmembers(H5I_GENPROP_LST); - - /* If there are any open classes or groups, attempt to get rid of them. */ - if ((nclass + nlist) > 0) { - /* Clear the lists */ - if (nlist > 0) { - (void)H5I_clear_type(H5I_GENPROP_LST, FALSE, FALSE); - - /* Reset the default property lists, if they've been closed */ - if (H5I_nmembers(H5I_GENPROP_LST) == 0) { - H5P_LST_FILE_CREATE_ID_g = H5P_LST_FILE_ACCESS_ID_g = H5P_LST_DATASET_CREATE_ID_g = - H5P_LST_DATASET_ACCESS_ID_g = H5P_LST_DATASET_XFER_ID_g = H5P_LST_GROUP_CREATE_ID_g = - H5P_LST_GROUP_ACCESS_ID_g = H5P_LST_DATATYPE_CREATE_ID_g = - H5P_LST_DATATYPE_ACCESS_ID_g = H5P_LST_MAP_CREATE_ID_g = - H5P_LST_MAP_ACCESS_ID_g = H5P_LST_ATTRIBUTE_CREATE_ID_g = - H5P_LST_ATTRIBUTE_ACCESS_ID_g = H5P_LST_OBJECT_COPY_ID_g = - H5P_LST_LINK_CREATE_ID_g = H5P_LST_LINK_ACCESS_ID_g = - H5P_LST_VOL_INITIALIZE_ID_g = H5P_LST_REFERENCE_ACCESS_ID_g = - H5P_LST_FILE_MOUNT_ID_g = H5I_INVALID_HID; - } /* end if */ - } /* end if */ - - /* Only attempt to close the classes after all the lists are closed */ - if (nlist == 0 && nclass > 0) { - (void)H5I_clear_type(H5I_GENPROP_CLS, FALSE, FALSE); - - /* Reset the default property classes, if they've been closed */ - if (H5I_nmembers(H5I_GENPROP_CLS) == 0) { - H5P_CLS_ROOT_g = H5P_CLS_OBJECT_CREATE_g = H5P_CLS_FILE_CREATE_g = H5P_CLS_FILE_ACCESS_g = - H5P_CLS_DATASET_CREATE_g = H5P_CLS_DATASET_ACCESS_g = H5P_CLS_DATASET_XFER_g = - H5P_CLS_GROUP_CREATE_g = H5P_CLS_GROUP_ACCESS_g = H5P_CLS_DATATYPE_CREATE_g = - H5P_CLS_DATATYPE_ACCESS_g = H5P_CLS_MAP_CREATE_g = H5P_CLS_MAP_ACCESS_g = - H5P_CLS_STRING_CREATE_g = H5P_CLS_ATTRIBUTE_CREATE_g = - H5P_CLS_ATTRIBUTE_ACCESS_g = H5P_CLS_OBJECT_COPY_g = - H5P_CLS_LINK_CREATE_g = H5P_CLS_LINK_ACCESS_g = - H5P_CLS_VOL_INITIALIZE_g = H5P_CLS_REFERENCE_ACCESS_g = - H5P_CLS_FILE_MOUNT_g = NULL; - - H5P_CLS_ROOT_ID_g = H5P_CLS_OBJECT_CREATE_ID_g = H5P_CLS_FILE_CREATE_ID_g = - H5P_CLS_FILE_ACCESS_ID_g = H5P_CLS_DATASET_CREATE_ID_g = H5P_CLS_DATASET_ACCESS_ID_g = - H5P_CLS_DATASET_XFER_ID_g = H5P_CLS_GROUP_CREATE_ID_g = - H5P_CLS_GROUP_ACCESS_ID_g = H5P_CLS_DATATYPE_CREATE_ID_g = - H5P_CLS_DATATYPE_ACCESS_ID_g = H5P_CLS_MAP_CREATE_ID_g = - H5P_CLS_MAP_ACCESS_ID_g = H5P_CLS_STRING_CREATE_ID_g = - H5P_CLS_ATTRIBUTE_CREATE_ID_g = H5P_CLS_ATTRIBUTE_ACCESS_ID_g = - H5P_CLS_OBJECT_COPY_ID_g = H5P_CLS_LINK_CREATE_ID_g = - H5P_CLS_LINK_ACCESS_ID_g = H5P_CLS_VOL_INITIALIZE_ID_g = - H5P_CLS_REFERENCE_ACCESS_ID_g = - H5P_CLS_FILE_MOUNT_ID_g = H5I_INVALID_HID; - } /* end if */ - } /* end if */ + int64_t nlist, nclass; + + /* Destroy HDF5 library property classes & lists */ + + /* Check if there are any open property list classes or lists */ + nclass = H5I_nmembers(H5I_GENPROP_CLS); + nlist = H5I_nmembers(H5I_GENPROP_LST); + + /* If there are any open classes or groups, attempt to get rid of them. */ + if ((nclass + nlist) > 0) { + /* Clear the lists */ + if (nlist > 0) { + (void)H5I_clear_type(H5I_GENPROP_LST, FALSE, FALSE); + + /* Reset the default property lists, if they've been closed */ + if (H5I_nmembers(H5I_GENPROP_LST) == 0) { + H5P_LST_FILE_CREATE_ID_g = H5P_LST_FILE_ACCESS_ID_g = H5P_LST_DATASET_CREATE_ID_g = + H5P_LST_DATASET_ACCESS_ID_g = H5P_LST_DATASET_XFER_ID_g = H5P_LST_GROUP_CREATE_ID_g = + H5P_LST_GROUP_ACCESS_ID_g = H5P_LST_DATATYPE_CREATE_ID_g = + H5P_LST_DATATYPE_ACCESS_ID_g = H5P_LST_MAP_CREATE_ID_g = H5P_LST_MAP_ACCESS_ID_g = + H5P_LST_ATTRIBUTE_CREATE_ID_g = H5P_LST_ATTRIBUTE_ACCESS_ID_g = + H5P_LST_OBJECT_COPY_ID_g = H5P_LST_LINK_CREATE_ID_g = + H5P_LST_LINK_ACCESS_ID_g = H5P_LST_VOL_INITIALIZE_ID_g = + H5P_LST_REFERENCE_ACCESS_ID_g = H5P_LST_FILE_MOUNT_ID_g = + H5I_INVALID_HID; + } /* end if */ + } /* end if */ - n++; /*H5I*/ - } - else { - /* Destroy the property list and class id groups */ - n += (H5I_dec_type_ref(H5I_GENPROP_LST) > 0); - n += (H5I_dec_type_ref(H5I_GENPROP_CLS) > 0); + /* Only attempt to close the classes after all the lists are closed */ + if (nlist == 0 && nclass > 0) { + (void)H5I_clear_type(H5I_GENPROP_CLS, FALSE, FALSE); + + /* Reset the default property classes, if they've been closed */ + if (H5I_nmembers(H5I_GENPROP_CLS) == 0) { + H5P_CLS_ROOT_g = H5P_CLS_OBJECT_CREATE_g = H5P_CLS_FILE_CREATE_g = H5P_CLS_FILE_ACCESS_g = + H5P_CLS_DATASET_CREATE_g = H5P_CLS_DATASET_ACCESS_g = H5P_CLS_DATASET_XFER_g = + H5P_CLS_GROUP_CREATE_g = H5P_CLS_GROUP_ACCESS_g = H5P_CLS_DATATYPE_CREATE_g = + H5P_CLS_DATATYPE_ACCESS_g = H5P_CLS_MAP_CREATE_g = H5P_CLS_MAP_ACCESS_g = + H5P_CLS_STRING_CREATE_g = H5P_CLS_ATTRIBUTE_CREATE_g = + H5P_CLS_ATTRIBUTE_ACCESS_g = H5P_CLS_OBJECT_COPY_g = + H5P_CLS_LINK_CREATE_g = H5P_CLS_LINK_ACCESS_g = + H5P_CLS_VOL_INITIALIZE_g = H5P_CLS_REFERENCE_ACCESS_g = + H5P_CLS_FILE_MOUNT_g = NULL; + + H5P_CLS_ROOT_ID_g = H5P_CLS_OBJECT_CREATE_ID_g = H5P_CLS_FILE_CREATE_ID_g = + H5P_CLS_FILE_ACCESS_ID_g = H5P_CLS_DATASET_CREATE_ID_g = H5P_CLS_DATASET_ACCESS_ID_g = + H5P_CLS_DATASET_XFER_ID_g = H5P_CLS_GROUP_CREATE_ID_g = H5P_CLS_GROUP_ACCESS_ID_g = + H5P_CLS_DATATYPE_CREATE_ID_g = H5P_CLS_DATATYPE_ACCESS_ID_g = + H5P_CLS_MAP_CREATE_ID_g = H5P_CLS_MAP_ACCESS_ID_g = + H5P_CLS_STRING_CREATE_ID_g = H5P_CLS_ATTRIBUTE_CREATE_ID_g = + H5P_CLS_ATTRIBUTE_ACCESS_ID_g = H5P_CLS_OBJECT_COPY_ID_g = + H5P_CLS_LINK_CREATE_ID_g = H5P_CLS_LINK_ACCESS_ID_g = + H5P_CLS_VOL_INITIALIZE_ID_g = H5P_CLS_REFERENCE_ACCESS_ID_g = + H5P_CLS_FILE_MOUNT_ID_g = H5I_INVALID_HID; + } /* end if */ + } /* end if */ - /* Mark closed */ - if (0 == n) - H5_PKG_INIT_VAR = FALSE; - } /* end else */ - } /* end if */ + n++; /*H5I*/ + } + else { + /* Destroy the property list and class id groups */ + n += (H5I_dec_type_ref(H5I_GENPROP_LST) > 0); + n += (H5I_dec_type_ref(H5I_GENPROP_CLS) > 0); + } /* end else */ FUNC_LEAVE_NOAPI(n) } /* end H5P_term_package() */ @@ -3553,7 +3524,7 @@ H5P_get_nprops_pclass(const H5P_genclass_t *pclass, size_t *nprops, hbool_t recu { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR HDassert(pclass); HDassert(nprops); @@ -3568,7 +3539,6 @@ H5P_get_nprops_pclass(const H5P_genclass_t *pclass, size_t *nprops, hbool_t recu *nprops += pclass->nprops; } /* end while */ -done: FUNC_LEAVE_NOAPI(ret_value) } /* H5P_get_nprops_pclass() */ @@ -3999,7 +3969,7 @@ H5P_class_isa(const H5P_genclass_t *pclass1, const H5P_genclass_t *pclass2) { htri_t ret_value = FAIL; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR HDassert(pclass1); HDassert(pclass2); @@ -5301,14 +5271,13 @@ H5P_get_class_name(H5P_genclass_t *pclass) { char *ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI(NULL) + FUNC_ENTER_NOAPI_NOERR HDassert(pclass); /* Get class name */ ret_value = H5MM_xstrdup(pclass->name); -done: FUNC_LEAVE_NOAPI(ret_value) } /* H5P_get_class_name() */ @@ -69,9 +69,6 @@ static herr_t H5RS__resize_for_append(H5RS_str_t *rs, size_t len); /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ diff --git a/src/H5Rint.c b/src/H5Rint.c index 7ee4ecc..65bd485 100644 --- a/src/H5Rint.c +++ b/src/H5Rint.c @@ -141,9 +141,6 @@ static herr_t H5R__decode_string(const unsigned char *buf, size_t *nbytes, char /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ @@ -152,106 +149,27 @@ hbool_t H5_PKG_INIT_VAR = FALSE; /* Local Variables */ /*******************/ -/* Flag indicating "top" of interface has been initialized */ -static hbool_t H5R_top_package_initialize_s = FALSE; - -/*-------------------------------------------------------------------------- -NAME - H5R__init_package -- Initialize interface-specific information -USAGE - herr_t H5R__init_package() - -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. - ---------------------------------------------------------------------------*/ +/*------------------------------------------------------------------------- + * Function: H5R_init + * + * Purpose: Initialize the interface from some other layer. + * + * Return: Success: non-negative + * Failure: negative + *------------------------------------------------------------------------- + */ herr_t -H5R__init_package(void) +H5R_init(void) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + herr_t ret_value = SUCCEED; - /* Mark "top" of interface as initialized */ - H5R_top_package_initialize_s = TRUE; + FUNC_ENTER_NOAPI_NOINIT_NOERR /* Sanity check, if assert fails, H5R_REF_BUF_SIZE must be increased */ HDcompile_assert(sizeof(H5R_ref_priv_t) <= H5R_REF_BUF_SIZE); - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5R__init_package() */ - -/*-------------------------------------------------------------------------- - NAME - H5R_top_term_package - PURPOSE - Terminate various H5R objects - USAGE - void H5R_top_term_package() - RETURNS - void - DESCRIPTION - Release IDs for the ID group, deferring full interface shutdown - until later (in H5R_term_package). - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - Can't report errors... - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -int -H5R_top_term_package(void) -{ - int n = 0; - - FUNC_ENTER_NOAPI_NOINIT_NOERR - - /* Mark closed if initialized */ - if (H5R_top_package_initialize_s) - if (0 == n) - H5R_top_package_initialize_s = FALSE; - - FUNC_LEAVE_NOAPI(n) -} /* end H5R_top_term_package() */ - -/*-------------------------------------------------------------------------- - NAME - H5R_term_package - PURPOSE - Terminate various H5R objects - USAGE - void H5R_term_package() - RETURNS - void - DESCRIPTION - Release the ID group and any other resources allocated. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - Can't report errors... - - Finishes shutting down the interface, after H5R_top_term_package() - is called - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -int -H5R_term_package(void) -{ - int n = 0; - - FUNC_ENTER_NOAPI_NOINIT_NOERR - - if (H5_PKG_INIT_VAR) { - /* Sanity checks */ - HDassert(FALSE == H5R_top_package_initialize_s); - - /* Mark closed */ - if (0 == n) - H5_PKG_INIT_VAR = FALSE; - } - - FUNC_LEAVE_NOAPI(n) -} /* end H5R_term_package() */ + FUNC_LEAVE_NOAPI(ret_value) +} /*------------------------------------------------------------------------- * Function: H5R__create_object diff --git a/src/H5Rprivate.h b/src/H5Rprivate.h index 6d6fcd5..59d2ed2 100644 --- a/src/H5Rprivate.h +++ b/src/H5Rprivate.h @@ -39,4 +39,6 @@ /* Library Private Prototypes */ /******************************/ +H5_DLL herr_t H5R_init(void); + #endif /* H5Rprivate_H */ @@ -55,9 +55,6 @@ static htri_t H5S__is_simple(const H5S_t *sdim); /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /* Format version bounds for dataspace */ const unsigned H5O_sdspace_ver_bounds[] = { H5O_SDSPACE_VERSION_1, /* H5F_LIBVER_EARLIEST */ @@ -96,9 +93,6 @@ static const H5I_class_t H5I_SPACE_SEL_ITER_CLS[1] = {{ (H5I_free_t)H5S__sel_iter_close_cb /* Callback routine for closing objects of this class */ }}; -/* Flag indicating "top" of interface has been initialized */ -static hbool_t H5S_top_package_initialize_s = FALSE; - /*------------------------------------------------------------------------- * Function: H5S_init * @@ -114,28 +108,6 @@ H5S_init(void) herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - /* FUNC_ENTER() does all the work */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5S_init() */ - -/*-------------------------------------------------------------------------- -NAME - H5S__init_package -- Initialize interface-specific information -USAGE - herr_t H5S__init_package() -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. ---------------------------------------------------------------------------*/ -herr_t -H5S__init_package(void) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE /* Initialize the ID group for the dataspace IDs */ if (H5I_register_type(H5I_DATASPACE_CLS) < 0) @@ -146,12 +118,9 @@ H5S__init_package(void) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize dataspace selection iterator ID class") - /* Mark "top" of interface as initialized, too */ - H5S_top_package_initialize_s = TRUE; - done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5S__init_package() */ +} /* end H5S_init() */ /*-------------------------------------------------------------------------- NAME @@ -178,21 +147,14 @@ H5S_top_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5S_top_package_initialize_s) { - if (H5I_nmembers(H5I_DATASPACE) > 0) { - (void)H5I_clear_type(H5I_DATASPACE, FALSE, FALSE); - n++; /*H5I*/ - } /* end if */ - - if (H5I_nmembers(H5I_SPACE_SEL_ITER) > 0) { - (void)H5I_clear_type(H5I_SPACE_SEL_ITER, FALSE, FALSE); - n++; /*H5I*/ - } /* end if */ - - /* Mark "top" of interface as closed */ - if (0 == n) - H5S_top_package_initialize_s = FALSE; - } /* end if */ + if (H5I_nmembers(H5I_DATASPACE) > 0) { + (void)H5I_clear_type(H5I_DATASPACE, FALSE, FALSE); + n++; + } + if (H5I_nmembers(H5I_SPACE_SEL_ITER) > 0) { + (void)H5I_clear_type(H5I_SPACE_SEL_ITER, FALSE, FALSE); + n++; + } FUNC_LEAVE_NOAPI(n) } /* end H5S_top_term_package() */ @@ -224,22 +186,15 @@ H5S_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5_PKG_INIT_VAR) { - /* Sanity checks */ - HDassert(0 == H5I_nmembers(H5I_DATASPACE)); - HDassert(0 == H5I_nmembers(H5I_SPACE_SEL_ITER)); - HDassert(FALSE == H5S_top_package_initialize_s); - - /* Destroy the dataspace object id group */ - n += (H5I_dec_type_ref(H5I_DATASPACE) > 0); + /* Sanity checks */ + HDassert(0 == H5I_nmembers(H5I_DATASPACE)); + HDassert(0 == H5I_nmembers(H5I_SPACE_SEL_ITER)); - /* Destroy the dataspace selection iterator object id group */ - n += (H5I_dec_type_ref(H5I_SPACE_SEL_ITER) > 0); + /* Destroy the dataspace object id group */ + n += (H5I_dec_type_ref(H5I_DATASPACE) > 0); - /* Mark interface as closed */ - if (0 == n) - H5_PKG_INIT_VAR = FALSE; - } /* end if */ + /* Destroy the dataspace selection iterator object id group */ + n += (H5I_dec_type_ref(H5I_SPACE_SEL_ITER) > 0); FUNC_LEAVE_NOAPI(n) } /* end H5S_term_package() */ @@ -759,7 +714,7 @@ H5S_get_simple_extent_npoints(const H5S_t *ds) { hssize_t ret_value = -1; /* Return value */ - FUNC_ENTER_NOAPI(-1) + FUNC_ENTER_NOAPI_NOERR /* check args */ HDassert(ds); @@ -767,7 +722,6 @@ H5S_get_simple_extent_npoints(const H5S_t *ds) /* Get the number of elements in extent */ ret_value = (hssize_t)ds->extent.nelem; -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_get_simple_extent_npoints() */ @@ -1740,13 +1694,12 @@ H5S_get_simple_extent_type(const H5S_t *space) { H5S_class_t ret_value = H5S_NO_CLASS; /* Return value */ - FUNC_ENTER_NOAPI(H5S_NO_CLASS) + FUNC_ENTER_NOAPI_NOERR HDassert(space); ret_value = H5S_GET_EXTENT_TYPE(space); -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_get_simple_extent_type() */ @@ -510,9 +510,6 @@ static H5SL_node_t *H5SL__insert_common(H5SL_t *slist, void *item, const void *k static herr_t H5SL__release_common(H5SL_t *slist, H5SL_operator_t op, void *op_data); static herr_t H5SL__close_common(H5SL_t *slist, H5SL_operator_t op, void *op_data); -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /* Declare a free list to manage the H5SL_t struct */ H5FL_DEFINE_STATIC(H5SL_t); @@ -524,26 +521,21 @@ static H5FL_fac_head_t **H5SL_fac_g; static size_t H5SL_fac_nused_g; static size_t H5SL_fac_nalloc_g; -/*-------------------------------------------------------------------------- - NAME - H5SL__init_package - PURPOSE - Initialize interface-specific information - USAGE - herr_t H5SL__init_package() - RETURNS - Non-negative on success/Negative on failure - DESCRIPTION - Initializes any interface-specific data or routines. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ +/*------------------------------------------------------------------------- + * Function: H5SL_init + * + * Purpose: Initialize the interface from some other layer. + * + * Return: Success: non-negative + * Failure: negative + *------------------------------------------------------------------------- + */ herr_t -H5SL__init_package(void) +H5SL_init(void) { - FUNC_ENTER_PACKAGE_NOERR + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOERR /* Allocate space for array of factories */ H5SL_fac_g = (H5FL_fac_head_t **)H5MM_malloc(sizeof(H5FL_fac_head_t *)); @@ -555,8 +547,8 @@ H5SL__init_package(void) HDassert(H5SL_fac_g[0]); H5SL_fac_nused_g = 1; - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5SL__init_package() */ + FUNC_LEAVE_NOAPI(ret_value) +} /*-------------------------------------------------------------------------- NAME @@ -584,32 +576,26 @@ H5SL_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5_PKG_INIT_VAR) { - /* Terminate all the factories */ - if (H5SL_fac_nused_g > 0) { - size_t i; - herr_t H5_ATTR_NDEBUG_UNUSED ret; - - for (i = 0; i < H5SL_fac_nused_g; i++) { - ret = H5FL_fac_term(H5SL_fac_g[i]); - HDassert(ret >= 0); - } - H5SL_fac_nused_g = 0; + /* Terminate all the factories */ + if (H5SL_fac_nused_g > 0) { + size_t i; + herr_t H5_ATTR_NDEBUG_UNUSED ret; - n++; + for (i = 0; i < H5SL_fac_nused_g; i++) { + ret = H5FL_fac_term(H5SL_fac_g[i]); + HDassert(ret >= 0); } + H5SL_fac_nused_g = 0; - /* Free the list of factories */ - if (H5SL_fac_g) { - H5SL_fac_g = (H5FL_fac_head_t **)H5MM_xfree((void *)H5SL_fac_g); - H5SL_fac_nalloc_g = 0; + n++; + } - n++; - } + /* Free the list of factories */ + if (H5SL_fac_g) { + H5SL_fac_g = (H5FL_fac_head_t **)H5MM_xfree((void *)H5SL_fac_g); + H5SL_fac_nalloc_g = 0; - /* Mark the interface as uninitialized */ - if (0 == n) - H5_PKG_INIT_VAR = FALSE; + n++; } FUNC_LEAVE_NOAPI(n) diff --git a/src/H5SLprivate.h b/src/H5SLprivate.h index be6f7b6..f4f7506 100644 --- a/src/H5SLprivate.h +++ b/src/H5SLprivate.h @@ -85,6 +85,7 @@ H5_DLL herr_t H5SL_release(H5SL_t *slist); H5_DLL herr_t H5SL_free(H5SL_t *slist, H5SL_operator_t op, void *op_data); H5_DLL herr_t H5SL_close(H5SL_t *slist); H5_DLL herr_t H5SL_destroy(H5SL_t *slist, H5SL_operator_t op, void *op_data); +H5_DLL herr_t H5SL_init(void); H5_DLL int H5SL_term_interface(void); #endif /* H5SLprivate_H */ @@ -76,9 +76,6 @@ static herr_t H5SM__read_mesg(H5F_t *f, const H5SM_sohm_t *mesg, H5HF_t *fheap, /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - H5FL_DEFINE(H5SM_master_table_t); H5FL_ARR_DEFINE(H5SM_index_header_t, H5O_SHMESG_MAX_NINDEXES); H5FL_DEFINE(H5SM_list_t); diff --git a/src/H5Shyper.c b/src/H5Shyper.c index a5b9b6c..8e282e3 100644 --- a/src/H5Shyper.c +++ b/src/H5Shyper.c @@ -12036,7 +12036,7 @@ H5S_hyper_get_clip_extent(const H5S_t *clip_space, const H5S_t *match_space, hbo hsize_t num_slices; /* Number of slices in unlimited dimension */ hsize_t ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI(0) + FUNC_ENTER_NOAPI_NOERR /* Check parameters */ HDassert(clip_space); @@ -12058,7 +12058,6 @@ H5S_hyper_get_clip_extent(const H5S_t *clip_space, const H5S_t *match_space, hbo /* Call "real" get_clip_extent function */ ret_value = H5S__hyper_get_clip_extent_real(clip_space, num_slices, incl_trail); -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_hyper_get_clip_extent() */ @@ -12094,7 +12093,7 @@ H5S_hyper_get_clip_extent_match(const H5S_t *clip_space, const H5S_t *match_spac hsize_t num_slices; /* Number of slices in unlimited dimension */ hsize_t ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI(0) + FUNC_ENTER_NOAPI_NOERR /* Check parameters */ HDassert(clip_space); @@ -12140,7 +12139,6 @@ H5S_hyper_get_clip_extent_match(const H5S_t *clip_space, const H5S_t *match_spac /* Call "real" get_clip_extent function */ ret_value = H5S__hyper_get_clip_extent_real(clip_space, num_slices, incl_trail); -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_hyper_get_clip_extent_match() */ @@ -12256,7 +12254,7 @@ H5S_hyper_get_first_inc_block(const H5S_t *space, hsize_t clip_size, hbool_t *pa H5S_hyper_dim_t *diminfo; /* Convenience pointer to diminfo in unlimited dimension */ hsize_t ret_value = 0; - FUNC_ENTER_NOAPI(0) + FUNC_ENTER_NOAPI_NOERR /* Check parameters */ HDassert(space); @@ -12286,7 +12284,6 @@ H5S_hyper_get_first_inc_block(const H5S_t *space, hsize_t clip_size, hbool_t *pa } /* end if */ } /* end else */ -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_hyper_get_first_inc_block */ @@ -368,12 +368,9 @@ H5T_order_t H5T_native_order_g = H5T_ORDER_ERROR; /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /* * Predefined data types. These are initialized at runtime in H5Tinit.c and - * by H5T__init_package() in this source file. + * by H5T_init() in this source file. * * If more of these are added, the new ones must be added to the list of * types to reset in H5T_term_package(). @@ -600,34 +597,6 @@ static const H5I_class_t H5I_DATATYPE_CLS[1] = {{ (H5I_free_t)H5T__close_cb /* Callback routine for closing objects of this class */ }}; -/* Flag indicating "top" of interface has been initialized */ -static hbool_t H5T_top_package_initialize_s = FALSE; - -/*------------------------------------------------------------------------- - * Function: H5T_init - * - * Purpose: Initialize the interface from some other package. - * - * Return: Success: non-negative - * Failure: negative - * - * Programmer: Robb Matzke - * Wednesday, December 16, 1998 - * - *------------------------------------------------------------------------- - */ -herr_t -H5T_init(void) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - /* FUNC_ENTER() does all the work */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T_init() */ - /*------------------------------------------------------------------------- * Function: H5T__init_inf * @@ -740,19 +709,17 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__init_inf() */ -/*-------------------------------------------------------------------------- -NAME - H5T__init_package -- Initialize interface-specific information -USAGE - herr__t H5T_init_package() -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. - ---------------------------------------------------------------------------*/ +/*------------------------------------------------------------------------- + * Function: H5T_init + * + * Purpose: Initialize the interface from some other layer. + * + * Return: Success: non-negative + * Failure: negative + *------------------------------------------------------------------------- + */ herr_t -H5T__init_package(void) +H5T_init(void) { H5T_t * native_schar = NULL; /* Datatype structure for native signed char */ H5T_t * native_uchar = NULL; /* Datatype structure for native unsigned char */ @@ -793,7 +760,7 @@ H5T__init_package(void) TRUE; /* Flag to indicate whether datatype was copied or allocated (for error cleanup) */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_NOAPI(FAIL) /* Initialize the ID group for the file IDs */ if (H5I_register_type(H5I_DATATYPE_CLS) < 0) @@ -1433,7 +1400,7 @@ H5T__init_package(void) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to register conversion function(s)") /* Register datatype creation property class properties here. See similar - * code in H5D__init_package(), etc. for example. + * code in H5D_init(), etc. for example. */ /* Only register the default property list if it hasn't been created yet */ @@ -1446,9 +1413,6 @@ H5T__init_package(void) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't insert property into class") } /* end if */ - /* Mark "top" of interface as initialized, too */ - H5T_top_package_initialize_s = TRUE; - done: /* General cleanup */ if (compound != NULL) @@ -1476,7 +1440,7 @@ done: } /* end if */ FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T__init_package() */ +} /* end H5T_init() */ /*------------------------------------------------------------------------- * Function: H5T__unlock_cb @@ -1532,183 +1496,177 @@ H5T_top_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5T_top_package_initialize_s) { - /* Unregister all conversion functions */ - if (H5T_g.path) { - int i, nprint = 0; - - for (i = 0; i < H5T_g.npaths; i++) { - H5T_path_t *path; - - path = H5T_g.path[i]; - HDassert(path); - if (path->conv.u.app_func) { - H5T__print_stats(path, &nprint /*in,out*/); - path->cdata.command = H5T_CONV_FREE; - if (path->conv.is_app) { - if ((path->conv.u.app_func)((hid_t)FAIL, (hid_t)FAIL, &(path->cdata), (size_t)0, - (size_t)0, (size_t)0, NULL, NULL, H5CX_get_dxpl()) < 0) { + /* Unregister all conversion functions */ + if (H5T_g.path) { + int i, nprint = 0; + + for (i = 0; i < H5T_g.npaths; i++) { + H5T_path_t *path; + + path = H5T_g.path[i]; + HDassert(path); + if (path->conv.u.app_func) { + H5T__print_stats(path, &nprint /*in,out*/); + path->cdata.command = H5T_CONV_FREE; + if (path->conv.is_app) { + if ((path->conv.u.app_func)((hid_t)FAIL, (hid_t)FAIL, &(path->cdata), (size_t)0, + (size_t)0, (size_t)0, NULL, NULL, H5CX_get_dxpl()) < 0) { #ifdef H5T_DEBUG - if (H5DEBUG(T)) { - HDfprintf(H5DEBUG(T), - "H5T: conversion function " - "0x%08lx failed to free private data for " - "%s (ignored)\n", - (unsigned long)(path->conv.u.app_func), path->name); - } /* end if */ + if (H5DEBUG(T)) { + HDfprintf(H5DEBUG(T), + "H5T: conversion function " + "0x%08lx failed to free private data for " + "%s (ignored)\n", + (unsigned long)(path->conv.u.app_func), path->name); + } /* end if */ #endif - H5E_clear_stack(NULL); /*ignore the error*/ - } /* end if */ - } /* end if */ - else { - if ((path->conv.u.lib_func)((hid_t)FAIL, (hid_t)FAIL, &(path->cdata), (size_t)0, - (size_t)0, (size_t)0, NULL, NULL) < 0) { + H5E_clear_stack(NULL); /*ignore the error*/ + } /* end if */ + } /* end if */ + else { + if ((path->conv.u.lib_func)((hid_t)FAIL, (hid_t)FAIL, &(path->cdata), (size_t)0, + (size_t)0, (size_t)0, NULL, NULL) < 0) { #ifdef H5T_DEBUG - if (H5DEBUG(T)) { - HDfprintf(H5DEBUG(T), - "H5T: conversion function " - "0x%08lx failed to free private data for " - "%s (ignored)\n", - (unsigned long)(path->conv.u.lib_func), path->name); - } /* end if */ + if (H5DEBUG(T)) { + HDfprintf(H5DEBUG(T), + "H5T: conversion function " + "0x%08lx failed to free private data for " + "%s (ignored)\n", + (unsigned long)(path->conv.u.lib_func), path->name); + } /* end if */ #endif - H5E_clear_stack(NULL); /*ignore the error*/ - } /* end if */ - } /* end else */ - } /* end if */ - - if (path->src) - (void)H5T_close_real(path->src); - if (path->dst) - (void)H5T_close_real(path->dst); - path = H5FL_FREE(H5T_path_t, path); - H5T_g.path[i] = NULL; - } /* end for */ - - /* Clear conversion tables */ - H5T_g.path = (H5T_path_t **)H5MM_xfree(H5T_g.path); - H5T_g.npaths = 0; - H5T_g.apaths = 0; - H5T_g.soft = (H5T_soft_t *)H5MM_xfree(H5T_g.soft); - H5T_g.nsoft = 0; - H5T_g.asoft = 0; + H5E_clear_stack(NULL); /*ignore the error*/ + } /* end if */ + } /* end else */ + } /* end if */ + + if (path->src) + (void)H5T_close_real(path->src); + if (path->dst) + (void)H5T_close_real(path->dst); + path = H5FL_FREE(H5T_path_t, path); + H5T_g.path[i] = NULL; + } /* end for */ - n++; - } /* end if */ + /* Clear conversion tables */ + H5T_g.path = (H5T_path_t **)H5MM_xfree(H5T_g.path); + H5T_g.npaths = 0; + H5T_g.apaths = 0; + H5T_g.soft = (H5T_soft_t *)H5MM_xfree(H5T_g.soft); + H5T_g.nsoft = 0; + H5T_g.asoft = 0; - /* Unlock all datatypes, then free them */ - /* note that we are ignoring the return value from H5I_iterate() */ - /* Also note that we are incrementing 'n' in the callback */ - H5I_iterate(H5I_DATATYPE, H5T__unlock_cb, &n, FALSE); - - /* Release all datatype IDs */ - if (H5I_nmembers(H5I_DATATYPE) > 0) { - (void)H5I_clear_type(H5I_DATATYPE, FALSE, FALSE); - n++; /*H5I*/ - } /* end if */ - - /* Reset all the datatype IDs */ - if (H5T_IEEE_F32BE_g > 0) { - H5T_IEEE_F32BE_g = FAIL; - H5T_IEEE_F32LE_g = FAIL; - H5T_IEEE_F64BE_g = FAIL; - H5T_IEEE_F64LE_g = FAIL; - - H5T_STD_I8BE_g = FAIL; - H5T_STD_I8LE_g = FAIL; - H5T_STD_I16BE_g = FAIL; - H5T_STD_I16LE_g = FAIL; - H5T_STD_I32BE_g = FAIL; - H5T_STD_I32LE_g = FAIL; - H5T_STD_I64BE_g = FAIL; - H5T_STD_I64LE_g = FAIL; - H5T_STD_U8BE_g = FAIL; - H5T_STD_U8LE_g = FAIL; - H5T_STD_U16BE_g = FAIL; - H5T_STD_U16LE_g = FAIL; - H5T_STD_U32BE_g = FAIL; - H5T_STD_U32LE_g = FAIL; - H5T_STD_U64BE_g = FAIL; - H5T_STD_U64LE_g = FAIL; - H5T_STD_B8BE_g = FAIL; - H5T_STD_B8LE_g = FAIL; - H5T_STD_B16BE_g = FAIL; - H5T_STD_B16LE_g = FAIL; - H5T_STD_B32BE_g = FAIL; - H5T_STD_B32LE_g = FAIL; - H5T_STD_B64BE_g = FAIL; - H5T_STD_B64LE_g = FAIL; - H5T_STD_REF_OBJ_g = FAIL; - H5T_STD_REF_DSETREG_g = FAIL; - H5T_STD_REF_g = FAIL; - - H5T_UNIX_D32BE_g = FAIL; - H5T_UNIX_D32LE_g = FAIL; - H5T_UNIX_D64BE_g = FAIL; - H5T_UNIX_D64LE_g = FAIL; - - H5T_C_S1_g = FAIL; - - H5T_FORTRAN_S1_g = FAIL; - - H5T_NATIVE_SCHAR_g = FAIL; - H5T_NATIVE_UCHAR_g = FAIL; - H5T_NATIVE_SHORT_g = FAIL; - H5T_NATIVE_USHORT_g = FAIL; - H5T_NATIVE_INT_g = FAIL; - H5T_NATIVE_UINT_g = FAIL; - H5T_NATIVE_LONG_g = FAIL; - H5T_NATIVE_ULONG_g = FAIL; - H5T_NATIVE_LLONG_g = FAIL; - H5T_NATIVE_ULLONG_g = FAIL; - H5T_NATIVE_FLOAT_g = FAIL; - H5T_NATIVE_DOUBLE_g = FAIL; - H5T_NATIVE_LDOUBLE_g = FAIL; - H5T_NATIVE_B8_g = FAIL; - H5T_NATIVE_B16_g = FAIL; - H5T_NATIVE_B32_g = FAIL; - H5T_NATIVE_B64_g = FAIL; - H5T_NATIVE_OPAQUE_g = FAIL; - H5T_NATIVE_HADDR_g = FAIL; - H5T_NATIVE_HSIZE_g = FAIL; - H5T_NATIVE_HSSIZE_g = FAIL; - H5T_NATIVE_HERR_g = FAIL; - H5T_NATIVE_HBOOL_g = FAIL; - - H5T_NATIVE_INT8_g = FAIL; - H5T_NATIVE_UINT8_g = FAIL; - H5T_NATIVE_INT_LEAST8_g = FAIL; - H5T_NATIVE_UINT_LEAST8_g = FAIL; - H5T_NATIVE_INT_FAST8_g = FAIL; - H5T_NATIVE_UINT_FAST8_g = FAIL; - - H5T_NATIVE_INT16_g = FAIL; - H5T_NATIVE_UINT16_g = FAIL; - H5T_NATIVE_INT_LEAST16_g = FAIL; - H5T_NATIVE_UINT_LEAST16_g = FAIL; - H5T_NATIVE_INT_FAST16_g = FAIL; - H5T_NATIVE_UINT_FAST16_g = FAIL; - - H5T_NATIVE_INT32_g = FAIL; - H5T_NATIVE_UINT32_g = FAIL; - H5T_NATIVE_INT_LEAST32_g = FAIL; - H5T_NATIVE_UINT_LEAST32_g = FAIL; - H5T_NATIVE_INT_FAST32_g = FAIL; - H5T_NATIVE_UINT_FAST32_g = FAIL; - - H5T_NATIVE_INT64_g = FAIL; - H5T_NATIVE_UINT64_g = FAIL; - H5T_NATIVE_INT_LEAST64_g = FAIL; - H5T_NATIVE_UINT_LEAST64_g = FAIL; - H5T_NATIVE_INT_FAST64_g = FAIL; - H5T_NATIVE_UINT_FAST64_g = FAIL; - - n++; - } /* end if */ + n++; + } /* end if */ - /* Mark "top" of interface as closed */ - if (0 == n) - H5T_top_package_initialize_s = FALSE; + /* Unlock all datatypes, then free them */ + /* note that we are ignoring the return value from H5I_iterate() */ + /* Also note that we are incrementing 'n' in the callback */ + H5I_iterate(H5I_DATATYPE, H5T__unlock_cb, &n, FALSE); + + /* Release all datatype IDs */ + if (H5I_nmembers(H5I_DATATYPE) > 0) { + (void)H5I_clear_type(H5I_DATATYPE, FALSE, FALSE); + n++; /*H5I*/ + } /* end if */ + + /* Reset all the datatype IDs */ + if (H5T_IEEE_F32BE_g > 0) { + H5T_IEEE_F32BE_g = FAIL; + H5T_IEEE_F32LE_g = FAIL; + H5T_IEEE_F64BE_g = FAIL; + H5T_IEEE_F64LE_g = FAIL; + + H5T_STD_I8BE_g = FAIL; + H5T_STD_I8LE_g = FAIL; + H5T_STD_I16BE_g = FAIL; + H5T_STD_I16LE_g = FAIL; + H5T_STD_I32BE_g = FAIL; + H5T_STD_I32LE_g = FAIL; + H5T_STD_I64BE_g = FAIL; + H5T_STD_I64LE_g = FAIL; + H5T_STD_U8BE_g = FAIL; + H5T_STD_U8LE_g = FAIL; + H5T_STD_U16BE_g = FAIL; + H5T_STD_U16LE_g = FAIL; + H5T_STD_U32BE_g = FAIL; + H5T_STD_U32LE_g = FAIL; + H5T_STD_U64BE_g = FAIL; + H5T_STD_U64LE_g = FAIL; + H5T_STD_B8BE_g = FAIL; + H5T_STD_B8LE_g = FAIL; + H5T_STD_B16BE_g = FAIL; + H5T_STD_B16LE_g = FAIL; + H5T_STD_B32BE_g = FAIL; + H5T_STD_B32LE_g = FAIL; + H5T_STD_B64BE_g = FAIL; + H5T_STD_B64LE_g = FAIL; + H5T_STD_REF_OBJ_g = FAIL; + H5T_STD_REF_DSETREG_g = FAIL; + H5T_STD_REF_g = FAIL; + + H5T_UNIX_D32BE_g = FAIL; + H5T_UNIX_D32LE_g = FAIL; + H5T_UNIX_D64BE_g = FAIL; + H5T_UNIX_D64LE_g = FAIL; + + H5T_C_S1_g = FAIL; + + H5T_FORTRAN_S1_g = FAIL; + + H5T_NATIVE_SCHAR_g = FAIL; + H5T_NATIVE_UCHAR_g = FAIL; + H5T_NATIVE_SHORT_g = FAIL; + H5T_NATIVE_USHORT_g = FAIL; + H5T_NATIVE_INT_g = FAIL; + H5T_NATIVE_UINT_g = FAIL; + H5T_NATIVE_LONG_g = FAIL; + H5T_NATIVE_ULONG_g = FAIL; + H5T_NATIVE_LLONG_g = FAIL; + H5T_NATIVE_ULLONG_g = FAIL; + H5T_NATIVE_FLOAT_g = FAIL; + H5T_NATIVE_DOUBLE_g = FAIL; + H5T_NATIVE_LDOUBLE_g = FAIL; + H5T_NATIVE_B8_g = FAIL; + H5T_NATIVE_B16_g = FAIL; + H5T_NATIVE_B32_g = FAIL; + H5T_NATIVE_B64_g = FAIL; + H5T_NATIVE_OPAQUE_g = FAIL; + H5T_NATIVE_HADDR_g = FAIL; + H5T_NATIVE_HSIZE_g = FAIL; + H5T_NATIVE_HSSIZE_g = FAIL; + H5T_NATIVE_HERR_g = FAIL; + H5T_NATIVE_HBOOL_g = FAIL; + + H5T_NATIVE_INT8_g = FAIL; + H5T_NATIVE_UINT8_g = FAIL; + H5T_NATIVE_INT_LEAST8_g = FAIL; + H5T_NATIVE_UINT_LEAST8_g = FAIL; + H5T_NATIVE_INT_FAST8_g = FAIL; + H5T_NATIVE_UINT_FAST8_g = FAIL; + + H5T_NATIVE_INT16_g = FAIL; + H5T_NATIVE_UINT16_g = FAIL; + H5T_NATIVE_INT_LEAST16_g = FAIL; + H5T_NATIVE_UINT_LEAST16_g = FAIL; + H5T_NATIVE_INT_FAST16_g = FAIL; + H5T_NATIVE_UINT_FAST16_g = FAIL; + + H5T_NATIVE_INT32_g = FAIL; + H5T_NATIVE_UINT32_g = FAIL; + H5T_NATIVE_INT_LEAST32_g = FAIL; + H5T_NATIVE_UINT_LEAST32_g = FAIL; + H5T_NATIVE_INT_FAST32_g = FAIL; + H5T_NATIVE_UINT_FAST32_g = FAIL; + + H5T_NATIVE_INT64_g = FAIL; + H5T_NATIVE_UINT64_g = FAIL; + H5T_NATIVE_INT_LEAST64_g = FAIL; + H5T_NATIVE_UINT_LEAST64_g = FAIL; + H5T_NATIVE_INT_FAST64_g = FAIL; + H5T_NATIVE_UINT_FAST64_g = FAIL; + + n++; } /* end if */ FUNC_LEAVE_NOAPI(n) @@ -1739,18 +1697,11 @@ H5T_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5_PKG_INIT_VAR) { - /* Sanity check */ - HDassert(0 == H5I_nmembers(H5I_DATATYPE)); - HDassert(FALSE == H5T_top_package_initialize_s); + /* Sanity check */ + HDassert(0 == H5I_nmembers(H5I_DATATYPE)); - /* Destroy the datatype object id group */ - n += (H5I_dec_type_ref(H5I_DATATYPE) > 0); - - /* Mark interface as closed */ - if (0 == n) - H5_PKG_INIT_VAR = FALSE; - } /* end if */ + /* Destroy the datatype object id group */ + n += (H5I_dec_type_ref(H5I_DATATYPE) > 0); FUNC_LEAVE_NOAPI(n) } /* end H5T_term_package() */ @@ -2170,7 +2121,7 @@ H5T_get_class(const H5T_t *dt, htri_t internal) { H5T_class_t ret_value = H5T_NO_CLASS; /* Return value */ - FUNC_ENTER_NOAPI(H5T_NO_CLASS) + FUNC_ENTER_NOAPI_NOERR HDassert(dt); @@ -2185,7 +2136,6 @@ H5T_get_class(const H5T_t *dt, htri_t internal) ret_value = dt->shared->type; } -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_get_class() */ @@ -2243,7 +2193,7 @@ H5T_detect_class(const H5T_t *dt, H5T_class_t cls, hbool_t from_api) unsigned i; htri_t ret_value = FALSE; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR HDassert(dt); HDassert(cls > H5T_NO_CLASS && cls < H5T_NCLASSES); @@ -5626,14 +5576,13 @@ H5T_is_immutable(const H5T_t *dt) { htri_t ret_value = FALSE; - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR HDassert(dt); if (dt->shared->state == H5T_STATE_IMMUTABLE) ret_value = TRUE; -done: FUNC_LEAVE_NOAPI(ret_value) } @@ -5651,7 +5600,7 @@ H5T_is_named(const H5T_t *dt) { htri_t ret_value = FALSE; - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR HDassert(dt); @@ -5660,7 +5609,6 @@ H5T_is_named(const H5T_t *dt) else ret_value = (H5T_STATE_OPEN == dt->shared->state || H5T_STATE_NAMED == dt->shared->state); -done: FUNC_LEAVE_NOAPI(ret_value) } @@ -5738,14 +5686,13 @@ H5T_get_ref_type(const H5T_t *dt) { H5R_type_t ret_value = H5R_BADTYPE; - FUNC_ENTER_NOAPI(H5R_BADTYPE) + FUNC_ENTER_NOAPI_NOERR HDassert(dt); if (dt->shared->type == H5T_REFERENCE) ret_value = dt->shared->u.atomic.u.r.rtype; -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_get_ref_type() */ @@ -5768,7 +5715,7 @@ H5T_is_sensible(const H5T_t *dt) { htri_t ret_value = FAIL; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR HDassert(dt); @@ -5806,7 +5753,6 @@ H5T_is_sensible(const H5T_t *dt) break; } /* end switch */ -done: FUNC_LEAVE_NOAPI(ret_value) } @@ -5999,7 +5945,7 @@ H5T_is_relocatable(const H5T_t *dt) { htri_t ret_value = FALSE; - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR /* Sanity check */ HDassert(dt); @@ -6008,7 +5954,6 @@ H5T_is_relocatable(const H5T_t *dt) if (H5T_detect_class(dt, H5T_VLEN, FALSE) || H5T_detect_class(dt, H5T_REFERENCE, FALSE)) ret_value = TRUE; -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_is_relocatable() */ @@ -6099,7 +6044,7 @@ H5T_is_vl_storage(const H5T_t *dt) { htri_t ret_value = FALSE; - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR /* Sanity check */ HDassert(dt); @@ -6112,7 +6057,6 @@ H5T_is_vl_storage(const H5T_t *dt) else ret_value = FALSE; -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_is_vl_storage() */ @@ -6266,7 +6210,7 @@ H5T_patch_file(H5T_t *dt, H5F_t *f) { herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR /* Sanity check */ HDassert(dt); @@ -6277,7 +6221,6 @@ H5T_patch_file(H5T_t *dt, H5F_t *f) dt->sh_loc.file = f; } /* end if */ -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_patch_file() */ diff --git a/src/H5VLint.c b/src/H5VLint.c index 936614f..b602ac0 100644 --- a/src/H5VLint.c +++ b/src/H5VLint.c @@ -32,6 +32,7 @@ #include "H5CXprivate.h" /* API Contexts */ #include "H5Dprivate.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ +#include "H5ESprivate.h" /* Event sets */ #include "H5Fprivate.h" /* Files */ #include "H5FLprivate.h" /* Free lists */ #include "H5Gprivate.h" /* Groups */ @@ -94,9 +95,6 @@ static herr_t H5VL__free_vol_wrapper(H5VL_wrap_ctx_t *vol_wrap_ctx); /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ @@ -149,7 +147,9 @@ H5VL_init_phase1(void) FUNC_ENTER_NOAPI(FAIL) - /* FUNC_ENTER() does all the work */ + /* Initialize the ID group for the VL IDs */ + if (H5I_register_type(H5I_VOL_CLS) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to initialize H5VL interface") done: FUNC_LEAVE_NOAPI(ret_value) @@ -171,23 +171,39 @@ done: herr_t H5VL_init_phase2(void) { + size_t i; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) + /* clang-format off */ + struct { + herr_t (*func)(void); + const char *descr; + } initializer[] = { + {H5T_init, "datatype"} + , {H5O_init, "object header"} + , {H5D_init, "dataset"} + , {H5F_init, "file"} + , {H5G_init, "group"} + , {H5A_init, "attribute"} + , {H5M_init, "map"} + , {H5CX_init, "context"} + , {H5ES_init, "event set"} + , {H5Z_init, "transform"} + , {H5PL_init, "plugin"} + , {H5R_init, "reference"} + }; + /* Initialize all packages for VOL-managed objects */ - if (H5T_init() < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to initialize datatype interface") - if (H5D_init() < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to initialize dataset interface") - if (H5F_init() < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to initialize file interface") - if (H5G_init() < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to initialize group interface") - if (H5A_init() < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to initialize attribute interface") - if (H5M_init() < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to initialize map interface") + for (i = 0; i < NELMTS(initializer); i++) { + if (initializer[i].func() < 0) { + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, + "unable to initialize %s interface", initializer[i].descr) + } + } + + /* clang-format on */ /* Sanity check default VOL connector */ HDassert(H5VL_def_conn_s.connector_id == (-1)); @@ -202,32 +218,6 @@ done: } /* end H5VL_init_phase2() */ /*------------------------------------------------------------------------- - * Function: H5VL__init_package - * - * Purpose: Initialize interface-specific information - * - * Return: Success: Non-negative - * - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VL__init_package(void) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* Initialize the ID group for the VL IDs */ - if (H5I_register_type(H5I_VOL_CLS) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to initialize H5VL interface") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__init_package() */ - -/*------------------------------------------------------------------------- * Function: H5VL_term_package * * Purpose: Terminate various H5VL objects @@ -245,37 +235,31 @@ H5VL_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5_PKG_INIT_VAR) { - if (H5VL_def_conn_s.connector_id > 0) { - /* Release the default VOL connector */ - (void)H5VL_conn_free(&H5VL_def_conn_s); - H5VL_def_conn_s.connector_id = -1; - H5VL_def_conn_s.connector_info = NULL; + if (H5VL_def_conn_s.connector_id > 0) { + /* Release the default VOL connector */ + (void)H5VL_conn_free(&H5VL_def_conn_s); + H5VL_def_conn_s.connector_id = -1; + H5VL_def_conn_s.connector_info = NULL; + n++; + } /* end if */ + else { + if (H5I_nmembers(H5I_VOL) > 0) { + /* Unregister all VOL connectors */ + (void)H5I_clear_type(H5I_VOL, TRUE, FALSE); n++; } /* end if */ else { - if (H5I_nmembers(H5I_VOL) > 0) { - /* Unregister all VOL connectors */ - (void)H5I_clear_type(H5I_VOL, TRUE, FALSE); + if (H5VL__num_opt_operation() > 0) { + /* Unregister all dynamically registered optional operations */ + (void)H5VL__term_opt_operation(); n++; } /* end if */ else { - if (H5VL__num_opt_operation() > 0) { - /* Unregister all dynamically registered optional operations */ - (void)H5VL__term_opt_operation(); - n++; - } /* end if */ - else { - /* Destroy the VOL connector ID group */ - n += (H5I_dec_type_ref(H5I_VOL) > 0); - - /* Mark interface as closed */ - if (0 == n) - H5_PKG_INIT_VAR = FALSE; - } /* end else */ - } /* end else */ - } /* end else */ - } /* end if */ + /* Destroy the VOL connector ID group */ + n += (H5I_dec_type_ref(H5I_VOL) > 0); + } /* end else */ + } /* end else */ + } /* end else */ FUNC_LEAVE_NOAPI(n) } /* end H5VL_term_package() */ @@ -972,7 +956,7 @@ H5VL_conn_inc_rc(H5VL_t *connector) { int64_t ret_value = -1; - FUNC_ENTER_NOAPI(-1) + FUNC_ENTER_NOAPI_NOERR /* Check arguments */ HDassert(connector); @@ -982,7 +966,6 @@ H5VL_conn_inc_rc(H5VL_t *connector) ret_value = connector->nrefs; -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_conn_inc_rc() */ @@ -2004,7 +1987,7 @@ H5VL_cmp_connector_cls(int *cmp_value, const H5VL_class_t *cls1, const H5VL_clas { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR /* Sanity checks */ HDassert(cls1); @@ -2532,7 +2515,7 @@ H5VL_check_plugin_load(const H5VL_class_t *cls, const H5PL_key_t *key, hbool_t * { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR /* Sanity checks */ HDassert(cls); @@ -2558,7 +2541,6 @@ H5VL_check_plugin_load(const H5VL_class_t *cls, const H5PL_key_t *key, hbool_t * if (*success && cls->version != H5VL_VERSION) *success = FALSE; -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_check_plugin_load() */ @@ -56,9 +56,6 @@ typedef enum { H5Z_PRELUDE_SET_LOCAL /* Call "set local" callback */ } H5Z_prelude_type_t; -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /* Local variables */ static size_t H5Z_table_alloc_g = 0; static size_t H5Z_table_used_g = 0; @@ -74,19 +71,23 @@ static int H5Z__check_unregister_group_cb(void *obj_ptr, hid_t obj_id, void *key static int H5Z__flush_file_cb(void *obj_ptr, hid_t obj_id, void *key); /*------------------------------------------------------------------------- - * Function: H5Z__init_package + * Function: H5Z_init * - * Purpose: Initializes the data filter layer. + * Purpose: Initialize the interface from some other layer. * - * Return: Non-negative on success/Negative on failure + * Return: Success: non-negative + * Failure: negative *------------------------------------------------------------------------- */ herr_t -H5Z__init_package(void) +H5Z_init(void) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_PACKAGE + FUNC_ENTER_NOAPI(FAIL) + + if (H5_TERM_GLOBAL) + HGOTO_DONE(SUCCEED) /* Internal filters */ if (H5Z_register(H5Z_SHUFFLE) < 0) @@ -111,7 +112,7 @@ H5Z__init_package(void) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5Z__init_package() */ +} /*------------------------------------------------------------------------- * Function: H5Z_term_package @@ -128,76 +129,70 @@ H5Z_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5_PKG_INIT_VAR) { #ifdef H5Z_DEBUG - char comment[16], bandwidth[32]; - int dir, nprint = 0; - size_t i; - - if (H5DEBUG(Z)) { - for (i = 0; i < H5Z_table_used_g; i++) { - for (dir = 0; dir < 2; dir++) { - struct { - char *user; - char *system; - char *elapsed; - } timestrs = {H5_timer_get_time_string(H5Z_stat_table_g[i].stats[dir].times.user), - H5_timer_get_time_string(H5Z_stat_table_g[i].stats[dir].times.system), - H5_timer_get_time_string(H5Z_stat_table_g[i].stats[dir].times.elapsed)}; - if (0 == H5Z_stat_table_g[i].stats[dir].total) - goto next; - - if (0 == nprint++) { - /* Print column headers */ - HDfprintf(H5DEBUG(Z), "H5Z: filter statistics " - "accumulated over life of library:\n"); - HDfprintf(H5DEBUG(Z), " %-16s %10s %10s %8s %8s %8s %10s\n", "Filter", "Total", - "Errors", "User", "System", "Elapsed", "Bandwidth"); - HDfprintf(H5DEBUG(Z), " %-16s %10s %10s %8s %8s %8s %10s\n", "------", "-----", - "------", "----", "------", "-------", "---------"); - } /* end if */ + char comment[16], bandwidth[32]; + int dir, nprint = 0; + size_t i; - /* Truncate the comment to fit in the field */ - HDstrncpy(comment, H5Z_table_g[i].name, sizeof comment); - comment[sizeof(comment) - 1] = '\0'; - - /* - * Format bandwidth to have four significant digits and - * units of `B/s', `kB/s', `MB/s', `GB/s', or `TB/s' or - * the word `Inf' if the elapsed time is zero. - */ - H5_bandwidth(bandwidth, (double)(H5Z_stat_table_g[i].stats[dir].total), - H5Z_stat_table_g[i].stats[dir].times.elapsed); - - /* Print the statistics */ - HDfprintf(H5DEBUG(Z), " %s%-15s %10" PRIdHSIZE " %10" PRIdHSIZE " %8s %8s %8s %10s\n", - (dir ? "<" : ">"), comment, H5Z_stat_table_g[i].stats[dir].total, - H5Z_stat_table_g[i].stats[dir].errors, timestrs.user, timestrs.system, - timestrs.elapsed, bandwidth); + if (H5DEBUG(Z)) { + for (i = 0; i < H5Z_table_used_g; i++) { + for (dir = 0; dir < 2; dir++) { + struct { + char *user; + char *system; + char *elapsed; + } timestrs = {H5_timer_get_time_string(H5Z_stat_table_g[i].stats[dir].times.user), + H5_timer_get_time_string(H5Z_stat_table_g[i].stats[dir].times.system), + H5_timer_get_time_string(H5Z_stat_table_g[i].stats[dir].times.elapsed)}; + if (0 == H5Z_stat_table_g[i].stats[dir].total) + goto next; + + if (0 == nprint++) { + /* Print column headers */ + HDfprintf(H5DEBUG(Z), "H5Z: filter statistics " + "accumulated over life of library:\n"); + HDfprintf(H5DEBUG(Z), " %-16s %10s %10s %8s %8s %8s %10s\n", "Filter", "Total", + "Errors", "User", "System", "Elapsed", "Bandwidth"); + HDfprintf(H5DEBUG(Z), " %-16s %10s %10s %8s %8s %8s %10s\n", "------", "-----", + "------", "----", "------", "-------", "---------"); + } /* end if */ + + /* Truncate the comment to fit in the field */ + HDstrncpy(comment, H5Z_table_g[i].name, sizeof comment); + comment[sizeof(comment) - 1] = '\0'; + + /* + * Format bandwidth to have four significant digits and + * units of `B/s', `kB/s', `MB/s', `GB/s', or `TB/s' or + * the word `Inf' if the elapsed time is zero. + */ + H5_bandwidth(bandwidth, (double)(H5Z_stat_table_g[i].stats[dir].total), + H5Z_stat_table_g[i].stats[dir].times.elapsed); + + /* Print the statistics */ + HDfprintf(H5DEBUG(Z), " %s%-15s %10" PRIdHSIZE " %10" PRIdHSIZE " %8s %8s %8s %10s\n", + (dir ? "<" : ">"), comment, H5Z_stat_table_g[i].stats[dir].total, + H5Z_stat_table_g[i].stats[dir].errors, timestrs.user, timestrs.system, + timestrs.elapsed, bandwidth); next: - HDfree(timestrs.user); - HDfree(timestrs.system); - HDfree(timestrs.elapsed); - } /* end for */ - } /* end for */ - } /* end if */ -#endif /* H5Z_DEBUG */ - - /* Free the table of filters */ - if (H5Z_table_g) { - H5Z_table_g = (H5Z_class2_t *)H5MM_xfree(H5Z_table_g); + HDfree(timestrs.user); + HDfree(timestrs.system); + HDfree(timestrs.elapsed); + } /* end for */ + } /* end for */ + } /* end if */ +#endif /* H5Z_DEBUG */ + + /* Free the table of filters */ + if (H5Z_table_g) { + H5Z_table_g = (H5Z_class2_t *)H5MM_xfree(H5Z_table_g); #ifdef H5Z_DEBUG - H5Z_stat_table_g = (H5Z_stats_t *)H5MM_xfree(H5Z_stat_table_g); + H5Z_stat_table_g = (H5Z_stats_t *)H5MM_xfree(H5Z_stat_table_g); #endif /* H5Z_DEBUG */ - H5Z_table_used_g = H5Z_table_alloc_g = 0; - - n++; - } /* end if */ + H5Z_table_used_g = H5Z_table_alloc_g = 0; - /* Mark interface as closed */ - if (0 == n) - H5_PKG_INIT_VAR = FALSE; + n++; } /* end if */ FUNC_LEAVE_NOAPI(n) @@ -1520,7 +1515,7 @@ H5Z_filter_in_pline(const H5O_pline_t *pline, H5Z_filter_t filter) size_t idx; /* Index of filter in pipeline */ htri_t ret_value = TRUE; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR HDassert(pline); HDassert(filter >= 0 && filter <= H5Z_FILTER_MAX); @@ -1534,7 +1529,6 @@ H5Z_filter_in_pline(const H5O_pline_t *pline, H5Z_filter_t filter) if (idx >= pline->nused) ret_value = FALSE; -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_filter_in_pline() */ @@ -1554,7 +1548,7 @@ H5Z_all_filters_avail(const H5O_pline_t *pline) size_t i, j; /* Local index variable */ htri_t ret_value = TRUE; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR /* Check args */ HDassert(pline); diff --git a/src/H5private.h b/src/H5private.h index 792cf00..1c3d358 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -99,8 +99,14 @@ #include <dirent.h> #endif -/* Define the default VFD for this platform. - * Since the removal of the Windows VFD, this is sec2 for all platforms. +/* Define the default VFD for this platform. Since the removal of the + * Windows VFD, this is sec2 for all platforms. + * + * Note well: if you change the default, then be sure to change + * H5_default_vfd_init() to call that default's initializer. Also, + * make sure that the initializer for each *non*-default VFD calls + * H5_init_library(); also, make sure that the initializer for default + * VFD does *not* call H5_init_library(). */ #define H5_DEFAULT_VFD H5FD_SEC2 @@ -2016,33 +2022,6 @@ extern hbool_t H5_libterm_g; /* Is the library being shutdown? */ extern hbool_t H5_MPEinit_g; /* Has the MPE Library been initialized? */ #endif -/* Macros for referencing package initialization symbols */ -#define H5_PACKAGE_INIT_VAR(x) H5_GLUE(x, _init_g) -#define H5_PACKAGE_INIT_FUNC(x) H5_GLUE(x, __init_package) - -/* Macros for defining package initialization routines */ -#ifdef H5_MY_PKG -#define H5_PKG_INIT_VAR H5_PACKAGE_INIT_VAR(H5_MY_PKG) -#define H5_PKG_INIT_FUNC H5_PACKAGE_INIT_FUNC(H5_MY_PKG) -#define H5_PACKAGE_YES_INIT(err) \ - /* Initialize this interface or bust */ \ - if (!H5_PKG_INIT_VAR && !H5_TERM_GLOBAL) { \ - H5_PKG_INIT_VAR = TRUE; \ - if (H5_PKG_INIT_FUNC() < 0) { \ - H5_PKG_INIT_VAR = FALSE; \ - HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, err, "interface initialization failed") \ - } \ - } -#define H5_PACKAGE_NO_INIT(err) \ - /* Initialize this interface or bust */ \ - if (!H5_PKG_INIT_VAR && !H5_TERM_GLOBAL) \ - H5_PKG_INIT_VAR = TRUE; -#define H5_PACKAGE_INIT(pkg_init, err) H5_GLUE3(H5_PACKAGE_, pkg_init, _INIT)(err) -#else /* H5_MY_PKG */ -#define H5_PKG_INIT_VAR (TRUE) -#define H5_PACKAGE_INIT(pkg_init, err) -#endif /* H5_MY_PKG */ - /* Forward declaration of H5CXpush() / H5CXpop() */ /* (Including H5CXprivate.h creates bad circular dependencies - QAK, 3/18/2018) */ H5_DLL herr_t H5CX_push(void); @@ -2098,10 +2077,7 @@ H5_DLL herr_t H5CX_pop(hbool_t update_dxpl_props); if (!H5_INIT_GLOBAL && !H5_TERM_GLOBAL) { \ if (H5_init_library() < 0) \ HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, err, "library initialization failed") \ - } /* end if */ \ - \ - /* Initialize the package, if appropriate */ \ - H5_PACKAGE_INIT(H5_MY_PKG_INIT, err) + } #define FUNC_ENTER_API_PUSH(err) \ /* Push the name of this function on the function stack */ \ @@ -2210,27 +2186,19 @@ H5_DLL herr_t H5CX_pop(hbool_t update_dxpl_props); FUNC_ENTER_COMMON_NOERR(H5_IS_API(__func__)); \ { -/* Note: this macro only works when there's _no_ interface initialization routine for the module */ -#define FUNC_ENTER_NOAPI_INIT(err) \ - /* Initialize the package, if appropriate */ \ - H5_PACKAGE_INIT(H5_MY_PKG_INIT, err) \ - \ - /* Push the name of this function on the function stack */ \ - H5_PUSH_FUNC - /* Use this macro for all "normal" non-API functions */ #define FUNC_ENTER_NOAPI(err) \ { \ FUNC_ENTER_COMMON(!H5_IS_API(__func__)); \ - FUNC_ENTER_NOAPI_INIT(err) \ - if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { + H5_PUSH_FUNC \ + { /* Use this macro for all non-API functions, which propagate errors, but don't issue them */ #define FUNC_ENTER_NOAPI_NOERR \ { \ FUNC_ENTER_COMMON_NOERR(!H5_IS_API(__func__)); \ - FUNC_ENTER_NOAPI_INIT(-) \ - if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { + H5_PUSH_FUNC \ + { /* * Use this macro for non-API functions which fall into these categories: @@ -2244,7 +2212,7 @@ H5_DLL herr_t H5CX_pop(hbool_t update_dxpl_props); { \ FUNC_ENTER_COMMON(!H5_IS_API(__func__)); \ H5_PUSH_FUNC \ - if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { + { /* * Use this macro for non-API functions which fall into these categories: @@ -2259,7 +2227,7 @@ H5_DLL herr_t H5CX_pop(hbool_t update_dxpl_props); { \ FUNC_ENTER_COMMON_NOERR(!H5_IS_API(__func__)); \ H5_PUSH_FUNC \ - if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { + { /* * Use this macro for non-API functions which fall into these categories: @@ -2271,9 +2239,7 @@ H5_DLL herr_t H5CX_pop(hbool_t update_dxpl_props); { \ FUNC_ENTER_COMMON(!H5_IS_API(__func__)); \ \ - /* Initialize the package, if appropriate */ \ - H5_PACKAGE_INIT(H5_MY_PKG_INIT, err) \ - if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { + { /* * Use this macro for non-API functions which fall into these categories: @@ -2287,7 +2253,7 @@ H5_DLL herr_t H5CX_pop(hbool_t update_dxpl_props); #define FUNC_ENTER_NOAPI_NOERR_NOFS \ { \ FUNC_ENTER_COMMON_NOERR(!H5_IS_API(__func__)); \ - if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { + { /* * Use this macro for non-API functions that shouldn't perform _any_ initialization @@ -2309,8 +2275,8 @@ H5_DLL herr_t H5CX_pop(hbool_t update_dxpl_props); \ FUNC_ENTER_COMMON(!H5_IS_API(__func__)); \ H5AC_tag(tag, &prev_tag); \ - FUNC_ENTER_NOAPI_INIT(err) \ - if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { + H5_PUSH_FUNC \ + { #define FUNC_ENTER_NOAPI_NOINIT_TAG(tag) \ { \ @@ -2319,21 +2285,21 @@ H5_DLL herr_t H5CX_pop(hbool_t update_dxpl_props); FUNC_ENTER_COMMON(!H5_IS_API(__func__)); \ H5AC_tag(tag, &prev_tag); \ H5_PUSH_FUNC \ - if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { + { /* Use this macro for all "normal" package-level functions */ #define FUNC_ENTER_PACKAGE \ { \ FUNC_ENTER_COMMON(H5_IS_PKG(__func__)); \ H5_PUSH_FUNC \ - if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { + { /* Use this macro for package-level functions which propgate errors, but don't issue them */ #define FUNC_ENTER_PACKAGE_NOERR \ { \ FUNC_ENTER_COMMON_NOERR(H5_IS_PKG(__func__)); \ H5_PUSH_FUNC \ - if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { + { /* Use the following macro as replacement for the FUNC_ENTER_PACKAGE * macro when the function needs to set up a metadata tag. */ @@ -2344,28 +2310,28 @@ H5_DLL herr_t H5CX_pop(hbool_t update_dxpl_props); FUNC_ENTER_COMMON(H5_IS_PKG(__func__)); \ H5AC_tag(tag, &prev_tag); \ H5_PUSH_FUNC \ - if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { + { /* Use this macro for all "normal" staticly-scoped functions */ #define FUNC_ENTER_STATIC \ { \ FUNC_ENTER_COMMON(H5_IS_PKG(__func__)); \ H5_PUSH_FUNC \ - if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { + { /* Use this macro for staticly-scoped functions which propgate errors, but don't issue them */ #define FUNC_ENTER_STATIC_NOERR \ { \ FUNC_ENTER_COMMON_NOERR(H5_IS_PKG(__func__)); \ H5_PUSH_FUNC \ - if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { + { /* Use this macro for staticly-scoped functions which propgate errors, but don't issue them */ /* And that shouldn't push their name on the function stack */ #define FUNC_ENTER_STATIC_NOERR_NOFS \ { \ FUNC_ENTER_COMMON_NOERR(H5_IS_PKG(__func__)); \ - if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { + { /* * Use this macro for non-API functions that shouldn't perform _any_ initialization @@ -2387,7 +2353,7 @@ H5_DLL herr_t H5CX_pop(hbool_t update_dxpl_props); FUNC_ENTER_COMMON(H5_IS_PKG(__func__)); \ H5AC_tag(tag, &prev_tag); \ H5_PUSH_FUNC \ - if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { + { /*------------------------------------------------------------------------- * Purpose: Register function exit for code profiling. This should be @@ -2516,27 +2482,6 @@ H5_DLL herr_t H5CX_pop(hbool_t update_dxpl_props); return (ret_value); \ } /*end scope from beginning of FUNC_ENTER*/ -/* Macros to declare package initialization function, if a package initialization routine is defined */ -#ifdef H5_PKG_SINGLE_SOURCE -#define H5_PKG_DECLARE_YES_FUNC(pkg) static herr_t H5_PACKAGE_INIT_FUNC(pkg)(void); -#else -#define H5_PKG_DECLARE_YES_FUNC(pkg) extern herr_t H5_PACKAGE_INIT_FUNC(pkg)(void); -#endif -#define H5_PKG_DECLARE_NO_FUNC(pkg) - -/* Declare package initialization symbols (if in a package) */ -#ifdef H5_PKG_SINGLE_SOURCE -#define H5_PKG_DECLARE_VAR(pkg) static hbool_t H5_PACKAGE_INIT_VAR(pkg); -#else -#define H5_PKG_DECLARE_VAR(pkg) extern hbool_t H5_PACKAGE_INIT_VAR(pkg); -#endif -#define H5_PKG_DECLARE_FUNC(pkg_init, pkg) H5_GLUE3(H5_PKG_DECLARE_, pkg_init, _FUNC)(pkg) - -#ifdef H5_MY_PKG -H5_PKG_DECLARE_VAR(H5_MY_PKG) -H5_PKG_DECLARE_FUNC(H5_MY_PKG_INIT, H5_MY_PKG) -#endif - /* Macro to begin/end tagging (when FUNC_ENTER_*TAG macros are insufficient). * Make sure to use HGOTO_ERROR_TAG and HGOTO_DONE_TAG between these macros! */ #define H5_BEGIN_TAG(tag) \ diff --git a/src/Makefile.am b/src/Makefile.am index ce6e3b1..c4023ae 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -62,7 +62,7 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5lib_settings.c H5system.c \ H5FA.c H5FAcache.c H5FAdbg.c H5FAdblock.c H5FAdblkpage.c H5FAhdr.c \ H5FAint.c H5FAstat.c H5FAtest.c \ H5FD.c H5FDcore.c H5FDfamily.c H5FDint.c H5FDlog.c \ - H5FDmulti.c H5FDsec2.c H5FDspace.c \ + H5FDmulti.c H5FDperform.c H5FDsec2.c H5FDspace.c \ H5FDsplitter.c H5FDstdio.c H5FDtest.c \ H5FL.c H5FO.c H5FS.c H5FScache.c H5FSdbg.c H5FSint.c H5FSsection.c \ H5FSstat.c H5FStest.c \ |