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[];
61 extern char _TLS_Alignment[];
68 uint32_t generation_number;
87 static inline uintptr_t _TLS_Get_size(
void )
93 return (uintptr_t) _TLS_BSS_end - (uintptr_t) _TLS_Data_begin;
96 static inline uintptr_t _TLS_Heap_align_up( uintptr_t val )
98 uintptr_t msk = CPU_HEAP_ALIGNMENT - 1;
100 return (val + msk) & ~msk;
103 static inline uintptr_t _TLS_Get_thread_control_block_area_size(
111 static inline uintptr_t _TLS_Get_allocation_size(
116 uintptr_t allocation_size = 0;
118 allocation_size += _TLS_Heap_align_up( size );
119 allocation_size += _TLS_Get_thread_control_block_area_size( alignment );
125 return allocation_size;
128 static inline void *_TLS_Copy_and_clear(
void *tls_area )
133 (
size_t) ((uintptr_t)_TLS_Data_size)
138 (
char *) tls_area + (
size_t)((intptr_t) _TLS_BSS_begin) -
139 (
size_t)((intptr_t) _TLS_Data_begin),
141 ((
size_t) (intptr_t)_TLS_BSS_size)
147 static inline void *_TLS_Initialize(
158 dtv->generation_number = 1;
159 dtv->tls_blocks[0] = tls_block;
162 return _TLS_Copy_and_clear( tls_block );
166 static inline void *_TLS_TCB_at_area_begin_initialize(
void *tls_area )
168 void *tls_block = (
char *) tls_area
169 + _TLS_Get_thread_control_block_area_size( (uintptr_t) _TLS_Alignment );
171 uintptr_t aligned_size = _TLS_Heap_align_up( (uintptr_t) _TLS_Size );
173 ((
char *) tls_block + aligned_size);
175 return _TLS_Initialize( tls_block, tcb, dtv );
179 static inline void *_TLS_TCB_before_TLS_block_initialize(
void *tls_area )
181 void *tls_block = (
char *) tls_area
182 + _TLS_Get_thread_control_block_area_size( (uintptr_t) _TLS_Alignment );
184 ((
char *) tls_block -
sizeof(*tcb));
185 uintptr_t aligned_size = _TLS_Heap_align_up( (uintptr_t) _TLS_Size );
187 ((
char *) tls_block + aligned_size);
189 return _TLS_Initialize( tls_block, tcb, dtv );
193 static inline void *_TLS_TCB_after_TLS_block_initialize(
void *tls_area )
195 uintptr_t size = (uintptr_t) _TLS_Size;
196 uintptr_t tls_align = (uintptr_t) _TLS_Alignment;
197 uintptr_t tls_mask = tls_align - 1;
198 uintptr_t heap_align = _TLS_Heap_align_up( tls_align );
199 uintptr_t heap_mask = heap_align - 1;
201 ((
char *) tls_area + ((size + heap_mask) & ~heap_mask));
202 void *tls_block = (
char *) tcb - ((size + tls_mask) & ~tls_mask);
204 ((
char *) tcb +
sizeof(*tcb));
206 _TLS_Initialize( tls_block, tcb, dtv );
unsigned size
Definition: tte.h:74