mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-10-24 04:09:07 +03:00
Detect accept4 in configure/CMake. Enable accept4 for musl. Musl has no dedicated macro so it is detected as non glibc/bionic/uclibc on Linux/Android.
This commit is contained in:
@@ -1388,6 +1388,7 @@ __TMS320C55X__
|
||||
__TURBOC__
|
||||
__UCLIBC_LINUX_SPECIFIC__
|
||||
__UCLIBC_MAJOR__
|
||||
__UCLIBC__
|
||||
__UNIX__
|
||||
__USE_GNU
|
||||
__USE_MISC
|
||||
|
||||
@@ -145,6 +145,7 @@ check_function_exists("socket" HAVE_SOCKET)
|
||||
check_function_exists("strftime" HAVE_STRFTIME)
|
||||
check_function_exists("__atomic_fetch_add" HAVE_C___ATOMIC)
|
||||
check_function_exists("getpid" HAVE_GETPID)
|
||||
check_function_exists("accept4" HAVE_ACCEPT4)
|
||||
|
||||
include(CheckSymbolExists)
|
||||
check_symbol_exists(isascii "ctype.h" HAVE_ISASCII)
|
||||
|
||||
@@ -13,6 +13,9 @@
|
||||
/* Define to 1 if you have the <errno.h> header file. */
|
||||
#cmakedefine HAVE_ERRNO_H @HAVE_ERRNO_H@
|
||||
|
||||
/* Define to 1 if you have the `accept4' function. */
|
||||
#cmakedefine HAVE_ACCEPT4 @HAVE_ACCEPT4@
|
||||
|
||||
/* Define to 1 if you have the `getaddrinfo' function. */
|
||||
#cmakedefine HAVE_GETADDRINFO @HAVE_GETADDRINFO@
|
||||
|
||||
|
||||
@@ -288,6 +288,9 @@ fi
|
||||
#include <sys/random.h>
|
||||
#endif
|
||||
]])
|
||||
# accept4() is declared under _GNU_SOURCE, which wc_port.c defines itself, so
|
||||
# linkability alone is decisive.
|
||||
AC_CHECK_FUNCS([accept4])
|
||||
|
||||
AC_PROG_INSTALL
|
||||
AC_TYPE_SIZE_T
|
||||
|
||||
@@ -42,10 +42,8 @@
|
||||
* technique mcdc_fault_hash.h uses for the hash primitives. Ordering is
|
||||
* load-bearing and mirrors that header exactly:
|
||||
* 1. define _GNU_SOURCE before the first libc header, exactly as
|
||||
* wc_port.c does at its own top. Without it glibc does not declare
|
||||
* accept4(), __USE_GNU is never set, wc_port.c's WC_HAVE_ACCEPT4 stays
|
||||
* undefined, and the block that CONTAINS the target guard would
|
||||
* compile out of this TU entirely;
|
||||
* wc_port.c does at its own top, so that glibc declares accept4() for
|
||||
* the wrapper below;
|
||||
* 2. include <sys/socket.h> so the REAL accept4() declaration is in scope
|
||||
* and is never rewritten by the macro;
|
||||
* 3. define the wrapper, which is compiled BEFORE the macro exists and so
|
||||
@@ -63,6 +61,11 @@
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
|
||||
/* HAVE_ACCEPT4 for the gate below comes from config.h, as in wc_port.c. */
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#if (defined(__unix__) || defined(__APPLE__)) && \
|
||||
!defined(WOLFSSL_LINUXKM) && !defined(WOLFSSL_KERNEL_MODE) && \
|
||||
!defined(WOLFSSL_ZEPHYR) && !defined(WOLFSSL_SGX)
|
||||
@@ -71,13 +74,23 @@
|
||||
#endif
|
||||
|
||||
/* The Linux half of wc_port.c's WC_HAVE_ACCEPT4 test; keep them identical. */
|
||||
#if (defined(__linux__) || defined(__ANDROID__)) && defined(__USE_GNU) && \
|
||||
((defined(__GLIBC__) && \
|
||||
(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10))) || \
|
||||
(defined(__UCLIBC_LINUX_SPECIFIC__) && (__UCLIBC_MAJOR__ >= 1)) || \
|
||||
(defined(__ANDROID_API__) && (__ANDROID_API__ >= 21)))
|
||||
#define WB_HAVE_ACCEPT4_HOOK
|
||||
#if defined(__linux__) || defined(__ANDROID__)
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#ifdef HAVE_ACCEPT4
|
||||
#define WB_HAVE_ACCEPT4_HOOK
|
||||
#endif
|
||||
#elif (defined(__USE_GNU) && \
|
||||
((defined(__GLIBC__) && \
|
||||
(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10))) || \
|
||||
(defined(__UCLIBC_LINUX_SPECIFIC__) && (__UCLIBC_MAJOR__ >= 1)) || \
|
||||
(defined(__ANDROID_API__) && (__ANDROID_API__ >= 21)))) || \
|
||||
(!defined(__GLIBC__) && !defined(__UCLIBC__) && \
|
||||
!defined(__ANDROID__))
|
||||
#define WB_HAVE_ACCEPT4_HOOK
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef WB_HAVE_ACCEPT4_HOOK
|
||||
/* 0 = pass through to the real accept4(); otherwise fail with this errno. */
|
||||
static int wb_accept4_errno = 0;
|
||||
|
||||
|
||||
@@ -5752,13 +5752,24 @@ char* wolfSSL_strnstr(const char* s1, const char* s2, size_t n)
|
||||
#define SOCK_CLOEXEC 0
|
||||
#endif
|
||||
|
||||
/* accept4(): glibc 2.10, uClibc-ng, bionic API 21, FreeBSD 10. */
|
||||
#if (defined(__linux__) || defined(__ANDROID__)) && defined(__USE_GNU) && \
|
||||
((defined(__GLIBC__) && \
|
||||
(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10))) || \
|
||||
(defined(__UCLIBC_LINUX_SPECIFIC__) && (__UCLIBC_MAJOR__ >= 1)) || \
|
||||
(defined(__ANDROID_API__) && (__ANDROID_API__ >= 21)))
|
||||
#define WC_HAVE_ACCEPT4
|
||||
/* accept4(): the configure/CMake probe (HAVE_ACCEPT4) decides when config.h
|
||||
* is in use; otherwise glibc 2.10, uClibc-ng, bionic API 21, and musl, which
|
||||
* has no identifying macro (Linux that is neither glibc, uClibc nor bionic).
|
||||
* FreeBSD 10. */
|
||||
#if defined(__linux__) || defined(__ANDROID__)
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#ifdef HAVE_ACCEPT4
|
||||
#define WC_HAVE_ACCEPT4
|
||||
#endif
|
||||
#elif (defined(__USE_GNU) && \
|
||||
((defined(__GLIBC__) && \
|
||||
(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10))) || \
|
||||
(defined(__UCLIBC_LINUX_SPECIFIC__) && (__UCLIBC_MAJOR__ >= 1)) || \
|
||||
(defined(__ANDROID_API__) && (__ANDROID_API__ >= 21)))) || \
|
||||
(!defined(__GLIBC__) && !defined(__UCLIBC__) && \
|
||||
!defined(__ANDROID__))
|
||||
#define WC_HAVE_ACCEPT4
|
||||
#endif
|
||||
#elif defined(__FreeBSD__) && defined(__BSD_VISIBLE) && __BSD_VISIBLE && \
|
||||
(__FreeBSD_version >= 1000000)
|
||||
#define WC_HAVE_ACCEPT4
|
||||
|
||||
Reference in New Issue
Block a user