23 #ifndef _RTEMS_SCORE_TLS_H 24 #define _RTEMS_SCORE_TLS_H 26 #include <rtems/score/cpu.h> 47 extern char _TLS_Data_begin[];
49 extern char _TLS_Data_end[];
51 extern char _TLS_Data_size[];
53 extern char _TLS_BSS_begin[];
55 extern char _TLS_BSS_end[];
57 extern char _TLS_BSS_size[];
59 extern char _TLS_Size[];
78 uint32_t generation_number;
88 #if CPU_SIZEOF_POINTER == 4 104 static inline uintptr_t _TLS_Get_size(
void )
113 size = (uintptr_t) _TLS_Size;
125 static inline uintptr_t _TLS_Heap_align_up( uintptr_t val )
127 uintptr_t msk = CPU_HEAP_ALIGNMENT - 1;
129 return (val + msk) & ~msk;
140 static inline uintptr_t _TLS_Get_thread_control_block_area_size(
163 static inline void *_TLS_Copy_and_clear(
void *tls_area )
168 (
size_t) ((uintptr_t)_TLS_Data_size)
173 (
char *) tls_area + (
size_t)((intptr_t) _TLS_BSS_begin) -
174 (
size_t)((intptr_t) _TLS_Data_begin),
176 ((
size_t) (intptr_t)_TLS_BSS_size)
192 static inline void *_TLS_Initialize(
203 dtv->generation_number = 1;
204 dtv->tls_blocks[0] = tls_block;
207 return _TLS_Copy_and_clear( tls_block );
221 static inline void *_TLS_TCB_at_area_begin_initialize(
void *tls_area )
223 void *tls_block = (
char *) tls_area
224 + _TLS_Get_thread_control_block_area_size( (uintptr_t)
_TLS_Alignment );
226 uintptr_t aligned_size = _TLS_Heap_align_up( (uintptr_t) _TLS_Size );
228 ((
char *) tls_block + aligned_size);
230 return _TLS_Initialize( tls_block, tcb, dtv );
244 static inline void *_TLS_TCB_before_TLS_block_initialize(
void *tls_area )
246 void *tls_block = (
char *) tls_area
247 + _TLS_Get_thread_control_block_area_size( (uintptr_t)
_TLS_Alignment );
249 ((
char *) tls_block -
sizeof(*tcb));
250 uintptr_t aligned_size = _TLS_Heap_align_up( (uintptr_t) _TLS_Size );
252 ((
char *) tls_block + aligned_size);
254 return _TLS_Initialize( tls_block, tcb, dtv );
268 static inline void *_TLS_TCB_after_TLS_block_initialize(
void *tls_area )
270 uintptr_t
size = (uintptr_t) _TLS_Size;
272 uintptr_t tls_mask = tls_align - 1;
273 uintptr_t heap_align = _TLS_Heap_align_up( tls_align );
274 uintptr_t heap_mask = heap_align - 1;
276 ((
char *) tls_area + ((
size + heap_mask) & ~heap_mask));
277 void *tls_block = (
char *) tcb - ((
size + tls_mask) & ~tls_mask);
279 ((
char *) tcb +
sizeof(*tcb));
281 _TLS_Initialize( tls_block, tcb, dtv );
uintptr_t _TLS_Get_allocation_size(void)
Return the TLS area allocation size.
Definition: tlsallocsize.c:36
#define RTEMS_OBFUSCATE_VARIABLE(_var)
Obfuscates the variable so that the compiler cannot perform optimizations based on the variable value...
Definition: basedefs.h:311
char _TLS_Alignment[]
The TLS section alignment.
unsigned size
Definition: tte.h:74