diff options
author | Dana Robinson <derobins@hdfgroup.org> | 2015-09-01 07:12:41 (GMT) |
---|---|---|
committer | Dana Robinson <derobins@hdfgroup.org> | 2015-09-01 07:12:41 (GMT) |
commit | 96360ad86e25159be8ef0647f77f5618012b99e5 (patch) | |
tree | 47d7a383e8b8331312c9f8a436795805633a88be /src | |
parent | 49ef02b3a11f4757beecf1f4008ec47bd6006f52 (diff) | |
download | hdf5-96360ad86e25159be8ef0647f77f5618012b99e5.zip hdf5-96360ad86e25159be8ef0647f77f5618012b99e5.tar.gz hdf5-96360ad86e25159be8ef0647f77f5618012b99e5.tar.bz2 |
[svn-r27643] Merge of r27581, 27587, and 27601 from trunk
Added a new public API call: H5is_library_threadsafe
This API call can determine, at runtime, if the library was built with
thread-safety enabled.
Also fixes a minor bug in the FUNC_ENTER macros.
Tested on: h5committest
jam w/ threadsafe
Diffstat (limited to 'src')
-rw-r--r-- | src/H5.c | 47 | ||||
-rw-r--r-- | src/H5private.h | 21 | ||||
-rw-r--r-- | src/H5public.h | 4 |
3 files changed, 59 insertions, 13 deletions
@@ -21,17 +21,16 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5Lprivate.h" /* Links */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5Lprivate.h" /* Links */ #include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5Tprivate.h" /* Datatypes */ +#include "H5Pprivate.h" /* Property lists */ #include "H5SLprivate.h" /* Skip lists */ - +#include "H5Tprivate.h" /* Datatypes */ /****************/ /* Local Macros */ @@ -971,6 +970,36 @@ H5free_memory(void *mem) } /* end H5free_memory() */ +/*------------------------------------------------------------------------- + * Function: H5is_library_threadsafe + * + * Purpose: Checks to see if the library was built with thread-safety + * enabled. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5is_library_threadsafe(hbool_t *is_ts) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API_NOINIT + H5TRACE1("e", "*b", is_ts); + + HDassert(is_ts); + +#ifdef H5_HAVE_THREADSAFE + *is_ts = TRUE; +#else /* H5_HAVE_THREADSAFE */ + *is_ts = FALSE; +#endif /* H5_HAVE_THREADSAFE */ + + FUNC_LEAVE_API(ret_value) +} /* end H5is_library_threadsafe() */ + + #if defined(H5_HAVE_THREADSAFE) && defined(H5_BUILT_AS_DYNAMIC_LIB) \ && defined(H5_HAVE_WIN32_API) && defined(H5_HAVE_WIN_THREADS) /*------------------------------------------------------------------------- diff --git a/src/H5private.h b/src/H5private.h index 6534f6f..15bb61c 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -1741,9 +1741,24 @@ H5_DLL double H5_trace(const double *calltime, const char *func, const char *typ *------------------------------------------------------------------------- */ -/* `S' is the name of a function which is being tested to check if its */ -/* 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 + * an API function. + * + * BADNESS: + * - Underscore at positions 2 or 3 (0-indexed string). Handles + * H5_ and H5X_. + * - Underscore at position 4 if position 3 is uppercase or a digit. + * Handles H5XY_. + */ +#define H5_IS_API(S) (\ + '_'!=((const char *)S)[2] /* underscore at position 2 */ \ + && '_'!=((const char *)S)[3] /* underscore at position 3 */ \ + && !( /* NOT */ \ + ((const char *)S)[4] /* pos 4 exists */ \ + && (HDisupper(S[3]) || HDisdigit(S[3])) /* pos 3 dig | uc */ \ + && '_'==((const char *)S)[4] /* pos 4 underscore */ \ + )\ +) /* `S' is the name of a function which is being tested to check if it's */ /* a public API function */ diff --git a/src/H5public.h b/src/H5public.h index b1b87e2..81953c2 100644 --- a/src/H5public.h +++ b/src/H5public.h @@ -331,6 +331,7 @@ H5_DLL herr_t H5get_libversion(unsigned *majnum, unsigned *minnum, unsigned *relnum); H5_DLL herr_t H5check_version(unsigned majnum, unsigned minnum, unsigned relnum); +H5_DLL herr_t H5is_library_threadsafe(hbool_t *is_ts); H5_DLL herr_t H5free_memory(void *mem); H5_DLL void *H5allocate_memory(size_t size, hbool_t clear); H5_DLL void *H5resize_memory(void *mem, size_t size); @@ -338,5 +339,6 @@ H5_DLL void *H5resize_memory(void *mem, size_t size); #ifdef __cplusplus } #endif -#endif +#endif /* _H5public_H */ + |