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 4e778461141 include/sys/param.h: Define the byte order macros.
4e778461141 is described below
commit 4e778461141e899d79b6a94626496ad7f229f41a
Author: Marco Casaroli <[email protected]>
AuthorDate: Sun Nov 1 19:36:45 2026 +0100
include/sys/param.h: Define the byte order macros.
glibc and the BSDs define BYTE_ORDER, LITTLE_ENDIAN and BIG_ENDIAN in
<sys/param.h>, and programs test them after they include only that
header (for example autoconf's AC_C_BIGENDIAN). NuttX defines them only
in <sys/endian.h>. An undefined name is 0 in #if, so
"#if BYTE_ORDER == BIG_ENDIAN" is true on every target and such a program
takes its big-endian path.
Define the three macros in <sys/param.h> with the same values as in
<sys/endian.h>, so that a program can include both headers in any order.
Only these names are added: the byte swap macros stay in <sys/endian.h>.
Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marco Casaroli <[email protected]>
---
include/sys/param.h | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/include/sys/param.h b/include/sys/param.h
index 9f621000d26..c580e5c860e 100644
--- a/include/sys/param.h
+++ b/include/sys/param.h
@@ -38,6 +38,20 @@
#define MAXNAMLEN NAME_MAX
#define MAXPATHLEN PATH_MAX
+/* The byte order of the host, as in <sys/endian.h>. BSD systems and glibc
+ * give these names in <sys/param.h> too, and programs test them there
+ * (autoconf's AC_C_BIGENDIAN).
+ */
+
+#define LITTLE_ENDIAN 1234
+#define BIG_ENDIAN 4321
+
+#ifdef CONFIG_ENDIAN_BIG
+# define BYTE_ORDER BIG_ENDIAN
+#else
+# define BYTE_ORDER LITTLE_ENDIAN
+#endif
+
/* Macros for min/max. */
#ifndef MIN