Index: src/amiga-glue.m ================================================================== --- src/amiga-glue.m +++ src/amiga-glue.m @@ -38,14 +38,13 @@ " blr\n" ); #endif bool __saveds -glue_of_init PPC_PARAMS(unsigned int version, struct of_libc *libc, - FILE *stderr_) +glue_of_init PPC_PARAMS(unsigned int version, struct of_libc *libc, FILE **sF) { M68K_ARG(unsigned int, version, d0) M68K_ARG(struct of_libc *, libc, a0) - M68K_ARG(FILE *, stderr_, a1) + M68K_ARG(FILE **, sF, a1) - return of_init(version, libc, stderr_); + return of_init(version, libc, sF); } Index: src/amiga-library.h ================================================================== --- src/amiga-library.h +++ src/amiga-library.h @@ -16,10 +16,19 @@ */ #import "macros.h" #if defined(OF_COMPILING_AMIGA_LIBRARY) || defined(OF_COMPILING_AMIGA_LINKLIB) +# if defined(__MORPHOS__) +# include +# define OF_M68K_ARG(type, name, reg) type name = (type)REG_##reg; +# else +# define OF_M68K_ARG(type, name, reg) \ + register type reg_##name __asm__(#reg); \ + type name = reg_##name; +# endif + struct of_libc { /* * Needed by the runtime. Some of them are also used by ObjFW, but we * need all of them to pass them along to the runtime. */ @@ -61,7 +70,7 @@ const char *_Nonnull restrict, va_list); void (*_Nonnull exit)(int); char *_Nullable (*_Nonnull setlocale)(int, const char *_Nullable); }; -extern bool of_init(unsigned int version, struct of_libc *libc_, FILE *stderr_); +extern bool of_init(unsigned int version, struct of_libc *libc, FILE **sF); #endif Index: src/amiga-library.m ================================================================== --- src/amiga-library.m +++ src/amiga-library.m @@ -75,11 +75,11 @@ #ifdef OF_MORPHOS const ULONG __abox__ = 1; #endif struct ExecBase *SysBase; struct of_libc libc; -FILE *stderr; +FILE **__sF; #if defined(OF_AMIGAOS_M68K) __asm__ ( ".text\n" ".globl ___restore_a4\n" @@ -314,11 +314,11 @@ { return NULL; } bool -of_init(unsigned int version, struct of_libc *libc_, FILE *stderr_) +of_init(unsigned int version, struct of_libc *libc_, FILE **sF) { #ifdef OF_AMIGAOS_M68K OF_M68K_ARG(struct ObjFWBase *, base, a6) #else register struct ObjFWBase *r12 __asm__("r12"); @@ -331,11 +331,11 @@ if (base->initialized) return true; memcpy(&libc, libc_, sizeof(libc)); - stderr = stderr_; + __sF = sF; #ifdef OF_AMIGAOS_M68K if ((size_t)_EH_FRAME_BEGINS__ != (size_t)_EH_FRAME_OBJECTS__) return false; Index: src/macros.h ================================================================== --- src/macros.h +++ src/macros.h @@ -307,23 +307,10 @@ # define OF_SWIFT_NAME(name) __attribute__((__swift_name__(name))) #else # define OF_SWIFT_NAME(name) #endif -#ifdef OF_COMPILING_AMIGA_LIBRARY -# if defined(__MORPHOS__) -# include -# define OF_M68K_ARG(type, name, reg) type name = (type)REG_##reg; -# else -# define OF_M68K_ARG(type, name, reg) \ - register type reg_##name __asm__(#reg); \ - type name = reg_##name; -# endif -# undef stderr -extern FILE *stderr; -#endif - #ifdef __GNUC__ # ifdef OF_X86_64 # define OF_X86_64_ASM # endif # ifdef OF_X86 Index: src/runtime/amiga-glue.m ================================================================== --- src/runtime/amiga-glue.m +++ src/runtime/amiga-glue.m @@ -27,11 +27,11 @@ #else # define PPC_PARAMS(...) (__VA_ARGS__) # define M68K_ARG(...) #endif -extern bool objc_init(unsigned int, struct objc_libc *, FILE *, FILE *); +extern bool objc_init(unsigned int, struct objc_libc *, FILE **); #ifdef OF_MORPHOS /* All __saveds functions in this file need to use the SysV ABI */ __asm__ ( ".section .text\n" @@ -42,18 +42,17 @@ ); #endif bool __saveds glue_objc_init PPC_PARAMS(unsigned int version, struct objc_libc *libc, - FILE *stdout_, FILE *stderr_) + FILE **sF) { M68K_ARG(unsigned int, version, d0) M68K_ARG(struct objc_libc *, libc, a0) - M68K_ARG(FILE *, stdout_, a1) - M68K_ARG(FILE *, stderr_, a2) + M68K_ARG(FILE **, sF, a1) - return objc_init(version, libc, stdout_, stderr_); + return objc_init(version, libc, sF); } void __saveds glue___objc_exec_class PPC_PARAMS(struct objc_module *module) { Index: src/runtime/amiga-library.m ================================================================== --- src/runtime/amiga-library.m +++ src/runtime/amiga-library.m @@ -151,11 +151,11 @@ #ifdef OF_MORPHOS const ULONG __abox__ = 1; #endif struct ExecBase *SysBase; struct objc_libc libc; -FILE *stdout, *stderr; +FILE **__sF; #if defined(OF_AMIGAOS_M68K) __asm__ ( ".text\n" ".globl ___restore_a4\n" @@ -391,12 +391,11 @@ { return NULL; } bool -objc_init(unsigned int version, struct objc_libc *libc_, FILE *stdout_, - FILE *stderr_) +objc_init(unsigned int version, struct objc_libc *libc_, FILE **sF) { #ifdef OF_AMIGAOS_M68K OBJC_M68K_ARG(struct ObjFWRTBase *, base, a6) #else register struct ObjFWRTBase *r12 __asm__("r12"); @@ -409,12 +408,11 @@ if (base->initialized) return true; memcpy(&libc, libc_, sizeof(libc)); - stdout = stdout_; - stderr = stderr_; + __sF = sF; #ifdef OF_AMIGAOS_M68K if ((size_t)_EH_FRAME_BEGINS__ != (size_t)_EH_FRAME_OBJECTS__) return false; Index: src/runtime/amigaos3.sfd ================================================================== --- src/runtime/amigaos3.sfd +++ src/runtime/amigaos3.sfd @@ -2,11 +2,11 @@ ==basetype struct Library * ==libname objfwrt68k.library ==bias 30 ==public * The following function is only for the linklib. -bool glue_objc_init(unsigned int version, struct objc_libc *libc, FILE *stdout, FILE *stderr)(d0,a0,a1,a2) +bool glue_objc_init(unsigned int version, struct objc_libc *libc, FILE **sF)(d0,a0,a1) void glue___objc_exec_class(struct objc_module *_Nonnull module)(a0) IMP _Nonnull glue_objc_msg_lookup(id _Nullable object, SEL _Nonnull selector)(a0,a1) IMP _Nonnull glue_objc_msg_lookup_stret(id _Nullable object, SEL _Nonnull selector)(a0,a1) IMP _Nonnull glue_objc_msg_lookup_super(struct objc_super *_Nonnull super, SEL _Nonnull selector)(a0,a1) IMP _Nonnull glue_objc_msg_lookup_super_stret(struct objc_super *_Nonnull super, SEL _Nonnull selector)(a0,a1) Index: src/runtime/linklib/linklib.m ================================================================== --- src/runtime/linklib/linklib.m +++ src/runtime/linklib/linklib.m @@ -106,11 +106,11 @@ OBJFWRT_LIB_MINOR)) == NULL) { fputs("Failed to open " OBJFWRT_AMIGA_LIB "!\n", stderr); abort(); } - if (!glue_objc_init(1, &libc, stdout, stderr)) { + if (!glue_objc_init(1, &libc, __sF)) { fputs("Failed to initialize " OBJFWRT_AMIGA_LIB "!\n", stderr); abort(); } initialized = true; Index: src/runtime/morphos-clib.h ================================================================== --- src/runtime/morphos-clib.h +++ src/runtime/morphos-clib.h @@ -1,7 +1,7 @@ /* The following function is only for the linklib. */ -bool glue_objc_init(unsigned int, struct objc_libc *, FILE *, FILE *); +bool glue_objc_init(unsigned int, struct objc_libc *, FILE **); void glue___objc_exec_class(struct objc_module *); IMP glue_objc_msg_lookup(id, SEL); IMP glue_objc_msg_lookup_stret(id, SEL); IMP glue_objc_msg_lookup_super(struct objc_super *, SEL); IMP glue_objc_msg_lookup_super_stret(struct objc_super *, SEL); Index: src/runtime/morphos.fd ================================================================== --- src/runtime/morphos.fd +++ src/runtime/morphos.fd @@ -1,10 +1,10 @@ ##base _ObjFWRTBase ##bias 30 ##public * The following function is only for the linklib. -glue_objc_init(version,libc,stdout,stderr)(sysv,r12base) +glue_objc_init(version,libc,sF)(sysv,r12base) glue___objc_exec_class(module)(sysv,r12base) glue_objc_msg_lookup(object,selector)(sysv,r12base) glue_objc_msg_lookup_stret(object,selector)(sysv,r12base) glue_objc_msg_lookup_super(super,selector)(sysv,r12base) glue_objc_msg_lookup_super_stret(super,selector)(sysv,r12base) Index: src/runtime/private.h ================================================================== --- src/runtime/private.h +++ src/runtime/private.h @@ -263,13 +263,10 @@ # else # define OBJC_M68K_ARG(type, name, reg) \ register type reg_##name __asm__(#reg); \ type name = reg_##name; # endif -# undef stdout -# undef stderr -extern FILE *stdout, *stderr; #endif extern void objc_register_all_categories(struct objc_symtab *_Nonnull); extern struct objc_category *_Nullable *_Nullable objc_categories_for_class(Class _Nonnull);