Skip to content

Commit

Permalink
TLS: Add configRESET_TLS_BLOCK macro to reset TLS to default value
Browse files Browse the repository at this point in the history
Useful when calling libc functions in exception handlers.
  • Loading branch information
paulbartell committed Apr 25, 2023
1 parent 02718f1 commit f3afb95
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
12 changes: 8 additions & 4 deletions include/FreeRTOS.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,19 +117,23 @@
#if ( configUSE_C_RUNTIME_TLS_SUPPORT == 1 )

#ifndef configTLS_BLOCK_TYPE
#error Missing definition: configTLS_BLOCK_TYPE must be defined in FreeRTOSConfig.h when configUSE_C_RUNTIME_TLS_SUPPORT is set to 1.
#error Missing definition: configTLS_BLOCK_TYPE must be defined when configUSE_C_RUNTIME_TLS_SUPPORT is set to 1.
#endif

#ifndef configINIT_TLS_BLOCK
#error Missing definition: configINIT_TLS_BLOCK must be defined in FreeRTOSConfig.h when configUSE_C_RUNTIME_TLS_SUPPORT is set to 1.
#error Missing definition: configINIT_TLS_BLOCK must be defined when configUSE_C_RUNTIME_TLS_SUPPORT is set to 1.
#endif

#ifndef configSET_TLS_BLOCK
#error Missing definition: configSET_TLS_BLOCK must be defined in FreeRTOSConfig.h when configUSE_C_RUNTIME_TLS_SUPPORT is set to 1.
#error Missing definition: configSET_TLS_BLOCK must be defined when configUSE_C_RUNTIME_TLS_SUPPORT is set to 1.
#endif

#ifndef configRESET_TLS_BLOCK
#error Missing definition: configRESET_TLS_BLOCK must be defined when configUSE_C_RUNTIME_TLS_SUPPORT is set to 1.
#endif

#ifndef configDEINIT_TLS_BLOCK
#error Missing definition: configDEINIT_TLS_BLOCK must be defined in FreeRTOSConfig.h when configUSE_C_RUNTIME_TLS_SUPPORT is set to 1.
#error Missing definition: configDEINIT_TLS_BLOCK must be defined when configUSE_C_RUNTIME_TLS_SUPPORT is set to 1.
#endif
#endif /* if ( configUSE_C_RUNTIME_TLS_SUPPORT == 1 ) */

Expand Down
9 changes: 9 additions & 0 deletions include/newlib-freertos.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@
while( 0 )
#endif /* configSET_TLS_BLOCK */

#ifndef configRESET_TLS_BLOCK
#define configRESET_TLS_BLOCK() \
do \
{ \
_impure_ptr = _global_impure_ptr; \
} \
while( 0 )
#endif /* configRESET_TLS_BLOCK */

#ifndef configDEINIT_TLS_BLOCK
#define configDEINIT_TLS_BLOCK( xTLSBlock ) \
do \
Expand Down
4 changes: 4 additions & 0 deletions include/picolibc-freertos.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@
#define configSET_TLS_BLOCK( xTLSBlock ) _set_tls( xTLSBlock )
#endif /* configSET_TLS_BLOCK */

#ifndef configRESET_TLS_BLOCK
#define configRESET_TLS_BLOCK( xTLSBlock )
#endif /* configRESET_TLS_BLOCK */

#ifndef configDEINIT_TLS_BLOCK
#define configDEINIT_TLS_BLOCK( xTLSBlock )
#endif /* configDEINIT_TLS_BLOCK */
Expand Down

0 comments on commit f3afb95

Please sign in to comment.