On 2024-06-04 02:10, Collin Funk wrote:
Good point. Probably yes since they are public functions. '__gl' is used
for private functions (see stdbit.in.h and binary-io.h).

Yes, that makes sense. I installed the first attached patch into Gnulib.

Po, could you please try the second (obvious) attached patch for Emacs on Android? Thanks.
From 04445460de095884f53170937d5733e74daf2552 Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Tue, 4 Jun 2024 11:50:07 -0700
Subject: [PATCH] endian: port better to Android NDK r26
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* lib/endian.in.h (be16toh, be32toh, be64toh, htobe16, htobe32)
(htobe64, le16toh, le32toh, le64toh, htole16, htole32, htole64):
When @HAVE_ENDIAN_H@, define each NAME to rpl_NAME so that they
don’t interact incorrectly with system-defined implementations.
Problem reported by Po Lu for Android NDK r26 in:
https://lists.gnu.org/r/bug-gnulib/2024-06/msg00040.html
and this patch is an updated version of Collin Funk’s patch in:
https://lists.gnu.org/r/bug-gnulib/2024-06/msg00041.html
---
 ChangeLog       | 12 ++++++++++++
 lib/endian.in.h | 18 +++++++++++++++++-
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 1200ec0ec8..8e808fd6a8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2024-06-04  Paul Eggert  <egg...@cs.ucla.edu>
+
+	endian: port better to Android NDK r26
+	* lib/endian.in.h (be16toh, be32toh, be64toh, htobe16, htobe32)
+	(htobe64, le16toh, le32toh, le64toh, htole16, htole32, htole64):
+	When @HAVE_ENDIAN_H@, define each NAME to rpl_NAME so that they
+	don’t interact incorrectly with system-defined implementations.
+	Problem reported by Po Lu for Android NDK r26 in:
+	https://lists.gnu.org/r/bug-gnulib/2024-06/msg00040.html
+	and this patch is an updated version of Collin Funk’s patch in:
+	https://lists.gnu.org/r/bug-gnulib/2024-06/msg00041.html
+
 2024-06-04  Collin Funk  <collin.fu...@gmail.com>
 
 	boot-time, readutmp: Fix missing MinGW include (regr. 2024-05-24).
diff --git a/lib/endian.in.h b/lib/endian.in.h
index bd65ae8aab..156fe49fbd 100644
--- a/lib/endian.in.h
+++ b/lib/endian.in.h
@@ -69,8 +69,9 @@ _GL_INLINE_HEADER_BEGIN
 # define BYTE_ORDER LITTLE_ENDIAN
 #endif
 
-/* Make sure function-like macros get undefined.  */
 #if @HAVE_ENDIAN_H@
+
+/* Make sure we don't have any system definitions.  */
 # undef be16toh
 # undef be32toh
 # undef be64toh
@@ -83,6 +84,21 @@ _GL_INLINE_HEADER_BEGIN
 # undef htole16
 # undef htole32
 # undef htole64
+
+/* Define our own.  */
+# define be16toh rpl_endian_be16toh
+# define be32toh rpl_endian_be32toh
+# define be64toh rpl_endian_be64toh
+# define htobe16 rpl_endian_htobe16
+# define htobe32 rpl_endian_htobe32
+# define htobe64 rpl_endian_htobe64
+# define le16toh rpl_endian_le16toh
+# define le32toh rpl_endian_le32toh
+# define le64toh rpl_endian_le64toh
+# define htole16 rpl_endian_htole16
+# define htole32 rpl_endian_htole32
+# define htole64 rpl_endian_htole64
+
 #endif
 
 #ifdef __cplusplus
-- 
2.43.0

From 604f7b45f97d4fe4146646cd296494716de767a6 Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Tue, 4 Jun 2024 11:54:24 -0700
Subject: [PATCH] More-permanent fix for build with Android NDK r10b

* configure.ac (gl_cv_header_working_endian_h):
Remove temporary workaround for Android.
* lib/endian.in.h: Copy latest version from Gnulib.
---
 configure.ac    |  6 ------
 lib/endian.in.h | 18 +++++++++++++++++-
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/configure.ac b/configure.ac
index 369c9005c61..e3213f4ac79 100644
--- a/configure.ac
+++ b/configure.ac
@@ -49,12 +49,6 @@
     CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=32"
     enable_largefile=no
     enable_year2038=no])
-  # Further, endian.h is not guaranteed to define every function that
-  # Gnulib seeks to replace, but Gnulib tests are not prepared for
-  # such versions of endian.h as only define a subset of the functions
-  # whose presence it tests.  Force such tests to succeed as a stopgap
-  # measure.
-  gl_cv_header_working_endian_h=yes
 fi
 
 dnl Set emacs_config_options to the options of 'configure', quoted for the shell,
diff --git a/lib/endian.in.h b/lib/endian.in.h
index bd65ae8aaba..156fe49fbda 100644
--- a/lib/endian.in.h
+++ b/lib/endian.in.h
@@ -69,8 +69,9 @@ #define PDP_ENDIAN 3412
 # define BYTE_ORDER LITTLE_ENDIAN
 #endif
 
-/* Make sure function-like macros get undefined.  */
 #if @HAVE_ENDIAN_H@
+
+/* Make sure we don't have any system definitions.  */
 # undef be16toh
 # undef be32toh
 # undef be64toh
@@ -83,6 +84,21 @@ #define PDP_ENDIAN 3412
 # undef htole16
 # undef htole32
 # undef htole64
+
+/* Define our own.  */
+# define be16toh rpl_endian_be16toh
+# define be32toh rpl_endian_be32toh
+# define be64toh rpl_endian_be64toh
+# define htobe16 rpl_endian_htobe16
+# define htobe32 rpl_endian_htobe32
+# define htobe64 rpl_endian_htobe64
+# define le16toh rpl_endian_le16toh
+# define le32toh rpl_endian_le32toh
+# define le64toh rpl_endian_le64toh
+# define htole16 rpl_endian_htole16
+# define htole32 rpl_endian_htole32
+# define htole64 rpl_endian_htole64
+
 #endif
 
 #ifdef __cplusplus
-- 
2.43.0

Reply via email to