Skip to content

Commit

Permalink
kqueue: add kqueue-based pollq implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
liamstask committed Feb 22, 2018
1 parent 3a0ca04 commit 73713b3
Show file tree
Hide file tree
Showing 4 changed files with 376 additions and 2 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ else ()
nng_check_sym (backtrace_symbols_fd execinfo.h NNG_HAVE_BACKTRACE)
nng_check_sym (alloca alloca.h NNG_HAVE_ALLOCA)
nng_check_struct_member(msghdr msg_control sys/socket.h NNG_HAVE_MSG_CONTROL)
nng_check_sym (kqueue sys/event.h NNG_HAVE_KQUEUE)
endif ()

nng_check_sym (strlcat string.h NNG_HAVE_STRLCAT)
Expand Down
13 changes: 11 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ set (NNG_SOURCES
core/transport.h
core/url.c
core/url.h
)
)

if (NNG_PLATFORM_POSIX)
set (NNG_SOURCES ${NNG_SOURCES}
Expand All @@ -98,7 +98,6 @@ if (NNG_PLATFORM_POSIX)
platform/posix/posix_ipc.c
platform/posix/posix_pipe.c
platform/posix/posix_pipedesc.c
platform/posix/posix_pollq_poll.c
platform/posix/posix_rand.c
platform/posix/posix_resolv_gai.c
platform/posix/posix_sockaddr.c
Expand All @@ -108,6 +107,16 @@ if (NNG_PLATFORM_POSIX)
)
endif()

if (NNG_HAVE_KQUEUE)
set (NNG_SOURCES ${NNG_SOURCES}
platform/posix/posix_pollq_kqueue.c
)
else()
set (NNG_SOURCES ${NNG_SOURCES}
platform/posix/posix_pollq_poll.c
)
endif()

if (NNG_PLATFORM_WINDOWS)
set (NNG_SOURCES ${NNG_SOURCES}
platform/windows/win_impl.h
Expand Down
5 changes: 5 additions & 0 deletions src/platform/posix/posix_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,12 @@
#define NNG_USE_CLOCKID CLOCK_REALTIME
#endif // CLOCK_REALTIME

#if defined(NNG_HAVE_KQUEUE)
// pass
#else
// fallback to poll(2)
#define NNG_USE_POSIX_POLLQ_POLL 1
#endif
#define NNG_USE_POSIX_RESOLV_GAI 1

#endif // NNG_PLATFORM_POSIX
Loading

0 comments on commit 73713b3

Please sign in to comment.