16 #define STDCALL __stdcall
22 #pragma GCC diagnostic ignored "-Wmissing-prototypes"
26 extern __declspec(dllimport) void __stdcall CoTaskMemFree(void *ptr);
29 typedef int (STDCALL *SimpleDelegate) (int a);
31 #if defined(WIN32) && defined (_MSC_VER)
32 #define LIBTEST_API __declspec(dllexport)
37 static void marshal_free (void *ptr)
46 static void* marshal_alloc (gsize size)
49 return CoTaskMemAlloc (size);
51 return g_malloc (size);
55 LIBTEST_API unsigned short* STDCALL
56 test_lpwstr_marshal (unsigned short* chars, long length)
61 res = marshal_alloc (2 * (length + 1));
63 // printf("test_lpwstr_marshal()\n");
65 while ( i < length ) {
66 // printf("X|%u|\n", chars[i]);
77 LIBTEST_API void STDCALL
78 test_lpwstr_marshal_out (unsigned short** chars)
81 const char abc[] = "ABC";
82 glong len = strlen(abc);
84 *chars = marshal_alloc (2 * (len + 1));
87 (*chars) [i] = abc[i];
100 LIBTEST_API int STDCALL
101 mono_union_test_1 (union_test_1_type u1) {
102 // printf ("Got values %d %d %d\n", u1.b, u1.a, u1.c);
103 return u1.a + u1.b + u1.c;
106 LIBTEST_API int STDCALL
107 mono_return_int (int a) {
108 // printf ("Got value %d\n", a);
112 LIBTEST_API float STDCALL
113 mono_test_marshal_pass_return_float (float f) {
122 LIBTEST_API int STDCALL
123 mono_return_int_ss (struct ss a) {
124 // printf ("Got value %d\n", a.i);
128 LIBTEST_API struct ss STDCALL
129 mono_return_ss (struct ss a) {
130 // printf ("Got value %d\n", a.i);
140 LIBTEST_API struct sc1 STDCALL
141 mono_return_sc1 (struct sc1 a) {
142 // printf ("Got value %d\n", a.c[0]);
153 LIBTEST_API struct sc3 STDCALL
154 mono_return_sc3 (struct sc3 a) {
155 // printf ("Got values %d %d %d\n", a.c[0], a.c[1], a.c[2]);
167 LIBTEST_API struct sc5 STDCALL
168 mono_return_sc5 (struct sc5 a) {
169 // printf ("Got values %d %d %d %d %d\n", a.c[0], a.c[1], a.c[2], a.c[3], a.c[4]);
184 LIBTEST_API int STDCALL
185 mono_return_int_su (union su a) {
186 // printf ("Got value %d\n", a.i1);
190 LIBTEST_API int STDCALL
191 mono_test_many_int_arguments (int a, int b, int c, int d, int e,
192 int f, int g, int h, int i, int j);
193 LIBTEST_API short STDCALL
194 mono_test_many_short_arguments (short a, short b, short c, short d, short e,
195 short f, short g, short h, short i, short j);
196 LIBTEST_API char STDCALL
197 mono_test_many_char_arguments (char a, char b, char c, char d, char e,
198 char f, char g, char h, char i, char j);
200 LIBTEST_API int STDCALL
201 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)
203 return a + b + c + d + e + f + g + h + i + j;
206 LIBTEST_API short STDCALL
207 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)
209 return a + b + c + d + e + f + g + h + i + j;
212 LIBTEST_API char STDCALL
213 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)
215 return a + b + c + d + e + f + g + h + i + j;
218 LIBTEST_API float STDCALL
219 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)
221 return a + b + c + d + e + f + g + h + i + j;
224 LIBTEST_API double STDCALL
225 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)
227 return a + b + c + d + e + f + g + h + i + j;
230 LIBTEST_API double STDCALL
231 mono_test_split_double_arguments (double a, double b, float c, double d, double e)
233 return a + b + c + d + e;
236 LIBTEST_API int STDCALL
237 mono_test_puts_static (char *s)
239 // printf ("TEST %s\n", s);
243 typedef int (STDCALL *SimpleDelegate3) (int a, int b);
245 LIBTEST_API int STDCALL
246 mono_invoke_delegate (SimpleDelegate3 delegate)
250 // printf ("start invoke %p\n", delegate);
252 res = delegate (2, 3);
254 // printf ("end invoke\n");
259 LIBTEST_API int STDCALL
260 mono_invoke_simple_delegate (SimpleDelegate d)
265 LIBTEST_API int STDCALL
266 mono_test_marshal_char (short a1)
274 LIBTEST_API void STDCALL
275 mono_test_marshal_char_array (gunichar2 *s)
277 const char m[] = "abcdef";
281 s2 = g_utf8_to_utf16 (m, -1, NULL, &len, NULL);
289 LIBTEST_API int STDCALL
290 mono_test_empty_pinvoke (int i)
295 LIBTEST_API int STDCALL
296 mono_test_marshal_bool_byref (int a, int *b, int c)
305 LIBTEST_API int STDCALL
306 mono_test_marshal_bool_in_as_I1_U1 (char bTrue, char bFalse)
315 LIBTEST_API int STDCALL
316 mono_test_marshal_bool_out_as_I1_U1 (char* bTrue, char* bFalse)
318 if (!bTrue || !bFalse)
327 LIBTEST_API int STDCALL
328 mono_test_marshal_bool_ref_as_I1_U1 (char* bTrue, char* bFalse)
330 if (!bTrue || !bFalse)
344 LIBTEST_API int STDCALL
345 mono_test_marshal_array (int *a1)
349 for (i = 0; i < 50; i++)
355 LIBTEST_API int STDCALL
356 mono_test_marshal_inout_array (int *a1)
360 for (i = 0; i < 50; i++) {
362 a1 [i] = 50 - a1 [i];
368 LIBTEST_API int STDCALL
369 mono_test_marshal_out_array (int *a1)
373 for (i = 0; i < 50; i++) {
380 LIBTEST_API int STDCALL
381 mono_test_marshal_inout_nonblittable_array (gunichar2 *a1)
385 for (i = 0; i < 10; i++) {
405 LIBTEST_API simplestruct STDCALL
406 mono_test_return_vtype (int i)
409 static gunichar2 test2 [] = { 'T', 'E', 'S', 'T', '2', 0 };
420 LIBTEST_API void STDCALL
421 mono_test_delegate_struct (void)
423 // printf ("TEST\n");
426 typedef char* (STDCALL *ReturnStringDelegate) (const char *s);
428 LIBTEST_API char * STDCALL
429 mono_test_return_string (ReturnStringDelegate func)
433 // printf ("mono_test_return_string\n");
438 // printf ("got string: %s\n", res);
439 return g_strdup ("12345");
442 typedef int (STDCALL *RefVTypeDelegate) (int a, simplestruct *ss, int b);
444 LIBTEST_API int STDCALL
445 mono_test_ref_vtype (int a, simplestruct *ss, int b, RefVTypeDelegate func)
447 if (a == 1 && b == 2 && ss->a == 0 && ss->b == 1 && ss->c == 0 &&
448 !strcmp (ss->d, "TEST1")) {
454 return func (a, ss, b);
460 typedef int (STDCALL *OutVTypeDelegate) (int a, simplestruct *ss, int b);
462 LIBTEST_API int STDCALL
463 mono_test_marshal_out_struct (int a, simplestruct *ss, int b, OutVTypeDelegate func)
465 /* Check that the input pointer is ignored */
466 ss->d = (gpointer)0x12345678;
470 if (ss->a && ss->b && ss->c && !strcmp (ss->d, "TEST3"))
478 SimpleDelegate func, func2, func3;
481 LIBTEST_API DelegateStruct STDCALL
482 mono_test_marshal_delegate_struct (DelegateStruct ds)
486 res.a = ds.func (ds.a) + ds.func2 (ds.a) + (ds.func3 == NULL ? 0 : 1);
488 res.func2 = ds.func2;
494 LIBTEST_API int STDCALL
495 mono_test_marshal_struct (simplestruct ss)
497 if (ss.a == 0 && ss.b == 1 && ss.c == 0 &&
498 !strcmp (ss.d, "TEST"))
504 LIBTEST_API int STDCALL
505 mono_test_marshal_byref_struct (simplestruct *ss, int a, int b, int c, char *d)
507 gboolean res = (ss->a == a && ss->b == b && ss->c == c && strcmp (ss->d, d) == 0);
509 marshal_free ((char*)ss->d);
514 ss->d = g_strdup ("DEF");
530 LIBTEST_API int STDCALL
531 mono_test_marshal_struct2 (simplestruct2 ss)
533 if (ss.a == 0 && ss.b == 1 && ss.c == 0 &&
534 !strcmp (ss.d, "TEST") &&
535 ss.e == 99 && ss.f == 1.5 && ss.g == 42 && ss.h == (guint64)123)
541 /* on HP some of the struct should be on the stack and not in registers */
542 LIBTEST_API int STDCALL
543 mono_test_marshal_struct2_2 (int i, int j, int k, simplestruct2 ss)
545 if (i != 10 || j != 11 || k != 12)
547 if (ss.a == 0 && ss.b == 1 && ss.c == 0 &&
548 !strcmp (ss.d, "TEST") &&
549 ss.e == 99 && ss.f == 1.5 && ss.g == 42 && ss.h == (guint64)123)
555 LIBTEST_API int STDCALL
556 mono_test_marshal_lpstruct (simplestruct *ss)
558 if (ss->a == 0 && ss->b == 1 && ss->c == 0 &&
559 !strcmp (ss->d, "TEST"))
565 LIBTEST_API int STDCALL
566 mono_test_marshal_lpstruct_blittable (point *p)
568 if (p->x == 1.0 && p->y == 2.0)
574 LIBTEST_API int STDCALL
575 mono_test_marshal_struct_array (simplestruct2 *ss)
577 if (! (ss[0].a == 0 && ss[0].b == 1 && ss[0].c == 0 &&
578 !strcmp (ss[0].d, "TEST") &&
579 ss[0].e == 99 && ss[0].f == 1.5 && ss[0].g == 42 && ss[0].h == (guint64)123))
582 if (! (ss[1].a == 0 && ss[1].b == 0 && ss[1].c == 0 &&
583 !strcmp (ss[1].d, "TEST2") &&
584 ss[1].e == 100 && ss[1].f == 2.5 && ss[1].g == 43 && ss[1].h == (guint64)124))
590 typedef struct long_align_struct {
596 LIBTEST_API int STDCALL
597 mono_test_marshal_long_align_struct_array (long_align_struct *ss)
599 return ss[0].a + ss[0].b + ss[0].c + ss[1].a + ss[1].b + ss[1].c;
602 LIBTEST_API simplestruct2 * STDCALL
603 mono_test_marshal_class (int i, int j, int k, simplestruct2 *ss, int l)
610 if (i != 10 || j != 11 || k != 12 || l != 14)
612 if (! (ss->a == 0 && ss->b == 1 && ss->c == 0 &&
613 !strcmp (ss->d, "TEST") &&
614 ss->e == 99 && ss->f == 1.5 && ss->g == 42 && ss->h == (guint64)123))
617 res = g_new0 (simplestruct2, 1);
618 memcpy (res, ss, sizeof (simplestruct2));
619 res->d = g_strdup ("TEST");
623 LIBTEST_API int STDCALL
624 mono_test_marshal_byref_class (simplestruct2 **ssp)
626 simplestruct2 *ss = *ssp;
629 if (! (ss->a == 0 && ss->b == 1 && ss->c == 0 &&
630 !strcmp (ss->d, "TEST") &&
631 ss->e == 99 && ss->f == 1.5 && ss->g == 42 && ss->h == (guint64)123))
634 res = g_new0 (simplestruct2, 1);
635 memcpy (res, ss, sizeof (simplestruct2));
636 res->d = g_strdup ("TEST-RES");
648 /* Yes, this is correct, we are only trying to determine the value of the stack here */
653 LIBTEST_API int STDCALL
654 reliable_delegate (int a)
660 * Checks whether get_sp() works as expected. It doesn't work with gcc-2.95.3 on linux.
663 is_get_sp_reliable (void)
667 reliable_delegate(1);
669 reliable_delegate(1);
674 LIBTEST_API int STDCALL
675 mono_test_marshal_delegate (SimpleDelegate delegate)
679 /* Check that the delegate wrapper is stdcall */
684 if (is_get_sp_reliable())
685 g_assert (sp1 == sp2);
690 static int STDCALL inc_cb (int i)
695 LIBTEST_API int STDCALL
696 mono_test_marshal_out_delegate (SimpleDelegate *delegate)
703 LIBTEST_API SimpleDelegate STDCALL
704 mono_test_marshal_return_delegate (SimpleDelegate delegate)
710 return_plus_one (int i)
715 LIBTEST_API SimpleDelegate STDCALL
716 mono_test_marshal_return_delegate_2 (void)
718 return return_plus_one;
721 typedef simplestruct (STDCALL *SimpleDelegate2) (simplestruct ss);
724 is_utf16_equals (gunichar2 *s1, const char *s2)
729 s = g_utf16_to_utf8 (s1, -1, NULL, NULL, NULL);
730 res = strcmp (s, s2);
736 LIBTEST_API int STDCALL
737 mono_test_marshal_delegate2 (SimpleDelegate2 delegate)
739 simplestruct ss, res;
745 ss.d2 = g_utf8_to_utf16 ("TEST2", -1, NULL, NULL, NULL);
748 if (! (res.a && !res.b && res.c && !strcmp (res.d, "TEST-RES") && is_utf16_equals (res.d2, "TEST2-RES")))
754 typedef simplestruct* (STDCALL *SimpleDelegate4) (simplestruct *ss);
756 LIBTEST_API int STDCALL
757 mono_test_marshal_delegate4 (SimpleDelegate4 delegate)
768 res = delegate (&ss);
772 /* Check return value */
773 if (! (!res->a && res->b && !res->c && !strcmp (res->d, "TEST")))
776 /* Check NULL argument and NULL result */
777 res = delegate (NULL);
784 typedef int (STDCALL *SimpleDelegate5) (simplestruct **ss);
786 LIBTEST_API int STDCALL
787 mono_test_marshal_delegate5 (SimpleDelegate5 delegate)
800 res = delegate (&ptr);
804 if (!(ptr->a && !ptr->b && ptr->c && !strcmp (ptr->d, "RES")))
810 LIBTEST_API int STDCALL
811 mono_test_marshal_delegate6 (SimpleDelegate5 delegate)
815 res = delegate (NULL);
820 typedef int (STDCALL *SimpleDelegate7) (simplestruct **ss);
822 LIBTEST_API int STDCALL
823 mono_test_marshal_delegate7 (SimpleDelegate7 delegate)
828 /* Check that the input pointer is ignored */
829 ptr = (gpointer)0x12345678;
831 res = delegate (&ptr);
835 if (!(ptr->a && !ptr->b && ptr->c && !strcmp (ptr->d, "RES")))
841 typedef int (STDCALL *InOutByvalClassDelegate) (simplestruct *ss);
843 LIBTEST_API int STDCALL
844 mono_test_marshal_inout_byval_class_delegate (InOutByvalClassDelegate delegate)
852 ss.d = g_strdup_printf ("%s", "FOO");
854 res = delegate (&ss);
858 if (!(ss.a && !ss.b && ss.c && !strcmp (ss.d, "RES")))
864 typedef int (STDCALL *SimpleDelegate8) (gunichar2 *s);
866 LIBTEST_API int STDCALL
867 mono_test_marshal_delegate8 (SimpleDelegate8 delegate, gunichar2 *s)
872 typedef int (STDCALL *return_int_fnt) (int i);
873 typedef int (STDCALL *SimpleDelegate9) (return_int_fnt d);
875 LIBTEST_API int STDCALL
876 mono_test_marshal_delegate9 (SimpleDelegate9 delegate, gpointer ftn)
878 return delegate (ftn);
887 LIBTEST_API int STDCALL
888 mono_test_marshal_delegate10 (SimpleDelegate9 delegate)
890 return delegate (return_self);
893 typedef int (STDCALL *PrimitiveByrefDelegate) (int *i);
895 LIBTEST_API int STDCALL
896 mono_test_marshal_primitive_byref_delegate (PrimitiveByrefDelegate delegate)
900 int res = delegate (&i);
910 typedef int (STDCALL *return_int_delegate) (int i);
912 typedef return_int_delegate (STDCALL *ReturnDelegateDelegate) (void);
914 LIBTEST_API int STDCALL
915 mono_test_marshal_return_delegate_delegate (ReturnDelegateDelegate d)
920 LIBTEST_API int STDCALL
921 mono_test_marshal_stringbuilder (char *s, int n)
923 const char m[] = "This is my message. Isn't it nice?";
925 if (strcmp (s, "ABCD") != 0)
932 LIBTEST_API int STDCALL
933 mono_test_marshal_stringbuilder_default (char *s, int n)
935 const char m[] = "This is my message. Isn't it nice?";
942 LIBTEST_API int STDCALL
943 mono_test_marshal_stringbuilder_unicode (gunichar2 *s, int n)
945 const char m[] = "This is my message. Isn't it nice?";
949 s2 = g_utf8_to_utf16 (m, -1, NULL, &len, NULL);
967 LIBTEST_API int STDCALL
968 mono_test_marshal_empty_string_array (char **array)
970 return (array == NULL) ? 0 : 1;
973 LIBTEST_API int STDCALL
974 mono_test_marshal_string_array (char **array)
976 if (strcmp (array [0], "ABC"))
978 if (strcmp (array [1], "DEF"))
981 if (array [2] != NULL)
987 LIBTEST_API int STDCALL
988 mono_test_marshal_byref_string_array (char ***array)
993 if (strcmp ((*array) [0], "Alpha"))
995 if (strcmp ((*array) [1], "Beta"))
997 if (strcmp ((*array) [2], "Gamma"))
1003 LIBTEST_API int STDCALL
1004 mono_test_marshal_stringbuilder_array (char **array)
1006 if (strcmp (array [0], "ABC"))
1008 if (strcmp (array [1], "DEF"))
1011 strcpy (array [0], "DEF");
1012 strcpy (array [1], "ABC");
1017 LIBTEST_API int STDCALL
1018 mono_test_marshal_unicode_string_array (gunichar2 **array, char **array2)
1020 GError *error = NULL;
1023 s = g_utf16_to_utf8 (array [0], -1, NULL, NULL, &error);
1024 if (strcmp (s, "ABC")) {
1031 s = g_utf16_to_utf8 (array [1], -1, NULL, NULL, &error);
1032 if (strcmp (s, "DEF")) {
1039 if (strcmp (array2 [0], "ABC"))
1042 if (strcmp (array2 [1], "DEF"))
1048 /* this does not work on Redhat gcc 2.96 */
1049 LIBTEST_API int STDCALL
1050 mono_test_empty_struct (int a, EmptyStruct es, int b)
1052 // printf ("mono_test_empty_struct %d %d\n", a, b);
1054 // Intel icc on ia64 passes 'es' in 2 registers
1055 #if defined(__ia64) && defined(__INTEL_COMPILER)
1058 if (a == 1 && b == 2)
1068 LIBTEST_API ByValStrStruct * STDCALL
1069 mono_test_byvalstr_gen (void)
1071 ByValStrStruct *ret;
1073 ret = malloc(sizeof(ByValStrStruct));
1074 memset(ret, 'a', sizeof(ByValStrStruct)-1);
1075 ret->a[sizeof(ByValStrStruct)-1] = 0;
1080 LIBTEST_API int STDCALL
1081 mono_test_byvalstr_check (ByValStrStruct* data, char* correctString)
1085 ret = strcmp(data->a, correctString);
1086 // printf ("T1: %s\n", data->a);
1087 // printf ("T2: %s\n", correctString);
1089 marshal_free (data);
1096 } ByValStrStruct_Unicode;
1098 LIBTEST_API int STDCALL
1099 mono_test_byvalstr_check_unicode (ByValStrStruct_Unicode *ref, int test)
1101 if (ref->flag != 0x1234abcd){
1102 printf ("overwritten data");
1106 if (test == 1 || test == 3){
1107 if (ref->a [0] != '1' ||
1108 ref->a [1] != '2' ||
1114 if (ref->a [0] != '1' ||
1122 LIBTEST_API int STDCALL
1123 NameManglingAnsi (char *data)
1125 return data [0] + data [1] + data [2];
1128 LIBTEST_API int STDCALL
1129 NameManglingAnsiA (char *data)
1131 g_assert_not_reached ();
1134 LIBTEST_API int STDCALL
1135 NameManglingAnsiW (char *data)
1137 g_assert_not_reached ();
1140 LIBTEST_API int STDCALL
1141 NameManglingAnsi2A (char *data)
1143 return data [0] + data [1] + data [2];
1146 LIBTEST_API int STDCALL
1147 NameManglingAnsi2W (char *data)
1149 g_assert_not_reached ();
1152 LIBTEST_API int STDCALL
1153 NameManglingUnicode (char *data)
1155 g_assert_not_reached ();
1158 LIBTEST_API int STDCALL
1159 NameManglingUnicodeW (gunichar2 *data)
1161 return data [0] + data [1] + data [2];
1164 LIBTEST_API int STDCALL
1165 NameManglingUnicode2 (gunichar2 *data)
1167 return data [0] + data [1] + data [2];
1170 LIBTEST_API int STDCALL
1171 NameManglingAutoW (char *data)
1174 return (data [0] + data [1] + data [2]) == 131 ? 0 : 1;
1176 g_assert_not_reached ();
1180 LIBTEST_API int STDCALL
1181 NameManglingAuto (char *data)
1184 return (data [0] + data [1] + data [2]) == 198 ? 0 : 1;
1186 g_assert_not_reached ();
1190 typedef int (STDCALL *intcharFunc)(const char*);
1192 LIBTEST_API void STDCALL
1193 callFunction (intcharFunc f)
1203 LIBTEST_API int STDCALL
1204 class_marshal_test0 (SimpleObj *obj1)
1206 // printf ("class_marshal_test0 %s %d\n", obj1->str, obj1->i);
1208 if (strcmp(obj1->str, "T1"))
1216 LIBTEST_API int STDCALL
1217 class_marshal_test4 (SimpleObj *obj1)
1225 LIBTEST_API void STDCALL
1226 class_marshal_test1 (SimpleObj **obj1)
1228 SimpleObj *res = malloc (sizeof (SimpleObj));
1230 res->str = g_strdup ("ABC");
1236 LIBTEST_API int STDCALL
1237 class_marshal_test2 (SimpleObj **obj1)
1239 // printf ("class_marshal_test2 %s %d\n", (*obj1)->str, (*obj1)->i);
1241 if (strcmp((*obj1)->str, "ABC"))
1243 if ((*obj1)->i != 5)
1249 LIBTEST_API int STDCALL
1250 string_marshal_test0 (char *str)
1252 if (strcmp (str, "TEST0"))
1258 LIBTEST_API void STDCALL
1259 string_marshal_test1 (const char **str)
1261 *str = g_strdup ("TEST1");
1264 LIBTEST_API int STDCALL
1265 string_marshal_test2 (char **str)
1267 // printf ("string_marshal_test2 %s\n", *str);
1269 if (strcmp (*str, "TEST1"))
1275 LIBTEST_API int STDCALL
1276 string_marshal_test3 (char *str)
1289 LIBTEST_API BlittableClass* STDCALL
1290 TestBlittableClass (BlittableClass *vl)
1292 BlittableClass *res;
1294 // printf ("TestBlittableClass %d %d\n", vl->a, vl->b);
1300 res = g_new0 (BlittableClass, 1);
1301 memcpy (res, vl, sizeof (BlittableClass));
1303 res = g_new0 (BlittableClass, 1);
1311 typedef struct OSVERSIONINFO_STRUCT
1315 } OSVERSIONINFO_STRUCT;
1317 LIBTEST_API int STDCALL
1318 MyGetVersionEx (OSVERSIONINFO_STRUCT *osvi)
1321 // printf ("GOT %d %d\n", osvi->a, osvi->b);
1326 return osvi->a + osvi->b;
1329 LIBTEST_API int STDCALL
1330 BugGetVersionEx (int a, int b, int c, int d, int e, int f, int g, int h, OSVERSIONINFO_STRUCT *osvi)
1333 // printf ("GOT %d %d\n", osvi->a, osvi->b);
1338 return osvi->a + osvi->b;
1341 LIBTEST_API int STDCALL
1342 mono_test_marshal_point (point pt)
1344 // printf("point %g %g\n", pt.x, pt.y);
1345 if (pt.x == 1.25 && pt.y == 3.5)
1356 LIBTEST_API int STDCALL
1357 mono_test_marshal_mixed_point (mixed_point pt)
1359 // printf("mixed point %d %g\n", pt.x, pt.y);
1360 if (pt.x == 5 && pt.y == 6.75)
1366 LIBTEST_API int STDCALL
1367 mono_test_marshal_mixed_point_2 (mixed_point *pt)
1369 if (pt->x != 5 || pt->y != 6.75)
1378 LIBTEST_API int STDCALL
1379 marshal_test_ref_bool(int i, char *b1, short *b2, int *b3)
1382 if (*b1 != 0 && *b1 != 1)
1384 if (*b2 != 0 && *b2 != -1) /* variant_bool */
1386 if (*b3 != 0 && *b3 != 1)
1388 if (i == ((*b1 << 2) | (-*b2 << 1) | *b3))
1400 short b2; /* variant_bool */
1404 LIBTEST_API int STDCALL
1405 marshal_test_bool_struct(struct BoolStruct *s)
1408 if (s->b1 != 0 && s->b1 != 1)
1410 if (s->b2 != 0 && s->b2 != -1)
1412 if (s->b3 != 0 && s->b3 != 1)
1414 if (s->i == ((s->b1 << 2) | (-s->b2 << 1) | s->b3))
1431 LIBTEST_API int STDCALL
1432 mono_test_marshal_long_struct (LongStruct *s)
1434 return s->i + s->l.l;
1437 LIBTEST_API void STDCALL
1438 mono_test_last_error (int err)
1447 LIBTEST_API int STDCALL
1448 mono_test_asany (void *ptr, int what)
1452 return (*(int*)ptr == 5) ? 0 : 1;
1454 return strcmp (ptr, "ABC") == 0 ? 0 : 1;
1456 simplestruct2 ss = *(simplestruct2*)ptr;
1458 if (ss.a == 0 && ss.b == 1 && ss.c == 0 &&
1459 !strcmp (ss.d, "TEST") &&
1460 ss.e == 99 && ss.f == 1.5 && ss.g == 42 && ss.h == (guint64)123)
1466 GError *error = NULL;
1469 s = g_utf16_to_utf8 (ptr, -1, NULL, NULL, &error);
1470 if (!strcmp (s, "ABC")) {
1480 g_assert_not_reached ();
1494 LIBTEST_API int STDCALL
1495 mono_test_marshal_asany_in (void* ptr)
1497 AsAnyStruct* asAny = ptr;
1498 int res = asAny->i + asAny->j + asAny->k;
1503 LIBTEST_API int STDCALL
1504 mono_test_marshal_asany_inout (void* ptr)
1506 AsAnyStruct* asAny = ptr;
1507 int res = asAny->i + asAny->j + asAny->k;
1509 marshal_free (asAny->s);
1519 LIBTEST_API int STDCALL
1520 mono_test_marshal_asany_out (void* ptr)
1522 AsAnyStruct* asAny = ptr;
1523 int res = asAny->i + asAny->j + asAny->k;
1534 * AMD64 marshalling tests.
1537 typedef struct amd64_struct1 {
1544 LIBTEST_API amd64_struct1 STDCALL
1545 mono_test_marshal_amd64_pass_return_struct1 (amd64_struct1 s)
1555 LIBTEST_API amd64_struct1 STDCALL
1556 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)
1561 s.l += 1 + i1 + i2 + i3 + i4 + i5 + i6 + i7 + i8;
1566 typedef struct amd64_struct2 {
1571 LIBTEST_API amd64_struct2 STDCALL
1572 mono_test_marshal_amd64_pass_return_struct2 (amd64_struct2 s)
1580 typedef struct amd64_struct3 {
1584 LIBTEST_API amd64_struct3 STDCALL
1585 mono_test_marshal_amd64_pass_return_struct3 (amd64_struct3 s)
1592 typedef struct amd64_struct4 {
1596 LIBTEST_API amd64_struct4 STDCALL
1597 mono_test_marshal_amd64_pass_return_struct4 (amd64_struct4 s)
1606 * IA64 marshalling tests.
1608 typedef struct test_struct5 {
1612 LIBTEST_API test_struct5 STDCALL
1613 mono_test_marshal_ia64_pass_return_struct5 (double d1, double d2, test_struct5 s, int i, double d3, double d4)
1615 s.d1 += d1 + d2 + i;
1616 s.d2 += d3 + d4 + i;
1621 typedef struct test_struct6 {
1625 LIBTEST_API test_struct6 STDCALL
1626 mono_test_marshal_ia64_pass_return_struct6 (double d1, double d2, test_struct6 s, int i, double d3, double d4)
1628 s.d1 += d1 + d2 + i;
1634 static guint32 custom_res [2];
1636 LIBTEST_API void* STDCALL
1637 mono_test_marshal_pass_return_custom (int i, guint32 *ptr, int j)
1639 /* ptr will be freed by CleanupNative, so make a copy */
1640 custom_res [0] = 0; /* not allocated by AllocHGlobal */
1641 custom_res [1] = ptr [1];
1646 LIBTEST_API int STDCALL
1647 mono_test_marshal_pass_out_custom (int i, guint32 **ptr, int j)
1650 custom_res [1] = i + j + 10;
1657 LIBTEST_API int STDCALL
1658 mono_test_marshal_pass_inout_custom (int i, guint32 *ptr, int j)
1661 ptr [1] = i + ptr [1] + j;
1666 LIBTEST_API int STDCALL
1667 mono_test_marshal_pass_out_byval_custom (int i, guint32 *ptr, int j)
1669 return ptr == NULL ? 0 : 1;
1672 LIBTEST_API int STDCALL
1673 mono_test_marshal_pass_byref_custom (int i, guint32 **ptr, int j)
1680 LIBTEST_API void* STDCALL
1681 mono_test_marshal_pass_return_custom2 (int i, guint32 *ptr, int j)
1683 g_assert_not_reached ();
1688 LIBTEST_API void* STDCALL
1689 mono_test_marshal_pass_return_custom_null (int i, guint32 *ptr, int j)
1691 g_assert (ptr == NULL);
1696 typedef void *(STDCALL *PassReturnPtrDelegate) (void *ptr);
1698 LIBTEST_API int STDCALL
1699 mono_test_marshal_pass_return_custom_in_delegate (PassReturnPtrDelegate del)
1713 /* FIXME: Freed with FreeHGlobal */
1721 LIBTEST_API int STDCALL
1722 mono_test_marshal_pass_return_custom_null_in_delegate (PassReturnPtrDelegate del)
1724 void *ptr = del (NULL);
1726 return (ptr == NULL) ? 15 : 0;
1729 typedef void (STDCALL *CustomOutParamDelegate) (void **pptr);
1731 LIBTEST_API int STDCALL
1732 mono_test_marshal_custom_out_param_delegate (CustomOutParamDelegate del)
1744 typedef int (STDCALL *ReturnEnumDelegate) (int e);
1746 LIBTEST_API int STDCALL
1747 mono_test_marshal_return_enum_delegate (ReturnEnumDelegate func)
1757 typedef BlittableStruct (STDCALL *SimpleDelegate10) (BlittableStruct ss);
1759 LIBTEST_API int STDCALL
1760 mono_test_marshal_blittable_struct_delegate (SimpleDelegate10 delegate)
1762 BlittableStruct ss, res;
1769 res = delegate (ss);
1770 if (! ((res.a == -1) && (res.b == -2) && (res.c == -3) && (res.d == -55)))
1776 LIBTEST_API int STDCALL
1777 mono_test_stdcall_name_mangling (int a, int b, int c)
1783 * PASSING AND RETURNING SMALL STRUCTURES FROM DELEGATES TESTS
1790 typedef SmallStruct1 (STDCALL *SmallStructDelegate1) (SmallStruct1 ss);
1792 LIBTEST_API int STDCALL
1793 mono_test_marshal_small_struct_delegate1 (SmallStructDelegate1 delegate)
1795 SmallStruct1 ss, res;
1799 res = delegate (ss);
1800 if (! (res.i == -1))
1810 typedef SmallStruct2 (STDCALL *SmallStructDelegate2) (SmallStruct2 ss);
1812 LIBTEST_API int STDCALL
1813 mono_test_marshal_small_struct_delegate2 (SmallStructDelegate2 delegate)
1815 SmallStruct2 ss, res;
1820 res = delegate (ss);
1821 if (! ((res.i == -2) && (res.j == -3)))
1832 typedef SmallStruct3 (STDCALL *SmallStructDelegate3) (SmallStruct3 ss);
1834 LIBTEST_API int STDCALL
1835 mono_test_marshal_small_struct_delegate3 (SmallStructDelegate3 delegate)
1837 SmallStruct3 ss, res;
1842 res = delegate (ss);
1843 if (! ((res.i == -1) && (res.j == -2)))
1853 typedef SmallStruct4 (STDCALL *SmallStructDelegate4) (SmallStruct4 ss);
1855 LIBTEST_API int STDCALL
1856 mono_test_marshal_small_struct_delegate4 (SmallStructDelegate4 delegate)
1858 SmallStruct4 ss, res;
1862 res = delegate (ss);
1863 if (! (res.i == -1))
1873 typedef SmallStruct5 (STDCALL *SmallStructDelegate5) (SmallStruct5 ss);
1875 LIBTEST_API int STDCALL
1876 mono_test_marshal_small_struct_delegate5 (SmallStructDelegate5 delegate)
1878 SmallStruct5 ss, res;
1882 res = delegate (ss);
1883 if (! (res.i == -5))
1893 typedef SmallStruct6 (STDCALL *SmallStructDelegate6) (SmallStruct6 ss);
1895 LIBTEST_API int STDCALL
1896 mono_test_marshal_small_struct_delegate6 (SmallStructDelegate6 delegate)
1898 SmallStruct6 ss, res;
1903 res = delegate (ss);
1904 if (! ((res.i == -1) && (res.j == -2)))
1915 typedef SmallStruct7 (STDCALL *SmallStructDelegate7) (SmallStruct7 ss);
1917 LIBTEST_API int STDCALL
1918 mono_test_marshal_small_struct_delegate7 (SmallStructDelegate7 delegate)
1920 SmallStruct7 ss, res;
1925 res = delegate (ss);
1926 if (! ((res.i == -1) && (res.j == -2)))
1936 typedef SmallStruct8 (STDCALL *SmallStructDelegate8) (SmallStruct8 ss);
1938 LIBTEST_API int STDCALL
1939 mono_test_marshal_small_struct_delegate8 (SmallStructDelegate8 delegate)
1941 SmallStruct8 ss, res;
1945 res = delegate (ss);
1946 if (! ((res.i == -1.0)))
1956 typedef SmallStruct9 (STDCALL *SmallStructDelegate9) (SmallStruct9 ss);
1958 LIBTEST_API int STDCALL
1959 mono_test_marshal_small_struct_delegate9 (SmallStructDelegate9 delegate)
1961 SmallStruct9 ss, res;
1965 res = delegate (ss);
1966 if (! ((res.i == -1.0)))
1976 typedef SmallStruct10 (STDCALL *SmallStructDelegate10) (SmallStruct10 ss);
1978 LIBTEST_API int STDCALL
1979 mono_test_marshal_small_struct_delegate10 (SmallStructDelegate10 delegate)
1981 SmallStruct10 ss, res;
1986 res = delegate (ss);
1987 if (! ((res.i == -1.0) && (res.j == -2.0)))
1998 typedef SmallStruct11 (STDCALL *SmallStructDelegate11) (SmallStruct11 ss);
2000 LIBTEST_API int STDCALL
2001 mono_test_marshal_small_struct_delegate11 (SmallStructDelegate11 delegate)
2003 SmallStruct11 ss, res;
2008 res = delegate (ss);
2009 if (! ((res.i == -1.0) && (res.j == -2)))
2015 typedef int (STDCALL *ArrayDelegate) (int i, char *j, void *arr);
2017 LIBTEST_API int STDCALL
2018 mono_test_marshal_array_delegate (void *arr, int len, ArrayDelegate del)
2020 return del (len, NULL, arr);
2023 LIBTEST_API int STDCALL
2024 mono_test_marshal_out_array_delegate (int *arr, int len, ArrayDelegate del)
2026 del (len, NULL, arr);
2028 if ((arr [0] != 1) || (arr [1] != 2))
2034 typedef gunichar2* (STDCALL *UnicodeStringDelegate) (gunichar2 *message);
2036 LIBTEST_API int STDCALL
2037 mono_test_marshal_return_unicode_string_delegate (UnicodeStringDelegate del)
2039 const char m[] = "abcdef";
2040 gunichar2 *s2, *res;
2043 s2 = g_utf8_to_utf16 (m, -1, NULL, &len, NULL);
2052 LIBTEST_API int STDCALL
2053 mono_test_marshal_out_string_array_delegate (char **arr, int len, ArrayDelegate del)
2055 del (len, NULL, arr);
2057 if (!strcmp (arr [0], "ABC") && !strcmp (arr [1], "DEF"))
2063 typedef int (*CdeclDelegate) (int i, int j);
2065 LIBTEST_API int STDCALL
2066 mono_test_marshal_cdecl_delegate (CdeclDelegate del)
2070 for (i = 0; i < 1000; ++i)
2076 typedef char** (STDCALL *ReturnStringArrayDelegate) (int i);
2078 LIBTEST_API int STDCALL
2079 mono_test_marshal_return_string_array_delegate (ReturnStringArrayDelegate d)
2087 if (strcmp (arr [0], "ABC") || strcmp (arr [1], "DEF"))
2097 typedef int (STDCALL *ByrefStringDelegate) (char **s);
2099 LIBTEST_API int STDCALL
2100 mono_test_marshal_byref_string_delegate (ByrefStringDelegate d)
2102 char *s = (char*)"ABC";
2109 if (!strcmp (s, "DEF"))
2119 LIBTEST_API int STDCALL
2120 add_delegate (int i, int j)
2125 LIBTEST_API gpointer STDCALL
2126 mono_test_marshal_return_fnptr (void)
2128 return &add_delegate;
2131 LIBTEST_API int STDCALL
2134 printf ("codigo %x\n", code);
2142 LIBTEST_API HandleRef STDCALL
2143 mono_xr_as_handle (int code)
2147 memset (&ref, 0, sizeof (ref));
2159 LIBTEST_API int STDCALL
2160 mono_safe_handle_struct_ref (HandleStructs *x)
2162 printf ("Dingus Ref! \n");
2163 printf ("Values: %d %d %p %p\n", x->a, x->b, x->handle1, x->handle2);
2169 if (x->handle1 != (void*) 0x7080feed)
2172 if (x->handle2 != (void*) 0x1234abcd)
2178 LIBTEST_API int STDCALL
2179 mono_safe_handle_struct (HandleStructs x)
2181 printf ("Dingus Standard! \n");
2182 printf ("Values: %d %d %p %p\n", x.a, x.b, x.handle1, x.handle2);
2188 if (x.handle1 != (void*) 0x7080feed)
2191 if (x.handle2 != (void*) 0x1234abcd)
2201 LIBTEST_API int STDCALL
2202 mono_safe_handle_struct_simple (TrivialHandle x)
2204 printf ("The value is %p\n", x.a);
2205 return ((int)(gsize)x.a) * 2;
2208 LIBTEST_API int STDCALL
2209 mono_safe_handle_return (void)
2214 LIBTEST_API void STDCALL
2215 mono_safe_handle_ref (void **handle)
2218 *handle = (void *) 0xbad;
2222 *handle = (void *) 0x800d;
2230 LIBTEST_API int STDCALL
2231 mono_test_marshal_bstr_in(BSTR bstr)
2233 if (!wcscmp(bstr, L"mono_test_marshal_bstr_in"))
2238 LIBTEST_API int STDCALL
2239 mono_test_marshal_bstr_out(BSTR* bstr)
2241 *bstr = SysAllocString(L"mono_test_marshal_bstr_out");
2245 LIBTEST_API int STDCALL
2246 mono_test_marshal_bstr_in_null(BSTR bstr)
2253 LIBTEST_API int STDCALL
2254 mono_test_marshal_bstr_out_null(BSTR* bstr)
2260 LIBTEST_API int STDCALL
2261 mono_test_marshal_variant_in_sbyte(VARIANT variant)
2263 if (variant.vt == VT_I1 && variant.cVal == 100)
2268 LIBTEST_API int STDCALL
2269 mono_test_marshal_variant_in_byte(VARIANT variant)
2271 if (variant.vt == VT_UI1 && variant.bVal == 100)
2276 LIBTEST_API int STDCALL
2277 mono_test_marshal_variant_in_short(VARIANT variant)
2279 if (variant.vt == VT_I2 && variant.iVal == 314)
2284 LIBTEST_API int STDCALL
2285 mono_test_marshal_variant_in_ushort(VARIANT variant)
2287 if (variant.vt == VT_UI2 && variant.uiVal == 314)
2292 LIBTEST_API int STDCALL
2293 mono_test_marshal_variant_in_int(VARIANT variant)
2295 if (variant.vt == VT_I4 && variant.lVal == 314)
2300 LIBTEST_API int STDCALL
2301 mono_test_marshal_variant_in_uint(VARIANT variant)
2303 if (variant.vt == VT_UI4 && variant.ulVal == 314)
2308 LIBTEST_API int STDCALL
2309 mono_test_marshal_variant_in_long(VARIANT variant)
2311 if (variant.vt == VT_I8 && variant.llVal == 314)
2316 LIBTEST_API int STDCALL
2317 mono_test_marshal_variant_in_ulong(VARIANT variant)
2319 if (variant.vt == VT_UI8 && variant.ullVal == 314)
2324 LIBTEST_API int STDCALL
2325 mono_test_marshal_variant_in_float(VARIANT variant)
2327 if (variant.vt == VT_R4 && (variant.fltVal - 3.14)/3.14 < .001)
2332 LIBTEST_API int STDCALL
2333 mono_test_marshal_variant_in_double(VARIANT variant)
2335 if (variant.vt == VT_R8 && (variant.dblVal - 3.14)/3.14 < .001)
2340 LIBTEST_API int STDCALL
2341 mono_test_marshal_variant_in_bstr(VARIANT variant)
2343 if (variant.vt == VT_BSTR && !wcscmp(variant.bstrVal, L"PI"))
2348 LIBTEST_API int STDCALL
2349 mono_test_marshal_variant_in_bool_true (VARIANT variant)
2351 if (variant.vt == VT_BOOL && variant.boolVal == VARIANT_TRUE)
2356 LIBTEST_API int STDCALL
2357 mono_test_marshal_variant_in_bool_false (VARIANT variant)
2359 if (variant.vt == VT_BOOL && variant.boolVal == VARIANT_FALSE)
2364 LIBTEST_API int STDCALL
2365 mono_test_marshal_variant_out_sbyte(VARIANT* variant)
2367 variant->vt = VT_I1;
2368 variant->cVal = 100;
2373 LIBTEST_API int STDCALL
2374 mono_test_marshal_variant_out_byte(VARIANT* variant)
2376 variant->vt = VT_UI1;
2377 variant->bVal = 100;
2382 LIBTEST_API int STDCALL
2383 mono_test_marshal_variant_out_short(VARIANT* variant)
2385 variant->vt = VT_I2;
2386 variant->iVal = 314;
2391 LIBTEST_API int STDCALL
2392 mono_test_marshal_variant_out_ushort(VARIANT* variant)
2394 variant->vt = VT_UI2;
2395 variant->uiVal = 314;
2400 LIBTEST_API int STDCALL
2401 mono_test_marshal_variant_out_int(VARIANT* variant)
2403 variant->vt = VT_I4;
2404 variant->lVal = 314;
2409 LIBTEST_API int STDCALL
2410 mono_test_marshal_variant_out_uint(VARIANT* variant)
2412 variant->vt = VT_UI4;
2413 variant->ulVal = 314;
2418 LIBTEST_API int STDCALL
2419 mono_test_marshal_variant_out_long(VARIANT* variant)
2421 variant->vt = VT_I8;
2422 variant->llVal = 314;
2427 LIBTEST_API int STDCALL
2428 mono_test_marshal_variant_out_ulong(VARIANT* variant)
2430 variant->vt = VT_UI8;
2431 variant->ullVal = 314;
2436 LIBTEST_API int STDCALL
2437 mono_test_marshal_variant_out_float(VARIANT* variant)
2439 variant->vt = VT_R4;
2440 variant->fltVal = 3.14;
2445 LIBTEST_API int STDCALL
2446 mono_test_marshal_variant_out_double(VARIANT* variant)
2448 variant->vt = VT_R8;
2449 variant->dblVal = 3.14;
2454 LIBTEST_API int STDCALL
2455 mono_test_marshal_variant_out_bstr(VARIANT* variant)
2457 variant->vt = VT_BSTR;
2458 variant->bstrVal = SysAllocString(L"PI");
2463 LIBTEST_API int STDCALL
2464 mono_test_marshal_variant_out_bool_true (VARIANT* variant)
2466 variant->vt = VT_BOOL;
2467 variant->boolVal = VARIANT_TRUE;
2472 LIBTEST_API int STDCALL
2473 mono_test_marshal_variant_out_bool_false (VARIANT* variant)
2475 variant->vt = VT_BOOL;
2476 variant->boolVal = VARIANT_FALSE;
2481 typedef int (STDCALL *VarFunc) (int vt, VARIANT variant);
2482 typedef int (STDCALL *VarRefFunc) (int vt, VARIANT* variant);
2484 LIBTEST_API int STDCALL
2485 mono_test_marshal_variant_in_sbyte_unmanaged(VarFunc func)
2490 return func (VT_I1, vt);
2493 LIBTEST_API int STDCALL
2494 mono_test_marshal_variant_in_byte_unmanaged(VarFunc func)
2499 return func (VT_UI1, vt);
2502 LIBTEST_API int STDCALL
2503 mono_test_marshal_variant_in_short_unmanaged(VarFunc func)
2508 return func (VT_I2, vt);
2511 LIBTEST_API int STDCALL
2512 mono_test_marshal_variant_in_ushort_unmanaged(VarFunc func)
2517 return func (VT_UI2, vt);
2520 LIBTEST_API int STDCALL
2521 mono_test_marshal_variant_in_int_unmanaged(VarFunc func)
2526 return func (VT_I4, vt);
2529 LIBTEST_API int STDCALL
2530 mono_test_marshal_variant_in_uint_unmanaged(VarFunc func)
2535 return func (VT_UI4, vt);
2538 LIBTEST_API int STDCALL
2539 mono_test_marshal_variant_in_long_unmanaged(VarFunc func)
2544 return func (VT_I8, vt);
2547 LIBTEST_API int STDCALL
2548 mono_test_marshal_variant_in_ulong_unmanaged(VarFunc func)
2553 return func (VT_UI8, vt);
2556 LIBTEST_API int STDCALL
2557 mono_test_marshal_variant_in_float_unmanaged(VarFunc func)
2562 return func (VT_R4, vt);
2565 LIBTEST_API int STDCALL
2566 mono_test_marshal_variant_in_double_unmanaged(VarFunc func)
2571 return func (VT_R8, vt);
2574 LIBTEST_API int STDCALL
2575 mono_test_marshal_variant_in_bstr_unmanaged(VarFunc func)
2579 vt.bstrVal = SysAllocString(L"PI");
2580 return func (VT_BSTR, vt);
2583 LIBTEST_API int STDCALL
2584 mono_test_marshal_variant_in_bool_true_unmanaged(VarFunc func)
2588 vt.boolVal = VARIANT_TRUE;
2589 return func (VT_BOOL, vt);
2592 LIBTEST_API int STDCALL
2593 mono_test_marshal_variant_in_bool_false_unmanaged(VarFunc func)
2597 vt.boolVal = VARIANT_FALSE;
2598 return func (VT_BOOL, vt);
2601 LIBTEST_API int STDCALL
2602 mono_test_marshal_variant_out_sbyte_unmanaged(VarRefFunc func)
2607 if (vt.vt == VT_I1 && vt.cVal == -100)
2612 LIBTEST_API int STDCALL
2613 mono_test_marshal_variant_out_byte_unmanaged(VarRefFunc func)
2618 if (vt.vt == VT_UI1 && vt.bVal == 100)
2623 LIBTEST_API int STDCALL
2624 mono_test_marshal_variant_out_short_unmanaged(VarRefFunc func)
2629 if (vt.vt == VT_I2 && vt.iVal == -100)
2634 LIBTEST_API int STDCALL
2635 mono_test_marshal_variant_out_ushort_unmanaged(VarRefFunc func)
2640 if (vt.vt == VT_UI2 && vt.uiVal == 100)
2645 LIBTEST_API int STDCALL
2646 mono_test_marshal_variant_out_int_unmanaged(VarRefFunc func)
2651 if (vt.vt == VT_I4 && vt.lVal == -100)
2656 LIBTEST_API int STDCALL
2657 mono_test_marshal_variant_out_uint_unmanaged(VarRefFunc func)
2662 if (vt.vt == VT_UI4 && vt.ulVal == 100)
2667 LIBTEST_API int STDCALL
2668 mono_test_marshal_variant_out_long_unmanaged(VarRefFunc func)
2673 if (vt.vt == VT_I8 && vt.llVal == -100)
2678 LIBTEST_API int STDCALL
2679 mono_test_marshal_variant_out_ulong_unmanaged(VarRefFunc func)
2684 if (vt.vt == VT_UI8 && vt.ullVal == 100)
2689 LIBTEST_API int STDCALL
2690 mono_test_marshal_variant_out_float_unmanaged(VarRefFunc func)
2695 if (vt.vt == VT_R4 && fabs (vt.fltVal - 3.14f) < 1e-10)
2700 LIBTEST_API int STDCALL
2701 mono_test_marshal_variant_out_double_unmanaged(VarRefFunc func)
2706 if (vt.vt == VT_R8 && fabs (vt.dblVal - 3.14) < 1e-10)
2711 LIBTEST_API int STDCALL
2712 mono_test_marshal_variant_out_bstr_unmanaged(VarRefFunc func)
2716 func (VT_BSTR, &vt);
2717 if (vt.vt == VT_BSTR && !wcscmp(vt.bstrVal, L"PI"))
2722 LIBTEST_API int STDCALL
2723 mono_test_marshal_variant_out_bool_true_unmanaged(VarRefFunc func)
2727 func (VT_BOOL, &vt);
2728 if (vt.vt == VT_BOOL && vt.boolVal == VARIANT_TRUE)
2733 LIBTEST_API int STDCALL
2734 mono_test_marshal_variant_out_bool_false_unmanaged(VarRefFunc func)
2738 func (VT_BOOL, &vt);
2739 if (vt.vt == VT_BOOL && vt.boolVal == VARIANT_TRUE)
2744 typedef struct MonoComObject MonoComObject;
2748 int (STDCALL *QueryInterface)(MonoComObject* pUnk, gpointer riid, gpointer* ppv);
2749 int (STDCALL *AddRef)(MonoComObject* pUnk);
2750 int (STDCALL *Release)(MonoComObject* pUnk);
2751 int (STDCALL *get_ITest)(MonoComObject* pUnk, MonoComObject* *ppUnk);
2752 int (STDCALL *SByteIn)(MonoComObject* pUnk, char a);
2753 int (STDCALL *ByteIn)(MonoComObject* pUnk, unsigned char a);
2754 int (STDCALL *ShortIn)(MonoComObject* pUnk, short a);
2755 int (STDCALL *UShortIn)(MonoComObject* pUnk, unsigned short a);
2756 int (STDCALL *IntIn)(MonoComObject* pUnk, int a);
2757 int (STDCALL *UIntIn)(MonoComObject* pUnk, unsigned int a);
2758 int (STDCALL *LongIn)(MonoComObject* pUnk, LONGLONG a);
2759 int (STDCALL *ULongIn)(MonoComObject* pUnk, ULONGLONG a);
2760 int (STDCALL *FloatIn)(MonoComObject* pUnk, float a);
2761 int (STDCALL *DoubleIn)(MonoComObject* pUnk, double a);
2762 int (STDCALL *ITestIn)(MonoComObject* pUnk, MonoComObject* pUnk2);
2763 int (STDCALL *ITestOut)(MonoComObject* pUnk, MonoComObject* *ppUnk);
2766 struct MonoComObject
2772 DEFINE_GUID(IID_ITest, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
2773 DEFINE_GUID(IID_IMonoUnknown, 0, 0, 0, 0xC0, 0, 0, 0, 0, 0, 0, 0x46);
2774 DEFINE_GUID(IID_IMonoDispatch, 0x00020400, 0, 0, 0xC0, 0, 0, 0, 0, 0, 0, 0x46);
2776 LIBTEST_API int STDCALL
2777 MonoQueryInterface(MonoComObject* pUnk, gpointer riid, gpointer* ppv)
2780 if (!memcmp(riid, &IID_IMonoUnknown, sizeof(GUID))) {
2784 else if (!memcmp(riid, &IID_ITest, sizeof(GUID))) {
2788 else if (!memcmp(riid, &IID_IMonoDispatch, sizeof(GUID))) {
2792 return E_NOINTERFACE;
2795 LIBTEST_API int STDCALL
2796 MonoAddRef(MonoComObject* pUnk)
2798 return ++(pUnk->m_ref);
2801 LIBTEST_API int STDCALL
2802 MonoRelease(MonoComObject* pUnk)
2804 return --(pUnk->m_ref);
2807 LIBTEST_API int STDCALL
2808 SByteIn(MonoComObject* pUnk, char a)
2813 LIBTEST_API int STDCALL
2814 ByteIn(MonoComObject* pUnk, unsigned char a)
2819 LIBTEST_API int STDCALL
2820 ShortIn(MonoComObject* pUnk, short a)
2825 LIBTEST_API int STDCALL
2826 UShortIn(MonoComObject* pUnk, unsigned short a)
2831 LIBTEST_API int STDCALL
2832 IntIn(MonoComObject* pUnk, int a)
2837 LIBTEST_API int STDCALL
2838 UIntIn(MonoComObject* pUnk, unsigned int a)
2843 LIBTEST_API int STDCALL
2844 LongIn(MonoComObject* pUnk, LONGLONG a)
2849 LIBTEST_API int STDCALL
2850 ULongIn(MonoComObject* pUnk, ULONGLONG a)
2855 LIBTEST_API int STDCALL
2856 FloatIn(MonoComObject* pUnk, float a)
2861 LIBTEST_API int STDCALL
2862 DoubleIn(MonoComObject* pUnk, double a)
2867 LIBTEST_API int STDCALL
2868 ITestIn(MonoComObject* pUnk, MonoComObject *pUnk2)
2873 LIBTEST_API int STDCALL
2874 ITestOut(MonoComObject* pUnk, MonoComObject* *ppUnk)
2879 LIBTEST_API int STDCALL
2880 get_ITest(MonoComObject* pUnk, MonoComObject* *ppUnk)
2885 static void create_com_object (MonoComObject** pOut)
2887 *pOut = g_new0 (MonoComObject, 1);
2888 (*pOut)->vtbl = g_new0 (MonoIUnknown, 1);
2891 (*pOut)->vtbl->QueryInterface = MonoQueryInterface;
2892 (*pOut)->vtbl->AddRef = MonoAddRef;
2893 (*pOut)->vtbl->Release = MonoRelease;
2894 (*pOut)->vtbl->SByteIn = SByteIn;
2895 (*pOut)->vtbl->ByteIn = ByteIn;
2896 (*pOut)->vtbl->ShortIn = ShortIn;
2897 (*pOut)->vtbl->UShortIn = UShortIn;
2898 (*pOut)->vtbl->IntIn = IntIn;
2899 (*pOut)->vtbl->UIntIn = UIntIn;
2900 (*pOut)->vtbl->LongIn = LongIn;
2901 (*pOut)->vtbl->ULongIn = ULongIn;
2902 (*pOut)->vtbl->FloatIn = FloatIn;
2903 (*pOut)->vtbl->DoubleIn = DoubleIn;
2904 (*pOut)->vtbl->ITestIn = ITestIn;
2905 (*pOut)->vtbl->ITestOut = ITestOut;
2906 (*pOut)->vtbl->get_ITest = get_ITest;
2909 static MonoComObject* same_object = NULL;
2911 LIBTEST_API int STDCALL
2912 mono_test_marshal_com_object_create(MonoComObject* *pUnk)
2914 create_com_object (pUnk);
2917 same_object = *pUnk;
2922 LIBTEST_API int STDCALL
2923 mono_test_marshal_com_object_same(MonoComObject* *pUnk)
2925 *pUnk = same_object;
2930 LIBTEST_API int STDCALL
2931 mono_test_marshal_com_object_destroy(MonoComObject *pUnk)
2933 int ref = --(pUnk->m_ref);
2940 LIBTEST_API int STDCALL
2941 mono_test_marshal_com_object_ref_count(MonoComObject *pUnk)
2946 LIBTEST_API int STDCALL
2947 mono_test_marshal_ccw_itest (MonoComObject *pUnk)
2950 MonoComObject* pTest;
2955 hr = pUnk->vtbl->SByteIn (pUnk, -100);
2958 hr = pUnk->vtbl->ByteIn (pUnk, 100);
2961 hr = pUnk->vtbl->ShortIn (pUnk, -100);
2964 hr = pUnk->vtbl->UShortIn (pUnk, 100);
2967 hr = pUnk->vtbl->IntIn (pUnk, -100);
2970 hr = pUnk->vtbl->UIntIn (pUnk, 100);
2973 hr = pUnk->vtbl->LongIn (pUnk, -100);
2976 hr = pUnk->vtbl->ULongIn (pUnk, 100);
2979 hr = pUnk->vtbl->FloatIn (pUnk, 3.14f);
2982 hr = pUnk->vtbl->DoubleIn (pUnk, 3.14);
2985 hr = pUnk->vtbl->ITestIn (pUnk, pUnk);
2988 hr = pUnk->vtbl->ITestOut (pUnk, &pTest);
3000 * mono_method_get_unmanaged_thunk tests
3003 #if defined(__GNUC__) && ((defined(__i386__) && (defined(__linux__) || defined (__APPLE__))) || (defined(__ppc__) && defined(__APPLE__)))
3004 #define ALIGN(size) __attribute__ ((aligned(size)))
3010 /* thunks.cs:TestStruct */
3011 typedef struct _TestStruct {
3013 double B ALIGN(8); /* align according to mono's struct layout */
3016 /* Searches for mono symbols in all loaded modules */
3018 lookup_mono_symbol (const char *symbol_name)
3021 if (g_module_symbol (g_module_open (NULL, G_MODULE_BIND_LAZY), symbol_name, &symbol))
3028 * test_method_thunk:
3030 * @test_id: the test number
3031 * @test_method_handle: MonoMethod* of the C# test method
3032 * @create_object_method_handle: MonoMethod* of thunks.cs:Test.CreateObject
3034 LIBTEST_API int STDCALL
3035 test_method_thunk (int test_id, gpointer test_method_handle, gpointer create_object_method_handle)
3037 gpointer (*mono_method_get_unmanaged_thunk)(gpointer)
3038 = lookup_mono_symbol ("mono_method_get_unmanaged_thunk");
3040 gpointer (*mono_string_new_wrapper)(const char *)
3041 = lookup_mono_symbol ("mono_string_new_wrapper");
3043 char* (*mono_string_to_utf8)(gpointer)
3044 = lookup_mono_symbol ("mono_string_to_utf8");
3046 gpointer (*mono_object_unbox)(gpointer)
3047 = lookup_mono_symbol ("mono_object_unbox");
3049 gpointer test_method, ex = NULL;
3050 gpointer (STDCALL *CreateObject)(gpointer*);
3053 if (!mono_method_get_unmanaged_thunk)
3056 test_method = mono_method_get_unmanaged_thunk (test_method_handle);
3060 CreateObject = mono_method_get_unmanaged_thunk (create_object_method_handle);
3068 /* thunks.cs:Test.Test0 */
3069 void (STDCALL *F)(gpointer*) = test_method;
3075 /* thunks.cs:Test.Test1 */
3076 int (STDCALL *F)(gpointer*) = test_method;
3083 /* thunks.cs:Test.Test2 */
3084 gpointer (STDCALL *F)(gpointer, gpointer*) = test_method;
3085 gpointer str = mono_string_new_wrapper ("foo");
3086 if (str != F (str, &ex))
3092 /* thunks.cs:Test.Test3 */
3093 gpointer (STDCALL *F)(gpointer, gpointer, gpointer*);
3098 obj = CreateObject (&ex);
3099 str = mono_string_new_wrapper ("bar");
3101 if (str != F (obj, str, &ex))
3107 /* thunks.cs:Test.Test4 */
3108 int (STDCALL *F)(gpointer, gpointer, int, gpointer*);
3113 obj = CreateObject (&ex);
3114 str = mono_string_new_wrapper ("bar");
3116 if (42 != F (obj, str, 42, &ex))
3123 /* thunks.cs:Test.Test5 */
3124 int (STDCALL *F)(gpointer, gpointer, int, gpointer*);
3129 obj = CreateObject (&ex);
3130 str = mono_string_new_wrapper ("bar");
3132 F (obj, str, 42, &ex);
3140 /* thunks.cs:Test.Test6 */
3141 int (STDCALL *F)(gpointer, guint8, gint16, gint32, gint64, float, double,
3142 gpointer, gpointer*);
3144 gpointer str = mono_string_new_wrapper ("Test6");
3148 obj = CreateObject (&ex);
3150 res = F (obj, 254, 32700, -245378, 6789600, 3.1415, 3.1415, str, &ex);
3161 /* thunks.cs:Test.Test7 */
3162 gint64 (STDCALL *F)(gpointer*) = test_method;
3163 if (F (&ex) != G_MAXINT64)
3169 /* thunks.cs:Test.Test8 */
3170 void (STDCALL *F)(guint8*, gint16*, gint32*, gint64*, float*, double*,
3171 gpointer*, gpointer*);
3183 F (&a1, &a2, &a3, &a4, &a5, &a6, &a7, &ex);
3191 (fabs (a5 - 3.1415) < 0.001) &&
3192 (fabs (a6 - 3.1415) < 0.001) &&
3193 strcmp (mono_string_to_utf8 (a7), "Test8") == 0))
3200 /* thunks.cs:Test.Test9 */
3201 void (STDCALL *F)(guint8*, gint16*, gint32*, gint64*, float*, double*,
3202 gpointer*, gpointer*);
3214 F (&a1, &a2, &a3, &a4, &a5, &a6, &a7, &ex);
3222 /* thunks.cs:Test.Test10 */
3223 void (STDCALL *F)(gpointer*, gpointer*);
3225 gpointer obj1, obj2;
3227 obj1 = obj2 = CreateObject (&ex);
3244 /* thunks.cs:TestStruct.Test0 */
3245 int (STDCALL *F)(gpointer*, gpointer*);
3251 obj = CreateObject (&ex);
3258 a1 = mono_object_unbox (obj);
3274 /* check whether the call was really by value */
3275 if (a1->A != 42 || a1->B != 3.1415)
3282 /* thunks.cs:TestStruct.Test1 */
3283 void (STDCALL *F)(gpointer, gpointer*);
3288 obj = CreateObject (&ex);
3295 a1 = mono_object_unbox (obj);
3308 if (!fabs (a1->B - 3.1415) < 0.001)
3315 /* thunks.cs:TestStruct.Test2 */
3316 gpointer (STDCALL *F)(gpointer*);
3330 a1 = mono_object_unbox (obj);
3335 if (!fabs (a1->B - 3.1415) < 0.001)
3342 /* thunks.cs:TestStruct.Test3 */
3343 void (STDCALL *F)(gpointer, gpointer*);
3348 obj = CreateObject (&ex);
3355 a1 = mono_object_unbox (obj);
3391 LIBTEST_API int STDCALL
3392 mono_test_Winx64_struct1_in (winx64_struct1 var)
3405 LIBTEST_API int STDCALL
3406 mono_test_Winx64_struct2_in (winx64_struct2 var)
3423 LIBTEST_API int STDCALL
3424 mono_test_Winx64_struct3_in (winx64_struct3 var)
3430 if (var.c != 0x1234)
3443 LIBTEST_API int STDCALL
3444 mono_test_Winx64_struct4_in (winx64_struct4 var)
3450 if (var.c != 0x1234)
3452 if (var.d != 0x87654321)
3464 LIBTEST_API int STDCALL
3465 mono_test_Winx64_struct5_in (winx64_struct5 var)
3483 LIBTEST_API int STDCALL
3484 mono_test_Winx64_struct6_in (winx64_struct6 var)
3495 LIBTEST_API int STDCALL
3496 mono_test_Winx64_structs_in1 (winx64_struct1 var1,
3497 winx64_struct2 var2,
3498 winx64_struct3 var3,
3499 winx64_struct4 var4)
3513 if (var3.c != 0x1234)
3520 if (var4.c != 0x1234)
3522 if (var4.d != 0x87654321)
3527 LIBTEST_API int STDCALL
3528 mono_test_Winx64_structs_in2 (winx64_struct1 var1,
3529 winx64_struct1 var2,
3530 winx64_struct1 var3,
3531 winx64_struct1 var4,
3532 winx64_struct1 var5)
3548 LIBTEST_API int STDCALL
3549 mono_test_Winx64_structs_in3 (winx64_struct1 var1,
3550 winx64_struct5 var2,
3551 winx64_struct1 var3,
3552 winx64_struct5 var4,
3553 winx64_struct1 var5,
3554 winx64_struct5 var6)
3589 LIBTEST_API winx64_struct1 STDCALL
3590 mono_test_Winx64_struct1_ret (void)
3597 LIBTEST_API winx64_struct2 STDCALL
3598 mono_test_Winx64_struct2_ret (void)
3606 LIBTEST_API winx64_struct3 STDCALL
3607 mono_test_Winx64_struct3_ret (void)
3616 LIBTEST_API winx64_struct4 STDCALL
3617 mono_test_Winx64_struct4_ret (void)
3627 LIBTEST_API winx64_struct5 STDCALL
3628 mono_test_Winx64_struct5_ret (void)
3637 LIBTEST_API winx64_struct1 STDCALL
3638 mono_test_Winx64_struct1_ret_5_args (char a, char b, char c, char d, char e)
3641 ret.a = a + b + c + d + e;
3645 LIBTEST_API winx64_struct5 STDCALL
3646 mono_test_Winx64_struct5_ret6_args (char a, char b, char c, char d, char e)
3659 } winx64_floatStruct;
3661 LIBTEST_API int STDCALL
3662 mono_test_Winx64_floatStruct (winx64_floatStruct a)
3664 if (a.a > 5.6 || a.a < 5.4)
3667 if (a.b > 9.6 || a.b < 9.4)
3676 } winx64_doubleStruct;
3678 LIBTEST_API int STDCALL
3679 mono_test_Winx64_doubleStruct (winx64_doubleStruct a)
3681 if (a.a > 5.6 || a.a < 5.4)
3687 typedef int (STDCALL *managed_struct1_delegate) (winx64_struct1 a);
3689 LIBTEST_API int STDCALL
3690 mono_test_managed_Winx64_struct1_in(managed_struct1_delegate func)
3697 typedef int (STDCALL *managed_struct5_delegate) (winx64_struct5 a);
3699 LIBTEST_API int STDCALL
3700 mono_test_managed_Winx64_struct5_in(managed_struct5_delegate func)
3709 typedef int (STDCALL *managed_struct1_struct5_delegate) (winx64_struct1 a, winx64_struct5 b,
3710 winx64_struct1 c, winx64_struct5 d,
3711 winx64_struct1 e, winx64_struct5 f);
3713 LIBTEST_API int STDCALL
3714 mono_test_managed_Winx64_struct1_struct5_in(managed_struct1_struct5_delegate func)
3716 winx64_struct1 a, c, e;
3717 winx64_struct5 b, d, f;
3719 b.a = 2; b.b = 3; b.c = 4;
3721 d.a = 6; d.b = 7; d.c = 8;
3723 f.a = 10; f.b = 11; f.c = 12;
3725 return func (a, b, c, d, e, f);
3728 typedef winx64_struct1 (STDCALL *managed_struct1_ret_delegate) (void);
3730 LIBTEST_API int STDCALL
3731 mono_test_Winx64_struct1_ret_managed (managed_struct1_ret_delegate func)
3743 typedef winx64_struct5 (STDCALL *managed_struct5_ret_delegate) (void);
3745 LIBTEST_API int STDCALL
3746 mono_test_Winx64_struct5_ret_managed (managed_struct5_ret_delegate func)
3762 LIBTEST_API int STDCALL
3763 mono_test_marshal_bool_in (int arg, unsigned int expected, unsigned int bDefaultMarsh, unsigned int bBoolCustMarsh,
3764 char bI1CustMarsh, unsigned char bU1CustMarsh, unsigned short bVBCustMarsh)
3768 if (bDefaultMarsh != expected)
3772 if (bBoolCustMarsh != expected)
3776 if (bI1CustMarsh != expected)
3780 if (bU1CustMarsh != expected)
3784 if (bVBCustMarsh != expected)
3793 LIBTEST_API int STDCALL
3794 mono_test_marshal_bool_out (int arg, unsigned int testVal, unsigned int* bDefaultMarsh, unsigned int* bBoolCustMarsh,
3795 char* bI1CustMarsh, unsigned char* bU1CustMarsh, unsigned short* bVBCustMarsh)
3801 *bDefaultMarsh = testVal;
3804 if (!bBoolCustMarsh)
3806 *bBoolCustMarsh = testVal;
3811 *bI1CustMarsh = (char)testVal;
3816 *bU1CustMarsh = (unsigned char)testVal;
3821 *bVBCustMarsh = (unsigned short)testVal;
3829 LIBTEST_API int STDCALL
3830 mono_test_marshal_bool_ref (int arg, unsigned int expected, unsigned int testVal, unsigned int* bDefaultMarsh,
3831 unsigned int* bBoolCustMarsh, char* bI1CustMarsh, unsigned char* bU1CustMarsh,
3832 unsigned short* bVBCustMarsh)
3838 if (*bDefaultMarsh != expected)
3840 *bDefaultMarsh = testVal;
3843 if (!bBoolCustMarsh)
3845 if (*bBoolCustMarsh != expected)
3847 *bBoolCustMarsh = testVal;
3852 if (*bI1CustMarsh != expected)
3854 *bI1CustMarsh = (char)testVal;
3859 if (*bU1CustMarsh != expected)
3861 *bU1CustMarsh = (unsigned char)testVal;
3866 if (*bVBCustMarsh != expected)
3868 *bVBCustMarsh = (unsigned short)testVal;
3877 typedef int (STDCALL *MarshalBoolInDelegate) (int arg, unsigned int expected, unsigned int bDefaultMarsh,
3878 unsigned int bBoolCustMarsh, char bI1CustMarsh, unsigned char bU1CustMarsh, unsigned short bVBCustMarsh);
3880 LIBTEST_API int STDCALL
3881 mono_test_managed_marshal_bool_in (int arg, unsigned int expected, unsigned int testVal, MarshalBoolInDelegate pfcn)
3888 return pfcn (arg, expected, testVal, 0, 0, 0, 0);
3890 return pfcn (arg, expected, 0, testVal, 0, 0, 0);
3892 return pfcn (arg, expected, 0, 0, testVal, 0, 0);
3894 return pfcn (arg, expected, 0, 0, 0, testVal, 0);
3896 return pfcn (arg, expected, 0, 0, 0, 0, testVal);
3904 typedef int (STDCALL *MarshalBoolOutDelegate) (int arg, unsigned int expected, unsigned int* bDefaultMarsh,
3905 unsigned int* bBoolCustMarsh, char* bI1CustMarsh, unsigned char* bU1CustMarsh, unsigned short* bVBCustMarsh);
3907 LIBTEST_API int STDCALL
3908 mono_test_managed_marshal_bool_out (int arg, unsigned int expected, unsigned int testVal, MarshalBoolOutDelegate pfcn)
3911 unsigned int lDefaultMarsh, lBoolCustMarsh;
3912 char lI1CustMarsh = 0;
3913 unsigned char lU1CustMarsh = 0;
3914 unsigned short lVBCustMarsh = 0;
3915 lDefaultMarsh = lBoolCustMarsh = 0;
3922 unsigned int ltVal = 0;
3923 ret = pfcn (arg, testVal, <Val, &lBoolCustMarsh, &lI1CustMarsh, &lU1CustMarsh, &lVBCustMarsh);
3925 return 0x0100 + ret;
3926 if (expected != ltVal)
3931 unsigned int ltVal = 0;
3932 ret = pfcn (arg, testVal, &lDefaultMarsh, <Val, &lI1CustMarsh, &lU1CustMarsh, &lVBCustMarsh);
3934 return 0x0300 + ret;
3935 if (expected != ltVal)
3941 ret = pfcn (arg, testVal, &lDefaultMarsh, &lBoolCustMarsh, <Val, &lU1CustMarsh, &lVBCustMarsh);
3943 return 0x0500 + ret;
3944 if (expected != ltVal)
3949 unsigned char ltVal = 0;
3950 ret = pfcn (arg, testVal, &lDefaultMarsh, &lBoolCustMarsh, &lI1CustMarsh, <Val, &lVBCustMarsh);
3952 return 0x0700 + ret;
3953 if (expected != ltVal)
3958 unsigned short ltVal = 0;
3959 ret = pfcn (arg, testVal, &lDefaultMarsh, &lBoolCustMarsh, &lI1CustMarsh, &lU1CustMarsh, <Val);
3961 return 0x0900 + ret;
3962 if (expected != ltVal)
3973 typedef int (STDCALL *MarshalBoolRefDelegate) (int arg, unsigned int expected, unsigned int testVal, unsigned int* bDefaultMarsh,
3974 unsigned int* bBoolCustMarsh, char* bI1CustMarsh, unsigned char* bU1CustMarsh, unsigned short* bVBCustMarsh);
3976 LIBTEST_API int STDCALL
3977 mono_test_managed_marshal_bool_ref (int arg, unsigned int expected, unsigned int testVal, unsigned int outExpected,
3978 unsigned int outTestVal, MarshalBoolRefDelegate pfcn)
3981 unsigned int lDefaultMarsh, lBoolCustMarsh;
3982 char lI1CustMarsh = 0;
3983 unsigned char lU1CustMarsh = 0;
3984 unsigned short lVBCustMarsh = 0;
3985 lDefaultMarsh = lBoolCustMarsh = 0;
3993 unsigned int ltestVal = testVal;
3994 ret = pfcn (arg, expected, outTestVal, <estVal, &lBoolCustMarsh, &lI1CustMarsh, &lU1CustMarsh, &lVBCustMarsh);
3996 return 0x0100 + ret;
3997 if (outExpected != ltestVal)
4003 unsigned int ltestVal = testVal;
4004 ret = pfcn (arg, expected, outTestVal, &lDefaultMarsh, <estVal, &lI1CustMarsh, &lU1CustMarsh, &lVBCustMarsh);
4006 return 0x0300 + ret;
4007 if (outExpected != ltestVal)
4013 char ltestVal = testVal;
4014 ret = pfcn (arg, expected, outTestVal, &lDefaultMarsh, &lBoolCustMarsh, <estVal, &lU1CustMarsh, &lVBCustMarsh);
4016 return 0x0500 + ret;
4017 if (outExpected != ltestVal)
4023 unsigned char ltestVal = testVal;
4024 ret = pfcn (arg, expected, outTestVal, &lDefaultMarsh, &lBoolCustMarsh, &lI1CustMarsh, <estVal, &lVBCustMarsh);
4026 return 0x0700 + ret;
4027 if (outExpected != ltestVal)
4033 unsigned short ltestVal = testVal;
4034 ret = pfcn (arg, expected, outTestVal, &lDefaultMarsh, &lBoolCustMarsh, &lI1CustMarsh, &lU1CustMarsh, <estVal);
4036 return 0x0900 + ret;
4037 if (outExpected != ltestVal)