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 = 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 = 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 = 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 = 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 = (gpointer)0x12345678;
630 if (ss->a && ss->b && ss->c && !strcmp (ss->d, "TEST3"))
636 typedef int (STDCALL *InVTypeDelegate) (int a, simplestruct *ss, int b);
638 LIBTEST_API int STDCALL
639 mono_test_marshal_in_struct (int a, simplestruct *ss, int b, InVTypeDelegate func)
644 memcpy (&ss2, ss, sizeof (simplestruct));
646 res = func (a, ss, b);
648 printf ("mono_test_marshal_in_struct () failed: %d\n", res);
652 /* Check that no modifications is made to the struct */
653 if (ss2.a == ss->a && ss2.b == ss->b && ss2.c == ss->c && ss2.d == ss->d)
661 SimpleDelegate func, func2, func3;
664 LIBTEST_API DelegateStruct STDCALL
665 mono_test_marshal_delegate_struct (DelegateStruct ds)
669 res.a = ds.func (ds.a) + ds.func2 (ds.a) + (ds.func3 == NULL ? 0 : 1);
671 res.func2 = ds.func2;
677 LIBTEST_API int STDCALL
678 mono_test_marshal_struct (simplestruct ss)
680 if (ss.a == 0 && ss.b == 1 && ss.c == 0 &&
681 !strcmp (ss.d, "TEST"))
687 LIBTEST_API int STDCALL
688 mono_test_marshal_byref_struct (simplestruct *ss, int a, int b, int c, char *d)
690 gboolean res = (ss->a == a && ss->b == b && ss->c == c && strcmp (ss->d, d) == 0);
692 marshal_free ((char*)ss->d);
697 ss->d = marshal_strdup ("DEF");
713 LIBTEST_API int STDCALL
714 mono_test_marshal_struct2 (simplestruct2 ss)
716 if (ss.a == 0 && ss.b == 1 && ss.c == 0 &&
717 !strcmp (ss.d, "TEST") &&
718 ss.e == 99 && ss.f == 1.5 && ss.g == 42 && ss.h == (guint64)123)
724 /* on HP some of the struct should be on the stack and not in registers */
725 LIBTEST_API int STDCALL
726 mono_test_marshal_struct2_2 (int i, int j, int k, simplestruct2 ss)
728 if (i != 10 || j != 11 || k != 12)
730 if (ss.a == 0 && ss.b == 1 && ss.c == 0 &&
731 !strcmp (ss.d, "TEST") &&
732 ss.e == 99 && ss.f == 1.5 && ss.g == 42 && ss.h == (guint64)123)
738 LIBTEST_API int STDCALL
739 mono_test_marshal_lpstruct (simplestruct *ss)
741 if (ss->a == 0 && ss->b == 1 && ss->c == 0 &&
742 !strcmp (ss->d, "TEST"))
748 LIBTEST_API int STDCALL
749 mono_test_marshal_lpstruct_blittable (point *p)
751 if (p->x == 1.0 && p->y == 2.0)
757 LIBTEST_API int STDCALL
758 mono_test_marshal_struct_array (simplestruct2 *ss)
760 if (! (ss[0].a == 0 && ss[0].b == 1 && ss[0].c == 0 &&
761 !strcmp (ss[0].d, "TEST") &&
762 ss[0].e == 99 && ss[0].f == 1.5 && ss[0].g == 42 && ss[0].h == (guint64)123))
765 if (! (ss[1].a == 0 && ss[1].b == 0 && ss[1].c == 0 &&
766 !strcmp (ss[1].d, "TEST2") &&
767 ss[1].e == 100 && ss[1].f == 2.5 && ss[1].g == 43 && ss[1].h == (guint64)124))
773 typedef struct long_align_struct {
779 LIBTEST_API int STDCALL
780 mono_test_marshal_long_align_struct_array (long_align_struct *ss)
782 return ss[0].a + ss[0].b + ss[0].c + ss[1].a + ss[1].b + ss[1].c;
785 LIBTEST_API simplestruct2 * STDCALL
786 mono_test_marshal_class (int i, int j, int k, simplestruct2 *ss, int l)
793 if (i != 10 || j != 11 || k != 12 || l != 14)
795 if (! (ss->a == 0 && ss->b == 1 && ss->c == 0 &&
796 !strcmp (ss->d, "TEST") &&
797 ss->e == 99 && ss->f == 1.5 && ss->g == 42 && ss->h == (guint64)123))
800 res = marshal_new0 (simplestruct2, 1);
801 memcpy (res, ss, sizeof (simplestruct2));
802 res->d = marshal_strdup ("TEST");
806 LIBTEST_API int STDCALL
807 mono_test_marshal_byref_class (simplestruct2 **ssp)
809 simplestruct2 *ss = *ssp;
812 if (! (ss->a == 0 && ss->b == 1 && ss->c == 0 &&
813 !strcmp (ss->d, "TEST") &&
814 ss->e == 99 && ss->f == 1.5 && ss->g == 42 && ss->h == (guint64)123))
817 res = marshal_new0 (simplestruct2, 1);
818 memcpy (res, ss, sizeof (simplestruct2));
819 res->d = marshal_strdup ("TEST-RES");
831 /* Yes, this is correct, we are only trying to determine the value of the stack here */
836 LIBTEST_API int STDCALL
837 reliable_delegate (int a)
843 * Checks whether get_sp() works as expected. It doesn't work with gcc-2.95.3 on linux.
846 is_get_sp_reliable (void)
850 reliable_delegate(1);
852 reliable_delegate(1);
857 LIBTEST_API int STDCALL
858 mono_test_marshal_delegate (SimpleDelegate delegate)
862 /* Check that the delegate wrapper is stdcall */
867 if (is_get_sp_reliable())
868 g_assert (sp1 == sp2);
873 static int STDCALL inc_cb (int i)
878 LIBTEST_API int STDCALL
879 mono_test_marshal_out_delegate (SimpleDelegate *delegate)
886 LIBTEST_API SimpleDelegate STDCALL
887 mono_test_marshal_return_delegate (SimpleDelegate delegate)
892 typedef int DelegateByrefDelegate (void *);
894 LIBTEST_API int STDCALL
895 mono_test_marshal_delegate_ref_delegate (DelegateByrefDelegate del)
905 return_plus_one (int i)
910 LIBTEST_API SimpleDelegate STDCALL
911 mono_test_marshal_return_delegate_2 (void)
913 return return_plus_one;
916 typedef simplestruct (STDCALL *SimpleDelegate2) (simplestruct ss);
919 is_utf16_equals (gunichar2 *s1, const char *s2)
924 s = g_utf16_to_utf8 (s1, -1, NULL, NULL, NULL);
925 res = strcmp (s, s2);
931 LIBTEST_API int STDCALL
932 mono_test_marshal_delegate2 (SimpleDelegate2 delegate)
934 simplestruct ss, res;
940 ss.d2 = g_utf8_to_utf16 ("TEST2", -1, NULL, NULL, NULL);
943 if (! (res.a && !res.b && res.c && !strcmp (res.d, "TEST-RES") && is_utf16_equals (res.d2, "TEST2-RES")))
949 typedef simplestruct* (STDCALL *SimpleDelegate4) (simplestruct *ss);
951 LIBTEST_API int STDCALL
952 mono_test_marshal_delegate4 (SimpleDelegate4 delegate)
963 res = delegate (&ss);
967 /* Check return value */
968 if (! (!res->a && res->b && !res->c && !strcmp (res->d, "TEST")))
971 /* Check NULL argument and NULL result */
972 res = delegate (NULL);
979 typedef int (STDCALL *SimpleDelegate5) (simplestruct **ss);
981 LIBTEST_API int STDCALL
982 mono_test_marshal_delegate5 (SimpleDelegate5 delegate)
995 res = delegate (&ptr);
999 if (!(ptr->a && !ptr->b && ptr->c && !strcmp (ptr->d, "RES")))
1005 LIBTEST_API int STDCALL
1006 mono_test_marshal_delegate6 (SimpleDelegate5 delegate)
1012 typedef int (STDCALL *SimpleDelegate7) (simplestruct **ss);
1014 LIBTEST_API int STDCALL
1015 mono_test_marshal_delegate7 (SimpleDelegate7 delegate)
1020 /* Check that the input pointer is ignored */
1021 ptr = (gpointer)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 (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 LIBTEST_API int STDCALL
1113 mono_test_marshal_stringbuilder (char *s, int n)
1115 const char m[] = "This is my message. Isn't it nice?";
1117 if (strcmp (s, "ABCD") != 0)
1124 LIBTEST_API int STDCALL
1125 mono_test_marshal_stringbuilder_append (char *s, int length)
1127 const char out_sentinel[] = "CSHARP_";
1128 const char out_len = strlen (out_sentinel);
1130 for (int i=0; i < length; i++) {
1131 s [i] = out_sentinel [i % out_len];
1140 LIBTEST_API int STDCALL
1141 mono_test_marshal_stringbuilder_default (char *s, int n)
1143 const char m[] = "This is my message. Isn't it nice?";
1150 LIBTEST_API int STDCALL
1151 mono_test_marshal_stringbuilder_unicode (gunichar2 *s, int n)
1153 const char m[] = "This is my message. Isn't it nice?";
1157 s2 = g_utf8_to_utf16 (m, -1, NULL, &len, NULL);
1159 len = (len * 2) + 2;
1162 memcpy (s, s2, len);
1169 LIBTEST_API void STDCALL
1170 mono_test_marshal_stringbuilder_out (char **s)
1172 const char m[] = "This is my message. Isn't it nice?";
1175 str = marshal_alloc (strlen (m) + 1);
1176 memcpy (str, m, strlen (m) + 1);
1181 LIBTEST_API int STDCALL
1182 mono_test_marshal_stringbuilder_out_unicode (gunichar2 **s)
1184 const char m[] = "This is my message. Isn't it nice?";
1188 s2 = g_utf8_to_utf16 (m, -1, NULL, &len, NULL);
1190 len = (len * 2) + 2;
1191 *s = marshal_alloc (len);
1192 memcpy (*s, s2, len);
1199 LIBTEST_API int STDCALL
1200 mono_test_marshal_stringbuilder_ref (char **s)
1202 const char m[] = "This is my message. Isn't it nice?";
1205 if (strcmp (*s, "ABC"))
1208 str = marshal_alloc (strlen (m) + 1);
1209 memcpy (str, m, strlen (m) + 1);
1221 LIBTEST_API int STDCALL
1222 mono_test_marshal_empty_string_array (char **array)
1224 return (array == NULL) ? 0 : 1;
1227 LIBTEST_API int STDCALL
1228 mono_test_marshal_string_array (char **array)
1230 if (strcmp (array [0], "ABC"))
1232 if (strcmp (array [1], "DEF"))
1235 if (array [2] != NULL)
1241 LIBTEST_API int STDCALL
1242 mono_test_marshal_byref_string_array (char ***array)
1247 if (strcmp ((*array) [0], "Alpha"))
1249 if (strcmp ((*array) [1], "Beta"))
1251 if (strcmp ((*array) [2], "Gamma"))
1257 LIBTEST_API int STDCALL
1258 mono_test_marshal_stringbuilder_array (char **array)
1260 if (strcmp (array [0], "ABC"))
1262 if (strcmp (array [1], "DEF"))
1265 strcpy (array [0], "DEF");
1266 strcpy (array [1], "ABC");
1271 LIBTEST_API int STDCALL
1272 mono_test_marshal_unicode_string_array (gunichar2 **array, char **array2)
1274 GError *error = NULL;
1277 s = g_utf16_to_utf8 (array [0], -1, NULL, NULL, &error);
1278 if (strcmp (s, "ABC")) {
1285 s = g_utf16_to_utf8 (array [1], -1, NULL, NULL, &error);
1286 if (strcmp (s, "DEF")) {
1293 if (strcmp (array2 [0], "ABC"))
1296 if (strcmp (array2 [1], "DEF"))
1302 /* this does not work on Redhat gcc 2.96 */
1303 LIBTEST_API int STDCALL
1304 mono_test_empty_struct (int a, EmptyStruct es, int b)
1306 // printf ("mono_test_empty_struct %d %d\n", a, b);
1308 // Intel icc on ia64 passes 'es' in 2 registers
1309 #if defined(__ia64) && defined(__INTEL_COMPILER)
1312 if (a == 1 && b == 2)
1318 LIBTEST_API EmptyStruct STDCALL
1319 mono_test_return_empty_struct (int a)
1332 LIBTEST_API ByValStrStruct * STDCALL
1333 mono_test_byvalstr_gen (void)
1335 ByValStrStruct *ret;
1337 ret = malloc(sizeof(ByValStrStruct));
1338 memset(ret, 'a', sizeof(ByValStrStruct)-1);
1339 ret->a[sizeof(ByValStrStruct)-1] = 0;
1344 LIBTEST_API int STDCALL
1345 mono_test_byvalstr_check (ByValStrStruct* data, char* correctString)
1349 ret = strcmp(data->a, correctString);
1350 // printf ("T1: %s\n", data->a);
1351 // printf ("T2: %s\n", correctString);
1353 /* we need g_free because the allocation was performed by mono_test_byvalstr_gen */
1361 } ByValStrStruct_Unicode;
1363 LIBTEST_API int STDCALL
1364 mono_test_byvalstr_check_unicode (ByValStrStruct_Unicode *ref, int test)
1366 if (ref->flag != 0x1234abcd){
1367 printf ("overwritten data");
1371 if (test == 1 || test == 3){
1372 if (ref->a [0] != '1' ||
1373 ref->a [1] != '2' ||
1379 if (ref->a [0] != '1' ||
1387 LIBTEST_API int STDCALL
1388 NameManglingAnsi (char *data)
1390 return data [0] + data [1] + data [2];
1393 LIBTEST_API int STDCALL
1394 NameManglingAnsiA (char *data)
1396 g_assert_not_reached ();
1399 LIBTEST_API int STDCALL
1400 NameManglingAnsiW (char *data)
1402 g_assert_not_reached ();
1405 LIBTEST_API int STDCALL
1406 NameManglingAnsi2A (char *data)
1408 return data [0] + data [1] + data [2];
1411 LIBTEST_API int STDCALL
1412 NameManglingAnsi2W (char *data)
1414 g_assert_not_reached ();
1417 LIBTEST_API int STDCALL
1418 NameManglingUnicode (char *data)
1420 g_assert_not_reached ();
1423 LIBTEST_API int STDCALL
1424 NameManglingUnicodeW (gunichar2 *data)
1426 return data [0] + data [1] + data [2];
1429 LIBTEST_API int STDCALL
1430 NameManglingUnicode2 (gunichar2 *data)
1432 return data [0] + data [1] + data [2];
1435 LIBTEST_API int STDCALL
1436 NameManglingAutoW (char *data)
1439 return (data [0] + data [1] + data [2]) == 131 ? 0 : 1;
1441 g_assert_not_reached ();
1445 LIBTEST_API int STDCALL
1446 NameManglingAuto (char *data)
1449 return (data [0] + data [1] + data [2]) == 198 ? 0 : 1;
1451 g_assert_not_reached ();
1455 typedef int (STDCALL *intcharFunc)(const char*);
1457 LIBTEST_API void STDCALL
1458 callFunction (intcharFunc f)
1468 LIBTEST_API int STDCALL
1469 class_marshal_test0 (SimpleObj *obj1)
1471 // printf ("class_marshal_test0 %s %d\n", obj1->str, obj1->i);
1473 if (strcmp(obj1->str, "T1"))
1481 LIBTEST_API int STDCALL
1482 class_marshal_test4 (SimpleObj *obj1)
1490 LIBTEST_API void STDCALL
1491 class_marshal_test1 (SimpleObj **obj1)
1493 SimpleObj *res = malloc (sizeof (SimpleObj));
1495 res->str = marshal_strdup ("ABC");
1501 LIBTEST_API int STDCALL
1502 class_marshal_test2 (SimpleObj **obj1)
1504 // printf ("class_marshal_test2 %s %d\n", (*obj1)->str, (*obj1)->i);
1506 if (strcmp((*obj1)->str, "ABC"))
1508 if ((*obj1)->i != 5)
1514 LIBTEST_API int STDCALL
1515 string_marshal_test0 (char *str)
1517 if (strcmp (str, "TEST0"))
1523 LIBTEST_API void STDCALL
1524 string_marshal_test1 (const char **str)
1526 *str = marshal_strdup ("TEST1");
1529 LIBTEST_API int STDCALL
1530 string_marshal_test2 (char **str)
1532 // printf ("string_marshal_test2 %s\n", *str);
1534 if (strcmp (*str, "TEST1"))
1537 *str = marshal_strdup ("TEST2");
1542 LIBTEST_API int STDCALL
1543 string_marshal_test3 (char *str)
1556 LIBTEST_API BlittableClass* STDCALL
1557 TestBlittableClass (BlittableClass *vl)
1559 BlittableClass *res;
1561 // printf ("TestBlittableClass %d %d\n", vl->a, vl->b);
1567 res = marshal_new0 (BlittableClass, 1);
1568 memcpy (res, vl, sizeof (BlittableClass));
1570 res = marshal_new0 (BlittableClass, 1);
1578 typedef struct OSVERSIONINFO_STRUCT
1582 } OSVERSIONINFO_STRUCT;
1584 LIBTEST_API int STDCALL
1585 MyGetVersionEx (OSVERSIONINFO_STRUCT *osvi)
1588 // printf ("GOT %d %d\n", osvi->a, osvi->b);
1593 return osvi->a + osvi->b;
1596 LIBTEST_API int STDCALL
1597 BugGetVersionEx (int a, int b, int c, int d, int e, int f, int g, int h, OSVERSIONINFO_STRUCT *osvi)
1600 // printf ("GOT %d %d\n", osvi->a, osvi->b);
1605 return osvi->a + osvi->b;
1608 LIBTEST_API int STDCALL
1609 mono_test_marshal_point (point pt)
1611 // printf("point %g %g\n", pt.x, pt.y);
1612 if (pt.x == 1.25 && pt.y == 3.5)
1623 LIBTEST_API int STDCALL
1624 mono_test_marshal_mixed_point (mixed_point pt)
1626 // printf("mixed point %d %g\n", pt.x, pt.y);
1627 if (pt.x == 5 && pt.y == 6.75)
1633 LIBTEST_API int STDCALL
1634 mono_test_marshal_mixed_point_2 (mixed_point *pt)
1636 if (pt->x != 5 || pt->y != 6.75)
1645 LIBTEST_API int STDCALL
1646 marshal_test_ref_bool(int i, char *b1, short *b2, int *b3)
1649 if (*b1 != 0 && *b1 != 1)
1651 if (*b2 != 0 && *b2 != -1) /* variant_bool */
1653 if (*b3 != 0 && *b3 != 1)
1655 if (i == ((*b1 << 2) | (-*b2 << 1) | *b3))
1667 short b2; /* variant_bool */
1671 LIBTEST_API int STDCALL
1672 marshal_test_bool_struct(struct BoolStruct *s)
1675 if (s->b1 != 0 && s->b1 != 1)
1677 if (s->b2 != 0 && s->b2 != -1)
1679 if (s->b3 != 0 && s->b3 != 1)
1681 if (s->i == ((s->b1 << 2) | (-s->b2 << 1) | s->b3))
1698 LIBTEST_API int STDCALL
1699 mono_test_marshal_long_struct (LongStruct *s)
1701 return s->i + s->l.l;
1704 LIBTEST_API void STDCALL
1705 mono_test_last_error (int err)
1714 LIBTEST_API int STDCALL
1715 mono_test_asany (void *ptr, int what)
1719 return (*(int*)ptr == 5) ? 0 : 1;
1721 return strcmp (ptr, "ABC") == 0 ? 0 : 1;
1723 simplestruct2 ss = *(simplestruct2*)ptr;
1725 if (ss.a == 0 && ss.b == 1 && ss.c == 0 &&
1726 !strcmp (ss.d, "TEST") &&
1727 ss.e == 99 && ss.f == 1.5 && ss.g == 42 && ss.h == (guint64)123)
1733 GError *error = NULL;
1736 s = g_utf16_to_utf8 (ptr, -1, NULL, NULL, &error);
1741 if (!strcmp (s, "ABC")) {
1751 g_assert_not_reached ();
1765 LIBTEST_API int STDCALL
1766 mono_test_marshal_asany_in (void* ptr)
1768 AsAnyStruct* asAny = ptr;
1769 int res = asAny->i + asAny->j + asAny->k;
1774 LIBTEST_API int STDCALL
1775 mono_test_marshal_asany_inout (void* ptr)
1777 AsAnyStruct* asAny = ptr;
1778 int res = asAny->i + asAny->j + asAny->k;
1780 marshal_free (asAny->s);
1790 LIBTEST_API int STDCALL
1791 mono_test_marshal_asany_out (void* ptr)
1793 AsAnyStruct* asAny = ptr;
1794 int res = asAny->i + asAny->j + asAny->k;
1805 * AMD64 marshalling tests.
1808 typedef struct amd64_struct1 {
1815 LIBTEST_API amd64_struct1 STDCALL
1816 mono_test_marshal_amd64_pass_return_struct1 (amd64_struct1 s)
1826 LIBTEST_API amd64_struct1 STDCALL
1827 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)
1832 s.l += 1 + i1 + i2 + i3 + i4 + i5 + i6 + i7 + i8;
1837 typedef struct amd64_struct2 {
1842 LIBTEST_API amd64_struct2 STDCALL
1843 mono_test_marshal_amd64_pass_return_struct2 (amd64_struct2 s)
1851 typedef struct amd64_struct3 {
1855 LIBTEST_API amd64_struct3 STDCALL
1856 mono_test_marshal_amd64_pass_return_struct3 (amd64_struct3 s)
1863 typedef struct amd64_struct4 {
1867 LIBTEST_API amd64_struct4 STDCALL
1868 mono_test_marshal_amd64_pass_return_struct4 (amd64_struct4 s)
1877 * IA64 marshalling tests.
1879 typedef struct test_struct5 {
1883 LIBTEST_API test_struct5 STDCALL
1884 mono_test_marshal_ia64_pass_return_struct5 (double d1, double d2, test_struct5 s, int i, double d3, double d4)
1886 s.d1 += d1 + d2 + i;
1887 s.d2 += d3 + d4 + i;
1892 typedef struct test_struct6 {
1896 LIBTEST_API test_struct6 STDCALL
1897 mono_test_marshal_ia64_pass_return_struct6 (double d1, double d2, test_struct6 s, int i, double d3, double d4)
1899 s.d1 += d1 + d2 + i;
1905 static guint32 custom_res [2];
1907 LIBTEST_API void* STDCALL
1908 mono_test_marshal_pass_return_custom (int i, guint32 *ptr, int j)
1910 /* ptr will be freed by CleanupNative, so make a copy */
1911 custom_res [0] = 0; /* not allocated by AllocHGlobal */
1912 custom_res [1] = ptr [1];
1917 LIBTEST_API int STDCALL
1918 mono_test_marshal_pass_out_custom (int i, guint32 **ptr, int j)
1921 custom_res [1] = i + j + 10;
1928 LIBTEST_API int STDCALL
1929 mono_test_marshal_pass_inout_custom (int i, guint32 *ptr, int j)
1932 ptr [1] = i + ptr [1] + j;
1937 LIBTEST_API int STDCALL
1938 mono_test_marshal_pass_out_byval_custom (int i, guint32 *ptr, int j)
1940 return ptr == NULL ? 0 : 1;
1943 LIBTEST_API int STDCALL
1944 mono_test_marshal_pass_byref_custom (int i, guint32 **ptr, int j)
1951 LIBTEST_API void* STDCALL
1952 mono_test_marshal_pass_return_custom2 (int i, guint32 *ptr, int j)
1954 g_assert_not_reached ();
1959 LIBTEST_API void* STDCALL
1960 mono_test_marshal_pass_return_custom_null (int i, guint32 *ptr, int j)
1962 g_assert (ptr == NULL);
1967 typedef void *(STDCALL *PassReturnPtrDelegate) (void *ptr);
1969 LIBTEST_API int STDCALL
1970 mono_test_marshal_pass_return_custom_in_delegate (PassReturnPtrDelegate del)
1984 /* FIXME: Freed with FreeHGlobal */
1992 LIBTEST_API int STDCALL
1993 mono_test_marshal_pass_return_custom_null_in_delegate (PassReturnPtrDelegate del)
1995 void *ptr = del (NULL);
1997 return (ptr == NULL) ? 15 : 0;
2000 typedef void (STDCALL *CustomOutParamDelegate) (void **pptr);
2002 LIBTEST_API int STDCALL
2003 mono_test_marshal_custom_out_param_delegate (CustomOutParamDelegate del)
2015 typedef int (STDCALL *ReturnEnumDelegate) (int e);
2017 LIBTEST_API int STDCALL
2018 mono_test_marshal_return_enum_delegate (ReturnEnumDelegate func)
2028 typedef BlittableStruct (STDCALL *SimpleDelegate10) (BlittableStruct ss);
2030 LIBTEST_API int STDCALL
2031 mono_test_marshal_blittable_struct_delegate (SimpleDelegate10 delegate)
2033 BlittableStruct ss, res;
2040 res = delegate (ss);
2041 if (! ((res.a == -1) && (res.b == -2) && (res.c == -3) && (res.d == -55)))
2047 LIBTEST_API int STDCALL
2048 mono_test_stdcall_name_mangling (int a, int b, int c)
2054 mono_test_stdcall_mismatch_1 (int a, int b, int c)
2059 LIBTEST_API int STDCALL
2060 mono_test_stdcall_mismatch_2 (int a, int b, int c)
2066 * PASSING AND RETURNING SMALL STRUCTURES FROM DELEGATES TESTS
2073 typedef SmallStruct1 (STDCALL *SmallStructDelegate1) (SmallStruct1 ss);
2075 LIBTEST_API int STDCALL
2076 mono_test_marshal_small_struct_delegate1 (SmallStructDelegate1 delegate)
2078 SmallStruct1 ss, res;
2082 res = delegate (ss);
2083 if (! (res.i == -1))
2093 typedef SmallStruct2 (STDCALL *SmallStructDelegate2) (SmallStruct2 ss);
2095 LIBTEST_API int STDCALL
2096 mono_test_marshal_small_struct_delegate2 (SmallStructDelegate2 delegate)
2098 SmallStruct2 ss, res;
2103 res = delegate (ss);
2104 if (! ((res.i == -2) && (res.j == -3)))
2115 typedef SmallStruct3 (STDCALL *SmallStructDelegate3) (SmallStruct3 ss);
2117 LIBTEST_API int STDCALL
2118 mono_test_marshal_small_struct_delegate3 (SmallStructDelegate3 delegate)
2120 SmallStruct3 ss, res;
2125 res = delegate (ss);
2126 if (! ((res.i == -1) && (res.j == -2)))
2136 typedef SmallStruct4 (STDCALL *SmallStructDelegate4) (SmallStruct4 ss);
2138 LIBTEST_API int STDCALL
2139 mono_test_marshal_small_struct_delegate4 (SmallStructDelegate4 delegate)
2141 SmallStruct4 ss, res;
2145 res = delegate (ss);
2146 if (! (res.i == -1))
2156 typedef SmallStruct5 (STDCALL *SmallStructDelegate5) (SmallStruct5 ss);
2158 LIBTEST_API int STDCALL
2159 mono_test_marshal_small_struct_delegate5 (SmallStructDelegate5 delegate)
2161 SmallStruct5 ss, res;
2165 res = delegate (ss);
2166 if (! (res.i == -5))
2176 typedef SmallStruct6 (STDCALL *SmallStructDelegate6) (SmallStruct6 ss);
2178 LIBTEST_API int STDCALL
2179 mono_test_marshal_small_struct_delegate6 (SmallStructDelegate6 delegate)
2181 SmallStruct6 ss, res;
2186 res = delegate (ss);
2187 if (! ((res.i == -1) && (res.j == -2)))
2198 typedef SmallStruct7 (STDCALL *SmallStructDelegate7) (SmallStruct7 ss);
2200 LIBTEST_API int STDCALL
2201 mono_test_marshal_small_struct_delegate7 (SmallStructDelegate7 delegate)
2203 SmallStruct7 ss, res;
2208 res = delegate (ss);
2209 if (! ((res.i == -1) && (res.j == -2)))
2219 typedef SmallStruct8 (STDCALL *SmallStructDelegate8) (SmallStruct8 ss);
2221 LIBTEST_API int STDCALL
2222 mono_test_marshal_small_struct_delegate8 (SmallStructDelegate8 delegate)
2224 SmallStruct8 ss, res;
2228 res = delegate (ss);
2229 if (! ((res.i == -1.0)))
2239 typedef SmallStruct9 (STDCALL *SmallStructDelegate9) (SmallStruct9 ss);
2241 LIBTEST_API int STDCALL
2242 mono_test_marshal_small_struct_delegate9 (SmallStructDelegate9 delegate)
2244 SmallStruct9 ss, res;
2248 res = delegate (ss);
2249 if (! ((res.i == -1.0)))
2259 typedef SmallStruct10 (STDCALL *SmallStructDelegate10) (SmallStruct10 ss);
2261 LIBTEST_API int STDCALL
2262 mono_test_marshal_small_struct_delegate10 (SmallStructDelegate10 delegate)
2264 SmallStruct10 ss, res;
2269 res = delegate (ss);
2270 if (! ((res.i == -1.0) && (res.j == -2.0)))
2281 typedef SmallStruct11 (STDCALL *SmallStructDelegate11) (SmallStruct11 ss);
2283 LIBTEST_API int STDCALL
2284 mono_test_marshal_small_struct_delegate11 (SmallStructDelegate11 delegate)
2286 SmallStruct11 ss, res;
2291 res = delegate (ss);
2292 if (! ((res.i == -1.0) && (res.j == -2)))
2298 typedef int (STDCALL *ArrayDelegate) (int i, char *j, void *arr);
2300 LIBTEST_API int STDCALL
2301 mono_test_marshal_array_delegate (void *arr, int len, ArrayDelegate del)
2303 return del (len, NULL, arr);
2306 typedef int (STDCALL *ArrayDelegateLong) (gint64 i, char *j, void *arr);
2308 LIBTEST_API int STDCALL
2309 mono_test_marshal_array_delegate_long (void *arr, gint64 len, ArrayDelegateLong del)
2311 return del (len, NULL, arr);
2314 LIBTEST_API int STDCALL
2315 mono_test_marshal_out_array_delegate (int *arr, int len, ArrayDelegate del)
2317 del (len, NULL, arr);
2319 if ((arr [0] != 1) || (arr [1] != 2))
2325 typedef gunichar2* (STDCALL *UnicodeStringDelegate) (gunichar2 *message);
2327 LIBTEST_API int STDCALL
2328 mono_test_marshal_return_unicode_string_delegate (UnicodeStringDelegate del)
2330 const char m[] = "abcdef";
2331 gunichar2 *s2, *res;
2334 s2 = g_utf8_to_utf16 (m, -1, NULL, &len, NULL);
2343 LIBTEST_API int STDCALL
2344 mono_test_marshal_out_string_array_delegate (char **arr, int len, ArrayDelegate del)
2346 del (len, NULL, arr);
2348 if (!strcmp (arr [0], "ABC") && !strcmp (arr [1], "DEF"))
2354 typedef int (*CdeclDelegate) (int i, int j);
2356 LIBTEST_API int STDCALL
2357 mono_test_marshal_cdecl_delegate (CdeclDelegate del)
2361 for (i = 0; i < 1000; ++i)
2367 typedef char** (STDCALL *ReturnStringArrayDelegate) (int i);
2369 LIBTEST_API int STDCALL
2370 mono_test_marshal_return_string_array_delegate (ReturnStringArrayDelegate d)
2378 if (strcmp (arr [0], "ABC") || strcmp (arr [1], "DEF"))
2388 typedef int (STDCALL *ByrefStringDelegate) (char **s);
2390 LIBTEST_API int STDCALL
2391 mono_test_marshal_byref_string_delegate (ByrefStringDelegate d)
2393 char *s = (char*)"ABC";
2400 if (!strcmp (s, "DEF"))
2410 LIBTEST_API int STDCALL
2411 add_delegate (int i, int j)
2416 LIBTEST_API gpointer STDCALL
2417 mono_test_marshal_return_fnptr (void)
2419 return &add_delegate;
2422 LIBTEST_API int STDCALL
2425 printf ("codigo %x\n", code);
2433 LIBTEST_API HandleRef STDCALL
2434 mono_xr_as_handle (int code)
2438 memset (&ref, 0, sizeof (ref));
2450 LIBTEST_API int STDCALL
2451 mono_safe_handle_struct_ref (HandleStructs *x)
2453 printf ("Dingus Ref! \n");
2454 printf ("Values: %d %d %p %p\n", x->a, x->b, x->handle1, x->handle2);
2460 if (x->handle1 != (void*) 0x7080feed)
2463 if (x->handle2 != (void*) 0x1234abcd)
2469 LIBTEST_API int STDCALL
2470 mono_safe_handle_struct (HandleStructs x)
2472 printf ("Dingus Standard! \n");
2473 printf ("Values: %d %d %p %p\n", x.a, x.b, x.handle1, x.handle2);
2479 if (x.handle1 != (void*) 0x7080feed)
2482 if (x.handle2 != (void*) 0x1234abcd)
2492 LIBTEST_API int STDCALL
2493 mono_safe_handle_struct_simple (TrivialHandle x)
2495 printf ("The value is %p\n", x.a);
2496 return ((int)(gsize)x.a) * 2;
2499 LIBTEST_API int STDCALL
2500 mono_safe_handle_return (void)
2505 LIBTEST_API void STDCALL
2506 mono_safe_handle_ref (void **handle)
2509 *handle = (void *) 0xbad;
2513 *handle = (void *) 0x800d;
2516 LIBTEST_API double STDCALL
2517 mono_test_marshal_date_time (double d, double *d2)
2589 VT_USERDEFINED = 29,
2597 VT_STREAMED_OBJECT = 68,
2598 VT_STORED_OBJECT = 69,
2599 VT_BLOB_OBJECT = 70,
2607 void VariantInit(VARIANT* vt)
2624 LIBTEST_API int STDCALL
2625 mono_test_marshal_bstr_in(gunichar2* bstr)
2628 gchar* bstr_utf8 = g_utf16_to_utf8 (bstr, -1, NULL, NULL, NULL);
2629 result = strcmp("mono_test_marshal_bstr_in", bstr_utf8);
2636 LIBTEST_API int STDCALL
2637 mono_test_marshal_bstr_out(gunichar2** bstr)
2639 *bstr = marshal_bstr_alloc ("mono_test_marshal_bstr_out");
2643 LIBTEST_API int STDCALL
2644 mono_test_marshal_bstr_in_null(gunichar2* bstr)
2651 LIBTEST_API int STDCALL
2652 mono_test_marshal_bstr_out_null(gunichar2** bstr)
2658 LIBTEST_API int STDCALL
2659 mono_test_marshal_variant_in_sbyte(VARIANT variant)
2661 if (variant.vt == VT_I1 && variant.cVal == 100)
2666 LIBTEST_API int STDCALL
2667 mono_test_marshal_variant_in_byte(VARIANT variant)
2669 if (variant.vt == VT_UI1 && variant.bVal == 100)
2674 LIBTEST_API int STDCALL
2675 mono_test_marshal_variant_in_short(VARIANT variant)
2677 if (variant.vt == VT_I2 && variant.iVal == 314)
2682 LIBTEST_API int STDCALL
2683 mono_test_marshal_variant_in_ushort(VARIANT variant)
2685 if (variant.vt == VT_UI2 && variant.uiVal == 314)
2690 LIBTEST_API int STDCALL
2691 mono_test_marshal_variant_in_int(VARIANT variant)
2693 if (variant.vt == VT_I4 && variant.lVal == 314)
2698 LIBTEST_API int STDCALL
2699 mono_test_marshal_variant_in_uint(VARIANT variant)
2701 if (variant.vt == VT_UI4 && variant.ulVal == 314)
2706 LIBTEST_API int STDCALL
2707 mono_test_marshal_variant_in_long(VARIANT variant)
2709 if (variant.vt == VT_I8 && variant.llVal == 314)
2714 LIBTEST_API int STDCALL
2715 mono_test_marshal_variant_in_ulong(VARIANT variant)
2717 if (variant.vt == VT_UI8 && variant.ullVal == 314)
2722 LIBTEST_API int STDCALL
2723 mono_test_marshal_variant_in_float(VARIANT variant)
2725 if (variant.vt == VT_R4 && (variant.fltVal - 3.14)/3.14 < .001)
2730 LIBTEST_API int STDCALL
2731 mono_test_marshal_variant_in_double(VARIANT variant)
2733 if (variant.vt == VT_R8 && (variant.dblVal - 3.14)/3.14 < .001)
2738 LIBTEST_API int STDCALL
2739 mono_test_marshal_variant_in_bstr(VARIANT variant)
2742 gchar* bstr_utf8 = g_utf16_to_utf8 (variant.bstrVal, -1, NULL, NULL, NULL);
2743 result = strcmp("PI", bstr_utf8);
2746 if (variant.vt == VT_BSTR && !result)
2751 LIBTEST_API int STDCALL
2752 mono_test_marshal_variant_in_bool_true (VARIANT variant)
2754 if (variant.vt == VT_BOOL && variant.boolVal == VARIANT_TRUE)
2759 LIBTEST_API int STDCALL
2760 mono_test_marshal_variant_in_bool_false (VARIANT variant)
2762 if (variant.vt == VT_BOOL && variant.boolVal == VARIANT_FALSE)
2767 LIBTEST_API int STDCALL
2768 mono_test_marshal_variant_out_sbyte(VARIANT* variant)
2770 variant->vt = VT_I1;
2771 variant->cVal = 100;
2776 LIBTEST_API int STDCALL
2777 mono_test_marshal_variant_out_sbyte_byref(VARIANT* variant)
2779 variant->vt = VT_I1|VT_BYREF;
2780 variant->byref = marshal_alloc(1);
2781 *((gint8*)variant->byref) = 100;
2786 LIBTEST_API int STDCALL
2787 mono_test_marshal_variant_out_byte(VARIANT* variant)
2789 variant->vt = VT_UI1;
2790 variant->bVal = 100;
2795 LIBTEST_API int STDCALL
2796 mono_test_marshal_variant_out_byte_byref(VARIANT* variant)
2798 variant->vt = VT_UI1|VT_BYREF;
2799 variant->byref = marshal_alloc(1);
2800 *((gint8*)variant->byref) = 100;
2805 LIBTEST_API int STDCALL
2806 mono_test_marshal_variant_out_short(VARIANT* variant)
2808 variant->vt = VT_I2;
2809 variant->iVal = 314;
2814 LIBTEST_API int STDCALL
2815 mono_test_marshal_variant_out_short_byref(VARIANT* variant)
2817 variant->vt = VT_I2|VT_BYREF;
2818 variant->byref = marshal_alloc(2);
2819 *((gint16*)variant->byref) = 314;
2824 LIBTEST_API int STDCALL
2825 mono_test_marshal_variant_out_ushort(VARIANT* variant)
2827 variant->vt = VT_UI2;
2828 variant->uiVal = 314;
2833 LIBTEST_API int STDCALL
2834 mono_test_marshal_variant_out_ushort_byref(VARIANT* variant)
2836 variant->vt = VT_UI2|VT_BYREF;
2837 variant->byref = marshal_alloc(2);
2838 *((guint16*)variant->byref) = 314;
2843 LIBTEST_API int STDCALL
2844 mono_test_marshal_variant_out_int(VARIANT* variant)
2846 variant->vt = VT_I4;
2847 variant->lVal = 314;
2852 LIBTEST_API int STDCALL
2853 mono_test_marshal_variant_out_int_byref(VARIANT* variant)
2855 variant->vt = VT_I4|VT_BYREF;
2856 variant->byref = marshal_alloc(4);
2857 *((gint32*)variant->byref) = 314;
2862 LIBTEST_API int STDCALL
2863 mono_test_marshal_variant_out_uint(VARIANT* variant)
2865 variant->vt = VT_UI4;
2866 variant->ulVal = 314;
2871 LIBTEST_API int STDCALL
2872 mono_test_marshal_variant_out_uint_byref(VARIANT* variant)
2874 variant->vt = VT_UI4|VT_BYREF;
2875 variant->byref = marshal_alloc(4);
2876 *((guint32*)variant->byref) = 314;
2881 LIBTEST_API int STDCALL
2882 mono_test_marshal_variant_out_long(VARIANT* variant)
2884 variant->vt = VT_I8;
2885 variant->llVal = 314;
2890 LIBTEST_API int STDCALL
2891 mono_test_marshal_variant_out_long_byref(VARIANT* variant)
2893 variant->vt = VT_I8|VT_BYREF;
2894 variant->byref = marshal_alloc(8);
2895 *((gint64*)variant->byref) = 314;
2900 LIBTEST_API int STDCALL
2901 mono_test_marshal_variant_out_ulong(VARIANT* variant)
2903 variant->vt = VT_UI8;
2904 variant->ullVal = 314;
2909 LIBTEST_API int STDCALL
2910 mono_test_marshal_variant_out_ulong_byref(VARIANT* variant)
2912 variant->vt = VT_UI8|VT_BYREF;
2913 variant->byref = marshal_alloc(8);
2914 *((guint64*)variant->byref) = 314;
2919 LIBTEST_API int STDCALL
2920 mono_test_marshal_variant_out_float(VARIANT* variant)
2922 variant->vt = VT_R4;
2923 variant->fltVal = 3.14;
2928 LIBTEST_API int STDCALL
2929 mono_test_marshal_variant_out_float_byref(VARIANT* variant)
2931 variant->vt = VT_R4|VT_BYREF;
2932 variant->byref = marshal_alloc(4);
2933 *((float*)variant->byref) = 3.14;
2938 LIBTEST_API int STDCALL
2939 mono_test_marshal_variant_out_double(VARIANT* variant)
2941 variant->vt = VT_R8;
2942 variant->dblVal = 3.14;
2947 LIBTEST_API int STDCALL
2948 mono_test_marshal_variant_out_double_byref(VARIANT* variant)
2950 variant->vt = VT_R8|VT_BYREF;
2951 variant->byref = marshal_alloc(8);
2952 *((double*)variant->byref) = 3.14;
2957 LIBTEST_API int STDCALL
2958 mono_test_marshal_variant_out_bstr(VARIANT* variant)
2960 variant->vt = VT_BSTR;
2961 variant->bstrVal = marshal_bstr_alloc("PI");
2966 LIBTEST_API int STDCALL
2967 mono_test_marshal_variant_out_bstr_byref(VARIANT* variant)
2969 variant->vt = VT_BSTR|VT_BYREF;
2970 variant->byref = marshal_alloc(sizeof(gpointer));
2971 *((gunichar**)variant->byref) = (gunichar*)marshal_bstr_alloc("PI");
2976 LIBTEST_API int STDCALL
2977 mono_test_marshal_variant_out_bool_true (VARIANT* variant)
2979 variant->vt = VT_BOOL;
2980 variant->boolVal = VARIANT_TRUE;
2985 LIBTEST_API int STDCALL
2986 mono_test_marshal_variant_out_bool_true_byref (VARIANT* variant)
2988 variant->vt = VT_BOOL|VT_BYREF;
2989 variant->byref = marshal_alloc(2);
2990 *((gint16*)variant->byref) = VARIANT_TRUE;
2995 LIBTEST_API int STDCALL
2996 mono_test_marshal_variant_out_bool_false (VARIANT* variant)
2998 variant->vt = VT_BOOL;
2999 variant->boolVal = VARIANT_FALSE;
3004 LIBTEST_API int STDCALL
3005 mono_test_marshal_variant_out_bool_false_byref (VARIANT* variant)
3007 variant->vt = VT_BOOL|VT_BYREF;
3008 variant->byref = marshal_alloc(2);
3009 *((gint16*)variant->byref) = VARIANT_FALSE;
3014 typedef int (STDCALL *VarFunc) (int vt, VARIANT variant);
3015 typedef int (STDCALL *VarRefFunc) (int vt, VARIANT* variant);
3017 LIBTEST_API int STDCALL
3018 mono_test_marshal_variant_in_sbyte_unmanaged(VarFunc func)
3023 return func (VT_I1, vt);
3026 LIBTEST_API int STDCALL
3027 mono_test_marshal_variant_in_byte_unmanaged(VarFunc func)
3032 return func (VT_UI1, vt);
3035 LIBTEST_API int STDCALL
3036 mono_test_marshal_variant_in_short_unmanaged(VarFunc func)
3041 return func (VT_I2, vt);
3044 LIBTEST_API int STDCALL
3045 mono_test_marshal_variant_in_ushort_unmanaged(VarFunc func)
3050 return func (VT_UI2, vt);
3053 LIBTEST_API int STDCALL
3054 mono_test_marshal_variant_in_int_unmanaged(VarFunc func)
3059 return func (VT_I4, vt);
3062 LIBTEST_API int STDCALL
3063 mono_test_marshal_variant_in_uint_unmanaged(VarFunc func)
3068 return func (VT_UI4, vt);
3071 LIBTEST_API int STDCALL
3072 mono_test_marshal_variant_in_long_unmanaged(VarFunc func)
3077 return func (VT_I8, vt);
3080 LIBTEST_API int STDCALL
3081 mono_test_marshal_variant_in_ulong_unmanaged(VarFunc func)
3086 return func (VT_UI8, vt);
3089 LIBTEST_API int STDCALL
3090 mono_test_marshal_variant_in_float_unmanaged(VarFunc func)
3095 return func (VT_R4, vt);
3098 LIBTEST_API int STDCALL
3099 mono_test_marshal_variant_in_double_unmanaged(VarFunc func)
3104 return func (VT_R8, vt);
3107 LIBTEST_API int STDCALL
3108 mono_test_marshal_variant_in_bstr_unmanaged(VarFunc func)
3112 vt.bstrVal = marshal_bstr_alloc("PI");
3113 return func (VT_BSTR, vt);
3116 LIBTEST_API int STDCALL
3117 mono_test_marshal_variant_in_bool_true_unmanaged(VarFunc func)
3121 vt.boolVal = VARIANT_TRUE;
3122 return func (VT_BOOL, vt);
3125 LIBTEST_API int STDCALL
3126 mono_test_marshal_variant_in_bool_false_unmanaged(VarFunc func)
3130 vt.boolVal = VARIANT_FALSE;
3131 return func (VT_BOOL, vt);
3134 LIBTEST_API int STDCALL
3135 mono_test_marshal_variant_out_sbyte_unmanaged(VarRefFunc func)
3140 if (vt.vt == VT_I1 && vt.cVal == -100)
3145 LIBTEST_API int STDCALL
3146 mono_test_marshal_variant_out_byte_unmanaged(VarRefFunc func)
3151 if (vt.vt == VT_UI1 && vt.bVal == 100)
3156 LIBTEST_API int STDCALL
3157 mono_test_marshal_variant_out_short_unmanaged(VarRefFunc func)
3162 if (vt.vt == VT_I2 && vt.iVal == -100)
3167 LIBTEST_API int STDCALL
3168 mono_test_marshal_variant_out_ushort_unmanaged(VarRefFunc func)
3173 if (vt.vt == VT_UI2 && vt.uiVal == 100)
3178 LIBTEST_API int STDCALL
3179 mono_test_marshal_variant_out_int_unmanaged(VarRefFunc func)
3184 if (vt.vt == VT_I4 && vt.lVal == -100)
3189 LIBTEST_API int STDCALL
3190 mono_test_marshal_variant_out_uint_unmanaged(VarRefFunc func)
3195 if (vt.vt == VT_UI4 && vt.ulVal == 100)
3200 LIBTEST_API int STDCALL
3201 mono_test_marshal_variant_out_long_unmanaged(VarRefFunc func)
3206 if (vt.vt == VT_I8 && vt.llVal == -100)
3211 LIBTEST_API int STDCALL
3212 mono_test_marshal_variant_out_ulong_unmanaged(VarRefFunc func)
3217 if (vt.vt == VT_UI8 && vt.ullVal == 100)
3222 LIBTEST_API int STDCALL
3223 mono_test_marshal_variant_out_float_unmanaged(VarRefFunc func)
3228 if (vt.vt == VT_R4 && fabs (vt.fltVal - 3.14f) < 1e-10)
3233 LIBTEST_API int STDCALL
3234 mono_test_marshal_variant_out_double_unmanaged(VarRefFunc func)
3239 if (vt.vt == VT_R8 && fabs (vt.dblVal - 3.14) < 1e-10)
3244 LIBTEST_API int STDCALL
3245 mono_test_marshal_variant_out_bstr_unmanaged(VarRefFunc func)
3253 func (VT_BSTR, &vt);
3254 bstr_utf8 = g_utf16_to_utf8 (vt.bstrVal, -1, NULL, NULL, NULL);
3255 result = strcmp("PI", bstr_utf8);
3257 if (vt.vt == VT_BSTR && !result)
3262 LIBTEST_API int STDCALL
3263 mono_test_marshal_variant_out_bool_true_unmanaged(VarRefFunc func)
3267 func (VT_BOOL, &vt);
3268 if (vt.vt == VT_BOOL && vt.boolVal == VARIANT_TRUE)
3273 LIBTEST_API int STDCALL
3274 mono_test_marshal_variant_out_bool_false_unmanaged(VarRefFunc func)
3278 func (VT_BOOL, &vt);
3279 if (vt.vt == VT_BOOL && vt.boolVal == VARIANT_TRUE)
3284 typedef struct MonoComObject MonoComObject;
3288 int (STDCALL *QueryInterface)(MonoComObject* pUnk, gpointer riid, gpointer* ppv);
3289 int (STDCALL *AddRef)(MonoComObject* pUnk);
3290 int (STDCALL *Release)(MonoComObject* pUnk);
3291 int (STDCALL *get_ITest)(MonoComObject* pUnk, MonoComObject* *ppUnk);
3292 int (STDCALL *SByteIn)(MonoComObject* pUnk, char a);
3293 int (STDCALL *ByteIn)(MonoComObject* pUnk, unsigned char a);
3294 int (STDCALL *ShortIn)(MonoComObject* pUnk, short a);
3295 int (STDCALL *UShortIn)(MonoComObject* pUnk, unsigned short a);
3296 int (STDCALL *IntIn)(MonoComObject* pUnk, int a);
3297 int (STDCALL *UIntIn)(MonoComObject* pUnk, unsigned int a);
3298 int (STDCALL *LongIn)(MonoComObject* pUnk, gint64 a);
3299 int (STDCALL *ULongIn)(MonoComObject* pUnk, guint64 a);
3300 int (STDCALL *FloatIn)(MonoComObject* pUnk, float a);
3301 int (STDCALL *DoubleIn)(MonoComObject* pUnk, double a);
3302 int (STDCALL *ITestIn)(MonoComObject* pUnk, MonoComObject* pUnk2);
3303 int (STDCALL *ITestOut)(MonoComObject* pUnk, MonoComObject* *ppUnk);
3306 struct MonoComObject
3312 static GUID IID_ITest = {0, 0, 0, {0,0,0,0,0,0,0,1}};
3313 static GUID IID_IMonoUnknown = {0, 0, 0, {0xc0,0,0,0,0,0,0,0x46}};
3314 static GUID IID_IMonoDispatch = {0x00020400, 0, 0, {0xc0,0,0,0,0,0,0,0x46}};
3316 LIBTEST_API int STDCALL
3317 MonoQueryInterface(MonoComObject* pUnk, gpointer riid, gpointer* ppv)
3321 if (!memcmp(riid, &IID_IMonoUnknown, sizeof(GUID))) {
3325 else if (!memcmp(riid, &IID_ITest, sizeof(GUID))) {
3329 else if (!memcmp(riid, &IID_IMonoDispatch, sizeof(GUID))) {
3333 return 0x80004002; //E_NOINTERFACE;
3336 LIBTEST_API int STDCALL
3337 MonoAddRef(MonoComObject* pUnk)
3339 return ++(pUnk->m_ref);
3342 LIBTEST_API int STDCALL
3343 MonoRelease(MonoComObject* pUnk)
3345 return --(pUnk->m_ref);
3348 LIBTEST_API int STDCALL
3349 SByteIn(MonoComObject* pUnk, char a)
3354 LIBTEST_API int STDCALL
3355 ByteIn(MonoComObject* pUnk, unsigned char a)
3360 LIBTEST_API int STDCALL
3361 ShortIn(MonoComObject* pUnk, short a)
3366 LIBTEST_API int STDCALL
3367 UShortIn(MonoComObject* pUnk, unsigned short a)
3372 LIBTEST_API int STDCALL
3373 IntIn(MonoComObject* pUnk, int a)
3378 LIBTEST_API int STDCALL
3379 UIntIn(MonoComObject* pUnk, unsigned int a)
3384 LIBTEST_API int STDCALL
3385 LongIn(MonoComObject* pUnk, gint64 a)
3390 LIBTEST_API int STDCALL
3391 ULongIn(MonoComObject* pUnk, guint64 a)
3396 LIBTEST_API int STDCALL
3397 FloatIn(MonoComObject* pUnk, float a)
3402 LIBTEST_API int STDCALL
3403 DoubleIn(MonoComObject* pUnk, double a)
3408 LIBTEST_API int STDCALL
3409 ITestIn(MonoComObject* pUnk, MonoComObject *pUnk2)
3414 LIBTEST_API int STDCALL
3415 ITestOut(MonoComObject* pUnk, MonoComObject* *ppUnk)
3420 static void create_com_object (MonoComObject** pOut);
3422 LIBTEST_API int STDCALL
3423 get_ITest(MonoComObject* pUnk, MonoComObject* *ppUnk)
3425 create_com_object (ppUnk);
3429 static void create_com_object (MonoComObject** pOut)
3431 *pOut = marshal_new0 (MonoComObject, 1);
3432 (*pOut)->vtbl = marshal_new0 (MonoIUnknown, 1);
3435 (*pOut)->vtbl->QueryInterface = MonoQueryInterface;
3436 (*pOut)->vtbl->AddRef = MonoAddRef;
3437 (*pOut)->vtbl->Release = MonoRelease;
3438 (*pOut)->vtbl->SByteIn = SByteIn;
3439 (*pOut)->vtbl->ByteIn = ByteIn;
3440 (*pOut)->vtbl->ShortIn = ShortIn;
3441 (*pOut)->vtbl->UShortIn = UShortIn;
3442 (*pOut)->vtbl->IntIn = IntIn;
3443 (*pOut)->vtbl->UIntIn = UIntIn;
3444 (*pOut)->vtbl->LongIn = LongIn;
3445 (*pOut)->vtbl->ULongIn = ULongIn;
3446 (*pOut)->vtbl->FloatIn = FloatIn;
3447 (*pOut)->vtbl->DoubleIn = DoubleIn;
3448 (*pOut)->vtbl->ITestIn = ITestIn;
3449 (*pOut)->vtbl->ITestOut = ITestOut;
3450 (*pOut)->vtbl->get_ITest = get_ITest;
3453 static MonoComObject* same_object = NULL;
3455 LIBTEST_API int STDCALL
3456 mono_test_marshal_com_object_create(MonoComObject* *pUnk)
3458 create_com_object (pUnk);
3461 same_object = *pUnk;
3466 LIBTEST_API int STDCALL
3467 mono_test_marshal_com_object_same(MonoComObject* *pUnk)
3469 *pUnk = same_object;
3474 LIBTEST_API int STDCALL
3475 mono_test_marshal_com_object_destroy(MonoComObject *pUnk)
3477 int ref = --(pUnk->m_ref);
3484 LIBTEST_API int STDCALL
3485 mono_test_marshal_com_object_ref_count(MonoComObject *pUnk)
3490 LIBTEST_API int STDCALL
3491 mono_test_marshal_ccw_itest (MonoComObject *pUnk)
3494 MonoComObject* pTest;
3499 hr = pUnk->vtbl->SByteIn (pUnk, -100);
3502 hr = pUnk->vtbl->ByteIn (pUnk, 100);
3505 hr = pUnk->vtbl->ShortIn (pUnk, -100);
3508 hr = pUnk->vtbl->UShortIn (pUnk, 100);
3511 hr = pUnk->vtbl->IntIn (pUnk, -100);
3514 hr = pUnk->vtbl->UIntIn (pUnk, 100);
3517 hr = pUnk->vtbl->LongIn (pUnk, -100);
3520 hr = pUnk->vtbl->ULongIn (pUnk, 100);
3523 hr = pUnk->vtbl->FloatIn (pUnk, 3.14f);
3526 hr = pUnk->vtbl->DoubleIn (pUnk, 3.14);
3529 hr = pUnk->vtbl->ITestIn (pUnk, pUnk);
3532 hr = pUnk->vtbl->ITestOut (pUnk, &pTest);
3540 * mono_method_get_unmanaged_thunk tests
3543 #if defined(__GNUC__) && ((defined(__i386__) && (defined(__linux__) || defined (__APPLE__)) || defined (__FreeBSD__) || defined(__OpenBSD__)) || (defined(__ppc__) && defined(__APPLE__)))
3544 #define ALIGN(size) __attribute__ ((aligned(size)))
3550 /* thunks.cs:TestStruct */
3551 typedef struct _TestStruct {
3556 /* Searches for mono symbols in all loaded modules */
3558 lookup_mono_symbol (const char *symbol_name)
3561 if (g_module_symbol (g_module_open (NULL, G_MODULE_BIND_LAZY), symbol_name, &symbol))
3567 LIBTEST_API gpointer STDCALL
3568 mono_test_marshal_lookup_symbol (const char *symbol_name)
3570 return lookup_mono_symbol (symbol_name);
3573 #define MONO_BEGIN_EFRAME { void *__dummy; void *__region_cookie = mono_threads_enter_gc_unsafe_region ? mono_threads_enter_gc_unsafe_region (&__dummy) : NULL;
3574 #define MONO_END_EFRAME if (mono_threads_exit_gc_unsafe_region) mono_threads_exit_gc_unsafe_region (__region_cookie, &__dummy); }
3577 * test_method_thunk:
3579 * @test_id: the test number
3580 * @test_method_handle: MonoMethod* of the C# test method
3581 * @create_object_method_handle: MonoMethod* of thunks.cs:Test.CreateObject
3583 LIBTEST_API int STDCALL
3584 test_method_thunk (int test_id, gpointer test_method_handle, gpointer create_object_method_handle)
3588 gpointer (*mono_method_get_unmanaged_thunk)(gpointer)
3589 = lookup_mono_symbol ("mono_method_get_unmanaged_thunk");
3591 gpointer (*mono_string_new_wrapper)(const char *)
3592 = lookup_mono_symbol ("mono_string_new_wrapper");
3594 char* (*mono_string_to_utf8)(gpointer)
3595 = lookup_mono_symbol ("mono_string_to_utf8");
3597 gpointer (*mono_object_unbox)(gpointer)
3598 = lookup_mono_symbol ("mono_object_unbox");
3600 gpointer (*mono_threads_enter_gc_unsafe_region) (gpointer)
3601 = lookup_mono_symbol ("mono_threads_enter_gc_unsafe_region");
3603 void (*mono_threads_exit_gc_unsafe_region) (gpointer, gpointer)
3604 = lookup_mono_symbol ("mono_threads_exit_gc_unsafe_region");
3608 gpointer test_method, ex = NULL;
3609 gpointer (STDCALL *CreateObject)(gpointer*);
3613 if (!mono_method_get_unmanaged_thunk) {
3618 test_method = mono_method_get_unmanaged_thunk (test_method_handle);
3624 CreateObject = mono_method_get_unmanaged_thunk (create_object_method_handle);
3625 if (!CreateObject) {
3634 /* thunks.cs:Test.Test0 */
3635 void (STDCALL *F)(gpointer*) = test_method;
3641 /* thunks.cs:Test.Test1 */
3642 int (STDCALL *F)(gpointer*) = test_method;
3643 if (F (&ex) != 42) {
3651 /* thunks.cs:Test.Test2 */
3652 gpointer (STDCALL *F)(gpointer, gpointer*) = test_method;
3653 gpointer str = mono_string_new_wrapper ("foo");
3654 if (str != F (str, &ex)) {
3662 /* thunks.cs:Test.Test3 */
3663 gpointer (STDCALL *F)(gpointer, gpointer, gpointer*);
3668 obj = CreateObject (&ex);
3669 str = mono_string_new_wrapper ("bar");
3671 if (str != F (obj, str, &ex)) {
3679 /* thunks.cs:Test.Test4 */
3680 int (STDCALL *F)(gpointer, gpointer, int, gpointer*);
3685 obj = CreateObject (&ex);
3686 str = mono_string_new_wrapper ("bar");
3688 if (42 != F (obj, str, 42, &ex)) {
3697 /* thunks.cs:Test.Test5 */
3698 int (STDCALL *F)(gpointer, gpointer, int, gpointer*);
3703 obj = CreateObject (&ex);
3704 str = mono_string_new_wrapper ("bar");
3706 F (obj, str, 42, &ex);
3716 /* thunks.cs:Test.Test6 */
3717 int (STDCALL *F)(gpointer, guint8, gint16, gint32, gint64, float, double,
3718 gpointer, gpointer*);
3720 gpointer str = mono_string_new_wrapper ("Test6");
3724 obj = CreateObject (&ex);
3726 res = F (obj, 254, 32700, -245378, 6789600, 3.1415, 3.1415, str, &ex);
3741 /* thunks.cs:Test.Test7 */
3742 gint64 (STDCALL *F)(gpointer*) = test_method;
3743 if (F (&ex) != G_MAXINT64) {
3751 /* thunks.cs:Test.Test8 */
3752 void (STDCALL *F)(guint8*, gint16*, gint32*, gint64*, float*, double*,
3753 gpointer*, gpointer*);
3765 F (&a1, &a2, &a3, &a4, &a5, &a6, &a7, &ex);
3775 (fabs (a5 - 3.1415) < 0.001) &&
3776 (fabs (a6 - 3.1415) < 0.001) &&
3777 strcmp (mono_string_to_utf8 (a7), "Test8") == 0)){
3786 /* thunks.cs:Test.Test9 */
3787 void (STDCALL *F)(guint8*, gint16*, gint32*, gint64*, float*, double*,
3788 gpointer*, gpointer*);
3800 F (&a1, &a2, &a3, &a4, &a5, &a6, &a7, &ex);
3810 /* thunks.cs:Test.Test10 */
3811 void (STDCALL *F)(gpointer*, gpointer*);
3813 gpointer obj1, obj2;
3815 obj1 = obj2 = CreateObject (&ex);
3838 /* thunks.cs:TestStruct.Test0 */
3839 int (STDCALL *F)(gpointer*, gpointer*);
3845 obj = CreateObject (&ex);
3856 a1 = mono_object_unbox (obj);
3878 /* check whether the call was really by value */
3879 if (a1->A != 42 || a1->B != 3.1415) {
3888 /* thunks.cs:TestStruct.Test1 */
3889 void (STDCALL *F)(gpointer, gpointer*);
3894 obj = CreateObject (&ex);
3905 a1 = mono_object_unbox (obj);
3924 if (!(fabs (a1->B - 3.1415) < 0.001)) {
3933 /* thunks.cs:TestStruct.Test2 */
3934 gpointer (STDCALL *F)(gpointer*);
3952 a1 = mono_object_unbox (obj);
3959 if (!(fabs (a1->B - 3.1415) < 0.001)) {
3968 /* thunks.cs:TestStruct.Test3 */
3969 void (STDCALL *F)(gpointer, gpointer*);
3974 obj = CreateObject (&ex);
3985 a1 = mono_object_unbox (obj);
4031 LIBTEST_API int STDCALL
4032 mono_test_Winx64_struct1_in (winx64_struct1 var)
4045 LIBTEST_API int STDCALL
4046 mono_test_Winx64_struct2_in (winx64_struct2 var)
4063 LIBTEST_API int STDCALL
4064 mono_test_Winx64_struct3_in (winx64_struct3 var)
4070 if (var.c != 0x1234)
4083 LIBTEST_API int STDCALL
4084 mono_test_Winx64_struct4_in (winx64_struct4 var)
4090 if (var.c != 0x1234)
4092 if (var.d != 0x87654321)
4104 LIBTEST_API int STDCALL
4105 mono_test_Winx64_struct5_in (winx64_struct5 var)
4123 LIBTEST_API int STDCALL
4124 mono_test_Winx64_struct6_in (winx64_struct6 var)
4135 LIBTEST_API int STDCALL
4136 mono_test_Winx64_structs_in1 (winx64_struct1 var1,
4137 winx64_struct2 var2,
4138 winx64_struct3 var3,
4139 winx64_struct4 var4)
4153 if (var3.c != 0x1234)
4160 if (var4.c != 0x1234)
4162 if (var4.d != 0x87654321)
4167 LIBTEST_API int STDCALL
4168 mono_test_Winx64_structs_in2 (winx64_struct1 var1,
4169 winx64_struct1 var2,
4170 winx64_struct1 var3,
4171 winx64_struct1 var4,
4172 winx64_struct1 var5)
4188 LIBTEST_API int STDCALL
4189 mono_test_Winx64_structs_in3 (winx64_struct1 var1,
4190 winx64_struct5 var2,
4191 winx64_struct1 var3,
4192 winx64_struct5 var4,
4193 winx64_struct1 var5,
4194 winx64_struct5 var6)
4229 LIBTEST_API winx64_struct1 STDCALL
4230 mono_test_Winx64_struct1_ret (void)
4237 LIBTEST_API winx64_struct2 STDCALL
4238 mono_test_Winx64_struct2_ret (void)
4246 LIBTEST_API winx64_struct3 STDCALL
4247 mono_test_Winx64_struct3_ret (void)
4256 LIBTEST_API winx64_struct4 STDCALL
4257 mono_test_Winx64_struct4_ret (void)
4267 LIBTEST_API winx64_struct5 STDCALL
4268 mono_test_Winx64_struct5_ret (void)
4277 LIBTEST_API winx64_struct1 STDCALL
4278 mono_test_Winx64_struct1_ret_5_args (char a, char b, char c, char d, char e)
4281 ret.a = a + b + c + d + e;
4285 LIBTEST_API winx64_struct5 STDCALL
4286 mono_test_Winx64_struct5_ret6_args (char a, char b, char c, char d, char e)
4299 } winx64_floatStruct;
4301 LIBTEST_API int STDCALL
4302 mono_test_Winx64_floatStruct (winx64_floatStruct a)
4304 if (a.a > 5.6 || a.a < 5.4)
4307 if (a.b > 9.6 || a.b < 9.4)
4316 } winx64_doubleStruct;
4318 LIBTEST_API int STDCALL
4319 mono_test_Winx64_doubleStruct (winx64_doubleStruct a)
4321 if (a.a > 5.6 || a.a < 5.4)
4327 typedef int (STDCALL *managed_struct1_delegate) (winx64_struct1 a);
4329 LIBTEST_API int STDCALL
4330 mono_test_managed_Winx64_struct1_in(managed_struct1_delegate func)
4337 typedef int (STDCALL *managed_struct5_delegate) (winx64_struct5 a);
4339 LIBTEST_API int STDCALL
4340 mono_test_managed_Winx64_struct5_in(managed_struct5_delegate func)
4349 typedef int (STDCALL *managed_struct1_struct5_delegate) (winx64_struct1 a, winx64_struct5 b,
4350 winx64_struct1 c, winx64_struct5 d,
4351 winx64_struct1 e, winx64_struct5 f);
4353 LIBTEST_API int STDCALL
4354 mono_test_managed_Winx64_struct1_struct5_in(managed_struct1_struct5_delegate func)
4356 winx64_struct1 a, c, e;
4357 winx64_struct5 b, d, f;
4359 b.a = 2; b.b = 3; b.c = 4;
4361 d.a = 6; d.b = 7; d.c = 8;
4363 f.a = 10; f.b = 11; f.c = 12;
4365 return func (a, b, c, d, e, f);
4368 typedef winx64_struct1 (STDCALL *managed_struct1_ret_delegate) (void);
4370 LIBTEST_API int STDCALL
4371 mono_test_Winx64_struct1_ret_managed (managed_struct1_ret_delegate func)
4383 typedef winx64_struct5 (STDCALL *managed_struct5_ret_delegate) (void);
4385 LIBTEST_API int STDCALL
4386 mono_test_Winx64_struct5_ret_managed (managed_struct5_ret_delegate func)
4402 LIBTEST_API int STDCALL
4403 mono_test_marshal_bool_in (int arg, unsigned int expected, unsigned int bDefaultMarsh, unsigned int bBoolCustMarsh,
4404 char bI1CustMarsh, unsigned char bU1CustMarsh, short bVBCustMarsh)
4408 if (bDefaultMarsh != expected)
4412 if (bBoolCustMarsh != expected)
4416 if (bI1CustMarsh != expected)
4420 if (bU1CustMarsh != expected)
4424 if (bVBCustMarsh != expected)
4433 LIBTEST_API int STDCALL
4434 mono_test_marshal_bool_out (int arg, unsigned int testVal, unsigned int* bDefaultMarsh, unsigned int* bBoolCustMarsh,
4435 char* bI1CustMarsh, unsigned char* bU1CustMarsh, unsigned short* bVBCustMarsh)
4441 *bDefaultMarsh = testVal;
4444 if (!bBoolCustMarsh)
4446 *bBoolCustMarsh = testVal;
4451 *bI1CustMarsh = (char)testVal;
4456 *bU1CustMarsh = (unsigned char)testVal;
4461 *bVBCustMarsh = (unsigned short)testVal;
4469 LIBTEST_API int STDCALL
4470 mono_test_marshal_bool_ref (int arg, unsigned int expected, unsigned int testVal, unsigned int* bDefaultMarsh,
4471 unsigned int* bBoolCustMarsh, char* bI1CustMarsh, unsigned char* bU1CustMarsh,
4472 unsigned short* bVBCustMarsh)
4478 if (*bDefaultMarsh != expected)
4480 *bDefaultMarsh = testVal;
4483 if (!bBoolCustMarsh)
4485 if (*bBoolCustMarsh != expected)
4487 *bBoolCustMarsh = testVal;
4492 if (*bI1CustMarsh != expected)
4494 *bI1CustMarsh = (char)testVal;
4499 if (*bU1CustMarsh != expected)
4501 *bU1CustMarsh = (unsigned char)testVal;
4506 if (*bVBCustMarsh != expected)
4508 *bVBCustMarsh = (unsigned short)testVal;
4517 typedef int (STDCALL *MarshalBoolInDelegate) (int arg, unsigned int expected, unsigned int bDefaultMarsh,
4518 unsigned int bBoolCustMarsh, char bI1CustMarsh, unsigned char bU1CustMarsh, unsigned short bVBCustMarsh);
4520 LIBTEST_API int STDCALL
4521 mono_test_managed_marshal_bool_in (int arg, unsigned int expected, unsigned int testVal, MarshalBoolInDelegate pfcn)
4528 return pfcn (arg, expected, testVal, 0, 0, 0, 0);
4530 return pfcn (arg, expected, 0, testVal, 0, 0, 0);
4532 return pfcn (arg, expected, 0, 0, testVal, 0, 0);
4534 return pfcn (arg, expected, 0, 0, 0, testVal, 0);
4536 return pfcn (arg, expected, 0, 0, 0, 0, testVal);
4544 typedef int (STDCALL *MarshalBoolOutDelegate) (int arg, unsigned int expected, unsigned int* bDefaultMarsh,
4545 unsigned int* bBoolCustMarsh, char* bI1CustMarsh, unsigned char* bU1CustMarsh, unsigned short* bVBCustMarsh);
4547 LIBTEST_API int STDCALL
4548 mono_test_managed_marshal_bool_out (int arg, unsigned int expected, unsigned int testVal, MarshalBoolOutDelegate pfcn)
4551 unsigned int lDefaultMarsh, lBoolCustMarsh;
4552 char lI1CustMarsh = 0;
4553 unsigned char lU1CustMarsh = 0;
4554 unsigned short lVBCustMarsh = 0;
4555 lDefaultMarsh = lBoolCustMarsh = 0;
4562 unsigned int ltVal = 0;
4563 ret = pfcn (arg, testVal, <Val, &lBoolCustMarsh, &lI1CustMarsh, &lU1CustMarsh, &lVBCustMarsh);
4565 return 0x0100 + ret;
4566 if (expected != ltVal)
4571 unsigned int ltVal = 0;
4572 ret = pfcn (arg, testVal, &lDefaultMarsh, <Val, &lI1CustMarsh, &lU1CustMarsh, &lVBCustMarsh);
4574 return 0x0300 + ret;
4575 if (expected != ltVal)
4581 ret = pfcn (arg, testVal, &lDefaultMarsh, &lBoolCustMarsh, <Val, &lU1CustMarsh, &lVBCustMarsh);
4583 return 0x0500 + ret;
4584 if (expected != ltVal)
4589 unsigned char ltVal = 0;
4590 ret = pfcn (arg, testVal, &lDefaultMarsh, &lBoolCustMarsh, &lI1CustMarsh, <Val, &lVBCustMarsh);
4592 return 0x0700 + ret;
4593 if (expected != ltVal)
4598 unsigned short ltVal = 0;
4599 ret = pfcn (arg, testVal, &lDefaultMarsh, &lBoolCustMarsh, &lI1CustMarsh, &lU1CustMarsh, <Val);
4601 return 0x0900 + ret;
4602 if (expected != ltVal)
4613 typedef int (STDCALL *MarshalBoolRefDelegate) (int arg, unsigned int expected, unsigned int testVal, unsigned int* bDefaultMarsh,
4614 unsigned int* bBoolCustMarsh, char* bI1CustMarsh, unsigned char* bU1CustMarsh, unsigned short* bVBCustMarsh);
4616 LIBTEST_API int STDCALL
4617 mono_test_managed_marshal_bool_ref (int arg, unsigned int expected, unsigned int testVal, unsigned int outExpected,
4618 unsigned int outTestVal, MarshalBoolRefDelegate pfcn)
4621 unsigned int lDefaultMarsh, lBoolCustMarsh;
4622 char lI1CustMarsh = 0;
4623 unsigned char lU1CustMarsh = 0;
4624 unsigned short lVBCustMarsh = 0;
4625 lDefaultMarsh = lBoolCustMarsh = 0;
4633 unsigned int ltestVal = testVal;
4634 ret = pfcn (arg, expected, outTestVal, <estVal, &lBoolCustMarsh, &lI1CustMarsh, &lU1CustMarsh, &lVBCustMarsh);
4636 return 0x0100 + ret;
4637 if (outExpected != ltestVal)
4643 unsigned int ltestVal = testVal;
4644 ret = pfcn (arg, expected, outTestVal, &lDefaultMarsh, <estVal, &lI1CustMarsh, &lU1CustMarsh, &lVBCustMarsh);
4646 return 0x0300 + ret;
4647 if (outExpected != ltestVal)
4653 char ltestVal = testVal;
4654 ret = pfcn (arg, expected, outTestVal, &lDefaultMarsh, &lBoolCustMarsh, <estVal, &lU1CustMarsh, &lVBCustMarsh);
4656 return 0x0500 + ret;
4657 if (outExpected != ltestVal)
4663 unsigned char ltestVal = testVal;
4664 ret = pfcn (arg, expected, outTestVal, &lDefaultMarsh, &lBoolCustMarsh, &lI1CustMarsh, <estVal, &lVBCustMarsh);
4666 return 0x0700 + ret;
4667 if (outExpected != ltestVal)
4673 unsigned short ltestVal = testVal;
4674 ret = pfcn (arg, expected, outTestVal, &lDefaultMarsh, &lBoolCustMarsh, &lI1CustMarsh, &lU1CustMarsh, <estVal);
4676 return 0x0900 + ret;
4677 if (outExpected != ltestVal)
4690 LIBTEST_API int STDCALL
4691 mono_test_marshal_safearray_out_1dim_vt_bstr_empty (SAFEARRAY** safearray)
4693 /* Create an empty one-dimensional array of variants */
4695 SAFEARRAYBOUND dimensions [1];
4697 dimensions [0].lLbound = 0;
4698 dimensions [0].cElements = 0;
4700 pSA= SafeArrayCreate (VT_VARIANT, 1, dimensions);
4705 LIBTEST_API int STDCALL
4706 mono_test_marshal_safearray_out_1dim_vt_bstr (SAFEARRAY** safearray)
4708 /* Create a one-dimensional array of 10 variants filled with "0" to "9" */
4710 SAFEARRAYBOUND dimensions [1];
4716 dimensions [0].lLbound = 0;
4717 dimensions [0].cElements = 10;
4719 pSA= SafeArrayCreate (VT_VARIANT, 1, dimensions);
4720 for (i= dimensions [0].lLbound; i< (dimensions [0].cElements + dimensions [0].lLbound); i++) {
4722 VariantInit (&vOut);
4724 _ltoa (i,buffer,10);
4725 vOut.bstrVal= marshal_bstr_alloc (buffer);
4727 if ((hr = SafeArrayPutElement (pSA, indices, &vOut)) != S_OK) {
4728 VariantClear (&vOut);
4729 SafeArrayDestroy (pSA);
4732 VariantClear (&vOut);
4738 LIBTEST_API int STDCALL
4739 mono_test_marshal_safearray_out_2dim_vt_i4 (SAFEARRAY** safearray)
4741 /* Create a two-dimensional array of 4x3 variants filled with 11, 12, 13, etc. */
4743 SAFEARRAYBOUND dimensions [2];
4748 dimensions [0].lLbound = 0;
4749 dimensions [0].cElements = 4;
4750 dimensions [1].lLbound = 0;
4751 dimensions [1].cElements = 3;
4753 pSA= SafeArrayCreate(VT_VARIANT, 2, dimensions);
4754 for (i= dimensions [0].lLbound; i< (dimensions [0].cElements + dimensions [0].lLbound); i++) {
4755 for (j= dimensions [1].lLbound; j< (dimensions [1].cElements + dimensions [1].lLbound); j++) {
4757 VariantInit (&vOut);
4759 vOut.lVal = (i+1)*10+(j+1);
4762 if ((hr = SafeArrayPutElement (pSA, indices, &vOut)) != S_OK) {
4763 VariantClear (&vOut);
4764 SafeArrayDestroy (pSA);
4767 VariantClear (&vOut); // does a deep destroy of source VARIANT
4774 LIBTEST_API int STDCALL
4775 mono_test_marshal_safearray_out_4dim_vt_i4 (SAFEARRAY** safearray)
4777 /* Create a four-dimensional array of 10x3x6x7 variants filled with their indices */
4778 /* Also use non zero lower bounds */
4780 SAFEARRAYBOUND dimensions [4];
4785 dimensions [0].lLbound = 15;
4786 dimensions [0].cElements = 10;
4787 dimensions [1].lLbound = 20;
4788 dimensions [1].cElements = 3;
4789 dimensions [2].lLbound = 5;
4790 dimensions [2].cElements = 6;
4791 dimensions [3].lLbound = 12;
4792 dimensions [3].cElements = 7;
4794 pSA= SafeArrayCreate (VT_VARIANT, 4, dimensions);
4796 SafeArrayAccessData (pSA, (void **)&pData);
4798 for (i= 0; i< 10*3*6*7; i++) {
4799 VariantInit(&pData [i]);
4800 pData [i].vt = VT_I4;
4803 SafeArrayUnaccessData (pSA);
4808 LIBTEST_API int STDCALL
4809 mono_test_marshal_safearray_in_byval_1dim_empty (SAFEARRAY* safearray)
4811 /* Check that array is one dimensional and empty */
4814 long lbound, ubound;
4816 dim = SafeArrayGetDim (safearray);
4820 SafeArrayGetLBound (safearray, 1, &lbound);
4821 SafeArrayGetUBound (safearray, 1, &ubound);
4823 if ((lbound > 0) || (ubound > 0))
4829 LIBTEST_API int STDCALL
4830 mono_test_marshal_safearray_in_byval_1dim_vt_i4 (SAFEARRAY* safearray)
4832 /* Check that array is one dimensional containing integers from 1 to 10 */
4835 long lbound, ubound;
4840 dim = SafeArrayGetDim (safearray);
4844 SafeArrayGetLBound (safearray, 1, &lbound);
4845 SafeArrayGetUBound (safearray, 1, &ubound);
4847 if ((lbound != 0) || (ubound != 9))
4850 SafeArrayAccessData (safearray, (void **)&pData);
4851 for (i= lbound; i <= ubound; i++) {
4852 if ((VariantChangeType (&pData [i], &pData [i], VARIANT_NOUSEROVERRIDE, VT_I4) != S_OK) || (pData [i].lVal != i + 1))
4855 SafeArrayUnaccessData (safearray);
4860 LIBTEST_API int STDCALL
4861 mono_test_marshal_safearray_in_byval_1dim_vt_mixed (SAFEARRAY* safearray)
4863 /* Check that array is one dimensional containing integers mixed with strings from 0 to 12 */
4866 long lbound, ubound;
4873 VariantInit (&element);
4875 dim = SafeArrayGetDim (safearray);
4879 SafeArrayGetLBound (safearray, 1, &lbound);
4880 SafeArrayGetUBound (safearray, 1, &ubound);
4882 if ((lbound != 0) || (ubound != 12))
4885 SafeArrayAccessData (safearray, (void **)&pData);
4886 for (i= lbound; i <= ubound; i++) {
4887 if ((i%2 == 0) && (pData [i].vt != VT_I4))
4889 if ((i%2 == 1) && (pData [i].vt != VT_BSTR))
4891 if ((VariantChangeType (&pData [i], &pData [i], VARIANT_NOUSEROVERRIDE, VT_I4) != S_OK) || (pData [i].lVal != i))
4894 SafeArrayUnaccessData (safearray);
4896 /* Change the first element of the array to verify that [in] parameters are not marshalled back to the managed side */
4901 SafeArrayPutElement (safearray, indices, &element);
4902 VariantClear (&element);
4907 LIBTEST_API int STDCALL
4908 mono_test_marshal_safearray_in_byval_2dim_vt_i4 (SAFEARRAY* safearray)
4910 /* Check that array is one dimensional containing integers mixed with strings from 0 to 12 */
4913 long lbound1, ubound1, lbound2, ubound2;
4918 VariantInit (&element);
4920 dim = SafeArrayGetDim (safearray);
4924 SafeArrayGetLBound (safearray, 1, &lbound1);
4925 SafeArrayGetUBound (safearray, 1, &ubound1);
4927 if ((lbound1 != 0) || (ubound1 != 1))
4930 SafeArrayGetLBound (safearray, 2, &lbound2);
4931 SafeArrayGetUBound (safearray, 2, &ubound2);
4933 if ((lbound2 != 0) || (ubound2 != 3)) {
4937 for (i= lbound1; i <= ubound1; i++) {
4939 for (j= lbound2; j <= ubound2; j++) {
4941 if (SafeArrayGetElement (safearray, indices, &element) != S_OK)
4943 failed = ((element.vt != VT_I4) || (element.lVal != 10*(i+1)+(j+1)));
4944 VariantClear (&element);
4950 /* Change the first element of the array to verify that [in] parameters are not marshalled back to the managed side */
4956 SafeArrayPutElement (safearray, indices, &element);
4957 VariantClear (&element);
4962 LIBTEST_API int STDCALL
4963 mono_test_marshal_safearray_in_byval_3dim_vt_bstr (SAFEARRAY* safearray)
4965 /* Check that array is one dimensional containing integers mixed with strings from 0 to 12 */
4968 long lbound1, ubound1, lbound2, ubound2, lbound3, ubound3;
4969 long i, j, k, failed;
4973 VariantInit (&element);
4975 dim = SafeArrayGetDim (safearray);
4979 SafeArrayGetLBound (safearray, 1, &lbound1);
4980 SafeArrayGetUBound (safearray, 1, &ubound1);
4982 if ((lbound1 != 0) || (ubound1 != 1))
4985 SafeArrayGetLBound (safearray, 2, &lbound2);
4986 SafeArrayGetUBound (safearray, 2, &ubound2);
4988 if ((lbound2 != 0) || (ubound2 != 1))
4991 SafeArrayGetLBound (safearray, 3, &lbound3);
4992 SafeArrayGetUBound (safearray, 3, &ubound3);
4994 if ((lbound3 != 0) || (ubound3 != 2))
4997 for (i= lbound1; i <= ubound1; i++) {
4999 for (j= lbound2; j <= ubound2; j++) {
5001 for (k= lbound3; k <= ubound3; k++) {
5003 if (SafeArrayGetElement (safearray, indices, &element) != S_OK)
5005 failed = ((element.vt != VT_BSTR)
5006 || (VariantChangeType (&element, &element, VARIANT_NOUSEROVERRIDE, VT_I4) != S_OK)
5007 || (element.lVal != 100*(i+1)+10*(j+1)+(k+1)));
5008 VariantClear (&element);
5015 /* Change the first element of the array to verify that [in] parameters are not marshalled back to the managed side */
5020 element.vt = VT_BSTR;
5021 element.bstrVal = SysAllocString(L"Should not be copied");
5022 SafeArrayPutElement (safearray, indices, &element);
5023 VariantClear (&element);
5028 LIBTEST_API int STDCALL
5029 mono_test_marshal_safearray_in_byref_3dim_vt_bstr (SAFEARRAY** safearray)
5031 return mono_test_marshal_safearray_in_byval_3dim_vt_bstr (*safearray);
5034 LIBTEST_API int STDCALL
5035 mono_test_marshal_safearray_in_out_byref_1dim_empty (SAFEARRAY** safearray)
5037 /* Check that the input array is what is expected and change it so the caller can check */
5038 /* correct marshalling back to managed code */
5041 long lbound, ubound;
5042 SAFEARRAYBOUND dimensions [1];
5044 wchar_t buffer [20];
5048 /* Check that in array is one dimensional and empty */
5050 dim = SafeArrayGetDim (*safearray);
5055 SafeArrayGetLBound (*safearray, 1, &lbound);
5056 SafeArrayGetUBound (*safearray, 1, &ubound);
5058 if ((lbound > 0) || (ubound > 0)) {
5062 /* Re-dimension the array and return a one-dimensional array of 8 variants filled with "0" to "7" */
5064 dimensions [0].lLbound = 0;
5065 dimensions [0].cElements = 8;
5067 hr = SafeArrayRedim (*safearray, dimensions);
5071 for (i= dimensions [0].lLbound; i< (dimensions [0].lLbound + dimensions [0].cElements); i++) {
5073 VariantInit (&vOut);
5075 _ltow (i,buffer,10);
5076 vOut.bstrVal = SysAllocString (buffer);
5078 if ((hr = SafeArrayPutElement (*safearray, indices, &vOut)) != S_OK) {
5079 VariantClear (&vOut);
5080 SafeArrayDestroy (*safearray);
5083 VariantClear (&vOut);
5088 LIBTEST_API int STDCALL
5089 mono_test_marshal_safearray_in_out_byref_3dim_vt_bstr (SAFEARRAY** safearray)
5091 /* Check that the input array is what is expected and change it so the caller can check */
5092 /* correct marshalling back to managed code */
5095 long lbound1, ubound1, lbound2, ubound2, lbound3, ubound3;
5096 SAFEARRAYBOUND dimensions [1];
5097 long i, j, k, failed;
5098 wchar_t buffer [20];
5103 VariantInit (&element);
5105 /* Check that in array is three dimensional and contains the expected values */
5107 dim = SafeArrayGetDim (*safearray);
5111 SafeArrayGetLBound (*safearray, 1, &lbound1);
5112 SafeArrayGetUBound (*safearray, 1, &ubound1);
5114 if ((lbound1 != 0) || (ubound1 != 1))
5117 SafeArrayGetLBound (*safearray, 2, &lbound2);
5118 SafeArrayGetUBound (*safearray, 2, &ubound2);
5120 if ((lbound2 != 0) || (ubound2 != 1))
5123 SafeArrayGetLBound (*safearray, 3, &lbound3);
5124 SafeArrayGetUBound (*safearray, 3, &ubound3);
5126 if ((lbound3 != 0) || (ubound3 != 2))
5129 for (i= lbound1; i <= ubound1; i++) {
5131 for (j= lbound2; j <= ubound2; j++) {
5133 for (k= lbound3; k <= ubound3; k++) {
5135 if (SafeArrayGetElement (*safearray, indices, &element) != S_OK)
5137 failed = ((element.vt != VT_BSTR)
5138 || (VariantChangeType (&element, &element, VARIANT_NOUSEROVERRIDE, VT_I4) != S_OK)
5139 || (element.lVal != 100*(i+1)+10*(j+1)+(k+1)));
5140 VariantClear (&element);
5147 hr = SafeArrayDestroy (*safearray);
5151 /* Return a new one-dimensional array of 8 variants filled with "0" to "7" */
5153 dimensions [0].lLbound = 0;
5154 dimensions [0].cElements = 8;
5156 *safearray = SafeArrayCreate (VT_VARIANT, 1, dimensions);
5158 for (i= dimensions [0].lLbound; i< (dimensions [0].lLbound + dimensions [0].cElements); i++) {
5160 VariantInit (&vOut);
5162 _ltow (i,buffer,10);
5163 vOut.bstrVal = SysAllocString (buffer);
5165 if ((hr = SafeArrayPutElement (*safearray, indices, &vOut)) != S_OK) {
5166 VariantClear (&vOut);
5167 SafeArrayDestroy (*safearray);
5170 VariantClear (&vOut);
5175 LIBTEST_API int STDCALL
5176 mono_test_marshal_safearray_in_out_byref_1dim_vt_i4 (SAFEARRAY** safearray)
5178 /* Check that the input array is what is expected and change it so the caller can check */
5179 /* correct marshalling back to managed code */
5182 long lbound1, ubound1;
5188 VariantInit (&element);
5190 /* Check that in array is one dimensional and contains the expected value */
5192 dim = SafeArrayGetDim (*safearray);
5196 SafeArrayGetLBound (*safearray, 1, &lbound1);
5197 SafeArrayGetUBound (*safearray, 1, &ubound1);
5200 if ((lbound1 != 0) || (ubound1 != 1))
5204 for (i= lbound1; i <= ubound1; i++) {
5206 if (SafeArrayGetElement (*safearray, indices, &element) != S_OK)
5208 failed = (element.vt != VT_I4) || (element.lVal != i+1);
5209 VariantClear (&element);
5214 /* Change one of the elements of the array to verify that [out] parameter is marshalled back to the managed side */
5219 SafeArrayPutElement (*safearray, indices, &element);
5220 VariantClear (&element);
5225 LIBTEST_API int STDCALL
5226 mono_test_marshal_safearray_in_out_byval_1dim_vt_i4 (SAFEARRAY* safearray)
5228 /* Check that the input array is what is expected and change it so the caller can check */
5229 /* correct marshalling back to managed code */
5232 long lbound1, ubound1;
5233 SAFEARRAYBOUND dimensions [1];
5239 VariantInit (&element);
5241 /* Check that in array is one dimensional and contains the expected value */
5243 dim = SafeArrayGetDim (safearray);
5247 SafeArrayGetLBound (safearray, 1, &lbound1);
5248 SafeArrayGetUBound (safearray, 1, &ubound1);
5250 if ((lbound1 != 0) || (ubound1 != 0))
5253 for (i= lbound1; i <= ubound1; i++) {
5255 if (SafeArrayGetElement (safearray, indices, &element) != S_OK)
5257 failed = (element.vt != VT_I4) || (element.lVal != i+1);
5258 VariantClear (&element);
5263 /* Change the array to verify how [out] parameter is marshalled back to the managed side */
5265 /* Redimension the array */
5266 dimensions [0].lLbound = lbound1;
5267 dimensions [0].cElements = 2;
5268 hr = SafeArrayRedim(safearray, dimensions);
5272 element.lVal = 12345;
5273 SafeArrayPutElement (safearray, indices, &element);
5274 VariantClear (&element);
5278 element.lVal = -12345;
5279 SafeArrayPutElement (safearray, indices, &element);
5280 VariantClear (&element);
5285 LIBTEST_API int STDCALL
5286 mono_test_marshal_safearray_in_out_byval_3dim_vt_bstr (SAFEARRAY* safearray)
5288 /* Check that the input array is what is expected and change it so the caller can check */
5289 /* correct marshalling back to managed code */
5292 long lbound1, ubound1, lbound2, ubound2, lbound3, ubound3;
5293 long i, j, k, failed;
5298 VariantInit (&element);
5300 /* Check that in array is three dimensional and contains the expected values */
5302 dim = SafeArrayGetDim (safearray);
5306 SafeArrayGetLBound (safearray, 1, &lbound1);
5307 SafeArrayGetUBound (safearray, 1, &ubound1);
5309 if ((lbound1 != 0) || (ubound1 != 1))
5312 SafeArrayGetLBound (safearray, 2, &lbound2);
5313 SafeArrayGetUBound (safearray, 2, &ubound2);
5315 if ((lbound2 != 0) || (ubound2 != 1))
5318 SafeArrayGetLBound (safearray, 3, &lbound3);
5319 SafeArrayGetUBound (safearray, 3, &ubound3);
5321 if ((lbound3 != 0) || (ubound3 != 2))
5324 for (i= lbound1; i <= ubound1; i++) {
5326 for (j= lbound2; j <= ubound2; j++) {
5328 for (k= lbound3; k <= ubound3; k++) {
5330 if (SafeArrayGetElement (safearray, indices, &element) != S_OK)
5332 failed = ((element.vt != VT_BSTR)
5333 || (VariantChangeType (&element, &element, VARIANT_NOUSEROVERRIDE, VT_I4) != S_OK)
5334 || (element.lVal != 100*(i+1)+10*(j+1)+(k+1)));
5335 VariantClear (&element);
5342 /* Change the elements of the array to verify that [out] parameter is marshalled back to the managed side */
5349 SafeArrayPutElement (safearray, indices, &element);
5350 VariantClear (&element);
5357 SafeArrayPutElement (safearray, indices, &element);
5358 VariantClear (&element);
5363 element.vt = VT_BSTR;
5364 element.bstrVal = marshal_bstr_alloc("ABCDEFG");
5365 SafeArrayPutElement (safearray, indices, &element);
5366 VariantClear (&element);
5371 LIBTEST_API int STDCALL
5372 mono_test_marshal_safearray_mixed(
5373 SAFEARRAY *safearray1,
5374 SAFEARRAY **safearray2,
5375 SAFEARRAY *safearray3,
5376 SAFEARRAY **safearray4
5381 /* Initialize out parameters */
5384 /* array1: Check that in array is one dimensional and contains the expected value */
5385 hr = mono_test_marshal_safearray_in_out_byval_1dim_vt_i4 (safearray1);
5387 /* array2: Fill in with some values to check on the managed side */
5389 hr = mono_test_marshal_safearray_out_1dim_vt_bstr (safearray2);
5391 /* array3: Check that in array is one dimensional and contains the expected value */
5393 hr = mono_test_marshal_safearray_in_byval_1dim_vt_mixed(safearray3);
5395 /* array4: Check input values and fill in with some values to check on the managed side */
5397 hr = mono_test_marshal_safearray_in_out_byref_3dim_vt_bstr(safearray4);
5404 static int call_managed_res;
5407 call_managed (gpointer arg)
5409 SimpleDelegate del = arg;
5411 call_managed_res = del (42);
5414 LIBTEST_API int STDCALL
5415 mono_test_marshal_thread_attach (SimpleDelegate del)
5423 res = pthread_create (&t, NULL, (gpointer)call_managed, del);
5424 g_assert (res == 0);
5425 pthread_join (t, NULL);
5427 return call_managed_res;
5431 typedef int (STDCALL *Callback) (void);
5433 static Callback callback;
5435 LIBTEST_API void STDCALL
5436 mono_test_marshal_set_callback (Callback cb)
5441 LIBTEST_API int STDCALL
5442 mono_test_marshal_call_callback (void)
5447 LIBTEST_API int STDCALL
5448 mono_test_marshal_lpstr (char *str)
5450 return strcmp ("ABC", str);
5453 LIBTEST_API int STDCALL
5454 mono_test_marshal_lpwstr (gunichar2 *str)
5459 s = g_utf16_to_utf8 (str, -1, NULL, NULL, NULL);
5460 res = strcmp ("ABC", s);
5466 LIBTEST_API char* STDCALL
5467 mono_test_marshal_return_lpstr (void)
5469 char *res = marshal_alloc (4);
5470 strcpy (res, "XYZ");
5475 LIBTEST_API gunichar2* STDCALL
5476 mono_test_marshal_return_lpwstr (void)
5478 gunichar2 *res = marshal_alloc (8);
5479 gunichar2* tmp = g_utf8_to_utf16 ("XYZ", -1, NULL, NULL, NULL);
5481 memcpy (res, tmp, 8);
5489 } SingleDoubleStruct;
5491 LIBTEST_API SingleDoubleStruct STDCALL
5492 mono_test_marshal_return_single_double_struct (void)
5494 SingleDoubleStruct res;
5504 LIBTEST_API int STDCALL
5505 mono_test_has_thiscall (void)
5511 _mono_test_native_thiscall1 (int arg)
5517 _mono_test_native_thiscall2 (int arg, int arg2)
5519 return arg + (arg2^1);
5523 _mono_test_native_thiscall3 (int arg, int arg2, int arg3)
5525 return arg + (arg2^1) + (arg3^2);
5528 #elif defined(__GNUC__)
5530 LIBTEST_API int STDCALL
5531 mono_test_has_thiscall (void)
5536 #define def_asm_fn(name) \
5538 "\t.globl _" #name "\n" \
5540 "\t.globl __" #name "\n" \
5545 def_asm_fn(mono_test_native_thiscall1)
5546 "\tmovl %ecx,%eax\n"
5549 def_asm_fn(mono_test_native_thiscall2)
5550 "\tmovl %ecx,%eax\n"
5551 "\tmovl 4(%esp),%ecx\n"
5553 "\taddl %ecx,%eax\n"
5556 def_asm_fn(mono_test_native_thiscall3)
5557 "\tmovl %ecx,%eax\n"
5558 "\tmovl 4(%esp),%ecx\n"
5560 "\taddl %ecx,%eax\n"
5561 "\tmovl 8(%esp),%ecx\n"
5563 "\taddl %ecx,%eax\n"
5570 LIBTEST_API int STDCALL
5571 mono_test_has_thiscall (void)
5583 LIBTEST_API sbyte1 STDCALL
5584 mono_return_sbyte1 (sbyte1 s1, int addend) {
5586 fprintf(stderr, "mono_return_sbyte1 s1.f1: got %d but expected %d\n", s1.f1, 1);
5596 LIBTEST_API sbyte2 STDCALL
5597 mono_return_sbyte2 (sbyte2 s2, int addend) {
5599 fprintf(stderr, "mono_return_sbyte2 s2.f1: got %d but expected %d\n", s2.f1, 1);
5602 fprintf(stderr, "mono_return_sbyte2 s2.f2: got %d but expected %d\n", s2.f2, 2);
5604 s2.f1+=addend; s2.f2+=addend;
5612 LIBTEST_API sbyte3 STDCALL
5613 mono_return_sbyte3 (sbyte3 s3, int addend) {
5615 fprintf(stderr, "mono_return_sbyte3 s3.f1: got %d but expected %d\n", s3.f1, 1);
5618 fprintf(stderr, "mono_return_sbyte3 s3.f2: got %d but expected %d\n", s3.f2, 2);
5621 fprintf(stderr, "mono_return_sbyte3 s3.f3: got %d but expected %d\n", s3.f3, 3);
5623 s3.f1+=addend; s3.f2+=addend; s3.f3+=addend;
5631 LIBTEST_API sbyte4 STDCALL
5632 mono_return_sbyte4 (sbyte4 s4, int addend) {
5634 fprintf(stderr, "mono_return_sbyte4 s4.f1: got %d but expected %d\n", s4.f1, 1);
5637 fprintf(stderr, "mono_return_sbyte4 s4.f2: got %d but expected %d\n", s4.f2, 2);
5640 fprintf(stderr, "mono_return_sbyte4 s4.f3: got %d but expected %d\n", s4.f3, 3);
5643 fprintf(stderr, "mono_return_sbyte4 s4.f4: got %d but expected %d\n", s4.f4, 4);
5645 s4.f1+=addend; s4.f2+=addend; s4.f3+=addend; s4.f4+=addend;
5650 char f1,f2,f3,f4,f5;
5653 LIBTEST_API sbyte5 STDCALL
5654 mono_return_sbyte5 (sbyte5 s5, int addend) {
5656 fprintf(stderr, "mono_return_sbyte5 s5.f1: got %d but expected %d\n", s5.f1, 1);
5659 fprintf(stderr, "mono_return_sbyte5 s5.f2: got %d but expected %d\n", s5.f2, 2);
5662 fprintf(stderr, "mono_return_sbyte5 s5.f3: got %d but expected %d\n", s5.f3, 3);
5665 fprintf(stderr, "mono_return_sbyte5 s5.f4: got %d but expected %d\n", s5.f4, 4);
5668 fprintf(stderr, "mono_return_sbyte5 s5.f5: got %d but expected %d\n", s5.f5, 5);
5670 s5.f1+=addend; s5.f2+=addend; s5.f3+=addend; s5.f4+=addend; s5.f5+=addend;
5675 char f1,f2,f3,f4,f5,f6;
5678 LIBTEST_API sbyte6 STDCALL
5679 mono_return_sbyte6 (sbyte6 s6, int addend) {
5681 fprintf(stderr, "mono_return_sbyte6 s6.f1: got %d but expected %d\n", s6.f1, 1);
5684 fprintf(stderr, "mono_return_sbyte6 s6.f2: got %d but expected %d\n", s6.f2, 2);
5687 fprintf(stderr, "mono_return_sbyte6 s6.f3: got %d but expected %d\n", s6.f3, 3);
5690 fprintf(stderr, "mono_return_sbyte6 s6.f4: got %d but expected %d\n", s6.f4, 4);
5693 fprintf(stderr, "mono_return_sbyte6 s6.f5: got %d but expected %d\n", s6.f5, 5);
5696 fprintf(stderr, "mono_return_sbyte6 s6.f6: got %d but expected %d\n", s6.f6, 6);
5698 s6.f1+=addend; s6.f2+=addend; s6.f3+=addend; s6.f4+=addend; s6.f5+=addend; s6.f6+=addend;
5703 char f1,f2,f3,f4,f5,f6,f7;
5706 LIBTEST_API sbyte7 STDCALL
5707 mono_return_sbyte7 (sbyte7 s7, int addend) {
5709 fprintf(stderr, "mono_return_sbyte7 s7.f1: got %d but expected %d\n", s7.f1, 1);
5712 fprintf(stderr, "mono_return_sbyte7 s7.f2: got %d but expected %d\n", s7.f2, 2);
5715 fprintf(stderr, "mono_return_sbyte7 s7.f3: got %d but expected %d\n", s7.f3, 3);
5718 fprintf(stderr, "mono_return_sbyte7 s7.f4: got %d but expected %d\n", s7.f4, 4);
5721 fprintf(stderr, "mono_return_sbyte7 s7.f5: got %d but expected %d\n", s7.f5, 5);
5724 fprintf(stderr, "mono_return_sbyte7 s7.f6: got %d but expected %d\n", s7.f6, 6);
5727 fprintf(stderr, "mono_return_sbyte7 s7.f7: got %d but expected %d\n", s7.f7, 7);
5729 s7.f1+=addend; s7.f2+=addend; s7.f3+=addend; s7.f4+=addend; s7.f5+=addend; s7.f6+=addend; s7.f7+=addend;
5734 char f1,f2,f3,f4,f5,f6,f7,f8;
5737 LIBTEST_API sbyte8 STDCALL
5738 mono_return_sbyte8 (sbyte8 s8, int addend) {
5740 fprintf(stderr, "mono_return_sbyte8 s8.f1: got %d but expected %d\n", s8.f1, 1);
5743 fprintf(stderr, "mono_return_sbyte8 s8.f2: got %d but expected %d\n", s8.f2, 2);
5746 fprintf(stderr, "mono_return_sbyte8 s8.f3: got %d but expected %d\n", s8.f3, 3);
5749 fprintf(stderr, "mono_return_sbyte8 s8.f4: got %d but expected %d\n", s8.f4, 4);
5752 fprintf(stderr, "mono_return_sbyte8 s8.f5: got %d but expected %d\n", s8.f5, 5);
5755 fprintf(stderr, "mono_return_sbyte8 s8.f6: got %d but expected %d\n", s8.f6, 6);
5758 fprintf(stderr, "mono_return_sbyte8 s8.f7: got %d but expected %d\n", s8.f7, 7);
5761 fprintf(stderr, "mono_return_sbyte8 s8.f8: got %d but expected %d\n", s8.f8, 8);
5763 s8.f1+=addend; s8.f2+=addend; s8.f3+=addend; s8.f4+=addend; s8.f5+=addend; s8.f6+=addend; s8.f7+=addend; s8.f8+=addend;
5768 char f1,f2,f3,f4,f5,f6,f7,f8,f9;
5771 LIBTEST_API sbyte9 STDCALL
5772 mono_return_sbyte9 (sbyte9 s9, int addend) {
5774 fprintf(stderr, "mono_return_sbyte9 s9.f1: got %d but expected %d\n", s9.f1, 1);
5777 fprintf(stderr, "mono_return_sbyte9 s9.f2: got %d but expected %d\n", s9.f2, 2);
5780 fprintf(stderr, "mono_return_sbyte9 s9.f3: got %d but expected %d\n", s9.f3, 3);
5783 fprintf(stderr, "mono_return_sbyte9 s9.f4: got %d but expected %d\n", s9.f4, 4);
5786 fprintf(stderr, "mono_return_sbyte9 s9.f5: got %d but expected %d\n", s9.f5, 5);
5789 fprintf(stderr, "mono_return_sbyte9 s9.f6: got %d but expected %d\n", s9.f6, 6);
5792 fprintf(stderr, "mono_return_sbyte9 s9.f7: got %d but expected %d\n", s9.f7, 7);
5795 fprintf(stderr, "mono_return_sbyte9 s9.f8: got %d but expected %d\n", s9.f8, 8);
5798 fprintf(stderr, "mono_return_sbyte9 s9.f9: got %d but expected %d\n", s9.f9, 9);
5800 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;
5805 char f1,f2,f3,f4,f5,f6,f7,f8,f9,f10;
5808 LIBTEST_API sbyte10 STDCALL
5809 mono_return_sbyte10 (sbyte10 s10, int addend) {
5811 fprintf(stderr, "mono_return_sbyte10 s10.f1: got %d but expected %d\n", s10.f1, 1);
5814 fprintf(stderr, "mono_return_sbyte10 s10.f2: got %d but expected %d\n", s10.f2, 2);
5817 fprintf(stderr, "mono_return_sbyte10 s10.f3: got %d but expected %d\n", s10.f3, 3);
5820 fprintf(stderr, "mono_return_sbyte10 s10.f4: got %d but expected %d\n", s10.f4, 4);
5823 fprintf(stderr, "mono_return_sbyte10 s10.f5: got %d but expected %d\n", s10.f5, 5);
5826 fprintf(stderr, "mono_return_sbyte10 s10.f6: got %d but expected %d\n", s10.f6, 6);
5829 fprintf(stderr, "mono_return_sbyte10 s10.f7: got %d but expected %d\n", s10.f7, 7);
5832 fprintf(stderr, "mono_return_sbyte10 s10.f8: got %d but expected %d\n", s10.f8, 8);
5835 fprintf(stderr, "mono_return_sbyte10 s10.f9: got %d but expected %d\n", s10.f9, 9);
5837 if (s10.f10 != 10) {
5838 fprintf(stderr, "mono_return_sbyte10 s10.f10: got %d but expected %d\n", s10.f10, 10);
5840 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;
5845 char f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11;
5848 LIBTEST_API sbyte11 STDCALL
5849 mono_return_sbyte11 (sbyte11 s11, int addend) {
5851 fprintf(stderr, "mono_return_sbyte11 s11.f1: got %d but expected %d\n", s11.f1, 1);
5854 fprintf(stderr, "mono_return_sbyte11 s11.f2: got %d but expected %d\n", s11.f2, 2);
5857 fprintf(stderr, "mono_return_sbyte11 s11.f3: got %d but expected %d\n", s11.f3, 3);
5860 fprintf(stderr, "mono_return_sbyte11 s11.f4: got %d but expected %d\n", s11.f4, 4);
5863 fprintf(stderr, "mono_return_sbyte11 s11.f5: got %d but expected %d\n", s11.f5, 5);
5866 fprintf(stderr, "mono_return_sbyte11 s11.f6: got %d but expected %d\n", s11.f6, 6);
5869 fprintf(stderr, "mono_return_sbyte11 s11.f7: got %d but expected %d\n", s11.f7, 7);
5872 fprintf(stderr, "mono_return_sbyte11 s11.f8: got %d but expected %d\n", s11.f8, 8);
5875 fprintf(stderr, "mono_return_sbyte11 s11.f9: got %d but expected %d\n", s11.f9, 9);
5877 if (s11.f10 != 10) {
5878 fprintf(stderr, "mono_return_sbyte11 s11.f10: got %d but expected %d\n", s11.f10, 10);
5880 if (s11.f11 != 11) {
5881 fprintf(stderr, "mono_return_sbyte11 s11.f11: got %d but expected %d\n", s11.f11, 11);
5883 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;
5888 char f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12;
5891 LIBTEST_API sbyte12 STDCALL
5892 mono_return_sbyte12 (sbyte12 s12, int addend) {
5894 fprintf(stderr, "mono_return_sbyte12 s12.f1: got %d but expected %d\n", s12.f1, 1);
5897 fprintf(stderr, "mono_return_sbyte12 s12.f2: got %d but expected %d\n", s12.f2, 2);
5900 fprintf(stderr, "mono_return_sbyte12 s12.f3: got %d but expected %d\n", s12.f3, 3);
5903 fprintf(stderr, "mono_return_sbyte12 s12.f4: got %d but expected %d\n", s12.f4, 4);
5906 fprintf(stderr, "mono_return_sbyte12 s12.f5: got %d but expected %d\n", s12.f5, 5);
5909 fprintf(stderr, "mono_return_sbyte12 s12.f6: got %d but expected %d\n", s12.f6, 6);
5912 fprintf(stderr, "mono_return_sbyte12 s12.f7: got %d but expected %d\n", s12.f7, 7);
5915 fprintf(stderr, "mono_return_sbyte12 s12.f8: got %d but expected %d\n", s12.f8, 8);
5918 fprintf(stderr, "mono_return_sbyte12 s12.f9: got %d but expected %d\n", s12.f9, 9);
5920 if (s12.f10 != 10) {
5921 fprintf(stderr, "mono_return_sbyte12 s12.f10: got %d but expected %d\n", s12.f10, 10);
5923 if (s12.f11 != 11) {
5924 fprintf(stderr, "mono_return_sbyte12 s12.f11: got %d but expected %d\n", s12.f11, 11);
5926 if (s12.f12 != 12) {
5927 fprintf(stderr, "mono_return_sbyte12 s12.f12: got %d but expected %d\n", s12.f12, 12);
5929 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;
5934 char f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13;
5937 LIBTEST_API sbyte13 STDCALL
5938 mono_return_sbyte13 (sbyte13 s13, int addend) {
5940 fprintf(stderr, "mono_return_sbyte13 s13.f1: got %d but expected %d\n", s13.f1, 1);
5943 fprintf(stderr, "mono_return_sbyte13 s13.f2: got %d but expected %d\n", s13.f2, 2);
5946 fprintf(stderr, "mono_return_sbyte13 s13.f3: got %d but expected %d\n", s13.f3, 3);
5949 fprintf(stderr, "mono_return_sbyte13 s13.f4: got %d but expected %d\n", s13.f4, 4);
5952 fprintf(stderr, "mono_return_sbyte13 s13.f5: got %d but expected %d\n", s13.f5, 5);
5955 fprintf(stderr, "mono_return_sbyte13 s13.f6: got %d but expected %d\n", s13.f6, 6);
5958 fprintf(stderr, "mono_return_sbyte13 s13.f7: got %d but expected %d\n", s13.f7, 7);
5961 fprintf(stderr, "mono_return_sbyte13 s13.f8: got %d but expected %d\n", s13.f8, 8);
5964 fprintf(stderr, "mono_return_sbyte13 s13.f9: got %d but expected %d\n", s13.f9, 9);
5966 if (s13.f10 != 10) {
5967 fprintf(stderr, "mono_return_sbyte13 s13.f10: got %d but expected %d\n", s13.f10, 10);
5969 if (s13.f11 != 11) {
5970 fprintf(stderr, "mono_return_sbyte13 s13.f11: got %d but expected %d\n", s13.f11, 11);
5972 if (s13.f12 != 12) {
5973 fprintf(stderr, "mono_return_sbyte13 s13.f12: got %d but expected %d\n", s13.f12, 12);
5975 if (s13.f13 != 13) {
5976 fprintf(stderr, "mono_return_sbyte13 s13.f13: got %d but expected %d\n", s13.f13, 13);
5978 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;
5983 char f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14;
5986 LIBTEST_API sbyte14 STDCALL
5987 mono_return_sbyte14 (sbyte14 s14, int addend) {
5989 fprintf(stderr, "mono_return_sbyte14 s14.f1: got %d but expected %d\n", s14.f1, 1);
5992 fprintf(stderr, "mono_return_sbyte14 s14.f2: got %d but expected %d\n", s14.f2, 2);
5995 fprintf(stderr, "mono_return_sbyte14 s14.f3: got %d but expected %d\n", s14.f3, 3);
5998 fprintf(stderr, "mono_return_sbyte14 s14.f4: got %d but expected %d\n", s14.f4, 4);
6001 fprintf(stderr, "mono_return_sbyte14 s14.f5: got %d but expected %d\n", s14.f5, 5);
6004 fprintf(stderr, "mono_return_sbyte14 s14.f6: got %d but expected %d\n", s14.f6, 6);
6007 fprintf(stderr, "mono_return_sbyte14 s14.f7: got %d but expected %d\n", s14.f7, 7);
6010 fprintf(stderr, "mono_return_sbyte14 s14.f8: got %d but expected %d\n", s14.f8, 8);
6013 fprintf(stderr, "mono_return_sbyte14 s14.f9: got %d but expected %d\n", s14.f9, 9);
6015 if (s14.f10 != 10) {
6016 fprintf(stderr, "mono_return_sbyte14 s14.f10: got %d but expected %d\n", s14.f10, 10);
6018 if (s14.f11 != 11) {
6019 fprintf(stderr, "mono_return_sbyte14 s14.f11: got %d but expected %d\n", s14.f11, 11);
6021 if (s14.f12 != 12) {
6022 fprintf(stderr, "mono_return_sbyte14 s14.f12: got %d but expected %d\n", s14.f12, 12);
6024 if (s14.f13 != 13) {
6025 fprintf(stderr, "mono_return_sbyte14 s14.f13: got %d but expected %d\n", s14.f13, 13);
6027 if (s14.f14 != 14) {
6028 fprintf(stderr, "mono_return_sbyte14 s14.f14: got %d but expected %d\n", s14.f14, 14);
6030 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;
6035 char f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15;
6038 LIBTEST_API sbyte15 STDCALL
6039 mono_return_sbyte15 (sbyte15 s15, int addend) {
6041 fprintf(stderr, "mono_return_sbyte15 s15.f1: got %d but expected %d\n", s15.f1, 1);
6044 fprintf(stderr, "mono_return_sbyte15 s15.f2: got %d but expected %d\n", s15.f2, 2);
6047 fprintf(stderr, "mono_return_sbyte15 s15.f3: got %d but expected %d\n", s15.f3, 3);
6050 fprintf(stderr, "mono_return_sbyte15 s15.f4: got %d but expected %d\n", s15.f4, 4);
6053 fprintf(stderr, "mono_return_sbyte15 s15.f5: got %d but expected %d\n", s15.f5, 5);
6056 fprintf(stderr, "mono_return_sbyte15 s15.f6: got %d but expected %d\n", s15.f6, 6);
6059 fprintf(stderr, "mono_return_sbyte15 s15.f7: got %d but expected %d\n", s15.f7, 7);
6062 fprintf(stderr, "mono_return_sbyte15 s15.f8: got %d but expected %d\n", s15.f8, 8);
6065 fprintf(stderr, "mono_return_sbyte15 s15.f9: got %d but expected %d\n", s15.f9, 9);
6067 if (s15.f10 != 10) {
6068 fprintf(stderr, "mono_return_sbyte15 s15.f10: got %d but expected %d\n", s15.f10, 10);
6070 if (s15.f11 != 11) {
6071 fprintf(stderr, "mono_return_sbyte15 s15.f11: got %d but expected %d\n", s15.f11, 11);
6073 if (s15.f12 != 12) {
6074 fprintf(stderr, "mono_return_sbyte15 s15.f12: got %d but expected %d\n", s15.f12, 12);
6076 if (s15.f13 != 13) {
6077 fprintf(stderr, "mono_return_sbyte15 s15.f13: got %d but expected %d\n", s15.f13, 13);
6079 if (s15.f14 != 14) {
6080 fprintf(stderr, "mono_return_sbyte15 s15.f14: got %d but expected %d\n", s15.f14, 14);
6082 if (s15.f15 != 15) {
6083 fprintf(stderr, "mono_return_sbyte15 s15.f15: got %d but expected %d\n", s15.f15, 15);
6085 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;
6090 char f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15,f16;
6093 LIBTEST_API sbyte16 STDCALL
6094 mono_return_sbyte16 (sbyte16 s16, int addend) {
6096 fprintf(stderr, "mono_return_sbyte16 s16.f1: got %d but expected %d\n", s16.f1, 1);
6099 fprintf(stderr, "mono_return_sbyte16 s16.f2: got %d but expected %d\n", s16.f2, 2);
6102 fprintf(stderr, "mono_return_sbyte16 s16.f3: got %d but expected %d\n", s16.f3, 3);
6105 fprintf(stderr, "mono_return_sbyte16 s16.f4: got %d but expected %d\n", s16.f4, 4);
6108 fprintf(stderr, "mono_return_sbyte16 s16.f5: got %d but expected %d\n", s16.f5, 5);
6111 fprintf(stderr, "mono_return_sbyte16 s16.f6: got %d but expected %d\n", s16.f6, 6);
6114 fprintf(stderr, "mono_return_sbyte16 s16.f7: got %d but expected %d\n", s16.f7, 7);
6117 fprintf(stderr, "mono_return_sbyte16 s16.f8: got %d but expected %d\n", s16.f8, 8);
6120 fprintf(stderr, "mono_return_sbyte16 s16.f9: got %d but expected %d\n", s16.f9, 9);
6122 if (s16.f10 != 10) {
6123 fprintf(stderr, "mono_return_sbyte16 s16.f10: got %d but expected %d\n", s16.f10, 10);
6125 if (s16.f11 != 11) {
6126 fprintf(stderr, "mono_return_sbyte16 s16.f11: got %d but expected %d\n", s16.f11, 11);
6128 if (s16.f12 != 12) {
6129 fprintf(stderr, "mono_return_sbyte16 s16.f12: got %d but expected %d\n", s16.f12, 12);
6131 if (s16.f13 != 13) {
6132 fprintf(stderr, "mono_return_sbyte16 s16.f13: got %d but expected %d\n", s16.f13, 13);
6134 if (s16.f14 != 14) {
6135 fprintf(stderr, "mono_return_sbyte16 s16.f14: got %d but expected %d\n", s16.f14, 14);
6137 if (s16.f15 != 15) {
6138 fprintf(stderr, "mono_return_sbyte16 s16.f15: got %d but expected %d\n", s16.f15, 15);
6140 if (s16.f16 != 16) {
6141 fprintf(stderr, "mono_return_sbyte16 s16.f16: got %d but expected %d\n", s16.f16, 16);
6143 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;
6148 char f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15,f16,f17;
6151 LIBTEST_API sbyte17 STDCALL
6152 mono_return_sbyte17 (sbyte17 s17, int addend) {
6154 fprintf(stderr, "mono_return_sbyte17 s17.f1: got %d but expected %d\n", s17.f1, 1);
6157 fprintf(stderr, "mono_return_sbyte17 s17.f2: got %d but expected %d\n", s17.f2, 2);
6160 fprintf(stderr, "mono_return_sbyte17 s17.f3: got %d but expected %d\n", s17.f3, 3);
6163 fprintf(stderr, "mono_return_sbyte17 s17.f4: got %d but expected %d\n", s17.f4, 4);
6166 fprintf(stderr, "mono_return_sbyte17 s17.f5: got %d but expected %d\n", s17.f5, 5);
6169 fprintf(stderr, "mono_return_sbyte17 s17.f6: got %d but expected %d\n", s17.f6, 6);
6172 fprintf(stderr, "mono_return_sbyte17 s17.f7: got %d but expected %d\n", s17.f7, 7);
6175 fprintf(stderr, "mono_return_sbyte17 s17.f8: got %d but expected %d\n", s17.f8, 8);
6178 fprintf(stderr, "mono_return_sbyte17 s17.f9: got %d but expected %d\n", s17.f9, 9);
6180 if (s17.f10 != 10) {
6181 fprintf(stderr, "mono_return_sbyte17 s17.f10: got %d but expected %d\n", s17.f10, 10);
6183 if (s17.f11 != 11) {
6184 fprintf(stderr, "mono_return_sbyte17 s17.f11: got %d but expected %d\n", s17.f11, 11);
6186 if (s17.f12 != 12) {
6187 fprintf(stderr, "mono_return_sbyte17 s17.f12: got %d but expected %d\n", s17.f12, 12);
6189 if (s17.f13 != 13) {
6190 fprintf(stderr, "mono_return_sbyte17 s17.f13: got %d but expected %d\n", s17.f13, 13);
6192 if (s17.f14 != 14) {
6193 fprintf(stderr, "mono_return_sbyte17 s17.f14: got %d but expected %d\n", s17.f14, 14);
6195 if (s17.f15 != 15) {
6196 fprintf(stderr, "mono_return_sbyte17 s17.f15: got %d but expected %d\n", s17.f15, 15);
6198 if (s17.f16 != 16) {
6199 fprintf(stderr, "mono_return_sbyte17 s17.f16: got %d but expected %d\n", s17.f16, 16);
6201 if (s17.f17 != 17) {
6202 fprintf(stderr, "mono_return_sbyte17 s17.f17: got %d but expected %d\n", s17.f17, 17);
6204 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;
6212 char f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15;
6218 LIBTEST_API sbyte16_nested STDCALL
6219 mono_return_sbyte16_nested (sbyte16_nested sn16, int addend) {
6220 if (sn16.nested1.f1 != 1) {
6221 fprintf(stderr, "mono_return_sbyte16_nested sn16.nested1.f1: got %d but expected %d\n", sn16.nested1.f1, 1);
6224 fprintf(stderr, "mono_return_sbyte16_nested sn16.f2: got %d but expected %d\n", sn16.f2, 2);
6227 fprintf(stderr, "mono_return_sbyte16_nested sn16.f3: got %d but expected %d\n", sn16.f3, 3);
6230 fprintf(stderr, "mono_return_sbyte16_nested sn16.f4: got %d but expected %d\n", sn16.f4, 4);
6233 fprintf(stderr, "mono_return_sbyte16_nested sn16.f5: got %d but expected %d\n", sn16.f5, 5);
6236 fprintf(stderr, "mono_return_sbyte16_nested sn16.f6: got %d but expected %d\n", sn16.f6, 6);
6239 fprintf(stderr, "mono_return_sbyte16_nested sn16.f7: got %d but expected %d\n", sn16.f7, 7);
6242 fprintf(stderr, "mono_return_sbyte16_nested sn16.f8: got %d but expected %d\n", sn16.f8, 8);
6245 fprintf(stderr, "mono_return_sbyte16_nested sn16.f9: got %d but expected %d\n", sn16.f9, 9);
6247 if (sn16.f10 != 10) {
6248 fprintf(stderr, "mono_return_sbyte16_nested sn16.f10: got %d but expected %d\n", sn16.f10, 10);
6250 if (sn16.f11 != 11) {
6251 fprintf(stderr, "mono_return_sbyte16_nested sn16.f11: got %d but expected %d\n", sn16.f11, 11);
6253 if (sn16.f12 != 12) {
6254 fprintf(stderr, "mono_return_sbyte16_nested sn16.f12: got %d but expected %d\n", sn16.f12, 12);
6256 if (sn16.f13 != 13) {
6257 fprintf(stderr, "mono_return_sbyte16_nested sn16.f13: got %d but expected %d\n", sn16.f13, 13);
6259 if (sn16.f14 != 14) {
6260 fprintf(stderr, "mono_return_sbyte16_nested sn16.f14: got %d but expected %d\n", sn16.f14, 14);
6262 if (sn16.f15 != 15) {
6263 fprintf(stderr, "mono_return_sbyte16_nested sn16.f15: got %d but expected %d\n", sn16.f15, 15);
6265 if (sn16.nested2.f16 != 16) {
6266 fprintf(stderr, "mono_return_sbyte16_nested sn16.nested2.f16: got %d but expected %d\n", sn16.nested2.f16, 16);
6268 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;
6277 LIBTEST_API short1 STDCALL
6278 mono_return_short1 (short1 s1, int addend) {
6280 fprintf(stderr, "mono_return_short1 s1.f1: got %d but expected %d\n", s1.f1, 1);
6290 LIBTEST_API short2 STDCALL
6291 mono_return_short2 (short2 s2, int addend) {
6293 fprintf(stderr, "mono_return_short2 s2.f1: got %d but expected %d\n", s2.f1, 1);
6296 fprintf(stderr, "mono_return_short2 s2.f2: got %d but expected %d\n", s2.f2, 2);
6298 s2.f1+=addend; s2.f2+=addend;
6306 LIBTEST_API short3 STDCALL
6307 mono_return_short3 (short3 s3, int addend) {
6309 fprintf(stderr, "mono_return_short3 s3.f1: got %d but expected %d\n", s3.f1, 1);
6312 fprintf(stderr, "mono_return_short3 s3.f2: got %d but expected %d\n", s3.f2, 2);
6315 fprintf(stderr, "mono_return_short3 s3.f3: got %d but expected %d\n", s3.f3, 3);
6317 s3.f1+=addend; s3.f2+=addend; s3.f3+=addend;
6325 LIBTEST_API short4 STDCALL
6326 mono_return_short4 (short4 s4, int addend) {
6328 fprintf(stderr, "mono_return_short4 s4.f1: got %d but expected %d\n", s4.f1, 1);
6331 fprintf(stderr, "mono_return_short4 s4.f2: got %d but expected %d\n", s4.f2, 2);
6334 fprintf(stderr, "mono_return_short4 s4.f3: got %d but expected %d\n", s4.f3, 3);
6337 fprintf(stderr, "mono_return_short4 s4.f4: got %d but expected %d\n", s4.f4, 4);
6339 s4.f1+=addend; s4.f2+=addend; s4.f3+=addend; s4.f4+=addend;
6344 short f1,f2,f3,f4,f5;
6347 LIBTEST_API short5 STDCALL
6348 mono_return_short5 (short5 s5, int addend) {
6350 fprintf(stderr, "mono_return_short5 s5.f1: got %d but expected %d\n", s5.f1, 1);
6353 fprintf(stderr, "mono_return_short5 s5.f2: got %d but expected %d\n", s5.f2, 2);
6356 fprintf(stderr, "mono_return_short5 s5.f3: got %d but expected %d\n", s5.f3, 3);
6359 fprintf(stderr, "mono_return_short5 s5.f4: got %d but expected %d\n", s5.f4, 4);
6362 fprintf(stderr, "mono_return_short5 s5.f5: got %d but expected %d\n", s5.f5, 5);
6364 s5.f1+=addend; s5.f2+=addend; s5.f3+=addend; s5.f4+=addend; s5.f5+=addend;
6369 short f1,f2,f3,f4,f5,f6;
6372 LIBTEST_API short6 STDCALL
6373 mono_return_short6 (short6 s6, int addend) {
6375 fprintf(stderr, "mono_return_short6 s6.f1: got %d but expected %d\n", s6.f1, 1);
6378 fprintf(stderr, "mono_return_short6 s6.f2: got %d but expected %d\n", s6.f2, 2);
6381 fprintf(stderr, "mono_return_short6 s6.f3: got %d but expected %d\n", s6.f3, 3);
6384 fprintf(stderr, "mono_return_short6 s6.f4: got %d but expected %d\n", s6.f4, 4);
6387 fprintf(stderr, "mono_return_short6 s6.f5: got %d but expected %d\n", s6.f5, 5);
6390 fprintf(stderr, "mono_return_short6 s6.f6: got %d but expected %d\n", s6.f6, 6);
6392 s6.f1+=addend; s6.f2+=addend; s6.f3+=addend; s6.f4+=addend; s6.f5+=addend; s6.f6+=addend;
6397 short f1,f2,f3,f4,f5,f6,f7;
6400 LIBTEST_API short7 STDCALL
6401 mono_return_short7 (short7 s7, int addend) {
6403 fprintf(stderr, "mono_return_short7 s7.f1: got %d but expected %d\n", s7.f1, 1);
6406 fprintf(stderr, "mono_return_short7 s7.f2: got %d but expected %d\n", s7.f2, 2);
6409 fprintf(stderr, "mono_return_short7 s7.f3: got %d but expected %d\n", s7.f3, 3);
6412 fprintf(stderr, "mono_return_short7 s7.f4: got %d but expected %d\n", s7.f4, 4);
6415 fprintf(stderr, "mono_return_short7 s7.f5: got %d but expected %d\n", s7.f5, 5);
6418 fprintf(stderr, "mono_return_short7 s7.f6: got %d but expected %d\n", s7.f6, 6);
6421 fprintf(stderr, "mono_return_short7 s7.f7: got %d but expected %d\n", s7.f7, 7);
6423 s7.f1+=addend; s7.f2+=addend; s7.f3+=addend; s7.f4+=addend; s7.f5+=addend; s7.f6+=addend; s7.f7+=addend;
6428 short f1,f2,f3,f4,f5,f6,f7,f8;
6431 LIBTEST_API short8 STDCALL
6432 mono_return_short8 (short8 s8, int addend) {
6434 fprintf(stderr, "mono_return_short8 s8.f1: got %d but expected %d\n", s8.f1, 1);
6437 fprintf(stderr, "mono_return_short8 s8.f2: got %d but expected %d\n", s8.f2, 2);
6440 fprintf(stderr, "mono_return_short8 s8.f3: got %d but expected %d\n", s8.f3, 3);
6443 fprintf(stderr, "mono_return_short8 s8.f4: got %d but expected %d\n", s8.f4, 4);
6446 fprintf(stderr, "mono_return_short8 s8.f5: got %d but expected %d\n", s8.f5, 5);
6449 fprintf(stderr, "mono_return_short8 s8.f6: got %d but expected %d\n", s8.f6, 6);
6452 fprintf(stderr, "mono_return_short8 s8.f7: got %d but expected %d\n", s8.f7, 7);
6455 fprintf(stderr, "mono_return_short8 s8.f8: got %d but expected %d\n", s8.f8, 8);
6457 s8.f1+=addend; s8.f2+=addend; s8.f3+=addend; s8.f4+=addend; s8.f5+=addend; s8.f6+=addend; s8.f7+=addend; s8.f8+=addend;
6462 short f1,f2,f3,f4,f5,f6,f7,f8,f9;
6465 LIBTEST_API short9 STDCALL
6466 mono_return_short9 (short9 s9, int addend) {
6468 fprintf(stderr, "mono_return_short9 s9.f1: got %d but expected %d\n", s9.f1, 1);
6471 fprintf(stderr, "mono_return_short9 s9.f2: got %d but expected %d\n", s9.f2, 2);
6474 fprintf(stderr, "mono_return_short9 s9.f3: got %d but expected %d\n", s9.f3, 3);
6477 fprintf(stderr, "mono_return_short9 s9.f4: got %d but expected %d\n", s9.f4, 4);
6480 fprintf(stderr, "mono_return_short9 s9.f5: got %d but expected %d\n", s9.f5, 5);
6483 fprintf(stderr, "mono_return_short9 s9.f6: got %d but expected %d\n", s9.f6, 6);
6486 fprintf(stderr, "mono_return_short9 s9.f7: got %d but expected %d\n", s9.f7, 7);
6489 fprintf(stderr, "mono_return_short9 s9.f8: got %d but expected %d\n", s9.f8, 8);
6492 fprintf(stderr, "mono_return_short9 s9.f9: got %d but expected %d\n", s9.f9, 9);
6494 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;
6502 short f2,f3,f4,f5,f6,f7;
6508 LIBTEST_API short8_nested STDCALL
6509 mono_return_short8_nested (short8_nested sn8, int addend) {
6510 if (sn8.nested1.f1 != 1) {
6511 fprintf(stderr, "mono_return_short8_nested sn8.nested1.f1: got %d but expected %d\n", sn8.nested1.f1, 1);
6514 fprintf(stderr, "mono_return_short8_nested sn8.f2: got %d but expected %d\n", sn8.f2, 2);
6517 fprintf(stderr, "mono_return_short8_nested sn8.f3: got %d but expected %d\n", sn8.f3, 3);
6520 fprintf(stderr, "mono_return_short8_nested sn8.f4: got %d but expected %d\n", sn8.f4, 4);
6523 fprintf(stderr, "mono_return_short8_nested sn8.f5: got %d but expected %d\n", sn8.f5, 5);
6526 fprintf(stderr, "mono_return_short8_nested sn8.f6: got %d but expected %d\n", sn8.f6, 6);
6529 fprintf(stderr, "mono_return_short8_nested sn8.f7: got %d but expected %d\n", sn8.f7, 7);
6531 if (sn8.nested2.f8 != 8) {
6532 fprintf(stderr, "mono_return_short8_nested sn8.nested2.f8: got %d but expected %d\n", sn8.nested2.f8, 8);
6534 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;
6543 LIBTEST_API int1 STDCALL
6544 mono_return_int1 (int1 s1, int addend) {
6546 fprintf(stderr, "mono_return_int1 s1.f1: got %d but expected %d\n", s1.f1, 1);
6556 LIBTEST_API int2 STDCALL
6557 mono_return_int2 (int2 s2, int addend) {
6559 fprintf(stderr, "mono_return_int2 s2.f1: got %d but expected %d\n", s2.f1, 1);
6562 fprintf(stderr, "mono_return_int2 s2.f2: got %d but expected %d\n", s2.f2, 2);
6564 s2.f1+=addend; s2.f2+=addend;
6572 LIBTEST_API int3 STDCALL
6573 mono_return_int3 (int3 s3, int addend) {
6575 fprintf(stderr, "mono_return_int3 s3.f1: got %d but expected %d\n", s3.f1, 1);
6578 fprintf(stderr, "mono_return_int3 s3.f2: got %d but expected %d\n", s3.f2, 2);
6581 fprintf(stderr, "mono_return_int3 s3.f3: got %d but expected %d\n", s3.f3, 3);
6583 s3.f1+=addend; s3.f2+=addend; s3.f3+=addend;
6591 LIBTEST_API int4 STDCALL
6592 mono_return_int4 (int4 s4, int addend) {
6594 fprintf(stderr, "mono_return_int4 s4.f1: got %d but expected %d\n", s4.f1, 1);
6597 fprintf(stderr, "mono_return_int4 s4.f2: got %d but expected %d\n", s4.f2, 2);
6600 fprintf(stderr, "mono_return_int4 s4.f3: got %d but expected %d\n", s4.f3, 3);
6603 fprintf(stderr, "mono_return_int4 s4.f4: got %d but expected %d\n", s4.f4, 4);
6605 s4.f1+=addend; s4.f2+=addend; s4.f3+=addend; s4.f4+=addend;
6613 LIBTEST_API int5 STDCALL
6614 mono_return_int5 (int5 s5, int addend) {
6616 fprintf(stderr, "mono_return_int5 s5.f1: got %d but expected %d\n", s5.f1, 1);
6619 fprintf(stderr, "mono_return_int5 s5.f2: got %d but expected %d\n", s5.f2, 2);
6622 fprintf(stderr, "mono_return_int5 s5.f3: got %d but expected %d\n", s5.f3, 3);
6625 fprintf(stderr, "mono_return_int5 s5.f4: got %d but expected %d\n", s5.f4, 4);
6628 fprintf(stderr, "mono_return_int5 s5.f5: got %d but expected %d\n", s5.f5, 5);
6630 s5.f1+=addend; s5.f2+=addend; s5.f3+=addend; s5.f4+=addend; s5.f5+=addend;
6644 LIBTEST_API int4_nested STDCALL
6645 mono_return_int4_nested (int4_nested sn4, int addend) {
6646 if (sn4.nested1.f1 != 1) {
6647 fprintf(stderr, "mono_return_int4_nested sn4.nested1.f1: got %d but expected %d\n", sn4.nested1.f1, 1);
6650 fprintf(stderr, "mono_return_int4_nested sn4.f2: got %d but expected %d\n", sn4.f2, 2);
6653 fprintf(stderr, "mono_return_int4_nested sn4.f3: got %d but expected %d\n", sn4.f3, 3);
6655 if (sn4.nested2.f4 != 4) {
6656 fprintf(stderr, "mono_return_int4_nested sn4.nested2.f4: got %d but expected %d\n", sn4.nested2.f4, 4);
6658 sn4.nested1.f1+=addend; sn4.f2+=addend; sn4.f3+=addend; sn4.nested2.f4+=addend;
6666 LIBTEST_API float1 STDCALL
6667 mono_return_float1 (float1 s1, int addend) {
6669 fprintf(stderr, "mono_return_float1 s1.f1: got %f but expected %d\n", s1.f1, 1);
6679 LIBTEST_API float2 STDCALL
6680 mono_return_float2 (float2 s2, int addend) {
6682 fprintf(stderr, "mono_return_float2 s2.f1: got %f but expected %d\n", s2.f1, 1);
6685 fprintf(stderr, "mono_return_float2 s2.f2: got %f but expected %d\n", s2.f2, 2);
6687 s2.f1+=addend; s2.f2+=addend;
6695 LIBTEST_API float3 STDCALL
6696 mono_return_float3 (float3 s3, int addend) {
6698 fprintf(stderr, "mono_return_float3 s3.f1: got %f but expected %d\n", s3.f1, 1);
6701 fprintf(stderr, "mono_return_float3 s3.f2: got %f but expected %d\n", s3.f2, 2);
6704 fprintf(stderr, "mono_return_float3 s3.f3: got %f but expected %d\n", s3.f3, 3);
6706 s3.f1+=addend; s3.f2+=addend; s3.f3+=addend;
6714 LIBTEST_API float4 STDCALL
6715 mono_return_float4 (float4 s4, int addend) {
6717 fprintf(stderr, "mono_return_float4 s4.f1: got %f but expected %d\n", s4.f1, 1);
6720 fprintf(stderr, "mono_return_float4 s4.f2: got %f but expected %d\n", s4.f2, 2);
6723 fprintf(stderr, "mono_return_float4 s4.f3: got %f but expected %d\n", s4.f3, 3);
6726 fprintf(stderr, "mono_return_float4 s4.f4: got %f but expected %d\n", s4.f4, 4);
6728 s4.f1+=addend; s4.f2+=addend; s4.f3+=addend; s4.f4+=addend;
6733 float f1,f2,f3,f4,f5;
6736 LIBTEST_API float5 STDCALL
6737 mono_return_float5 (float5 s5, int addend) {
6739 fprintf(stderr, "mono_return_float5 s5.f1: got %f but expected %d\n", s5.f1, 1);
6742 fprintf(stderr, "mono_return_float5 s5.f2: got %f but expected %d\n", s5.f2, 2);
6745 fprintf(stderr, "mono_return_float5 s5.f3: got %f but expected %d\n", s5.f3, 3);
6748 fprintf(stderr, "mono_return_float5 s5.f4: got %f but expected %d\n", s5.f4, 4);
6751 fprintf(stderr, "mono_return_float5 s5.f5: got %f but expected %d\n", s5.f5, 5);
6753 s5.f1+=addend; s5.f2+=addend; s5.f3+=addend; s5.f4+=addend; s5.f5+=addend;
6758 float f1,f2,f3,f4,f5,f6;
6761 LIBTEST_API float6 STDCALL
6762 mono_return_float6 (float6 s6, int addend) {
6764 fprintf(stderr, "mono_return_float6 s6.f1: got %f but expected %d\n", s6.f1, 1);
6767 fprintf(stderr, "mono_return_float6 s6.f2: got %f but expected %d\n", s6.f2, 2);
6770 fprintf(stderr, "mono_return_float6 s6.f3: got %f but expected %d\n", s6.f3, 3);
6773 fprintf(stderr, "mono_return_float6 s6.f4: got %f but expected %d\n", s6.f4, 4);
6776 fprintf(stderr, "mono_return_float6 s6.f5: got %f but expected %d\n", s6.f5, 5);
6779 fprintf(stderr, "mono_return_float6 s6.f6: got %f but expected %d\n", s6.f6, 6);
6781 s6.f1+=addend; s6.f2+=addend; s6.f3+=addend; s6.f4+=addend; s6.f5+=addend; s6.f6+=addend;
6786 float f1,f2,f3,f4,f5,f6,f7;
6789 LIBTEST_API float7 STDCALL
6790 mono_return_float7 (float7 s7, int addend) {
6792 fprintf(stderr, "mono_return_float7 s7.f1: got %f but expected %d\n", s7.f1, 1);
6795 fprintf(stderr, "mono_return_float7 s7.f2: got %f but expected %d\n", s7.f2, 2);
6798 fprintf(stderr, "mono_return_float7 s7.f3: got %f but expected %d\n", s7.f3, 3);
6801 fprintf(stderr, "mono_return_float7 s7.f4: got %f but expected %d\n", s7.f4, 4);
6804 fprintf(stderr, "mono_return_float7 s7.f5: got %f but expected %d\n", s7.f5, 5);
6807 fprintf(stderr, "mono_return_float7 s7.f6: got %f but expected %d\n", s7.f6, 6);
6810 fprintf(stderr, "mono_return_float7 s7.f7: got %f but expected %d\n", s7.f7, 7);
6812 s7.f1+=addend; s7.f2+=addend; s7.f3+=addend; s7.f4+=addend; s7.f5+=addend; s7.f6+=addend; s7.f7+=addend;
6817 float f1,f2,f3,f4,f5,f6,f7,f8;
6820 LIBTEST_API float8 STDCALL
6821 mono_return_float8 (float8 s8, int addend) {
6823 fprintf(stderr, "mono_return_float8 s8.f1: got %f but expected %d\n", s8.f1, 1);
6826 fprintf(stderr, "mono_return_float8 s8.f2: got %f but expected %d\n", s8.f2, 2);
6829 fprintf(stderr, "mono_return_float8 s8.f3: got %f but expected %d\n", s8.f3, 3);
6832 fprintf(stderr, "mono_return_float8 s8.f4: got %f but expected %d\n", s8.f4, 4);
6835 fprintf(stderr, "mono_return_float8 s8.f5: got %f but expected %d\n", s8.f5, 5);
6838 fprintf(stderr, "mono_return_float8 s8.f6: got %f but expected %d\n", s8.f6, 6);
6841 fprintf(stderr, "mono_return_float8 s8.f7: got %f but expected %d\n", s8.f7, 7);
6844 fprintf(stderr, "mono_return_float8 s8.f8: got %f but expected %d\n", s8.f8, 8);
6846 s8.f1+=addend; s8.f2+=addend; s8.f3+=addend; s8.f4+=addend; s8.f5+=addend; s8.f6+=addend; s8.f7+=addend; s8.f8+=addend;
6851 float f1,f2,f3,f4,f5,f6,f7,f8,f9;
6854 LIBTEST_API float9 STDCALL
6855 mono_return_float9 (float9 s9, int addend) {
6857 fprintf(stderr, "mono_return_float9 s9.f1: got %f but expected %d\n", s9.f1, 1);
6860 fprintf(stderr, "mono_return_float9 s9.f2: got %f but expected %d\n", s9.f2, 2);
6863 fprintf(stderr, "mono_return_float9 s9.f3: got %f but expected %d\n", s9.f3, 3);
6866 fprintf(stderr, "mono_return_float9 s9.f4: got %f but expected %d\n", s9.f4, 4);
6869 fprintf(stderr, "mono_return_float9 s9.f5: got %f but expected %d\n", s9.f5, 5);
6872 fprintf(stderr, "mono_return_float9 s9.f6: got %f but expected %d\n", s9.f6, 6);
6875 fprintf(stderr, "mono_return_float9 s9.f7: got %f but expected %d\n", s9.f7, 7);
6878 fprintf(stderr, "mono_return_float9 s9.f8: got %f but expected %d\n", s9.f8, 8);
6881 fprintf(stderr, "mono_return_float9 s9.f9: got %f but expected %d\n", s9.f9, 9);
6883 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;
6897 LIBTEST_API float4_nested STDCALL
6898 mono_return_float4_nested (float4_nested sn4, int addend) {
6899 if (sn4.nested1.f1 != 1) {
6900 fprintf(stderr, "mono_return_float4_nested sn4.nested1.f1: got %f but expected %d\n", sn4.nested1.f1, 1);
6903 fprintf(stderr, "mono_return_float4_nested sn4.f2: got %f but expected %d\n", sn4.f2, 2);
6906 fprintf(stderr, "mono_return_float4_nested sn4.f3: got %f but expected %d\n", sn4.f3, 3);
6908 if (sn4.nested2.f4 != 4) {
6909 fprintf(stderr, "mono_return_float4_nested sn4.nested2.f4: got %f but expected %d\n", sn4.nested2.f4, 4);
6911 sn4.nested1.f1+=addend; sn4.f2+=addend; sn4.f3+=addend; sn4.nested2.f4+=addend;
6919 LIBTEST_API double1 STDCALL
6920 mono_return_double1 (double1 s1, int addend) {
6922 fprintf(stderr, "mono_return_double1 s1.f1: got %f but expected %d\n", s1.f1, 1);
6932 LIBTEST_API double2 STDCALL
6933 mono_return_double2 (double2 s2, int addend) {
6935 fprintf(stderr, "mono_return_double2 s2.f1: got %f but expected %d\n", s2.f1, 1);
6938 fprintf(stderr, "mono_return_double2 s2.f2: got %f but expected %d\n", s2.f2, 2);
6940 s2.f1+=addend; s2.f2+=addend;
6948 LIBTEST_API double3 STDCALL
6949 mono_return_double3 (double3 s3, int addend) {
6951 fprintf(stderr, "mono_return_double3 s3.f1: got %f but expected %d\n", s3.f1, 1);
6954 fprintf(stderr, "mono_return_double3 s3.f2: got %f but expected %d\n", s3.f2, 2);
6957 fprintf(stderr, "mono_return_double3 s3.f3: got %f but expected %d\n", s3.f3, 3);
6959 s3.f1+=addend; s3.f2+=addend; s3.f3+=addend;
6967 LIBTEST_API double4 STDCALL
6968 mono_return_double4 (double4 s4, int addend) {
6970 fprintf(stderr, "mono_return_double4 s4.f1: got %f but expected %d\n", s4.f1, 1);
6973 fprintf(stderr, "mono_return_double4 s4.f2: got %f but expected %d\n", s4.f2, 2);
6976 fprintf(stderr, "mono_return_double4 s4.f3: got %f but expected %d\n", s4.f3, 3);
6979 fprintf(stderr, "mono_return_double4 s4.f4: got %f but expected %d\n", s4.f4, 4);
6981 s4.f1+=addend; s4.f2+=addend; s4.f3+=addend; s4.f4+=addend;
6986 double f1,f2,f3,f4,f5;
6989 LIBTEST_API double5 STDCALL
6990 mono_return_double5 (double5 s5, int addend) {
6992 fprintf(stderr, "mono_return_double5 s5.f1: got %f but expected %d\n", s5.f1, 1);
6995 fprintf(stderr, "mono_return_double5 s5.f2: got %f but expected %d\n", s5.f2, 2);
6998 fprintf(stderr, "mono_return_double5 s5.f3: got %f but expected %d\n", s5.f3, 3);
7001 fprintf(stderr, "mono_return_double5 s5.f4: got %f but expected %d\n", s5.f4, 4);
7004 fprintf(stderr, "mono_return_double5 s5.f5: got %f but expected %d\n", s5.f5, 5);
7006 s5.f1+=addend; s5.f2+=addend; s5.f3+=addend; s5.f4+=addend; s5.f5+=addend;
7011 double f1,f2,f3,f4,f5,f6;
7014 LIBTEST_API double6 STDCALL
7015 mono_return_double6 (double6 s6, int addend) {
7017 fprintf(stderr, "mono_return_double6 s6.f1: got %f but expected %d\n", s6.f1, 1);
7020 fprintf(stderr, "mono_return_double6 s6.f2: got %f but expected %d\n", s6.f2, 2);
7023 fprintf(stderr, "mono_return_double6 s6.f3: got %f but expected %d\n", s6.f3, 3);
7026 fprintf(stderr, "mono_return_double6 s6.f4: got %f but expected %d\n", s6.f4, 4);
7029 fprintf(stderr, "mono_return_double6 s6.f5: got %f but expected %d\n", s6.f5, 5);
7032 fprintf(stderr, "mono_return_double6 s6.f6: got %f but expected %d\n", s6.f6, 6);
7034 s6.f1+=addend; s6.f2+=addend; s6.f3+=addend; s6.f4+=addend; s6.f5+=addend; s6.f6+=addend;
7039 double f1,f2,f3,f4,f5,f6,f7;
7042 LIBTEST_API double7 STDCALL
7043 mono_return_double7 (double7 s7, int addend) {
7045 fprintf(stderr, "mono_return_double7 s7.f1: got %f but expected %d\n", s7.f1, 1);
7048 fprintf(stderr, "mono_return_double7 s7.f2: got %f but expected %d\n", s7.f2, 2);
7051 fprintf(stderr, "mono_return_double7 s7.f3: got %f but expected %d\n", s7.f3, 3);
7054 fprintf(stderr, "mono_return_double7 s7.f4: got %f but expected %d\n", s7.f4, 4);
7057 fprintf(stderr, "mono_return_double7 s7.f5: got %f but expected %d\n", s7.f5, 5);
7060 fprintf(stderr, "mono_return_double7 s7.f6: got %f but expected %d\n", s7.f6, 6);
7063 fprintf(stderr, "mono_return_double7 s7.f7: got %f but expected %d\n", s7.f7, 7);
7065 s7.f1+=addend; s7.f2+=addend; s7.f3+=addend; s7.f4+=addend; s7.f5+=addend; s7.f6+=addend; s7.f7+=addend;
7070 double f1,f2,f3,f4,f5,f6,f7,f8;
7073 LIBTEST_API double8 STDCALL
7074 mono_return_double8 (double8 s8, int addend) {
7076 fprintf(stderr, "mono_return_double8 s8.f1: got %f but expected %d\n", s8.f1, 1);
7079 fprintf(stderr, "mono_return_double8 s8.f2: got %f but expected %d\n", s8.f2, 2);
7082 fprintf(stderr, "mono_return_double8 s8.f3: got %f but expected %d\n", s8.f3, 3);
7085 fprintf(stderr, "mono_return_double8 s8.f4: got %f but expected %d\n", s8.f4, 4);
7088 fprintf(stderr, "mono_return_double8 s8.f5: got %f but expected %d\n", s8.f5, 5);
7091 fprintf(stderr, "mono_return_double8 s8.f6: got %f but expected %d\n", s8.f6, 6);
7094 fprintf(stderr, "mono_return_double8 s8.f7: got %f but expected %d\n", s8.f7, 7);
7097 fprintf(stderr, "mono_return_double8 s8.f8: got %f but expected %d\n", s8.f8, 8);
7099 s8.f1+=addend; s8.f2+=addend; s8.f3+=addend; s8.f4+=addend; s8.f5+=addend; s8.f6+=addend; s8.f7+=addend; s8.f8+=addend;
7104 double f1,f2,f3,f4,f5,f6,f7,f8,f9;
7107 LIBTEST_API double9 STDCALL
7108 mono_return_double9 (double9 s9, int addend) {
7110 fprintf(stderr, "mono_return_double9 s9.f1: got %f but expected %d\n", s9.f1, 1);
7113 fprintf(stderr, "mono_return_double9 s9.f2: got %f but expected %d\n", s9.f2, 2);
7116 fprintf(stderr, "mono_return_double9 s9.f3: got %f but expected %d\n", s9.f3, 3);
7119 fprintf(stderr, "mono_return_double9 s9.f4: got %f but expected %d\n", s9.f4, 4);
7122 fprintf(stderr, "mono_return_double9 s9.f5: got %f but expected %d\n", s9.f5, 5);
7125 fprintf(stderr, "mono_return_double9 s9.f6: got %f but expected %d\n", s9.f6, 6);
7128 fprintf(stderr, "mono_return_double9 s9.f7: got %f but expected %d\n", s9.f7, 7);
7131 fprintf(stderr, "mono_return_double9 s9.f8: got %f but expected %d\n", s9.f8, 8);
7134 fprintf(stderr, "mono_return_double9 s9.f9: got %f but expected %d\n", s9.f9, 9);
7136 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;
7149 LIBTEST_API double2_nested STDCALL
7150 mono_return_double2_nested (double2_nested sn2, int addend) {
7151 if (sn2.nested1.f1 != 1) {
7152 fprintf(stderr, "mono_return_double2_nested sn2.nested1.f1: got %f but expected %d\n", sn2.nested1.f1, 1);
7154 if (sn2.nested2.f2 != 2) {
7155 fprintf(stderr, "mono_return_double2_nested sn2.nested2.f2: got %f but expected %d\n", sn2.nested2.f2, 2);
7157 sn2.nested1.f1+=addend; sn2.nested2.f2+=addend;
7167 LIBTEST_API double_array4 STDCALL
7168 mono_return_double_array4 (double_array4 sa4, int addend) {
7169 if (sa4.f1[0] != 1) {
7170 fprintf(stderr, "mono_return_double_array4 sa4.f1[0]: got %f but expected %d\n", sa4.f1[0], 1);
7172 if (sa4.f1[1] != 2) {
7173 fprintf(stderr, "mono_return_double_array4 sa4.f1[1]: got %f but expected %d\n", sa4.f1[1], 2);
7175 if (sa4.f1[2] != 3) {
7176 fprintf(stderr, "mono_return_double_array4 sa4.f1[2]: got %f but expected %d\n", sa4.f1[2], 3);
7178 if (sa4.f1[3] != 4) {
7179 fprintf(stderr, "mono_return_double_array4 sa4.f1[3]: got %f but expected %d\n", sa4.f1[3], 4);
7181 sa4.f1[0]+=addend; sa4.f1[1]+=addend; sa4.f1[2]+=addend; sa4.f1[3]+=addend;