From owner-svn-src-stable-7@FreeBSD.ORG Thu Dec 17 20:41:41 2009 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3564F1065740; Thu, 17 Dec 2009 20:41:41 +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 0AEBF8FC13; Thu, 17 Dec 2009 20:41:41 +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 nBHKfeUY049694; Thu, 17 Dec 2009 20:41:40 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id nBHKfeIA049690; Thu, 17 Dec 2009 20:41:40 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <200912172041.nBHKfeIA049690@svn.freebsd.org> From: John Baldwin Date: Thu, 17 Dec 2009 20:41:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r200649 - in stable/7/lib/libc: gen include X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Dec 2009 20:41:41 -0000 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 /* * 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);