This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 7f8f800e63aa0ee3233ff2a0539d67471857f30a
Author: Jukka Laitinen <[email protected]>
AuthorDate: Wed Jun 10 11:14:26 2026 +0300

    arch, sched/signal: Fix compilation with ENABLE_PARTIAL_SIGNALS=y
    
    Correct build errors when CONFIG_ENABLE_ALL_SIGNALS is not defined
    
    - sched makefiles: Move pending-signal helpers from the 
ENABLE_ALL_SIGNALS-only
      list to the !DISABLE_ALL_SIGNALS list so signal dispatch is available in
      PARTIAL builds sched: make SIG_PREALLOC_ACTIONS, SIG_ALLOC_ACTIONS and
      SIG_DEFAULT depend on ENABLE_ALL_SIGNALS
    - sched: fix ifdefs around pending-signal queue access and signal-mask for
      PARTIAL/DISABLE modes
    - arch: gate SYS_signal_handler / _return calls and SYSCALL_LOOKUP(signal)
      with ENABLE_ALL_SIGNALS
    
    Signed-off-by: Jukka Laitinen <[email protected]>
---
 arch/arm/src/armv6-m/arm_svcall.c         |  4 +-
 arch/arm/src/armv7-m/arm_svcall.c         |  4 +-
 arch/arm/src/armv8-m/arm_svcall.c         |  4 +-
 arch/arm/src/armv8-r/arm_syscall.c        |  4 +-
 arch/arm64/src/common/arm64_syscall.c     |  3 +-
 arch/risc-v/src/common/riscv_swint.c      |  4 +-
 arch/xtensa/src/common/xtensa_swint.c     |  4 +-
 include/nuttx/sched.h                     |  4 +-
 include/sys/syscall_lookup.h              |  4 ++
 libs/libc/pthread/CMakeLists.txt          |  4 +-
 libs/libc/pthread/Make.defs               |  3 --
 libs/libc/pthread/pthread_mutex_destroy.c |  2 -
 sched/Kconfig                             | 19 ++++++----
 sched/group/group_leave.c                 |  2 +-
 sched/init/nx_start.c                     |  2 +-
 sched/sched/sched_suspend.c               |  4 ++
 sched/semaphore/sem_wait.c                |  6 +--
 sched/signal/CMakeLists.txt               | 21 +++++------
 sched/signal/Make.defs                    | 13 ++++---
 sched/signal/sig_cleanup.c                |  9 ++++-
 sched/signal/sig_dispatch.c               | 62 ++++++++++++++++---------------
 sched/signal/sig_initialize.c             | 15 ++++++--
 sched/signal/sig_kill.c                   | 13 ++++++-
 sched/signal/sig_procmask.c               |  2 -
 sched/signal/sig_tgkill.c                 | 13 ++++++-
 sched/signal/sig_timedwait.c              |  4 --
 sched/signal/signal.h                     | 11 ++++--
 sched/task/task_exithook.c                |  2 +-
 sched/task/task_restart.c                 |  4 +-
 sched/task/task_setup.c                   |  3 +-
 30 files changed, 147 insertions(+), 102 deletions(-)

diff --git a/arch/arm/src/armv6-m/arm_svcall.c 
b/arch/arm/src/armv6-m/arm_svcall.c
index 0167f86d12e..b004d252018 100644
--- a/arch/arm/src/armv6-m/arm_svcall.c
+++ b/arch/arm/src/armv6-m/arm_svcall.c
@@ -238,7 +238,7 @@ int arm_svcall(int irq, void *context, void *arg)
        *   R4 = ucontext
        */
 
-#ifdef CONFIG_BUILD_PROTECTED
+#if defined(CONFIG_BUILD_PROTECTED) && defined(CONFIG_ENABLE_ALL_SIGNALS)
       case SYS_signal_handler:
         {
           struct tcb_s *rtcb   = this_task();
@@ -280,7 +280,7 @@ int arm_svcall(int irq, void *context, void *arg)
        *   R0 = SYS_signal_handler_return
        */
 
-#ifdef CONFIG_BUILD_PROTECTED
+#if defined(CONFIG_BUILD_PROTECTED) && defined(CONFIG_ENABLE_ALL_SIGNALS)
       case SYS_signal_handler_return:
         {
           struct tcb_s *rtcb   = this_task();
diff --git a/arch/arm/src/armv7-m/arm_svcall.c 
b/arch/arm/src/armv7-m/arm_svcall.c
index 9f77ce5cf93..956f1b95b52 100644
--- a/arch/arm/src/armv7-m/arm_svcall.c
+++ b/arch/arm/src/armv7-m/arm_svcall.c
@@ -240,7 +240,7 @@ int arm_svcall(int irq, void *context, void *arg)
        *   R4 = ucontext
        */
 
-#ifdef CONFIG_BUILD_PROTECTED
+#if defined(CONFIG_BUILD_PROTECTED) && defined(CONFIG_ENABLE_ALL_SIGNALS)
       case SYS_signal_handler:
         {
           struct tcb_s *rtcb   = this_task();
@@ -282,7 +282,7 @@ int arm_svcall(int irq, void *context, void *arg)
        *   R0 = SYS_signal_handler_return
        */
 
-#ifdef CONFIG_BUILD_PROTECTED
+#if defined(CONFIG_BUILD_PROTECTED) && defined(CONFIG_ENABLE_ALL_SIGNALS)
       case SYS_signal_handler_return:
         {
           struct tcb_s *rtcb   = this_task();
diff --git a/arch/arm/src/armv8-m/arm_svcall.c 
b/arch/arm/src/armv8-m/arm_svcall.c
index f3c3dc16f93..03ab17d0ce3 100644
--- a/arch/arm/src/armv8-m/arm_svcall.c
+++ b/arch/arm/src/armv8-m/arm_svcall.c
@@ -240,7 +240,7 @@ int arm_svcall(int irq, void *context, void *arg)
        *   R4 = ucontext
        */
 
-#ifdef CONFIG_BUILD_PROTECTED
+#if defined(CONFIG_BUILD_PROTECTED) && defined(CONFIG_ENABLE_ALL_SIGNALS)
       case SYS_signal_handler:
         {
           struct tcb_s *rtcb   = this_task();
@@ -282,7 +282,7 @@ int arm_svcall(int irq, void *context, void *arg)
        *   R0 = SYS_signal_handler_return
        */
 
-#ifdef CONFIG_BUILD_PROTECTED
+#if defined(CONFIG_BUILD_PROTECTED) && defined(CONFIG_ENABLE_ALL_SIGNALS)
       case SYS_signal_handler_return:
         {
           struct tcb_s *rtcb   = this_task();
diff --git a/arch/arm/src/armv8-r/arm_syscall.c 
b/arch/arm/src/armv8-r/arm_syscall.c
index bf0c64a6cd5..e9b54c382b7 100644
--- a/arch/arm/src/armv8-r/arm_syscall.c
+++ b/arch/arm/src/armv8-r/arm_syscall.c
@@ -356,7 +356,7 @@ uint32_t *arm_syscall(uint32_t *regs)
         break;
 #endif
 
-#ifdef CONFIG_BUILD_PROTECTED
+#if defined(CONFIG_BUILD_PROTECTED) && defined(CONFIG_ENABLE_ALL_SIGNALS)
       /* R0=SYS_signal_handler:  This a user signal handler callback
        *
        * void signal_handler(_sa_sigaction_t sighand, int signo,
@@ -438,7 +438,7 @@ uint32_t *arm_syscall(uint32_t *regs)
         break;
 #endif
 
-#ifdef CONFIG_BUILD_PROTECTED
+#if defined(CONFIG_BUILD_PROTECTED) && defined(CONFIG_ENABLE_ALL_SIGNALS)
       /* R0=SYS_signal_handler_return:  This a user signal handler callback
        *
        *   void signal_handler_return(void);
diff --git a/arch/arm64/src/common/arm64_syscall.c 
b/arch/arm64/src/common/arm64_syscall.c
index fec098c92ed..8d503aa64e3 100644
--- a/arch/arm64/src/common/arm64_syscall.c
+++ b/arch/arm64/src/common/arm64_syscall.c
@@ -159,7 +159,8 @@ uint64_t *arm64_syscall(uint64_t *regs)
   struct tcb_s **running_task = &g_running_tasks[cpu];
   struct tcb_s *tcb = this_task();
   uint64_t cmd;
-#if defined(CONFIG_BUILD_KERNEL) || defined(CONFIG_BUILD_PROTECTED)
+#if (defined(CONFIG_BUILD_KERNEL) || defined(CONFIG_BUILD_PROTECTED)) \
+    && defined(CONFIG_ENABLE_ALL_SIGNALS)
   uint64_t             spsr;
 #endif
 
diff --git a/arch/risc-v/src/common/riscv_swint.c 
b/arch/risc-v/src/common/riscv_swint.c
index c41f4448218..b5dc855484f 100644
--- a/arch/risc-v/src/common/riscv_swint.c
+++ b/arch/risc-v/src/common/riscv_swint.c
@@ -195,7 +195,7 @@ int riscv_swint(int irq, void *context, void *arg)
        *   A4 = ucontext
        */
 
-#ifndef CONFIG_BUILD_FLAT
+#if !defined(CONFIG_BUILD_FLAT) && defined(CONFIG_ENABLE_ALL_SIGNALS)
       case SYS_signal_handler:
         {
           struct tcb_s *rtcb   = this_task();
@@ -272,7 +272,7 @@ int riscv_swint(int irq, void *context, void *arg)
        *   R0 = SYS_signal_handler_return
        */
 
-#ifndef CONFIG_BUILD_FLAT
+#if !defined(CONFIG_BUILD_FLAT) && defined(CONFIG_ENABLE_ALL_SIGNALS)
       case SYS_signal_handler_return:
         {
           struct tcb_s *rtcb   = this_task();
diff --git a/arch/xtensa/src/common/xtensa_swint.c 
b/arch/xtensa/src/common/xtensa_swint.c
index 1a4b3aa8ee9..4b38987e17e 100644
--- a/arch/xtensa/src/common/xtensa_swint.c
+++ b/arch/xtensa/src/common/xtensa_swint.c
@@ -261,7 +261,7 @@ int xtensa_swint(int irq, void *context, void *arg)
        *   A6 = ucontext
        */
 
-#ifndef CONFIG_BUILD_FLAT
+#if !defined(CONFIG_BUILD_FLAT) && defined(CONFIG_ENABLE_ALL_SIGNALS)
       case SYS_signal_handler:
         {
           struct tcb_s *rtcb  = this_task();
@@ -300,7 +300,7 @@ int xtensa_swint(int irq, void *context, void *arg)
        *   A2 = SYS_signal_handler_return
        */
 
-#ifndef CONFIG_BUILD_FLAT
+#if !defined(CONFIG_BUILD_FLAT) && defined(CONFIG_ENABLE_ALL_SIGNALS)
       case SYS_signal_handler_return:
         {
           struct tcb_s *rtcb  = this_task();
diff --git a/include/nuttx/sched.h b/include/nuttx/sched.h
index 9f40db43828..76630d3f101 100644
--- a/include/nuttx/sched.h
+++ b/include/nuttx/sched.h
@@ -519,8 +519,10 @@ struct task_group_s
 
 #ifdef CONFIG_ENABLE_ALL_SIGNALS
   sq_queue_t tg_sigactionq;         /* List of actions for signals             
 */
-  sq_queue_t tg_sigpendingq;        /* List of pending signals                 
 */
 #endif /* CONFIG_ENABLE_ALL_SIGNALS */
+#ifndef CONFIG_DISABLE_ALL_SIGNALS
+  sq_queue_t tg_sigpendingq;        /* List of pending signals                 
 */
+#endif /* !CONFIG_DISABLE_ALL_SIGNALS */
 #ifdef CONFIG_SIG_DEFAULT
   sigset_t tg_sigdefault;           /* Set of signals set to the default 
action */
 #endif
diff --git a/include/sys/syscall_lookup.h b/include/sys/syscall_lookup.h
index c83fa657e66..7a1f37284c8 100644
--- a/include/sys/syscall_lookup.h
+++ b/include/sys/syscall_lookup.h
@@ -217,8 +217,10 @@ SYSCALL_LOOKUP(pwrite,                     4)
 #endif
   SYSCALL_LOOKUP(poll,                     3)
   SYSCALL_LOOKUP(select,                   5)
+#ifndef CONFIG_DISABLE_ALL_SIGNALS
   SYSCALL_LOOKUP(ppoll,                    4)
   SYSCALL_LOOKUP(pselect,                  6)
+#endif
 #ifdef CONFIG_EVENT_FD
   SYSCALL_LOOKUP(eventfd,                  2)
 #endif
@@ -397,7 +399,9 @@ SYSCALL_LOOKUP(settimeofday,               2)
 
 /* ANSI C signal handling */
 
+#ifdef CONFIG_ENABLE_ALL_SIGNALS
 SYSCALL_LOOKUP(signal,                     2)
+#endif
 
 #ifdef CONFIG_SCHED_INSTRUMENTATION_DUMP
   SYSCALL_LOOKUP(sched_note_vprintf_ip,    5)
diff --git a/libs/libc/pthread/CMakeLists.txt b/libs/libc/pthread/CMakeLists.txt
index 96ff96e8225..523f2818f7e 100644
--- a/libs/libc/pthread/CMakeLists.txt
+++ b/libs/libc/pthread/CMakeLists.txt
@@ -131,9 +131,7 @@ if(NOT CONFIG_DISABLE_PTHREAD)
     list(APPEND SRCS pthread_spinlock.c)
   endif()
 
-  if(NOT CONFIG_DISABLE_ALL_SIGNALS)
-    list(APPEND SRCS pthread_kill.c)
-  endif()
+  list(APPEND SRCS pthread_kill.c)
 
   if(NOT CONFIG_TLS_NCLEANUP EQUAL 0)
     list(APPEND SRCS pthread_cleanup.c)
diff --git a/libs/libc/pthread/Make.defs b/libs/libc/pthread/Make.defs
index 14a4200d0c8..25869be1a04 100644
--- a/libs/libc/pthread/Make.defs
+++ b/libs/libc/pthread/Make.defs
@@ -68,10 +68,7 @@ CSRCS += pthread_setcancelstate.c pthread_setcanceltype.c
 CSRCS += pthread_testcancel.c pthread_getcpuclockid.c
 CSRCS += pthread_self.c pthread_gettid_np.c
 CSRCS += pthread_concurrency.c
-
-ifneq ($(CONFIG_DISABLE_ALL_SIGNALS),y)
 CSRCS += pthread_kill.c
-endif
 
 ifeq ($(CONFIG_SMP),y)
 CSRCS += pthread_attr_getaffinity.c pthread_attr_setaffinity.c
diff --git a/libs/libc/pthread/pthread_mutex_destroy.c 
b/libs/libc/pthread/pthread_mutex_destroy.c
index 45b6a2e000b..6432bb6782b 100644
--- a/libs/libc/pthread/pthread_mutex_destroy.c
+++ b/libs/libc/pthread/pthread_mutex_destroy.c
@@ -90,7 +90,6 @@ int pthread_mutex_destroy(FAR pthread_mutex_t *mutex)
            * nxsched_get_tcb() does.
            */
 
-#ifndef CONFIG_DISABLE_ALL_SIGNALS
           if (pthread_kill(pid, 0) != 0)
             {
               /* The thread associated with the PID no longer exists */
@@ -122,7 +121,6 @@ int pthread_mutex_destroy(FAR pthread_mutex_t *mutex)
                 }
             }
           else
-#endif
             {
               ret = EBUSY;
             }
diff --git a/sched/Kconfig b/sched/Kconfig
index 3b5808a4417..5532fc4114b 100644
--- a/sched/Kconfig
+++ b/sched/Kconfig
@@ -1601,6 +1601,16 @@ config DISABLE_ALL_SIGNALS
 
 endchoice
 
+config SIG_PREALLOC_IRQ_ACTIONS
+       int "Number of pre-allocated irq actions"
+       default 4 if DEFAULT_SMALL
+       default 8 if !DEFAULT_SMALL
+       depends on !DISABLE_ALL_SIGNALS
+       ---help---
+               The number of pre-allocated irq action structures.
+
+if ENABLE_ALL_SIGNALS
+
 config SIG_PREALLOC_ACTIONS
        int "Number of pre-allocated sigactions"
        default 4
@@ -1615,13 +1625,6 @@ config SIG_ALLOC_ACTIONS
                if this number is larger than 1, the allocation won't be
                returned to the heap but kept in a free list for reuse.
 
-config SIG_PREALLOC_IRQ_ACTIONS
-       int "Number of pre-allocated irq actions"
-       default 4 if DEFAULT_SMALL
-       default 8 if !DEFAULT_SMALL
-       ---help---
-               The number of pre-allocated irq action structures.
-
 config SIG_EVTHREAD
        bool "Support SIGEV_THREAD"
        default n
@@ -1736,6 +1739,8 @@ config SIG_SIGURG_ACTION
 
 endif # SIG_DEFAULT
 
+endif # ENABLE_ALL_SIGNALS
+
 endmenu # Signal Configuration
 
 menu "Message Queue Options"
diff --git a/sched/group/group_leave.c b/sched/group/group_leave.c
index a4ff9eab12e..afe62da8c07 100644
--- a/sched/group/group_leave.c
+++ b/sched/group/group_leave.c
@@ -86,7 +86,7 @@ static inline void group_release(FAR struct task_group_s 
*group)
 
   /* Release pending signals */
 
-#ifdef CONFIG_ENABLE_ALL_SIGNALS
+#ifndef CONFIG_DISABLE_ALL_SIGNALS
   nxsig_release(group);
 #endif
 
diff --git a/sched/init/nx_start.c b/sched/init/nx_start.c
index 418619bdd74..b9bcb07fb2f 100644
--- a/sched/init/nx_start.c
+++ b/sched/init/nx_start.c
@@ -643,7 +643,7 @@ void nx_start(void)
 
   /* Initialize the signal facility (if in link) */
 
-#ifdef CONFIG_ENABLE_ALL_SIGNALS
+#ifndef CONFIG_DISABLE_ALL_SIGNALS
   nxsig_initialize();
 #endif
 
diff --git a/sched/sched/sched_suspend.c b/sched/sched/sched_suspend.c
index e67d8bfe804..c2b38b21d92 100644
--- a/sched/sched/sched_suspend.c
+++ b/sched/sched/sched_suspend.c
@@ -103,12 +103,15 @@ void nxsched_suspend(FAR struct tcb_s *tcb)
 {
   irqstate_t flags;
   bool switch_needed;
+#ifdef CONFIG_ENABLE_ALL_SIGNALS
   FAR sq_entry_t *entry;
+#endif
 
   DEBUGASSERT(tcb != NULL);
 
   flags = enter_critical_section();
 
+#ifdef CONFIG_ENABLE_ALL_SIGNALS
   /* Check if received SIGCONT */
 
   sq_for_every(&tcb->sigpendactionq, entry)
@@ -120,6 +123,7 @@ void nxsched_suspend(FAR struct tcb_s *tcb)
           return;
         }
     }
+#endif
 
   /* Check the current state of the task */
 
diff --git a/sched/semaphore/sem_wait.c b/sched/semaphore/sem_wait.c
index aac400ddd32..e4c065bfb47 100644
--- a/sched/semaphore/sem_wait.c
+++ b/sched/semaphore/sem_wait.c
@@ -34,9 +34,7 @@
 #include <nuttx/irq.h>
 #include <nuttx/arch.h>
 #include <nuttx/mm/kmap.h>
-#ifdef CONFIG_ENABLE_ALL_SIGNALS
 #include <nuttx/signal.h>
-#endif
 
 #include "sched/sched.h"
 #include "semaphore/semaphore.h"
@@ -74,7 +72,7 @@
 
 int nxsem_wait_slow(FAR sem_t *sem)
 {
-#ifdef CONFIG_ENABLE_ALL_SIGNALS
+#ifndef CONFIG_DISABLE_ALL_SIGNALS
   sigset_t pendingset;
 #endif
   FAR struct tcb_s *rtcb = this_task();
@@ -93,7 +91,7 @@ int nxsem_wait_slow(FAR sem_t *sem)
 
   /* Make sure we were supplied with a valid semaphore. */
 
-#ifdef CONFIG_ENABLE_ALL_SIGNALS
+#ifndef CONFIG_DISABLE_ALL_SIGNALS
   /* A signal can arrive before sem_wait transitions the task to
    * TSTATE_WAIT_SEM. In that window, the wait cannot yet be aborted by
    * sem_wait_irq(). If sem_wait then blocks without re-checking unmasked
diff --git a/sched/signal/CMakeLists.txt b/sched/signal/CMakeLists.txt
index a9595309737..1fa0eeb49af 100644
--- a/sched/signal/CMakeLists.txt
+++ b/sched/signal/CMakeLists.txt
@@ -20,7 +20,8 @@
 #
 # 
##############################################################################
 
-set(SRCS sig_nanosleep.c sig_usleep.c sig_sleep.c sig_clockwait.c)
+set(SRCS sig_nanosleep.c sig_usleep.c sig_sleep.c sig_clockwait.c sig_kill.c
+         sig_tgkill.c)
 
 if(NOT CONFIG_DISABLE_ALL_SIGNALS)
   list(
@@ -28,8 +29,6 @@ if(NOT CONFIG_DISABLE_ALL_SIGNALS)
     SRCS
     sig_procmask.c
     sig_suspend.c
-    sig_kill.c
-    sig_tgkill.c
     sig_queue.c
     sig_waitinfo.c
     sig_timedwait.c
@@ -38,7 +37,13 @@ if(NOT CONFIG_DISABLE_ALL_SIGNALS)
     sig_dispatch.c
     sig_pause.c
     sig_ppoll.c
-    sig_pselect.c)
+    sig_pselect.c
+    sig_cleanup.c
+    sig_initialize.c
+    sig_pending.c
+    sig_releasependingsignal.c
+    sig_removependingsignal.c
+    sig_unmaskpendingsignal.c)
 endif()
 
 if(CONFIG_ENABLE_ALL_SIGNALS)
@@ -47,15 +52,9 @@ if(CONFIG_ENABLE_ALL_SIGNALS)
     SRCS
     sig_action.c
     sig_allocpendingsigaction.c
-    sig_cleanup.c
     sig_deliver.c
     sig_findaction.c
-    sig_initialize.c
-    sig_pending.c
-    sig_releasependingsigaction.c
-    sig_releasependingsignal.c
-    sig_removependingsignal.c
-    sig_unmaskpendingsignal.c)
+    sig_releasependingsigaction.c)
 endif()
 
 if(CONFIG_SIG_DEFAULT)
diff --git a/sched/signal/Make.defs b/sched/signal/Make.defs
index e1099a4ebc1..079ffe58af3 100644
--- a/sched/signal/Make.defs
+++ b/sched/signal/Make.defs
@@ -21,18 +21,21 @@
 ############################################################################
 
 CSRCS += sig_nanosleep.c sig_sleep.c sig_usleep.c sig_clockwait.c
+CSRCS += sig_kill.c sig_tgkill.c
 
 ifneq ($(CONFIG_DISABLE_ALL_SIGNALS),y)
-CSRCS += sig_dispatch.c sig_kill.c sig_lowest.c
+CSRCS += sig_dispatch.c sig_lowest.c
 CSRCS += sig_notification.c sig_pause.c sig_ppoll.c sig_procmask.c
-CSRCS += sig_pselect.c sig_queue.c  sig_suspend.c sig_tgkill.c
+CSRCS += sig_pselect.c sig_queue.c  sig_suspend.c
 CSRCS += sig_timedwait.c sig_waitinfo.c
+CSRCS += sig_cleanup.c sig_initialize.c sig_pending.c
+CSRCS += sig_releasependingsignal.c sig_removependingsignal.c
+CSRCS += sig_unmaskpendingsignal.c
 endif
 
 ifeq ($(CONFIG_ENABLE_ALL_SIGNALS),y)
-CSRCS += sig_action.c sig_allocpendingsigaction.c sig_cleanup.c sig_deliver.c
-CSRCS += sig_findaction.c sig_initialize.c sig_pending.c 
sig_releasependingsigaction.c
-CSRCS += sig_releasependingsignal.c sig_removependingsignal.c 
sig_unmaskpendingsignal.c
+CSRCS += sig_action.c sig_allocpendingsigaction.c sig_deliver.c
+CSRCS += sig_findaction.c sig_releasependingsigaction.c
 endif
 
 ifeq ($(CONFIG_SIG_DEFAULT),y)
diff --git a/sched/signal/sig_cleanup.c b/sched/signal/sig_cleanup.c
index df63a2d783f..0947c0e63bb 100644
--- a/sched/signal/sig_cleanup.c
+++ b/sched/signal/sig_cleanup.c
@@ -46,6 +46,7 @@
 
 void nxsig_cleanup(FAR struct tcb_s *stcb)
 {
+#ifdef CONFIG_ENABLE_ALL_SIGNALS
   FAR sigq_t *sigq;
 
   /* Deallocate all entries in the list of pending signal actions */
@@ -61,6 +62,7 @@ void nxsig_cleanup(FAR struct tcb_s *stcb)
     {
       nxsig_release_pendingsigaction(sigq);
     }
+#endif
 
   /* Misc. signal-related clean-up */
 
@@ -81,13 +83,17 @@ void nxsig_cleanup(FAR struct tcb_s *stcb)
 
 void nxsig_release(FAR struct task_group_s *group)
 {
+#ifdef CONFIG_ENABLE_ALL_SIGNALS
   FAR sigactq_t  *sigact;
+#endif
   FAR sigpendq_t *sigpend;
   irqstate_t flags;
 
+  flags = spin_lock_irqsave(&group->tg_lock);
+
+#ifdef CONFIG_ENABLE_ALL_SIGNALS
   /* Deallocate all entries in the list of signal actions */
 
-  flags = spin_lock_irqsave(&group->tg_lock);
   while ((sigact = (FAR sigactq_t *)sq_remfirst(&group->tg_sigactionq))
          != NULL)
     {
@@ -95,6 +101,7 @@ void nxsig_release(FAR struct task_group_s *group)
       nxsig_release_action(sigact);
       flags = spin_lock_irqsave(&group->tg_lock);
     }
+#endif
 
   /* Deallocate all entries in the list of pending signals */
 
diff --git a/sched/signal/sig_dispatch.c b/sched/signal/sig_dispatch.c
index 0596c80a413..79dc91a1da6 100644
--- a/sched/signal/sig_dispatch.c
+++ b/sched/signal/sig_dispatch.c
@@ -204,6 +204,25 @@ static int nxsig_queue_action(FAR struct tcb_s *stcb,
   return ret;
 }
 
+/****************************************************************************
+ * Name: nxsig_dispatch_kernel_action
+ ****************************************************************************/
+
+static void nxsig_dispatch_kernel_action(FAR struct tcb_s *stcb,
+                                         FAR siginfo_t *info)
+{
+  FAR struct task_group_s *group = stcb->group;
+  FAR sigactq_t *sigact;
+
+  sigact = nxsig_find_action(group, info->si_signo);
+  if (sigact && (sigact->act.sa_flags & SA_KERNELHAND))
+    {
+      info->si_user = sigact->act.sa_user;
+      (sigact->act.sa_sigaction)(info->si_signo, info, NULL);
+    }
+}
+#endif /* CONFIG_ENABLE_ALL_SIGNALS */
+
 /****************************************************************************
  * Name: nxsig_alloc_pendingsignal
  *
@@ -275,24 +294,6 @@ nxsig_find_pendingsignal(FAR struct task_group_s *group, 
int signo)
   return sigpend;
 }
 
-/****************************************************************************
- * Name: nxsig_dispatch_kernel_action
- ****************************************************************************/
-
-static void nxsig_dispatch_kernel_action(FAR struct tcb_s *stcb,
-                                         FAR siginfo_t *info)
-{
-  FAR struct task_group_s *group = stcb->group;
-  FAR sigactq_t *sigact;
-
-  sigact = nxsig_find_action(group, info->si_signo);
-  if (sigact && (sigact->act.sa_flags & SA_KERNELHAND))
-    {
-      info->si_user = sigact->act.sa_user;
-      (sigact->act.sa_sigaction)(info->si_signo, info, NULL);
-    }
-}
-
 /****************************************************************************
  * Name: nxsig_add_pendingsignal
  *
@@ -381,12 +382,18 @@ static int nxsig_alloc_dyn_pending(FAR irqstate_t *flags)
 {
   int ret = OK;
   bool alloc_signal = sq_empty(&g_sigpendingsignal);
+#ifdef CONFIG_ENABLE_ALL_SIGNALS
   bool alloc_sigact = sq_empty(&g_sigpendingaction);
 
   if (alloc_signal || alloc_sigact)
+#else
+  if (alloc_signal)
+#endif
     {
       FAR sigpendq_t *sigpend = NULL;
+#ifdef CONFIG_ENABLE_ALL_SIGNALS
       FAR sigq_t *sigq = NULL;
+#endif
 
       /* We can't do memory allocations in idle task or interrupt */
 
@@ -406,12 +413,14 @@ static int nxsig_alloc_dyn_pending(FAR irqstate_t *flags)
           sigpend = kmm_malloc(sizeof(sigpendq_t));
         }
 
+#ifdef CONFIG_ENABLE_ALL_SIGNALS
       /* Allocate more pending signal actions if there are no more */
 
       if (alloc_sigact)
         {
           sigq = kmm_malloc(sizeof(sigq_t));
         }
+#endif
 
       /* Restore critical section and add the allocated structures to
        * the free pending queues
@@ -432,6 +441,7 @@ static int nxsig_alloc_dyn_pending(FAR irqstate_t *flags)
             }
         }
 
+#ifdef CONFIG_ENABLE_ALL_SIGNALS
       if (alloc_sigact)
         {
           if (sigq)
@@ -444,11 +454,11 @@ static int nxsig_alloc_dyn_pending(FAR irqstate_t *flags)
               ret = -EAGAIN;
             }
         }
+#endif
     }
 
   return ret;
 }
-#endif
 
 /****************************************************************************
  * Public Functions
@@ -483,9 +493,9 @@ int nxsig_tcbdispatch(FAR struct tcb_s *stcb, siginfo_t 
*info,
   irqstate_t flags;
   int masked;
   int ret = OK;
+  FAR sigpendq_t *sigpend = NULL;
 #ifdef CONFIG_ENABLE_ALL_SIGNALS
   FAR sigactq_t *sigact;
-  FAR sigpendq_t *sigpend = NULL;
 #endif
 
   sinfo("TCB=%p pid=%d signo=%d code=%d value=%d masked=%s\n",
@@ -519,14 +529,12 @@ int nxsig_tcbdispatch(FAR struct tcb_s *stcb, siginfo_t 
*info,
    * needs to be done here before using the task state or sigprocmask.
    */
 
-#ifdef CONFIG_ENABLE_ALL_SIGNALS
   ret = nxsig_alloc_dyn_pending(&flags);
   if (ret < 0)
     {
       leave_critical_section(flags);
       return ret;
     }
-#endif
 
   masked = nxsig_ismember(&stcb->sigprocmask, info->si_signo);
 
@@ -594,19 +602,16 @@ int nxsig_tcbdispatch(FAR struct tcb_s *stcb, siginfo_t 
*info,
               up_switch_context(this_task(), rtcb);
             }
 
-#ifdef CONFIG_ENABLE_ALL_SIGNALS
-#  ifdef CONFIG_LIB_SYSCALL
+#if defined(CONFIG_LIB_SYSCALL) && defined(CONFIG_ENABLE_ALL_SIGNALS)
           /* Must also add signal action if in system call */
 
           if (masked == 0)
             {
               sigpend = nxsig_add_pendingsignal(stcb, info, group_dispatch);
             }
-#  endif
 #endif
         }
 
-#ifdef CONFIG_ENABLE_ALL_SIGNALS
       /* Its not one we are waiting for... Add it to the list of pending
        * signals.
        */
@@ -615,7 +620,6 @@ int nxsig_tcbdispatch(FAR struct tcb_s *stcb, siginfo_t 
*info,
         {
           sigpend = nxsig_add_pendingsignal(stcb, info, group_dispatch);
         }
-#endif
     }
 
   /************************* UNMASKED SIGNAL ACTIONS ************************/
@@ -727,14 +731,14 @@ int nxsig_tcbdispatch(FAR struct tcb_s *stcb, siginfo_t 
*info,
 
   leave_critical_section(flags);
 
-#ifdef CONFIG_ENABLE_ALL_SIGNALS
   /* Dispatch kernel action, if needed, in case a pending signal was added */
 
   if (sigpend != NULL)
     {
+#ifdef CONFIG_ENABLE_ALL_SIGNALS
       nxsig_dispatch_kernel_action(stcb, &sigpend->info);
-    }
 #endif
+    }
 
   /* In case nxsig_ismember failed due to an invalid signal number */
 
diff --git a/sched/signal/sig_initialize.c b/sched/signal/sig_initialize.c
index 3bb977a784c..4582df1ecc3 100644
--- a/sched/signal/sig_initialize.c
+++ b/sched/signal/sig_initialize.c
@@ -41,8 +41,10 @@
 
 struct sigpool_s
 {
+#ifdef CONFIG_ENABLE_ALL_SIGNALS
   sigq_t sigq[NUM_PENDING_ACTIONS +
               CONFIG_SIG_PREALLOC_IRQ_ACTIONS];
+#endif
   sigpendq_t sigpendq[NUM_SIGNALS_PENDING +
                       CONFIG_SIG_PREALLOC_IRQ_ACTIONS];
 };
@@ -53,9 +55,8 @@ struct sigpool_s
 
 /* This is a pool of pre-allocated signal action structures buffers */
 
-#if CONFIG_SIG_PREALLOC_ACTIONS > 0
+#if defined(CONFIG_ENABLE_ALL_SIGNALS) && CONFIG_SIG_PREALLOC_ACTIONS > 0
 sigactq_t  g_sigactions[CONFIG_SIG_PREALLOC_ACTIONS];
-#endif
 
 /* The g_sigfreeaction data structure is a list of available signal
  * action structures.
@@ -74,6 +75,7 @@ sq_queue_t  g_sigpendingaction;
  */
 
 sq_queue_t  g_sigpendingirqaction;
+#endif
 
 /* The g_sigpendingsignal data structure is a list of available pending
  * signal structures.
@@ -100,7 +102,7 @@ static struct sigpool_s g_sigpool;
  * Private Functions
  ****************************************************************************/
 
-#if CONFIG_SIG_PREALLOC_ACTIONS > 0
+#if defined(CONFIG_ENABLE_ALL_SIGNALS) && CONFIG_SIG_PREALLOC_ACTIONS > 0
 static void nxsig_init_signalactionblock(sq_queue_t *siglist,
                                          FAR sigactq_t *sigact,
                                          uint16_t nsigs)
@@ -125,6 +127,7 @@ static void nxsig_init_signalactionblock(sq_queue_t 
*siglist,
  *
  ****************************************************************************/
 
+#ifdef CONFIG_ENABLE_ALL_SIGNALS
 static void *nxsig_init_block(sq_queue_t *siglist, FAR sigq_t *sigq,
                               uint16_t nsigs, uint8_t sigtype)
 {
@@ -138,6 +141,7 @@ static void *nxsig_init_block(sq_queue_t *siglist, FAR 
sigq_t *sigq,
 
   return sigq;
 }
+#endif
 
 /****************************************************************************
  * Name: nxsig_init_pendingsignalblock
@@ -184,12 +188,15 @@ void nxsig_initialize(void)
 
   /* Initialize free lists */
 
+#if defined(CONFIG_ENABLE_ALL_SIGNALS) && CONFIG_SIG_PREALLOC_ACTIONS > 0
   sq_init(&g_sigfreeaction);
   sq_init(&g_sigpendingaction);
   sq_init(&g_sigpendingirqaction);
+#endif
   sq_init(&g_sigpendingsignal);
   sq_init(&g_sigpendingirqsignal);
 
+#ifdef CONFIG_ENABLE_ALL_SIGNALS
   nxsig_init_signalactionblock(&g_sigfreeaction,
                                g_sigactions,
                                CONFIG_SIG_PREALLOC_ACTIONS);
@@ -198,6 +205,8 @@ void nxsig_initialize(void)
   sigpool = nxsig_init_block(&g_sigpendingirqaction, sigpool,
                              CONFIG_SIG_PREALLOC_IRQ_ACTIONS,
                              SIG_ALLOC_IRQ);
+#endif
+
   sigpool = nxsig_init_pendingsignalblock(&g_sigpendingsignal, sigpool,
                                           NUM_SIGNALS_PENDING,
                                           SIG_ALLOC_FIXED);
diff --git a/sched/signal/sig_kill.c b/sched/signal/sig_kill.c
index bff39d81724..16927138eb8 100644
--- a/sched/signal/sig_kill.c
+++ b/sched/signal/sig_kill.c
@@ -77,10 +77,12 @@
 
 int nxsig_kill(pid_t pid, int signo)
 {
-#ifdef CONFIG_SCHED_HAVE_PARENT
+#if !defined(CONFIG_DISABLE_ALL_SIGNALS) && defined(CONFIG_SCHED_HAVE_PARENT)
   FAR struct tcb_s *rtcb = this_task();
 #endif
+#ifndef CONFIG_DISABLE_ALL_SIGNALS
   siginfo_t info;
+#endif
 
   /* We do not support sending signals to process groups */
 
@@ -89,6 +91,14 @@ int nxsig_kill(pid_t pid, int signo)
       return -ENOSYS;
     }
 
+  if (signo == 0)
+    {
+      return (nxsched_get_tcb(pid) != NULL) ? 0 : -ESRCH;
+    }
+
+#ifdef CONFIG_DISABLE_ALL_SIGNALS
+  return -ENOSYS;
+#else
   /* Make sure that the signal is valid */
 
   if (!GOOD_SIGNO(signo))
@@ -110,6 +120,7 @@ int nxsig_kill(pid_t pid, int signo)
   /* Send the signal */
 
   return nxsig_dispatch(pid, &info, false);
+#endif
 }
 
 /****************************************************************************
diff --git a/sched/signal/sig_procmask.c b/sched/signal/sig_procmask.c
index cfc8d625077..529e07a939a 100644
--- a/sched/signal/sig_procmask.c
+++ b/sched/signal/sig_procmask.c
@@ -145,9 +145,7 @@ int nxsig_procmask(int how, FAR const sigset_t *set, FAR 
sigset_t *oset)
 
       /* Now, process any pending signals that were just unmasked */
 
-#ifdef CONFIG_ENABLE_ALL_SIGNALS
       nxsig_unmask_pendingsignal();
-#endif
     }
 
   return ret;
diff --git a/sched/signal/sig_tgkill.c b/sched/signal/sig_tgkill.c
index 284738a6143..c1d09be9cae 100644
--- a/sched/signal/sig_tgkill.c
+++ b/sched/signal/sig_tgkill.c
@@ -75,12 +75,22 @@ int nxsig_tgkill(pid_t pid, pid_t tid, int signo)
    * will just deliver the signal to the thread ID it is requested to use.
    */
 
-#ifdef CONFIG_SCHED_HAVE_PARENT
+#if !defined(CONFIG_DISABLE_ALL_SIGNALS) && defined(CONFIG_SCHED_HAVE_PARENT)
   FAR struct tcb_s *rtcb = this_task();
 #endif
+#ifndef CONFIG_DISABLE_ALL_SIGNALS
   siginfo_t info;
   int ret;
+#endif
+
+  if (signo == 0)
+    {
+      return (nxsched_get_tcb(tid) != NULL) ? 0 : -ESRCH;
+    }
 
+#ifdef CONFIG_DISABLE_ALL_SIGNALS
+  return -ENOSYS;
+#else
   /* Make sure that the signal is valid */
 
   if (!GOOD_SIGNO(signo))
@@ -104,6 +114,7 @@ int nxsig_tgkill(pid_t pid, pid_t tid, int signo)
 
 errout:
   return ret;
+#endif
 }
 
 /****************************************************************************
diff --git a/sched/signal/sig_timedwait.c b/sched/signal/sig_timedwait.c
index 720f89c3f2a..19412b87474 100644
--- a/sched/signal/sig_timedwait.c
+++ b/sched/signal/sig_timedwait.c
@@ -103,10 +103,8 @@ int nxsig_timedwait(FAR const sigset_t *set, FAR struct 
siginfo *info,
                     FAR const struct timespec *timeout)
 {
   FAR struct tcb_s *rtcb;
-#ifdef CONFIG_ENABLE_ALL_SIGNALS
   sigset_t intersection;
   FAR sigpendq_t *sigpend;
-#endif
   irqstate_t flags;
   siginfo_t unbinfo;
   int ret;
@@ -122,7 +120,6 @@ int nxsig_timedwait(FAR const sigset_t *set, FAR struct 
siginfo *info,
   flags = enter_critical_section();
   rtcb  = this_task();
 
-#ifdef CONFIG_ENABLE_ALL_SIGNALS
   /* Check if there is a pending signal corresponding to one of the
    * signals in the pending signal set argument.
    */
@@ -159,7 +156,6 @@ int nxsig_timedwait(FAR const sigset_t *set, FAR struct 
siginfo *info,
   /* We will have to wait for a signal to be posted to this task. */
 
   else
-#endif
     {
       rtcb->sigunbinfo = (info == NULL) ? &unbinfo : info;
 
diff --git a/sched/signal/signal.h b/sched/signal/signal.h
index 549745c659f..46f64d56a52 100644
--- a/sched/signal/signal.h
+++ b/sched/signal/signal.h
@@ -166,9 +166,7 @@ struct task_group_s;
 
 /* sig_initializee.c */
 
-#ifdef CONFIG_ENABLE_ALL_SIGNALS
 void               nxsig_initialize(void);
-#endif
 
 /* sig_action.c */
 
@@ -194,10 +192,8 @@ int                nxsig_dispatch(pid_t pid, FAR siginfo_t 
*info,
 
 /* sig_cleanup.c */
 
-#ifdef CONFIG_ENABLE_ALL_SIGNALS
 void               nxsig_cleanup(FAR struct tcb_s *stcb);
 void               nxsig_release(FAR struct task_group_s *group);
-#endif
 
 /* sig_timedwait.c */
 
@@ -215,6 +211,13 @@ void               nxsig_release_pendingsigaction(FAR 
sigq_t *sigq);
 void               nxsig_release_pendingsignal(FAR sigpendq_t *sigpend);
 FAR sigpendq_t    *nxsig_remove_pendingsignal(FAR struct tcb_s *stcb,
                                               int signo);
+#ifndef CONFIG_DISABLE_ALL_SIGNALS
 bool               nxsig_unmask_pendingsignal(void);
+#else
+static inline bool nxsig_unmask_pendingsignal(void)
+{
+  return false;
+}
+#endif
 
 #endif /* __SCHED_SIGNAL_SIGNAL_H */
diff --git a/sched/task/task_exithook.c b/sched/task/task_exithook.c
index caece6bd99b..30703cd7862 100644
--- a/sched/task/task_exithook.c
+++ b/sched/task/task_exithook.c
@@ -455,7 +455,7 @@ void nxtask_exithook(FAR struct tcb_s *tcb, int status)
 
   /* Deallocate anything left in the TCB's queues */
 
-#ifdef CONFIG_ENABLE_ALL_SIGNALS
+#ifndef CONFIG_DISABLE_ALL_SIGNALS
   nxsig_cleanup(tcb); /* Deallocate Signal lists */
 #endif
 
diff --git a/sched/task/task_restart.c b/sched/task/task_restart.c
index d129945e89d..753b40c451f 100644
--- a/sched/task/task_restart.c
+++ b/sched/task/task_restart.c
@@ -119,10 +119,8 @@ static void nxtask_reset_task(FAR struct tcb_s *tcb, bool 
remove)
 
   /* Deallocate anything left in the TCB's signal queues */
 
-#ifdef CONFIG_ENABLE_ALL_SIGNALS
-  nxsig_cleanup(tcb);             /* Deallocate Signal lists */
-#endif
 #ifndef CONFIG_DISABLE_ALL_SIGNALS
+  nxsig_cleanup(tcb);             /* Deallocate Signal lists */
   sigemptyset(&tcb->sigprocmask); /* Reset sigprocmask */
 #endif
 
diff --git a/sched/task/task_setup.c b/sched/task/task_setup.c
index ad82567192f..65ee13e7f1c 100644
--- a/sched/task/task_setup.c
+++ b/sched/task/task_setup.c
@@ -403,7 +403,6 @@ static int nxthread_setup_scheduler(FAR struct tcb_s *tcb, 
int priority,
                                     start_t start, CODE void *entry,
                                     uint8_t ttype)
 {
-  FAR struct tcb_s *rtcb = this_task();
   irqstate_t flags;
   int ret;
 
@@ -462,7 +461,7 @@ static int nxthread_setup_scheduler(FAR struct tcb_s *tcb, 
int priority,
        */
 
 #ifndef CONFIG_DISABLE_ALL_SIGNALS
-      tcb->sigprocmask = rtcb->sigprocmask;
+      tcb->sigprocmask = this_task()->sigprocmask;
 #endif
 
       /* Initialize the task state.  It does not get a valid state

Reply via email to