1 // pinvoke_ppcc.cs - Test cases for passing structures to and and returning
2 // structures from functions. This particular test is for
3 // structures consisting wholy of 1 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_sbyte {
22 [DllImport ("libtest", EntryPoint="mono_return_sbyte1")]
23 public static extern sbyte mono_return_sbyte1 (sbyte1 s, int addend);
24 [StructLayout(LayoutKind.Sequential)]
25 public struct sbyte1 {
28 [DllImport ("libtest", EntryPoint="mono_return_sbyte2")]
29 public static extern sbyte mono_return_sbyte2 (sbyte2 s, int addend);
30 [StructLayout(LayoutKind.Sequential)]
31 public struct sbyte2 {
34 [DllImport ("libtest", EntryPoint="mono_return_sbyte3")]
35 public static extern sbyte mono_return_sbyte3 (sbyte3 s, int addend);
36 [StructLayout(LayoutKind.Sequential)]
37 public struct sbyte3 {
38 public sbyte f1,f2,f3;
40 [DllImport ("libtest", EntryPoint="mono_return_sbyte4")]
41 public static extern sbyte mono_return_sbyte4 (sbyte4 s, int addend);
42 [StructLayout(LayoutKind.Sequential)]
43 public struct sbyte4 {
44 public sbyte f1,f2,f3,f4;
46 [DllImport ("libtest", EntryPoint="mono_return_sbyte5")]
47 public static extern sbyte mono_return_sbyte5 (sbyte5 s, int addend);
48 [StructLayout(LayoutKind.Sequential)]
49 public struct sbyte5 {
50 public sbyte f1,f2,f3,f4,f5;
52 [DllImport ("libtest", EntryPoint="mono_return_sbyte6")]
53 public static extern sbyte mono_return_sbyte6 (sbyte6 s, int addend);
54 [StructLayout(LayoutKind.Sequential)]
55 public struct sbyte6 {
56 public sbyte f1,f2,f3,f4,f5,f6;
58 [DllImport ("libtest", EntryPoint="mono_return_sbyte7")]
59 public static extern sbyte mono_return_sbyte7 (sbyte7 s, int addend);
60 [StructLayout(LayoutKind.Sequential)]
61 public struct sbyte7 {
62 public sbyte f1,f2,f3,f4,f5,f6,f7;
64 [DllImport ("libtest", EntryPoint="mono_return_sbyte8")]
65 public static extern sbyte mono_return_sbyte8 (sbyte8 s, int addend);
66 [StructLayout(LayoutKind.Sequential)]
67 public struct sbyte8 {
68 public sbyte f1,f2,f3,f4,f5,f6,f7,f8;
70 [DllImport ("libtest", EntryPoint="mono_return_sbyte9")]
71 public static extern sbyte mono_return_sbyte9 (sbyte9 s, int addend);
72 [StructLayout(LayoutKind.Sequential)]
73 public struct sbyte9 {
74 public sbyte f1,f2,f3,f4,f5,f6,f7,f8,f9;
76 [DllImport ("libtest", EntryPoint="mono_return_sbyte10")]
77 public static extern sbyte mono_return_sbyte10 (sbyte10 s, int addend);
78 [StructLayout(LayoutKind.Sequential)]
79 public struct sbyte10 {
80 public sbyte f1,f2,f3,f4,f5,f6,f7,f8,f9,f10;
82 [DllImport ("libtest", EntryPoint="mono_return_sbyte11")]
83 public static extern sbyte mono_return_sbyte11 (sbyte11 s, int addend);
84 [StructLayout(LayoutKind.Sequential)]
85 public struct sbyte11 {
86 public sbyte f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11;
88 [DllImport ("libtest", EntryPoint="mono_return_sbyte12")]
89 public static extern sbyte mono_return_sbyte12 (sbyte12 s, int addend);
90 [StructLayout(LayoutKind.Sequential)]
91 public struct sbyte12 {
92 public sbyte f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12;
94 [DllImport ("libtest", EntryPoint="mono_return_sbyte13")]
95 public static extern sbyte mono_return_sbyte13 (sbyte13 s, int addend);
96 [StructLayout(LayoutKind.Sequential)]
97 public struct sbyte13 {
98 public sbyte f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13;
100 [DllImport ("libtest", EntryPoint="mono_return_sbyte14")]
101 public static extern sbyte mono_return_sbyte14 (sbyte14 s, int addend);
102 [StructLayout(LayoutKind.Sequential)]
103 public struct sbyte14 {
104 public sbyte f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14;
106 [DllImport ("libtest", EntryPoint="mono_return_sbyte15")]
107 public static extern sbyte mono_return_sbyte15 (sbyte15 s, int addend);
108 [StructLayout(LayoutKind.Sequential)]
109 public struct sbyte15 {
110 public sbyte f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15;
112 [DllImport ("libtest", EntryPoint="mono_return_sbyte16")]
113 public static extern sbyte mono_return_sbyte16 (sbyte16 s, int addend);
114 [StructLayout(LayoutKind.Sequential)]
115 public struct sbyte16 {
116 public sbyte f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15,f16;
118 // This structure is 1 element too large to use the special return
120 [DllImport ("libtest", EntryPoint="mono_return_sbyte17")]
121 public static extern sbyte mono_return_sbyte17 (sbyte17 s, int addend);
122 [StructLayout(LayoutKind.Sequential)]
123 public struct sbyte17 {
124 public sbyte f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15,f16,f17;
127 // This structure has nested structures within it but they are
128 // homogenous and thus should still use the special rules.
129 public struct sbyte16_nested1 {
132 public struct sbyte16_nested2 {
135 [DllImport ("libtest", EntryPoint="mono_return_sbyte16_nested")]
136 public static extern sbyte16_nested mono_return_sbyte16_nested (sbyte16_nested s, int addend);
137 [StructLayout(LayoutKind.Sequential)]
138 public struct sbyte16_nested {
139 public sbyte16_nested1 nested1;
140 public sbyte f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15;
141 public sbyte16_nested2 nested2;
144 public static int Main (string[] args) {
148 sbyte retval1 = mono_return_sbyte1(s1, 9);
149 if (retval1 != 2*9) {
150 Console.WriteLine(" sbyte1 retval1: got {0} but expected {1}", retval1, 2*9);
157 sbyte retval2 = mono_return_sbyte2(s2, 9);
158 if (retval2 != 2*9) {
159 Console.WriteLine(" sbyte2 retval2: got {0} but expected {1}", retval2, 2*9);
167 sbyte retval3 = mono_return_sbyte3(s3, 9);
168 if (retval3 != 2*9) {
169 Console.WriteLine(" sbyte3 retval3: got {0} but expected {1}", retval3, 2*9);
178 sbyte retval4 = mono_return_sbyte4(s4, 9);
179 if (retval4 != 2*9) {
180 Console.WriteLine(" sbyte4 retval4: got {0} but expected {1}", retval4, 2*9);
190 sbyte retval5 = mono_return_sbyte5(s5, 9);
191 if (retval5 != 2*9) {
192 Console.WriteLine(" sbyte5 retval5: got {0} but expected {1}", retval5, 2*9);
203 sbyte retval6 = mono_return_sbyte6(s6, 9);
204 if (retval6 != 2*9) {
205 Console.WriteLine(" sbyte6 retval6: got {0} but expected {1}", retval6, 2*9);
217 sbyte retval7 = mono_return_sbyte7(s7, 9);
218 if (retval7 != 2*9) {
219 Console.WriteLine(" sbyte7 retval7: got {0} but expected {1}", retval7, 2*9);
232 sbyte retval8 = mono_return_sbyte8(s8, 9);
233 if (retval8 != 2*9) {
234 Console.WriteLine(" sbyte8 retval8: got {0} but expected {1}", retval8, 2*9);
248 sbyte retval9 = mono_return_sbyte9(s9, 9);
249 if (retval9 != 2*9) {
250 Console.WriteLine(" sbyte9 retval9: got {0} but expected {1}", retval9, 2*9);
265 sbyte retval10 = mono_return_sbyte10(s10, 9);
266 if (retval10 != 2*9) {
267 Console.WriteLine(" sbyte10 retval10: got {0} but expected {1}", retval10, 2*9);
283 sbyte retval11 = mono_return_sbyte11(s11, 9);
284 if (retval11 != 2*9) {
285 Console.WriteLine(" sbyte11 retval11: got {0} but expected {1}", retval11, 2*9);
302 sbyte retval12 = mono_return_sbyte12(s12, 9);
303 if (retval12 != 2*9) {
304 Console.WriteLine(" sbyte12 retval12: got {0} but expected {1}", retval12, 2*9);
322 sbyte retval13 = mono_return_sbyte13(s13, 9);
323 if (retval13 != 2*9) {
324 Console.WriteLine(" sbyte13 retval13: got {0} but expected {1}", retval13, 2*9);
343 sbyte retval14 = mono_return_sbyte14(s14, 9);
344 if (retval14 != 2*9) {
345 Console.WriteLine(" sbyte14 retval14: got {0} but expected {1}", retval14, 2*9);
365 sbyte retval15 = mono_return_sbyte15(s15, 9);
366 if (retval15 != 2*9) {
367 Console.WriteLine(" sbyte15 retval15: got {0} but expected {1}", retval15, 2*9);
388 sbyte retval16 = mono_return_sbyte16(s16, 9);
389 if (retval16 != 2*9) {
390 Console.WriteLine(" sbyte16 retval16: got {0} but expected {1}", retval16, 2*9);
412 sbyte retval17 = mono_return_sbyte17(s17, 9);
413 if (retval17 != 2*9) {
414 Console.WriteLine(" sbyte17 retval17: got {0} but expected {1}", retval17, 2*9);
421 } // end class Test_sbyte