aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/unix/async.c84
-rw-r--r--src/unix/linux-syscalls.c37
-rw-r--r--src/unix/linux-syscalls.h5
3 files changed, 13 insertions, 113 deletions
diff --git a/src/unix/async.c b/src/unix/async.c
index a5c47bca..26d337e0 100644
--- a/src/unix/async.c
+++ b/src/unix/async.c
@@ -33,9 +33,12 @@
#include <string.h>
#include <unistd.h>
+#ifdef __linux__
+#include <sys/eventfd.h>
+#endif
+
static void uv__async_send(uv_loop_t* loop);
static int uv__async_start(uv_loop_t* loop);
-static int uv__async_eventfd(void);
int uv_async_init(uv_loop_t* loop, uv_async_t* handle, uv_async_cb async_cb) {
@@ -190,36 +193,18 @@ static int uv__async_start(uv_loop_t* loop) {
if (loop->async_io_watcher.fd != -1)
return 0;
- err = uv__async_eventfd();
- if (err >= 0) {
- pipefd[0] = err;
- pipefd[1] = -1;
- }
- else if (err == UV_ENOSYS) {
- err = uv__make_pipe(pipefd, UV__F_NONBLOCK);
-#if defined(__linux__)
- /* Save a file descriptor by opening one of the pipe descriptors as
- * read/write through the procfs. That file descriptor can then
- * function as both ends of the pipe.
- */
- if (err == 0) {
- char buf[32];
- int fd;
-
- snprintf(buf, sizeof(buf), "/proc/self/fd/%d", pipefd[0]);
- fd = uv__open_cloexec(buf, O_RDWR);
- if (fd >= 0) {
- uv__close(pipefd[0]);
- uv__close(pipefd[1]);
- pipefd[0] = fd;
- pipefd[1] = fd;
- }
- }
-#endif
- }
+#ifdef __linux__
+ err = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
+ if (err < 0)
+ return UV__ERR(errno);
+ pipefd[0] = err;
+ pipefd[1] = -1;
+#else
+ err = uv__make_pipe(pipefd, UV__F_NONBLOCK);
if (err < 0)
return err;
+#endif
uv__io_init(&loop->async_io_watcher, uv__async_io, pipefd[0]);
uv__io_start(loop, &loop->async_io_watcher, POLLIN);
@@ -253,46 +238,3 @@ void uv__async_stop(uv_loop_t* loop) {
uv__close(loop->async_io_watcher.fd);
loop->async_io_watcher.fd = -1;
}
-
-
-static int uv__async_eventfd(void) {
-#if defined(__linux__)
- static int no_eventfd2;
- static int no_eventfd;
- int fd;
-
- if (no_eventfd2)
- goto skip_eventfd2;
-
- fd = uv__eventfd2(0, UV__EFD_CLOEXEC | UV__EFD_NONBLOCK);
- if (fd != -1)
- return fd;
-
- if (errno != ENOSYS)
- return UV__ERR(errno);
-
- no_eventfd2 = 1;
-
-skip_eventfd2:
-
- if (no_eventfd)
- goto skip_eventfd;
-
- fd = uv__eventfd(0);
- if (fd != -1) {
- uv__cloexec(fd, 1);
- uv__nonblock(fd, 1);
- return fd;
- }
-
- if (errno != ENOSYS)
- return UV__ERR(errno);
-
- no_eventfd = 1;
-
-skip_eventfd:
-
-#endif
-
- return UV_ENOSYS;
-}
diff --git a/src/unix/linux-syscalls.c b/src/unix/linux-syscalls.c
index de085055..e971e82a 100644
--- a/src/unix/linux-syscalls.c
+++ b/src/unix/linux-syscalls.c
@@ -34,26 +34,6 @@
# endif
#endif /* __arm__ */
-#ifndef __NR_eventfd
-# if defined(__x86_64__)
-# define __NR_eventfd 284
-# elif defined(__i386__)
-# define __NR_eventfd 323
-# elif defined(__arm__)
-# define __NR_eventfd (UV_SYSCALL_BASE + 351)
-# endif
-#endif /* __NR_eventfd */
-
-#ifndef __NR_eventfd2
-# if defined(__x86_64__)
-# define __NR_eventfd2 290
-# elif defined(__i386__)
-# define __NR_eventfd2 328
-# elif defined(__arm__)
-# define __NR_eventfd2 (UV_SYSCALL_BASE + 356)
-# endif
-#endif /* __NR_eventfd2 */
-
#ifndef __NR_inotify_init
# if defined(__x86_64__)
# define __NR_inotify_init 253
@@ -186,23 +166,6 @@
# endif
#endif /* __NR_getrandom */
-int uv__eventfd(unsigned int count) {
-#if defined(__NR_eventfd)
- return syscall(__NR_eventfd, count);
-#else
- return errno = ENOSYS, -1;
-#endif
-}
-
-
-int uv__eventfd2(unsigned int count, int flags) {
-#if defined(__NR_eventfd2)
- return syscall(__NR_eventfd2, count, flags);
-#else
- return errno = ENOSYS, -1;
-#endif
-}
-
int uv__inotify_init(void) {
#if defined(__NR_inotify_init)
diff --git a/src/unix/linux-syscalls.h b/src/unix/linux-syscalls.h
index 82400d77..35ef43e8 100644
--- a/src/unix/linux-syscalls.h
+++ b/src/unix/linux-syscalls.h
@@ -31,9 +31,6 @@
#include <sys/time.h>
#include <sys/socket.h>
-#define UV__EFD_CLOEXEC O_CLOEXEC
-#define UV__EFD_NONBLOCK O_NONBLOCK
-
#define UV__IN_CLOEXEC O_CLOEXEC
#define UV__IN_NONBLOCK O_NONBLOCK
@@ -94,8 +91,6 @@ struct uv__mmsghdr {
unsigned int msg_len;
};
-int uv__eventfd(unsigned int count);
-int uv__eventfd2(unsigned int count, int flags);
int uv__inotify_init(void);
int uv__inotify_init1(int flags);
int uv__inotify_add_watch(int fd, const char* path, uint32_t mask);