Index: src/OFApplication.m ================================================================== --- src/OFApplication.m +++ src/OFApplication.m @@ -33,11 +33,11 @@ #import "OFRunLoop.h" #import "OFRunLoop+Private.h" #import "OFThread.h" #import "OFThread+Private.h" #import "OFSandbox.h" -#if defined(OF_MORPHOS) && !defined(OF_IXEMUL) +#ifdef OF_MORPHOS # import "OFFile.h" # import "OFFileManager.h" #endif #import "OFOutOfMemoryException.h" @@ -49,11 +49,11 @@ #elif defined(OF_WINDOWS) # include extern int _CRT_glob; extern void __wgetmainargs(int *, wchar_t ***, wchar_t ***, int, int *); -#elif defined(OF_MORPHOS) && !defined(OF_IXEMUL) +#elif defined(OF_MORPHOS) # define BOOL EXEC_BOOL # include # include # undef BOOL #elif !defined(OF_IOS) @@ -265,11 +265,11 @@ objc_autoreleasePoolPop(pool); } FreeEnvironmentStringsW(env0); -#elif defined(OF_MORPHOS) && !defined(OF_IXEMUL) +#elif defined(OF_MORPHOS) void *pool = objc_autoreleasePoolPush(); OFFileManager *fileManager = [OFFileManager defaultManager]; OFArray *envContents = [fileManager contentsOfDirectoryAtPath: @"ENV:"]; const of_string_encoding_t encoding = [OFLocalization encoding]; Index: src/OFFile.h ================================================================== --- src/OFFile.h +++ src/OFFile.h @@ -14,11 +14,11 @@ * file. */ #import "OFSeekableStream.h" -#if !defined(OF_MORPHOS) || defined(OF_IXEMUL) +#ifndef OF_MORPHOS # define OF_FILE_HANDLE_IS_FD # define OF_INVALID_FILE_HANDLE (-1) # define OF_FILE_HANDLE_IS_VALID(h) (h != -1) typedef int of_file_handle_t; #else Index: src/OFFile.m ================================================================== --- src/OFFile.m +++ src/OFFile.m @@ -67,11 +67,11 @@ #endif #ifndef O_EXLOCK # define O_EXLOCK 0 #endif -#if !defined(OF_MORPHOS) || defined(OF_IXEMUL) +#ifndef OF_MORPHOS # define closeHandle(h) close(h) #else static OFDataArray *openHandles = nil; static void @@ -98,11 +98,11 @@ for (size_t i = 0; i < count; i++) Close(handles[i]); } #endif -#if !defined(OF_MORPHOS) || defined(OF_IXEMUL) +#ifndef OF_MORPHOS static int parseMode(const char *mode) { if (strcmp(mode, "r") == 0) return O_RDONLY; @@ -190,11 +190,11 @@ + (void)initialize { if (self != [OFFile class]) return; -#if defined(OF_MORPHOS) && !defined(OF_IXEMUL) +#ifdef OF_MORPHOS openHandles = [[OFDataArray alloc] initWithItemSize: sizeof(BPTR)]; #endif #ifdef OF_WII if (!fatInitDefault()) @@ -233,11 +233,11 @@ @try { void *pool = objc_autoreleasePoolPush(); int flags; -#if !defined(OF_MORPHOS) || defined(OF_IXEMUL) +#ifndef OF_MORPHOS if ((flags = parseMode([mode UTF8String])) == -1) @throw [OFInvalidArgumentException exception]; flags |= O_CLOEXEC; @@ -329,11 +329,11 @@ if ((ret = read(_handle, buffer, (unsigned int)length)) < 0) @throw [OFReadFailedException exceptionWithObject: self requestedLength: length errNo: errno]; -#elif defined(OF_MORPHOS) && !defined(OF_IXEMUL) +#elif defined(OF_MORPHOS) if (length > LONG_MAX) @throw [OFOutOfRangeException exception]; if ((ret = Read(_handle.handle, buffer, length)) < 0) @throw [OFReadFailedException exceptionWithObject: self @@ -364,11 +364,11 @@ if (write(_handle, buffer, (int)length) != (int)length) @throw [OFWriteFailedException exceptionWithObject: self requestedLength: length errNo: errno]; -#elif defined(OF_MORPHOS) && !defined(OF_IXEMUL) +#elif defined(OF_MORPHOS) if (length > LONG_MAX) @throw [OFOutOfRangeException exception]; if (_handle.append) { if (Seek64(_handle.handle, 0, OFFSET_END) == -1) @@ -399,11 +399,11 @@ if (!OF_FILE_HANDLE_IS_VALID(_handle)) @throw [OFSeekFailedException exceptionWithStream: self offset: offset whence: whence]; -#if !defined(OF_MORPHOS) || defined(OF_IXEMUL) +#ifndef OF_MORPHOS # if defined(OF_WINDOWS) ret = _lseeki64(_handle, offset, whence); # elif defined(OF_HAVE_OFF64_T) ret = lseek64(_handle, offset, whence); # else Index: src/OFLocalization.m ================================================================== --- src/OFLocalization.m +++ src/OFLocalization.m @@ -24,20 +24,20 @@ #import "OFDictionary.h" #import "OFInvalidArgumentException.h" #import "OFInvalidEncodingException.h" -#if defined(OF_MORPHOS) && !defined(OF_IXEMUL) +#ifdef OF_MORPHOS # define BOOL EXEC_BOOL # include # include # undef BOOL #endif static OFLocalization *sharedLocalization = nil; -#if !defined(OF_MORPHOS) || defined(OF_IXEMUL) +#ifndef OF_MORPHOS static void parseLocale(char *locale, of_string_encoding_t *encoding, OFString **language, OFString **territory) { if ((locale = of_strdup(locale)) == NULL) @@ -121,11 +121,11 @@ - init { self = [super init]; @try { -#if !defined(OF_MORPHOS) || defined(OF_IXEMUL) +#ifndef OF_MORPHOS char *locale, *messagesLocale = NULL; _encoding = OF_STRING_ENCODING_UTF_8; _decimalPoint = @"."; _localizedStrings = [[OFMutableArray alloc] init]; Index: src/OFSeekableStream.h ================================================================== --- src/OFSeekableStream.h +++ src/OFSeekableStream.h @@ -33,11 +33,11 @@ #if defined(OF_WINDOWS) typedef __int64 of_offset_t; #elif defined(OF_ANDROID) typedef long long of_offset_t; -#elif defined(OF_MORPHOS) && !defined(OF_IXEMUL) +#elif defined(OF_MORPHOS) typedef signed long long of_offset_t; #elif defined(OF_HAVE_OFF64_T) typedef off64_t of_offset_t; #else typedef off_t of_offset_t; Index: src/OFStdIOStream+Private.h ================================================================== --- src/OFStdIOStream+Private.h +++ src/OFStdIOStream+Private.h @@ -17,14 +17,14 @@ #import "OFStdIOStream.h" OF_ASSUME_NONNULL_BEGIN @interface OFStdIOStream () -#if !defined(OF_MORPHOS) || defined(OF_IXEMUL) +#ifndef OF_MORPHOS - (instancetype)of_initWithFileDescriptor: (int)fd OF_METHOD_FAMILY(init); #else - (instancetype)of_initWithHandle: (BPTR)handle closable: (bool)closable OF_METHOD_FAMILY(init); #endif @end OF_ASSUME_NONNULL_END Index: src/OFStdIOStream.h ================================================================== --- src/OFStdIOStream.h +++ src/OFStdIOStream.h @@ -14,11 +14,11 @@ * file. */ #import "OFStream.h" -#if defined(OF_MORPHOS) && !defined(OF_IXEMUL) +#ifdef OF_MORPHOS # define BOOL EXEC_BOOL # include # undef BOOL #endif @@ -35,11 +35,11 @@ #ifdef OF_STDIO_STREAM_WIN32_CONSOLE_H OF_SUBCLASSING_RESTRICTED #endif @interface OFStdIOStream: OFStream { -#if !defined(OF_MORPHOS) || defined(OF_IXEMUL) +#ifndef OF_MORPHOS int _fd; #else BPTR _handle; bool _closable; #endif Index: src/OFStdIOStream.m ================================================================== --- src/OFStdIOStream.m +++ src/OFStdIOStream.m @@ -37,11 +37,11 @@ #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFWriteFailedException.h" -#if defined(OF_MORPHOS) && !defined(OF_IXEMUL) +#ifdef OF_MORPHOS # define BOOL EXEC_BOOL # include # undef BOOL #endif @@ -56,11 +56,11 @@ OFStdIOStream *of_stdin = nil; OFStdIOStream *of_stdout = nil; OFStdIOStream *of_stderr = nil; -#if defined(OF_MORPHOS) && !defined(OF_IXEMUL) +#ifdef OF_MORPHOS OF_DESTRUCTOR() { [of_stdin dealloc]; [of_stdout dealloc]; [of_stderr dealloc]; @@ -92,11 +92,11 @@ @implementation OFStdIOStream #ifndef OF_WINDOWS + (void)load { -# if !defined(OF_MORPHOS) || defined(OF_IXEMUL) +# ifndef OF_MORPHOS of_stdin = [[OFStdIOStream alloc] of_initWithFileDescriptor: 0]; of_stdout = [[OFStdIOStream alloc] of_initWithFileDescriptor: 1]; of_stderr = [[OFStdIOStream alloc] of_initWithFileDescriptor: 2]; # else BPTR input = Input(), output = Output(); @@ -132,11 +132,11 @@ - init { OF_INVALID_INIT_METHOD } -#if !defined(OF_MORPHOS) || defined(OF_IXEMUL) +#ifndef OF_MORPHOS - (instancetype)of_initWithFileDescriptor: (int)fd { self = [super init]; _fd = fd; @@ -163,11 +163,11 @@ [super dealloc]; } - (bool)lowlevelIsAtEndOfStream { -#if !defined(OF_MORPHOS) || defined(OF_IXEMUL) +#ifndef OF_MORPHOS if (_fd == -1) return true; #else if (_handle == 0) return true; @@ -179,11 +179,11 @@ - (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)length { ssize_t ret; -#if !defined(OF_MORPHOS) || defined(OF_IXEMUL) +#ifndef OF_MORPHOS if (_fd == -1 || _atEndOfStream) @throw [OFReadFailedException exceptionWithObject: self requestedLength: length]; # ifndef OF_WINDOWS @@ -220,11 +220,11 @@ } - (void)lowlevelWriteBuffer: (const void *)buffer length: (size_t)length { -#if !defined(OF_MORPHOS) || defined(OF_IXEMUL) +#ifndef OF_MORPHOS if (_fd == -1 || _atEndOfStream) @throw [OFWriteFailedException exceptionWithObject: self requestedLength: length]; # ifndef OF_WINDOWS @@ -256,11 +256,11 @@ @throw [OFWriteFailedException exceptionWithObject: self requestedLength: length]; #endif } -#if !defined(OF_WINDOWS) && (!defined(OF_MORPHOS) || defined(OF_IXEMUL)) +#if !defined(OF_WINDOWS) && !defined(OF_MORPHOS) - (int)fileDescriptorForReading { return _fd; } @@ -270,11 +270,11 @@ } #endif - (void)close { -#if !defined(OF_MORPHOS) || defined(OF_IXEMUL) +#ifndef OF_MORPHOS if (_fd != -1) close(_fd); _fd = -1; #else @@ -306,12 +306,11 @@ return OF_RETAIN_COUNT_MAX; } - (int)columns { -#if defined(HAVE_SYS_IOCTL_H) && defined(TIOCGWINSZ) && \ - (!defined(OF_MORPHOS) || defined(OF_IXEMUL)) +#if defined(HAVE_SYS_IOCTL_H) && defined(TIOCGWINSZ) && !defined(OF_MORPHOS) struct winsize ws; if (ioctl(_fd, TIOCGWINSZ, &ws) != 0) return -1; @@ -321,12 +320,11 @@ #endif } - (int)rows { -#if defined(HAVE_SYS_IOCTL_H) && defined(TIOCGWINSZ) && \ - (!defined(OF_MORPHOS) || defined(OF_IXEMUL)) +#if defined(HAVE_SYS_IOCTL_H) && defined(TIOCGWINSZ) && !defined(OF_MORPHOS) struct winsize ws; if (ioctl(_fd, TIOCGWINSZ, &ws) != 0) return -1; Index: src/OFStream.m ================================================================== --- src/OFStream.m +++ src/OFStream.m @@ -29,11 +29,11 @@ # include #endif #include "platform.h" -#if !defined(OF_WINDOWS) && (!defined(OF_MORPHOS) || defined(OF_IXEMUL)) +#if !defined(OF_WINDOWS) && !defined(OF_MORPHOS) # include #endif #import "OFStream.h" #import "OFStream+Private.h" @@ -54,11 +54,11 @@ #define MIN_READ_SIZE 512 @implementation OFStream @synthesize of_waitingForDelimiter = _waitingForDelimiter; -#if !defined(OF_WINDOWS) && (!defined(OF_MORPHOS) || defined(OF_IXEMUL)) +#if !defined(OF_WINDOWS) && !defined(OF_MORPHOS) + (void)initialize { if (self == [OFStream class]) signal(SIGPIPE, SIG_IGN); } Index: src/OFString.m ================================================================== --- src/OFString.m +++ src/OFString.m @@ -2519,11 +2519,11 @@ - (float)floatValue { void *pool = objc_autoreleasePoolPush(); -#if defined(OF_MORPHOS) && !defined(OF_IXEMUL) +#ifdef OF_MORPHOS OFString *stripped = [self stringByDeletingEnclosingWhitespaces]; if ([stripped caseInsensitiveCompare: @"INF"] == OF_ORDERED_SAME || [stripped caseInsensitiveCompare: @"INFINITY"] == OF_ORDERED_SAME) return INFINITY; @@ -2572,11 +2572,11 @@ - (double)doubleValue { void *pool = objc_autoreleasePoolPush(); -#if defined(OF_MORPHOS) && !defined(OF_IXEMUL) +#ifdef OF_MORPHOS OFString *stripped = [self stringByDeletingEnclosingWhitespaces]; if ([stripped caseInsensitiveCompare: @"INF"] == OF_ORDERED_SAME || [stripped caseInsensitiveCompare: @"INFINITY"] == OF_ORDERED_SAME) return INFINITY; Index: src/OFThread.m ================================================================== --- src/OFThread.m +++ src/OFThread.m @@ -29,11 +29,11 @@ #endif #include "unistd_wrapper.h" #include "platform.h" -#if defined(OF_MORPHOS) && !defined(OF_IXEMUL) +#ifdef OF_MORPHOS # define BOOL EXEC_BOOL # include # undef BOOL #endif @@ -193,11 +193,11 @@ if (rqtp.tv_sec != floor(timeInterval)) @throw [OFOutOfRangeException exception]; nanosleep(&rqtp, NULL); -#elif defined(OF_MORPHOS) && !defined(OF_IXEMUL) +#elif defined(OF_MORPHOS) if (timeInterval * 50 > ULONG_MAX) @throw [OFOutOfRangeException exception]; Delay(timeInterval * 50); #elif defined(OF_NINTENDO_DS) Index: src/platform.h ================================================================== --- src/platform.h +++ src/platform.h @@ -95,13 +95,15 @@ #elif defined(__ANDROID__) # define OF_ANDROID #elif defined(__HAIKU__) # define OF_HAIKU #elif defined(__MORPHOS__) -# define OF_MORPHOS -# ifdef __ixemul__ -# define OF_IXEMUL +# ifndef __ixemul__ +# define OF_MORPHOS +# define OF_AMIGAOS_LIKE +# else +# define OF_MORPHOS_IXEMUL # endif #elif defined(__sun__) # define OF_SOLARIS #elif defined(__QNX__) # define OF_QNX Index: src/socket.h ================================================================== --- src/socket.h +++ src/socket.h @@ -23,15 +23,15 @@ #include #import "platform.h" #ifdef OF_HAVE_SYS_SOCKET_H -# if defined(OF_MORPHOS) && !defined(OF_IXEMUL) +# ifdef OF_MORPHOS # define BOOL EXEC_BOOL # endif # include -# if defined(OF_MORPHOS) && !defined(OF_IXEMUL) +# ifdef OF_MORPHOS # undef BOOL # endif #endif #ifdef OF_HAVE_NETINET_IN_H # include @@ -52,15 +52,21 @@ # include # include #endif #ifdef OF_MORPHOS -# ifndef OF_IXEMUL typedef long socklen_t; -# else -typedef int socklen_t; + +struct sockaddr_storage { + uint8_t ss_len; + uint8_t ss_family; + char ss_data[2 + sizeof(struct in_addr) + 8]; +}; #endif + +#ifdef OF_MORPHOS_IXEMUL +typedef int socklen_t; struct sockaddr_storage { uint8_t ss_len; uint8_t ss_family; char ss_data[2 + sizeof(struct in_addr) + 8]; Index: src/socket_helpers.h ================================================================== --- src/socket_helpers.h +++ src/socket_helpers.h @@ -59,13 +59,15 @@ #if !defined(OF_WINDOWS) && !defined(OF_WII) # define closesocket(sock) close(sock) #endif #ifdef OF_MORPHOS -# ifndef OF_IXEMUL -# define hstrerror(err) "unknown (no hstrerror)" -# endif +# define hstrerror(err) "unknown (no hstrerror)" +typedef uint32_t in_addr_t; +#endif + +#ifdef OF_MORPHOS_IXEMUL typedef uint32_t in_addr_t; #endif #ifdef OF_WII # define accept(sock, addr, addrlen) net_accept(sock, addr, addrlen) Index: src/unistd_wrapper.h ================================================================== --- src/unistd_wrapper.h +++ src/unistd_wrapper.h @@ -17,11 +17,11 @@ #include /* Make sure we have any libc include */ #import "platform.h" -#if defined(OF_MORPHOS) && !defined(OF_IXEMUL) +#ifdef OF_MORPHOS # define BOOL EXEC_BOOL # include # undef BOOL #endif Index: utils/ofhash/OFHash.m ================================================================== --- utils/ofhash/OFHash.m +++ utils/ofhash/OFHash.m @@ -88,11 +88,11 @@ } @finally { [sandbox release]; } #endif -#if !defined(OF_MORPHOS) || defined(OF_IXEMUL) +#ifndef OF_MORPHOS [OFLocalization addLanguageDirectory: @LANGUAGE_DIR]; #else [OFLocalization addLanguageDirectory: @"PROGDIR:/share/ofhash/lang"]; #endif Index: utils/ofhttp/OFHTTP.m ================================================================== --- utils/ofhttp/OFHTTP.m +++ utils/ofhttp/OFHTTP.m @@ -268,11 +268,11 @@ } @finally { [sandbox release]; } #endif -#if !defined(OF_MORPHOS) || defined(OF_IXEMUL) +#ifndef OF_MORPHOS [OFLocalization addLanguageDirectory: @LANGUAGE_DIR]; #else [OFLocalization addLanguageDirectory: @"PROGDIR:/share/ofhttp/lang"]; #endif Index: utils/ofzip/OFZIP.m ================================================================== --- utils/ofzip/OFZIP.m +++ utils/ofzip/OFZIP.m @@ -152,11 +152,11 @@ } @finally { [sandbox release]; } #endif -#if !defined(OF_MORPHOS) || defined(OF_IXEMUL) +#ifndef OF_MORPHOS [OFLocalization addLanguageDirectory: @LANGUAGE_DIR]; #else [OFLocalization addLanguageDirectory: @"PROGDIR:/share/ofzip/lang"]; #endif