[Mesa-dev] [PATCH mesa] meson/configure: detect endian.h instead of trying to guess when it's available

Jonathan Gray jsg at jsg.id.au
Wed Mar 28 03:05:00 UTC 2018


On Tue, Mar 27, 2018 at 07:36:17PM +0100, Emil Velikov wrote:
> On 25 March 2018 at 09:06, Jonathan Gray <jsg at jsg.id.au> wrote:
> > On Wed, Mar 21, 2018 at 05:09:17PM +0000, Eric Engestrom wrote:
> >> Cc: Maxin B. John <maxin.john at gmail.com>
> >> Cc: Khem Raj <raj.khem at gmail.com>
> >> Suggested-by: Jon Turney <jon.turney at dronecode.org.uk>
> >> Signed-off-by: Eric Engestrom <eric.engestrom at imgtec.com>
> >> ---
> >>  configure.ac        | 1 +
> >>  meson.build         | 2 +-
> >>  src/util/u_endian.h | 2 +-
> >>  3 files changed, 3 insertions(+), 2 deletions(-)
> >
> > OpenBSD and I suspect other systems have an endian.h that does not have
> > the __ defines like glibc.
> >
> Sigh, I guess the C/POSIX commitee should really wake up and add that
> to the standard.
> ... one way or another.
> 
> Jonathan can you play around with AC_CHECK_DECLS and send a patch that
> works on your end?
> 
> Thanks
> Emil
> 
> [1] https://www.gnu.org/software/autoconf/manual/autoconf-2.62/html_node/Generic-Declarations.html

Or just change the header?

Some care is needed as '#if undefined == undefined' becomes '#if 0 == 0'
which is true...

diff --git a/src/util/u_endian.h b/src/util/u_endian.h
index e11b381588..bf3b8707a1 100644
--- a/src/util/u_endian.h
+++ b/src/util/u_endian.h
@@ -30,9 +30,17 @@
 #ifdef HAVE_ENDIAN_H
 #include <endian.h>
 
-#if __BYTE_ORDER == __LITTLE_ENDIAN
+/* glibc */
+#if defined(__BYTE_ORDER) && (__BYTE_ORDER == __LITTLE_ENDIAN)
 # define PIPE_ARCH_LITTLE_ENDIAN
-#elif __BYTE_ORDER == __BIG_ENDIAN
+#elif defined(__BYTE_ORDER) && (__BYTE_ORDER == __BIG_ENDIAN)
+# define PIPE_ARCH_BIG_ENDIAN
+#endif
+
+/* OpenBSD */
+#if defined(BYTE_ORDER) && (BYTE_ORDER == LITTLE_ENDIAN)
+# define PIPE_ARCH_LITTLE_ENDIAN
+#elif defined(BYTE_ORDER) && (BYTE_ORDER == BIG_ENDIAN)
 # define PIPE_ARCH_BIG_ENDIAN
 #endif
 
@@ -54,8 +62,8 @@
 # define PIPE_ARCH_BIG_ENDIAN
 #endif
 
-#elif defined(__OpenBSD__) || defined(__NetBSD__) || \
-      defined(__FreeBSD__) || defined(__DragonFly__)
+#elif defined(__NetBSD__) || defined(__FreeBSD__) || \
+      defined(__DragonFly__)
 #include <sys/types.h>
 #include <machine/endian.h>
 


More information about the mesa-dev mailing list