]> git.saurik.com Git - apple/objc4.git/blobdiff - test/blocksAsImps.m
objc4-646.tar.gz
[apple/objc4.git] / test / blocksAsImps.m
index 5376efb0fc178f6a6f7c0caf72a36d98ba159d54..360321af7ec9593359b1651598ecce21695dcb94 100644 (file)
 #if !__clang__
     // gcc and llvm-gcc will never support struct-return marking
 #   define STRET_OK 0
+#   define STRET_SPECIAL 0
+#elif __arm64__
+    // stret supported, but is identical to non-stret
+#   define STRET_OK 1
+#   define STRET_SPECIAL 0
 #else
+    // stret supported and distinct from non-stret
 #   define STRET_OK 1
+#   define STRET_SPECIAL 1
 #endif
 
 typedef struct BigStruct {
@@ -71,15 +78,21 @@ void dealloc_imp(Deallocator *self, SEL _cmd) {
 /* Code copied from objc-block-trampolines.m to test Block innards */
 typedef enum {
     ReturnValueInRegisterArgumentMode,
+#if STRET_SPECIAL
     ReturnValueOnStackArgumentMode,
+#endif
     
     ArgumentModeMax
 } ArgumentMode;
 
 static ArgumentMode _argumentModeForBlock(id block) {
     ArgumentMode aMode = ReturnValueInRegisterArgumentMode;
+#if STRET_SPECIAL
     if ( _Block_use_stret((__bridge void *)block) )
         aMode = ReturnValueOnStackArgumentMode;
+#else
+    testassert(!_Block_use_stret((__bridge void *)block));
+#endif
     
     return aMode;
 }
@@ -96,9 +109,13 @@ int main () {
 #if STRET_OK
     BigStruct (^stackReturn)() = ^() { BigStruct k; return k; };
     aMode = _argumentModeForBlock(stackReturn);
+# if STRET_SPECIAL
     testassert(aMode == ReturnValueOnStackArgumentMode);
+# else
+    testassert(aMode == ReturnValueInRegisterArgumentMode);
+# endif
 #endif
-        
+
 #define TEST_QUANTITY 100000
     static FuncPtr funcArray[TEST_QUANTITY];