Index: configure.ac ================================================================== --- configure.ac +++ configure.ac @@ -285,12 +285,10 @@ case "$host_os" in darwin*) AC_SUBST(LDFLAGS_REEXPORT, ["-Wl,-reexport-lobjfw"]) AS_IF([test x"$objc_runtime" = x"Apple runtime"], [ AC_SUBST(REEXPORT_LIBOBJC, ["-Wl,-reexport-lobjc"]) - tmp="-Xarch_x86_64 -Wl,-alias_list,mach_alias_list" - AC_SUBST(MACH_ALIAS_LIST, $tmp) ]) ;; esac AC_C_BIGENDIAN([ Index: extra.mk.in ================================================================== --- extra.mk.in +++ extra.mk.in @@ -19,11 +19,10 @@ EXCEPTIONS_EXCEPTIONS_LIB_A = @EXCEPTIONS_EXCEPTIONS_LIB_A@ EXCEPTIONS_LIB_A = @EXCEPTIONS_LIB_A@ FOUNDATION_COMPAT_M = @FOUNDATION_COMPAT_M@ INSTANCE_M = @INSTANCE_M@ LOOKUP_S = @LOOKUP_S@ -MACH_ALIAS_LIST = @MACH_ALIAS_LIST@ OFBLOCKTESTS_M = @OFBLOCKTESTS_M@ OBJC_PROPERTIES_M = @OBJC_PROPERTIES_M@ OBJC_SYNC_M = @OBJC_SYNC_M@ OFHTTPREQUESTTESTS_M = @OFHTTPREQUESTTESTS_M@ OFPLUGIN_M = @OFPLUGIN_M@ Index: src/Makefile ================================================================== --- src/Makefile +++ src/Makefile @@ -114,8 +114,8 @@ CPPFLAGS += -I. -I.. -Iexceptions -Iruntime AS = ${OBJC} ASFLAGS = ${CPPFLAGS} AS_DEPENDS = ${OBJC_DEPENDS} LD = ${OBJC} -LDFLAGS += ${REEXPORT_LIBOBJC} ${MACH_ALIAS_LIST} +LDFLAGS += ${REEXPORT_LIBOBJC} ${BRIDGE}: ${SHARED_LIB} Index: src/OFBlock.m ================================================================== --- src/OFBlock.m +++ src/OFBlock.m @@ -18,14 +18,14 @@ #include #include #include -#if defined(OF_APPLE_RUNTIME) && !defined(__OBJC2__) -# import -#elif defined(OF_OBJFW_RUNTIME) +#if defined(OF_OBJFW_RUNTIME) # import "runtime-private.h" +#elif defined(OF_APPLE_RUNTIME) +# import #endif #import "OFBlock.h" #import "OFAllocFailedException.h" @@ -70,20 +70,11 @@ @protocol RetainRelease - retain; - (void)release; @end -#ifndef OF_OBJFW_RUNTIME -enum objc_abi_class_info { - OBJC_CLASS_INFO_CLASS = 0x01, - OBJC_CLASS_INFO_METACLASS = 0x02 -}; -#endif - -#if defined(OF_OBJFW_RUNTIME) -extern void __objc_exec_class(struct objc_abi_module*); - +#ifdef OF_OBJFW_RUNTIME /* Begin of ObjC module */ static struct objc_abi_class _NSConcreteStackBlock_metaclass = { (struct objc_abi_class*)(void*)"OFBlock", "OFBlock", "OFStackBlock", 8, OBJC_CLASS_INFO_METACLASS, sizeof(struct objc_abi_class), NULL, NULL }; @@ -128,17 +119,21 @@ static struct objc_abi_module module = { 8, sizeof(module), NULL, (struct objc_abi_symtab*)&symtab }; +extern void __objc_exec_class(struct objc_abi_module*); + static void __attribute__((constructor)) constructor(void) { __objc_exec_class(&module); } /* End of ObjC module */ -#elif defined(OF_APPLE_RUNTIME) && !defined(__OBJC2__) +#elif defined(OF_APPLE_RUNTIME) +extern Class objc_initializeClassPair(Class, const char*, Class, Class); + struct class { struct class *isa, *super_class; const char *name; long version, info, instance_size; struct ivar_list *ivars; @@ -150,14 +145,15 @@ }; struct class _NSConcreteStackBlock; struct class _NSConcreteGlobalBlock; struct class _NSConcreteMallocBlock; -#else -extern void *_NSConcreteStackBlock; -extern void *_NSConcreteGlobalBlock; -extern void *_NSConcreteMallocBlock; +# ifdef __OBJC2__ +struct class _NSConcreteStackBlock_metaclass; +struct class _NSConcreteGlobalBlock_metaclass; +struct class _NSConcreteMallocBlock_metaclass; +# endif #endif static struct { Class isa; } alloc_failed_exception; @@ -317,15 +313,40 @@ break; } } @implementation OFBlock -#if defined(OF_APPLE_RUNTIME) && !defined(__OBJC2__) +#ifdef OF_APPLE_RUNTIME + (void)load { Class tmp; +#ifdef __OBJC2__ + tmp = objc_initializeClassPair(self, "OFStackBlock", + (Class)&_NSConcreteStackBlock, + (Class)&_NSConcreteStackBlock_metaclass); + if (tmp == Nil) + @throw [OFInitializationFailedException + exceptionWithClass: self]; + objc_registerClassPair(tmp); + + tmp = objc_initializeClassPair(self, "OFGlobalBlock", + (Class)&_NSConcreteGlobalBlock, + (Class)&_NSConcreteGlobalBlock_metaclass); + if (tmp == Nil) + @throw [OFInitializationFailedException + exceptionWithClass: self]; + objc_registerClassPair(tmp); + + tmp = objc_initializeClassPair([OFBlock class], "OFMallocBlock", + (Class)&_NSConcreteMallocBlock, + (Class)&_NSConcreteMallocBlock_metaclass); + if (tmp == Nil) + @throw [OFInitializationFailedException + exceptionWithClass: self]; + objc_registerClassPair(tmp); +# else /* * There is no objc_initializeClassPair in 10.5. * However, objc_allocateClassPair does not register the new class with * the subclass in the ObjC1 runtime like the ObjC2 runtime does, so * this workaround should be fine. @@ -348,10 +369,11 @@ @throw [OFInitializationFailedException exceptionWithClass: self]; memcpy(&_NSConcreteMallocBlock, tmp, sizeof(_NSConcreteMallocBlock)); free(tmp); objc_registerClassPair((Class)&_NSConcreteMallocBlock); +# endif } #endif #if !defined(OF_ATOMIC_OPS) + (void)initialize @@ -452,40 +474,5 @@ @throw [OFNotImplementedException exceptionWithClass: [self class] selector: _cmd]; [super dealloc]; /* Get rid of a stupid warning */ } @end - -#if defined(OF_APPLE_RUNTIME) && defined(__OBJC2__) -@implementation OFStackBlock -+ (void)load -{ - /* - * Send a message to the class to ensure it's initialized. Otherwise it - * it might not get initialized as blocks are preallocated. - */ - [self class]; -} -@end - -@implementation OFGlobalBlock -+ (void)load -{ - /* - * Send a message to the class to ensure it's initialized. Otherwise it - * it might not get initialized as blocks are preallocated. - */ - [self class]; -} -@end - -@implementation OFMallocBlock -+ (void)load -{ - /* - * Send a message to the class to ensure it's initialized. Otherwise it - * it might not get initialized as blocks are preallocated. - */ - [self class]; -} -@end -#endif DELETED src/mach_alias_list Index: src/mach_alias_list ================================================================== --- src/mach_alias_list +++ src/mach_alias_list @@ -1,4 +0,0 @@ -# List of aliases for Mach-O -_OBJC_CLASS_$_OFStackBlock __NSConcreteStackBlock -_OBJC_CLASS_$_OFGlobalBlock __NSConcreteGlobalBlock -_OBJC_CLASS_$_OFMallocBlock __NSConcreteMallocBlock