2 using System.Runtime.InteropServices;
4 [StructLayout (LayoutKind.Sequential)]
7 public winx64_struct1 (byte ia)
14 [StructLayout (LayoutKind.Sequential)]
17 public winx64_struct2 (byte ia, byte ib)
27 [StructLayout (LayoutKind.Sequential)]
30 public winx64_struct3 (byte ia, byte ib, short ic)
42 [StructLayout (LayoutKind.Sequential)]
45 public winx64_struct4 (byte ia, byte ib, short ic, uint id)
59 [StructLayout (LayoutKind.Sequential)]
62 public winx64_struct5 (byte ia, byte ib, byte ic)
74 [StructLayout (LayoutKind.Sequential)]
77 public winx64_struct6 (winx64_struct1 ia, short ib, byte ic)
84 public winx64_struct1 a;
89 [StructLayout (LayoutKind.Sequential)]
90 struct winx64_floatStruct
92 public winx64_floatStruct (float ia, float ib)
102 [StructLayout (LayoutKind.Sequential)]
103 struct winx64_doubleStruct
105 public winx64_doubleStruct (double ia)
115 [DllImport ("libtest")]
116 static extern int mono_test_Winx64_struct1_in ([MarshalAs (UnmanagedType.Struct)] winx64_struct1 var);
118 [DllImport ("libtest")]
119 static extern int mono_test_Winx64_struct2_in ([MarshalAs (UnmanagedType.Struct)] winx64_struct2 var);
121 [DllImport ("libtest")]
122 static extern int mono_test_Winx64_struct3_in ([MarshalAs (UnmanagedType.Struct)] winx64_struct3 var);
124 [DllImport ("libtest")]
125 static extern int mono_test_Winx64_struct4_in ([MarshalAs (UnmanagedType.Struct)] winx64_struct4 var);
127 [DllImport ("libtest")]
128 static extern int mono_test_Winx64_struct5_in ([MarshalAs (UnmanagedType.Struct)] winx64_struct5 var);
130 [DllImport ("libtest")]
131 static extern int mono_test_Winx64_struct6_in ([MarshalAs (UnmanagedType.Struct)] winx64_struct6 var);
133 [DllImport ("libtest")]
134 static extern int mono_test_Winx64_structs_in1 ([MarshalAs (UnmanagedType.Struct)] winx64_struct1 var1,
135 [MarshalAs (UnmanagedType.Struct)] winx64_struct2 var2,
136 [MarshalAs (UnmanagedType.Struct)] winx64_struct3 var3,
137 [MarshalAs (UnmanagedType.Struct)] winx64_struct4 var4);
139 [DllImport ("libtest")]
140 static extern int mono_test_Winx64_structs_in2 ([MarshalAs (UnmanagedType.Struct)] winx64_struct1 var1,
141 [MarshalAs (UnmanagedType.Struct)] winx64_struct1 var2,
142 [MarshalAs (UnmanagedType.Struct)] winx64_struct1 var3,
143 [MarshalAs (UnmanagedType.Struct)] winx64_struct1 var4,
144 [MarshalAs (UnmanagedType.Struct)] winx64_struct1 var5);
146 [DllImport ("libtest")]
147 static extern int mono_test_Winx64_structs_in3 ([MarshalAs (UnmanagedType.Struct)] winx64_struct1 var1,
148 [MarshalAs (UnmanagedType.Struct)] winx64_struct5 var2,
149 [MarshalAs (UnmanagedType.Struct)] winx64_struct1 var3,
150 [MarshalAs (UnmanagedType.Struct)] winx64_struct5 var4,
151 [MarshalAs (UnmanagedType.Struct)] winx64_struct1 var5,
152 [MarshalAs (UnmanagedType.Struct)] winx64_struct5 var6);
154 [DllImport ("libtest")]
155 [return:MarshalAs (UnmanagedType.Struct)]
156 static extern winx64_struct1 mono_test_Winx64_struct1_ret ();
158 [DllImport ("libtest")]
159 [return: MarshalAs (UnmanagedType.Struct)]
160 static extern winx64_struct2 mono_test_Winx64_struct2_ret ();
162 [DllImport ("libtest")]
163 [return: MarshalAs (UnmanagedType.Struct)]
164 static extern winx64_struct3 mono_test_Winx64_struct3_ret ();
166 [DllImport ("libtest")]
167 [return: MarshalAs (UnmanagedType.Struct)]
168 static extern winx64_struct4 mono_test_Winx64_struct4_ret ();
170 [DllImport ("libtest")]
171 [return: MarshalAs (UnmanagedType.Struct)]
172 static extern winx64_struct5 mono_test_Winx64_struct5_ret ();
174 [DllImport ("libtest")]
175 static extern int mono_test_Winx64_floatStruct ([MarshalAs (UnmanagedType.Struct)] winx64_floatStruct var);
177 [DllImport ("libtest")]
178 static extern int mono_test_Winx64_doubleStruct ([MarshalAs (UnmanagedType.Struct)] winx64_doubleStruct var);
180 public delegate int managed_struct1_delegate ([MarshalAs (UnmanagedType.Struct)] winx64_struct1 var);
182 [DllImport ("libtest")]
183 static extern int mono_test_managed_Winx64_struct1_in (managed_struct1_delegate func);
185 private static bool enableBroken = false;
187 static int Main (string[] args)
189 return TestDriver.RunTests (typeof (winx64structs), args);
192 public static int test_0_In_Args_Value_In_RCX ()
196 winx64_struct1 t_winx64_struct1 = new winx64_struct1 (123);
198 if ((retCode = mono_test_Winx64_struct1_in (t_winx64_struct1)) != 0)
199 return 100 + retCode;
201 winx64_struct2 t_winx64_struct2 = new winx64_struct2 (4, 5);
203 if ((retCode = mono_test_Winx64_struct2_in (t_winx64_struct2)) != 0)
204 return 200 + retCode;
206 winx64_struct3 t_winx64_struct3 = new winx64_struct3 (4, 5, 0x1234);
208 if ((retCode = mono_test_Winx64_struct3_in (t_winx64_struct3)) != 0)
209 return 300 + retCode;
211 winx64_struct4 t_winx64_struct4 = new winx64_struct4 (4, 5, 0x1234, 0x87654321);
213 if ((retCode = mono_test_Winx64_struct4_in (t_winx64_struct4)) != 0)
214 return 400 + retCode;
216 winx64_floatStruct t_winx64_floatStruct = new winx64_floatStruct (5.5F, 9.5F);
218 if ((retCode = mono_test_Winx64_floatStruct (t_winx64_floatStruct)) != 0)
219 return 500 + retCode;
221 winx64_doubleStruct t_winx64_doubleStruct = new winx64_doubleStruct (5.5F);
223 if ((retCode = mono_test_Winx64_doubleStruct (t_winx64_doubleStruct)) != 0)
224 return 600 + retCode;
229 public static int test_0_In_Args_Values_In_Multiple_Registers ()
233 winx64_struct1 t_winx64_struct1 = new winx64_struct1 (123);
234 winx64_struct2 t_winx64_struct2 = new winx64_struct2 (4, 5);
235 winx64_struct3 t_winx64_struct3 = new winx64_struct3 (4, 5, 0x1234);
236 winx64_struct4 t_winx64_struct4 = new winx64_struct4 (4, 5, 0x1234, 0x87654321);
238 if ((retCode = mono_test_Winx64_structs_in1 (t_winx64_struct1, t_winx64_struct2,
239 t_winx64_struct3, t_winx64_struct4)) != 0)
240 return 100 + retCode;
246 public static int test_0_Ret_In_RAX ()
248 winx64_struct1 t_winx64_struct1 = mono_test_Winx64_struct1_ret ();
249 if (t_winx64_struct1.a != 123)
252 winx64_struct2 t_winx64_struct2 = mono_test_Winx64_struct2_ret ();
253 if (t_winx64_struct2.a != 4)
255 if (t_winx64_struct2.b != 5)
258 winx64_struct3 t_winx64_struct3 = mono_test_Winx64_struct3_ret ();
259 if (t_winx64_struct3.a != 4)
261 if (t_winx64_struct3.b != 5)
263 if (t_winx64_struct3.c != 0x1234)
266 winx64_struct4 t_winx64_struct4 = mono_test_Winx64_struct4_ret ();
267 if (t_winx64_struct4.a != 4)
269 if (t_winx64_struct4.b != 5)
271 if (t_winx64_struct4.c != 0x1234)
273 if (t_winx64_struct4.d != 0x87654321)
279 public static int test_0_Ret_In_Address ()
281 winx64_struct5 t_winx64_struct5 = mono_test_Winx64_struct5_ret ();
282 if (t_winx64_struct5.a != 4)
284 if (t_winx64_struct5.b != 5)
286 if (t_winx64_struct5.c != 6)
292 public static int test_0_In_Args_Values_In_Registers_and_Stack ()
296 winx64_struct1 var1 = new winx64_struct1 (1);
297 winx64_struct1 var2 = new winx64_struct1 (2);
298 winx64_struct1 var3 = new winx64_struct1 (3);
299 winx64_struct1 var4 = new winx64_struct1 (4);
300 winx64_struct1 var5 = new winx64_struct1 (5);
302 if ((retCode = mono_test_Winx64_structs_in2 (var1, var2, var3, var4, var5)) != 0)
303 return 100 + retCode;
308 public static int test_0_In_Args_Values_In_Registers_with_Stack_and_On_Stack ()
312 winx64_struct1 var1 = new winx64_struct1 (1);
313 winx64_struct5 var2 = new winx64_struct5 (2, 3, 4);
314 winx64_struct1 var3 = new winx64_struct1 (5);
315 winx64_struct5 var4 = new winx64_struct5 (6, 7, 8);
316 winx64_struct1 var5 = new winx64_struct1 (9);
317 winx64_struct5 var6 = new winx64_struct5 (10, 11, 12);
319 if ((retCode = mono_test_Winx64_structs_in3 (var1, var2, var3, var4, var5, var6)) != 0)
320 return 100 + retCode;
325 public static int test_0_In_Args_Value_On_Stack_ADDR_In_RCX ()
329 winx64_struct5 t_winx64_struct5 = new winx64_struct5 (4, 5, 6);
330 t_winx64_struct5.a = 4;
331 t_winx64_struct5.b = 5;
332 t_winx64_struct5.c = 6;
334 if ((retCode = mono_test_Winx64_struct5_in (t_winx64_struct5)) != 0)
335 return 100 + retCode;
337 winx64_struct6 t_winx64_struct6 = new winx64_struct6 (new winx64_struct1 (4), 5, 6);
339 if ((retCode = mono_test_Winx64_struct6_in (t_winx64_struct6)) != 0)
340 return 200 + retCode;
345 public static int test_0_In_Args_Value_In_RCX_Managed ()
349 managed_struct1_delegate s1Del = new managed_struct1_delegate (managed_struct1_test);
351 if ((retCode = mono_test_managed_Winx64_struct1_in (s1Del)) != 0)
352 return 100 + retCode;
357 public static int managed_struct1_test (winx64_struct1 var)