From 652be81b7a7e80eb51064918b933b4090935f86f Mon Sep 17 00:00:00 2001 From: "Dustin L. Howett" Date: Mon, 4 Jan 2016 10:20:30 -0800 Subject: [PATCH] win32: add an unpleasant workaround for _NSConcreteGlobalBlock's linkage --- arc.m | 11 +++++++++-- class.h | 4 ++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/arc.m b/arc.m index 1a4f7773..687651b1 100644 --- a/arc.m +++ b/arc.m @@ -45,7 +45,7 @@ static inline DWORD arc_tls_key_create(void WINAPI(*cleanupFunction)(void*)) extern void _NSConcreteMallocBlock; extern void _NSConcreteStackBlock; -extern void _NSConcreteGlobalBlock; +extern struct objc_class _NSConcreteGlobalBlock; @interface NSAutoreleasePool + (Class)class; @@ -190,6 +190,12 @@ static inline id retain(id obj) { if (isSmallObject(obj)) { return obj; } Class cls = obj->isa; + + if ((Class)&_NSConcreteGlobalBlock == cls->isa) + { + cls = cls->isa; + } + if ((Class)&_NSConcreteMallocBlock == cls || (Class)&_NSConcreteStackBlock == cls) { @@ -214,13 +220,14 @@ static inline void release(id obj) { if (isSmallObject(obj)) { return; } Class cls = obj->isa; + if (cls == &_NSConcreteMallocBlock) { _Block_release(obj); return; } if ((cls == &_NSConcreteStackBlock) || - (cls == &_NSConcreteGlobalBlock)) + (cls->isa == &_NSConcreteGlobalBlock)) { return; } diff --git a/class.h b/class.h index 8da94eb2..e41afac4 100644 --- a/class.h +++ b/class.h @@ -300,6 +300,10 @@ static inline Class classForObject(id obj) return SmallObjectClasses[(addr & OBJC_SMALL_OBJECT_MASK)]; } } + extern struct objc_class _NSConcreteGlobalBlock; + if (obj->isa->isa == (Class)&_NSConcreteGlobalBlock) { + return (Class)&_NSConcreteGlobalBlock; + } return obj->isa; }