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

commit 0d2b21b3417d6520898c8d493e1c8165c760835a
Author: Marco Casaroli <[email protected]>
AuthorDate: Wed Nov 11 04:59:21 2026 +0100

    include/unistd.h: Add the sysconf() names of POSIX.1-2024.
    
    POSIX.1-2024 lists sysconf() names that <unistd.h> did not define:
    _SC_DEVICE_CONTROL, _SC_NSIG, _SC_THREAD_ROBUST_PRIO_INHERIT,
    _SC_THREAD_ROBUST_PRIO_PROTECT, _SC_V7_* and _SC_V8_* (the C
    compilation environments), and _SC_XOPEN_UUCP.  Define them and answer
    them in sysconf(): _SC_NSIG is NSIG; the robust mutex names follow the
    priority options and CONFIG_PTHREAD_MUTEX_UNSAFE; the environment names
    give the same values as the _SC_V6_* names.  NuttX has no
    posix_devctl() and no UUCP utilities: -1.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Marco Casaroli <[email protected]>
---
 include/unistd.h               | 14 ++++++++++++++
 libs/libc/unistd/lib_sysconf.c | 43 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 57 insertions(+)

diff --git a/include/unistd.h b/include/unistd.h
index 07682ef08e7..25a40c36435 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -335,6 +335,20 @@
 #define _SC_NPROCESSORS_CONF             0x007d
 #define _SC_NPROCESSORS_ONLN             0x007e
 
+#define _SC_DEVICE_CONTROL               0x007f
+#define _SC_NSIG                         0x0080
+#define _SC_THREAD_ROBUST_PRIO_INHERIT   0x0081
+#define _SC_THREAD_ROBUST_PRIO_PROTECT   0x0082
+#define _SC_V7_ILP32_OFF32               0x0083
+#define _SC_V7_ILP32_OFFBIG              0x0084
+#define _SC_V7_LP64_OFF64                0x0085
+#define _SC_V7_LPBIG_OFFBIG              0x0086
+#define _SC_V8_ILP32_OFF32               0x0087
+#define _SC_V8_ILP32_OFFBIG              0x0088
+#define _SC_V8_LP64_OFF64                0x0089
+#define _SC_V8_LPBIG_OFFBIG              0x008a
+#define _SC_XOPEN_UUCP                   0x008b
+
 /* Constants used with POSIX confstr(). */
 
 #define _CS_PATH                           1
diff --git a/libs/libc/unistd/lib_sysconf.c b/libs/libc/unistd/lib_sysconf.c
index 79fb6acdff6..f48c71d1a8e 100644
--- a/libs/libc/unistd/lib_sysconf.c
+++ b/libs/libc/unistd/lib_sysconf.c
@@ -33,6 +33,7 @@
 #include <unistd.h>
 #include <limits.h>
 #include <sched.h>
+#include <signal.h>
 #include <errno.h>
 
 #ifdef CONFIG_MM_PGSIZE
@@ -87,12 +88,14 @@
  *     getpwnam_r() data buffers
  *     {MQ_OPEN_MAX}                       _SC_MQ_OPEN_MAX
  *     {MQ_PRIO_MAX}                       _SC_MQ_PRIO_MAX
+ *     Highest signal number + 1           _SC_NSIG
  *     {OPEN_MAX}                          _SC_OPEN_MAX
  *     _POSIX_ADVISORY_INFO                _SC_ADVISORY_INFO
  *     _POSIX_BARRIERS                     _SC_BARRIERS
  *     _POSIX_ASYNCHRONOUS_IO              _SC_ASYNCHRONOUS_IO
  *     _POSIX_CLOCK_SELECTION              _SC_CLOCK_SELECTION
  *     _POSIX_CPUTIME                      _SC_CPUTIME
+ *     _POSIX_DEVICE_CONTROL               _SC_DEVICE_CONTROL
  *     _POSIX_FSYNC                        _SC_FSYNC
  *     _POSIX_IPV6                         _SC_IPV6
  *     _POSIX_JOB_CONTROL                  _SC_JOB_CONTROL
@@ -124,6 +127,8 @@
  *     _POSIX_THREAD_PRIO_PROTECT          _SC_THREAD_PRIO_PROTECT
  *     _POSIX_THREAD_PRIORITY_SCHEDULING   _SC_THREAD_PRIORITY_SCHEDULING
  *     _POSIX_THREAD_PROCESS_SHARED        _SC_THREAD_PROCESS_SHARED
+ *     _POSIX_THREAD_ROBUST_PRIO_INHERIT   _SC_THREAD_ROBUST_PRIO_INHERIT
+ *     _POSIX_THREAD_ROBUST_PRIO_PROTECT   _SC_THREAD_ROBUST_PRIO_PROTECT
  *     _POSIX_THREAD_SAFE_FUNCTIONS        _SC_THREAD_SAFE_FUNCTIONS
  *     _POSIX_THREAD_SPORADIC_SERVER       _SC_THREAD_SPORADIC_SERVER
  *     _POSIX_THREADS                      _SC_THREADS
@@ -143,6 +148,14 @@
  *     _POSIX_V6_ILP32_OFFBIG              _SC_V6_ILP32_OFFBIG
  *     _POSIX_V6_LP64_OFF64                _SC_V6_LP64_OFF64
  *     _POSIX_V6_LPBIG_OFFBIG              _SC_V6_LPBIG_OFFBIG
+ *     _POSIX_V7_ILP32_OFF32               _SC_V7_ILP32_OFF32
+ *     _POSIX_V7_ILP32_OFFBIG              _SC_V7_ILP32_OFFBIG
+ *     _POSIX_V7_LP64_OFF64                _SC_V7_LP64_OFF64
+ *     _POSIX_V7_LPBIG_OFFBIG              _SC_V7_LPBIG_OFFBIG
+ *     _POSIX_V8_ILP32_OFF32               _SC_V8_ILP32_OFF32
+ *     _POSIX_V8_ILP32_OFFBIG              _SC_V8_ILP32_OFFBIG
+ *     _POSIX_V8_LP64_OFF64                _SC_V8_LP64_OFF64
+ *     _POSIX_V8_LPBIG_OFFBIG              _SC_V8_LPBIG_OFFBIG
  *     _POSIX2_C_BIND                      _SC_2_C_BIND
  *     _POSIX2_C_DEV                       _SC_2_C_DEV
  *     _POSIX2_CHAR_TERM                   _SC_2_CHAR_TERM
@@ -186,6 +199,7 @@
  *     _XOPEN_SHM                          _SC_XOPEN_SHM
  *     _XOPEN_STREAMS                      _SC_XOPEN_STREAMS
  *     _XOPEN_UNIX                         _SC_XOPEN_UNIX
+ *     _XOPEN_UUCP                         _SC_XOPEN_UUCP
  *     _XOPEN_VERSION                      _SC_XOPEN_VERSION
  *
  * Returned Value:
@@ -292,6 +306,9 @@ long sysconf(int name)
       case _SC_NGROUPS_MAX:
         return NGROUPS_MAX;
 
+      case _SC_NSIG:
+        return NSIG;
+
       case _SC_OPEN_MAX:
         {
           struct rlimit rlim;
@@ -507,19 +524,41 @@ long sysconf(int name)
         return -1;
 #endif
 
+      case _SC_THREAD_ROBUST_PRIO_INHERIT:
+#if defined(CONFIG_PRIORITY_INHERITANCE) && !defined(CONFIG_DISABLE_PTHREAD) 
&& \
+    !defined(CONFIG_PTHREAD_MUTEX_UNSAFE)
+        return _POSIX_VERSION;
+#else
+        return -1;
+#endif
+
+      case _SC_THREAD_ROBUST_PRIO_PROTECT:
+#if defined(CONFIG_PRIORITY_PROTECT) && !defined(CONFIG_DISABLE_PTHREAD) && \
+    !defined(CONFIG_PTHREAD_MUTEX_UNSAFE)
+        return _POSIX_VERSION;
+#else
+        return -1;
+#endif
+
       /* The C-language compilation environment of this build */
 
       case _SC_V6_ILP32_OFF32:
+      case _SC_V7_ILP32_OFF32:
+      case _SC_V8_ILP32_OFF32:
       case _SC_XBS5_ILP32_OFF32:
         return sizeof(int) == 4 && sizeof(long) == 4 &&
                sizeof(FAR void *) == 4 && sizeof(off_t) == 4 ? 1 : -1;
 
       case _SC_V6_ILP32_OFFBIG:
+      case _SC_V7_ILP32_OFFBIG:
+      case _SC_V8_ILP32_OFFBIG:
       case _SC_XBS5_ILP32_OFFBIG:
         return sizeof(int) == 4 && sizeof(long) == 4 &&
                sizeof(FAR void *) == 4 && sizeof(off_t) == 8 ? 1 : -1;
 
       case _SC_V6_LP64_OFF64:
+      case _SC_V7_LP64_OFF64:
+      case _SC_V8_LP64_OFF64:
       case _SC_XBS5_LP64_OFF64:
         return sizeof(int) == 4 && sizeof(long) == 8 &&
                sizeof(FAR void *) == 8 && sizeof(off_t) == 8 ? 1 : -1;
@@ -544,6 +583,7 @@ long sysconf(int name)
       case _SC_2_UPE:
       case _SC_2_VERSION:
       case _SC_ADVISORY_INFO:
+      case _SC_DEVICE_CONTROL:
       case _SC_JOB_CONTROL:
       case _SC_MEMLOCK:
       case _SC_MEMLOCK_RANGE:
@@ -565,6 +605,8 @@ long sysconf(int name)
       case _SC_TRACE_USER_EVENT_MAX:
       case _SC_TYPED_MEMORY_OBJECTS:
       case _SC_V6_LPBIG_OFFBIG:
+      case _SC_V7_LPBIG_OFFBIG:
+      case _SC_V8_LPBIG_OFFBIG:
       case _SC_XBS5_LPBIG_OFFBIG:
       case _SC_XOPEN_CRYPT:
       case _SC_XOPEN_ENH_I18N:
@@ -573,6 +615,7 @@ long sysconf(int name)
       case _SC_XOPEN_REALTIME_THREADS:
       case _SC_XOPEN_SHM:
       case _SC_XOPEN_STREAMS:
+      case _SC_XOPEN_UUCP:
         return -1;
 
       default:

Reply via email to