Revert "Use compiler builtins for fabs."

Use of "extern inline" breaks clang build.

This reverts commit d76f16973a9d06765fb1f482239b9559f893ffd0.

Change-Id: I995d0d38c3776f5c50b060f16770741c92a2acac
diff --git a/benchmarks/math_benchmark.cpp b/benchmarks/math_benchmark.cpp
index ed5b56c..2e0c962 100644
--- a/benchmarks/math_benchmark.cpp
+++ b/benchmarks/math_benchmark.cpp
@@ -258,29 +258,3 @@
 
   StopBenchmarkTiming();
 }
-
-BENCHMARK_WITH_ARG(BM_math_fabs_macro, double)->AT_COMMON_VALS;
-void BM_math_fabs_macro::Run(int iters, double value) {
-  StartBenchmarkTiming();
-
-  d = 0.0;
-  v = value;
-  for (int i = 0; i < iters; ++i) {
-    d += fabs(v);
-  }
-
-  StopBenchmarkTiming();
-}
-
-BENCHMARK_WITH_ARG(BM_math_fabs, double)->AT_COMMON_VALS;
-void BM_math_fabs::Run(int iters, double value) {
-  StartBenchmarkTiming();
-
-  d = 0.0;
-  v = value;
-  for (int i = 0; i < iters; ++i) {
-    d += (fabs)(v);
-  }
-
-  StopBenchmarkTiming();
-}
diff --git a/libm/Android.mk b/libm/Android.mk
index 2d55b1d..7b28f70 100644
--- a/libm/Android.mk
+++ b/libm/Android.mk
@@ -108,6 +108,8 @@
     upstream-freebsd/lib/msun/src/s_exp2.c \
     upstream-freebsd/lib/msun/src/s_exp2f.c \
     upstream-freebsd/lib/msun/src/s_expm1f.c \
+    upstream-freebsd/lib/msun/src/s_fabs.c \
+    upstream-freebsd/lib/msun/src/s_fabsf.c \
     upstream-freebsd/lib/msun/src/s_fdim.c \
     upstream-freebsd/lib/msun/src/s_finite.c \
     upstream-freebsd/lib/msun/src/s_finitef.c \
@@ -173,6 +175,7 @@
     upstream-freebsd/lib/msun/src/s_copysignl.c \
     upstream-freebsd/lib/msun/src/e_coshl.c \
     upstream-freebsd/lib/msun/src/s_cosl.c \
+    upstream-freebsd/lib/msun/src/s_fabsl.c \
     upstream-freebsd/lib/msun/src/s_floorl.c \
     upstream-freebsd/lib/msun/src/s_fmal.c \
     upstream-freebsd/lib/msun/src/s_fmaxl.c \
@@ -225,10 +228,6 @@
 LOCAL_SRC_FILES += \
     signbit.c \
 
-# Home-grown stuff.
-LOCAL_SRC_FILES += \
-    fabs.cpp \
-
 # Arch specific optimizations.
 
 # -----------------------------------------------------------------------------
diff --git a/libm/fabs.cpp b/libm/fabs.cpp
deleted file mode 100644
index add73fe..0000000
--- a/libm/fabs.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <math.h>
-
-#include "fpmath.h"
-
-double fabs(double x) {
-#if __arm__
-  // Both Clang and GCC insist on moving r0/r1 into a double register
-  // and using fabs where bit-twiddling would be a better choice.
-  // They get fabsf right, but we need to be careful in fabsl too.
-  IEEEd2bits u;
-  u.d = x;
-  u.bits.sign = 0;
-  return u.d;
-#else
-  return __builtin_fabs(x);
-#endif
-}
-
-float fabsf(float x) {
-  return __builtin_fabsf(x);
-}
-
-#if defined(__LP64__)
-long double fabsl(long double x) { return __builtin_fabsl(x); }
-#else
-long double fabsl(long double x) {
-  // Don't use __builtin_fabs here because of ARM. (See fabs above.)
-  return fabs(x);
-}
-#endif
diff --git a/libm/fake_long_double.c b/libm/fake_long_double.c
index 5edf839..317a115 100644
--- a/libm/fake_long_double.c
+++ b/libm/fake_long_double.c
@@ -25,6 +25,7 @@
  */
 
 long double copysignl(long double a1, long double a2) { return copysign(a1, a2); }
+long double fabsl(long double a1) { return fabs(a1); }
 long double fmaxl(long double a1, long double a2) { return fmax(a1, a2); }
 long double fmodl(long double a1, long double a2) { return fmod(a1, a2); }
 long double fminl(long double a1, long double a2) { return fmin(a1, a2); }
diff --git a/libm/include/math.h b/libm/include/math.h
index 9bc3aff..bc48b6a 100644
--- a/libm/include/math.h
+++ b/libm/include/math.h
@@ -20,8 +20,6 @@
 #include <sys/cdefs.h>
 #include <limits.h>
 
-#define __BIONIC_MATH_INLINE extern __inline__ __always_inline __attribute__((gnu_inline)) __attribute__((__artificial__))
-
 __BEGIN_DECLS
 #pragma GCC visibility push(default)
 
@@ -163,7 +161,6 @@
 
 double	ceil(double);
 double	fabs(double) __pure2;
-__BIONIC_MATH_INLINE double fabs(double x) { return __builtin_fabs(x); }
 double	floor(double);
 double	fmod(double, double);
 
@@ -282,7 +279,6 @@
 
 float	ceilf(float);
 float	fabsf(float) __pure2;
-__BIONIC_MATH_INLINE float fabsf(float x) { return __builtin_fabsf(x); }
 float	floorf(float);
 float	fmodf(float, float);
 float	roundf(float);
@@ -370,7 +366,6 @@
 long double	expl(long double);
 long double	expm1l(long double);
 long double	fabsl(long double) __pure2;
-__BIONIC_MATH_INLINE long double fabsl(long double x) { return __builtin_fabsl(x); }
 long double	fdiml(long double, long double);
 long double	floorl(long double);
 long double	fmal(long double, long double, long double);
diff --git a/libm/upstream-freebsd/lib/msun/src/s_fabs.c b/libm/upstream-freebsd/lib/msun/src/s_fabs.c
new file mode 100644
index 0000000..15529e5
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_fabs.c
@@ -0,0 +1,31 @@
+/* @(#)s_fabs.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#ifndef lint
+static char rcsid[] = "$FreeBSD$";
+#endif
+
+/*
+ * fabs(x) returns the absolute value of x.
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+double
+fabs(double x)
+{
+	u_int32_t high;
+	GET_HIGH_WORD(high,x);
+	SET_HIGH_WORD(x,high&0x7fffffff);
+        return x;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_fabsf.c b/libm/upstream-freebsd/lib/msun/src/s_fabsf.c
new file mode 100644
index 0000000..e9383d0
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_fabsf.c
@@ -0,0 +1,33 @@
+/* s_fabsf.c -- float version of s_fabs.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/*
+ * fabsf(x) returns the absolute value of x.
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+float
+fabsf(float x)
+{
+	u_int32_t ix;
+	GET_FLOAT_WORD(ix,x);
+	SET_FLOAT_WORD(x,ix&0x7fffffff);
+        return x;
+}