swrap: Provide a fcntl64()
[socket_wrapper.git] / ConfigureChecks.cmake
index 4a2f55e95258f67ad310f0c9671a28ce0333fa61..daaee2b53a09a6bcfff525917a8db275067a2e6f 100644 (file)
@@ -7,8 +7,8 @@ include(CheckStructHasMember)
 include(CheckPrototypeDefinition)
 include(TestBigEndian)
 
-set(PACKAGE ${PROJECT_NAME})
-set(VERSION ${PROJECT_VERSION})
+set(SOCKET_WRAPPER_PACKAGE ${PROJECT_NAME})
+set(SOCKET_WRAPPER_VERSION ${PROJECT_VERSION})
 
 set(BINARYDIR ${CMAKE_BINARY_DIR})
 set(SOURCEDIR ${CMAKE_SOURCE_DIR})
@@ -48,8 +48,10 @@ check_include_file(sys/filio.h HAVE_SYS_FILIO_H)
 check_include_file(sys/signalfd.h HAVE_SYS_SIGNALFD_H)
 check_include_file(sys/eventfd.h HAVE_SYS_EVENTFD_H)
 check_include_file(sys/timerfd.h HAVE_SYS_TIMERFD_H)
+check_include_file(sys/syscall.h HAVE_SYS_SYSCALL_H)
 check_include_file(gnu/lib-names.h HAVE_GNU_LIB_NAMES_H)
 check_include_file(rpc/rpc.h HAVE_RPC_RPC_H)
+check_include_file(syscall.h HAVE_SYSCALL_H)
 
 # SYMBOLS
 set(CMAKE_REQUIRED_FLAGS -D_GNU_SOURCE)
@@ -68,12 +70,18 @@ check_function_exists(timerfd_create HAVE_TIMERFD_CREATE)
 check_function_exists(bindresvport HAVE_BINDRESVPORT)
 check_function_exists(accept4 HAVE_ACCEPT4)
 check_function_exists(open64 HAVE_OPEN64)
+check_function_exists(openat64 HAVE_OPENAT64)
 check_function_exists(fopen64 HAVE_FOPEN64)
 check_function_exists(getprogname HAVE_GETPROGNAME)
 check_function_exists(getexecname HAVE_GETEXECNAME)
 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)
+check_function_exists(syscall HAVE_SYSCALL)
+check_function_exists(fcntl64 HAVE_FCNTL64)
 
 if (UNIX)
     find_library(DLFCN_LIBRARY dl)
@@ -146,6 +154,44 @@ if (HAVE_EVENTFD)
         HAVE_EVENTFD_UNSIGNED_INT)
 endif (HAVE_EVENTFD)
 
+if (HAVE_SYSCALL)
+    set(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
+
+    check_prototype_definition(syscall
+        "int syscall(int sysno, ...)"
+        "-1"
+        "unistd.h;sys/syscall.h"
+        HAVE_SYSCALL_INT)
+    set(CMAKE_REQUIRED_DEFINITIONS)
+endif (HAVE_SYSCALL)
+
+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>
@@ -216,6 +262,32 @@ int main(void) {
     return 0;
 }" HAVE_DESTRUCTOR_ATTRIBUTE)
 
+check_c_source_compiles("
+#pragma init (test_constructor)
+void test_constructor(void);
+
+void test_constructor(void)
+{
+    return;
+}
+
+int main(void) {
+    return 0;
+}" HAVE_PRAGMA_INIT)
+
+check_c_source_compiles("
+#pragma fini (test_destructor)
+void test_destructor(void);
+
+void test_destructor(void)
+{
+    return;
+}
+
+int main(void) {
+    return 0;
+}" HAVE_PRAGMA_FINI)
+
 check_c_source_compiles("
 #define FALL_THROUGH __attribute__((fallthrough))