Skip to content

Commit

Permalink
lib: monkey: sync windows macro changes
Browse files Browse the repository at this point in the history
Signed-off-by: Eduardo Silva <[email protected]>
  • Loading branch information
edsiper committed Aug 12, 2024
1 parent c28ebf5 commit 0e0ec91
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 38 deletions.
11 changes: 10 additions & 1 deletion lib/monkey/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,16 @@ include_directories(include/monkey/)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/monkey/)

if (MK_EVENT_LOOP_LIBEVENT)
# Check if we need to build libevent by using auto discovery mechanism
if (CMAKE_SYSTEM_NAME MATCHES "Windows" AND
(
NOT MK_EVENT_LOOP_SELECT AND
NOT MK_EVENT_LOOP_POLL AND
NOT MK_EVENT_LOOP_KQUEUE AND
NOT MK_EVENT_LOOP_EPOLL
) OR MK_EVENT_LOOP_LIBEVENT)

set(MK_EVENT_LOOP_LIBEVENT Yes)
include_directories(mk_core/deps/libevent/include)
include_directories("${PROJECT_BINARY_DIR}/mk_core/deps/libevent/include/")
endif()
Expand Down
34 changes: 16 additions & 18 deletions lib/monkey/include/monkey/mk_core/mk_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,28 +70,26 @@

#define MK_EVENT_IS_REGISTERED(event) ((event->status & MK_EVENT_REGISTERED) != 0)

#if defined(_WIN32)
#include "mk_event_libevent.c"
#if defined(MK_EVENT_LOOP_SELECT)
#include "mk_event_select.h"
#elif defined(MK_EVENT_LOOP_POLL)
#include "mk_event_poll.h"
#elif defined(MK_EVENT_LOOP_KQUEUE)
#include "mk_event_kqueue.h"
#elif defined(MK_EVENT_LOOP_EPOLL)
#include "mk_event_epoll.h"
#elif defined(MK_EVENT_LOOP_LIBEVENT)
#include "mk_event_libevent.h"
#else
#if defined(MK_EVENT_LOOP_SELECT)
#include "mk_event_select.h"
#elif defined(MK_EVENT_LOOP_POLL)
#include "mk_event_poll.h"
#elif defined(MK_EVENT_LOOP_KQUEUE)
#include "mk_event_kqueue.h"
#elif defined(MK_EVENT_LOOP_EPOLL)
/* do our best based on the operating system */
#if defined(__linux__)
#include "mk_event_epoll.h"
#elif defined(MK_EVENT_LOOP_LIBEVENT)
#elif defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__) || defined(__OpenBSD__)
#include "mk_event_kqueue.h"
#elif defined(_WIN32)
#include "mk_event_libevent.h"
#else
/* do our best based on the operating system */
#if defined(__linux__)
#include "mk_event_epoll.h"
#elif defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__) || defined(__OpenBSD__)
#include "mk_event_kqueue.h"
#else
#include "mk_event_select.h"
#endif
#include "mk_event_select.h"
#endif
#endif

Expand Down
34 changes: 15 additions & 19 deletions lib/monkey/mk_core/mk_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,33 +28,29 @@
#include <mk_core/mk_utils.h>
#include <mk_core/mk_event.h>


#if defined(_WIN32)
#if defined(MK_EVENT_LOOP_SELECT)
#include "mk_event_select.c"
#elif defined(MK_EVENT_LOOP_POLL)
#include "mk_event_poll.c"
#elif defined(MK_EVENT_LOOP_KQUEUE)
#include "mk_event_kqueue.c"
#elif defined(MK_EVENT_LOOP_EPOLL)
#include "mk_event_epoll.c"
#elif defined(MK_EVENT_LOOP_LIBEVENT)
#include "mk_event_libevent.c"
#else
#if defined(MK_EVENT_LOOP_SELECT)
#include "mk_event_select.c"
#elif defined(MK_EVENT_LOOP_POLL)
#include "mk_event_poll.c"
#elif defined(MK_EVENT_LOOP_KQUEUE)
#include "mk_event_kqueue.c"
#elif defined(MK_EVENT_LOOP_EPOLL)
/* do our best based on the operating system */
#if defined(__linux__)
#include "mk_event_epoll.c"
#elif defined(MK_EVENT_LOOP_LIBEVENT)
#elif defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__) || defined(__OpenBSD__)
#include "mk_event_kqueue.c"
#elif defined(_WIN32)
#include "mk_event_libevent.c"
#else
/* do our best based on the operating system */
#if defined(__linux__)
#include "mk_event_epoll.c"
#elif defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__) || defined(__OpenBSD__)
#include "mk_event_kqueue.c"
#else
#include "mk_event_select.c"
#endif
#include "mk_event_select.c"
#endif
#endif


/* Initialize backend */
int mk_event_init()
{
Expand Down

0 comments on commit 0e0ec91

Please sign in to comment.