Skip to content

Commit 66ea4da

Browse files
committed
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.
1 parent 3279b36 commit 66ea4da

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

.wolfssl_known_macro_extras

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,6 +1023,7 @@ __AVX512F__
10231023
__BCPLUSPLUS__
10241024
__BIG_ENDIAN__
10251025
__BORLANDC__
1026+
__BSD_VISIBLE
10261027
__CCRX__
10271028
__CC_ARM
10281029
__COMPILER_VER__

wolfcrypt/src/wc_port.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
!defined(WOLFSSL_LINUXKM) && !defined(WOLFSSL_ZEPHYR) && \
2424
!defined(_GNU_SOURCE)
2525
#define _GNU_SOURCE 1
26+
#elif defined(__FreeBSD__)
27+
/* for __FreeBSD_version */
28+
#include <sys/param.h>
2629
#endif
2730

2831
/*
@@ -5210,7 +5213,9 @@ int wc_socket_cloexec(int domain, int type, int protocol)
52105213
int wc_accept_cloexec(int sockfd, void* addr, void* addrlen)
52115214
{
52125215
int fd;
5213-
#if defined(__linux__) || defined(__ANDROID__)
5216+
#if (defined(__USE_GNU) && (defined(__linux__) || defined(__ANDROID__))) || \
5217+
(defined(__FreeBSD__) && defined(__BSD_VISIBLE) && __BSD_VISIBLE && \
5218+
(__FreeBSD_version >= 1000000))
52145219
fd = accept4(sockfd, (struct sockaddr*)addr, (socklen_t*)addrlen,
52155220
SOCK_CLOEXEC);
52165221
if (fd >= 0)

0 commit comments

Comments
 (0)