The attached patch fixes Android NDK bug https://github.com/android-ndk/ndk/issues/396 --- basically the presence of EPOLL_CLOEXEC doesn't necessarily imply the presence of epoll_create1 on Android. This is because (as of NDK r15) we're using the same headers for all API levels, so even if you're targeting Gingerbread, you'll have all the enums and macros and structs from Marshmallow and O. so you actually need a proper configure test for epoll_create1.
It also seems that the existing Android support had bitrotted over the years, so this patch fixes that too (you need __ANDROID__, not ANDROID). With this patch I can build for either old or new releases (I tested with JellyBean and yet-to-be-released O), and I correctly get a reference to epoll_create1 or not, depending. I also checked that this didn't break glibc.
Index: ev.c =================================================================== RCS file: /schmorpforge/libev/ev.c,v retrieving revision 1.480 diff -u -r1.480 ev.c --- ev.c 18 Feb 2016 04:48:05 -0000 1.480 +++ ev.c 31 May 2017 00:27:06 -0000 @@ -365,13 +365,10 @@ # define EV_HEAP_CACHE_AT EV_FEATURE_DATA #endif -#ifdef ANDROID -/* supposedly, android doesn't typedef fd_mask */ -# undef EV_USE_SELECT -# define EV_USE_SELECT 0 -/* supposedly, we need to include syscall.h, not sys/syscall.h, so just disable */ -# undef EV_USE_CLOCK_SYSCALL -# define EV_USE_CLOCK_SYSCALL 0 +#ifdef __ANDROID__ +/* Android doesn't typedef fd_mask. */ +# undef EV_SELECT_USE_FD_SET +# define EV_SELECT_USE_FD_SET 1 #endif /* aix's poll.h seems to cause lots of trouble */ Index: ev_epoll.c =================================================================== RCS file: /schmorpforge/libev/ev_epoll.c,v retrieving revision 1.71 diff -u -r1.71 ev_epoll.c --- ev_epoll.c 18 Feb 2016 04:48:05 -0000 1.71 +++ ev_epoll.c 31 May 2017 00:27:06 -0000 @@ -239,7 +239,7 @@ int epoll_init (EV_P_ int flags) { -#ifdef EPOLL_CLOEXEC +#ifdef HAVE_EPOLL_CREATE1 backend_fd = epoll_create1 (EPOLL_CLOEXEC); if (backend_fd < 0 && (errno == EINVAL || errno == ENOSYS)) Index: libev.m4 =================================================================== RCS file: /schmorpforge/libev/libev.m4,v retrieving revision 1.16 diff -u -r1.16 libev.m4 --- libev.m4 28 Oct 2013 12:36:44 -0000 1.16 +++ libev.m4 31 May 2017 00:27:06 -0000 @@ -4,7 +4,7 @@ dnl libev support AC_CHECK_HEADERS(sys/inotify.h sys/epoll.h sys/event.h port.h poll.h sys/select.h sys/eventfd.h sys/signalfd.h) -AC_CHECK_FUNCS(inotify_init epoll_ctl kqueue port_create poll select eventfd signalfd) +AC_CHECK_FUNCS(inotify_init epoll_create1 epoll_ctl kqueue port_create poll select eventfd signalfd) AC_CHECK_FUNCS(clock_gettime, [], [ dnl on linux, try syscall wrapper first
_______________________________________________ libev mailing list libev@lists.schmorp.de http://lists.schmorp.de/mailman/listinfo/libev