util: unbreak endian detection on OpenBSD
Sincecbee1bfb34
endian.h is unconditionally used if available. glibc has byte order defines with two leading underscores. OpenBSD has private defines with a single leading underscore in machine/endian.h and public defines in endian.h with no underscore. The code under the endian.h block did not check if symbols were defined before equating them so '#if __BYTE_ORDER == __LITTLE_ENDIAN' would turn into '#if 0 == 0' which is always true. Fixes:cbee1bfb34
("meson/configure: detect endian.h instead of trying to guess when it's available") Signed-off-by: Jonathan Gray <jsg@jsg.id.au> Reviewed-by: Eric Engestrom <eric@engestrom.ch> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5630>
This commit is contained in:
parent
8301a43f27
commit
7eab6845e9
|
@ -30,10 +30,19 @@
|
||||||
#ifdef HAVE_ENDIAN_H
|
#ifdef HAVE_ENDIAN_H
|
||||||
#include <endian.h>
|
#include <endian.h>
|
||||||
|
|
||||||
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
/* glibc */
|
||||||
|
#if defined(__BYTE_ORDER) && (__BYTE_ORDER == __LITTLE_ENDIAN)
|
||||||
# define UTIL_ARCH_LITTLE_ENDIAN 1
|
# define UTIL_ARCH_LITTLE_ENDIAN 1
|
||||||
# define UTIL_ARCH_BIG_ENDIAN 0
|
# define UTIL_ARCH_BIG_ENDIAN 0
|
||||||
#elif __BYTE_ORDER == __BIG_ENDIAN
|
#elif defined(__BYTE_ORDER) && (__BYTE_ORDER == __BIG_ENDIAN)
|
||||||
|
# define UTIL_ARCH_LITTLE_ENDIAN 0
|
||||||
|
# define UTIL_ARCH_BIG_ENDIAN 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(BYTE_ORDER) && (BYTE_ORDER == LITTLE_ENDIAN)
|
||||||
|
# define UTIL_ARCH_LITTLE_ENDIAN 1
|
||||||
|
# define UTIL_ARCH_BIG_ENDIAN 0
|
||||||
|
#elif defined(BYTE_ORDER) && (BYTE_ORDER == BIG_ENDIAN)
|
||||||
# define UTIL_ARCH_LITTLE_ENDIAN 0
|
# define UTIL_ARCH_LITTLE_ENDIAN 0
|
||||||
# define UTIL_ARCH_BIG_ENDIAN 1
|
# define UTIL_ARCH_BIG_ENDIAN 1
|
||||||
#endif
|
#endif
|
||||||
|
@ -60,8 +69,8 @@
|
||||||
# define UTIL_ARCH_BIG_ENDIAN 1
|
# define UTIL_ARCH_BIG_ENDIAN 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#elif defined(__OpenBSD__) || defined(__NetBSD__) || \
|
#elif defined(__NetBSD__) || defined(__FreeBSD__) || \
|
||||||
defined(__FreeBSD__) || defined(__DragonFly__)
|
defined(__DragonFly__)
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <machine/endian.h>
|
#include <machine/endian.h>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue