Skip to content

Commit

Permalink
Committing clang-format changes
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Jul 6, 2024
1 parent d15663e commit dd1cc71
Show file tree
Hide file tree
Showing 8 changed files with 332 additions and 335 deletions.
354 changes: 179 additions & 175 deletions src/H5FL.c

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions src/H5FLprivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ typedef struct H5FL_reg_node_t {

/* Data structure for free list of blocks */
typedef struct H5FL_reg_head_t {
H5TS_dclp_t dlcp_info; /* Information for init */
/* (MUST be first field in structure) */
H5TS_dclp_t dlcp_info; /* Information for init */
/* (MUST be first field in structure) */
#ifdef H5_HAVE_CONCURRENCY
H5TS_dlftt_mutex_t mutex; /* Guard access to this free list */
#endif /* H5_HAVE_CONCURRENCY */
H5TS_dlftt_mutex_t mutex; /* Guard access to this free list */
#endif /* H5_HAVE_CONCURRENCY */
unsigned allocated; /* Number of blocks allocated */
unsigned onlist; /* Number of blocks on free list */
const char *name; /* Name of the type */
Expand Down Expand Up @@ -122,11 +122,11 @@ typedef struct H5FL_blk_node_t {

/* Data structure for priority queue of native block free lists */
typedef struct H5FL_blk_head_t {
H5TS_dclp_t dlcp_info; /* Information for init */
/* (MUST be first field in structure) */
H5TS_dclp_t dlcp_info; /* Information for init */
/* (MUST be first field in structure) */
#ifdef H5_HAVE_CONCURRENCY
H5TS_dlftt_mutex_t mutex; /* Guard access to this free list */
#endif /* H5_HAVE_CONCURRENCY */
H5TS_dlftt_mutex_t mutex; /* Guard access to this free list */
#endif /* H5_HAVE_CONCURRENCY */
unsigned allocated; /* Total number of blocks allocated */
unsigned onlist; /* Total number of blocks on free list */
size_t list_mem; /* Total amount of memory in blocks on free list */
Expand Down Expand Up @@ -199,11 +199,11 @@ typedef struct H5FL_arr_node_t {

/* Data structure for free list of array blocks */
typedef struct H5FL_arr_head_t {
H5TS_dclp_t dlcp_info; /* Information for init */
/* (MUST be first field in structure) */
H5TS_dclp_t dlcp_info; /* Information for init */
/* (MUST be first field in structure) */
#ifdef H5_HAVE_CONCURRENCY
H5TS_dlftt_mutex_t mutex; /* Guard access to this free list */
#endif /* H5_HAVE_CONCURRENCY */
H5TS_dlftt_mutex_t mutex; /* Guard access to this free list */
#endif /* H5_HAVE_CONCURRENCY */
unsigned allocated; /* Total number of blocks allocated */
size_t list_mem; /* Amount of memory in block on free list */
const char *name; /* Name of the type */
Expand All @@ -220,7 +220,8 @@ typedef struct H5FL_arr_head_t {
#ifndef H5_NO_ARR_FREE_LISTS
/* Common macro for H5FL_ARR_DEFINE & H5FL_ARR_DEFINE_STATIC (and H5FL_BARR variants) */
#define H5FL_ARR_DEFINE_COMMON(b, t, m) \
H5FL_arr_head_t H5FL_ARR_NAME(t) = {.name = #t "_arr", .maxelem = m + 1, .base_size = b, .elem_size = sizeof(t)}
H5FL_arr_head_t H5FL_ARR_NAME(t) = { \
.name = #t "_arr", .maxelem = m + 1, .base_size = b, .elem_size = sizeof(t)}

/* Declare a free list to manage arrays of type 't' */
#define H5FL_ARR_DEFINE(t, m) H5_DLL H5FL_ARR_DEFINE_COMMON(0, t, m)
Expand Down Expand Up @@ -279,8 +280,7 @@ typedef struct H5FL_seq_head_t {
#define H5FL_SEQ_NAME(t) H5_##t##_seq_free_list
#ifndef H5_NO_SEQ_FREE_LISTS
/* Common macro for H5FL_SEQ_DEFINE & H5FL_SEQ_DEFINE_STATIC */
#define H5FL_SEQ_DEFINE_COMMON(t) \
H5FL_seq_head_t H5FL_SEQ_NAME(t) = {{.name = #t "_seq"}, .size = sizeof(t)}
#define H5FL_SEQ_DEFINE_COMMON(t) H5FL_seq_head_t H5FL_SEQ_NAME(t) = {{.name = #t "_seq"}, .size = sizeof(t)}

/* Declare a free list to manage sequences of type 't' */
#define H5FL_SEQ_DEFINE(t) H5_DLL H5FL_SEQ_DEFINE_COMMON(t)
Expand Down Expand Up @@ -317,7 +317,7 @@ typedef struct H5FL_seq_head_t {
#endif /* H5_NO_SEQ_FREE_LISTS */

/* Forward declarations of the data structures for free list block factory */
typedef struct H5FL_fac_head_t H5FL_fac_head_t;
typedef struct H5FL_fac_head_t H5FL_fac_head_t;

/*
* Macros for defining & using free list factories
Expand Down
1 change: 0 additions & 1 deletion src/H5TSdlftt_mutex.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,3 @@ H5TS_dlftt_mutex_destroy(H5TS_dlftt_mutex_t *mutex)
} /* end H5TS_dlftt_mutex_destroy() */

#endif /* H5_HAVE_THREADS */

2 changes: 0 additions & 2 deletions src/H5TSdlftt_mutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,3 @@ H5TS_dlftt_mutex_release(H5TS_dlftt_mutex_t *mtx)

return SUCCEED;
} /* end H5TS_dlftt_mutex_release() */


2 changes: 1 addition & 1 deletion src/H5TSint.c
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ H5TS__tinfo_init(void)
ret_value = FAIL;
#endif /* H5_HAVE_CONCURRENCY */

/* Initialize key for thread-specific API contexts */
/* Initialize key for thread-specific API contexts */
#ifdef H5_HAVE_WIN_THREADS
if (H5_UNLIKELY(H5TS_key_create(&H5TS_thrd_info_key_g, NULL) < 0))
ret_value = FAIL;
Expand Down
8 changes: 4 additions & 4 deletions src/H5TSkey.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
/*******************/

#ifdef H5_HAVE_C11_THREADS
#define H5TS_key_set_value(key,value) (H5_UNLIKELY(tss_set((key), (value)) != thrd_success) ? FAIL : SUCCEED)
#define H5TS_key_get_value(key,value) (*(value) = tss_get(key), SUCCEED)
#define H5TS_key_set_value(key, value) (H5_UNLIKELY(tss_set((key), (value)) != thrd_success) ? FAIL : SUCCEED)
#define H5TS_key_get_value(key, value) (*(value) = tss_get(key), SUCCEED)

#else
#ifdef H5_HAVE_WIN_THREADS
Expand Down Expand Up @@ -100,8 +100,8 @@ H5TS_key_get_value(H5TS_key_t key, void **value)

#else

#define H5TS_key_set_value(key,value) (H5_UNLIKELY(pthread_setspecific((key), (value))) ? FAIL : SUCCEED)
#define H5TS_key_get_value(key,value) (*(value) = pthread_getspecific(key), SUCCEED)
#define H5TS_key_set_value(key, value) (H5_UNLIKELY(pthread_setspecific((key), (value))) ? FAIL : SUCCEED)
#define H5TS_key_get_value(key, value) (*(value) = pthread_getspecific(key), SUCCEED)

#endif
#endif
75 changes: 37 additions & 38 deletions src/H5TSprivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ typedef void (*H5TS_once_init_func_t)(void);

/* Atomics */
#if defined(H5_HAVE_STDATOMIC_H) && !defined(__cplusplus)
typedef atomic_int H5TS_atomic_int_t;
typedef atomic_uint H5TS_atomic_uint_t;
typedef atomic_int H5TS_atomic_int_t;
typedef atomic_uint H5TS_atomic_uint_t;
typedef atomic_size_t H5TS_atomic_size_t;
/* Suppress warning about _Atomic keyword not supported in C99 */
H5_GCC_DIAG_OFF("c99-c11-compat")
Expand Down Expand Up @@ -303,15 +303,15 @@ H5_CLANG_DIAG_ON("c11-extensions")
/* Mutex that efficiently obeys the "DLFTT" locking protocol */
typedef struct H5TS_dlftt_mutex_t {
H5TS_mutex_t mtx;
unsigned dlftt;
unsigned dlftt;
} H5TS_dlftt_mutex_t;

/* Mechanism for implementing Double-checked Locking Protocol (DCLP) for global
* variables with deferred initialization (i.e. not at library init time.
* FYI: https://preshing.com/20130930/double-checked-locking-is-fixed-in-cpp11/
*/
typedef struct H5TS_dclp_t {
bool init; /* Whether the global has been initialized */
bool init; /* Whether the global has been initialized */
} H5TS_dclp_t;

/* Safely call an initialization routine for a global variable. This is invoked
Expand All @@ -322,39 +322,38 @@ typedef struct H5TS_dclp_t {
* containing a field of type H5TS_dclp_t as its first field.
*/
#ifdef H5_HAVE_CONCURRENCY
#define H5TS_INIT_GLOBAL(v,f,maj,min,err_ret,...) \
do { \
if (H5_UNLIKELY(!((H5TS_dclp_t *)(v))->init)) { \
if (H5_UNLIKELY(H5TS_dlftt_mutex_acquire(&H5TS_bootstrap_mtx_g) < 0)) \
HGOTO_ERROR((maj), H5E_CANTLOCK, (err_ret), "can't acquire global bootstrap mutex"); \
if (!((H5TS_dclp_t *)(v))->init) { \
/* Invoke the init function */ \
if (H5_UNLIKELY((f)(v) < 0)) \
HGOTO_ERROR((maj), (min), (err_ret), __VA_ARGS__); \
\
/* Indicate that the free list is initialized */ \
H5TS_SET_GLOBAL_INIT(v, true); \
} \
if (H5_UNLIKELY(H5TS_dlftt_mutex_release(&H5TS_bootstrap_mtx_g) < 0)) \
HGOTO_ERROR((maj), H5E_CANTUNLOCK, (err_ret), "can't release global bootstrap mutex"); \
} \
} while(0)
#define H5TS_INIT_GLOBAL(v, f, maj, min, err_ret, ...) \
do { \
if (H5_UNLIKELY(!((H5TS_dclp_t *)(v))->init)) { \
if (H5_UNLIKELY(H5TS_dlftt_mutex_acquire(&H5TS_bootstrap_mtx_g) < 0)) \
HGOTO_ERROR((maj), H5E_CANTLOCK, (err_ret), "can't acquire global bootstrap mutex"); \
if (!((H5TS_dclp_t *)(v))->init) { \
/* Invoke the init function */ \
if (H5_UNLIKELY((f)(v) < 0)) \
HGOTO_ERROR((maj), (min), (err_ret), __VA_ARGS__); \
\
/* Indicate that the free list is initialized */ \
H5TS_SET_GLOBAL_INIT(v, true); \
} \
if (H5_UNLIKELY(H5TS_dlftt_mutex_release(&H5TS_bootstrap_mtx_g) < 0)) \
HGOTO_ERROR((maj), H5E_CANTUNLOCK, (err_ret), "can't release global bootstrap mutex"); \
} \
} while (0)
#else /* H5_HAVE_CONCURRENCY */
#define H5TS_INIT_GLOBAL(v,f,maj,min,err_ret,...) \
do { \
if (H5_UNLIKELY(!((H5TS_dclp_t *)(v))->init)) { \
/* Invoke the init function */ \
if (H5_UNLIKELY((f)(v) < 0)) \
HGOTO_ERROR((maj), (min), (err_ret), __VA_ARGS__); \
\
/* Indicate that the free list is initialized */ \
H5TS_SET_GLOBAL_INIT(v, true); \
} \
} while(0)
#define H5TS_INIT_GLOBAL(v, f, maj, min, err_ret, ...) \
do { \
if (H5_UNLIKELY(!((H5TS_dclp_t *)(v))->init)) { \
/* Invoke the init function */ \
if (H5_UNLIKELY((f)(v) < 0)) \
HGOTO_ERROR((maj), (min), (err_ret), __VA_ARGS__); \
\
/* Indicate that the free list is initialized */ \
H5TS_SET_GLOBAL_INIT(v, true); \
} \
} while (0)
#endif /* H5_HAVE_CONCURRENCY */
#define H5TS_IS_GLOBAL_INIT(v) (((H5TS_dclp_t *)(v))->init)
#define H5TS_SET_GLOBAL_INIT(v,x) ((H5TS_dclp_t *)(v))->init = (x)

#define H5TS_IS_GLOBAL_INIT(v) (((H5TS_dclp_t *)(v))->init)
#define H5TS_SET_GLOBAL_INIT(v, x) ((H5TS_dclp_t *)(v))->init = (x)

/*****************************/
/* Library-private Variables */
Expand Down Expand Up @@ -433,7 +432,7 @@ H5_DLL herr_t H5TS_cond_destroy(H5TS_cond_t *cond);
/* Thread-specific keys */
H5_DLL herr_t H5TS_key_create(H5TS_key_t *key, H5TS_key_destructor_func_t dtor);
/* Key set & get calls are defined in H5TSkey.h */
H5_DLL herr_t H5TS_key_delete(H5TS_key_t key);
H5_DLL herr_t H5TS_key_delete(H5TS_key_t key);

/* Threads */
H5_DLL herr_t H5TS_thread_create(H5TS_thread_t *thread, H5TS_thread_start_func_t func, void *udata);
Expand Down Expand Up @@ -471,10 +470,10 @@ H5_DLL void H5TS_atomic_destroy_uint(H5TS_atomic_uint_t *obj);
H5_DLL void H5TS_atomic_init_size_t(H5TS_atomic_size_t *obj, size_t desired);
/* Atomic 'size_t' load, store, etc. calls are defined in H5TSatomic.h */
static inline size_t H5TS_atomic_load_size_t(H5TS_atomic_size_t *obj);
static inline void H5TS_atomic_store_size_t(H5TS_atomic_size_t *obj, size_t desired);
static inline void H5TS_atomic_store_size_t(H5TS_atomic_size_t *obj, size_t desired);
static inline size_t H5TS_atomic_fetch_add_size_t(H5TS_atomic_size_t *obj, size_t arg);
static inline size_t H5TS_atomic_fetch_sub_size_t(H5TS_atomic_size_t *obj, size_t arg);
H5_DLL void H5TS_atomic_destroy_size_t(H5TS_atomic_size_t *obj);
H5_DLL void H5TS_atomic_destroy_size_t(H5TS_atomic_size_t *obj);

/* void * _Atomic (atomic void pointer) */
H5_DLL void H5TS_atomic_init_voidp(H5TS_atomic_voidp_t *obj, void *desired);
Expand Down
Loading

0 comments on commit dd1cc71

Please sign in to comment.