Skip to content

Commit

Permalink
WIP: check sys/epoll.h on configure
Browse files Browse the repository at this point in the history
  • Loading branch information
ko1 committed Aug 18, 2023
1 parent 0a8118d commit 1145506
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 2 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1342,6 +1342,8 @@ AC_CHECK_HEADERS(syscall.h)
AC_CHECK_HEADERS(time.h)
AC_CHECK_HEADERS(ucontext.h)
AC_CHECK_HEADERS(utime.h)
AC_CHECK_HEADERS(sys/epoll.h)

AS_CASE("$target_cpu", [x64|x86_64|i[3-6]86*], [
AC_CHECK_HEADERS(x86intrin.h)
])
Expand Down
16 changes: 10 additions & 6 deletions thread_pthread.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,15 @@ static pthread_condattr_t *condattr_monotonic = &condattr_mono;
static const void *const condattr_monotonic = NULL;
#endif

#ifndef HAVE_EPOLL
#define HAVE_EPOLL 0
#ifndef HAVE_SYS_EPOLL_H
#define HAVE_SYS_EPOLL_H 0
#else
// force setting for debug
// #undef HAVE_SYS_EPOLL_H
// #define HAVE_SYS_EPOLL_H 0
#endif

#if HAVE_EPOLL
#if HAVE_SYS_EPOLL_H
#include <sys/epoll.h>
#define USE_MN_THREADS 1
#else
Expand Down Expand Up @@ -2536,7 +2540,7 @@ static struct {

int comm_fds[2]; // r, w

#if HAVE_EPOLL
#if HAVE_SYS_EPOLL_H
#define EPOLL_EVENTS_MAX 0x10
int epoll_fd;
struct epoll_event finished_events[EPOLL_EVENTS_MAX];
Expand Down Expand Up @@ -2823,7 +2827,7 @@ rb_thread_create_timer_thread(void)
RUBY_DEBUG_LOG("forked child process");

CLOSE_INVALIDATE_PAIR(timer_th.comm_fds);
#if HAVE_EPOLL
#if HAVE_SYS_EPOLL_H
close_invalidate(&timer_th.epoll_fd, "close epoll_fd");
#endif
rb_native_mutex_destroy(&timer_th.waiting_lock);
Expand Down Expand Up @@ -2915,7 +2919,7 @@ rb_reserved_fd_p(int fd)

if (fd == timer_th.comm_fds[0] ||
fd == timer_th.comm_fds[1]
#if HAVE_EPOLL
#if HAVE_SYS_EPOLL_H
|| fd == timer_th.epoll_fd
#endif
) {
Expand Down

0 comments on commit 1145506

Please sign in to comment.