diff options
author | Adam <Adam@anope.org> | 2011-10-22 12:45:55 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2011-10-22 12:45:55 -0400 |
commit | f4a0bdd54d80e740026b05c63ada4e71650a1959 (patch) | |
tree | e169e927c19fdfe1b32405fe1c1ec123cc4e479f | |
parent | 3e2ac3640d186004798269e6ca89938cb1da6f73 (diff) |
Added our own eventfd test for openvz machines which have eventfd but can not be used
-rw-r--r-- | CMakeLists.txt | 9 | ||||
-rw-r--r-- | cmake/eventfd_test.cpp | 8 | ||||
-rw-r--r-- | src/CMakeLists.txt | 6 |
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) |