Add __NDK_FPABI__ to function taking/returning float/double

Allow user code to be compiled with "-mhard-float" for armeabi-v7a
(which implies -mfloat-abi=hard), and either link with
1. Android native APIs which use softfp, or
2. A customized libm_hard.a which is compiled with -mhard-float. Need
   -D_NDK_MATH_NO_SOFTFP=1

See tests/device/hard-float/jni/Android.mk for details and restriction
on Clang

Change-Id: I773a842c73368e08b9a6cda0441e95a96fa303b2
This commit is contained in:
Andrew Hsieh
2013-10-16 16:26:26 +08:00
parent a36935be21
commit 5881b5cbe7
20 changed files with 1064 additions and 985 deletions

View File

@@ -499,4 +499,31 @@
#define __BIONIC__ 1
#include <android/api-level.h>
/* __NDK_FPABI__ or __NDK_FPABI_MATH__ are applied to APIs taking or returning float or
[long] double, to ensure even at the presence of -mhard-float (which implies
-mfloat-abi=hard), calling to 32-bit Android native APIs still follow -mfloat-abi=softfp.
__NDK_FPABI_MATH__ is applied to APIs in math.h. It normally equals to __NDK_FPABI__,
but allows use of customized libm.a compiled with -mhard-float by -D_NDK_MATH_NO_SOFTFP=1
NOTE: Disable for clang for now unless _NDK_MATH_NO_SOFTFP=1, because clang before 3.4 doesn't
allow change of calling convension for builtin and produces error message reads:
a.i:564:6: error: function declared 'aapcs' here was previously declared without calling convention
int sin(double d) __attribute__((pcs("aapcs")));
^
a.i:564:6: note: previous declaration is here
*/
#if defined(__ANDROID__) && !__LP64__ && defined( __arm__)
#define __NDK_FPABI__ __attribute__((pcs("aapcs")))
#else
#define __NDK_FPABI__
#endif
#if (!defined(_NDK_MATH_NO_SOFTFP) || _NDK_MATH_NO_SOFTFP != 1) && !defined(__clang__)
#define __NDK_FPABI_MATH__ __NDK_FPABI__
#else
#define __NDK_FPABI_MATH__ /* nothing */
#endif
#endif /* !_SYS_CDEFS_H_ */