1 // pinvoke_ppcd.cs - Test cases for passing structures to and and returning
2 // structures from functions. This particular test is for
3 // structures consisting wholy of 8 byte fields.
5 // The Power ABI version 2 allows for special parameter
6 // passing and returning optimizations for certain
7 // structures of homogenous composition (like all ints).
8 // This set of tests checks all the possible combinations
9 // that use the special parm/return rules and one beyond.
11 // Bill Seurer (seurer@linux.vnet.ibm.com)
13 // (C) {Copyright holder}
17 using System.Runtime.InteropServices;
20 public class Test_double {
22 [DllImport ("libtest", EntryPoint="mono_return_double1")]
23 public static extern double mono_return_double1 (double1 s, int addend);
24 [StructLayout(LayoutKind.Sequential)]
25 public struct double1 {
28 [DllImport ("libtest", EntryPoint="mono_return_double2")]
29 public static extern double mono_return_double2 (double2 s, int addend);
30 [StructLayout(LayoutKind.Sequential)]
31 public struct double2 {
34 // This structure is 1 element too large to use the special return
36 [DllImport ("libtest", EntryPoint="mono_return_double3")]
37 public static extern double mono_return_double3 (double3 s, int addend);
38 [StructLayout(LayoutKind.Sequential)]
39 public struct double3 {
40 public double f1,f2,f3;
42 [DllImport ("libtest", EntryPoint="mono_return_double4")]
43 public static extern double mono_return_double4 (double4 s, int addend);
44 [StructLayout(LayoutKind.Sequential)]
45 public struct double4 {
46 public double f1,f2,f3,f4;
48 [DllImport ("libtest", EntryPoint="mono_return_double5")]
49 public static extern double mono_return_double5 (double5 s, int addend);
50 [StructLayout(LayoutKind.Sequential)]
51 public struct double5 {
52 public double f1,f2,f3,f4,f5;
54 [DllImport ("libtest", EntryPoint="mono_return_double6")]
55 public static extern double mono_return_double6 (double6 s, int addend);
56 [StructLayout(LayoutKind.Sequential)]
57 public struct double6 {
58 public double f1,f2,f3,f4,f5,f6;
60 [DllImport ("libtest", EntryPoint="mono_return_double7")]
61 public static extern double mono_return_double7 (double7 s, int addend);
62 [StructLayout(LayoutKind.Sequential)]
63 public struct double7 {
64 public double f1,f2,f3,f4,f5,f6,f7;
66 [DllImport ("libtest", EntryPoint="mono_return_double8")]
67 public static extern double mono_return_double8 (double8 s, int addend);
68 [StructLayout(LayoutKind.Sequential)]
69 public struct double8 {
70 public double f1,f2,f3,f4,f5,f6,f7,f8;
72 // This structure is 1 element too large to use the special parameter
74 [DllImport ("libtest", EntryPoint="mono_return_double9")]
75 public static extern double mono_return_double9 (double9 s, int addend);
76 [StructLayout(LayoutKind.Sequential)]
77 public struct double9 {
78 public double f1,f2,f3,f4,f5,f6,f7,f8,f9;
81 // This structure has nested structures within it but they are
82 // homogenous and thus should still use the special rules.
83 public struct double2_nested1 {
86 public struct double2_nested2 {
89 [DllImport ("libtest", EntryPoint="mono_return_double2_nested")]
90 public static extern double2_nested mono_return_double2_nested (double2_nested s, int addend);
91 [StructLayout(LayoutKind.Sequential)]
92 public struct double2_nested {
93 public double2_nested1 nested1;
94 public double2_nested2 nested2;
97 public static int Main (string[] args) {
101 double retval1 = mono_return_double1(s1, 9);
102 if (retval1 != 2*9) {
103 Console.WriteLine(" double1 retval1: got {0} but expected {1}", retval1, 2*9);
110 double retval2 = mono_return_double2(s2, 9);
111 if (retval2 != 2*9) {
112 Console.WriteLine(" double2 retval2: got {0} but expected {1}", retval2, 2*9);
120 double retval3 = mono_return_double3(s3, 9);
121 if (retval3 != 2*9) {
122 Console.WriteLine(" double3 retval3: got {0} but expected {1}", retval3, 2*9);
131 double retval4 = mono_return_double4(s4, 9);
132 if (retval4 != 2*9) {
133 Console.WriteLine(" double4 retval4: got {0} but expected {1}", retval4, 2*9);
143 double retval5 = mono_return_double5(s5, 9);
144 if (retval5 != 2*9) {
145 Console.WriteLine(" double5 retval5: got {0} but expected {1}", retval5, 2*9);
156 double retval6 = mono_return_double6(s6, 9);
157 if (retval6 != 2*9) {
158 Console.WriteLine(" double6 retval6: got {0} but expected {1}", retval6, 2*9);
170 double retval7 = mono_return_double7(s7, 9);
171 if (retval7 != 2*9) {
172 Console.WriteLine(" double7 retval7: got {0} but expected {1}", retval7, 2*9);
185 double retval8 = mono_return_double8(s8, 9);
186 if (retval8 != 2*9) {
187 Console.WriteLine(" double8 retval8: got {0} but expected {1}", retval8, 2*9);
201 double retval9 = mono_return_double9(s9, 9);
202 if (retval9 != 2*9) {
203 Console.WriteLine(" double9 retval9: got {0} but expected {1}", retval9, 2*9);
210 } // end class Test_double