Fix build.

Rather than try to be clever with header files (which didn't work with glibc
for the sim build) let's make Math.copySign have the StrictMath behavior,
and have StrictMath call Math. (The other way round, though it might seem
more logical, wouldn't solve the problem. We already have numerous cases of
StrictMath calling Math anyway.)

Change-Id: Ifff065ddc8fbd5d5f8d4d5b67bc9ac07a719eb00
diff --git a/libcore/luni/src/main/java/java/lang/StrictMath.java b/libcore/luni/src/main/java/java/lang/StrictMath.java
index cd3c9b5..5c6ebc7 100644
--- a/libcore/luni/src/main/java/java/lang/StrictMath.java
+++ b/libcore/luni/src/main/java/java/lang/StrictMath.java
@@ -1042,7 +1042,9 @@
      * @since 1.6
      * @hide
      */
-    public static native double copySign(double magnitude, double sign);
+    public static double copySign(double magnitude, double sign) {
+        return Math.copySign(magnitude, sign);
+    }
 
     /**
      * Returns a float with the given magnitude and the sign of {@code sign}.
@@ -1050,7 +1052,9 @@
      * @since 1.6
      * @hide
      */
-    public static native float copySign(float magnitude, float sign);
+    public static float copySign(float magnitude, float sign) {
+        return Math.copySign(magnitude, sign);
+    }
 
     /**
      * Answers the exponent of a float.
diff --git a/libcore/luni/src/main/native/java_lang_Math.c b/libcore/luni/src/main/native/java_lang_Math.c
index 35754cd..90cb9b5 100644
--- a/libcore/luni/src/main/native/java_lang_Math.c
+++ b/libcore/luni/src/main/native/java_lang_Math.c
@@ -160,11 +160,13 @@
 }
 
 static jdouble copySign(JNIEnv* env, jclass clazz, jdouble a, jdouble b) {
-    return copysign(a, b);
+    // Our StrictMath.copySign delegates to Math.copySign, so we need to treat NaN as positive.
+    return copysign(a, isnan(b) ? 1.0 : b);
 }
 
 static jfloat copySign_f(JNIEnv* env, jclass clazz, jfloat a, jfloat b) {
-    return copysignf(a, b);
+    // Our StrictMath.copySign delegates to Math.copySign, so we need to treat NaN as positive.
+    return copysignf(a, isnan(b) ? 1.0 : b);
 }
 
 /*
diff --git a/libcore/luni/src/main/native/java_lang_StrictMath.c b/libcore/luni/src/main/native/java_lang_StrictMath.c
index 3839c21..cb0f87e 100644
--- a/libcore/luni/src/main/native/java_lang_StrictMath.c
+++ b/libcore/luni/src/main/native/java_lang_StrictMath.c
@@ -20,8 +20,6 @@
 #include "../../external/fdlibm/fdlibm.h"
 _LIB_VERSION_TYPE _LIB_VERSION = _IEEE_;
 
-#include <math.h>
-
 /* native public static double sin(double a); */
 static jdouble jsin(JNIEnv* env, jclass clazz, jdouble a)
 {
@@ -186,14 +184,6 @@
     return arg1;
 }
 
-static jdouble copySign(JNIEnv* env, jclass clazz, jdouble a, jdouble b) {
-    return copysign(a, isnan(b) ? 1.0 : b);
-}
-
-static jfloat copySign_f(JNIEnv* env, jclass clazz, jfloat a, jfloat b) {
-    return copysignf(a, isnan(b) ? 1.0f : b);
-}
-
 /*
  * JNI registration.
  */
@@ -206,8 +196,6 @@
     { "atan2",  "(DD)D", jatan2 },
     { "cbrt",   "(D)D", jcbrt },
     { "ceil",   "(D)D", jceil },
-    { "copySign",  "(DD)D", copySign },
-    { "copySign",  "(FF)F", copySign_f },
     { "cos",    "(D)D", jcos },
     { "cosh",   "(D)D", jcosh },
     { "exp",    "(D)D", jexp },