From 836eaa62dfc3b13fbd6a202e4470075573147304 Mon Sep 17 00:00:00 2001 From: Greg McGary Date: Tue, 12 Dec 2017 16:51:17 -0800 Subject: [PATCH] Explicitly #define isnan __builtin_isnan for Android clang-5 to mimic gcc's default behavior Summary: GCC internally aliases isnan and a dozen other math.h primitives to their `__builtin_` counterparts, which compile straight to assembler. Clang does not do this, so calls to `isnan` compile to a function call. The Android libc does not define `isnan` because it assumes all application code compiled `__builtin_isnan` and has no need for the function `isnan`. This is a temporary kludge: Starting with NDK r16, the math.h header has appropriate `#defines` to alias primitives to their `__builtin_` counterparts. Upon upgrade to NDK r16, this can be reverted. Reviewed By: passy Differential Revision: D6527499 fbshipit-source-id: 65d9e43c7e7d973a6c92e9863ebe469b35a24ac8 --- yoga/Yoga.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/yoga/Yoga.cpp b/yoga/Yoga.cpp index fb0388d2..3ccd103c 100644 --- a/yoga/Yoga.cpp +++ b/yoga/Yoga.cpp @@ -133,6 +133,13 @@ static int YGDefaultLog(const YGConfigRef config, #endif bool YGFloatIsUndefined(const float value) { +// TODO(gkm): Ugh! Some Android builds (r13b & clang-3.8) fail +// with the kludge below, so we must tailor it specifically for +// NDK r15c which has clang-5.0. NDK r16 will make it all better. +#if __ANDROID__ && __clang_major__ == 5 // TODO(gkm): remove for NDK >= 16 +#undef isnan +#define isnan __builtin_isnan +#endif return isnan(value); }