diff options
| author | Heather McIntyre <[email protected]> | 2023-10-09 23:09:28 +0200 |
|---|---|---|
| committer | Mark Wielaard <[email protected]> | 2023-10-14 16:44:35 +0200 |
| commit | 6d84c62cebeb2768dcb4a1843d503537d86a153e (patch) | |
| tree | 6f8bf415bd06c69e64887d5bcef3e533df3bb70b /lib | |
| parent | a78cb7d4cb604f737244d3dacd5ce6c01d6bc156 (diff) | |
lib: Add new once_define and once macros to eu-config.h
* lib/eu-config.h New macros.
[USE_LOCKS] (ONCE_CALL): (once_define, once)
Signed-off-by: Heather S. McIntyre <[email protected]>
Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/eu-config.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/eu-config.h b/lib/eu-config.h index 78a5c4fe..feb079db 100644 --- a/lib/eu-config.h +++ b/lib/eu-config.h @@ -33,13 +33,18 @@ # include <pthread.h> # include <assert.h> # define rwlock_define(class,name) class pthread_rwlock_t name +# define once_define(class,name) class pthread_once_t name = PTHREAD_ONCE_INIT # define RWLOCK_CALL(call) \ ({ int _err = pthread_rwlock_ ## call; assert_perror (_err); }) +# define ONCE_CALL(call) \ + ({ int _err = pthread_ ## call; assert_perror (_err); }) # define rwlock_init(lock) RWLOCK_CALL (init (&lock, NULL)) # define rwlock_fini(lock) RWLOCK_CALL (destroy (&lock)) # define rwlock_rdlock(lock) RWLOCK_CALL (rdlock (&lock)) # define rwlock_wrlock(lock) RWLOCK_CALL (wrlock (&lock)) # define rwlock_unlock(lock) RWLOCK_CALL (unlock (&lock)) +# define once(once_control, init_routine) \ + ONCE_CALL (once (&once_control, init_routine)) #else /* Eventually we will allow multi-threaded applications to use the libraries. Therefore we will add the necessary locking although @@ -50,6 +55,8 @@ # define rwlock_rdlock(lock) ((void) (lock)) # define rwlock_wrlock(lock) ((void) (lock)) # define rwlock_unlock(lock) ((void) (lock)) +# define once_define(class,name) +# define once(once_control, init_routine) init_routine() #endif /* USE_LOCKS */ #include <libintl.h> |
