This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.
Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Hi! This patch improves libpthread.a object interdependencies a little bit. Without this patch, really many objects brought in pthread_create.o and many other objects completely unnecessarily, e.g. through __is_smp dependency (if pthread_create.o is not linked in, __is_smp can very well be 0 on both UP and SMP) or __pthread_multiple_threads (the same). On the other side, this patch adds a few new dependencies to make libgcc_eh.a/libsupc++.a/libstdc++.a happy - these libs assume that if weak pthread_create != NULL, a couple of other functions is available too (and frankly, it is hard to do something else without requiring libpthread.a always - if pthread_create is linked in, the chances that there will be multiple threads are pretty high and in that case it really should be able to use locking etc.). The end result is that a few functions (pthread_{create,detach,join,tryjoin,timedjoin}) bring in the NPTL core objects (init.o, pthread_create.o, pthread_mutex_{,un}lock.o, etc.) and the rest of objects have really very few dependencies. See attached before.bz2 and after.bz2 that lists what each libpthread.o object {used to ,}depend{,s} on from libpthread.a. 2004-11-20 Jakub Jelinek <jakub@redhat.com> * Makefile (libpthread-routines): Add vars. * sysdeps/pthread/createthread.c (__pthread_multiple_threads): Remove. * init.c (__default_stacksize, __is_smp): Remove. * vars.c: New file. * pthreadP.h (__find_thread_by_id): If !SHARED, add weak_function and define a wrapper macro. (PTHREAD_STATIC_FN_REQUIRE): Define. * allocatestack.c (__find_thread_by_id): Undefine. * pthread_create (__pthread_keys): Remove. (pthread_mutex_lock, pthread_mutex_unlock, pthread_once, pthread_key_create, pthread_setspecific, pthread_getspecific): Add PTHREAD_STATIC_FN_REQUIRE. --- libc/nptl/Makefile.jj 2004-11-12 13:57:44.000000000 +0100 +++ libc/nptl/Makefile 2004-11-19 18:36:37.014384900 +0100 @@ -30,7 +30,7 @@ install-lib-ldscripts := libpthread.so routines = alloca_cutoff forward libc-lowlevellock libc-cancellation shared-only-routines = forward -libpthread-routines = init events version \ +libpthread-routines = init vars events version \ pthread_create pthread_exit pthread_detach \ pthread_join pthread_tryjoin pthread_timedjoin \ pthread_self pthread_equal pthread_yield \ --- libc/nptl/sysdeps/pthread/createthread.c.jj 2004-11-10 07:53:09.000000000 +0100 +++ libc/nptl/sysdeps/pthread/createthread.c 2004-11-19 18:38:03.098023025 +0100 @@ -42,8 +42,6 @@ #ifndef TLS_MULTIPLE_THREADS_IN_TCB -/* Variable set to a nonzero value if more than one thread runs or ran. */ -int __pthread_multiple_threads attribute_hidden; /* Pointer to the corresponding variable in libc. */ int *__libc_multiple_threads_ptr attribute_hidden; #endif --- libc/nptl/init.c.jj 2004-09-20 15:35:01.000000000 +0200 +++ libc/nptl/init.c 2004-11-20 00:06:01.670703155 +0100 @@ -56,16 +56,10 @@ #endif -/* Default stack size. */ -size_t __default_stacksize attribute_hidden; - /* Size and alignment of static TLS block. */ size_t __static_tls_size; size_t __static_tls_align_m1; -/* Flag whether the machine is SMP or not. */ -int __is_smp attribute_hidden; - /* Version of the library, used in libthread_db to detect mismatches. */ static const char nptl_version[] __attribute_used__ = VERSION; --- libc/nptl/vars.c.jj 2004-11-19 19:03:31.679259845 +0100 +++ libc/nptl/vars.c 2004-11-20 00:08:58.405204444 +0100 @@ -0,0 +1,43 @@ +/* Copyright (C) 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <pthreadP.h> +#include <stdlib.h> +#include <tls.h> +#include <unistd.h> + +/* Default stack size. */ +size_t __default_stacksize attribute_hidden +#ifdef SHARED +; +#else + = PTHREAD_STACK_MIN; +#endif + +/* Flag whether the machine is SMP or not. */ +int __is_smp attribute_hidden; + +#ifndef TLS_MULTIPLE_THREADS_IN_TCB +/* Variable set to a nonzero value if more than one thread runs or ran. */ +int __pthread_multiple_threads attribute_hidden; +#endif + +/* Table of the key information. */ +struct pthread_key_struct __pthread_keys[PTHREAD_KEYS_MAX] + __attribute__ ((nocommon)); +hidden_data_def (__pthread_keys) --- libc/nptl/pthreadP.h.jj 2004-11-12 13:57:44.000000000 +0100 +++ libc/nptl/pthreadP.h 2004-11-19 23:40:26.245415327 +0100 @@ -278,7 +278,14 @@ extern int *__libc_multiple_threads_ptr #endif /* Find a thread given its TID. */ -extern struct pthread *__find_thread_by_id (pid_t tid) attribute_hidden; +extern struct pthread *__find_thread_by_id (pid_t tid) attribute_hidden +#ifdef SHARED +; +#else +weak_function; +#define __find_thread_by_id(tid) \ + (__find_thread_by_id ? (__find_thread_by_id) (tid) : (struct pthread *) NULL) +#endif extern void __pthread_init_static_tls (struct link_map *) attribute_hidden; @@ -450,4 +457,10 @@ extern void __nptl_deallocate_tsd (void) extern int __nptl_setxid (struct xid_command *cmdp) attribute_hidden; +#ifdef SHARED +# define PTHREAD_STATIC_FN_REQUIRE(name) +#else +# define PTHREAD_STATIC_FN_REQUIRE(name) __asm (".globl " #name); +#endif + #endif /* pthreadP.h */ --- libc/nptl/allocatestack.c.jj 2004-11-12 13:57:44.000000000 +0100 +++ libc/nptl/allocatestack.c 2004-11-19 23:50:24.911683818 +0100 @@ -771,6 +771,7 @@ __reclaim_stacks (void) #if HP_TIMING_AVAIL +# undef __find_thread_by_id /* Find a thread given the thread ID. */ attribute_hidden struct pthread * --- libc/nptl/pthread_create.c.jj 2004-11-10 07:53:09.000000000 +0100 +++ libc/nptl/pthread_create.c 2004-11-19 23:15:30.162164032 +0100 @@ -55,11 +55,6 @@ unsigned int __nptl_nthreads = 1; #include "createthread.c" -/* Table of the key information. */ -struct pthread_key_struct __pthread_keys[PTHREAD_KEYS_MAX] - __attribute__ ((nocommon)); -hidden_data_def (__pthread_keys) - struct pthread * internal_function __find_in_stack_list (pd) @@ -513,3 +508,14 @@ compat_symbol (libpthread, __pthread_cre /* Information for libthread_db. */ #include "../nptl_db/db_info.c" + +/* If pthread_create is present, libgcc_eh.a and libsupc++.a expects some other POSIX thread + functions to be present as well. */ +PTHREAD_STATIC_FN_REQUIRE (pthread_mutex_lock) +PTHREAD_STATIC_FN_REQUIRE (pthread_mutex_unlock) + +PTHREAD_STATIC_FN_REQUIRE (pthread_once) + +PTHREAD_STATIC_FN_REQUIRE (pthread_key_create) +PTHREAD_STATIC_FN_REQUIRE (pthread_setspecific) +PTHREAD_STATIC_FN_REQUIRE (pthread_getspecific) Jakub
Attachment:
before.bz2
Description: BZip2 compressed data
Attachment:
after.bz2
Description: BZip2 compressed data
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |