Commit 5cb309b
committed
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>1 parent fc61562 commit 5cb309b
2 files changed
Lines changed: 71 additions & 41 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
74 | 83 | | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
75 | 125 | | |
76 | 126 | | |
77 | 127 | | |
| |||
1223 | 1273 | | |
1224 | 1274 | | |
1225 | 1275 | | |
1226 | | - | |
1227 | | - | |
| 1276 | + | |
| 1277 | + | |
1228 | 1278 | | |
1229 | 1279 | | |
1230 | 1280 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
296 | 296 | | |
297 | 297 | | |
298 | 298 | | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
| 299 | + | |
| 300 | + | |
312 | 301 | | |
313 | 302 | | |
314 | 303 | | |
| |||
964 | 953 | | |
965 | 954 | | |
966 | 955 | | |
967 | | - | |
| 956 | + | |
968 | 957 | | |
969 | | - | |
970 | | - | |
971 | | - | |
972 | | - | |
| 958 | + | |
| 959 | + | |
973 | 960 | | |
974 | 961 | | |
975 | 962 | | |
| |||
2038 | 2025 | | |
2039 | 2026 | | |
2040 | 2027 | | |
2041 | | - | |
| 2028 | + | |
2042 | 2029 | | |
2043 | | - | |
2044 | | - | |
2045 | | - | |
2046 | | - | |
2047 | | - | |
| 2030 | + | |
| 2031 | + | |
| 2032 | + | |
2048 | 2033 | | |
2049 | | - | |
| 2034 | + | |
2050 | 2035 | | |
2051 | 2036 | | |
2052 | 2037 | | |
| |||
3078 | 3063 | | |
3079 | 3064 | | |
3080 | 3065 | | |
3081 | | - | |
| 3066 | + | |
3082 | 3067 | | |
3083 | | - | |
3084 | | - | |
3085 | | - | |
3086 | | - | |
3087 | | - | |
| 3068 | + | |
| 3069 | + | |
| 3070 | + | |
3088 | 3071 | | |
3089 | | - | |
| 3072 | + | |
3090 | 3073 | | |
3091 | 3074 | | |
3092 | 3075 | | |
| |||
3958 | 3941 | | |
3959 | 3942 | | |
3960 | 3943 | | |
3961 | | - | |
3962 | | - | |
3963 | | - | |
3964 | | - | |
3965 | | - | |
| 3944 | + | |
3966 | 3945 | | |
3967 | | - | |
| 3946 | + | |
| 3947 | + | |
3968 | 3948 | | |
3969 | | - | |
| 3949 | + | |
3970 | 3950 | | |
3971 | 3951 | | |
3972 | 3952 | | |
| |||
0 commit comments