From owner-p4-projects@FreeBSD.ORG Sun Jan 30 07:37:52 2005 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 5B5F016A4D0; Sun, 30 Jan 2005 07:37:52 +0000 (GMT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2D93C16A4CE for ; Sun, 30 Jan 2005 07:37:52 +0000 (GMT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id F00BF43D46 for ; Sun, 30 Jan 2005 07:37:51 +0000 (GMT) (envelope-from davidxu@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id j0U7bpTW096635 for ; Sun, 30 Jan 2005 07:37:51 GMT (envelope-from davidxu@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id j0U7bpDB096632 for perforce@freebsd.org; Sun, 30 Jan 2005 07:37:51 GMT (envelope-from davidxu@freebsd.org) Date: Sun, 30 Jan 2005 07:37:51 GMT Message-Id: <200501300737.j0U7bpDB096632@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to davidxu@freebsd.org using -f From: David Xu To: Perforce Change Reviews Subject: PERFORCE change 69957 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Jan 2005 07:37:53 -0000 http://perforce.freebsd.org/chv.cgi?CH=69957 Change 69957 by davidxu@davidxu_tiger on 2005/01/30 07:37:21 Merge thr_autoinit.c Affected files ... .. //depot/projects/davidxu_thread/src/lib/libthread/thread/thr_init.c#10 edit Differences ... ==== //depot/projects/davidxu_thread/src/lib/libthread/thread/thr_init.c#10 (text+ko) ==== @@ -72,8 +72,7 @@ int __pthread_cond_wait(pthread_cond_t *, pthread_mutex_t *); int __pthread_mutex_lock(pthread_mutex_t *); int __pthread_mutex_trylock(pthread_mutex_t *); -void _thread_init_hack(void); -extern int _thread_state_running; +void _thread_init_hack(void) __attribute__ ((constructor)); static void init_private(void); static void init_main_thread(struct pthread *thread); @@ -195,7 +194,29 @@ {DUAL_ENTRY(_pthread_sigmask)} /* PJT_SIGMASK */ }; -static int init_once = 0; +extern int _thread_state_running; +static int init_once = 0; + +/* + * For the shared version of the threads library, the above is sufficient. + * But for the archive version of the library, we need a little bit more. + * Namely, we must arrange for this particular module to be pulled in from + * the archive library at link time. To accomplish that, we define and + * initialize a variable, "_thread_autoinit_dummy_decl". This variable is + * referenced (as an extern) from libc/stdlib/exit.c. This will always + * create a need for this module, ensuring that it is present in the + * executable. + */ +extern int _thread_autoinit_dummy_decl; +int _thread_autoinit_dummy_decl = 0; + +void +_thread_init_hack(void) +{ + + _libpthread_init(NULL); +} + /* * Threaded process initialization. @@ -357,11 +378,11 @@ size_t len; int mib[2]; - umtx_init(&_mutex_static_lock); - umtx_init(&_cond_static_lock); - umtx_init(&_rwlock_static_lock); - umtx_init(&_keytable_lock); - umtx_init(&_thr_atfork_lock); + _thr_umtx_init(&_mutex_static_lock); + _thr_umtx_init(&_cond_static_lock); + _thr_umtx_init(&_rwlock_static_lock); + _thr_umtx_init(&_keytable_lock); + _thr_umtx_init(&_thr_atfork_lock); _thr_spinlock_init(); _thr_list_init();