[arm64] Fix another crash due to not using the right objc_msgSend signature.
authorRolf Bjarne Kvinge <rolf@xamarin.com>
Fri, 23 May 2014 16:53:18 +0000 (18:53 +0200)
committerRolf Bjarne Kvinge <rolf@xamarin.com>
Mon, 26 May 2014 16:29:25 +0000 (18:29 +0200)
Also simplify the code a little bit, there's no need to have separate
code paths for ARM64, since using the correct objc_msgSend signature
works on all architectures.

mono/utils/mono-threads-mach-helper.c

index d072050078d167374d803c960f6580f8aca66edc..cafb3fe96d03a7ddc35d3e72216ccdb8258be080 100644 (file)
@@ -66,25 +66,24 @@ mono_threads_install_dead_letter (void)
 {
        id cur, dict;
 
+       /*
+        * See the 'Dispatch Objective-C Messages Using the Method Function’s Prototype' section in
+        * the '64-Bit Transition Guide for Cocoa Touch' as to why this is required.
+        *
+        * It doesn't hurt on other architectures either, so no need to #ifdef it only for ARM64.
+        */
+
+       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);
        if (!cur)
                return;
        dict = objc_msgSend (cur, threadDictionary);
-       if (dict && objc_msgSend (dict, objectForKey, mono_dead_letter_key) == nil) {
+       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);
 
-#ifdef TARGET_ARM64
-               /*
-                * See the 'Dispatch Objective-C Messages Using the Method Function’s Prototype' section in
-                * the '64-Bit Transition Guide for Cocoa Touch' as to why this is required.
-                */
-               {
-                       void (*action)(id, SEL, id, id) = (void (*)(id, SEL, id, id)) objc_msgSend;
-                       action (dict, setObjectForKey, value, mono_dead_letter_key);
-               }
-#else
-               objc_msgSend (dict, setObjectForKey, value, mono_dead_letter_key);
-#endif
+               objc_msgSend_id_id (dict, setObjectForKey, value, mono_dead_letter_key);
 
                objc_msgSend (value, release);
        }
@@ -121,14 +120,8 @@ mono_threads_init_dead_letter (void)
        // create the dict key
        pool = objc_msgSend (objc_msgSend (nsautoreleasepool, alloc), init);
 
-#ifdef TARGET_ARM64
-       {
-               id (*action)(id, SEL, char*) = (id (*)(id, SEL, char*)) objc_msgSend;
-               mono_dead_letter_key = action(nsstring, stringWithUTF8String, "mono-dead-letter");
-       }
-#else
-       mono_dead_letter_key = objc_msgSend (nsstring, stringWithUTF8String, "mono-dead-letter");
-#endif
+       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);