19 #define STDCALL __stdcall
25 #pragma GCC diagnostic ignored "-Wmissing-prototypes"
29 extern __declspec(dllimport
) void __stdcall
CoTaskMemFree(void *ptr
);
32 typedef int (STDCALL
*SimpleDelegate
) (int a
);
34 #if defined(WIN32) && defined (_MSC_VER)
35 #define LIBTEST_API __declspec(dllexport)
36 #elif defined(__GNUC__)
37 #define LIBTEST_API __attribute__ ((visibility ("default")))
42 static void marshal_free (void *ptr
)
51 static void* marshal_alloc (gsize size
)
54 return CoTaskMemAlloc (size
);
56 return g_malloc (size
);
60 static void* marshal_alloc0 (gsize size
)
63 void* ptr
= CoTaskMemAlloc (size
);
67 return g_malloc0 (size
);
71 static char* marshal_strdup (const char *str
)
81 buf
= (char *) CoTaskMemAlloc (len
+ 1);
82 return strcpy (buf
, str
);
84 return g_strdup (str
);
88 static gunichar2
* marshal_bstr_alloc(const gchar
* str
)
91 gunichar2
* ret
= NULL
;
92 gunichar2
* temp
= NULL
;
93 temp
= g_utf8_to_utf16 (str
, -1, NULL
, NULL
, NULL
);
94 ret
= SysAllocString (temp
);
99 int slen
= strlen (str
);
101 /* allocate len + 1 utf16 characters plus 4 byte integer for length*/
102 ret
= (gchar
*)g_malloc ((slen
+ 1) * sizeof(gunichar2
) + sizeof(guint32
));
105 temp
= g_utf8_to_utf16 (str
, -1, NULL
, NULL
, NULL
);
106 memcpy (ret
+ sizeof(guint32
), temp
, slen
* sizeof(gunichar2
));
107 * ((guint32
*) ret
) = slen
* sizeof(gunichar2
);
108 ret
[4 + slen
* sizeof(gunichar2
)] = 0;
109 ret
[5 + slen
* sizeof(gunichar2
)] = 0;
111 return (gunichar2
*)(ret
+ 4);
115 #define marshal_new0(type,size) ((type *) marshal_alloc0 (sizeof (type)* (size)))
117 LIBTEST_API
int STDCALL
118 mono_cominterop_is_supported (void)
120 #if defined(TARGET_X86) || defined(TARGET_AMD64)
126 LIBTEST_API
unsigned short* STDCALL
127 test_lpwstr_marshal (unsigned short* chars
, long length
)
132 res
= (unsigned short *)marshal_alloc (2 * (length
+ 1));
134 // printf("test_lpwstr_marshal()\n");
136 while ( i
< length
) {
137 // printf("X|%u|\n", chars[i]);
148 LIBTEST_API
void STDCALL
149 test_lpwstr_marshal_out (unsigned short** chars
)
152 const char abc
[] = "ABC";
153 glong len
= strlen(abc
);
155 *chars
= (unsigned short *)marshal_alloc (2 * (len
+ 1));
158 (*chars
) [i
] = abc
[i
];
171 LIBTEST_API
int STDCALL
172 mono_union_test_1 (union_test_1_type u1
) {
173 // printf ("Got values %d %d %d\n", u1.b, u1.a, u1.c);
174 return u1
.a
+ u1
.b
+ u1
.c
;
177 LIBTEST_API
int STDCALL
178 mono_return_int (int a
) {
179 // printf ("Got value %d\n", a);
183 LIBTEST_API
float STDCALL
184 mono_test_marshal_pass_return_float (float f
) {
193 LIBTEST_API
int STDCALL
194 mono_return_int_ss (struct ss a
) {
195 // printf ("Got value %d\n", a.i);
199 LIBTEST_API
struct ss STDCALL
200 mono_return_ss (struct ss a
) {
201 // printf ("Got value %d\n", a.i);
211 LIBTEST_API
struct sc1 STDCALL
212 mono_return_sc1 (struct sc1 a
) {
213 // printf ("Got value %d\n", a.c[0]);
224 LIBTEST_API
struct sc3 STDCALL
225 mono_return_sc3 (struct sc3 a
) {
226 // printf ("Got values %d %d %d\n", a.c[0], a.c[1], a.c[2]);
238 LIBTEST_API
struct sc5 STDCALL
239 mono_return_sc5 (struct sc5 a
) {
240 // printf ("Got values %d %d %d %d %d\n", a.c[0], a.c[1], a.c[2], a.c[3], a.c[4]);
255 LIBTEST_API
int STDCALL
256 mono_return_int_su (union su a
) {
257 // printf ("Got value %d\n", a.i1);
272 LIBTEST_API
struct NestedFloat STDCALL
273 mono_return_nested_float (void)
275 struct NestedFloat f
;
283 LIBTEST_API
int STDCALL
284 mono_test_many_int_arguments (int a
, int b
, int c
, int d
, int e
,
285 int f
, int g
, int h
, int i
, int j
);
286 LIBTEST_API
short STDCALL
287 mono_test_many_short_arguments (short a
, short b
, short c
, short d
, short e
,
288 short f
, short g
, short h
, short i
, short j
);
289 LIBTEST_API
char STDCALL
290 mono_test_many_char_arguments (char a
, char b
, char c
, char d
, char e
,
291 char f
, char g
, char h
, char i
, char j
);
293 LIBTEST_API
int STDCALL
294 mono_test_many_int_arguments (int a
, int b
, int c
, int d
, int e
, int f
, int g
, int h
, int i
, int j
)
296 return a
+ b
+ c
+ d
+ e
+ f
+ g
+ h
+ i
+ j
;
299 LIBTEST_API
short STDCALL
300 mono_test_many_short_arguments (short a
, short b
, short c
, short d
, short e
, short f
, short g
, short h
, short i
, short j
)
302 return a
+ b
+ c
+ d
+ e
+ f
+ g
+ h
+ i
+ j
;
305 LIBTEST_API
char STDCALL
306 mono_test_many_byte_arguments (char a
, char b
, char c
, char d
, char e
, char f
, char g
, char h
, char i
, char j
)
308 return a
+ b
+ c
+ d
+ e
+ f
+ g
+ h
+ i
+ j
;
311 LIBTEST_API
float STDCALL
312 mono_test_many_float_arguments (float a
, float b
, float c
, float d
, float e
, float f
, float g
, float h
, float i
, float j
)
314 return a
+ b
+ c
+ d
+ e
+ f
+ g
+ h
+ i
+ j
;
317 LIBTEST_API
double STDCALL
318 mono_test_many_double_arguments (double a
, double b
, double c
, double d
, double e
, double f
, double g
, double h
, double i
, double j
)
320 return a
+ b
+ c
+ d
+ e
+ f
+ g
+ h
+ i
+ j
;
323 LIBTEST_API
double STDCALL
324 mono_test_split_double_arguments (double a
, double b
, float c
, double d
, double e
)
326 return a
+ b
+ c
+ d
+ e
;
329 LIBTEST_API
int STDCALL
330 mono_test_puts_static (char *s
)
332 // printf ("TEST %s\n", s);
336 typedef int (STDCALL
*SimpleDelegate3
) (int a
, int b
);
338 LIBTEST_API
int STDCALL
339 mono_invoke_delegate (SimpleDelegate3 delegate
)
343 // printf ("start invoke %p\n", delegate);
345 res
= delegate (2, 3);
347 // printf ("end invoke\n");
352 LIBTEST_API
int STDCALL
353 mono_invoke_simple_delegate (SimpleDelegate d
)
358 LIBTEST_API
int STDCALL
359 mono_test_marshal_char (short a1
)
367 LIBTEST_API
void STDCALL
368 mono_test_marshal_char_array (gunichar2
*s
)
370 const char m
[] = "abcdef";
374 s2
= g_utf8_to_utf16 (m
, -1, NULL
, &len
, NULL
);
382 LIBTEST_API
int STDCALL
383 mono_test_marshal_ansi_char_array (char *s
)
385 const char m
[] = "abcdef";
387 if (strncmp ("qwer", s
, 4))
390 memcpy (s
, m
, sizeof (m
));
394 LIBTEST_API
int STDCALL
395 mono_test_marshal_unicode_char_array (gunichar2
*s
)
397 const char m
[] = "abcdef";
398 const char expected
[] = "qwer";
402 s1
= g_utf8_to_utf16 (m
, -1, NULL
, &len1
, NULL
);
403 s2
= g_utf8_to_utf16 (expected
, -1, NULL
, &len2
, NULL
);
407 if (memcmp (s
, s2
, len2
))
410 memcpy (s
, s1
, len1
);
414 LIBTEST_API
int STDCALL
415 mono_test_empty_pinvoke (int i
)
420 LIBTEST_API
int STDCALL
421 mono_test_marshal_bool_byref (int a
, int *b
, int c
)
430 LIBTEST_API
int STDCALL
431 mono_test_marshal_bool_in_as_I1_U1 (char bTrue
, char bFalse
)
440 LIBTEST_API
int STDCALL
441 mono_test_marshal_bool_out_as_I1_U1 (char* bTrue
, char* bFalse
)
443 if (!bTrue
|| !bFalse
)
452 LIBTEST_API
int STDCALL
453 mono_test_marshal_bool_ref_as_I1_U1 (char* bTrue
, char* bFalse
)
455 if (!bTrue
|| !bFalse
)
469 LIBTEST_API
int STDCALL
470 mono_test_marshal_array (int *a1
)
474 for (i
= 0; i
< 50; i
++)
480 LIBTEST_API
int STDCALL
481 mono_test_marshal_inout_array (int *a1
)
485 for (i
= 0; i
< 50; i
++) {
487 a1
[i
] = 50 - a1
[i
];
493 LIBTEST_API
int /* cdecl */
494 mono_test_marshal_inout_array_cdecl (int *a1
)
496 return mono_test_marshal_inout_array (a1
);
499 LIBTEST_API
int STDCALL
500 mono_test_marshal_out_array (int *a1
)
504 for (i
= 0; i
< 50; i
++) {
511 LIBTEST_API
int STDCALL
512 mono_test_marshal_out_byref_array_out_size_param (int **out_arr
, int *out_len
)
518 arr
= (gint32
*)marshal_alloc (sizeof (gint32
) * len
);
519 for (i
= 0; i
< len
; ++i
)
527 LIBTEST_API
int STDCALL
528 mono_test_marshal_out_lparray_out_size_param (int *arr
, int *out_len
)
533 for (i
= 0; i
< len
; ++i
)
540 LIBTEST_API
int STDCALL
541 mono_test_marshal_inout_nonblittable_array (gunichar2
*a1
)
545 for (i
= 0; i
< 10; i
++) {
565 LIBTEST_API simplestruct STDCALL
566 mono_test_return_vtype (int i
)
569 static gunichar2 test2
[] = { 'T', 'E', 'S', 'T', '2', 0 };
580 LIBTEST_API
void STDCALL
581 mono_test_delegate_struct (void)
583 // printf ("TEST\n");
586 typedef char* (STDCALL
*ReturnStringDelegate
) (const char *s
);
588 LIBTEST_API
char * STDCALL
589 mono_test_return_string (ReturnStringDelegate func
)
593 // printf ("mono_test_return_string\n");
598 // printf ("got string: %s\n", res);
599 return marshal_strdup ("12345");
602 typedef int (STDCALL
*RefVTypeDelegate
) (int a
, simplestruct
*ss
, int b
);
604 LIBTEST_API
int STDCALL
605 mono_test_ref_vtype (int a
, simplestruct
*ss
, int b
, RefVTypeDelegate func
)
607 if (a
== 1 && b
== 2 && ss
->a
== 0 && ss
->b
== 1 && ss
->c
== 0 &&
608 !strcmp (ss
->d
, "TEST1")) {
614 return func (a
, ss
, b
);
620 typedef int (STDCALL
*OutVTypeDelegate
) (int a
, simplestruct
*ss
, int b
);
622 LIBTEST_API
int STDCALL
623 mono_test_marshal_out_struct (int a
, simplestruct
*ss
, int b
, OutVTypeDelegate func
)
625 /* Check that the input pointer is ignored */
626 ss
->d
= (const char *)0x12345678;
630 if (ss
->a
&& ss
->b
&& ss
->c
&& !strcmp (ss
->d
, "TEST3"))
636 typedef int (STDCALL
*InVTypeDelegate
) (int a
, simplestruct
*ss
, int b
);
638 LIBTEST_API
int STDCALL
639 mono_test_marshal_in_struct (int a
, simplestruct
*ss
, int b
, InVTypeDelegate func
)
644 memcpy (&ss2
, ss
, sizeof (simplestruct
));
646 res
= func (a
, ss
, b
);
648 printf ("mono_test_marshal_in_struct () failed: %d\n", res
);
652 /* Check that no modifications is made to the struct */
653 if (ss2
.a
== ss
->a
&& ss2
.b
== ss
->b
&& ss2
.c
== ss
->c
&& ss2
.d
== ss
->d
)
661 SimpleDelegate func
, func2
, func3
;
664 LIBTEST_API DelegateStruct STDCALL
665 mono_test_marshal_delegate_struct (DelegateStruct ds
)
669 res
.a
= ds
.func (ds
.a
) + ds
.func2 (ds
.a
) + (ds
.func3
== NULL
? 0 : 1);
671 res
.func2
= ds
.func2
;
677 LIBTEST_API
int STDCALL
678 mono_test_marshal_struct (simplestruct ss
)
680 if (ss
.a
== 0 && ss
.b
== 1 && ss
.c
== 0 &&
681 !strcmp (ss
.d
, "TEST"))
687 LIBTEST_API
int STDCALL
688 mono_test_marshal_byref_struct (simplestruct
*ss
, int a
, int b
, int c
, char *d
)
690 gboolean res
= (ss
->a
== a
&& ss
->b
== b
&& ss
->c
== c
&& strcmp (ss
->d
, d
) == 0);
692 marshal_free ((char*)ss
->d
);
697 ss
->d
= marshal_strdup ("DEF");
713 LIBTEST_API
int STDCALL
714 mono_test_marshal_struct2 (simplestruct2 ss
)
716 if (ss
.a
== 0 && ss
.b
== 1 && ss
.c
== 0 &&
717 !strcmp (ss
.d
, "TEST") &&
718 ss
.e
== 99 && ss
.f
== 1.5 && ss
.g
== 42 && ss
.h
== (guint64
)123)
724 /* on HP some of the struct should be on the stack and not in registers */
725 LIBTEST_API
int STDCALL
726 mono_test_marshal_struct2_2 (int i
, int j
, int k
, simplestruct2 ss
)
728 if (i
!= 10 || j
!= 11 || k
!= 12)
730 if (ss
.a
== 0 && ss
.b
== 1 && ss
.c
== 0 &&
731 !strcmp (ss
.d
, "TEST") &&
732 ss
.e
== 99 && ss
.f
== 1.5 && ss
.g
== 42 && ss
.h
== (guint64
)123)
738 LIBTEST_API
int STDCALL
739 mono_test_marshal_lpstruct (simplestruct
*ss
)
741 if (ss
->a
== 0 && ss
->b
== 1 && ss
->c
== 0 &&
742 !strcmp (ss
->d
, "TEST"))
748 LIBTEST_API
int STDCALL
749 mono_test_marshal_lpstruct_blittable (point
*p
)
751 if (p
->x
== 1.0 && p
->y
== 2.0)
757 LIBTEST_API
int STDCALL
758 mono_test_marshal_struct_array (simplestruct2
*ss
)
760 if (! (ss
[0].a
== 0 && ss
[0].b
== 1 && ss
[0].c
== 0 &&
761 !strcmp (ss
[0].d
, "TEST") &&
762 ss
[0].e
== 99 && ss
[0].f
== 1.5 && ss
[0].g
== 42 && ss
[0].h
== (guint64
)123))
765 if (! (ss
[1].a
== 0 && ss
[1].b
== 0 && ss
[1].c
== 0 &&
766 !strcmp (ss
[1].d
, "TEST2") &&
767 ss
[1].e
== 100 && ss
[1].f
== 2.5 && ss
[1].g
== 43 && ss
[1].h
== (guint64
)124))
773 typedef struct long_align_struct
{
779 LIBTEST_API
int STDCALL
780 mono_test_marshal_long_align_struct_array (long_align_struct
*ss
)
782 return ss
[0].a
+ ss
[0].b
+ ss
[0].c
+ ss
[1].a
+ ss
[1].b
+ ss
[1].c
;
785 LIBTEST_API simplestruct2
* STDCALL
786 mono_test_marshal_class (int i
, int j
, int k
, simplestruct2
*ss
, int l
)
793 if (i
!= 10 || j
!= 11 || k
!= 12 || l
!= 14)
795 if (! (ss
->a
== 0 && ss
->b
== 1 && ss
->c
== 0 &&
796 !strcmp (ss
->d
, "TEST") &&
797 ss
->e
== 99 && ss
->f
== 1.5 && ss
->g
== 42 && ss
->h
== (guint64
)123))
800 res
= marshal_new0 (simplestruct2
, 1);
801 memcpy (res
, ss
, sizeof (simplestruct2
));
802 res
->d
= marshal_strdup ("TEST");
806 LIBTEST_API
int STDCALL
807 mono_test_marshal_byref_class (simplestruct2
**ssp
)
809 simplestruct2
*ss
= *ssp
;
812 if (! (ss
->a
== 0 && ss
->b
== 1 && ss
->c
== 0 &&
813 !strcmp (ss
->d
, "TEST") &&
814 ss
->e
== 99 && ss
->f
== 1.5 && ss
->g
== 42 && ss
->h
== (guint64
)123))
817 res
= marshal_new0 (simplestruct2
, 1);
818 memcpy (res
, ss
, sizeof (simplestruct2
));
819 res
->d
= marshal_strdup ("TEST-RES");
831 /* Yes, this is correct, we are only trying to determine the value of the stack here */
836 LIBTEST_API
int STDCALL
837 reliable_delegate (int a
)
843 * Checks whether get_sp() works as expected. It doesn't work with gcc-2.95.3 on linux.
846 is_get_sp_reliable (void)
850 reliable_delegate(1);
852 reliable_delegate(1);
857 LIBTEST_API
int STDCALL
858 mono_test_marshal_delegate (SimpleDelegate delegate
)
862 /* Check that the delegate wrapper is stdcall */
867 if (is_get_sp_reliable())
868 g_assert (sp1
== sp2
);
873 static int STDCALL
inc_cb (int i
)
878 LIBTEST_API
int STDCALL
879 mono_test_marshal_out_delegate (SimpleDelegate
*delegate
)
886 LIBTEST_API SimpleDelegate STDCALL
887 mono_test_marshal_return_delegate (SimpleDelegate delegate
)
892 typedef int (STDCALL
*DelegateByrefDelegate
) (void *);
894 LIBTEST_API
int STDCALL
895 mono_test_marshal_delegate_ref_delegate (DelegateByrefDelegate del
)
897 int (STDCALL
*ptr
) (int i
);
905 return_plus_one (int i
)
910 LIBTEST_API SimpleDelegate STDCALL
911 mono_test_marshal_return_delegate_2 (void)
913 return return_plus_one
;
916 typedef simplestruct (STDCALL
*SimpleDelegate2
) (simplestruct ss
);
919 is_utf16_equals (gunichar2
*s1
, const char *s2
)
924 s
= g_utf16_to_utf8 (s1
, -1, NULL
, NULL
, NULL
);
925 res
= strcmp (s
, s2
);
931 LIBTEST_API
int STDCALL
932 mono_test_marshal_delegate2 (SimpleDelegate2 delegate
)
934 simplestruct ss
, res
;
940 ss
.d2
= g_utf8_to_utf16 ("TEST2", -1, NULL
, NULL
, NULL
);
943 if (! (res
.a
&& !res
.b
&& res
.c
&& !strcmp (res
.d
, "TEST-RES") && is_utf16_equals (res
.d2
, "TEST2-RES")))
949 typedef simplestruct
* (STDCALL
*SimpleDelegate4
) (simplestruct
*ss
);
951 LIBTEST_API
int STDCALL
952 mono_test_marshal_delegate4 (SimpleDelegate4 delegate
)
963 res
= delegate (&ss
);
967 /* Check return value */
968 if (! (!res
->a
&& res
->b
&& !res
->c
&& !strcmp (res
->d
, "TEST")))
971 /* Check NULL argument and NULL result */
972 res
= delegate (NULL
);
979 typedef int (STDCALL
*SimpleDelegate5
) (simplestruct
**ss
);
981 LIBTEST_API
int STDCALL
982 mono_test_marshal_delegate5 (SimpleDelegate5 delegate
)
995 res
= delegate (&ptr
);
999 if (!(ptr
->a
&& !ptr
->b
&& ptr
->c
&& !strcmp (ptr
->d
, "RES")))
1005 LIBTEST_API
int STDCALL
1006 mono_test_marshal_delegate6 (SimpleDelegate5 delegate
)
1012 typedef int (STDCALL
*SimpleDelegate7
) (simplestruct
**ss
);
1014 LIBTEST_API
int STDCALL
1015 mono_test_marshal_delegate7 (SimpleDelegate7 delegate
)
1020 /* Check that the input pointer is ignored */
1021 ptr
= (simplestruct
*)0x12345678;
1023 res
= delegate (&ptr
);
1027 if (!(ptr
->a
&& !ptr
->b
&& ptr
->c
&& !strcmp (ptr
->d
, "RES")))
1033 typedef int (STDCALL
*InOutByvalClassDelegate
) (simplestruct
*ss
);
1035 LIBTEST_API
int STDCALL
1036 mono_test_marshal_inout_byval_class_delegate (InOutByvalClassDelegate delegate
)
1044 ss
.d
= g_strdup_printf ("%s", "FOO");
1046 res
= delegate (&ss
);
1050 if (!(ss
.a
&& !ss
.b
&& ss
.c
&& !strcmp (ss
.d
, "RES")))
1056 typedef int (STDCALL
*SimpleDelegate8
) (gunichar2
*s
);
1058 LIBTEST_API
int STDCALL
1059 mono_test_marshal_delegate8 (SimpleDelegate8 delegate
, gunichar2
*s
)
1061 return delegate (s
);
1064 typedef int (STDCALL
*return_int_fnt
) (int i
);
1065 typedef int (STDCALL
*SimpleDelegate9
) (return_int_fnt d
);
1067 LIBTEST_API
int STDCALL
1068 mono_test_marshal_delegate9 (SimpleDelegate9 delegate
, gpointer ftn
)
1070 return delegate ((return_int_fnt
)ftn
);
1079 LIBTEST_API
int STDCALL
1080 mono_test_marshal_delegate10 (SimpleDelegate9 delegate
)
1082 return delegate (return_self
);
1085 typedef int (STDCALL
*PrimitiveByrefDelegate
) (int *i
);
1087 LIBTEST_API
int STDCALL
1088 mono_test_marshal_primitive_byref_delegate (PrimitiveByrefDelegate delegate
)
1092 int res
= delegate (&i
);
1102 typedef int (STDCALL
*return_int_delegate
) (int i
);
1104 typedef return_int_delegate (STDCALL
*ReturnDelegateDelegate
) (void);
1106 LIBTEST_API
int STDCALL
1107 mono_test_marshal_return_delegate_delegate (ReturnDelegateDelegate d
)
1112 typedef int (STDCALL
*VirtualDelegate
) (int);
1114 LIBTEST_API
int STDCALL
1115 mono_test_marshal_virtual_delegate (VirtualDelegate del
)
1120 typedef char* (STDCALL
*IcallDelegate
) (const char *);
1121 LIBTEST_API
int STDCALL
1122 mono_test_marshal_icall_delegate (IcallDelegate del
)
1124 char *res
= del ("ABC");
1125 return strcmp (res
, "ABC") == 0 ? 0 : 1;
1128 LIBTEST_API
int STDCALL
1129 mono_test_marshal_stringbuilder (char *s
, int n
)
1131 const char m
[] = "This is my message. Isn't it nice?";
1133 if (strcmp (s
, "ABCD") != 0)
1140 LIBTEST_API
int STDCALL
1141 mono_test_marshal_stringbuilder_append (char *s
, int length
)
1143 const char out_sentinel
[] = "CSHARP_";
1144 const char out_len
= strlen (out_sentinel
);
1146 for (int i
=0; i
< length
; i
++) {
1147 s
[i
] = out_sentinel
[i
% out_len
];
1156 LIBTEST_API
int STDCALL
1157 mono_test_marshal_stringbuilder_default (char *s
, int n
)
1159 const char m
[] = "This is my message. Isn't it nice?";
1166 LIBTEST_API
int STDCALL
1167 mono_test_marshal_stringbuilder_unicode (gunichar2
*s
, int n
)
1169 const char m
[] = "This is my message. Isn't it nice?";
1173 s2
= g_utf8_to_utf16 (m
, -1, NULL
, &len
, NULL
);
1175 len
= (len
* 2) + 2;
1178 memcpy (s
, s2
, len
);
1185 LIBTEST_API
void STDCALL
1186 mono_test_marshal_stringbuilder_out (char **s
)
1188 const char m
[] = "This is my message. Isn't it nice?";
1191 str
= (char *)marshal_alloc (strlen (m
) + 1);
1192 memcpy (str
, m
, strlen (m
) + 1);
1197 LIBTEST_API
int STDCALL
1198 mono_test_marshal_stringbuilder_out_unicode (gunichar2
**s
)
1200 const char m
[] = "This is my message. Isn't it nice?";
1204 s2
= g_utf8_to_utf16 (m
, -1, NULL
, &len
, NULL
);
1206 len
= (len
* 2) + 2;
1207 *s
= (gunichar2
*)marshal_alloc (len
);
1208 memcpy (*s
, s2
, len
);
1215 LIBTEST_API
int STDCALL
1216 mono_test_marshal_stringbuilder_ref (char **s
)
1218 const char m
[] = "This is my message. Isn't it nice?";
1221 if (strcmp (*s
, "ABC"))
1224 str
= (char *)marshal_alloc (strlen (m
) + 1);
1225 memcpy (str
, m
, strlen (m
) + 1);
1232 #pragma GCC diagnostic push
1233 #pragma GCC diagnostic ignored "-Wc++-compat"
1237 * Standard C and C++ doesn't allow empty structs, empty structs will always have a size of 1 byte.
1238 * GCC have an extension to allow empty structs, https://gcc.gnu.org/onlinedocs/gcc/Empty-Structures.html.
1239 * This cause a little dilemma since runtime build using none GCC compiler will not be compatible with
1240 * GCC build C libraries and the other way around. On platforms where empty structs has size of 1 byte
1241 * it must be represented in call and cannot be dropped. On Windows x64 structs will always be represented in the call
1242 * meaning that an empty struct must have a representation in the callee in order to correctly follow the ABI used by the
1243 * C/C++ standard and the runtime.
1246 #if !defined(__GNUC__) || defined(TARGET_WIN32)
1252 #pragma GCC diagnostic pop
1255 LIBTEST_API
int STDCALL
1256 mono_test_marshal_empty_string_array (char **array
)
1258 return (array
== NULL
) ? 0 : 1;
1261 LIBTEST_API
int STDCALL
1262 mono_test_marshal_string_array (char **array
)
1264 if (strcmp (array
[0], "ABC"))
1266 if (strcmp (array
[1], "DEF"))
1269 if (array
[2] != NULL
)
1275 LIBTEST_API
int STDCALL
1276 mono_test_marshal_byref_string_array (char ***array
)
1281 if (strcmp ((*array
) [0], "Alpha"))
1283 if (strcmp ((*array
) [1], "Beta"))
1285 if (strcmp ((*array
) [2], "Gamma"))
1291 LIBTEST_API
int STDCALL
1292 mono_test_marshal_stringbuilder_array (char **array
)
1294 if (strcmp (array
[0], "ABC"))
1296 if (strcmp (array
[1], "DEF"))
1299 strcpy (array
[0], "DEF");
1300 strcpy (array
[1], "ABC");
1305 LIBTEST_API
int STDCALL
1306 mono_test_marshal_unicode_string_array (gunichar2
**array
, char **array2
)
1308 GError
*error
= NULL
;
1311 s
= g_utf16_to_utf8 (array
[0], -1, NULL
, NULL
, &error
);
1312 if (strcmp (s
, "ABC")) {
1319 s
= g_utf16_to_utf8 (array
[1], -1, NULL
, NULL
, &error
);
1320 if (strcmp (s
, "DEF")) {
1327 if (strcmp (array2
[0], "ABC"))
1330 if (strcmp (array2
[1], "DEF"))
1336 /* this does not work on Redhat gcc 2.96 */
1337 LIBTEST_API
int STDCALL
1338 mono_test_empty_struct (int a
, EmptyStruct es
, int b
)
1340 // printf ("mono_test_empty_struct %d %d\n", a, b);
1342 // Intel icc on ia64 passes 'es' in 2 registers
1343 #if defined(__ia64) && defined(__INTEL_COMPILER)
1346 if (a
== 1 && b
== 2)
1352 LIBTEST_API EmptyStruct STDCALL
1353 mono_test_return_empty_struct (int a
)
1357 memset (&s
, 0, sizeof (s
));
1368 LIBTEST_API ByValStrStruct
* STDCALL
1369 mono_test_byvalstr_gen (void)
1371 ByValStrStruct
*ret
;
1373 ret
= (ByValStrStruct
*)malloc (sizeof (ByValStrStruct
));
1374 memset(ret
, 'a', sizeof(ByValStrStruct
)-1);
1375 ret
->a
[sizeof(ByValStrStruct
)-1] = 0;
1380 LIBTEST_API
int STDCALL
1381 mono_test_byvalstr_check (ByValStrStruct
* data
, char* correctString
)
1385 ret
= strcmp(data
->a
, correctString
);
1386 // printf ("T1: %s\n", data->a);
1387 // printf ("T2: %s\n", correctString);
1389 /* we need g_free because the allocation was performed by mono_test_byvalstr_gen */
1397 } ByValStrStruct_Unicode
;
1399 LIBTEST_API
int STDCALL
1400 mono_test_byvalstr_check_unicode (ByValStrStruct_Unicode
*ref
, int test
)
1402 if (ref
->flag
!= 0x1234abcd){
1403 printf ("overwritten data");
1407 if (test
== 1 || test
== 3){
1408 if (ref
->a
[0] != '1' ||
1409 ref
->a
[1] != '2' ||
1415 if (ref
->a
[0] != '1' ||
1423 LIBTEST_API
int STDCALL
1424 NameManglingAnsi (char *data
)
1426 return data
[0] + data
[1] + data
[2];
1429 LIBTEST_API
int STDCALL
1430 NameManglingAnsiA (char *data
)
1432 g_assert_not_reached ();
1435 LIBTEST_API
int STDCALL
1436 NameManglingAnsiW (char *data
)
1438 g_assert_not_reached ();
1441 LIBTEST_API
int STDCALL
1442 NameManglingAnsi2A (char *data
)
1444 return data
[0] + data
[1] + data
[2];
1447 LIBTEST_API
int STDCALL
1448 NameManglingAnsi2W (char *data
)
1450 g_assert_not_reached ();
1453 LIBTEST_API
int STDCALL
1454 NameManglingUnicode (char *data
)
1456 g_assert_not_reached ();
1459 LIBTEST_API
int STDCALL
1460 NameManglingUnicodeW (gunichar2
*data
)
1462 return data
[0] + data
[1] + data
[2];
1465 LIBTEST_API
int STDCALL
1466 NameManglingUnicode2 (gunichar2
*data
)
1468 return data
[0] + data
[1] + data
[2];
1471 LIBTEST_API
int STDCALL
1472 NameManglingAutoW (char *data
)
1475 return (data
[0] + data
[1] + data
[2]) == 131 ? 0 : 1;
1477 g_assert_not_reached ();
1481 LIBTEST_API
int STDCALL
1482 NameManglingAuto (char *data
)
1485 return (data
[0] + data
[1] + data
[2]) == 198 ? 0 : 1;
1487 g_assert_not_reached ();
1491 typedef int (STDCALL
*intcharFunc
)(const char*);
1493 LIBTEST_API
void STDCALL
1494 callFunction (intcharFunc f
)
1504 LIBTEST_API
int STDCALL
1505 class_marshal_test0 (SimpleObj
*obj1
)
1507 // printf ("class_marshal_test0 %s %d\n", obj1->str, obj1->i);
1509 if (strcmp(obj1
->str
, "T1"))
1517 LIBTEST_API
int STDCALL
1518 class_marshal_test4 (SimpleObj
*obj1
)
1526 LIBTEST_API
void STDCALL
1527 class_marshal_test1 (SimpleObj
**obj1
)
1529 SimpleObj
*res
= (SimpleObj
*)malloc (sizeof (SimpleObj
));
1531 res
->str
= marshal_strdup ("ABC");
1537 LIBTEST_API
int STDCALL
1538 class_marshal_test2 (SimpleObj
**obj1
)
1540 // printf ("class_marshal_test2 %s %d\n", (*obj1)->str, (*obj1)->i);
1542 if (strcmp((*obj1
)->str
, "ABC"))
1544 if ((*obj1
)->i
!= 5)
1550 LIBTEST_API
int STDCALL
1551 string_marshal_test0 (char *str
)
1553 if (strcmp (str
, "TEST0"))
1559 LIBTEST_API
void STDCALL
1560 string_marshal_test1 (const char **str
)
1562 *str
= marshal_strdup ("TEST1");
1565 LIBTEST_API
int STDCALL
1566 string_marshal_test2 (char **str
)
1568 // printf ("string_marshal_test2 %s\n", *str);
1570 if (strcmp (*str
, "TEST1"))
1573 *str
= marshal_strdup ("TEST2");
1578 LIBTEST_API
int STDCALL
1579 string_marshal_test3 (char *str
)
1592 LIBTEST_API BlittableClass
* STDCALL
1593 TestBlittableClass (BlittableClass
*vl
)
1595 BlittableClass
*res
;
1597 // printf ("TestBlittableClass %d %d\n", vl->a, vl->b);
1603 res
= marshal_new0 (BlittableClass
, 1);
1604 memcpy (res
, vl
, sizeof (BlittableClass
));
1606 res
= marshal_new0 (BlittableClass
, 1);
1614 typedef struct OSVERSIONINFO_STRUCT
1618 } OSVERSIONINFO_STRUCT
;
1620 LIBTEST_API
int STDCALL
1621 MyGetVersionEx (OSVERSIONINFO_STRUCT
*osvi
)
1624 // printf ("GOT %d %d\n", osvi->a, osvi->b);
1629 return osvi
->a
+ osvi
->b
;
1632 LIBTEST_API
int STDCALL
1633 BugGetVersionEx (int a
, int b
, int c
, int d
, int e
, int f
, int g
, int h
, OSVERSIONINFO_STRUCT
*osvi
)
1636 // printf ("GOT %d %d\n", osvi->a, osvi->b);
1641 return osvi
->a
+ osvi
->b
;
1644 LIBTEST_API
int STDCALL
1645 mono_test_marshal_point (point pt
)
1647 // printf("point %g %g\n", pt.x, pt.y);
1648 if (pt
.x
== 1.25 && pt
.y
== 3.5)
1659 LIBTEST_API
int STDCALL
1660 mono_test_marshal_mixed_point (mixed_point pt
)
1662 // printf("mixed point %d %g\n", pt.x, pt.y);
1663 if (pt
.x
== 5 && pt
.y
== 6.75)
1669 LIBTEST_API
int STDCALL
1670 mono_test_marshal_mixed_point_2 (mixed_point
*pt
)
1672 if (pt
->x
!= 5 || pt
->y
!= 6.75)
1681 LIBTEST_API
int STDCALL
1682 marshal_test_ref_bool(int i
, char *b1
, short *b2
, int *b3
)
1685 if (*b1
!= 0 && *b1
!= 1)
1687 if (*b2
!= 0 && *b2
!= -1) /* variant_bool */
1689 if (*b3
!= 0 && *b3
!= 1)
1691 if (i
== ((*b1
<< 2) | (-*b2
<< 1) | *b3
))
1703 short b2
; /* variant_bool */
1707 LIBTEST_API
int STDCALL
1708 marshal_test_bool_struct(struct BoolStruct
*s
)
1711 if (s
->b1
!= 0 && s
->b1
!= 1)
1713 if (s
->b2
!= 0 && s
->b2
!= -1)
1715 if (s
->b3
!= 0 && s
->b3
!= 1)
1717 if (s
->i
== ((s
->b1
<< 2) | (-s
->b2
<< 1) | s
->b3
))
1734 LIBTEST_API
int STDCALL
1735 mono_test_marshal_long_struct (LongStruct
*s
)
1737 return s
->i
+ s
->l
.l
;
1740 LIBTEST_API
void STDCALL
1741 mono_test_last_error (int err
)
1750 LIBTEST_API
int STDCALL
1751 mono_test_asany (void *ptr
, int what
)
1755 return (*(int*)ptr
== 5) ? 0 : 1;
1757 return strcmp (ptr
, "ABC") == 0 ? 0 : 1;
1759 simplestruct2 ss
= *(simplestruct2
*)ptr
;
1761 if (ss
.a
== 0 && ss
.b
== 1 && ss
.c
== 0 &&
1762 !strcmp (ss
.d
, "TEST") &&
1763 ss
.e
== 99 && ss
.f
== 1.5 && ss
.g
== 42 && ss
.h
== (guint64
)123)
1769 GError
*error
= NULL
;
1772 s
= g_utf16_to_utf8 ((const gunichar2
*)ptr
, -1, NULL
, NULL
, &error
);
1777 if (!strcmp (s
, "ABC")) {
1787 g_assert_not_reached ();
1801 LIBTEST_API
int STDCALL
1802 mono_test_marshal_asany_in (void* ptr
)
1804 AsAnyStruct
*asAny
= (AsAnyStruct
*)ptr
;
1805 int res
= asAny
->i
+ asAny
->j
+ asAny
->k
;
1810 LIBTEST_API
int STDCALL
1811 mono_test_marshal_asany_inout (void* ptr
)
1813 AsAnyStruct
*asAny
= (AsAnyStruct
*)ptr
;
1814 int res
= asAny
->i
+ asAny
->j
+ asAny
->k
;
1816 marshal_free (asAny
->s
);
1826 LIBTEST_API
int STDCALL
1827 mono_test_marshal_asany_out (void* ptr
)
1829 AsAnyStruct
*asAny
= (AsAnyStruct
*)ptr
;
1830 int res
= asAny
->i
+ asAny
->j
+ asAny
->k
;
1841 * AMD64 marshalling tests.
1844 typedef struct amd64_struct1
{
1851 LIBTEST_API amd64_struct1 STDCALL
1852 mono_test_marshal_amd64_pass_return_struct1 (amd64_struct1 s
)
1862 LIBTEST_API amd64_struct1 STDCALL
1863 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
)
1868 s
.l
+= 1 + i1
+ i2
+ i3
+ i4
+ i5
+ i6
+ i7
+ i8
;
1873 typedef struct amd64_struct2
{
1878 LIBTEST_API amd64_struct2 STDCALL
1879 mono_test_marshal_amd64_pass_return_struct2 (amd64_struct2 s
)
1887 typedef struct amd64_struct3
{
1891 LIBTEST_API amd64_struct3 STDCALL
1892 mono_test_marshal_amd64_pass_return_struct3 (amd64_struct3 s
)
1899 typedef struct amd64_struct4
{
1903 LIBTEST_API amd64_struct4 STDCALL
1904 mono_test_marshal_amd64_pass_return_struct4 (amd64_struct4 s
)
1913 * IA64 marshalling tests.
1915 typedef struct test_struct5
{
1919 LIBTEST_API test_struct5 STDCALL
1920 mono_test_marshal_ia64_pass_return_struct5 (double d1
, double d2
, test_struct5 s
, int i
, double d3
, double d4
)
1922 s
.d1
+= d1
+ d2
+ i
;
1923 s
.d2
+= d3
+ d4
+ i
;
1928 typedef struct test_struct6
{
1932 LIBTEST_API test_struct6 STDCALL
1933 mono_test_marshal_ia64_pass_return_struct6 (double d1
, double d2
, test_struct6 s
, int i
, double d3
, double d4
)
1935 s
.d1
+= d1
+ d2
+ i
;
1941 static guint32 custom_res
[2];
1943 LIBTEST_API
void* STDCALL
1944 mono_test_marshal_pass_return_custom (int i
, guint32
*ptr
, int j
)
1946 /* ptr will be freed by CleanupNative, so make a copy */
1947 custom_res
[0] = 0; /* not allocated by AllocHGlobal */
1948 custom_res
[1] = ptr
[1];
1953 LIBTEST_API
int STDCALL
1954 mono_test_marshal_pass_out_custom (int i
, guint32
**ptr
, int j
)
1957 custom_res
[1] = i
+ j
+ 10;
1964 LIBTEST_API
int STDCALL
1965 mono_test_marshal_pass_inout_custom (int i
, guint32
*ptr
, int j
)
1968 ptr
[1] = i
+ ptr
[1] + j
;
1973 LIBTEST_API
int STDCALL
1974 mono_test_marshal_pass_out_byval_custom (int i
, guint32
*ptr
, int j
)
1976 return ptr
== NULL
? 0 : 1;
1979 LIBTEST_API
int STDCALL
1980 mono_test_marshal_pass_byref_custom (int i
, guint32
**ptr
, int j
)
1987 LIBTEST_API
void* STDCALL
1988 mono_test_marshal_pass_return_custom2 (int i
, guint32
*ptr
, int j
)
1990 g_assert_not_reached ();
1995 LIBTEST_API
void* STDCALL
1996 mono_test_marshal_pass_return_custom_null (int i
, guint32
*ptr
, int j
)
1998 g_assert (ptr
== NULL
);
2003 typedef void *(STDCALL
*PassReturnPtrDelegate
) (void *ptr
);
2005 LIBTEST_API
int STDCALL
2006 mono_test_marshal_pass_return_custom_in_delegate (PassReturnPtrDelegate del
)
2015 ptr
= (guint32
*)del (&buf
);
2020 /* FIXME: Freed with FreeHGlobal */
2028 LIBTEST_API
int STDCALL
2029 mono_test_marshal_pass_return_custom_null_in_delegate (PassReturnPtrDelegate del
)
2031 void *ptr
= del (NULL
);
2033 return (ptr
== NULL
) ? 15 : 0;
2036 typedef void (STDCALL
*CustomOutParamDelegate
) (void **pptr
);
2038 LIBTEST_API
int STDCALL
2039 mono_test_marshal_custom_out_param_delegate (CustomOutParamDelegate del
)
2051 typedef int (STDCALL
*ReturnEnumDelegate
) (int e
);
2053 LIBTEST_API
int STDCALL
2054 mono_test_marshal_return_enum_delegate (ReturnEnumDelegate func
)
2064 typedef BlittableStruct (STDCALL
*SimpleDelegate10
) (BlittableStruct ss
);
2066 LIBTEST_API
int STDCALL
2067 mono_test_marshal_blittable_struct_delegate (SimpleDelegate10 delegate
)
2069 BlittableStruct ss
, res
;
2076 res
= delegate (ss
);
2077 if (! ((res
.a
== -1) && (res
.b
== -2) && (res
.c
== -3) && (res
.d
== -55)))
2083 LIBTEST_API
int STDCALL
2084 mono_test_stdcall_name_mangling (int a
, int b
, int c
)
2090 mono_test_stdcall_mismatch_1 (int a
, int b
, int c
)
2095 LIBTEST_API
int STDCALL
2096 mono_test_stdcall_mismatch_2 (int a
, int b
, int c
)
2102 * PASSING AND RETURNING SMALL STRUCTURES FROM DELEGATES TESTS
2109 typedef SmallStruct1 (STDCALL
*SmallStructDelegate1
) (SmallStruct1 ss
);
2111 LIBTEST_API
int STDCALL
2112 mono_test_marshal_small_struct_delegate1 (SmallStructDelegate1 delegate
)
2114 SmallStruct1 ss
, res
;
2118 res
= delegate (ss
);
2119 if (! (res
.i
== -1))
2129 typedef SmallStruct2 (STDCALL
*SmallStructDelegate2
) (SmallStruct2 ss
);
2131 LIBTEST_API
int STDCALL
2132 mono_test_marshal_small_struct_delegate2 (SmallStructDelegate2 delegate
)
2134 SmallStruct2 ss
, res
;
2139 res
= delegate (ss
);
2140 if (! ((res
.i
== -2) && (res
.j
== -3)))
2151 typedef SmallStruct3 (STDCALL
*SmallStructDelegate3
) (SmallStruct3 ss
);
2153 LIBTEST_API
int STDCALL
2154 mono_test_marshal_small_struct_delegate3 (SmallStructDelegate3 delegate
)
2156 SmallStruct3 ss
, res
;
2161 res
= delegate (ss
);
2162 if (! ((res
.i
== -1) && (res
.j
== -2)))
2172 typedef SmallStruct4 (STDCALL
*SmallStructDelegate4
) (SmallStruct4 ss
);
2174 LIBTEST_API
int STDCALL
2175 mono_test_marshal_small_struct_delegate4 (SmallStructDelegate4 delegate
)
2177 SmallStruct4 ss
, res
;
2181 res
= delegate (ss
);
2182 if (! (res
.i
== -1))
2192 typedef SmallStruct5 (STDCALL
*SmallStructDelegate5
) (SmallStruct5 ss
);
2194 LIBTEST_API
int STDCALL
2195 mono_test_marshal_small_struct_delegate5 (SmallStructDelegate5 delegate
)
2197 SmallStruct5 ss
, res
;
2201 res
= delegate (ss
);
2202 if (! (res
.i
== -5))
2212 typedef SmallStruct6 (STDCALL
*SmallStructDelegate6
) (SmallStruct6 ss
);
2214 LIBTEST_API
int STDCALL
2215 mono_test_marshal_small_struct_delegate6 (SmallStructDelegate6 delegate
)
2217 SmallStruct6 ss
, res
;
2222 res
= delegate (ss
);
2223 if (! ((res
.i
== -1) && (res
.j
== -2)))
2234 typedef SmallStruct7 (STDCALL
*SmallStructDelegate7
) (SmallStruct7 ss
);
2236 LIBTEST_API
int STDCALL
2237 mono_test_marshal_small_struct_delegate7 (SmallStructDelegate7 delegate
)
2239 SmallStruct7 ss
, res
;
2244 res
= delegate (ss
);
2245 if (! ((res
.i
== -1) && (res
.j
== -2)))
2255 typedef SmallStruct8 (STDCALL
*SmallStructDelegate8
) (SmallStruct8 ss
);
2257 LIBTEST_API
int STDCALL
2258 mono_test_marshal_small_struct_delegate8 (SmallStructDelegate8 delegate
)
2260 SmallStruct8 ss
, res
;
2264 res
= delegate (ss
);
2265 if (! ((res
.i
== -1.0)))
2275 typedef SmallStruct9 (STDCALL
*SmallStructDelegate9
) (SmallStruct9 ss
);
2277 LIBTEST_API
int STDCALL
2278 mono_test_marshal_small_struct_delegate9 (SmallStructDelegate9 delegate
)
2280 SmallStruct9 ss
, res
;
2284 res
= delegate (ss
);
2285 if (! ((res
.i
== -1.0)))
2295 typedef SmallStruct10 (STDCALL
*SmallStructDelegate10
) (SmallStruct10 ss
);
2297 LIBTEST_API
int STDCALL
2298 mono_test_marshal_small_struct_delegate10 (SmallStructDelegate10 delegate
)
2300 SmallStruct10 ss
, res
;
2305 res
= delegate (ss
);
2306 if (! ((res
.i
== -1.0) && (res
.j
== -2.0)))
2317 typedef SmallStruct11 (STDCALL
*SmallStructDelegate11
) (SmallStruct11 ss
);
2319 LIBTEST_API
int STDCALL
2320 mono_test_marshal_small_struct_delegate11 (SmallStructDelegate11 delegate
)
2322 SmallStruct11 ss
, res
;
2327 res
= delegate (ss
);
2328 if (! ((res
.i
== -1.0) && (res
.j
== -2)))
2334 typedef int (STDCALL
*ArrayDelegate
) (int i
, char *j
, void *arr
);
2336 LIBTEST_API
int STDCALL
2337 mono_test_marshal_array_delegate (void *arr
, int len
, ArrayDelegate del
)
2339 return del (len
, NULL
, arr
);
2342 typedef int (STDCALL
*ArrayDelegateLong
) (gint64 i
, char *j
, void *arr
);
2344 LIBTEST_API
int STDCALL
2345 mono_test_marshal_array_delegate_long (void *arr
, gint64 len
, ArrayDelegateLong del
)
2347 return del (len
, NULL
, arr
);
2350 LIBTEST_API
int STDCALL
2351 mono_test_marshal_out_array_delegate (int *arr
, int len
, ArrayDelegate del
)
2353 del (len
, NULL
, arr
);
2355 if ((arr
[0] != 1) || (arr
[1] != 2))
2361 typedef gunichar2
* (STDCALL
*UnicodeStringDelegate
) (gunichar2
*message
);
2363 LIBTEST_API
int STDCALL
2364 mono_test_marshal_return_unicode_string_delegate (UnicodeStringDelegate del
)
2366 const char m
[] = "abcdef";
2367 gunichar2
*s2
, *res
;
2370 s2
= g_utf8_to_utf16 (m
, -1, NULL
, &len
, NULL
);
2379 LIBTEST_API
int STDCALL
2380 mono_test_marshal_out_string_array_delegate (char **arr
, int len
, ArrayDelegate del
)
2382 del (len
, NULL
, arr
);
2384 if (!strcmp (arr
[0], "ABC") && !strcmp (arr
[1], "DEF"))
2390 typedef int (*CdeclDelegate
) (int i
, int j
);
2392 LIBTEST_API
int STDCALL
2393 mono_test_marshal_cdecl_delegate (CdeclDelegate del
)
2397 for (i
= 0; i
< 1000; ++i
)
2403 typedef char** (STDCALL
*ReturnStringArrayDelegate
) (int i
);
2405 LIBTEST_API
int STDCALL
2406 mono_test_marshal_return_string_array_delegate (ReturnStringArrayDelegate d
)
2414 if (strcmp (arr
[0], "ABC") || strcmp (arr
[1], "DEF"))
2424 typedef int (STDCALL
*ByrefStringDelegate
) (char **s
);
2426 LIBTEST_API
int STDCALL
2427 mono_test_marshal_byref_string_delegate (ByrefStringDelegate d
)
2429 char *s
= (char*)"ABC";
2436 if (!strcmp (s
, "DEF"))
2446 LIBTEST_API
int STDCALL
2447 add_delegate (int i
, int j
)
2452 LIBTEST_API gpointer STDCALL
2453 mono_test_marshal_return_fnptr (void)
2455 return &add_delegate
;
2458 LIBTEST_API
int STDCALL
2461 printf ("codigo %x\n", code
);
2469 LIBTEST_API HandleRef STDCALL
2470 mono_xr_as_handle (int code
)
2474 memset (&ref
, 0, sizeof (ref
));
2486 LIBTEST_API
int STDCALL
2487 mono_safe_handle_struct_ref (HandleStructs
*x
)
2489 printf ("Dingus Ref! \n");
2490 printf ("Values: %d %d %p %p\n", x
->a
, x
->b
, x
->handle1
, x
->handle2
);
2496 if (x
->handle1
!= (void*) 0x7080feed)
2499 if (x
->handle2
!= (void*) 0x1234abcd)
2505 LIBTEST_API
int STDCALL
2506 mono_safe_handle_struct (HandleStructs x
)
2508 printf ("Dingus Standard! \n");
2509 printf ("Values: %d %d %p %p\n", x
.a
, x
.b
, x
.handle1
, x
.handle2
);
2515 if (x
.handle1
!= (void*) 0x7080feed)
2518 if (x
.handle2
!= (void*) 0x1234abcd)
2528 LIBTEST_API
int STDCALL
2529 mono_safe_handle_struct_simple (TrivialHandle x
)
2531 printf ("The value is %p\n", x
.a
);
2532 return ((int)(gsize
)x
.a
) * 2;
2535 LIBTEST_API
int STDCALL
2536 mono_safe_handle_return (void)
2541 LIBTEST_API
void STDCALL
2542 mono_safe_handle_ref (void **handle
)
2545 *handle
= (void *) 0xbad;
2549 *handle
= (void *) 0x800d;
2552 LIBTEST_API
double STDCALL
2553 mono_test_marshal_date_time (double d
, double *d2
)
2625 VT_USERDEFINED
= 29,
2633 VT_STREAMED_OBJECT
= 68,
2634 VT_STORED_OBJECT
= 69,
2635 VT_BLOB_OBJECT
= 70,
2643 void VariantInit(VARIANT
* vt
)
2660 LIBTEST_API
int STDCALL
2661 mono_test_marshal_bstr_in(gunichar2
* bstr
)
2664 gchar
* bstr_utf8
= g_utf16_to_utf8 (bstr
, -1, NULL
, NULL
, NULL
);
2665 result
= strcmp("mono_test_marshal_bstr_in", bstr_utf8
);
2672 LIBTEST_API
int STDCALL
2673 mono_test_marshal_bstr_out(gunichar2
** bstr
)
2675 *bstr
= marshal_bstr_alloc ("mono_test_marshal_bstr_out");
2679 LIBTEST_API
int STDCALL
2680 mono_test_marshal_bstr_in_null(gunichar2
* bstr
)
2687 LIBTEST_API
int STDCALL
2688 mono_test_marshal_bstr_out_null(gunichar2
** bstr
)
2694 LIBTEST_API
int STDCALL
2695 mono_test_marshal_variant_in_sbyte(VARIANT variant
)
2697 if (variant
.vt
== VT_I1
&& variant
.cVal
== 100)
2702 LIBTEST_API
int STDCALL
2703 mono_test_marshal_variant_in_byte(VARIANT variant
)
2705 if (variant
.vt
== VT_UI1
&& variant
.bVal
== 100)
2710 LIBTEST_API
int STDCALL
2711 mono_test_marshal_variant_in_short(VARIANT variant
)
2713 if (variant
.vt
== VT_I2
&& variant
.iVal
== 314)
2718 LIBTEST_API
int STDCALL
2719 mono_test_marshal_variant_in_ushort(VARIANT variant
)
2721 if (variant
.vt
== VT_UI2
&& variant
.uiVal
== 314)
2726 LIBTEST_API
int STDCALL
2727 mono_test_marshal_variant_in_int(VARIANT variant
)
2729 if (variant
.vt
== VT_I4
&& variant
.lVal
== 314)
2734 LIBTEST_API
int STDCALL
2735 mono_test_marshal_variant_in_uint(VARIANT variant
)
2737 if (variant
.vt
== VT_UI4
&& variant
.ulVal
== 314)
2742 LIBTEST_API
int STDCALL
2743 mono_test_marshal_variant_in_long(VARIANT variant
)
2745 if (variant
.vt
== VT_I8
&& variant
.llVal
== 314)
2750 LIBTEST_API
int STDCALL
2751 mono_test_marshal_variant_in_ulong(VARIANT variant
)
2753 if (variant
.vt
== VT_UI8
&& variant
.ullVal
== 314)
2758 LIBTEST_API
int STDCALL
2759 mono_test_marshal_variant_in_float(VARIANT variant
)
2761 if (variant
.vt
== VT_R4
&& (variant
.fltVal
- 3.14)/3.14 < .001)
2766 LIBTEST_API
int STDCALL
2767 mono_test_marshal_variant_in_double(VARIANT variant
)
2769 if (variant
.vt
== VT_R8
&& (variant
.dblVal
- 3.14)/3.14 < .001)
2774 LIBTEST_API
int STDCALL
2775 mono_test_marshal_variant_in_bstr(VARIANT variant
)
2778 gchar
* bstr_utf8
= g_utf16_to_utf8 (variant
.bstrVal
, -1, NULL
, NULL
, NULL
);
2779 result
= strcmp("PI", bstr_utf8
);
2782 if (variant
.vt
== VT_BSTR
&& !result
)
2787 LIBTEST_API
int STDCALL
2788 mono_test_marshal_variant_in_bool_true (VARIANT variant
)
2790 if (variant
.vt
== VT_BOOL
&& variant
.boolVal
== VARIANT_TRUE
)
2795 LIBTEST_API
int STDCALL
2796 mono_test_marshal_variant_in_bool_false (VARIANT variant
)
2798 if (variant
.vt
== VT_BOOL
&& variant
.boolVal
== VARIANT_FALSE
)
2803 LIBTEST_API
int STDCALL
2804 mono_test_marshal_variant_out_sbyte(VARIANT
* variant
)
2806 variant
->vt
= VT_I1
;
2807 variant
->cVal
= 100;
2812 LIBTEST_API
int STDCALL
2813 mono_test_marshal_variant_out_sbyte_byref(VARIANT
* variant
)
2815 variant
->vt
= VT_I1
|VT_BYREF
;
2816 variant
->byref
= marshal_alloc(1);
2817 *((gint8
*)variant
->byref
) = 100;
2822 LIBTEST_API
int STDCALL
2823 mono_test_marshal_variant_out_byte(VARIANT
* variant
)
2825 variant
->vt
= VT_UI1
;
2826 variant
->bVal
= 100;
2831 LIBTEST_API
int STDCALL
2832 mono_test_marshal_variant_out_byte_byref(VARIANT
* variant
)
2834 variant
->vt
= VT_UI1
|VT_BYREF
;
2835 variant
->byref
= marshal_alloc(1);
2836 *((gint8
*)variant
->byref
) = 100;
2841 LIBTEST_API
int STDCALL
2842 mono_test_marshal_variant_out_short(VARIANT
* variant
)
2844 variant
->vt
= VT_I2
;
2845 variant
->iVal
= 314;
2850 LIBTEST_API
int STDCALL
2851 mono_test_marshal_variant_out_short_byref(VARIANT
* variant
)
2853 variant
->vt
= VT_I2
|VT_BYREF
;
2854 variant
->byref
= marshal_alloc(2);
2855 *((gint16
*)variant
->byref
) = 314;
2860 LIBTEST_API
int STDCALL
2861 mono_test_marshal_variant_out_ushort(VARIANT
* variant
)
2863 variant
->vt
= VT_UI2
;
2864 variant
->uiVal
= 314;
2869 LIBTEST_API
int STDCALL
2870 mono_test_marshal_variant_out_ushort_byref(VARIANT
* variant
)
2872 variant
->vt
= VT_UI2
|VT_BYREF
;
2873 variant
->byref
= marshal_alloc(2);
2874 *((guint16
*)variant
->byref
) = 314;
2879 LIBTEST_API
int STDCALL
2880 mono_test_marshal_variant_out_int(VARIANT
* variant
)
2882 variant
->vt
= VT_I4
;
2883 variant
->lVal
= 314;
2888 LIBTEST_API
int STDCALL
2889 mono_test_marshal_variant_out_int_byref(VARIANT
* variant
)
2891 variant
->vt
= VT_I4
|VT_BYREF
;
2892 variant
->byref
= marshal_alloc(4);
2893 *((gint32
*)variant
->byref
) = 314;
2898 LIBTEST_API
int STDCALL
2899 mono_test_marshal_variant_out_uint(VARIANT
* variant
)
2901 variant
->vt
= VT_UI4
;
2902 variant
->ulVal
= 314;
2907 LIBTEST_API
int STDCALL
2908 mono_test_marshal_variant_out_uint_byref(VARIANT
* variant
)
2910 variant
->vt
= VT_UI4
|VT_BYREF
;
2911 variant
->byref
= marshal_alloc(4);
2912 *((guint32
*)variant
->byref
) = 314;
2917 LIBTEST_API
int STDCALL
2918 mono_test_marshal_variant_out_long(VARIANT
* variant
)
2920 variant
->vt
= VT_I8
;
2921 variant
->llVal
= 314;
2926 LIBTEST_API
int STDCALL
2927 mono_test_marshal_variant_out_long_byref(VARIANT
* variant
)
2929 variant
->vt
= VT_I8
|VT_BYREF
;
2930 variant
->byref
= marshal_alloc(8);
2931 *((gint64
*)variant
->byref
) = 314;
2936 LIBTEST_API
int STDCALL
2937 mono_test_marshal_variant_out_ulong(VARIANT
* variant
)
2939 variant
->vt
= VT_UI8
;
2940 variant
->ullVal
= 314;
2945 LIBTEST_API
int STDCALL
2946 mono_test_marshal_variant_out_ulong_byref(VARIANT
* variant
)
2948 variant
->vt
= VT_UI8
|VT_BYREF
;
2949 variant
->byref
= marshal_alloc(8);
2950 *((guint64
*)variant
->byref
) = 314;
2955 LIBTEST_API
int STDCALL
2956 mono_test_marshal_variant_out_float(VARIANT
* variant
)
2958 variant
->vt
= VT_R4
;
2959 variant
->fltVal
= 3.14;
2964 LIBTEST_API
int STDCALL
2965 mono_test_marshal_variant_out_float_byref(VARIANT
* variant
)
2967 variant
->vt
= VT_R4
|VT_BYREF
;
2968 variant
->byref
= marshal_alloc(4);
2969 *((float*)variant
->byref
) = 3.14;
2974 LIBTEST_API
int STDCALL
2975 mono_test_marshal_variant_out_double(VARIANT
* variant
)
2977 variant
->vt
= VT_R8
;
2978 variant
->dblVal
= 3.14;
2983 LIBTEST_API
int STDCALL
2984 mono_test_marshal_variant_out_double_byref(VARIANT
* variant
)
2986 variant
->vt
= VT_R8
|VT_BYREF
;
2987 variant
->byref
= marshal_alloc(8);
2988 *((double*)variant
->byref
) = 3.14;
2993 LIBTEST_API
int STDCALL
2994 mono_test_marshal_variant_out_bstr(VARIANT
* variant
)
2996 variant
->vt
= VT_BSTR
;
2997 variant
->bstrVal
= marshal_bstr_alloc("PI");
3002 LIBTEST_API
int STDCALL
3003 mono_test_marshal_variant_out_bstr_byref(VARIANT
* variant
)
3005 variant
->vt
= VT_BSTR
|VT_BYREF
;
3006 variant
->byref
= marshal_alloc(sizeof(gpointer
));
3007 *((gunichar
**)variant
->byref
) = (gunichar
*)marshal_bstr_alloc("PI");
3012 LIBTEST_API
int STDCALL
3013 mono_test_marshal_variant_out_bool_true (VARIANT
* variant
)
3015 variant
->vt
= VT_BOOL
;
3016 variant
->boolVal
= VARIANT_TRUE
;
3021 LIBTEST_API
int STDCALL
3022 mono_test_marshal_variant_out_bool_true_byref (VARIANT
* variant
)
3024 variant
->vt
= VT_BOOL
|VT_BYREF
;
3025 variant
->byref
= marshal_alloc(2);
3026 *((gint16
*)variant
->byref
) = VARIANT_TRUE
;
3031 LIBTEST_API
int STDCALL
3032 mono_test_marshal_variant_out_bool_false (VARIANT
* variant
)
3034 variant
->vt
= VT_BOOL
;
3035 variant
->boolVal
= VARIANT_FALSE
;
3040 LIBTEST_API
int STDCALL
3041 mono_test_marshal_variant_out_bool_false_byref (VARIANT
* variant
)
3043 variant
->vt
= VT_BOOL
|VT_BYREF
;
3044 variant
->byref
= marshal_alloc(2);
3045 *((gint16
*)variant
->byref
) = VARIANT_FALSE
;
3050 typedef int (STDCALL
*VarFunc
) (int vt
, VARIANT variant
);
3051 typedef int (STDCALL
*VarRefFunc
) (int vt
, VARIANT
* variant
);
3053 LIBTEST_API
int STDCALL
3054 mono_test_marshal_variant_in_sbyte_unmanaged(VarFunc func
)
3059 return func (VT_I1
, vt
);
3062 LIBTEST_API
int STDCALL
3063 mono_test_marshal_variant_in_byte_unmanaged(VarFunc func
)
3068 return func (VT_UI1
, vt
);
3071 LIBTEST_API
int STDCALL
3072 mono_test_marshal_variant_in_short_unmanaged(VarFunc func
)
3077 return func (VT_I2
, vt
);
3080 LIBTEST_API
int STDCALL
3081 mono_test_marshal_variant_in_ushort_unmanaged(VarFunc func
)
3086 return func (VT_UI2
, vt
);
3089 LIBTEST_API
int STDCALL
3090 mono_test_marshal_variant_in_int_unmanaged(VarFunc func
)
3095 return func (VT_I4
, vt
);
3098 LIBTEST_API
int STDCALL
3099 mono_test_marshal_variant_in_uint_unmanaged(VarFunc func
)
3104 return func (VT_UI4
, vt
);
3107 LIBTEST_API
int STDCALL
3108 mono_test_marshal_variant_in_long_unmanaged(VarFunc func
)
3113 return func (VT_I8
, vt
);
3116 LIBTEST_API
int STDCALL
3117 mono_test_marshal_variant_in_ulong_unmanaged(VarFunc func
)
3122 return func (VT_UI8
, vt
);
3125 LIBTEST_API
int STDCALL
3126 mono_test_marshal_variant_in_float_unmanaged(VarFunc func
)
3131 return func (VT_R4
, vt
);
3134 LIBTEST_API
int STDCALL
3135 mono_test_marshal_variant_in_double_unmanaged(VarFunc func
)
3140 return func (VT_R8
, vt
);
3143 LIBTEST_API
int STDCALL
3144 mono_test_marshal_variant_in_bstr_unmanaged(VarFunc func
)
3148 vt
.bstrVal
= marshal_bstr_alloc("PI");
3149 return func (VT_BSTR
, vt
);
3152 LIBTEST_API
int STDCALL
3153 mono_test_marshal_variant_in_bool_true_unmanaged(VarFunc func
)
3157 vt
.boolVal
= VARIANT_TRUE
;
3158 return func (VT_BOOL
, vt
);
3161 LIBTEST_API
int STDCALL
3162 mono_test_marshal_variant_in_bool_false_unmanaged(VarFunc func
)
3166 vt
.boolVal
= VARIANT_FALSE
;
3167 return func (VT_BOOL
, vt
);
3170 LIBTEST_API
int STDCALL
3171 mono_test_marshal_variant_out_sbyte_unmanaged(VarRefFunc func
)
3176 if (vt
.vt
== VT_I1
&& vt
.cVal
== -100)
3181 LIBTEST_API
int STDCALL
3182 mono_test_marshal_variant_out_byte_unmanaged(VarRefFunc func
)
3187 if (vt
.vt
== VT_UI1
&& vt
.bVal
== 100)
3192 LIBTEST_API
int STDCALL
3193 mono_test_marshal_variant_out_short_unmanaged(VarRefFunc func
)
3198 if (vt
.vt
== VT_I2
&& vt
.iVal
== -100)
3203 LIBTEST_API
int STDCALL
3204 mono_test_marshal_variant_out_ushort_unmanaged(VarRefFunc func
)
3209 if (vt
.vt
== VT_UI2
&& vt
.uiVal
== 100)
3214 LIBTEST_API
int STDCALL
3215 mono_test_marshal_variant_out_int_unmanaged(VarRefFunc func
)
3220 if (vt
.vt
== VT_I4
&& vt
.lVal
== -100)
3225 LIBTEST_API
int STDCALL
3226 mono_test_marshal_variant_out_uint_unmanaged(VarRefFunc func
)
3231 if (vt
.vt
== VT_UI4
&& vt
.ulVal
== 100)
3236 LIBTEST_API
int STDCALL
3237 mono_test_marshal_variant_out_long_unmanaged(VarRefFunc func
)
3242 if (vt
.vt
== VT_I8
&& vt
.llVal
== -100)
3247 LIBTEST_API
int STDCALL
3248 mono_test_marshal_variant_out_ulong_unmanaged(VarRefFunc func
)
3253 if (vt
.vt
== VT_UI8
&& vt
.ullVal
== 100)
3258 LIBTEST_API
int STDCALL
3259 mono_test_marshal_variant_out_float_unmanaged(VarRefFunc func
)
3264 if (vt
.vt
== VT_R4
&& fabs (vt
.fltVal
- 3.14f
) < 1e-10)
3269 LIBTEST_API
int STDCALL
3270 mono_test_marshal_variant_out_double_unmanaged(VarRefFunc func
)
3275 if (vt
.vt
== VT_R8
&& fabs (vt
.dblVal
- 3.14) < 1e-10)
3280 LIBTEST_API
int STDCALL
3281 mono_test_marshal_variant_out_bstr_unmanaged(VarRefFunc func
)
3289 func (VT_BSTR
, &vt
);
3290 bstr_utf8
= g_utf16_to_utf8 (vt
.bstrVal
, -1, NULL
, NULL
, NULL
);
3291 result
= strcmp("PI", bstr_utf8
);
3293 if (vt
.vt
== VT_BSTR
&& !result
)
3298 LIBTEST_API
int STDCALL
3299 mono_test_marshal_variant_out_bool_true_unmanaged(VarRefFunc func
)
3303 func (VT_BOOL
, &vt
);
3304 if (vt
.vt
== VT_BOOL
&& vt
.boolVal
== VARIANT_TRUE
)
3309 LIBTEST_API
int STDCALL
3310 mono_test_marshal_variant_out_bool_false_unmanaged(VarRefFunc func
)
3314 func (VT_BOOL
, &vt
);
3315 if (vt
.vt
== VT_BOOL
&& vt
.boolVal
== VARIANT_TRUE
)
3320 typedef struct MonoComObject MonoComObject
;
3324 int (STDCALL
*QueryInterface
)(MonoComObject
* pUnk
, gpointer riid
, gpointer
* ppv
);
3325 int (STDCALL
*AddRef
)(MonoComObject
* pUnk
);
3326 int (STDCALL
*Release
)(MonoComObject
* pUnk
);
3327 int (STDCALL
*get_ITest
)(MonoComObject
* pUnk
, MonoComObject
* *ppUnk
);
3328 int (STDCALL
*SByteIn
)(MonoComObject
* pUnk
, char a
);
3329 int (STDCALL
*ByteIn
)(MonoComObject
* pUnk
, unsigned char a
);
3330 int (STDCALL
*ShortIn
)(MonoComObject
* pUnk
, short a
);
3331 int (STDCALL
*UShortIn
)(MonoComObject
* pUnk
, unsigned short a
);
3332 int (STDCALL
*IntIn
)(MonoComObject
* pUnk
, int a
);
3333 int (STDCALL
*UIntIn
)(MonoComObject
* pUnk
, unsigned int a
);
3334 int (STDCALL
*LongIn
)(MonoComObject
* pUnk
, gint64 a
);
3335 int (STDCALL
*ULongIn
)(MonoComObject
* pUnk
, guint64 a
);
3336 int (STDCALL
*FloatIn
)(MonoComObject
* pUnk
, float a
);
3337 int (STDCALL
*DoubleIn
)(MonoComObject
* pUnk
, double a
);
3338 int (STDCALL
*ITestIn
)(MonoComObject
* pUnk
, MonoComObject
* pUnk2
);
3339 int (STDCALL
*ITestOut
)(MonoComObject
* pUnk
, MonoComObject
* *ppUnk
);
3342 struct MonoComObject
3348 static GUID IID_ITest
= {0, 0, 0, {0,0,0,0,0,0,0,1}};
3349 static GUID IID_IMonoUnknown
= {0, 0, 0, {0xc0,0,0,0,0,0,0,0x46}};
3350 static GUID IID_IMonoDispatch
= {0x00020400, 0, 0, {0xc0,0,0,0,0,0,0,0x46}};
3352 LIBTEST_API
int STDCALL
3353 MonoQueryInterface(MonoComObject
* pUnk
, gpointer riid
, gpointer
* ppv
)
3357 if (!memcmp(riid
, &IID_IMonoUnknown
, sizeof(GUID
))) {
3361 else if (!memcmp(riid
, &IID_ITest
, sizeof(GUID
))) {
3365 else if (!memcmp(riid
, &IID_IMonoDispatch
, sizeof(GUID
))) {
3369 return 0x80004002; //E_NOINTERFACE;
3372 LIBTEST_API
int STDCALL
3373 MonoAddRef(MonoComObject
* pUnk
)
3375 return ++(pUnk
->m_ref
);
3378 LIBTEST_API
int STDCALL
3379 MonoRelease(MonoComObject
* pUnk
)
3381 return --(pUnk
->m_ref
);
3384 LIBTEST_API
int STDCALL
3385 SByteIn(MonoComObject
* pUnk
, char a
)
3390 LIBTEST_API
int STDCALL
3391 ByteIn(MonoComObject
* pUnk
, unsigned char a
)
3396 LIBTEST_API
int STDCALL
3397 ShortIn(MonoComObject
* pUnk
, short a
)
3402 LIBTEST_API
int STDCALL
3403 UShortIn(MonoComObject
* pUnk
, unsigned short a
)
3408 LIBTEST_API
int STDCALL
3409 IntIn(MonoComObject
* pUnk
, int a
)
3414 LIBTEST_API
int STDCALL
3415 UIntIn(MonoComObject
* pUnk
, unsigned int a
)
3420 LIBTEST_API
int STDCALL
3421 LongIn(MonoComObject
* pUnk
, gint64 a
)
3426 LIBTEST_API
int STDCALL
3427 ULongIn(MonoComObject
* pUnk
, guint64 a
)
3432 LIBTEST_API
int STDCALL
3433 FloatIn(MonoComObject
* pUnk
, float a
)
3438 LIBTEST_API
int STDCALL
3439 DoubleIn(MonoComObject
* pUnk
, double a
)
3444 LIBTEST_API
int STDCALL
3445 ITestIn(MonoComObject
* pUnk
, MonoComObject
*pUnk2
)
3450 LIBTEST_API
int STDCALL
3451 ITestOut(MonoComObject
* pUnk
, MonoComObject
* *ppUnk
)
3456 static void create_com_object (MonoComObject
** pOut
);
3458 LIBTEST_API
int STDCALL
3459 get_ITest(MonoComObject
* pUnk
, MonoComObject
* *ppUnk
)
3461 create_com_object (ppUnk
);
3465 static void create_com_object (MonoComObject
** pOut
)
3467 *pOut
= marshal_new0 (MonoComObject
, 1);
3468 (*pOut
)->vtbl
= marshal_new0 (MonoIUnknown
, 1);
3471 (*pOut
)->vtbl
->QueryInterface
= MonoQueryInterface
;
3472 (*pOut
)->vtbl
->AddRef
= MonoAddRef
;
3473 (*pOut
)->vtbl
->Release
= MonoRelease
;
3474 (*pOut
)->vtbl
->SByteIn
= SByteIn
;
3475 (*pOut
)->vtbl
->ByteIn
= ByteIn
;
3476 (*pOut
)->vtbl
->ShortIn
= ShortIn
;
3477 (*pOut
)->vtbl
->UShortIn
= UShortIn
;
3478 (*pOut
)->vtbl
->IntIn
= IntIn
;
3479 (*pOut
)->vtbl
->UIntIn
= UIntIn
;
3480 (*pOut
)->vtbl
->LongIn
= LongIn
;
3481 (*pOut
)->vtbl
->ULongIn
= ULongIn
;
3482 (*pOut
)->vtbl
->FloatIn
= FloatIn
;
3483 (*pOut
)->vtbl
->DoubleIn
= DoubleIn
;
3484 (*pOut
)->vtbl
->ITestIn
= ITestIn
;
3485 (*pOut
)->vtbl
->ITestOut
= ITestOut
;
3486 (*pOut
)->vtbl
->get_ITest
= get_ITest
;
3489 static MonoComObject
* same_object
= NULL
;
3491 LIBTEST_API
int STDCALL
3492 mono_test_marshal_com_object_create(MonoComObject
* *pUnk
)
3494 create_com_object (pUnk
);
3497 same_object
= *pUnk
;
3502 LIBTEST_API
int STDCALL
3503 mono_test_marshal_com_object_same(MonoComObject
* *pUnk
)
3505 *pUnk
= same_object
;
3510 LIBTEST_API
int STDCALL
3511 mono_test_marshal_com_object_destroy(MonoComObject
*pUnk
)
3513 int ref
= --(pUnk
->m_ref
);
3520 LIBTEST_API
int STDCALL
3521 mono_test_marshal_com_object_ref_count(MonoComObject
*pUnk
)
3526 LIBTEST_API
int STDCALL
3527 mono_test_marshal_ccw_itest (MonoComObject
*pUnk
)
3530 MonoComObject
* pTest
;
3535 hr
= pUnk
->vtbl
->SByteIn (pUnk
, -100);
3538 hr
= pUnk
->vtbl
->ByteIn (pUnk
, 100);
3541 hr
= pUnk
->vtbl
->ShortIn (pUnk
, -100);
3544 hr
= pUnk
->vtbl
->UShortIn (pUnk
, 100);
3547 hr
= pUnk
->vtbl
->IntIn (pUnk
, -100);
3550 hr
= pUnk
->vtbl
->UIntIn (pUnk
, 100);
3553 hr
= pUnk
->vtbl
->LongIn (pUnk
, -100);
3556 hr
= pUnk
->vtbl
->ULongIn (pUnk
, 100);
3559 hr
= pUnk
->vtbl
->FloatIn (pUnk
, 3.14f
);
3562 hr
= pUnk
->vtbl
->DoubleIn (pUnk
, 3.14);
3565 hr
= pUnk
->vtbl
->ITestIn (pUnk
, pUnk
);
3568 hr
= pUnk
->vtbl
->ITestOut (pUnk
, &pTest
);
3576 * mono_method_get_unmanaged_thunk tests
3579 #if defined(__GNUC__) && ((defined(__i386__) && (defined(__linux__) || defined (__APPLE__)) || defined (__FreeBSD__) || defined(__OpenBSD__)) || (defined(__ppc__) && defined(__APPLE__)))
3580 #define ALIGN(size) __attribute__ ((aligned(size)))
3586 /* thunks.cs:TestStruct */
3587 typedef struct _TestStruct
{
3592 /* Searches for mono symbols in all loaded modules */
3594 lookup_mono_symbol (const char *symbol_name
)
3597 if (g_module_symbol (g_module_open (NULL
, G_MODULE_BIND_LAZY
), symbol_name
, &symbol
))
3603 LIBTEST_API gpointer STDCALL
3604 mono_test_marshal_lookup_symbol (const char *symbol_name
)
3606 return lookup_mono_symbol (symbol_name
);
3609 #define MONO_BEGIN_EFRAME { void *__dummy; void *__region_cookie = mono_threads_enter_gc_unsafe_region ? mono_threads_enter_gc_unsafe_region (&__dummy) : NULL;
3610 #define MONO_END_EFRAME if (mono_threads_exit_gc_unsafe_region) mono_threads_exit_gc_unsafe_region (__region_cookie, &__dummy); }
3613 * test_method_thunk:
3615 * @test_id: the test number
3616 * @test_method_handle: MonoMethod* of the C# test method
3617 * @create_object_method_handle: MonoMethod* of thunks.cs:Test.CreateObject
3619 LIBTEST_API
int STDCALL
3620 test_method_thunk (int test_id
, gpointer test_method_handle
, gpointer create_object_method_handle
)
3624 gpointer (*mono_method_get_unmanaged_thunk
)(gpointer
)
3625 = (gpointer (*)(gpointer
))lookup_mono_symbol ("mono_method_get_unmanaged_thunk");
3627 gpointer (*mono_string_new_wrapper
)(const char *)
3628 = (gpointer (*)(const char *))lookup_mono_symbol ("mono_string_new_wrapper");
3630 char *(*mono_string_to_utf8
)(gpointer
)
3631 = (char *(*)(gpointer
))lookup_mono_symbol ("mono_string_to_utf8");
3633 gpointer (*mono_object_unbox
)(gpointer
)
3634 = (gpointer (*)(gpointer
))lookup_mono_symbol ("mono_object_unbox");
3636 gpointer (*mono_threads_enter_gc_unsafe_region
) (gpointer
)
3637 = (gpointer (*)(gpointer
))lookup_mono_symbol ("mono_threads_enter_gc_unsafe_region");
3639 void (*mono_threads_exit_gc_unsafe_region
) (gpointer
, gpointer
)
3640 = (void (*)(gpointer
, gpointer
))lookup_mono_symbol ("mono_threads_exit_gc_unsafe_region");
3644 gpointer test_method
, ex
= NULL
;
3645 gpointer (STDCALL
*CreateObject
)(gpointer
*);
3649 if (!mono_method_get_unmanaged_thunk
) {
3654 test_method
= mono_method_get_unmanaged_thunk (test_method_handle
);
3660 CreateObject
= (gpointer (STDCALL
*)(gpointer
*))mono_method_get_unmanaged_thunk (create_object_method_handle
);
3661 if (!CreateObject
) {
3670 /* thunks.cs:Test.Test0 */
3671 void (STDCALL
*F
)(gpointer
*) = (void (STDCALL
*)(gpointer
*))test_method
;
3677 /* thunks.cs:Test.Test1 */
3678 int (STDCALL
*F
)(gpointer
*) = (int (STDCALL
*)(gpointer
*))test_method
;
3679 if (F (&ex
) != 42) {
3687 /* thunks.cs:Test.Test2 */
3688 gpointer (STDCALL
*F
)(gpointer
, gpointer
*) = (gpointer (STDCALL
*)(gpointer
, gpointer
*))test_method
;
3689 gpointer str
= mono_string_new_wrapper ("foo");
3690 if (str
!= F (str
, &ex
)) {
3698 /* thunks.cs:Test.Test3 */
3699 gpointer (STDCALL
*F
)(gpointer
, gpointer
, gpointer
*);
3703 F
= (gpointer (STDCALL
*)(gpointer
, gpointer
, gpointer
*))test_method
;
3704 obj
= CreateObject (&ex
);
3705 str
= mono_string_new_wrapper ("bar");
3707 if (str
!= F (obj
, str
, &ex
)) {
3715 /* thunks.cs:Test.Test4 */
3716 int (STDCALL
*F
)(gpointer
, gpointer
, int, gpointer
*);
3720 F
= (int (STDCALL
*)(gpointer
, gpointer
, int, gpointer
*))test_method
;
3721 obj
= CreateObject (&ex
);
3722 str
= mono_string_new_wrapper ("bar");
3724 if (42 != F (obj
, str
, 42, &ex
)) {
3733 /* thunks.cs:Test.Test5 */
3734 int (STDCALL
*F
)(gpointer
, gpointer
, int, gpointer
*);
3738 F
= (int (STDCALL
*)(gpointer
, gpointer
, int, gpointer
*))test_method
;
3739 obj
= CreateObject (&ex
);
3740 str
= mono_string_new_wrapper ("bar");
3742 F (obj
, str
, 42, &ex
);
3752 /* thunks.cs:Test.Test6 */
3753 int (STDCALL
*F
)(gpointer
, guint8
, gint16
, gint32
, gint64
, float, double,
3754 gpointer
, gpointer
*);
3756 gpointer str
= mono_string_new_wrapper ("Test6");
3759 F
= (int (STDCALL
*)(gpointer
, guint8
, gint16
, gint32
, gint64
, float, double, gpointer
, gpointer
*))test_method
;
3760 obj
= CreateObject (&ex
);
3762 res
= F (obj
, 254, 32700, -245378, 6789600, 3.1415, 3.1415, str
, &ex
);
3777 /* thunks.cs:Test.Test7 */
3778 gint64 (STDCALL
*F
)(gpointer
*) = (gint64 (STDCALL
*)(gpointer
*))test_method
;
3779 if (F (&ex
) != G_MAXINT64
) {
3787 /* thunks.cs:Test.Test8 */
3788 void (STDCALL
*F
)(guint8
*, gint16
*, gint32
*, gint64
*, float*, double*,
3789 gpointer
*, gpointer
*);
3799 F
= (void (STDCALL
*)(guint8
*, gint16
*, gint32
*, gint64
*, float *, double *,
3800 gpointer
*, gpointer
*))test_method
;
3802 F (&a1
, &a2
, &a3
, &a4
, &a5
, &a6
, &a7
, &ex
);
3812 (fabs (a5
- 3.1415) < 0.001) &&
3813 (fabs (a6
- 3.1415) < 0.001) &&
3814 strcmp (mono_string_to_utf8 (a7
), "Test8") == 0)){
3823 /* thunks.cs:Test.Test9 */
3824 void (STDCALL
*F
)(guint8
*, gint16
*, gint32
*, gint64
*, float*, double*,
3825 gpointer
*, gpointer
*);
3835 F
= (void (STDCALL
*)(guint8
*, gint16
*, gint32
*, gint64
*, float *, double *,
3836 gpointer
*, gpointer
*))test_method
;
3838 F (&a1
, &a2
, &a3
, &a4
, &a5
, &a6
, &a7
, &ex
);
3848 /* thunks.cs:Test.Test10 */
3849 void (STDCALL
*F
)(gpointer
*, gpointer
*);
3851 gpointer obj1
, obj2
;
3853 obj1
= obj2
= CreateObject (&ex
);
3859 F
= (void (STDCALL
*)(gpointer
*, gpointer
*))test_method
;
3876 /* thunks.cs:TestStruct.Test0 */
3877 int (STDCALL
*F
)(gpointer
*, gpointer
*);
3883 obj
= CreateObject (&ex
);
3894 a1
= (TestStruct
*)mono_object_unbox (obj
);
3903 F
= (int (STDCALL
*)(gpointer
*, gpointer
*))test_method
;
3905 res
= F ((gpointer
*)obj
, &ex
);
3916 /* check whether the call was really by value */
3917 if (a1
->A
!= 42 || a1
->B
!= 3.1415) {
3926 /* thunks.cs:TestStruct.Test1 */
3927 void (STDCALL
*F
)(gpointer
, gpointer
*);
3932 obj
= CreateObject (&ex
);
3943 a1
= (TestStruct
*)mono_object_unbox (obj
);
3949 F
= (void (STDCALL
*)(gpointer
, gpointer
*))test_method
;
3962 if (!(fabs (a1
->B
- 3.1415) < 0.001)) {
3971 /* thunks.cs:TestStruct.Test2 */
3972 gpointer (STDCALL
*F
)(gpointer
*);
3977 F
= (gpointer (STDCALL
*)(gpointer
*))test_method
;
3990 a1
= (TestStruct
*)mono_object_unbox (obj
);
3997 if (!(fabs (a1
->B
- 3.1415) < 0.001)) {
4006 /* thunks.cs:TestStruct.Test3 */
4007 void (STDCALL
*F
)(gpointer
, gpointer
*);
4012 obj
= CreateObject (&ex
);
4023 a1
= (TestStruct
*)mono_object_unbox (obj
);
4033 F
= (void (STDCALL
*)(gpointer
, gpointer
*))test_method
;
4069 LIBTEST_API
int STDCALL
4070 mono_test_Winx64_struct1_in (winx64_struct1 var
)
4083 LIBTEST_API
int STDCALL
4084 mono_test_Winx64_struct2_in (winx64_struct2 var
)
4101 LIBTEST_API
int STDCALL
4102 mono_test_Winx64_struct3_in (winx64_struct3 var
)
4108 if (var
.c
!= 0x1234)
4121 LIBTEST_API
int STDCALL
4122 mono_test_Winx64_struct4_in (winx64_struct4 var
)
4128 if (var
.c
!= 0x1234)
4130 if (var
.d
!= 0x87654321)
4142 LIBTEST_API
int STDCALL
4143 mono_test_Winx64_struct5_in (winx64_struct5 var
)
4161 LIBTEST_API
int STDCALL
4162 mono_test_Winx64_struct6_in (winx64_struct6 var
)
4173 LIBTEST_API
int STDCALL
4174 mono_test_Winx64_structs_in1 (winx64_struct1 var1
,
4175 winx64_struct2 var2
,
4176 winx64_struct3 var3
,
4177 winx64_struct4 var4
)
4191 if (var3
.c
!= 0x1234)
4198 if (var4
.c
!= 0x1234)
4200 if (var4
.d
!= 0x87654321)
4205 LIBTEST_API
int STDCALL
4206 mono_test_Winx64_structs_in2 (winx64_struct1 var1
,
4207 winx64_struct1 var2
,
4208 winx64_struct1 var3
,
4209 winx64_struct1 var4
,
4210 winx64_struct1 var5
)
4226 LIBTEST_API
int STDCALL
4227 mono_test_Winx64_structs_in3 (winx64_struct1 var1
,
4228 winx64_struct5 var2
,
4229 winx64_struct1 var3
,
4230 winx64_struct5 var4
,
4231 winx64_struct1 var5
,
4232 winx64_struct5 var6
)
4267 LIBTEST_API winx64_struct1 STDCALL
4268 mono_test_Winx64_struct1_ret (void)
4275 LIBTEST_API winx64_struct2 STDCALL
4276 mono_test_Winx64_struct2_ret (void)
4284 LIBTEST_API winx64_struct3 STDCALL
4285 mono_test_Winx64_struct3_ret (void)
4294 LIBTEST_API winx64_struct4 STDCALL
4295 mono_test_Winx64_struct4_ret (void)
4305 LIBTEST_API winx64_struct5 STDCALL
4306 mono_test_Winx64_struct5_ret (void)
4315 LIBTEST_API winx64_struct1 STDCALL
4316 mono_test_Winx64_struct1_ret_5_args (char a
, char b
, char c
, char d
, char e
)
4319 ret
.a
= a
+ b
+ c
+ d
+ e
;
4323 LIBTEST_API winx64_struct5 STDCALL
4324 mono_test_Winx64_struct5_ret6_args (char a
, char b
, char c
, char d
, char e
)
4337 } winx64_floatStruct
;
4339 LIBTEST_API
int STDCALL
4340 mono_test_Winx64_floatStruct (winx64_floatStruct a
)
4342 if (a
.a
> 5.6 || a
.a
< 5.4)
4345 if (a
.b
> 9.6 || a
.b
< 9.4)
4354 } winx64_doubleStruct
;
4356 LIBTEST_API
int STDCALL
4357 mono_test_Winx64_doubleStruct (winx64_doubleStruct a
)
4359 if (a
.a
> 5.6 || a
.a
< 5.4)
4365 typedef int (STDCALL
*managed_struct1_delegate
) (winx64_struct1 a
);
4367 LIBTEST_API
int STDCALL
4368 mono_test_managed_Winx64_struct1_in(managed_struct1_delegate func
)
4375 typedef int (STDCALL
*managed_struct5_delegate
) (winx64_struct5 a
);
4377 LIBTEST_API
int STDCALL
4378 mono_test_managed_Winx64_struct5_in(managed_struct5_delegate func
)
4387 typedef int (STDCALL
*managed_struct1_struct5_delegate
) (winx64_struct1 a
, winx64_struct5 b
,
4388 winx64_struct1 c
, winx64_struct5 d
,
4389 winx64_struct1 e
, winx64_struct5 f
);
4391 LIBTEST_API
int STDCALL
4392 mono_test_managed_Winx64_struct1_struct5_in(managed_struct1_struct5_delegate func
)
4394 winx64_struct1 a
, c
, e
;
4395 winx64_struct5 b
, d
, f
;
4397 b
.a
= 2; b
.b
= 3; b
.c
= 4;
4399 d
.a
= 6; d
.b
= 7; d
.c
= 8;
4401 f
.a
= 10; f
.b
= 11; f
.c
= 12;
4403 return func (a
, b
, c
, d
, e
, f
);
4406 typedef winx64_struct1 (STDCALL
*managed_struct1_ret_delegate
) (void);
4408 LIBTEST_API
int STDCALL
4409 mono_test_Winx64_struct1_ret_managed (managed_struct1_ret_delegate func
)
4421 typedef winx64_struct5 (STDCALL
*managed_struct5_ret_delegate
) (void);
4423 LIBTEST_API
int STDCALL
4424 mono_test_Winx64_struct5_ret_managed (managed_struct5_ret_delegate func
)
4440 LIBTEST_API
int STDCALL
4441 mono_test_marshal_bool_in (int arg
, unsigned int expected
, unsigned int bDefaultMarsh
, unsigned int bBoolCustMarsh
,
4442 char bI1CustMarsh
, unsigned char bU1CustMarsh
, short bVBCustMarsh
)
4446 if (bDefaultMarsh
!= expected
)
4450 if (bBoolCustMarsh
!= expected
)
4454 if (bI1CustMarsh
!= expected
)
4458 if (bU1CustMarsh
!= expected
)
4462 if (bVBCustMarsh
!= expected
)
4471 LIBTEST_API
int STDCALL
4472 mono_test_marshal_bool_out (int arg
, unsigned int testVal
, unsigned int* bDefaultMarsh
, unsigned int* bBoolCustMarsh
,
4473 char* bI1CustMarsh
, unsigned char* bU1CustMarsh
, unsigned short* bVBCustMarsh
)
4479 *bDefaultMarsh
= testVal
;
4482 if (!bBoolCustMarsh
)
4484 *bBoolCustMarsh
= testVal
;
4489 *bI1CustMarsh
= (char)testVal
;
4494 *bU1CustMarsh
= (unsigned char)testVal
;
4499 *bVBCustMarsh
= (unsigned short)testVal
;
4507 LIBTEST_API
int STDCALL
4508 mono_test_marshal_bool_ref (int arg
, unsigned int expected
, unsigned int testVal
, unsigned int* bDefaultMarsh
,
4509 unsigned int* bBoolCustMarsh
, char* bI1CustMarsh
, unsigned char* bU1CustMarsh
,
4510 unsigned short* bVBCustMarsh
)
4516 if (*bDefaultMarsh
!= expected
)
4518 *bDefaultMarsh
= testVal
;
4521 if (!bBoolCustMarsh
)
4523 if (*bBoolCustMarsh
!= expected
)
4525 *bBoolCustMarsh
= testVal
;
4530 if (*bI1CustMarsh
!= expected
)
4532 *bI1CustMarsh
= (char)testVal
;
4537 if (*bU1CustMarsh
!= expected
)
4539 *bU1CustMarsh
= (unsigned char)testVal
;
4544 if (*bVBCustMarsh
!= expected
)
4546 *bVBCustMarsh
= (unsigned short)testVal
;
4555 typedef int (STDCALL
*MarshalBoolInDelegate
) (int arg
, unsigned int expected
, unsigned int bDefaultMarsh
,
4556 unsigned int bBoolCustMarsh
, char bI1CustMarsh
, unsigned char bU1CustMarsh
, unsigned short bVBCustMarsh
);
4558 LIBTEST_API
int STDCALL
4559 mono_test_managed_marshal_bool_in (int arg
, unsigned int expected
, unsigned int testVal
, MarshalBoolInDelegate pfcn
)
4566 return pfcn (arg
, expected
, testVal
, 0, 0, 0, 0);
4568 return pfcn (arg
, expected
, 0, testVal
, 0, 0, 0);
4570 return pfcn (arg
, expected
, 0, 0, testVal
, 0, 0);
4572 return pfcn (arg
, expected
, 0, 0, 0, testVal
, 0);
4574 return pfcn (arg
, expected
, 0, 0, 0, 0, testVal
);
4582 typedef int (STDCALL
*MarshalBoolOutDelegate
) (int arg
, unsigned int expected
, unsigned int* bDefaultMarsh
,
4583 unsigned int* bBoolCustMarsh
, char* bI1CustMarsh
, unsigned char* bU1CustMarsh
, unsigned short* bVBCustMarsh
);
4585 LIBTEST_API
int STDCALL
4586 mono_test_managed_marshal_bool_out (int arg
, unsigned int expected
, unsigned int testVal
, MarshalBoolOutDelegate pfcn
)
4589 unsigned int lDefaultMarsh
, lBoolCustMarsh
;
4590 char lI1CustMarsh
= 0;
4591 unsigned char lU1CustMarsh
= 0;
4592 unsigned short lVBCustMarsh
= 0;
4593 lDefaultMarsh
= lBoolCustMarsh
= 0;
4600 unsigned int ltVal
= 0;
4601 ret
= pfcn (arg
, testVal
, <Val
, &lBoolCustMarsh
, &lI1CustMarsh
, &lU1CustMarsh
, &lVBCustMarsh
);
4603 return 0x0100 + ret
;
4604 if (expected
!= ltVal
)
4609 unsigned int ltVal
= 0;
4610 ret
= pfcn (arg
, testVal
, &lDefaultMarsh
, <Val
, &lI1CustMarsh
, &lU1CustMarsh
, &lVBCustMarsh
);
4612 return 0x0300 + ret
;
4613 if (expected
!= ltVal
)
4619 ret
= pfcn (arg
, testVal
, &lDefaultMarsh
, &lBoolCustMarsh
, <Val
, &lU1CustMarsh
, &lVBCustMarsh
);
4621 return 0x0500 + ret
;
4622 if (expected
!= ltVal
)
4627 unsigned char ltVal
= 0;
4628 ret
= pfcn (arg
, testVal
, &lDefaultMarsh
, &lBoolCustMarsh
, &lI1CustMarsh
, <Val
, &lVBCustMarsh
);
4630 return 0x0700 + ret
;
4631 if (expected
!= ltVal
)
4636 unsigned short ltVal
= 0;
4637 ret
= pfcn (arg
, testVal
, &lDefaultMarsh
, &lBoolCustMarsh
, &lI1CustMarsh
, &lU1CustMarsh
, <Val
);
4639 return 0x0900 + ret
;
4640 if (expected
!= ltVal
)
4651 typedef int (STDCALL
*MarshalBoolRefDelegate
) (int arg
, unsigned int expected
, unsigned int testVal
, unsigned int* bDefaultMarsh
,
4652 unsigned int* bBoolCustMarsh
, char* bI1CustMarsh
, unsigned char* bU1CustMarsh
, unsigned short* bVBCustMarsh
);
4654 LIBTEST_API
int STDCALL
4655 mono_test_managed_marshal_bool_ref (int arg
, unsigned int expected
, unsigned int testVal
, unsigned int outExpected
,
4656 unsigned int outTestVal
, MarshalBoolRefDelegate pfcn
)
4659 unsigned int lDefaultMarsh
, lBoolCustMarsh
;
4660 char lI1CustMarsh
= 0;
4661 unsigned char lU1CustMarsh
= 0;
4662 unsigned short lVBCustMarsh
= 0;
4663 lDefaultMarsh
= lBoolCustMarsh
= 0;
4671 unsigned int ltestVal
= testVal
;
4672 ret
= pfcn (arg
, expected
, outTestVal
, <estVal
, &lBoolCustMarsh
, &lI1CustMarsh
, &lU1CustMarsh
, &lVBCustMarsh
);
4674 return 0x0100 + ret
;
4675 if (outExpected
!= ltestVal
)
4681 unsigned int ltestVal
= testVal
;
4682 ret
= pfcn (arg
, expected
, outTestVal
, &lDefaultMarsh
, <estVal
, &lI1CustMarsh
, &lU1CustMarsh
, &lVBCustMarsh
);
4684 return 0x0300 + ret
;
4685 if (outExpected
!= ltestVal
)
4691 char ltestVal
= testVal
;
4692 ret
= pfcn (arg
, expected
, outTestVal
, &lDefaultMarsh
, &lBoolCustMarsh
, <estVal
, &lU1CustMarsh
, &lVBCustMarsh
);
4694 return 0x0500 + ret
;
4695 if (outExpected
!= ltestVal
)
4701 unsigned char ltestVal
= testVal
;
4702 ret
= pfcn (arg
, expected
, outTestVal
, &lDefaultMarsh
, &lBoolCustMarsh
, &lI1CustMarsh
, <estVal
, &lVBCustMarsh
);
4704 return 0x0700 + ret
;
4705 if (outExpected
!= ltestVal
)
4711 unsigned short ltestVal
= testVal
;
4712 ret
= pfcn (arg
, expected
, outTestVal
, &lDefaultMarsh
, &lBoolCustMarsh
, &lI1CustMarsh
, &lU1CustMarsh
, <estVal
);
4714 return 0x0900 + ret
;
4715 if (outExpected
!= ltestVal
)
4728 LIBTEST_API
int STDCALL
4729 mono_test_marshal_safearray_out_1dim_vt_bstr_empty (SAFEARRAY
** safearray
)
4731 /* Create an empty one-dimensional array of variants */
4733 SAFEARRAYBOUND dimensions
[1];
4735 dimensions
[0].lLbound
= 0;
4736 dimensions
[0].cElements
= 0;
4738 pSA
= SafeArrayCreate (VT_VARIANT
, 1, dimensions
);
4743 LIBTEST_API
int STDCALL
4744 mono_test_marshal_safearray_out_1dim_vt_bstr (SAFEARRAY
** safearray
)
4746 /* Create a one-dimensional array of 10 variants filled with "0" to "9" */
4748 SAFEARRAYBOUND dimensions
[1];
4754 dimensions
[0].lLbound
= 0;
4755 dimensions
[0].cElements
= 10;
4757 pSA
= SafeArrayCreate (VT_VARIANT
, 1, dimensions
);
4758 for (i
= dimensions
[0].lLbound
; i
< (dimensions
[0].cElements
+ dimensions
[0].lLbound
); i
++) {
4760 VariantInit (&vOut
);
4762 _ltoa (i
,buffer
,10);
4763 vOut
.bstrVal
= marshal_bstr_alloc (buffer
);
4765 if ((hr
= SafeArrayPutElement (pSA
, indices
, &vOut
)) != S_OK
) {
4766 VariantClear (&vOut
);
4767 SafeArrayDestroy (pSA
);
4770 VariantClear (&vOut
);
4776 LIBTEST_API
int STDCALL
4777 mono_test_marshal_safearray_out_2dim_vt_i4 (SAFEARRAY
** safearray
)
4779 /* Create a two-dimensional array of 4x3 variants filled with 11, 12, 13, etc. */
4781 SAFEARRAYBOUND dimensions
[2];
4786 dimensions
[0].lLbound
= 0;
4787 dimensions
[0].cElements
= 4;
4788 dimensions
[1].lLbound
= 0;
4789 dimensions
[1].cElements
= 3;
4791 pSA
= SafeArrayCreate(VT_VARIANT
, 2, dimensions
);
4792 for (i
= dimensions
[0].lLbound
; i
< (dimensions
[0].cElements
+ dimensions
[0].lLbound
); i
++) {
4793 for (j
= dimensions
[1].lLbound
; j
< (dimensions
[1].cElements
+ dimensions
[1].lLbound
); j
++) {
4795 VariantInit (&vOut
);
4797 vOut
.lVal
= (i
+1)*10+(j
+1);
4800 if ((hr
= SafeArrayPutElement (pSA
, indices
, &vOut
)) != S_OK
) {
4801 VariantClear (&vOut
);
4802 SafeArrayDestroy (pSA
);
4805 VariantClear (&vOut
); // does a deep destroy of source VARIANT
4812 LIBTEST_API
int STDCALL
4813 mono_test_marshal_safearray_out_4dim_vt_i4 (SAFEARRAY
** safearray
)
4815 /* Create a four-dimensional array of 10x3x6x7 variants filled with their indices */
4816 /* Also use non zero lower bounds */
4818 SAFEARRAYBOUND dimensions
[4];
4823 dimensions
[0].lLbound
= 15;
4824 dimensions
[0].cElements
= 10;
4825 dimensions
[1].lLbound
= 20;
4826 dimensions
[1].cElements
= 3;
4827 dimensions
[2].lLbound
= 5;
4828 dimensions
[2].cElements
= 6;
4829 dimensions
[3].lLbound
= 12;
4830 dimensions
[3].cElements
= 7;
4832 pSA
= SafeArrayCreate (VT_VARIANT
, 4, dimensions
);
4834 SafeArrayAccessData (pSA
, (void **)&pData
);
4836 for (i
= 0; i
< 10*3*6*7; i
++) {
4837 VariantInit(&pData
[i
]);
4838 pData
[i
].vt
= VT_I4
;
4841 SafeArrayUnaccessData (pSA
);
4846 LIBTEST_API
int STDCALL
4847 mono_test_marshal_safearray_in_byval_1dim_empty (SAFEARRAY
* safearray
)
4849 /* Check that array is one dimensional and empty */
4852 long lbound
, ubound
;
4854 dim
= SafeArrayGetDim (safearray
);
4858 SafeArrayGetLBound (safearray
, 1, &lbound
);
4859 SafeArrayGetUBound (safearray
, 1, &ubound
);
4861 if ((lbound
> 0) || (ubound
> 0))
4867 LIBTEST_API
int STDCALL
4868 mono_test_marshal_safearray_in_byval_1dim_vt_i4 (SAFEARRAY
* safearray
)
4870 /* Check that array is one dimensional containing integers from 1 to 10 */
4873 long lbound
, ubound
;
4878 dim
= SafeArrayGetDim (safearray
);
4882 SafeArrayGetLBound (safearray
, 1, &lbound
);
4883 SafeArrayGetUBound (safearray
, 1, &ubound
);
4885 if ((lbound
!= 0) || (ubound
!= 9))
4888 SafeArrayAccessData (safearray
, (void **)&pData
);
4889 for (i
= lbound
; i
<= ubound
; i
++) {
4890 if ((VariantChangeType (&pData
[i
], &pData
[i
], VARIANT_NOUSEROVERRIDE
, VT_I4
) != S_OK
) || (pData
[i
].lVal
!= i
+ 1))
4893 SafeArrayUnaccessData (safearray
);
4898 LIBTEST_API
int STDCALL
4899 mono_test_marshal_safearray_in_byval_1dim_vt_mixed (SAFEARRAY
* safearray
)
4901 /* Check that array is one dimensional containing integers mixed with strings from 0 to 12 */
4904 long lbound
, ubound
;
4911 VariantInit (&element
);
4913 dim
= SafeArrayGetDim (safearray
);
4917 SafeArrayGetLBound (safearray
, 1, &lbound
);
4918 SafeArrayGetUBound (safearray
, 1, &ubound
);
4920 if ((lbound
!= 0) || (ubound
!= 12))
4923 SafeArrayAccessData (safearray
, (void **)&pData
);
4924 for (i
= lbound
; i
<= ubound
; i
++) {
4925 if ((i
%2 == 0) && (pData
[i
].vt
!= VT_I4
))
4927 if ((i
%2 == 1) && (pData
[i
].vt
!= VT_BSTR
))
4929 if ((VariantChangeType (&pData
[i
], &pData
[i
], VARIANT_NOUSEROVERRIDE
, VT_I4
) != S_OK
) || (pData
[i
].lVal
!= i
))
4932 SafeArrayUnaccessData (safearray
);
4934 /* Change the first element of the array to verify that [in] parameters are not marshalled back to the managed side */
4939 SafeArrayPutElement (safearray
, indices
, &element
);
4940 VariantClear (&element
);
4945 LIBTEST_API
int STDCALL
4946 mono_test_marshal_safearray_in_byval_2dim_vt_i4 (SAFEARRAY
* safearray
)
4948 /* Check that array is one dimensional containing integers mixed with strings from 0 to 12 */
4951 long lbound1
, ubound1
, lbound2
, ubound2
;
4956 VariantInit (&element
);
4958 dim
= SafeArrayGetDim (safearray
);
4962 SafeArrayGetLBound (safearray
, 1, &lbound1
);
4963 SafeArrayGetUBound (safearray
, 1, &ubound1
);
4965 if ((lbound1
!= 0) || (ubound1
!= 1))
4968 SafeArrayGetLBound (safearray
, 2, &lbound2
);
4969 SafeArrayGetUBound (safearray
, 2, &ubound2
);
4971 if ((lbound2
!= 0) || (ubound2
!= 3)) {
4975 for (i
= lbound1
; i
<= ubound1
; i
++) {
4977 for (j
= lbound2
; j
<= ubound2
; j
++) {
4979 if (SafeArrayGetElement (safearray
, indices
, &element
) != S_OK
)
4981 failed
= ((element
.vt
!= VT_I4
) || (element
.lVal
!= 10*(i
+1)+(j
+1)));
4982 VariantClear (&element
);
4988 /* Change the first element of the array to verify that [in] parameters are not marshalled back to the managed side */
4994 SafeArrayPutElement (safearray
, indices
, &element
);
4995 VariantClear (&element
);
5000 LIBTEST_API
int STDCALL
5001 mono_test_marshal_safearray_in_byval_3dim_vt_bstr (SAFEARRAY
* safearray
)
5003 /* Check that array is one dimensional containing integers mixed with strings from 0 to 12 */
5006 long lbound1
, ubound1
, lbound2
, ubound2
, lbound3
, ubound3
;
5007 long i
, j
, k
, failed
;
5011 VariantInit (&element
);
5013 dim
= SafeArrayGetDim (safearray
);
5017 SafeArrayGetLBound (safearray
, 1, &lbound1
);
5018 SafeArrayGetUBound (safearray
, 1, &ubound1
);
5020 if ((lbound1
!= 0) || (ubound1
!= 1))
5023 SafeArrayGetLBound (safearray
, 2, &lbound2
);
5024 SafeArrayGetUBound (safearray
, 2, &ubound2
);
5026 if ((lbound2
!= 0) || (ubound2
!= 1))
5029 SafeArrayGetLBound (safearray
, 3, &lbound3
);
5030 SafeArrayGetUBound (safearray
, 3, &ubound3
);
5032 if ((lbound3
!= 0) || (ubound3
!= 2))
5035 for (i
= lbound1
; i
<= ubound1
; i
++) {
5037 for (j
= lbound2
; j
<= ubound2
; j
++) {
5039 for (k
= lbound3
; k
<= ubound3
; k
++) {
5041 if (SafeArrayGetElement (safearray
, indices
, &element
) != S_OK
)
5043 failed
= ((element
.vt
!= VT_BSTR
)
5044 || (VariantChangeType (&element
, &element
, VARIANT_NOUSEROVERRIDE
, VT_I4
) != S_OK
)
5045 || (element
.lVal
!= 100*(i
+1)+10*(j
+1)+(k
+1)));
5046 VariantClear (&element
);
5053 /* Change the first element of the array to verify that [in] parameters are not marshalled back to the managed side */
5058 element
.vt
= VT_BSTR
;
5059 element
.bstrVal
= SysAllocString(L
"Should not be copied");
5060 SafeArrayPutElement (safearray
, indices
, &element
);
5061 VariantClear (&element
);
5066 LIBTEST_API
int STDCALL
5067 mono_test_marshal_safearray_in_byref_3dim_vt_bstr (SAFEARRAY
** safearray
)
5069 return mono_test_marshal_safearray_in_byval_3dim_vt_bstr (*safearray
);
5072 LIBTEST_API
int STDCALL
5073 mono_test_marshal_safearray_in_out_byref_1dim_empty (SAFEARRAY
** safearray
)
5075 /* Check that the input array is what is expected and change it so the caller can check */
5076 /* correct marshalling back to managed code */
5079 long lbound
, ubound
;
5080 SAFEARRAYBOUND dimensions
[1];
5082 wchar_t buffer
[20];
5086 /* Check that in array is one dimensional and empty */
5088 dim
= SafeArrayGetDim (*safearray
);
5093 SafeArrayGetLBound (*safearray
, 1, &lbound
);
5094 SafeArrayGetUBound (*safearray
, 1, &ubound
);
5096 if ((lbound
> 0) || (ubound
> 0)) {
5100 /* Re-dimension the array and return a one-dimensional array of 8 variants filled with "0" to "7" */
5102 dimensions
[0].lLbound
= 0;
5103 dimensions
[0].cElements
= 8;
5105 hr
= SafeArrayRedim (*safearray
, dimensions
);
5109 for (i
= dimensions
[0].lLbound
; i
< (dimensions
[0].lLbound
+ dimensions
[0].cElements
); i
++) {
5111 VariantInit (&vOut
);
5113 _ltow (i
,buffer
,10);
5114 vOut
.bstrVal
= SysAllocString (buffer
);
5116 if ((hr
= SafeArrayPutElement (*safearray
, indices
, &vOut
)) != S_OK
) {
5117 VariantClear (&vOut
);
5118 SafeArrayDestroy (*safearray
);
5121 VariantClear (&vOut
);
5126 LIBTEST_API
int STDCALL
5127 mono_test_marshal_safearray_in_out_byref_3dim_vt_bstr (SAFEARRAY
** safearray
)
5129 /* Check that the input array is what is expected and change it so the caller can check */
5130 /* correct marshalling back to managed code */
5133 long lbound1
, ubound1
, lbound2
, ubound2
, lbound3
, ubound3
;
5134 SAFEARRAYBOUND dimensions
[1];
5135 long i
, j
, k
, failed
;
5136 wchar_t buffer
[20];
5141 VariantInit (&element
);
5143 /* Check that in array is three dimensional and contains the expected values */
5145 dim
= SafeArrayGetDim (*safearray
);
5149 SafeArrayGetLBound (*safearray
, 1, &lbound1
);
5150 SafeArrayGetUBound (*safearray
, 1, &ubound1
);
5152 if ((lbound1
!= 0) || (ubound1
!= 1))
5155 SafeArrayGetLBound (*safearray
, 2, &lbound2
);
5156 SafeArrayGetUBound (*safearray
, 2, &ubound2
);
5158 if ((lbound2
!= 0) || (ubound2
!= 1))
5161 SafeArrayGetLBound (*safearray
, 3, &lbound3
);
5162 SafeArrayGetUBound (*safearray
, 3, &ubound3
);
5164 if ((lbound3
!= 0) || (ubound3
!= 2))
5167 for (i
= lbound1
; i
<= ubound1
; i
++) {
5169 for (j
= lbound2
; j
<= ubound2
; j
++) {
5171 for (k
= lbound3
; k
<= ubound3
; k
++) {
5173 if (SafeArrayGetElement (*safearray
, indices
, &element
) != S_OK
)
5175 failed
= ((element
.vt
!= VT_BSTR
)
5176 || (VariantChangeType (&element
, &element
, VARIANT_NOUSEROVERRIDE
, VT_I4
) != S_OK
)
5177 || (element
.lVal
!= 100*(i
+1)+10*(j
+1)+(k
+1)));
5178 VariantClear (&element
);
5185 hr
= SafeArrayDestroy (*safearray
);
5189 /* Return a new one-dimensional array of 8 variants filled with "0" to "7" */
5191 dimensions
[0].lLbound
= 0;
5192 dimensions
[0].cElements
= 8;
5194 *safearray
= SafeArrayCreate (VT_VARIANT
, 1, dimensions
);
5196 for (i
= dimensions
[0].lLbound
; i
< (dimensions
[0].lLbound
+ dimensions
[0].cElements
); i
++) {
5198 VariantInit (&vOut
);
5200 _ltow (i
,buffer
,10);
5201 vOut
.bstrVal
= SysAllocString (buffer
);
5203 if ((hr
= SafeArrayPutElement (*safearray
, indices
, &vOut
)) != S_OK
) {
5204 VariantClear (&vOut
);
5205 SafeArrayDestroy (*safearray
);
5208 VariantClear (&vOut
);
5213 LIBTEST_API
int STDCALL
5214 mono_test_marshal_safearray_in_out_byref_1dim_vt_i4 (SAFEARRAY
** safearray
)
5216 /* Check that the input array is what is expected and change it so the caller can check */
5217 /* correct marshalling back to managed code */
5220 long lbound1
, ubound1
;
5226 VariantInit (&element
);
5228 /* Check that in array is one dimensional and contains the expected value */
5230 dim
= SafeArrayGetDim (*safearray
);
5234 SafeArrayGetLBound (*safearray
, 1, &lbound1
);
5235 SafeArrayGetUBound (*safearray
, 1, &ubound1
);
5238 if ((lbound1
!= 0) || (ubound1
!= 1))
5242 for (i
= lbound1
; i
<= ubound1
; i
++) {
5244 if (SafeArrayGetElement (*safearray
, indices
, &element
) != S_OK
)
5246 failed
= (element
.vt
!= VT_I4
) || (element
.lVal
!= i
+1);
5247 VariantClear (&element
);
5252 /* Change one of the elements of the array to verify that [out] parameter is marshalled back to the managed side */
5257 SafeArrayPutElement (*safearray
, indices
, &element
);
5258 VariantClear (&element
);
5263 LIBTEST_API
int STDCALL
5264 mono_test_marshal_safearray_in_out_byval_1dim_vt_i4 (SAFEARRAY
* safearray
)
5266 /* Check that the input array is what is expected and change it so the caller can check */
5267 /* correct marshalling back to managed code */
5270 long lbound1
, ubound1
;
5271 SAFEARRAYBOUND dimensions
[1];
5277 VariantInit (&element
);
5279 /* Check that in array is one dimensional and contains the expected value */
5281 dim
= SafeArrayGetDim (safearray
);
5285 SafeArrayGetLBound (safearray
, 1, &lbound1
);
5286 SafeArrayGetUBound (safearray
, 1, &ubound1
);
5288 if ((lbound1
!= 0) || (ubound1
!= 0))
5291 for (i
= lbound1
; i
<= ubound1
; i
++) {
5293 if (SafeArrayGetElement (safearray
, indices
, &element
) != S_OK
)
5295 failed
= (element
.vt
!= VT_I4
) || (element
.lVal
!= i
+1);
5296 VariantClear (&element
);
5301 /* Change the array to verify how [out] parameter is marshalled back to the managed side */
5303 /* Redimension the array */
5304 dimensions
[0].lLbound
= lbound1
;
5305 dimensions
[0].cElements
= 2;
5306 hr
= SafeArrayRedim(safearray
, dimensions
);
5310 element
.lVal
= 12345;
5311 SafeArrayPutElement (safearray
, indices
, &element
);
5312 VariantClear (&element
);
5316 element
.lVal
= -12345;
5317 SafeArrayPutElement (safearray
, indices
, &element
);
5318 VariantClear (&element
);
5323 LIBTEST_API
int STDCALL
5324 mono_test_marshal_safearray_in_out_byval_3dim_vt_bstr (SAFEARRAY
* safearray
)
5326 /* Check that the input array is what is expected and change it so the caller can check */
5327 /* correct marshalling back to managed code */
5330 long lbound1
, ubound1
, lbound2
, ubound2
, lbound3
, ubound3
;
5331 long i
, j
, k
, failed
;
5336 VariantInit (&element
);
5338 /* Check that in array is three dimensional and contains the expected values */
5340 dim
= SafeArrayGetDim (safearray
);
5344 SafeArrayGetLBound (safearray
, 1, &lbound1
);
5345 SafeArrayGetUBound (safearray
, 1, &ubound1
);
5347 if ((lbound1
!= 0) || (ubound1
!= 1))
5350 SafeArrayGetLBound (safearray
, 2, &lbound2
);
5351 SafeArrayGetUBound (safearray
, 2, &ubound2
);
5353 if ((lbound2
!= 0) || (ubound2
!= 1))
5356 SafeArrayGetLBound (safearray
, 3, &lbound3
);
5357 SafeArrayGetUBound (safearray
, 3, &ubound3
);
5359 if ((lbound3
!= 0) || (ubound3
!= 2))
5362 for (i
= lbound1
; i
<= ubound1
; i
++) {
5364 for (j
= lbound2
; j
<= ubound2
; j
++) {
5366 for (k
= lbound3
; k
<= ubound3
; k
++) {
5368 if (SafeArrayGetElement (safearray
, indices
, &element
) != S_OK
)
5370 failed
= ((element
.vt
!= VT_BSTR
)
5371 || (VariantChangeType (&element
, &element
, VARIANT_NOUSEROVERRIDE
, VT_I4
) != S_OK
)
5372 || (element
.lVal
!= 100*(i
+1)+10*(j
+1)+(k
+1)));
5373 VariantClear (&element
);
5380 /* Change the elements of the array to verify that [out] parameter is marshalled back to the managed side */
5387 SafeArrayPutElement (safearray
, indices
, &element
);
5388 VariantClear (&element
);
5395 SafeArrayPutElement (safearray
, indices
, &element
);
5396 VariantClear (&element
);
5401 element
.vt
= VT_BSTR
;
5402 element
.bstrVal
= marshal_bstr_alloc("ABCDEFG");
5403 SafeArrayPutElement (safearray
, indices
, &element
);
5404 VariantClear (&element
);
5409 LIBTEST_API
int STDCALL
5410 mono_test_marshal_safearray_mixed(
5411 SAFEARRAY
*safearray1
,
5412 SAFEARRAY
**safearray2
,
5413 SAFEARRAY
*safearray3
,
5414 SAFEARRAY
**safearray4
5419 /* Initialize out parameters */
5422 /* array1: Check that in array is one dimensional and contains the expected value */
5423 hr
= mono_test_marshal_safearray_in_out_byval_1dim_vt_i4 (safearray1
);
5425 /* array2: Fill in with some values to check on the managed side */
5427 hr
= mono_test_marshal_safearray_out_1dim_vt_bstr (safearray2
);
5429 /* array3: Check that in array is one dimensional and contains the expected value */
5431 hr
= mono_test_marshal_safearray_in_byval_1dim_vt_mixed(safearray3
);
5433 /* array4: Check input values and fill in with some values to check on the managed side */
5435 hr
= mono_test_marshal_safearray_in_out_byref_3dim_vt_bstr(safearray4
);
5442 static int call_managed_res
;
5445 call_managed (gpointer arg
)
5447 SimpleDelegate del
= (SimpleDelegate
)arg
;
5449 call_managed_res
= del (42);
5452 LIBTEST_API
int STDCALL
5453 mono_test_marshal_thread_attach (SimpleDelegate del
)
5461 res
= pthread_create (&t
, NULL
, (gpointer (*)(gpointer
))call_managed
, del
);
5462 g_assert (res
== 0);
5463 pthread_join (t
, NULL
);
5465 return call_managed_res
;
5469 typedef int (STDCALL
*Callback
) (void);
5471 static Callback callback
;
5473 LIBTEST_API
void STDCALL
5474 mono_test_marshal_set_callback (Callback cb
)
5479 LIBTEST_API
int STDCALL
5480 mono_test_marshal_call_callback (void)
5485 LIBTEST_API
int STDCALL
5486 mono_test_marshal_lpstr (char *str
)
5488 return strcmp ("ABC", str
);
5491 LIBTEST_API
int STDCALL
5492 mono_test_marshal_lpwstr (gunichar2
*str
)
5497 s
= g_utf16_to_utf8 (str
, -1, NULL
, NULL
, NULL
);
5498 res
= strcmp ("ABC", s
);
5504 LIBTEST_API
char* STDCALL
5505 mono_test_marshal_return_lpstr (void)
5507 char *res
= (char *)marshal_alloc (4);
5508 strcpy (res
, "XYZ");
5513 LIBTEST_API gunichar2
* STDCALL
5514 mono_test_marshal_return_lpwstr (void)
5516 gunichar2
*res
= (gunichar2
*)marshal_alloc (8);
5517 gunichar2
* tmp
= g_utf8_to_utf16 ("XYZ", -1, NULL
, NULL
, NULL
);
5519 memcpy (res
, tmp
, 8);
5527 } SingleDoubleStruct
;
5529 LIBTEST_API SingleDoubleStruct STDCALL
5530 mono_test_marshal_return_single_double_struct (void)
5532 SingleDoubleStruct res
;
5542 LIBTEST_API
int STDCALL
5543 mono_test_has_thiscall (void)
5549 _mono_test_native_thiscall1 (int arg
)
5555 _mono_test_native_thiscall2 (int arg
, int arg2
)
5557 return arg
+ (arg2
^1);
5561 _mono_test_native_thiscall3 (int arg
, int arg2
, int arg3
)
5563 return arg
+ (arg2
^1) + (arg3
^2);
5566 #elif defined(__GNUC__)
5568 LIBTEST_API
int STDCALL
5569 mono_test_has_thiscall (void)
5574 #define def_asm_fn(name) \
5576 "\t.globl _" #name "\n" \
5578 "\t.globl __" #name "\n" \
5583 def_asm_fn(mono_test_native_thiscall1
)
5584 "\tmovl %ecx,%eax\n"
5587 def_asm_fn(mono_test_native_thiscall2
)
5588 "\tmovl %ecx,%eax\n"
5589 "\tmovl 4(%esp),%ecx\n"
5591 "\taddl %ecx,%eax\n"
5594 def_asm_fn(mono_test_native_thiscall3
)
5595 "\tmovl %ecx,%eax\n"
5596 "\tmovl 4(%esp),%ecx\n"
5598 "\taddl %ecx,%eax\n"
5599 "\tmovl 8(%esp),%ecx\n"
5601 "\taddl %ecx,%eax\n"
5608 LIBTEST_API
int STDCALL
5609 mono_test_has_thiscall (void)
5621 LIBTEST_API sbyte1 STDCALL
5622 mono_return_sbyte1 (sbyte1 s1
, int addend
) {
5624 fprintf(stderr
, "mono_return_sbyte1 s1.f1: got %d but expected %d\n", s1
.f1
, 1);
5634 LIBTEST_API sbyte2 STDCALL
5635 mono_return_sbyte2 (sbyte2 s2
, int addend
) {
5637 fprintf(stderr
, "mono_return_sbyte2 s2.f1: got %d but expected %d\n", s2
.f1
, 1);
5640 fprintf(stderr
, "mono_return_sbyte2 s2.f2: got %d but expected %d\n", s2
.f2
, 2);
5642 s2
.f1
+=addend
; s2
.f2
+=addend
;
5650 LIBTEST_API sbyte3 STDCALL
5651 mono_return_sbyte3 (sbyte3 s3
, int addend
) {
5653 fprintf(stderr
, "mono_return_sbyte3 s3.f1: got %d but expected %d\n", s3
.f1
, 1);
5656 fprintf(stderr
, "mono_return_sbyte3 s3.f2: got %d but expected %d\n", s3
.f2
, 2);
5659 fprintf(stderr
, "mono_return_sbyte3 s3.f3: got %d but expected %d\n", s3
.f3
, 3);
5661 s3
.f1
+=addend
; s3
.f2
+=addend
; s3
.f3
+=addend
;
5669 LIBTEST_API sbyte4 STDCALL
5670 mono_return_sbyte4 (sbyte4 s4
, int addend
) {
5672 fprintf(stderr
, "mono_return_sbyte4 s4.f1: got %d but expected %d\n", s4
.f1
, 1);
5675 fprintf(stderr
, "mono_return_sbyte4 s4.f2: got %d but expected %d\n", s4
.f2
, 2);
5678 fprintf(stderr
, "mono_return_sbyte4 s4.f3: got %d but expected %d\n", s4
.f3
, 3);
5681 fprintf(stderr
, "mono_return_sbyte4 s4.f4: got %d but expected %d\n", s4
.f4
, 4);
5683 s4
.f1
+=addend
; s4
.f2
+=addend
; s4
.f3
+=addend
; s4
.f4
+=addend
;
5688 char f1
,f2
,f3
,f4
,f5
;
5691 LIBTEST_API sbyte5 STDCALL
5692 mono_return_sbyte5 (sbyte5 s5
, int addend
) {
5694 fprintf(stderr
, "mono_return_sbyte5 s5.f1: got %d but expected %d\n", s5
.f1
, 1);
5697 fprintf(stderr
, "mono_return_sbyte5 s5.f2: got %d but expected %d\n", s5
.f2
, 2);
5700 fprintf(stderr
, "mono_return_sbyte5 s5.f3: got %d but expected %d\n", s5
.f3
, 3);
5703 fprintf(stderr
, "mono_return_sbyte5 s5.f4: got %d but expected %d\n", s5
.f4
, 4);
5706 fprintf(stderr
, "mono_return_sbyte5 s5.f5: got %d but expected %d\n", s5
.f5
, 5);
5708 s5
.f1
+=addend
; s5
.f2
+=addend
; s5
.f3
+=addend
; s5
.f4
+=addend
; s5
.f5
+=addend
;
5713 char f1
,f2
,f3
,f4
,f5
,f6
;
5716 LIBTEST_API sbyte6 STDCALL
5717 mono_return_sbyte6 (sbyte6 s6
, int addend
) {
5719 fprintf(stderr
, "mono_return_sbyte6 s6.f1: got %d but expected %d\n", s6
.f1
, 1);
5722 fprintf(stderr
, "mono_return_sbyte6 s6.f2: got %d but expected %d\n", s6
.f2
, 2);
5725 fprintf(stderr
, "mono_return_sbyte6 s6.f3: got %d but expected %d\n", s6
.f3
, 3);
5728 fprintf(stderr
, "mono_return_sbyte6 s6.f4: got %d but expected %d\n", s6
.f4
, 4);
5731 fprintf(stderr
, "mono_return_sbyte6 s6.f5: got %d but expected %d\n", s6
.f5
, 5);
5734 fprintf(stderr
, "mono_return_sbyte6 s6.f6: got %d but expected %d\n", s6
.f6
, 6);
5736 s6
.f1
+=addend
; s6
.f2
+=addend
; s6
.f3
+=addend
; s6
.f4
+=addend
; s6
.f5
+=addend
; s6
.f6
+=addend
;
5741 char f1
,f2
,f3
,f4
,f5
,f6
,f7
;
5744 LIBTEST_API sbyte7 STDCALL
5745 mono_return_sbyte7 (sbyte7 s7
, int addend
) {
5747 fprintf(stderr
, "mono_return_sbyte7 s7.f1: got %d but expected %d\n", s7
.f1
, 1);
5750 fprintf(stderr
, "mono_return_sbyte7 s7.f2: got %d but expected %d\n", s7
.f2
, 2);
5753 fprintf(stderr
, "mono_return_sbyte7 s7.f3: got %d but expected %d\n", s7
.f3
, 3);
5756 fprintf(stderr
, "mono_return_sbyte7 s7.f4: got %d but expected %d\n", s7
.f4
, 4);
5759 fprintf(stderr
, "mono_return_sbyte7 s7.f5: got %d but expected %d\n", s7
.f5
, 5);
5762 fprintf(stderr
, "mono_return_sbyte7 s7.f6: got %d but expected %d\n", s7
.f6
, 6);
5765 fprintf(stderr
, "mono_return_sbyte7 s7.f7: got %d but expected %d\n", s7
.f7
, 7);
5767 s7
.f1
+=addend
; s7
.f2
+=addend
; s7
.f3
+=addend
; s7
.f4
+=addend
; s7
.f5
+=addend
; s7
.f6
+=addend
; s7
.f7
+=addend
;
5772 char f1
,f2
,f3
,f4
,f5
,f6
,f7
,f8
;
5775 LIBTEST_API sbyte8 STDCALL
5776 mono_return_sbyte8 (sbyte8 s8
, int addend
) {
5778 fprintf(stderr
, "mono_return_sbyte8 s8.f1: got %d but expected %d\n", s8
.f1
, 1);
5781 fprintf(stderr
, "mono_return_sbyte8 s8.f2: got %d but expected %d\n", s8
.f2
, 2);
5784 fprintf(stderr
, "mono_return_sbyte8 s8.f3: got %d but expected %d\n", s8
.f3
, 3);
5787 fprintf(stderr
, "mono_return_sbyte8 s8.f4: got %d but expected %d\n", s8
.f4
, 4);
5790 fprintf(stderr
, "mono_return_sbyte8 s8.f5: got %d but expected %d\n", s8
.f5
, 5);
5793 fprintf(stderr
, "mono_return_sbyte8 s8.f6: got %d but expected %d\n", s8
.f6
, 6);
5796 fprintf(stderr
, "mono_return_sbyte8 s8.f7: got %d but expected %d\n", s8
.f7
, 7);
5799 fprintf(stderr
, "mono_return_sbyte8 s8.f8: got %d but expected %d\n", s8
.f8
, 8);
5801 s8
.f1
+=addend
; s8
.f2
+=addend
; s8
.f3
+=addend
; s8
.f4
+=addend
; s8
.f5
+=addend
; s8
.f6
+=addend
; s8
.f7
+=addend
; s8
.f8
+=addend
;
5806 char f1
,f2
,f3
,f4
,f5
,f6
,f7
,f8
,f9
;
5809 LIBTEST_API sbyte9 STDCALL
5810 mono_return_sbyte9 (sbyte9 s9
, int addend
) {
5812 fprintf(stderr
, "mono_return_sbyte9 s9.f1: got %d but expected %d\n", s9
.f1
, 1);
5815 fprintf(stderr
, "mono_return_sbyte9 s9.f2: got %d but expected %d\n", s9
.f2
, 2);
5818 fprintf(stderr
, "mono_return_sbyte9 s9.f3: got %d but expected %d\n", s9
.f3
, 3);
5821 fprintf(stderr
, "mono_return_sbyte9 s9.f4: got %d but expected %d\n", s9
.f4
, 4);
5824 fprintf(stderr
, "mono_return_sbyte9 s9.f5: got %d but expected %d\n", s9
.f5
, 5);
5827 fprintf(stderr
, "mono_return_sbyte9 s9.f6: got %d but expected %d\n", s9
.f6
, 6);
5830 fprintf(stderr
, "mono_return_sbyte9 s9.f7: got %d but expected %d\n", s9
.f7
, 7);
5833 fprintf(stderr
, "mono_return_sbyte9 s9.f8: got %d but expected %d\n", s9
.f8
, 8);
5836 fprintf(stderr
, "mono_return_sbyte9 s9.f9: got %d but expected %d\n", s9
.f9
, 9);
5838 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
;
5843 char f1
,f2
,f3
,f4
,f5
,f6
,f7
,f8
,f9
,f10
;
5846 LIBTEST_API sbyte10 STDCALL
5847 mono_return_sbyte10 (sbyte10 s10
, int addend
) {
5849 fprintf(stderr
, "mono_return_sbyte10 s10.f1: got %d but expected %d\n", s10
.f1
, 1);
5852 fprintf(stderr
, "mono_return_sbyte10 s10.f2: got %d but expected %d\n", s10
.f2
, 2);
5855 fprintf(stderr
, "mono_return_sbyte10 s10.f3: got %d but expected %d\n", s10
.f3
, 3);
5858 fprintf(stderr
, "mono_return_sbyte10 s10.f4: got %d but expected %d\n", s10
.f4
, 4);
5861 fprintf(stderr
, "mono_return_sbyte10 s10.f5: got %d but expected %d\n", s10
.f5
, 5);
5864 fprintf(stderr
, "mono_return_sbyte10 s10.f6: got %d but expected %d\n", s10
.f6
, 6);
5867 fprintf(stderr
, "mono_return_sbyte10 s10.f7: got %d but expected %d\n", s10
.f7
, 7);
5870 fprintf(stderr
, "mono_return_sbyte10 s10.f8: got %d but expected %d\n", s10
.f8
, 8);
5873 fprintf(stderr
, "mono_return_sbyte10 s10.f9: got %d but expected %d\n", s10
.f9
, 9);
5875 if (s10
.f10
!= 10) {
5876 fprintf(stderr
, "mono_return_sbyte10 s10.f10: got %d but expected %d\n", s10
.f10
, 10);
5878 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
;
5883 char f1
,f2
,f3
,f4
,f5
,f6
,f7
,f8
,f9
,f10
,f11
;
5886 LIBTEST_API sbyte11 STDCALL
5887 mono_return_sbyte11 (sbyte11 s11
, int addend
) {
5889 fprintf(stderr
, "mono_return_sbyte11 s11.f1: got %d but expected %d\n", s11
.f1
, 1);
5892 fprintf(stderr
, "mono_return_sbyte11 s11.f2: got %d but expected %d\n", s11
.f2
, 2);
5895 fprintf(stderr
, "mono_return_sbyte11 s11.f3: got %d but expected %d\n", s11
.f3
, 3);
5898 fprintf(stderr
, "mono_return_sbyte11 s11.f4: got %d but expected %d\n", s11
.f4
, 4);
5901 fprintf(stderr
, "mono_return_sbyte11 s11.f5: got %d but expected %d\n", s11
.f5
, 5);
5904 fprintf(stderr
, "mono_return_sbyte11 s11.f6: got %d but expected %d\n", s11
.f6
, 6);
5907 fprintf(stderr
, "mono_return_sbyte11 s11.f7: got %d but expected %d\n", s11
.f7
, 7);
5910 fprintf(stderr
, "mono_return_sbyte11 s11.f8: got %d but expected %d\n", s11
.f8
, 8);
5913 fprintf(stderr
, "mono_return_sbyte11 s11.f9: got %d but expected %d\n", s11
.f9
, 9);
5915 if (s11
.f10
!= 10) {
5916 fprintf(stderr
, "mono_return_sbyte11 s11.f10: got %d but expected %d\n", s11
.f10
, 10);
5918 if (s11
.f11
!= 11) {
5919 fprintf(stderr
, "mono_return_sbyte11 s11.f11: got %d but expected %d\n", s11
.f11
, 11);
5921 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
;
5926 char f1
,f2
,f3
,f4
,f5
,f6
,f7
,f8
,f9
,f10
,f11
,f12
;
5929 LIBTEST_API sbyte12 STDCALL
5930 mono_return_sbyte12 (sbyte12 s12
, int addend
) {
5932 fprintf(stderr
, "mono_return_sbyte12 s12.f1: got %d but expected %d\n", s12
.f1
, 1);
5935 fprintf(stderr
, "mono_return_sbyte12 s12.f2: got %d but expected %d\n", s12
.f2
, 2);
5938 fprintf(stderr
, "mono_return_sbyte12 s12.f3: got %d but expected %d\n", s12
.f3
, 3);
5941 fprintf(stderr
, "mono_return_sbyte12 s12.f4: got %d but expected %d\n", s12
.f4
, 4);
5944 fprintf(stderr
, "mono_return_sbyte12 s12.f5: got %d but expected %d\n", s12
.f5
, 5);
5947 fprintf(stderr
, "mono_return_sbyte12 s12.f6: got %d but expected %d\n", s12
.f6
, 6);
5950 fprintf(stderr
, "mono_return_sbyte12 s12.f7: got %d but expected %d\n", s12
.f7
, 7);
5953 fprintf(stderr
, "mono_return_sbyte12 s12.f8: got %d but expected %d\n", s12
.f8
, 8);
5956 fprintf(stderr
, "mono_return_sbyte12 s12.f9: got %d but expected %d\n", s12
.f9
, 9);
5958 if (s12
.f10
!= 10) {
5959 fprintf(stderr
, "mono_return_sbyte12 s12.f10: got %d but expected %d\n", s12
.f10
, 10);
5961 if (s12
.f11
!= 11) {
5962 fprintf(stderr
, "mono_return_sbyte12 s12.f11: got %d but expected %d\n", s12
.f11
, 11);
5964 if (s12
.f12
!= 12) {
5965 fprintf(stderr
, "mono_return_sbyte12 s12.f12: got %d but expected %d\n", s12
.f12
, 12);
5967 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
;
5972 char f1
,f2
,f3
,f4
,f5
,f6
,f7
,f8
,f9
,f10
,f11
,f12
,f13
;
5975 LIBTEST_API sbyte13 STDCALL
5976 mono_return_sbyte13 (sbyte13 s13
, int addend
) {
5978 fprintf(stderr
, "mono_return_sbyte13 s13.f1: got %d but expected %d\n", s13
.f1
, 1);
5981 fprintf(stderr
, "mono_return_sbyte13 s13.f2: got %d but expected %d\n", s13
.f2
, 2);
5984 fprintf(stderr
, "mono_return_sbyte13 s13.f3: got %d but expected %d\n", s13
.f3
, 3);
5987 fprintf(stderr
, "mono_return_sbyte13 s13.f4: got %d but expected %d\n", s13
.f4
, 4);
5990 fprintf(stderr
, "mono_return_sbyte13 s13.f5: got %d but expected %d\n", s13
.f5
, 5);
5993 fprintf(stderr
, "mono_return_sbyte13 s13.f6: got %d but expected %d\n", s13
.f6
, 6);
5996 fprintf(stderr
, "mono_return_sbyte13 s13.f7: got %d but expected %d\n", s13
.f7
, 7);
5999 fprintf(stderr
, "mono_return_sbyte13 s13.f8: got %d but expected %d\n", s13
.f8
, 8);
6002 fprintf(stderr
, "mono_return_sbyte13 s13.f9: got %d but expected %d\n", s13
.f9
, 9);
6004 if (s13
.f10
!= 10) {
6005 fprintf(stderr
, "mono_return_sbyte13 s13.f10: got %d but expected %d\n", s13
.f10
, 10);
6007 if (s13
.f11
!= 11) {
6008 fprintf(stderr
, "mono_return_sbyte13 s13.f11: got %d but expected %d\n", s13
.f11
, 11);
6010 if (s13
.f12
!= 12) {
6011 fprintf(stderr
, "mono_return_sbyte13 s13.f12: got %d but expected %d\n", s13
.f12
, 12);
6013 if (s13
.f13
!= 13) {
6014 fprintf(stderr
, "mono_return_sbyte13 s13.f13: got %d but expected %d\n", s13
.f13
, 13);
6016 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
;
6021 char f1
,f2
,f3
,f4
,f5
,f6
,f7
,f8
,f9
,f10
,f11
,f12
,f13
,f14
;
6024 LIBTEST_API sbyte14 STDCALL
6025 mono_return_sbyte14 (sbyte14 s14
, int addend
) {
6027 fprintf(stderr
, "mono_return_sbyte14 s14.f1: got %d but expected %d\n", s14
.f1
, 1);
6030 fprintf(stderr
, "mono_return_sbyte14 s14.f2: got %d but expected %d\n", s14
.f2
, 2);
6033 fprintf(stderr
, "mono_return_sbyte14 s14.f3: got %d but expected %d\n", s14
.f3
, 3);
6036 fprintf(stderr
, "mono_return_sbyte14 s14.f4: got %d but expected %d\n", s14
.f4
, 4);
6039 fprintf(stderr
, "mono_return_sbyte14 s14.f5: got %d but expected %d\n", s14
.f5
, 5);
6042 fprintf(stderr
, "mono_return_sbyte14 s14.f6: got %d but expected %d\n", s14
.f6
, 6);
6045 fprintf(stderr
, "mono_return_sbyte14 s14.f7: got %d but expected %d\n", s14
.f7
, 7);
6048 fprintf(stderr
, "mono_return_sbyte14 s14.f8: got %d but expected %d\n", s14
.f8
, 8);
6051 fprintf(stderr
, "mono_return_sbyte14 s14.f9: got %d but expected %d\n", s14
.f9
, 9);
6053 if (s14
.f10
!= 10) {
6054 fprintf(stderr
, "mono_return_sbyte14 s14.f10: got %d but expected %d\n", s14
.f10
, 10);
6056 if (s14
.f11
!= 11) {
6057 fprintf(stderr
, "mono_return_sbyte14 s14.f11: got %d but expected %d\n", s14
.f11
, 11);
6059 if (s14
.f12
!= 12) {
6060 fprintf(stderr
, "mono_return_sbyte14 s14.f12: got %d but expected %d\n", s14
.f12
, 12);
6062 if (s14
.f13
!= 13) {
6063 fprintf(stderr
, "mono_return_sbyte14 s14.f13: got %d but expected %d\n", s14
.f13
, 13);
6065 if (s14
.f14
!= 14) {
6066 fprintf(stderr
, "mono_return_sbyte14 s14.f14: got %d but expected %d\n", s14
.f14
, 14);
6068 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
;
6073 char f1
,f2
,f3
,f4
,f5
,f6
,f7
,f8
,f9
,f10
,f11
,f12
,f13
,f14
,f15
;
6076 LIBTEST_API sbyte15 STDCALL
6077 mono_return_sbyte15 (sbyte15 s15
, int addend
) {
6079 fprintf(stderr
, "mono_return_sbyte15 s15.f1: got %d but expected %d\n", s15
.f1
, 1);
6082 fprintf(stderr
, "mono_return_sbyte15 s15.f2: got %d but expected %d\n", s15
.f2
, 2);
6085 fprintf(stderr
, "mono_return_sbyte15 s15.f3: got %d but expected %d\n", s15
.f3
, 3);
6088 fprintf(stderr
, "mono_return_sbyte15 s15.f4: got %d but expected %d\n", s15
.f4
, 4);
6091 fprintf(stderr
, "mono_return_sbyte15 s15.f5: got %d but expected %d\n", s15
.f5
, 5);
6094 fprintf(stderr
, "mono_return_sbyte15 s15.f6: got %d but expected %d\n", s15
.f6
, 6);
6097 fprintf(stderr
, "mono_return_sbyte15 s15.f7: got %d but expected %d\n", s15
.f7
, 7);
6100 fprintf(stderr
, "mono_return_sbyte15 s15.f8: got %d but expected %d\n", s15
.f8
, 8);
6103 fprintf(stderr
, "mono_return_sbyte15 s15.f9: got %d but expected %d\n", s15
.f9
, 9);
6105 if (s15
.f10
!= 10) {
6106 fprintf(stderr
, "mono_return_sbyte15 s15.f10: got %d but expected %d\n", s15
.f10
, 10);
6108 if (s15
.f11
!= 11) {
6109 fprintf(stderr
, "mono_return_sbyte15 s15.f11: got %d but expected %d\n", s15
.f11
, 11);
6111 if (s15
.f12
!= 12) {
6112 fprintf(stderr
, "mono_return_sbyte15 s15.f12: got %d but expected %d\n", s15
.f12
, 12);
6114 if (s15
.f13
!= 13) {
6115 fprintf(stderr
, "mono_return_sbyte15 s15.f13: got %d but expected %d\n", s15
.f13
, 13);
6117 if (s15
.f14
!= 14) {
6118 fprintf(stderr
, "mono_return_sbyte15 s15.f14: got %d but expected %d\n", s15
.f14
, 14);
6120 if (s15
.f15
!= 15) {
6121 fprintf(stderr
, "mono_return_sbyte15 s15.f15: got %d but expected %d\n", s15
.f15
, 15);
6123 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
;
6128 char f1
,f2
,f3
,f4
,f5
,f6
,f7
,f8
,f9
,f10
,f11
,f12
,f13
,f14
,f15
,f16
;
6131 LIBTEST_API sbyte16 STDCALL
6132 mono_return_sbyte16 (sbyte16 s16
, int addend
) {
6134 fprintf(stderr
, "mono_return_sbyte16 s16.f1: got %d but expected %d\n", s16
.f1
, 1);
6137 fprintf(stderr
, "mono_return_sbyte16 s16.f2: got %d but expected %d\n", s16
.f2
, 2);
6140 fprintf(stderr
, "mono_return_sbyte16 s16.f3: got %d but expected %d\n", s16
.f3
, 3);
6143 fprintf(stderr
, "mono_return_sbyte16 s16.f4: got %d but expected %d\n", s16
.f4
, 4);
6146 fprintf(stderr
, "mono_return_sbyte16 s16.f5: got %d but expected %d\n", s16
.f5
, 5);
6149 fprintf(stderr
, "mono_return_sbyte16 s16.f6: got %d but expected %d\n", s16
.f6
, 6);
6152 fprintf(stderr
, "mono_return_sbyte16 s16.f7: got %d but expected %d\n", s16
.f7
, 7);
6155 fprintf(stderr
, "mono_return_sbyte16 s16.f8: got %d but expected %d\n", s16
.f8
, 8);
6158 fprintf(stderr
, "mono_return_sbyte16 s16.f9: got %d but expected %d\n", s16
.f9
, 9);
6160 if (s16
.f10
!= 10) {
6161 fprintf(stderr
, "mono_return_sbyte16 s16.f10: got %d but expected %d\n", s16
.f10
, 10);
6163 if (s16
.f11
!= 11) {
6164 fprintf(stderr
, "mono_return_sbyte16 s16.f11: got %d but expected %d\n", s16
.f11
, 11);
6166 if (s16
.f12
!= 12) {
6167 fprintf(stderr
, "mono_return_sbyte16 s16.f12: got %d but expected %d\n", s16
.f12
, 12);
6169 if (s16
.f13
!= 13) {
6170 fprintf(stderr
, "mono_return_sbyte16 s16.f13: got %d but expected %d\n", s16
.f13
, 13);
6172 if (s16
.f14
!= 14) {
6173 fprintf(stderr
, "mono_return_sbyte16 s16.f14: got %d but expected %d\n", s16
.f14
, 14);
6175 if (s16
.f15
!= 15) {
6176 fprintf(stderr
, "mono_return_sbyte16 s16.f15: got %d but expected %d\n", s16
.f15
, 15);
6178 if (s16
.f16
!= 16) {
6179 fprintf(stderr
, "mono_return_sbyte16 s16.f16: got %d but expected %d\n", s16
.f16
, 16);
6181 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
;
6186 char f1
,f2
,f3
,f4
,f5
,f6
,f7
,f8
,f9
,f10
,f11
,f12
,f13
,f14
,f15
,f16
,f17
;
6189 LIBTEST_API sbyte17 STDCALL
6190 mono_return_sbyte17 (sbyte17 s17
, int addend
) {
6192 fprintf(stderr
, "mono_return_sbyte17 s17.f1: got %d but expected %d\n", s17
.f1
, 1);
6195 fprintf(stderr
, "mono_return_sbyte17 s17.f2: got %d but expected %d\n", s17
.f2
, 2);
6198 fprintf(stderr
, "mono_return_sbyte17 s17.f3: got %d but expected %d\n", s17
.f3
, 3);
6201 fprintf(stderr
, "mono_return_sbyte17 s17.f4: got %d but expected %d\n", s17
.f4
, 4);
6204 fprintf(stderr
, "mono_return_sbyte17 s17.f5: got %d but expected %d\n", s17
.f5
, 5);
6207 fprintf(stderr
, "mono_return_sbyte17 s17.f6: got %d but expected %d\n", s17
.f6
, 6);
6210 fprintf(stderr
, "mono_return_sbyte17 s17.f7: got %d but expected %d\n", s17
.f7
, 7);
6213 fprintf(stderr
, "mono_return_sbyte17 s17.f8: got %d but expected %d\n", s17
.f8
, 8);
6216 fprintf(stderr
, "mono_return_sbyte17 s17.f9: got %d but expected %d\n", s17
.f9
, 9);
6218 if (s17
.f10
!= 10) {
6219 fprintf(stderr
, "mono_return_sbyte17 s17.f10: got %d but expected %d\n", s17
.f10
, 10);
6221 if (s17
.f11
!= 11) {
6222 fprintf(stderr
, "mono_return_sbyte17 s17.f11: got %d but expected %d\n", s17
.f11
, 11);
6224 if (s17
.f12
!= 12) {
6225 fprintf(stderr
, "mono_return_sbyte17 s17.f12: got %d but expected %d\n", s17
.f12
, 12);
6227 if (s17
.f13
!= 13) {
6228 fprintf(stderr
, "mono_return_sbyte17 s17.f13: got %d but expected %d\n", s17
.f13
, 13);
6230 if (s17
.f14
!= 14) {
6231 fprintf(stderr
, "mono_return_sbyte17 s17.f14: got %d but expected %d\n", s17
.f14
, 14);
6233 if (s17
.f15
!= 15) {
6234 fprintf(stderr
, "mono_return_sbyte17 s17.f15: got %d but expected %d\n", s17
.f15
, 15);
6236 if (s17
.f16
!= 16) {
6237 fprintf(stderr
, "mono_return_sbyte17 s17.f16: got %d but expected %d\n", s17
.f16
, 16);
6239 if (s17
.f17
!= 17) {
6240 fprintf(stderr
, "mono_return_sbyte17 s17.f17: got %d but expected %d\n", s17
.f17
, 17);
6242 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
;
6250 char f2
,f3
,f4
,f5
,f6
,f7
,f8
,f9
,f10
,f11
,f12
,f13
,f14
,f15
;
6256 LIBTEST_API sbyte16_nested STDCALL
6257 mono_return_sbyte16_nested (sbyte16_nested sn16
, int addend
) {
6258 if (sn16
.nested1
.f1
!= 1) {
6259 fprintf(stderr
, "mono_return_sbyte16_nested sn16.nested1.f1: got %d but expected %d\n", sn16
.nested1
.f1
, 1);
6262 fprintf(stderr
, "mono_return_sbyte16_nested sn16.f2: got %d but expected %d\n", sn16
.f2
, 2);
6265 fprintf(stderr
, "mono_return_sbyte16_nested sn16.f3: got %d but expected %d\n", sn16
.f3
, 3);
6268 fprintf(stderr
, "mono_return_sbyte16_nested sn16.f4: got %d but expected %d\n", sn16
.f4
, 4);
6271 fprintf(stderr
, "mono_return_sbyte16_nested sn16.f5: got %d but expected %d\n", sn16
.f5
, 5);
6274 fprintf(stderr
, "mono_return_sbyte16_nested sn16.f6: got %d but expected %d\n", sn16
.f6
, 6);
6277 fprintf(stderr
, "mono_return_sbyte16_nested sn16.f7: got %d but expected %d\n", sn16
.f7
, 7);
6280 fprintf(stderr
, "mono_return_sbyte16_nested sn16.f8: got %d but expected %d\n", sn16
.f8
, 8);
6283 fprintf(stderr
, "mono_return_sbyte16_nested sn16.f9: got %d but expected %d\n", sn16
.f9
, 9);
6285 if (sn16
.f10
!= 10) {
6286 fprintf(stderr
, "mono_return_sbyte16_nested sn16.f10: got %d but expected %d\n", sn16
.f10
, 10);
6288 if (sn16
.f11
!= 11) {
6289 fprintf(stderr
, "mono_return_sbyte16_nested sn16.f11: got %d but expected %d\n", sn16
.f11
, 11);
6291 if (sn16
.f12
!= 12) {
6292 fprintf(stderr
, "mono_return_sbyte16_nested sn16.f12: got %d but expected %d\n", sn16
.f12
, 12);
6294 if (sn16
.f13
!= 13) {
6295 fprintf(stderr
, "mono_return_sbyte16_nested sn16.f13: got %d but expected %d\n", sn16
.f13
, 13);
6297 if (sn16
.f14
!= 14) {
6298 fprintf(stderr
, "mono_return_sbyte16_nested sn16.f14: got %d but expected %d\n", sn16
.f14
, 14);
6300 if (sn16
.f15
!= 15) {
6301 fprintf(stderr
, "mono_return_sbyte16_nested sn16.f15: got %d but expected %d\n", sn16
.f15
, 15);
6303 if (sn16
.nested2
.f16
!= 16) {
6304 fprintf(stderr
, "mono_return_sbyte16_nested sn16.nested2.f16: got %d but expected %d\n", sn16
.nested2
.f16
, 16);
6306 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
;
6315 LIBTEST_API short1 STDCALL
6316 mono_return_short1 (short1 s1
, int addend
) {
6318 fprintf(stderr
, "mono_return_short1 s1.f1: got %d but expected %d\n", s1
.f1
, 1);
6328 LIBTEST_API short2 STDCALL
6329 mono_return_short2 (short2 s2
, int addend
) {
6331 fprintf(stderr
, "mono_return_short2 s2.f1: got %d but expected %d\n", s2
.f1
, 1);
6334 fprintf(stderr
, "mono_return_short2 s2.f2: got %d but expected %d\n", s2
.f2
, 2);
6336 s2
.f1
+=addend
; s2
.f2
+=addend
;
6344 LIBTEST_API short3 STDCALL
6345 mono_return_short3 (short3 s3
, int addend
) {
6347 fprintf(stderr
, "mono_return_short3 s3.f1: got %d but expected %d\n", s3
.f1
, 1);
6350 fprintf(stderr
, "mono_return_short3 s3.f2: got %d but expected %d\n", s3
.f2
, 2);
6353 fprintf(stderr
, "mono_return_short3 s3.f3: got %d but expected %d\n", s3
.f3
, 3);
6355 s3
.f1
+=addend
; s3
.f2
+=addend
; s3
.f3
+=addend
;
6363 LIBTEST_API short4 STDCALL
6364 mono_return_short4 (short4 s4
, int addend
) {
6366 fprintf(stderr
, "mono_return_short4 s4.f1: got %d but expected %d\n", s4
.f1
, 1);
6369 fprintf(stderr
, "mono_return_short4 s4.f2: got %d but expected %d\n", s4
.f2
, 2);
6372 fprintf(stderr
, "mono_return_short4 s4.f3: got %d but expected %d\n", s4
.f3
, 3);
6375 fprintf(stderr
, "mono_return_short4 s4.f4: got %d but expected %d\n", s4
.f4
, 4);
6377 s4
.f1
+=addend
; s4
.f2
+=addend
; s4
.f3
+=addend
; s4
.f4
+=addend
;
6382 short f1
,f2
,f3
,f4
,f5
;
6385 LIBTEST_API short5 STDCALL
6386 mono_return_short5 (short5 s5
, int addend
) {
6388 fprintf(stderr
, "mono_return_short5 s5.f1: got %d but expected %d\n", s5
.f1
, 1);
6391 fprintf(stderr
, "mono_return_short5 s5.f2: got %d but expected %d\n", s5
.f2
, 2);
6394 fprintf(stderr
, "mono_return_short5 s5.f3: got %d but expected %d\n", s5
.f3
, 3);
6397 fprintf(stderr
, "mono_return_short5 s5.f4: got %d but expected %d\n", s5
.f4
, 4);
6400 fprintf(stderr
, "mono_return_short5 s5.f5: got %d but expected %d\n", s5
.f5
, 5);
6402 s5
.f1
+=addend
; s5
.f2
+=addend
; s5
.f3
+=addend
; s5
.f4
+=addend
; s5
.f5
+=addend
;
6407 short f1
,f2
,f3
,f4
,f5
,f6
;
6410 LIBTEST_API short6 STDCALL
6411 mono_return_short6 (short6 s6
, int addend
) {
6413 fprintf(stderr
, "mono_return_short6 s6.f1: got %d but expected %d\n", s6
.f1
, 1);
6416 fprintf(stderr
, "mono_return_short6 s6.f2: got %d but expected %d\n", s6
.f2
, 2);
6419 fprintf(stderr
, "mono_return_short6 s6.f3: got %d but expected %d\n", s6
.f3
, 3);
6422 fprintf(stderr
, "mono_return_short6 s6.f4: got %d but expected %d\n", s6
.f4
, 4);
6425 fprintf(stderr
, "mono_return_short6 s6.f5: got %d but expected %d\n", s6
.f5
, 5);
6428 fprintf(stderr
, "mono_return_short6 s6.f6: got %d but expected %d\n", s6
.f6
, 6);
6430 s6
.f1
+=addend
; s6
.f2
+=addend
; s6
.f3
+=addend
; s6
.f4
+=addend
; s6
.f5
+=addend
; s6
.f6
+=addend
;
6435 short f1
,f2
,f3
,f4
,f5
,f6
,f7
;
6438 LIBTEST_API short7 STDCALL
6439 mono_return_short7 (short7 s7
, int addend
) {
6441 fprintf(stderr
, "mono_return_short7 s7.f1: got %d but expected %d\n", s7
.f1
, 1);
6444 fprintf(stderr
, "mono_return_short7 s7.f2: got %d but expected %d\n", s7
.f2
, 2);
6447 fprintf(stderr
, "mono_return_short7 s7.f3: got %d but expected %d\n", s7
.f3
, 3);
6450 fprintf(stderr
, "mono_return_short7 s7.f4: got %d but expected %d\n", s7
.f4
, 4);
6453 fprintf(stderr
, "mono_return_short7 s7.f5: got %d but expected %d\n", s7
.f5
, 5);
6456 fprintf(stderr
, "mono_return_short7 s7.f6: got %d but expected %d\n", s7
.f6
, 6);
6459 fprintf(stderr
, "mono_return_short7 s7.f7: got %d but expected %d\n", s7
.f7
, 7);
6461 s7
.f1
+=addend
; s7
.f2
+=addend
; s7
.f3
+=addend
; s7
.f4
+=addend
; s7
.f5
+=addend
; s7
.f6
+=addend
; s7
.f7
+=addend
;
6466 short f1
,f2
,f3
,f4
,f5
,f6
,f7
,f8
;
6469 LIBTEST_API short8 STDCALL
6470 mono_return_short8 (short8 s8
, int addend
) {
6472 fprintf(stderr
, "mono_return_short8 s8.f1: got %d but expected %d\n", s8
.f1
, 1);
6475 fprintf(stderr
, "mono_return_short8 s8.f2: got %d but expected %d\n", s8
.f2
, 2);
6478 fprintf(stderr
, "mono_return_short8 s8.f3: got %d but expected %d\n", s8
.f3
, 3);
6481 fprintf(stderr
, "mono_return_short8 s8.f4: got %d but expected %d\n", s8
.f4
, 4);
6484 fprintf(stderr
, "mono_return_short8 s8.f5: got %d but expected %d\n", s8
.f5
, 5);
6487 fprintf(stderr
, "mono_return_short8 s8.f6: got %d but expected %d\n", s8
.f6
, 6);
6490 fprintf(stderr
, "mono_return_short8 s8.f7: got %d but expected %d\n", s8
.f7
, 7);
6493 fprintf(stderr
, "mono_return_short8 s8.f8: got %d but expected %d\n", s8
.f8
, 8);
6495 s8
.f1
+=addend
; s8
.f2
+=addend
; s8
.f3
+=addend
; s8
.f4
+=addend
; s8
.f5
+=addend
; s8
.f6
+=addend
; s8
.f7
+=addend
; s8
.f8
+=addend
;
6500 short f1
,f2
,f3
,f4
,f5
,f6
,f7
,f8
,f9
;
6503 LIBTEST_API short9 STDCALL
6504 mono_return_short9 (short9 s9
, int addend
) {
6506 fprintf(stderr
, "mono_return_short9 s9.f1: got %d but expected %d\n", s9
.f1
, 1);
6509 fprintf(stderr
, "mono_return_short9 s9.f2: got %d but expected %d\n", s9
.f2
, 2);
6512 fprintf(stderr
, "mono_return_short9 s9.f3: got %d but expected %d\n", s9
.f3
, 3);
6515 fprintf(stderr
, "mono_return_short9 s9.f4: got %d but expected %d\n", s9
.f4
, 4);
6518 fprintf(stderr
, "mono_return_short9 s9.f5: got %d but expected %d\n", s9
.f5
, 5);
6521 fprintf(stderr
, "mono_return_short9 s9.f6: got %d but expected %d\n", s9
.f6
, 6);
6524 fprintf(stderr
, "mono_return_short9 s9.f7: got %d but expected %d\n", s9
.f7
, 7);
6527 fprintf(stderr
, "mono_return_short9 s9.f8: got %d but expected %d\n", s9
.f8
, 8);
6530 fprintf(stderr
, "mono_return_short9 s9.f9: got %d but expected %d\n", s9
.f9
, 9);
6532 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
;
6540 short f2
,f3
,f4
,f5
,f6
,f7
;
6546 LIBTEST_API short8_nested STDCALL
6547 mono_return_short8_nested (short8_nested sn8
, int addend
) {
6548 if (sn8
.nested1
.f1
!= 1) {
6549 fprintf(stderr
, "mono_return_short8_nested sn8.nested1.f1: got %d but expected %d\n", sn8
.nested1
.f1
, 1);
6552 fprintf(stderr
, "mono_return_short8_nested sn8.f2: got %d but expected %d\n", sn8
.f2
, 2);
6555 fprintf(stderr
, "mono_return_short8_nested sn8.f3: got %d but expected %d\n", sn8
.f3
, 3);
6558 fprintf(stderr
, "mono_return_short8_nested sn8.f4: got %d but expected %d\n", sn8
.f4
, 4);
6561 fprintf(stderr
, "mono_return_short8_nested sn8.f5: got %d but expected %d\n", sn8
.f5
, 5);
6564 fprintf(stderr
, "mono_return_short8_nested sn8.f6: got %d but expected %d\n", sn8
.f6
, 6);
6567 fprintf(stderr
, "mono_return_short8_nested sn8.f7: got %d but expected %d\n", sn8
.f7
, 7);
6569 if (sn8
.nested2
.f8
!= 8) {
6570 fprintf(stderr
, "mono_return_short8_nested sn8.nested2.f8: got %d but expected %d\n", sn8
.nested2
.f8
, 8);
6572 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
;
6581 LIBTEST_API int1 STDCALL
6582 mono_return_int1 (int1 s1
, int addend
) {
6584 fprintf(stderr
, "mono_return_int1 s1.f1: got %d but expected %d\n", s1
.f1
, 1);
6594 LIBTEST_API int2 STDCALL
6595 mono_return_int2 (int2 s2
, int addend
) {
6597 fprintf(stderr
, "mono_return_int2 s2.f1: got %d but expected %d\n", s2
.f1
, 1);
6600 fprintf(stderr
, "mono_return_int2 s2.f2: got %d but expected %d\n", s2
.f2
, 2);
6602 s2
.f1
+=addend
; s2
.f2
+=addend
;
6610 LIBTEST_API int3 STDCALL
6611 mono_return_int3 (int3 s3
, int addend
) {
6613 fprintf(stderr
, "mono_return_int3 s3.f1: got %d but expected %d\n", s3
.f1
, 1);
6616 fprintf(stderr
, "mono_return_int3 s3.f2: got %d but expected %d\n", s3
.f2
, 2);
6619 fprintf(stderr
, "mono_return_int3 s3.f3: got %d but expected %d\n", s3
.f3
, 3);
6621 s3
.f1
+=addend
; s3
.f2
+=addend
; s3
.f3
+=addend
;
6629 LIBTEST_API int4 STDCALL
6630 mono_return_int4 (int4 s4
, int addend
) {
6632 fprintf(stderr
, "mono_return_int4 s4.f1: got %d but expected %d\n", s4
.f1
, 1);
6635 fprintf(stderr
, "mono_return_int4 s4.f2: got %d but expected %d\n", s4
.f2
, 2);
6638 fprintf(stderr
, "mono_return_int4 s4.f3: got %d but expected %d\n", s4
.f3
, 3);
6641 fprintf(stderr
, "mono_return_int4 s4.f4: got %d but expected %d\n", s4
.f4
, 4);
6643 s4
.f1
+=addend
; s4
.f2
+=addend
; s4
.f3
+=addend
; s4
.f4
+=addend
;
6651 LIBTEST_API int5 STDCALL
6652 mono_return_int5 (int5 s5
, int addend
) {
6654 fprintf(stderr
, "mono_return_int5 s5.f1: got %d but expected %d\n", s5
.f1
, 1);
6657 fprintf(stderr
, "mono_return_int5 s5.f2: got %d but expected %d\n", s5
.f2
, 2);
6660 fprintf(stderr
, "mono_return_int5 s5.f3: got %d but expected %d\n", s5
.f3
, 3);
6663 fprintf(stderr
, "mono_return_int5 s5.f4: got %d but expected %d\n", s5
.f4
, 4);
6666 fprintf(stderr
, "mono_return_int5 s5.f5: got %d but expected %d\n", s5
.f5
, 5);
6668 s5
.f1
+=addend
; s5
.f2
+=addend
; s5
.f3
+=addend
; s5
.f4
+=addend
; s5
.f5
+=addend
;
6682 LIBTEST_API int4_nested STDCALL
6683 mono_return_int4_nested (int4_nested sn4
, int addend
) {
6684 if (sn4
.nested1
.f1
!= 1) {
6685 fprintf(stderr
, "mono_return_int4_nested sn4.nested1.f1: got %d but expected %d\n", sn4
.nested1
.f1
, 1);
6688 fprintf(stderr
, "mono_return_int4_nested sn4.f2: got %d but expected %d\n", sn4
.f2
, 2);
6691 fprintf(stderr
, "mono_return_int4_nested sn4.f3: got %d but expected %d\n", sn4
.f3
, 3);
6693 if (sn4
.nested2
.f4
!= 4) {
6694 fprintf(stderr
, "mono_return_int4_nested sn4.nested2.f4: got %d but expected %d\n", sn4
.nested2
.f4
, 4);
6696 sn4
.nested1
.f1
+=addend
; sn4
.f2
+=addend
; sn4
.f3
+=addend
; sn4
.nested2
.f4
+=addend
;
6704 LIBTEST_API float1 STDCALL
6705 mono_return_float1 (float1 s1
, int addend
) {
6707 fprintf(stderr
, "mono_return_float1 s1.f1: got %f but expected %d\n", s1
.f1
, 1);
6717 LIBTEST_API float2 STDCALL
6718 mono_return_float2 (float2 s2
, int addend
) {
6720 fprintf(stderr
, "mono_return_float2 s2.f1: got %f but expected %d\n", s2
.f1
, 1);
6723 fprintf(stderr
, "mono_return_float2 s2.f2: got %f but expected %d\n", s2
.f2
, 2);
6725 s2
.f1
+=addend
; s2
.f2
+=addend
;
6733 LIBTEST_API float3 STDCALL
6734 mono_return_float3 (float3 s3
, int addend
) {
6736 fprintf(stderr
, "mono_return_float3 s3.f1: got %f but expected %d\n", s3
.f1
, 1);
6739 fprintf(stderr
, "mono_return_float3 s3.f2: got %f but expected %d\n", s3
.f2
, 2);
6742 fprintf(stderr
, "mono_return_float3 s3.f3: got %f but expected %d\n", s3
.f3
, 3);
6744 s3
.f1
+=addend
; s3
.f2
+=addend
; s3
.f3
+=addend
;
6752 LIBTEST_API float4 STDCALL
6753 mono_return_float4 (float4 s4
, int addend
) {
6755 fprintf(stderr
, "mono_return_float4 s4.f1: got %f but expected %d\n", s4
.f1
, 1);
6758 fprintf(stderr
, "mono_return_float4 s4.f2: got %f but expected %d\n", s4
.f2
, 2);
6761 fprintf(stderr
, "mono_return_float4 s4.f3: got %f but expected %d\n", s4
.f3
, 3);
6764 fprintf(stderr
, "mono_return_float4 s4.f4: got %f but expected %d\n", s4
.f4
, 4);
6766 s4
.f1
+=addend
; s4
.f2
+=addend
; s4
.f3
+=addend
; s4
.f4
+=addend
;
6771 float f1
,f2
,f3
,f4
,f5
;
6774 LIBTEST_API float5 STDCALL
6775 mono_return_float5 (float5 s5
, int addend
) {
6777 fprintf(stderr
, "mono_return_float5 s5.f1: got %f but expected %d\n", s5
.f1
, 1);
6780 fprintf(stderr
, "mono_return_float5 s5.f2: got %f but expected %d\n", s5
.f2
, 2);
6783 fprintf(stderr
, "mono_return_float5 s5.f3: got %f but expected %d\n", s5
.f3
, 3);
6786 fprintf(stderr
, "mono_return_float5 s5.f4: got %f but expected %d\n", s5
.f4
, 4);
6789 fprintf(stderr
, "mono_return_float5 s5.f5: got %f but expected %d\n", s5
.f5
, 5);
6791 s5
.f1
+=addend
; s5
.f2
+=addend
; s5
.f3
+=addend
; s5
.f4
+=addend
; s5
.f5
+=addend
;
6796 float f1
,f2
,f3
,f4
,f5
,f6
;
6799 LIBTEST_API float6 STDCALL
6800 mono_return_float6 (float6 s6
, int addend
) {
6802 fprintf(stderr
, "mono_return_float6 s6.f1: got %f but expected %d\n", s6
.f1
, 1);
6805 fprintf(stderr
, "mono_return_float6 s6.f2: got %f but expected %d\n", s6
.f2
, 2);
6808 fprintf(stderr
, "mono_return_float6 s6.f3: got %f but expected %d\n", s6
.f3
, 3);
6811 fprintf(stderr
, "mono_return_float6 s6.f4: got %f but expected %d\n", s6
.f4
, 4);
6814 fprintf(stderr
, "mono_return_float6 s6.f5: got %f but expected %d\n", s6
.f5
, 5);
6817 fprintf(stderr
, "mono_return_float6 s6.f6: got %f but expected %d\n", s6
.f6
, 6);
6819 s6
.f1
+=addend
; s6
.f2
+=addend
; s6
.f3
+=addend
; s6
.f4
+=addend
; s6
.f5
+=addend
; s6
.f6
+=addend
;
6824 float f1
,f2
,f3
,f4
,f5
,f6
,f7
;
6827 LIBTEST_API float7 STDCALL
6828 mono_return_float7 (float7 s7
, int addend
) {
6830 fprintf(stderr
, "mono_return_float7 s7.f1: got %f but expected %d\n", s7
.f1
, 1);
6833 fprintf(stderr
, "mono_return_float7 s7.f2: got %f but expected %d\n", s7
.f2
, 2);
6836 fprintf(stderr
, "mono_return_float7 s7.f3: got %f but expected %d\n", s7
.f3
, 3);
6839 fprintf(stderr
, "mono_return_float7 s7.f4: got %f but expected %d\n", s7
.f4
, 4);
6842 fprintf(stderr
, "mono_return_float7 s7.f5: got %f but expected %d\n", s7
.f5
, 5);
6845 fprintf(stderr
, "mono_return_float7 s7.f6: got %f but expected %d\n", s7
.f6
, 6);
6848 fprintf(stderr
, "mono_return_float7 s7.f7: got %f but expected %d\n", s7
.f7
, 7);
6850 s7
.f1
+=addend
; s7
.f2
+=addend
; s7
.f3
+=addend
; s7
.f4
+=addend
; s7
.f5
+=addend
; s7
.f6
+=addend
; s7
.f7
+=addend
;
6855 float f1
,f2
,f3
,f4
,f5
,f6
,f7
,f8
;
6858 LIBTEST_API float8 STDCALL
6859 mono_return_float8 (float8 s8
, int addend
) {
6861 fprintf(stderr
, "mono_return_float8 s8.f1: got %f but expected %d\n", s8
.f1
, 1);
6864 fprintf(stderr
, "mono_return_float8 s8.f2: got %f but expected %d\n", s8
.f2
, 2);
6867 fprintf(stderr
, "mono_return_float8 s8.f3: got %f but expected %d\n", s8
.f3
, 3);
6870 fprintf(stderr
, "mono_return_float8 s8.f4: got %f but expected %d\n", s8
.f4
, 4);
6873 fprintf(stderr
, "mono_return_float8 s8.f5: got %f but expected %d\n", s8
.f5
, 5);
6876 fprintf(stderr
, "mono_return_float8 s8.f6: got %f but expected %d\n", s8
.f6
, 6);
6879 fprintf(stderr
, "mono_return_float8 s8.f7: got %f but expected %d\n", s8
.f7
, 7);
6882 fprintf(stderr
, "mono_return_float8 s8.f8: got %f but expected %d\n", s8
.f8
, 8);
6884 s8
.f1
+=addend
; s8
.f2
+=addend
; s8
.f3
+=addend
; s8
.f4
+=addend
; s8
.f5
+=addend
; s8
.f6
+=addend
; s8
.f7
+=addend
; s8
.f8
+=addend
;
6889 float f1
,f2
,f3
,f4
,f5
,f6
,f7
,f8
,f9
;
6892 LIBTEST_API float9 STDCALL
6893 mono_return_float9 (float9 s9
, int addend
) {
6895 fprintf(stderr
, "mono_return_float9 s9.f1: got %f but expected %d\n", s9
.f1
, 1);
6898 fprintf(stderr
, "mono_return_float9 s9.f2: got %f but expected %d\n", s9
.f2
, 2);
6901 fprintf(stderr
, "mono_return_float9 s9.f3: got %f but expected %d\n", s9
.f3
, 3);
6904 fprintf(stderr
, "mono_return_float9 s9.f4: got %f but expected %d\n", s9
.f4
, 4);
6907 fprintf(stderr
, "mono_return_float9 s9.f5: got %f but expected %d\n", s9
.f5
, 5);
6910 fprintf(stderr
, "mono_return_float9 s9.f6: got %f but expected %d\n", s9
.f6
, 6);
6913 fprintf(stderr
, "mono_return_float9 s9.f7: got %f but expected %d\n", s9
.f7
, 7);
6916 fprintf(stderr
, "mono_return_float9 s9.f8: got %f but expected %d\n", s9
.f8
, 8);
6919 fprintf(stderr
, "mono_return_float9 s9.f9: got %f but expected %d\n", s9
.f9
, 9);
6921 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
;
6935 LIBTEST_API float4_nested STDCALL
6936 mono_return_float4_nested (float4_nested sn4
, int addend
) {
6937 if (sn4
.nested1
.f1
!= 1) {
6938 fprintf(stderr
, "mono_return_float4_nested sn4.nested1.f1: got %f but expected %d\n", sn4
.nested1
.f1
, 1);
6941 fprintf(stderr
, "mono_return_float4_nested sn4.f2: got %f but expected %d\n", sn4
.f2
, 2);
6944 fprintf(stderr
, "mono_return_float4_nested sn4.f3: got %f but expected %d\n", sn4
.f3
, 3);
6946 if (sn4
.nested2
.f4
!= 4) {
6947 fprintf(stderr
, "mono_return_float4_nested sn4.nested2.f4: got %f but expected %d\n", sn4
.nested2
.f4
, 4);
6949 sn4
.nested1
.f1
+=addend
; sn4
.f2
+=addend
; sn4
.f3
+=addend
; sn4
.nested2
.f4
+=addend
;
6957 LIBTEST_API double1 STDCALL
6958 mono_return_double1 (double1 s1
, int addend
) {
6960 fprintf(stderr
, "mono_return_double1 s1.f1: got %f but expected %d\n", s1
.f1
, 1);
6970 LIBTEST_API double2 STDCALL
6971 mono_return_double2 (double2 s2
, int addend
) {
6973 fprintf(stderr
, "mono_return_double2 s2.f1: got %f but expected %d\n", s2
.f1
, 1);
6976 fprintf(stderr
, "mono_return_double2 s2.f2: got %f but expected %d\n", s2
.f2
, 2);
6978 s2
.f1
+=addend
; s2
.f2
+=addend
;
6986 LIBTEST_API double3 STDCALL
6987 mono_return_double3 (double3 s3
, int addend
) {
6989 fprintf(stderr
, "mono_return_double3 s3.f1: got %f but expected %d\n", s3
.f1
, 1);
6992 fprintf(stderr
, "mono_return_double3 s3.f2: got %f but expected %d\n", s3
.f2
, 2);
6995 fprintf(stderr
, "mono_return_double3 s3.f3: got %f but expected %d\n", s3
.f3
, 3);
6997 s3
.f1
+=addend
; s3
.f2
+=addend
; s3
.f3
+=addend
;
7005 LIBTEST_API double4 STDCALL
7006 mono_return_double4 (double4 s4
, int addend
) {
7008 fprintf(stderr
, "mono_return_double4 s4.f1: got %f but expected %d\n", s4
.f1
, 1);
7011 fprintf(stderr
, "mono_return_double4 s4.f2: got %f but expected %d\n", s4
.f2
, 2);
7014 fprintf(stderr
, "mono_return_double4 s4.f3: got %f but expected %d\n", s4
.f3
, 3);
7017 fprintf(stderr
, "mono_return_double4 s4.f4: got %f but expected %d\n", s4
.f4
, 4);
7019 s4
.f1
+=addend
; s4
.f2
+=addend
; s4
.f3
+=addend
; s4
.f4
+=addend
;
7024 double f1
,f2
,f3
,f4
,f5
;
7027 LIBTEST_API double5 STDCALL
7028 mono_return_double5 (double5 s5
, int addend
) {
7030 fprintf(stderr
, "mono_return_double5 s5.f1: got %f but expected %d\n", s5
.f1
, 1);
7033 fprintf(stderr
, "mono_return_double5 s5.f2: got %f but expected %d\n", s5
.f2
, 2);
7036 fprintf(stderr
, "mono_return_double5 s5.f3: got %f but expected %d\n", s5
.f3
, 3);
7039 fprintf(stderr
, "mono_return_double5 s5.f4: got %f but expected %d\n", s5
.f4
, 4);
7042 fprintf(stderr
, "mono_return_double5 s5.f5: got %f but expected %d\n", s5
.f5
, 5);
7044 s5
.f1
+=addend
; s5
.f2
+=addend
; s5
.f3
+=addend
; s5
.f4
+=addend
; s5
.f5
+=addend
;
7049 double f1
,f2
,f3
,f4
,f5
,f6
;
7052 LIBTEST_API double6 STDCALL
7053 mono_return_double6 (double6 s6
, int addend
) {
7055 fprintf(stderr
, "mono_return_double6 s6.f1: got %f but expected %d\n", s6
.f1
, 1);
7058 fprintf(stderr
, "mono_return_double6 s6.f2: got %f but expected %d\n", s6
.f2
, 2);
7061 fprintf(stderr
, "mono_return_double6 s6.f3: got %f but expected %d\n", s6
.f3
, 3);
7064 fprintf(stderr
, "mono_return_double6 s6.f4: got %f but expected %d\n", s6
.f4
, 4);
7067 fprintf(stderr
, "mono_return_double6 s6.f5: got %f but expected %d\n", s6
.f5
, 5);
7070 fprintf(stderr
, "mono_return_double6 s6.f6: got %f but expected %d\n", s6
.f6
, 6);
7072 s6
.f1
+=addend
; s6
.f2
+=addend
; s6
.f3
+=addend
; s6
.f4
+=addend
; s6
.f5
+=addend
; s6
.f6
+=addend
;
7077 double f1
,f2
,f3
,f4
,f5
,f6
,f7
;
7080 LIBTEST_API double7 STDCALL
7081 mono_return_double7 (double7 s7
, int addend
) {
7083 fprintf(stderr
, "mono_return_double7 s7.f1: got %f but expected %d\n", s7
.f1
, 1);
7086 fprintf(stderr
, "mono_return_double7 s7.f2: got %f but expected %d\n", s7
.f2
, 2);
7089 fprintf(stderr
, "mono_return_double7 s7.f3: got %f but expected %d\n", s7
.f3
, 3);
7092 fprintf(stderr
, "mono_return_double7 s7.f4: got %f but expected %d\n", s7
.f4
, 4);
7095 fprintf(stderr
, "mono_return_double7 s7.f5: got %f but expected %d\n", s7
.f5
, 5);
7098 fprintf(stderr
, "mono_return_double7 s7.f6: got %f but expected %d\n", s7
.f6
, 6);
7101 fprintf(stderr
, "mono_return_double7 s7.f7: got %f but expected %d\n", s7
.f7
, 7);
7103 s7
.f1
+=addend
; s7
.f2
+=addend
; s7
.f3
+=addend
; s7
.f4
+=addend
; s7
.f5
+=addend
; s7
.f6
+=addend
; s7
.f7
+=addend
;
7108 double f1
,f2
,f3
,f4
,f5
,f6
,f7
,f8
;
7111 LIBTEST_API double8 STDCALL
7112 mono_return_double8 (double8 s8
, int addend
) {
7114 fprintf(stderr
, "mono_return_double8 s8.f1: got %f but expected %d\n", s8
.f1
, 1);
7117 fprintf(stderr
, "mono_return_double8 s8.f2: got %f but expected %d\n", s8
.f2
, 2);
7120 fprintf(stderr
, "mono_return_double8 s8.f3: got %f but expected %d\n", s8
.f3
, 3);
7123 fprintf(stderr
, "mono_return_double8 s8.f4: got %f but expected %d\n", s8
.f4
, 4);
7126 fprintf(stderr
, "mono_return_double8 s8.f5: got %f but expected %d\n", s8
.f5
, 5);
7129 fprintf(stderr
, "mono_return_double8 s8.f6: got %f but expected %d\n", s8
.f6
, 6);
7132 fprintf(stderr
, "mono_return_double8 s8.f7: got %f but expected %d\n", s8
.f7
, 7);
7135 fprintf(stderr
, "mono_return_double8 s8.f8: got %f but expected %d\n", s8
.f8
, 8);
7137 s8
.f1
+=addend
; s8
.f2
+=addend
; s8
.f3
+=addend
; s8
.f4
+=addend
; s8
.f5
+=addend
; s8
.f6
+=addend
; s8
.f7
+=addend
; s8
.f8
+=addend
;
7142 double f1
,f2
,f3
,f4
,f5
,f6
,f7
,f8
,f9
;
7145 LIBTEST_API double9 STDCALL
7146 mono_return_double9 (double9 s9
, int addend
) {
7148 fprintf(stderr
, "mono_return_double9 s9.f1: got %f but expected %d\n", s9
.f1
, 1);
7151 fprintf(stderr
, "mono_return_double9 s9.f2: got %f but expected %d\n", s9
.f2
, 2);
7154 fprintf(stderr
, "mono_return_double9 s9.f3: got %f but expected %d\n", s9
.f3
, 3);
7157 fprintf(stderr
, "mono_return_double9 s9.f4: got %f but expected %d\n", s9
.f4
, 4);
7160 fprintf(stderr
, "mono_return_double9 s9.f5: got %f but expected %d\n", s9
.f5
, 5);
7163 fprintf(stderr
, "mono_return_double9 s9.f6: got %f but expected %d\n", s9
.f6
, 6);
7166 fprintf(stderr
, "mono_return_double9 s9.f7: got %f but expected %d\n", s9
.f7
, 7);
7169 fprintf(stderr
, "mono_return_double9 s9.f8: got %f but expected %d\n", s9
.f8
, 8);
7172 fprintf(stderr
, "mono_return_double9 s9.f9: got %f but expected %d\n", s9
.f9
, 9);
7174 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
;
7187 LIBTEST_API double2_nested STDCALL
7188 mono_return_double2_nested (double2_nested sn2
, int addend
) {
7189 if (sn2
.nested1
.f1
!= 1) {
7190 fprintf(stderr
, "mono_return_double2_nested sn2.nested1.f1: got %f but expected %d\n", sn2
.nested1
.f1
, 1);
7192 if (sn2
.nested2
.f2
!= 2) {
7193 fprintf(stderr
, "mono_return_double2_nested sn2.nested2.f2: got %f but expected %d\n", sn2
.nested2
.f2
, 2);
7195 sn2
.nested1
.f1
+=addend
; sn2
.nested2
.f2
+=addend
;
7205 LIBTEST_API double_array4 STDCALL
7206 mono_return_double_array4 (double_array4 sa4
, int addend
) {
7207 if (sa4
.f1
[0] != 1) {
7208 fprintf(stderr
, "mono_return_double_array4 sa4.f1[0]: got %f but expected %d\n", sa4
.f1
[0], 1);
7210 if (sa4
.f1
[1] != 2) {
7211 fprintf(stderr
, "mono_return_double_array4 sa4.f1[1]: got %f but expected %d\n", sa4
.f1
[1], 2);
7213 if (sa4
.f1
[2] != 3) {
7214 fprintf(stderr
, "mono_return_double_array4 sa4.f1[2]: got %f but expected %d\n", sa4
.f1
[2], 3);
7216 if (sa4
.f1
[3] != 4) {
7217 fprintf(stderr
, "mono_return_double_array4 sa4.f1[3]: got %f but expected %d\n", sa4
.f1
[3], 4);
7219 sa4
.f1
[0]+=addend
; sa4
.f1
[1]+=addend
; sa4
.f1
[2]+=addend
; sa4
.f1
[3]+=addend
;
7227 LIBTEST_API
int STDCALL
7228 mono_test_marshal_fixed_array (FixedArrayStruct s
)
7230 return s
.array
[0] + s
.array
[1] + s
.array
[2];
7238 LIBTEST_API
int STDCALL
7239 mono_test_marshal_fixed_buffer_char (FixedBufferChar
*s
)
7241 if (!(s
->array
[0] == 'A' && s
->array
[1] == 'B' && s
->array
[2] == 'C' && s
->c
== 'D'))
7252 } FixedBufferUnicode
;
7254 LIBTEST_API
int STDCALL
7255 mono_test_marshal_fixed_buffer_unicode (FixedBufferUnicode
*s
)
7257 if (!(s
->array
[0] == 'A' && s
->array
[1] == 'B' && s
->array
[2] == 'C' && s
->c
== 'D'))
7265 const int NSTRINGS
= 6;
7267 const char *utf8Strings
[] = {
7269 "Sîne klâwen durh die wolken sint geslagen" ,
7270 "काचं शक्नोम्यत्तुम् । नोपहिनस्ति माम्",
7272 "ღმერთსი შემვედრე,შემვედრე, ნუთუ კვლა დამხსნას შემვედრე,სოფლისა შემვედრე, შემვედრე,შემვედრე,შემვედრე,შრომასა, ცეცხლს, წყალსა და მიწასა, ჰაერთა თანა მრომასა; მომცნეს ფრთენი და აღვფრინდე, მივჰხვდე მას ჩემსა ნდომასა, დღისით და ღამით ვჰხედვიდე მზისა ელვათა კრთომაასაშემვედრე,შემვედრე,",
7273 "Τη γλώσσα μου έδωσαν ελληνική",
7278 build_return_string(const char* pReturn
)
7281 if (pReturn
== 0 || *pReturn
== 0)
7284 size_t strLength
= strlen(pReturn
);
7285 ret
= (char *)(marshal_alloc (sizeof(char)* (strLength
+ 1)));
7286 memset(ret
, '\0', strLength
+ 1);
7287 strncpy(ret
, pReturn
, strLength
);
7292 StringParameterInOut(/*[In,Out]*/ char *s
, int index
)
7295 return build_return_string(s
);
7299 StringParameterRefOut(/*out*/ char **s
, int index
)
7301 char *pszTextutf8
= (char*)utf8Strings
[index
];
7302 size_t strLength
= strlen(pszTextutf8
);
7303 *s
= (char *)(marshal_alloc (sizeof(char)* (strLength
+ 1)));
7304 memcpy(*s
, pszTextutf8
, strLength
);
7305 (*s
)[strLength
] = '\0';
7309 StringParameterRef(/*ref*/ char **s
, int index
)
7311 char *pszTextutf8
= (char*)utf8Strings
[index
];
7312 size_t strLength
= strlen(pszTextutf8
);
7313 // do byte by byte validation of in string
7314 size_t szLen
= strlen(*s
);
7315 for (size_t i
= 0; i
< szLen
; i
++)
7317 if ((*s
)[i
] != pszTextutf8
[i
])
7319 printf("[in] managed string do not match native string\n");
7328 // overwrite the orginal
7329 *s
= (char *)(marshal_alloc (sizeof(char)* (strLength
+ 1)));
7330 memcpy(*s
, pszTextutf8
, strLength
);
7331 (*s
)[strLength
] = '\0';
7335 StringBuilderParameterInOut(/*[In,Out] StringBuilder*/ char *s
, int index
)
7338 if (s
== 0 || *s
== 0)
7341 char *pszTextutf8
= (char*)utf8Strings
[index
];
7343 // do byte by byte validation of in string
7344 size_t szLen
= strlen(s
);
7345 for (size_t i
= 0; i
< szLen
; i
++)
7347 if (s
[i
] != pszTextutf8
[i
])
7349 printf("[in] managed string do not match native string\n");
7354 // modify the string inplace
7355 size_t outLen
= strlen(pszTextutf8
);
7356 for (size_t i
= 0; i
< outLen
; i
++) {
7357 s
[i
] = pszTextutf8
[i
];
7362 //out string builder
7364 StringBuilderParameterOut(/*[Out] StringBuilder*/ char *s
, int index
)
7366 char *pszTextutf8
= (char*)utf8Strings
[index
];
7368 printf ("SBPO: Receiving %s\n", s
);
7369 // modify the string inplace
7370 size_t outLen
= strlen(pszTextutf8
);
7371 for (size_t i
= 0; i
< outLen
; i
++) {
7372 s
[i
] = pszTextutf8
[i
];
7378 StringParameterOut(/*[Out]*/ char *s
, int index
)
7381 return build_return_string(s
);
7385 typedef struct FieldWithUtf8
7393 TestStructWithUtf8Field(struct FieldWithUtf8 fieldStruct
)
7395 char *pszManagedutf8
= fieldStruct
.pFirst
;
7396 int stringIndex
= fieldStruct
.index
;
7397 char *pszNative
= 0;
7400 if (pszManagedutf8
== 0 || *pszManagedutf8
== 0)
7403 pszNative
= (char*)utf8Strings
[stringIndex
];
7405 outLen
= strlen(pszNative
);
7406 // do byte by byte comparision
7407 for (size_t i
= 0; i
< outLen
; i
++)
7409 if (pszNative
[i
] != pszManagedutf8
[i
])
7411 printf("Native and managed string do not match.\n");
7417 typedef void (* Callback2
)(char *text
, int index
);
7420 Utf8DelegateAsParameter(Callback2 managedCallback
)
7422 for (int i
= 0; i
< NSTRINGS
; ++i
)
7424 char *pszNative
= 0;
7425 pszNative
= (char*)utf8Strings
[i
];
7426 managedCallback(pszNative
, i
);
7432 StringBuilderParameterReturn(int index
)
7434 char *pszTextutf8
= (char*)utf8Strings
[index
];
7435 size_t strLength
= strlen(pszTextutf8
);
7436 char * ret
= (char *)(marshal_alloc (sizeof(char)* (strLength
+ 1)));
7437 memcpy(ret
, pszTextutf8
, strLength
);
7438 ret
[strLength
] = '\0';
7443 LIBTEST_API
int STDCALL
7444 mono_test_marshal_pointer_array (int *arr
[])
7448 for (i
= 0; i
< 10; ++i
) {