Index: configure.ac ================================================================== --- configure.ac +++ configure.ac @@ -44,12 +44,13 @@ ;; m68k-*-amigaos*) AS_IF([test x"$OBJCFLAGS" = x""], [ OBJCFLAGS="-O0" ]) - OBJCFLAGS="$OBJCFLAGS -noixemul -D__NO_NET_API" + OBJCFLAGS="$OBJCFLAGS -noixemul" OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS -noixemul" + CPPFLAGS="$CPPFLAGS -D__NO_NET_API" LDFLAGS="$LDFLAGS -noixemul" enable_shared="no" enable_threads="no" enable_files="yes" # Required for reading ENV: @@ -66,15 +67,21 @@ AC_SUBST(AMIGA_LIB_CFLAGS, "-mcpu=68020 -fbaserel -ffreestanding") AC_SUBST(AMIGA_LIB_LDFLAGS, "-mcpu=68020 -fbaserel -resident -nostartfiles") ]) + + AC_SUBST(LIBBASES_M, libbases.m) ;; powerpc-*-amigaos*) + CPPFLAGS="$CPPFLAGS -D__USE_INLINE__" + enable_shared="no" enable_threads="no" enable_files="yes" # Required for reading ENV: + + AC_SUBST(LIBBASES_M, libbases.m) ;; *-morphos*) AS_IF([test x"$with_ixemul" != x"yes"], [ AS_IF([test x"$OBJCFLAGS" = x""], [ OBJCFLAGS="-O2 -g" @@ -93,10 +100,12 @@ AC_SUBST(AMIGA_LIB_CFLAGS, $t) t="-mresident32 -nostartfiles -nodefaultlibs" t="$t -lc" AC_SUBST(AMIGA_LIB_LDFLAGS, $t) ]) + + AC_SUBST(LIBBASES_M, libbases.m) ]) enable_shared="no" enable_threads="no" ;; Index: extra.mk.in ================================================================== --- extra.mk.in +++ extra.mk.in @@ -40,10 +40,11 @@ INSTANCE_M = @INSTANCE_M@ INVOCATION_A = @INVOCATION_A@ INVOCATION_INVOCATION_A = @INVOCATION_INVOCATION_A@ INVOCATION_INVOCATION_LIB_A = @INVOCATION_INVOCATION_LIB_A@ INVOCATION_LIB_A = @INVOCATION_LIB_A@ +LIBBASES_M = @LIBBASES_M@ LIBOBJFWRT_DEP = @LIBOBJFWRT_DEP@ LIBOBJFWRT_DEP_LVL2 = @LIBOBJFWRT_DEP_LVL2@ LIBOBJFW_DEP = @LIBOBJFW_DEP@ LIBOBJFW_DEP_LVL2 = @LIBOBJFW_DEP_LVL2@ LINKLIB = @LINKLIB@ Index: src/Makefile ================================================================== --- src/Makefile +++ src/Makefile @@ -208,11 +208,12 @@ OFRectangleValue.m \ OFSubarray.m \ OFUTF8String.m \ ${AUTORELEASE_M} \ ${FOUNDATION_COMPAT_M} \ - ${INSTANCE_M} + ${INSTANCE_M} \ + ${LIBBASES_M} SRCS_FILES += OFFileURLHandler.m \ OFINIFileSettings.m SRCS_SOCKETS += OFHTTPURLHandler.m \ OFKernelEventObserver.m \ ${OFEPOLLKERNELEVENTOBSERVER_M} \ Index: src/OFApplication.m ================================================================== --- src/OFApplication.m +++ src/OFApplication.m @@ -54,15 +54,10 @@ #elif defined(OF_WINDOWS) # include extern int _CRT_glob; extern void __wgetmainargs(int *, wchar_t ***, wchar_t ***, int, int *); #elif defined(OF_AMIGAOS) -# ifdef OF_AMIGAOS4 -# define __USE_INLINE__ -# define __NOLIBBASE__ -# define __NOGLOBALIFACE__ -# endif # include # include #elif !defined(OF_IOS) extern char **environ; #endif @@ -76,14 +71,10 @@ # define asm __asm__ # include # undef asm #endif -#ifdef OF_AMIGAOS4 -extern struct ExecIFace *IExec; -#endif - @interface OFApplication () - (instancetype)of_init OF_METHOD_FAMILY(init); - (void)of_setArgumentCount: (int *)argc andArgumentValues: (char **[])argv; #ifdef OF_WINDOWS Index: src/OFDNSResolver.m ================================================================== --- src/OFDNSResolver.m +++ src/OFDNSResolver.m @@ -54,13 +54,10 @@ # include # undef interface #endif #ifdef OF_AMIGAOS -# ifdef OF_AMIGAOS4 -# define __USE_INLINE__ -# endif # include # include #endif #ifdef OF_NINTENDO_3DS Index: src/OFFile.m ================================================================== --- src/OFFile.m +++ src/OFFile.m @@ -56,15 +56,10 @@ # include # include #endif #ifdef OF_AMIGAOS -# ifdef OF_AMIGAOS4 -# define __USE_INLINE__ -# define __NOLIBBASE__ -# define __NOGLOBALIFACE__ -# endif # include # include #endif #ifndef O_BINARY @@ -81,16 +76,10 @@ #endif #ifndef OF_AMIGAOS # define closeHandle(h) close(h) #else -# ifdef OF_AMIGAOS4 -extern struct ExecIFace *IExec; -static struct Library *DOSBase = NULL; -static struct DOSIFace *IDOS = NULL; -# endif - struct of_file_handle { of_file_handle_t previous, next; BPTR handle; bool append; } *firstHandle = NULL; @@ -114,18 +103,10 @@ OF_DESTRUCTOR() { for (of_file_handle_t iter = firstHandle; iter != NULL; iter = iter->next) Close(iter->handle); - -# ifdef OF_AMIGAOS4 - if (IDOS != NULL) - DropInterface((struct Interface *)IDOS); - - if (DOSBase != NULL) - CloseLibrary(DOSBase); -# endif } #endif #ifndef OF_AMIGAOS static int @@ -196,21 +177,10 @@ #ifdef OF_NINTENDO_DS if (!nitroFSInit(NULL)) @throw [OFInitializationFailedException exceptionWithClass: self]; #endif - -#ifdef OF_AMIGAOS4 - if ((DOSBase = OpenLibrary("dos.library", 36)) == NULL) - @throw [OFInitializationFailedException - exceptionWithClass: self]; - - if ((IDOS = (struct DOSIFace *) - GetInterface(DOSBase, "main", 1, NULL)) == NULL) - @throw [OFInitializationFailedException - exceptionWithClass: self]; -#endif } + (instancetype)fileWithPath: (OFString *)path mode: (OFString *)mode { Index: src/OFFileManager.m ================================================================== --- src/OFFileManager.m +++ src/OFFileManager.m @@ -62,18 +62,12 @@ # include # include #endif #ifdef OF_AMIGAOS -# ifdef OF_AMIGAOS4 -# define __USE_INLINE__ -# define __NOLIBBASE__ -# define __NOGLOBALIFACE__ -# endif # include # include -# include #endif @interface OFDefaultFileManager: OFFileManager @end @@ -111,13 +105,10 @@ const of_file_type_t of_file_type_block_special = @"of_file_type_block_special"; const of_file_type_t of_file_type_socket = @"of_file_type_socket"; #ifdef OF_AMIGAOS4 # define CurrentDir(lock) SetCurrentDir(lock) -extern struct ExecIFace *IExec; -static struct Library *DOSBase = NULL; -static struct DOSIFace *IDOS = NULL; #endif static OFFileManager *defaultManager; #ifdef OF_AMIGAOS @@ -126,18 +117,10 @@ OF_DESTRUCTOR() { if (dirChanged) UnLock(CurrentDir(originalDirLock)); - -# ifdef OF_AMIGAOS4 - if (IDOS != NULL) - DropInterface((struct Interface *)IDOS); - - if (DOSBase != NULL) - CloseLibrary(DOSBase); -# endif } #endif static id attributeForKeyOrException(of_file_attributes_t attributes, @@ -157,21 +140,10 @@ { if (self != [OFFileManager class]) return; #ifdef OF_HAVE_FILES -# ifdef OF_AMIGAOS4 - if ((DOSBase = OpenLibrary("dos.library", 36)) == NULL) - @throw [OFInitializationFailedException - exceptionWithClass: self]; - - if ((IDOS = (struct DOSIFace *) - GetInterface(DOSBase, "main", 1, NULL)) == NULL) - @throw [OFInitializationFailedException - exceptionWithClass: self]; -# endif - /* * Make sure OFFile is initialized. * On some systems, this is needed to initialize the file system driver. */ [OFFile class]; Index: src/OFFileURLHandler.m ================================================================== --- src/OFFileURLHandler.m +++ src/OFFileURLHandler.m @@ -68,15 +68,10 @@ # include # include #endif #ifdef OF_AMIGAOS -# ifdef OF_AMIGAOS4 -# define __USE_INLINE__ -# define __NOLIBBASE__ -# define __NOGLOBALIFACE__ -# endif # include # include # include # ifdef OF_AMIGAOS4 # define DeleteFile(path) Delete(path) @@ -112,33 +107,10 @@ static OFMutex *readdirMutex; #endif #ifdef OF_WINDOWS static WINAPI BOOLEAN (*func_CreateSymbolicLinkW)(LPCWSTR, LPCWSTR, DWORD); -#endif - -#ifdef OF_AMIGAOS4 -extern struct ExecIFace *IExec; -static struct Library *DOSBase = NULL; -static struct DOSIFace *IDOS = NULL; -static struct Library *LocaleBase = NULL; -static struct LocaleIFace *ILocale = NULL; - -OF_DESTRUCTOR() -{ - if (ILocale != NULL) - DropInterface((struct Interface *)ILocale); - - if (LocaleBase != NULL) - CloseLibrary(LocaleBase); - - if (IDOS != NULL) - DropInterface((struct Interface *)IDOS); - - if (DOSBase != NULL) - CloseLibrary(DOSBase); -} #endif #ifdef OF_WINDOWS static of_time_interval_t filetimeToTimeInterval(const FILETIME *filetime) @@ -516,30 +488,10 @@ #endif if (self != [OFFileURLHandler class]) return; -#ifdef OF_AMIGAOS4 - if ((DOSBase = OpenLibrary("dos.library", 36)) == NULL) - @throw [OFInitializationFailedException - exceptionWithClass: self]; - - if ((IDOS = (struct DOSIFace *) - GetInterface(DOSBase, "main", 1, NULL)) == NULL) - @throw [OFInitializationFailedException - exceptionWithClass: self]; - - if ((LocaleBase = OpenLibrary("locale.library", 38)) == NULL) - @throw [OFInitializationFailedException - exceptionWithClass: self]; - - if ((ILocale = (struct LocaleIFace *) - GetInterface(LocaleBase, "main", 1, NULL)) == NULL) - @throw [OFInitializationFailedException - exceptionWithClass: self]; -#endif - #if defined(OF_FILE_MANAGER_SUPPORTS_OWNER) && defined(OF_HAVE_THREADS) passwdMutex = [[OFMutex alloc] init]; #endif #if !defined(HAVE_READDIR_R) && !defined(OF_WINDOWS) && defined(OF_HAVE_THREADS) readdirMutex = [[OFMutex alloc] init]; Index: src/OFLocale.m ================================================================== --- src/OFLocale.m +++ src/OFLocale.m @@ -28,45 +28,17 @@ #import "OFInvalidArgumentException.h" #import "OFInvalidEncodingException.h" #import "OFOpenItemFailedException.h" #ifdef OF_AMIGAOS -# ifdef OF_AMIGAOS4 -# define __NOLIBBASE__ -# define __NOGLOBALIFACE__ -# define __USE_INLINE__ -# endif # include # include # include #endif static OFLocale *currentLocale = nil; -#ifdef OF_AMIGAOS4 -extern struct ExecIFace *IExec; -static struct Library *DOSBase = NULL; -static struct DOSIFace *IDOS = NULL; -static struct Library *LocaleBase = NULL; -static struct LocaleIFace *ILocale = NULL; - -OF_DESTRUCTOR() -{ - if (ILocale != NULL) - DropInterface((struct Interface *)ILocale); - - if (LocaleBase != NULL) - CloseLibrary(LocaleBase); - - if (IDOS != NULL) - DropInterface((struct Interface *)IDOS); - - if (DOSBase != NULL) - CloseLibrary(DOSBase); -} -#endif - #ifndef OF_AMIGAOS static void parseLocale(char *locale, of_string_encoding_t *encoding, OFString **language, OFString **territory) { @@ -114,36 +86,10 @@ @implementation OFLocale @synthesize language = _language, territory = _territory, encoding = _encoding; @synthesize decimalPoint = _decimalPoint; -#ifdef OF_AMIGAOS4 -+ (void)initialize -{ - if (self != [OFLocale class]) - return; - - if ((DOSBase = OpenLibrary("dos.library", 36)) == NULL) - @throw [OFInitializationFailedException - exceptionWithClass: self]; - - if ((IDOS = (struct DOSIFace *) - GetInterface(DOSBase, "main", 1, NULL)) == NULL) - @throw [OFInitializationFailedException - exceptionWithClass: self]; - - if ((LocaleBase = OpenLibrary("locale.library", 38)) == NULL) - @throw [OFInitializationFailedException - exceptionWithClass: self]; - - if ((ILocale = (struct LocaleIFace *) - GetInterface(LocaleBase, "main", 1, NULL)) == NULL) - @throw [OFInitializationFailedException - exceptionWithClass: self]; -} -#endif - + (OFLocale *)currentLocale { return currentLocale; } Index: src/OFStdIOStream.m ================================================================== --- src/OFStdIOStream.m +++ src/OFStdIOStream.m @@ -41,15 +41,10 @@ #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFWriteFailedException.h" #ifdef OF_AMIGAOS -# ifdef OF_AMIGAOS4 -# define __USE_INLINE__ -# define __NOLIBBASE__ -# define __NOGLOBALIFACE__ -# endif # include # include #endif /* References for static linking */ @@ -59,16 +54,10 @@ { [OFWin32ConsoleStdIOStream class]; } #endif -#ifdef OF_AMIGAOS4 -extern struct ExecIFace *IExec; -static struct Library *DOSBase = NULL; -static struct DOSIFace *IDOS = NULL; -#endif - OFStdIOStream *of_stdin = nil; OFStdIOStream *of_stdout = nil; OFStdIOStream *of_stderr = nil; #ifdef OF_AMIGAOS @@ -75,18 +64,10 @@ OF_DESTRUCTOR() { [of_stdin dealloc]; [of_stdout dealloc]; [of_stderr dealloc]; - -# ifdef OF_AMIGAOS4 - if (IDOS != NULL) - DropInterface((struct Interface *)IDOS); - - if (DOSBase != NULL) - CloseLibrary(DOSBase); -# endif } #endif void of_log(OFConstantString *format, ...) @@ -137,21 +118,10 @@ # else BPTR input, output, error; bool inputClosable = false, outputClosable = false, errorClosable = false; -# ifdef OF_AMIGAOS4 - if ((DOSBase = OpenLibrary("dos.library", 36)) == NULL) - @throw [OFInitializationFailedException - exceptionWithClass: self]; - - if ((IDOS = (struct DOSIFace *) - GetInterface(DOSBase, "main", 1, NULL)) == NULL) - @throw [OFInitializationFailedException - exceptionWithClass: self]; -# endif - input = Input(); output = Output(); error = ((struct Process *)FindTask(NULL))->pr_CES; if (input == 0) { Index: src/OFSystemInfo.m ================================================================== --- src/OFSystemInfo.m +++ src/OFSystemInfo.m @@ -31,13 +31,10 @@ #if defined(OF_MACOS) || defined(OF_NETBSD) # include #endif #if defined(OF_AMIGAOS4) -# define __USE_INLINE__ -# define __NOLIBBASE__ -# define __NOGLOBALIFACE__ # include # include #elif defined(OF_MORPHOS) # include # include @@ -99,14 +96,10 @@ struct x86_regs { uint32_t eax, ebx, ecx, edx; }; #endif -#ifdef OF_AMIGAOS4 -extern struct ExecIFace *IExec; -#endif - static size_t pageSize = 4096; static size_t numberOfCPUs = 1; static OFString *operatingSystemName = nil; static OFString *operatingSystemVersion = nil; Index: src/OFThread.m ================================================================== --- src/OFThread.m +++ src/OFThread.m @@ -31,15 +31,10 @@ #include "unistd_wrapper.h" #include "platform.h" #ifdef OF_AMIGAOS -# ifdef OF_AMIGAOS4 -# define __USE_INLINE__ -# define __NOLIBBASE__ -# define __NOGLOBALIFACE__ -# endif # include # include #endif #ifdef OF_WII @@ -89,25 +84,10 @@ # import "atomic.h" #endif #ifdef OF_DJGPP # define lrint(x) rint(x) -#endif - -#ifdef OF_AMIGAOS4 -extern struct ExecIFace *IExec; -static struct Library *DOSBase = NULL; -static struct DOSIFace *IDOS = NULL; - -OF_DESTRUCTOR() -{ - if (IDOS != NULL) - DropInterface((struct Interface *)IDOS); - - if (DOSBase != NULL) - CloseLibrary(DOSBase); -} #endif #if defined(OF_HAVE_THREADS) # import "tlskey.h" @@ -208,25 +188,10 @@ if (thread->_threadDictionary == nil) thread->_threadDictionary = [[OFMutableDictionary alloc] init]; return thread->_threadDictionary; } -#elif defined(OF_AMIGAOS4) -+ (void)initialize -{ - if (self != [OFThread class]) - return; - - if ((DOSBase = OpenLibrary("dos.library", 36)) == NULL) - @throw [OFInitializationFailedException - exceptionWithClass: self]; - - if ((IDOS = (struct DOSIFace *) - GetInterface(DOSBase, "main", 1, NULL)) == NULL) - @throw [OFInitializationFailedException - exceptionWithClass: self]; -} #endif #ifdef OF_HAVE_SOCKETS + (OFDNSResolver *)DNSResolver { Index: src/condition_amiga.m ================================================================== --- src/condition_amiga.m +++ src/condition_amiga.m @@ -13,25 +13,16 @@ * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ -#ifdef OF_AMIGAOS4 -# define __USE_INLINE__ -# define __NOLIBBASE__ -# define __NOGLOBALIFACE__ -#endif #include #include #ifndef OF_AMIGAOS4 # include #endif -#ifdef OF_AMIGAOS4 -extern struct ExecIFace *IExec; -#endif - bool of_condition_new(of_condition_t *condition) { condition->waitingTasks = NULL; ADDED src/libbases.m Index: src/libbases.m ================================================================== --- src/libbases.m +++ src/libbases.m @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, + * 2018, 2019 + * Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE.QPL included in + * the packaging of this file. + * + * Alternatively, it may be distributed under the terms of the GNU General + * Public License, either version 2 or 3, which can be found in the file + * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this + * file. + */ + +#include "config.h" + +#include + +#import "OFInitializationFailedException.h" + +#import "macros.h" + +#ifdef OF_AMIGAOS4 +extern struct Library *DOSBase; +extern struct DOSIFace *IDOS; +#endif +struct Library *LocaleBase; +#ifdef OF_AMIGAOS4 +struct LocaleIFace *ILocale; +#endif + +OF_CONSTRUCTOR() +{ +#ifdef OF_AMIGAOS4 + if ((DOSBase = OpenLibrary("dos.library", 36)) == NULL) + @throw [OFInitializationFailedException exception]; + + if ((IDOS = (struct DOSIFace *) + GetInterface(DOSBase, "main", 1, NULL)) == NULL) + @throw [OFInitializationFailedException exception]; +#endif + + if ((LocaleBase = OpenLibrary("locale.library", 38)) == NULL) + @throw [OFInitializationFailedException exception]; + +#ifdef OF_AMIGAOS4 + if ((ILocale = (struct LocaleIFace *) + GetInterface(LocaleBase, "main", 1, NULL)) == NULL) + @throw [OFInitializationFailedException exception]; +#endif +} + +OF_DESTRUCTOR() +{ +#ifdef OF_AMIGAOS4 + if (ILocale != NULL) + DropInterface((struct Interface *)ILocale); +#endif + + if (LocaleBase != NULL) + CloseLibrary(LocaleBase); + +#ifdef OF_AMIGAOS4 + if (DOSBase != NULL) + CloseLibrary(DOSBase); + + if (IDOS != NULL) + DropInterface((struct Interface *)IDOS); +#endif +} Index: src/mutex_amiga.m ================================================================== --- src/mutex_amiga.m +++ src/mutex_amiga.m @@ -13,21 +13,12 @@ * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ -#ifdef OF_AMIGAOS4 -# define __USE_INLINE__ -# define __NOLIBBASE__ -# define __NOGLOBALIFACE__ -#endif #include -#ifdef OF_AMIGAOS4 -extern struct ExecIFace *IExec; -#endif - bool of_mutex_new(of_mutex_t *mutex) { InitSemaphore(mutex); Index: src/socket_helpers.h ================================================================== --- src/socket_helpers.h +++ src/socket_helpers.h @@ -47,13 +47,10 @@ #ifndef SOCK_CLOEXEC # define SOCK_CLOEXEC 0 #endif #if defined(OF_AMIGAOS) -# ifdef OF_AMIGAOS4 -# define __USE_INLINE__ -# endif # include # include # define closesocket(sock) CloseSocket(sock) # define ioctlsocket(fd, req, arg) IoctlSocket(fd, req, arg) # define hstrerror(err) "unknown (no hstrerror)" Index: src/thread_amiga.m ================================================================== --- src/thread_amiga.m +++ src/thread_amiga.m @@ -13,15 +13,10 @@ * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ -#ifdef OF_AMIGAOS4 -# define __USE_INLINE__ -# define __NOLIBBASE__ -# define __NOGLOBALIFACE__ -#endif #include #include #include #import "OFData.h" @@ -28,33 +23,10 @@ #import "tlskey.h" extern void of_tlskey_thread_exited(void); static of_tlskey_t threadKey; -#ifdef OF_AMIGAOS4 -extern struct ExecIFace *IExec; -static struct Library *DOSBase = NULL; -static struct DOSIFace *IDOS = NULL; - -OF_CONSTRUCTOR() -{ - DOSBase = OpenLibrary("dos.library", 36); - OF_ENSURE(DOSBase != NULL); - - IDOS = (struct DOSIFace *)GetInterface(DOSBase, "main", 1, NULL); - OF_ENSURE(IDOS != NULL); -} - -OF_DESTRUCTOR() -{ - if (IDOS != NULL) - DropInterface((struct Interface *)IDOS); - - if (DOSBase != NULL) - CloseLibrary(DOSBase); -} -#endif OF_CONSTRUCTOR() { OF_ENSURE(of_tlskey_new(&threadKey)); } Index: src/tlskey.m ================================================================== --- src/tlskey.m +++ src/tlskey.m @@ -18,24 +18,16 @@ #include "config.h" #import "tlskey.h" #ifdef OF_AMIGAOS -# ifdef OF_AMIGAOS4 -# define __USE_INLINE__ -# define __NOLIBBASE__ -# define __NOGLOBALIFACE__ -# endif # include # include # import "OFMapTable.h" # import "OFList.h" -# ifdef OF_AMIGAOS4 -extern struct ExecIFace *IExec; -# endif static const of_map_table_functions_t functions = { NULL }; static OFList *allKeys = nil; static struct SignalSemaphore semaphore; OF_CONSTRUCTOR()