From owner-svn-src-all@FreeBSD.ORG Thu Dec 17 20:41:27 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 75B9A106566C; Thu, 17 Dec 2009 20:41:27 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5B29E8FC0C; Thu, 17 Dec 2009 20:41:27 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id nBHKfRlQ049650; Thu, 17 Dec 2009 20:41:27 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id nBHKfRnQ049646; Thu, 17 Dec 2009 20:41:27 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <200912172041.nBHKfRnQ049646@svn.freebsd.org> From: John Baldwin Date: Thu, 17 Dec 2009 20:41:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r200648 - in stable/8/lib/libc: gen include X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Dec 2009 20:41:27 -0000 Author: jhb Date: Thu Dec 17 20:41:27 2009 New Revision: 200648 URL: http://svn.freebsd.org/changeset/base/200648 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/8/lib/libc/gen/_once_stub.c - copied, changed from r199606, head/lib/libc/gen/_once_stub.c Modified: stable/8/lib/libc/gen/Makefile.inc stable/8/lib/libc/include/libc_private.h Directory Properties: stable/8/lib/libc/ (props changed) stable/8/lib/libc/stdtime/ (props changed) Modified: stable/8/lib/libc/gen/Makefile.inc ============================================================================== --- stable/8/lib/libc/gen/Makefile.inc Thu Dec 17 19:56:09 2009 (r200647) +++ stable/8/lib/libc/gen/Makefile.inc Thu Dec 17 20:41:27 2009 (r200648) @@ -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/8/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/8/lib/libc/gen/_once_stub.c Thu Dec 17 20:41:27 2009 (r200648) @@ -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/8/lib/libc/include/libc_private.h ============================================================================== --- stable/8/lib/libc/include/libc_private.h Thu Dec 17 19:56:09 2009 (r200647) +++ stable/8/lib/libc/include/libc_private.h Thu Dec 17 20:41:27 2009 (r200648) @@ -34,6 +34,7 @@ #ifndef _LIBC_PRIVATE_H_ #define _LIBC_PRIVATE_H_ +#include /* * 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);