int slen = strlen (str);
gunichar2* temp;
/* allocate len + 1 utf16 characters plus 4 byte integer for length*/
- ret = g_malloc ((slen + 1) * sizeof(gunichar2) + sizeof(guint32));
+ ret = (gchar *)g_malloc ((slen + 1) * sizeof(gunichar2) + sizeof(guint32));
if (ret == NULL)
return NULL;
temp = g_utf8_to_utf16 (str, -1, NULL, NULL, NULL);
int i = 0;
unsigned short *res;
- res = marshal_alloc (2 * (length + 1));
+ res = (unsigned short *)marshal_alloc (2 * (length + 1));
// printf("test_lpwstr_marshal()\n");
const char abc[] = "ABC";
glong len = strlen(abc);
- *chars = marshal_alloc (2 * (len + 1));
+ *chars = (unsigned short *)marshal_alloc (2 * (len + 1));
while ( i < len ) {
(*chars) [i] = abc[i];
int i, len;
len = 4;
- arr = marshal_alloc (sizeof (gint32) * len);
+ arr = (gint32 *)marshal_alloc (sizeof (gint32) * len);
for (i = 0; i < len; ++i)
arr [i] = i;
*out_arr = arr;
return 0;
}
+LIBTEST_API int STDCALL
+mono_test_marshal_out_lparray_out_size_param (int *arr, int *out_len)
+{
+ int i, len;
+
+ len = 4;
+ for (i = 0; i < len; ++i)
+ arr [i] = i;
+ *out_len = len;
+
+ return 0;
+}
+
LIBTEST_API int STDCALL
mono_test_marshal_inout_nonblittable_array (gunichar2 *a1)
{
mono_test_marshal_out_struct (int a, simplestruct *ss, int b, OutVTypeDelegate func)
{
/* Check that the input pointer is ignored */
- ss->d = (gpointer)0x12345678;
+ ss->d = (const char *)0x12345678;
func (a, ss, b);
simplestruct *ptr;
/* Check that the input pointer is ignored */
- ptr = (gpointer)0x12345678;
+ ptr = (simplestruct *)0x12345678;
res = delegate (&ptr);
if (res != 0)
LIBTEST_API int STDCALL
mono_test_marshal_delegate9 (SimpleDelegate9 delegate, gpointer ftn)
{
- return delegate (ftn);
+ return delegate ((return_int_fnt)ftn);
}
static int STDCALL
return (d ()) (55);
}
+typedef int (STDCALL *VirtualDelegate) (int);
+
+LIBTEST_API int STDCALL
+mono_test_marshal_virtual_delegate (VirtualDelegate del)
+{
+ return del (42);
+}
+
+typedef char* (STDCALL *IcallDelegate) (const char *);
+LIBTEST_API int STDCALL
+mono_test_marshal_icall_delegate (IcallDelegate del)
+{
+ char *res = del ("ABC");
+ return strcmp (res, "ABC") == 0 ? 0 : 1;
+}
+
LIBTEST_API int STDCALL
mono_test_marshal_stringbuilder (char *s, int n)
{
const char m[] = "This is my message. Isn't it nice?";
char *str;
- str = marshal_alloc (strlen (m) + 1);
+ str = (char *)marshal_alloc (strlen (m) + 1);
memcpy (str, m, strlen (m) + 1);
*s = str;
s2 = g_utf8_to_utf16 (m, -1, NULL, &len, NULL);
len = (len * 2) + 2;
- *s = marshal_alloc (len);
+ *s = (gunichar2 *)marshal_alloc (len);
memcpy (*s, s2, len);
g_free (s2);
if (strcmp (*s, "ABC"))
return 1;
- str = marshal_alloc (strlen (m) + 1);
+ str = (char *)marshal_alloc (strlen (m) + 1);
memcpy (str, m, strlen (m) + 1);
*s = str;
return 0;
}
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wc++-compat"
typedef struct {
#ifndef __GNUC__
char a;
#endif
} EmptyStruct;
+#pragma GCC diagnostic pop
LIBTEST_API int STDCALL
mono_test_marshal_empty_string_array (char **array)
{
ByValStrStruct *ret;
- ret = malloc(sizeof(ByValStrStruct));
+ ret = (ByValStrStruct *)malloc (sizeof (ByValStrStruct));
memset(ret, 'a', sizeof(ByValStrStruct)-1);
ret->a[sizeof(ByValStrStruct)-1] = 0;
LIBTEST_API void STDCALL
class_marshal_test1 (SimpleObj **obj1)
{
- SimpleObj *res = malloc (sizeof (SimpleObj));
+ SimpleObj *res = (SimpleObj *)malloc (sizeof (SimpleObj));
res->str = marshal_strdup ("ABC");
res->i = 5;
GError *error = NULL;
char *s;
- s = g_utf16_to_utf8 (ptr, -1, NULL, NULL, &error);
+ s = g_utf16_to_utf8 ((const gunichar2 *)ptr, -1, NULL, NULL, &error);
if (!s)
return 1;
LIBTEST_API int STDCALL
mono_test_marshal_asany_in (void* ptr)
{
- AsAnyStruct* asAny = ptr;
+ AsAnyStruct *asAny = (AsAnyStruct *)ptr;
int res = asAny->i + asAny->j + asAny->k;
return res;
LIBTEST_API int STDCALL
mono_test_marshal_asany_inout (void* ptr)
{
- AsAnyStruct* asAny = ptr;
+ AsAnyStruct *asAny = (AsAnyStruct *)ptr;
int res = asAny->i + asAny->j + asAny->k;
marshal_free (asAny->s);
LIBTEST_API int STDCALL
mono_test_marshal_asany_out (void* ptr)
{
- AsAnyStruct* asAny = ptr;
+ AsAnyStruct *asAny = (AsAnyStruct *)ptr;
int res = asAny->i + asAny->j + asAny->k;
asAny->i = 10;
buf [0] = 0;
buf [1] = 10;
- ptr = del (&buf);
+ ptr = (guint32 *)del (&buf);
res = ptr [1];
int ret = 0;
gpointer (*mono_method_get_unmanaged_thunk)(gpointer)
- = lookup_mono_symbol ("mono_method_get_unmanaged_thunk");
+ = (gpointer (*)(gpointer))lookup_mono_symbol ("mono_method_get_unmanaged_thunk");
gpointer (*mono_string_new_wrapper)(const char *)
- = lookup_mono_symbol ("mono_string_new_wrapper");
+ = (gpointer (*)(const char *))lookup_mono_symbol ("mono_string_new_wrapper");
- char* (*mono_string_to_utf8)(gpointer)
- = lookup_mono_symbol ("mono_string_to_utf8");
+ char *(*mono_string_to_utf8)(gpointer)
+ = (char *(*)(gpointer))lookup_mono_symbol ("mono_string_to_utf8");
gpointer (*mono_object_unbox)(gpointer)
- = lookup_mono_symbol ("mono_object_unbox");
+ = (gpointer (*)(gpointer))lookup_mono_symbol ("mono_object_unbox");
gpointer (*mono_threads_enter_gc_unsafe_region) (gpointer)
- = lookup_mono_symbol ("mono_threads_enter_gc_unsafe_region");
+ = (gpointer (*)(gpointer))lookup_mono_symbol ("mono_threads_enter_gc_unsafe_region");
void (*mono_threads_exit_gc_unsafe_region) (gpointer, gpointer)
- = lookup_mono_symbol ("mono_threads_exit_gc_unsafe_region");
+ = (void (*)(gpointer, gpointer))lookup_mono_symbol ("mono_threads_exit_gc_unsafe_region");
goto done;
}
- CreateObject = mono_method_get_unmanaged_thunk (create_object_method_handle);
+ CreateObject = (gpointer (STDCALL *)(gpointer *))mono_method_get_unmanaged_thunk (create_object_method_handle);
if (!CreateObject) {
ret = 3;
goto done;
case 0: {
/* thunks.cs:Test.Test0 */
- void (STDCALL *F)(gpointer*) = test_method;
+ void (STDCALL *F)(gpointer *) = (void (STDCALL *)(gpointer *))test_method;
F (&ex);
break;
}
case 1: {
/* thunks.cs:Test.Test1 */
- int (STDCALL *F)(gpointer*) = test_method;
+ int (STDCALL *F)(gpointer *) = (int (STDCALL *)(gpointer *))test_method;
if (F (&ex) != 42) {
ret = 4;
goto done;
case 2: {
/* thunks.cs:Test.Test2 */
- gpointer (STDCALL *F)(gpointer, gpointer*) = test_method;
+ gpointer (STDCALL *F)(gpointer, gpointer*) = (gpointer (STDCALL *)(gpointer, gpointer *))test_method;
gpointer str = mono_string_new_wrapper ("foo");
if (str != F (str, &ex)) {
ret = 4;
gpointer obj;
gpointer str;
- F = test_method;
+ F = (gpointer (STDCALL *)(gpointer, gpointer, gpointer *))test_method;
obj = CreateObject (&ex);
str = mono_string_new_wrapper ("bar");
gpointer obj;
gpointer str;
- F = test_method;
+ F = (int (STDCALL *)(gpointer, gpointer, int, gpointer *))test_method;
obj = CreateObject (&ex);
str = mono_string_new_wrapper ("bar");
gpointer obj;
gpointer str;
- F = test_method;
+ F = (int (STDCALL *)(gpointer, gpointer, int, gpointer *))test_method;
obj = CreateObject (&ex);
str = mono_string_new_wrapper ("bar");
gpointer str = mono_string_new_wrapper ("Test6");
int res;
- F = test_method;
+ F = (int (STDCALL *)(gpointer, guint8, gint16, gint32, gint64, float, double, gpointer, gpointer *))test_method;
obj = CreateObject (&ex);
res = F (obj, 254, 32700, -245378, 6789600, 3.1415, 3.1415, str, &ex);
case 7: {
/* thunks.cs:Test.Test7 */
- gint64 (STDCALL *F)(gpointer*) = test_method;
+ gint64 (STDCALL *F)(gpointer*) = (gint64 (STDCALL *)(gpointer *))test_method;
if (F (&ex) != G_MAXINT64) {
ret = 4;
goto done;
double a6;
gpointer a7;
- F = test_method;
+ F = (void (STDCALL *)(guint8 *, gint16 *, gint32 *, gint64 *, float *, double *,
+ gpointer *, gpointer *))test_method;
F (&a1, &a2, &a3, &a4, &a5, &a6, &a7, &ex);
if (ex) {
case 9: {
/* thunks.cs:Test.Test9 */
void (STDCALL *F)(guint8*, gint16*, gint32*, gint64*, float*, double*,
- gpointer*, gpointer*);
+ gpointer*, gpointer*);
guint8 a1;
gint16 a2;
double a6;
gpointer a7;
- F = test_method;
+ F = (void (STDCALL *)(guint8 *, gint16 *, gint32 *, gint64 *, float *, double *,
+ gpointer *, gpointer *))test_method;
F (&a1, &a2, &a3, &a4, &a5, &a6, &a7, &ex);
if (!ex) {
goto done;
}
- F = test_method;
+ F = (void (STDCALL *)(gpointer *, gpointer *))test_method;
F (&obj1, &ex);
if (ex) {
goto done;
}
- a1 = mono_object_unbox (obj);
+ a1 = (TestStruct *)mono_object_unbox (obj);
if (!a1) {
ret = 6;
goto done;
a1->A = 42;
a1->B = 3.1415;
- F = test_method;
+ F = (int (STDCALL *)(gpointer *, gpointer *))test_method;
- res = F (obj, &ex);
+ res = F ((gpointer *)obj, &ex);
if (ex) {
ret = 7;
goto done;
goto done;
}
- a1 = mono_object_unbox (obj);
+ a1 = (TestStruct *)mono_object_unbox (obj);
if (!a1) {
ret = 6;
goto done;
}
- F = test_method;
+ F = (void (STDCALL *)(gpointer, gpointer *))test_method;
F (obj, &ex);
if (ex) {
TestStruct *a1;
gpointer obj;
- F = test_method;
+ F = (gpointer (STDCALL *)(gpointer *))test_method;
obj = F (&ex);
if (ex) {
goto done;
}
- a1 = mono_object_unbox (obj);
+ a1 = (TestStruct *)mono_object_unbox (obj);
if (a1->A != 42) {
ret = 5;
goto done;
}
- a1 = mono_object_unbox (obj);
+ a1 = (TestStruct *)mono_object_unbox (obj);
if (!a1) {
ret = 6;
a1->A = 42;
a1->B = 3.1415;
- F = test_method;
+ F = (void (STDCALL *)(gpointer, gpointer *))test_method;
F (obj, &ex);
if (ex) {
static void
call_managed (gpointer arg)
{
- SimpleDelegate del = arg;
+ SimpleDelegate del = (SimpleDelegate)arg;
call_managed_res = del (42);
}
int res;
pthread_t t;
- res = pthread_create (&t, NULL, (gpointer)call_managed, del);
+ res = pthread_create (&t, NULL, (gpointer (*)(gpointer))call_managed, del);
g_assert (res == 0);
pthread_join (t, NULL);
LIBTEST_API char* STDCALL
mono_test_marshal_return_lpstr (void)
{
- char *res = marshal_alloc (4);
+ char *res = (char *)marshal_alloc (4);
strcpy (res, "XYZ");
return res;
}
LIBTEST_API gunichar2* STDCALL
mono_test_marshal_return_lpwstr (void)
{
- gunichar2 *res = marshal_alloc (8);
+ gunichar2 *res = (gunichar2 *)marshal_alloc (8);
gunichar2* tmp = g_utf8_to_utf16 ("XYZ", -1, NULL, NULL, NULL);
memcpy (res, tmp, 8);