diff --git a/.wolfssl_known_macro_extras b/.wolfssl_known_macro_extras index 277703dd14..c676c15524 100644 --- a/.wolfssl_known_macro_extras +++ b/.wolfssl_known_macro_extras @@ -1023,6 +1023,7 @@ __AVX512F__ __BCPLUSPLUS__ __BIG_ENDIAN__ __BORLANDC__ +__BSD_VISIBLE __CCRX__ __CC_ARM __COMPILER_VER__ diff --git a/wolfcrypt/src/wc_port.c b/wolfcrypt/src/wc_port.c index 3ffb962de0..e84c385744 100644 --- a/wolfcrypt/src/wc_port.c +++ b/wolfcrypt/src/wc_port.c @@ -23,6 +23,9 @@ !defined(WOLFSSL_LINUXKM) && !defined(WOLFSSL_ZEPHYR) && \ !defined(_GNU_SOURCE) #define _GNU_SOURCE 1 +#elif defined(__FreeBSD__) + /* for __FreeBSD_version */ + #include #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)