From fcf6c877881626ee2ac94fc77051c79e3f7ae7ce Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Sun, 3 Oct 2021 13:33:16 +0200 Subject: Support operating systems without some non-POSIX headers The arpa/nameser.h, netinet/ip.h, and resolv.h headers are not crucial to building LibreSSL. The netinet/ip.h header is used in nc(1) for optional IPTOS_ features that can be ifdef'd on systems without support. The endian.h header is the upcoming standard header and should be used whenever available and correct. The machine/endian.h header is non-standard and doesn't have to exist on POSIX systems. Fix the check for getpagesize(3) not forward declaring the function, such that CFLAGS with -Werror=implicit-function-declaration doesn't cause the check to fail. --- include/compat/arpa/nameser.h | 2 ++ include/compat/machine/endian.h | 2 +- include/compat/netinet/ip.h | 2 ++ include/compat/resolv.h | 2 +- m4/check-libc.m4 | 6 ++---- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/include/compat/arpa/nameser.h b/include/compat/arpa/nameser.h index 0126a60..eff3b0d 100644 --- a/include/compat/arpa/nameser.h +++ b/include/compat/arpa/nameser.h @@ -4,7 +4,9 @@ */ #ifndef _WIN32 +#ifdef HAVE_ARPA_NAMESER_H #include_next +#endif #else #include diff --git a/include/compat/machine/endian.h b/include/compat/machine/endian.h index 4dcb60d..bb22f5b 100644 --- a/include/compat/machine/endian.h +++ b/include/compat/machine/endian.h @@ -21,7 +21,7 @@ #define BYTE_ORDER BIG_ENDIAN #endif -#elif defined(__linux__) || defined(__midipix__) +#elif defined(HAVE_ENDIAN_H) #include #elif defined(__sun) || defined(_AIX) || defined(__hpux) diff --git a/include/compat/netinet/ip.h b/include/compat/netinet/ip.h index 6019f7d..29f17f3 100644 --- a/include/compat/netinet/ip.h +++ b/include/compat/netinet/ip.h @@ -8,7 +8,9 @@ #endif #ifndef _WIN32 +#ifdef HAVE_NETINET_IP_H #include_next +#endif #else #include #endif diff --git a/include/compat/resolv.h b/include/compat/resolv.h index 42dec07..b804460 100644 --- a/include/compat/resolv.h +++ b/include/compat/resolv.h @@ -12,7 +12,7 @@ #else #include <../include/resolv.h> #endif -#else +#elif defined(HAVE_RESOLV_H) #include_next #endif diff --git a/m4/check-libc.m4 b/m4/check-libc.m4 index e511f6d..cca97c3 100644 --- a/m4/check-libc.m4 +++ b/m4/check-libc.m4 @@ -1,6 +1,7 @@ AC_DEFUN([CHECK_LIBC_COMPAT], [ # Check for libc headers AC_CHECK_HEADERS([err.h readpassphrase.h]) +AC_CHECK_HEADERS([arpa/nameser.h endian.h netinet/ip.h resolv.h]) # Check for general libc functions AC_CHECK_FUNCS([asprintf freezero memmem]) AC_CHECK_FUNCS([readpassphrase reallocarray recallocarray]) @@ -9,10 +10,7 @@ AC_CHECK_FUNCS([timegm _mkgmtime timespecsub]) AC_CHECK_FUNCS([getprogname syslog syslog_r]) AC_CACHE_CHECK([for getpagesize], ac_cv_func_getpagesize, [ AC_LINK_IFELSE([AC_LANG_PROGRAM([[ -// Since Android NDK v16 getpagesize is defined as inline inside unistd.h -#ifdef __ANDROID__ -# include -#endif +#include ]], [[ getpagesize(); ]])], -- cgit v1.2.3-55-g6feb