libc/tls: Supports up to 64 elements

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
This commit is contained in:
Huang Qi 2022-02-19 09:39:30 +08:00 committed by Xiang Xiao
parent 037d5038f9
commit 18227cbeff
4 changed files with 6 additions and 3 deletions

View File

@ -67,8 +67,10 @@
*/
#if CONFIG_TLS_NELEM > 0
# if CONFIG_TLS_NELEM > 32
# if CONFIG_TLS_NELEM > 64
# error Too many TLS elements
# elif CONFIG_TLS_NELEM > 32
typedef uint64_t tls_ndxset_t;
# elif CONFIG_TLS_NELEM > 16
typedef uint32_t tls_ndxset_t;
# elif CONFIG_TLS_NELEM > 8

View File

@ -46,6 +46,7 @@ config TLS_LOG2_MAXSTACK
config TLS_NELEM
int "Number of TLS elements"
default 4
range 0 64
---help---
The number of unique TLS elements. These can be accessed with
the user library functions tls_get_value() and tls_set_value()

View File

@ -80,7 +80,7 @@ int tls_alloc(CODE void (*dtor)(FAR void *))
{
/* Is this candidate index available? */
tls_ndxset_t mask = (1 << candidate);
tls_ndxset_t mask = (tls_ndxset_t)1 << candidate;
if ((info->ta_tlsset & mask) == 0)
{
/* Yes.. allocate the index and break out of the loop */

View File

@ -65,7 +65,7 @@ void tls_destruct(void)
{
/* Is this candidate index available? */
tls_ndxset_t mask = (1 << candidate);
tls_ndxset_t mask = (tls_ndxset_t)1 << candidate;
if (tlsset & mask)
{
tls_elem_ptr = (FAR void *)tls->tl_elem[candidate];