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