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)
880 return_plus_one (int i)
885 LIBTEST_API SimpleDelegate STDCALL
886 mono_test_marshal_return_delegate_2 (void)
888 return return_plus_one;
891 typedef simplestruct (STDCALL *SimpleDelegate2) (simplestruct ss);
894 is_utf16_equals (gunichar2 *s1, const char *s2)
899 s = g_utf16_to_utf8 (s1, -1, NULL, NULL, NULL);
900 res = strcmp (s, s2);
906 LIBTEST_API int STDCALL
907 mono_test_marshal_delegate2 (SimpleDelegate2 delegate)
909 simplestruct ss, res;
915 ss.d2 = g_utf8_to_utf16 ("TEST2", -1, NULL, NULL, NULL);
918 if (! (res.a && !res.b && res.c && !strcmp (res.d, "TEST-RES") && is_utf16_equals (res.d2, "TEST2-RES")))
924 typedef simplestruct* (STDCALL *SimpleDelegate4) (simplestruct *ss);
926 LIBTEST_API int STDCALL
927 mono_test_marshal_delegate4 (SimpleDelegate4 delegate)
938 res = delegate (&ss);
942 /* Check return value */
943 if (! (!res->a && res->b && !res->c && !strcmp (res->d, "TEST")))
946 /* Check NULL argument and NULL result */
947 res = delegate (NULL);
954 typedef int (STDCALL *SimpleDelegate5) (simplestruct **ss);
956 LIBTEST_API int STDCALL
957 mono_test_marshal_delegate5 (SimpleDelegate5 delegate)
970 res = delegate (&ptr);
974 if (!(ptr->a && !ptr->b && ptr->c && !strcmp (ptr->d, "RES")))
980 LIBTEST_API int STDCALL
981 mono_test_marshal_delegate6 (SimpleDelegate5 delegate)
987 typedef int (STDCALL *SimpleDelegate7) (simplestruct **ss);
989 LIBTEST_API int STDCALL
990 mono_test_marshal_delegate7 (SimpleDelegate7 delegate)
995 /* Check that the input pointer is ignored */
996 ptr = (gpointer)0x12345678;
998 res = delegate (&ptr);
1002 if (!(ptr->a && !ptr->b && ptr->c && !strcmp (ptr->d, "RES")))
1008 typedef int (STDCALL *InOutByvalClassDelegate) (simplestruct *ss);
1010 LIBTEST_API int STDCALL
1011 mono_test_marshal_inout_byval_class_delegate (InOutByvalClassDelegate delegate)
1019 ss.d = g_strdup_printf ("%s", "FOO");
1021 res = delegate (&ss);
1025 if (!(ss.a && !ss.b && ss.c && !strcmp (ss.d, "RES")))
1031 typedef int (STDCALL *SimpleDelegate8) (gunichar2 *s);
1033 LIBTEST_API int STDCALL
1034 mono_test_marshal_delegate8 (SimpleDelegate8 delegate, gunichar2 *s)
1036 return delegate (s);
1039 typedef int (STDCALL *return_int_fnt) (int i);
1040 typedef int (STDCALL *SimpleDelegate9) (return_int_fnt d);
1042 LIBTEST_API int STDCALL
1043 mono_test_marshal_delegate9 (SimpleDelegate9 delegate, gpointer ftn)
1045 return delegate (ftn);
1054 LIBTEST_API int STDCALL
1055 mono_test_marshal_delegate10 (SimpleDelegate9 delegate)
1057 return delegate (return_self);
1060 typedef int (STDCALL *PrimitiveByrefDelegate) (int *i);
1062 LIBTEST_API int STDCALL
1063 mono_test_marshal_primitive_byref_delegate (PrimitiveByrefDelegate delegate)
1067 int res = delegate (&i);
1077 typedef int (STDCALL *return_int_delegate) (int i);
1079 typedef return_int_delegate (STDCALL *ReturnDelegateDelegate) (void);
1081 LIBTEST_API int STDCALL
1082 mono_test_marshal_return_delegate_delegate (ReturnDelegateDelegate d)
1087 LIBTEST_API int STDCALL
1088 mono_test_marshal_stringbuilder (char *s, int n)
1090 const char m[] = "This is my message. Isn't it nice?";
1092 if (strcmp (s, "ABCD") != 0)
1099 LIBTEST_API int STDCALL
1100 mono_test_marshal_stringbuilder_append (char *s, int length)
1102 const char out_sentinel[] = "CSHARP_";
1103 const char out_len = strlen (out_sentinel);
1105 for (int i=0; i < length; i++) {
1106 s [i] = out_sentinel [i % out_len];
1115 LIBTEST_API int STDCALL
1116 mono_test_marshal_stringbuilder_default (char *s, int n)
1118 const char m[] = "This is my message. Isn't it nice?";
1125 LIBTEST_API int STDCALL
1126 mono_test_marshal_stringbuilder_unicode (gunichar2 *s, int n)
1128 const char m[] = "This is my message. Isn't it nice?";
1132 s2 = g_utf8_to_utf16 (m, -1, NULL, &len, NULL);
1134 len = (len * 2) + 2;
1137 memcpy (s, s2, len);
1144 LIBTEST_API void STDCALL
1145 mono_test_marshal_stringbuilder_out (char **s)
1147 const char m[] = "This is my message. Isn't it nice?";
1150 str = marshal_alloc (strlen (m) + 1);
1151 memcpy (str, m, strlen (m) + 1);
1156 LIBTEST_API int STDCALL
1157 mono_test_marshal_stringbuilder_out_unicode (gunichar2 **s)
1159 const char m[] = "This is my message. Isn't it nice?";
1163 s2 = g_utf8_to_utf16 (m, -1, NULL, &len, NULL);
1165 len = (len * 2) + 2;
1166 *s = marshal_alloc (len);
1167 memcpy (*s, s2, len);
1174 LIBTEST_API int STDCALL
1175 mono_test_marshal_stringbuilder_ref (char **s)
1177 const char m[] = "This is my message. Isn't it nice?";
1180 if (strcmp (*s, "ABC"))
1183 str = marshal_alloc (strlen (m) + 1);
1184 memcpy (str, m, strlen (m) + 1);
1196 LIBTEST_API int STDCALL
1197 mono_test_marshal_empty_string_array (char **array)
1199 return (array == NULL) ? 0 : 1;
1202 LIBTEST_API int STDCALL
1203 mono_test_marshal_string_array (char **array)
1205 if (strcmp (array [0], "ABC"))
1207 if (strcmp (array [1], "DEF"))
1210 if (array [2] != NULL)
1216 LIBTEST_API int STDCALL
1217 mono_test_marshal_byref_string_array (char ***array)
1222 if (strcmp ((*array) [0], "Alpha"))
1224 if (strcmp ((*array) [1], "Beta"))
1226 if (strcmp ((*array) [2], "Gamma"))
1232 LIBTEST_API int STDCALL
1233 mono_test_marshal_stringbuilder_array (char **array)
1235 if (strcmp (array [0], "ABC"))
1237 if (strcmp (array [1], "DEF"))
1240 strcpy (array [0], "DEF");
1241 strcpy (array [1], "ABC");
1246 LIBTEST_API int STDCALL
1247 mono_test_marshal_unicode_string_array (gunichar2 **array, char **array2)
1249 GError *error = NULL;
1252 s = g_utf16_to_utf8 (array [0], -1, NULL, NULL, &error);
1253 if (strcmp (s, "ABC")) {
1260 s = g_utf16_to_utf8 (array [1], -1, NULL, NULL, &error);
1261 if (strcmp (s, "DEF")) {
1268 if (strcmp (array2 [0], "ABC"))
1271 if (strcmp (array2 [1], "DEF"))
1277 /* this does not work on Redhat gcc 2.96 */
1278 LIBTEST_API int STDCALL
1279 mono_test_empty_struct (int a, EmptyStruct es, int b)
1281 // printf ("mono_test_empty_struct %d %d\n", a, b);
1283 // Intel icc on ia64 passes 'es' in 2 registers
1284 #if defined(__ia64) && defined(__INTEL_COMPILER)
1287 if (a == 1 && b == 2)
1293 LIBTEST_API EmptyStruct STDCALL
1294 mono_test_return_empty_struct (int a)
1307 LIBTEST_API ByValStrStruct * STDCALL
1308 mono_test_byvalstr_gen (void)
1310 ByValStrStruct *ret;
1312 ret = malloc(sizeof(ByValStrStruct));
1313 memset(ret, 'a', sizeof(ByValStrStruct)-1);
1314 ret->a[sizeof(ByValStrStruct)-1] = 0;
1319 LIBTEST_API int STDCALL
1320 mono_test_byvalstr_check (ByValStrStruct* data, char* correctString)
1324 ret = strcmp(data->a, correctString);
1325 // printf ("T1: %s\n", data->a);
1326 // printf ("T2: %s\n", correctString);
1328 /* we need g_free because the allocation was performed by mono_test_byvalstr_gen */
1336 } ByValStrStruct_Unicode;
1338 LIBTEST_API int STDCALL
1339 mono_test_byvalstr_check_unicode (ByValStrStruct_Unicode *ref, int test)
1341 if (ref->flag != 0x1234abcd){
1342 printf ("overwritten data");
1346 if (test == 1 || test == 3){
1347 if (ref->a [0] != '1' ||
1348 ref->a [1] != '2' ||
1354 if (ref->a [0] != '1' ||
1362 LIBTEST_API int STDCALL
1363 NameManglingAnsi (char *data)
1365 return data [0] + data [1] + data [2];
1368 LIBTEST_API int STDCALL
1369 NameManglingAnsiA (char *data)
1371 g_assert_not_reached ();
1374 LIBTEST_API int STDCALL
1375 NameManglingAnsiW (char *data)
1377 g_assert_not_reached ();
1380 LIBTEST_API int STDCALL
1381 NameManglingAnsi2A (char *data)
1383 return data [0] + data [1] + data [2];
1386 LIBTEST_API int STDCALL
1387 NameManglingAnsi2W (char *data)
1389 g_assert_not_reached ();
1392 LIBTEST_API int STDCALL
1393 NameManglingUnicode (char *data)
1395 g_assert_not_reached ();
1398 LIBTEST_API int STDCALL
1399 NameManglingUnicodeW (gunichar2 *data)
1401 return data [0] + data [1] + data [2];
1404 LIBTEST_API int STDCALL
1405 NameManglingUnicode2 (gunichar2 *data)
1407 return data [0] + data [1] + data [2];
1410 LIBTEST_API int STDCALL
1411 NameManglingAutoW (char *data)
1414 return (data [0] + data [1] + data [2]) == 131 ? 0 : 1;
1416 g_assert_not_reached ();
1420 LIBTEST_API int STDCALL
1421 NameManglingAuto (char *data)
1424 return (data [0] + data [1] + data [2]) == 198 ? 0 : 1;
1426 g_assert_not_reached ();
1430 typedef int (STDCALL *intcharFunc)(const char*);
1432 LIBTEST_API void STDCALL
1433 callFunction (intcharFunc f)
1443 LIBTEST_API int STDCALL
1444 class_marshal_test0 (SimpleObj *obj1)
1446 // printf ("class_marshal_test0 %s %d\n", obj1->str, obj1->i);
1448 if (strcmp(obj1->str, "T1"))
1456 LIBTEST_API int STDCALL
1457 class_marshal_test4 (SimpleObj *obj1)
1465 LIBTEST_API void STDCALL
1466 class_marshal_test1 (SimpleObj **obj1)
1468 SimpleObj *res = malloc (sizeof (SimpleObj));
1470 res->str = marshal_strdup ("ABC");
1476 LIBTEST_API int STDCALL
1477 class_marshal_test2 (SimpleObj **obj1)
1479 // printf ("class_marshal_test2 %s %d\n", (*obj1)->str, (*obj1)->i);
1481 if (strcmp((*obj1)->str, "ABC"))
1483 if ((*obj1)->i != 5)
1489 LIBTEST_API int STDCALL
1490 string_marshal_test0 (char *str)
1492 if (strcmp (str, "TEST0"))
1498 LIBTEST_API void STDCALL
1499 string_marshal_test1 (const char **str)
1501 *str = marshal_strdup ("TEST1");
1504 LIBTEST_API int STDCALL
1505 string_marshal_test2 (char **str)
1507 // printf ("string_marshal_test2 %s\n", *str);
1509 if (strcmp (*str, "TEST1"))
1512 *str = marshal_strdup ("TEST2");
1517 LIBTEST_API int STDCALL
1518 string_marshal_test3 (char *str)
1531 LIBTEST_API BlittableClass* STDCALL
1532 TestBlittableClass (BlittableClass *vl)
1534 BlittableClass *res;
1536 // printf ("TestBlittableClass %d %d\n", vl->a, vl->b);
1542 res = marshal_new0 (BlittableClass, 1);
1543 memcpy (res, vl, sizeof (BlittableClass));
1545 res = marshal_new0 (BlittableClass, 1);
1553 typedef struct OSVERSIONINFO_STRUCT
1557 } OSVERSIONINFO_STRUCT;
1559 LIBTEST_API int STDCALL
1560 MyGetVersionEx (OSVERSIONINFO_STRUCT *osvi)
1563 // printf ("GOT %d %d\n", osvi->a, osvi->b);
1568 return osvi->a + osvi->b;
1571 LIBTEST_API int STDCALL
1572 BugGetVersionEx (int a, int b, int c, int d, int e, int f, int g, int h, 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 mono_test_marshal_point (point pt)
1586 // printf("point %g %g\n", pt.x, pt.y);
1587 if (pt.x == 1.25 && pt.y == 3.5)
1598 LIBTEST_API int STDCALL
1599 mono_test_marshal_mixed_point (mixed_point pt)
1601 // printf("mixed point %d %g\n", pt.x, pt.y);
1602 if (pt.x == 5 && pt.y == 6.75)
1608 LIBTEST_API int STDCALL
1609 mono_test_marshal_mixed_point_2 (mixed_point *pt)
1611 if (pt->x != 5 || pt->y != 6.75)
1620 LIBTEST_API int STDCALL
1621 marshal_test_ref_bool(int i, char *b1, short *b2, int *b3)
1624 if (*b1 != 0 && *b1 != 1)
1626 if (*b2 != 0 && *b2 != -1) /* variant_bool */
1628 if (*b3 != 0 && *b3 != 1)
1630 if (i == ((*b1 << 2) | (-*b2 << 1) | *b3))
1642 short b2; /* variant_bool */
1646 LIBTEST_API int STDCALL
1647 marshal_test_bool_struct(struct BoolStruct *s)
1650 if (s->b1 != 0 && s->b1 != 1)
1652 if (s->b2 != 0 && s->b2 != -1)
1654 if (s->b3 != 0 && s->b3 != 1)
1656 if (s->i == ((s->b1 << 2) | (-s->b2 << 1) | s->b3))
1673 LIBTEST_API int STDCALL
1674 mono_test_marshal_long_struct (LongStruct *s)
1676 return s->i + s->l.l;
1679 LIBTEST_API void STDCALL
1680 mono_test_last_error (int err)
1689 LIBTEST_API int STDCALL
1690 mono_test_asany (void *ptr, int what)
1694 return (*(int*)ptr == 5) ? 0 : 1;
1696 return strcmp (ptr, "ABC") == 0 ? 0 : 1;
1698 simplestruct2 ss = *(simplestruct2*)ptr;
1700 if (ss.a == 0 && ss.b == 1 && ss.c == 0 &&
1701 !strcmp (ss.d, "TEST") &&
1702 ss.e == 99 && ss.f == 1.5 && ss.g == 42 && ss.h == (guint64)123)
1708 GError *error = NULL;
1711 s = g_utf16_to_utf8 (ptr, -1, NULL, NULL, &error);
1716 if (!strcmp (s, "ABC")) {
1726 g_assert_not_reached ();
1740 LIBTEST_API int STDCALL
1741 mono_test_marshal_asany_in (void* ptr)
1743 AsAnyStruct* asAny = ptr;
1744 int res = asAny->i + asAny->j + asAny->k;
1749 LIBTEST_API int STDCALL
1750 mono_test_marshal_asany_inout (void* ptr)
1752 AsAnyStruct* asAny = ptr;
1753 int res = asAny->i + asAny->j + asAny->k;
1755 marshal_free (asAny->s);
1765 LIBTEST_API int STDCALL
1766 mono_test_marshal_asany_out (void* ptr)
1768 AsAnyStruct* asAny = ptr;
1769 int res = asAny->i + asAny->j + asAny->k;
1780 * AMD64 marshalling tests.
1783 typedef struct amd64_struct1 {
1790 LIBTEST_API amd64_struct1 STDCALL
1791 mono_test_marshal_amd64_pass_return_struct1 (amd64_struct1 s)
1801 LIBTEST_API amd64_struct1 STDCALL
1802 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)
1807 s.l += 1 + i1 + i2 + i3 + i4 + i5 + i6 + i7 + i8;
1812 typedef struct amd64_struct2 {
1817 LIBTEST_API amd64_struct2 STDCALL
1818 mono_test_marshal_amd64_pass_return_struct2 (amd64_struct2 s)
1826 typedef struct amd64_struct3 {
1830 LIBTEST_API amd64_struct3 STDCALL
1831 mono_test_marshal_amd64_pass_return_struct3 (amd64_struct3 s)
1838 typedef struct amd64_struct4 {
1842 LIBTEST_API amd64_struct4 STDCALL
1843 mono_test_marshal_amd64_pass_return_struct4 (amd64_struct4 s)
1852 * IA64 marshalling tests.
1854 typedef struct test_struct5 {
1858 LIBTEST_API test_struct5 STDCALL
1859 mono_test_marshal_ia64_pass_return_struct5 (double d1, double d2, test_struct5 s, int i, double d3, double d4)
1861 s.d1 += d1 + d2 + i;
1862 s.d2 += d3 + d4 + i;
1867 typedef struct test_struct6 {
1871 LIBTEST_API test_struct6 STDCALL
1872 mono_test_marshal_ia64_pass_return_struct6 (double d1, double d2, test_struct6 s, int i, double d3, double d4)
1874 s.d1 += d1 + d2 + i;
1880 static guint32 custom_res [2];
1882 LIBTEST_API void* STDCALL
1883 mono_test_marshal_pass_return_custom (int i, guint32 *ptr, int j)
1885 /* ptr will be freed by CleanupNative, so make a copy */
1886 custom_res [0] = 0; /* not allocated by AllocHGlobal */
1887 custom_res [1] = ptr [1];
1892 LIBTEST_API int STDCALL
1893 mono_test_marshal_pass_out_custom (int i, guint32 **ptr, int j)
1896 custom_res [1] = i + j + 10;
1903 LIBTEST_API int STDCALL
1904 mono_test_marshal_pass_inout_custom (int i, guint32 *ptr, int j)
1907 ptr [1] = i + ptr [1] + j;
1912 LIBTEST_API int STDCALL
1913 mono_test_marshal_pass_out_byval_custom (int i, guint32 *ptr, int j)
1915 return ptr == NULL ? 0 : 1;
1918 LIBTEST_API int STDCALL
1919 mono_test_marshal_pass_byref_custom (int i, guint32 **ptr, int j)
1926 LIBTEST_API void* STDCALL
1927 mono_test_marshal_pass_return_custom2 (int i, guint32 *ptr, int j)
1929 g_assert_not_reached ();
1934 LIBTEST_API void* STDCALL
1935 mono_test_marshal_pass_return_custom_null (int i, guint32 *ptr, int j)
1937 g_assert (ptr == NULL);
1942 typedef void *(STDCALL *PassReturnPtrDelegate) (void *ptr);
1944 LIBTEST_API int STDCALL
1945 mono_test_marshal_pass_return_custom_in_delegate (PassReturnPtrDelegate del)
1959 /* FIXME: Freed with FreeHGlobal */
1967 LIBTEST_API int STDCALL
1968 mono_test_marshal_pass_return_custom_null_in_delegate (PassReturnPtrDelegate del)
1970 void *ptr = del (NULL);
1972 return (ptr == NULL) ? 15 : 0;
1975 typedef void (STDCALL *CustomOutParamDelegate) (void **pptr);
1977 LIBTEST_API int STDCALL
1978 mono_test_marshal_custom_out_param_delegate (CustomOutParamDelegate del)
1990 typedef int (STDCALL *ReturnEnumDelegate) (int e);
1992 LIBTEST_API int STDCALL
1993 mono_test_marshal_return_enum_delegate (ReturnEnumDelegate func)
2003 typedef BlittableStruct (STDCALL *SimpleDelegate10) (BlittableStruct ss);
2005 LIBTEST_API int STDCALL
2006 mono_test_marshal_blittable_struct_delegate (SimpleDelegate10 delegate)
2008 BlittableStruct ss, res;
2015 res = delegate (ss);
2016 if (! ((res.a == -1) && (res.b == -2) && (res.c == -3) && (res.d == -55)))
2022 LIBTEST_API int STDCALL
2023 mono_test_stdcall_name_mangling (int a, int b, int c)
2029 mono_test_stdcall_mismatch_1 (int a, int b, int c)
2034 LIBTEST_API int STDCALL
2035 mono_test_stdcall_mismatch_2 (int a, int b, int c)
2041 * PASSING AND RETURNING SMALL STRUCTURES FROM DELEGATES TESTS
2048 typedef SmallStruct1 (STDCALL *SmallStructDelegate1) (SmallStruct1 ss);
2050 LIBTEST_API int STDCALL
2051 mono_test_marshal_small_struct_delegate1 (SmallStructDelegate1 delegate)
2053 SmallStruct1 ss, res;
2057 res = delegate (ss);
2058 if (! (res.i == -1))
2068 typedef SmallStruct2 (STDCALL *SmallStructDelegate2) (SmallStruct2 ss);
2070 LIBTEST_API int STDCALL
2071 mono_test_marshal_small_struct_delegate2 (SmallStructDelegate2 delegate)
2073 SmallStruct2 ss, res;
2078 res = delegate (ss);
2079 if (! ((res.i == -2) && (res.j == -3)))
2090 typedef SmallStruct3 (STDCALL *SmallStructDelegate3) (SmallStruct3 ss);
2092 LIBTEST_API int STDCALL
2093 mono_test_marshal_small_struct_delegate3 (SmallStructDelegate3 delegate)
2095 SmallStruct3 ss, res;
2100 res = delegate (ss);
2101 if (! ((res.i == -1) && (res.j == -2)))
2111 typedef SmallStruct4 (STDCALL *SmallStructDelegate4) (SmallStruct4 ss);
2113 LIBTEST_API int STDCALL
2114 mono_test_marshal_small_struct_delegate4 (SmallStructDelegate4 delegate)
2116 SmallStruct4 ss, res;
2120 res = delegate (ss);
2121 if (! (res.i == -1))
2131 typedef SmallStruct5 (STDCALL *SmallStructDelegate5) (SmallStruct5 ss);
2133 LIBTEST_API int STDCALL
2134 mono_test_marshal_small_struct_delegate5 (SmallStructDelegate5 delegate)
2136 SmallStruct5 ss, res;
2140 res = delegate (ss);
2141 if (! (res.i == -5))
2151 typedef SmallStruct6 (STDCALL *SmallStructDelegate6) (SmallStruct6 ss);
2153 LIBTEST_API int STDCALL
2154 mono_test_marshal_small_struct_delegate6 (SmallStructDelegate6 delegate)
2156 SmallStruct6 ss, res;
2161 res = delegate (ss);
2162 if (! ((res.i == -1) && (res.j == -2)))
2173 typedef SmallStruct7 (STDCALL *SmallStructDelegate7) (SmallStruct7 ss);
2175 LIBTEST_API int STDCALL
2176 mono_test_marshal_small_struct_delegate7 (SmallStructDelegate7 delegate)
2178 SmallStruct7 ss, res;
2183 res = delegate (ss);
2184 if (! ((res.i == -1) && (res.j == -2)))
2194 typedef SmallStruct8 (STDCALL *SmallStructDelegate8) (SmallStruct8 ss);
2196 LIBTEST_API int STDCALL
2197 mono_test_marshal_small_struct_delegate8 (SmallStructDelegate8 delegate)
2199 SmallStruct8 ss, res;
2203 res = delegate (ss);
2204 if (! ((res.i == -1.0)))
2214 typedef SmallStruct9 (STDCALL *SmallStructDelegate9) (SmallStruct9 ss);
2216 LIBTEST_API int STDCALL
2217 mono_test_marshal_small_struct_delegate9 (SmallStructDelegate9 delegate)
2219 SmallStruct9 ss, res;
2223 res = delegate (ss);
2224 if (! ((res.i == -1.0)))
2234 typedef SmallStruct10 (STDCALL *SmallStructDelegate10) (SmallStruct10 ss);
2236 LIBTEST_API int STDCALL
2237 mono_test_marshal_small_struct_delegate10 (SmallStructDelegate10 delegate)
2239 SmallStruct10 ss, res;
2244 res = delegate (ss);
2245 if (! ((res.i == -1.0) && (res.j == -2.0)))
2256 typedef SmallStruct11 (STDCALL *SmallStructDelegate11) (SmallStruct11 ss);
2258 LIBTEST_API int STDCALL
2259 mono_test_marshal_small_struct_delegate11 (SmallStructDelegate11 delegate)
2261 SmallStruct11 ss, res;
2266 res = delegate (ss);
2267 if (! ((res.i == -1.0) && (res.j == -2)))
2273 typedef int (STDCALL *ArrayDelegate) (int i, char *j, void *arr);
2275 LIBTEST_API int STDCALL
2276 mono_test_marshal_array_delegate (void *arr, int len, ArrayDelegate del)
2278 return del (len, NULL, arr);
2281 typedef int (STDCALL *ArrayDelegateLong) (gint64 i, char *j, void *arr);
2283 LIBTEST_API int STDCALL
2284 mono_test_marshal_array_delegate_long (void *arr, gint64 len, ArrayDelegateLong del)
2286 return del (len, NULL, arr);
2289 LIBTEST_API int STDCALL
2290 mono_test_marshal_out_array_delegate (int *arr, int len, ArrayDelegate del)
2292 del (len, NULL, arr);
2294 if ((arr [0] != 1) || (arr [1] != 2))
2300 typedef gunichar2* (STDCALL *UnicodeStringDelegate) (gunichar2 *message);
2302 LIBTEST_API int STDCALL
2303 mono_test_marshal_return_unicode_string_delegate (UnicodeStringDelegate del)
2305 const char m[] = "abcdef";
2306 gunichar2 *s2, *res;
2309 s2 = g_utf8_to_utf16 (m, -1, NULL, &len, NULL);
2318 LIBTEST_API int STDCALL
2319 mono_test_marshal_out_string_array_delegate (char **arr, int len, ArrayDelegate del)
2321 del (len, NULL, arr);
2323 if (!strcmp (arr [0], "ABC") && !strcmp (arr [1], "DEF"))
2329 typedef int (*CdeclDelegate) (int i, int j);
2331 LIBTEST_API int STDCALL
2332 mono_test_marshal_cdecl_delegate (CdeclDelegate del)
2336 for (i = 0; i < 1000; ++i)
2342 typedef char** (STDCALL *ReturnStringArrayDelegate) (int i);
2344 LIBTEST_API int STDCALL
2345 mono_test_marshal_return_string_array_delegate (ReturnStringArrayDelegate d)
2353 if (strcmp (arr [0], "ABC") || strcmp (arr [1], "DEF"))
2363 typedef int (STDCALL *ByrefStringDelegate) (char **s);
2365 LIBTEST_API int STDCALL
2366 mono_test_marshal_byref_string_delegate (ByrefStringDelegate d)
2368 char *s = (char*)"ABC";
2375 if (!strcmp (s, "DEF"))
2385 LIBTEST_API int STDCALL
2386 add_delegate (int i, int j)
2391 LIBTEST_API gpointer STDCALL
2392 mono_test_marshal_return_fnptr (void)
2394 return &add_delegate;
2397 LIBTEST_API int STDCALL
2400 printf ("codigo %x\n", code);
2408 LIBTEST_API HandleRef STDCALL
2409 mono_xr_as_handle (int code)
2413 memset (&ref, 0, sizeof (ref));
2425 LIBTEST_API int STDCALL
2426 mono_safe_handle_struct_ref (HandleStructs *x)
2428 printf ("Dingus Ref! \n");
2429 printf ("Values: %d %d %p %p\n", x->a, x->b, x->handle1, x->handle2);
2435 if (x->handle1 != (void*) 0x7080feed)
2438 if (x->handle2 != (void*) 0x1234abcd)
2444 LIBTEST_API int STDCALL
2445 mono_safe_handle_struct (HandleStructs x)
2447 printf ("Dingus Standard! \n");
2448 printf ("Values: %d %d %p %p\n", x.a, x.b, x.handle1, x.handle2);
2454 if (x.handle1 != (void*) 0x7080feed)
2457 if (x.handle2 != (void*) 0x1234abcd)
2467 LIBTEST_API int STDCALL
2468 mono_safe_handle_struct_simple (TrivialHandle x)
2470 printf ("The value is %p\n", x.a);
2471 return ((int)(gsize)x.a) * 2;
2474 LIBTEST_API int STDCALL
2475 mono_safe_handle_return (void)
2480 LIBTEST_API void STDCALL
2481 mono_safe_handle_ref (void **handle)
2484 *handle = (void *) 0xbad;
2488 *handle = (void *) 0x800d;
2491 LIBTEST_API double STDCALL
2492 mono_test_marshal_date_time (double d, double *d2)
2564 VT_USERDEFINED = 29,
2572 VT_STREAMED_OBJECT = 68,
2573 VT_STORED_OBJECT = 69,
2574 VT_BLOB_OBJECT = 70,
2582 void VariantInit(VARIANT* vt)
2599 LIBTEST_API int STDCALL
2600 mono_test_marshal_bstr_in(gunichar2* bstr)
2603 gchar* bstr_utf8 = g_utf16_to_utf8 (bstr, -1, NULL, NULL, NULL);
2604 result = strcmp("mono_test_marshal_bstr_in", bstr_utf8);
2611 LIBTEST_API int STDCALL
2612 mono_test_marshal_bstr_out(gunichar2** bstr)
2614 *bstr = marshal_bstr_alloc ("mono_test_marshal_bstr_out");
2618 LIBTEST_API int STDCALL
2619 mono_test_marshal_bstr_in_null(gunichar2* bstr)
2626 LIBTEST_API int STDCALL
2627 mono_test_marshal_bstr_out_null(gunichar2** bstr)
2633 LIBTEST_API int STDCALL
2634 mono_test_marshal_variant_in_sbyte(VARIANT variant)
2636 if (variant.vt == VT_I1 && variant.cVal == 100)
2641 LIBTEST_API int STDCALL
2642 mono_test_marshal_variant_in_byte(VARIANT variant)
2644 if (variant.vt == VT_UI1 && variant.bVal == 100)
2649 LIBTEST_API int STDCALL
2650 mono_test_marshal_variant_in_short(VARIANT variant)
2652 if (variant.vt == VT_I2 && variant.iVal == 314)
2657 LIBTEST_API int STDCALL
2658 mono_test_marshal_variant_in_ushort(VARIANT variant)
2660 if (variant.vt == VT_UI2 && variant.uiVal == 314)
2665 LIBTEST_API int STDCALL
2666 mono_test_marshal_variant_in_int(VARIANT variant)
2668 if (variant.vt == VT_I4 && variant.lVal == 314)
2673 LIBTEST_API int STDCALL
2674 mono_test_marshal_variant_in_uint(VARIANT variant)
2676 if (variant.vt == VT_UI4 && variant.ulVal == 314)
2681 LIBTEST_API int STDCALL
2682 mono_test_marshal_variant_in_long(VARIANT variant)
2684 if (variant.vt == VT_I8 && variant.llVal == 314)
2689 LIBTEST_API int STDCALL
2690 mono_test_marshal_variant_in_ulong(VARIANT variant)
2692 if (variant.vt == VT_UI8 && variant.ullVal == 314)
2697 LIBTEST_API int STDCALL
2698 mono_test_marshal_variant_in_float(VARIANT variant)
2700 if (variant.vt == VT_R4 && (variant.fltVal - 3.14)/3.14 < .001)
2705 LIBTEST_API int STDCALL
2706 mono_test_marshal_variant_in_double(VARIANT variant)
2708 if (variant.vt == VT_R8 && (variant.dblVal - 3.14)/3.14 < .001)
2713 LIBTEST_API int STDCALL
2714 mono_test_marshal_variant_in_bstr(VARIANT variant)
2717 gchar* bstr_utf8 = g_utf16_to_utf8 (variant.bstrVal, -1, NULL, NULL, NULL);
2718 result = strcmp("PI", bstr_utf8);
2721 if (variant.vt == VT_BSTR && !result)
2726 LIBTEST_API int STDCALL
2727 mono_test_marshal_variant_in_bool_true (VARIANT variant)
2729 if (variant.vt == VT_BOOL && variant.boolVal == VARIANT_TRUE)
2734 LIBTEST_API int STDCALL
2735 mono_test_marshal_variant_in_bool_false (VARIANT variant)
2737 if (variant.vt == VT_BOOL && variant.boolVal == VARIANT_FALSE)
2742 LIBTEST_API int STDCALL
2743 mono_test_marshal_variant_out_sbyte(VARIANT* variant)
2745 variant->vt = VT_I1;
2746 variant->cVal = 100;
2751 LIBTEST_API int STDCALL
2752 mono_test_marshal_variant_out_sbyte_byref(VARIANT* variant)
2754 variant->vt = VT_I1|VT_BYREF;
2755 variant->byref = marshal_alloc(1);
2756 *((gint8*)variant->byref) = 100;
2761 LIBTEST_API int STDCALL
2762 mono_test_marshal_variant_out_byte(VARIANT* variant)
2764 variant->vt = VT_UI1;
2765 variant->bVal = 100;
2770 LIBTEST_API int STDCALL
2771 mono_test_marshal_variant_out_byte_byref(VARIANT* variant)
2773 variant->vt = VT_UI1|VT_BYREF;
2774 variant->byref = marshal_alloc(1);
2775 *((gint8*)variant->byref) = 100;
2780 LIBTEST_API int STDCALL
2781 mono_test_marshal_variant_out_short(VARIANT* variant)
2783 variant->vt = VT_I2;
2784 variant->iVal = 314;
2789 LIBTEST_API int STDCALL
2790 mono_test_marshal_variant_out_short_byref(VARIANT* variant)
2792 variant->vt = VT_I2|VT_BYREF;
2793 variant->byref = marshal_alloc(2);
2794 *((gint16*)variant->byref) = 314;
2799 LIBTEST_API int STDCALL
2800 mono_test_marshal_variant_out_ushort(VARIANT* variant)
2802 variant->vt = VT_UI2;
2803 variant->uiVal = 314;
2808 LIBTEST_API int STDCALL
2809 mono_test_marshal_variant_out_ushort_byref(VARIANT* variant)
2811 variant->vt = VT_UI2|VT_BYREF;
2812 variant->byref = marshal_alloc(2);
2813 *((guint16*)variant->byref) = 314;
2818 LIBTEST_API int STDCALL
2819 mono_test_marshal_variant_out_int(VARIANT* variant)
2821 variant->vt = VT_I4;
2822 variant->lVal = 314;
2827 LIBTEST_API int STDCALL
2828 mono_test_marshal_variant_out_int_byref(VARIANT* variant)
2830 variant->vt = VT_I4|VT_BYREF;
2831 variant->byref = marshal_alloc(4);
2832 *((gint32*)variant->byref) = 314;
2837 LIBTEST_API int STDCALL
2838 mono_test_marshal_variant_out_uint(VARIANT* variant)
2840 variant->vt = VT_UI4;
2841 variant->ulVal = 314;
2846 LIBTEST_API int STDCALL
2847 mono_test_marshal_variant_out_uint_byref(VARIANT* variant)
2849 variant->vt = VT_UI4|VT_BYREF;
2850 variant->byref = marshal_alloc(4);
2851 *((guint32*)variant->byref) = 314;
2856 LIBTEST_API int STDCALL
2857 mono_test_marshal_variant_out_long(VARIANT* variant)
2859 variant->vt = VT_I8;
2860 variant->llVal = 314;
2865 LIBTEST_API int STDCALL
2866 mono_test_marshal_variant_out_long_byref(VARIANT* variant)
2868 variant->vt = VT_I8|VT_BYREF;
2869 variant->byref = marshal_alloc(8);
2870 *((gint64*)variant->byref) = 314;
2875 LIBTEST_API int STDCALL
2876 mono_test_marshal_variant_out_ulong(VARIANT* variant)
2878 variant->vt = VT_UI8;
2879 variant->ullVal = 314;
2884 LIBTEST_API int STDCALL
2885 mono_test_marshal_variant_out_ulong_byref(VARIANT* variant)
2887 variant->vt = VT_UI8|VT_BYREF;
2888 variant->byref = marshal_alloc(8);
2889 *((guint64*)variant->byref) = 314;
2894 LIBTEST_API int STDCALL
2895 mono_test_marshal_variant_out_float(VARIANT* variant)
2897 variant->vt = VT_R4;
2898 variant->fltVal = 3.14;
2903 LIBTEST_API int STDCALL
2904 mono_test_marshal_variant_out_float_byref(VARIANT* variant)
2906 variant->vt = VT_R4|VT_BYREF;
2907 variant->byref = marshal_alloc(4);
2908 *((float*)variant->byref) = 3.14;
2913 LIBTEST_API int STDCALL
2914 mono_test_marshal_variant_out_double(VARIANT* variant)
2916 variant->vt = VT_R8;
2917 variant->dblVal = 3.14;
2922 LIBTEST_API int STDCALL
2923 mono_test_marshal_variant_out_double_byref(VARIANT* variant)
2925 variant->vt = VT_R8|VT_BYREF;
2926 variant->byref = marshal_alloc(8);
2927 *((double*)variant->byref) = 3.14;
2932 LIBTEST_API int STDCALL
2933 mono_test_marshal_variant_out_bstr(VARIANT* variant)
2935 variant->vt = VT_BSTR;
2936 variant->bstrVal = marshal_bstr_alloc("PI");
2941 LIBTEST_API int STDCALL
2942 mono_test_marshal_variant_out_bstr_byref(VARIANT* variant)
2944 variant->vt = VT_BSTR|VT_BYREF;
2945 variant->byref = marshal_alloc(sizeof(gpointer));
2946 *((gunichar**)variant->byref) = (gunichar*)marshal_bstr_alloc("PI");
2951 LIBTEST_API int STDCALL
2952 mono_test_marshal_variant_out_bool_true (VARIANT* variant)
2954 variant->vt = VT_BOOL;
2955 variant->boolVal = VARIANT_TRUE;
2960 LIBTEST_API int STDCALL
2961 mono_test_marshal_variant_out_bool_true_byref (VARIANT* variant)
2963 variant->vt = VT_BOOL|VT_BYREF;
2964 variant->byref = marshal_alloc(2);
2965 *((gint16*)variant->byref) = VARIANT_TRUE;
2970 LIBTEST_API int STDCALL
2971 mono_test_marshal_variant_out_bool_false (VARIANT* variant)
2973 variant->vt = VT_BOOL;
2974 variant->boolVal = VARIANT_FALSE;
2979 LIBTEST_API int STDCALL
2980 mono_test_marshal_variant_out_bool_false_byref (VARIANT* variant)
2982 variant->vt = VT_BOOL|VT_BYREF;
2983 variant->byref = marshal_alloc(2);
2984 *((gint16*)variant->byref) = VARIANT_FALSE;
2989 typedef int (STDCALL *VarFunc) (int vt, VARIANT variant);
2990 typedef int (STDCALL *VarRefFunc) (int vt, VARIANT* variant);
2992 LIBTEST_API int STDCALL
2993 mono_test_marshal_variant_in_sbyte_unmanaged(VarFunc func)
2998 return func (VT_I1, vt);
3001 LIBTEST_API int STDCALL
3002 mono_test_marshal_variant_in_byte_unmanaged(VarFunc func)
3007 return func (VT_UI1, vt);
3010 LIBTEST_API int STDCALL
3011 mono_test_marshal_variant_in_short_unmanaged(VarFunc func)
3016 return func (VT_I2, vt);
3019 LIBTEST_API int STDCALL
3020 mono_test_marshal_variant_in_ushort_unmanaged(VarFunc func)
3025 return func (VT_UI2, vt);
3028 LIBTEST_API int STDCALL
3029 mono_test_marshal_variant_in_int_unmanaged(VarFunc func)
3034 return func (VT_I4, vt);
3037 LIBTEST_API int STDCALL
3038 mono_test_marshal_variant_in_uint_unmanaged(VarFunc func)
3043 return func (VT_UI4, vt);
3046 LIBTEST_API int STDCALL
3047 mono_test_marshal_variant_in_long_unmanaged(VarFunc func)
3052 return func (VT_I8, vt);
3055 LIBTEST_API int STDCALL
3056 mono_test_marshal_variant_in_ulong_unmanaged(VarFunc func)
3061 return func (VT_UI8, vt);
3064 LIBTEST_API int STDCALL
3065 mono_test_marshal_variant_in_float_unmanaged(VarFunc func)
3070 return func (VT_R4, vt);
3073 LIBTEST_API int STDCALL
3074 mono_test_marshal_variant_in_double_unmanaged(VarFunc func)
3079 return func (VT_R8, vt);
3082 LIBTEST_API int STDCALL
3083 mono_test_marshal_variant_in_bstr_unmanaged(VarFunc func)
3087 vt.bstrVal = marshal_bstr_alloc("PI");
3088 return func (VT_BSTR, vt);
3091 LIBTEST_API int STDCALL
3092 mono_test_marshal_variant_in_bool_true_unmanaged(VarFunc func)
3096 vt.boolVal = VARIANT_TRUE;
3097 return func (VT_BOOL, vt);
3100 LIBTEST_API int STDCALL
3101 mono_test_marshal_variant_in_bool_false_unmanaged(VarFunc func)
3105 vt.boolVal = VARIANT_FALSE;
3106 return func (VT_BOOL, vt);
3109 LIBTEST_API int STDCALL
3110 mono_test_marshal_variant_out_sbyte_unmanaged(VarRefFunc func)
3115 if (vt.vt == VT_I1 && vt.cVal == -100)
3120 LIBTEST_API int STDCALL
3121 mono_test_marshal_variant_out_byte_unmanaged(VarRefFunc func)
3126 if (vt.vt == VT_UI1 && vt.bVal == 100)
3131 LIBTEST_API int STDCALL
3132 mono_test_marshal_variant_out_short_unmanaged(VarRefFunc func)
3137 if (vt.vt == VT_I2 && vt.iVal == -100)
3142 LIBTEST_API int STDCALL
3143 mono_test_marshal_variant_out_ushort_unmanaged(VarRefFunc func)
3148 if (vt.vt == VT_UI2 && vt.uiVal == 100)
3153 LIBTEST_API int STDCALL
3154 mono_test_marshal_variant_out_int_unmanaged(VarRefFunc func)
3159 if (vt.vt == VT_I4 && vt.lVal == -100)
3164 LIBTEST_API int STDCALL
3165 mono_test_marshal_variant_out_uint_unmanaged(VarRefFunc func)
3170 if (vt.vt == VT_UI4 && vt.ulVal == 100)
3175 LIBTEST_API int STDCALL
3176 mono_test_marshal_variant_out_long_unmanaged(VarRefFunc func)
3181 if (vt.vt == VT_I8 && vt.llVal == -100)
3186 LIBTEST_API int STDCALL
3187 mono_test_marshal_variant_out_ulong_unmanaged(VarRefFunc func)
3192 if (vt.vt == VT_UI8 && vt.ullVal == 100)
3197 LIBTEST_API int STDCALL
3198 mono_test_marshal_variant_out_float_unmanaged(VarRefFunc func)
3203 if (vt.vt == VT_R4 && fabs (vt.fltVal - 3.14f) < 1e-10)
3208 LIBTEST_API int STDCALL
3209 mono_test_marshal_variant_out_double_unmanaged(VarRefFunc func)
3214 if (vt.vt == VT_R8 && fabs (vt.dblVal - 3.14) < 1e-10)
3219 LIBTEST_API int STDCALL
3220 mono_test_marshal_variant_out_bstr_unmanaged(VarRefFunc func)
3228 func (VT_BSTR, &vt);
3229 bstr_utf8 = g_utf16_to_utf8 (vt.bstrVal, -1, NULL, NULL, NULL);
3230 result = strcmp("PI", bstr_utf8);
3232 if (vt.vt == VT_BSTR && !result)
3237 LIBTEST_API int STDCALL
3238 mono_test_marshal_variant_out_bool_true_unmanaged(VarRefFunc func)
3242 func (VT_BOOL, &vt);
3243 if (vt.vt == VT_BOOL && vt.boolVal == VARIANT_TRUE)
3248 LIBTEST_API int STDCALL
3249 mono_test_marshal_variant_out_bool_false_unmanaged(VarRefFunc func)
3253 func (VT_BOOL, &vt);
3254 if (vt.vt == VT_BOOL && vt.boolVal == VARIANT_TRUE)
3259 typedef struct MonoComObject MonoComObject;
3263 int (STDCALL *QueryInterface)(MonoComObject* pUnk, gpointer riid, gpointer* ppv);
3264 int (STDCALL *AddRef)(MonoComObject* pUnk);
3265 int (STDCALL *Release)(MonoComObject* pUnk);
3266 int (STDCALL *get_ITest)(MonoComObject* pUnk, MonoComObject* *ppUnk);
3267 int (STDCALL *SByteIn)(MonoComObject* pUnk, char a);
3268 int (STDCALL *ByteIn)(MonoComObject* pUnk, unsigned char a);
3269 int (STDCALL *ShortIn)(MonoComObject* pUnk, short a);
3270 int (STDCALL *UShortIn)(MonoComObject* pUnk, unsigned short a);
3271 int (STDCALL *IntIn)(MonoComObject* pUnk, int a);
3272 int (STDCALL *UIntIn)(MonoComObject* pUnk, unsigned int a);
3273 int (STDCALL *LongIn)(MonoComObject* pUnk, gint64 a);
3274 int (STDCALL *ULongIn)(MonoComObject* pUnk, guint64 a);
3275 int (STDCALL *FloatIn)(MonoComObject* pUnk, float a);
3276 int (STDCALL *DoubleIn)(MonoComObject* pUnk, double a);
3277 int (STDCALL *ITestIn)(MonoComObject* pUnk, MonoComObject* pUnk2);
3278 int (STDCALL *ITestOut)(MonoComObject* pUnk, MonoComObject* *ppUnk);
3281 struct MonoComObject
3287 static GUID IID_ITest = {0, 0, 0, {0,0,0,0,0,0,0,1}};
3288 static GUID IID_IMonoUnknown = {0, 0, 0, {0xc0,0,0,0,0,0,0,0x46}};
3289 static GUID IID_IMonoDispatch = {0x00020400, 0, 0, {0xc0,0,0,0,0,0,0,0x46}};
3291 LIBTEST_API int STDCALL
3292 MonoQueryInterface(MonoComObject* pUnk, gpointer riid, gpointer* ppv)
3296 if (!memcmp(riid, &IID_IMonoUnknown, sizeof(GUID))) {
3300 else if (!memcmp(riid, &IID_ITest, sizeof(GUID))) {
3304 else if (!memcmp(riid, &IID_IMonoDispatch, sizeof(GUID))) {
3308 return 0x80004002; //E_NOINTERFACE;
3311 LIBTEST_API int STDCALL
3312 MonoAddRef(MonoComObject* pUnk)
3314 return ++(pUnk->m_ref);
3317 LIBTEST_API int STDCALL
3318 MonoRelease(MonoComObject* pUnk)
3320 return --(pUnk->m_ref);
3323 LIBTEST_API int STDCALL
3324 SByteIn(MonoComObject* pUnk, char a)
3329 LIBTEST_API int STDCALL
3330 ByteIn(MonoComObject* pUnk, unsigned char a)
3335 LIBTEST_API int STDCALL
3336 ShortIn(MonoComObject* pUnk, short a)
3341 LIBTEST_API int STDCALL
3342 UShortIn(MonoComObject* pUnk, unsigned short a)
3347 LIBTEST_API int STDCALL
3348 IntIn(MonoComObject* pUnk, int a)
3353 LIBTEST_API int STDCALL
3354 UIntIn(MonoComObject* pUnk, unsigned int a)
3359 LIBTEST_API int STDCALL
3360 LongIn(MonoComObject* pUnk, gint64 a)
3365 LIBTEST_API int STDCALL
3366 ULongIn(MonoComObject* pUnk, guint64 a)
3371 LIBTEST_API int STDCALL
3372 FloatIn(MonoComObject* pUnk, float a)
3377 LIBTEST_API int STDCALL
3378 DoubleIn(MonoComObject* pUnk, double a)
3383 LIBTEST_API int STDCALL
3384 ITestIn(MonoComObject* pUnk, MonoComObject *pUnk2)
3389 LIBTEST_API int STDCALL
3390 ITestOut(MonoComObject* pUnk, MonoComObject* *ppUnk)
3395 static void create_com_object (MonoComObject** pOut);
3397 LIBTEST_API int STDCALL
3398 get_ITest(MonoComObject* pUnk, MonoComObject* *ppUnk)
3400 create_com_object (ppUnk);
3404 static void create_com_object (MonoComObject** pOut)
3406 *pOut = marshal_new0 (MonoComObject, 1);
3407 (*pOut)->vtbl = marshal_new0 (MonoIUnknown, 1);
3410 (*pOut)->vtbl->QueryInterface = MonoQueryInterface;
3411 (*pOut)->vtbl->AddRef = MonoAddRef;
3412 (*pOut)->vtbl->Release = MonoRelease;
3413 (*pOut)->vtbl->SByteIn = SByteIn;
3414 (*pOut)->vtbl->ByteIn = ByteIn;
3415 (*pOut)->vtbl->ShortIn = ShortIn;
3416 (*pOut)->vtbl->UShortIn = UShortIn;
3417 (*pOut)->vtbl->IntIn = IntIn;
3418 (*pOut)->vtbl->UIntIn = UIntIn;
3419 (*pOut)->vtbl->LongIn = LongIn;
3420 (*pOut)->vtbl->ULongIn = ULongIn;
3421 (*pOut)->vtbl->FloatIn = FloatIn;
3422 (*pOut)->vtbl->DoubleIn = DoubleIn;
3423 (*pOut)->vtbl->ITestIn = ITestIn;
3424 (*pOut)->vtbl->ITestOut = ITestOut;
3425 (*pOut)->vtbl->get_ITest = get_ITest;
3428 static MonoComObject* same_object = NULL;
3430 LIBTEST_API int STDCALL
3431 mono_test_marshal_com_object_create(MonoComObject* *pUnk)
3433 create_com_object (pUnk);
3436 same_object = *pUnk;
3441 LIBTEST_API int STDCALL
3442 mono_test_marshal_com_object_same(MonoComObject* *pUnk)
3444 *pUnk = same_object;
3449 LIBTEST_API int STDCALL
3450 mono_test_marshal_com_object_destroy(MonoComObject *pUnk)
3452 int ref = --(pUnk->m_ref);
3459 LIBTEST_API int STDCALL
3460 mono_test_marshal_com_object_ref_count(MonoComObject *pUnk)
3465 LIBTEST_API int STDCALL
3466 mono_test_marshal_ccw_itest (MonoComObject *pUnk)
3469 MonoComObject* pTest;
3474 hr = pUnk->vtbl->SByteIn (pUnk, -100);
3477 hr = pUnk->vtbl->ByteIn (pUnk, 100);
3480 hr = pUnk->vtbl->ShortIn (pUnk, -100);
3483 hr = pUnk->vtbl->UShortIn (pUnk, 100);
3486 hr = pUnk->vtbl->IntIn (pUnk, -100);
3489 hr = pUnk->vtbl->UIntIn (pUnk, 100);
3492 hr = pUnk->vtbl->LongIn (pUnk, -100);
3495 hr = pUnk->vtbl->ULongIn (pUnk, 100);
3498 hr = pUnk->vtbl->FloatIn (pUnk, 3.14f);
3501 hr = pUnk->vtbl->DoubleIn (pUnk, 3.14);
3504 hr = pUnk->vtbl->ITestIn (pUnk, pUnk);
3507 hr = pUnk->vtbl->ITestOut (pUnk, &pTest);
3515 * mono_method_get_unmanaged_thunk tests
3518 #if defined(__GNUC__) && ((defined(__i386__) && (defined(__linux__) || defined (__APPLE__)) || defined (__FreeBSD__) || defined(__OpenBSD__)) || (defined(__ppc__) && defined(__APPLE__)))
3519 #define ALIGN(size) __attribute__ ((aligned(size)))
3525 /* thunks.cs:TestStruct */
3526 typedef struct _TestStruct {
3531 /* Searches for mono symbols in all loaded modules */
3533 lookup_mono_symbol (const char *symbol_name)
3536 if (g_module_symbol (g_module_open (NULL, G_MODULE_BIND_LAZY), symbol_name, &symbol))
3542 LIBTEST_API gpointer STDCALL
3543 mono_test_marshal_lookup_symbol (const char *symbol_name)
3545 return lookup_mono_symbol (symbol_name);
3548 #define MONO_BEGIN_EFRAME { void *__region_cookie = mono_threads_enter_gc_unsafe_region ? mono_threads_enter_gc_unsafe_region () : NULL;
3549 #define MONO_END_EFRAME if (mono_threads_exit_gc_unsafe_region) mono_threads_exit_gc_unsafe_region (__region_cookie); }
3552 * test_method_thunk:
3554 * @test_id: the test number
3555 * @test_method_handle: MonoMethod* of the C# test method
3556 * @create_object_method_handle: MonoMethod* of thunks.cs:Test.CreateObject
3558 LIBTEST_API int STDCALL
3559 test_method_thunk (int test_id, gpointer test_method_handle, gpointer create_object_method_handle)
3563 gpointer (*mono_method_get_unmanaged_thunk)(gpointer)
3564 = lookup_mono_symbol ("mono_method_get_unmanaged_thunk");
3566 gpointer (*mono_string_new_wrapper)(const char *)
3567 = lookup_mono_symbol ("mono_string_new_wrapper");
3569 char* (*mono_string_to_utf8)(gpointer)
3570 = lookup_mono_symbol ("mono_string_to_utf8");
3572 gpointer (*mono_object_unbox)(gpointer)
3573 = lookup_mono_symbol ("mono_object_unbox");
3575 gpointer* (*mono_threads_enter_gc_unsafe_region) ()
3576 = lookup_mono_symbol ("mono_threads_enter_gc_unsafe_region");
3578 gpointer (*mono_threads_exit_gc_unsafe_region) (gpointer *)
3579 = lookup_mono_symbol ("mono_threads_exit_gc_unsafe_region");
3583 gpointer test_method, ex = NULL;
3584 gpointer (STDCALL *CreateObject)(gpointer*);
3588 if (!mono_method_get_unmanaged_thunk) {
3593 test_method = mono_method_get_unmanaged_thunk (test_method_handle);
3599 CreateObject = mono_method_get_unmanaged_thunk (create_object_method_handle);
3600 if (!CreateObject) {
3609 /* thunks.cs:Test.Test0 */
3610 void (STDCALL *F)(gpointer*) = test_method;
3616 /* thunks.cs:Test.Test1 */
3617 int (STDCALL *F)(gpointer*) = test_method;
3618 if (F (&ex) != 42) {
3626 /* thunks.cs:Test.Test2 */
3627 gpointer (STDCALL *F)(gpointer, gpointer*) = test_method;
3628 gpointer str = mono_string_new_wrapper ("foo");
3629 if (str != F (str, &ex)) {
3637 /* thunks.cs:Test.Test3 */
3638 gpointer (STDCALL *F)(gpointer, gpointer, gpointer*);
3643 obj = CreateObject (&ex);
3644 str = mono_string_new_wrapper ("bar");
3646 if (str != F (obj, str, &ex)) {
3654 /* thunks.cs:Test.Test4 */
3655 int (STDCALL *F)(gpointer, gpointer, int, gpointer*);
3660 obj = CreateObject (&ex);
3661 str = mono_string_new_wrapper ("bar");
3663 if (42 != F (obj, str, 42, &ex)) {
3672 /* thunks.cs:Test.Test5 */
3673 int (STDCALL *F)(gpointer, gpointer, int, gpointer*);
3678 obj = CreateObject (&ex);
3679 str = mono_string_new_wrapper ("bar");
3681 F (obj, str, 42, &ex);
3691 /* thunks.cs:Test.Test6 */
3692 int (STDCALL *F)(gpointer, guint8, gint16, gint32, gint64, float, double,
3693 gpointer, gpointer*);
3695 gpointer str = mono_string_new_wrapper ("Test6");
3699 obj = CreateObject (&ex);
3701 res = F (obj, 254, 32700, -245378, 6789600, 3.1415, 3.1415, str, &ex);
3716 /* thunks.cs:Test.Test7 */
3717 gint64 (STDCALL *F)(gpointer*) = test_method;
3718 if (F (&ex) != G_MAXINT64) {
3726 /* thunks.cs:Test.Test8 */
3727 void (STDCALL *F)(guint8*, gint16*, gint32*, gint64*, float*, double*,
3728 gpointer*, gpointer*);
3740 F (&a1, &a2, &a3, &a4, &a5, &a6, &a7, &ex);
3750 (fabs (a5 - 3.1415) < 0.001) &&
3751 (fabs (a6 - 3.1415) < 0.001) &&
3752 strcmp (mono_string_to_utf8 (a7), "Test8") == 0)){
3761 /* thunks.cs:Test.Test9 */
3762 void (STDCALL *F)(guint8*, gint16*, gint32*, gint64*, float*, double*,
3763 gpointer*, gpointer*);
3775 F (&a1, &a2, &a3, &a4, &a5, &a6, &a7, &ex);
3785 /* thunks.cs:Test.Test10 */
3786 void (STDCALL *F)(gpointer*, gpointer*);
3788 gpointer obj1, obj2;
3790 obj1 = obj2 = CreateObject (&ex);
3813 /* thunks.cs:TestStruct.Test0 */
3814 int (STDCALL *F)(gpointer*, gpointer*);
3820 obj = CreateObject (&ex);
3831 a1 = mono_object_unbox (obj);
3853 /* check whether the call was really by value */
3854 if (a1->A != 42 || a1->B != 3.1415) {
3863 /* thunks.cs:TestStruct.Test1 */
3864 void (STDCALL *F)(gpointer, gpointer*);
3869 obj = CreateObject (&ex);
3880 a1 = mono_object_unbox (obj);
3899 if (!(fabs (a1->B - 3.1415) < 0.001)) {
3908 /* thunks.cs:TestStruct.Test2 */
3909 gpointer (STDCALL *F)(gpointer*);
3927 a1 = mono_object_unbox (obj);
3934 if (!(fabs (a1->B - 3.1415) < 0.001)) {
3943 /* thunks.cs:TestStruct.Test3 */
3944 void (STDCALL *F)(gpointer, gpointer*);
3949 obj = CreateObject (&ex);
3960 a1 = mono_object_unbox (obj);
4006 LIBTEST_API int STDCALL
4007 mono_test_Winx64_struct1_in (winx64_struct1 var)
4020 LIBTEST_API int STDCALL
4021 mono_test_Winx64_struct2_in (winx64_struct2 var)
4038 LIBTEST_API int STDCALL
4039 mono_test_Winx64_struct3_in (winx64_struct3 var)
4045 if (var.c != 0x1234)
4058 LIBTEST_API int STDCALL
4059 mono_test_Winx64_struct4_in (winx64_struct4 var)
4065 if (var.c != 0x1234)
4067 if (var.d != 0x87654321)
4079 LIBTEST_API int STDCALL
4080 mono_test_Winx64_struct5_in (winx64_struct5 var)
4098 LIBTEST_API int STDCALL
4099 mono_test_Winx64_struct6_in (winx64_struct6 var)
4110 LIBTEST_API int STDCALL
4111 mono_test_Winx64_structs_in1 (winx64_struct1 var1,
4112 winx64_struct2 var2,
4113 winx64_struct3 var3,
4114 winx64_struct4 var4)
4128 if (var3.c != 0x1234)
4135 if (var4.c != 0x1234)
4137 if (var4.d != 0x87654321)
4142 LIBTEST_API int STDCALL
4143 mono_test_Winx64_structs_in2 (winx64_struct1 var1,
4144 winx64_struct1 var2,
4145 winx64_struct1 var3,
4146 winx64_struct1 var4,
4147 winx64_struct1 var5)
4163 LIBTEST_API int STDCALL
4164 mono_test_Winx64_structs_in3 (winx64_struct1 var1,
4165 winx64_struct5 var2,
4166 winx64_struct1 var3,
4167 winx64_struct5 var4,
4168 winx64_struct1 var5,
4169 winx64_struct5 var6)
4204 LIBTEST_API winx64_struct1 STDCALL
4205 mono_test_Winx64_struct1_ret (void)
4212 LIBTEST_API winx64_struct2 STDCALL
4213 mono_test_Winx64_struct2_ret (void)
4221 LIBTEST_API winx64_struct3 STDCALL
4222 mono_test_Winx64_struct3_ret (void)
4231 LIBTEST_API winx64_struct4 STDCALL
4232 mono_test_Winx64_struct4_ret (void)
4242 LIBTEST_API winx64_struct5 STDCALL
4243 mono_test_Winx64_struct5_ret (void)
4252 LIBTEST_API winx64_struct1 STDCALL
4253 mono_test_Winx64_struct1_ret_5_args (char a, char b, char c, char d, char e)
4256 ret.a = a + b + c + d + e;
4260 LIBTEST_API winx64_struct5 STDCALL
4261 mono_test_Winx64_struct5_ret6_args (char a, char b, char c, char d, char e)
4274 } winx64_floatStruct;
4276 LIBTEST_API int STDCALL
4277 mono_test_Winx64_floatStruct (winx64_floatStruct a)
4279 if (a.a > 5.6 || a.a < 5.4)
4282 if (a.b > 9.6 || a.b < 9.4)
4291 } winx64_doubleStruct;
4293 LIBTEST_API int STDCALL
4294 mono_test_Winx64_doubleStruct (winx64_doubleStruct a)
4296 if (a.a > 5.6 || a.a < 5.4)
4302 typedef int (STDCALL *managed_struct1_delegate) (winx64_struct1 a);
4304 LIBTEST_API int STDCALL
4305 mono_test_managed_Winx64_struct1_in(managed_struct1_delegate func)
4312 typedef int (STDCALL *managed_struct5_delegate) (winx64_struct5 a);
4314 LIBTEST_API int STDCALL
4315 mono_test_managed_Winx64_struct5_in(managed_struct5_delegate func)
4324 typedef int (STDCALL *managed_struct1_struct5_delegate) (winx64_struct1 a, winx64_struct5 b,
4325 winx64_struct1 c, winx64_struct5 d,
4326 winx64_struct1 e, winx64_struct5 f);
4328 LIBTEST_API int STDCALL
4329 mono_test_managed_Winx64_struct1_struct5_in(managed_struct1_struct5_delegate func)
4331 winx64_struct1 a, c, e;
4332 winx64_struct5 b, d, f;
4334 b.a = 2; b.b = 3; b.c = 4;
4336 d.a = 6; d.b = 7; d.c = 8;
4338 f.a = 10; f.b = 11; f.c = 12;
4340 return func (a, b, c, d, e, f);
4343 typedef winx64_struct1 (STDCALL *managed_struct1_ret_delegate) (void);
4345 LIBTEST_API int STDCALL
4346 mono_test_Winx64_struct1_ret_managed (managed_struct1_ret_delegate func)
4358 typedef winx64_struct5 (STDCALL *managed_struct5_ret_delegate) (void);
4360 LIBTEST_API int STDCALL
4361 mono_test_Winx64_struct5_ret_managed (managed_struct5_ret_delegate func)
4377 LIBTEST_API int STDCALL
4378 mono_test_marshal_bool_in (int arg, unsigned int expected, unsigned int bDefaultMarsh, unsigned int bBoolCustMarsh,
4379 char bI1CustMarsh, unsigned char bU1CustMarsh, short bVBCustMarsh)
4383 if (bDefaultMarsh != expected)
4387 if (bBoolCustMarsh != expected)
4391 if (bI1CustMarsh != expected)
4395 if (bU1CustMarsh != expected)
4399 if (bVBCustMarsh != expected)
4408 LIBTEST_API int STDCALL
4409 mono_test_marshal_bool_out (int arg, unsigned int testVal, unsigned int* bDefaultMarsh, unsigned int* bBoolCustMarsh,
4410 char* bI1CustMarsh, unsigned char* bU1CustMarsh, unsigned short* bVBCustMarsh)
4416 *bDefaultMarsh = testVal;
4419 if (!bBoolCustMarsh)
4421 *bBoolCustMarsh = testVal;
4426 *bI1CustMarsh = (char)testVal;
4431 *bU1CustMarsh = (unsigned char)testVal;
4436 *bVBCustMarsh = (unsigned short)testVal;
4444 LIBTEST_API int STDCALL
4445 mono_test_marshal_bool_ref (int arg, unsigned int expected, unsigned int testVal, unsigned int* bDefaultMarsh,
4446 unsigned int* bBoolCustMarsh, char* bI1CustMarsh, unsigned char* bU1CustMarsh,
4447 unsigned short* bVBCustMarsh)
4453 if (*bDefaultMarsh != expected)
4455 *bDefaultMarsh = testVal;
4458 if (!bBoolCustMarsh)
4460 if (*bBoolCustMarsh != expected)
4462 *bBoolCustMarsh = testVal;
4467 if (*bI1CustMarsh != expected)
4469 *bI1CustMarsh = (char)testVal;
4474 if (*bU1CustMarsh != expected)
4476 *bU1CustMarsh = (unsigned char)testVal;
4481 if (*bVBCustMarsh != expected)
4483 *bVBCustMarsh = (unsigned short)testVal;
4492 typedef int (STDCALL *MarshalBoolInDelegate) (int arg, unsigned int expected, unsigned int bDefaultMarsh,
4493 unsigned int bBoolCustMarsh, char bI1CustMarsh, unsigned char bU1CustMarsh, unsigned short bVBCustMarsh);
4495 LIBTEST_API int STDCALL
4496 mono_test_managed_marshal_bool_in (int arg, unsigned int expected, unsigned int testVal, MarshalBoolInDelegate pfcn)
4503 return pfcn (arg, expected, testVal, 0, 0, 0, 0);
4505 return pfcn (arg, expected, 0, testVal, 0, 0, 0);
4507 return pfcn (arg, expected, 0, 0, testVal, 0, 0);
4509 return pfcn (arg, expected, 0, 0, 0, testVal, 0);
4511 return pfcn (arg, expected, 0, 0, 0, 0, testVal);
4519 typedef int (STDCALL *MarshalBoolOutDelegate) (int arg, unsigned int expected, unsigned int* bDefaultMarsh,
4520 unsigned int* bBoolCustMarsh, char* bI1CustMarsh, unsigned char* bU1CustMarsh, unsigned short* bVBCustMarsh);
4522 LIBTEST_API int STDCALL
4523 mono_test_managed_marshal_bool_out (int arg, unsigned int expected, unsigned int testVal, MarshalBoolOutDelegate pfcn)
4526 unsigned int lDefaultMarsh, lBoolCustMarsh;
4527 char lI1CustMarsh = 0;
4528 unsigned char lU1CustMarsh = 0;
4529 unsigned short lVBCustMarsh = 0;
4530 lDefaultMarsh = lBoolCustMarsh = 0;
4537 unsigned int ltVal = 0;
4538 ret = pfcn (arg, testVal, <Val, &lBoolCustMarsh, &lI1CustMarsh, &lU1CustMarsh, &lVBCustMarsh);
4540 return 0x0100 + ret;
4541 if (expected != ltVal)
4546 unsigned int ltVal = 0;
4547 ret = pfcn (arg, testVal, &lDefaultMarsh, <Val, &lI1CustMarsh, &lU1CustMarsh, &lVBCustMarsh);
4549 return 0x0300 + ret;
4550 if (expected != ltVal)
4556 ret = pfcn (arg, testVal, &lDefaultMarsh, &lBoolCustMarsh, <Val, &lU1CustMarsh, &lVBCustMarsh);
4558 return 0x0500 + ret;
4559 if (expected != ltVal)
4564 unsigned char ltVal = 0;
4565 ret = pfcn (arg, testVal, &lDefaultMarsh, &lBoolCustMarsh, &lI1CustMarsh, <Val, &lVBCustMarsh);
4567 return 0x0700 + ret;
4568 if (expected != ltVal)
4573 unsigned short ltVal = 0;
4574 ret = pfcn (arg, testVal, &lDefaultMarsh, &lBoolCustMarsh, &lI1CustMarsh, &lU1CustMarsh, <Val);
4576 return 0x0900 + ret;
4577 if (expected != ltVal)
4588 typedef int (STDCALL *MarshalBoolRefDelegate) (int arg, unsigned int expected, unsigned int testVal, unsigned int* bDefaultMarsh,
4589 unsigned int* bBoolCustMarsh, char* bI1CustMarsh, unsigned char* bU1CustMarsh, unsigned short* bVBCustMarsh);
4591 LIBTEST_API int STDCALL
4592 mono_test_managed_marshal_bool_ref (int arg, unsigned int expected, unsigned int testVal, unsigned int outExpected,
4593 unsigned int outTestVal, MarshalBoolRefDelegate pfcn)
4596 unsigned int lDefaultMarsh, lBoolCustMarsh;
4597 char lI1CustMarsh = 0;
4598 unsigned char lU1CustMarsh = 0;
4599 unsigned short lVBCustMarsh = 0;
4600 lDefaultMarsh = lBoolCustMarsh = 0;
4608 unsigned int ltestVal = testVal;
4609 ret = pfcn (arg, expected, outTestVal, <estVal, &lBoolCustMarsh, &lI1CustMarsh, &lU1CustMarsh, &lVBCustMarsh);
4611 return 0x0100 + ret;
4612 if (outExpected != ltestVal)
4618 unsigned int ltestVal = testVal;
4619 ret = pfcn (arg, expected, outTestVal, &lDefaultMarsh, <estVal, &lI1CustMarsh, &lU1CustMarsh, &lVBCustMarsh);
4621 return 0x0300 + ret;
4622 if (outExpected != ltestVal)
4628 char ltestVal = testVal;
4629 ret = pfcn (arg, expected, outTestVal, &lDefaultMarsh, &lBoolCustMarsh, <estVal, &lU1CustMarsh, &lVBCustMarsh);
4631 return 0x0500 + ret;
4632 if (outExpected != ltestVal)
4638 unsigned char ltestVal = testVal;
4639 ret = pfcn (arg, expected, outTestVal, &lDefaultMarsh, &lBoolCustMarsh, &lI1CustMarsh, <estVal, &lVBCustMarsh);
4641 return 0x0700 + ret;
4642 if (outExpected != ltestVal)
4648 unsigned short ltestVal = testVal;
4649 ret = pfcn (arg, expected, outTestVal, &lDefaultMarsh, &lBoolCustMarsh, &lI1CustMarsh, &lU1CustMarsh, <estVal);
4651 return 0x0900 + ret;
4652 if (outExpected != ltestVal)
4665 LIBTEST_API int STDCALL
4666 mono_test_marshal_safearray_out_1dim_vt_bstr_empty (SAFEARRAY** safearray)
4668 /* Create an empty one-dimensional array of variants */
4670 SAFEARRAYBOUND dimensions [1];
4672 dimensions [0].lLbound = 0;
4673 dimensions [0].cElements = 0;
4675 pSA= SafeArrayCreate (VT_VARIANT, 1, dimensions);
4680 LIBTEST_API int STDCALL
4681 mono_test_marshal_safearray_out_1dim_vt_bstr (SAFEARRAY** safearray)
4683 /* Create a one-dimensional array of 10 variants filled with "0" to "9" */
4685 SAFEARRAYBOUND dimensions [1];
4691 dimensions [0].lLbound = 0;
4692 dimensions [0].cElements = 10;
4694 pSA= SafeArrayCreate (VT_VARIANT, 1, dimensions);
4695 for (i= dimensions [0].lLbound; i< (dimensions [0].cElements + dimensions [0].lLbound); i++) {
4697 VariantInit (&vOut);
4699 _ltoa (i,buffer,10);
4700 vOut.bstrVal= marshal_bstr_alloc (buffer);
4702 if ((hr = SafeArrayPutElement (pSA, indices, &vOut)) != S_OK) {
4703 VariantClear (&vOut);
4704 SafeArrayDestroy (pSA);
4707 VariantClear (&vOut);
4713 LIBTEST_API int STDCALL
4714 mono_test_marshal_safearray_out_2dim_vt_i4 (SAFEARRAY** safearray)
4716 /* Create a two-dimensional array of 4x3 variants filled with 11, 12, 13, etc. */
4718 SAFEARRAYBOUND dimensions [2];
4723 dimensions [0].lLbound = 0;
4724 dimensions [0].cElements = 4;
4725 dimensions [1].lLbound = 0;
4726 dimensions [1].cElements = 3;
4728 pSA= SafeArrayCreate(VT_VARIANT, 2, dimensions);
4729 for (i= dimensions [0].lLbound; i< (dimensions [0].cElements + dimensions [0].lLbound); i++) {
4730 for (j= dimensions [1].lLbound; j< (dimensions [1].cElements + dimensions [1].lLbound); j++) {
4732 VariantInit (&vOut);
4734 vOut.lVal = (i+1)*10+(j+1);
4737 if ((hr = SafeArrayPutElement (pSA, indices, &vOut)) != S_OK) {
4738 VariantClear (&vOut);
4739 SafeArrayDestroy (pSA);
4742 VariantClear (&vOut); // does a deep destroy of source VARIANT
4749 LIBTEST_API int STDCALL
4750 mono_test_marshal_safearray_out_4dim_vt_i4 (SAFEARRAY** safearray)
4752 /* Create a four-dimensional array of 10x3x6x7 variants filled with their indices */
4753 /* Also use non zero lower bounds */
4755 SAFEARRAYBOUND dimensions [4];
4760 dimensions [0].lLbound = 15;
4761 dimensions [0].cElements = 10;
4762 dimensions [1].lLbound = 20;
4763 dimensions [1].cElements = 3;
4764 dimensions [2].lLbound = 5;
4765 dimensions [2].cElements = 6;
4766 dimensions [3].lLbound = 12;
4767 dimensions [3].cElements = 7;
4769 pSA= SafeArrayCreate (VT_VARIANT, 4, dimensions);
4771 SafeArrayAccessData (pSA, (void **)&pData);
4773 for (i= 0; i< 10*3*6*7; i++) {
4774 VariantInit(&pData [i]);
4775 pData [i].vt = VT_I4;
4778 SafeArrayUnaccessData (pSA);
4783 LIBTEST_API int STDCALL
4784 mono_test_marshal_safearray_in_byval_1dim_empty (SAFEARRAY* safearray)
4786 /* Check that array is one dimensional and empty */
4789 long lbound, ubound;
4791 dim = SafeArrayGetDim (safearray);
4795 SafeArrayGetLBound (safearray, 1, &lbound);
4796 SafeArrayGetUBound (safearray, 1, &ubound);
4798 if ((lbound > 0) || (ubound > 0))
4804 LIBTEST_API int STDCALL
4805 mono_test_marshal_safearray_in_byval_1dim_vt_i4 (SAFEARRAY* safearray)
4807 /* Check that array is one dimensional containing integers from 1 to 10 */
4810 long lbound, ubound;
4815 dim = SafeArrayGetDim (safearray);
4819 SafeArrayGetLBound (safearray, 1, &lbound);
4820 SafeArrayGetUBound (safearray, 1, &ubound);
4822 if ((lbound != 0) || (ubound != 9))
4825 SafeArrayAccessData (safearray, (void **)&pData);
4826 for (i= lbound; i <= ubound; i++) {
4827 if ((VariantChangeType (&pData [i], &pData [i], VARIANT_NOUSEROVERRIDE, VT_I4) != S_OK) || (pData [i].lVal != i + 1))
4830 SafeArrayUnaccessData (safearray);
4835 LIBTEST_API int STDCALL
4836 mono_test_marshal_safearray_in_byval_1dim_vt_mixed (SAFEARRAY* safearray)
4838 /* Check that array is one dimensional containing integers mixed with strings from 0 to 12 */
4841 long lbound, ubound;
4848 VariantInit (&element);
4850 dim = SafeArrayGetDim (safearray);
4854 SafeArrayGetLBound (safearray, 1, &lbound);
4855 SafeArrayGetUBound (safearray, 1, &ubound);
4857 if ((lbound != 0) || (ubound != 12))
4860 SafeArrayAccessData (safearray, (void **)&pData);
4861 for (i= lbound; i <= ubound; i++) {
4862 if ((i%2 == 0) && (pData [i].vt != VT_I4))
4864 if ((i%2 == 1) && (pData [i].vt != VT_BSTR))
4866 if ((VariantChangeType (&pData [i], &pData [i], VARIANT_NOUSEROVERRIDE, VT_I4) != S_OK) || (pData [i].lVal != i))
4869 SafeArrayUnaccessData (safearray);
4871 /* Change the first element of the array to verify that [in] parameters are not marshalled back to the managed side */
4876 SafeArrayPutElement (safearray, indices, &element);
4877 VariantClear (&element);
4882 LIBTEST_API int STDCALL
4883 mono_test_marshal_safearray_in_byval_2dim_vt_i4 (SAFEARRAY* safearray)
4885 /* Check that array is one dimensional containing integers mixed with strings from 0 to 12 */
4888 long lbound1, ubound1, lbound2, ubound2;
4893 VariantInit (&element);
4895 dim = SafeArrayGetDim (safearray);
4899 SafeArrayGetLBound (safearray, 1, &lbound1);
4900 SafeArrayGetUBound (safearray, 1, &ubound1);
4902 if ((lbound1 != 0) || (ubound1 != 1))
4905 SafeArrayGetLBound (safearray, 2, &lbound2);
4906 SafeArrayGetUBound (safearray, 2, &ubound2);
4908 if ((lbound2 != 0) || (ubound2 != 3)) {
4912 for (i= lbound1; i <= ubound1; i++) {
4914 for (j= lbound2; j <= ubound2; j++) {
4916 if (SafeArrayGetElement (safearray, indices, &element) != S_OK)
4918 failed = ((element.vt != VT_I4) || (element.lVal != 10*(i+1)+(j+1)));
4919 VariantClear (&element);
4925 /* Change the first element of the array to verify that [in] parameters are not marshalled back to the managed side */
4931 SafeArrayPutElement (safearray, indices, &element);
4932 VariantClear (&element);
4937 LIBTEST_API int STDCALL
4938 mono_test_marshal_safearray_in_byval_3dim_vt_bstr (SAFEARRAY* safearray)
4940 /* Check that array is one dimensional containing integers mixed with strings from 0 to 12 */
4943 long lbound1, ubound1, lbound2, ubound2, lbound3, ubound3;
4944 long i, j, k, failed;
4948 VariantInit (&element);
4950 dim = SafeArrayGetDim (safearray);
4954 SafeArrayGetLBound (safearray, 1, &lbound1);
4955 SafeArrayGetUBound (safearray, 1, &ubound1);
4957 if ((lbound1 != 0) || (ubound1 != 1))
4960 SafeArrayGetLBound (safearray, 2, &lbound2);
4961 SafeArrayGetUBound (safearray, 2, &ubound2);
4963 if ((lbound2 != 0) || (ubound2 != 1))
4966 SafeArrayGetLBound (safearray, 3, &lbound3);
4967 SafeArrayGetUBound (safearray, 3, &ubound3);
4969 if ((lbound3 != 0) || (ubound3 != 2))
4972 for (i= lbound1; i <= ubound1; i++) {
4974 for (j= lbound2; j <= ubound2; j++) {
4976 for (k= lbound3; k <= ubound3; k++) {
4978 if (SafeArrayGetElement (safearray, indices, &element) != S_OK)
4980 failed = ((element.vt != VT_BSTR)
4981 || (VariantChangeType (&element, &element, VARIANT_NOUSEROVERRIDE, VT_I4) != S_OK)
4982 || (element.lVal != 100*(i+1)+10*(j+1)+(k+1)));
4983 VariantClear (&element);
4990 /* Change the first element of the array to verify that [in] parameters are not marshalled back to the managed side */
4995 element.vt = VT_BSTR;
4996 element.bstrVal = SysAllocString(L"Should not be copied");
4997 SafeArrayPutElement (safearray, indices, &element);
4998 VariantClear (&element);
5003 LIBTEST_API int STDCALL
5004 mono_test_marshal_safearray_in_byref_3dim_vt_bstr (SAFEARRAY** safearray)
5006 return mono_test_marshal_safearray_in_byval_3dim_vt_bstr (*safearray);
5009 LIBTEST_API int STDCALL
5010 mono_test_marshal_safearray_in_out_byref_1dim_empty (SAFEARRAY** safearray)
5012 /* Check that the input array is what is expected and change it so the caller can check */
5013 /* correct marshalling back to managed code */
5016 long lbound, ubound;
5017 SAFEARRAYBOUND dimensions [1];
5019 wchar_t buffer [20];
5023 /* Check that in array is one dimensional and empty */
5025 dim = SafeArrayGetDim (*safearray);
5030 SafeArrayGetLBound (*safearray, 1, &lbound);
5031 SafeArrayGetUBound (*safearray, 1, &ubound);
5033 if ((lbound > 0) || (ubound > 0)) {
5037 /* Re-dimension the array and return a one-dimensional array of 8 variants filled with "0" to "7" */
5039 dimensions [0].lLbound = 0;
5040 dimensions [0].cElements = 8;
5042 hr = SafeArrayRedim (*safearray, dimensions);
5046 for (i= dimensions [0].lLbound; i< (dimensions [0].lLbound + dimensions [0].cElements); i++) {
5048 VariantInit (&vOut);
5050 _ltow (i,buffer,10);
5051 vOut.bstrVal = SysAllocString (buffer);
5053 if ((hr = SafeArrayPutElement (*safearray, indices, &vOut)) != S_OK) {
5054 VariantClear (&vOut);
5055 SafeArrayDestroy (*safearray);
5058 VariantClear (&vOut);
5063 LIBTEST_API int STDCALL
5064 mono_test_marshal_safearray_in_out_byref_3dim_vt_bstr (SAFEARRAY** safearray)
5066 /* Check that the input array is what is expected and change it so the caller can check */
5067 /* correct marshalling back to managed code */
5070 long lbound1, ubound1, lbound2, ubound2, lbound3, ubound3;
5071 SAFEARRAYBOUND dimensions [1];
5072 long i, j, k, failed;
5073 wchar_t buffer [20];
5078 VariantInit (&element);
5080 /* Check that in array is three dimensional and contains the expected values */
5082 dim = SafeArrayGetDim (*safearray);
5086 SafeArrayGetLBound (*safearray, 1, &lbound1);
5087 SafeArrayGetUBound (*safearray, 1, &ubound1);
5089 if ((lbound1 != 0) || (ubound1 != 1))
5092 SafeArrayGetLBound (*safearray, 2, &lbound2);
5093 SafeArrayGetUBound (*safearray, 2, &ubound2);
5095 if ((lbound2 != 0) || (ubound2 != 1))
5098 SafeArrayGetLBound (*safearray, 3, &lbound3);
5099 SafeArrayGetUBound (*safearray, 3, &ubound3);
5101 if ((lbound3 != 0) || (ubound3 != 2))
5104 for (i= lbound1; i <= ubound1; i++) {
5106 for (j= lbound2; j <= ubound2; j++) {
5108 for (k= lbound3; k <= ubound3; k++) {
5110 if (SafeArrayGetElement (*safearray, indices, &element) != S_OK)
5112 failed = ((element.vt != VT_BSTR)
5113 || (VariantChangeType (&element, &element, VARIANT_NOUSEROVERRIDE, VT_I4) != S_OK)
5114 || (element.lVal != 100*(i+1)+10*(j+1)+(k+1)));
5115 VariantClear (&element);
5122 hr = SafeArrayDestroy (*safearray);
5126 /* Return a new one-dimensional array of 8 variants filled with "0" to "7" */
5128 dimensions [0].lLbound = 0;
5129 dimensions [0].cElements = 8;
5131 *safearray = SafeArrayCreate (VT_VARIANT, 1, dimensions);
5133 for (i= dimensions [0].lLbound; i< (dimensions [0].lLbound + dimensions [0].cElements); i++) {
5135 VariantInit (&vOut);
5137 _ltow (i,buffer,10);
5138 vOut.bstrVal = SysAllocString (buffer);
5140 if ((hr = SafeArrayPutElement (*safearray, indices, &vOut)) != S_OK) {
5141 VariantClear (&vOut);
5142 SafeArrayDestroy (*safearray);
5145 VariantClear (&vOut);
5150 LIBTEST_API int STDCALL
5151 mono_test_marshal_safearray_in_out_byref_1dim_vt_i4 (SAFEARRAY** safearray)
5153 /* Check that the input array is what is expected and change it so the caller can check */
5154 /* correct marshalling back to managed code */
5157 long lbound1, ubound1;
5163 VariantInit (&element);
5165 /* Check that in array is one dimensional and contains the expected value */
5167 dim = SafeArrayGetDim (*safearray);
5171 SafeArrayGetLBound (*safearray, 1, &lbound1);
5172 SafeArrayGetUBound (*safearray, 1, &ubound1);
5175 if ((lbound1 != 0) || (ubound1 != 1))
5179 for (i= lbound1; i <= ubound1; i++) {
5181 if (SafeArrayGetElement (*safearray, indices, &element) != S_OK)
5183 failed = (element.vt != VT_I4) || (element.lVal != i+1);
5184 VariantClear (&element);
5189 /* Change one of the elements of the array to verify that [out] parameter is marshalled back to the managed side */
5194 SafeArrayPutElement (*safearray, indices, &element);
5195 VariantClear (&element);
5200 LIBTEST_API int STDCALL
5201 mono_test_marshal_safearray_in_out_byval_1dim_vt_i4 (SAFEARRAY* safearray)
5203 /* Check that the input array is what is expected and change it so the caller can check */
5204 /* correct marshalling back to managed code */
5207 long lbound1, ubound1;
5208 SAFEARRAYBOUND dimensions [1];
5214 VariantInit (&element);
5216 /* Check that in array is one dimensional and contains the expected value */
5218 dim = SafeArrayGetDim (safearray);
5222 SafeArrayGetLBound (safearray, 1, &lbound1);
5223 SafeArrayGetUBound (safearray, 1, &ubound1);
5225 if ((lbound1 != 0) || (ubound1 != 0))
5228 for (i= lbound1; i <= ubound1; i++) {
5230 if (SafeArrayGetElement (safearray, indices, &element) != S_OK)
5232 failed = (element.vt != VT_I4) || (element.lVal != i+1);
5233 VariantClear (&element);
5238 /* Change the array to verify how [out] parameter is marshalled back to the managed side */
5240 /* Redimension the array */
5241 dimensions [0].lLbound = lbound1;
5242 dimensions [0].cElements = 2;
5243 hr = SafeArrayRedim(safearray, dimensions);
5247 element.lVal = 12345;
5248 SafeArrayPutElement (safearray, indices, &element);
5249 VariantClear (&element);
5253 element.lVal = -12345;
5254 SafeArrayPutElement (safearray, indices, &element);
5255 VariantClear (&element);
5260 LIBTEST_API int STDCALL
5261 mono_test_marshal_safearray_in_out_byval_3dim_vt_bstr (SAFEARRAY* safearray)
5263 /* Check that the input array is what is expected and change it so the caller can check */
5264 /* correct marshalling back to managed code */
5267 long lbound1, ubound1, lbound2, ubound2, lbound3, ubound3;
5268 long i, j, k, failed;
5273 VariantInit (&element);
5275 /* Check that in array is three dimensional and contains the expected values */
5277 dim = SafeArrayGetDim (safearray);
5281 SafeArrayGetLBound (safearray, 1, &lbound1);
5282 SafeArrayGetUBound (safearray, 1, &ubound1);
5284 if ((lbound1 != 0) || (ubound1 != 1))
5287 SafeArrayGetLBound (safearray, 2, &lbound2);
5288 SafeArrayGetUBound (safearray, 2, &ubound2);
5290 if ((lbound2 != 0) || (ubound2 != 1))
5293 SafeArrayGetLBound (safearray, 3, &lbound3);
5294 SafeArrayGetUBound (safearray, 3, &ubound3);
5296 if ((lbound3 != 0) || (ubound3 != 2))
5299 for (i= lbound1; i <= ubound1; i++) {
5301 for (j= lbound2; j <= ubound2; j++) {
5303 for (k= lbound3; k <= ubound3; k++) {
5305 if (SafeArrayGetElement (safearray, indices, &element) != S_OK)
5307 failed = ((element.vt != VT_BSTR)
5308 || (VariantChangeType (&element, &element, VARIANT_NOUSEROVERRIDE, VT_I4) != S_OK)
5309 || (element.lVal != 100*(i+1)+10*(j+1)+(k+1)));
5310 VariantClear (&element);
5317 /* Change the elements of the array to verify that [out] parameter is marshalled back to the managed side */
5324 SafeArrayPutElement (safearray, indices, &element);
5325 VariantClear (&element);
5332 SafeArrayPutElement (safearray, indices, &element);
5333 VariantClear (&element);
5338 element.vt = VT_BSTR;
5339 element.bstrVal = marshal_bstr_alloc("ABCDEFG");
5340 SafeArrayPutElement (safearray, indices, &element);
5341 VariantClear (&element);
5346 LIBTEST_API int STDCALL
5347 mono_test_marshal_safearray_mixed(
5348 SAFEARRAY *safearray1,
5349 SAFEARRAY **safearray2,
5350 SAFEARRAY *safearray3,
5351 SAFEARRAY **safearray4
5356 /* Initialize out parameters */
5359 /* array1: Check that in array is one dimensional and contains the expected value */
5360 hr = mono_test_marshal_safearray_in_out_byval_1dim_vt_i4 (safearray1);
5362 /* array2: Fill in with some values to check on the managed side */
5364 hr = mono_test_marshal_safearray_out_1dim_vt_bstr (safearray2);
5366 /* array3: Check that in array is one dimensional and contains the expected value */
5368 hr = mono_test_marshal_safearray_in_byval_1dim_vt_mixed(safearray3);
5370 /* array4: Check input values and fill in with some values to check on the managed side */
5372 hr = mono_test_marshal_safearray_in_out_byref_3dim_vt_bstr(safearray4);
5379 static int call_managed_res;
5382 call_managed (gpointer arg)
5384 SimpleDelegate del = arg;
5386 call_managed_res = del (42);
5389 LIBTEST_API int STDCALL
5390 mono_test_marshal_thread_attach (SimpleDelegate del)
5398 res = pthread_create (&t, NULL, (gpointer)call_managed, del);
5399 g_assert (res == 0);
5400 pthread_join (t, NULL);
5402 return call_managed_res;
5406 typedef int (STDCALL *Callback) (void);
5408 static Callback callback;
5410 LIBTEST_API void STDCALL
5411 mono_test_marshal_set_callback (Callback cb)
5416 LIBTEST_API int STDCALL
5417 mono_test_marshal_call_callback (void)
5422 LIBTEST_API int STDCALL
5423 mono_test_marshal_lpstr (char *str)
5425 return strcmp ("ABC", str);
5428 LIBTEST_API int STDCALL
5429 mono_test_marshal_lpwstr (gunichar2 *str)
5434 s = g_utf16_to_utf8 (str, -1, NULL, NULL, NULL);
5435 res = strcmp ("ABC", s);
5441 LIBTEST_API char* STDCALL
5442 mono_test_marshal_return_lpstr (void)
5444 char *res = marshal_alloc (4);
5445 strcpy (res, "XYZ");
5450 LIBTEST_API gunichar2* STDCALL
5451 mono_test_marshal_return_lpwstr (void)
5453 gunichar2 *res = marshal_alloc (8);
5454 gunichar2* tmp = g_utf8_to_utf16 ("XYZ", -1, NULL, NULL, NULL);
5456 memcpy (res, tmp, 8);
5464 } SingleDoubleStruct;
5466 LIBTEST_API SingleDoubleStruct STDCALL
5467 mono_test_marshal_return_single_double_struct (void)
5469 SingleDoubleStruct res;
5479 LIBTEST_API int STDCALL
5480 mono_test_has_thiscall (void)
5486 _mono_test_native_thiscall1 (int arg)
5492 _mono_test_native_thiscall2 (int arg, int arg2)
5494 return arg + (arg2^1);
5498 _mono_test_native_thiscall3 (int arg, int arg2, int arg3)
5500 return arg + (arg2^1) + (arg3^2);
5503 #elif defined(__GNUC__)
5505 LIBTEST_API int STDCALL
5506 mono_test_has_thiscall (void)
5511 #define def_asm_fn(name) \
5513 "\t.globl _" #name "\n" \
5515 "\t.globl __" #name "\n" \
5520 def_asm_fn(mono_test_native_thiscall1)
5521 "\tmovl %ecx,%eax\n"
5524 def_asm_fn(mono_test_native_thiscall2)
5525 "\tmovl %ecx,%eax\n"
5526 "\tmovl 4(%esp),%ecx\n"
5528 "\taddl %ecx,%eax\n"
5531 def_asm_fn(mono_test_native_thiscall3)
5532 "\tmovl %ecx,%eax\n"
5533 "\tmovl 4(%esp),%ecx\n"
5535 "\taddl %ecx,%eax\n"
5536 "\tmovl 8(%esp),%ecx\n"
5538 "\taddl %ecx,%eax\n"
5545 LIBTEST_API int STDCALL
5546 mono_test_has_thiscall (void)
5558 LIBTEST_API sbyte1 STDCALL
5559 mono_return_sbyte1 (sbyte1 s1, int addend) {
5561 fprintf(stderr, "mono_return_sbyte1 s1.f1: got %d but expected %d\n", s1.f1, 1);
5571 LIBTEST_API sbyte2 STDCALL
5572 mono_return_sbyte2 (sbyte2 s2, int addend) {
5574 fprintf(stderr, "mono_return_sbyte2 s2.f1: got %d but expected %d\n", s2.f1, 1);
5577 fprintf(stderr, "mono_return_sbyte2 s2.f2: got %d but expected %d\n", s2.f2, 2);
5579 s2.f1+=addend; s2.f2+=addend;
5587 LIBTEST_API sbyte3 STDCALL
5588 mono_return_sbyte3 (sbyte3 s3, int addend) {
5590 fprintf(stderr, "mono_return_sbyte3 s3.f1: got %d but expected %d\n", s3.f1, 1);
5593 fprintf(stderr, "mono_return_sbyte3 s3.f2: got %d but expected %d\n", s3.f2, 2);
5596 fprintf(stderr, "mono_return_sbyte3 s3.f3: got %d but expected %d\n", s3.f3, 3);
5598 s3.f1+=addend; s3.f2+=addend; s3.f3+=addend;
5606 LIBTEST_API sbyte4 STDCALL
5607 mono_return_sbyte4 (sbyte4 s4, int addend) {
5609 fprintf(stderr, "mono_return_sbyte4 s4.f1: got %d but expected %d\n", s4.f1, 1);
5612 fprintf(stderr, "mono_return_sbyte4 s4.f2: got %d but expected %d\n", s4.f2, 2);
5615 fprintf(stderr, "mono_return_sbyte4 s4.f3: got %d but expected %d\n", s4.f3, 3);
5618 fprintf(stderr, "mono_return_sbyte4 s4.f4: got %d but expected %d\n", s4.f4, 4);
5620 s4.f1+=addend; s4.f2+=addend; s4.f3+=addend; s4.f4+=addend;
5625 char f1,f2,f3,f4,f5;
5628 LIBTEST_API sbyte5 STDCALL
5629 mono_return_sbyte5 (sbyte5 s5, int addend) {
5631 fprintf(stderr, "mono_return_sbyte5 s5.f1: got %d but expected %d\n", s5.f1, 1);
5634 fprintf(stderr, "mono_return_sbyte5 s5.f2: got %d but expected %d\n", s5.f2, 2);
5637 fprintf(stderr, "mono_return_sbyte5 s5.f3: got %d but expected %d\n", s5.f3, 3);
5640 fprintf(stderr, "mono_return_sbyte5 s5.f4: got %d but expected %d\n", s5.f4, 4);
5643 fprintf(stderr, "mono_return_sbyte5 s5.f5: got %d but expected %d\n", s5.f5, 5);
5645 s5.f1+=addend; s5.f2+=addend; s5.f3+=addend; s5.f4+=addend; s5.f5+=addend;
5650 char f1,f2,f3,f4,f5,f6;
5653 LIBTEST_API sbyte6 STDCALL
5654 mono_return_sbyte6 (sbyte6 s6, int addend) {
5656 fprintf(stderr, "mono_return_sbyte6 s6.f1: got %d but expected %d\n", s6.f1, 1);
5659 fprintf(stderr, "mono_return_sbyte6 s6.f2: got %d but expected %d\n", s6.f2, 2);
5662 fprintf(stderr, "mono_return_sbyte6 s6.f3: got %d but expected %d\n", s6.f3, 3);
5665 fprintf(stderr, "mono_return_sbyte6 s6.f4: got %d but expected %d\n", s6.f4, 4);
5668 fprintf(stderr, "mono_return_sbyte6 s6.f5: got %d but expected %d\n", s6.f5, 5);
5671 fprintf(stderr, "mono_return_sbyte6 s6.f6: got %d but expected %d\n", s6.f6, 6);
5673 s6.f1+=addend; s6.f2+=addend; s6.f3+=addend; s6.f4+=addend; s6.f5+=addend; s6.f6+=addend;
5678 char f1,f2,f3,f4,f5,f6,f7;
5681 LIBTEST_API sbyte7 STDCALL
5682 mono_return_sbyte7 (sbyte7 s7, int addend) {
5684 fprintf(stderr, "mono_return_sbyte7 s7.f1: got %d but expected %d\n", s7.f1, 1);
5687 fprintf(stderr, "mono_return_sbyte7 s7.f2: got %d but expected %d\n", s7.f2, 2);
5690 fprintf(stderr, "mono_return_sbyte7 s7.f3: got %d but expected %d\n", s7.f3, 3);
5693 fprintf(stderr, "mono_return_sbyte7 s7.f4: got %d but expected %d\n", s7.f4, 4);
5696 fprintf(stderr, "mono_return_sbyte7 s7.f5: got %d but expected %d\n", s7.f5, 5);
5699 fprintf(stderr, "mono_return_sbyte7 s7.f6: got %d but expected %d\n", s7.f6, 6);
5702 fprintf(stderr, "mono_return_sbyte7 s7.f7: got %d but expected %d\n", s7.f7, 7);
5704 s7.f1+=addend; s7.f2+=addend; s7.f3+=addend; s7.f4+=addend; s7.f5+=addend; s7.f6+=addend; s7.f7+=addend;
5709 char f1,f2,f3,f4,f5,f6,f7,f8;
5712 LIBTEST_API sbyte8 STDCALL
5713 mono_return_sbyte8 (sbyte8 s8, int addend) {
5715 fprintf(stderr, "mono_return_sbyte8 s8.f1: got %d but expected %d\n", s8.f1, 1);
5718 fprintf(stderr, "mono_return_sbyte8 s8.f2: got %d but expected %d\n", s8.f2, 2);
5721 fprintf(stderr, "mono_return_sbyte8 s8.f3: got %d but expected %d\n", s8.f3, 3);
5724 fprintf(stderr, "mono_return_sbyte8 s8.f4: got %d but expected %d\n", s8.f4, 4);
5727 fprintf(stderr, "mono_return_sbyte8 s8.f5: got %d but expected %d\n", s8.f5, 5);
5730 fprintf(stderr, "mono_return_sbyte8 s8.f6: got %d but expected %d\n", s8.f6, 6);
5733 fprintf(stderr, "mono_return_sbyte8 s8.f7: got %d but expected %d\n", s8.f7, 7);
5736 fprintf(stderr, "mono_return_sbyte8 s8.f8: got %d but expected %d\n", s8.f8, 8);
5738 s8.f1+=addend; s8.f2+=addend; s8.f3+=addend; s8.f4+=addend; s8.f5+=addend; s8.f6+=addend; s8.f7+=addend; s8.f8+=addend;
5743 char f1,f2,f3,f4,f5,f6,f7,f8,f9;
5746 LIBTEST_API sbyte9 STDCALL
5747 mono_return_sbyte9 (sbyte9 s9, int addend) {
5749 fprintf(stderr, "mono_return_sbyte9 s9.f1: got %d but expected %d\n", s9.f1, 1);
5752 fprintf(stderr, "mono_return_sbyte9 s9.f2: got %d but expected %d\n", s9.f2, 2);
5755 fprintf(stderr, "mono_return_sbyte9 s9.f3: got %d but expected %d\n", s9.f3, 3);
5758 fprintf(stderr, "mono_return_sbyte9 s9.f4: got %d but expected %d\n", s9.f4, 4);
5761 fprintf(stderr, "mono_return_sbyte9 s9.f5: got %d but expected %d\n", s9.f5, 5);
5764 fprintf(stderr, "mono_return_sbyte9 s9.f6: got %d but expected %d\n", s9.f6, 6);
5767 fprintf(stderr, "mono_return_sbyte9 s9.f7: got %d but expected %d\n", s9.f7, 7);
5770 fprintf(stderr, "mono_return_sbyte9 s9.f8: got %d but expected %d\n", s9.f8, 8);
5773 fprintf(stderr, "mono_return_sbyte9 s9.f9: got %d but expected %d\n", s9.f9, 9);
5775 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;
5780 char f1,f2,f3,f4,f5,f6,f7,f8,f9,f10;
5783 LIBTEST_API sbyte10 STDCALL
5784 mono_return_sbyte10 (sbyte10 s10, int addend) {
5786 fprintf(stderr, "mono_return_sbyte10 s10.f1: got %d but expected %d\n", s10.f1, 1);
5789 fprintf(stderr, "mono_return_sbyte10 s10.f2: got %d but expected %d\n", s10.f2, 2);
5792 fprintf(stderr, "mono_return_sbyte10 s10.f3: got %d but expected %d\n", s10.f3, 3);
5795 fprintf(stderr, "mono_return_sbyte10 s10.f4: got %d but expected %d\n", s10.f4, 4);
5798 fprintf(stderr, "mono_return_sbyte10 s10.f5: got %d but expected %d\n", s10.f5, 5);
5801 fprintf(stderr, "mono_return_sbyte10 s10.f6: got %d but expected %d\n", s10.f6, 6);
5804 fprintf(stderr, "mono_return_sbyte10 s10.f7: got %d but expected %d\n", s10.f7, 7);
5807 fprintf(stderr, "mono_return_sbyte10 s10.f8: got %d but expected %d\n", s10.f8, 8);
5810 fprintf(stderr, "mono_return_sbyte10 s10.f9: got %d but expected %d\n", s10.f9, 9);
5812 if (s10.f10 != 10) {
5813 fprintf(stderr, "mono_return_sbyte10 s10.f10: got %d but expected %d\n", s10.f10, 10);
5815 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;
5820 char f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11;
5823 LIBTEST_API sbyte11 STDCALL
5824 mono_return_sbyte11 (sbyte11 s11, int addend) {
5826 fprintf(stderr, "mono_return_sbyte11 s11.f1: got %d but expected %d\n", s11.f1, 1);
5829 fprintf(stderr, "mono_return_sbyte11 s11.f2: got %d but expected %d\n", s11.f2, 2);
5832 fprintf(stderr, "mono_return_sbyte11 s11.f3: got %d but expected %d\n", s11.f3, 3);
5835 fprintf(stderr, "mono_return_sbyte11 s11.f4: got %d but expected %d\n", s11.f4, 4);
5838 fprintf(stderr, "mono_return_sbyte11 s11.f5: got %d but expected %d\n", s11.f5, 5);
5841 fprintf(stderr, "mono_return_sbyte11 s11.f6: got %d but expected %d\n", s11.f6, 6);
5844 fprintf(stderr, "mono_return_sbyte11 s11.f7: got %d but expected %d\n", s11.f7, 7);
5847 fprintf(stderr, "mono_return_sbyte11 s11.f8: got %d but expected %d\n", s11.f8, 8);
5850 fprintf(stderr, "mono_return_sbyte11 s11.f9: got %d but expected %d\n", s11.f9, 9);
5852 if (s11.f10 != 10) {
5853 fprintf(stderr, "mono_return_sbyte11 s11.f10: got %d but expected %d\n", s11.f10, 10);
5855 if (s11.f11 != 11) {
5856 fprintf(stderr, "mono_return_sbyte11 s11.f11: got %d but expected %d\n", s11.f11, 11);
5858 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;
5863 char f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12;
5866 LIBTEST_API sbyte12 STDCALL
5867 mono_return_sbyte12 (sbyte12 s12, int addend) {
5869 fprintf(stderr, "mono_return_sbyte12 s12.f1: got %d but expected %d\n", s12.f1, 1);
5872 fprintf(stderr, "mono_return_sbyte12 s12.f2: got %d but expected %d\n", s12.f2, 2);
5875 fprintf(stderr, "mono_return_sbyte12 s12.f3: got %d but expected %d\n", s12.f3, 3);
5878 fprintf(stderr, "mono_return_sbyte12 s12.f4: got %d but expected %d\n", s12.f4, 4);
5881 fprintf(stderr, "mono_return_sbyte12 s12.f5: got %d but expected %d\n", s12.f5, 5);
5884 fprintf(stderr, "mono_return_sbyte12 s12.f6: got %d but expected %d\n", s12.f6, 6);
5887 fprintf(stderr, "mono_return_sbyte12 s12.f7: got %d but expected %d\n", s12.f7, 7);
5890 fprintf(stderr, "mono_return_sbyte12 s12.f8: got %d but expected %d\n", s12.f8, 8);
5893 fprintf(stderr, "mono_return_sbyte12 s12.f9: got %d but expected %d\n", s12.f9, 9);
5895 if (s12.f10 != 10) {
5896 fprintf(stderr, "mono_return_sbyte12 s12.f10: got %d but expected %d\n", s12.f10, 10);
5898 if (s12.f11 != 11) {
5899 fprintf(stderr, "mono_return_sbyte12 s12.f11: got %d but expected %d\n", s12.f11, 11);
5901 if (s12.f12 != 12) {
5902 fprintf(stderr, "mono_return_sbyte12 s12.f12: got %d but expected %d\n", s12.f12, 12);
5904 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;
5909 char f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13;
5912 LIBTEST_API sbyte13 STDCALL
5913 mono_return_sbyte13 (sbyte13 s13, int addend) {
5915 fprintf(stderr, "mono_return_sbyte13 s13.f1: got %d but expected %d\n", s13.f1, 1);
5918 fprintf(stderr, "mono_return_sbyte13 s13.f2: got %d but expected %d\n", s13.f2, 2);
5921 fprintf(stderr, "mono_return_sbyte13 s13.f3: got %d but expected %d\n", s13.f3, 3);
5924 fprintf(stderr, "mono_return_sbyte13 s13.f4: got %d but expected %d\n", s13.f4, 4);
5927 fprintf(stderr, "mono_return_sbyte13 s13.f5: got %d but expected %d\n", s13.f5, 5);
5930 fprintf(stderr, "mono_return_sbyte13 s13.f6: got %d but expected %d\n", s13.f6, 6);
5933 fprintf(stderr, "mono_return_sbyte13 s13.f7: got %d but expected %d\n", s13.f7, 7);
5936 fprintf(stderr, "mono_return_sbyte13 s13.f8: got %d but expected %d\n", s13.f8, 8);
5939 fprintf(stderr, "mono_return_sbyte13 s13.f9: got %d but expected %d\n", s13.f9, 9);
5941 if (s13.f10 != 10) {
5942 fprintf(stderr, "mono_return_sbyte13 s13.f10: got %d but expected %d\n", s13.f10, 10);
5944 if (s13.f11 != 11) {
5945 fprintf(stderr, "mono_return_sbyte13 s13.f11: got %d but expected %d\n", s13.f11, 11);
5947 if (s13.f12 != 12) {
5948 fprintf(stderr, "mono_return_sbyte13 s13.f12: got %d but expected %d\n", s13.f12, 12);
5950 if (s13.f13 != 13) {
5951 fprintf(stderr, "mono_return_sbyte13 s13.f13: got %d but expected %d\n", s13.f13, 13);
5953 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;
5958 char f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14;
5961 LIBTEST_API sbyte14 STDCALL
5962 mono_return_sbyte14 (sbyte14 s14, int addend) {
5964 fprintf(stderr, "mono_return_sbyte14 s14.f1: got %d but expected %d\n", s14.f1, 1);
5967 fprintf(stderr, "mono_return_sbyte14 s14.f2: got %d but expected %d\n", s14.f2, 2);
5970 fprintf(stderr, "mono_return_sbyte14 s14.f3: got %d but expected %d\n", s14.f3, 3);
5973 fprintf(stderr, "mono_return_sbyte14 s14.f4: got %d but expected %d\n", s14.f4, 4);
5976 fprintf(stderr, "mono_return_sbyte14 s14.f5: got %d but expected %d\n", s14.f5, 5);
5979 fprintf(stderr, "mono_return_sbyte14 s14.f6: got %d but expected %d\n", s14.f6, 6);
5982 fprintf(stderr, "mono_return_sbyte14 s14.f7: got %d but expected %d\n", s14.f7, 7);
5985 fprintf(stderr, "mono_return_sbyte14 s14.f8: got %d but expected %d\n", s14.f8, 8);
5988 fprintf(stderr, "mono_return_sbyte14 s14.f9: got %d but expected %d\n", s14.f9, 9);
5990 if (s14.f10 != 10) {
5991 fprintf(stderr, "mono_return_sbyte14 s14.f10: got %d but expected %d\n", s14.f10, 10);
5993 if (s14.f11 != 11) {
5994 fprintf(stderr, "mono_return_sbyte14 s14.f11: got %d but expected %d\n", s14.f11, 11);
5996 if (s14.f12 != 12) {
5997 fprintf(stderr, "mono_return_sbyte14 s14.f12: got %d but expected %d\n", s14.f12, 12);
5999 if (s14.f13 != 13) {
6000 fprintf(stderr, "mono_return_sbyte14 s14.f13: got %d but expected %d\n", s14.f13, 13);
6002 if (s14.f14 != 14) {
6003 fprintf(stderr, "mono_return_sbyte14 s14.f14: got %d but expected %d\n", s14.f14, 14);
6005 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;
6010 char f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15;
6013 LIBTEST_API sbyte15 STDCALL
6014 mono_return_sbyte15 (sbyte15 s15, int addend) {
6016 fprintf(stderr, "mono_return_sbyte15 s15.f1: got %d but expected %d\n", s15.f1, 1);
6019 fprintf(stderr, "mono_return_sbyte15 s15.f2: got %d but expected %d\n", s15.f2, 2);
6022 fprintf(stderr, "mono_return_sbyte15 s15.f3: got %d but expected %d\n", s15.f3, 3);
6025 fprintf(stderr, "mono_return_sbyte15 s15.f4: got %d but expected %d\n", s15.f4, 4);
6028 fprintf(stderr, "mono_return_sbyte15 s15.f5: got %d but expected %d\n", s15.f5, 5);
6031 fprintf(stderr, "mono_return_sbyte15 s15.f6: got %d but expected %d\n", s15.f6, 6);
6034 fprintf(stderr, "mono_return_sbyte15 s15.f7: got %d but expected %d\n", s15.f7, 7);
6037 fprintf(stderr, "mono_return_sbyte15 s15.f8: got %d but expected %d\n", s15.f8, 8);
6040 fprintf(stderr, "mono_return_sbyte15 s15.f9: got %d but expected %d\n", s15.f9, 9);
6042 if (s15.f10 != 10) {
6043 fprintf(stderr, "mono_return_sbyte15 s15.f10: got %d but expected %d\n", s15.f10, 10);
6045 if (s15.f11 != 11) {
6046 fprintf(stderr, "mono_return_sbyte15 s15.f11: got %d but expected %d\n", s15.f11, 11);
6048 if (s15.f12 != 12) {
6049 fprintf(stderr, "mono_return_sbyte15 s15.f12: got %d but expected %d\n", s15.f12, 12);
6051 if (s15.f13 != 13) {
6052 fprintf(stderr, "mono_return_sbyte15 s15.f13: got %d but expected %d\n", s15.f13, 13);
6054 if (s15.f14 != 14) {
6055 fprintf(stderr, "mono_return_sbyte15 s15.f14: got %d but expected %d\n", s15.f14, 14);
6057 if (s15.f15 != 15) {
6058 fprintf(stderr, "mono_return_sbyte15 s15.f15: got %d but expected %d\n", s15.f15, 15);
6060 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;
6065 char f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15,f16;
6068 LIBTEST_API sbyte16 STDCALL
6069 mono_return_sbyte16 (sbyte16 s16, int addend) {
6071 fprintf(stderr, "mono_return_sbyte16 s16.f1: got %d but expected %d\n", s16.f1, 1);
6074 fprintf(stderr, "mono_return_sbyte16 s16.f2: got %d but expected %d\n", s16.f2, 2);
6077 fprintf(stderr, "mono_return_sbyte16 s16.f3: got %d but expected %d\n", s16.f3, 3);
6080 fprintf(stderr, "mono_return_sbyte16 s16.f4: got %d but expected %d\n", s16.f4, 4);
6083 fprintf(stderr, "mono_return_sbyte16 s16.f5: got %d but expected %d\n", s16.f5, 5);
6086 fprintf(stderr, "mono_return_sbyte16 s16.f6: got %d but expected %d\n", s16.f6, 6);
6089 fprintf(stderr, "mono_return_sbyte16 s16.f7: got %d but expected %d\n", s16.f7, 7);
6092 fprintf(stderr, "mono_return_sbyte16 s16.f8: got %d but expected %d\n", s16.f8, 8);
6095 fprintf(stderr, "mono_return_sbyte16 s16.f9: got %d but expected %d\n", s16.f9, 9);
6097 if (s16.f10 != 10) {
6098 fprintf(stderr, "mono_return_sbyte16 s16.f10: got %d but expected %d\n", s16.f10, 10);
6100 if (s16.f11 != 11) {
6101 fprintf(stderr, "mono_return_sbyte16 s16.f11: got %d but expected %d\n", s16.f11, 11);
6103 if (s16.f12 != 12) {
6104 fprintf(stderr, "mono_return_sbyte16 s16.f12: got %d but expected %d\n", s16.f12, 12);
6106 if (s16.f13 != 13) {
6107 fprintf(stderr, "mono_return_sbyte16 s16.f13: got %d but expected %d\n", s16.f13, 13);
6109 if (s16.f14 != 14) {
6110 fprintf(stderr, "mono_return_sbyte16 s16.f14: got %d but expected %d\n", s16.f14, 14);
6112 if (s16.f15 != 15) {
6113 fprintf(stderr, "mono_return_sbyte16 s16.f15: got %d but expected %d\n", s16.f15, 15);
6115 if (s16.f16 != 16) {
6116 fprintf(stderr, "mono_return_sbyte16 s16.f16: got %d but expected %d\n", s16.f16, 16);
6118 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;
6123 char f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15,f16,f17;
6126 LIBTEST_API sbyte17 STDCALL
6127 mono_return_sbyte17 (sbyte17 s17, int addend) {
6129 fprintf(stderr, "mono_return_sbyte17 s17.f1: got %d but expected %d\n", s17.f1, 1);
6132 fprintf(stderr, "mono_return_sbyte17 s17.f2: got %d but expected %d\n", s17.f2, 2);
6135 fprintf(stderr, "mono_return_sbyte17 s17.f3: got %d but expected %d\n", s17.f3, 3);
6138 fprintf(stderr, "mono_return_sbyte17 s17.f4: got %d but expected %d\n", s17.f4, 4);
6141 fprintf(stderr, "mono_return_sbyte17 s17.f5: got %d but expected %d\n", s17.f5, 5);
6144 fprintf(stderr, "mono_return_sbyte17 s17.f6: got %d but expected %d\n", s17.f6, 6);
6147 fprintf(stderr, "mono_return_sbyte17 s17.f7: got %d but expected %d\n", s17.f7, 7);
6150 fprintf(stderr, "mono_return_sbyte17 s17.f8: got %d but expected %d\n", s17.f8, 8);
6153 fprintf(stderr, "mono_return_sbyte17 s17.f9: got %d but expected %d\n", s17.f9, 9);
6155 if (s17.f10 != 10) {
6156 fprintf(stderr, "mono_return_sbyte17 s17.f10: got %d but expected %d\n", s17.f10, 10);
6158 if (s17.f11 != 11) {
6159 fprintf(stderr, "mono_return_sbyte17 s17.f11: got %d but expected %d\n", s17.f11, 11);
6161 if (s17.f12 != 12) {
6162 fprintf(stderr, "mono_return_sbyte17 s17.f12: got %d but expected %d\n", s17.f12, 12);
6164 if (s17.f13 != 13) {
6165 fprintf(stderr, "mono_return_sbyte17 s17.f13: got %d but expected %d\n", s17.f13, 13);
6167 if (s17.f14 != 14) {
6168 fprintf(stderr, "mono_return_sbyte17 s17.f14: got %d but expected %d\n", s17.f14, 14);
6170 if (s17.f15 != 15) {
6171 fprintf(stderr, "mono_return_sbyte17 s17.f15: got %d but expected %d\n", s17.f15, 15);
6173 if (s17.f16 != 16) {
6174 fprintf(stderr, "mono_return_sbyte17 s17.f16: got %d but expected %d\n", s17.f16, 16);
6176 if (s17.f17 != 17) {
6177 fprintf(stderr, "mono_return_sbyte17 s17.f17: got %d but expected %d\n", s17.f17, 17);
6179 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;
6187 char f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15;
6193 LIBTEST_API sbyte16_nested STDCALL
6194 mono_return_sbyte16_nested (sbyte16_nested sn16, int addend) {
6195 if (sn16.nested1.f1 != 1) {
6196 fprintf(stderr, "mono_return_sbyte16_nested sn16.nested1.f1: got %d but expected %d\n", sn16.nested1.f1, 1);
6199 fprintf(stderr, "mono_return_sbyte16_nested sn16.f2: got %d but expected %d\n", sn16.f2, 2);
6202 fprintf(stderr, "mono_return_sbyte16_nested sn16.f3: got %d but expected %d\n", sn16.f3, 3);
6205 fprintf(stderr, "mono_return_sbyte16_nested sn16.f4: got %d but expected %d\n", sn16.f4, 4);
6208 fprintf(stderr, "mono_return_sbyte16_nested sn16.f5: got %d but expected %d\n", sn16.f5, 5);
6211 fprintf(stderr, "mono_return_sbyte16_nested sn16.f6: got %d but expected %d\n", sn16.f6, 6);
6214 fprintf(stderr, "mono_return_sbyte16_nested sn16.f7: got %d but expected %d\n", sn16.f7, 7);
6217 fprintf(stderr, "mono_return_sbyte16_nested sn16.f8: got %d but expected %d\n", sn16.f8, 8);
6220 fprintf(stderr, "mono_return_sbyte16_nested sn16.f9: got %d but expected %d\n", sn16.f9, 9);
6222 if (sn16.f10 != 10) {
6223 fprintf(stderr, "mono_return_sbyte16_nested sn16.f10: got %d but expected %d\n", sn16.f10, 10);
6225 if (sn16.f11 != 11) {
6226 fprintf(stderr, "mono_return_sbyte16_nested sn16.f11: got %d but expected %d\n", sn16.f11, 11);
6228 if (sn16.f12 != 12) {
6229 fprintf(stderr, "mono_return_sbyte16_nested sn16.f12: got %d but expected %d\n", sn16.f12, 12);
6231 if (sn16.f13 != 13) {
6232 fprintf(stderr, "mono_return_sbyte16_nested sn16.f13: got %d but expected %d\n", sn16.f13, 13);
6234 if (sn16.f14 != 14) {
6235 fprintf(stderr, "mono_return_sbyte16_nested sn16.f14: got %d but expected %d\n", sn16.f14, 14);
6237 if (sn16.f15 != 15) {
6238 fprintf(stderr, "mono_return_sbyte16_nested sn16.f15: got %d but expected %d\n", sn16.f15, 15);
6240 if (sn16.nested2.f16 != 16) {
6241 fprintf(stderr, "mono_return_sbyte16_nested sn16.nested2.f16: got %d but expected %d\n", sn16.nested2.f16, 16);
6243 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;
6252 LIBTEST_API short1 STDCALL
6253 mono_return_short1 (short1 s1, int addend) {
6255 fprintf(stderr, "mono_return_short1 s1.f1: got %d but expected %d\n", s1.f1, 1);
6265 LIBTEST_API short2 STDCALL
6266 mono_return_short2 (short2 s2, int addend) {
6268 fprintf(stderr, "mono_return_short2 s2.f1: got %d but expected %d\n", s2.f1, 1);
6271 fprintf(stderr, "mono_return_short2 s2.f2: got %d but expected %d\n", s2.f2, 2);
6273 s2.f1+=addend; s2.f2+=addend;
6281 LIBTEST_API short3 STDCALL
6282 mono_return_short3 (short3 s3, int addend) {
6284 fprintf(stderr, "mono_return_short3 s3.f1: got %d but expected %d\n", s3.f1, 1);
6287 fprintf(stderr, "mono_return_short3 s3.f2: got %d but expected %d\n", s3.f2, 2);
6290 fprintf(stderr, "mono_return_short3 s3.f3: got %d but expected %d\n", s3.f3, 3);
6292 s3.f1+=addend; s3.f2+=addend; s3.f3+=addend;
6300 LIBTEST_API short4 STDCALL
6301 mono_return_short4 (short4 s4, int addend) {
6303 fprintf(stderr, "mono_return_short4 s4.f1: got %d but expected %d\n", s4.f1, 1);
6306 fprintf(stderr, "mono_return_short4 s4.f2: got %d but expected %d\n", s4.f2, 2);
6309 fprintf(stderr, "mono_return_short4 s4.f3: got %d but expected %d\n", s4.f3, 3);
6312 fprintf(stderr, "mono_return_short4 s4.f4: got %d but expected %d\n", s4.f4, 4);
6314 s4.f1+=addend; s4.f2+=addend; s4.f3+=addend; s4.f4+=addend;
6319 short f1,f2,f3,f4,f5;
6322 LIBTEST_API short5 STDCALL
6323 mono_return_short5 (short5 s5, int addend) {
6325 fprintf(stderr, "mono_return_short5 s5.f1: got %d but expected %d\n", s5.f1, 1);
6328 fprintf(stderr, "mono_return_short5 s5.f2: got %d but expected %d\n", s5.f2, 2);
6331 fprintf(stderr, "mono_return_short5 s5.f3: got %d but expected %d\n", s5.f3, 3);
6334 fprintf(stderr, "mono_return_short5 s5.f4: got %d but expected %d\n", s5.f4, 4);
6337 fprintf(stderr, "mono_return_short5 s5.f5: got %d but expected %d\n", s5.f5, 5);
6339 s5.f1+=addend; s5.f2+=addend; s5.f3+=addend; s5.f4+=addend; s5.f5+=addend;
6344 short f1,f2,f3,f4,f5,f6;
6347 LIBTEST_API short6 STDCALL
6348 mono_return_short6 (short6 s6, int addend) {
6350 fprintf(stderr, "mono_return_short6 s6.f1: got %d but expected %d\n", s6.f1, 1);
6353 fprintf(stderr, "mono_return_short6 s6.f2: got %d but expected %d\n", s6.f2, 2);
6356 fprintf(stderr, "mono_return_short6 s6.f3: got %d but expected %d\n", s6.f3, 3);
6359 fprintf(stderr, "mono_return_short6 s6.f4: got %d but expected %d\n", s6.f4, 4);
6362 fprintf(stderr, "mono_return_short6 s6.f5: got %d but expected %d\n", s6.f5, 5);
6365 fprintf(stderr, "mono_return_short6 s6.f6: got %d but expected %d\n", s6.f6, 6);
6367 s6.f1+=addend; s6.f2+=addend; s6.f3+=addend; s6.f4+=addend; s6.f5+=addend; s6.f6+=addend;
6372 short f1,f2,f3,f4,f5,f6,f7;
6375 LIBTEST_API short7 STDCALL
6376 mono_return_short7 (short7 s7, int addend) {
6378 fprintf(stderr, "mono_return_short7 s7.f1: got %d but expected %d\n", s7.f1, 1);
6381 fprintf(stderr, "mono_return_short7 s7.f2: got %d but expected %d\n", s7.f2, 2);
6384 fprintf(stderr, "mono_return_short7 s7.f3: got %d but expected %d\n", s7.f3, 3);
6387 fprintf(stderr, "mono_return_short7 s7.f4: got %d but expected %d\n", s7.f4, 4);
6390 fprintf(stderr, "mono_return_short7 s7.f5: got %d but expected %d\n", s7.f5, 5);
6393 fprintf(stderr, "mono_return_short7 s7.f6: got %d but expected %d\n", s7.f6, 6);
6396 fprintf(stderr, "mono_return_short7 s7.f7: got %d but expected %d\n", s7.f7, 7);
6398 s7.f1+=addend; s7.f2+=addend; s7.f3+=addend; s7.f4+=addend; s7.f5+=addend; s7.f6+=addend; s7.f7+=addend;
6403 short f1,f2,f3,f4,f5,f6,f7,f8;
6406 LIBTEST_API short8 STDCALL
6407 mono_return_short8 (short8 s8, int addend) {
6409 fprintf(stderr, "mono_return_short8 s8.f1: got %d but expected %d\n", s8.f1, 1);
6412 fprintf(stderr, "mono_return_short8 s8.f2: got %d but expected %d\n", s8.f2, 2);
6415 fprintf(stderr, "mono_return_short8 s8.f3: got %d but expected %d\n", s8.f3, 3);
6418 fprintf(stderr, "mono_return_short8 s8.f4: got %d but expected %d\n", s8.f4, 4);
6421 fprintf(stderr, "mono_return_short8 s8.f5: got %d but expected %d\n", s8.f5, 5);
6424 fprintf(stderr, "mono_return_short8 s8.f6: got %d but expected %d\n", s8.f6, 6);
6427 fprintf(stderr, "mono_return_short8 s8.f7: got %d but expected %d\n", s8.f7, 7);
6430 fprintf(stderr, "mono_return_short8 s8.f8: got %d but expected %d\n", s8.f8, 8);
6432 s8.f1+=addend; s8.f2+=addend; s8.f3+=addend; s8.f4+=addend; s8.f5+=addend; s8.f6+=addend; s8.f7+=addend; s8.f8+=addend;
6437 short f1,f2,f3,f4,f5,f6,f7,f8,f9;
6440 LIBTEST_API short9 STDCALL
6441 mono_return_short9 (short9 s9, int addend) {
6443 fprintf(stderr, "mono_return_short9 s9.f1: got %d but expected %d\n", s9.f1, 1);
6446 fprintf(stderr, "mono_return_short9 s9.f2: got %d but expected %d\n", s9.f2, 2);
6449 fprintf(stderr, "mono_return_short9 s9.f3: got %d but expected %d\n", s9.f3, 3);
6452 fprintf(stderr, "mono_return_short9 s9.f4: got %d but expected %d\n", s9.f4, 4);
6455 fprintf(stderr, "mono_return_short9 s9.f5: got %d but expected %d\n", s9.f5, 5);
6458 fprintf(stderr, "mono_return_short9 s9.f6: got %d but expected %d\n", s9.f6, 6);
6461 fprintf(stderr, "mono_return_short9 s9.f7: got %d but expected %d\n", s9.f7, 7);
6464 fprintf(stderr, "mono_return_short9 s9.f8: got %d but expected %d\n", s9.f8, 8);
6467 fprintf(stderr, "mono_return_short9 s9.f9: got %d but expected %d\n", s9.f9, 9);
6469 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;
6477 short f2,f3,f4,f5,f6,f7;
6483 LIBTEST_API short8_nested STDCALL
6484 mono_return_short8_nested (short8_nested sn8, int addend) {
6485 if (sn8.nested1.f1 != 1) {
6486 fprintf(stderr, "mono_return_short8_nested sn8.nested1.f1: got %d but expected %d\n", sn8.nested1.f1, 1);
6489 fprintf(stderr, "mono_return_short8_nested sn8.f2: got %d but expected %d\n", sn8.f2, 2);
6492 fprintf(stderr, "mono_return_short8_nested sn8.f3: got %d but expected %d\n", sn8.f3, 3);
6495 fprintf(stderr, "mono_return_short8_nested sn8.f4: got %d but expected %d\n", sn8.f4, 4);
6498 fprintf(stderr, "mono_return_short8_nested sn8.f5: got %d but expected %d\n", sn8.f5, 5);
6501 fprintf(stderr, "mono_return_short8_nested sn8.f6: got %d but expected %d\n", sn8.f6, 6);
6504 fprintf(stderr, "mono_return_short8_nested sn8.f7: got %d but expected %d\n", sn8.f7, 7);
6506 if (sn8.nested2.f8 != 8) {
6507 fprintf(stderr, "mono_return_short8_nested sn8.nested2.f8: got %d but expected %d\n", sn8.nested2.f8, 8);
6509 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;
6518 LIBTEST_API int1 STDCALL
6519 mono_return_int1 (int1 s1, int addend) {
6521 fprintf(stderr, "mono_return_int1 s1.f1: got %d but expected %d\n", s1.f1, 1);
6531 LIBTEST_API int2 STDCALL
6532 mono_return_int2 (int2 s2, int addend) {
6534 fprintf(stderr, "mono_return_int2 s2.f1: got %d but expected %d\n", s2.f1, 1);
6537 fprintf(stderr, "mono_return_int2 s2.f2: got %d but expected %d\n", s2.f2, 2);
6539 s2.f1+=addend; s2.f2+=addend;
6547 LIBTEST_API int3 STDCALL
6548 mono_return_int3 (int3 s3, int addend) {
6550 fprintf(stderr, "mono_return_int3 s3.f1: got %d but expected %d\n", s3.f1, 1);
6553 fprintf(stderr, "mono_return_int3 s3.f2: got %d but expected %d\n", s3.f2, 2);
6556 fprintf(stderr, "mono_return_int3 s3.f3: got %d but expected %d\n", s3.f3, 3);
6558 s3.f1+=addend; s3.f2+=addend; s3.f3+=addend;
6566 LIBTEST_API int4 STDCALL
6567 mono_return_int4 (int4 s4, int addend) {
6569 fprintf(stderr, "mono_return_int4 s4.f1: got %d but expected %d\n", s4.f1, 1);
6572 fprintf(stderr, "mono_return_int4 s4.f2: got %d but expected %d\n", s4.f2, 2);
6575 fprintf(stderr, "mono_return_int4 s4.f3: got %d but expected %d\n", s4.f3, 3);
6578 fprintf(stderr, "mono_return_int4 s4.f4: got %d but expected %d\n", s4.f4, 4);
6580 s4.f1+=addend; s4.f2+=addend; s4.f3+=addend; s4.f4+=addend;
6588 LIBTEST_API int5 STDCALL
6589 mono_return_int5 (int5 s5, int addend) {
6591 fprintf(stderr, "mono_return_int5 s5.f1: got %d but expected %d\n", s5.f1, 1);
6594 fprintf(stderr, "mono_return_int5 s5.f2: got %d but expected %d\n", s5.f2, 2);
6597 fprintf(stderr, "mono_return_int5 s5.f3: got %d but expected %d\n", s5.f3, 3);
6600 fprintf(stderr, "mono_return_int5 s5.f4: got %d but expected %d\n", s5.f4, 4);
6603 fprintf(stderr, "mono_return_int5 s5.f5: got %d but expected %d\n", s5.f5, 5);
6605 s5.f1+=addend; s5.f2+=addend; s5.f3+=addend; s5.f4+=addend; s5.f5+=addend;
6619 LIBTEST_API int4_nested STDCALL
6620 mono_return_int4_nested (int4_nested sn4, int addend) {
6621 if (sn4.nested1.f1 != 1) {
6622 fprintf(stderr, "mono_return_int4_nested sn4.nested1.f1: got %d but expected %d\n", sn4.nested1.f1, 1);
6625 fprintf(stderr, "mono_return_int4_nested sn4.f2: got %d but expected %d\n", sn4.f2, 2);
6628 fprintf(stderr, "mono_return_int4_nested sn4.f3: got %d but expected %d\n", sn4.f3, 3);
6630 if (sn4.nested2.f4 != 4) {
6631 fprintf(stderr, "mono_return_int4_nested sn4.nested2.f4: got %d but expected %d\n", sn4.nested2.f4, 4);
6633 sn4.nested1.f1+=addend; sn4.f2+=addend; sn4.f3+=addend; sn4.nested2.f4+=addend;
6641 LIBTEST_API float1 STDCALL
6642 mono_return_float1 (float1 s1, int addend) {
6644 fprintf(stderr, "mono_return_float1 s1.f1: got %f but expected %d\n", s1.f1, 1);
6654 LIBTEST_API float2 STDCALL
6655 mono_return_float2 (float2 s2, int addend) {
6657 fprintf(stderr, "mono_return_float2 s2.f1: got %f but expected %d\n", s2.f1, 1);
6660 fprintf(stderr, "mono_return_float2 s2.f2: got %f but expected %d\n", s2.f2, 2);
6662 s2.f1+=addend; s2.f2+=addend;
6670 LIBTEST_API float3 STDCALL
6671 mono_return_float3 (float3 s3, int addend) {
6673 fprintf(stderr, "mono_return_float3 s3.f1: got %f but expected %d\n", s3.f1, 1);
6676 fprintf(stderr, "mono_return_float3 s3.f2: got %f but expected %d\n", s3.f2, 2);
6679 fprintf(stderr, "mono_return_float3 s3.f3: got %f but expected %d\n", s3.f3, 3);
6681 s3.f1+=addend; s3.f2+=addend; s3.f3+=addend;
6689 LIBTEST_API float4 STDCALL
6690 mono_return_float4 (float4 s4, int addend) {
6692 fprintf(stderr, "mono_return_float4 s4.f1: got %f but expected %d\n", s4.f1, 1);
6695 fprintf(stderr, "mono_return_float4 s4.f2: got %f but expected %d\n", s4.f2, 2);
6698 fprintf(stderr, "mono_return_float4 s4.f3: got %f but expected %d\n", s4.f3, 3);
6701 fprintf(stderr, "mono_return_float4 s4.f4: got %f but expected %d\n", s4.f4, 4);
6703 s4.f1+=addend; s4.f2+=addend; s4.f3+=addend; s4.f4+=addend;
6708 float f1,f2,f3,f4,f5;
6711 LIBTEST_API float5 STDCALL
6712 mono_return_float5 (float5 s5, int addend) {
6714 fprintf(stderr, "mono_return_float5 s5.f1: got %f but expected %d\n", s5.f1, 1);
6717 fprintf(stderr, "mono_return_float5 s5.f2: got %f but expected %d\n", s5.f2, 2);
6720 fprintf(stderr, "mono_return_float5 s5.f3: got %f but expected %d\n", s5.f3, 3);
6723 fprintf(stderr, "mono_return_float5 s5.f4: got %f but expected %d\n", s5.f4, 4);
6726 fprintf(stderr, "mono_return_float5 s5.f5: got %f but expected %d\n", s5.f5, 5);
6728 s5.f1+=addend; s5.f2+=addend; s5.f3+=addend; s5.f4+=addend; s5.f5+=addend;
6733 float f1,f2,f3,f4,f5,f6;
6736 LIBTEST_API float6 STDCALL
6737 mono_return_float6 (float6 s6, int addend) {
6739 fprintf(stderr, "mono_return_float6 s6.f1: got %f but expected %d\n", s6.f1, 1);
6742 fprintf(stderr, "mono_return_float6 s6.f2: got %f but expected %d\n", s6.f2, 2);
6745 fprintf(stderr, "mono_return_float6 s6.f3: got %f but expected %d\n", s6.f3, 3);
6748 fprintf(stderr, "mono_return_float6 s6.f4: got %f but expected %d\n", s6.f4, 4);
6751 fprintf(stderr, "mono_return_float6 s6.f5: got %f but expected %d\n", s6.f5, 5);
6754 fprintf(stderr, "mono_return_float6 s6.f6: got %f but expected %d\n", s6.f6, 6);
6756 s6.f1+=addend; s6.f2+=addend; s6.f3+=addend; s6.f4+=addend; s6.f5+=addend; s6.f6+=addend;
6761 float f1,f2,f3,f4,f5,f6,f7;
6764 LIBTEST_API float7 STDCALL
6765 mono_return_float7 (float7 s7, int addend) {
6767 fprintf(stderr, "mono_return_float7 s7.f1: got %f but expected %d\n", s7.f1, 1);
6770 fprintf(stderr, "mono_return_float7 s7.f2: got %f but expected %d\n", s7.f2, 2);
6773 fprintf(stderr, "mono_return_float7 s7.f3: got %f but expected %d\n", s7.f3, 3);
6776 fprintf(stderr, "mono_return_float7 s7.f4: got %f but expected %d\n", s7.f4, 4);
6779 fprintf(stderr, "mono_return_float7 s7.f5: got %f but expected %d\n", s7.f5, 5);
6782 fprintf(stderr, "mono_return_float7 s7.f6: got %f but expected %d\n", s7.f6, 6);
6785 fprintf(stderr, "mono_return_float7 s7.f7: got %f but expected %d\n", s7.f7, 7);
6787 s7.f1+=addend; s7.f2+=addend; s7.f3+=addend; s7.f4+=addend; s7.f5+=addend; s7.f6+=addend; s7.f7+=addend;
6792 float f1,f2,f3,f4,f5,f6,f7,f8;
6795 LIBTEST_API float8 STDCALL
6796 mono_return_float8 (float8 s8, int addend) {
6798 fprintf(stderr, "mono_return_float8 s8.f1: got %f but expected %d\n", s8.f1, 1);
6801 fprintf(stderr, "mono_return_float8 s8.f2: got %f but expected %d\n", s8.f2, 2);
6804 fprintf(stderr, "mono_return_float8 s8.f3: got %f but expected %d\n", s8.f3, 3);
6807 fprintf(stderr, "mono_return_float8 s8.f4: got %f but expected %d\n", s8.f4, 4);
6810 fprintf(stderr, "mono_return_float8 s8.f5: got %f but expected %d\n", s8.f5, 5);
6813 fprintf(stderr, "mono_return_float8 s8.f6: got %f but expected %d\n", s8.f6, 6);
6816 fprintf(stderr, "mono_return_float8 s8.f7: got %f but expected %d\n", s8.f7, 7);
6819 fprintf(stderr, "mono_return_float8 s8.f8: got %f but expected %d\n", s8.f8, 8);
6821 s8.f1+=addend; s8.f2+=addend; s8.f3+=addend; s8.f4+=addend; s8.f5+=addend; s8.f6+=addend; s8.f7+=addend; s8.f8+=addend;
6826 float f1,f2,f3,f4,f5,f6,f7,f8,f9;
6829 LIBTEST_API float9 STDCALL
6830 mono_return_float9 (float9 s9, int addend) {
6832 fprintf(stderr, "mono_return_float9 s9.f1: got %f but expected %d\n", s9.f1, 1);
6835 fprintf(stderr, "mono_return_float9 s9.f2: got %f but expected %d\n", s9.f2, 2);
6838 fprintf(stderr, "mono_return_float9 s9.f3: got %f but expected %d\n", s9.f3, 3);
6841 fprintf(stderr, "mono_return_float9 s9.f4: got %f but expected %d\n", s9.f4, 4);
6844 fprintf(stderr, "mono_return_float9 s9.f5: got %f but expected %d\n", s9.f5, 5);
6847 fprintf(stderr, "mono_return_float9 s9.f6: got %f but expected %d\n", s9.f6, 6);
6850 fprintf(stderr, "mono_return_float9 s9.f7: got %f but expected %d\n", s9.f7, 7);
6853 fprintf(stderr, "mono_return_float9 s9.f8: got %f but expected %d\n", s9.f8, 8);
6856 fprintf(stderr, "mono_return_float9 s9.f9: got %f but expected %d\n", s9.f9, 9);
6858 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;
6872 LIBTEST_API float4_nested STDCALL
6873 mono_return_float4_nested (float4_nested sn4, int addend) {
6874 if (sn4.nested1.f1 != 1) {
6875 fprintf(stderr, "mono_return_float4_nested sn4.nested1.f1: got %f but expected %d\n", sn4.nested1.f1, 1);
6878 fprintf(stderr, "mono_return_float4_nested sn4.f2: got %f but expected %d\n", sn4.f2, 2);
6881 fprintf(stderr, "mono_return_float4_nested sn4.f3: got %f but expected %d\n", sn4.f3, 3);
6883 if (sn4.nested2.f4 != 4) {
6884 fprintf(stderr, "mono_return_float4_nested sn4.nested2.f4: got %f but expected %d\n", sn4.nested2.f4, 4);
6886 sn4.nested1.f1+=addend; sn4.f2+=addend; sn4.f3+=addend; sn4.nested2.f4+=addend;
6894 LIBTEST_API double1 STDCALL
6895 mono_return_double1 (double1 s1, int addend) {
6897 fprintf(stderr, "mono_return_double1 s1.f1: got %f but expected %d\n", s1.f1, 1);
6907 LIBTEST_API double2 STDCALL
6908 mono_return_double2 (double2 s2, int addend) {
6910 fprintf(stderr, "mono_return_double2 s2.f1: got %f but expected %d\n", s2.f1, 1);
6913 fprintf(stderr, "mono_return_double2 s2.f2: got %f but expected %d\n", s2.f2, 2);
6915 s2.f1+=addend; s2.f2+=addend;
6923 LIBTEST_API double3 STDCALL
6924 mono_return_double3 (double3 s3, int addend) {
6926 fprintf(stderr, "mono_return_double3 s3.f1: got %f but expected %d\n", s3.f1, 1);
6929 fprintf(stderr, "mono_return_double3 s3.f2: got %f but expected %d\n", s3.f2, 2);
6932 fprintf(stderr, "mono_return_double3 s3.f3: got %f but expected %d\n", s3.f3, 3);
6934 s3.f1+=addend; s3.f2+=addend; s3.f3+=addend;
6942 LIBTEST_API double4 STDCALL
6943 mono_return_double4 (double4 s4, int addend) {
6945 fprintf(stderr, "mono_return_double4 s4.f1: got %f but expected %d\n", s4.f1, 1);
6948 fprintf(stderr, "mono_return_double4 s4.f2: got %f but expected %d\n", s4.f2, 2);
6951 fprintf(stderr, "mono_return_double4 s4.f3: got %f but expected %d\n", s4.f3, 3);
6954 fprintf(stderr, "mono_return_double4 s4.f4: got %f but expected %d\n", s4.f4, 4);
6956 s4.f1+=addend; s4.f2+=addend; s4.f3+=addend; s4.f4+=addend;
6961 double f1,f2,f3,f4,f5;
6964 LIBTEST_API double5 STDCALL
6965 mono_return_double5 (double5 s5, int addend) {
6967 fprintf(stderr, "mono_return_double5 s5.f1: got %f but expected %d\n", s5.f1, 1);
6970 fprintf(stderr, "mono_return_double5 s5.f2: got %f but expected %d\n", s5.f2, 2);
6973 fprintf(stderr, "mono_return_double5 s5.f3: got %f but expected %d\n", s5.f3, 3);
6976 fprintf(stderr, "mono_return_double5 s5.f4: got %f but expected %d\n", s5.f4, 4);
6979 fprintf(stderr, "mono_return_double5 s5.f5: got %f but expected %d\n", s5.f5, 5);
6981 s5.f1+=addend; s5.f2+=addend; s5.f3+=addend; s5.f4+=addend; s5.f5+=addend;
6986 double f1,f2,f3,f4,f5,f6;
6989 LIBTEST_API double6 STDCALL
6990 mono_return_double6 (double6 s6, int addend) {
6992 fprintf(stderr, "mono_return_double6 s6.f1: got %f but expected %d\n", s6.f1, 1);
6995 fprintf(stderr, "mono_return_double6 s6.f2: got %f but expected %d\n", s6.f2, 2);
6998 fprintf(stderr, "mono_return_double6 s6.f3: got %f but expected %d\n", s6.f3, 3);
7001 fprintf(stderr, "mono_return_double6 s6.f4: got %f but expected %d\n", s6.f4, 4);
7004 fprintf(stderr, "mono_return_double6 s6.f5: got %f but expected %d\n", s6.f5, 5);
7007 fprintf(stderr, "mono_return_double6 s6.f6: got %f but expected %d\n", s6.f6, 6);
7009 s6.f1+=addend; s6.f2+=addend; s6.f3+=addend; s6.f4+=addend; s6.f5+=addend; s6.f6+=addend;
7014 double f1,f2,f3,f4,f5,f6,f7;
7017 LIBTEST_API double7 STDCALL
7018 mono_return_double7 (double7 s7, int addend) {
7020 fprintf(stderr, "mono_return_double7 s7.f1: got %f but expected %d\n", s7.f1, 1);
7023 fprintf(stderr, "mono_return_double7 s7.f2: got %f but expected %d\n", s7.f2, 2);
7026 fprintf(stderr, "mono_return_double7 s7.f3: got %f but expected %d\n", s7.f3, 3);
7029 fprintf(stderr, "mono_return_double7 s7.f4: got %f but expected %d\n", s7.f4, 4);
7032 fprintf(stderr, "mono_return_double7 s7.f5: got %f but expected %d\n", s7.f5, 5);
7035 fprintf(stderr, "mono_return_double7 s7.f6: got %f but expected %d\n", s7.f6, 6);
7038 fprintf(stderr, "mono_return_double7 s7.f7: got %f but expected %d\n", s7.f7, 7);
7040 s7.f1+=addend; s7.f2+=addend; s7.f3+=addend; s7.f4+=addend; s7.f5+=addend; s7.f6+=addend; s7.f7+=addend;
7045 double f1,f2,f3,f4,f5,f6,f7,f8;
7048 LIBTEST_API double8 STDCALL
7049 mono_return_double8 (double8 s8, int addend) {
7051 fprintf(stderr, "mono_return_double8 s8.f1: got %f but expected %d\n", s8.f1, 1);
7054 fprintf(stderr, "mono_return_double8 s8.f2: got %f but expected %d\n", s8.f2, 2);
7057 fprintf(stderr, "mono_return_double8 s8.f3: got %f but expected %d\n", s8.f3, 3);
7060 fprintf(stderr, "mono_return_double8 s8.f4: got %f but expected %d\n", s8.f4, 4);
7063 fprintf(stderr, "mono_return_double8 s8.f5: got %f but expected %d\n", s8.f5, 5);
7066 fprintf(stderr, "mono_return_double8 s8.f6: got %f but expected %d\n", s8.f6, 6);
7069 fprintf(stderr, "mono_return_double8 s8.f7: got %f but expected %d\n", s8.f7, 7);
7072 fprintf(stderr, "mono_return_double8 s8.f8: got %f but expected %d\n", s8.f8, 8);
7074 s8.f1+=addend; s8.f2+=addend; s8.f3+=addend; s8.f4+=addend; s8.f5+=addend; s8.f6+=addend; s8.f7+=addend; s8.f8+=addend;
7079 double f1,f2,f3,f4,f5,f6,f7,f8,f9;
7082 LIBTEST_API double9 STDCALL
7083 mono_return_double9 (double9 s9, int addend) {
7085 fprintf(stderr, "mono_return_double9 s9.f1: got %f but expected %d\n", s9.f1, 1);
7088 fprintf(stderr, "mono_return_double9 s9.f2: got %f but expected %d\n", s9.f2, 2);
7091 fprintf(stderr, "mono_return_double9 s9.f3: got %f but expected %d\n", s9.f3, 3);
7094 fprintf(stderr, "mono_return_double9 s9.f4: got %f but expected %d\n", s9.f4, 4);
7097 fprintf(stderr, "mono_return_double9 s9.f5: got %f but expected %d\n", s9.f5, 5);
7100 fprintf(stderr, "mono_return_double9 s9.f6: got %f but expected %d\n", s9.f6, 6);
7103 fprintf(stderr, "mono_return_double9 s9.f7: got %f but expected %d\n", s9.f7, 7);
7106 fprintf(stderr, "mono_return_double9 s9.f8: got %f but expected %d\n", s9.f8, 8);
7109 fprintf(stderr, "mono_return_double9 s9.f9: got %f but expected %d\n", s9.f9, 9);
7111 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;
7124 LIBTEST_API double2_nested STDCALL
7125 mono_return_double2_nested (double2_nested sn2, int addend) {
7126 if (sn2.nested1.f1 != 1) {
7127 fprintf(stderr, "mono_return_double2_nested sn2.nested1.f1: got %f but expected %d\n", sn2.nested1.f1, 1);
7129 if (sn2.nested2.f2 != 2) {
7130 fprintf(stderr, "mono_return_double2_nested sn2.nested2.f2: got %f but expected %d\n", sn2.nested2.f2, 2);
7132 sn2.nested1.f1+=addend; sn2.nested2.f2+=addend;
7142 LIBTEST_API double_array4 STDCALL
7143 mono_return_double_array4 (double_array4 sa4, int addend) {
7144 if (sa4.f1[0] != 1) {
7145 fprintf(stderr, "mono_return_double_array4 sa4.f1[0]: got %f but expected %d\n", sa4.f1[0], 1);
7147 if (sa4.f1[1] != 2) {
7148 fprintf(stderr, "mono_return_double_array4 sa4.f1[1]: got %f but expected %d\n", sa4.f1[1], 2);
7150 if (sa4.f1[2] != 3) {
7151 fprintf(stderr, "mono_return_double_array4 sa4.f1[2]: got %f but expected %d\n", sa4.f1[2], 3);
7153 if (sa4.f1[3] != 4) {
7154 fprintf(stderr, "mono_return_double_array4 sa4.f1[3]: got %f but expected %d\n", sa4.f1[3], 4);
7156 sa4.f1[0]+=addend; sa4.f1[1]+=addend; sa4.f1[2]+=addend; sa4.f1[3]+=addend;