diff --git a/include/sys/syscall.h b/include/sys/syscall.h index b041abda913..99fd22b454f 100644 --- a/include/sys/syscall.h +++ b/include/sys/syscall.h @@ -401,19 +401,25 @@ # define SYS_pthread_mutex_unlock (__SYS_pthread+21) # define SYS_pthread_once (__SYS_pthread+22) # define SYS_pthread_setcancelstate (__SYS_pthread+23) -# define SYS_pthread_setcanceltype (__SYS_pthread+24) -# define SYS_pthread_setschedparam (__SYS_pthread+25) -# define SYS_pthread_setschedprio (__SYS_pthread+26) -# define SYS_pthread_setspecific (__SYS_pthread+27) -# define SYS_pthread_testcancel (__SYS_pthread+28) -# define SYS_pthread_yield (__SYS_pthread+29) +# define SYS_pthread_setschedparam (__SYS_pthread+24) +# define SYS_pthread_setschedprio (__SYS_pthread+25) +# define SYS_pthread_setspecific (__SYS_pthread+26) +# define SYS_pthread_yield (__SYS_pthread+27) + +# ifdef CONFIG_CANCELLATION_POINTS +# define SYS_pthread_setcanceltype (__SYS_pthread+28) +# define SYS_pthread_testcancel (__SYS_pthread+29) +# define __SYS_pthread_smp (__SYS_pthread+30) +# else +# define __SYS_pthread_smp (__SYS_pthread+28) +# endif # ifdef CONFIG_SMP -# define SYS_pthread_setaffinity_np (__SYS_pthread+30) -# define SYS_pthread_getaffinity_np (__SYS_pthread+31) -# define __SYS_pthread_signals (__SYS_pthread+32) +# define SYS_pthread_setaffinity_np (__SYS_pthread_smp+0) +# define SYS_pthread_getaffinity_np (__SYS_pthread_smp+1) +# define __SYS_pthread_signals (__SYS_pthread_smp+2) # else -# define __SYS_pthread_signals (__SYS_pthread+30) +# define __SYS_pthread_signals __SYS_pthread_smp # endif # ifndef CONFIG_DISABLE_SIGNALS diff --git a/libc/pthread/Make.defs b/libc/pthread/Make.defs index bbb3280959d..60ae02b59ad 100644 --- a/libc/pthread/Make.defs +++ b/libc/pthread/Make.defs @@ -48,6 +48,10 @@ CSRCS += pthread_mutexattr_getpshared.c pthread_mutexattr_setpshared.c CSRCS += pthread_mutexattr_setprotocol.c pthread_mutexattr_getprotocol.c CSRCS += pthread_mutexattr_settype.c pthread_mutexattr_gettype.c +ifneq ($(CONFIG_CANCELLATION_POINTS),y) +CSRCS += pthread_setcanceltype.c pthread_testcancel.c +endif + ifeq ($(CONFIG_SMP),y) CSRCS += pthread_attr_getaffinity.c pthread_attr_setaffinity.c endif diff --git a/sched/pthread/Make.defs b/sched/pthread/Make.defs index 0ed862edf06..c8ef588422b 100644 --- a/sched/pthread/Make.defs +++ b/sched/pthread/Make.defs @@ -42,8 +42,7 @@ CSRCS += pthread_mutexlock.c pthread_mutextrylock.c pthread_mutexunlock.c CSRCS += pthread_condinit.c pthread_conddestroy.c CSRCS += pthread_condwait.c pthread_condsignal.c pthread_condbroadcast.c CSRCS += pthread_barrierinit.c pthread_barrierdestroy.c pthread_barrierwait.c -CSRCS += pthread_cancel.c pthread_setcancelstate.c pthread_setcanceltype.c -CSRCS += pthread_testcancel.c +CSRCS += pthread_cancel.c pthread_setcancelstate.c CSRCS += pthread_keycreate.c pthread_setspecific.c pthread_getspecific.c CSRCS += pthread_keydelete.c CSRCS += pthread_initialize.c pthread_completejoin.c pthread_findjoininfo.c @@ -53,6 +52,10 @@ ifneq ($(CONFIG_DISABLE_SIGNALS),y) CSRCS += pthread_condtimedwait.c pthread_kill.c pthread_sigmask.c endif +ifeq ($(CONFIG_CANCELLATION_POINTS),y) +CSRCS += pthread_setcanceltype.c pthread_testcancel.c +endif + ifeq ($(CONFIG_SMP),y) CSRCS += pthread_setaffinity.c pthread_getaffinity.c endif diff --git a/sched/pthread/pthread_setcancelstate.c b/sched/pthread/pthread_setcancelstate.c index 44c05fba9ab..bcc5d24f6b9 100644 --- a/sched/pthread/pthread_setcancelstate.c +++ b/sched/pthread/pthread_setcancelstate.c @@ -78,7 +78,7 @@ int pthread_setcancelstate(int state, FAR int *oldstate) /* Return the current state if so requrested */ - if (oldstate) + if (oldstate != NULL) { if ((tcb->flags & TCB_FLAG_NONCANCELABLE) != 0) { diff --git a/sched/pthread/pthread_setcanceltype.c b/sched/pthread/pthread_setcanceltype.c index 0de093cb09e..ba3704cd2ac 100644 --- a/sched/pthread/pthread_setcanceltype.c +++ b/sched/pthread/pthread_setcanceltype.c @@ -77,7 +77,7 @@ int pthread_setcanceltype(int type, FAR int *oldtype) /* Return the current type if so requrested */ - if (oldtype) + if (oldtype != NULL) { if ((tcb->flags & TCB_FLAG_CANCEL_DEFERRED) != 0) { diff --git a/syscall/syscall.csv b/syscall/syscall.csv index e52159ab1d1..19ff12aed66 100644 --- a/syscall/syscall.csv +++ b/syscall/syscall.csv @@ -90,12 +90,12 @@ "pthread_once","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","FAR pthread_once_t*","CODE void (*)(void)" "pthread_setaffinity_np","pthread.h","!defined(CONFIG_DISABLE_PTHREAD) && defined(CONFIG_SMP)","int","pthread_t","size_t","FAR const cpu_set_t*" "pthread_setcancelstate","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","int","FAR int*" -"pthread_setcanceltype","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","int","FAR int*" +"pthread_setcanceltype","pthread.h","!defined(CONFIG_DISABLE_PTHREAD) && defined(CONFIG_CANCELLATION_POINTS)","int","int","FAR int*" "pthread_setschedparam","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","pthread_t","int","FAR const struct sched_param*" "pthread_setschedprio","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","pthread_t","int" "pthread_setspecific","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","pthread_key_t","FAR const void*" "pthread_sigmask","pthread.h","!defined(CONFIG_DISABLE_SIGNALS) && !defined(CONFIG_DISABLE_PTHREAD)","int","int","FAR const sigset_t*","FAR sigset_t*" -"pthread_testcancel","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","void" +"pthread_testcancel","pthread.h","!defined(CONFIG_DISABLE_PTHREAD) && defined(CONFIG_CANCELLATION_POINTS)","void" "pthread_yield","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","void" "putenv","stdlib.h","!defined(CONFIG_DISABLE_ENVIRON)","int","FAR const char*" "read","unistd.h","CONFIG_NSOCKET_DESCRIPTORS > 0 || CONFIG_NFILE_DESCRIPTORS > 0","ssize_t","int","FAR void*","size_t" diff --git a/syscall/syscall_lookup.h b/syscall/syscall_lookup.h index a261bef9a71..9381c36b0cb 100644 --- a/syscall/syscall_lookup.h +++ b/syscall/syscall_lookup.h @@ -291,12 +291,14 @@ SYSCALL_LOOKUP(up_assert, 2, STUB_up_assert) SYSCALL_LOOKUP(pthread_mutex_unlock, 1, STUB_pthread_mutex_unlock) SYSCALL_LOOKUP(pthread_once, 2, STUB_pthread_once) SYSCALL_LOOKUP(pthread_setcancelstate, 2, STUB_pthread_setcancelstate) - SYSCALL_LOOKUP(pthread_setcanceltype, 2, STUB_pthread_setcanceltype) SYSCALL_LOOKUP(pthread_setschedparam, 3, STUB_pthread_setschedparam) SYSCALL_LOOKUP(pthread_setschedprio, 2, STUB_pthread_setschedprio) SYSCALL_LOOKUP(pthread_setspecific, 2, STUB_pthread_setspecific) - SYSCALL_LOOKUP(pthread_testcancel, 0, STUB_pthread_testcancel) SYSCALL_LOOKUP(pthread_yield, 0, STUB_pthread_yield) +# ifdef CONFIG_CANCELLATION_POINTS + SYSCALL_LOOKUP(pthread_setcanceltype, 2, STUB_pthread_setcanceltype) + SYSCALL_LOOKUP(pthread_testcancel, 0, STUB_pthread_testcancel) +# endif # ifdef CONFIG_SMP SYSCALL_LOOKUP(pthread_setaffinity, 3, STUB_pthread_setaffinity) SYSCALL_LOOKUP(pthread_getaffinity, 3, STUB_pthread_getaffinity) diff --git a/syscall/syscall_stublookup.c b/syscall/syscall_stublookup.c index 43e4ebfecb3..3004dedccef 100644 --- a/syscall/syscall_stublookup.c +++ b/syscall/syscall_stublookup.c @@ -292,17 +292,18 @@ uintptr_t STUB_pthread_mutex_unlock(int nbr, uintptr_t parm1); uintptr_t STUB_pthread_once(int nbr, uintptr_t parm1, uintptr_t parm2); uintptr_t STUB_pthread_setcancelstate(int nbr, uintptr_t parm1, uintptr_t parm2); -uintptr_t STUB_pthread_setcanceltype(int nbr, uintptr_t parm1, - uintptr_t parm2); uintptr_t STUB_pthread_setschedparam(int nbr, uintptr_t parm1, uintptr_t parm2, uintptr_t parm3); uintptr_t STUB_pthread_setschedprio(int nbr, uintptr_t parm1, uintptr_t parm2); uintptr_t STUB_pthread_setspecific(int nbr, uintptr_t parm1, uintptr_t parm2); -uintptr_t STUB_pthread_testcancel(int nbr); uintptr_t STUB_pthread_yield(int nbr); +uintptr_t STUB_pthread_setcanceltype(int nbr, uintptr_t parm1, + uintptr_t parm2); +uintptr_t STUB_pthread_testcancel(int nbr); + uintptr_t STUB_pthread_setaffinity(int nbr, uintptr_t parm1, uintptr_t parm2, uintptr_t parm3); uintptr_t STUB_pthread_getaffinity(int nbr, uintptr_t parm1,