diff --git a/src/unix/internal.h b/src/unix/internal.h index 23b1def3..469fd7d2 100644 --- a/src/unix/internal.h +++ b/src/unix/internal.h @@ -28,7 +28,7 @@ #include /* _POSIX_PATH_MAX, PATH_MAX */ #include /* abort */ #include /* strrchr */ -#include /* O_CLOEXEC, may be */ +#include /* O_CLOEXEC and O_NONBLOCK, if supported. */ #include #include @@ -284,8 +284,8 @@ int uv___stream_fd(const uv_stream_t* handle); #define uv__stream_fd(handle) ((handle)->io_watcher.fd) #endif /* defined(__APPLE__) */ -#ifdef UV__O_NONBLOCK -# define UV__F_NONBLOCK UV__O_NONBLOCK +#ifdef O_NONBLOCK +# define UV__F_NONBLOCK O_NONBLOCK #else # define UV__F_NONBLOCK 1 #endif diff --git a/src/unix/linux-syscalls.c b/src/unix/linux-syscalls.c index 476af66f..de085055 100644 --- a/src/unix/linux-syscalls.c +++ b/src/unix/linux-syscalls.c @@ -26,13 +26,6 @@ #include #include -#if defined(__has_feature) -# if __has_feature(memory_sanitizer) -# define MSAN_ACTIVE 1 -# include -# endif -#endif - #if defined(__arm__) # if defined(__thumb__) || defined(__ARM_EABI__) # define UV_SYSCALL_BASE 0 @@ -101,16 +94,6 @@ # endif #endif /* __NR_inotify_rm_watch */ -#ifndef __NR_pipe2 -# if defined(__x86_64__) -# define __NR_pipe2 293 -# elif defined(__i386__) -# define __NR_pipe2 331 -# elif defined(__arm__) -# define __NR_pipe2 (UV_SYSCALL_BASE + 359) -# endif -#endif /* __NR_pipe2 */ - #ifndef __NR_recvmmsg # if defined(__x86_64__) # define __NR_recvmmsg 299 @@ -257,21 +240,6 @@ int uv__inotify_rm_watch(int fd, int32_t wd) { } -int uv__pipe2(int pipefd[2], int flags) { -#if defined(__NR_pipe2) - int result; - result = syscall(__NR_pipe2, pipefd, flags); -#if MSAN_ACTIVE - if (!result) - __msan_unpoison(pipefd, sizeof(int[2])); -#endif - return result; -#else - return errno = ENOSYS, -1; -#endif -} - - int uv__sendmmsg(int fd, struct uv__mmsghdr* mmsg, unsigned int vlen, diff --git a/src/unix/linux-syscalls.h b/src/unix/linux-syscalls.h index dee7d1b5..82400d77 100644 --- a/src/unix/linux-syscalls.h +++ b/src/unix/linux-syscalls.h @@ -31,33 +31,11 @@ #include #include -#if defined(__alpha__) -# define UV__O_CLOEXEC 0x200000 -#elif defined(__hppa__) -# define UV__O_CLOEXEC 0x200000 -#elif defined(__sparc__) -# define UV__O_CLOEXEC 0x400000 -#else -# define UV__O_CLOEXEC 0x80000 -#endif +#define UV__EFD_CLOEXEC O_CLOEXEC +#define UV__EFD_NONBLOCK O_NONBLOCK -#if defined(__alpha__) -# define UV__O_NONBLOCK 0x4 -#elif defined(__hppa__) -# define UV__O_NONBLOCK O_NONBLOCK -#elif defined(__mips__) -# define UV__O_NONBLOCK 0x80 -#elif defined(__sparc__) -# define UV__O_NONBLOCK 0x4000 -#else -# define UV__O_NONBLOCK 0x800 -#endif - -#define UV__EFD_CLOEXEC UV__O_CLOEXEC -#define UV__EFD_NONBLOCK UV__O_NONBLOCK - -#define UV__IN_CLOEXEC UV__O_CLOEXEC -#define UV__IN_NONBLOCK UV__O_NONBLOCK +#define UV__IN_CLOEXEC O_CLOEXEC +#define UV__IN_NONBLOCK O_NONBLOCK /* inotify flags */ #define UV__IN_ACCESS 0x001 @@ -122,7 +100,6 @@ int uv__inotify_init(void); int uv__inotify_init1(int flags); int uv__inotify_add_watch(int fd, const char* path, uint32_t mask); int uv__inotify_rm_watch(int fd, int32_t wd); -int uv__pipe2(int pipefd[2], int flags); int uv__recvmmsg(int fd, struct uv__mmsghdr* mmsg, unsigned int vlen, diff --git a/src/unix/process.c b/src/unix/process.c index f0c1108e..d0d01a9e 100644 --- a/src/unix/process.c +++ b/src/unix/process.c @@ -140,23 +140,12 @@ static int uv__make_socketpair(int fds[2]) { int uv__make_pipe(int fds[2], int flags) { -#if defined(__linux__) - static int no_pipe2; - - if (no_pipe2) - goto skip; - - if (uv__pipe2(fds, flags | UV__O_CLOEXEC) == 0) - return 0; - - if (errno != ENOSYS) +#if defined(__FreeBSD__) || defined(__linux__) + if (pipe2(fds, flags | O_CLOEXEC)) return UV__ERR(errno); - no_pipe2 = 1; - -skip: -#endif - + return 0; +#else if (pipe(fds)) return UV__ERR(errno); @@ -169,6 +158,7 @@ skip: } return 0; +#endif }