diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-04-07 16:50:13 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-04-09 15:30:25 +0200 |
commit | 6cf45cbeef58697af3349299f3fd717133eae5ed (patch) | |
tree | 3a33bf77880608b1513c6c1e6e97405125f98b74 /cpukit/score/src/wkspace.c | |
parent | sptests/sp37: Account for internal struct align (diff) | |
download | rtems-6cf45cbeef58697af3349299f3fd717133eae5ed.tar.bz2 |
score: Fix workspace size estimate for TLS
Diffstat (limited to 'cpukit/score/src/wkspace.c')
-rw-r--r-- | cpukit/score/src/wkspace.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/cpukit/score/src/wkspace.c b/cpukit/score/src/wkspace.c index 071c178758..20e2563287 100644 --- a/cpukit/score/src/wkspace.c +++ b/cpukit/score/src/wkspace.c @@ -67,11 +67,18 @@ void _Workspace_Handler_initialization( size_t i; if ( tls_size > 0 ) { - uintptr_t tls_alignment = (uintptr_t) _TLS_Alignment; - uintptr_t tls_alloc = _TLS_Get_allocation_size( tls_size, tls_alignment ); + uintptr_t tls_align = _TLS_Heap_align_up( (uintptr_t) _TLS_Alignment ); + uintptr_t tls_alloc = _TLS_Get_allocation_size( tls_size, tls_align ); + + /* + * Memory allocated with an alignment constraint is allocated from the end + * of a free block. The last allocation may need one free block of minimum + * size. + */ + remaining += _Heap_Min_block_size( page_size ); remaining += _Get_maximum_thread_count() - * _Heap_Size_with_overhead( page_size, tls_alloc, tls_alignment ); + * _Heap_Size_with_overhead( page_size, tls_alloc, tls_align ); } for (i = 0; i < area_count; ++i) { |