User Details
- User Since
- Mar 27 2017, 4:47 PM (400 w, 1 d)
- Availability
- Available
Dec 7 2013
Even if that function is never called on Android, it will need to be #ifdefed out
in order for that code to build for Android. Right now, linking fails because it
can't find the symbol pthread_atfork.
Dec 6 2013
Its also not in any headers in the NDK:
$ grep atfork /opt/android-ndk/platforms/android-*/arch-arm/usr/include/*.h
$ grep atfork /opt/android-ndk/platforms/android-*/arch-arm/usr/include/*/*.h
$
Bad news, though that .c/.cpp file exists, it does not seem to get built into
Android. I have tried building against android-14, which is after that file was
introduces, and no luck. I also tried looking for it in the libs, and its not
in the .so or .a libs. Running this gives me nothing:
$ strings /opt/android-ndk/platforms/android-*/arch-arm/usr/lib/* | grep atfork
Dec 5 2013
we've decided to suspend support for older versions on Android, so we can leave
this as is for now, any maybe forever. We want to support older versions, but
its more work than we can handle. Patches are welcome though, if anyone wants
to add back support for Android versions old than android-14/4.0/Ice Cream Sandwich.
It looks like pthread_atfork() was not added to bionic libc[1] until after
android-10/v2.3.6/Gingerbread. That excludes 1/4 of current Google Android
users, and probably more of unoffical Android users.[4] To target older
versions of Android, you either have to include pthread-atfork.c[2] or the newer
[pthread_atfork.cpp][3] in your project, or not use pthread_atfork() at all.
We might be able to manage including pthread-atfork.c, but it could be ugly.
[1]:
https://android.googlesource.com/platform/bionic.git/+/4f086aeb4aa06e13079b7fec71a8178ceeacf318
[2]:
https://android.googlesource.com/platform/bionic.git/+/android-4.0.1_r1/libc/bionic/pthread-atfork.c
[3]:
https://android.googlesource.com/platform/bionic.git/+/master/libc/bionic/pthread_atfork.cpp
[3]: https://developer.android.com/about/dashboards/index.html