Index: ObjFW.xcodeproj/project.pbxproj ================================================================== --- ObjFW.xcodeproj/project.pbxproj +++ ObjFW.xcodeproj/project.pbxproj @@ -460,10 +460,11 @@ 4BF33B12133807A20059CEF7 /* TestsAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B6EF6811235358D0076B512 /* TestsAppDelegate.m */; }; 4BF33B4713380CE20059CEF7 /* testfile.txt in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4BF33B4313380CD40059CEF7 /* testfile.txt */; }; 4BF33B4813380D2D0059CEF7 /* testfile.bin in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4BF33B4213380CD40059CEF7 /* testfile.bin */; }; 4BF48CE118A95F83000E8D04 /* OFBigDataArray.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BF48CDF18A95F83000E8D04 /* OFBigDataArray.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4BF48CE218A95F83000E8D04 /* OFBigDataArray.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BF48CE018A95F83000E8D04 /* OFBigDataArray.m */; }; + 4BF69CE61BD44F8B00DFFC1B /* platform.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BF69CE51BD44F8B00DFFC1B /* platform.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4BFF3714177E17C100192782 /* OFRemoveItemFailedException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BFF3710177E17C100192782 /* OFRemoveItemFailedException.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4BFF3715177E17C100192782 /* OFRemoveItemFailedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BFF3711177E17C100192782 /* OFRemoveItemFailedException.m */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -983,10 +984,11 @@ 4BF33AF0133807310059CEF7 /* Tests */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = Tests; sourceTree = BUILT_PRODUCTS_DIR; }; 4BF33B4213380CD40059CEF7 /* testfile.bin */ = {isa = PBXFileReference; lastKnownFileType = archive.macbinary; name = testfile.bin; path = tests/testfile.bin; sourceTree = ""; }; 4BF33B4313380CD40059CEF7 /* testfile.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = testfile.txt; path = tests/testfile.txt; sourceTree = ""; }; 4BF48CDF18A95F83000E8D04 /* OFBigDataArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFBigDataArray.h; path = src/OFBigDataArray.h; sourceTree = ""; }; 4BF48CE018A95F83000E8D04 /* OFBigDataArray.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFBigDataArray.m; path = src/OFBigDataArray.m; sourceTree = ""; }; + 4BF69CE51BD44F8B00DFFC1B /* platform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = platform.h; path = src/platform.h; sourceTree = ""; }; 4BFBDD1610A0724800051AFB /* unicode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = unicode.m; path = src/unicode.m; sourceTree = ""; }; 4BFF3710177E17C100192782 /* OFRemoveItemFailedException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFRemoveItemFailedException.h; path = src/exceptions/OFRemoveItemFailedException.h; sourceTree = ""; }; 4BFF3711177E17C100192782 /* OFRemoveItemFailedException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFRemoveItemFailedException.m; path = src/exceptions/OFRemoveItemFailedException.m; sourceTree = ""; }; /* End PBXFileReference section */ @@ -1494,10 +1496,11 @@ 4BF1BCBF11C9663F0025511F /* objfw-defs.h.in */, 4BB50DCF12F863C700C9393F /* of_asprintf.h */, 4BB50DD012F863C700C9393F /* of_asprintf.m */, 4BA355BC14879BF700442EF4 /* of_strptime.h */, 4BA355B914879BDD00442EF4 /* of_strptime.m */, + 4BF69CE51BD44F8B00DFFC1B /* platform.h */, 4B7769EB1895C07D00D12284 /* resolver.h */, 4B7769EC1895C07D00D12284 /* resolver.m */, 4B7DD58718943D4A00990FD6 /* socket.h */, 4B40EC1A189FE2650031E19E /* socket.m */, 4B7DD58118942FE200990FD6 /* socket_helpers.h */, @@ -1729,10 +1732,11 @@ 4B837D7A16829C5F007A3E83 /* instance.h in Headers */, 4B3D23E81337FCB000DD29B8 /* macros.h in Headers */, 4BD98C03133814220048DD5B /* objfw-defs.h in Headers */, 4B3D23E91337FCB000DD29B8 /* of_asprintf.h in Headers */, 4BA355BD14879BF700442EF4 /* of_strptime.h in Headers */, + 4BF69CE61BD44F8B00DFFC1B /* platform.h in Headers */, 4B7769ED1895C07D00D12284 /* resolver.h in Headers */, 4B7DD58818943D4A00990FD6 /* socket.h in Headers */, 4B3D23EA1337FCB000DD29B8 /* threading.h in Headers */, 4B3D23EB1337FCB000DD29B8 /* unicode.h in Headers */, 4B90B79E133AD87D00BD33CB /* OFAcceptFailedException.h in Headers */, Index: configure.ac ================================================================== --- configure.ac +++ configure.ac @@ -1004,16 +1004,10 @@ AC_SUBST(OBJFW_BRIDGE_STATIC_LIB, "libobjfw-bridge.a") ]) ]) ]) -case "$host" in - arm*-apple-darwin*) - AC_DEFINE(OF_IOS, 1, [Whether we compile for iOS]) - ;; -esac - AS_IF([test x"$GOBJC" = x"yes"], [ OBJCFLAGS="$OBJCFLAGS -Wwrite-strings -Wpointer-arith -Werror" AC_MSG_CHECKING(whether we have GCC bug objc/27438) AC_TRY_COMPILE([ Index: src/Makefile ================================================================== --- src/Makefile +++ src/Makefile @@ -119,11 +119,12 @@ autorelease.h \ ${ATOMIC_H} \ block.h \ instance.h \ macros.h \ - objfw-defs.h + objfw-defs.h \ + platform.h SRCS += OFArray_adjacent.m \ OFArray_adjacentSubarray.m \ OFCountedSet_hashtable.m \ OFDictionary_hashtable.m \ Index: src/OFApplication.h ================================================================== --- src/OFApplication.h +++ src/OFApplication.h @@ -61,11 +61,11 @@ * signal-safe operations like setting a variable or calling a * signal-safe function! */ - (void)applicationDidReceiveSIGINT; -#ifndef _WIN32 +#ifndef OF_WINDOWS /*! * @brief A method which is called when the application received a SIGHUP. * * This signal is not available on Windows. * @@ -121,11 +121,11 @@ int *_argc; char ***_argv; @public id _delegate; void (*_SIGINTHandler)(id, SEL); -#ifndef _WIN32 +#ifndef OF_WINDOWS void (*_SIGHUPHandler)(id, SEL); void (*_SIGUSR1Handler)(id, SEL); void (*_SIGUSR2Handler)(id, SEL); #endif } Index: src/OFApplication.m ================================================================== --- src/OFApplication.m +++ src/OFApplication.m @@ -30,22 +30,22 @@ #import "OFRunLoop.h" #import "OFRunLoop+Private.h" #import "OFThread.h" #import "OFThread+Private.h" -#if defined(__MACH__) && !defined(OF_IOS) +#if defined(OF_MAC_OS_X) # include -#elif defined(_WIN32) +#elif defined(OF_WINDOWS) # include extern int _CRT_glob; extern void __wgetmainargs(int*, wchar_t***, wchar_t***, int, int*); #elif !defined(OF_IOS) extern char **environ; #endif -#ifdef _PSP +#ifdef OF_PSP # include # include #endif #ifdef OF_NINTENDO_DS @@ -55,11 +55,11 @@ #endif @interface OFApplication (OF_PRIVATE_CATEGORY) - (void)OF_setArgumentCount: (int*)argc andArgumentValues: (char**[])argv; -#ifdef _WIN32 +#ifdef OF_WINDOWS - (void)OF_setArgumentCount: (int)argc andWideArgumentValues: (wchar_t*[])argv; #endif - (void)OF_run; @end @@ -83,11 +83,11 @@ { \ app->_##sig##Handler(app->_delegate, \ @selector(applicationDidReceive##sig)); \ } SIGNAL_HANDLER(SIGINT) -#ifndef _WIN32 +#ifndef OF_WINDOWS SIGNAL_HANDLER(SIGHUP) SIGNAL_HANDLER(SIGUSR1) SIGNAL_HANDLER(SIGUSR2) #endif #undef SIGNAL_HANDLER @@ -94,11 +94,11 @@ int of_application_main(int *argc, char **argv[], Class cls) { id delegate; -#ifdef _WIN32 +#ifdef OF_WINDOWS wchar_t **wargv, **wenvp; int wargc, si = 0; #endif if ([cls isSubclassOfClass: [OFApplication class]]) { @@ -114,11 +114,11 @@ app = [[OFApplication alloc] init]; [app OF_setArgumentCount: argc andArgumentValues: argv]; -#ifdef _WIN32 +#ifdef OF_WINDOWS __wgetmainargs(&wargc, &wargv, &wenvp, _CRT_glob, &si); [app OF_setArgumentCount: wargc andWideArgumentValues: wargv]; #endif @@ -158,11 +158,11 @@ exit(0); } + (void)terminateWithStatus: (int)status { -#ifdef _PSP +#ifdef OF_PSP sceKernelExitGame(); abort(); /* sceKernelExitGame() is not marked noreturn */ #else exit(status); #endif @@ -173,13 +173,13 @@ self = [super init]; @try { void *pool; OFMutableDictionary *environment; -#if defined(__MACH__) && !defined(OF_IOS) +#if defined(OF_MAC_OS_X) char **env = *_NSGetEnviron(); -#elif defined(_WIN32) +#elif defined(OF_WINDOWS) of_char16_t *env, *env0; #elif !defined(OF_IOS) char **env = environ; #else char *env; @@ -186,11 +186,11 @@ #endif environment = [[OFMutableDictionary alloc] init]; atexit(atexitHandler); -#if defined(_WIN32) +#if defined(OF_WINDOWS) env = env0 = GetEnvironmentStringsW(); while (*env != 0) { OFString *tmp, *key, *value; size_t length, pos; @@ -327,11 +327,11 @@ } - (void)OF_setArgumentCount: (int*)argc andArgumentValues: (char***)argv { -#ifndef _WIN32 +#ifndef OF_WINDOWS void *pool = objc_autoreleasePoolPush(); OFMutableArray *arguments; int i; of_string_encoding_t encoding; @@ -364,11 +364,11 @@ _argc = argc; _argv = argv; #endif } -#ifdef _WIN32 +#ifdef OF_WINDOWS - (void)OF_setArgumentCount: (int)argc andWideArgumentValues: (wchar_t**)argv { void *pool = objc_autoreleasePoolPush(); OFMutableArray *arguments; @@ -429,11 +429,11 @@ @selector(applicationDidReceive##sig)]; \ signal(sig, handle##sig); \ } else \ signal(sig, SIG_DFL); REGISTER_SIGNAL(SIGINT) -#ifndef _WIN32 +#ifndef OF_WINDOWS REGISTER_SIGNAL(SIGHUP) REGISTER_SIGNAL(SIGUSR1) REGISTER_SIGNAL(SIGUSR2) #endif #undef REGISTER_SIGNAL Index: src/OFBlock.m ================================================================== --- src/OFBlock.m +++ src/OFBlock.m @@ -141,11 +141,11 @@ }; struct class _NSConcreteStackBlock; struct class _NSConcreteGlobalBlock; struct class _NSConcreteMallocBlock; -# if defined(__OBJC2__) && !defined(__ppc64__) +# if defined(__OBJC2__) && !defined(OF_POWERPC64) struct class _NSConcreteStackBlock_metaclass; struct class _NSConcreteGlobalBlock_metaclass; struct class _NSConcreteMallocBlock_metaclass; # endif #endif @@ -319,11 +319,11 @@ #endif #ifdef OF_APPLE_RUNTIME Class tmp; -# if defined(__OBJC2__) && !defined(__ppc64__) +# if defined(__OBJC2__) && !defined(OF_POWERPC64) tmp = objc_initializeClassPair(self, "OFStackBlock", (Class)&_NSConcreteStackBlock, (Class)&_NSConcreteStackBlock_metaclass); if (tmp == Nil) @throw [OFInitializationFailedException Index: src/OFFile.h ================================================================== --- src/OFFile.h +++ src/OFFile.h @@ -26,11 +26,11 @@ #import "OFSeekableStream.h" OF_ASSUME_NONNULL_BEGIN -#if defined(_WIN32) +#if defined(OF_WINDOWS) typedef struct __stat64 of_stat_t; #elif defined(OF_HAVE_OFF64_T) typedef struct stat64 of_stat_t; #else typedef struct stat of_stat_t; Index: src/OFFile.m ================================================================== --- src/OFFile.m +++ src/OFFile.m @@ -19,11 +19,13 @@ #include #include #include -#ifdef __wii__ +#include "platform.h" + +#ifdef OF_WII # define BOOL OGC_BOOL # include # undef BOOL #endif @@ -42,11 +44,11 @@ #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFSeekFailedException.h" #import "OFWriteFailedException.h" -#ifdef _WIN32 +#ifdef OF_WINDOWS # include #endif #ifndef O_BINARY # define O_BINARY 0 @@ -114,11 +116,11 @@ + (void)initialize { if (self != [OFFile class]) return; -#ifdef __wii__ +#ifdef OF_WII if (!fatInitDefault()) @throw [OFInitializationFailedException exceptionWithClass: self]; #endif @@ -158,11 +160,11 @@ if ((flags = parseMode([mode UTF8String])) == -1) @throw [OFInvalidArgumentException exception]; flags |= O_CLOEXEC; -#if defined(_WIN32) +#if defined(OF_WINDOWS) if ((_fd = _wopen([path UTF16String], flags, DEFAULT_MODE)) == -1) #elif defined(OF_HAVE_OFF64_T) if ((_fd = open64([path cStringWithEncoding: [OFSystemInfo native8BitEncoding]], flags, DEFAULT_MODE)) == -1) @@ -206,11 +208,11 @@ if (_fd == -1 || _atEndOfStream) @throw [OFReadFailedException exceptionWithObject: self requestedLength: length]; -#ifndef _WIN32 +#ifndef OF_WINDOWS if ((ret = read(_fd, buffer, length)) < 0) @throw [OFReadFailedException exceptionWithObject: self requestedLength: length errNo: errno]; #else @@ -234,11 +236,11 @@ { if (_fd == -1 || _atEndOfStream) @throw [OFWriteFailedException exceptionWithObject: self requestedLength: length]; -#ifndef _WIN32 +#ifndef OF_WINDOWS if (length > SSIZE_MAX) @throw [OFOutOfRangeException exception]; if (write(_fd, buffer, length) != (ssize_t)length) @throw [OFWriteFailedException exceptionWithObject: self @@ -256,11 +258,11 @@ } - (of_offset_t)lowlevelSeekToOffset: (of_offset_t)offset whence: (int)whence { -#if defined(_WIN32) +#if defined(OF_WINDOWS) of_offset_t ret = _lseeki64(_fd, offset, whence); #elif defined(OF_HAVE_OFF64_T) of_offset_t ret = lseek64(_fd, offset, whence); #else of_offset_t ret = lseek(_fd, offset, whence); Index: src/OFFileManager.m ================================================================== --- src/OFFileManager.m +++ src/OFFileManager.m @@ -55,11 +55,11 @@ #import "OFReadFailedException.h" #import "OFRemoveItemFailedException.h" #import "OFStatItemFailedException.h" #import "OFUnlockFailedException.h" -#ifdef _WIN32 +#ifdef OF_WINDOWS # include # include #endif #ifndef S_IRGRP @@ -81,18 +81,18 @@ static OFFileManager *defaultManager; #if defined(OF_HAVE_CHOWN) && defined(OF_HAVE_THREADS) static of_mutex_t chownMutex; #endif -#if !defined(HAVE_READDIR_R) && !defined(_WIN32) && defined(OF_HAVE_THREADS) +#if !defined(HAVE_READDIR_R) && !defined(OF_WINDOWS) && defined(OF_HAVE_THREADS) static of_mutex_t readdirMutex; #endif int of_stat(OFString *path, of_stat_t *buffer) { -#if defined(_WIN32) +#if defined(OF_WINDOWS) return _wstat64([path UTF16String], buffer); #elif defined(OF_HAVE_OFF64_T) return stat64([path cStringWithEncoding: [OFSystemInfo native8BitEncoding]], buffer); #else @@ -102,11 +102,11 @@ } int of_lstat(OFString *path, of_stat_t *buffer) { -#if defined(_WIN32) +#if defined(OF_WINDOWS) return _wstat64([path UTF16String], buffer); #elif defined(HAVE_LSTAT) # ifdef OF_HAVE_OFF64_T return lstat64([path cStringWithEncoding: [OFSystemInfo native8BitEncoding]], buffer); @@ -141,11 +141,11 @@ if (!of_mutex_new(&chownMutex)) @throw [OFInitializationFailedException exceptionWithClass: self]; #endif -#if !defined(HAVE_READDIR_R) && !defined(_WIN32) && defined(OF_HAVE_THREADS) +#if !defined(HAVE_READDIR_R) && !defined(OF_WINDOWS) && defined(OF_HAVE_THREADS) if (!of_mutex_new(&readdirMutex)) @throw [OFInitializationFailedException exceptionWithClass: self]; #endif @@ -158,18 +158,18 @@ } - (OFString*)currentDirectoryPath { OFString *ret; -#ifndef _WIN32 +#ifndef OF_WINDOWS char *buffer = getcwd(NULL, 0); #else wchar_t *buffer = _wgetcwd(NULL, 0); #endif @try { -#ifndef _WIN32 +#ifndef OF_WINDOWS ret = [OFString stringWithCString: buffer encoding: [OFSystemInfo native8BitEncoding]]; #else ret = [OFString stringWithUTF16String: buffer]; @@ -234,11 +234,11 @@ - (void)createDirectoryAtPath: (OFString*)path { if (path == nil) @throw [OFInvalidArgumentException exception]; -#ifndef _WIN32 +#ifndef OF_WINDOWS if (mkdir([path cStringWithEncoding: [OFSystemInfo native8BitEncoding]], DIR_MODE) != 0) #else if (_wmkdir([path UTF16String]) != 0) #endif @@ -291,20 +291,20 @@ } - (OFArray*)contentsOfDirectoryAtPath: (OFString*)path { OFMutableArray *files; -#ifndef _WIN32 +#ifndef OF_WINDOWS of_string_encoding_t encoding; #endif if (path == nil) @throw [OFInvalidArgumentException exception]; files = [OFMutableArray array]; -#ifndef _WIN32 +#ifndef OF_WINDOWS DIR *dir; encoding = [OFSystemInfo native8BitEncoding]; if ((dir = opendir([path cStringWithEncoding: encoding])) == NULL) @@ -416,11 +416,11 @@ - (void)changeCurrentDirectoryPath: (OFString*)path { if (path == nil) @throw [OFInvalidArgumentException exception]; -#ifndef _WIN32 +#ifndef OF_WINDOWS if (chdir([path cStringWithEncoding: [OFSystemInfo native8BitEncoding]]) != 0) #else if (_wchdir([path UTF16String]) != 0) #endif @@ -493,11 +493,11 @@ permissions: (mode_t)permissions { if (path == nil) @throw [OFInvalidArgumentException exception]; -# ifndef _WIN32 +# ifndef OF_WINDOWS if (chmod([path cStringWithEncoding: [OFSystemInfo native8BitEncoding]], permissions) != 0) # else if (_wchmod([path UTF16String], permissions) != 0) # endif @@ -720,11 +720,11 @@ - (void)moveItemAtPath: (OFString*)source toPath: (OFString*)destination { void *pool; of_stat_t s; -#ifndef _WIN32 +#ifndef OF_WINDOWS of_string_encoding_t encoding; #endif if (source == nil || destination == nil) @throw [OFInvalidArgumentException exception]; @@ -735,11 +735,11 @@ @throw [OFCopyItemFailedException exceptionWithSourcePath: source destinationPath: destination errNo: EEXIST]; -#ifndef _WIN32 +#ifndef OF_WINDOWS encoding = [OFSystemInfo native8BitEncoding]; if (rename([source cStringWithEncoding: encoding], [destination cStringWithEncoding: encoding]) != 0) { #else @@ -822,11 +822,11 @@ objc_autoreleasePoolPop(pool2); } } -#ifndef _WIN32 +#ifndef OF_WINDOWS if (remove([path cStringWithEncoding: [OFSystemInfo native8BitEncoding]]) != 0) #else if (_wremove([path UTF16String]) != 0) #endif Index: src/OFKernelEventObserver.m ================================================================== --- src/OFKernelEventObserver.m +++ src/OFKernelEventObserver.m @@ -39,14 +39,14 @@ # import "OFKernelEventObserver_kqueue.h" #endif #ifdef HAVE_EPOLL # import "OFKernelEventObserver_epoll.h" #endif -#if defined(HAVE_POLL_H) || defined(__wii__) +#if defined(HAVE_POLL_H) || defined(OF_WII) # import "OFKernelEventObserver_poll.h" #endif -#if defined(HAVE_SYS_SELECT_H) || defined(_WIN32) +#if defined(HAVE_SYS_SELECT_H) || defined(OF_WINDOWS) # import "OFKernelEventObserver_select.h" #endif #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" @@ -84,13 +84,13 @@ if (self == [OFKernelEventObserver class]) #if defined(HAVE_KQUEUE) return [OFKernelEventObserver_kqueue alloc]; #elif defined(HAVE_EPOLL) return [OFKernelEventObserver_epoll alloc]; -#elif defined(HAVE_POLL_H) || defined(__wii__) +#elif defined(HAVE_POLL_H) || defined(OF_WII) return [OFKernelEventObserver_poll alloc]; -#elif defined(HAVE_SYS_SELECT_H) || defined(_WIN32) +#elif defined(HAVE_SYS_SELECT_H) || defined(OF_WINDOWS) return [OFKernelEventObserver_select alloc]; #else # error No kqueue / epoll / poll / select found! #endif @@ -100,11 +100,11 @@ - init { self = [super init]; @try { -#if !defined(OF_HAVE_PIPE) && !defined(__wii__) +#if !defined(OF_HAVE_PIPE) && !defined(OF_WII) socklen_t cancelAddrLen; #endif _readObjects = [[OFMutableArray alloc] init]; _writeObjects = [[OFMutableArray alloc] init]; @@ -125,11 +125,11 @@ _cancelAddr.sin_family = AF_INET; _cancelAddr.sin_port = 0; _cancelAddr.sin_addr.s_addr = inet_addr("127.0.0.1"); -# ifdef __wii__ +# ifdef OF_WII _cancelAddr.sin_len = 8; /* The Wii does not accept port 0 as "choose any free port" */ _cancelAddr.sin_port = of_socket_port_find(SOCK_DGRAM); # endif @@ -136,11 +136,11 @@ if (bind(_cancelFD[0], (struct sockaddr*)&_cancelAddr, sizeof(_cancelAddr))) @throw [OFInitializationFailedException exceptionWithClass: [self class]]; -# ifndef __wii__ +# ifndef OF_WII cancelAddrLen = sizeof(_cancelAddr); if (of_getsockname(_cancelFD[0], (struct sockaddr*)&_cancelAddr, &cancelAddrLen) != 0) @throw [OFInitializationFailedException exceptionWithClass: [self class]]; @@ -162,11 +162,11 @@ { close(_cancelFD[0]); if (_cancelFD[1] != _cancelFD[0]) close(_cancelFD[1]); -#ifdef __wii__ +#ifdef OF_WII of_socket_port_free(_cancelAddr.sin_port, SOCK_DGRAM); #endif [_readObjects release]; [_writeObjects release]; @@ -358,11 +358,11 @@ - (void)cancel { #ifdef OF_HAVE_PIPE OF_ENSURE(write(_cancelFD[1], "", 1) > 0); #else -# ifndef __wii__ +# ifndef OF_WII OF_ENSURE(sendto(_cancelFD[1], "", 1, 0, (struct sockaddr*)&_cancelAddr, sizeof(_cancelAddr)) > 0); # else OF_ENSURE(sendto(_cancelFD[1], "", 1, 0, (struct sockaddr*)&_cancelAddr, 8) > 0); Index: src/OFKernelEventObserver_kqueue.m ================================================================== --- src/OFKernelEventObserver_kqueue.m +++ src/OFKernelEventObserver_kqueue.m @@ -95,11 +95,11 @@ memset(&event, 0, sizeof(event)); event.ident = [object fileDescriptorForReading]; event.filter = EVFILT_READ; event.flags = EV_ADD; -#ifndef __NetBSD__ +#ifndef OF_NETBSD event.udata = object; #else event.udata = (intptr_t)object; #endif @@ -115,11 +115,11 @@ memset(&event, 0, sizeof(event)); event.ident = [object fileDescriptorForWriting]; event.filter = EVFILT_WRITE; event.flags = EV_ADD; -#ifndef __NetBSD__ +#ifndef OF_NETBSD event.udata = object; #else event.udata = (intptr_t)object; #endif Index: src/OFKernelEventObserver_poll.m ================================================================== --- src/OFKernelEventObserver_poll.m +++ src/OFKernelEventObserver_poll.m @@ -33,11 +33,11 @@ #import "OFObserveFailedException.h" #import "OFOutOfRangeException.h" #import "socket_helpers.h" -#ifdef __wii__ +#ifdef OF_WII # define pollfd pollsd # define fd socket #endif @implementation OFKernelEventObserver_poll Index: src/OFKernelEventObserver_select.h ================================================================== --- src/OFKernelEventObserver_select.h +++ src/OFKernelEventObserver_select.h @@ -11,10 +11,12 @@ * 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 "objfw-defs.h" #ifndef __STDC_LIMIT_MACROS # define __STDC_LIMIT_MACROS #endif #ifndef __STDC_CONSTANT_MACROS Index: src/OFKernelEventObserver_select.m ================================================================== --- src/OFKernelEventObserver_select.m +++ src/OFKernelEventObserver_select.m @@ -16,11 +16,13 @@ #define __NO_EXT_QNX #include "config.h" -#ifdef _WIN32 +#include "platform.h" + +#ifdef OF_WINDOWS /* Win32 has a ridiculous default of 64, even though it supports much more. */ # define FD_SETSIZE 1024 #endif #include @@ -43,11 +45,11 @@ @implementation OFKernelEventObserver_select - init { self = [super init]; -#ifndef _WIN32 +#ifndef OF_WINDOWS if (_cancelFD[0] >= FD_SETSIZE) @throw [OFInitializationFailedException exception]; #endif FD_ZERO(&_readFDs); @@ -67,11 +69,11 @@ int fd = [object fileDescriptorForReading]; if (fd < 0 || fd > INT_MAX - 1) @throw [OFOutOfRangeException exception]; -#ifndef _WIN32 +#ifndef OF_WINDOWS if (fd >= FD_SETSIZE) @throw [OFOutOfRangeException exception]; #endif if (fd > _maxFD) @@ -85,11 +87,11 @@ int fd = [object fileDescriptorForWriting]; if (fd < 0 || fd > INT_MAX - 1) @throw [OFOutOfRangeException exception]; -#ifndef _WIN32 +#ifndef OF_WINDOWS if (fd >= FD_SETSIZE) @throw [OFOutOfRangeException exception]; #endif if (fd > _maxFD) @@ -105,11 +107,11 @@ int fd = [object fileDescriptorForReading]; if (fd < 0) @throw [OFOutOfRangeException exception]; -#ifndef _WIN32 +#ifndef OF_WINDOWS if (fd >= FD_SETSIZE) @throw [OFOutOfRangeException exception]; #endif FD_CLR(fd, &_readFDs); @@ -122,11 +124,11 @@ int fd = [object fileDescriptorForWriting]; if (fd < 0) @throw [OFOutOfRangeException exception]; -#ifndef _WIN32 +#ifndef OF_WINDOWS if (fd >= FD_SETSIZE) @throw [OFOutOfRangeException exception]; #endif FD_CLR(fd, &_writeFDs); @@ -159,11 +161,11 @@ * We cast to int before assigning to tv_usec in order to avoid a * warning with Apple GCC on PPC. POSIX defines this as suseconds_t, * however, this is not available on Win32. As an int should always * satisfy the required range, we just cast to int. */ -#ifndef _WIN32 +#ifndef OF_WINDOWS timeout.tv_sec = (time_t)timeInterval; #else timeout.tv_sec = (long)timeInterval; #endif timeout.tv_usec = (int)lrint((timeInterval - timeout.tv_sec) * 1000); Index: src/OFObject.h ================================================================== --- src/OFObject.h +++ src/OFObject.h @@ -12,11 +12,11 @@ * 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. */ -#import "objfw-defs.h" +#include "objfw-defs.h" #ifndef __STDC_LIMIT_MACROS # define __STDC_LIMIT_MACROS #endif #ifndef __STDC_CONSTANT_MACROS Index: src/OFObject.m ================================================================== --- src/OFObject.m +++ src/OFObject.m @@ -44,11 +44,11 @@ # import #elif defined(OF_OBJFW_RUNTIME) # import "runtime.h" #endif -#ifdef _WIN32 +#ifdef OF_WINDOWS # include #endif #import "OFString.h" Index: src/OFPlugin.h ================================================================== --- src/OFPlugin.h +++ src/OFPlugin.h @@ -16,11 +16,11 @@ #import "OFObject.h" @class OFString; -#ifndef _WIN32 +#ifndef OF_WINDOWS typedef void* of_plugin_handle_t; #else # include typedef HMODULE of_plugin_handle_t; #endif Index: src/OFPlugin.m ================================================================== --- src/OFPlugin.m +++ src/OFPlugin.m @@ -27,11 +27,11 @@ #import "OFString.h" #import "OFSystemInfo.h" #import "OFInitializationFailedException.h" -#ifdef _WIN32 +#ifdef OF_WINDOWS # define dlsym(handle, symbol) GetProcAddress(handle, symbol) # define dlclose(handle) FreeLibrary(handle) #endif typedef OFPlugin* (*init_plugin_t)(void); @@ -44,11 +44,11 @@ init_plugin_t initPlugin; OFPlugin *plugin; path = [path stringByAppendingString: @PLUGIN_SUFFIX]; -#ifndef _WIN32 +#ifndef OF_WINDOWS if ((handle = dlopen([path cStringWithEncoding: [OFSystemInfo native8BitEncoding]], RTLD_LAZY)) == NULL) #else if ((handle = LoadLibraryW([path UTF16String])) == NULL) #endif Index: src/OFProcess.h ================================================================== --- src/OFProcess.h +++ src/OFProcess.h @@ -24,11 +24,11 @@ #include #import "OFStream.h" #import "OFString.h" -#ifdef _WIN32 +#ifdef OF_WINDOWS # include #endif OF_ASSUME_NONNULL_BEGIN @@ -40,11 +40,11 @@ * * @brief A class for stream-like communication with a newly created process. */ @interface OFProcess: OFStream { -#ifndef _WIN32 +#ifndef OF_WINDOWS pid_t _pid; int _readPipe[2], _writePipe[2]; #else HANDLE _process, _readPipe[2], _writePipe[2]; #endif Index: src/OFProcess.m ================================================================== --- src/OFProcess.m +++ src/OFProcess.m @@ -22,11 +22,13 @@ /* Work around __block being used by glibc */ #ifdef __GLIBC__ # undef __USE_XOPEN #endif -#ifndef _WIN32 +#include "platform.h" + +#ifndef OF_WINDOWS # include # include # include #endif @@ -44,20 +46,20 @@ #import "OFInitializationFailedException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFWriteFailedException.h" -#ifdef _WIN32 +#ifdef OF_WINDOWS # include #endif -#ifndef __MACH__ +#if !defined(OF_WINDOWS) && !defined(HAVE_POSIX_SPAWNP) extern char **environ; #endif @interface OFProcess (OF_PRIVATE_CATEGORY) -#ifndef _WIN32 +#ifndef OF_WINDOWS - (void)OF_getArgV: (char***)argv forProgramName: (OFString*)programName andArguments: (OFArray*)arguments; - (char**)OF_environmentForDictionary: (OFDictionary*)dictionary; #else @@ -136,11 +138,11 @@ environment: (OFDictionary*)environment { self = [super init]; @try { -#ifndef _WIN32 +#ifndef OF_WINDOWS void *pool = objc_autoreleasePoolPush(); const char *path; char **argv; if (pipe(_readPipe) != 0 || pipe(_writePipe) != 0) @@ -337,11 +339,11 @@ [self close]; [super dealloc]; } -#ifndef _WIN32 +#ifndef OF_WINDOWS - (void)OF_getArgV: (char***)argv forProgramName: (OFString*)programName andArguments: (OFArray*)arguments { OFString *const *objects = [arguments objects]; @@ -435,11 +437,11 @@ } #endif - (bool)lowlevelIsAtEndOfStream { -#ifndef _WIN32 +#ifndef OF_WINDOWS if (_readPipe[0] == -1) #else if (_readPipe[0] == NULL) #endif return true; @@ -448,26 +450,24 @@ } - (size_t)lowlevelReadIntoBuffer: (void*)buffer length: (size_t)length { -#ifndef _WIN32 +#ifndef OF_WINDOWS ssize_t ret; -#else - DWORD ret; -#endif -#ifndef _WIN32 if (_readPipe[0] == -1 || _atEndOfStream) @throw [OFReadFailedException exceptionWithObject: self requestedLength: length]; if ((ret = read(_readPipe[0], buffer, length)) < 0) @throw [OFReadFailedException exceptionWithObject: self requestedLength: length errNo: errno]; #else + DWORD ret; + if (length > UINT32_MAX) @throw [OFOutOfRangeException exception]; if (_readPipe[0] == NULL || _atEndOfStream) @throw [OFReadFailedException exceptionWithObject: self @@ -491,11 +491,11 @@ } - (void)lowlevelWriteBuffer: (const void*)buffer length: (size_t)length { -#ifndef _WIN32 +#ifndef OF_WINDOWS if (_writePipe[1] == -1 || _atEndOfStream) @throw [OFWriteFailedException exceptionWithObject: self requestedLength: length]; if (length > SSIZE_MAX) @@ -529,29 +529,29 @@ #endif } - (int)fileDescriptorForReading { -#ifndef _WIN32 +#ifndef OF_WINDOWS return _readPipe[0]; #else OF_UNRECOGNIZED_SELECTOR #endif } - (int)fileDescriptorForWriting { -#ifndef _WIN32 +#ifndef OF_WINDOWS return _writePipe[1]; #else OF_UNRECOGNIZED_SELECTOR #endif } - (void)closeForWriting { -#ifndef _WIN32 +#ifndef OF_WINDOWS if (_writePipe[1] != -1) close(_writePipe[1]); _writePipe[1] = -1; #else @@ -562,11 +562,11 @@ #endif } - (void)close { -#ifndef _WIN32 +#ifndef OF_WINDOWS if (_readPipe[0] != -1) close(_readPipe[0]); if (_writePipe[1] != -1) close(_writePipe[1]); Index: src/OFSeekableStream.h ================================================================== --- src/OFSeekableStream.h +++ src/OFSeekableStream.h @@ -25,11 +25,11 @@ #import "OFStream.h" OF_ASSUME_NONNULL_BEGIN -#if defined(_WIN32) +#if defined(OF_WINDOWS) typedef __int64 of_offset_t; #elif defined(__ANDROID__) typedef long long of_offset_t; #elif defined(OF_HAVE_OFF64_T) typedef off64_t of_offset_t; Index: src/OFStdIOStream.m ================================================================== --- src/OFStdIOStream.m +++ src/OFStdIOStream.m @@ -101,11 +101,11 @@ if (_fd == -1 || _atEndOfStream) @throw [OFReadFailedException exceptionWithObject: self requestedLength: length]; -#ifndef _WIN32 +#ifndef OF_WINDOWS if ((ret = read(_fd, buffer, length)) < 0) @throw [OFReadFailedException exceptionWithObject: self requestedLength: length errNo: errno]; #else @@ -129,11 +129,11 @@ { if (_fd == -1 || _atEndOfStream) @throw [OFWriteFailedException exceptionWithObject: self requestedLength: length]; -#ifndef _WIN32 +#ifndef OF_WINDOWS if (length > SSIZE_MAX) @throw [OFOutOfRangeException exception]; if (write(_fd, buffer, length) != (ssize_t)length) @throw [OFWriteFailedException exceptionWithObject: self Index: src/OFStream.m ================================================================== --- src/OFStream.m +++ src/OFStream.m @@ -25,11 +25,13 @@ #include #include #include -#ifndef _WIN32 +#include "platform.h" + +#ifndef OF_WINDOWS # include #endif #import "OFStream.h" #import "OFStream+Private.h" @@ -46,11 +48,11 @@ #import "OFSetOptionFailedException.h" #import "of_asprintf.h" @implementation OFStream -#ifndef _WIN32 +#ifndef OF_WINDOWS + (void)initialize { if (self == [OFStream class]) signal(SIGPIPE, SIG_IGN); } Index: src/OFStreamSocket.m ================================================================== --- src/OFStreamSocket.m +++ src/OFStreamSocket.m @@ -64,11 +64,11 @@ if (_atEndOfStream) @throw [OFReadFailedException exceptionWithObject: self requestedLength: length errNo: ENOTCONN]; -#ifndef _WIN32 +#ifndef OF_WINDOWS if ((ret = recv(_socket, buffer, length, 0)) < 0) @throw [OFReadFailedException exceptionWithObject: self requestedLength: length errNo: of_socket_errno()]; @@ -98,11 +98,11 @@ if (_atEndOfStream) @throw [OFWriteFailedException exceptionWithObject: self requestedLength: length errNo: ENOTCONN]; -#ifndef _WIN32 +#ifndef OF_WINDOWS if (length > SSIZE_MAX) @throw [OFOutOfRangeException exception]; if (send(_socket, buffer, length, 0) != (ssize_t)length) @throw [OFWriteFailedException @@ -119,11 +119,11 @@ requestedLength: length errNo: of_socket_errno()]; #endif } -#ifdef _WIN32 +#ifdef OF_WINDOWS - (void)setBlocking: (bool)enable { u_long v = enable; _blocking = enable; @@ -134,11 +134,11 @@ } #endif - (int)fileDescriptorForReading { -#ifndef _WIN32 +#ifndef OF_WINDOWS return _socket; #else if (_socket == INVALID_SOCKET) return -1; @@ -149,11 +149,11 @@ #endif } - (int)fileDescriptorForWriting { -#ifndef _WIN32 +#ifndef OF_WINDOWS return _socket; #else if (_socket == INVALID_SOCKET) return -1; Index: src/OFString.m ================================================================== --- src/OFString.m +++ src/OFString.m @@ -60,11 +60,11 @@ /* * It seems strtod is buggy on Win32. * However, the MinGW version __strtod seems to be ok. */ -#ifdef _WIN32 +#ifdef __MINGW32__ # define strtod __strtod #endif @interface OFString (OF_PRIVATE_CATEGORY) - (size_t)OF_getCString: (char*)cString Index: src/OFSystemInfo.m ================================================================== --- src/OFSystemInfo.m +++ src/OFSystemInfo.m @@ -32,20 +32,20 @@ #import "OFDictionary.h" #import "OFApplication.h" #import "OFNotImplementedException.h" -#if defined(__APPLE__) && !defined(OF_IOS) +#if defined(OF_MAC_OS_X) # include #endif -#ifdef _WIN32 +#ifdef OF_WINDOWS # include #endif -#ifdef __HAIKU__ +#ifdef OF_HAIKU # include #endif -#ifdef __QNX__ +#ifdef OF_QNX # include #endif #if defined(OF_X86_64_ASM) || defined(OF_X86_ASM) struct x86_regs { @@ -99,16 +99,16 @@ + (void)initialize { if (self != [OFSystemInfo class]) return; -#if defined(_WIN32) +#if defined(OF_WINDOWS) SYSTEM_INFO si; GetSystemInfo(&si); pageSize = si.dwPageSize; numberOfCPUs = si.dwNumberOfProcessors; -#elif defined(__QNX__) +#elif defined(OF_QNX) if ((pageSize = sysconf(_SC_PAGESIZE)) < 1) pageSize = 4096; numberOfCPUs = _syspage_ptr->num_cpu; #else # if defined(HAVE_SYSCONF) && defined(_SC_PAGESIZE) @@ -144,11 +144,11 @@ } + (OFString*)userDataPath { /* TODO: Return something more sensible for iOS */ -#if defined(__APPLE__) && !defined(OF_IOS) +#if defined(OF_MAC_OS_X) void *pool = objc_autoreleasePoolPush(); char pathC[PATH_MAX]; NSSearchPathEnumerationState state; OFMutableString *path; OFString *home; @@ -175,11 +175,11 @@ [path makeImmutable]; [path retain]; objc_autoreleasePoolPop(pool); return [path autorelease]; -#elif defined(_WIN32) +#elif defined(OF_WINDOWS) void *pool = objc_autoreleasePoolPush(); OFDictionary *env = [OFApplication environment]; OFString *appData; if ((appData = [env objectForKey: @"APPDATA"]) == nil) @@ -187,11 +187,11 @@ object: self]; [appData retain]; objc_autoreleasePoolPop(pool); return [appData autorelease]; -#elif defined(__HAIKU__) +#elif defined(OF_HAIKU) char pathC[PATH_MAX]; if (find_directory(B_USER_SETTINGS_DIRECTORY, 0, false, pathC, PATH_MAX) != B_OK) @throw [OFNotImplementedException exceptionWithSelector: _cmd @@ -224,11 +224,11 @@ } + (OFString*)userConfigPath { /* TODO: Return something more sensible for iOS */ -#if defined(__APPLE__) && !defined(OF_IOS) +#if defined(OF_MAC_OS_X) void *pool = objc_autoreleasePoolPush(); char pathC[PATH_MAX]; NSSearchPathEnumerationState state; OFMutableString *path; OFString *home; @@ -257,11 +257,11 @@ [path makeImmutable]; [path retain]; objc_autoreleasePoolPop(pool); return [path autorelease]; -#elif defined(_WIN32) +#elif defined(OF_WINDOWS) void *pool = objc_autoreleasePoolPush(); OFDictionary *env = [OFApplication environment]; OFString *appData; if ((appData = [env objectForKey: @"APPDATA"]) == nil) @@ -269,11 +269,11 @@ object: self]; [appData retain]; objc_autoreleasePoolPop(pool); return [appData autorelease]; -#elif defined(__HAIKU__) +#elif defined(OF_HAIKU) char pathC[PATH_MAX]; if (find_directory(B_USER_SETTINGS_DIRECTORY, 0, false, pathC, PATH_MAX) != B_OK) @throw [OFNotImplementedException exceptionWithSelector: _cmd Index: src/OFTCPSocket.h ================================================================== --- src/OFTCPSocket.h +++ src/OFTCPSocket.h @@ -63,11 +63,11 @@ bool _listening; struct sockaddr *_address; socklen_t _addressLength; OFString *_SOCKS5Host; uint16_t _SOCKS5Port; -#ifdef __wii__ +#ifdef OF_WII uint16_t _port; bool _keepAliveEnabled, _TCPNoDelayEnabled; #endif } Index: src/OFTCPSocket.m ================================================================== --- src/OFTCPSocket.m +++ src/OFTCPSocket.m @@ -13,11 +13,10 @@ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #define OF_TCP_SOCKET_M - #define __NO_EXT_QNX #include "config.h" #include @@ -238,11 +237,11 @@ - (void)close { [super close]; -#ifdef __wii__ +#ifdef OF_WII if (_port > 0) { of_socket_port_free(_port, SOCK_STREAM); _port = 0; } #endif @@ -387,11 +386,11 @@ - (uint16_t)bindToHost: (OFString*)host port: (uint16_t)port { of_resolver_result_t **results; const int one = 1; -#ifndef __wii__ +#ifndef OF_WII union { struct sockaddr_storage storage; struct sockaddr_in in; # ifdef AF_INET6 struct sockaddr_in6 in6; @@ -405,11 +404,11 @@ if (_SOCKS5Host != nil) @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; -#ifdef __wii__ +#ifdef OF_WII if (port == 0) port = of_socket_port_find(SOCK_STREAM); else if (!of_socket_port_register(port, SOCK_STREAM)) @throw [OFBindFailedException exceptionWithHost: host port: port @@ -418,11 +417,11 @@ #endif @try { results = of_resolve_host(host, port, SOCK_STREAM); } @catch (id e) { -#ifdef __wii__ +#ifdef OF_WII of_socket_port_free(port, SOCK_STREAM); #endif @throw e; } @@ -459,26 +458,26 @@ port: port socket: self errNo: errNo]; } } @catch (id e) { -#ifdef __wii__ +#ifdef OF_WII of_socket_port_free(port, SOCK_STREAM); #endif @throw e; } @finally { of_resolver_free(results); } if (port > 0) { -#ifdef __wii__ +#ifdef OF_WII _port = port; #endif return port; } -#ifndef __wii__ +#ifndef OF_WII addrLen = (socklen_t)sizeof(addr.storage); if (of_getsockname(_socket, (struct sockaddr*)&addr.storage, &addrLen) != 0) { int errNo = of_socket_errno(); @@ -623,18 +622,18 @@ (char*)&v, (socklen_t)sizeof(v)) != 0) @throw [OFSetOptionFailedException exceptionWithStream: self errNo: of_socket_errno()]; -#ifdef __wii__ +#ifdef OF_WII _keepAliveEnabled = enabled; #endif } - (bool)isKeepAliveEnabled { -#ifndef __wii__ +#ifndef OF_WII int v; socklen_t len = sizeof(v); if (getsockopt(_socket, SOL_SOCKET, SO_KEEPALIVE, (char*)&v, &len) != 0 || len != sizeof(v)) @@ -656,18 +655,18 @@ (char*)&v, (socklen_t)sizeof(v)) != 0) @throw [OFSetOptionFailedException exceptionWithStream: self errNo: of_socket_errno()]; -#ifdef __wii__ +#ifdef OF_WII _TCPNoDelayEnabled = enabled; #endif } - (bool)isTCPNoDelayEnabled { -#ifndef __wii__ +#ifndef OF_WII int v; socklen_t len = sizeof(v); if (getsockopt(_socket, IPPROTO_TCP, TCP_NODELAY, (char*)&v, &len) != 0 || len != sizeof(v)) Index: src/OFThread.m ================================================================== --- src/OFThread.m +++ src/OFThread.m @@ -27,19 +27,21 @@ /* Work around __block being used by glibc */ #ifdef __GLIBC__ # undef __USE_XOPEN #endif -#ifndef _WIN32 +#include "platform.h" + +#ifndef OF_WINDOWS # include #endif #ifdef OF_HAVE_SCHED_YIELD # include #endif -#ifdef __wii__ +#ifdef OF_WII # define BOOL OGC_BOOL # define nanosleep ogc_nanosleep # include # undef BOOL # undef nanosleep @@ -52,11 +54,11 @@ #import "OFDate.h" #import "OFDictionary.h" #import "OFAutoreleasePool.h" #import "OFAutoreleasePool+Private.h" -#ifdef _WIN32 +#ifdef OF_WINDOWS # include #endif #ifdef OF_NINTENDO_DS # define asm __asm__ @@ -174,11 +176,11 @@ + (void)sleepForTimeInterval: (of_time_interval_t)timeInterval { if (timeInterval < 0) return; -#if defined(_WIN32) +#if defined(OF_WINDOWS) if (timeInterval * 1000 > UINT_MAX) @throw [OFOutOfRangeException exception]; Sleep((unsigned int)(timeInterval * 1000)); #elif defined(HAVE_NANOSLEEP) Index: src/OFUDPSocket.h ================================================================== --- src/OFUDPSocket.h +++ src/OFUDPSocket.h @@ -88,11 +88,11 @@ */ @interface OFUDPSocket: OFObject { of_socket_t _socket; -#ifdef __wii__ +#ifdef OF_WII uint16_t _port; #endif } /*! Index: src/OFUDPSocket.m ================================================================== --- src/OFUDPSocket.m +++ src/OFUDPSocket.m @@ -183,11 +183,11 @@ if (address1->address.ss_family != address2->address.ss_family) return false; switch (address1->address.ss_family) { case AF_INET: -#ifndef __wii__ +#ifndef OF_WII if (address1->length < sizeof(struct sockaddr_in) || address2->length < sizeof(struct sockaddr_in)) @throw [OFInvalidArgumentException exception]; #else if (address1->length < 8 || address2->length < 8) @@ -241,11 +241,11 @@ hash += address->address.ss_family; switch (address->address.ss_family) { case AF_INET: -#ifndef __wii__ +#ifndef OF_WII if (address->length < sizeof(struct sockaddr_in)) @throw [OFInvalidArgumentException exception]; #else if (address->length < 8) @throw [OFInvalidArgumentException exception]; @@ -384,11 +384,11 @@ - (uint16_t)bindToHost: (OFString*)host port: (uint16_t)port { of_resolver_result_t **results; -#ifndef __wii__ +#ifndef OF_WII union { struct sockaddr_storage storage; struct sockaddr_in in; # ifdef AF_INET6 struct sockaddr_in6 in6; @@ -395,11 +395,11 @@ # endif } addr; socklen_t addrLen; #endif -#ifdef __wii__ +#ifdef OF_WII if (port == 0) port = of_socket_port_find(SOCK_DGRAM); else if (!of_socket_port_register(port, SOCK_DGRAM)) @throw [OFBindFailedException exceptionWithHost: host port: port @@ -408,11 +408,11 @@ #endif @try { results = of_resolve_host(host, port, SOCK_DGRAM); } @catch (id e) { -#ifdef __wii__ +#ifdef OF_WII of_socket_port_free(port, SOCK_DGRAM); #endif @throw e; } @@ -446,26 +446,26 @@ port: port socket: self errNo: errNo]; } } @catch (id e) { -#ifdef __wii__ +#ifdef OF_WII of_socket_port_free(port, SOCK_DGRAM); #endif @throw e; } @finally { of_resolver_free(results); } if (port > 0) { -#ifdef __wii__ +#ifdef OF_WII _port = port; #endif return port; } -#ifndef __wii__ +#ifndef OF_WII addrLen = (socklen_t)sizeof(addr.storage); if (of_getsockname(_socket, (struct sockaddr*)&addr.storage, &addrLen) != 0) { int errNo = of_socket_errno(); @@ -503,11 +503,11 @@ if (_socket == INVALID_SOCKET) @throw [OFNotOpenException exceptionWithObject: self]; sender->length = (socklen_t)sizeof(sender->address); -#ifndef _WIN32 +#ifndef OF_WINDOWS if ((ret = recvfrom(_socket, buffer, length, 0, (struct sockaddr*)&sender->address, &sender->length)) < 0) @throw [OFReadFailedException exceptionWithObject: self requestedLength: length @@ -556,11 +556,11 @@ receiver: (const of_udp_socket_address_t*)receiver { if (_socket == INVALID_SOCKET) @throw [OFNotOpenException exceptionWithObject: self]; -#ifndef _WIN32 +#ifndef OF_WINDOWS if (length > SSIZE_MAX) @throw [OFOutOfRangeException exception]; if (sendto(_socket, buffer, length, 0, (struct sockaddr*)&receiver->address, @@ -588,11 +588,11 @@ [OFRunLoop OF_cancelAsyncRequestsForObject: self]; } - (int)fileDescriptorForReading { -#ifndef _WIN32 +#ifndef OF_WINDOWS return _socket; #else if (_socket == INVALID_SOCKET) return -1; @@ -603,11 +603,11 @@ #endif } - (int)fileDescriptorForWriting { -#ifndef _WIN32 +#ifndef OF_WINDOWS return _socket; #else if (_socket == INVALID_SOCKET) return -1; @@ -624,13 +624,13 @@ @throw [OFNotOpenException exceptionWithObject: self]; close(_socket); _socket = INVALID_SOCKET; -#ifdef __wii__ +#ifdef OF_WII if (_port > 0) { of_socket_port_free(_port, SOCK_DGRAM); _port = 0; } #endif } @end Index: src/ObjFW.h ================================================================== --- src/ObjFW.h +++ src/ObjFW.h @@ -12,12 +12,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. */ -#import "objfw-defs.h" - #import "OFObject.h" #import "OFBlock.h" #import "OFAutoreleasePool.h" #import "OFString.h" Index: src/atomic.h ================================================================== --- src/atomic.h +++ src/atomic.h @@ -12,20 +12,18 @@ * 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. */ -#import "objfw-defs.h" +#include + +#import "macros.h" #ifndef OF_HAVE_ATOMIC_OPS # error No atomic operations available! #endif -#include - -#import "macros.h" - #ifdef OF_HAVE_OSATOMIC # include #endif OF_ASSUME_NONNULL_BEGIN @@ -58,11 +56,11 @@ # endif else abort(); return i; -#elif defined(OF_PPC_ASM) +#elif defined(OF_POWERPC_ASM) __asm__ __volatile__ ( "0:\n\t" "lwarx %0, 0, %2\n\t" "add %0, %0, %1\n\t" "stwcx. %0, 0, %2\n\t" @@ -94,11 +92,11 @@ : "+&r"(i) : "r"(i), "m"(*p) ); return i; -#elif defined(OF_PPC_ASM) +#elif defined(OF_POWERPC_ASM) __asm__ __volatile__ ( "0:\n\t" "lwarx %0, 0, %2\n\t" "add %0, %0, %1\n\t" "stwcx. %0, 0, %2\n\t" @@ -140,11 +138,11 @@ : "+&r"(i) : "r"(i), "m"(*p) ); return (void*)i; -#elif defined(OF_PPC_ASM) +#elif defined(OF_POWERPC_ASM) __asm__ __volatile__ ( "0:\n\t" "lwarx %0, 0, %2\n\t" "add %0, %0, %1\n\t" "stwcx. %0, 0, %2\n\t" @@ -195,11 +193,11 @@ # endif else abort(); return i; -#elif defined(OF_PPC_ASM) +#elif defined(OF_POWERPC_ASM) __asm__ __volatile__ ( "0:\n\t" "lwarx %0, 0, %2\n\t" "sub %0, %0, %1\n\t" "stwcx. %0, 0, %2\n\t" @@ -232,11 +230,11 @@ : "+&r"(i) : "r"(i), "m"(*p) ); return i; -#elif defined(OF_PPC_ASM) +#elif defined(OF_POWERPC_ASM) __asm__ __volatile__ ( "0:\n\t" "lwarx %0, 0, %2\n\t" "sub %0, %0, %1\n\t" "stwcx. %0, 0, %2\n\t" @@ -280,11 +278,11 @@ : "+&r"(i) : "r"(i), "m"(*p) ); return (void*)i; -#elif defined(OF_PPC_ASM) +#elif defined(OF_POWERPC_ASM) __asm__ __volatile__ ( "0:\n\t" "lwarx %0, 0, %2\n\t" "sub %0, %0, %1\n\t" "stwcx. %0, 0, %2\n\t" @@ -339,11 +337,11 @@ # endif else abort(); return i; -#elif defined(OF_PPC_ASM) +#elif defined(OF_POWERPC_ASM) int i; __asm__ __volatile__ ( "0:\n\t" "lwarx %0, 0, %1\n\t" @@ -381,11 +379,11 @@ : "=&r"(i) : "m"(*p) ); return i; -#elif defined(OF_PPC_ASM) +#elif defined(OF_POWERPC_ASM) int32_t i; __asm__ __volatile__ ( "0:\n\t" "lwarx %0, 0, %1\n\t" @@ -438,11 +436,11 @@ # endif else abort(); return i; -#elif defined(OF_PPC_ASM) +#elif defined(OF_POWERPC_ASM) int i; __asm__ __volatile__ ( "0:\n\t" "lwarx %0, 0, %1\n\t" @@ -480,11 +478,11 @@ : "=&r"(i) : "m"(*p) ); return i; -#elif defined(OF_PPC_ASM) +#elif defined(OF_POWERPC_ASM) int32_t i; __asm__ __volatile__ ( "0:\n\t" "lwarx %0, 0, %1\n\t" @@ -541,11 +539,11 @@ # endif else abort(); return i; -#elif defined(OF_PPC_ASM) +#elif defined(OF_POWERPC_ASM) __asm__ __volatile__ ( "0:\n\t" "lwarx %0, 0, %2\n\t" "or %0, %0, %1\n\t" "stwcx. %0, 0, %2\n\t" @@ -582,11 +580,11 @@ : "r"(i), "m"(*p) : "eax", "cc" ); return i; -#elif defined(OF_PPC_ASM) +#elif defined(OF_POWERPC_ASM) __asm__ __volatile__ ( "0:\n\t" "lwarx %0, 0, %2\n\t" "or %0, %0, %1\n\t" "stwcx. %0, 0, %2\n\t" @@ -641,11 +639,11 @@ # endif else abort(); return i; -#elif defined(OF_PPC_ASM) +#elif defined(OF_POWERPC_ASM) __asm__ __volatile__ ( "0:\n\t" "lwarx %0, 0, %2\n\t" "and %0, %0, %1\n\t" "stwcx. %0, 0, %2\n\t" @@ -682,11 +680,11 @@ : "r"(i), "m"(*p) : "eax", "cc" ); return i; -#elif defined(OF_PPC_ASM) +#elif defined(OF_POWERPC_ASM) __asm__ __volatile__ ( "0:\n\t" "lwarx %0, 0, %2\n\t" "and %0, %0, %1\n\t" "stwcx. %0, 0, %2\n\t" @@ -741,11 +739,11 @@ # endif else abort(); return i; -#elif defined(OF_PPC_ASM) +#elif defined(OF_POWERPC_ASM) __asm__ __volatile__ ( "0:\n\t" "lwarx %0, 0, %2\n\t" "xor %0, %0, %1\n\t" "stwcx. %0, 0, %2\n\t" @@ -782,11 +780,11 @@ : "r"(i), "m"(*p) : "eax", "cc" ); return i; -#elif defined(OF_PPC_ASM) +#elif defined(OF_POWERPC_ASM) __asm__ __volatile__ ( "0:\n\t" "lwarx %0, 0, %2\n\t" "xor %0, %0, %1\n\t" "stwcx. %0, 0, %2\n\t" @@ -827,11 +825,11 @@ : "r"(n), "m"(*p) : "cc" ); return r; -#elif defined(OF_PPC_ASM) +#elif defined(OF_POWERPC_ASM) int r; __asm__ __volatile__ ( "0:\n\t" "lwarx %0, 0, %3\n\t" @@ -882,11 +880,11 @@ : "r"(n), "m"(*p) : "cc" ); return r; -#elif defined(OF_PPC_ASM) +#elif defined(OF_POWERPC_ASM) int r; __asm__ __volatile__ ( "0:\n\t" "lwarx %0, 0, %3\n\t" @@ -938,11 +936,11 @@ : "r"(n), "m"(*p) : "cc" ); return r; -#elif defined(OF_PPC_ASM) +#elif defined(OF_POWERPC_ASM) int r; __asm__ __volatile__ ( "0:\n\t" "lwarx %0, 0, %3\n\t" @@ -975,11 +973,11 @@ #if !defined(OF_HAVE_THREADS) #elif defined(OF_X86_64_ASM) || defined(OF_X86_ASM) __asm__ __volatile__ ( "mfence" ); -#elif defined(OF_PPC_ASM) +#elif defined(OF_POWERPC_ASM) __asm__ __volatile__ ( "sync" ); #elif defined(OF_HAVE_GCC_ATOMIC_OPS) __sync_synchronize(); Index: src/base64.h ================================================================== --- src/base64.h +++ src/base64.h @@ -12,12 +12,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. */ -#import "objfw-defs.h" - #ifndef __STDC_LIMIT_MACROS # define __STDC_LIMIT_MACROS #endif #ifndef __STDC_CONSTANT_MACROS # define __STDC_CONSTANT_MACROS Index: src/exceptions/OFAddressTranslationFailedException.m ================================================================== --- src/exceptions/OFAddressTranslationFailedException.m +++ src/exceptions/OFAddressTranslationFailedException.m @@ -107,21 +107,21 @@ } - (OFString*)description { /* FIXME: Add proper description for Win32 */ -#ifndef _WIN32 +#ifndef OF_WINDOWS if (_error == 0) { #endif if (_host != nil) return [OFString stringWithFormat: @"The host %@ could not be translated to an " @"address!", _host]; else return @"An address could not be translated!"; -#ifndef _WIN32 +#ifndef OF_WINDOWS } # ifdef HAVE_GETADDRINFO # if defined(OF_HAVE_THREADS) && !defined(HAVE_THREADSAFE_GETADDRINFO) if (!of_mutex_lock(&mutex)) Index: src/exceptions/OFException.h ================================================================== --- src/exceptions/OFException.h +++ src/exceptions/OFException.h @@ -22,11 +22,11 @@ @class OFMutableArray OF_GENERIC(ObjectType); #endif #define OF_BACKTRACE_SIZE 32 -#if defined(_WIN32) && defined(OF_HAVE_SOCKETS) +#if defined(OF_WINDOWS) && defined(OF_HAVE_SOCKETS) # ifndef EADDRINUSE # define EADDRINUSE WSAEADDRINUSE # endif # ifndef EADDRNOTAVAIL # define EADDRNOTAVAIL WSAEADDRNOTAVAIL Index: src/exceptions/OFException.m ================================================================== --- src/exceptions/OFException.m +++ src/exceptions/OFException.m @@ -36,11 +36,11 @@ #if !defined(HAVE_STRERROR_R) && defined(OF_HAVE_THREADS) # import "threading.h" #endif -#if defined(_WIN32) && defined(OF_HAVE_SOCKETS) +#if defined(OF_WINDOWS) && defined(OF_HAVE_SOCKETS) # include #endif /* * Define HAVE_DWARF_EXCEPTIONS if OBJC_ZEROCOST_EXCEPTIONS is defined, but @@ -72,11 +72,11 @@ uint_fast8_t i; }; extern _Unwind_Reason_Code _Unwind_Backtrace( _Unwind_Reason_Code(*)(struct _Unwind_Context*, void*), void*); -# if defined(__arm__) || defined(__ARM__) +# ifdef OF_ARM extern int _Unwind_VRS_Get(struct _Unwind_Context*, int, uint32_t, int, void*); # else extern uintptr_t _Unwind_GetIP(struct _Unwind_Context*); # endif #endif @@ -98,11 +98,11 @@ OFString *ret; #ifdef HAVE_STRERROR_R char buffer[256]; #endif -#ifdef _WIN32 +#ifdef OF_WINDOWS /* * These were translated from WSAE* errors to errno and thus Win32's * strerror_r() does not know about them. * * FIXME: These could have better descriptions! @@ -213,11 +213,11 @@ backtrace_callback(struct _Unwind_Context *ctx, void *data) { struct backtrace_ctx *bt = data; if (bt->i < OF_BACKTRACE_SIZE) { -# if defined(__arm__) || defined(__ARM__) +# ifdef OF_ARM uintptr_t ip; _Unwind_VRS_Get(ctx, 0, 15, 0, &ip); bt->backtrace[bt->i++] = (void*)(ip & ~1); # else Index: src/forwarding/Makefile ================================================================== --- src/forwarding/Makefile +++ src/forwarding/Makefile @@ -5,6 +5,6 @@ SRCS = forwarding.S include ../../buildsys.mk -ASFLAGS += -I../.. +ASFLAGS += -I../.. -I.. Index: src/forwarding/forwarding-arm-elf.S ================================================================== --- src/forwarding/forwarding-arm-elf.S +++ src/forwarding/forwarding-arm-elf.S @@ -14,10 +14,12 @@ * file. */ #include "config.h" +#include "platform.h" + .globl of_forward .globl of_forward_stret .section .text of_forward: @@ -165,8 +167,8 @@ .long 0 .long 0 module: .long 8, 16, 0, symtab -#ifdef __linux__ +#ifdef OF_LINUX .section .note.GNU-stack, "", %progbits #endif Index: src/forwarding/forwarding-mips-elf.S ================================================================== --- src/forwarding/forwarding-mips-elf.S +++ src/forwarding/forwarding-mips-elf.S @@ -14,14 +14,16 @@ * file. */ #include "config.h" +#include "platform.h" + .globl of_forward .globl of_forward_stret -#ifdef __PIC__ +#ifdef OF_PIC .macro j_pic symbol lw $t9, %call16(\symbol)($gp) jr $t9 .endm .macro jal_pic symbol @@ -37,11 +39,11 @@ .endm #endif .section .text of_forward: -#ifdef __PIC__ +#ifdef OF_PIC lui $gp, %hi(_gp_disp) addiu $gp, $gp, %lo(_gp_disp) addu $gp, $gp, $t9 #endif @@ -60,11 +62,11 @@ sw $a0, 28($sp) sw $a1, 32($sp) sw $a2, 36($sp) sw $a3, 40($sp) -#ifdef __mips_eabi +#ifdef OF_MIPS_EABI /* For some reason, $a4-$a8 are not always defined */ sw $8, 44($sp) sw $9, 48($sp) sw $10, 52($sp) sw $11, 56($sp) @@ -78,11 +80,11 @@ swc1 $f18, 84($sp) swc1 $f19, 88($sp) #endif move $s0, $gp -#ifdef __PIC__ +#ifdef OF_PIC lw $s1, %got(sel_forwardingTargetForSelector_)($gp) #else lui $s1, %hi(sel_forwardingTargetForSelector_) #endif addiu $s1, $s1, %lo(sel_forwardingTargetForSelector_) @@ -116,11 +118,11 @@ move $gp, $s0 move $a0, $v0 lw $a1, 32($sp) jal_pic objc_msg_lookup -#ifdef __mips_eabi +#ifdef OF_MIPS_EABI lwc1 $f19, 88($sp) lwc1 $f18, 84($sp) lwc1 $f17, 80($sp) lwc1 $f16, 76($sp) lwc1 $f15, 72($sp) @@ -161,11 +163,11 @@ j_pic of_method_not_found .type of_forward, %function .size of_forward, .-of_forward of_forward_stret: -#ifdef __PIC__ +#ifdef OF_PIC lui $gp, %hi(_gp_disp) addiu $gp, $gp, %lo(_gp_disp) addu $gp, $gp, $t9 #endif @@ -184,11 +186,11 @@ sw $a0, 28($sp) sw $a1, 32($sp) sw $a2, 36($sp) sw $a3, 40($sp) -#ifdef __mips_eabi +#ifdef OF_MIPS_EABI /* For some reason, $a4-$a8 are not always defined */ sw $8, 44($sp) sw $9, 48($sp) sw $10, 52($sp) sw $11, 56($sp) @@ -202,11 +204,11 @@ swc1 $f18, 84($sp) swc1 $f19, 88($sp) #endif move $s0, $gp -#ifdef __PIC__ +#ifdef OF_PIC lw $s1, %got(sel_forwardingTargetForSelector_)($gp) #else lui $s1, %hi(sel_forwardingTargetForSelector_) #endif addiu $s1, $s1, %lo(sel_forwardingTargetForSelector_) @@ -241,11 +243,11 @@ move $gp, $s0 move $a0, $v0 lw $a1, 36($sp) jal_pic objc_msg_lookup_stret -#ifdef __mips_eabi +#ifdef OF_MIPS_EABI lwc1 $f19, 88($sp) lwc1 $f18, 84($sp) lwc1 $f17, 80($sp) lwc1 $f16, 76($sp) lwc1 $f15, 72($sp) @@ -287,11 +289,11 @@ j_pic of_method_not_found_stret .type of_forward_stret, %function .size of_forward_stret, .-of_forward_stret init: -#ifdef __PIC__ +#ifdef OF_PIC lui $gp, %hi(_gp_disp) addiu $gp, $gp, %lo(_gp_disp) addu $gp, $gp, $t9 lw $a0, %got(module)($gp) @@ -321,8 +323,8 @@ .long 0 .long 0 module: .long 8, 16, 0, symtab -#ifdef __linux__ +#ifdef OF_LINUX .section .note.GNU-stack, "", %progbits #endif Index: src/forwarding/forwarding-ppc-elf.S ================================================================== --- src/forwarding/forwarding-ppc-elf.S +++ src/forwarding/forwarding-ppc-elf.S @@ -14,10 +14,12 @@ * file. */ #include "config.h" +#include "platform.h" + .globl of_forward .globl of_forward_stret .section .text of_forward: @@ -234,8 +236,8 @@ .long 0 .long 0 module: .long 8, 16, 0, symtab -#ifdef __linux__ +#ifdef OF_LINUX .section .note.GNU-stack, "", %progbits #endif Index: src/forwarding/forwarding-x86-elf.S ================================================================== --- src/forwarding/forwarding-x86-elf.S +++ src/forwarding/forwarding-x86-elf.S @@ -14,10 +14,12 @@ * file. */ #include "config.h" +#include "platform.h" + .globl of_forward .globl of_forward_stret .section .text of_forward: @@ -200,8 +202,8 @@ .long 0 .long 0 module: .long 8, 16, 0, symtab -#ifdef __linux__ +#ifdef OF_LINUX .section .note.GNU-stack, "", %progbits #endif Index: src/forwarding/forwarding-x86_64-elf.S ================================================================== --- src/forwarding/forwarding-x86_64-elf.S +++ src/forwarding/forwarding-x86_64-elf.S @@ -14,10 +14,12 @@ * file. */ #include "config.h" +#include "platform.h" + .globl of_forward .globl of_forward_stret .section .text of_forward: @@ -213,8 +215,8 @@ .long 0 .quad 0 module: .quad 8, 32, 0, symtab -#ifdef __linux__ +#ifdef OF_LINUX .section .note.GNU-stack, "", %progbits #endif Index: src/forwarding/forwarding.S ================================================================== --- src/forwarding/forwarding.S +++ src/forwarding/forwarding.S @@ -13,40 +13,41 @@ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" + +#include "platform.h" #ifdef OF_APPLE_RUNTIME -# if defined(__x86_64__) +# if defined(OF_X86_64) # include "apple-forwarding-x86_64.S" -# elif defined(__i386__) +# elif defined(OF_X86) # include "apple-forwarding-i386.S" -# elif defined(__ARM64_ARCH_8__) +# elif defined(OF_ARM64) # include "apple-forwarding-arm64.S" -# elif defined(__arm__) +# elif defined(OF_ARM) # include "apple-forwarding-arm.S" -# elif defined(__ppc__) +# elif defined(OF_POWERPC) # include "apple-forwarding-ppc.S" # endif #else -# if defined(__ELF__) -# if defined(__x86_64__) || defined(__amd64__) +# if defined(OF_ELF) +# if defined(OF_X86_64) # include "forwarding-x86_64-elf.S" -# elif defined(__i386__) +# elif defined(OF_X86) # include "forwarding-x86-elf.S" -# elif defined(__arm__) || defined(__ARM__) +# elif defined(OF_ARM) # include "forwarding-arm-elf.S" -# elif defined(__ppc__) || defined(__PPC__) +# elif defined(OF_POWERPC) # include "forwarding-ppc-elf.S" -# elif (defined(_MIPS_SIM) && _MIPS_SIM == _ABIO32) || \ - (defined(__mips_eabi) && _MIPS_SZPTR == 32) +# elif defined(OF_MIPS) # include "forwarding-mips-elf.S" # endif -# elif defined(_WIN32) -# if defined(__x86_64__) +# elif defined(OF_WINDOWS) +# if defined(OF_X86_64) # include "forwarding-x86_64-win64.S" -# elif defined(__i386__) +# elif defined(OF_X86) # include "forwarding-x86-win32.S" # endif # endif #endif Index: src/macros.h ================================================================== --- src/macros.h +++ src/macros.h @@ -12,11 +12,11 @@ * 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. */ -#import "objfw-defs.h" +#include "objfw-defs.h" #ifndef __STDC_LIMIT_MACROS # define __STDC_LIMIT_MACROS #endif #ifndef __STDC_CONSTANT_MACROS @@ -27,10 +27,12 @@ #include #include #include #include #include + +#include "platform.h" #ifdef OF_OBJFW_RUNTIME # import "runtime.h" #endif #ifdef OF_APPLE_RUNTIME @@ -74,20 +76,10 @@ # define OF_UNLIKELY(cond) cond # define OF_CONST_FUNC # define OF_NO_RETURN_FUNC #endif -/* Required to build universal binaries on OS X */ -#ifdef OF_UNIVERSAL -# if __BIG_ENDIAN__ -# define OF_BIG_ENDIAN -# define OF_FLOAT_BIG_ENDIAN -# elif !__LITTLE_ENDIAN__ -# error OF_UNIVERSAL defined, but neither __BIG_ENDIAN__ nor __LITTLE_ENDIAN__! -# endif -#endif - #ifdef OF_BIG_ENDIAN # define OF_BYTE_ORDER_NATIVE OF_BYTE_ORDER_BIG_ENDIAN #else # define OF_BYTE_ORDER_NATIVE OF_BYTE_ORDER_LITTLE_ENDIAN #endif @@ -229,87 +221,53 @@ #else # define OF_SUBCLASSING_RESTRICTED #endif #ifdef __GNUC__ -# if defined(__x86_64__) || defined(__amd64__) +# ifdef OF_X86_64 # define OF_X86_64_ASM -# elif defined(__i386__) +# endif +# ifdef OF_X86 # define OF_X86_ASM -# elif defined(__ppc__) || defined(__PPC__) -# define OF_PPC_ASM -# elif defined(__arm__) || defined(__ARM__) +# endif +# ifdef OF_POWERPC +# define OF_POWERPC_ASM +# endif +# ifdef OF_ARM64 +# define OF_ARM64_ASM +# endif +# ifdef OF_ARM # define OF_ARM_ASM -# ifdef __ARM_ARCH_7__ -# define OF_ARMV7_ASM -# endif -# ifdef __ARM_ARCH_7A__ -# define OF_ARMV7_ASM -# endif -# ifdef __ARM_ARCH_7R__ -# define OF_ARMV7_ASM -# endif -# ifdef __ARM_ARCH_7M__ -# define OF_ARMV7_ASM -# endif -# ifdef __ARM_ARCH_7EM__ -# define OF_ARMV7_ASM -# endif -# ifdef __ARM_ARCH_6__ -# define OF_ARMV6_ASM -# endif -# ifdef __ARM_ARCH_6J__ -# define OF_ARMV6_ASM -# endif -# ifdef __ARM_ARCH_6K__ -# define OF_ARMV6_ASM -# endif -# ifdef __ARM_ARCH_6Z__ -# define OF_ARMV6_ASM -# endif -# ifdef __ARM_ARCH_6ZK__ -# define OF_ARMV6_ASM -# endif -# ifdef __ARM_ARCH_6T2__ -# define OF_ARMV6_ASM -# endif -# ifdef OF_ARMV7_ASM -# define OF_ARMV6_ASM -# endif -# elif defined(__arm64__) || defined(__aarch64__) -# define OF_ARM64_ASM -# elif (defined(_MIPS_SIM) && _MIPS_SIM == _ABIO32) || \ - (defined(__mips_eabi) && _MIPS_SZPTR == 32) +# endif +# ifdef OF_ARMV7 +# define OF_ARMV7_ASM +# endif +# ifdef OF_ARMV6 +# define OF_ARMV6_ASM +# endif +# ifdef OF_MIPS # define OF_MIPS_ASM # endif #endif #ifdef OF_APPLE_RUNTIME -# if defined(__x86_64__) || defined(__i386__) || defined(__ARM64_ARCH_8__) || \ - defined(__arm__) || defined(__ppc__) +# if defined(OF_X86_64) || defined(OF_X86) || defined(OF_ARM64) || \ + defined(OF_ARM) || defined(OF_POWERPC) # define OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR # define OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR_STRET # endif #else -# if defined(__ELF__) -# if defined(__x86_64__) || defined(__amd64__) || defined(__i386__) || \ - defined(__arm__) || defined(__ARM__) || defined(__ppc__) || \ - defined(__PPC__) +# if defined(OF_ELF) +# if defined(OF_X86_64) || defined(OF_X86) || \ + defined(OF_ARM) || defined(OF_POWERPC) || defined(OF_MIPS) # define OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR # if __OBJFW_RUNTIME_ABI__ >= 800 # define OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR_STRET # endif # endif -# if (defined(_MIPS_SIM) && _MIPS_SIM == _ABIO32) || \ - (defined(__mips_eabi) && _MIPS_SZPTR == 32) -# define OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR -# if __OBJFW_RUNTIME_ABI__ >= 800 -# define OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR_STRET -# endif -# endif -# elif defined(_WIN32) -# if defined(__x86_64__) || defined(__i386__) +# elif defined(OF_WINDOWS) +# if defined(OF_X86_64) || defined(OF_X86) # define OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR # if __OBJFW_RUNTIME_ABI__ >= 800 # define OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR_STRET # endif # endif @@ -317,11 +275,11 @@ #endif #define OF_RETAIN_COUNT_MAX UINT_MAX #define OF_NOT_FOUND SIZE_MAX -#if !defined(_WIN32) && !defined(__DJGPP__) +#if !defined(OF_WINDOWS) && !defined(OF_MSDOS) # define OF_PATH_DELIMITER '/' # define OF_PATH_DELIMITER_STRING @"/" # define OF_IS_PATH_DELIMITER(c) (c == '/') #else # define OF_PATH_DELIMITER '\\' @@ -405,11 +363,11 @@ __asm__ ( "xchgb %h0, %b0" : "=Q"(i) : "0"(i) ); -#elif defined(OF_PPC_ASM) +#elif defined(OF_POWERPC_ASM) __asm__ ( "lhbrx %0, 0, %1" : "=r"(i) : "r"(&i), "m"(i) ); @@ -435,11 +393,11 @@ __asm__ ( "bswap %0" : "=q"(i) : "0"(i) ); -#elif defined(OF_PPC_ASM) +#elif defined(OF_POWERPC_ASM) __asm__ ( "lwbrx %0, 0, %1" : "=r"(i) : "r"(&i), "m"(i) ); Index: src/of_asprintf.m ================================================================== --- src/of_asprintf.m +++ src/of_asprintf.m @@ -212,11 +212,11 @@ break; case 'l': /* and also ll */ if (ctx->formatLen > ctx->i + 1 && ctx->format[ctx->i + 1] == 'l') { -#ifndef _WIN32 +#ifndef OF_WINDOWS if (!appendSubformat(ctx, ctx->format + ctx->i, 2)) return false; #else if (!appendSubformat(ctx, "I64", 3)) return false; @@ -231,11 +231,11 @@ ctx->lengthModifier = LENGTH_MODIFIER_L; } break; case 'j': -#if defined(_WIN32) +#if defined(OF_WINDOWS) if (!appendSubformat(ctx, "I64", 3)) return false; #elif defined(_NEWLIB_VERSION) if (!appendSubformat(ctx, "ll", 2)) return false; @@ -246,11 +246,11 @@ ctx->lengthModifier = LENGTH_MODIFIER_J; break; case 'z': -#if defined(_WIN32) +#if defined(OF_WINDOWS) if (!appendSubformat(ctx, "I", 1)) return false; #elif defined(_NEWLIB_VERSION) if (!appendSubformat(ctx, "l", 1)) return false; @@ -261,11 +261,11 @@ ctx->lengthModifier = LENGTH_MODIFIER_Z; break; case 't': -#if defined(_WIN32) +#if defined(OF_WINDOWS) if (!appendSubformat(ctx, "I", 1)) return false; #elif defined(_NEWLIB_VERSION) if (!appendSubformat(ctx, "l", 1)) return false; @@ -282,11 +282,11 @@ return false; ctx->lengthModifier = LENGTH_MODIFIER_CAPITAL_L; break; -#ifdef _WIN32 +#ifdef OF_WINDOWS case 'I': /* win32 strangeness (I64 instead of ll or j) */ if (ctx->formatLen > ctx->i + 2 && ctx->format[ctx->i + 1] == '6' && ctx->format[ctx->i + 2] == '4') { if (!appendSubformat(ctx, ctx->format + ctx->i, 3)) Index: src/of_strptime.m ================================================================== --- src/of_strptime.m +++ src/of_strptime.m @@ -17,10 +17,12 @@ #include "config.h" #include #include + +#include "macros.h" const char* of_strptime(const char *buffer, const char *format, struct tm *tm) { enum { ADDED src/platform.h Index: src/platform.h ================================================================== --- src/platform.h +++ src/platform.h @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 + * 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 "objfw-defs.h" + +/* Required to build universal binaries on OS X */ +#ifdef OF_UNIVERSAL +# if __BIG_ENDIAN__ +# define OF_BIG_ENDIAN +# define OF_FLOAT_BIG_ENDIAN +# elif !__LITTLE_ENDIAN__ +# error OF_UNIVERSAL defined, but neither __BIG_ENDIAN__ nor __LITTLE_ENDIAN__! +# endif +#endif + +#if defined(__x86_64__) || defined(__amd64__) +# define OF_X86_64 +#elif defined(__i386__) +# define OF_X86 +#elif defined(__powerpc64__) || defined(__ppc64__) || defined(__PPC64__) +# define OF_POWERPC64 +#elif defined(__powerpc__) || defined(__ppc__) || defined(__PPC__) +# define OF_POWERPC +#elif defined(__arm64__) || defined(__aarch64__) || defined(__ARM64_ARCH_8__) +# define OF_ARM64 +#elif defined(__arm__) || defined(__ARM__) +# define OF_ARM +# if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || \ + defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || \ + defined(__ARM_ARCH_7EM__) +# define OF_ARMV7 +# endif +# if defined(OF_ARMV7) || defined(__ARM_ARCH_6__) || \ + defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || \ + defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) || \ + defined(__ARM_ARCH_6T2__) +# define OF_ARMV6 +# endif +#elif defined(_MIPS_SIM) && _MIPS_SIM == _ABIO32 +# define OF_MIPS +# define OF_MIPS_O32 +#elif defined(__mips_eabi) && _MIPS_SZPTR == 32 +# define OF_MIPS +# define OF_MIPS_EABI +#elif defined(__sparc__) && !defined(__arch64__) +# define OF_SPARC +#endif + +#if defined(__APPLE__) +# if defined(OF_ARM) || defined(OF_ARM64) +# define OF_IOS +# else +# define OF_MAC_OS_X +# endif +#elif defined(__linux__) +# define OF_LINUX +#elif defined(_WIN32) +# define OF_WINDOWS +#elif defined(__NetBSD__) +# define OF_NETBSD +#elif defined(__DragonFly__) +# define OF_DRAGONFLYBSD +#elif defined(__HAIKU__) +# define OF_HAIKU +#elif defined(__sun__) +# define OF_SOLARIS +#elif defined(__QNX__) +# define OF_QNX +#elif defined(__wii__) +# define OF_WII +#elif defined(_PSP) +# define OF_PSP +#elif defined(__DJGPP__) +# define OF_MSDOS +#endif + +#if defined(__ELF__) +# define OF_ELF +#elif defined(__MACH__) +# define OF_MACH_O +#endif + +#if defined(__PIC__) || defined(__pic__) +# define OF_PIC +#endif Index: src/resolver.m ================================================================== --- src/resolver.m +++ src/resolver.m @@ -163,11 +163,11 @@ free(tmp); @throw [OFOutOfMemoryException exceptionWithRequestedSize: sizeof(*addr)]; } -#ifdef __wii__ +#ifdef OF_WII addr->sin_len = 8; #endif addr->sin_family = AF_INET; addr->sin_port = OF_BSWAP16_IF_LE(port); addr->sin_addr.s_addr = s_addr; @@ -174,11 +174,11 @@ tmp->family = AF_INET; tmp->type = type; tmp->protocol = 0; tmp->address = (struct sockaddr*)addr; -#ifndef __wii__ +#ifndef OF_WII tmp->addressLength = sizeof(*addr); #else tmp->addressLength = 8; #endif Index: src/runtime/exception.m ================================================================== --- src/runtime/exception.m +++ src/runtime/exception.m @@ -22,10 +22,12 @@ #ifdef HAVE_SEH_EXCEPTIONS # include #endif #import "runtime.h" + +#import "macros.h" #if defined(HAVE_DWARF_EXCEPTIONS) # define PERSONALITY __gnu_objc_personality_v0 #elif defined(HAVE_SJLJ_EXCEPTIONS) # define PERSONALITY __gnu_objc_personality_sj0 @@ -84,11 +86,11 @@ struct objc_exception { struct _Unwind_Exception { uint64_t class; void (*cleanup)(_Unwind_Reason_Code, struct _Unwind_Exception*); -#if defined(__arm__) || defined(__ARM__) +#ifdef OF_ARM /* From "Exception Handling ABI for the ARM(R) Architecture" */ struct { uint32_t reserved1, reserved2, reserved3, reserved4; uint32_t reserved; } unwinder_cache; @@ -117,11 +119,11 @@ uint64_t private1, private2; # endif #endif } exception; id object; -#if !defined(__arm__) && !defined(__ARM__) +#ifndef OF_ARM uintptr_t landingpad; intptr_t filter; #endif }; @@ -139,11 +141,11 @@ extern void* _Unwind_GetLanguageSpecificData(struct _Unwind_Context*); extern uintptr_t _Unwind_GetRegionStart(struct _Unwind_Context*); extern uintptr_t _Unwind_GetDataRelBase(struct _Unwind_Context*); extern uintptr_t _Unwind_GetTextRelBase(struct _Unwind_Context*); -#if defined(__arm__) || defined(__ARM__) +#ifdef OF_ARM extern _Unwind_Reason_Code __gnu_unwind_frame(struct _Unwind_Exception*, struct _Unwind_Context*); extern int _Unwind_VRS_Get(struct _Unwind_Context*, int, uint32_t, int, void*); extern int _Unwind_VRS_Set(struct _Unwind_Context*, int, uint32_t, int, void*); @@ -312,11 +314,11 @@ #undef READ return value; } -#if !defined(__arm__) && !defined(__ARM__) +#ifndef OF_ARM static uint64_t resolve_value(uint64_t value, uint8_t enc, const uint8_t *start, uint64_t base) { if (value == 0) return 0; @@ -459,17 +461,17 @@ Class class; const char *className; uintptr_t c; const uint8_t *tmp; -#if defined(__arm__) || defined(__ARM__) +#ifdef OF_ARM tmp = lsda->typestable - (filter * 4); c = *(uintptr_t*)(void*)tmp; if (c != 0) { c += (uintptr_t)tmp; -# if defined(__linux__) || defined(__NetBSD__) +# if defined(OF_LINUX) || defined(OF_NETBSD) c = *(uintptr_t*)c; # endif } #else uintptr_t i; @@ -500,11 +502,11 @@ } while (displacement != 0); return 0; } -#if defined(__arm__) || defined(__ARM__) +#ifdef OF_ARM _Unwind_Reason_Code PERSONALITY(uint32_t state, struct _Unwind_Exception *ex, struct _Unwind_Context *ctx) { int version = 1; @@ -556,11 +558,11 @@ * For handlers, reg #0 must be the exception's object and reg * #1 the filter. */ _Unwind_SetGR(ctx, __builtin_eh_return_data_regno(0), (uintptr_t)e->object); -#if defined(__arm__) || defined(__ARM__) +#ifdef OF_ARM _Unwind_SetGR(ctx, __builtin_eh_return_data_regno(1), ex->barrier_cache.bitpattern[1]); _Unwind_SetIP(ctx, ex->barrier_cache.bitpattern[3]); #else _Unwind_SetGR(ctx, __builtin_eh_return_data_regno(1), @@ -594,11 +596,11 @@ if (actions & _UA_SEARCH_PHASE) { if (!(found & HANDLER_FOUND) || foreign) CONTINUE_UNWIND; /* Cache it so we don't have to search it again in phase 2 */ -#if defined(__arm__) || defined(__ARM__) +#ifdef OF_ARM ex->barrier_cache.sp = _Unwind_GetGR(ctx, 13); ex->barrier_cache.bitpattern[1] = filter; ex->barrier_cache.bitpattern[3] = landingpad; #else e->landingpad = landingpad; Index: src/runtime/lookup-asm/Makefile ================================================================== --- src/runtime/lookup-asm/Makefile +++ src/runtime/lookup-asm/Makefile @@ -5,6 +5,6 @@ SRCS = lookup-asm.S include ../../../buildsys.mk -ASFLAGS += -I../../.. +ASFLAGS += -I../../.. -I../.. Index: src/runtime/lookup-asm/lookup-asm-arm-elf.S ================================================================== --- src/runtime/lookup-asm/lookup-asm-arm-elf.S +++ src/runtime/lookup-asm/lookup-asm-arm-elf.S @@ -13,10 +13,12 @@ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" + +#include "platform.h" .globl objc_msg_lookup .globl objc_msg_lookup_stret .globl objc_msg_lookup_super .globl objc_msg_lookup_super_stret @@ -74,8 +76,8 @@ nil_method: mov r0, #0 bx lr -#ifdef __linux__ +#ifdef OF_LINUX .section .note.GNU-stack, "", %progbits #endif Index: src/runtime/lookup-asm/lookup-asm-mips-elf.S ================================================================== --- src/runtime/lookup-asm/lookup-asm-mips-elf.S +++ src/runtime/lookup-asm/lookup-asm-mips-elf.S @@ -13,10 +13,12 @@ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" + +#include "platform.h" .globl objc_msg_lookup .globl objc_msg_lookup_stret .globl objc_msg_lookup_super .globl objc_msg_lookup_super_stret @@ -28,24 +30,22 @@ lw $t0, 0($a0) lw $t0, 32($t0) .Lmain_\name: -#if defined(__MIPSEL__) -# ifdef OF_SELUID24 - lbu $t1, 2($a1) -# endif - lbu $t2, 1($a1) - lbu $t3, 0($a1) -#elif defined(__MIPSEB__) +#ifdef OF_BIGENDIAN # ifdef OF_SELUID24 lbu $t1, 1($a1) # endif lbu $t2, 2($a1) lbu $t3, 3($a1) #else -# error Neither __MIPSEL__ nor __MIPSEB__ defined! +# ifdef OF_SELUID24 + lbu $t1, 2($a1) +# endif + lbu $t2, 1($a1) + lbu $t3, 0($a1) #endif #ifdef OF_SELUID24 sll $t1, $t1, 2 #endif @@ -59,28 +59,28 @@ addu $t0, $t0, $t2 lw $t0, 0($t0) addu $t0, $t0, $t3 lw $t0, 0($t0) -#ifdef __PIC__ +#ifdef OF_PIC beqz $t0, 1f #else beqz $t0, \not_found #endif move $v0, $t0 j $ra 0: -#ifdef __PIC__ +#ifdef OF_PIC addiu $v0, $t9, nil_method-\name #else la $v0, nil_method #endif j $ra -#ifdef __PIC__ +#ifdef OF_PIC 1: lui $gp, %hi(_gp_disp) addiu $gp, $gp, %lo(_gp_disp) addu $gp, $gp, $t9 addiu $gp, $gp, 1b-\name @@ -101,11 +101,11 @@ lw $t0, 32($t0) b .Lmain_\lookup 0: -#ifdef __PIC__ +#ifdef OF_PIC addiu $v0, $t9, nil_method-\name #else la $v0, nil_method #endif j $ra @@ -120,8 +120,8 @@ nil_method: move $v0, $zero j $ra -#ifdef __linux__ +#ifdef OF_LINUX .section .note.GNU-stack, "", %progbits #endif Index: src/runtime/lookup-asm/lookup-asm-ppc-elf.S ================================================================== --- src/runtime/lookup-asm/lookup-asm-ppc-elf.S +++ src/runtime/lookup-asm/lookup-asm-ppc-elf.S @@ -13,10 +13,12 @@ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" + +#include "platform.h" .globl objc_msg_lookup .globl objc_msg_lookup_stret .globl objc_msg_lookup_super .globl objc_msg_lookup_super_stret @@ -89,8 +91,8 @@ get_pc: mflr %r3 blr -#ifdef __linux__ +#ifdef OF_LINUX .section .note.GNU-stack, "", %progbits #endif Index: src/runtime/lookup-asm/lookup-asm-sparc-elf.S ================================================================== --- src/runtime/lookup-asm/lookup-asm-sparc-elf.S +++ src/runtime/lookup-asm/lookup-asm-sparc-elf.S @@ -13,10 +13,12 @@ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" + +#include "platform.h" .globl objc_msg_lookup .globl objc_msg_lookup_stret .globl objc_msg_lookup_super .globl objc_msg_lookup_super_stret @@ -102,8 +104,8 @@ nil_method: retl clr %o0 -#ifdef __linux__ +#ifdef OF_LINUX .section .note.GNU-stack, "", %progbits #endif Index: src/runtime/lookup-asm/lookup-asm-x86-elf.S ================================================================== --- src/runtime/lookup-asm/lookup-asm-x86-elf.S +++ src/runtime/lookup-asm/lookup-asm-x86-elf.S @@ -13,10 +13,12 @@ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" + +#include "platform.h" .globl objc_msg_lookup .globl objc_msg_lookup_stret .globl objc_msg_lookup_super .globl objc_msg_lookup_super_stret @@ -88,8 +90,8 @@ get_eip: movl (%esp), %eax ret -#ifdef __linux__ +#ifdef OF_LINUX .section .note.GNU-stack, "", %progbits #endif Index: src/runtime/lookup-asm/lookup-asm-x86_64-elf.S ================================================================== --- src/runtime/lookup-asm/lookup-asm-x86_64-elf.S +++ src/runtime/lookup-asm/lookup-asm-x86_64-elf.S @@ -13,10 +13,12 @@ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" + +#include "platform.h" .globl objc_msg_lookup .globl objc_msg_lookup_stret .globl objc_msg_lookup_super .globl objc_msg_lookup_super_stret @@ -74,8 +76,8 @@ nil_method: xorq %rax, %rax ret -#ifdef __linux__ +#ifdef OF_LINUX .section .note.GNU-stack, "", %progbits #endif Index: src/runtime/lookup-asm/lookup-asm.S ================================================================== --- src/runtime/lookup-asm/lookup-asm.S +++ src/runtime/lookup-asm/lookup-asm.S @@ -14,33 +14,34 @@ * file. */ #include "config.h" -#if defined(__ELF__) -# if defined(__x86_64__) || defined(__amd64__) +#include "platform.h" + +#if defined(OF_ELF) +# if defined(OF_X86_64) # include "lookup-asm-x86_64-elf.S" -# elif defined(__i386__) +# elif defined(OF_X86) # include "lookup-asm-x86-elf.S" -# elif defined(__arm__) || defined(__ARM__) +# elif defined(OF_ARM) # include "lookup-asm-arm-elf.S" -# elif defined(__ppc__) || defined(__PPC__) +# elif defined(OF_POWERPC) # include "lookup-asm-ppc-elf.S" -# elif (defined(_MIPS_SIM) && _MIPS_SIM == _ABIO32) || \ - (defined(__mips_eabi) && _MIPS_SZPTR == 32) +# elif defined(OF_MIPS) # include "lookup-asm-mips-elf.S" -# elif defined(__sparc__) && !defined(__arch64__) +# elif defined(OF_SPARC) # include "lookup-asm-sparc-elf.S" # endif -#elif defined(__MACH__) -# if defined(__x86_64__) +#elif defined(OF_MACH_O) +# if defined(OF_X86_64) # include "lookup-asm-x86_64-macho.S" -# elif defined(__ppc__) +# elif defined(OF_POWERPC) # include "lookup-asm-ppc-macho.S" # endif -#elif defined(_WIN32) -# if defined(__x86_64__) +#elif defined(OF_WINDOWS) +# if defined(OF_X86_64) # include "lookup-asm-x86_64-win64.S" -# elif defined(__i386__) +# elif defined(OF_X86) # include "lookup-asm-x86-win32.S" # endif #endif Index: src/runtime/runtime-private.h ================================================================== --- src/runtime/runtime-private.h +++ src/runtime/runtime-private.h @@ -13,10 +13,12 @@ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" + +#include "platform.h" struct objc_abi_class { struct objc_abi_class *metaclass; const char *superclass; const char *name; @@ -180,29 +182,21 @@ return dtable->buckets[i]->buckets[j]; #endif } -#if defined(__ELF__) -# if defined(__x86_64__) || defined(__amd64__) || defined(__i386__) || \ - defined(__ppc__) || defined(__PPC__) || defined(__arm__) || \ - defined(__ARM__) -# define OF_ASM_LOOKUP -# endif -# if (defined(_MIPS_SIM) && _MIPS_SIM == _ABIO32) || \ - (defined(__mips_eabi) && _MIPS_SZPTR == 32) -# define OF_ASM_LOOKUP -# endif -# if defined(__sparc__) && !defined(__arch64__) -# define OF_ASM_LOOKUP -# endif -#elif defined(__MACH__) -# if defined(__x86_64__) || defined(__ppc__) -# define OF_ASM_LOOKUP -# endif -#elif defined(_WIN32) -# if defined(__x86_64__) || defined(__i386__) +#if defined(OF_ELF) +# if defined(OF_X86_64) || defined(OF_X86) || defined(OF_POWERPC) || \ + defined(OF_ARM) || defined(OF_MIPS) || defined(OF_SPARC) +# define OF_ASM_LOOKUP +# endif +#elif defined(OF_MACH_O) +# if defined(OF_X86_64) || defined(OF_POWERPC) +# define OF_ASM_LOOKUP +# endif +#elif defined(OF_WINDOWS) +# if defined(OF_X86_64) || defined(OF_X86) # define OF_ASM_LOOKUP # endif #endif #define OBJC_ERROR(...) \ Index: src/socket.h ================================================================== --- src/socket.h +++ src/socket.h @@ -12,11 +12,11 @@ * 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. */ -#import "objfw-defs.h" +#include "objfw-defs.h" #ifndef OF_HAVE_SOCKETS # error No sockets available! #endif @@ -30,11 +30,13 @@ #endif #ifdef OF_HAVE_NETINET_TCP_H # include #endif -#ifdef _WIN32 +#include "platform.h" + +#ifdef OF_WINDOWS # ifdef __MINGW32__ # include <_mingw.h> # ifdef __MINGW64_VERSION_MAJOR # include # endif @@ -41,11 +43,11 @@ # endif # include # include #endif -#ifdef __wii__ +#ifdef OF_WII # define BOOL OGC_BOOL # include # undef BOOL struct sockaddr_storage { @@ -53,11 +55,11 @@ u8 ss_family; u8 ss_data[14]; }; #endif -#ifdef _PSP +#ifdef OF_PSP # include struct sockaddr_storage { uint8_t ss_len; sa_family_t ss_family; @@ -69,11 +71,11 @@ #import "macros.h" OF_ASSUME_NONNULL_BEGIN -#ifndef _WIN32 +#ifndef OF_WINDOWS typedef int of_socket_t; #else typedef SOCKET of_socket_t; #endif @@ -80,11 +82,11 @@ #ifdef __cplusplus extern "C" { #endif extern bool of_socket_init(void); extern int of_socket_errno(void); -# ifndef __wii__ +# ifndef OF_WII extern int of_getsockname(of_socket_t socket, struct sockaddr *restrict address, socklen_t *restrict address_len); # else extern bool of_socket_port_register(uint16_t port, int type); extern void of_socket_port_free(uint16_t port, int type); Index: src/socket.m ================================================================== --- src/socket.m +++ src/socket.m @@ -30,35 +30,35 @@ static of_once_t onceControl = OF_ONCE_INIT; static of_mutex_t mutex; #endif static bool initialized = false; -#ifdef __wii__ +#ifdef OF_WII # ifdef OF_HAVE_THREADS static of_spinlock_t spinlock; # endif static uint8_t portRegistry[2][65536 / 8]; #endif static void init(void) { -#if defined(_WIN32) +#if defined(OF_WINDOWS) WSADATA wsa; if (WSAStartup(MAKEWORD(2, 0), &wsa)) return; -#elif defined(__wii__) +#elif defined(OF_WII) if (net_init() < 0) return; #endif #ifdef OF_HAVE_THREADS if (!of_mutex_new(&mutex)) return; -# ifdef __wii__ +# ifdef OF_WII if (!of_spinlock_new(&spinlock)) return; # endif #endif @@ -79,11 +79,11 @@ } int of_socket_errno() { -#ifndef _WIN32 +#ifndef OF_WINDOWS return errno; #else switch (WSAGetLastError()) { case WSAEACCES: return EACCES; @@ -175,11 +175,11 @@ return 0; #endif } -#ifndef __wii__ +#ifndef OF_WII int of_getsockname(of_socket_t socket, struct sockaddr *restrict address, socklen_t *restrict address_len) { int ret; Index: src/socket_helpers.h ================================================================== --- src/socket_helpers.h +++ src/socket_helpers.h @@ -11,10 +11,12 @@ * 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" /* Work around __block being used by glibc */ #ifdef __GLIBC__ # undef __USE_XOPEN #endif @@ -53,20 +55,20 @@ #ifndef SOCK_CLOEXEC # define SOCK_CLOEXEC 0 #endif -#ifdef _WIN32 +#ifdef OF_WINDOWS # define close(sock) closesocket(sock) #endif -#ifdef _PSP +#ifdef OF_PSP /* PSP defines AF_INET6, even though sockaddr_in6 is missing */ # undef AF_INET6 #endif -#ifdef __wii__ +#ifdef OF_WII # define accept(sock, addr, addrlen) net_accept(sock, addr, addrlen) # define bind(sock, addr, addrlen) net_bind(sock, addr, addrlen) # define close(sock) net_close(sock) # define connect(sock, addr, addrlen) net_connect(sock, addr, addrlen) # define gethostbyname(name) net_gethostbyname(name) Index: src/threading.h ================================================================== --- src/threading.h +++ src/threading.h @@ -12,14 +12,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. */ -#import "objfw-defs.h" +#include "objfw-defs.h" + +#include "platform.h" #if !defined(OF_HAVE_THREADS) || \ - (!defined(OF_HAVE_PTHREADS) && !defined(_WIN32)) + (!defined(OF_HAVE_PTHREADS) && !defined(OF_WINDOWS)) # error No threads available! #endif #include @@ -32,11 +34,11 @@ typedef pthread_key_t of_tlskey_t; typedef pthread_mutex_t of_mutex_t; typedef pthread_cond_t of_condition_t; typedef pthread_once_t of_once_t; # define OF_ONCE_INIT PTHREAD_ONCE_INIT -#elif defined(_WIN32) +#elif defined(OF_WINDOWS) /* * winsock2.h needs to be included before windows.h. Not including it here * would make it impossible to use sockets after threading.h has been * imported. */ @@ -69,11 +71,11 @@ #ifdef OF_HAVE_SCHED_YIELD # include #endif -#if defined(OF_HAVE_RECURSIVE_PTHREAD_MUTEXES) || defined(_WIN32) +#if defined(OF_HAVE_RECURSIVE_PTHREAD_MUTEXES) || defined(OF_WINDOWS) # define of_rmutex_t of_mutex_t #else typedef struct { of_mutex_t mutex; of_tlskey_t count; @@ -86,11 +88,11 @@ } of_thread_attr_t; #if defined(OF_HAVE_PTHREADS) # define of_thread_is_current(t) pthread_equal(t, pthread_self()) # define of_thread_current pthread_self -#elif defined(_WIN32) +#elif defined(OF_WINDOWS) # define of_thread_is_current(t) (t == GetCurrentThread()) # define of_thread_current GetCurrentThread #else # error of_thread_is_current not implemented! # error of_thread_current not implemented! @@ -127,11 +129,11 @@ static OF_INLINE bool of_tlskey_new(of_tlskey_t *key) { #if defined(OF_HAVE_PTHREADS) return !pthread_key_create(key, NULL); -#elif defined(_WIN32) +#elif defined(OF_WINDOWS) return ((*key = TlsAlloc()) != TLS_OUT_OF_INDEXES); #else # error of_tlskey_new not implemented! #endif } @@ -139,11 +141,11 @@ static OF_INLINE void* of_tlskey_get(of_tlskey_t key) { #if defined(OF_HAVE_PTHREADS) return pthread_getspecific(key); -#elif defined(_WIN32) +#elif defined(OF_WINDOWS) return TlsGetValue(key); #else # error of_tlskey_get not implemented! #endif } @@ -151,11 +153,11 @@ static OF_INLINE bool of_tlskey_set(of_tlskey_t key, void *ptr) { #if defined(OF_HAVE_PTHREADS) return !pthread_setspecific(key, ptr); -#elif defined(_WIN32) +#elif defined(OF_WINDOWS) return TlsSetValue(key, ptr); #else # error of_tlskey_set not implemented! #endif } @@ -163,11 +165,11 @@ static OF_INLINE bool of_tlskey_free(of_tlskey_t key) { #if defined(OF_HAVE_PTHREADS) return !pthread_key_delete(key); -#elif defined(_WIN32) +#elif defined(OF_WINDOWS) return TlsFree(key); #else # error of_tlskey_free not implemented! #endif } @@ -199,19 +201,19 @@ static OF_INLINE bool of_spinlock_lock(of_spinlock_t *spinlock) { #if defined(OF_HAVE_ATOMIC_OPS) -# if defined(OF_HAVE_SCHED_YIELD) || defined(_WIN32) +# if defined(OF_HAVE_SCHED_YIELD) || defined(OF_WINDOWS) int i; for (i = 0; i < OF_SPINCOUNT; i++) if (of_spinlock_trylock(spinlock)) return true; while (!of_spinlock_trylock(spinlock)) -# ifndef _WIN32 +# ifndef OF_WINDOWS sched_yield(); # else Sleep(0); # endif # else Index: src/threading.m ================================================================== --- src/threading.m +++ src/threading.m @@ -18,17 +18,17 @@ #import "threading.h" #if defined(OF_HAVE_PTHREADS) # include "threading_pthread.m" -#elif defined(_WIN32) +#elif defined(OF_WINDOWS) # include "threading_winapi.m" #else # error No threads available! #endif -#ifdef __HAIKU__ +#ifdef OF_HAIKU # include #endif bool of_rmutex_new(of_rmutex_t *rmutex) @@ -47,11 +47,11 @@ if (pthread_mutexattr_destroy(&attr) != 0) return false; return true; -#elif defined(_WIN32) +#elif defined(OF_WINDOWS) return of_mutex_new(rmutex); #else if (!of_mutex_new(&rmutex->mutex)) return false; @@ -63,11 +63,11 @@ } bool of_rmutex_lock(of_rmutex_t *rmutex) { -#if defined(OF_HAVE_RECURSIVE_PTHREAD_MUTEXES) || defined(_WIN32) +#if defined(OF_HAVE_RECURSIVE_PTHREAD_MUTEXES) || defined(OF_WINDOWS) return of_mutex_lock(rmutex); #else uintptr_t count = (uintptr_t)of_tlskey_get(rmutex->count); if (count > 0) { @@ -90,11 +90,11 @@ } bool of_rmutex_trylock(of_rmutex_t *rmutex) { -#if defined(OF_HAVE_RECURSIVE_PTHREAD_MUTEXES) || defined(_WIN32) +#if defined(OF_HAVE_RECURSIVE_PTHREAD_MUTEXES) || defined(OF_WINDOWS) return of_mutex_trylock(rmutex); #else uintptr_t count = (uintptr_t)of_tlskey_get(rmutex->count); if (count > 0) { @@ -117,11 +117,11 @@ } bool of_rmutex_unlock(of_rmutex_t *rmutex) { -#if defined(OF_HAVE_RECURSIVE_PTHREAD_MUTEXES) || defined(_WIN32) +#if defined(OF_HAVE_RECURSIVE_PTHREAD_MUTEXES) || defined(OF_WINDOWS) return of_mutex_unlock(rmutex); #else uintptr_t count = (uintptr_t)of_tlskey_get(rmutex->count); if (count > 1) { @@ -142,11 +142,11 @@ } bool of_rmutex_free(of_rmutex_t *rmutex) { -#if defined(OF_HAVE_RECURSIVE_PTHREAD_MUTEXES) || defined(_WIN32) +#if defined(OF_HAVE_RECURSIVE_PTHREAD_MUTEXES) || defined(OF_WINDOWS) return of_mutex_free(rmutex); #else if (!of_mutex_free(&rmutex->mutex)) return false; Index: src/threading_pthread.m ================================================================== --- src/threading_pthread.m +++ src/threading_pthread.m @@ -11,14 +11,18 @@ * 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" #ifdef HAVE_PTHREAD_NP_H # include #endif + +#import "macros.h" struct thread_ctx { void (*function)(id object); id object; }; @@ -161,16 +165,16 @@ } void of_thread_set_name(of_thread_t thread, const char *name) { -#if defined(__HAIKU__) +#if defined(OF_HAIKU) rename_thread(get_pthread_thread_id(thread), name); #elif defined(HAVE_PTHREAD_SET_NAME_NP) pthread_set_name_np(pthread_self(), name); #elif defined(HAVE_PTHREAD_SETNAME_NP) -# if defined(__APPLE__) +# if defined(OF_MAC_OS_X) || defined(OF_IOS) pthread_setname_np(name); # elif defined(__GLIBC__) char buffer[16]; strncpy(buffer, name, 15); Index: src/threading_winapi.m ================================================================== --- src/threading_winapi.m +++ src/threading_winapi.m @@ -11,10 +11,14 @@ * 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" + +#import "macros.h" bool of_thread_attr_init(of_thread_attr_t *attr) { attr->priority = Index: tests/ForwardingTests.m ================================================================== --- tests/ForwardingTests.m +++ tests/ForwardingTests.m @@ -210,11 +210,12 @@ [[t forwardingTargetVarArgTest: FMT, ARGS] isEqual: RESULT]) /* * Don't try fpret on Win64 if we don't have stret forwarding, as * long double is handled as a struct there. */ -# if !defined(_WIN64) || defined(OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR_STRET) +# if !defined(OF_WINDOWS) || !defined(OF_X86_64) || \ + defined(OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR_STRET) TEST(@"-[forwardingTargetForSelector:] fp return", [t forwardingTargetFPRetTest] == 12345678.00006103515625) # endif # ifdef OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR_STRET TEST(@"-[forwardingTargetForSelector:] struct return", Index: tests/OFINIFileTests.m ================================================================== --- tests/OFINIFileTests.m +++ tests/OFINIFileTests.m @@ -24,11 +24,11 @@ #import "OFFileManager.h" #import "OFAutoreleasePool.h" #import "TestsAppDelegate.h" -#ifdef _WIN32 +#if defined(OF_WINDOWS) || defined(OF_MSDOS) # define NL @"\r\n" #else # define NL @"\n" #endif Index: tests/OFKernelEventObserverTests.m ================================================================== --- tests/OFKernelEventObserverTests.m +++ tests/OFKernelEventObserverTests.m @@ -20,14 +20,14 @@ #import "OFString.h" #import "OFDate.h" #import "OFTCPSocket.h" #import "OFAutoreleasePool.h" -#if defined(HAVE_SYS_SELECT_H) || defined(_WIN32) +#if defined(HAVE_SYS_SELECT_H) || defined(OF_WINDOWS) # import "OFKernelEventObserver_select.h" #endif -#if defined(HAVE_POLL_H) || defined(__wii__) +#if defined(HAVE_POLL_H) || defined(OF_WII) # import "OFKernelEventObserver_poll.h" #endif #ifdef HAVE_EPOLL # import "OFKernelEventObserver_epoll.h" #endif @@ -210,16 +210,16 @@ - (void)kernelEventObserverTests { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; -#if defined(HAVE_SYS_SELECT_H) || defined(_WIN32) +#if defined(HAVE_SYS_SELECT_H) || defined(OF_WINDOWS) [self kernelEventObserverTestsWithClass: [OFKernelEventObserver_select class]]; #endif -#if defined(HAVE_POLL_H) || defined(__wii__) +#if defined(HAVE_POLL_H) || defined(OF_WII) [self kernelEventObserverTestsWithClass: [OFKernelEventObserver_poll class]]; #endif #ifdef HAVE_EPOLL Index: tests/OFObjectTests.m ================================================================== --- tests/OFObjectTests.m +++ tests/OFObjectTests.m @@ -22,11 +22,11 @@ #import "OFMemoryNotPartOfObjectException.h" #import "OFOutOfMemoryException.h" #import "TestsAppDelegate.h" -#if defined(__DragonFly__) && defined(__LP64__) +#if defined(OF_DRAGONFLYBSD) && defined(__LP64__) # define TOO_BIG (SIZE_MAX / 3) #else # define TOO_BIG (SIZE_MAX - 128) #endif Index: tests/OFStringTests.m ================================================================== --- tests/OFStringTests.m +++ tests/OFStringTests.m @@ -347,11 +347,11 @@ [a count] == 3 && [[a objectAtIndex: i++] isEqual: @"foo"] && [[a objectAtIndex: i++] isEqual: @"bar"] && [[a objectAtIndex: i++] isEqual: @"baz"]) -#if !defined(_WIN32) && !defined(__DJGPP__) +#if !defined(OF_WINDOWS) && !defined(OF_MSDOS) # define EXPECTED @"foo/bar/baz" #else # define EXPECTED @"foo\\bar\\baz" #endif TEST(@"+[pathWithComponents:]", @@ -411,11 +411,11 @@ isEqual: @"/tmp"] && [[@"foo/bar" stringByDeletingLastPathComponent] isEqual: @"foo"] && [[@"/" stringByDeletingLastPathComponent] isEqual: @"/"] && [[@"foo" stringByDeletingLastPathComponent] isEqual: @"."]) -#if !defined(_WIN32) && !defined(__DJGPP__) +#if !defined(OF_WINDOWS) && !defined(OF_MSDOS) # define EXPECTED @"/foo./bar" #else # define EXPECTED @"\\foo.\\bar" #endif TEST(@"-[stringByDeletingPathExtension]", @@ -451,16 +451,16 @@ TEST(@"-[floatValue]", [@"\t-0.25 " floatValue] == -0.25 && [@"\r-INFINITY\n" floatValue] == -INFINITY && isnan([@" NAN\t\t" floatValue])) -#if !defined(__ANDROID__) && !defined(__sun__) && !defined(__DJGPP__) +#if !defined(__ANDROID__) && !defined(OF_SOLARIS) && !defined(__DJGPP__) # define INPUT @"\t-0x1.FFFFFFFFFFFFFP-1020 " # define EXPECTED -0x1.FFFFFFFFFFFFFP-1020 #else /* Android, Solaris and DJGPP do not accept 0x for strtod() */ -# if !defined(__sun__) || !defined(__i386__) +# if !defined(OF_SOLARIS) || !defined(OF_X86) # define INPUT @"\t-0.123456789 " # define EXPECTED -0.123456789 # else /* Solaris' strtod() has weird rounding on x86, but not on x86_64 */ # define INPUT @"\t-0.125 " Index: tests/TestsAppDelegate.m ================================================================== --- tests/TestsAppDelegate.m +++ tests/TestsAppDelegate.m @@ -20,24 +20,24 @@ #import "ObjFW.h" #import "TestsAppDelegate.h" -#if defined(STDOUT) && (defined(_WIN32) || defined(__DJGPP__)) +#if defined(STDOUT) && (defined(OF_WINDOWS) || defined(OF_MSDOS)) # undef STDOUT # define STDOUT_SIMPLE #endif -#ifdef _PSP +#ifdef OF_PSP # include # include # include # include PSP_MODULE_INFO("ObjFW Tests", 0, 0, 0); #endif -#ifdef __wii__ +#ifdef OF_WII # define BOOL OGC_BOOL # define asm __asm__ # include # include # undef BOOL @@ -55,11 +55,11 @@ RED, GREEN, YELLOW }; -#ifdef _PSP +#ifdef OF_PSP static int exit_cb(int arg1, int arg2, void *arg) { sceKernelExitGame(); @@ -78,23 +78,23 @@ #endif int main(int argc, char *argv[]) { -#ifdef _PSP +#ifdef OF_PSP int tid; #endif -#if defined(OF_OBJFW_RUNTIME) && !defined(_WIN32) +#if defined(OF_OBJFW_RUNTIME) && !defined(OF_WINDOWS) /* This does not work on Win32 if ObjFW is built as a DLL */ atexit(objc_exit); #endif /* We need deterministic hashes for tests */ of_hash_seed = 0; -#ifdef __wii__ +#ifdef OF_WII GXRModeObj *rmode; void *xfb; VIDEO_Init(); WPAD_Init(); @@ -112,11 +112,11 @@ CON_InitEx(rmode, 10, 20, rmode->fbWidth - 10, rmode->xfbHeight - 20); VIDEO_ClearFrameBuffer(rmode, xfb, COLOR_BLACK); #endif -#ifdef _PSP +#ifdef OF_PSP pspDebugScreenInit(); sceCtrlSetSamplingCycle(0); sceCtrlSetSamplingMode(PSP_CTRL_MODE_DIGITAL); @@ -127,11 +127,11 @@ #ifdef OF_NINTENDO_DS consoleDemoInit(); #endif -#if defined(__wii__) || defined(_PSP) || defined(OF_NINTENDO_DS) +#if defined(OF_WII) || defined(OF_PSP) || defined(OF_NINTENDO_DS) @try { return of_application_main(&argc, &argv, [TestsAppDelegate class]); } @catch (id e) { TestsAppDelegate *delegate = @@ -144,11 +144,11 @@ [delegate outputString: string inColor: RED]; [delegate outputString: backtrace inColor: RED]; -# if defined(__wii__) +# if defined(OF_WII) [delegate outputString: @"Press home button to exit!\n" inColor: NO_COLOR]; for (;;) { WPAD_ScanPads(); @@ -155,11 +155,11 @@ if (WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) [OFApplication terminateWithStatus: 1]; VIDEO_WaitVSync(); } -# elif defined(_PSP) +# elif defined(OF_PSP) sceKernelSleepThreadCB(); # elif defined(OF_NINTENDO_DS) [delegate outputString: @"Press start button to exit!" inColor: NO_COLOR]; for (;;) { @@ -179,11 +179,11 @@ @implementation TestsAppDelegate - (void)outputString: (OFString*)str inColor: (int)color { -#if defined(_PSP) +#if defined(OF_PSP) char i, space = ' '; int y = pspDebugScreenGetY(); pspDebugScreenSetXY(0, y); for (i = 0; i < 68; i++) @@ -208,11 +208,11 @@ pspDebugScreenPrintData([str UTF8String], [str UTF8StringLength]); #elif defined(STDOUT) switch (color) { case NO_COLOR: [of_stdout writeString: @"\r\033[K"]; -# if defined(__wii__) || defined(OF_NINTENDO_DS) +# if defined(OF_WII) || defined(OF_NINTENDO_DS) [of_stdout writeString: @"\033[37m"]; # endif break; case RED: [of_stdout writeString: @"\r\033[K\033[31;1m"]; @@ -273,11 +273,11 @@ [self outputString: [OFString stringWithFormat: @"[%@] %@: failed\n", module, test] inColor: RED]; [pool release]; -# ifdef __wii__ +# ifdef OF_WII [self outputString: @"Press A to continue!\n" inColor: NO_COLOR]; for (;;) { WPAD_ScanPads(); @@ -285,11 +285,11 @@ return; VIDEO_WaitVSync(); } # endif -# ifdef _PSP +# ifdef OF_PSP [self outputString: @"Press X to continue!\n" inColor: NO_COLOR]; for (;;) { SceCtrlData pad; @@ -319,11 +319,11 @@ #endif } - (void)applicationDidFinishLaunching { -#if defined(__wii__) && defined(OF_HAVE_FILES) +#if defined(OF_WII) && defined(OF_HAVE_FILES) [[OFFileManager defaultManager] changeCurrentDirectoryPath: @"/apps/objfw-tests"]; #endif [self objectTests]; @@ -374,11 +374,11 @@ [self forwardingTests]; #ifdef OF_HAVE_PROPERTIES [self propertiesTests]; #endif -#if defined(__wii__) +#if defined(OF_WII) [self outputString: @"Press home button to exit!\n" inColor: NO_COLOR]; for (;;) { WPAD_ScanPads(); @@ -385,11 +385,11 @@ if (WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) [OFApplication terminateWithStatus: _fails]; VIDEO_WaitVSync(); } -#elif defined(_PSP) +#elif defined(OF_PSP) [self outputString: [OFString stringWithFormat: @"%d tests failed!", _fails] inColor: NO_COLOR]; sceKernelSleepThreadCB(); #elif defined(OF_NINTENDO_DS) Index: utils/ofzip/OFZIP.m ================================================================== --- utils/ofzip/OFZIP.m +++ utils/ofzip/OFZIP.m @@ -312,11 +312,11 @@ if (!all && ![files containsObject: fileName]) continue; [missing removeObject: fileName]; -#ifndef _WIN32 +#if !defined(OF_WINDOWS) && !defined(OF_MSDOS) if ([outFileName hasPrefix: @"/"]) { #else if ([outFileName hasPrefix: @"/"] || [outFileName containsString: @":"]) { #endif