Index: extra.mk.in ================================================================== --- extra.mk.in +++ extra.mk.in @@ -22,13 +22,10 @@ BRIDGE = @BRIDGE@ CVINCLUDE_INLINE_H = @CVINCLUDE_INLINE_H@ ENCODINGS = @ENCODINGS@ ENCODINGS_A = @ENCODINGS_A@ ENCODINGS_AMIGALIB_A = @ENCODINGS_AMIGALIB_A@ -ENCODINGS_ENCODINGS_A = @ENCODINGS_ENCODINGS_A@ -ENCODINGS_ENCODINGS_AMIGALIB_A = @ENCODINGS_ENCODINGS_AMIGALIB_A@ -ENCODINGS_ENCODINGS_LIB_A = @ENCODINGS_ENCODINGS_LIB_A@ ENCODINGS_LIB_A = @ENCODINGS_LIB_A@ ENCODINGS_SRCS = @ENCODINGS_SRCS@ EXCEPTIONS_A = @EXCEPTIONS_A@ EXCEPTIONS_AMIGALIB_A = @EXCEPTIONS_AMIGALIB_A@ EXCEPTIONS_LIB_A = @EXCEPTIONS_LIB_A@ Index: src/amiga-library.h ================================================================== --- src/amiga-library.h +++ src/amiga-library.h @@ -65,10 +65,11 @@ void (*_Nonnull __register_frame_info)(const void *_Nonnull, void *_Nonnull); void *_Nullable (*_Nonnull __deregister_frame_info)( const void *_Nonnull); #endif + int *_Nonnull (*_Nonnull get_errno)(void); /* Needed only by ObjFW. */ int (*_Nonnull vsnprintf)(char *_Nonnull restrict, size_t, const char *_Nonnull restrict, va_list); #ifdef OF_AMIGAOS_M68K Index: src/amiga-library.m ================================================================== --- src/amiga-library.m +++ src/amiga-library.m @@ -573,10 +573,16 @@ *__deregister_frame_info(const void *begin) { return libc.__deregister_frame_info(begin); } #endif + +int * +of_get_errno(void) +{ + return libc.get_errno(); +} int vsnprintf(char *restrict str, size_t size, const char *restrict fmt, va_list args) { Index: src/linklib/linklib.m ================================================================== --- src/linklib/linklib.m +++ src/linklib/linklib.m @@ -25,10 +25,11 @@ struct ObjFWBase; #import "inline.h" +#include #include #include #include #if defined(OF_AMIGAOS_M68K) @@ -270,10 +271,16 @@ void *__objc_class_name_OFMutableMapTableSet; void *__objc_class_name_OFMutableUTF8String; void *__objc_class_name_OFRangeCharacterSet; void *__objc_class_name_OFSelectKernelEventObserver; void *__objc_class_name_OFUTF8String; + +static int * +get_errno(void) +{ + return &errno; +} static void __attribute__((__used__)) ctor(void) { static bool initialized = false; @@ -307,10 +314,11 @@ #endif #ifdef OF_AMIGAOS_M68K .__register_frame_info = __register_frame_info, .__deregister_frame_info = __deregister_frame_info, #endif + .get_errno = get_errno, .vsnprintf = vsnprintf, #ifdef OF_AMIGAOS_M68K .vsscanf = vsscanf, #endif .exit = exit, Index: src/macros.h ================================================================== --- src/macros.h +++ src/macros.h @@ -318,10 +318,16 @@ #if __has_attribute(__objc_direct_members__) && defined(OF_APPLE_RUNTIME) # define OF_DIRECT_MEMBERS __attribute__((__objc_direct_members__)) #else # define OF_DIRECT_MEMBERS #endif + +#ifdef OF_COMPILING_AMIGA_LIBRARY +# undef errno +extern int *_Nonnull of_get_errno(void); +# define errno (*of_get_errno()) +#endif #ifdef __GNUC__ # ifdef OF_X86_64 # define OF_X86_64_ASM # endif