src/socket_wrapper.c: implement recvmmsg and sendmmsg
[socket_wrapper.git] / ConfigureChecks.cmake
index 2c78b83f168dabde65f1c1b20dc7c03bc0ff0b31..ccf3c12cde2ab799333f90e3ebb939574802abcb 100644 (file)
@@ -75,6 +75,8 @@ check_function_exists(pledge HAVE_PLEDGE)
 check_function_exists(_socket HAVE__SOCKET)
 check_function_exists(_close HAVE__CLOSE)
 check_function_exists(__close_nocancel HAVE___CLOSE_NOCANCEL)
+check_function_exists(recvmmsg HAVE_RECVMMSG)
+check_function_exists(sendmmsg HAVE_SENDMMSG)
 
 if (UNIX)
     find_library(DLFCN_LIBRARY dl)
@@ -147,6 +149,33 @@ if (HAVE_EVENTFD)
         HAVE_EVENTFD_UNSIGNED_INT)
 endif (HAVE_EVENTFD)
 
+if (HAVE_RECVMMSG)
+    # Linux legacy glibc < 2.21
+    set(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
+    check_prototype_definition(recvmmsg
+        "int recvmmsg(int __fd, struct mmsghdr *__vmessages, unsigned int __vlen, int __flags, const struct timespec *__tmo)"
+        "-1"
+        "sys/types.h;sys/socket.h"
+        HAVE_RECVMMSG_CONST_TIMEOUT)
+    set(CMAKE_REQUIRED_DEFINITIONS)
+
+    # FreeBSD
+    check_prototype_definition(recvmmsg
+        "ssize_t recvmmsg(int __fd, struct mmsghdr * __restrict __vmessages, size_t __vlen, int __flags, const struct timespec * __restrict __tmo)"
+        "-1"
+        "sys/types.h;sys/socket.h"
+        HAVE_RECVMMSG_SSIZE_T_CONST_TIMEOUT)
+endif (HAVE_RECVMMSG)
+
+if (HAVE_SENDMMSG)
+    # FreeBSD
+    check_prototype_definition(sendmmsg
+        "ssize_t sendmmsg(int __fd, struct mmsghdr * __restrict __vmessages, size_t __vlen, int __flags)"
+        "-1"
+        "sys/types.h;sys/socket.h"
+        HAVE_SENDMMSG_SSIZE_T)
+endif (HAVE_SENDMMSG)
+
 # IPV6
 check_c_source_compiles("
     #include <stdlib.h>