summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/H5.c329
-rw-r--r--src/H5A.c32
-rw-r--r--src/H5AC.c2
-rw-r--r--src/H5B.c2
-rw-r--r--src/H5D.c57
-rw-r--r--src/H5Distore.c2
-rw-r--r--src/H5E.c2
-rw-r--r--src/H5F.c61
-rw-r--r--src/H5Farray.c2
-rw-r--r--src/H5Fcore.c2
-rw-r--r--src/H5Ffamily.c9
-rw-r--r--src/H5Fistore.c2
-rw-r--r--src/H5Flow.c2
-rw-r--r--src/H5Fmpio.c2
-rw-r--r--src/H5Fsec2.c2
-rw-r--r--src/H5Fsplit.c2
-rw-r--r--src/H5Fstdio.c2
-rw-r--r--src/H5G.c29
-rw-r--r--src/H5Gent.c2
-rw-r--r--src/H5Gnode.c2
-rw-r--r--src/H5Gstab.c2
-rw-r--r--src/H5HG.c2
-rw-r--r--src/H5HL.c2
-rw-r--r--src/H5I.c35
-rw-r--r--src/H5Iprivate.h1
-rw-r--r--src/H5MF.c2
-rw-r--r--src/H5MM.c2
-rw-r--r--src/H5O.c2
-rw-r--r--src/H5Oattr.c2
-rw-r--r--src/H5Ocomp.c2
-rw-r--r--src/H5Ocont.c2
-rw-r--r--src/H5Odtype.c2
-rw-r--r--src/H5Oefl.c2
-rw-r--r--src/H5Ofill.c2
-rw-r--r--src/H5Olayout.c2
-rw-r--r--src/H5Omtime.c2
-rw-r--r--src/H5Oname.c2
-rw-r--r--src/H5Osdspace.c2
-rw-r--r--src/H5Oshared.c2
-rw-r--r--src/H5Ostab.c2
-rw-r--r--src/H5P.c26
-rw-r--r--src/H5R.c30
-rw-r--r--src/H5RA.c28
-rw-r--r--src/H5S.c188
-rw-r--r--src/H5Sall.c2
-rw-r--r--src/H5Shyper.c2
-rw-r--r--src/H5Smpio.c2
-rw-r--r--src/H5Snone.c2
-rw-r--r--src/H5Spoint.c2
-rw-r--r--src/H5Sselect.c54
-rw-r--r--src/H5T.c228
-rw-r--r--src/H5TB.c46
-rw-r--r--src/H5Tbit.c2
-rw-r--r--src/H5Tconv.c2
-rw-r--r--src/H5V.c2
-rw-r--r--src/H5Z.c111
-rw-r--r--src/H5detect.c11
-rw-r--r--src/H5private.h39
58 files changed, 627 insertions, 767 deletions
diff --git a/src/H5.c b/src/H5.c
index 42d19dc..f97409d 100644
--- a/src/H5.c
+++ b/src/H5.c
@@ -16,26 +16,6 @@ static char RcsId[] = "@(#)$Revision$";
/* $Id$ */
-/*LINTLIBRARY */
-/*+
- FILE
- hdf5.c
- HDF library support routines
-
- EXPORTED ROUTINES
- H5dont_atexit -- Indicate that an 'atexit' routine is _not_ to be installed
- H5get_libversion -- Check the version of the library
-
- LIBRARY-SCOPED ROUTINES
- H5_init_library -- initialize the HDF5 library
- H5_term_library -- shut-down the HDF5 library
- H5_init_thread -- initialize thread-specific information
-
- LOCAL ROUTINES
- H5_init_interface -- initialize the H5 interface
- + */
-
-
/* private headers */
#include <H5private.h> /*library */
#include <H5ACprivate.h> /*cache */
@@ -44,7 +24,7 @@ static char RcsId[] = "@(#)$Revision$";
#include <H5Iprivate.h> /*atoms */
#include <H5MMprivate.h> /*memory management */
#include <H5Pprivate.h> /*property lists */
-#include <H5Rpublic.h> /* References */
+#include <H5Rpublic.h> /*references */
#include <H5Sprivate.h> /*data spaces */
#include <H5Tprivate.h> /*data types */
#include <H5Zprivate.h> /*filters */
@@ -55,22 +35,13 @@ FILE *fdopen(int fd, const char *mode);
#define PABLO_MASK H5_mask
hbool_t library_initialize_g = FALSE;
-hbool_t thread_initialize_g = FALSE;
-hbool_t install_atexit_g = TRUE;
+hbool_t dont_atexit_g = FALSE;
H5_debug_t H5_debug_g; /*debugging info */
static void H5_debug_mask(const char*);
-typedef struct H5_exit {
- void (*func) (void); /* Interface function to call during exit */
- struct H5_exit *next; /* Pointer to next node with exit function */
-} H5_exit_t;
-
-H5_exit_t *lib_exit_head; /* Pointer to the head of the list of 'atexit' functions */
-
/* Interface initialization */
-static hbool_t interface_initialize_g = FALSE;
-#define INTERFACE_INIT H5_init_interface
-static herr_t H5_init_interface(void);
+static intn interface_initialize_g = 0;
+#define INTERFACE_INIT NULL
/*--------------------------------------------------------------------------
NAME
@@ -112,13 +83,17 @@ H5_init_library(void)
H5_debug_g.pkg[H5_PKG_V].name = "v";
H5_debug_g.pkg[H5_PKG_Z].name = "z";
- /* Install atexit() library cleanup routine */
- if (install_atexit_g == TRUE &&
- HDatexit(&H5_term_library) != 0) {
- HRETURN_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL,
- "unable to register atexit function");
+ /*
+ * Install atexit() library cleanup routine unless the H5dont_atexit()
+ * has been called. Once we add something to the atexit() list it stays
+ * there permanently, so we set dont_atexit_g after we add it to prevent
+ * adding it again later if the library is cosed and reopened.
+ */
+ if (!dont_atexit_g) {
+ atexit(H5_term_library);
+ dont_atexit_g = TRUE;
}
-
+
/*
* Initialize interfaces that might not be able to initialize themselves
* soon enough.
@@ -135,187 +110,113 @@ H5_init_library(void)
FUNC_LEAVE(SUCCEED);
}
-/*--------------------------------------------------------------------------
- NAME
- H5_add_exit
- PURPOSE
- Add an exit routine to the list of routines to call during 'atexit'
- USAGE
- herr_t H5_add_exit(func)
- void (*func)(void); IN: Function pointer of routine to add to chain
-
- RETURNS
- Non-negative on success/Negative on failure
- DESCRIPTION
- Pre-pend the new function to the list of function to call during the exit
- process. These routines are responsible for free'ing static buffers, etc.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- Don't make assumptions about the environment during the exit procedure...
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-herr_t
-H5_add_exit(void (*func)(void))
-{
- H5_exit_t *new_exit;
-
- FUNC_ENTER_INIT(H5_add_exit, NULL, FAIL);
-
- assert(func);
-
- if (NULL==(new_exit = H5MM_calloc(sizeof(H5_exit_t)))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
-
- new_exit->func = func;
- new_exit->next = lib_exit_head;
- lib_exit_head = new_exit;
-
- FUNC_LEAVE(SUCCEED);
-} /* end H5_add_exit() */
-
-/*--------------------------------------------------------------------------
- NAME
- H5_term_library
- PURPOSE
- Terminate various static buffers and shutdown the library.
- USAGE
- void H5_term_library()
- RETURNS
- Non-negative on success/Negative on failure
- DESCRIPTION
- Walk through the shutdown routines for the various interfaces and
- terminate them all.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- Should only ever be called by the "atexit" function, or real power-users.
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
+
+/*-------------------------------------------------------------------------
+ * Function: H5_term_library
+ *
+ * Purpose: Terminate interfaces in a well-defined order due to
+ * dependencies among the interfaces, then terminate
+ * library-specific data.
+ *
+ * Return: void
+ *
+ * Programmer: Robb Matzke
+ * Friday, November 20, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
void
H5_term_library(void)
{
- H5_exit_t *temp;
-
- temp = lib_exit_head;
- while (lib_exit_head != NULL) {
- (*lib_exit_head->func) ();
- lib_exit_head = lib_exit_head->next;
- HDfree(temp);
- temp = lib_exit_head;
- } /* end while */
-} /* end H5_term_library() */
-
-/*--------------------------------------------------------------------------
-NAME
- H5_init_thread -- Initialize thread-specific information
-USAGE
- void H5_init_thread()
-
-RETURNS
- Non-negative on success/Negative on failure
-DESCRIPTION
- Initializes any thread-specific data or routines.
-
---------------------------------------------------------------------------*/
-herr_t
-H5_init_thread(void)
-{
- FUNC_ENTER_INIT(H5_init_thread, NULL, FAIL);
-
- /* Add the "thread termination" routine to the exit chain */
- if (H5_add_exit(&H5_term_thread)<0)
- HRETURN_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL,
- "unable to set thread atexit function");
-
- FUNC_LEAVE(SUCCEED);
-} /* H5_init_thread */
-
-/*--------------------------------------------------------------------------
- NAME
- H5_term_thread
- PURPOSE
- Terminate various thread-specific objects
- USAGE
- void H5_term_thread()
- RETURNS
- Non-negative on success/Negative on failure
- DESCRIPTION
- Release the error stack and any other thread-specific resources allocated
- on a "per thread" basis.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- Can't report errors...
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-void
-H5_term_thread(void)
-{/*void*/}
+ /* Don't do anything if the library is already closed */
+ if (!library_initialize_g) return;
-/*--------------------------------------------------------------------------
-NAME
- H5_init_interface -- Initialize interface-specific information
-USAGE
- herr_t H5_init_interface()
-
-RETURNS
- Non-negative on success/Negative on failure
-DESCRIPTION
- Initializes any interface-specific data or routines.
+ /*
+ * Close interfaces in a well-defined order based on dependencies. The
+ * goal is that closing one interface doesn't reopen another that was
+ * just closed. In order to help us track down dependencies that we
+ * didn't know about, we close the interfaces in a two step process. The
+ * first step does the real work and makes the interface unusable. The
+ * second step doesn't do any work but makes it possible to reopen the
+ * interface later.
+ */
---------------------------------------------------------------------------*/
-static herr_t
-H5_init_interface(void)
-{
- FUNC_ENTER(H5_init_interface, FAIL);
+ /* Function What depends on it? */
+ /*------------------------- ------------------------------- */
+ H5D_term_interface(-1); /* */
+ H5TB_term_interface(-1); /* */
+ H5Z_term_interface(-1); /* */
+ H5A_term_interface(-1); /* */
+ H5RA_term_interface(-1); /* */
+ H5F_term_interface(-1); /* T */
+ H5G_term_interface(-1); /* */
+ H5R_term_interface(-1); /* */
+ H5S_term_interface(-1); /* */
+ H5T_native_close(-1); /* D RA */
+ H5T_term_interface(-1); /* D RA */
+ H5P_term_interface(-1); /* D */
+ H5I_term_interface(-1); /* A D F G P RA S T TB Z */
+ /*------------------------- --------------------------------- */
- FUNC_LEAVE(SUCCEED);
-} /* H5_init_interface */
+ /*
+ * Finalize the closing by calling all the functions again but with an
+ * argument of zero. This allows the interface to be reopened later.
+ */
+ H5A_term_interface(0);
+ H5D_term_interface(0);
+ H5F_term_interface(0);
+ H5G_term_interface(0);
+ H5I_term_interface(0);
+ H5P_term_interface(0);
+ H5RA_term_interface(0);
+ H5R_term_interface(0);
+ H5S_term_interface(0);
+ H5TB_term_interface(0);
+ H5T_native_close(0);
+ H5T_term_interface(0);
+ H5Z_term_interface(0);
+
+ /* Mark library as closed */
+ library_initialize_g = FALSE;
+}
-/*--------------------------------------------------------------------------
- NAME
- H5dont_atexit
- PURPOSE
- Indicates to the library that an 'atexit()' routine is _not_ to be installed
- USAGE
- herr_t H5dont_atexit(void)
- RETURNS
- Non-negative on success/Negative on failure
- DESCRIPTION
- This routine indicates to the library that an 'atexit()' cleanip routine
- should not be installed. The major (only?) purpose for this is in
- situations where the library is dynamically linked into an application and
- is un-linked from the application before 'exit()' gets callled. In those
- situations, a routine installed with 'atexit()' would jump to a routine
- which was no longer in memory, causing errors.
- In order to be effective, this routine _must_ be called before any other
- HDF function calls, and must be called each time the library is loaded/
- linked into the application. (the first time and after it's been un-loaded)
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- If this routine is used, certain memory buffers will not be de-allocated,
- although in theory a user could call HPend on their own...
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
+
+/*-------------------------------------------------------------------------
+ * Function: H5dont_atexit
+ *
+ * Purpose: Indicates that the library is not to clean up after itself
+ * when the application exits by calling exit() or returning
+ * from main(). This function must be called before any other
+ * HDF5 function or constant is used or it will have no effect.
+ *
+ * If this function is used then certain memory buffers will not
+ * be de-allocated nor will open files be flushed automatically.
+ * The application may still call H5close() explicitly to
+ * accomplish these things.
+ *
+ * Return: Success: non-negative
+ *
+ * Failure: negative if this function is called more than
+ * once or if it is called too late.
+ *
+ * Programmer: Robb Matzke
+ * Friday, November 20, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
herr_t
H5dont_atexit(void)
{
-#ifdef DONT_DO_THIS
- FUNC_ENTER_INIT(H5dont_atexit, NULL, FAIL);
-#endif /* DONT_DO_THIS */
-
- if (install_atexit_g == TRUE)
- install_atexit_g = FALSE;
-
-#ifdef DONT_DO_THIS
- FUNC_LEAVE(SUCCEED);
-#else /* DONT_DO_THIS */
+ /* FUNC_ENTER_INIT() should not be called */
+ H5_trace(FALSE, "H5dont_atexit", "");
+ if (dont_atexit_g) return FAIL;
+ dont_atexit_g = TRUE;
+ H5_trace(TRUE, NULL, "e", SUCCEED);
return(SUCCEED);
-#endif /* DONT_DO_THIS */
}
@@ -531,7 +432,7 @@ H5close (void)
* thing just to release it all right away. It is safe to call this
* function for an uninitialized library.
*/
- H5_term_library ();
+ H5_term_library();
return SUCCEED;
}
@@ -1138,6 +1039,12 @@ H5_bandwidth(char *buf/*out*/, double nbytes, double nseconds)
* Note: The TYPE string is meant to be terse and is generated by a
* separate perl script.
*
+ * WARNING: DO NOT CALL ANY HDF5 FUNCTION THAT CALLS FUNC_ENTER(). DOING
+ * SO MAY CAUSE H5_trace() TO BE INVOKED RECURSIVELY OR MAY
+ * CAUSE LIBRARY INITIALIZATIONS THAT ARE NOT DESIRED. DO NOT
+ * USE THE H5T_*_* CONSTANTS SINCE THEY CALL H5_open() WHICH
+ * INVOKES FUNC_ENTER().
+ *
* Return: void
*
* Programmer: Robb Matzke
@@ -1159,6 +1066,8 @@ H5_trace (hbool_t returning, const char *func, const char *type, ...)
void *vp = NULL;
FILE *out = H5_debug_g.trace;
+ /* FUNC_ENTER() should not be called */
+
if (!out) return; /*tracing is off*/
va_start (ap, type);
diff --git a/src/H5A.c b/src/H5A.c
index 89ee492..7ccf64d 100644
--- a/src/H5A.c
+++ b/src/H5A.c
@@ -34,12 +34,11 @@ static char RcsId[] = "$Revision$";
#define PABLO_MASK H5A_mask
/* Is the interface initialized? */
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT H5A_init_interface
static herr_t H5A_init_interface(void);
/* PRIVATE PROTOTYPES */
-static void H5A_term_interface(void);
static hid_t H5A_create(const H5G_entry_t *ent, const char *name,
const H5T_t *type, const H5S_t *space);
static hid_t H5A_open(H5G_entry_t *ent, unsigned idx);
@@ -63,26 +62,18 @@ DESCRIPTION
static herr_t
H5A_init_interface(void)
{
- herr_t ret_value = SUCCEED;
-
FUNC_ENTER(H5A_init_interface, FAIL);
/*
- * Register cleanup function.
+ * Create attribute group.
*/
- if ((ret_value = H5I_init_group(H5I_ATTR, H5I_ATTRID_HASHSIZE,
- H5A_RESERVED_ATOMS,
- (herr_t (*)(void *)) H5A_close))<0) {
+ if (H5I_init_group(H5I_ATTR, H5I_ATTRID_HASHSIZE, H5A_RESERVED_ATOMS,
+ (herr_t (*)(void *)) H5A_close)<0) {
HRETURN_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL,
- "unable to initialize attribute group");
- }
-
- if (H5_add_exit(H5A_term_interface) < 0) {
- HRETURN_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL,
- "unable to install atexit function");
+ "unable to initialize interface");
}
- FUNC_LEAVE(ret_value);
+ FUNC_LEAVE(SUCCEED);
}
@@ -94,7 +85,6 @@ H5A_init_interface(void)
USAGE
void H5A_term_interface()
RETURNS
- Non-negative on success/Negative on failure
DESCRIPTION
Release any other resources allocated.
GLOBAL VARIABLES
@@ -103,11 +93,13 @@ H5A_init_interface(void)
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-static void
-H5A_term_interface(void)
+void
+H5A_term_interface(intn status)
{
- H5I_destroy_group(H5I_ATTR);
- interface_initialize_g = FALSE;
+ if (interface_initialize_g>0) {
+ H5I_destroy_group(H5I_ATTR);
+ }
+ interface_initialize_g = status;
}
diff --git a/src/H5AC.c b/src/H5AC.c
index 73261c7..cc69208 100644
--- a/src/H5AC.c
+++ b/src/H5AC.c
@@ -36,7 +36,7 @@
*/
#define PABLO_MASK H5AC_mask
#define INTERFACE_INIT NULL
-static int interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#ifdef H5AC_SORT_BY_ADDR
static H5AC_t *current_cache_g = NULL; /*for sorting */
diff --git a/src/H5B.c b/src/H5B.c
index 8b45638..09bb967 100644
--- a/src/H5B.c
+++ b/src/H5B.c
@@ -139,7 +139,7 @@ static const H5AC_class_t H5AC_BT[1] = {{
/* Interface initialization? */
#define INTERFACE_INIT NULL
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
/*-------------------------------------------------------------------------
diff --git a/src/H5D.c b/src/H5D.c
index 15c0956..dd3cfc2 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -91,10 +91,9 @@ const H5D_xfer_t H5D_xfer_dflt = {
};
/* Interface initialization? */
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT H5D_init_interface
static herr_t H5D_init_interface(void);
-static void H5D_term_interface(void);
static herr_t H5D_init_storage(H5D_t *dataset, const H5S_t *space);
H5D_t * H5D_new(const H5D_create_t *create_parms);
@@ -114,42 +113,42 @@ DESCRIPTION
static herr_t
H5D_init_interface(void)
{
- herr_t ret_value = SUCCEED;
FUNC_ENTER(H5D_init_interface, FAIL);
/* Initialize the atom group for the dataset IDs */
- if ((ret_value = H5I_init_group(H5I_DATASET, H5I_DATASETID_HASHSIZE,
- H5D_RESERVED_ATOMS,
- (herr_t (*)(void *)) H5D_close)) >=0) {
- ret_value = H5_add_exit(H5D_term_interface);
+ if (H5I_init_group(H5I_DATASET, H5I_DATASETID_HASHSIZE, H5D_RESERVED_ATOMS,
+ (herr_t (*)(void *)) H5D_close)<0) {
+ HRETURN_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL,
+ "unable to initialize interface");
}
- FUNC_LEAVE(ret_value);
+
+ FUNC_LEAVE(SUCCEED);
}
-/*--------------------------------------------------------------------------
- NAME
- H5D_term_interface
- PURPOSE
- Terminate various H5D objects
- USAGE
- void H5D_term_interface()
- RETURNS
- Non-negative on success/Negative on failure
- DESCRIPTION
- Release the atom group and any other resources allocated.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- Can't report errors...
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-static void
-H5D_term_interface(void)
+/*-------------------------------------------------------------------------
+ * Function: H5D_term_interface
+ *
+ * Purpose: Terminate this interface.
+ *
+ * Return: void
+ *
+ * Programmer: Robb Matzke
+ * Friday, November 20, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+void
+H5D_term_interface(intn status)
{
- H5I_destroy_group(H5I_DATASET);
- interface_initialize_g = FALSE;
+ if (interface_initialize_g>0) {
+ H5I_destroy_group(H5I_DATASET);
+ }
+ interface_initialize_g = status;
}
+
/*-------------------------------------------------------------------------
* Function: H5Dcreate
diff --git a/src/H5Distore.c b/src/H5Distore.c
index 92c0dd3..89d087c 100644
--- a/src/H5Distore.c
+++ b/src/H5Distore.c
@@ -65,7 +65,7 @@
/* Interface initialization */
#define PABLO_MASK H5F_istore_mask
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
/*
diff --git a/src/H5E.c b/src/H5E.c
index 5e4ce31..3ed3c8c 100644
--- a/src/H5E.c
+++ b/src/H5E.c
@@ -110,7 +110,7 @@ static const H5E_minor_mesg_t H5E_minor_mesg_g[] = {
};
/* Interface initialization? */
-static intn interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
const hbool_t H5E_clearable_g = TRUE; /* DO NOT CHANGE */
diff --git a/src/H5F.c b/src/H5F.c
index 39e9bb3..1c7baae 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -98,9 +98,8 @@ const H5F_mprop_t H5F_mount_dflt = {
};
/* Interface initialization */
-static intn interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT H5F_init_interface
-static void H5F_term_interface(void);
/* PRIVATE PROTOTYPES */
static H5F_t *H5F_new(H5F_file_t *shared, const H5F_create_t *fcpl,
@@ -112,28 +111,27 @@ static herr_t H5F_locate_signature(H5F_low_t *f_handle,
haddr_t *addr/*out*/);
-/*--------------------------------------------------------------------------
-NAME
- H5F_init_interface -- Initialize interface-specific information
-USAGE
- herr_t H5F_init_interface()
-
-RETURNS
- Non-negative on success/Negative on failure
-DESCRIPTION
- Initializes any interface-specific data or routines.
-
-ERRORS
-
-Modifications:
- Robb Matzke, 4 Aug 1997
- Changed pablo mask from H5_mask to H5F_mask for the FUNC_LEAVE call.
- It was already H5F_mask for the PABLO_TRACE_ON call.
-
- rky 980816
- Added .disp, .btype, .ftype to H5F_access_t.
-
---------------------------------------------------------------------------*/
+/*-------------------------------------------------------------------------
+ * Function: H5F_init_interface
+ *
+ * Purpose: Initialize interface-specific information.
+ *
+ * Return: Success: non-negative
+ *
+ * Failure: negative
+ *
+ * Programmer: Robb Matzke
+ * Friday, November 20, 1998
+ *
+ * Modifications:
+ * Robb Matzke, 4 Aug 1997
+ * Changed pablo mask from H5_mask to H5F_mask for the FUNC_LEAVE call.
+ * It was already H5F_mask for the PABLO_TRACE_ON call.
+ *
+ * rky 980816
+ * Added .disp, .btype, .ftype to H5F_access_t.
+ *-------------------------------------------------------------------------
+ */
herr_t
H5F_init_interface(void)
{
@@ -154,9 +152,8 @@ H5F_init_interface(void)
/* Initialize the atom group for the file IDs */
if (H5I_init_group(H5I_FILE, H5I_FILEID_HASHSIZE, 0,
- (herr_t (*)(void*))H5F_close)<0 ||
- H5_add_exit(H5F_term_interface)<0) {
- HRETURN_ERROR (H5E_ATOM, H5E_CANTINIT, FAIL,
+ (herr_t (*)(void*))H5F_close)<0) {
+ HRETURN_ERROR (H5E_FILE, H5E_CANTINIT, FAIL,
"unable to initialize interface");
}
@@ -211,11 +208,13 @@ H5F_init_interface(void)
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-static void
-H5F_term_interface(void)
+void
+H5F_term_interface(intn status)
{
- H5I_destroy_group(H5I_FILE);
- interface_initialize_g = FALSE;
+ if (interface_initialize_g>0) {
+ H5I_destroy_group(H5I_FILE);
+ }
+ interface_initialize_g = status;
}
diff --git a/src/H5Farray.c b/src/H5Farray.c
index 38f3f07..c38709a 100644
--- a/src/H5Farray.c
+++ b/src/H5Farray.c
@@ -22,7 +22,7 @@
/* Interface initialization */
#define PABLO_MASK H5F_arr_mask
#define INTERFACE_INIT NULL
-static intn interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
diff --git a/src/H5Fcore.c b/src/H5Fcore.c
index 557aed2..4cdd1ec 100644
--- a/src/H5Fcore.c
+++ b/src/H5Fcore.c
@@ -22,7 +22,7 @@
#define H5F_CORE_DEV 0xffff /*pseudo dev for core until we fix things */
#define PABLO_MASK H5F_core
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
static htri_t H5F_core_access(const char *name,
diff --git a/src/H5Ffamily.c b/src/H5Ffamily.c
index d9fb032..0a035e2 100644
--- a/src/H5Ffamily.c
+++ b/src/H5Ffamily.c
@@ -27,7 +27,7 @@
#include <H5MMprivate.h>
#define PABLO_MASK H5F_family
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
#define H5F_FAM_OFFSET(LF,ADDR) ((off_t)((ADDR)->offset % \
@@ -454,11 +454,14 @@ H5F_fam_write(H5F_low_t *lf, const H5F_access_t *access_parms,
/*
* Make sure the logical eof is large enough to handle the request.
+ * Do not decrease the EOF
*/
max_addr = cur_addr;
H5F_addr_inc(&max_addr, (hsize_t)nbytes);
- H5F_low_seteof(lf->u.fam.memb[membno], &max_addr);
-
+ if (H5F_addr_gt(&max_addr, &(lf->u.fam.memb[membno]->eof))) {
+ H5F_low_seteof(lf->u.fam.memb[membno], &max_addr);
+ }
+
/* Write the data to the member */
if (H5F_low_write(lf->u.fam.memb[membno],
access_parms->u.fam.memb_access, xfer_mode,
diff --git a/src/H5Fistore.c b/src/H5Fistore.c
index 92c0dd3..89d087c 100644
--- a/src/H5Fistore.c
+++ b/src/H5Fistore.c
@@ -65,7 +65,7 @@
/* Interface initialization */
#define PABLO_MASK H5F_istore_mask
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
/*
diff --git a/src/H5Flow.c b/src/H5Flow.c
index 3bed7f0..3211886 100644
--- a/src/H5Flow.c
+++ b/src/H5Flow.c
@@ -18,7 +18,7 @@
#define addr_defined(X) (((uint64_t)(-1)!=(X)->offset) ? TRUE : FALSE)
#define PABLO_MASK H5F_low
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
diff --git a/src/H5Fmpio.c b/src/H5Fmpio.c
index dc67fba..27d0871 100644
--- a/src/H5Fmpio.c
+++ b/src/H5Fmpio.c
@@ -63,7 +63,7 @@
#include <mpio.h>
#define PABLO_MASK H5F_mpio
-static hbool_t interface_initialize_g = FALSE; /* rky??? */
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
/* Global var to allow elimination of redundant metadata writes
diff --git a/src/H5Fsec2.c b/src/H5Fsec2.c
index 97ecaeb..ef54477 100644
--- a/src/H5Fsec2.c
+++ b/src/H5Fsec2.c
@@ -20,7 +20,7 @@
#include <H5MMprivate.h>
#define PABLO_MASK H5F_sec2
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
static H5F_low_t *H5F_sec2_open(const char *name,
diff --git a/src/H5Fsplit.c b/src/H5Fsplit.c
index 7655054..e4298ff 100644
--- a/src/H5Fsplit.c
+++ b/src/H5Fsplit.c
@@ -22,7 +22,7 @@
#define H5F_SPLIT_RAW_EXT ".raw"
#define PABLO_MASK H5F_split
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
static htri_t H5F_split_access(const char *name,
diff --git a/src/H5Fstdio.c b/src/H5Fstdio.c
index eff325f..d55fd19 100644
--- a/src/H5Fstdio.c
+++ b/src/H5Fstdio.c
@@ -14,7 +14,7 @@
#include <H5MMprivate.h>
#define PABLO_MASK H5F_stdio
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
static H5F_low_t *H5F_stdio_open(const char *name,
diff --git a/src/H5G.c b/src/H5G.c
index 71f2e77..ceff4dc 100644
--- a/src/H5G.c
+++ b/src/H5G.c
@@ -91,10 +91,9 @@
#define PABLO_MASK H5G_mask
/* Interface initialization */
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT H5G_init_interface
static herr_t H5G_init_interface(void);
-static void H5G_term_interface(void);
static H5G_typeinfo_t *H5G_type_g = NULL; /*object typing info */
static size_t H5G_ntypes_g = 0; /*entries in type table */
static size_t H5G_atypes_g = 0; /*entries allocated */
@@ -683,8 +682,7 @@ H5G_init_interface(void)
/* Initialize the atom group for the group IDs */
if (H5I_init_group(H5I_GROUP, H5I_GROUPID_HASHSIZE, H5G_RESERVED_ATOMS,
- (herr_t (*)(void *)) H5G_close) < 0 ||
- H5_add_exit(H5G_term_interface) < 0) {
+ (herr_t (*)(void *)) H5G_close) < 0) {
HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL,
"unable to initialize interface");
}
@@ -717,21 +715,24 @@ H5G_init_interface(void)
*
*-------------------------------------------------------------------------
*/
-static void
-H5G_term_interface(void)
+void
+H5G_term_interface(intn status)
{
size_t i;
+
+ if (interface_initialize_g>0) {
+ /* Empty the object type table */
+ for (i=0; i<H5G_ntypes_g; i++) {
+ H5MM_xfree(H5G_type_g[i].desc);
+ }
+ H5G_ntypes_g = H5G_atypes_g = 0;
+ H5G_type_g = H5MM_xfree(H5G_type_g);
- /* Empty the object type table */
- for (i=0; i<H5G_ntypes_g; i++) {
- H5MM_xfree(H5G_type_g[i].desc);
+ /* Destroy the group object id group */
+ H5I_destroy_group(H5I_GROUP);
}
- H5G_ntypes_g = H5G_atypes_g = 0;
- H5G_type_g = H5MM_xfree(H5G_type_g);
- /* Destroy the group object id group */
- H5I_destroy_group(H5I_GROUP);
- interface_initialize_g = FALSE;
+ interface_initialize_g = status;
}
diff --git a/src/H5Gent.c b/src/H5Gent.c
index 70421ca..7a37e2b 100644
--- a/src/H5Gent.c
+++ b/src/H5Gent.c
@@ -14,7 +14,7 @@
#include <H5MMprivate.h>
#define PABLO_MASK H5G_ent_mask
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
diff --git a/src/H5Gnode.c b/src/H5Gnode.c
index b7810c0..ac2004f 100644
--- a/src/H5Gnode.c
+++ b/src/H5Gnode.c
@@ -91,7 +91,7 @@ H5B_class_t H5B_SNODE[1] = {{
}};
/* Interface initialization */
-static intn interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
diff --git a/src/H5Gstab.c b/src/H5Gstab.c
index 200c2e8..773c564 100644
--- a/src/H5Gstab.c
+++ b/src/H5Gstab.c
@@ -17,7 +17,7 @@
#include <H5Oprivate.h>
#define PABLO_MASK H5G_stab_mask
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
/*-------------------------------------------------------------------------
diff --git a/src/H5HG.c b/src/H5HG.c
index c72f47d..1149783 100644
--- a/src/H5HG.c
+++ b/src/H5HG.c
@@ -64,7 +64,7 @@ static const H5AC_class_t H5AC_GHEAP[1] = {{
}};
/* Interface initialization */
-static intn interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
diff --git a/src/H5HL.c b/src/H5HL.c
index edc267f..d3da812 100644
--- a/src/H5HL.c
+++ b/src/H5HL.c
@@ -61,7 +61,7 @@ static const H5AC_class_t H5AC_LHEAP[1] = {{
}};
/* Interface initialization */
-static intn interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
diff --git a/src/H5I.c b/src/H5I.c
index dfceb41..fa79b72 100644
--- a/src/H5I.c
+++ b/src/H5I.c
@@ -65,7 +65,7 @@ static char RcsId[] = "@(#)$Revision$";
/* Interface initialialization? */
#define PABLO_MASK H5I_mask
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT H5I_init_interface
static herr_t H5I_init_interface(void);
@@ -161,9 +161,6 @@ H5I_init_interface(void)
*/
assert(H5I_MAXID<=(1<<GROUP_BITS));
- /* Registers the cleanup routine with the exit chain */
- ret_value = H5_add_exit(&H5I_term_interface);
-
FUNC_LEAVE(ret_value);
}
@@ -920,28 +917,28 @@ H5I_release_id_node(H5I_id_info_t *id)
REVISION LOG
--------------------------------------------------------------------------*/
void
-H5I_term_interface(void)
+H5I_term_interface(intn status)
{
- H5I_id_info_t *curr;
- intn i;
+ H5I_id_info_t *curr;
+ intn i;
- /* Release the free-list if it exists */
- if (id_free_list != NULL) {
- while (id_free_list != NULL) {
+ if (interface_initialize_g>0) {
+ /* Release the free-list */
+ while (id_free_list) {
curr = id_free_list;
id_free_list = id_free_list->next;
HDfree(curr);
}
- }
- /* Release all groups */
- for (i = 0; i < (intn) H5I_MAXID; i++) {
- if (id_group_list[i] != NULL) {
- HDfree(id_group_list[i]);
- id_group_list[i] = NULL;
+ /* Release all groups */
+ for (i = 0; i < (intn) H5I_MAXID; i++) {
+ if (id_group_list[i] != NULL) {
+ HDfree(id_group_list[i]);
+ id_group_list[i] = NULL;
+ }
}
}
-
- /* Indicate interface closed */
- interface_initialize_g = FALSE;
+
+ /* Indicate interface status */
+ interface_initialize_g = status;
}
diff --git a/src/H5Iprivate.h b/src/H5Iprivate.h
index 788afb2..f2c179a 100644
--- a/src/H5Iprivate.h
+++ b/src/H5Iprivate.h
@@ -70,7 +70,6 @@ void *H5I_object (hid_t id);
H5I_type_t H5I_get_type (hid_t id);
void *H5I_remove (hid_t id);
void *H5I_search (H5I_type_t grp, H5I_search_func_t func, const void *key);
-void H5I_term_interface (void);
intn H5I_dec_ref (hid_t id);
hid_t H5I_inc_ref (hid_t id);
diff --git a/src/H5MF.c b/src/H5MF.c
index e8665db..9a12970 100644
--- a/src/H5MF.c
+++ b/src/H5MF.c
@@ -28,7 +28,7 @@
#define PABLO_MASK H5MF_mask
/* Is the interface initialized? */
-static intn interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
diff --git a/src/H5MM.c b/src/H5MM.c
index bc2a7ef..5d6c2c3 100644
--- a/src/H5MM.c
+++ b/src/H5MM.c
@@ -20,7 +20,7 @@
/* Interface initialization? */
#define PABLO_MASK H5MM_mask
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
diff --git a/src/H5O.c b/src/H5O.c
index e2de522..578517e 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -45,7 +45,7 @@ static const H5AC_class_t H5AC_OHDR[1] = {{
}};
/* Interface initialization */
-static intn interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT H5O_init_interface
static herr_t H5O_init_interface(void);
diff --git a/src/H5Oattr.c b/src/H5Oattr.c
index afdd533..d74d2c4 100644
--- a/src/H5Oattr.c
+++ b/src/H5Oattr.c
@@ -54,7 +54,7 @@ const H5O_class_t H5O_ATTR[1] = {{
#define H5O_ATTR_VERSION 1
/* Interface initialization */
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
/*--------------------------------------------------------------------------
diff --git a/src/H5Ocomp.c b/src/H5Ocomp.c
index 90fd622..32c4760 100644
--- a/src/H5Ocomp.c
+++ b/src/H5Ocomp.c
@@ -14,7 +14,7 @@
/* Interface initialization */
#define PABLO_MASK H5O_pline_mask
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
#define H5O_PLINE_VERSION 1
diff --git a/src/H5Ocont.c b/src/H5Ocont.c
index 3ba9b24..4cd3776 100644
--- a/src/H5Ocont.c
+++ b/src/H5Ocont.c
@@ -46,7 +46,7 @@ const H5O_class_t H5O_CONT[1] = {{
}};
/* Interface initialization */
-static intn interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
/*-------------------------------------------------------------------------
diff --git a/src/H5Odtype.c b/src/H5Odtype.c
index 2ccdfec..84de73c 100644
--- a/src/H5Odtype.c
+++ b/src/H5Odtype.c
@@ -58,7 +58,7 @@ const H5O_class_t H5O_DTYPE[1] = {{
#define H5O_DTYPE_VERSION 1
/* Interface initialization */
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
/*-------------------------------------------------------------------------
diff --git a/src/H5Oefl.c b/src/H5Oefl.c
index f812c3f..0da84d2 100644
--- a/src/H5Oefl.c
+++ b/src/H5Oefl.c
@@ -40,7 +40,7 @@ const H5O_class_t H5O_EFL[1] = {{
#define H5O_EFL_VERSION 1
/* Interface initialization */
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
diff --git a/src/H5Ofill.c b/src/H5Ofill.c
index 6d77bb8..840ea01 100644
--- a/src/H5Ofill.c
+++ b/src/H5Ofill.c
@@ -40,7 +40,7 @@ const H5O_class_t H5O_FILL[1] = {{
}};
/* Interface initialization */
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
diff --git a/src/H5Olayout.c b/src/H5Olayout.c
index 363277c..b045b3d 100644
--- a/src/H5Olayout.c
+++ b/src/H5Olayout.c
@@ -40,7 +40,7 @@ const H5O_class_t H5O_LAYOUT[1] = {{
/* Interface initialization */
#define PABLO_MASK H5O_layout_mask
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
diff --git a/src/H5Omtime.c b/src/H5Omtime.c
index 86e19b8..df0294b 100644
--- a/src/H5Omtime.c
+++ b/src/H5Omtime.c
@@ -37,7 +37,7 @@ const H5O_class_t H5O_MTIME[1] = {{
}};
/* Interface initialization */
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
diff --git a/src/H5Oname.c b/src/H5Oname.c
index 50ae81e..3179350 100644
--- a/src/H5Oname.c
+++ b/src/H5Oname.c
@@ -46,7 +46,7 @@ const H5O_class_t H5O_NAME[1] = {{
}};
/* Interface initialization */
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
diff --git a/src/H5Osdspace.c b/src/H5Osdspace.c
index 4dfaaa5..2400fe9 100644
--- a/src/H5Osdspace.c
+++ b/src/H5Osdspace.c
@@ -51,7 +51,7 @@ const H5O_class_t H5O_SDSPACE[1] = {{
#define H5O_SDSPACE_VERSION 1
/* Is the interface initialized? */
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
/*--------------------------------------------------------------------------
diff --git a/src/H5Oshared.c b/src/H5Oshared.c
index ba3971f..962430b 100644
--- a/src/H5Oshared.c
+++ b/src/H5Oshared.c
@@ -42,7 +42,7 @@ const H5O_class_t H5O_SHARED[1] = {{
/* Interface initialization */
#define PABLO_MASK H5O_shared_mask
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
diff --git a/src/H5Ostab.c b/src/H5Ostab.c
index 9f48c9d..32f0528 100644
--- a/src/H5Ostab.c
+++ b/src/H5Ostab.c
@@ -46,7 +46,7 @@ const H5O_class_t H5O_STAB[1] = {{
}};
/* Interface initialization */
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
/*-------------------------------------------------------------------------
diff --git a/src/H5P.c b/src/H5P.c
index f529128..3f00ea2 100644
--- a/src/H5P.c
+++ b/src/H5P.c
@@ -28,13 +28,10 @@ static char RcsId[] = "@(#)$Revision$";
#define PABLO_MASK H5P_mask
/* Is the interface initialized? */
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT H5P_init_interface
static herr_t H5P_init_interface(void);
-/* PRIVATE PROTOTYPES */
-static void H5P_term_interface(void);
-
/*--------------------------------------------------------------------------
NAME
H5P_init_interface -- Initialize interface-specific information
@@ -83,14 +80,6 @@ H5P_init_interface(void)
"unable to initialize atom group");
}
- /*
- * Register cleanup function.
- */
- if (H5_add_exit(H5P_term_interface) < 0) {
- HRETURN_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL,
- "unable to install atexit function");
- }
-
FUNC_LEAVE(ret_value);
}
@@ -111,15 +100,18 @@ H5P_init_interface(void)
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-static void
-H5P_term_interface(void)
+void
+H5P_term_interface(intn status)
{
intn i;
- for (i = 0; i < H5P_NCLASSES; i++) {
- H5I_destroy_group((H5I_type_t)(H5I_TEMPLATE_0 + i));
+ if (interface_initialize_g>0) {
+ for (i = 0; i < H5P_NCLASSES; i++) {
+ H5I_destroy_group((H5I_type_t)(H5I_TEMPLATE_0 + i));
+ }
}
- interface_initialize_g = FALSE;
+
+ interface_initialize_g = status;
}
/*--------------------------------------------------------------------------
diff --git a/src/H5R.c b/src/H5R.c
index 209de7f..c50f09d 100644
--- a/src/H5R.c
+++ b/src/H5R.c
@@ -29,9 +29,8 @@ static char RcsId[] = "@(#)$Revision$";
/* Interface initialization */
#define PABLO_MASK H5R_mask
#define INTERFACE_INIT H5R_init_interface
-static intn interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
static herr_t H5R_init_interface(void);
-static void H5R_term_interface(void);
/* Static functions */
static herr_t H5R_create(void *ref, H5G_entry_t *loc, const char *name,
@@ -55,17 +54,17 @@ DESCRIPTION
static herr_t
H5R_init_interface(void)
{
- herr_t ret_value = SUCCEED;
FUNC_ENTER(H5R_init_interface, FAIL);
/* Initialize the atom group for the file IDs */
- if ((ret_value = H5I_init_group(H5I_REFERENCE, H5I_REFID_HASHSIZE,
- H5R_RESERVED_ATOMS, (herr_t (*)(void *)) NULL)) >= 0) {
- ret_value = H5_add_exit(&H5R_term_interface);
+ if (H5I_init_group(H5I_REFERENCE, H5I_REFID_HASHSIZE, H5R_RESERVED_ATOMS,
+ (herr_t (*)(void *)) NULL)<0) {
+ HRETURN_ERROR (H5E_REFERENCE, H5E_CANTINIT, FAIL,
+ "unable to initialize interface");
}
- FUNC_LEAVE(ret_value);
-} /* end H5R_init_interface() */
+ FUNC_LEAVE(SUCCEED);
+}
/*--------------------------------------------------------------------------
@@ -85,13 +84,16 @@ H5R_init_interface(void)
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-static void
-H5R_term_interface(void)
+void
+H5R_term_interface(intn status)
{
- /* Free ID group */
- H5I_destroy_group(H5I_REFERENCE);
- interface_initialize_g = FALSE;
-} /* end H5R_term_interface() */
+ if (interface_initialize_g>0) {
+ /* Free ID group */
+ H5I_destroy_group(H5I_REFERENCE);
+ }
+
+ interface_initialize_g = status;
+}
/*--------------------------------------------------------------------------
diff --git a/src/H5RA.c b/src/H5RA.c
index d9eb0b5..5585b84 100644
--- a/src/H5RA.c
+++ b/src/H5RA.c
@@ -47,10 +47,9 @@ struct H5RA_t {
};
#define PABLO_MASK H5RA_mask
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT H5RA_init_interface
static herr_t H5RA_init_interface(void);
-static void H5RA_term_interface(void);
static H5T_t *H5RA_meta_type_g = NULL;
static herr_t H5RA_fix_overflow(H5RA_t *ra, H5T_t *type, H5RA_meta_t *meta,
@@ -74,15 +73,15 @@ static herr_t H5RA_fix_overflow(H5RA_t *ra, H5T_t *type, H5RA_meta_t *meta,
static herr_t
H5RA_init_interface(void)
{
- herr_t ret_value = SUCCEED;
H5T_t *type = NULL;
FUNC_ENTER(H5RA_init_interface, FAIL);
/* The atom group */
- if ((ret_value=H5I_init_group(H5I_RAGGED, H5I_RAGGED_HASHSIZE, 0,
- (herr_t(*)(void*))H5RA_close))>=0) {
- ret_value = H5_add_exit(H5RA_term_interface);
+ if (H5I_init_group(H5I_RAGGED, H5I_RAGGED_HASHSIZE, 0,
+ (herr_t(*)(void*))H5RA_close)<0) {
+ HRETURN_ERROR (H5E_RAGGED, H5E_CANTINIT, FAIL,
+ "unable to initialize interface");
}
/* The meta dataset type */
@@ -98,7 +97,7 @@ H5RA_init_interface(void)
}
H5RA_meta_type_g = type;
- FUNC_LEAVE(ret_value);
+ FUNC_LEAVE(SUCCEED);
}
@@ -116,13 +115,16 @@ H5RA_init_interface(void)
*
*-------------------------------------------------------------------------
*/
-static void
-H5RA_term_interface(void)
+void
+H5RA_term_interface(intn status)
{
- H5I_destroy_group(H5I_RAGGED);
- H5T_close(H5RA_meta_type_g);
- H5RA_meta_type_g = NULL;
- interface_initialize_g = FALSE;
+ if (interface_initialize_g>0) {
+ H5I_destroy_group(H5I_RAGGED);
+ H5T_close(H5RA_meta_type_g);
+ H5RA_meta_type_g = NULL;
+ }
+
+ interface_initialize_g = status;
}
diff --git a/src/H5S.c b/src/H5S.c
index 9675eae..1521a97 100644
--- a/src/H5S.c
+++ b/src/H5S.c
@@ -27,9 +27,8 @@ static char RcsId[] = "@(#)$Revision$";
/* Interface initialization */
#define PABLO_MASK H5S_mask
#define INTERFACE_INIT H5S_init_interface
-static intn interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
static herr_t H5S_init_interface(void);
-static void H5S_term_interface(void);
/* Tables of file and memory conversion information */
static const H5S_fconv_t *H5S_fconv_g[H5S_SEL_N];
@@ -61,13 +60,13 @@ DESCRIPTION
static herr_t
H5S_init_interface(void)
{
- herr_t ret_value = SUCCEED;
FUNC_ENTER(H5S_init_interface, FAIL);
/* Initialize the atom group for the file IDs */
- if ((ret_value = H5I_init_group(H5I_DATASPACE, H5I_DATASPACEID_HASHSIZE,
- H5S_RESERVED_ATOMS, (herr_t (*)(void *)) H5S_close)) >= 0) {
- ret_value = H5_add_exit(&H5S_term_interface);
+ if (H5I_init_group(H5I_DATASPACE, H5I_DATASPACEID_HASHSIZE,
+ H5S_RESERVED_ATOMS, (herr_t (*)(void *))H5S_close)<0) {
+ HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL,
+ "unable to initialize interface");
}
/* Register space conversion functions */
@@ -88,7 +87,7 @@ H5S_init_interface(void)
}
#endif
- FUNC_LEAVE(ret_value);
+ FUNC_LEAVE(SUCCEED);
}
@@ -109,8 +108,8 @@ H5S_init_interface(void)
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-static void
-H5S_term_interface(void)
+void
+H5S_term_interface(intn status)
{
size_t i;
@@ -118,96 +117,101 @@ H5S_term_interface(void)
int j, nprints=0;
H5S_conv_t *path=NULL;
char buf[256];
-
- /*
- * Print statistics about each conversion path.
- */
- if (H5DEBUG(S)) {
- for (i=0; i<H5S_nconv_g; i++) {
- path = H5S_conv_g[i];
- for (j=0; j<2; j++) {
- if (0==path->stats[j].gath_ncalls &&
- 0==path->stats[j].scat_ncalls &&
- 0==path->stats[j].bkg_ncalls) {
- continue;
- }
- if (0==nprints++) {
- fprintf(H5DEBUG(S), "H5S: data space conversion "
- "statistics accumulated over life of library:\n");
- fprintf(H5DEBUG(S),
- " %-16s %10s %10s %8s %8s %8s %10s\n",
- "Memory <> File", "Bytes", "Calls",
- "User", "System", "Elapsed", "Bandwidth");
- fprintf(H5DEBUG(S),
- " %-16s %10s %10s %8s %8s %8s %10s\n",
- "--------------", "-----", "-----",
- "----", "------", "-------", "---------");
- }
-
- /* Summary */
- sprintf(buf, "%s %c %s",
- path->m->name, 0==j?'>':'<', path->f->name);
- fprintf(H5DEBUG(S), " %-16s\n", buf);
-
- /* Gather */
- if (path->stats[j].gath_ncalls) {
- H5_bandwidth(buf, (double)(path->stats[j].gath_nbytes),
- path->stats[j].gath_timer.etime);
- HDfprintf(H5DEBUG(S),
- " %16s %10Hu %10Hu %8.2f %8.2f %8.2f %10s\n",
- "gather",
- path->stats[j].gath_nbytes,
- path->stats[j].gath_ncalls,
- path->stats[j].gath_timer.utime,
- path->stats[j].gath_timer.stime,
- path->stats[j].gath_timer.etime,
- buf);
- }
-
- /* Scatter */
- if (path->stats[j].scat_ncalls) {
- H5_bandwidth(buf, (double)(path->stats[j].scat_nbytes),
- path->stats[j].scat_timer.etime);
- HDfprintf(H5DEBUG(S),
- " %16s %10Hu %10Hu %8.2f %8.2f %8.2f %10s\n",
- "scatter",
- path->stats[j].scat_nbytes,
- path->stats[j].scat_ncalls,
- path->stats[j].scat_timer.utime,
- path->stats[j].scat_timer.stime,
- path->stats[j].scat_timer.etime,
- buf);
- }
+#endif
- /* Background */
- if (path->stats[j].bkg_ncalls) {
- H5_bandwidth(buf, (double)(path->stats[j].bkg_nbytes),
- path->stats[j].bkg_timer.etime);
- HDfprintf(H5DEBUG(S),
- " %16s %10Hu %10Hu %8.2f %8.2f %8.2f %10s\n",
- "background",
- path->stats[j].bkg_nbytes,
- path->stats[j].bkg_ncalls,
- path->stats[j].bkg_timer.utime,
- path->stats[j].bkg_timer.stime,
- path->stats[j].bkg_timer.etime,
- buf);
+ if (interface_initialize_g>0) {
+#ifdef H5S_DEBUG
+ /*
+ * Print statistics about each conversion path.
+ */
+ if (H5DEBUG(S)) {
+ for (i=0; i<H5S_nconv_g; i++) {
+ path = H5S_conv_g[i];
+ for (j=0; j<2; j++) {
+ if (0==path->stats[j].gath_ncalls &&
+ 0==path->stats[j].scat_ncalls &&
+ 0==path->stats[j].bkg_ncalls) {
+ continue;
+ }
+ if (0==nprints++) {
+ fprintf(H5DEBUG(S), "H5S: data space conversion "
+ "statistics:\n");
+ fprintf(H5DEBUG(S),
+ " %-16s %10s %10s %8s %8s %8s %10s\n",
+ "Memory <> File", "Bytes", "Calls",
+ "User", "System", "Elapsed", "Bandwidth");
+ fprintf(H5DEBUG(S),
+ " %-16s %10s %10s %8s %8s %8s %10s\n",
+ "--------------", "-----", "-----",
+ "----", "------", "-------", "---------");
+ }
+
+ /* Summary */
+ sprintf(buf, "%s %c %s",
+ path->m->name, 0==j?'>':'<', path->f->name);
+ fprintf(H5DEBUG(S), " %-16s\n", buf);
+
+ /* Gather */
+ if (path->stats[j].gath_ncalls) {
+ H5_bandwidth(buf, (double)(path->stats[j].gath_nbytes),
+ path->stats[j].gath_timer.etime);
+ HDfprintf(H5DEBUG(S),
+ " %16s %10Hu %10Hu %8.2f %8.2f %8.2f "
+ "%10s\n", "gather",
+ path->stats[j].gath_nbytes,
+ path->stats[j].gath_ncalls,
+ path->stats[j].gath_timer.utime,
+ path->stats[j].gath_timer.stime,
+ path->stats[j].gath_timer.etime,
+ buf);
+ }
+
+ /* Scatter */
+ if (path->stats[j].scat_ncalls) {
+ H5_bandwidth(buf, (double)(path->stats[j].scat_nbytes),
+ path->stats[j].scat_timer.etime);
+ HDfprintf(H5DEBUG(S),
+ " %16s %10Hu %10Hu %8.2f %8.2f %8.2f "
+ "%10s\n", "scatter",
+ path->stats[j].scat_nbytes,
+ path->stats[j].scat_ncalls,
+ path->stats[j].scat_timer.utime,
+ path->stats[j].scat_timer.stime,
+ path->stats[j].scat_timer.etime,
+ buf);
+ }
+
+ /* Background */
+ if (path->stats[j].bkg_ncalls) {
+ H5_bandwidth(buf, (double)(path->stats[j].bkg_nbytes),
+ path->stats[j].bkg_timer.etime);
+ HDfprintf(H5DEBUG(S),
+ " %16s %10Hu %10Hu %8.2f %8.2f %8.2f "
+ "%10s\n", "background",
+ path->stats[j].bkg_nbytes,
+ path->stats[j].bkg_ncalls,
+ path->stats[j].bkg_timer.utime,
+ path->stats[j].bkg_timer.stime,
+ path->stats[j].bkg_timer.etime,
+ buf);
+ }
}
}
}
- }
#endif
- /* Free data types */
- H5I_destroy_group(H5I_DATASPACE);
+ /* Free data types */
+ H5I_destroy_group(H5I_DATASPACE);
- /* Clear/free conversion table */
- HDmemset(H5S_fconv_g, 0, sizeof(H5S_fconv_g));
- HDmemset(H5S_mconv_g, 0, sizeof(H5S_mconv_g));
- for (i=0; i<H5S_nconv_g; i++) H5MM_xfree(H5S_conv_g[i]);
- H5S_conv_g = H5MM_xfree(H5S_conv_g);
- H5S_nconv_g = H5S_aconv_g = 0;
- interface_initialize_g = FALSE;
+ /* Clear/free conversion table */
+ HDmemset(H5S_fconv_g, 0, sizeof(H5S_fconv_g));
+ HDmemset(H5S_mconv_g, 0, sizeof(H5S_mconv_g));
+ for (i=0; i<H5S_nconv_g; i++) H5MM_xfree(H5S_conv_g[i]);
+ H5S_conv_g = H5MM_xfree(H5S_conv_g);
+ H5S_nconv_g = H5S_aconv_g = 0;
+ }
+
+ interface_initialize_g = status;
}
diff --git a/src/H5Sall.c b/src/H5Sall.c
index 8904339..1148594 100644
--- a/src/H5Sall.c
+++ b/src/H5Sall.c
@@ -16,7 +16,7 @@
/* Interface initialization */
#define PABLO_MASK H5S_all_mask
#define INTERFACE_INIT NULL
-static intn interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
static herr_t H5S_all_init (const struct H5O_layout_t *layout,
const H5S_t *space, H5S_sel_iter_t *iter);
diff --git a/src/H5Shyper.c b/src/H5Shyper.c
index a3fef1e..2392ea9 100644
--- a/src/H5Shyper.c
+++ b/src/H5Shyper.c
@@ -18,7 +18,7 @@
/* Interface initialization */
#define PABLO_MASK H5S_hyper_mask
#define INTERFACE_INIT NULL
-static intn interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
/* Local datatypes */
/* Parameter block for H5S_hyper_fread & H5S_hyper_fwrite */
diff --git a/src/H5Smpio.c b/src/H5Smpio.c
index e49916e..7cf93a6 100644
--- a/src/H5Smpio.c
+++ b/src/H5Smpio.c
@@ -29,7 +29,7 @@
/* Interface initialization */
#define PABLO_MASK H5S_all_mask
#define INTERFACE_INIT NULL
-static intn interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
static herr_t
H5S_mpio_all_type( const H5S_t *space, const size_t elmt_size,
diff --git a/src/H5Snone.c b/src/H5Snone.c
index 6721d98..beaeb58 100644
--- a/src/H5Snone.c
+++ b/src/H5Snone.c
@@ -16,7 +16,7 @@
/* Interface initialization */
#define PABLO_MASK H5S_none_mask
#define INTERFACE_INIT NULL
-static intn interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
/*--------------------------------------------------------------------------
diff --git a/src/H5Spoint.c b/src/H5Spoint.c
index e52eb14..ae4a217 100644
--- a/src/H5Spoint.c
+++ b/src/H5Spoint.c
@@ -17,7 +17,7 @@
/* Interface initialization */
#define PABLO_MASK H5S_point_mask
#define INTERFACE_INIT NULL
-static intn interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
static herr_t H5S_point_init (const struct H5O_layout_t *layout,
const H5S_t *space, H5S_sel_iter_t *iter);
diff --git a/src/H5Sselect.c b/src/H5Sselect.c
index f5db9ad..c97a350 100644
--- a/src/H5Sselect.c
+++ b/src/H5Sselect.c
@@ -18,62 +18,12 @@
/* Interface initialization */
#define PABLO_MASK H5S_select_mask
-#define INTERFACE_INIT H5S_select_init
-static intn interface_initialize_g = FALSE;
-static herr_t H5S_select_init(void);
-static void H5S_select_term(void);
+#define INTERFACE_INIT NULL
+static intn interface_initialize_g = 0;
/*--------------------------------------------------------------------------
NAME
- H5S_select_init
- PURPOSE
- Initialize selection interface
- USAGE
- herr_t H5S_select_init(void)
- RETURNS
- Non-negative on success/Negative on failure
- DESCRIPTION
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-herr_t
-H5S_select_init (void)
-{
- herr_t ret_value = SUCCEED;
- FUNC_ENTER (H5S_select_init, FAIL);
-
- /* Register the atexit function for this (sub)interface */
- ret_value = H5_add_exit(&H5S_select_term);
- FUNC_LEAVE(ret_value);
-}
-
-/*--------------------------------------------------------------------------
- NAME
- H5S_select_term
- PURPOSE
- Terminate various H5S selection objects and free lists
- USAGE
- void H5S_select_term()
- RETURNS
- Non-negative on success/Negative on failure
- DESCRIPTION
- Release the selection resources allocated.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- Can't report errors...
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-static void
-H5S_select_term(void)
-{
-}
-
-/*--------------------------------------------------------------------------
- NAME
H5S_select_copy
PURPOSE
Copy a selection from one dataspace to another
diff --git a/src/H5T.c b/src/H5T.c
index e3d84d4..c964cad 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -26,9 +26,8 @@ static char RcsId[] = "@(#)$Revision$";
#define H5T_COMPND_INC 64 /*typical max numb of members per struct */
/* Interface initialization */
-static intn interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT H5T_init_interface
-static void H5T_term_interface(void);
hid_t H5T_IEEE_F32BE_g = FAIL;
hid_t H5T_IEEE_F32LE_g = FAIL;
@@ -123,23 +122,25 @@ herr_t
H5T_init_interface(void)
{
H5T_t *dt = NULL;
- herr_t ret_value = SUCCEED;
interface_initialize_g = TRUE;
FUNC_ENTER(H5T_init_interface, FAIL);
/* Initialize the atom group for the file IDs */
- if ((ret_value = H5I_init_group(H5I_DATATYPE, H5I_DATATYPEID_HASHSIZE,
- H5T_RESERVED_ATOMS,
- (herr_t (*)(void *)) H5T_close)) >= 0) {
- ret_value = H5_add_exit(&H5T_term_interface);
+ if (H5I_init_group(H5I_DATATYPE, H5I_DATATYPEID_HASHSIZE,
+ H5T_RESERVED_ATOMS, (herr_t (*)(void *))H5T_close)<0) {
+ HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
+ "unable to initialize interface");
}
/*
* Initialize pre-defined native data types from code generated during
* the library configuration by H5detect.
*/
- ret_value = H5T_native_open();
+ if (H5T_native_open()<0) {
+ HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
+ "unable to initialize interface");
+ }
/*------------------------------------------------------------
* Native types
@@ -1163,7 +1164,7 @@ H5T_init_interface(void)
"unable to register conversion function");
}
- FUNC_LEAVE(ret_value);
+ FUNC_LEAVE(SUCCEED);
}
@@ -1196,29 +1197,25 @@ H5T_unlock_cb (void *_dt, const void __unused__ *key)
FUNC_LEAVE (0);
}
-/*--------------------------------------------------------------------------
- NAME
- H5T_term_interface
- PURPOSE
- Terminate various H5T objects
- USAGE
- void H5T_term_interface()
- RETURNS
- Non-negative on success/Negative on failure
- DESCRIPTION
- Release the atom group and any other resources allocated.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- Can't report errors...
- EXAMPLES
- REVISION LOG
+
+/*-------------------------------------------------------------------------
+ * Function: H5T_term_interface
+ *
+ * Purpose: Close this interface.
+ *
+ * Return: void
+ *
+ * Programmer: Robb Matzke
+ * Friday, November 20, 1998
+ *
+ * Modifications:
* Robb Matzke, 1998-06-11
* Statistics are only printed for conversion functions that were
* called.
- *
---------------------------------------------------------------------------*/
-static void
-H5T_term_interface(void)
+ *-------------------------------------------------------------------------
+ */
+void
+H5T_term_interface(intn status)
{
intn i;
H5T_path_t *path = NULL;
@@ -1230,110 +1227,115 @@ H5T_term_interface(void)
H5T_cdata_t *cdata;
char bandwidth[32];
#endif
-
- /* Unregister all conversion functions */
- for (i=0; i<H5T_npath_g; i++) {
- path = H5T_path_g[i];
- assert (path);
- if (path->func) {
- path->cdata.command = H5T_CONV_FREE;
- if ((path->func)(FAIL, FAIL, &(path->cdata), 0, NULL, NULL)<0) {
+ if (interface_initialize_g>0) {
+ /* Unregister all conversion functions */
+ for (i=0; i<H5T_npath_g; i++) {
+ path = H5T_path_g[i];
+ assert (path);
+
+ if (path->func) {
+ path->cdata.command = H5T_CONV_FREE;
+ if ((path->func)(FAIL, FAIL, &(path->cdata), 0, NULL,
+ NULL)<0) {
#ifdef H5T_DEBUG
- if (H5DEBUG(T)) {
- fprintf (H5DEBUG(T), "H5T: conversion function failed "
- "to free private data for %s\n", path->name);
+ if (H5DEBUG(T)) {
+ fprintf (H5DEBUG(T), "H5T: conversion function failed "
+ "to free private data for %s\n", path->name);
+ }
+#endif
+ H5E_clear(); /*ignore the error*/
+ }
+#ifdef H5T_DEBUG
+ if (H5DEBUG(T) && path->cdata.stats->ncalls>0) {
+ if (0==nprint++) {
+ HDfprintf (H5DEBUG(T),
+ "H5T: type conversion statistics:\n");
+ HDfprintf (H5DEBUG(T),
+ " %-16s %10s %10s %8s %8s %8s %10s\n",
+ "Conversion", "Elmts", "Calls", "User",
+ "System", "Elapsed", "Bandwidth");
+ HDfprintf (H5DEBUG(T),
+ " %-16s %10s %10s %8s %8s %8s %10s\n",
+ "----------", "-----", "-----", "----",
+ "------", "-------", "---------");
+ }
+ nbytes = MAX (H5T_get_size (path->src),
+ H5T_get_size (path->dst));
+ nbytes *= path->cdata.stats->nelmts;
+ H5_bandwidth(bandwidth, (double)nbytes,
+ path->cdata.stats->timer.etime);
+ HDfprintf (H5DEBUG(T),
+ " %-16s %10Hd %10d %8.2f %8.2f %8.2f %10s\n",
+ path->name,
+ path->cdata.stats->nelmts,
+ path->cdata.stats->ncalls,
+ path->cdata.stats->timer.utime,
+ path->cdata.stats->timer.stime,
+ path->cdata.stats->timer.etime,
+ bandwidth);
}
#endif
- H5E_clear(); /*ignore the error*/
+ H5T_close (path->src);
+ H5T_close (path->dst);
+ H5MM_xfree (path->cdata.stats);
}
+ H5MM_xfree (path);
+ H5T_path_g[i] = NULL;
+ }
+
#ifdef H5T_DEBUG
- if (H5DEBUG(T) && path->cdata.stats->ncalls>0) {
+ /* Print debugging infor for the `noop' conversion */
+ if (H5DEBUG(T) &&
+ H5T_conv_noop==H5T_find(NULL, NULL, H5T_BKG_NO, &cdata)) {
+ if (cdata->stats->ncalls>0) {
if (0==nprint++) {
- HDfprintf (H5DEBUG(T), "H5T: type conversion statistics "
- "accumulated over life of function:\n");
HDfprintf (H5DEBUG(T),
- " %-16s %10s %10s %8s %8s %8s %10s\n",
- "Conversion", "Elmts", "Calls", "User",
- "System", "Elapsed", "Bandwidth");
- HDfprintf (H5DEBUG(T),
- " %-16s %10s %10s %8s %8s %8s %10s\n",
- "----------", "-----", "-----", "----",
- "------", "-------", "---------");
+ "H5T: type conversion statistics\n");
+ HDfprintf (H5DEBUG(T), " %-16s %10s %10s %8s %8s %8s "
+ "%10s\n", "Conversion", "Elmts", "Calls",
+ "User", "System", "Elapsed", "Bandwidth");
+ HDfprintf (H5DEBUG(T), " %-16s %10s %10s %8s %8s %8s "
+ "%10s\n", "----------", "-----", "-----",
+ "----", "------", "-------", "---------");
}
- nbytes = MAX (H5T_get_size (path->src),
- H5T_get_size (path->dst));
- nbytes *= path->cdata.stats->nelmts;
+ nbytes = cdata->stats->nelmts;
H5_bandwidth(bandwidth, (double)nbytes,
- path->cdata.stats->timer.etime);
+ cdata->stats->timer.etime);
HDfprintf (H5DEBUG(T),
" %-16s %10Hd %10d %8.2f %8.2f %8.2f %10s\n",
- path->name,
- path->cdata.stats->nelmts,
- path->cdata.stats->ncalls,
- path->cdata.stats->timer.utime,
- path->cdata.stats->timer.stime,
- path->cdata.stats->timer.etime,
+ "no-op",
+ cdata->stats->nelmts,
+ cdata->stats->ncalls,
+ cdata->stats->timer.utime,
+ cdata->stats->timer.stime,
+ cdata->stats->timer.etime,
bandwidth);
}
-#endif
- H5T_close (path->src);
- H5T_close (path->dst);
- H5MM_xfree (path->cdata.stats);
}
- H5MM_xfree (path);
- H5T_path_g[i] = NULL;
- }
-
-#ifdef H5T_DEBUG
- /* Print debugging infor for the `noop' conversion */
- if (H5DEBUG(T) &&
- H5T_conv_noop==H5T_find(NULL, NULL, H5T_BKG_NO, &cdata)) {
- if (cdata->stats->ncalls>0) {
- if (0==nprint++) {
- HDfprintf (H5DEBUG(T), "H5T: type conversion statistics "
- "accumulated over life of library:\n");
- HDfprintf (H5DEBUG(T), " %-16s %10s %10s %8s %8s %8s %10s\n",
- "Conversion", "Elmts", "Calls", "User",
- "System", "Elapsed", "Bandwidth");
- HDfprintf (H5DEBUG(T), " %-16s %10s %10s %8s %8s %8s %10s\n",
- "----------", "-----", "-----", "----",
- "------", "-------", "---------");
- }
- nbytes = cdata->stats->nelmts;
- H5_bandwidth(bandwidth, (double)nbytes, cdata->stats->timer.etime);
- HDfprintf (H5DEBUG(T),
- " %-16s %10Hd %10d %8.2f %8.2f %8.2f %10s\n",
- "no-op",
- cdata->stats->nelmts,
- cdata->stats->ncalls,
- cdata->stats->timer.utime,
- cdata->stats->timer.stime,
- cdata->stats->timer.etime,
- bandwidth);
- }
- }
#endif
- /* Clear conversion tables */
- H5T_apath_g = 0;
- H5T_npath_g = 0;
- H5T_path_g = H5MM_xfree (H5T_path_g);
+ /* Clear conversion tables */
+ H5T_apath_g = 0;
+ H5T_npath_g = 0;
+ H5T_path_g = H5MM_xfree (H5T_path_g);
- H5T_asoft_g = 0;
- H5T_nsoft_g = 0;
- H5T_soft_g = H5MM_xfree (H5T_soft_g);
+ H5T_asoft_g = 0;
+ H5T_nsoft_g = 0;
+ H5T_soft_g = H5MM_xfree (H5T_soft_g);
- /* Clear noop function */
- if ((cfunc=H5T_find (NULL, NULL, H5T_BKG_NO, &pcdata))) {
- pcdata->command = H5T_CONV_FREE;
- (cfunc)(FAIL, FAIL, pcdata, 0, NULL, NULL);
- }
+ /* Clear noop function */
+ if ((cfunc=H5T_find (NULL, NULL, H5T_BKG_NO, &pcdata))) {
+ pcdata->command = H5T_CONV_FREE;
+ (cfunc)(FAIL, FAIL, pcdata, 0, NULL, NULL);
+ }
- /* Unlock all datatypes, then free them */
- H5I_search (H5I_DATATYPE, H5T_unlock_cb, NULL);
- H5I_destroy_group(H5I_DATATYPE);
- interface_initialize_g = FALSE;
+ /* Unlock all datatypes, then free them */
+ H5I_search (H5I_DATATYPE, H5T_unlock_cb, NULL);
+ H5I_destroy_group(H5I_DATATYPE);
+ }
+
+ interface_initialize_g = status;
}
diff --git a/src/H5TB.c b/src/H5TB.c
index de6473c..93b87d6 100644
--- a/src/H5TB.c
+++ b/src/H5TB.c
@@ -43,9 +43,8 @@ static char RcsId[] = "@(#)$Revision$";
/* Interface init/term information */
#define PABLO_MASK H5TB_mask
#define INTERFACE_INIT H5TB_init_interface
-static intn interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
static herr_t H5TB_init_interface(void);
-static void H5TB_term_interface(void);
/* Local information for managing buffers */
#define H5TB_RESERVED_ATOMS 0
@@ -80,15 +79,15 @@ DESCRIPTION
static herr_t
H5TB_init_interface(void)
{
- herr_t ret_value = SUCCEED;
FUNC_ENTER(H5TB_init_interface, FAIL);
/* Initialize the atom group for the file IDs */
- if ((ret_value = H5I_init_group(H5I_TEMPBUF, H5I_TEMPBUFID_HASHSIZE,
- H5TB_RESERVED_ATOMS, NULL)) >= 0) {
- ret_value = H5_add_exit(&H5TB_term_interface);
+ if (H5I_init_group(H5I_TEMPBUF, H5I_TEMPBUFID_HASHSIZE,
+ H5TB_RESERVED_ATOMS, NULL)<0) {
+ HRETURN_ERROR (H5E_INTERNAL, H5E_CANTINIT, FAIL,
+ "unable to initialize interface");
}
- FUNC_LEAVE(ret_value);
+ FUNC_LEAVE(SUCCEED);
}
@@ -109,29 +108,32 @@ H5TB_init_interface(void)
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-static void
-H5TB_term_interface(void)
+void
+H5TB_term_interface(intn status)
{
H5TB_t *curr=H5TB_list_head, /* pointer to current temp. buffer */
*next; /* pointer to next temp. buffer */
- /* Destroy the atom group */
- H5I_destroy_group(H5I_TEMPBUF);
+ if (interface_initialize_g>0) {
+ /* Destroy the atom group */
+ H5I_destroy_group(H5I_TEMPBUF);
- /* Step through the list and free the buffers */
- while(curr!=NULL) {
- next=curr->next;
+ /* Step through the list and free the buffers */
+ while(curr!=NULL) {
+ next=curr->next;
- if(curr->buf!=NULL)
- H5MM_xfree(curr->buf);
- H5MM_xfree(curr);
+ if(curr->buf!=NULL)
+ H5MM_xfree(curr->buf);
+ H5MM_xfree(curr);
- curr=next;
- } /* end while */
+ curr=next;
+ } /* end while */
- /* Reset head & tail pointers */
- H5TB_list_head=H5TB_list_tail=NULL;
- interface_initialize_g = FALSE;
+ /* Reset head & tail pointers */
+ H5TB_list_head=H5TB_list_tail=NULL;
+ }
+
+ interface_initialize_g = status;
}
/*-------------------------------------------------------------------------
diff --git a/src/H5Tbit.c b/src/H5Tbit.c
index 6a5474d..ed074ab 100644
--- a/src/H5Tbit.c
+++ b/src/H5Tbit.c
@@ -17,7 +17,7 @@
/* Interface initialization */
#define PABLO_MASK H5Tbit_mask
-static intn interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
diff --git a/src/H5Tconv.c b/src/H5Tconv.c
index a1fc1aa..481437e 100644
--- a/src/H5Tconv.c
+++ b/src/H5Tconv.c
@@ -26,7 +26,7 @@ typedef struct H5T_conv_struct_t {
} H5T_conv_struct_t;
/* Interface initialization */
-static intn interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
/*
diff --git a/src/H5V.c b/src/H5V.c
index 6504ed0..15cf867 100644
--- a/src/H5V.c
+++ b/src/H5V.c
@@ -13,7 +13,7 @@
#define H5V_HYPER_NDIMS H5O_LAYOUT_NDIMS
#define PABLO_MASK H5V_mask
-static hbool_t interface_initialize_g = TRUE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
diff --git a/src/H5Z.c b/src/H5Z.c
index 1a52b78..c9c6d13 100644
--- a/src/H5Z.c
+++ b/src/H5Z.c
@@ -20,9 +20,8 @@
/* Interface initialization */
#define PABLO_MASK H5Z_mask
#define INTERFACE_INIT H5Z_init_interface
-static intn interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
static herr_t H5Z_init_interface (void);
-static void H5Z_term_interface (void);
static size_t H5Z_table_alloc_g = 0;
static size_t H5Z_table_used_g = 0;
@@ -52,10 +51,8 @@ static herr_t
H5Z_init_interface (void)
{
FUNC_ENTER (H5Z_init_interface, FAIL);
- H5_add_exit (H5Z_term_interface);
- H5Z_register (H5Z_FILTER_DEFLATE, "deflate",
- H5Z_filter_deflate);
+ H5Z_register (H5Z_FILTER_DEFLATE, "deflate", H5Z_filter_deflate);
FUNC_LEAVE (SUCCEED);
}
@@ -75,69 +72,73 @@ H5Z_init_interface (void)
*
*-------------------------------------------------------------------------
*/
-static void
-H5Z_term_interface (void)
+void
+H5Z_term_interface (intn status)
{
size_t i;
-
#ifdef H5Z_DEBUG
int dir, nprint=0;
char comment[16], bandwidth[32];
+#endif
- if (H5DEBUG(Z)) {
- for (i=0; i<H5Z_table_used_g; i++) {
- for (dir=0; dir<2; dir++) {
- if (0==H5Z_table_g[i].stats[dir].total) continue;
-
- 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");
+ if (interface_initialize_g>0) {
+#ifdef H5Z_DEBUG
+ if (H5DEBUG(Z)) {
+ for (i=0; i<H5Z_table_used_g; i++) {
+ for (dir=0; dir<2; dir++) {
+ if (0==H5Z_table_g[i].stats[dir].total) continue;
+
+ 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",
+ "------", "-----", "------", "----",
+ "------", "-------", "---------");
+ }
+
+ /* 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_table_g[i].stats[dir].total),
+ H5Z_table_g[i].stats[dir].timer.etime);
+
+ /* Print the statistics */
HDfprintf (H5DEBUG(Z),
- " %-16s %10s %10s %8s %8s %8s %10s\n",
- "------", "-----", "------", "----",
- "------", "-------", "---------");
+ " %s%-15s %10Hd %10Hd %8.2f %8.2f %8.2f "
+ "%10s\n", dir?"<":">", comment,
+ H5Z_table_g[i].stats[dir].total,
+ H5Z_table_g[i].stats[dir].errors,
+ H5Z_table_g[i].stats[dir].timer.utime,
+ H5Z_table_g[i].stats[dir].timer.stime,
+ H5Z_table_g[i].stats[dir].timer.etime,
+ bandwidth);
}
-
- /* 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_table_g[i].stats[dir].total),
- H5Z_table_g[i].stats[dir].timer.etime);
-
- /* Print the statistics */
- HDfprintf (H5DEBUG(Z),
- " %s%-15s %10Hd %10Hd %8.2f %8.2f %8.2f "
- "%10s\n", dir?"<":">", comment,
- H5Z_table_g[i].stats[dir].total,
- H5Z_table_g[i].stats[dir].errors,
- H5Z_table_g[i].stats[dir].timer.utime,
- H5Z_table_g[i].stats[dir].timer.stime,
- H5Z_table_g[i].stats[dir].timer.etime,
- bandwidth);
}
}
- }
#endif
- /* Free the table */
- for (i=0; i<H5Z_table_used_g; i++) {
- H5MM_xfree(H5Z_table_g[i].name);
+ /* Free the table */
+ for (i=0; i<H5Z_table_used_g; i++) {
+ H5MM_xfree(H5Z_table_g[i].name);
+ }
+ H5Z_table_g = H5MM_xfree(H5Z_table_g);
+ H5Z_table_used_g = H5Z_table_alloc_g = 0;
}
- H5Z_table_g = H5MM_xfree(H5Z_table_g);
- H5Z_table_used_g = H5Z_table_alloc_g = 0;
- interface_initialize_g = FALSE;
+
+ interface_initialize_g = status;
}
diff --git a/src/H5detect.c b/src/H5detect.c
index 44b0486..57aa066 100644
--- a/src/H5detect.c
+++ b/src/H5detect.c
@@ -321,16 +321,16 @@ print_results(int nd, detected_t *d)
#include <H5MMprivate.h>\n\
#include <H5Tpkg.h>\n\
\n\
-static hbool_t interface_initialize_g = FALSE;\n\
+static intn interface_initialize_g = 0;\n\
#define INTERFACE_INIT NULL\n\
\n");
/* The interface termination function */
printf("\n\
-static void\n\
-H5T_native_close(void)\n\
+void\n\
+H5T_native_close(intn status)\n\
{\n\
- interface_initialize_g = FALSE;\n\
+ interface_initialize_g = status;\n\
}\n");
/* The interface initialization function */
@@ -340,8 +340,7 @@ H5T_native_open (void)\n\
{\n\
H5T_t *dt = NULL;\n\
\n\
- FUNC_ENTER (H5T_init, FAIL);\n\
- H5_add_exit(&H5T_native_close);\n");
+ FUNC_ENTER (H5T_init, FAIL);\n");
for (i = 0; i < nd; i++) {
diff --git a/src/H5private.h b/src/H5private.h
index 87d973a..1e55eb3 100644
--- a/src/H5private.h
+++ b/src/H5private.h
@@ -818,7 +818,6 @@ void H5_trace (hbool_t returning, const char *func, const char *type, ...);
*-------------------------------------------------------------------------
*/
extern hbool_t library_initialize_g; /*good thing C's lazy about extern! */
-extern hbool_t thread_initialize_g; /*don't decl interface_initialize_g */
/* Is `S' the name of an API function? */
#define H5_IS_API(S) ('_'!=S[2] && '_'!=S[3] && (!S[4] || '_'!=S[4]))
@@ -839,18 +838,9 @@ extern hbool_t thread_initialize_g; /*don't decl interface_initialize_g */
HRETURN_ERROR (H5E_FUNC, H5E_CANTINIT, err, \
"library initialization failed"); \
} \
- } \
+ } \
\
- /* Initialize this thread */ \
- if (!thread_initialize_g) { \
- thread_initialize_g = TRUE; \
- if (H5_init_thread()<0) { \
- HRETURN_ERROR (H5E_FUNC, H5E_CANTINIT, err, \
- "thread initialization failed"); \
- } \
- } \
- \
- /* Initialize this interface */ \
+ /* Initialize this interface or bust */ \
if (!interface_initialize_g) { \
interface_initialize_g = TRUE; \
if (interface_init_func && \
@@ -858,10 +848,14 @@ extern hbool_t thread_initialize_g; /*don't decl interface_initialize_g */
HRETURN_ERROR (H5E_FUNC, H5E_CANTINIT, err, \
"interface initialization failed"); \
} \
+ } else if (interface_initialize_g<0) { \
+ HRETURN_ERROR(H5E_FUNC, H5E_CANTINIT, err, \
+ "interface is closing"); \
+ assert("interface is closing" && 0); \
} \
\
/* Clear thread error stack entering public functions */ \
- if (H5E_clearable_g && H5_IS_API (FUNC)) { \
+ if (H5E_clearable_g && H5_IS_API (FUNC)) { \
H5E_clear (); \
} \
{
@@ -901,8 +895,21 @@ extern hbool_t thread_initialize_g; /*don't decl interface_initialize_g */
/* Private functions, not part of the publicly documented API */
herr_t H5_init_library(void);
void H5_term_library(void);
-herr_t H5_add_exit(void (*func) (void));
-herr_t H5_init_thread(void);
-void H5_term_thread(void);
+
+/* Functions to terminate interfaces */
+void H5A_term_interface(intn status);
+void H5D_term_interface(intn status);
+void H5F_term_interface(intn status);
+void H5G_term_interface(intn status);
+void H5I_term_interface(intn status);
+void H5P_term_interface(intn status);
+void H5RA_term_interface(intn status);
+void H5R_term_interface(intn status);
+void H5S_term_interface(intn status);
+void H5TB_term_interface(intn status);
+void H5T_native_close(intn status);
+void H5T_term_interface(intn status);
+void H5Z_term_interface(intn status);
+
#endif