|
102 | 102 | #endif
|
103 | 103 | #endif /* if ( configUSE_NEWLIB_REENTRANT == 1 ) */
|
104 | 104 |
|
| 105 | +#if ( configUSE_PICOLIBC_TLS == 1) |
| 106 | + |
| 107 | + /* Use picolibc TLS support to allocate space for __thread variables, |
| 108 | + * initialize them at thread creation and set the TLS context at |
| 109 | + * thread switch time. |
| 110 | + * |
| 111 | + * See the picolibc TLS docs: |
| 112 | + * https://github.com/picolibc/picolibc/blob/main/doc/tls.md |
| 113 | + * for additional information. */ |
| 114 | + #include <picotls.h> |
| 115 | + |
| 116 | + #define configUSE_C_RUNTIME_TLS_SUPPORT 1 |
| 117 | + |
| 118 | + #define configTLS_BLOCK_TYPE void * |
| 119 | + |
| 120 | + /* Allocate thread local storage block off the end of the |
| 121 | + * stack. The _tls_size() function returns the size (in |
| 122 | + * bytes) of the total TLS area used by the application */ |
| 123 | + #if ( portSTACK_GROWTH < 0 ) |
| 124 | + #define configINIT_TLS_BLOCK( xTLSBlock ) do { \ |
| 125 | + pxTopOfStack = ( StackType_t *) ( ( ( portPOINTER_SIZE_TYPE) pxTopOfStack) - _tls_size() ); \ |
| 126 | + xTLSBlock = pxTopOfStack; \ |
| 127 | + _init_tls( xTLSBlock ); \ |
| 128 | + } while(0) |
| 129 | + #else /* portSTACK_GROWTH */ |
| 130 | + #define configINIT_TLS_BLOCK( xTLSBlock ) do { \ |
| 131 | + xTLSBlock = pxTopOfStack; \ |
| 132 | + pxTopOfStack = ( StackType_t *) ( ( ( portPOINTER_SIZE_TYPE) pxTopOfStack) + _tls_size() ); \ |
| 133 | + _init_tls(xTLSBlock); \ |
| 134 | + } while(0) |
| 135 | + #endif /* portSTACK_GROWTH */ |
| 136 | + |
| 137 | + #define configSET_TLS_BLOCK( xTLSBlock ) _set_tls( xTLSBlock ) |
| 138 | + |
| 139 | + #define configDEINIT_TLS_BLOCK( xTLSBlock ) |
| 140 | +#endif |
| 141 | + |
105 | 142 | #ifndef configUSE_C_RUNTIME_TLS_SUPPORT
|
106 | 143 | #define configUSE_C_RUNTIME_TLS_SUPPORT 0
|
107 | 144 | #endif
|
|
0 commit comments