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_inout_nonblittable_array (gunichar2 *a1)
532 for (i = 0; i < 10; i++) {
552 LIBTEST_API simplestruct STDCALL
553 mono_test_return_vtype (int i)
556 static gunichar2 test2 [] = { 'T', 'E', 'S', 'T', '2', 0 };
567 LIBTEST_API void STDCALL
568 mono_test_delegate_struct (void)
570 // printf ("TEST\n");
573 typedef char* (STDCALL *ReturnStringDelegate) (const char *s);
575 LIBTEST_API char * STDCALL
576 mono_test_return_string (ReturnStringDelegate func)
580 // printf ("mono_test_return_string\n");
585 // printf ("got string: %s\n", res);
586 return marshal_strdup ("12345");
589 typedef int (STDCALL *RefVTypeDelegate) (int a, simplestruct *ss, int b);
591 LIBTEST_API int STDCALL
592 mono_test_ref_vtype (int a, simplestruct *ss, int b, RefVTypeDelegate func)
594 if (a == 1 && b == 2 && ss->a == 0 && ss->b == 1 && ss->c == 0 &&
595 !strcmp (ss->d, "TEST1")) {
601 return func (a, ss, b);
607 typedef int (STDCALL *OutVTypeDelegate) (int a, simplestruct *ss, int b);
609 LIBTEST_API int STDCALL
610 mono_test_marshal_out_struct (int a, simplestruct *ss, int b, OutVTypeDelegate func)
612 /* Check that the input pointer is ignored */
613 ss->d = (gpointer)0x12345678;
617 if (ss->a && ss->b && ss->c && !strcmp (ss->d, "TEST3"))
623 typedef int (STDCALL *InVTypeDelegate) (int a, simplestruct *ss, int b);
625 LIBTEST_API int STDCALL
626 mono_test_marshal_in_struct (int a, simplestruct *ss, int b, InVTypeDelegate func)
631 memcpy (&ss2, ss, sizeof (simplestruct));
633 res = func (a, ss, b);
635 printf ("mono_test_marshal_in_struct () failed: %d\n", res);
639 /* Check that no modifications is made to the struct */
640 if (ss2.a == ss->a && ss2.b == ss->b && ss2.c == ss->c && ss2.d == ss->d)
648 SimpleDelegate func, func2, func3;
651 LIBTEST_API DelegateStruct STDCALL
652 mono_test_marshal_delegate_struct (DelegateStruct ds)
656 res.a = ds.func (ds.a) + ds.func2 (ds.a) + (ds.func3 == NULL ? 0 : 1);
658 res.func2 = ds.func2;
664 LIBTEST_API int STDCALL
665 mono_test_marshal_struct (simplestruct ss)
667 if (ss.a == 0 && ss.b == 1 && ss.c == 0 &&
668 !strcmp (ss.d, "TEST"))
674 LIBTEST_API int STDCALL
675 mono_test_marshal_byref_struct (simplestruct *ss, int a, int b, int c, char *d)
677 gboolean res = (ss->a == a && ss->b == b && ss->c == c && strcmp (ss->d, d) == 0);
679 marshal_free ((char*)ss->d);
684 ss->d = marshal_strdup ("DEF");
700 LIBTEST_API int STDCALL
701 mono_test_marshal_struct2 (simplestruct2 ss)
703 if (ss.a == 0 && ss.b == 1 && ss.c == 0 &&
704 !strcmp (ss.d, "TEST") &&
705 ss.e == 99 && ss.f == 1.5 && ss.g == 42 && ss.h == (guint64)123)
711 /* on HP some of the struct should be on the stack and not in registers */
712 LIBTEST_API int STDCALL
713 mono_test_marshal_struct2_2 (int i, int j, int k, simplestruct2 ss)
715 if (i != 10 || j != 11 || k != 12)
717 if (ss.a == 0 && ss.b == 1 && ss.c == 0 &&
718 !strcmp (ss.d, "TEST") &&
719 ss.e == 99 && ss.f == 1.5 && ss.g == 42 && ss.h == (guint64)123)
725 LIBTEST_API int STDCALL
726 mono_test_marshal_lpstruct (simplestruct *ss)
728 if (ss->a == 0 && ss->b == 1 && ss->c == 0 &&
729 !strcmp (ss->d, "TEST"))
735 LIBTEST_API int STDCALL
736 mono_test_marshal_lpstruct_blittable (point *p)
738 if (p->x == 1.0 && p->y == 2.0)
744 LIBTEST_API int STDCALL
745 mono_test_marshal_struct_array (simplestruct2 *ss)
747 if (! (ss[0].a == 0 && ss[0].b == 1 && ss[0].c == 0 &&
748 !strcmp (ss[0].d, "TEST") &&
749 ss[0].e == 99 && ss[0].f == 1.5 && ss[0].g == 42 && ss[0].h == (guint64)123))
752 if (! (ss[1].a == 0 && ss[1].b == 0 && ss[1].c == 0 &&
753 !strcmp (ss[1].d, "TEST2") &&
754 ss[1].e == 100 && ss[1].f == 2.5 && ss[1].g == 43 && ss[1].h == (guint64)124))
760 typedef struct long_align_struct {
766 LIBTEST_API int STDCALL
767 mono_test_marshal_long_align_struct_array (long_align_struct *ss)
769 return ss[0].a + ss[0].b + ss[0].c + ss[1].a + ss[1].b + ss[1].c;
772 LIBTEST_API simplestruct2 * STDCALL
773 mono_test_marshal_class (int i, int j, int k, simplestruct2 *ss, int l)
780 if (i != 10 || j != 11 || k != 12 || l != 14)
782 if (! (ss->a == 0 && ss->b == 1 && ss->c == 0 &&
783 !strcmp (ss->d, "TEST") &&
784 ss->e == 99 && ss->f == 1.5 && ss->g == 42 && ss->h == (guint64)123))
787 res = marshal_new0 (simplestruct2, 1);
788 memcpy (res, ss, sizeof (simplestruct2));
789 res->d = marshal_strdup ("TEST");
793 LIBTEST_API int STDCALL
794 mono_test_marshal_byref_class (simplestruct2 **ssp)
796 simplestruct2 *ss = *ssp;
799 if (! (ss->a == 0 && ss->b == 1 && ss->c == 0 &&
800 !strcmp (ss->d, "TEST") &&
801 ss->e == 99 && ss->f == 1.5 && ss->g == 42 && ss->h == (guint64)123))
804 res = marshal_new0 (simplestruct2, 1);
805 memcpy (res, ss, sizeof (simplestruct2));
806 res->d = marshal_strdup ("TEST-RES");
818 /* Yes, this is correct, we are only trying to determine the value of the stack here */
823 LIBTEST_API int STDCALL
824 reliable_delegate (int a)
830 * Checks whether get_sp() works as expected. It doesn't work with gcc-2.95.3 on linux.
833 is_get_sp_reliable (void)
837 reliable_delegate(1);
839 reliable_delegate(1);
844 LIBTEST_API int STDCALL
845 mono_test_marshal_delegate (SimpleDelegate delegate)
849 /* Check that the delegate wrapper is stdcall */
854 if (is_get_sp_reliable())
855 g_assert (sp1 == sp2);
860 static int STDCALL inc_cb (int i)
865 LIBTEST_API int STDCALL
866 mono_test_marshal_out_delegate (SimpleDelegate *delegate)
873 LIBTEST_API SimpleDelegate STDCALL
874 mono_test_marshal_return_delegate (SimpleDelegate delegate)
879 typedef int DelegateByrefDelegate (void *);
881 LIBTEST_API int STDCALL
882 mono_test_marshal_delegate_ref_delegate (DelegateByrefDelegate del)
892 return_plus_one (int i)
897 LIBTEST_API SimpleDelegate STDCALL
898 mono_test_marshal_return_delegate_2 (void)
900 return return_plus_one;
903 typedef simplestruct (STDCALL *SimpleDelegate2) (simplestruct ss);
906 is_utf16_equals (gunichar2 *s1, const char *s2)
911 s = g_utf16_to_utf8 (s1, -1, NULL, NULL, NULL);
912 res = strcmp (s, s2);
918 LIBTEST_API int STDCALL
919 mono_test_marshal_delegate2 (SimpleDelegate2 delegate)
921 simplestruct ss, res;
927 ss.d2 = g_utf8_to_utf16 ("TEST2", -1, NULL, NULL, NULL);
930 if (! (res.a && !res.b && res.c && !strcmp (res.d, "TEST-RES") && is_utf16_equals (res.d2, "TEST2-RES")))
936 typedef simplestruct* (STDCALL *SimpleDelegate4) (simplestruct *ss);
938 LIBTEST_API int STDCALL
939 mono_test_marshal_delegate4 (SimpleDelegate4 delegate)
950 res = delegate (&ss);
954 /* Check return value */
955 if (! (!res->a && res->b && !res->c && !strcmp (res->d, "TEST")))
958 /* Check NULL argument and NULL result */
959 res = delegate (NULL);
966 typedef int (STDCALL *SimpleDelegate5) (simplestruct **ss);
968 LIBTEST_API int STDCALL
969 mono_test_marshal_delegate5 (SimpleDelegate5 delegate)
982 res = delegate (&ptr);
986 if (!(ptr->a && !ptr->b && ptr->c && !strcmp (ptr->d, "RES")))
992 LIBTEST_API int STDCALL
993 mono_test_marshal_delegate6 (SimpleDelegate5 delegate)
999 typedef int (STDCALL *SimpleDelegate7) (simplestruct **ss);
1001 LIBTEST_API int STDCALL
1002 mono_test_marshal_delegate7 (SimpleDelegate7 delegate)
1007 /* Check that the input pointer is ignored */
1008 ptr = (gpointer)0x12345678;
1010 res = delegate (&ptr);
1014 if (!(ptr->a && !ptr->b && ptr->c && !strcmp (ptr->d, "RES")))
1020 typedef int (STDCALL *InOutByvalClassDelegate) (simplestruct *ss);
1022 LIBTEST_API int STDCALL
1023 mono_test_marshal_inout_byval_class_delegate (InOutByvalClassDelegate delegate)
1031 ss.d = g_strdup_printf ("%s", "FOO");
1033 res = delegate (&ss);
1037 if (!(ss.a && !ss.b && ss.c && !strcmp (ss.d, "RES")))
1043 typedef int (STDCALL *SimpleDelegate8) (gunichar2 *s);
1045 LIBTEST_API int STDCALL
1046 mono_test_marshal_delegate8 (SimpleDelegate8 delegate, gunichar2 *s)
1048 return delegate (s);
1051 typedef int (STDCALL *return_int_fnt) (int i);
1052 typedef int (STDCALL *SimpleDelegate9) (return_int_fnt d);
1054 LIBTEST_API int STDCALL
1055 mono_test_marshal_delegate9 (SimpleDelegate9 delegate, gpointer ftn)
1057 return delegate (ftn);
1066 LIBTEST_API int STDCALL
1067 mono_test_marshal_delegate10 (SimpleDelegate9 delegate)
1069 return delegate (return_self);
1072 typedef int (STDCALL *PrimitiveByrefDelegate) (int *i);
1074 LIBTEST_API int STDCALL
1075 mono_test_marshal_primitive_byref_delegate (PrimitiveByrefDelegate delegate)
1079 int res = delegate (&i);
1089 typedef int (STDCALL *return_int_delegate) (int i);
1091 typedef return_int_delegate (STDCALL *ReturnDelegateDelegate) (void);
1093 LIBTEST_API int STDCALL
1094 mono_test_marshal_return_delegate_delegate (ReturnDelegateDelegate d)
1099 LIBTEST_API int STDCALL
1100 mono_test_marshal_stringbuilder (char *s, int n)
1102 const char m[] = "This is my message. Isn't it nice?";
1104 if (strcmp (s, "ABCD") != 0)
1111 LIBTEST_API int STDCALL
1112 mono_test_marshal_stringbuilder_append (char *s, int length)
1114 const char out_sentinel[] = "CSHARP_";
1115 const char out_len = strlen (out_sentinel);
1117 for (int i=0; i < length; i++) {
1118 s [i] = out_sentinel [i % out_len];
1127 LIBTEST_API int STDCALL
1128 mono_test_marshal_stringbuilder_default (char *s, int n)
1130 const char m[] = "This is my message. Isn't it nice?";
1137 LIBTEST_API int STDCALL
1138 mono_test_marshal_stringbuilder_unicode (gunichar2 *s, int n)
1140 const char m[] = "This is my message. Isn't it nice?";
1144 s2 = g_utf8_to_utf16 (m, -1, NULL, &len, NULL);
1146 len = (len * 2) + 2;
1149 memcpy (s, s2, len);
1156 LIBTEST_API void STDCALL
1157 mono_test_marshal_stringbuilder_out (char **s)
1159 const char m[] = "This is my message. Isn't it nice?";
1162 str = marshal_alloc (strlen (m) + 1);
1163 memcpy (str, m, strlen (m) + 1);
1168 LIBTEST_API int STDCALL
1169 mono_test_marshal_stringbuilder_out_unicode (gunichar2 **s)
1171 const char m[] = "This is my message. Isn't it nice?";
1175 s2 = g_utf8_to_utf16 (m, -1, NULL, &len, NULL);
1177 len = (len * 2) + 2;
1178 *s = marshal_alloc (len);
1179 memcpy (*s, s2, len);
1186 LIBTEST_API int STDCALL
1187 mono_test_marshal_stringbuilder_ref (char **s)
1189 const char m[] = "This is my message. Isn't it nice?";
1192 if (strcmp (*s, "ABC"))
1195 str = marshal_alloc (strlen (m) + 1);
1196 memcpy (str, m, strlen (m) + 1);
1208 LIBTEST_API int STDCALL
1209 mono_test_marshal_empty_string_array (char **array)
1211 return (array == NULL) ? 0 : 1;
1214 LIBTEST_API int STDCALL
1215 mono_test_marshal_string_array (char **array)
1217 if (strcmp (array [0], "ABC"))
1219 if (strcmp (array [1], "DEF"))
1222 if (array [2] != NULL)
1228 LIBTEST_API int STDCALL
1229 mono_test_marshal_byref_string_array (char ***array)
1234 if (strcmp ((*array) [0], "Alpha"))
1236 if (strcmp ((*array) [1], "Beta"))
1238 if (strcmp ((*array) [2], "Gamma"))
1244 LIBTEST_API int STDCALL
1245 mono_test_marshal_stringbuilder_array (char **array)
1247 if (strcmp (array [0], "ABC"))
1249 if (strcmp (array [1], "DEF"))
1252 strcpy (array [0], "DEF");
1253 strcpy (array [1], "ABC");
1258 LIBTEST_API int STDCALL
1259 mono_test_marshal_unicode_string_array (gunichar2 **array, char **array2)
1261 GError *error = NULL;
1264 s = g_utf16_to_utf8 (array [0], -1, NULL, NULL, &error);
1265 if (strcmp (s, "ABC")) {
1272 s = g_utf16_to_utf8 (array [1], -1, NULL, NULL, &error);
1273 if (strcmp (s, "DEF")) {
1280 if (strcmp (array2 [0], "ABC"))
1283 if (strcmp (array2 [1], "DEF"))
1289 /* this does not work on Redhat gcc 2.96 */
1290 LIBTEST_API int STDCALL
1291 mono_test_empty_struct (int a, EmptyStruct es, int b)
1293 // printf ("mono_test_empty_struct %d %d\n", a, b);
1295 // Intel icc on ia64 passes 'es' in 2 registers
1296 #if defined(__ia64) && defined(__INTEL_COMPILER)
1299 if (a == 1 && b == 2)
1305 LIBTEST_API EmptyStruct STDCALL
1306 mono_test_return_empty_struct (int a)
1319 LIBTEST_API ByValStrStruct * STDCALL
1320 mono_test_byvalstr_gen (void)
1322 ByValStrStruct *ret;
1324 ret = malloc(sizeof(ByValStrStruct));
1325 memset(ret, 'a', sizeof(ByValStrStruct)-1);
1326 ret->a[sizeof(ByValStrStruct)-1] = 0;
1331 LIBTEST_API int STDCALL
1332 mono_test_byvalstr_check (ByValStrStruct* data, char* correctString)
1336 ret = strcmp(data->a, correctString);
1337 // printf ("T1: %s\n", data->a);
1338 // printf ("T2: %s\n", correctString);
1340 /* we need g_free because the allocation was performed by mono_test_byvalstr_gen */
1348 } ByValStrStruct_Unicode;
1350 LIBTEST_API int STDCALL
1351 mono_test_byvalstr_check_unicode (ByValStrStruct_Unicode *ref, int test)
1353 if (ref->flag != 0x1234abcd){
1354 printf ("overwritten data");
1358 if (test == 1 || test == 3){
1359 if (ref->a [0] != '1' ||
1360 ref->a [1] != '2' ||
1366 if (ref->a [0] != '1' ||
1374 LIBTEST_API int STDCALL
1375 NameManglingAnsi (char *data)
1377 return data [0] + data [1] + data [2];
1380 LIBTEST_API int STDCALL
1381 NameManglingAnsiA (char *data)
1383 g_assert_not_reached ();
1386 LIBTEST_API int STDCALL
1387 NameManglingAnsiW (char *data)
1389 g_assert_not_reached ();
1392 LIBTEST_API int STDCALL
1393 NameManglingAnsi2A (char *data)
1395 return data [0] + data [1] + data [2];
1398 LIBTEST_API int STDCALL
1399 NameManglingAnsi2W (char *data)
1401 g_assert_not_reached ();
1404 LIBTEST_API int STDCALL
1405 NameManglingUnicode (char *data)
1407 g_assert_not_reached ();
1410 LIBTEST_API int STDCALL
1411 NameManglingUnicodeW (gunichar2 *data)
1413 return data [0] + data [1] + data [2];
1416 LIBTEST_API int STDCALL
1417 NameManglingUnicode2 (gunichar2 *data)
1419 return data [0] + data [1] + data [2];
1422 LIBTEST_API int STDCALL
1423 NameManglingAutoW (char *data)
1426 return (data [0] + data [1] + data [2]) == 131 ? 0 : 1;
1428 g_assert_not_reached ();
1432 LIBTEST_API int STDCALL
1433 NameManglingAuto (char *data)
1436 return (data [0] + data [1] + data [2]) == 198 ? 0 : 1;
1438 g_assert_not_reached ();
1442 typedef int (STDCALL *intcharFunc)(const char*);
1444 LIBTEST_API void STDCALL
1445 callFunction (intcharFunc f)
1455 LIBTEST_API int STDCALL
1456 class_marshal_test0 (SimpleObj *obj1)
1458 // printf ("class_marshal_test0 %s %d\n", obj1->str, obj1->i);
1460 if (strcmp(obj1->str, "T1"))
1468 LIBTEST_API int STDCALL
1469 class_marshal_test4 (SimpleObj *obj1)
1477 LIBTEST_API void STDCALL
1478 class_marshal_test1 (SimpleObj **obj1)
1480 SimpleObj *res = malloc (sizeof (SimpleObj));
1482 res->str = marshal_strdup ("ABC");
1488 LIBTEST_API int STDCALL
1489 class_marshal_test2 (SimpleObj **obj1)
1491 // printf ("class_marshal_test2 %s %d\n", (*obj1)->str, (*obj1)->i);
1493 if (strcmp((*obj1)->str, "ABC"))
1495 if ((*obj1)->i != 5)
1501 LIBTEST_API int STDCALL
1502 string_marshal_test0 (char *str)
1504 if (strcmp (str, "TEST0"))
1510 LIBTEST_API void STDCALL
1511 string_marshal_test1 (const char **str)
1513 *str = marshal_strdup ("TEST1");
1516 LIBTEST_API int STDCALL
1517 string_marshal_test2 (char **str)
1519 // printf ("string_marshal_test2 %s\n", *str);
1521 if (strcmp (*str, "TEST1"))
1524 *str = marshal_strdup ("TEST2");
1529 LIBTEST_API int STDCALL
1530 string_marshal_test3 (char *str)
1543 LIBTEST_API BlittableClass* STDCALL
1544 TestBlittableClass (BlittableClass *vl)
1546 BlittableClass *res;
1548 // printf ("TestBlittableClass %d %d\n", vl->a, vl->b);
1554 res = marshal_new0 (BlittableClass, 1);
1555 memcpy (res, vl, sizeof (BlittableClass));
1557 res = marshal_new0 (BlittableClass, 1);
1565 typedef struct OSVERSIONINFO_STRUCT
1569 } OSVERSIONINFO_STRUCT;
1571 LIBTEST_API int STDCALL
1572 MyGetVersionEx (OSVERSIONINFO_STRUCT *osvi)
1575 // printf ("GOT %d %d\n", osvi->a, osvi->b);
1580 return osvi->a + osvi->b;
1583 LIBTEST_API int STDCALL
1584 BugGetVersionEx (int a, int b, int c, int d, int e, int f, int g, int h, OSVERSIONINFO_STRUCT *osvi)
1587 // printf ("GOT %d %d\n", osvi->a, osvi->b);
1592 return osvi->a + osvi->b;
1595 LIBTEST_API int STDCALL
1596 mono_test_marshal_point (point pt)
1598 // printf("point %g %g\n", pt.x, pt.y);
1599 if (pt.x == 1.25 && pt.y == 3.5)
1610 LIBTEST_API int STDCALL
1611 mono_test_marshal_mixed_point (mixed_point pt)
1613 // printf("mixed point %d %g\n", pt.x, pt.y);
1614 if (pt.x == 5 && pt.y == 6.75)
1620 LIBTEST_API int STDCALL
1621 mono_test_marshal_mixed_point_2 (mixed_point *pt)
1623 if (pt->x != 5 || pt->y != 6.75)
1632 LIBTEST_API int STDCALL
1633 marshal_test_ref_bool(int i, char *b1, short *b2, int *b3)
1636 if (*b1 != 0 && *b1 != 1)
1638 if (*b2 != 0 && *b2 != -1) /* variant_bool */
1640 if (*b3 != 0 && *b3 != 1)
1642 if (i == ((*b1 << 2) | (-*b2 << 1) | *b3))
1654 short b2; /* variant_bool */
1658 LIBTEST_API int STDCALL
1659 marshal_test_bool_struct(struct BoolStruct *s)
1662 if (s->b1 != 0 && s->b1 != 1)
1664 if (s->b2 != 0 && s->b2 != -1)
1666 if (s->b3 != 0 && s->b3 != 1)
1668 if (s->i == ((s->b1 << 2) | (-s->b2 << 1) | s->b3))
1685 LIBTEST_API int STDCALL
1686 mono_test_marshal_long_struct (LongStruct *s)
1688 return s->i + s->l.l;
1691 LIBTEST_API void STDCALL
1692 mono_test_last_error (int err)
1701 LIBTEST_API int STDCALL
1702 mono_test_asany (void *ptr, int what)
1706 return (*(int*)ptr == 5) ? 0 : 1;
1708 return strcmp (ptr, "ABC") == 0 ? 0 : 1;
1710 simplestruct2 ss = *(simplestruct2*)ptr;
1712 if (ss.a == 0 && ss.b == 1 && ss.c == 0 &&
1713 !strcmp (ss.d, "TEST") &&
1714 ss.e == 99 && ss.f == 1.5 && ss.g == 42 && ss.h == (guint64)123)
1720 GError *error = NULL;
1723 s = g_utf16_to_utf8 (ptr, -1, NULL, NULL, &error);
1728 if (!strcmp (s, "ABC")) {
1738 g_assert_not_reached ();
1752 LIBTEST_API int STDCALL
1753 mono_test_marshal_asany_in (void* ptr)
1755 AsAnyStruct* asAny = ptr;
1756 int res = asAny->i + asAny->j + asAny->k;
1761 LIBTEST_API int STDCALL
1762 mono_test_marshal_asany_inout (void* ptr)
1764 AsAnyStruct* asAny = ptr;
1765 int res = asAny->i + asAny->j + asAny->k;
1767 marshal_free (asAny->s);
1777 LIBTEST_API int STDCALL
1778 mono_test_marshal_asany_out (void* ptr)
1780 AsAnyStruct* asAny = ptr;
1781 int res = asAny->i + asAny->j + asAny->k;
1792 * AMD64 marshalling tests.
1795 typedef struct amd64_struct1 {
1802 LIBTEST_API amd64_struct1 STDCALL
1803 mono_test_marshal_amd64_pass_return_struct1 (amd64_struct1 s)
1813 LIBTEST_API amd64_struct1 STDCALL
1814 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)
1819 s.l += 1 + i1 + i2 + i3 + i4 + i5 + i6 + i7 + i8;
1824 typedef struct amd64_struct2 {
1829 LIBTEST_API amd64_struct2 STDCALL
1830 mono_test_marshal_amd64_pass_return_struct2 (amd64_struct2 s)
1838 typedef struct amd64_struct3 {
1842 LIBTEST_API amd64_struct3 STDCALL
1843 mono_test_marshal_amd64_pass_return_struct3 (amd64_struct3 s)
1850 typedef struct amd64_struct4 {
1854 LIBTEST_API amd64_struct4 STDCALL
1855 mono_test_marshal_amd64_pass_return_struct4 (amd64_struct4 s)
1864 * IA64 marshalling tests.
1866 typedef struct test_struct5 {
1870 LIBTEST_API test_struct5 STDCALL
1871 mono_test_marshal_ia64_pass_return_struct5 (double d1, double d2, test_struct5 s, int i, double d3, double d4)
1873 s.d1 += d1 + d2 + i;
1874 s.d2 += d3 + d4 + i;
1879 typedef struct test_struct6 {
1883 LIBTEST_API test_struct6 STDCALL
1884 mono_test_marshal_ia64_pass_return_struct6 (double d1, double d2, test_struct6 s, int i, double d3, double d4)
1886 s.d1 += d1 + d2 + i;
1892 static guint32 custom_res [2];
1894 LIBTEST_API void* STDCALL
1895 mono_test_marshal_pass_return_custom (int i, guint32 *ptr, int j)
1897 /* ptr will be freed by CleanupNative, so make a copy */
1898 custom_res [0] = 0; /* not allocated by AllocHGlobal */
1899 custom_res [1] = ptr [1];
1904 LIBTEST_API int STDCALL
1905 mono_test_marshal_pass_out_custom (int i, guint32 **ptr, int j)
1908 custom_res [1] = i + j + 10;
1915 LIBTEST_API int STDCALL
1916 mono_test_marshal_pass_inout_custom (int i, guint32 *ptr, int j)
1919 ptr [1] = i + ptr [1] + j;
1924 LIBTEST_API int STDCALL
1925 mono_test_marshal_pass_out_byval_custom (int i, guint32 *ptr, int j)
1927 return ptr == NULL ? 0 : 1;
1930 LIBTEST_API int STDCALL
1931 mono_test_marshal_pass_byref_custom (int i, guint32 **ptr, int j)
1938 LIBTEST_API void* STDCALL
1939 mono_test_marshal_pass_return_custom2 (int i, guint32 *ptr, int j)
1941 g_assert_not_reached ();
1946 LIBTEST_API void* STDCALL
1947 mono_test_marshal_pass_return_custom_null (int i, guint32 *ptr, int j)
1949 g_assert (ptr == NULL);
1954 typedef void *(STDCALL *PassReturnPtrDelegate) (void *ptr);
1956 LIBTEST_API int STDCALL
1957 mono_test_marshal_pass_return_custom_in_delegate (PassReturnPtrDelegate del)
1971 /* FIXME: Freed with FreeHGlobal */
1979 LIBTEST_API int STDCALL
1980 mono_test_marshal_pass_return_custom_null_in_delegate (PassReturnPtrDelegate del)
1982 void *ptr = del (NULL);
1984 return (ptr == NULL) ? 15 : 0;
1987 typedef void (STDCALL *CustomOutParamDelegate) (void **pptr);
1989 LIBTEST_API int STDCALL
1990 mono_test_marshal_custom_out_param_delegate (CustomOutParamDelegate del)
2002 typedef int (STDCALL *ReturnEnumDelegate) (int e);
2004 LIBTEST_API int STDCALL
2005 mono_test_marshal_return_enum_delegate (ReturnEnumDelegate func)
2015 typedef BlittableStruct (STDCALL *SimpleDelegate10) (BlittableStruct ss);
2017 LIBTEST_API int STDCALL
2018 mono_test_marshal_blittable_struct_delegate (SimpleDelegate10 delegate)
2020 BlittableStruct ss, res;
2027 res = delegate (ss);
2028 if (! ((res.a == -1) && (res.b == -2) && (res.c == -3) && (res.d == -55)))
2034 LIBTEST_API int STDCALL
2035 mono_test_stdcall_name_mangling (int a, int b, int c)
2041 mono_test_stdcall_mismatch_1 (int a, int b, int c)
2046 LIBTEST_API int STDCALL
2047 mono_test_stdcall_mismatch_2 (int a, int b, int c)
2053 * PASSING AND RETURNING SMALL STRUCTURES FROM DELEGATES TESTS
2060 typedef SmallStruct1 (STDCALL *SmallStructDelegate1) (SmallStruct1 ss);
2062 LIBTEST_API int STDCALL
2063 mono_test_marshal_small_struct_delegate1 (SmallStructDelegate1 delegate)
2065 SmallStruct1 ss, res;
2069 res = delegate (ss);
2070 if (! (res.i == -1))
2080 typedef SmallStruct2 (STDCALL *SmallStructDelegate2) (SmallStruct2 ss);
2082 LIBTEST_API int STDCALL
2083 mono_test_marshal_small_struct_delegate2 (SmallStructDelegate2 delegate)
2085 SmallStruct2 ss, res;
2090 res = delegate (ss);
2091 if (! ((res.i == -2) && (res.j == -3)))
2102 typedef SmallStruct3 (STDCALL *SmallStructDelegate3) (SmallStruct3 ss);
2104 LIBTEST_API int STDCALL
2105 mono_test_marshal_small_struct_delegate3 (SmallStructDelegate3 delegate)
2107 SmallStruct3 ss, res;
2112 res = delegate (ss);
2113 if (! ((res.i == -1) && (res.j == -2)))
2123 typedef SmallStruct4 (STDCALL *SmallStructDelegate4) (SmallStruct4 ss);
2125 LIBTEST_API int STDCALL
2126 mono_test_marshal_small_struct_delegate4 (SmallStructDelegate4 delegate)
2128 SmallStruct4 ss, res;
2132 res = delegate (ss);
2133 if (! (res.i == -1))
2143 typedef SmallStruct5 (STDCALL *SmallStructDelegate5) (SmallStruct5 ss);
2145 LIBTEST_API int STDCALL
2146 mono_test_marshal_small_struct_delegate5 (SmallStructDelegate5 delegate)
2148 SmallStruct5 ss, res;
2152 res = delegate (ss);
2153 if (! (res.i == -5))
2163 typedef SmallStruct6 (STDCALL *SmallStructDelegate6) (SmallStruct6 ss);
2165 LIBTEST_API int STDCALL
2166 mono_test_marshal_small_struct_delegate6 (SmallStructDelegate6 delegate)
2168 SmallStruct6 ss, res;
2173 res = delegate (ss);
2174 if (! ((res.i == -1) && (res.j == -2)))
2185 typedef SmallStruct7 (STDCALL *SmallStructDelegate7) (SmallStruct7 ss);
2187 LIBTEST_API int STDCALL
2188 mono_test_marshal_small_struct_delegate7 (SmallStructDelegate7 delegate)
2190 SmallStruct7 ss, res;
2195 res = delegate (ss);
2196 if (! ((res.i == -1) && (res.j == -2)))
2206 typedef SmallStruct8 (STDCALL *SmallStructDelegate8) (SmallStruct8 ss);
2208 LIBTEST_API int STDCALL
2209 mono_test_marshal_small_struct_delegate8 (SmallStructDelegate8 delegate)
2211 SmallStruct8 ss, res;
2215 res = delegate (ss);
2216 if (! ((res.i == -1.0)))
2226 typedef SmallStruct9 (STDCALL *SmallStructDelegate9) (SmallStruct9 ss);
2228 LIBTEST_API int STDCALL
2229 mono_test_marshal_small_struct_delegate9 (SmallStructDelegate9 delegate)
2231 SmallStruct9 ss, res;
2235 res = delegate (ss);
2236 if (! ((res.i == -1.0)))
2246 typedef SmallStruct10 (STDCALL *SmallStructDelegate10) (SmallStruct10 ss);
2248 LIBTEST_API int STDCALL
2249 mono_test_marshal_small_struct_delegate10 (SmallStructDelegate10 delegate)
2251 SmallStruct10 ss, res;
2256 res = delegate (ss);
2257 if (! ((res.i == -1.0) && (res.j == -2.0)))
2268 typedef SmallStruct11 (STDCALL *SmallStructDelegate11) (SmallStruct11 ss);
2270 LIBTEST_API int STDCALL
2271 mono_test_marshal_small_struct_delegate11 (SmallStructDelegate11 delegate)
2273 SmallStruct11 ss, res;
2278 res = delegate (ss);
2279 if (! ((res.i == -1.0) && (res.j == -2)))
2285 typedef int (STDCALL *ArrayDelegate) (int i, char *j, void *arr);
2287 LIBTEST_API int STDCALL
2288 mono_test_marshal_array_delegate (void *arr, int len, ArrayDelegate del)
2290 return del (len, NULL, arr);
2293 typedef int (STDCALL *ArrayDelegateLong) (gint64 i, char *j, void *arr);
2295 LIBTEST_API int STDCALL
2296 mono_test_marshal_array_delegate_long (void *arr, gint64 len, ArrayDelegateLong del)
2298 return del (len, NULL, arr);
2301 LIBTEST_API int STDCALL
2302 mono_test_marshal_out_array_delegate (int *arr, int len, ArrayDelegate del)
2304 del (len, NULL, arr);
2306 if ((arr [0] != 1) || (arr [1] != 2))
2312 typedef gunichar2* (STDCALL *UnicodeStringDelegate) (gunichar2 *message);
2314 LIBTEST_API int STDCALL
2315 mono_test_marshal_return_unicode_string_delegate (UnicodeStringDelegate del)
2317 const char m[] = "abcdef";
2318 gunichar2 *s2, *res;
2321 s2 = g_utf8_to_utf16 (m, -1, NULL, &len, NULL);
2330 LIBTEST_API int STDCALL
2331 mono_test_marshal_out_string_array_delegate (char **arr, int len, ArrayDelegate del)
2333 del (len, NULL, arr);
2335 if (!strcmp (arr [0], "ABC") && !strcmp (arr [1], "DEF"))
2341 typedef int (*CdeclDelegate) (int i, int j);
2343 LIBTEST_API int STDCALL
2344 mono_test_marshal_cdecl_delegate (CdeclDelegate del)
2348 for (i = 0; i < 1000; ++i)
2354 typedef char** (STDCALL *ReturnStringArrayDelegate) (int i);
2356 LIBTEST_API int STDCALL
2357 mono_test_marshal_return_string_array_delegate (ReturnStringArrayDelegate d)
2365 if (strcmp (arr [0], "ABC") || strcmp (arr [1], "DEF"))
2375 typedef int (STDCALL *ByrefStringDelegate) (char **s);
2377 LIBTEST_API int STDCALL
2378 mono_test_marshal_byref_string_delegate (ByrefStringDelegate d)
2380 char *s = (char*)"ABC";
2387 if (!strcmp (s, "DEF"))
2397 LIBTEST_API int STDCALL
2398 add_delegate (int i, int j)
2403 LIBTEST_API gpointer STDCALL
2404 mono_test_marshal_return_fnptr (void)
2406 return &add_delegate;
2409 LIBTEST_API int STDCALL
2412 printf ("codigo %x\n", code);
2420 LIBTEST_API HandleRef STDCALL
2421 mono_xr_as_handle (int code)
2425 memset (&ref, 0, sizeof (ref));
2437 LIBTEST_API int STDCALL
2438 mono_safe_handle_struct_ref (HandleStructs *x)
2440 printf ("Dingus Ref! \n");
2441 printf ("Values: %d %d %p %p\n", x->a, x->b, x->handle1, x->handle2);
2447 if (x->handle1 != (void*) 0x7080feed)
2450 if (x->handle2 != (void*) 0x1234abcd)
2456 LIBTEST_API int STDCALL
2457 mono_safe_handle_struct (HandleStructs x)
2459 printf ("Dingus Standard! \n");
2460 printf ("Values: %d %d %p %p\n", x.a, x.b, x.handle1, x.handle2);
2466 if (x.handle1 != (void*) 0x7080feed)
2469 if (x.handle2 != (void*) 0x1234abcd)
2479 LIBTEST_API int STDCALL
2480 mono_safe_handle_struct_simple (TrivialHandle x)
2482 printf ("The value is %p\n", x.a);
2483 return ((int)(gsize)x.a) * 2;
2486 LIBTEST_API int STDCALL
2487 mono_safe_handle_return (void)
2492 LIBTEST_API void STDCALL
2493 mono_safe_handle_ref (void **handle)
2496 *handle = (void *) 0xbad;
2500 *handle = (void *) 0x800d;
2503 LIBTEST_API double STDCALL
2504 mono_test_marshal_date_time (double d, double *d2)
2576 VT_USERDEFINED = 29,
2584 VT_STREAMED_OBJECT = 68,
2585 VT_STORED_OBJECT = 69,
2586 VT_BLOB_OBJECT = 70,
2594 void VariantInit(VARIANT* vt)
2611 LIBTEST_API int STDCALL
2612 mono_test_marshal_bstr_in(gunichar2* bstr)
2615 gchar* bstr_utf8 = g_utf16_to_utf8 (bstr, -1, NULL, NULL, NULL);
2616 result = strcmp("mono_test_marshal_bstr_in", bstr_utf8);
2623 LIBTEST_API int STDCALL
2624 mono_test_marshal_bstr_out(gunichar2** bstr)
2626 *bstr = marshal_bstr_alloc ("mono_test_marshal_bstr_out");
2630 LIBTEST_API int STDCALL
2631 mono_test_marshal_bstr_in_null(gunichar2* bstr)
2638 LIBTEST_API int STDCALL
2639 mono_test_marshal_bstr_out_null(gunichar2** bstr)
2645 LIBTEST_API int STDCALL
2646 mono_test_marshal_variant_in_sbyte(VARIANT variant)
2648 if (variant.vt == VT_I1 && variant.cVal == 100)
2653 LIBTEST_API int STDCALL
2654 mono_test_marshal_variant_in_byte(VARIANT variant)
2656 if (variant.vt == VT_UI1 && variant.bVal == 100)
2661 LIBTEST_API int STDCALL
2662 mono_test_marshal_variant_in_short(VARIANT variant)
2664 if (variant.vt == VT_I2 && variant.iVal == 314)
2669 LIBTEST_API int STDCALL
2670 mono_test_marshal_variant_in_ushort(VARIANT variant)
2672 if (variant.vt == VT_UI2 && variant.uiVal == 314)
2677 LIBTEST_API int STDCALL
2678 mono_test_marshal_variant_in_int(VARIANT variant)
2680 if (variant.vt == VT_I4 && variant.lVal == 314)
2685 LIBTEST_API int STDCALL
2686 mono_test_marshal_variant_in_uint(VARIANT variant)
2688 if (variant.vt == VT_UI4 && variant.ulVal == 314)
2693 LIBTEST_API int STDCALL
2694 mono_test_marshal_variant_in_long(VARIANT variant)
2696 if (variant.vt == VT_I8 && variant.llVal == 314)
2701 LIBTEST_API int STDCALL
2702 mono_test_marshal_variant_in_ulong(VARIANT variant)
2704 if (variant.vt == VT_UI8 && variant.ullVal == 314)
2709 LIBTEST_API int STDCALL
2710 mono_test_marshal_variant_in_float(VARIANT variant)
2712 if (variant.vt == VT_R4 && (variant.fltVal - 3.14)/3.14 < .001)
2717 LIBTEST_API int STDCALL
2718 mono_test_marshal_variant_in_double(VARIANT variant)
2720 if (variant.vt == VT_R8 && (variant.dblVal - 3.14)/3.14 < .001)
2725 LIBTEST_API int STDCALL
2726 mono_test_marshal_variant_in_bstr(VARIANT variant)
2729 gchar* bstr_utf8 = g_utf16_to_utf8 (variant.bstrVal, -1, NULL, NULL, NULL);
2730 result = strcmp("PI", bstr_utf8);
2733 if (variant.vt == VT_BSTR && !result)
2738 LIBTEST_API int STDCALL
2739 mono_test_marshal_variant_in_bool_true (VARIANT variant)
2741 if (variant.vt == VT_BOOL && variant.boolVal == VARIANT_TRUE)
2746 LIBTEST_API int STDCALL
2747 mono_test_marshal_variant_in_bool_false (VARIANT variant)
2749 if (variant.vt == VT_BOOL && variant.boolVal == VARIANT_FALSE)
2754 LIBTEST_API int STDCALL
2755 mono_test_marshal_variant_out_sbyte(VARIANT* variant)
2757 variant->vt = VT_I1;
2758 variant->cVal = 100;
2763 LIBTEST_API int STDCALL
2764 mono_test_marshal_variant_out_sbyte_byref(VARIANT* variant)
2766 variant->vt = VT_I1|VT_BYREF;
2767 variant->byref = marshal_alloc(1);
2768 *((gint8*)variant->byref) = 100;
2773 LIBTEST_API int STDCALL
2774 mono_test_marshal_variant_out_byte(VARIANT* variant)
2776 variant->vt = VT_UI1;
2777 variant->bVal = 100;
2782 LIBTEST_API int STDCALL
2783 mono_test_marshal_variant_out_byte_byref(VARIANT* variant)
2785 variant->vt = VT_UI1|VT_BYREF;
2786 variant->byref = marshal_alloc(1);
2787 *((gint8*)variant->byref) = 100;
2792 LIBTEST_API int STDCALL
2793 mono_test_marshal_variant_out_short(VARIANT* variant)
2795 variant->vt = VT_I2;
2796 variant->iVal = 314;
2801 LIBTEST_API int STDCALL
2802 mono_test_marshal_variant_out_short_byref(VARIANT* variant)
2804 variant->vt = VT_I2|VT_BYREF;
2805 variant->byref = marshal_alloc(2);
2806 *((gint16*)variant->byref) = 314;
2811 LIBTEST_API int STDCALL
2812 mono_test_marshal_variant_out_ushort(VARIANT* variant)
2814 variant->vt = VT_UI2;
2815 variant->uiVal = 314;
2820 LIBTEST_API int STDCALL
2821 mono_test_marshal_variant_out_ushort_byref(VARIANT* variant)
2823 variant->vt = VT_UI2|VT_BYREF;
2824 variant->byref = marshal_alloc(2);
2825 *((guint16*)variant->byref) = 314;
2830 LIBTEST_API int STDCALL
2831 mono_test_marshal_variant_out_int(VARIANT* variant)
2833 variant->vt = VT_I4;
2834 variant->lVal = 314;
2839 LIBTEST_API int STDCALL
2840 mono_test_marshal_variant_out_int_byref(VARIANT* variant)
2842 variant->vt = VT_I4|VT_BYREF;
2843 variant->byref = marshal_alloc(4);
2844 *((gint32*)variant->byref) = 314;
2849 LIBTEST_API int STDCALL
2850 mono_test_marshal_variant_out_uint(VARIANT* variant)
2852 variant->vt = VT_UI4;
2853 variant->ulVal = 314;
2858 LIBTEST_API int STDCALL
2859 mono_test_marshal_variant_out_uint_byref(VARIANT* variant)
2861 variant->vt = VT_UI4|VT_BYREF;
2862 variant->byref = marshal_alloc(4);
2863 *((guint32*)variant->byref) = 314;
2868 LIBTEST_API int STDCALL
2869 mono_test_marshal_variant_out_long(VARIANT* variant)
2871 variant->vt = VT_I8;
2872 variant->llVal = 314;
2877 LIBTEST_API int STDCALL
2878 mono_test_marshal_variant_out_long_byref(VARIANT* variant)
2880 variant->vt = VT_I8|VT_BYREF;
2881 variant->byref = marshal_alloc(8);
2882 *((gint64*)variant->byref) = 314;
2887 LIBTEST_API int STDCALL
2888 mono_test_marshal_variant_out_ulong(VARIANT* variant)
2890 variant->vt = VT_UI8;
2891 variant->ullVal = 314;
2896 LIBTEST_API int STDCALL
2897 mono_test_marshal_variant_out_ulong_byref(VARIANT* variant)
2899 variant->vt = VT_UI8|VT_BYREF;
2900 variant->byref = marshal_alloc(8);
2901 *((guint64*)variant->byref) = 314;
2906 LIBTEST_API int STDCALL
2907 mono_test_marshal_variant_out_float(VARIANT* variant)
2909 variant->vt = VT_R4;
2910 variant->fltVal = 3.14;
2915 LIBTEST_API int STDCALL
2916 mono_test_marshal_variant_out_float_byref(VARIANT* variant)
2918 variant->vt = VT_R4|VT_BYREF;
2919 variant->byref = marshal_alloc(4);
2920 *((float*)variant->byref) = 3.14;
2925 LIBTEST_API int STDCALL
2926 mono_test_marshal_variant_out_double(VARIANT* variant)
2928 variant->vt = VT_R8;
2929 variant->dblVal = 3.14;
2934 LIBTEST_API int STDCALL
2935 mono_test_marshal_variant_out_double_byref(VARIANT* variant)
2937 variant->vt = VT_R8|VT_BYREF;
2938 variant->byref = marshal_alloc(8);
2939 *((double*)variant->byref) = 3.14;
2944 LIBTEST_API int STDCALL
2945 mono_test_marshal_variant_out_bstr(VARIANT* variant)
2947 variant->vt = VT_BSTR;
2948 variant->bstrVal = marshal_bstr_alloc("PI");
2953 LIBTEST_API int STDCALL
2954 mono_test_marshal_variant_out_bstr_byref(VARIANT* variant)
2956 variant->vt = VT_BSTR|VT_BYREF;
2957 variant->byref = marshal_alloc(sizeof(gpointer));
2958 *((gunichar**)variant->byref) = (gunichar*)marshal_bstr_alloc("PI");
2963 LIBTEST_API int STDCALL
2964 mono_test_marshal_variant_out_bool_true (VARIANT* variant)
2966 variant->vt = VT_BOOL;
2967 variant->boolVal = VARIANT_TRUE;
2972 LIBTEST_API int STDCALL
2973 mono_test_marshal_variant_out_bool_true_byref (VARIANT* variant)
2975 variant->vt = VT_BOOL|VT_BYREF;
2976 variant->byref = marshal_alloc(2);
2977 *((gint16*)variant->byref) = VARIANT_TRUE;
2982 LIBTEST_API int STDCALL
2983 mono_test_marshal_variant_out_bool_false (VARIANT* variant)
2985 variant->vt = VT_BOOL;
2986 variant->boolVal = VARIANT_FALSE;
2991 LIBTEST_API int STDCALL
2992 mono_test_marshal_variant_out_bool_false_byref (VARIANT* variant)
2994 variant->vt = VT_BOOL|VT_BYREF;
2995 variant->byref = marshal_alloc(2);
2996 *((gint16*)variant->byref) = VARIANT_FALSE;
3001 typedef int (STDCALL *VarFunc) (int vt, VARIANT variant);
3002 typedef int (STDCALL *VarRefFunc) (int vt, VARIANT* variant);
3004 LIBTEST_API int STDCALL
3005 mono_test_marshal_variant_in_sbyte_unmanaged(VarFunc func)
3010 return func (VT_I1, vt);
3013 LIBTEST_API int STDCALL
3014 mono_test_marshal_variant_in_byte_unmanaged(VarFunc func)
3019 return func (VT_UI1, vt);
3022 LIBTEST_API int STDCALL
3023 mono_test_marshal_variant_in_short_unmanaged(VarFunc func)
3028 return func (VT_I2, vt);
3031 LIBTEST_API int STDCALL
3032 mono_test_marshal_variant_in_ushort_unmanaged(VarFunc func)
3037 return func (VT_UI2, vt);
3040 LIBTEST_API int STDCALL
3041 mono_test_marshal_variant_in_int_unmanaged(VarFunc func)
3046 return func (VT_I4, vt);
3049 LIBTEST_API int STDCALL
3050 mono_test_marshal_variant_in_uint_unmanaged(VarFunc func)
3055 return func (VT_UI4, vt);
3058 LIBTEST_API int STDCALL
3059 mono_test_marshal_variant_in_long_unmanaged(VarFunc func)
3064 return func (VT_I8, vt);
3067 LIBTEST_API int STDCALL
3068 mono_test_marshal_variant_in_ulong_unmanaged(VarFunc func)
3073 return func (VT_UI8, vt);
3076 LIBTEST_API int STDCALL
3077 mono_test_marshal_variant_in_float_unmanaged(VarFunc func)
3082 return func (VT_R4, vt);
3085 LIBTEST_API int STDCALL
3086 mono_test_marshal_variant_in_double_unmanaged(VarFunc func)
3091 return func (VT_R8, vt);
3094 LIBTEST_API int STDCALL
3095 mono_test_marshal_variant_in_bstr_unmanaged(VarFunc func)
3099 vt.bstrVal = marshal_bstr_alloc("PI");
3100 return func (VT_BSTR, vt);
3103 LIBTEST_API int STDCALL
3104 mono_test_marshal_variant_in_bool_true_unmanaged(VarFunc func)
3108 vt.boolVal = VARIANT_TRUE;
3109 return func (VT_BOOL, vt);
3112 LIBTEST_API int STDCALL
3113 mono_test_marshal_variant_in_bool_false_unmanaged(VarFunc func)
3117 vt.boolVal = VARIANT_FALSE;
3118 return func (VT_BOOL, vt);
3121 LIBTEST_API int STDCALL
3122 mono_test_marshal_variant_out_sbyte_unmanaged(VarRefFunc func)
3127 if (vt.vt == VT_I1 && vt.cVal == -100)
3132 LIBTEST_API int STDCALL
3133 mono_test_marshal_variant_out_byte_unmanaged(VarRefFunc func)
3138 if (vt.vt == VT_UI1 && vt.bVal == 100)
3143 LIBTEST_API int STDCALL
3144 mono_test_marshal_variant_out_short_unmanaged(VarRefFunc func)
3149 if (vt.vt == VT_I2 && vt.iVal == -100)
3154 LIBTEST_API int STDCALL
3155 mono_test_marshal_variant_out_ushort_unmanaged(VarRefFunc func)
3160 if (vt.vt == VT_UI2 && vt.uiVal == 100)
3165 LIBTEST_API int STDCALL
3166 mono_test_marshal_variant_out_int_unmanaged(VarRefFunc func)
3171 if (vt.vt == VT_I4 && vt.lVal == -100)
3176 LIBTEST_API int STDCALL
3177 mono_test_marshal_variant_out_uint_unmanaged(VarRefFunc func)
3182 if (vt.vt == VT_UI4 && vt.ulVal == 100)
3187 LIBTEST_API int STDCALL
3188 mono_test_marshal_variant_out_long_unmanaged(VarRefFunc func)
3193 if (vt.vt == VT_I8 && vt.llVal == -100)
3198 LIBTEST_API int STDCALL
3199 mono_test_marshal_variant_out_ulong_unmanaged(VarRefFunc func)
3204 if (vt.vt == VT_UI8 && vt.ullVal == 100)
3209 LIBTEST_API int STDCALL
3210 mono_test_marshal_variant_out_float_unmanaged(VarRefFunc func)
3215 if (vt.vt == VT_R4 && fabs (vt.fltVal - 3.14f) < 1e-10)
3220 LIBTEST_API int STDCALL
3221 mono_test_marshal_variant_out_double_unmanaged(VarRefFunc func)
3226 if (vt.vt == VT_R8 && fabs (vt.dblVal - 3.14) < 1e-10)
3231 LIBTEST_API int STDCALL
3232 mono_test_marshal_variant_out_bstr_unmanaged(VarRefFunc func)
3240 func (VT_BSTR, &vt);
3241 bstr_utf8 = g_utf16_to_utf8 (vt.bstrVal, -1, NULL, NULL, NULL);
3242 result = strcmp("PI", bstr_utf8);
3244 if (vt.vt == VT_BSTR && !result)
3249 LIBTEST_API int STDCALL
3250 mono_test_marshal_variant_out_bool_true_unmanaged(VarRefFunc func)
3254 func (VT_BOOL, &vt);
3255 if (vt.vt == VT_BOOL && vt.boolVal == VARIANT_TRUE)
3260 LIBTEST_API int STDCALL
3261 mono_test_marshal_variant_out_bool_false_unmanaged(VarRefFunc func)
3265 func (VT_BOOL, &vt);
3266 if (vt.vt == VT_BOOL && vt.boolVal == VARIANT_TRUE)
3271 typedef struct MonoComObject MonoComObject;
3275 int (STDCALL *QueryInterface)(MonoComObject* pUnk, gpointer riid, gpointer* ppv);
3276 int (STDCALL *AddRef)(MonoComObject* pUnk);
3277 int (STDCALL *Release)(MonoComObject* pUnk);
3278 int (STDCALL *get_ITest)(MonoComObject* pUnk, MonoComObject* *ppUnk);
3279 int (STDCALL *SByteIn)(MonoComObject* pUnk, char a);
3280 int (STDCALL *ByteIn)(MonoComObject* pUnk, unsigned char a);
3281 int (STDCALL *ShortIn)(MonoComObject* pUnk, short a);
3282 int (STDCALL *UShortIn)(MonoComObject* pUnk, unsigned short a);
3283 int (STDCALL *IntIn)(MonoComObject* pUnk, int a);
3284 int (STDCALL *UIntIn)(MonoComObject* pUnk, unsigned int a);
3285 int (STDCALL *LongIn)(MonoComObject* pUnk, gint64 a);
3286 int (STDCALL *ULongIn)(MonoComObject* pUnk, guint64 a);
3287 int (STDCALL *FloatIn)(MonoComObject* pUnk, float a);
3288 int (STDCALL *DoubleIn)(MonoComObject* pUnk, double a);
3289 int (STDCALL *ITestIn)(MonoComObject* pUnk, MonoComObject* pUnk2);
3290 int (STDCALL *ITestOut)(MonoComObject* pUnk, MonoComObject* *ppUnk);
3293 struct MonoComObject
3299 static GUID IID_ITest = {0, 0, 0, {0,0,0,0,0,0,0,1}};
3300 static GUID IID_IMonoUnknown = {0, 0, 0, {0xc0,0,0,0,0,0,0,0x46}};
3301 static GUID IID_IMonoDispatch = {0x00020400, 0, 0, {0xc0,0,0,0,0,0,0,0x46}};
3303 LIBTEST_API int STDCALL
3304 MonoQueryInterface(MonoComObject* pUnk, gpointer riid, gpointer* ppv)
3308 if (!memcmp(riid, &IID_IMonoUnknown, sizeof(GUID))) {
3312 else if (!memcmp(riid, &IID_ITest, sizeof(GUID))) {
3316 else if (!memcmp(riid, &IID_IMonoDispatch, sizeof(GUID))) {
3320 return 0x80004002; //E_NOINTERFACE;
3323 LIBTEST_API int STDCALL
3324 MonoAddRef(MonoComObject* pUnk)
3326 return ++(pUnk->m_ref);
3329 LIBTEST_API int STDCALL
3330 MonoRelease(MonoComObject* pUnk)
3332 return --(pUnk->m_ref);
3335 LIBTEST_API int STDCALL
3336 SByteIn(MonoComObject* pUnk, char a)
3341 LIBTEST_API int STDCALL
3342 ByteIn(MonoComObject* pUnk, unsigned char a)
3347 LIBTEST_API int STDCALL
3348 ShortIn(MonoComObject* pUnk, short a)
3353 LIBTEST_API int STDCALL
3354 UShortIn(MonoComObject* pUnk, unsigned short a)
3359 LIBTEST_API int STDCALL
3360 IntIn(MonoComObject* pUnk, int a)
3365 LIBTEST_API int STDCALL
3366 UIntIn(MonoComObject* pUnk, unsigned int a)
3371 LIBTEST_API int STDCALL
3372 LongIn(MonoComObject* pUnk, gint64 a)
3377 LIBTEST_API int STDCALL
3378 ULongIn(MonoComObject* pUnk, guint64 a)
3383 LIBTEST_API int STDCALL
3384 FloatIn(MonoComObject* pUnk, float a)
3389 LIBTEST_API int STDCALL
3390 DoubleIn(MonoComObject* pUnk, double a)
3395 LIBTEST_API int STDCALL
3396 ITestIn(MonoComObject* pUnk, MonoComObject *pUnk2)
3401 LIBTEST_API int STDCALL
3402 ITestOut(MonoComObject* pUnk, MonoComObject* *ppUnk)
3407 static void create_com_object (MonoComObject** pOut);
3409 LIBTEST_API int STDCALL
3410 get_ITest(MonoComObject* pUnk, MonoComObject* *ppUnk)
3412 create_com_object (ppUnk);
3416 static void create_com_object (MonoComObject** pOut)
3418 *pOut = marshal_new0 (MonoComObject, 1);
3419 (*pOut)->vtbl = marshal_new0 (MonoIUnknown, 1);
3422 (*pOut)->vtbl->QueryInterface = MonoQueryInterface;
3423 (*pOut)->vtbl->AddRef = MonoAddRef;
3424 (*pOut)->vtbl->Release = MonoRelease;
3425 (*pOut)->vtbl->SByteIn = SByteIn;
3426 (*pOut)->vtbl->ByteIn = ByteIn;
3427 (*pOut)->vtbl->ShortIn = ShortIn;
3428 (*pOut)->vtbl->UShortIn = UShortIn;
3429 (*pOut)->vtbl->IntIn = IntIn;
3430 (*pOut)->vtbl->UIntIn = UIntIn;
3431 (*pOut)->vtbl->LongIn = LongIn;
3432 (*pOut)->vtbl->ULongIn = ULongIn;
3433 (*pOut)->vtbl->FloatIn = FloatIn;
3434 (*pOut)->vtbl->DoubleIn = DoubleIn;
3435 (*pOut)->vtbl->ITestIn = ITestIn;
3436 (*pOut)->vtbl->ITestOut = ITestOut;
3437 (*pOut)->vtbl->get_ITest = get_ITest;
3440 static MonoComObject* same_object = NULL;
3442 LIBTEST_API int STDCALL
3443 mono_test_marshal_com_object_create(MonoComObject* *pUnk)
3445 create_com_object (pUnk);
3448 same_object = *pUnk;
3453 LIBTEST_API int STDCALL
3454 mono_test_marshal_com_object_same(MonoComObject* *pUnk)
3456 *pUnk = same_object;
3461 LIBTEST_API int STDCALL
3462 mono_test_marshal_com_object_destroy(MonoComObject *pUnk)
3464 int ref = --(pUnk->m_ref);
3471 LIBTEST_API int STDCALL
3472 mono_test_marshal_com_object_ref_count(MonoComObject *pUnk)
3477 LIBTEST_API int STDCALL
3478 mono_test_marshal_ccw_itest (MonoComObject *pUnk)
3481 MonoComObject* pTest;
3486 hr = pUnk->vtbl->SByteIn (pUnk, -100);
3489 hr = pUnk->vtbl->ByteIn (pUnk, 100);
3492 hr = pUnk->vtbl->ShortIn (pUnk, -100);
3495 hr = pUnk->vtbl->UShortIn (pUnk, 100);
3498 hr = pUnk->vtbl->IntIn (pUnk, -100);
3501 hr = pUnk->vtbl->UIntIn (pUnk, 100);
3504 hr = pUnk->vtbl->LongIn (pUnk, -100);
3507 hr = pUnk->vtbl->ULongIn (pUnk, 100);
3510 hr = pUnk->vtbl->FloatIn (pUnk, 3.14f);
3513 hr = pUnk->vtbl->DoubleIn (pUnk, 3.14);
3516 hr = pUnk->vtbl->ITestIn (pUnk, pUnk);
3519 hr = pUnk->vtbl->ITestOut (pUnk, &pTest);
3527 * mono_method_get_unmanaged_thunk tests
3530 #if defined(__GNUC__) && ((defined(__i386__) && (defined(__linux__) || defined (__APPLE__)) || defined (__FreeBSD__) || defined(__OpenBSD__)) || (defined(__ppc__) && defined(__APPLE__)))
3531 #define ALIGN(size) __attribute__ ((aligned(size)))
3537 /* thunks.cs:TestStruct */
3538 typedef struct _TestStruct {
3543 /* Searches for mono symbols in all loaded modules */
3545 lookup_mono_symbol (const char *symbol_name)
3548 if (g_module_symbol (g_module_open (NULL, G_MODULE_BIND_LAZY), symbol_name, &symbol))
3554 LIBTEST_API gpointer STDCALL
3555 mono_test_marshal_lookup_symbol (const char *symbol_name)
3557 return lookup_mono_symbol (symbol_name);
3560 #define MONO_BEGIN_EFRAME { void *__dummy; void *__region_cookie = mono_threads_enter_gc_unsafe_region ? mono_threads_enter_gc_unsafe_region (&__dummy) : NULL;
3561 #define MONO_END_EFRAME if (mono_threads_exit_gc_unsafe_region) mono_threads_exit_gc_unsafe_region (__region_cookie, &__dummy); }
3564 * test_method_thunk:
3566 * @test_id: the test number
3567 * @test_method_handle: MonoMethod* of the C# test method
3568 * @create_object_method_handle: MonoMethod* of thunks.cs:Test.CreateObject
3570 LIBTEST_API int STDCALL
3571 test_method_thunk (int test_id, gpointer test_method_handle, gpointer create_object_method_handle)
3575 gpointer (*mono_method_get_unmanaged_thunk)(gpointer)
3576 = lookup_mono_symbol ("mono_method_get_unmanaged_thunk");
3578 gpointer (*mono_string_new_wrapper)(const char *)
3579 = lookup_mono_symbol ("mono_string_new_wrapper");
3581 char* (*mono_string_to_utf8)(gpointer)
3582 = lookup_mono_symbol ("mono_string_to_utf8");
3584 gpointer (*mono_object_unbox)(gpointer)
3585 = lookup_mono_symbol ("mono_object_unbox");
3587 gpointer (*mono_threads_enter_gc_unsafe_region) (gpointer)
3588 = lookup_mono_symbol ("mono_threads_enter_gc_unsafe_region");
3590 void (*mono_threads_exit_gc_unsafe_region) (gpointer, gpointer)
3591 = lookup_mono_symbol ("mono_threads_exit_gc_unsafe_region");
3595 gpointer test_method, ex = NULL;
3596 gpointer (STDCALL *CreateObject)(gpointer*);
3600 if (!mono_method_get_unmanaged_thunk) {
3605 test_method = mono_method_get_unmanaged_thunk (test_method_handle);
3611 CreateObject = mono_method_get_unmanaged_thunk (create_object_method_handle);
3612 if (!CreateObject) {
3621 /* thunks.cs:Test.Test0 */
3622 void (STDCALL *F)(gpointer*) = test_method;
3628 /* thunks.cs:Test.Test1 */
3629 int (STDCALL *F)(gpointer*) = test_method;
3630 if (F (&ex) != 42) {
3638 /* thunks.cs:Test.Test2 */
3639 gpointer (STDCALL *F)(gpointer, gpointer*) = test_method;
3640 gpointer str = mono_string_new_wrapper ("foo");
3641 if (str != F (str, &ex)) {
3649 /* thunks.cs:Test.Test3 */
3650 gpointer (STDCALL *F)(gpointer, gpointer, gpointer*);
3655 obj = CreateObject (&ex);
3656 str = mono_string_new_wrapper ("bar");
3658 if (str != F (obj, str, &ex)) {
3666 /* thunks.cs:Test.Test4 */
3667 int (STDCALL *F)(gpointer, gpointer, int, gpointer*);
3672 obj = CreateObject (&ex);
3673 str = mono_string_new_wrapper ("bar");
3675 if (42 != F (obj, str, 42, &ex)) {
3684 /* thunks.cs:Test.Test5 */
3685 int (STDCALL *F)(gpointer, gpointer, int, gpointer*);
3690 obj = CreateObject (&ex);
3691 str = mono_string_new_wrapper ("bar");
3693 F (obj, str, 42, &ex);
3703 /* thunks.cs:Test.Test6 */
3704 int (STDCALL *F)(gpointer, guint8, gint16, gint32, gint64, float, double,
3705 gpointer, gpointer*);
3707 gpointer str = mono_string_new_wrapper ("Test6");
3711 obj = CreateObject (&ex);
3713 res = F (obj, 254, 32700, -245378, 6789600, 3.1415, 3.1415, str, &ex);
3728 /* thunks.cs:Test.Test7 */
3729 gint64 (STDCALL *F)(gpointer*) = test_method;
3730 if (F (&ex) != G_MAXINT64) {
3738 /* thunks.cs:Test.Test8 */
3739 void (STDCALL *F)(guint8*, gint16*, gint32*, gint64*, float*, double*,
3740 gpointer*, gpointer*);
3752 F (&a1, &a2, &a3, &a4, &a5, &a6, &a7, &ex);
3762 (fabs (a5 - 3.1415) < 0.001) &&
3763 (fabs (a6 - 3.1415) < 0.001) &&
3764 strcmp (mono_string_to_utf8 (a7), "Test8") == 0)){
3773 /* thunks.cs:Test.Test9 */
3774 void (STDCALL *F)(guint8*, gint16*, gint32*, gint64*, float*, double*,
3775 gpointer*, gpointer*);
3787 F (&a1, &a2, &a3, &a4, &a5, &a6, &a7, &ex);
3797 /* thunks.cs:Test.Test10 */
3798 void (STDCALL *F)(gpointer*, gpointer*);
3800 gpointer obj1, obj2;
3802 obj1 = obj2 = CreateObject (&ex);
3825 /* thunks.cs:TestStruct.Test0 */
3826 int (STDCALL *F)(gpointer*, gpointer*);
3832 obj = CreateObject (&ex);
3843 a1 = mono_object_unbox (obj);
3865 /* check whether the call was really by value */
3866 if (a1->A != 42 || a1->B != 3.1415) {
3875 /* thunks.cs:TestStruct.Test1 */
3876 void (STDCALL *F)(gpointer, gpointer*);
3881 obj = CreateObject (&ex);
3892 a1 = mono_object_unbox (obj);
3911 if (!(fabs (a1->B - 3.1415) < 0.001)) {
3920 /* thunks.cs:TestStruct.Test2 */
3921 gpointer (STDCALL *F)(gpointer*);
3939 a1 = mono_object_unbox (obj);
3946 if (!(fabs (a1->B - 3.1415) < 0.001)) {
3955 /* thunks.cs:TestStruct.Test3 */
3956 void (STDCALL *F)(gpointer, gpointer*);
3961 obj = CreateObject (&ex);
3972 a1 = mono_object_unbox (obj);
4018 LIBTEST_API int STDCALL
4019 mono_test_Winx64_struct1_in (winx64_struct1 var)
4032 LIBTEST_API int STDCALL
4033 mono_test_Winx64_struct2_in (winx64_struct2 var)
4050 LIBTEST_API int STDCALL
4051 mono_test_Winx64_struct3_in (winx64_struct3 var)
4057 if (var.c != 0x1234)
4070 LIBTEST_API int STDCALL
4071 mono_test_Winx64_struct4_in (winx64_struct4 var)
4077 if (var.c != 0x1234)
4079 if (var.d != 0x87654321)
4091 LIBTEST_API int STDCALL
4092 mono_test_Winx64_struct5_in (winx64_struct5 var)
4110 LIBTEST_API int STDCALL
4111 mono_test_Winx64_struct6_in (winx64_struct6 var)
4122 LIBTEST_API int STDCALL
4123 mono_test_Winx64_structs_in1 (winx64_struct1 var1,
4124 winx64_struct2 var2,
4125 winx64_struct3 var3,
4126 winx64_struct4 var4)
4140 if (var3.c != 0x1234)
4147 if (var4.c != 0x1234)
4149 if (var4.d != 0x87654321)
4154 LIBTEST_API int STDCALL
4155 mono_test_Winx64_structs_in2 (winx64_struct1 var1,
4156 winx64_struct1 var2,
4157 winx64_struct1 var3,
4158 winx64_struct1 var4,
4159 winx64_struct1 var5)
4175 LIBTEST_API int STDCALL
4176 mono_test_Winx64_structs_in3 (winx64_struct1 var1,
4177 winx64_struct5 var2,
4178 winx64_struct1 var3,
4179 winx64_struct5 var4,
4180 winx64_struct1 var5,
4181 winx64_struct5 var6)
4216 LIBTEST_API winx64_struct1 STDCALL
4217 mono_test_Winx64_struct1_ret (void)
4224 LIBTEST_API winx64_struct2 STDCALL
4225 mono_test_Winx64_struct2_ret (void)
4233 LIBTEST_API winx64_struct3 STDCALL
4234 mono_test_Winx64_struct3_ret (void)
4243 LIBTEST_API winx64_struct4 STDCALL
4244 mono_test_Winx64_struct4_ret (void)
4254 LIBTEST_API winx64_struct5 STDCALL
4255 mono_test_Winx64_struct5_ret (void)
4264 LIBTEST_API winx64_struct1 STDCALL
4265 mono_test_Winx64_struct1_ret_5_args (char a, char b, char c, char d, char e)
4268 ret.a = a + b + c + d + e;
4272 LIBTEST_API winx64_struct5 STDCALL
4273 mono_test_Winx64_struct5_ret6_args (char a, char b, char c, char d, char e)
4286 } winx64_floatStruct;
4288 LIBTEST_API int STDCALL
4289 mono_test_Winx64_floatStruct (winx64_floatStruct a)
4291 if (a.a > 5.6 || a.a < 5.4)
4294 if (a.b > 9.6 || a.b < 9.4)
4303 } winx64_doubleStruct;
4305 LIBTEST_API int STDCALL
4306 mono_test_Winx64_doubleStruct (winx64_doubleStruct a)
4308 if (a.a > 5.6 || a.a < 5.4)
4314 typedef int (STDCALL *managed_struct1_delegate) (winx64_struct1 a);
4316 LIBTEST_API int STDCALL
4317 mono_test_managed_Winx64_struct1_in(managed_struct1_delegate func)
4324 typedef int (STDCALL *managed_struct5_delegate) (winx64_struct5 a);
4326 LIBTEST_API int STDCALL
4327 mono_test_managed_Winx64_struct5_in(managed_struct5_delegate func)
4336 typedef int (STDCALL *managed_struct1_struct5_delegate) (winx64_struct1 a, winx64_struct5 b,
4337 winx64_struct1 c, winx64_struct5 d,
4338 winx64_struct1 e, winx64_struct5 f);
4340 LIBTEST_API int STDCALL
4341 mono_test_managed_Winx64_struct1_struct5_in(managed_struct1_struct5_delegate func)
4343 winx64_struct1 a, c, e;
4344 winx64_struct5 b, d, f;
4346 b.a = 2; b.b = 3; b.c = 4;
4348 d.a = 6; d.b = 7; d.c = 8;
4350 f.a = 10; f.b = 11; f.c = 12;
4352 return func (a, b, c, d, e, f);
4355 typedef winx64_struct1 (STDCALL *managed_struct1_ret_delegate) (void);
4357 LIBTEST_API int STDCALL
4358 mono_test_Winx64_struct1_ret_managed (managed_struct1_ret_delegate func)
4370 typedef winx64_struct5 (STDCALL *managed_struct5_ret_delegate) (void);
4372 LIBTEST_API int STDCALL
4373 mono_test_Winx64_struct5_ret_managed (managed_struct5_ret_delegate func)
4389 LIBTEST_API int STDCALL
4390 mono_test_marshal_bool_in (int arg, unsigned int expected, unsigned int bDefaultMarsh, unsigned int bBoolCustMarsh,
4391 char bI1CustMarsh, unsigned char bU1CustMarsh, short bVBCustMarsh)
4395 if (bDefaultMarsh != expected)
4399 if (bBoolCustMarsh != expected)
4403 if (bI1CustMarsh != expected)
4407 if (bU1CustMarsh != expected)
4411 if (bVBCustMarsh != expected)
4420 LIBTEST_API int STDCALL
4421 mono_test_marshal_bool_out (int arg, unsigned int testVal, unsigned int* bDefaultMarsh, unsigned int* bBoolCustMarsh,
4422 char* bI1CustMarsh, unsigned char* bU1CustMarsh, unsigned short* bVBCustMarsh)
4428 *bDefaultMarsh = testVal;
4431 if (!bBoolCustMarsh)
4433 *bBoolCustMarsh = testVal;
4438 *bI1CustMarsh = (char)testVal;
4443 *bU1CustMarsh = (unsigned char)testVal;
4448 *bVBCustMarsh = (unsigned short)testVal;
4456 LIBTEST_API int STDCALL
4457 mono_test_marshal_bool_ref (int arg, unsigned int expected, unsigned int testVal, unsigned int* bDefaultMarsh,
4458 unsigned int* bBoolCustMarsh, char* bI1CustMarsh, unsigned char* bU1CustMarsh,
4459 unsigned short* bVBCustMarsh)
4465 if (*bDefaultMarsh != expected)
4467 *bDefaultMarsh = testVal;
4470 if (!bBoolCustMarsh)
4472 if (*bBoolCustMarsh != expected)
4474 *bBoolCustMarsh = testVal;
4479 if (*bI1CustMarsh != expected)
4481 *bI1CustMarsh = (char)testVal;
4486 if (*bU1CustMarsh != expected)
4488 *bU1CustMarsh = (unsigned char)testVal;
4493 if (*bVBCustMarsh != expected)
4495 *bVBCustMarsh = (unsigned short)testVal;
4504 typedef int (STDCALL *MarshalBoolInDelegate) (int arg, unsigned int expected, unsigned int bDefaultMarsh,
4505 unsigned int bBoolCustMarsh, char bI1CustMarsh, unsigned char bU1CustMarsh, unsigned short bVBCustMarsh);
4507 LIBTEST_API int STDCALL
4508 mono_test_managed_marshal_bool_in (int arg, unsigned int expected, unsigned int testVal, MarshalBoolInDelegate pfcn)
4515 return pfcn (arg, expected, testVal, 0, 0, 0, 0);
4517 return pfcn (arg, expected, 0, testVal, 0, 0, 0);
4519 return pfcn (arg, expected, 0, 0, testVal, 0, 0);
4521 return pfcn (arg, expected, 0, 0, 0, testVal, 0);
4523 return pfcn (arg, expected, 0, 0, 0, 0, testVal);
4531 typedef int (STDCALL *MarshalBoolOutDelegate) (int arg, unsigned int expected, unsigned int* bDefaultMarsh,
4532 unsigned int* bBoolCustMarsh, char* bI1CustMarsh, unsigned char* bU1CustMarsh, unsigned short* bVBCustMarsh);
4534 LIBTEST_API int STDCALL
4535 mono_test_managed_marshal_bool_out (int arg, unsigned int expected, unsigned int testVal, MarshalBoolOutDelegate pfcn)
4538 unsigned int lDefaultMarsh, lBoolCustMarsh;
4539 char lI1CustMarsh = 0;
4540 unsigned char lU1CustMarsh = 0;
4541 unsigned short lVBCustMarsh = 0;
4542 lDefaultMarsh = lBoolCustMarsh = 0;
4549 unsigned int ltVal = 0;
4550 ret = pfcn (arg, testVal, <Val, &lBoolCustMarsh, &lI1CustMarsh, &lU1CustMarsh, &lVBCustMarsh);
4552 return 0x0100 + ret;
4553 if (expected != ltVal)
4558 unsigned int ltVal = 0;
4559 ret = pfcn (arg, testVal, &lDefaultMarsh, <Val, &lI1CustMarsh, &lU1CustMarsh, &lVBCustMarsh);
4561 return 0x0300 + ret;
4562 if (expected != ltVal)
4568 ret = pfcn (arg, testVal, &lDefaultMarsh, &lBoolCustMarsh, <Val, &lU1CustMarsh, &lVBCustMarsh);
4570 return 0x0500 + ret;
4571 if (expected != ltVal)
4576 unsigned char ltVal = 0;
4577 ret = pfcn (arg, testVal, &lDefaultMarsh, &lBoolCustMarsh, &lI1CustMarsh, <Val, &lVBCustMarsh);
4579 return 0x0700 + ret;
4580 if (expected != ltVal)
4585 unsigned short ltVal = 0;
4586 ret = pfcn (arg, testVal, &lDefaultMarsh, &lBoolCustMarsh, &lI1CustMarsh, &lU1CustMarsh, <Val);
4588 return 0x0900 + ret;
4589 if (expected != ltVal)
4600 typedef int (STDCALL *MarshalBoolRefDelegate) (int arg, unsigned int expected, unsigned int testVal, unsigned int* bDefaultMarsh,
4601 unsigned int* bBoolCustMarsh, char* bI1CustMarsh, unsigned char* bU1CustMarsh, unsigned short* bVBCustMarsh);
4603 LIBTEST_API int STDCALL
4604 mono_test_managed_marshal_bool_ref (int arg, unsigned int expected, unsigned int testVal, unsigned int outExpected,
4605 unsigned int outTestVal, MarshalBoolRefDelegate pfcn)
4608 unsigned int lDefaultMarsh, lBoolCustMarsh;
4609 char lI1CustMarsh = 0;
4610 unsigned char lU1CustMarsh = 0;
4611 unsigned short lVBCustMarsh = 0;
4612 lDefaultMarsh = lBoolCustMarsh = 0;
4620 unsigned int ltestVal = testVal;
4621 ret = pfcn (arg, expected, outTestVal, <estVal, &lBoolCustMarsh, &lI1CustMarsh, &lU1CustMarsh, &lVBCustMarsh);
4623 return 0x0100 + ret;
4624 if (outExpected != ltestVal)
4630 unsigned int ltestVal = testVal;
4631 ret = pfcn (arg, expected, outTestVal, &lDefaultMarsh, <estVal, &lI1CustMarsh, &lU1CustMarsh, &lVBCustMarsh);
4633 return 0x0300 + ret;
4634 if (outExpected != ltestVal)
4640 char ltestVal = testVal;
4641 ret = pfcn (arg, expected, outTestVal, &lDefaultMarsh, &lBoolCustMarsh, <estVal, &lU1CustMarsh, &lVBCustMarsh);
4643 return 0x0500 + ret;
4644 if (outExpected != ltestVal)
4650 unsigned char ltestVal = testVal;
4651 ret = pfcn (arg, expected, outTestVal, &lDefaultMarsh, &lBoolCustMarsh, &lI1CustMarsh, <estVal, &lVBCustMarsh);
4653 return 0x0700 + ret;
4654 if (outExpected != ltestVal)
4660 unsigned short ltestVal = testVal;
4661 ret = pfcn (arg, expected, outTestVal, &lDefaultMarsh, &lBoolCustMarsh, &lI1CustMarsh, &lU1CustMarsh, <estVal);
4663 return 0x0900 + ret;
4664 if (outExpected != ltestVal)
4677 LIBTEST_API int STDCALL
4678 mono_test_marshal_safearray_out_1dim_vt_bstr_empty (SAFEARRAY** safearray)
4680 /* Create an empty one-dimensional array of variants */
4682 SAFEARRAYBOUND dimensions [1];
4684 dimensions [0].lLbound = 0;
4685 dimensions [0].cElements = 0;
4687 pSA= SafeArrayCreate (VT_VARIANT, 1, dimensions);
4692 LIBTEST_API int STDCALL
4693 mono_test_marshal_safearray_out_1dim_vt_bstr (SAFEARRAY** safearray)
4695 /* Create a one-dimensional array of 10 variants filled with "0" to "9" */
4697 SAFEARRAYBOUND dimensions [1];
4703 dimensions [0].lLbound = 0;
4704 dimensions [0].cElements = 10;
4706 pSA= SafeArrayCreate (VT_VARIANT, 1, dimensions);
4707 for (i= dimensions [0].lLbound; i< (dimensions [0].cElements + dimensions [0].lLbound); i++) {
4709 VariantInit (&vOut);
4711 _ltoa (i,buffer,10);
4712 vOut.bstrVal= marshal_bstr_alloc (buffer);
4714 if ((hr = SafeArrayPutElement (pSA, indices, &vOut)) != S_OK) {
4715 VariantClear (&vOut);
4716 SafeArrayDestroy (pSA);
4719 VariantClear (&vOut);
4725 LIBTEST_API int STDCALL
4726 mono_test_marshal_safearray_out_2dim_vt_i4 (SAFEARRAY** safearray)
4728 /* Create a two-dimensional array of 4x3 variants filled with 11, 12, 13, etc. */
4730 SAFEARRAYBOUND dimensions [2];
4735 dimensions [0].lLbound = 0;
4736 dimensions [0].cElements = 4;
4737 dimensions [1].lLbound = 0;
4738 dimensions [1].cElements = 3;
4740 pSA= SafeArrayCreate(VT_VARIANT, 2, dimensions);
4741 for (i= dimensions [0].lLbound; i< (dimensions [0].cElements + dimensions [0].lLbound); i++) {
4742 for (j= dimensions [1].lLbound; j< (dimensions [1].cElements + dimensions [1].lLbound); j++) {
4744 VariantInit (&vOut);
4746 vOut.lVal = (i+1)*10+(j+1);
4749 if ((hr = SafeArrayPutElement (pSA, indices, &vOut)) != S_OK) {
4750 VariantClear (&vOut);
4751 SafeArrayDestroy (pSA);
4754 VariantClear (&vOut); // does a deep destroy of source VARIANT
4761 LIBTEST_API int STDCALL
4762 mono_test_marshal_safearray_out_4dim_vt_i4 (SAFEARRAY** safearray)
4764 /* Create a four-dimensional array of 10x3x6x7 variants filled with their indices */
4765 /* Also use non zero lower bounds */
4767 SAFEARRAYBOUND dimensions [4];
4772 dimensions [0].lLbound = 15;
4773 dimensions [0].cElements = 10;
4774 dimensions [1].lLbound = 20;
4775 dimensions [1].cElements = 3;
4776 dimensions [2].lLbound = 5;
4777 dimensions [2].cElements = 6;
4778 dimensions [3].lLbound = 12;
4779 dimensions [3].cElements = 7;
4781 pSA= SafeArrayCreate (VT_VARIANT, 4, dimensions);
4783 SafeArrayAccessData (pSA, (void **)&pData);
4785 for (i= 0; i< 10*3*6*7; i++) {
4786 VariantInit(&pData [i]);
4787 pData [i].vt = VT_I4;
4790 SafeArrayUnaccessData (pSA);
4795 LIBTEST_API int STDCALL
4796 mono_test_marshal_safearray_in_byval_1dim_empty (SAFEARRAY* safearray)
4798 /* Check that array is one dimensional and empty */
4801 long lbound, ubound;
4803 dim = SafeArrayGetDim (safearray);
4807 SafeArrayGetLBound (safearray, 1, &lbound);
4808 SafeArrayGetUBound (safearray, 1, &ubound);
4810 if ((lbound > 0) || (ubound > 0))
4816 LIBTEST_API int STDCALL
4817 mono_test_marshal_safearray_in_byval_1dim_vt_i4 (SAFEARRAY* safearray)
4819 /* Check that array is one dimensional containing integers from 1 to 10 */
4822 long lbound, ubound;
4827 dim = SafeArrayGetDim (safearray);
4831 SafeArrayGetLBound (safearray, 1, &lbound);
4832 SafeArrayGetUBound (safearray, 1, &ubound);
4834 if ((lbound != 0) || (ubound != 9))
4837 SafeArrayAccessData (safearray, (void **)&pData);
4838 for (i= lbound; i <= ubound; i++) {
4839 if ((VariantChangeType (&pData [i], &pData [i], VARIANT_NOUSEROVERRIDE, VT_I4) != S_OK) || (pData [i].lVal != i + 1))
4842 SafeArrayUnaccessData (safearray);
4847 LIBTEST_API int STDCALL
4848 mono_test_marshal_safearray_in_byval_1dim_vt_mixed (SAFEARRAY* safearray)
4850 /* Check that array is one dimensional containing integers mixed with strings from 0 to 12 */
4853 long lbound, ubound;
4860 VariantInit (&element);
4862 dim = SafeArrayGetDim (safearray);
4866 SafeArrayGetLBound (safearray, 1, &lbound);
4867 SafeArrayGetUBound (safearray, 1, &ubound);
4869 if ((lbound != 0) || (ubound != 12))
4872 SafeArrayAccessData (safearray, (void **)&pData);
4873 for (i= lbound; i <= ubound; i++) {
4874 if ((i%2 == 0) && (pData [i].vt != VT_I4))
4876 if ((i%2 == 1) && (pData [i].vt != VT_BSTR))
4878 if ((VariantChangeType (&pData [i], &pData [i], VARIANT_NOUSEROVERRIDE, VT_I4) != S_OK) || (pData [i].lVal != i))
4881 SafeArrayUnaccessData (safearray);
4883 /* Change the first element of the array to verify that [in] parameters are not marshalled back to the managed side */
4888 SafeArrayPutElement (safearray, indices, &element);
4889 VariantClear (&element);
4894 LIBTEST_API int STDCALL
4895 mono_test_marshal_safearray_in_byval_2dim_vt_i4 (SAFEARRAY* safearray)
4897 /* Check that array is one dimensional containing integers mixed with strings from 0 to 12 */
4900 long lbound1, ubound1, lbound2, ubound2;
4905 VariantInit (&element);
4907 dim = SafeArrayGetDim (safearray);
4911 SafeArrayGetLBound (safearray, 1, &lbound1);
4912 SafeArrayGetUBound (safearray, 1, &ubound1);
4914 if ((lbound1 != 0) || (ubound1 != 1))
4917 SafeArrayGetLBound (safearray, 2, &lbound2);
4918 SafeArrayGetUBound (safearray, 2, &ubound2);
4920 if ((lbound2 != 0) || (ubound2 != 3)) {
4924 for (i= lbound1; i <= ubound1; i++) {
4926 for (j= lbound2; j <= ubound2; j++) {
4928 if (SafeArrayGetElement (safearray, indices, &element) != S_OK)
4930 failed = ((element.vt != VT_I4) || (element.lVal != 10*(i+1)+(j+1)));
4931 VariantClear (&element);
4937 /* Change the first element of the array to verify that [in] parameters are not marshalled back to the managed side */
4943 SafeArrayPutElement (safearray, indices, &element);
4944 VariantClear (&element);
4949 LIBTEST_API int STDCALL
4950 mono_test_marshal_safearray_in_byval_3dim_vt_bstr (SAFEARRAY* safearray)
4952 /* Check that array is one dimensional containing integers mixed with strings from 0 to 12 */
4955 long lbound1, ubound1, lbound2, ubound2, lbound3, ubound3;
4956 long i, j, k, failed;
4960 VariantInit (&element);
4962 dim = SafeArrayGetDim (safearray);
4966 SafeArrayGetLBound (safearray, 1, &lbound1);
4967 SafeArrayGetUBound (safearray, 1, &ubound1);
4969 if ((lbound1 != 0) || (ubound1 != 1))
4972 SafeArrayGetLBound (safearray, 2, &lbound2);
4973 SafeArrayGetUBound (safearray, 2, &ubound2);
4975 if ((lbound2 != 0) || (ubound2 != 1))
4978 SafeArrayGetLBound (safearray, 3, &lbound3);
4979 SafeArrayGetUBound (safearray, 3, &ubound3);
4981 if ((lbound3 != 0) || (ubound3 != 2))
4984 for (i= lbound1; i <= ubound1; i++) {
4986 for (j= lbound2; j <= ubound2; j++) {
4988 for (k= lbound3; k <= ubound3; k++) {
4990 if (SafeArrayGetElement (safearray, indices, &element) != S_OK)
4992 failed = ((element.vt != VT_BSTR)
4993 || (VariantChangeType (&element, &element, VARIANT_NOUSEROVERRIDE, VT_I4) != S_OK)
4994 || (element.lVal != 100*(i+1)+10*(j+1)+(k+1)));
4995 VariantClear (&element);
5002 /* Change the first element of the array to verify that [in] parameters are not marshalled back to the managed side */
5007 element.vt = VT_BSTR;
5008 element.bstrVal = SysAllocString(L"Should not be copied");
5009 SafeArrayPutElement (safearray, indices, &element);
5010 VariantClear (&element);
5015 LIBTEST_API int STDCALL
5016 mono_test_marshal_safearray_in_byref_3dim_vt_bstr (SAFEARRAY** safearray)
5018 return mono_test_marshal_safearray_in_byval_3dim_vt_bstr (*safearray);
5021 LIBTEST_API int STDCALL
5022 mono_test_marshal_safearray_in_out_byref_1dim_empty (SAFEARRAY** safearray)
5024 /* Check that the input array is what is expected and change it so the caller can check */
5025 /* correct marshalling back to managed code */
5028 long lbound, ubound;
5029 SAFEARRAYBOUND dimensions [1];
5031 wchar_t buffer [20];
5035 /* Check that in array is one dimensional and empty */
5037 dim = SafeArrayGetDim (*safearray);
5042 SafeArrayGetLBound (*safearray, 1, &lbound);
5043 SafeArrayGetUBound (*safearray, 1, &ubound);
5045 if ((lbound > 0) || (ubound > 0)) {
5049 /* Re-dimension the array and return a one-dimensional array of 8 variants filled with "0" to "7" */
5051 dimensions [0].lLbound = 0;
5052 dimensions [0].cElements = 8;
5054 hr = SafeArrayRedim (*safearray, dimensions);
5058 for (i= dimensions [0].lLbound; i< (dimensions [0].lLbound + dimensions [0].cElements); i++) {
5060 VariantInit (&vOut);
5062 _ltow (i,buffer,10);
5063 vOut.bstrVal = SysAllocString (buffer);
5065 if ((hr = SafeArrayPutElement (*safearray, indices, &vOut)) != S_OK) {
5066 VariantClear (&vOut);
5067 SafeArrayDestroy (*safearray);
5070 VariantClear (&vOut);
5075 LIBTEST_API int STDCALL
5076 mono_test_marshal_safearray_in_out_byref_3dim_vt_bstr (SAFEARRAY** safearray)
5078 /* Check that the input array is what is expected and change it so the caller can check */
5079 /* correct marshalling back to managed code */
5082 long lbound1, ubound1, lbound2, ubound2, lbound3, ubound3;
5083 SAFEARRAYBOUND dimensions [1];
5084 long i, j, k, failed;
5085 wchar_t buffer [20];
5090 VariantInit (&element);
5092 /* Check that in array is three dimensional and contains the expected values */
5094 dim = SafeArrayGetDim (*safearray);
5098 SafeArrayGetLBound (*safearray, 1, &lbound1);
5099 SafeArrayGetUBound (*safearray, 1, &ubound1);
5101 if ((lbound1 != 0) || (ubound1 != 1))
5104 SafeArrayGetLBound (*safearray, 2, &lbound2);
5105 SafeArrayGetUBound (*safearray, 2, &ubound2);
5107 if ((lbound2 != 0) || (ubound2 != 1))
5110 SafeArrayGetLBound (*safearray, 3, &lbound3);
5111 SafeArrayGetUBound (*safearray, 3, &ubound3);
5113 if ((lbound3 != 0) || (ubound3 != 2))
5116 for (i= lbound1; i <= ubound1; i++) {
5118 for (j= lbound2; j <= ubound2; j++) {
5120 for (k= lbound3; k <= ubound3; k++) {
5122 if (SafeArrayGetElement (*safearray, indices, &element) != S_OK)
5124 failed = ((element.vt != VT_BSTR)
5125 || (VariantChangeType (&element, &element, VARIANT_NOUSEROVERRIDE, VT_I4) != S_OK)
5126 || (element.lVal != 100*(i+1)+10*(j+1)+(k+1)));
5127 VariantClear (&element);
5134 hr = SafeArrayDestroy (*safearray);
5138 /* Return a new one-dimensional array of 8 variants filled with "0" to "7" */
5140 dimensions [0].lLbound = 0;
5141 dimensions [0].cElements = 8;
5143 *safearray = SafeArrayCreate (VT_VARIANT, 1, dimensions);
5145 for (i= dimensions [0].lLbound; i< (dimensions [0].lLbound + dimensions [0].cElements); i++) {
5147 VariantInit (&vOut);
5149 _ltow (i,buffer,10);
5150 vOut.bstrVal = SysAllocString (buffer);
5152 if ((hr = SafeArrayPutElement (*safearray, indices, &vOut)) != S_OK) {
5153 VariantClear (&vOut);
5154 SafeArrayDestroy (*safearray);
5157 VariantClear (&vOut);
5162 LIBTEST_API int STDCALL
5163 mono_test_marshal_safearray_in_out_byref_1dim_vt_i4 (SAFEARRAY** safearray)
5165 /* Check that the input array is what is expected and change it so the caller can check */
5166 /* correct marshalling back to managed code */
5169 long lbound1, ubound1;
5175 VariantInit (&element);
5177 /* Check that in array is one dimensional and contains the expected value */
5179 dim = SafeArrayGetDim (*safearray);
5183 SafeArrayGetLBound (*safearray, 1, &lbound1);
5184 SafeArrayGetUBound (*safearray, 1, &ubound1);
5187 if ((lbound1 != 0) || (ubound1 != 1))
5191 for (i= lbound1; i <= ubound1; i++) {
5193 if (SafeArrayGetElement (*safearray, indices, &element) != S_OK)
5195 failed = (element.vt != VT_I4) || (element.lVal != i+1);
5196 VariantClear (&element);
5201 /* Change one of the elements of the array to verify that [out] parameter is marshalled back to the managed side */
5206 SafeArrayPutElement (*safearray, indices, &element);
5207 VariantClear (&element);
5212 LIBTEST_API int STDCALL
5213 mono_test_marshal_safearray_in_out_byval_1dim_vt_i4 (SAFEARRAY* safearray)
5215 /* Check that the input array is what is expected and change it so the caller can check */
5216 /* correct marshalling back to managed code */
5219 long lbound1, ubound1;
5220 SAFEARRAYBOUND dimensions [1];
5226 VariantInit (&element);
5228 /* Check that in array is one dimensional and contains the expected value */
5230 dim = SafeArrayGetDim (safearray);
5234 SafeArrayGetLBound (safearray, 1, &lbound1);
5235 SafeArrayGetUBound (safearray, 1, &ubound1);
5237 if ((lbound1 != 0) || (ubound1 != 0))
5240 for (i= lbound1; i <= ubound1; i++) {
5242 if (SafeArrayGetElement (safearray, indices, &element) != S_OK)
5244 failed = (element.vt != VT_I4) || (element.lVal != i+1);
5245 VariantClear (&element);
5250 /* Change the array to verify how [out] parameter is marshalled back to the managed side */
5252 /* Redimension the array */
5253 dimensions [0].lLbound = lbound1;
5254 dimensions [0].cElements = 2;
5255 hr = SafeArrayRedim(safearray, dimensions);
5259 element.lVal = 12345;
5260 SafeArrayPutElement (safearray, indices, &element);
5261 VariantClear (&element);
5265 element.lVal = -12345;
5266 SafeArrayPutElement (safearray, indices, &element);
5267 VariantClear (&element);
5272 LIBTEST_API int STDCALL
5273 mono_test_marshal_safearray_in_out_byval_3dim_vt_bstr (SAFEARRAY* safearray)
5275 /* Check that the input array is what is expected and change it so the caller can check */
5276 /* correct marshalling back to managed code */
5279 long lbound1, ubound1, lbound2, ubound2, lbound3, ubound3;
5280 long i, j, k, failed;
5285 VariantInit (&element);
5287 /* Check that in array is three dimensional and contains the expected values */
5289 dim = SafeArrayGetDim (safearray);
5293 SafeArrayGetLBound (safearray, 1, &lbound1);
5294 SafeArrayGetUBound (safearray, 1, &ubound1);
5296 if ((lbound1 != 0) || (ubound1 != 1))
5299 SafeArrayGetLBound (safearray, 2, &lbound2);
5300 SafeArrayGetUBound (safearray, 2, &ubound2);
5302 if ((lbound2 != 0) || (ubound2 != 1))
5305 SafeArrayGetLBound (safearray, 3, &lbound3);
5306 SafeArrayGetUBound (safearray, 3, &ubound3);
5308 if ((lbound3 != 0) || (ubound3 != 2))
5311 for (i= lbound1; i <= ubound1; i++) {
5313 for (j= lbound2; j <= ubound2; j++) {
5315 for (k= lbound3; k <= ubound3; k++) {
5317 if (SafeArrayGetElement (safearray, indices, &element) != S_OK)
5319 failed = ((element.vt != VT_BSTR)
5320 || (VariantChangeType (&element, &element, VARIANT_NOUSEROVERRIDE, VT_I4) != S_OK)
5321 || (element.lVal != 100*(i+1)+10*(j+1)+(k+1)));
5322 VariantClear (&element);
5329 /* Change the elements of the array to verify that [out] parameter is marshalled back to the managed side */
5336 SafeArrayPutElement (safearray, indices, &element);
5337 VariantClear (&element);
5344 SafeArrayPutElement (safearray, indices, &element);
5345 VariantClear (&element);
5350 element.vt = VT_BSTR;
5351 element.bstrVal = marshal_bstr_alloc("ABCDEFG");
5352 SafeArrayPutElement (safearray, indices, &element);
5353 VariantClear (&element);
5358 LIBTEST_API int STDCALL
5359 mono_test_marshal_safearray_mixed(
5360 SAFEARRAY *safearray1,
5361 SAFEARRAY **safearray2,
5362 SAFEARRAY *safearray3,
5363 SAFEARRAY **safearray4
5368 /* Initialize out parameters */
5371 /* array1: Check that in array is one dimensional and contains the expected value */
5372 hr = mono_test_marshal_safearray_in_out_byval_1dim_vt_i4 (safearray1);
5374 /* array2: Fill in with some values to check on the managed side */
5376 hr = mono_test_marshal_safearray_out_1dim_vt_bstr (safearray2);
5378 /* array3: Check that in array is one dimensional and contains the expected value */
5380 hr = mono_test_marshal_safearray_in_byval_1dim_vt_mixed(safearray3);
5382 /* array4: Check input values and fill in with some values to check on the managed side */
5384 hr = mono_test_marshal_safearray_in_out_byref_3dim_vt_bstr(safearray4);
5391 static int call_managed_res;
5394 call_managed (gpointer arg)
5396 SimpleDelegate del = arg;
5398 call_managed_res = del (42);
5401 LIBTEST_API int STDCALL
5402 mono_test_marshal_thread_attach (SimpleDelegate del)
5410 res = pthread_create (&t, NULL, (gpointer)call_managed, del);
5411 g_assert (res == 0);
5412 pthread_join (t, NULL);
5414 return call_managed_res;
5418 typedef int (STDCALL *Callback) (void);
5420 static Callback callback;
5422 LIBTEST_API void STDCALL
5423 mono_test_marshal_set_callback (Callback cb)
5428 LIBTEST_API int STDCALL
5429 mono_test_marshal_call_callback (void)
5434 LIBTEST_API int STDCALL
5435 mono_test_marshal_lpstr (char *str)
5437 return strcmp ("ABC", str);
5440 LIBTEST_API int STDCALL
5441 mono_test_marshal_lpwstr (gunichar2 *str)
5446 s = g_utf16_to_utf8 (str, -1, NULL, NULL, NULL);
5447 res = strcmp ("ABC", s);
5453 LIBTEST_API char* STDCALL
5454 mono_test_marshal_return_lpstr (void)
5456 char *res = marshal_alloc (4);
5457 strcpy (res, "XYZ");
5462 LIBTEST_API gunichar2* STDCALL
5463 mono_test_marshal_return_lpwstr (void)
5465 gunichar2 *res = marshal_alloc (8);
5466 gunichar2* tmp = g_utf8_to_utf16 ("XYZ", -1, NULL, NULL, NULL);
5468 memcpy (res, tmp, 8);
5476 } SingleDoubleStruct;
5478 LIBTEST_API SingleDoubleStruct STDCALL
5479 mono_test_marshal_return_single_double_struct (void)
5481 SingleDoubleStruct res;
5491 LIBTEST_API int STDCALL
5492 mono_test_has_thiscall (void)
5498 _mono_test_native_thiscall1 (int arg)
5504 _mono_test_native_thiscall2 (int arg, int arg2)
5506 return arg + (arg2^1);
5510 _mono_test_native_thiscall3 (int arg, int arg2, int arg3)
5512 return arg + (arg2^1) + (arg3^2);
5515 #elif defined(__GNUC__)
5517 LIBTEST_API int STDCALL
5518 mono_test_has_thiscall (void)
5523 #define def_asm_fn(name) \
5525 "\t.globl _" #name "\n" \
5527 "\t.globl __" #name "\n" \
5532 def_asm_fn(mono_test_native_thiscall1)
5533 "\tmovl %ecx,%eax\n"
5536 def_asm_fn(mono_test_native_thiscall2)
5537 "\tmovl %ecx,%eax\n"
5538 "\tmovl 4(%esp),%ecx\n"
5540 "\taddl %ecx,%eax\n"
5543 def_asm_fn(mono_test_native_thiscall3)
5544 "\tmovl %ecx,%eax\n"
5545 "\tmovl 4(%esp),%ecx\n"
5547 "\taddl %ecx,%eax\n"
5548 "\tmovl 8(%esp),%ecx\n"
5550 "\taddl %ecx,%eax\n"
5557 LIBTEST_API int STDCALL
5558 mono_test_has_thiscall (void)
5570 LIBTEST_API sbyte1 STDCALL
5571 mono_return_sbyte1 (sbyte1 s1, int addend) {
5573 fprintf(stderr, "mono_return_sbyte1 s1.f1: got %d but expected %d\n", s1.f1, 1);
5583 LIBTEST_API sbyte2 STDCALL
5584 mono_return_sbyte2 (sbyte2 s2, int addend) {
5586 fprintf(stderr, "mono_return_sbyte2 s2.f1: got %d but expected %d\n", s2.f1, 1);
5589 fprintf(stderr, "mono_return_sbyte2 s2.f2: got %d but expected %d\n", s2.f2, 2);
5591 s2.f1+=addend; s2.f2+=addend;
5599 LIBTEST_API sbyte3 STDCALL
5600 mono_return_sbyte3 (sbyte3 s3, int addend) {
5602 fprintf(stderr, "mono_return_sbyte3 s3.f1: got %d but expected %d\n", s3.f1, 1);
5605 fprintf(stderr, "mono_return_sbyte3 s3.f2: got %d but expected %d\n", s3.f2, 2);
5608 fprintf(stderr, "mono_return_sbyte3 s3.f3: got %d but expected %d\n", s3.f3, 3);
5610 s3.f1+=addend; s3.f2+=addend; s3.f3+=addend;
5618 LIBTEST_API sbyte4 STDCALL
5619 mono_return_sbyte4 (sbyte4 s4, int addend) {
5621 fprintf(stderr, "mono_return_sbyte4 s4.f1: got %d but expected %d\n", s4.f1, 1);
5624 fprintf(stderr, "mono_return_sbyte4 s4.f2: got %d but expected %d\n", s4.f2, 2);
5627 fprintf(stderr, "mono_return_sbyte4 s4.f3: got %d but expected %d\n", s4.f3, 3);
5630 fprintf(stderr, "mono_return_sbyte4 s4.f4: got %d but expected %d\n", s4.f4, 4);
5632 s4.f1+=addend; s4.f2+=addend; s4.f3+=addend; s4.f4+=addend;
5637 char f1,f2,f3,f4,f5;
5640 LIBTEST_API sbyte5 STDCALL
5641 mono_return_sbyte5 (sbyte5 s5, int addend) {
5643 fprintf(stderr, "mono_return_sbyte5 s5.f1: got %d but expected %d\n", s5.f1, 1);
5646 fprintf(stderr, "mono_return_sbyte5 s5.f2: got %d but expected %d\n", s5.f2, 2);
5649 fprintf(stderr, "mono_return_sbyte5 s5.f3: got %d but expected %d\n", s5.f3, 3);
5652 fprintf(stderr, "mono_return_sbyte5 s5.f4: got %d but expected %d\n", s5.f4, 4);
5655 fprintf(stderr, "mono_return_sbyte5 s5.f5: got %d but expected %d\n", s5.f5, 5);
5657 s5.f1+=addend; s5.f2+=addend; s5.f3+=addend; s5.f4+=addend; s5.f5+=addend;
5662 char f1,f2,f3,f4,f5,f6;
5665 LIBTEST_API sbyte6 STDCALL
5666 mono_return_sbyte6 (sbyte6 s6, int addend) {
5668 fprintf(stderr, "mono_return_sbyte6 s6.f1: got %d but expected %d\n", s6.f1, 1);
5671 fprintf(stderr, "mono_return_sbyte6 s6.f2: got %d but expected %d\n", s6.f2, 2);
5674 fprintf(stderr, "mono_return_sbyte6 s6.f3: got %d but expected %d\n", s6.f3, 3);
5677 fprintf(stderr, "mono_return_sbyte6 s6.f4: got %d but expected %d\n", s6.f4, 4);
5680 fprintf(stderr, "mono_return_sbyte6 s6.f5: got %d but expected %d\n", s6.f5, 5);
5683 fprintf(stderr, "mono_return_sbyte6 s6.f6: got %d but expected %d\n", s6.f6, 6);
5685 s6.f1+=addend; s6.f2+=addend; s6.f3+=addend; s6.f4+=addend; s6.f5+=addend; s6.f6+=addend;
5690 char f1,f2,f3,f4,f5,f6,f7;
5693 LIBTEST_API sbyte7 STDCALL
5694 mono_return_sbyte7 (sbyte7 s7, int addend) {
5696 fprintf(stderr, "mono_return_sbyte7 s7.f1: got %d but expected %d\n", s7.f1, 1);
5699 fprintf(stderr, "mono_return_sbyte7 s7.f2: got %d but expected %d\n", s7.f2, 2);
5702 fprintf(stderr, "mono_return_sbyte7 s7.f3: got %d but expected %d\n", s7.f3, 3);
5705 fprintf(stderr, "mono_return_sbyte7 s7.f4: got %d but expected %d\n", s7.f4, 4);
5708 fprintf(stderr, "mono_return_sbyte7 s7.f5: got %d but expected %d\n", s7.f5, 5);
5711 fprintf(stderr, "mono_return_sbyte7 s7.f6: got %d but expected %d\n", s7.f6, 6);
5714 fprintf(stderr, "mono_return_sbyte7 s7.f7: got %d but expected %d\n", s7.f7, 7);
5716 s7.f1+=addend; s7.f2+=addend; s7.f3+=addend; s7.f4+=addend; s7.f5+=addend; s7.f6+=addend; s7.f7+=addend;
5721 char f1,f2,f3,f4,f5,f6,f7,f8;
5724 LIBTEST_API sbyte8 STDCALL
5725 mono_return_sbyte8 (sbyte8 s8, int addend) {
5727 fprintf(stderr, "mono_return_sbyte8 s8.f1: got %d but expected %d\n", s8.f1, 1);
5730 fprintf(stderr, "mono_return_sbyte8 s8.f2: got %d but expected %d\n", s8.f2, 2);
5733 fprintf(stderr, "mono_return_sbyte8 s8.f3: got %d but expected %d\n", s8.f3, 3);
5736 fprintf(stderr, "mono_return_sbyte8 s8.f4: got %d but expected %d\n", s8.f4, 4);
5739 fprintf(stderr, "mono_return_sbyte8 s8.f5: got %d but expected %d\n", s8.f5, 5);
5742 fprintf(stderr, "mono_return_sbyte8 s8.f6: got %d but expected %d\n", s8.f6, 6);
5745 fprintf(stderr, "mono_return_sbyte8 s8.f7: got %d but expected %d\n", s8.f7, 7);
5748 fprintf(stderr, "mono_return_sbyte8 s8.f8: got %d but expected %d\n", s8.f8, 8);
5750 s8.f1+=addend; s8.f2+=addend; s8.f3+=addend; s8.f4+=addend; s8.f5+=addend; s8.f6+=addend; s8.f7+=addend; s8.f8+=addend;
5755 char f1,f2,f3,f4,f5,f6,f7,f8,f9;
5758 LIBTEST_API sbyte9 STDCALL
5759 mono_return_sbyte9 (sbyte9 s9, int addend) {
5761 fprintf(stderr, "mono_return_sbyte9 s9.f1: got %d but expected %d\n", s9.f1, 1);
5764 fprintf(stderr, "mono_return_sbyte9 s9.f2: got %d but expected %d\n", s9.f2, 2);
5767 fprintf(stderr, "mono_return_sbyte9 s9.f3: got %d but expected %d\n", s9.f3, 3);
5770 fprintf(stderr, "mono_return_sbyte9 s9.f4: got %d but expected %d\n", s9.f4, 4);
5773 fprintf(stderr, "mono_return_sbyte9 s9.f5: got %d but expected %d\n", s9.f5, 5);
5776 fprintf(stderr, "mono_return_sbyte9 s9.f6: got %d but expected %d\n", s9.f6, 6);
5779 fprintf(stderr, "mono_return_sbyte9 s9.f7: got %d but expected %d\n", s9.f7, 7);
5782 fprintf(stderr, "mono_return_sbyte9 s9.f8: got %d but expected %d\n", s9.f8, 8);
5785 fprintf(stderr, "mono_return_sbyte9 s9.f9: got %d but expected %d\n", s9.f9, 9);
5787 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;
5792 char f1,f2,f3,f4,f5,f6,f7,f8,f9,f10;
5795 LIBTEST_API sbyte10 STDCALL
5796 mono_return_sbyte10 (sbyte10 s10, int addend) {
5798 fprintf(stderr, "mono_return_sbyte10 s10.f1: got %d but expected %d\n", s10.f1, 1);
5801 fprintf(stderr, "mono_return_sbyte10 s10.f2: got %d but expected %d\n", s10.f2, 2);
5804 fprintf(stderr, "mono_return_sbyte10 s10.f3: got %d but expected %d\n", s10.f3, 3);
5807 fprintf(stderr, "mono_return_sbyte10 s10.f4: got %d but expected %d\n", s10.f4, 4);
5810 fprintf(stderr, "mono_return_sbyte10 s10.f5: got %d but expected %d\n", s10.f5, 5);
5813 fprintf(stderr, "mono_return_sbyte10 s10.f6: got %d but expected %d\n", s10.f6, 6);
5816 fprintf(stderr, "mono_return_sbyte10 s10.f7: got %d but expected %d\n", s10.f7, 7);
5819 fprintf(stderr, "mono_return_sbyte10 s10.f8: got %d but expected %d\n", s10.f8, 8);
5822 fprintf(stderr, "mono_return_sbyte10 s10.f9: got %d but expected %d\n", s10.f9, 9);
5824 if (s10.f10 != 10) {
5825 fprintf(stderr, "mono_return_sbyte10 s10.f10: got %d but expected %d\n", s10.f10, 10);
5827 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;
5832 char f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11;
5835 LIBTEST_API sbyte11 STDCALL
5836 mono_return_sbyte11 (sbyte11 s11, int addend) {
5838 fprintf(stderr, "mono_return_sbyte11 s11.f1: got %d but expected %d\n", s11.f1, 1);
5841 fprintf(stderr, "mono_return_sbyte11 s11.f2: got %d but expected %d\n", s11.f2, 2);
5844 fprintf(stderr, "mono_return_sbyte11 s11.f3: got %d but expected %d\n", s11.f3, 3);
5847 fprintf(stderr, "mono_return_sbyte11 s11.f4: got %d but expected %d\n", s11.f4, 4);
5850 fprintf(stderr, "mono_return_sbyte11 s11.f5: got %d but expected %d\n", s11.f5, 5);
5853 fprintf(stderr, "mono_return_sbyte11 s11.f6: got %d but expected %d\n", s11.f6, 6);
5856 fprintf(stderr, "mono_return_sbyte11 s11.f7: got %d but expected %d\n", s11.f7, 7);
5859 fprintf(stderr, "mono_return_sbyte11 s11.f8: got %d but expected %d\n", s11.f8, 8);
5862 fprintf(stderr, "mono_return_sbyte11 s11.f9: got %d but expected %d\n", s11.f9, 9);
5864 if (s11.f10 != 10) {
5865 fprintf(stderr, "mono_return_sbyte11 s11.f10: got %d but expected %d\n", s11.f10, 10);
5867 if (s11.f11 != 11) {
5868 fprintf(stderr, "mono_return_sbyte11 s11.f11: got %d but expected %d\n", s11.f11, 11);
5870 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;
5875 char f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12;
5878 LIBTEST_API sbyte12 STDCALL
5879 mono_return_sbyte12 (sbyte12 s12, int addend) {
5881 fprintf(stderr, "mono_return_sbyte12 s12.f1: got %d but expected %d\n", s12.f1, 1);
5884 fprintf(stderr, "mono_return_sbyte12 s12.f2: got %d but expected %d\n", s12.f2, 2);
5887 fprintf(stderr, "mono_return_sbyte12 s12.f3: got %d but expected %d\n", s12.f3, 3);
5890 fprintf(stderr, "mono_return_sbyte12 s12.f4: got %d but expected %d\n", s12.f4, 4);
5893 fprintf(stderr, "mono_return_sbyte12 s12.f5: got %d but expected %d\n", s12.f5, 5);
5896 fprintf(stderr, "mono_return_sbyte12 s12.f6: got %d but expected %d\n", s12.f6, 6);
5899 fprintf(stderr, "mono_return_sbyte12 s12.f7: got %d but expected %d\n", s12.f7, 7);
5902 fprintf(stderr, "mono_return_sbyte12 s12.f8: got %d but expected %d\n", s12.f8, 8);
5905 fprintf(stderr, "mono_return_sbyte12 s12.f9: got %d but expected %d\n", s12.f9, 9);
5907 if (s12.f10 != 10) {
5908 fprintf(stderr, "mono_return_sbyte12 s12.f10: got %d but expected %d\n", s12.f10, 10);
5910 if (s12.f11 != 11) {
5911 fprintf(stderr, "mono_return_sbyte12 s12.f11: got %d but expected %d\n", s12.f11, 11);
5913 if (s12.f12 != 12) {
5914 fprintf(stderr, "mono_return_sbyte12 s12.f12: got %d but expected %d\n", s12.f12, 12);
5916 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;
5921 char f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13;
5924 LIBTEST_API sbyte13 STDCALL
5925 mono_return_sbyte13 (sbyte13 s13, int addend) {
5927 fprintf(stderr, "mono_return_sbyte13 s13.f1: got %d but expected %d\n", s13.f1, 1);
5930 fprintf(stderr, "mono_return_sbyte13 s13.f2: got %d but expected %d\n", s13.f2, 2);
5933 fprintf(stderr, "mono_return_sbyte13 s13.f3: got %d but expected %d\n", s13.f3, 3);
5936 fprintf(stderr, "mono_return_sbyte13 s13.f4: got %d but expected %d\n", s13.f4, 4);
5939 fprintf(stderr, "mono_return_sbyte13 s13.f5: got %d but expected %d\n", s13.f5, 5);
5942 fprintf(stderr, "mono_return_sbyte13 s13.f6: got %d but expected %d\n", s13.f6, 6);
5945 fprintf(stderr, "mono_return_sbyte13 s13.f7: got %d but expected %d\n", s13.f7, 7);
5948 fprintf(stderr, "mono_return_sbyte13 s13.f8: got %d but expected %d\n", s13.f8, 8);
5951 fprintf(stderr, "mono_return_sbyte13 s13.f9: got %d but expected %d\n", s13.f9, 9);
5953 if (s13.f10 != 10) {
5954 fprintf(stderr, "mono_return_sbyte13 s13.f10: got %d but expected %d\n", s13.f10, 10);
5956 if (s13.f11 != 11) {
5957 fprintf(stderr, "mono_return_sbyte13 s13.f11: got %d but expected %d\n", s13.f11, 11);
5959 if (s13.f12 != 12) {
5960 fprintf(stderr, "mono_return_sbyte13 s13.f12: got %d but expected %d\n", s13.f12, 12);
5962 if (s13.f13 != 13) {
5963 fprintf(stderr, "mono_return_sbyte13 s13.f13: got %d but expected %d\n", s13.f13, 13);
5965 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;
5970 char f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14;
5973 LIBTEST_API sbyte14 STDCALL
5974 mono_return_sbyte14 (sbyte14 s14, int addend) {
5976 fprintf(stderr, "mono_return_sbyte14 s14.f1: got %d but expected %d\n", s14.f1, 1);
5979 fprintf(stderr, "mono_return_sbyte14 s14.f2: got %d but expected %d\n", s14.f2, 2);
5982 fprintf(stderr, "mono_return_sbyte14 s14.f3: got %d but expected %d\n", s14.f3, 3);
5985 fprintf(stderr, "mono_return_sbyte14 s14.f4: got %d but expected %d\n", s14.f4, 4);
5988 fprintf(stderr, "mono_return_sbyte14 s14.f5: got %d but expected %d\n", s14.f5, 5);
5991 fprintf(stderr, "mono_return_sbyte14 s14.f6: got %d but expected %d\n", s14.f6, 6);
5994 fprintf(stderr, "mono_return_sbyte14 s14.f7: got %d but expected %d\n", s14.f7, 7);
5997 fprintf(stderr, "mono_return_sbyte14 s14.f8: got %d but expected %d\n", s14.f8, 8);
6000 fprintf(stderr, "mono_return_sbyte14 s14.f9: got %d but expected %d\n", s14.f9, 9);
6002 if (s14.f10 != 10) {
6003 fprintf(stderr, "mono_return_sbyte14 s14.f10: got %d but expected %d\n", s14.f10, 10);
6005 if (s14.f11 != 11) {
6006 fprintf(stderr, "mono_return_sbyte14 s14.f11: got %d but expected %d\n", s14.f11, 11);
6008 if (s14.f12 != 12) {
6009 fprintf(stderr, "mono_return_sbyte14 s14.f12: got %d but expected %d\n", s14.f12, 12);
6011 if (s14.f13 != 13) {
6012 fprintf(stderr, "mono_return_sbyte14 s14.f13: got %d but expected %d\n", s14.f13, 13);
6014 if (s14.f14 != 14) {
6015 fprintf(stderr, "mono_return_sbyte14 s14.f14: got %d but expected %d\n", s14.f14, 14);
6017 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;
6022 char f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15;
6025 LIBTEST_API sbyte15 STDCALL
6026 mono_return_sbyte15 (sbyte15 s15, int addend) {
6028 fprintf(stderr, "mono_return_sbyte15 s15.f1: got %d but expected %d\n", s15.f1, 1);
6031 fprintf(stderr, "mono_return_sbyte15 s15.f2: got %d but expected %d\n", s15.f2, 2);
6034 fprintf(stderr, "mono_return_sbyte15 s15.f3: got %d but expected %d\n", s15.f3, 3);
6037 fprintf(stderr, "mono_return_sbyte15 s15.f4: got %d but expected %d\n", s15.f4, 4);
6040 fprintf(stderr, "mono_return_sbyte15 s15.f5: got %d but expected %d\n", s15.f5, 5);
6043 fprintf(stderr, "mono_return_sbyte15 s15.f6: got %d but expected %d\n", s15.f6, 6);
6046 fprintf(stderr, "mono_return_sbyte15 s15.f7: got %d but expected %d\n", s15.f7, 7);
6049 fprintf(stderr, "mono_return_sbyte15 s15.f8: got %d but expected %d\n", s15.f8, 8);
6052 fprintf(stderr, "mono_return_sbyte15 s15.f9: got %d but expected %d\n", s15.f9, 9);
6054 if (s15.f10 != 10) {
6055 fprintf(stderr, "mono_return_sbyte15 s15.f10: got %d but expected %d\n", s15.f10, 10);
6057 if (s15.f11 != 11) {
6058 fprintf(stderr, "mono_return_sbyte15 s15.f11: got %d but expected %d\n", s15.f11, 11);
6060 if (s15.f12 != 12) {
6061 fprintf(stderr, "mono_return_sbyte15 s15.f12: got %d but expected %d\n", s15.f12, 12);
6063 if (s15.f13 != 13) {
6064 fprintf(stderr, "mono_return_sbyte15 s15.f13: got %d but expected %d\n", s15.f13, 13);
6066 if (s15.f14 != 14) {
6067 fprintf(stderr, "mono_return_sbyte15 s15.f14: got %d but expected %d\n", s15.f14, 14);
6069 if (s15.f15 != 15) {
6070 fprintf(stderr, "mono_return_sbyte15 s15.f15: got %d but expected %d\n", s15.f15, 15);
6072 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;
6077 char f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15,f16;
6080 LIBTEST_API sbyte16 STDCALL
6081 mono_return_sbyte16 (sbyte16 s16, int addend) {
6083 fprintf(stderr, "mono_return_sbyte16 s16.f1: got %d but expected %d\n", s16.f1, 1);
6086 fprintf(stderr, "mono_return_sbyte16 s16.f2: got %d but expected %d\n", s16.f2, 2);
6089 fprintf(stderr, "mono_return_sbyte16 s16.f3: got %d but expected %d\n", s16.f3, 3);
6092 fprintf(stderr, "mono_return_sbyte16 s16.f4: got %d but expected %d\n", s16.f4, 4);
6095 fprintf(stderr, "mono_return_sbyte16 s16.f5: got %d but expected %d\n", s16.f5, 5);
6098 fprintf(stderr, "mono_return_sbyte16 s16.f6: got %d but expected %d\n", s16.f6, 6);
6101 fprintf(stderr, "mono_return_sbyte16 s16.f7: got %d but expected %d\n", s16.f7, 7);
6104 fprintf(stderr, "mono_return_sbyte16 s16.f8: got %d but expected %d\n", s16.f8, 8);
6107 fprintf(stderr, "mono_return_sbyte16 s16.f9: got %d but expected %d\n", s16.f9, 9);
6109 if (s16.f10 != 10) {
6110 fprintf(stderr, "mono_return_sbyte16 s16.f10: got %d but expected %d\n", s16.f10, 10);
6112 if (s16.f11 != 11) {
6113 fprintf(stderr, "mono_return_sbyte16 s16.f11: got %d but expected %d\n", s16.f11, 11);
6115 if (s16.f12 != 12) {
6116 fprintf(stderr, "mono_return_sbyte16 s16.f12: got %d but expected %d\n", s16.f12, 12);
6118 if (s16.f13 != 13) {
6119 fprintf(stderr, "mono_return_sbyte16 s16.f13: got %d but expected %d\n", s16.f13, 13);
6121 if (s16.f14 != 14) {
6122 fprintf(stderr, "mono_return_sbyte16 s16.f14: got %d but expected %d\n", s16.f14, 14);
6124 if (s16.f15 != 15) {
6125 fprintf(stderr, "mono_return_sbyte16 s16.f15: got %d but expected %d\n", s16.f15, 15);
6127 if (s16.f16 != 16) {
6128 fprintf(stderr, "mono_return_sbyte16 s16.f16: got %d but expected %d\n", s16.f16, 16);
6130 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;
6135 char f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15,f16,f17;
6138 LIBTEST_API sbyte17 STDCALL
6139 mono_return_sbyte17 (sbyte17 s17, int addend) {
6141 fprintf(stderr, "mono_return_sbyte17 s17.f1: got %d but expected %d\n", s17.f1, 1);
6144 fprintf(stderr, "mono_return_sbyte17 s17.f2: got %d but expected %d\n", s17.f2, 2);
6147 fprintf(stderr, "mono_return_sbyte17 s17.f3: got %d but expected %d\n", s17.f3, 3);
6150 fprintf(stderr, "mono_return_sbyte17 s17.f4: got %d but expected %d\n", s17.f4, 4);
6153 fprintf(stderr, "mono_return_sbyte17 s17.f5: got %d but expected %d\n", s17.f5, 5);
6156 fprintf(stderr, "mono_return_sbyte17 s17.f6: got %d but expected %d\n", s17.f6, 6);
6159 fprintf(stderr, "mono_return_sbyte17 s17.f7: got %d but expected %d\n", s17.f7, 7);
6162 fprintf(stderr, "mono_return_sbyte17 s17.f8: got %d but expected %d\n", s17.f8, 8);
6165 fprintf(stderr, "mono_return_sbyte17 s17.f9: got %d but expected %d\n", s17.f9, 9);
6167 if (s17.f10 != 10) {
6168 fprintf(stderr, "mono_return_sbyte17 s17.f10: got %d but expected %d\n", s17.f10, 10);
6170 if (s17.f11 != 11) {
6171 fprintf(stderr, "mono_return_sbyte17 s17.f11: got %d but expected %d\n", s17.f11, 11);
6173 if (s17.f12 != 12) {
6174 fprintf(stderr, "mono_return_sbyte17 s17.f12: got %d but expected %d\n", s17.f12, 12);
6176 if (s17.f13 != 13) {
6177 fprintf(stderr, "mono_return_sbyte17 s17.f13: got %d but expected %d\n", s17.f13, 13);
6179 if (s17.f14 != 14) {
6180 fprintf(stderr, "mono_return_sbyte17 s17.f14: got %d but expected %d\n", s17.f14, 14);
6182 if (s17.f15 != 15) {
6183 fprintf(stderr, "mono_return_sbyte17 s17.f15: got %d but expected %d\n", s17.f15, 15);
6185 if (s17.f16 != 16) {
6186 fprintf(stderr, "mono_return_sbyte17 s17.f16: got %d but expected %d\n", s17.f16, 16);
6188 if (s17.f17 != 17) {
6189 fprintf(stderr, "mono_return_sbyte17 s17.f17: got %d but expected %d\n", s17.f17, 17);
6191 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;
6199 char f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15;
6205 LIBTEST_API sbyte16_nested STDCALL
6206 mono_return_sbyte16_nested (sbyte16_nested sn16, int addend) {
6207 if (sn16.nested1.f1 != 1) {
6208 fprintf(stderr, "mono_return_sbyte16_nested sn16.nested1.f1: got %d but expected %d\n", sn16.nested1.f1, 1);
6211 fprintf(stderr, "mono_return_sbyte16_nested sn16.f2: got %d but expected %d\n", sn16.f2, 2);
6214 fprintf(stderr, "mono_return_sbyte16_nested sn16.f3: got %d but expected %d\n", sn16.f3, 3);
6217 fprintf(stderr, "mono_return_sbyte16_nested sn16.f4: got %d but expected %d\n", sn16.f4, 4);
6220 fprintf(stderr, "mono_return_sbyte16_nested sn16.f5: got %d but expected %d\n", sn16.f5, 5);
6223 fprintf(stderr, "mono_return_sbyte16_nested sn16.f6: got %d but expected %d\n", sn16.f6, 6);
6226 fprintf(stderr, "mono_return_sbyte16_nested sn16.f7: got %d but expected %d\n", sn16.f7, 7);
6229 fprintf(stderr, "mono_return_sbyte16_nested sn16.f8: got %d but expected %d\n", sn16.f8, 8);
6232 fprintf(stderr, "mono_return_sbyte16_nested sn16.f9: got %d but expected %d\n", sn16.f9, 9);
6234 if (sn16.f10 != 10) {
6235 fprintf(stderr, "mono_return_sbyte16_nested sn16.f10: got %d but expected %d\n", sn16.f10, 10);
6237 if (sn16.f11 != 11) {
6238 fprintf(stderr, "mono_return_sbyte16_nested sn16.f11: got %d but expected %d\n", sn16.f11, 11);
6240 if (sn16.f12 != 12) {
6241 fprintf(stderr, "mono_return_sbyte16_nested sn16.f12: got %d but expected %d\n", sn16.f12, 12);
6243 if (sn16.f13 != 13) {
6244 fprintf(stderr, "mono_return_sbyte16_nested sn16.f13: got %d but expected %d\n", sn16.f13, 13);
6246 if (sn16.f14 != 14) {
6247 fprintf(stderr, "mono_return_sbyte16_nested sn16.f14: got %d but expected %d\n", sn16.f14, 14);
6249 if (sn16.f15 != 15) {
6250 fprintf(stderr, "mono_return_sbyte16_nested sn16.f15: got %d but expected %d\n", sn16.f15, 15);
6252 if (sn16.nested2.f16 != 16) {
6253 fprintf(stderr, "mono_return_sbyte16_nested sn16.nested2.f16: got %d but expected %d\n", sn16.nested2.f16, 16);
6255 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;
6264 LIBTEST_API short1 STDCALL
6265 mono_return_short1 (short1 s1, int addend) {
6267 fprintf(stderr, "mono_return_short1 s1.f1: got %d but expected %d\n", s1.f1, 1);
6277 LIBTEST_API short2 STDCALL
6278 mono_return_short2 (short2 s2, int addend) {
6280 fprintf(stderr, "mono_return_short2 s2.f1: got %d but expected %d\n", s2.f1, 1);
6283 fprintf(stderr, "mono_return_short2 s2.f2: got %d but expected %d\n", s2.f2, 2);
6285 s2.f1+=addend; s2.f2+=addend;
6293 LIBTEST_API short3 STDCALL
6294 mono_return_short3 (short3 s3, int addend) {
6296 fprintf(stderr, "mono_return_short3 s3.f1: got %d but expected %d\n", s3.f1, 1);
6299 fprintf(stderr, "mono_return_short3 s3.f2: got %d but expected %d\n", s3.f2, 2);
6302 fprintf(stderr, "mono_return_short3 s3.f3: got %d but expected %d\n", s3.f3, 3);
6304 s3.f1+=addend; s3.f2+=addend; s3.f3+=addend;
6312 LIBTEST_API short4 STDCALL
6313 mono_return_short4 (short4 s4, int addend) {
6315 fprintf(stderr, "mono_return_short4 s4.f1: got %d but expected %d\n", s4.f1, 1);
6318 fprintf(stderr, "mono_return_short4 s4.f2: got %d but expected %d\n", s4.f2, 2);
6321 fprintf(stderr, "mono_return_short4 s4.f3: got %d but expected %d\n", s4.f3, 3);
6324 fprintf(stderr, "mono_return_short4 s4.f4: got %d but expected %d\n", s4.f4, 4);
6326 s4.f1+=addend; s4.f2+=addend; s4.f3+=addend; s4.f4+=addend;
6331 short f1,f2,f3,f4,f5;
6334 LIBTEST_API short5 STDCALL
6335 mono_return_short5 (short5 s5, int addend) {
6337 fprintf(stderr, "mono_return_short5 s5.f1: got %d but expected %d\n", s5.f1, 1);
6340 fprintf(stderr, "mono_return_short5 s5.f2: got %d but expected %d\n", s5.f2, 2);
6343 fprintf(stderr, "mono_return_short5 s5.f3: got %d but expected %d\n", s5.f3, 3);
6346 fprintf(stderr, "mono_return_short5 s5.f4: got %d but expected %d\n", s5.f4, 4);
6349 fprintf(stderr, "mono_return_short5 s5.f5: got %d but expected %d\n", s5.f5, 5);
6351 s5.f1+=addend; s5.f2+=addend; s5.f3+=addend; s5.f4+=addend; s5.f5+=addend;
6356 short f1,f2,f3,f4,f5,f6;
6359 LIBTEST_API short6 STDCALL
6360 mono_return_short6 (short6 s6, int addend) {
6362 fprintf(stderr, "mono_return_short6 s6.f1: got %d but expected %d\n", s6.f1, 1);
6365 fprintf(stderr, "mono_return_short6 s6.f2: got %d but expected %d\n", s6.f2, 2);
6368 fprintf(stderr, "mono_return_short6 s6.f3: got %d but expected %d\n", s6.f3, 3);
6371 fprintf(stderr, "mono_return_short6 s6.f4: got %d but expected %d\n", s6.f4, 4);
6374 fprintf(stderr, "mono_return_short6 s6.f5: got %d but expected %d\n", s6.f5, 5);
6377 fprintf(stderr, "mono_return_short6 s6.f6: got %d but expected %d\n", s6.f6, 6);
6379 s6.f1+=addend; s6.f2+=addend; s6.f3+=addend; s6.f4+=addend; s6.f5+=addend; s6.f6+=addend;
6384 short f1,f2,f3,f4,f5,f6,f7;
6387 LIBTEST_API short7 STDCALL
6388 mono_return_short7 (short7 s7, int addend) {
6390 fprintf(stderr, "mono_return_short7 s7.f1: got %d but expected %d\n", s7.f1, 1);
6393 fprintf(stderr, "mono_return_short7 s7.f2: got %d but expected %d\n", s7.f2, 2);
6396 fprintf(stderr, "mono_return_short7 s7.f3: got %d but expected %d\n", s7.f3, 3);
6399 fprintf(stderr, "mono_return_short7 s7.f4: got %d but expected %d\n", s7.f4, 4);
6402 fprintf(stderr, "mono_return_short7 s7.f5: got %d but expected %d\n", s7.f5, 5);
6405 fprintf(stderr, "mono_return_short7 s7.f6: got %d but expected %d\n", s7.f6, 6);
6408 fprintf(stderr, "mono_return_short7 s7.f7: got %d but expected %d\n", s7.f7, 7);
6410 s7.f1+=addend; s7.f2+=addend; s7.f3+=addend; s7.f4+=addend; s7.f5+=addend; s7.f6+=addend; s7.f7+=addend;
6415 short f1,f2,f3,f4,f5,f6,f7,f8;
6418 LIBTEST_API short8 STDCALL
6419 mono_return_short8 (short8 s8, int addend) {
6421 fprintf(stderr, "mono_return_short8 s8.f1: got %d but expected %d\n", s8.f1, 1);
6424 fprintf(stderr, "mono_return_short8 s8.f2: got %d but expected %d\n", s8.f2, 2);
6427 fprintf(stderr, "mono_return_short8 s8.f3: got %d but expected %d\n", s8.f3, 3);
6430 fprintf(stderr, "mono_return_short8 s8.f4: got %d but expected %d\n", s8.f4, 4);
6433 fprintf(stderr, "mono_return_short8 s8.f5: got %d but expected %d\n", s8.f5, 5);
6436 fprintf(stderr, "mono_return_short8 s8.f6: got %d but expected %d\n", s8.f6, 6);
6439 fprintf(stderr, "mono_return_short8 s8.f7: got %d but expected %d\n", s8.f7, 7);
6442 fprintf(stderr, "mono_return_short8 s8.f8: got %d but expected %d\n", s8.f8, 8);
6444 s8.f1+=addend; s8.f2+=addend; s8.f3+=addend; s8.f4+=addend; s8.f5+=addend; s8.f6+=addend; s8.f7+=addend; s8.f8+=addend;
6449 short f1,f2,f3,f4,f5,f6,f7,f8,f9;
6452 LIBTEST_API short9 STDCALL
6453 mono_return_short9 (short9 s9, int addend) {
6455 fprintf(stderr, "mono_return_short9 s9.f1: got %d but expected %d\n", s9.f1, 1);
6458 fprintf(stderr, "mono_return_short9 s9.f2: got %d but expected %d\n", s9.f2, 2);
6461 fprintf(stderr, "mono_return_short9 s9.f3: got %d but expected %d\n", s9.f3, 3);
6464 fprintf(stderr, "mono_return_short9 s9.f4: got %d but expected %d\n", s9.f4, 4);
6467 fprintf(stderr, "mono_return_short9 s9.f5: got %d but expected %d\n", s9.f5, 5);
6470 fprintf(stderr, "mono_return_short9 s9.f6: got %d but expected %d\n", s9.f6, 6);
6473 fprintf(stderr, "mono_return_short9 s9.f7: got %d but expected %d\n", s9.f7, 7);
6476 fprintf(stderr, "mono_return_short9 s9.f8: got %d but expected %d\n", s9.f8, 8);
6479 fprintf(stderr, "mono_return_short9 s9.f9: got %d but expected %d\n", s9.f9, 9);
6481 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;
6489 short f2,f3,f4,f5,f6,f7;
6495 LIBTEST_API short8_nested STDCALL
6496 mono_return_short8_nested (short8_nested sn8, int addend) {
6497 if (sn8.nested1.f1 != 1) {
6498 fprintf(stderr, "mono_return_short8_nested sn8.nested1.f1: got %d but expected %d\n", sn8.nested1.f1, 1);
6501 fprintf(stderr, "mono_return_short8_nested sn8.f2: got %d but expected %d\n", sn8.f2, 2);
6504 fprintf(stderr, "mono_return_short8_nested sn8.f3: got %d but expected %d\n", sn8.f3, 3);
6507 fprintf(stderr, "mono_return_short8_nested sn8.f4: got %d but expected %d\n", sn8.f4, 4);
6510 fprintf(stderr, "mono_return_short8_nested sn8.f5: got %d but expected %d\n", sn8.f5, 5);
6513 fprintf(stderr, "mono_return_short8_nested sn8.f6: got %d but expected %d\n", sn8.f6, 6);
6516 fprintf(stderr, "mono_return_short8_nested sn8.f7: got %d but expected %d\n", sn8.f7, 7);
6518 if (sn8.nested2.f8 != 8) {
6519 fprintf(stderr, "mono_return_short8_nested sn8.nested2.f8: got %d but expected %d\n", sn8.nested2.f8, 8);
6521 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;
6530 LIBTEST_API int1 STDCALL
6531 mono_return_int1 (int1 s1, int addend) {
6533 fprintf(stderr, "mono_return_int1 s1.f1: got %d but expected %d\n", s1.f1, 1);
6543 LIBTEST_API int2 STDCALL
6544 mono_return_int2 (int2 s2, int addend) {
6546 fprintf(stderr, "mono_return_int2 s2.f1: got %d but expected %d\n", s2.f1, 1);
6549 fprintf(stderr, "mono_return_int2 s2.f2: got %d but expected %d\n", s2.f2, 2);
6551 s2.f1+=addend; s2.f2+=addend;
6559 LIBTEST_API int3 STDCALL
6560 mono_return_int3 (int3 s3, int addend) {
6562 fprintf(stderr, "mono_return_int3 s3.f1: got %d but expected %d\n", s3.f1, 1);
6565 fprintf(stderr, "mono_return_int3 s3.f2: got %d but expected %d\n", s3.f2, 2);
6568 fprintf(stderr, "mono_return_int3 s3.f3: got %d but expected %d\n", s3.f3, 3);
6570 s3.f1+=addend; s3.f2+=addend; s3.f3+=addend;
6578 LIBTEST_API int4 STDCALL
6579 mono_return_int4 (int4 s4, int addend) {
6581 fprintf(stderr, "mono_return_int4 s4.f1: got %d but expected %d\n", s4.f1, 1);
6584 fprintf(stderr, "mono_return_int4 s4.f2: got %d but expected %d\n", s4.f2, 2);
6587 fprintf(stderr, "mono_return_int4 s4.f3: got %d but expected %d\n", s4.f3, 3);
6590 fprintf(stderr, "mono_return_int4 s4.f4: got %d but expected %d\n", s4.f4, 4);
6592 s4.f1+=addend; s4.f2+=addend; s4.f3+=addend; s4.f4+=addend;
6600 LIBTEST_API int5 STDCALL
6601 mono_return_int5 (int5 s5, int addend) {
6603 fprintf(stderr, "mono_return_int5 s5.f1: got %d but expected %d\n", s5.f1, 1);
6606 fprintf(stderr, "mono_return_int5 s5.f2: got %d but expected %d\n", s5.f2, 2);
6609 fprintf(stderr, "mono_return_int5 s5.f3: got %d but expected %d\n", s5.f3, 3);
6612 fprintf(stderr, "mono_return_int5 s5.f4: got %d but expected %d\n", s5.f4, 4);
6615 fprintf(stderr, "mono_return_int5 s5.f5: got %d but expected %d\n", s5.f5, 5);
6617 s5.f1+=addend; s5.f2+=addend; s5.f3+=addend; s5.f4+=addend; s5.f5+=addend;
6631 LIBTEST_API int4_nested STDCALL
6632 mono_return_int4_nested (int4_nested sn4, int addend) {
6633 if (sn4.nested1.f1 != 1) {
6634 fprintf(stderr, "mono_return_int4_nested sn4.nested1.f1: got %d but expected %d\n", sn4.nested1.f1, 1);
6637 fprintf(stderr, "mono_return_int4_nested sn4.f2: got %d but expected %d\n", sn4.f2, 2);
6640 fprintf(stderr, "mono_return_int4_nested sn4.f3: got %d but expected %d\n", sn4.f3, 3);
6642 if (sn4.nested2.f4 != 4) {
6643 fprintf(stderr, "mono_return_int4_nested sn4.nested2.f4: got %d but expected %d\n", sn4.nested2.f4, 4);
6645 sn4.nested1.f1+=addend; sn4.f2+=addend; sn4.f3+=addend; sn4.nested2.f4+=addend;
6653 LIBTEST_API float1 STDCALL
6654 mono_return_float1 (float1 s1, int addend) {
6656 fprintf(stderr, "mono_return_float1 s1.f1: got %f but expected %d\n", s1.f1, 1);
6666 LIBTEST_API float2 STDCALL
6667 mono_return_float2 (float2 s2, int addend) {
6669 fprintf(stderr, "mono_return_float2 s2.f1: got %f but expected %d\n", s2.f1, 1);
6672 fprintf(stderr, "mono_return_float2 s2.f2: got %f but expected %d\n", s2.f2, 2);
6674 s2.f1+=addend; s2.f2+=addend;
6682 LIBTEST_API float3 STDCALL
6683 mono_return_float3 (float3 s3, int addend) {
6685 fprintf(stderr, "mono_return_float3 s3.f1: got %f but expected %d\n", s3.f1, 1);
6688 fprintf(stderr, "mono_return_float3 s3.f2: got %f but expected %d\n", s3.f2, 2);
6691 fprintf(stderr, "mono_return_float3 s3.f3: got %f but expected %d\n", s3.f3, 3);
6693 s3.f1+=addend; s3.f2+=addend; s3.f3+=addend;
6701 LIBTEST_API float4 STDCALL
6702 mono_return_float4 (float4 s4, int addend) {
6704 fprintf(stderr, "mono_return_float4 s4.f1: got %f but expected %d\n", s4.f1, 1);
6707 fprintf(stderr, "mono_return_float4 s4.f2: got %f but expected %d\n", s4.f2, 2);
6710 fprintf(stderr, "mono_return_float4 s4.f3: got %f but expected %d\n", s4.f3, 3);
6713 fprintf(stderr, "mono_return_float4 s4.f4: got %f but expected %d\n", s4.f4, 4);
6715 s4.f1+=addend; s4.f2+=addend; s4.f3+=addend; s4.f4+=addend;
6720 float f1,f2,f3,f4,f5;
6723 LIBTEST_API float5 STDCALL
6724 mono_return_float5 (float5 s5, int addend) {
6726 fprintf(stderr, "mono_return_float5 s5.f1: got %f but expected %d\n", s5.f1, 1);
6729 fprintf(stderr, "mono_return_float5 s5.f2: got %f but expected %d\n", s5.f2, 2);
6732 fprintf(stderr, "mono_return_float5 s5.f3: got %f but expected %d\n", s5.f3, 3);
6735 fprintf(stderr, "mono_return_float5 s5.f4: got %f but expected %d\n", s5.f4, 4);
6738 fprintf(stderr, "mono_return_float5 s5.f5: got %f but expected %d\n", s5.f5, 5);
6740 s5.f1+=addend; s5.f2+=addend; s5.f3+=addend; s5.f4+=addend; s5.f5+=addend;
6745 float f1,f2,f3,f4,f5,f6;
6748 LIBTEST_API float6 STDCALL
6749 mono_return_float6 (float6 s6, int addend) {
6751 fprintf(stderr, "mono_return_float6 s6.f1: got %f but expected %d\n", s6.f1, 1);
6754 fprintf(stderr, "mono_return_float6 s6.f2: got %f but expected %d\n", s6.f2, 2);
6757 fprintf(stderr, "mono_return_float6 s6.f3: got %f but expected %d\n", s6.f3, 3);
6760 fprintf(stderr, "mono_return_float6 s6.f4: got %f but expected %d\n", s6.f4, 4);
6763 fprintf(stderr, "mono_return_float6 s6.f5: got %f but expected %d\n", s6.f5, 5);
6766 fprintf(stderr, "mono_return_float6 s6.f6: got %f but expected %d\n", s6.f6, 6);
6768 s6.f1+=addend; s6.f2+=addend; s6.f3+=addend; s6.f4+=addend; s6.f5+=addend; s6.f6+=addend;
6773 float f1,f2,f3,f4,f5,f6,f7;
6776 LIBTEST_API float7 STDCALL
6777 mono_return_float7 (float7 s7, int addend) {
6779 fprintf(stderr, "mono_return_float7 s7.f1: got %f but expected %d\n", s7.f1, 1);
6782 fprintf(stderr, "mono_return_float7 s7.f2: got %f but expected %d\n", s7.f2, 2);
6785 fprintf(stderr, "mono_return_float7 s7.f3: got %f but expected %d\n", s7.f3, 3);
6788 fprintf(stderr, "mono_return_float7 s7.f4: got %f but expected %d\n", s7.f4, 4);
6791 fprintf(stderr, "mono_return_float7 s7.f5: got %f but expected %d\n", s7.f5, 5);
6794 fprintf(stderr, "mono_return_float7 s7.f6: got %f but expected %d\n", s7.f6, 6);
6797 fprintf(stderr, "mono_return_float7 s7.f7: got %f but expected %d\n", s7.f7, 7);
6799 s7.f1+=addend; s7.f2+=addend; s7.f3+=addend; s7.f4+=addend; s7.f5+=addend; s7.f6+=addend; s7.f7+=addend;
6804 float f1,f2,f3,f4,f5,f6,f7,f8;
6807 LIBTEST_API float8 STDCALL
6808 mono_return_float8 (float8 s8, int addend) {
6810 fprintf(stderr, "mono_return_float8 s8.f1: got %f but expected %d\n", s8.f1, 1);
6813 fprintf(stderr, "mono_return_float8 s8.f2: got %f but expected %d\n", s8.f2, 2);
6816 fprintf(stderr, "mono_return_float8 s8.f3: got %f but expected %d\n", s8.f3, 3);
6819 fprintf(stderr, "mono_return_float8 s8.f4: got %f but expected %d\n", s8.f4, 4);
6822 fprintf(stderr, "mono_return_float8 s8.f5: got %f but expected %d\n", s8.f5, 5);
6825 fprintf(stderr, "mono_return_float8 s8.f6: got %f but expected %d\n", s8.f6, 6);
6828 fprintf(stderr, "mono_return_float8 s8.f7: got %f but expected %d\n", s8.f7, 7);
6831 fprintf(stderr, "mono_return_float8 s8.f8: got %f but expected %d\n", s8.f8, 8);
6833 s8.f1+=addend; s8.f2+=addend; s8.f3+=addend; s8.f4+=addend; s8.f5+=addend; s8.f6+=addend; s8.f7+=addend; s8.f8+=addend;
6838 float f1,f2,f3,f4,f5,f6,f7,f8,f9;
6841 LIBTEST_API float9 STDCALL
6842 mono_return_float9 (float9 s9, int addend) {
6844 fprintf(stderr, "mono_return_float9 s9.f1: got %f but expected %d\n", s9.f1, 1);
6847 fprintf(stderr, "mono_return_float9 s9.f2: got %f but expected %d\n", s9.f2, 2);
6850 fprintf(stderr, "mono_return_float9 s9.f3: got %f but expected %d\n", s9.f3, 3);
6853 fprintf(stderr, "mono_return_float9 s9.f4: got %f but expected %d\n", s9.f4, 4);
6856 fprintf(stderr, "mono_return_float9 s9.f5: got %f but expected %d\n", s9.f5, 5);
6859 fprintf(stderr, "mono_return_float9 s9.f6: got %f but expected %d\n", s9.f6, 6);
6862 fprintf(stderr, "mono_return_float9 s9.f7: got %f but expected %d\n", s9.f7, 7);
6865 fprintf(stderr, "mono_return_float9 s9.f8: got %f but expected %d\n", s9.f8, 8);
6868 fprintf(stderr, "mono_return_float9 s9.f9: got %f but expected %d\n", s9.f9, 9);
6870 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;
6884 LIBTEST_API float4_nested STDCALL
6885 mono_return_float4_nested (float4_nested sn4, int addend) {
6886 if (sn4.nested1.f1 != 1) {
6887 fprintf(stderr, "mono_return_float4_nested sn4.nested1.f1: got %f but expected %d\n", sn4.nested1.f1, 1);
6890 fprintf(stderr, "mono_return_float4_nested sn4.f2: got %f but expected %d\n", sn4.f2, 2);
6893 fprintf(stderr, "mono_return_float4_nested sn4.f3: got %f but expected %d\n", sn4.f3, 3);
6895 if (sn4.nested2.f4 != 4) {
6896 fprintf(stderr, "mono_return_float4_nested sn4.nested2.f4: got %f but expected %d\n", sn4.nested2.f4, 4);
6898 sn4.nested1.f1+=addend; sn4.f2+=addend; sn4.f3+=addend; sn4.nested2.f4+=addend;
6906 LIBTEST_API double1 STDCALL
6907 mono_return_double1 (double1 s1, int addend) {
6909 fprintf(stderr, "mono_return_double1 s1.f1: got %f but expected %d\n", s1.f1, 1);
6919 LIBTEST_API double2 STDCALL
6920 mono_return_double2 (double2 s2, int addend) {
6922 fprintf(stderr, "mono_return_double2 s2.f1: got %f but expected %d\n", s2.f1, 1);
6925 fprintf(stderr, "mono_return_double2 s2.f2: got %f but expected %d\n", s2.f2, 2);
6927 s2.f1+=addend; s2.f2+=addend;
6935 LIBTEST_API double3 STDCALL
6936 mono_return_double3 (double3 s3, int addend) {
6938 fprintf(stderr, "mono_return_double3 s3.f1: got %f but expected %d\n", s3.f1, 1);
6941 fprintf(stderr, "mono_return_double3 s3.f2: got %f but expected %d\n", s3.f2, 2);
6944 fprintf(stderr, "mono_return_double3 s3.f3: got %f but expected %d\n", s3.f3, 3);
6946 s3.f1+=addend; s3.f2+=addend; s3.f3+=addend;
6954 LIBTEST_API double4 STDCALL
6955 mono_return_double4 (double4 s4, int addend) {
6957 fprintf(stderr, "mono_return_double4 s4.f1: got %f but expected %d\n", s4.f1, 1);
6960 fprintf(stderr, "mono_return_double4 s4.f2: got %f but expected %d\n", s4.f2, 2);
6963 fprintf(stderr, "mono_return_double4 s4.f3: got %f but expected %d\n", s4.f3, 3);
6966 fprintf(stderr, "mono_return_double4 s4.f4: got %f but expected %d\n", s4.f4, 4);
6968 s4.f1+=addend; s4.f2+=addend; s4.f3+=addend; s4.f4+=addend;
6973 double f1,f2,f3,f4,f5;
6976 LIBTEST_API double5 STDCALL
6977 mono_return_double5 (double5 s5, int addend) {
6979 fprintf(stderr, "mono_return_double5 s5.f1: got %f but expected %d\n", s5.f1, 1);
6982 fprintf(stderr, "mono_return_double5 s5.f2: got %f but expected %d\n", s5.f2, 2);
6985 fprintf(stderr, "mono_return_double5 s5.f3: got %f but expected %d\n", s5.f3, 3);
6988 fprintf(stderr, "mono_return_double5 s5.f4: got %f but expected %d\n", s5.f4, 4);
6991 fprintf(stderr, "mono_return_double5 s5.f5: got %f but expected %d\n", s5.f5, 5);
6993 s5.f1+=addend; s5.f2+=addend; s5.f3+=addend; s5.f4+=addend; s5.f5+=addend;
6998 double f1,f2,f3,f4,f5,f6;
7001 LIBTEST_API double6 STDCALL
7002 mono_return_double6 (double6 s6, int addend) {
7004 fprintf(stderr, "mono_return_double6 s6.f1: got %f but expected %d\n", s6.f1, 1);
7007 fprintf(stderr, "mono_return_double6 s6.f2: got %f but expected %d\n", s6.f2, 2);
7010 fprintf(stderr, "mono_return_double6 s6.f3: got %f but expected %d\n", s6.f3, 3);
7013 fprintf(stderr, "mono_return_double6 s6.f4: got %f but expected %d\n", s6.f4, 4);
7016 fprintf(stderr, "mono_return_double6 s6.f5: got %f but expected %d\n", s6.f5, 5);
7019 fprintf(stderr, "mono_return_double6 s6.f6: got %f but expected %d\n", s6.f6, 6);
7021 s6.f1+=addend; s6.f2+=addend; s6.f3+=addend; s6.f4+=addend; s6.f5+=addend; s6.f6+=addend;
7026 double f1,f2,f3,f4,f5,f6,f7;
7029 LIBTEST_API double7 STDCALL
7030 mono_return_double7 (double7 s7, int addend) {
7032 fprintf(stderr, "mono_return_double7 s7.f1: got %f but expected %d\n", s7.f1, 1);
7035 fprintf(stderr, "mono_return_double7 s7.f2: got %f but expected %d\n", s7.f2, 2);
7038 fprintf(stderr, "mono_return_double7 s7.f3: got %f but expected %d\n", s7.f3, 3);
7041 fprintf(stderr, "mono_return_double7 s7.f4: got %f but expected %d\n", s7.f4, 4);
7044 fprintf(stderr, "mono_return_double7 s7.f5: got %f but expected %d\n", s7.f5, 5);
7047 fprintf(stderr, "mono_return_double7 s7.f6: got %f but expected %d\n", s7.f6, 6);
7050 fprintf(stderr, "mono_return_double7 s7.f7: got %f but expected %d\n", s7.f7, 7);
7052 s7.f1+=addend; s7.f2+=addend; s7.f3+=addend; s7.f4+=addend; s7.f5+=addend; s7.f6+=addend; s7.f7+=addend;
7057 double f1,f2,f3,f4,f5,f6,f7,f8;
7060 LIBTEST_API double8 STDCALL
7061 mono_return_double8 (double8 s8, int addend) {
7063 fprintf(stderr, "mono_return_double8 s8.f1: got %f but expected %d\n", s8.f1, 1);
7066 fprintf(stderr, "mono_return_double8 s8.f2: got %f but expected %d\n", s8.f2, 2);
7069 fprintf(stderr, "mono_return_double8 s8.f3: got %f but expected %d\n", s8.f3, 3);
7072 fprintf(stderr, "mono_return_double8 s8.f4: got %f but expected %d\n", s8.f4, 4);
7075 fprintf(stderr, "mono_return_double8 s8.f5: got %f but expected %d\n", s8.f5, 5);
7078 fprintf(stderr, "mono_return_double8 s8.f6: got %f but expected %d\n", s8.f6, 6);
7081 fprintf(stderr, "mono_return_double8 s8.f7: got %f but expected %d\n", s8.f7, 7);
7084 fprintf(stderr, "mono_return_double8 s8.f8: got %f but expected %d\n", s8.f8, 8);
7086 s8.f1+=addend; s8.f2+=addend; s8.f3+=addend; s8.f4+=addend; s8.f5+=addend; s8.f6+=addend; s8.f7+=addend; s8.f8+=addend;
7091 double f1,f2,f3,f4,f5,f6,f7,f8,f9;
7094 LIBTEST_API double9 STDCALL
7095 mono_return_double9 (double9 s9, int addend) {
7097 fprintf(stderr, "mono_return_double9 s9.f1: got %f but expected %d\n", s9.f1, 1);
7100 fprintf(stderr, "mono_return_double9 s9.f2: got %f but expected %d\n", s9.f2, 2);
7103 fprintf(stderr, "mono_return_double9 s9.f3: got %f but expected %d\n", s9.f3, 3);
7106 fprintf(stderr, "mono_return_double9 s9.f4: got %f but expected %d\n", s9.f4, 4);
7109 fprintf(stderr, "mono_return_double9 s9.f5: got %f but expected %d\n", s9.f5, 5);
7112 fprintf(stderr, "mono_return_double9 s9.f6: got %f but expected %d\n", s9.f6, 6);
7115 fprintf(stderr, "mono_return_double9 s9.f7: got %f but expected %d\n", s9.f7, 7);
7118 fprintf(stderr, "mono_return_double9 s9.f8: got %f but expected %d\n", s9.f8, 8);
7121 fprintf(stderr, "mono_return_double9 s9.f9: got %f but expected %d\n", s9.f9, 9);
7123 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;
7136 LIBTEST_API double2_nested STDCALL
7137 mono_return_double2_nested (double2_nested sn2, int addend) {
7138 if (sn2.nested1.f1 != 1) {
7139 fprintf(stderr, "mono_return_double2_nested sn2.nested1.f1: got %f but expected %d\n", sn2.nested1.f1, 1);
7141 if (sn2.nested2.f2 != 2) {
7142 fprintf(stderr, "mono_return_double2_nested sn2.nested2.f2: got %f but expected %d\n", sn2.nested2.f2, 2);
7144 sn2.nested1.f1+=addend; sn2.nested2.f2+=addend;
7154 LIBTEST_API double_array4 STDCALL
7155 mono_return_double_array4 (double_array4 sa4, int addend) {
7156 if (sa4.f1[0] != 1) {
7157 fprintf(stderr, "mono_return_double_array4 sa4.f1[0]: got %f but expected %d\n", sa4.f1[0], 1);
7159 if (sa4.f1[1] != 2) {
7160 fprintf(stderr, "mono_return_double_array4 sa4.f1[1]: got %f but expected %d\n", sa4.f1[1], 2);
7162 if (sa4.f1[2] != 3) {
7163 fprintf(stderr, "mono_return_double_array4 sa4.f1[2]: got %f but expected %d\n", sa4.f1[2], 3);
7165 if (sa4.f1[3] != 4) {
7166 fprintf(stderr, "mono_return_double_array4 sa4.f1[3]: got %f but expected %d\n", sa4.f1[3], 4);
7168 sa4.f1[0]+=addend; sa4.f1[1]+=addend; sa4.f1[2]+=addend; sa4.f1[3]+=addend;