Index: src/OFObject.m ================================================================== --- src/OFObject.m +++ src/OFObject.m @@ -92,15 +92,10 @@ static SEL cxx_destruct = NULL; size_t of_pagesize; size_t of_num_cpus; -#ifdef OF_OBJFW_RUNTIME -extern BOOL objc_sync_init(); -extern BOOL objc_properties_init(); -#endif - #if !defined(OF_APPLE_RUNTIME) || defined(__OBJC2__) static void uncaught_exception_handler(id exception) { fprintf(stderr, "\nRuntime error: Unhandled exception:\n%s\n", @@ -234,23 +229,10 @@ } @implementation OFObject + (void)load { -#ifdef OF_OBJFW_RUNTIME - if (!objc_sync_init()) { - fputs("Runtime error: objc_sync_init() failed!\n", stderr); - abort(); - } - - if (!objc_properties_init()) { - fputs("Runtime error: objc_properties_init() failed!\n", - stderr); - abort(); - } -#endif - #if !defined(OF_APPLE_RUNTIME) || defined(__OBJC2__) objc_setUncaughtExceptionHandler(uncaught_exception_handler); #endif #ifdef OF_OBJFW_RUNTIME Index: src/runtime/property.m ================================================================== --- src/runtime/property.m +++ src/runtime/property.m @@ -16,10 +16,13 @@ #include "config.h" #include +#import "runtime.h" +#import "runtime-private.h" + #import "OFObject.h" #import "macros.h" #ifdef OF_THREADS # import "threading.h" @@ -26,23 +29,21 @@ # define NUM_SPINLOCKS 8 /* needs to be a power of 2 */ # define SPINLOCK_HASH(p) ((unsigned)((uintptr_t)p >> 4) & (NUM_SPINLOCKS - 1)) static of_spinlock_t spinlocks[NUM_SPINLOCKS]; #endif -BOOL -objc_properties_init(void) -{ #ifdef OF_THREADS +static void __attribute__((constructor)) +init(void) +{ size_t i; for (i = 0; i < NUM_SPINLOCKS; i++) if (!of_spinlock_new(&spinlocks[i])) - return NO; -#endif - - return YES; + OBJC_ERROR("Failed to initialize spinlocks!") } +#endif id objc_getProperty(id self, SEL _cmd, ptrdiff_t offset, BOOL atomic) { if (atomic) { Index: src/runtime/synchronized.m ================================================================== --- src/runtime/synchronized.m +++ src/runtime/synchronized.m @@ -21,18 +21,19 @@ #include #include #import "runtime.h" +#import "runtime-private.h" #import "threading.h" struct lock_s { - id object; - size_t count; - size_t recursion; - of_thread_t thread; - of_mutex_t mutex; + id object; + size_t count; + size_t recursion; + of_thread_t thread; + of_mutex_t mutex; }; static of_mutex_t mutex; static struct lock_s *locks = NULL; static ssize_t numLocks = 0; @@ -43,14 +44,15 @@ "WARNING: This might result in a race " \ "condition!\n", f, __LINE__); \ return 1; \ } -BOOL -objc_sync_init(void) +static void __attribute__((constructor)) +init(void) { - return of_mutex_new(&mutex); + if (!of_mutex_new(&mutex)) + OBJC_ERROR("Failed to create mutex!") } int objc_sync_enter(id object) {