366fce9b2369baa25ee6059ff7a061f435f88f97
[cacao.git] / tests / regression / native / testarguments.java
1 /* tests/regressions/native/testarguments.java - tests argument passing
2
3    Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
4    C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5    E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6    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: testarguments.java 8123 2007-06-20 23:50:55Z michi $
26
27 */
28
29
30 public class testarguments {
31     public static native Object adr(int i);
32     public static native void np(Object o);
33
34     public static native void nisub(int a, int b, int c, int d, int e,
35                                     int f, int g, int h, int i, int j,
36                                     int k, int l, int m, int n, int o);
37
38     public static native void nlsub(long a, long b, long c, long d, long e,
39                                     long f, long g, long h, long i, long j,
40                                     long k, long l, long m, long n, long o);
41
42     public static native void nfsub(float a, float b, float c, float d, float e,
43                                     float f, float g, float h, float i, float j,
44                                     float k, float l, float m, float n, float o);
45
46     public static native void ndsub(double a, double b, double c, double d, double e,
47                                     double f, double g, double h, double i, double j,
48                                     double k, double l, double m, double n, double o);
49
50     public static native void nasub(Object a, Object b, Object c, Object d, Object e,
51                                     Object f, Object g, Object h, Object i, Object j,
52                                     Object k, Object l, Object m, Object n, Object o);
53
54     public static native void nmsub(int a, long b, float c, double d,
55                                     int e, long f, float g, double h,
56                                     int i, long j, float k, double l,
57                                     int m, long n, float o);
58
59     public static void main(String[] argv) {
60         System.loadLibrary("testarguments");
61
62         itest();
63         ltest();
64         ftest();
65         dtest();
66         atest();
67
68         mtest();
69     }
70
71     static void itest() {
72         pln("testing int --------------------------------------------------");
73
74         isub(0x11111111, 0x22222222, 0x33333333, 0x44444444, 0x55555555,
75              0x66666666, 0x77777777, 0x88888888, 0x99999999, 0xaaaaaaaa,
76              0xbbbbbbbb, 0xcccccccc, 0xdddddddd, 0xeeeeeeee, 0xffffffff);
77
78         pln();
79     }
80
81     static void ltest() {
82         pln("testing long -------------------------------------------------");
83
84         lsub(0x1111111111111111L, 0x2222222222222222L, 0x3333333333333333L,
85              0x4444444444444444L, 0x5555555555555555L, 0x6666666666666666L,
86              0x7777777777777777L, 0x8888888888888888L, 0x9999999999999999L,
87              0xaaaaaaaaaaaaaaaaL, 0xbbbbbbbbbbbbbbbbL, 0xccccccccccccccccL,
88              0xddddddddddddddddL, 0xeeeeeeeeeeeeeeeeL, 0xffffffffffffffffL);
89
90         pln();
91     }
92
93     static void ftest() {
94         pln("testing float ------------------------------------------------");
95
96         fsub(i2f(0x11111111), i2f(0x22222222), i2f(0x33333333),
97              i2f(0x44444444), i2f(0x55555555), i2f(0x66666666),
98              i2f(0x77777777), i2f(0x88888888), i2f(0x99999999),
99              i2f(0xaaaaaaaa), i2f(0xbbbbbbbb), i2f(0xcccccccc),
100              i2f(0xdddddddd), i2f(0xeeeeeeee), i2f(0xffffffff));
101
102         pln();
103     }
104
105     static void dtest() {
106         pln("testing double -----------------------------------------------");
107
108         dsub(l2d(0x1111111111111111L), l2d(0x2222222222222222L),
109              l2d(0x3333333333333333L), l2d(0x4444444444444444L),
110              l2d(0x5555555555555555L), l2d(0x6666666666666666L),
111              l2d(0x7777777777777777L), l2d(0x8888888888888888L),
112              l2d(0x9999999999999999L), l2d(0xaaaaaaaaaaaaaaaaL),
113              l2d(0xbbbbbbbbbbbbbbbbL), l2d(0xccccccccccccccccL),
114              l2d(0xddddddddddddddddL), l2d(0xeeeeeeeeeeeeeeeeL),
115              l2d(0xffffffffffffffffL));
116
117         pln();
118     }
119
120     static void atest() {
121         pln("testing address ----------------------------------------------");
122
123         asub(adr(1),  adr(2),  adr(3),  adr(4),  adr(5),
124              adr(6),  adr(7),  adr(8),  adr(9),  adr(10),
125              adr(11), adr(12), adr(13), adr(14), adr(15));
126
127         pln();
128     }
129
130     static void mtest() {
131         pln("testing mixed ------------------------------------------------");
132
133         msub(0x11111111, 0x2222222222222222L,
134              i2f(0x33333333), l2d(0x4444444444444444L),
135              0x55555555, 0x6666666666666666L,
136              i2f(0x77777777), l2d(0x8888888888888888L),
137              0x99999999, 0xaaaaaaaaaaaaaaaaL,
138              i2f(0xbbbbbbbb), l2d(0xccccccccccccccccL),
139              0xdddddddd, 0xeeeeeeeeeeeeeeeeL,
140              i2f(0xffffffff));
141     }
142
143
144     // test java-java argument passing
145
146     public static void isub(int a, int b, int c, int d, int e,
147                             int f, int g, int h, int i, int j,
148                             int k, int l, int m, int n, int o) {
149         p("java-java  :");
150
151         p(a); p(b); p(c); p(d); p(e);
152         p(f); p(g); p(h); p(i); p(j);
153         p(k); p(l); p(m); p(n); p(o);
154
155         pln();
156
157         nisub(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o);
158     }
159
160     public static void lsub(long a, long b, long c, long d, long e,
161                             long f, long g, long h, long i, long j,
162                             long k, long l, long m, long n, long o) {
163         p("java-java  :");
164
165         p(a); p(b); p(c); p(d); p(e);
166         p(f); p(g); p(h); p(i); p(j);
167         p(k); p(l); p(m); p(n); p(o);
168
169         pln();
170
171         nlsub(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o);
172     }
173
174     public static void fsub(float a, float b, float c, float d, float e,
175                             float f, float g, float h, float i, float j,
176                             float k, float l, float m, float n, float o) {
177         p("java-java  :");
178
179         p(a); p(b); p(c); p(d); p(e);
180         p(f); p(g); p(h); p(i); p(j);
181         p(k); p(l); p(m); p(n); p(o);
182
183         pln();
184
185         nfsub(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o);
186     }
187
188     public static void dsub(double a, double b, double c, double d, double e,
189                             double f, double g, double h, double i, double j,
190                             double k, double l, double m, double n, double o) {
191         p("java-java  :");
192
193         p(a); p(b); p(c); p(d); p(e);
194         p(f); p(g); p(h); p(i); p(j);
195         p(k); p(l); p(m); p(n); p(o);
196
197         pln();
198
199         ndsub(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o);
200     }
201
202     public static void asub(Object a, Object b, Object c, Object d, Object e,
203                             Object f, Object g, Object h, Object i, Object j,
204                             Object k, Object l, Object m, Object n, Object o) {
205         p("java-java  :");
206
207         p(a); p(b); p(c); p(d); p(e);
208         p(f); p(g); p(h); p(i); p(j);
209         p(k); p(l); p(m); p(n); p(o);
210
211         pln();
212
213         nasub(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o);
214     }
215
216     public static void msub(int a, long b, float c, double d,
217                             int e, long f, float g, double h,
218                             int i, long j, float k, double l,
219                             int m, long n, float o) {
220         p("java-java  :");
221
222         p(a); p(b); p(c); p(d); p(e);
223         p(f); p(g); p(h); p(i); p(j);
224         p(k); p(l); p(m); p(n); p(o);
225
226         pln();
227
228         nmsub(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o);
229     }
230
231
232     // test native-java argument passing
233
234     public static void jisub(int a, int b, int c, int d, int e,
235                              int f, int g, int h, int i, int j,
236                              int k, int l, int m, int n, int o) {
237         p("native-java:");
238
239         p(a); p(b); p(c); p(d); p(e);
240         p(f); p(g); p(h); p(i); p(j);
241         p(k); p(l); p(m); p(n); p(o);
242
243         pln();
244     }
245
246     public static void jlsub(long a, long b, long c, long d, long e,
247                              long f, long g, long h, long i, long j,
248                              long k, long l, long m, long n, long o) {
249         p("native-java:");
250
251         p(a); p(b); p(c); p(d); p(e);
252         p(f); p(g); p(h); p(i); p(j);
253         p(k); p(l); p(m); p(n); p(o);
254
255         pln();
256     }
257
258     public static void jfsub(float a, float b, float c, float d, float e,
259                              float f, float g, float h, float i, float j,
260                              float k, float l, float m, float n, float o) {
261         p("native-java:");
262
263         p(a); p(b); p(c); p(d); p(e);
264         p(f); p(g); p(h); p(i); p(j);
265         p(k); p(l); p(m); p(n); p(o);
266
267         pln();
268     }
269
270     public static void jdsub(double a, double b, double c, double d, double e,
271                              double f, double g, double h, double i, double j,
272                              double k, double l, double m, double n, double o) {
273         p("native-java:");
274
275         p(a); p(b); p(c); p(d); p(e);
276         p(f); p(g); p(h); p(i); p(j);
277         p(k); p(l); p(m); p(n); p(o);
278
279         pln();
280     }
281
282     public static void jasub(Object a, Object b, Object c, Object d, Object e,
283                              Object f, Object g, Object h, Object i, Object j,
284                              Object k, Object l, Object m, Object n, Object o) {
285         p("native-java:");
286
287         p(a); p(b); p(c); p(d); p(e);
288         p(f); p(g); p(h); p(i); p(j);
289         p(k); p(l); p(m); p(n); p(o);
290
291         pln();
292     }
293
294     public static void jmsub(int a, long b, float c, double d,
295                              int e, long f, float g, double h,
296                              int i, long j, float k, double l,
297                              int m, long n, float o) {
298         p("native-java:");
299
300         p(a); p(b); p(c); p(d); p(e);
301         p(f); p(g); p(h); p(i); p(j);
302         p(k); p(l); p(m); p(n); p(o);
303
304         pln();
305     }
306
307     static float i2f(int i) {
308         return Float.intBitsToFloat(i);
309     }
310
311     static double l2d(long l) {
312         return Double.longBitsToDouble(l);
313     }
314
315     static void p(String s) { System.out.print(s); }
316
317     static void p(int i) {
318         System.out.print(" 0x" + Integer.toHexString(i));
319     }
320
321     static void p(long l) {
322         System.out.print(" 0x" + Long.toHexString(l));
323     }
324
325     static void p(float f) {
326         p(Float.floatToIntBits(f));
327     }
328
329     static void p(double d) {
330         p(Double.doubleToLongBits(d));
331     }
332
333     static void p(Object o) {
334         np(o);
335     }
336
337     static void pln() { System.out.println(); }
338     static void pln(String s) { System.out.println(s); }
339 }