Re: [PATCH] Fixed Android support

2017-05-31 Thread enh
On Wed, May 31, 2017 at 8:15 PM, Marc Lehmann  wrote:
> On Tue, May 30, 2017 at 05:28:07PM -0700, enh  wrote:
>> 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
>
> If android uses header files that don't match it's libc *on purpose* then
> android is way beyond broken.

no, these are the Android libc header files.

>> 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.
>
> configure is optional for libev, so a "proper" test wouldn't work.

i'm not sure what you're saying here: you already use configure and
have correctly used HAVE_ tests for other functions.

> This is clearly a bug in the android headers, and since it apparently only
> affects old versions, I don't think it makes sense to make things worse
> for users of higher quality platforms that have correct header files.

no, it's the opposite way round. older versions of Android didn't have
epoll_create1. newer versions do. if you want to keep building on NDK
r15 and later, you'll need to check for the function, not the
constant. (the constants come from the upstream kernel uapi header
files, and a given Android release doesn't mandate any corresponding
kernel version, so there's no way to version that.)

> I would suggest opening a bug against android so these obvious bugs get
> fixed instead of trying to push patches to the rest of the world to work
> around it.

i manage the Android libc/NDK team :-)

this change is a result the NDK catching up with the platform headers
after being years behind.

> Unrelated, the __ANDROID__ change will be in the next release.
>
> Greetings,
>
> --
> The choice of a   Deliantra, the free code+content MORPG
>   -==- _GNU_  http://www.deliantra.net
>   ==-- _   generation
>   ---==---(_)__  __   __  Marc Lehmann
>   --==---/ / _ \/ // /\ \/ /  schm...@schmorp.de
>   -=/_/_//_/\_,_/ /_/\_\

___
libev mailing list
libev@lists.schmorp.de
http://lists.schmorp.de/mailman/listinfo/libev

Re: [PATCH] Fixed Android support

2017-05-31 Thread Marc Lehmann
On Tue, May 30, 2017 at 05:28:07PM -0700, enh  wrote:
> 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

If android uses header files that don't match it's libc *on purpose* then
android is way beyond broken.

> 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.

configure is optional for libev, so a "proper" test wouldn't work.

This is clearly a bug in the android headers, and since it apparently only
affects old versions, I don't think it makes sense to make things worse
for users of higher quality platforms that have correct header files.

I would suggest opening a bug against android so these obvious bugs get
fixed instead of trying to push patches to the rest of the world to work
around it.

Unrelated, the __ANDROID__ change will be in the next release.

Greetings,

-- 
The choice of a   Deliantra, the free code+content MORPG
  -==- _GNU_  http://www.deliantra.net
  ==-- _   generation
  ---==---(_)__  __   __  Marc Lehmann
  --==---/ / _ \/ // /\ \/ /  schm...@schmorp.de
  -=/_/_//_/\_,_/ /_/\_\

___
libev mailing list
libev@lists.schmorp.de
http://lists.schmorp.de/mailman/listinfo/libev

[PATCH] Fixed Android support

2017-05-31 Thread enh
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.c18 Feb 2016 04:48:05 -  1.480
+++ ev.c31 May 2017 00:27:06 -
@@ -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 -  1.71
+++ ev_epoll.c  31 May 2017 00:27:06 -
@@ -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.m428 Oct 2013 12:36:44 -  1.16
+++ libev.m431 May 2017 00:27:06 -
@@ -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