Thread Local Storage

Marcel Moolenaar marcel at xcllnt.net
Tue Mar 30 10:03:24 PST 2004


On Tue, Mar 30, 2004 at 09:35:49AM +0100, Doug Rabson wrote:
> > >
> > > I'd quite like to see us use it for stuff like errno, _res and
> > > other uglification currently in libc. Not until the 6.x timeframe
> > > though.
> >
> > 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. 

Yes. It's also far more optimal.

> It would even work for evil cases where libpthread is loaded after 
> program startup with dlopen.

Yup. I think it's important to have it work.

-- 
 Marcel Moolenaar	  USPA: A-39004		 marcel at xcllnt.net


More information about the freebsd-threads mailing list