Index: src/runtime/amiga-library.m ================================================================== --- src/runtime/amiga-library.m +++ src/runtime/amiga-library.m @@ -586,10 +586,16 @@ _Unwind_Resume(void *ex) { libc._Unwind_Resume(ex); } #endif + +int * +objc_get_errno(void) +{ + return libc.get_errno(); +} #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wpedantic" static CONST_APTR functionTable[] = { #ifdef OF_MORPHOS Index: src/runtime/linklib/linklib.m ================================================================== --- src/runtime/linklib/linklib.m +++ src/runtime/linklib/linklib.m @@ -25,10 +25,11 @@ struct ObjFWRTBase; #import "inline.h" +#include #include #include #if defined(OF_AMIGAOS_M68K) # include @@ -60,10 +61,16 @@ extern void __register_frame_info(const void *, void *); extern void *__deregister_frame_info(const void *); struct Library *ObjFWRTBase; void *__objc_class_name_Protocol; + +static int * +get_errno(void) +{ + return &errno; +} static void __attribute__((__used__)) ctor(void) { static bool initialized = false; @@ -95,10 +102,11 @@ #else ._Unwind_Resume = _Unwind_Resume, #endif .__register_frame_info = __register_frame_info, .__deregister_frame_info = __deregister_frame_info, + .get_errno = get_errno, }; if (initialized) return; Index: src/runtime/private.h ================================================================== --- src/runtime/private.h +++ src/runtime/private.h @@ -249,10 +249,11 @@ void (*_Nonnull _Unwind_Resume)(void *_Nonnull); # endif void (*_Nonnull __register_frame_info)(const void *_Nonnull, void *_Nonnull); void *(*_Nonnull __deregister_frame_info)(const void *_Nonnull); + int *_Nonnull (*_Nonnull get_errno)(void); }; #endif #ifdef OBJC_COMPILING_AMIGA_LIBRARY # if defined(__MORPHOS__) @@ -263,11 +264,14 @@ register type reg_##name __asm__(#reg); \ type name = reg_##name; # endif # undef stdout # undef stderr -extern FILE *stdout, *stderr; +# undef errno +extern FILE *_Nonnull stdout, *_Nonnull stderr; +extern int *_Nonnull objc_get_errno(void); +# define errno (*objc_get_errno()) #endif extern void objc_register_all_categories(struct objc_symtab *_Nonnull); extern struct objc_category *_Nullable *_Nullable objc_categories_for_class(Class _Nonnull);