19 #define STDCALL __stdcall
25 #pragma GCC diagnostic ignored "-Wmissing-prototypes"
29 extern __declspec(dllimport) void __stdcall CoTaskMemFree(void *ptr);
32 typedef int (STDCALL *SimpleDelegate) (int a);
34 #if defined(WIN32) && defined (_MSC_VER)
35 #define LIBTEST_API __declspec(dllexport)
36 #elif defined(__GNUC__)
37 #define LIBTEST_API __attribute__ ((visibility ("default")))
42 static void marshal_free (void *ptr)
51 static void* marshal_alloc (gsize size)
54 return CoTaskMemAlloc (size);
56 return g_malloc (size);
60 static void* marshal_alloc0 (gsize size)
63 void* ptr = CoTaskMemAlloc (size);
67 return g_malloc0 (size);
71 static char* marshal_strdup (const char *str)
81 buf = (char *) CoTaskMemAlloc (len + 1);
82 return strcpy (buf, str);
84 return g_strdup (str);
88 static gunichar2* marshal_bstr_alloc(const gchar* str)
91 gunichar2* ret = NULL;
92 gunichar2* temp = NULL;
93 temp = g_utf8_to_utf16 (str, -1, NULL, NULL, NULL);
94 ret = SysAllocString (temp);
99 int slen = strlen (str);
101 /* allocate len + 1 utf16 characters plus 4 byte integer for length*/
102 ret = (gchar *)g_malloc ((slen + 1) * sizeof(gunichar2) + sizeof(guint32));
105 temp = g_utf8_to_utf16 (str, -1, NULL, NULL, NULL);
106 memcpy (ret + sizeof(guint32), temp, slen * sizeof(gunichar2));
107 * ((guint32 *) ret) = slen * sizeof(gunichar2);
108 ret [4 + slen * sizeof(gunichar2)] = 0;
109 ret [5 + slen * sizeof(gunichar2)] = 0;
111 return (gunichar2*)(ret + 4);
115 #define marshal_new0(type,size) ((type *) marshal_alloc0 (sizeof (type)* (size)))
117 LIBTEST_API int STDCALL
118 mono_cominterop_is_supported (void)
120 #if defined(TARGET_X86) || defined(TARGET_AMD64)
126 LIBTEST_API unsigned short* STDCALL
127 test_lpwstr_marshal (unsigned short* chars, long length)
132 res = (unsigned short *)marshal_alloc (2 * (length + 1));
134 // printf("test_lpwstr_marshal()\n");
136 while ( i < length ) {
137 // printf("X|%u|\n", chars[i]);
148 LIBTEST_API void STDCALL
149 test_lpwstr_marshal_out (unsigned short** chars)
152 const char abc[] = "ABC";
153 glong len = strlen(abc);
155 *chars = (unsigned short *)marshal_alloc (2 * (len + 1));
158 (*chars) [i] = abc[i];
171 LIBTEST_API int STDCALL
172 mono_union_test_1 (union_test_1_type u1) {
173 // printf ("Got values %d %d %d\n", u1.b, u1.a, u1.c);
174 return u1.a + u1.b + u1.c;
177 LIBTEST_API int STDCALL
178 mono_return_int (int a) {
179 // printf ("Got value %d\n", a);
183 LIBTEST_API float STDCALL
184 mono_test_marshal_pass_return_float (float f) {
193 LIBTEST_API int STDCALL
194 mono_return_int_ss (struct ss a) {
195 // printf ("Got value %d\n", a.i);
199 LIBTEST_API struct ss STDCALL
200 mono_return_ss (struct ss a) {
201 // printf ("Got value %d\n", a.i);
211 LIBTEST_API struct sc1 STDCALL
212 mono_return_sc1 (struct sc1 a) {
213 // printf ("Got value %d\n", a.c[0]);
224 LIBTEST_API struct sc3 STDCALL
225 mono_return_sc3 (struct sc3 a) {
226 // printf ("Got values %d %d %d\n", a.c[0], a.c[1], a.c[2]);
238 LIBTEST_API struct sc5 STDCALL
239 mono_return_sc5 (struct sc5 a) {
240 // printf ("Got values %d %d %d %d %d\n", a.c[0], a.c[1], a.c[2], a.c[3], a.c[4]);
255 LIBTEST_API int STDCALL
256 mono_return_int_su (union su a) {
257 // printf ("Got value %d\n", a.i1);
272 LIBTEST_API struct NestedFloat STDCALL
273 mono_return_nested_float (void)
275 struct NestedFloat f;
283 LIBTEST_API int STDCALL
284 mono_test_many_int_arguments (int a, int b, int c, int d, int e,
285 int f, int g, int h, int i, int j);
286 LIBTEST_API short STDCALL
287 mono_test_many_short_arguments (short a, short b, short c, short d, short e,
288 short f, short g, short h, short i, short j);
289 LIBTEST_API char STDCALL
290 mono_test_many_char_arguments (char a, char b, char c, char d, char e,
291 char f, char g, char h, char i, char j);
293 LIBTEST_API int STDCALL
294 mono_test_many_int_arguments (int a, int b, int c, int d, int e, int f, int g, int h, int i, int j)
296 return a + b + c + d + e + f + g + h + i + j;
299 LIBTEST_API short STDCALL
300 mono_test_many_short_arguments (short a, short b, short c, short d, short e, short f, short g, short h, short i, short j)
302 return a + b + c + d + e + f + g + h + i + j;
305 LIBTEST_API char STDCALL
306 mono_test_many_byte_arguments (char a, char b, char c, char d, char e, char f, char g, char h, char i, char j)
308 return a + b + c + d + e + f + g + h + i + j;
311 LIBTEST_API float STDCALL
312 mono_test_many_float_arguments (float a, float b, float c, float d, float e, float f, float g, float h, float i, float j)
314 return a + b + c + d + e + f + g + h + i + j;
317 LIBTEST_API double STDCALL
318 mono_test_many_double_arguments (double a, double b, double c, double d, double e, double f, double g, double h, double i, double j)
320 return a + b + c + d + e + f + g + h + i + j;
323 LIBTEST_API double STDCALL
324 mono_test_split_double_arguments (double a, double b, float c, double d, double e)
326 return a + b + c + d + e;
329 LIBTEST_API int STDCALL
330 mono_test_puts_static (char *s)
332 // printf ("TEST %s\n", s);
336 typedef int (STDCALL *SimpleDelegate3) (int a, int b);
338 LIBTEST_API int STDCALL
339 mono_invoke_delegate (SimpleDelegate3 delegate)
343 // printf ("start invoke %p\n", delegate);
345 res = delegate (2, 3);
347 // printf ("end invoke\n");
352 LIBTEST_API int STDCALL
353 mono_invoke_simple_delegate (SimpleDelegate d)
358 LIBTEST_API int STDCALL
359 mono_test_marshal_char (short a1)
367 LIBTEST_API void STDCALL
368 mono_test_marshal_char_array (gunichar2 *s)
370 const char m[] = "abcdef";
374 s2 = g_utf8_to_utf16 (m, -1, NULL, &len, NULL);
382 LIBTEST_API int STDCALL
383 mono_test_marshal_ansi_char_array (char *s)
385 const char m[] = "abcdef";
387 if (strncmp ("qwer", s, 4))
390 memcpy (s, m, sizeof (m));
394 LIBTEST_API int STDCALL
395 mono_test_marshal_unicode_char_array (gunichar2 *s)
397 const char m[] = "abcdef";
398 const char expected[] = "qwer";
402 s1 = g_utf8_to_utf16 (m, -1, NULL, &len1, NULL);
403 s2 = g_utf8_to_utf16 (expected, -1, NULL, &len2, NULL);
407 if (memcmp (s, s2, len2))
410 memcpy (s, s1, len1);
414 LIBTEST_API int STDCALL
415 mono_test_empty_pinvoke (int i)
420 LIBTEST_API int STDCALL
421 mono_test_marshal_bool_byref (int a, int *b, int c)
430 LIBTEST_API int STDCALL
431 mono_test_marshal_bool_in_as_I1_U1 (char bTrue, char bFalse)
440 LIBTEST_API int STDCALL
441 mono_test_marshal_bool_out_as_I1_U1 (char* bTrue, char* bFalse)
443 if (!bTrue || !bFalse)
452 LIBTEST_API int STDCALL
453 mono_test_marshal_bool_ref_as_I1_U1 (char* bTrue, char* bFalse)
455 if (!bTrue || !bFalse)
469 LIBTEST_API int STDCALL
470 mono_test_marshal_array (int *a1)
474 for (i = 0; i < 50; i++)
480 LIBTEST_API int STDCALL
481 mono_test_marshal_inout_array (int *a1)
485 for (i = 0; i < 50; i++) {
487 a1 [i] = 50 - a1 [i];
493 LIBTEST_API int /* cdecl */
494 mono_test_marshal_inout_array_cdecl (int *a1)
496 return mono_test_marshal_inout_array (a1);
499 LIBTEST_API int STDCALL
500 mono_test_marshal_out_array (int *a1)
504 for (i = 0; i < 50; i++) {
511 LIBTEST_API int STDCALL
512 mono_test_marshal_out_byref_array_out_size_param (int **out_arr, int *out_len)
518 arr = (gint32 *)marshal_alloc (sizeof (gint32) * len);
519 for (i = 0; i < len; ++i)
527 LIBTEST_API int STDCALL
528 mono_test_marshal_out_lparray_out_size_param (int *arr, int *out_len)
533 for (i = 0; i < len; ++i)
540 LIBTEST_API int STDCALL
541 mono_test_marshal_inout_nonblittable_array (gunichar2 *a1)
545 for (i = 0; i < 10; i++) {
565 LIBTEST_API simplestruct STDCALL
566 mono_test_return_vtype (int i)
569 static gunichar2 test2 [] = { 'T', 'E', 'S', 'T', '2', 0 };
580 LIBTEST_API void STDCALL
581 mono_test_delegate_struct (void)
583 // printf ("TEST\n");
586 typedef char* (STDCALL *ReturnStringDelegate) (const char *s);
588 LIBTEST_API char * STDCALL
589 mono_test_return_string (ReturnStringDelegate func)
593 // printf ("mono_test_return_string\n");
598 // printf ("got string: %s\n", res);
599 return marshal_strdup ("12345");
602 typedef int (STDCALL *RefVTypeDelegate) (int a, simplestruct *ss, int b);
604 LIBTEST_API int STDCALL
605 mono_test_ref_vtype (int a, simplestruct *ss, int b, RefVTypeDelegate func)
607 if (a == 1 && b == 2 && ss->a == 0 && ss->b == 1 && ss->c == 0 &&
608 !strcmp (ss->d, "TEST1")) {
614 return func (a, ss, b);
620 typedef int (STDCALL *OutVTypeDelegate) (int a, simplestruct *ss, int b);
622 LIBTEST_API int STDCALL
623 mono_test_marshal_out_struct (int a, simplestruct *ss, int b, OutVTypeDelegate func)
625 /* Check that the input pointer is ignored */
626 ss->d = (const char *)0x12345678;
630 if (ss->a && ss->b && ss->c && !strcmp (ss->d, "TEST3"))
636 typedef int (STDCALL *InVTypeDelegate) (int a, simplestruct *ss, int b);
638 LIBTEST_API int STDCALL
639 mono_test_marshal_in_struct (int a, simplestruct *ss, int b, InVTypeDelegate func)
644 memcpy (&ss2, ss, sizeof (simplestruct));
646 res = func (a, ss, b);
648 printf ("mono_test_marshal_in_struct () failed: %d\n", res);
652 /* Check that no modifications is made to the struct */
653 if (ss2.a == ss->a && ss2.b == ss->b && ss2.c == ss->c && ss2.d == ss->d)
661 SimpleDelegate func, func2, func3;
664 LIBTEST_API DelegateStruct STDCALL
665 mono_test_marshal_delegate_struct (DelegateStruct ds)
669 res.a = ds.func (ds.a) + ds.func2 (ds.a) + (ds.func3 == NULL ? 0 : 1);
671 res.func2 = ds.func2;
677 LIBTEST_API int STDCALL
678 mono_test_marshal_struct (simplestruct ss)
680 if (ss.a == 0 && ss.b == 1 && ss.c == 0 &&
681 !strcmp (ss.d, "TEST"))
687 LIBTEST_API int STDCALL
688 mono_test_marshal_byref_struct (simplestruct *ss, int a, int b, int c, char *d)
690 gboolean res = (ss->a == a && ss->b == b && ss->c == c && strcmp (ss->d, d) == 0);
692 marshal_free ((char*)ss->d);
697 ss->d = marshal_strdup ("DEF");
713 LIBTEST_API int STDCALL
714 mono_test_marshal_struct2 (simplestruct2 ss)
716 if (ss.a == 0 && ss.b == 1 && ss.c == 0 &&
717 !strcmp (ss.d, "TEST") &&
718 ss.e == 99 && ss.f == 1.5 && ss.g == 42 && ss.h == (guint64)123)
724 /* on HP some of the struct should be on the stack and not in registers */
725 LIBTEST_API int STDCALL
726 mono_test_marshal_struct2_2 (int i, int j, int k, simplestruct2 ss)
728 if (i != 10 || j != 11 || k != 12)
730 if (ss.a == 0 && ss.b == 1 && ss.c == 0 &&
731 !strcmp (ss.d, "TEST") &&
732 ss.e == 99 && ss.f == 1.5 && ss.g == 42 && ss.h == (guint64)123)
738 LIBTEST_API int STDCALL
739 mono_test_marshal_lpstruct (simplestruct *ss)
741 if (ss->a == 0 && ss->b == 1 && ss->c == 0 &&
742 !strcmp (ss->d, "TEST"))
748 LIBTEST_API int STDCALL
749 mono_test_marshal_lpstruct_blittable (point *p)
751 if (p->x == 1.0 && p->y == 2.0)
757 LIBTEST_API int STDCALL
758 mono_test_marshal_struct_array (simplestruct2 *ss)
760 if (! (ss[0].a == 0 && ss[0].b == 1 && ss[0].c == 0 &&
761 !strcmp (ss[0].d, "TEST") &&
762 ss[0].e == 99 && ss[0].f == 1.5 && ss[0].g == 42 && ss[0].h == (guint64)123))
765 if (! (ss[1].a == 0 && ss[1].b == 0 && ss[1].c == 0 &&
766 !strcmp (ss[1].d, "TEST2") &&
767 ss[1].e == 100 && ss[1].f == 2.5 && ss[1].g == 43 && ss[1].h == (guint64)124))
773 typedef struct long_align_struct {
779 LIBTEST_API int STDCALL
780 mono_test_marshal_long_align_struct_array (long_align_struct *ss)
782 return ss[0].a + ss[0].b + ss[0].c + ss[1].a + ss[1].b + ss[1].c;
785 LIBTEST_API simplestruct2 * STDCALL
786 mono_test_marshal_class (int i, int j, int k, simplestruct2 *ss, int l)
793 if (i != 10 || j != 11 || k != 12 || l != 14)
795 if (! (ss->a == 0 && ss->b == 1 && ss->c == 0 &&
796 !strcmp (ss->d, "TEST") &&
797 ss->e == 99 && ss->f == 1.5 && ss->g == 42 && ss->h == (guint64)123))
800 res = marshal_new0 (simplestruct2, 1);
801 memcpy (res, ss, sizeof (simplestruct2));
802 res->d = marshal_strdup ("TEST");
806 LIBTEST_API int STDCALL
807 mono_test_marshal_byref_class (simplestruct2 **ssp)
809 simplestruct2 *ss = *ssp;
812 if (! (ss->a == 0 && ss->b == 1 && ss->c == 0 &&
813 !strcmp (ss->d, "TEST") &&
814 ss->e == 99 && ss->f == 1.5 && ss->g == 42 && ss->h == (guint64)123))
817 res = marshal_new0 (simplestruct2, 1);
818 memcpy (res, ss, sizeof (simplestruct2));
819 res->d = marshal_strdup ("TEST-RES");
831 /* Yes, this is correct, we are only trying to determine the value of the stack here */
836 LIBTEST_API int STDCALL
837 reliable_delegate (int a)
843 * Checks whether get_sp() works as expected. It doesn't work with gcc-2.95.3 on linux.
846 is_get_sp_reliable (void)
850 reliable_delegate(1);
852 reliable_delegate(1);
857 LIBTEST_API int STDCALL
858 mono_test_marshal_delegate (SimpleDelegate delegate)
862 /* Check that the delegate wrapper is stdcall */
867 if (is_get_sp_reliable())
868 g_assert (sp1 == sp2);
873 static int STDCALL inc_cb (int i)
878 LIBTEST_API int STDCALL
879 mono_test_marshal_out_delegate (SimpleDelegate *delegate)
886 LIBTEST_API SimpleDelegate STDCALL
887 mono_test_marshal_return_delegate (SimpleDelegate delegate)
892 typedef int DelegateByrefDelegate (void *);
894 LIBTEST_API int STDCALL
895 mono_test_marshal_delegate_ref_delegate (DelegateByrefDelegate del)
905 return_plus_one (int i)
910 LIBTEST_API SimpleDelegate STDCALL
911 mono_test_marshal_return_delegate_2 (void)
913 return return_plus_one;
916 typedef simplestruct (STDCALL *SimpleDelegate2) (simplestruct ss);
919 is_utf16_equals (gunichar2 *s1, const char *s2)
924 s = g_utf16_to_utf8 (s1, -1, NULL, NULL, NULL);
925 res = strcmp (s, s2);
931 LIBTEST_API int STDCALL
932 mono_test_marshal_delegate2 (SimpleDelegate2 delegate)
934 simplestruct ss, res;
940 ss.d2 = g_utf8_to_utf16 ("TEST2", -1, NULL, NULL, NULL);
943 if (! (res.a && !res.b && res.c && !strcmp (res.d, "TEST-RES") && is_utf16_equals (res.d2, "TEST2-RES")))
949 typedef simplestruct* (STDCALL *SimpleDelegate4) (simplestruct *ss);
951 LIBTEST_API int STDCALL
952 mono_test_marshal_delegate4 (SimpleDelegate4 delegate)
963 res = delegate (&ss);
967 /* Check return value */
968 if (! (!res->a && res->b && !res->c && !strcmp (res->d, "TEST")))
971 /* Check NULL argument and NULL result */
972 res = delegate (NULL);
979 typedef int (STDCALL *SimpleDelegate5) (simplestruct **ss);
981 LIBTEST_API int STDCALL
982 mono_test_marshal_delegate5 (SimpleDelegate5 delegate)
995 res = delegate (&ptr);
999 if (!(ptr->a && !ptr->b && ptr->c && !strcmp (ptr->d, "RES")))
1005 LIBTEST_API int STDCALL
1006 mono_test_marshal_delegate6 (SimpleDelegate5 delegate)
1012 typedef int (STDCALL *SimpleDelegate7) (simplestruct **ss);
1014 LIBTEST_API int STDCALL
1015 mono_test_marshal_delegate7 (SimpleDelegate7 delegate)
1020 /* Check that the input pointer is ignored */
1021 ptr = (simplestruct *)0x12345678;
1023 res = delegate (&ptr);
1027 if (!(ptr->a && !ptr->b && ptr->c && !strcmp (ptr->d, "RES")))
1033 typedef int (STDCALL *InOutByvalClassDelegate) (simplestruct *ss);
1035 LIBTEST_API int STDCALL
1036 mono_test_marshal_inout_byval_class_delegate (InOutByvalClassDelegate delegate)
1044 ss.d = g_strdup_printf ("%s", "FOO");
1046 res = delegate (&ss);
1050 if (!(ss.a && !ss.b && ss.c && !strcmp (ss.d, "RES")))
1056 typedef int (STDCALL *SimpleDelegate8) (gunichar2 *s);
1058 LIBTEST_API int STDCALL
1059 mono_test_marshal_delegate8 (SimpleDelegate8 delegate, gunichar2 *s)
1061 return delegate (s);
1064 typedef int (STDCALL *return_int_fnt) (int i);
1065 typedef int (STDCALL *SimpleDelegate9) (return_int_fnt d);
1067 LIBTEST_API int STDCALL
1068 mono_test_marshal_delegate9 (SimpleDelegate9 delegate, gpointer ftn)
1070 return delegate ((return_int_fnt)ftn);
1079 LIBTEST_API int STDCALL
1080 mono_test_marshal_delegate10 (SimpleDelegate9 delegate)
1082 return delegate (return_self);
1085 typedef int (STDCALL *PrimitiveByrefDelegate) (int *i);
1087 LIBTEST_API int STDCALL
1088 mono_test_marshal_primitive_byref_delegate (PrimitiveByrefDelegate delegate)
1092 int res = delegate (&i);
1102 typedef int (STDCALL *return_int_delegate) (int i);
1104 typedef return_int_delegate (STDCALL *ReturnDelegateDelegate) (void);
1106 LIBTEST_API int STDCALL
1107 mono_test_marshal_return_delegate_delegate (ReturnDelegateDelegate d)
1112 typedef int (STDCALL *VirtualDelegate) (int);
1114 LIBTEST_API int STDCALL
1115 mono_test_marshal_virtual_delegate (VirtualDelegate del)
1120 typedef char* (STDCALL *IcallDelegate) (const char *);
1121 LIBTEST_API int STDCALL
1122 mono_test_marshal_icall_delegate (IcallDelegate del)
1124 char *res = del ("ABC");
1125 return strcmp (res, "ABC") == 0 ? 0 : 1;
1128 LIBTEST_API int STDCALL
1129 mono_test_marshal_stringbuilder (char *s, int n)
1131 const char m[] = "This is my message. Isn't it nice?";
1133 if (strcmp (s, "ABCD") != 0)
1140 LIBTEST_API int STDCALL
1141 mono_test_marshal_stringbuilder_append (char *s, int length)
1143 const char out_sentinel[] = "CSHARP_";
1144 const char out_len = strlen (out_sentinel);
1146 for (int i=0; i < length; i++) {
1147 s [i] = out_sentinel [i % out_len];
1156 LIBTEST_API int STDCALL
1157 mono_test_marshal_stringbuilder_default (char *s, int n)
1159 const char m[] = "This is my message. Isn't it nice?";
1166 LIBTEST_API int STDCALL
1167 mono_test_marshal_stringbuilder_unicode (gunichar2 *s, int n)
1169 const char m[] = "This is my message. Isn't it nice?";
1173 s2 = g_utf8_to_utf16 (m, -1, NULL, &len, NULL);
1175 len = (len * 2) + 2;
1178 memcpy (s, s2, len);
1185 LIBTEST_API void STDCALL
1186 mono_test_marshal_stringbuilder_out (char **s)
1188 const char m[] = "This is my message. Isn't it nice?";
1191 str = (char *)marshal_alloc (strlen (m) + 1);
1192 memcpy (str, m, strlen (m) + 1);
1197 LIBTEST_API int STDCALL
1198 mono_test_marshal_stringbuilder_out_unicode (gunichar2 **s)
1200 const char m[] = "This is my message. Isn't it nice?";
1204 s2 = g_utf8_to_utf16 (m, -1, NULL, &len, NULL);
1206 len = (len * 2) + 2;
1207 *s = (gunichar2 *)marshal_alloc (len);
1208 memcpy (*s, s2, len);
1215 LIBTEST_API int STDCALL
1216 mono_test_marshal_stringbuilder_ref (char **s)
1218 const char m[] = "This is my message. Isn't it nice?";
1221 if (strcmp (*s, "ABC"))
1224 str = (char *)marshal_alloc (strlen (m) + 1);
1225 memcpy (str, m, strlen (m) + 1);
1231 #pragma GCC diagnostic push
1232 #pragma GCC diagnostic ignored "-Wc++-compat"
1238 #pragma GCC diagnostic pop
1240 LIBTEST_API int STDCALL
1241 mono_test_marshal_empty_string_array (char **array)
1243 return (array == NULL) ? 0 : 1;
1246 LIBTEST_API int STDCALL
1247 mono_test_marshal_string_array (char **array)
1249 if (strcmp (array [0], "ABC"))
1251 if (strcmp (array [1], "DEF"))
1254 if (array [2] != NULL)
1260 LIBTEST_API int STDCALL
1261 mono_test_marshal_byref_string_array (char ***array)
1266 if (strcmp ((*array) [0], "Alpha"))
1268 if (strcmp ((*array) [1], "Beta"))
1270 if (strcmp ((*array) [2], "Gamma"))
1276 LIBTEST_API int STDCALL
1277 mono_test_marshal_stringbuilder_array (char **array)
1279 if (strcmp (array [0], "ABC"))
1281 if (strcmp (array [1], "DEF"))
1284 strcpy (array [0], "DEF");
1285 strcpy (array [1], "ABC");
1290 LIBTEST_API int STDCALL
1291 mono_test_marshal_unicode_string_array (gunichar2 **array, char **array2)
1293 GError *error = NULL;
1296 s = g_utf16_to_utf8 (array [0], -1, NULL, NULL, &error);
1297 if (strcmp (s, "ABC")) {
1304 s = g_utf16_to_utf8 (array [1], -1, NULL, NULL, &error);
1305 if (strcmp (s, "DEF")) {
1312 if (strcmp (array2 [0], "ABC"))
1315 if (strcmp (array2 [1], "DEF"))
1321 /* this does not work on Redhat gcc 2.96 */
1322 LIBTEST_API int STDCALL
1323 mono_test_empty_struct (int a, EmptyStruct es, int b)
1325 // printf ("mono_test_empty_struct %d %d\n", a, b);
1327 // Intel icc on ia64 passes 'es' in 2 registers
1328 #if defined(__ia64) && defined(__INTEL_COMPILER)
1331 if (a == 1 && b == 2)
1337 LIBTEST_API EmptyStruct STDCALL
1338 mono_test_return_empty_struct (int a)
1342 memset (&s, 0, sizeof (s));
1353 LIBTEST_API ByValStrStruct * STDCALL
1354 mono_test_byvalstr_gen (void)
1356 ByValStrStruct *ret;
1358 ret = (ByValStrStruct *)malloc (sizeof (ByValStrStruct));
1359 memset(ret, 'a', sizeof(ByValStrStruct)-1);
1360 ret->a[sizeof(ByValStrStruct)-1] = 0;
1365 LIBTEST_API int STDCALL
1366 mono_test_byvalstr_check (ByValStrStruct* data, char* correctString)
1370 ret = strcmp(data->a, correctString);
1371 // printf ("T1: %s\n", data->a);
1372 // printf ("T2: %s\n", correctString);
1374 /* we need g_free because the allocation was performed by mono_test_byvalstr_gen */
1382 } ByValStrStruct_Unicode;
1384 LIBTEST_API int STDCALL
1385 mono_test_byvalstr_check_unicode (ByValStrStruct_Unicode *ref, int test)
1387 if (ref->flag != 0x1234abcd){
1388 printf ("overwritten data");
1392 if (test == 1 || test == 3){
1393 if (ref->a [0] != '1' ||
1394 ref->a [1] != '2' ||
1400 if (ref->a [0] != '1' ||
1408 LIBTEST_API int STDCALL
1409 NameManglingAnsi (char *data)
1411 return data [0] + data [1] + data [2];
1414 LIBTEST_API int STDCALL
1415 NameManglingAnsiA (char *data)
1417 g_assert_not_reached ();
1420 LIBTEST_API int STDCALL
1421 NameManglingAnsiW (char *data)
1423 g_assert_not_reached ();
1426 LIBTEST_API int STDCALL
1427 NameManglingAnsi2A (char *data)
1429 return data [0] + data [1] + data [2];
1432 LIBTEST_API int STDCALL
1433 NameManglingAnsi2W (char *data)
1435 g_assert_not_reached ();
1438 LIBTEST_API int STDCALL
1439 NameManglingUnicode (char *data)
1441 g_assert_not_reached ();
1444 LIBTEST_API int STDCALL
1445 NameManglingUnicodeW (gunichar2 *data)
1447 return data [0] + data [1] + data [2];
1450 LIBTEST_API int STDCALL
1451 NameManglingUnicode2 (gunichar2 *data)
1453 return data [0] + data [1] + data [2];
1456 LIBTEST_API int STDCALL
1457 NameManglingAutoW (char *data)
1460 return (data [0] + data [1] + data [2]) == 131 ? 0 : 1;
1462 g_assert_not_reached ();
1466 LIBTEST_API int STDCALL
1467 NameManglingAuto (char *data)
1470 return (data [0] + data [1] + data [2]) == 198 ? 0 : 1;
1472 g_assert_not_reached ();
1476 typedef int (STDCALL *intcharFunc)(const char*);
1478 LIBTEST_API void STDCALL
1479 callFunction (intcharFunc f)
1489 LIBTEST_API int STDCALL
1490 class_marshal_test0 (SimpleObj *obj1)
1492 // printf ("class_marshal_test0 %s %d\n", obj1->str, obj1->i);
1494 if (strcmp(obj1->str, "T1"))
1502 LIBTEST_API int STDCALL
1503 class_marshal_test4 (SimpleObj *obj1)
1511 LIBTEST_API void STDCALL
1512 class_marshal_test1 (SimpleObj **obj1)
1514 SimpleObj *res = (SimpleObj *)malloc (sizeof (SimpleObj));
1516 res->str = marshal_strdup ("ABC");
1522 LIBTEST_API int STDCALL
1523 class_marshal_test2 (SimpleObj **obj1)
1525 // printf ("class_marshal_test2 %s %d\n", (*obj1)->str, (*obj1)->i);
1527 if (strcmp((*obj1)->str, "ABC"))
1529 if ((*obj1)->i != 5)
1535 LIBTEST_API int STDCALL
1536 string_marshal_test0 (char *str)
1538 if (strcmp (str, "TEST0"))
1544 LIBTEST_API void STDCALL
1545 string_marshal_test1 (const char **str)
1547 *str = marshal_strdup ("TEST1");
1550 LIBTEST_API int STDCALL
1551 string_marshal_test2 (char **str)
1553 // printf ("string_marshal_test2 %s\n", *str);
1555 if (strcmp (*str, "TEST1"))
1558 *str = marshal_strdup ("TEST2");
1563 LIBTEST_API int STDCALL
1564 string_marshal_test3 (char *str)
1577 LIBTEST_API BlittableClass* STDCALL
1578 TestBlittableClass (BlittableClass *vl)
1580 BlittableClass *res;
1582 // printf ("TestBlittableClass %d %d\n", vl->a, vl->b);
1588 res = marshal_new0 (BlittableClass, 1);
1589 memcpy (res, vl, sizeof (BlittableClass));
1591 res = marshal_new0 (BlittableClass, 1);
1599 typedef struct OSVERSIONINFO_STRUCT
1603 } OSVERSIONINFO_STRUCT;
1605 LIBTEST_API int STDCALL
1606 MyGetVersionEx (OSVERSIONINFO_STRUCT *osvi)
1609 // printf ("GOT %d %d\n", osvi->a, osvi->b);
1614 return osvi->a + osvi->b;
1617 LIBTEST_API int STDCALL
1618 BugGetVersionEx (int a, int b, int c, int d, int e, int f, int g, int h, OSVERSIONINFO_STRUCT *osvi)
1621 // printf ("GOT %d %d\n", osvi->a, osvi->b);
1626 return osvi->a + osvi->b;
1629 LIBTEST_API int STDCALL
1630 mono_test_marshal_point (point pt)
1632 // printf("point %g %g\n", pt.x, pt.y);
1633 if (pt.x == 1.25 && pt.y == 3.5)
1644 LIBTEST_API int STDCALL
1645 mono_test_marshal_mixed_point (mixed_point pt)
1647 // printf("mixed point %d %g\n", pt.x, pt.y);
1648 if (pt.x == 5 && pt.y == 6.75)
1654 LIBTEST_API int STDCALL
1655 mono_test_marshal_mixed_point_2 (mixed_point *pt)
1657 if (pt->x != 5 || pt->y != 6.75)
1666 LIBTEST_API int STDCALL
1667 marshal_test_ref_bool(int i, char *b1, short *b2, int *b3)
1670 if (*b1 != 0 && *b1 != 1)
1672 if (*b2 != 0 && *b2 != -1) /* variant_bool */
1674 if (*b3 != 0 && *b3 != 1)
1676 if (i == ((*b1 << 2) | (-*b2 << 1) | *b3))
1688 short b2; /* variant_bool */
1692 LIBTEST_API int STDCALL
1693 marshal_test_bool_struct(struct BoolStruct *s)
1696 if (s->b1 != 0 && s->b1 != 1)
1698 if (s->b2 != 0 && s->b2 != -1)
1700 if (s->b3 != 0 && s->b3 != 1)
1702 if (s->i == ((s->b1 << 2) | (-s->b2 << 1) | s->b3))
1719 LIBTEST_API int STDCALL
1720 mono_test_marshal_long_struct (LongStruct *s)
1722 return s->i + s->l.l;
1725 LIBTEST_API void STDCALL
1726 mono_test_last_error (int err)
1735 LIBTEST_API int STDCALL
1736 mono_test_asany (void *ptr, int what)
1740 return (*(int*)ptr == 5) ? 0 : 1;
1742 return strcmp (ptr, "ABC") == 0 ? 0 : 1;
1744 simplestruct2 ss = *(simplestruct2*)ptr;
1746 if (ss.a == 0 && ss.b == 1 && ss.c == 0 &&
1747 !strcmp (ss.d, "TEST") &&
1748 ss.e == 99 && ss.f == 1.5 && ss.g == 42 && ss.h == (guint64)123)
1754 GError *error = NULL;
1757 s = g_utf16_to_utf8 ((const gunichar2 *)ptr, -1, NULL, NULL, &error);
1762 if (!strcmp (s, "ABC")) {
1772 g_assert_not_reached ();
1786 LIBTEST_API int STDCALL
1787 mono_test_marshal_asany_in (void* ptr)
1789 AsAnyStruct *asAny = (AsAnyStruct *)ptr;
1790 int res = asAny->i + asAny->j + asAny->k;
1795 LIBTEST_API int STDCALL
1796 mono_test_marshal_asany_inout (void* ptr)
1798 AsAnyStruct *asAny = (AsAnyStruct *)ptr;
1799 int res = asAny->i + asAny->j + asAny->k;
1801 marshal_free (asAny->s);
1811 LIBTEST_API int STDCALL
1812 mono_test_marshal_asany_out (void* ptr)
1814 AsAnyStruct *asAny = (AsAnyStruct *)ptr;
1815 int res = asAny->i + asAny->j + asAny->k;
1826 * AMD64 marshalling tests.
1829 typedef struct amd64_struct1 {
1836 LIBTEST_API amd64_struct1 STDCALL
1837 mono_test_marshal_amd64_pass_return_struct1 (amd64_struct1 s)
1847 LIBTEST_API amd64_struct1 STDCALL
1848 mono_test_marshal_amd64_pass_return_struct1_many_args (amd64_struct1 s, int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8)
1853 s.l += 1 + i1 + i2 + i3 + i4 + i5 + i6 + i7 + i8;
1858 typedef struct amd64_struct2 {
1863 LIBTEST_API amd64_struct2 STDCALL
1864 mono_test_marshal_amd64_pass_return_struct2 (amd64_struct2 s)
1872 typedef struct amd64_struct3 {
1876 LIBTEST_API amd64_struct3 STDCALL
1877 mono_test_marshal_amd64_pass_return_struct3 (amd64_struct3 s)
1884 typedef struct amd64_struct4 {
1888 LIBTEST_API amd64_struct4 STDCALL
1889 mono_test_marshal_amd64_pass_return_struct4 (amd64_struct4 s)
1898 * IA64 marshalling tests.
1900 typedef struct test_struct5 {
1904 LIBTEST_API test_struct5 STDCALL
1905 mono_test_marshal_ia64_pass_return_struct5 (double d1, double d2, test_struct5 s, int i, double d3, double d4)
1907 s.d1 += d1 + d2 + i;
1908 s.d2 += d3 + d4 + i;
1913 typedef struct test_struct6 {
1917 LIBTEST_API test_struct6 STDCALL
1918 mono_test_marshal_ia64_pass_return_struct6 (double d1, double d2, test_struct6 s, int i, double d3, double d4)
1920 s.d1 += d1 + d2 + i;
1926 static guint32 custom_res [2];
1928 LIBTEST_API void* STDCALL
1929 mono_test_marshal_pass_return_custom (int i, guint32 *ptr, int j)
1931 /* ptr will be freed by CleanupNative, so make a copy */
1932 custom_res [0] = 0; /* not allocated by AllocHGlobal */
1933 custom_res [1] = ptr [1];
1938 LIBTEST_API int STDCALL
1939 mono_test_marshal_pass_out_custom (int i, guint32 **ptr, int j)
1942 custom_res [1] = i + j + 10;
1949 LIBTEST_API int STDCALL
1950 mono_test_marshal_pass_inout_custom (int i, guint32 *ptr, int j)
1953 ptr [1] = i + ptr [1] + j;
1958 LIBTEST_API int STDCALL
1959 mono_test_marshal_pass_out_byval_custom (int i, guint32 *ptr, int j)
1961 return ptr == NULL ? 0 : 1;
1964 LIBTEST_API int STDCALL
1965 mono_test_marshal_pass_byref_custom (int i, guint32 **ptr, int j)
1972 LIBTEST_API void* STDCALL
1973 mono_test_marshal_pass_return_custom2 (int i, guint32 *ptr, int j)
1975 g_assert_not_reached ();
1980 LIBTEST_API void* STDCALL
1981 mono_test_marshal_pass_return_custom_null (int i, guint32 *ptr, int j)
1983 g_assert (ptr == NULL);
1988 typedef void *(STDCALL *PassReturnPtrDelegate) (void *ptr);
1990 LIBTEST_API int STDCALL
1991 mono_test_marshal_pass_return_custom_in_delegate (PassReturnPtrDelegate del)
2000 ptr = (guint32 *)del (&buf);
2005 /* FIXME: Freed with FreeHGlobal */
2013 LIBTEST_API int STDCALL
2014 mono_test_marshal_pass_return_custom_null_in_delegate (PassReturnPtrDelegate del)
2016 void *ptr = del (NULL);
2018 return (ptr == NULL) ? 15 : 0;
2021 typedef void (STDCALL *CustomOutParamDelegate) (void **pptr);
2023 LIBTEST_API int STDCALL
2024 mono_test_marshal_custom_out_param_delegate (CustomOutParamDelegate del)
2036 typedef int (STDCALL *ReturnEnumDelegate) (int e);
2038 LIBTEST_API int STDCALL
2039 mono_test_marshal_return_enum_delegate (ReturnEnumDelegate func)
2049 typedef BlittableStruct (STDCALL *SimpleDelegate10) (BlittableStruct ss);
2051 LIBTEST_API int STDCALL
2052 mono_test_marshal_blittable_struct_delegate (SimpleDelegate10 delegate)
2054 BlittableStruct ss, res;
2061 res = delegate (ss);
2062 if (! ((res.a == -1) && (res.b == -2) && (res.c == -3) && (res.d == -55)))
2068 LIBTEST_API int STDCALL
2069 mono_test_stdcall_name_mangling (int a, int b, int c)
2075 mono_test_stdcall_mismatch_1 (int a, int b, int c)
2080 LIBTEST_API int STDCALL
2081 mono_test_stdcall_mismatch_2 (int a, int b, int c)
2087 * PASSING AND RETURNING SMALL STRUCTURES FROM DELEGATES TESTS
2094 typedef SmallStruct1 (STDCALL *SmallStructDelegate1) (SmallStruct1 ss);
2096 LIBTEST_API int STDCALL
2097 mono_test_marshal_small_struct_delegate1 (SmallStructDelegate1 delegate)
2099 SmallStruct1 ss, res;
2103 res = delegate (ss);
2104 if (! (res.i == -1))
2114 typedef SmallStruct2 (STDCALL *SmallStructDelegate2) (SmallStruct2 ss);
2116 LIBTEST_API int STDCALL
2117 mono_test_marshal_small_struct_delegate2 (SmallStructDelegate2 delegate)
2119 SmallStruct2 ss, res;
2124 res = delegate (ss);
2125 if (! ((res.i == -2) && (res.j == -3)))
2136 typedef SmallStruct3 (STDCALL *SmallStructDelegate3) (SmallStruct3 ss);
2138 LIBTEST_API int STDCALL
2139 mono_test_marshal_small_struct_delegate3 (SmallStructDelegate3 delegate)
2141 SmallStruct3 ss, res;
2146 res = delegate (ss);
2147 if (! ((res.i == -1) && (res.j == -2)))
2157 typedef SmallStruct4 (STDCALL *SmallStructDelegate4) (SmallStruct4 ss);
2159 LIBTEST_API int STDCALL
2160 mono_test_marshal_small_struct_delegate4 (SmallStructDelegate4 delegate)
2162 SmallStruct4 ss, res;
2166 res = delegate (ss);
2167 if (! (res.i == -1))
2177 typedef SmallStruct5 (STDCALL *SmallStructDelegate5) (SmallStruct5 ss);
2179 LIBTEST_API int STDCALL
2180 mono_test_marshal_small_struct_delegate5 (SmallStructDelegate5 delegate)
2182 SmallStruct5 ss, res;
2186 res = delegate (ss);
2187 if (! (res.i == -5))
2197 typedef SmallStruct6 (STDCALL *SmallStructDelegate6) (SmallStruct6 ss);
2199 LIBTEST_API int STDCALL
2200 mono_test_marshal_small_struct_delegate6 (SmallStructDelegate6 delegate)
2202 SmallStruct6 ss, res;
2207 res = delegate (ss);
2208 if (! ((res.i == -1) && (res.j == -2)))
2219 typedef SmallStruct7 (STDCALL *SmallStructDelegate7) (SmallStruct7 ss);
2221 LIBTEST_API int STDCALL
2222 mono_test_marshal_small_struct_delegate7 (SmallStructDelegate7 delegate)
2224 SmallStruct7 ss, res;
2229 res = delegate (ss);
2230 if (! ((res.i == -1) && (res.j == -2)))
2240 typedef SmallStruct8 (STDCALL *SmallStructDelegate8) (SmallStruct8 ss);
2242 LIBTEST_API int STDCALL
2243 mono_test_marshal_small_struct_delegate8 (SmallStructDelegate8 delegate)
2245 SmallStruct8 ss, res;
2249 res = delegate (ss);
2250 if (! ((res.i == -1.0)))
2260 typedef SmallStruct9 (STDCALL *SmallStructDelegate9) (SmallStruct9 ss);
2262 LIBTEST_API int STDCALL
2263 mono_test_marshal_small_struct_delegate9 (SmallStructDelegate9 delegate)
2265 SmallStruct9 ss, res;
2269 res = delegate (ss);
2270 if (! ((res.i == -1.0)))
2280 typedef SmallStruct10 (STDCALL *SmallStructDelegate10) (SmallStruct10 ss);
2282 LIBTEST_API int STDCALL
2283 mono_test_marshal_small_struct_delegate10 (SmallStructDelegate10 delegate)
2285 SmallStruct10 ss, res;
2290 res = delegate (ss);
2291 if (! ((res.i == -1.0) && (res.j == -2.0)))
2302 typedef SmallStruct11 (STDCALL *SmallStructDelegate11) (SmallStruct11 ss);
2304 LIBTEST_API int STDCALL
2305 mono_test_marshal_small_struct_delegate11 (SmallStructDelegate11 delegate)
2307 SmallStruct11 ss, res;
2312 res = delegate (ss);
2313 if (! ((res.i == -1.0) && (res.j == -2)))
2319 typedef int (STDCALL *ArrayDelegate) (int i, char *j, void *arr);
2321 LIBTEST_API int STDCALL
2322 mono_test_marshal_array_delegate (void *arr, int len, ArrayDelegate del)
2324 return del (len, NULL, arr);
2327 typedef int (STDCALL *ArrayDelegateLong) (gint64 i, char *j, void *arr);
2329 LIBTEST_API int STDCALL
2330 mono_test_marshal_array_delegate_long (void *arr, gint64 len, ArrayDelegateLong del)
2332 return del (len, NULL, arr);
2335 LIBTEST_API int STDCALL
2336 mono_test_marshal_out_array_delegate (int *arr, int len, ArrayDelegate del)
2338 del (len, NULL, arr);
2340 if ((arr [0] != 1) || (arr [1] != 2))
2346 typedef gunichar2* (STDCALL *UnicodeStringDelegate) (gunichar2 *message);
2348 LIBTEST_API int STDCALL
2349 mono_test_marshal_return_unicode_string_delegate (UnicodeStringDelegate del)
2351 const char m[] = "abcdef";
2352 gunichar2 *s2, *res;
2355 s2 = g_utf8_to_utf16 (m, -1, NULL, &len, NULL);
2364 LIBTEST_API int STDCALL
2365 mono_test_marshal_out_string_array_delegate (char **arr, int len, ArrayDelegate del)
2367 del (len, NULL, arr);
2369 if (!strcmp (arr [0], "ABC") && !strcmp (arr [1], "DEF"))
2375 typedef int (*CdeclDelegate) (int i, int j);
2377 LIBTEST_API int STDCALL
2378 mono_test_marshal_cdecl_delegate (CdeclDelegate del)
2382 for (i = 0; i < 1000; ++i)
2388 typedef char** (STDCALL *ReturnStringArrayDelegate) (int i);
2390 LIBTEST_API int STDCALL
2391 mono_test_marshal_return_string_array_delegate (ReturnStringArrayDelegate d)
2399 if (strcmp (arr [0], "ABC") || strcmp (arr [1], "DEF"))
2409 typedef int (STDCALL *ByrefStringDelegate) (char **s);
2411 LIBTEST_API int STDCALL
2412 mono_test_marshal_byref_string_delegate (ByrefStringDelegate d)
2414 char *s = (char*)"ABC";
2421 if (!strcmp (s, "DEF"))
2431 LIBTEST_API int STDCALL
2432 add_delegate (int i, int j)
2437 LIBTEST_API gpointer STDCALL
2438 mono_test_marshal_return_fnptr (void)
2440 return &add_delegate;
2443 LIBTEST_API int STDCALL
2446 printf ("codigo %x\n", code);
2454 LIBTEST_API HandleRef STDCALL
2455 mono_xr_as_handle (int code)
2459 memset (&ref, 0, sizeof (ref));
2471 LIBTEST_API int STDCALL
2472 mono_safe_handle_struct_ref (HandleStructs *x)
2474 printf ("Dingus Ref! \n");
2475 printf ("Values: %d %d %p %p\n", x->a, x->b, x->handle1, x->handle2);
2481 if (x->handle1 != (void*) 0x7080feed)
2484 if (x->handle2 != (void*) 0x1234abcd)
2490 LIBTEST_API int STDCALL
2491 mono_safe_handle_struct (HandleStructs x)
2493 printf ("Dingus Standard! \n");
2494 printf ("Values: %d %d %p %p\n", x.a, x.b, x.handle1, x.handle2);
2500 if (x.handle1 != (void*) 0x7080feed)
2503 if (x.handle2 != (void*) 0x1234abcd)
2513 LIBTEST_API int STDCALL
2514 mono_safe_handle_struct_simple (TrivialHandle x)
2516 printf ("The value is %p\n", x.a);
2517 return ((int)(gsize)x.a) * 2;
2520 LIBTEST_API int STDCALL
2521 mono_safe_handle_return (void)
2526 LIBTEST_API void STDCALL
2527 mono_safe_handle_ref (void **handle)
2530 *handle = (void *) 0xbad;
2534 *handle = (void *) 0x800d;
2537 LIBTEST_API double STDCALL
2538 mono_test_marshal_date_time (double d, double *d2)
2610 VT_USERDEFINED = 29,
2618 VT_STREAMED_OBJECT = 68,
2619 VT_STORED_OBJECT = 69,
2620 VT_BLOB_OBJECT = 70,
2628 void VariantInit(VARIANT* vt)
2645 LIBTEST_API int STDCALL
2646 mono_test_marshal_bstr_in(gunichar2* bstr)
2649 gchar* bstr_utf8 = g_utf16_to_utf8 (bstr, -1, NULL, NULL, NULL);
2650 result = strcmp("mono_test_marshal_bstr_in", bstr_utf8);
2657 LIBTEST_API int STDCALL
2658 mono_test_marshal_bstr_out(gunichar2** bstr)
2660 *bstr = marshal_bstr_alloc ("mono_test_marshal_bstr_out");
2664 LIBTEST_API int STDCALL
2665 mono_test_marshal_bstr_in_null(gunichar2* bstr)
2672 LIBTEST_API int STDCALL
2673 mono_test_marshal_bstr_out_null(gunichar2** bstr)
2679 LIBTEST_API int STDCALL
2680 mono_test_marshal_variant_in_sbyte(VARIANT variant)
2682 if (variant.vt == VT_I1 && variant.cVal == 100)
2687 LIBTEST_API int STDCALL
2688 mono_test_marshal_variant_in_byte(VARIANT variant)
2690 if (variant.vt == VT_UI1 && variant.bVal == 100)
2695 LIBTEST_API int STDCALL
2696 mono_test_marshal_variant_in_short(VARIANT variant)
2698 if (variant.vt == VT_I2 && variant.iVal == 314)
2703 LIBTEST_API int STDCALL
2704 mono_test_marshal_variant_in_ushort(VARIANT variant)
2706 if (variant.vt == VT_UI2 && variant.uiVal == 314)
2711 LIBTEST_API int STDCALL
2712 mono_test_marshal_variant_in_int(VARIANT variant)
2714 if (variant.vt == VT_I4 && variant.lVal == 314)
2719 LIBTEST_API int STDCALL
2720 mono_test_marshal_variant_in_uint(VARIANT variant)
2722 if (variant.vt == VT_UI4 && variant.ulVal == 314)
2727 LIBTEST_API int STDCALL
2728 mono_test_marshal_variant_in_long(VARIANT variant)
2730 if (variant.vt == VT_I8 && variant.llVal == 314)
2735 LIBTEST_API int STDCALL
2736 mono_test_marshal_variant_in_ulong(VARIANT variant)
2738 if (variant.vt == VT_UI8 && variant.ullVal == 314)
2743 LIBTEST_API int STDCALL
2744 mono_test_marshal_variant_in_float(VARIANT variant)
2746 if (variant.vt == VT_R4 && (variant.fltVal - 3.14)/3.14 < .001)
2751 LIBTEST_API int STDCALL
2752 mono_test_marshal_variant_in_double(VARIANT variant)
2754 if (variant.vt == VT_R8 && (variant.dblVal - 3.14)/3.14 < .001)
2759 LIBTEST_API int STDCALL
2760 mono_test_marshal_variant_in_bstr(VARIANT variant)
2763 gchar* bstr_utf8 = g_utf16_to_utf8 (variant.bstrVal, -1, NULL, NULL, NULL);
2764 result = strcmp("PI", bstr_utf8);
2767 if (variant.vt == VT_BSTR && !result)
2772 LIBTEST_API int STDCALL
2773 mono_test_marshal_variant_in_bool_true (VARIANT variant)
2775 if (variant.vt == VT_BOOL && variant.boolVal == VARIANT_TRUE)
2780 LIBTEST_API int STDCALL
2781 mono_test_marshal_variant_in_bool_false (VARIANT variant)
2783 if (variant.vt == VT_BOOL && variant.boolVal == VARIANT_FALSE)
2788 LIBTEST_API int STDCALL
2789 mono_test_marshal_variant_out_sbyte(VARIANT* variant)
2791 variant->vt = VT_I1;
2792 variant->cVal = 100;
2797 LIBTEST_API int STDCALL
2798 mono_test_marshal_variant_out_sbyte_byref(VARIANT* variant)
2800 variant->vt = VT_I1|VT_BYREF;
2801 variant->byref = marshal_alloc(1);
2802 *((gint8*)variant->byref) = 100;
2807 LIBTEST_API int STDCALL
2808 mono_test_marshal_variant_out_byte(VARIANT* variant)
2810 variant->vt = VT_UI1;
2811 variant->bVal = 100;
2816 LIBTEST_API int STDCALL
2817 mono_test_marshal_variant_out_byte_byref(VARIANT* variant)
2819 variant->vt = VT_UI1|VT_BYREF;
2820 variant->byref = marshal_alloc(1);
2821 *((gint8*)variant->byref) = 100;
2826 LIBTEST_API int STDCALL
2827 mono_test_marshal_variant_out_short(VARIANT* variant)
2829 variant->vt = VT_I2;
2830 variant->iVal = 314;
2835 LIBTEST_API int STDCALL
2836 mono_test_marshal_variant_out_short_byref(VARIANT* variant)
2838 variant->vt = VT_I2|VT_BYREF;
2839 variant->byref = marshal_alloc(2);
2840 *((gint16*)variant->byref) = 314;
2845 LIBTEST_API int STDCALL
2846 mono_test_marshal_variant_out_ushort(VARIANT* variant)
2848 variant->vt = VT_UI2;
2849 variant->uiVal = 314;
2854 LIBTEST_API int STDCALL
2855 mono_test_marshal_variant_out_ushort_byref(VARIANT* variant)
2857 variant->vt = VT_UI2|VT_BYREF;
2858 variant->byref = marshal_alloc(2);
2859 *((guint16*)variant->byref) = 314;
2864 LIBTEST_API int STDCALL
2865 mono_test_marshal_variant_out_int(VARIANT* variant)
2867 variant->vt = VT_I4;
2868 variant->lVal = 314;
2873 LIBTEST_API int STDCALL
2874 mono_test_marshal_variant_out_int_byref(VARIANT* variant)
2876 variant->vt = VT_I4|VT_BYREF;
2877 variant->byref = marshal_alloc(4);
2878 *((gint32*)variant->byref) = 314;
2883 LIBTEST_API int STDCALL
2884 mono_test_marshal_variant_out_uint(VARIANT* variant)
2886 variant->vt = VT_UI4;
2887 variant->ulVal = 314;
2892 LIBTEST_API int STDCALL
2893 mono_test_marshal_variant_out_uint_byref(VARIANT* variant)
2895 variant->vt = VT_UI4|VT_BYREF;
2896 variant->byref = marshal_alloc(4);
2897 *((guint32*)variant->byref) = 314;
2902 LIBTEST_API int STDCALL
2903 mono_test_marshal_variant_out_long(VARIANT* variant)
2905 variant->vt = VT_I8;
2906 variant->llVal = 314;
2911 LIBTEST_API int STDCALL
2912 mono_test_marshal_variant_out_long_byref(VARIANT* variant)
2914 variant->vt = VT_I8|VT_BYREF;
2915 variant->byref = marshal_alloc(8);
2916 *((gint64*)variant->byref) = 314;
2921 LIBTEST_API int STDCALL
2922 mono_test_marshal_variant_out_ulong(VARIANT* variant)
2924 variant->vt = VT_UI8;
2925 variant->ullVal = 314;
2930 LIBTEST_API int STDCALL
2931 mono_test_marshal_variant_out_ulong_byref(VARIANT* variant)
2933 variant->vt = VT_UI8|VT_BYREF;
2934 variant->byref = marshal_alloc(8);
2935 *((guint64*)variant->byref) = 314;
2940 LIBTEST_API int STDCALL
2941 mono_test_marshal_variant_out_float(VARIANT* variant)
2943 variant->vt = VT_R4;
2944 variant->fltVal = 3.14;
2949 LIBTEST_API int STDCALL
2950 mono_test_marshal_variant_out_float_byref(VARIANT* variant)
2952 variant->vt = VT_R4|VT_BYREF;
2953 variant->byref = marshal_alloc(4);
2954 *((float*)variant->byref) = 3.14;
2959 LIBTEST_API int STDCALL
2960 mono_test_marshal_variant_out_double(VARIANT* variant)
2962 variant->vt = VT_R8;
2963 variant->dblVal = 3.14;
2968 LIBTEST_API int STDCALL
2969 mono_test_marshal_variant_out_double_byref(VARIANT* variant)
2971 variant->vt = VT_R8|VT_BYREF;
2972 variant->byref = marshal_alloc(8);
2973 *((double*)variant->byref) = 3.14;
2978 LIBTEST_API int STDCALL
2979 mono_test_marshal_variant_out_bstr(VARIANT* variant)
2981 variant->vt = VT_BSTR;
2982 variant->bstrVal = marshal_bstr_alloc("PI");
2987 LIBTEST_API int STDCALL
2988 mono_test_marshal_variant_out_bstr_byref(VARIANT* variant)
2990 variant->vt = VT_BSTR|VT_BYREF;
2991 variant->byref = marshal_alloc(sizeof(gpointer));
2992 *((gunichar**)variant->byref) = (gunichar*)marshal_bstr_alloc("PI");
2997 LIBTEST_API int STDCALL
2998 mono_test_marshal_variant_out_bool_true (VARIANT* variant)
3000 variant->vt = VT_BOOL;
3001 variant->boolVal = VARIANT_TRUE;
3006 LIBTEST_API int STDCALL
3007 mono_test_marshal_variant_out_bool_true_byref (VARIANT* variant)
3009 variant->vt = VT_BOOL|VT_BYREF;
3010 variant->byref = marshal_alloc(2);
3011 *((gint16*)variant->byref) = VARIANT_TRUE;
3016 LIBTEST_API int STDCALL
3017 mono_test_marshal_variant_out_bool_false (VARIANT* variant)
3019 variant->vt = VT_BOOL;
3020 variant->boolVal = VARIANT_FALSE;
3025 LIBTEST_API int STDCALL
3026 mono_test_marshal_variant_out_bool_false_byref (VARIANT* variant)
3028 variant->vt = VT_BOOL|VT_BYREF;
3029 variant->byref = marshal_alloc(2);
3030 *((gint16*)variant->byref) = VARIANT_FALSE;
3035 typedef int (STDCALL *VarFunc) (int vt, VARIANT variant);
3036 typedef int (STDCALL *VarRefFunc) (int vt, VARIANT* variant);
3038 LIBTEST_API int STDCALL
3039 mono_test_marshal_variant_in_sbyte_unmanaged(VarFunc func)
3044 return func (VT_I1, vt);
3047 LIBTEST_API int STDCALL
3048 mono_test_marshal_variant_in_byte_unmanaged(VarFunc func)
3053 return func (VT_UI1, vt);
3056 LIBTEST_API int STDCALL
3057 mono_test_marshal_variant_in_short_unmanaged(VarFunc func)
3062 return func (VT_I2, vt);
3065 LIBTEST_API int STDCALL
3066 mono_test_marshal_variant_in_ushort_unmanaged(VarFunc func)
3071 return func (VT_UI2, vt);
3074 LIBTEST_API int STDCALL
3075 mono_test_marshal_variant_in_int_unmanaged(VarFunc func)
3080 return func (VT_I4, vt);
3083 LIBTEST_API int STDCALL
3084 mono_test_marshal_variant_in_uint_unmanaged(VarFunc func)
3089 return func (VT_UI4, vt);
3092 LIBTEST_API int STDCALL
3093 mono_test_marshal_variant_in_long_unmanaged(VarFunc func)
3098 return func (VT_I8, vt);
3101 LIBTEST_API int STDCALL
3102 mono_test_marshal_variant_in_ulong_unmanaged(VarFunc func)
3107 return func (VT_UI8, vt);
3110 LIBTEST_API int STDCALL
3111 mono_test_marshal_variant_in_float_unmanaged(VarFunc func)
3116 return func (VT_R4, vt);
3119 LIBTEST_API int STDCALL
3120 mono_test_marshal_variant_in_double_unmanaged(VarFunc func)
3125 return func (VT_R8, vt);
3128 LIBTEST_API int STDCALL
3129 mono_test_marshal_variant_in_bstr_unmanaged(VarFunc func)
3133 vt.bstrVal = marshal_bstr_alloc("PI");
3134 return func (VT_BSTR, vt);
3137 LIBTEST_API int STDCALL
3138 mono_test_marshal_variant_in_bool_true_unmanaged(VarFunc func)
3142 vt.boolVal = VARIANT_TRUE;
3143 return func (VT_BOOL, vt);
3146 LIBTEST_API int STDCALL
3147 mono_test_marshal_variant_in_bool_false_unmanaged(VarFunc func)
3151 vt.boolVal = VARIANT_FALSE;
3152 return func (VT_BOOL, vt);
3155 LIBTEST_API int STDCALL
3156 mono_test_marshal_variant_out_sbyte_unmanaged(VarRefFunc func)
3161 if (vt.vt == VT_I1 && vt.cVal == -100)
3166 LIBTEST_API int STDCALL
3167 mono_test_marshal_variant_out_byte_unmanaged(VarRefFunc func)
3172 if (vt.vt == VT_UI1 && vt.bVal == 100)
3177 LIBTEST_API int STDCALL
3178 mono_test_marshal_variant_out_short_unmanaged(VarRefFunc func)
3183 if (vt.vt == VT_I2 && vt.iVal == -100)
3188 LIBTEST_API int STDCALL
3189 mono_test_marshal_variant_out_ushort_unmanaged(VarRefFunc func)
3194 if (vt.vt == VT_UI2 && vt.uiVal == 100)
3199 LIBTEST_API int STDCALL
3200 mono_test_marshal_variant_out_int_unmanaged(VarRefFunc func)
3205 if (vt.vt == VT_I4 && vt.lVal == -100)
3210 LIBTEST_API int STDCALL
3211 mono_test_marshal_variant_out_uint_unmanaged(VarRefFunc func)
3216 if (vt.vt == VT_UI4 && vt.ulVal == 100)
3221 LIBTEST_API int STDCALL
3222 mono_test_marshal_variant_out_long_unmanaged(VarRefFunc func)
3227 if (vt.vt == VT_I8 && vt.llVal == -100)
3232 LIBTEST_API int STDCALL
3233 mono_test_marshal_variant_out_ulong_unmanaged(VarRefFunc func)
3238 if (vt.vt == VT_UI8 && vt.ullVal == 100)
3243 LIBTEST_API int STDCALL
3244 mono_test_marshal_variant_out_float_unmanaged(VarRefFunc func)
3249 if (vt.vt == VT_R4 && fabs (vt.fltVal - 3.14f) < 1e-10)
3254 LIBTEST_API int STDCALL
3255 mono_test_marshal_variant_out_double_unmanaged(VarRefFunc func)
3260 if (vt.vt == VT_R8 && fabs (vt.dblVal - 3.14) < 1e-10)
3265 LIBTEST_API int STDCALL
3266 mono_test_marshal_variant_out_bstr_unmanaged(VarRefFunc func)
3274 func (VT_BSTR, &vt);
3275 bstr_utf8 = g_utf16_to_utf8 (vt.bstrVal, -1, NULL, NULL, NULL);
3276 result = strcmp("PI", bstr_utf8);
3278 if (vt.vt == VT_BSTR && !result)
3283 LIBTEST_API int STDCALL
3284 mono_test_marshal_variant_out_bool_true_unmanaged(VarRefFunc func)
3288 func (VT_BOOL, &vt);
3289 if (vt.vt == VT_BOOL && vt.boolVal == VARIANT_TRUE)
3294 LIBTEST_API int STDCALL
3295 mono_test_marshal_variant_out_bool_false_unmanaged(VarRefFunc func)
3299 func (VT_BOOL, &vt);
3300 if (vt.vt == VT_BOOL && vt.boolVal == VARIANT_TRUE)
3305 typedef struct MonoComObject MonoComObject;
3309 int (STDCALL *QueryInterface)(MonoComObject* pUnk, gpointer riid, gpointer* ppv);
3310 int (STDCALL *AddRef)(MonoComObject* pUnk);
3311 int (STDCALL *Release)(MonoComObject* pUnk);
3312 int (STDCALL *get_ITest)(MonoComObject* pUnk, MonoComObject* *ppUnk);
3313 int (STDCALL *SByteIn)(MonoComObject* pUnk, char a);
3314 int (STDCALL *ByteIn)(MonoComObject* pUnk, unsigned char a);
3315 int (STDCALL *ShortIn)(MonoComObject* pUnk, short a);
3316 int (STDCALL *UShortIn)(MonoComObject* pUnk, unsigned short a);
3317 int (STDCALL *IntIn)(MonoComObject* pUnk, int a);
3318 int (STDCALL *UIntIn)(MonoComObject* pUnk, unsigned int a);
3319 int (STDCALL *LongIn)(MonoComObject* pUnk, gint64 a);
3320 int (STDCALL *ULongIn)(MonoComObject* pUnk, guint64 a);
3321 int (STDCALL *FloatIn)(MonoComObject* pUnk, float a);
3322 int (STDCALL *DoubleIn)(MonoComObject* pUnk, double a);
3323 int (STDCALL *ITestIn)(MonoComObject* pUnk, MonoComObject* pUnk2);
3324 int (STDCALL *ITestOut)(MonoComObject* pUnk, MonoComObject* *ppUnk);
3327 struct MonoComObject
3333 static GUID IID_ITest = {0, 0, 0, {0,0,0,0,0,0,0,1}};
3334 static GUID IID_IMonoUnknown = {0, 0, 0, {0xc0,0,0,0,0,0,0,0x46}};
3335 static GUID IID_IMonoDispatch = {0x00020400, 0, 0, {0xc0,0,0,0,0,0,0,0x46}};
3337 LIBTEST_API int STDCALL
3338 MonoQueryInterface(MonoComObject* pUnk, gpointer riid, gpointer* ppv)
3342 if (!memcmp(riid, &IID_IMonoUnknown, sizeof(GUID))) {
3346 else if (!memcmp(riid, &IID_ITest, sizeof(GUID))) {
3350 else if (!memcmp(riid, &IID_IMonoDispatch, sizeof(GUID))) {
3354 return 0x80004002; //E_NOINTERFACE;
3357 LIBTEST_API int STDCALL
3358 MonoAddRef(MonoComObject* pUnk)
3360 return ++(pUnk->m_ref);
3363 LIBTEST_API int STDCALL
3364 MonoRelease(MonoComObject* pUnk)
3366 return --(pUnk->m_ref);
3369 LIBTEST_API int STDCALL
3370 SByteIn(MonoComObject* pUnk, char a)
3375 LIBTEST_API int STDCALL
3376 ByteIn(MonoComObject* pUnk, unsigned char a)
3381 LIBTEST_API int STDCALL
3382 ShortIn(MonoComObject* pUnk, short a)
3387 LIBTEST_API int STDCALL
3388 UShortIn(MonoComObject* pUnk, unsigned short a)
3393 LIBTEST_API int STDCALL
3394 IntIn(MonoComObject* pUnk, int a)
3399 LIBTEST_API int STDCALL
3400 UIntIn(MonoComObject* pUnk, unsigned int a)
3405 LIBTEST_API int STDCALL
3406 LongIn(MonoComObject* pUnk, gint64 a)
3411 LIBTEST_API int STDCALL
3412 ULongIn(MonoComObject* pUnk, guint64 a)
3417 LIBTEST_API int STDCALL
3418 FloatIn(MonoComObject* pUnk, float a)
3423 LIBTEST_API int STDCALL
3424 DoubleIn(MonoComObject* pUnk, double a)
3429 LIBTEST_API int STDCALL
3430 ITestIn(MonoComObject* pUnk, MonoComObject *pUnk2)
3435 LIBTEST_API int STDCALL
3436 ITestOut(MonoComObject* pUnk, MonoComObject* *ppUnk)
3441 static void create_com_object (MonoComObject** pOut);
3443 LIBTEST_API int STDCALL
3444 get_ITest(MonoComObject* pUnk, MonoComObject* *ppUnk)
3446 create_com_object (ppUnk);
3450 static void create_com_object (MonoComObject** pOut)
3452 *pOut = marshal_new0 (MonoComObject, 1);
3453 (*pOut)->vtbl = marshal_new0 (MonoIUnknown, 1);
3456 (*pOut)->vtbl->QueryInterface = MonoQueryInterface;
3457 (*pOut)->vtbl->AddRef = MonoAddRef;
3458 (*pOut)->vtbl->Release = MonoRelease;
3459 (*pOut)->vtbl->SByteIn = SByteIn;
3460 (*pOut)->vtbl->ByteIn = ByteIn;
3461 (*pOut)->vtbl->ShortIn = ShortIn;
3462 (*pOut)->vtbl->UShortIn = UShortIn;
3463 (*pOut)->vtbl->IntIn = IntIn;
3464 (*pOut)->vtbl->UIntIn = UIntIn;
3465 (*pOut)->vtbl->LongIn = LongIn;
3466 (*pOut)->vtbl->ULongIn = ULongIn;
3467 (*pOut)->vtbl->FloatIn = FloatIn;
3468 (*pOut)->vtbl->DoubleIn = DoubleIn;
3469 (*pOut)->vtbl->ITestIn = ITestIn;
3470 (*pOut)->vtbl->ITestOut = ITestOut;
3471 (*pOut)->vtbl->get_ITest = get_ITest;
3474 static MonoComObject* same_object = NULL;
3476 LIBTEST_API int STDCALL
3477 mono_test_marshal_com_object_create(MonoComObject* *pUnk)
3479 create_com_object (pUnk);
3482 same_object = *pUnk;
3487 LIBTEST_API int STDCALL
3488 mono_test_marshal_com_object_same(MonoComObject* *pUnk)
3490 *pUnk = same_object;
3495 LIBTEST_API int STDCALL
3496 mono_test_marshal_com_object_destroy(MonoComObject *pUnk)
3498 int ref = --(pUnk->m_ref);
3505 LIBTEST_API int STDCALL
3506 mono_test_marshal_com_object_ref_count(MonoComObject *pUnk)
3511 LIBTEST_API int STDCALL
3512 mono_test_marshal_ccw_itest (MonoComObject *pUnk)
3515 MonoComObject* pTest;
3520 hr = pUnk->vtbl->SByteIn (pUnk, -100);
3523 hr = pUnk->vtbl->ByteIn (pUnk, 100);
3526 hr = pUnk->vtbl->ShortIn (pUnk, -100);
3529 hr = pUnk->vtbl->UShortIn (pUnk, 100);
3532 hr = pUnk->vtbl->IntIn (pUnk, -100);
3535 hr = pUnk->vtbl->UIntIn (pUnk, 100);
3538 hr = pUnk->vtbl->LongIn (pUnk, -100);
3541 hr = pUnk->vtbl->ULongIn (pUnk, 100);
3544 hr = pUnk->vtbl->FloatIn (pUnk, 3.14f);
3547 hr = pUnk->vtbl->DoubleIn (pUnk, 3.14);
3550 hr = pUnk->vtbl->ITestIn (pUnk, pUnk);
3553 hr = pUnk->vtbl->ITestOut (pUnk, &pTest);
3561 * mono_method_get_unmanaged_thunk tests
3564 #if defined(__GNUC__) && ((defined(__i386__) && (defined(__linux__) || defined (__APPLE__)) || defined (__FreeBSD__) || defined(__OpenBSD__)) || (defined(__ppc__) && defined(__APPLE__)))
3565 #define ALIGN(size) __attribute__ ((aligned(size)))
3571 /* thunks.cs:TestStruct */
3572 typedef struct _TestStruct {
3577 /* Searches for mono symbols in all loaded modules */
3579 lookup_mono_symbol (const char *symbol_name)
3582 if (g_module_symbol (g_module_open (NULL, G_MODULE_BIND_LAZY), symbol_name, &symbol))
3588 LIBTEST_API gpointer STDCALL
3589 mono_test_marshal_lookup_symbol (const char *symbol_name)
3591 return lookup_mono_symbol (symbol_name);
3594 #define MONO_BEGIN_EFRAME { void *__dummy; void *__region_cookie = mono_threads_enter_gc_unsafe_region ? mono_threads_enter_gc_unsafe_region (&__dummy) : NULL;
3595 #define MONO_END_EFRAME if (mono_threads_exit_gc_unsafe_region) mono_threads_exit_gc_unsafe_region (__region_cookie, &__dummy); }
3598 * test_method_thunk:
3600 * @test_id: the test number
3601 * @test_method_handle: MonoMethod* of the C# test method
3602 * @create_object_method_handle: MonoMethod* of thunks.cs:Test.CreateObject
3604 LIBTEST_API int STDCALL
3605 test_method_thunk (int test_id, gpointer test_method_handle, gpointer create_object_method_handle)
3609 gpointer (*mono_method_get_unmanaged_thunk)(gpointer)
3610 = (gpointer (*)(gpointer))lookup_mono_symbol ("mono_method_get_unmanaged_thunk");
3612 gpointer (*mono_string_new_wrapper)(const char *)
3613 = (gpointer (*)(const char *))lookup_mono_symbol ("mono_string_new_wrapper");
3615 char *(*mono_string_to_utf8)(gpointer)
3616 = (char *(*)(gpointer))lookup_mono_symbol ("mono_string_to_utf8");
3618 gpointer (*mono_object_unbox)(gpointer)
3619 = (gpointer (*)(gpointer))lookup_mono_symbol ("mono_object_unbox");
3621 gpointer (*mono_threads_enter_gc_unsafe_region) (gpointer)
3622 = (gpointer (*)(gpointer))lookup_mono_symbol ("mono_threads_enter_gc_unsafe_region");
3624 void (*mono_threads_exit_gc_unsafe_region) (gpointer, gpointer)
3625 = (void (*)(gpointer, gpointer))lookup_mono_symbol ("mono_threads_exit_gc_unsafe_region");
3629 gpointer test_method, ex = NULL;
3630 gpointer (STDCALL *CreateObject)(gpointer*);
3634 if (!mono_method_get_unmanaged_thunk) {
3639 test_method = mono_method_get_unmanaged_thunk (test_method_handle);
3645 CreateObject = (gpointer (STDCALL *)(gpointer *))mono_method_get_unmanaged_thunk (create_object_method_handle);
3646 if (!CreateObject) {
3655 /* thunks.cs:Test.Test0 */
3656 void (STDCALL *F)(gpointer *) = (void (STDCALL *)(gpointer *))test_method;
3662 /* thunks.cs:Test.Test1 */
3663 int (STDCALL *F)(gpointer *) = (int (STDCALL *)(gpointer *))test_method;
3664 if (F (&ex) != 42) {
3672 /* thunks.cs:Test.Test2 */
3673 gpointer (STDCALL *F)(gpointer, gpointer*) = (gpointer (STDCALL *)(gpointer, gpointer *))test_method;
3674 gpointer str = mono_string_new_wrapper ("foo");
3675 if (str != F (str, &ex)) {
3683 /* thunks.cs:Test.Test3 */
3684 gpointer (STDCALL *F)(gpointer, gpointer, gpointer*);
3688 F = (gpointer (STDCALL *)(gpointer, gpointer, gpointer *))test_method;
3689 obj = CreateObject (&ex);
3690 str = mono_string_new_wrapper ("bar");
3692 if (str != F (obj, str, &ex)) {
3700 /* thunks.cs:Test.Test4 */
3701 int (STDCALL *F)(gpointer, gpointer, int, gpointer*);
3705 F = (int (STDCALL *)(gpointer, gpointer, int, gpointer *))test_method;
3706 obj = CreateObject (&ex);
3707 str = mono_string_new_wrapper ("bar");
3709 if (42 != F (obj, str, 42, &ex)) {
3718 /* thunks.cs:Test.Test5 */
3719 int (STDCALL *F)(gpointer, gpointer, int, gpointer*);
3723 F = (int (STDCALL *)(gpointer, gpointer, int, gpointer *))test_method;
3724 obj = CreateObject (&ex);
3725 str = mono_string_new_wrapper ("bar");
3727 F (obj, str, 42, &ex);
3737 /* thunks.cs:Test.Test6 */
3738 int (STDCALL *F)(gpointer, guint8, gint16, gint32, gint64, float, double,
3739 gpointer, gpointer*);
3741 gpointer str = mono_string_new_wrapper ("Test6");
3744 F = (int (STDCALL *)(gpointer, guint8, gint16, gint32, gint64, float, double, gpointer, gpointer *))test_method;
3745 obj = CreateObject (&ex);
3747 res = F (obj, 254, 32700, -245378, 6789600, 3.1415, 3.1415, str, &ex);
3762 /* thunks.cs:Test.Test7 */
3763 gint64 (STDCALL *F)(gpointer*) = (gint64 (STDCALL *)(gpointer *))test_method;
3764 if (F (&ex) != G_MAXINT64) {
3772 /* thunks.cs:Test.Test8 */
3773 void (STDCALL *F)(guint8*, gint16*, gint32*, gint64*, float*, double*,
3774 gpointer*, gpointer*);
3784 F = (void (STDCALL *)(guint8 *, gint16 *, gint32 *, gint64 *, float *, double *,
3785 gpointer *, gpointer *))test_method;
3787 F (&a1, &a2, &a3, &a4, &a5, &a6, &a7, &ex);
3797 (fabs (a5 - 3.1415) < 0.001) &&
3798 (fabs (a6 - 3.1415) < 0.001) &&
3799 strcmp (mono_string_to_utf8 (a7), "Test8") == 0)){
3808 /* thunks.cs:Test.Test9 */
3809 void (STDCALL *F)(guint8*, gint16*, gint32*, gint64*, float*, double*,
3810 gpointer*, gpointer*);
3820 F = (void (STDCALL *)(guint8 *, gint16 *, gint32 *, gint64 *, float *, double *,
3821 gpointer *, gpointer *))test_method;
3823 F (&a1, &a2, &a3, &a4, &a5, &a6, &a7, &ex);
3833 /* thunks.cs:Test.Test10 */
3834 void (STDCALL *F)(gpointer*, gpointer*);
3836 gpointer obj1, obj2;
3838 obj1 = obj2 = CreateObject (&ex);
3844 F = (void (STDCALL *)(gpointer *, gpointer *))test_method;
3861 /* thunks.cs:TestStruct.Test0 */
3862 int (STDCALL *F)(gpointer*, gpointer*);
3868 obj = CreateObject (&ex);
3879 a1 = (TestStruct *)mono_object_unbox (obj);
3888 F = (int (STDCALL *)(gpointer *, gpointer *))test_method;
3890 res = F ((gpointer *)obj, &ex);
3901 /* check whether the call was really by value */
3902 if (a1->A != 42 || a1->B != 3.1415) {
3911 /* thunks.cs:TestStruct.Test1 */
3912 void (STDCALL *F)(gpointer, gpointer*);
3917 obj = CreateObject (&ex);
3928 a1 = (TestStruct *)mono_object_unbox (obj);
3934 F = (void (STDCALL *)(gpointer, gpointer *))test_method;
3947 if (!(fabs (a1->B - 3.1415) < 0.001)) {
3956 /* thunks.cs:TestStruct.Test2 */
3957 gpointer (STDCALL *F)(gpointer*);
3962 F = (gpointer (STDCALL *)(gpointer *))test_method;
3975 a1 = (TestStruct *)mono_object_unbox (obj);
3982 if (!(fabs (a1->B - 3.1415) < 0.001)) {
3991 /* thunks.cs:TestStruct.Test3 */
3992 void (STDCALL *F)(gpointer, gpointer*);
3997 obj = CreateObject (&ex);
4008 a1 = (TestStruct *)mono_object_unbox (obj);
4018 F = (void (STDCALL *)(gpointer, gpointer *))test_method;
4054 LIBTEST_API int STDCALL
4055 mono_test_Winx64_struct1_in (winx64_struct1 var)
4068 LIBTEST_API int STDCALL
4069 mono_test_Winx64_struct2_in (winx64_struct2 var)
4086 LIBTEST_API int STDCALL
4087 mono_test_Winx64_struct3_in (winx64_struct3 var)
4093 if (var.c != 0x1234)
4106 LIBTEST_API int STDCALL
4107 mono_test_Winx64_struct4_in (winx64_struct4 var)
4113 if (var.c != 0x1234)
4115 if (var.d != 0x87654321)
4127 LIBTEST_API int STDCALL
4128 mono_test_Winx64_struct5_in (winx64_struct5 var)
4146 LIBTEST_API int STDCALL
4147 mono_test_Winx64_struct6_in (winx64_struct6 var)
4158 LIBTEST_API int STDCALL
4159 mono_test_Winx64_structs_in1 (winx64_struct1 var1,
4160 winx64_struct2 var2,
4161 winx64_struct3 var3,
4162 winx64_struct4 var4)
4176 if (var3.c != 0x1234)
4183 if (var4.c != 0x1234)
4185 if (var4.d != 0x87654321)
4190 LIBTEST_API int STDCALL
4191 mono_test_Winx64_structs_in2 (winx64_struct1 var1,
4192 winx64_struct1 var2,
4193 winx64_struct1 var3,
4194 winx64_struct1 var4,
4195 winx64_struct1 var5)
4211 LIBTEST_API int STDCALL
4212 mono_test_Winx64_structs_in3 (winx64_struct1 var1,
4213 winx64_struct5 var2,
4214 winx64_struct1 var3,
4215 winx64_struct5 var4,
4216 winx64_struct1 var5,
4217 winx64_struct5 var6)
4252 LIBTEST_API winx64_struct1 STDCALL
4253 mono_test_Winx64_struct1_ret (void)
4260 LIBTEST_API winx64_struct2 STDCALL
4261 mono_test_Winx64_struct2_ret (void)
4269 LIBTEST_API winx64_struct3 STDCALL
4270 mono_test_Winx64_struct3_ret (void)
4279 LIBTEST_API winx64_struct4 STDCALL
4280 mono_test_Winx64_struct4_ret (void)
4290 LIBTEST_API winx64_struct5 STDCALL
4291 mono_test_Winx64_struct5_ret (void)
4300 LIBTEST_API winx64_struct1 STDCALL
4301 mono_test_Winx64_struct1_ret_5_args (char a, char b, char c, char d, char e)
4304 ret.a = a + b + c + d + e;
4308 LIBTEST_API winx64_struct5 STDCALL
4309 mono_test_Winx64_struct5_ret6_args (char a, char b, char c, char d, char e)
4322 } winx64_floatStruct;
4324 LIBTEST_API int STDCALL
4325 mono_test_Winx64_floatStruct (winx64_floatStruct a)
4327 if (a.a > 5.6 || a.a < 5.4)
4330 if (a.b > 9.6 || a.b < 9.4)
4339 } winx64_doubleStruct;
4341 LIBTEST_API int STDCALL
4342 mono_test_Winx64_doubleStruct (winx64_doubleStruct a)
4344 if (a.a > 5.6 || a.a < 5.4)
4350 typedef int (STDCALL *managed_struct1_delegate) (winx64_struct1 a);
4352 LIBTEST_API int STDCALL
4353 mono_test_managed_Winx64_struct1_in(managed_struct1_delegate func)
4360 typedef int (STDCALL *managed_struct5_delegate) (winx64_struct5 a);
4362 LIBTEST_API int STDCALL
4363 mono_test_managed_Winx64_struct5_in(managed_struct5_delegate func)
4372 typedef int (STDCALL *managed_struct1_struct5_delegate) (winx64_struct1 a, winx64_struct5 b,
4373 winx64_struct1 c, winx64_struct5 d,
4374 winx64_struct1 e, winx64_struct5 f);
4376 LIBTEST_API int STDCALL
4377 mono_test_managed_Winx64_struct1_struct5_in(managed_struct1_struct5_delegate func)
4379 winx64_struct1 a, c, e;
4380 winx64_struct5 b, d, f;
4382 b.a = 2; b.b = 3; b.c = 4;
4384 d.a = 6; d.b = 7; d.c = 8;
4386 f.a = 10; f.b = 11; f.c = 12;
4388 return func (a, b, c, d, e, f);
4391 typedef winx64_struct1 (STDCALL *managed_struct1_ret_delegate) (void);
4393 LIBTEST_API int STDCALL
4394 mono_test_Winx64_struct1_ret_managed (managed_struct1_ret_delegate func)
4406 typedef winx64_struct5 (STDCALL *managed_struct5_ret_delegate) (void);
4408 LIBTEST_API int STDCALL
4409 mono_test_Winx64_struct5_ret_managed (managed_struct5_ret_delegate func)
4425 LIBTEST_API int STDCALL
4426 mono_test_marshal_bool_in (int arg, unsigned int expected, unsigned int bDefaultMarsh, unsigned int bBoolCustMarsh,
4427 char bI1CustMarsh, unsigned char bU1CustMarsh, short bVBCustMarsh)
4431 if (bDefaultMarsh != expected)
4435 if (bBoolCustMarsh != expected)
4439 if (bI1CustMarsh != expected)
4443 if (bU1CustMarsh != expected)
4447 if (bVBCustMarsh != expected)
4456 LIBTEST_API int STDCALL
4457 mono_test_marshal_bool_out (int arg, unsigned int testVal, unsigned int* bDefaultMarsh, unsigned int* bBoolCustMarsh,
4458 char* bI1CustMarsh, unsigned char* bU1CustMarsh, unsigned short* bVBCustMarsh)
4464 *bDefaultMarsh = testVal;
4467 if (!bBoolCustMarsh)
4469 *bBoolCustMarsh = testVal;
4474 *bI1CustMarsh = (char)testVal;
4479 *bU1CustMarsh = (unsigned char)testVal;
4484 *bVBCustMarsh = (unsigned short)testVal;
4492 LIBTEST_API int STDCALL
4493 mono_test_marshal_bool_ref (int arg, unsigned int expected, unsigned int testVal, unsigned int* bDefaultMarsh,
4494 unsigned int* bBoolCustMarsh, char* bI1CustMarsh, unsigned char* bU1CustMarsh,
4495 unsigned short* bVBCustMarsh)
4501 if (*bDefaultMarsh != expected)
4503 *bDefaultMarsh = testVal;
4506 if (!bBoolCustMarsh)
4508 if (*bBoolCustMarsh != expected)
4510 *bBoolCustMarsh = testVal;
4515 if (*bI1CustMarsh != expected)
4517 *bI1CustMarsh = (char)testVal;
4522 if (*bU1CustMarsh != expected)
4524 *bU1CustMarsh = (unsigned char)testVal;
4529 if (*bVBCustMarsh != expected)
4531 *bVBCustMarsh = (unsigned short)testVal;
4540 typedef int (STDCALL *MarshalBoolInDelegate) (int arg, unsigned int expected, unsigned int bDefaultMarsh,
4541 unsigned int bBoolCustMarsh, char bI1CustMarsh, unsigned char bU1CustMarsh, unsigned short bVBCustMarsh);
4543 LIBTEST_API int STDCALL
4544 mono_test_managed_marshal_bool_in (int arg, unsigned int expected, unsigned int testVal, MarshalBoolInDelegate pfcn)
4551 return pfcn (arg, expected, testVal, 0, 0, 0, 0);
4553 return pfcn (arg, expected, 0, testVal, 0, 0, 0);
4555 return pfcn (arg, expected, 0, 0, testVal, 0, 0);
4557 return pfcn (arg, expected, 0, 0, 0, testVal, 0);
4559 return pfcn (arg, expected, 0, 0, 0, 0, testVal);
4567 typedef int (STDCALL *MarshalBoolOutDelegate) (int arg, unsigned int expected, unsigned int* bDefaultMarsh,
4568 unsigned int* bBoolCustMarsh, char* bI1CustMarsh, unsigned char* bU1CustMarsh, unsigned short* bVBCustMarsh);
4570 LIBTEST_API int STDCALL
4571 mono_test_managed_marshal_bool_out (int arg, unsigned int expected, unsigned int testVal, MarshalBoolOutDelegate pfcn)
4574 unsigned int lDefaultMarsh, lBoolCustMarsh;
4575 char lI1CustMarsh = 0;
4576 unsigned char lU1CustMarsh = 0;
4577 unsigned short lVBCustMarsh = 0;
4578 lDefaultMarsh = lBoolCustMarsh = 0;
4585 unsigned int ltVal = 0;
4586 ret = pfcn (arg, testVal, <Val, &lBoolCustMarsh, &lI1CustMarsh, &lU1CustMarsh, &lVBCustMarsh);
4588 return 0x0100 + ret;
4589 if (expected != ltVal)
4594 unsigned int ltVal = 0;
4595 ret = pfcn (arg, testVal, &lDefaultMarsh, <Val, &lI1CustMarsh, &lU1CustMarsh, &lVBCustMarsh);
4597 return 0x0300 + ret;
4598 if (expected != ltVal)
4604 ret = pfcn (arg, testVal, &lDefaultMarsh, &lBoolCustMarsh, <Val, &lU1CustMarsh, &lVBCustMarsh);
4606 return 0x0500 + ret;
4607 if (expected != ltVal)
4612 unsigned char ltVal = 0;
4613 ret = pfcn (arg, testVal, &lDefaultMarsh, &lBoolCustMarsh, &lI1CustMarsh, <Val, &lVBCustMarsh);
4615 return 0x0700 + ret;
4616 if (expected != ltVal)
4621 unsigned short ltVal = 0;
4622 ret = pfcn (arg, testVal, &lDefaultMarsh, &lBoolCustMarsh, &lI1CustMarsh, &lU1CustMarsh, <Val);
4624 return 0x0900 + ret;
4625 if (expected != ltVal)
4636 typedef int (STDCALL *MarshalBoolRefDelegate) (int arg, unsigned int expected, unsigned int testVal, unsigned int* bDefaultMarsh,
4637 unsigned int* bBoolCustMarsh, char* bI1CustMarsh, unsigned char* bU1CustMarsh, unsigned short* bVBCustMarsh);
4639 LIBTEST_API int STDCALL
4640 mono_test_managed_marshal_bool_ref (int arg, unsigned int expected, unsigned int testVal, unsigned int outExpected,
4641 unsigned int outTestVal, MarshalBoolRefDelegate pfcn)
4644 unsigned int lDefaultMarsh, lBoolCustMarsh;
4645 char lI1CustMarsh = 0;
4646 unsigned char lU1CustMarsh = 0;
4647 unsigned short lVBCustMarsh = 0;
4648 lDefaultMarsh = lBoolCustMarsh = 0;
4656 unsigned int ltestVal = testVal;
4657 ret = pfcn (arg, expected, outTestVal, <estVal, &lBoolCustMarsh, &lI1CustMarsh, &lU1CustMarsh, &lVBCustMarsh);
4659 return 0x0100 + ret;
4660 if (outExpected != ltestVal)
4666 unsigned int ltestVal = testVal;
4667 ret = pfcn (arg, expected, outTestVal, &lDefaultMarsh, <estVal, &lI1CustMarsh, &lU1CustMarsh, &lVBCustMarsh);
4669 return 0x0300 + ret;
4670 if (outExpected != ltestVal)
4676 char ltestVal = testVal;
4677 ret = pfcn (arg, expected, outTestVal, &lDefaultMarsh, &lBoolCustMarsh, <estVal, &lU1CustMarsh, &lVBCustMarsh);
4679 return 0x0500 + ret;
4680 if (outExpected != ltestVal)
4686 unsigned char ltestVal = testVal;
4687 ret = pfcn (arg, expected, outTestVal, &lDefaultMarsh, &lBoolCustMarsh, &lI1CustMarsh, <estVal, &lVBCustMarsh);
4689 return 0x0700 + ret;
4690 if (outExpected != ltestVal)
4696 unsigned short ltestVal = testVal;
4697 ret = pfcn (arg, expected, outTestVal, &lDefaultMarsh, &lBoolCustMarsh, &lI1CustMarsh, &lU1CustMarsh, <estVal);
4699 return 0x0900 + ret;
4700 if (outExpected != ltestVal)
4713 LIBTEST_API int STDCALL
4714 mono_test_marshal_safearray_out_1dim_vt_bstr_empty (SAFEARRAY** safearray)
4716 /* Create an empty one-dimensional array of variants */
4718 SAFEARRAYBOUND dimensions [1];
4720 dimensions [0].lLbound = 0;
4721 dimensions [0].cElements = 0;
4723 pSA= SafeArrayCreate (VT_VARIANT, 1, dimensions);
4728 LIBTEST_API int STDCALL
4729 mono_test_marshal_safearray_out_1dim_vt_bstr (SAFEARRAY** safearray)
4731 /* Create a one-dimensional array of 10 variants filled with "0" to "9" */
4733 SAFEARRAYBOUND dimensions [1];
4739 dimensions [0].lLbound = 0;
4740 dimensions [0].cElements = 10;
4742 pSA= SafeArrayCreate (VT_VARIANT, 1, dimensions);
4743 for (i= dimensions [0].lLbound; i< (dimensions [0].cElements + dimensions [0].lLbound); i++) {
4745 VariantInit (&vOut);
4747 _ltoa (i,buffer,10);
4748 vOut.bstrVal= marshal_bstr_alloc (buffer);
4750 if ((hr = SafeArrayPutElement (pSA, indices, &vOut)) != S_OK) {
4751 VariantClear (&vOut);
4752 SafeArrayDestroy (pSA);
4755 VariantClear (&vOut);
4761 LIBTEST_API int STDCALL
4762 mono_test_marshal_safearray_out_2dim_vt_i4 (SAFEARRAY** safearray)
4764 /* Create a two-dimensional array of 4x3 variants filled with 11, 12, 13, etc. */
4766 SAFEARRAYBOUND dimensions [2];
4771 dimensions [0].lLbound = 0;
4772 dimensions [0].cElements = 4;
4773 dimensions [1].lLbound = 0;
4774 dimensions [1].cElements = 3;
4776 pSA= SafeArrayCreate(VT_VARIANT, 2, dimensions);
4777 for (i= dimensions [0].lLbound; i< (dimensions [0].cElements + dimensions [0].lLbound); i++) {
4778 for (j= dimensions [1].lLbound; j< (dimensions [1].cElements + dimensions [1].lLbound); j++) {
4780 VariantInit (&vOut);
4782 vOut.lVal = (i+1)*10+(j+1);
4785 if ((hr = SafeArrayPutElement (pSA, indices, &vOut)) != S_OK) {
4786 VariantClear (&vOut);
4787 SafeArrayDestroy (pSA);
4790 VariantClear (&vOut); // does a deep destroy of source VARIANT
4797 LIBTEST_API int STDCALL
4798 mono_test_marshal_safearray_out_4dim_vt_i4 (SAFEARRAY** safearray)
4800 /* Create a four-dimensional array of 10x3x6x7 variants filled with their indices */
4801 /* Also use non zero lower bounds */
4803 SAFEARRAYBOUND dimensions [4];
4808 dimensions [0].lLbound = 15;
4809 dimensions [0].cElements = 10;
4810 dimensions [1].lLbound = 20;
4811 dimensions [1].cElements = 3;
4812 dimensions [2].lLbound = 5;
4813 dimensions [2].cElements = 6;
4814 dimensions [3].lLbound = 12;
4815 dimensions [3].cElements = 7;
4817 pSA= SafeArrayCreate (VT_VARIANT, 4, dimensions);
4819 SafeArrayAccessData (pSA, (void **)&pData);
4821 for (i= 0; i< 10*3*6*7; i++) {
4822 VariantInit(&pData [i]);
4823 pData [i].vt = VT_I4;
4826 SafeArrayUnaccessData (pSA);
4831 LIBTEST_API int STDCALL
4832 mono_test_marshal_safearray_in_byval_1dim_empty (SAFEARRAY* safearray)
4834 /* Check that array is one dimensional and empty */
4837 long lbound, ubound;
4839 dim = SafeArrayGetDim (safearray);
4843 SafeArrayGetLBound (safearray, 1, &lbound);
4844 SafeArrayGetUBound (safearray, 1, &ubound);
4846 if ((lbound > 0) || (ubound > 0))
4852 LIBTEST_API int STDCALL
4853 mono_test_marshal_safearray_in_byval_1dim_vt_i4 (SAFEARRAY* safearray)
4855 /* Check that array is one dimensional containing integers from 1 to 10 */
4858 long lbound, ubound;
4863 dim = SafeArrayGetDim (safearray);
4867 SafeArrayGetLBound (safearray, 1, &lbound);
4868 SafeArrayGetUBound (safearray, 1, &ubound);
4870 if ((lbound != 0) || (ubound != 9))
4873 SafeArrayAccessData (safearray, (void **)&pData);
4874 for (i= lbound; i <= ubound; i++) {
4875 if ((VariantChangeType (&pData [i], &pData [i], VARIANT_NOUSEROVERRIDE, VT_I4) != S_OK) || (pData [i].lVal != i + 1))
4878 SafeArrayUnaccessData (safearray);
4883 LIBTEST_API int STDCALL
4884 mono_test_marshal_safearray_in_byval_1dim_vt_mixed (SAFEARRAY* safearray)
4886 /* Check that array is one dimensional containing integers mixed with strings from 0 to 12 */
4889 long lbound, ubound;
4896 VariantInit (&element);
4898 dim = SafeArrayGetDim (safearray);
4902 SafeArrayGetLBound (safearray, 1, &lbound);
4903 SafeArrayGetUBound (safearray, 1, &ubound);
4905 if ((lbound != 0) || (ubound != 12))
4908 SafeArrayAccessData (safearray, (void **)&pData);
4909 for (i= lbound; i <= ubound; i++) {
4910 if ((i%2 == 0) && (pData [i].vt != VT_I4))
4912 if ((i%2 == 1) && (pData [i].vt != VT_BSTR))
4914 if ((VariantChangeType (&pData [i], &pData [i], VARIANT_NOUSEROVERRIDE, VT_I4) != S_OK) || (pData [i].lVal != i))
4917 SafeArrayUnaccessData (safearray);
4919 /* Change the first element of the array to verify that [in] parameters are not marshalled back to the managed side */
4924 SafeArrayPutElement (safearray, indices, &element);
4925 VariantClear (&element);
4930 LIBTEST_API int STDCALL
4931 mono_test_marshal_safearray_in_byval_2dim_vt_i4 (SAFEARRAY* safearray)
4933 /* Check that array is one dimensional containing integers mixed with strings from 0 to 12 */
4936 long lbound1, ubound1, lbound2, ubound2;
4941 VariantInit (&element);
4943 dim = SafeArrayGetDim (safearray);
4947 SafeArrayGetLBound (safearray, 1, &lbound1);
4948 SafeArrayGetUBound (safearray, 1, &ubound1);
4950 if ((lbound1 != 0) || (ubound1 != 1))
4953 SafeArrayGetLBound (safearray, 2, &lbound2);
4954 SafeArrayGetUBound (safearray, 2, &ubound2);
4956 if ((lbound2 != 0) || (ubound2 != 3)) {
4960 for (i= lbound1; i <= ubound1; i++) {
4962 for (j= lbound2; j <= ubound2; j++) {
4964 if (SafeArrayGetElement (safearray, indices, &element) != S_OK)
4966 failed = ((element.vt != VT_I4) || (element.lVal != 10*(i+1)+(j+1)));
4967 VariantClear (&element);
4973 /* Change the first element of the array to verify that [in] parameters are not marshalled back to the managed side */
4979 SafeArrayPutElement (safearray, indices, &element);
4980 VariantClear (&element);
4985 LIBTEST_API int STDCALL
4986 mono_test_marshal_safearray_in_byval_3dim_vt_bstr (SAFEARRAY* safearray)
4988 /* Check that array is one dimensional containing integers mixed with strings from 0 to 12 */
4991 long lbound1, ubound1, lbound2, ubound2, lbound3, ubound3;
4992 long i, j, k, failed;
4996 VariantInit (&element);
4998 dim = SafeArrayGetDim (safearray);
5002 SafeArrayGetLBound (safearray, 1, &lbound1);
5003 SafeArrayGetUBound (safearray, 1, &ubound1);
5005 if ((lbound1 != 0) || (ubound1 != 1))
5008 SafeArrayGetLBound (safearray, 2, &lbound2);
5009 SafeArrayGetUBound (safearray, 2, &ubound2);
5011 if ((lbound2 != 0) || (ubound2 != 1))
5014 SafeArrayGetLBound (safearray, 3, &lbound3);
5015 SafeArrayGetUBound (safearray, 3, &ubound3);
5017 if ((lbound3 != 0) || (ubound3 != 2))
5020 for (i= lbound1; i <= ubound1; i++) {
5022 for (j= lbound2; j <= ubound2; j++) {
5024 for (k= lbound3; k <= ubound3; k++) {
5026 if (SafeArrayGetElement (safearray, indices, &element) != S_OK)
5028 failed = ((element.vt != VT_BSTR)
5029 || (VariantChangeType (&element, &element, VARIANT_NOUSEROVERRIDE, VT_I4) != S_OK)
5030 || (element.lVal != 100*(i+1)+10*(j+1)+(k+1)));
5031 VariantClear (&element);
5038 /* Change the first element of the array to verify that [in] parameters are not marshalled back to the managed side */
5043 element.vt = VT_BSTR;
5044 element.bstrVal = SysAllocString(L"Should not be copied");
5045 SafeArrayPutElement (safearray, indices, &element);
5046 VariantClear (&element);
5051 LIBTEST_API int STDCALL
5052 mono_test_marshal_safearray_in_byref_3dim_vt_bstr (SAFEARRAY** safearray)
5054 return mono_test_marshal_safearray_in_byval_3dim_vt_bstr (*safearray);
5057 LIBTEST_API int STDCALL
5058 mono_test_marshal_safearray_in_out_byref_1dim_empty (SAFEARRAY** safearray)
5060 /* Check that the input array is what is expected and change it so the caller can check */
5061 /* correct marshalling back to managed code */
5064 long lbound, ubound;
5065 SAFEARRAYBOUND dimensions [1];
5067 wchar_t buffer [20];
5071 /* Check that in array is one dimensional and empty */
5073 dim = SafeArrayGetDim (*safearray);
5078 SafeArrayGetLBound (*safearray, 1, &lbound);
5079 SafeArrayGetUBound (*safearray, 1, &ubound);
5081 if ((lbound > 0) || (ubound > 0)) {
5085 /* Re-dimension the array and return a one-dimensional array of 8 variants filled with "0" to "7" */
5087 dimensions [0].lLbound = 0;
5088 dimensions [0].cElements = 8;
5090 hr = SafeArrayRedim (*safearray, dimensions);
5094 for (i= dimensions [0].lLbound; i< (dimensions [0].lLbound + dimensions [0].cElements); i++) {
5096 VariantInit (&vOut);
5098 _ltow (i,buffer,10);
5099 vOut.bstrVal = SysAllocString (buffer);
5101 if ((hr = SafeArrayPutElement (*safearray, indices, &vOut)) != S_OK) {
5102 VariantClear (&vOut);
5103 SafeArrayDestroy (*safearray);
5106 VariantClear (&vOut);
5111 LIBTEST_API int STDCALL
5112 mono_test_marshal_safearray_in_out_byref_3dim_vt_bstr (SAFEARRAY** safearray)
5114 /* Check that the input array is what is expected and change it so the caller can check */
5115 /* correct marshalling back to managed code */
5118 long lbound1, ubound1, lbound2, ubound2, lbound3, ubound3;
5119 SAFEARRAYBOUND dimensions [1];
5120 long i, j, k, failed;
5121 wchar_t buffer [20];
5126 VariantInit (&element);
5128 /* Check that in array is three dimensional and contains the expected values */
5130 dim = SafeArrayGetDim (*safearray);
5134 SafeArrayGetLBound (*safearray, 1, &lbound1);
5135 SafeArrayGetUBound (*safearray, 1, &ubound1);
5137 if ((lbound1 != 0) || (ubound1 != 1))
5140 SafeArrayGetLBound (*safearray, 2, &lbound2);
5141 SafeArrayGetUBound (*safearray, 2, &ubound2);
5143 if ((lbound2 != 0) || (ubound2 != 1))
5146 SafeArrayGetLBound (*safearray, 3, &lbound3);
5147 SafeArrayGetUBound (*safearray, 3, &ubound3);
5149 if ((lbound3 != 0) || (ubound3 != 2))
5152 for (i= lbound1; i <= ubound1; i++) {
5154 for (j= lbound2; j <= ubound2; j++) {
5156 for (k= lbound3; k <= ubound3; k++) {
5158 if (SafeArrayGetElement (*safearray, indices, &element) != S_OK)
5160 failed = ((element.vt != VT_BSTR)
5161 || (VariantChangeType (&element, &element, VARIANT_NOUSEROVERRIDE, VT_I4) != S_OK)
5162 || (element.lVal != 100*(i+1)+10*(j+1)+(k+1)));
5163 VariantClear (&element);
5170 hr = SafeArrayDestroy (*safearray);
5174 /* Return a new one-dimensional array of 8 variants filled with "0" to "7" */
5176 dimensions [0].lLbound = 0;
5177 dimensions [0].cElements = 8;
5179 *safearray = SafeArrayCreate (VT_VARIANT, 1, dimensions);
5181 for (i= dimensions [0].lLbound; i< (dimensions [0].lLbound + dimensions [0].cElements); i++) {
5183 VariantInit (&vOut);
5185 _ltow (i,buffer,10);
5186 vOut.bstrVal = SysAllocString (buffer);
5188 if ((hr = SafeArrayPutElement (*safearray, indices, &vOut)) != S_OK) {
5189 VariantClear (&vOut);
5190 SafeArrayDestroy (*safearray);
5193 VariantClear (&vOut);
5198 LIBTEST_API int STDCALL
5199 mono_test_marshal_safearray_in_out_byref_1dim_vt_i4 (SAFEARRAY** safearray)
5201 /* Check that the input array is what is expected and change it so the caller can check */
5202 /* correct marshalling back to managed code */
5205 long lbound1, ubound1;
5211 VariantInit (&element);
5213 /* Check that in array is one dimensional and contains the expected value */
5215 dim = SafeArrayGetDim (*safearray);
5219 SafeArrayGetLBound (*safearray, 1, &lbound1);
5220 SafeArrayGetUBound (*safearray, 1, &ubound1);
5223 if ((lbound1 != 0) || (ubound1 != 1))
5227 for (i= lbound1; i <= ubound1; i++) {
5229 if (SafeArrayGetElement (*safearray, indices, &element) != S_OK)
5231 failed = (element.vt != VT_I4) || (element.lVal != i+1);
5232 VariantClear (&element);
5237 /* Change one of the elements of the array to verify that [out] parameter is marshalled back to the managed side */
5242 SafeArrayPutElement (*safearray, indices, &element);
5243 VariantClear (&element);
5248 LIBTEST_API int STDCALL
5249 mono_test_marshal_safearray_in_out_byval_1dim_vt_i4 (SAFEARRAY* safearray)
5251 /* Check that the input array is what is expected and change it so the caller can check */
5252 /* correct marshalling back to managed code */
5255 long lbound1, ubound1;
5256 SAFEARRAYBOUND dimensions [1];
5262 VariantInit (&element);
5264 /* Check that in array is one dimensional and contains the expected value */
5266 dim = SafeArrayGetDim (safearray);
5270 SafeArrayGetLBound (safearray, 1, &lbound1);
5271 SafeArrayGetUBound (safearray, 1, &ubound1);
5273 if ((lbound1 != 0) || (ubound1 != 0))
5276 for (i= lbound1; i <= ubound1; i++) {
5278 if (SafeArrayGetElement (safearray, indices, &element) != S_OK)
5280 failed = (element.vt != VT_I4) || (element.lVal != i+1);
5281 VariantClear (&element);
5286 /* Change the array to verify how [out] parameter is marshalled back to the managed side */
5288 /* Redimension the array */
5289 dimensions [0].lLbound = lbound1;
5290 dimensions [0].cElements = 2;
5291 hr = SafeArrayRedim(safearray, dimensions);
5295 element.lVal = 12345;
5296 SafeArrayPutElement (safearray, indices, &element);
5297 VariantClear (&element);
5301 element.lVal = -12345;
5302 SafeArrayPutElement (safearray, indices, &element);
5303 VariantClear (&element);
5308 LIBTEST_API int STDCALL
5309 mono_test_marshal_safearray_in_out_byval_3dim_vt_bstr (SAFEARRAY* safearray)
5311 /* Check that the input array is what is expected and change it so the caller can check */
5312 /* correct marshalling back to managed code */
5315 long lbound1, ubound1, lbound2, ubound2, lbound3, ubound3;
5316 long i, j, k, failed;
5321 VariantInit (&element);
5323 /* Check that in array is three dimensional and contains the expected values */
5325 dim = SafeArrayGetDim (safearray);
5329 SafeArrayGetLBound (safearray, 1, &lbound1);
5330 SafeArrayGetUBound (safearray, 1, &ubound1);
5332 if ((lbound1 != 0) || (ubound1 != 1))
5335 SafeArrayGetLBound (safearray, 2, &lbound2);
5336 SafeArrayGetUBound (safearray, 2, &ubound2);
5338 if ((lbound2 != 0) || (ubound2 != 1))
5341 SafeArrayGetLBound (safearray, 3, &lbound3);
5342 SafeArrayGetUBound (safearray, 3, &ubound3);
5344 if ((lbound3 != 0) || (ubound3 != 2))
5347 for (i= lbound1; i <= ubound1; i++) {
5349 for (j= lbound2; j <= ubound2; j++) {
5351 for (k= lbound3; k <= ubound3; k++) {
5353 if (SafeArrayGetElement (safearray, indices, &element) != S_OK)
5355 failed = ((element.vt != VT_BSTR)
5356 || (VariantChangeType (&element, &element, VARIANT_NOUSEROVERRIDE, VT_I4) != S_OK)
5357 || (element.lVal != 100*(i+1)+10*(j+1)+(k+1)));
5358 VariantClear (&element);
5365 /* Change the elements of the array to verify that [out] parameter is marshalled back to the managed side */
5372 SafeArrayPutElement (safearray, indices, &element);
5373 VariantClear (&element);
5380 SafeArrayPutElement (safearray, indices, &element);
5381 VariantClear (&element);
5386 element.vt = VT_BSTR;
5387 element.bstrVal = marshal_bstr_alloc("ABCDEFG");
5388 SafeArrayPutElement (safearray, indices, &element);
5389 VariantClear (&element);
5394 LIBTEST_API int STDCALL
5395 mono_test_marshal_safearray_mixed(
5396 SAFEARRAY *safearray1,
5397 SAFEARRAY **safearray2,
5398 SAFEARRAY *safearray3,
5399 SAFEARRAY **safearray4
5404 /* Initialize out parameters */
5407 /* array1: Check that in array is one dimensional and contains the expected value */
5408 hr = mono_test_marshal_safearray_in_out_byval_1dim_vt_i4 (safearray1);
5410 /* array2: Fill in with some values to check on the managed side */
5412 hr = mono_test_marshal_safearray_out_1dim_vt_bstr (safearray2);
5414 /* array3: Check that in array is one dimensional and contains the expected value */
5416 hr = mono_test_marshal_safearray_in_byval_1dim_vt_mixed(safearray3);
5418 /* array4: Check input values and fill in with some values to check on the managed side */
5420 hr = mono_test_marshal_safearray_in_out_byref_3dim_vt_bstr(safearray4);
5427 static int call_managed_res;
5430 call_managed (gpointer arg)
5432 SimpleDelegate del = (SimpleDelegate)arg;
5434 call_managed_res = del (42);
5437 LIBTEST_API int STDCALL
5438 mono_test_marshal_thread_attach (SimpleDelegate del)
5446 res = pthread_create (&t, NULL, (gpointer (*)(gpointer))call_managed, del);
5447 g_assert (res == 0);
5448 pthread_join (t, NULL);
5450 return call_managed_res;
5454 typedef int (STDCALL *Callback) (void);
5456 static Callback callback;
5458 LIBTEST_API void STDCALL
5459 mono_test_marshal_set_callback (Callback cb)
5464 LIBTEST_API int STDCALL
5465 mono_test_marshal_call_callback (void)
5470 LIBTEST_API int STDCALL
5471 mono_test_marshal_lpstr (char *str)
5473 return strcmp ("ABC", str);
5476 LIBTEST_API int STDCALL
5477 mono_test_marshal_lpwstr (gunichar2 *str)
5482 s = g_utf16_to_utf8 (str, -1, NULL, NULL, NULL);
5483 res = strcmp ("ABC", s);
5489 LIBTEST_API char* STDCALL
5490 mono_test_marshal_return_lpstr (void)
5492 char *res = (char *)marshal_alloc (4);
5493 strcpy (res, "XYZ");
5498 LIBTEST_API gunichar2* STDCALL
5499 mono_test_marshal_return_lpwstr (void)
5501 gunichar2 *res = (gunichar2 *)marshal_alloc (8);
5502 gunichar2* tmp = g_utf8_to_utf16 ("XYZ", -1, NULL, NULL, NULL);
5504 memcpy (res, tmp, 8);
5512 } SingleDoubleStruct;
5514 LIBTEST_API SingleDoubleStruct STDCALL
5515 mono_test_marshal_return_single_double_struct (void)
5517 SingleDoubleStruct res;
5527 LIBTEST_API int STDCALL
5528 mono_test_has_thiscall (void)
5534 _mono_test_native_thiscall1 (int arg)
5540 _mono_test_native_thiscall2 (int arg, int arg2)
5542 return arg + (arg2^1);
5546 _mono_test_native_thiscall3 (int arg, int arg2, int arg3)
5548 return arg + (arg2^1) + (arg3^2);
5551 #elif defined(__GNUC__)
5553 LIBTEST_API int STDCALL
5554 mono_test_has_thiscall (void)
5559 #define def_asm_fn(name) \
5561 "\t.globl _" #name "\n" \
5563 "\t.globl __" #name "\n" \
5568 def_asm_fn(mono_test_native_thiscall1)
5569 "\tmovl %ecx,%eax\n"
5572 def_asm_fn(mono_test_native_thiscall2)
5573 "\tmovl %ecx,%eax\n"
5574 "\tmovl 4(%esp),%ecx\n"
5576 "\taddl %ecx,%eax\n"
5579 def_asm_fn(mono_test_native_thiscall3)
5580 "\tmovl %ecx,%eax\n"
5581 "\tmovl 4(%esp),%ecx\n"
5583 "\taddl %ecx,%eax\n"
5584 "\tmovl 8(%esp),%ecx\n"
5586 "\taddl %ecx,%eax\n"
5593 LIBTEST_API int STDCALL
5594 mono_test_has_thiscall (void)
5606 LIBTEST_API sbyte1 STDCALL
5607 mono_return_sbyte1 (sbyte1 s1, int addend) {
5609 fprintf(stderr, "mono_return_sbyte1 s1.f1: got %d but expected %d\n", s1.f1, 1);
5619 LIBTEST_API sbyte2 STDCALL
5620 mono_return_sbyte2 (sbyte2 s2, int addend) {
5622 fprintf(stderr, "mono_return_sbyte2 s2.f1: got %d but expected %d\n", s2.f1, 1);
5625 fprintf(stderr, "mono_return_sbyte2 s2.f2: got %d but expected %d\n", s2.f2, 2);
5627 s2.f1+=addend; s2.f2+=addend;
5635 LIBTEST_API sbyte3 STDCALL
5636 mono_return_sbyte3 (sbyte3 s3, int addend) {
5638 fprintf(stderr, "mono_return_sbyte3 s3.f1: got %d but expected %d\n", s3.f1, 1);
5641 fprintf(stderr, "mono_return_sbyte3 s3.f2: got %d but expected %d\n", s3.f2, 2);
5644 fprintf(stderr, "mono_return_sbyte3 s3.f3: got %d but expected %d\n", s3.f3, 3);
5646 s3.f1+=addend; s3.f2+=addend; s3.f3+=addend;
5654 LIBTEST_API sbyte4 STDCALL
5655 mono_return_sbyte4 (sbyte4 s4, int addend) {
5657 fprintf(stderr, "mono_return_sbyte4 s4.f1: got %d but expected %d\n", s4.f1, 1);
5660 fprintf(stderr, "mono_return_sbyte4 s4.f2: got %d but expected %d\n", s4.f2, 2);
5663 fprintf(stderr, "mono_return_sbyte4 s4.f3: got %d but expected %d\n", s4.f3, 3);
5666 fprintf(stderr, "mono_return_sbyte4 s4.f4: got %d but expected %d\n", s4.f4, 4);
5668 s4.f1+=addend; s4.f2+=addend; s4.f3+=addend; s4.f4+=addend;
5673 char f1,f2,f3,f4,f5;
5676 LIBTEST_API sbyte5 STDCALL
5677 mono_return_sbyte5 (sbyte5 s5, int addend) {
5679 fprintf(stderr, "mono_return_sbyte5 s5.f1: got %d but expected %d\n", s5.f1, 1);
5682 fprintf(stderr, "mono_return_sbyte5 s5.f2: got %d but expected %d\n", s5.f2, 2);
5685 fprintf(stderr, "mono_return_sbyte5 s5.f3: got %d but expected %d\n", s5.f3, 3);
5688 fprintf(stderr, "mono_return_sbyte5 s5.f4: got %d but expected %d\n", s5.f4, 4);
5691 fprintf(stderr, "mono_return_sbyte5 s5.f5: got %d but expected %d\n", s5.f5, 5);
5693 s5.f1+=addend; s5.f2+=addend; s5.f3+=addend; s5.f4+=addend; s5.f5+=addend;
5698 char f1,f2,f3,f4,f5,f6;
5701 LIBTEST_API sbyte6 STDCALL
5702 mono_return_sbyte6 (sbyte6 s6, int addend) {
5704 fprintf(stderr, "mono_return_sbyte6 s6.f1: got %d but expected %d\n", s6.f1, 1);
5707 fprintf(stderr, "mono_return_sbyte6 s6.f2: got %d but expected %d\n", s6.f2, 2);
5710 fprintf(stderr, "mono_return_sbyte6 s6.f3: got %d but expected %d\n", s6.f3, 3);
5713 fprintf(stderr, "mono_return_sbyte6 s6.f4: got %d but expected %d\n", s6.f4, 4);
5716 fprintf(stderr, "mono_return_sbyte6 s6.f5: got %d but expected %d\n", s6.f5, 5);
5719 fprintf(stderr, "mono_return_sbyte6 s6.f6: got %d but expected %d\n", s6.f6, 6);
5721 s6.f1+=addend; s6.f2+=addend; s6.f3+=addend; s6.f4+=addend; s6.f5+=addend; s6.f6+=addend;
5726 char f1,f2,f3,f4,f5,f6,f7;
5729 LIBTEST_API sbyte7 STDCALL
5730 mono_return_sbyte7 (sbyte7 s7, int addend) {
5732 fprintf(stderr, "mono_return_sbyte7 s7.f1: got %d but expected %d\n", s7.f1, 1);
5735 fprintf(stderr, "mono_return_sbyte7 s7.f2: got %d but expected %d\n", s7.f2, 2);
5738 fprintf(stderr, "mono_return_sbyte7 s7.f3: got %d but expected %d\n", s7.f3, 3);
5741 fprintf(stderr, "mono_return_sbyte7 s7.f4: got %d but expected %d\n", s7.f4, 4);
5744 fprintf(stderr, "mono_return_sbyte7 s7.f5: got %d but expected %d\n", s7.f5, 5);
5747 fprintf(stderr, "mono_return_sbyte7 s7.f6: got %d but expected %d\n", s7.f6, 6);
5750 fprintf(stderr, "mono_return_sbyte7 s7.f7: got %d but expected %d\n", s7.f7, 7);
5752 s7.f1+=addend; s7.f2+=addend; s7.f3+=addend; s7.f4+=addend; s7.f5+=addend; s7.f6+=addend; s7.f7+=addend;
5757 char f1,f2,f3,f4,f5,f6,f7,f8;
5760 LIBTEST_API sbyte8 STDCALL
5761 mono_return_sbyte8 (sbyte8 s8, int addend) {
5763 fprintf(stderr, "mono_return_sbyte8 s8.f1: got %d but expected %d\n", s8.f1, 1);
5766 fprintf(stderr, "mono_return_sbyte8 s8.f2: got %d but expected %d\n", s8.f2, 2);
5769 fprintf(stderr, "mono_return_sbyte8 s8.f3: got %d but expected %d\n", s8.f3, 3);
5772 fprintf(stderr, "mono_return_sbyte8 s8.f4: got %d but expected %d\n", s8.f4, 4);
5775 fprintf(stderr, "mono_return_sbyte8 s8.f5: got %d but expected %d\n", s8.f5, 5);
5778 fprintf(stderr, "mono_return_sbyte8 s8.f6: got %d but expected %d\n", s8.f6, 6);
5781 fprintf(stderr, "mono_return_sbyte8 s8.f7: got %d but expected %d\n", s8.f7, 7);
5784 fprintf(stderr, "mono_return_sbyte8 s8.f8: got %d but expected %d\n", s8.f8, 8);
5786 s8.f1+=addend; s8.f2+=addend; s8.f3+=addend; s8.f4+=addend; s8.f5+=addend; s8.f6+=addend; s8.f7+=addend; s8.f8+=addend;
5791 char f1,f2,f3,f4,f5,f6,f7,f8,f9;
5794 LIBTEST_API sbyte9 STDCALL
5795 mono_return_sbyte9 (sbyte9 s9, int addend) {
5797 fprintf(stderr, "mono_return_sbyte9 s9.f1: got %d but expected %d\n", s9.f1, 1);
5800 fprintf(stderr, "mono_return_sbyte9 s9.f2: got %d but expected %d\n", s9.f2, 2);
5803 fprintf(stderr, "mono_return_sbyte9 s9.f3: got %d but expected %d\n", s9.f3, 3);
5806 fprintf(stderr, "mono_return_sbyte9 s9.f4: got %d but expected %d\n", s9.f4, 4);
5809 fprintf(stderr, "mono_return_sbyte9 s9.f5: got %d but expected %d\n", s9.f5, 5);
5812 fprintf(stderr, "mono_return_sbyte9 s9.f6: got %d but expected %d\n", s9.f6, 6);
5815 fprintf(stderr, "mono_return_sbyte9 s9.f7: got %d but expected %d\n", s9.f7, 7);
5818 fprintf(stderr, "mono_return_sbyte9 s9.f8: got %d but expected %d\n", s9.f8, 8);
5821 fprintf(stderr, "mono_return_sbyte9 s9.f9: got %d but expected %d\n", s9.f9, 9);
5823 s9.f1+=addend; s9.f2+=addend; s9.f3+=addend; s9.f4+=addend; s9.f5+=addend; s9.f6+=addend; s9.f7+=addend; s9.f8+=addend; s9.f9+=addend;
5828 char f1,f2,f3,f4,f5,f6,f7,f8,f9,f10;
5831 LIBTEST_API sbyte10 STDCALL
5832 mono_return_sbyte10 (sbyte10 s10, int addend) {
5834 fprintf(stderr, "mono_return_sbyte10 s10.f1: got %d but expected %d\n", s10.f1, 1);
5837 fprintf(stderr, "mono_return_sbyte10 s10.f2: got %d but expected %d\n", s10.f2, 2);
5840 fprintf(stderr, "mono_return_sbyte10 s10.f3: got %d but expected %d\n", s10.f3, 3);
5843 fprintf(stderr, "mono_return_sbyte10 s10.f4: got %d but expected %d\n", s10.f4, 4);
5846 fprintf(stderr, "mono_return_sbyte10 s10.f5: got %d but expected %d\n", s10.f5, 5);
5849 fprintf(stderr, "mono_return_sbyte10 s10.f6: got %d but expected %d\n", s10.f6, 6);
5852 fprintf(stderr, "mono_return_sbyte10 s10.f7: got %d but expected %d\n", s10.f7, 7);
5855 fprintf(stderr, "mono_return_sbyte10 s10.f8: got %d but expected %d\n", s10.f8, 8);
5858 fprintf(stderr, "mono_return_sbyte10 s10.f9: got %d but expected %d\n", s10.f9, 9);
5860 if (s10.f10 != 10) {
5861 fprintf(stderr, "mono_return_sbyte10 s10.f10: got %d but expected %d\n", s10.f10, 10);
5863 s10.f1+=addend; s10.f2+=addend; s10.f3+=addend; s10.f4+=addend; s10.f5+=addend; s10.f6+=addend; s10.f7+=addend; s10.f8+=addend; s10.f9+=addend; s10.f10+=addend;
5868 char f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11;
5871 LIBTEST_API sbyte11 STDCALL
5872 mono_return_sbyte11 (sbyte11 s11, int addend) {
5874 fprintf(stderr, "mono_return_sbyte11 s11.f1: got %d but expected %d\n", s11.f1, 1);
5877 fprintf(stderr, "mono_return_sbyte11 s11.f2: got %d but expected %d\n", s11.f2, 2);
5880 fprintf(stderr, "mono_return_sbyte11 s11.f3: got %d but expected %d\n", s11.f3, 3);
5883 fprintf(stderr, "mono_return_sbyte11 s11.f4: got %d but expected %d\n", s11.f4, 4);
5886 fprintf(stderr, "mono_return_sbyte11 s11.f5: got %d but expected %d\n", s11.f5, 5);
5889 fprintf(stderr, "mono_return_sbyte11 s11.f6: got %d but expected %d\n", s11.f6, 6);
5892 fprintf(stderr, "mono_return_sbyte11 s11.f7: got %d but expected %d\n", s11.f7, 7);
5895 fprintf(stderr, "mono_return_sbyte11 s11.f8: got %d but expected %d\n", s11.f8, 8);
5898 fprintf(stderr, "mono_return_sbyte11 s11.f9: got %d but expected %d\n", s11.f9, 9);
5900 if (s11.f10 != 10) {
5901 fprintf(stderr, "mono_return_sbyte11 s11.f10: got %d but expected %d\n", s11.f10, 10);
5903 if (s11.f11 != 11) {
5904 fprintf(stderr, "mono_return_sbyte11 s11.f11: got %d but expected %d\n", s11.f11, 11);
5906 s11.f1+=addend; s11.f2+=addend; s11.f3+=addend; s11.f4+=addend; s11.f5+=addend; s11.f6+=addend; s11.f7+=addend; s11.f8+=addend; s11.f9+=addend; s11.f10+=addend; s11.f11+=addend;
5911 char f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12;
5914 LIBTEST_API sbyte12 STDCALL
5915 mono_return_sbyte12 (sbyte12 s12, int addend) {
5917 fprintf(stderr, "mono_return_sbyte12 s12.f1: got %d but expected %d\n", s12.f1, 1);
5920 fprintf(stderr, "mono_return_sbyte12 s12.f2: got %d but expected %d\n", s12.f2, 2);
5923 fprintf(stderr, "mono_return_sbyte12 s12.f3: got %d but expected %d\n", s12.f3, 3);
5926 fprintf(stderr, "mono_return_sbyte12 s12.f4: got %d but expected %d\n", s12.f4, 4);
5929 fprintf(stderr, "mono_return_sbyte12 s12.f5: got %d but expected %d\n", s12.f5, 5);
5932 fprintf(stderr, "mono_return_sbyte12 s12.f6: got %d but expected %d\n", s12.f6, 6);
5935 fprintf(stderr, "mono_return_sbyte12 s12.f7: got %d but expected %d\n", s12.f7, 7);
5938 fprintf(stderr, "mono_return_sbyte12 s12.f8: got %d but expected %d\n", s12.f8, 8);
5941 fprintf(stderr, "mono_return_sbyte12 s12.f9: got %d but expected %d\n", s12.f9, 9);
5943 if (s12.f10 != 10) {
5944 fprintf(stderr, "mono_return_sbyte12 s12.f10: got %d but expected %d\n", s12.f10, 10);
5946 if (s12.f11 != 11) {
5947 fprintf(stderr, "mono_return_sbyte12 s12.f11: got %d but expected %d\n", s12.f11, 11);
5949 if (s12.f12 != 12) {
5950 fprintf(stderr, "mono_return_sbyte12 s12.f12: got %d but expected %d\n", s12.f12, 12);
5952 s12.f1+=addend; s12.f2+=addend; s12.f3+=addend; s12.f4+=addend; s12.f5+=addend; s12.f6+=addend; s12.f7+=addend; s12.f8+=addend; s12.f9+=addend; s12.f10+=addend; s12.f11+=addend; s12.f12+=addend;
5957 char f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13;
5960 LIBTEST_API sbyte13 STDCALL
5961 mono_return_sbyte13 (sbyte13 s13, int addend) {
5963 fprintf(stderr, "mono_return_sbyte13 s13.f1: got %d but expected %d\n", s13.f1, 1);
5966 fprintf(stderr, "mono_return_sbyte13 s13.f2: got %d but expected %d\n", s13.f2, 2);
5969 fprintf(stderr, "mono_return_sbyte13 s13.f3: got %d but expected %d\n", s13.f3, 3);
5972 fprintf(stderr, "mono_return_sbyte13 s13.f4: got %d but expected %d\n", s13.f4, 4);
5975 fprintf(stderr, "mono_return_sbyte13 s13.f5: got %d but expected %d\n", s13.f5, 5);
5978 fprintf(stderr, "mono_return_sbyte13 s13.f6: got %d but expected %d\n", s13.f6, 6);
5981 fprintf(stderr, "mono_return_sbyte13 s13.f7: got %d but expected %d\n", s13.f7, 7);
5984 fprintf(stderr, "mono_return_sbyte13 s13.f8: got %d but expected %d\n", s13.f8, 8);
5987 fprintf(stderr, "mono_return_sbyte13 s13.f9: got %d but expected %d\n", s13.f9, 9);
5989 if (s13.f10 != 10) {
5990 fprintf(stderr, "mono_return_sbyte13 s13.f10: got %d but expected %d\n", s13.f10, 10);
5992 if (s13.f11 != 11) {
5993 fprintf(stderr, "mono_return_sbyte13 s13.f11: got %d but expected %d\n", s13.f11, 11);
5995 if (s13.f12 != 12) {
5996 fprintf(stderr, "mono_return_sbyte13 s13.f12: got %d but expected %d\n", s13.f12, 12);
5998 if (s13.f13 != 13) {
5999 fprintf(stderr, "mono_return_sbyte13 s13.f13: got %d but expected %d\n", s13.f13, 13);
6001 s13.f1+=addend; s13.f2+=addend; s13.f3+=addend; s13.f4+=addend; s13.f5+=addend; s13.f6+=addend; s13.f7+=addend; s13.f8+=addend; s13.f9+=addend; s13.f10+=addend; s13.f11+=addend; s13.f12+=addend; s13.f13+=addend;
6006 char f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14;
6009 LIBTEST_API sbyte14 STDCALL
6010 mono_return_sbyte14 (sbyte14 s14, int addend) {
6012 fprintf(stderr, "mono_return_sbyte14 s14.f1: got %d but expected %d\n", s14.f1, 1);
6015 fprintf(stderr, "mono_return_sbyte14 s14.f2: got %d but expected %d\n", s14.f2, 2);
6018 fprintf(stderr, "mono_return_sbyte14 s14.f3: got %d but expected %d\n", s14.f3, 3);
6021 fprintf(stderr, "mono_return_sbyte14 s14.f4: got %d but expected %d\n", s14.f4, 4);
6024 fprintf(stderr, "mono_return_sbyte14 s14.f5: got %d but expected %d\n", s14.f5, 5);
6027 fprintf(stderr, "mono_return_sbyte14 s14.f6: got %d but expected %d\n", s14.f6, 6);
6030 fprintf(stderr, "mono_return_sbyte14 s14.f7: got %d but expected %d\n", s14.f7, 7);
6033 fprintf(stderr, "mono_return_sbyte14 s14.f8: got %d but expected %d\n", s14.f8, 8);
6036 fprintf(stderr, "mono_return_sbyte14 s14.f9: got %d but expected %d\n", s14.f9, 9);
6038 if (s14.f10 != 10) {
6039 fprintf(stderr, "mono_return_sbyte14 s14.f10: got %d but expected %d\n", s14.f10, 10);
6041 if (s14.f11 != 11) {
6042 fprintf(stderr, "mono_return_sbyte14 s14.f11: got %d but expected %d\n", s14.f11, 11);
6044 if (s14.f12 != 12) {
6045 fprintf(stderr, "mono_return_sbyte14 s14.f12: got %d but expected %d\n", s14.f12, 12);
6047 if (s14.f13 != 13) {
6048 fprintf(stderr, "mono_return_sbyte14 s14.f13: got %d but expected %d\n", s14.f13, 13);
6050 if (s14.f14 != 14) {
6051 fprintf(stderr, "mono_return_sbyte14 s14.f14: got %d but expected %d\n", s14.f14, 14);
6053 s14.f1+=addend; s14.f2+=addend; s14.f3+=addend; s14.f4+=addend; s14.f5+=addend; s14.f6+=addend; s14.f7+=addend; s14.f8+=addend; s14.f9+=addend; s14.f10+=addend; s14.f11+=addend; s14.f12+=addend; s14.f13+=addend; s14.f14+=addend;
6058 char f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15;
6061 LIBTEST_API sbyte15 STDCALL
6062 mono_return_sbyte15 (sbyte15 s15, int addend) {
6064 fprintf(stderr, "mono_return_sbyte15 s15.f1: got %d but expected %d\n", s15.f1, 1);
6067 fprintf(stderr, "mono_return_sbyte15 s15.f2: got %d but expected %d\n", s15.f2, 2);
6070 fprintf(stderr, "mono_return_sbyte15 s15.f3: got %d but expected %d\n", s15.f3, 3);
6073 fprintf(stderr, "mono_return_sbyte15 s15.f4: got %d but expected %d\n", s15.f4, 4);
6076 fprintf(stderr, "mono_return_sbyte15 s15.f5: got %d but expected %d\n", s15.f5, 5);
6079 fprintf(stderr, "mono_return_sbyte15 s15.f6: got %d but expected %d\n", s15.f6, 6);
6082 fprintf(stderr, "mono_return_sbyte15 s15.f7: got %d but expected %d\n", s15.f7, 7);
6085 fprintf(stderr, "mono_return_sbyte15 s15.f8: got %d but expected %d\n", s15.f8, 8);
6088 fprintf(stderr, "mono_return_sbyte15 s15.f9: got %d but expected %d\n", s15.f9, 9);
6090 if (s15.f10 != 10) {
6091 fprintf(stderr, "mono_return_sbyte15 s15.f10: got %d but expected %d\n", s15.f10, 10);
6093 if (s15.f11 != 11) {
6094 fprintf(stderr, "mono_return_sbyte15 s15.f11: got %d but expected %d\n", s15.f11, 11);
6096 if (s15.f12 != 12) {
6097 fprintf(stderr, "mono_return_sbyte15 s15.f12: got %d but expected %d\n", s15.f12, 12);
6099 if (s15.f13 != 13) {
6100 fprintf(stderr, "mono_return_sbyte15 s15.f13: got %d but expected %d\n", s15.f13, 13);
6102 if (s15.f14 != 14) {
6103 fprintf(stderr, "mono_return_sbyte15 s15.f14: got %d but expected %d\n", s15.f14, 14);
6105 if (s15.f15 != 15) {
6106 fprintf(stderr, "mono_return_sbyte15 s15.f15: got %d but expected %d\n", s15.f15, 15);
6108 s15.f1+=addend; s15.f2+=addend; s15.f3+=addend; s15.f4+=addend; s15.f5+=addend; s15.f6+=addend; s15.f7+=addend; s15.f8+=addend; s15.f9+=addend; s15.f10+=addend; s15.f11+=addend; s15.f12+=addend; s15.f13+=addend; s15.f14+=addend; s15.f15+=addend;
6113 char f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15,f16;
6116 LIBTEST_API sbyte16 STDCALL
6117 mono_return_sbyte16 (sbyte16 s16, int addend) {
6119 fprintf(stderr, "mono_return_sbyte16 s16.f1: got %d but expected %d\n", s16.f1, 1);
6122 fprintf(stderr, "mono_return_sbyte16 s16.f2: got %d but expected %d\n", s16.f2, 2);
6125 fprintf(stderr, "mono_return_sbyte16 s16.f3: got %d but expected %d\n", s16.f3, 3);
6128 fprintf(stderr, "mono_return_sbyte16 s16.f4: got %d but expected %d\n", s16.f4, 4);
6131 fprintf(stderr, "mono_return_sbyte16 s16.f5: got %d but expected %d\n", s16.f5, 5);
6134 fprintf(stderr, "mono_return_sbyte16 s16.f6: got %d but expected %d\n", s16.f6, 6);
6137 fprintf(stderr, "mono_return_sbyte16 s16.f7: got %d but expected %d\n", s16.f7, 7);
6140 fprintf(stderr, "mono_return_sbyte16 s16.f8: got %d but expected %d\n", s16.f8, 8);
6143 fprintf(stderr, "mono_return_sbyte16 s16.f9: got %d but expected %d\n", s16.f9, 9);
6145 if (s16.f10 != 10) {
6146 fprintf(stderr, "mono_return_sbyte16 s16.f10: got %d but expected %d\n", s16.f10, 10);
6148 if (s16.f11 != 11) {
6149 fprintf(stderr, "mono_return_sbyte16 s16.f11: got %d but expected %d\n", s16.f11, 11);
6151 if (s16.f12 != 12) {
6152 fprintf(stderr, "mono_return_sbyte16 s16.f12: got %d but expected %d\n", s16.f12, 12);
6154 if (s16.f13 != 13) {
6155 fprintf(stderr, "mono_return_sbyte16 s16.f13: got %d but expected %d\n", s16.f13, 13);
6157 if (s16.f14 != 14) {
6158 fprintf(stderr, "mono_return_sbyte16 s16.f14: got %d but expected %d\n", s16.f14, 14);
6160 if (s16.f15 != 15) {
6161 fprintf(stderr, "mono_return_sbyte16 s16.f15: got %d but expected %d\n", s16.f15, 15);
6163 if (s16.f16 != 16) {
6164 fprintf(stderr, "mono_return_sbyte16 s16.f16: got %d but expected %d\n", s16.f16, 16);
6166 s16.f1+=addend; s16.f2+=addend; s16.f3+=addend; s16.f4+=addend; s16.f5+=addend; s16.f6+=addend; s16.f7+=addend; s16.f8+=addend; s16.f9+=addend; s16.f10+=addend; s16.f11+=addend; s16.f12+=addend; s16.f13+=addend; s16.f14+=addend; s16.f15+=addend; s16.f16+=addend;
6171 char f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15,f16,f17;
6174 LIBTEST_API sbyte17 STDCALL
6175 mono_return_sbyte17 (sbyte17 s17, int addend) {
6177 fprintf(stderr, "mono_return_sbyte17 s17.f1: got %d but expected %d\n", s17.f1, 1);
6180 fprintf(stderr, "mono_return_sbyte17 s17.f2: got %d but expected %d\n", s17.f2, 2);
6183 fprintf(stderr, "mono_return_sbyte17 s17.f3: got %d but expected %d\n", s17.f3, 3);
6186 fprintf(stderr, "mono_return_sbyte17 s17.f4: got %d but expected %d\n", s17.f4, 4);
6189 fprintf(stderr, "mono_return_sbyte17 s17.f5: got %d but expected %d\n", s17.f5, 5);
6192 fprintf(stderr, "mono_return_sbyte17 s17.f6: got %d but expected %d\n", s17.f6, 6);
6195 fprintf(stderr, "mono_return_sbyte17 s17.f7: got %d but expected %d\n", s17.f7, 7);
6198 fprintf(stderr, "mono_return_sbyte17 s17.f8: got %d but expected %d\n", s17.f8, 8);
6201 fprintf(stderr, "mono_return_sbyte17 s17.f9: got %d but expected %d\n", s17.f9, 9);
6203 if (s17.f10 != 10) {
6204 fprintf(stderr, "mono_return_sbyte17 s17.f10: got %d but expected %d\n", s17.f10, 10);
6206 if (s17.f11 != 11) {
6207 fprintf(stderr, "mono_return_sbyte17 s17.f11: got %d but expected %d\n", s17.f11, 11);
6209 if (s17.f12 != 12) {
6210 fprintf(stderr, "mono_return_sbyte17 s17.f12: got %d but expected %d\n", s17.f12, 12);
6212 if (s17.f13 != 13) {
6213 fprintf(stderr, "mono_return_sbyte17 s17.f13: got %d but expected %d\n", s17.f13, 13);
6215 if (s17.f14 != 14) {
6216 fprintf(stderr, "mono_return_sbyte17 s17.f14: got %d but expected %d\n", s17.f14, 14);
6218 if (s17.f15 != 15) {
6219 fprintf(stderr, "mono_return_sbyte17 s17.f15: got %d but expected %d\n", s17.f15, 15);
6221 if (s17.f16 != 16) {
6222 fprintf(stderr, "mono_return_sbyte17 s17.f16: got %d but expected %d\n", s17.f16, 16);
6224 if (s17.f17 != 17) {
6225 fprintf(stderr, "mono_return_sbyte17 s17.f17: got %d but expected %d\n", s17.f17, 17);
6227 s17.f1+=addend; s17.f2+=addend; s17.f3+=addend; s17.f4+=addend; s17.f5+=addend; s17.f6+=addend; s17.f7+=addend; s17.f8+=addend; s17.f9+=addend; s17.f10+=addend; s17.f11+=addend; s17.f12+=addend; s17.f13+=addend; s17.f14+=addend; s17.f15+=addend; s17.f16+=addend; s17.f17+=addend;
6235 char f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15;
6241 LIBTEST_API sbyte16_nested STDCALL
6242 mono_return_sbyte16_nested (sbyte16_nested sn16, int addend) {
6243 if (sn16.nested1.f1 != 1) {
6244 fprintf(stderr, "mono_return_sbyte16_nested sn16.nested1.f1: got %d but expected %d\n", sn16.nested1.f1, 1);
6247 fprintf(stderr, "mono_return_sbyte16_nested sn16.f2: got %d but expected %d\n", sn16.f2, 2);
6250 fprintf(stderr, "mono_return_sbyte16_nested sn16.f3: got %d but expected %d\n", sn16.f3, 3);
6253 fprintf(stderr, "mono_return_sbyte16_nested sn16.f4: got %d but expected %d\n", sn16.f4, 4);
6256 fprintf(stderr, "mono_return_sbyte16_nested sn16.f5: got %d but expected %d\n", sn16.f5, 5);
6259 fprintf(stderr, "mono_return_sbyte16_nested sn16.f6: got %d but expected %d\n", sn16.f6, 6);
6262 fprintf(stderr, "mono_return_sbyte16_nested sn16.f7: got %d but expected %d\n", sn16.f7, 7);
6265 fprintf(stderr, "mono_return_sbyte16_nested sn16.f8: got %d but expected %d\n", sn16.f8, 8);
6268 fprintf(stderr, "mono_return_sbyte16_nested sn16.f9: got %d but expected %d\n", sn16.f9, 9);
6270 if (sn16.f10 != 10) {
6271 fprintf(stderr, "mono_return_sbyte16_nested sn16.f10: got %d but expected %d\n", sn16.f10, 10);
6273 if (sn16.f11 != 11) {
6274 fprintf(stderr, "mono_return_sbyte16_nested sn16.f11: got %d but expected %d\n", sn16.f11, 11);
6276 if (sn16.f12 != 12) {
6277 fprintf(stderr, "mono_return_sbyte16_nested sn16.f12: got %d but expected %d\n", sn16.f12, 12);
6279 if (sn16.f13 != 13) {
6280 fprintf(stderr, "mono_return_sbyte16_nested sn16.f13: got %d but expected %d\n", sn16.f13, 13);
6282 if (sn16.f14 != 14) {
6283 fprintf(stderr, "mono_return_sbyte16_nested sn16.f14: got %d but expected %d\n", sn16.f14, 14);
6285 if (sn16.f15 != 15) {
6286 fprintf(stderr, "mono_return_sbyte16_nested sn16.f15: got %d but expected %d\n", sn16.f15, 15);
6288 if (sn16.nested2.f16 != 16) {
6289 fprintf(stderr, "mono_return_sbyte16_nested sn16.nested2.f16: got %d but expected %d\n", sn16.nested2.f16, 16);
6291 sn16.nested1.f1+=addend; sn16.f2+=addend; sn16.f3+=addend; sn16.f4+=addend; sn16.f5+=addend; sn16.f6+=addend; sn16.f7+=addend; sn16.f8+=addend; sn16.f9+=addend; sn16.f10+=addend; sn16.f11+=addend; sn16.f12+=addend; sn16.f13+=addend; sn16.f14+=addend; sn16.f15+=addend; sn16.nested2.f16+=addend;
6300 LIBTEST_API short1 STDCALL
6301 mono_return_short1 (short1 s1, int addend) {
6303 fprintf(stderr, "mono_return_short1 s1.f1: got %d but expected %d\n", s1.f1, 1);
6313 LIBTEST_API short2 STDCALL
6314 mono_return_short2 (short2 s2, int addend) {
6316 fprintf(stderr, "mono_return_short2 s2.f1: got %d but expected %d\n", s2.f1, 1);
6319 fprintf(stderr, "mono_return_short2 s2.f2: got %d but expected %d\n", s2.f2, 2);
6321 s2.f1+=addend; s2.f2+=addend;
6329 LIBTEST_API short3 STDCALL
6330 mono_return_short3 (short3 s3, int addend) {
6332 fprintf(stderr, "mono_return_short3 s3.f1: got %d but expected %d\n", s3.f1, 1);
6335 fprintf(stderr, "mono_return_short3 s3.f2: got %d but expected %d\n", s3.f2, 2);
6338 fprintf(stderr, "mono_return_short3 s3.f3: got %d but expected %d\n", s3.f3, 3);
6340 s3.f1+=addend; s3.f2+=addend; s3.f3+=addend;
6348 LIBTEST_API short4 STDCALL
6349 mono_return_short4 (short4 s4, int addend) {
6351 fprintf(stderr, "mono_return_short4 s4.f1: got %d but expected %d\n", s4.f1, 1);
6354 fprintf(stderr, "mono_return_short4 s4.f2: got %d but expected %d\n", s4.f2, 2);
6357 fprintf(stderr, "mono_return_short4 s4.f3: got %d but expected %d\n", s4.f3, 3);
6360 fprintf(stderr, "mono_return_short4 s4.f4: got %d but expected %d\n", s4.f4, 4);
6362 s4.f1+=addend; s4.f2+=addend; s4.f3+=addend; s4.f4+=addend;
6367 short f1,f2,f3,f4,f5;
6370 LIBTEST_API short5 STDCALL
6371 mono_return_short5 (short5 s5, int addend) {
6373 fprintf(stderr, "mono_return_short5 s5.f1: got %d but expected %d\n", s5.f1, 1);
6376 fprintf(stderr, "mono_return_short5 s5.f2: got %d but expected %d\n", s5.f2, 2);
6379 fprintf(stderr, "mono_return_short5 s5.f3: got %d but expected %d\n", s5.f3, 3);
6382 fprintf(stderr, "mono_return_short5 s5.f4: got %d but expected %d\n", s5.f4, 4);
6385 fprintf(stderr, "mono_return_short5 s5.f5: got %d but expected %d\n", s5.f5, 5);
6387 s5.f1+=addend; s5.f2+=addend; s5.f3+=addend; s5.f4+=addend; s5.f5+=addend;
6392 short f1,f2,f3,f4,f5,f6;
6395 LIBTEST_API short6 STDCALL
6396 mono_return_short6 (short6 s6, int addend) {
6398 fprintf(stderr, "mono_return_short6 s6.f1: got %d but expected %d\n", s6.f1, 1);
6401 fprintf(stderr, "mono_return_short6 s6.f2: got %d but expected %d\n", s6.f2, 2);
6404 fprintf(stderr, "mono_return_short6 s6.f3: got %d but expected %d\n", s6.f3, 3);
6407 fprintf(stderr, "mono_return_short6 s6.f4: got %d but expected %d\n", s6.f4, 4);
6410 fprintf(stderr, "mono_return_short6 s6.f5: got %d but expected %d\n", s6.f5, 5);
6413 fprintf(stderr, "mono_return_short6 s6.f6: got %d but expected %d\n", s6.f6, 6);
6415 s6.f1+=addend; s6.f2+=addend; s6.f3+=addend; s6.f4+=addend; s6.f5+=addend; s6.f6+=addend;
6420 short f1,f2,f3,f4,f5,f6,f7;
6423 LIBTEST_API short7 STDCALL
6424 mono_return_short7 (short7 s7, int addend) {
6426 fprintf(stderr, "mono_return_short7 s7.f1: got %d but expected %d\n", s7.f1, 1);
6429 fprintf(stderr, "mono_return_short7 s7.f2: got %d but expected %d\n", s7.f2, 2);
6432 fprintf(stderr, "mono_return_short7 s7.f3: got %d but expected %d\n", s7.f3, 3);
6435 fprintf(stderr, "mono_return_short7 s7.f4: got %d but expected %d\n", s7.f4, 4);
6438 fprintf(stderr, "mono_return_short7 s7.f5: got %d but expected %d\n", s7.f5, 5);
6441 fprintf(stderr, "mono_return_short7 s7.f6: got %d but expected %d\n", s7.f6, 6);
6444 fprintf(stderr, "mono_return_short7 s7.f7: got %d but expected %d\n", s7.f7, 7);
6446 s7.f1+=addend; s7.f2+=addend; s7.f3+=addend; s7.f4+=addend; s7.f5+=addend; s7.f6+=addend; s7.f7+=addend;
6451 short f1,f2,f3,f4,f5,f6,f7,f8;
6454 LIBTEST_API short8 STDCALL
6455 mono_return_short8 (short8 s8, int addend) {
6457 fprintf(stderr, "mono_return_short8 s8.f1: got %d but expected %d\n", s8.f1, 1);
6460 fprintf(stderr, "mono_return_short8 s8.f2: got %d but expected %d\n", s8.f2, 2);
6463 fprintf(stderr, "mono_return_short8 s8.f3: got %d but expected %d\n", s8.f3, 3);
6466 fprintf(stderr, "mono_return_short8 s8.f4: got %d but expected %d\n", s8.f4, 4);
6469 fprintf(stderr, "mono_return_short8 s8.f5: got %d but expected %d\n", s8.f5, 5);
6472 fprintf(stderr, "mono_return_short8 s8.f6: got %d but expected %d\n", s8.f6, 6);
6475 fprintf(stderr, "mono_return_short8 s8.f7: got %d but expected %d\n", s8.f7, 7);
6478 fprintf(stderr, "mono_return_short8 s8.f8: got %d but expected %d\n", s8.f8, 8);
6480 s8.f1+=addend; s8.f2+=addend; s8.f3+=addend; s8.f4+=addend; s8.f5+=addend; s8.f6+=addend; s8.f7+=addend; s8.f8+=addend;
6485 short f1,f2,f3,f4,f5,f6,f7,f8,f9;
6488 LIBTEST_API short9 STDCALL
6489 mono_return_short9 (short9 s9, int addend) {
6491 fprintf(stderr, "mono_return_short9 s9.f1: got %d but expected %d\n", s9.f1, 1);
6494 fprintf(stderr, "mono_return_short9 s9.f2: got %d but expected %d\n", s9.f2, 2);
6497 fprintf(stderr, "mono_return_short9 s9.f3: got %d but expected %d\n", s9.f3, 3);
6500 fprintf(stderr, "mono_return_short9 s9.f4: got %d but expected %d\n", s9.f4, 4);
6503 fprintf(stderr, "mono_return_short9 s9.f5: got %d but expected %d\n", s9.f5, 5);
6506 fprintf(stderr, "mono_return_short9 s9.f6: got %d but expected %d\n", s9.f6, 6);
6509 fprintf(stderr, "mono_return_short9 s9.f7: got %d but expected %d\n", s9.f7, 7);
6512 fprintf(stderr, "mono_return_short9 s9.f8: got %d but expected %d\n", s9.f8, 8);
6515 fprintf(stderr, "mono_return_short9 s9.f9: got %d but expected %d\n", s9.f9, 9);
6517 s9.f1+=addend; s9.f2+=addend; s9.f3+=addend; s9.f4+=addend; s9.f5+=addend; s9.f6+=addend; s9.f7+=addend; s9.f8+=addend; s9.f9+=addend;
6525 short f2,f3,f4,f5,f6,f7;
6531 LIBTEST_API short8_nested STDCALL
6532 mono_return_short8_nested (short8_nested sn8, int addend) {
6533 if (sn8.nested1.f1 != 1) {
6534 fprintf(stderr, "mono_return_short8_nested sn8.nested1.f1: got %d but expected %d\n", sn8.nested1.f1, 1);
6537 fprintf(stderr, "mono_return_short8_nested sn8.f2: got %d but expected %d\n", sn8.f2, 2);
6540 fprintf(stderr, "mono_return_short8_nested sn8.f3: got %d but expected %d\n", sn8.f3, 3);
6543 fprintf(stderr, "mono_return_short8_nested sn8.f4: got %d but expected %d\n", sn8.f4, 4);
6546 fprintf(stderr, "mono_return_short8_nested sn8.f5: got %d but expected %d\n", sn8.f5, 5);
6549 fprintf(stderr, "mono_return_short8_nested sn8.f6: got %d but expected %d\n", sn8.f6, 6);
6552 fprintf(stderr, "mono_return_short8_nested sn8.f7: got %d but expected %d\n", sn8.f7, 7);
6554 if (sn8.nested2.f8 != 8) {
6555 fprintf(stderr, "mono_return_short8_nested sn8.nested2.f8: got %d but expected %d\n", sn8.nested2.f8, 8);
6557 sn8.nested1.f1+=addend; sn8.f2+=addend; sn8.f3+=addend; sn8.f4+=addend; sn8.f5+=addend; sn8.f6+=addend; sn8.f7+=addend; sn8.nested2.f8+=addend;
6566 LIBTEST_API int1 STDCALL
6567 mono_return_int1 (int1 s1, int addend) {
6569 fprintf(stderr, "mono_return_int1 s1.f1: got %d but expected %d\n", s1.f1, 1);
6579 LIBTEST_API int2 STDCALL
6580 mono_return_int2 (int2 s2, int addend) {
6582 fprintf(stderr, "mono_return_int2 s2.f1: got %d but expected %d\n", s2.f1, 1);
6585 fprintf(stderr, "mono_return_int2 s2.f2: got %d but expected %d\n", s2.f2, 2);
6587 s2.f1+=addend; s2.f2+=addend;
6595 LIBTEST_API int3 STDCALL
6596 mono_return_int3 (int3 s3, int addend) {
6598 fprintf(stderr, "mono_return_int3 s3.f1: got %d but expected %d\n", s3.f1, 1);
6601 fprintf(stderr, "mono_return_int3 s3.f2: got %d but expected %d\n", s3.f2, 2);
6604 fprintf(stderr, "mono_return_int3 s3.f3: got %d but expected %d\n", s3.f3, 3);
6606 s3.f1+=addend; s3.f2+=addend; s3.f3+=addend;
6614 LIBTEST_API int4 STDCALL
6615 mono_return_int4 (int4 s4, int addend) {
6617 fprintf(stderr, "mono_return_int4 s4.f1: got %d but expected %d\n", s4.f1, 1);
6620 fprintf(stderr, "mono_return_int4 s4.f2: got %d but expected %d\n", s4.f2, 2);
6623 fprintf(stderr, "mono_return_int4 s4.f3: got %d but expected %d\n", s4.f3, 3);
6626 fprintf(stderr, "mono_return_int4 s4.f4: got %d but expected %d\n", s4.f4, 4);
6628 s4.f1+=addend; s4.f2+=addend; s4.f3+=addend; s4.f4+=addend;
6636 LIBTEST_API int5 STDCALL
6637 mono_return_int5 (int5 s5, int addend) {
6639 fprintf(stderr, "mono_return_int5 s5.f1: got %d but expected %d\n", s5.f1, 1);
6642 fprintf(stderr, "mono_return_int5 s5.f2: got %d but expected %d\n", s5.f2, 2);
6645 fprintf(stderr, "mono_return_int5 s5.f3: got %d but expected %d\n", s5.f3, 3);
6648 fprintf(stderr, "mono_return_int5 s5.f4: got %d but expected %d\n", s5.f4, 4);
6651 fprintf(stderr, "mono_return_int5 s5.f5: got %d but expected %d\n", s5.f5, 5);
6653 s5.f1+=addend; s5.f2+=addend; s5.f3+=addend; s5.f4+=addend; s5.f5+=addend;
6667 LIBTEST_API int4_nested STDCALL
6668 mono_return_int4_nested (int4_nested sn4, int addend) {
6669 if (sn4.nested1.f1 != 1) {
6670 fprintf(stderr, "mono_return_int4_nested sn4.nested1.f1: got %d but expected %d\n", sn4.nested1.f1, 1);
6673 fprintf(stderr, "mono_return_int4_nested sn4.f2: got %d but expected %d\n", sn4.f2, 2);
6676 fprintf(stderr, "mono_return_int4_nested sn4.f3: got %d but expected %d\n", sn4.f3, 3);
6678 if (sn4.nested2.f4 != 4) {
6679 fprintf(stderr, "mono_return_int4_nested sn4.nested2.f4: got %d but expected %d\n", sn4.nested2.f4, 4);
6681 sn4.nested1.f1+=addend; sn4.f2+=addend; sn4.f3+=addend; sn4.nested2.f4+=addend;
6689 LIBTEST_API float1 STDCALL
6690 mono_return_float1 (float1 s1, int addend) {
6692 fprintf(stderr, "mono_return_float1 s1.f1: got %f but expected %d\n", s1.f1, 1);
6702 LIBTEST_API float2 STDCALL
6703 mono_return_float2 (float2 s2, int addend) {
6705 fprintf(stderr, "mono_return_float2 s2.f1: got %f but expected %d\n", s2.f1, 1);
6708 fprintf(stderr, "mono_return_float2 s2.f2: got %f but expected %d\n", s2.f2, 2);
6710 s2.f1+=addend; s2.f2+=addend;
6718 LIBTEST_API float3 STDCALL
6719 mono_return_float3 (float3 s3, int addend) {
6721 fprintf(stderr, "mono_return_float3 s3.f1: got %f but expected %d\n", s3.f1, 1);
6724 fprintf(stderr, "mono_return_float3 s3.f2: got %f but expected %d\n", s3.f2, 2);
6727 fprintf(stderr, "mono_return_float3 s3.f3: got %f but expected %d\n", s3.f3, 3);
6729 s3.f1+=addend; s3.f2+=addend; s3.f3+=addend;
6737 LIBTEST_API float4 STDCALL
6738 mono_return_float4 (float4 s4, int addend) {
6740 fprintf(stderr, "mono_return_float4 s4.f1: got %f but expected %d\n", s4.f1, 1);
6743 fprintf(stderr, "mono_return_float4 s4.f2: got %f but expected %d\n", s4.f2, 2);
6746 fprintf(stderr, "mono_return_float4 s4.f3: got %f but expected %d\n", s4.f3, 3);
6749 fprintf(stderr, "mono_return_float4 s4.f4: got %f but expected %d\n", s4.f4, 4);
6751 s4.f1+=addend; s4.f2+=addend; s4.f3+=addend; s4.f4+=addend;
6756 float f1,f2,f3,f4,f5;
6759 LIBTEST_API float5 STDCALL
6760 mono_return_float5 (float5 s5, int addend) {
6762 fprintf(stderr, "mono_return_float5 s5.f1: got %f but expected %d\n", s5.f1, 1);
6765 fprintf(stderr, "mono_return_float5 s5.f2: got %f but expected %d\n", s5.f2, 2);
6768 fprintf(stderr, "mono_return_float5 s5.f3: got %f but expected %d\n", s5.f3, 3);
6771 fprintf(stderr, "mono_return_float5 s5.f4: got %f but expected %d\n", s5.f4, 4);
6774 fprintf(stderr, "mono_return_float5 s5.f5: got %f but expected %d\n", s5.f5, 5);
6776 s5.f1+=addend; s5.f2+=addend; s5.f3+=addend; s5.f4+=addend; s5.f5+=addend;
6781 float f1,f2,f3,f4,f5,f6;
6784 LIBTEST_API float6 STDCALL
6785 mono_return_float6 (float6 s6, int addend) {
6787 fprintf(stderr, "mono_return_float6 s6.f1: got %f but expected %d\n", s6.f1, 1);
6790 fprintf(stderr, "mono_return_float6 s6.f2: got %f but expected %d\n", s6.f2, 2);
6793 fprintf(stderr, "mono_return_float6 s6.f3: got %f but expected %d\n", s6.f3, 3);
6796 fprintf(stderr, "mono_return_float6 s6.f4: got %f but expected %d\n", s6.f4, 4);
6799 fprintf(stderr, "mono_return_float6 s6.f5: got %f but expected %d\n", s6.f5, 5);
6802 fprintf(stderr, "mono_return_float6 s6.f6: got %f but expected %d\n", s6.f6, 6);
6804 s6.f1+=addend; s6.f2+=addend; s6.f3+=addend; s6.f4+=addend; s6.f5+=addend; s6.f6+=addend;
6809 float f1,f2,f3,f4,f5,f6,f7;
6812 LIBTEST_API float7 STDCALL
6813 mono_return_float7 (float7 s7, int addend) {
6815 fprintf(stderr, "mono_return_float7 s7.f1: got %f but expected %d\n", s7.f1, 1);
6818 fprintf(stderr, "mono_return_float7 s7.f2: got %f but expected %d\n", s7.f2, 2);
6821 fprintf(stderr, "mono_return_float7 s7.f3: got %f but expected %d\n", s7.f3, 3);
6824 fprintf(stderr, "mono_return_float7 s7.f4: got %f but expected %d\n", s7.f4, 4);
6827 fprintf(stderr, "mono_return_float7 s7.f5: got %f but expected %d\n", s7.f5, 5);
6830 fprintf(stderr, "mono_return_float7 s7.f6: got %f but expected %d\n", s7.f6, 6);
6833 fprintf(stderr, "mono_return_float7 s7.f7: got %f but expected %d\n", s7.f7, 7);
6835 s7.f1+=addend; s7.f2+=addend; s7.f3+=addend; s7.f4+=addend; s7.f5+=addend; s7.f6+=addend; s7.f7+=addend;
6840 float f1,f2,f3,f4,f5,f6,f7,f8;
6843 LIBTEST_API float8 STDCALL
6844 mono_return_float8 (float8 s8, int addend) {
6846 fprintf(stderr, "mono_return_float8 s8.f1: got %f but expected %d\n", s8.f1, 1);
6849 fprintf(stderr, "mono_return_float8 s8.f2: got %f but expected %d\n", s8.f2, 2);
6852 fprintf(stderr, "mono_return_float8 s8.f3: got %f but expected %d\n", s8.f3, 3);
6855 fprintf(stderr, "mono_return_float8 s8.f4: got %f but expected %d\n", s8.f4, 4);
6858 fprintf(stderr, "mono_return_float8 s8.f5: got %f but expected %d\n", s8.f5, 5);
6861 fprintf(stderr, "mono_return_float8 s8.f6: got %f but expected %d\n", s8.f6, 6);
6864 fprintf(stderr, "mono_return_float8 s8.f7: got %f but expected %d\n", s8.f7, 7);
6867 fprintf(stderr, "mono_return_float8 s8.f8: got %f but expected %d\n", s8.f8, 8);
6869 s8.f1+=addend; s8.f2+=addend; s8.f3+=addend; s8.f4+=addend; s8.f5+=addend; s8.f6+=addend; s8.f7+=addend; s8.f8+=addend;
6874 float f1,f2,f3,f4,f5,f6,f7,f8,f9;
6877 LIBTEST_API float9 STDCALL
6878 mono_return_float9 (float9 s9, int addend) {
6880 fprintf(stderr, "mono_return_float9 s9.f1: got %f but expected %d\n", s9.f1, 1);
6883 fprintf(stderr, "mono_return_float9 s9.f2: got %f but expected %d\n", s9.f2, 2);
6886 fprintf(stderr, "mono_return_float9 s9.f3: got %f but expected %d\n", s9.f3, 3);
6889 fprintf(stderr, "mono_return_float9 s9.f4: got %f but expected %d\n", s9.f4, 4);
6892 fprintf(stderr, "mono_return_float9 s9.f5: got %f but expected %d\n", s9.f5, 5);
6895 fprintf(stderr, "mono_return_float9 s9.f6: got %f but expected %d\n", s9.f6, 6);
6898 fprintf(stderr, "mono_return_float9 s9.f7: got %f but expected %d\n", s9.f7, 7);
6901 fprintf(stderr, "mono_return_float9 s9.f8: got %f but expected %d\n", s9.f8, 8);
6904 fprintf(stderr, "mono_return_float9 s9.f9: got %f but expected %d\n", s9.f9, 9);
6906 s9.f1+=addend; s9.f2+=addend; s9.f3+=addend; s9.f4+=addend; s9.f5+=addend; s9.f6+=addend; s9.f7+=addend; s9.f8+=addend; s9.f9+=addend;
6920 LIBTEST_API float4_nested STDCALL
6921 mono_return_float4_nested (float4_nested sn4, int addend) {
6922 if (sn4.nested1.f1 != 1) {
6923 fprintf(stderr, "mono_return_float4_nested sn4.nested1.f1: got %f but expected %d\n", sn4.nested1.f1, 1);
6926 fprintf(stderr, "mono_return_float4_nested sn4.f2: got %f but expected %d\n", sn4.f2, 2);
6929 fprintf(stderr, "mono_return_float4_nested sn4.f3: got %f but expected %d\n", sn4.f3, 3);
6931 if (sn4.nested2.f4 != 4) {
6932 fprintf(stderr, "mono_return_float4_nested sn4.nested2.f4: got %f but expected %d\n", sn4.nested2.f4, 4);
6934 sn4.nested1.f1+=addend; sn4.f2+=addend; sn4.f3+=addend; sn4.nested2.f4+=addend;
6942 LIBTEST_API double1 STDCALL
6943 mono_return_double1 (double1 s1, int addend) {
6945 fprintf(stderr, "mono_return_double1 s1.f1: got %f but expected %d\n", s1.f1, 1);
6955 LIBTEST_API double2 STDCALL
6956 mono_return_double2 (double2 s2, int addend) {
6958 fprintf(stderr, "mono_return_double2 s2.f1: got %f but expected %d\n", s2.f1, 1);
6961 fprintf(stderr, "mono_return_double2 s2.f2: got %f but expected %d\n", s2.f2, 2);
6963 s2.f1+=addend; s2.f2+=addend;
6971 LIBTEST_API double3 STDCALL
6972 mono_return_double3 (double3 s3, int addend) {
6974 fprintf(stderr, "mono_return_double3 s3.f1: got %f but expected %d\n", s3.f1, 1);
6977 fprintf(stderr, "mono_return_double3 s3.f2: got %f but expected %d\n", s3.f2, 2);
6980 fprintf(stderr, "mono_return_double3 s3.f3: got %f but expected %d\n", s3.f3, 3);
6982 s3.f1+=addend; s3.f2+=addend; s3.f3+=addend;
6990 LIBTEST_API double4 STDCALL
6991 mono_return_double4 (double4 s4, int addend) {
6993 fprintf(stderr, "mono_return_double4 s4.f1: got %f but expected %d\n", s4.f1, 1);
6996 fprintf(stderr, "mono_return_double4 s4.f2: got %f but expected %d\n", s4.f2, 2);
6999 fprintf(stderr, "mono_return_double4 s4.f3: got %f but expected %d\n", s4.f3, 3);
7002 fprintf(stderr, "mono_return_double4 s4.f4: got %f but expected %d\n", s4.f4, 4);
7004 s4.f1+=addend; s4.f2+=addend; s4.f3+=addend; s4.f4+=addend;
7009 double f1,f2,f3,f4,f5;
7012 LIBTEST_API double5 STDCALL
7013 mono_return_double5 (double5 s5, int addend) {
7015 fprintf(stderr, "mono_return_double5 s5.f1: got %f but expected %d\n", s5.f1, 1);
7018 fprintf(stderr, "mono_return_double5 s5.f2: got %f but expected %d\n", s5.f2, 2);
7021 fprintf(stderr, "mono_return_double5 s5.f3: got %f but expected %d\n", s5.f3, 3);
7024 fprintf(stderr, "mono_return_double5 s5.f4: got %f but expected %d\n", s5.f4, 4);
7027 fprintf(stderr, "mono_return_double5 s5.f5: got %f but expected %d\n", s5.f5, 5);
7029 s5.f1+=addend; s5.f2+=addend; s5.f3+=addend; s5.f4+=addend; s5.f5+=addend;
7034 double f1,f2,f3,f4,f5,f6;
7037 LIBTEST_API double6 STDCALL
7038 mono_return_double6 (double6 s6, int addend) {
7040 fprintf(stderr, "mono_return_double6 s6.f1: got %f but expected %d\n", s6.f1, 1);
7043 fprintf(stderr, "mono_return_double6 s6.f2: got %f but expected %d\n", s6.f2, 2);
7046 fprintf(stderr, "mono_return_double6 s6.f3: got %f but expected %d\n", s6.f3, 3);
7049 fprintf(stderr, "mono_return_double6 s6.f4: got %f but expected %d\n", s6.f4, 4);
7052 fprintf(stderr, "mono_return_double6 s6.f5: got %f but expected %d\n", s6.f5, 5);
7055 fprintf(stderr, "mono_return_double6 s6.f6: got %f but expected %d\n", s6.f6, 6);
7057 s6.f1+=addend; s6.f2+=addend; s6.f3+=addend; s6.f4+=addend; s6.f5+=addend; s6.f6+=addend;
7062 double f1,f2,f3,f4,f5,f6,f7;
7065 LIBTEST_API double7 STDCALL
7066 mono_return_double7 (double7 s7, int addend) {
7068 fprintf(stderr, "mono_return_double7 s7.f1: got %f but expected %d\n", s7.f1, 1);
7071 fprintf(stderr, "mono_return_double7 s7.f2: got %f but expected %d\n", s7.f2, 2);
7074 fprintf(stderr, "mono_return_double7 s7.f3: got %f but expected %d\n", s7.f3, 3);
7077 fprintf(stderr, "mono_return_double7 s7.f4: got %f but expected %d\n", s7.f4, 4);
7080 fprintf(stderr, "mono_return_double7 s7.f5: got %f but expected %d\n", s7.f5, 5);
7083 fprintf(stderr, "mono_return_double7 s7.f6: got %f but expected %d\n", s7.f6, 6);
7086 fprintf(stderr, "mono_return_double7 s7.f7: got %f but expected %d\n", s7.f7, 7);
7088 s7.f1+=addend; s7.f2+=addend; s7.f3+=addend; s7.f4+=addend; s7.f5+=addend; s7.f6+=addend; s7.f7+=addend;
7093 double f1,f2,f3,f4,f5,f6,f7,f8;
7096 LIBTEST_API double8 STDCALL
7097 mono_return_double8 (double8 s8, int addend) {
7099 fprintf(stderr, "mono_return_double8 s8.f1: got %f but expected %d\n", s8.f1, 1);
7102 fprintf(stderr, "mono_return_double8 s8.f2: got %f but expected %d\n", s8.f2, 2);
7105 fprintf(stderr, "mono_return_double8 s8.f3: got %f but expected %d\n", s8.f3, 3);
7108 fprintf(stderr, "mono_return_double8 s8.f4: got %f but expected %d\n", s8.f4, 4);
7111 fprintf(stderr, "mono_return_double8 s8.f5: got %f but expected %d\n", s8.f5, 5);
7114 fprintf(stderr, "mono_return_double8 s8.f6: got %f but expected %d\n", s8.f6, 6);
7117 fprintf(stderr, "mono_return_double8 s8.f7: got %f but expected %d\n", s8.f7, 7);
7120 fprintf(stderr, "mono_return_double8 s8.f8: got %f but expected %d\n", s8.f8, 8);
7122 s8.f1+=addend; s8.f2+=addend; s8.f3+=addend; s8.f4+=addend; s8.f5+=addend; s8.f6+=addend; s8.f7+=addend; s8.f8+=addend;
7127 double f1,f2,f3,f4,f5,f6,f7,f8,f9;
7130 LIBTEST_API double9 STDCALL
7131 mono_return_double9 (double9 s9, int addend) {
7133 fprintf(stderr, "mono_return_double9 s9.f1: got %f but expected %d\n", s9.f1, 1);
7136 fprintf(stderr, "mono_return_double9 s9.f2: got %f but expected %d\n", s9.f2, 2);
7139 fprintf(stderr, "mono_return_double9 s9.f3: got %f but expected %d\n", s9.f3, 3);
7142 fprintf(stderr, "mono_return_double9 s9.f4: got %f but expected %d\n", s9.f4, 4);
7145 fprintf(stderr, "mono_return_double9 s9.f5: got %f but expected %d\n", s9.f5, 5);
7148 fprintf(stderr, "mono_return_double9 s9.f6: got %f but expected %d\n", s9.f6, 6);
7151 fprintf(stderr, "mono_return_double9 s9.f7: got %f but expected %d\n", s9.f7, 7);
7154 fprintf(stderr, "mono_return_double9 s9.f8: got %f but expected %d\n", s9.f8, 8);
7157 fprintf(stderr, "mono_return_double9 s9.f9: got %f but expected %d\n", s9.f9, 9);
7159 s9.f1+=addend; s9.f2+=addend; s9.f3+=addend; s9.f4+=addend; s9.f5+=addend; s9.f6+=addend; s9.f7+=addend; s9.f8+=addend; s9.f9+=addend;
7172 LIBTEST_API double2_nested STDCALL
7173 mono_return_double2_nested (double2_nested sn2, int addend) {
7174 if (sn2.nested1.f1 != 1) {
7175 fprintf(stderr, "mono_return_double2_nested sn2.nested1.f1: got %f but expected %d\n", sn2.nested1.f1, 1);
7177 if (sn2.nested2.f2 != 2) {
7178 fprintf(stderr, "mono_return_double2_nested sn2.nested2.f2: got %f but expected %d\n", sn2.nested2.f2, 2);
7180 sn2.nested1.f1+=addend; sn2.nested2.f2+=addend;
7190 LIBTEST_API double_array4 STDCALL
7191 mono_return_double_array4 (double_array4 sa4, int addend) {
7192 if (sa4.f1[0] != 1) {
7193 fprintf(stderr, "mono_return_double_array4 sa4.f1[0]: got %f but expected %d\n", sa4.f1[0], 1);
7195 if (sa4.f1[1] != 2) {
7196 fprintf(stderr, "mono_return_double_array4 sa4.f1[1]: got %f but expected %d\n", sa4.f1[1], 2);
7198 if (sa4.f1[2] != 3) {
7199 fprintf(stderr, "mono_return_double_array4 sa4.f1[2]: got %f but expected %d\n", sa4.f1[2], 3);
7201 if (sa4.f1[3] != 4) {
7202 fprintf(stderr, "mono_return_double_array4 sa4.f1[3]: got %f but expected %d\n", sa4.f1[3], 4);
7204 sa4.f1[0]+=addend; sa4.f1[1]+=addend; sa4.f1[2]+=addend; sa4.f1[3]+=addend;