summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt9
-rw-r--r--cmake/eventfd_test.cpp8
-rw-r--r--src/CMakeLists.txt6
3 files changed, 18 insertions, 5 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 310b9d431..0e863bf06 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -331,14 +331,12 @@ endif(CMAKE_BUILD_TYPE STREQUAL "DEBUG" OR CMAKE_BUILD_TYPE STREQUAL "RELWITHDEB
# Check for the existance of the following include files
check_include_file(sys/types.h HAVE_SYS_TYPES_H)
check_include_file(strings.h HAVE_STRINGS_H)
-check_include_file(sys/eventfd.h HAVE_SYS_EVENTFD_H)
# Check for the existance of the following functions
check_function_exists(setgrent HAVE_SETGRENT)
check_function_exists(strcasecmp HAVE_STRCASECMP)
check_function_exists(stricmp HAVE_STRICMP)
check_function_exists(umask HAVE_UMASK)
-check_function_exists(eventfd HAVE_EVENTFD)
check_function_exists(epoll_wait HAVE_EPOLL)
check_function_exists(poll HAVE_POLL)
check_function_exists(kqueue HAVE_KQUEUE)
@@ -353,6 +351,13 @@ check_type_size(int32_t INT32_T)
check_type_size(uint32_t UINT32_T)
check_type_size(u_int32_t U_INT32_T)
+# Check if eventfd works
+try_run(EVENTFD_TEST_RUN_RESULT EVENTFD_TEST_COMPILE_RESULT ${CMAKE_CURRENT_BINARY_DIR} ${Anope_SOURCE_DIR}/cmake/eventfd_test.cpp)
+set(HAVE_EVENTFD FALSE)
+if (EVENTFD_TEST_COMPILE_RESULT AND EVENTFD_TEST_RUN_RESULT EQUAL 1)
+ set(HAVE_EVENTFD TRUE)
+endif(EVENTFD_TEST_COMPILE_RESULT AND EVENTFD_TEST_RUN_RESULT EQUAL 1)
+
# Strip the leading and trailing spaces from the compile flags
if(CXXFLAGS)
strip_string(${CXXFLAGS} CXXFLAGS)
diff --git a/cmake/eventfd_test.cpp b/cmake/eventfd_test.cpp
new file mode 100644
index 000000000..8abd9c381
--- /dev/null
+++ b/cmake/eventfd_test.cpp
@@ -0,0 +1,8 @@
+#include <sys/eventfd.h>
+
+int main()
+{
+ int i = eventfd(0, EFD_NONBLOCK);
+ return i > 0 ? 1 : 0;
+}
+
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 292da5a3f..3c21ba477 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -11,12 +11,12 @@ if(WIN32)
else(WIN32)
append_to_list(SRC_SRCS threadengines/threadengine_pthread.cpp)
# If we have eventfd, use it
- if(HAVE_EVENTFD AND HAVE_SYS_EVENTFD_H)
+ if(HAVE_EVENTFD)
append_to_list(SRC_SRCS socketengines/pipeengine_eventfd.cpp)
# Else fall back to pipe
- else(HAVE_EVENTFD AND HAVE_SYS_EVENTFD_H)
+ else(HAVE_EVENTFD)
append_to_list(SRC_SRCS socketengines/pipeengine_pipe.cpp)
- endif(HAVE_EVENTFD AND HAVE_SYS_EVENTFD_H)
+ endif(HAVE_EVENTFD)
endif(WIN32)
if(HAVE_EPOLL)