]> begriffs open source - freertos/commit
Generalize Thread Local Storage (TLS) support (#540)
authorGaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
Mon, 8 Aug 2022 15:53:29 +0000 (21:23 +0530)
committerGitHub <noreply@github.com>
Mon, 8 Aug 2022 15:53:29 +0000 (21:23 +0530)
commit95669cc1a177f2ea5c8ab072af395f5cb5dde070
tree315bbae869aa9d5ec38a8840681ab70e8f3bcc4d
parent3b18a0756844a04145d0ffc21f657f0752c3a3cd
Generalize Thread Local Storage (TLS) support (#540)

* Generalize Thread Local Storage (TLS) support

FreeRTOS's Thread Local Storage (TLS) support used variables and
functions from newlib, thereby making the TLS support specific to
newlib. This commit generalizes the TLS support so that it can be used
with other c-runtime libraries also. The default behavior for newlib
support is still kept same for backward compatibility.

The application writer would need to set configUSE_C_RUNTIME_TLS_SUPPORT
to 1 in their FreeRTOSConfig.h and define the following macros to
support TLS for a c-runtime library:

1. configTLS_BLOCK_TYPE - Type used to define the TLS block in TCB.
2. configINIT_TLS_BLOCK( xTLSBlock ) - Allocate and initialize memory
   block for the task's TLS Block.
3. configSET_TLS_BLOCK( xTLSBlock ) - Switch C-Runtime's TLS Block to
   point to xTLSBlock.
4. configDEINIT_TLS_BLOCK( xTLSBlock ) - Free up the memory allocated
   for the task's TLS Block.

The following is an example to support TLS for picolibc:

 #define configUSE_C_RUNTIME_TLS_SUPPORT        1
 #define configTLS_BLOCK_TYPE                   void*
 #define configINIT_TLS_BLOCK( xTLSBlock )      _init_tls( xTLSBlock )
 #define configSET_TLS_BLOCK( xTLSBlock )       _set_tls( xTLSBlock )
 #define configDEINIT_TLS_BLOCK( xTLSBlock )

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
.github/lexicon.txt
include/FreeRTOS.h
tasks.c