summaryrefslogtreecommitdiff
path: root/ojluni/src/main/native/Math.c
blob: 4bbcd1d0f1b8ab6ece506a4c26630ccf8821f469 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/*
 * Copyright (C) 2015 The Android Open Source Project
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.  The Android Open Source
 * Project designates this particular file as subject to the "Classpath"
 * exception as provided by The Android Open Source Project in the LICENSE
 * file that accompanied this code.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 */

#include "jni.h"
#include <nativehelper/JNIHelp.h>
#include "nativehelper/jni_macros.h"

#include <stdlib.h>
#include <math.h>

JNIEXPORT jdouble JNICALL
Math_cos(jdouble d) {
    return cos(d);
}

JNIEXPORT jdouble JNICALL
Math_sin(jdouble d) {
    return sin(d);
}

JNIEXPORT jdouble JNICALL
Math_tan(jdouble d) {
    return tan(d);
}

JNIEXPORT jdouble JNICALL
Math_asin(jdouble d) {
    return asin(d);
}

JNIEXPORT jdouble JNICALL
Math_acos(jdouble d) {
    return acos(d);
}

JNIEXPORT jdouble JNICALL
Math_atan(jdouble d) {
    return atan(d);
}

JNIEXPORT jdouble JNICALL
Math_exp(jdouble d) {
    return exp(d);
}

JNIEXPORT jdouble JNICALL
Math_log(jdouble d) {
    return log(d);
}

JNIEXPORT jdouble JNICALL
Math_log10(jdouble d) {
    return log10(d);
}

JNIEXPORT jdouble JNICALL
Math_sqrt(jdouble d) {
    return sqrt(d);
}

JNIEXPORT jdouble JNICALL
Math_cbrt(jdouble d) {
    return cbrt(d);
}

JNIEXPORT jdouble JNICALL
Math_atan2(jdouble d1, jdouble d2) {
    return atan2(d1, d2);
}

JNIEXPORT jdouble JNICALL
Math_pow(jdouble d1, jdouble d2) {
    return pow(d1, d2);
}

JNIEXPORT jdouble JNICALL
Math_IEEEremainder(jdouble dividend, jdouble divisor) {
    return remainder(dividend, divisor);
}

JNIEXPORT jdouble JNICALL
Math_cosh(jdouble d) {
    return cosh(d);
}

JNIEXPORT jdouble JNICALL
Math_sinh(jdouble d) {
    return sinh(d);
}

JNIEXPORT jdouble JNICALL
Math_tanh(jdouble d) {
    return tanh(d);
}

JNIEXPORT jdouble JNICALL
Math_hypot(jdouble x, jdouble y) {
    return hypot(x, y);
}

JNIEXPORT jdouble JNICALL
Math_log1p(jdouble d) {
    return log1p(d);
}

JNIEXPORT jdouble JNICALL
Math_expm1(jdouble d) {
    return expm1(d);
}

JNIEXPORT jdouble JNICALL
Math_floor(jdouble d) {
    return floor(d);
}

JNIEXPORT jdouble JNICALL
Math_ceil(jdouble d) {
    return ceil(d);
}

JNIEXPORT jdouble JNICALL
Math_rint(jdouble d) {
    return rint(d);
}

static JNINativeMethod gMethods[] = {
  FAST_NATIVE_METHOD(Math, IEEEremainder, "(DD)D"),
  FAST_NATIVE_METHOD(Math, acos, "(D)D"),
  FAST_NATIVE_METHOD(Math, asin, "(D)D"),
  FAST_NATIVE_METHOD(Math, atan, "(D)D"),
  FAST_NATIVE_METHOD(Math, atan2, "(DD)D"),
  FAST_NATIVE_METHOD(Math, cbrt, "(D)D"),
  FAST_NATIVE_METHOD(Math, cos, "(D)D"),
  FAST_NATIVE_METHOD(Math, ceil, "(D)D"),
  FAST_NATIVE_METHOD(Math, cosh, "(D)D"),
  FAST_NATIVE_METHOD(Math, exp, "(D)D"),
  FAST_NATIVE_METHOD(Math, expm1, "(D)D"),
  FAST_NATIVE_METHOD(Math, floor, "(D)D"),
  FAST_NATIVE_METHOD(Math, hypot, "(DD)D"),
  FAST_NATIVE_METHOD(Math, log, "(D)D"),
  FAST_NATIVE_METHOD(Math, log10, "(D)D"),
  FAST_NATIVE_METHOD(Math, log1p, "(D)D"),
  FAST_NATIVE_METHOD(Math, pow, "(DD)D"),
  FAST_NATIVE_METHOD(Math, rint, "(D)D"),
  FAST_NATIVE_METHOD(Math, sin, "(D)D"),
  FAST_NATIVE_METHOD(Math, sinh, "(D)D"),
  FAST_NATIVE_METHOD(Math, sqrt, "(D)D"),
  FAST_NATIVE_METHOD(Math, tan, "(D)D"),
  FAST_NATIVE_METHOD(Math, tanh, "(D)D"),
};

void register_java_lang_Math(JNIEnv* env) {
  jniRegisterNativeMethods(env, "java/lang/Math", gMethods, NELEM(gMethods));
}