@@ -25,10 +25,14 @@ #import "inline.h" #include #include + +#ifdef OF_AMIGAOS_M68K +# include +#endif #ifdef HAVE_SJLJ_EXCEPTIONS extern int _Unwind_SjLj_RaiseException(void *); #else extern int _Unwind_RaiseException(void *); @@ -51,12 +55,15 @@ extern void __deregister_frame_info(const void *); struct Library *ObjFWRTBase; void *__objc_class_name_Protocol; -static void __attribute__((__constructor__)) -init(void) +static void +#ifndef OF_AMIGAOS_M68K + __attribute__((__constructor__)) +#endif +ctor(void) { static bool initialized = false; struct objc_libc libc = { .malloc = malloc, .calloc = calloc, @@ -104,23 +111,34 @@ } initialized = true; } -OF_DESTRUCTOR() +static void +#ifndef OF_AMIGAOS_M68K + __attribute__((__destructor__)) +#else + __attribute__((__unused__)) +#endif +dtor(void) { CloseLibrary(ObjFWRTBase); } + +#ifdef OF_AMIGAOS_M68K +ADD2INIT(ctor, -2); +ADD2EXIT(dtor, -2); +#endif void __objc_exec_class(void *module) { /* * The compiler generates constructors that call into this, so it is * possible that we are not set up yet when we get called. */ - init(); + ctor(); __objc_exec_class_m68k(module); } IMP