diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2012-02-10 19:48:08 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2012-02-10 19:48:08 (GMT) |
commit | 5f94d17285913b2497d169cadfb639f300773407 (patch) | |
tree | f4a96b86d8ac5d13411ca897e1377fb2f1808cb3 /src/H5private.h | |
parent | f16098f402139aa4e258542661c3003389803de9 (diff) | |
download | hdf5-5f94d17285913b2497d169cadfb639f300773407.zip hdf5-5f94d17285913b2497d169cadfb639f300773407.tar.gz hdf5-5f94d17285913b2497d169cadfb639f300773407.tar.bz2 |
[svn-r21925] Description:
Bring r21919-21924 from trunk to 1.8 branch: cleanup FUNC_ENTER macros,
etc.
Also removed Subversion mergeinfo tags from a few directories and files.
These are artifacts from non-root merges using pre-1.6 Subversion clients. (This
should fix the problem of unchanged directories looking "changed" during
checkins.)
Tested on:
Mac OSX/64 10.7.3 (amazon) w/debug & production
(daily tested on trunk)
Diffstat (limited to 'src/H5private.h')
-rw-r--r-- | src/H5private.h | 239 |
1 files changed, 122 insertions, 117 deletions
diff --git a/src/H5private.h b/src/H5private.h index 7129f72..24a8394 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -193,11 +193,10 @@ */ #define eventa(func_name) h5_mpe_eventa #define eventb(func_name) h5_mpe_eventb -#define MPE_LOG_VARS(func_name) \ - static int eventa(func_name) = -1; \ - static int eventb(func_name) = -1; \ - const char* p_end_funcname = #func_name; \ - const char* p_event_start = "start" #func_name; +#define MPE_LOG_VARS \ + static int eventa(FUNC) = -1; \ + static int eventb(FUNC) = -1; \ + const char* p_event_start = "start" FUNC; /* Hardwire the color to "red", since that's what all the routines are using * now. In the future, if we want to change that color for a given routine, @@ -206,15 +205,15 @@ * color information down to the BEGIN_MPE_LOG macro (which should have a new * BEGIN_MPE_LOG_COLOR variant). -QAK */ -#define BEGIN_MPE_LOG(func_name) \ +#define BEGIN_MPE_LOG \ if (H5_MPEinit_g){ \ - if (eventa(func_name) == -1 && eventb(func_name) == -1) { \ + if (eventa(FUNC) == -1 && eventb(FUNC) == -1) { \ const char* p_color = "red"; \ - eventa(func_name)=MPE_Log_get_event_number(); \ - eventb(func_name)=MPE_Log_get_event_number(); \ - MPE_Describe_state(eventa(func_name), eventb(func_name), (char *)p_end_funcname, (char *)p_color); \ + eventa(FUNC)=MPE_Log_get_event_number(); \ + eventb(FUNC)=MPE_Log_get_event_number(); \ + MPE_Describe_state(eventa(FUNC), eventb(FUNC), (char *)FUNC, (char *)p_color); \ } \ - MPE_Log_event(eventa(func_name), 0, (char *)p_event_start); \ + MPE_Log_event(eventa(FUNC), 0, (char *)p_event_start); \ } @@ -226,12 +225,12 @@ */ #define FINISH_MPE_LOG \ if (H5_MPEinit_g) { \ - MPE_Log_event(eventb(func_name), 0, (char *)p_end_funcname); \ + MPE_Log_event(eventb(FUNC), 0, (char *)FUNC); \ } #else /* H5_HAVE_MPE */ -#define MPE_LOG_VARS(func_name) /* void */ -#define BEGIN_MPE_LOG(func_name) /* void */ +#define MPE_LOG_VARS /* void */ +#define BEGIN_MPE_LOG /* void */ #define FINISH_MPE_LOG /* void */ #endif /* H5_HAVE_MPE */ @@ -271,15 +270,6 @@ #endif /* __cplusplus */ /* - * Does the compiler expand __FUNCTION__ to be the name of the function - * currently being defined? If not then define it to be some constant - * string. - */ -#ifndef H5_HAVE_FUNCTION -# define __FUNCTION__ "NoFunctionName" -#endif - -/* * Status return values for the `herr_t' type. * Since some unix/c routines use 0 and -1 (or more precisely, non-negative * vs. negative) as their return code, and some assumption had been made in @@ -1498,6 +1488,15 @@ extern char *strdup(const char *s); #define COLON_SEPC ':' +/* Use FUNC to safely handle variations of C99 __func__ keyword handling */ +#ifdef H5_HAVE_C99_FUNC +#define FUNC __func__ +#elif defined(H5_HAVE_FUNCTION) +#define FUNC __FUNCTION__ +#else +#error "We need __func__ or __FUNCTION__ to test function names!" +#endif + /* * These macros check whether debugging has been requested for a certain * package at run-time. Code for debugging is conditionally compiled by @@ -1643,8 +1642,6 @@ H5_DLL double H5_trace(const double *calltime, const char *func, const char *typ * * Programmer: Quincey Koziol * - * Modifications: - * *------------------------------------------------------------------------- */ @@ -1652,6 +1649,24 @@ H5_DLL double H5_trace(const double *calltime, const char *func, const char *typ /* an API function */ #define H5_IS_API(S) ('_'!=((const char *)S)[2] && '_'!=((const char *)S)[3] && (!((const char *)S)[4] || '_'!=((const char *)S)[4])) +/* `S' is the name of a function which is being tested to check if it's */ +/* a public API function */ +#define H5_IS_PUB(S) (((HDisdigit(S[1]) || HDisupper(S[1])) && HDislower(S[2])) || \ + ((HDisdigit(S[2]) || HDisupper(S[2])) && HDislower(S[3])) || \ + (!S[4] || ((HDisdigit(S[3]) || HDisupper(S[3])) && HDislower(S[4])))) + +/* `S' is the name of a function which is being tested to check if it's */ +/* a private library function */ +#define H5_IS_PRIV(S) (((HDisdigit(S[1]) || HDisupper(S[1])) && '_' == S[2] && HDislower(S[3])) || \ + ((HDisdigit(S[2]) || HDisupper(S[2])) && '_' == S[3] && HDislower(S[4])) || \ + ((HDisdigit(S[3]) || HDisupper(S[3])) && '_' == S[4] && HDislower(S[5]))) + +/* `S' is the name of a function which is being tested to check if it's */ +/* a package private function */ +#define H5_IS_PKG(S) (((HDisdigit(S[1]) || HDisupper(S[1])) && '_' == S[2] && '_' == S[3] && HDislower(S[4])) || \ + ((HDisdigit(S[2]) || HDisupper(S[2])) && '_' == S[3] && '_' == S[4] && HDislower(S[5])) || \ + ((HDisdigit(S[3]) || HDisupper(S[3])) && '_' == S[4] && '_' == S[5] && HDislower(S[6]))) + /* global library version information string */ extern char H5_lib_vers_info_g[]; @@ -1718,10 +1733,10 @@ extern hbool_t H5_libinit_g; /* Has the library been initialized? */ /* Include required function stack header */ #include "H5CSprivate.h" -#define H5_PUSH_FUNC(func_name) H5CS_push(#func_name); +#define H5_PUSH_FUNC H5CS_push(FUNC); #define H5_POP_FUNC H5CS_pop(); #else /* H5_HAVE_CODESTACK */ -#define H5_PUSH_FUNC(func_name) /* void */ +#define H5_PUSH_FUNC /* void */ #define H5_POP_FUNC /* void */ #endif /* H5_HAVE_CODESTACK */ @@ -1729,15 +1744,6 @@ extern hbool_t H5_libinit_g; /* Has the library been initialized? */ extern hbool_t H5_MPEinit_g; /* Has the MPE Library been initialized? */ #endif -/* Check if the function name is correct (if the compiler supports __FUNCTION__) */ -#ifdef H5_HAVE_FUNCTION -#define H5_CHECK_FUNCNAME(func_name) \ - assert(!HDstrcmp(#func_name, __FUNCTION__)) -#else /* H5_HAVE_FUNCTION */ -#define H5_CHECK_FUNCNAME(func_name) \ - assert(func_name) -#endif /* H5_HAVE_FUNCTION */ - /* Macros for defining interface initialization routines */ #ifdef H5_INTERFACE_INIT_FUNC static int H5_interface_initialize_g = 0; @@ -1758,31 +1764,29 @@ static herr_t H5_INTERFACE_INIT_FUNC(void); #ifndef NDEBUG -#define FUNC_ENTER_COMMON_NOFUNC(func_name,asrt) \ - static hbool_t func_check = FALSE; \ - \ - if(!func_check) { \ - /* Check API status */ \ - HDassert(asrt); \ - \ - /* Check function name */ \ - H5_CHECK_FUNCNAME(func_name); \ - \ - /* Don't check again */ \ - func_check = TRUE; \ - } /* end if */ +#define FUNC_ENTER_CHECK_NAME(asrt) \ + { \ + static hbool_t func_check = FALSE; \ + \ + if(!func_check) { \ + /* Check function naming status */ \ + HDassert(asrt); \ + \ + /* Don't check again */ \ + func_check = TRUE; \ + } /* end if */ \ + } /* end scope */ #else /* NDEBUG */ -#define FUNC_ENTER_COMMON_NOFUNC(func_name,asrt) +#define FUNC_ENTER_CHECK_NAME(asrt) #endif /* NDEBUG */ -#define FUNC_ENTER_COMMON(func_name, asrt) \ - static const char FUNC[] = #func_name; \ + +#define FUNC_ENTER_COMMON(asrt) \ hbool_t err_occurred = FALSE; \ - FUNC_ENTER_COMMON_NOFUNC(func_name, asrt); + FUNC_ENTER_CHECK_NAME(asrt); -#define FUNC_ENTER_COMMON_NOERR(func_name, asrt) \ - static const char FUNC[] = #func_name; \ - FUNC_ENTER_COMMON_NOFUNC(func_name, asrt); +#define FUNC_ENTER_COMMON_NOERR(asrt) \ + FUNC_ENTER_CHECK_NAME(asrt); /* Threadsafety initialization code for API routines */ #define FUNC_ENTER_API_THREADSAFE \ @@ -1794,16 +1798,16 @@ static herr_t H5_INTERFACE_INIT_FUNC(void); H5_API_LOCK /* Local variables for API routines */ -#define FUNC_ENTER_API_VARS(func_name) \ - MPE_LOG_VARS(func_name) \ +#define FUNC_ENTER_API_VARS \ + MPE_LOG_VARS \ H5TRACE_DECL -#define FUNC_ENTER_API_COMMON(func_name) \ - FUNC_ENTER_API_VARS(func_name) \ - FUNC_ENTER_COMMON(func_name, H5_IS_API(#func_name)); \ +#define FUNC_ENTER_API_COMMON \ + FUNC_ENTER_API_VARS \ + FUNC_ENTER_COMMON(H5_IS_API(FUNC)); \ FUNC_ENTER_API_THREADSAFE; -#define FUNC_ENTER_API_INIT(func_name,err) \ +#define FUNC_ENTER_API_INIT(err) \ /* Initialize the library */ \ if(!(H5_INIT_GLOBAL)) { \ H5_INIT_GLOBAL = TRUE; \ @@ -1816,14 +1820,14 @@ static herr_t H5_INTERFACE_INIT_FUNC(void); H5_INTERFACE_INIT(err) \ \ /* Push the name of this function on the function stack */ \ - H5_PUSH_FUNC(#func_name) \ + H5_PUSH_FUNC \ \ - BEGIN_MPE_LOG(func_name) + BEGIN_MPE_LOG /* Use this macro for all "normal" API functions */ -#define FUNC_ENTER_API(func_name,err) {{ \ - FUNC_ENTER_API_COMMON(func_name) \ - FUNC_ENTER_API_INIT(func_name,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); \ { @@ -1832,9 +1836,9 @@ static herr_t H5_INTERFACE_INIT_FUNC(void); * Use this macro for API functions that shouldn't clear the error stack * like H5Eprint and H5Ewalk. */ -#define FUNC_ENTER_API_NOCLEAR(func_name,err) {{ \ - FUNC_ENTER_API_COMMON(func_name) \ - FUNC_ENTER_API_INIT(func_name,err); \ +#define FUNC_ENTER_API_NOCLEAR(err) {{ \ + FUNC_ENTER_API_COMMON \ + FUNC_ENTER_API_INIT(err); \ { /* @@ -1843,10 +1847,10 @@ static herr_t H5_INTERFACE_INIT_FUNC(void); * are: H5check_version, etc. * */ -#define FUNC_ENTER_API_NOINIT(func_name) {{ \ - FUNC_ENTER_API_COMMON(func_name) \ - H5_PUSH_FUNC(func_name) \ - BEGIN_MPE_LOG(func_name); \ +#define FUNC_ENTER_API_NOINIT {{ \ + FUNC_ENTER_API_COMMON \ + H5_PUSH_FUNC \ + BEGIN_MPE_LOG \ { /* @@ -1856,50 +1860,55 @@ static herr_t H5_INTERFACE_INIT_FUNC(void); * are: H5close, H5check_version, etc. * */ -#define FUNC_ENTER_API_NOINIT_NOERR_NOFS(func_name) {{ \ - FUNC_ENTER_API_VARS(func_name) \ - FUNC_ENTER_COMMON_NOERR(func_name, H5_IS_API(#func_name)); \ +#define FUNC_ENTER_API_NOINIT_NOERR_NOFS {{ \ + FUNC_ENTER_API_VARS \ + FUNC_ENTER_COMMON_NOERR(H5_IS_API(FUNC)); \ FUNC_ENTER_API_THREADSAFE; \ - BEGIN_MPE_LOG(func_name); \ + BEGIN_MPE_LOG \ { /* Note: this macro only works when there's _no_ interface initialization routine for the module */ -#define FUNC_ENTER_NOAPI_INIT(func_name,err) \ +#define FUNC_ENTER_NOAPI_INIT(err) \ /* Initialize the interface, if appropriate */ \ H5_INTERFACE_INIT(err) \ \ /* Push the name of this function on the function stack */ \ - H5_PUSH_FUNC(#func_name) + H5_PUSH_FUNC /* Use this macro for all "normal" non-API functions */ -#define FUNC_ENTER_NOAPI(func_name,err) { \ - FUNC_ENTER_COMMON(func_name, !H5_IS_API(#func_name)); \ - FUNC_ENTER_NOAPI_INIT(func_name,err) \ +#define FUNC_ENTER_NOAPI(err) { \ + FUNC_ENTER_COMMON(!H5_IS_API(FUNC)); \ + FUNC_ENTER_NOAPI_INIT(err) \ { -/* Use this macro for all non-API functions, which propagate errors, but don't issue them */ -#define FUNC_ENTER_NOAPI_NOERR(func_name,err) { \ - FUNC_ENTER_COMMON_NOERR(func_name, !H5_IS_API(#func_name)); \ - FUNC_ENTER_NOAPI_INIT(func_name,err) \ +/* Use this macro for all "normal" package-level functions */ +#define FUNC_ENTER_PACKAGE { \ + FUNC_ENTER_COMMON(H5_IS_PKG(FUNC)); \ + H5_PUSH_FUNC \ { -/* Use this macro for all non-API functions which don't issue errors */ -#define FUNC_ENTER_NOAPI_NOFUNC(func_name) { \ - FUNC_ENTER_COMMON_NOFUNC(func_name,!H5_IS_API(#func_name)); \ - FUNC_ENTER_NOAPI_INIT(func_name,err) \ +/* 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 \ { -/* - * 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_name) { \ - FUNC_ENTER_COMMON(func_name, !H5_IS_API(#func_name)); \ - H5_PUSH_FUNC(func_name) \ +/* Use the following macro as replacement for the FUNC_ENTER_PACKAGE + * macro when the function needs to set up a metadata tag. */ +#define FUNC_ENTER_PACKAGE_TAG(dxpl_id, tag, err) { \ + haddr_t prev_tag = HADDR_UNDEF; \ + hid_t tag_dxpl_id = dxpl_id; \ + \ + 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") \ + 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(-) \ { /* @@ -1909,11 +1918,10 @@ static herr_t H5_INTERFACE_INIT_FUNC(void); * 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_name) { \ - FUNC_ENTER_COMMON_NOERR(func_name, !H5_IS_API(#func_name)); \ - H5_PUSH_FUNC(#func_name) \ +#define FUNC_ENTER_NOAPI_NOINIT { \ + FUNC_ENTER_COMMON(!H5_IS_API(FUNC)); \ + H5_PUSH_FUNC \ { /* @@ -1923,14 +1931,11 @@ static herr_t H5_INTERFACE_INIT_FUNC(void); * initialized. * - functions which are called during library shutdown, since we don't * want to re-initialize the library. - * - * 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) - * + * - functions that propagate, but don't issue errors */ -#define FUNC_ENTER_NOAPI_NOINIT_NOFUNC(func_name) { \ - FUNC_ENTER_COMMON_NOFUNC(func_name,!H5_IS_API(#func_name)); \ - H5_PUSH_FUNC(func_name) \ +#define FUNC_ENTER_NOAPI_NOINIT_NOERR { \ + FUNC_ENTER_COMMON_NOERR(!H5_IS_API(FUNC)); \ + H5_PUSH_FUNC \ { /* @@ -1942,8 +1947,8 @@ static herr_t H5_INTERFACE_INIT_FUNC(void); * also don't use the 'FUNC' variable (i.e. don't push errors on the error stack) * */ -#define FUNC_ENTER_NOAPI_NOFUNC_NOFS(func_name) { \ - FUNC_ENTER_COMMON_NOFUNC(func_name,!H5_IS_API(#func_name)); \ +#define FUNC_ENTER_NOAPI_NOERR_NOFS { \ + FUNC_ENTER_COMMON_NOERR(!H5_IS_API(FUNC)); \ { /*------------------------------------------------------------------------- @@ -1960,7 +1965,7 @@ static herr_t H5_INTERFACE_INIT_FUNC(void); H5_API_SET_CANCEL #define FUNC_LEAVE_API(ret_value) \ - FINISH_MPE_LOG; \ + FINISH_MPE_LOG \ H5TRACE_RETURN(ret_value); \ H5_POP_FUNC \ if(err_occurred) \ @@ -1972,7 +1977,7 @@ static herr_t H5_INTERFACE_INIT_FUNC(void); /* Use this macro to match the FUNC_ENTER_API_NOFS macro */ #define FUNC_LEAVE_API_NOFS(ret_value) \ - FINISH_MPE_LOG; \ + FINISH_MPE_LOG \ H5TRACE_RETURN(ret_value); \ FUNC_LEAVE_API_THREADSAFE \ return(ret_value); \ |