1 /*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #define LOG_TAG "StrictMath"
18
19 #include "../../external/fdlibm/fdlibm.h"
20
21 #include "jni.h"
22 #include "JNIHelp.h"
23 #include "JniConstants.h"
24
StrictMath_sin(JNIEnv *,jclass,jdouble a)25 static jdouble StrictMath_sin(JNIEnv*, jclass, jdouble a) {
26 return ieee_sin(a);
27 }
28
StrictMath_cos(JNIEnv *,jclass,jdouble a)29 static jdouble StrictMath_cos(JNIEnv*, jclass, jdouble a) {
30 return ieee_cos(a);
31 }
32
StrictMath_tan(JNIEnv *,jclass,jdouble a)33 static jdouble StrictMath_tan(JNIEnv*, jclass, jdouble a) {
34 return ieee_tan(a);
35 }
36
StrictMath_sqrt(JNIEnv *,jclass,jdouble a)37 static jdouble StrictMath_sqrt(JNIEnv*, jclass, jdouble a) {
38 return ieee_sqrt(a);
39 }
40
StrictMath_IEEEremainder(JNIEnv *,jclass,jdouble a,jdouble b)41 static jdouble StrictMath_IEEEremainder(JNIEnv*, jclass, jdouble a, jdouble b) {
42 return ieee_remainder(a, b);
43 }
44
StrictMath_floor(JNIEnv *,jclass,jdouble a)45 static jdouble StrictMath_floor(JNIEnv*, jclass, jdouble a) {
46 return ieee_floor(a);
47 }
48
StrictMath_ceil(JNIEnv *,jclass,jdouble a)49 static jdouble StrictMath_ceil(JNIEnv*, jclass, jdouble a) {
50 return ieee_ceil(a);
51 }
52
StrictMath_rint(JNIEnv *,jclass,jdouble a)53 static jdouble StrictMath_rint(JNIEnv*, jclass, jdouble a) {
54 return ieee_rint(a);
55 }
56
StrictMath_pow(JNIEnv *,jclass,jdouble a,jdouble b)57 static jdouble StrictMath_pow(JNIEnv*, jclass, jdouble a, jdouble b) {
58 return ieee_pow(a,b);
59 }
60
StrictMath_hypot(JNIEnv *,jclass,jdouble a,jdouble b)61 static jdouble StrictMath_hypot(JNIEnv*, jclass, jdouble a, jdouble b) {
62 return ieee_hypot(a, b);
63 }
64
StrictMath_nextafter(JNIEnv *,jclass,jdouble a,jdouble b)65 static jdouble StrictMath_nextafter(JNIEnv*, jclass, jdouble a, jdouble b) {
66 return ieee_nextafter(a, b);
67 }
68
69 static JNINativeMethod gMethods[] = {
70 NATIVE_METHOD(StrictMath, IEEEremainder, "!(DD)D"),
71 NATIVE_METHOD(StrictMath, ceil, "!(D)D"),
72 NATIVE_METHOD(StrictMath, cos, "!(D)D"),
73 NATIVE_METHOD(StrictMath, floor, "!(D)D"),
74 NATIVE_METHOD(StrictMath, hypot, "!(DD)D"),
75 NATIVE_METHOD(StrictMath, nextafter, "!(DD)D"),
76 NATIVE_METHOD(StrictMath, pow, "!(DD)D"),
77 NATIVE_METHOD(StrictMath, rint, "!(D)D"),
78 NATIVE_METHOD(StrictMath, sin, "!(D)D"),
79 NATIVE_METHOD(StrictMath, sqrt, "!(D)D"),
80 NATIVE_METHOD(StrictMath, tan, "!(D)D"),
81 };
register_java_lang_StrictMath(JNIEnv * env)82 void register_java_lang_StrictMath(JNIEnv* env) {
83 jniRegisterNativeMethods(env, "java/lang/StrictMath", gMethods, NELEM(gMethods));
84 }
85