[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 28 09:26:19 UTC 2018


On Wednesday, 2018-03-28 14:05:00 +1100, Jonathan Gray wrote:
> 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?

Or just add `_DEFAULT_SOURCE` to the build, allowing glibc to use
non-underscored names?

I was meaning to send a patch with this, but I'm swamped right now and
haven't have a change to do this, but I'd rather not duplicate the block
like suggested below.

Automatic ack from me on a patch that adds this define to all the build
systems, replaces all 3 names with their non-underscored variants and
adds a `#ifndef BYTE_ORDER #error "BYTE_ORDER undefined" #endif`.

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

Agreed :)

> 
> 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