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 (STDCALL *DelegateByrefDelegate) (void *);
894 LIBTEST_API int STDCALL
895 mono_test_marshal_delegate_ref_delegate (DelegateByrefDelegate del)
897 int (STDCALL *ptr) (int i);
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);
1232 #pragma GCC diagnostic push
1233 #pragma GCC diagnostic ignored "-Wc++-compat"
1237 * Standard C and C++ doesn't allow empty structs, empty structs will always have a size of 1 byte.
1238 * GCC have an extension to allow empty structs, https://gcc.gnu.org/onlinedocs/gcc/Empty-Structures.html.
1239 * This cause a little dilemma since runtime build using none GCC compiler will not be compatible with
1240 * GCC build C libraries and the other way around. On platforms where empty structs has size of 1 byte
1241 * it must be represented in call and cannot be dropped. On Windows x64 structs will always be represented in the call
1242 * meaning that an empty struct must have a representation in the callee in order to correctly follow the ABI used by the
1243 * C/C++ standard and the runtime.
1246 #if !defined(__GNUC__) || defined(TARGET_WIN32)
1252 #pragma GCC diagnostic pop
1255 LIBTEST_API int STDCALL
1256 mono_test_marshal_empty_string_array (char **array)
1258 return (array == NULL) ? 0 : 1;
1261 LIBTEST_API int STDCALL
1262 mono_test_marshal_string_array (char **array)
1264 if (strcmp (array [0], "ABC"))
1266 if (strcmp (array [1], "DEF"))
1269 if (array [2] != NULL)
1275 LIBTEST_API int STDCALL
1276 mono_test_marshal_byref_string_array (char ***array)
1281 if (strcmp ((*array) [0], "Alpha"))
1283 if (strcmp ((*array) [1], "Beta"))
1285 if (strcmp ((*array) [2], "Gamma"))
1291 LIBTEST_API int STDCALL
1292 mono_test_marshal_stringbuilder_array (char **array)
1294 if (strcmp (array [0], "ABC"))
1296 if (strcmp (array [1], "DEF"))
1299 strcpy (array [0], "DEF");
1300 strcpy (array [1], "ABC");
1305 LIBTEST_API int STDCALL
1306 mono_test_marshal_unicode_string_array (gunichar2 **array, char **array2)
1308 GError *error = NULL;
1311 s = g_utf16_to_utf8 (array [0], -1, NULL, NULL, &error);
1312 if (strcmp (s, "ABC")) {
1319 s = g_utf16_to_utf8 (array [1], -1, NULL, NULL, &error);
1320 if (strcmp (s, "DEF")) {
1327 if (strcmp (array2 [0], "ABC"))
1330 if (strcmp (array2 [1], "DEF"))
1336 /* this does not work on Redhat gcc 2.96 */
1337 LIBTEST_API int STDCALL
1338 mono_test_empty_struct (int a, EmptyStruct es, int b)
1340 // printf ("mono_test_empty_struct %d %d\n", a, b);
1342 // Intel icc on ia64 passes 'es' in 2 registers
1343 #if defined(__ia64) && defined(__INTEL_COMPILER)
1346 if (a == 1 && b == 2)
1352 LIBTEST_API EmptyStruct STDCALL
1353 mono_test_return_empty_struct (int a)
1357 memset (&s, 0, sizeof (s));
1359 #if !(defined(__i386__) && defined(__clang__))
1360 /* https://bugzilla.xamarin.com/show_bug.cgi?id=58901 */
1371 LIBTEST_API ByValStrStruct * STDCALL
1372 mono_test_byvalstr_gen (void)
1374 ByValStrStruct *ret;
1376 ret = (ByValStrStruct *)malloc (sizeof (ByValStrStruct));
1377 memset(ret, 'a', sizeof(ByValStrStruct)-1);
1378 ret->a[sizeof(ByValStrStruct)-1] = 0;
1383 LIBTEST_API int STDCALL
1384 mono_test_byvalstr_check (ByValStrStruct* data, char* correctString)
1388 ret = strcmp(data->a, correctString);
1389 // printf ("T1: %s\n", data->a);
1390 // printf ("T2: %s\n", correctString);
1392 /* we need g_free because the allocation was performed by mono_test_byvalstr_gen */
1400 } ByValStrStruct_Unicode;
1402 LIBTEST_API int STDCALL
1403 mono_test_byvalstr_check_unicode (ByValStrStruct_Unicode *ref, int test)
1405 if (ref->flag != 0x1234abcd){
1406 printf ("overwritten data");
1410 if (test == 1 || test == 3){
1411 if (ref->a [0] != '1' ||
1412 ref->a [1] != '2' ||
1418 if (ref->a [0] != '1' ||
1426 LIBTEST_API int STDCALL
1427 NameManglingAnsi (char *data)
1429 return data [0] + data [1] + data [2];
1432 LIBTEST_API int STDCALL
1433 NameManglingAnsiA (char *data)
1435 g_assert_not_reached ();
1438 LIBTEST_API int STDCALL
1439 NameManglingAnsiW (char *data)
1441 g_assert_not_reached ();
1444 LIBTEST_API int STDCALL
1445 NameManglingAnsi2A (char *data)
1447 return data [0] + data [1] + data [2];
1450 LIBTEST_API int STDCALL
1451 NameManglingAnsi2W (char *data)
1453 g_assert_not_reached ();
1456 LIBTEST_API int STDCALL
1457 NameManglingUnicode (char *data)
1459 g_assert_not_reached ();
1462 LIBTEST_API int STDCALL
1463 NameManglingUnicodeW (gunichar2 *data)
1465 return data [0] + data [1] + data [2];
1468 LIBTEST_API int STDCALL
1469 NameManglingUnicode2 (gunichar2 *data)
1471 return data [0] + data [1] + data [2];
1474 LIBTEST_API int STDCALL
1475 NameManglingAutoW (char *data)
1478 return (data [0] + data [1] + data [2]) == 131 ? 0 : 1;
1480 g_assert_not_reached ();
1484 LIBTEST_API int STDCALL
1485 NameManglingAuto (char *data)
1488 return (data [0] + data [1] + data [2]) == 198 ? 0 : 1;
1490 g_assert_not_reached ();
1494 typedef int (STDCALL *intcharFunc)(const char*);
1496 LIBTEST_API void STDCALL
1497 callFunction (intcharFunc f)
1507 LIBTEST_API int STDCALL
1508 class_marshal_test0 (SimpleObj *obj1)
1510 // printf ("class_marshal_test0 %s %d\n", obj1->str, obj1->i);
1512 if (strcmp(obj1->str, "T1"))
1520 LIBTEST_API int STDCALL
1521 class_marshal_test4 (SimpleObj *obj1)
1529 LIBTEST_API void STDCALL
1530 class_marshal_test1 (SimpleObj **obj1)
1532 SimpleObj *res = (SimpleObj *)malloc (sizeof (SimpleObj));
1534 res->str = marshal_strdup ("ABC");
1540 LIBTEST_API int STDCALL
1541 class_marshal_test2 (SimpleObj **obj1)
1543 // printf ("class_marshal_test2 %s %d\n", (*obj1)->str, (*obj1)->i);
1545 if (strcmp((*obj1)->str, "ABC"))
1547 if ((*obj1)->i != 5)
1553 LIBTEST_API int STDCALL
1554 string_marshal_test0 (char *str)
1556 if (strcmp (str, "TEST0"))
1562 LIBTEST_API void STDCALL
1563 string_marshal_test1 (const char **str)
1565 *str = marshal_strdup ("TEST1");
1568 LIBTEST_API int STDCALL
1569 string_marshal_test2 (char **str)
1571 // printf ("string_marshal_test2 %s\n", *str);
1573 if (strcmp (*str, "TEST1"))
1576 *str = marshal_strdup ("TEST2");
1581 LIBTEST_API int STDCALL
1582 string_marshal_test3 (char *str)
1595 LIBTEST_API BlittableClass* STDCALL
1596 TestBlittableClass (BlittableClass *vl)
1598 BlittableClass *res;
1600 // printf ("TestBlittableClass %d %d\n", vl->a, vl->b);
1606 res = marshal_new0 (BlittableClass, 1);
1607 memcpy (res, vl, sizeof (BlittableClass));
1609 res = marshal_new0 (BlittableClass, 1);
1617 typedef struct OSVERSIONINFO_STRUCT
1621 } OSVERSIONINFO_STRUCT;
1623 LIBTEST_API int STDCALL
1624 MyGetVersionEx (OSVERSIONINFO_STRUCT *osvi)
1627 // printf ("GOT %d %d\n", osvi->a, osvi->b);
1632 return osvi->a + osvi->b;
1635 LIBTEST_API int STDCALL
1636 BugGetVersionEx (int a, int b, int c, int d, int e, int f, int g, int h, OSVERSIONINFO_STRUCT *osvi)
1639 // printf ("GOT %d %d\n", osvi->a, osvi->b);
1644 return osvi->a + osvi->b;
1647 LIBTEST_API int STDCALL
1648 mono_test_marshal_point (point pt)
1650 // printf("point %g %g\n", pt.x, pt.y);
1651 if (pt.x == 1.25 && pt.y == 3.5)
1662 LIBTEST_API int STDCALL
1663 mono_test_marshal_mixed_point (mixed_point pt)
1665 // printf("mixed point %d %g\n", pt.x, pt.y);
1666 if (pt.x == 5 && pt.y == 6.75)
1672 LIBTEST_API int STDCALL
1673 mono_test_marshal_mixed_point_2 (mixed_point *pt)
1675 if (pt->x != 5 || pt->y != 6.75)
1684 LIBTEST_API int STDCALL
1685 marshal_test_ref_bool(int i, char *b1, short *b2, int *b3)
1688 if (*b1 != 0 && *b1 != 1)
1690 if (*b2 != 0 && *b2 != -1) /* variant_bool */
1692 if (*b3 != 0 && *b3 != 1)
1694 if (i == ((*b1 << 2) | (-*b2 << 1) | *b3))
1706 short b2; /* variant_bool */
1710 LIBTEST_API int STDCALL
1711 marshal_test_bool_struct(struct BoolStruct *s)
1714 if (s->b1 != 0 && s->b1 != 1)
1716 if (s->b2 != 0 && s->b2 != -1)
1718 if (s->b3 != 0 && s->b3 != 1)
1720 if (s->i == ((s->b1 << 2) | (-s->b2 << 1) | s->b3))
1737 LIBTEST_API int STDCALL
1738 mono_test_marshal_long_struct (LongStruct *s)
1740 return s->i + s->l.l;
1743 LIBTEST_API void STDCALL
1744 mono_test_last_error (int err)
1753 LIBTEST_API int STDCALL
1754 mono_test_asany (void *ptr, int what)
1758 return (*(int*)ptr == 5) ? 0 : 1;
1760 return strcmp (ptr, "ABC") == 0 ? 0 : 1;
1762 simplestruct2 ss = *(simplestruct2*)ptr;
1764 if (ss.a == 0 && ss.b == 1 && ss.c == 0 &&
1765 !strcmp (ss.d, "TEST") &&
1766 ss.e == 99 && ss.f == 1.5 && ss.g == 42 && ss.h == (guint64)123)
1772 GError *error = NULL;
1775 s = g_utf16_to_utf8 ((const gunichar2 *)ptr, -1, NULL, NULL, &error);
1780 if (!strcmp (s, "ABC")) {
1790 g_assert_not_reached ();
1804 LIBTEST_API int STDCALL
1805 mono_test_marshal_asany_in (void* ptr)
1807 AsAnyStruct *asAny = (AsAnyStruct *)ptr;
1808 int res = asAny->i + asAny->j + asAny->k;
1813 LIBTEST_API int STDCALL
1814 mono_test_marshal_asany_inout (void* ptr)
1816 AsAnyStruct *asAny = (AsAnyStruct *)ptr;
1817 int res = asAny->i + asAny->j + asAny->k;
1819 marshal_free (asAny->s);
1829 LIBTEST_API int STDCALL
1830 mono_test_marshal_asany_out (void* ptr)
1832 AsAnyStruct *asAny = (AsAnyStruct *)ptr;
1833 int res = asAny->i + asAny->j + asAny->k;
1844 * AMD64 marshalling tests.
1847 typedef struct amd64_struct1 {
1854 LIBTEST_API amd64_struct1 STDCALL
1855 mono_test_marshal_amd64_pass_return_struct1 (amd64_struct1 s)
1865 LIBTEST_API amd64_struct1 STDCALL
1866 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)
1871 s.l += 1 + i1 + i2 + i3 + i4 + i5 + i6 + i7 + i8;
1876 typedef struct amd64_struct2 {
1881 LIBTEST_API amd64_struct2 STDCALL
1882 mono_test_marshal_amd64_pass_return_struct2 (amd64_struct2 s)
1890 typedef struct amd64_struct3 {
1894 LIBTEST_API amd64_struct3 STDCALL
1895 mono_test_marshal_amd64_pass_return_struct3 (amd64_struct3 s)
1902 typedef struct amd64_struct4 {
1906 LIBTEST_API amd64_struct4 STDCALL
1907 mono_test_marshal_amd64_pass_return_struct4 (amd64_struct4 s)
1916 * IA64 marshalling tests.
1918 typedef struct test_struct5 {
1922 LIBTEST_API test_struct5 STDCALL
1923 mono_test_marshal_ia64_pass_return_struct5 (double d1, double d2, test_struct5 s, int i, double d3, double d4)
1925 s.d1 += d1 + d2 + i;
1926 s.d2 += d3 + d4 + i;
1931 typedef struct test_struct6 {
1935 LIBTEST_API test_struct6 STDCALL
1936 mono_test_marshal_ia64_pass_return_struct6 (double d1, double d2, test_struct6 s, int i, double d3, double d4)
1938 s.d1 += d1 + d2 + i;
1944 static guint32 custom_res [2];
1946 LIBTEST_API void* STDCALL
1947 mono_test_marshal_pass_return_custom (int i, guint32 *ptr, int j)
1949 /* ptr will be freed by CleanupNative, so make a copy */
1950 custom_res [0] = 0; /* not allocated by AllocHGlobal */
1951 custom_res [1] = ptr [1];
1956 LIBTEST_API int STDCALL
1957 mono_test_marshal_pass_out_custom (int i, guint32 **ptr, int j)
1960 custom_res [1] = i + j + 10;
1967 LIBTEST_API int STDCALL
1968 mono_test_marshal_pass_inout_custom (int i, guint32 *ptr, int j)
1971 ptr [1] = i + ptr [1] + j;
1976 LIBTEST_API int STDCALL
1977 mono_test_marshal_pass_out_byval_custom (int i, guint32 *ptr, int j)
1979 return ptr == NULL ? 0 : 1;
1982 LIBTEST_API int STDCALL
1983 mono_test_marshal_pass_byref_custom (int i, guint32 **ptr, int j)
1990 LIBTEST_API void* STDCALL
1991 mono_test_marshal_pass_return_custom2 (int i, guint32 *ptr, int j)
1993 g_assert_not_reached ();
1998 LIBTEST_API void* STDCALL
1999 mono_test_marshal_pass_return_custom_null (int i, guint32 *ptr, int j)
2001 g_assert (ptr == NULL);
2006 typedef void *(STDCALL *PassReturnPtrDelegate) (void *ptr);
2008 LIBTEST_API int STDCALL
2009 mono_test_marshal_pass_return_custom_in_delegate (PassReturnPtrDelegate del)
2018 ptr = (guint32 *)del (&buf);
2023 /* FIXME: Freed with FreeHGlobal */
2031 LIBTEST_API int STDCALL
2032 mono_test_marshal_pass_return_custom_null_in_delegate (PassReturnPtrDelegate del)
2034 void *ptr = del (NULL);
2036 return (ptr == NULL) ? 15 : 0;
2039 typedef void (STDCALL *CustomOutParamDelegate) (void **pptr);
2041 LIBTEST_API int STDCALL
2042 mono_test_marshal_custom_out_param_delegate (CustomOutParamDelegate del)
2054 typedef int (STDCALL *ReturnEnumDelegate) (int e);
2056 LIBTEST_API int STDCALL
2057 mono_test_marshal_return_enum_delegate (ReturnEnumDelegate func)
2067 typedef BlittableStruct (STDCALL *SimpleDelegate10) (BlittableStruct ss);
2069 LIBTEST_API int STDCALL
2070 mono_test_marshal_blittable_struct_delegate (SimpleDelegate10 delegate)
2072 BlittableStruct ss, res;
2079 res = delegate (ss);
2080 if (! ((res.a == -1) && (res.b == -2) && (res.c == -3) && (res.d == -55)))
2086 LIBTEST_API int STDCALL
2087 mono_test_stdcall_name_mangling (int a, int b, int c)
2093 mono_test_stdcall_mismatch_1 (int a, int b, int c)
2098 LIBTEST_API int STDCALL
2099 mono_test_stdcall_mismatch_2 (int a, int b, int c)
2105 * PASSING AND RETURNING SMALL STRUCTURES FROM DELEGATES TESTS
2112 typedef SmallStruct1 (STDCALL *SmallStructDelegate1) (SmallStruct1 ss);
2114 LIBTEST_API int STDCALL
2115 mono_test_marshal_small_struct_delegate1 (SmallStructDelegate1 delegate)
2117 SmallStruct1 ss, res;
2121 res = delegate (ss);
2122 if (! (res.i == -1))
2132 typedef SmallStruct2 (STDCALL *SmallStructDelegate2) (SmallStruct2 ss);
2134 LIBTEST_API int STDCALL
2135 mono_test_marshal_small_struct_delegate2 (SmallStructDelegate2 delegate)
2137 SmallStruct2 ss, res;
2142 res = delegate (ss);
2143 if (! ((res.i == -2) && (res.j == -3)))
2154 typedef SmallStruct3 (STDCALL *SmallStructDelegate3) (SmallStruct3 ss);
2156 LIBTEST_API int STDCALL
2157 mono_test_marshal_small_struct_delegate3 (SmallStructDelegate3 delegate)
2159 SmallStruct3 ss, res;
2164 res = delegate (ss);
2165 if (! ((res.i == -1) && (res.j == -2)))
2175 typedef SmallStruct4 (STDCALL *SmallStructDelegate4) (SmallStruct4 ss);
2177 LIBTEST_API int STDCALL
2178 mono_test_marshal_small_struct_delegate4 (SmallStructDelegate4 delegate)
2180 SmallStruct4 ss, res;
2184 res = delegate (ss);
2185 if (! (res.i == -1))
2195 typedef SmallStruct5 (STDCALL *SmallStructDelegate5) (SmallStruct5 ss);
2197 LIBTEST_API int STDCALL
2198 mono_test_marshal_small_struct_delegate5 (SmallStructDelegate5 delegate)
2200 SmallStruct5 ss, res;
2204 res = delegate (ss);
2205 if (! (res.i == -5))
2215 typedef SmallStruct6 (STDCALL *SmallStructDelegate6) (SmallStruct6 ss);
2217 LIBTEST_API int STDCALL
2218 mono_test_marshal_small_struct_delegate6 (SmallStructDelegate6 delegate)
2220 SmallStruct6 ss, res;
2225 res = delegate (ss);
2226 if (! ((res.i == -1) && (res.j == -2)))
2237 typedef SmallStruct7 (STDCALL *SmallStructDelegate7) (SmallStruct7 ss);
2239 LIBTEST_API int STDCALL
2240 mono_test_marshal_small_struct_delegate7 (SmallStructDelegate7 delegate)
2242 SmallStruct7 ss, res;
2247 res = delegate (ss);
2248 if (! ((res.i == -1) && (res.j == -2)))
2258 typedef SmallStruct8 (STDCALL *SmallStructDelegate8) (SmallStruct8 ss);
2260 LIBTEST_API int STDCALL
2261 mono_test_marshal_small_struct_delegate8 (SmallStructDelegate8 delegate)
2263 SmallStruct8 ss, res;
2267 res = delegate (ss);
2268 if (! ((res.i == -1.0)))
2278 typedef SmallStruct9 (STDCALL *SmallStructDelegate9) (SmallStruct9 ss);
2280 LIBTEST_API int STDCALL
2281 mono_test_marshal_small_struct_delegate9 (SmallStructDelegate9 delegate)
2283 SmallStruct9 ss, res;
2287 res = delegate (ss);
2288 if (! ((res.i == -1.0)))
2298 typedef SmallStruct10 (STDCALL *SmallStructDelegate10) (SmallStruct10 ss);
2300 LIBTEST_API int STDCALL
2301 mono_test_marshal_small_struct_delegate10 (SmallStructDelegate10 delegate)
2303 SmallStruct10 ss, res;
2308 res = delegate (ss);
2309 if (! ((res.i == -1.0) && (res.j == -2.0)))
2320 typedef SmallStruct11 (STDCALL *SmallStructDelegate11) (SmallStruct11 ss);
2322 LIBTEST_API int STDCALL
2323 mono_test_marshal_small_struct_delegate11 (SmallStructDelegate11 delegate)
2325 SmallStruct11 ss, res;
2330 res = delegate (ss);
2331 if (! ((res.i == -1.0) && (res.j == -2)))
2337 typedef int (STDCALL *ArrayDelegate) (int i, char *j, void *arr);
2339 LIBTEST_API int STDCALL
2340 mono_test_marshal_array_delegate (void *arr, int len, ArrayDelegate del)
2342 return del (len, NULL, arr);
2345 typedef int (STDCALL *ArrayDelegateLong) (gint64 i, char *j, void *arr);
2347 LIBTEST_API int STDCALL
2348 mono_test_marshal_array_delegate_long (void *arr, gint64 len, ArrayDelegateLong del)
2350 return del (len, NULL, arr);
2353 LIBTEST_API int STDCALL
2354 mono_test_marshal_out_array_delegate (int *arr, int len, ArrayDelegate del)
2356 del (len, NULL, arr);
2358 if ((arr [0] != 1) || (arr [1] != 2))
2364 typedef gunichar2* (STDCALL *UnicodeStringDelegate) (gunichar2 *message);
2366 LIBTEST_API int STDCALL
2367 mono_test_marshal_return_unicode_string_delegate (UnicodeStringDelegate del)
2369 const char m[] = "abcdef";
2370 gunichar2 *s2, *res;
2373 s2 = g_utf8_to_utf16 (m, -1, NULL, &len, NULL);
2382 LIBTEST_API int STDCALL
2383 mono_test_marshal_out_string_array_delegate (char **arr, int len, ArrayDelegate del)
2385 del (len, NULL, arr);
2387 if (!strcmp (arr [0], "ABC") && !strcmp (arr [1], "DEF"))
2393 typedef int (*CdeclDelegate) (int i, int j);
2395 LIBTEST_API int STDCALL
2396 mono_test_marshal_cdecl_delegate (CdeclDelegate del)
2400 for (i = 0; i < 1000; ++i)
2406 typedef char** (STDCALL *ReturnStringArrayDelegate) (int i);
2408 LIBTEST_API int STDCALL
2409 mono_test_marshal_return_string_array_delegate (ReturnStringArrayDelegate d)
2417 if (strcmp (arr [0], "ABC") || strcmp (arr [1], "DEF"))
2427 typedef int (STDCALL *ByrefStringDelegate) (char **s);
2429 LIBTEST_API int STDCALL
2430 mono_test_marshal_byref_string_delegate (ByrefStringDelegate d)
2432 char *s = (char*)"ABC";
2439 if (!strcmp (s, "DEF"))
2449 LIBTEST_API int STDCALL
2450 add_delegate (int i, int j)
2455 LIBTEST_API gpointer STDCALL
2456 mono_test_marshal_return_fnptr (void)
2458 return &add_delegate;
2461 LIBTEST_API int STDCALL
2464 printf ("codigo %x\n", code);
2472 LIBTEST_API HandleRef STDCALL
2473 mono_xr_as_handle (int code)
2477 memset (&ref, 0, sizeof (ref));
2489 LIBTEST_API int STDCALL
2490 mono_safe_handle_struct_ref (HandleStructs *x)
2492 printf ("Dingus Ref! \n");
2493 printf ("Values: %d %d %p %p\n", x->a, x->b, x->handle1, x->handle2);
2499 if (x->handle1 != (void*) 0x7080feed)
2502 if (x->handle2 != (void*) 0x1234abcd)
2508 LIBTEST_API int STDCALL
2509 mono_safe_handle_struct (HandleStructs x)
2511 printf ("Dingus Standard! \n");
2512 printf ("Values: %d %d %p %p\n", x.a, x.b, x.handle1, x.handle2);
2518 if (x.handle1 != (void*) 0x7080feed)
2521 if (x.handle2 != (void*) 0x1234abcd)
2531 LIBTEST_API int STDCALL
2532 mono_safe_handle_struct_simple (TrivialHandle x)
2534 printf ("The value is %p\n", x.a);
2535 return ((int)(gsize)x.a) * 2;
2538 LIBTEST_API int STDCALL
2539 mono_safe_handle_return (void)
2544 LIBTEST_API void STDCALL
2545 mono_safe_handle_ref (void **handle)
2548 *handle = (void *) 0xbad;
2552 *handle = (void *) 0x800d;
2555 LIBTEST_API double STDCALL
2556 mono_test_marshal_date_time (double d, double *d2)
2628 VT_USERDEFINED = 29,
2636 VT_STREAMED_OBJECT = 68,
2637 VT_STORED_OBJECT = 69,
2638 VT_BLOB_OBJECT = 70,
2646 void VariantInit(VARIANT* vt)
2663 LIBTEST_API int STDCALL
2664 mono_test_marshal_bstr_in(gunichar2* bstr)
2667 gchar* bstr_utf8 = g_utf16_to_utf8 (bstr, -1, NULL, NULL, NULL);
2668 result = strcmp("mono_test_marshal_bstr_in", bstr_utf8);
2675 LIBTEST_API int STDCALL
2676 mono_test_marshal_bstr_out(gunichar2** bstr)
2678 *bstr = marshal_bstr_alloc ("mono_test_marshal_bstr_out");
2682 LIBTEST_API int STDCALL
2683 mono_test_marshal_bstr_in_null(gunichar2* bstr)
2690 LIBTEST_API int STDCALL
2691 mono_test_marshal_bstr_out_null(gunichar2** bstr)
2697 LIBTEST_API int STDCALL
2698 mono_test_marshal_variant_in_sbyte(VARIANT variant)
2700 if (variant.vt == VT_I1 && variant.cVal == 100)
2705 LIBTEST_API int STDCALL
2706 mono_test_marshal_variant_in_byte(VARIANT variant)
2708 if (variant.vt == VT_UI1 && variant.bVal == 100)
2713 LIBTEST_API int STDCALL
2714 mono_test_marshal_variant_in_short(VARIANT variant)
2716 if (variant.vt == VT_I2 && variant.iVal == 314)
2721 LIBTEST_API int STDCALL
2722 mono_test_marshal_variant_in_ushort(VARIANT variant)
2724 if (variant.vt == VT_UI2 && variant.uiVal == 314)
2729 LIBTEST_API int STDCALL
2730 mono_test_marshal_variant_in_int(VARIANT variant)
2732 if (variant.vt == VT_I4 && variant.lVal == 314)
2737 LIBTEST_API int STDCALL
2738 mono_test_marshal_variant_in_uint(VARIANT variant)
2740 if (variant.vt == VT_UI4 && variant.ulVal == 314)
2745 LIBTEST_API int STDCALL
2746 mono_test_marshal_variant_in_long(VARIANT variant)
2748 if (variant.vt == VT_I8 && variant.llVal == 314)
2753 LIBTEST_API int STDCALL
2754 mono_test_marshal_variant_in_ulong(VARIANT variant)
2756 if (variant.vt == VT_UI8 && variant.ullVal == 314)
2761 LIBTEST_API int STDCALL
2762 mono_test_marshal_variant_in_float(VARIANT variant)
2764 if (variant.vt == VT_R4 && (variant.fltVal - 3.14)/3.14 < .001)
2769 LIBTEST_API int STDCALL
2770 mono_test_marshal_variant_in_double(VARIANT variant)
2772 if (variant.vt == VT_R8 && (variant.dblVal - 3.14)/3.14 < .001)
2777 LIBTEST_API int STDCALL
2778 mono_test_marshal_variant_in_bstr(VARIANT variant)
2781 gchar* bstr_utf8 = g_utf16_to_utf8 (variant.bstrVal, -1, NULL, NULL, NULL);
2782 result = strcmp("PI", bstr_utf8);
2785 if (variant.vt == VT_BSTR && !result)
2790 LIBTEST_API int STDCALL
2791 mono_test_marshal_variant_in_bool_true (VARIANT variant)
2793 if (variant.vt == VT_BOOL && variant.boolVal == VARIANT_TRUE)
2798 LIBTEST_API int STDCALL
2799 mono_test_marshal_variant_in_bool_false (VARIANT variant)
2801 if (variant.vt == VT_BOOL && variant.boolVal == VARIANT_FALSE)
2806 LIBTEST_API int STDCALL
2807 mono_test_marshal_variant_out_sbyte(VARIANT* variant)
2809 variant->vt = VT_I1;
2810 variant->cVal = 100;
2815 LIBTEST_API int STDCALL
2816 mono_test_marshal_variant_out_sbyte_byref(VARIANT* variant)
2818 variant->vt = VT_I1|VT_BYREF;
2819 variant->byref = marshal_alloc(1);
2820 *((gint8*)variant->byref) = 100;
2825 LIBTEST_API int STDCALL
2826 mono_test_marshal_variant_out_byte(VARIANT* variant)
2828 variant->vt = VT_UI1;
2829 variant->bVal = 100;
2834 LIBTEST_API int STDCALL
2835 mono_test_marshal_variant_out_byte_byref(VARIANT* variant)
2837 variant->vt = VT_UI1|VT_BYREF;
2838 variant->byref = marshal_alloc(1);
2839 *((gint8*)variant->byref) = 100;
2844 LIBTEST_API int STDCALL
2845 mono_test_marshal_variant_out_short(VARIANT* variant)
2847 variant->vt = VT_I2;
2848 variant->iVal = 314;
2853 LIBTEST_API int STDCALL
2854 mono_test_marshal_variant_out_short_byref(VARIANT* variant)
2856 variant->vt = VT_I2|VT_BYREF;
2857 variant->byref = marshal_alloc(2);
2858 *((gint16*)variant->byref) = 314;
2863 LIBTEST_API int STDCALL
2864 mono_test_marshal_variant_out_ushort(VARIANT* variant)
2866 variant->vt = VT_UI2;
2867 variant->uiVal = 314;
2872 LIBTEST_API int STDCALL
2873 mono_test_marshal_variant_out_ushort_byref(VARIANT* variant)
2875 variant->vt = VT_UI2|VT_BYREF;
2876 variant->byref = marshal_alloc(2);
2877 *((guint16*)variant->byref) = 314;
2882 LIBTEST_API int STDCALL
2883 mono_test_marshal_variant_out_int(VARIANT* variant)
2885 variant->vt = VT_I4;
2886 variant->lVal = 314;
2891 LIBTEST_API int STDCALL
2892 mono_test_marshal_variant_out_int_byref(VARIANT* variant)
2894 variant->vt = VT_I4|VT_BYREF;
2895 variant->byref = marshal_alloc(4);
2896 *((gint32*)variant->byref) = 314;
2901 LIBTEST_API int STDCALL
2902 mono_test_marshal_variant_out_uint(VARIANT* variant)
2904 variant->vt = VT_UI4;
2905 variant->ulVal = 314;
2910 LIBTEST_API int STDCALL
2911 mono_test_marshal_variant_out_uint_byref(VARIANT* variant)
2913 variant->vt = VT_UI4|VT_BYREF;
2914 variant->byref = marshal_alloc(4);
2915 *((guint32*)variant->byref) = 314;
2920 LIBTEST_API int STDCALL
2921 mono_test_marshal_variant_out_long(VARIANT* variant)
2923 variant->vt = VT_I8;
2924 variant->llVal = 314;
2929 LIBTEST_API int STDCALL
2930 mono_test_marshal_variant_out_long_byref(VARIANT* variant)
2932 variant->vt = VT_I8|VT_BYREF;
2933 variant->byref = marshal_alloc(8);
2934 *((gint64*)variant->byref) = 314;
2939 LIBTEST_API int STDCALL
2940 mono_test_marshal_variant_out_ulong(VARIANT* variant)
2942 variant->vt = VT_UI8;
2943 variant->ullVal = 314;
2948 LIBTEST_API int STDCALL
2949 mono_test_marshal_variant_out_ulong_byref(VARIANT* variant)
2951 variant->vt = VT_UI8|VT_BYREF;
2952 variant->byref = marshal_alloc(8);
2953 *((guint64*)variant->byref) = 314;
2958 LIBTEST_API int STDCALL
2959 mono_test_marshal_variant_out_float(VARIANT* variant)
2961 variant->vt = VT_R4;
2962 variant->fltVal = 3.14;
2967 LIBTEST_API int STDCALL
2968 mono_test_marshal_variant_out_float_byref(VARIANT* variant)
2970 variant->vt = VT_R4|VT_BYREF;
2971 variant->byref = marshal_alloc(4);
2972 *((float*)variant->byref) = 3.14;
2977 LIBTEST_API int STDCALL
2978 mono_test_marshal_variant_out_double(VARIANT* variant)
2980 variant->vt = VT_R8;
2981 variant->dblVal = 3.14;
2986 LIBTEST_API int STDCALL
2987 mono_test_marshal_variant_out_double_byref(VARIANT* variant)
2989 variant->vt = VT_R8|VT_BYREF;
2990 variant->byref = marshal_alloc(8);
2991 *((double*)variant->byref) = 3.14;
2996 LIBTEST_API int STDCALL
2997 mono_test_marshal_variant_out_bstr(VARIANT* variant)
2999 variant->vt = VT_BSTR;
3000 variant->bstrVal = marshal_bstr_alloc("PI");
3005 LIBTEST_API int STDCALL
3006 mono_test_marshal_variant_out_bstr_byref(VARIANT* variant)
3008 variant->vt = VT_BSTR|VT_BYREF;
3009 variant->byref = marshal_alloc(sizeof(gpointer));
3010 *((gunichar**)variant->byref) = (gunichar*)marshal_bstr_alloc("PI");
3015 LIBTEST_API int STDCALL
3016 mono_test_marshal_variant_out_bool_true (VARIANT* variant)
3018 variant->vt = VT_BOOL;
3019 variant->boolVal = VARIANT_TRUE;
3024 LIBTEST_API int STDCALL
3025 mono_test_marshal_variant_out_bool_true_byref (VARIANT* variant)
3027 variant->vt = VT_BOOL|VT_BYREF;
3028 variant->byref = marshal_alloc(2);
3029 *((gint16*)variant->byref) = VARIANT_TRUE;
3034 LIBTEST_API int STDCALL
3035 mono_test_marshal_variant_out_bool_false (VARIANT* variant)
3037 variant->vt = VT_BOOL;
3038 variant->boolVal = VARIANT_FALSE;
3043 LIBTEST_API int STDCALL
3044 mono_test_marshal_variant_out_bool_false_byref (VARIANT* variant)
3046 variant->vt = VT_BOOL|VT_BYREF;
3047 variant->byref = marshal_alloc(2);
3048 *((gint16*)variant->byref) = VARIANT_FALSE;
3053 typedef int (STDCALL *VarFunc) (int vt, VARIANT variant);
3054 typedef int (STDCALL *VarRefFunc) (int vt, VARIANT* variant);
3056 LIBTEST_API int STDCALL
3057 mono_test_marshal_variant_in_sbyte_unmanaged(VarFunc func)
3062 return func (VT_I1, vt);
3065 LIBTEST_API int STDCALL
3066 mono_test_marshal_variant_in_byte_unmanaged(VarFunc func)
3071 return func (VT_UI1, vt);
3074 LIBTEST_API int STDCALL
3075 mono_test_marshal_variant_in_short_unmanaged(VarFunc func)
3080 return func (VT_I2, vt);
3083 LIBTEST_API int STDCALL
3084 mono_test_marshal_variant_in_ushort_unmanaged(VarFunc func)
3089 return func (VT_UI2, vt);
3092 LIBTEST_API int STDCALL
3093 mono_test_marshal_variant_in_int_unmanaged(VarFunc func)
3098 return func (VT_I4, vt);
3101 LIBTEST_API int STDCALL
3102 mono_test_marshal_variant_in_uint_unmanaged(VarFunc func)
3107 return func (VT_UI4, vt);
3110 LIBTEST_API int STDCALL
3111 mono_test_marshal_variant_in_long_unmanaged(VarFunc func)
3116 return func (VT_I8, vt);
3119 LIBTEST_API int STDCALL
3120 mono_test_marshal_variant_in_ulong_unmanaged(VarFunc func)
3125 return func (VT_UI8, vt);
3128 LIBTEST_API int STDCALL
3129 mono_test_marshal_variant_in_float_unmanaged(VarFunc func)
3134 return func (VT_R4, vt);
3137 LIBTEST_API int STDCALL
3138 mono_test_marshal_variant_in_double_unmanaged(VarFunc func)
3143 return func (VT_R8, vt);
3146 LIBTEST_API int STDCALL
3147 mono_test_marshal_variant_in_bstr_unmanaged(VarFunc func)
3151 vt.bstrVal = marshal_bstr_alloc("PI");
3152 return func (VT_BSTR, vt);
3155 LIBTEST_API int STDCALL
3156 mono_test_marshal_variant_in_bool_true_unmanaged(VarFunc func)
3160 vt.boolVal = VARIANT_TRUE;
3161 return func (VT_BOOL, vt);
3164 LIBTEST_API int STDCALL
3165 mono_test_marshal_variant_in_bool_false_unmanaged(VarFunc func)
3169 vt.boolVal = VARIANT_FALSE;
3170 return func (VT_BOOL, vt);
3173 LIBTEST_API int STDCALL
3174 mono_test_marshal_variant_out_sbyte_unmanaged(VarRefFunc func)
3179 if (vt.vt == VT_I1 && vt.cVal == -100)
3184 LIBTEST_API int STDCALL
3185 mono_test_marshal_variant_out_byte_unmanaged(VarRefFunc func)
3190 if (vt.vt == VT_UI1 && vt.bVal == 100)
3195 LIBTEST_API int STDCALL
3196 mono_test_marshal_variant_out_short_unmanaged(VarRefFunc func)
3201 if (vt.vt == VT_I2 && vt.iVal == -100)
3206 LIBTEST_API int STDCALL
3207 mono_test_marshal_variant_out_ushort_unmanaged(VarRefFunc func)
3212 if (vt.vt == VT_UI2 && vt.uiVal == 100)
3217 LIBTEST_API int STDCALL
3218 mono_test_marshal_variant_out_int_unmanaged(VarRefFunc func)
3223 if (vt.vt == VT_I4 && vt.lVal == -100)
3228 LIBTEST_API int STDCALL
3229 mono_test_marshal_variant_out_uint_unmanaged(VarRefFunc func)
3234 if (vt.vt == VT_UI4 && vt.ulVal == 100)
3239 LIBTEST_API int STDCALL
3240 mono_test_marshal_variant_out_long_unmanaged(VarRefFunc func)
3245 if (vt.vt == VT_I8 && vt.llVal == -100)
3250 LIBTEST_API int STDCALL
3251 mono_test_marshal_variant_out_ulong_unmanaged(VarRefFunc func)
3256 if (vt.vt == VT_UI8 && vt.ullVal == 100)
3261 LIBTEST_API int STDCALL
3262 mono_test_marshal_variant_out_float_unmanaged(VarRefFunc func)
3267 if (vt.vt == VT_R4 && fabs (vt.fltVal - 3.14f) < 1e-10)
3272 LIBTEST_API int STDCALL
3273 mono_test_marshal_variant_out_double_unmanaged(VarRefFunc func)
3278 if (vt.vt == VT_R8 && fabs (vt.dblVal - 3.14) < 1e-10)
3283 LIBTEST_API int STDCALL
3284 mono_test_marshal_variant_out_bstr_unmanaged(VarRefFunc func)
3292 func (VT_BSTR, &vt);
3293 bstr_utf8 = g_utf16_to_utf8 (vt.bstrVal, -1, NULL, NULL, NULL);
3294 result = strcmp("PI", bstr_utf8);
3296 if (vt.vt == VT_BSTR && !result)
3301 LIBTEST_API int STDCALL
3302 mono_test_marshal_variant_out_bool_true_unmanaged(VarRefFunc func)
3306 func (VT_BOOL, &vt);
3307 if (vt.vt == VT_BOOL && vt.boolVal == VARIANT_TRUE)
3312 LIBTEST_API int STDCALL
3313 mono_test_marshal_variant_out_bool_false_unmanaged(VarRefFunc func)
3317 func (VT_BOOL, &vt);
3318 if (vt.vt == VT_BOOL && vt.boolVal == VARIANT_TRUE)
3323 typedef struct MonoComObject MonoComObject;
3327 int (STDCALL *QueryInterface)(MonoComObject* pUnk, gpointer riid, gpointer* ppv);
3328 int (STDCALL *AddRef)(MonoComObject* pUnk);
3329 int (STDCALL *Release)(MonoComObject* pUnk);
3330 int (STDCALL *get_ITest)(MonoComObject* pUnk, MonoComObject* *ppUnk);
3331 int (STDCALL *SByteIn)(MonoComObject* pUnk, char a);
3332 int (STDCALL *ByteIn)(MonoComObject* pUnk, unsigned char a);
3333 int (STDCALL *ShortIn)(MonoComObject* pUnk, short a);
3334 int (STDCALL *UShortIn)(MonoComObject* pUnk, unsigned short a);
3335 int (STDCALL *IntIn)(MonoComObject* pUnk, int a);
3336 int (STDCALL *UIntIn)(MonoComObject* pUnk, unsigned int a);
3337 int (STDCALL *LongIn)(MonoComObject* pUnk, gint64 a);
3338 int (STDCALL *ULongIn)(MonoComObject* pUnk, guint64 a);
3339 int (STDCALL *FloatIn)(MonoComObject* pUnk, float a);
3340 int (STDCALL *DoubleIn)(MonoComObject* pUnk, double a);
3341 int (STDCALL *ITestIn)(MonoComObject* pUnk, MonoComObject* pUnk2);
3342 int (STDCALL *ITestOut)(MonoComObject* pUnk, MonoComObject* *ppUnk);
3343 int (STDCALL *Return22NoICall)(MonoComObject* pUnk);
3346 struct MonoComObject
3352 static GUID IID_ITest = {0, 0, 0, {0,0,0,0,0,0,0,1}};
3353 static GUID IID_IMonoUnknown = {0, 0, 0, {0xc0,0,0,0,0,0,0,0x46}};
3354 static GUID IID_IMonoDispatch = {0x00020400, 0, 0, {0xc0,0,0,0,0,0,0,0x46}};
3356 LIBTEST_API int STDCALL
3357 MonoQueryInterface(MonoComObject* pUnk, gpointer riid, gpointer* ppv)
3361 if (!memcmp(riid, &IID_IMonoUnknown, sizeof(GUID))) {
3365 else if (!memcmp(riid, &IID_ITest, sizeof(GUID))) {
3369 else if (!memcmp(riid, &IID_IMonoDispatch, sizeof(GUID))) {
3373 return 0x80004002; //E_NOINTERFACE;
3376 LIBTEST_API int STDCALL
3377 MonoAddRef(MonoComObject* pUnk)
3379 return ++(pUnk->m_ref);
3382 LIBTEST_API int STDCALL
3383 MonoRelease(MonoComObject* pUnk)
3385 return --(pUnk->m_ref);
3388 LIBTEST_API int STDCALL
3389 SByteIn(MonoComObject* pUnk, char a)
3394 LIBTEST_API int STDCALL
3395 ByteIn(MonoComObject* pUnk, unsigned char a)
3400 LIBTEST_API int STDCALL
3401 ShortIn(MonoComObject* pUnk, short a)
3406 LIBTEST_API int STDCALL
3407 UShortIn(MonoComObject* pUnk, unsigned short a)
3412 LIBTEST_API int STDCALL
3413 IntIn(MonoComObject* pUnk, int a)
3418 LIBTEST_API int STDCALL
3419 UIntIn(MonoComObject* pUnk, unsigned int a)
3424 LIBTEST_API int STDCALL
3425 LongIn(MonoComObject* pUnk, gint64 a)
3430 LIBTEST_API int STDCALL
3431 ULongIn(MonoComObject* pUnk, guint64 a)
3436 LIBTEST_API int STDCALL
3437 FloatIn(MonoComObject* pUnk, float a)
3442 LIBTEST_API int STDCALL
3443 DoubleIn(MonoComObject* pUnk, double a)
3448 LIBTEST_API int STDCALL
3449 ITestIn(MonoComObject* pUnk, MonoComObject *pUnk2)
3454 LIBTEST_API int STDCALL
3455 ITestOut(MonoComObject* pUnk, MonoComObject* *ppUnk)
3460 LIBTEST_API int STDCALL
3461 Return22NoICall(MonoComObject* pUnk)
3467 static void create_com_object (MonoComObject** pOut);
3469 LIBTEST_API int STDCALL
3470 get_ITest(MonoComObject* pUnk, MonoComObject* *ppUnk)
3472 create_com_object (ppUnk);
3476 static void create_com_object (MonoComObject** pOut)
3478 *pOut = marshal_new0 (MonoComObject, 1);
3479 (*pOut)->vtbl = marshal_new0 (MonoIUnknown, 1);
3482 (*pOut)->vtbl->QueryInterface = MonoQueryInterface;
3483 (*pOut)->vtbl->AddRef = MonoAddRef;
3484 (*pOut)->vtbl->Release = MonoRelease;
3485 (*pOut)->vtbl->SByteIn = SByteIn;
3486 (*pOut)->vtbl->ByteIn = ByteIn;
3487 (*pOut)->vtbl->ShortIn = ShortIn;
3488 (*pOut)->vtbl->UShortIn = UShortIn;
3489 (*pOut)->vtbl->IntIn = IntIn;
3490 (*pOut)->vtbl->UIntIn = UIntIn;
3491 (*pOut)->vtbl->LongIn = LongIn;
3492 (*pOut)->vtbl->ULongIn = ULongIn;
3493 (*pOut)->vtbl->FloatIn = FloatIn;
3494 (*pOut)->vtbl->DoubleIn = DoubleIn;
3495 (*pOut)->vtbl->ITestIn = ITestIn;
3496 (*pOut)->vtbl->ITestOut = ITestOut;
3497 (*pOut)->vtbl->get_ITest = get_ITest;
3498 (*pOut)->vtbl->Return22NoICall = Return22NoICall;
3501 static MonoComObject* same_object = NULL;
3503 LIBTEST_API int STDCALL
3504 mono_test_marshal_com_object_create(MonoComObject* *pUnk)
3506 create_com_object (pUnk);
3509 same_object = *pUnk;
3514 LIBTEST_API int STDCALL
3515 mono_test_marshal_com_object_same(MonoComObject* *pUnk)
3517 *pUnk = same_object;
3522 LIBTEST_API int STDCALL
3523 mono_test_marshal_com_object_destroy(MonoComObject *pUnk)
3525 int ref = --(pUnk->m_ref);
3532 LIBTEST_API int STDCALL
3533 mono_test_marshal_com_object_ref_count(MonoComObject *pUnk)
3538 LIBTEST_API int STDCALL
3539 mono_test_marshal_ccw_itest (MonoComObject *pUnk)
3542 MonoComObject* pTest;
3547 hr = pUnk->vtbl->SByteIn (pUnk, -100);
3550 hr = pUnk->vtbl->ByteIn (pUnk, 100);
3553 hr = pUnk->vtbl->ShortIn (pUnk, -100);
3556 hr = pUnk->vtbl->UShortIn (pUnk, 100);
3559 hr = pUnk->vtbl->IntIn (pUnk, -100);
3562 hr = pUnk->vtbl->UIntIn (pUnk, 100);
3565 hr = pUnk->vtbl->LongIn (pUnk, -100);
3568 hr = pUnk->vtbl->ULongIn (pUnk, 100);
3571 hr = pUnk->vtbl->FloatIn (pUnk, 3.14f);
3574 hr = pUnk->vtbl->DoubleIn (pUnk, 3.14);
3577 hr = pUnk->vtbl->ITestIn (pUnk, pUnk);
3580 hr = pUnk->vtbl->ITestOut (pUnk, &pTest);
3588 LIBTEST_API int STDCALL
3589 mono_test_marshal_array_ccw_itest (int count, MonoComObject ** ppUnk)
3602 hr = ppUnk[0]->vtbl->SByteIn (ppUnk[0], -100);
3610 * mono_method_get_unmanaged_thunk tests
3613 #if defined(__GNUC__) && ((defined(__i386__) && (defined(__linux__) || defined (__APPLE__)) || defined (__FreeBSD__) || defined(__OpenBSD__)) || (defined(__ppc__) && defined(__APPLE__)))
3614 #define ALIGN(size) __attribute__ ((__aligned__(size)))
3620 /* thunks.cs:TestStruct */
3621 typedef struct _TestStruct {
3626 /* Searches for mono symbols in all loaded modules */
3628 lookup_mono_symbol (const char *symbol_name)
3631 if (g_module_symbol (g_module_open (NULL, G_MODULE_BIND_LAZY), symbol_name, &symbol))
3637 LIBTEST_API gpointer STDCALL
3638 mono_test_marshal_lookup_symbol (const char *symbol_name)
3640 return lookup_mono_symbol (symbol_name);
3643 #define MONO_BEGIN_EFRAME { void *__dummy; void *__region_cookie = mono_threads_enter_gc_unsafe_region ? mono_threads_enter_gc_unsafe_region (&__dummy) : NULL;
3644 #define MONO_END_EFRAME if (mono_threads_exit_gc_unsafe_region) mono_threads_exit_gc_unsafe_region (__region_cookie, &__dummy); }
3647 * test_method_thunk:
3649 * @test_id: the test number
3650 * @test_method_handle: MonoMethod* of the C# test method
3651 * @create_object_method_handle: MonoMethod* of thunks.cs:Test.CreateObject
3653 LIBTEST_API int STDCALL
3654 test_method_thunk (int test_id, gpointer test_method_handle, gpointer create_object_method_handle)
3658 gpointer (*mono_method_get_unmanaged_thunk)(gpointer)
3659 = (gpointer (*)(gpointer))lookup_mono_symbol ("mono_method_get_unmanaged_thunk");
3661 gpointer (*mono_string_new_wrapper)(const char *)
3662 = (gpointer (*)(const char *))lookup_mono_symbol ("mono_string_new_wrapper");
3664 char *(*mono_string_to_utf8)(gpointer)
3665 = (char *(*)(gpointer))lookup_mono_symbol ("mono_string_to_utf8");
3667 gpointer (*mono_object_unbox)(gpointer)
3668 = (gpointer (*)(gpointer))lookup_mono_symbol ("mono_object_unbox");
3670 gpointer (*mono_threads_enter_gc_unsafe_region) (gpointer)
3671 = (gpointer (*)(gpointer))lookup_mono_symbol ("mono_threads_enter_gc_unsafe_region");
3673 void (*mono_threads_exit_gc_unsafe_region) (gpointer, gpointer)
3674 = (void (*)(gpointer, gpointer))lookup_mono_symbol ("mono_threads_exit_gc_unsafe_region");
3678 gpointer test_method, ex = NULL;
3679 gpointer (STDCALL *CreateObject)(gpointer*);
3683 if (!mono_method_get_unmanaged_thunk) {
3688 test_method = mono_method_get_unmanaged_thunk (test_method_handle);
3694 CreateObject = (gpointer (STDCALL *)(gpointer *))mono_method_get_unmanaged_thunk (create_object_method_handle);
3695 if (!CreateObject) {
3704 /* thunks.cs:Test.Test0 */
3705 void (STDCALL *F)(gpointer *) = (void (STDCALL *)(gpointer *))test_method;
3711 /* thunks.cs:Test.Test1 */
3712 int (STDCALL *F)(gpointer *) = (int (STDCALL *)(gpointer *))test_method;
3713 if (F (&ex) != 42) {
3721 /* thunks.cs:Test.Test2 */
3722 gpointer (STDCALL *F)(gpointer, gpointer*) = (gpointer (STDCALL *)(gpointer, gpointer *))test_method;
3723 gpointer str = mono_string_new_wrapper ("foo");
3724 if (str != F (str, &ex)) {
3732 /* thunks.cs:Test.Test3 */
3733 gpointer (STDCALL *F)(gpointer, gpointer, gpointer*);
3737 F = (gpointer (STDCALL *)(gpointer, gpointer, gpointer *))test_method;
3738 obj = CreateObject (&ex);
3739 str = mono_string_new_wrapper ("bar");
3741 if (str != F (obj, str, &ex)) {
3749 /* thunks.cs:Test.Test4 */
3750 int (STDCALL *F)(gpointer, gpointer, int, gpointer*);
3754 F = (int (STDCALL *)(gpointer, gpointer, int, gpointer *))test_method;
3755 obj = CreateObject (&ex);
3756 str = mono_string_new_wrapper ("bar");
3758 if (42 != F (obj, str, 42, &ex)) {
3767 /* thunks.cs:Test.Test5 */
3768 int (STDCALL *F)(gpointer, gpointer, int, gpointer*);
3772 F = (int (STDCALL *)(gpointer, gpointer, int, gpointer *))test_method;
3773 obj = CreateObject (&ex);
3774 str = mono_string_new_wrapper ("bar");
3776 F (obj, str, 42, &ex);
3786 /* thunks.cs:Test.Test6 */
3787 int (STDCALL *F)(gpointer, guint8, gint16, gint32, gint64, float, double,
3788 gpointer, gpointer*);
3790 gpointer str = mono_string_new_wrapper ("Test6");
3793 F = (int (STDCALL *)(gpointer, guint8, gint16, gint32, gint64, float, double, gpointer, gpointer *))test_method;
3794 obj = CreateObject (&ex);
3796 res = F (obj, 254, 32700, -245378, 6789600, 3.1415, 3.1415, str, &ex);
3811 /* thunks.cs:Test.Test7 */
3812 gint64 (STDCALL *F)(gpointer*) = (gint64 (STDCALL *)(gpointer *))test_method;
3813 if (F (&ex) != G_MAXINT64) {
3821 /* thunks.cs:Test.Test8 */
3822 void (STDCALL *F)(guint8*, gint16*, gint32*, gint64*, float*, double*,
3823 gpointer*, gpointer*);
3833 F = (void (STDCALL *)(guint8 *, gint16 *, gint32 *, gint64 *, float *, double *,
3834 gpointer *, gpointer *))test_method;
3836 F (&a1, &a2, &a3, &a4, &a5, &a6, &a7, &ex);
3846 (fabs (a5 - 3.1415) < 0.001) &&
3847 (fabs (a6 - 3.1415) < 0.001) &&
3848 strcmp (mono_string_to_utf8 (a7), "Test8") == 0)){
3857 /* thunks.cs:Test.Test9 */
3858 void (STDCALL *F)(guint8*, gint16*, gint32*, gint64*, float*, double*,
3859 gpointer*, gpointer*);
3869 F = (void (STDCALL *)(guint8 *, gint16 *, gint32 *, gint64 *, float *, double *,
3870 gpointer *, gpointer *))test_method;
3872 F (&a1, &a2, &a3, &a4, &a5, &a6, &a7, &ex);
3882 /* thunks.cs:Test.Test10 */
3883 void (STDCALL *F)(gpointer*, gpointer*);
3885 gpointer obj1, obj2;
3887 obj1 = obj2 = CreateObject (&ex);
3893 F = (void (STDCALL *)(gpointer *, gpointer *))test_method;
3910 /* thunks.cs:TestStruct.Test0 */
3911 int (STDCALL *F)(gpointer*, gpointer*);
3917 obj = CreateObject (&ex);
3928 a1 = (TestStruct *)mono_object_unbox (obj);
3937 F = (int (STDCALL *)(gpointer *, gpointer *))test_method;
3939 res = F ((gpointer *)obj, &ex);
3950 /* check whether the call was really by value */
3951 if (a1->A != 42 || a1->B != 3.1415) {
3960 /* thunks.cs:TestStruct.Test1 */
3961 void (STDCALL *F)(gpointer, gpointer*);
3966 obj = CreateObject (&ex);
3977 a1 = (TestStruct *)mono_object_unbox (obj);
3983 F = (void (STDCALL *)(gpointer, gpointer *))test_method;
3996 if (!(fabs (a1->B - 3.1415) < 0.001)) {
4005 /* thunks.cs:TestStruct.Test2 */
4006 gpointer (STDCALL *F)(gpointer*);
4011 F = (gpointer (STDCALL *)(gpointer *))test_method;
4024 a1 = (TestStruct *)mono_object_unbox (obj);
4031 if (!(fabs (a1->B - 3.1415) < 0.001)) {
4040 /* thunks.cs:TestStruct.Test3 */
4041 void (STDCALL *F)(gpointer, gpointer*);
4046 obj = CreateObject (&ex);
4057 a1 = (TestStruct *)mono_object_unbox (obj);
4067 F = (void (STDCALL *)(gpointer, gpointer *))test_method;
4103 LIBTEST_API int STDCALL
4104 mono_test_Winx64_struct1_in (winx64_struct1 var)
4117 LIBTEST_API int STDCALL
4118 mono_test_Winx64_struct2_in (winx64_struct2 var)
4135 LIBTEST_API int STDCALL
4136 mono_test_Winx64_struct3_in (winx64_struct3 var)
4142 if (var.c != 0x1234)
4155 LIBTEST_API int STDCALL
4156 mono_test_Winx64_struct4_in (winx64_struct4 var)
4162 if (var.c != 0x1234)
4164 if (var.d != 0x87654321)
4176 LIBTEST_API int STDCALL
4177 mono_test_Winx64_struct5_in (winx64_struct5 var)
4195 LIBTEST_API int STDCALL
4196 mono_test_Winx64_struct6_in (winx64_struct6 var)
4207 LIBTEST_API int STDCALL
4208 mono_test_Winx64_structs_in1 (winx64_struct1 var1,
4209 winx64_struct2 var2,
4210 winx64_struct3 var3,
4211 winx64_struct4 var4)
4225 if (var3.c != 0x1234)
4232 if (var4.c != 0x1234)
4234 if (var4.d != 0x87654321)
4239 LIBTEST_API int STDCALL
4240 mono_test_Winx64_structs_in2 (winx64_struct1 var1,
4241 winx64_struct1 var2,
4242 winx64_struct1 var3,
4243 winx64_struct1 var4,
4244 winx64_struct1 var5)
4260 LIBTEST_API int STDCALL
4261 mono_test_Winx64_structs_in3 (winx64_struct1 var1,
4262 winx64_struct5 var2,
4263 winx64_struct1 var3,
4264 winx64_struct5 var4,
4265 winx64_struct1 var5,
4266 winx64_struct5 var6)
4301 LIBTEST_API winx64_struct1 STDCALL
4302 mono_test_Winx64_struct1_ret (void)
4309 LIBTEST_API winx64_struct2 STDCALL
4310 mono_test_Winx64_struct2_ret (void)
4318 LIBTEST_API winx64_struct3 STDCALL
4319 mono_test_Winx64_struct3_ret (void)
4328 LIBTEST_API winx64_struct4 STDCALL
4329 mono_test_Winx64_struct4_ret (void)
4339 LIBTEST_API winx64_struct5 STDCALL
4340 mono_test_Winx64_struct5_ret (void)
4349 LIBTEST_API winx64_struct1 STDCALL
4350 mono_test_Winx64_struct1_ret_5_args (char a, char b, char c, char d, char e)
4353 ret.a = a + b + c + d + e;
4357 LIBTEST_API winx64_struct5 STDCALL
4358 mono_test_Winx64_struct5_ret6_args (char a, char b, char c, char d, char e)
4371 } winx64_floatStruct;
4373 LIBTEST_API int STDCALL
4374 mono_test_Winx64_floatStruct (winx64_floatStruct a)
4376 if (a.a > 5.6 || a.a < 5.4)
4379 if (a.b > 9.6 || a.b < 9.4)
4388 } winx64_doubleStruct;
4390 LIBTEST_API int STDCALL
4391 mono_test_Winx64_doubleStruct (winx64_doubleStruct a)
4393 if (a.a > 5.6 || a.a < 5.4)
4399 typedef int (STDCALL *managed_struct1_delegate) (winx64_struct1 a);
4401 LIBTEST_API int STDCALL
4402 mono_test_managed_Winx64_struct1_in(managed_struct1_delegate func)
4409 typedef int (STDCALL *managed_struct5_delegate) (winx64_struct5 a);
4411 LIBTEST_API int STDCALL
4412 mono_test_managed_Winx64_struct5_in(managed_struct5_delegate func)
4421 typedef int (STDCALL *managed_struct1_struct5_delegate) (winx64_struct1 a, winx64_struct5 b,
4422 winx64_struct1 c, winx64_struct5 d,
4423 winx64_struct1 e, winx64_struct5 f);
4425 LIBTEST_API int STDCALL
4426 mono_test_managed_Winx64_struct1_struct5_in(managed_struct1_struct5_delegate func)
4428 winx64_struct1 a, c, e;
4429 winx64_struct5 b, d, f;
4431 b.a = 2; b.b = 3; b.c = 4;
4433 d.a = 6; d.b = 7; d.c = 8;
4435 f.a = 10; f.b = 11; f.c = 12;
4437 return func (a, b, c, d, e, f);
4440 typedef winx64_struct1 (STDCALL *managed_struct1_ret_delegate) (void);
4442 LIBTEST_API int STDCALL
4443 mono_test_Winx64_struct1_ret_managed (managed_struct1_ret_delegate func)
4455 typedef winx64_struct5 (STDCALL *managed_struct5_ret_delegate) (void);
4457 LIBTEST_API int STDCALL
4458 mono_test_Winx64_struct5_ret_managed (managed_struct5_ret_delegate func)
4474 LIBTEST_API int STDCALL
4475 mono_test_marshal_bool_in (int arg, unsigned int expected, unsigned int bDefaultMarsh, unsigned int bBoolCustMarsh,
4476 char bI1CustMarsh, unsigned char bU1CustMarsh, short bVBCustMarsh)
4480 if (bDefaultMarsh != expected)
4484 if (bBoolCustMarsh != expected)
4488 if (bI1CustMarsh != expected)
4492 if (bU1CustMarsh != expected)
4496 if (bVBCustMarsh != expected)
4505 LIBTEST_API int STDCALL
4506 mono_test_marshal_bool_out (int arg, unsigned int testVal, unsigned int* bDefaultMarsh, unsigned int* bBoolCustMarsh,
4507 char* bI1CustMarsh, unsigned char* bU1CustMarsh, unsigned short* bVBCustMarsh)
4513 *bDefaultMarsh = testVal;
4516 if (!bBoolCustMarsh)
4518 *bBoolCustMarsh = testVal;
4523 *bI1CustMarsh = (char)testVal;
4528 *bU1CustMarsh = (unsigned char)testVal;
4533 *bVBCustMarsh = (unsigned short)testVal;
4541 LIBTEST_API int STDCALL
4542 mono_test_marshal_bool_ref (int arg, unsigned int expected, unsigned int testVal, unsigned int* bDefaultMarsh,
4543 unsigned int* bBoolCustMarsh, char* bI1CustMarsh, unsigned char* bU1CustMarsh,
4544 unsigned short* bVBCustMarsh)
4550 if (*bDefaultMarsh != expected)
4552 *bDefaultMarsh = testVal;
4555 if (!bBoolCustMarsh)
4557 if (*bBoolCustMarsh != expected)
4559 *bBoolCustMarsh = testVal;
4564 if (*bI1CustMarsh != expected)
4566 *bI1CustMarsh = (char)testVal;
4571 if (*bU1CustMarsh != expected)
4573 *bU1CustMarsh = (unsigned char)testVal;
4578 if (*bVBCustMarsh != expected)
4580 *bVBCustMarsh = (unsigned short)testVal;
4589 typedef int (STDCALL *MarshalBoolInDelegate) (int arg, unsigned int expected, unsigned int bDefaultMarsh,
4590 unsigned int bBoolCustMarsh, char bI1CustMarsh, unsigned char bU1CustMarsh, unsigned short bVBCustMarsh);
4592 LIBTEST_API int STDCALL
4593 mono_test_managed_marshal_bool_in (int arg, unsigned int expected, unsigned int testVal, MarshalBoolInDelegate pfcn)
4600 return pfcn (arg, expected, testVal, 0, 0, 0, 0);
4602 return pfcn (arg, expected, 0, testVal, 0, 0, 0);
4604 return pfcn (arg, expected, 0, 0, testVal, 0, 0);
4606 return pfcn (arg, expected, 0, 0, 0, testVal, 0);
4608 return pfcn (arg, expected, 0, 0, 0, 0, testVal);
4616 typedef int (STDCALL *MarshalBoolOutDelegate) (int arg, unsigned int expected, unsigned int* bDefaultMarsh,
4617 unsigned int* bBoolCustMarsh, char* bI1CustMarsh, unsigned char* bU1CustMarsh, unsigned short* bVBCustMarsh);
4619 LIBTEST_API int STDCALL
4620 mono_test_managed_marshal_bool_out (int arg, unsigned int expected, unsigned int testVal, MarshalBoolOutDelegate pfcn)
4623 unsigned int lDefaultMarsh, lBoolCustMarsh;
4624 char lI1CustMarsh = 0;
4625 unsigned char lU1CustMarsh = 0;
4626 unsigned short lVBCustMarsh = 0;
4627 lDefaultMarsh = lBoolCustMarsh = 0;
4634 unsigned int ltVal = 0;
4635 ret = pfcn (arg, testVal, <Val, &lBoolCustMarsh, &lI1CustMarsh, &lU1CustMarsh, &lVBCustMarsh);
4637 return 0x0100 + ret;
4638 if (expected != ltVal)
4643 unsigned int ltVal = 0;
4644 ret = pfcn (arg, testVal, &lDefaultMarsh, <Val, &lI1CustMarsh, &lU1CustMarsh, &lVBCustMarsh);
4646 return 0x0300 + ret;
4647 if (expected != ltVal)
4653 ret = pfcn (arg, testVal, &lDefaultMarsh, &lBoolCustMarsh, <Val, &lU1CustMarsh, &lVBCustMarsh);
4655 return 0x0500 + ret;
4656 if (expected != ltVal)
4661 unsigned char ltVal = 0;
4662 ret = pfcn (arg, testVal, &lDefaultMarsh, &lBoolCustMarsh, &lI1CustMarsh, <Val, &lVBCustMarsh);
4664 return 0x0700 + ret;
4665 if (expected != ltVal)
4670 unsigned short ltVal = 0;
4671 ret = pfcn (arg, testVal, &lDefaultMarsh, &lBoolCustMarsh, &lI1CustMarsh, &lU1CustMarsh, <Val);
4673 return 0x0900 + ret;
4674 if (expected != ltVal)
4685 typedef int (STDCALL *MarshalBoolRefDelegate) (int arg, unsigned int expected, unsigned int testVal, unsigned int* bDefaultMarsh,
4686 unsigned int* bBoolCustMarsh, char* bI1CustMarsh, unsigned char* bU1CustMarsh, unsigned short* bVBCustMarsh);
4688 LIBTEST_API int STDCALL
4689 mono_test_managed_marshal_bool_ref (int arg, unsigned int expected, unsigned int testVal, unsigned int outExpected,
4690 unsigned int outTestVal, MarshalBoolRefDelegate pfcn)
4693 unsigned int lDefaultMarsh, lBoolCustMarsh;
4694 char lI1CustMarsh = 0;
4695 unsigned char lU1CustMarsh = 0;
4696 unsigned short lVBCustMarsh = 0;
4697 lDefaultMarsh = lBoolCustMarsh = 0;
4705 unsigned int ltestVal = testVal;
4706 ret = pfcn (arg, expected, outTestVal, <estVal, &lBoolCustMarsh, &lI1CustMarsh, &lU1CustMarsh, &lVBCustMarsh);
4708 return 0x0100 + ret;
4709 if (outExpected != ltestVal)
4715 unsigned int ltestVal = testVal;
4716 ret = pfcn (arg, expected, outTestVal, &lDefaultMarsh, <estVal, &lI1CustMarsh, &lU1CustMarsh, &lVBCustMarsh);
4718 return 0x0300 + ret;
4719 if (outExpected != ltestVal)
4725 char ltestVal = testVal;
4726 ret = pfcn (arg, expected, outTestVal, &lDefaultMarsh, &lBoolCustMarsh, <estVal, &lU1CustMarsh, &lVBCustMarsh);
4728 return 0x0500 + ret;
4729 if (outExpected != ltestVal)
4735 unsigned char ltestVal = testVal;
4736 ret = pfcn (arg, expected, outTestVal, &lDefaultMarsh, &lBoolCustMarsh, &lI1CustMarsh, <estVal, &lVBCustMarsh);
4738 return 0x0700 + ret;
4739 if (outExpected != ltestVal)
4745 unsigned short ltestVal = testVal;
4746 ret = pfcn (arg, expected, outTestVal, &lDefaultMarsh, &lBoolCustMarsh, &lI1CustMarsh, &lU1CustMarsh, <estVal);
4748 return 0x0900 + ret;
4749 if (outExpected != ltestVal)
4762 LIBTEST_API int STDCALL
4763 mono_test_marshal_safearray_out_1dim_vt_bstr_empty (SAFEARRAY** safearray)
4765 /* Create an empty one-dimensional array of variants */
4767 SAFEARRAYBOUND dimensions [1];
4769 dimensions [0].lLbound = 0;
4770 dimensions [0].cElements = 0;
4772 pSA= SafeArrayCreate (VT_VARIANT, 1, dimensions);
4777 LIBTEST_API int STDCALL
4778 mono_test_marshal_safearray_out_1dim_vt_bstr (SAFEARRAY** safearray)
4780 /* Create a one-dimensional array of 10 variants filled with "0" to "9" */
4782 SAFEARRAYBOUND dimensions [1];
4788 dimensions [0].lLbound = 0;
4789 dimensions [0].cElements = 10;
4791 pSA= SafeArrayCreate (VT_VARIANT, 1, dimensions);
4792 for (i= dimensions [0].lLbound; i< (dimensions [0].cElements + dimensions [0].lLbound); i++) {
4794 VariantInit (&vOut);
4796 _ltoa (i,buffer,10);
4797 vOut.bstrVal= marshal_bstr_alloc (buffer);
4799 if ((hr = SafeArrayPutElement (pSA, indices, &vOut)) != S_OK) {
4800 VariantClear (&vOut);
4801 SafeArrayDestroy (pSA);
4804 VariantClear (&vOut);
4810 LIBTEST_API int STDCALL
4811 mono_test_marshal_safearray_out_2dim_vt_i4 (SAFEARRAY** safearray)
4813 /* Create a two-dimensional array of 4x3 variants filled with 11, 12, 13, etc. */
4815 SAFEARRAYBOUND dimensions [2];
4820 dimensions [0].lLbound = 0;
4821 dimensions [0].cElements = 4;
4822 dimensions [1].lLbound = 0;
4823 dimensions [1].cElements = 3;
4825 pSA= SafeArrayCreate(VT_VARIANT, 2, dimensions);
4826 for (i= dimensions [0].lLbound; i< (dimensions [0].cElements + dimensions [0].lLbound); i++) {
4827 for (j= dimensions [1].lLbound; j< (dimensions [1].cElements + dimensions [1].lLbound); j++) {
4829 VariantInit (&vOut);
4831 vOut.lVal = (i+1)*10+(j+1);
4834 if ((hr = SafeArrayPutElement (pSA, indices, &vOut)) != S_OK) {
4835 VariantClear (&vOut);
4836 SafeArrayDestroy (pSA);
4839 VariantClear (&vOut); // does a deep destroy of source VARIANT
4846 LIBTEST_API int STDCALL
4847 mono_test_marshal_safearray_out_4dim_vt_i4 (SAFEARRAY** safearray)
4849 /* Create a four-dimensional array of 10x3x6x7 variants filled with their indices */
4850 /* Also use non zero lower bounds */
4852 SAFEARRAYBOUND dimensions [4];
4857 dimensions [0].lLbound = 15;
4858 dimensions [0].cElements = 10;
4859 dimensions [1].lLbound = 20;
4860 dimensions [1].cElements = 3;
4861 dimensions [2].lLbound = 5;
4862 dimensions [2].cElements = 6;
4863 dimensions [3].lLbound = 12;
4864 dimensions [3].cElements = 7;
4866 pSA= SafeArrayCreate (VT_VARIANT, 4, dimensions);
4868 SafeArrayAccessData (pSA, (void **)&pData);
4870 for (i= 0; i< 10*3*6*7; i++) {
4871 VariantInit(&pData [i]);
4872 pData [i].vt = VT_I4;
4875 SafeArrayUnaccessData (pSA);
4880 LIBTEST_API int STDCALL
4881 mono_test_marshal_safearray_in_byval_1dim_empty (SAFEARRAY* safearray)
4883 /* Check that array is one dimensional and empty */
4886 long lbound, ubound;
4888 dim = SafeArrayGetDim (safearray);
4892 SafeArrayGetLBound (safearray, 1, &lbound);
4893 SafeArrayGetUBound (safearray, 1, &ubound);
4895 if ((lbound > 0) || (ubound > 0))
4901 LIBTEST_API int STDCALL
4902 mono_test_marshal_safearray_in_byval_1dim_vt_i4 (SAFEARRAY* safearray)
4904 /* Check that array is one dimensional containing integers from 1 to 10 */
4907 long lbound, ubound;
4912 dim = SafeArrayGetDim (safearray);
4916 SafeArrayGetLBound (safearray, 1, &lbound);
4917 SafeArrayGetUBound (safearray, 1, &ubound);
4919 if ((lbound != 0) || (ubound != 9))
4922 SafeArrayAccessData (safearray, (void **)&pData);
4923 for (i= lbound; i <= ubound; i++) {
4924 if ((VariantChangeType (&pData [i], &pData [i], VARIANT_NOUSEROVERRIDE, VT_I4) != S_OK) || (pData [i].lVal != i + 1))
4927 SafeArrayUnaccessData (safearray);
4932 LIBTEST_API int STDCALL
4933 mono_test_marshal_safearray_in_byval_1dim_vt_mixed (SAFEARRAY* safearray)
4935 /* Check that array is one dimensional containing integers mixed with strings from 0 to 12 */
4938 long lbound, ubound;
4945 VariantInit (&element);
4947 dim = SafeArrayGetDim (safearray);
4951 SafeArrayGetLBound (safearray, 1, &lbound);
4952 SafeArrayGetUBound (safearray, 1, &ubound);
4954 if ((lbound != 0) || (ubound != 12))
4957 SafeArrayAccessData (safearray, (void **)&pData);
4958 for (i= lbound; i <= ubound; i++) {
4959 if ((i%2 == 0) && (pData [i].vt != VT_I4))
4961 if ((i%2 == 1) && (pData [i].vt != VT_BSTR))
4963 if ((VariantChangeType (&pData [i], &pData [i], VARIANT_NOUSEROVERRIDE, VT_I4) != S_OK) || (pData [i].lVal != i))
4966 SafeArrayUnaccessData (safearray);
4968 /* Change the first element of the array to verify that [in] parameters are not marshalled back to the managed side */
4973 SafeArrayPutElement (safearray, indices, &element);
4974 VariantClear (&element);
4979 LIBTEST_API int STDCALL
4980 mono_test_marshal_safearray_in_byval_2dim_vt_i4 (SAFEARRAY* safearray)
4982 /* Check that array is one dimensional containing integers mixed with strings from 0 to 12 */
4985 long lbound1, ubound1, lbound2, ubound2;
4990 VariantInit (&element);
4992 dim = SafeArrayGetDim (safearray);
4996 SafeArrayGetLBound (safearray, 1, &lbound1);
4997 SafeArrayGetUBound (safearray, 1, &ubound1);
4999 if ((lbound1 != 0) || (ubound1 != 1))
5002 SafeArrayGetLBound (safearray, 2, &lbound2);
5003 SafeArrayGetUBound (safearray, 2, &ubound2);
5005 if ((lbound2 != 0) || (ubound2 != 3)) {
5009 for (i= lbound1; i <= ubound1; i++) {
5011 for (j= lbound2; j <= ubound2; j++) {
5013 if (SafeArrayGetElement (safearray, indices, &element) != S_OK)
5015 failed = ((element.vt != VT_I4) || (element.lVal != 10*(i+1)+(j+1)));
5016 VariantClear (&element);
5022 /* Change the first element of the array to verify that [in] parameters are not marshalled back to the managed side */
5028 SafeArrayPutElement (safearray, indices, &element);
5029 VariantClear (&element);
5034 LIBTEST_API int STDCALL
5035 mono_test_marshal_safearray_in_byval_3dim_vt_bstr (SAFEARRAY* safearray)
5037 /* Check that array is one dimensional containing integers mixed with strings from 0 to 12 */
5040 long lbound1, ubound1, lbound2, ubound2, lbound3, ubound3;
5041 long i, j, k, failed;
5045 VariantInit (&element);
5047 dim = SafeArrayGetDim (safearray);
5051 SafeArrayGetLBound (safearray, 1, &lbound1);
5052 SafeArrayGetUBound (safearray, 1, &ubound1);
5054 if ((lbound1 != 0) || (ubound1 != 1))
5057 SafeArrayGetLBound (safearray, 2, &lbound2);
5058 SafeArrayGetUBound (safearray, 2, &ubound2);
5060 if ((lbound2 != 0) || (ubound2 != 1))
5063 SafeArrayGetLBound (safearray, 3, &lbound3);
5064 SafeArrayGetUBound (safearray, 3, &ubound3);
5066 if ((lbound3 != 0) || (ubound3 != 2))
5069 for (i= lbound1; i <= ubound1; i++) {
5071 for (j= lbound2; j <= ubound2; j++) {
5073 for (k= lbound3; k <= ubound3; k++) {
5075 if (SafeArrayGetElement (safearray, indices, &element) != S_OK)
5077 failed = ((element.vt != VT_BSTR)
5078 || (VariantChangeType (&element, &element, VARIANT_NOUSEROVERRIDE, VT_I4) != S_OK)
5079 || (element.lVal != 100*(i+1)+10*(j+1)+(k+1)));
5080 VariantClear (&element);
5087 /* Change the first element of the array to verify that [in] parameters are not marshalled back to the managed side */
5092 element.vt = VT_BSTR;
5093 element.bstrVal = SysAllocString(L"Should not be copied");
5094 SafeArrayPutElement (safearray, indices, &element);
5095 VariantClear (&element);
5100 LIBTEST_API int STDCALL
5101 mono_test_marshal_safearray_in_byref_3dim_vt_bstr (SAFEARRAY** safearray)
5103 return mono_test_marshal_safearray_in_byval_3dim_vt_bstr (*safearray);
5106 LIBTEST_API int STDCALL
5107 mono_test_marshal_safearray_in_out_byref_1dim_empty (SAFEARRAY** safearray)
5109 /* Check that the input array is what is expected and change it so the caller can check */
5110 /* correct marshalling back to managed code */
5113 long lbound, ubound;
5114 SAFEARRAYBOUND dimensions [1];
5116 wchar_t buffer [20];
5120 /* Check that in array is one dimensional and empty */
5122 dim = SafeArrayGetDim (*safearray);
5127 SafeArrayGetLBound (*safearray, 1, &lbound);
5128 SafeArrayGetUBound (*safearray, 1, &ubound);
5130 if ((lbound > 0) || (ubound > 0)) {
5134 /* Re-dimension the array and return a one-dimensional array of 8 variants filled with "0" to "7" */
5136 dimensions [0].lLbound = 0;
5137 dimensions [0].cElements = 8;
5139 hr = SafeArrayRedim (*safearray, dimensions);
5143 for (i= dimensions [0].lLbound; i< (dimensions [0].lLbound + dimensions [0].cElements); i++) {
5145 VariantInit (&vOut);
5147 _ltow (i,buffer,10);
5148 vOut.bstrVal = SysAllocString (buffer);
5150 if ((hr = SafeArrayPutElement (*safearray, indices, &vOut)) != S_OK) {
5151 VariantClear (&vOut);
5152 SafeArrayDestroy (*safearray);
5155 VariantClear (&vOut);
5160 LIBTEST_API int STDCALL
5161 mono_test_marshal_safearray_in_out_byref_3dim_vt_bstr (SAFEARRAY** safearray)
5163 /* Check that the input array is what is expected and change it so the caller can check */
5164 /* correct marshalling back to managed code */
5167 long lbound1, ubound1, lbound2, ubound2, lbound3, ubound3;
5168 SAFEARRAYBOUND dimensions [1];
5169 long i, j, k, failed;
5170 wchar_t buffer [20];
5175 VariantInit (&element);
5177 /* Check that in array is three dimensional and contains the expected values */
5179 dim = SafeArrayGetDim (*safearray);
5183 SafeArrayGetLBound (*safearray, 1, &lbound1);
5184 SafeArrayGetUBound (*safearray, 1, &ubound1);
5186 if ((lbound1 != 0) || (ubound1 != 1))
5189 SafeArrayGetLBound (*safearray, 2, &lbound2);
5190 SafeArrayGetUBound (*safearray, 2, &ubound2);
5192 if ((lbound2 != 0) || (ubound2 != 1))
5195 SafeArrayGetLBound (*safearray, 3, &lbound3);
5196 SafeArrayGetUBound (*safearray, 3, &ubound3);
5198 if ((lbound3 != 0) || (ubound3 != 2))
5201 for (i= lbound1; i <= ubound1; i++) {
5203 for (j= lbound2; j <= ubound2; j++) {
5205 for (k= lbound3; k <= ubound3; k++) {
5207 if (SafeArrayGetElement (*safearray, indices, &element) != S_OK)
5209 failed = ((element.vt != VT_BSTR)
5210 || (VariantChangeType (&element, &element, VARIANT_NOUSEROVERRIDE, VT_I4) != S_OK)
5211 || (element.lVal != 100*(i+1)+10*(j+1)+(k+1)));
5212 VariantClear (&element);
5219 hr = SafeArrayDestroy (*safearray);
5223 /* Return a new one-dimensional array of 8 variants filled with "0" to "7" */
5225 dimensions [0].lLbound = 0;
5226 dimensions [0].cElements = 8;
5228 *safearray = SafeArrayCreate (VT_VARIANT, 1, dimensions);
5230 for (i= dimensions [0].lLbound; i< (dimensions [0].lLbound + dimensions [0].cElements); i++) {
5232 VariantInit (&vOut);
5234 _ltow (i,buffer,10);
5235 vOut.bstrVal = SysAllocString (buffer);
5237 if ((hr = SafeArrayPutElement (*safearray, indices, &vOut)) != S_OK) {
5238 VariantClear (&vOut);
5239 SafeArrayDestroy (*safearray);
5242 VariantClear (&vOut);
5247 LIBTEST_API int STDCALL
5248 mono_test_marshal_safearray_in_out_byref_1dim_vt_i4 (SAFEARRAY** safearray)
5250 /* Check that the input array is what is expected and change it so the caller can check */
5251 /* correct marshalling back to managed code */
5254 long lbound1, ubound1;
5260 VariantInit (&element);
5262 /* Check that in array is one dimensional and contains the expected value */
5264 dim = SafeArrayGetDim (*safearray);
5268 SafeArrayGetLBound (*safearray, 1, &lbound1);
5269 SafeArrayGetUBound (*safearray, 1, &ubound1);
5272 if ((lbound1 != 0) || (ubound1 != 1))
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 one of the elements of the array to verify that [out] parameter is marshalled back to the managed side */
5291 SafeArrayPutElement (*safearray, indices, &element);
5292 VariantClear (&element);
5297 LIBTEST_API int STDCALL
5298 mono_test_marshal_safearray_in_out_byval_1dim_vt_i4 (SAFEARRAY* safearray)
5300 /* Check that the input array is what is expected and change it so the caller can check */
5301 /* correct marshalling back to managed code */
5304 long lbound1, ubound1;
5305 SAFEARRAYBOUND dimensions [1];
5311 VariantInit (&element);
5313 /* Check that in array is one dimensional and contains the expected value */
5315 dim = SafeArrayGetDim (safearray);
5319 SafeArrayGetLBound (safearray, 1, &lbound1);
5320 SafeArrayGetUBound (safearray, 1, &ubound1);
5322 if ((lbound1 != 0) || (ubound1 != 0))
5325 for (i= lbound1; i <= ubound1; i++) {
5327 if (SafeArrayGetElement (safearray, indices, &element) != S_OK)
5329 failed = (element.vt != VT_I4) || (element.lVal != i+1);
5330 VariantClear (&element);
5335 /* Change the array to verify how [out] parameter is marshalled back to the managed side */
5337 /* Redimension the array */
5338 dimensions [0].lLbound = lbound1;
5339 dimensions [0].cElements = 2;
5340 hr = SafeArrayRedim(safearray, dimensions);
5344 element.lVal = 12345;
5345 SafeArrayPutElement (safearray, indices, &element);
5346 VariantClear (&element);
5350 element.lVal = -12345;
5351 SafeArrayPutElement (safearray, indices, &element);
5352 VariantClear (&element);
5357 LIBTEST_API int STDCALL
5358 mono_test_marshal_safearray_in_out_byval_3dim_vt_bstr (SAFEARRAY* safearray)
5360 /* Check that the input array is what is expected and change it so the caller can check */
5361 /* correct marshalling back to managed code */
5364 long lbound1, ubound1, lbound2, ubound2, lbound3, ubound3;
5365 long i, j, k, failed;
5370 VariantInit (&element);
5372 /* Check that in array is three dimensional and contains the expected values */
5374 dim = SafeArrayGetDim (safearray);
5378 SafeArrayGetLBound (safearray, 1, &lbound1);
5379 SafeArrayGetUBound (safearray, 1, &ubound1);
5381 if ((lbound1 != 0) || (ubound1 != 1))
5384 SafeArrayGetLBound (safearray, 2, &lbound2);
5385 SafeArrayGetUBound (safearray, 2, &ubound2);
5387 if ((lbound2 != 0) || (ubound2 != 1))
5390 SafeArrayGetLBound (safearray, 3, &lbound3);
5391 SafeArrayGetUBound (safearray, 3, &ubound3);
5393 if ((lbound3 != 0) || (ubound3 != 2))
5396 for (i= lbound1; i <= ubound1; i++) {
5398 for (j= lbound2; j <= ubound2; j++) {
5400 for (k= lbound3; k <= ubound3; k++) {
5402 if (SafeArrayGetElement (safearray, indices, &element) != S_OK)
5404 failed = ((element.vt != VT_BSTR)
5405 || (VariantChangeType (&element, &element, VARIANT_NOUSEROVERRIDE, VT_I4) != S_OK)
5406 || (element.lVal != 100*(i+1)+10*(j+1)+(k+1)));
5407 VariantClear (&element);
5414 /* Change the elements of the array to verify that [out] parameter is marshalled back to the managed side */
5421 SafeArrayPutElement (safearray, indices, &element);
5422 VariantClear (&element);
5429 SafeArrayPutElement (safearray, indices, &element);
5430 VariantClear (&element);
5435 element.vt = VT_BSTR;
5436 element.bstrVal = marshal_bstr_alloc("ABCDEFG");
5437 SafeArrayPutElement (safearray, indices, &element);
5438 VariantClear (&element);
5443 LIBTEST_API int STDCALL
5444 mono_test_marshal_safearray_mixed(
5445 SAFEARRAY *safearray1,
5446 SAFEARRAY **safearray2,
5447 SAFEARRAY *safearray3,
5448 SAFEARRAY **safearray4
5453 /* Initialize out parameters */
5456 /* array1: Check that in array is one dimensional and contains the expected value */
5457 hr = mono_test_marshal_safearray_in_out_byval_1dim_vt_i4 (safearray1);
5459 /* array2: Fill in with some values to check on the managed side */
5461 hr = mono_test_marshal_safearray_out_1dim_vt_bstr (safearray2);
5463 /* array3: Check that in array is one dimensional and contains the expected value */
5465 hr = mono_test_marshal_safearray_in_byval_1dim_vt_mixed(safearray3);
5467 /* array4: Check input values and fill in with some values to check on the managed side */
5469 hr = mono_test_marshal_safearray_in_out_byref_3dim_vt_bstr(safearray4);
5476 static int call_managed_res;
5479 call_managed (gpointer arg)
5481 SimpleDelegate del = (SimpleDelegate)arg;
5483 call_managed_res = del (42);
5486 LIBTEST_API int STDCALL
5487 mono_test_marshal_thread_attach (SimpleDelegate del)
5495 res = pthread_create (&t, NULL, (gpointer (*)(gpointer))call_managed, del);
5496 g_assert (res == 0);
5497 pthread_join (t, NULL);
5499 return call_managed_res;
5503 typedef int (STDCALL *Callback) (void);
5505 static Callback callback;
5507 LIBTEST_API void STDCALL
5508 mono_test_marshal_set_callback (Callback cb)
5513 LIBTEST_API int STDCALL
5514 mono_test_marshal_call_callback (void)
5519 LIBTEST_API int STDCALL
5520 mono_test_marshal_lpstr (char *str)
5522 return strcmp ("ABC", str);
5525 LIBTEST_API int STDCALL
5526 mono_test_marshal_lpwstr (gunichar2 *str)
5531 s = g_utf16_to_utf8 (str, -1, NULL, NULL, NULL);
5532 res = strcmp ("ABC", s);
5538 LIBTEST_API char* STDCALL
5539 mono_test_marshal_return_lpstr (void)
5541 char *res = (char *)marshal_alloc (4);
5542 strcpy (res, "XYZ");
5547 LIBTEST_API gunichar2* STDCALL
5548 mono_test_marshal_return_lpwstr (void)
5550 gunichar2 *res = (gunichar2 *)marshal_alloc (8);
5551 gunichar2* tmp = g_utf8_to_utf16 ("XYZ", -1, NULL, NULL, NULL);
5553 memcpy (res, tmp, 8);
5561 } SingleDoubleStruct;
5563 LIBTEST_API SingleDoubleStruct STDCALL
5564 mono_test_marshal_return_single_double_struct (void)
5566 SingleDoubleStruct res;
5576 LIBTEST_API int STDCALL
5577 mono_test_has_thiscall (void)
5583 _mono_test_native_thiscall1 (int arg)
5589 _mono_test_native_thiscall2 (int arg, int arg2)
5591 return arg + (arg2^1);
5595 _mono_test_native_thiscall3 (int arg, int arg2, int arg3)
5597 return arg + (arg2^1) + (arg3^2);
5600 #elif defined(__GNUC__)
5602 LIBTEST_API int STDCALL
5603 mono_test_has_thiscall (void)
5608 #define def_asm_fn(name) \
5610 "\t.globl _" #name "\n" \
5612 "\t.globl __" #name "\n" \
5617 def_asm_fn(mono_test_native_thiscall1)
5618 "\tmovl %ecx,%eax\n"
5621 def_asm_fn(mono_test_native_thiscall2)
5622 "\tmovl %ecx,%eax\n"
5623 "\tmovl 4(%esp),%ecx\n"
5625 "\taddl %ecx,%eax\n"
5628 def_asm_fn(mono_test_native_thiscall3)
5629 "\tmovl %ecx,%eax\n"
5630 "\tmovl 4(%esp),%ecx\n"
5632 "\taddl %ecx,%eax\n"
5633 "\tmovl 8(%esp),%ecx\n"
5635 "\taddl %ecx,%eax\n"
5642 LIBTEST_API int STDCALL
5643 mono_test_has_thiscall (void)
5655 LIBTEST_API sbyte1 STDCALL
5656 mono_return_sbyte1 (sbyte1 s1, int addend) {
5658 fprintf(stderr, "mono_return_sbyte1 s1.f1: got %d but expected %d\n", s1.f1, 1);
5668 LIBTEST_API sbyte2 STDCALL
5669 mono_return_sbyte2 (sbyte2 s2, int addend) {
5671 fprintf(stderr, "mono_return_sbyte2 s2.f1: got %d but expected %d\n", s2.f1, 1);
5674 fprintf(stderr, "mono_return_sbyte2 s2.f2: got %d but expected %d\n", s2.f2, 2);
5676 s2.f1+=addend; s2.f2+=addend;
5684 LIBTEST_API sbyte3 STDCALL
5685 mono_return_sbyte3 (sbyte3 s3, int addend) {
5687 fprintf(stderr, "mono_return_sbyte3 s3.f1: got %d but expected %d\n", s3.f1, 1);
5690 fprintf(stderr, "mono_return_sbyte3 s3.f2: got %d but expected %d\n", s3.f2, 2);
5693 fprintf(stderr, "mono_return_sbyte3 s3.f3: got %d but expected %d\n", s3.f3, 3);
5695 s3.f1+=addend; s3.f2+=addend; s3.f3+=addend;
5703 LIBTEST_API sbyte4 STDCALL
5704 mono_return_sbyte4 (sbyte4 s4, int addend) {
5706 fprintf(stderr, "mono_return_sbyte4 s4.f1: got %d but expected %d\n", s4.f1, 1);
5709 fprintf(stderr, "mono_return_sbyte4 s4.f2: got %d but expected %d\n", s4.f2, 2);
5712 fprintf(stderr, "mono_return_sbyte4 s4.f3: got %d but expected %d\n", s4.f3, 3);
5715 fprintf(stderr, "mono_return_sbyte4 s4.f4: got %d but expected %d\n", s4.f4, 4);
5717 s4.f1+=addend; s4.f2+=addend; s4.f3+=addend; s4.f4+=addend;
5722 char f1,f2,f3,f4,f5;
5725 LIBTEST_API sbyte5 STDCALL
5726 mono_return_sbyte5 (sbyte5 s5, int addend) {
5728 fprintf(stderr, "mono_return_sbyte5 s5.f1: got %d but expected %d\n", s5.f1, 1);
5731 fprintf(stderr, "mono_return_sbyte5 s5.f2: got %d but expected %d\n", s5.f2, 2);
5734 fprintf(stderr, "mono_return_sbyte5 s5.f3: got %d but expected %d\n", s5.f3, 3);
5737 fprintf(stderr, "mono_return_sbyte5 s5.f4: got %d but expected %d\n", s5.f4, 4);
5740 fprintf(stderr, "mono_return_sbyte5 s5.f5: got %d but expected %d\n", s5.f5, 5);
5742 s5.f1+=addend; s5.f2+=addend; s5.f3+=addend; s5.f4+=addend; s5.f5+=addend;
5747 char f1,f2,f3,f4,f5,f6;
5750 LIBTEST_API sbyte6 STDCALL
5751 mono_return_sbyte6 (sbyte6 s6, int addend) {
5753 fprintf(stderr, "mono_return_sbyte6 s6.f1: got %d but expected %d\n", s6.f1, 1);
5756 fprintf(stderr, "mono_return_sbyte6 s6.f2: got %d but expected %d\n", s6.f2, 2);
5759 fprintf(stderr, "mono_return_sbyte6 s6.f3: got %d but expected %d\n", s6.f3, 3);
5762 fprintf(stderr, "mono_return_sbyte6 s6.f4: got %d but expected %d\n", s6.f4, 4);
5765 fprintf(stderr, "mono_return_sbyte6 s6.f5: got %d but expected %d\n", s6.f5, 5);
5768 fprintf(stderr, "mono_return_sbyte6 s6.f6: got %d but expected %d\n", s6.f6, 6);
5770 s6.f1+=addend; s6.f2+=addend; s6.f3+=addend; s6.f4+=addend; s6.f5+=addend; s6.f6+=addend;
5775 char f1,f2,f3,f4,f5,f6,f7;
5778 LIBTEST_API sbyte7 STDCALL
5779 mono_return_sbyte7 (sbyte7 s7, int addend) {
5781 fprintf(stderr, "mono_return_sbyte7 s7.f1: got %d but expected %d\n", s7.f1, 1);
5784 fprintf(stderr, "mono_return_sbyte7 s7.f2: got %d but expected %d\n", s7.f2, 2);
5787 fprintf(stderr, "mono_return_sbyte7 s7.f3: got %d but expected %d\n", s7.f3, 3);
5790 fprintf(stderr, "mono_return_sbyte7 s7.f4: got %d but expected %d\n", s7.f4, 4);
5793 fprintf(stderr, "mono_return_sbyte7 s7.f5: got %d but expected %d\n", s7.f5, 5);
5796 fprintf(stderr, "mono_return_sbyte7 s7.f6: got %d but expected %d\n", s7.f6, 6);
5799 fprintf(stderr, "mono_return_sbyte7 s7.f7: got %d but expected %d\n", s7.f7, 7);
5801 s7.f1+=addend; s7.f2+=addend; s7.f3+=addend; s7.f4+=addend; s7.f5+=addend; s7.f6+=addend; s7.f7+=addend;
5806 char f1,f2,f3,f4,f5,f6,f7,f8;
5809 LIBTEST_API sbyte8 STDCALL
5810 mono_return_sbyte8 (sbyte8 s8, int addend) {
5812 fprintf(stderr, "mono_return_sbyte8 s8.f1: got %d but expected %d\n", s8.f1, 1);
5815 fprintf(stderr, "mono_return_sbyte8 s8.f2: got %d but expected %d\n", s8.f2, 2);
5818 fprintf(stderr, "mono_return_sbyte8 s8.f3: got %d but expected %d\n", s8.f3, 3);
5821 fprintf(stderr, "mono_return_sbyte8 s8.f4: got %d but expected %d\n", s8.f4, 4);
5824 fprintf(stderr, "mono_return_sbyte8 s8.f5: got %d but expected %d\n", s8.f5, 5);
5827 fprintf(stderr, "mono_return_sbyte8 s8.f6: got %d but expected %d\n", s8.f6, 6);
5830 fprintf(stderr, "mono_return_sbyte8 s8.f7: got %d but expected %d\n", s8.f7, 7);
5833 fprintf(stderr, "mono_return_sbyte8 s8.f8: got %d but expected %d\n", s8.f8, 8);
5835 s8.f1+=addend; s8.f2+=addend; s8.f3+=addend; s8.f4+=addend; s8.f5+=addend; s8.f6+=addend; s8.f7+=addend; s8.f8+=addend;
5840 char f1,f2,f3,f4,f5,f6,f7,f8,f9;
5843 LIBTEST_API sbyte9 STDCALL
5844 mono_return_sbyte9 (sbyte9 s9, int addend) {
5846 fprintf(stderr, "mono_return_sbyte9 s9.f1: got %d but expected %d\n", s9.f1, 1);
5849 fprintf(stderr, "mono_return_sbyte9 s9.f2: got %d but expected %d\n", s9.f2, 2);
5852 fprintf(stderr, "mono_return_sbyte9 s9.f3: got %d but expected %d\n", s9.f3, 3);
5855 fprintf(stderr, "mono_return_sbyte9 s9.f4: got %d but expected %d\n", s9.f4, 4);
5858 fprintf(stderr, "mono_return_sbyte9 s9.f5: got %d but expected %d\n", s9.f5, 5);
5861 fprintf(stderr, "mono_return_sbyte9 s9.f6: got %d but expected %d\n", s9.f6, 6);
5864 fprintf(stderr, "mono_return_sbyte9 s9.f7: got %d but expected %d\n", s9.f7, 7);
5867 fprintf(stderr, "mono_return_sbyte9 s9.f8: got %d but expected %d\n", s9.f8, 8);
5870 fprintf(stderr, "mono_return_sbyte9 s9.f9: got %d but expected %d\n", s9.f9, 9);
5872 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;
5877 char f1,f2,f3,f4,f5,f6,f7,f8,f9,f10;
5880 LIBTEST_API sbyte10 STDCALL
5881 mono_return_sbyte10 (sbyte10 s10, int addend) {
5883 fprintf(stderr, "mono_return_sbyte10 s10.f1: got %d but expected %d\n", s10.f1, 1);
5886 fprintf(stderr, "mono_return_sbyte10 s10.f2: got %d but expected %d\n", s10.f2, 2);
5889 fprintf(stderr, "mono_return_sbyte10 s10.f3: got %d but expected %d\n", s10.f3, 3);
5892 fprintf(stderr, "mono_return_sbyte10 s10.f4: got %d but expected %d\n", s10.f4, 4);
5895 fprintf(stderr, "mono_return_sbyte10 s10.f5: got %d but expected %d\n", s10.f5, 5);
5898 fprintf(stderr, "mono_return_sbyte10 s10.f6: got %d but expected %d\n", s10.f6, 6);
5901 fprintf(stderr, "mono_return_sbyte10 s10.f7: got %d but expected %d\n", s10.f7, 7);
5904 fprintf(stderr, "mono_return_sbyte10 s10.f8: got %d but expected %d\n", s10.f8, 8);
5907 fprintf(stderr, "mono_return_sbyte10 s10.f9: got %d but expected %d\n", s10.f9, 9);
5909 if (s10.f10 != 10) {
5910 fprintf(stderr, "mono_return_sbyte10 s10.f10: got %d but expected %d\n", s10.f10, 10);
5912 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;
5917 char f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11;
5920 LIBTEST_API sbyte11 STDCALL
5921 mono_return_sbyte11 (sbyte11 s11, int addend) {
5923 fprintf(stderr, "mono_return_sbyte11 s11.f1: got %d but expected %d\n", s11.f1, 1);
5926 fprintf(stderr, "mono_return_sbyte11 s11.f2: got %d but expected %d\n", s11.f2, 2);
5929 fprintf(stderr, "mono_return_sbyte11 s11.f3: got %d but expected %d\n", s11.f3, 3);
5932 fprintf(stderr, "mono_return_sbyte11 s11.f4: got %d but expected %d\n", s11.f4, 4);
5935 fprintf(stderr, "mono_return_sbyte11 s11.f5: got %d but expected %d\n", s11.f5, 5);
5938 fprintf(stderr, "mono_return_sbyte11 s11.f6: got %d but expected %d\n", s11.f6, 6);
5941 fprintf(stderr, "mono_return_sbyte11 s11.f7: got %d but expected %d\n", s11.f7, 7);
5944 fprintf(stderr, "mono_return_sbyte11 s11.f8: got %d but expected %d\n", s11.f8, 8);
5947 fprintf(stderr, "mono_return_sbyte11 s11.f9: got %d but expected %d\n", s11.f9, 9);
5949 if (s11.f10 != 10) {
5950 fprintf(stderr, "mono_return_sbyte11 s11.f10: got %d but expected %d\n", s11.f10, 10);
5952 if (s11.f11 != 11) {
5953 fprintf(stderr, "mono_return_sbyte11 s11.f11: got %d but expected %d\n", s11.f11, 11);
5955 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;
5960 char f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12;
5963 LIBTEST_API sbyte12 STDCALL
5964 mono_return_sbyte12 (sbyte12 s12, int addend) {
5966 fprintf(stderr, "mono_return_sbyte12 s12.f1: got %d but expected %d\n", s12.f1, 1);
5969 fprintf(stderr, "mono_return_sbyte12 s12.f2: got %d but expected %d\n", s12.f2, 2);
5972 fprintf(stderr, "mono_return_sbyte12 s12.f3: got %d but expected %d\n", s12.f3, 3);
5975 fprintf(stderr, "mono_return_sbyte12 s12.f4: got %d but expected %d\n", s12.f4, 4);
5978 fprintf(stderr, "mono_return_sbyte12 s12.f5: got %d but expected %d\n", s12.f5, 5);
5981 fprintf(stderr, "mono_return_sbyte12 s12.f6: got %d but expected %d\n", s12.f6, 6);
5984 fprintf(stderr, "mono_return_sbyte12 s12.f7: got %d but expected %d\n", s12.f7, 7);
5987 fprintf(stderr, "mono_return_sbyte12 s12.f8: got %d but expected %d\n", s12.f8, 8);
5990 fprintf(stderr, "mono_return_sbyte12 s12.f9: got %d but expected %d\n", s12.f9, 9);
5992 if (s12.f10 != 10) {
5993 fprintf(stderr, "mono_return_sbyte12 s12.f10: got %d but expected %d\n", s12.f10, 10);
5995 if (s12.f11 != 11) {
5996 fprintf(stderr, "mono_return_sbyte12 s12.f11: got %d but expected %d\n", s12.f11, 11);
5998 if (s12.f12 != 12) {
5999 fprintf(stderr, "mono_return_sbyte12 s12.f12: got %d but expected %d\n", s12.f12, 12);
6001 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;
6006 char f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13;
6009 LIBTEST_API sbyte13 STDCALL
6010 mono_return_sbyte13 (sbyte13 s13, int addend) {
6012 fprintf(stderr, "mono_return_sbyte13 s13.f1: got %d but expected %d\n", s13.f1, 1);
6015 fprintf(stderr, "mono_return_sbyte13 s13.f2: got %d but expected %d\n", s13.f2, 2);
6018 fprintf(stderr, "mono_return_sbyte13 s13.f3: got %d but expected %d\n", s13.f3, 3);
6021 fprintf(stderr, "mono_return_sbyte13 s13.f4: got %d but expected %d\n", s13.f4, 4);
6024 fprintf(stderr, "mono_return_sbyte13 s13.f5: got %d but expected %d\n", s13.f5, 5);
6027 fprintf(stderr, "mono_return_sbyte13 s13.f6: got %d but expected %d\n", s13.f6, 6);
6030 fprintf(stderr, "mono_return_sbyte13 s13.f7: got %d but expected %d\n", s13.f7, 7);
6033 fprintf(stderr, "mono_return_sbyte13 s13.f8: got %d but expected %d\n", s13.f8, 8);
6036 fprintf(stderr, "mono_return_sbyte13 s13.f9: got %d but expected %d\n", s13.f9, 9);
6038 if (s13.f10 != 10) {
6039 fprintf(stderr, "mono_return_sbyte13 s13.f10: got %d but expected %d\n", s13.f10, 10);
6041 if (s13.f11 != 11) {
6042 fprintf(stderr, "mono_return_sbyte13 s13.f11: got %d but expected %d\n", s13.f11, 11);
6044 if (s13.f12 != 12) {
6045 fprintf(stderr, "mono_return_sbyte13 s13.f12: got %d but expected %d\n", s13.f12, 12);
6047 if (s13.f13 != 13) {
6048 fprintf(stderr, "mono_return_sbyte13 s13.f13: got %d but expected %d\n", s13.f13, 13);
6050 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;
6055 char f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14;
6058 LIBTEST_API sbyte14 STDCALL
6059 mono_return_sbyte14 (sbyte14 s14, int addend) {
6061 fprintf(stderr, "mono_return_sbyte14 s14.f1: got %d but expected %d\n", s14.f1, 1);
6064 fprintf(stderr, "mono_return_sbyte14 s14.f2: got %d but expected %d\n", s14.f2, 2);
6067 fprintf(stderr, "mono_return_sbyte14 s14.f3: got %d but expected %d\n", s14.f3, 3);
6070 fprintf(stderr, "mono_return_sbyte14 s14.f4: got %d but expected %d\n", s14.f4, 4);
6073 fprintf(stderr, "mono_return_sbyte14 s14.f5: got %d but expected %d\n", s14.f5, 5);
6076 fprintf(stderr, "mono_return_sbyte14 s14.f6: got %d but expected %d\n", s14.f6, 6);
6079 fprintf(stderr, "mono_return_sbyte14 s14.f7: got %d but expected %d\n", s14.f7, 7);
6082 fprintf(stderr, "mono_return_sbyte14 s14.f8: got %d but expected %d\n", s14.f8, 8);
6085 fprintf(stderr, "mono_return_sbyte14 s14.f9: got %d but expected %d\n", s14.f9, 9);
6087 if (s14.f10 != 10) {
6088 fprintf(stderr, "mono_return_sbyte14 s14.f10: got %d but expected %d\n", s14.f10, 10);
6090 if (s14.f11 != 11) {
6091 fprintf(stderr, "mono_return_sbyte14 s14.f11: got %d but expected %d\n", s14.f11, 11);
6093 if (s14.f12 != 12) {
6094 fprintf(stderr, "mono_return_sbyte14 s14.f12: got %d but expected %d\n", s14.f12, 12);
6096 if (s14.f13 != 13) {
6097 fprintf(stderr, "mono_return_sbyte14 s14.f13: got %d but expected %d\n", s14.f13, 13);
6099 if (s14.f14 != 14) {
6100 fprintf(stderr, "mono_return_sbyte14 s14.f14: got %d but expected %d\n", s14.f14, 14);
6102 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;
6107 char f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15;
6110 LIBTEST_API sbyte15 STDCALL
6111 mono_return_sbyte15 (sbyte15 s15, int addend) {
6113 fprintf(stderr, "mono_return_sbyte15 s15.f1: got %d but expected %d\n", s15.f1, 1);
6116 fprintf(stderr, "mono_return_sbyte15 s15.f2: got %d but expected %d\n", s15.f2, 2);
6119 fprintf(stderr, "mono_return_sbyte15 s15.f3: got %d but expected %d\n", s15.f3, 3);
6122 fprintf(stderr, "mono_return_sbyte15 s15.f4: got %d but expected %d\n", s15.f4, 4);
6125 fprintf(stderr, "mono_return_sbyte15 s15.f5: got %d but expected %d\n", s15.f5, 5);
6128 fprintf(stderr, "mono_return_sbyte15 s15.f6: got %d but expected %d\n", s15.f6, 6);
6131 fprintf(stderr, "mono_return_sbyte15 s15.f7: got %d but expected %d\n", s15.f7, 7);
6134 fprintf(stderr, "mono_return_sbyte15 s15.f8: got %d but expected %d\n", s15.f8, 8);
6137 fprintf(stderr, "mono_return_sbyte15 s15.f9: got %d but expected %d\n", s15.f9, 9);
6139 if (s15.f10 != 10) {
6140 fprintf(stderr, "mono_return_sbyte15 s15.f10: got %d but expected %d\n", s15.f10, 10);
6142 if (s15.f11 != 11) {
6143 fprintf(stderr, "mono_return_sbyte15 s15.f11: got %d but expected %d\n", s15.f11, 11);
6145 if (s15.f12 != 12) {
6146 fprintf(stderr, "mono_return_sbyte15 s15.f12: got %d but expected %d\n", s15.f12, 12);
6148 if (s15.f13 != 13) {
6149 fprintf(stderr, "mono_return_sbyte15 s15.f13: got %d but expected %d\n", s15.f13, 13);
6151 if (s15.f14 != 14) {
6152 fprintf(stderr, "mono_return_sbyte15 s15.f14: got %d but expected %d\n", s15.f14, 14);
6154 if (s15.f15 != 15) {
6155 fprintf(stderr, "mono_return_sbyte15 s15.f15: got %d but expected %d\n", s15.f15, 15);
6157 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;
6162 char f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15,f16;
6165 LIBTEST_API sbyte16 STDCALL
6166 mono_return_sbyte16 (sbyte16 s16, int addend) {
6168 fprintf(stderr, "mono_return_sbyte16 s16.f1: got %d but expected %d\n", s16.f1, 1);
6171 fprintf(stderr, "mono_return_sbyte16 s16.f2: got %d but expected %d\n", s16.f2, 2);
6174 fprintf(stderr, "mono_return_sbyte16 s16.f3: got %d but expected %d\n", s16.f3, 3);
6177 fprintf(stderr, "mono_return_sbyte16 s16.f4: got %d but expected %d\n", s16.f4, 4);
6180 fprintf(stderr, "mono_return_sbyte16 s16.f5: got %d but expected %d\n", s16.f5, 5);
6183 fprintf(stderr, "mono_return_sbyte16 s16.f6: got %d but expected %d\n", s16.f6, 6);
6186 fprintf(stderr, "mono_return_sbyte16 s16.f7: got %d but expected %d\n", s16.f7, 7);
6189 fprintf(stderr, "mono_return_sbyte16 s16.f8: got %d but expected %d\n", s16.f8, 8);
6192 fprintf(stderr, "mono_return_sbyte16 s16.f9: got %d but expected %d\n", s16.f9, 9);
6194 if (s16.f10 != 10) {
6195 fprintf(stderr, "mono_return_sbyte16 s16.f10: got %d but expected %d\n", s16.f10, 10);
6197 if (s16.f11 != 11) {
6198 fprintf(stderr, "mono_return_sbyte16 s16.f11: got %d but expected %d\n", s16.f11, 11);
6200 if (s16.f12 != 12) {
6201 fprintf(stderr, "mono_return_sbyte16 s16.f12: got %d but expected %d\n", s16.f12, 12);
6203 if (s16.f13 != 13) {
6204 fprintf(stderr, "mono_return_sbyte16 s16.f13: got %d but expected %d\n", s16.f13, 13);
6206 if (s16.f14 != 14) {
6207 fprintf(stderr, "mono_return_sbyte16 s16.f14: got %d but expected %d\n", s16.f14, 14);
6209 if (s16.f15 != 15) {
6210 fprintf(stderr, "mono_return_sbyte16 s16.f15: got %d but expected %d\n", s16.f15, 15);
6212 if (s16.f16 != 16) {
6213 fprintf(stderr, "mono_return_sbyte16 s16.f16: got %d but expected %d\n", s16.f16, 16);
6215 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;
6220 char f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15,f16,f17;
6223 LIBTEST_API sbyte17 STDCALL
6224 mono_return_sbyte17 (sbyte17 s17, int addend) {
6226 fprintf(stderr, "mono_return_sbyte17 s17.f1: got %d but expected %d\n", s17.f1, 1);
6229 fprintf(stderr, "mono_return_sbyte17 s17.f2: got %d but expected %d\n", s17.f2, 2);
6232 fprintf(stderr, "mono_return_sbyte17 s17.f3: got %d but expected %d\n", s17.f3, 3);
6235 fprintf(stderr, "mono_return_sbyte17 s17.f4: got %d but expected %d\n", s17.f4, 4);
6238 fprintf(stderr, "mono_return_sbyte17 s17.f5: got %d but expected %d\n", s17.f5, 5);
6241 fprintf(stderr, "mono_return_sbyte17 s17.f6: got %d but expected %d\n", s17.f6, 6);
6244 fprintf(stderr, "mono_return_sbyte17 s17.f7: got %d but expected %d\n", s17.f7, 7);
6247 fprintf(stderr, "mono_return_sbyte17 s17.f8: got %d but expected %d\n", s17.f8, 8);
6250 fprintf(stderr, "mono_return_sbyte17 s17.f9: got %d but expected %d\n", s17.f9, 9);
6252 if (s17.f10 != 10) {
6253 fprintf(stderr, "mono_return_sbyte17 s17.f10: got %d but expected %d\n", s17.f10, 10);
6255 if (s17.f11 != 11) {
6256 fprintf(stderr, "mono_return_sbyte17 s17.f11: got %d but expected %d\n", s17.f11, 11);
6258 if (s17.f12 != 12) {
6259 fprintf(stderr, "mono_return_sbyte17 s17.f12: got %d but expected %d\n", s17.f12, 12);
6261 if (s17.f13 != 13) {
6262 fprintf(stderr, "mono_return_sbyte17 s17.f13: got %d but expected %d\n", s17.f13, 13);
6264 if (s17.f14 != 14) {
6265 fprintf(stderr, "mono_return_sbyte17 s17.f14: got %d but expected %d\n", s17.f14, 14);
6267 if (s17.f15 != 15) {
6268 fprintf(stderr, "mono_return_sbyte17 s17.f15: got %d but expected %d\n", s17.f15, 15);
6270 if (s17.f16 != 16) {
6271 fprintf(stderr, "mono_return_sbyte17 s17.f16: got %d but expected %d\n", s17.f16, 16);
6273 if (s17.f17 != 17) {
6274 fprintf(stderr, "mono_return_sbyte17 s17.f17: got %d but expected %d\n", s17.f17, 17);
6276 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;
6284 char f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15;
6290 LIBTEST_API sbyte16_nested STDCALL
6291 mono_return_sbyte16_nested (sbyte16_nested sn16, int addend) {
6292 if (sn16.nested1.f1 != 1) {
6293 fprintf(stderr, "mono_return_sbyte16_nested sn16.nested1.f1: got %d but expected %d\n", sn16.nested1.f1, 1);
6296 fprintf(stderr, "mono_return_sbyte16_nested sn16.f2: got %d but expected %d\n", sn16.f2, 2);
6299 fprintf(stderr, "mono_return_sbyte16_nested sn16.f3: got %d but expected %d\n", sn16.f3, 3);
6302 fprintf(stderr, "mono_return_sbyte16_nested sn16.f4: got %d but expected %d\n", sn16.f4, 4);
6305 fprintf(stderr, "mono_return_sbyte16_nested sn16.f5: got %d but expected %d\n", sn16.f5, 5);
6308 fprintf(stderr, "mono_return_sbyte16_nested sn16.f6: got %d but expected %d\n", sn16.f6, 6);
6311 fprintf(stderr, "mono_return_sbyte16_nested sn16.f7: got %d but expected %d\n", sn16.f7, 7);
6314 fprintf(stderr, "mono_return_sbyte16_nested sn16.f8: got %d but expected %d\n", sn16.f8, 8);
6317 fprintf(stderr, "mono_return_sbyte16_nested sn16.f9: got %d but expected %d\n", sn16.f9, 9);
6319 if (sn16.f10 != 10) {
6320 fprintf(stderr, "mono_return_sbyte16_nested sn16.f10: got %d but expected %d\n", sn16.f10, 10);
6322 if (sn16.f11 != 11) {
6323 fprintf(stderr, "mono_return_sbyte16_nested sn16.f11: got %d but expected %d\n", sn16.f11, 11);
6325 if (sn16.f12 != 12) {
6326 fprintf(stderr, "mono_return_sbyte16_nested sn16.f12: got %d but expected %d\n", sn16.f12, 12);
6328 if (sn16.f13 != 13) {
6329 fprintf(stderr, "mono_return_sbyte16_nested sn16.f13: got %d but expected %d\n", sn16.f13, 13);
6331 if (sn16.f14 != 14) {
6332 fprintf(stderr, "mono_return_sbyte16_nested sn16.f14: got %d but expected %d\n", sn16.f14, 14);
6334 if (sn16.f15 != 15) {
6335 fprintf(stderr, "mono_return_sbyte16_nested sn16.f15: got %d but expected %d\n", sn16.f15, 15);
6337 if (sn16.nested2.f16 != 16) {
6338 fprintf(stderr, "mono_return_sbyte16_nested sn16.nested2.f16: got %d but expected %d\n", sn16.nested2.f16, 16);
6340 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;
6349 LIBTEST_API short1 STDCALL
6350 mono_return_short1 (short1 s1, int addend) {
6352 fprintf(stderr, "mono_return_short1 s1.f1: got %d but expected %d\n", s1.f1, 1);
6362 LIBTEST_API short2 STDCALL
6363 mono_return_short2 (short2 s2, int addend) {
6365 fprintf(stderr, "mono_return_short2 s2.f1: got %d but expected %d\n", s2.f1, 1);
6368 fprintf(stderr, "mono_return_short2 s2.f2: got %d but expected %d\n", s2.f2, 2);
6370 s2.f1+=addend; s2.f2+=addend;
6378 LIBTEST_API short3 STDCALL
6379 mono_return_short3 (short3 s3, int addend) {
6381 fprintf(stderr, "mono_return_short3 s3.f1: got %d but expected %d\n", s3.f1, 1);
6384 fprintf(stderr, "mono_return_short3 s3.f2: got %d but expected %d\n", s3.f2, 2);
6387 fprintf(stderr, "mono_return_short3 s3.f3: got %d but expected %d\n", s3.f3, 3);
6389 s3.f1+=addend; s3.f2+=addend; s3.f3+=addend;
6397 LIBTEST_API short4 STDCALL
6398 mono_return_short4 (short4 s4, int addend) {
6400 fprintf(stderr, "mono_return_short4 s4.f1: got %d but expected %d\n", s4.f1, 1);
6403 fprintf(stderr, "mono_return_short4 s4.f2: got %d but expected %d\n", s4.f2, 2);
6406 fprintf(stderr, "mono_return_short4 s4.f3: got %d but expected %d\n", s4.f3, 3);
6409 fprintf(stderr, "mono_return_short4 s4.f4: got %d but expected %d\n", s4.f4, 4);
6411 s4.f1+=addend; s4.f2+=addend; s4.f3+=addend; s4.f4+=addend;
6416 short f1,f2,f3,f4,f5;
6419 LIBTEST_API short5 STDCALL
6420 mono_return_short5 (short5 s5, int addend) {
6422 fprintf(stderr, "mono_return_short5 s5.f1: got %d but expected %d\n", s5.f1, 1);
6425 fprintf(stderr, "mono_return_short5 s5.f2: got %d but expected %d\n", s5.f2, 2);
6428 fprintf(stderr, "mono_return_short5 s5.f3: got %d but expected %d\n", s5.f3, 3);
6431 fprintf(stderr, "mono_return_short5 s5.f4: got %d but expected %d\n", s5.f4, 4);
6434 fprintf(stderr, "mono_return_short5 s5.f5: got %d but expected %d\n", s5.f5, 5);
6436 s5.f1+=addend; s5.f2+=addend; s5.f3+=addend; s5.f4+=addend; s5.f5+=addend;
6441 short f1,f2,f3,f4,f5,f6;
6444 LIBTEST_API short6 STDCALL
6445 mono_return_short6 (short6 s6, int addend) {
6447 fprintf(stderr, "mono_return_short6 s6.f1: got %d but expected %d\n", s6.f1, 1);
6450 fprintf(stderr, "mono_return_short6 s6.f2: got %d but expected %d\n", s6.f2, 2);
6453 fprintf(stderr, "mono_return_short6 s6.f3: got %d but expected %d\n", s6.f3, 3);
6456 fprintf(stderr, "mono_return_short6 s6.f4: got %d but expected %d\n", s6.f4, 4);
6459 fprintf(stderr, "mono_return_short6 s6.f5: got %d but expected %d\n", s6.f5, 5);
6462 fprintf(stderr, "mono_return_short6 s6.f6: got %d but expected %d\n", s6.f6, 6);
6464 s6.f1+=addend; s6.f2+=addend; s6.f3+=addend; s6.f4+=addend; s6.f5+=addend; s6.f6+=addend;
6469 short f1,f2,f3,f4,f5,f6,f7;
6472 LIBTEST_API short7 STDCALL
6473 mono_return_short7 (short7 s7, int addend) {
6475 fprintf(stderr, "mono_return_short7 s7.f1: got %d but expected %d\n", s7.f1, 1);
6478 fprintf(stderr, "mono_return_short7 s7.f2: got %d but expected %d\n", s7.f2, 2);
6481 fprintf(stderr, "mono_return_short7 s7.f3: got %d but expected %d\n", s7.f3, 3);
6484 fprintf(stderr, "mono_return_short7 s7.f4: got %d but expected %d\n", s7.f4, 4);
6487 fprintf(stderr, "mono_return_short7 s7.f5: got %d but expected %d\n", s7.f5, 5);
6490 fprintf(stderr, "mono_return_short7 s7.f6: got %d but expected %d\n", s7.f6, 6);
6493 fprintf(stderr, "mono_return_short7 s7.f7: got %d but expected %d\n", s7.f7, 7);
6495 s7.f1+=addend; s7.f2+=addend; s7.f3+=addend; s7.f4+=addend; s7.f5+=addend; s7.f6+=addend; s7.f7+=addend;
6500 short f1,f2,f3,f4,f5,f6,f7,f8;
6503 LIBTEST_API short8 STDCALL
6504 mono_return_short8 (short8 s8, int addend) {
6506 fprintf(stderr, "mono_return_short8 s8.f1: got %d but expected %d\n", s8.f1, 1);
6509 fprintf(stderr, "mono_return_short8 s8.f2: got %d but expected %d\n", s8.f2, 2);
6512 fprintf(stderr, "mono_return_short8 s8.f3: got %d but expected %d\n", s8.f3, 3);
6515 fprintf(stderr, "mono_return_short8 s8.f4: got %d but expected %d\n", s8.f4, 4);
6518 fprintf(stderr, "mono_return_short8 s8.f5: got %d but expected %d\n", s8.f5, 5);
6521 fprintf(stderr, "mono_return_short8 s8.f6: got %d but expected %d\n", s8.f6, 6);
6524 fprintf(stderr, "mono_return_short8 s8.f7: got %d but expected %d\n", s8.f7, 7);
6527 fprintf(stderr, "mono_return_short8 s8.f8: got %d but expected %d\n", s8.f8, 8);
6529 s8.f1+=addend; s8.f2+=addend; s8.f3+=addend; s8.f4+=addend; s8.f5+=addend; s8.f6+=addend; s8.f7+=addend; s8.f8+=addend;
6534 short f1,f2,f3,f4,f5,f6,f7,f8,f9;
6537 LIBTEST_API short9 STDCALL
6538 mono_return_short9 (short9 s9, int addend) {
6540 fprintf(stderr, "mono_return_short9 s9.f1: got %d but expected %d\n", s9.f1, 1);
6543 fprintf(stderr, "mono_return_short9 s9.f2: got %d but expected %d\n", s9.f2, 2);
6546 fprintf(stderr, "mono_return_short9 s9.f3: got %d but expected %d\n", s9.f3, 3);
6549 fprintf(stderr, "mono_return_short9 s9.f4: got %d but expected %d\n", s9.f4, 4);
6552 fprintf(stderr, "mono_return_short9 s9.f5: got %d but expected %d\n", s9.f5, 5);
6555 fprintf(stderr, "mono_return_short9 s9.f6: got %d but expected %d\n", s9.f6, 6);
6558 fprintf(stderr, "mono_return_short9 s9.f7: got %d but expected %d\n", s9.f7, 7);
6561 fprintf(stderr, "mono_return_short9 s9.f8: got %d but expected %d\n", s9.f8, 8);
6564 fprintf(stderr, "mono_return_short9 s9.f9: got %d but expected %d\n", s9.f9, 9);
6566 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;
6574 short f2,f3,f4,f5,f6,f7;
6580 LIBTEST_API short8_nested STDCALL
6581 mono_return_short8_nested (short8_nested sn8, int addend) {
6582 if (sn8.nested1.f1 != 1) {
6583 fprintf(stderr, "mono_return_short8_nested sn8.nested1.f1: got %d but expected %d\n", sn8.nested1.f1, 1);
6586 fprintf(stderr, "mono_return_short8_nested sn8.f2: got %d but expected %d\n", sn8.f2, 2);
6589 fprintf(stderr, "mono_return_short8_nested sn8.f3: got %d but expected %d\n", sn8.f3, 3);
6592 fprintf(stderr, "mono_return_short8_nested sn8.f4: got %d but expected %d\n", sn8.f4, 4);
6595 fprintf(stderr, "mono_return_short8_nested sn8.f5: got %d but expected %d\n", sn8.f5, 5);
6598 fprintf(stderr, "mono_return_short8_nested sn8.f6: got %d but expected %d\n", sn8.f6, 6);
6601 fprintf(stderr, "mono_return_short8_nested sn8.f7: got %d but expected %d\n", sn8.f7, 7);
6603 if (sn8.nested2.f8 != 8) {
6604 fprintf(stderr, "mono_return_short8_nested sn8.nested2.f8: got %d but expected %d\n", sn8.nested2.f8, 8);
6606 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;
6615 LIBTEST_API int1 STDCALL
6616 mono_return_int1 (int1 s1, int addend) {
6618 fprintf(stderr, "mono_return_int1 s1.f1: got %d but expected %d\n", s1.f1, 1);
6628 LIBTEST_API int2 STDCALL
6629 mono_return_int2 (int2 s2, int addend) {
6631 fprintf(stderr, "mono_return_int2 s2.f1: got %d but expected %d\n", s2.f1, 1);
6634 fprintf(stderr, "mono_return_int2 s2.f2: got %d but expected %d\n", s2.f2, 2);
6636 s2.f1+=addend; s2.f2+=addend;
6644 LIBTEST_API int3 STDCALL
6645 mono_return_int3 (int3 s3, int addend) {
6647 fprintf(stderr, "mono_return_int3 s3.f1: got %d but expected %d\n", s3.f1, 1);
6650 fprintf(stderr, "mono_return_int3 s3.f2: got %d but expected %d\n", s3.f2, 2);
6653 fprintf(stderr, "mono_return_int3 s3.f3: got %d but expected %d\n", s3.f3, 3);
6655 s3.f1+=addend; s3.f2+=addend; s3.f3+=addend;
6663 LIBTEST_API int4 STDCALL
6664 mono_return_int4 (int4 s4, int addend) {
6666 fprintf(stderr, "mono_return_int4 s4.f1: got %d but expected %d\n", s4.f1, 1);
6669 fprintf(stderr, "mono_return_int4 s4.f2: got %d but expected %d\n", s4.f2, 2);
6672 fprintf(stderr, "mono_return_int4 s4.f3: got %d but expected %d\n", s4.f3, 3);
6675 fprintf(stderr, "mono_return_int4 s4.f4: got %d but expected %d\n", s4.f4, 4);
6677 s4.f1+=addend; s4.f2+=addend; s4.f3+=addend; s4.f4+=addend;
6685 LIBTEST_API int5 STDCALL
6686 mono_return_int5 (int5 s5, int addend) {
6688 fprintf(stderr, "mono_return_int5 s5.f1: got %d but expected %d\n", s5.f1, 1);
6691 fprintf(stderr, "mono_return_int5 s5.f2: got %d but expected %d\n", s5.f2, 2);
6694 fprintf(stderr, "mono_return_int5 s5.f3: got %d but expected %d\n", s5.f3, 3);
6697 fprintf(stderr, "mono_return_int5 s5.f4: got %d but expected %d\n", s5.f4, 4);
6700 fprintf(stderr, "mono_return_int5 s5.f5: got %d but expected %d\n", s5.f5, 5);
6702 s5.f1+=addend; s5.f2+=addend; s5.f3+=addend; s5.f4+=addend; s5.f5+=addend;
6716 LIBTEST_API int4_nested STDCALL
6717 mono_return_int4_nested (int4_nested sn4, int addend) {
6718 if (sn4.nested1.f1 != 1) {
6719 fprintf(stderr, "mono_return_int4_nested sn4.nested1.f1: got %d but expected %d\n", sn4.nested1.f1, 1);
6722 fprintf(stderr, "mono_return_int4_nested sn4.f2: got %d but expected %d\n", sn4.f2, 2);
6725 fprintf(stderr, "mono_return_int4_nested sn4.f3: got %d but expected %d\n", sn4.f3, 3);
6727 if (sn4.nested2.f4 != 4) {
6728 fprintf(stderr, "mono_return_int4_nested sn4.nested2.f4: got %d but expected %d\n", sn4.nested2.f4, 4);
6730 sn4.nested1.f1+=addend; sn4.f2+=addend; sn4.f3+=addend; sn4.nested2.f4+=addend;
6738 LIBTEST_API float1 STDCALL
6739 mono_return_float1 (float1 s1, int addend) {
6741 fprintf(stderr, "mono_return_float1 s1.f1: got %f but expected %d\n", s1.f1, 1);
6751 LIBTEST_API float2 STDCALL
6752 mono_return_float2 (float2 s2, int addend) {
6754 fprintf(stderr, "mono_return_float2 s2.f1: got %f but expected %d\n", s2.f1, 1);
6757 fprintf(stderr, "mono_return_float2 s2.f2: got %f but expected %d\n", s2.f2, 2);
6759 s2.f1+=addend; s2.f2+=addend;
6767 LIBTEST_API float3 STDCALL
6768 mono_return_float3 (float3 s3, int addend) {
6770 fprintf(stderr, "mono_return_float3 s3.f1: got %f but expected %d\n", s3.f1, 1);
6773 fprintf(stderr, "mono_return_float3 s3.f2: got %f but expected %d\n", s3.f2, 2);
6776 fprintf(stderr, "mono_return_float3 s3.f3: got %f but expected %d\n", s3.f3, 3);
6778 s3.f1+=addend; s3.f2+=addend; s3.f3+=addend;
6786 LIBTEST_API float4 STDCALL
6787 mono_return_float4 (float4 s4, int addend) {
6789 fprintf(stderr, "mono_return_float4 s4.f1: got %f but expected %d\n", s4.f1, 1);
6792 fprintf(stderr, "mono_return_float4 s4.f2: got %f but expected %d\n", s4.f2, 2);
6795 fprintf(stderr, "mono_return_float4 s4.f3: got %f but expected %d\n", s4.f3, 3);
6798 fprintf(stderr, "mono_return_float4 s4.f4: got %f but expected %d\n", s4.f4, 4);
6800 s4.f1+=addend; s4.f2+=addend; s4.f3+=addend; s4.f4+=addend;
6805 float f1,f2,f3,f4,f5;
6808 LIBTEST_API float5 STDCALL
6809 mono_return_float5 (float5 s5, int addend) {
6811 fprintf(stderr, "mono_return_float5 s5.f1: got %f but expected %d\n", s5.f1, 1);
6814 fprintf(stderr, "mono_return_float5 s5.f2: got %f but expected %d\n", s5.f2, 2);
6817 fprintf(stderr, "mono_return_float5 s5.f3: got %f but expected %d\n", s5.f3, 3);
6820 fprintf(stderr, "mono_return_float5 s5.f4: got %f but expected %d\n", s5.f4, 4);
6823 fprintf(stderr, "mono_return_float5 s5.f5: got %f but expected %d\n", s5.f5, 5);
6825 s5.f1+=addend; s5.f2+=addend; s5.f3+=addend; s5.f4+=addend; s5.f5+=addend;
6830 float f1,f2,f3,f4,f5,f6;
6833 LIBTEST_API float6 STDCALL
6834 mono_return_float6 (float6 s6, int addend) {
6836 fprintf(stderr, "mono_return_float6 s6.f1: got %f but expected %d\n", s6.f1, 1);
6839 fprintf(stderr, "mono_return_float6 s6.f2: got %f but expected %d\n", s6.f2, 2);
6842 fprintf(stderr, "mono_return_float6 s6.f3: got %f but expected %d\n", s6.f3, 3);
6845 fprintf(stderr, "mono_return_float6 s6.f4: got %f but expected %d\n", s6.f4, 4);
6848 fprintf(stderr, "mono_return_float6 s6.f5: got %f but expected %d\n", s6.f5, 5);
6851 fprintf(stderr, "mono_return_float6 s6.f6: got %f but expected %d\n", s6.f6, 6);
6853 s6.f1+=addend; s6.f2+=addend; s6.f3+=addend; s6.f4+=addend; s6.f5+=addend; s6.f6+=addend;
6858 float f1,f2,f3,f4,f5,f6,f7;
6861 LIBTEST_API float7 STDCALL
6862 mono_return_float7 (float7 s7, int addend) {
6864 fprintf(stderr, "mono_return_float7 s7.f1: got %f but expected %d\n", s7.f1, 1);
6867 fprintf(stderr, "mono_return_float7 s7.f2: got %f but expected %d\n", s7.f2, 2);
6870 fprintf(stderr, "mono_return_float7 s7.f3: got %f but expected %d\n", s7.f3, 3);
6873 fprintf(stderr, "mono_return_float7 s7.f4: got %f but expected %d\n", s7.f4, 4);
6876 fprintf(stderr, "mono_return_float7 s7.f5: got %f but expected %d\n", s7.f5, 5);
6879 fprintf(stderr, "mono_return_float7 s7.f6: got %f but expected %d\n", s7.f6, 6);
6882 fprintf(stderr, "mono_return_float7 s7.f7: got %f but expected %d\n", s7.f7, 7);
6884 s7.f1+=addend; s7.f2+=addend; s7.f3+=addend; s7.f4+=addend; s7.f5+=addend; s7.f6+=addend; s7.f7+=addend;
6889 float f1,f2,f3,f4,f5,f6,f7,f8;
6892 LIBTEST_API float8 STDCALL
6893 mono_return_float8 (float8 s8, int addend) {
6895 fprintf(stderr, "mono_return_float8 s8.f1: got %f but expected %d\n", s8.f1, 1);
6898 fprintf(stderr, "mono_return_float8 s8.f2: got %f but expected %d\n", s8.f2, 2);
6901 fprintf(stderr, "mono_return_float8 s8.f3: got %f but expected %d\n", s8.f3, 3);
6904 fprintf(stderr, "mono_return_float8 s8.f4: got %f but expected %d\n", s8.f4, 4);
6907 fprintf(stderr, "mono_return_float8 s8.f5: got %f but expected %d\n", s8.f5, 5);
6910 fprintf(stderr, "mono_return_float8 s8.f6: got %f but expected %d\n", s8.f6, 6);
6913 fprintf(stderr, "mono_return_float8 s8.f7: got %f but expected %d\n", s8.f7, 7);
6916 fprintf(stderr, "mono_return_float8 s8.f8: got %f but expected %d\n", s8.f8, 8);
6918 s8.f1+=addend; s8.f2+=addend; s8.f3+=addend; s8.f4+=addend; s8.f5+=addend; s8.f6+=addend; s8.f7+=addend; s8.f8+=addend;
6923 float f1,f2,f3,f4,f5,f6,f7,f8,f9;
6926 LIBTEST_API float9 STDCALL
6927 mono_return_float9 (float9 s9, int addend) {
6929 fprintf(stderr, "mono_return_float9 s9.f1: got %f but expected %d\n", s9.f1, 1);
6932 fprintf(stderr, "mono_return_float9 s9.f2: got %f but expected %d\n", s9.f2, 2);
6935 fprintf(stderr, "mono_return_float9 s9.f3: got %f but expected %d\n", s9.f3, 3);
6938 fprintf(stderr, "mono_return_float9 s9.f4: got %f but expected %d\n", s9.f4, 4);
6941 fprintf(stderr, "mono_return_float9 s9.f5: got %f but expected %d\n", s9.f5, 5);
6944 fprintf(stderr, "mono_return_float9 s9.f6: got %f but expected %d\n", s9.f6, 6);
6947 fprintf(stderr, "mono_return_float9 s9.f7: got %f but expected %d\n", s9.f7, 7);
6950 fprintf(stderr, "mono_return_float9 s9.f8: got %f but expected %d\n", s9.f8, 8);
6953 fprintf(stderr, "mono_return_float9 s9.f9: got %f but expected %d\n", s9.f9, 9);
6955 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;
6969 LIBTEST_API float4_nested STDCALL
6970 mono_return_float4_nested (float4_nested sn4, int addend) {
6971 if (sn4.nested1.f1 != 1) {
6972 fprintf(stderr, "mono_return_float4_nested sn4.nested1.f1: got %f but expected %d\n", sn4.nested1.f1, 1);
6975 fprintf(stderr, "mono_return_float4_nested sn4.f2: got %f but expected %d\n", sn4.f2, 2);
6978 fprintf(stderr, "mono_return_float4_nested sn4.f3: got %f but expected %d\n", sn4.f3, 3);
6980 if (sn4.nested2.f4 != 4) {
6981 fprintf(stderr, "mono_return_float4_nested sn4.nested2.f4: got %f but expected %d\n", sn4.nested2.f4, 4);
6983 sn4.nested1.f1+=addend; sn4.f2+=addend; sn4.f3+=addend; sn4.nested2.f4+=addend;
6991 LIBTEST_API double1 STDCALL
6992 mono_return_double1 (double1 s1, int addend) {
6994 fprintf(stderr, "mono_return_double1 s1.f1: got %f but expected %d\n", s1.f1, 1);
7004 LIBTEST_API double2 STDCALL
7005 mono_return_double2 (double2 s2, int addend) {
7007 fprintf(stderr, "mono_return_double2 s2.f1: got %f but expected %d\n", s2.f1, 1);
7010 fprintf(stderr, "mono_return_double2 s2.f2: got %f but expected %d\n", s2.f2, 2);
7012 s2.f1+=addend; s2.f2+=addend;
7020 LIBTEST_API double3 STDCALL
7021 mono_return_double3 (double3 s3, int addend) {
7023 fprintf(stderr, "mono_return_double3 s3.f1: got %f but expected %d\n", s3.f1, 1);
7026 fprintf(stderr, "mono_return_double3 s3.f2: got %f but expected %d\n", s3.f2, 2);
7029 fprintf(stderr, "mono_return_double3 s3.f3: got %f but expected %d\n", s3.f3, 3);
7031 s3.f1+=addend; s3.f2+=addend; s3.f3+=addend;
7039 LIBTEST_API double4 STDCALL
7040 mono_return_double4 (double4 s4, int addend) {
7042 fprintf(stderr, "mono_return_double4 s4.f1: got %f but expected %d\n", s4.f1, 1);
7045 fprintf(stderr, "mono_return_double4 s4.f2: got %f but expected %d\n", s4.f2, 2);
7048 fprintf(stderr, "mono_return_double4 s4.f3: got %f but expected %d\n", s4.f3, 3);
7051 fprintf(stderr, "mono_return_double4 s4.f4: got %f but expected %d\n", s4.f4, 4);
7053 s4.f1+=addend; s4.f2+=addend; s4.f3+=addend; s4.f4+=addend;
7058 double f1,f2,f3,f4,f5;
7061 LIBTEST_API double5 STDCALL
7062 mono_return_double5 (double5 s5, int addend) {
7064 fprintf(stderr, "mono_return_double5 s5.f1: got %f but expected %d\n", s5.f1, 1);
7067 fprintf(stderr, "mono_return_double5 s5.f2: got %f but expected %d\n", s5.f2, 2);
7070 fprintf(stderr, "mono_return_double5 s5.f3: got %f but expected %d\n", s5.f3, 3);
7073 fprintf(stderr, "mono_return_double5 s5.f4: got %f but expected %d\n", s5.f4, 4);
7076 fprintf(stderr, "mono_return_double5 s5.f5: got %f but expected %d\n", s5.f5, 5);
7078 s5.f1+=addend; s5.f2+=addend; s5.f3+=addend; s5.f4+=addend; s5.f5+=addend;
7083 double f1,f2,f3,f4,f5,f6;
7086 LIBTEST_API double6 STDCALL
7087 mono_return_double6 (double6 s6, int addend) {
7089 fprintf(stderr, "mono_return_double6 s6.f1: got %f but expected %d\n", s6.f1, 1);
7092 fprintf(stderr, "mono_return_double6 s6.f2: got %f but expected %d\n", s6.f2, 2);
7095 fprintf(stderr, "mono_return_double6 s6.f3: got %f but expected %d\n", s6.f3, 3);
7098 fprintf(stderr, "mono_return_double6 s6.f4: got %f but expected %d\n", s6.f4, 4);
7101 fprintf(stderr, "mono_return_double6 s6.f5: got %f but expected %d\n", s6.f5, 5);
7104 fprintf(stderr, "mono_return_double6 s6.f6: got %f but expected %d\n", s6.f6, 6);
7106 s6.f1+=addend; s6.f2+=addend; s6.f3+=addend; s6.f4+=addend; s6.f5+=addend; s6.f6+=addend;
7111 double f1,f2,f3,f4,f5,f6,f7;
7114 LIBTEST_API double7 STDCALL
7115 mono_return_double7 (double7 s7, int addend) {
7117 fprintf(stderr, "mono_return_double7 s7.f1: got %f but expected %d\n", s7.f1, 1);
7120 fprintf(stderr, "mono_return_double7 s7.f2: got %f but expected %d\n", s7.f2, 2);
7123 fprintf(stderr, "mono_return_double7 s7.f3: got %f but expected %d\n", s7.f3, 3);
7126 fprintf(stderr, "mono_return_double7 s7.f4: got %f but expected %d\n", s7.f4, 4);
7129 fprintf(stderr, "mono_return_double7 s7.f5: got %f but expected %d\n", s7.f5, 5);
7132 fprintf(stderr, "mono_return_double7 s7.f6: got %f but expected %d\n", s7.f6, 6);
7135 fprintf(stderr, "mono_return_double7 s7.f7: got %f but expected %d\n", s7.f7, 7);
7137 s7.f1+=addend; s7.f2+=addend; s7.f3+=addend; s7.f4+=addend; s7.f5+=addend; s7.f6+=addend; s7.f7+=addend;
7142 double f1,f2,f3,f4,f5,f6,f7,f8;
7145 LIBTEST_API double8 STDCALL
7146 mono_return_double8 (double8 s8, int addend) {
7148 fprintf(stderr, "mono_return_double8 s8.f1: got %f but expected %d\n", s8.f1, 1);
7151 fprintf(stderr, "mono_return_double8 s8.f2: got %f but expected %d\n", s8.f2, 2);
7154 fprintf(stderr, "mono_return_double8 s8.f3: got %f but expected %d\n", s8.f3, 3);
7157 fprintf(stderr, "mono_return_double8 s8.f4: got %f but expected %d\n", s8.f4, 4);
7160 fprintf(stderr, "mono_return_double8 s8.f5: got %f but expected %d\n", s8.f5, 5);
7163 fprintf(stderr, "mono_return_double8 s8.f6: got %f but expected %d\n", s8.f6, 6);
7166 fprintf(stderr, "mono_return_double8 s8.f7: got %f but expected %d\n", s8.f7, 7);
7169 fprintf(stderr, "mono_return_double8 s8.f8: got %f but expected %d\n", s8.f8, 8);
7171 s8.f1+=addend; s8.f2+=addend; s8.f3+=addend; s8.f4+=addend; s8.f5+=addend; s8.f6+=addend; s8.f7+=addend; s8.f8+=addend;
7176 double f1,f2,f3,f4,f5,f6,f7,f8,f9;
7179 LIBTEST_API double9 STDCALL
7180 mono_return_double9 (double9 s9, int addend) {
7182 fprintf(stderr, "mono_return_double9 s9.f1: got %f but expected %d\n", s9.f1, 1);
7185 fprintf(stderr, "mono_return_double9 s9.f2: got %f but expected %d\n", s9.f2, 2);
7188 fprintf(stderr, "mono_return_double9 s9.f3: got %f but expected %d\n", s9.f3, 3);
7191 fprintf(stderr, "mono_return_double9 s9.f4: got %f but expected %d\n", s9.f4, 4);
7194 fprintf(stderr, "mono_return_double9 s9.f5: got %f but expected %d\n", s9.f5, 5);
7197 fprintf(stderr, "mono_return_double9 s9.f6: got %f but expected %d\n", s9.f6, 6);
7200 fprintf(stderr, "mono_return_double9 s9.f7: got %f but expected %d\n", s9.f7, 7);
7203 fprintf(stderr, "mono_return_double9 s9.f8: got %f but expected %d\n", s9.f8, 8);
7206 fprintf(stderr, "mono_return_double9 s9.f9: got %f but expected %d\n", s9.f9, 9);
7208 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;
7221 LIBTEST_API double2_nested STDCALL
7222 mono_return_double2_nested (double2_nested sn2, int addend) {
7223 if (sn2.nested1.f1 != 1) {
7224 fprintf(stderr, "mono_return_double2_nested sn2.nested1.f1: got %f but expected %d\n", sn2.nested1.f1, 1);
7226 if (sn2.nested2.f2 != 2) {
7227 fprintf(stderr, "mono_return_double2_nested sn2.nested2.f2: got %f but expected %d\n", sn2.nested2.f2, 2);
7229 sn2.nested1.f1+=addend; sn2.nested2.f2+=addend;
7239 LIBTEST_API double_array4 STDCALL
7240 mono_return_double_array4 (double_array4 sa4, int addend) {
7241 if (sa4.f1[0] != 1) {
7242 fprintf(stderr, "mono_return_double_array4 sa4.f1[0]: got %f but expected %d\n", sa4.f1[0], 1);
7244 if (sa4.f1[1] != 2) {
7245 fprintf(stderr, "mono_return_double_array4 sa4.f1[1]: got %f but expected %d\n", sa4.f1[1], 2);
7247 if (sa4.f1[2] != 3) {
7248 fprintf(stderr, "mono_return_double_array4 sa4.f1[2]: got %f but expected %d\n", sa4.f1[2], 3);
7250 if (sa4.f1[3] != 4) {
7251 fprintf(stderr, "mono_return_double_array4 sa4.f1[3]: got %f but expected %d\n", sa4.f1[3], 4);
7253 sa4.f1[0]+=addend; sa4.f1[1]+=addend; sa4.f1[2]+=addend; sa4.f1[3]+=addend;
7261 LIBTEST_API int STDCALL
7262 mono_test_marshal_fixed_array (FixedArrayStruct s)
7264 return s.array [0] + s.array [1] + s.array [2];
7272 LIBTEST_API int STDCALL
7273 mono_test_marshal_fixed_buffer_char (FixedBufferChar *s)
7275 if (!(s->array [0] == 'A' && s->array [1] == 'B' && s->array [2] == 'C' && s->c == 'D'))
7286 } FixedBufferUnicode;
7288 LIBTEST_API int STDCALL
7289 mono_test_marshal_fixed_buffer_unicode (FixedBufferUnicode *s)
7291 if (!(s->array [0] == 'A' && s->array [1] == 'B' && s->array [2] == 'C' && s->c == 'D'))
7299 const int NSTRINGS = 6;
7301 const char *utf8Strings[] = {
7303 "Sîne klâwen durh die wolken sint geslagen" ,
7304 "काचं शक्नोम्यत्तुम् । नोपहिनस्ति माम्",
7306 "ღმერთსი შემვედრე,შემვედრე, ნუთუ კვლა დამხსნას შემვედრე,სოფლისა შემვედრე, შემვედრე,შემვედრე,შემვედრე,შრომასა, ცეცხლს, წყალსა და მიწასა, ჰაერთა თანა მრომასა; მომცნეს ფრთენი და აღვფრინდე, მივჰხვდე მას ჩემსა ნდომასა, დღისით და ღამით ვჰხედვიდე მზისა ელვათა კრთომაასაშემვედრე,შემვედრე,",
7307 "Τη γλώσσα μου έδωσαν ελληνική",
7312 build_return_string(const char* pReturn)
7315 if (pReturn == 0 || *pReturn == 0)
7318 size_t strLength = strlen(pReturn);
7319 ret = (char *)(marshal_alloc (sizeof(char)* (strLength + 1)));
7320 memcpy(ret, pReturn, strLength);
7321 ret [strLength] = '\0';
7326 StringParameterInOut(/*[In,Out]*/ char *s, int index)
7329 return build_return_string(s);
7333 StringParameterRefOut(/*out*/ char **s, int index)
7335 char *pszTextutf8 = (char*)utf8Strings[index];
7336 size_t strLength = strlen(pszTextutf8);
7337 *s = (char *)(marshal_alloc (sizeof(char)* (strLength + 1)));
7338 memcpy(*s, pszTextutf8, strLength);
7339 (*s)[strLength] = '\0';
7343 StringParameterRef(/*ref*/ char **s, int index)
7345 char *pszTextutf8 = (char*)utf8Strings[index];
7346 size_t strLength = strlen(pszTextutf8);
7347 // do byte by byte validation of in string
7348 size_t szLen = strlen(*s);
7349 for (size_t i = 0; i < szLen; i++)
7351 if ((*s)[i] != pszTextutf8[i])
7353 printf("[in] managed string do not match native string\n");
7362 // overwrite the orginal
7363 *s = (char *)(marshal_alloc (sizeof(char)* (strLength + 1)));
7364 memcpy(*s, pszTextutf8, strLength);
7365 (*s)[strLength] = '\0';
7369 StringBuilderParameterInOut(/*[In,Out] StringBuilder*/ char *s, int index)
7372 if (s == 0 || *s == 0)
7375 char *pszTextutf8 = (char*)utf8Strings[index];
7377 // do byte by byte validation of in string
7378 size_t szLen = strlen(s);
7379 for (size_t i = 0; i < szLen; i++)
7381 if (s[i] != pszTextutf8[i])
7383 printf("[in] managed string do not match native string\n");
7388 // modify the string inplace
7389 size_t outLen = strlen(pszTextutf8);
7390 for (size_t i = 0; i < outLen; i++) {
7391 s[i] = pszTextutf8[i];
7396 //out string builder
7398 StringBuilderParameterOut(/*[Out] StringBuilder*/ char *s, int index)
7400 char *pszTextutf8 = (char*)utf8Strings[index];
7402 printf ("SBPO: Receiving %s\n", s);
7403 // modify the string inplace
7404 size_t outLen = strlen(pszTextutf8);
7405 for (size_t i = 0; i < outLen; i++) {
7406 s[i] = pszTextutf8[i];
7412 StringParameterOut(/*[Out]*/ char *s, int index)
7415 return build_return_string(s);
7419 typedef struct FieldWithUtf8
7427 TestStructWithUtf8Field(struct FieldWithUtf8 fieldStruct)
7429 char *pszManagedutf8 = fieldStruct.pFirst;
7430 int stringIndex = fieldStruct.index;
7431 char *pszNative = 0;
7434 if (pszManagedutf8 == 0 || *pszManagedutf8 == 0)
7437 pszNative = (char*)utf8Strings[stringIndex];
7439 outLen = strlen(pszNative);
7440 // do byte by byte comparision
7441 for (size_t i = 0; i < outLen; i++)
7443 if (pszNative[i] != pszManagedutf8[i])
7445 printf("Native and managed string do not match.\n");
7451 typedef void (* Callback2)(char *text, int index);
7454 Utf8DelegateAsParameter(Callback2 managedCallback)
7456 for (int i = 0; i < NSTRINGS; ++i)
7458 char *pszNative = 0;
7459 pszNative = (char*)utf8Strings[i];
7460 managedCallback(pszNative, i);
7466 StringBuilderParameterReturn(int index)
7468 char *pszTextutf8 = (char*)utf8Strings[index];
7469 size_t strLength = strlen(pszTextutf8);
7470 char * ret = (char *)(marshal_alloc (sizeof(char)* (strLength + 1)));
7471 memcpy(ret, pszTextutf8, strLength);
7472 ret[strLength] = '\0';
7477 LIBTEST_API int STDCALL
7478 mono_test_marshal_pointer_array (int *arr[])
7482 for (i = 0; i < 10; ++i) {
7491 typedef void (*NativeToManagedExceptionRethrowFunc) (void);
7493 void *mono_test_native_to_managed_exception_rethrow_thread (void *arg)
7495 NativeToManagedExceptionRethrowFunc func = (NativeToManagedExceptionRethrowFunc) arg;
7500 LIBTEST_API void STDCALL
7501 mono_test_native_to_managed_exception_rethrow (NativeToManagedExceptionRethrowFunc func)
7504 pthread_create (&t, NULL, mono_test_native_to_managed_exception_rethrow_thread, func);
7505 pthread_join (t, NULL);