From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/2773 Path: news.gmane.org!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH v3] move the definition of __pthread_tsd_main to the only compilation unit that references it Date: Mon, 11 Feb 2013 12:14:17 +0100 Message-ID: <20130211111417.GA6181@port70.net> References: <1360579429.9132.37.camel@eris.loria.fr> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1360581274 1179 80.91.229.3 (11 Feb 2013 11:14:34 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 11 Feb 2013 11:14:34 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-2774-gllmg-musl=m.gmane.org@lists.openwall.com Mon Feb 11 12:14:55 2013 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1U4rLU-0006TU-JP for gllmg-musl@plane.gmane.org; Mon, 11 Feb 2013 12:14:48 +0100 Original-Received: (qmail 19809 invoked by uid 550); 11 Feb 2013 11:14:29 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 19800 invoked from network); 11 Feb 2013 11:14:29 -0000 Content-Disposition: inline In-Reply-To: <1360579429.9132.37.camel@eris.loria.fr> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:2773 Archived-At: * Jens Gustedt [2013-02-11 11:44:21 +0100]: > - Avoids a const cast that doesn't seem to be very useful. > - Remove unused __pthread_tsd_size > sorry i was wrong, __pthread_tsd_size is used in pthread_create (i haven't read all the mails yet) the logic is that it is 0 when pthread_key_create is not linked to your code so you avoid all the tsd stack overhead (which is reasonable: in small tools where size and memory usage matters most you don't often use thread specific data.. especially now that c11 has tls) same for pthread_self: you only want non-dummy tsd if pthread_key_create is used with your change you break pthread_create (now __pthread_tsd_size is always 0 there) and pthread_create always pulls in the tsd buf the weak_alias is there for a reason.. > 0 3 src/thread/pthread_key_create.c > 2 4 src/thread/pthread_self.c > > diff --git a/src/thread/pthread_key_create.c b/src/thread/pthread_key_create.c > index e51cb02..084cbaa 100644 > --- a/src/thread/pthread_key_create.c > +++ b/src/thread/pthread_key_create.c > @@ -1,8 +1,5 @@ > #include "pthread_impl.h" > > -const size_t __pthread_tsd_size = sizeof(void *) * PTHREAD_KEYS_MAX; > -void *__pthread_tsd_main[PTHREAD_KEYS_MAX] = { 0 }; > - > static void (*keys[PTHREAD_KEYS_MAX])(void *); > > static void nodtor(void *dummy) > diff --git a/src/thread/pthread_self.c b/src/thread/pthread_self.c > index 23dbaa5..af4998d 100644 > --- a/src/thread/pthread_self.c > +++ b/src/thread/pthread_self.c > @@ -2,9 +2,7 @@ > > static struct pthread *main_thread = &(struct pthread){0}; > > -/* pthread_key_create.c overrides this */ > -static const void *dummy[1] = { 0 }; > -weak_alias(dummy, __pthread_tsd_main); > +static void *__pthread_tsd_main[PTHREAD_KEYS_MAX]; > > static int init_main_thread() > { > @@ -12,7 +10,7 @@ static int init_main_thread() > SIGPT_SET, 0, __SYSCALL_SSLEN); > if (__set_thread_area(TP_ADJ(main_thread)) < 0) return -1; > main_thread->canceldisable = libc.canceldisable; > - main_thread->tsd = (void **)__pthread_tsd_main; > + main_thread->tsd = __pthread_tsd_main; > main_thread->errno_ptr = __errno_location(); > main_thread->self = main_thread; > main_thread->tid = main_thread->pid = > -- > 1.7.9.5