diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2017-06-09 15:42:36 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2017-06-12 08:01:58 +0200 |
commit | 7b0c74ffb085656d67554102857224223ee03f88 (patch) | |
tree | d2cf69f695da218e67c6c5cb7d26f82c3fc967be /cpukit/score/include/rtems/score/tls.h | |
parent | i386: Move _CPU_Context_Initialize() (diff) | |
download | rtems-7b0c74ffb085656d67554102857224223ee03f88.tar.bz2 |
i386: Support thread-local storage (TLS)
Update #2468.
Diffstat (limited to '')
-rw-r--r-- | cpukit/score/include/rtems/score/tls.h | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/cpukit/score/include/rtems/score/tls.h b/cpukit/score/include/rtems/score/tls.h index 51398a0a35..644e54e6f7 100644 --- a/cpukit/score/include/rtems/score/tls.h +++ b/cpukit/score/include/rtems/score/tls.h @@ -70,9 +70,13 @@ typedef struct { void *tls_blocks[1]; } TLS_Dynamic_thread_vector; -typedef struct { +typedef struct TLS_Thread_control_block { +#ifdef __i386__ + struct TLS_Thread_control_block *tcb; +#else TLS_Dynamic_thread_vector *dtv; uintptr_t reserved; +#endif } TLS_Thread_control_block; typedef struct { @@ -109,10 +113,16 @@ static inline uintptr_t _TLS_Get_allocation_size( uintptr_t alignment ) { - uintptr_t aligned_size = _TLS_Heap_align_up( size ); + uintptr_t allocation_size = 0; + + allocation_size += _TLS_Heap_align_up( size ); + allocation_size += _TLS_Get_thread_control_block_area_size( alignment ); + +#ifndef __i386__ + allocation_size += sizeof(TLS_Dynamic_thread_vector); +#endif - return _TLS_Get_thread_control_block_area_size( alignment ) - + aligned_size + sizeof(TLS_Dynamic_thread_vector); + return allocation_size; } static inline void *_TLS_Copy_and_clear( void *tls_area ) @@ -140,9 +150,14 @@ static inline void *_TLS_Initialize( TLS_Dynamic_thread_vector *dtv ) { +#ifdef __i386__ + (void) dtv; + tcb->tcb = tcb; +#else tcb->dtv = dtv; dtv->generation_number = 1; dtv->tls_blocks[0] = tls_block; +#endif return _TLS_Copy_and_clear( tls_block ); } |