On Wed, Jun 19, 2019 at 2:28 PM Joseph Van Riper <vanriper.t...@gmail.com> wrote: > > CMake uses this library for some of its work, but it doesn't compile on Linux > kernels previous to 2.6.27 thanks to a missing epoll_create1 function > introduced in 2.6.26. > > I can provide an update that would address this by using preprocessor > directives to test the kernel version and appropriately use epoll_create or > epoll_create1, but in testing, I still see five tests failing (within my use > case): > > not ok 48 - fs_copyfile > # exit code 134 > # Output from process `fs_copyfile`: > # Assertion failed in test/test-fs-copyfile.c on line 126: r == 0 > > not ok 63 - fs_event_watch_file_twice > # exit code 134 > # Output from process `fs_event_watch_file_twice`: > # Assertion failed in test/test-fs-event.c on line 635: 0 == > uv_fs_event_start(watchers + 0, fail_cb, path, 0) > > not ok 91 - fs_readdir_file > # exit code 134 > # Output from process `fs_readdir_file`: > # Assertion failed in test/test-fs-readdir.c on line 244: r == UV_ENOTDIR > > not ok 98 - fs_scandir_file > # exit code 134 > # Output from process `fs_scandir_file`: > # Assertion failed in test/test-fs.c on line 2541: r == UV_ENOTDIR > > not ok 166 - pipe_connect_to_file > # exit code 134 > # Output from process `pipe_connect_to_file`: > # Assertion failed in test/test-pipe-connect-error.c on line 53: status == > UV_ENOTSOCK || status == UV_ECONNREFUSED > > > > I strongly doubt the changes I made caused these failures, though. My > changes look like this: > > #include <linux/version.h> > > > #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) > /* epoll_create1 unavailable in these kernels */ > #define NO_EPOLL_CREATE1 > #endif > #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,8) > /* epoll_create ignores the size parameter in these kernels */ > #define EPOLL_IGNORE_SIZE > #endif > > (after the other #includes, followed by): > > int uv__platform_loop_init(uv_loop_t* loop) { > int fd; > > #ifndef NO_EPOLL_CREATE1 > > > /* It was reported that EPOLL_CLOEXEC is not defined on Android API < 21, > * a.k.a. Lollipop. Since EPOLL_CLOEXEC is an alias for O_CLOEXEC on all > * architectures, we just use that instead. > */ > fd = epoll_create1(O_CLOEXEC); > > #elif defined EPOLL_IGNORE_SIZE > > fd = epoll_create(1); > > #else > > fd = -1; > errno = ENOSYS; > > #endif > > /* epoll_create1() can fail either because it's not implemented (old kernel) > * or because it doesn't understand the O_CLOEXEC flag. > */ > if (fd == -1 && (errno == ENOSYS || errno == EINVAL)) { > fd = epoll_create(256); > > if (fd != -1) > uv__cloexec(fd, 1); > } > > loop->backend_fd = fd; > loop->inotify_fd = -1; > loop->inotify_watchers = NULL; > > if (fd == -1) > return UV__ERR(errno); > > return 0; > } > > > I'm hesitant to submit this because of the failures, even though the tests > succeed in a normal use case (building for a current Linux OS with normal > toolkits). > > Recommendations?
I agree the test failures are unrelated to your change. As to the change itself, libuv does feature detection at runtime, not compile time. Rather than sniffing system headers, it makes the system call directly (using syscall()) and checks for ENOSYS. We used to have wrappers for epoll until not too long ago but I removed those in https://github.com/libuv/libuv/pull/1372 and now libuv goes through libc. I'd be okay with restoring the wrappers for epoll_create() and epoll_create1() if that helps out cmake as long as it's understood that it comes with absolutely no promise of support. You're welcome to open a pull request. Check the other pull request to see how to implement it. -- You received this message because you are subscribed to the Google Groups "libuv" group. To unsubscribe from this group and stop receiving emails from it, send an email to libuv+unsubscr...@googlegroups.com. To post to this group, send email to libuv@googlegroups.com. Visit this group at https://groups.google.com/group/libuv. To view this discussion on the web visit https://groups.google.com/d/msgid/libuv/CAHQurc_9c7J46Fy0xG7aMDrp3x%2B1h1xD%2BzC6w66WrLQOFU6nnw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.