diff options
author | jhb <jhb@FreeBSD.org> | 2009-11-20 19:19:51 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2009-11-20 19:19:51 +0000 |
commit | b850b4760dddafa38d7850f86e99ce47326a2676 (patch) | |
tree | 9dcf60a4d7bd680a0877e1a8aa449c9766bdcc8f /lib/libc/include | |
parent | be8a54e0c3db12d3fecac288bf6ddfd350731d11 (diff) | |
download | FreeBSD-src-b850b4760dddafa38d7850f86e99ce47326a2676.zip FreeBSD-src-b850b4760dddafa38d7850f86e99ce47326a2676.tar.gz |
Add an internal _once() method. This works identical to pthread_once(3)
with the additional property that it is safe for routines in libc to use
in both single-threaded and multi-threaded processes. Multi-threaded
processes use the pthread_once() implementation from the threading library
while single-threaded processes use a simplified "stub" version internal
to libc. The libc stub-version of pthread_once() now also uses the
simplified "stub" version as well instead of being a nop.
Reviewed by: deischen, Matthew Fleming @ Isilon
Suggested by: alc
MFC after: 1 week
Diffstat (limited to 'lib/libc/include')
-rw-r--r-- | lib/libc/include/libc_private.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/libc/include/libc_private.h b/lib/libc/include/libc_private.h index 50903f3..bcf2b1c 100644 --- a/lib/libc/include/libc_private.h +++ b/lib/libc/include/libc_private.h @@ -34,6 +34,7 @@ #ifndef _LIBC_PRIVATE_H_ #define _LIBC_PRIVATE_H_ +#include <sys/_pthreadtypes.h> /* * This global flag is non-zero when a process has created one @@ -147,6 +148,13 @@ int _yp_check(char **); void _init_tls(void); /* + * Provides pthread_once()-like functionality for both single-threaded + * and multi-threaded applications. + */ +int _once(pthread_once_t *, void (*)(void)); +int _libc_once(pthread_once_t *, void (*)(void)); + +/* * Set the TLS thread pointer */ void _set_tp(void *tp); |