On android, many of the math function overloads for long double are available starting with API level 21[1]. This change makes those long double overloads conditional on __ANDROID_API__ being at 21 or newer. In a couple of cases, the function was first available with API level 18, and those have been adjusted as well.
Diff Detail
Event Timeline
I don't really understand why we need this. This goes from always having it available to only being available if the NDK user is targeting L or newer (which is definitely the minority of users because most people won't choose to cut their user base by ~1/2). The NDK has a compatibility shim that provides definitions for these on older platforms.
@danalbert Thanks for the feedback. The issue I was hitting is that for 19 and earlier, math.h puts these long double functions inside a #if 0 block. Where does the compatibility shim come from? Does it include declarations for these long double functions?
The shim is part of the NDK: https://android.googlesource.com/platform/ndk/+/master/sources/android/support/include/math.h
The issue I was hitting is that for 19 and earlier, math.h puts these long double functions inside a #if 0 block.
Which math.h are we talking about? There are three in play here: libc++'s, libc's, and libandroid_support's.
Which math.h are we talking about? There are three in play here: libc++'s, libc's, and libandroid_support's.
I'm not sure where it is on android.googlesource.com, but in the NDK release it's this one: platforms/android-19/arch-arm/usr/include/math.h.
The current bionic header gives us a clearer picture: https://android.googlesource.com/platform/bionic/+/master/libc/include/math.h#240
So yes, most of these were missing until somewhat recently. libandroid_support provides these things though (if it's missing any, that's still the right place to fix this).
We've also debated just defaulting to using a static libm for Android since all that stuff can be safely statically linked across platform versions, so there's really no reason to not always use the latest version.