Skip Navigation Links | |
Exit Print View | |
Oracle Solaris Studio 12.3: C User's Guide Oracle Solaris Studio 12.3 Information Library |
1. Introduction to the C Compiler
2. C-Compiler Implementation-Specific Information
2.4 Floating Point, Nonstandard Mode
2.6.1 Printing long long Data Types
2.6.2 Usual Arithmetic Conversions
2.7 Case Ranges in Switch Statements
2.11.3 does_not_read_global_data
2.11.5 does_not_write_global_data
2.11.26 warn_missing_parameter_info
2.13 Preserving the Value of errno
2.14.3 __inline and __inline__
2.14.5 __FUNCTION__ and __PRETTY_FUNCTION__
2.16 How to Specify Include Files
2.16.1 Using the -I- Option to Change the Search Algorithm
2.17 Compiling in Free-Standing Environments
2.18 Compiler Support for Intel MMX and Extended x86 Platform Intrinsics
7. Converting Applications for a 64-Bit Environment
8. cscope: Interactively Examining a C Program
A. Compiler Options Grouped by Functionality
B. C Compiler Options Reference
C. Implementation-Defined ISO/IEC C99 Behavior
E. Implementation-Defined ISO/IEC C90 Behavior
H. Oracle Solaris Studio C: Differences Between K&R C and ISO C
Take advantage of thread-local storage by declaring thread-local variables. A thread-local variable declaration consists of a normal variable declaration with the addition of the variable specifier __thread. For more information, see B.2.157 -xthreadvar[=o].
You must include the __thread specifier in the first declaration of the thread variable in the source file being compiled.
You can only use the __thread specifier in the declaration of an object with static storage duration. You can statically initialize a thread variable as you would any other object of static-storage duration.
Variables that you declare with the __thread specifier have the same linker binding as they would without the __thread specifier. This includes tentative definitions, such as declarations without initializers.
The address of a thread variable is not a constant. Therefore, the address-of operator (&) for a thread variable is evaluated at run time and returns the address of the thread variable for the current thread. As a consequence, objects of static storage duration are initialized dynamically to the address of a thread variable.
The address of a thread variable is stable for the lifetime of the corresponding thread. Any thread in the process can freely use the address of a thread variable during the variable’s lifetime. You cannot use a thread variable’s address after its thread terminates. After a thread terminates, all addresses of that thread’s variables are invalid.