libc/tls: Supports up to 64 elements
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
This commit is contained in:
parent
037d5038f9
commit
18227cbeff
@ -67,8 +67,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#if CONFIG_TLS_NELEM > 0
|
#if CONFIG_TLS_NELEM > 0
|
||||||
# if CONFIG_TLS_NELEM > 32
|
# if CONFIG_TLS_NELEM > 64
|
||||||
# error Too many TLS elements
|
# error Too many TLS elements
|
||||||
|
# elif CONFIG_TLS_NELEM > 32
|
||||||
|
typedef uint64_t tls_ndxset_t;
|
||||||
# elif CONFIG_TLS_NELEM > 16
|
# elif CONFIG_TLS_NELEM > 16
|
||||||
typedef uint32_t tls_ndxset_t;
|
typedef uint32_t tls_ndxset_t;
|
||||||
# elif CONFIG_TLS_NELEM > 8
|
# elif CONFIG_TLS_NELEM > 8
|
||||||
|
@ -46,6 +46,7 @@ config TLS_LOG2_MAXSTACK
|
|||||||
config TLS_NELEM
|
config TLS_NELEM
|
||||||
int "Number of TLS elements"
|
int "Number of TLS elements"
|
||||||
default 4
|
default 4
|
||||||
|
range 0 64
|
||||||
---help---
|
---help---
|
||||||
The number of unique TLS elements. These can be accessed with
|
The number of unique TLS elements. These can be accessed with
|
||||||
the user library functions tls_get_value() and tls_set_value()
|
the user library functions tls_get_value() and tls_set_value()
|
||||||
|
@ -80,7 +80,7 @@ int tls_alloc(CODE void (*dtor)(FAR void *))
|
|||||||
{
|
{
|
||||||
/* Is this candidate index available? */
|
/* 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)
|
if ((info->ta_tlsset & mask) == 0)
|
||||||
{
|
{
|
||||||
/* Yes.. allocate the index and break out of the loop */
|
/* Yes.. allocate the index and break out of the loop */
|
||||||
|
@ -65,7 +65,7 @@ void tls_destruct(void)
|
|||||||
{
|
{
|
||||||
/* Is this candidate index available? */
|
/* Is this candidate index available? */
|
||||||
|
|
||||||
tls_ndxset_t mask = (1 << candidate);
|
tls_ndxset_t mask = (tls_ndxset_t)1 << candidate;
|
||||||
if (tlsset & mask)
|
if (tlsset & mask)
|
||||||
{
|
{
|
||||||
tls_elem_ptr = (FAR void *)tls->tl_elem[candidate];
|
tls_elem_ptr = (FAR void *)tls->tl_elem[candidate];
|
||||||
|
Loading…
Reference in New Issue
Block a user