]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
endian: Support multiple gnulib-tool invocations in the same package.
authorBruno Haible <bruno@clisp.org>
Tue, 28 Apr 2026 23:40:18 +0000 (01:40 +0200)
committerBruno Haible <bruno@clisp.org>
Tue, 28 Apr 2026 23:40:18 +0000 (01:40 +0200)
* lib/endian.in.h (GNULIB_defined_be16toh, GNULIB_defined_be32toh,
GNULIB_defined_be64toh, GNULIB_defined_htobe16, GNULIB_defined_htobe32,
GNULIB_defined_htobe64, GNULIB_defined_le16toh, GNULIB_defined_le32toh,
GNULIB_defined_le64toh, GNULIB_defined_htole16, GNULIB_defined_htole32,
GNULIB_defined_htole64): New macros.

ChangeLog
lib/endian.in.h

index 05d8f4e9f6660f8df2316f5f8682ec6100f51091..7ec80a5f3c2f8fa9373971db1a8e6f0a863f37c6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2026-04-28  Bruno Haible  <bruno@clisp.org>
+
+       endian: Support multiple gnulib-tool invocations in the same package.
+       * lib/endian.in.h (GNULIB_defined_be16toh, GNULIB_defined_be32toh,
+       GNULIB_defined_be64toh, GNULIB_defined_htobe16, GNULIB_defined_htobe32,
+       GNULIB_defined_htobe64, GNULIB_defined_le16toh, GNULIB_defined_le32toh,
+       GNULIB_defined_le64toh, GNULIB_defined_htole16, GNULIB_defined_htole32,
+       GNULIB_defined_htole64): New macros.
+
 2026-04-28  Bruno Haible  <bruno@clisp.org>
 
        arpa_inet-h: Support multiple gnulib-tool invocations in a package.
index 5eb603a12071403c0498fc95f0cc24f50f243e15..6fa0678f939bc640595af75481e514985a12a758 100644 (file)
@@ -120,138 +120,174 @@ _GL_BYTESWAP_INLINE uint_least64_t bswap_64 (uint_least64_t);
 
 /* Big endian to host.  */
 
+#if !GNULIB_defined_be16toh
 _GL_ENDIAN_INLINE uint16_t
 be16toh (uint16_t x)
 {
-#if BYTE_ORDER == BIG_ENDIAN
+# if BYTE_ORDER == BIG_ENDIAN
   return x;
-#else
+# else
   return bswap_16 (x);
-#endif
+# endif
 }
+# define GNULIB_defined_be16toh 1
+#endif
 
+#if !GNULIB_defined_be32toh
 _GL_ENDIAN_INLINE uint32_t
 be32toh (uint32_t x)
 {
-#if BYTE_ORDER == BIG_ENDIAN
+# if BYTE_ORDER == BIG_ENDIAN
   return x;
-#else
+# else
   return bswap_32 (x);
-#endif
+# endif
 }
+# define GNULIB_defined_be32toh 1
+#endif
 
 #ifdef UINT64_MAX
+# if !GNULIB_defined_be64toh
 _GL_ENDIAN_INLINE uint64_t
 be64toh (uint64_t x)
 {
-# if BYTE_ORDER == BIG_ENDIAN
+#  if BYTE_ORDER == BIG_ENDIAN
   return x;
-# else
+#  else
   return bswap_64 (x);
-# endif
+#  endif
 }
+#  define GNULIB_defined_be64toh 1
+# endif
 #endif
 
 /* Host to big endian.  */
 
+#if !GNULIB_defined_htobe16
 _GL_ENDIAN_INLINE uint16_t
 htobe16 (uint16_t x)
 {
-#if BYTE_ORDER == BIG_ENDIAN
+# if BYTE_ORDER == BIG_ENDIAN
   return x;
-#else
+# else
   return bswap_16 (x);
-#endif
+# endif
 }
+# define GNULIB_defined_htobe16 1
+#endif
 
+#if !GNULIB_defined_htobe32
 _GL_ENDIAN_INLINE uint32_t
 htobe32 (uint32_t x)
 {
-#if BYTE_ORDER == BIG_ENDIAN
+# if BYTE_ORDER == BIG_ENDIAN
   return x;
-#else
+# else
   return bswap_32 (x);
-#endif
+# endif
 }
+# define GNULIB_defined_htobe32 1
+#endif
 
 #ifdef UINT64_MAX
+# if !GNULIB_defined_htobe64
 _GL_ENDIAN_INLINE uint64_t
 htobe64 (uint64_t x)
 {
-# if BYTE_ORDER == BIG_ENDIAN
+#  if BYTE_ORDER == BIG_ENDIAN
   return x;
-# else
+#  else
   return bswap_64 (x);
-# endif
+#  endif
 }
+#  define GNULIB_defined_htobe64 1
+# endif
 #endif
 
 /* Little endian to host.  */
 
+#if !GNULIB_defined_le16toh
 _GL_ENDIAN_INLINE uint16_t
 le16toh (uint16_t x)
 {
-#if BYTE_ORDER == BIG_ENDIAN
+# if BYTE_ORDER == BIG_ENDIAN
   return bswap_16 (x);
-#else
+# else
   return x;
-#endif
+# endif
 }
+# define GNULIB_defined_le16toh 1
+#endif
 
+#if !GNULIB_defined_le32toh
 _GL_ENDIAN_INLINE uint32_t
 le32toh (uint32_t x)
 {
-#if BYTE_ORDER == BIG_ENDIAN
+# if BYTE_ORDER == BIG_ENDIAN
   return bswap_32 (x);
-#else
+# else
   return x;
-#endif
+# endif
 }
+# define GNULIB_defined_le32toh 1
+#endif
 
 #ifdef UINT64_MAX
+# if !GNULIB_defined_le64toh
 _GL_ENDIAN_INLINE uint64_t
 le64toh (uint64_t x)
 {
-# if BYTE_ORDER == BIG_ENDIAN
+#  if BYTE_ORDER == BIG_ENDIAN
   return bswap_64 (x);
-# else
+#  else
   return x;
-# endif
+#  endif
 }
+#  define GNULIB_defined_le64toh 1
+# endif
 #endif
 
 /* Host to little endian.  */
 
+#if !GNULIB_defined_htole16
 _GL_ENDIAN_INLINE uint16_t
 htole16 (uint16_t x)
 {
-#if BYTE_ORDER == BIG_ENDIAN
+# if BYTE_ORDER == BIG_ENDIAN
   return bswap_16 (x);
-#else
+# else
   return x;
-#endif
+# endif
 }
+# define GNULIB_defined_htole16 1
+#endif
 
+#if !GNULIB_defined_htole32
 _GL_ENDIAN_INLINE uint32_t
 htole32 (uint32_t x)
 {
-#if BYTE_ORDER == BIG_ENDIAN
+# if BYTE_ORDER == BIG_ENDIAN
   return bswap_32 (x);
-#else
+# else
   return x;
-#endif
+# endif
 }
+# define GNULIB_defined_htole32 1
+#endif
 
 #ifdef UINT64_MAX
+# if !GNULIB_defined_htole64
 _GL_ENDIAN_INLINE uint64_t
 htole64 (uint64_t x)
 {
-# if BYTE_ORDER == BIG_ENDIAN
+#  if BYTE_ORDER == BIG_ENDIAN
   return bswap_64 (x);
-# else
+#  else
   return x;
-# endif
+#  endif
 }
+#  define GNULIB_defined_htole64 1
+# endif
 #endif
 
 #ifdef __cplusplus