Check out my first novel, midnight's simulacra!

Thread-Local Storage: Difference between revisions

From dankwiki
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
==[[C|C99]]==
* ISO/IEC 9899:1999 is amended by [[gcc]] and others to introduce the <tt>__thread</tt> storage specifier (§6.2.4, §6.4.1, §6.7.1), and to add a vague definition of threads to the execution model (§5.1.2).
===C++11===
* C++11 adds the <tt>thread_local</tt> keyword
** Only constant initializers can be used for variables having __thread storage.
==Windows==
==Windows==
* <tt>__declspec(thread)</tt> doesn't work in DLL's prior to Vista
* <tt>__declspec(thread)</tt> doesn't work in DLL's prior to Vista when loaded via LoadLibrary().
** The DLL must be linked into the binary before the binary's main image is loaded.


==See Also==
==See Also==
Line 6: Line 12:
* Ulrich Drepper's paper, "[http://dev.gentoo.org/~dberkholz/articles/toolchain/tls.pdf ELF Handling for Thread-Local Storage]"
* Ulrich Drepper's paper, "[http://dev.gentoo.org/~dberkholz/articles/toolchain/tls.pdf ELF Handling for Thread-Local Storage]"
* [[gcc]]'s Info entry for [http://gcc.gnu.org/onlinedocs/gcc/Thread_002dLocal.html#Thread_002dLocal TLS]
* [[gcc]]'s Info entry for [http://gcc.gnu.org/onlinedocs/gcc/Thread_002dLocal.html#Thread_002dLocal TLS]
* "[http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1423.htm#TLS C and C++ Thread Compatibility]", ISO/IEC JTC1 SC22 WG14 N1423 (Lawrence Crowl)

Latest revision as of 14:42, 6 September 2011

C99

  • ISO/IEC 9899:1999 is amended by gcc and others to introduce the __thread storage specifier (§6.2.4, §6.4.1, §6.7.1), and to add a vague definition of threads to the execution model (§5.1.2).

C++11

  • C++11 adds the thread_local keyword
    • Only constant initializers can be used for variables having __thread storage.

Windows

  • __declspec(thread) doesn't work in DLL's prior to Vista when loaded via LoadLibrary().
    • The DLL must be linked into the binary before the binary's main image is loaded.

See Also