@@ -31,11 +31,16 @@ #include "unistd_wrapper.h" #include "platform.h" #ifdef OF_AMIGAOS -# define __USE_INLINE__ +# ifdef OF_AMIGAOS4 +# define __USE_INLINE__ +# define __NOLIBBASE__ +# define __NOGLOBALIFACE__ +# endif +# include # include #endif #ifdef OF_WII # define nanosleep ogc_nanosleep @@ -85,10 +90,25 @@ #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(IDOS); + + if (DOSBase != NULL) + CloseLibrary(DOSBase); +} +#endif #if defined(OF_HAVE_THREADS) # import "threading.h" static of_tlskey_t threadSelfKey; @@ -186,10 +206,25 @@ 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 {