Index: src/runtime/Makefile ================================================================== --- src/runtime/Makefile +++ src/runtime/Makefile @@ -45,8 +45,8 @@ CPPFLAGS += -I. -I.. -I../.. \ -DOF_COMPILING_OBJFW_RT \ -DOBJFW_RT_LIB_MAJOR=${OBJFW_RT_LIB_MAJOR} \ -DOBJFW_RT_LIB_MINOR=${OBJFW_RT_LIB_MINOR} -AMIGA_LIB_CFLAGS += -DOF_AMIGA_LIBRARY +AMIGA_LIB_CFLAGS += -DOBJC_AMIGA_LIBRARY LD = ${OBJC} FRAMEWORK_LIBS = ${LIBS} Index: src/runtime/ObjFW_RT.fd ================================================================== --- src/runtime/ObjFW_RT.fd +++ src/runtime/ObjFW_RT.fd @@ -19,35 +19,35 @@ objc_setProperty_inline()(sysv,r12base) objc_getPropertyStruct_inline()(sysv,r12base) objc_setPropertyStruct_inline()(sysv,r12base) objc_enumerationMutation_inline()(sysv,r12base) * Functions declared in ObjFW_RT.h -sel_registerName()(sysv,r12base) -sel_getName()(sysv,r12base) -sel_isEqual()(sysv,r12base) -objc_allocateClassPair()(sysv,r12base) -objc_registerClassPair()(sysv,r12base) -objc_getClassList()(sysv,r12base) -objc_copyClassList()(sysv,r12base) -class_isMetaClass()(sysv,r12base) -class_getName()(sysv,r12base) -class_getSuperclass()(sysv,r12base) -class_getInstanceSize()(sysv,r12base) -class_respondsToSelector()(sysv,r12base) -class_conformsToProtocol()(sysv,r12base) -class_getMethodImplementation()(sysv,r12base) -class_getMethodImplementation_stret()(sysv,r12base) -class_getMethodTypeEncoding()(sysv,r12base) -class_addMethod()(sysv,r12base) -class_replaceMethod()(sysv,r12base) -object_getClass()(sysv,r12base) -object_setClass()(sysv,r12base) -object_getClassName()(sysv,r12base) -protocol_getName()(sysv,r12base) -protocol_isEqual()(sysv,r12base) -protocol_conformsToProtocol()(sysv,r12base) -objc_exit()(sysv,r12base) -objc_setUncaughtExceptionHandler()(sysv,r12base) -objc_setForwardHandler()(sysv,r12base) -objc_setEnumerationMutationHandler()(sysv,r12base) -objc_zero_weak_references()(sysv,r12base) +sel_registerName(name)(A0) +sel_getName(sel)(A0) +sel_isEqual(sel1, sel2)(A0/A1) +objc_allocateClassPair(superclass, name, extra_bytes)(A0/A1/D0) +objc_registerClassPair(cls)(A0) +objc_getClassList(buf, count)(A0/D)) +objc_copyClassList(len)(A0) +class_isMetaClass(cls)(A0) +class_getName(cls)(A0) +class_getSuperclass(cls)(A0) +class_getInstanceSize(cls)(A0) +class_respondsToSelector(cls, sel)(A0/A1) +class_conformsToProtocol(cls, p)(A0/A1) +class_getMethodImplementation(cls, sel)(A0/A1) +class_getMethodImplementation_stret(cls, sel)(A0/A1) +class_getMethodTypeEncoding(cls, sel)(A0/A1) +class_addMethod(cls, sel, imp, types)(A0/A1/A2/A3) +class_replaceMethod(cls, sel, imp, types)(A0/A1/A2/A3) +object_getClass(obj)(A0) +object_setClass(obj, cls)(A0/A1) +object_getClassName(obj)(A0) +protocol_getName(p)(A0) +protocol_isEqual(a, b)(A0/A1) +protocol_conformsToProtocol(a, b)(A0/A1) +objc_exit()() +objc_setUncaughtExceptionHandler(handler)(A0) +objc_setForwardHandler(forward, forward_stret)(A0/A1) +objc_setEnumerationMutationHandler(handler)(A0) +objc_zero_weak_references(value)(A0) ##end Index: src/runtime/ObjFW_RT.h ================================================================== --- src/runtime/ObjFW_RT.h +++ src/runtime/ObjFW_RT.h @@ -61,11 +61,11 @@ #if defined(__amigaos__) && !defined(__MORPHOS__) && !defined(__amigaos4__) # define OBJC_M68K_REG(reg) __asm__(reg) #else # define OBJC_M68K_REG(reg) #endif -#ifdef __MORPHOS__ +#if defined(__MORPHOS__) && defined(OBJC_AMIGA_LIBRARY) # define OBJC_M68K_FUNC(name, args) name(void) # define OBJC_M68K_ARG(type, name, reg) type name = (type)reg; #else # define OBJC_M68K_FUNC(name, ...) name(__VA_ARGS__) # define OBJC_M68K_ARG(type, name, reg) @@ -219,48 +219,73 @@ }; #ifdef __cplusplus extern "C" { #endif -extern SEL _Nonnull sel_registerName(const char *_Nonnull); -extern const char *_Nonnull sel_getName(SEL _Nonnull); -extern bool sel_isEqual(SEL _Nonnull, SEL _Nonnull); -extern Class _Nonnull objc_allocateClassPair(Class _Nullable, - const char *_Nonnull, size_t); -extern void objc_registerClassPair(Class _Nonnull); -extern unsigned int objc_getClassList(Class _Nonnull *_Nullable, unsigned int); -extern Class _Nonnull *_Nonnull objc_copyClassList(unsigned int *_Nullable); -extern bool class_isMetaClass(Class _Nullable); -extern const char *_Nullable class_getName(Class _Nullable); -extern Class _Nullable class_getSuperclass(Class _Nullable); -extern unsigned long class_getInstanceSize(Class _Nullable); -extern bool class_respondsToSelector(Class _Nullable, SEL _Nonnull); -extern bool class_conformsToProtocol(Class _Nullable, Protocol *_Nonnull); -extern IMP _Nullable class_getMethodImplementation(Class _Nullable, - SEL _Nonnull); -extern IMP _Nullable class_getMethodImplementation_stret(Class _Nullable, - SEL _Nonnull); -extern const char *_Nullable class_getMethodTypeEncoding(Class _Nullable, - SEL _Nonnull); -extern bool class_addMethod(Class _Nonnull, SEL _Nonnull, IMP _Nonnull, - const char *_Nullable); -extern IMP _Nullable class_replaceMethod(Class _Nonnull, SEL _Nonnull, - IMP _Nonnull, const char *_Nullable); -extern Class _Nullable object_getClass(id _Nullable); -extern Class _Nullable object_setClass(id _Nullable, Class _Nonnull); -extern const char *_Nullable object_getClassName(id _Nullable); -extern const char *_Nonnull protocol_getName(Protocol *_Nonnull); -extern bool protocol_isEqual(Protocol *_Nonnull, Protocol *_Nonnull); -extern bool protocol_conformsToProtocol(Protocol *_Nonnull, Protocol *_Nonnull); +extern SEL _Nonnull sel_registerName( + const char *_Nonnull name OBJC_M68K_REG("a0")); +extern const char *_Nonnull sel_getName(SEL _Nonnull sel OBJC_M68K_REG("a0")); +extern bool sel_isEqual(SEL _Nonnull sel1 OBJC_M68K_REG("a0"), + SEL _Nonnull sel2 OBJC_M68K_REG("a1")); +extern Class _Nonnull objc_allocateClassPair( + Class _Nullable superclass OBJC_M68K_REG("a0"), + const char *_Nonnull name OBJC_M68K_REG("a1"), + size_t extra_bytes OBJC_M68K_REG("d0")); +extern void objc_registerClassPair(Class _Nonnull cls OBJC_M68K_REG("a0")); +extern unsigned int objc_getClassList( + Class _Nonnull *_Nullable buf OBJC_M68K_REG("a0"), + unsigned int count OBJC_M68K_REG("d0")); +extern Class _Nonnull *_Nonnull objc_copyClassList( + unsigned int *_Nullable OBJC_M68K_REG("a0")); +extern bool class_isMetaClass(Class _Nullable cls OBJC_M68K_REG("a0")); +extern const char *_Nullable class_getName( + Class _Nullable cls OBJC_M68K_REG("a0")); +extern Class _Nullable class_getSuperclass( + Class _Nullable cls OBJC_M68K_REG("a0")); +extern unsigned long class_getInstanceSize( + Class _Nullable cls OBJC_M68K_REG("a0")); +extern bool class_respondsToSelector(Class _Nullable cls OBJC_M68K_REG("a0"), + SEL _Nonnull sel OBJC_M68K_REG("a1")); +extern bool class_conformsToProtocol(Class _Nullable cls OBJC_M68K_REG("a0"), + Protocol *_Nonnull p OBJC_M68K_REG("a1")); +extern IMP _Nullable class_getMethodImplementation( + Class _Nullable cls OBJC_M68K_REG("a0"), + SEL _Nonnull sel OBJC_M68K_REG("a1")); +extern IMP _Nullable class_getMethodImplementation_stret( + Class _Nullable cls OBJC_M68K_REG("a0"), + SEL _Nonnull sel OBJC_M68K_REG("a1")); +extern const char *_Nullable class_getMethodTypeEncoding( + Class _Nullable cls OBJC_M68K_REG("a0"), + SEL _Nonnull sel OBJC_M68K_REG("a1")); +extern bool class_addMethod(Class _Nonnull cls OBJC_M68K_REG("a0"), + SEL _Nonnull sel OBJC_M68K_REG("a1"), IMP _Nonnull imp OBJC_M68K_REG("a2"), + const char *_Nullable types OBJC_M68K_REG("a3")); +extern IMP _Nullable class_replaceMethod(Class _Nonnull cls OBJC_M68K_REG("a0"), + SEL _Nonnull sel OBJC_M68K_REG("a1"), + IMP _Nonnull imp OBJC_M68K_REG("a2"), + const char *_Nullable types OBJC_M68K_REG("a3")); +extern Class _Nullable object_getClass(id _Nullable obj OBJC_M68K_REG("a0")); +extern Class _Nullable object_setClass(id _Nullable obj OBJC_M68K_REG("a0"), + Class _Nonnull OBJC_M68K_REG("a1")); +extern const char *_Nullable object_getClassName( + id _Nullable obj OBJC_M68K_REG("a0")); +extern const char *_Nonnull protocol_getName( + Protocol *_Nonnull p OBJC_M68K_REG("a0")); +extern bool protocol_isEqual(Protocol *_Nonnull a OBJC_M68K_REG("a0"), + Protocol *_Nonnull b OBJC_M68K_REG("a1")); +extern bool protocol_conformsToProtocol( + Protocol *_Nonnull a OBJC_M68K_REG("a0"), + Protocol *_Nonnull b OBJC_M68K_REG("a1")); extern void objc_exit(void); extern _Nullable objc_uncaught_exception_handler objc_setUncaughtExceptionHandler( - objc_uncaught_exception_handler _Nullable); -extern void objc_setForwardHandler(IMP _Nullable, IMP _Nullable); + objc_uncaught_exception_handler _Nullable handler OBJC_M68K_REG("a0")); +extern void objc_setForwardHandler(IMP _Nullable forward OBJC_M68K_REG("a0"), + IMP _Nullable forward_stret OBJC_M68K_REG("a1")); extern void objc_setEnumerationMutationHandler( - objc_enumeration_mutation_handler _Nullable); -extern void objc_zero_weak_references(id _Nonnull); + objc_enumeration_mutation_handler _Nullable handler OBJC_M68K_REG("a0")); +extern void objc_zero_weak_references(id _Nonnull value OBJC_M68K_REG("a0")); # ifdef OF_AMIGAOS extern struct Library *ObjFWRTBase; # endif /* Index: src/runtime/amiga-library.m ================================================================== --- src/runtime/amiga-library.m +++ src/runtime/amiga-library.m @@ -122,11 +122,11 @@ { return 0; } static void -objc_set_libc(struct objc_libc *libc_) +objc_set_libc(struct objc_libc *libc_ OBJC_M68K_REG("a0")) { libc = libc_; stdout = libc->stdout; stderr = libc->stderr; Index: src/runtime/arc.m ================================================================== --- src/runtime/arc.m +++ src/runtime/arc.m @@ -267,11 +267,11 @@ OBJC_ERROR("Failed to unlock spinlock!") #endif } void -objc_zero_weak_references(id value) +objc_zero_weak_references(id value OBJC_M68K_REG("a0")) { struct weak_ref *ref; #ifdef OF_HAVE_THREADS if (!of_spinlock_lock(&spinlock)) Index: src/runtime/class.m ================================================================== --- src/runtime/class.m +++ src/runtime/class.m @@ -417,11 +417,13 @@ process_load_queue(); } Class -objc_allocateClassPair(Class superclass, const char *name, size_t extra_bytes) +objc_allocateClassPair(Class superclass OBJC_M68K_REG("a0"), + const char *name OBJC_M68K_REG("a1"), + size_t extra_bytes OBJC_M68K_REG("d0")) { struct objc_class *cls, *metaclass; Class iter, rootclass = Nil; if (extra_bytes > LONG_MAX) @@ -451,11 +453,11 @@ return cls; } void -objc_registerClassPair(Class cls) +objc_registerClassPair(Class cls OBJC_M68K_REG("a0")) { objc_global_mutex_lock(); register_class((struct objc_abi_class *)cls); @@ -528,11 +530,12 @@ { return objc_getRequiredClass(name); } unsigned int -objc_getClassList(Class *buf, unsigned int count) +objc_getClassList(Class *buf OBJC_M68K_REG("a0"), + unsigned int count OBJC_M68K_REG("d0")) { unsigned int j; objc_global_mutex_lock(); if (buf == NULL) @@ -568,11 +571,11 @@ return j; } Class * -objc_copyClassList(unsigned int *len) +objc_copyClassList(unsigned int *len OBJC_M68K_REG("a0")) { Class *ret; unsigned int count; objc_global_mutex_lock(); @@ -592,47 +595,48 @@ return ret; } bool -class_isMetaClass(Class cls) +class_isMetaClass(Class cls OBJC_M68K_REG("a0")) { if (cls == Nil) return false; return (cls->info & OBJC_CLASS_INFO_METACLASS); } const char * -class_getName(Class cls) +class_getName(Class cls OBJC_M68K_REG("a0")) { if (cls == Nil) return ""; return cls->name; } Class -class_getSuperclass(Class cls) +class_getSuperclass(Class cls OBJC_M68K_REG("a0")) { if (cls == Nil) return Nil; return cls->superclass; } unsigned long -class_getInstanceSize(Class cls) +class_getInstanceSize(Class cls OBJC_M68K_REG("a0")) { if (cls == Nil) return 0; return cls->instance_size; } IMP -class_getMethodImplementation(Class cls, SEL sel) +class_getMethodImplementation(Class cls OBJC_M68K_REG("a0"), + SEL sel OBJC_M68K_REG("a1")) { /* * We use a dummy object here so that the normal lookup is used, even * though we don't have an object. Doing so is safe, as objc_msg_lookup * does not access the object, but only its class. @@ -652,11 +656,12 @@ dummy.isa = cls; return objc_msg_lookup((id)&dummy, sel); } IMP -class_getMethodImplementation_stret(Class cls, SEL sel) +class_getMethodImplementation_stret(Class cls OBJC_M68K_REG("a0"), + SEL sel OBJC_M68K_REG("a1")) { /* * Same as above, but use objc_msg_lookup_stret instead, so that the * correct forwarding handler is returned. */ @@ -719,11 +724,12 @@ objc_update_dtable(cls); } const char * -class_getMethodTypeEncoding(Class cls, SEL sel) +class_getMethodTypeEncoding(Class cls OBJC_M68K_REG("a0"), + SEL sel OBJC_M68K_REG("a1")) { struct objc_method *method; if (cls == Nil) return NULL; @@ -743,11 +749,12 @@ return NULL; } bool -class_addMethod(Class cls, SEL sel, IMP imp, const char *types) +class_addMethod(Class cls OBJC_M68K_REG("a0"), SEL sel OBJC_M68K_REG("a1"), + IMP imp OBJC_M68K_REG("a2"), const char *types OBJC_M68K_REG("a3")) { bool ret; objc_global_mutex_lock(); @@ -761,11 +768,12 @@ return ret; } IMP -class_replaceMethod(Class cls, SEL sel, IMP newimp, const char *types) +class_replaceMethod(Class cls OBJC_M68K_REG("a0"), SEL sel OBJC_M68K_REG("a1"), + IMP newimp OBJC_M68K_REG("a2"), const char *types OBJC_M68K_REG("a3")) { struct objc_method *method; IMP oldimp; objc_global_mutex_lock(); @@ -783,11 +791,11 @@ return oldimp; } Class -object_getClass(id obj_) +object_getClass(id obj_ OBJC_M68K_REG("a0")) { struct objc_object *obj; if (obj_ == nil) return Nil; @@ -796,11 +804,11 @@ return obj->isa; } Class -object_setClass(id obj_, Class cls) +object_setClass(id obj_ OBJC_M68K_REG("a0"), Class cls OBJC_M68K_REG("a1")) { struct objc_object *obj; Class old; if (obj_ == nil) @@ -813,11 +821,11 @@ return old; } const char * -object_getClassName(id obj) +object_getClassName(id obj OBJC_M68K_REG("a0")) { return class_getName(object_getClass(obj)); } static void Index: src/runtime/exception.m ================================================================== --- src/runtime/exception.m +++ src/runtime/exception.m @@ -757,11 +757,12 @@ OBJC_ERROR("_Unwind_RaiseException() returned!") } objc_uncaught_exception_handler -objc_setUncaughtExceptionHandler(objc_uncaught_exception_handler handler) +objc_setUncaughtExceptionHandler( + objc_uncaught_exception_handler handler OBJC_M68K_REG("a0")) { objc_uncaught_exception_handler old = uncaught_exception_handler; uncaught_exception_handler = handler; return old; Index: src/runtime/lookup.m ================================================================== --- src/runtime/lookup.m +++ src/runtime/lookup.m @@ -115,18 +115,20 @@ return common_method_not_found(obj, sel, objc_msg_lookup_stret, forward_handler_stret); } void -objc_setForwardHandler(IMP forward, IMP forward_stret) +objc_setForwardHandler(IMP forward OBJC_M68K_REG("a0"), + IMP forward_stret OBJC_M68K_REG("a1")) { forward_handler = forward; forward_handler_stret = forward_stret; } bool -class_respondsToSelector(Class cls, SEL sel) +class_respondsToSelector(Class cls OBJC_M68K_REG("a0"), + SEL sel OBJC_M68K_REG("a1")) { if (cls == Nil) return false; return (objc_dtable_get(cls->dtable, (uint32_t)sel->uid) != (IMP)0); Index: src/runtime/misc.m ================================================================== --- src/runtime/misc.m +++ src/runtime/misc.m @@ -33,9 +33,10 @@ else OBJC_ERROR("Object was mutated during enumeration!"); } void -objc_setEnumerationMutationHandler(void (*handler)(id)) +objc_setEnumerationMutationHandler( + objc_enumeration_mutation_handler handler OBJC_M68K_REG("a0")) { enumeration_mutation_handler = handler; } Index: src/runtime/private.h ================================================================== --- src/runtime/private.h +++ src/runtime/private.h @@ -132,11 +132,11 @@ IMP _Nullable buckets[256]; #endif } *_Nonnull buckets[256]; }; -#ifdef OF_AMIGA_LIBRARY +#ifdef OBJC_AMIGA_LIBRARY # undef stdout # undef stderr extern struct objc_libc { void *(*malloc)(size_t); void *(*calloc)(size_t, size_t); Index: src/runtime/protocol.m ================================================================== --- src/runtime/protocol.m +++ src/runtime/protocol.m @@ -24,23 +24,25 @@ @implementation Protocol @end const char * -protocol_getName(Protocol *p) +protocol_getName(Protocol *p OBJC_M68K_REG("a0")) { return p->name; } bool -protocol_isEqual(Protocol *a, Protocol *b) +protocol_isEqual(Protocol *a OBJC_M68K_REG("a0"), + Protocol *b OBJC_M68K_REG("a1")) { return (strcmp(protocol_getName(a), protocol_getName(b)) == 0); } bool -protocol_conformsToProtocol(Protocol *a, Protocol *b) +protocol_conformsToProtocol(Protocol *a OBJC_M68K_REG("a0"), + Protocol *b OBJC_M68K_REG("a1")) { if (protocol_isEqual(a, b)) return true; for (struct objc_protocol_list *pl = a->protocol_list; @@ -51,11 +53,12 @@ return false; } bool -class_conformsToProtocol(Class cls, Protocol *p) +class_conformsToProtocol(Class cls OBJC_M68K_REG("a0"), + Protocol *p OBJC_M68K_REG("a1")) { struct objc_category **cats; if (cls == Nil) return false; Index: src/runtime/selector.m ================================================================== --- src/runtime/selector.m +++ src/runtime/selector.m @@ -67,11 +67,11 @@ objc_hashtable_set(selectors, name, rsel); objc_sparsearray_set(selector_names, (uint32_t)rsel->uid, (void *)name); } SEL -sel_registerName(const char *name) +sel_registerName(const char *name OBJC_M68K_REG("a0")) { const struct objc_abi_selector *rsel; struct objc_abi_selector *sel; objc_global_mutex_lock(); @@ -114,11 +114,11 @@ for (sel = symtab->sel_refs; sel->name != NULL; sel++) objc_register_selector(sel); } const char * -sel_getName(SEL sel) +sel_getName(SEL sel OBJC_M68K_REG("a0")) { const char *ret; objc_global_mutex_lock(); ret = objc_sparsearray_get(selector_names, (uint32_t)sel->uid); @@ -126,11 +126,11 @@ return ret; } bool -sel_isEqual(SEL sel1, SEL sel2) +sel_isEqual(SEL sel1 OBJC_M68K_REG("a0"), SEL sel2 OBJC_M68K_REG("a1")) { return (sel1->uid == sel2->uid); } void