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

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


The following commit(s) were added to refs/heads/master by this push:
     new 1eba3515851 signal: Inline nxsig_addset(), nxsig_delset() and 
nxsig_ismember().
1eba3515851 is described below

commit 1eba3515851adf0b6c88167339088a4765680f2c
Author: Marco Casaroli <[email protected]>
AuthorDate: Tue Sep 29 15:31:18 2026 +0200

    signal: Inline nxsig_addset(), nxsig_delset() and nxsig_ismember().
    
    Each was an out-of-line function in libc around one bit operation and a
    range check.  The kernel calls them on its signal paths, often with a
    constant signal number, where the check folds away.
    
    Move them into the header as static inline.  sigaddset(), sigdelset()
    and sigismember() stay in libc and call them as before.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Marco Casaroli <[email protected]>
---
 include/nuttx/signal.h          | 43 +++++++++++++++++++++++++++++++++++------
 libs/libc/signal/sig_addset.c   | 39 -------------------------------------
 libs/libc/signal/sig_delset.c   | 39 -------------------------------------
 libs/libc/signal/sig_ismember.c | 39 -------------------------------------
 4 files changed, 37 insertions(+), 123 deletions(-)

diff --git a/include/nuttx/signal.h b/include/nuttx/signal.h
index 41d42dba568..f58dc6f901f 100644
--- a/include/nuttx/signal.h
+++ b/include/nuttx/signal.h
@@ -31,6 +31,7 @@
 
 #include <sys/types.h>
 #include <stdbool.h>
+#include <errno.h>
 #include <signal.h>
 
 #include <nuttx/wqueue.h>
@@ -138,11 +139,9 @@ extern "C"
 #endif
 
 /****************************************************************************
- * Public Function Prototypes
+ * Inline Functions
  ****************************************************************************/
 
-struct timespec;  /* Forward reference */
-
 /****************************************************************************
  * Name: nxsig_ismember
  *
@@ -166,7 +165,15 @@ struct timespec;  /* Forward reference */
  *
  ****************************************************************************/
 
-int nxsig_ismember(FAR const sigset_t *set, int signo);
+static inline int nxsig_ismember(FAR const sigset_t *set, int signo)
+{
+  if (!GOOD_SIGNO(signo))
+    {
+      return -EINVAL;
+    }
+
+  return (set->_elem[_SIGSET_NDX(signo)] & _SIGNO2SET(signo)) ? 1 : 0;
+}
 
 /****************************************************************************
  * Name: nxsig_addset
@@ -190,7 +197,16 @@ int nxsig_ismember(FAR const sigset_t *set, int signo);
  *
  ****************************************************************************/
 
-int nxsig_addset(FAR sigset_t *set, int signo);
+static inline int nxsig_addset(FAR sigset_t *set, int signo)
+{
+  if (!GOOD_SIGNO(signo))
+    {
+      return -EINVAL;
+    }
+
+  set->_elem[_SIGSET_NDX(signo)] |= _SIGNO2SET(signo);
+  return OK;
+}
 
 /****************************************************************************
  * Name: nxsig_delset
@@ -214,7 +230,22 @@ int nxsig_addset(FAR sigset_t *set, int signo);
  *
  ****************************************************************************/
 
-int nxsig_delset(FAR sigset_t *set, int signo);
+static inline int nxsig_delset(FAR sigset_t *set, int signo)
+{
+  if (!GOOD_SIGNO(signo))
+    {
+      return -EINVAL;
+    }
+
+  set->_elem[_SIGSET_NDX(signo)] &= ~_SIGNO2SET(signo);
+  return OK;
+}
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+struct timespec;  /* Forward reference */
 
 /****************************************************************************
  * Name: nxsig_nandset
diff --git a/libs/libc/signal/sig_addset.c b/libs/libc/signal/sig_addset.c
index 57d00c70fb5..001806be06e 100644
--- a/libs/libc/signal/sig_addset.c
+++ b/libs/libc/signal/sig_addset.c
@@ -32,45 +32,6 @@
  * Public Functions
  ****************************************************************************/
 
-/****************************************************************************
- * Name: nxsig_addset
- *
- * Description:
- *   This function adds the signal specified by signo to the signal set
- *   specified by set.
- *
- * Input Parameters:
- *   set   - Signal set to add signal to
- *   signo - Signal to add
- *
- * Returned Value:
- *   This is an internal OS interface and should not be used by applications.
- *   It follows the NuttX internal error return policy:  Zero (OK) is
- *   returned on success.  A negated errno value is returned on failure.
- *
- *    EINVAL - The signo argument is invalid.
- *
- * Assumptions:
- *
- ****************************************************************************/
-
-int nxsig_addset(FAR sigset_t *set, int signo)
-{
-  /* Verify the signal */
-
-  if (!GOOD_SIGNO(signo))
-    {
-      return -EINVAL;
-    }
-  else
-    {
-      /* Add the signal to the set */
-
-      set->_elem[_SIGSET_NDX(signo)] |= _SIGNO2SET(signo);
-      return OK;
-    }
-}
-
 /****************************************************************************
  * Name: sigaddset
  *
diff --git a/libs/libc/signal/sig_delset.c b/libs/libc/signal/sig_delset.c
index 29d6a960667..3269dbc3095 100644
--- a/libs/libc/signal/sig_delset.c
+++ b/libs/libc/signal/sig_delset.c
@@ -32,45 +32,6 @@
  * Public Functions
  ****************************************************************************/
 
-/****************************************************************************
- * Name: nxsig_delset
- *
- * Description:
- *   This function deletes the signal specified by signo from the signal
- *   set specified by the 'set' argument.
- *
- * Input Parameters:
- *   set - Signal set to delete the signal from
- *   signo - Signal to delete
- *
- * Returned Value:
- *   This is an internal OS interface and should not be used by applications.
- *   It follows the NuttX internal error return policy:  Zero (OK) is
- *   returned on success.  A negated errno value is returned on failure.
- *
- *    EINVAL - The signo argument is invalid.
- *
- * Assumptions:
- *
- ****************************************************************************/
-
-int nxsig_delset(FAR sigset_t *set, int signo)
-{
-  /* Verify the signal */
-
-  if (!GOOD_SIGNO(signo))
-    {
-      return -EINVAL;
-    }
-  else
-    {
-      /* Remove the signal from the set */
-
-      set->_elem[_SIGSET_NDX(signo)] &= ~_SIGNO2SET(signo);
-      return OK;
-    }
-}
-
 /****************************************************************************
  * Name: sigdelset
  *
diff --git a/libs/libc/signal/sig_ismember.c b/libs/libc/signal/sig_ismember.c
index d0333ddb1b9..d5c553f39fa 100644
--- a/libs/libc/signal/sig_ismember.c
+++ b/libs/libc/signal/sig_ismember.c
@@ -33,45 +33,6 @@
  * Public Functions
  ****************************************************************************/
 
-/****************************************************************************
- * Name: nxsig_ismember
- *
- * Description:
- *   This function tests whether the signal specified by signo is a member
- *   of the set specified by set.
- *
- * Input Parameters:
- *   set - Signal set to test
- *   signo - Signal to test for
- *
- * Returned Value:
- *   This is an internal OS interface and should not be used by applications.
- *   On success, it returns 0 if the signal is not a member, 1 if the signal
- *   is a member of the set.
- *   A negated errno value is returned on failure.
- *
- *    EINVAL - The signo argument is invalid.
- *
- * Assumptions:
- *
- ****************************************************************************/
-
-int nxsig_ismember(FAR const sigset_t *set, int signo)
-{
-  /* Verify the signal */
-
-  if (!GOOD_SIGNO(signo))
-    {
-      return -EINVAL;
-    }
-  else
-    {
-      /* Check if the signal is in the set */
-
-      return (set->_elem[_SIGSET_NDX(signo)] & _SIGNO2SET(signo)) ? 1 : 0;
-    }
-}
-
 /****************************************************************************
  * Name: sigismember
  *

Reply via email to