Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions runtime/runtime.m
Original file line number Diff line number Diff line change
Expand Up @@ -1840,7 +1840,7 @@ -(void) xamarinSetGCHandle: (int) gc_handle;
}

void
xamarin_free_gchandle (id self, int gchandle)
xamarin_free_gchandle (id self, uint32_t gchandle)
{
// COOP: no managed memory access, but calls mono function mono_gc_handle_free. Assuming that function can be called with any mode: this function can be called with any mode as well
if (gchandle) {
Expand Down Expand Up @@ -2901,4 +2901,4 @@ -(int) getHandle
}
@end

#pragma clang diagnostic pop
#pragma clang diagnostic pop

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^ check your editor settings, it seems you change the last line endings very frequently

31 changes: 13 additions & 18 deletions runtime/trampolines.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@
#include "runtime-internal.h"
//#define DEBUG_REF_COUNTING

// TODO: temp ignore to minimize diff
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wsign-conversion"
static pthread_mutex_t refcount_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER;

size_t
Expand Down Expand Up @@ -484,7 +481,7 @@
min_start--;
if (min_start < desc + rvlength) {
for (int i = 0; i < desc + rvlength - min_start; i++)
min_length = min_length * 10 + (min_start [i] - '0');
min_length = min_length * 10ul + (unsigned long)(min_start [i] - '0');
}
}

Expand Down Expand Up @@ -648,7 +645,7 @@
}

void
xamarin_notify_dealloc (id self, int gchandle)
xamarin_notify_dealloc (id self, uint32_t gchandle)
{
guint32 exception_gchandle = 0;

Expand Down Expand Up @@ -751,15 +748,15 @@
pthread_mutex_unlock (&gchandle_hash_lock);
}

int
uint32_t
xamarin_get_gchandle_trampoline (id self, SEL sel)
{
// COOP: Called by ObjC (when the getGCHandle selector is called on an object).
// COOP: Safe mode upon entry, and doesn't access managed memory, so no need to switch.
MONO_ASSERT_GC_SAFE;

/* This is for types registered using the dynamic registrar */
int gc_handle = 0;
uint32_t gc_handle = 0;
pthread_mutex_lock (&gchandle_hash_lock);
if (gchandle_hash != NULL)
gc_handle = GPOINTER_TO_UINT (CFDictionaryGetValue (gchandle_hash, self));
Expand Down Expand Up @@ -1398,7 +1395,7 @@
guint32 context_ref = GPOINTER_TO_UINT (context);
if (context_ref == INVALID_TOKEN_REF) {
// This requires the dynamic registrar to invoke the correct conversion function
int handle = mono_gchandle_new (value, FALSE);
uint32_t handle = mono_gchandle_new (value, FALSE);
NSString *rv = xamarin_convert_smart_enum_to_nsstring (GINT_TO_POINTER (handle), exception_gchandle);
mono_gchandle_free (handle);
return rv;
Expand Down Expand Up @@ -1433,7 +1430,7 @@
xamarin_nsstring_to_smart_enum (id value, void *ptr, MonoClass *managedType, void *context, guint32 *exception_gchandle)
{
guint32 context_ref = GPOINTER_TO_UINT (context);
int gc_handle = 0;
uint32_t gc_handle = 0;
MonoObject *obj;

if (context_ref == INVALID_TOKEN_REF) {
Expand Down Expand Up @@ -1464,7 +1461,7 @@
}
}

int size = mono_class_value_size (managedType, NULL);
size_t size = (size_t) mono_class_value_size (managedType, NULL);
if (!ptr)
ptr = xamarin_calloc (size);
void *value_ptr = mono_object_unbox (obj);
Expand All @@ -1491,7 +1488,7 @@
{
id *buf = NULL;
NSArray *rv = NULL;
int element_size = 0;
size_t element_size = 0;
char *ptr = NULL;

if (array == NULL)
Expand All @@ -1505,8 +1502,8 @@
MonoClass *element_class = mono_class_get_element_class (mono_object_get_class ((MonoObject *) array));
bool is_value_type = mono_class_is_valuetype (element_class);
if (is_value_type) {
element_size = mono_class_value_size (element_class, NULL);
ptr = (char *) mono_array_addr_with_size (array, element_size, 0);
element_size = (size_t) mono_class_value_size (element_class, NULL);
ptr = (char *) mono_array_addr_with_size (array, (int) element_size, 0);
}
for (unsigned long i = 0; i < length; i++) {
MonoObject *value;
Expand Down Expand Up @@ -1544,12 +1541,12 @@
bool is_value_type = mono_class_is_valuetype (managedElementType);
MonoObject *mobj;
void *valueptr = NULL;
int element_size = 0;
size_t element_size = 0;
char *ptr = NULL;

if (is_value_type) {
element_size = mono_class_value_size (managedElementType, NULL);
ptr = (char *) mono_array_addr_with_size (rv, element_size, 0);
element_size = (size_t) mono_class_value_size (managedElementType, NULL);
ptr = (char *) mono_array_addr_with_size (rv, (int) element_size, 0);
}
for (unsigned long i = 0; i < length; i++) {
if (is_value_type) {
Expand Down Expand Up @@ -1635,5 +1632,3 @@

return ptr;
}

#pragma clang diagnostic pop
4 changes: 2 additions & 2 deletions runtime/xamarin/runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,14 @@ bool xamarin_has_managed_ref (id self);
bool xamarin_has_managed_ref_safe (id self);
void xamarin_switch_gchandle (id self, bool to_weak);
int xamarin_get_gchandle (id self);
void xamarin_free_gchandle (id self, int gchandle);
void xamarin_free_gchandle (id self, uint32_t gchandle);
void xamarin_clear_gchandle (id self);
int xamarin_get_gchandle_with_flags (id self);
void xamarin_set_gchandle (id self, int gchandle);
void xamarin_create_gchandle (id self, void *managed_object, int flags, bool force_weak);
void xamarin_create_managed_ref (id self, void * managed_object, bool retain);
void xamarin_release_managed_ref (id self, MonoObject *managed_obj);
void xamarin_notify_dealloc (id self, int gchandle);
void xamarin_notify_dealloc (id self, uint32_t gchandle);

int xamarin_main (int argc, char *argv[], enum XamarinLaunchMode launch_mode);

Expand Down
2 changes: 1 addition & 1 deletion runtime/xamarin/trampolines.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ long long xamarin_longret_trampoline (id self, SEL sel, ...);
long long xamarin_static_longret_trampoline (id self, SEL sel, ...);
id xamarin_copyWithZone_trampoline1 (id self, SEL sel, NSZone *zone);
id xamarin_copyWithZone_trampoline2 (id self, SEL sel, NSZone *zone);
int xamarin_get_gchandle_trampoline (id self, SEL sel);
uint32_t xamarin_get_gchandle_trampoline (id self, SEL sel);
void xamarin_set_gchandle_trampoline (id self, SEL sel, int gc_handle);

unsigned long xamarin_get_frame_length (id self, SEL sel);
Expand Down