mirror of
https://github.com/apache/nuttx.git
synced 2026-05-30 21:36:28 +08:00
Move pthread-specific data into TLS
1. Move pthread-specific data files from sched/pthread/ to libs/libc/pthread. 2. Remove pthread-specific data functions from syscalls. 3. Implement tls_alloc() and tls_free() with system calls. 4. Reimplement pthread_key_create() and pthread_key_free() using tls_alloc() and tls_free(). 5. Reimplement pthread_set_specific() and pthread_get_specicif() using tls_set_value() and tls_get_value()
This commit is contained in:
committed by
Abdelatif Guettouche
parent
a6c82a27db
commit
9ce03b1660
@@ -35,7 +35,7 @@ CONFIG_MM_SMALL=y
|
|||||||
CONFIG_MOTOROLA_SREC=y
|
CONFIG_MOTOROLA_SREC=y
|
||||||
CONFIG_NFILE_DESCRIPTORS=6
|
CONFIG_NFILE_DESCRIPTORS=6
|
||||||
CONFIG_NFILE_STREAMS=6
|
CONFIG_NFILE_STREAMS=6
|
||||||
CONFIG_NPTHREAD_KEYS=0
|
CONFIG_TLS_NELEM=0
|
||||||
CONFIG_NSH_BUILTIN_APPS=y
|
CONFIG_NSH_BUILTIN_APPS=y
|
||||||
CONFIG_NSH_DISABLE_CD=y
|
CONFIG_NSH_DISABLE_CD=y
|
||||||
CONFIG_NSH_DISABLE_CP=y
|
CONFIG_NSH_DISABLE_CP=y
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ CONFIG_MM_SMALL=y
|
|||||||
CONFIG_MOTOROLA_SREC=y
|
CONFIG_MOTOROLA_SREC=y
|
||||||
CONFIG_NFILE_DESCRIPTORS=6
|
CONFIG_NFILE_DESCRIPTORS=6
|
||||||
CONFIG_NFILE_STREAMS=6
|
CONFIG_NFILE_STREAMS=6
|
||||||
CONFIG_NPTHREAD_KEYS=0
|
CONFIG_TLS_NELEM=0
|
||||||
CONFIG_NSH_BUILTIN_APPS=y
|
CONFIG_NSH_BUILTIN_APPS=y
|
||||||
CONFIG_NSH_DISABLE_CD=y
|
CONFIG_NSH_DISABLE_CD=y
|
||||||
CONFIG_NSH_DISABLE_CP=y
|
CONFIG_NSH_DISABLE_CP=y
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ CONFIG_MAX_WDOGPARMS=2
|
|||||||
CONFIG_MM_SMALL=y
|
CONFIG_MM_SMALL=y
|
||||||
CONFIG_NFILE_DESCRIPTORS=6
|
CONFIG_NFILE_DESCRIPTORS=6
|
||||||
CONFIG_NFILE_STREAMS=6
|
CONFIG_NFILE_STREAMS=6
|
||||||
CONFIG_NPTHREAD_KEYS=0
|
CONFIG_TLS_NELEM=0
|
||||||
CONFIG_NSH_BUILTIN_APPS=y
|
CONFIG_NSH_BUILTIN_APPS=y
|
||||||
CONFIG_NSH_DISABLE_CD=y
|
CONFIG_NSH_DISABLE_CD=y
|
||||||
CONFIG_NSH_DISABLE_CP=y
|
CONFIG_NSH_DISABLE_CP=y
|
||||||
|
|||||||
@@ -836,7 +836,7 @@ Configurations
|
|||||||
CONFIG_DISABLE_POSIX_TIMERS=y
|
CONFIG_DISABLE_POSIX_TIMERS=y
|
||||||
CONFIG_DISABLE_PTHREAD=y
|
CONFIG_DISABLE_PTHREAD=y
|
||||||
CONFIG_MQ_MAXMSGSIZE=0
|
CONFIG_MQ_MAXMSGSIZE=0
|
||||||
CONFIG_NPTHREAD_KEYS=0
|
CONFIG_TLS_NELEM=0
|
||||||
CONFIG_NUNGET_CHARS=0
|
CONFIG_NUNGET_CHARS=0
|
||||||
CONFIG_PREALLOC_MQ_MSGS=0
|
CONFIG_PREALLOC_MQ_MSGS=0
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ CONFIG_MAX_WDOGPARMS=2
|
|||||||
CONFIG_MM_SMALL=y
|
CONFIG_MM_SMALL=y
|
||||||
CONFIG_NFILE_DESCRIPTORS=6
|
CONFIG_NFILE_DESCRIPTORS=6
|
||||||
CONFIG_NFILE_STREAMS=6
|
CONFIG_NFILE_STREAMS=6
|
||||||
CONFIG_NPTHREAD_KEYS=0
|
CONFIG_TLS_NELEM=0
|
||||||
CONFIG_NSH_DISABLE_CD=y
|
CONFIG_NSH_DISABLE_CD=y
|
||||||
CONFIG_NSH_DISABLE_CP=y
|
CONFIG_NSH_DISABLE_CP=y
|
||||||
CONFIG_NSH_DISABLE_MKDIR=y
|
CONFIG_NSH_DISABLE_MKDIR=y
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ CONFIG_MM_SMALL=y
|
|||||||
CONFIG_MOTOROLA_SREC=y
|
CONFIG_MOTOROLA_SREC=y
|
||||||
CONFIG_NFILE_DESCRIPTORS=6
|
CONFIG_NFILE_DESCRIPTORS=6
|
||||||
CONFIG_NFILE_STREAMS=6
|
CONFIG_NFILE_STREAMS=6
|
||||||
CONFIG_NPTHREAD_KEYS=0
|
CONFIG_TLS_NELEM=0
|
||||||
CONFIG_NSH_ARCHINIT=y
|
CONFIG_NSH_ARCHINIT=y
|
||||||
CONFIG_NSH_DISABLE_CD=y
|
CONFIG_NSH_DISABLE_CD=y
|
||||||
CONFIG_NSH_DISABLE_CP=y
|
CONFIG_NSH_DISABLE_CP=y
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ CONFIG_MAX_TASKS=8
|
|||||||
CONFIG_MAX_WDOGPARMS=2
|
CONFIG_MAX_WDOGPARMS=2
|
||||||
CONFIG_NFILE_DESCRIPTORS=6
|
CONFIG_NFILE_DESCRIPTORS=6
|
||||||
CONFIG_NFILE_STREAMS=6
|
CONFIG_NFILE_STREAMS=6
|
||||||
CONFIG_NPTHREAD_KEYS=0
|
CONFIG_TLS_NELEM=0
|
||||||
CONFIG_NSH_BUILTIN_APPS=y
|
CONFIG_NSH_BUILTIN_APPS=y
|
||||||
CONFIG_NSH_FILEIOSIZE=64
|
CONFIG_NSH_FILEIOSIZE=64
|
||||||
CONFIG_NSH_LINELEN=64
|
CONFIG_NSH_LINELEN=64
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ CONFIG_MM_SMALL=y
|
|||||||
CONFIG_NAME_MAX=8
|
CONFIG_NAME_MAX=8
|
||||||
CONFIG_NFILE_DESCRIPTORS=5
|
CONFIG_NFILE_DESCRIPTORS=5
|
||||||
CONFIG_NFILE_STREAMS=5
|
CONFIG_NFILE_STREAMS=5
|
||||||
CONFIG_NPTHREAD_KEYS=0
|
CONFIG_TLS_NELEM=0
|
||||||
CONFIG_NSH_ARCHINIT=y
|
CONFIG_NSH_ARCHINIT=y
|
||||||
CONFIG_NSH_BUILTIN_APPS=y
|
CONFIG_NSH_BUILTIN_APPS=y
|
||||||
CONFIG_NSH_CODECS_BUFSIZE=0
|
CONFIG_NSH_CODECS_BUFSIZE=0
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ CONFIG_MM_SMALL=y
|
|||||||
CONFIG_NAME_MAX=8
|
CONFIG_NAME_MAX=8
|
||||||
CONFIG_NFILE_DESCRIPTORS=5
|
CONFIG_NFILE_DESCRIPTORS=5
|
||||||
CONFIG_NFILE_STREAMS=5
|
CONFIG_NFILE_STREAMS=5
|
||||||
CONFIG_NPTHREAD_KEYS=0
|
CONFIG_TLS_NELEM=0
|
||||||
CONFIG_NSH_ARCHINIT=y
|
CONFIG_NSH_ARCHINIT=y
|
||||||
CONFIG_NSH_BUILTIN_APPS=y
|
CONFIG_NSH_BUILTIN_APPS=y
|
||||||
CONFIG_NSH_CODECS_BUFSIZE=0
|
CONFIG_NSH_CODECS_BUFSIZE=0
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ CONFIG_MM_SMALL=y
|
|||||||
CONFIG_NAME_MAX=8
|
CONFIG_NAME_MAX=8
|
||||||
CONFIG_NFILE_DESCRIPTORS=5
|
CONFIG_NFILE_DESCRIPTORS=5
|
||||||
CONFIG_NFILE_STREAMS=5
|
CONFIG_NFILE_STREAMS=5
|
||||||
CONFIG_NPTHREAD_KEYS=0
|
CONFIG_TLS_NELEM=0
|
||||||
CONFIG_NSH_ARCHINIT=y
|
CONFIG_NSH_ARCHINIT=y
|
||||||
CONFIG_NSH_BUILTIN_APPS=y
|
CONFIG_NSH_BUILTIN_APPS=y
|
||||||
CONFIG_NSH_CODECS_BUFSIZE=0
|
CONFIG_NSH_CODECS_BUFSIZE=0
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ CONFIG_MM_SMALL=y
|
|||||||
CONFIG_NAME_MAX=8
|
CONFIG_NAME_MAX=8
|
||||||
CONFIG_NFILE_DESCRIPTORS=5
|
CONFIG_NFILE_DESCRIPTORS=5
|
||||||
CONFIG_NFILE_STREAMS=5
|
CONFIG_NFILE_STREAMS=5
|
||||||
CONFIG_NPTHREAD_KEYS=0
|
CONFIG_TLS_NELEM=0
|
||||||
CONFIG_NSH_ARCHINIT=y
|
CONFIG_NSH_ARCHINIT=y
|
||||||
CONFIG_NSH_BUILTIN_APPS=y
|
CONFIG_NSH_BUILTIN_APPS=y
|
||||||
CONFIG_NSH_CODECS_BUFSIZE=0
|
CONFIG_NSH_CODECS_BUFSIZE=0
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ CONFIG_MM_SMALL=y
|
|||||||
CONFIG_NAME_MAX=8
|
CONFIG_NAME_MAX=8
|
||||||
CONFIG_NFILE_DESCRIPTORS=5
|
CONFIG_NFILE_DESCRIPTORS=5
|
||||||
CONFIG_NFILE_STREAMS=5
|
CONFIG_NFILE_STREAMS=5
|
||||||
CONFIG_NPTHREAD_KEYS=0
|
CONFIG_TLS_NELEM=0
|
||||||
CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=768
|
CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=768
|
||||||
CONFIG_PREALLOC_MQ_MSGS=4
|
CONFIG_PREALLOC_MQ_MSGS=4
|
||||||
CONFIG_PREALLOC_TIMERS=2
|
CONFIG_PREALLOC_TIMERS=2
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ CONFIG_MAX_WDOGPARMS=2
|
|||||||
CONFIG_MM_SMALL=y
|
CONFIG_MM_SMALL=y
|
||||||
CONFIG_NFILE_DESCRIPTORS=6
|
CONFIG_NFILE_DESCRIPTORS=6
|
||||||
CONFIG_NFILE_STREAMS=6
|
CONFIG_NFILE_STREAMS=6
|
||||||
CONFIG_NPTHREAD_KEYS=0
|
CONFIG_TLS_NELEM=0
|
||||||
CONFIG_NSH_ARCHINIT=y
|
CONFIG_NSH_ARCHINIT=y
|
||||||
CONFIG_NSH_BUILTIN_APPS=y
|
CONFIG_NSH_BUILTIN_APPS=y
|
||||||
CONFIG_NSH_DISABLE_CD=y
|
CONFIG_NSH_DISABLE_CD=y
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ CONFIG_MAX_WDOGPARMS=2
|
|||||||
CONFIG_MM_SMALL=y
|
CONFIG_MM_SMALL=y
|
||||||
CONFIG_NFILE_DESCRIPTORS=6
|
CONFIG_NFILE_DESCRIPTORS=6
|
||||||
CONFIG_NFILE_STREAMS=6
|
CONFIG_NFILE_STREAMS=6
|
||||||
CONFIG_NPTHREAD_KEYS=0
|
CONFIG_TLS_NELEM=0
|
||||||
CONFIG_NSH_DISABLE_CD=y
|
CONFIG_NSH_DISABLE_CD=y
|
||||||
CONFIG_NSH_DISABLE_CP=y
|
CONFIG_NSH_DISABLE_CP=y
|
||||||
CONFIG_NSH_DISABLE_MKDIR=y
|
CONFIG_NSH_DISABLE_MKDIR=y
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ CONFIG_MAX_TASKS=8
|
|||||||
CONFIG_MAX_WDOGPARMS=2
|
CONFIG_MAX_WDOGPARMS=2
|
||||||
CONFIG_NFILE_DESCRIPTORS=6
|
CONFIG_NFILE_DESCRIPTORS=6
|
||||||
CONFIG_NFILE_STREAMS=6
|
CONFIG_NFILE_STREAMS=6
|
||||||
CONFIG_NPTHREAD_KEYS=0
|
CONFIG_TLS_NELEM=0
|
||||||
CONFIG_NSH_ARCHINIT=y
|
CONFIG_NSH_ARCHINIT=y
|
||||||
CONFIG_NSH_BUILTIN_APPS=y
|
CONFIG_NSH_BUILTIN_APPS=y
|
||||||
CONFIG_NSH_FILEIOSIZE=64
|
CONFIG_NSH_FILEIOSIZE=64
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ CONFIG_MAX_TASKS=8
|
|||||||
CONFIG_MAX_WDOGPARMS=2
|
CONFIG_MAX_WDOGPARMS=2
|
||||||
CONFIG_NFILE_DESCRIPTORS=6
|
CONFIG_NFILE_DESCRIPTORS=6
|
||||||
CONFIG_NFILE_STREAMS=6
|
CONFIG_NFILE_STREAMS=6
|
||||||
CONFIG_NPTHREAD_KEYS=0
|
CONFIG_TLS_NELEM=0
|
||||||
CONFIG_NSH_BUILTIN_APPS=y
|
CONFIG_NSH_BUILTIN_APPS=y
|
||||||
CONFIG_NSH_FILEIOSIZE=64
|
CONFIG_NSH_FILEIOSIZE=64
|
||||||
CONFIG_NSH_LINELEN=64
|
CONFIG_NSH_LINELEN=64
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ CONFIG_MAX_WDOGPARMS=2
|
|||||||
CONFIG_MQ_MAXMSGSIZE=64
|
CONFIG_MQ_MAXMSGSIZE=64
|
||||||
CONFIG_NFILE_DESCRIPTORS=6
|
CONFIG_NFILE_DESCRIPTORS=6
|
||||||
CONFIG_NFILE_STREAMS=6
|
CONFIG_NFILE_STREAMS=6
|
||||||
CONFIG_NPTHREAD_KEYS=0
|
CONFIG_TLS_NELEM=0
|
||||||
CONFIG_NSH_ARCHINIT=y
|
CONFIG_NSH_ARCHINIT=y
|
||||||
CONFIG_NSH_BUILTIN_APPS=y
|
CONFIG_NSH_BUILTIN_APPS=y
|
||||||
CONFIG_NSH_FILEIOSIZE=64
|
CONFIG_NSH_FILEIOSIZE=64
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ CONFIG_MAX_TASKS=8
|
|||||||
CONFIG_MAX_WDOGPARMS=2
|
CONFIG_MAX_WDOGPARMS=2
|
||||||
CONFIG_NFILE_DESCRIPTORS=6
|
CONFIG_NFILE_DESCRIPTORS=6
|
||||||
CONFIG_NFILE_STREAMS=6
|
CONFIG_NFILE_STREAMS=6
|
||||||
CONFIG_NPTHREAD_KEYS=0
|
CONFIG_TLS_NELEM=0
|
||||||
CONFIG_NSH_ARCHINIT=y
|
CONFIG_NSH_ARCHINIT=y
|
||||||
CONFIG_NSH_BUILTIN_APPS=y
|
CONFIG_NSH_BUILTIN_APPS=y
|
||||||
CONFIG_NSH_FILEIOSIZE=64
|
CONFIG_NSH_FILEIOSIZE=64
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ CONFIG_MAX_WDOGPARMS=2
|
|||||||
CONFIG_MM_SMALL=y
|
CONFIG_MM_SMALL=y
|
||||||
CONFIG_NFILE_DESCRIPTORS=6
|
CONFIG_NFILE_DESCRIPTORS=6
|
||||||
CONFIG_NFILE_STREAMS=6
|
CONFIG_NFILE_STREAMS=6
|
||||||
CONFIG_NPTHREAD_KEYS=0
|
CONFIG_TLS_NELEM=0
|
||||||
CONFIG_NSH_ARCHINIT=y
|
CONFIG_NSH_ARCHINIT=y
|
||||||
CONFIG_NSH_BUILTIN_APPS=y
|
CONFIG_NSH_BUILTIN_APPS=y
|
||||||
CONFIG_NSH_DISABLE_CP=y
|
CONFIG_NSH_DISABLE_CP=y
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ CONFIG_MAX_WDOGPARMS=2
|
|||||||
CONFIG_MM_SMALL=y
|
CONFIG_MM_SMALL=y
|
||||||
CONFIG_NFILE_DESCRIPTORS=6
|
CONFIG_NFILE_DESCRIPTORS=6
|
||||||
CONFIG_NFILE_STREAMS=6
|
CONFIG_NFILE_STREAMS=6
|
||||||
CONFIG_NPTHREAD_KEYS=0
|
CONFIG_TLS_NELEM=0
|
||||||
CONFIG_NSH_ARCHINIT=y
|
CONFIG_NSH_ARCHINIT=y
|
||||||
CONFIG_NSH_BUILTIN_APPS=y
|
CONFIG_NSH_BUILTIN_APPS=y
|
||||||
CONFIG_NSH_DISABLE_CP=y
|
CONFIG_NSH_DISABLE_CP=y
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ CONFIG_MAX_TASKS=8
|
|||||||
CONFIG_MAX_WDOGPARMS=2
|
CONFIG_MAX_WDOGPARMS=2
|
||||||
CONFIG_NFILE_DESCRIPTORS=6
|
CONFIG_NFILE_DESCRIPTORS=6
|
||||||
CONFIG_NFILE_STREAMS=6
|
CONFIG_NFILE_STREAMS=6
|
||||||
CONFIG_NPTHREAD_KEYS=0
|
CONFIG_TLS_NELEM=0
|
||||||
CONFIG_NSH_ARCHINIT=y
|
CONFIG_NSH_ARCHINIT=y
|
||||||
CONFIG_NSH_BUILTIN_APPS=y
|
CONFIG_NSH_BUILTIN_APPS=y
|
||||||
CONFIG_NSH_FILEIOSIZE=64
|
CONFIG_NSH_FILEIOSIZE=64
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ CONFIG_MAX_TASKS=8
|
|||||||
CONFIG_MAX_WDOGPARMS=2
|
CONFIG_MAX_WDOGPARMS=2
|
||||||
CONFIG_NFILE_DESCRIPTORS=6
|
CONFIG_NFILE_DESCRIPTORS=6
|
||||||
CONFIG_NFILE_STREAMS=6
|
CONFIG_NFILE_STREAMS=6
|
||||||
CONFIG_NPTHREAD_KEYS=0
|
CONFIG_TLS_NELEM=0
|
||||||
CONFIG_NSH_BUILTIN_APPS=y
|
CONFIG_NSH_BUILTIN_APPS=y
|
||||||
CONFIG_NSH_FILEIOSIZE=64
|
CONFIG_NSH_FILEIOSIZE=64
|
||||||
CONFIG_NSH_LINELEN=64
|
CONFIG_NSH_LINELEN=64
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ CONFIG_MAX_TASKS=8
|
|||||||
CONFIG_MAX_WDOGPARMS=2
|
CONFIG_MAX_WDOGPARMS=2
|
||||||
CONFIG_NFILE_DESCRIPTORS=6
|
CONFIG_NFILE_DESCRIPTORS=6
|
||||||
CONFIG_NFILE_STREAMS=6
|
CONFIG_NFILE_STREAMS=6
|
||||||
CONFIG_NPTHREAD_KEYS=0
|
CONFIG_TLS_NELEM=0
|
||||||
CONFIG_NSH_BUILTIN_APPS=y
|
CONFIG_NSH_BUILTIN_APPS=y
|
||||||
CONFIG_NSH_FILEIOSIZE=64
|
CONFIG_NSH_FILEIOSIZE=64
|
||||||
CONFIG_NSH_LINELEN=64
|
CONFIG_NSH_LINELEN=64
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ CONFIG_MAX_TASKS=8
|
|||||||
CONFIG_MAX_WDOGPARMS=2
|
CONFIG_MAX_WDOGPARMS=2
|
||||||
CONFIG_NFILE_DESCRIPTORS=6
|
CONFIG_NFILE_DESCRIPTORS=6
|
||||||
CONFIG_NFILE_STREAMS=6
|
CONFIG_NFILE_STREAMS=6
|
||||||
CONFIG_NPTHREAD_KEYS=0
|
CONFIG_TLS_NELEM=0
|
||||||
CONFIG_NSH_BUILTIN_APPS=y
|
CONFIG_NSH_BUILTIN_APPS=y
|
||||||
CONFIG_NSH_FILEIOSIZE=64
|
CONFIG_NSH_FILEIOSIZE=64
|
||||||
CONFIG_NSH_LINELEN=64
|
CONFIG_NSH_LINELEN=64
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ CONFIG_MAX_TASKS=8
|
|||||||
CONFIG_MAX_WDOGPARMS=2
|
CONFIG_MAX_WDOGPARMS=2
|
||||||
CONFIG_NFILE_DESCRIPTORS=6
|
CONFIG_NFILE_DESCRIPTORS=6
|
||||||
CONFIG_NFILE_STREAMS=6
|
CONFIG_NFILE_STREAMS=6
|
||||||
CONFIG_NPTHREAD_KEYS=0
|
CONFIG_TLS_NELEM=0
|
||||||
CONFIG_NSH_ARCHINIT=y
|
CONFIG_NSH_ARCHINIT=y
|
||||||
CONFIG_NSH_BUILTIN_APPS=y
|
CONFIG_NSH_BUILTIN_APPS=y
|
||||||
CONFIG_NSH_FILEIOSIZE=64
|
CONFIG_NSH_FILEIOSIZE=64
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ CONFIG_MAX_WDOGPARMS=2
|
|||||||
CONFIG_MM_SMALL=y
|
CONFIG_MM_SMALL=y
|
||||||
CONFIG_NFILE_DESCRIPTORS=6
|
CONFIG_NFILE_DESCRIPTORS=6
|
||||||
CONFIG_NFILE_STREAMS=6
|
CONFIG_NFILE_STREAMS=6
|
||||||
CONFIG_NPTHREAD_KEYS=0
|
CONFIG_TLS_NELEM=0
|
||||||
CONFIG_NSH_DISABLE_CD=y
|
CONFIG_NSH_DISABLE_CD=y
|
||||||
CONFIG_NSH_DISABLE_CP=y
|
CONFIG_NSH_DISABLE_CP=y
|
||||||
CONFIG_NSH_DISABLE_MKDIR=y
|
CONFIG_NSH_DISABLE_MKDIR=y
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ CONFIG_MAX_WDOGPARMS=2
|
|||||||
CONFIG_MM_SMALL=y
|
CONFIG_MM_SMALL=y
|
||||||
CONFIG_NFILE_DESCRIPTORS=6
|
CONFIG_NFILE_DESCRIPTORS=6
|
||||||
CONFIG_NFILE_STREAMS=6
|
CONFIG_NFILE_STREAMS=6
|
||||||
CONFIG_NPTHREAD_KEYS=0
|
CONFIG_TLS_NELEM=0
|
||||||
CONFIG_NSH_DISABLE_CD=y
|
CONFIG_NSH_DISABLE_CD=y
|
||||||
CONFIG_NSH_DISABLE_CP=y
|
CONFIG_NSH_DISABLE_CP=y
|
||||||
CONFIG_NSH_DISABLE_MKDIR=y
|
CONFIG_NSH_DISABLE_MKDIR=y
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ CONFIG_NET_TCPBACKLOG=y
|
|||||||
CONFIG_NET_TCP_CONNS=16
|
CONFIG_NET_TCP_CONNS=16
|
||||||
CONFIG_NFILE_DESCRIPTORS=8
|
CONFIG_NFILE_DESCRIPTORS=8
|
||||||
CONFIG_NFILE_STREAMS=8
|
CONFIG_NFILE_STREAMS=8
|
||||||
CONFIG_NPTHREAD_KEYS=0
|
CONFIG_TLS_NELEM=0
|
||||||
CONFIG_NSOCKET_DESCRIPTORS=16
|
CONFIG_NSOCKET_DESCRIPTORS=16
|
||||||
CONFIG_NUNGET_CHARS=0
|
CONFIG_NUNGET_CHARS=0
|
||||||
CONFIG_PREALLOC_WDOGS=8
|
CONFIG_PREALLOC_WDOGS=8
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ CONFIG_MMCSD=y
|
|||||||
CONFIG_MMCSD_SPICLOCK=12500000
|
CONFIG_MMCSD_SPICLOCK=12500000
|
||||||
CONFIG_NFILE_DESCRIPTORS=6
|
CONFIG_NFILE_DESCRIPTORS=6
|
||||||
CONFIG_NFILE_STREAMS=6
|
CONFIG_NFILE_STREAMS=6
|
||||||
CONFIG_NPTHREAD_KEYS=0
|
CONFIG_TLS_NELEM=0
|
||||||
CONFIG_NUNGET_CHARS=0
|
CONFIG_NUNGET_CHARS=0
|
||||||
CONFIG_PREALLOC_TIMERS=0
|
CONFIG_PREALLOC_TIMERS=0
|
||||||
CONFIG_PREALLOC_WDOGS=6
|
CONFIG_PREALLOC_WDOGS=6
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ CONFIG_MAX_WDOGPARMS=2
|
|||||||
CONFIG_MOTOROLA_SREC=y
|
CONFIG_MOTOROLA_SREC=y
|
||||||
CONFIG_NFILE_DESCRIPTORS=8
|
CONFIG_NFILE_DESCRIPTORS=8
|
||||||
CONFIG_NFILE_STREAMS=8
|
CONFIG_NFILE_STREAMS=8
|
||||||
CONFIG_NPTHREAD_KEYS=0
|
CONFIG_TLS_NELEM=0
|
||||||
CONFIG_NUNGET_CHARS=0
|
CONFIG_NUNGET_CHARS=0
|
||||||
CONFIG_PREALLOC_TIMERS=0
|
CONFIG_PREALLOC_TIMERS=0
|
||||||
CONFIG_PREALLOC_WDOGS=8
|
CONFIG_PREALLOC_WDOGS=8
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ CONFIG_NET_TCPBACKLOG=y
|
|||||||
CONFIG_NET_TCP_CONNS=16
|
CONFIG_NET_TCP_CONNS=16
|
||||||
CONFIG_NFILE_DESCRIPTORS=8
|
CONFIG_NFILE_DESCRIPTORS=8
|
||||||
CONFIG_NFILE_STREAMS=8
|
CONFIG_NFILE_STREAMS=8
|
||||||
CONFIG_NPTHREAD_KEYS=0
|
CONFIG_TLS_NELEM=0
|
||||||
CONFIG_NSOCKET_DESCRIPTORS=16
|
CONFIG_NSOCKET_DESCRIPTORS=16
|
||||||
CONFIG_NUNGET_CHARS=0
|
CONFIG_NUNGET_CHARS=0
|
||||||
CONFIG_PREALLOC_WDOGS=8
|
CONFIG_PREALLOC_WDOGS=8
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ CONFIG_NET_TCP=y
|
|||||||
CONFIG_NET_TCPBACKLOG=y
|
CONFIG_NET_TCPBACKLOG=y
|
||||||
CONFIG_NFILE_DESCRIPTORS=8
|
CONFIG_NFILE_DESCRIPTORS=8
|
||||||
CONFIG_NFILE_STREAMS=8
|
CONFIG_NFILE_STREAMS=8
|
||||||
CONFIG_NPTHREAD_KEYS=0
|
CONFIG_TLS_NELEM=0
|
||||||
CONFIG_NUNGET_CHARS=0
|
CONFIG_NUNGET_CHARS=0
|
||||||
CONFIG_PIPES=y
|
CONFIG_PIPES=y
|
||||||
CONFIG_PREALLOC_WDOGS=8
|
CONFIG_PREALLOC_WDOGS=8
|
||||||
|
|||||||
+17
-18
@@ -333,19 +333,21 @@ struct pthread_cleanup_s
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* type pthread_keyset_t ********************************************************/
|
/* type tls_ndxset_t ************************************************************/
|
||||||
|
|
||||||
/* Smallest addressable type that can hold the entire configured number of keys */
|
/* Smallest addressable type that can hold the entire configured number of TLS
|
||||||
|
* data indexes.
|
||||||
|
*/
|
||||||
|
|
||||||
#if defined(CONFIG_NPTHREAD_KEYS) && CONFIG_NPTHREAD_KEYS > 0
|
#if CONFIG_TLS_NELEM > 0
|
||||||
# if CONFIG_NPTHREAD_KEYS > 32
|
# if CONFIG_TLS_NELEM > 32
|
||||||
# error Too many pthread keys
|
# error Too many TLS elements
|
||||||
# elif CONFIG_NPTHREAD_KEYS > 16
|
# elif CONFIG_TLS_NELEM > 16
|
||||||
typedef uint32_t pthread_keyset_t;
|
typedef uint32_t tls_ndxset_t;
|
||||||
# elif CONFIG_NPTHREAD_KEYS > 8
|
# elif CONFIG_TLS_NELEM > 8
|
||||||
typedef uint16_t pthread_keyset_t;
|
typedef uint16_t tls_ndxset_t;
|
||||||
# else
|
# else
|
||||||
typedef uint8_t pthread_keyset_t;
|
typedef uint8_t tls_ndxset_t;
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -525,8 +527,11 @@ struct task_group_s
|
|||||||
FAR struct join_s *tg_joinhead; /* Head of a list of join data */
|
FAR struct join_s *tg_joinhead; /* Head of a list of join data */
|
||||||
FAR struct join_s *tg_jointail; /* Tail of a list of join data */
|
FAR struct join_s *tg_jointail; /* Tail of a list of join data */
|
||||||
#endif
|
#endif
|
||||||
#if CONFIG_NPTHREAD_KEYS > 0
|
|
||||||
pthread_keyset_t tg_keyset; /* Set of pthread keys allocated */
|
/* Thread local storage *******************************************************/
|
||||||
|
|
||||||
|
#if CONFIG_TLS_NELEM > 0
|
||||||
|
tls_ndxset_t tg_tlsset; /* Set of TLS data indexes allocated */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* POSIX Signal Control Fields ************************************************/
|
/* POSIX Signal Control Fields ************************************************/
|
||||||
@@ -694,12 +699,6 @@ struct tcb_s
|
|||||||
FAR struct mqueue_inode_s *msgwaitq; /* Waiting for this message queue */
|
FAR struct mqueue_inode_s *msgwaitq; /* Waiting for this message queue */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* POSIX Thread Specific Data *************************************************/
|
|
||||||
|
|
||||||
#if CONFIG_NPTHREAD_KEYS > 0
|
|
||||||
FAR void *pthread_data[CONFIG_NPTHREAD_KEYS];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Pre-emption monitor support ************************************************/
|
/* Pre-emption monitor support ************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_SCHED_CRITMONITOR
|
#ifdef CONFIG_SCHED_CRITMONITOR
|
||||||
|
|||||||
+60
-15
@@ -86,41 +86,86 @@ struct tls_info_s
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: tls_get_element
|
* Name: tls_alloc
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Return an the TLS element associated with the 'elem' index
|
* Allocate a group-unique TLS data index
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* elem - Index of TLS element to return
|
* None
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* The value of TLS element associated with 'elem'. Errors are not
|
* A TLS index that is unique for use within this task group.
|
||||||
* reported. Zero is returned in the event of an error, but zero may also
|
|
||||||
* be valid value and returned when there is no error. The only possible
|
|
||||||
* error would be if elem < 0 or elem >=CONFIG_TLS_NELEM.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
uintptr_t tls_get_element(int elem);
|
#if CONFIG_TLS_NELEM > 0
|
||||||
|
int tls_alloc(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: tls_get_element
|
* Name: tls_free
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Set the TLS element associated with the 'elem' index to 'value'
|
* Release a group-unique TLS data index previous obtained by tls_alloc()
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* elem - Index of TLS element to set
|
* tlsindex - The previously allocated TLS index to be freed
|
||||||
* value - The new value of the TLS element
|
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* None. Errors are not reported. The only possible error would be if
|
* OK is returned on success; a negated errno value will be returned on
|
||||||
* elem < 0 or elem >=CONFIG_TLS_NELEM.
|
* failure:
|
||||||
|
*
|
||||||
|
* -EINVAL - the index to be freed is out of range.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void tls_set_element(int elem, uintptr_t value);
|
#if CONFIG_TLS_NELEM > 0
|
||||||
|
int tls_free(int tlsindex);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: tls_get_value
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Return an the TLS data value associated with the 'tlsindx'
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* tlsindex - Index of TLS data element to return
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* The value of TLS element associated with 'tlsindex'. Errors are not
|
||||||
|
* reported. Zero is returned in the event of an error, but zero may also
|
||||||
|
* be valid value and returned when there is no error. The only possible
|
||||||
|
* error would be if tlsindex < 0 or tlsindex >=CONFIG_TLS_NELEM.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#if CONFIG_TLS_NELEM > 0
|
||||||
|
uintptr_t tls_get_value(int tlsindex);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: tls_set_value
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Set the TLS element associated with the 'tlsindex' to 'tlsvalue'
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* tlsindex - Index of TLS data element to set
|
||||||
|
* tlsvalue - The new value of the TLS data element
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Zero is returned on success, a negated errno value is return on
|
||||||
|
* failure:
|
||||||
|
*
|
||||||
|
* EINVAL - tlsindex is not in range.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#if CONFIG_TLS_NELEM > 0
|
||||||
|
int tls_set_value(int tlsindex, uintptr_t tlsvalue);
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: tls_get_info
|
* Name: tls_get_info
|
||||||
|
|||||||
+13
-29
@@ -1,36 +1,20 @@
|
|||||||
/********************************************************************************
|
/********************************************************************************
|
||||||
* include/sched.h
|
* include/sched.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007-2009, 2011, 2013, 2015-2016, 2020 Gregory Nutt. All
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
* rights reserved.
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* this work for additional information regarding copyright ownership. The
|
||||||
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
* notice, this list of conditions and the following disclaimer in
|
* License for the specific language governing permissions and limitations
|
||||||
* the documentation and/or other materials provided with the
|
* under the License.
|
||||||
* distribution.
|
|
||||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
|
||||||
* used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
||||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
||||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
||||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
||||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
||||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
*
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
@@ -80,7 +64,7 @@
|
|||||||
|
|
||||||
/* Pthread definitions **********************************************************/
|
/* Pthread definitions **********************************************************/
|
||||||
|
|
||||||
#define PTHREAD_KEYS_MAX CONFIG_NPTHREAD_KEYS
|
#define PTHREAD_KEYS_MAX CONFIG_TLS_NELEM
|
||||||
|
|
||||||
/* CPU affinity mask helpers ****************************************************/
|
/* CPU affinity mask helpers ****************************************************/
|
||||||
|
|
||||||
|
|||||||
@@ -283,6 +283,9 @@ SYSCALL_LOOKUP(telldir, 1)
|
|||||||
SYSCALL_LOOKUP(shmdt, 1)
|
SYSCALL_LOOKUP(shmdt, 1)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
SYSCALL_LOOKUP(tls_alloc, 0)
|
||||||
|
SYSCALL_LOOKUP(tls_free, 1)
|
||||||
|
|
||||||
/* The following are defined if pthreads are enabled */
|
/* The following are defined if pthreads are enabled */
|
||||||
|
|
||||||
#ifndef CONFIG_DISABLE_PTHREAD
|
#ifndef CONFIG_DISABLE_PTHREAD
|
||||||
@@ -294,10 +297,7 @@ SYSCALL_LOOKUP(telldir, 1)
|
|||||||
SYSCALL_LOOKUP(pthread_detach, 1)
|
SYSCALL_LOOKUP(pthread_detach, 1)
|
||||||
SYSCALL_LOOKUP(pthread_exit, 1)
|
SYSCALL_LOOKUP(pthread_exit, 1)
|
||||||
SYSCALL_LOOKUP(pthread_getschedparam, 3)
|
SYSCALL_LOOKUP(pthread_getschedparam, 3)
|
||||||
SYSCALL_LOOKUP(pthread_getspecific, 1)
|
|
||||||
SYSCALL_LOOKUP(pthread_join, 2)
|
SYSCALL_LOOKUP(pthread_join, 2)
|
||||||
SYSCALL_LOOKUP(pthread_key_create, 2)
|
|
||||||
SYSCALL_LOOKUP(pthread_key_delete, 1)
|
|
||||||
SYSCALL_LOOKUP(pthread_mutex_destroy, 1)
|
SYSCALL_LOOKUP(pthread_mutex_destroy, 1)
|
||||||
SYSCALL_LOOKUP(pthread_mutex_init, 2)
|
SYSCALL_LOOKUP(pthread_mutex_init, 2)
|
||||||
SYSCALL_LOOKUP(pthread_mutex_timedlock, 2)
|
SYSCALL_LOOKUP(pthread_mutex_timedlock, 2)
|
||||||
@@ -308,7 +308,6 @@ SYSCALL_LOOKUP(telldir, 1)
|
|||||||
#endif
|
#endif
|
||||||
SYSCALL_LOOKUP(pthread_setschedparam, 3)
|
SYSCALL_LOOKUP(pthread_setschedparam, 3)
|
||||||
SYSCALL_LOOKUP(pthread_setschedprio, 2)
|
SYSCALL_LOOKUP(pthread_setschedprio, 2)
|
||||||
SYSCALL_LOOKUP(pthread_setspecific, 2)
|
|
||||||
#ifdef CONFIG_SMP
|
#ifdef CONFIG_SMP
|
||||||
SYSCALL_LOOKUP(pthread_setaffinity_np, 3)
|
SYSCALL_LOOKUP(pthread_setaffinity_np, 3)
|
||||||
SYSCALL_LOOKUP(pthread_getaffinity_np, 3)
|
SYSCALL_LOOKUP(pthread_getaffinity_np, 3)
|
||||||
|
|||||||
@@ -18,6 +18,11 @@
|
|||||||
#
|
#
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
|
ifneq ($(CONFIG_TLS_NELEM),0)
|
||||||
|
CSRCS += pthread_keycreate.c pthread_setspecific.c pthread_getspecific.c
|
||||||
|
CSRCS += pthread_keydelete.c
|
||||||
|
endif
|
||||||
|
|
||||||
ifneq ($(CONFIG_DISABLE_PTHREAD),y)
|
ifneq ($(CONFIG_DISABLE_PTHREAD),y)
|
||||||
|
|
||||||
# Add the pthread C files to the build
|
# Add the pthread C files to the build
|
||||||
@@ -57,9 +62,10 @@ ifeq ($(CONFIG_BUILD_PROTECTED),y)
|
|||||||
CSRCS += pthread_startup.c
|
CSRCS += pthread_startup.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
endif # CONFIG_DISABLE_PTHREAD
|
||||||
|
|
||||||
# Add the pthread directory to the build
|
# Add the pthread directory to the build
|
||||||
|
|
||||||
DEPPATH += --dep-path pthread
|
DEPPATH += --dep-path pthread
|
||||||
VPATH += :pthread
|
VPATH += :pthread
|
||||||
|
|
||||||
endif # CONFIG_DISABLE_PTHREAD
|
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* libs/libc/pthread/pthread_getspecific.c
|
||||||
|
*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership. The
|
||||||
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
|
#include <nuttx/tls.h>
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: pthread_getspecific
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* The pthread_getspecific() function returns the value currently
|
||||||
|
* bound to the specified key on behalf of the calling thread.
|
||||||
|
*
|
||||||
|
* The effect of calling pthread_getspecific() with a key value
|
||||||
|
* not obtained from pthread_key_create() or after a key has been
|
||||||
|
* deleted with pthread_key_delete() is undefined.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* key = The data key to get or set
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* The function pthread_getspecific() returns the thread-specific data
|
||||||
|
* associated with the given key. If no thread specific data is
|
||||||
|
* associated with the key, then the value NULL is returned.
|
||||||
|
*
|
||||||
|
* POSIX Compatibility:
|
||||||
|
* - Both pthread_setspecific() and pthread_getspecific() may be
|
||||||
|
* called from a thread-specific data destructor function.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
FAR void *pthread_getspecific(pthread_key_t key)
|
||||||
|
{
|
||||||
|
return (FAR void *)tls_get_value((int)key);
|
||||||
|
}
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* libs/libc/pthread/pthread_keycreate.c
|
||||||
|
*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership. The
|
||||||
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <pthread.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include <nuttx/tls.h>
|
||||||
|
|
||||||
|
#if CONFIG_TLS_NELEM > 0
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: pthread_key_create
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* This function creates a thread-specific data key visible to all threads
|
||||||
|
* in the system. Although the same key value may be used by different
|
||||||
|
* threads, the values bound to the key by pthread_setspecific() are
|
||||||
|
* maintained on a per-thread basis and persist for the life of the calling
|
||||||
|
* thread.
|
||||||
|
*
|
||||||
|
* Upon key creation, the value NULL will be associated with the new key
|
||||||
|
* in all active threads. Upon thread creation, the value NULL will be
|
||||||
|
* associated with all defined keys in the new thread.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* key - A pointer to the key to create.
|
||||||
|
* destructor - An optional destructor() function that may be associated
|
||||||
|
* with each key that is invoked when a thread exits.
|
||||||
|
* However, this argument is ignored in the current
|
||||||
|
* implementation.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* If successful, the pthread_key_create() function will store the newly
|
||||||
|
* created key value at *key and return zero (OK). Otherwise, an error
|
||||||
|
* number will be returned to indicate the error:
|
||||||
|
*
|
||||||
|
* EAGAIN - The system lacked sufficient resources to create another
|
||||||
|
* thread-specific data key, or the system-imposed limit on
|
||||||
|
* the total number of keys pers process {PTHREAD_KEYS_MAX}
|
||||||
|
* has been exceeded
|
||||||
|
* ENOMEM - Insufficient memory exist to create the key.
|
||||||
|
*
|
||||||
|
* POSIX Compatibility:
|
||||||
|
* - The present implementation ignores the destructor argument.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int pthread_key_create(FAR pthread_key_t *key,
|
||||||
|
CODE void (*destructor)(FAR void *))
|
||||||
|
{
|
||||||
|
int tlsindex;
|
||||||
|
|
||||||
|
DEBUGASSERT(key != NULL);
|
||||||
|
|
||||||
|
/* Allocate a TLS index */
|
||||||
|
|
||||||
|
tlsindex = tls_alloc();
|
||||||
|
|
||||||
|
/* Check if found a TLS index. */
|
||||||
|
|
||||||
|
if (tlsindex >= 0)
|
||||||
|
{
|
||||||
|
/* Yes.. Return the key value and success */
|
||||||
|
|
||||||
|
*key = (pthread_key_t)tlsindex;
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -tlsindex;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* CONFIG_TLS_NELEM */
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* libs/libc/pthread/pthread_keydelete.c
|
||||||
|
*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership. The
|
||||||
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
|
#include <nuttx/tls.h>
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: pthread_key_delete
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* This POSIX function deletes a thread-specific data key
|
||||||
|
* previously returned by pthread_key_create().
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* key - the key to delete
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Returns zero (OK) on success. EINVAL may be returned if an invalid
|
||||||
|
* key is received.
|
||||||
|
*
|
||||||
|
* POSIX Compatibility:
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int pthread_key_delete(pthread_key_t key)
|
||||||
|
{
|
||||||
|
/* Free the TLS index */
|
||||||
|
|
||||||
|
int ret = tls_free((int)key);
|
||||||
|
return ret < 0 ? -ret : 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* libs/libc/pthread/pthread_setspecific.c
|
||||||
|
*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership. The
|
||||||
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
|
#include <nuttx/tls.h>
|
||||||
|
|
||||||
|
#if CONFIG_TLS_NELEM > 0
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: pthread_setspecific
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* The pthread_setspecific() function associates a thread-
|
||||||
|
* specific value with a key obtained via a previous call
|
||||||
|
* to pthread_key_create(). Different threads may bind
|
||||||
|
* different values to the same key. These values are
|
||||||
|
* typically pointers to blocks of dynamically allocated
|
||||||
|
* memory that have been reserved for use by the calling
|
||||||
|
* thread.
|
||||||
|
*
|
||||||
|
* The effect of calling pthread_setspecific() with
|
||||||
|
* a key value not obtained from pthread_key_create() or
|
||||||
|
* after a key has been deleted with pthread_key_delete()
|
||||||
|
* is undefined.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* key = The data key to get or set
|
||||||
|
* value = The value to bind to the key.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* If successful, pthread_setspecific() will return zero (OK).
|
||||||
|
* Otherwise, an error number will be returned:
|
||||||
|
*
|
||||||
|
* ENOMEM - Insufficient memory exists to associate
|
||||||
|
* the value with the key.
|
||||||
|
* EINVAL - The key value is invalid.
|
||||||
|
*
|
||||||
|
* POSIX Compatibility:
|
||||||
|
* - Both pthread_setspecific() and pthread_getspecific()
|
||||||
|
* may be called from a thread-specific data destructor
|
||||||
|
* function.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int pthread_setspecific(pthread_key_t key, FAR const void *value)
|
||||||
|
{
|
||||||
|
int ret = tls_set_value((int)key, (uintptr_t)value);
|
||||||
|
return ret < 0 ? -ret : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* CONFIG_TLS_NELEM */
|
||||||
|
|
||||||
@@ -45,10 +45,11 @@ config TLS_LOG2_MAXSTACK
|
|||||||
|
|
||||||
config TLS_NELEM
|
config TLS_NELEM
|
||||||
int "Number of TLS elements"
|
int "Number of TLS elements"
|
||||||
default 0
|
default 4
|
||||||
---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_element() and tls_set_element().
|
the user library functions tls_get_value() and tls_set_value()
|
||||||
|
and the OS interfaces tls_alloc() and tls_free().
|
||||||
|
|
||||||
NOTE that the special value of CONFIG_TLS_NELEM disables these
|
NOTE that the special value of CONFIG_TLS_NELEM disables these
|
||||||
TLS interfaces.
|
TLS interfaces.
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
ifneq ($(CONFIG_TLS_NELEM),0)
|
ifneq ($(CONFIG_TLS_NELEM),0)
|
||||||
CSRCS += tls_setelem.c tls_getelem.c
|
CSRCS += tls_setvalue.c tls_getvalue.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifneq ($(CONFIG_TLS_ALIGNED),y)
|
ifneq ($(CONFIG_TLS_ALIGNED),y)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* libs/libc/fixedmath/tls_setelem.c
|
* libs/libc/tls/tls_getinfo.c
|
||||||
*
|
*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* libs/libc/fixedmath/tls_getelem.c
|
* libs/libc/tls/tls_getvalue.c
|
||||||
*
|
*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
@@ -38,29 +38,29 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: tls_get_element
|
* Name: tls_get_value
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Return an the TLS element associated with the 'elem' index
|
* Return an the TLS data value associated with the 'tlsindx'
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* elem - Index of TLS element to return
|
* tlsindex - Index of TLS data element to return
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* The value of TLS element associated with 'elem'. Errors are not
|
* The value of TLS element associated with 'tlsindex'. Errors are not
|
||||||
* reported. Zero is returned in the event of an error, but zero may also
|
* reported. Zero is returned in the event of an error, but zero may also
|
||||||
* be valid value and returned when there is no error. The only possible
|
* be valid value and returned when there is no error. The only possible
|
||||||
* error would be if elem < 0 or elem >=CONFIG_TLS_NELEM.
|
* error would be if tlsindex < 0 or tlsindex >=CONFIG_TLS_NELEM.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
uintptr_t tls_get_element(int elem)
|
uintptr_t tls_get_value(int tlsindex)
|
||||||
{
|
{
|
||||||
FAR struct tls_info_s *info;
|
FAR struct tls_info_s *info;
|
||||||
uintptr_t ret = 0;
|
uintptr_t ret = 0;
|
||||||
|
|
||||||
DEBUGASSERT(elem >= 0 && elem < CONFIG_TLS_NELEM);
|
DEBUGASSERT(tlsindex >= 0 && tlsindex < CONFIG_TLS_NELEM);
|
||||||
if (elem >= 0 && elem < CONFIG_TLS_NELEM)
|
if (tlsindex >= 0 && tlsindex < CONFIG_TLS_NELEM)
|
||||||
{
|
{
|
||||||
/* Get the TLS info structure from the current threads stack */
|
/* Get the TLS info structure from the current threads stack */
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ uintptr_t tls_get_element(int elem)
|
|||||||
|
|
||||||
/* Get the element value from the TLS info. */
|
/* Get the element value from the TLS info. */
|
||||||
|
|
||||||
ret = info->tl_elem[elem];
|
ret = info->tl_elem[tlsindex];
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* libs/libc/fixedmath/tls_setelem.c
|
* libs/libc/tls/tls_setvalue.c
|
||||||
*
|
*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
@@ -38,27 +38,29 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: tls_get_element
|
* Name: tls_set_value
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Set the TLS element associated with the 'elem' index to 'value'
|
* Set the TLS element associated with the 'tlsindex' to 'tlsvalue'
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* elem - Index of TLS element to set
|
* tlsindex - Index of TLS data element to set
|
||||||
* value - The new value of the TLS element
|
* tlsvalue - The new value of the TLS data element
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* None. Errors are not reported. The only possible error would be if
|
* Zero is returned on success, a negated errno value is return on
|
||||||
* elem >=CONFIG_TLS_NELEM.
|
* failure:
|
||||||
|
*
|
||||||
|
* EINVAL - tlsindex is not in range.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void tls_set_element(int elem, uintptr_t value)
|
int tls_set_value(int tlsindex, uintptr_t tlsvalue)
|
||||||
{
|
{
|
||||||
FAR struct tls_info_s *info;
|
FAR struct tls_info_s *info;
|
||||||
|
|
||||||
DEBUGASSERT(elem >= 0 && elem < CONFIG_TLS_NELEM);
|
DEBUGASSERT(tlsindex >= 0 && tlsindex < CONFIG_TLS_NELEM);
|
||||||
if (elem >= 0 && elem < CONFIG_TLS_NELEM)
|
if (tlsindex >= 0 && tlsindex < CONFIG_TLS_NELEM)
|
||||||
{
|
{
|
||||||
/* Get the TLS info structure from the current threads stack */
|
/* Get the TLS info structure from the current threads stack */
|
||||||
|
|
||||||
@@ -67,8 +69,11 @@ void tls_set_element(int elem, uintptr_t value)
|
|||||||
|
|
||||||
/* Set the element value int the TLS info. */
|
/* Set the element value int the TLS info. */
|
||||||
|
|
||||||
info->tl_elem[elem] = value;
|
info->tl_elem[tlsindex] = tlsvalue;
|
||||||
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_TLS_NELEM > 0 */
|
#endif /* CONFIG_TLS_NELEM > 0 */
|
||||||
+16
-27
@@ -1,35 +1,20 @@
|
|||||||
############################################################################
|
############################################################################
|
||||||
# sched/group/Make.defs
|
# sched/group/Make.defs
|
||||||
#
|
#
|
||||||
# Copyright (C) 2014, 2018 Gregory Nutt. All rights reserved.
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
# contributor license agreements. See the NOTICE file distributed with
|
||||||
|
# this work for additional information regarding copyright ownership. The
|
||||||
|
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
# "License"); you may not use this file except in compliance with the
|
||||||
|
# License. You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# modification, are permitted provided that the following conditions
|
|
||||||
# are met:
|
|
||||||
#
|
#
|
||||||
# 1. Redistributions of source code must retain the above copyright
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# notice, this list of conditions and the following disclaimer.
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
# 2. Redistributions in binary form must reproduce the above copyright
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# notice, this list of conditions and the following disclaimer in
|
# License for the specific language governing permissions and limitations
|
||||||
# the documentation and/or other materials provided with the
|
# under the License.
|
||||||
# distribution.
|
|
||||||
# 3. Neither the name NuttX nor the names of its contributors may be
|
|
||||||
# used to endorse or promote products derived from this software
|
|
||||||
# without specific prior written permission.
|
|
||||||
#
|
|
||||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
||||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
||||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
||||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
||||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
||||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
||||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
# POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
#
|
#
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
@@ -68,6 +53,10 @@ ifneq ($(CONFIG_BUILD_FLAT),y)
|
|||||||
CSRCS += group_malloc.c group_zalloc.c group_free.c
|
CSRCS += group_malloc.c group_zalloc.c group_free.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifneq ($(CONFIG_TLS_NELEM),0)
|
||||||
|
CSRCS += group_tlsalloc.c group_tlsfree.c
|
||||||
|
endif
|
||||||
|
|
||||||
# Include group build support
|
# Include group build support
|
||||||
|
|
||||||
DEPPATH += --dep-path group
|
DEPPATH += --dep-path group
|
||||||
|
|||||||
@@ -0,0 +1,101 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* sched/group/group_tlsalloc.c
|
||||||
|
*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership. The
|
||||||
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <sched.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include <nuttx/irq.h>
|
||||||
|
#include <nuttx/tls.h>
|
||||||
|
|
||||||
|
#include "sched/sched.h"
|
||||||
|
#include "group/group.h"
|
||||||
|
|
||||||
|
#if CONFIG_TLS_NELEM > 0
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: tls_alloc
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Allocate a group-unique TLS data index
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* A TLS index that is unique for use within this task group.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int tls_alloc(void)
|
||||||
|
{
|
||||||
|
FAR struct tcb_s *rtcb = this_task();
|
||||||
|
FAR struct task_group_s *group = rtcb->group;
|
||||||
|
irqstate_t flags;
|
||||||
|
int candidate;
|
||||||
|
int ret = -EAGAIN;
|
||||||
|
|
||||||
|
DEBUGASSERT(group != NULL);
|
||||||
|
|
||||||
|
/* Search for an unused index. This is done in a critical section here to
|
||||||
|
* avoid concurrent modification of the group TLS index set.
|
||||||
|
*/
|
||||||
|
|
||||||
|
flags = spin_lock_irqsave();
|
||||||
|
for (candidate = 0; candidate < CONFIG_TLS_NELEM; candidate++)
|
||||||
|
{
|
||||||
|
/* Is this candidate index available? */
|
||||||
|
|
||||||
|
tls_ndxset_t mask = (1 << candidate);
|
||||||
|
if ((group->tg_tlsset & mask) == 0)
|
||||||
|
{
|
||||||
|
/* Yes.. allocate the index and break out of the loop */
|
||||||
|
|
||||||
|
group->tg_tlsset |= mask;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
spin_unlock_irqrestore(flags);
|
||||||
|
|
||||||
|
/* Check if found a valid TLS data index. */
|
||||||
|
|
||||||
|
if (candidate < CONFIG_TLS_NELEM)
|
||||||
|
{
|
||||||
|
/* Yes.. Return the TLS index and success */
|
||||||
|
|
||||||
|
ret = candidate;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* CONFIG_TLS_NELEM > 0 */
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* sched/group/group_tlsfree.c
|
||||||
|
*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership. The
|
||||||
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <sched.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include <nuttx/irq.h>
|
||||||
|
#include <nuttx/tls.h>
|
||||||
|
|
||||||
|
#include "sched/sched.h"
|
||||||
|
#include "group/group.h"
|
||||||
|
|
||||||
|
#if CONFIG_TLS_NELEM > 0
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: tls_free
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Release a group-unique TLS data index previous obtained by tls_alloc()
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* tlsindex - The previously allocated TLS index to be freed
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* OK is returned on success; a negated errno value will be returned on
|
||||||
|
* failure:
|
||||||
|
*
|
||||||
|
* -EINVAL - the index to be freed is out of range.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int tls_free(int tlsindex)
|
||||||
|
{
|
||||||
|
FAR struct tcb_s *rtcb = this_task();
|
||||||
|
FAR struct task_group_s *group = rtcb->group;
|
||||||
|
tls_ndxset_t mask;
|
||||||
|
irqstate_t flags;
|
||||||
|
int ret = -EINVAL;
|
||||||
|
|
||||||
|
DEBUGASSERT((unsigned)tlsindex < CONFIG_TLS_NELEM && group != NULL);
|
||||||
|
if ((unsigned)tlsindex < CONFIG_TLS_NELEM)
|
||||||
|
{
|
||||||
|
/* This is done in a critical section here to avoid concurrent
|
||||||
|
* modification of the group TLS index set.
|
||||||
|
*/
|
||||||
|
|
||||||
|
mask = (1 << tlsindex);
|
||||||
|
flags = spin_lock_irqsave();
|
||||||
|
|
||||||
|
DEBUGASSERT((group->tg_tlsset & mask) != 0);
|
||||||
|
group->tg_tlsset &= ~mask;
|
||||||
|
spin_unlock_irqrestore(flags);
|
||||||
|
|
||||||
|
ret = OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* CONFIG_TLS_NELEM > 0 */
|
||||||
+14
-32
@@ -1,41 +1,23 @@
|
|||||||
############################################################################
|
############################################################################
|
||||||
# sched/pthread/Make.defs
|
# sched/pthread/Make.defs
|
||||||
#
|
#
|
||||||
# Copyright (C) 2014, 2016 Gregory Nutt. All rights reserved.
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
# contributor license agreements. See the NOTICE file distributed with
|
||||||
|
# this work for additional information regarding copyright ownership. The
|
||||||
|
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
# "License"); you may not use this file except in compliance with the
|
||||||
|
# License. You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# modification, are permitted provided that the following conditions
|
|
||||||
# are met:
|
|
||||||
#
|
#
|
||||||
# 1. Redistributions of source code must retain the above copyright
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# notice, this list of conditions and the following disclaimer.
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
# 2. Redistributions in binary form must reproduce the above copyright
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# notice, this list of conditions and the following disclaimer in
|
# License for the specific language governing permissions and limitations
|
||||||
# the documentation and/or other materials provided with the
|
# under the License.
|
||||||
# distribution.
|
|
||||||
# 3. Neither the name NuttX nor the names of its contributors may be
|
|
||||||
# used to endorse or promote products derived from this software
|
|
||||||
# without specific prior written permission.
|
|
||||||
#
|
|
||||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
||||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
||||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
||||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
||||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
||||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
||||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
# POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
#
|
#
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
CSRCS += pthread_keycreate.c pthread_setspecific.c pthread_getspecific.c
|
|
||||||
CSRCS += pthread_keydelete.c
|
|
||||||
|
|
||||||
ifneq ($(CONFIG_DISABLE_PTHREAD),y)
|
ifneq ($(CONFIG_DISABLE_PTHREAD),y)
|
||||||
|
|
||||||
CSRCS += pthread_create.c pthread_exit.c pthread_join.c pthread_detach.c
|
CSRCS += pthread_create.c pthread_exit.c pthread_join.c pthread_detach.c
|
||||||
@@ -60,9 +42,9 @@ ifeq ($(CONFIG_PTHREAD_CLEANUP),y)
|
|||||||
CSRCS += pthread_cleanup.c
|
CSRCS += pthread_cleanup.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Include pthread build support
|
# Include pthread build support
|
||||||
|
|
||||||
DEPPATH += --dep-path pthread
|
DEPPATH += --dep-path pthread
|
||||||
VPATH += :pthread
|
VPATH += :pthread
|
||||||
|
|
||||||
|
endif # CONFIG_DISABLE_PTHREAD
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user