diff --git a/3rdParty/libev/CMakeLists.txt b/3rdParty/libev/CMakeLists.txt index 536ff69e33..44cd7d9405 100755 --- a/3rdParty/libev/CMakeLists.txt +++ b/3rdParty/libev/CMakeLists.txt @@ -20,6 +20,9 @@ endif () project(libev VERSION 4.22) if (MSVC) + + set (FLAGS "${FLAGS} /FI\"${PROJECT_SOURCE_DIR}/ev_triagens_win32.h\"") + foreach (flag_var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG @@ -110,6 +113,8 @@ add_library(ev STATIC ${LIBEV_DIR}/event.c ) +set_target_properties(ev PROPERTIES COMPILE_FLAGS "${FLAGS}") + set(LIBEV_VERSION ${libev_VERSION} CACHE INTERNAL diff --git a/3rdParty/libev/ev_triagens_win32.h b/3rdParty/libev/ev_triagens_win32.h new file mode 100644 index 0000000000..8de0b7334d --- /dev/null +++ b/3rdParty/libev/ev_triagens_win32.h @@ -0,0 +1,12 @@ +// libev officially recommends to use _open_osfhandle to wrap a SOCKET +// handle into a file descriptor. However, one should never use +// _open_osfhandle for SOCKET handles. Therefore, we do the following +// hack: We simply cast a SOCKET handle to an int before we hand it over +// to libev. This means that we have to redefine the following three +// macros for our version of libev. We close the handle ourselves outside +// of libev. Please note that we only use libev for sockets and not for +// file descriptors of regular files! + +#define EV_FD_TO_WIN32_HANDLE(fd) ((SOCKET) fd) +#define EV_WIN32_HANDLE_TO_FD(handle) ((int) handle) +#define EV_WIN32_CLOSE_FD(fd)