Skip to content

Commit

Permalink
Avoid calling into H5open if the library is already initialized
Browse files Browse the repository at this point in the history
Signed-off-by: Quincey Koziol <[email protected]>
  • Loading branch information
qkoziol committed Oct 3, 2024
1 parent cdb637b commit d76c617
Show file tree
Hide file tree
Showing 22 changed files with 34 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/H5Epublic.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ typedef struct H5E_error2_t {
/* When this header is included from a private header, don't make calls to H5open() */
#undef H5OPEN
#ifndef H5private_H
#define H5OPEN H5open(),
#define H5OPEN ((!H5_libinit_g && !H5_libterm_g) ? H5open() : 0),
#else /* H5private_H */
#define H5OPEN
#endif /* H5private_H */
Expand Down
2 changes: 1 addition & 1 deletion src/H5FDcore.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
/* When this header is included from a private header, don't make calls to H5open() */
#undef H5OPEN
#ifndef H5private_H
#define H5OPEN H5open(),
#define H5OPEN ((!H5_libinit_g && !H5_libterm_g) ? H5open() : 0),
#else /* H5private_H */
#define H5OPEN
#endif /* H5private_H */
Expand Down
2 changes: 1 addition & 1 deletion src/H5FDdirect.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/* When this header is included from a private header, don't make calls to H5open() */
#undef H5OPEN
#ifndef H5private_H
#define H5OPEN H5open(),
#define H5OPEN ((!H5_libinit_g && !H5_libterm_g) ? H5open() : 0),
#else /* H5private_H */
#define H5OPEN
#endif /* H5private_H */
Expand Down
2 changes: 1 addition & 1 deletion src/H5FDfamily.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
/* When this header is included from a private header, don't make calls to H5open() */
#undef H5OPEN
#ifndef H5private_H
#define H5OPEN H5open(),
#define H5OPEN ((!H5_libinit_g && !H5_libterm_g) ? H5open() : 0),
#else /* H5private_H */
#define H5OPEN
#endif /* H5private_H */
Expand Down
2 changes: 1 addition & 1 deletion src/H5FDhdfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/* When this header is included from a private header, don't make calls to H5open() */
#undef H5OPEN
#ifndef H5private_H
#define H5OPEN H5open(),
#define H5OPEN ((!H5_libinit_g && !H5_libterm_g) ? H5open() : 0),
#else /* H5private_H */
#define H5OPEN
#endif /* H5private_H */
Expand Down
2 changes: 1 addition & 1 deletion src/H5FDlog.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
/* When this header is included from a private header, don't make calls to H5open() */
#undef H5OPEN
#ifndef H5private_H
#define H5OPEN H5open(),
#define H5OPEN ((!H5_libinit_g && !H5_libterm_g) ? H5open() : 0),
#else /* H5private_H */
#define H5OPEN
#endif /* H5private_H */
Expand Down
2 changes: 1 addition & 1 deletion src/H5FDmirror.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
/* When this header is included from a private header, don't make calls to H5open() */
#undef H5OPEN
#ifndef H5private_H
#define H5OPEN H5open(),
#define H5OPEN ((!H5_libinit_g && !H5_libterm_g) ? H5open() : 0),
#else /* H5private_H */
#define H5OPEN
#endif /* H5private_H */
Expand Down
2 changes: 1 addition & 1 deletion src/H5FDmpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/* When this header is included from a private header, don't make calls to H5open() */
#undef H5OPEN
#ifndef H5private_H
#define H5OPEN H5open(),
#define H5OPEN ((!H5_libinit_g && !H5_libterm_g) ? H5open() : 0),
#else /* H5private_H */
#define H5OPEN
#endif /* H5private_H */
Expand Down
2 changes: 1 addition & 1 deletion src/H5FDmulti.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
/* When this header is included from a private header, don't make calls to H5open() */
#undef H5OPEN
#ifndef H5private_H
#define H5OPEN H5open(),
#define H5OPEN ((!H5_libinit_g && !H5_libterm_g) ? H5open() : 0),
#else /* H5private_H */
#define H5OPEN
#endif /* H5private_H */
Expand Down
2 changes: 1 addition & 1 deletion src/H5FDonion.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
/* When this header is included from a private header, don't make calls to H5open() */
#undef H5OPEN
#ifndef H5private_H
#define H5OPEN H5open(),
#define H5OPEN ((!H5_libinit_g && !H5_libterm_g) ? H5open() : 0),
#else /* H5private_H */
#define H5OPEN
#endif /* H5private_H */
Expand Down
2 changes: 1 addition & 1 deletion src/H5FDros3.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/* When this header is included from a private header, don't make calls to H5open() */
#undef H5OPEN
#ifndef H5private_H
#define H5OPEN H5open(),
#define H5OPEN ((!H5_libinit_g && !H5_libterm_g) ? H5open() : 0),
#else /* H5private_H */
#define H5OPEN
#endif /* H5private_H */
Expand Down
2 changes: 1 addition & 1 deletion src/H5FDsec2.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
/* When this header is included from a private header, don't make calls to H5open() */
#undef H5OPEN
#ifndef H5private_H
#define H5OPEN H5open(),
#define H5OPEN ((!H5_libinit_g && !H5_libterm_g) ? H5open() : 0),
#else /* H5private_H */
#define H5OPEN
#endif /* H5private_H */
Expand Down
2 changes: 1 addition & 1 deletion src/H5FDsplitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
/* When this header is included from a private header, don't make calls to H5open() */
#undef H5OPEN
#ifndef H5private_H
#define H5OPEN H5open(),
#define H5OPEN ((!H5_libinit_g && !H5_libterm_g) ? H5open() : 0),
#else /* H5private_H */
#define H5OPEN
#endif /* H5private_H */
Expand Down
2 changes: 1 addition & 1 deletion src/H5FDstdio.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
/* When this header is included from a private header, don't make calls to H5open() */
#undef H5OPEN
#ifndef H5private_H
#define H5OPEN H5open(),
#define H5OPEN ((!H5_libinit_g && !H5_libterm_g) ? H5open() : 0),
#else /* H5private_H */
#define H5OPEN
#endif /* H5private_H */
Expand Down
2 changes: 1 addition & 1 deletion src/H5FDsubfiling/H5FDioc.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
/* When this header is included from a private header, don't make calls to H5open() */
#undef H5OPEN
#ifndef H5private_H
#define H5OPEN H5open(),
#define H5OPEN ((!H5_libinit_g && !H5_libterm_g) ? H5open() : 0),
#else /* H5private_H */
#define H5OPEN
#endif /* H5private_H */
Expand Down
2 changes: 1 addition & 1 deletion src/H5FDsubfiling/H5FDsubfiling.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
/* When this header is included from a private header, don't make calls to H5open() */
#undef H5OPEN
#ifndef H5private_H
#define H5OPEN H5open(),
#define H5OPEN ((!H5_libinit_g && !H5_libterm_g) ? H5open() : 0),
#else /* H5private_H */
#define H5OPEN
#endif /* H5private_H */
Expand Down
2 changes: 1 addition & 1 deletion src/H5FDwindows.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/* When this header is included from a private header, don't make calls to H5open() */
#undef H5OPEN
#ifndef H5private_H
#define H5OPEN H5open(),
#define H5OPEN ((!H5_libinit_g && !H5_libterm_g) ? H5open() : 0),
#else /* H5private_H */
#define H5OPEN
#endif /* H5private_H */
Expand Down
8 changes: 8 additions & 0 deletions src/H5Opublic.h
Original file line number Diff line number Diff line change
Expand Up @@ -1681,6 +1681,14 @@ H5_DLL herr_t H5Otoken_from_str(hid_t loc_id, const char *token_str, H5O_token_t
#endif
/// \endcond

/* When this header is included from a private header, don't make calls to H5open() */
#undef H5OPEN
#ifndef H5private_H
#define H5OPEN ((!H5_libinit_g && !H5_libterm_g) ? H5open() : 0),
#else /* H5private_H */
#define H5OPEN
#endif /* H5private_H */

/* The canonical 'undefined' token value */
#define H5O_TOKEN_UNDEF (H5OPEN H5O_TOKEN_UNDEF_g)
H5_DLLVAR const H5O_token_t H5O_TOKEN_UNDEF_g;
Expand Down
2 changes: 1 addition & 1 deletion src/H5Ppublic.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
/* When this header is included from a private HDF5 header, don't make calls to H5open() */
#undef H5OPEN
#ifndef H5private_H
#define H5OPEN H5open(),
#define H5OPEN ((!H5_libinit_g && !H5_libterm_g) ? H5open() : 0),
#else /* H5private_H */
#define H5OPEN
#endif /* H5private_H */
Expand Down
2 changes: 1 addition & 1 deletion src/H5Tpublic.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ typedef H5T_conv_ret_t (*H5T_conv_except_func_t)(H5T_conv_except_t except_type,
/* When this header is included from a private header, don't make calls to H5open() */
#undef H5OPEN
#ifndef H5private_H
#define H5OPEN H5open(),
#define H5OPEN ((!H5_libinit_g && !H5_libterm_g) ? H5open() : 0),
#else /* H5private_H */
#define H5OPEN
#endif /* H5private_H */
Expand Down
4 changes: 0 additions & 4 deletions src/H5private.h
Original file line number Diff line number Diff line change
Expand Up @@ -1207,10 +1207,6 @@ extern char H5_lib_vers_info_g[];

#endif /* H5_HAVE_THREADSAFE */

/* Library init / term status (global) */
extern bool H5_libinit_g; /* Has the library been initialized? */
extern bool H5_libterm_g; /* Is the library being shutdown? */

/* Macros for accessing the global variables */
#define H5_INIT_GLOBAL (H5_libinit_g)
#define H5_TERM_GLOBAL (H5_libterm_g)
Expand Down
7 changes: 7 additions & 0 deletions src/H5public.h
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,13 @@ typedef void (*H5_atclose_func_t)(void *ctx);
extern "C" {
#endif

/** @private
*
* \brief Library init / term status (global)
*/
H5_DLLVAR bool H5_libinit_g; /* Has the library been initialized? */
H5_DLLVAR bool H5_libterm_g; /* Is the library being shutdown? */

/* Functions in H5.c */
/**
* \ingroup H5
Expand Down

0 comments on commit d76c617

Please sign in to comment.