9 #define STDCALL __stdcall
15 extern __declspec(dllimport) __stdcall void CoTaskMemFree(void *ptr);
18 typedef int (STDCALL *SimpleDelegate) (int a);
20 static void marshal_free (void *ptr)
29 STDCALL unsigned short*
30 test_lpwstr_marshal (unsigned short* chars, long length)
35 res = malloc (2 * (length + 1));
37 // printf("test_lpwstr_marshal()\n");
39 while ( i < length ) {
40 // printf("X|%u|\n", chars[i]);
57 mono_union_test_1 (union_test_1_type u1) {
58 // printf ("Got values %d %d %d\n", u1.b, u1.a, u1.c);
59 return u1.a + u1.b + u1.c;
63 mono_return_int (int a) {
64 // printf ("Got value %d\n", a);
74 mono_return_int_ss (struct ss a) {
75 // printf ("Got value %d\n", a.i);
80 mono_return_ss (struct ss a) {
81 // printf ("Got value %d\n", a.i);
92 mono_return_sc1 (struct sc1 a) {
93 // printf ("Got value %d\n", a.c[0]);
105 mono_return_sc3 (struct sc3 a) {
106 // printf ("Got values %d %d %d\n", a.c[0], a.c[1], a.c[2]);
119 mono_return_sc5 (struct sc5 a) {
120 // printf ("Got values %d %d %d %d %d\n", a.c[0], a.c[1], a.c[2], a.c[3], a.c[4]);
136 mono_return_int_su (union su a) {
137 // printf ("Got value %d\n", a.i1);
142 mono_test_many_int_arguments (int a, int b, int c, int d, int e,
143 int f, int g, int h, int i, int j);
145 mono_test_many_short_arguments (short a, short b, short c, short d, short e,
146 short f, short g, short h, short i, short j);
148 mono_test_many_char_arguments (char a, char b, char c, char d, char e,
149 char f, char g, char h, char i, char j);
152 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)
154 return a + b + c + d + e + f + g + h + i + j;
158 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)
160 return a + b + c + d + e + f + g + h + i + j;
164 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)
166 return a + b + c + d + e + f + g + h + i + j;
170 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)
172 return a + b + c + d + e + f + g + h + i + j;
176 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)
178 return a + b + c + d + e + f + g + h + i + j;
182 mono_test_split_double_arguments (double a, double b, float c, double d, double e)
184 return a + b + c + d + e;
188 mono_test_puts_static (char *s)
190 // printf ("TEST %s\n", s);
194 typedef int (STDCALL *SimpleDelegate3) (int a, int b);
197 mono_invoke_delegate (SimpleDelegate3 delegate)
201 // printf ("start invoke %p\n", delegate);
203 res = delegate (2, 3);
205 // printf ("end invoke\n");
211 mono_test_marshal_char (short a1)
220 mono_test_marshal_char_array (gunichar2 *s)
222 const char m[] = "abcdef";
226 s2 = g_utf8_to_utf16 (m, -1, NULL, &len, NULL);
235 mono_test_empty_pinvoke (int i)
241 mono_test_marshal_bool_byref (int a, int *b, int c)
251 mono_test_marshal_array (int *a1)
255 for (i = 0; i < 50; i++)
262 mono_test_marshal_inout_array (int *a1)
266 for (i = 0; i < 50; i++) {
268 a1 [i] = 50 - a1 [i];
275 mono_test_marshal_out_array (int *a1)
279 for (i = 0; i < 50; i++) {
287 mono_test_marshal_inout_nonblittable_array (gunichar2 *a1)
291 for (i = 0; i < 10; i++) {
312 mono_test_return_vtype (int i)
315 static gunichar2 test2 [] = { 'T', 'E', 'S', 'T', '2', 0 };
327 mono_test_delegate_struct (void)
329 // printf ("TEST\n");
332 typedef char* (STDCALL *ReturnStringDelegate) (const char *s);
335 mono_test_return_string (ReturnStringDelegate func)
339 // printf ("mono_test_return_string\n");
344 // printf ("got string: %s\n", res);
345 return g_strdup ("12345");
348 typedef int (STDCALL *RefVTypeDelegate) (int a, simplestruct *ss, int b);
351 mono_test_ref_vtype (int a, simplestruct *ss, int b, RefVTypeDelegate func)
353 if (a == 1 && b == 2 && ss->a == 0 && ss->b == 1 && ss->c == 0 &&
354 !strcmp (ss->d, "TEST1")) {
360 return func (a, ss, b);
366 typedef int (STDCALL *OutVTypeDelegate) (int a, simplestruct *ss, int b);
369 mono_test_marshal_out_struct (int a, simplestruct *ss, int b, OutVTypeDelegate func)
371 /* Check that the input pointer is ignored */
372 ss->d = (gpointer)0x12345678;
376 if (ss->a && ss->b && ss->c && !strcmp (ss->d, "TEST3"))
384 SimpleDelegate func, func2;
387 STDCALL DelegateStruct
388 mono_test_marshal_delegate_struct (DelegateStruct ds)
392 res.a = ds.func (ds.a) + ds.func2 (ds.a);
394 res.func2 = ds.func2;
400 mono_test_marshal_struct (simplestruct ss)
402 if (ss.a == 0 && ss.b == 1 && ss.c == 0 &&
403 !strcmp (ss.d, "TEST"))
410 mono_test_marshal_byref_struct (simplestruct *ss, int a, int b, int c, char *d)
412 gboolean res = (ss->a == a && ss->b == b && ss->c == c && strcmp (ss->d, d) == 0);
417 ss->d = g_strdup ("DEF");
434 mono_test_marshal_struct2 (simplestruct2 ss)
436 if (ss.a == 0 && ss.b == 1 && ss.c == 0 &&
437 !strcmp (ss.d, "TEST") &&
438 ss.e == 99 && ss.f == 1.5 && ss.g == 42 && ss.h == (guint64)123)
444 /* on HP some of the struct should be on the stack and not in registers */
446 mono_test_marshal_struct2_2 (int i, int j, int k, simplestruct2 ss)
448 if (i != 10 || j != 11 || k != 12)
450 if (ss.a == 0 && ss.b == 1 && ss.c == 0 &&
451 !strcmp (ss.d, "TEST") &&
452 ss.e == 99 && ss.f == 1.5 && ss.g == 42 && ss.h == (guint64)123)
459 mono_test_marshal_lpstruct (simplestruct *ss)
461 if (ss->a == 0 && ss->b == 1 && ss->c == 0 &&
462 !strcmp (ss->d, "TEST"))
469 mono_test_marshal_lpstruct_blittable (point *p)
471 if (p->x == 1.0 && p->y == 2.0)
478 mono_test_marshal_struct_array (simplestruct2 *ss)
480 if (! (ss[0].a == 0 && ss[0].b == 1 && ss[0].c == 0 &&
481 !strcmp (ss[0].d, "TEST") &&
482 ss[0].e == 99 && ss[0].f == 1.5 && ss[0].g == 42 && ss[0].h == (guint64)123))
485 if (! (ss[1].a == 0 && ss[1].b == 0 && ss[1].c == 0 &&
486 !strcmp (ss[1].d, "TEST2") &&
487 ss[1].e == 100 && ss[1].f == 2.5 && ss[1].g == 43 && ss[1].h == (guint64)124))
493 typedef struct long_align_struct {
500 mono_test_marshal_long_align_struct_array (long_align_struct *ss)
502 return ss[0].a + ss[0].b + ss[0].c + ss[1].a + ss[1].b + ss[1].c;
505 STDCALL simplestruct2 *
506 mono_test_marshal_class (int i, int j, int k, simplestruct2 *ss, int l)
513 if (i != 10 || j != 11 || k != 12 || l != 14)
515 if (! (ss->a == 0 && ss->b == 1 && ss->c == 0 &&
516 !strcmp (ss->d, "TEST") &&
517 ss->e == 99 && ss->f == 1.5 && ss->g == 42 && ss->h == (guint64)123))
520 res = g_new0 (simplestruct2, 1);
521 memcpy (res, ss, sizeof (simplestruct2));
522 res->d = g_strdup ("TEST");
527 mono_test_marshal_byref_class (simplestruct2 **ssp)
529 simplestruct2 *ss = *ssp;
532 if (! (ss->a == 0 && ss->b == 1 && ss->c == 0 &&
533 !strcmp (ss->d, "TEST") &&
534 ss->e == 99 && ss->f == 1.5 && ss->g == 42 && ss->h == (guint64)123))
537 res = g_new0 (simplestruct2, 1);
538 memcpy (res, ss, sizeof (simplestruct2));
539 res->d = g_strdup ("TEST-RES");
551 /* Yes, this is correct, we are only trying to determine the value of the stack here */
557 reliable_delegate (int a)
563 * Checks whether get_sp() works as expected. It doesn't work with gcc-2.95.3 on linux.
566 is_get_sp_reliable (void)
570 reliable_delegate(1);
572 reliable_delegate(1);
578 mono_test_marshal_delegate (SimpleDelegate delegate)
582 /* Check that the delegate wrapper is stdcall */
587 if (is_get_sp_reliable())
588 g_assert (sp1 == sp2);
593 STDCALL SimpleDelegate
594 mono_test_marshal_return_delegate (SimpleDelegate delegate)
600 return_plus_one (int i)
605 STDCALL SimpleDelegate
606 mono_test_marshal_return_delegate_2 ()
608 return return_plus_one;
611 typedef simplestruct (STDCALL *SimpleDelegate2) (simplestruct ss);
614 is_utf16_equals (gunichar2 *s1, const char *s2)
619 s = g_utf16_to_utf8 (s1, -1, NULL, NULL, NULL);
620 res = strcmp (s, s2);
627 mono_test_marshal_delegate2 (SimpleDelegate2 delegate)
629 simplestruct ss, res;
635 ss.d2 = g_utf8_to_utf16 ("TEST2", -1, NULL, NULL, NULL);
638 if (! (res.a && !res.b && res.c && !strcmp (res.d, "TEST-RES") && is_utf16_equals (res.d2, "TEST2-RES")))
644 typedef simplestruct* (STDCALL *SimpleDelegate4) (simplestruct *ss);
647 mono_test_marshal_delegate4 (SimpleDelegate4 delegate)
658 res = delegate (&ss);
662 /* Check return value */
663 if (! (!res->a && res->b && !res->c && !strcmp (res->d, "TEST")))
666 /* Check NULL argument and NULL result */
667 res = delegate (NULL);
674 typedef int (STDCALL *SimpleDelegate5) (simplestruct **ss);
677 mono_test_marshal_delegate5 (SimpleDelegate5 delegate)
690 res = delegate (&ptr);
694 if (!(ptr->a && !ptr->b && ptr->c && !strcmp (ptr->d, "RES")))
701 mono_test_marshal_delegate6 (SimpleDelegate5 delegate)
705 res = delegate (NULL);
710 typedef int (STDCALL *SimpleDelegate7) (simplestruct **ss);
713 mono_test_marshal_delegate7 (SimpleDelegate7 delegate)
718 /* Check that the input pointer is ignored */
719 ptr = (gpointer)0x12345678;
721 res = delegate (&ptr);
725 if (!(ptr->a && !ptr->b && ptr->c && !strcmp (ptr->d, "RES")))
731 typedef int (STDCALL *SimpleDelegate8) (gunichar2 *s);
734 mono_test_marshal_delegate8 (SimpleDelegate8 delegate, gunichar2 *s)
739 typedef int (STDCALL *return_int_fnt) (int i);
740 typedef int (STDCALL *SimpleDelegate9) (return_int_fnt d);
743 mono_test_marshal_delegate9 (SimpleDelegate9 delegate, gpointer ftn)
745 return delegate (ftn);
755 mono_test_marshal_delegate10 (SimpleDelegate9 delegate)
757 return delegate (return_self);
760 typedef int (STDCALL *PrimitiveByrefDelegate) (int *i);
763 mono_test_marshal_primitive_byref_delegate (PrimitiveByrefDelegate delegate)
767 int res = delegate (&i);
777 typedef int (STDCALL *return_int_delegate) (int i);
779 typedef return_int_delegate (STDCALL *ReturnDelegateDelegate) (void);
782 mono_test_marshal_return_delegate_delegate (ReturnDelegateDelegate d)
788 mono_test_marshal_stringbuilder (char *s, int n)
790 const char m[] = "This is my message. Isn't it nice?";
792 if (strcmp (s, "ABCD") != 0)
799 mono_test_marshal_stringbuilder_unicode (gunichar2 *s, int n)
801 const char m[] = "This is my message. Isn't it nice?";
805 s2 = g_utf8_to_utf16 (m, -1, NULL, &len, NULL);
824 mono_test_marshal_empty_string_array (char **array)
826 return (array == NULL) ? 0 : 1;
830 mono_test_marshal_string_array (char **array)
832 if (strcmp (array [0], "ABC"))
834 if (strcmp (array [1], "DEF"))
837 if (array [2] != NULL)
844 mono_test_marshal_byref_string_array (char ***array)
849 if (strcmp ((*array) [0], "Alpha"))
851 if (strcmp ((*array) [1], "Beta"))
853 if (strcmp ((*array) [2], "Gamma"))
860 mono_test_marshal_stringbuilder_array (char **array)
862 if (strcmp (array [0], "ABC"))
864 if (strcmp (array [1], "DEF"))
867 strcpy (array [0], "DEF");
868 strcpy (array [1], "ABC");
874 mono_test_marshal_unicode_string_array (gunichar2 **array, char **array2)
876 GError *error = NULL;
879 s = g_utf16_to_utf8 (array [0], -1, NULL, NULL, &error);
880 if (strcmp (s, "ABC")) {
887 s = g_utf16_to_utf8 (array [1], -1, NULL, NULL, &error);
888 if (strcmp (s, "DEF")) {
895 if (strcmp (array2 [0], "ABC"))
898 if (strcmp (array2 [1], "DEF"))
904 /* this does not work on Redhat gcc 2.96 */
906 mono_test_empty_struct (int a, EmptyStruct es, int b)
908 // printf ("mono_test_empty_struct %d %d\n", a, b);
910 // Intel icc on ia64 passes 'es' in 2 registers
911 #if defined(__ia64) && defined(__INTEL_COMPILER)
914 if (a == 1 && b == 2)
924 STDCALL ByValStrStruct *
925 mono_test_byvalstr_gen (void)
929 ret = malloc(sizeof(ByValStrStruct));
930 memset(ret, 'a', sizeof(ByValStrStruct)-1);
931 ret->a[sizeof(ByValStrStruct)-1] = 0;
937 mono_test_byvalstr_check (ByValStrStruct* data, char* correctString)
941 ret = strcmp(data->a, correctString);
942 // printf ("T1: %s\n", data->a);
943 // printf ("T2: %s\n", correctString);
950 NameManglingAnsi (char *data)
952 return data [0] + data [1] + data [2];
956 NameManglingAnsiA (char *data)
958 g_assert_not_reached ();
962 NameManglingAnsiW (char *data)
964 g_assert_not_reached ();
968 NameManglingAnsi2A (char *data)
970 return data [0] + data [1] + data [2];
974 NameManglingAnsi2W (char *data)
976 g_assert_not_reached ();
980 NameManglingUnicode (char *data)
982 g_assert_not_reached ();
986 NameManglingUnicodeW (gunichar2 *data)
988 return data [0] + data [1] + data [2];
992 NameManglingUnicode2 (gunichar2 *data)
994 return data [0] + data [1] + data [2];
998 NameManglingAutoW (char *data)
1001 return (data [0] + data [1] + data [2]) == 131 ? 0 : 1;
1003 g_assert_not_reached ();
1008 NameManglingAuto (char *data)
1011 return (data [0] + data [1] + data [2]) == 198 ? 0 : 1;
1013 g_assert_not_reached ();
1017 typedef int (STDCALL *intcharFunc)(const char*);
1020 callFunction (intcharFunc f)
1031 class_marshal_test0 (SimpleObj *obj1)
1033 // printf ("class_marshal_test0 %s %d\n", obj1->str, obj1->i);
1035 if (strcmp(obj1->str, "T1"))
1044 class_marshal_test4 (SimpleObj *obj1)
1053 class_marshal_test1 (SimpleObj **obj1)
1055 SimpleObj *res = malloc (sizeof (SimpleObj));
1057 res->str = g_strdup ("ABC");
1064 class_marshal_test2 (SimpleObj **obj1)
1066 // printf ("class_marshal_test2 %s %d\n", (*obj1)->str, (*obj1)->i);
1068 if (strcmp((*obj1)->str, "ABC"))
1070 if ((*obj1)->i != 5)
1077 string_marshal_test0 (char *str)
1079 if (strcmp (str, "TEST0"))
1086 string_marshal_test1 (const char **str)
1092 string_marshal_test2 (char **str)
1094 // printf ("string_marshal_test2 %s\n", *str);
1096 if (strcmp (*str, "TEST1"))
1103 string_marshal_test3 (char *str)
1117 TestVectorList (VectorList *vl)
1121 // printf ("TestVectorList %d %d\n", vl->a, vl->b);
1126 res = g_new0 (VectorList, 1);
1127 memcpy (res, vl, sizeof (VectorList));
1132 typedef struct _OSVERSIONINFO
1139 GetVersionEx (OSVERSIONINFO *osvi)
1142 // printf ("GOT %d %d\n", osvi->a, osvi->b);
1147 return osvi->a + osvi->b;
1151 BugGetVersionEx (int a, int b, int c, int d, int e, int f, int g, int h, OSVERSIONINFO *osvi)
1154 // printf ("GOT %d %d\n", osvi->a, osvi->b);
1159 return osvi->a + osvi->b;
1163 mono_test_marshal_point (point pt)
1165 // printf("point %g %g\n", pt.x, pt.y);
1166 if (pt.x == 1.25 && pt.y == 3.5)
1178 mono_test_marshal_mixed_point (mixed_point pt)
1180 // printf("mixed point %d %g\n", pt.x, pt.y);
1181 if (pt.x == 5 && pt.y == 6.75)
1188 mono_test_marshal_mixed_point_2 (mixed_point *pt)
1190 if (pt->x != 5 || pt->y != 6.75)
1200 marshal_test_ref_bool(int i, char *b1, short *b2, int *b3)
1203 if (*b1 != 0 && *b1 != 1)
1205 if (*b2 != 0 && *b2 != -1) /* variant_bool */
1207 if (*b3 != 0 && *b3 != 1)
1209 if (i == ((*b1 << 2) | (-*b2 << 1) | *b3))
1221 short b2; /* variant_bool */
1226 marshal_test_bool_struct(struct BoolStruct *s)
1229 if (s->b1 != 0 && s->b1 != 1)
1231 if (s->b2 != 0 && s->b2 != -1)
1233 if (s->b3 != 0 && s->b3 != 1)
1235 if (s->i == ((s->b1 << 2) | (-s->b2 << 1) | s->b3))
1244 extern __declspec(dllimport) __stdcall void SetLastError(int x);
1248 mono_test_last_error (int err)
1258 mono_test_asany (void *ptr, int what)
1262 return (*(int*)ptr == 5) ? 0 : 1;
1264 return strcmp (ptr, "ABC") == 0 ? 0 : 1;
1266 simplestruct2 ss = *(simplestruct2*)ptr;
1268 if (ss.a == 0 && ss.b == 1 && ss.c == 0 &&
1269 !strcmp (ss.d, "TEST") &&
1270 ss.e == 99 && ss.f == 1.5 && ss.g == 42 && ss.h == (guint64)123)
1276 GError *error = NULL;
1279 s = g_utf16_to_utf8 (ptr, -1, NULL, NULL, &error);
1280 if (!strcmp (s, "ABC")) {
1290 g_assert_not_reached ();
1305 mono_test_marshal_asany_inout (void* ptr)
1307 AsAnyStruct* asAny = ptr;
1308 int res = asAny->i + asAny->j + asAny->k;
1319 * AMD64 marshalling tests.
1322 typedef struct amd64_struct1 {
1329 STDCALL amd64_struct1
1330 mono_test_marshal_amd64_pass_return_struct1 (amd64_struct1 s)
1340 typedef struct amd64_struct2 {
1345 STDCALL amd64_struct2
1346 mono_test_marshal_amd64_pass_return_struct2 (amd64_struct2 s)
1354 typedef struct amd64_struct3 {
1358 STDCALL amd64_struct3
1359 mono_test_marshal_amd64_pass_return_struct3 (amd64_struct3 s)
1366 typedef struct amd64_struct4 {
1370 STDCALL amd64_struct4
1371 mono_test_marshal_amd64_pass_return_struct4 (amd64_struct4 s)
1380 * IA64 marshalling tests.
1382 typedef struct test_struct5 {
1386 STDCALL test_struct5
1387 mono_test_marshal_ia64_pass_return_struct5 (double d1, double d2, test_struct5 s, double d3, double d4)
1395 typedef struct test_struct6 {
1399 STDCALL test_struct6
1400 mono_test_marshal_ia64_pass_return_struct6 (double d1, double d2, test_struct6 s, double d3, double d4)
1408 static guint32 custom_res [2];
1411 mono_test_marshal_pass_return_custom (int i, guint32 *ptr, int j)
1413 /* ptr will be freed by CleanupNative, so make a copy */
1414 custom_res [0] = 0; /* not allocated by AllocHGlobal */
1415 custom_res [1] = ptr [1];
1421 mono_test_marshal_pass_out_custom (int i, guint32 **ptr, int j)
1424 custom_res [1] = i + j + 10;
1432 mono_test_marshal_pass_byref_custom (int i, guint32 **ptr, int j)
1440 mono_test_marshal_pass_return_custom2 (int i, guint32 *ptr, int j)
1442 g_assert_not_reached ();
1448 mono_test_marshal_pass_return_custom_null (int i, guint32 *ptr, int j)
1450 g_assert (ptr == NULL);
1455 typedef void *(STDCALL *PassReturnPtrDelegate) (void *ptr);
1458 mono_test_marshal_pass_return_custom_in_delegate (PassReturnPtrDelegate del)
1472 /* FIXME: Freed with FreeHGlobal */
1481 mono_test_marshal_pass_return_custom_null_in_delegate (PassReturnPtrDelegate del)
1483 void *ptr = del (NULL);
1485 return (ptr == NULL) ? 15 : 0;
1488 typedef int (STDCALL *ReturnEnumDelegate) (int e);
1491 mono_test_marshal_return_enum_delegate (ReturnEnumDelegate func)
1501 typedef BlittableStruct (STDCALL *SimpleDelegate10) (BlittableStruct ss);
1504 mono_test_marshal_blittable_struct_delegate (SimpleDelegate10 delegate)
1506 BlittableStruct ss, res;
1513 res = delegate (ss);
1514 if (! ((res.a == -1) && (res.b == -2) && (res.c == -3) && (res.d == -55)))
1521 mono_test_stdcall_name_mangling (int a, int b, int c)
1527 * PASSING AND RETURNING SMALL STRUCTURES FROM DELEGATES TESTS
1534 typedef SmallStruct1 (STDCALL *SmallStructDelegate1) (SmallStruct1 ss);
1537 mono_test_marshal_small_struct_delegate1 (SmallStructDelegate1 delegate)
1539 SmallStruct1 ss, res;
1543 res = delegate (ss);
1544 if (! (res.i == -1))
1554 typedef SmallStruct2 (STDCALL *SmallStructDelegate2) (SmallStruct2 ss);
1557 mono_test_marshal_small_struct_delegate2 (SmallStructDelegate2 delegate)
1559 SmallStruct2 ss, res;
1564 res = delegate (ss);
1565 if (! ((res.i == -2) && (res.j == -3)))
1576 typedef SmallStruct3 (STDCALL *SmallStructDelegate3) (SmallStruct3 ss);
1579 mono_test_marshal_small_struct_delegate3 (SmallStructDelegate3 delegate)
1581 SmallStruct3 ss, res;
1586 res = delegate (ss);
1587 if (! ((res.i == -1) && (res.j == -2)))
1597 typedef SmallStruct4 (STDCALL *SmallStructDelegate4) (SmallStruct4 ss);
1600 mono_test_marshal_small_struct_delegate4 (SmallStructDelegate4 delegate)
1602 SmallStruct4 ss, res;
1606 res = delegate (ss);
1607 if (! (res.i == -1))
1617 typedef SmallStruct5 (STDCALL *SmallStructDelegate5) (SmallStruct5 ss);
1620 mono_test_marshal_small_struct_delegate5 (SmallStructDelegate5 delegate)
1622 SmallStruct5 ss, res;
1626 res = delegate (ss);
1627 if (! (res.i == -5))
1637 typedef SmallStruct6 (STDCALL *SmallStructDelegate6) (SmallStruct6 ss);
1640 mono_test_marshal_small_struct_delegate6 (SmallStructDelegate6 delegate)
1642 SmallStruct6 ss, res;
1647 res = delegate (ss);
1648 if (! ((res.i == -1) && (res.j == -2)))
1659 typedef SmallStruct7 (STDCALL *SmallStructDelegate7) (SmallStruct7 ss);
1662 mono_test_marshal_small_struct_delegate7 (SmallStructDelegate7 delegate)
1664 SmallStruct7 ss, res;
1669 res = delegate (ss);
1670 if (! ((res.i == -1) && (res.j == -2)))
1680 typedef SmallStruct8 (STDCALL *SmallStructDelegate8) (SmallStruct8 ss);
1683 mono_test_marshal_small_struct_delegate8 (SmallStructDelegate8 delegate)
1685 SmallStruct8 ss, res;
1689 res = delegate (ss);
1690 if (! ((res.i == -1.0)))
1700 typedef SmallStruct9 (STDCALL *SmallStructDelegate9) (SmallStruct9 ss);
1703 mono_test_marshal_small_struct_delegate9 (SmallStructDelegate9 delegate)
1705 SmallStruct9 ss, res;
1709 res = delegate (ss);
1710 if (! ((res.i == -1.0)))
1720 typedef SmallStruct10 (STDCALL *SmallStructDelegate10) (SmallStruct10 ss);
1723 mono_test_marshal_small_struct_delegate10 (SmallStructDelegate10 delegate)
1725 SmallStruct10 ss, res;
1730 res = delegate (ss);
1731 if (! ((res.i == -1.0) && (res.j == -2.0)))
1742 typedef SmallStruct11 (STDCALL *SmallStructDelegate11) (SmallStruct11 ss);
1745 mono_test_marshal_small_struct_delegate11 (SmallStructDelegate11 delegate)
1747 SmallStruct11 ss, res;
1752 res = delegate (ss);
1753 if (! ((res.i == -1.0) && (res.j == -2)))
1759 typedef int (STDCALL *ArrayDelegate) (int i, char *j, void *arr);
1762 mono_test_marshal_array_delegate (void *arr, int len, ArrayDelegate del)
1764 return del (len, NULL, arr);
1768 mono_test_marshal_out_array_delegate (int *arr, int len, ArrayDelegate del)
1770 del (len, NULL, arr);
1772 if ((arr [0] != 1) || (arr [1] != 2))
1779 mono_test_marshal_out_string_array_delegate (char **arr, int len, ArrayDelegate del)
1781 del (len, NULL, arr);
1783 if (!strcmp (arr [0], "ABC") && !strcmp (arr [1], "DEF"))
1789 typedef int (*CdeclDelegate) (int i, int j);
1792 mono_test_marshal_cdecl_delegate (CdeclDelegate del)
1796 for (i = 0; i < 1000; ++i)
1802 typedef char** (*ReturnStringArrayDelegate) (int i);
1805 mono_test_marshal_return_string_array_delegate (ReturnStringArrayDelegate d)
1813 if (strcmp (arr [0], "ABC") || strcmp (arr [1], "DEF"))