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 d1191e0ad01 include/limits.h: Add LONG_BIT and WORD_BIT.
d1191e0ad01 is described below

commit d1191e0ad0167ac8fbad8bc5edcfcda5d856201d
Author: Marco Casaroli <[email protected]>
AuthorDate: Thu Nov 5 09:15:06 2026 +0100

    include/limits.h: Add LONG_BIT and WORD_BIT.
    
    POSIX (XSI) defines LONG_BIT and WORD_BIT in <limits.h>: the number of
    bits in a long and in an int.  Programs use them to size bit masks and
    bit arrays.  NuttX does not define them.
    
    Derive the values from LONG_MAX and INT_MAX of the architecture, so
    that they are correct for ILP32, LP64 and the targets with a 16-bit
    int.  The values work in #if.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Marco Casaroli <[email protected]>
---
 include/limits.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/include/limits.h b/include/limits.h
index 8ae80cec664..75b5d1fd217 100644
--- a/include/limits.h
+++ b/include/limits.h
@@ -193,6 +193,20 @@
 #  define CLOCK_MAX                             LLONG_MAX
 #endif
 
+/* The number of bits in a long and in an int (XSI) */
+
+#if LONG_MAX > 2147483647L
+#  define LONG_BIT                              64
+#else
+#  define LONG_BIT                              32
+#endif
+
+#if INT_MAX > 32767
+#  define WORD_BIT                              32
+#else
+#  define WORD_BIT                              16
+#endif
+
 /* Other invariant values */
 
 /* CHARCLASS_NAME_MAX

Reply via email to