diff options
author | Ulrich Drepper <drepper@redhat.com> | 1997-08-08 00:34:55 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 1997-08-08 00:34:55 +0000 |
commit | 181e1431e49988869b003be6c562893a13741cf6 (patch) | |
tree | e3fbb9345311d8241b22cd50ad2eceb7169ff74c | |
parent | c58fe9a2dcf8758c48a6835918d9f6c2eda66042 (diff) | |
download | glibc-181e1431e49988869b003be6c562893a13741cf6.zip glibc-181e1431e49988869b003be6c562893a13741cf6.tar.gz glibc-181e1431e49988869b003be6c562893a13741cf6.tar.bz2 |
(__libc_once, __libc_once_define): New macros.
-rw-r--r-- | sysdeps/mach/libc-lock.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/sysdeps/mach/libc-lock.h b/sysdeps/mach/libc-lock.h index cfd1767..0b80b1c 100644 --- a/sysdeps/mach/libc-lock.h +++ b/sysdeps/mach/libc-lock.h @@ -72,6 +72,20 @@ typedef struct __libc_lock_opaque__ __libc_lock_t; (*__save_FCT)(__save_ARG); \ } +/* Use mutexes as once control variables. */ + +/* Define once control variable. */ +#define __libc_once_define(CLASS, NAME) \ + CLASS __libc_lock_define_initialized(,NAME) + +/* Call handler iff the first call. */ +#define __libc_once(ONCE_CONTROL, INIT_FUNCTION) \ + do { \ + if (!__libc_lock_trylock(ONCE_CONTROL) { \ + (INIT_FUNCTION) (); \ + __libc_lock_lock(ONCE_CONTROL); \ + } \ + } while (0) #ifdef _LIBC /* We need portable names for some functions. E.g., when they are |