RTEMS
Files | Classes | Typedefs | Functions | Variables
Thread-Local Storage (TLS)

Thread-local storage (TLS) support. More...

Files

file  tls.h
 Thread-Local Storage (TLS)
 

Classes

struct  TLS_Dynamic_thread_vector
 
struct  TLS_Thread_control_block
 
struct  TLS_Index
 

Typedefs

typedef struct TLS_Thread_control_block TLS_Thread_control_block
 

Functions

static uintptr_t _TLS_Get_size (void)
 Gets the TLS size. More...
 
static uintptr_t _TLS_Heap_align_up (uintptr_t val)
 Returns the value aligned up to the heap alignment. More...
 
static uintptr_t _TLS_Get_thread_control_block_area_size (uintptr_t alignment)
 Returns the size of the thread control block area size for this alignment, or the minimum size if alignment is too small. More...
 
uintptr_t _TLS_Get_allocation_size (void)
 Return the TLS area allocation size. More...
 
static void * _TLS_Copy_and_clear (void *tls_area)
 Copies TLS size bytes from the address tls_area and returns a pointer to the start of the area after clearing it. More...
 
static void * _TLS_Initialize (void *tls_block, TLS_Thread_control_block *tcb, TLS_Dynamic_thread_vector *dtv)
 Initializes the dynamic thread vector. More...
 
static void * _TLS_TCB_at_area_begin_initialize (void *tls_area)
 Initializes a dynamic thread vector beginning at the given starting address. More...
 
static void * _TLS_TCB_before_TLS_block_initialize (void *tls_area)
 Initializes a dynamic thread vector with the area before a given starting address as thread control block. More...
 
static void * _TLS_TCB_after_TLS_block_initialize (void *tls_area)
 Initializes a dynamic thread vector with the area after a given starting address as thread control block. More...
 

Variables

char _TLS_Data_begin []
 
char _TLS_Data_end []
 
char _TLS_Data_size []
 
char _TLS_BSS_begin []
 
char _TLS_BSS_end []
 
char _TLS_BSS_size []
 
char _TLS_Size []
 
char _TLS_Alignment []
 The TLS section alignment. More...
 

Detailed Description

Thread-local storage (TLS) support.

Variants I and II are according to Ulrich Drepper, "ELF Handling For Thread-Local Storage".

Function Documentation

◆ _TLS_Copy_and_clear()

static void* _TLS_Copy_and_clear ( void *  tls_area)
inlinestatic

Copies TLS size bytes from the address tls_area and returns a pointer to the start of the area after clearing it.

Parameters
tls_areaThe starting address of the area to clear.
Returns
The pointer to the beginning of the cleared section.

Definition at line 167 of file tls.h.

◆ _TLS_Get_allocation_size()

uintptr_t _TLS_Get_allocation_size ( void  )

Return the TLS area allocation size.

Returns
The TLS area allocation size.

Definition at line 38 of file tlsallocsize.c.

◆ _TLS_Get_size()

static uintptr_t _TLS_Get_size ( void  )
inlinestatic

Gets the TLS size.

Returns
The TLS size.

Definition at line 108 of file tls.h.

◆ _TLS_Get_thread_control_block_area_size()

static uintptr_t _TLS_Get_thread_control_block_area_size ( uintptr_t  alignment)
inlinestatic

Returns the size of the thread control block area size for this alignment, or the minimum size if alignment is too small.

Parameters
alignmentThe alignment for the operation.
Returns
The size of the thread control block area.

Definition at line 144 of file tls.h.

◆ _TLS_Heap_align_up()

static uintptr_t _TLS_Heap_align_up ( uintptr_t  val)
inlinestatic

Returns the value aligned up to the heap alignment.

Parameters
valThe value to align.
Returns
The value aligned to the heap alignment.

Definition at line 129 of file tls.h.

◆ _TLS_Initialize()

static void* _TLS_Initialize ( void *  tls_block,
TLS_Thread_control_block tcb,
TLS_Dynamic_thread_vector dtv 
)
inlinestatic

Initializes the dynamic thread vector.

Parameters
tls_blockThe tls block for dtv.
tcbThe thread control block for dtv.
[out]dtvThe dynamic thread vector to initialize.
Returns
Pointer to an area that was copied and cleared from tls_block onwards (
See also
_TLS_Copy_and_clear).

Definition at line 196 of file tls.h.

◆ _TLS_TCB_after_TLS_block_initialize()

static void* _TLS_TCB_after_TLS_block_initialize ( void *  tls_area)
inlinestatic

Initializes a dynamic thread vector with the area after a given starting address as thread control block.

Use Variant II

Parameters
tls_areaThe tls area for the initialization.
Returns
Pointer to an area that was copied and cleared from tls_block onwards (
See also
_TLS_Copy_and_clear).

Definition at line 272 of file tls.h.

◆ _TLS_TCB_at_area_begin_initialize()

static void* _TLS_TCB_at_area_begin_initialize ( void *  tls_area)
inlinestatic

Initializes a dynamic thread vector beginning at the given starting address.

Use Variant I, TLS offsets emitted by linker takes the TCB into account.

Parameters
tls_areaThe tls area for the initialization.
Returns
Pointer to an area that was copied and cleared from tls_block onwards (
See also
_TLS_Copy_and_clear).

Definition at line 225 of file tls.h.

◆ _TLS_TCB_before_TLS_block_initialize()

static void* _TLS_TCB_before_TLS_block_initialize ( void *  tls_area)
inlinestatic

Initializes a dynamic thread vector with the area before a given starting address as thread control block.

Use Variant I, TLS offsets emitted by linker neglects the TCB.

Parameters
tls_areaThe tls area for the initialization.
Returns
Pointer to an area that was copied and cleared from tls_block onwards (
See also
_TLS_Copy_and_clear).

Definition at line 248 of file tls.h.

Variable Documentation

◆ _TLS_Alignment

char _TLS_Alignment[]

The TLS section alignment.

This symbol is provided by the linker command file as the maximum alignment of the .tdata and .tbss sections. The linker ensures that the first TLS output section is aligned to the maximum alignment of all TLS output sections, see function _bfd_elf_tls_setup() in bfd/elflink.c of the GNU Binutils sources. The linker command file must take into account the case that the .tdata section is empty and the .tbss section is non-empty.