diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2020-09-10 16:35:09 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2020-09-17 17:42:25 +0200 |
commit | c312f3110ebd6b38c3971910fe034b6c97ebb28c (patch) | |
tree | dcc82c92d7088b1d9c2e12e1ece1f6b705f49a05 /cpukit | |
parent | dce1cdf19e6d8d7c5f72163401171648093d27bb (diff) |
CONFIGURE_MAXIMUM_THREAD_LOCAL_STORAGE_SIZE
Add this application configuration option. This configuration option can be
used to reserve space for the dynamic linking of modules with thread-local
storage objects.
Add RTEMS_TASK_STORAGE_ALIGNMENT to define the minium alignment of a
thread-local storage size.
Update #4074.
Diffstat (limited to 'cpukit')
-rw-r--r-- | cpukit/doxygen/appl-config.h | 37 | ||||
-rw-r--r-- | cpukit/include/rtems/confdefs/threads.h | 7 | ||||
-rw-r--r-- | cpukit/include/rtems/rtems/tasks.h | 9 | ||||
-rw-r--r-- | cpukit/include/rtems/score/interr.h | 3 | ||||
-rw-r--r-- | cpukit/include/rtems/score/thread.h | 10 | ||||
-rw-r--r-- | cpukit/sapi/src/interrtext.c | 5 | ||||
-rw-r--r-- | cpukit/score/src/tlsallocsize.c | 16 |
7 files changed, 81 insertions, 6 deletions
diff --git a/cpukit/doxygen/appl-config.h b/cpukit/doxygen/appl-config.h index cd4664f7c8..47a8e2d39e 100644 --- a/cpukit/doxygen/appl-config.h +++ b/cpukit/doxygen/appl-config.h @@ -804,6 +804,43 @@ /** * @brief This configuration option is an integer define. * + * If the value of this configuration option is greater than zero, then it + * defines the maximum thread-local storage size, otherwise the thread-local + * storage size is defined by the linker depending on the thread-local storage + * objects used by the application in the statically-linked executable. + * + * @par Default Value + * The default value is 0. + * + * @par Value Constraints + * The value of this configuration option shall be greater than or equal to 0 + * and less than or equal to <a + * href="https://en.cppreference.com/w/c/types/limits">SIZE_MAX</a>. + * + * @par Notes + * @parblock + * This configuration option can be used to reserve space for the dynamic + * linking of modules with thread-local storage objects. + * + * If the thread-local storage size defined by the thread-local storage objects + * used by the application in the statically-linked executable is greater than + * a non-zero value of this configuration option, then a fatal error will occur + * during system initialization. + * + * Use RTEMS_ALIGN_UP() and #RTEMS_TASK_STORAGE_ALIGNMENT to adjust the size to + * meet the minimum alignment requirement of a thread-local storage area. + * + * The actual thread-local storage size is determined when the application + * executable is linked. The ``rtems-exeinfo`` command line tool included in + * the RTEMS Tools can be used to obtain the thread-local storage size and + * alignment of an application executable. + * @endparblock + */ +#define CONFIGURE_MAXIMUM_THREAD_LOCAL_STORAGE_SIZE + +/** + * @brief This configuration option is an integer define. + * * The value of this configuration option defines the maximum number of Classic * API Timers that can be concurrently active. * diff --git a/cpukit/include/rtems/confdefs/threads.h b/cpukit/include/rtems/confdefs/threads.h index 33b8c5cee2..9e34696e61 100644 --- a/cpukit/include/rtems/confdefs/threads.h +++ b/cpukit/include/rtems/confdefs/threads.h @@ -84,6 +84,10 @@ #define CONFIGURE_MAXIMUM_THREAD_NAME_SIZE THREAD_DEFAULT_MAXIMUM_NAME_SIZE #endif +#ifndef CONFIGURE_MAXIMUM_THREAD_LOCAL_STORAGE_SIZE + #define CONFIGURE_MAXIMUM_THREAD_LOCAL_STORAGE_SIZE 0 +#endif + #ifdef __cplusplus extern "C" { #endif @@ -125,6 +129,9 @@ typedef union { const size_t _Thread_Maximum_name_size = CONFIGURE_MAXIMUM_THREAD_NAME_SIZE; +const size_t _Thread_Maximum_TLS_size = + CONFIGURE_MAXIMUM_THREAD_LOCAL_STORAGE_SIZE; + struct Thread_Configured_control { Thread_Control Control; #if CONFIGURE_MAXIMUM_USER_EXTENSIONS > 0 diff --git a/cpukit/include/rtems/rtems/tasks.h b/cpukit/include/rtems/rtems/tasks.h index 12c323e60e..e07db6cd2b 100644 --- a/cpukit/include/rtems/rtems/tasks.h +++ b/cpukit/include/rtems/rtems/tasks.h @@ -165,6 +165,15 @@ rtems_status_code rtems_task_create( ); /** + * @brief This constant defines the recommended alignment of a task storage + * area in bytes. + * + * Use it with RTEMS_ALIGNED() to define the alignment of a statically + * allocated task storage area. + */ +#define RTEMS_TASK_STORAGE_ALIGNMENT CPU_HEAP_ALIGNMENT + +/** * @brief RTEMS Task Name to Id * * This routine implements the rtems_task_ident directive. diff --git a/cpukit/include/rtems/score/interr.h b/cpukit/include/rtems/score/interr.h index 2f449deedb..1371e55653 100644 --- a/cpukit/include/rtems/score/interr.h +++ b/cpukit/include/rtems/score/interr.h @@ -203,7 +203,8 @@ typedef enum { INTERNAL_ERROR_LIBIO_STDERR_FD_OPEN_FAILED = 37, INTERNAL_ERROR_ILLEGAL_USE_OF_FLOATING_POINT_UNIT = 38, INTERNAL_ERROR_ARC4RANDOM_GETENTROPY_FAIL = 39, - INTERNAL_ERROR_NO_MEMORY_FOR_PER_CPU_DATA = 40 + INTERNAL_ERROR_NO_MEMORY_FOR_PER_CPU_DATA = 40, + INTERNAL_ERROR_TOO_LARGE_TLS_SIZE = 41 } Internal_errors_Core_list; typedef CPU_Uint32ptr Internal_errors_t; diff --git a/cpukit/include/rtems/score/thread.h b/cpukit/include/rtems/score/thread.h index 1daf6143f9..1388744548 100644 --- a/cpukit/include/rtems/score/thread.h +++ b/cpukit/include/rtems/score/thread.h @@ -954,6 +954,16 @@ extern const size_t _Thread_Initial_thread_count; extern const size_t _Thread_Maximum_name_size; /** + * @brief If this constant is greater than zero, then it defines the maximum + * thread-local storage size, otherwise the thread-local storage size is defined + * by the linker depending on the thread-local storage objects used by the + * application in the statically-linked executable. + * + * This value is provided via <rtems/confdefs.h>. + */ +extern const size_t _Thread_Maximum_TLS_size; + +/** * @brief The configured thread control block. * * This type is defined in <rtems/confdefs.h> and depends on the application diff --git a/cpukit/sapi/src/interrtext.c b/cpukit/sapi/src/interrtext.c index 2aff34487a..3d49135c44 100644 --- a/cpukit/sapi/src/interrtext.c +++ b/cpukit/sapi/src/interrtext.c @@ -7,7 +7,7 @@ */ /* - * Copyright (c) 2012, 2018 embedded brains GmbH. All rights reserved. + * Copyright (c) 2012, 2020 embedded brains GmbH. All rights reserved. * * embedded brains GmbH * Dornierstr. 4 @@ -67,7 +67,8 @@ static const char *const internal_error_text[] = { "INTERNAL_ERROR_LIBIO_STDERR_FD_OPEN_FAILED", "INTERNAL_ERROR_ILLEGAL_USE_OF_FLOATING_POINT_UNIT", "INTERNAL_ERROR_ARC4RANDOM_GETENTROPY_FAIL", - "INTERNAL_ERROR_NO_MEMORY_FOR_PER_CPU_DATA" + "INTERNAL_ERROR_NO_MEMORY_FOR_PER_CPU_DATA", + "INTERNAL_ERROR_TOO_LARGE_TLS_SIZE" }; const char *rtems_internal_error_text( rtems_fatal_code error ) diff --git a/cpukit/score/src/tlsallocsize.c b/cpukit/score/src/tlsallocsize.c index 8fa5600602..a9f0c0cd23 100644 --- a/cpukit/score/src/tlsallocsize.c +++ b/cpukit/score/src/tlsallocsize.c @@ -1,7 +1,7 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /* - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (C) 2014, 2019 embedded brains GmbH + * Copyright (C) 2014, 2020 embedded brains GmbH (http://www.embedded-brains.de) * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -30,6 +30,8 @@ #endif #include <rtems/score/tls.h> +#include <rtems/score/interr.h> +#include <rtems/score/thread.h> static uintptr_t _TLS_Allocation_size; @@ -65,6 +67,14 @@ uintptr_t _TLS_Get_allocation_size( void ) allocation_size += sizeof(TLS_Dynamic_thread_vector); #endif + if ( _Thread_Maximum_TLS_size != 0 ) { + if ( allocation_size <= _Thread_Maximum_TLS_size ) { + allocation_size = _Thread_Maximum_TLS_size; + } else { + _Internal_error( INTERNAL_ERROR_TOO_LARGE_TLS_SIZE ); + } + } + _TLS_Allocation_size = allocation_size; } |