fix: dev: include <sys/endian.h> according by checking in meson

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.

Merge branch 'aydin/isc-endian-macos-fix' into 'main'

See merge request isc-projects/bind9!11751
This commit is contained in:
Aydın Mercan 2026-03-31 16:07:05 +03:00
commit f27aba4d7d
2 changed files with 3 additions and 3 deletions

View file

@ -13,8 +13,7 @@
#pragma once
#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || \
defined(__OpenBSD__) || defined(__bsdi__)
#ifdef HAVE_SYS_ENDIAN_H
#include <sys/endian.h>
@ -32,7 +31,7 @@
#define le64toh(x) letoh64(x)
#endif /* !be16toh */
#elif defined __APPLE__
#elif defined(__APPLE__)
/*
* macOS has its own byte-swapping routines, so use these.

View file

@ -538,6 +538,7 @@ foreach h : [
'regex.h',
'stdckdint.h',
'sys/mman.h',
'sys/endian.h',
'sys/select.h',
'sys/sockio.h',
'sys/sysctl.h',