Skip to content

Commit

Permalink
[mach] cast objc_msgSend{,Super} usages (#14836)
Browse files Browse the repository at this point in the history
Fixes #14792

(cherry picked from commit 812357e)
  • Loading branch information
lewurm authored and akoeplinger committed Jun 6, 2019
1 parent c6edaa6 commit c22486e
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions mono/utils/mono-threads-mach-helper.c
Expand Up @@ -10,8 +10,6 @@

#if defined(__MACH__)

#define OBJC_OLD_DISPATCH_PROTOTYPES 1 // TODO remove once https://github.com/mono/mono/issues/14792 is fixed

#include "config.h"
#include <glib.h>
#include <stdio.h>
Expand Down Expand Up @@ -66,7 +64,8 @@ mono_dead_letter_dealloc (id self, SEL _cmd)
#else
super.super_class = nsobject;
#endif
objc_msgSendSuper (&super, dealloc);
void (*objc_msgSendSuper_op)(struct objc_super *, SEL) = (void (*)(struct objc_super *, SEL)) objc_msgSendSuper;
objc_msgSendSuper_op (&super, dealloc);

mono_thread_info_detach ();
}
Expand All @@ -83,19 +82,20 @@ mono_threads_install_dead_letter (void)
* It doesn't hurt on other architectures either, so no need to #ifdef it only for ARM64.
*/

id (*id_objc_msgSend)(id, SEL) = (id (*)(id, SEL)) objc_msgSend;
id (*id_objc_msgSend_id)(id, SEL, id) = (id (*)(id, SEL, id)) objc_msgSend;
void (*objc_msgSend_id_id)(id, SEL, id, id) = (void (*)(id, SEL, id, id)) objc_msgSend;

cur = objc_msgSend ((id)nsthread, currentThread);
cur = id_objc_msgSend ((id)nsthread, currentThread);
if (!cur)
return;
dict = objc_msgSend (cur, threadDictionary);
dict = id_objc_msgSend (cur, threadDictionary);
if (dict && id_objc_msgSend_id (dict, objectForKey, mono_dead_letter_key) == nil) {
id value = objc_msgSend (objc_msgSend ((id)mono_dead_letter_class, alloc), init);
id value = id_objc_msgSend (id_objc_msgSend ((id)mono_dead_letter_class, alloc), init);

objc_msgSend_id_id (dict, setObjectForKey, value, mono_dead_letter_key);

objc_msgSend (value, release);
id_objc_msgSend (value, release);
}
}

Expand Down Expand Up @@ -127,13 +127,15 @@ mono_threads_init_dead_letter (void)
class_addMethod (mono_dead_letter_class, dealloc, (IMP)mono_dead_letter_dealloc, "v@:");
objc_registerClassPair (mono_dead_letter_class);

id (*id_objc_msgSend)(id, SEL) = (id (*)(id, SEL)) objc_msgSend;

// create the dict key
pool = objc_msgSend (objc_msgSend (nsautoreleasepool, alloc), init);
pool = id_objc_msgSend (id_objc_msgSend (nsautoreleasepool, alloc), init);

id (*objc_msgSend_char)(id, SEL, const char*) = (id (*)(id, SEL, const char*)) objc_msgSend;
mono_dead_letter_key = objc_msgSend_char (nsstring, stringWithUTF8String, "mono-dead-letter");

objc_msgSend (mono_dead_letter_key, retain);
objc_msgSend (pool, release);
id_objc_msgSend (mono_dead_letter_key, retain);
id_objc_msgSend (pool, release);
}
#endif

0 comments on commit c22486e

Please sign in to comment.