FFI, safe vs unsafe

Fergus Henderson fjh-mailbox-18 at galois.com
Thu Apr 6 13:05:56 EDT 2006


On 03-Apr-2006, John Meacham <john at repetae.net> wrote:
> On Mon, Apr 03, 2006 at 02:00:33PM -0400, Wolfgang Thaller wrote:
> > About how fast thread-local state really is:
> > __thread attribute on Linux: ~ 2 memory load instructions.
> > __declspec(thread) in MSVC++ on Windows: about the same.
> > pthread_getspecific on Mac OS X/x86 and Mac OS X/G5: ~10 instructions
> > pthread_getspecific on Linux and TlsGetValue on Windows: ~10-20  
> > instructions
> > pthread_getspecific on Mac OS X/G4: a system call :-(.
> 
> how prevelant is support for __thread BTW? is it required by any
> standards or an ELFism?

It's a recent innovation that standards have not yet had time to catch
up with.  But __thread is the way of the future, IMHO.
GNU C/C++ supports __thread for at least the following architectures:

	IA-32, x86-64,
	IA-64,
	SPARC (32- and 64-bit),
	Alpha,
	S390 (31- and 64-bit),
	SuperHitachi (SH),
	HP/PA 64-bit.

It's also supported by Borland C++ builder, Sun Studio C/C++, and Visual C++.
(VC++ does use a slightly different syntax, but you can use macros to work
around that.)

-- 
Fergus J. Henderson                 |  "I have always known that the pursuit
Galois Connections, Inc.            |  of excellence is a lethal habit"
Phone: +1 503 626 6616              |     -- the last words of T. S. Garp.


More information about the Haskell-prime mailing list