11 #include "../utils/mono-errno.h"
12 #include "../utils/mono-compiler.h"
30 #define STDCALL __stdcall
33 #define __thiscall /* nothing */
37 #pragma GCC diagnostic ignored "-Wmissing-prototypes"
41 extern __declspec(dllimport
) void __stdcall
CoTaskMemFree(void *ptr
);
44 typedef int (STDCALL
*SimpleDelegate
) (int a
);
46 #if defined(WIN32) && defined (_MSC_VER)
47 #define LIBTEST_API __declspec(dllexport)
48 #elif defined(__GNUC__)
49 #define LIBTEST_API __attribute__ ((__visibility__ ("default")))
54 static void marshal_free (void *ptr
)
63 static void* marshal_alloc (gsize size
)
66 return CoTaskMemAlloc (size
);
68 return g_malloc (size
);
72 static void* marshal_alloc0 (gsize size
)
75 void* ptr
= CoTaskMemAlloc (size
);
79 return g_malloc0 (size
);
83 static char* marshal_strdup (const char *str
)
89 char *buf
= (char *) CoTaskMemAlloc (strlen (str
) + 1);
90 return strcpy (buf
, str
);
92 return g_strdup (str
);
96 static gunichar2
* marshal_bstr_alloc(const gchar
* str
)
99 gunichar2
* temp
= g_utf8_to_utf16 (str
, -1, NULL
, NULL
, NULL
);
100 gunichar2
* ret
= SysAllocString (temp
);
105 int slen
= strlen (str
);
107 /* allocate len + 1 utf16 characters plus 4 byte integer for length*/
108 ret
= (gchar
*)g_malloc ((slen
+ 1) * sizeof(gunichar2
) + sizeof(guint32
));
111 temp
= g_utf8_to_utf16 (str
, -1, NULL
, NULL
, NULL
);
112 memcpy (ret
+ sizeof(guint32
), temp
, slen
* sizeof(gunichar2
));
113 * ((guint32
*) ret
) = slen
* sizeof(gunichar2
);
114 ret
[4 + slen
* sizeof(gunichar2
)] = 0;
115 ret
[5 + slen
* sizeof(gunichar2
)] = 0;
117 return (gunichar2
*)(ret
+ 4);
121 #define marshal_new0(type,size) ((type *) marshal_alloc0 (sizeof (type)* (size)))
123 LIBTEST_API
int STDCALL
124 mono_cominterop_is_supported (void)
126 #if defined(TARGET_X86) || defined(TARGET_AMD64)
132 LIBTEST_API
unsigned short* STDCALL
133 test_lpwstr_marshal (unsigned short* chars
, int length
)
138 res
= (unsigned short *)marshal_alloc (2 * (length
+ 1));
140 // printf("test_lpwstr_marshal()\n");
142 while ( i
< length
) {
143 // printf("X|%u|\n", chars[i]);
154 LIBTEST_API
void STDCALL
155 test_lpwstr_marshal_out (unsigned short** chars
)
158 const char abc
[] = "ABC";
159 glong len
= strlen(abc
);
161 *chars
= (unsigned short *)marshal_alloc (2 * (len
+ 1));
164 (*chars
) [i
] = abc
[i
];
177 LIBTEST_API
int STDCALL
178 mono_union_test_1 (union_test_1_type u1
) {
179 // printf ("Got values %d %d %d\n", u1.b, u1.a, u1.c);
180 return u1
.a
+ u1
.b
+ u1
.c
;
183 LIBTEST_API
int STDCALL
184 mono_return_int (int a
) {
185 // printf ("Got value %d\n", a);
189 LIBTEST_API
float STDCALL
190 mono_test_marshal_pass_return_float (float f
) {
199 LIBTEST_API
int STDCALL
200 mono_return_int_ss (struct ss a
) {
201 // printf ("Got value %d\n", a.i);
205 LIBTEST_API
struct ss STDCALL
206 mono_return_ss (struct ss a
) {
207 // printf ("Got value %d\n", a.i);
217 LIBTEST_API
struct sc1 STDCALL
218 mono_return_sc1 (struct sc1 a
) {
219 // printf ("Got value %d\n", a.c[0]);
230 LIBTEST_API
struct sc3 STDCALL
231 mono_return_sc3 (struct sc3 a
) {
232 // printf ("Got values %d %d %d\n", a.c[0], a.c[1], a.c[2]);
244 LIBTEST_API
struct sc5 STDCALL
245 mono_return_sc5 (struct sc5 a
) {
246 // printf ("Got values %d %d %d %d %d\n", a.c[0], a.c[1], a.c[2], a.c[3], a.c[4]);
261 LIBTEST_API
int STDCALL
262 mono_return_int_su (union su a
) {
263 // printf ("Got value %d\n", a.i1);
278 LIBTEST_API
struct NestedFloat STDCALL
279 mono_return_nested_float (void)
281 struct NestedFloat f
;
300 LIBTEST_API
char * STDCALL
301 mono_return_struct_4_double (void *ptr
, struct Rect rect
, struct Scalar4 sc4
, int a
, int b
, int c
)
303 char *buffer
= (char *)marshal_alloc (1024 * sizeof (char));
304 sprintf (buffer
, "sc4 = {%.1f, %.1f, %.1f, %.1f }, a=%x, b=%x, c=%x\n", (float) sc4
.val
[0], (float) sc4
.val
[1], (float) sc4
.val
[2], (float) sc4
.val
[3], a
, b
, c
);
308 LIBTEST_API
int STDCALL
309 mono_test_many_int_arguments (int a
, int b
, int c
, int d
, int e
,
310 int f
, int g
, int h
, int i
, int j
);
311 LIBTEST_API
short STDCALL
312 mono_test_many_short_arguments (short a
, short b
, short c
, short d
, short e
,
313 short f
, short g
, short h
, short i
, short j
);
314 LIBTEST_API
char STDCALL
315 mono_test_many_char_arguments (char a
, char b
, char c
, char d
, char e
,
316 char f
, char g
, char h
, char i
, char j
);
318 LIBTEST_API
int STDCALL
319 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
)
321 return a
+ b
+ c
+ d
+ e
+ f
+ g
+ h
+ i
+ j
;
324 LIBTEST_API
short STDCALL
325 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
)
327 return a
+ b
+ c
+ d
+ e
+ f
+ g
+ h
+ i
+ j
;
330 LIBTEST_API
char STDCALL
331 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
)
333 return a
+ b
+ c
+ d
+ e
+ f
+ g
+ h
+ i
+ j
;
336 LIBTEST_API
float STDCALL
337 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
)
339 return a
+ b
+ c
+ d
+ e
+ f
+ g
+ h
+ i
+ j
;
342 LIBTEST_API
double STDCALL
343 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
)
345 return a
+ b
+ c
+ d
+ e
+ f
+ g
+ h
+ i
+ j
;
348 LIBTEST_API
double STDCALL
349 mono_test_split_double_arguments (double a
, double b
, float c
, double d
, double e
)
351 return a
+ b
+ c
+ d
+ e
;
354 LIBTEST_API
int STDCALL
355 mono_test_puts_static (char *s
)
357 // printf ("TEST %s\n", s);
361 typedef int (STDCALL
*SimpleDelegate3
) (int a
, int b
);
363 LIBTEST_API
int STDCALL
364 mono_invoke_delegate (SimpleDelegate3 delegate
)
368 // printf ("start invoke %p\n", delegate);
370 res
= delegate (2, 3);
372 // printf ("end invoke\n");
377 LIBTEST_API
int STDCALL
378 mono_invoke_simple_delegate (SimpleDelegate d
)
383 LIBTEST_API
int STDCALL
384 mono_test_marshal_char (short a1
)
392 LIBTEST_API
void STDCALL
393 mono_test_marshal_char_array (gunichar2
*s
)
395 const char m
[] = "abcdef";
399 s2
= g_utf8_to_utf16 (m
, -1, NULL
, &len
, NULL
);
407 LIBTEST_API
int STDCALL
408 mono_test_marshal_ansi_char_array (char *s
)
410 const char m
[] = "abcdef";
412 if (strncmp ("qwer", s
, 4))
415 memcpy (s
, m
, sizeof (m
));
419 LIBTEST_API
int STDCALL
420 mono_test_marshal_unicode_char_array (gunichar2
*s
)
422 const char m
[] = "abcdef";
423 const char expected
[] = "qwer";
427 s1
= g_utf8_to_utf16 (m
, -1, NULL
, &len1
, NULL
);
428 s2
= g_utf8_to_utf16 (expected
, -1, NULL
, &len2
, NULL
);
432 if (memcmp (s
, s2
, len2
))
435 memcpy (s
, s1
, len1
);
439 LIBTEST_API
int STDCALL
440 mono_test_empty_pinvoke (int i
)
445 LIBTEST_API
int STDCALL
446 mono_test_marshal_bool_byref (int a
, int *b
, int c
)
455 LIBTEST_API
int STDCALL
456 mono_test_marshal_bool_in_as_I1_U1 (char bTrue
, char bFalse
)
465 LIBTEST_API
int STDCALL
466 mono_test_marshal_bool_out_as_I1_U1 (char* bTrue
, char* bFalse
)
468 if (!bTrue
|| !bFalse
)
477 LIBTEST_API
int STDCALL
478 mono_test_marshal_bool_ref_as_I1_U1 (char* bTrue
, char* bFalse
)
480 if (!bTrue
|| !bFalse
)
494 LIBTEST_API
int STDCALL
495 mono_test_marshal_array (int *a1
)
499 for (i
= 0; i
< 50; i
++)
505 LIBTEST_API
int STDCALL
506 mono_test_marshal_inout_array (int *a1
)
510 for (i
= 0; i
< 50; i
++) {
512 a1
[i
] = 50 - a1
[i
];
518 LIBTEST_API
int /* cdecl */
519 mono_test_marshal_inout_array_cdecl (int *a1
)
521 return mono_test_marshal_inout_array (a1
);
524 LIBTEST_API
int STDCALL
525 mono_test_marshal_out_array (int *a1
)
529 for (i
= 0; i
< 50; i
++) {
536 LIBTEST_API
int STDCALL
537 mono_test_marshal_out_byref_array_out_size_param (int **out_arr
, int *out_len
)
543 arr
= (gint32
*)marshal_alloc (sizeof (gint32
) * len
);
544 for (i
= 0; i
< len
; ++i
)
552 LIBTEST_API
int STDCALL
553 mono_test_marshal_out_lparray_out_size_param (int *arr
, int *out_len
)
558 for (i
= 0; i
< len
; ++i
)
565 LIBTEST_API
int STDCALL
566 mono_test_marshal_inout_nonblittable_array (gunichar2
*a1
)
570 for (i
= 0; i
< 10; i
++) {
590 LIBTEST_API simplestruct STDCALL
591 mono_test_return_vtype (int i
)
594 static gunichar2 test2
[] = { 'T', 'E', 'S', 'T', '2', 0 };
605 LIBTEST_API
void STDCALL
606 mono_test_delegate_struct (void)
608 // printf ("TEST\n");
611 typedef char* (STDCALL
*ReturnStringDelegate
) (const char *s
);
613 LIBTEST_API
char * STDCALL
614 mono_test_return_string (ReturnStringDelegate func
)
618 // printf ("mono_test_return_string\n");
623 // printf ("got string: %s\n", res);
624 return marshal_strdup ("12345");
627 typedef int (STDCALL
*RefVTypeDelegate
) (int a
, simplestruct
*ss
, int b
);
629 LIBTEST_API
int STDCALL
630 mono_test_ref_vtype (int a
, simplestruct
*ss
, int b
, RefVTypeDelegate func
)
632 if (a
== 1 && b
== 2 && ss
->a
== 0 && ss
->b
== 1 && ss
->c
== 0 &&
633 !strcmp (ss
->d
, "TEST1")) {
639 return func (a
, ss
, b
);
645 typedef int (STDCALL
*OutVTypeDelegate
) (int a
, simplestruct
*ss
, int b
);
647 LIBTEST_API
int STDCALL
648 mono_test_marshal_out_struct (int a
, simplestruct
*ss
, int b
, OutVTypeDelegate func
)
650 /* Check that the input pointer is ignored */
651 ss
->d
= (const char *)0x12345678;
655 if (ss
->a
&& ss
->b
&& ss
->c
&& !strcmp (ss
->d
, "TEST3"))
661 typedef int (STDCALL
*InVTypeDelegate
) (int a
, simplestruct
*ss
, int b
);
663 LIBTEST_API
int STDCALL
664 mono_test_marshal_in_struct (int a
, simplestruct
*ss
, int b
, InVTypeDelegate func
)
669 memcpy (&ss2
, ss
, sizeof (simplestruct
));
671 res
= func (a
, ss
, b
);
673 printf ("mono_test_marshal_in_struct () failed: %d\n", res
);
677 /* Check that no modifications is made to the struct */
678 if (ss2
.a
== ss
->a
&& ss2
.b
== ss
->b
&& ss2
.c
== ss
->c
&& ss2
.d
== ss
->d
)
686 SimpleDelegate func
, func2
, func3
;
689 LIBTEST_API DelegateStruct STDCALL
690 mono_test_marshal_delegate_struct (DelegateStruct ds
)
694 res
.a
= ds
.func (ds
.a
) + ds
.func2 (ds
.a
) + (ds
.func3
== NULL
? 0 : 1);
696 res
.func2
= ds
.func2
;
702 LIBTEST_API
int STDCALL
703 mono_test_marshal_struct (simplestruct ss
)
705 if (ss
.a
== 0 && ss
.b
== 1 && ss
.c
== 0 &&
706 !strcmp (ss
.d
, "TEST"))
712 LIBTEST_API
int STDCALL
713 mono_test_marshal_byref_struct (simplestruct
*ss
, int a
, int b
, int c
, char *d
)
715 gboolean res
= (ss
->a
== a
&& ss
->b
== b
&& ss
->c
== c
&& strcmp (ss
->d
, d
) == 0);
717 marshal_free ((char*)ss
->d
);
722 ss
->d
= marshal_strdup ("DEF");
738 LIBTEST_API
int STDCALL
739 mono_test_marshal_struct2 (simplestruct2 ss
)
741 if (ss
.a
== 0 && ss
.b
== 1 && ss
.c
== 0 &&
742 !strcmp (ss
.d
, "TEST") &&
743 ss
.e
== 99 && ss
.f
== 1.5 && ss
.g
== 42 && ss
.h
== (guint64
)123)
749 /* on HP some of the struct should be on the stack and not in registers */
750 LIBTEST_API
int STDCALL
751 mono_test_marshal_struct2_2 (int i
, int j
, int k
, simplestruct2 ss
)
753 if (i
!= 10 || j
!= 11 || k
!= 12)
755 if (ss
.a
== 0 && ss
.b
== 1 && ss
.c
== 0 &&
756 !strcmp (ss
.d
, "TEST") &&
757 ss
.e
== 99 && ss
.f
== 1.5 && ss
.g
== 42 && ss
.h
== (guint64
)123)
763 LIBTEST_API
int STDCALL
764 mono_test_marshal_lpstruct (simplestruct
*ss
)
766 if (ss
->a
== 0 && ss
->b
== 1 && ss
->c
== 0 &&
767 !strcmp (ss
->d
, "TEST"))
773 LIBTEST_API
int STDCALL
774 mono_test_marshal_lpstruct_blittable (point
*p
)
776 if (p
->x
== 1.0 && p
->y
== 2.0)
782 LIBTEST_API
int STDCALL
783 mono_test_marshal_struct_array (simplestruct2
*ss
)
785 if (! (ss
[0].a
== 0 && ss
[0].b
== 1 && ss
[0].c
== 0 &&
786 !strcmp (ss
[0].d
, "TEST") &&
787 ss
[0].e
== 99 && ss
[0].f
== 1.5 && ss
[0].g
== 42 && ss
[0].h
== (guint64
)123))
790 if (! (ss
[1].a
== 0 && ss
[1].b
== 0 && ss
[1].c
== 0 &&
791 !strcmp (ss
[1].d
, "TEST2") &&
792 ss
[1].e
== 100 && ss
[1].f
== 2.5 && ss
[1].g
== 43 && ss
[1].h
== (guint64
)124))
798 typedef struct long_align_struct
{
804 LIBTEST_API
int STDCALL
805 mono_test_marshal_long_align_struct_array (long_align_struct
*ss
)
807 return ss
[0].a
+ ss
[0].b
+ ss
[0].c
+ ss
[1].a
+ ss
[1].b
+ ss
[1].c
;
810 LIBTEST_API simplestruct2
* STDCALL
811 mono_test_marshal_class (int i
, int j
, int k
, simplestruct2
*ss
, int l
)
818 if (i
!= 10 || j
!= 11 || k
!= 12 || l
!= 14)
820 if (! (ss
->a
== 0 && ss
->b
== 1 && ss
->c
== 0 &&
821 !strcmp (ss
->d
, "TEST") &&
822 ss
->e
== 99 && ss
->f
== 1.5 && ss
->g
== 42 && ss
->h
== (guint64
)123))
825 res
= marshal_new0 (simplestruct2
, 1);
826 memcpy (res
, ss
, sizeof (simplestruct2
));
827 res
->d
= marshal_strdup ("TEST");
831 LIBTEST_API
int STDCALL
832 mono_test_marshal_byref_class (simplestruct2
**ssp
)
834 simplestruct2
*ss
= *ssp
;
837 if (! (ss
->a
== 0 && ss
->b
== 1 && ss
->c
== 0 &&
838 !strcmp (ss
->d
, "TEST") &&
839 ss
->e
== 99 && ss
->f
== 1.5 && ss
->g
== 42 && ss
->h
== (guint64
)123))
842 res
= marshal_new0 (simplestruct2
, 1);
843 memcpy (res
, ss
, sizeof (simplestruct2
));
844 res
->d
= marshal_strdup ("TEST-RES");
856 /* Yes, this is correct, we are only trying to determine the value of the stack here */
861 LIBTEST_API
int STDCALL
862 reliable_delegate (int a
)
868 * Checks whether get_sp() works as expected. It doesn't work with gcc-2.95.3 on linux.
871 is_get_sp_reliable (void)
875 reliable_delegate(1);
877 reliable_delegate(1);
882 LIBTEST_API
int STDCALL
883 mono_test_marshal_delegate (SimpleDelegate delegate
)
887 /* Check that the delegate wrapper is stdcall */
892 if (is_get_sp_reliable())
893 g_assert (sp1
== sp2
);
898 static int STDCALL
inc_cb (int i
)
903 LIBTEST_API
int STDCALL
904 mono_test_marshal_out_delegate (SimpleDelegate
*delegate
)
911 LIBTEST_API SimpleDelegate STDCALL
912 mono_test_marshal_return_delegate (SimpleDelegate delegate
)
917 typedef int (STDCALL
*DelegateByrefDelegate
) (void *);
919 LIBTEST_API
int STDCALL
920 mono_test_marshal_delegate_ref_delegate (DelegateByrefDelegate del
)
922 int (STDCALL
*ptr
) (int i
);
930 return_plus_one (int i
)
935 LIBTEST_API SimpleDelegate STDCALL
936 mono_test_marshal_return_delegate_2 (void)
938 return return_plus_one
;
941 typedef simplestruct (STDCALL
*SimpleDelegate2
) (simplestruct ss
);
944 is_utf16_equals (gunichar2
*s1
, const char *s2
)
949 s
= g_utf16_to_utf8 (s1
, -1, NULL
, NULL
, NULL
);
950 res
= strcmp (s
, s2
);
956 LIBTEST_API
int STDCALL
957 mono_test_marshal_delegate2 (SimpleDelegate2 delegate
)
959 simplestruct ss
, res
;
965 ss
.d2
= g_utf8_to_utf16 ("TEST2", -1, NULL
, NULL
, NULL
);
968 if (! (res
.a
&& !res
.b
&& res
.c
&& !strcmp (res
.d
, "TEST-RES") && is_utf16_equals (res
.d2
, "TEST2-RES")))
974 typedef simplestruct
* (STDCALL
*SimpleDelegate4
) (simplestruct
*ss
);
976 LIBTEST_API
int STDCALL
977 mono_test_marshal_delegate4 (SimpleDelegate4 delegate
)
988 res
= delegate (&ss
);
992 /* Check return value */
993 if (! (!res
->a
&& res
->b
&& !res
->c
&& !strcmp (res
->d
, "TEST")))
996 /* Check NULL argument and NULL result */
997 res
= delegate (NULL
);
1004 typedef int (STDCALL
*SimpleDelegate5
) (simplestruct
**ss
);
1006 LIBTEST_API
int STDCALL
1007 mono_test_marshal_delegate5 (SimpleDelegate5 delegate
)
1020 res
= delegate (&ptr
);
1024 if (!(ptr
->a
&& !ptr
->b
&& ptr
->c
&& !strcmp (ptr
->d
, "RES")))
1030 LIBTEST_API
int STDCALL
1031 mono_test_marshal_delegate6 (SimpleDelegate5 delegate
)
1037 typedef int (STDCALL
*SimpleDelegate7
) (simplestruct
**ss
);
1039 LIBTEST_API
int STDCALL
1040 mono_test_marshal_delegate7 (SimpleDelegate7 delegate
)
1045 /* Check that the input pointer is ignored */
1046 ptr
= (simplestruct
*)0x12345678;
1048 res
= delegate (&ptr
);
1052 if (!(ptr
->a
&& !ptr
->b
&& ptr
->c
&& !strcmp (ptr
->d
, "RES")))
1058 typedef int (STDCALL
*InOutByvalClassDelegate
) (simplestruct
*ss
);
1060 LIBTEST_API
int STDCALL
1061 mono_test_marshal_inout_byval_class_delegate (InOutByvalClassDelegate delegate
)
1069 ss
.d
= g_strdup_printf ("%s", "FOO");
1071 res
= delegate (&ss
);
1075 if (!(ss
.a
&& !ss
.b
&& ss
.c
&& !strcmp (ss
.d
, "RES")))
1081 typedef int (STDCALL
*SimpleDelegate8
) (gunichar2
*s
);
1083 LIBTEST_API
int STDCALL
1084 mono_test_marshal_delegate8 (SimpleDelegate8 delegate
, gunichar2
*s
)
1086 return delegate (s
);
1089 typedef int (STDCALL
*return_int_fnt
) (int i
);
1090 typedef int (STDCALL
*SimpleDelegate9
) (return_int_fnt d
);
1092 LIBTEST_API
int STDCALL
1093 mono_test_marshal_delegate9 (SimpleDelegate9 delegate
, gpointer ftn
)
1095 return delegate ((return_int_fnt
)ftn
);
1104 LIBTEST_API
int STDCALL
1105 mono_test_marshal_delegate10 (SimpleDelegate9 delegate
)
1107 return delegate (return_self
);
1110 typedef int (STDCALL
*PrimitiveByrefDelegate
) (int *i
);
1112 LIBTEST_API
int STDCALL
1113 mono_test_marshal_primitive_byref_delegate (PrimitiveByrefDelegate delegate
)
1117 int res
= delegate (&i
);
1127 typedef int (STDCALL
*return_int_delegate
) (int i
);
1129 typedef return_int_delegate (STDCALL
*ReturnDelegateDelegate
) (void);
1131 LIBTEST_API
int STDCALL
1132 mono_test_marshal_return_delegate_delegate (ReturnDelegateDelegate d
)
1137 typedef int (STDCALL
*VirtualDelegate
) (int);
1139 LIBTEST_API
int STDCALL
1140 mono_test_marshal_virtual_delegate (VirtualDelegate del
)
1145 typedef char* (STDCALL
*IcallDelegate
) (const char *);
1146 LIBTEST_API
int STDCALL
1147 mono_test_marshal_icall_delegate (IcallDelegate del
)
1149 char *res
= del ("ABC");
1150 return strcmp (res
, "ABC") == 0 ? 0 : 1;
1153 LIBTEST_API
int STDCALL
1154 mono_test_marshal_stringbuilder (char *s
, int n
)
1156 const char m
[] = "This is my message. Isn't it nice?";
1158 if (strcmp (s
, "ABCD") != 0)
1165 LIBTEST_API
int STDCALL
1166 mono_test_marshal_stringbuilder_append (char *s
, int length
)
1168 const char out_sentinel
[] = "CSHARP_";
1169 const char out_len
= strlen (out_sentinel
);
1171 for (int i
=0; i
< length
; i
++) {
1172 s
[i
] = out_sentinel
[i
% out_len
];
1181 LIBTEST_API
int STDCALL
1182 mono_test_marshal_stringbuilder_default (char *s
, int n
)
1184 const char m
[] = "This is my message. Isn't it nice?";
1191 LIBTEST_API
int STDCALL
1192 mono_test_marshal_stringbuilder_unicode (gunichar2
*s
, int n
)
1194 const char m
[] = "This is my message. Isn't it nice?";
1198 s2
= g_utf8_to_utf16 (m
, -1, NULL
, &len
, NULL
);
1200 len
= (len
* 2) + 2;
1203 memcpy (s
, s2
, len
);
1210 LIBTEST_API
void STDCALL
1211 mono_test_marshal_stringbuilder_out (char **s
)
1213 const char m
[] = "This is my message. Isn't it nice?";
1216 str
= (char *)marshal_alloc (strlen (m
) + 1);
1217 memcpy (str
, m
, strlen (m
) + 1);
1222 LIBTEST_API
int STDCALL
1223 mono_test_marshal_stringbuilder_out_unicode (gunichar2
**s
)
1225 const char m
[] = "This is my message. Isn't it nice?";
1229 s2
= g_utf8_to_utf16 (m
, -1, NULL
, &len
, NULL
);
1231 len
= (len
* 2) + 2;
1232 *s
= (gunichar2
*)marshal_alloc (len
);
1233 memcpy (*s
, s2
, len
);
1240 LIBTEST_API
int STDCALL
1241 mono_test_marshal_stringbuilder_ref (char **s
)
1243 const char m
[] = "This is my message. Isn't it nice?";
1246 if (strcmp (*s
, "ABC"))
1249 str
= (char *)marshal_alloc (strlen (m
) + 1);
1250 memcpy (str
, m
, strlen (m
) + 1);
1256 LIBTEST_API
void STDCALL
1257 mono_test_marshal_stringbuilder_utf16_tolower (short *s
, int n
)
1259 for (int i
= 0; i
< n
; i
++)
1260 s
[i
] = tolower(s
[i
]);
1265 #pragma GCC diagnostic push
1266 #pragma GCC diagnostic ignored "-Wc++-compat"
1270 * Standard C and C++ doesn't allow empty structs, empty structs will always have a size of 1 byte.
1271 * GCC have an extension to allow empty structs, https://gcc.gnu.org/onlinedocs/gcc/Empty-Structures.html.
1272 * This cause a little dilemma since runtime build using none GCC compiler will not be compatible with
1273 * GCC build C libraries and the other way around. On platforms where empty structs has size of 1 byte
1274 * it must be represented in call and cannot be dropped. On Windows x64 structs will always be represented in the call
1275 * meaning that an empty struct must have a representation in the callee in order to correctly follow the ABI used by the
1276 * C/C++ standard and the runtime.
1279 #if !defined(__GNUC__) || defined(TARGET_WIN32)
1285 #pragma GCC diagnostic pop
1288 LIBTEST_API
int STDCALL
1289 mono_test_marshal_empty_string_array (char **array
)
1291 return (array
== NULL
) ? 0 : 1;
1294 LIBTEST_API
int STDCALL
1295 mono_test_marshal_string_array (char **array
)
1297 if (strcmp (array
[0], "ABC"))
1299 if (strcmp (array
[1], "DEF"))
1302 if (array
[2] != NULL
)
1308 LIBTEST_API
int STDCALL
1309 mono_test_marshal_byref_string_array (char ***array
)
1314 if (strcmp ((*array
) [0], "Alpha"))
1316 if (strcmp ((*array
) [1], "Beta"))
1318 if (strcmp ((*array
) [2], "Gamma"))
1324 LIBTEST_API
int STDCALL
1325 mono_test_marshal_stringbuilder_array (char **array
)
1327 if (strcmp (array
[0], "ABC"))
1329 if (strcmp (array
[1], "DEF"))
1332 strcpy (array
[0], "DEF");
1333 strcpy (array
[1], "ABC");
1338 LIBTEST_API
int STDCALL
1339 mono_test_marshal_unicode_string_array (gunichar2
**array
, char **array2
)
1341 GError
*gerror
= NULL
;
1344 s
= g_utf16_to_utf8 (array
[0], -1, NULL
, NULL
, &gerror
);
1345 if (strcmp (s
, "ABC")) {
1352 s
= g_utf16_to_utf8 (array
[1], -1, NULL
, NULL
, &gerror
);
1353 if (strcmp (s
, "DEF")) {
1360 if (strcmp (array2
[0], "ABC"))
1363 if (strcmp (array2
[1], "DEF"))
1369 /* this does not work on Redhat gcc 2.96 */
1370 LIBTEST_API
int STDCALL
1371 mono_test_empty_struct (int a
, EmptyStruct es
, int b
)
1373 // printf ("mono_test_empty_struct %d %d\n", a, b);
1375 // Intel icc on ia64 passes 'es' in 2 registers
1376 #if defined(__ia64) && defined(__INTEL_COMPILER)
1379 if (a
== 1 && b
== 2)
1385 LIBTEST_API EmptyStruct STDCALL
1386 mono_test_return_empty_struct (int a
)
1390 memset (&s
, 0, sizeof (s
));
1392 #if !(defined(__i386__) && defined(__clang__))
1393 /* https://bugzilla.xamarin.com/show_bug.cgi?id=58901 */
1404 LIBTEST_API ByValStrStruct
* STDCALL
1405 mono_test_byvalstr_gen (void)
1407 ByValStrStruct
*ret
;
1409 ret
= (ByValStrStruct
*)malloc (sizeof (ByValStrStruct
));
1410 memset(ret
, 'a', sizeof(ByValStrStruct
)-1);
1411 ret
->a
[sizeof(ByValStrStruct
)-1] = 0;
1416 LIBTEST_API
int STDCALL
1417 mono_test_byvalstr_check (ByValStrStruct
* data
, char* correctString
)
1421 ret
= strcmp(data
->a
, correctString
);
1422 // printf ("T1: %s\n", data->a);
1423 // printf ("T2: %s\n", correctString);
1425 /* we need g_free because the allocation was performed by mono_test_byvalstr_gen */
1433 } ByValStrStruct_Unicode
;
1435 LIBTEST_API
int STDCALL
1436 mono_test_byvalstr_check_unicode (ByValStrStruct_Unicode
*ref
, int test
)
1438 if (ref
->flag
!= 0x1234abcd){
1439 printf ("overwritten data");
1443 if (test
== 1 || test
== 3){
1444 if (ref
->a
[0] != '1' ||
1445 ref
->a
[1] != '2' ||
1451 if (ref
->a
[0] != '1' ||
1459 LIBTEST_API
int STDCALL
1460 NameManglingAnsi (char *data
)
1462 return data
[0] + data
[1] + data
[2];
1465 LIBTEST_API
int STDCALL
1466 NameManglingAnsiA (char *data
)
1468 g_assert_not_reached ();
1471 LIBTEST_API
int STDCALL
1472 NameManglingAnsiW (char *data
)
1474 g_assert_not_reached ();
1477 LIBTEST_API
int STDCALL
1478 NameManglingAnsi2A (char *data
)
1480 return data
[0] + data
[1] + data
[2];
1483 LIBTEST_API
int STDCALL
1484 NameManglingAnsi2W (char *data
)
1486 g_assert_not_reached ();
1489 LIBTEST_API
int STDCALL
1490 NameManglingUnicode (char *data
)
1492 g_assert_not_reached ();
1495 LIBTEST_API
int STDCALL
1496 NameManglingUnicodeW (gunichar2
*data
)
1498 return data
[0] + data
[1] + data
[2];
1501 LIBTEST_API
int STDCALL
1502 NameManglingUnicode2 (gunichar2
*data
)
1504 return data
[0] + data
[1] + data
[2];
1507 LIBTEST_API
int STDCALL
1508 NameManglingAutoW (char *data
)
1511 return (data
[0] + data
[1] + data
[2]) == 131 ? 0 : 1;
1513 g_assert_not_reached ();
1517 LIBTEST_API
int STDCALL
1518 NameManglingAuto (char *data
)
1521 return (data
[0] + data
[1] + data
[2]) == 198 ? 0 : 1;
1523 g_assert_not_reached ();
1527 typedef int (STDCALL
*intcharFunc
)(const char*);
1529 LIBTEST_API
void STDCALL
1530 callFunction (intcharFunc f
)
1540 LIBTEST_API
int STDCALL
1541 class_marshal_test0 (SimpleObj
*obj1
)
1543 // printf ("class_marshal_test0 %s %d\n", obj1->str, obj1->i);
1545 if (strcmp(obj1
->str
, "T1"))
1553 LIBTEST_API
int STDCALL
1554 class_marshal_test4 (SimpleObj
*obj1
)
1562 LIBTEST_API
void STDCALL
1563 class_marshal_test1 (SimpleObj
**obj1
)
1565 SimpleObj
*res
= (SimpleObj
*)malloc (sizeof (SimpleObj
));
1567 res
->str
= marshal_strdup ("ABC");
1573 LIBTEST_API
int STDCALL
1574 class_marshal_test2 (SimpleObj
**obj1
)
1576 // printf ("class_marshal_test2 %s %d\n", (*obj1)->str, (*obj1)->i);
1578 if (strcmp((*obj1
)->str
, "ABC"))
1580 if ((*obj1
)->i
!= 5)
1586 LIBTEST_API
int STDCALL
1587 string_marshal_test0 (char *str
)
1589 if (strcmp (str
, "TEST0"))
1595 LIBTEST_API
void STDCALL
1596 string_marshal_test1 (const char **str
)
1598 *str
= marshal_strdup ("TEST1");
1601 LIBTEST_API
int STDCALL
1602 string_marshal_test2 (char **str
)
1604 // printf ("string_marshal_test2 %s\n", *str);
1606 if (strcmp (*str
, "TEST1"))
1609 *str
= marshal_strdup ("TEST2");
1614 LIBTEST_API
int STDCALL
1615 string_marshal_test3 (char *str
)
1628 LIBTEST_API BlittableClass
* STDCALL
1629 TestBlittableClass (BlittableClass
*vl
)
1631 BlittableClass
*res
;
1633 // printf ("TestBlittableClass %d %d\n", vl->a, vl->b);
1639 res
= marshal_new0 (BlittableClass
, 1);
1640 memcpy (res
, vl
, sizeof (BlittableClass
));
1642 res
= marshal_new0 (BlittableClass
, 1);
1650 typedef struct OSVERSIONINFO_STRUCT
1654 } OSVERSIONINFO_STRUCT
;
1656 LIBTEST_API
int STDCALL
1657 MyGetVersionEx (OSVERSIONINFO_STRUCT
*osvi
)
1660 // printf ("GOT %d %d\n", osvi->a, osvi->b);
1665 return osvi
->a
+ osvi
->b
;
1668 LIBTEST_API
int STDCALL
1669 BugGetVersionEx (int a
, int b
, int c
, int d
, int e
, int f
, int g
, int h
, OSVERSIONINFO_STRUCT
*osvi
)
1672 // printf ("GOT %d %d\n", osvi->a, osvi->b);
1677 return osvi
->a
+ osvi
->b
;
1680 LIBTEST_API
int STDCALL
1681 mono_test_marshal_point (point pt
)
1683 // printf("point %g %g\n", pt.x, pt.y);
1684 if (pt
.x
== 1.25 && pt
.y
== 3.5)
1695 LIBTEST_API
int STDCALL
1696 mono_test_marshal_mixed_point (mixed_point pt
)
1698 // printf("mixed point %d %g\n", pt.x, pt.y);
1699 if (pt
.x
== 5 && pt
.y
== 6.75)
1705 LIBTEST_API
int STDCALL
1706 mono_test_marshal_mixed_point_2 (mixed_point
*pt
)
1708 if (pt
->x
!= 5 || pt
->y
!= 6.75)
1717 LIBTEST_API
int STDCALL
1718 marshal_test_ref_bool(int i
, char *b1
, short *b2
, int *b3
)
1721 if (*b1
!= 0 && *b1
!= 1)
1723 if (*b2
!= 0 && *b2
!= -1) /* variant_bool */
1725 if (*b3
!= 0 && *b3
!= 1)
1727 if (i
== ((*b1
<< 2) | (-*b2
<< 1) | *b3
))
1739 short b2
; /* variant_bool */
1743 LIBTEST_API
int STDCALL
1744 marshal_test_bool_struct(struct BoolStruct
*s
)
1747 if (s
->b1
!= 0 && s
->b1
!= 1)
1749 if (s
->b2
!= 0 && s
->b2
!= -1)
1751 if (s
->b3
!= 0 && s
->b3
!= 1)
1753 if (s
->i
== ((s
->b1
<< 2) | (-s
->b2
<< 1) | s
->b3
))
1770 LIBTEST_API
int STDCALL
1771 mono_test_marshal_long_struct (LongStruct
*s
)
1773 return s
->i
+ s
->l
.l
;
1776 LIBTEST_API
void STDCALL
1777 mono_test_last_error (int err
)
1783 * Make sure argument register used calling SetLastError
1784 * get's cleaned before returning back to caller. This is done to ensure
1785 * we don't get a undetected failure if error is preserved in register
1786 * on return since we read back value directly when doing p/invoke with SetLastError = true
1787 * into first argument register and then pass it to Mono function setting value in TLS.
1788 * If there is a codegen bug reading last error or the code has been incorrectly eliminated
1789 * this test could still succeed since expected error code could be left in argument register.
1790 * Below code just do something that shouldn't touch last error and won't be optimized away
1791 * but will change the argument registers to something different than err.
1793 char buffer
[256] = { 0 };
1794 char value
[] = "Dummy";
1795 strncpy (buffer
, value
, G_N_ELEMENTS (value
) - 1);
1797 mono_set_errno (err
);
1801 LIBTEST_API
int STDCALL
1802 mono_test_asany (void *ptr
, int what
)
1806 return (*(int*)ptr
== 5) ? 0 : 1;
1808 return strcmp ((const char*)ptr
, "ABC") == 0 ? 0 : 1;
1810 simplestruct2 ss
= *(simplestruct2
*)ptr
;
1812 if (ss
.a
== 0 && ss
.b
== 1 && ss
.c
== 0 &&
1813 !strcmp (ss
.d
, "TEST") &&
1814 ss
.e
== 99 && ss
.f
== 1.5 && ss
.g
== 42 && ss
.h
== (guint64
)123)
1820 GError
*gerror
= NULL
;
1823 s
= g_utf16_to_utf8 ((const gunichar2
*)ptr
, -1, NULL
, NULL
, &gerror
);
1828 if (!strcmp (s
, "ABC")) {
1838 g_assert_not_reached ();
1852 LIBTEST_API
int STDCALL
1853 mono_test_marshal_asany_in (void* ptr
)
1855 AsAnyStruct
*asAny
= (AsAnyStruct
*)ptr
;
1856 int res
= asAny
->i
+ asAny
->j
+ asAny
->k
;
1861 LIBTEST_API
int STDCALL
1862 mono_test_marshal_asany_inout (void* ptr
)
1864 AsAnyStruct
*asAny
= (AsAnyStruct
*)ptr
;
1865 int res
= asAny
->i
+ asAny
->j
+ asAny
->k
;
1867 marshal_free (asAny
->s
);
1877 LIBTEST_API
int STDCALL
1878 mono_test_marshal_asany_out (void* ptr
)
1880 AsAnyStruct
*asAny
= (AsAnyStruct
*)ptr
;
1881 int res
= asAny
->i
+ asAny
->j
+ asAny
->k
;
1892 * AMD64 marshalling tests.
1895 typedef struct amd64_struct1
{
1902 LIBTEST_API amd64_struct1 STDCALL
1903 mono_test_marshal_amd64_pass_return_struct1 (amd64_struct1 s
)
1913 LIBTEST_API amd64_struct1 STDCALL
1914 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
)
1919 s
.l
+= 1 + i1
+ i2
+ i3
+ i4
+ i5
+ i6
+ i7
+ i8
;
1924 typedef struct amd64_struct2
{
1929 LIBTEST_API amd64_struct2 STDCALL
1930 mono_test_marshal_amd64_pass_return_struct2 (amd64_struct2 s
)
1938 typedef struct amd64_struct3
{
1942 LIBTEST_API amd64_struct3 STDCALL
1943 mono_test_marshal_amd64_pass_return_struct3 (amd64_struct3 s
)
1950 typedef struct amd64_struct4
{
1954 LIBTEST_API amd64_struct4 STDCALL
1955 mono_test_marshal_amd64_pass_return_struct4 (amd64_struct4 s
)
1964 * IA64 marshalling tests.
1966 typedef struct test_struct5
{
1970 LIBTEST_API test_struct5 STDCALL
1971 mono_test_marshal_ia64_pass_return_struct5 (double d1
, double d2
, test_struct5 s
, int i
, double d3
, double d4
)
1973 s
.d1
+= d1
+ d2
+ i
;
1974 s
.d2
+= d3
+ d4
+ i
;
1979 typedef struct test_struct6
{
1983 LIBTEST_API test_struct6 STDCALL
1984 mono_test_marshal_ia64_pass_return_struct6 (double d1
, double d2
, test_struct6 s
, int i
, double d3
, double d4
)
1986 s
.d1
+= d1
+ d2
+ i
;
1992 static guint32 custom_res
[2];
1994 LIBTEST_API
void* STDCALL
1995 mono_test_marshal_pass_return_custom (int i
, guint32
*ptr
, int j
)
1997 /* ptr will be freed by CleanupNative, so make a copy */
1998 custom_res
[0] = 0; /* not allocated by AllocHGlobal */
1999 custom_res
[1] = ptr
[1];
2004 LIBTEST_API
int STDCALL
2005 mono_test_marshal_pass_out_custom (int i
, guint32
**ptr
, int j
)
2008 custom_res
[1] = i
+ j
+ 10;
2015 LIBTEST_API
int STDCALL
2016 mono_test_marshal_pass_inout_custom (int i
, guint32
*ptr
, int j
)
2019 ptr
[1] = i
+ ptr
[1] + j
;
2024 LIBTEST_API
int STDCALL
2025 mono_test_marshal_pass_out_byval_custom (int i
, guint32
*ptr
, int j
)
2027 return ptr
== NULL
? 0 : 1;
2030 LIBTEST_API
int STDCALL
2031 mono_test_marshal_pass_byref_custom (int i
, guint32
**ptr
, int j
)
2038 LIBTEST_API
void* STDCALL
2039 mono_test_marshal_pass_return_custom2 (int i
, guint32
*ptr
, int j
)
2041 g_assert_not_reached ();
2046 LIBTEST_API
void* STDCALL
2047 mono_test_marshal_pass_return_custom_null (int i
, guint32
*ptr
, int j
)
2049 g_assert (ptr
== NULL
);
2054 typedef void *(STDCALL
*PassReturnPtrDelegate
) (void *ptr
);
2056 LIBTEST_API
int STDCALL
2057 mono_test_marshal_pass_return_custom_in_delegate (PassReturnPtrDelegate del
)
2066 ptr
= (guint32
*)del (&buf
);
2071 /* FIXME: Freed with FreeHGlobal */
2079 LIBTEST_API
int STDCALL
2080 mono_test_marshal_pass_return_custom_null_in_delegate (PassReturnPtrDelegate del
)
2082 void *ptr
= del (NULL
);
2084 return (ptr
== NULL
) ? 15 : 0;
2087 typedef void (STDCALL
*CustomOutParamDelegate
) (void **pptr
);
2089 LIBTEST_API
int STDCALL
2090 mono_test_marshal_custom_out_param_delegate (CustomOutParamDelegate del
)
2092 void* pptr
= (void*)del
;
2102 typedef int (STDCALL
*ReturnEnumDelegate
) (int e
);
2104 LIBTEST_API
int STDCALL
2105 mono_test_marshal_return_enum_delegate (ReturnEnumDelegate func
)
2115 typedef BlittableStruct (STDCALL
*SimpleDelegate10
) (BlittableStruct ss
);
2117 LIBTEST_API
int STDCALL
2118 mono_test_marshal_blittable_struct_delegate (SimpleDelegate10 delegate
)
2120 BlittableStruct ss
, res
;
2127 res
= delegate (ss
);
2128 if (! ((res
.a
== -1) && (res
.b
== -2) && (res
.c
== -3) && (res
.d
== -55)))
2134 LIBTEST_API
int STDCALL
2135 mono_test_stdcall_name_mangling (int a
, int b
, int c
)
2141 mono_test_stdcall_mismatch_1 (int a
, int b
, int c
)
2146 LIBTEST_API
int STDCALL
2147 mono_test_stdcall_mismatch_2 (int a
, int b
, int c
)
2153 * PASSING AND RETURNING SMALL STRUCTURES FROM DELEGATES TESTS
2160 typedef SmallStruct1 (STDCALL
*SmallStructDelegate1
) (SmallStruct1 ss
);
2162 LIBTEST_API
int STDCALL
2163 mono_test_marshal_small_struct_delegate1 (SmallStructDelegate1 delegate
)
2165 SmallStruct1 ss
, res
;
2169 res
= delegate (ss
);
2170 if (! (res
.i
== -1))
2180 typedef SmallStruct2 (STDCALL
*SmallStructDelegate2
) (SmallStruct2 ss
);
2182 LIBTEST_API
int STDCALL
2183 mono_test_marshal_small_struct_delegate2 (SmallStructDelegate2 delegate
)
2185 SmallStruct2 ss
, res
;
2190 res
= delegate (ss
);
2191 if (! ((res
.i
== -2) && (res
.j
== -3)))
2202 typedef SmallStruct3 (STDCALL
*SmallStructDelegate3
) (SmallStruct3 ss
);
2204 LIBTEST_API
int STDCALL
2205 mono_test_marshal_small_struct_delegate3 (SmallStructDelegate3 delegate
)
2207 SmallStruct3 ss
, res
;
2212 res
= delegate (ss
);
2213 if (! ((res
.i
== -1) && (res
.j
== -2)))
2223 typedef SmallStruct4 (STDCALL
*SmallStructDelegate4
) (SmallStruct4 ss
);
2225 LIBTEST_API
int STDCALL
2226 mono_test_marshal_small_struct_delegate4 (SmallStructDelegate4 delegate
)
2228 SmallStruct4 ss
, res
;
2232 res
= delegate (ss
);
2233 if (! (res
.i
== -1))
2243 typedef SmallStruct5 (STDCALL
*SmallStructDelegate5
) (SmallStruct5 ss
);
2245 LIBTEST_API
int STDCALL
2246 mono_test_marshal_small_struct_delegate5 (SmallStructDelegate5 delegate
)
2248 SmallStruct5 ss
, res
;
2252 res
= delegate (ss
);
2253 if (! (res
.i
== -5))
2263 typedef SmallStruct6 (STDCALL
*SmallStructDelegate6
) (SmallStruct6 ss
);
2265 LIBTEST_API
int STDCALL
2266 mono_test_marshal_small_struct_delegate6 (SmallStructDelegate6 delegate
)
2268 SmallStruct6 ss
, res
;
2273 res
= delegate (ss
);
2274 if (! ((res
.i
== -1) && (res
.j
== -2)))
2285 typedef SmallStruct7 (STDCALL
*SmallStructDelegate7
) (SmallStruct7 ss
);
2287 LIBTEST_API
int STDCALL
2288 mono_test_marshal_small_struct_delegate7 (SmallStructDelegate7 delegate
)
2290 SmallStruct7 ss
, res
;
2295 res
= delegate (ss
);
2296 if (! ((res
.i
== -1) && (res
.j
== -2)))
2306 typedef SmallStruct8 (STDCALL
*SmallStructDelegate8
) (SmallStruct8 ss
);
2308 LIBTEST_API
int STDCALL
2309 mono_test_marshal_small_struct_delegate8 (SmallStructDelegate8 delegate
)
2311 SmallStruct8 ss
, res
;
2315 res
= delegate (ss
);
2316 if (! ((res
.i
== -1.0)))
2326 typedef SmallStruct9 (STDCALL
*SmallStructDelegate9
) (SmallStruct9 ss
);
2328 LIBTEST_API
int STDCALL
2329 mono_test_marshal_small_struct_delegate9 (SmallStructDelegate9 delegate
)
2331 SmallStruct9 ss
, res
;
2335 res
= delegate (ss
);
2336 if (! ((res
.i
== -1.0)))
2346 typedef SmallStruct10 (STDCALL
*SmallStructDelegate10
) (SmallStruct10 ss
);
2348 LIBTEST_API
int STDCALL
2349 mono_test_marshal_small_struct_delegate10 (SmallStructDelegate10 delegate
)
2351 SmallStruct10 ss
, res
;
2356 res
= delegate (ss
);
2357 if (! ((res
.i
== -1.0) && (res
.j
== -2.0)))
2368 typedef SmallStruct11 (STDCALL
*SmallStructDelegate11
) (SmallStruct11 ss
);
2370 LIBTEST_API
int STDCALL
2371 mono_test_marshal_small_struct_delegate11 (SmallStructDelegate11 delegate
)
2373 SmallStruct11 ss
, res
;
2378 res
= delegate (ss
);
2379 if (! ((res
.i
== -1.0) && (res
.j
== -2)))
2385 typedef int (STDCALL
*ArrayDelegate
) (int i
, char *j
, void *arr
);
2387 LIBTEST_API
int STDCALL
2388 mono_test_marshal_array_delegate (void *arr
, int len
, ArrayDelegate del
)
2390 return del (len
, NULL
, arr
);
2393 typedef int (STDCALL
*ArrayDelegateLong
) (gint64 i
, char *j
, void *arr
);
2395 LIBTEST_API
int STDCALL
2396 mono_test_marshal_array_delegate_long (void *arr
, gint64 len
, ArrayDelegateLong del
)
2398 return del (len
, NULL
, arr
);
2401 LIBTEST_API
int STDCALL
2402 mono_test_marshal_out_array_delegate (int *arr
, int len
, ArrayDelegate del
)
2404 del (len
, NULL
, arr
);
2406 if ((arr
[0] != 1) || (arr
[1] != 2))
2412 typedef gunichar2
* (STDCALL
*UnicodeStringDelegate
) (gunichar2
*message
);
2414 LIBTEST_API
int STDCALL
2415 mono_test_marshal_return_unicode_string_delegate (UnicodeStringDelegate del
)
2417 const char m
[] = "abcdef";
2418 gunichar2
*s2
, *res
;
2421 s2
= g_utf8_to_utf16 (m
, -1, NULL
, &len
, NULL
);
2430 LIBTEST_API
int STDCALL
2431 mono_test_marshal_out_string_array_delegate (char **arr
, int len
, ArrayDelegate del
)
2433 del (len
, NULL
, arr
);
2435 if (!strcmp (arr
[0], "ABC") && !strcmp (arr
[1], "DEF"))
2441 typedef int (*CdeclDelegate
) (int i
, int j
);
2443 LIBTEST_API
int STDCALL
2444 mono_test_marshal_cdecl_delegate (CdeclDelegate del
)
2448 for (i
= 0; i
< 1000; ++i
)
2454 typedef char** (STDCALL
*ReturnStringArrayDelegate
) (int i
);
2456 LIBTEST_API
int STDCALL
2457 mono_test_marshal_return_string_array_delegate (ReturnStringArrayDelegate d
)
2465 if (strcmp (arr
[0], "ABC") || strcmp (arr
[1], "DEF"))
2475 typedef int (STDCALL
*ByrefStringDelegate
) (char **s
);
2477 LIBTEST_API
int STDCALL
2478 mono_test_marshal_byref_string_delegate (ByrefStringDelegate d
)
2480 char *s
= (char*)"ABC";
2487 if (!strcmp (s
, "DEF"))
2497 LIBTEST_API
int STDCALL
2498 add_delegate (int i
, int j
)
2503 LIBTEST_API gpointer STDCALL
2504 mono_test_marshal_return_fnptr (void)
2506 return (gpointer
)&add_delegate
;
2509 LIBTEST_API
int STDCALL
2512 printf ("codigo %x\n", code
);
2520 LIBTEST_API HandleRef STDCALL
2521 mono_xr_as_handle (int code
)
2525 memset (&ref
, 0, sizeof (ref
));
2537 LIBTEST_API
int STDCALL
2538 mono_safe_handle_struct_ref (HandleStructs
*x
)
2540 printf ("Dingus Ref! \n");
2541 printf ("Values: %d %d %p %p\n", x
->a
, x
->b
, x
->handle1
, x
->handle2
);
2547 if (x
->handle1
!= (void*) 0x7080feed)
2550 if (x
->handle2
!= (void*) 0x1234abcd)
2556 LIBTEST_API
int STDCALL
2557 mono_safe_handle_struct (HandleStructs x
)
2559 printf ("Dingus Standard! \n");
2560 printf ("Values: %d %d %p %p\n", x
.a
, x
.b
, x
.handle1
, x
.handle2
);
2566 if (x
.handle1
!= (void*) 0x7080feed)
2569 if (x
.handle2
!= (void*) 0x1234abcd)
2579 LIBTEST_API
int STDCALL
2580 mono_safe_handle_struct_simple (TrivialHandle x
)
2582 printf ("The value is %p\n", x
.a
);
2583 return ((int)(gsize
)x
.a
) * 2;
2586 LIBTEST_API
int STDCALL
2587 mono_safe_handle_return (void)
2592 LIBTEST_API
void STDCALL
2593 mono_safe_handle_ref (void **handle
)
2596 *handle
= (void *) 0x800d;
2600 *handle
= (void *) 0xbad;
2603 LIBTEST_API
void* STDCALL
2604 mono_safe_handle_ref_nomod (void **handle
)
2609 LIBTEST_API
double STDCALL
2610 mono_test_marshal_date_time (double d
, double *d2
)
2682 VT_USERDEFINED
= 29,
2690 VT_STREAMED_OBJECT
= 68,
2691 VT_STORED_OBJECT
= 69,
2692 VT_BLOB_OBJECT
= 70,
2700 void VariantInit(VARIANT
* vt
)
2717 LIBTEST_API
int STDCALL
2718 mono_test_marshal_bstr_in(gunichar2
* bstr
)
2721 gchar
* bstr_utf8
= g_utf16_to_utf8 (bstr
, -1, NULL
, NULL
, NULL
);
2722 result
= strcmp("mono_test_marshal_bstr_in", bstr_utf8
);
2729 LIBTEST_API
int STDCALL
2730 mono_test_marshal_bstr_out(gunichar2
** bstr
)
2732 *bstr
= marshal_bstr_alloc ("mono_test_marshal_bstr_out");
2736 LIBTEST_API
int STDCALL
2737 mono_test_marshal_bstr_in_null(gunichar2
* bstr
)
2744 LIBTEST_API
int STDCALL
2745 mono_test_marshal_bstr_out_null(gunichar2
** bstr
)
2751 LIBTEST_API
int STDCALL
2752 mono_test_marshal_variant_in_sbyte(VARIANT variant
)
2754 if (variant
.vt
== VT_I1
&& variant
.cVal
== 100)
2759 LIBTEST_API
int STDCALL
2760 mono_test_marshal_variant_in_byte(VARIANT variant
)
2762 if (variant
.vt
== VT_UI1
&& variant
.bVal
== 100)
2767 LIBTEST_API
int STDCALL
2768 mono_test_marshal_variant_in_short(VARIANT variant
)
2770 if (variant
.vt
== VT_I2
&& variant
.iVal
== 314)
2775 LIBTEST_API
int STDCALL
2776 mono_test_marshal_variant_in_ushort(VARIANT variant
)
2778 if (variant
.vt
== VT_UI2
&& variant
.uiVal
== 314)
2783 LIBTEST_API
int STDCALL
2784 mono_test_marshal_variant_in_int(VARIANT variant
)
2786 if (variant
.vt
== VT_I4
&& variant
.lVal
== 314)
2791 LIBTEST_API
int STDCALL
2792 mono_test_marshal_variant_in_uint(VARIANT variant
)
2794 if (variant
.vt
== VT_UI4
&& variant
.ulVal
== 314)
2799 LIBTEST_API
int STDCALL
2800 mono_test_marshal_variant_in_long(VARIANT variant
)
2802 if (variant
.vt
== VT_I8
&& variant
.llVal
== 314)
2807 LIBTEST_API
int STDCALL
2808 mono_test_marshal_variant_in_ulong(VARIANT variant
)
2810 if (variant
.vt
== VT_UI8
&& variant
.ullVal
== 314)
2815 LIBTEST_API
int STDCALL
2816 mono_test_marshal_variant_in_float(VARIANT variant
)
2818 if (variant
.vt
== VT_R4
&& (variant
.fltVal
- 3.14)/3.14 < .001)
2823 LIBTEST_API
int STDCALL
2824 mono_test_marshal_variant_in_double(VARIANT variant
)
2826 if (variant
.vt
== VT_R8
&& (variant
.dblVal
- 3.14)/3.14 < .001)
2831 LIBTEST_API
int STDCALL
2832 mono_test_marshal_variant_in_bstr(VARIANT variant
)
2835 gchar
* bstr_utf8
= g_utf16_to_utf8 (variant
.bstrVal
, -1, NULL
, NULL
, NULL
);
2836 result
= strcmp("PI", bstr_utf8
);
2839 if (variant
.vt
== VT_BSTR
&& !result
)
2844 LIBTEST_API
int STDCALL
2845 mono_test_marshal_variant_in_bool_true (VARIANT variant
)
2847 if (variant
.vt
== VT_BOOL
&& variant
.boolVal
== VARIANT_TRUE
)
2852 LIBTEST_API
int STDCALL
2853 mono_test_marshal_variant_in_bool_false (VARIANT variant
)
2855 if (variant
.vt
== VT_BOOL
&& variant
.boolVal
== VARIANT_FALSE
)
2860 LIBTEST_API
int STDCALL
2861 mono_test_marshal_variant_out_sbyte(VARIANT
* variant
)
2863 variant
->vt
= VT_I1
;
2864 variant
->cVal
= 100;
2869 LIBTEST_API
int STDCALL
2870 mono_test_marshal_variant_out_sbyte_byref(VARIANT
* variant
)
2872 variant
->vt
= VT_I1
|VT_BYREF
;
2873 variant
->byref
= marshal_alloc(1);
2874 *((gint8
*)variant
->byref
) = 100;
2879 LIBTEST_API
int STDCALL
2880 mono_test_marshal_variant_out_byte(VARIANT
* variant
)
2882 variant
->vt
= VT_UI1
;
2883 variant
->bVal
= 100;
2888 LIBTEST_API
int STDCALL
2889 mono_test_marshal_variant_out_byte_byref(VARIANT
* variant
)
2891 variant
->vt
= VT_UI1
|VT_BYREF
;
2892 variant
->byref
= marshal_alloc(1);
2893 *((gint8
*)variant
->byref
) = 100;
2898 LIBTEST_API
int STDCALL
2899 mono_test_marshal_variant_out_short(VARIANT
* variant
)
2901 variant
->vt
= VT_I2
;
2902 variant
->iVal
= 314;
2907 LIBTEST_API
int STDCALL
2908 mono_test_marshal_variant_out_short_byref(VARIANT
* variant
)
2910 variant
->vt
= VT_I2
|VT_BYREF
;
2911 variant
->byref
= marshal_alloc(2);
2912 *((gint16
*)variant
->byref
) = 314;
2917 LIBTEST_API
int STDCALL
2918 mono_test_marshal_variant_out_ushort(VARIANT
* variant
)
2920 variant
->vt
= VT_UI2
;
2921 variant
->uiVal
= 314;
2926 LIBTEST_API
int STDCALL
2927 mono_test_marshal_variant_out_ushort_byref(VARIANT
* variant
)
2929 variant
->vt
= VT_UI2
|VT_BYREF
;
2930 variant
->byref
= marshal_alloc(2);
2931 *((guint16
*)variant
->byref
) = 314;
2936 LIBTEST_API
int STDCALL
2937 mono_test_marshal_variant_out_int(VARIANT
* variant
)
2939 variant
->vt
= VT_I4
;
2940 variant
->lVal
= 314;
2945 LIBTEST_API
int STDCALL
2946 mono_test_marshal_variant_out_int_byref(VARIANT
* variant
)
2948 variant
->vt
= VT_I4
|VT_BYREF
;
2949 variant
->byref
= marshal_alloc(4);
2950 *((gint32
*)variant
->byref
) = 314;
2955 LIBTEST_API
int STDCALL
2956 mono_test_marshal_variant_out_uint(VARIANT
* variant
)
2958 variant
->vt
= VT_UI4
;
2959 variant
->ulVal
= 314;
2964 LIBTEST_API
int STDCALL
2965 mono_test_marshal_variant_out_uint_byref(VARIANT
* variant
)
2967 variant
->vt
= VT_UI4
|VT_BYREF
;
2968 variant
->byref
= marshal_alloc(4);
2969 *((guint32
*)variant
->byref
) = 314;
2974 LIBTEST_API
int STDCALL
2975 mono_test_marshal_variant_out_long(VARIANT
* variant
)
2977 variant
->vt
= VT_I8
;
2978 variant
->llVal
= 314;
2983 LIBTEST_API
int STDCALL
2984 mono_test_marshal_variant_out_long_byref(VARIANT
* variant
)
2986 variant
->vt
= VT_I8
|VT_BYREF
;
2987 variant
->byref
= marshal_alloc(8);
2988 *((gint64
*)variant
->byref
) = 314;
2993 LIBTEST_API
int STDCALL
2994 mono_test_marshal_variant_out_ulong(VARIANT
* variant
)
2996 variant
->vt
= VT_UI8
;
2997 variant
->ullVal
= 314;
3002 LIBTEST_API
int STDCALL
3003 mono_test_marshal_variant_out_ulong_byref(VARIANT
* variant
)
3005 variant
->vt
= VT_UI8
|VT_BYREF
;
3006 variant
->byref
= marshal_alloc(8);
3007 *((guint64
*)variant
->byref
) = 314;
3012 LIBTEST_API
int STDCALL
3013 mono_test_marshal_variant_out_float(VARIANT
* variant
)
3015 variant
->vt
= VT_R4
;
3016 variant
->fltVal
= 3.14;
3021 LIBTEST_API
int STDCALL
3022 mono_test_marshal_variant_out_float_byref(VARIANT
* variant
)
3024 variant
->vt
= VT_R4
|VT_BYREF
;
3025 variant
->byref
= marshal_alloc(4);
3026 *((float*)variant
->byref
) = 3.14;
3031 LIBTEST_API
int STDCALL
3032 mono_test_marshal_variant_out_double(VARIANT
* variant
)
3034 variant
->vt
= VT_R8
;
3035 variant
->dblVal
= 3.14;
3040 LIBTEST_API
int STDCALL
3041 mono_test_marshal_variant_out_double_byref(VARIANT
* variant
)
3043 variant
->vt
= VT_R8
|VT_BYREF
;
3044 variant
->byref
= marshal_alloc(8);
3045 *((double*)variant
->byref
) = 3.14;
3050 LIBTEST_API
int STDCALL
3051 mono_test_marshal_variant_out_bstr(VARIANT
* variant
)
3053 variant
->vt
= VT_BSTR
;
3054 variant
->bstrVal
= marshal_bstr_alloc("PI");
3059 LIBTEST_API
int STDCALL
3060 mono_test_marshal_variant_out_bstr_byref(VARIANT
* variant
)
3062 variant
->vt
= VT_BSTR
|VT_BYREF
;
3063 variant
->byref
= marshal_alloc(sizeof(gpointer
));
3064 *((gunichar
**)variant
->byref
) = (gunichar
*)marshal_bstr_alloc("PI");
3069 LIBTEST_API
int STDCALL
3070 mono_test_marshal_variant_out_bool_true (VARIANT
* variant
)
3072 variant
->vt
= VT_BOOL
;
3073 variant
->boolVal
= VARIANT_TRUE
;
3078 LIBTEST_API
int STDCALL
3079 mono_test_marshal_variant_out_bool_true_byref (VARIANT
* variant
)
3081 variant
->vt
= VT_BOOL
|VT_BYREF
;
3082 variant
->byref
= marshal_alloc(2);
3083 *((gint16
*)variant
->byref
) = VARIANT_TRUE
;
3088 LIBTEST_API
int STDCALL
3089 mono_test_marshal_variant_out_bool_false (VARIANT
* variant
)
3091 variant
->vt
= VT_BOOL
;
3092 variant
->boolVal
= VARIANT_FALSE
;
3097 LIBTEST_API
int STDCALL
3098 mono_test_marshal_variant_out_bool_false_byref (VARIANT
* variant
)
3100 variant
->vt
= VT_BOOL
|VT_BYREF
;
3101 variant
->byref
= marshal_alloc(2);
3102 *((gint16
*)variant
->byref
) = VARIANT_FALSE
;
3107 typedef int (STDCALL
*VarFunc
) (int vt
, VARIANT variant
);
3108 typedef int (STDCALL
*VarRefFunc
) (int vt
, VARIANT
* variant
);
3110 LIBTEST_API
int STDCALL
3111 mono_test_marshal_variant_in_sbyte_unmanaged(VarFunc func
)
3116 return func (VT_I1
, vt
);
3119 LIBTEST_API
int STDCALL
3120 mono_test_marshal_variant_in_byte_unmanaged(VarFunc func
)
3125 return func (VT_UI1
, vt
);
3128 LIBTEST_API
int STDCALL
3129 mono_test_marshal_variant_in_short_unmanaged(VarFunc func
)
3134 return func (VT_I2
, vt
);
3137 LIBTEST_API
int STDCALL
3138 mono_test_marshal_variant_in_ushort_unmanaged(VarFunc func
)
3143 return func (VT_UI2
, vt
);
3146 LIBTEST_API
int STDCALL
3147 mono_test_marshal_variant_in_int_unmanaged(VarFunc func
)
3152 return func (VT_I4
, vt
);
3155 LIBTEST_API
int STDCALL
3156 mono_test_marshal_variant_in_uint_unmanaged(VarFunc func
)
3161 return func (VT_UI4
, vt
);
3164 LIBTEST_API
int STDCALL
3165 mono_test_marshal_variant_in_long_unmanaged(VarFunc func
)
3170 return func (VT_I8
, vt
);
3173 LIBTEST_API
int STDCALL
3174 mono_test_marshal_variant_in_ulong_unmanaged(VarFunc func
)
3179 return func (VT_UI8
, vt
);
3182 LIBTEST_API
int STDCALL
3183 mono_test_marshal_variant_in_float_unmanaged(VarFunc func
)
3188 return func (VT_R4
, vt
);
3191 LIBTEST_API
int STDCALL
3192 mono_test_marshal_variant_in_double_unmanaged(VarFunc func
)
3197 return func (VT_R8
, vt
);
3200 LIBTEST_API
int STDCALL
3201 mono_test_marshal_variant_in_bstr_unmanaged(VarFunc func
)
3205 vt
.bstrVal
= marshal_bstr_alloc("PI");
3206 return func (VT_BSTR
, vt
);
3209 LIBTEST_API
int STDCALL
3210 mono_test_marshal_variant_in_bool_true_unmanaged(VarFunc func
)
3214 vt
.boolVal
= VARIANT_TRUE
;
3215 return func (VT_BOOL
, vt
);
3218 LIBTEST_API
int STDCALL
3219 mono_test_marshal_variant_in_bool_false_unmanaged(VarFunc func
)
3223 vt
.boolVal
= VARIANT_FALSE
;
3224 return func (VT_BOOL
, vt
);
3227 LIBTEST_API
int STDCALL
3228 mono_test_marshal_variant_out_sbyte_unmanaged(VarRefFunc func
)
3233 if (vt
.vt
== VT_I1
&& vt
.cVal
== -100)
3238 LIBTEST_API
int STDCALL
3239 mono_test_marshal_variant_out_byte_unmanaged(VarRefFunc func
)
3244 if (vt
.vt
== VT_UI1
&& vt
.bVal
== 100)
3249 LIBTEST_API
int STDCALL
3250 mono_test_marshal_variant_out_short_unmanaged(VarRefFunc func
)
3255 if (vt
.vt
== VT_I2
&& vt
.iVal
== -100)
3260 LIBTEST_API
int STDCALL
3261 mono_test_marshal_variant_out_ushort_unmanaged(VarRefFunc func
)
3266 if (vt
.vt
== VT_UI2
&& vt
.uiVal
== 100)
3271 LIBTEST_API
int STDCALL
3272 mono_test_marshal_variant_out_int_unmanaged(VarRefFunc func
)
3277 if (vt
.vt
== VT_I4
&& vt
.lVal
== -100)
3282 LIBTEST_API
int STDCALL
3283 mono_test_marshal_variant_out_uint_unmanaged(VarRefFunc func
)
3288 if (vt
.vt
== VT_UI4
&& vt
.ulVal
== 100)
3293 LIBTEST_API
int STDCALL
3294 mono_test_marshal_variant_out_long_unmanaged(VarRefFunc func
)
3299 if (vt
.vt
== VT_I8
&& vt
.llVal
== -100)
3304 LIBTEST_API
int STDCALL
3305 mono_test_marshal_variant_out_ulong_unmanaged(VarRefFunc func
)
3310 if (vt
.vt
== VT_UI8
&& vt
.ullVal
== 100)
3315 LIBTEST_API
int STDCALL
3316 mono_test_marshal_variant_out_float_unmanaged(VarRefFunc func
)
3321 if (vt
.vt
== VT_R4
&& fabs (vt
.fltVal
- 3.14f
) < 1e-10)
3326 LIBTEST_API
int STDCALL
3327 mono_test_marshal_variant_out_double_unmanaged(VarRefFunc func
)
3332 if (vt
.vt
== VT_R8
&& fabs (vt
.dblVal
- 3.14) < 1e-10)
3337 LIBTEST_API
int STDCALL
3338 mono_test_marshal_variant_out_bstr_unmanaged(VarRefFunc func
)
3346 func (VT_BSTR
, &vt
);
3347 bstr_utf8
= g_utf16_to_utf8 (vt
.bstrVal
, -1, NULL
, NULL
, NULL
);
3348 result
= strcmp("PI", bstr_utf8
);
3350 if (vt
.vt
== VT_BSTR
&& !result
)
3355 LIBTEST_API
int STDCALL
3356 mono_test_marshal_variant_out_bool_true_unmanaged(VarRefFunc func
)
3360 func (VT_BOOL
, &vt
);
3361 if (vt
.vt
== VT_BOOL
&& vt
.boolVal
== VARIANT_TRUE
)
3366 LIBTEST_API
int STDCALL
3367 mono_test_marshal_variant_out_bool_false_unmanaged(VarRefFunc func
)
3371 func (VT_BOOL
, &vt
);
3372 if (vt
.vt
== VT_BOOL
&& vt
.boolVal
== VARIANT_TRUE
)
3377 typedef struct MonoComObject MonoComObject
;
3378 typedef struct MonoDefItfObject MonoDefItfObject
;
3382 int (STDCALL
*QueryInterface
)(MonoDefItfObject
* pUnk
, gpointer riid
, gpointer
* ppv
);
3383 int (STDCALL
*AddRef
)(MonoDefItfObject
* pUnk
);
3384 int (STDCALL
*Release
)(MonoDefItfObject
* pUnk
);
3385 int (STDCALL
*Method
)(MonoDefItfObject
* pUnk
, int *value
);
3390 int (STDCALL
*QueryInterface
)(MonoComObject
* pUnk
, gpointer riid
, gpointer
* ppv
);
3391 int (STDCALL
*AddRef
)(MonoComObject
* pUnk
);
3392 int (STDCALL
*Release
)(MonoComObject
* pUnk
);
3393 int (STDCALL
*get_ITest
)(MonoComObject
* pUnk
, MonoComObject
* *ppUnk
);
3394 int (STDCALL
*SByteIn
)(MonoComObject
* pUnk
, char a
);
3395 int (STDCALL
*ByteIn
)(MonoComObject
* pUnk
, unsigned char a
);
3396 int (STDCALL
*ShortIn
)(MonoComObject
* pUnk
, short a
);
3397 int (STDCALL
*UShortIn
)(MonoComObject
* pUnk
, unsigned short a
);
3398 int (STDCALL
*IntIn
)(MonoComObject
* pUnk
, int a
);
3399 int (STDCALL
*UIntIn
)(MonoComObject
* pUnk
, unsigned int a
);
3400 int (STDCALL
*LongIn
)(MonoComObject
* pUnk
, gint64 a
);
3401 int (STDCALL
*ULongIn
)(MonoComObject
* pUnk
, guint64 a
);
3402 int (STDCALL
*FloatIn
)(MonoComObject
* pUnk
, float a
);
3403 int (STDCALL
*DoubleIn
)(MonoComObject
* pUnk
, double a
);
3404 int (STDCALL
*ITestIn
)(MonoComObject
* pUnk
, MonoComObject
* pUnk2
);
3405 int (STDCALL
*ITestOut
)(MonoComObject
* pUnk
, MonoComObject
* *ppUnk
);
3406 int (STDCALL
*Return22NoICall
)(MonoComObject
* pUnk
);
3407 int (STDCALL
*IntOut
)(MonoComObject
* pUnk
, int *a
);
3408 int (STDCALL
*ArrayIn
)(MonoComObject
* pUnk
, void *array
);
3409 int (STDCALL
*ArrayIn2
)(MonoComObject
* pUnk
, void *array
);
3410 int (STDCALL
*ArrayIn3
)(MonoComObject
* pUnk
, void *array
);
3411 int (STDCALL
*GetDefInterface1
)(MonoComObject
* pUnk
, MonoDefItfObject
**iface
);
3412 int (STDCALL
*GetDefInterface2
)(MonoComObject
* pUnk
, MonoDefItfObject
**iface
);
3415 struct MonoComObject
3421 struct MonoDefItfObject
3426 static GUID IID_ITest
= {0, 0, 0, {0,0,0,0,0,0,0,1}};
3427 static GUID IID_IMonoUnknown
= {0, 0, 0, {0xc0,0,0,0,0,0,0,0x46}};
3428 static GUID IID_IMonoDispatch
= {0x00020400, 0, 0, {0xc0,0,0,0,0,0,0,0x46}};
3429 static GUID IID_INotImplemented
= {0x12345678, 0, 0, {0x9a, 0xbc, 0xde, 0xf0, 0, 0, 0, 0}};
3431 LIBTEST_API
int STDCALL
3432 MonoQueryInterface(MonoComObject
* pUnk
, gpointer riid
, gpointer
* ppv
)
3436 if (!memcmp(riid
, &IID_IMonoUnknown
, sizeof(GUID
))) {
3440 else if (!memcmp(riid
, &IID_ITest
, sizeof(GUID
))) {
3444 else if (!memcmp(riid
, &IID_IMonoDispatch
, sizeof(GUID
))) {
3448 return 0x80004002; //E_NOINTERFACE;
3451 LIBTEST_API
int STDCALL
3452 MonoAddRef(MonoComObject
* pUnk
)
3454 return ++(pUnk
->m_ref
);
3457 LIBTEST_API
int STDCALL
3458 MonoRelease(MonoComObject
* pUnk
)
3460 return --(pUnk
->m_ref
);
3463 LIBTEST_API
int STDCALL
3464 SByteIn(MonoComObject
* pUnk
, char a
)
3469 LIBTEST_API
int STDCALL
3470 ByteIn(MonoComObject
* pUnk
, unsigned char a
)
3475 LIBTEST_API
int STDCALL
3476 ShortIn(MonoComObject
* pUnk
, short a
)
3481 LIBTEST_API
int STDCALL
3482 UShortIn(MonoComObject
* pUnk
, unsigned short a
)
3487 LIBTEST_API
int STDCALL
3488 IntIn(MonoComObject
* pUnk
, int a
)
3493 LIBTEST_API
int STDCALL
3494 UIntIn(MonoComObject
* pUnk
, unsigned int a
)
3499 LIBTEST_API
int STDCALL
3500 LongIn(MonoComObject
* pUnk
, gint64 a
)
3505 LIBTEST_API
int STDCALL
3506 ULongIn(MonoComObject
* pUnk
, guint64 a
)
3511 LIBTEST_API
int STDCALL
3512 FloatIn(MonoComObject
* pUnk
, float a
)
3517 LIBTEST_API
int STDCALL
3518 DoubleIn(MonoComObject
* pUnk
, double a
)
3523 LIBTEST_API
int STDCALL
3524 ITestIn(MonoComObject
* pUnk
, MonoComObject
*pUnk2
)
3529 LIBTEST_API
int STDCALL
3530 ITestOut(MonoComObject
* pUnk
, MonoComObject
* *ppUnk
)
3535 LIBTEST_API
int STDCALL
3536 Return22NoICall(MonoComObject
* pUnk
)
3541 LIBTEST_API
int STDCALL
3542 IntOut(MonoComObject
* pUnk
, int *a
)
3547 LIBTEST_API
int STDCALL
3548 ArrayIn(MonoComObject
* pUnk
, void *array
)
3553 LIBTEST_API
int STDCALL
3554 ArrayIn2(MonoComObject
* pUnk
, void *array
)
3559 LIBTEST_API
int STDCALL
3560 ArrayIn3(MonoComObject
* pUnk
, void *array
)
3565 LIBTEST_API
int STDCALL
3566 GetDefInterface1(MonoComObject
* pUnk
, MonoDefItfObject
**obj
)
3571 LIBTEST_API
int STDCALL
3572 GetDefInterface2(MonoComObject
* pUnk
, MonoDefItfObject
**obj
)
3577 static void create_com_object (MonoComObject
** pOut
);
3579 LIBTEST_API
int STDCALL
3580 get_ITest(MonoComObject
* pUnk
, MonoComObject
* *ppUnk
)
3582 create_com_object (ppUnk
);
3586 static void create_com_object (MonoComObject
** pOut
)
3588 *pOut
= marshal_new0 (MonoComObject
, 1);
3589 (*pOut
)->vtbl
= marshal_new0 (MonoIUnknown
, 1);
3592 (*pOut
)->vtbl
->QueryInterface
= MonoQueryInterface
;
3593 (*pOut
)->vtbl
->AddRef
= MonoAddRef
;
3594 (*pOut
)->vtbl
->Release
= MonoRelease
;
3595 (*pOut
)->vtbl
->SByteIn
= SByteIn
;
3596 (*pOut
)->vtbl
->ByteIn
= ByteIn
;
3597 (*pOut
)->vtbl
->ShortIn
= ShortIn
;
3598 (*pOut
)->vtbl
->UShortIn
= UShortIn
;
3599 (*pOut
)->vtbl
->IntIn
= IntIn
;
3600 (*pOut
)->vtbl
->UIntIn
= UIntIn
;
3601 (*pOut
)->vtbl
->LongIn
= LongIn
;
3602 (*pOut
)->vtbl
->ULongIn
= ULongIn
;
3603 (*pOut
)->vtbl
->FloatIn
= FloatIn
;
3604 (*pOut
)->vtbl
->DoubleIn
= DoubleIn
;
3605 (*pOut
)->vtbl
->ITestIn
= ITestIn
;
3606 (*pOut
)->vtbl
->ITestOut
= ITestOut
;
3607 (*pOut
)->vtbl
->get_ITest
= get_ITest
;
3608 (*pOut
)->vtbl
->Return22NoICall
= Return22NoICall
;
3609 (*pOut
)->vtbl
->IntOut
= IntOut
;
3610 (*pOut
)->vtbl
->ArrayIn
= ArrayIn
;
3611 (*pOut
)->vtbl
->ArrayIn2
= ArrayIn2
;
3612 (*pOut
)->vtbl
->ArrayIn3
= ArrayIn3
;
3613 (*pOut
)->vtbl
->GetDefInterface1
= GetDefInterface1
;
3614 (*pOut
)->vtbl
->GetDefInterface2
= GetDefInterface2
;
3617 static MonoComObject
* same_object
= NULL
;
3619 LIBTEST_API
int STDCALL
3620 mono_test_marshal_com_object_create(MonoComObject
* *pUnk
)
3622 create_com_object (pUnk
);
3625 same_object
= *pUnk
;
3630 LIBTEST_API
int STDCALL
3631 mono_test_marshal_com_object_same(MonoComObject
* *pUnk
)
3633 *pUnk
= same_object
;
3638 LIBTEST_API
int STDCALL
3639 mono_test_marshal_com_object_destroy(MonoComObject
*pUnk
)
3641 int ref
= --(pUnk
->m_ref
);
3648 LIBTEST_API
int STDCALL
3649 mono_test_marshal_com_object_ref_count(MonoComObject
*pUnk
)
3654 LIBTEST_API
int STDCALL
3655 mono_test_marshal_ccw_itest (MonoComObject
*pUnk
)
3658 MonoComObject
* pTest
;
3663 hr
= pUnk
->vtbl
->SByteIn (pUnk
, -100);
3666 hr
= pUnk
->vtbl
->ByteIn (pUnk
, 100);
3669 hr
= pUnk
->vtbl
->ShortIn (pUnk
, -100);
3672 hr
= pUnk
->vtbl
->UShortIn (pUnk
, 100);
3675 hr
= pUnk
->vtbl
->IntIn (pUnk
, -100);
3678 hr
= pUnk
->vtbl
->UIntIn (pUnk
, 100);
3681 hr
= pUnk
->vtbl
->LongIn (pUnk
, -100);
3684 hr
= pUnk
->vtbl
->ULongIn (pUnk
, 100);
3687 hr
= pUnk
->vtbl
->FloatIn (pUnk
, 3.14f
);
3690 hr
= pUnk
->vtbl
->DoubleIn (pUnk
, 3.14);
3693 hr
= pUnk
->vtbl
->ITestIn (pUnk
, pUnk
);
3696 hr
= pUnk
->vtbl
->ITestOut (pUnk
, &pTest
);
3704 LIBTEST_API
int STDCALL
3705 mono_test_marshal_array_ccw_itest (int count
, MonoComObject
** ppUnk
)
3718 hr
= ppUnk
[0]->vtbl
->SByteIn (ppUnk
[0], -100);
3725 LIBTEST_API
int STDCALL
3726 mono_test_marshal_retval_ccw_itest (MonoComObject
*pUnk
, int test_null
)
3733 hr
= pUnk
->vtbl
->IntOut (pUnk
, &i
);
3740 hr
= pUnk
->vtbl
->IntOut (pUnk
, NULL
);
3748 LIBTEST_API
int STDCALL
3749 mono_test_default_interface_ccw (MonoComObject
*pUnk
)
3751 MonoDefItfObject
*obj
;
3754 ret
= pUnk
->vtbl
->GetDefInterface1(pUnk
, &obj
);
3759 ret
= obj
->vtbl
->Method(obj
, &value
);
3760 obj
->vtbl
->Release(obj
);
3766 ret
= pUnk
->vtbl
->GetDefInterface2(pUnk
, &obj
);
3769 ret
= obj
->vtbl
->Method(obj
, &value
);
3770 obj
->vtbl
->Release(obj
);
3780 * mono_method_get_unmanaged_thunk tests
3783 #if defined(__GNUC__) && ((defined(__i386__) && (defined(__linux__) || defined (__APPLE__)) || defined (__FreeBSD__) || defined(__OpenBSD__)) || (defined(__ppc__) && defined(__APPLE__)))
3784 #define ALIGN(size) __attribute__ ((__aligned__(size)))
3790 /* thunks.cs:TestStruct */
3791 typedef struct _TestStruct
{
3796 /* Searches for mono symbols in all loaded modules */
3798 lookup_mono_symbol (const char *symbol_name
)
3800 gpointer symbol
= NULL
;
3801 const gboolean success
= g_module_symbol (g_module_open (NULL
, G_MODULE_BIND_LAZY
), symbol_name
, &symbol
);
3802 g_assertf (success
, "%s", symbol_name
);
3803 return success
? symbol
: NULL
;
3806 LIBTEST_API gpointer STDCALL
3807 mono_test_marshal_lookup_symbol (const char *symbol_name
)
3809 return lookup_mono_symbol (symbol_name
);
3813 // FIXME use runtime headers
3814 #define MONO_BEGIN_EFRAME { void *__dummy; void *__region_cookie = mono_threads_enter_gc_unsafe_region ? mono_threads_enter_gc_unsafe_region (&__dummy) : NULL;
3815 #define MONO_END_EFRAME if (mono_threads_exit_gc_unsafe_region) mono_threads_exit_gc_unsafe_region (__region_cookie, &__dummy); }
3818 * test_method_thunk:
3820 * @test_id: the test number
3821 * @test_method_handle: MonoMethod* of the C# test method
3822 * @create_object_method_handle: MonoMethod* of thunks.cs:Test.CreateObject
3824 LIBTEST_API
int STDCALL
3825 test_method_thunk (int test_id
, gpointer test_method_handle
, gpointer create_object_method_handle
)
3829 // FIXME use runtime headers
3830 gpointer (*mono_method_get_unmanaged_thunk
)(gpointer
)
3831 = (gpointer (*)(gpointer
))lookup_mono_symbol ("mono_method_get_unmanaged_thunk");
3833 // FIXME use runtime headers
3834 gpointer (*mono_string_new_wrapper
)(const char *)
3835 = (gpointer (*)(const char *))lookup_mono_symbol ("mono_string_new_wrapper");
3837 // FIXME use runtime headers
3838 char *(*mono_string_to_utf8
)(gpointer
)
3839 = (char *(*)(gpointer
))lookup_mono_symbol ("mono_string_to_utf8");
3841 // FIXME use runtime headers
3842 gpointer (*mono_object_unbox
)(gpointer
)
3843 = (gpointer (*)(gpointer
))lookup_mono_symbol ("mono_object_unbox");
3845 // FIXME use runtime headers
3846 gpointer (*mono_threads_enter_gc_unsafe_region
) (gpointer
)
3847 = (gpointer (*)(gpointer
))lookup_mono_symbol ("mono_threads_enter_gc_unsafe_region");
3849 // FIXME use runtime headers
3850 void (*mono_threads_exit_gc_unsafe_region
) (gpointer
, gpointer
)
3851 = (void (*)(gpointer
, gpointer
))lookup_mono_symbol ("mono_threads_exit_gc_unsafe_region");
3855 gpointer test_method
, ex
= NULL
;
3856 gpointer (STDCALL
*CreateObject
)(gpointer
*);
3860 if (!mono_method_get_unmanaged_thunk
) {
3865 test_method
= mono_method_get_unmanaged_thunk (test_method_handle
);
3871 CreateObject
= (gpointer (STDCALL
*)(gpointer
*))mono_method_get_unmanaged_thunk (create_object_method_handle
);
3872 if (!CreateObject
) {
3881 /* thunks.cs:Test.Test0 */
3882 void (STDCALL
*F
)(gpointer
*) = (void (STDCALL
*)(gpointer
*))test_method
;
3888 /* thunks.cs:Test.Test1 */
3889 int (STDCALL
*F
)(gpointer
*) = (int (STDCALL
*)(gpointer
*))test_method
;
3890 if (F (&ex
) != 42) {
3898 /* thunks.cs:Test.Test2 */
3899 gpointer (STDCALL
*F
)(gpointer
, gpointer
*) = (gpointer (STDCALL
*)(gpointer
, gpointer
*))test_method
;
3900 gpointer str
= mono_string_new_wrapper ("foo");
3901 if (str
!= F (str
, &ex
)) {
3909 /* thunks.cs:Test.Test3 */
3910 gpointer (STDCALL
*F
)(gpointer
, gpointer
, gpointer
*);
3914 F
= (gpointer (STDCALL
*)(gpointer
, gpointer
, gpointer
*))test_method
;
3915 obj
= CreateObject (&ex
);
3916 str
= mono_string_new_wrapper ("bar");
3918 if (str
!= F (obj
, str
, &ex
)) {
3926 /* thunks.cs:Test.Test4 */
3927 int (STDCALL
*F
)(gpointer
, gpointer
, int, gpointer
*);
3931 F
= (int (STDCALL
*)(gpointer
, gpointer
, int, gpointer
*))test_method
;
3932 obj
= CreateObject (&ex
);
3933 str
= mono_string_new_wrapper ("bar");
3935 if (42 != F (obj
, str
, 42, &ex
)) {
3944 /* thunks.cs:Test.Test5 */
3945 int (STDCALL
*F
)(gpointer
, gpointer
, int, gpointer
*);
3949 F
= (int (STDCALL
*)(gpointer
, gpointer
, int, gpointer
*))test_method
;
3950 obj
= CreateObject (&ex
);
3951 str
= mono_string_new_wrapper ("bar");
3953 F (obj
, str
, 42, &ex
);
3963 /* thunks.cs:Test.Test6 */
3964 int (STDCALL
*F
)(gpointer
, guint8
, gint16
, gint32
, gint64
, float, double,
3965 gpointer
, gpointer
*);
3967 gpointer str
= mono_string_new_wrapper ("Test6");
3970 F
= (int (STDCALL
*)(gpointer
, guint8
, gint16
, gint32
, gint64
, float, double, gpointer
, gpointer
*))test_method
;
3971 obj
= CreateObject (&ex
);
3973 res
= F (obj
, 254, 32700, -245378, 6789600, 3.1415, 3.1415, str
, &ex
);
3988 /* thunks.cs:Test.Test7 */
3989 gint64 (STDCALL
*F
)(gpointer
*) = (gint64 (STDCALL
*)(gpointer
*))test_method
;
3990 if (F (&ex
) != G_MAXINT64
) {
3998 /* thunks.cs:Test.Test8 */
3999 void (STDCALL
*F
)(guint8
*, gint16
*, gint32
*, gint64
*, float*, double*,
4000 gpointer
*, gpointer
*);
4010 F
= (void (STDCALL
*)(guint8
*, gint16
*, gint32
*, gint64
*, float *, double *,
4011 gpointer
*, gpointer
*))test_method
;
4013 F (&a1
, &a2
, &a3
, &a4
, &a5
, &a6
, &a7
, &ex
);
4023 (fabs (a5
- 3.1415) < 0.001) &&
4024 (fabs (a6
- 3.1415) < 0.001) &&
4025 strcmp (mono_string_to_utf8 (a7
), "Test8") == 0)){
4034 /* thunks.cs:Test.Test9 */
4035 void (STDCALL
*F
)(guint8
*, gint16
*, gint32
*, gint64
*, float*, double*,
4036 gpointer
*, gpointer
*);
4046 F
= (void (STDCALL
*)(guint8
*, gint16
*, gint32
*, gint64
*, float *, double *,
4047 gpointer
*, gpointer
*))test_method
;
4049 F (&a1
, &a2
, &a3
, &a4
, &a5
, &a6
, &a7
, &ex
);
4059 /* thunks.cs:Test.Test10 */
4060 void (STDCALL
*F
)(gpointer
*, gpointer
*);
4062 gpointer obj1
, obj2
;
4064 obj1
= obj2
= CreateObject (&ex
);
4070 F
= (void (STDCALL
*)(gpointer
*, gpointer
*))test_method
;
4087 /* thunks.cs:TestStruct.Test0 */
4088 int (STDCALL
*F
)(gpointer
*, gpointer
*);
4094 obj
= CreateObject (&ex
);
4105 a1
= (TestStruct
*)mono_object_unbox (obj
);
4114 F
= (int (STDCALL
*)(gpointer
*, gpointer
*))test_method
;
4116 res
= F ((gpointer
*)obj
, &ex
);
4127 /* check whether the call was really by value */
4128 if (a1
->A
!= 42 || a1
->B
!= 3.1415) {
4137 /* thunks.cs:TestStruct.Test1 */
4138 void (STDCALL
*F
)(gpointer
, gpointer
*);
4143 obj
= CreateObject (&ex
);
4154 a1
= (TestStruct
*)mono_object_unbox (obj
);
4160 F
= (void (STDCALL
*)(gpointer
, gpointer
*))test_method
;
4173 if (!(fabs (a1
->B
- 3.1415) < 0.001)) {
4182 /* thunks.cs:TestStruct.Test2 */
4183 gpointer (STDCALL
*F
)(gpointer
*);
4188 F
= (gpointer (STDCALL
*)(gpointer
*))test_method
;
4201 a1
= (TestStruct
*)mono_object_unbox (obj
);
4208 if (!(fabs (a1
->B
- 3.1415) < 0.001)) {
4217 /* thunks.cs:TestStruct.Test3 */
4218 void (STDCALL
*F
)(gpointer
, gpointer
*);
4223 obj
= CreateObject (&ex
);
4234 a1
= (TestStruct
*)mono_object_unbox (obj
);
4244 F
= (void (STDCALL
*)(gpointer
, gpointer
*))test_method
;
4280 LIBTEST_API
int STDCALL
4281 mono_test_Winx64_struct1_in (winx64_struct1 var
)
4294 LIBTEST_API
int STDCALL
4295 mono_test_Winx64_struct2_in (winx64_struct2 var
)
4312 LIBTEST_API
int STDCALL
4313 mono_test_Winx64_struct3_in (winx64_struct3 var
)
4319 if (var
.c
!= 0x1234)
4332 LIBTEST_API
int STDCALL
4333 mono_test_Winx64_struct4_in (winx64_struct4 var
)
4339 if (var
.c
!= 0x1234)
4341 if (var
.d
!= 0x87654321)
4353 LIBTEST_API
int STDCALL
4354 mono_test_Winx64_struct5_in (winx64_struct5 var
)
4372 LIBTEST_API
int STDCALL
4373 mono_test_Winx64_struct6_in (winx64_struct6 var
)
4384 LIBTEST_API
int STDCALL
4385 mono_test_Winx64_structs_in1 (winx64_struct1 var1
,
4386 winx64_struct2 var2
,
4387 winx64_struct3 var3
,
4388 winx64_struct4 var4
)
4402 if (var3
.c
!= 0x1234)
4409 if (var4
.c
!= 0x1234)
4411 if (var4
.d
!= 0x87654321)
4416 LIBTEST_API
int STDCALL
4417 mono_test_Winx64_structs_in2 (winx64_struct1 var1
,
4418 winx64_struct1 var2
,
4419 winx64_struct1 var3
,
4420 winx64_struct1 var4
,
4421 winx64_struct1 var5
)
4437 LIBTEST_API
int STDCALL
4438 mono_test_Winx64_structs_in3 (winx64_struct1 var1
,
4439 winx64_struct5 var2
,
4440 winx64_struct1 var3
,
4441 winx64_struct5 var4
,
4442 winx64_struct1 var5
,
4443 winx64_struct5 var6
)
4478 LIBTEST_API winx64_struct1 STDCALL
4479 mono_test_Winx64_struct1_ret (void)
4486 LIBTEST_API winx64_struct2 STDCALL
4487 mono_test_Winx64_struct2_ret (void)
4495 LIBTEST_API winx64_struct3 STDCALL
4496 mono_test_Winx64_struct3_ret (void)
4505 LIBTEST_API winx64_struct4 STDCALL
4506 mono_test_Winx64_struct4_ret (void)
4516 LIBTEST_API winx64_struct5 STDCALL
4517 mono_test_Winx64_struct5_ret (void)
4526 LIBTEST_API winx64_struct1 STDCALL
4527 mono_test_Winx64_struct1_ret_5_args (char a
, char b
, char c
, char d
, char e
)
4530 ret
.a
= a
+ b
+ c
+ d
+ e
;
4534 LIBTEST_API winx64_struct5 STDCALL
4535 mono_test_Winx64_struct5_ret6_args (char a
, char b
, char c
, char d
, char e
)
4548 } winx64_floatStruct
;
4550 LIBTEST_API
int STDCALL
4551 mono_test_Winx64_floatStruct (winx64_floatStruct a
)
4553 if (a
.a
> 5.6 || a
.a
< 5.4)
4556 if (a
.b
> 9.6 || a
.b
< 9.4)
4565 } winx64_doubleStruct
;
4567 LIBTEST_API
int STDCALL
4568 mono_test_Winx64_doubleStruct (winx64_doubleStruct a
)
4570 if (a
.a
> 5.6 || a
.a
< 5.4)
4576 typedef int (STDCALL
*managed_struct1_delegate
) (winx64_struct1 a
);
4578 LIBTEST_API
int STDCALL
4579 mono_test_managed_Winx64_struct1_in(managed_struct1_delegate func
)
4586 typedef int (STDCALL
*managed_struct5_delegate
) (winx64_struct5 a
);
4588 LIBTEST_API
int STDCALL
4589 mono_test_managed_Winx64_struct5_in(managed_struct5_delegate func
)
4598 typedef int (STDCALL
*managed_struct1_struct5_delegate
) (winx64_struct1 a
, winx64_struct5 b
,
4599 winx64_struct1 c
, winx64_struct5 d
,
4600 winx64_struct1 e
, winx64_struct5 f
);
4602 LIBTEST_API
int STDCALL
4603 mono_test_managed_Winx64_struct1_struct5_in(managed_struct1_struct5_delegate func
)
4605 winx64_struct1 a
, c
, e
;
4606 winx64_struct5 b
, d
, f
;
4608 b
.a
= 2; b
.b
= 3; b
.c
= 4;
4610 d
.a
= 6; d
.b
= 7; d
.c
= 8;
4612 f
.a
= 10; f
.b
= 11; f
.c
= 12;
4614 return func (a
, b
, c
, d
, e
, f
);
4617 typedef winx64_struct1 (STDCALL
*managed_struct1_ret_delegate
) (void);
4619 LIBTEST_API
int STDCALL
4620 mono_test_Winx64_struct1_ret_managed (managed_struct1_ret_delegate func
)
4632 typedef winx64_struct5 (STDCALL
*managed_struct5_ret_delegate
) (void);
4634 LIBTEST_API
int STDCALL
4635 mono_test_Winx64_struct5_ret_managed (managed_struct5_ret_delegate func
)
4651 LIBTEST_API
int STDCALL
4652 mono_test_marshal_bool_in (int arg
, unsigned int expected
, unsigned int bDefaultMarsh
, unsigned int bBoolCustMarsh
,
4653 char bI1CustMarsh
, unsigned char bU1CustMarsh
, short bVBCustMarsh
)
4657 if (bDefaultMarsh
!= expected
)
4661 if (bBoolCustMarsh
!= expected
)
4665 if (bI1CustMarsh
!= expected
)
4669 if (bU1CustMarsh
!= expected
)
4673 if (bVBCustMarsh
!= expected
)
4682 LIBTEST_API
int STDCALL
4683 mono_test_marshal_bool_out (int arg
, unsigned int testVal
, unsigned int* bDefaultMarsh
, unsigned int* bBoolCustMarsh
,
4684 char* bI1CustMarsh
, unsigned char* bU1CustMarsh
, unsigned short* bVBCustMarsh
)
4690 *bDefaultMarsh
= testVal
;
4693 if (!bBoolCustMarsh
)
4695 *bBoolCustMarsh
= testVal
;
4700 *bI1CustMarsh
= (char)testVal
;
4705 *bU1CustMarsh
= (unsigned char)testVal
;
4710 *bVBCustMarsh
= (unsigned short)testVal
;
4718 LIBTEST_API
int STDCALL
4719 mono_test_marshal_bool_ref (int arg
, unsigned int expected
, unsigned int testVal
, unsigned int* bDefaultMarsh
,
4720 unsigned int* bBoolCustMarsh
, char* bI1CustMarsh
, unsigned char* bU1CustMarsh
,
4721 unsigned short* bVBCustMarsh
)
4727 if (*bDefaultMarsh
!= expected
)
4729 *bDefaultMarsh
= testVal
;
4732 if (!bBoolCustMarsh
)
4734 if (*bBoolCustMarsh
!= expected
)
4736 *bBoolCustMarsh
= testVal
;
4741 if (*bI1CustMarsh
!= expected
)
4743 *bI1CustMarsh
= (char)testVal
;
4748 if (*bU1CustMarsh
!= expected
)
4750 *bU1CustMarsh
= (unsigned char)testVal
;
4755 if (*bVBCustMarsh
!= expected
)
4757 *bVBCustMarsh
= (unsigned short)testVal
;
4766 typedef int (STDCALL
*MarshalBoolInDelegate
) (int arg
, unsigned int expected
, unsigned int bDefaultMarsh
,
4767 unsigned int bBoolCustMarsh
, char bI1CustMarsh
, unsigned char bU1CustMarsh
, unsigned short bVBCustMarsh
);
4769 LIBTEST_API
int STDCALL
4770 mono_test_managed_marshal_bool_in (int arg
, unsigned int expected
, unsigned int testVal
, MarshalBoolInDelegate pfcn
)
4777 return pfcn (arg
, expected
, testVal
, 0, 0, 0, 0);
4779 return pfcn (arg
, expected
, 0, testVal
, 0, 0, 0);
4781 return pfcn (arg
, expected
, 0, 0, testVal
, 0, 0);
4783 return pfcn (arg
, expected
, 0, 0, 0, testVal
, 0);
4785 return pfcn (arg
, expected
, 0, 0, 0, 0, testVal
);
4793 typedef int (STDCALL
*MarshalBoolOutDelegate
) (int arg
, unsigned int expected
, unsigned int* bDefaultMarsh
,
4794 unsigned int* bBoolCustMarsh
, char* bI1CustMarsh
, unsigned char* bU1CustMarsh
, unsigned short* bVBCustMarsh
);
4796 LIBTEST_API
int STDCALL
4797 mono_test_managed_marshal_bool_out (int arg
, unsigned int expected
, unsigned int testVal
, MarshalBoolOutDelegate pfcn
)
4800 unsigned int lDefaultMarsh
, lBoolCustMarsh
;
4801 char lI1CustMarsh
= 0;
4802 unsigned char lU1CustMarsh
= 0;
4803 unsigned short lVBCustMarsh
= 0;
4804 lDefaultMarsh
= lBoolCustMarsh
= 0;
4811 unsigned int ltVal
= 0;
4812 ret
= pfcn (arg
, testVal
, <Val
, &lBoolCustMarsh
, &lI1CustMarsh
, &lU1CustMarsh
, &lVBCustMarsh
);
4814 return 0x0100 + ret
;
4815 if (expected
!= ltVal
)
4820 unsigned int ltVal
= 0;
4821 ret
= pfcn (arg
, testVal
, &lDefaultMarsh
, <Val
, &lI1CustMarsh
, &lU1CustMarsh
, &lVBCustMarsh
);
4823 return 0x0300 + ret
;
4824 if (expected
!= ltVal
)
4830 ret
= pfcn (arg
, testVal
, &lDefaultMarsh
, &lBoolCustMarsh
, <Val
, &lU1CustMarsh
, &lVBCustMarsh
);
4832 return 0x0500 + ret
;
4833 if (expected
!= ltVal
)
4838 unsigned char ltVal
= 0;
4839 ret
= pfcn (arg
, testVal
, &lDefaultMarsh
, &lBoolCustMarsh
, &lI1CustMarsh
, <Val
, &lVBCustMarsh
);
4841 return 0x0700 + ret
;
4842 if (expected
!= ltVal
)
4847 unsigned short ltVal
= 0;
4848 ret
= pfcn (arg
, testVal
, &lDefaultMarsh
, &lBoolCustMarsh
, &lI1CustMarsh
, &lU1CustMarsh
, <Val
);
4850 return 0x0900 + ret
;
4851 if (expected
!= ltVal
)
4862 typedef int (STDCALL
*MarshalBoolRefDelegate
) (int arg
, unsigned int expected
, unsigned int testVal
, unsigned int* bDefaultMarsh
,
4863 unsigned int* bBoolCustMarsh
, char* bI1CustMarsh
, unsigned char* bU1CustMarsh
, unsigned short* bVBCustMarsh
);
4865 LIBTEST_API
int STDCALL
4866 mono_test_managed_marshal_bool_ref (int arg
, unsigned int expected
, unsigned int testVal
, unsigned int outExpected
,
4867 unsigned int outTestVal
, MarshalBoolRefDelegate pfcn
)
4870 unsigned int lDefaultMarsh
, lBoolCustMarsh
;
4871 char lI1CustMarsh
= 0;
4872 unsigned char lU1CustMarsh
= 0;
4873 unsigned short lVBCustMarsh
= 0;
4874 lDefaultMarsh
= lBoolCustMarsh
= 0;
4882 unsigned int ltestVal
= testVal
;
4883 ret
= pfcn (arg
, expected
, outTestVal
, <estVal
, &lBoolCustMarsh
, &lI1CustMarsh
, &lU1CustMarsh
, &lVBCustMarsh
);
4885 return 0x0100 + ret
;
4886 if (outExpected
!= ltestVal
)
4892 unsigned int ltestVal
= testVal
;
4893 ret
= pfcn (arg
, expected
, outTestVal
, &lDefaultMarsh
, <estVal
, &lI1CustMarsh
, &lU1CustMarsh
, &lVBCustMarsh
);
4895 return 0x0300 + ret
;
4896 if (outExpected
!= ltestVal
)
4902 char ltestVal
= testVal
;
4903 ret
= pfcn (arg
, expected
, outTestVal
, &lDefaultMarsh
, &lBoolCustMarsh
, <estVal
, &lU1CustMarsh
, &lVBCustMarsh
);
4905 return 0x0500 + ret
;
4906 if (outExpected
!= ltestVal
)
4912 unsigned char ltestVal
= testVal
;
4913 ret
= pfcn (arg
, expected
, outTestVal
, &lDefaultMarsh
, &lBoolCustMarsh
, &lI1CustMarsh
, <estVal
, &lVBCustMarsh
);
4915 return 0x0700 + ret
;
4916 if (outExpected
!= ltestVal
)
4922 unsigned short ltestVal
= testVal
;
4923 ret
= pfcn (arg
, expected
, outTestVal
, &lDefaultMarsh
, &lBoolCustMarsh
, &lI1CustMarsh
, &lU1CustMarsh
, <estVal
);
4925 return 0x0900 + ret
;
4926 if (outExpected
!= ltestVal
)
4939 LIBTEST_API
int STDCALL
4940 mono_test_marshal_safearray_out_1dim_vt_bstr_empty (SAFEARRAY
** safearray
)
4942 /* Create an empty one-dimensional array of variants */
4944 SAFEARRAYBOUND dimensions
[1];
4946 dimensions
[0].lLbound
= 0;
4947 dimensions
[0].cElements
= 0;
4949 pSA
= SafeArrayCreate (VT_VARIANT
, 1, dimensions
);
4954 LIBTEST_API
int STDCALL
4955 mono_test_marshal_safearray_out_1dim_vt_bstr (SAFEARRAY
** safearray
)
4957 /* Create a one-dimensional array of 10 variants filled with "0" to "9" */
4959 SAFEARRAYBOUND dimensions
[1];
4965 dimensions
[0].lLbound
= 0;
4966 dimensions
[0].cElements
= 10;
4968 pSA
= SafeArrayCreate (VT_VARIANT
, 1, dimensions
);
4969 for (i
= dimensions
[0].lLbound
; i
< (dimensions
[0].cElements
+ dimensions
[0].lLbound
); i
++) {
4971 VariantInit (&vOut
);
4973 _ltoa (i
,buffer
,10);
4974 vOut
.bstrVal
= marshal_bstr_alloc (buffer
);
4976 if ((hr
= SafeArrayPutElement (pSA
, indices
, &vOut
)) != S_OK
) {
4977 VariantClear (&vOut
);
4978 SafeArrayDestroy (pSA
);
4981 VariantClear (&vOut
);
4987 LIBTEST_API
int STDCALL
4988 mono_test_marshal_safearray_out_2dim_vt_i4 (SAFEARRAY
** safearray
)
4990 /* Create a two-dimensional array of 4x3 variants filled with 11, 12, 13, etc. */
4992 SAFEARRAYBOUND dimensions
[2];
4997 dimensions
[0].lLbound
= 0;
4998 dimensions
[0].cElements
= 4;
4999 dimensions
[1].lLbound
= 0;
5000 dimensions
[1].cElements
= 3;
5002 pSA
= SafeArrayCreate(VT_VARIANT
, 2, dimensions
);
5003 for (i
= dimensions
[0].lLbound
; i
< (dimensions
[0].cElements
+ dimensions
[0].lLbound
); i
++) {
5004 for (j
= dimensions
[1].lLbound
; j
< (dimensions
[1].cElements
+ dimensions
[1].lLbound
); j
++) {
5006 VariantInit (&vOut
);
5008 vOut
.lVal
= (i
+1)*10+(j
+1);
5011 if ((hr
= SafeArrayPutElement (pSA
, indices
, &vOut
)) != S_OK
) {
5012 VariantClear (&vOut
);
5013 SafeArrayDestroy (pSA
);
5016 VariantClear (&vOut
); // does a deep destroy of source VARIANT
5023 LIBTEST_API
int STDCALL
5024 mono_test_marshal_safearray_out_4dim_vt_i4 (SAFEARRAY
** safearray
)
5026 /* Create a four-dimensional array of 10x3x6x7 variants filled with their indices */
5027 /* Also use non zero lower bounds */
5029 SAFEARRAYBOUND dimensions
[4];
5034 dimensions
[0].lLbound
= 15;
5035 dimensions
[0].cElements
= 10;
5036 dimensions
[1].lLbound
= 20;
5037 dimensions
[1].cElements
= 3;
5038 dimensions
[2].lLbound
= 5;
5039 dimensions
[2].cElements
= 6;
5040 dimensions
[3].lLbound
= 12;
5041 dimensions
[3].cElements
= 7;
5043 pSA
= SafeArrayCreate (VT_VARIANT
, 4, dimensions
);
5045 SafeArrayAccessData (pSA
, (void **)&pData
);
5047 for (i
= 0; i
< 10*3*6*7; i
++) {
5048 VariantInit(&pData
[i
]);
5049 pData
[i
].vt
= VT_I4
;
5052 SafeArrayUnaccessData (pSA
);
5057 LIBTEST_API
int STDCALL
5058 mono_test_marshal_safearray_in_byval_1dim_empty (SAFEARRAY
* safearray
)
5060 /* Check that array is one dimensional and empty */
5063 long lbound
, ubound
;
5065 dim
= SafeArrayGetDim (safearray
);
5069 SafeArrayGetLBound (safearray
, 1, &lbound
);
5070 SafeArrayGetUBound (safearray
, 1, &ubound
);
5072 if ((lbound
> 0) || (ubound
> 0))
5078 LIBTEST_API
int STDCALL
5079 mono_test_marshal_safearray_in_byval_1dim_vt_i4 (SAFEARRAY
* safearray
)
5081 /* Check that array is one dimensional containing integers from 1 to 10 */
5084 long lbound
, ubound
;
5089 dim
= SafeArrayGetDim (safearray
);
5093 SafeArrayGetLBound (safearray
, 1, &lbound
);
5094 SafeArrayGetUBound (safearray
, 1, &ubound
);
5096 if ((lbound
!= 0) || (ubound
!= 9))
5099 SafeArrayAccessData (safearray
, (void **)&pData
);
5100 for (i
= lbound
; i
<= ubound
; i
++) {
5101 if ((VariantChangeType (&pData
[i
], &pData
[i
], VARIANT_NOUSEROVERRIDE
, VT_I4
) != S_OK
) || (pData
[i
].lVal
!= i
+ 1))
5104 SafeArrayUnaccessData (safearray
);
5109 LIBTEST_API
int STDCALL
5110 mono_test_marshal_safearray_in_byval_1dim_vt_mixed (SAFEARRAY
* safearray
)
5112 /* Check that array is one dimensional containing integers mixed with strings from 0 to 12 */
5115 long lbound
, ubound
;
5122 VariantInit (&element
);
5124 dim
= SafeArrayGetDim (safearray
);
5128 SafeArrayGetLBound (safearray
, 1, &lbound
);
5129 SafeArrayGetUBound (safearray
, 1, &ubound
);
5131 if ((lbound
!= 0) || (ubound
!= 12))
5134 SafeArrayAccessData (safearray
, (void **)&pData
);
5135 for (i
= lbound
; i
<= ubound
; i
++) {
5136 if ((i
%2 == 0) && (pData
[i
].vt
!= VT_I4
))
5138 if ((i
%2 == 1) && (pData
[i
].vt
!= VT_BSTR
))
5140 if ((VariantChangeType (&pData
[i
], &pData
[i
], VARIANT_NOUSEROVERRIDE
, VT_I4
) != S_OK
) || (pData
[i
].lVal
!= i
))
5143 SafeArrayUnaccessData (safearray
);
5145 /* Change the first element of the array to verify that [in] parameters are not marshalled back to the managed side */
5150 SafeArrayPutElement (safearray
, indices
, &element
);
5151 VariantClear (&element
);
5156 LIBTEST_API
int STDCALL
5157 mono_test_marshal_safearray_in_byval_2dim_vt_i4 (SAFEARRAY
* safearray
)
5159 /* Check that array is one dimensional containing integers mixed with strings from 0 to 12 */
5162 long lbound1
, ubound1
, lbound2
, ubound2
;
5167 VariantInit (&element
);
5169 dim
= SafeArrayGetDim (safearray
);
5173 SafeArrayGetLBound (safearray
, 1, &lbound1
);
5174 SafeArrayGetUBound (safearray
, 1, &ubound1
);
5176 if ((lbound1
!= 0) || (ubound1
!= 1))
5179 SafeArrayGetLBound (safearray
, 2, &lbound2
);
5180 SafeArrayGetUBound (safearray
, 2, &ubound2
);
5182 if ((lbound2
!= 0) || (ubound2
!= 3)) {
5186 for (i
= lbound1
; i
<= ubound1
; i
++) {
5188 for (j
= lbound2
; j
<= ubound2
; j
++) {
5190 if (SafeArrayGetElement (safearray
, indices
, &element
) != S_OK
)
5192 failed
= ((element
.vt
!= VT_I4
) || (element
.lVal
!= 10*(i
+1)+(j
+1)));
5193 VariantClear (&element
);
5199 /* Change the first element of the array to verify that [in] parameters are not marshalled back to the managed side */
5205 SafeArrayPutElement (safearray
, indices
, &element
);
5206 VariantClear (&element
);
5211 LIBTEST_API
int STDCALL
5212 mono_test_marshal_safearray_in_byval_3dim_vt_bstr (SAFEARRAY
* safearray
)
5214 /* Check that array is one dimensional containing integers mixed with strings from 0 to 12 */
5217 long lbound1
, ubound1
, lbound2
, ubound2
, lbound3
, ubound3
;
5218 long i
, j
, k
, failed
;
5222 VariantInit (&element
);
5224 dim
= SafeArrayGetDim (safearray
);
5228 SafeArrayGetLBound (safearray
, 1, &lbound1
);
5229 SafeArrayGetUBound (safearray
, 1, &ubound1
);
5231 if ((lbound1
!= 0) || (ubound1
!= 1))
5234 SafeArrayGetLBound (safearray
, 2, &lbound2
);
5235 SafeArrayGetUBound (safearray
, 2, &ubound2
);
5237 if ((lbound2
!= 0) || (ubound2
!= 1))
5240 SafeArrayGetLBound (safearray
, 3, &lbound3
);
5241 SafeArrayGetUBound (safearray
, 3, &ubound3
);
5243 if ((lbound3
!= 0) || (ubound3
!= 2))
5246 for (i
= lbound1
; i
<= ubound1
; i
++) {
5248 for (j
= lbound2
; j
<= ubound2
; j
++) {
5250 for (k
= lbound3
; k
<= ubound3
; k
++) {
5252 if (SafeArrayGetElement (safearray
, indices
, &element
) != S_OK
)
5254 failed
= ((element
.vt
!= VT_BSTR
)
5255 || (VariantChangeType (&element
, &element
, VARIANT_NOUSEROVERRIDE
, VT_I4
) != S_OK
)
5256 || (element
.lVal
!= 100*(i
+1)+10*(j
+1)+(k
+1)));
5257 VariantClear (&element
);
5264 /* Change the first element of the array to verify that [in] parameters are not marshalled back to the managed side */
5269 element
.vt
= VT_BSTR
;
5270 element
.bstrVal
= SysAllocString(L
"Should not be copied");
5271 SafeArrayPutElement (safearray
, indices
, &element
);
5272 VariantClear (&element
);
5277 LIBTEST_API
int STDCALL
5278 mono_test_marshal_safearray_in_byref_3dim_vt_bstr (SAFEARRAY
** safearray
)
5280 return mono_test_marshal_safearray_in_byval_3dim_vt_bstr (*safearray
);
5283 LIBTEST_API
int STDCALL
5284 mono_test_marshal_safearray_in_out_byref_1dim_empty (SAFEARRAY
** safearray
)
5286 /* Check that the input array is what is expected and change it so the caller can check */
5287 /* correct marshalling back to managed code */
5290 long lbound
, ubound
;
5291 SAFEARRAYBOUND dimensions
[1];
5293 wchar_t buffer
[20];
5297 /* Check that in array is one dimensional and empty */
5299 dim
= SafeArrayGetDim (*safearray
);
5304 SafeArrayGetLBound (*safearray
, 1, &lbound
);
5305 SafeArrayGetUBound (*safearray
, 1, &ubound
);
5307 if ((lbound
> 0) || (ubound
> 0)) {
5311 /* Re-dimension the array and return a one-dimensional array of 8 variants filled with "0" to "7" */
5313 dimensions
[0].lLbound
= 0;
5314 dimensions
[0].cElements
= 8;
5316 hr
= SafeArrayRedim (*safearray
, dimensions
);
5320 for (i
= dimensions
[0].lLbound
; i
< (dimensions
[0].lLbound
+ dimensions
[0].cElements
); i
++) {
5322 VariantInit (&vOut
);
5324 _ltow (i
,buffer
,10);
5325 vOut
.bstrVal
= SysAllocString (buffer
);
5327 if ((hr
= SafeArrayPutElement (*safearray
, indices
, &vOut
)) != S_OK
) {
5328 VariantClear (&vOut
);
5329 SafeArrayDestroy (*safearray
);
5332 VariantClear (&vOut
);
5337 LIBTEST_API
int STDCALL
5338 mono_test_marshal_safearray_in_out_byref_3dim_vt_bstr (SAFEARRAY
** safearray
)
5340 /* Check that the input array is what is expected and change it so the caller can check */
5341 /* correct marshalling back to managed code */
5344 long lbound1
, ubound1
, lbound2
, ubound2
, lbound3
, ubound3
;
5345 SAFEARRAYBOUND dimensions
[1];
5346 long i
, j
, k
, failed
;
5347 wchar_t buffer
[20];
5352 VariantInit (&element
);
5354 /* Check that in array is three dimensional and contains the expected values */
5356 dim
= SafeArrayGetDim (*safearray
);
5360 SafeArrayGetLBound (*safearray
, 1, &lbound1
);
5361 SafeArrayGetUBound (*safearray
, 1, &ubound1
);
5363 if ((lbound1
!= 0) || (ubound1
!= 1))
5366 SafeArrayGetLBound (*safearray
, 2, &lbound2
);
5367 SafeArrayGetUBound (*safearray
, 2, &ubound2
);
5369 if ((lbound2
!= 0) || (ubound2
!= 1))
5372 SafeArrayGetLBound (*safearray
, 3, &lbound3
);
5373 SafeArrayGetUBound (*safearray
, 3, &ubound3
);
5375 if ((lbound3
!= 0) || (ubound3
!= 2))
5378 for (i
= lbound1
; i
<= ubound1
; i
++) {
5380 for (j
= lbound2
; j
<= ubound2
; j
++) {
5382 for (k
= lbound3
; k
<= ubound3
; k
++) {
5384 if (SafeArrayGetElement (*safearray
, indices
, &element
) != S_OK
)
5386 failed
= ((element
.vt
!= VT_BSTR
)
5387 || (VariantChangeType (&element
, &element
, VARIANT_NOUSEROVERRIDE
, VT_I4
) != S_OK
)
5388 || (element
.lVal
!= 100*(i
+1)+10*(j
+1)+(k
+1)));
5389 VariantClear (&element
);
5396 hr
= SafeArrayDestroy (*safearray
);
5400 /* Return a new one-dimensional array of 8 variants filled with "0" to "7" */
5402 dimensions
[0].lLbound
= 0;
5403 dimensions
[0].cElements
= 8;
5405 *safearray
= SafeArrayCreate (VT_VARIANT
, 1, dimensions
);
5407 for (i
= dimensions
[0].lLbound
; i
< (dimensions
[0].lLbound
+ dimensions
[0].cElements
); i
++) {
5409 VariantInit (&vOut
);
5411 _ltow (i
,buffer
,10);
5412 vOut
.bstrVal
= SysAllocString (buffer
);
5414 if ((hr
= SafeArrayPutElement (*safearray
, indices
, &vOut
)) != S_OK
) {
5415 VariantClear (&vOut
);
5416 SafeArrayDestroy (*safearray
);
5419 VariantClear (&vOut
);
5424 LIBTEST_API
int STDCALL
5425 mono_test_marshal_safearray_in_out_byref_1dim_vt_i4 (SAFEARRAY
** safearray
)
5427 /* Check that the input array is what is expected and change it so the caller can check */
5428 /* correct marshalling back to managed code */
5431 long lbound1
, ubound1
;
5437 VariantInit (&element
);
5439 /* Check that in array is one dimensional and contains the expected value */
5441 dim
= SafeArrayGetDim (*safearray
);
5445 SafeArrayGetLBound (*safearray
, 1, &lbound1
);
5446 SafeArrayGetUBound (*safearray
, 1, &ubound1
);
5449 if ((lbound1
!= 0) || (ubound1
!= 1))
5453 for (i
= lbound1
; i
<= ubound1
; i
++) {
5455 if (SafeArrayGetElement (*safearray
, indices
, &element
) != S_OK
)
5457 failed
= (element
.vt
!= VT_I4
) || (element
.lVal
!= i
+1);
5458 VariantClear (&element
);
5463 /* Change one of the elements of the array to verify that [out] parameter is marshalled back to the managed side */
5468 SafeArrayPutElement (*safearray
, indices
, &element
);
5469 VariantClear (&element
);
5474 LIBTEST_API
int STDCALL
5475 mono_test_marshal_safearray_in_out_byval_1dim_vt_i4 (SAFEARRAY
* safearray
)
5477 /* Check that the input array is what is expected and change it so the caller can check */
5478 /* correct marshalling back to managed code */
5481 long lbound1
, ubound1
;
5482 SAFEARRAYBOUND dimensions
[1];
5488 VariantInit (&element
);
5490 /* Check that in array is one dimensional and contains the expected value */
5492 dim
= SafeArrayGetDim (safearray
);
5496 SafeArrayGetLBound (safearray
, 1, &lbound1
);
5497 SafeArrayGetUBound (safearray
, 1, &ubound1
);
5499 if ((lbound1
!= 0) || (ubound1
!= 0))
5502 for (i
= lbound1
; i
<= ubound1
; i
++) {
5504 if (SafeArrayGetElement (safearray
, indices
, &element
) != S_OK
)
5506 failed
= (element
.vt
!= VT_I4
) || (element
.lVal
!= i
+1);
5507 VariantClear (&element
);
5512 /* Change the array to verify how [out] parameter is marshalled back to the managed side */
5514 /* Redimension the array */
5515 dimensions
[0].lLbound
= lbound1
;
5516 dimensions
[0].cElements
= 2;
5517 hr
= SafeArrayRedim(safearray
, dimensions
);
5521 element
.lVal
= 12345;
5522 SafeArrayPutElement (safearray
, indices
, &element
);
5523 VariantClear (&element
);
5527 element
.lVal
= -12345;
5528 SafeArrayPutElement (safearray
, indices
, &element
);
5529 VariantClear (&element
);
5534 LIBTEST_API
int STDCALL
5535 mono_test_marshal_safearray_in_out_byval_3dim_vt_bstr (SAFEARRAY
* safearray
)
5537 /* Check that the input array is what is expected and change it so the caller can check */
5538 /* correct marshalling back to managed code */
5541 long lbound1
, ubound1
, lbound2
, ubound2
, lbound3
, ubound3
;
5542 long i
, j
, k
, failed
;
5547 VariantInit (&element
);
5549 /* Check that in array is three dimensional and contains the expected values */
5551 dim
= SafeArrayGetDim (safearray
);
5555 SafeArrayGetLBound (safearray
, 1, &lbound1
);
5556 SafeArrayGetUBound (safearray
, 1, &ubound1
);
5558 if ((lbound1
!= 0) || (ubound1
!= 1))
5561 SafeArrayGetLBound (safearray
, 2, &lbound2
);
5562 SafeArrayGetUBound (safearray
, 2, &ubound2
);
5564 if ((lbound2
!= 0) || (ubound2
!= 1))
5567 SafeArrayGetLBound (safearray
, 3, &lbound3
);
5568 SafeArrayGetUBound (safearray
, 3, &ubound3
);
5570 if ((lbound3
!= 0) || (ubound3
!= 2))
5573 for (i
= lbound1
; i
<= ubound1
; i
++) {
5575 for (j
= lbound2
; j
<= ubound2
; j
++) {
5577 for (k
= lbound3
; k
<= ubound3
; k
++) {
5579 if (SafeArrayGetElement (safearray
, indices
, &element
) != S_OK
)
5581 failed
= ((element
.vt
!= VT_BSTR
)
5582 || (VariantChangeType (&element
, &element
, VARIANT_NOUSEROVERRIDE
, VT_I4
) != S_OK
)
5583 || (element
.lVal
!= 100*(i
+1)+10*(j
+1)+(k
+1)));
5584 VariantClear (&element
);
5591 /* Change the elements of the array to verify that [out] parameter is marshalled back to the managed side */
5598 SafeArrayPutElement (safearray
, indices
, &element
);
5599 VariantClear (&element
);
5606 SafeArrayPutElement (safearray
, indices
, &element
);
5607 VariantClear (&element
);
5612 element
.vt
= VT_BSTR
;
5613 element
.bstrVal
= marshal_bstr_alloc("ABCDEFG");
5614 SafeArrayPutElement (safearray
, indices
, &element
);
5615 VariantClear (&element
);
5620 LIBTEST_API
int STDCALL
5621 mono_test_marshal_safearray_mixed(
5622 SAFEARRAY
*safearray1
,
5623 SAFEARRAY
**safearray2
,
5624 SAFEARRAY
*safearray3
,
5625 SAFEARRAY
**safearray4
5630 /* Initialize out parameters */
5633 /* array1: Check that in array is one dimensional and contains the expected value */
5634 hr
= mono_test_marshal_safearray_in_out_byval_1dim_vt_i4 (safearray1
);
5636 /* array2: Fill in with some values to check on the managed side */
5638 hr
= mono_test_marshal_safearray_out_1dim_vt_bstr (safearray2
);
5640 /* array3: Check that in array is one dimensional and contains the expected value */
5642 hr
= mono_test_marshal_safearray_in_byval_1dim_vt_mixed(safearray3
);
5644 /* array4: Check input values and fill in with some values to check on the managed side */
5646 hr
= mono_test_marshal_safearray_in_out_byref_3dim_vt_bstr(safearray4
);
5651 LIBTEST_API
int STDCALL
5652 mono_test_marshal_safearray_in_ccw(MonoComObject
*pUnk
)
5659 array
= SafeArrayCreateVector(VT_VARIANT
, 0, 2);
5662 var
.bstrVal
= marshal_bstr_alloc("Test");
5664 SafeArrayPutElement(array
, &index
, &var
);
5669 SafeArrayPutElement(array
, &index
, &var
);
5671 ret
= pUnk
->vtbl
->ArrayIn (pUnk
, (void *)array
);
5673 ret
= pUnk
->vtbl
->ArrayIn2 (pUnk
, (void *)array
);
5675 ret
= pUnk
->vtbl
->ArrayIn3 (pUnk
, (void *)array
);
5677 SafeArrayDestroy(array
);
5684 static int call_managed_res
;
5687 call_managed (gpointer arg
)
5689 SimpleDelegate del
= (SimpleDelegate
)arg
;
5691 call_managed_res
= del (42);
5694 LIBTEST_API
int STDCALL
5695 mono_test_marshal_thread_attach (SimpleDelegate del
)
5703 res
= pthread_create (&t
, NULL
, (gpointer (*)(gpointer
))call_managed
, (gpointer
)del
);
5704 g_assert (res
== 0);
5705 pthread_join (t
, NULL
);
5707 return call_managed_res
;
5712 char arr
[4 * 1024];
5715 typedef int (STDCALL
*LargeStructDelegate
) (LargeStruct
*s
);
5718 call_managed_large_vt (gpointer arg
)
5720 LargeStructDelegate del
= (LargeStructDelegate
)arg
;
5723 call_managed_res
= del (&s
);
5726 LIBTEST_API
int STDCALL
5727 mono_test_marshal_thread_attach_large_vt (SimpleDelegate del
)
5735 res
= pthread_create (&t
, NULL
, (gpointer (*)(gpointer
))call_managed_large_vt
, (gpointer
)del
);
5736 g_assert (res
== 0);
5737 pthread_join (t
, NULL
);
5739 return call_managed_res
;
5743 typedef int (STDCALL
*Callback
) (void);
5745 static Callback callback
;
5747 LIBTEST_API
void STDCALL
5748 mono_test_marshal_set_callback (Callback cb
)
5753 LIBTEST_API
int STDCALL
5754 mono_test_marshal_call_callback (void)
5759 LIBTEST_API
int STDCALL
5760 mono_test_marshal_lpstr (char *str
)
5762 return strcmp ("ABC", str
);
5765 LIBTEST_API
int STDCALL
5766 mono_test_marshal_lpwstr (gunichar2
*str
)
5771 s
= g_utf16_to_utf8 (str
, -1, NULL
, NULL
, NULL
);
5772 res
= strcmp ("ABC", s
);
5778 LIBTEST_API
char* STDCALL
5779 mono_test_marshal_return_lpstr (void)
5781 char *res
= (char *)marshal_alloc (4);
5782 strcpy (res
, "XYZ");
5786 LIBTEST_API gunichar2
* STDCALL
5787 mono_test_marshal_return_lpwstr (void)
5789 gunichar2
*res
= (gunichar2
*)marshal_alloc (8);
5790 gunichar2
* tmp
= g_utf8_to_utf16 ("XYZ", -1, NULL
, NULL
, NULL
);
5792 memcpy (res
, tmp
, 8);
5799 #if defined (HOST_WIN32) && defined (HOST_X86) && defined (__GNUC__)
5800 // Workaround gcc ABI bug. It returns the struct in ST0 instead of edx:eax.
5801 // Mono and Visual C++ agree.
5808 } SingleDoubleStruct
;
5810 LIBTEST_API SingleDoubleStruct STDCALL
5811 mono_test_marshal_return_single_double_struct (void)
5813 SingleDoubleStruct res
= {3.0};
5817 LIBTEST_API
int STDCALL
5818 mono_test_has_thiscall_globals (void)
5820 // Visual C++ does not accept __thiscall on global functions, only
5821 // member function and function pointers. Gcc accepts it also on global functions.
5822 #if defined (HOST_X86) && defined (HOST_WIN32) && !defined (_MSC_VER)
5829 LIBTEST_API
int STDCALL
5830 mono_test_has_thiscall_pointers (void)
5832 #if defined (HOST_X86) && defined (HOST_WIN32)
5843 _mono_test_native_thiscall1 (int arg
)
5852 _mono_test_native_thiscall2 (int arg
, int arg2
)
5854 return arg
+ (arg2
^1);
5861 _mono_test_native_thiscall3 (int arg
, int arg2
, int arg3
)
5863 return arg
+ (arg2
^1) + (arg3
^2);
5870 *ThiscallFunction
)(int arg
, int arg2
);
5872 LIBTEST_API ThiscallFunction STDCALL
5873 mono_test_get_native_thiscall2 (void)
5875 return _mono_test_native_thiscall2
;
5878 LIBTEST_API
int STDCALL
5879 _mono_test_managed_thiscall1 (int (__thiscall
*fn
)(int), int arg
)
5884 LIBTEST_API
int STDCALL
5885 _mono_test_managed_thiscall2 (int (__thiscall
*fn
)(int,int), int arg
, int arg2
)
5887 return fn(arg
, arg2
);
5890 LIBTEST_API
int STDCALL
5891 _mono_test_managed_thiscall3 (int (__thiscall
*fn
)(int,int,int), int arg
, int arg2
, int arg3
)
5893 return fn(arg
, arg2
, arg3
);
5900 LIBTEST_API sbyte1 STDCALL
5901 mono_return_sbyte1 (sbyte1 s1
, int addend
) {
5903 fprintf(stderr
, "mono_return_sbyte1 s1.f1: got %d but expected %d\n", s1
.f1
, 1);
5913 LIBTEST_API sbyte2 STDCALL
5914 mono_return_sbyte2 (sbyte2 s2
, int addend
) {
5916 fprintf(stderr
, "mono_return_sbyte2 s2.f1: got %d but expected %d\n", s2
.f1
, 1);
5919 fprintf(stderr
, "mono_return_sbyte2 s2.f2: got %d but expected %d\n", s2
.f2
, 2);
5921 s2
.f1
+=addend
; s2
.f2
+=addend
;
5929 LIBTEST_API sbyte3 STDCALL
5930 mono_return_sbyte3 (sbyte3 s3
, int addend
) {
5932 fprintf(stderr
, "mono_return_sbyte3 s3.f1: got %d but expected %d\n", s3
.f1
, 1);
5935 fprintf(stderr
, "mono_return_sbyte3 s3.f2: got %d but expected %d\n", s3
.f2
, 2);
5938 fprintf(stderr
, "mono_return_sbyte3 s3.f3: got %d but expected %d\n", s3
.f3
, 3);
5940 s3
.f1
+=addend
; s3
.f2
+=addend
; s3
.f3
+=addend
;
5948 LIBTEST_API sbyte4 STDCALL
5949 mono_return_sbyte4 (sbyte4 s4
, int addend
) {
5951 fprintf(stderr
, "mono_return_sbyte4 s4.f1: got %d but expected %d\n", s4
.f1
, 1);
5954 fprintf(stderr
, "mono_return_sbyte4 s4.f2: got %d but expected %d\n", s4
.f2
, 2);
5957 fprintf(stderr
, "mono_return_sbyte4 s4.f3: got %d but expected %d\n", s4
.f3
, 3);
5960 fprintf(stderr
, "mono_return_sbyte4 s4.f4: got %d but expected %d\n", s4
.f4
, 4);
5962 s4
.f1
+=addend
; s4
.f2
+=addend
; s4
.f3
+=addend
; s4
.f4
+=addend
;
5967 char f1
,f2
,f3
,f4
,f5
;
5970 LIBTEST_API sbyte5 STDCALL
5971 mono_return_sbyte5 (sbyte5 s5
, int addend
) {
5973 fprintf(stderr
, "mono_return_sbyte5 s5.f1: got %d but expected %d\n", s5
.f1
, 1);
5976 fprintf(stderr
, "mono_return_sbyte5 s5.f2: got %d but expected %d\n", s5
.f2
, 2);
5979 fprintf(stderr
, "mono_return_sbyte5 s5.f3: got %d but expected %d\n", s5
.f3
, 3);
5982 fprintf(stderr
, "mono_return_sbyte5 s5.f4: got %d but expected %d\n", s5
.f4
, 4);
5985 fprintf(stderr
, "mono_return_sbyte5 s5.f5: got %d but expected %d\n", s5
.f5
, 5);
5987 s5
.f1
+=addend
; s5
.f2
+=addend
; s5
.f3
+=addend
; s5
.f4
+=addend
; s5
.f5
+=addend
;
5992 char f1
,f2
,f3
,f4
,f5
,f6
;
5995 LIBTEST_API sbyte6 STDCALL
5996 mono_return_sbyte6 (sbyte6 s6
, int addend
) {
5998 fprintf(stderr
, "mono_return_sbyte6 s6.f1: got %d but expected %d\n", s6
.f1
, 1);
6001 fprintf(stderr
, "mono_return_sbyte6 s6.f2: got %d but expected %d\n", s6
.f2
, 2);
6004 fprintf(stderr
, "mono_return_sbyte6 s6.f3: got %d but expected %d\n", s6
.f3
, 3);
6007 fprintf(stderr
, "mono_return_sbyte6 s6.f4: got %d but expected %d\n", s6
.f4
, 4);
6010 fprintf(stderr
, "mono_return_sbyte6 s6.f5: got %d but expected %d\n", s6
.f5
, 5);
6013 fprintf(stderr
, "mono_return_sbyte6 s6.f6: got %d but expected %d\n", s6
.f6
, 6);
6015 s6
.f1
+=addend
; s6
.f2
+=addend
; s6
.f3
+=addend
; s6
.f4
+=addend
; s6
.f5
+=addend
; s6
.f6
+=addend
;
6020 char f1
,f2
,f3
,f4
,f5
,f6
,f7
;
6023 LIBTEST_API sbyte7 STDCALL
6024 mono_return_sbyte7 (sbyte7 s7
, int addend
) {
6026 fprintf(stderr
, "mono_return_sbyte7 s7.f1: got %d but expected %d\n", s7
.f1
, 1);
6029 fprintf(stderr
, "mono_return_sbyte7 s7.f2: got %d but expected %d\n", s7
.f2
, 2);
6032 fprintf(stderr
, "mono_return_sbyte7 s7.f3: got %d but expected %d\n", s7
.f3
, 3);
6035 fprintf(stderr
, "mono_return_sbyte7 s7.f4: got %d but expected %d\n", s7
.f4
, 4);
6038 fprintf(stderr
, "mono_return_sbyte7 s7.f5: got %d but expected %d\n", s7
.f5
, 5);
6041 fprintf(stderr
, "mono_return_sbyte7 s7.f6: got %d but expected %d\n", s7
.f6
, 6);
6044 fprintf(stderr
, "mono_return_sbyte7 s7.f7: got %d but expected %d\n", s7
.f7
, 7);
6046 s7
.f1
+=addend
; s7
.f2
+=addend
; s7
.f3
+=addend
; s7
.f4
+=addend
; s7
.f5
+=addend
; s7
.f6
+=addend
; s7
.f7
+=addend
;
6051 char f1
,f2
,f3
,f4
,f5
,f6
,f7
,f8
;
6054 LIBTEST_API sbyte8 STDCALL
6055 mono_return_sbyte8 (sbyte8 s8
, int addend
) {
6057 fprintf(stderr
, "mono_return_sbyte8 s8.f1: got %d but expected %d\n", s8
.f1
, 1);
6060 fprintf(stderr
, "mono_return_sbyte8 s8.f2: got %d but expected %d\n", s8
.f2
, 2);
6063 fprintf(stderr
, "mono_return_sbyte8 s8.f3: got %d but expected %d\n", s8
.f3
, 3);
6066 fprintf(stderr
, "mono_return_sbyte8 s8.f4: got %d but expected %d\n", s8
.f4
, 4);
6069 fprintf(stderr
, "mono_return_sbyte8 s8.f5: got %d but expected %d\n", s8
.f5
, 5);
6072 fprintf(stderr
, "mono_return_sbyte8 s8.f6: got %d but expected %d\n", s8
.f6
, 6);
6075 fprintf(stderr
, "mono_return_sbyte8 s8.f7: got %d but expected %d\n", s8
.f7
, 7);
6078 fprintf(stderr
, "mono_return_sbyte8 s8.f8: got %d but expected %d\n", s8
.f8
, 8);
6080 s8
.f1
+=addend
; s8
.f2
+=addend
; s8
.f3
+=addend
; s8
.f4
+=addend
; s8
.f5
+=addend
; s8
.f6
+=addend
; s8
.f7
+=addend
; s8
.f8
+=addend
;
6085 char f1
,f2
,f3
,f4
,f5
,f6
,f7
,f8
,f9
;
6088 LIBTEST_API sbyte9 STDCALL
6089 mono_return_sbyte9 (sbyte9 s9
, int addend
) {
6091 fprintf(stderr
, "mono_return_sbyte9 s9.f1: got %d but expected %d\n", s9
.f1
, 1);
6094 fprintf(stderr
, "mono_return_sbyte9 s9.f2: got %d but expected %d\n", s9
.f2
, 2);
6097 fprintf(stderr
, "mono_return_sbyte9 s9.f3: got %d but expected %d\n", s9
.f3
, 3);
6100 fprintf(stderr
, "mono_return_sbyte9 s9.f4: got %d but expected %d\n", s9
.f4
, 4);
6103 fprintf(stderr
, "mono_return_sbyte9 s9.f5: got %d but expected %d\n", s9
.f5
, 5);
6106 fprintf(stderr
, "mono_return_sbyte9 s9.f6: got %d but expected %d\n", s9
.f6
, 6);
6109 fprintf(stderr
, "mono_return_sbyte9 s9.f7: got %d but expected %d\n", s9
.f7
, 7);
6112 fprintf(stderr
, "mono_return_sbyte9 s9.f8: got %d but expected %d\n", s9
.f8
, 8);
6115 fprintf(stderr
, "mono_return_sbyte9 s9.f9: got %d but expected %d\n", s9
.f9
, 9);
6117 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
;
6122 char f1
,f2
,f3
,f4
,f5
,f6
,f7
,f8
,f9
,f10
;
6125 LIBTEST_API sbyte10 STDCALL
6126 mono_return_sbyte10 (sbyte10 s10
, int addend
) {
6128 fprintf(stderr
, "mono_return_sbyte10 s10.f1: got %d but expected %d\n", s10
.f1
, 1);
6131 fprintf(stderr
, "mono_return_sbyte10 s10.f2: got %d but expected %d\n", s10
.f2
, 2);
6134 fprintf(stderr
, "mono_return_sbyte10 s10.f3: got %d but expected %d\n", s10
.f3
, 3);
6137 fprintf(stderr
, "mono_return_sbyte10 s10.f4: got %d but expected %d\n", s10
.f4
, 4);
6140 fprintf(stderr
, "mono_return_sbyte10 s10.f5: got %d but expected %d\n", s10
.f5
, 5);
6143 fprintf(stderr
, "mono_return_sbyte10 s10.f6: got %d but expected %d\n", s10
.f6
, 6);
6146 fprintf(stderr
, "mono_return_sbyte10 s10.f7: got %d but expected %d\n", s10
.f7
, 7);
6149 fprintf(stderr
, "mono_return_sbyte10 s10.f8: got %d but expected %d\n", s10
.f8
, 8);
6152 fprintf(stderr
, "mono_return_sbyte10 s10.f9: got %d but expected %d\n", s10
.f9
, 9);
6154 if (s10
.f10
!= 10) {
6155 fprintf(stderr
, "mono_return_sbyte10 s10.f10: got %d but expected %d\n", s10
.f10
, 10);
6157 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
;
6162 char f1
,f2
,f3
,f4
,f5
,f6
,f7
,f8
,f9
,f10
,f11
;
6165 LIBTEST_API sbyte11 STDCALL
6166 mono_return_sbyte11 (sbyte11 s11
, int addend
) {
6168 fprintf(stderr
, "mono_return_sbyte11 s11.f1: got %d but expected %d\n", s11
.f1
, 1);
6171 fprintf(stderr
, "mono_return_sbyte11 s11.f2: got %d but expected %d\n", s11
.f2
, 2);
6174 fprintf(stderr
, "mono_return_sbyte11 s11.f3: got %d but expected %d\n", s11
.f3
, 3);
6177 fprintf(stderr
, "mono_return_sbyte11 s11.f4: got %d but expected %d\n", s11
.f4
, 4);
6180 fprintf(stderr
, "mono_return_sbyte11 s11.f5: got %d but expected %d\n", s11
.f5
, 5);
6183 fprintf(stderr
, "mono_return_sbyte11 s11.f6: got %d but expected %d\n", s11
.f6
, 6);
6186 fprintf(stderr
, "mono_return_sbyte11 s11.f7: got %d but expected %d\n", s11
.f7
, 7);
6189 fprintf(stderr
, "mono_return_sbyte11 s11.f8: got %d but expected %d\n", s11
.f8
, 8);
6192 fprintf(stderr
, "mono_return_sbyte11 s11.f9: got %d but expected %d\n", s11
.f9
, 9);
6194 if (s11
.f10
!= 10) {
6195 fprintf(stderr
, "mono_return_sbyte11 s11.f10: got %d but expected %d\n", s11
.f10
, 10);
6197 if (s11
.f11
!= 11) {
6198 fprintf(stderr
, "mono_return_sbyte11 s11.f11: got %d but expected %d\n", s11
.f11
, 11);
6200 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
;
6205 char f1
,f2
,f3
,f4
,f5
,f6
,f7
,f8
,f9
,f10
,f11
,f12
;
6208 LIBTEST_API sbyte12 STDCALL
6209 mono_return_sbyte12 (sbyte12 s12
, int addend
) {
6211 fprintf(stderr
, "mono_return_sbyte12 s12.f1: got %d but expected %d\n", s12
.f1
, 1);
6214 fprintf(stderr
, "mono_return_sbyte12 s12.f2: got %d but expected %d\n", s12
.f2
, 2);
6217 fprintf(stderr
, "mono_return_sbyte12 s12.f3: got %d but expected %d\n", s12
.f3
, 3);
6220 fprintf(stderr
, "mono_return_sbyte12 s12.f4: got %d but expected %d\n", s12
.f4
, 4);
6223 fprintf(stderr
, "mono_return_sbyte12 s12.f5: got %d but expected %d\n", s12
.f5
, 5);
6226 fprintf(stderr
, "mono_return_sbyte12 s12.f6: got %d but expected %d\n", s12
.f6
, 6);
6229 fprintf(stderr
, "mono_return_sbyte12 s12.f7: got %d but expected %d\n", s12
.f7
, 7);
6232 fprintf(stderr
, "mono_return_sbyte12 s12.f8: got %d but expected %d\n", s12
.f8
, 8);
6235 fprintf(stderr
, "mono_return_sbyte12 s12.f9: got %d but expected %d\n", s12
.f9
, 9);
6237 if (s12
.f10
!= 10) {
6238 fprintf(stderr
, "mono_return_sbyte12 s12.f10: got %d but expected %d\n", s12
.f10
, 10);
6240 if (s12
.f11
!= 11) {
6241 fprintf(stderr
, "mono_return_sbyte12 s12.f11: got %d but expected %d\n", s12
.f11
, 11);
6243 if (s12
.f12
!= 12) {
6244 fprintf(stderr
, "mono_return_sbyte12 s12.f12: got %d but expected %d\n", s12
.f12
, 12);
6246 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
;
6251 char f1
,f2
,f3
,f4
,f5
,f6
,f7
,f8
,f9
,f10
,f11
,f12
,f13
;
6254 LIBTEST_API sbyte13 STDCALL
6255 mono_return_sbyte13 (sbyte13 s13
, int addend
) {
6257 fprintf(stderr
, "mono_return_sbyte13 s13.f1: got %d but expected %d\n", s13
.f1
, 1);
6260 fprintf(stderr
, "mono_return_sbyte13 s13.f2: got %d but expected %d\n", s13
.f2
, 2);
6263 fprintf(stderr
, "mono_return_sbyte13 s13.f3: got %d but expected %d\n", s13
.f3
, 3);
6266 fprintf(stderr
, "mono_return_sbyte13 s13.f4: got %d but expected %d\n", s13
.f4
, 4);
6269 fprintf(stderr
, "mono_return_sbyte13 s13.f5: got %d but expected %d\n", s13
.f5
, 5);
6272 fprintf(stderr
, "mono_return_sbyte13 s13.f6: got %d but expected %d\n", s13
.f6
, 6);
6275 fprintf(stderr
, "mono_return_sbyte13 s13.f7: got %d but expected %d\n", s13
.f7
, 7);
6278 fprintf(stderr
, "mono_return_sbyte13 s13.f8: got %d but expected %d\n", s13
.f8
, 8);
6281 fprintf(stderr
, "mono_return_sbyte13 s13.f9: got %d but expected %d\n", s13
.f9
, 9);
6283 if (s13
.f10
!= 10) {
6284 fprintf(stderr
, "mono_return_sbyte13 s13.f10: got %d but expected %d\n", s13
.f10
, 10);
6286 if (s13
.f11
!= 11) {
6287 fprintf(stderr
, "mono_return_sbyte13 s13.f11: got %d but expected %d\n", s13
.f11
, 11);
6289 if (s13
.f12
!= 12) {
6290 fprintf(stderr
, "mono_return_sbyte13 s13.f12: got %d but expected %d\n", s13
.f12
, 12);
6292 if (s13
.f13
!= 13) {
6293 fprintf(stderr
, "mono_return_sbyte13 s13.f13: got %d but expected %d\n", s13
.f13
, 13);
6295 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
;
6300 char f1
,f2
,f3
,f4
,f5
,f6
,f7
,f8
,f9
,f10
,f11
,f12
,f13
,f14
;
6303 LIBTEST_API sbyte14 STDCALL
6304 mono_return_sbyte14 (sbyte14 s14
, int addend
) {
6306 fprintf(stderr
, "mono_return_sbyte14 s14.f1: got %d but expected %d\n", s14
.f1
, 1);
6309 fprintf(stderr
, "mono_return_sbyte14 s14.f2: got %d but expected %d\n", s14
.f2
, 2);
6312 fprintf(stderr
, "mono_return_sbyte14 s14.f3: got %d but expected %d\n", s14
.f3
, 3);
6315 fprintf(stderr
, "mono_return_sbyte14 s14.f4: got %d but expected %d\n", s14
.f4
, 4);
6318 fprintf(stderr
, "mono_return_sbyte14 s14.f5: got %d but expected %d\n", s14
.f5
, 5);
6321 fprintf(stderr
, "mono_return_sbyte14 s14.f6: got %d but expected %d\n", s14
.f6
, 6);
6324 fprintf(stderr
, "mono_return_sbyte14 s14.f7: got %d but expected %d\n", s14
.f7
, 7);
6327 fprintf(stderr
, "mono_return_sbyte14 s14.f8: got %d but expected %d\n", s14
.f8
, 8);
6330 fprintf(stderr
, "mono_return_sbyte14 s14.f9: got %d but expected %d\n", s14
.f9
, 9);
6332 if (s14
.f10
!= 10) {
6333 fprintf(stderr
, "mono_return_sbyte14 s14.f10: got %d but expected %d\n", s14
.f10
, 10);
6335 if (s14
.f11
!= 11) {
6336 fprintf(stderr
, "mono_return_sbyte14 s14.f11: got %d but expected %d\n", s14
.f11
, 11);
6338 if (s14
.f12
!= 12) {
6339 fprintf(stderr
, "mono_return_sbyte14 s14.f12: got %d but expected %d\n", s14
.f12
, 12);
6341 if (s14
.f13
!= 13) {
6342 fprintf(stderr
, "mono_return_sbyte14 s14.f13: got %d but expected %d\n", s14
.f13
, 13);
6344 if (s14
.f14
!= 14) {
6345 fprintf(stderr
, "mono_return_sbyte14 s14.f14: got %d but expected %d\n", s14
.f14
, 14);
6347 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
;
6352 char f1
,f2
,f3
,f4
,f5
,f6
,f7
,f8
,f9
,f10
,f11
,f12
,f13
,f14
,f15
;
6355 LIBTEST_API sbyte15 STDCALL
6356 mono_return_sbyte15 (sbyte15 s15
, int addend
) {
6358 fprintf(stderr
, "mono_return_sbyte15 s15.f1: got %d but expected %d\n", s15
.f1
, 1);
6361 fprintf(stderr
, "mono_return_sbyte15 s15.f2: got %d but expected %d\n", s15
.f2
, 2);
6364 fprintf(stderr
, "mono_return_sbyte15 s15.f3: got %d but expected %d\n", s15
.f3
, 3);
6367 fprintf(stderr
, "mono_return_sbyte15 s15.f4: got %d but expected %d\n", s15
.f4
, 4);
6370 fprintf(stderr
, "mono_return_sbyte15 s15.f5: got %d but expected %d\n", s15
.f5
, 5);
6373 fprintf(stderr
, "mono_return_sbyte15 s15.f6: got %d but expected %d\n", s15
.f6
, 6);
6376 fprintf(stderr
, "mono_return_sbyte15 s15.f7: got %d but expected %d\n", s15
.f7
, 7);
6379 fprintf(stderr
, "mono_return_sbyte15 s15.f8: got %d but expected %d\n", s15
.f8
, 8);
6382 fprintf(stderr
, "mono_return_sbyte15 s15.f9: got %d but expected %d\n", s15
.f9
, 9);
6384 if (s15
.f10
!= 10) {
6385 fprintf(stderr
, "mono_return_sbyte15 s15.f10: got %d but expected %d\n", s15
.f10
, 10);
6387 if (s15
.f11
!= 11) {
6388 fprintf(stderr
, "mono_return_sbyte15 s15.f11: got %d but expected %d\n", s15
.f11
, 11);
6390 if (s15
.f12
!= 12) {
6391 fprintf(stderr
, "mono_return_sbyte15 s15.f12: got %d but expected %d\n", s15
.f12
, 12);
6393 if (s15
.f13
!= 13) {
6394 fprintf(stderr
, "mono_return_sbyte15 s15.f13: got %d but expected %d\n", s15
.f13
, 13);
6396 if (s15
.f14
!= 14) {
6397 fprintf(stderr
, "mono_return_sbyte15 s15.f14: got %d but expected %d\n", s15
.f14
, 14);
6399 if (s15
.f15
!= 15) {
6400 fprintf(stderr
, "mono_return_sbyte15 s15.f15: got %d but expected %d\n", s15
.f15
, 15);
6402 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
;
6407 char f1
,f2
,f3
,f4
,f5
,f6
,f7
,f8
,f9
,f10
,f11
,f12
,f13
,f14
,f15
,f16
;
6410 LIBTEST_API sbyte16 STDCALL
6411 mono_return_sbyte16 (sbyte16 s16
, int addend
) {
6413 fprintf(stderr
, "mono_return_sbyte16 s16.f1: got %d but expected %d\n", s16
.f1
, 1);
6416 fprintf(stderr
, "mono_return_sbyte16 s16.f2: got %d but expected %d\n", s16
.f2
, 2);
6419 fprintf(stderr
, "mono_return_sbyte16 s16.f3: got %d but expected %d\n", s16
.f3
, 3);
6422 fprintf(stderr
, "mono_return_sbyte16 s16.f4: got %d but expected %d\n", s16
.f4
, 4);
6425 fprintf(stderr
, "mono_return_sbyte16 s16.f5: got %d but expected %d\n", s16
.f5
, 5);
6428 fprintf(stderr
, "mono_return_sbyte16 s16.f6: got %d but expected %d\n", s16
.f6
, 6);
6431 fprintf(stderr
, "mono_return_sbyte16 s16.f7: got %d but expected %d\n", s16
.f7
, 7);
6434 fprintf(stderr
, "mono_return_sbyte16 s16.f8: got %d but expected %d\n", s16
.f8
, 8);
6437 fprintf(stderr
, "mono_return_sbyte16 s16.f9: got %d but expected %d\n", s16
.f9
, 9);
6439 if (s16
.f10
!= 10) {
6440 fprintf(stderr
, "mono_return_sbyte16 s16.f10: got %d but expected %d\n", s16
.f10
, 10);
6442 if (s16
.f11
!= 11) {
6443 fprintf(stderr
, "mono_return_sbyte16 s16.f11: got %d but expected %d\n", s16
.f11
, 11);
6445 if (s16
.f12
!= 12) {
6446 fprintf(stderr
, "mono_return_sbyte16 s16.f12: got %d but expected %d\n", s16
.f12
, 12);
6448 if (s16
.f13
!= 13) {
6449 fprintf(stderr
, "mono_return_sbyte16 s16.f13: got %d but expected %d\n", s16
.f13
, 13);
6451 if (s16
.f14
!= 14) {
6452 fprintf(stderr
, "mono_return_sbyte16 s16.f14: got %d but expected %d\n", s16
.f14
, 14);
6454 if (s16
.f15
!= 15) {
6455 fprintf(stderr
, "mono_return_sbyte16 s16.f15: got %d but expected %d\n", s16
.f15
, 15);
6457 if (s16
.f16
!= 16) {
6458 fprintf(stderr
, "mono_return_sbyte16 s16.f16: got %d but expected %d\n", s16
.f16
, 16);
6460 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
;
6465 char f1
,f2
,f3
,f4
,f5
,f6
,f7
,f8
,f9
,f10
,f11
,f12
,f13
,f14
,f15
,f16
,f17
;
6468 LIBTEST_API sbyte17 STDCALL
6469 mono_return_sbyte17 (sbyte17 s17
, int addend
) {
6471 fprintf(stderr
, "mono_return_sbyte17 s17.f1: got %d but expected %d\n", s17
.f1
, 1);
6474 fprintf(stderr
, "mono_return_sbyte17 s17.f2: got %d but expected %d\n", s17
.f2
, 2);
6477 fprintf(stderr
, "mono_return_sbyte17 s17.f3: got %d but expected %d\n", s17
.f3
, 3);
6480 fprintf(stderr
, "mono_return_sbyte17 s17.f4: got %d but expected %d\n", s17
.f4
, 4);
6483 fprintf(stderr
, "mono_return_sbyte17 s17.f5: got %d but expected %d\n", s17
.f5
, 5);
6486 fprintf(stderr
, "mono_return_sbyte17 s17.f6: got %d but expected %d\n", s17
.f6
, 6);
6489 fprintf(stderr
, "mono_return_sbyte17 s17.f7: got %d but expected %d\n", s17
.f7
, 7);
6492 fprintf(stderr
, "mono_return_sbyte17 s17.f8: got %d but expected %d\n", s17
.f8
, 8);
6495 fprintf(stderr
, "mono_return_sbyte17 s17.f9: got %d but expected %d\n", s17
.f9
, 9);
6497 if (s17
.f10
!= 10) {
6498 fprintf(stderr
, "mono_return_sbyte17 s17.f10: got %d but expected %d\n", s17
.f10
, 10);
6500 if (s17
.f11
!= 11) {
6501 fprintf(stderr
, "mono_return_sbyte17 s17.f11: got %d but expected %d\n", s17
.f11
, 11);
6503 if (s17
.f12
!= 12) {
6504 fprintf(stderr
, "mono_return_sbyte17 s17.f12: got %d but expected %d\n", s17
.f12
, 12);
6506 if (s17
.f13
!= 13) {
6507 fprintf(stderr
, "mono_return_sbyte17 s17.f13: got %d but expected %d\n", s17
.f13
, 13);
6509 if (s17
.f14
!= 14) {
6510 fprintf(stderr
, "mono_return_sbyte17 s17.f14: got %d but expected %d\n", s17
.f14
, 14);
6512 if (s17
.f15
!= 15) {
6513 fprintf(stderr
, "mono_return_sbyte17 s17.f15: got %d but expected %d\n", s17
.f15
, 15);
6515 if (s17
.f16
!= 16) {
6516 fprintf(stderr
, "mono_return_sbyte17 s17.f16: got %d but expected %d\n", s17
.f16
, 16);
6518 if (s17
.f17
!= 17) {
6519 fprintf(stderr
, "mono_return_sbyte17 s17.f17: got %d but expected %d\n", s17
.f17
, 17);
6521 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
;
6529 char f2
,f3
,f4
,f5
,f6
,f7
,f8
,f9
,f10
,f11
,f12
,f13
,f14
,f15
;
6535 LIBTEST_API sbyte16_nested STDCALL
6536 mono_return_sbyte16_nested (sbyte16_nested sn16
, int addend
) {
6537 if (sn16
.nested1
.f1
!= 1) {
6538 fprintf(stderr
, "mono_return_sbyte16_nested sn16.nested1.f1: got %d but expected %d\n", sn16
.nested1
.f1
, 1);
6541 fprintf(stderr
, "mono_return_sbyte16_nested sn16.f2: got %d but expected %d\n", sn16
.f2
, 2);
6544 fprintf(stderr
, "mono_return_sbyte16_nested sn16.f3: got %d but expected %d\n", sn16
.f3
, 3);
6547 fprintf(stderr
, "mono_return_sbyte16_nested sn16.f4: got %d but expected %d\n", sn16
.f4
, 4);
6550 fprintf(stderr
, "mono_return_sbyte16_nested sn16.f5: got %d but expected %d\n", sn16
.f5
, 5);
6553 fprintf(stderr
, "mono_return_sbyte16_nested sn16.f6: got %d but expected %d\n", sn16
.f6
, 6);
6556 fprintf(stderr
, "mono_return_sbyte16_nested sn16.f7: got %d but expected %d\n", sn16
.f7
, 7);
6559 fprintf(stderr
, "mono_return_sbyte16_nested sn16.f8: got %d but expected %d\n", sn16
.f8
, 8);
6562 fprintf(stderr
, "mono_return_sbyte16_nested sn16.f9: got %d but expected %d\n", sn16
.f9
, 9);
6564 if (sn16
.f10
!= 10) {
6565 fprintf(stderr
, "mono_return_sbyte16_nested sn16.f10: got %d but expected %d\n", sn16
.f10
, 10);
6567 if (sn16
.f11
!= 11) {
6568 fprintf(stderr
, "mono_return_sbyte16_nested sn16.f11: got %d but expected %d\n", sn16
.f11
, 11);
6570 if (sn16
.f12
!= 12) {
6571 fprintf(stderr
, "mono_return_sbyte16_nested sn16.f12: got %d but expected %d\n", sn16
.f12
, 12);
6573 if (sn16
.f13
!= 13) {
6574 fprintf(stderr
, "mono_return_sbyte16_nested sn16.f13: got %d but expected %d\n", sn16
.f13
, 13);
6576 if (sn16
.f14
!= 14) {
6577 fprintf(stderr
, "mono_return_sbyte16_nested sn16.f14: got %d but expected %d\n", sn16
.f14
, 14);
6579 if (sn16
.f15
!= 15) {
6580 fprintf(stderr
, "mono_return_sbyte16_nested sn16.f15: got %d but expected %d\n", sn16
.f15
, 15);
6582 if (sn16
.nested2
.f16
!= 16) {
6583 fprintf(stderr
, "mono_return_sbyte16_nested sn16.nested2.f16: got %d but expected %d\n", sn16
.nested2
.f16
, 16);
6585 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
;
6594 LIBTEST_API short1 STDCALL
6595 mono_return_short1 (short1 s1
, int addend
) {
6597 fprintf(stderr
, "mono_return_short1 s1.f1: got %d but expected %d\n", s1
.f1
, 1);
6607 LIBTEST_API short2 STDCALL
6608 mono_return_short2 (short2 s2
, int addend
) {
6610 fprintf(stderr
, "mono_return_short2 s2.f1: got %d but expected %d\n", s2
.f1
, 1);
6613 fprintf(stderr
, "mono_return_short2 s2.f2: got %d but expected %d\n", s2
.f2
, 2);
6615 s2
.f1
+=addend
; s2
.f2
+=addend
;
6623 LIBTEST_API short3 STDCALL
6624 mono_return_short3 (short3 s3
, int addend
) {
6626 fprintf(stderr
, "mono_return_short3 s3.f1: got %d but expected %d\n", s3
.f1
, 1);
6629 fprintf(stderr
, "mono_return_short3 s3.f2: got %d but expected %d\n", s3
.f2
, 2);
6632 fprintf(stderr
, "mono_return_short3 s3.f3: got %d but expected %d\n", s3
.f3
, 3);
6634 s3
.f1
+=addend
; s3
.f2
+=addend
; s3
.f3
+=addend
;
6642 LIBTEST_API short4 STDCALL
6643 mono_return_short4 (short4 s4
, int addend
) {
6645 fprintf(stderr
, "mono_return_short4 s4.f1: got %d but expected %d\n", s4
.f1
, 1);
6648 fprintf(stderr
, "mono_return_short4 s4.f2: got %d but expected %d\n", s4
.f2
, 2);
6651 fprintf(stderr
, "mono_return_short4 s4.f3: got %d but expected %d\n", s4
.f3
, 3);
6654 fprintf(stderr
, "mono_return_short4 s4.f4: got %d but expected %d\n", s4
.f4
, 4);
6656 s4
.f1
+=addend
; s4
.f2
+=addend
; s4
.f3
+=addend
; s4
.f4
+=addend
;
6661 short f1
,f2
,f3
,f4
,f5
;
6664 LIBTEST_API short5 STDCALL
6665 mono_return_short5 (short5 s5
, int addend
) {
6667 fprintf(stderr
, "mono_return_short5 s5.f1: got %d but expected %d\n", s5
.f1
, 1);
6670 fprintf(stderr
, "mono_return_short5 s5.f2: got %d but expected %d\n", s5
.f2
, 2);
6673 fprintf(stderr
, "mono_return_short5 s5.f3: got %d but expected %d\n", s5
.f3
, 3);
6676 fprintf(stderr
, "mono_return_short5 s5.f4: got %d but expected %d\n", s5
.f4
, 4);
6679 fprintf(stderr
, "mono_return_short5 s5.f5: got %d but expected %d\n", s5
.f5
, 5);
6681 s5
.f1
+=addend
; s5
.f2
+=addend
; s5
.f3
+=addend
; s5
.f4
+=addend
; s5
.f5
+=addend
;
6686 short f1
,f2
,f3
,f4
,f5
,f6
;
6689 LIBTEST_API short6 STDCALL
6690 mono_return_short6 (short6 s6
, int addend
) {
6692 fprintf(stderr
, "mono_return_short6 s6.f1: got %d but expected %d\n", s6
.f1
, 1);
6695 fprintf(stderr
, "mono_return_short6 s6.f2: got %d but expected %d\n", s6
.f2
, 2);
6698 fprintf(stderr
, "mono_return_short6 s6.f3: got %d but expected %d\n", s6
.f3
, 3);
6701 fprintf(stderr
, "mono_return_short6 s6.f4: got %d but expected %d\n", s6
.f4
, 4);
6704 fprintf(stderr
, "mono_return_short6 s6.f5: got %d but expected %d\n", s6
.f5
, 5);
6707 fprintf(stderr
, "mono_return_short6 s6.f6: got %d but expected %d\n", s6
.f6
, 6);
6709 s6
.f1
+=addend
; s6
.f2
+=addend
; s6
.f3
+=addend
; s6
.f4
+=addend
; s6
.f5
+=addend
; s6
.f6
+=addend
;
6714 short f1
,f2
,f3
,f4
,f5
,f6
,f7
;
6717 LIBTEST_API short7 STDCALL
6718 mono_return_short7 (short7 s7
, int addend
) {
6720 fprintf(stderr
, "mono_return_short7 s7.f1: got %d but expected %d\n", s7
.f1
, 1);
6723 fprintf(stderr
, "mono_return_short7 s7.f2: got %d but expected %d\n", s7
.f2
, 2);
6726 fprintf(stderr
, "mono_return_short7 s7.f3: got %d but expected %d\n", s7
.f3
, 3);
6729 fprintf(stderr
, "mono_return_short7 s7.f4: got %d but expected %d\n", s7
.f4
, 4);
6732 fprintf(stderr
, "mono_return_short7 s7.f5: got %d but expected %d\n", s7
.f5
, 5);
6735 fprintf(stderr
, "mono_return_short7 s7.f6: got %d but expected %d\n", s7
.f6
, 6);
6738 fprintf(stderr
, "mono_return_short7 s7.f7: got %d but expected %d\n", s7
.f7
, 7);
6740 s7
.f1
+=addend
; s7
.f2
+=addend
; s7
.f3
+=addend
; s7
.f4
+=addend
; s7
.f5
+=addend
; s7
.f6
+=addend
; s7
.f7
+=addend
;
6745 short f1
,f2
,f3
,f4
,f5
,f6
,f7
,f8
;
6748 LIBTEST_API short8 STDCALL
6749 mono_return_short8 (short8 s8
, int addend
) {
6751 fprintf(stderr
, "mono_return_short8 s8.f1: got %d but expected %d\n", s8
.f1
, 1);
6754 fprintf(stderr
, "mono_return_short8 s8.f2: got %d but expected %d\n", s8
.f2
, 2);
6757 fprintf(stderr
, "mono_return_short8 s8.f3: got %d but expected %d\n", s8
.f3
, 3);
6760 fprintf(stderr
, "mono_return_short8 s8.f4: got %d but expected %d\n", s8
.f4
, 4);
6763 fprintf(stderr
, "mono_return_short8 s8.f5: got %d but expected %d\n", s8
.f5
, 5);
6766 fprintf(stderr
, "mono_return_short8 s8.f6: got %d but expected %d\n", s8
.f6
, 6);
6769 fprintf(stderr
, "mono_return_short8 s8.f7: got %d but expected %d\n", s8
.f7
, 7);
6772 fprintf(stderr
, "mono_return_short8 s8.f8: got %d but expected %d\n", s8
.f8
, 8);
6774 s8
.f1
+=addend
; s8
.f2
+=addend
; s8
.f3
+=addend
; s8
.f4
+=addend
; s8
.f5
+=addend
; s8
.f6
+=addend
; s8
.f7
+=addend
; s8
.f8
+=addend
;
6779 short f1
,f2
,f3
,f4
,f5
,f6
,f7
,f8
,f9
;
6782 LIBTEST_API short9 STDCALL
6783 mono_return_short9 (short9 s9
, int addend
) {
6785 fprintf(stderr
, "mono_return_short9 s9.f1: got %d but expected %d\n", s9
.f1
, 1);
6788 fprintf(stderr
, "mono_return_short9 s9.f2: got %d but expected %d\n", s9
.f2
, 2);
6791 fprintf(stderr
, "mono_return_short9 s9.f3: got %d but expected %d\n", s9
.f3
, 3);
6794 fprintf(stderr
, "mono_return_short9 s9.f4: got %d but expected %d\n", s9
.f4
, 4);
6797 fprintf(stderr
, "mono_return_short9 s9.f5: got %d but expected %d\n", s9
.f5
, 5);
6800 fprintf(stderr
, "mono_return_short9 s9.f6: got %d but expected %d\n", s9
.f6
, 6);
6803 fprintf(stderr
, "mono_return_short9 s9.f7: got %d but expected %d\n", s9
.f7
, 7);
6806 fprintf(stderr
, "mono_return_short9 s9.f8: got %d but expected %d\n", s9
.f8
, 8);
6809 fprintf(stderr
, "mono_return_short9 s9.f9: got %d but expected %d\n", s9
.f9
, 9);
6811 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
;
6819 short f2
,f3
,f4
,f5
,f6
,f7
;
6825 LIBTEST_API short8_nested STDCALL
6826 mono_return_short8_nested (short8_nested sn8
, int addend
) {
6827 if (sn8
.nested1
.f1
!= 1) {
6828 fprintf(stderr
, "mono_return_short8_nested sn8.nested1.f1: got %d but expected %d\n", sn8
.nested1
.f1
, 1);
6831 fprintf(stderr
, "mono_return_short8_nested sn8.f2: got %d but expected %d\n", sn8
.f2
, 2);
6834 fprintf(stderr
, "mono_return_short8_nested sn8.f3: got %d but expected %d\n", sn8
.f3
, 3);
6837 fprintf(stderr
, "mono_return_short8_nested sn8.f4: got %d but expected %d\n", sn8
.f4
, 4);
6840 fprintf(stderr
, "mono_return_short8_nested sn8.f5: got %d but expected %d\n", sn8
.f5
, 5);
6843 fprintf(stderr
, "mono_return_short8_nested sn8.f6: got %d but expected %d\n", sn8
.f6
, 6);
6846 fprintf(stderr
, "mono_return_short8_nested sn8.f7: got %d but expected %d\n", sn8
.f7
, 7);
6848 if (sn8
.nested2
.f8
!= 8) {
6849 fprintf(stderr
, "mono_return_short8_nested sn8.nested2.f8: got %d but expected %d\n", sn8
.nested2
.f8
, 8);
6851 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
;
6860 LIBTEST_API int1 STDCALL
6861 mono_return_int1 (int1 s1
, int addend
) {
6863 fprintf(stderr
, "mono_return_int1 s1.f1: got %d but expected %d\n", s1
.f1
, 1);
6873 LIBTEST_API int2 STDCALL
6874 mono_return_int2 (int2 s2
, int addend
) {
6876 fprintf(stderr
, "mono_return_int2 s2.f1: got %d but expected %d\n", s2
.f1
, 1);
6879 fprintf(stderr
, "mono_return_int2 s2.f2: got %d but expected %d\n", s2
.f2
, 2);
6881 s2
.f1
+=addend
; s2
.f2
+=addend
;
6889 LIBTEST_API int3 STDCALL
6890 mono_return_int3 (int3 s3
, int addend
) {
6892 fprintf(stderr
, "mono_return_int3 s3.f1: got %d but expected %d\n", s3
.f1
, 1);
6895 fprintf(stderr
, "mono_return_int3 s3.f2: got %d but expected %d\n", s3
.f2
, 2);
6898 fprintf(stderr
, "mono_return_int3 s3.f3: got %d but expected %d\n", s3
.f3
, 3);
6900 s3
.f1
+=addend
; s3
.f2
+=addend
; s3
.f3
+=addend
;
6908 LIBTEST_API int4 STDCALL
6909 mono_return_int4 (int4 s4
, int addend
) {
6911 fprintf(stderr
, "mono_return_int4 s4.f1: got %d but expected %d\n", s4
.f1
, 1);
6914 fprintf(stderr
, "mono_return_int4 s4.f2: got %d but expected %d\n", s4
.f2
, 2);
6917 fprintf(stderr
, "mono_return_int4 s4.f3: got %d but expected %d\n", s4
.f3
, 3);
6920 fprintf(stderr
, "mono_return_int4 s4.f4: got %d but expected %d\n", s4
.f4
, 4);
6922 s4
.f1
+=addend
; s4
.f2
+=addend
; s4
.f3
+=addend
; s4
.f4
+=addend
;
6930 LIBTEST_API int5 STDCALL
6931 mono_return_int5 (int5 s5
, int addend
) {
6933 fprintf(stderr
, "mono_return_int5 s5.f1: got %d but expected %d\n", s5
.f1
, 1);
6936 fprintf(stderr
, "mono_return_int5 s5.f2: got %d but expected %d\n", s5
.f2
, 2);
6939 fprintf(stderr
, "mono_return_int5 s5.f3: got %d but expected %d\n", s5
.f3
, 3);
6942 fprintf(stderr
, "mono_return_int5 s5.f4: got %d but expected %d\n", s5
.f4
, 4);
6945 fprintf(stderr
, "mono_return_int5 s5.f5: got %d but expected %d\n", s5
.f5
, 5);
6947 s5
.f1
+=addend
; s5
.f2
+=addend
; s5
.f3
+=addend
; s5
.f4
+=addend
; s5
.f5
+=addend
;
6961 LIBTEST_API int4_nested STDCALL
6962 mono_return_int4_nested (int4_nested sn4
, int addend
) {
6963 if (sn4
.nested1
.f1
!= 1) {
6964 fprintf(stderr
, "mono_return_int4_nested sn4.nested1.f1: got %d but expected %d\n", sn4
.nested1
.f1
, 1);
6967 fprintf(stderr
, "mono_return_int4_nested sn4.f2: got %d but expected %d\n", sn4
.f2
, 2);
6970 fprintf(stderr
, "mono_return_int4_nested sn4.f3: got %d but expected %d\n", sn4
.f3
, 3);
6972 if (sn4
.nested2
.f4
!= 4) {
6973 fprintf(stderr
, "mono_return_int4_nested sn4.nested2.f4: got %d but expected %d\n", sn4
.nested2
.f4
, 4);
6975 sn4
.nested1
.f1
+=addend
; sn4
.f2
+=addend
; sn4
.f3
+=addend
; sn4
.nested2
.f4
+=addend
;
6983 LIBTEST_API float1 STDCALL
6984 mono_return_float1 (float1 s1
, int addend
) {
6986 fprintf(stderr
, "mono_return_float1 s1.f1: got %f but expected %d\n", s1
.f1
, 1);
6996 LIBTEST_API float2 STDCALL
6997 mono_return_float2 (float2 s2
, int addend
) {
6999 fprintf(stderr
, "mono_return_float2 s2.f1: got %f but expected %d\n", s2
.f1
, 1);
7002 fprintf(stderr
, "mono_return_float2 s2.f2: got %f but expected %d\n", s2
.f2
, 2);
7004 s2
.f1
+=addend
; s2
.f2
+=addend
;
7012 LIBTEST_API float3 STDCALL
7013 mono_return_float3 (float3 s3
, int addend
) {
7015 fprintf(stderr
, "mono_return_float3 s3.f1: got %f but expected %d\n", s3
.f1
, 1);
7018 fprintf(stderr
, "mono_return_float3 s3.f2: got %f but expected %d\n", s3
.f2
, 2);
7021 fprintf(stderr
, "mono_return_float3 s3.f3: got %f but expected %d\n", s3
.f3
, 3);
7023 s3
.f1
+=addend
; s3
.f2
+=addend
; s3
.f3
+=addend
;
7031 LIBTEST_API float4 STDCALL
7032 mono_return_float4 (float4 s4
, int addend
) {
7034 fprintf(stderr
, "mono_return_float4 s4.f1: got %f but expected %d\n", s4
.f1
, 1);
7037 fprintf(stderr
, "mono_return_float4 s4.f2: got %f but expected %d\n", s4
.f2
, 2);
7040 fprintf(stderr
, "mono_return_float4 s4.f3: got %f but expected %d\n", s4
.f3
, 3);
7043 fprintf(stderr
, "mono_return_float4 s4.f4: got %f but expected %d\n", s4
.f4
, 4);
7045 s4
.f1
+=addend
; s4
.f2
+=addend
; s4
.f3
+=addend
; s4
.f4
+=addend
;
7050 float f1
,f2
,f3
,f4
,f5
;
7053 LIBTEST_API float5 STDCALL
7054 mono_return_float5 (float5 s5
, int addend
) {
7056 fprintf(stderr
, "mono_return_float5 s5.f1: got %f but expected %d\n", s5
.f1
, 1);
7059 fprintf(stderr
, "mono_return_float5 s5.f2: got %f but expected %d\n", s5
.f2
, 2);
7062 fprintf(stderr
, "mono_return_float5 s5.f3: got %f but expected %d\n", s5
.f3
, 3);
7065 fprintf(stderr
, "mono_return_float5 s5.f4: got %f but expected %d\n", s5
.f4
, 4);
7068 fprintf(stderr
, "mono_return_float5 s5.f5: got %f but expected %d\n", s5
.f5
, 5);
7070 s5
.f1
+=addend
; s5
.f2
+=addend
; s5
.f3
+=addend
; s5
.f4
+=addend
; s5
.f5
+=addend
;
7075 float f1
,f2
,f3
,f4
,f5
,f6
;
7078 LIBTEST_API float6 STDCALL
7079 mono_return_float6 (float6 s6
, int addend
) {
7081 fprintf(stderr
, "mono_return_float6 s6.f1: got %f but expected %d\n", s6
.f1
, 1);
7084 fprintf(stderr
, "mono_return_float6 s6.f2: got %f but expected %d\n", s6
.f2
, 2);
7087 fprintf(stderr
, "mono_return_float6 s6.f3: got %f but expected %d\n", s6
.f3
, 3);
7090 fprintf(stderr
, "mono_return_float6 s6.f4: got %f but expected %d\n", s6
.f4
, 4);
7093 fprintf(stderr
, "mono_return_float6 s6.f5: got %f but expected %d\n", s6
.f5
, 5);
7096 fprintf(stderr
, "mono_return_float6 s6.f6: got %f but expected %d\n", s6
.f6
, 6);
7098 s6
.f1
+=addend
; s6
.f2
+=addend
; s6
.f3
+=addend
; s6
.f4
+=addend
; s6
.f5
+=addend
; s6
.f6
+=addend
;
7103 float f1
,f2
,f3
,f4
,f5
,f6
,f7
;
7106 LIBTEST_API float7 STDCALL
7107 mono_return_float7 (float7 s7
, int addend
) {
7109 fprintf(stderr
, "mono_return_float7 s7.f1: got %f but expected %d\n", s7
.f1
, 1);
7112 fprintf(stderr
, "mono_return_float7 s7.f2: got %f but expected %d\n", s7
.f2
, 2);
7115 fprintf(stderr
, "mono_return_float7 s7.f3: got %f but expected %d\n", s7
.f3
, 3);
7118 fprintf(stderr
, "mono_return_float7 s7.f4: got %f but expected %d\n", s7
.f4
, 4);
7121 fprintf(stderr
, "mono_return_float7 s7.f5: got %f but expected %d\n", s7
.f5
, 5);
7124 fprintf(stderr
, "mono_return_float7 s7.f6: got %f but expected %d\n", s7
.f6
, 6);
7127 fprintf(stderr
, "mono_return_float7 s7.f7: got %f but expected %d\n", s7
.f7
, 7);
7129 s7
.f1
+=addend
; s7
.f2
+=addend
; s7
.f3
+=addend
; s7
.f4
+=addend
; s7
.f5
+=addend
; s7
.f6
+=addend
; s7
.f7
+=addend
;
7134 float f1
,f2
,f3
,f4
,f5
,f6
,f7
,f8
;
7137 LIBTEST_API float8 STDCALL
7138 mono_return_float8 (float8 s8
, int addend
) {
7140 fprintf(stderr
, "mono_return_float8 s8.f1: got %f but expected %d\n", s8
.f1
, 1);
7143 fprintf(stderr
, "mono_return_float8 s8.f2: got %f but expected %d\n", s8
.f2
, 2);
7146 fprintf(stderr
, "mono_return_float8 s8.f3: got %f but expected %d\n", s8
.f3
, 3);
7149 fprintf(stderr
, "mono_return_float8 s8.f4: got %f but expected %d\n", s8
.f4
, 4);
7152 fprintf(stderr
, "mono_return_float8 s8.f5: got %f but expected %d\n", s8
.f5
, 5);
7155 fprintf(stderr
, "mono_return_float8 s8.f6: got %f but expected %d\n", s8
.f6
, 6);
7158 fprintf(stderr
, "mono_return_float8 s8.f7: got %f but expected %d\n", s8
.f7
, 7);
7161 fprintf(stderr
, "mono_return_float8 s8.f8: got %f but expected %d\n", s8
.f8
, 8);
7163 s8
.f1
+=addend
; s8
.f2
+=addend
; s8
.f3
+=addend
; s8
.f4
+=addend
; s8
.f5
+=addend
; s8
.f6
+=addend
; s8
.f7
+=addend
; s8
.f8
+=addend
;
7168 float f1
,f2
,f3
,f4
,f5
,f6
,f7
,f8
,f9
;
7171 LIBTEST_API float9 STDCALL
7172 mono_return_float9 (float9 s9
, int addend
) {
7174 fprintf(stderr
, "mono_return_float9 s9.f1: got %f but expected %d\n", s9
.f1
, 1);
7177 fprintf(stderr
, "mono_return_float9 s9.f2: got %f but expected %d\n", s9
.f2
, 2);
7180 fprintf(stderr
, "mono_return_float9 s9.f3: got %f but expected %d\n", s9
.f3
, 3);
7183 fprintf(stderr
, "mono_return_float9 s9.f4: got %f but expected %d\n", s9
.f4
, 4);
7186 fprintf(stderr
, "mono_return_float9 s9.f5: got %f but expected %d\n", s9
.f5
, 5);
7189 fprintf(stderr
, "mono_return_float9 s9.f6: got %f but expected %d\n", s9
.f6
, 6);
7192 fprintf(stderr
, "mono_return_float9 s9.f7: got %f but expected %d\n", s9
.f7
, 7);
7195 fprintf(stderr
, "mono_return_float9 s9.f8: got %f but expected %d\n", s9
.f8
, 8);
7198 fprintf(stderr
, "mono_return_float9 s9.f9: got %f but expected %d\n", s9
.f9
, 9);
7200 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
;
7214 LIBTEST_API float4_nested STDCALL
7215 mono_return_float4_nested (float4_nested sn4
, int addend
) {
7216 if (sn4
.nested1
.f1
!= 1) {
7217 fprintf(stderr
, "mono_return_float4_nested sn4.nested1.f1: got %f but expected %d\n", sn4
.nested1
.f1
, 1);
7220 fprintf(stderr
, "mono_return_float4_nested sn4.f2: got %f but expected %d\n", sn4
.f2
, 2);
7223 fprintf(stderr
, "mono_return_float4_nested sn4.f3: got %f but expected %d\n", sn4
.f3
, 3);
7225 if (sn4
.nested2
.f4
!= 4) {
7226 fprintf(stderr
, "mono_return_float4_nested sn4.nested2.f4: got %f but expected %d\n", sn4
.nested2
.f4
, 4);
7228 sn4
.nested1
.f1
+=addend
; sn4
.f2
+=addend
; sn4
.f3
+=addend
; sn4
.nested2
.f4
+=addend
;
7236 LIBTEST_API double1 STDCALL
7237 mono_return_double1 (double1 s1
, int addend
) {
7239 fprintf(stderr
, "mono_return_double1 s1.f1: got %f but expected %d\n", s1
.f1
, 1);
7249 LIBTEST_API double2 STDCALL
7250 mono_return_double2 (double2 s2
, int addend
) {
7252 fprintf(stderr
, "mono_return_double2 s2.f1: got %f but expected %d\n", s2
.f1
, 1);
7255 fprintf(stderr
, "mono_return_double2 s2.f2: got %f but expected %d\n", s2
.f2
, 2);
7257 s2
.f1
+=addend
; s2
.f2
+=addend
;
7265 LIBTEST_API double3 STDCALL
7266 mono_return_double3 (double3 s3
, int addend
) {
7268 fprintf(stderr
, "mono_return_double3 s3.f1: got %f but expected %d\n", s3
.f1
, 1);
7271 fprintf(stderr
, "mono_return_double3 s3.f2: got %f but expected %d\n", s3
.f2
, 2);
7274 fprintf(stderr
, "mono_return_double3 s3.f3: got %f but expected %d\n", s3
.f3
, 3);
7276 s3
.f1
+=addend
; s3
.f2
+=addend
; s3
.f3
+=addend
;
7284 LIBTEST_API double4 STDCALL
7285 mono_return_double4 (double4 s4
, int addend
) {
7287 fprintf(stderr
, "mono_return_double4 s4.f1: got %f but expected %d\n", s4
.f1
, 1);
7290 fprintf(stderr
, "mono_return_double4 s4.f2: got %f but expected %d\n", s4
.f2
, 2);
7293 fprintf(stderr
, "mono_return_double4 s4.f3: got %f but expected %d\n", s4
.f3
, 3);
7296 fprintf(stderr
, "mono_return_double4 s4.f4: got %f but expected %d\n", s4
.f4
, 4);
7298 s4
.f1
+=addend
; s4
.f2
+=addend
; s4
.f3
+=addend
; s4
.f4
+=addend
;
7303 double f1
,f2
,f3
,f4
,f5
;
7306 LIBTEST_API double5 STDCALL
7307 mono_return_double5 (double5 s5
, int addend
) {
7309 fprintf(stderr
, "mono_return_double5 s5.f1: got %f but expected %d\n", s5
.f1
, 1);
7312 fprintf(stderr
, "mono_return_double5 s5.f2: got %f but expected %d\n", s5
.f2
, 2);
7315 fprintf(stderr
, "mono_return_double5 s5.f3: got %f but expected %d\n", s5
.f3
, 3);
7318 fprintf(stderr
, "mono_return_double5 s5.f4: got %f but expected %d\n", s5
.f4
, 4);
7321 fprintf(stderr
, "mono_return_double5 s5.f5: got %f but expected %d\n", s5
.f5
, 5);
7323 s5
.f1
+=addend
; s5
.f2
+=addend
; s5
.f3
+=addend
; s5
.f4
+=addend
; s5
.f5
+=addend
;
7328 double f1
,f2
,f3
,f4
,f5
,f6
;
7331 LIBTEST_API double6 STDCALL
7332 mono_return_double6 (double6 s6
, int addend
) {
7334 fprintf(stderr
, "mono_return_double6 s6.f1: got %f but expected %d\n", s6
.f1
, 1);
7337 fprintf(stderr
, "mono_return_double6 s6.f2: got %f but expected %d\n", s6
.f2
, 2);
7340 fprintf(stderr
, "mono_return_double6 s6.f3: got %f but expected %d\n", s6
.f3
, 3);
7343 fprintf(stderr
, "mono_return_double6 s6.f4: got %f but expected %d\n", s6
.f4
, 4);
7346 fprintf(stderr
, "mono_return_double6 s6.f5: got %f but expected %d\n", s6
.f5
, 5);
7349 fprintf(stderr
, "mono_return_double6 s6.f6: got %f but expected %d\n", s6
.f6
, 6);
7351 s6
.f1
+=addend
; s6
.f2
+=addend
; s6
.f3
+=addend
; s6
.f4
+=addend
; s6
.f5
+=addend
; s6
.f6
+=addend
;
7356 double f1
,f2
,f3
,f4
,f5
,f6
,f7
;
7359 LIBTEST_API double7 STDCALL
7360 mono_return_double7 (double7 s7
, int addend
) {
7362 fprintf(stderr
, "mono_return_double7 s7.f1: got %f but expected %d\n", s7
.f1
, 1);
7365 fprintf(stderr
, "mono_return_double7 s7.f2: got %f but expected %d\n", s7
.f2
, 2);
7368 fprintf(stderr
, "mono_return_double7 s7.f3: got %f but expected %d\n", s7
.f3
, 3);
7371 fprintf(stderr
, "mono_return_double7 s7.f4: got %f but expected %d\n", s7
.f4
, 4);
7374 fprintf(stderr
, "mono_return_double7 s7.f5: got %f but expected %d\n", s7
.f5
, 5);
7377 fprintf(stderr
, "mono_return_double7 s7.f6: got %f but expected %d\n", s7
.f6
, 6);
7380 fprintf(stderr
, "mono_return_double7 s7.f7: got %f but expected %d\n", s7
.f7
, 7);
7382 s7
.f1
+=addend
; s7
.f2
+=addend
; s7
.f3
+=addend
; s7
.f4
+=addend
; s7
.f5
+=addend
; s7
.f6
+=addend
; s7
.f7
+=addend
;
7387 double f1
,f2
,f3
,f4
,f5
,f6
,f7
,f8
;
7390 LIBTEST_API double8 STDCALL
7391 mono_return_double8 (double8 s8
, int addend
) {
7393 fprintf(stderr
, "mono_return_double8 s8.f1: got %f but expected %d\n", s8
.f1
, 1);
7396 fprintf(stderr
, "mono_return_double8 s8.f2: got %f but expected %d\n", s8
.f2
, 2);
7399 fprintf(stderr
, "mono_return_double8 s8.f3: got %f but expected %d\n", s8
.f3
, 3);
7402 fprintf(stderr
, "mono_return_double8 s8.f4: got %f but expected %d\n", s8
.f4
, 4);
7405 fprintf(stderr
, "mono_return_double8 s8.f5: got %f but expected %d\n", s8
.f5
, 5);
7408 fprintf(stderr
, "mono_return_double8 s8.f6: got %f but expected %d\n", s8
.f6
, 6);
7411 fprintf(stderr
, "mono_return_double8 s8.f7: got %f but expected %d\n", s8
.f7
, 7);
7414 fprintf(stderr
, "mono_return_double8 s8.f8: got %f but expected %d\n", s8
.f8
, 8);
7416 s8
.f1
+=addend
; s8
.f2
+=addend
; s8
.f3
+=addend
; s8
.f4
+=addend
; s8
.f5
+=addend
; s8
.f6
+=addend
; s8
.f7
+=addend
; s8
.f8
+=addend
;
7421 double f1
,f2
,f3
,f4
,f5
,f6
,f7
,f8
,f9
;
7424 LIBTEST_API double9 STDCALL
7425 mono_return_double9 (double9 s9
, int addend
) {
7427 fprintf(stderr
, "mono_return_double9 s9.f1: got %f but expected %d\n", s9
.f1
, 1);
7430 fprintf(stderr
, "mono_return_double9 s9.f2: got %f but expected %d\n", s9
.f2
, 2);
7433 fprintf(stderr
, "mono_return_double9 s9.f3: got %f but expected %d\n", s9
.f3
, 3);
7436 fprintf(stderr
, "mono_return_double9 s9.f4: got %f but expected %d\n", s9
.f4
, 4);
7439 fprintf(stderr
, "mono_return_double9 s9.f5: got %f but expected %d\n", s9
.f5
, 5);
7442 fprintf(stderr
, "mono_return_double9 s9.f6: got %f but expected %d\n", s9
.f6
, 6);
7445 fprintf(stderr
, "mono_return_double9 s9.f7: got %f but expected %d\n", s9
.f7
, 7);
7448 fprintf(stderr
, "mono_return_double9 s9.f8: got %f but expected %d\n", s9
.f8
, 8);
7451 fprintf(stderr
, "mono_return_double9 s9.f9: got %f but expected %d\n", s9
.f9
, 9);
7453 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
;
7466 LIBTEST_API double2_nested STDCALL
7467 mono_return_double2_nested (double2_nested sn2
, int addend
) {
7468 if (sn2
.nested1
.f1
!= 1) {
7469 fprintf(stderr
, "mono_return_double2_nested sn2.nested1.f1: got %f but expected %d\n", sn2
.nested1
.f1
, 1);
7471 if (sn2
.nested2
.f2
!= 2) {
7472 fprintf(stderr
, "mono_return_double2_nested sn2.nested2.f2: got %f but expected %d\n", sn2
.nested2
.f2
, 2);
7474 sn2
.nested1
.f1
+=addend
; sn2
.nested2
.f2
+=addend
;
7484 LIBTEST_API double_array4 STDCALL
7485 mono_return_double_array4 (double_array4 sa4
, int addend
) {
7486 if (sa4
.f1
[0] != 1) {
7487 fprintf(stderr
, "mono_return_double_array4 sa4.f1[0]: got %f but expected %d\n", sa4
.f1
[0], 1);
7489 if (sa4
.f1
[1] != 2) {
7490 fprintf(stderr
, "mono_return_double_array4 sa4.f1[1]: got %f but expected %d\n", sa4
.f1
[1], 2);
7492 if (sa4
.f1
[2] != 3) {
7493 fprintf(stderr
, "mono_return_double_array4 sa4.f1[2]: got %f but expected %d\n", sa4
.f1
[2], 3);
7495 if (sa4
.f1
[3] != 4) {
7496 fprintf(stderr
, "mono_return_double_array4 sa4.f1[3]: got %f but expected %d\n", sa4
.f1
[3], 4);
7498 sa4
.f1
[0]+=addend
; sa4
.f1
[1]+=addend
; sa4
.f1
[2]+=addend
; sa4
.f1
[3]+=addend
;
7506 LIBTEST_API
int STDCALL
7507 mono_test_marshal_fixed_array (FixedArrayStruct s
)
7509 return s
.array
[0] + s
.array
[1] + s
.array
[2];
7517 LIBTEST_API
int STDCALL
7518 mono_test_marshal_fixed_buffer_char (FixedBufferChar
*s
)
7520 if (!(s
->array
[0] == 'A' && s
->array
[1] == 'B' && s
->array
[2] == 'C' && s
->c
== 'D'))
7531 } FixedBufferUnicode
;
7533 LIBTEST_API
int STDCALL
7534 mono_test_marshal_fixed_buffer_unicode (FixedBufferUnicode
*s
)
7536 if (!(s
->array
[0] == 'A' && s
->array
[1] == 'B' && s
->array
[2] == 'C' && s
->c
== 'D'))
7544 const int NSTRINGS
= 6;
7546 const char *utf8Strings
[] = {
7548 "Sîne klâwen durh die wolken sint geslagen" ,
7549 "काचं शक्नोम्यत्तुम् । नोपहिनस्ति माम्",
7551 "ღმერთსი შემვედრე,შემვედრე, ნუთუ კვლა დამხსნას შემვედრე,სოფლისა შემვედრე, შემვედრე,შემვედრე,შემვედრე,შრომასა, ცეცხლს, წყალსა და მიწასა, ჰაერთა თანა მრომასა; მომცნეს ფრთენი და აღვფრინდე, მივჰხვდე მას ჩემსა ნდომასა, დღისით და ღამით ვჰხედვიდე მზისა ელვათა კრთომაასაშემვედრე,შემვედრე,",
7552 "Τη γλώσσα μου έδωσαν ελληνική",
7557 build_return_string(const char* pReturn
)
7560 if (pReturn
== 0 || *pReturn
== 0)
7563 size_t strLength
= strlen(pReturn
);
7564 ret
= (char *)(marshal_alloc (sizeof(char)* (strLength
+ 1)));
7565 memcpy(ret
, pReturn
, strLength
);
7566 ret
[strLength
] = '\0';
7571 StringParameterInOut(/*[In,Out]*/ char *s
, int index
)
7574 return build_return_string(s
);
7578 StringParameterRefOut(/*out*/ char **s
, int index
)
7580 char *pszTextutf8
= (char*)utf8Strings
[index
];
7581 size_t strLength
= strlen(pszTextutf8
);
7582 *s
= (char *)(marshal_alloc (sizeof(char)* (strLength
+ 1)));
7583 memcpy(*s
, pszTextutf8
, strLength
);
7584 (*s
)[strLength
] = '\0';
7588 StringParameterRef(/*ref*/ char **s
, int index
)
7590 char *pszTextutf8
= (char*)utf8Strings
[index
];
7591 size_t strLength
= strlen(pszTextutf8
);
7592 // do byte by byte validation of in string
7593 size_t szLen
= strlen(*s
);
7594 for (size_t i
= 0; i
< szLen
; i
++)
7596 if ((*s
)[i
] != pszTextutf8
[i
])
7598 printf("[in] managed string do not match native string\n");
7607 // overwrite the orginal
7608 *s
= (char *)(marshal_alloc (sizeof(char)* (strLength
+ 1)));
7609 memcpy(*s
, pszTextutf8
, strLength
);
7610 (*s
)[strLength
] = '\0';
7614 StringBuilderParameterInOut(/*[In,Out] StringBuilder*/ char *s
, int index
)
7617 if (s
== 0 || *s
== 0)
7620 char *pszTextutf8
= (char*)utf8Strings
[index
];
7622 // do byte by byte validation of in string
7623 size_t szLen
= strlen(s
);
7624 for (size_t i
= 0; i
< szLen
; i
++)
7626 if (s
[i
] != pszTextutf8
[i
])
7628 printf("[in] managed string do not match native string\n");
7633 // modify the string inplace
7634 size_t outLen
= strlen(pszTextutf8
);
7635 for (size_t i
= 0; i
< outLen
; i
++) {
7636 s
[i
] = pszTextutf8
[i
];
7641 //out string builder
7643 StringBuilderParameterOut(/*[Out] StringBuilder*/ char *s
, int index
)
7645 char *pszTextutf8
= (char*)utf8Strings
[index
];
7647 printf ("SBPO: Receiving %s\n", s
);
7648 // modify the string inplace
7649 size_t outLen
= strlen(pszTextutf8
);
7650 for (size_t i
= 0; i
< outLen
; i
++) {
7651 s
[i
] = pszTextutf8
[i
];
7657 StringParameterOut(/*[Out]*/ char *s
, int index
)
7660 return build_return_string(s
);
7664 typedef struct FieldWithUtf8
7672 TestStructWithUtf8Field(struct FieldWithUtf8 fieldStruct
)
7674 char *pszManagedutf8
= fieldStruct
.pFirst
;
7675 int stringIndex
= fieldStruct
.index
;
7676 char *pszNative
= 0;
7679 if (pszManagedutf8
== 0 || *pszManagedutf8
== 0)
7682 pszNative
= (char*)utf8Strings
[stringIndex
];
7684 outLen
= strlen(pszNative
);
7685 // do byte by byte comparision
7686 for (size_t i
= 0; i
< outLen
; i
++)
7688 if (pszNative
[i
] != pszManagedutf8
[i
])
7690 printf("Native and managed string do not match.\n");
7696 typedef void (* Callback2
)(char *text
, int index
);
7699 Utf8DelegateAsParameter(Callback2 managedCallback
)
7701 for (int i
= 0; i
< NSTRINGS
; ++i
)
7703 char *pszNative
= 0;
7704 pszNative
= (char*)utf8Strings
[i
];
7705 managedCallback(pszNative
, i
);
7711 StringBuilderParameterReturn(int index
)
7713 char *pszTextutf8
= (char*)utf8Strings
[index
];
7714 size_t strLength
= strlen(pszTextutf8
);
7715 char * ret
= (char *)(marshal_alloc (sizeof(char)* (strLength
+ 1)));
7716 memcpy(ret
, pszTextutf8
, strLength
);
7717 ret
[strLength
] = '\0';
7722 LIBTEST_API
int STDCALL
7723 mono_test_marshal_pointer_array (int *arr
[])
7727 for (i
= 0; i
< 10; ++i
) {
7736 typedef void (*NativeToManagedExceptionRethrowFunc
) (void);
7738 void *mono_test_native_to_managed_exception_rethrow_thread (void *arg
)
7740 NativeToManagedExceptionRethrowFunc func
= (NativeToManagedExceptionRethrowFunc
) arg
;
7745 LIBTEST_API
void STDCALL
7746 mono_test_native_to_managed_exception_rethrow (NativeToManagedExceptionRethrowFunc func
)
7749 pthread_create (&t
, NULL
, mono_test_native_to_managed_exception_rethrow_thread
, (gpointer
)func
);
7750 pthread_join (t
, NULL
);
7754 typedef void (*VoidVoidCallback
) (void);
7755 typedef void (*MonoFtnPtrEHCallback
) (guint32 gchandle
);
7757 typedef long long MonoObject
;
7758 typedef MonoObject MonoException
;
7759 typedef int32_t mono_bool
;
7761 static int sym_inited
= 0;
7762 static void (*sym_mono_install_ftnptr_eh_callback
) (MonoFtnPtrEHCallback
);
7763 static MonoObject
* (*sym_mono_gchandle_get_target
) (guint32 gchandle
);
7764 static guint32 (*sym_mono_gchandle_new
) (MonoObject
*, mono_bool pinned
);
7765 static void (*sym_mono_gchandle_free
) (guint32 gchandle
);
7766 static void (*sym_mono_raise_exception
) (MonoException
*ex
);
7767 static void (*sym_mono_domain_unload
) (gpointer
);
7768 static void (*sym_mono_threads_exit_gc_safe_region_unbalanced
) (gpointer
, gpointer
*);
7769 static void (*null_function_ptr
) (void);
7772 mono_test_init_symbols (void)
7777 sym_mono_install_ftnptr_eh_callback
= (void (*) (MonoFtnPtrEHCallback
)) (lookup_mono_symbol ("mono_install_ftnptr_eh_callback"));
7779 sym_mono_gchandle_get_target
= (MonoObject
* (*) (guint32 gchandle
)) (lookup_mono_symbol ("mono_gchandle_get_target"));
7781 sym_mono_gchandle_new
= (guint32 (*) (MonoObject
*, mono_bool
)) (lookup_mono_symbol ("mono_gchandle_new"));
7783 sym_mono_gchandle_free
= (void (*) (guint32 gchandle
)) (lookup_mono_symbol ("mono_gchandle_free"));
7785 sym_mono_raise_exception
= (void (*) (MonoException
*)) (lookup_mono_symbol ("mono_raise_exception"));
7787 sym_mono_domain_unload
= (void (*) (gpointer
)) (lookup_mono_symbol ("mono_domain_unload"));
7789 sym_mono_threads_exit_gc_safe_region_unbalanced
= (void (*) (gpointer
, gpointer
*)) (lookup_mono_symbol ("mono_threads_exit_gc_safe_region_unbalanced"));
7796 static jmp_buf test_jmp_buf
;
7797 static guint32 test_gchandle
;
7800 mono_test_longjmp_callback (guint32 gchandle
)
7802 test_gchandle
= gchandle
;
7803 longjmp (test_jmp_buf
, 1);
7806 LIBTEST_API
void STDCALL
7807 mono_test_setjmp_and_call (VoidVoidCallback managedCallback
, intptr_t *out_handle
)
7809 mono_test_init_symbols ();
7810 if (setjmp (test_jmp_buf
) == 0) {
7812 sym_mono_install_ftnptr_eh_callback (mono_test_longjmp_callback
);
7814 *out_handle
= 0; /* Do not expect to return here */
7816 sym_mono_install_ftnptr_eh_callback (NULL
);
7817 *out_handle
= test_gchandle
;
7823 LIBTEST_API
void STDCALL
7824 mono_test_marshal_bstr (void *ptr
)
7828 static void (*mono_test_capture_throw_callback
) (guint32 gchandle
, guint32
*exception_out
);
7831 mono_test_ftnptr_eh_callback (guint32 gchandle
)
7833 guint32 exception_handle
= 0;
7835 g_assert (gchandle
!= 0);
7836 MonoObject
*exc
= sym_mono_gchandle_get_target (gchandle
);
7837 sym_mono_gchandle_free (gchandle
);
7839 guint32 handle
= sym_mono_gchandle_new (exc
, FALSE
);
7840 mono_test_capture_throw_callback (handle
, &exception_handle
);
7841 sym_mono_gchandle_free (handle
);
7843 g_assert (exception_handle
!= 0);
7844 exc
= sym_mono_gchandle_get_target (exception_handle
);
7845 sym_mono_gchandle_free (exception_handle
);
7847 sym_mono_raise_exception (exc
);
7848 g_error ("mono_raise_exception should not return");
7851 LIBTEST_API
void STDCALL
7852 mono_test_setup_ftnptr_eh_callback (VoidVoidCallback managed_entry
, void (*capture_throw_callback
) (guint32
, guint32
*))
7854 mono_test_init_symbols ();
7855 mono_test_capture_throw_callback
= capture_throw_callback
;
7856 sym_mono_install_ftnptr_eh_callback (mono_test_ftnptr_eh_callback
);
7860 LIBTEST_API
void STDCALL
7861 mono_test_cleanup_ftptr_eh_callback (void)
7863 mono_test_init_symbols ();
7864 sym_mono_install_ftnptr_eh_callback (NULL
);
7867 LIBTEST_API
int STDCALL
7868 mono_test_cominterop_ccw_queryinterface (MonoComObject
*pUnk
)
7871 int hr
= pUnk
->vtbl
->QueryInterface (pUnk
, &IID_INotImplemented
, &pp
);
7873 // Return true if we can't get INotImplemented
7874 return pUnk
== NULL
&& hr
== S_OK
;
7877 LIBTEST_API
void STDCALL
7878 mono_test_MerpCrashSnprintf (void)
7880 fprintf (stderr
, "Before overwrite\n");
7882 char buff
[1] = { '\0' };
7883 char overflow
[1] = { 'a' }; // Not null-terminated
7884 g_snprintf (buff
, sizeof(buff
) * 10, "THISSHOULDOVERRUNTERRIBLY%s", overflow
);
7885 g_snprintf ((char *) GINT_TO_POINTER(-1), sizeof(buff
) * 10, "THISSHOULDOVERRUNTERRIBLY%s", overflow
);
7888 LIBTEST_API
void STDCALL
7889 mono_test_MerpCrashDladdr (void)
7892 dlopen (GINT_TO_POINTER(-1), -1);
7896 LIBTEST_API
void STDCALL
7897 mono_test_MerpCrashMalloc (void)
7899 gpointer x
= g_malloc (sizeof(gpointer
));
7906 LIBTEST_API
void STDCALL
7907 mono_test_MerpCrashNullFp (void)
7909 null_function_ptr ();
7912 LIBTEST_API
void STDCALL
7913 mono_test_MerpCrashDomainUnload (void)
7915 mono_test_init_symbols ();
7916 sym_mono_domain_unload (GINT_TO_POINTER (-1));
7919 LIBTEST_API
void STDCALL
7920 mono_test_MerpCrashUnbalancedGCSafe (void)
7922 mono_test_init_symbols ();
7923 gpointer foo
= GINT_TO_POINTER (-1);
7924 gpointer bar
= GINT_TO_POINTER (-2);
7925 sym_mono_threads_exit_gc_safe_region_unbalanced (foo
, &bar
);
7928 LIBTEST_API
void STDCALL
7929 mono_test_MerpCrashUnhandledExceptionHook (void)
7931 g_assert_not_reached ();