Date: Thu, 17 Dec 2009 20:41:40 +0000 (UTC) From: John Baldwin <jhb@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org Subject: svn commit: r200649 - in stable/7/lib/libc: gen include Message-ID: <200912172041.nBHKfeIA049690@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jhb Date: Thu Dec 17 20:41:40 2009 New Revision: 200649 URL: http://svn.freebsd.org/changeset/base/200649 Log: MFC 199606, 199614: 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. Added: stable/7/lib/libc/gen/_once_stub.c - copied, changed from r199606, head/lib/libc/gen/_once_stub.c Modified: stable/7/lib/libc/gen/Makefile.inc stable/7/lib/libc/include/libc_private.h Directory Properties: stable/7/lib/libc/ (props changed) Modified: stable/7/lib/libc/gen/Makefile.inc ============================================================================== --- stable/7/lib/libc/gen/Makefile.inc Thu Dec 17 20:41:27 2009 (r200648) +++ stable/7/lib/libc/gen/Makefile.inc Thu Dec 17 20:41:40 2009 (r200649) @@ -5,7 +5,8 @@ .PATH: ${.CURDIR}/${MACHINE_ARCH}/gen ${.CURDIR}/gen SRCS+= __getosreldate.c __xuname.c \ - _pthread_stubs.c _rand48.c _spinlock_stub.c _thread_init.c \ + _once_stub.c _pthread_stubs.c _rand48.c _spinlock_stub.c \ + _thread_init.c \ alarm.c arc4random.c assert.c basename.c check_utility_compat.c \ clock.c closedir.c confstr.c \ crypt.c ctermid.c daemon.c devname.c dirname.c disklabel.c \ Copied and modified: stable/7/lib/libc/gen/_once_stub.c (from r199606, head/lib/libc/gen/_once_stub.c) ============================================================================== --- head/lib/libc/gen/_once_stub.c Fri Nov 20 19:19:51 2009 (r199606, copy source) +++ stable/7/lib/libc/gen/_once_stub.c Thu Dec 17 20:41:40 2009 (r200649) @@ -33,11 +33,8 @@ __FBSDID("$FreeBSD$"); #include "un-namespace.h" #include "libc_private.h" -/* - * This implements pthread_once() for the single-threaded case. It is - * non-static so that it can be used by _pthread_stubs.c. - */ -int +/* This implements pthread_once() for the single-threaded case. */ +static int _libc_once(pthread_once_t *once_control, void (*init_routine)(void)) { Modified: stable/7/lib/libc/include/libc_private.h ============================================================================== --- stable/7/lib/libc/include/libc_private.h Thu Dec 17 20:41:27 2009 (r200648) +++ stable/7/lib/libc/include/libc_private.h Thu Dec 17 20:41:40 2009 (r200649) @@ -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,12 @@ 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)); + +/* * Set the TLS thread pointer */ void _set_tp(void *tp);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200912172041.nBHKfeIA049690>