On Wed, Aug 17, 2011 at 5:45 PM, Paolo Bonzini <pbonz...@redhat.com> wrote: > On 08/17/2011 10:37 AM, Blue Swirl wrote: >> >> > I would agree (just did it for fun and to see how it looks like), but >> > perhaps we can do something similar to what Windows does for OpenBSD >> > too. >> > >> > Though I'm quite disappointed and I must say OpenBSD should enter the >> > 21st >> > century. >> >> I can't justify their design decisions, but isn't __thread a >> non-standard extension by GCC anyway whereas POSIX threads are the >> standard? Are other compilers supporting it? > > Visual C++ supports __declspec(thread). > > pthread TLS is orders of magnitudes slower than __thread. __thread in an > executable is just as fast as a non-TLS variable access, 2 or 3 machine > language instructions at most. > > Some pthread_getspecific implementation do a _linear walk_ of the keys. In > that case it may work to have something like Windows plus a single > pthread_getspecific key. On the other hand, Windows provides very good > support for that thanks to its ordered subsections (.tls$something). It > only needs a bit of preprocessor magic. Thinks such as linker scripts would > be way out of scope.
According to this blog, also pthread_getspecific on OSX can amount to three instructions except on PPC: http://lifecs.likai.org/2010/05/mac-os-x-thread-local-storage.html