wolfcrypt/src/wc_port.c: in wc_socket_cloexec(), add necessary but undocumented __USE_GNU gating on call to accept4() (pre-includes can bring in socket.h before the override setting of _GNU_SOURCE at the top). Also enable accept4() for FreeBSD.

This commit is contained in:
Daniel Pouzzner
2026-04-27 11:40:04 -05:00
parent 3279b367d7
commit 66ea4daa09
2 changed files with 7 additions and 1 deletions
+6 -1
View File
@@ -23,6 +23,9 @@
!defined(WOLFSSL_LINUXKM) && !defined(WOLFSSL_ZEPHYR) && \
!defined(_GNU_SOURCE)
#define _GNU_SOURCE 1
#elif defined(__FreeBSD__)
/* for __FreeBSD_version */
#include <sys/param.h>
#endif
/*
@@ -5210,7 +5213,9 @@ int wc_socket_cloexec(int domain, int type, int protocol)
int wc_accept_cloexec(int sockfd, void* addr, void* addrlen)
{
int fd;
#if defined(__linux__) || defined(__ANDROID__)
#if (defined(__USE_GNU) && (defined(__linux__) || defined(__ANDROID__))) || \
(defined(__FreeBSD__) && defined(__BSD_VISIBLE) && __BSD_VISIBLE && \
(__FreeBSD_version >= 1000000))
fd = accept4(sockfd, (struct sockaddr*)addr, (socklen_t*)addrlen,
SOCK_CLOEXEC);
if (fd >= 0)