1 /* tests/native/testarguments.java - tests argument passing
3 Copyright (C) 1996-2005 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,
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., 59 Temple Place - Suite 330, Boston, MA
25 Contact: cacao@complang.tuwien.ac.at
27 Authors: Christian Thalinger
29 $Id: testarguments.java 3523 2005-10-28 19:56:29Z twisti $
36 public class testarguments {
39 public static native void nisub(int a, int b, int c, int d, int e,
40 int f, int g, int h, int i, int j,
41 int k, int l, int m, int n, int o);
43 public static native void nlsub(long a, long b, long c, long d, long e,
44 long f, long g, long h, long i, long j,
45 long k, long l, long m, long n, long o);
47 public static native void nfsub(float a, float b, float c, float d, float e,
48 float f, float g, float h, float i, float j,
49 float k, float l, float m, float n, float o);
51 public static native void ndsub(double a, double b, double c, double d, double e,
52 double f, double g, double h, double i, double j,
53 double k, double l, double m, double n, double o);
55 public static void main(String[] argv) {
58 System.loadLibrary("testarguments");
67 pln("testing int --------------------------------------------------");
69 isub(0x11111111, 0x22222222, 0x33333333, 0x44444444, 0x55555555,
70 0x66666666, 0x77777777, 0x88888888, 0x99999999, 0xaaaaaaaa,
71 0xbbbbbbbb, 0xcccccccc, 0xdddddddd, 0xeeeeeeee, 0xffffffff);
77 pln("testing long -------------------------------------------------");
79 lsub(0x1111111111111111L, 0x2222222222222222L, 0x3333333333333333L,
80 0x4444444444444444L, 0x5555555555555555L, 0x6666666666666666L,
81 0x7777777777777777L, 0x8888888888888888L, 0x9999999999999999L,
82 0xaaaaaaaaaaaaaaaaL, 0xbbbbbbbbbbbbbbbbL, 0xccccccccccccccccL,
83 0xddddddddddddddddL, 0xeeeeeeeeeeeeeeeeL, 0xffffffffffffffffL);
89 pln("testing float ------------------------------------------------");
91 fsub(i2f(0x11111111), i2f(0x22222222), i2f(0x33333333),
92 i2f(0x44444444), i2f(0x55555555), i2f(0x66666666),
93 i2f(0x77777777), i2f(0x88888888), i2f(0x99999999),
94 i2f(0xaaaaaaaa), i2f(0xbbbbbbbb), i2f(0xcccccccc),
95 i2f(0xdddddddd), i2f(0xeeeeeeee), i2f(0xffffffff));
100 static void dtest() {
101 pln("testing double -----------------------------------------------");
103 dsub(l2d(0x1111111111111111L), l2d(0x2222222222222222L),
104 l2d(0x3333333333333333L), l2d(0x4444444444444444L),
105 l2d(0x5555555555555555L), l2d(0x6666666666666666L),
106 l2d(0x7777777777777777L), l2d(0x8888888888888888L),
107 l2d(0x9999999999999999L), l2d(0xaaaaaaaaaaaaaaaaL),
108 l2d(0xbbbbbbbbbbbbbbbbL), l2d(0xccccccccccccccccL),
109 l2d(0xddddddddddddddddL), l2d(0xeeeeeeeeeeeeeeeeL),
110 l2d(0xffffffffffffffffL));
114 // test java-java argument passing
116 public static void isub(int a, int b, int c, int d, int e,
117 int f, int g, int h, int i, int j,
118 int k, int l, int m, int n, int o) {
121 p(a); p(b); p(c); p(d); p(e);
122 p(f); p(g); p(h); p(i); p(j);
123 p(k); p(l); p(m); p(n); p(o);
127 nisub(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o);
130 public static void lsub(long a, long b, long c, long d, long e,
131 long f, long g, long h, long i, long j,
132 long k, long l, long m, long n, long o) {
135 p(a); p(b); p(c); p(d); p(e);
136 p(f); p(g); p(h); p(i); p(j);
137 p(k); p(l); p(m); p(n); p(o);
141 nlsub(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o);
144 public static void fsub(float a, float b, float c, float d, float e,
145 float f, float g, float h, float i, float j,
146 float k, float l, float m, float n, float 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 nfsub(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o);
158 public static void dsub(double a, double b, double c, double d, double e,
159 double f, double g, double h, double i, double j,
160 double k, double l, double m, double n, double 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 ndsub(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o);
173 // test native-java argument passing
175 public static void jisub(int a, int b, int c, int d, int e,
176 int f, int g, int h, int i, int j,
177 int k, int l, int m, int n, int o) {
180 p(a); p(b); p(c); p(d); p(e);
181 p(f); p(g); p(h); p(i); p(j);
182 p(k); p(l); p(m); p(n); p(o);
187 public static void jlsub(long a, long b, long c, long d, long e,
188 long f, long g, long h, long i, long j,
189 long k, long l, long m, long n, long o) {
192 p(a); p(b); p(c); p(d); p(e);
193 p(f); p(g); p(h); p(i); p(j);
194 p(k); p(l); p(m); p(n); p(o);
199 public static void jfsub(float a, float b, float c, float d, float e,
200 float f, float g, float h, float i, float j,
201 float k, float l, float m, float n, float o) {
204 p(a); p(b); p(c); p(d); p(e);
205 p(f); p(g); p(h); p(i); p(j);
206 p(k); p(l); p(m); p(n); p(o);
211 public static void jdsub(double a, double b, double c, double d, double e,
212 double f, double g, double h, double i, double j,
213 double k, double l, double m, double n, double o) {
216 p(a); p(b); p(c); p(d); p(e);
217 p(f); p(g); p(h); p(i); p(j);
218 p(k); p(l); p(m); p(n); p(o);
223 static float i2f(int i) {
224 return Float.intBitsToFloat(i);
227 static double l2d(long l) {
228 return Double.longBitsToDouble(l);
231 static void p(String s) { System.out.print(s); }
233 static void p(int i) {
234 System.out.print(" 0x" + Integer.toHexString(i));
237 static void p(long l) {
238 System.out.print(" 0x" + Long.toHexString(l));
241 static void p(float f) {
242 p(Float.floatToIntBits(f));
245 static void p(double d) {
246 p(Double.doubleToLongBits(d));
249 static void pln() { System.out.println(); }
250 static void pln(String s) { System.out.println(s); }