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

Eric Engestrom eric.engestrom at imgtec.com
Wed Mar 21 17:56:10 UTC 2018


On Wednesday, 2018-03-21 17:54:02 +0000, Eric Engestrom wrote:
> On Wednesday, 2018-03-21 10:45:35 -0700, Dylan Baker wrote:
> > Quoting Eric Engestrom (2018-03-21 10:09:17)
> > > 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(-)
> > > 
> > > diff --git a/configure.ac b/configure.ac
> > > index 29d3c3457a7cdaefc36a..36c56da787e4fab5a355 100644
> > > --- a/configure.ac
> > > +++ b/configure.ac
> > > @@ -865,6 +865,7 @@ fi
> > >  AC_HEADER_MAJOR
> > >  AC_CHECK_HEADER([xlocale.h], [DEFINES="$DEFINES -DHAVE_XLOCALE_H"])
> > >  AC_CHECK_HEADER([sys/sysctl.h], [DEFINES="$DEFINES -DHAVE_SYS_SYSCTL_H"])
> > > +AC_CHECK_HEADER([endian.h], [DEFINES="$DEFINES -DHAVE_ENDIAN_H"])
> > >  AC_CHECK_FUNC([strtof], [DEFINES="$DEFINES -DHAVE_STRTOF"])
> > >  AC_CHECK_FUNC([mkostemp], [DEFINES="$DEFINES -DHAVE_MKOSTEMP"])
> > >  AC_CHECK_FUNC([timespec_get], [DEFINES="$DEFINES -DHAVE_TIMESPEC_GET"])
> > > diff --git a/meson.build b/meson.build
> > > index 88518ec0f0e9b81759a7..1132b4bd37075d8c9d21 100644
> > > --- a/meson.build
> > > +++ b/meson.build
> > > @@ -904,7 +904,7 @@ elif cc.has_header_symbol('sys/mkdev.h', 'major')
> > >    pre_args += '-DMAJOR_IN_MKDEV'
> > >  endif
> > >  
> > > -foreach h : ['xlocale.h', 'sys/sysctl.h', 'linux/futex.h']
> > > +foreach h : ['xlocale.h', 'sys/sysctl.h', 'linux/futex.h', 'endian.h']
> > >    if cc.compiles('#include <@0@>'.format(h), name : '@0@ works'.format(h))
> > >      pre_args += '-DHAVE_ at 0@'.format(h.to_upper().underscorify())
> > >    endif
> > > diff --git a/src/util/u_endian.h b/src/util/u_endian.h
> > > index 22d011ec0086ee77e11c..e11b381588dbc960e8c3 100644
> > > --- a/src/util/u_endian.h
> > > +++ b/src/util/u_endian.h
> > > @@ -27,7 +27,7 @@
> > >  #ifndef U_ENDIAN_H
> > >  #define U_ENDIAN_H
> > >  
> > > -#if defined(__GLIBC__) || defined(ANDROID) || defined(__CYGWIN__)
> > > +#ifdef HAVE_ENDIAN_H
> > 
> > is it really safe to remove the `defined(ANDROID)` check here?
> 
> I'm clearly too tired to do this...
> 
> Cc'ing Rob; can you tell us if defining HAVE_ENDIAN_H unconditionally in
> Android.mk seems reasonable? Or is there a way to detect headers on Android?

To be clear, I'm suggesting this:
----8<----
diff --git a/Android.common.mk b/Android.common.mk
index 52dc7bff3be5af1f97b6..e8aed48c31ab1704cbcf 100644
--- a/Android.common.mk
+++ b/Android.common.mk
@@ -70,6 +70,7 @@ LOCAL_CFLAGS += \
 	-DHAVE_DLADDR \
 	-DHAVE_DL_ITERATE_PHDR \
 	-DHAVE_LINUX_FUTEX_H \
+	-DHAVE_ENDIAN_H \
 	-DHAVE_ZLIB \
 	-DMAJOR_IN_SYSMACROS \
 	-fvisibility=hidden \
---->8----

> 
> I also forgot to add the check in scons; I just added this to the commit
> locally:
> ----8<----
> diff --git a/scons/gallium.py b/scons/gallium.py
> index 75200b89c1fe6d751980..6cb20efcbf4b8c997f60 100755
> --- a/scons/gallium.py
> +++ b/scons/gallium.py
> @@ -354,6 +354,9 @@ def generate(env):
>          if check_header(env, 'xlocale.h'):
>              cppdefines += ['HAVE_XLOCALE_H']
>  
> +        if check_header(env, 'endian.h'):
> +            cppdefines += ['HAVE_ENDIAN_H']
> +
>          if check_functions(env, ['strtod_l', 'strtof_l']):
>              cppdefines += ['HAVE_STRTOD_L']
>  
> ---->8----
> 
> > 
> > >  #include <endian.h>
> > >  
> > >  #if __BYTE_ORDER == __LITTLE_ENDIAN
> > > -- 
> > > Cheers,
> > >   Eric
> > > 
> > > _______________________________________________
> > > mesa-dev mailing list
> > > mesa-dev at lists.freedesktop.org
> > > https://lists.freedesktop.org/mailman/listinfo/mesa-dev
> > 


More information about the mesa-dev mailing list