diff options
author | Dana Robinson <derobins@hdfgroup.org> | 2015-10-16 02:19:11 (GMT) |
---|---|---|
committer | Dana Robinson <derobins@hdfgroup.org> | 2015-10-16 02:19:11 (GMT) |
commit | 84d6d40b57ac26b73ecde3ed3ee2dad26855b9eb (patch) | |
tree | 5680e556dbb0971024bcea8911beb7efebc184c1 /src | |
parent | 31683703d9bf394cef27805c50fc89efa29361b9 (diff) | |
download | hdf5-84d6d40b57ac26b73ecde3ed3ee2dad26855b9eb.zip hdf5-84d6d40b57ac26b73ecde3ed3ee2dad26855b9eb.tar.gz hdf5-84d6d40b57ac26b73ecde3ed3ee2dad26855b9eb.tar.bz2 |
[svn-r28093] Merge of r27768 and r27774 from trunk
Description:
Complete revamp of package initialization/shutdown mechanism in the library.
Each package now has a single init/term routine.
This new way should avoid packages being re-initialized during library
shutdown and is also be _much_ more proactive about giving feedback for
resource leaks internal to the library.
Introduces a new "module" header file for packages in the library
(e.g src/H5Fmodule.h) which sets up some necessary package configuration macros
for the FUNC_ENTER/LEAVE macros. (The VFL drivers have their own slightly
modified version of this header, src/H5FDdrvr_module.h)
Also cleaned up a bunch of resources leaks all across the library and tests,
along with addressing many warnings, as I encountered them.
Tested on: Ubuntu 15.04 (Linux 3.19 x86_64) gcc 4.9.2
serial and parallel (MPICH 3.1.4)
Diffstat (limited to 'src')
332 files changed, 5064 insertions, 4143 deletions
@@ -74,6 +74,7 @@ hbool_t H5_api_entered_g = FALSE; H5_api_t H5_g; #else hbool_t H5_libinit_g = FALSE; /* Library hasn't been initialized */ +hbool_t H5_libterm_g = FALSE; /* Library isn't being shutdown */ #endif #ifdef H5_HAVE_MPE @@ -261,6 +262,9 @@ H5_term_library(void) if(!(H5_INIT_GLOBAL)) goto done; + /* Indicate that the library is being shut down */ + H5_TERM_GLOBAL = TRUE; + /* Check if we should display error output */ (void)H5Eget_auto2(H5E_DEFAULT, &func, NULL); @@ -270,7 +274,7 @@ H5_term_library(void) * way that would necessitate some cleanup work in the other interface. */ #define DOWN(F) \ - (((n = H5##F##_term_interface()) && (at + 8) < sizeof loop)? \ + (((n = H5##F##_term_package()) && (at + 8) < sizeof loop)? \ (sprintf(loop + at, "%s%s", (at ? "," : ""), #F), \ at += HDstrlen(loop + at), \ n): \ @@ -281,20 +285,46 @@ H5_term_library(void) 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 */ - pending += DOWN(R); - pending += DOWN(D); - pending += DOWN(L); - pending += DOWN(G); - pending += DOWN(A); - pending += DOWN(S); - pending += DOWN(T); + 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(R_top); + pending += DOWN(S_top); + pending += DOWN(T_top); + /* Don't shut down the file code until objects in files are shut down */ if(pending == 0) pending += DOWN(F); + /* Wait to shut down the "bottom" of various interfaces until the + * files are closed, so pieces of the file can be serialized + * correctly. + */ + 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(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 @@ -318,7 +348,7 @@ H5_term_library(void) /* Don't shut down the free list code until _everything_ else is down */ if(pending == 0) pending += DOWN(FL); - } + } /* end if */ } while(pending && ntries++ < 100); if(pending) { @@ -362,12 +392,17 @@ H5_term_library(void) (void)H5MM_free(tmp_open_stream); } /* end while */ + /* Reset flag indicating that the library is being shut down */ + H5_TERM_GLOBAL = FALSE; + /* Mark library as closed */ H5_INIT_GLOBAL = FALSE; + done: #ifdef H5_HAVE_THREADSAFE H5_API_UNLOCK #endif /* H5_HAVE_THREADSAFE */ + return; } /* end H5_term_library() */ @@ -17,11 +17,8 @@ /* Module Setup */ /****************/ -#define H5A_PACKAGE /*suppress error about including H5Apkg */ -#define H5O_PACKAGE /*suppress error about including H5Opkg */ - -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5A__init_interface +#include "H5Amodule.h" /* This source code file is part of the H5A module */ +#define H5O_FRIEND /*suppress error about including H5Opkg */ /***********/ @@ -37,6 +34,7 @@ #include "H5Sprivate.h" /* Dataspace functions */ #include "H5SMprivate.h" /* Shared Object Header Messages */ + /****************/ /* Local Macros */ /****************/ @@ -68,6 +66,9 @@ typedef struct H5A_iter_cb1 { /* Package Variables */ /*********************/ +/* Package initialization variable */ +hbool_t H5_PKG_INIT_VAR = FALSE; + /*****************************/ /* Library Private Variables */ @@ -95,39 +96,16 @@ static const H5I_class_t H5I_ATTR_CLS[1] = {{ (H5I_free_t)H5A_close /* 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 - * - * Purpose: Initialize the interface from some other package. - * - * Return: Success: non-negative - * Failure: negative - * - * Programmer: Quincey Koziol - * Monday, November 27, 2006 - * - *------------------------------------------------------------------------- - */ -herr_t -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_interface -- Initialize interface-specific information + H5A__init_package -- Initialize interface-specific information USAGE - herr_t H5A__init_interface() + herr_t H5A__init_package() RETURNS Non-negative on success/Negative on failure @@ -135,12 +113,12 @@ DESCRIPTION Initializes any interface-specific data or routines. --------------------------------------------------------------------------*/ -static herr_t -H5A__init_interface(void) +herr_t +H5A__init_package(void) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC + FUNC_ENTER_PACKAGE /* * Create attribute ID type. @@ -148,21 +126,25 @@ H5A__init_interface(void) if(H5I_register_type(H5I_ATTR_CLS) < 0) HGOTO_ERROR(H5E_INTERNAL, 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_interface() */ +} /* end H5A__init_package() */ /*-------------------------------------------------------------------------- NAME - H5A_term_interface + H5A_top_term_package PURPOSE Terminate various H5A objects USAGE - void H5A_term_interface() + void H5A_top_term_package() RETURNS DESCRIPTION - Release any other resources allocated. + Release IDs for the atom group, deferring full interface shutdown + until later (in H5A_term_package). GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS Can't report errors... @@ -170,32 +152,68 @@ done: REVISION LOG --------------------------------------------------------------------------*/ int -H5A_term_interface(void) +H5A_top_term_package(void) { int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5_interface_initialize_g) { + if(H5A_top_package_initialize_s) { if(H5I_nmembers(H5I_ATTR) > 0) { (void)H5I_clear_type(H5I_ATTR, FALSE, FALSE); n++; /*H5I*/ } /* end if */ - else { - /* Close deprecated interface */ - n += H5A__term_deprec_interface(); - /* Destroy the attribute object id group */ - (void)H5I_dec_type_ref(H5I_ATTR); - n++; /*H5I*/ + /* Mark closed */ + if(0 == n) + H5A_top_package_initialize_s = FALSE; + } /* end if */ + + FUNC_LEAVE_NOAPI(n) +} /* H5A_top_term_package() */ + + +/*-------------------------------------------------------------------------- + NAME + H5A_term_package + PURPOSE + Terminate various H5A objects + USAGE + void H5A_term_package() + RETURNS + DESCRIPTION + Release any other resources allocated. + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + Can't report errors... + + Finishes shutting down the interface, after H5A_top_term_package() + is called + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +int +H5A_term_package(void) +{ + int n = 0; + + 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); - /* Mark closed */ - H5_interface_initialize_g = 0; - } /* end else */ + /* Mark closed */ + if(0 == n) + H5_PKG_INIT_VAR = FALSE; } /* end if */ FUNC_LEAVE_NOAPI(n) -} /* H5A_term_interface() */ +} /* H5A_term_package() */ /*-------------------------------------------------------------------------- @@ -31,12 +31,10 @@ /* Module Setup */ /****************/ -#define H5AC_PACKAGE /*suppress error about including H5ACpkg */ -#define H5C_PACKAGE /*suppress error about including H5Cpkg */ -#define H5F_PACKAGE /*suppress error about including H5Fpkg */ +#include "H5ACmodule.h" /* This source code file is part of the H5AC module */ +#define H5C_FRIEND /* Suppress error about including H5Cpkg */ +#define H5F_FRIEND /* Suppress error about including H5Fpkg */ -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5AC_init_interface /***********/ /* Headers */ @@ -75,6 +73,9 @@ static herr_t H5AC__ext_config_2_int_config(H5AC_cache_config_t *ext_conf_ptr, /* Package Variables */ /*********************/ +/* Package initialization variable */ +hbool_t H5_PKG_INIT_VAR = FALSE; + /*****************************/ /* Library Private Variables */ @@ -140,7 +141,6 @@ static const char * H5AC_entry_type_names[H5AC_NTYPES] = * Purpose: Initialize the interface from some other layer. * * Return: Success: non-negative - * * Failure: negative * * Programmer: Quincey Koziol @@ -151,7 +151,7 @@ static const char * H5AC_entry_type_names[H5AC_NTYPES] = herr_t H5AC_init(void) { - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* FUNC_ENTER() does all the work */ @@ -162,7 +162,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5AC_init_interface + * Function: H5AC__init_package * * Purpose: Initialize interface-specific information * @@ -173,8 +173,8 @@ done: * *------------------------------------------------------------------------- */ -static herr_t -H5AC_init_interface(void) +herr_t +H5AC__init_package(void) { #ifdef H5_HAVE_PARALLEL H5P_genplist_t *xfer_plist; /* Dataset transfer property list object */ @@ -182,7 +182,7 @@ H5AC_init_interface(void) #endif /* H5_HAVE_PARALLEL */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE #ifdef H5_HAVE_PARALLEL /* Sanity check */ @@ -229,17 +229,16 @@ H5AC_init_interface(void) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5AC_init_interface() */ +} /* end H5AC__init_package() */ /*------------------------------------------------------------------------- - * Function: H5AC_term_interface + * Function: H5AC_term_package * * Purpose: Terminate this interface. * * Return: Success: Positive if anything was done that might * affect other interfaces; zero otherwise. - * * Failure: Negative. * * Programmer: Quincey Koziol @@ -248,13 +247,13 @@ done: *------------------------------------------------------------------------- */ int -H5AC_term_interface(void) +H5AC_term_package(void) { int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5_interface_initialize_g) { + if(H5_PKG_INIT_VAR) { #ifdef H5_HAVE_PARALLEL if(H5AC_dxpl_id > 0 || H5AC_ind_dxpl_id > 0) { /* Indicate more work to do */ @@ -263,30 +262,20 @@ H5AC_term_interface(void) /* Close H5AC dxpl */ if(H5I_dec_ref(H5AC_dxpl_id) < 0 || H5I_dec_ref(H5AC_ind_dxpl_id) < 0) H5E_clear_stack(NULL); /*ignore error*/ - else { - /* Reset static IDs */ - H5AC_dxpl_id = (-1); - H5AC_ind_dxpl_id = (-1); - - /* Reset interface initialization flag */ - H5_interface_initialize_g = 0; - } /* end else */ } /* end if */ - else { -#endif /* H5_HAVE_PARALLEL */ - /* Reset static IDs */ - H5AC_dxpl_id = (-1); - H5AC_ind_dxpl_id = (-1); -#ifdef H5_HAVE_PARALLEL - } /* end else */ #endif /* H5_HAVE_PARALLEL */ + + /* Reset static IDs */ + H5AC_dxpl_id = (-1); + H5AC_ind_dxpl_id = (-1); /* Reset interface initialization flag */ - H5_interface_initialize_g = 0; + if(0 == n) + H5_PKG_INIT_VAR = FALSE; } /* end if */ FUNC_LEAVE_NOAPI(n) -} /* end H5AC_term_interface() */ +} /* end H5AC_term_package() */ /*------------------------------------------------------------------------- @@ -1251,7 +1240,7 @@ H5AC_protect(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, void * thing; /* Pointer to native data structure for entry */ hbool_t log_enabled; /* TRUE if logging was set up */ hbool_t curr_logging; /* TRUE if currently logging */ - void * ret_value; /* Return value */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) diff --git a/src/H5AClog.c b/src/H5AClog.c index fc96f9a..11579d8 100644 --- a/src/H5AClog.c +++ b/src/H5AClog.c @@ -25,8 +25,8 @@ /****************/ /* Module Setup */ /****************/ -#define H5AC_PACKAGE /* suppress error about including H5ACpkg */ -#define H5C_PACKAGE /* suppress error about including H5Cpkg */ +#include "H5ACmodule.h" /* This source code file is part of the H5AC module */ +#define H5C_FRIEND /* Suppress error about including H5Cpkg */ /***********/ /* Headers */ diff --git a/src/H5ACmodule.h b/src/H5ACmodule.h new file mode 100644 index 0000000..a8dba59 --- /dev/null +++ b/src/H5ACmodule.h @@ -0,0 +1,35 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Quincey Koziol <koziol@hdfgroup.org> + * Saturday, September 12, 2015 + * + * Purpose: This file contains declarations which define macros for the + * H5AC package. Including this header means that the source file + * is part of the H5AC package. + */ +#ifndef _H5ACmodule_H +#define _H5ACmodule_H + +/* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error + * reporting macros. + */ +#define H5AC_MODULE +#define H5_MY_PKG H5AC +#define H5_MY_PKG_ERR H5E_CACHE +#define H5_MY_PKG_INIT YES + +#endif /* _H5ACmodule_H */ + diff --git a/src/H5ACmpio.c b/src/H5ACmpio.c index 6912f33..b23949a 100644 --- a/src/H5ACmpio.c +++ b/src/H5ACmpio.c @@ -29,11 +29,9 @@ /* Module Setup */ /****************/ -#define H5AC_PACKAGE /*suppress error about including H5ACpkg */ -#define H5F_PACKAGE /*suppress error about including H5Fpkg */ +#include "H5ACmodule.h" /* This source code file is part of the H5AC module */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5AC__init_mpio_interface /***********/ /* Headers */ @@ -135,33 +133,6 @@ H5FL_DEFINE(H5AC_aux_t); H5FL_DEFINE_STATIC(H5AC_slist_entry_t); -/*------------------------------------------------------------------------- - * Function: H5AC__init_mpio_interface - * - * Purpose: Initialize interface-specific information - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * 6/20/15 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5AC__init_mpio_interface(void) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - /* Funnel all work to H5AC_init() */ - if(H5AC_init() < 0) - HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "interface initialization failed") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5AC__init_mpio_interface() */ - /*------------------------------------------------------------------------- * Function: H5AC__set_sync_point_done_callback diff --git a/src/H5ACpkg.h b/src/H5ACpkg.h index 84029c7..4e0b358 100644 --- a/src/H5ACpkg.h +++ b/src/H5ACpkg.h @@ -28,7 +28,7 @@ * */ -#ifndef H5AC_PACKAGE +#if !(defined H5AC_FRIEND || defined H5AC_MODULE) #error "Do not include this file outside the H5AC package!" #endif diff --git a/src/H5Abtree2.c b/src/H5Abtree2.c index b85bee3..b4bef75 100644 --- a/src/H5Abtree2.c +++ b/src/H5Abtree2.c @@ -28,7 +28,7 @@ /* Module Setup */ /****************/ -#define H5A_PACKAGE /*suppress error about including H5Apkg */ +#include "H5Amodule.h" /* This source code file is part of the H5A module */ /***********/ @@ -253,7 +253,7 @@ H5A__dense_btree2_name_compare(const void *_bt2_udata, const void *_bt2_rec) { const H5A_bt2_ud_common_t *bt2_udata = (const H5A_bt2_ud_common_t *)_bt2_udata; const H5A_dense_bt2_name_rec_t *bt2_rec = (const H5A_dense_bt2_name_rec_t *)_bt2_rec; - herr_t ret_value; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -445,7 +445,7 @@ H5A__dense_btree2_corder_compare(const void *_bt2_udata, const void *_bt2_rec) { const H5A_bt2_ud_common_t *bt2_udata = (const H5A_bt2_ud_common_t *)_bt2_udata; const H5A_dense_bt2_corder_rec_t *bt2_rec = (const H5A_dense_bt2_corder_rec_t *)_bt2_rec; - herr_t ret_value; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_STATIC_NOERR diff --git a/src/H5Adense.c b/src/H5Adense.c index 9dd38c7..8bc0e05 100644 --- a/src/H5Adense.c +++ b/src/H5Adense.c @@ -29,8 +29,8 @@ /* Module Setup */ /****************/ -#define H5A_PACKAGE /*suppress error about including H5Apkg */ -#define H5O_PACKAGE /*suppress error about including H5Opkg */ +#include "H5Amodule.h" /* This source code file is part of the H5A module */ +#define H5O_FRIEND /*suppress error about including H5Opkg */ /***********/ @@ -1180,7 +1180,7 @@ H5A_dense_iterate(H5F_t *f, hid_t dxpl_id, hid_t loc_id, H5A_attr_table_t atable = {0, NULL}; /* Table of attributes */ H5B2_t *bt2 = NULL; /* v2 B-tree handle for index */ haddr_t bt2_addr; /* Address of v2 B-tree to use for lookup */ - herr_t ret_value; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1736,7 +1736,7 @@ H5A_dense_exists(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, htri_t attr_sharable; /* Flag indicating attributes are sharable */ htri_t ret_value = TRUE; /* Return value */ - FUNC_ENTER_NOAPI(NULL) + FUNC_ENTER_NOAPI(FAIL) /* * Check arguments. diff --git a/src/H5Adeprec.c b/src/H5Adeprec.c index ccc7659..ae0f041 100644 --- a/src/H5Adeprec.c +++ b/src/H5Adeprec.c @@ -31,11 +31,8 @@ /* Module Setup */ /****************/ -#define H5A_PACKAGE /*suppress error about including H5Apkg */ -#define H5O_PACKAGE /*suppress error about including H5Opkg */ - -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5A__init_deprec_interface +#include "H5Amodule.h" /* This source code file is part of the H5A module */ +#define H5O_FRIEND /*suppress error about including H5Opkg */ /***********/ @@ -84,51 +81,6 @@ /*******************/ - -/*-------------------------------------------------------------------------- -NAME - H5A__init_deprec_interface -- Initialize interface-specific information -USAGE - herr_t H5A__init_deprec_interface() -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. (Just calls - H5A_init() currently). - ---------------------------------------------------------------------------*/ -static herr_t -H5A__init_deprec_interface(void) -{ - FUNC_ENTER_STATIC_NOERR - - FUNC_LEAVE_NOAPI(H5A_init()) -} /* H5A__init_deprec_interface() */ - - -/*-------------------------------------------------------------------------- -NAME - H5A__term_deprec_interface -- Terminate interface -USAGE - herr_t H5A__term_deprec_interface() -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Terminates interface. (Just resets H5_interface_initialize_g - currently). - ---------------------------------------------------------------------------*/ -herr_t -H5A__term_deprec_interface(void) -{ - FUNC_ENTER_PACKAGE_NOERR - - /* Mark closed */ - H5_interface_initialize_g = 0; - - FUNC_LEAVE_NOAPI(0) -} /* H5A__term_deprec_interface() */ - #ifndef H5_NO_DEPRECATED_SYMBOLS /*-------------------------------------------------------------------------- diff --git a/src/H5Aint.c b/src/H5Aint.c index ff1ab93..6cdf9b2 100644 --- a/src/H5Aint.c +++ b/src/H5Aint.c @@ -28,8 +28,8 @@ /* Module Setup */ /****************/ -#define H5A_PACKAGE /*suppress error about including H5Apkg */ -#define H5O_PACKAGE /*suppress error about including H5Opkg */ +#include "H5Amodule.h" /* This source code file is part of the H5A module */ +#define H5O_FRIEND /*suppress error about including H5Opkg */ /***********/ @@ -142,11 +142,11 @@ H5A_t * H5A_create(const H5G_loc_t *loc, const char *name, const H5T_t *type, const H5S_t *space, hid_t acpl_id, hid_t dxpl_id) { - H5A_t *attr = NULL; /* Attribute created */ - hssize_t snelmts; /* elements in attribute */ - size_t nelmts; /* elements in attribute */ - htri_t tri_ret; /* htri_t return value */ - H5A_t *ret_value; /* Return value */ + H5A_t *attr = NULL; /* Attribute created */ + hssize_t snelmts; /* elements in attribute */ + size_t nelmts; /* elements in attribute */ + htri_t exists; /* Whether attribute exists */ + H5A_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_TAG(dxpl_id, loc->oloc->addr, NULL) @@ -161,9 +161,9 @@ H5A_create(const H5G_loc_t *loc, const char *name, const H5T_t *type, * name, but it's going to be hard to unwind all the special cases on * failure, so just check first, for now - QAK) */ - if((tri_ret = H5O_attr_exists(loc->oloc, name, H5AC_ind_dxpl_id)) < 0) + if((exists = H5O_attr_exists(loc->oloc, name, H5AC_ind_dxpl_id)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, NULL, "error checking attributes") - else if(tri_ret > 0) + else if(exists > 0) HGOTO_ERROR(H5E_ATTR, H5E_ALREADYEXISTS, NULL, "attribute already exists") /* Check if the dataspace has an extent set (or is NULL) */ @@ -360,7 +360,7 @@ H5A_open_by_idx(const H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, H5O_loc_t obj_oloc; /* Opened object object location */ hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ H5A_t *attr = NULL; /* Attribute from object header */ - H5A_t *ret_value; /* Return value */ + H5A_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -424,7 +424,7 @@ H5A_open_by_name(const H5G_loc_t *loc, const char *obj_name, const char *attr_na H5O_loc_t obj_oloc; /* Opened object object location */ hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ H5A_t *attr = NULL; /* Attribute from object header */ - H5A_t *ret_value; /* Return value */ + H5A_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -705,7 +705,7 @@ ssize_t H5A__get_name(H5A_t *attr, size_t buf_size, char *buf) { size_t copy_len, nbytes; - ssize_t ret_value; + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -839,7 +839,8 @@ H5A_get_create_plist(H5A_t* attr) H5P_genplist_t *plist; /* Default property list */ hid_t new_plist_id; /* ID of ACPL to return */ H5P_genplist_t *new_plist; /* ACPL to return */ - hid_t ret_value; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + FUNC_ENTER_NOAPI_NOINIT if(NULL == (plist = (H5P_genplist_t *)H5I_object(H5P_LST_ATTRIBUTE_CREATE_ID_g))) @@ -878,7 +879,9 @@ done: herr_t H5A__get_info(const H5A_t *attr, H5A_info_t *ainfo) { - FUNC_ENTER_NOAPI_NOERR + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) /* Check args */ HDassert(attr); @@ -896,7 +899,8 @@ H5A__get_info(const H5A_t *attr, H5A_info_t *ainfo) ainfo->corder = attr->shared->crt_idx; } /* end else */ - FUNC_LEAVE_NOAPI(SUCCEED) +done: + FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__get_info() */ @@ -1089,15 +1093,16 @@ done: H5O_loc_t * H5A_oloc(H5A_t *attr) { - H5O_loc_t *ret_value; /* Return value */ + H5O_loc_t *ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOERR + FUNC_ENTER_NOAPI(NULL) HDassert(attr); /* Set return value */ ret_value = &(attr->oloc); +done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A_oloc() */ @@ -1120,15 +1125,16 @@ H5A_oloc(H5A_t *attr) H5G_name_t * H5A_nameof(H5A_t *attr) { - H5G_name_t *ret_value; /* Return value */ + H5G_name_t *ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOERR + FUNC_ENTER_NOAPI(NULL) HDassert(attr); /* Set return value */ - ret_value=&(attr->path); + ret_value = &(attr->path); +done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A_nameof() */ @@ -1149,15 +1155,16 @@ H5A_nameof(H5A_t *attr) H5T_t * H5A_type(const H5A_t *attr) { - H5T_t *ret_value; /* Return value */ + H5T_t *ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOERR + FUNC_ENTER_NOAPI(NULL) HDassert(attr); /* Set return value */ ret_value = attr->shared->dt; +done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A_type() */ @@ -1183,7 +1190,7 @@ H5A_exists_by_name(H5G_loc_t loc, const char *obj_name, const char *attr_name, H5G_name_t obj_path; /* Opened object group hier. path */ H5O_loc_t obj_oloc; /* Opened object object location */ hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ - htri_t ret_value; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1543,7 +1550,7 @@ H5A__attr_cmp_name_dec(const void *attr1, const void *attr2) static int H5A__attr_cmp_corder_inc(const void *attr1, const void *attr2) { - int ret_value; /* Return value */ + int ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -1578,7 +1585,7 @@ H5A__attr_cmp_corder_inc(const void *attr1, const void *attr2) static int H5A__attr_cmp_corder_dec(const void *attr1, const void *attr2) { - int ret_value; /* Return value */ + int ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -1783,7 +1790,7 @@ H5A_get_ainfo(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5O_ainfo_t *ainfo) { H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ H5O_proxy_t *oh_proxy = NULL; /* Object header proxy */ - htri_t ret_value; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_TAG(dxpl_id, oh->cache_info.addr, FAIL) @@ -1857,8 +1864,9 @@ H5A_set_version(const H5F_t *f, H5A_t *attr) { hbool_t type_shared, space_shared; /* Flags to indicate that shared messages are used for this attribute */ hbool_t use_latest_format; /* Flag indicating the newest file format should be used */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOERR + FUNC_ENTER_NOAPI(FAIL) /* check arguments */ HDassert(f); @@ -1888,7 +1896,8 @@ H5A_set_version(const H5F_t *f, H5A_t *attr) else attr->shared->version = H5O_ATTR_VERSION_1; /* Write out basic version */ - FUNC_LEAVE_NOAPI(SUCCEED) +done: + FUNC_LEAVE_NOAPI(ret_value) } /* end H5A_set_version() */ @@ -1925,8 +1934,7 @@ H5A_attr_copy_file(const H5A_t *attr_src, H5F_t *file_dst, hbool_t *recompute_si void *buf = NULL; /* Buffer for copying data */ void *reclaim_buf = NULL; /* Buffer for reclaiming data */ hid_t buf_sid = -1; /* ID for buffer dataspace */ - - H5A_t *ret_value; /* Return value */ + H5A_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT diff --git a/src/H5Amodule.h b/src/H5Amodule.h new file mode 100644 index 0000000..e347fe1 --- /dev/null +++ b/src/H5Amodule.h @@ -0,0 +1,35 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Quincey Koziol <koziol@hdfgroup.org> + * Saturday, September 12, 2015 + * + * Purpose: This file contains declarations which define macros for the + * H5A package. Including this header means that the source file + * is part of the H5A package. + */ +#ifndef _H5Amodule_H +#define _H5Amodule_H + +/* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error + * reporting macros. + */ +#define H5A_MODULE +#define H5_MY_PKG H5A +#define H5_MY_PKG_ERR H5E_ATTR +#define H5_MY_PKG_INIT YES + +#endif /* _H5Amodule_H */ + diff --git a/src/H5Apkg.h b/src/H5Apkg.h index a8be098..ab036fa 100644 --- a/src/H5Apkg.h +++ b/src/H5Apkg.h @@ -21,7 +21,7 @@ * the H5A package. Source files outside the H5A package should * include H5Aprivate.h instead. */ -#ifndef H5A_PACKAGE +#if !(defined H5A_FRIEND || defined H5A_MODULE) #error "Do not include this file outside the H5A package!" #endif @@ -184,8 +184,6 @@ H5_DLLVAR const H5B2_class_t H5A_BT2_CORDER[1]; /******************************/ /* Function prototypes for H5A package scope */ -H5_DLL herr_t H5A_init(void); -H5_DLL herr_t H5A__term_deprec_interface(void); H5_DLL H5A_t *H5A_create(const H5G_loc_t *loc, const char *name, const H5T_t *type, const H5S_t *space, hid_t acpl_id, hid_t dxpl_id); H5_DLL H5A_t *H5A_open_by_name(const H5G_loc_t *loc, const char *obj_name, diff --git a/src/H5Atest.c b/src/H5Atest.c index 19b5547..d57bbe1 100644 --- a/src/H5Atest.c +++ b/src/H5Atest.c @@ -28,7 +28,7 @@ /* Module Setup */ /****************/ -#define H5A_PACKAGE /*suppress error about including H5Apkg */ +#include "H5Amodule.h" /* This source code file is part of the H5A module */ #define H5A_TESTING /*suppress warning about H5A testing funcs*/ @@ -95,7 +95,7 @@ htri_t H5A_is_shared_test(hid_t attr_id) { H5A_t *attr; /* Attribute object for ID */ - htri_t ret_value; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -97,7 +97,7 @@ /* Module Setup */ /****************/ -#define H5B_PACKAGE /*suppress error about including H5Bpkg */ +#include "H5Bmodule.h" /* This source code file is part of the H5B module */ /***********/ @@ -165,6 +165,9 @@ 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); @@ -308,7 +311,7 @@ H5B_find(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void *u H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */ unsigned idx = 0, lt = 0, rt; /* Final, left & right key indices */ int cmp = 1; /* Key comparison value */ - htri_t ret_value; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1216,7 +1219,7 @@ herr_t H5B_iterate(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, H5B_operator_t op, void *udata) { - herr_t ret_value; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOERR @@ -1713,7 +1716,7 @@ H5B_shared_new(const H5F_t *f, const H5B_class_t *type, size_t sizeof_rkey) { H5B_shared_t *shared = NULL; /* New shared B-tree struct */ size_t u; /* Local index variable */ - H5B_shared_t *ret_value; /* Return value */ + H5B_shared_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -1821,7 +1824,7 @@ H5B__copy(const H5B_t *old_bt) { H5B_t *new_node = NULL; H5B_shared_t *shared; /* Pointer to shared B-tree info */ - H5B_t *ret_value; + H5B_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -33,7 +33,8 @@ /* Module Setup */ /****************/ -#define H5B2_PACKAGE /* suppress error about including H5B2pkg */ +#include "H5B2module.h" /* This source code file is part of the H5B2 module */ + /***********/ /* Headers */ @@ -67,6 +68,9 @@ /* 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 @@ -137,7 +141,7 @@ H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam, H5B2_hdr_t *hdr = NULL; /* Pointer to the B-tree header */ H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */ haddr_t hdr_addr; /* B-tree header address */ - H5B2_t *ret_value; /* Return value */ + H5B2_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -212,7 +216,7 @@ H5B2_open(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *ctx_udata, void *parent) H5B2_t *bt2 = NULL; /* Pointer to the B-tree */ H5B2_hdr_t *hdr = NULL; /* Pointer to the B-tree header */ H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */ - H5B2_t *ret_value; /* Return value */ + H5B2_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT diff --git a/src/H5B2cache.c b/src/H5B2cache.c index e5faa2d..bb6c6ea 100644 --- a/src/H5B2cache.c +++ b/src/H5B2cache.c @@ -28,7 +28,7 @@ /* Module Setup */ /****************/ -#define H5B2_PACKAGE /*suppress error about including H5B2pkg */ +#include "H5B2module.h" /* This source code file is part of the H5B2 module */ /***********/ @@ -274,7 +274,7 @@ H5B2__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, uint16_t depth; /* Depth of B-tree */ uint32_t stored_chksum; /* Stored metadata checksum value */ const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ - H5B2_hdr_t *ret_value; /* Return value */ + H5B2_hdr_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -672,7 +672,7 @@ H5B2__cache_int_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, H5B2_node_ptr_t *int_node_ptr; /* Pointer to node pointer info */ uint32_t stored_chksum; /* Stored metadata checksum value */ unsigned u; /* Local index variable */ - H5B2_internal_t *ret_value; /* Return value */ + H5B2_internal_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -1114,7 +1114,7 @@ H5B2__cache_leaf_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, uint8_t *native; /* Pointer to native keys */ uint32_t stored_chksum; /* Stored metadata checksum value */ unsigned u; /* Local index variable */ - H5B2_leaf_t *ret_value; /* Return value */ + H5B2_leaf_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC diff --git a/src/H5B2dbg.c b/src/H5B2dbg.c index 20c0a5f..4d9a019 100644 --- a/src/H5B2dbg.c +++ b/src/H5B2dbg.c @@ -28,7 +28,8 @@ /* Module Setup */ /****************/ -#define H5B2_PACKAGE /*suppress error about including H5B2pkg */ +#include "H5B2module.h" /* This source code file is part of the H5B2 module */ + /***********/ /* Headers */ diff --git a/src/H5B2hdr.c b/src/H5B2hdr.c index 800dc36..66c8019 100644 --- a/src/H5B2hdr.c +++ b/src/H5B2hdr.c @@ -28,7 +28,8 @@ /* Module Setup */ /****************/ -#define H5B2_PACKAGE /*suppress error about including H5B2pkg */ +#include "H5B2module.h" /* This source code file is part of the H5B2 module */ + /***********/ /* Headers */ @@ -250,7 +251,7 @@ H5B2_hdr_t * H5B2__hdr_alloc(H5F_t *f) { H5B2_hdr_t *hdr = NULL; /* v2 B-tree header */ - H5B2_hdr_t *ret_value; /* Return value */ + H5B2_hdr_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -296,8 +297,8 @@ haddr_t H5B2__hdr_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam, void *ctx_udata, void *parent) { - H5B2_hdr_t *hdr = NULL; /* The new v2 B-tree header information */ - haddr_t ret_value; /* Return value */ + H5B2_hdr_t *hdr = NULL; /* The new v2 B-tree header information */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_PACKAGE diff --git a/src/H5B2int.c b/src/H5B2int.c index 7f53264..6c6317b 100644 --- a/src/H5B2int.c +++ b/src/H5B2int.c @@ -28,7 +28,8 @@ /* Module Setup */ /****************/ -#define H5B2_PACKAGE /*suppress error about including H5B2pkg */ +#include "H5B2module.h" /* This source code file is part of the H5B2 module */ + /***********/ /* Headers */ @@ -2603,7 +2604,7 @@ H5B2__protect_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id, haddr_t addr, void *parent, uint16_t nrec, unsigned flags) { H5B2_leaf_cache_ud_t udata; /* User-data for callback */ - H5B2_leaf_t *ret_value; /* Return value */ + H5B2_leaf_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -2733,7 +2734,7 @@ H5B2__protect_internal(H5B2_hdr_t *hdr, hid_t dxpl_id, haddr_t addr, void *parent, uint16_t nrec, uint16_t depth, unsigned flags) { H5B2_internal_cache_ud_t udata; /* User data to pass through to cache 'deserialize' callback */ - H5B2_internal_t *ret_value; /* Return value */ + H5B2_internal_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE diff --git a/src/H5B2module.h b/src/H5B2module.h new file mode 100644 index 0000000..0fc30a5 --- /dev/null +++ b/src/H5B2module.h @@ -0,0 +1,36 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Quincey Koziol <koziol@hdfgroup.org> + * Saturday, September 12, 2015 + * + * Purpose: This file contains declarations which define macros for the + * H5B2 package. Including this header means that the source file + * is part of the H5B2 package. + */ +#ifndef _H5B2module_H +#define _H5B2module_H + +/* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error + * reporting macros. + */ +#define H5B2_MODULE +#define H5_MY_PKG H5B2 +#define H5_MY_PKG_ERR H5E_BTREE +#define H5_MY_PKG_INIT NO + +#endif /* _H5B2module_H */ + + diff --git a/src/H5B2pkg.h b/src/H5B2pkg.h index 9702ae0..d5ef9fe 100644 --- a/src/H5B2pkg.h +++ b/src/H5B2pkg.h @@ -21,7 +21,7 @@ * the H5B2 package. Source files outside the H5B2 package should * include H5B2private.h instead. */ -#ifndef H5B2_PACKAGE +#if !(defined H5B2_FRIEND || defined H5B2_MODULE) #error "Do not include this file outside the H5B2 package!" #endif diff --git a/src/H5B2stat.c b/src/H5B2stat.c index a6ce1a8..da721c6 100644 --- a/src/H5B2stat.c +++ b/src/H5B2stat.c @@ -24,7 +24,7 @@ /* Module Setup */ /****************/ -#define H5B2_PACKAGE /* Suppress error about including H5B2pkg */ +#include "H5B2module.h" /* This source code file is part of the H5B2 module */ /***********/ diff --git a/src/H5B2test.c b/src/H5B2test.c index 5890fb8..1e6f4a0 100644 --- a/src/H5B2test.c +++ b/src/H5B2test.c @@ -25,7 +25,7 @@ /* Module Setup */ /****************/ -#define H5B2_PACKAGE /*suppress error about including H5B2pkg */ +#include "H5B2module.h" /* This source code file is part of the H5B2 module */ #define H5B2_TESTING /*suppress warning about H5B2 testing funcs*/ @@ -124,7 +124,7 @@ H5B2__test_crt_context(void *_f) { H5F_t *f = (H5F_t *)_f; /* User data for building callback context */ H5B2_test_ctx_t *ctx; /* Callback context structure */ - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -543,7 +543,7 @@ int H5B2_get_node_depth_test(H5B2_t *bt2, hid_t dxpl_id, void *udata) { H5B2_node_info_test_t ninfo; /* Node information */ - int ret_value; /* Return information */ + int ret_value = -1; /* Return information */ FUNC_ENTER_NOAPI(FAIL) diff --git a/src/H5Bcache.c b/src/H5Bcache.c index f3ed46f..73136b4 100644 --- a/src/H5Bcache.c +++ b/src/H5Bcache.c @@ -28,7 +28,7 @@ /* Module Setup */ /****************/ -#define H5B_PACKAGE /*suppress error about including H5Bpkg */ +#include "H5Bmodule.h" /* This source code file is part of the H5B module */ /***********/ @@ -160,7 +160,7 @@ H5B__deserialize(const void *_image, size_t H5_ATTR_UNUSED len, void *_udata, const uint8_t *image = (const uint8_t *)_image; /* Pointer into image buffer */ uint8_t *native; /* Pointer to native keys */ unsigned u; /* Local index variable */ - H5B_t *ret_value; /* Return value */ + H5B_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC diff --git a/src/H5Bdbg.c b/src/H5Bdbg.c index 34e8465..ed7ccf2 100644 --- a/src/H5Bdbg.c +++ b/src/H5Bdbg.c @@ -28,7 +28,7 @@ /* Module Setup */ /****************/ -#define H5B_PACKAGE /*suppress error about including H5Bpkg */ +#include "H5Bmodule.h" /* This source code file is part of the H5B module */ /***********/ diff --git a/src/H5Bmodule.h b/src/H5Bmodule.h new file mode 100644 index 0000000..6800b26 --- /dev/null +++ b/src/H5Bmodule.h @@ -0,0 +1,35 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Quincey Koziol <koziol@hdfgroup.org> + * Saturday, September 12, 2015 + * + * Purpose: This file contains declarations which define macros for the + * H5B package. Including this header means that the source file + * is part of the H5B package. + */ +#ifndef _H5Bmodule_H +#define _H5Bmodule_H + +/* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error + * reporting macros. + */ +#define H5B_MODULE +#define H5_MY_PKG H5B +#define H5_MY_PKG_ERR H5E_BTREE +#define H5_MY_PKG_INIT NO + +#endif /* _H5Bmodule_H */ + diff --git a/src/H5Bpkg.h b/src/H5Bpkg.h index 157e3ae..e9cf69a 100644 --- a/src/H5Bpkg.h +++ b/src/H5Bpkg.h @@ -21,7 +21,7 @@ * the H5B package. Source files outside the H5B package should * include H5Bprivate.h instead. */ -#ifndef H5B_PACKAGE +#if !(defined H5B_FRIEND || defined H5B_MODULE) #error "Do not include this file outside the H5B package!" #endif @@ -74,8 +74,8 @@ /* Module Setup */ /****************/ -#define H5C_PACKAGE /*suppress error about including H5Cpkg */ -#define H5F_PACKAGE /*suppress error about including H5Fpkg */ +#include "H5Cmodule.h" /* This source code file is part of the H5C module */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ /***********/ @@ -83,7 +83,7 @@ /***********/ #include "H5private.h" /* Generic Functions */ #ifdef H5_HAVE_PARALLEL -#define H5AC_PACKAGE /*suppress error about including H5ACpkg */ +#define H5AC_FRIEND /*suppress error about including H5ACpkg */ #include "H5ACpkg.h" /* Metadata cache */ #endif /* H5_HAVE_PARALLEL */ #include "H5Cpkg.h" /* Cache */ @@ -108,6 +108,7 @@ #define H5C_IMAGE_EXTRA_SPACE 0 #endif /* H5C_DO_MEMORY_SANITY_CHECKS */ + /******************/ /* Local Typedefs */ /******************/ @@ -219,6 +220,9 @@ herr_t H5C_dump_cache_skip_list(H5C_t * cache_ptr, char * calling_fcn); /* Package Variables */ /*********************/ +/* Package initialization variable */ +hbool_t H5_PKG_INIT_VAR = FALSE; + /*****************************/ /* Library Private Variables */ @@ -3073,7 +3077,7 @@ H5C_protect(H5F_t * f, size_t empty_space; void * thing; H5C_cache_entry_t * entry_ptr; - void * ret_value; /* Return value */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -8721,7 +8725,7 @@ H5C_load_entry(H5F_t * f, void * thing = NULL; /* Pointer to thing loaded */ H5C_cache_entry_t * entry; /* Alias for thing loaded, as cache entry */ size_t len; /* Size of image in file */ - void * ret_value; /* Return value */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -10587,42 +10591,42 @@ H5C_cork(H5C_t * cache_ptr, haddr_t obj_addr, unsigned action, hbool_t *corked) if(H5C__SET_CORK == action) { haddr_t *addr_ptr = NULL; /* Points to an address */ - if(ptr != NULL && *ptr == obj_addr) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't cork an already corked object") + if(ptr != NULL && *ptr == obj_addr) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't cork an already corked object") - /* Allocate address */ - if(NULL == (addr_ptr = H5FL_MALLOC(haddr_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + /* Allocate address */ + if(NULL == (addr_ptr = H5FL_MALLOC(haddr_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - /* Insert into the list */ - *addr_ptr = obj_addr; - if(H5SL_insert(cache_ptr->cork_list_ptr, addr_ptr, addr_ptr) < 0) { + /* Insert into the list */ + *addr_ptr = obj_addr; + if(H5SL_insert(cache_ptr->cork_list_ptr, addr_ptr, addr_ptr) < 0) { addr_ptr = H5FL_FREE(haddr_t, addr_ptr); - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't insert address into cork list") + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't insert address into cork list") } /* end if */ - /* Set the entry's cork status */ - is_corked = TRUE; + /* Set the entry's cork status */ + is_corked = TRUE; } /* end if */ else { - if(ptr == NULL) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't uncork an object that is not corked ") + if(ptr == NULL) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't uncork an object that is not corked ") - /* Remove the object address from the list */ - ptr = (haddr_t *)H5SL_remove(cache_ptr->cork_list_ptr, &obj_addr); - if(ptr == NULL || *ptr != obj_addr) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't remove address from list") + /* Remove the object address from the list */ + ptr = (haddr_t *)H5SL_remove(cache_ptr->cork_list_ptr, &obj_addr); + if(ptr == NULL || *ptr != obj_addr) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't remove address from list") - /* Free address */ - ptr = H5FL_FREE(haddr_t, ptr); + /* Free address */ + ptr = H5FL_FREE(haddr_t, ptr); - /* Set the entry's cork status */ - is_corked = FALSE; + /* Set the entry's cork status */ + is_corked = FALSE; } /* end else */ - /* Mark existing cache entries with tag (obj_addr) to the cork status */ - if(H5C_mark_tagged_entries_cork(cache_ptr, obj_addr, is_corked) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't mark cork status on entry") + /* Mark existing cache entries with tag (obj_addr) to the cork status */ + if(H5C_mark_tagged_entries_cork(cache_ptr, obj_addr, is_corked) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't mark cork status on entry") } /* end else */ done: @@ -30,10 +30,19 @@ #include "H5private.h" /* Generic Functions */ #include "H5CSprivate.h" /* Function stack */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5Eprivate.h" /* Error handling */ #ifdef H5_HAVE_CODESTACK +#define H5CS_MIN_NSLOTS 16 /* Minimum number of records in an function stack */ + +/* A function stack */ +typedef struct H5CS_t { + unsigned nused; /* Number of records currently used in stack */ + unsigned nalloc; /* Number of records current allocated for stack */ + const char **rec; /* Array of function records */ +} H5CS_t; + #ifdef H5_HAVE_THREADSAFE /* * The per-thread function stack. pthread_once() initializes a special @@ -44,8 +53,8 @@ * In order for this macro to work, H5CS_get_my_stack() must be preceeded * by "H5CS_t *fstack =". */ -static H5CS_t *H5CS_get_stack(void); -#define H5CS_get_my_stack() H5CS_get_stack() +static H5CS_t *H5CS__get_stack(void); +#define H5CS_get_my_stack() H5CS__get_stack() #else /* H5_HAVE_THREADSAFE */ /* * The function stack. Eventually we'll have some sort of global table so each @@ -58,7 +67,7 @@ H5CS_t H5CS_stack_g[1]; #ifdef H5_HAVE_THREADSAFE /*------------------------------------------------------------------------- - * Function: H5CS_get_stack + * Function: H5CS__get_stack * * Purpose: Support function for H5CS_get_my_stack() to initialize and * acquire per-thread function stack. @@ -70,19 +79,17 @@ H5CS_t H5CS_stack_g[1]; * Programmer: Quincey Koziol * February 6, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ static H5CS_t * -H5CS_get_stack(void) +H5CS__get_stack(void) { H5CS_t *fstack; - FUNC_ENTER_NOAPI_NOERR_NOFS + FUNC_ENTER_STATIC_NOERR_NOFS fstack = H5TS_get_thread_local_value(H5TS_funcstk_key_g); - if (!fstack) { + if(!fstack) { /* No associated value with current thread - create one */ #ifdef H5_HAVE_WIN_THREADS fstack = (H5CS_t *)LocalAlloc(LPTR, sizeof(H5CS_t)); /* Win32 has to use LocalAlloc to match the LocalFree in DllMain */ @@ -92,17 +99,19 @@ H5CS_get_stack(void) HDassert(fstack); /* Set the thread-specific info */ - fstack->nused=0; + fstack->nused = 0; + fstack->nalloc = 0; + fstack->rec = NULL; /* (It's not necessary to release this in this API, it is * released by the "key destructor" set up in the H5TS * routines. See calls to pthread_key_create() in H5TS.c -QAK) */ H5TS_set_thread_local_value(H5TS_funcstk_key_g, (void *)fstack); - } + } /* end if */ - FUNC_LEAVE_NOAPI_NOFS(fstack); -} /* end H5CS_get_stack() */ + FUNC_LEAVE_NOAPI_NOFS(fstack) +} /* end H5CS__get_stack() */ #endif /* H5_HAVE_THREADSAFE */ @@ -133,59 +142,28 @@ H5CS_print_stack(const H5CS_t *fstack, FILE *stream) HDassert(fstack); /* Default to outputting information to stderr */ - if (!stream) + if(!stream) stream = stderr; - HDfprintf (stream, "HDF5-DIAG: Function stack from %s ", H5_lib_vers_info_g); + HDfprintf(stream, "HDF5-DIAG: Function stack from %s ", H5_lib_vers_info_g); /* try show the process or thread id in multiple processes cases*/ #ifdef H5_HAVE_THREADSAFE - HDfprintf (stream, "thread %lu.", HDpthread_self_ulong()); + HDfprintf(stream, "thread %lu.", HDpthread_self_ulong()); #else /* H5_HAVE_THREADSAFE */ - HDfprintf (stream, "thread 0."); + HDfprintf(stream, "thread 0."); #endif /* H5_HAVE_THREADSAFE */ - if (fstack && fstack->nused>0) - HDfprintf (stream, " Back trace follows."); - HDfputc ('\n', stream); + if(fstack && fstack->nused>0) + HDfprintf(stream, " Back trace follows."); + HDfputc('\n', stream); - for (i=fstack->nused-1; i>=0; --i) - HDfprintf(stream, "%*s#%03d: Routine: %s\n", indent, "", i, fstack->slot[i]); + for(i = fstack->nused - 1; i >= 0; --i) + HDfprintf(stream, "%*s#%03d: Routine: %s\n", indent, "", i, fstack->rec[i]); - FUNC_LEAVE_NOAPI_NOFS(SUCCEED); + FUNC_LEAVE_NOAPI_NOFS(SUCCEED) } /* end H5CS_print_stack() */ /*------------------------------------------------------------------------- - * Function: H5CS_print - * - * Purpose: Prints the default function stack in some default way. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * Thursday, February 6, 2003 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -herr_t -H5CS_print(FILE *stream) -{ - H5CS_t *fstack = H5CS_get_my_stack (); /* Get the correct function stack */ - - /* Don't push this function on the function stack... :-) */ - FUNC_ENTER_NOAPI_NOERR_NOFS - - /* Sanity check */ - HDassert(fstack); - - H5CS_print_stack(fstack, stream); - - FUNC_LEAVE_NOAPI_NOFS(SUCCEED); -} /* end H5CS_print() */ - - -/*------------------------------------------------------------------------- * Function: H5CS_push * * Purpose: Pushes a new record onto function stack for the current @@ -196,30 +174,37 @@ H5CS_print(FILE *stream) * Programmer: Quincey Koziol * Thursday, February 6, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t H5CS_push(const char *func_name) { - H5CS_t *fstack = H5CS_get_my_stack (); + H5CS_t *fstack = H5CS_get_my_stack(); /* Current function stack for library */ /* Don't push this function on the function stack... :-) */ FUNC_ENTER_NOAPI_NOERR_NOFS /* Sanity check */ HDassert(fstack); + HDassert(fstack->nused <= fstack->nalloc); HDassert(func_name); - /* - * Push the function if there's room. Otherwise just increment count - */ - if (fstack->nused<H5CS_NSLOTS) - fstack->slot[fstack->nused] = func_name; + /* Check if we need to expand the stack of records */ + if(fstack->nused == fstack->nalloc) { + size_t na = MAX((fstack->nalloc * 2), H5CS_MIN_NSLOTS); + const char **x = (const char **)HDrealloc(fstack->rec, na * sizeof(const char *)); + + /* (Avoid returning an error from this routine, currently -QAK) */ + HDassert(x); + fstack->rec = x; + fstack->nalloc = na; + } /* end if */ + + /* Push the function name */ + fstack->rec[fstack->nused] = func_name; fstack->nused++; - FUNC_LEAVE_NOAPI_NOFS(SUCCEED); + FUNC_LEAVE_NOAPI_NOFS(SUCCEED) } /* end H5CS_push() */ @@ -240,14 +225,14 @@ H5CS_push(const char *func_name) herr_t H5CS_pop(void) { - H5CS_t *fstack = H5CS_get_my_stack (); + H5CS_t *fstack = H5CS_get_my_stack(); /* Don't push this function on the function stack... :-) */ FUNC_ENTER_NOAPI_NOERR_NOFS /* Sanity check */ HDassert(fstack); - HDassert(fstack->nused>0); + HDassert(fstack->nused > 0); /* Pop the function. */ fstack->nused--; @@ -266,43 +251,52 @@ H5CS_pop(void) * Programmer: Quincey Koziol * Tuesday, August 9, 2005 * - * Modifications: - * *------------------------------------------------------------------------- */ -herr_t -H5CS_copy_stack(H5CS_t *new_stack) +H5CS_t * +H5CS_copy_stack(void) { - H5CS_t *old_stack = H5CS_get_my_stack (); + H5CS_t *old_stack = H5CS_get_my_stack(); /* Existing function stack for library */ + H5CS_t *new_stack; /* New function stack, for copy */ unsigned u; /* Local index variable */ + H5CS_t *ret_value = NULL; /* Return value */ /* Don't push this function on the function stack... :-) */ - FUNC_ENTER_NOAPI_NOERR_NOFS + FUNC_ENTER_NOAPI_NOFS /* Sanity check */ HDassert(old_stack); + /* Allocate a new stack */ + /* (Don't use library allocate code, since this code stack supports it) */ + if(NULL == (new_stack = HDcalloc(1, sizeof(H5CS_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "can't allocate function stack") + if(NULL == (new_stack->rec = HDcalloc(old_stack->nused, sizeof(const char *)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "can't allocate function stack records") + /* Copy old stack to new one, duplicating the strings */ for(u = 0; u < old_stack->nused; u++) - new_stack->slot[u] = H5MM_strdup(old_stack->slot[u]); - new_stack->nused = old_stack->nused; + new_stack->rec[u] = HDstrdup(old_stack->rec[u]); + new_stack->nused = new_stack->nalloc = old_stack->nused; - FUNC_LEAVE_NOAPI_NOFS(SUCCEED); + /* Set the return value */ + ret_value = new_stack; + +done: + FUNC_LEAVE_NOAPI_NOFS(ret_value) } /* end H5CS_copy_stack() */ /*------------------------------------------------------------------------- * Function: H5CS_close_stack * - * Purpose: Closes a copy of a stack + * Purpose: Closes and frees a copy of a stack * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Tuesday, August 9, 2005 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t @@ -316,11 +310,20 @@ H5CS_close_stack(H5CS_t *stack) /* Sanity check */ HDassert(stack); - /* Free strings on stack */ - for(u = 0; u < stack->nused; u++) - stack->slot[u] = H5MM_xfree((void *)stack->slot[u]); - - FUNC_LEAVE_NOAPI_NOFS(SUCCEED); + /* Free stack */ + for(u = 0; u < stack->nused; u++) { + if(stack->rec[u]) + HDfree((void *)stack->rec[u]); + stack->rec[u] = NULL; + } /* end for */ + if(stack->rec) { + HDfree(stack->rec); + stack->rec = NULL; + } /* end if */ + if(stack) + HDfree(stack); + + FUNC_LEAVE_NOAPI_NOFS(SUCCEED) } /* end H5CS_close_stack() */ #endif /* H5_HAVE_CODESTACK */ diff --git a/src/H5CSprivate.h b/src/H5CSprivate.h index 13f3b66..ab7f993 100644 --- a/src/H5CSprivate.h +++ b/src/H5CSprivate.h @@ -26,19 +26,13 @@ /* Private headers needed by this file */ #include "H5private.h" -#define H5CS_NSLOTS 48 /*number of slots in an function stack */ - -/* A function stack */ -typedef struct H5CS_t { - unsigned nused; /*num slots currently used in stack */ - const char *slot[H5CS_NSLOTS]; /*array of function records */ -} H5CS_t; - -H5_DLL herr_t H5CS_push (const char *func_name); -H5_DLL herr_t H5CS_pop (void); -H5_DLL herr_t H5CS_print (FILE *stream); -H5_DLL herr_t H5CS_print_stack (const H5CS_t *stack, FILE *stream); -H5_DLL herr_t H5CS_copy_stack (H5CS_t *stack); -H5_DLL herr_t H5CS_close_stack (H5CS_t *stack); +/* Forward declarations for structure fields */ +struct H5CS_t; +H5_DLL herr_t H5CS_push(const char *func_name); +H5_DLL herr_t H5CS_pop(void); +H5_DLL herr_t H5CS_print_stack(const struct H5CS_t *stack, FILE *stream); +H5_DLL struct H5CS_t *H5CS_copy_stack(void); +H5_DLL herr_t H5CS_close_stack(struct H5CS_t *stack); #endif /* _H5CSprivate_H */ + diff --git a/src/H5Cmodule.h b/src/H5Cmodule.h new file mode 100644 index 0000000..2c39eab --- /dev/null +++ b/src/H5Cmodule.h @@ -0,0 +1,35 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Quincey Koziol <koziol@hdfgroup.org> + * Saturday, September 12, 2015 + * + * Purpose: This file contains declarations which define macros for the + * H5C package. Including this header means that the source file + * is part of the H5C package. + */ +#ifndef _H5Cmodule_H +#define _H5Cmodule_H + +/* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error + * reporting macros. + */ +#define H5C_MODULE +#define H5_MY_PKG H5C +#define H5_MY_PKG_ERR H5E_CACHE +#define H5_MY_PKG_INIT NO + +#endif /* _H5Cmodule_H */ + diff --git a/src/H5Cmpio.c b/src/H5Cmpio.c index ec34285..6b63ad5 100644 --- a/src/H5Cmpio.c +++ b/src/H5Cmpio.c @@ -29,8 +29,8 @@ /* Module Setup */ /****************/ -#define H5C_PACKAGE /*suppress error about including H5Cpkg */ -#define H5F_PACKAGE /*suppress error about including H5Fpkg */ +#include "H5Cmodule.h" /* This source code file is part of the H5C module */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ /***********/ diff --git a/src/H5Cpkg.h b/src/H5Cpkg.h index 22cc9c0..f5cb4de 100644 --- a/src/H5Cpkg.h +++ b/src/H5Cpkg.h @@ -28,7 +28,7 @@ * reason why this file was created. */ -#ifndef H5C_PACKAGE +#if !(defined H5C_FRIEND || defined H5C_MODULE) #error "Do not include this file outside the H5C package!" #endif @@ -17,10 +17,7 @@ /* Module Setup */ /****************/ -#define H5D_PACKAGE /*suppress error about including H5Dpkg */ - -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5D__init_pub_interface +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ @@ -52,6 +49,9 @@ /* Package Variables */ /*********************/ +/* Package initialization variable */ +hbool_t H5_PKG_INIT_VAR = FALSE; + /* Declare extern the free list to manage blocks of VL data */ H5FL_BLK_EXTERN(vlen_vl_buf); @@ -73,51 +73,6 @@ H5FL_BLK_EXTERN(type_conv); -/*-------------------------------------------------------------------------- -NAME - H5D__init_pub_interface -- Initialize interface-specific information -USAGE - herr_t H5D__init_pub_interface() -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. (Just calls - H5D_init() currently). - ---------------------------------------------------------------------------*/ -static herr_t -H5D__init_pub_interface(void) -{ - FUNC_ENTER_STATIC_NOERR - - FUNC_LEAVE_NOAPI(H5D_init()) -} /* H5D__init_pub_interface() */ - - -/*-------------------------------------------------------------------------- -NAME - H5D__term_pub_interface -- Terminate interface -USAGE - herr_t H5D__term_pub_interface() -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Terminates interface. (Just resets H5_interface_initialize_g - currently). - ---------------------------------------------------------------------------*/ -herr_t -H5D__term_pub_interface(void) -{ - FUNC_ENTER_PACKAGE_NOERR - - /* Mark closed */ - H5_interface_initialize_g = 0; - - FUNC_LEAVE_NOAPI(0) -} /* H5D__term_pub_interface() */ - - /*------------------------------------------------------------------------- * Function: H5Dcreate2 * diff --git a/src/H5Dbtree.c b/src/H5Dbtree.c index 268962f..0402cb8 100644 --- a/src/H5Dbtree.c +++ b/src/H5Dbtree.c @@ -26,7 +26,7 @@ /* Module Setup */ /****************/ -#define H5D_PACKAGE /*suppress error about including H5Dpkg */ +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ @@ -332,7 +332,7 @@ H5D__btree_cmp2(void *_lt_key, void *_udata, void *_rt_key) H5D_btree_key_t *lt_key = (H5D_btree_key_t *) _lt_key; H5D_btree_key_t *rt_key = (H5D_btree_key_t *) _rt_key; H5D_chunk_common_ud_t *udata = (H5D_chunk_common_ud_t *) _udata; - int ret_value; + int ret_value = -1; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -554,7 +554,7 @@ H5D__btree_insert(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, void *_l H5D_chunk_ud_t *udata = (H5D_chunk_ud_t *) _udata; int cmp; unsigned u; - H5B_ins_t ret_value; + H5B_ins_t ret_value = H5B_INS_ERROR; /* Return value */ FUNC_ENTER_STATIC @@ -971,7 +971,7 @@ done: static hbool_t H5D__btree_idx_is_space_alloc(const H5O_storage_chunk_t *storage) { - hbool_t ret_value; /* Return value */ + hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -1078,7 +1078,6 @@ done: * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static int H5D__btree_idx_iterate_cb(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, const void *_lt_key, haddr_t addr, const void H5_ATTR_UNUSED *_rt_key, @@ -1087,9 +1086,9 @@ H5D__btree_idx_iterate_cb(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, H5D_btree_it_ud_t *udata = (H5D_btree_it_ud_t *)_udata; /* User data */ const H5D_btree_key_t *lt_key = (const H5D_btree_key_t *)_lt_key; /* B-tree key for chunk */ H5D_chunk_rec_t chunk_rec; /* Generic chunk record for callback */ - int ret_value; /* Return value */ + int ret_value = -1; /* Return value */ - FUNC_ENTER_STATIC_NOERR + FUNC_ENTER_STATIC /* Sanity check for memcpy() */ HDcompile_assert(offsetof(H5D_chunk_rec_t, nbytes) == offsetof(H5D_btree_key_t, nbytes)); @@ -1105,8 +1104,9 @@ H5D__btree_idx_iterate_cb(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, /* Make "generic chunk" callback */ if((ret_value = (udata->cb)(&chunk_rec, udata->udata)) < 0) - HERROR(H5E_DATASET, H5E_CALLBACK, "failure in generic chunk iterator callback"); + HGOTO_ERROR(H5E_DATASET, H5E_CALLBACK, (-1), "failure in generic chunk iterator callback"); +done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__btree_idx_iterate_cb() */ @@ -1129,9 +1129,9 @@ H5D__btree_idx_iterate(const H5D_chk_idx_info_t *idx_info, H5D_chunk_cb_func_t chunk_cb, void *chunk_udata) { H5D_btree_it_ud_t udata; /* User data for B-tree iterator callback */ - int ret_value; /* Return value */ + int ret_value = -1; /* Return value */ - FUNC_ENTER_STATIC_NOERR + FUNC_ENTER_STATIC HDassert(idx_info); HDassert(idx_info->f); @@ -1151,8 +1151,9 @@ H5D__btree_idx_iterate(const H5D_chk_idx_info_t *idx_info, /* Iterate over existing chunks */ if((ret_value = H5B_iterate(idx_info->f, idx_info->dxpl_id, H5B_BTREE, idx_info->storage->idx_addr, H5D__btree_idx_iterate_cb, &udata)) < 0) - HERROR(H5E_DATASET, H5E_BADITER, "unable to iterate over chunk B-tree"); + HGOTO_ERROR(H5E_DATASET, H5E_BADITER, (-1), "unable to iterate over chunk B-tree"); +done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__btree_idx_iterate() */ diff --git a/src/H5Dbtree2.c b/src/H5Dbtree2.c index 8f1fdc6..76c7e69 100644 --- a/src/H5Dbtree2.c +++ b/src/H5Dbtree2.c @@ -25,7 +25,7 @@ /* Module Setup */ /****************/ -#define H5D_PACKAGE /*suppress error about including H5Dpkg */ +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ @@ -1293,9 +1293,9 @@ H5D_bt2_idx_iterate_cb(const void *_record, void *_udata) { H5D_bt2_it_ud_t *udata = (H5D_bt2_it_ud_t *)_udata; /* User data */ unsigned u; /* Local index variable */ - int ret_value; /* Return value */ + int ret_value =-1; /* Return value */ - FUNC_ENTER_NOAPI_NOERR + FUNC_ENTER_NOAPI_NOINIT /* Compose generic chunk record for callback */ if(udata->filtered) { /* filtered record */ @@ -1319,8 +1319,9 @@ H5D_bt2_idx_iterate_cb(const void *_record, void *_udata) /* Make "generic chunk" callback */ if((ret_value = (udata->cb)(&udata->chunk_rec, udata->udata)) < 0) - HERROR(H5E_DATASET, H5E_CALLBACK, "failure in generic chunk iterator callback"); + HGOTO_ERROR(H5E_DATASET, H5E_CALLBACK, (-1), "failure in generic chunk iterator callback"); +done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D_bt2_idx_iterate_cb() */ @@ -1380,7 +1381,7 @@ H5D_bt2_idx_iterate(const H5D_chk_idx_info_t *idx_info, /* Iterate over the records in the v2 B-tree */ if((ret_value = H5B2_iterate(bt2, idx_info->dxpl_id, H5D_bt2_idx_iterate_cb, &udata)) < 0) - HERROR(H5E_DATASET, H5E_BADITER, "unable to iterate over v2 B-tree for dataset chunks"); + HGOTO_ERROR(H5E_DATASET, H5E_BADITER, FAIL, "unable to iterate over v2 B-tree for dataset chunks"); done: FUNC_LEAVE_NOAPI(ret_value) @@ -1743,7 +1744,7 @@ H5D_bt2_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *index_size) H5B2_t *bt2_cdset = NULL; /* Pointer to v2 B-tree structure */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOINIT /* Check args */ HDassert(idx_info); diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 6ec8aae..1bb4d67 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -44,7 +44,7 @@ /* Module Setup */ /****************/ -#define H5D_PACKAGE /*suppress error about including H5Dpkg */ +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ @@ -713,7 +713,7 @@ done: hbool_t H5D__chunk_is_space_alloc(const H5O_storage_t *storage) { - hbool_t ret_value; /* Return value */ + hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_PACKAGE_NOERR @@ -2566,7 +2566,7 @@ H5D__chunk_hash_val(const H5D_shared_t *shared, const hsize_t *scaled) { hsize_t val; /* Intermediate value */ unsigned ndims = shared->ndims; /* Rank of dataset */ - unsigned ret; /* Value to return */ + unsigned ret = 0; /* Value to return */ FUNC_ENTER_STATIC_NOERR @@ -3121,7 +3121,7 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, size_t chunk_size; /*size of a chunk */ hbool_t disable_filters = FALSE; /* Whether to disable filters (when adding to cache) */ void *chunk = NULL; /*the file chunk */ - void *ret_value; /*return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -6146,7 +6146,7 @@ H5D__nonexistent_readvv(const H5D_io_info_t *io_info, size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_off_arr[]) { H5D_chunk_readvv_ud_t udata; /* User data for H5VM_opvv() operator */ - ssize_t ret_value; /* Return value */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_STATIC diff --git a/src/H5Dcompact.c b/src/H5Dcompact.c index 8fe8e81..e2dc36f 100644 --- a/src/H5Dcompact.c +++ b/src/H5Dcompact.c @@ -25,7 +25,7 @@ /* Module Setup */ /****************/ -#define H5D_PACKAGE /*suppress error about including H5Dpkg */ +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ @@ -287,7 +287,7 @@ H5D__compact_readvv(const H5D_io_info_t *io_info, size_t dset_max_nseq, size_t *dset_curr_seq, size_t dset_size_arr[], hsize_t dset_offset_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_size_arr[], hsize_t mem_offset_arr[]) { - ssize_t ret_value; /* Return value */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_STATIC @@ -328,7 +328,7 @@ H5D__compact_writevv(const H5D_io_info_t *io_info, size_t dset_max_nseq, size_t *dset_curr_seq, size_t dset_size_arr[], hsize_t dset_offset_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_size_arr[], hsize_t mem_offset_arr[]) { - ssize_t ret_value; /* Return value */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_STATIC diff --git a/src/H5Dcontig.c b/src/H5Dcontig.c index 2331af4..492abc7 100644 --- a/src/H5Dcontig.c +++ b/src/H5Dcontig.c @@ -27,7 +27,7 @@ /* Module Setup */ /****************/ -#define H5D_PACKAGE /*suppress error about including H5Dpkg */ +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ @@ -542,7 +542,7 @@ done: hbool_t H5D__contig_is_space_alloc(const H5O_storage_t *storage) { - hbool_t ret_value; /* Return value */ + hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_PACKAGE_NOERR @@ -920,7 +920,7 @@ H5D__contig_readvv(const H5D_io_info_t *io_info, size_t dset_max_nseq, size_t *dset_curr_seq, size_t dset_len_arr[], hsize_t dset_off_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_off_arr[]) { - ssize_t ret_value; /* Return value */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_STATIC @@ -1247,7 +1247,7 @@ H5D__contig_writevv(const H5D_io_info_t *io_info, size_t dset_max_nseq, size_t *dset_curr_seq, size_t dset_len_arr[], hsize_t dset_off_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_off_arr[]) { - ssize_t ret_value; /* Return value (Size of sequence in bytes) */ + ssize_t ret_value = -1; /* Return value (Size of sequence in bytes) */ FUNC_ENTER_STATIC diff --git a/src/H5Ddbg.c b/src/H5Ddbg.c index 4e934f2..34e0ae9 100644 --- a/src/H5Ddbg.c +++ b/src/H5Ddbg.c @@ -17,10 +17,7 @@ /* Module Setup */ /****************/ -#define H5D_PACKAGE /*suppress error about including H5Dpkg */ - -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5D__init_dbg_interface +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ @@ -61,26 +58,6 @@ /* Local Variables */ /*******************/ - -/*-------------------------------------------------------------------------- -NAME - H5D__init_dbg_interface -- Initialize interface-specific information -USAGE - herr_t H5D__init_dbg_interface() -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. (Just calls - H5D_init() currently). - ---------------------------------------------------------------------------*/ -static herr_t -H5D__init_dbg_interface(void) -{ - FUNC_ENTER_STATIC_NOERR - - FUNC_LEAVE_NOAPI(H5D_init()) -} /* H5D__init_dbg_interface() */ /*------------------------------------------------------------------------- diff --git a/src/H5Ddeprec.c b/src/H5Ddeprec.c index cd2bc84..5a2b355 100644 --- a/src/H5Ddeprec.c +++ b/src/H5Ddeprec.c @@ -31,10 +31,7 @@ /* Module Setup */ /****************/ -#define H5D_PACKAGE /*suppress error about including H5Dpkg */ - -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5D__init_deprec_interface +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ @@ -85,51 +82,6 @@ static herr_t H5D__extend(H5D_t *dataset, const hsize_t *size, hid_t dxpl_id); /*******************/ - -/*-------------------------------------------------------------------------- -NAME - H5D__init_deprec_interface -- Initialize interface-specific information -USAGE - herr_t H5D__init_deprec_interface() -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. (Just calls - H5D_init() currently). - ---------------------------------------------------------------------------*/ -static herr_t -H5D__init_deprec_interface(void) -{ - FUNC_ENTER_STATIC_NOERR - - FUNC_LEAVE_NOAPI(H5D_init()) -} /* H5D__init_deprec_interface() */ - - -/*-------------------------------------------------------------------------- -NAME - H5D__term_deprec_interface -- Terminate interface -USAGE - herr_t H5D__term_deprec_interface() -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Terminates interface. (Just resets H5_interface_initialize_g - currently). - ---------------------------------------------------------------------------*/ -herr_t -H5D__term_deprec_interface(void) -{ - FUNC_ENTER_PACKAGE_NOERR - - /* Mark closed */ - H5_interface_initialize_g = 0; - - FUNC_LEAVE_NOAPI(0) -} /* H5D__term_deprec_interface() */ - #ifndef H5_NO_DEPRECATED_SYMBOLS /*------------------------------------------------------------------------- diff --git a/src/H5Dearray.c b/src/H5Dearray.c index dcd2632..6c77333 100644 --- a/src/H5Dearray.c +++ b/src/H5Dearray.c @@ -27,7 +27,7 @@ /* Module Setup */ /****************/ -#define H5D_PACKAGE /*suppress error about including H5Dpkg */ +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ diff --git a/src/H5Defl.c b/src/H5Defl.c index 7a77c22..ec96ae7 100644 --- a/src/H5Defl.c +++ b/src/H5Defl.c @@ -22,7 +22,7 @@ /* Module Setup */ /****************/ -#define H5D_PACKAGE /*suppress error about including H5Dpkg */ +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ @@ -456,7 +456,7 @@ H5D__efl_readvv(const H5D_io_info_t *io_info, size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_off_arr[]) { H5D_efl_readvv_ud_t udata; /* User data for H5VM_opvv() operator */ - ssize_t ret_value; /* Return value (Total size of sequence in bytes) */ + ssize_t ret_value = -1; /* Return value (Total size of sequence in bytes) */ FUNC_ENTER_STATIC @@ -536,7 +536,7 @@ H5D__efl_writevv(const H5D_io_info_t *io_info, size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_off_arr[]) { H5D_efl_writevv_ud_t udata; /* User data for H5VM_opvv() operator */ - ssize_t ret_value; /* Return value (Total size of sequence in bytes) */ + ssize_t ret_value = -1; /* Return value (Total size of sequence in bytes) */ FUNC_ENTER_STATIC diff --git a/src/H5Dfarray.c b/src/H5Dfarray.c index a074c87..a031232 100644 --- a/src/H5Dfarray.c +++ b/src/H5Dfarray.c @@ -26,7 +26,7 @@ /* Module Setup */ /****************/ -#define H5D_PACKAGE /*suppress error about including H5Dpkg */ +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ diff --git a/src/H5Dfill.c b/src/H5Dfill.c index 484c362..947a177 100644 --- a/src/H5Dfill.c +++ b/src/H5Dfill.c @@ -28,7 +28,8 @@ /* Module Setup */ /****************/ -#define H5D_PACKAGE /*suppress error about including H5Dpkg */ +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ + /***********/ /* Headers */ diff --git a/src/H5Dint.c b/src/H5Dint.c index a4caf3b..5812d2b 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -17,10 +17,7 @@ /* Module Setup */ /****************/ -#define H5D_PACKAGE /*suppress error about including H5Dpkg */ - -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5D__init_interface +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ @@ -120,6 +117,9 @@ static const H5I_class_t H5I_DATASET_CLS[1] = {{ (H5I_free_t)H5D_close /* 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; + /*------------------------------------------------------------------------- @@ -151,9 +151,9 @@ done: /*-------------------------------------------------------------------------- NAME - H5D__init_interface -- Initialize interface-specific information + H5D__init_package -- Initialize interface-specific information USAGE - herr_t H5D__init_interface() + herr_t H5D__init_package() RETURNS Non-negative on success/Negative on failure @@ -164,13 +164,13 @@ NOTES a deadlock in the library when the library is attempting to terminate -QAK --------------------------------------------------------------------------*/ -static herr_t -H5D__init_interface(void) +herr_t +H5D__init_package(void) { - H5P_genplist_t *def_dcpl; /* Default Dataset Creation Property list */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *def_dcpl; /* Default Dataset Creation Property list */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC + FUNC_ENTER_PACKAGE /* Initialize the atom group for the dataset IDs */ if(H5I_register_type(H5I_DATASET_CLS) < 0) @@ -204,34 +204,36 @@ H5D__init_interface(void) if(H5D__get_dxpl_cache_real(H5P_DATASET_XFER_DEFAULT, &H5D_def_dxpl_cache) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve default DXPL info") + /* Mark "top" of interface as initialized, too */ + H5D_top_package_initialize_s = TRUE; + done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5D__init_interface() */ +} /* end H5D__init_package() */ /*------------------------------------------------------------------------- - * Function: H5D_term_interface + * Function: H5D_top_term_package * - * Purpose: Terminate this interface. + * Purpose: Close the "top" of the interface, releasing IDs, etc. * * Return: Success: Positive if anything was done that might * affect other interfaces; zero otherwise. - * * Failure: Negative. * - * Programmer: Robb Matzke - * Friday, November 20, 1998 + * Programmer: Quincey Koziol + * Sunday, September 13, 2015 * *------------------------------------------------------------------------- */ int -H5D_term_interface(void) +H5D_top_term_package(void) { int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5_interface_initialize_g) { + 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 @@ -258,24 +260,55 @@ H5D_term_interface(void) (void)H5I_clear_type(H5I_DATASET, TRUE, FALSE); n++; /*H5I*/ } /* end if */ - else { - /* Close public interface */ - n += H5D__term_pub_interface(); - /* Close deprecated interface */ - n += H5D__term_deprec_interface(); + /* Mark closed */ + if(0 == n) + H5D_top_package_initialize_s = FALSE; + } /* end if */ + + FUNC_LEAVE_NOAPI(n) +} /* end H5D_top_term_package() */ - /* Destroy the dataset object id group */ - (void)H5I_dec_type_ref(H5I_DATASET); - n++; /*H5I*/ + +/*------------------------------------------------------------------------- + * Function: H5D_term_package + * + * Purpose: Terminate this interface. + * + * Note: Finishes shutting down the interface, after + * H5D_top_term_package() is called + * + * Return: Success: Positive if anything was done that might + * affect other interfaces; zero otherwise. + * Failure: Negative. + * + * Programmer: Robb Matzke + * Friday, November 20, 1998 + * + *------------------------------------------------------------------------- + */ +int +H5D_term_package(void) +{ + int n = 0; + + 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); - /* Mark closed */ - H5_interface_initialize_g = 0; - } /* end else */ + /* Mark closed */ + if(0 == n) + H5_PKG_INIT_VAR = FALSE; } /* end if */ FUNC_LEAVE_NOAPI(n) -} /* end H5D_term_interface() */ +} /* end H5D_term_package() */ /*-------------------------------------------------------------------------- @@ -429,7 +462,7 @@ H5D__create_named(const H5G_loc_t *loc, const char *name, hid_t type_id, { H5O_obj_create_t ocrt_info; /* Information for object creation */ H5D_obj_create_t dcrt_info; /* Information for dataset creation */ - H5D_t *ret_value; /* Return value */ + H5D_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -554,7 +587,7 @@ H5D__new(hid_t dcpl_id, hbool_t creating, hbool_t vl_type) { H5D_shared_t *new_dset = NULL; /* New dataset object */ H5P_genplist_t *plist; /* Property list created */ - H5D_shared_t *ret_value; /* Return value */ + H5D_shared_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -1088,7 +1121,7 @@ H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, hbool_t pline_copied = FALSE; /* Flag to indicate that pipeline message was copied */ hbool_t efl_copied = FALSE; /* Flag to indicate that external file list message was copied */ H5G_loc_t dset_loc; /* Dataset location */ - H5D_t *ret_value; /* Return value */ + H5D_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -1312,7 +1345,7 @@ H5D__open_name(const H5G_loc_t *loc, const char *name, hid_t dapl_id, H5O_loc_t oloc; /* Dataset object location */ H5O_type_t obj_type; /* Type of object at location */ hbool_t loc_found = FALSE; /* Location at 'name' found */ - H5D_t *ret_value; /* Return value */ + H5D_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -1372,7 +1405,7 @@ H5D_open(const H5G_loc_t *loc, hid_t dapl_id, hid_t dxpl_id) { H5D_shared_t *shared_fo = NULL; H5D_t *dataset = NULL; - H5D_t *ret_value; /* Return value */ + H5D_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -2305,7 +2338,7 @@ H5D_vlen_reclaim(hid_t type_id, H5S_t *space, hid_t plist_id, void *buf) H5S_sel_iter_op_t dset_op; /* Operator for iteration */ H5T_vlen_alloc_info_t _vl_alloc_info; /* VL allocation info buffer */ H5T_vlen_alloc_info_t *vl_alloc_info = &_vl_alloc_info; /* VL allocation info */ - herr_t ret_value; + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2353,7 +2386,7 @@ void * H5D__vlen_get_buf_size_alloc(size_t size, void *info) { H5D_vlen_bufsize_t *vlen_bufsize = (H5D_vlen_bufsize_t *)info; - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE_NOERR @@ -2983,7 +3016,7 @@ H5D_get_create_plist(H5D_t *dset) H5O_fill_t copied_fill; /* Fill value to tweak */ H5O_efl_t copied_efl; /* External file list to tweak */ hid_t new_dcpl_id = FAIL; - hid_t ret_value; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(FAIL) diff --git a/src/H5Dio.c b/src/H5Dio.c index f9e8f37..d85632a 100644 --- a/src/H5Dio.c +++ b/src/H5Dio.c @@ -17,7 +17,7 @@ /* Module Setup */ /****************/ -#define H5D_PACKAGE /*suppress error about including H5Dpkg */ +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ diff --git a/src/H5Dlayout.c b/src/H5Dlayout.c index e61cb7c..571ea19 100644 --- a/src/H5Dlayout.c +++ b/src/H5Dlayout.c @@ -17,7 +17,7 @@ /* Module Setup */ /****************/ -#define H5D_PACKAGE /*suppress error about including H5Dpkg */ +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ @@ -156,7 +156,7 @@ done: size_t H5D__layout_meta_size(const H5F_t *f, const H5O_layout_t *layout, hbool_t include_compact_data) { - size_t ret_value; + size_t ret_value = 0; /* Return value */ FUNC_ENTER_PACKAGE diff --git a/src/H5Dmodule.h b/src/H5Dmodule.h new file mode 100644 index 0000000..9b0c411 --- /dev/null +++ b/src/H5Dmodule.h @@ -0,0 +1,35 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Quincey Koziol <koziol@hdfgroup.org> + * Saturday, September 12, 2015 + * + * Purpose: This file contains declarations which define macros for the + * H5D package. Including this header means that the source file + * is part of the H5D package. + */ +#ifndef _H5Dmodule_H +#define _H5Dmodule_H + +/* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error + * reporting macros. + */ +#define H5D_MODULE +#define H5_MY_PKG H5D +#define H5_MY_PKG_ERR H5E_DATASET +#define H5_MY_PKG_INIT YES + +#endif /* _H5Dmodule_H */ + diff --git a/src/H5Dmpio.c b/src/H5Dmpio.c index c35f194..a5f34d1 100644 --- a/src/H5Dmpio.c +++ b/src/H5Dmpio.c @@ -27,7 +27,7 @@ /* Module Setup */ /****************/ -#define H5D_PACKAGE /* suppress error about including H5Dpkg */ +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ diff --git a/src/H5Dnone.c b/src/H5Dnone.c index 427aeb6..3d761fb 100644 --- a/src/H5Dnone.c +++ b/src/H5Dnone.c @@ -30,7 +30,7 @@ /* Module Setup */ /****************/ -#define H5D_PACKAGE /*suppress error about including H5Dpkg */ +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ diff --git a/src/H5Doh.c b/src/H5Doh.c index 8f32e15..bc46a37 100644 --- a/src/H5Doh.c +++ b/src/H5Doh.c @@ -17,8 +17,8 @@ /* Module Setup */ /****************/ -#define H5D_PACKAGE /*suppress error about including H5Dpkg */ -#define H5O_PACKAGE /*suppress error about including H5Opkg */ +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ +#define H5O_FRIEND /*suppress error about including H5Opkg */ /***********/ @@ -108,7 +108,7 @@ H5FL_DEFINE(H5D_copy_file_ud_t); static void * H5O__dset_get_copy_file_udata(void) { - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -227,10 +227,10 @@ done: static hid_t H5O__dset_open(const H5G_loc_t *obj_loc, hid_t lapl_id, hid_t dxpl_id, hbool_t app_ref) { - H5D_t *dset = NULL; /* Dataset opened */ - htri_t isdapl; /* lapl_id is a dapl */ - hid_t dapl_id; /* dapl to use to open this dataset */ - hid_t ret_value; /* Return value */ + H5D_t *dset = NULL; /* Dataset opened */ + htri_t isdapl; /* lapl_id is a dapl */ + hid_t dapl_id; /* dapl to use to open this dataset */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_STATIC @@ -283,7 +283,7 @@ H5O__dset_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc, hid_t dxpl_id) { H5D_obj_create_t *crt_info = (H5D_obj_create_t *)_crt_info; /* Dataset creation parameters */ H5D_t *dset = NULL; /* New dataset created */ - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -331,7 +331,7 @@ static H5O_loc_t * H5O__dset_get_oloc(hid_t obj_id) { H5D_t *dset; /* Dataset opened */ - H5O_loc_t *ret_value; /* Return value */ + H5O_loc_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h index 258c161..7569f72 100644 --- a/src/H5Dpkg.h +++ b/src/H5Dpkg.h @@ -21,7 +21,7 @@ * the H5D package. Source files outside the H5D package should * include H5Dprivate.h instead. */ -#ifndef H5D_PACKAGE +#if !(defined H5D_FRIEND || defined H5D_MODULE) #error "Do not include this file outside the H5D package!" #endif @@ -583,8 +583,6 @@ H5_DLLVAR const H5B2_class_t H5D_BT2_FILT[1]; /* Package Private Prototypes */ /******************************/ -H5_DLL herr_t H5D__term_pub_interface(void); -H5_DLL herr_t H5D__term_deprec_interface(void); H5_DLL H5D_t *H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id); H5_DLL H5D_t *H5D__create_named(const H5G_loc_t *loc, const char *name, diff --git a/src/H5Dscatgath.c b/src/H5Dscatgath.c index 4b0846f..9902b7b 100644 --- a/src/H5Dscatgath.c +++ b/src/H5Dscatgath.c @@ -17,7 +17,7 @@ /* Module Setup */ /****************/ -#define H5D_PACKAGE /*suppress error about including H5Dpkg */ +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ diff --git a/src/H5Dselect.c b/src/H5Dselect.c index 38f8bc4..ce6073c 100644 --- a/src/H5Dselect.c +++ b/src/H5Dselect.c @@ -23,7 +23,7 @@ /* Module Setup */ /****************/ -#define H5D_PACKAGE /*suppress error about including H5Dpkg */ +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ diff --git a/src/H5Dtest.c b/src/H5Dtest.c index 410a3f6..c3b0b19 100644 --- a/src/H5Dtest.c +++ b/src/H5Dtest.c @@ -23,7 +23,7 @@ /* Module Setup */ /****************/ -#define H5D_PACKAGE /*suppress error about including H5Dpkg */ +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ #define H5D_TESTING /*suppress warning about H5D testing funcs*/ @@ -45,10 +45,7 @@ /* Module Setup */ /****************/ -#define H5E_PACKAGE /*suppress error about including H5Epkg */ - -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5E_init_interface +#include "H5Emodule.h" /* This source code file is part of the H5E module */ /***********/ @@ -83,6 +80,7 @@ /* Local Prototypes */ /********************/ /* Static function declarations */ +static herr_t H5E_set_default_auto(H5E_t *stk); static H5E_cls_t *H5E_register_class(const char *cls_name, const char *lib_name, const char *version); static herr_t H5E_unregister_class(H5E_cls_t *cls); @@ -100,6 +98,9 @@ static ssize_t H5E_get_num(const H5E_t *err_stack); /* Package Variables */ /*********************/ +/* Package initialization variable */ +hbool_t H5_PKG_INIT_VAR = FALSE; + /*****************************/ /* Library Private Variables */ @@ -173,45 +174,7 @@ done: /*-------------------------------------------------------------------------- - * Function: H5E_set_default_auto - * - * Purpose: Initialize "automatic" error stack reporting info to library - * default - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * Thursday, November 1, 2007 - * - *-------------------------------------------------------------------------- - */ -static herr_t -H5E_set_default_auto(H5E_t *stk) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - -#ifndef H5_NO_DEPRECATED_SYMBOLS -#ifdef H5_USE_16_API_DEFAULT - stk->auto_op.vers = 1; -#else /* H5_USE_16_API */ - stk->auto_op.vers = 2; -#endif /* H5_USE_16_API_DEFAULT */ - - stk->auto_op.func1 = stk->auto_op.func1_default = (H5E_auto1_t)H5Eprint1; - stk->auto_op.func2 = stk->auto_op.func2_default = (H5E_auto2_t)H5Eprint2; - stk->auto_op.is_default = TRUE; -#else /* H5_NO_DEPRECATED_SYMBOLS */ - stk->auto_op.func2 = (H5E_auto2_t)H5Eprint2; -#endif /* H5_NO_DEPRECATED_SYMBOLS */ - - stk->auto_data = NULL; - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5E_set_default_auto() */ - - -/*-------------------------------------------------------------------------- - * Function: H5E_init_interface + * Function: H5E__init_package * * Purpose: Initialize interface-specific information * @@ -222,15 +185,15 @@ H5E_set_default_auto(H5E_t *stk) * *-------------------------------------------------------------------------- */ -static herr_t -H5E_init_interface(void) +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 */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* Initialize the atom group for the error class IDs */ if(H5I_register_type(H5I_ERRCLS_CLS) < 0) @@ -262,11 +225,11 @@ H5E_init_interface(void) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5E_init_interface() */ +} /* end H5E__init_package() */ /*------------------------------------------------------------------------- - * Function: H5E_term_interface + * Function: H5E_term_package * * Purpose: Terminates the H5E interface * @@ -281,13 +244,13 @@ done: *------------------------------------------------------------------------- */ int -H5E_term_interface(void) +H5E_term_package(void) { int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5_interface_initialize_g) { + if(H5_PKG_INIT_VAR) { int64_t ncls, nmsg, nstk; /* Check if there are any open error stacks, classes or messages */ @@ -323,22 +286,57 @@ H5E_term_interface(void) n++; /*H5I*/ } /* end if */ else { - /* Close deprecated interface */ - n += H5E__term_deprec_interface(); - /* Destroy the error class, message, and stack id groups */ - (void)H5I_dec_type_ref(H5I_ERROR_STACK); - (void)H5I_dec_type_ref(H5I_ERROR_CLASS); - (void)H5I_dec_type_ref(H5I_ERROR_MSG); - n++; /*H5I*/ + 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 */ - H5_interface_initialize_g = 0; + if(0 == n) + H5_PKG_INIT_VAR = FALSE; } /* end else */ } /* end if */ FUNC_LEAVE_NOAPI(n) -} /* end H5E_term_interface() */ +} /* end H5E_term_package() */ + + +/*-------------------------------------------------------------------------- + * Function: H5E_set_default_auto + * + * Purpose: Initialize "automatic" error stack reporting info to library + * default + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Thursday, November 1, 2007 + * + *-------------------------------------------------------------------------- + */ +static herr_t +H5E_set_default_auto(H5E_t *stk) +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR + +#ifndef H5_NO_DEPRECATED_SYMBOLS +#ifdef H5_USE_16_API_DEFAULT + stk->auto_op.vers = 1; +#else /* H5_USE_16_API */ + stk->auto_op.vers = 2; +#endif /* H5_USE_16_API_DEFAULT */ + + stk->auto_op.func1 = stk->auto_op.func1_default = (H5E_auto1_t)H5Eprint1; + stk->auto_op.func2 = stk->auto_op.func2_default = (H5E_auto2_t)H5Eprint2; + stk->auto_op.is_default = TRUE; +#else /* H5_NO_DEPRECATED_SYMBOLS */ + stk->auto_op.func2 = (H5E_auto2_t)H5Eprint2; +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + + stk->auto_data = NULL; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5E_set_default_auto() */ #ifdef H5_HAVE_THREADSAFE @@ -360,7 +358,7 @@ H5E_term_interface(void) H5E_t * H5E_get_stack(void) { - H5E_t *estack; + H5E_t *estack = NULL; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -371,7 +369,7 @@ H5E_get_stack(void) #ifdef H5_HAVE_WIN_THREADS estack = (H5E_t *)LocalAlloc(LPTR, sizeof(H5E_t)); /* Win32 has to use LocalAlloc to match the LocalFree in DllMain */ #else - estack = (H5E_t *)H5FL_MALLOC(H5E_t); + estack = (H5E_t *)HDmalloc(sizeof(H5E_t)); #endif /* H5_HAVE_WIN_THREADS */ HDassert(estack); @@ -475,8 +473,8 @@ done: static H5E_cls_t * H5E_register_class(const char *cls_name, const char *lib_name, const char *version) { - H5E_cls_t *cls = NULL; /* Pointer to error class */ - H5E_cls_t *ret_value; /* Return value */ + H5E_cls_t *cls = NULL; /* Pointer to error class */ + H5E_cls_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -631,7 +629,7 @@ done: static ssize_t H5E_get_class_name(const H5E_cls_t *cls, char *name, size_t size) { - ssize_t len; /* Length of error class's name */ + ssize_t len = 0; /* Length of error class's name */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -812,8 +810,8 @@ done: static H5E_msg_t * H5E_create_msg(H5E_cls_t *cls, H5E_type_t msg_type, const char *msg_str) { - H5E_msg_t *msg = NULL; /* Pointer to new error message */ - H5E_msg_t *ret_value; /* Return value */ + H5E_msg_t *msg = NULL; /* Pointer to new error message */ + H5E_msg_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -967,10 +965,10 @@ done: static H5E_t * H5E_get_current_stack(void) { - H5E_t *current_stack; /* Pointer to the current error stack */ - H5E_t *estack_copy=NULL; /* Pointer to new error stack to return */ - unsigned u; /* Local index variable */ - H5E_t *ret_value; /* Return value */ + H5E_t *current_stack; /* Pointer to the current error stack */ + H5E_t *estack_copy = NULL; /* Pointer to new error stack to return */ + unsigned u; /* Local index variable */ + H5E_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -33,7 +33,7 @@ /* Module Declaration */ /**********************/ -#define H5EA_MODULE +#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ /***********************/ @@ -79,6 +79,9 @@ typedef herr_t (*H5EA__unprotect_func_t)(void *thing, hid_t dxpl_id, /* 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/H5EAcache.c b/src/H5EAcache.c index 9041877..1a9531b 100644 --- a/src/H5EAcache.c +++ b/src/H5EAcache.c @@ -28,7 +28,7 @@ /* Module Declaration */ /**********************/ -#define H5EA_MODULE +#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ /***********************/ diff --git a/src/H5EAdbg.c b/src/H5EAdbg.c index 9c3ce6d..ef45881 100644 --- a/src/H5EAdbg.c +++ b/src/H5EAdbg.c @@ -28,7 +28,7 @@ /* Module Declaration */ /**********************/ -#define H5EA_MODULE +#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ /***********************/ diff --git a/src/H5EAdblkpage.c b/src/H5EAdblkpage.c index 5d188c2..15bad43 100644 --- a/src/H5EAdblkpage.c +++ b/src/H5EAdblkpage.c @@ -28,7 +28,7 @@ /* Module Declaration */ /**********************/ -#define H5EA_MODULE +#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ /***********************/ diff --git a/src/H5EAdblock.c b/src/H5EAdblock.c index 24be87a..cd20bba 100644 --- a/src/H5EAdblock.c +++ b/src/H5EAdblock.c @@ -28,7 +28,7 @@ /* Module Declaration */ /**********************/ -#define H5EA_MODULE +#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ /***********************/ diff --git a/src/H5EAhdr.c b/src/H5EAhdr.c index e82ad7f..111dc88 100644 --- a/src/H5EAhdr.c +++ b/src/H5EAhdr.c @@ -28,7 +28,7 @@ /* Module Declaration */ /**********************/ -#define H5EA_MODULE +#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ /***********************/ diff --git a/src/H5EAiblock.c b/src/H5EAiblock.c index 364b443..3f49d0d 100644 --- a/src/H5EAiblock.c +++ b/src/H5EAiblock.c @@ -28,7 +28,7 @@ /* Module Declaration */ /**********************/ -#define H5EA_MODULE +#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ /***********************/ diff --git a/src/H5EAint.c b/src/H5EAint.c index 12a9cda..9f910d0 100644 --- a/src/H5EAint.c +++ b/src/H5EAint.c @@ -28,7 +28,7 @@ /* Module Declaration */ /**********************/ -#define H5EA_MODULE +#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ /***********************/ diff --git a/src/H5EAmodule.h b/src/H5EAmodule.h new file mode 100644 index 0000000..405b232 --- /dev/null +++ b/src/H5EAmodule.h @@ -0,0 +1,35 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Quincey Koziol <koziol@hdfgroup.org> + * Saturday, September 12, 2015 + * + * Purpose: This file contains declarations which define macros for the + * H5EA package. Including this header means that the source file + * is part of the H5EA package. + */ +#ifndef _H5EAmodule_H +#define _H5EAmodule_H + +/* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error + * reporting macros. + */ +#define H5EA_MODULE +#define H5_MY_PKG H5EA +#define H5_MY_PKG_ERR H5E_EARRAY +#define H5_MY_PKG_INIT NO + +#endif /* _H5EAmodule_H */ + diff --git a/src/H5EApkg.h b/src/H5EApkg.h index 993a9e1..f7ab4ba 100644 --- a/src/H5EApkg.h +++ b/src/H5EApkg.h @@ -21,7 +21,7 @@ * the H5EA package. Source files outside the H5EA package should * include H5EAprivate.h instead. */ -#if !(defined(H5EA_PACKAGE) | defined(H5EA_MODULE)) +#if !(defined(H5EA_FRIEND) | defined(H5EA_MODULE)) #error "Do not include this file outside the H5EA package!" #endif @@ -39,16 +39,6 @@ /* Package Private Macros */ /**************************/ -/* If this package header is being included in one of the H5EA modules, define - * the proper control macros for the generic FUNC_ENTER/LEAVE and error - * reporting macros. - */ -#ifdef H5EA_MODULE -#define H5_MY_PKG H5EA -#define H5_MY_PKG_ERR H5E_EARRAY -#define H5_MY_PKG_INIT NO -#endif /* H5EA_MODULE */ - /* Fill value for extensible array test class */ #ifdef H5EA_TESTING #define H5EA_TEST_FILL ((uint64_t)ULLONG_MAX) diff --git a/src/H5EAsblock.c b/src/H5EAsblock.c index 33f34c9..7753f0e 100644 --- a/src/H5EAsblock.c +++ b/src/H5EAsblock.c @@ -28,7 +28,7 @@ /* Module Declaration */ /**********************/ -#define H5EA_MODULE +#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ /***********************/ diff --git a/src/H5EAstat.c b/src/H5EAstat.c index 8a26e34..0c27681 100644 --- a/src/H5EAstat.c +++ b/src/H5EAstat.c @@ -28,7 +28,7 @@ /* Module Declaration */ /**********************/ -#define H5EA_MODULE +#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ /***********************/ diff --git a/src/H5EAtest.c b/src/H5EAtest.c index b3942ca..905aa7f 100644 --- a/src/H5EAtest.c +++ b/src/H5EAtest.c @@ -24,7 +24,7 @@ /* Module Declaration */ /**********************/ -#define H5EA_MODULE +#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ #define H5EA_TESTING diff --git a/src/H5Edeprec.c b/src/H5Edeprec.c index 6a83745..1a13c01 100644 --- a/src/H5Edeprec.c +++ b/src/H5Edeprec.c @@ -31,10 +31,7 @@ /* Module Setup */ /****************/ -#define H5E_PACKAGE /*suppress error about including H5Epkg */ - -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5E__init_deprec_interface +#include "H5Emodule.h" /* This source code file is part of the H5E module */ /***********/ @@ -82,51 +79,6 @@ /*******************/ - -/*-------------------------------------------------------------------------- -NAME - H5E__init_deprec_interface -- Initialize interface-specific information -USAGE - herr_t H5E__init_deprec_interface() -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. (Just calls - H5E_init() currently). - ---------------------------------------------------------------------------*/ -static herr_t -H5E__init_deprec_interface(void) -{ - FUNC_ENTER_STATIC_NOERR - - FUNC_LEAVE_NOAPI(H5E_init()) -} /* H5E__init_deprec_interface() */ - - -/*-------------------------------------------------------------------------- -NAME - H5E__term_deprec_interface -- Terminate interface -USAGE - herr_t H5E__term_deprec_interface() -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Terminates interface. (Just resets H5_interface_initialize_g - currently). - ---------------------------------------------------------------------------*/ -herr_t -H5E__term_deprec_interface(void) -{ - FUNC_ENTER_PACKAGE_NOERR - - /* Mark closed */ - H5_interface_initialize_g = 0; - - FUNC_LEAVE_NOAPI(0) -} /* H5E__term_deprec_interface() */ - #ifndef H5_NO_DEPRECATED_SYMBOLS /*------------------------------------------------------------------------- diff --git a/src/H5Eint.c b/src/H5Eint.c index 07d1e46..6e84a09 100644 --- a/src/H5Eint.c +++ b/src/H5Eint.c @@ -28,10 +28,7 @@ /* Module Setup */ /****************/ -#define H5E_PACKAGE /*suppress error about including H5Epkg */ - -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5E_init_int_interface +#include "H5Emodule.h" /* This source code file is part of the H5E module */ /***********/ @@ -117,27 +114,6 @@ int H5E_mpi_error_str_len; -/*-------------------------------------------------------------------------- -NAME - H5E_init_int_interface -- Initialize interface-specific information -USAGE - herr_t H5E_init_int_interface() -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. (Just calls - H5E_init() currently). - ---------------------------------------------------------------------------*/ -static herr_t -H5E_init_int_interface(void) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - FUNC_LEAVE_NOAPI(H5E_init()) -} /* H5E_init_int_interface() */ - - /*------------------------------------------------------------------------- * Function: H5E_get_msg * @@ -154,7 +130,7 @@ H5E_init_int_interface(void) ssize_t H5E_get_msg(const H5E_msg_t *msg, H5E_type_t *type, char *msg_str, size_t size) { - ssize_t len; /* Length of error message */ + ssize_t len = -1; /* Length of error message */ FUNC_ENTER_NOAPI_NOINIT_NOERR diff --git a/src/H5Emodule.h b/src/H5Emodule.h new file mode 100644 index 0000000..d624409 --- /dev/null +++ b/src/H5Emodule.h @@ -0,0 +1,36 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Quincey Koziol <koziol@hdfgroup.org> + * Saturday, September 12, 2015 + * + * Purpose: This file contains declarations which define macros for the + * H5E package. Including this header means that the source file + * is part of the H5E package. + */ +#ifndef _H5Emodule_H +#define _H5Emodule_H + +/* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error + * reporting macros. + */ +#define H5E_MODULE +#define H5_MY_PKG H5E +#define H5_MY_PKG_ERR H5E_ERROR +#define H5_MY_PKG_INIT YES + +#endif /* _H5Emodule_H */ + + diff --git a/src/H5Epkg.h b/src/H5Epkg.h index bfaaf9d..3af653a 100644 --- a/src/H5Epkg.h +++ b/src/H5Epkg.h @@ -21,7 +21,7 @@ * the H5E package. Source files outside the H5E package should * include H5Eprivate.h instead. */ -#ifndef H5E_PACKAGE +#if !(defined H5E_FRIEND || defined H5E_MODULE) #error "Do not include this file outside the H5E package!" #endif @@ -17,10 +17,7 @@ /* Module Setup */ /****************/ -#define H5F_PACKAGE /*suppress error about including H5Fpkg */ - -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5F__init_pub_interface +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ /***********/ @@ -65,6 +62,9 @@ /* Package Variables */ /*********************/ +/* Package initialization variable */ +hbool_t H5_PKG_INIT_VAR = FALSE; + /*****************************/ /* Library Private Variables */ @@ -87,21 +87,21 @@ static const H5I_class_t H5I_FILE_CLS[1] = {{ /*-------------------------------------------------------------------------- NAME - H5F__init_pub_interface -- Initialize interface-specific information + H5F__init_package -- Initialize interface-specific information USAGE - herr_t H5F__init_pub_interface() + herr_t H5F__init_package() RETURNS Non-negative on success/Negative on failure DESCRIPTION - Initializes any interface-specific data or routines. (Just calls - H5F_init() currently). + Initializes any interface-specific data or routines. --------------------------------------------------------------------------*/ -static herr_t -H5F__init_pub_interface(void) +herr_t +H5F__init_package(void) { - herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE /* * Initialize the atom group for the file IDs. @@ -109,40 +109,13 @@ H5F__init_pub_interface(void) if(H5I_register_type(H5I_FILE_CLS) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to initialize interface") - ret_value = H5F_init(); -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5F__init_pub_interface() */ - - -/*------------------------------------------------------------------------- - * Function: H5F_init - * - * Purpose: Initialize the interface from some other layer. - * - * Return: Success: non-negative - * Failure: negative - * - * Programmer: Robb Matzke - * Wednesday, December 16, 1998 - * - *------------------------------------------------------------------------- - */ -herr_t -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() */ +} /* H5F__init_package() */ /*------------------------------------------------------------------------- - * Function: H5F_term_interface + * Function: H5F_term_package * * Purpose: Terminate this interface: free all memory and reset global * variables to their initial values. Release all ID groups @@ -160,13 +133,13 @@ done: *------------------------------------------------------------------------- */ int -H5F_term_interface(void) +H5F_term_package(void) { int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5_interface_initialize_g) { + if(H5_PKG_INIT_VAR) { if(H5I_nmembers(H5I_FILE) > 0) { (void)H5I_clear_type(H5I_FILE, FALSE, FALSE); n++; /*H5I*/ @@ -175,20 +148,17 @@ H5F_term_interface(void) /* Make certain we've cleaned up all the shared file objects */ H5F_sfile_assert_num(0); - /* Close deprecated interface */ - n += H5F__term_deprec_interface(); - /* Destroy the file object id group */ - (void)H5I_dec_type_ref(H5I_FILE); - n++; /*H5I*/ + n += (H5I_dec_type_ref(H5I_FILE) > 0); /* Mark closed */ - H5_interface_initialize_g = 0; + if(0 == n) + H5_PKG_INIT_VAR = FALSE; } /* end else */ } /* end if */ FUNC_LEAVE_NOAPI(n) -} /* end H5F_term_interface() */ +} /* end H5F_term_package() */ /*------------------------------------------------------------------------- @@ -29,7 +29,7 @@ /* Module Declaration */ /**********************/ -#define H5FA_MODULE +#include "H5FAmodule.h" /* This source code file is part of the H5FA module */ /***********************/ /* Other Packages Used */ @@ -70,6 +70,9 @@ /* 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 diff --git a/src/H5FAcache.c b/src/H5FAcache.c index ce07b24..fad6757 100644 --- a/src/H5FAcache.c +++ b/src/H5FAcache.c @@ -28,7 +28,7 @@ /* Module Declaration */ /**********************/ -#define H5FA_MODULE +#include "H5FAmodule.h" /* This source code file is part of the H5FA module */ /***********************/ diff --git a/src/H5FAdbg.c b/src/H5FAdbg.c index 1d1e569..2dc51c5 100644 --- a/src/H5FAdbg.c +++ b/src/H5FAdbg.c @@ -26,7 +26,7 @@ /* Module Declaration */ /**********************/ -#define H5FA_MODULE +#include "H5FAmodule.h" /* This source code file is part of the H5FA module */ /***********************/ diff --git a/src/H5FAdblkpage.c b/src/H5FAdblkpage.c index 4337504..bba4439 100644 --- a/src/H5FAdblkpage.c +++ b/src/H5FAdblkpage.c @@ -26,7 +26,7 @@ /* Module Declaration */ /**********************/ -#define H5FA_MODULE +#include "H5FAmodule.h" /* This source code file is part of the H5FA module */ /***********************/ diff --git a/src/H5FAdblock.c b/src/H5FAdblock.c index 9336a85..95419f8 100644 --- a/src/H5FAdblock.c +++ b/src/H5FAdblock.c @@ -26,7 +26,7 @@ /* Module Declaration */ /**********************/ -#define H5FA_MODULE +#include "H5FAmodule.h" /* This source code file is part of the H5FA module */ /***********************/ diff --git a/src/H5FAhdr.c b/src/H5FAhdr.c index 79fe72a..b55bae1 100644 --- a/src/H5FAhdr.c +++ b/src/H5FAhdr.c @@ -26,7 +26,7 @@ /* Module Declaration */ /**********************/ -#define H5FA_MODULE +#include "H5FAmodule.h" /* This source code file is part of the H5FA module */ /***********************/ diff --git a/src/H5FAint.c b/src/H5FAint.c index b42b3ae..331227b 100644 --- a/src/H5FAint.c +++ b/src/H5FAint.c @@ -28,7 +28,7 @@ /* Module Declaration */ /**********************/ -#define H5FA_MODULE +#include "H5FAmodule.h" /* This source code file is part of the H5FA module */ /***********************/ diff --git a/src/H5FAmodule.h b/src/H5FAmodule.h new file mode 100644 index 0000000..e46b071 --- /dev/null +++ b/src/H5FAmodule.h @@ -0,0 +1,35 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Quincey Koziol <koziol@hdfgroup.org> + * Saturday, September 12, 2015 + * + * Purpose: This file contains declarations which define macros for the + * H5FA package. Including this header means that the source file + * is part of the H5FA package. + */ +#ifndef _H5FAmodule_H +#define _H5FAmodule_H + +/* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error + * reporting macros. + */ +#define H5FA_MODULE +#define H5_MY_PKG H5FA +#define H5_MY_PKG_ERR H5E_FARRAY +#define H5_MY_PKG_INIT NO + +#endif /* _H5FAmodule_H */ + diff --git a/src/H5FApkg.h b/src/H5FApkg.h index 77276cf..c36b7fc 100644 --- a/src/H5FApkg.h +++ b/src/H5FApkg.h @@ -20,7 +20,7 @@ * the H5FA package. Source files outside the H5FA package should * include H5FAprivate.h instead. */ -#if !(defined(H5FA_PACKAGE) | defined(H5FA_MODULE)) +#if !(defined(H5FA_FRIEND) | defined(H5FA_MODULE)) #error "Do not include this file outside the H5FA package!" #endif @@ -43,16 +43,6 @@ /* #define H5FA_DEBUG */ -/* If this package header is being included in one of the H5FA modules, define - * the proper control macros for the generic FUNC_ENTER/LEAVE and error - * reporting macros. - */ -#ifdef H5FA_MODULE -#define H5_MY_PKG H5FA -#define H5_MY_PKG_ERR H5E_FARRAY -#define H5_MY_PKG_INIT NO -#endif /* H5FA_MODULE */ - /* Fill value for fixed array test class */ #ifdef H5FA_TESTING #define H5FA_TEST_FILL ((uint64_t)ULLONG_MAX) diff --git a/src/H5FAstat.c b/src/H5FAstat.c index d6509c3..72fa0de 100644 --- a/src/H5FAstat.c +++ b/src/H5FAstat.c @@ -26,7 +26,7 @@ /* Module Declaration */ /**********************/ -#define H5FA_MODULE +#include "H5FAmodule.h" /* This source code file is part of the H5FA module */ /***********************/ diff --git a/src/H5FAtest.c b/src/H5FAtest.c index 2d22158..091f284 100644 --- a/src/H5FAtest.c +++ b/src/H5FAtest.c @@ -22,7 +22,7 @@ /* Module Declaration */ /**********************/ -#define H5FA_MODULE +#include "H5FAmodule.h" /* This source code file is part of the H5FA module */ #define H5FA_TESTING @@ -28,11 +28,8 @@ /* Module Setup */ /****************/ -#define H5F_PACKAGE /*suppress error about including H5Fpkg */ -#define H5FD_PACKAGE /*suppress error about including H5FDpkg */ - -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5FD_init_interface +#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#include "H5FDmodule.h" /* This source code file is part of the H5FD module */ /***********/ @@ -73,6 +70,9 @@ static int H5FD_driver_query(const H5FD_class_t *driver, unsigned long *flags/*o /* Package Variables */ /*********************/ +/* Package initialization variable */ +hbool_t H5_PKG_INIT_VAR = FALSE; + /*****************************/ /* Library Private Variables */ @@ -108,53 +108,24 @@ static const H5I_class_t H5I_VFL_CLS[1] = {{ /*------------------------------------------------------------------------- - * Function: H5FD_init - * - * Purpose: Initialize the interface from some other package. - * - * Return: Success: non-negative - * Failure: negative - * - * Programmer: Quincey Koziol - * Thursday, January 3, 2007 - * - *------------------------------------------------------------------------- - */ -herr_t -H5FD_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 H5FD_init() */ - - -/*------------------------------------------------------------------------- - * Function: H5FD_init_interface + * Function: H5FD__init_package * * Purpose: Initialize the virtual file layer. * * Return: Success: Non-negative - * * Failure: Negative * * Programmer: Robb Matzke * Monday, July 26, 1999 * - * Modifications: - * *------------------------------------------------------------------------- */ -static herr_t -H5FD_init_interface(void) +herr_t +H5FD__init_package(void) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE if(H5I_register_type(H5I_VFL_CLS) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize interface") @@ -164,11 +135,11 @@ H5FD_init_interface(void) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_init_interface() */ +} /* end H5FD__init_package() */ /*------------------------------------------------------------------------- - * Function: H5FD_term_interface + * Function: H5FD_term_package * * Purpose: Terminate this interface: free all memory and reset global * variables to their initial values. Release all ID groups @@ -177,40 +148,37 @@ done: * Return: Success: Positive if anything was done that might * have affected other interfaces; zero * otherwise. - * * Failure: Never fails. * * Programmer: Robb Matzke * Friday, February 19, 1999 * - * Modifications: - * *------------------------------------------------------------------------- */ int -H5FD_term_interface(void) +H5FD_term_package(void) { int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5_interface_initialize_g) { + 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 */ - (void)H5I_dec_type_ref(H5I_VFL); - n++; /*H5I*/ + n += (H5I_dec_type_ref(H5I_VFL) > 0); /* Mark closed */ - H5_interface_initialize_g = 0; + if(0 == n) + H5_PKG_INIT_VAR = FALSE; } /* end else */ } /* end if */ FUNC_LEAVE_NOAPI(n) -} /* end H5FD_term_interface() */ +} /* end H5FD_term_package() */ /*------------------------------------------------------------------------- @@ -218,7 +186,7 @@ H5FD_term_interface(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_interface). + * virtual file layer object identifiers (cf H5FD__init_package). * * Return: Success: Non-negative * @@ -345,7 +313,7 @@ H5FD_register(const void *_cls, size_t size, hbool_t app_ref) const H5FD_class_t *cls = (const H5FD_class_t *)_cls; H5FD_class_t *saved = NULL; H5FD_mem_t type; - hid_t ret_value; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -802,7 +770,7 @@ H5FD_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) H5P_genplist_t *plist; /* Property list pointer */ unsigned long driver_flags = 0; /* File-inspecific driver feature flags */ H5FD_file_image_info_t file_image_info; /* Initial file image */ - H5FD_t *ret_value; /* Return value */ + H5FD_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -1021,7 +989,7 @@ done: int H5FD_cmp(const H5FD_t *f1, const H5FD_t *f2) { - int ret_value; + int ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI(-1) /*return value is arbitrary*/ @@ -1434,7 +1402,7 @@ done: haddr_t H5FD_get_maxaddr(const H5FD_t *file) { - haddr_t ret_value; /* Return value */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI(HADDR_UNDEF) diff --git a/src/H5FDcore.c b/src/H5FDcore.c index 9e576d6..2307589 100644 --- a/src/H5FDcore.c +++ b/src/H5FDcore.c @@ -22,8 +22,7 @@ * access to small, temporary hdf5 files. */ -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5FD_core_init_interface +#include "H5FDdrvr_module.h" /* This source code file is part of the H5FD driver module */ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ @@ -123,26 +122,26 @@ typedef struct H5FD_core_fapl_t { (size_t)((A)+(Z))<(size_t)(A)) /* Prototypes */ -static herr_t H5FD_core_add_dirty_region(H5FD_core_t *file, haddr_t start, haddr_t end); -static herr_t H5FD_core_destroy_dirty_list(H5FD_core_t *file); -static herr_t H5FD_core_write_to_bstore(H5FD_core_t *file, haddr_t addr, size_t size); -static herr_t H5FD_core_term(void); -static void *H5FD_core_fapl_get(H5FD_t *_file); -static H5FD_t *H5FD_core_open(const char *name, unsigned flags, hid_t fapl_id, +static herr_t H5FD__core_add_dirty_region(H5FD_core_t *file, haddr_t start, haddr_t end); +static herr_t H5FD__core_destroy_dirty_list(H5FD_core_t *file); +static herr_t H5FD__core_write_to_bstore(H5FD_core_t *file, haddr_t addr, size_t size); +static herr_t H5FD__core_term(void); +static void *H5FD__core_fapl_get(H5FD_t *_file); +static H5FD_t *H5FD__core_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); -static herr_t H5FD_core_close(H5FD_t *_file); -static int H5FD_core_cmp(const H5FD_t *_f1, const H5FD_t *_f2); -static herr_t H5FD_core_query(const H5FD_t *_f1, unsigned long *flags); -static haddr_t H5FD_core_get_eoa(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD_core_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); -static haddr_t H5FD_core_get_eof(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD_core_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle); -static herr_t H5FD_core_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, +static herr_t H5FD__core_close(H5FD_t *_file); +static int H5FD__core_cmp(const H5FD_t *_f1, const H5FD_t *_f2); +static herr_t H5FD__core_query(const H5FD_t *_f1, unsigned long *flags); +static haddr_t H5FD__core_get_eoa(const H5FD_t *_file, H5FD_mem_t type); +static herr_t H5FD__core_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); +static haddr_t H5FD__core_get_eof(const H5FD_t *_file, H5FD_mem_t type); +static herr_t H5FD__core_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle); +static herr_t H5FD__core_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, void *buf); -static herr_t H5FD_core_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, +static herr_t H5FD__core_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, const void *buf); -static herr_t H5FD_core_flush(H5FD_t *_file, hid_t dxpl_id, unsigned closing); -static herr_t H5FD_core_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); +static herr_t H5FD__core_flush(H5FD_t *_file, hid_t dxpl_id, unsigned closing); +static herr_t H5FD__core_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); static herr_t H5FD_core_lock(H5FD_t *_file, hbool_t rw); static herr_t H5FD_core_unlock(H5FD_t *_file); @@ -150,32 +149,32 @@ static const H5FD_class_t H5FD_core_g = { "core", /* name */ MAXADDR, /* maxaddr */ H5F_CLOSE_WEAK, /* fc_degree */ - H5FD_core_term, /* terminate */ + H5FD__core_term, /* terminate */ NULL, /* sb_size */ NULL, /* sb_encode */ NULL, /* sb_decode */ sizeof(H5FD_core_fapl_t), /* fapl_size */ - H5FD_core_fapl_get, /* fapl_get */ + H5FD__core_fapl_get, /* fapl_get */ NULL, /* fapl_copy */ NULL, /* fapl_free */ 0, /* dxpl_size */ NULL, /* dxpl_copy */ NULL, /* dxpl_free */ - H5FD_core_open, /* open */ - H5FD_core_close, /* close */ - H5FD_core_cmp, /* cmp */ - H5FD_core_query, /* query */ + H5FD__core_open, /* open */ + H5FD__core_close, /* close */ + H5FD__core_cmp, /* cmp */ + H5FD__core_query, /* query */ NULL, /* get_type_map */ NULL, /* alloc */ NULL, /* free */ - H5FD_core_get_eoa, /* get_eoa */ - H5FD_core_set_eoa, /* set_eoa */ - H5FD_core_get_eof, /* get_eof */ - H5FD_core_get_handle, /* get_handle */ - H5FD_core_read, /* read */ - H5FD_core_write, /* write */ - H5FD_core_flush, /* flush */ - H5FD_core_truncate, /* truncate */ + H5FD__core_get_eoa, /* get_eoa */ + H5FD__core_set_eoa, /* set_eoa */ + H5FD__core_get_eof, /* get_eof */ + H5FD__core_get_handle, /* get_handle */ + H5FD__core_read, /* read */ + H5FD__core_write, /* write */ + H5FD__core_flush, /* flush */ + H5FD__core_truncate, /* truncate */ H5FD_core_lock, /* lock */ H5FD_core_unlock, /* unlock */ H5FD_FLMAP_DICHOTOMY /* fl_map */ @@ -186,7 +185,7 @@ H5FL_DEFINE(H5FD_core_region_t); /*------------------------------------------------------------------------- - * Function: H5FD_core_add_dirty_region + * Function: H5FD__core_add_dirty_region * * Purpose: Add a new dirty region to the list for later flushing * to the backing store. @@ -196,7 +195,7 @@ H5FL_DEFINE(H5FD_core_region_t); *------------------------------------------------------------------------- */ static herr_t -H5FD_core_add_dirty_region(H5FD_core_t *file, haddr_t start, haddr_t end) +H5FD__core_add_dirty_region(H5FD_core_t *file, haddr_t start, haddr_t end) { H5FD_core_region_t *b_item = NULL; H5FD_core_region_t *a_item = NULL; @@ -209,7 +208,7 @@ H5FD_core_add_dirty_region(H5FD_core_t *file, haddr_t start, haddr_t end) hbool_t was_adjusted = FALSE; #endif - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC HDassert(file); HDassert(file->dirty_list); @@ -313,11 +312,11 @@ if(was_adjusted) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_core_add_dirty_region() */ +} /* end H5FD__core_add_dirty_region() */ /*------------------------------------------------------------------------- - * Function: H5FD_core_destroy_dirty_list + * Function: H5FD__core_destroy_dirty_list * * Purpose: Completely destroy the dirty list. * @@ -326,11 +325,11 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_core_destroy_dirty_list(H5FD_core_t *file) +H5FD__core_destroy_dirty_list(H5FD_core_t *file) { herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC HDassert(file); @@ -355,11 +354,11 @@ if(count != 0) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_core_destroy_dirty_list() */ +} /* end H5FD__core_destroy_dirty_list() */ /*------------------------------------------------------------------------- - * Function: H5FD_core_write_to_bstore + * Function: H5FD__core_write_to_bstore * * Purpose: Write data to the backing store. * @@ -367,7 +366,8 @@ done: * *------------------------------------------------------------------------- */ -static herr_t H5FD_core_write_to_bstore(H5FD_core_t *file, haddr_t addr, size_t size) +static herr_t +H5FD__core_write_to_bstore(H5FD_core_t *file, haddr_t addr, size_t size) { unsigned char *ptr = file->mem + addr; /* mutable pointer into the * buffer (can't change mem) @@ -423,12 +423,11 @@ fprintf(stderr, "bytes wrote: %lu\n", bytes_wrote); done: FUNC_LEAVE_NOAPI(ret_value) - -} /* end H5FD_core_write_to_bstore() */ +} /* end H5FD__core_write_to_bstore() */ /*------------------------------------------------------------------------- - * Function: H5FD_core_init_interface + * Function: H5FD__init_package * * Purpose: Initializes any interface-specific data or routines. * @@ -437,7 +436,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_core_init_interface(void) +H5FD__init_package(void) { herr_t ret_value = SUCCEED; @@ -448,7 +447,7 @@ H5FD_core_init_interface(void) done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5FD_core_init_interface() */ +} /* H5FD__init_package() */ /*------------------------------------------------------------------------- @@ -468,23 +467,23 @@ done: hid_t H5FD_core_init(void) { - hid_t ret_value = H5FD_CORE_g; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(FAIL) if(H5I_VFL != H5I_get_type(H5FD_CORE_g)) - H5FD_CORE_g = H5FD_register(&H5FD_core_g,sizeof(H5FD_class_t),FALSE); + H5FD_CORE_g = H5FD_register(&H5FD_core_g, sizeof(H5FD_class_t), FALSE); /* Set return value */ ret_value = H5FD_CORE_g; done: FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5FD_core_init() */ /*--------------------------------------------------------------------------- - * Function: H5FD_core_term + * Function: H5FD__core_term * * Purpose: Shut down the VFD * @@ -496,15 +495,15 @@ done: *--------------------------------------------------------------------------- */ static herr_t -H5FD_core_term(void) +H5FD__core_term(void) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Reset VFL ID */ H5FD_CORE_g = 0; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5FD_core_term() */ +} /* end H5FD__core_term() */ /*------------------------------------------------------------------------- @@ -542,7 +541,7 @@ H5Pset_fapl_core(hid_t fapl_id, size_t increment, hbool_t backing_store) done: FUNC_LEAVE_API(ret_value) -} +} /* end H5Pset_fapl_core() */ /*------------------------------------------------------------------------- @@ -581,16 +580,15 @@ H5Pget_fapl_core(hid_t fapl_id, size_t *increment /*out*/, hbool_t *backing_stor done: FUNC_LEAVE_API(ret_value) -} +} /* end H5Pget_fapl_core() */ /*------------------------------------------------------------------------- - * Function: H5FD_core_fapl_get + * Function: H5FD__core_fapl_get * * Purpose: Returns a copy of the file access properties. * * Return: Success: Ptr to new file access properties. - * * Failure: NULL * * Programmer: Robb Matzke @@ -599,13 +597,13 @@ done: *------------------------------------------------------------------------- */ static void * -H5FD_core_fapl_get(H5FD_t *_file) +H5FD__core_fapl_get(H5FD_t *_file) { H5FD_core_t *file = (H5FD_core_t*)_file; H5FD_core_fapl_t *fa; - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC if(NULL == (fa = (H5FD_core_fapl_t *)H5MM_calloc(sizeof(H5FD_core_fapl_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") @@ -618,18 +616,17 @@ H5FD_core_fapl_get(H5FD_t *_file) done: FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5FD__core_fapl_get() */ /*------------------------------------------------------------------------- - * Function: H5FD_core_open + * Function: H5FD___core_open * * Purpose: Create memory as an HDF5 file. * * Return: Success: A pointer to a new file data structure. The * public fields will be initialized by the * caller, which is always H5FD_open(). - * * Failure: NULL * * Programmer: Robb Matzke @@ -638,7 +635,7 @@ done: *------------------------------------------------------------------------- */ static H5FD_t * -H5FD_core_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) +H5FD__core_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { int o_flags; H5FD_core_t *file = NULL; @@ -650,9 +647,9 @@ H5FD_core_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) h5_stat_t sb; int fd = -1; H5FD_file_image_info_t file_image_info; - H5FD_t *ret_value; + H5FD_t *ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check arguments */ if(!name || !*name) @@ -867,11 +864,11 @@ done: } /* end if */ FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_core_open() */ +} /* end H5FD__core_open() */ /*------------------------------------------------------------------------- - * Function: H5FD_core_close + * Function: H5FD__core_close * * Purpose: Closes the file. * @@ -883,20 +880,20 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_core_close(H5FD_t *_file) +H5FD__core_close(H5FD_t *_file) { H5FD_core_t *file = (H5FD_core_t*)_file; herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Flush any changed buffers */ - if(H5FD_core_flush(_file, (hid_t)-1, TRUE) < 0) + if(H5FD__core_flush(_file, (hid_t)-1, TRUE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush core vfd backing store") /* Destroy the dirty region list */ if(file->dirty_list) - if(H5FD_core_destroy_dirty_list(file) != SUCCEED) + if(H5FD__core_destroy_dirty_list(file) != SUCCEED) HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, "unable to free core vfd dirty region list") /* Release resources */ @@ -918,11 +915,11 @@ H5FD_core_close(H5FD_t *_file) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_core_close() */ +} /* end H5FD__core_close() */ /*------------------------------------------------------------------------- - * Function: H5FD_core_cmp + * Function: H5FD__core_cmp * * Purpose: Compares two files belonging to this driver by name. If one * file doesn't have a name then it is less than the other file. @@ -930,7 +927,6 @@ done: * address. * * Return: Success: A value like strcmp() - * * Failure: never fails (arguments were checked by the * caller). * @@ -940,13 +936,13 @@ done: *------------------------------------------------------------------------- */ static int -H5FD_core_cmp(const H5FD_t *_f1, const H5FD_t *_f2) +H5FD__core_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { const H5FD_core_t *f1 = (const H5FD_core_t*)_f1; const H5FD_core_t *f2 = (const H5FD_core_t*)_f2; int ret_value = 0; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR if(f1->fd >= 0 && f2->fd >= 0) { /* Compare low level file information for backing store */ @@ -997,11 +993,11 @@ H5FD_core_cmp(const H5FD_t *_f1, const H5FD_t *_f2) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_core_cmp() */ +} /* end H5FD__core_cmp() */ /*------------------------------------------------------------------------- - * Function: H5FD_core_query + * Function: H5FD__core_query * * Purpose: Set the flags that this VFL driver is capable of supporting. * (listed in H5FDpublic.h) @@ -1014,11 +1010,11 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_core_query(const H5FD_t * _file, unsigned long *flags /* out */) +H5FD__core_query(const H5FD_t * _file, unsigned long *flags /* out */) { const H5FD_core_t *file = (const H5FD_core_t*)_file; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Set the VFL feature flags that this driver supports */ if(flags) { @@ -1036,11 +1032,11 @@ H5FD_core_query(const H5FD_t * _file, unsigned long *flags /* out */) } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5FD_core_query() */ +} /* end H5FD__core_query() */ /*------------------------------------------------------------------------- - * Function: H5FD_core_get_eoa + * Function: H5FD__core_get_eoa * * Purpose: Gets the end-of-address marker for the file. The EOA marker * is the first address past the last byte allocated in the @@ -1054,18 +1050,18 @@ H5FD_core_query(const H5FD_t * _file, unsigned long *flags /* out */) *------------------------------------------------------------------------- */ static haddr_t -H5FD_core_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) +H5FD__core_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { const H5FD_core_t *file = (const H5FD_core_t*)_file; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR FUNC_LEAVE_NOAPI(file->eoa) -} +} /* end H5FD__core_get_eoa() */ /*------------------------------------------------------------------------- - * Function: H5FD_core_set_eoa + * Function: H5FD__core_set_eoa * * Purpose: Set the end-of-address marker for the file. This function is * called shortly after an existing HDF5 file is opened in order @@ -1079,12 +1075,12 @@ H5FD_core_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) *------------------------------------------------------------------------- */ static herr_t -H5FD_core_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) +H5FD__core_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) { H5FD_core_t *file = (H5FD_core_t*)_file; herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC if(ADDR_OVERFLOW(addr)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "address overflow") @@ -1093,11 +1089,11 @@ H5FD_core_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_core_set_eoa() */ +} /* end H5FD__core_set_eoa() */ /*------------------------------------------------------------------------- - * Function: H5FD_core_get_eof + * Function: H5FD__core_get_eof * * Purpose: Returns the end-of-file marker, which is the greater of * either the size of the underlying memory or the HDF5 @@ -1113,18 +1109,18 @@ done: *------------------------------------------------------------------------- */ static haddr_t -H5FD_core_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) +H5FD__core_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { const H5FD_core_t *file = (const H5FD_core_t*)_file; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR FUNC_LEAVE_NOAPI(file->eof) -} +} /* end H5FD__core_get_eof() */ /*------------------------------------------------------------------------- - * Function: H5FD_core_get_handle + * Function: H5FD__core_get_handle * * Purpose: Gets the file handle of CORE file driver. * @@ -1136,12 +1132,12 @@ H5FD_core_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) *------------------------------------------------------------------------- */ static herr_t -H5FD_core_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle) +H5FD__core_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle) { H5FD_core_t *file = (H5FD_core_t *)_file; /* core VFD info */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check args */ if(!file_handle) @@ -1180,11 +1176,11 @@ H5FD_core_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_core_get_handle() */ +} /* end H5FD__core_get_handle() */ /*------------------------------------------------------------------------- - * Function: H5FD_core_read + * Function: H5FD__core_read * * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR * into buffer BUF according to data transfer properties in @@ -1192,7 +1188,6 @@ done: * * Return: Success: SUCCEED. Result is stored in caller-supplied * buffer BUF. - * * Failure: FAIL, Contents of buffer BUF are undefined. * * Programmer: Robb Matzke @@ -1201,13 +1196,13 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_core_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, +H5FD__core_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, size_t size, void *buf/*out*/) { H5FD_core_t *file = (H5FD_core_t*)_file; - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC HDassert(file && file->pub.cls); HDassert(buf); @@ -1243,11 +1238,11 @@ H5FD_core_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUS done: FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5FD__core_read() */ /*------------------------------------------------------------------------- - * Function: H5FD_core_write + * Function: H5FD__core_write * * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR * from buffer BUF according to data transfer properties in @@ -1261,13 +1256,13 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_core_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, +H5FD__core_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, size_t size, const void *buf) { H5FD_core_t *file = (H5FD_core_t*)_file; herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC HDassert(file && file->pub.cls); HDassert(buf); @@ -1313,7 +1308,8 @@ H5FD_core_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU if(file->dirty_list) { haddr_t start = addr; haddr_t end = addr + (haddr_t)size - 1; - if(H5FD_core_add_dirty_region(file, start, end) != SUCCEED) + + if(H5FD__core_add_dirty_region(file, start, end) != SUCCEED) HGOTO_ERROR(H5E_VFL, H5E_CANTINSERT, FAIL, "unable to add core VFD dirty region during write call - addresses: start=%llu end=%llu", start, end) } @@ -1325,11 +1321,11 @@ H5FD_core_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_core_write() */ +} /* end H5FD__core_write() */ /*------------------------------------------------------------------------- - * Function: H5FD_core_flush + * Function: H5FD__core_flush * * Purpose: Flushes the file to backing store if there is any and if the * dirty flag is set. @@ -1342,12 +1338,12 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_core_flush(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, unsigned H5_ATTR_UNUSED closing) +H5FD__core_flush(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, unsigned H5_ATTR_UNUSED closing) { H5FD_core_t *file = (H5FD_core_t*)_file; herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Write to backing store */ if (file->dirty && file->fd >= 0 && file->backing_store) { @@ -1374,7 +1370,7 @@ H5FD_core_flush(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, unsigned H5_ATTR_UN #ifdef DER fprintf(stderr, "(%llu, %llu : %lu)\n", item->start, item->end, size); #endif - if(H5FD_core_write_to_bstore(file, item->start, size) != SUCCEED) + if(H5FD__core_write_to_bstore(file, item->start, size) != SUCCEED) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "unable to write to backing store") } /* end if */ @@ -1388,24 +1384,23 @@ if(file->eoa > file->eof) fprintf(stderr, "*** EOA BADNESS ***\n"); fprintf(stderr, "\n"); #endif - } + } /* end if */ /* Otherwise, write the entire file out at once */ else { - if(H5FD_core_write_to_bstore(file, (haddr_t)0, (size_t)file->eof) != SUCCEED) + if(H5FD__core_write_to_bstore(file, (haddr_t)0, (size_t)file->eof) != SUCCEED) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "unable to write to backing store") - - } /* end while */ + } /* end else */ file->dirty = FALSE; } done: FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5FD__core_flush() */ /*------------------------------------------------------------------------- - * Function: H5FD_core_truncate + * Function: H5FD__core_truncate * * Purpose: Makes sure that the true file size is the same (or larger) * than the end-of-address. @@ -1440,13 +1435,13 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_core_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t closing) +H5FD__core_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t closing) { H5FD_core_t *file = (H5FD_core_t*)_file; size_t new_eof; /* New size of memory buffer */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC HDassert(file); @@ -1526,7 +1521,7 @@ fprintf(stderr, "OLD: Truncated to: %llu\n", file->eoa); done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_core_truncate() */ +} /* end H5FD__core_truncate() */ /*------------------------------------------------------------------------- diff --git a/src/H5FDdirect.c b/src/H5FDdirect.c index 642ce4c..27088a4 100644 --- a/src/H5FDdirect.c +++ b/src/H5FDdirect.c @@ -22,12 +22,8 @@ * buffer. The main system support this feature is Linux. */ -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5FD_direct_init_interface +#include "H5FDdrvr_module.h" /* This source code file is part of the H5FD driver module */ -/* For system function posix_memalign - Commented it out because copper isn't able to compile - * this file. */ -/* #define _XOPEN_SOURCE 600 */ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ @@ -186,10 +182,9 @@ H5FL_DEFINE_STATIC(H5FD_direct_t); /*-------------------------------------------------------------------------- NAME - H5FD_direct_init_interface -- Initialize interface-specific information + H5FD__init_package -- Initialize interface-specific information USAGE - herr_t H5FD_direct_init_interface() - + herr_t H5FD__init_package() RETURNS Non-negative on success/Negative on failure DESCRIPTION @@ -198,18 +193,18 @@ DESCRIPTION --------------------------------------------------------------------------*/ static herr_t -H5FD_direct_init_interface(void) +H5FD__init_package(void) { herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC if(H5FD_direct_init() < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize direct VFD") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5FD_direct_init_interface() */ +} /* H5FD__init_package() */ /*------------------------------------------------------------------------- @@ -240,7 +235,7 @@ H5FD_direct_init(void) H5FD_DIRECT_g = H5FD_register(&H5FD_direct_g,sizeof(H5FD_class_t),FALSE); /* Set return value */ - ret_value=H5FD_DIRECT_g; + ret_value = H5FD_DIRECT_g; done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5FDdrvr_module.h b/src/H5FDdrvr_module.h new file mode 100644 index 0000000..8bb83a1 --- /dev/null +++ b/src/H5FDdrvr_module.h @@ -0,0 +1,35 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Quincey Koziol <koziol@hdfgroup.org> + * Saturday, September 12, 2015 + * + * Purpose: This file contains declarations which define macros for the + * H5FD driver package. Including this header means that the source file + * is part of the H5FD driver package. + */ +#ifndef _H5FDdrvr_module_H +#define _H5FDdrvr_module_H + +/* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error + * reporting macros. + */ +#define H5_MY_PKG H5FD +#define H5_MY_PKG_ERR H5E_FILE +#define H5_MY_PKG_INIT YES +#define H5_PKG_SINGLE_SOURCE + +#endif /* _H5FDdrvr_module_H */ + diff --git a/src/H5FDfamily.c b/src/H5FDfamily.c index 8886e2c..310b72f 100644 --- a/src/H5FDfamily.c +++ b/src/H5FDfamily.c @@ -34,8 +34,7 @@ * */ -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5FD_family_init_interface +#include "H5FDdrvr_module.h" /* This source code file is part of the H5FD driver module */ #include "H5private.h" /* Generic Functions */ @@ -149,10 +148,9 @@ static const H5FD_class_t H5FD_family_g = { /*-------------------------------------------------------------------------- NAME - H5FD_family_init_interface -- Initialize interface-specific information + H5FD__init_package -- Initialize interface-specific information USAGE - herr_t H5FD_family_init_interface() - + herr_t H5FD__init_package() RETURNS Non-negative on success/Negative on failure DESCRIPTION @@ -161,18 +159,18 @@ DESCRIPTION --------------------------------------------------------------------------*/ static herr_t -H5FD_family_init_interface(void) +H5FD__init_package(void) { herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT + 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_family_init_interface() */ +} /* H5FD__init_package() */ /*------------------------------------------------------------------------- @@ -365,7 +363,7 @@ H5FD_family_fapl_get(H5FD_t *_file) H5FD_family_t *file = (H5FD_family_t*)_file; H5FD_family_fapl_t *fa = NULL; H5P_genplist_t *plist; /* Property list pointer */ - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -411,7 +409,7 @@ H5FD_family_fapl_copy(const void *_old_fa) const H5FD_family_fapl_t *old_fa = (const H5FD_family_fapl_t*)_old_fa; H5FD_family_fapl_t *new_fa = NULL; H5P_genplist_t *plist; /* Property list pointer */ - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1024,7 +1022,7 @@ H5FD_family_get_eof(const H5FD_t *_file, H5FD_mem_t type) const H5FD_family_t *file = (const H5FD_family_t*)_file; haddr_t eof=0; int i; /* Local index variable */ - haddr_t ret_value; /* Return value */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1078,7 +1076,7 @@ H5FD_family_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle) H5P_genplist_t *plist; hsize_t offset; int memb; - herr_t ret_value; + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT diff --git a/src/H5FDint.c b/src/H5FDint.c index ca4e0ff..933752c 100644 --- a/src/H5FDint.c +++ b/src/H5FDint.c @@ -28,10 +28,7 @@ /* Module Setup */ /****************/ -#define H5FD_PACKAGE /*suppress error about including H5FDpkg */ - -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5FD_int_init_interface +#include "H5FDmodule.h" /* This source code file is part of the H5FD module */ /***********/ @@ -80,28 +77,6 @@ -/*-------------------------------------------------------------------------- -NAME - H5FD_int_init_interface -- Initialize interface-specific information -USAGE - herr_t H5FD_int_init_interface() - -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. (Just calls - H5FD_init_iterface currently). - ---------------------------------------------------------------------------*/ -static herr_t -H5FD_int_init_interface(void) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - FUNC_LEAVE_NOAPI(H5FD_init()) -} /* H5FD_int_init_interface() */ - - /*------------------------------------------------------------------------- * Function: H5FD_locate_signature * @@ -333,7 +308,7 @@ done: haddr_t H5FD_get_eoa(const H5FD_t *file, H5FD_mem_t type) { - haddr_t ret_value; + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI(HADDR_UNDEF) @@ -375,7 +350,7 @@ done: haddr_t H5FD_get_eof(const H5FD_t *file, H5FD_mem_t type) { - haddr_t ret_value; + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI(HADDR_UNDEF) diff --git a/src/H5FDlog.c b/src/H5FDlog.c index 7e1342a..1273dba 100644 --- a/src/H5FDlog.c +++ b/src/H5FDlog.c @@ -26,8 +26,7 @@ * With custom modifications... */ -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5FD_log_init_interface +#include "H5FDdrvr_module.h" /* This source code file is part of the H5FD driver module */ #include "H5private.h" /* Generic Functions */ @@ -223,7 +222,7 @@ H5FL_DEFINE_STATIC(H5FD_log_t); /*------------------------------------------------------------------------- - * Function: H5FD_log_init_interface + * Function: H5FD__init_package * * Purpose: Initializes any interface-specific data or routines. * @@ -232,18 +231,18 @@ H5FL_DEFINE_STATIC(H5FD_log_t); *------------------------------------------------------------------------- */ static herr_t -H5FD_log_init_interface(void) +H5FD__init_package(void) { herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC if(H5FD_log_init() < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize log VFD") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5FD_log_init_interface() */ +} /* H5FD__init_package() */ /*------------------------------------------------------------------------- @@ -263,7 +262,7 @@ done: hid_t H5FD_log_init(void) { - hid_t ret_value; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -363,7 +362,7 @@ static void * H5FD_log_fapl_get(H5FD_t *_file) { H5FD_log_t *file = (H5FD_log_t *)_file; - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -392,7 +391,7 @@ H5FD_log_fapl_copy(const void *_old_fa) { const H5FD_log_fapl_t *old_fa = (const H5FD_log_fapl_t*)_old_fa; H5FD_log_fapl_t *new_fa = NULL; /* New FAPL info */ - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -485,7 +484,7 @@ H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) struct timeval stat_timeval_diff; #endif /* H5_HAVE_GETTIMEOFDAY */ h5_stat_t sb; - H5FD_t *ret_value; /* Return value */ + H5FD_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -925,7 +924,7 @@ H5FD_log_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, hsi { H5FD_log_t *file = (H5FD_log_t *)_file; haddr_t addr; - haddr_t ret_value; /* Return value */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR diff --git a/src/H5FDmodule.h b/src/H5FDmodule.h new file mode 100644 index 0000000..6358e86 --- /dev/null +++ b/src/H5FDmodule.h @@ -0,0 +1,35 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Quincey Koziol <koziol@hdfgroup.org> + * Saturday, September 12, 2015 + * + * Purpose: This file contains declarations which define macros for the + * H5FD package. Including this header means that the source file + * is part of the H5FD package. + */ +#ifndef _H5FDmodule_H +#define _H5FDmodule_H + +/* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error + * reporting macros. + */ +#define H5FD_MODULE +#define H5_MY_PKG H5FD +#define H5_MY_PKG_ERR H5E_VFL +#define H5_MY_PKG_INIT YES + +#endif /* _H5FDmodule_H */ + diff --git a/src/H5FDmpio.c b/src/H5FDmpio.c index eb8e70f..b3ef1f2 100644 --- a/src/H5FDmpio.c +++ b/src/H5FDmpio.c @@ -21,8 +21,7 @@ * */ -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5FD_mpio_init_interface +#include "H5FDdrvr_module.h" /* This source code file is part of the H5FD driver module */ #include "H5private.h" /* Generic Functions */ @@ -167,10 +166,9 @@ static int H5FD_mpio_Debug[256] = /*-------------------------------------------------------------------------- NAME - H5FD_mpio_init_interface -- Initialize interface-specific information + H5FD__init_package -- Initialize interface-specific information USAGE - herr_t H5FD_mpio_init_interface() - + herr_t H5FD__init_package() RETURNS Non-negative on success/Negative on failure DESCRIPTION @@ -179,18 +177,18 @@ DESCRIPTION --------------------------------------------------------------------------*/ static herr_t -H5FD_mpio_init_interface(void) +H5FD__init_package(void) { herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT + 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_mpio_init_interface() */ +} /* H5FD__init_package() */ /*------------------------------------------------------------------------- diff --git a/src/H5FDpkg.h b/src/H5FDpkg.h index d7f240e..45bcfd8 100644 --- a/src/H5FDpkg.h +++ b/src/H5FDpkg.h @@ -21,7 +21,7 @@ * the H5FD package. Source files outside the H5FD package should * include H5FDprivate.h instead. */ -#ifndef H5FD_PACKAGE +#if !(defined H5FD_FRIEND || defined H5FD_MODULE) #error "Do not include this file outside the H5FD package!" #endif @@ -52,7 +52,6 @@ /******************************/ /* Package Private Prototypes */ /******************************/ -H5_DLL herr_t H5FD_init(void); H5_DLL haddr_t H5FD_alloc_real(H5FD_t *file, hid_t dxpl_id, H5FD_mem_t type, hsize_t size, haddr_t *align_addr, hsize_t *align_size); H5_DLL herr_t H5FD_free_real(H5FD_t *file, hid_t dxpl_id, H5FD_mem_t type, diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c index ba03c65..149715e 100644 --- a/src/H5FDsec2.c +++ b/src/H5FDsec2.c @@ -25,8 +25,7 @@ * application to the same file). */ -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5FD_sec2_init_interface +#include "H5FDdrvr_module.h" /* This source code file is part of the H5FD driver module */ #include "H5private.h" /* Generic Functions */ @@ -182,7 +181,7 @@ H5FL_DEFINE_STATIC(H5FD_sec2_t); /*------------------------------------------------------------------------- - * Function: H5FD_sec2_init_interface + * Function: H5FD__init_package * * Purpose: Initializes any interface-specific data or routines. * @@ -191,18 +190,18 @@ H5FL_DEFINE_STATIC(H5FD_sec2_t); *------------------------------------------------------------------------- */ static herr_t -H5FD_sec2_init_interface(void) +H5FD__init_package(void) { herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC if(H5FD_sec2_init() < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize sec2 VFD") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5FD_sec2_init_interface() */ +} /* H5FD__init_package() */ /*------------------------------------------------------------------------- @@ -222,7 +221,7 @@ done: hid_t H5FD_sec2_init(void) { - hid_t ret_value; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -319,7 +318,7 @@ H5FD_sec2_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) struct _BY_HANDLE_FILE_INFORMATION fileinfo; #endif h5_stat_t sb; - H5FD_t *ret_value; /* Return value */ + H5FD_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT diff --git a/src/H5FDspace.c b/src/H5FDspace.c index deb2153..edc83e6 100644 --- a/src/H5FDspace.c +++ b/src/H5FDspace.c @@ -28,10 +28,7 @@ /* Module Setup */ /****************/ -#define H5FD_PACKAGE /*suppress error about including H5FDpkg */ - -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5FD_space_init_interface +#include "H5FDmodule.h" /* This source code file is part of the H5FD module */ /***********/ @@ -86,28 +83,6 @@ H5FL_DEFINE(H5FD_free_t); -/*-------------------------------------------------------------------------- -NAME - H5FD_space_init_interface -- Initialize interface-specific information -USAGE - herr_t H5FD_space_init_interface() - -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. (Just calls - H5FD_init_iterface currently). - ---------------------------------------------------------------------------*/ -static herr_t -H5FD_space_init_interface(void) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - FUNC_LEAVE_NOAPI(H5FD_init()) -} /* H5FD_space_init_interface() */ - - /*------------------------------------------------------------------------- * Function: H5FD_extend * @@ -129,7 +104,7 @@ H5FD_extend(H5FD_t *file, H5FD_mem_t type, hbool_t new_block, hsize_t size, hadd hsize_t orig_size = size; /* Original allocation size */ haddr_t eoa; /* Address of end-of-allocated space */ hsize_t extra; /* Extra space to allocate, to align request */ - haddr_t ret_value; /* Return value */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -197,7 +172,7 @@ done: haddr_t H5FD_alloc_real(H5FD_t *file, hid_t dxpl_id, H5FD_mem_t type, hsize_t size, haddr_t *frag_addr, hsize_t *frag_size) { - haddr_t ret_value; /* Return value */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI(HADDR_UNDEF) #ifdef H5FD_ALLOC_DEBUG @@ -253,7 +228,7 @@ haddr_t H5FD_alloc(H5FD_t *file, hid_t dxpl_id, H5FD_mem_t type, H5F_t *f, hsize_t size, haddr_t *frag_addr, hsize_t *frag_size) { - haddr_t ret_value; /* Return value */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI(HADDR_UNDEF) diff --git a/src/H5FDtest.c b/src/H5FDtest.c index 8646958..9d2f2e9 100644 --- a/src/H5FDtest.c +++ b/src/H5FDtest.c @@ -27,7 +27,7 @@ /* Module Setup */ /****************/ -#define H5FD_PACKAGE /* Suppress error about including H5FDpkg */ +#include "H5FDmodule.h" /* This source code file is part of the H5FD module */ #define H5FD_TESTING /* Suppress warning about H5FD testing funcs */ @@ -27,8 +27,7 @@ * move frequently accessed free lists to the head of the queue. */ -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5FL_init_interface +#include "H5FLmodule.h" /* This source code file is part of the H5FL module */ /* #define H5FL_DEBUG */ @@ -117,6 +116,9 @@ 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}; @@ -130,14 +132,18 @@ static H5FL_track_t *H5FL_out_head_g = NULL; #endif /* H5FL_TRACK */ /* Forward declarations of local static functions */ -static herr_t H5FL_reg_gc(void); -static herr_t H5FL_reg_gc_list(H5FL_reg_head_t *head); -static herr_t H5FL_arr_gc(void); -static herr_t H5FL_arr_gc_list(H5FL_arr_head_t *head); -static herr_t H5FL_blk_gc(void); -static herr_t H5FL_blk_gc_list(H5FL_blk_head_t *head); -static herr_t H5FL_fac_gc(void); -static herr_t H5FL_fac_gc_list(H5FL_fac_head_t *head); +static herr_t H5FL__reg_gc(void); +static herr_t H5FL__reg_gc_list(H5FL_reg_head_t *head); +static int H5FL__reg_term(void); +static herr_t H5FL__arr_gc(void); +static herr_t H5FL__arr_gc_list(H5FL_arr_head_t *head); +static int H5FL__arr_term(void); +static herr_t H5FL__blk_gc(void); +static herr_t H5FL__blk_gc_list(H5FL_blk_head_t *head); +static int H5FL__blk_term(void); +static herr_t H5FL__fac_gc(void); +static herr_t H5FL__fac_gc_list(H5FL_fac_head_t *head); +static int H5FL__fac_term_all(void); /* Declare a free list to manage the H5FL_blk_node_t struct */ H5FL_DEFINE(H5FL_blk_node_t); @@ -150,26 +156,66 @@ H5FL_DEFINE(H5FL_fac_head_t); /*-------------------------------------------------------------------------- -NAME - H5FL_init_interface -- Initialize interface-specific information -USAGE - herr_t H5FL_init_interface() - -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. - + NAME + H5FL_term_package + PURPOSE + Terminate various H5FL objects + USAGE + void H5FL_term_package() + RETURNS + Success: Positive if any action might have caused a change in some + other interface; zero otherwise. + Failure: Negative + DESCRIPTION + Release any resources allocated. + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + Can't report errors... + EXAMPLES + REVISION LOG --------------------------------------------------------------------------*/ -static herr_t -H5FL_init_interface(void) +int +H5FL_term_package(void) { + int n = 0; + FUNC_ENTER_NOAPI_NOINIT_NOERR - /* Nothing currently... */ + if(H5_PKG_INIT_VAR) { + /* Garbage collect any nodes on the free lists */ + (void)H5FL_garbage_coll(); - FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5FL_init_interface() */ + /* 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 */ + +#ifdef H5FL_TRACK + /* If we haven't freed all the allocated memory, dump out the list now */ + if(n > 0 && H5FL_out_head_g) { + H5FL_track_t *trk = H5FL_out_head_g; + + /* Dump information about all the outstanding allocations */ + while(trk != NULL) { + /* Print information about the outstanding block */ + HDfprintf(stderr,"%s: Outstanding allocation:\n", "H5FL_term_package"); + HDfprintf(stderr,"\tFile: %s, Function: %s, Line: %d\n", trk->file, trk->func, trk->line); + H5CS_print_stack(trk->stack, stderr); + + /* Advance to next node */ + trk = trk->next; + } /* end while */ + } /* end if */ +#endif /* H5FL_TRACK */ + + FUNC_LEAVE_NOAPI(n) +} /* end H5FL_term_package() */ /*------------------------------------------------------------------------- @@ -191,7 +237,7 @@ H5FL_init_interface(void) static void * H5FL_malloc(size_t mem_size) { - void *ret_value; /* return value*/ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -296,7 +342,6 @@ H5FL_reg_free(H5FL_reg_head_t *head, void *obj) /* Free tracking information about the allocation location */ H5CS_close_stack(trk->stack); - trk->stack = H5MM_xfree(trk->stack); trk->file = H5MM_xfree(trk->file); trk->func = H5MM_xfree(trk->func); @@ -336,12 +381,12 @@ H5FL_reg_free(H5FL_reg_head_t *head, void *obj) /* Check for exceeding free list memory use limits */ /* First check this particular list */ if(head->onlist * head->size > H5FL_reg_lst_mem_lim) - if(H5FL_reg_gc_list(head)<0) + if(H5FL__reg_gc_list(head) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, NULL, "garbage collection failed during free") /* Then check the global amount memory on regular free lists */ if(H5FL_reg_gc_head.mem_freed>H5FL_reg_glb_mem_lim) - if(H5FL_reg_gc()<0) + if(H5FL__reg_gc() < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, NULL, "garbage collection failed during free") done: @@ -367,7 +412,7 @@ done: void * H5FL_reg_malloc(H5FL_reg_head_t *head H5FL_TRACK_PARAMS) { - void *ret_value; /* Pointer to object to return */ + void *ret_value = NULL; /* Pointer to object to return */ FUNC_ENTER_NOAPI(NULL) @@ -404,8 +449,8 @@ H5FL_reg_malloc(H5FL_reg_head_t *head H5FL_TRACK_PARAMS) #ifdef H5FL_TRACK /* Copy allocation location information */ - ((H5FL_track_t *)ret_value)->stack = H5MM_calloc(sizeof(H5CS_t)); - H5CS_copy_stack(((H5FL_track_t *)ret_value)->stack); + ((H5FL_track_t *)ret_value)->stack = H5CS_copy_stack(); + HDassert(((H5FL_track_t *)ret_value)->stack); ((H5FL_track_t *)ret_value)->file = H5MM_strdup(call_file); ((H5FL_track_t *)ret_value)->func = H5MM_strdup(call_func); ((H5FL_track_t *)ret_value)->line = call_line; @@ -444,7 +489,7 @@ done: void * H5FL_reg_calloc(H5FL_reg_head_t *head H5FL_TRACK_PARAMS) { - void *ret_value; /* Pointer to object to return */ + void *ret_value = NULL; /* Pointer to object to return */ FUNC_ENTER_NOAPI(NULL) @@ -465,7 +510,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5FL_reg_gc_list + * Function: H5FL__reg_gc_list * * Purpose: Garbage collect on a particular object free list * @@ -475,26 +520,25 @@ done: * Programmer: Quincey Koziol * Tuesday, July 25, 2000 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t -H5FL_reg_gc_list(H5FL_reg_head_t *head) +H5FL__reg_gc_list(H5FL_reg_head_t *head) { H5FL_reg_node_t *free_list; /* Pointer to nodes in free list being garbage collected */ - void *tmp; /* Temporary node pointer */ size_t total_mem; /* Total memory used on list */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Calculate the total memory used on this list */ - total_mem=head->onlist*head->size; + total_mem = head->onlist * head->size; /* For each free list being garbage collected, walk through the nodes and free them */ - free_list=head->list; - while(free_list!=NULL) { - tmp=free_list->next; + free_list = head->list; + while(free_list != NULL) { + void *tmp; /* Temporary node pointer */ + + tmp = free_list->next; /* Decrement the count of nodes allocated and free the node */ head->allocated--; @@ -505,18 +549,18 @@ H5FL_reg_gc_list(H5FL_reg_head_t *head) } /* end while */ /* Indicate no free nodes on the free list */ - head->list=NULL; - head->onlist=0; + head->list = NULL; + head->onlist = 0; /* Decrement global count of free memory on "regular" lists */ - H5FL_reg_gc_head.mem_freed-=total_mem; + H5FL_reg_gc_head.mem_freed -= total_mem; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5FL_reg_gc_list() */ +} /* end H5FL__reg_gc_list() */ /*------------------------------------------------------------------------- - * Function: H5FL_reg_gc + * Function: H5FL__reg_gc * * Purpose: Garbage collect on all the object free lists * @@ -533,30 +577,30 @@ H5FL_reg_gc_list(H5FL_reg_head_t *head) *------------------------------------------------------------------------- */ static herr_t -H5FL_reg_gc(void) +H5FL__reg_gc(void) { H5FL_reg_gc_node_t *gc_node; /* Pointer into the list of things to garbage collect */ - herr_t ret_value=SUCCEED; /* return value*/ + herr_t ret_value = SUCCEED; /* return value*/ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Walk through all the free lists, free()'ing the nodes */ - gc_node=H5FL_reg_gc_head.first; - while(gc_node!=NULL) { + gc_node = H5FL_reg_gc_head.first; + while(gc_node != NULL) { /* Release the free nodes on the list */ - if(H5FL_reg_gc_list(gc_node->list)<0) + if(H5FL__reg_gc_list(gc_node->list) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "garbage collection of list failed") /* Go on to the next free list to garbage collect */ - gc_node=gc_node->next; + gc_node = gc_node->next; } /* end while */ /* Double check that all the memory on the free lists is recycled */ - HDassert(H5FL_reg_gc_head.mem_freed==0); + HDassert(H5FL_reg_gc_head.mem_freed == 0); done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL_reg_gc() */ +} /* end H5FL__reg_gc() */ /*-------------------------------------------------------------------------- @@ -565,7 +609,7 @@ done: PURPOSE Terminate various H5FL object free lists USAGE - int H5FL_term() + int H5FL_reg_term() RETURNS Success: Positive if any action might have caused a change in some other interface; zero otherwise. @@ -585,50 +629,46 @@ done: again to reclaim this layer's memory. --------------------------------------------------------------------------*/ static int -H5FL_reg_term(void) +H5FL__reg_term(void) { H5FL_reg_gc_node_t *left; /* pointer to garbage collection lists with work left */ - H5FL_reg_gc_node_t *tmp; /* Temporary pointer to a garbage collection node */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR + + /* Free the nodes on the garbage collection list, keeping nodes with allocations outstanding */ + left = NULL; + while(H5FL_reg_gc_head.first != NULL) { + H5FL_reg_gc_node_t *tmp; /* Temporary pointer to a garbage collection node */ - if (H5_interface_initialize_g) { - /* Free the nodes on the garbage collection list, keeping nodes with allocations outstanding */ - left=NULL; - while(H5FL_reg_gc_head.first!=NULL) { - tmp=H5FL_reg_gc_head.first->next; + /* Get a copy of the next node */ + tmp = H5FL_reg_gc_head.first->next; #ifdef H5FL_DEBUG - printf("H5FL_reg_term: head->name=%s, head->allocated=%d\n", H5FL_reg_gc_head.first->list->name,(int)H5FL_reg_gc_head.first->list->allocated); +printf("%s: head->name = %s, head->allocated = %d\n", FUNC, H5FL_reg_gc_head.first->list->name, (int)H5FL_reg_gc_head.first->list->allocated); #endif /* H5FL_DEBUG */ - /* Check if the list has allocations outstanding */ - if(H5FL_reg_gc_head.first->list->allocated>0) { - /* Add free list to the list of nodes with allocations open still */ - H5FL_reg_gc_head.first->next=left; - left=H5FL_reg_gc_head.first; - } /* end if */ - /* No allocations left open for list, get rid of it */ - else { - /* Reset the "initialized" flag, in case we restart this list somehow (I don't know how..) */ - H5FL_reg_gc_head.first->list->init=0; + /* Check if the list has allocations outstanding */ + if(H5FL_reg_gc_head.first->list->allocated > 0) { + /* Add free list to the list of nodes with allocations open still */ + H5FL_reg_gc_head.first->next = left; + left = H5FL_reg_gc_head.first; + } /* end if */ + /* No allocations left open for list, get rid of it */ + else { + /* Reset the "initialized" flag, in case we restart this list somehow (I don't know how..) */ + H5FL_reg_gc_head.first->list->init = 0; - /* Free the node from the garbage collection list */ - H5MM_xfree(H5FL_reg_gc_head.first); - } /* end else */ + /* Free the node from the garbage collection list */ + H5MM_xfree(H5FL_reg_gc_head.first); + } /* end else */ - H5FL_reg_gc_head.first=tmp; - } /* end while */ + H5FL_reg_gc_head.first = tmp; + } /* end while */ - /* Point to the list of nodes left with allocations open, if any */ - H5FL_reg_gc_head.first=left; - if (!left) - H5_interface_initialize_g = 0; /*this layer has reached its initial state*/ - } + /* Point to the list of nodes left with allocations open, if any */ + H5FL_reg_gc_head.first = left; - /* Terminating this layer never affects other layers; rather, other layers affect - * the termination of this layer. */ - FUNC_LEAVE_NOAPI(0) -} /* end H5FL_reg_term() */ + FUNC_LEAVE_NOAPI(H5FL_reg_gc_head.first != NULL ? 1 : 0) +} /* end H5FL__reg_term() */ /*------------------------------------------------------------------------- @@ -653,7 +693,7 @@ H5FL_reg_term(void) static H5FL_blk_node_t * H5FL_blk_find_list(H5FL_blk_node_t **head, size_t size) { - H5FL_blk_node_t *temp; /* Temp. pointer to node in the native list */ + H5FL_blk_node_t *temp = NULL; /* Temp. pointer to node in the native list */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -715,7 +755,7 @@ static H5FL_blk_node_t * H5FL_blk_create_list(H5FL_blk_node_t **head, size_t size) { H5FL_blk_node_t *temp; /* Temp. pointer to node in the list */ - H5FL_blk_node_t *ret_value; + H5FL_blk_node_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -808,21 +848,20 @@ done: htri_t H5FL_blk_free_block_avail(H5FL_blk_head_t *head, size_t size) { - H5FL_blk_node_t *free_list; /* The free list of nodes of correct size */ - htri_t ret_value; /* Return value */ + H5FL_blk_node_t *free_list; /* The free list of nodes of correct size */ + htri_t ret_value = FAIL; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR /* Double check parameters */ HDassert(head); /* check if there is a free list for blocks of this size */ /* and if there are any blocks available on the list */ - if((free_list=H5FL_blk_find_list(&(head->head),size))!=NULL && free_list->list!=NULL) - ret_value=TRUE; + if((free_list = H5FL_blk_find_list(&(head->head), size)) != NULL && free_list->list != NULL) + ret_value = TRUE; else - ret_value=FALSE; -done: + ret_value = FALSE; FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL_blk_free_block_avail() */ @@ -848,9 +887,9 @@ done: void * H5FL_blk_malloc(H5FL_blk_head_t *head, size_t size H5FL_TRACK_PARAMS) { - H5FL_blk_node_t *free_list; /* The free list of nodes of correct size */ - H5FL_blk_list_t *temp; /* Temp. ptr to the new native list allocated */ - void *ret_value; /* Pointer to the block to return to the user */ + H5FL_blk_node_t *free_list; /* The free list of nodes of correct size */ + H5FL_blk_list_t *temp; /* Temp. ptr to the new native list allocated */ + void *ret_value = NULL; /* Pointer to the block to return to the user */ FUNC_ENTER_NOAPI(NULL) @@ -896,8 +935,8 @@ H5FL_blk_malloc(H5FL_blk_head_t *head, size_t size H5FL_TRACK_PARAMS) #ifdef H5FL_TRACK /* Copy allocation location information */ - ((H5FL_track_t *)ret_value)->stack = H5MM_calloc(sizeof(H5CS_t)); - H5CS_copy_stack(((H5FL_track_t *)ret_value)->stack); + ((H5FL_track_t *)ret_value)->stack = H5CS_copy_stack(); + HDassert(((H5FL_track_t *)ret_value)->stack); ((H5FL_track_t *)ret_value)->file = H5MM_strdup(call_file); ((H5FL_track_t *)ret_value)->func = H5MM_strdup(call_func); ((H5FL_track_t *)ret_value)->line = call_line; @@ -940,7 +979,7 @@ done: void * H5FL_blk_calloc(H5FL_blk_head_t *head, size_t size H5FL_TRACK_PARAMS) { - void *ret_value; /* Pointer to the block to return to the user */ + void *ret_value = NULL; /* Pointer to the block to return to the user */ FUNC_ENTER_NOAPI(NULL) @@ -1000,7 +1039,6 @@ H5FL_blk_free(H5FL_blk_head_t *head, void *block) /* Free tracking information about the allocation location */ H5CS_close_stack(trk->stack); - trk->stack = H5MM_xfree(trk->stack); trk->file = H5MM_xfree(trk->file); trk->func = H5MM_xfree(trk->func); @@ -1043,20 +1081,20 @@ H5FL_blk_free(H5FL_blk_head_t *head, void *block) /* Increment the number of blocks on free list */ head->onlist++; - head->list_mem+=free_size; + head->list_mem += free_size; /* Increment the amount of "block" freed memory globally */ - H5FL_blk_gc_head.mem_freed+=free_size; + H5FL_blk_gc_head.mem_freed += free_size; /* Check for exceeding free list memory use limits */ /* First check this particular list */ - if(head->list_mem>H5FL_blk_lst_mem_lim) - if(H5FL_blk_gc_list(head)<0) + if(head->list_mem > H5FL_blk_lst_mem_lim) + if(H5FL__blk_gc_list(head) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, NULL, "garbage collection failed during free") /* Then check the global amount memory on block free lists */ - if(H5FL_blk_gc_head.mem_freed>H5FL_blk_glb_mem_lim) - if(H5FL_blk_gc()<0) + if(H5FL_blk_gc_head.mem_freed > H5FL_blk_glb_mem_lim) + if(H5FL__blk_gc() < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, NULL, "garbage collection failed during free") done: @@ -1120,7 +1158,8 @@ H5FL_blk_realloc(H5FL_blk_head_t *head, void *block, size_t new_size H5FL_TRACK_ trk->func = H5MM_xfree(trk->func); /* Store new tracking information */ - H5CS_copy_stack(trk->stack); + trk->stack = H5CS_copy_stack(); + HDassert(trk->stack); trk->file = H5MM_strdup(call_file); trk->func = H5MM_strdup(call_func); trk->line = call_line; @@ -1139,7 +1178,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5FL_blk_gc_list + * Function: H5FL__blk_gc_list * * Purpose: Garbage collect a priority queue * @@ -1149,34 +1188,33 @@ done: * Programmer: Quincey Koziol * Thursday, March 23, 2000 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t -H5FL_blk_gc_list(H5FL_blk_head_t *head) +H5FL__blk_gc_list(H5FL_blk_head_t *head) { - H5FL_blk_list_t *list; /* The free list of native nodes of a particular size */ - void *next; /* Temp. ptr to the free list list node */ - void *temp; /* Temp. ptr to the free list page node */ - - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Loop through all the nodes in the block free list queue */ - while(head->head!=NULL) { - temp=head->head->next; + while(head->head != NULL) { + H5FL_blk_list_t *list; /* The free list of native nodes of a particular size */ + void *temp; /* Temp. ptr to the free list page node */ + + temp = head->head->next; /* Loop through all the blocks in the free list, freeing them */ - list=head->head->list; - while(list!=NULL) { - next=list->next; + list = head->head->list; + while(list != NULL) { + void *next; /* Temp. ptr to the free list list node */ + + next = list->next; /* Decrement the number of blocks & memory allocated from this PQ */ head->allocated--; - head->list_mem-=head->head->size; + head->list_mem -= head->head->size; /* Decrement global count of free memory on "block" lists */ - H5FL_blk_gc_head.mem_freed-=head->head->size; + H5FL_blk_gc_head.mem_freed -= head->head->size; /* Free the block */ H5MM_free(list); @@ -1199,11 +1237,11 @@ H5FL_blk_gc_list(H5FL_blk_head_t *head) HDassert(0 == head->list_mem); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5FL_blk_gc_list() */ +} /* end H5FL__blk_gc_list() */ /*------------------------------------------------------------------------- - * Function: H5FL_blk_gc + * Function: H5FL__blk_gc * * Purpose: Garbage collect on all the priority queues * @@ -1213,44 +1251,42 @@ H5FL_blk_gc_list(H5FL_blk_head_t *head) * Programmer: Quincey Koziol * Saturday, March 25, 2000 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t -H5FL_blk_gc(void) +H5FL__blk_gc(void) { H5FL_blk_gc_node_t *gc_node; /* Pointer into the list of things to garbage collect */ - herr_t ret_value=SUCCEED; /* return value*/ + herr_t ret_value = SUCCEED; /* return value*/ FUNC_ENTER_NOAPI_NOINIT /* Walk through all the free lists, free()'ing the nodes */ - gc_node=H5FL_blk_gc_head.first; - while(gc_node!=NULL) { + gc_node = H5FL_blk_gc_head.first; + while(gc_node != NULL) { /* For each free list being garbage collected, walk through the nodes and free them */ - if(H5FL_blk_gc_list(gc_node->pq)<0) + if(H5FL__blk_gc_list(gc_node->pq) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "garbage collection of list failed") /* Go on to the next free list to garbage collect */ - gc_node=gc_node->next; + gc_node = gc_node->next; } /* end while */ /* Double check that all the memory on the free lists are recycled */ - HDassert(H5FL_blk_gc_head.mem_freed==0); + HDassert(H5FL_blk_gc_head.mem_freed == 0); done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL_blk_gc() */ +} /* end H5FL__blk_gc() */ /*-------------------------------------------------------------------------- NAME - H5FL_blk_term + H5FL__blk_term PURPOSE Terminate various H5FL_blk objects USAGE - void H5FL_blk_term() + void H5FL__blk_term() RETURNS Success: Positive if any action might have caused a change in some other interface; zero otherwise. @@ -1264,45 +1300,46 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static int -H5FL_blk_term(void) +H5FL__blk_term(void) { H5FL_blk_gc_node_t *left; /* pointer to garbage collection lists with work left */ - H5FL_blk_gc_node_t *tmp; /* Temporary pointer to a garbage collection node */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Free the nodes on the garbage collection list, keeping nodes with allocations outstanding */ - left=NULL; - while(H5FL_blk_gc_head.first!=NULL) { - tmp=H5FL_blk_gc_head.first->next; + left = NULL; + while(H5FL_blk_gc_head.first != NULL) { + H5FL_blk_gc_node_t *tmp; /* Temporary pointer to a garbage collection node */ + + tmp = H5FL_blk_gc_head.first->next; #ifdef H5FL_DEBUG -printf("H5FL_blk_term: head->name=%s, head->allocated=%d\n", H5FL_blk_gc_head.first->pq->name,(int)H5FL_blk_gc_head.first->pq->allocated); +printf("%s: head->name = %s, head->allocated = %d\n", FUNC, H5FL_blk_gc_head.first->pq->name, (int)H5FL_blk_gc_head.first->pq->allocated); #endif /* H5FL_DEBUG */ /* Check if the list has allocations outstanding */ - if(H5FL_blk_gc_head.first->pq->allocated>0) { + if(H5FL_blk_gc_head.first->pq->allocated > 0) { /* Add free list to the list of nodes with allocations open still */ - H5FL_blk_gc_head.first->next=left; - left=H5FL_blk_gc_head.first; + H5FL_blk_gc_head.first->next = left; + left = H5FL_blk_gc_head.first; } /* end if */ /* No allocations left open for list, get rid of it */ else { /* Reset the "initialized" flag, in case we restart this list somehow (I don't know how..) */ - H5FL_blk_gc_head.first->pq->init=0; + H5FL_blk_gc_head.first->pq->init = 0; /* Free the node from the garbage collection list */ H5MM_free(H5FL_blk_gc_head.first); } /* end else */ - H5FL_blk_gc_head.first=tmp; + H5FL_blk_gc_head.first = tmp; } /* end while */ /* Point to the list of nodes left with allocations open, if any */ - H5FL_blk_gc_head.first=left; + H5FL_blk_gc_head.first = left; - FUNC_LEAVE_NOAPI(H5FL_blk_gc_head.first!=NULL ? 1 : 0) -} /* end H5FL_blk_term() */ + FUNC_LEAVE_NOAPI(H5FL_blk_gc_head.first != NULL ? 1 : 0) +} /* end H5FL__blk_term() */ /*------------------------------------------------------------------------- @@ -1421,13 +1458,13 @@ H5FL_arr_free(H5FL_arr_head_t *head, void *obj) /* Check for exceeding free list memory use limits */ /* First check this particular list */ - if(head->list_mem>H5FL_arr_lst_mem_lim) - if(H5FL_arr_gc_list(head)<0) + if(head->list_mem > H5FL_arr_lst_mem_lim) + if(H5FL__arr_gc_list(head) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, NULL, "garbage collection failed during free") /* Then check the global amount memory on array free lists */ - if(H5FL_arr_gc_head.mem_freed>H5FL_arr_glb_mem_lim) - if(H5FL_arr_gc()<0) + if(H5FL_arr_gc_head.mem_freed > H5FL_arr_glb_mem_lim) + if(H5FL__arr_gc() < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, NULL, "garbage collection failed during free") done: @@ -1454,8 +1491,8 @@ void * H5FL_arr_malloc(H5FL_arr_head_t *head, size_t elem) { H5FL_arr_list_t *new_obj; /* Pointer to the new free list node allocated */ - void *ret_value; /* Pointer to object to return */ - size_t mem_size; /* Size of memory block being recycled */ + size_t mem_size; /* Size of memory block being recycled */ + void *ret_value = NULL; /* Pointer to the block to return */ FUNC_ENTER_NOAPI(NULL) @@ -1528,7 +1565,7 @@ done: void * H5FL_arr_calloc(H5FL_arr_head_t *head, size_t elem) { - void *ret_value; /* Pointer to object to return */ + void *ret_value = NULL; /* Pointer to the block to return */ FUNC_ENTER_NOAPI(NULL) @@ -1566,51 +1603,50 @@ done: void * H5FL_arr_realloc(H5FL_arr_head_t *head, void * obj, size_t new_elem) { - void *ret_value; /* Pointer to object to return */ + void *ret_value = NULL; /* Pointer to the block to return */ - FUNC_ENTER_NOAPI(NULL) + FUNC_ENTER_NOAPI_NOERR /* Double check parameters */ HDassert(head); HDassert(new_elem); /* Check if we are really allocating the object */ - if(obj==NULL) - ret_value=H5FL_arr_malloc(head,new_elem); + if(obj == NULL) + ret_value = H5FL_arr_malloc(head, new_elem); else { H5FL_arr_list_t *temp; /* Temp. ptr to the new free list node allocated */ /* Sanity check that the number of elements is supported */ - HDassert((int)new_elem<=head->maxelem); + HDassert((int)new_elem <= head->maxelem); /* Get the pointer to the info header in front of the block to free */ - temp=(H5FL_arr_list_t *)((unsigned char *)obj-sizeof(H5FL_arr_list_t)); /*lint !e826 Pointer-to-pointer cast is appropriate here */ + temp = (H5FL_arr_list_t *)((unsigned char *)obj - sizeof(H5FL_arr_list_t)); /*lint !e826 Pointer-to-pointer cast is appropriate here */ /* Check if the size is really changing */ - if(temp->nelem!=new_elem) { + if(temp->nelem != new_elem) { size_t blk_size; /* Size of block */ /* Get the new array of objects */ - ret_value=H5FL_arr_malloc(head,new_elem); + ret_value = H5FL_arr_malloc(head, new_elem); /* Copy the appropriate amount of elements */ - blk_size = head->list_arr[ MIN(temp->nelem, new_elem) ].size; - HDmemcpy(ret_value,obj,blk_size); + blk_size = head->list_arr[MIN(temp->nelem, new_elem)].size; + HDmemcpy(ret_value, obj, blk_size); /* Free the old block */ - H5FL_arr_free(head,obj); + H5FL_arr_free(head, obj); } /* end if */ else - ret_value=obj; + ret_value = obj; } /* end else */ -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL_arr_realloc() */ /*------------------------------------------------------------------------- - * Function: H5FL_arr_gc_list + * Function: H5FL__arr_gc_list * * Purpose: Garbage collect on an array object free list * @@ -1620,29 +1656,29 @@ done: * Programmer: Quincey Koziol * Tuesday, July 25, 2000 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t -H5FL_arr_gc_list(H5FL_arr_head_t *head) +H5FL__arr_gc_list(H5FL_arr_head_t *head) { - H5FL_arr_list_t *arr_free_list; /* Pointer to nodes in free list being garbage collected */ - void *tmp; /* Temporary node pointer */ unsigned u; /* Counter for array of free lists */ - size_t total_mem; /* Total memory used on list */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Walk through the array of free lists */ - for(u=0; u<(unsigned)head->maxelem; u++) { - if(head->list_arr[u].onlist>0) { + for(u = 0; u < (unsigned)head->maxelem; u++) { + if(head->list_arr[u].onlist > 0) { + H5FL_arr_list_t *arr_free_list; /* Pointer to nodes in free list being garbage collected */ + size_t total_mem; /* Total memory used on list */ + /* Calculate the total memory used on this list */ - total_mem=head->list_arr[u].onlist*head->list_arr[u].size; + total_mem = head->list_arr[u].onlist * head->list_arr[u].size; /* For each free list being garbage collected, walk through the nodes and free them */ - arr_free_list=head->list_arr[u].list; - while(arr_free_list!=NULL) { + arr_free_list = head->list_arr[u].list; + while(arr_free_list != NULL) { + void *tmp; /* Temporary node pointer */ + tmp = arr_free_list->next; /* Decrement the count of nodes allocated and free the node */ @@ -1657,22 +1693,22 @@ H5FL_arr_gc_list(H5FL_arr_head_t *head) head->list_arr[u].onlist = 0; /* Decrement count of free memory on this "array" list */ - head->list_mem-=total_mem; + head->list_mem -= total_mem; /* Decrement global count of free memory on "array" lists */ - H5FL_arr_gc_head.mem_freed-=total_mem; + H5FL_arr_gc_head.mem_freed -= total_mem; } /* end if */ } /* end for */ /* Double check that all the memory on this list is recycled */ - HDassert(head->list_mem==0); + HDassert(head->list_mem == 0); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5FL_arr_gc_list() */ +} /* end H5FL__arr_gc_list() */ /*------------------------------------------------------------------------- - * Function: H5FL_arr_gc + * Function: H5FL__arr_gc * * Purpose: Garbage collect on all the array object free lists * @@ -1682,44 +1718,42 @@ H5FL_arr_gc_list(H5FL_arr_head_t *head) * Programmer: Quincey Koziol * Saturday, March 25, 2000 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t -H5FL_arr_gc(void) +H5FL__arr_gc(void) { H5FL_gc_arr_node_t *gc_arr_node; /* Pointer into the list of things to garbage collect */ - herr_t ret_value=SUCCEED; /* return value*/ + herr_t ret_value = SUCCEED; /* return value*/ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Walk through all the free lists, free()'ing the nodes */ - gc_arr_node=H5FL_arr_gc_head.first; - while(gc_arr_node!=NULL) { + gc_arr_node = H5FL_arr_gc_head.first; + while(gc_arr_node != NULL) { /* Release the free nodes on the list */ - if(H5FL_arr_gc_list(gc_arr_node->list)<0) + if(H5FL__arr_gc_list(gc_arr_node->list) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "garbage collection of list failed") /* Go on to the next free list to garbage collect */ - gc_arr_node=gc_arr_node->next; + gc_arr_node = gc_arr_node->next; } /* end while */ /* Double check that all the memory on the free lists are recycled */ - HDassert(H5FL_arr_gc_head.mem_freed==0); + HDassert(H5FL_arr_gc_head.mem_freed == 0); done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL_arr_gc() */ +} /* end H5FL__arr_gc() */ /*-------------------------------------------------------------------------- NAME - H5FL_arr_term + H5FL__arr_term PURPOSE Terminate various H5FL array object free lists USAGE - int H5FL_arr_term() + int H5FL__arr_term() RETURNS Success: Positive if any action might have caused a change in some other interface; zero otherwise. @@ -1733,26 +1767,27 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static int -H5FL_arr_term(void) +H5FL__arr_term(void) { H5FL_gc_arr_node_t *left; /* pointer to garbage collection lists with work left */ - H5FL_gc_arr_node_t *tmp; /* Temporary pointer to a garbage collection node */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Free the nodes on the garbage collection list, keeping nodes with allocations outstanding */ - left=NULL; - while(H5FL_arr_gc_head.first!=NULL) { - tmp=H5FL_arr_gc_head.first->next; + left = NULL; + while(H5FL_arr_gc_head.first != NULL) { + H5FL_gc_arr_node_t *tmp; /* Temporary pointer to a garbage collection node */ + + tmp = H5FL_arr_gc_head.first->next; /* Check if the list has allocations outstanding */ #ifdef H5FL_DEBUG -printf("H5FL_arr_term: head->name=%s, head->allocated=%d\n", H5FL_arr_gc_head.first->list->name,(int)H5FL_arr_gc_head.first->list->allocated); +printf("%s: head->name = %s, head->allocated = %d\n", FUNC, H5FL_arr_gc_head.first->list->name, (int)H5FL_arr_gc_head.first->list->allocated); #endif /* H5FL_DEBUG */ - if(H5FL_arr_gc_head.first->list->allocated>0) { + if(H5FL_arr_gc_head.first->list->allocated > 0) { /* Add free list to the list of nodes with allocations open still */ - H5FL_arr_gc_head.first->next=left; - left=H5FL_arr_gc_head.first; + H5FL_arr_gc_head.first->next = left; + left = H5FL_arr_gc_head.first; } /* end if */ /* No allocations left open for list, get rid of it */ else { @@ -1760,20 +1795,20 @@ printf("H5FL_arr_term: head->name=%s, head->allocated=%d\n", H5FL_arr_gc_head.fi H5MM_xfree(H5FL_arr_gc_head.first->list->list_arr); /* Reset the "initialized" flag, in case we restart this list somehow (I don't know how..) */ - H5FL_arr_gc_head.first->list->init=0; + H5FL_arr_gc_head.first->list->init = 0; /* Free the node from the garbage collection list */ H5MM_free(H5FL_arr_gc_head.first); } /* end else */ - H5FL_arr_gc_head.first=tmp; + H5FL_arr_gc_head.first = tmp; } /* end while */ /* Point to the list of nodes left with allocations open, if any */ - H5FL_arr_gc_head.first=left; + H5FL_arr_gc_head.first = left; - FUNC_LEAVE_NOAPI(H5FL_arr_gc_head.first!=NULL ? 1 : 0) -} /* end H5FL_arr_term() */ + FUNC_LEAVE_NOAPI(H5FL_arr_gc_head.first != NULL ? 1 : 0) +} /* end H5FL__arr_term() */ /*------------------------------------------------------------------------- @@ -1830,18 +1865,17 @@ H5FL_seq_free(H5FL_seq_head_t *head, void *obj) void * H5FL_seq_malloc(H5FL_seq_head_t *head, size_t elem H5FL_TRACK_PARAMS) { - void *ret_value; /* Pointer to object to return */ + void *ret_value = NULL; /* Pointer to the block to return */ - FUNC_ENTER_NOAPI(NULL) + FUNC_ENTER_NOAPI_NOERR /* Double check parameters */ HDassert(head); HDassert(elem); /* Use block routine */ - ret_value=H5FL_blk_malloc(&(head->queue),head->size*elem H5FL_TRACK_INFO_INT); + ret_value = H5FL_blk_malloc(&(head->queue), head->size * elem H5FL_TRACK_INFO_INT); -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL_seq_malloc() */ @@ -1864,18 +1898,17 @@ done: void * H5FL_seq_calloc(H5FL_seq_head_t *head, size_t elem H5FL_TRACK_PARAMS) { - void *ret_value; /* Pointer to object to return */ + void *ret_value = NULL; /* Pointer to the block to return */ - FUNC_ENTER_NOAPI(NULL) + FUNC_ENTER_NOAPI_NOERR /* Double check parameters */ HDassert(head); HDassert(elem); /* Use block routine */ - ret_value=H5FL_blk_calloc(&(head->queue),head->size*elem H5FL_TRACK_INFO_INT); + ret_value = H5FL_blk_calloc(&(head->queue), head->size * elem H5FL_TRACK_INFO_INT); -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL_seq_calloc() */ @@ -1898,18 +1931,17 @@ done: void * H5FL_seq_realloc(H5FL_seq_head_t *head, void * obj, size_t new_elem H5FL_TRACK_PARAMS) { - void *ret_value; /* Pointer to object to return */ + void *ret_value = NULL; /* Pointer to the block to return */ - FUNC_ENTER_NOAPI(NULL) + FUNC_ENTER_NOAPI_NOERR /* Double check parameters */ HDassert(head); HDassert(new_elem); /* Use block routine */ - ret_value=H5FL_blk_realloc(&(head->queue),obj,head->size*new_elem H5FL_TRACK_INFO_INT); + ret_value = H5FL_blk_realloc(&(head->queue), obj, head->size * new_elem H5FL_TRACK_INFO_INT); -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL_seq_realloc() */ @@ -1935,9 +1967,9 @@ done: H5FL_fac_head_t * H5FL_fac_init(size_t size) { - H5FL_fac_gc_node_t *new_node = NULL; /* Pointer to the node for the new list to garbage collect */ - H5FL_fac_head_t *factory = NULL; /* Pointer to new block factory */ - H5FL_fac_head_t *ret_value; /* Return value */ + H5FL_fac_gc_node_t *new_node = NULL; /* Pointer to the node for the new list to garbage collect */ + H5FL_fac_head_t *factory = NULL; /* Pointer to new block factory */ + H5FL_fac_head_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -2012,7 +2044,7 @@ done: void * H5FL_fac_free(H5FL_fac_head_t *head, void *obj) { - void *ret_value=NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ /* NOINIT OK here because this must be called after H5FL_fac_init -NAF */ FUNC_ENTER_NOAPI_NOINIT @@ -2027,7 +2059,6 @@ H5FL_fac_free(H5FL_fac_head_t *head, void *obj) /* Free tracking information about the allocation location */ H5CS_close_stack(trk->stack); - trk->stack = H5MM_xfree(trk->stack); trk->file = H5MM_xfree(trk->file); trk->func = H5MM_xfree(trk->func); @@ -2053,26 +2084,26 @@ H5FL_fac_free(H5FL_fac_head_t *head, void *obj) HDassert(head->init); /* Link into the free list */ - ((H5FL_fac_node_t *)obj)->next=head->list; + ((H5FL_fac_node_t *)obj)->next = head->list; /* Point free list at the node freed */ - head->list=(H5FL_fac_node_t *)obj; + head->list = (H5FL_fac_node_t *)obj; /* Increment the number of blocks on free list */ head->onlist++; /* Increment the amount of "factory" freed memory globally */ - H5FL_fac_gc_head.mem_freed+=head->size; + H5FL_fac_gc_head.mem_freed += head->size; /* Check for exceeding free list memory use limits */ /* First check this particular list */ if(head->onlist * head->size > H5FL_fac_lst_mem_lim) - if(H5FL_fac_gc_list(head)<0) + if(H5FL__fac_gc_list(head) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, NULL, "garbage collection failed during free") /* Then check the global amount memory on factory free lists */ if(H5FL_fac_gc_head.mem_freed > H5FL_fac_glb_mem_lim) - if(H5FL_fac_gc()<0) + if(H5FL__fac_gc() < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, NULL, "garbage collection failed during free") done: @@ -2101,7 +2132,7 @@ done: void * H5FL_fac_malloc(H5FL_fac_head_t *head H5FL_TRACK_PARAMS) { - void *ret_value; /* Pointer to object to return */ + void *ret_value = NULL; /* Pointer to the block to return */ /* NOINIT OK here because this must be called after H5FL_fac_init -NAF */ FUNC_ENTER_NOAPI_NOINIT @@ -2135,8 +2166,8 @@ H5FL_fac_malloc(H5FL_fac_head_t *head H5FL_TRACK_PARAMS) #ifdef H5FL_TRACK /* Copy allocation location information */ - ((H5FL_track_t *)ret_value)->stack = H5MM_calloc(sizeof(H5CS_t)); - H5CS_copy_stack(((H5FL_track_t *)ret_value)->stack); + ((H5FL_track_t *)ret_value)->stack = H5CS_copy_stack(); + HDassert(((H5FL_track_t *)ret_value)->stack); ((H5FL_track_t *)ret_value)->file = H5MM_strdup(call_file); ((H5FL_track_t *)ret_value)->func = H5MM_strdup(call_func); ((H5FL_track_t *)ret_value)->line = call_line; @@ -2178,7 +2209,7 @@ done: void * H5FL_fac_calloc(H5FL_fac_head_t *head H5FL_TRACK_PARAMS) { - void *ret_value; /* Pointer to object to return */ + void *ret_value = NULL; /* Pointer to the block to return */ /* NOINIT OK here because this must be called after H5FL_fac_init -NAF */ FUNC_ENTER_NOAPI_NOINIT @@ -2197,9 +2228,10 @@ H5FL_fac_calloc(H5FL_fac_head_t *head H5FL_TRACK_PARAMS) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL_fac_calloc() */ + /*------------------------------------------------------------------------- - * Function: H5FL_fac_gc_list + * Function: H5FL__fac_gc_list * * Purpose: Garbage collect on a particular factory free list * @@ -2209,26 +2241,25 @@ done: * Programmer: Neil Fortner * Friday, December 19, 2008 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t -H5FL_fac_gc_list(H5FL_fac_head_t *head) +H5FL__fac_gc_list(H5FL_fac_head_t *head) { H5FL_fac_node_t *free_list; /* Pointer to nodes in free list being garbage collected */ - void *tmp; /* Temporary node pointer */ size_t total_mem; /* Total memory used on list */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Calculate the total memory used on this list */ - total_mem=head->onlist*head->size; + total_mem = head->onlist * head->size; /* For each free list being garbage collected, walk through the nodes and free them */ - free_list=head->list; - while(free_list!=NULL) { - tmp=free_list->next; + free_list = head->list; + while(free_list != NULL) { + void *tmp; /* Temporary node pointer */ + + tmp = free_list->next; /* Decrement the count of nodes allocated and free the node */ head->allocated--; @@ -2239,18 +2270,18 @@ H5FL_fac_gc_list(H5FL_fac_head_t *head) } /* end while */ /* Indicate no free nodes on the free list */ - head->list=NULL; - head->onlist=0; + head->list = NULL; + head->onlist = 0; /* Decrement global count of free memory on "factory" lists */ - H5FL_fac_gc_head.mem_freed-=total_mem; + H5FL_fac_gc_head.mem_freed -= total_mem; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5FL_fac_gc_list() */ +} /* end H5FL__fac_gc_list() */ /*------------------------------------------------------------------------- - * Function: H5FL_fac_gc + * Function: H5FL__fac_gc * * Purpose: Garbage collect on all the factory free lists * @@ -2260,35 +2291,33 @@ H5FL_fac_gc_list(H5FL_fac_head_t *head) * Programmer: Neil Fortner * Friday, December 19, 2008 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t -H5FL_fac_gc(void) +H5FL__fac_gc(void) { H5FL_fac_gc_node_t *gc_node; /* Pointer into the list of things to garbage collect */ - herr_t ret_value=SUCCEED; /* return value*/ + herr_t ret_value = SUCCEED; /* return value*/ FUNC_ENTER_NOAPI_NOINIT /* Walk through all the free lists, free()'ing the nodes */ - gc_node=H5FL_fac_gc_head.first; - while(gc_node!=NULL) { + gc_node = H5FL_fac_gc_head.first; + while(gc_node != NULL) { /* Release the free nodes on the list */ - if(H5FL_fac_gc_list(gc_node->list)<0) + if(H5FL__fac_gc_list(gc_node->list) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "garbage collection of list failed") /* Go on to the next free list to garbage collect */ - gc_node=gc_node->next; + gc_node = gc_node->next; } /* end while */ /* Double check that all the memory on the free lists is recycled */ - HDassert(H5FL_fac_gc_head.mem_freed==0); + HDassert(H5FL_fac_gc_head.mem_freed == 0); done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL_fac_gc() */ +} /* end H5FL__fac_gc() */ /*------------------------------------------------------------------------- @@ -2322,11 +2351,11 @@ H5FL_fac_term(H5FL_fac_head_t *factory) HDassert(factory); /* Garbage collect all the blocks in the factory's free list */ - if(H5FL_fac_gc_list(factory)<0) + if(H5FL__fac_gc_list(factory) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "garbage collection of factory failed") /* Verify that all the blocks have been freed */ - if(factory->allocated>0) + if(factory->allocated > 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "factory still has objects allocated") /* Unlink block free list for factory from global free list */ @@ -2357,7 +2386,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5FL_fac_term_all + * Function: H5FL__fac_term_all * * Purpose: Terminate all block factories * @@ -2367,23 +2396,21 @@ done: * Programmer: Neil Fortner * Friday, December 19, 2008 * - * Modifications: - * *------------------------------------------------------------------------- */ static int -H5FL_fac_term_all(void) +H5FL__fac_term_all(void) { - H5FL_fac_gc_node_t *tmp; /* Temporary pointer to a garbage collection node */ - - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Free the nodes on the garbage collection list */ while(H5FL_fac_gc_head.first != NULL) { - tmp=H5FL_fac_gc_head.first->next; + H5FL_fac_gc_node_t *tmp; /* Temporary pointer to a garbage collection node */ + + tmp = H5FL_fac_gc_head.first->next; #ifdef H5FL_DEBUG -printf("H5FL_fac_term: head->size=%d, head->allocated=%d\n", (int)H5FL_fac_gc_head.first->list->size,(int)H5FL_fac_gc_head.first->list->allocated); +printf("%s: head->size = %d, head->allocated = %d\n", FUNC, (int)H5FL_fac_gc_head.first->list->size, (int)H5FL_fac_gc_head.first->list->allocated); #endif /* H5FL_DEBUG */ /* The list cannot have any allocations outstanding */ @@ -2399,7 +2426,7 @@ printf("H5FL_fac_term: head->size=%d, head->allocated=%d\n", (int)H5FL_fac_gc_he } /* end while */ FUNC_LEAVE_NOAPI(0) -} /* end H5FL_fac_term_all() */ +} /* end H5FL__fac_term_all() */ /*------------------------------------------------------------------------- @@ -2425,20 +2452,20 @@ H5FL_garbage_coll(void) FUNC_ENTER_NOAPI(FAIL) /* Garbage collect the free lists for array objects */ - if(H5FL_arr_gc()<0) + if(H5FL__arr_gc() < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "can't garbage collect array objects") /* Garbage collect free lists for blocks */ - if(H5FL_blk_gc()<0) + if(H5FL__blk_gc() < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "can't garbage collect block objects") /* Garbage collect the free lists for regular objects */ - if(H5FL_reg_gc()<0) + if(H5FL__reg_gc() < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "can't garbage collect regular objects") /* Garbage collect the free lists for factory objects */ - if(H5FL_fac_gc()<0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "can't garbage collect regular objects") + if(H5FL__fac_gc() < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "can't garbage collect factory objects") done: FUNC_LEAVE_NOAPI(ret_value) @@ -2481,82 +2508,28 @@ H5FL_set_free_list_limits(int reg_global_lim, int reg_list_lim, int arr_global_l int arr_list_lim, int blk_global_lim, int blk_list_lim, int fac_global_lim, int fac_list_lim) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR /* Set the limit variables */ /* limit on all regular free lists */ - H5FL_reg_glb_mem_lim=(reg_global_lim==-1 ? UINT_MAX : (size_t)reg_global_lim); + H5FL_reg_glb_mem_lim = (reg_global_lim == -1 ? UINT_MAX : (size_t)reg_global_lim); /* limit on each regular free list */ - H5FL_reg_lst_mem_lim=(reg_list_lim==-1 ? UINT_MAX : (size_t)reg_list_lim); + H5FL_reg_lst_mem_lim = (reg_list_lim == -1 ? UINT_MAX : (size_t)reg_list_lim); /* limit on all array free lists */ - H5FL_arr_glb_mem_lim=(arr_global_lim==-1 ? UINT_MAX : (size_t)arr_global_lim); + H5FL_arr_glb_mem_lim = (arr_global_lim == -1 ? UINT_MAX : (size_t)arr_global_lim); /* limit on each array free list */ - H5FL_arr_lst_mem_lim=(arr_list_lim==-1 ? UINT_MAX : (size_t)arr_list_lim); + H5FL_arr_lst_mem_lim = (arr_list_lim == -1 ? UINT_MAX : (size_t)arr_list_lim); /* limit on all block free lists */ - H5FL_blk_glb_mem_lim=(blk_global_lim==-1 ? UINT_MAX : (size_t)blk_global_lim); + H5FL_blk_glb_mem_lim = (blk_global_lim == -1 ? UINT_MAX : (size_t)blk_global_lim); /* limit on each block free list */ - H5FL_blk_lst_mem_lim=(blk_list_lim==-1 ? UINT_MAX : (size_t)blk_list_lim); + H5FL_blk_lst_mem_lim = (blk_list_lim == -1 ? UINT_MAX : (size_t)blk_list_lim); /* limit on all factory free lists */ - H5FL_fac_glb_mem_lim=(fac_global_lim==-1 ? UINT_MAX : (size_t)fac_global_lim); + H5FL_fac_glb_mem_lim = (fac_global_lim == -1 ? UINT_MAX : (size_t)fac_global_lim); /* limit on each factory free list */ - H5FL_fac_lst_mem_lim=(fac_list_lim==-1 ? UINT_MAX : (size_t)fac_list_lim); + H5FL_fac_lst_mem_lim = (fac_list_lim == -1 ? UINT_MAX : (size_t)fac_list_lim); -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL_set_free_list_limits() */ - -/*-------------------------------------------------------------------------- - NAME - H5FL_term_interface - PURPOSE - Terminate various H5FL objects - USAGE - void H5FL_term_interface() - RETURNS - Success: Positive if any action might have caused a change in some - other interface; zero otherwise. - Failure: Negative - DESCRIPTION - Release any resources allocated. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - Can't report errors... - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -int -H5FL_term_interface(void) -{ - int ret_value=0; - - FUNC_ENTER_NOAPI_NOINIT_NOERR - - /* Garbage collect any nodes on the free lists */ - (void)H5FL_garbage_coll(); - - ret_value=H5FL_reg_term()+H5FL_fac_term_all()+H5FL_arr_term()+H5FL_blk_term(); - -#ifdef H5FL_TRACK - /* If we haven't freed all the allocated memory, dump out the list now */ - if(ret_value > 0 && H5FL_out_head_g) { - H5FL_track_t *trk = H5FL_out_head_g; - - /* Dump information about all the outstanding allocations */ - while(trk != NULL) { - /* Print information about the outstanding block */ - HDfprintf(stderr,"%s: Outstanding allocation:\n", "H5FL_term_interface"); - HDfprintf(stderr,"\tFile: %s, Function: %s, Line: %d\n", trk->file, trk->func, trk->line); - H5CS_print_stack(trk->stack, stderr); - - /* Advance to next node */ - trk = trk->next; - } /* end while */ - } /* end if */ -#endif /* H5FL_TRACK */ - - FUNC_LEAVE_NOAPI(ret_value) -} - diff --git a/src/H5FLmodule.h b/src/H5FLmodule.h new file mode 100644 index 0000000..cfa585c --- /dev/null +++ b/src/H5FLmodule.h @@ -0,0 +1,35 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Quincey Koziol <koziol@hdfgroup.org> + * Saturday, September 12, 2015 + * + * Purpose: This file contains declarations which define macros for the + * H5FL package. Including this header means that the source file + * is part of the H5FL package. + */ +#ifndef _H5FLmodule_H +#define _H5FLmodule_H + +/* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error + * reporting macros. + */ +#define H5FL_MODULE +#define H5_MY_PKG H5FL +#define H5_MY_PKG_ERR H5E_RESOURCE +#define H5_MY_PKG_INIT NO + +#endif /* _H5FLmodule_H */ + @@ -21,7 +21,7 @@ * */ -#define H5F_PACKAGE /*suppress error about including H5Fpkg */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ #include "H5Eprivate.h" /* Error handling */ @@ -27,7 +27,8 @@ /* Module Setup */ /****************/ -#define H5FS_PACKAGE /* suppress error about including H5FSpkg */ +#include "H5FSmodule.h" /* This source code file is part of the H5FS module */ + /***********/ /* Headers */ @@ -38,6 +39,7 @@ #include "H5FSpkg.h" /* File free space */ #include "H5MFprivate.h" /* File memory management */ + /****************/ /* Local Macros */ /****************/ @@ -66,6 +68,9 @@ 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); @@ -102,7 +107,7 @@ H5FS_create(H5F_t *f, hid_t dxpl_id, haddr_t *fs_addr, const H5FS_create_t *fs_c uint16_t nclasses, const H5FS_section_class_t *classes[], void *cls_init_udata, hsize_t alignment, hsize_t threshold) { H5FS_t *fspace = NULL; /* New free space structure */ - H5FS_t *ret_value; /* Return value */ + H5FS_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_TAG(dxpl_id, H5AC__FREESPACE_TAG, NULL) #ifdef H5FS_DEBUG @@ -588,7 +593,7 @@ H5FS__new(const H5F_t *f, uint16_t nclasses, const H5FS_section_class_t *classes { H5FS_t *fspace = NULL; /* Free space manager */ size_t u; /* Local index variable */ - H5FS_t *ret_value; /* Return value */ + H5FS_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE diff --git a/src/H5FScache.c b/src/H5FScache.c index 923f3fb..50b17bc 100644 --- a/src/H5FScache.c +++ b/src/H5FScache.c @@ -28,7 +28,8 @@ /* Module Setup */ /****************/ -#define H5FS_PACKAGE /* Suppress error about including H5FSpkg */ +#include "H5FSmodule.h" /* This source code file is part of the H5FS module */ + /***********/ /* Headers */ @@ -41,6 +42,7 @@ #include "H5VMprivate.h" /* Vectors and arrays */ #include "H5WBprivate.h" /* Wrapped Buffers */ + /****************/ /* Local Macros */ /****************/ @@ -263,7 +265,7 @@ H5FS__cache_hdr_deserialize(const void *_image, size_t len, void *_udata, const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ unsigned nclasses; /* Number of section classes */ - H5FS_t *ret_value; /* Return value */ + H5FS_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -930,7 +932,7 @@ H5FS__cache_sinfo_deserialize(const void *_image, size_t len, void *_udata, size_t old_sect_size; /* Old section size */ const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum */ - void * ret_value; /* Return value */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC diff --git a/src/H5FSdbg.c b/src/H5FSdbg.c index 4599b52..fbdeb70 100644 --- a/src/H5FSdbg.c +++ b/src/H5FSdbg.c @@ -28,9 +28,10 @@ /* Module Setup */ /****************/ -#define H5FS_PACKAGE /* Suppress error about including H5FSpkg */ -#define H5HF_DEBUGGING /* Need access to fractal heap debugging routines */ -#define H5MF_DEBUGGING /* Need access to file space debugging routines */ +#include "H5FSmodule.h" /* This source code file is part of the H5FS module */ +#define H5HF_DEBUGGING /* Need access to fractal heap debugging routines */ +#define H5MF_DEBUGGING /* Need access to file space debugging routines */ + /***********/ /* Headers */ @@ -41,6 +42,7 @@ #include "H5HFprivate.h" /* Fractal heaps */ #include "H5MFprivate.h" /* File memory management */ + /****************/ /* Local Macros */ /****************/ diff --git a/src/H5FSint.c b/src/H5FSint.c index 43c3b83..60cedd5 100644 --- a/src/H5FSint.c +++ b/src/H5FSint.c @@ -28,7 +28,7 @@ /* Module Declaration */ /**********************/ -#define H5FS_PACKAGE +#include "H5FSmodule.h" /* This source code file is part of the H5FS module */ /***********************/ diff --git a/src/H5FSmodule.h b/src/H5FSmodule.h new file mode 100644 index 0000000..b435b79 --- /dev/null +++ b/src/H5FSmodule.h @@ -0,0 +1,35 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Quincey Koziol <koziol@hdfgroup.org> + * Saturday, September 12, 2015 + * + * Purpose: This file contains declarations which define macros for the + * H5FS package. Including this header means that the source file + * is part of the H5FS package. + */ +#ifndef _H5FSmodule_H +#define _H5FSmodule_H + +/* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error + * reporting macros. + */ +#define H5FS_MODULE +#define H5_MY_PKG H5FS +#define H5_MY_PKG_ERR H5E_FSPACE +#define H5_MY_PKG_INIT NO + +#endif /* _H5FSmodule_H */ + diff --git a/src/H5FSpkg.h b/src/H5FSpkg.h index 62da2e3..bb5ba7b 100644 --- a/src/H5FSpkg.h +++ b/src/H5FSpkg.h @@ -21,7 +21,7 @@ * the H5FS package. Source files outside the H5FS package should * include H5FSprivate.h instead. */ -#ifndef H5FS_PACKAGE +#if !(defined H5FS_FRIEND || defined H5FS_MODULE) #error "Do not include this file outside the H5FS package!" #endif diff --git a/src/H5FSsection.c b/src/H5FSsection.c index 7fb1944..62500e7 100644 --- a/src/H5FSsection.c +++ b/src/H5FSsection.c @@ -25,7 +25,7 @@ /* Module Setup */ /****************/ -#define H5FS_PACKAGE /* Suppress error about including H5FSpkg */ +#include "H5FSmodule.h" /* This source code file is part of the H5FS module */ /***********/ @@ -126,8 +126,8 @@ H5FL_DEFINE(H5FS_sinfo_t); H5FS_sinfo_t * H5FS_sinfo_new(H5F_t *f, H5FS_t *fspace) { - H5FS_sinfo_t *sinfo = NULL; /* Section information struct created */ - H5FS_sinfo_t *ret_value; /* Return value */ + H5FS_sinfo_t *sinfo = NULL; /* Section information struct created */ + H5FS_sinfo_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT diff --git a/src/H5FSstat.c b/src/H5FSstat.c index 042dc8f..d2c0177 100644 --- a/src/H5FSstat.c +++ b/src/H5FSstat.c @@ -22,7 +22,8 @@ /* Module Setup */ /****************/ -#define H5FS_PACKAGE /* suppress error about including H5FSpkg */ +#include "H5FSmodule.h" /* This source code file is part of the H5FS module */ + /***********/ /* Headers */ @@ -31,6 +32,7 @@ #include "H5Eprivate.h" /* Error handling */ #include "H5FSpkg.h" /* Free-space manager */ + /****************/ /* Local Macros */ /****************/ diff --git a/src/H5FStest.c b/src/H5FStest.c index 2549ed2..06f5166 100644 --- a/src/H5FStest.c +++ b/src/H5FStest.c @@ -22,8 +22,9 @@ /* Module Setup */ /****************/ -#define H5FS_PACKAGE /* suppress error about including H5FSpkg */ -#define H5FS_TESTING /* suppress warning about H5FS testing funcs */ +#include "H5FSmodule.h" /* This source code file is part of the H5FS module */ +#define H5FS_TESTING /* Suppress warning about H5FS testing funcs */ + /***********/ /* Headers */ @@ -32,6 +33,7 @@ #include "H5Eprivate.h" /* Error handling */ #include "H5FSpkg.h" /* Free-space manager */ + /****************/ /* Local Macros */ /****************/ diff --git a/src/H5Faccum.c b/src/H5Faccum.c index 5cd789f..d8cd614 100644 --- a/src/H5Faccum.c +++ b/src/H5Faccum.c @@ -30,7 +30,7 @@ /* Module Setup */ /****************/ -#define H5F_PACKAGE /*suppress error about including H5Fpkg */ +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ /***********/ diff --git a/src/H5Fcwfs.c b/src/H5Fcwfs.c index 36f0a93..32c73b0 100644 --- a/src/H5Fcwfs.c +++ b/src/H5Fcwfs.c @@ -35,7 +35,7 @@ /* Module Setup */ /****************/ -#define H5F_PACKAGE /*suppress error about including H5Fpkg */ +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ /***********/ @@ -260,8 +260,9 @@ herr_t 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_NOERR + FUNC_ENTER_NOAPI(FAIL) /* Check args */ HDassert(f); @@ -281,7 +282,8 @@ 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 */ - FUNC_LEAVE_NOAPI(SUCCEED) +done: + FUNC_LEAVE_NOAPI(ret_value) } /* H5F_cwfs_advance_heap() */ @@ -302,8 +304,9 @@ herr_t H5F_cwfs_remove_heap(H5F_file_t *shared, H5HG_heap_t *heap) { unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOERR + FUNC_ENTER_NOAPI(FAIL) /* Check args */ HDassert(shared); @@ -318,6 +321,7 @@ H5F_cwfs_remove_heap(H5F_file_t *shared, H5HG_heap_t *heap) } /* end if */ } /* end for */ - FUNC_LEAVE_NOAPI(SUCCEED) +done: + FUNC_LEAVE_NOAPI(ret_value) } /* H5F_cwfs_remove_heap() */ diff --git a/src/H5Fdbg.c b/src/H5Fdbg.c index 40d24e5..d5bacd3 100644 --- a/src/H5Fdbg.c +++ b/src/H5Fdbg.c @@ -19,8 +19,8 @@ * Purpose: File object debugging functions. */ -#define H5F_PACKAGE /*suppress error about including H5Fpkg */ -#define H5G_PACKAGE /*suppress error about including H5Gpkg */ +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ +#define H5G_FRIEND /*suppress error about including H5Gpkg */ #include "H5private.h" /* Generic Functions */ diff --git a/src/H5Fdeprec.c b/src/H5Fdeprec.c index 7e2ea17..d16e2d4 100644 --- a/src/H5Fdeprec.c +++ b/src/H5Fdeprec.c @@ -31,10 +31,7 @@ /* Module Setup */ /****************/ -#define H5F_PACKAGE /*suppress error about including H5Fpkg */ - -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5F__init_deprec_interface +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ /***********/ @@ -82,51 +79,6 @@ /*******************/ - -/*-------------------------------------------------------------------------- -NAME - H5F__init_deprec_interface -- Initialize interface-specific information -USAGE - herr_t H5F__init_deprec_interface() -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. (Just calls - H5F_init() currently). - ---------------------------------------------------------------------------*/ -static herr_t -H5F__init_deprec_interface(void) -{ - FUNC_ENTER_STATIC_NOERR - - FUNC_LEAVE_NOAPI(H5F_init()) -} /* H5F__init_deprec_interface() */ - - -/*-------------------------------------------------------------------------- -NAME - H5F__term_deprec_interface -- Terminate interface -USAGE - herr_t H5F__term_deprec_interface() -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Terminates interface. (Just resets H5_interface_initialize_g - currently). - ---------------------------------------------------------------------------*/ -herr_t -H5F__term_deprec_interface(void) -{ - FUNC_ENTER_PACKAGE_NOERR - - /* Mark closed */ - H5_interface_initialize_g = 0; - - FUNC_LEAVE_NOAPI(0) -} /* H5F__term_deprec_interface() */ - #ifndef H5_NO_DEPRECATED_SYMBOLS /*------------------------------------------------------------------------- diff --git a/src/H5Fefc.c b/src/H5Fefc.c index 8aa9079..5e3deb1 100644 --- a/src/H5Fefc.c +++ b/src/H5Fefc.c @@ -26,7 +26,7 @@ *------------------------------------------------------------------------- */ -#define H5F_PACKAGE /*suppress error about including H5Fpkg */ +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ /* Packages needed by this file... */ @@ -92,7 +92,7 @@ H5F_efc_t * H5F_efc_create(unsigned max_nfiles) { H5F_efc_t *efc = NULL; /* EFC object */ - H5F_efc_t *ret_value; /* Return value */ + H5F_efc_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) diff --git a/src/H5Ffake.c b/src/H5Ffake.c index af048bc..e191003 100644 --- a/src/H5Ffake.c +++ b/src/H5Ffake.c @@ -13,10 +13,7 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#define H5F_PACKAGE /*suppress error about including H5Fpkg */ - -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5F_init_fake_interface +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ /* Packages needed by this file... */ @@ -27,28 +24,6 @@ /* PRIVATE PROTOTYPES */ -/*-------------------------------------------------------------------------- -NAME - H5F_init_fake_interface -- Initialize interface-specific information -USAGE - herr_t H5F_init_fake_interface() - -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. (Just calls - H5F_init() currently). - ---------------------------------------------------------------------------*/ -static herr_t -H5F_init_fake_interface(void) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - FUNC_LEAVE_NOAPI(H5F_init()) -} /* H5F_init_fake_interface() */ - - /*------------------------------------------------------------------------- * Function: H5F_fake_alloc * @@ -70,7 +45,7 @@ H5F_t * H5F_fake_alloc(uint8_t sizeof_size) { H5F_t *f = NULL; /* Pointer to fake file struct */ - H5F_t *ret_value; /* Return value */ + H5F_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) diff --git a/src/H5Fint.c b/src/H5Fint.c index ae0b3ba..161b00d 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -17,10 +17,7 @@ /* Module Setup */ /****************/ -#define H5F_PACKAGE /*suppress error about including H5Fpkg */ - -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5F_init_interface +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ /***********/ @@ -103,30 +100,6 @@ H5FL_DEFINE(H5F_file_t); /*------------------------------------------------------------------------- - * Function: H5F_init_interface - * - * Purpose: Initialize interface-specific information. - * - * Return: Success: non-negative - * Failure: negative - * - * Programmer: Robb Matzke - * Friday, November 20, 1998 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5F_init_interface(void) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT_NOERR - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5F_init_interface() */ - - -/*------------------------------------------------------------------------- * Function: H5F_get_access_plist * * Purpose: Returns a copy of the file access property list of the @@ -540,7 +513,7 @@ H5F_is_hdf5(const char *name) { H5FD_t *file = NULL; /* Low-level file struct */ haddr_t sig_addr; /* Addess of hdf5 file signature */ - htri_t ret_value; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -588,7 +561,7 @@ done: H5F_t * H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf) { - H5F_t *f = NULL, *ret_value; + H5F_t *f = NULL, *ret_value = NULL; FUNC_ENTER_NOAPI_NOINIT @@ -1070,7 +1043,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5F_close_degree_t fc_degree; /*file close degree */ hbool_t set_flag = FALSE; /*set the status_flags in the superblock */ hbool_t clear = FALSE; /*clear the status_flags */ - H5F_t *ret_value; /*actual return value */ + H5F_t *ret_value = NULL; /*actual return value */ FUNC_ENTER_NOAPI(NULL) @@ -1627,7 +1600,7 @@ done: hid_t H5F_get_id(H5F_t *file, hbool_t app_ref) { - hid_t ret_value; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -2151,7 +2124,7 @@ H5F_get_file_image(H5F_t *file, void *buf_ptr, size_t buf_len) { H5FD_t *fd_ptr; /* file driver */ haddr_t eoa; /* End of file address */ - ssize_t ret_value; /* Return value */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI_NOINIT diff --git a/src/H5Fio.c b/src/H5Fio.c index b7e925e..d312b47 100644 --- a/src/H5Fio.c +++ b/src/H5Fio.c @@ -28,7 +28,7 @@ /* Module Setup */ /****************/ -#define H5F_PACKAGE /*suppress error about including H5Fpkg */ +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ /***********/ diff --git a/src/H5Fmodule.h b/src/H5Fmodule.h new file mode 100644 index 0000000..4bb2506 --- /dev/null +++ b/src/H5Fmodule.h @@ -0,0 +1,35 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Quincey Koziol <koziol@hdfgroup.org> + * Saturday, September 12, 2015 + * + * Purpose: This file contains declarations which define macros for the + * H5F package. Including this header means that the source file + * is part of the H5F package. + */ +#ifndef _H5Fmodule_H +#define _H5Fmodule_H + +/* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error + * reporting macros. + */ +#define H5F_MODULE +#define H5_MY_PKG H5F +#define H5_MY_PKG_ERR H5E_FILE +#define H5_MY_PKG_INIT YES + +#endif /* _H5Fmodule_H */ + diff --git a/src/H5Fmount.c b/src/H5Fmount.c index 643eba5..99fa4f2 100644 --- a/src/H5Fmount.c +++ b/src/H5Fmount.c @@ -13,10 +13,7 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#define H5F_PACKAGE /*suppress error about including H5Fpkg */ - -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5F_init_mount_interface +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ /* Packages needed by this file... */ @@ -36,28 +33,6 @@ static herr_t H5F_unmount(H5G_loc_t *loc, const char *name, hid_t dxpl_id); static void H5F_mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs); -/*-------------------------------------------------------------------------- -NAME - H5F_init_mount_interface -- Initialize interface-specific information -USAGE - herr_t H5F_init_mount_interface() - -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. (Just calls - H5F_init() currently). - ---------------------------------------------------------------------------*/ -static herr_t -H5F_init_mount_interface(void) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - FUNC_LEAVE_NOAPI(H5F_init()) -} /* H5F_init_mount_interface() */ - - /*------------------------------------------------------------------------- * Function: H5F_close_mounts * @@ -439,7 +414,7 @@ done: hbool_t H5F_is_mount(const H5F_t *file) { - hbool_t ret_value; /* Return value */ + hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR diff --git a/src/H5Fmpi.c b/src/H5Fmpi.c index 39b8dfa..fe2a774 100644 --- a/src/H5Fmpi.c +++ b/src/H5Fmpi.c @@ -28,7 +28,7 @@ /* Module Setup */ /****************/ -#define H5F_PACKAGE /*suppress error about including H5Fpkg */ +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ /***********/ diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index 18bc7ef..4980c82 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -21,7 +21,7 @@ * the H5F package. Source files outside the H5F package should * include H5Fprivate.h instead. */ -#ifndef H5F_PACKAGE +#if !(defined H5F_FRIEND || defined H5F_MODULE) #error "Do not include this file outside the H5F package!" #endif @@ -374,8 +374,6 @@ H5_DLLVAR const H5AC_class_t H5AC_DRVRINFO[1]; /******************************/ /* General routines */ -H5_DLL herr_t H5F_init(void); -H5_DLL herr_t H5F__term_deprec_interface(void); H5F_t *H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf); herr_t H5F_dest(H5F_t *f, hid_t dxpl_id, hbool_t flush); diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index c2d2d0e..63006f7 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -270,7 +270,7 @@ ((O1) >= (O2) && (O1) < ((O2) + (L2)))) /* If the module using this macro is allowed access to the private variables, access them directly */ -#ifdef H5F_PACKAGE +#ifdef H5F_MODULE #define H5F_INTENT(F) ((F)->shared->flags) #define H5F_OPEN_NAME(F) ((F)->open_name) #define H5F_ACTUAL_NAME(F) ((F)->actual_name) @@ -313,7 +313,7 @@ #define H5F_SET_GRP_BTREE_SHARED(F, RC) (((F)->shared->grp_btree_shared = (RC)) ? SUCCEED : FAIL) #define H5F_USE_TMP_SPACE(F) ((F)->shared->use_tmp_space) #define H5F_IS_TMP_ADDR(F, ADDR) (H5F_addr_le((F)->shared->tmp_addr, (ADDR))) -#else /* H5F_PACKAGE */ +#else /* H5F_MODULE */ #define H5F_INTENT(F) (H5F_get_intent(F)) #define H5F_OPEN_NAME(F) (H5F_get_open_name(F)) #define H5F_ACTUAL_NAME(F) (H5F_get_actual_name(F)) @@ -356,7 +356,7 @@ #define H5F_SET_GRP_BTREE_SHARED(F, RC) (H5F_set_grp_btree_shared((F), (RC))) #define H5F_USE_TMP_SPACE(F) (H5F_use_tmp_space(F)) #define H5F_IS_TMP_ADDR(F, ADDR) (H5F_is_tmp_addr((F), (ADDR))) -#endif /* H5F_PACKAGE */ +#endif /* H5F_MODULE */ /* Macros to encode/decode offset/length's for storing in the file */ diff --git a/src/H5Fquery.c b/src/H5Fquery.c index fb3b490..dee4b48 100644 --- a/src/H5Fquery.c +++ b/src/H5Fquery.c @@ -28,7 +28,7 @@ /* Module Setup */ /****************/ -#define H5F_PACKAGE /*suppress error about including H5Fpkg */ +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ /***********/ @@ -991,7 +991,7 @@ done: haddr_t H5F_get_eoa(const H5F_t *f, H5FD_mem_t type) { - haddr_t ret_value; + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI(HADDR_UNDEF) diff --git a/src/H5Fsfile.c b/src/H5Fsfile.c index a1c6976..4fb9cd9 100644 --- a/src/H5Fsfile.c +++ b/src/H5Fsfile.c @@ -13,7 +13,7 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#define H5F_PACKAGE /*suppress error about including H5Fpkg */ +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ /* Packages needed by this file... */ #include "H5private.h" /* Generic Functions */ diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c index 71b7194..d911dff 100644 --- a/src/H5Fsuper.c +++ b/src/H5Fsuper.c @@ -17,10 +17,7 @@ /* Module Setup */ /****************/ -#define H5F_PACKAGE /*suppress error about including H5Fpkg */ - -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5F_init_super_interface +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ /***********/ @@ -77,28 +74,6 @@ H5FL_DEFINE(H5F_super_t); -/*-------------------------------------------------------------------------- -NAME - H5F_init_super_interface -- Initialize interface-specific information -USAGE - herr_t H5F_init_super_interface() - -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. (Just calls - H5F_init() currently). - ---------------------------------------------------------------------------*/ -static herr_t -H5F_init_super_interface(void) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - FUNC_LEAVE_NOAPI(H5F_init()) -} /* H5F_init_super_interface() */ - - /*------------------------------------------------------------------------- * Function: H5F_super_ext_create * diff --git a/src/H5Fsuper_cache.c b/src/H5Fsuper_cache.c index af253bc..6f37ff6 100644 --- a/src/H5Fsuper_cache.c +++ b/src/H5Fsuper_cache.c @@ -28,8 +28,8 @@ /* Module Setup */ /****************/ -#define H5F_PACKAGE /*suppress error about including H5Fpkg */ -#define H5G_PACKAGE /*suppress error about including H5Gpkg */ +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ +#define H5G_FRIEND /*suppress error about including H5Gpkg */ /***********/ @@ -317,7 +317,7 @@ H5F__cache_superblock_deserialize(const void *_image, size_t len, void *_udata, unsigned super_vers; /* Superblock version */ uint8_t sizeof_addr; /* Size of offsets in the file (in bytes) */ uint8_t sizeof_size; /* Size of lengths in the file (in bytes) */ - H5F_super_t *ret_value; /* Return value */ + H5F_super_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -981,7 +981,7 @@ H5F__cache_drvrinfo_deserialize(const void *_image, size_t len, void *_udata, const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ char drv_name[9]; /* Name of driver */ unsigned drv_vers; /* Version of driver info block */ - H5O_drvinfo_t *ret_value; /* Return value */ + H5O_drvinfo_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC diff --git a/src/H5Ftest.c b/src/H5Ftest.c index 73b00a6..b741e0d 100644 --- a/src/H5Ftest.c +++ b/src/H5Ftest.c @@ -28,12 +28,12 @@ /* Module Setup */ /****************/ -#define H5F_PACKAGE /*suppress error about including H5Fpkg */ +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ #define H5F_TESTING /*suppress warning about H5F testing funcs*/ -#define H5SM_PACKAGE /*suppress error about including H5SMpkg */ -#define H5SM_TESTING /*suppress warning about H5SM testing funcs*/ -#define H5G_PACKAGE /*suppress error about including H5Gpkg */ +#define H5G_FRIEND /*suppress error about including H5Gpkg */ #define H5G_TESTING /*suppress warning about H5G testing funcs*/ +#define H5SM_FRIEND /*suppress error about including H5SMpkg */ +#define H5SM_TESTING /*suppress warning about H5SM testing funcs*/ /***********/ @@ -79,10 +79,7 @@ /* Module Setup */ /****************/ -#define H5G_PACKAGE /*suppress error about including H5Gpkg */ - -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5G_init_interface +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ /***********/ @@ -120,6 +117,9 @@ /* Package Variables */ /*********************/ +/* Package initialization variable */ +hbool_t H5_PKG_INIT_VAR = FALSE; + /*****************************/ /* Library Private Variables */ @@ -138,36 +138,13 @@ static const H5I_class_t H5I_GROUP_CLS[1] = {{ (H5I_free_t)H5G_close /* 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 - * - * Purpose: Initialize the interface from some other package. - * - * Return: Success: non-negative - * Failure: negative - * - * Programmer: Quincey Koziol - * Saturday, November 11, 2006 - * - *------------------------------------------------------------------------- - */ -herr_t -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_interface + * Function: H5G__init_package * * Purpose: Initializes the H5G interface. * @@ -177,7 +154,7 @@ done: * Monday, January 5, 1998 * * Notes: The group creation properties are registered in the property - * list interface initialization routine (H5P_init_interface) + * 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 @@ -185,64 +162,100 @@ done: * *------------------------------------------------------------------------- */ -static herr_t -H5G_init_interface(void) +herr_t +H5G__init_package(void) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* Initialize the atom 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_interface() */ +} /* end H5G__init_package() */ /*------------------------------------------------------------------------- - * Function: H5G_term_interface + * Function: H5G_top_term_package * - * Purpose: Terminates the H5G interface + * Purpose: Close the "top" of the interface, releasing IDs, etc. * * Return: Success: Positive if anything is done that might * affect other interfaces; zero otherwise. - * * Failure: Negative. * - * Programmer: Robb Matzke - * Monday, January 5, 1998 + * Programmer: Quincey Koziol + * Sunday, September 13, 2015 * *------------------------------------------------------------------------- */ int -H5G_term_interface(void) +H5G_top_term_package(void) { int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5_interface_initialize_g) { + if(H5G_top_package_initialize_s) { if(H5I_nmembers(H5I_GROUP) > 0) { (void)H5I_clear_type(H5I_GROUP, FALSE, FALSE); n++; /*H5I*/ } /* end if */ - else { - /* Close deprecated interface */ - n += H5G__term_deprec_interface(); - /* Destroy the group object id group */ - (void)H5I_dec_type_ref(H5I_GROUP); - n++; /*H5I*/ + /* Mark closed */ + if(0 == n) + H5G_top_package_initialize_s = FALSE; + } /* end if */ + + FUNC_LEAVE_NOAPI(n) +} /* end H5G_top_term_package() */ + + +/*------------------------------------------------------------------------- + * Function: H5G_term_package + * + * Purpose: Terminates the H5G interface + * + * Note: Finishes shutting down the interface, after + * H5G_top_term_package() is called + * + * Return: Success: Positive if anything is done that might + * affect other interfaces; zero otherwise. + * Failure: Negative. + * + * Programmer: Robb Matzke + * Monday, January 5, 1998 + * + *------------------------------------------------------------------------- + */ +int +H5G_term_package(void) +{ + int n = 0; + + 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); - /* Mark closed */ - H5_interface_initialize_g = 0; - } /* end else */ + /* Mark closed */ + if(0 == n) + H5_PKG_INIT_VAR = FALSE; } /* end if */ FUNC_LEAVE_NOAPI(n) -} /* end H5G_term_interface() */ +} /* end H5G_term_package() */ /*------------------------------------------------------------------------- diff --git a/src/H5Gbtree2.c b/src/H5Gbtree2.c index 06af245..3c6fac6 100644 --- a/src/H5Gbtree2.c +++ b/src/H5Gbtree2.c @@ -28,7 +28,7 @@ /* Module Setup */ /****************/ -#define H5G_PACKAGE /*suppress error about including H5Gpkg */ +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ /***********/ @@ -238,7 +238,7 @@ H5G_dense_btree2_name_compare(const void *_bt2_udata, const void *_bt2_rec) { const H5G_bt2_ud_common_t *bt2_udata = (const H5G_bt2_ud_common_t *)_bt2_udata; const H5G_dense_bt2_name_rec_t *bt2_rec = (const H5G_dense_bt2_name_rec_t *)_bt2_rec; - herr_t ret_value; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -428,7 +428,7 @@ H5G_dense_btree2_corder_compare(const void *_bt2_udata, const void *_bt2_rec) { const H5G_bt2_ud_common_t *bt2_udata = (const H5G_bt2_ud_common_t *)_bt2_udata; const H5G_dense_bt2_corder_rec_t *bt2_rec = (const H5G_dense_bt2_corder_rec_t *)_bt2_rec; - herr_t ret_value; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR diff --git a/src/H5Gcache.c b/src/H5Gcache.c index 2797edd..a4f9530 100644 --- a/src/H5Gcache.c +++ b/src/H5Gcache.c @@ -28,7 +28,7 @@ /* Module Setup */ /****************/ -#define H5G_PACKAGE /*suppress error about including H5Gpkg */ +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ /***********/ @@ -190,7 +190,7 @@ H5G__cache_node_deserialize(const void *_image, size_t len, void *_udata, H5F_t *f = (H5F_t *)_udata; /* User data for callback */ H5G_node_t *sym = NULL; /* Symbol table node created */ const uint8_t *image = (const uint8_t *)_image; /* Pointer to image to deserialize */ - void * ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC diff --git a/src/H5Gcompact.c b/src/H5Gcompact.c index 89e79cc..41ca4f5 100644 --- a/src/H5Gcompact.c +++ b/src/H5Gcompact.c @@ -23,7 +23,7 @@ * *------------------------------------------------------------------------- */ -#define H5G_PACKAGE /*suppress error about including H5Gpkg */ +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ /* Packages needed by this file... */ @@ -224,8 +224,8 @@ H5G__compact_get_name_by_idx(const H5O_loc_t *oloc, hid_t dxpl_id, const H5O_linfo_t *linfo, H5_index_t idx_type, H5_iter_order_t order, hsize_t idx, char* name, size_t size) { - H5G_link_table_t ltable = {0, NULL}; /* Link table */ - ssize_t ret_value; /* Return value */ + H5G_link_table_t ltable = {0, NULL}; /* Link table */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_PACKAGE @@ -411,7 +411,7 @@ H5G__compact_iterate(const H5O_loc_t *oloc, hid_t dxpl_id, const H5O_linfo_t *li H5G_lib_iterate_t op, void *op_data) { H5G_link_table_t ltable = {0, NULL}; /* Link table */ - herr_t ret_value; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE @@ -503,7 +503,7 @@ H5G__compact_lookup(const H5O_loc_t *oloc, const char *name, H5O_link_t *lnk, { H5G_iter_lkp_t udata; /* User data for iteration callback */ H5O_mesg_operator_t op; /* Message operator */ - htri_t ret_value; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE @@ -598,7 +598,7 @@ H5G__compact_get_type_by_idx(H5O_loc_t *oloc, hid_t dxpl_id, const H5O_linfo_t * hsize_t idx) { H5G_link_table_t ltable = {0, NULL}; /* Link table */ - H5G_obj_t ret_value; /* Return value */ + H5G_obj_t ret_value = H5G_UNKNOWN; /* Return value */ FUNC_ENTER_PACKAGE diff --git a/src/H5Gdense.c b/src/H5Gdense.c index 553b910..ebd291c 100644 --- a/src/H5Gdense.c +++ b/src/H5Gdense.c @@ -29,7 +29,7 @@ /* Module Setup */ /****************/ -#define H5G_PACKAGE /*suppress error about including H5Gpkg */ +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ /***********/ /* Headers */ @@ -540,7 +540,7 @@ H5G__dense_lookup(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo, H5G_bt2_ud_common_t udata; /* User data for v2 B-tree link lookup */ H5HF_t *fheap = NULL; /* Fractal heap handle */ H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ - htri_t ret_value; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE @@ -991,7 +991,7 @@ H5G__dense_iterate(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo, H5G_link_table_t ltable = {0, NULL}; /* Table of links */ H5B2_t *bt2 = NULL; /* v2 B-tree handle for index */ haddr_t bt2_addr; /* Address of v2 B-tree to use for lookup */ - herr_t ret_value; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE @@ -1197,7 +1197,7 @@ H5G__dense_get_name_by_idx(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo, H5G_link_table_t ltable = {0, NULL}; /* Table of links */ H5B2_t *bt2 = NULL; /* v2 B-tree handle for index */ haddr_t bt2_addr; /* Address of v2 B-tree to use for lookup */ - ssize_t ret_value; /* Return value */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_PACKAGE @@ -1836,8 +1836,8 @@ H5G_obj_t H5G__dense_get_type_by_idx(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo, hsize_t idx) { - H5G_link_table_t ltable = {0, NULL}; /* Table of links */ - H5G_obj_t ret_value; /* Return value */ + H5G_link_table_t ltable = {0, NULL}; /* Table of links */ + H5G_obj_t ret_value = H5G_UNKNOWN; /* Return value */ FUNC_ENTER_PACKAGE diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c index 4e3572e..e0bc78e 100644 --- a/src/H5Gdeprec.c +++ b/src/H5Gdeprec.c @@ -31,10 +31,7 @@ /* Module Setup */ /****************/ -#define H5G_PACKAGE /*suppress error about including H5Gpkg */ - -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5G__init_deprec_interface +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ /***********/ @@ -106,51 +103,6 @@ static H5G_obj_t H5G_obj_get_type_by_idx(H5O_loc_t *oloc, hsize_t idx, /*******************/ - -/*-------------------------------------------------------------------------- -NAME - H5G__init_deprec_interface -- Initialize interface-specific information -USAGE - herr_t H5G__init_deprec_interface() -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. (Just calls - H5G__init() currently). - ---------------------------------------------------------------------------*/ -static herr_t -H5G__init_deprec_interface(void) -{ - FUNC_ENTER_STATIC_NOERR - - FUNC_LEAVE_NOAPI(H5G__init()) -} /* H5G__init_deprec_interface() */ - - -/*-------------------------------------------------------------------------- -NAME - H5G__term_deprec_interface -- Terminate interface -USAGE - herr_t H5G__term_deprec_interface() -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Terminates interface. (Just resets H5_interface_initialize_g - currently). - ---------------------------------------------------------------------------*/ -herr_t -H5G__term_deprec_interface(void) -{ - FUNC_ENTER_PACKAGE_NOERR - - /* Mark closed */ - H5_interface_initialize_g = 0; - - FUNC_LEAVE_NOAPI(0) -} /* H5G__term_deprec_interface() */ - #ifndef H5_NO_DEPRECATED_SYMBOLS /*------------------------------------------------------------------------- @@ -168,7 +120,7 @@ H5G__term_deprec_interface(void) H5G_obj_t H5G_map_obj_type(H5O_type_t obj_type) { - H5G_obj_t ret_value; /* Return value */ + H5G_obj_t ret_value = H5G_UNKNOWN; /* Return value */ /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1164,7 +1116,7 @@ H5G_obj_get_type_by_idx(H5O_loc_t *oloc, hsize_t idx, hid_t dxpl_id) { H5O_linfo_t linfo; /* Link info message */ htri_t linfo_exists; /* Whether the link info message exists */ - H5G_obj_t ret_value; /* Return value */ + H5G_obj_t ret_value = H5G_UNKNOWN; /* Return value */ FUNC_ENTER_NOAPI_TAG(dxpl_id, oloc->addr, H5G_UNKNOWN) diff --git a/src/H5Gent.c b/src/H5Gent.c index 2959a53..6020028 100644 --- a/src/H5Gent.c +++ b/src/H5Gent.c @@ -22,7 +22,7 @@ /* Module Setup */ /****************/ -#define H5G_PACKAGE /*suppress error about including H5Gpkg */ +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ /***********/ diff --git a/src/H5Gint.c b/src/H5Gint.c index 53e503a..741be59 100644 --- a/src/H5Gint.c +++ b/src/H5Gint.c @@ -28,10 +28,7 @@ /* Module Setup */ /****************/ -#define H5G_PACKAGE /*suppress error about including H5Gpkg */ - -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5G_init_int_interface +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ /***********/ @@ -119,34 +116,6 @@ H5FL_DEFINE(H5_obj_t); -/*-------------------------------------------------------------------------- -NAME - H5G_init_int_interface -- Initialize interface-specific information -USAGE - herr_t H5G_init_int_interface() -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. (Just calls - H5G__init() currently). - ---------------------------------------------------------------------------*/ -static herr_t -H5G_init_int_interface(void) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - /* Funnel all work to H5G__init() */ - if(H5G__init() < 0) - HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "interface initialization failed") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5G_init_int_interface() */ - - /*------------------------------------------------------------------------- * Function: H5G__create_named * @@ -167,7 +136,7 @@ H5G__create_named(const H5G_loc_t *loc, const char *name, hid_t lcpl_id, { H5O_obj_create_t ocrt_info; /* Information for object creation */ H5G_obj_create_t gcrt_info; /* Information for group creation */ - H5G_t *ret_value; /* Return value */ + H5G_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -225,7 +194,7 @@ H5G__create(H5F_t *file, H5G_obj_create_t *gcrt_info, hid_t dxpl_id) { H5G_t *grp = NULL; /*new group */ unsigned oloc_init = 0; /* Flag to indicate that the group object location was created successfully */ - H5G_t *ret_value; /* Return value */ + H5G_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -302,7 +271,7 @@ H5G__open_name(const H5G_loc_t *loc, const char *name, hid_t gapl_id, H5O_loc_t grp_oloc; /* Opened object object location */ hbool_t loc_found = FALSE; /* Location at 'name' found */ H5O_type_t obj_type; /* Type of object at location */ - H5G_t *ret_value; /* Return value */ + H5G_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -363,7 +332,7 @@ H5G_open(const H5G_loc_t *loc, hid_t dxpl_id) { H5G_t *grp = NULL; /* Group opened */ H5G_shared_t *shared_fo; /* Shared group object */ - H5G_t *ret_value; /* Return value */ + H5G_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -823,7 +792,7 @@ H5G_iterate(hid_t loc_id, const char *group_name, hid_t gid = -1; /* ID of group to iterate over */ H5G_t *grp = NULL; /* Pointer to group data structure to iterate over */ H5G_iter_appcall_ud_t udata; /* User data for callback */ - herr_t ret_value; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1093,7 +1062,7 @@ H5G_visit(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5G_loc_t loc; /* Location of group passed in */ H5G_loc_t start_loc; /* Location of starting group */ unsigned rc; /* Reference count of object */ - herr_t ret_value; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ /* Portably clear udata struct (before FUNC_ENTER) */ HDmemset(&udata, 0, sizeof(udata)); diff --git a/src/H5Glink.c b/src/H5Glink.c index 8b258b5..5a195c8 100644 --- a/src/H5Glink.c +++ b/src/H5Glink.c @@ -28,7 +28,7 @@ /* Module Setup */ /****************/ -#define H5G_PACKAGE /*suppress error about including H5Gpkg */ +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ /***********/ @@ -159,7 +159,7 @@ H5G_link_cmp_name_dec(const void *lnk1, const void *lnk2) static int H5G_link_cmp_corder_inc(const void *lnk1, const void *lnk2) { - int ret_value; /* Return value */ + int ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -194,7 +194,7 @@ H5G_link_cmp_corder_inc(const void *lnk1, const void *lnk2) static int H5G_link_cmp_corder_dec(const void *lnk1, const void *lnk2) { - int ret_value; /* Return value */ + int ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR diff --git a/src/H5Gloc.c b/src/H5Gloc.c index ced2a6f..3fcbd09 100644 --- a/src/H5Gloc.c +++ b/src/H5Gloc.c @@ -28,7 +28,7 @@ /* Module Setup */ /****************/ -#define H5G_PACKAGE /*suppress error about including H5Gpkg */ +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ /***********/ @@ -649,7 +649,7 @@ htri_t H5G_loc_exists(const H5G_loc_t *loc, const char *name, hid_t lapl_id, hid_t dxpl_id) { H5G_loc_exists_t udata; /* User data for traversal callback */ - htri_t ret_value; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -913,7 +913,7 @@ H5G_loc_get_comment(H5G_loc_t *loc, const char *name, char *comment/*out*/, size_t bufsize, hid_t lapl_id, hid_t dxpl_id) { H5G_loc_gc_t udata; /* User data for traversal callback */ - ssize_t ret_value; /* Return value */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI(FAIL) diff --git a/src/H5Gmodule.h b/src/H5Gmodule.h new file mode 100644 index 0000000..52ac067 --- /dev/null +++ b/src/H5Gmodule.h @@ -0,0 +1,35 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Quincey Koziol <koziol@hdfgroup.org> + * Saturday, September 12, 2015 + * + * Purpose: This file contains declarations which define macros for the + * H5G package. Including this header means that the source file + * is part of the H5G package. + */ +#ifndef _H5Gmodule_H +#define _H5Gmodule_H + +/* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error + * reporting macros. + */ +#define H5G_MODULE +#define H5_MY_PKG H5G +#define H5_MY_PKG_ERR H5E_SYM +#define H5_MY_PKG_INIT YES + +#endif /* _H5Gmodule_H */ + diff --git a/src/H5Gname.c b/src/H5Gname.c index bbeddb6..aff9d31 100644 --- a/src/H5Gname.c +++ b/src/H5Gname.c @@ -28,7 +28,7 @@ /* Module Setup */ /****************/ -#define H5G_PACKAGE /*suppress error about including H5Gpkg */ +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ /***********/ @@ -166,7 +166,7 @@ H5G_normalize(const char *name) char *norm; /* Pointer to the normalized string */ size_t s,d; /* Positions within the strings */ unsigned last_slash; /* Flag to indicate last character was a slash */ - char *ret_value; /* Return value */ + char *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -297,7 +297,7 @@ H5G_build_fullpath(const char *prefix, const char *name) size_t path_len; /* Length of the path */ size_t name_len; /* Length of the name */ unsigned need_sep; /* Flag to indicate if separator is needed */ - H5RS_str_t *ret_value; /* Return value */ + H5RS_str_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -354,7 +354,7 @@ H5RS_str_t * H5G_build_fullpath_refstr_str(H5RS_str_t *prefix_r, const char *name) { const char *prefix; /* Pointer to raw string for path */ - H5RS_str_t *ret_value; + H5RS_str_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -565,7 +565,7 @@ H5G_get_name(const H5G_loc_t *loc, char *name/*out*/, size_t size, hbool_t *cached, hid_t lapl_id, hid_t dxpl_id) { ssize_t len = 0; /* Length of object's name */ - ssize_t ret_value; /* Return value */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1292,7 +1292,7 @@ H5G_get_name_by_addr(hid_t file, hid_t lapl_id, hid_t dxpl_id, const H5O_loc_t * H5G_loc_t root_loc; /* Root group's location */ hbool_t found_obj = FALSE; /* If we found the object */ herr_t status; /* Status from iteration */ - ssize_t ret_value; /* Return value */ + ssize_t ret_value = -1; /* Return value */ /* Portably clear udata struct (before FUNC_ENTER) */ HDmemset(&udata, 0, sizeof(udata)); diff --git a/src/H5Gnode.c b/src/H5Gnode.c index 9c4c962..4d299dc 100644 --- a/src/H5Gnode.c +++ b/src/H5Gnode.c @@ -31,7 +31,7 @@ /* Module Setup */ /****************/ -#define H5G_PACKAGE /*suppress error about including H5Gpkg */ +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ /***********/ @@ -404,7 +404,7 @@ H5G_node_cmp2(void *_lt_key, void *_udata, void *_rt_key) H5G_node_key_t *rt_key = (H5G_node_key_t *) _rt_key; const char *s1, *s2; const char *base; /* Base of heap */ - int ret_value; + int ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR diff --git a/src/H5Gobj.c b/src/H5Gobj.c index 6c7b488..f4c6f94 100644 --- a/src/H5Gobj.c +++ b/src/H5Gobj.c @@ -28,7 +28,7 @@ /* Module Setup */ /****************/ -#define H5G_PACKAGE /*suppress error about including H5Gpkg */ +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ /***********/ @@ -320,8 +320,8 @@ done: htri_t H5G__obj_get_linfo(const H5O_loc_t *grp_oloc, H5O_linfo_t *linfo, hid_t dxpl_id) { - H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ - htri_t ret_value; /* Return value */ + H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE_TAG(dxpl_id, grp_oloc->addr, FAIL) @@ -666,7 +666,7 @@ H5G__obj_iterate(const H5O_loc_t *grp_oloc, { H5O_linfo_t linfo; /* Link info message */ htri_t linfo_exists; /* Whether the link info message exists */ - herr_t ret_value; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE_TAG(dxpl_id, grp_oloc->addr, FAIL) @@ -813,7 +813,7 @@ H5G_obj_get_name_by_idx(const H5O_loc_t *oloc, H5_index_t idx_type, { H5O_linfo_t linfo; /* Link info message */ htri_t linfo_exists; /* Whether the link info message exists */ - ssize_t ret_value; /* Return value */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI_TAG(dxpl_id, oloc->addr, FAIL) diff --git a/src/H5Goh.c b/src/H5Goh.c index bf434ab..e015d19 100644 --- a/src/H5Goh.c +++ b/src/H5Goh.c @@ -17,8 +17,8 @@ /* Module Setup */ /****************/ -#define H5O_PACKAGE /*suppress error about including H5Opkg */ -#define H5G_PACKAGE /*suppress error about including H5Gpkg */ +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ +#define H5O_FRIEND /*suppress error about including H5Opkg */ /***********/ @@ -107,7 +107,7 @@ H5FL_DEFINE(H5G_copy_file_ud_t); static void * H5O_group_get_copy_file_udata(void) { - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -177,7 +177,7 @@ H5O_group_isa(struct H5O_t *oh) { htri_t stab_exists; /* Whether the 'stab' message is in the object header */ htri_t linfo_exists; /* Whether the 'linfo' message is in the object header */ - htri_t ret_value; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -213,7 +213,7 @@ static hid_t H5O_group_open(const H5G_loc_t *obj_loc, hid_t H5_ATTR_UNUSED lapl_id, hid_t dxpl_id, hbool_t app_ref) { H5G_t *grp = NULL; /* Group opened */ - hid_t ret_value; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -254,7 +254,7 @@ H5O_group_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc, hid_t dxpl_id) { H5G_obj_create_t *crt_info = (H5G_obj_create_t *)_crt_info; /* Group creation parameters */ H5G_t *grp = NULL; /* New group created */ - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -302,7 +302,7 @@ static H5O_loc_t * H5O_group_get_oloc(hid_t obj_id) { H5G_t *grp; /* Group opened */ - H5O_loc_t *ret_value; /* Return value */ + H5O_loc_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h index a8bc8a6..4cb6f9b 100644 --- a/src/H5Gpkg.h +++ b/src/H5Gpkg.h @@ -21,7 +21,7 @@ * only within the H5G package. Source files outside the * H5G package should include H5Gprivate.h instead. */ -#ifndef H5G_PACKAGE +#if !(defined H5G_FRIEND || defined H5G_MODULE) #error "Do not include this file outside the H5G package!" #endif @@ -351,8 +351,6 @@ H5_DLL herr_t H5G__traverse_special(const H5G_loc_t *grp_loc, /* * Utility functions */ -H5_DLL herr_t H5G__init(void); -H5_DLL herr_t H5G__term_deprec_interface(void); H5_DLL const char *H5G__component(const char *name, size_t *size_p); /* diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h index a6e0f47..1ab5522 100644 --- a/src/H5Gprivate.h +++ b/src/H5Gprivate.h @@ -101,11 +101,11 @@ } /* If the module using this macro is allowed access to the private variables, access them directly */ -#ifdef H5G_PACKAGE +#ifdef H5G_MODULE #define H5G_MOUNTED(G) ((G)->shared->mounted) -#else /* H5G_PACKAGE */ +#else /* H5G_MODULE */ #define H5G_MOUNTED(G) (H5G_mounted(G)) -#endif /* H5G_PACKAGE */ +#endif /* H5G_MODULE */ /* * During name lookups (see H5G_traverse()) we sometimes want information about diff --git a/src/H5Groot.c b/src/H5Groot.c index 5ec9d3a..ba25f31 100644 --- a/src/H5Groot.c +++ b/src/H5Groot.c @@ -28,8 +28,8 @@ /* Module Setup */ /****************/ -#define H5F_PACKAGE /*suppress error about including H5Fpkg */ -#define H5G_PACKAGE /*suppress error about including H5Gpkg */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ /***********/ diff --git a/src/H5Gstab.c b/src/H5Gstab.c index a5c5d3e..c8e5bc8 100644 --- a/src/H5Gstab.c +++ b/src/H5Gstab.c @@ -22,7 +22,7 @@ /* Module Setup */ /****************/ -#define H5G_PACKAGE /*suppress error about including H5Gpkg */ +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ /***********/ @@ -533,7 +533,7 @@ H5G__stab_iterate(const H5O_loc_t *oloc, hid_t dxpl_id, H5_iter_order_t order, H5HL_t *heap = NULL; /* Local heap for group */ H5O_stab_t stab; /* Info about symbol table */ H5G_link_table_t ltable = {0, NULL}; /* Link table */ - herr_t ret_value; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE_TAG(dxpl_id, oloc->addr, FAIL) @@ -751,7 +751,7 @@ H5G__stab_get_name_by_idx(const H5O_loc_t *oloc, H5_iter_order_t order, hsize_t H5O_stab_t stab; /* Info about local heap & B-tree */ H5G_bt_it_gnbi_t udata; /* Iteration information */ hbool_t udata_valid = FALSE; /* Whether iteration information is valid */ - ssize_t ret_value; /* Return value */ + ssize_t ret_value = -1; /* Return value */ /* Portably clear udata struct (before FUNC_ENTER) */ HDmemset(&udata, 0, sizeof(udata)); @@ -874,7 +874,7 @@ H5G__stab_lookup(const H5O_loc_t *grp_oloc, const char *name, H5O_link_t *lnk, H5G_bt_lkp_t bt_udata; /* Data to pass through B-tree */ H5G_stab_fnd_ud_t udata; /* 'User data' to give to callback */ H5O_stab_t stab; /* Symbol table message */ - htri_t ret_value; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE @@ -1191,7 +1191,7 @@ H5G__stab_get_type_by_idx(H5O_loc_t *oloc, hsize_t idx, hid_t dxpl_id) { H5O_stab_t stab; /* Info about local heap & B-tree */ H5G_bt_it_gtbi_t udata; /* User data for B-tree callback */ - H5G_obj_t ret_value; /* Return value */ + H5G_obj_t ret_value = H5G_UNKNOWN; /* Return value */ FUNC_ENTER_PACKAGE_TAG(dxpl_id, oloc->addr, H5G_UNKNOWN) diff --git a/src/H5Gtest.c b/src/H5Gtest.c index 412389b..b34a8fa 100644 --- a/src/H5Gtest.c +++ b/src/H5Gtest.c @@ -23,7 +23,7 @@ /* Module Setup */ /****************/ -#define H5G_PACKAGE /*suppress error about including H5Gpkg */ +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ #define H5G_TESTING /*suppress warning about H5G testing funcs*/ diff --git a/src/H5Gtraverse.c b/src/H5Gtraverse.c index 3fa09eb..4d84e9f 100644 --- a/src/H5Gtraverse.c +++ b/src/H5Gtraverse.c @@ -28,7 +28,7 @@ /* Module Setup */ /****************/ -#define H5G_PACKAGE /*suppress error about including H5Gpkg */ +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ /***********/ @@ -33,7 +33,8 @@ /* Module Setup */ /****************/ -#define H5HF_PACKAGE /* Suppress error about including H5HFpkg.h */ +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ + /***********/ /* Headers */ @@ -68,6 +69,9 @@ /* Package Variables */ /*********************/ +/* Package initialization variable */ +hbool_t H5_PKG_INIT_VAR = FALSE; + /*****************************/ /* Library Private Variables */ @@ -153,7 +157,7 @@ H5HF_create(H5F_t *f, hid_t dxpl_id, const H5HF_create_t *cparam) H5HF_t *fh = NULL; /* Pointer to new fractal heap */ H5HF_hdr_t *hdr = NULL; /* The fractal heap header information */ haddr_t fh_addr; /* Heap header address */ - H5HF_t *ret_value; /* Return value */ + H5HF_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -220,7 +224,7 @@ H5HF_open(H5F_t *f, hid_t dxpl_id, haddr_t fh_addr) { H5HF_t *fh = NULL; /* Pointer to new fractal heap */ H5HF_hdr_t *hdr = NULL; /* The fractal heap header information */ - H5HF_t *ret_value; /* Return value */ + H5HF_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) diff --git a/src/H5HFbtree2.c b/src/H5HFbtree2.c index 0229ebe..37aa53c 100644 --- a/src/H5HFbtree2.c +++ b/src/H5HFbtree2.c @@ -28,7 +28,7 @@ /* Module Setup */ /****************/ -#define H5HF_PACKAGE /*suppress error about including H5HFpkg */ +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ /***********/ @@ -209,7 +209,7 @@ H5HF_huge_bt2_crt_context(void *_f) { H5F_t *f = (H5F_t *)_f; /* User data for building callback context */ H5HF_huge_bt2_ctx_t *ctx; /* Callback context structure */ - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -819,7 +819,7 @@ H5HF_huge_bt2_dir_compare(const void *_rec1, const void *_rec2) { const H5HF_huge_bt2_dir_rec_t *rec1 = (const H5HF_huge_bt2_dir_rec_t *)_rec1; const H5HF_huge_bt2_dir_rec_t *rec2 = (const H5HF_huge_bt2_dir_rec_t *)_rec2; - herr_t ret_value; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1044,7 +1044,7 @@ H5HF_huge_bt2_filt_dir_compare(const void *_rec1, const void *_rec2) { const H5HF_huge_bt2_filt_dir_rec_t *rec1 = (const H5HF_huge_bt2_filt_dir_rec_t *)_rec1; const H5HF_huge_bt2_filt_dir_rec_t *rec2 = (const H5HF_huge_bt2_filt_dir_rec_t *)_rec2; - herr_t ret_value; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR diff --git a/src/H5HFcache.c b/src/H5HFcache.c index 1ba0c02..ed45457 100644 --- a/src/H5HFcache.c +++ b/src/H5HFcache.c @@ -28,7 +28,7 @@ /* Module Setup */ /****************/ -#define H5HF_PACKAGE /*suppress error about including H5HFpkg */ +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ /***********/ @@ -483,7 +483,7 @@ H5HF__cache_hdr_deserialize(const void *_image, size_t len, void *_udata, size_t size; /* Header size */ uint32_t stored_chksum; /* Stored metadata checksum value */ uint8_t heap_flags; /* Status flags for heap */ - void * ret_value; /* Return value */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -1025,7 +1025,7 @@ H5HF__cache_iblock_deserialize(const void *_image, size_t len, void *_udata, haddr_t heap_addr; /* Address of heap header in the file */ uint32_t stored_chksum; /* Stored metadata checksum value */ unsigned u; /* Local index variable */ - void * ret_value; /* Return value */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -1869,7 +1869,7 @@ H5HF__cache_dblock_deserialize(const void *_image, size_t len, void *_udata, H5HF_direct_t *dblock = NULL; /* Direct block info */ const uint8_t *image; /* Pointer into raw data buffer */ haddr_t heap_addr; /* Address of heap header in the file */ - void * ret_value; /* Return value */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC diff --git a/src/H5HFdbg.c b/src/H5HFdbg.c index 5183b67..3cb4d54 100644 --- a/src/H5HFdbg.c +++ b/src/H5HFdbg.c @@ -28,7 +28,7 @@ /* Module Setup */ /****************/ -#define H5HF_PACKAGE /*suppress error about including H5HFpkg */ +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ #define H5HF_DEBUGGING /* Need access to fractal heap debugging routines */ /***********/ diff --git a/src/H5HFdblock.c b/src/H5HFdblock.c index 0d5172c..eb4f155 100644 --- a/src/H5HFdblock.c +++ b/src/H5HFdblock.c @@ -28,7 +28,8 @@ /* Module Setup */ /****************/ -#define H5HF_PACKAGE /*suppress error about including H5HFpkg */ +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ + /***********/ /* Headers */ @@ -447,7 +448,7 @@ H5HF_man_dblock_protect(H5HF_hdr_t *hdr, hid_t dxpl_id, haddr_t dblock_addr, { H5HF_direct_t *dblock; /* Direct block from cache */ H5HF_dblock_cache_ud_t udata; /* parent and other infor for deserializing direct block */ - H5HF_direct_t *ret_value; /* Return value */ + H5HF_direct_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT diff --git a/src/H5HFdtable.c b/src/H5HFdtable.c index c523396..3ceb6f5 100644 --- a/src/H5HFdtable.c +++ b/src/H5HFdtable.c @@ -28,7 +28,8 @@ /* Module Setup */ /****************/ -#define H5HF_PACKAGE /*suppress error about including H5HFpkg */ +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ + /***********/ /* Headers */ @@ -240,7 +241,7 @@ H5HF_dtable_dest(H5HF_dtable_t *dtable) unsigned H5HF_dtable_size_to_row(const H5HF_dtable_t *dtable, size_t block_size) { - unsigned row; /* Row where block will fit */ + unsigned row = 0; /* Row where block will fit */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -274,7 +275,7 @@ H5HF_dtable_size_to_row(const H5HF_dtable_t *dtable, size_t block_size) unsigned H5HF_dtable_size_to_rows(const H5HF_dtable_t *dtable, hsize_t size) { - unsigned rows; /* # of rows required for indirect block */ + unsigned rows = 0; /* # of rows required for indirect block */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -310,7 +311,7 @@ H5HF_dtable_span_size(const H5HF_dtable_t *dtable, unsigned start_row, unsigned end_row; /* Row for last block covered */ unsigned end_col; /* Column for last block covered */ unsigned end_entry; /* Entry for last block covered */ - hsize_t acc_span_size; /* Accumulated span size */ + hsize_t acc_span_size = 0; /* Accumulated span size */ FUNC_ENTER_NOAPI_NOINIT_NOERR diff --git a/src/H5HFhdr.c b/src/H5HFhdr.c index 814d524..ec60322 100644 --- a/src/H5HFhdr.c +++ b/src/H5HFhdr.c @@ -28,7 +28,8 @@ /* Module Setup */ /****************/ -#define H5HF_PACKAGE /*suppress error about including H5HFpkg */ +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ + /***********/ /* Headers */ @@ -110,7 +111,7 @@ H5HF_hdr_t * H5HF_hdr_alloc(H5F_t *f) { H5HF_hdr_t *hdr = NULL; /* Shared fractal heap header */ - H5HF_hdr_t *ret_value; /* Return value */ + H5HF_hdr_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -343,7 +344,7 @@ H5HF_hdr_create(H5F_t *f, hid_t dxpl_id, const H5HF_create_t *cparam) { H5HF_hdr_t *hdr = NULL; /* The new fractal heap header information */ size_t dblock_overhead; /* Direct block's overhead */ - haddr_t ret_value; /* Return value */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -534,7 +535,7 @@ H5HF_hdr_protect(H5F_t *f, hid_t dxpl_id, haddr_t addr, unsigned flags) { H5HF_hdr_cache_ud_t cache_udata; /* User-data for callback */ H5HF_hdr_t *hdr; /* Fractal heap header */ - H5HF_hdr_t *ret_value; /* Return value */ + H5HF_hdr_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT diff --git a/src/H5HFhuge.c b/src/H5HFhuge.c index 7c3b5f9..2204343 100644 --- a/src/H5HFhuge.c +++ b/src/H5HFhuge.c @@ -28,7 +28,7 @@ /* Module Setup */ /****************/ -#define H5HF_PACKAGE /*suppress error about including H5HFpkg */ +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ /***********/ @@ -264,7 +264,7 @@ static hsize_t H5HF_huge_new_id(H5HF_hdr_t *hdr) { hsize_t new_id; /* New object's ID */ - hsize_t ret_value; /* Return value */ + hsize_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT diff --git a/src/H5HFiblock.c b/src/H5HFiblock.c index 547aaf0..29f4662 100644 --- a/src/H5HFiblock.c +++ b/src/H5HFiblock.c @@ -28,7 +28,8 @@ /* Module Setup */ /****************/ -#define H5HF_PACKAGE /*suppress error about including H5HFpkg */ +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ + /***********/ /* Headers */ @@ -1171,7 +1172,7 @@ H5HF_man_iblock_protect(H5HF_hdr_t *hdr, hid_t dxpl_id, haddr_t iblock_addr, H5HF_parent_t par_info; /* Parent info for loading block */ H5HF_indirect_t *iblock = NULL; /* Indirect block from cache */ hbool_t should_protect = FALSE; /* Whether we should protect the indirect block or not */ - H5HF_indirect_t *ret_value; /* Return value */ + H5HF_indirect_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT diff --git a/src/H5HFint.c b/src/H5HFint.c index 57d75cf..61c357c 100644 --- a/src/H5HFint.c +++ b/src/H5HFint.c @@ -28,7 +28,7 @@ /* Module Declaration */ /**********************/ -#define H5HF_PACKAGE +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ /***********************/ diff --git a/src/H5HFiter.c b/src/H5HFiter.c index 262a9ee..55a8532 100644 --- a/src/H5HFiter.c +++ b/src/H5HFiter.c @@ -28,7 +28,8 @@ /* Module Setup */ /****************/ -#define H5HF_PACKAGE /*suppress error about including H5HFpkg */ +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ + /***********/ /* Headers */ diff --git a/src/H5HFman.c b/src/H5HFman.c index 5f95a91..fabf3c9 100644 --- a/src/H5HFman.c +++ b/src/H5HFman.c @@ -28,7 +28,8 @@ /* Module Setup */ /****************/ -#define H5HF_PACKAGE /*suppress error about including H5HFpkg */ +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ + /***********/ /* Headers */ diff --git a/src/H5HFmodule.h b/src/H5HFmodule.h new file mode 100644 index 0000000..e3274ce --- /dev/null +++ b/src/H5HFmodule.h @@ -0,0 +1,35 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Quincey Koziol <koziol@hdfgroup.org> + * Saturday, September 12, 2015 + * + * Purpose: This file contains declarations which define macros for the + * H5HF package. Including this header means that the source file + * is part of the H5HF package. + */ +#ifndef _H5HFmodule_H +#define _H5HFmodule_H + +/* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error + * reporting macros. + */ +#define H5HF_MODULE +#define H5_MY_PKG H5HF +#define H5_MY_PKG_ERR H5E_HEAP +#define H5_MY_PKG_INIT NO + +#endif /* _H5HFmodule_H */ + diff --git a/src/H5HFpkg.h b/src/H5HFpkg.h index cb5488b..90c8081 100644 --- a/src/H5HFpkg.h +++ b/src/H5HFpkg.h @@ -21,7 +21,7 @@ * the H5HF package. Source files outside the H5HF package should * include H5HFprivate.h instead. */ -#ifndef H5HF_PACKAGE +#if !(defined H5HF_FRIEND || defined H5HF_MODULE) #error "Do not include this file outside the H5HF package!" #endif diff --git a/src/H5HFsection.c b/src/H5HFsection.c index 6da456b..3150413 100644 --- a/src/H5HFsection.c +++ b/src/H5HFsection.c @@ -25,7 +25,8 @@ /* Module Setup */ /****************/ -#define H5HF_PACKAGE /*suppress error about including H5HFpkg */ +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ + /***********/ /* Headers */ @@ -407,8 +408,8 @@ static H5HF_free_section_t * H5HF_sect_node_new(unsigned sect_type, haddr_t sect_addr, hsize_t sect_size, H5FS_section_state_t sect_state) { - H5HF_free_section_t *new_sect; /* New section */ - H5HF_free_section_t *ret_value; /* Return value */ + H5HF_free_section_t *new_sect; /* New section */ + H5HF_free_section_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -489,7 +490,7 @@ H5HF_sect_single_new(hsize_t sect_off, size_t sect_size, H5HF_indirect_t *parent, unsigned par_entry) { H5HF_free_section_t *sect = NULL; /* 'Single' free space section to add */ - H5HF_free_section_t *ret_value; /* Return value */ + H5HF_free_section_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -866,7 +867,7 @@ H5HF_sect_single_deserialize(const H5FS_section_class_t H5_ATTR_UNUSED *cls, hsize_t sect_size, unsigned H5_ATTR_UNUSED *des_flags) { H5HF_free_section_t *new_sect; /* New section */ - H5FS_section_info_t *ret_value; /* Return value */ + H5FS_section_info_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1261,7 +1262,7 @@ H5HF_sect_row_create(haddr_t sect_off, hsize_t sect_size, hbool_t is_first, unsigned row, unsigned col, unsigned nentries, H5HF_free_section_t *under_sect) { H5HF_free_section_t *sect = NULL; /* 'Row' section created */ - H5HF_free_section_t *ret_value; /* Return value */ + H5HF_free_section_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1513,7 +1514,7 @@ done: H5HF_indirect_t * H5HF_sect_row_get_iblock(H5HF_free_section_t *sect) { - H5HF_indirect_t *ret_value; /* Return value */ + H5HF_indirect_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1675,7 +1676,7 @@ H5HF_sect_row_deserialize(const H5FS_section_class_t *cls, hid_t dxpl_id, unsigned *des_flags) { H5HF_hdr_t *hdr; /* Fractal heap header */ - H5FS_section_info_t *ret_value; /* Return value */ + H5FS_section_info_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -2102,7 +2103,7 @@ H5HF_sect_row_debug(const H5FS_section_info_t *_sect, static hsize_t H5HF_sect_indirect_iblock_off(const H5HF_free_section_t *sect) { - hsize_t ret_value; /* Return value */ + hsize_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -2133,7 +2134,7 @@ H5HF_sect_indirect_iblock_off(const H5HF_free_section_t *sect) static H5HF_free_section_t * H5HF_sect_indirect_top(H5HF_free_section_t *sect) { - H5HF_free_section_t *ret_value; /* Return value */ + H5HF_free_section_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -2242,7 +2243,7 @@ H5HF_sect_indirect_new(H5HF_hdr_t *hdr, haddr_t sect_off, hsize_t sect_size, unsigned nentries) { H5HF_free_section_t *sect = NULL; /* 'Indirect' free space section to add */ - H5HF_free_section_t *ret_value; /* Return value */ + H5HF_free_section_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -2313,7 +2314,7 @@ H5HF_sect_indirect_for_row(H5HF_hdr_t *hdr, H5HF_indirect_t *iblock, H5HF_free_section_t *row_sect) { H5HF_free_section_t *sect = NULL; /* 'Indirect' free space section to add */ - H5HF_free_section_t *ret_value; /* Return value */ + H5HF_free_section_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -3945,7 +3946,7 @@ H5HF_sect_indirect_deserialize(H5HF_hdr_t *hdr, hid_t dxpl_id, unsigned end_entry; /* End entry in indirect block */ unsigned end_row; /* End row in indirect block */ unsigned end_col; /* End column in indirect block */ - H5FS_section_info_t *ret_value; /* Return value */ + H5FS_section_info_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT diff --git a/src/H5HFspace.c b/src/H5HFspace.c index 7fb0dd4..20057e4 100644 --- a/src/H5HFspace.c +++ b/src/H5HFspace.c @@ -28,7 +28,8 @@ /* Module Setup */ /****************/ -#define H5HF_PACKAGE /*suppress error about including H5HFpkg */ +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ + /***********/ /* Headers */ @@ -216,7 +217,7 @@ htri_t H5HF_space_find(H5HF_hdr_t *hdr, hid_t dxpl_id, hsize_t request, H5HF_free_section_t **node) { htri_t node_found = FALSE; /* Whether an existing free list node was found */ - htri_t ret_value; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT diff --git a/src/H5HFstat.c b/src/H5HFstat.c index 802a332..b54a191 100644 --- a/src/H5HFstat.c +++ b/src/H5HFstat.c @@ -24,7 +24,8 @@ /* Module Setup */ /****************/ -#define H5HF_PACKAGE /*suppress error about including H5HFpkg */ +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ + /***********/ /* Headers */ diff --git a/src/H5HFtest.c b/src/H5HFtest.c index 39a08c1..3e4e5d2 100644 --- a/src/H5HFtest.c +++ b/src/H5HFtest.c @@ -24,9 +24,10 @@ /* Module Setup */ /****************/ -#define H5HF_PACKAGE /*suppress error about including H5HFpkg */ +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ #define H5HF_TESTING /*suppress warning about H5HF testing funcs*/ + /***********/ /* Headers */ /***********/ @@ -244,7 +245,7 @@ done: unsigned H5HF_get_max_root_rows(const H5HF_t *fh) { - unsigned ret_value; /* Return value */ + unsigned ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -275,7 +276,7 @@ H5HF_get_max_root_rows(const H5HF_t *fh) unsigned H5HF_get_dtable_width_test(const H5HF_t *fh) { - unsigned ret_value; /* Return value */ + unsigned ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -306,7 +307,7 @@ H5HF_get_dtable_width_test(const H5HF_t *fh) unsigned H5HF_get_dtable_max_drows_test(const H5HF_t *fh) { - unsigned ret_value; /* Return value */ + unsigned ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -341,7 +342,7 @@ H5HF_get_dtable_max_drows_test(const H5HF_t *fh) unsigned H5HF_get_iblock_max_drows_test(const H5HF_t *fh, unsigned pos) { - unsigned ret_value; /* Return value */ + unsigned ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -374,7 +375,7 @@ H5HF_get_iblock_max_drows_test(const H5HF_t *fh, unsigned pos) hsize_t H5HF_get_dblock_size_test(const H5HF_t *fh, unsigned row) { - hsize_t ret_value; /* Return value */ + hsize_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -406,7 +407,7 @@ H5HF_get_dblock_size_test(const H5HF_t *fh, unsigned row) hsize_t H5HF_get_dblock_free_test(const H5HF_t *fh, unsigned row) { - hsize_t ret_value; /* Return value */ + hsize_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR diff --git a/src/H5HFtiny.c b/src/H5HFtiny.c index 27ab443..8c321bc 100644 --- a/src/H5HFtiny.c +++ b/src/H5HFtiny.c @@ -28,7 +28,7 @@ /* Module Setup */ /****************/ -#define H5HF_PACKAGE /* suppress error about including H5HFpkg */ +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ /***********/ @@ -41,7 +41,7 @@ /* Module Setup */ /****************/ -#define H5HG_PACKAGE /*suppress error about including H5HGpkg */ +#include "H5HGmodule.h" /* This source code file is part of the H5HG module */ /***********/ @@ -91,6 +91,9 @@ static haddr_t H5HG_create(H5F_t *f, hid_t dxpl_id, size_t size); /* 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); @@ -249,7 +252,7 @@ H5HG_heap_t * H5HG_protect(H5F_t *f, hid_t dxpl_id, haddr_t addr, unsigned flags) { H5HG_heap_t *heap; /* Global heap */ - H5HG_heap_t *ret_value; /* Return value */ + H5HG_heap_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -299,7 +302,7 @@ H5HG_alloc(H5F_t *f, H5HG_heap_t *heap, size_t size, unsigned *heap_flags_ptr) size_t idx; uint8_t *p; size_t need = H5HG_SIZEOF_OBJHDR(f) + H5HG_ALIGN(size); - size_t ret_value; /* Return value */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -612,7 +615,7 @@ H5HG_read(H5F_t *f, hid_t dxpl_id, H5HG_t *hobj, void *object/*out*/, size_t size; /* Size of the heap object */ uint8_t *p; /* Pointer to object in heap buffer */ void *orig_object = object; /* Keep a copy of the original object pointer */ - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_TAG(dxpl_id, H5AC__GLOBALHEAP_TAG, NULL) @@ -684,7 +687,7 @@ H5HG_link(H5F_t *f, hid_t dxpl_id, const H5HG_t *hobj, int adjust) { H5HG_heap_t *heap = NULL; unsigned heap_flags = H5AC__NO_FLAGS_SET; - int ret_value; /* Return value */ + int ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI_TAG(dxpl_id, H5AC__GLOBALHEAP_TAG, FAIL) diff --git a/src/H5HGcache.c b/src/H5HGcache.c index c5d5517..511937d 100644 --- a/src/H5HGcache.c +++ b/src/H5HGcache.c @@ -28,7 +28,7 @@ /* Module Setup */ /****************/ -#define H5HG_PACKAGE /*suppress error about including H5HGpkg */ +#include "H5HGmodule.h" /* This source code file is part of the H5HG module */ /***********/ @@ -197,7 +197,7 @@ H5HG__cache_heap_deserialize(const void *_image, size_t len, void *_udata, H5F_t *f = (H5F_t *)_udata; /* File pointer -- obtained from user data */ H5HG_heap_t *heap = NULL; /* New global heap */ uint8_t *image; /* Pointer to image to decode */ - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC diff --git a/src/H5HGdbg.c b/src/H5HGdbg.c index c79aac8..6013de5 100644 --- a/src/H5HGdbg.c +++ b/src/H5HGdbg.c @@ -23,7 +23,7 @@ /* Module Setup */ /****************/ -#define H5HG_PACKAGE /*suppress error about including H5HGpkg */ +#include "H5HGmodule.h" /* This source code file is part of the H5HG module */ /***********/ diff --git a/src/H5HGmodule.h b/src/H5HGmodule.h new file mode 100644 index 0000000..aa34f29 --- /dev/null +++ b/src/H5HGmodule.h @@ -0,0 +1,35 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Quincey Koziol <koziol@hdfgroup.org> + * Saturday, September 12, 2015 + * + * Purpose: This file contains declarations which define macros for the + * H5HG package. Including this header means that the source file + * is part of the H5HG package. + */ +#ifndef _H5HGmodule_H +#define _H5HGmodule_H + +/* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error + * reporting macros. + */ +#define H5HG_MODULE +#define H5_MY_PKG H5HG +#define H5_MY_PKG_ERR H5E_HEAP +#define H5_MY_PKG_INIT NO + +#endif /* _H5HGmodule_H */ + diff --git a/src/H5HGpkg.h b/src/H5HGpkg.h index 5d00cbd..e566ece 100644 --- a/src/H5HGpkg.h +++ b/src/H5HGpkg.h @@ -21,7 +21,7 @@ * only within the H5HG package. Source files outside the * H5HG package should include H5HGprivate.h instead. */ -#ifndef H5HG_PACKAGE +#if !(defined H5HG_FRIEND || defined H5HG_MODULE) #error "Do not include this file outside the H5HG package!" #endif diff --git a/src/H5HGprivate.h b/src/H5HGprivate.h index 3765c47..b090d4c 100644 --- a/src/H5HGprivate.h +++ b/src/H5HGprivate.h @@ -44,15 +44,15 @@ typedef struct H5HG_heap_t H5HG_heap_t; #define H5HG_MAXSIZE 65536 /* If the module using this macro is allowed access to the private variables, access them directly */ -#ifdef H5HG_PACKAGE +#ifdef H5HG_MODULE #define H5HG_ADDR(H) ((H)->addr) #define H5HG_SIZE(H) ((H)->size) #define H5HG_FREE_SIZE(H) ((H)->obj[0].size) -#else /* H5HG_PACKAGE */ +#else /* H5HG_MODULE */ #define H5HG_ADDR(H) (H5HG_get_addr(H)) #define H5HG_SIZE(H) (H5HG_get_size(H)) #define H5HG_FREE_SIZE(H) (H5HG_get_free_size(H)) -#endif /* H5HG_PACKAGE */ +#endif /* H5HG_MODULE */ /* Main global heap routines */ diff --git a/src/H5HGquery.c b/src/H5HGquery.c index a1b3777..d07edcc 100644 --- a/src/H5HGquery.c +++ b/src/H5HGquery.c @@ -25,7 +25,7 @@ /* Module Setup */ /****************/ -#define H5HG_PACKAGE /*suppress error about including H5HGpkg */ +#include "H5HGmodule.h" /* This source code file is part of the H5HG module */ /***********/ @@ -29,7 +29,7 @@ /* Module Setup */ /****************/ -#define H5HL_PACKAGE /* Suppress error about including H5HLpkg */ +#include "H5HLmodule.h" /* This source code file is part of the H5HL module */ /***********/ @@ -72,6 +72,9 @@ 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/H5HLcache.c b/src/H5HLcache.c index cb8dc49..14442f6 100644 --- a/src/H5HLcache.c +++ b/src/H5HLcache.c @@ -28,7 +28,7 @@ /* Module Setup */ /****************/ -#define H5HL_PACKAGE /* Suppress error about including H5HLpkg */ +#include "H5HLmodule.h" /* This source code file is part of the H5HL module */ /***********/ @@ -231,11 +231,13 @@ END_FUNC(STATIC) /* end H5HL__fl_deserialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC_VOID(STATIC, NOERR, -H5HL__fl_serialize(const H5HL_t *heap)) - +static void +H5HL__fl_serialize(const H5HL_t *heap) +{ H5HL_free_t *fl; /* Pointer to heap free list node */ + FUNC_ENTER_STATIC_NOERR + /* check arguments */ HDassert(heap); @@ -254,7 +256,9 @@ H5HL__fl_serialize(const H5HL_t *heap)) H5F_ENCODE_LENGTH_LEN(image, fl->size, heap->sizeof_size) } /* end for */ -END_FUNC_VOID(STATIC) /* end H5HL__fl_serialize() */ + FUNC_LEAVE_NOAPI_VOID + +} /* end H5HL__fl_serialize() */ /*------------------------------------------------------------------------- @@ -367,7 +371,7 @@ H5HL__cache_prefix_deserialize(const void *_image, size_t len, void *_udata, H5HL_prfx_t *prfx = NULL; /* Heap prefix deserialized */ const uint8_t *image = (const uint8_t *)_image; /* Pointer into decoding buffer */ H5HL_cache_prfx_ud_t *udata = (H5HL_cache_prfx_ud_t *)_udata; /* User data for callback */ - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -744,7 +748,7 @@ H5HL__cache_datablock_deserialize(const void *image, size_t len, void *_udata, { H5HL_dblk_t *dblk = NULL; /* Local heap data block deserialized */ H5HL_cache_dblk_ud_t *udata = (H5HL_cache_dblk_ud_t *)_udata; /* User data for callback */ - void * ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC diff --git a/src/H5HLdbg.c b/src/H5HLdbg.c index f94b0cc..19b828d 100644 --- a/src/H5HLdbg.c +++ b/src/H5HLdbg.c @@ -18,8 +18,16 @@ * * Purpose: Local Heap object debugging functions. */ -#define H5HL_PACKAGE /* Suppress error about including H5HLpkg */ +/****************/ +/* Module Setup */ +/****************/ + +#include "H5HLmodule.h" /* This source code file is part of the H5HL module */ + +/***********/ +/* Headers */ +/***********/ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ diff --git a/src/H5HLdblk.c b/src/H5HLdblk.c index 8878351..6a4d8ce 100644 --- a/src/H5HLdblk.c +++ b/src/H5HLdblk.c @@ -28,7 +28,7 @@ /* Module Setup */ /****************/ -#define H5HL_PACKAGE /* Suppress error about including H5HLpkg */ +#include "H5HLmodule.h" /* This source code file is part of the H5HL module */ /***********/ diff --git a/src/H5HLint.c b/src/H5HLint.c index 41ded17..361a64d 100644 --- a/src/H5HLint.c +++ b/src/H5HLint.c @@ -28,7 +28,7 @@ /* Module Setup */ /****************/ -#define H5HL_PACKAGE /* Suppress error about including H5HLpkg */ +#include "H5HLmodule.h" /* This source code file is part of the H5HL module */ /***********/ @@ -124,7 +124,7 @@ END_FUNC(PKG) /* end H5HL__new() */ /*------------------------------------------------------------------------- - * Function: H5HL__inc_rc + * Function: H5HL__inc_rc * * Purpose: Increment ref. count on heap * @@ -149,7 +149,11 @@ END_FUNC(PKG) /* end H5HL__inc_rc() */ /*------------------------------------------------------------------------- +<<<<<<< .working * Function: H5HL__dec_rc +======= + * Function: H5HL__dec_rc +>>>>>>> .merge-right.r27768 * * Purpose: Decrement ref. count on heap * @@ -280,3 +284,4 @@ CATCH /* No special processing on errors */ END_FUNC(PKG) /* end H5HL__destroy_flush_depend() */ + diff --git a/src/H5HLmodule.h b/src/H5HLmodule.h new file mode 100644 index 0000000..b38c077 --- /dev/null +++ b/src/H5HLmodule.h @@ -0,0 +1,35 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Quincey Koziol <koziol@hdfgroup.org> + * Saturday, September 12, 2015 + * + * Purpose: This file contains declarations which define macros for the + * H5HL package. Including this header means that the source file + * is part of the H5HL package. + */ +#ifndef _H5HLmodule_H +#define _H5HLmodule_H + +/* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error + * reporting macros. + */ +#define H5HL_MODULE +#define H5_MY_PKG H5HL +#define H5_MY_PKG_ERR H5E_HEAP +#define H5_MY_PKG_INIT NO + +#endif /* _H5HLmodule_H */ + diff --git a/src/H5HLpkg.h b/src/H5HLpkg.h index 77d6255..d25d8aa 100644 --- a/src/H5HLpkg.h +++ b/src/H5HLpkg.h @@ -21,7 +21,7 @@ * only within the H5HL package. Source files outside the * H5HL package should include H5HLprivate.h instead. */ -#ifndef H5HL_PACKAGE +#if !(defined H5HL_FRIEND || defined H5HL_MODULE) #error "Do not include this file outside the H5HL package!" #endif diff --git a/src/H5HLprfx.c b/src/H5HLprfx.c index 1f7a1a1..66c4dad 100644 --- a/src/H5HLprfx.c +++ b/src/H5HLprfx.c @@ -28,7 +28,7 @@ /* Module Setup */ /****************/ -#define H5HL_PACKAGE /* Suppress error about including H5HLpkg */ +#include "H5HLmodule.h" /* This source code file is part of the H5HL module */ /***********/ @@ -35,10 +35,7 @@ * 5/18/04 - Expanded to allow registration of new types at run-time */ -#define H5I_PACKAGE /*suppress error about including H5Ipkg */ - -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5I_init_interface +#include "H5Imodule.h" /* This source code file is part of the H5I module */ #include "H5private.h" /* Generic Functions */ @@ -55,7 +52,7 @@ #ifndef H5I_DEBUG_OUTPUT #include "H5Gprivate.h" /* Groups */ #else /* H5I_DEBUG_OUTPUT */ -#define H5G_PACKAGE /*suppress error message about including H5Gpkg.h */ +#define H5G_FRIEND /*suppress error about including H5Gpkg */ #include "H5Gpkg.h" /* Groups */ #include "H5Dprivate.h" /* Datasets */ #include "H5Tprivate.h" /* Datatypes */ @@ -106,6 +103,9 @@ typedef struct { hbool_t app_ref; /* Whether this is an appl. ref. call */ } H5I_clear_type_ud_t; +/* Package initialization variable */ +hbool_t H5_PKG_INIT_VAR = FALSE; + /*-------------------- Locally scoped variables -----------------------------*/ /* Array of pointers to atomic types */ @@ -141,29 +141,8 @@ static herr_t H5I__debug(H5I_type_t type); #endif /* H5I_DEBUG_OUTPUT */ -/*-------------------------------------------------------------------------- -NAME - H5I_init_interface -- Initialize interface-specific information -USAGE - herr_t H5I_init_interface() - -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. - ---------------------------------------------------------------------------*/ -static herr_t -H5I_init_interface(void) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5I_init_interface() */ - - /*------------------------------------------------------------------------- - * Function: H5I_term_interface + * Function: H5I_term_package * * Purpose: Terminate the H5I interface: release all memory, reset all * global variables to initial values. This only happens if all @@ -179,20 +158,20 @@ H5I_init_interface(void) *------------------------------------------------------------------------- */ int -H5I_term_interface(void) +H5I_term_package(void) { - H5I_id_type_t *type_ptr; - H5I_type_t type; - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5_interface_initialize_g) { + if(H5_PKG_INIT_VAR) { + H5I_id_type_t *type_ptr; /* Pointer to ID type */ + H5I_type_t type; /* Type of ID */ + /* How many types are still being used? */ - for(type = (H5I_type_t)0; type < H5I_next_type; H5_INC_ENUM(H5I_type_t, type)) { + for(type = (H5I_type_t)0; type < H5I_next_type; H5_INC_ENUM(H5I_type_t, type)) if((type_ptr = H5I_id_type_list_g[type]) && type_ptr->ids) n++; - } /* end for */ /* If no types are used then clean up */ if(0 == n) { @@ -202,16 +181,18 @@ H5I_term_interface(void) HDassert(NULL == type_ptr->ids); type_ptr = H5FL_FREE(H5I_id_type_t, type_ptr); H5I_id_type_list_g[type] = NULL; + n++; } /* end if */ } /* end for */ - } /* end if */ - /* Mark interface closed */ - H5_interface_initialize_g = 0; + /* Mark interface closed */ + if(0 == n) + H5_PKG_INIT_VAR = FALSE; + } /* end if */ } /* end if */ FUNC_LEAVE_NOAPI(n) -} /* end H5I_term_interface() */ +} /* end H5I_term_package() */ /*------------------------------------------------------------------------- @@ -238,9 +219,9 @@ H5I_term_interface(void) H5I_type_t H5Iregister_type(size_t hash_size, unsigned reserved, H5I_free_t free_func) { - H5I_class_t *cls = NULL; /* New ID class */ - H5I_type_t new_type; /* New ID type value */ - H5I_type_t ret_value; /* Return value */ + H5I_class_t *cls = NULL; /* New ID class */ + H5I_type_t new_type; /* New ID type value */ + H5I_type_t ret_value = H5I_BADID; /* Return value */ FUNC_ENTER_API(H5I_BADID) H5TRACE3("It", "zIux", hash_size, reserved, free_func); @@ -290,10 +271,9 @@ H5Iregister_type(size_t hash_size, unsigned reserved, H5I_free_t free_func) done: /* Clean up on error */ - if(ret_value < 0) { + if(ret_value < 0) if(cls) cls = H5FL_FREE(H5I_class_t, cls); - } /* end if */ FUNC_LEAVE_API(ret_value) } /* end H5Iregister_type() */ @@ -467,8 +447,8 @@ done: int64_t H5I_nmembers(H5I_type_t type) { - H5I_id_type_t *type_ptr = NULL; - int64_t ret_value; + H5I_id_type_t *type_ptr; /* Pointer to the ID type */ + int64_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -504,7 +484,7 @@ done: herr_t H5Iclear_type(H5I_type_t type, hbool_t force) { - herr_t ret_value; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "Itb", type, force); @@ -625,7 +605,6 @@ H5I__clear_type_cb(void *_id, void H5_ATTR_UNUSED *key, void *_udata) } /* end if */ } /* end if */ - FUNC_LEAVE_NOAPI(ret_value) } /* end H5I__clear_type_cb() */ @@ -649,7 +628,7 @@ H5I__clear_type_cb(void *_id, void H5_ATTR_UNUSED *key, void *_udata) herr_t H5Idestroy_type(H5I_type_t type) { - herr_t ret_value; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "It", type); @@ -731,7 +710,7 @@ done: hid_t H5Iregister(H5I_type_t type, const void *object) { - hid_t ret_value; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE2("i", "It*x", type, object); @@ -895,8 +874,8 @@ done: void * H5I_subst(hid_t id, const void *new_object) { - H5I_id_info_t *id_ptr; /* Ptr to the atom */ - void *ret_value; /* Return value */ + H5I_id_info_t *id_ptr; /* Pointer to the atom */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -935,7 +914,7 @@ H5I_object(hid_t id) H5I_id_info_t *id_ptr; /*ptr to the new atom */ void *ret_value = NULL; /*return value */ - FUNC_ENTER_NOAPI(NULL) + FUNC_ENTER_NOAPI_NOERR /* General lookup of the ID */ if(NULL != (id_ptr = H5I__find_id(id))) { @@ -944,7 +923,6 @@ H5I_object(hid_t id) ret_value = (void *)id_ptr->obj_ptr; } /* end if */ -done: FUNC_LEAVE_NOAPI(ret_value) } /* end if */ @@ -969,7 +947,7 @@ done: void * H5Iobject_verify(hid_t id, H5I_type_t id_type) { - void * ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_API(NULL) H5TRACE2("*x", "iIt", id, id_type); @@ -1008,7 +986,7 @@ H5I_object_verify(hid_t id, H5I_type_t id_type) H5I_id_info_t *id_ptr = NULL; /*ptr to the new atom */ void *ret_value = NULL; /*return value */ - FUNC_ENTER_NOAPI(NULL) + FUNC_ENTER_NOAPI_NOERR HDassert(id_type >= 1 && id_type < H5I_next_type); @@ -1019,7 +997,6 @@ H5I_object_verify(hid_t id, H5I_type_t id_type) ret_value = (void *)id_ptr->obj_ptr; } /* end if */ -done: FUNC_LEAVE_NOAPI(ret_value) } /* H5I_object_verify() */ @@ -1043,16 +1020,15 @@ done: H5I_type_t H5I_get_type(hid_t id) { - H5I_type_t ret_value = H5I_BADID; + H5I_type_t ret_value = H5I_BADID; /* Return value */ - FUNC_ENTER_NOAPI(H5I_BADID) + FUNC_ENTER_NOAPI_NOERR if(id > 0) ret_value = H5I_TYPE(id); HDassert(ret_value >= H5I_BADID && ret_value < H5I_next_type); -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5I_get_type() */ @@ -1075,7 +1051,7 @@ done: H5I_type_t H5Iget_type(hid_t id) { - H5I_type_t ret_value = H5I_BADID; /* Return value */ + H5I_type_t ret_value = H5I_BADID; /* Return value */ FUNC_ENTER_API(H5I_BADID) H5TRACE1("It", "i", id); @@ -1110,7 +1086,7 @@ done: void * H5Iremove_verify(hid_t id, H5I_type_t id_type) { - void * ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_API(NULL) H5TRACE2("*x", "iIt", id, id_type); @@ -1177,8 +1153,8 @@ H5I__remove_verify(hid_t id, H5I_type_t id_type) static void * H5I__remove_common(H5I_id_type_t *type_ptr, hid_t id) { - H5I_id_info_t *curr_id; /*ptr to the current atom */ - void * ret_value; /*return value */ + H5I_id_info_t *curr_id; /* Pointer to the current atom */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -1218,9 +1194,9 @@ done: void * H5I_remove(hid_t id) { - H5I_id_type_t *type_ptr; /*ptr to the atomic type */ - H5I_type_t type; /*atom's atomic type */ - void * ret_value; /*return value */ + H5I_id_type_t *type_ptr; /* Pointer to the atomic type */ + H5I_type_t type; /* Atom's atomic type */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -1259,7 +1235,7 @@ done: int H5Idec_ref(hid_t id) { - int ret_value; /* Return value */ + int ret_value = 0; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("Is", "i", id); @@ -1297,8 +1273,8 @@ done: int H5I_dec_ref(hid_t id) { - H5I_id_info_t *id_ptr; /*ptr to the new ID */ - int ret_value; /* Return value */ + H5I_id_info_t *id_ptr; /* Pointer to the new ID */ + int ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1367,8 +1343,8 @@ done: int H5I_dec_app_ref(hid_t id) { - H5I_id_info_t *id_ptr; /*ptr to the new ID */ - int ret_value; /* Return value */ + H5I_id_info_t *id_ptr; /* Pointer to the new ID */ + int ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1415,7 +1391,7 @@ done: int H5I_dec_app_ref_always_close(hid_t id) { - int ret_value; /* Return value */ + int ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1493,8 +1469,8 @@ done: int H5I_inc_ref(hid_t id, hbool_t app_ref) { - H5I_id_info_t *id_ptr; /*ptr to the ID */ - int ret_value; /* Return value */ + H5I_id_info_t *id_ptr; /* Pointer to the ID */ + int ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1568,8 +1544,8 @@ done: int H5I_get_ref(hid_t id, hbool_t app_ref) { - H5I_id_info_t *id_ptr; /*ptr to the ID */ - int ret_value; /* Return value */ + H5I_id_info_t *id_ptr; /* Pointer to the ID */ + int ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1643,8 +1619,8 @@ done: static int H5I__inc_type_ref(H5I_type_t type) { - H5I_id_type_t *type_ptr; /* ptr to the type */ - int ret_value; /* Return value */ + H5I_id_type_t *type_ptr; /* Pointer to the type */ + int ret_value = -1; /* Return value */ FUNC_ENTER_STATIC @@ -1727,8 +1703,8 @@ done: herr_t H5I_dec_type_ref(H5I_type_t type) { - H5I_id_type_t *type_ptr; /* Pointer to the ID type */ - herr_t ret_value; /* Return value */ + H5I_id_type_t *type_ptr; /* Pointer to the ID type */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1816,7 +1792,7 @@ static int H5I__get_type_ref(H5I_type_t type) { H5I_id_type_t *type_ptr; /*ptr to the type */ - int ret_value; /* Return value */ + int ret_value = -1; /* Return value */ FUNC_ENTER_STATIC @@ -1894,7 +1870,7 @@ static int H5I__search_cb(void *obj, hid_t id, void *_udata) { H5I_search_ud_t *udata = (H5I_search_ud_t *)_udata; /* User data for callback */ - int ret_value; /* Callback return value */ + int ret_value = -1; /* Callback return value */ FUNC_ENTER_STATIC_NOERR @@ -2082,7 +2058,7 @@ H5I__find_id(hid_t id) { H5I_type_t type; /*ID's type */ H5I_id_type_t *type_ptr; /*ptr to the type */ - H5I_id_info_t *ret_value; /*return value */ + H5I_id_info_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -2199,7 +2175,7 @@ hid_t H5I_get_file_id(hid_t obj_id, hbool_t app_ref) { H5I_type_t type; /* ID type */ - hid_t ret_value; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI_NOINIT diff --git a/src/H5Imodule.h b/src/H5Imodule.h new file mode 100644 index 0000000..19cc9a4 --- /dev/null +++ b/src/H5Imodule.h @@ -0,0 +1,35 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Quincey Koziol <koziol@hdfgroup.org> + * Saturday, September 12, 2015 + * + * Purpose: This file contains declarations which define macros for the + * H5I package. Including this header means that the source file + * is part of the H5I package. + */ +#ifndef _H5Imodule_H +#define _H5Imodule_H + +/* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error + * reporting macros. + */ +#define H5I_MODULE +#define H5_MY_PKG H5I +#define H5_MY_PKG_ERR H5E_ATOM +#define H5_MY_PKG_INIT NO + +#endif /* _H5Imodule_H */ + diff --git a/src/H5Ipkg.h b/src/H5Ipkg.h index 1666b76..0a6ae8c 100644 --- a/src/H5Ipkg.h +++ b/src/H5Ipkg.h @@ -21,7 +21,7 @@ * the H5I package. Source files outside the H5I package should * include H5Iprivate.h instead. */ -#ifndef H5I_PACKAGE +#if !(defined H5I_FRIEND || defined H5I_MODULE) #error "Do not include this file outside the H5I package!" #endif diff --git a/src/H5Itest.c b/src/H5Itest.c index 5236e8d..9d451c6 100644 --- a/src/H5Itest.c +++ b/src/H5Itest.c @@ -23,7 +23,7 @@ /* Module Setup */ /****************/ -#define H5I_PACKAGE /*suppress error about including H5Ipkg */ +#include "H5Imodule.h" /* This source code file is part of the H5I module */ #define H5I_TESTING /*suppress warning about H5I testing funcs*/ @@ -80,7 +80,7 @@ ssize_t H5I_get_name_test(hid_t id, char *name/*out*/, size_t size, hbool_t *cached) { H5G_loc_t loc; /* Object location */ - ssize_t ret_value; /* Return value */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -17,10 +17,8 @@ /* Module Setup */ /****************/ -#define H5L_PACKAGE /*suppress error about including H5Lpkg */ +#include "H5Lmodule.h" /* This source code file is part of the H5L module */ -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5L_init_interface /***********/ /* Headers */ @@ -191,6 +189,9 @@ static herr_t H5L_get_name_by_idx_cb(H5G_loc_t *grp_loc/*in*/, /* Package Variables */ /*********************/ +/* Package initialization variable */ +hbool_t H5_PKG_INIT_VAR = FALSE; + /*****************************/ /* Library Private Variables */ @@ -235,7 +236,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5L_init_interface + * Function: H5L__init_package * * Purpose: Initialize information specific to H5L interface. * @@ -246,12 +247,12 @@ done: * *------------------------------------------------------------------------- */ -static herr_t -H5L_init_interface(void) +herr_t +H5L__init_package(void) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* Initialize user-defined link classes */ if(H5L_register_external() < 0) @@ -259,13 +260,13 @@ H5L_init_interface(void) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5L_init_interface() */ +} /* end H5L_init_package() */ /*------------------------------------------------------------------------- - * Function: H5L_term_interface + * Function: H5L_term_package * - * Purpose: Terminate any resources allocated in H5L_init_interface. + * Purpose: Terminate any resources allocated in H5L__init_package. * * Return: Non-negative on success/Negative on failure * @@ -275,21 +276,27 @@ done: *------------------------------------------------------------------------- */ int -H5L_term_interface(void) +H5L_term_package(void) { int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - /* Free the table of link types */ - H5L_table_g = (H5L_class_t *)H5MM_xfree(H5L_table_g); - H5L_table_used_g = H5L_table_alloc_g = 0; + 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 */ - H5_interface_initialize_g = 0; + /* Mark the interface as uninitialized */ + if(0 == n) + H5_PKG_INIT_VAR = FALSE; + } /* end if */ FUNC_LEAVE_NOAPI(n) -} /* H5L_term_interface() */ +} /* H5L_term_package() */ /*------------------------------------------------------------------------- @@ -2756,7 +2763,7 @@ static htri_t H5L_exists(const H5G_loc_t *loc, const char *name, hid_t lapl_id, hid_t dxpl_id) { hbool_t exists = FALSE; /* Whether the link exists in the group */ - htri_t ret_value; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -2913,7 +2920,7 @@ done: hid_t H5L_get_default_lcpl(void) { - hid_t ret_value; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(FAIL) diff --git a/src/H5Lexternal.c b/src/H5Lexternal.c index bbdad12..dd2061c 100644 --- a/src/H5Lexternal.c +++ b/src/H5Lexternal.c @@ -13,12 +13,17 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#define H5G_PACKAGE /*suppress error about including H5Gpkg */ -#define H5L_PACKAGE /*suppress error about including H5Lpkg */ +/****************/ +/* Module Setup */ +/****************/ -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5L_init_extern_interface +#define H5G_FRIEND /*suppress error about including H5Gpkg */ +#include "H5Lmodule.h" /* This source code file is part of the H5L module */ + +/***********/ +/* Headers */ +/***********/ #include "H5private.h" /* Generic Functions */ #include "H5ACprivate.h" /* Metadata cache */ #include "H5Eprivate.h" /* Error handling */ @@ -29,13 +34,52 @@ #include "H5Opublic.h" /* File objects */ #include "H5Pprivate.h" /* Property lists */ + +/****************/ +/* Local Macros */ +/****************/ + +/* Version of external link format */ +#define H5L_EXT_VERSION 0 + +/* Valid flags for external links */ +#define H5L_EXT_FLAGS_ALL 0 + +/* Size of local link name buffer for traversing external links */ +#define H5L_EXT_TRAVERSE_BUF_SIZE 256 + + +/******************/ +/* Local Typedefs */ +/******************/ + + +/********************/ +/* Local Prototypes */ +/********************/ + static hid_t H5L_extern_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, const void *udata, size_t H5_ATTR_UNUSED udata_size, hid_t lapl_id); static ssize_t H5L_extern_query(const char H5_ATTR_UNUSED * link_name, const void *udata, size_t udata_size, void * buf /*out*/, size_t buf_size); + +/*********************/ +/* Package Variables */ +/*********************/ + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ + /* Default External Link link class */ -const H5L_class_t H5L_EXTERN_LINK_CLASS[1] = {{ +static const H5L_class_t H5L_EXTERN_LINK_CLASS[1] = {{ H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ H5L_TYPE_EXTERNAL, /* Link type id number */ "external", /* Link name for debugging */ @@ -47,41 +91,9 @@ const H5L_class_t H5L_EXTERN_LINK_CLASS[1] = {{ H5L_extern_query /* Query callback */ }}; -/* Version of external link format */ -#define H5L_EXT_VERSION 0 - -/* Valid flags for external links */ -#define H5L_EXT_FLAGS_ALL 0 - -/* Size of local link name buffer for traversing external links */ -#define H5L_EXT_TRAVERSE_BUF_SIZE 256 /*-------------------------------------------------------------------------- -NAME - H5L_init_extern_interface -- Initialize interface-specific information -USAGE - herr_t H5L_init_extern_interface() - -RETURNS - Non-negative on success/Negative on failure - -DESCRIPTION - Initializes any interface-specific data or routines. (Just calls - H5L_init() currently). - ---------------------------------------------------------------------------*/ -static herr_t -H5L_init_extern_interface(void) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - FUNC_LEAVE_NOAPI(H5L_init()) -} /* H5L_init_extern_interface() */ - - - -/*-------------------------------------------------------------------------- * Function: H5L_getenv_prefix_name -- * * Purpose: Get the first pathname in the list of pathnames stored in ENV_PREFIX, @@ -210,7 +222,7 @@ H5L_extern_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, char *actual_file_name = NULL; /* Parent file's actual name */ H5P_genplist_t *fa_plist; /* File access property list pointer */ H5F_close_degree_t fc_degree = H5F_CLOSE_WEAK; /* File close degree for target file */ - hid_t ret_value; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(FAIL) diff --git a/src/H5Lmodule.h b/src/H5Lmodule.h new file mode 100644 index 0000000..e665c81 --- /dev/null +++ b/src/H5Lmodule.h @@ -0,0 +1,36 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Quincey Koziol <koziol@hdfgroup.org> + * Saturday, September 12, 2015 + * + * Purpose: This file contains declarations which define macros for the + * H5L package. Including this header means that the source file + * is part of the H5L package. + */ +#ifndef _H5Lmodule_H +#define _H5Lmodule_H + +/* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error + * reporting macros. + */ +#define H5L_MODULE +#define H5_MY_PKG H5L +#define H5_MY_PKG_ERR H5E_LINK +#define H5_MY_PKG_INIT YES + +#endif /* _H5Lmodule_H */ + + diff --git a/src/H5Lpkg.h b/src/H5Lpkg.h index 2e931f5..bb8534b 100644 --- a/src/H5Lpkg.h +++ b/src/H5Lpkg.h @@ -21,7 +21,7 @@ * only within the H5L package. Source files outside the * H5L package should include H5Lprivate.h instead. */ -#ifndef H5L_PACKAGE +#if !(defined H5L_FRIEND || defined H5L_MODULE) #error "Do not include this file outside the H5L package!" #endif @@ -28,8 +28,8 @@ /* Module Setup */ /****************/ -#define H5F_PACKAGE /*suppress error about including H5Fpkg */ -#define H5MF_PACKAGE /*suppress error about including H5MFpkg */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#include "H5MFmodule.h" /* This source code file is part of the H5MF module */ /***********/ @@ -92,6 +92,9 @@ static herr_t H5MF_alloc_close(H5F_t *f, hid_t dxpl_id, H5FD_mem_t type); /* Package Variables */ /*********************/ +/* Package initialization variable */ +hbool_t H5_PKG_INIT_VAR = FALSE; + /*****************************/ /* Library Private Variables */ @@ -436,7 +439,7 @@ H5MF_alloc(H5F_t *f, H5FD_mem_t alloc_type, hid_t dxpl_id, hsize_t size) H5P_genplist_t *dxpl = NULL; /* DXPL for setting ring */ H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ H5FD_mem_t fs_type; /* Free space type (mapped from allocation type) */ - haddr_t ret_value; /* Return value */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI(HADDR_UNDEF) #ifdef H5MF_ALLOC_DEBUG @@ -571,7 +574,7 @@ haddr_t H5MF_alloc_tmp(H5F_t *f, hsize_t size) { haddr_t eoa; /* End of allocated space in the file */ - haddr_t ret_value; /* Return value */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI(HADDR_UNDEF) #ifdef H5MF_ALLOC_DEBUG @@ -796,7 +799,7 @@ H5MF_try_extend(H5F_t *f, hid_t dxpl_id, H5FD_mem_t alloc_type, haddr_t addr, H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ haddr_t end; /* End of block to extend */ H5FD_mem_t map_type; /* Mapped type */ - htri_t ret_value; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) #ifdef H5MF_ALLOC_DEBUG @@ -1029,7 +1032,7 @@ H5MF_try_shrink(H5F_t *f, H5FD_mem_t alloc_type, hid_t dxpl_id, haddr_t addr, H5MF_sect_ud_t udata; /* User data for callback */ H5P_genplist_t *dxpl = NULL; /* DXPL for setting ring */ H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - htri_t ret_value; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) #ifdef H5MF_ALLOC_DEBUG @@ -1411,7 +1414,7 @@ H5MF_get_free_sections(H5F_t *f, hid_t dxpl_id, H5FD_mem_t type, size_t nsects, H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ H5FD_mem_t start_type, end_type; /* Memory types to iterate over */ H5FD_mem_t ty; /* Memory type for iteration */ - ssize_t ret_value; /* Return value */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI(FAIL) diff --git a/src/H5MFaggr.c b/src/H5MFaggr.c index c5a7b49..40f3ac0 100644 --- a/src/H5MFaggr.c +++ b/src/H5MFaggr.c @@ -25,8 +25,8 @@ /* Module Setup */ /****************/ -#define H5F_PACKAGE /*suppress error about including H5Fpkg */ -#define H5MF_PACKAGE /*suppress error about including H5MFpkg */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#include "H5MFmodule.h" /* This source code file is part of the H5MF module */ /***********/ @@ -97,7 +97,7 @@ static herr_t H5MF_aggr_free(H5F_t *f, hid_t dxpl_id, H5FD_mem_t type, haddr_t H5MF_aggr_vfd_alloc(H5F_t *f, H5FD_mem_t alloc_type, hid_t dxpl_id, hsize_t size) { - haddr_t ret_value; /* Return value */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI(HADDR_UNDEF) #ifdef H5MF_ALLOC_DEBUG @@ -158,7 +158,7 @@ H5MF_aggr_alloc(H5F_t *f, hid_t dxpl_id, H5F_blk_aggr_t *aggr, haddr_t eoa_frag_addr = HADDR_UNDEF; /* Address of fragment at EOA */ hsize_t eoa_frag_size = 0; /* Size of fragment at EOA */ haddr_t eoa = HADDR_UNDEF; /* Initial EOA for the file */ - haddr_t ret_value; /* Return value */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI(HADDR_UNDEF) #ifdef H5MF_AGGR_DEBUG @@ -871,7 +871,7 @@ H5MF_aggrs_try_shrink_eoa(H5F_t *f, hid_t dxpl_id) { htri_t ma_status; /* Whether the metadata aggregator can shrink the EOA */ htri_t sda_status; /* Whether the small data aggregator can shrink the EOA */ - htri_t ret_value; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) diff --git a/src/H5MFdbg.c b/src/H5MFdbg.c index 3a664ef..59da9e8 100644 --- a/src/H5MFdbg.c +++ b/src/H5MFdbg.c @@ -28,8 +28,8 @@ /* Module Setup */ /****************/ -#define H5F_PACKAGE /*suppress error about including H5Fpkg */ -#define H5MF_PACKAGE /*suppress error about including H5MFpkg */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#include "H5MFmodule.h" /* This source code file is part of the H5MF module */ #define H5MF_DEBUGGING /* Need access to file space debugging routines */ diff --git a/src/H5MFmodule.h b/src/H5MFmodule.h new file mode 100644 index 0000000..6e5f8ad --- /dev/null +++ b/src/H5MFmodule.h @@ -0,0 +1,35 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Quincey Koziol <koziol@hdfgroup.org> + * Saturday, September 12, 2015 + * + * Purpose: This file contains declarations which define macros for the + * H5MF package. Including this header means that the source file + * is part of the H5MF package. + */ +#ifndef _H5MFmodule_H +#define _H5MFmodule_H + +/* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error + * reporting macros. + */ +#define H5MF_MODULE +#define H5_MY_PKG H5MF +#define H5_MY_PKG_ERR H5E_RESOURCE +#define H5_MY_PKG_INIT NO + +#endif /* _H5MFmodule_H */ + diff --git a/src/H5MFpkg.h b/src/H5MFpkg.h index 2071a0a..1a62710 100644 --- a/src/H5MFpkg.h +++ b/src/H5MFpkg.h @@ -21,7 +21,7 @@ * the H5MF package. Source files outside the H5MF package should * include H5MFprivate.h instead. */ -#ifndef H5MF_PACKAGE +#if !(defined H5MF_FRIEND || defined H5MF_MODULE) #error "Do not include this file outside the H5MF package!" #endif diff --git a/src/H5MFsection.c b/src/H5MFsection.c index 20b9984..f333356 100644 --- a/src/H5MFsection.c +++ b/src/H5MFsection.c @@ -25,8 +25,8 @@ /* Module Setup */ /****************/ -#define H5F_PACKAGE /*suppress error about including H5Fpkg */ -#define H5MF_PACKAGE /*suppress error about including H5MFpkg */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#include "H5MFmodule.h" /* This source code file is part of the H5MF module */ /***********/ @@ -132,7 +132,7 @@ H5MF_free_section_t * H5MF_sect_simple_new(haddr_t sect_off, hsize_t sect_size) { H5MF_free_section_t *sect = NULL; /* 'Simple' free space section to add */ - H5MF_free_section_t *ret_value; /* Return value */ + H5MF_free_section_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -178,7 +178,7 @@ H5MF_sect_simple_deserialize(const H5FS_section_class_t H5_ATTR_UNUSED *cls, hsize_t sect_size, unsigned H5_ATTR_UNUSED *des_flags) { H5MF_free_section_t *sect; /* New section */ - H5FS_section_info_t *ret_value; /* Return value */ + H5FS_section_info_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -219,7 +219,7 @@ H5MF_sect_simple_can_merge(const H5FS_section_info_t *_sect1, { const H5MF_free_section_t *sect1 = (const H5MF_free_section_t *)_sect1; /* File free section */ const H5MF_free_section_t *sect2 = (const H5MF_free_section_t *)_sect2; /* File free section */ - htri_t ret_value; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -300,7 +300,7 @@ H5MF_sect_simple_can_shrink(const H5FS_section_info_t *_sect, void *_udata) H5MF_sect_ud_t *udata = (H5MF_sect_ud_t *)_udata; /* User data for callback */ haddr_t eoa; /* End of address space in the file */ haddr_t end; /* End of section to extend */ - htri_t ret_value; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -519,7 +519,7 @@ H5MF_sect_simple_valid(const H5FS_section_class_t H5_ATTR_UNUSED *cls, static H5FS_section_info_t * H5MF_sect_simple_split(H5FS_section_info_t *sect, hsize_t frag_size) { - H5MF_free_section_t *ret_value; /* Return value */ + H5MF_free_section_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -29,7 +29,7 @@ *------------------------------------------------------------------------- */ -#define H5MP_PACKAGE /*suppress error about including H5MPpkg */ +#include "H5MPmodule.h" /* This source code file is part of the H5MP module */ /* Private headers */ #include "H5private.h" /* Generic Functions */ @@ -63,6 +63,9 @@ /* Package Variable Definitions */ /********************************/ +/* Package initialization variable */ +hbool_t H5_PKG_INIT_VAR = FALSE; + /********************/ /* Static Variables */ @@ -90,7 +93,7 @@ H5MP_pool_t * H5MP_create(size_t page_size, unsigned flags) { H5MP_pool_t *mp = NULL; /* New memory pool header */ - H5MP_pool_t *ret_value; /* Return value */ + H5MP_pool_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -141,7 +144,7 @@ H5MP_new_page(H5MP_pool_t *mp, size_t page_size) { H5MP_page_t *new_page; /* New page created */ H5MP_page_blk_t *first_blk; /* Pointer to first block in page */ - H5MP_page_t *ret_value; /* Return value */ + H5MP_page_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -212,7 +215,7 @@ H5MP_malloc (H5MP_pool_t *mp, size_t request) H5MP_page_t *alloc_page = NULL; /* Page to allocate space from */ H5MP_page_blk_t *alloc_free; /* Pointer to free space in page */ size_t needed; /* Size requested, plus block header and alignment */ - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) diff --git a/src/H5MPmodule.h b/src/H5MPmodule.h new file mode 100644 index 0000000..ca6c405 --- /dev/null +++ b/src/H5MPmodule.h @@ -0,0 +1,35 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Quincey Koziol <koziol@hdfgroup.org> + * Saturday, September 12, 2015 + * + * Purpose: This file contains declarations which define macros for the + * H5MP package. Including this header means that the source file + * is part of the H5MP package. + */ +#ifndef _H5MPmodule_H +#define _H5MPmodule_H + +/* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error + * reporting macros. + */ +#define H5MP_MODULE +#define H5_MY_PKG H5MP +#define H5_MY_PKG_ERR H5E_RESOURCE +#define H5_MY_PKG_INIT NO + +#endif /* _H5MPmodule_H */ + diff --git a/src/H5MPpkg.h b/src/H5MPpkg.h index 5a0b1f8..e724146 100644 --- a/src/H5MPpkg.h +++ b/src/H5MPpkg.h @@ -21,7 +21,7 @@ * the H5MP package. Source files outside the H5MP package should * include H5MPprivate.h instead. */ -#ifndef H5MP_PACKAGE +#if !(defined H5MP_FRIEND || defined H5MP_MODULE) #error "Do not include this file outside the H5MP package!" #endif diff --git a/src/H5MPtest.c b/src/H5MPtest.c index ccbd140..3f218db 100644 --- a/src/H5MPtest.c +++ b/src/H5MPtest.c @@ -19,7 +19,7 @@ * Purpose: Memory pool testing functions. */ -#define H5MP_PACKAGE /*suppress error about including H5MPpkg */ +#include "H5MPmodule.h" /* This source code file is part of the H5MP module */ #define H5MP_TESTING /*include H5MP testing funcs*/ /* Private headers */ @@ -28,10 +28,8 @@ /* Module Setup */ /****************/ -#define H5O_PACKAGE /*suppress error about including H5Opkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5O_init_interface /***********/ /* Headers */ @@ -94,6 +92,9 @@ static const H5O_obj_class_t *H5O_obj_class_real(H5O_t *oh); /* 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,7 +179,7 @@ static const H5O_obj_class_t *const H5O_obj_class_g[] = { /*------------------------------------------------------------------------- - * Function: H5O_init_interface + * Function: H5O__init_package * * Purpose: Initialize information specific to H5O interface. * @@ -187,16 +188,12 @@ static const H5O_obj_class_t *const H5O_obj_class_g[] = { * Programmer: Quincey Koziol * Thursday, January 18, 2007 * - * Changes: JRM -- 12/12/07 - * Added santity check verifying that H5O_msg_class_g - * is big enough. - * *------------------------------------------------------------------------- */ -static herr_t -H5O_init_interface(void) +herr_t +H5O__init_package(void) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_PACKAGE_NOERR /* H5O interface sanity checks */ HDcompile_assert(H5O_MSG_TYPES == NELMTS(H5O_msg_class_g)); @@ -205,7 +202,7 @@ H5O_init_interface(void) HDcompile_assert(H5O_UNKNOWN_ID < H5O_MSG_TYPES); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5O_init_interface() */ +} /* end H5O__init_package() */ /*------------------------------------------------------------------------- @@ -247,7 +244,7 @@ H5Oopen(hid_t loc_id, const char *name, hid_t lapl_id) /* Open the object */ if((ret_value = H5O_open_name(&loc, name, lapl_id, TRUE)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object") + HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object") done: FUNC_LEAVE_API(ret_value) @@ -313,18 +310,18 @@ H5Oopen_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, /* Find the object's location, according to the order in the index */ if(H5G_loc_find_by_idx(&loc, group_name, idx_type, order, n, &obj_loc/*out*/, lapl_id, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found") + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "group not found") loc_found = TRUE; /* Open the object */ if((ret_value = H5O_open_by_loc(&obj_loc, lapl_id, H5AC_ind_dxpl_id, TRUE)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object") + HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object") done: /* Release the object location if we failed after copying it */ if(ret_value < 0 && loc_found) if(H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") + HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location") FUNC_LEAVE_API(ret_value) } /* end H5Oopen_by_idx() */ @@ -394,7 +391,7 @@ H5Oopen_by_addr(hid_t loc_id, haddr_t addr) /* Open the object */ if((ret_value = H5O_open_by_loc(&obj_loc, lapl_id, H5AC_ind_dxpl_id, TRUE)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object") + HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object") done: @@ -453,7 +450,7 @@ H5Olink(hid_t obj_id, hid_t new_loc_id, const char *new_name, hid_t lcpl_id, /* Link to the object */ if(H5L_link(&new_loc, new_name, &obj_loc, lcpl_id, lapl_id, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to create link") done: FUNC_LEAVE_API(ret_value) @@ -614,7 +611,7 @@ H5Oget_info(hid_t loc_id, H5O_info_t *oinfo) /* Retrieve the object's information */ if(H5G_loc_info(&loc, ".", TRUE, oinfo/*out*/, H5P_LINK_ACCESS_DEFAULT, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") done: FUNC_LEAVE_API(ret_value) @@ -658,7 +655,7 @@ H5Oget_info_by_name(hid_t loc_id, const char *name, H5O_info_t *oinfo, hid_t lap /* Retrieve the object's information */ if(H5G_loc_info(&loc, name, TRUE, oinfo/*out*/, lapl_id, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") done: FUNC_LEAVE_API(ret_value) @@ -718,17 +715,17 @@ H5Oget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, /* Find the object's location, according to the order in the index */ if(H5G_loc_find_by_idx(&loc, group_name, idx_type, order, n, &obj_loc/*out*/, lapl_id, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found") + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "group not found") loc_found = TRUE; /* Retrieve the object's information */ if(H5O_get_info(obj_loc.oloc, H5AC_ind_dxpl_id, TRUE, oinfo) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve object info") + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object info") done: /* Release the object location */ if(loc_found && H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") + HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location") FUNC_LEAVE_API(ret_value) } /* end H5Oget_info_by_idx() */ @@ -766,7 +763,7 @@ H5Oset_comment(hid_t obj_id, const char *comment) /* (Re)set the object's comment */ if(H5G_loc_set_comment(&loc, ".", comment, H5P_LINK_ACCESS_DEFAULT, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") done: FUNC_LEAVE_API(ret_value) @@ -813,7 +810,7 @@ H5Oset_comment_by_name(hid_t loc_id, const char *name, const char *comment, /* (Re)set the object's comment */ if(H5G_loc_set_comment(&loc, name, comment, lapl_id, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") done: FUNC_LEAVE_API(ret_value) @@ -851,7 +848,7 @@ H5Oget_comment(hid_t obj_id, char *comment, size_t bufsize) /* Retrieve the object's comment */ if((ret_value = H5G_loc_get_comment(&loc, ".", comment/*out*/, bufsize, H5P_LINK_ACCESS_DEFAULT, H5AC_ind_dxpl_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") done: FUNC_LEAVE_API(ret_value) @@ -897,7 +894,7 @@ H5Oget_comment_by_name(hid_t loc_id, const char *name, char *comment, size_t buf /* Retrieve the object's comment */ if((ret_value = H5G_loc_get_comment(&loc, name, comment/*out*/, bufsize, lapl_id, H5AC_ind_dxpl_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") done: FUNC_LEAVE_API(ret_value) @@ -955,7 +952,7 @@ H5Ovisit(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, /* Call internal object visitation routine */ if((ret_value = H5O_visit(obj_id, ".", idx_type, order, op, op_data, H5P_LINK_ACCESS_DEFAULT, H5AC_ind_dxpl_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "object visitation failed") + HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") done: FUNC_LEAVE_API(ret_value) @@ -1021,7 +1018,7 @@ H5Ovisit_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type, /* Call internal object visitation routine */ if((ret_value = H5O_visit(loc_id, obj_name, idx_type, order, op, op_data, lapl_id, H5AC_ind_dxpl_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "object visitation failed") + HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") done: FUNC_LEAVE_API(ret_value) @@ -1484,17 +1481,17 @@ H5O_open_name(H5G_loc_t *loc, const char *name, hid_t lapl_id, hbool_t app_ref) /* Find the object's location */ if(H5G_loc_find(loc, name, &obj_loc/*out*/, lapl_id, dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") loc_found = TRUE; /* Open the object */ if((ret_value = H5O_open_by_loc(&obj_loc, lapl_id, dxpl_id, app_ref)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object") + HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object") done: if(ret_value < 0 && loc_found) if(H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") + HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_open_name() */ @@ -1517,7 +1514,7 @@ hid_t H5O_open_by_loc(const H5G_loc_t *obj_loc, hid_t lapl_id, hid_t dxpl_id, hbool_t app_ref) { const H5O_obj_class_t *obj_class; /* Class of object for location */ - hid_t ret_value; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1613,7 +1610,7 @@ int H5O_link_oh(H5F_t *f, int adjust, hid_t dxpl_id, H5O_t *oh, hbool_t *deleted) { haddr_t addr = H5O_OH_GET_ADDR(oh); /* Object header address */ - int ret_value; /* Return value */ + int ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1729,7 +1726,7 @@ H5O_link(const H5O_loc_t *loc, int adjust, hid_t dxpl_id) { H5O_t *oh = NULL; hbool_t deleted = FALSE; /* Whether the object was deleted */ - int ret_value; /* Return value */ + int ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI_TAG(dxpl_id, loc->addr, FAIL) @@ -1780,7 +1777,7 @@ H5O_protect(const H5O_loc_t *loc, hid_t dxpl_id, unsigned prot_flags) H5O_cache_ud_t udata; /* User data for protecting object header */ H5O_cont_msgs_t cont_msg_info; /* Continuation message info */ unsigned file_intent; /* R/W intent on file */ - H5O_t *ret_value; /* Return value */ + H5O_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_TAG(dxpl_id, loc->addr, NULL) @@ -1999,8 +1996,8 @@ done: H5O_t * H5O_pin(const H5O_loc_t *loc, hid_t dxpl_id) { - H5O_t *oh = NULL; /* Object header */ - H5O_t *ret_value; /* Return value */ + H5O_t *oh = NULL; /* Object header */ + H5O_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -2503,7 +2500,7 @@ const H5O_obj_class_t * H5O_obj_class(const H5O_loc_t *loc, hid_t dxpl_id) { H5O_t *oh = NULL; /* Object header for location */ - const H5O_obj_class_t *ret_value; /* Return value */ + const H5O_obj_class_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_TAG(dxpl_id, loc->addr, NULL) @@ -2540,7 +2537,7 @@ static const H5O_obj_class_t * H5O_obj_class_real(H5O_t *oh) { size_t i; /* Local index variable */ - const H5O_obj_class_t *ret_value; /* Return value */ + const H5O_obj_class_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -2582,7 +2579,7 @@ done: H5O_loc_t * H5O_get_loc(hid_t object_id) { - H5O_loc_t *ret_value; /* Return value */ + H5O_loc_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -3402,7 +3399,7 @@ H5O_visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type, hbool_t loc_found = FALSE; /* Entry at 'name' found */ H5O_info_t oinfo; /* Object info struct */ hid_t obj_id = (-1); /* ID of object */ - herr_t ret_value; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) diff --git a/src/H5Oainfo.c b/src/H5Oainfo.c index ba29efd..9e32af4 100644 --- a/src/H5Oainfo.c +++ b/src/H5Oainfo.c @@ -24,8 +24,9 @@ *------------------------------------------------------------------------- */ -#define H5A_PACKAGE /*suppress error about including H5Apkg */ -#define H5O_PACKAGE /*suppress error about including H5Opkg */ +#define H5A_FRIEND /*suppress error about including H5Apkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ + #include "H5private.h" /* Generic Functions */ #include "H5Apkg.h" /* Attributes */ @@ -110,7 +111,7 @@ H5O_ainfo_decode(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_t H5_ATTR_UNUSED *o { H5O_ainfo_t *ainfo = NULL; /* Attribute info */ unsigned char flags; /* Flags for encoding attribute info */ - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -239,7 +240,7 @@ H5O_ainfo_copy(const void *_mesg, void *_dest) { const H5O_ainfo_t *ainfo = (const H5O_ainfo_t *)_mesg; H5O_ainfo_t *dest = (H5O_ainfo_t *) _dest; - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -279,7 +280,7 @@ static size_t H5O_ainfo_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void *_mesg) { const H5O_ainfo_t *ainfo = (const H5O_ainfo_t *)_mesg; - size_t ret_value; /* Return value */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -424,7 +425,7 @@ H5O_ainfo_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst, { H5O_ainfo_t *ainfo_src = (H5O_ainfo_t *)mesg_src; H5O_ainfo_t *ainfo_dst = NULL; - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT diff --git a/src/H5Oalloc.c b/src/H5Oalloc.c index 96c811b..146412f 100644 --- a/src/H5Oalloc.c +++ b/src/H5Oalloc.c @@ -28,7 +28,8 @@ /* Module Setup */ /****************/ -#define H5O_PACKAGE /*suppress error about including H5Opkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ + /***********/ /* Headers */ @@ -515,7 +516,7 @@ H5O_alloc_extend_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned chunkno, uint8_t *old_image; /* Old address of chunk's image in memory */ size_t old_size; /* Old size of chunk */ htri_t was_extended; /* If chunk can be extended */ - size_t extend_msg; /* Index of null message to extend */ + size_t extend_msg = 0; /* Index of null message to extend */ hbool_t extended_msg = FALSE; /* Whether an existing message was extended */ uint8_t new_size_flags = 0; /* New chunk #0 size flags */ hbool_t adjust_size_flags = FALSE; /* Whether to adjust the chunk #0 size flags */ @@ -1461,7 +1462,7 @@ H5O_move_msgs_forward(H5F_t *f, hid_t dxpl_id, H5O_t *oh) hbool_t curr_chk_dirtied = FALSE; /* Flags for unprotecting curr chunk */ hbool_t packed_msg; /* Flag to indicate that messages were packed */ hbool_t did_packing = FALSE; /* Whether any messages were packed */ - htri_t ret_value; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1791,7 +1792,7 @@ H5O_merge_null(H5F_t *f, hid_t dxpl_id, H5O_t *oh) { hbool_t merged_msg; /* Flag to indicate that messages were merged */ hbool_t did_merging = FALSE; /* Whether any messages were merged */ - htri_t ret_value; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1926,7 +1927,7 @@ H5O_remove_empty_chunks(H5F_t *f, hid_t dxpl_id, H5O_t *oh) { hbool_t deleted_chunk; /* Whether to a chunk was deleted */ hbool_t did_deleting = FALSE; /* Whether any chunks were deleted */ - htri_t ret_value; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT diff --git a/src/H5Oattr.c b/src/H5Oattr.c index fd7fcda..9cbcdc4 100644 --- a/src/H5Oattr.c +++ b/src/H5Oattr.c @@ -13,9 +13,9 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#define H5A_PACKAGE /*prevent warning from including H5Apkg */ -#define H5O_PACKAGE /*suppress error about including H5Opkg */ -#define H5S_PACKAGE /*suppress error about including H5Spkg */ +#define H5A_FRIEND /*suppress error about including H5Apkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#define H5S_FRIEND /*suppress error about including H5Spkg */ #include "H5private.h" /* Generic Functions */ @@ -129,7 +129,7 @@ H5O_attr_decode(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, unsigned H5_ATTR_UNUSED H5S_extent_t *extent; /*extent dimensionality information */ size_t name_len; /*attribute name length */ unsigned flags = 0; /* Attribute flags */ - H5A_t *ret_value; /* Return value */ + H5A_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -380,7 +380,7 @@ done: static void * H5O_attr_copy(const void *_src, void *_dst) { - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -496,10 +496,6 @@ H5O_attr_reset(void H5_ATTR_UNUSED *_mesg) * Programmer: Quincey Koziol * Thursday, November 18, 2004 * - * Modification:Raymond Lu - * 4 June 2008 - * Let this function call H5A_close in turn. - * *------------------------------------------------------------------------- */ static herr_t @@ -652,7 +648,7 @@ H5O_attr_copy_file(H5F_t *file_src, const H5O_msg_class_t H5_ATTR_UNUSED *mesg_t void *native_src, H5F_t *file_dst, hbool_t *recompute_size, H5O_copy_t *cpy_info, void H5_ATTR_UNUSED *udata, hid_t dxpl_id) { - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT diff --git a/src/H5Oattribute.c b/src/H5Oattribute.c index 79ec506..a11e6dc 100644 --- a/src/H5Oattribute.c +++ b/src/H5Oattribute.c @@ -28,8 +28,9 @@ /* Module Setup */ /****************/ -#define H5A_PACKAGE /*suppress error about including H5Apkg */ -#define H5O_PACKAGE /*suppress error about including H5Opkg */ +#define H5A_FRIEND /*suppress error about including H5Apkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ + /***********/ /* Headers */ @@ -484,7 +485,7 @@ H5O_attr_open_by_name(const H5O_loc_t *loc, const char *name, hid_t dxpl_id) H5A_t *exist_attr = NULL; /* Existing opened attribute object */ H5A_t *opened_attr = NULL; /* Newly opened attribute object */ htri_t found_open_attr = FALSE; /* Whether opened object is found */ - H5A_t *ret_value; /* Return value */ + H5A_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_TAG(dxpl_id, loc->addr, NULL) @@ -634,7 +635,7 @@ H5O_attr_open_by_idx(const H5O_loc_t *loc, H5_index_t idx_type, H5A_t *exist_attr = NULL; /* Existing opened attribute object */ H5A_t *opened_attr = NULL; /* Newly opened attribute object */ htri_t found_open_attr = FALSE; /* Whether opened object is found */ - H5A_t *ret_value; /* Return value */ + H5A_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1300,7 +1301,7 @@ H5O_attr_iterate_real(hid_t loc_id, const H5O_loc_t *loc, hid_t dxpl_id, H5O_proxy_t *oh_proxy = NULL; /* Object header proxy */ H5O_ainfo_t ainfo; /* Attribute information for object */ H5A_attr_table_t atable = {0, NULL}; /* Table of attributes */ - herr_t ret_value; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_TAG(dxpl_id, loc->addr, FAIL) @@ -1393,7 +1394,7 @@ H5O_attr_iterate(hid_t loc_id, hid_t dxpl_id, hsize_t *last_attr, const H5A_attr_iter_op_t *attr_op, void *op_data) { H5G_loc_t loc; /* Object location */ - herr_t ret_value; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1901,7 +1902,7 @@ H5O_attr_exists(const H5O_loc_t *loc, const char *name, hid_t dxpl_id) H5O_t *oh = NULL; /* Pointer to actual object header */ H5O_proxy_t *oh_proxy = NULL; /* Object header proxy */ H5O_ainfo_t ainfo; /* Attribute information for object */ - htri_t ret_value; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_TAG(dxpl_id, loc->addr, FAIL) @@ -2073,7 +2074,7 @@ H5O_attr_count(const H5O_loc_t *loc, hid_t dxpl_id) { H5O_t *oh = NULL; /* Pointer to actual object header */ hsize_t nattrs; /* Number of attributes */ - int ret_value; /* Return value */ + int ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI_NOINIT diff --git a/src/H5Obogus.c b/src/H5Obogus.c index b368ab6..de205f6 100644 --- a/src/H5Obogus.c +++ b/src/H5Obogus.c @@ -28,7 +28,8 @@ *------------------------------------------------------------------------- */ -#define H5O_PACKAGE /*suppress error about including H5Opkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ + #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ diff --git a/src/H5Obtreek.c b/src/H5Obtreek.c index 802f23a..ac6fe37 100644 --- a/src/H5Obtreek.c +++ b/src/H5Obtreek.c @@ -21,7 +21,8 @@ * information in the superblock extension. */ -#define H5O_PACKAGE /*suppress error about including H5Opkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ + #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ @@ -83,7 +84,7 @@ H5O_btreek_decode(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_t H unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, const uint8_t *p) { H5O_btreek_t *mesg; /* Native message */ - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -165,7 +166,7 @@ H5O_btreek_copy(const void *_mesg, void *_dest) { const H5O_btreek_t *mesg = (const H5O_btreek_t *)_mesg; H5O_btreek_t *dest = (H5O_btreek_t *)_dest; - void *ret_value; + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT diff --git a/src/H5Ocache.c b/src/H5Ocache.c index 300be13..3ee3367 100644 --- a/src/H5Ocache.c +++ b/src/H5Ocache.c @@ -28,7 +28,7 @@ /* Module Setup */ /****************/ -#define H5O_PACKAGE /*suppress error about including H5Opkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ /***********/ @@ -907,9 +907,9 @@ static void * H5O__cache_chk_deserialize(const void *image, size_t len, void *_udata, hbool_t *dirty) { - H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk proxy object */ + H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk proxy object */ H5O_chk_cache_ud_t *udata = (H5O_chk_cache_ud_t *)_udata; /* User data for callback */ - void * ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC diff --git a/src/H5Ochunk.c b/src/H5Ochunk.c index 2d025e7..d2a2060 100644 --- a/src/H5Ochunk.c +++ b/src/H5Ochunk.c @@ -28,7 +28,8 @@ /* Module Setup */ /****************/ -#define H5O_PACKAGE /*suppress error about including H5Opkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ + /***********/ /* Headers */ @@ -153,7 +154,7 @@ H5O_chunk_proxy_t * H5O_chunk_protect(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned idx) { H5O_chunk_proxy_t *chk_proxy = NULL; /* Proxy for protected chunk */ - H5O_chunk_proxy_t *ret_value; /* Return value */ + H5O_chunk_proxy_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_TAG(dxpl_id, oh->cache_info.addr, NULL) diff --git a/src/H5Ocont.c b/src/H5Ocont.c index a139654..63002c5 100644 --- a/src/H5Ocont.c +++ b/src/H5Ocont.c @@ -27,7 +27,8 @@ *------------------------------------------------------------------------- */ -#define H5O_PACKAGE /*suppress error about including H5Opkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ + #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ @@ -94,7 +95,7 @@ H5O_cont_decode(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_t H5_ATTR_UNUSED *op unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, const uint8_t *p) { H5O_cont_t *cont = NULL; - void *ret_value; + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -174,7 +175,7 @@ H5O_cont_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, con static size_t H5O_cont_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void H5_ATTR_UNUSED *_mesg) { - size_t ret_value; /* Return value */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c index f205e74..7f041c5 100644 --- a/src/H5Ocopy.c +++ b/src/H5Ocopy.c @@ -28,7 +28,8 @@ /* Module Setup */ /****************/ -#define H5O_PACKAGE /*suppress error about including H5Opkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ + /***********/ /* Headers */ @@ -336,7 +337,7 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, size_t null_msgs; /* Number of NULL messages found in each loop */ size_t orig_dst_msgs; /* Original # of messages in dest. object */ H5O_mesg_t *mesg_src; /* Message in source object header */ - H5O_mesg_t *mesg_dst; /* Message in source object header */ + H5O_mesg_t *mesg_dst; /* Message in destination object header */ const H5O_msg_class_t *copy_type; /* Type of message to use for copying */ const H5O_obj_class_t *obj_class = NULL; /* Type of object we are copying */ void *cpy_udata = NULL; /* User data for passing to message callbacks */ diff --git a/src/H5Odbg.c b/src/H5Odbg.c index 0388cd5..a606611 100644 --- a/src/H5Odbg.c +++ b/src/H5Odbg.c @@ -28,7 +28,8 @@ /* Module Setup */ /****************/ -#define H5O_PACKAGE /*suppress error about including H5Opkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ + /***********/ /* Headers */ @@ -247,8 +248,8 @@ H5O_assert(const H5O_t *oh) herr_t H5O_debug_id(unsigned type_id, H5F_t *f, hid_t dxpl_id, const void *mesg, FILE *stream, int indent, int fwidth) { - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - herr_t ret_value; /* Return value */ + const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) diff --git a/src/H5Odrvinfo.c b/src/H5Odrvinfo.c index 73cb7cc..2fdf494 100644 --- a/src/H5Odrvinfo.c +++ b/src/H5Odrvinfo.c @@ -21,7 +21,8 @@ * in the superblock extension. */ -#define H5O_PACKAGE /*suppress error about including H5Opkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ + #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ @@ -84,7 +85,7 @@ H5O_drvinfo_decode(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_t unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, const uint8_t *p) { H5O_drvinfo_t *mesg; /* Native message */ - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -181,7 +182,7 @@ H5O_drvinfo_copy(const void *_mesg, void *_dest) { const H5O_drvinfo_t *mesg = (const H5O_drvinfo_t *)_mesg; H5O_drvinfo_t *dest = (H5O_drvinfo_t *)_dest; - void *ret_value; + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -228,7 +229,7 @@ static size_t H5O_drvinfo_size(const H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, const void *_mesg) { const H5O_drvinfo_t *mesg = (const H5O_drvinfo_t *)_mesg; - size_t ret_value; + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR diff --git a/src/H5Odtype.c b/src/H5Odtype.c index 622a18e..cee6e1e 100644 --- a/src/H5Odtype.c +++ b/src/H5Odtype.c @@ -13,8 +13,9 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#define H5O_PACKAGE /*suppress error about including H5Opkg */ -#define H5T_PACKAGE /*prevent warning from including H5Tpkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#define H5T_FRIEND /*prevent warning from including H5Tpkg */ + #include "H5private.h" /* Generic Functions */ #include "H5Dprivate.h" /* Datasets */ @@ -35,7 +36,7 @@ static void *H5O_dtype_decode(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, static void *H5O_dtype_copy(const void *_mesg, void *_dest); static size_t H5O_dtype_size(const H5F_t *f, const void *_mesg); static herr_t H5O_dtype_reset(void *_mesg); -static herr_t H5O_dtype_free(void *_mesg); +static herr_t H5O__dtype_free(void *_mesg); static herr_t H5O_dtype_set_share(void *_mesg, const H5O_shared_t *sh); static htri_t H5O_dtype_can_share(const void *_mesg); static herr_t H5O_dtype_pre_copy_file(H5F_t *file_src, const void *mesg_src, @@ -101,7 +102,7 @@ const H5O_msg_class_t H5O_MSG_DTYPE[1] = {{ H5O_dtype_copy, /* copy the native value */ H5O_dtype_shared_size, /* size of raw message */ H5O_dtype_reset, /* reset method */ - H5O_dtype_free, /* free method */ + H5O__dtype_free, /* free method */ H5O_dtype_shared_delete, /* file delete method */ H5O_dtype_shared_link, /* link method */ H5O_dtype_set_share, /* set share method */ @@ -1093,7 +1094,7 @@ H5O_dtype_decode(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_t H5_ATTR_UNUSED *o unsigned *ioflags/*in,out*/, const uint8_t *p) { H5T_t *dt = NULL; - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1175,9 +1176,9 @@ done: static void * H5O_dtype_copy(const void *_src, void *_dst) { - const H5T_t *src = (const H5T_t *) _src; - H5T_t *dst; - void *ret_value; /* Return value */ + const H5T_t *src = (const H5T_t *) _src; + H5T_t *dst; + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1224,7 +1225,7 @@ H5O_dtype_size(const H5F_t *f, const void *_mesg) { const H5T_t *dt = (const H5T_t *)_mesg; unsigned u; /* Local index variable */ - size_t ret_value; + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1369,31 +1370,34 @@ H5O_dtype_reset(void *_mesg) /*------------------------------------------------------------------------- - * Function: H5O_dtype_free + * Function: H5O__dtype_free * - * Purpose: Free's the message + * Purpose: Frees the message * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Thursday, March 30, 2000 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t -H5O_dtype_free(void *mesg) +H5O__dtype_free(void *mesg) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + herr_t ret_value = SUCCEED; /* Return value */ + FUNC_ENTER_STATIC + + /* Sanity check */ HDassert(mesg); - ((H5T_t *) mesg)->shared = H5FL_FREE(H5T_shared_t, ((H5T_t *) mesg)->shared); - mesg = H5FL_FREE(H5T_t, mesg); + /* Release the datatype */ + if(H5T_close((H5T_t *)mesg) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free datatype") - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5O_dtype_free() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O__dtype_free() */ /*------------------------------------------------------------------------- @@ -1562,7 +1566,7 @@ H5O_dtype_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const H5O_msg_class_t *mesg_ H5O_copy_t H5_ATTR_UNUSED *cpy_info, void H5_ATTR_UNUSED *udata, hid_t H5_ATTR_UNUSED dxpl_id) { H5T_t *dst_mesg; /* Destination datatype */ - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT diff --git a/src/H5Oefl.c b/src/H5Oefl.c index a6b51e6..149c8b2 100644 --- a/src/H5Oefl.c +++ b/src/H5Oefl.c @@ -18,7 +18,7 @@ * Tuesday, November 25, 1997 */ -#define H5O_PACKAGE /*suppress error about including H5Opkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ #include "H5private.h" /* Generic Functions */ @@ -96,8 +96,8 @@ H5O_efl_decode(H5F_t *f, hid_t dxpl_id, H5O_t H5_ATTR_UNUSED *open_oh, int version; const char *s = NULL; H5HL_t *heap; - size_t u; /* Local index variable */ - void *ret_value; /* Return value */ + size_t u; /* Local index variable */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -445,9 +445,9 @@ H5O_efl_copy_file(H5F_t H5_ATTR_UNUSED *file_src, void *mesg_src, H5F_t *file_ds { H5O_efl_t *efl_src = (H5O_efl_t *) mesg_src; H5O_efl_t *efl_dst = NULL; - H5HL_t *heap = NULL; /* Pointer to local heap for EFL file names */ + H5HL_t *heap = NULL; /* Pointer to local heap for EFL file names */ size_t idx, size, name_offset, heap_size; - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_TAG(dxpl_id, H5AC__COPIED_TAG, NULL) diff --git a/src/H5Ofill.c b/src/H5Ofill.c index 3bd1e84..ebcb5d3 100644 --- a/src/H5Ofill.c +++ b/src/H5Ofill.c @@ -20,7 +20,8 @@ * uninitialized data points of a dataset. */ -#define H5O_PACKAGE /*suppress error about including H5Opkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ + #include "H5private.h" /* Generic Functions */ #include "H5Dprivate.h" /* Datasets */ @@ -188,7 +189,7 @@ H5O_fill_new_decode(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_t unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, const uint8_t *p) { H5O_fill_t *fill = NULL; - void *ret_value; + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -301,8 +302,8 @@ static void * H5O_fill_old_decode(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, const uint8_t *p) { - H5O_fill_t *fill = NULL; /* Decoded fill value message */ - void *ret_value; /* Return value */ + H5O_fill_t *fill = NULL; /* Decoded fill value message */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -494,7 +495,7 @@ H5O_fill_copy(const void *_src, void *_dst) { const H5O_fill_t *src = (const H5O_fill_t *)_src; H5O_fill_t *dst = (H5O_fill_t *)_dst; - void *ret_value; + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -611,7 +612,7 @@ static size_t H5O_fill_new_size(const H5F_t H5_ATTR_UNUSED *f, const void *_fill) { const H5O_fill_t *fill = (const H5O_fill_t *)_fill; - size_t ret_value; + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR diff --git a/src/H5Oflush.c b/src/H5Oflush.c index b051b6a..ea989ad 100644 --- a/src/H5Oflush.c +++ b/src/H5Oflush.c @@ -28,7 +28,7 @@ /* Module Setup */ /****************/ -#define H5O_PACKAGE /* suppress error about including H5Opkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ /***********/ /* Headers */ diff --git a/src/H5Ofsinfo.c b/src/H5Ofsinfo.c index 180ebe8..1712857 100644 --- a/src/H5Ofsinfo.c +++ b/src/H5Ofsinfo.c @@ -24,7 +24,8 @@ *------------------------------------------------------------------------- */ -#define H5O_PACKAGE /* suppress error about including H5Opkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ + #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ @@ -89,7 +90,7 @@ H5O_fsinfo_decode(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_t H5_ATTR_UNUSED * { H5O_fsinfo_t *fsinfo = NULL; /* free-space manager info */ H5FD_mem_t type; /* Memory type for iteration */ - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -183,9 +184,9 @@ H5O_fsinfo_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, c static void * H5O_fsinfo_copy(const void *_mesg, void *_dest) { - const H5O_fsinfo_t *fsinfo = (const H5O_fsinfo_t *)_mesg; - H5O_fsinfo_t *dest = (H5O_fsinfo_t *) _dest; - void *ret_value; /* Return value */ + const H5O_fsinfo_t *fsinfo = (const H5O_fsinfo_t *)_mesg; + H5O_fsinfo_t *dest = (H5O_fsinfo_t *) _dest; + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -224,7 +225,7 @@ H5O_fsinfo_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const voi { const H5O_fsinfo_t *fsinfo = (const H5O_fsinfo_t *)_mesg; size_t fs_addr_size = 0; - size_t ret_value; /* Return value */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR diff --git a/src/H5Oginfo.c b/src/H5Oginfo.c index 5519021..9cd0dc1 100644 --- a/src/H5Oginfo.c +++ b/src/H5Oginfo.c @@ -24,7 +24,8 @@ *------------------------------------------------------------------------- */ -#define H5O_PACKAGE /*suppress error about including H5Opkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ + #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ @@ -100,7 +101,7 @@ H5O_ginfo_decode(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_t H5 { H5O_ginfo_t *ginfo = NULL; /* Pointer to group information message */ unsigned char flags; /* Flags for encoding group info */ - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -224,7 +225,7 @@ H5O_ginfo_copy(const void *_mesg, void *_dest) { const H5O_ginfo_t *ginfo = (const H5O_ginfo_t *)_mesg; H5O_ginfo_t *dest = (H5O_ginfo_t *)_dest; - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -265,7 +266,7 @@ static size_t H5O_ginfo_size(const H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, const void *_mesg) { const H5O_ginfo_t *ginfo = (const H5O_ginfo_t *)_mesg; - size_t ret_value; /* Return value */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR diff --git a/src/H5Olayout.c b/src/H5Olayout.c index 767c4fb..16f4ee9 100644 --- a/src/H5Olayout.c +++ b/src/H5Olayout.c @@ -19,8 +19,9 @@ * Purpose: Messages related to data layout. */ -#define H5D_PACKAGE /*suppress error about including H5Dpkg */ -#define H5O_PACKAGE /*suppress error about including H5Opkg */ +#define H5D_FRIEND /*suppress error about including H5Dpkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ + #include "H5private.h" /* Generic Functions */ #include "H5Dpkg.h" /* Dataset functions */ @@ -102,7 +103,7 @@ H5O__layout_decode(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_t H5_ATTR_UNUSED { H5O_layout_t *mesg = NULL; unsigned u; - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -534,7 +535,7 @@ H5O__layout_copy(const void *_mesg, void *_dest) { const H5O_layout_t *mesg = (const H5O_layout_t *) _mesg; H5O_layout_t *dest = (H5O_layout_t *) _dest; - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -615,7 +616,7 @@ static size_t H5O__layout_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void *_mesg) { const H5O_layout_t *mesg = (const H5O_layout_t *) _mesg; - size_t ret_value; + size_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -771,8 +772,8 @@ H5O__layout_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst, H5D_copy_file_ud_t *udata = (H5D_copy_file_ud_t *)_udata; /* Dataset copying user data */ H5O_layout_t *layout_src = (H5O_layout_t *) mesg_src; H5O_layout_t *layout_dst = NULL; - hbool_t copied = FALSE; /* Whether the data was copied */ - void *ret_value; /* Return value */ + hbool_t copied = FALSE; /* Whether the data was copied */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC diff --git a/src/H5Olinfo.c b/src/H5Olinfo.c index a0b6e4a..62e63d4 100644 --- a/src/H5Olinfo.c +++ b/src/H5Olinfo.c @@ -24,9 +24,10 @@ *------------------------------------------------------------------------- */ -#define H5G_PACKAGE /*suppress error about including H5Gpkg */ -#define H5L_PACKAGE /*suppress error about including H5Lpkg */ -#define H5O_PACKAGE /*suppress error about including H5Opkg */ +#define H5G_FRIEND /*suppress error about including H5Gpkg */ +#define H5L_FRIEND /*suppress error about including H5Lpkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ + #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ @@ -119,7 +120,7 @@ H5O_linfo_decode(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_t H5_ATTR_UNUSED *o { H5O_linfo_t *linfo = NULL; /* Link info */ unsigned char index_flags; /* Flags for encoding link index info */ - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -249,7 +250,7 @@ H5O_linfo_copy(const void *_mesg, void *_dest) { const H5O_linfo_t *linfo = (const H5O_linfo_t *)_mesg; H5O_linfo_t *dest = (H5O_linfo_t *) _dest; - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -289,7 +290,7 @@ static size_t H5O_linfo_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void *_mesg) { const H5O_linfo_t *linfo = (const H5O_linfo_t *)_mesg; - size_t ret_value; /* Return value */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -383,10 +384,10 @@ H5O_linfo_copy_file(H5F_t H5_ATTR_UNUSED *file_src, void *native_src, H5F_t *fil hbool_t H5_ATTR_UNUSED *recompute_size, unsigned H5_ATTR_UNUSED *mesg_flags, H5O_copy_t *cpy_info, void *_udata, hid_t dxpl_id) { - H5O_linfo_t *linfo_src = (H5O_linfo_t *) native_src; - H5O_linfo_t *linfo_dst = NULL; + H5O_linfo_t *linfo_src = (H5O_linfo_t *) native_src; + H5O_linfo_t *linfo_dst = NULL; H5G_copy_file_ud_t *udata = (H5G_copy_file_ud_t *) _udata; - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_TAG(dxpl_id, H5AC__COPIED_TAG, NULL) diff --git a/src/H5Olink.c b/src/H5Olink.c index 53191ca..d3c7f73 100644 --- a/src/H5Olink.c +++ b/src/H5Olink.c @@ -24,9 +24,10 @@ *------------------------------------------------------------------------- */ -#define H5G_PACKAGE /*suppress error about including H5Gpkg */ -#define H5L_PACKAGE /*suppress error about including H5Lpkg */ -#define H5O_PACKAGE /*suppress error about including H5Opkg */ +#define H5G_FRIEND /*suppress error about including H5Gpkg */ +#define H5L_FRIEND /*suppress error about including H5Lpkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ + #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ @@ -124,7 +125,7 @@ H5O_link_decode(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_t H5_ATTR_UNUSED *op H5O_link_t *lnk = NULL; /* Pointer to link message */ size_t len = 0; /* Length of a string in the message */ unsigned char link_flags; /* Flags for encoding link info */ - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -411,7 +412,7 @@ H5O_link_copy(const void *_mesg, void *_dest) { const H5O_link_t *lnk = (const H5O_link_t *) _mesg; H5O_link_t *dest = (H5O_link_t *) _dest; - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -478,9 +479,9 @@ static size_t H5O_link_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void *_mesg) { const H5O_link_t *lnk = (const H5O_link_t *)_mesg; - uint64_t name_len; /* Length of name */ - size_t name_size; /* Size of encoded name length */ - size_t ret_value; /* Return value */ + uint64_t name_len; /* Length of name */ + size_t name_size; /* Size of encoded name length */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -727,7 +728,7 @@ H5O_link_copy_file(H5F_t H5_ATTR_UNUSED *file_src, void *native_src, H5F_t H5_AT H5O_copy_t H5_ATTR_UNUSED *cpy_info, void H5_ATTR_UNUSED *udata, hid_t H5_ATTR_UNUSED dxpl_id) { H5O_link_t *link_src = (H5O_link_t *)native_src; - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT diff --git a/src/H5Omessage.c b/src/H5Omessage.c index c2756ea..d42896c 100644 --- a/src/H5Omessage.c +++ b/src/H5Omessage.c @@ -28,7 +28,8 @@ /* Module Setup */ /****************/ -#define H5O_PACKAGE /*suppress error about including H5Opkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ + /***********/ /* Headers */ @@ -465,7 +466,7 @@ H5O_msg_read(const H5O_loc_t *loc, unsigned type_id, void *mesg, hid_t dxpl_id) { H5O_t *oh = NULL; /* Object header to use */ - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_TAG(dxpl_id, loc->addr, NULL) @@ -652,7 +653,7 @@ void * H5O_msg_free(unsigned type_id, void *mesg) { const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - void * ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -749,7 +750,7 @@ void * H5O_msg_copy(unsigned type_id, const void *mesg, void *dst) { const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -789,7 +790,7 @@ H5O_msg_count(const H5O_loc_t *loc, unsigned type_id, hid_t dxpl_id) H5O_t *oh = NULL; /* Object header to operate on */ const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ unsigned msg_count; /* Message count */ - int ret_value; /* Return value */ + int ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -836,7 +837,7 @@ unsigned H5O_msg_count_real(const H5O_t *oh, const H5O_msg_class_t *type) { unsigned u; /* Local index variable */ - unsigned ret_value; /* Return value */ + unsigned ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -875,7 +876,7 @@ htri_t H5O_msg_exists(const H5O_loc_t *loc, unsigned type_id, hid_t dxpl_id) { H5O_t *oh = NULL; /* Object header for location */ - htri_t ret_value; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_TAG(dxpl_id, loc->addr, FAIL) @@ -966,8 +967,8 @@ H5O_msg_remove(const H5O_loc_t *loc, unsigned type_id, int sequence, hbool_t adj hid_t dxpl_id) { H5O_t *oh = NULL; /* Pointer to actual object header */ - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - herr_t ret_value; /* Return value */ + const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1018,8 +1019,8 @@ H5O_msg_remove_op(const H5O_loc_t *loc, unsigned type_id, int sequence, H5O_operator_t op, void *op_data, hbool_t adj_link, hid_t dxpl_id) { H5O_t *oh = NULL; /* Pointer to actual object header */ - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - herr_t ret_value; /* Return value */ + const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1210,7 +1211,7 @@ H5O_msg_iterate(const H5O_loc_t *loc, unsigned type_id, { H5O_t *oh = NULL; /* Pointer to actual object header */ const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - herr_t ret_value; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1359,7 +1360,7 @@ H5O_msg_raw_size(const H5F_t *f, unsigned type_id, hbool_t disable_shared, const void *mesg) { const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - size_t ret_value; /* Return value */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI(0) @@ -1404,7 +1405,7 @@ H5O_msg_size_f(const H5F_t *f, hid_t ocpl_id, unsigned type_id, const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ H5P_genplist_t *ocpl; /* Object Creation Property list */ uint8_t oh_flags; /* Object header status flags */ - size_t ret_value; /* Return value */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI(0) @@ -1466,7 +1467,7 @@ H5O_msg_size_oh(const H5F_t *f, const H5O_t *oh, unsigned type_id, const void *mesg, size_t extra_raw) { const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - size_t ret_value; /* Return value */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI(0) @@ -1517,7 +1518,7 @@ htri_t H5O_msg_can_share(unsigned type_id, const void *mesg) { const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - htri_t ret_value; + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1564,7 +1565,7 @@ htri_t H5O_msg_can_share_in_ohdr(unsigned type_id) { const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - htri_t ret_value; + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1602,7 +1603,7 @@ htri_t H5O_msg_is_shared(unsigned type_id, const void *mesg) { const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - htri_t ret_value; + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1816,8 +1817,8 @@ H5O_msg_decode(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, unsigned type_id, const unsigned char *buf) { const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - void *ret_value; /* Return value */ unsigned ioflags = 0; /* Flags for decode routine */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -1859,7 +1860,7 @@ H5O_msg_copy_file(const H5O_msg_class_t *type, H5F_t *file_src, void *native_src, H5F_t *file_dst, hbool_t *recompute_size, unsigned *mesg_flags, H5O_copy_t *cpy_info, void *udata, hid_t dxpl_id) { - void *ret_value; + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -2047,7 +2048,7 @@ H5O_msg_delete(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, unsigned type_id, const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(NULL) + FUNC_ENTER_NOAPI(FAIL) /* check args */ HDassert(f); @@ -2276,7 +2277,7 @@ H5O_msg_get_chunkno(const H5O_loc_t *loc, unsigned type_id, hid_t dxpl_id) const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ H5O_mesg_t *idx_msg; /* Pointer to message to modify */ unsigned idx; /* Index of message to modify */ - int ret_value; /* Return value */ + int ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI(FAIL) diff --git a/src/H5Omodule.h b/src/H5Omodule.h new file mode 100644 index 0000000..a8f1301 --- /dev/null +++ b/src/H5Omodule.h @@ -0,0 +1,35 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Quincey Koziol <koziol@hdfgroup.org> + * Saturday, September 12, 2015 + * + * Purpose: This file contains declarations which define macros for the + * H5O package. Including this header means that the source file + * is part of the H5O package. + */ +#ifndef _H5Omodule_H +#define _H5Omodule_H + +/* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error + * reporting macros. + */ +#define H5O_MODULE +#define H5_MY_PKG H5O +#define H5_MY_PKG_ERR H5E_OHDR +#define H5_MY_PKG_INIT YES + +#endif /* _H5Omodule_H */ + diff --git a/src/H5Omtime.c b/src/H5Omtime.c index 63ba152..622d57d 100644 --- a/src/H5Omtime.c +++ b/src/H5Omtime.c @@ -19,7 +19,8 @@ * Purpose: The object modification time message. */ -#define H5O_PACKAGE /*suppress error about including H5Opkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ + #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ @@ -126,8 +127,8 @@ H5O_mtime_new_decode(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_ unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, const uint8_t *p) { time_t *mesg; - uint32_t tmp_time; /* Temporary copy of the time */ - void *ret_value; /* Return value */ + uint32_t tmp_time; /* Temporary copy of the time */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -184,7 +185,7 @@ H5O_mtime_decode(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_t H5 time_t *mesg, the_time; int i; struct tm tm; - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -352,7 +353,7 @@ H5O_mtime_copy(const void *_mesg, void *_dest) { const time_t *mesg = (const time_t *) _mesg; time_t *dest = (time_t *) _dest; - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT diff --git a/src/H5Oname.c b/src/H5Oname.c index 2cd9e72..6c4f76f 100644 --- a/src/H5Oname.c +++ b/src/H5Oname.c @@ -24,7 +24,8 @@ *------------------------------------------------------------------------- */ -#define H5O_PACKAGE /*suppress error about including H5Opkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ + #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ @@ -88,7 +89,7 @@ H5O_name_decode(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_t H5_ unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, const uint8_t *p) { H5O_name_t *mesg; - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -170,9 +171,9 @@ H5O_name_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, static void * H5O_name_copy(const void *_mesg, void *_dest) { - const H5O_name_t *mesg = (const H5O_name_t *) _mesg; - H5O_name_t *dest = (H5O_name_t *) _dest; - void *ret_value; /* Return value */ + const H5O_name_t *mesg = (const H5O_name_t *) _mesg; + H5O_name_t *dest = (H5O_name_t *) _dest; + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -223,7 +224,7 @@ static size_t H5O_name_size(const H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, const void *_mesg) { const H5O_name_t *mesg = (const H5O_name_t *) _mesg; - size_t ret_value; + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR diff --git a/src/H5Onull.c b/src/H5Onull.c index a6c6524..258f695 100644 --- a/src/H5Onull.c +++ b/src/H5Onull.c @@ -24,7 +24,8 @@ *------------------------------------------------------------------------- */ -#define H5O_PACKAGE /*suppress error about including H5Opkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ + #include "H5private.h" /* Generic Functions */ #include "H5Opkg.h" /* Object headers */ diff --git a/src/H5Opkg.h b/src/H5Opkg.h index af9c320..db37d9f 100644 --- a/src/H5Opkg.h +++ b/src/H5Opkg.h @@ -13,7 +13,7 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef H5O_PACKAGE +#if !(defined H5O_FRIEND || defined H5O_MODULE) #error "Do not include this file outside the H5O package!" #endif diff --git a/src/H5Opline.c b/src/H5Opline.c index b79a73c..95a82b5 100644 --- a/src/H5Opline.c +++ b/src/H5Opline.c @@ -20,8 +20,9 @@ * Purpose: Data filter pipeline message. */ -#define H5O_PACKAGE /*suppress error about including H5Opkg */ -#define H5Z_PACKAGE /*suppress error about including H5Zpkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#define H5Z_FRIEND /*suppress error about including H5Zpkg */ + #include "H5private.h" /* Generic Functions */ #include "H5Dprivate.h" /* Datasets */ @@ -116,7 +117,7 @@ H5O_pline_decode(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_t H5 H5Z_filter_info_t *filter; /* Filter to decode */ size_t name_length; /* Length of filter name */ size_t i; /* Local index variable */ - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -344,7 +345,7 @@ H5O_pline_copy(const void *_src, void *_dst/*out*/) const H5O_pline_t *src = (const H5O_pline_t *)_src; /* Source pipeline message */ H5O_pline_t *dst = (H5O_pline_t *)_dst; /* Destination pipeline message */ size_t i; /* Local index variable */ - H5O_pline_t *ret_value; /* Return value */ + H5O_pline_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -434,7 +435,7 @@ H5O_pline_size(const H5F_t H5_ATTR_UNUSED *f, const void *mesg) { const H5O_pline_t *pline = (const H5O_pline_t*)mesg; /* Pipeline message */ size_t i; /* Local index variable */ - size_t ret_value; /* Return value */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index 21cf49a..dff6aba 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -110,11 +110,11 @@ typedef struct H5O_proxy_t H5O_proxy_t; #define H5O_CPY_MCDT_SEARCH_CB_NAME "committed dtype list search" /* Callback function when the search for a matching committed datatype is complete */ /* If the module using this macro is allowed access to the private variables, access them directly */ -#ifdef H5O_PACKAGE +#ifdef H5O_MODULE #define H5O_OH_GET_ADDR(O) ((O)->chunk[0].addr) -#else /* H5O_PACKAGE */ +#else /* H5O_MODULE */ #define H5O_OH_GET_ADDR(O) (H5O_get_oh_addr(O)) -#endif /* H5O_PACKAGE */ +#endif /* H5O_MODULE */ /* Set the fields in a shared message structure */ #define H5O_UPDATE_SHARED(SH_MESG, SH_TYPE, F, MSG_TYPE, CRT_IDX, OH_ADDR) \ diff --git a/src/H5Oproxy.c b/src/H5Oproxy.c index 3675ba3..f5a4315 100644 --- a/src/H5Oproxy.c +++ b/src/H5Oproxy.c @@ -38,7 +38,7 @@ /* Module Setup */ /****************/ -#define H5O_PACKAGE /*suppress error about including H5Opkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ /***********/ diff --git a/src/H5Orefcount.c b/src/H5Orefcount.c index f5c7e25..ff7dfee 100644 --- a/src/H5Orefcount.c +++ b/src/H5Orefcount.c @@ -24,7 +24,8 @@ *------------------------------------------------------------------------- */ -#define H5O_PACKAGE /*suppress error about including H5Opkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ + #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ @@ -93,8 +94,8 @@ static void * H5O_refcount_decode(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, const uint8_t *p) { - H5O_refcount_t *refcount = NULL; /* Reference count */ - void *ret_value; /* Return value */ + H5O_refcount_t *refcount = NULL; /* Reference count */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -177,9 +178,9 @@ H5O_refcount_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shar static void * H5O_refcount_copy(const void *_mesg, void *_dest) { - const H5O_refcount_t *refcount = (const H5O_refcount_t *)_mesg; - H5O_refcount_t *dest = (H5O_refcount_t *) _dest; - void *ret_value; /* Return value */ + const H5O_refcount_t *refcount = (const H5O_refcount_t *)_mesg; + H5O_refcount_t *dest = (H5O_refcount_t *) _dest; + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT diff --git a/src/H5Osdspace.c b/src/H5Osdspace.c index 8d357c2..0f3eb5d 100644 --- a/src/H5Osdspace.c +++ b/src/H5Osdspace.c @@ -13,8 +13,8 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#define H5O_PACKAGE /*suppress error about including H5Opkg */ -#define H5S_PACKAGE /*prevent warning from including H5Spkg.h */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#define H5S_FRIEND /*prevent warning from including H5Spkg.h */ #include "H5private.h" /* Generic Functions */ #include "H5Dprivate.h" /* Datasets */ @@ -115,9 +115,9 @@ H5O_sdspace_decode(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_t H5_ATTR_UNUSED unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, const uint8_t *p) { H5S_extent_t *sdim = NULL;/* New extent dimensionality structure */ - void *ret_value; - unsigned i; /* local counting variable */ unsigned flags, version; + unsigned i; /* Local counting variable */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -302,7 +302,7 @@ H5O_sdspace_copy(const void *_mesg, void *_dest) { const H5S_extent_t *mesg = (const H5S_extent_t *)_mesg; H5S_extent_t *dest = (H5S_extent_t *)_dest; - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -352,7 +352,7 @@ static size_t H5O_sdspace_size(const H5F_t *f, const void *_mesg) { const H5S_extent_t *space = (const H5S_extent_t *)_mesg; - size_t ret_value; + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR diff --git a/src/H5Oshared.c b/src/H5Oshared.c index c5c088a..25baa88 100644 --- a/src/H5Oshared.c +++ b/src/H5Oshared.c @@ -30,7 +30,7 @@ /* Module Setup */ /****************/ -#define H5O_PACKAGE /*suppress error about including H5Opkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ /***********/ @@ -313,7 +313,7 @@ H5O_shared_decode(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, unsigned *ioflags, { H5O_shared_t sh_mesg; /* Shared message info */ unsigned version; /* Shared message version */ - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -477,7 +477,7 @@ H5O_set_shared(H5O_shared_t *dst, const H5O_shared_t *src) size_t H5O_shared_size(const H5F_t *f, const H5O_shared_t *sh_mesg) { - size_t ret_value; /* Return value */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR diff --git a/src/H5Oshared.h b/src/H5Oshared.h index 2ac2a98..e8d620a 100644 --- a/src/H5Oshared.h +++ b/src/H5Oshared.h @@ -51,7 +51,7 @@ static H5_INLINE void * H5O_SHARED_DECODE(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, const uint8_t *p) { - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -166,7 +166,7 @@ static H5_INLINE size_t H5O_SHARED_SIZE(const H5F_t *f, hbool_t disable_shared, const void *_mesg) { const H5O_shared_t *sh_mesg = (const H5O_shared_t *)_mesg; /* Pointer to shared message portion of actual message */ - size_t ret_value; /* Return value */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -324,7 +324,7 @@ H5O_SHARED_COPY_FILE(H5F_t *file_src, void *_native_src, H5F_t *file_dst, void *udata, hid_t dxpl_id) { void *dst_mesg = NULL; /* Destination message */ - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT diff --git a/src/H5Oshmesg.c b/src/H5Oshmesg.c index deb10ab..a506ce2 100644 --- a/src/H5Oshmesg.c +++ b/src/H5Oshmesg.c @@ -21,7 +21,8 @@ * information in the superblock extension. */ -#define H5O_PACKAGE /*suppress error about including H5Opkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ + #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ @@ -79,8 +80,8 @@ static void * H5O_shmesg_decode(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, const uint8_t *p) { - H5O_shmesg_table_t *mesg; /* Native message */ - void *ret_value; /* Return value */ + H5O_shmesg_table_t *mesg; /* Native message */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -156,7 +157,7 @@ H5O_shmesg_copy(const void *_mesg, void *_dest) { const H5O_shmesg_table_t *mesg = (const H5O_shmesg_table_t *)_mesg; H5O_shmesg_table_t *dest = (H5O_shmesg_table_t *)_dest; - void *ret_value; + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -194,7 +195,7 @@ done: static size_t H5O_shmesg_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void H5_ATTR_UNUSED *_mesg) { - size_t ret_value; + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR diff --git a/src/H5Ostab.c b/src/H5Ostab.c index 133a3e2..bb39e58 100644 --- a/src/H5Ostab.c +++ b/src/H5Ostab.c @@ -24,8 +24,9 @@ *------------------------------------------------------------------------- */ -#define H5G_PACKAGE /*suppress error about including H5Gpkg */ -#define H5O_PACKAGE /*suppress error about including H5Opkg */ +#define H5G_FRIEND /*suppress error about including H5Gpkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ + #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ @@ -101,7 +102,7 @@ H5O_stab_decode(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_t H5_ATTR_UNUSED *op unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, const uint8_t *p) { H5O_stab_t *stab = NULL; - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -180,9 +181,9 @@ H5O_stab_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, con static void * H5O_stab_copy(const void *_mesg, void *_dest) { - const H5O_stab_t *stab = (const H5O_stab_t *) _mesg; - H5O_stab_t *dest = (H5O_stab_t *) _dest; - void *ret_value; /* Return value */ + const H5O_stab_t *stab = (const H5O_stab_t *) _mesg; + H5O_stab_t *dest = (H5O_stab_t *) _dest; + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -222,7 +223,7 @@ done: static size_t H5O_stab_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void H5_ATTR_UNUSED *_mesg) { - size_t ret_value; /* Return value */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -314,8 +315,8 @@ H5O_stab_copy_file(H5F_t *file_src, void *native_src, H5F_t *file_dst, H5O_stab_t *stab_src = (H5O_stab_t *) native_src; H5O_stab_t *stab_dst = NULL; H5G_copy_file_ud_t *udata = (H5G_copy_file_ud_t *)_udata; - size_t size_hint; /* Local heap initial size */ - void *ret_value; /* Return value */ + size_t size_hint; /* Local heap initial size */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT diff --git a/src/H5Ostorage.c b/src/H5Ostorage.c new file mode 100644 index 0000000..5268bee --- /dev/null +++ b/src/H5Ostorage.c @@ -0,0 +1,753 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* Programmer: Quincey Koziol <koziol@hdfgroup.org> + * Wednesday, July 29, 2009 + * + * Purpose: Message related to data storage. + */ + +#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#define H5D_FRIEND /* Suppress error about including H5Dpkg */ + +#include "H5private.h" /* Generic Functions */ +#include "H5Dpkg.h" /* Dataset functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ + + +/* Local macros */ + +/* Current version of storage information */ +#define H5O_STORAGE_VERSION 0 + +/* Flags for chunked storage feature encoding */ +#ifdef NOT_YET +#define H5O_STORAGE_CHUNK_HAVE_ELEM_INDEX 0x02 +#define H5O_STORAGE_ALL_CHUNK_FLAGS ( \ + H5O_STORAGE_CHUNK_HAVE_ELEM_INDEX \ + | H5O_STORAGE_CHUNK_HAVE_CHUNK_INDEX \ + ) +#else /* NOT_YET */ +#define H5O_STORAGE_CHUNK_HAVE_CHUNK_INDEX 0x01 +#define H5O_STORAGE_ALL_CHUNK_FLAGS H5O_STORAGE_CHUNK_HAVE_CHUNK_INDEX +#endif /* NOT_YET */ + + +/* PRIVATE PROTOTYPES */ +static void *H5O_storage_decode(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, + unsigned mesg_flags, unsigned *ioflags, const uint8_t *p); +static herr_t H5O_storage_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg); +static size_t H5O_storage_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); +static herr_t H5O_storage_free(void *_mesg); +static herr_t H5O_storage_delete(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, + void *_mesg); +static void *H5O_storage_copy_file(H5F_t *file_src, void *mesg_src, + H5F_t *file_dst, hbool_t *recompute_size, unsigned *mesg_flags, + H5O_copy_t *cpy_info, void *udata, hid_t dxpl_id); +static herr_t H5O_storage_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE * stream, + int indent, int fwidth); + +/* This message derives from H5O message class */ +const H5O_msg_class_t H5O_MSG_STORAGE[1] = {{ + H5O_STORAGE_ID, /*message id number */ + "storage", /*message name for debugging */ + sizeof(H5O_storage_t), /*native message size */ + 0, /* messages are sharable? */ + H5O_storage_decode, /*decode message */ + H5O_storage_encode, /*encode message */ + H5O_storage_copy, /*copy the native value */ + H5O_storage_size, /*size of message on disk */ + H5O_storage_reset, /*reset method */ + H5O_storage_free, /*free the struct */ + H5O_storage_delete, /* file delete method */ + NULL, /* link method */ + NULL, /*set share method */ + NULL, /*can share method */ + NULL, /* pre copy native value to file */ + H5O_storage_copy_file, /* copy native value to file */ + NULL, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O_storage_debug /*debug the message */ +}}; + + +/* Declare a free list to manage the H5O_storage_t struct */ +H5FL_DEFINE_STATIC(H5O_storage_t); + + +/*------------------------------------------------------------------------- + * Function: H5O_storage_decode + * + * Purpose: Decode a data storage message and return a pointer to a + * new one created with malloc(). + * + * Return: Success: Ptr to new message in native order. + * Failure: NULL + * + * Programmer: Quincey Koziol + * Wednesday, July 29, 2009 + * + *------------------------------------------------------------------------- + */ +static void * +H5O_storage_decode(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_t H5_ATTR_UNUSED *open_oh, + unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, const uint8_t *p) +{ + H5O_storage_t *mesg = NULL; /* Message decoded */ + uint8_t version; /* Version of message decoded */ + void *ret_value; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* check args */ + HDassert(f); + HDassert(p); + + /* Allocate new message */ + if(NULL == (mesg = H5FL_CALLOC(H5O_storage_t))) + HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "memory allocation failed") + + /* decode */ + version = *p++; + if(H5O_STORAGE_VERSION != version) + HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for message") + + /* Layout class */ + mesg->type = (H5D_layout_t)*p++; + + /* Interpret the rest of the message according to the layout class */ + switch(mesg->type) { + case H5D_COMPACT: + /* Compact data size */ + UINT16DECODE(p, mesg->u.compact.size); + + /* Check for any data stored */ + if(mesg->u.compact.size > 0) { + /* Allocate space for compact data */ + if(NULL == (mesg->u.compact.buf = H5MM_malloc(mesg->u.compact.size))) + HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "memory allocation failed for compact data buffer") + + /* Compact data */ + HDmemcpy(mesg->u.compact.buf, p, mesg->u.compact.size); + p += mesg->u.compact.size; + } /* end if */ + break; + + case H5D_CONTIGUOUS: + /* Contiguous storage address */ + H5F_addr_decode(f, &p, &(mesg->u.contig.addr)); + + /* Contiguous storage size */ + H5F_DECODE_LENGTH(f, p, mesg->u.contig.size); + break; + + case H5D_CHUNKED: + { + uint8_t flags; /* Flags for decoding chunk feature info */ + + /* Get the chunked layout flags */ + flags = *p++; + + /* Check for valid flags */ + if(flags & ~H5O_STORAGE_ALL_CHUNK_FLAGS) + HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad flag value for message") + + /* Check for chunk index */ + if(flags & H5O_STORAGE_CHUNK_HAVE_CHUNK_INDEX) { + /* Chunk index type */ + mesg->u.chunk.idx_type = (H5D_chunk_index_t)*p++; + switch(mesg->u.chunk.idx_type) { + case H5D_CHUNK_IDX_NONE: + /* Set the chunk operations */ + mesg->u.chunk.ops = H5D_COPS_NONE; + break; + + case H5D_CHUNK_IDX_FARRAY: + /* Set the chunk operations */ + mesg->u.chunk.ops = H5D_COPS_FARRAY; + break; + + case H5D_CHUNK_IDX_EARRAY: + /* Set the chunk operations */ + mesg->u.chunk.ops = H5D_COPS_EARRAY; + break; + + case H5D_CHUNK_IDX_BT2: /* v2 B-tree index */ + /* Set the chunk operations */ + mesg->u.chunk.ops = H5D_COPS_BT2; + break; + + default: + HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "Invalid chunk index type") + } /* end switch */ + + /* Chunk index address */ + H5F_addr_decode(f, &p, &(mesg->u.chunk.idx_addr)); + } /* end if */ + } /* end block */ + break; + + default: + HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "Invalid layout class") + } /* end switch */ + + /* Set return value */ + ret_value = mesg; + +done: + if(ret_value == NULL) + if(mesg) + (void)H5FL_FREE(H5O_storage_t, mesg); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_storage_decode() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_storage_encode + * + * Purpose: Encodes a message. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Wednesday, July 29, 2009 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5O_storage_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, + const void *_mesg) +{ + const H5O_storage_t *mesg = (const H5O_storage_t *) _mesg; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* check args */ + HDassert(f); + HDassert(mesg); + HDassert(p); + + /* Message version */ + *p++ = (uint8_t)H5O_STORAGE_VERSION; + + /* Layout class */ + *p++ = mesg->type; + + /* Write out layout class specific information */ + switch(mesg->type) { + case H5D_COMPACT: + /* Size of raw data */ + UINT16ENCODE(p, mesg->u.compact.size); + + /* Raw data */ + if(mesg->u.compact.size > 0) { + if(mesg->u.compact.buf) + HDmemcpy(p, mesg->u.compact.buf, mesg->u.compact.size); + else + HDmemset(p, 0, mesg->u.compact.size); + p += mesg->u.compact.size; + } /* end if */ + break; + + case H5D_CONTIGUOUS: + /* Contiguous storage address */ + H5F_addr_encode(f, &p, mesg->u.contig.addr); + + /* Contiguous storage size */ + H5F_ENCODE_LENGTH(f, p, mesg->u.contig.size); + break; + + case H5D_CHUNKED: + { + /* Chunk feature flags */ + *p++ = (uint8_t)H5O_STORAGE_CHUNK_HAVE_CHUNK_INDEX; + + /* Chunk index type */ + *p++ = (uint8_t)mesg->u.chunk.idx_type; + + /* Chunk index address */ + H5F_addr_encode(f, &p, mesg->u.chunk.idx_addr); + } /* end block */ + break; + + default: + HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, "Invalid layout class") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_storage_encode() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_storage_copy + * + * Purpose: Copies a message from _MESG to _DEST, allocating _DEST if + * necessary. + * + * Return: Success: Ptr to _DEST + * Failure: NULL + * + * Programmer: Quincey Koziol + * Wednesday, July 29, 2009 + * + *------------------------------------------------------------------------- + */ +void * +H5O_storage_copy(const void *_mesg, void *_dest) +{ + const H5O_storage_t *mesg = (const H5O_storage_t *) _mesg; + H5O_storage_t *dest = (H5O_storage_t *) _dest; + void *ret_value; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* check args */ + HDassert(mesg); + if(!dest && NULL == (dest = H5FL_MALLOC(H5O_storage_t))) + HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "memory allocation failed") + + /* copy */ + *dest = *mesg; + + /* Deep copy the buffer for compact datasets also */ + if(mesg->type == H5D_COMPACT) { + if(mesg->u.compact.size > 0) { + /* Allocate memory for the raw data */ + if(NULL == (dest->u.compact.buf = H5MM_malloc(dest->u.compact.size))) + HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "unable to allocate memory for compact dataset") + + /* Copy over the raw data */ + HDmemcpy(dest->u.compact.buf, mesg->u.compact.buf, dest->u.compact.size); + } /* end if */ + else + HDassert(dest->u.compact.buf == NULL); + } /* end if */ + + /* Reset the pointer of the chunked storage index but not the address */ + if(dest->type == H5D_CHUNKED && dest->u.chunk.ops) + H5D_chunk_idx_reset(&dest->u.chunk, FALSE); + + /* Set return value */ + ret_value = dest; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_storage_copy() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_storage_size + * + * Purpose: Returns the size of the raw message in bytes. If it's + * compact dataset, the data part is also included. + * This function doesn't take into account message alignment. + * + * Return: Success: Message data size in bytes + * Failure: 0 + * + * Programmer: Quincey Koziol + * Wednesday, July 29, 2009 + * + *------------------------------------------------------------------------- + */ +static size_t +H5O_storage_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void *_mesg) +{ + const H5O_storage_t *mesg = (const H5O_storage_t *) _mesg; + size_t ret_value; + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + /* check args */ + HDassert(f); + HDassert(mesg); + + /* Compute the storage message's encoded size in the file */ + /* (including possible compact data) */ + ret_value = H5O_storage_meta_size(f, mesg, TRUE); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_storage_size() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_storage_reset + * + * Purpose: Frees resources within a message, but doesn't free + * the message itself. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Wednesday, July 29, 2009 + * + *------------------------------------------------------------------------- + */ +herr_t +H5O_storage_reset(void *_mesg) +{ + H5O_storage_t *mesg = (H5O_storage_t *)_mesg; + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + if(mesg) { + /* Free the compact storage buffer */ + if(H5D_COMPACT == mesg->type) + mesg->u.compact.buf = H5MM_xfree(mesg->u.compact.buf); + + /* Reset the message */ + mesg->type = H5D_CONTIGUOUS; + } /* end if */ + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5O_storage_reset() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_storage_free + * + * Purpose: Free's the message + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Wednesday, July 29, 2009 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5O_storage_free(void *_mesg) +{ + H5O_storage_t *mesg = (H5O_storage_t *) _mesg; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT + + HDassert(mesg); + + /* Free resources within the message */ + if(H5O_storage_reset(mesg) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free message resources") + + (void)H5FL_FREE(H5O_storage_t, mesg); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_storage_free() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_storage_delete + * + * Purpose: Free file space referenced by message + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Thursday, July 30, 2009 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5O_storage_delete(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, void *_mesg) +{ + H5O_storage_t *mesg = (H5O_storage_t *) _mesg; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* check args */ + HDassert(f); + HDassert(open_oh); + HDassert(mesg); + + /* Perform different actions, depending on the type of storage */ + switch(mesg->type) { + case H5D_COMPACT: /* Compact data storage */ + /* Nothing required */ + break; + + case H5D_CONTIGUOUS: /* Contiguous block on disk */ + /* Free the file space for the raw data */ + if(H5D__contig_delete(f, dxpl_id, mesg) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free raw data") + break; + + case H5D_CHUNKED: /* Chunked blocks on disk */ + /* Free the file space for the index & chunk raw data */ + if(H5D__chunk_delete(f, dxpl_id, open_oh, mesg) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free raw data") + break; + + default: + HGOTO_ERROR(H5E_OHDR, H5E_BADTYPE, FAIL, "not valid storage type") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_storage_delete() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_storage_copy_file + * + * Purpose: Copies a message from _MESG to _DEST in file + * + * Return: Success: Ptr to _DEST + * Failure: NULL + * + * Programmer: Quincey Koziol + * Thursday, July 30, 2009 + * + *------------------------------------------------------------------------- + */ +static void * +H5O_storage_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst, + hbool_t H5_ATTR_UNUSED *recompute_size, unsigned H5_ATTR_UNUSED *mesg_flags, + H5O_copy_t *cpy_info, void *_udata, hid_t dxpl_id) +{ + H5D_copy_file_ud_t *udata = (H5D_copy_file_ud_t *)_udata; /* Dataset copying user data */ + H5O_storage_t *storage_src = (H5O_storage_t *)mesg_src; + H5O_storage_t *storage_dst = NULL; + void *ret_value; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* check args */ + HDassert(file_src); + HDassert(storage_src); + HDassert(file_dst); + HDassert(cpy_info); + HDassert(udata); + HDassert(udata->src_layout); + HDassert(udata->src_layout->version >= H5O_LAYOUT_VERSION_4 ); + + /* Allocate space for the destination storage */ + if(NULL == (storage_dst = H5FL_MALLOC(H5O_storage_t))) + HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "memory allocation failed") + + /* Copy the "top level" information */ + *storage_dst = *storage_src; + + /* Copy the storage type specific information */ + switch(storage_src->type) { + case H5D_COMPACT: + if(storage_src->u.compact.buf) { + if(NULL == (storage_dst->u.compact.buf = H5MM_malloc(storage_src->u.compact.size))) + HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "unable to allocate memory for compact dataset") + + /* Copy compact raw data */ + if(H5D__compact_copy(file_src, &storage_src->u.compact, file_dst, &storage_dst->u.compact, udata->src_dtype, cpy_info, dxpl_id) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy chunked storage") + + storage_dst->u.compact.dirty = TRUE; + } /* end if */ + break; + + case H5D_CONTIGUOUS: + if(H5D__contig_is_space_alloc(storage_src)) { + /* Copy contiguous raw data */ + if(H5D__contig_copy(file_src, &storage_src->u.contig, file_dst, &storage_dst->u.contig, udata->src_dtype, cpy_info, dxpl_id) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy contiguous storage") + } /* end if */ + break; + + case H5D_CHUNKED: + if(H5D__chunk_is_space_alloc(storage_src)) { + /* Create chunked layout */ + if(H5D__chunk_copy(file_src, &storage_src->u.chunk, &udata->src_layout->u.chunk, file_dst, &storage_dst->u.chunk, udata->src_space_extent, udata->src_dtype, udata->common.src_pline, cpy_info, dxpl_id) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy chunked storage") + } /* end if */ + break; + + default: + HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "Invalid layout class") + } /* end switch */ + + /* Freed by copy routine */ + udata->src_dtype = NULL; + + /* Set return value */ + ret_value = storage_dst; + +done: + if(!ret_value) + if(storage_dst) + (void)H5FL_FREE(H5O_storage_t, storage_dst); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_storage_copy_file() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_storage_debug + * + * Purpose: Prints debugging info for a message. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Thursday, July 30, 2009 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5O_storage_debug(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, const void *_mesg, + FILE * stream, int indent, int fwidth) +{ + const H5O_storage_t *mesg = (const H5O_storage_t *) _mesg; + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + /* check args */ + HDassert(f); + HDassert(mesg); + HDassert(stream); + HDassert(indent >= 0); + HDassert(fwidth >= 0); + + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, + "Version:", (unsigned)H5O_STORAGE_VERSION); + switch(mesg->type) { + case H5D_CHUNKED: + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, + "Type:", "Chunked"); + + /* Index information */ + switch(mesg->u.chunk.idx_type) { + case H5D_CHUNK_IDX_BTREE: + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, + "Index Type:", "v1 B-tree"); + break; + + case H5D_CHUNK_IDX_NONE: + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, + "Index Type:", "None"); + break; + + case H5D_CHUNK_IDX_FARRAY: + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, + "Index Type:", "Fixed Array"); + break; + + case H5D_CHUNK_IDX_EARRAY: + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, + "Index Type:", "Extensible Array"); + break; + + case H5D_CHUNK_IDX_BT2: + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, + "Index Type:", "v2 B-tree"); + break; + + default: + HDfprintf(stream, "%*s%-*s %s (%u)\n", indent, "", fwidth, + "Index Type:", "Unknown", (unsigned)mesg->u.chunk.idx_type); + break; + } /* end switch */ + HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, + "Index address:", mesg->u.chunk.idx_addr); + break; + + case H5D_CONTIGUOUS: + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, + "Type:", "Contiguous"); + HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, + "Data address:", mesg->u.contig.addr); + HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, + "Data Size:", mesg->u.contig.size); + break; + + case H5D_COMPACT: + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, + "Type:", "Compact"); + HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, + "Data Size:", mesg->u.compact.size); + break; + + default: + HDfprintf(stream, "%*s%-*s %s (%u)\n", indent, "", fwidth, + "Type:", "Unknown", (unsigned)mesg->type); + break; + } /* end switch */ + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5O_storage_debug() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_storage_meta_size + * + * Purpose: Returns the size of the raw message in bytes except raw data + * part for compact dataset. This function doesn't take into + * account message alignment. + * + * Return: Success: Message data size in bytes + * Failure: 0 + * + * Programmer: Quincey Koziol + * July 29, 2009 + * + *------------------------------------------------------------------------- + */ +size_t +H5O_storage_meta_size(const H5F_t *f, const H5O_storage_t *storage, + hbool_t include_compact_data) +{ + size_t ret_value; + + FUNC_ENTER_NOAPI_NOINIT + + /* check args */ + HDassert(f); + HDassert(storage); + + ret_value = 1 + /* Version number */ + 1; /* Layout class type */ + + switch(storage->type) { + case H5D_COMPACT: + /* Size of raw data */ + ret_value += 2; + if(include_compact_data) + ret_value += storage->u.compact.size;/* data for compact dataset */ + break; + + case H5D_CONTIGUOUS: + ret_value += H5F_SIZEOF_ADDR(f); /* Address of data */ + ret_value += H5F_SIZEOF_SIZE(f); /* Length of data */ + break; + + case H5D_CHUNKED: + ret_value += 1 + /* Chunk feature flags */ + 1; /* Chunk index type */ + ret_value += H5F_SIZEOF_ADDR(f); /* Chunk index address or data address */ + break; + + default: + HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, 0, "Invalid layout class") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_storage_meta_size() */ + diff --git a/src/H5Otest.c b/src/H5Otest.c index 66fd092..040a09f 100644 --- a/src/H5Otest.c +++ b/src/H5Otest.c @@ -23,8 +23,8 @@ /* Module Setup */ /****************/ -#define H5A_PACKAGE /*suppress error about including H5Apkg */ -#define H5O_PACKAGE /*suppress error about including H5Opkg */ +#define H5A_FRIEND /*suppress error about including H5Apkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ #define H5O_TESTING /*suppress warning about H5O testing funcs*/ @@ -99,7 +99,7 @@ H5O_is_attr_dense_test(hid_t oid) H5O_t *oh = NULL; /* Object header */ H5O_ainfo_t ainfo; /* Attribute information for object */ H5O_loc_t *loc; /* Pointer to object's location */ - htri_t ret_value; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -163,9 +163,9 @@ H5O_is_attr_empty_test(hid_t oid) H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ H5O_ainfo_t ainfo; /* Attribute information for object */ htri_t ainfo_exists = FALSE; /* Whether the attribute info exists in the file */ - H5O_loc_t *loc; /* Pointer to object's location */ + H5O_loc_t *loc; /* Pointer to object's location */ hsize_t nattrs; /* Number of attributes */ - htri_t ret_value; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) diff --git a/src/H5Ounknown.c b/src/H5Ounknown.c index 548f74d..546e839 100644 --- a/src/H5Ounknown.c +++ b/src/H5Ounknown.c @@ -24,7 +24,8 @@ *------------------------------------------------------------------------- */ -#define H5O_PACKAGE /*suppress error about including H5Opkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ + #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ @@ -22,10 +22,7 @@ /* Module Setup */ /****************/ -#define H5P_PACKAGE /*suppress error about including H5Ppkg */ - -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5P__init_pub_interface +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ /***********/ @@ -62,6 +59,9 @@ typedef struct { /* Package Variables */ /*********************/ +/* Package initialization variable */ +hbool_t H5_PKG_INIT_VAR = FALSE; + /*****************************/ /* Library Private Variables */ @@ -74,51 +74,6 @@ typedef struct { /*-------------------------------------------------------------------------- -NAME - H5P__init_pub_interface -- Initialize interface-specific information -USAGE - herr_t H5P__init_pub_interface() -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. (Just calls - H5P_init() currently). - ---------------------------------------------------------------------------*/ -static herr_t -H5P__init_pub_interface(void) -{ - FUNC_ENTER_STATIC_NOERR - - FUNC_LEAVE_NOAPI(H5P_init()) -} /* H5P__init_pub_interface() */ - - -/*-------------------------------------------------------------------------- -NAME - H5P__term_pub_interface -- Terminate interface -USAGE - herr_t H5P__term_pub_interface() -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Terminates interface. (Just resets H5_interface_initialize_g - currently). - ---------------------------------------------------------------------------*/ -herr_t -H5P__term_pub_interface(void) -{ - FUNC_ENTER_PACKAGE_NOERR - - /* Mark closed */ - H5_interface_initialize_g = 0; - - FUNC_LEAVE_NOAPI(0) -} /* H5P__term_pub_interface() */ - - -/*-------------------------------------------------------------------------- NAME H5Pcopy PURPOSE @@ -16,8 +16,7 @@ /* Module Setup */ /****************/ -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5PL__init_interface +#include "H5PLmodule.h" /* This source code file is part of the H5PL module */ /***********/ @@ -52,7 +51,6 @@ * If you do not do this, people will be unable to incorporate our * source code into their own CMake builds if they define UNICODE. */ - #ifdef H5_HAVE_WIN32_API #define H5PL_PATH_SEPARATOR ";" @@ -103,6 +101,7 @@ typedef const void *(*H5PL_get_plugin_info_t)(void); /* Special symbol to indicate no plugin loading */ #define H5PL_NO_PLUGIN "::" + /******************/ /* Local Typedefs */ /******************/ @@ -130,6 +129,9 @@ static herr_t H5PL__close(H5PL_HANDLE handle); /* Package Variables */ /*********************/ +/* Package initialization variable */ +hbool_t H5_PKG_INIT_VAR = FALSE; + /*****************************/ /* Library Private Variables */ @@ -153,36 +155,94 @@ static hbool_t H5PL_path_found_g = FALSE; /* Enable all plugin libraries */ static unsigned int H5PL_plugin_g = H5PL_ALL_PLUGIN; + /*-------------------------------------------------------------------------- NAME - H5PL__init_interface -- Initialize interface-specific information + H5PL__init_package -- Initialize interface-specific information USAGE - herr_t H5PL__init_interface() + herr_t H5PL__init_package() RETURNS Non-negative on success/Negative on failure DESCRIPTION Initializes any interface-specific data or routines. --------------------------------------------------------------------------*/ -static herr_t -H5PL__init_interface(void) +herr_t +H5PL__init_package(void) { char *preload_path; - FUNC_ENTER_STATIC_NOERR + FUNC_ENTER_PACKAGE_NOERR /* Retrieve pathnames from HDF5_PLUGIN_PRELOAD if the user sets it * to tell the library to load plugin libraries without search. */ - if(NULL != (preload_path = HDgetenv("HDF5_PLUGIN_PRELOAD"))) { + if(NULL != (preload_path = HDgetenv("HDF5_PLUGIN_PRELOAD"))) /* Special symbal "::" means no plugin during data reading. */ if(!HDstrcmp(preload_path, H5PL_NO_PLUGIN)) H5PL_plugin_g = 0; - } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5PL__init_interface() */ +} /* end H5PL__init_package() */ + + +/*------------------------------------------------------------------------- + * Function: H5PL_term_package + * + * Purpose: Terminate the H5PL interface: release all memory, reset all + * global variables to initial values. This only happens if all + * types have been destroyed from other interfaces. + * + * Return: Success: Positive if any action was taken that might + * affect some other interface; zero otherwise. + * Failure: Negative. + * + * Programmer: Raymond Lu + * 20 February 2013 + * + *------------------------------------------------------------------------- + */ +int +H5PL_term_package(void) +{ + int n = 0; + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + if(H5_PKG_INIT_VAR) { + size_t u; /* Local index variable */ + + /* Close opened dynamic libraries */ + if(H5PL_table_g) { + for(u = 0; u < H5PL_table_used_g; u++) + H5PL__close((H5PL_table_g[u]).handle); + + /* Free the table of dynamic libraries */ + H5PL_table_g = (H5PL_table_t *)H5MM_xfree(H5PL_table_g); + H5PL_table_used_g = H5PL_table_alloc_g = 0; + + n++; + } /* end if */ + + /* Free the table of search paths */ + if(H5PL_num_paths_g > 0) { + for(u = 0; u < H5PL_num_paths_g; u++) + if(H5PL_path_table_g[u]) + H5PL_path_table_g[u] = (char *)H5MM_xfree(H5PL_path_table_g[u]); + H5PL_num_paths_g = 0; + H5PL_path_found_g = FALSE; + + n++; + } /* end if */ + + /* Mark the interface as uninitialized */ + if(0 == n) + H5_PKG_INIT_VAR = FALSE; + } /* end if */ + + FUNC_LEAVE_NOAPI(n) +} /* end H5PL_term_package() */ /*------------------------------------------------------------------------- @@ -209,21 +269,24 @@ H5PLset_loading_state(unsigned int plugin_type) { char *preload_path; herr_t ret_value = SUCCEED; /* Return value */ + FUNC_ENTER_API(FAIL) H5TRACE1("e", "Iu", plugin_type); + /* change the bit value of the requested plugin type(s) */ H5PL_plugin_g = plugin_type; + /* check if special ENV variable is set and disable all plugin types */ - if(NULL != (preload_path = HDgetenv("HDF5_PLUGIN_PRELOAD"))) { + if(NULL != (preload_path = HDgetenv("HDF5_PLUGIN_PRELOAD"))) /* Special symbol "::" means no plugin during data reading. */ if(!HDstrcmp(preload_path, H5PL_NO_PLUGIN)) H5PL_plugin_g = 0; - } + done: FUNC_LEAVE_API(ret_value) } /* end H5PLset_loading_state() */ - + /*------------------------------------------------------------------------- * Function: H5PLget_loading_state * @@ -240,66 +303,17 @@ herr_t H5PLget_loading_state(unsigned int *plugin_type) { herr_t ret_value = SUCCEED; /* Return value */ + FUNC_ENTER_API(FAIL) H5TRACE1("e", "*Iu", plugin_type); if(plugin_type) *plugin_type = H5PL_plugin_g; - done: + +done: FUNC_LEAVE_API(ret_value) } /* end H5PLget_loading_state() */ - - -/*------------------------------------------------------------------------- - * Function: H5PL_term_interface - * - * Purpose: Terminate the H5PL interface: release all memory, reset all - * global variables to initial values. This only happens if all - * types have been destroyed from other interfaces. - * - * Return: Success: Positive if any action was taken that might - * affect some other interface; zero otherwise. - * - * Failure: Negative. - * - * Programmer: Raymond Lu - * 20 February 2013 - * - *------------------------------------------------------------------------- - */ -int -H5PL_term_interface(void) -{ - int i = 0; - - FUNC_ENTER_NOAPI_NOINIT_NOERR - - if(H5_interface_initialize_g) { - size_t u; /* Local index variable */ - - /* Close opened dynamic libraries */ - for(u = 0; u < H5PL_table_used_g; u++) - H5PL__close((H5PL_table_g[u]).handle); - - /* Free the table of dynamic libraries */ - H5PL_table_g = (H5PL_table_t *)H5MM_xfree(H5PL_table_g); - H5PL_table_used_g = H5PL_table_alloc_g = 0; - - /* Free the table of search paths */ - for(u = 0; u < H5PL_num_paths_g; u++) - if(H5PL_path_table_g[u]) - H5PL_path_table_g[u] = (char *)H5MM_xfree(H5PL_path_table_g[u]); - H5PL_num_paths_g = 0; - H5PL_path_found_g = FALSE; - - H5_interface_initialize_g = 0; - i = 1; - } /* end if */ - - FUNC_LEAVE_NOAPI(i) -} /* end H5PL_term_interface() */ - /*------------------------------------------------------------------------- * Function: H5PL_load @@ -324,16 +338,17 @@ H5PL_load(H5PL_type_t type, int id) FUNC_ENTER_NOAPI(NULL) - switch (type) { - case H5PL_TYPE_FILTER: - if((H5PL_plugin_g & H5PL_FILTER_PLUGIN) == 0) - HGOTO_ERROR(H5E_PLUGIN, H5E_CANTLOAD, NULL, "required dynamically loaded plugin filter '%d' is not available", id) - break; - case H5PL_TYPE_ERROR: - case H5PL_TYPE_NONE: - default: - HGOTO_ERROR(H5E_PLUGIN, H5E_CANTLOAD, NULL, "required dynamically loaded plugin '%d' is not valid", id) - } + switch(type) { + case H5PL_TYPE_FILTER: + if((H5PL_plugin_g & H5PL_FILTER_PLUGIN) == 0) + HGOTO_ERROR(H5E_PLUGIN, H5E_CANTLOAD, NULL, "required dynamically loaded plugin filter '%d' is not available", id) + break; + + case H5PL_TYPE_ERROR: + case H5PL_TYPE_NONE: + default: + HGOTO_ERROR(H5E_PLUGIN, H5E_CANTLOAD, NULL, "required dynamically loaded plugin '%d' is not valid", id) + } /* end switch */ /* Initialize the location paths for dynamic libraries, if they aren't * already set up. @@ -726,3 +741,4 @@ H5PL__close(H5PL_HANDLE handle) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5PL__close() */ + diff --git a/src/H5PLmodule.h b/src/H5PLmodule.h new file mode 100644 index 0000000..0339737 --- /dev/null +++ b/src/H5PLmodule.h @@ -0,0 +1,36 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Quincey Koziol <koziol@hdfgroup.org> + * Saturday, September 12, 2015 + * + * Purpose: This file contains declarations which define macros for the + * H5PL package. Including this header means that the source file + * is part of the H5PL package. + */ +#ifndef _H5PLmodule_H +#define _H5PLmodule_H + +/* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error + * reporting macros. + */ +#define H5PL_MODULE +#define H5_MY_PKG H5PL +#define H5_MY_PKG_ERR H5E_PLUGIN +#define H5_MY_PKG_INIT YES + +#endif /* _H5PLmodule_H */ + + diff --git a/src/H5Pacpl.c b/src/H5Pacpl.c index 0a0641c..bfed332 100644 --- a/src/H5Pacpl.c +++ b/src/H5Pacpl.c @@ -27,7 +27,9 @@ /****************/ /* Module Setup */ /****************/ -#define H5P_PACKAGE /*suppress error about including H5Ppkg */ + +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ + /***********/ /* Headers */ diff --git a/src/H5Pdapl.c b/src/H5Pdapl.c index f180938..d1d8a0c 100644 --- a/src/H5Pdapl.c +++ b/src/H5Pdapl.c @@ -27,7 +27,8 @@ /****************/ /* Module Setup */ /****************/ -#define H5P_PACKAGE /*suppress error about including H5Ppkg */ + +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ /***********/ diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index 54344f2..2582fd2 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -27,9 +27,9 @@ /****************/ /* Module Setup */ /****************/ -#define H5D_PACKAGE /*suppress error about including H5Dpkg */ -#define H5P_PACKAGE /*suppress error about including H5Ppkg */ -#define H5Z_PACKAGE /*suppress error about including H5Zpkg */ + +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ +#define H5D_FRIEND /* Suppress error about including H5Dpkg */ /***********/ @@ -44,7 +44,7 @@ #include "H5Ppkg.h" /* Property lists */ #include "H5VMprivate.h" /* Vectors and arrays */ #include "H5Tprivate.h" /* Datatypes */ -#include "H5Zpkg.h" /* Data filters */ +#include "H5Zprivate.h" /* Data filters */ /****************/ @@ -2502,7 +2502,7 @@ H5Pset_fill_value(hid_t plist_id, hid_t type_id, const void *value) if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - /* Set the fill value */ + /* Set the fill value */ if(NULL == (fill.type = H5T_copy(type, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy datatype") fill.size = (ssize_t)H5T_get_size(type); diff --git a/src/H5Pdeprec.c b/src/H5Pdeprec.c index e4e91ac..ecf2bea 100644 --- a/src/H5Pdeprec.c +++ b/src/H5Pdeprec.c @@ -31,10 +31,7 @@ /* Module Setup */ /****************/ -#define H5P_PACKAGE /*suppress error about including H5Ppkg */ - -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5P__init_deprec_interface +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ /***********/ @@ -82,51 +79,6 @@ /*******************/ - -/*-------------------------------------------------------------------------- -NAME - H5P__init_deprec_interface -- Initialize interface-specific information -USAGE - herr_t H5P__init_deprec_interface() -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. (Just calls - H5P_init() currently). - ---------------------------------------------------------------------------*/ -static herr_t -H5P__init_deprec_interface(void) -{ - FUNC_ENTER_STATIC_NOERR - - FUNC_LEAVE_NOAPI(H5P_init()) -} /* H5P__init_deprec_interface() */ - - -/*-------------------------------------------------------------------------- -NAME - H5P__term_deprec_interface -- Terminate interface -USAGE - herr_t H5P__term_deprec_interface() -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Terminates interface. (Just resets H5_interface_initialize_g - currently). - ---------------------------------------------------------------------------*/ -herr_t -H5P__term_deprec_interface(void) -{ - FUNC_ENTER_PACKAGE_NOERR - - /* Mark closed */ - H5_interface_initialize_g = 0; - - FUNC_LEAVE_NOAPI(0) -} /* H5P__term_deprec_interface() */ - #ifndef H5_NO_DEPRECATED_SYMBOLS /*-------------------------------------------------------------------------- diff --git a/src/H5Pdxpl.c b/src/H5Pdxpl.c index bb30fe2..b6d5218 100644 --- a/src/H5Pdxpl.c +++ b/src/H5Pdxpl.c @@ -27,7 +27,8 @@ /****************/ /* Module Setup */ /****************/ -#define H5P_PACKAGE /*suppress error about including H5Ppkg */ + +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ /***********/ diff --git a/src/H5Pencdec.c b/src/H5Pencdec.c index 351bd52..1bcd19c 100644 --- a/src/H5Pencdec.c +++ b/src/H5Pencdec.c @@ -22,12 +22,7 @@ /* Module Setup */ /****************/ -#define H5P_PACKAGE /*suppress error about including H5Ppkg */ - -#ifdef NOT_YET -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5P_init_encdec_interface -#endif /* NOT_YET */ +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ /***********/ @@ -82,29 +77,6 @@ typedef struct { /*******************/ -#ifdef NOT_YET - -/*-------------------------------------------------------------------------- -NAME - H5P_init_encdec_interface -- Initialize interface-specific information -USAGE - herr_t H5P_init_encdec_interface() -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. (Just calls - H5P_init() currently). - ---------------------------------------------------------------------------*/ -static herr_t -H5P_init_encdec_interface(void) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - FUNC_LEAVE_NOAPI(H5P_init()) -} /* H5P_init_encdec_interface() */ -#endif /* NOT_YET */ - /*------------------------------------------------------------------------- * Function: H5P__encode_size_t @@ -737,7 +709,7 @@ H5P__decode(const void *buf) hid_t plist_id = -1; /* ID of new property list */ size_t value_buf_size = 0; /* Size of current value buffer */ uint8_t vers; /* Version of encoded property list */ - hid_t ret_value; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_PACKAGE @@ -793,7 +765,7 @@ H5P__decode(const void *buf) HGOTO_ERROR(H5E_PLIST, H5E_CANTDECODE, FAIL, "property decoding routine failed, property: '%s'", name) } /* end if */ else - HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "no decode callback for property: '%s', name") + HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "no decode callback for property: '%s'", name) /* Set the value for the property */ if(H5P_poke(plist, name, value_buf) < 0) diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c index c163dd7..ea7f5ea 100644 --- a/src/H5Pfapl.c +++ b/src/H5Pfapl.c @@ -27,7 +27,8 @@ /****************/ /* Module Setup */ /****************/ -#define H5P_PACKAGE /*suppress error about including H5Ppkg */ + +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ /***********/ diff --git a/src/H5Pfcpl.c b/src/H5Pfcpl.c index 5fc93fd..d451982 100644 --- a/src/H5Pfcpl.c +++ b/src/H5Pfcpl.c @@ -27,7 +27,8 @@ /****************/ /* Module Setup */ /****************/ -#define H5P_PACKAGE /*suppress error about including H5Ppkg */ + +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ /***********/ diff --git a/src/H5Pfmpl.c b/src/H5Pfmpl.c index 875f101..de9fa3b 100644 --- a/src/H5Pfmpl.c +++ b/src/H5Pfmpl.c @@ -27,7 +27,8 @@ /****************/ /* Module Setup */ /****************/ -#define H5P_PACKAGE /*suppress error about including H5Ppkg */ + +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ /***********/ diff --git a/src/H5Pgcpl.c b/src/H5Pgcpl.c index 1e3a278..f84fa7b 100644 --- a/src/H5Pgcpl.c +++ b/src/H5Pgcpl.c @@ -27,7 +27,9 @@ /****************/ /* Module Setup */ /****************/ -#define H5P_PACKAGE /*suppress error about including H5Ppkg */ + +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ + /***********/ /* Headers */ diff --git a/src/H5Pint.c b/src/H5Pint.c index 099d531..69b2791 100644 --- a/src/H5Pint.c +++ b/src/H5Pint.c @@ -22,10 +22,7 @@ /* Module Setup */ /****************/ -#define H5P_PACKAGE /*suppress error about including H5Ppkg */ - -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5P_init_interface +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ /***********/ @@ -114,7 +111,7 @@ static herr_t H5P__do_prop(H5P_genplist_t *plist, const char *name, H5P_do_plist /* * Predefined property list classes. These are initialized at runtime by - * H5P_init_interface() in this source file. + * H5P__init_package() in this source file. */ hid_t H5P_CLS_ROOT_ID_g = FAIL; H5P_genclass_t *H5P_CLS_ROOT_g = NULL; @@ -153,7 +150,7 @@ H5P_genclass_t *H5P_CLS_STRING_CREATE_g = NULL; /* * Predefined property lists for each predefined class. These are initialized - * at runtime by H5P_init_interface() in this source file. + * at runtime by H5P__init_package() in this source file. */ hid_t H5P_LST_FILE_CREATE_ID_g = FAIL; hid_t H5P_LST_FILE_ACCESS_ID_g = FAIL; @@ -336,14 +333,11 @@ static const H5I_class_t H5I_GENPROPLST_CLS[1] = {{ * Purpose: Initialize the interface from some other layer. * * Return: Success: non-negative - * * Failure: negative * * Programmer: Quincey Koziol * Saturday, March 4, 2000 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t @@ -361,22 +355,22 @@ done: /*-------------------------------------------------------------------------- NAME - H5P_init_interface -- Initialize interface-specific information + H5P__init_package -- Initialize interface-specific information USAGE - herr_t H5P_init_interface() + herr_t H5P__init_package() RETURNS Non-negative on success/Negative on failure DESCRIPTION Initializes any interface-specific data or routines. --------------------------------------------------------------------------*/ -static herr_t -H5P_init_interface(void) +herr_t +H5P__init_package(void) { size_t tot_init; /* Total # of classes initialized */ size_t pass_init; /* # of classes initialized in each pass */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* * Initialize the Generic Property class & object groups. @@ -439,16 +433,16 @@ H5P_init_interface(void) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_init_interface() */ +} /* end H5P__init_package() */ /*-------------------------------------------------------------------------- NAME - H5P_term_interface + H5P_term_package PURPOSE Terminate various H5P objects USAGE - void H5P_term_interface() + void H5P_term_package() RETURNS Non-negative on success/Negative on failure DESCRIPTION @@ -460,13 +454,13 @@ done: REVISION LOG --------------------------------------------------------------------------*/ int -H5P_term_interface(void) +H5P_term_package(void) { int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5_interface_initialize_g) { + if(H5_PKG_INIT_VAR) { int64_t nlist, nclass; /* Destroy HDF5 library property classes & lists */ @@ -546,25 +540,18 @@ H5P_term_interface(void) n++; /*H5I*/ } else { - /* Close public interface */ - n += H5P__term_pub_interface(); - - /* Close deprecated interface */ - n += H5P__term_deprec_interface(); - /* Destroy the property list and class id groups */ - (void)H5I_dec_type_ref(H5I_GENPROP_LST); - n++; /*H5I*/ - (void)H5I_dec_type_ref(H5I_GENPROP_CLS); - n++; /*H5I*/ + n += (H5I_dec_type_ref(H5I_GENPROP_LST) > 0); + n += (H5I_dec_type_ref(H5I_GENPROP_CLS) > 0); /* Mark closed */ - H5_interface_initialize_g = 0; + if(0 == n) + H5_PKG_INIT_VAR = FALSE; } /* end else */ } /* end if */ FUNC_LEAVE_NOAPI(n) -} /* end H5P_term_interface() */ +} /* end H5P_term_package() */ /*-------------------------------------------------------------------------- @@ -954,7 +941,7 @@ static H5P_genprop_t * H5P_dup_prop(H5P_genprop_t *oprop, H5P_prop_within_t type) { H5P_genprop_t *prop = NULL; /* Pointer to new property copied */ - H5P_genprop_t *ret_value; /* Return value */ + H5P_genprop_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1070,8 +1057,8 @@ H5P_create_prop(const char *name, size_t size, H5P_prop_within_t type, H5P_prp_copy_func_t prp_copy, H5P_prp_compare_func_t prp_cmp, H5P_prp_close_func_t prp_close) { - H5P_genprop_t *prop = NULL; /* Pointer to new property copied */ - H5P_genprop_t *ret_value; /* Return value */ + H5P_genprop_t *prop = NULL; /* Pointer to new property copied */ + H5P_genprop_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1191,7 +1178,7 @@ done: H5P_genprop_t * H5P__find_prop_plist(const H5P_genplist_t *plist, const char *name) { - H5P_genprop_t *ret_value; /* Property pointer return value */ + H5P_genprop_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -1251,7 +1238,7 @@ done: static H5P_genprop_t * H5P_find_prop_pclass(H5P_genclass_t *pclass, const char *name) { - H5P_genprop_t *ret_value; /* Property pointer return value */ + H5P_genprop_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1561,8 +1548,8 @@ H5P_create_class(H5P_genclass_t *par_class, const char *name, H5P_plist_type_t t H5P_cls_copy_func_t cls_copy, void *copy_data, H5P_cls_close_func_t cls_close, void *close_data) { - H5P_genclass_t *pclass=NULL; /* Property list class created */ - H5P_genclass_t *ret_value; /* return value */ + H5P_genclass_t *pclass = NULL; /* Property list class created */ + H5P_genclass_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -1656,10 +1643,10 @@ static H5P_genplist_t * H5P_create(H5P_genclass_t *pclass) { H5P_genclass_t *tclass; /* Temporary class pointer */ - H5P_genplist_t *plist=NULL; /* New property list created */ + H5P_genplist_t *plist = NULL; /* New property list created */ H5P_genprop_t *tmp; /* Temporary pointer to parent class properties */ - H5SL_t *seen=NULL; /* Skip list to hold names of properties already seen */ - H5P_genplist_t *ret_value; /* Return value */ + H5SL_t *seen = NULL; /* Skip list to hold names of properties already seen */ + H5P_genplist_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1795,10 +1782,10 @@ done: hid_t H5P_create_id(H5P_genclass_t *pclass, hbool_t app_ref) { - H5P_genclass_t *tclass; /* Temporary class pointer */ - H5P_genplist_t *plist = NULL; /* Property list created */ - hid_t plist_id = FAIL; /* Property list ID */ - hid_t ret_value; /* return value */ + H5P_genclass_t *tclass; /* Temporary class pointer */ + H5P_genplist_t *plist = NULL; /* Property list created */ + hid_t plist_id = FAIL; /* Property list ID */ + hid_t ret_value = H5I_INVALID_HID; /* return value */ FUNC_ENTER_NOAPI(FAIL) @@ -3690,7 +3677,7 @@ done: htri_t H5P_class_isa(const H5P_genclass_t *pclass1, const H5P_genclass_t *pclass2) { - htri_t ret_value; + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -3743,7 +3730,7 @@ H5P_isa_class(hid_t plist_id, hid_t pclass_id) { H5P_genplist_t *plist; /* Property list to query */ H5P_genclass_t *pclass; /* Property list class */ - htri_t ret_value; /* return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -3793,7 +3780,7 @@ done: H5P_genplist_t * H5P_object_verify(hid_t plist_id, hid_t pclass_id) { - H5P_genplist_t *ret_value; /* return value */ + H5P_genplist_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -5010,7 +4997,7 @@ done: char * H5P_get_class_name(H5P_genclass_t *pclass) { - char *ret_value; /* return value */ + char *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -5048,7 +5035,7 @@ done: char * H5P_get_class_path(H5P_genclass_t *pclass) { - char *ret_value; /* return value */ + char *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -5114,7 +5101,7 @@ H5P_open_class_path(const char *path) char *delimit; /* Pointer to path delimiter during traversal */ H5P_genclass_t *curr_class; /* Pointer to class during path traversal */ H5P_check_class_t check_info; /* Structure to hold the information for checking duplicate names */ - H5P_genclass_t *ret_value; /* Return value */ + H5P_genclass_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -5194,7 +5181,7 @@ done: H5P_genclass_t * H5P_get_class_parent(const H5P_genclass_t *pclass) { - H5P_genclass_t *ret_value; /* return value */ + H5P_genclass_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -5261,7 +5248,7 @@ H5P__new_plist_of_type(H5P_plist_type_t type) { H5P_genclass_t *pclass; /* Class of property list to create */ hid_t class_id; /* ID of class to create */ - hid_t ret_value; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_PACKAGE diff --git a/src/H5Plapl.c b/src/H5Plapl.c index 93e2531..f70fe5e 100644 --- a/src/H5Plapl.c +++ b/src/H5Plapl.c @@ -27,7 +27,9 @@ /****************/ /* Module Setup */ /****************/ -#define H5P_PACKAGE /*suppress error about including H5Ppkg */ + +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ + /***********/ /* Headers */ diff --git a/src/H5Plcpl.c b/src/H5Plcpl.c index cde2035..f6e7793 100644 --- a/src/H5Plcpl.c +++ b/src/H5Plcpl.c @@ -27,7 +27,8 @@ /****************/ /* Module Setup */ /****************/ -#define H5P_PACKAGE /*suppress error about including H5Ppkg */ + +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ /***********/ diff --git a/src/H5Pmodule.h b/src/H5Pmodule.h new file mode 100644 index 0000000..ddf7c0f --- /dev/null +++ b/src/H5Pmodule.h @@ -0,0 +1,35 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Quincey Koziol <koziol@hdfgroup.org> + * Saturday, September 12, 2015 + * + * Purpose: This file contains declarations which define macros for the + * H5P package. Including this header means that the source file + * is part of the H5P package. + */ +#ifndef _H5Pmodule_H +#define _H5Pmodule_H + +/* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error + * reporting macros. + */ +#define H5P_MODULE +#define H5_MY_PKG H5P +#define H5_MY_PKG_ERR H5E_PLIST +#define H5_MY_PKG_INIT YES + +#endif /* _H5Pmodule_H */ + diff --git a/src/H5Pocpl.c b/src/H5Pocpl.c index f26b84e..7ae5a6e 100644 --- a/src/H5Pocpl.c +++ b/src/H5Pocpl.c @@ -27,8 +27,9 @@ /****************/ /* Module Setup */ /****************/ -#define H5O_PACKAGE /*suppress error about including H5Opkg */ -#define H5P_PACKAGE /*suppress error about including H5Ppkg */ + +#define H5O_FRIEND /*suppress error about including H5Opkg */ +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ /***********/ diff --git a/src/H5Pocpypl.c b/src/H5Pocpypl.c index 338ecc3..7657d52 100644 --- a/src/H5Pocpypl.c +++ b/src/H5Pocpypl.c @@ -27,7 +27,8 @@ /****************/ /* Module Setup */ /****************/ -#define H5P_PACKAGE /*suppress error about including H5Ppkg */ + +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ /***********/ diff --git a/src/H5Ppkg.h b/src/H5Ppkg.h index fb8b8e9..6dffcec 100644 --- a/src/H5Ppkg.h +++ b/src/H5Ppkg.h @@ -21,7 +21,7 @@ * the H5P package. Source files outside the H5P package should * include H5Pprivate.h instead. */ -#ifndef H5P_PACKAGE +#if !(defined H5P_FRIEND || defined H5P_MODULE) #error "Do not include this file outside the H5P package!" #endif @@ -158,8 +158,6 @@ struct H5Z_filter_info_t; /******************************/ /* Private functions, not part of the publicly documented API */ -H5_DLL herr_t H5P__term_pub_interface(void); -H5_DLL herr_t H5P__term_deprec_interface(void); H5_DLL H5P_genclass_t *H5P_create_class(H5P_genclass_t *par_class, const char *name, H5P_plist_type_t type, H5P_cls_create_func_t cls_create, void *create_data, diff --git a/src/H5Pprivate.h b/src/H5Pprivate.h index e27401d..05830d1 100644 --- a/src/H5Pprivate.h +++ b/src/H5Pprivate.h @@ -33,13 +33,13 @@ #define H5P_STRCRT_CHAR_ENCODING_NAME "character_encoding" /* Character set encoding for string */ /* If the module using this macro is allowed access to the private variables, access them directly */ -#ifdef H5P_PACKAGE +#ifdef H5P_MODULE #define H5P_PLIST_ID(P) ((P)->plist_id) #define H5P_CLASS(P) ((P)->pclass) -#else /* H5F_PACKAGE */ +#else /* H5P_MODULE */ #define H5P_PLIST_ID(P) (H5P_get_plist_id(P)) #define H5P_CLASS(P) (H5P_get_class(P)) -#endif /* H5P_PACKAGE */ +#endif /* H5P_MODULE */ /****************************/ diff --git a/src/H5Pstrcpl.c b/src/H5Pstrcpl.c index 3ba625e..5a09cd7 100644 --- a/src/H5Pstrcpl.c +++ b/src/H5Pstrcpl.c @@ -27,7 +27,9 @@ /****************/ /* Module Setup */ /****************/ -#define H5P_PACKAGE /*suppress error about including H5Ppkg */ + +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ + /***********/ /* Headers */ diff --git a/src/H5Ptest.c b/src/H5Ptest.c index dead67e..63708e7 100644 --- a/src/H5Ptest.c +++ b/src/H5Ptest.c @@ -19,7 +19,7 @@ * Purpose: Generic Property Testing Functions */ -#define H5P_PACKAGE /*suppress error about including H5Ppkg */ +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ #define H5P_TESTING /*suppress warning about H5P testing funcs*/ @@ -60,8 +60,8 @@ char * H5P_get_class_path_test(hid_t pclass_id) { - H5P_genclass_t *pclass; /* Property class to query */ - char *ret_value; /* return value */ + H5P_genclass_t *pclass; /* Property class to query */ + char *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -101,8 +101,8 @@ done: hid_t H5P_open_class_path_test(const char *path) { - H5P_genclass_t *pclass=NULL;/* Property class to query */ - hid_t ret_value; /* Return value */ + H5P_genclass_t *pclass = NULL; /* Property class to query */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -17,10 +17,7 @@ /* Module Setup */ /****************/ -#define H5R_PACKAGE /*suppress error about including H5Rpkg */ - -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5R_init_interface +#include "H5Rmodule.h" /* This source code file is part of the H5R module */ /***********/ @@ -63,6 +60,9 @@ static ssize_t H5R_get_name(H5F_t *file, hid_t lapl_id, hid_t dxpl_id, hid_t id, /* Package Variables */ /*********************/ +/* Package initialization variable */ +hbool_t H5_PKG_INIT_VAR = FALSE; + /*****************************/ /* Library Private Variables */ @@ -81,39 +81,16 @@ static const H5I_class_t H5I_REFERENCE_CLS[1] = {{ NULL /* Callback routine for closing objects of this class */ }}; +/* Flag indicating "top" of interface has been initialized */ +static hbool_t H5R_top_package_initialize_s = FALSE; - -/*------------------------------------------------------------------------- - * Function: H5R_init - * - * Purpose: Initialize the interface from some other package. - * - * Return: Success: non-negative - * Failure: negative - * - * Programmer: Quincey Koziol - * Thursday, September 13, 2007 - * - *------------------------------------------------------------------------- - */ -herr_t -H5R_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 H5R_init() */ /*-------------------------------------------------------------------------- NAME - H5R_init_interface -- Initialize interface-specific information + H5R__init_package -- Initialize interface-specific information USAGE - herr_t H5R_init_interface() + herr_t H5R__init_package() RETURNS Non-negative on success/Negative on failure @@ -121,33 +98,37 @@ DESCRIPTION Initializes any interface-specific data or routines. --------------------------------------------------------------------------*/ -static herr_t -H5R_init_interface(void) +herr_t +H5R__init_package(void) { - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Initialize the atom group for the file IDs */ if(H5I_register_type(H5I_REFERENCE_CLS) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable to initialize interface"); + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable to initialize interface") + + /* Mark "top" of interface as initialized, too */ + H5R_top_package_initialize_s = TRUE; done: FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5R__init_package() */ /*-------------------------------------------------------------------------- NAME - H5R_term_interface + H5R_top_term_package PURPOSE Terminate various H5R objects USAGE - void H5R_term_interface() + void H5R_top_term_package() RETURNS void DESCRIPTION - Release the atom group and any other resources allocated. + Release IDs for the atom group, deferring full interface shutdown + until later (in H5R_term_package). GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS Can't report errors... @@ -155,32 +136,69 @@ done: REVISION LOG --------------------------------------------------------------------------*/ int -H5R_term_interface(void) +H5R_top_term_package(void) { int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5_interface_initialize_g) { + if(H5R_top_package_initialize_s) { if(H5I_nmembers(H5I_REFERENCE) > 0) { (void)H5I_clear_type(H5I_REFERENCE, FALSE, FALSE); n++; /*H5I*/ } /* end if */ - else { - /* Close deprecated interface */ - n += H5R__term_deprec_interface(); - /* Destroy the reference id group */ - (void)H5I_dec_type_ref(H5I_REFERENCE); - n++; /*H5I*/ + /* Mark closed */ + if(0 == n) + H5R_top_package_initialize_s = FALSE; + } /* end if */ + + 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 atom 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(0 == H5I_nmembers(H5I_REFERENCE)); + HDassert(FALSE == H5R_top_package_initialize_s); + + /* Destroy the reference id group */ + n += (H5I_dec_type_ref(H5I_REFERENCE) > 0); - /* Mark closed */ - H5_interface_initialize_g = 0; - } /* end else */ + /* Mark closed */ + if(0 == n) + H5_PKG_INIT_VAR = FALSE; } /* end if */ FUNC_LEAVE_NOAPI(n) -} /* end H5R_term_interface() */ +} /* end H5R_term_package() */ /*-------------------------------------------------------------------------- @@ -424,7 +442,7 @@ H5R_dereference(H5F_t *file, hid_t oapl_id, hid_t dxpl_id, H5R_type_t ref_type, H5G_loc_t loc; /* Group location */ unsigned rc; /* Reference count of object */ H5O_type_t obj_type; /* Type of object */ - hid_t ret_value; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -902,9 +920,9 @@ static ssize_t H5R_get_name(H5F_t *f, hid_t lapl_id, hid_t dxpl_id, hid_t id, H5R_type_t ref_type, const void *_ref, char *name, size_t size) { - hid_t file_id = (-1); /* ID for file that the reference is in */ + hid_t file_id = H5I_INVALID_HID; /* ID for file that the reference is in */ H5O_loc_t oloc; /* Object location describing object for reference */ - ssize_t ret_value; /* Return value */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI_NOINIT diff --git a/src/H5Rdeprec.c b/src/H5Rdeprec.c index 9877f42..b8133b2 100644 --- a/src/H5Rdeprec.c +++ b/src/H5Rdeprec.c @@ -31,10 +31,7 @@ /* Module Setup */ /****************/ -#define H5R_PACKAGE /*suppress error about including H5Rpkg */ - -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5R__init_deprec_interface +#include "H5Rmodule.h" /* This source code file is part of the H5R module */ /***********/ @@ -84,51 +81,6 @@ /*******************/ - -/*-------------------------------------------------------------------------- -NAME - H5R__init_deprec_interface -- Initialize interface-specific information -USAGE - herr_t H5R__init_deprec_interface() -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. (Just calls - H5R_init() currently). - ---------------------------------------------------------------------------*/ -static herr_t -H5R__init_deprec_interface(void) -{ - FUNC_ENTER_STATIC_NOERR - - FUNC_LEAVE_NOAPI(H5R_init()) -} /* H5R__init_deprec_interface() */ - - -/*-------------------------------------------------------------------------- -NAME - H5R__term_deprec_interface -- Terminate interface -USAGE - herr_t H5R__term_deprec_interface() -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Terminates interface. (Just resets H5_interface_initialize_g - currently). - ---------------------------------------------------------------------------*/ -herr_t -H5R__term_deprec_interface(void) -{ - FUNC_ENTER_PACKAGE_NOERR - - /* Mark closed */ - H5_interface_initialize_g = 0; - - FUNC_LEAVE_NOAPI(0) -} /* H5R__term_deprec_interface() */ - #ifndef H5_NO_DEPRECATED_SYMBOLS /*-------------------------------------------------------------------------- diff --git a/src/H5Rmodule.h b/src/H5Rmodule.h new file mode 100644 index 0000000..6799483 --- /dev/null +++ b/src/H5Rmodule.h @@ -0,0 +1,36 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Quincey Koziol <koziol@hdfgroup.org> + * Saturday, September 12, 2015 + * + * Purpose: This file contains declarations which define macros for the + * H5R package. Including this header means that the source file + * is part of the H5R package. + */ +#ifndef _H5Rmodule_H +#define _H5Rmodule_H + +/* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error + * reporting macros. + */ +#define H5R_MODULE +#define H5_MY_PKG H5R +#define H5_MY_PKG_ERR H5E_REFERENCE +#define H5_MY_PKG_INIT YES + +#endif /* _H5Rmodule_H */ + + diff --git a/src/H5Rpkg.h b/src/H5Rpkg.h index fd16754..8ed8d65 100644 --- a/src/H5Rpkg.h +++ b/src/H5Rpkg.h @@ -21,7 +21,7 @@ * only within the H5R package. Source files outside the * H5R package should include H5Rprivate.h instead. */ -#ifndef H5R_PACKAGE +#if !(defined H5R_FRIEND || defined H5R_MODULE) #error "Do not include this file outside the H5R package!" #endif @@ -54,8 +54,6 @@ /******************************/ /* General functions */ -H5_DLL herr_t H5R_init(void); -H5_DLL herr_t H5R__term_deprec_interface(void); H5_DLL herr_t H5R_get_obj_type(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type, const void *_ref, H5O_type_t *obj_type); H5_DLL hid_t H5R_dereference(H5F_t *file, hid_t dapl_id, hid_t dxpl_id, H5R_type_t ref_type, @@ -17,10 +17,7 @@ /* Module Setup */ /****************/ -#define H5S_PACKAGE /*suppress error about including H5Spkg */ - -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5S_init_interface +#include "H5Smodule.h" /* This source code file is part of the H5S module */ /***********/ @@ -63,6 +60,9 @@ static H5S_t *H5S_decode(const unsigned char *buf); /* Package Variables */ /*********************/ +/* Package initialization variable */ +hbool_t H5_PKG_INIT_VAR = FALSE; + /*****************************/ /* Library Private Variables */ @@ -80,7 +80,7 @@ H5FL_DEFINE(H5S_extent_t); H5FL_DEFINE(H5S_t); /* Declare a free list to manage the array's of hsize_t's */ -H5FL_ARR_DEFINE(hsize_t,H5S_MAX_RANK); +H5FL_ARR_DEFINE(hsize_t, H5S_MAX_RANK); /* Dataspace ID class */ static const H5I_class_t H5I_DATASPACE_CLS[1] = {{ @@ -90,47 +90,52 @@ static const H5I_class_t H5I_DATASPACE_CLS[1] = {{ (H5I_free_t)H5S_close /* 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; + /*-------------------------------------------------------------------------- NAME - H5S_init_interface -- Initialize interface-specific information + H5S__init_package -- Initialize interface-specific information USAGE - herr_t H5S_init_interface() - + herr_t H5S__init_package() RETURNS Non-negative on success/Negative on failure DESCRIPTION Initializes any interface-specific data or routines. - --------------------------------------------------------------------------*/ -static herr_t -H5S_init_interface(void) +herr_t +H5S__init_package(void) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* Initialize the atom group for the file IDs */ if(H5I_register_type(H5I_DATASPACE_CLS) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize interface") + /* Mark "top" of interface as initialized, too */ + H5S_top_package_initialize_s = TRUE; + done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5S_init_interface() */ +} /* end H5S__init_package() */ /*-------------------------------------------------------------------------- NAME - H5S_term_interface + H5S_top_term_package PURPOSE Terminate various H5S objects USAGE - void H5S_term_interface() + void H5S_top_term_package() RETURNS Non-negative on success/Negative on failure DESCRIPTION - Release the atom group and any other resources allocated. + Release IDs for the atom group, deferring full interface shutdown + until later (in H5S_term_package). GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS Can't report errors... @@ -138,29 +143,69 @@ done: REVISION LOG --------------------------------------------------------------------------*/ int -H5S_term_interface(void) +H5S_top_term_package(void) { int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5_interface_initialize_g) { + if(H5S_top_package_initialize_s) { if(H5I_nmembers(H5I_DATASPACE) > 0) { (void)H5I_clear_type(H5I_DATASPACE, FALSE, FALSE); n++; /*H5I*/ } /* end if */ - else { - /* Destroy the dataspace object id group */ - (void)H5I_dec_type_ref(H5I_DATASPACE); - n++; /*H5I*/ - /* Shut down interface */ - H5_interface_initialize_g = 0; - } /* end else */ + /* Mark "top" of interface as closed */ + if(0 == n) + H5S_top_package_initialize_s = FALSE; } /* end if */ FUNC_LEAVE_NOAPI(n) -} /* end H5S_term_interface() */ +} /* end H5S_top_term_package() */ + + +/*-------------------------------------------------------------------------- + NAME + H5S_term_package + PURPOSE + Terminate various H5S objects + USAGE + void H5S_term_package() + 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... + + Finishes shutting down the interface, after H5S_top_term_package() + is called + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +int +H5S_term_package(void) +{ + int n = 0; + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + if(H5_PKG_INIT_VAR) { + /* Sanity checks */ + HDassert(0 == H5I_nmembers(H5I_DATASPACE)); + HDassert(FALSE == H5S_top_package_initialize_s); + + /* 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 */ + + FUNC_LEAVE_NOAPI(n) +} /* end H5S_term_package() */ /*-------------------------------------------------------------------------- @@ -185,7 +230,7 @@ H5S_t * H5S_create(H5S_class_t type) { H5S_t *new_ds = NULL; /* New dataspace created */ - H5S_t *ret_value; /* Return value */ + H5S_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -588,8 +633,8 @@ done: H5S_t * H5S_copy(const H5S_t *src, hbool_t share_selection, hbool_t copy_max) { - H5S_t *dst = NULL; - H5S_t *ret_value; /* Return value */ + H5S_t *dst = NULL; + H5S_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -640,7 +685,7 @@ done: hssize_t H5S_get_simple_extent_npoints(const H5S_t *ds) { - hssize_t ret_value; + hssize_t ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI(-1) @@ -716,8 +761,8 @@ done: hsize_t H5S_get_npoints_max(const H5S_t *ds) { - hsize_t ret_value; unsigned u; + hsize_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI(0) @@ -821,7 +866,7 @@ done: int H5S_get_simple_extent_ndims(const H5S_t *ds) { - int ret_value; /* Return value */ + int ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -906,8 +951,8 @@ done: int H5S_extent_get_dims(const H5S_extent_t *ext, hsize_t dims[], hsize_t max_dims[]) { - int i; /* Local index variable */ - int ret_value; /* Return value */ + int i; /* Local index variable */ + int ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -965,7 +1010,7 @@ done: int H5S_get_simple_extent_dims(const H5S_t *ds, hsize_t dims[], hsize_t max_dims[]) { - int ret_value; /* Return value */ + int ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1073,8 +1118,8 @@ done: H5S_t * H5S_read(const H5O_loc_t *loc, hid_t dxpl_id) { - H5S_t *ds = NULL; /* Dataspace to return */ - H5S_t *ret_value; /* Return value */ + H5S_t *ds = NULL; /* Dataspace to return */ + H5S_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -1121,7 +1166,7 @@ done: static htri_t H5S_is_simple(const H5S_t *sdim) { - htri_t ret_value; + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1426,7 +1471,7 @@ H5S_t * H5S_create_simple(unsigned rank, const hsize_t dims[/*rank*/], const hsize_t maxdims[/*rank*/]) { - H5S_t *ret_value; /* Return value */ + H5S_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -1623,7 +1668,7 @@ H5S_decode(const unsigned char *buf) size_t extent_size; /* size of the extent message*/ H5F_t *f = NULL; /* Fake file structure*/ uint8_t sizeof_size; /* 'Size of sizes' for file */ - H5S_t *ret_value; + H5S_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1705,7 +1750,7 @@ done: H5S_class_t H5S_get_simple_extent_type(const H5S_t *space) { - H5S_class_t ret_value; + H5S_class_t ret_value = H5S_NO_CLASS; /* Return value */ FUNC_ENTER_NOAPI(H5S_NO_CLASS) @@ -1903,7 +1948,7 @@ done: hbool_t H5S_has_extent(const H5S_t *ds) { - hbool_t ret_value; + hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -59,16 +59,15 @@ * */ -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5SL_init_interface +#include "H5SLmodule.h" /* This source code file is part of the H5SL module */ /* Private headers needed */ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5FLprivate.h" /* Free Lists */ +#include "H5MMprivate.h" /* Memory management */ #include "H5SLprivate.h" /* Skip list routines */ -#include "H5MMprivate.h" /* Memory management */ /* Local Macros */ @@ -576,6 +575,9 @@ static H5SL_node_t *H5SL_insert_common(H5SL_t *slist, void *item, const void *ke 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); @@ -590,12 +592,11 @@ static size_t H5SL_fac_nalloc_g; /*-------------------------------------------------------------------------- NAME - H5SL_init_interface + H5SL__init_package PURPOSE Initialize interface-specific information USAGE - herr_t H5SL_init_interface() - + herr_t H5SL__init_package() RETURNS Non-negative on success/Negative on failure DESCRIPTION @@ -605,10 +606,10 @@ static size_t H5SL_fac_nalloc_g; EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -static herr_t -H5SL_init_interface(void) +herr_t +H5SL__init_package(void) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_PACKAGE_NOERR /* Allocate space for array of factories */ H5SL_fac_g = (H5FL_fac_head_t **)H5MM_malloc(sizeof(H5FL_fac_head_t *)); @@ -621,7 +622,64 @@ H5SL_init_interface(void) H5SL_fac_nused_g = 1; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5SL_init_interface() */ +} /* end H5SL__init_package() */ + + +/*-------------------------------------------------------------------------- + NAME + H5SL_term_package + PURPOSE + Terminate all the H5FL factories used in this package, and clear memory + USAGE + int H5SL_term_package() + RETURNS + Success: Positive if any action might have caused a change in some + other interface; zero otherwise. + Failure: Negative + DESCRIPTION + Release any resources allocated. + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + Can't report errors... + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +int H5SL_term_package(void) +{ + int n = 0; + + 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 ret; + + for(i = 0; i < H5SL_fac_nused_g; i++) { + ret = H5FL_fac_term(H5SL_fac_g[i]); + HDassert(ret >= 0); + } /* end if */ + H5SL_fac_nused_g = 0; + + n++; + } /* end if */ + + /* 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++; + } /* end if */ + + /* Mark the interface as uninitialized */ + if(0 == n) + H5_PKG_INIT_VAR = FALSE; + } /* end if */ + + FUNC_LEAVE_NOAPI(n) +} /* H5SL_term_package() */ /*-------------------------------------------------------------------------- @@ -649,7 +707,7 @@ H5SL_init_interface(void) static H5SL_node_t * H5SL_new_node(void *item, const void *key, uint32_t hashval) { - H5SL_node_t *ret_value; /* New skip list node */ + H5SL_node_t *ret_value = NULL; /* New skip list node */ FUNC_ENTER_NOAPI_NOINIT @@ -938,7 +996,7 @@ H5SL_create(H5SL_type_t type, H5SL_cmp_t cmp) { H5SL_t *new_slist = NULL; /* Pointer to new skip list object created */ H5SL_node_t *header; /* Pointer to skip list header node */ - H5SL_t *ret_value; /* Return value */ + H5SL_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -1097,7 +1155,7 @@ done: H5SL_node_t * H5SL_add(H5SL_t *slist, void *item, const void *key) { - H5SL_node_t *ret_value; /* Return value */ + H5SL_node_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1425,9 +1483,9 @@ done: void * H5SL_less(H5SL_t *slist, const void *key) { - H5SL_node_t *x; /* Current node to examine */ - uint32_t hashval = 0; /* Hash value for key */ - void *ret_value; /* Return value */ + H5SL_node_t *x; /* Current node to examine */ + uint32_t hashval = 0; /* Hash value for key */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1534,9 +1592,9 @@ done: void * H5SL_greater(H5SL_t *slist, const void *key) { - H5SL_node_t *x; /* Current node to examine */ - uint32_t hashval = 0; /* Hash value for key */ - void *ret_value; /* Return value */ + H5SL_node_t *x; /* Current node to examine */ + uint32_t hashval = 0; /* Hash value for key */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1726,9 +1784,9 @@ done: H5SL_node_t * H5SL_below(H5SL_t *slist, const void *key) { - H5SL_node_t *x; /* Current node to examine */ - uint32_t hashval = 0; /* Hash value for key */ - H5SL_node_t *ret_value; /* Return value */ + H5SL_node_t *x; /* Current node to examine */ + uint32_t hashval = 0; /* Hash value for key */ + H5SL_node_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1832,9 +1890,9 @@ done: H5SL_node_t * H5SL_above(H5SL_t *slist, const void *key) { - H5SL_node_t *x; /* Current node to examine */ - uint32_t hashval = 0; /* Hash value for key */ - H5SL_node_t *ret_value; /* Return value */ + H5SL_node_t *x; /* Current node to examine */ + uint32_t hashval = 0; /* Hash value for key */ + H5SL_node_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -2509,50 +2567,3 @@ H5SL_close(H5SL_t *slist) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5SL_close() */ - -/*-------------------------------------------------------------------------- - NAME - H5SL_term_interface - PURPOSE - Terminate all the H5FL factories used in this package, and clear memory - USAGE - int H5SL_term_interface() - RETURNS - Success: Positive if any action might have caused a change in some - other interface; zero otherwise. - Failure: Negative - DESCRIPTION - Release any resources allocated. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - Can't report errors... - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -int H5SL_term_interface(void) -{ - size_t i; - herr_t ret; - int n = H5_interface_initialize_g ? 1 : 0; - - FUNC_ENTER_NOAPI_NOINIT_NOERR - - if(n) { - /* Terminate all the factories */ - 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 */ - H5SL_fac_g = (H5FL_fac_head_t **)H5MM_xfree((void *)H5SL_fac_g); - H5SL_fac_nalloc_g = 0; - - /* Mark the interface as uninitialized */ - H5_interface_initialize_g = 0; - } /* end if */ - - FUNC_LEAVE_NOAPI(n) -} /* H5SL_term_interface() */ - diff --git a/src/H5SLmodule.h b/src/H5SLmodule.h new file mode 100644 index 0000000..d5bfbc2 --- /dev/null +++ b/src/H5SLmodule.h @@ -0,0 +1,35 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Quincey Koziol <koziol@hdfgroup.org> + * Saturday, September 12, 2015 + * + * Purpose: This file contains declarations which define macros for the + * H5SL package. Including this header means that the source file + * is part of the H5SL package. + */ +#ifndef _H5SLmodule_H +#define _H5SLmodule_H + +/* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error + * reporting macros. + */ +#define H5SL_MODULE +#define H5_MY_PKG H5SL +#define H5_MY_PKG_ERR H5E_SLIST +#define H5_MY_PKG_INIT YES + +#endif /* _H5SLmodule_H */ + @@ -17,8 +17,9 @@ /* Module Setup */ /****************/ -#define H5O_PACKAGE /*suppress error about including H5Opkg */ -#define H5SM_PACKAGE /*suppress error about including H5SMpkg */ +#define H5O_FRIEND /*suppress error about including H5Opkg */ +#include "H5SMmodule.h" /* This source code file is part of the H5SM module */ + /***********/ /* Headers */ @@ -84,6 +85,9 @@ 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); @@ -642,7 +646,7 @@ H5SM_create_list(H5F_t *f, H5SM_index_header_t *header, hid_t dxpl_id) hsize_t x; /* Counter variable */ size_t num_entries; /* Number of messages to create in list */ haddr_t addr = HADDR_UNDEF; /* Address of the list on disk */ - haddr_t ret_value; + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_TAG(dxpl_id, H5AC__SOHM_TAG, HADDR_UNDEF) @@ -885,7 +889,7 @@ done: static htri_t H5SM_can_share_common(const H5F_t *f, unsigned type_id, const void *mesg) { - htri_t ret_value; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1262,7 +1266,7 @@ H5SM_write_mesg(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, /* Encode the message to be written */ if((buf_size = H5O_msg_raw_size(f, type_id, TRUE, mesg)) == 0) HGOTO_ERROR(H5E_SOHM, H5E_BADSIZE, FAIL, "can't find message size") - if(NULL == (encoding_buf = H5MM_malloc(buf_size))) + if(NULL == (encoding_buf = H5MM_calloc(buf_size))) HGOTO_ERROR(H5E_SOHM, H5E_NOSPACE, FAIL, "can't allocate buffer for encoding") if(H5O_msg_encode(f, type_id, TRUE, (unsigned char *)encoding_buf, mesg) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTENCODE, FAIL, "can't encode message to be shared") @@ -1617,8 +1621,8 @@ done: static size_t H5SM_find_in_list(const H5SM_list_t *list, const H5SM_mesg_key_t *key, size_t *empty_pos) { - size_t x; - size_t ret_value; + size_t x; + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR diff --git a/src/H5SMbtree2.c b/src/H5SMbtree2.c index e18e9fb..e975840 100644 --- a/src/H5SMbtree2.c +++ b/src/H5SMbtree2.c @@ -17,8 +17,8 @@ /* Module Setup */ /****************/ -#define H5O_PACKAGE /*suppress error about including H5Opkg */ -#define H5SM_PACKAGE /*suppress error about including H5SMpkg */ +#define H5O_FRIEND /*suppress error about including H5Opkg */ +#include "H5SMmodule.h" /* This source code file is part of the H5SM module */ /***********/ @@ -100,7 +100,7 @@ H5SM_bt2_crt_context(void *_f) { H5F_t *f = (H5F_t *)_f; /* User data for building callback context */ H5SM_bt2_ctx_t *ctx; /* Callback context structure */ - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT diff --git a/src/H5SMcache.c b/src/H5SMcache.c index b5c3215..f2f37df 100644 --- a/src/H5SMcache.c +++ b/src/H5SMcache.c @@ -28,7 +28,7 @@ /* Module Setup */ /****************/ -#define H5SM_PACKAGE /*suppress error about including H5SMpkg */ +#include "H5SMmodule.h" /* This source code file is part of the H5SM module */ /***********/ @@ -237,7 +237,7 @@ H5SM__cache_table_deserialize(const void *_image, size_t len, void *_udata, const uint8_t *image = (const uint8_t *)_image; /* Pointer into input buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ size_t u; /* Counter variable for index headers */ - void * ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -606,7 +606,7 @@ H5SM__cache_list_deserialize(const void *_image, size_t len, void *_udata, const uint8_t *image = (const uint8_t *)_image; /* Pointer into input buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ size_t u; /* Counter variable for messages in list */ - void * ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC diff --git a/src/H5SMmessage.c b/src/H5SMmessage.c index d2dff47..5dbe5cf 100644 --- a/src/H5SMmessage.c +++ b/src/H5SMmessage.c @@ -17,8 +17,8 @@ /* Module Setup */ /****************/ -#define H5O_PACKAGE /*suppress error about including H5Opkg */ -#define H5SM_PACKAGE /*suppress error about including H5SMpkg */ +#define H5O_FRIEND /*suppress error about including H5Opkg */ +#include "H5SMmodule.h" /* This source code file is part of the H5SM module */ /***********/ diff --git a/src/H5SMmodule.h b/src/H5SMmodule.h new file mode 100644 index 0000000..b6991b6 --- /dev/null +++ b/src/H5SMmodule.h @@ -0,0 +1,35 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Quincey Koziol <koziol@hdfgroup.org> + * Saturday, September 12, 2015 + * + * Purpose: This file contains declarations which define macros for the + * H5SM package. Including this header means that the source file + * is part of the H5SM package. + */ +#ifndef _H5SMmodule_H +#define _H5SMmodule_H + +/* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error + * reporting macros. + */ +#define H5SM_MODULE +#define H5_MY_PKG H5SM +#define H5_MY_PKG_ERR H5E_SOHM +#define H5_MY_PKG_INIT NO + +#endif /* _H5SMmodule_H */ + diff --git a/src/H5SMpkg.h b/src/H5SMpkg.h index 68dc484..ac2ba1b 100644 --- a/src/H5SMpkg.h +++ b/src/H5SMpkg.h @@ -21,7 +21,7 @@ * the H5SM shared object header messages package. Source files * outside the H5SM package should include H5SMprivate.h instead. */ -#ifndef H5SM_PACKAGE +#if !(defined H5SM_FRIEND || defined H5SM_MODULE) #error "Do not include this file outside the H5SM package!" #endif diff --git a/src/H5SMtest.c b/src/H5SMtest.c index c4e02bc..798203d 100644 --- a/src/H5SMtest.c +++ b/src/H5SMtest.c @@ -17,7 +17,7 @@ /* Module Setup */ /****************/ -#define H5SM_PACKAGE /*suppress error about including H5SMpkg */ +#include "H5SMmodule.h" /* This source code file is part of the H5SM module */ #define H5SM_TESTING /*suppress warning about H5SM testing funcs*/ diff --git a/src/H5Sall.c b/src/H5Sall.c index 7eab8b3..c373fd1 100644 --- a/src/H5Sall.c +++ b/src/H5Sall.c @@ -20,7 +20,7 @@ * Purpose: "All" selection data space I/O functions. */ -#define H5S_PACKAGE /*suppress error about including H5Spkg */ +#include "H5Smodule.h" /* This source code file is part of the H5S module */ #include "H5private.h" /* Generic Functions */ diff --git a/src/H5Sdbg.c b/src/H5Sdbg.c index 0cbe4f2..b69604c 100644 --- a/src/H5Sdbg.c +++ b/src/H5Sdbg.c @@ -28,7 +28,7 @@ /* Module Setup */ /****************/ -#define H5S_PACKAGE /*suppress error about including H5Spkg */ +#include "H5Smodule.h" /* This source code file is part of the H5S module */ /***********/ diff --git a/src/H5Shyper.c b/src/H5Shyper.c index a2eb804..12e23fa 100644 --- a/src/H5Shyper.c +++ b/src/H5Shyper.c @@ -20,7 +20,7 @@ * Purpose: Hyperslab selection data space I/O functions. */ -#define H5S_PACKAGE /*suppress error about including H5Spkg */ +#include "H5Smodule.h" /* This source code file is part of the H5S module */ #include "H5private.h" /* Generic Functions */ @@ -1093,7 +1093,7 @@ H5S_hyper_iter_release (H5S_sel_iter_t *iter) static H5S_hyper_span_t * H5S_hyper_new_span(hsize_t low, hsize_t high, H5S_hyper_span_info_t *down, H5S_hyper_span_t *next) { - H5S_hyper_span_t *ret_value; + H5S_hyper_span_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1288,7 +1288,7 @@ H5S_hyper_copy_span_helper (H5S_hyper_span_info_t *spans) H5S_hyper_span_t *new_span; /* Temporary hyperslab span */ H5S_hyper_span_t *prev_span; /* Previous hyperslab span */ H5S_hyper_span_info_t *new_down; /* New down span tree */ - H5S_hyper_span_info_t *ret_value; + H5S_hyper_span_info_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1374,7 +1374,7 @@ done: static H5S_hyper_span_info_t * H5S_hyper_copy_span(H5S_hyper_span_info_t *spans) { - H5S_hyper_span_info_t *ret_value; + H5S_hyper_span_info_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1753,9 +1753,9 @@ static htri_t H5S_hyper_is_valid (const H5S_t *space) { unsigned u; /* Counter */ - htri_t ret_value=TRUE; /* return value */ + htri_t ret_value = TRUE; /* return value */ - FUNC_ENTER_NOAPI_NOERR + FUNC_ENTER_NOAPI(FAIL) HDassert(space); @@ -1858,7 +1858,7 @@ H5S_hyper_span_nblocks(H5S_hyper_span_info_t *spans) static hsize_t H5S_get_select_hyper_nblocks(H5S_t *space) { - hsize_t ret_value; /* return value */ + hsize_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1940,9 +1940,9 @@ done: static hssize_t H5S_hyper_serial_size(const H5S_t *space) { - unsigned u; /* Counter */ hsize_t block_count; /* block counter for regular hyperslabs */ - hssize_t ret_value; /* return value */ + unsigned u; /* Counter */ + hssize_t ret_value = -1; /* return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -2890,7 +2890,7 @@ H5S_hyper_is_contiguous(const H5S_t *space) unsigned u; /* index variable */ htri_t ret_value = FALSE; /* Return value */ - FUNC_ENTER_NOAPI_NOERR + FUNC_ENTER_NOAPI(FAIL) HDassert(space); @@ -3045,6 +3045,7 @@ H5S_hyper_is_contiguous(const H5S_t *space) ret_value=TRUE; } /* end else */ +done: FUNC_LEAVE_NOAPI(ret_value) } /* H5S_hyper_is_contiguous() */ @@ -3075,7 +3076,7 @@ H5S_hyper_is_single(const H5S_t *space) unsigned u; /* index variable */ htri_t ret_value=TRUE; /* return value */ - FUNC_ENTER_NOAPI_NOERR + FUNC_ENTER_NOAPI(FAIL) HDassert(space); @@ -3140,7 +3141,7 @@ done: static htri_t H5S_hyper_is_regular(const H5S_t *space) { - htri_t ret_value; /* return value */ + htri_t ret_value = FAIL; /* return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -5259,7 +5260,7 @@ H5S_hyper_merge_spans_helper (H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf H5S_hyper_span_t *span_b; /* Pointer to current span 'b' working on */ H5S_hyper_span_t *prev_span_merge; /* Pointer to previous merged span */ unsigned recover_a, recover_b; /* Flags to indicate when to recover temporary spans */ - H5S_hyper_span_info_t *ret_value; + H5S_hyper_span_info_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -5627,7 +5628,7 @@ static hsize_t H5S_hyper_spans_nelem (H5S_hyper_span_info_t *spans) { H5S_hyper_span_t *span; /* Hyperslab span */ - hsize_t ret_value; + hsize_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -5689,7 +5690,7 @@ H5S_hyper_make_spans(unsigned rank, const hsize_t *start, const hsize_t *stride, hsize_t stride_iter; /* Iterator over the stride values */ int i; /* Counters */ unsigned u; /* Counters */ - H5S_hyper_span_info_t *ret_value; /* Return value */ + H5S_hyper_span_info_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -8720,7 +8721,7 @@ H5S_hyper_get_seq_list(const H5S_t *space, unsigned H5_ATTR_UNUSED flags, H5S_se size_t maxseq, size_t maxelem, size_t *nseq, size_t *nelem, hsize_t *off, size_t *len) { - herr_t ret_value; /* return value */ + herr_t ret_value = FAIL; /* return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR diff --git a/src/H5Smodule.h b/src/H5Smodule.h new file mode 100644 index 0000000..d4d94f2 --- /dev/null +++ b/src/H5Smodule.h @@ -0,0 +1,35 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Quincey Koziol <koziol@hdfgroup.org> + * Saturday, September 12, 2015 + * + * Purpose: This file contains declarations which define macros for the + * H5S package. Including this header means that the source file + * is part of the H5S package. + */ +#ifndef _H5Smodule_H +#define _H5Smodule_H + +/* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error + * reporting macros. + */ +#define H5S_MODULE +#define H5_MY_PKG H5S +#define H5_MY_PKG_ERR H5E_DATASPACE +#define H5_MY_PKG_INIT YES + +#endif /* _H5Smodule_H */ + diff --git a/src/H5Smpio.c b/src/H5Smpio.c index c2190b4..1f97bc8 100644 --- a/src/H5Smpio.c +++ b/src/H5Smpio.c @@ -22,7 +22,7 @@ * I didn't make them portable. */ -#define H5S_PACKAGE /*suppress error about including H5Spkg */ +#include "H5Smodule.h" /* This source code file is part of the H5S module */ #include "H5private.h" /* Generic Functions */ diff --git a/src/H5Snone.c b/src/H5Snone.c index a67880e..6a4474d 100644 --- a/src/H5Snone.c +++ b/src/H5Snone.c @@ -20,7 +20,7 @@ * Purpose: "None" selection data space I/O functions. */ -#define H5S_PACKAGE /*suppress error about including H5Spkg */ +#include "H5Smodule.h" /* This source code file is part of the H5S module */ #include "H5private.h" diff --git a/src/H5Spkg.h b/src/H5Spkg.h index 5f84717..8213919 100644 --- a/src/H5Spkg.h +++ b/src/H5Spkg.h @@ -21,7 +21,7 @@ * the H5S package. Source files outside the H5S package should * include H5Sprivate.h instead. */ -#ifndef H5S_PACKAGE +#if !(defined H5S_FRIEND || defined H5S_MODULE) #error "Do not include this file outside the H5S package!" #endif diff --git a/src/H5Spoint.c b/src/H5Spoint.c index 20a60bb..d225ab2 100644 --- a/src/H5Spoint.c +++ b/src/H5Spoint.c @@ -20,7 +20,7 @@ * Purpose: Point selection data space I/O functions. */ -#define H5S_PACKAGE /*suppress error about including H5Spkg */ +#include "H5Smodule.h" /* This source code file is part of the H5S module */ #include "H5private.h" /* Generic Functions */ @@ -774,7 +774,7 @@ static hssize_t H5S_point_serial_size (const H5S_t *space) { H5S_pnt_node_t *curr; /* Point information nodes */ - hssize_t ret_value; /* return value */ + hssize_t ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1208,7 +1208,7 @@ done: static htri_t H5S_point_is_contiguous(const H5S_t *space) { - htri_t ret_value; /* return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1245,7 +1245,7 @@ H5S_point_is_contiguous(const H5S_t *space) static htri_t H5S_point_is_single(const H5S_t *space) { - htri_t ret_value; /* return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1285,7 +1285,7 @@ H5S_point_is_single(const H5S_t *space) static htri_t H5S_point_is_regular(const H5S_t *space) { - htri_t ret_value; /* return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h index 15066e4..55e5dbe 100644 --- a/src/H5Sprivate.h +++ b/src/H5Sprivate.h @@ -140,7 +140,7 @@ typedef struct H5S_sel_iter_op_t { } H5S_sel_iter_op_t; /* If the module using this macro is allowed access to the private variables, access them directly */ -#ifdef H5S_PACKAGE +#ifdef H5S_MODULE #define H5S_GET_EXTENT_TYPE(S) ((S)->extent.type) #define H5S_GET_EXTENT_NDIMS(S) ((S)->extent.rank) #define H5S_GET_EXTENT_NPOINTS(S) ((S)->extent.nelem) @@ -166,7 +166,7 @@ typedef struct H5S_sel_iter_op_t { #define H5S_SELECT_ITER_NEXT(ITER,NELEM)((*(ITER)->type->iter_next)(ITER,NELEM)) #define H5S_SELECT_ITER_NEXT_BLOCK(ITER) ((*(ITER)->type->iter_next_block)(ITER)) #define H5S_SELECT_ITER_RELEASE(ITER) ((*(ITER)->type->iter_release)(ITER)) -#else /* H5S_PACKAGE */ +#else /* H5S_MODULE */ #define H5S_GET_EXTENT_TYPE(S) (H5S_get_simple_extent_type(S)) #define H5S_GET_EXTENT_NDIMS(S) (H5S_get_simple_extent_ndims(S)) #define H5S_GET_EXTENT_NPOINTS(S) (H5S_get_simple_extent_npoints(S)) @@ -192,7 +192,7 @@ typedef struct H5S_sel_iter_op_t { #define H5S_SELECT_ITER_NEXT(ITER,NELEM)(H5S_select_iter_next(ITER,NELEM)) #define H5S_SELECT_ITER_NEXT_BLOCK(ITER) (H5S_select_iter_next_block(ITER)) #define H5S_SELECT_ITER_RELEASE(ITER) (H5S_select_iter_release(ITER)) -#endif /* H5S_PACKAGE */ +#endif /* H5S_MODULE */ /* Handle these two callbacks in a special way, since they have prologs that need to be executed */ #define H5S_SELECT_COPY(DST,SRC,SHARE) (H5S_select_copy(DST,SRC,SHARE)) #define H5S_SELECT_DESERIALIZE(S,BUF) (H5S_select_deserialize(S,BUF)) diff --git a/src/H5Sselect.c b/src/H5Sselect.c index 6dfe671..c1fd207 100644 --- a/src/H5Sselect.c +++ b/src/H5Sselect.c @@ -19,7 +19,7 @@ * Purpose: Dataspace selection functions. */ -#define H5S_PACKAGE /*suppress error about including H5Spkg */ +#include "H5Smodule.h" /* This source code file is part of the H5S module */ #include "H5private.h" /* Generic Functions */ @@ -107,7 +107,7 @@ H5S_select_offset(H5S_t *space, const hssize_t *offset) herr_t H5S_select_copy (H5S_t *dst, const H5S_t *src, hbool_t share_selection) { - herr_t ret_value; /* return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -148,7 +148,7 @@ done: herr_t H5S_select_release(H5S_t *ds) { - herr_t ret_value; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -185,7 +185,7 @@ H5S_select_get_seq_list(const H5S_t *space, unsigned flags, H5S_sel_iter_t *iter, size_t maxseq, size_t maxbytes, size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len) { - herr_t ret_value; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -220,7 +220,7 @@ H5S_select_get_seq_list(const H5S_t *space, unsigned flags, hssize_t H5S_select_serial_size(const H5S_t *space) { - hssize_t ret_value; /* Return value */ + hssize_t ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -411,7 +411,7 @@ done: htri_t H5S_select_valid(const H5S_t *space) { - htri_t ret_value; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -452,10 +452,10 @@ H5S_select_valid(const H5S_t *space) herr_t H5S_select_deserialize (H5S_t **space, const uint8_t **p) { - H5S_t *tmp_space; /* Pointer to actual dataspace to use, either - *space or a newly allocated one */ - uint32_t sel_type; /* Pointer to the selection type */ - herr_t ret_value=FAIL; /* return value */ + H5S_t *tmp_space = NULL; /* Pointer to actual dataspace to use, either + *space or a newly allocated one */ + uint32_t sel_type; /* Pointer to the selection type */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -611,7 +611,7 @@ done: herr_t H5S_get_select_bounds(const H5S_t *space, hsize_t *start, hsize_t *end) { - herr_t ret_value; /* return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -652,7 +652,7 @@ H5S_get_select_bounds(const H5S_t *space, hsize_t *start, hsize_t *end) herr_t H5S_get_select_offset(const H5S_t *space, hsize_t *offset) { - herr_t ret_value; /* return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -690,7 +690,7 @@ H5S_get_select_offset(const H5S_t *space, hsize_t *offset) htri_t H5S_select_is_contiguous(const H5S_t *space) { - herr_t ret_value; /* return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -727,7 +727,7 @@ H5S_select_is_contiguous(const H5S_t *space) htri_t H5S_select_is_single(const H5S_t *space) { - herr_t ret_value; /* return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -764,7 +764,7 @@ H5S_select_is_single(const H5S_t *space) htri_t H5S_select_is_regular(const H5S_t *space) { - herr_t ret_value; /* return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -801,7 +801,7 @@ H5S_select_is_regular(const H5S_t *space) herr_t H5S_select_adjust_u(H5S_t *space, const hsize_t *offset) { - herr_t ret_value; /* return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -839,7 +839,7 @@ H5S_select_adjust_u(H5S_t *space, const hsize_t *offset) herr_t H5S_select_project_scalar(const H5S_t *space, hsize_t *offset) { - herr_t ret_value; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -879,7 +879,7 @@ H5S_select_project_scalar(const H5S_t *space, hsize_t *offset) herr_t H5S_select_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset) { - herr_t ret_value; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -914,7 +914,7 @@ H5S_select_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset) herr_t H5S_select_iter_init(H5S_sel_iter_t *sel_iter, const H5S_t *space, size_t elmt_size) { - herr_t ret_value; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -969,7 +969,7 @@ H5S_select_iter_init(H5S_sel_iter_t *sel_iter, const H5S_t *space, size_t elmt_s herr_t H5S_select_iter_coords(const H5S_sel_iter_t *sel_iter, hsize_t *coords) { - herr_t ret_value; /* return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1051,7 +1051,7 @@ H5S_select_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end) hsize_t H5S_select_iter_nelmts(const H5S_sel_iter_t *sel_iter) { - hsize_t ret_value; /* return value */ + hsize_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1130,7 +1130,7 @@ H5S_select_iter_has_next_block(const H5S_sel_iter_t *iter) herr_t H5S_select_iter_next(H5S_sel_iter_t *iter, size_t nelem) { - herr_t ret_value; /* return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1213,7 +1213,7 @@ H5S_select_iter_next_block(H5S_sel_iter_t *iter) herr_t H5S_select_iter_release(H5S_sel_iter_t *sel_iter) { - herr_t ret_value; /* return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1438,7 +1438,7 @@ done: H5S_sel_type H5S_get_select_type(const H5S_t *space) { - H5S_sel_type ret_value; /* Return value */ + H5S_sel_type ret_value = H5S_SEL_ERROR; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR diff --git a/src/H5Stest.c b/src/H5Stest.c index 62a4179..e1f4b61 100644 --- a/src/H5Stest.c +++ b/src/H5Stest.c @@ -19,7 +19,7 @@ * Purpose: Dataspace selection testing functions. */ -#define H5S_PACKAGE /*suppress error about including H5Spkg */ +#include "H5Smodule.h" /* This source code file is part of the H5S module */ #define H5S_TESTING /*suppress warning about H5S testing funcs*/ @@ -54,7 +54,7 @@ H5S_select_shape_same_test(hid_t sid1, hid_t sid2) { H5S_t *space1; /* Pointer to 1st dataspace */ H5S_t *space2; /* Pointer to 2nd dataspace */ - htri_t ret_value; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -95,7 +95,7 @@ htri_t H5S_get_rebuild_status_test(hid_t space_id) { H5S_t *space; /* Pointer to 1st dataspace */ - htri_t ret_value; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1,4 +1,3 @@ - /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by The HDF Group. * * Copyright by the Board of Trustees of the University of Illinois. * @@ -25,10 +24,7 @@ /* Module Setup */ /****************/ -#define H5T_PACKAGE /*suppress error about including H5Tpkg */ - -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5T_init_interface +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ /***********/ @@ -304,12 +300,15 @@ 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_interface() in this source file. + * by H5T__init_package() 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_interface(). + * types to reset in H5T_term_package(). */ hid_t H5T_IEEE_F32BE_g = FAIL; hid_t H5T_IEEE_F32LE_g = FAIL; @@ -529,6 +528,9 @@ static const H5I_class_t H5I_DATATYPE_CLS[1] = {{ (H5I_free_t)H5T_close /* 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; + /*------------------------------------------------------------------------- @@ -537,48 +539,42 @@ static const H5I_class_t H5I_DATATYPE_CLS[1] = {{ * Purpose: Initialize the interface from some other package. * * Return: Success: non-negative - * * Failure: negative * * Programmer: Robb Matzke * Wednesday, December 16, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t H5T_init(void) { - herr_t ret_value=SUCCEED; /* Return value */ + 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 + * Function: H5T__init_inf * * Purpose: Initialize the +/- Infinity floating-poing values for type * conversion. * * Return: Success: non-negative - * * Failure: negative * * Programmer: Quincey Koziol * Saturday, November 22, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t -H5T_init_inf(void) +H5T__init_inf(void) { H5T_t *dst_p; /* Datatype type operate on */ H5T_atomic_t *dst; /* Datatype's atomic info */ @@ -587,7 +583,7 @@ H5T_init_inf(void) size_t u; /* Local index value */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Get the float datatype */ if(NULL == (dst_p = (H5T_t *)H5I_object(H5T_NATIVE_FLOAT_g))) @@ -673,63 +669,22 @@ H5T_init_inf(void) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T_init_inf() */ - - -/*------------------------------------------------------------------------- - * Function: H5T_init_hw - * - * Purpose: Perform hardware specific [floating-point] initialization - * - * Return: Success: non-negative - * Failure: negative - * - * Programmer: Quincey Koziol - * Monday, November 24, 2003 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5T_init_hw(void) -{ -#ifdef H5_HAVE_GET_FPC_CSR - union fpc_csr csr; /* Union to hold results of floating-point status register query */ -#endif /* H5_HAVE_GET_FPC_CSR */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT_NOERR - -#ifdef H5_HAVE_GET_FPC_CSR - /* [This code is specific to SGI machines] */ - - /* Get the floating-point status register */ - csr.fc_word = get_fpc_csr(); - - /* If the "flush denormalized values to zero" flag is set, unset it */ - if(csr.fc_struct.flush) { - csr.fc_struct.flush = 0; - set_fpc_csr(csr.fc_word); - } /* end if */ -#endif /* H5_HAVE_GET_FPC_CSR */ - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T_init_hw() */ +} /* end H5T__init_inf() */ /*-------------------------------------------------------------------------- NAME - H5T_init_interface -- Initialize interface-specific information + H5T__init_package -- Initialize interface-specific information USAGE - herr_t H5T_init_interface() - + herr__t H5T_init_package() RETURNS Non-negative on success/Negative on failure DESCRIPTION Initializes any interface-specific data or routines. --------------------------------------------------------------------------*/ -static herr_t -H5T_init_interface(void) +herr_t +H5T__init_package(void) { H5T_t *native_schar=NULL; /* Datatype structure for native signed char */ H5T_t *native_uchar=NULL; /* Datatype structure for native unsigned char */ @@ -777,17 +732,13 @@ H5T_init_interface(void) /* Make certain there aren't too many classes of datatypes defined */ /* Only 16 (numbered 0-15) are supported in the current file format */ - HDassert(H5T_NCLASSES < 16); - - /* Perform any necessary hardware initializations */ - if(H5T_init_hw() < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize interface") + HDcompile_assert(H5T_NCLASSES < 16); /* * Initialize pre-defined native datatypes from code generated during * the library configuration by H5detect. */ - if(H5TN_init_interface() < 0) + if(H5T__init_native() < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize interface") /* Get the atomic datatype structures needed by the initialization code below */ @@ -1004,7 +955,7 @@ H5T_init_interface(void) /* One-byte character string */ H5T_INIT_TYPE(CSTRING, H5T_C_S1_g, ALLOC, -, SET, 1) - string=dt; /* Keep type for later */ + string = dt; /* Keep type for later */ /*------------------------------------------------------------ * The `Fortran' architecture @@ -1021,7 +972,7 @@ H5T_init_interface(void) /* Object reference (i.e. object header address in file) */ H5T_INIT_TYPE(OBJREF, H5T_STD_REF_OBJ_g, ALLOC, -, SET, H5R_OBJ_REF_BUF_SIZE) - objref=dt; /* Keep type for later */ + objref = dt; /* Keep type for later */ /* Dataset Region reference (i.e. selection inside a dataset) */ H5T_INIT_TYPE(REGREF, H5T_STD_REF_DSETREG_g, ALLOC, -, SET, H5R_DSET_REG_REF_BUF_SIZE) @@ -1295,13 +1246,13 @@ H5T_init_interface(void) status |= H5T_register(H5T_PERS_HARD, "no-op", native_int, native_int, H5T__conv_noop, H5AC_ind_dxpl_id, FALSE); /* Initialize the +/- Infinity values for floating-point types */ - status |= H5T_init_inf(); + status |= H5T__init_inf(); - if (status<0) + if(status < 0) 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_interface(), etc. for example. + * code in H5D__init_package(), etc. for example. */ /* Only register the default property list if it hasn't been created yet */ @@ -1314,6 +1265,9 @@ H5T_init_interface(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) @@ -1339,11 +1293,11 @@ done: } /* end if */ FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T_init_interface() */ +} /* end H5T__init_package() */ /*------------------------------------------------------------------------- - * Function: H5T_unlock_cb + * Function: H5T__unlock_cb * * Purpose: Clear the immutable flag for a datatype. This function is * called when the library is closing in order to unlock all @@ -1357,198 +1311,252 @@ done: *------------------------------------------------------------------------- */ static int -H5T_unlock_cb(void *_dt, hid_t H5_ATTR_UNUSED id, void H5_ATTR_UNUSED *key) +H5T__unlock_cb(void *_dt, hid_t H5_ATTR_UNUSED id, void *_udata) { H5T_t *dt = (H5T_t *)_dt; + int *n = (int *)_udata; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR + + HDassert(dt && dt->shared); - HDassert (dt && dt->shared); - if (H5T_STATE_IMMUTABLE==dt->shared->state) + if(H5T_STATE_IMMUTABLE==dt->shared->state) { dt->shared->state = H5T_STATE_RDONLY; + (*n)++; + } /* end if */ + FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5T_unlock_cb() */ +} /* end H5T__unlock_cb() */ /*------------------------------------------------------------------------- - * Function: H5T_term_interface + * Function: H5T_top_term_package * - * Purpose: Close this interface. + * Purpose: Close the "top" of the interface, releasing IDs, etc. * * Return: Success: Positive if any action might have caused a - * change in some other interface; zero - * otherwise. - * + * change in some other interface; zero otherwise. * Failure: Negative * - * Programmer: Robb Matzke - * Friday, November 20, 1998 + * Programmer: Quincey Koziol + * Thursday, September 10, 2015 * *------------------------------------------------------------------------- */ int -H5T_term_interface(void) +H5T_top_term_package(void) { int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5_interface_initialize_g) { - int i, nprint = 0; - + if(H5T_top_package_initialize_s) { /* Unregister all conversion functions */ - for(i = 0; i < H5T_g.npaths; i++) { - H5T_path_t *path; - - path = H5T_g.path[i]; - HDassert(path); - if(path->func) { - H5T__print_stats(path, &nprint/*in,out*/); - path->cdata.command = H5T_CONV_FREE; - if((path->func)((hid_t)FAIL, (hid_t)FAIL, &(path->cdata), (size_t)0, - (size_t)0, (size_t)0, NULL, NULL,H5AC_ind_dxpl_id) < 0) { + 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->func) { + H5T__print_stats(path, &nprint/*in,out*/); + path->cdata.command = H5T_CONV_FREE; + if((path->func)((hid_t)FAIL, (hid_t)FAIL, &(path->cdata), (size_t)0, + (size_t)0, (size_t)0, NULL, NULL,H5AC_ind_dxpl_id) < 0) { #ifdef H5T_DEBUG - if (H5DEBUG(T)) { - fprintf(H5DEBUG(T), "H5T: conversion function " - "0x%08lx failed to free private data for " - "%s (ignored)\n", - (unsigned long)(path->func), path->name); - } /* end if */ + if (H5DEBUG(T)) { + fprintf(H5DEBUG(T), "H5T: conversion function " + "0x%08lx failed to free private data for " + "%s (ignored)\n", + (unsigned long)(path->func), path->name); + } /* end if */ #endif - H5E_clear_stack(NULL); /*ignore the error*/ - } /* end if */ - } /* end if */ + H5E_clear_stack(NULL); /*ignore the error*/ + } /* end if */ + } /* end if */ - if(path->src) - H5T_close(path->src); - if(path->dst) - H5T_close(path->dst); - path = H5FL_FREE(H5T_path_t, path); - H5T_g.path[i] = NULL; - } /* end for */ + if(path->src) + H5T_close(path->src); + if(path->dst) + H5T_close(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; - /* 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; + n++; + } /* end if */ /* Unlock all datatypes, then free them */ /* note that we are ignoring the return value from H5I_iterate() */ - H5I_iterate(H5I_DATATYPE, H5T_unlock_cb, NULL, FALSE); + /* Also note that we are incrementing 'n' in the callback */ + H5I_iterate(H5I_DATATYPE, H5T__unlock_cb, &n, FALSE); - /* Close deprecated interface */ - n += H5T__term_deprec_interface(); - - /* Destroy the datatype object id group */ - (void)H5I_dec_type_ref(H5I_DATATYPE); - n++; /*H5I*/ + /* 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 */ - 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_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; + 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_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; #if H5_SIZEOF_LONG_DOUBLE !=0 - H5T_NATIVE_LDOUBLE_g = FAIL; + H5T_NATIVE_LDOUBLE_g = FAIL; #endif - 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; + 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 */ + + /* Mark "top" of interface as closed */ + if(0 == n) + H5T_top_package_initialize_s = FALSE; + } /* end if */ + + FUNC_LEAVE_NOAPI(n) +} /* end H5T_top_term_package() */ + + +/*------------------------------------------------------------------------- + * Function: H5T_term_package + * + * Purpose: Close this interface. + * + * Note: Finishes shutting down the interface, after + * H5T_top_term_package() is called + * + * Return: Success: Positive if any action might have caused a + * change in some other interface; zero + * otherwise. + * Failure: Negative + * + * Programmer: Robb Matzke + * Friday, November 20, 1998 + * + *------------------------------------------------------------------------- + */ +int +H5T_term_package(void) +{ + int n = 0; + + 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); + + /* Destroy the datatype object id group */ + n += (H5I_dec_type_ref(H5I_DATATYPE) > 0); /* Mark interface as closed */ - H5_interface_initialize_g = 0; + if(0 == n) + H5_PKG_INIT_VAR = FALSE; } /* end if */ FUNC_LEAVE_NOAPI(n) -} /* end H5T_term_interface() */ +} /* end H5T_term_package() */ /*------------------------------------------------------------------------- @@ -1866,7 +1874,7 @@ done: H5T_class_t H5T_get_class(const H5T_t *dt, htri_t internal) { - H5T_class_t ret_value; + H5T_class_t ret_value = H5T_NO_CLASS; /* Return value */ FUNC_ENTER_NOAPI(H5T_NO_CLASS) @@ -2913,8 +2921,8 @@ done: H5T_t * H5T_decode(const unsigned char *buf) { - H5F_t *f = NULL; /* Fake file structure*/ - H5T_t *ret_value; /* Return value */ + H5F_t *f = NULL; /* Fake file structure*/ + H5T_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -3117,7 +3125,7 @@ H5T_copy(H5T_t *old_dt, H5T_copy_t method) H5T_shared_t *reopened_fo = NULL; unsigned i; char *s; - H5T_t *ret_value; + H5T_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -3446,7 +3454,7 @@ H5T_t * H5T__alloc(void) { H5T_t *dt = NULL; /* Pointer to datatype allocated */ - H5T_t *ret_value; /* Return value */ + H5T_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -3533,21 +3541,23 @@ H5T__free(H5T_t *dt) switch(dt->shared->type) { case H5T_COMPOUND: for(i = 0; i < dt->shared->u.compnd.nmembs; i++) { - H5MM_xfree(dt->shared->u.compnd.memb[i].name); + dt->shared->u.compnd.memb[i].name = (char *)H5MM_xfree(dt->shared->u.compnd.memb[i].name); H5T_close(dt->shared->u.compnd.memb[i].type); } /* end for */ - H5MM_xfree(dt->shared->u.compnd.memb); + dt->shared->u.compnd.memb = (H5T_cmemb_t *)H5MM_xfree(dt->shared->u.compnd.memb); + dt->shared->u.compnd.nmembs = 0; break; case H5T_ENUM: for(i = 0; i < dt->shared->u.enumer.nmembs; i++) - H5MM_xfree(dt->shared->u.enumer.name[i]); - H5MM_xfree(dt->shared->u.enumer.name); - H5MM_xfree(dt->shared->u.enumer.value); + dt->shared->u.enumer.name[i] = (char *)H5MM_xfree(dt->shared->u.enumer.name[i]); + dt->shared->u.enumer.name = (char **)H5MM_xfree(dt->shared->u.enumer.name); + dt->shared->u.enumer.value = (uint8_t *)H5MM_xfree(dt->shared->u.enumer.value); + dt->shared->u.enumer.nmembs = 0; break; case H5T_OPAQUE: - H5MM_xfree(dt->shared->u.opaque.tag); + dt->shared->u.opaque.tag = (char *)H5MM_xfree(dt->shared->u.opaque.tag); break; case H5T_NO_CLASS: @@ -3563,11 +3573,13 @@ H5T__free(H5T_t *dt) default: break; } /* end switch */ + dt->shared->type = H5T_NO_CLASS; /* Close the parent */ HDassert(dt->shared->parent != dt); if(dt->shared->parent && H5T_close(dt->shared->parent) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, FAIL, "unable to close parent data type") + dt->shared->parent = NULL; done: FUNC_LEAVE_NOAPI(ret_value) @@ -3653,7 +3665,7 @@ H5T_close(H5T_t *dt) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "problem attempting to free location") } /* end if */ - /* Free the group hier. path since we're not calling H5T__free*/ + /* Free the group hier. path since we're not calling H5T__free() */ H5G_name_free(&(dt->path)); } /* end else */ @@ -4387,7 +4399,7 @@ done: * function like H5Tregister() is calling this function to * register a new hard conversion function, IS_API is TRUE * and the old path is replaced. If a private function like - * H5T_init_interface() is trying to register hard conversions, + * H5T__init_package() is trying to register hard conversions, * IS_API is FALSE and the old hard path is not replaced. * Tuesday, Sept 13, 2005 * @@ -4406,7 +4418,7 @@ H5T_path_find(const H5T_t *src, const H5T_t *dst, const char *name, hid_t src_id = -1, dst_id = -1; /*src and dst type identifiers */ int i; /*counter */ int nprint = 0; /*lines of output printed */ - H5T_path_t *ret_value; /*return value */ + H5T_path_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -4767,7 +4779,7 @@ static htri_t H5T_compiler_conv(H5T_t *src, H5T_t *dst) { H5T_path_t *path; - htri_t ret_value; + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -5059,7 +5071,7 @@ done: htri_t H5T_is_sensible(const H5T_t *dt) { - htri_t ret_value; + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -62,7 +62,7 @@ static void H5TS_key_destructor(void *key_val) { /* Use HDfree here instead of H5MM_xfree(), to avoid calling the H5CS routines */ - if(key_val!=NULL) + if(key_val != NULL) HDfree(key_val); } @@ -91,7 +91,8 @@ H5TS_key_destructor(void *key_val) void H5TS_pthread_first_thread_init(void) { - H5_g.H5_libinit_g = FALSE; + H5_g.H5_libinit_g = FALSE; /* Library hasn't been initialized */ + H5_g.H5_libterm_g = FALSE; /* Library isn't being shutdown */ #ifdef H5_HAVE_WIN32_API # ifdef PTW32_STATIC_LIB diff --git a/src/H5Tarray.c b/src/H5Tarray.c index 752f2aa..4b2c7cf 100644 --- a/src/H5Tarray.c +++ b/src/H5Tarray.c @@ -22,10 +22,7 @@ /* Module Setup */ /****************/ -#define H5T_PACKAGE /*suppress error about including H5Tpkg */ - -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5T_init_array_interface +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ /***********/ @@ -78,28 +75,6 @@ -/*-------------------------------------------------------------------------- -NAME - H5T_init_array_interface -- Initialize interface-specific information -USAGE - herr_t H5T_init_array_interface() - -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. (Just calls - H5T_init_iterface currently). - ---------------------------------------------------------------------------*/ -static herr_t -H5T_init_array_interface(void) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - FUNC_LEAVE_NOAPI(H5T_init()) -} /* H5T_init_array_interface() */ - - /*------------------------------------------------------------------------- * Function: H5Tarray_create2 * @@ -179,8 +154,8 @@ done: H5T_t * H5T__array_create(H5T_t *base, unsigned ndims, const hsize_t dim[/* ndims */]) { - H5T_t *ret_value; /* new array data type */ - unsigned u; /* local index variable */ + unsigned u; /* Local index variable */ + H5T_t *ret_value = NULL; /* New array data type */ FUNC_ENTER_PACKAGE diff --git a/src/H5Tbit.c b/src/H5Tbit.c index 5322959..8c53066 100644 --- a/src/H5Tbit.c +++ b/src/H5Tbit.c @@ -19,7 +19,7 @@ * the bytes are in little-endian order. */ -#define H5T_PACKAGE /*suppress error about including H5Tpkg */ +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ #include "H5private.h" /*generic functions */ @@ -261,7 +261,7 @@ H5T__bit_get_d(uint8_t *buf, size_t offset, size_t size) { uint64_t val = 0; size_t i, hs; - uint64_t ret_value; /* Return value */ + uint64_t ret_value = 0; /* Return value */ FUNC_ENTER_PACKAGE_NOERR diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c index 024cc83..5ff1c73 100644 --- a/src/H5Tcommit.c +++ b/src/H5Tcommit.c @@ -22,10 +22,7 @@ /* Module Setup */ /****************/ -#define H5T_PACKAGE /*suppress error about including H5Tpkg */ - -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5T_init_commit_interface +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ /***********/ @@ -83,28 +80,6 @@ static H5T_t *H5T_open_oid(const H5G_loc_t *loc, hid_t dxpl_id); -/*-------------------------------------------------------------------------- -NAME - H5T_init_commit_interface -- Initialize interface-specific information -USAGE - herr_t H5T_init_commit_interface() - -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. (Just calls - H5T_init_iterface currently). - ---------------------------------------------------------------------------*/ -static herr_t -H5T_init_commit_interface(void) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - FUNC_LEAVE_NOAPI(H5T_init()) -} /* H5T_init_commit_interface() */ - - /*------------------------------------------------------------------------- * Function: H5Tcommit2 * @@ -184,10 +159,10 @@ herr_t H5T__commit_named(const H5G_loc_t *loc, const char *name, H5T_t *dt, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id) { - H5O_obj_create_t ocrt_info; /* Information for object creation */ - H5T_obj_create_t tcrt_info; /* Information for named datatype creation */ - H5T_state_t old_state = H5T_STATE_TRANSIENT; /* The state of the datatype before H5T__commit. */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_obj_create_t ocrt_info; /* Information for object creation */ + H5T_obj_create_t tcrt_info; /* Information for named datatype creation */ + H5T_state_t old_state; /* The state of the datatype before H5T__commit. */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -518,7 +493,7 @@ H5T_committed(const H5T_t *type) int H5T_link(const H5T_t *type, int adjust, hid_t dxpl_id) { - int ret_value; /* Return value */ + int ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -705,7 +680,7 @@ H5T_open(const H5G_loc_t *loc, hid_t dxpl_id) { H5T_shared_t *shared_fo = NULL; H5T_t *dt = NULL; - H5T_t *ret_value; + H5T_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -821,7 +796,7 @@ static H5T_t * H5T_open_oid(const H5G_loc_t *loc, hid_t dxpl_id) { H5T_t *dt = NULL; /* Datatype from the file */ - H5T_t *ret_value; /* Return value */ + H5T_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT diff --git a/src/H5Tcompound.c b/src/H5Tcompound.c index b377b29..1342770 100644 --- a/src/H5Tcompound.c +++ b/src/H5Tcompound.c @@ -22,10 +22,7 @@ /* Module Setup */ /****************/ -#define H5T_PACKAGE /*suppress error about including H5Tpkg */ - -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5T_init_compound_interface +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ /***********/ @@ -80,26 +77,6 @@ static htri_t H5T_is_packed(const H5T_t *dt); -/*-------------------------------------------------------------------------- -NAME - H5T_init_compound_interface -- Initialize interface-specific information -USAGE - herr_t H5T_init_compound_interface() -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. (Just calls - H5T_init() currently). ---------------------------------------------------------------------------*/ -static herr_t -H5T_init_compound_interface(void) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - FUNC_LEAVE_NOAPI(H5T_init()) -} /* H5T_init_compound_interface() */ - - /*------------------------------------------------------------------------- * Function: H5Tget_member_offset * @@ -282,7 +259,7 @@ done: H5T_t * H5T_get_member_type(const H5T_t *dt, unsigned membno, H5T_copy_t method) { - H5T_t *ret_value; /* Return value */ + H5T_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) diff --git a/src/H5Tconv.c b/src/H5Tconv.c index 6847e68..8b96d22 100644 --- a/src/H5Tconv.c +++ b/src/H5Tconv.c @@ -21,7 +21,8 @@ /* Module Setup */ /****************/ -#define H5T_PACKAGE /*suppress error about including H5Tpkg */ +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ + /***********/ /* Headers */ @@ -2111,7 +2112,7 @@ done: H5T_subset_info_t * H5T__conv_struct_subset(const H5T_cdata_t *cdata) { - H5T_conv_struct_t *priv; + H5T_conv_struct_t *priv = NULL; FUNC_ENTER_PACKAGE_NOERR @@ -2925,7 +2926,7 @@ H5T__conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, /* Use O(log N) lookup */ unsigned lt = 0; unsigned rt = src->shared->u.enumer.nmembs; - unsigned md; + unsigned md = 0; int cmp; while(lt < rt) { diff --git a/src/H5Tcset.c b/src/H5Tcset.c index 33fb32a..95658ed 100644 --- a/src/H5Tcset.c +++ b/src/H5Tcset.c @@ -18,10 +18,7 @@ * the character set (cset) for the H5T interface. */ -#define H5T_PACKAGE /*suppress error about including H5Tpkg */ - -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5T_init_cset_interface +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ #include "H5private.h" /*generic functions */ @@ -30,28 +27,6 @@ #include "H5Tpkg.h" /*data-type functions */ -/*-------------------------------------------------------------------------- -NAME - H5T_init_cset_interface -- Initialize interface-specific information -USAGE - herr_t H5T_init_cset_interface() - -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. (Just calls - H5T_init_iterface currently). - ---------------------------------------------------------------------------*/ -static herr_t -H5T_init_cset_interface(void) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - FUNC_LEAVE_NOAPI(H5T_init()) -} /* H5T_init_cset_interface() */ - - /*------------------------------------------------------------------------- * Function: H5Tget_cset * diff --git a/src/H5Tdbg.c b/src/H5Tdbg.c index 717fc17..8a10cc6 100644 --- a/src/H5Tdbg.c +++ b/src/H5Tdbg.c @@ -28,7 +28,7 @@ /* Module Setup */ /****************/ -#define H5T_PACKAGE /*suppress error about including H5Tpkg */ +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ /***********/ diff --git a/src/H5Tdeprec.c b/src/H5Tdeprec.c index f1586bd..cd4de1d 100644 --- a/src/H5Tdeprec.c +++ b/src/H5Tdeprec.c @@ -31,10 +31,7 @@ /* Module Setup */ /****************/ -#define H5T_PACKAGE /*suppress error about including H5Tpkg */ - -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5T__init_deprec_interface +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ /***********/ @@ -84,51 +81,6 @@ /*******************/ - -/*-------------------------------------------------------------------------- -NAME - H5T__init_deprec_interface -- Initialize interface-specific information -USAGE - herr_t H5T__init_deprec_interface() -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. (Just calls - H5T_init() currently). - ---------------------------------------------------------------------------*/ -static herr_t -H5T__init_deprec_interface(void) -{ - FUNC_ENTER_STATIC_NOERR - - FUNC_LEAVE_NOAPI(H5T_init()) -} /* H5T__init_deprec_interface() */ - - -/*-------------------------------------------------------------------------- -NAME - H5T__term_deprec_interface -- Terminate interface -USAGE - herr_t H5T__term_deprec_interface() -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Terminates interface. (Just resets H5_interface_initialize_g - currently). - ---------------------------------------------------------------------------*/ -herr_t -H5T__term_deprec_interface(void) -{ - FUNC_ENTER_PACKAGE_NOERR - - /* Mark closed */ - H5_interface_initialize_g = 0; - - FUNC_LEAVE_NOAPI(0) -} /* H5T__term_deprec_interface() */ - #ifndef H5_NO_DEPRECATED_SYMBOLS /*------------------------------------------------------------------------- diff --git a/src/H5Tenum.c b/src/H5Tenum.c index 2b7563b..e80d748 100644 --- a/src/H5Tenum.c +++ b/src/H5Tenum.c @@ -18,10 +18,7 @@ * in the H5T interface. */ -#define H5T_PACKAGE /*suppress error about including H5Tpkg */ - -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5T_init_enum_interface +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ #include "H5private.h" /*generic functions */ @@ -36,27 +33,6 @@ static char *H5T_enum_nameof(const H5T_t *dt, const void *value, char *name/*out static herr_t H5T_enum_valueof(const H5T_t *dt, const char *name, void *value/*out*/); - -/*-------------------------------------------------------------------------- -NAME - H5T_init_enum_interface -- Initialize interface-specific information -USAGE - herr_t H5T_init_enum_interface() - -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. (Just calls - H5T_init_iterface currently). - ---------------------------------------------------------------------------*/ -static herr_t -H5T_init_enum_interface(void) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - FUNC_LEAVE_NOAPI(H5T_init()) -} /* H5T_init_enum_interface() */ /*------------------------------------------------------------------------- @@ -123,7 +99,7 @@ done: H5T_t * H5T__enum_create(const H5T_t *parent) { - H5T_t *ret_value; /*new enumeration data type */ + H5T_t *ret_value = NULL; /* New enumeration data type */ FUNC_ENTER_PACKAGE @@ -416,7 +392,7 @@ H5T_enum_nameof(const H5T_t *dt, const void *value, char *name/*out*/, size_t si unsigned lt, md = 0, rt; /* Indices for binary search */ int cmp = (-1); /* Comparison result */ hbool_t alloc_name = FALSE; /* Whether name has been allocated */ - char *ret_value; /* Return value */ + char *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT diff --git a/src/H5Tfields.c b/src/H5Tfields.c index fb186fb..8818a73 100644 --- a/src/H5Tfields.c +++ b/src/H5Tfields.c @@ -18,10 +18,7 @@ * enumerated & compound datatypes in the H5T interface. */ -#define H5T_PACKAGE /*suppress error about including H5Tpkg */ - -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5T_init_fields_interface +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ #include "H5private.h" /*generic functions */ @@ -31,28 +28,6 @@ #include "H5Tpkg.h" /*data-type functions */ -/*-------------------------------------------------------------------------- -NAME - H5T_init_fields_interface -- Initialize interface-specific information -USAGE - herr_t H5T_init_fields_interface() - -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. (Just calls - H5T_init_iterface currently). - ---------------------------------------------------------------------------*/ -static herr_t -H5T_init_fields_interface(void) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - FUNC_LEAVE_NOAPI(H5T_init()) -} /* H5T_init_fields_interface() */ - - /*------------------------------------------------------------------------- * Function: H5Tget_nmembers * @@ -117,7 +92,7 @@ done: int H5T_get_nmembers(const H5T_t *dt) { - int ret_value; + int ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -199,7 +174,7 @@ done: char * H5T__get_member_name(H5T_t const *dt, unsigned membno) { - char *ret_value; + char *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE diff --git a/src/H5Tfixed.c b/src/H5Tfixed.c index daa7886..62b8e79 100644 --- a/src/H5Tfixed.c +++ b/src/H5Tfixed.c @@ -18,10 +18,7 @@ * integer) datatypes in the H5T interface. */ -#define H5T_PACKAGE /*suppress error about including H5Tpkg */ - -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5T_init_fixed_interface +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ #include "H5private.h" /*generic functions */ @@ -30,28 +27,6 @@ #include "H5Tpkg.h" /*data-type functions */ -/*-------------------------------------------------------------------------- -NAME - H5T_init_fixed_interface -- Initialize interface-specific information -USAGE - herr_t H5T_init_fixed_interface() - -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. (Just calls - H5T_init_iterface currently). - ---------------------------------------------------------------------------*/ -static herr_t -H5T_init_fixed_interface(void) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - FUNC_LEAVE_NOAPI(H5T_init()) -} /* H5T_init_fixed_interface() */ - - /*------------------------------------------------------------------------- * Function: H5Tget_sign * @@ -109,7 +84,7 @@ done: H5T_sign_t H5T_get_sign(H5T_t const *dt) { - H5T_sign_t ret_value; + H5T_sign_t ret_value = H5T_SGN_ERROR; /* Return value */ FUNC_ENTER_NOAPI(H5T_SGN_ERROR) diff --git a/src/H5Tfloat.c b/src/H5Tfloat.c index fff413d..b8b1c07 100644 --- a/src/H5Tfloat.c +++ b/src/H5Tfloat.c @@ -18,10 +18,7 @@ * datatypes in the H5T interface. */ -#define H5T_PACKAGE /*suppress error about including H5Tpkg */ - -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5T_init_float_interface +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ #include "H5private.h" /*generic functions */ @@ -29,27 +26,6 @@ #include "H5Iprivate.h" /*ID functions */ #include "H5Tpkg.h" /*data-type functions */ - -/*-------------------------------------------------------------------------- -NAME - H5T_init_float_interface -- Initialize interface-specific information -USAGE - herr_t H5T_init_float_interface() - -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. (Just calls - H5T_init_iterface currently). - ---------------------------------------------------------------------------*/ -static herr_t -H5T_init_float_interface(void) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - FUNC_LEAVE_NOAPI(H5T_init()) -} /* H5T_init_float_interface() */ /*------------------------------------------------------------------------- diff --git a/src/H5Tmodule.h b/src/H5Tmodule.h new file mode 100644 index 0000000..bfaab5e6 --- /dev/null +++ b/src/H5Tmodule.h @@ -0,0 +1,35 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Quincey Koziol <koziol@hdfgroup.org> + * Saturday, September 12, 2015 + * + * Purpose: This file contains declarations which define macros for the + * H5T package. Including this header means that the source file + * is part of the H5T package. + */ +#ifndef _H5Tmodule_H +#define _H5Tmodule_H + +/* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error + * reporting macros. + */ +#define H5T_MODULE +#define H5_MY_PKG H5T +#define H5_MY_PKG_ERR H5E_DATATYPE +#define H5_MY_PKG_INIT YES + +#endif /* _H5Tmodule_H */ + diff --git a/src/H5Tnative.c b/src/H5Tnative.c index bf6ba08..229fe94 100644 --- a/src/H5Tnative.c +++ b/src/H5Tnative.c @@ -18,10 +18,7 @@ * a "native" datatype for the H5T interface. */ -#define H5T_PACKAGE /*suppress error about including H5Tpkg */ - -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5T_init_native_interface +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ #include "H5private.h" /* Generic Functions */ @@ -43,27 +40,6 @@ static H5T_t* H5T_get_native_bitfield(size_t prec, H5T_direction_t direction, static herr_t H5T_cmp_offset(size_t *comp_size, size_t *offset, size_t elem_size, size_t nelems, size_t align, size_t *struct_align); - -/*-------------------------------------------------------------------------- -NAME - H5T_init_native_interface -- Initialize interface-specific information -USAGE - herr_t H5T_init_native_interface() - -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. (Just calls - H5T_init_iterface currently). - ---------------------------------------------------------------------------*/ -static herr_t -H5T_init_native_interface(void) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - FUNC_LEAVE_NOAPI(H5T_init()) -} /* H5T_init_native_interface() */ /*------------------------------------------------------------------------- @@ -168,7 +144,7 @@ H5T_get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_alig int snmemb; /* Number of members in compound & enum types */ unsigned nmemb = 0; /* Number of members in compound & enum types */ unsigned u; /* Local index variable */ - H5T_t *ret_value; /* Return value */ + H5T_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -571,7 +547,7 @@ H5T_get_native_integer(size_t prec, H5T_sign_t sign, H5T_direction_t direction, H5T_NATIVE_INT_MATCH_LLONG, H5T_NATIVE_INT_MATCH_UNKNOWN } match = H5T_NATIVE_INT_MATCH_UNKNOWN; - H5T_t *ret_value; /* Return value */ + H5T_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -711,7 +687,7 @@ H5T_get_native_float(size_t size, H5T_direction_t direction, size_t *struct_alig #endif H5T_NATIVE_FLOAT_MATCH_UNKNOWN } match=H5T_NATIVE_FLOAT_MATCH_UNKNOWN; - H5T_t *ret_value; /* Return value */ + H5T_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -829,7 +805,7 @@ H5T_get_native_bitfield(size_t prec, H5T_direction_t direction, size_t *struct_a hid_t tid=(-1); /* Datatype ID of appropriate native datatype */ size_t align=0; /* Alignment necessary for native datatype */ size_t native_size=0; /* Datatype size of the native type */ - H5T_t *ret_value; /* Return value */ + H5T_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) diff --git a/src/H5Toffset.c b/src/H5Toffset.c index ea4b3b5..cc45d8e 100644 --- a/src/H5Toffset.c +++ b/src/H5Toffset.c @@ -18,10 +18,7 @@ * the datatype offset for the H5T interface. */ -#define H5T_PACKAGE /*suppress error about including H5Tpkg */ - -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5T_init_offset_interface +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ #include "H5private.h" /* Generic Functions */ @@ -32,27 +29,6 @@ /* Static local functions */ static herr_t H5T_set_offset(const H5T_t *dt, size_t offset); - -/*-------------------------------------------------------------------------- -NAME - H5T_init_offset_interface -- Initialize interface-specific information -USAGE - herr_t H5T_init_offset_interface() - -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. (Just calls - H5T_init_iterface currently). - ---------------------------------------------------------------------------*/ -static herr_t -H5T_init_offset_interface(void) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - FUNC_LEAVE_NOAPI(H5T_init()) -} /* H5T_init_offset_interface() */ /*------------------------------------------------------------------------- @@ -138,7 +114,7 @@ done: int H5T_get_offset(const H5T_t *dt) { - int ret_value; + int ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI(-1) diff --git a/src/H5Toh.c b/src/H5Toh.c index abf8a51..9c8ad80 100644 --- a/src/H5Toh.c +++ b/src/H5Toh.c @@ -17,8 +17,8 @@ /* Module Setup */ /****************/ -#define H5O_PACKAGE /*suppress error about including H5Opkg */ -#define H5T_PACKAGE /*suppress error about including H5Tpkg */ +#define H5O_FRIEND /*suppress error about including H5Opkg */ +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ /***********/ @@ -102,7 +102,7 @@ const H5O_obj_class_t H5O_OBJ_DATATYPE[1] = {{ static htri_t H5O_dtype_isa(struct H5O_t *oh) { - htri_t ret_value; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -133,7 +133,7 @@ static hid_t H5O_dtype_open(const H5G_loc_t *obj_loc, hid_t H5_ATTR_UNUSED lapl_id, hid_t dxpl_id, hbool_t app_ref) { H5T_t *type = NULL; /* Datatype opened */ - hid_t ret_value; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -173,7 +173,7 @@ static void * H5O_dtype_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc, hid_t dxpl_id) { H5T_obj_create_t *crt_info = (H5T_obj_create_t *)_crt_info; /* Named datatype creation parameters */ - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -217,7 +217,7 @@ static H5O_loc_t * H5O_dtype_get_oloc(hid_t obj_id) { H5T_t *type; /* Datatype opened */ - H5O_loc_t *ret_value; /* Return value */ + H5O_loc_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT diff --git a/src/H5Topaque.c b/src/H5Topaque.c index f37d14b..9cc22c9 100644 --- a/src/H5Topaque.c +++ b/src/H5Topaque.c @@ -18,10 +18,7 @@ * datatypes in the H5T interface. */ -#define H5T_PACKAGE /*suppress error about including H5Tpkg */ - -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5T_init_opaque_interface +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ #include "H5private.h" /* Generic Functions */ @@ -30,27 +27,6 @@ #include "H5MMprivate.h" /* Memory management */ #include "H5Tpkg.h" /* Datatypes */ - -/*-------------------------------------------------------------------------- -NAME - H5T_init_opaque_interface -- Initialize interface-specific information -USAGE - herr_t H5T_init_opaque_interface() - -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. (Just calls - H5T_init_iterface currently). - ---------------------------------------------------------------------------*/ -static herr_t -H5T_init_opaque_interface(void) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - FUNC_LEAVE_NOAPI(H5T_init()) -} /* H5T_init_opaque_interface() */ /*------------------------------------------------------------------------- diff --git a/src/H5Torder.c b/src/H5Torder.c index 35be454..6c9c55c 100644 --- a/src/H5Torder.c +++ b/src/H5Torder.c @@ -22,10 +22,7 @@ /* Module Setup */ /****************/ -#define H5T_PACKAGE /*suppress error about including H5Tpkg */ - -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5T_init_order_interface +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ /***********/ @@ -79,27 +76,6 @@ static herr_t H5T_set_order(H5T_t *dtype, H5T_order_t order); -/*-------------------------------------------------------------------------- -NAME - H5T_init_order_interface -- Initialize interface-specific information -USAGE - herr_t H5T_init_order_interface() -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. (Just calls - H5T_init_iterface currently). - ---------------------------------------------------------------------------*/ -static herr_t -H5T_init_order_interface(void) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - FUNC_LEAVE_NOAPI(H5T_init()) -} /* H5T_init_order_interface() */ - - /*------------------------------------------------------------------------- * Function: H5Tget_order * diff --git a/src/H5Tpad.c b/src/H5Tpad.c index 38de494..e636a84 100644 --- a/src/H5Tpad.c +++ b/src/H5Tpad.c @@ -18,10 +18,7 @@ * the datatype padding for the H5T interface. */ -#define H5T_PACKAGE /*suppress error about including H5Tpkg */ - -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5T_init_pad_interface +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ #include "H5private.h" /* Generic Functions */ @@ -29,27 +26,6 @@ #include "H5Iprivate.h" /* IDs */ #include "H5Tpkg.h" /* Datatypes */ - -/*-------------------------------------------------------------------------- -NAME - H5T_init_pad_interface -- Initialize interface-specific information -USAGE - herr_t H5T_init_pad_interface() - -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. (Just calls - H5T_init_iterface currently). - ---------------------------------------------------------------------------*/ -static herr_t -H5T_init_pad_interface(void) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - FUNC_LEAVE_NOAPI(H5T_init()) -} /* H5T_init_pad_interface() */ /*------------------------------------------------------------------------- diff --git a/src/H5Tpkg.h b/src/H5Tpkg.h index 0b0cd61..0bd1e06 100644 --- a/src/H5Tpkg.h +++ b/src/H5Tpkg.h @@ -21,7 +21,7 @@ * the H5T package. Source files outside the H5T package should * include H5Tprivate.h instead. */ -#ifndef H5T_PACKAGE +#if !(defined H5T_FRIEND || defined H5T_MODULE) #error "Do not include this file outside the H5T package!" #endif @@ -424,7 +424,7 @@ H5FL_EXTERN(H5T_t); H5FL_EXTERN(H5T_shared_t); /* Common functions */ -H5_DLL herr_t H5T__term_deprec_interface(void); +H5_DLL herr_t H5T__init_native(void); H5_DLL H5T_t *H5T__create(H5T_class_t type, size_t size); H5_DLL herr_t H5T__commit(H5F_t *file, H5T_t *type, hid_t tcpl_id, hid_t dxpl_id); H5_DLL herr_t H5T__commit_named(const H5G_loc_t *loc, const char *name, diff --git a/src/H5Tprecis.c b/src/H5Tprecis.c index 73a4e32..be85491 100644 --- a/src/H5Tprecis.c +++ b/src/H5Tprecis.c @@ -18,10 +18,7 @@ * the datatype precision for the H5T interface. */ -#define H5T_PACKAGE /*suppress error about including H5Tpkg */ - -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5T_init_precis_interface +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ #include "H5private.h" /* Generic Functions */ @@ -32,27 +29,6 @@ /* Static local functions */ static herr_t H5T_set_precision(const H5T_t *dt, size_t prec); - -/*-------------------------------------------------------------------------- -NAME - H5T_init_precis_interface -- Initialize interface-specific information -USAGE - herr_t H5T_init_precis_interface() - -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. (Just calls - H5T_init_iterface currently). - ---------------------------------------------------------------------------*/ -static herr_t -H5T_init_precis_interface(void) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - FUNC_LEAVE_NOAPI(H5T_init()) -} /* H5T_init_precis_interface() */ /*------------------------------------------------------------------------- @@ -119,7 +95,7 @@ done: size_t H5T_get_precision(const H5T_t *dt) { - size_t ret_value; + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI(0) diff --git a/src/H5Tprivate.h b/src/H5Tprivate.h index 558afaf..93fe599 100644 --- a/src/H5Tprivate.h +++ b/src/H5Tprivate.h @@ -34,17 +34,17 @@ #define H5T_ELEM_BUF_SIZE 256 /* If the module using this macro is allowed access to the private variables, access them directly */ -#ifdef H5T_PACKAGE +#ifdef H5T_MODULE #define H5T_GET_SIZE(T) ((T)->shared->size) #define H5T_GET_SHARED(T) ((T)->shared) #define H5T_GET_MEMBER_OFFSET(T, I) ((T)->u.compnd.memb[I].offset) #define H5T_GET_MEMBER_SIZE(T, I) ((T)->u.compnd.memb[I].shared->size) -#else /* H5T_PACKAGE */ +#else /* H5T_MODULE */ #define H5T_GET_SIZE(T) (H5T_get_size(T)) #define H5T_GET_SHARED(T) (H5T_get_shared(T)) #define H5T_GET_MEMBER_OFFSET(T, I) (H5T_get_member_offset((T), (I))) #define H5T_GET_MEMBER_SIZE(T, I) (H5T_get_member_size((T), (I))) -#endif /* H5T_PACKAGE */ +#endif /* H5T_MODULE */ /* Forward references of package typedefs (declared in H5Tpkg.h) */ typedef struct H5T_t H5T_t; @@ -104,7 +104,6 @@ struct H5O_t; H5_DLLVAR H5T_order_t H5T_native_order_g; /* Private functions */ -H5_DLL herr_t H5TN_init_interface(void); H5_DLL herr_t H5T_init(void); H5_DLL H5T_t *H5T_copy(H5T_t *old_dt, H5T_copy_t method); H5_DLL herr_t H5T_lock(H5T_t *dt, hbool_t immutable); diff --git a/src/H5Tstrpad.c b/src/H5Tstrpad.c index c71827b..2cd1db4 100644 --- a/src/H5Tstrpad.c +++ b/src/H5Tstrpad.c @@ -18,10 +18,7 @@ * the datatype string padding for the H5T interface. */ -#define H5T_PACKAGE /*suppress error about including H5Tpkg */ - -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5T_init_strpad_interface +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ #include "H5private.h" /* Generic Functions */ @@ -29,27 +26,6 @@ #include "H5Iprivate.h" /* IDs */ #include "H5Tpkg.h" /* Datatypes */ - -/*-------------------------------------------------------------------------- -NAME - H5T_init_strpad_interface -- Initialize interface-specific information -USAGE - herr_t H5T_init_strpad_interface() - -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. (Just calls - H5T_init_iterface currently). - ---------------------------------------------------------------------------*/ -static herr_t -H5T_init_strpad_interface(void) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - FUNC_LEAVE_NOAPI(H5T_init()) -} /* H5T_init_strpad_interface() */ /*------------------------------------------------------------------------- diff --git a/src/H5Tvisit.c b/src/H5Tvisit.c index 4ede3f3..d732fb3 100644 --- a/src/H5Tvisit.c +++ b/src/H5Tvisit.c @@ -35,7 +35,7 @@ /* Module Setup */ /****************/ -#define H5T_PACKAGE /*suppress error about including H5Tpkg */ +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ /***********/ diff --git a/src/H5Tvlen.c b/src/H5Tvlen.c index 64337b8..26346d6 100644 --- a/src/H5Tvlen.c +++ b/src/H5Tvlen.c @@ -18,10 +18,7 @@ * datatypes in the H5T interface. */ -#define H5T_PACKAGE /*suppress error about including H5Tpkg */ - -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5T_init_vlen_interface +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ #include "H5private.h" /* Generic Functions */ @@ -64,27 +61,6 @@ static H5T_vlen_alloc_info_t H5T_vlen_def_vl_alloc_info ={ H5D_VLEN_FREE_INFO }; - -/*-------------------------------------------------------------------------- -NAME - H5T_init_vlen_interface -- Initialize interface-specific information -USAGE - herr_t H5T_init_vlen_interface() - -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. (Just calls - H5T_init_iterface currently). - ---------------------------------------------------------------------------*/ -static herr_t -H5T_init_vlen_interface(void) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - FUNC_LEAVE_NOAPI(H5T_init()) -} /* H5T_init_vlen_interface() */ /*------------------------------------------------------------------------- @@ -147,8 +123,8 @@ done: H5T_t * H5T__vlen_create(const H5T_t *base) { - H5T_t *dt = NULL; /*new VL datatype */ - H5T_t *ret_value; /*return value */ + H5T_t *dt = NULL; /* New VL datatype */ + H5T_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -781,7 +757,7 @@ static ssize_t H5T_vlen_disk_getlen(const void *_vl) { const uint8_t *vl=(const uint8_t *)_vl; /* Pointer to the disk VL information */ - size_t seq_len; /* Sequence length */ + size_t seq_len = 0; /* Sequence length */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -13,10 +13,7 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#define H5Z_PACKAGE /*suppress error about including H5Zpkg */ - -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5Z_init_interface +#include "H5Zmodule.h" /* This source code file is part of the H5Z module */ #include "H5private.h" /* Generic Functions */ @@ -57,6 +54,9 @@ 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; @@ -73,7 +73,7 @@ static int H5Z__flush_file_cb(void *obj_ptr, hid_t obj_id, void *key); /*------------------------------------------------------------------------- - * Function: H5Z_init_interface + * Function: H5Z__init_package * * Purpose: Initializes the data filter layer. * @@ -82,45 +82,43 @@ static int H5Z__flush_file_cb(void *obj_ptr, hid_t obj_id, void *key); * Programmer: Robb Matzke * Thursday, April 16, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ -static herr_t -H5Z_init_interface (void) +herr_t +H5Z__init_package(void) { - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* Internal filters */ - if (H5Z_register (H5Z_SHUFFLE)<0) - HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register shuffle filter") - if (H5Z_register (H5Z_FLETCHER32)<0) - HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register fletcher32 filter") - if (H5Z_register (H5Z_NBIT)<0) - HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register nbit filter") - if (H5Z_register (H5Z_SCALEOFFSET)<0) - HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register scaleoffset filter") + if(H5Z_register(H5Z_SHUFFLE) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register shuffle filter") + if(H5Z_register(H5Z_FLETCHER32) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register fletcher32 filter") + if(H5Z_register(H5Z_NBIT) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register nbit filter") + if(H5Z_register(H5Z_SCALEOFFSET) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register scaleoffset filter") /* External filters */ #ifdef H5_HAVE_FILTER_DEFLATE - if (H5Z_register (H5Z_DEFLATE)<0) + if(H5Z_register(H5Z_DEFLATE) < 0) HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register deflate filter") #endif /* H5_HAVE_FILTER_DEFLATE */ #ifdef H5_HAVE_FILTER_SZIP H5Z_SZIP->encoder_present = SZ_encoder_enabled(); - if (H5Z_register (H5Z_SZIP)<0) + if(H5Z_register(H5Z_SZIP) < 0) HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register szip filter") #endif /* H5_HAVE_FILTER_SZIP */ done: FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5Z__init_package() */ /*------------------------------------------------------------------------- - * Function: H5Z_term_interface + * Function: H5Z_term_package * * Purpose: Terminate the H5Z layer. * @@ -129,44 +127,44 @@ done: * Programmer: Robb Matzke * Thursday, April 16, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ int -H5Z_term_interface(void) +H5Z_term_package(void) { -#ifdef H5Z_DEBUG - size_t i; - int dir, nprint=0; - char comment[16], bandwidth[32]; -#endif + int n = 0; + + FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5_interface_initialize_g) { + if(H5_PKG_INIT_VAR) { #ifdef H5Z_DEBUG - if (H5DEBUG(Z)) { - for (i=0; i<H5Z_table_used_g; i++) { - for (dir=0; dir<2; dir++) { - if (0==H5Z_stat_table_g[i].stats[dir].total) continue; + char comment[16], bandwidth[32]; + int dir, nprint = 0; + size_t i; - if (0==nprint++) { + if(H5DEBUG(Z)) { + for(i = 0; i < H5Z_table_used_g; i++) { + for(dir = 0; dir<2; dir++) { + if(0 == H5Z_stat_table_g[i].stats[dir].total) + continue; + + if(0 == nprint++) { /* Print column headers */ - HDfprintf (H5DEBUG(Z), "H5Z: filter statistics " + HDfprintf(H5DEBUG(Z), "H5Z: filter statistics " "accumulated over life of library:\n"); - HDfprintf (H5DEBUG(Z), + HDfprintf(H5DEBUG(Z), " %-16s %10s %10s %8s %8s %8s %10s\n", "Filter", "Total", "Errors", "User", "System", "Elapsed", "Bandwidth"); - HDfprintf (H5DEBUG(Z), + 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'; + HDstrncpy(comment, H5Z_table_g[i].name, sizeof comment); + comment[sizeof(comment) - 1] = '\0'; /* * Format bandwidth to have four significant digits and @@ -178,7 +176,7 @@ H5Z_term_interface(void) H5Z_stat_table_g[i].stats[dir].timer.etime); /* Print the statistics */ - HDfprintf (H5DEBUG(Z), + HDfprintf(H5DEBUG(Z), " %s%-15s %10Hd %10Hd %8.2f %8.2f %8.2f " "%10s\n", dir?"<":">", comment, H5Z_stat_table_g[i].stats[dir].total, @@ -187,21 +185,28 @@ H5Z_term_interface(void) H5Z_stat_table_g[i].stats[dir].timer.stime, H5Z_stat_table_g[i].stats[dir].timer.etime, bandwidth); - } - } - } + } /* end for */ + } /* end for */ + } /* end if */ #endif /* H5Z_DEBUG */ /* Free the table of filters */ - H5Z_table_g = (H5Z_class2_t *)H5MM_xfree(H5Z_table_g); + 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; - H5_interface_initialize_g = 0; + H5Z_table_used_g = H5Z_table_alloc_g = 0; + + n++; + } /* end if */ + + /* Mark interface as closed */ + if(0 == n) + H5_PKG_INIT_VAR = FALSE; } /* end if */ - return(0); -} /* end H5Z_term_interface() */ + FUNC_LEAVE_NOAPI(n) +} /* end H5Z_term_package() */ /*------------------------------------------------------------------------- @@ -1445,8 +1450,8 @@ done: H5Z_filter_info_t * H5Z_filter_info(const H5O_pline_t *pline, H5Z_filter_t filter) { - size_t idx; /* Index of filter in pipeline */ - H5Z_filter_info_t *ret_value; /* Return value */ + size_t idx; /* Index of filter in pipeline */ + H5Z_filter_info_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) diff --git a/src/H5Zdeflate.c b/src/H5Zdeflate.c index 06d9866..15aac27 100644 --- a/src/H5Zdeflate.c +++ b/src/H5Zdeflate.c @@ -18,7 +18,7 @@ * Friday, August 27, 1999 */ -#define H5Z_PACKAGE /*suppress error about including H5Zpkg */ +#include "H5Zmodule.h" /* This source code file is part of the H5Z module */ #include "H5private.h" /* Generic Functions */ @@ -77,7 +77,7 @@ H5Z_filter_deflate (unsigned flags, size_t cd_nelmts, { void *outbuf = NULL; /* Pointer to new buffer */ int status; /* Status from zlib operation */ - size_t ret_value; /* Return value */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI(0) diff --git a/src/H5Zfletcher32.c b/src/H5Zfletcher32.c index 1877ddd..690d7a2 100644 --- a/src/H5Zfletcher32.c +++ b/src/H5Zfletcher32.c @@ -14,11 +14,11 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Raymond Lu<slu@ncsa.uiuc.edu> + * Programmer: Raymond Lu <slu@ncsa.uiuc.edu> * Jan 3, 2003 */ -#define H5Z_PACKAGE /*suppress error about including H5Zpkg */ +#include "H5Zmodule.h" /* This source code file is part of the H5Z module */ #include "H5private.h" /* Generic Functions */ @@ -81,7 +81,7 @@ H5Z_filter_fletcher32 (unsigned flags, size_t H5_ATTR_UNUSED cd_nelmts, const un uint32_t reversed_fletcher; /* Possible wrong checksum value */ uint8_t c[4]; uint8_t tmp; - size_t ret_value; /* Return value */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI(0) diff --git a/src/H5Zmodule.h b/src/H5Zmodule.h new file mode 100644 index 0000000..fa0ef8f --- /dev/null +++ b/src/H5Zmodule.h @@ -0,0 +1,35 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Quincey Koziol <koziol@hdfgroup.org> + * Saturday, September 12, 2015 + * + * Purpose: This file contains declarations which define macros for the + * H5Z package. Including this header means that the source file + * is part of the H5Z package. + */ +#ifndef _H5Zmodule_H +#define _H5Zmodule_H + +/* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error + * reporting macros. + */ +#define H5Z_MODULE +#define H5_MY_PKG H5Z +#define H5_MY_PKG_ERR H5E_PLINE +#define H5_MY_PKG_INIT YES + +#endif /* _H5Zmodule_H */ + diff --git a/src/H5Znbit.c b/src/H5Znbit.c index 479cd6c..e2fb300 100644 --- a/src/H5Znbit.c +++ b/src/H5Znbit.c @@ -13,7 +13,7 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#define H5Z_PACKAGE /*suppress error about including H5Zpkg */ +#include "H5Zmodule.h" /* This source code file is part of the H5Z module */ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ diff --git a/src/H5Zpkg.h b/src/H5Zpkg.h index e2cec89..aa2ffe2 100644 --- a/src/H5Zpkg.h +++ b/src/H5Zpkg.h @@ -13,7 +13,7 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef H5Z_PACKAGE +#if !(defined H5Z_FRIEND || defined H5Z_MODULE) #error "Do not include this file outside the H5Z package!" #endif diff --git a/src/H5Zscaleoffset.c b/src/H5Zscaleoffset.c index 46dd3c1..7de0060 100644 --- a/src/H5Zscaleoffset.c +++ b/src/H5Zscaleoffset.c @@ -13,7 +13,7 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#define H5Z_PACKAGE /*suppress error about including H5Zpkg */ +#include "H5Zmodule.h" /* This source code file is part of the H5Z module */ #include "H5private.h" /* Generic Functions */ #include "H5ACprivate.h" /* Metadata cache */ @@ -746,7 +746,7 @@ static enum H5Z_scaleoffset_t H5Z_scaleoffset_get_type(unsigned dtype_class, unsigned dtype_size, unsigned dtype_sign) { enum H5Z_scaleoffset_t type = t_bad; /* integer type */ - enum H5Z_scaleoffset_t ret_value; /* return value */ + enum H5Z_scaleoffset_t ret_value = t_bad; /* Return value */ FUNC_ENTER_NOAPI_NOINIT diff --git a/src/H5Zshuffle.c b/src/H5Zshuffle.c index 654a7d5..3fa6c8d 100644 --- a/src/H5Zshuffle.c +++ b/src/H5Zshuffle.c @@ -13,7 +13,7 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#define H5Z_PACKAGE /*suppress error about including H5Zpkg */ +#include "H5Zmodule.h" /* This source code file is part of the H5Z module */ #include "H5private.h" /* Generic Functions */ @@ -135,7 +135,7 @@ H5Z_filter_shuffle(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], size_t j; /* Local index variable */ #endif /* NO_DUFFS_DEVICE */ size_t leftover; /* Extra bytes at end of buffer */ - size_t ret_value; /* Return value */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI(0) diff --git a/src/H5Zszip.c b/src/H5Zszip.c index f0d08d8..2c2ed07 100644 --- a/src/H5Zszip.c +++ b/src/H5Zszip.c @@ -13,7 +13,7 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#define H5Z_PACKAGE /*suppress error about including H5Zpkg */ +#include "H5Zmodule.h" /* This source code file is part of the H5Z module */ #include "H5private.h" /* Generic Functions */ diff --git a/src/H5Ztrans.c b/src/H5Ztrans.c index ee15b52..42d6ceb 100644 --- a/src/H5Ztrans.c +++ b/src/H5Ztrans.c @@ -13,7 +13,7 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#define H5Z_PACKAGE /*suppress error about including H5Zpkg */ +#include "H5Zmodule.h" /* This source code file is part of the H5Z module */ #include "H5private.h" /* Generic Functions */ @@ -548,7 +548,7 @@ static void * H5Z_xform_parse(const char *expression, H5Z_datval_ptrs* dat_val_pointers) { H5Z_token tok; - void* ret_value; + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -587,7 +587,7 @@ static H5Z_node * H5Z_parse_expression(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers) { H5Z_node *expr; - H5Z_node *ret_value; /* Return value */ + H5Z_node *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -681,7 +681,7 @@ static H5Z_node * H5Z_parse_term(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers) { H5Z_node *term = NULL; - H5Z_node *ret_value; + H5Z_node *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -781,7 +781,7 @@ H5Z_parse_factor(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers) { H5Z_node *factor=NULL; H5Z_node *new_node; - H5Z_node *ret_value; + H5Z_node *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -923,7 +923,7 @@ done: static H5Z_node * H5Z_new_node(H5Z_token_type type) { - H5Z_node *ret_value; + H5Z_node *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1480,10 +1480,10 @@ H5Z_do_op(H5Z_node* tree) H5Z_data_xform_t * H5Z_xform_create(const char *expr) { - H5Z_data_xform_t *data_xform_prop=NULL; - H5Z_data_xform_t *ret_value; + H5Z_data_xform_t *data_xform_prop = NULL; unsigned int i; unsigned int count = 0; + H5Z_data_xform_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -1697,7 +1697,7 @@ done: hbool_t H5Z_xform_noop(const H5Z_data_xform_t *data_xform_prop) { - hbool_t ret_value; + hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR diff --git a/src/H5detect.c b/src/H5detect.c index 5daf883..ee02c52 100644 --- a/src/H5detect.c +++ b/src/H5detect.c @@ -608,7 +608,7 @@ print_results(int nd, detected_t *d, int na, malign_t *misc_align) /* Module Setup */\n\ /****************/\n\ \n\ -#define H5T_PACKAGE /*suppress error about including H5Tpkg.h*/\n\ +#include \"H5Tmodule.h\" /* This source code file is part of the H5T module */\n\ \n\ \n\ /***********/\n\ @@ -667,7 +667,7 @@ print_results(int nd, detected_t *d, int na, malign_t *misc_align) printf("\n\ \n\ /*-------------------------------------------------------------------------\n\ - * Function: H5TN_init_interface\n\ + * Function: H5T__init_native\n\ *\n\ * Purpose: Initialize pre-defined native datatypes from code generated\n\ * during the library configuration by H5detect.\n\ @@ -681,12 +681,12 @@ print_results(int nd, detected_t *d, int na, malign_t *misc_align) *-------------------------------------------------------------------------\n\ */\n\ herr_t\n\ -H5TN_init_interface(void)\n\ +H5T__init_native(void)\n\ {\n\ H5T_t *dt = NULL;\n\ herr_t ret_value = SUCCEED;\n\ \n\ - FUNC_ENTER_NOAPI(FAIL)\n"); + FUNC_ENTER_PACKAGE\n"); for(i = 0; i < nd; i++) { /* The native endianess of this machine */ @@ -809,7 +809,7 @@ done:\n\ } /* end if */\n\ } /* end if */\n\ \n\ - FUNC_LEAVE_NOAPI(ret_value);\n} /* end H5TN_init_interface() */\n"); + FUNC_LEAVE_NOAPI(ret_value);\n} /* end H5T__init_native() */\n"); /* Print the ALIGNMENT and signal-handling status as comments */ printf("\n" diff --git a/src/H5private.h b/src/H5private.h index 10f47a7..e057d20 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -1505,6 +1505,16 @@ extern char *strdup(const char *s); #define HDpthread_self_ulong() ((unsigned long)pthread_self()) #endif /* HDpthread_self_ulong */ +/* Macro for "stringizing" an integer in the C preprocessor (use H5_TOSTRING) */ +/* (use H5_TOSTRING, H5_STRINGIZE is just part of the implementation) */ +#define H5_STRINGIZE(x) #x +#define H5_TOSTRING(x) H5_STRINGIZE(x) + +/* Macro for "glueing" together items, for re-scanning macros */ +#define H5_GLUE(x,y) x##y +#define H5_GLUE3(x,y,z) x##y##z +#define H5_GLUE4(w,x,y,z) w##x##y##z + /* * A macro for detecting over/under-flow when casting between types */ @@ -1824,10 +1834,12 @@ extern char H5_lib_vers_info_g[]; typedef struct H5_api_struct { H5TS_mutex_t init_lock; /* API entrance mutex */ hbool_t H5_libinit_g; /* Has the library been initialized? */ + hbool_t H5_libterm_g; /* Is the library being shutdown? */ } H5_api_t; /* Macros for accessing the global variables */ -#define H5_INIT_GLOBAL H5_g.H5_libinit_g +#define H5_INIT_GLOBAL (H5_g.H5_libinit_g) +#define H5_TERM_GLOBAL (H5_g.H5_libterm_g) /* Macro for first thread initialization */ #ifdef H5_HAVE_WIN_THREADS @@ -1866,9 +1878,11 @@ extern H5_api_t H5_g; /* extern global variables */ extern hbool_t H5_libinit_g; /* Has the library been initialized? */ +extern hbool_t H5_libterm_g; /* Is the library being shutdown? */ /* Macros for accessing the global variables */ -#define H5_INIT_GLOBAL H5_libinit_g +#define H5_INIT_GLOBAL (H5_libinit_g) +#define H5_TERM_GLOBAL (H5_libterm_g) #endif /* H5_HAVE_THREADSAFE */ @@ -1888,101 +1902,110 @@ extern hbool_t H5_libinit_g; /* Has the library been initialized? */ extern hbool_t H5_MPEinit_g; /* Has the MPE Library been initialized? */ #endif -/* Macros for defining interface initialization routines */ -#ifdef H5_INTERFACE_INIT_FUNC -static int H5_interface_initialize_g = 0; -static herr_t H5_INTERFACE_INIT_FUNC(void); -#define H5_INTERFACE_INIT(err) \ - /* Initialize this interface or bust */ \ - if (!H5_interface_initialize_g) { \ - H5_interface_initialize_g = 1; \ - if (H5_INTERFACE_INIT_FUNC()<0) { \ - H5_interface_initialize_g = 0; \ - HGOTO_ERROR (H5E_FUNC, H5E_CANTINIT, err, \ - "interface initialization failed") \ - } \ - } -#else /* H5_INTERFACE_INIT_FUNC */ -#define H5_INTERFACE_INIT(err) -#endif /* H5_INTERFACE_INIT_FUNC */ +/* 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 */ #ifndef NDEBUG -#define FUNC_ENTER_CHECK_NAME(asrt) \ - { \ - static hbool_t func_check = FALSE; \ +#define FUNC_ENTER_CHECK_NAME(asrt) \ + { \ + static hbool_t func_check = FALSE; \ \ - if(!func_check) { \ - /* Check function naming status */ \ - HDassert(asrt); \ + if(!func_check) { \ + /* Check function naming status */ \ + HDassert(asrt); \ \ - /* Don't check again */ \ - func_check = TRUE; \ - } /* end if */ \ + /* Don't check again */ \ + func_check = TRUE; \ + } /* end if */ \ } /* end scope */ #else /* NDEBUG */ #define FUNC_ENTER_CHECK_NAME(asrt) #endif /* NDEBUG */ -#define FUNC_ENTER_COMMON(asrt) \ - hbool_t err_occurred = FALSE; \ +#define FUNC_ENTER_COMMON(asrt) \ + hbool_t err_occurred = FALSE; \ + \ FUNC_ENTER_CHECK_NAME(asrt); -#define FUNC_ENTER_COMMON_NOERR(asrt) \ +#define FUNC_ENTER_COMMON_NOERR(asrt) \ FUNC_ENTER_CHECK_NAME(asrt); /* Threadsafety initialization code for API routines */ #define FUNC_ENTER_API_THREADSAFE \ - /* Initialize the thread-safe code */ \ + /* Initialize the thread-safe code */ \ H5_FIRST_THREAD_INIT \ - \ - /* Grab the mutex for the library */ \ + \ + /* Grab the mutex for the library */ \ H5_API_UNSET_CANCEL \ H5_API_LOCK /* Local variables for API routines */ #define FUNC_ENTER_API_VARS \ - MPE_LOG_VARS \ + MPE_LOG_VARS \ H5TRACE_DECL -#define FUNC_ENTER_API_COMMON \ +#define FUNC_ENTER_API_COMMON \ FUNC_ENTER_API_VARS \ - FUNC_ENTER_COMMON(H5_IS_API(FUNC)); \ + FUNC_ENTER_COMMON(H5_IS_API(FUNC)); \ FUNC_ENTER_API_THREADSAFE; -#define FUNC_ENTER_API_INIT(err) \ - /* Initialize the library */ \ - if(!(H5_INIT_GLOBAL)) { \ - H5_INIT_GLOBAL = TRUE; \ - if(H5_init_library() < 0) \ - HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, err, \ - "library initialization failed") \ - } \ +#define FUNC_ENTER_API_INIT(err) \ + /* Initialize the library */ \ + if(!H5_INIT_GLOBAL && !H5_TERM_GLOBAL) { \ + H5_INIT_GLOBAL = TRUE; \ + if(H5_init_library() < 0) \ + HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, err, "library initialization failed") \ + } /* end if */ \ \ - /* Initialize the interface, if appropriate */ \ - H5_INTERFACE_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 \ + /* Push the name of this function on the function stack */ \ + H5_PUSH_FUNC \ \ - BEGIN_MPE_LOG + BEGIN_MPE_LOG /* Use this macro for all "normal" API functions */ -#define FUNC_ENTER_API(err) {{ \ +#define FUNC_ENTER_API(err) {{ \ FUNC_ENTER_API_COMMON \ - FUNC_ENTER_API_INIT(err); \ - /* Clear thread error stack entering public functions */ \ - H5E_clear_stack(NULL); \ + FUNC_ENTER_API_INIT(err); \ + /* Clear thread error stack entering public functions */ \ + H5E_clear_stack(NULL); \ { /* * Use this macro for API functions that shouldn't clear the error stack * like H5Eprint and H5Ewalk. */ -#define FUNC_ENTER_API_NOCLEAR(err) {{ \ +#define FUNC_ENTER_API_NOCLEAR(err) {{ \ FUNC_ENTER_API_COMMON \ - FUNC_ENTER_API_INIT(err); \ + FUNC_ENTER_API_INIT(err); \ { /* @@ -1991,7 +2014,7 @@ static herr_t H5_INTERFACE_INIT_FUNC(void); * are: H5check_version, etc. * */ -#define FUNC_ENTER_API_NOINIT {{ \ +#define FUNC_ENTER_API_NOINIT {{ \ FUNC_ENTER_API_COMMON \ H5_PUSH_FUNC \ BEGIN_MPE_LOG \ @@ -2004,38 +2027,120 @@ static herr_t H5_INTERFACE_INIT_FUNC(void); * are: H5close, H5check_version, etc. * */ -#define FUNC_ENTER_API_NOINIT_NOERR_NOFS {{ \ +#define FUNC_ENTER_API_NOINIT_NOERR_NOFS {{ \ FUNC_ENTER_API_VARS \ - FUNC_ENTER_COMMON_NOERR(H5_IS_API(FUNC)); \ - FUNC_ENTER_API_THREADSAFE; \ + FUNC_ENTER_COMMON_NOERR(H5_IS_API(FUNC)); \ + FUNC_ENTER_API_THREADSAFE; \ BEGIN_MPE_LOG \ { /* Note: this macro only works when there's _no_ interface initialization routine for the module */ -#define FUNC_ENTER_NOAPI_INIT(err) \ - /* Initialize the interface, if appropriate */ \ - H5_INTERFACE_INIT(err) \ +#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 + /* 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) \ - { +#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) { + +/* 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) { + +/* + * Use this macro for non-API functions which fall into these categories: + * - static functions, since they must be called from a function in the + * interface, the library and interface must already be + * initialized. + * - functions which are called during library shutdown, since we don't + * want to re-initialize the library. + */ +#define FUNC_ENTER_NOAPI_NOINIT { \ + 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: + * - static functions, since they must be called from a function in the + * interface, the library and interface must already be + * initialized. + * - functions which are called during library shutdown, since we don't + * want to re-initialize the library. + * - functions that propagate, but don't issue errors + */ +#define FUNC_ENTER_NOAPI_NOINIT_NOERR { \ + 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: + * - functions which shouldn't push their name on the function stack + * (so far, just the H5CS routines themselves) + * + */ +#define FUNC_ENTER_NOAPI_NOFS { \ + 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: + * - functions which shouldn't push their name on the function stack + * (so far, just the H5CS routines themselves) + * + * This macro is used for functions which fit the above categories _and_ + * also don't use the 'FUNC' variable (i.e. don't push errors on the error stack) + * + */ +#define FUNC_ENTER_NOAPI_NOERR_NOFS { \ + FUNC_ENTER_COMMON_NOERR(!H5_IS_API(FUNC)); \ + if(H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { + +/* Use the following two macros as replacements for the FUNC_ENTER_NOAPI + * and FUNC_ENTER_NOAPI_NOINIT macros when the function needs to set + * up a metadata tag. */ +#define FUNC_ENTER_NOAPI_TAG(dxpl_id, tag, err) { \ + haddr_t prev_tag = HADDR_UNDEF; \ + hid_t tag_dxpl_id = dxpl_id; \ + \ + FUNC_ENTER_COMMON(!H5_IS_API(FUNC)); \ + if(H5AC_tag(tag_dxpl_id, tag, &prev_tag)<0) \ + HGOTO_ERROR(H5_MY_PKG_ERR, H5E_CANTTAG, err, "unable to apply metadata tag") \ + FUNC_ENTER_NOAPI_INIT(err) \ + if(H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { + +#define FUNC_ENTER_NOAPI_NOINIT_TAG(dxpl_id, tag, err) { \ + haddr_t prev_tag = HADDR_UNDEF; \ + hid_t tag_dxpl_id = dxpl_id; \ + \ + FUNC_ENTER_COMMON(!H5_IS_API(FUNC)); \ + if(H5AC_tag(tag_dxpl_id, tag, &prev_tag)<0) \ + HGOTO_ERROR(H5_MY_PKG_ERR, H5E_CANTTAG, err, "unable to apply metadata 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. */ @@ -2045,21 +2150,27 @@ static herr_t H5_INTERFACE_INIT_FUNC(void); \ FUNC_ENTER_COMMON(H5_IS_PKG(FUNC)); \ if(H5AC_tag(tag_dxpl_id, tag, &prev_tag) < 0) \ - HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, err, "unable to apply metadata tag") \ + HGOTO_ERROR(H5_MY_PKG_ERR, H5E_CANTTAG, err, "unable to apply metadata 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 the following macro as replacement for the FUNC_ENTER_STATIC * macro when the function needs to set up a metadata tag. */ @@ -2069,76 +2180,9 @@ static herr_t H5_INTERFACE_INIT_FUNC(void); \ FUNC_ENTER_COMMON(H5_IS_PKG(FUNC)); \ if(H5AC_tag(tag_dxpl_id, tag, &prev_tag) < 0) \ - HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, err, "unable to apply metadata tag") \ + HGOTO_ERROR(H5_MY_PKG_ERR, H5E_CANTTAG, err, "unable to apply metadata tag") \ 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(-) \ - { - -/* - * Use this macro for non-API functions which fall into these categories: - * - static functions, since they must be called from a function in the - * interface, the library and interface must already be - * initialized. - * - functions which are called during library shutdown, since we don't - * want to re-initialize the library. - */ -#define FUNC_ENTER_NOAPI_NOINIT { \ - FUNC_ENTER_COMMON(!H5_IS_API(FUNC)); \ - H5_PUSH_FUNC \ - { - -/* - * Use this macro for non-API functions which fall into these categories: - * - static functions, since they must be called from a function in the - * interface, the library and interface must already be - * initialized. - * - functions which are called during library shutdown, since we don't - * want to re-initialize the library. - * - functions that propagate, but don't issue errors - */ -#define FUNC_ENTER_NOAPI_NOINIT_NOERR { \ - FUNC_ENTER_COMMON_NOERR(!H5_IS_API(FUNC)); \ - H5_PUSH_FUNC \ - { - -/* - * Use this macro for non-API functions which fall into these categories: - * - functions which shouldn't push their name on the function stack - * (so far, just the H5CS routines themselves) - * - * This macro is used for functions which fit the above categories _and_ - * also don't use the 'FUNC' variable (i.e. don't push errors on the error stack) - * - */ -#define FUNC_ENTER_NOAPI_NOERR_NOFS { \ - FUNC_ENTER_COMMON_NOERR(!H5_IS_API(FUNC)); \ - { - -/* Use the following two macros as replacements for the FUNC_ENTER_NOAPI - * and FUNC_ENTER_NOAPI_NOINIT macros when the function needs to set - * up a metadata tag. */ -#define FUNC_ENTER_NOAPI_TAG(dxpl_id, tag, err) { \ - haddr_t prev_tag = HADDR_UNDEF; \ - hid_t tag_dxpl_id = dxpl_id; \ - FUNC_ENTER_COMMON(!H5_IS_API(FUNC)); \ - if(H5AC_tag(tag_dxpl_id, tag, &prev_tag)<0) \ - HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, err, "unable to apply metadata tag") \ - FUNC_ENTER_NOAPI_INIT(err) \ - { - -#define FUNC_ENTER_NOAPI_NOINIT_TAG(dxpl_id, tag, err) { \ - haddr_t prev_tag = HADDR_UNDEF; \ - hid_t tag_dxpl_id = dxpl_id; \ - FUNC_ENTER_COMMON(!H5_IS_API(FUNC)); \ - if(H5AC_tag(tag_dxpl_id, tag, &prev_tag)<0) \ - HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, err, "unable to apply metadata tag") \ - H5_PUSH_FUNC \ - { + if(H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { /*------------------------------------------------------------------------- @@ -2155,35 +2199,39 @@ static herr_t H5_INTERFACE_INIT_FUNC(void); H5_API_SET_CANCEL #define FUNC_LEAVE_API(ret_value) \ - FINISH_MPE_LOG \ - H5TRACE_RETURN(ret_value); \ - H5_POP_FUNC \ - if(err_occurred) \ - (void)H5E_dump_api_stack(TRUE); \ - FUNC_LEAVE_API_THREADSAFE \ - return(ret_value); \ + ; \ } /*end scope from end of FUNC_ENTER*/ \ + FINISH_MPE_LOG \ + H5TRACE_RETURN(ret_value); \ + H5_POP_FUNC \ + if(err_occurred) \ + (void)H5E_dump_api_stack(TRUE); \ + FUNC_LEAVE_API_THREADSAFE \ + return(ret_value); \ }} /*end scope from beginning of FUNC_ENTER*/ /* Use this macro to match the FUNC_ENTER_API_NOFS macro */ #define FUNC_LEAVE_API_NOFS(ret_value) \ - FINISH_MPE_LOG \ - H5TRACE_RETURN(ret_value); \ - FUNC_LEAVE_API_THREADSAFE \ - return(ret_value); \ + ; \ } /*end scope from end of FUNC_ENTER*/ \ + FINISH_MPE_LOG \ + H5TRACE_RETURN(ret_value); \ + FUNC_LEAVE_API_THREADSAFE \ + return(ret_value); \ }} /*end scope from beginning of FUNC_ENTER*/ #define FUNC_LEAVE_NOAPI(ret_value) \ - H5_POP_FUNC \ - return(ret_value); \ + ; \ } /*end scope from end of FUNC_ENTER*/ \ + H5_POP_FUNC \ + return(ret_value); \ } /*end scope from beginning of FUNC_ENTER*/ #define FUNC_LEAVE_NOAPI_VOID \ - H5_POP_FUNC \ - return; \ + ; \ } /*end scope from end of FUNC_ENTER*/ \ + H5_POP_FUNC \ + return; \ } /*end scope from beginning of FUNC_ENTER*/ /* @@ -2192,135 +2240,146 @@ static herr_t H5_INTERFACE_INIT_FUNC(void); * (so far, just the H5CS routines themselves) */ #define FUNC_LEAVE_NOAPI_NOFS(ret_value) \ - return(ret_value); \ + ; \ } /*end scope from end of FUNC_ENTER*/ \ + return(ret_value); \ } /*end scope from beginning of FUNC_ENTER*/ /* Use this macro when exiting a function that set up a metadata tag */ -#define FUNC_LEAVE_NOAPI_TAG(ret_value, err) \ - if(H5AC_tag(tag_dxpl_id, prev_tag, NULL)<0) \ - HDONE_ERROR(H5E_CACHE, H5E_CANTTAG, err, "unable to apply metadata tag") \ - H5_POP_FUNC \ - return(ret_value); \ - } /*end scope from end of FUNC_ENTER*/ \ +#define FUNC_LEAVE_NOAPI_TAG(ret_value, err) \ + ; \ + } /*end scope from end of FUNC_ENTER*/ \ + if(H5AC_tag(tag_dxpl_id, prev_tag, NULL) < 0) \ + HDONE_ERROR(H5E_CACHE, H5E_CANTTAG, err, "unable to apply metadata tag") \ + H5_POP_FUNC \ + return(ret_value); \ } /*end scope from beginning of FUNC_ENTER*/ + /****************************************/ /* Revisions to FUNC_ENTER/LEAVE Macros */ /****************************************/ -/* Macros for referencing package initialization symbols */ -#define H5_PACKAGE_INIT_VAR(x) H5_GLUE3(H5_, x, _init_g) -#define H5_PACKAGE_INIT_FUNC(x) H5_GLUE(x, __pkg_init) - /* Macros to check if a package is initialized */ -#define H5_CHECK_PACKAGE_INIT_REG_YES(asrt) HDassert(H5_PACKAGE_INIT_VAR(pkg)); +#define H5_CHECK_PACKAGE_INIT_REG_YES(asrt) HDassert(H5_PACKAGE_INIT_VAR(pkg)); #define H5_CHECK_PACKAGE_INIT_REG_NO(asrt) #define H5_CHECK_PACKAGE_INIT_INIT_YES(asrt) #define H5_CHECK_PACKAGE_INIT_INIT_NO(asrt) +#define H5_CHECK_PACKAGE_INIT(pkg, pkg_init, init) H5_GLUE4(H5_CHECK_PACKAGE_INIT_, init, _, pkg_init)(pkg) /* Macros to initialize package, if a package initialization routine is defined */ -#define H5_PKG_YES_INIT(pkg) \ - if(!H5_PACKAGE_INIT_VAR(pkg)) { \ - if(H5_GLUE(pkg, _pkg_init)() < 0) { \ - /* (Can't use H5E_THROW here) */ \ - H5E_PRINTF(H5E_CANTINIT, "interface initialization failed"); \ - ret_value = fail_value; \ - goto func_init_failed; \ - } /* end if */ \ +#define H5_PKG_YES_INIT(pkg) \ + if(!H5_PACKAGE_INIT_VAR(pkg) && !H5_TERM_GLOBAL) { \ + H5_PACKAGE_INIT_VAR(pkg) = TRUE; \ + if(H5_PACKAGE_INIT_FUNC(pkg)() < 0) { \ + H5_PACKAGE_INIT_VAR(pkg) = FALSE; \ + /* (Can't use H5E_THROW here) */ \ + H5E_PRINTF(H5E_CANTINIT, "interface initialization failed"); \ + ret_value = fail_value; \ + goto func_init_failed; \ + } /* end if */ \ } /* end if */ -#define H5_PKG_NO_INIT(pkg) - -/* Macros to declare package initialization symbols, if a package initialization routine is defined */ -#define H5_PKG_YES_INIT_VAR(pkg) extern hbool_t H5_PACKAGE_INIT_VAR(H5_MY_PKG); -#define H5_PKG_NO_INIT_VAR(pkg) -#define H5_PKG_YES_INIT_FUNC(pkg) extern herr_t H5_PACKAGE_INIT_FUNC(pkg)(void); -#define H5_PKG_NO_INIT_FUNC(pkg) +#define H5_PKG_NO_INIT(pkg) \ + if(!H5_PACKAGE_INIT_VAR(pkg) && !H5_TERM_GLOBAL) \ + H5_PACKAGE_INIT_VAR(pkg) = TRUE; +#define H5_PKG_INIT(pkg_init, pkg) H5_GLUE3(H5_PKG_, pkg_init, _INIT)(pkg) + +/* Macros to declare package initialization function, if a package initialization routine is defined */ +#ifdef H5_PKG_SINGLE_SOURCE +#define H5_PKG_DECLARE_YES_FUNC(pkg) static herr_t H5_PACKAGE_INIT_FUNC(pkg)(void); +#else /* H5_PKG_SINGLE_SOURCE */ +#define H5_PKG_DECLARE_YES_FUNC(pkg) extern herr_t H5_PACKAGE_INIT_FUNC(pkg)(void); +#endif /* H5_PKG_SINGLE_SOURCE */ +#define H5_PKG_DECLARE_NO_FUNC(pkg) /* Declare package initialization symbols (if in a package) */ -#define H5_DECLARE_PKG_VAR(pkg_init, pkg) H5_GLUE3(H5_PKG_, pkg_init, _INIT_VAR)(pkg) -#define H5_DECLARE_PKG_FUNC(pkg_init, pkg) H5_GLUE3(H5_PKG_, pkg_init, _INIT_FUNC)(pkg) +#ifdef H5_PKG_SINGLE_SOURCE +#define H5_PKG_DECLARE_VAR(pkg) static hbool_t H5_PACKAGE_INIT_VAR(pkg); +#else /* H5_PKG_SINGLE_SOURCE */ +#define H5_PKG_DECLARE_VAR(pkg) extern hbool_t H5_PACKAGE_INIT_VAR(pkg); +#endif /* H5_PKG_SINGLE_SOURCE */ +#define H5_PKG_DECLARE_FUNC(pkg_init, pkg) H5_GLUE3(H5_PKG_DECLARE_, pkg_init, _FUNC)(pkg) #ifdef H5_MY_PKG -H5_DECLARE_PKG_VAR(H5_MY_PKG_INIT, H5_MY_PKG) -H5_DECLARE_PKG_FUNC(H5_MY_PKG_INIT, H5_MY_PKG) +H5_PKG_DECLARE_VAR(H5_MY_PKG) +H5_PKG_DECLARE_FUNC(H5_MY_PKG_INIT, H5_MY_PKG) #endif /* H5_MY_PKG */ /* API re-entrance variable */ extern hbool_t H5_api_entered_g; /* Has library already been entered through API? */ /* Macros for entering different scopes of routines */ -#define H5_PACKAGE_ENTER(pkg, pkg_init, init) \ - FUNC_ENTER_CHECK_NAME(H5_IS_PKG(FUNC)) \ - \ - /* The library should be initialized already */ \ - HDassert(H5_INIT_GLOBAL); \ - \ - /* This interface should be initialized already */ \ - /* (except for package initialization routines :-) */ \ - H5_GLUE4(H5_CHECK_PACKAGE_INIT_, init, _, pkg_init)(pkg) \ - \ - /* Push the name of this function on the function stack */ \ - H5_PUSH_FUNC \ - \ - /* Enter scope for this type of function */ \ +#define H5_PACKAGE_ENTER(pkg, pkg_init, init) \ + FUNC_ENTER_CHECK_NAME(H5_IS_PKG(FUNC)) \ + \ + /* The library should be initialized already */ \ + HDassert(H5_INIT_GLOBAL); \ + \ + /* This interface should be initialized already */ \ + /* (except for package initialization routines :-) */ \ + H5_CHECK_PACKAGE_INIT(pkg, pkg_init, init) \ + \ + /* Push the name of this function on the function stack */ \ + H5_PUSH_FUNC \ + \ + /* Enter scope for this type of function */ \ { -#define H5_PRIVATE_ENTER(pkg, pkg_init) \ - FUNC_ENTER_CHECK_NAME(H5_IS_PRIV(FUNC)) \ - \ - /* The library should be initialized already */ \ - HDassert(H5_INIT_GLOBAL); \ - \ - /* Initialize this interface if desired */ \ - H5_GLUE3(H5_PKG_, pkg_init, _INIT)(pkg) \ - \ - /* Push the name of this function on the function stack */ \ - H5_PUSH_FUNC \ - \ - /* Enter scope for this type of function */ \ +#define H5_PRIVATE_ENTER(pkg, pkg_init) \ + FUNC_ENTER_CHECK_NAME(H5_IS_PRIV(FUNC)) \ + \ + /* The library should be initialized already */ \ + HDassert(H5_INIT_GLOBAL); \ + \ + /* Initialize this interface if desired */ \ + H5_PKG_INIT(pkg_init, pkg) \ + \ + /* Push the name of this function on the function stack */ \ + H5_PUSH_FUNC \ + \ + /* Enter scope for this type of function */ \ {{ -#define H5_PUBLIC_ENTER(pkg, pkg_init) \ - FUNC_ENTER_API_VARS \ - FUNC_ENTER_API_THREADSAFE; \ - FUNC_ENTER_CHECK_NAME(H5_IS_PUB(FUNC)) \ - \ - /* Clear thread error stack when entering public functions */ \ - H5E_clear_stack(NULL); \ - \ - /* Initialize the library or bust */ \ - if(!(H5_INIT_GLOBAL)) { \ - H5_INIT_GLOBAL = TRUE; \ - if(H5_init_library() < 0) { \ - /* (Can't use H5E_THROW here) */ \ - H5E_PRINTF(H5E_CANTINIT, "interface initialization failed"); \ - ret_value = fail_value; \ - goto func_init_failed; \ - } /* end if */ \ - } /* end if */ \ - \ - /* Initialize this interface if desired */ \ - H5_GLUE3(H5_PKG_, pkg_init, _INIT)(pkg) \ - \ - /* Check for re-entering API routine */ \ - HDassert(!H5_api_entered_g); \ - H5_api_entered_g = TRUE; \ - \ - /* Start logging MPI's MPE information */ \ - BEGIN_MPE_LOG \ - \ - /* Push the name of this function on the function stack */ \ - H5_PUSH_FUNC \ - \ - /* Enter scope for this type of function */ \ +#define H5_PUBLIC_ENTER(pkg, pkg_init) \ + FUNC_ENTER_API_VARS \ + FUNC_ENTER_API_THREADSAFE; \ + FUNC_ENTER_CHECK_NAME(H5_IS_PUB(FUNC)) \ + \ + /* Clear thread error stack when entering public functions */ \ + H5E_clear_stack(NULL); \ + \ + /* Initialize the library or bust */ \ + if(!H5_INIT_GLOBAL && !H5_TERM_GLOBAL) { \ + H5_INIT_GLOBAL = TRUE; \ + if(H5_init_library() < 0) { \ + /* (Can't use H5E_THROW here) */ \ + H5E_PRINTF(H5E_CANTINIT, "interface initialization failed"); \ + ret_value = fail_value; \ + goto func_init_failed; \ + } /* end if */ \ + } /* end if */ \ + \ + /* Initialize this interface if desired */ \ + H5_PKG_INIT(pkg_init, pkg) \ + \ + /* Check for re-entering API routine */ \ + HDassert(!H5_api_entered_g); \ + H5_api_entered_g = TRUE; \ + \ + /* Start logging MPI's MPE information */ \ + BEGIN_MPE_LOG \ + \ + /* Push the name of this function on the function stack */ \ + H5_PUSH_FUNC \ + \ + /* Enter scope for this type of function */ \ {{{ /* Macros for substituting the package name */ -#define FUNC_ENT_STATIC H5_PACKAGE_ENTER(H5_MY_PKG, H5_MY_PKG_INIT, REG) -#define FUNC_ENT_PKGINIT H5_PACKAGE_ENTER(H5_MY_PKG, H5_MY_PKG_INIT, INIT) -#define FUNC_ENT_PKG H5_PACKAGE_ENTER(H5_MY_PKG, H5_MY_PKG_INIT, REG) -#define FUNC_ENT_PRIV H5_PRIVATE_ENTER(H5_MY_PKG, H5_MY_PKG_INIT) -#define FUNC_ENT_PUB H5_PUBLIC_ENTER(H5_MY_PKG, H5_MY_PKG_INIT) +#define FUNC_ENT_STATIC(pkg, pkg_init) H5_PACKAGE_ENTER(pkg, pkg_init, REG) +#define FUNC_ENT_PKGINIT(pkg, pkg_init) H5_PACKAGE_ENTER(pkg, pkg_init, INIT) +#define FUNC_ENT_PKG(pkg, pkg_init) H5_PACKAGE_ENTER(pkg, pkg_init, REG) +#define FUNC_ENT_PRIV(pkg, pkg_init) H5_PRIVATE_ENTER(pkg, pkg_init) +#define FUNC_ENT_PUB(pkg, pkg_init) H5_PUBLIC_ENTER(pkg, pkg_init) /* Macros for substituting a function prefix */ #define FUNC_PREFIX_STATIC static @@ -2331,25 +2390,25 @@ extern hbool_t H5_api_entered_g; /* Has library already been entered through /* Macros for declaring error variables */ /* Function can detect errors and has a specific error return value */ -#define FUNC_ERR_VAR_ERR(ret_typ, ret_init, err_value) \ - hbool_t past_catch = FALSE; \ - ret_typ fail_value = err_value; +#define FUNC_ERR_VAR_ERR(ret_typ, err) \ + hbool_t past_catch = FALSE; \ + ret_typ fail_value = err; /* Function can detect errors but cannot return an error value (Cleanup only) */ -#define FUNC_ERR_VAR_ERRCATCH(ret_typ, ret_init, err_value) \ +#define FUNC_ERR_VAR_ERRCATCH(ret_typ, err) \ hbool_t past_catch = FALSE; /* Function has no need to detect or clean up from errors */ -#define FUNC_ERR_VAR_NOERR(ret_typ, ret_init, err_value) - -/* Use this macro when entering functions with a return value */ -#define BEGIN_FUNC(scope, use_err, ret_typ, ret_init, err_value, func) \ -H5_GLUE(FUNC_PREFIX_, scope) \ -ret_typ \ -func \ -/* Open function */ \ -{ \ - ret_typ ret_value = ret_init; \ - H5_GLUE(FUNC_ERR_VAR_, use_err)(ret_typ, ret_init, err_value) \ - H5_GLUE(FUNC_ENT_, scope) +#define FUNC_ERR_VAR_NOERR(ret_typ, err) + +/* Use this macro when entering all functions */ +#define BEGIN_FUNC(scope, use_err, ret_typ, ret_init, err, func) \ +H5_GLUE(FUNC_PREFIX_, scope) \ +ret_typ \ +func \ +/* Open function */ \ +{ \ + ret_typ ret_value = ret_init; \ + H5_GLUE(FUNC_ERR_VAR_, use_err)(ret_typ, err) \ + H5_GLUE(FUNC_ENT_, scope)(H5_MY_PKG, H5_MY_PKG_INIT) /* Use this macro when entering functions that have no return value */ #define BEGIN_FUNC_VOID(scope, use_err, func) \ @@ -2367,73 +2426,73 @@ func \ #define H5_PRIV_FUNC_INIT_FAILED(pkg_init) H5_GLUE3(H5_PRIV_, pkg_init, _FUNC_INIT_FAILED) /* Macros for leaving different scopes of routines */ -#define FUNC_LEAVE_PKGINIT \ - /* Leave scope for this type of function */ \ - } \ - \ - /* Pop the name of this function off the function stack */ \ +#define FUNC_LEAVE_PKGINIT \ + /* Leave scope for this type of function */ \ + } \ + \ + /* Pop the name of this function off the function stack */ \ H5_POP_FUNC -#define FUNC_LEAVE_STATIC \ - /* Leave scope for this type of function */ \ - } \ - \ - /* Pop the name of this function off the function stack */ \ +#define FUNC_LEAVE_STATIC \ + /* Leave scope for this type of function */ \ + } \ + \ + /* Pop the name of this function off the function stack */ \ H5_POP_FUNC -#define FUNC_LEAVE_PKG \ - /* Leave scope for this type of function */ \ - } \ - \ - /* Pop the name of this function off the function stack */ \ +#define FUNC_LEAVE_PKG \ + /* Leave scope for this type of function */ \ + } \ + \ + /* Pop the name of this function off the function stack */ \ H5_POP_FUNC -#define FUNC_LEAVE_PRIV \ - /* Leave scope for this type of function */ \ - }} \ - \ - /* Label for errors during FUNC_ENTER */ \ - H5_PRIV_FUNC_INIT_FAILED(H5_MY_PKG_INIT) \ - \ - /* Pop the name of this function off the function stack */ \ +#define FUNC_LEAVE_PRIV \ + /* Leave scope for this type of function */ \ + }} \ + \ + /* Label for errors during FUNC_ENTER */ \ + H5_PRIV_FUNC_INIT_FAILED(H5_MY_PKG_INIT) \ + \ + /* Pop the name of this function off the function stack */ \ H5_POP_FUNC -#define FUNC_LEAVE_PUB \ - /* Leave scope for this type of function */ \ - }}} \ - \ - /* Label for errors during FUNC_ENTER */ \ -func_init_failed: \ - \ - /* Dump error stack if an error occurred during API routine */ \ - if(ret_value == fail_value) \ - (void)H5E_dump_api_stack(TRUE); \ - \ - /* Finish the API tracing info */ \ - H5TRACE_RETURN(ret_value); \ - \ - /* Pop the name of this function off the function stack */ \ - H5_POP_FUNC \ - \ - /* Finish the MPE tracing info */ \ - FINISH_MPE_LOG \ - \ - /* Check for leaving API routine */ \ - HDassert(H5_api_entered_g); \ - H5_api_entered_g = FALSE; \ - \ - /* Release thread-safety semaphore */ \ +#define FUNC_LEAVE_PUB \ + /* Leave scope for this type of function */ \ + }}} \ + \ + /* Label for errors during FUNC_ENTER */ \ +func_init_failed: \ + \ + /* Dump error stack if an error occurred during API routine */ \ + if(ret_value == fail_value) \ + (void)H5E_dump_api_stack(TRUE); \ + \ + /* Finish the API tracing info */ \ + H5TRACE_RETURN(ret_value); \ + \ + /* Pop the name of this function off the function stack */ \ + H5_POP_FUNC \ + \ + /* Finish the MPE tracing info */ \ + FINISH_MPE_LOG \ + \ + /* Check for leaving API routine */ \ + HDassert(H5_api_entered_g); \ + H5_api_entered_g = FALSE; \ + \ + /* Release thread-safety semaphore */ \ FUNC_LEAVE_API_THREADSAFE -/* Use this macro when leaving all functions with a return value*/ -#define END_FUNC(scope) \ - /* Scope-specific function conclusion */ \ - H5_GLUE(FUNC_LEAVE_, scope) \ - \ - /* Leave routine */ \ - return(ret_value); \ - \ - /* Close Function */ \ +/* Use this macro when leaving all functions */ +#define END_FUNC(scope) \ + /* Scope-specific function conclusion */ \ + H5_GLUE(FUNC_LEAVE_, scope) \ + \ + /* Leave routine */ \ + return(ret_value); \ + \ + /* Close Function */ \ } /* Use this macro when leaving void functions */ @@ -2453,23 +2512,13 @@ func_init_failed: \ haddr_t prv_tag = HADDR_UNDEF; \ hid_t my_dxpl_id = dxpl; \ if(H5AC_tag(my_dxpl_id, tag, &prv_tag) < 0) \ - HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, err, "unable to apply metadata tag") + HGOTO_ERROR(H5_MY_PKG_ERR, H5E_CANTTAG, err, "unable to apply metadata tag") #define H5_END_TAG(err) \ if(H5AC_tag(my_dxpl_id, prv_tag, NULL) <0) \ - HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, err, "unable to apply metadata tag") \ + HGOTO_ERROR(H5_MY_PKG_ERR, H5E_CANTTAG, err, "unable to apply metadata tag") \ } -/* Macro for "stringizing" an integer in the C preprocessor (use H5_TOSTRING) */ -/* (use H5_TOSTRING, H5_STRINGIZE is just part of the implementation) */ -#define H5_STRINGIZE(x) #x -#define H5_TOSTRING(x) H5_STRINGIZE(x) - -/* Macro for "glueing" together items, for re-scanning macros */ -#define H5_GLUE(x,y) x##y -#define H5_GLUE3(x,y,z) x##y##z -#define H5_GLUE4(w,x,y,z) w##x##y##z - /* Compile-time "assert" macro */ #define HDcompile_assert(e) ((void)sizeof(char[ !!(e) ? 1 : -1])) /* Variants that are correct, but generate compile-time warnings in some circumstances: @@ -2482,21 +2531,30 @@ H5_DLL herr_t H5_init_library(void); H5_DLL void H5_term_library(void); /* Functions to terminate interfaces */ -H5_DLL int H5A_term_interface(void); -H5_DLL int H5AC_term_interface(void); -H5_DLL int H5D_term_interface(void); -H5_DLL int H5E_term_interface(void); -H5_DLL int H5F_term_interface(void); -H5_DLL int H5FS_term_interface(void); -H5_DLL int H5G_term_interface(void); -H5_DLL int H5I_term_interface(void); -H5_DLL int H5L_term_interface(void); -H5_DLL int H5P_term_interface(void); -H5_DLL int H5PL_term_interface(void); -H5_DLL int H5R_term_interface(void); -H5_DLL int H5S_term_interface(void); -H5_DLL int H5T_term_interface(void); -H5_DLL int H5Z_term_interface(void); +H5_DLL int H5A_term_package(void); +H5_DLL int H5A_top_term_package(void); +H5_DLL int H5AC_term_package(void); +H5_DLL int H5D_term_package(void); +H5_DLL int H5D_top_term_package(void); +H5_DLL int H5E_term_package(void); +H5_DLL int H5F_term_package(void); +H5_DLL int H5FD_term_package(void); +H5_DLL int H5FL_term_package(void); +H5_DLL int H5FS_term_package(void); +H5_DLL int H5G_term_package(void); +H5_DLL int H5G_top_term_package(void); +H5_DLL int H5I_term_package(void); +H5_DLL int H5L_term_package(void); +H5_DLL int H5P_term_package(void); +H5_DLL int H5PL_term_package(void); +H5_DLL int H5R_term_package(void); +H5_DLL int H5R_top_term_package(void); +H5_DLL int H5S_term_package(void); +H5_DLL int H5S_top_term_package(void); +H5_DLL int H5SL_term_package(void); +H5_DLL int H5T_term_package(void); +H5_DLL int H5T_top_term_package(void); +H5_DLL int H5Z_term_package(void); /* Checksum functions */ H5_DLL uint32_t H5_checksum_fletcher32(const void *data, size_t len); diff --git a/src/H5trace.c b/src/H5trace.c index 49bc2d4..8c7a304 100644 --- a/src/H5trace.c +++ b/src/H5trace.c @@ -27,7 +27,7 @@ /****************/ /* Module Setup */ /****************/ -#define H5I_PACKAGE /*suppress error about including H5Ipkg */ +#define H5I_FRIEND /*suppress error about including H5Ipkg */ /***********/ /* Headers */ diff --git a/src/Makefile.am b/src/Makefile.am index 77c8ee5..dfb63bb 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -110,8 +110,8 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5Topaque.c \ H5Torder.c \ H5Tpad.c H5Tprecis.c H5Tstrpad.c H5Tvisit.c H5Tvlen.c H5TS.c H5VM.c H5WB.c H5Z.c \ - H5Zdeflate.c H5Zfletcher32.c H5Znbit.c H5Zshuffle.c H5Zszip.c \ - H5Zscaleoffset.c H5Ztrans.c + H5Zdeflate.c H5Zfletcher32.c H5Znbit.c H5Zshuffle.c \ + H5Zscaleoffset.c H5Zszip.c H5Ztrans.c # Only compile parallel sources if necessary if BUILD_PARALLEL_CONDITIONAL |