From 7b0c74ffb085656d67554102857224223ee03f88 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 9 Jun 2017 15:42:36 +0200 Subject: i386: Support thread-local storage (TLS) Update #2468. --- cpukit/score/include/rtems/score/tls.h | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'cpukit/score/include/rtems/score/tls.h') 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 ); } -- cgit v1.2.3