The <sys/endian.h> header has existed in macOS since around ~26. This
causes the `htobeNN`/`htoleNN` macros to be redefined in <isc/endian.h>
in terms of <libkern/OSByteOrder.h> when other system headers include
<sys/endian.h>.
Fix this issue by using checking for the existence of <sys/endian.h> in
meson and including it according to the probe result.
#pragma once
-#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || \
- defined(__OpenBSD__) || defined(__bsdi__)
+#ifdef HAVE_SYS_ENDIAN_H
#include <sys/endian.h>
#define le64toh(x) letoh64(x)
#endif /* !be16toh */
-#elif defined __APPLE__
+#elif defined(__APPLE__)
/*
* macOS has its own byte-swapping routines, so use these.
'regex.h',
'stdckdint.h',
'sys/mman.h',
+ 'sys/endian.h',
'sys/select.h',
'sys/sockio.h',
'sys/sysctl.h',