From owner-freebsd-threads@FreeBSD.ORG Wed May 7 18:05:08 2003 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6AE7437B401 for ; Wed, 7 May 2003 18:05:08 -0700 (PDT) Received: from mail.pcnet.com (mail.pcnet.com [204.213.232.4]) by mx1.FreeBSD.org (Postfix) with ESMTP id AB03C43F93 for ; Wed, 7 May 2003 18:05:07 -0700 (PDT) (envelope-from eischen@pcnet1.pcnet.com) Received: from pcnet1.pcnet.com (localhost [127.0.0.1]) by mail.pcnet.com (8.12.8/8.12.1) with ESMTP id h48155Bg003541; Wed, 7 May 2003 21:05:06 -0400 (EDT) Received: from localhost (eischen@localhost)h48153m8003524; Wed, 7 May 2003 21:05:04 -0400 (EDT) Date: Wed, 7 May 2003 21:05:03 -0400 (EDT) From: Daniel Eischen To: David Xu In-Reply-To: <004301c314f1$b0b67fd0$0701a8c0@tiger> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: freebsd-threads@freebsd.org Subject: Re: libpthread_init X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 May 2003 01:05:08 -0000 On Thu, 8 May 2003, David Xu wrote: > CCed freebsd-threads@freebsd.org > > ----- Original Message ----- > From: "Daniel Eischen" > To: "David Xu" > Sent: Wednesday, May 07, 2003 8:22 PM > Subject: Re: libpthread_init > > > > On Wed, 7 May 2003, David Xu wrote: > > > > > Is it possible to call libpthread_init in libc at > > > startup to initialize libpthread for static linked > > > binary? > > > for example, use "__attribute__((constructor))" > > > or put a weak symbol in crt1.c to let libpthread > > > override it, and be called in libc startup routine? > > > > I don't know. It would be nice to get rid of all the > > calls to lipbthread_init() in libpthread. > > > > I think there should be a weak symbol in crt1.c or somewhere > to let static linked thread library overide it, the weak symbol will be called > at libc startup time to initialize thread library . I don't like current > thread initializing mode --- it is triggered by user application, and the > initializing point is not clear, where and when is it initialized? I know. I brought this up years ago, but didn't really know how to fix it. > It is error-prone mode, while mono-thread has a perfect initializing step, > why should threaded app have a bad initializing step, and we must > put : "if (!__isthreaded) then do something" everywhere in thread library, I know, I know :-) You're preaching to the choir! (I agree) > I have already found that a simple "write(1, "hello", 5)" would cause SEGSIGV > when it is linked with static pthread library. FreeBSD now has two mode apps, > mono-threaded and mutli-threaded, I think both should have a good initializing > code, both are important, libc should be refined to reflect the fact. Yes. Have you tried it to see if it works? The other thread libraries would also need to be updated. We should use a common symbol like __thread_init() or __libc_thread_init() so they can all override the same symbol. -- Dan Eischen