From owner-freebsd-threads@FreeBSD.ORG Tue Mar 30 06:40:50 2004 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 C4E5D16A4CE for ; Tue, 30 Mar 2004 06:40:50 -0800 (PST) Received: from mail.qubesoft.com (gate.qubesoft.com [217.169.36.34]) by mx1.FreeBSD.org (Postfix) with ESMTP id CBE2F43D2F for ; Tue, 30 Mar 2004 06:40:49 -0800 (PST) (envelope-from dfr@nlsystems.com) Received: from bluebottle.qubesoft.com (bluebottle.qubesoft.com [192.168.1.2]) by mail.qubesoft.com (8.12.9/8.12.9) with ESMTP id i2UEelkM088956; Tue, 30 Mar 2004 15:40:47 +0100 (BST) (envelope-from dfr@nlsystems.com) Received: from builder02.qubesoft.com (builder02.qubesoft.com [192.168.1.8]) i2UEekUQ034248; Tue, 30 Mar 2004 15:40:47 +0100 (BST) (envelope-from dfr@nlsystems.com) From: Doug Rabson To: Daniel Eischen In-Reply-To: References: Content-Type: text/plain Message-Id: <1080657646.18663.9.camel@builder02.qubesoft.com> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.0 Date: 30 Mar 2004 15:40:46 +0100 Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV version 'clamd / ClamAV version 0.65', clamav-milter version '0.60p' cc: freebsd-threads@freebsd.org Subject: Re: Thread Local Storage 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: Tue, 30 Mar 2004 14:40:50 -0000 On Tue, 2004-03-30 at 15:13, Daniel Eischen wrote: > On Tue, 30 Mar 2004, Doug Rabson wrote: > > > On Monday 29 March 2004 23:36, Daniel Eischen wrote: > > > I'd like to see libc free of TLS ;-) The _res stuff can be > > > avoided by modifying the implementation to use thread-safe > > > APIs. The current _res stuff can _almost_ be eliminated > > > by passing using pthread_getspecific() once and passing > > > the _res around internal APIs. That's actually a pretty > > > simple change. > > > > Unfortunately pthread_setspecific() and pthread_getspecific() don't work > > for non-threaded programs whereas 'int __thread errno' works anywhere. > > It works for libc, since libc knows whether it is threaded > or not. I think libc is always going to be sort of special, > especially since we seem to need the jump table for the > pthread_* functions to handle the static case. Right now, the stubs for setspecific and getspecific are too simplistic which means that libc can't use them for anything interesting. The nice part of using TLS for errno is that libc doesn't have to care whether or not its threaded (in this tiny area, anyway). It even makes it straightforward to preserve the value of errno (or any other thread-specific value) when a threading library is loaded. Anyway, this is all blue-sky stuff which isn't relavent to the matter in hand. I was just getting into the whole TLS thing, which is kind of neat (IMHO) :-) > > I'd be in favor of not providing static thread libraries, > but there was too much opposition when I brought it up... Bah. Static sucks. The only way I can see to make TLS work for static is to implement it in the kernel and setup %gs in setregs :-(.