772a3eefa5dc76608304897db00b28e7eb2a5d4a
[cacao.git] / src / native / vm / cldc1.1 / java_lang_Math.c
1 /* src/native/vm/cldc1.1/java_lang_Math.c
2
3    Copyright (C) 2006, 2007 R. Grafl, A. Krall, C. Kruegel, C. Oates,
4    R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
5    C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
6    Institut f. Computersprachen - TU Wien
7
8    This file is part of CACAO.
9
10    This program is free software; you can redistribute it and/or
11    modify it under the terms of the GNU General Public License as
12    published by the Free Software Foundation; either version 2, or (at
13    your option) any later version.
14
15    This program is distributed in the hope that it will be useful, but
16    WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18    General Public License for more details.
19
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23    02110-1301, USA.
24
25    $Id: java_lang_VMRuntime.c 5900 2006-11-04 17:30:44Z michi $
26
27 */
28
29
30 #include "config.h"
31 #include "vm/types.h"
32
33 #include "fdlibm/fdlibm.h"
34
35 #include "native/jni.h"
36 #include "native/native.h"
37
38 #include "native/include/java_lang_Math.h"
39
40
41 /* native methods implemented by this file ************************************/
42  
43 static JNINativeMethod methods[] = {
44         { "ceil",  "(D)D", (void *) (ptrint) &Java_java_lang_Math_ceil  },
45         { "cos",   "(D)D", (void *) (ptrint) &Java_java_lang_Math_cos   },
46         { "floor", "(D)D", (void *) (ptrint) &Java_java_lang_Math_floor },
47         { "sin",   "(D)D", (void *) (ptrint) &Java_java_lang_Math_sin   },
48         { "sqrt",  "(D)D", (void *) (ptrint) &Java_java_lang_Math_sqrt  },
49         { "tan",   "(D)D", (void *) (ptrint) &Java_java_lang_Math_tan   },
50 };
51  
52  
53 /* _Jv_java_lang_Math_init *****************************************************
54  
55    Register native functions.
56  
57 *******************************************************************************/
58  
59 void _Jv_java_lang_Math_init(void)
60 {
61         utf *u;
62  
63         u = utf_new_char("java/lang/Math");
64  
65         native_method_register(u, methods, NATIVE_METHODS_COUNT);
66 }
67
68
69 /*
70  * Class:     java/lang/Math
71  * Method:    ceil
72  * Signature: (D)D
73  */
74 JNIEXPORT double JNICALL Java_java_lang_Math_ceil(JNIEnv *env, jclass clazz, double a)
75 {
76         return ceil(a);
77 }
78
79
80 /*
81  * Class:     java/lang/Math
82  * Method:    cos
83  * Signature: (D)D
84  */
85 JNIEXPORT double JNICALL Java_java_lang_Math_cos(JNIEnv *env, jclass clazz, double a)
86 {
87         return cos(a);
88 }
89
90
91 /*
92  * Class:     java/lang/Math
93  * Method:    floor
94  * Signature: (D)D
95  */
96 JNIEXPORT double JNICALL Java_java_lang_Math_floor(JNIEnv *env, jclass clazz, double a)
97 {
98         return floor(a);
99 }
100
101
102 /*
103  * Class:     java/lang/Math
104  * Method:    sin
105  * Signature: (D)D
106  */
107 JNIEXPORT double JNICALL Java_java_lang_Math_sin(JNIEnv *env, jclass clazz, double a)
108 {
109         return sin(a);
110 }
111
112
113 /*
114  * Class:     java/lang/Math
115  * Method:    sqrt
116  * Signature: (D)D
117  */
118 JNIEXPORT double JNICALL Java_java_lang_Math_sqrt(JNIEnv *env, jclass clazz, double a)
119 {
120         return sqrt(a);
121 }
122
123
124 /*
125  * Class:     java/lang/Math
126  * Method:    tan
127  * Signature: (D)D
128  */
129 JNIEXPORT double JNICALL Java_java_lang_Math_tan(JNIEnv *env, jclass clazz, double a)
130 {
131         return tan(a);
132 }
133
134
135 /*
136  * These are local overrides for various environment variables in Emacs.
137  * Please do not remove this and leave it at the end of the file, where
138  * Emacs will automagically detect them.
139  * ---------------------------------------------------------------------
140  * Local variables:
141  * mode: c
142  * indent-tabs-mode: t
143  * c-basic-offset: 4
144  * tab-width: 4
145  * End:
146  * vim:noexpandtab:sw=4:ts=4:
147  */