2010-06-17 Geoff Norton <gnorton@novell.com>
[mono.git] / mono / tests / pinvoke.cs
blob78be250d04157da32707d8fb7520a6b84b358a37
1 using System;
2 using System.Runtime.InteropServices;
4 public class Test {
6 [DllImport ("libtest", EntryPoint="mono_test_many_int_arguments")]
7 public static extern int mono_test_many_int_arguments (int a, int b, int c, int d, int e,
8 int f, int g, int h, int i, int j);
9 [DllImport ("libtest", EntryPoint="mono_test_many_short_arguments")]
10 public static extern int mono_test_many_short_arguments (short a, short b, short c, short d, short e,
11 short f, short g, short h, short i, short j);
12 [DllImport ("libtest", EntryPoint="mono_test_many_byte_arguments")]
13 public static extern int mono_test_many_byte_arguments (byte a, byte b, byte c, byte d, byte e,
14 byte f, byte g, byte h, byte i, byte j);
15 [DllImport ("libtest", EntryPoint="mono_test_many_float_arguments")]
16 public static extern float mono_test_many_float_arguments (float a, float b, float c, float d, float e,
17 float f, float g, float h, float i, float j);
18 [DllImport ("libtest", EntryPoint="mono_test_many_double_arguments")]
19 public static extern double mono_test_many_double_arguments (double a, double b, double c, double d, double e,
20 double f, double g, double h, double i, double j);
21 [DllImport ("libtest", EntryPoint="mono_test_split_double_arguments")]
22 public static extern double mono_test_split_double_arguments (double a, double b, float c, double d, double e);
24 public static int Main () {
25 if (Math.Cos (Math.PI) != -1)
26 return 1;
27 if (Math.Acos (1) != 0)
28 return 2;
29 if (mono_test_many_int_arguments (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) != 10)
30 return 3;
31 if (mono_test_many_short_arguments (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) != 55)
32 return 4;
33 if (mono_test_many_byte_arguments (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) != 55)
34 return 5;
35 if (mono_test_many_float_arguments (1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f) != 55.0f)
36 return 6;
37 if (mono_test_many_double_arguments (1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0) != 55.0)
38 return 7;
40 /* Test Sparc V8 split register/stack double parameter passing */
41 if (mono_test_split_double_arguments (1.0, 2.0, 3.0f, 4.0, 5.0) != 15.0)
42 return 8;
44 return 0;