Merge pull request #4607 from kevans91/epoll

FreeBSD: epoll/timerfd support
This commit is contained in:
David Fort 2018-05-02 09:47:17 +02:00 committed by GitHub
commit 2dee696af0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 2 deletions

View File

@ -198,6 +198,16 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "BSD")
endif()
endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "DragonFly")
set(BSD TRUE)
set(FREEBSD TRUE)
endif()
if(FREEBSD)
find_path(EPOLLSHIM_INCLUDE_DIR NAMES sys/epoll.h sys/timerfd.h HINTS /usr/local/include/libepoll-shim)
find_library(EPOLLSHIM_LIBS NAMES epoll-shim libepoll-shim HINTS /usr/local/lib)
endif()
# Configure MSVC Runtime
if(MSVC)
include(MSVCRuntime)
@ -648,7 +658,13 @@ if(UNIX OR CYGWIN)
if (HAVE_SYS_EVENTFD_H)
check_symbol_exists(eventfd_read sys/eventfd.h WITH_EVENTFD_READ_WRITE)
endif()
if (FREEBSD)
list(APPEND CMAKE_REQUIRED_INCLUDES ${EPOLLSHIM_INCLUDE_DIR})
endif()
check_include_files(sys/timerfd.h HAVE_SYS_TIMERFD_H)
if (FREEBSD)
list(REMOVE_ITEM CMAKE_REQUIRED_INCLUDES ${EPOLLSHIM_INCLUDE_DIR})
endif()
check_include_files(poll.h HAVE_POLL_H)
list(APPEND CMAKE_REQUIRED_LIBRARIES m)
check_symbol_exists(ceill math.h HAVE_MATH_C99_LONG_DOUBLE)

View File

@ -40,6 +40,9 @@ generate_protocol_file(xdg-shell)
generate_protocol_file(ivi-application)
generate_protocol_file(fullscreen-shell)
if(FREEBSD)
include_directories(${EPOLLSHIM_INCLUDE_DIR})
endif()
include_directories(${WAYLAND_INCLUDE_DIR})
include_directories(${XKBCOMMON_INCLUDE_DIR})
include_directories("${CMAKE_SOURCE_DIR}/uwac/include")
@ -69,7 +72,7 @@ if (WITH_LIBRARY_VERSIONING)
set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${UWAC_VERSION} SOVERSION ${UWAC_API_VERSION})
endif()
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS} ${PRIVATE_KEYWORD} ${WAYLAND_LIBS} ${XKBCOMMON_LIBS} freerdp)
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS} ${PRIVATE_KEYWORD} ${WAYLAND_LIBS} ${XKBCOMMON_LIBS} ${EPOLLSHIM_LIBS} freerdp)
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR} EXPORT uwac)

View File

@ -29,8 +29,15 @@
#define _GNU_SOURCE
#if defined(__FreeBSD__) || defined(__DragonFly__)
#define USE_SHM
#endif
#include <sys/types.h>
#include <sys/socket.h>
#ifdef USE_SHM
#include <sys/mman.h>
#endif
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
@ -153,7 +160,9 @@ static int create_tmpfile_cloexec(char *tmpname)
{
int fd;
#ifdef HAVE_MKOSTEMP
#ifdef USE_SHM
fd = shm_open(SHM_ANON, O_CREAT | O_RDWR, 0600);
#elif defined(HAVE_MKOSTEMP)
fd = mkostemp(tmpname, O_CLOEXEC);
if (fd >= 0)
unlink(tmpname);

View File

@ -30,6 +30,11 @@ winpr_module_add(
timer.c
wait.c)
if(FREEBSD)
winpr_include_directory_add(${EPOLLSHIM_INCLUDE_DIR})
winpr_library_add(${EPOLLSHIM_LIBS})
endif()
if((NOT WIN32) AND (NOT APPLE) AND (NOT ANDROID) AND (NOT OPENBSD))
winpr_library_add(rt)
endif()