1 /* tests/regressions/native/testarguments.java - tests argument passing
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,
8 This file is part of CACAO.
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.
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.
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
28 public class testarguments {
29 public static native Object adr(int i);
30 public static native void np(Object o);
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);
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);
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);
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);
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);
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);
57 public static void main(String[] argv) {
58 System.loadLibrary("testarguments");
70 pln("testing int --------------------------------------------------");
72 isub(0x11111111, 0x22222222, 0x33333333, 0x44444444, 0x55555555,
73 0x66666666, 0x77777777, 0x88888888, 0x99999999, 0xaaaaaaaa,
74 0xbbbbbbbb, 0xcccccccc, 0xdddddddd, 0xeeeeeeee, 0xffffffff);
80 pln("testing long -------------------------------------------------");
82 lsub(0x1111111111111111L, 0x2222222222222222L, 0x3333333333333333L,
83 0x4444444444444444L, 0x5555555555555555L, 0x6666666666666666L,
84 0x7777777777777777L, 0x8888888888888888L, 0x9999999999999999L,
85 0xaaaaaaaaaaaaaaaaL, 0xbbbbbbbbbbbbbbbbL, 0xccccccccccccccccL,
86 0xddddddddddddddddL, 0xeeeeeeeeeeeeeeeeL, 0xffffffffffffffffL);
92 pln("testing float ------------------------------------------------");
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));
103 static void dtest() {
104 pln("testing double -----------------------------------------------");
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));
118 static void atest() {
119 pln("testing address ----------------------------------------------");
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));
128 static void mtest() {
129 pln("testing mixed ------------------------------------------------");
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,
142 // test java-java argument passing
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) {
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);
155 nisub(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o);
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) {
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);
169 nlsub(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o);
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) {
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);
183 nfsub(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o);
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) {
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);
197 ndsub(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o);
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) {
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);
211 nasub(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o);
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) {
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);
226 nmsub(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o);
230 // test native-java argument passing
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) {
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);
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) {
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);
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) {
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);
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) {
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);
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) {
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);
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) {
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);
305 static float i2f(int i) {
306 return Float.intBitsToFloat(i);
309 static double l2d(long l) {
310 return Double.longBitsToDouble(l);
313 static void p(String s) { System.out.print(s); }
315 static void p(int i) {
316 System.out.print(" 0x" + Integer.toHexString(i));
319 static void p(long l) {
320 System.out.print(" 0x" + Long.toHexString(l));
323 static void p(float f) {
324 p(Float.floatToIntBits(f));
327 static void p(double d) {
328 p(Double.doubleToLongBits(d));
331 static void p(Object o) {
335 static void pln() { System.out.println(); }
336 static void pln(String s) { System.out.println(s); }