Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Add platform.h & make platform defines consistent |
|---|---|
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
1ba08eebc50c52142681374191e2437a |
| User & Date: | js 2015-10-19 22:15:13.000 |
Context
|
2015-10-24
| ||
| 20:53 | OFSystemInfo.h: Use OF_X86 rather than OF_X86_ASM check-in: 952af5f0aa user: js tags: trunk | |
|
2015-10-19
| ||
| 22:15 | Add platform.h & make platform defines consistent check-in: 1ba08eebc5 user: js tags: trunk | |
|
2015-10-18
| ||
| 09:22 | Remove +[OFSystemInfo supports{AltiVec,MXU}] check-in: de7e038127 user: js tags: trunk | |
Changes
Changes to ObjFW.xcodeproj/project.pbxproj.
| ︙ | ︙ | |||
458 459 460 461 462 463 464 465 466 467 468 469 470 471 |
4BF33B10133807A20059CEF7 /* OFXMLParserTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B6EF67E1235358D0076B512 /* OFXMLParserTests.m */; };
4BF33B11133807A20059CEF7 /* PropertiesTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B6EF67F1235358D0076B512 /* PropertiesTests.m */; };
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 */; };
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 */
4B23CA8E133811B20047A1D9 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
| > | 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 |
4BF33B10133807A20059CEF7 /* OFXMLParserTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B6EF67E1235358D0076B512 /* OFXMLParserTests.m */; };
4BF33B11133807A20059CEF7 /* PropertiesTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B6EF67F1235358D0076B512 /* PropertiesTests.m */; };
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 */
4B23CA8E133811B20047A1D9 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
|
| ︙ | ︙ | |||
981 982 983 984 985 986 987 988 989 990 991 992 993 994 |
4BF1BCCE11C9663F0025511F /* OFXMLAttribute.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFXMLAttribute.h; path = src/OFXMLAttribute.h; sourceTree = "<group>"; };
4BF1BCCF11C9663F0025511F /* OFXMLAttribute.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFXMLAttribute.m; path = src/OFXMLAttribute.m; sourceTree = "<group>"; };
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 = "<group>"; };
4BF33B4313380CD40059CEF7 /* testfile.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = testfile.txt; path = tests/testfile.txt; sourceTree = "<group>"; };
4BF48CDF18A95F83000E8D04 /* OFBigDataArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFBigDataArray.h; path = src/OFBigDataArray.h; sourceTree = "<group>"; };
4BF48CE018A95F83000E8D04 /* OFBigDataArray.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFBigDataArray.m; path = src/OFBigDataArray.m; sourceTree = "<group>"; };
4BFBDD1610A0724800051AFB /* unicode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = unicode.m; path = src/unicode.m; sourceTree = "<group>"; };
4BFF3710177E17C100192782 /* OFRemoveItemFailedException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFRemoveItemFailedException.h; path = src/exceptions/OFRemoveItemFailedException.h; sourceTree = "<group>"; };
4BFF3711177E17C100192782 /* OFRemoveItemFailedException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFRemoveItemFailedException.m; path = src/exceptions/OFRemoveItemFailedException.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
4B187E0A163EA29F0049A832 /* Frameworks */ = {
| > | 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 |
4BF1BCCE11C9663F0025511F /* OFXMLAttribute.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFXMLAttribute.h; path = src/OFXMLAttribute.h; sourceTree = "<group>"; };
4BF1BCCF11C9663F0025511F /* OFXMLAttribute.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFXMLAttribute.m; path = src/OFXMLAttribute.m; sourceTree = "<group>"; };
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 = "<group>"; };
4BF33B4313380CD40059CEF7 /* testfile.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = testfile.txt; path = tests/testfile.txt; sourceTree = "<group>"; };
4BF48CDF18A95F83000E8D04 /* OFBigDataArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFBigDataArray.h; path = src/OFBigDataArray.h; sourceTree = "<group>"; };
4BF48CE018A95F83000E8D04 /* OFBigDataArray.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFBigDataArray.m; path = src/OFBigDataArray.m; sourceTree = "<group>"; };
4BF69CE51BD44F8B00DFFC1B /* platform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = platform.h; path = src/platform.h; sourceTree = "<group>"; };
4BFBDD1610A0724800051AFB /* unicode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = unicode.m; path = src/unicode.m; sourceTree = "<group>"; };
4BFF3710177E17C100192782 /* OFRemoveItemFailedException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFRemoveItemFailedException.h; path = src/exceptions/OFRemoveItemFailedException.h; sourceTree = "<group>"; };
4BFF3711177E17C100192782 /* OFRemoveItemFailedException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFRemoveItemFailedException.m; path = src/exceptions/OFRemoveItemFailedException.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
4B187E0A163EA29F0049A832 /* Frameworks */ = {
|
| ︙ | ︙ | |||
1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 | 4BE17AD812FD744C002CEB0B /* foundation-compat.m */, 4BBA36C511406AB700CBA3AC /* macros.h */, 4BF1BCBF11C9663F0025511F /* objfw-defs.h.in */, 4BB50DCF12F863C700C9393F /* of_asprintf.h */, 4BB50DD012F863C700C9393F /* of_asprintf.m */, 4BA355BC14879BF700442EF4 /* of_strptime.h */, 4BA355B914879BDD00442EF4 /* of_strptime.m */, 4B7769EB1895C07D00D12284 /* resolver.h */, 4B7769EC1895C07D00D12284 /* resolver.m */, 4B7DD58718943D4A00990FD6 /* socket.h */, 4B40EC1A189FE2650031E19E /* socket.m */, 4B7DD58118942FE200990FD6 /* socket_helpers.h */, 4B67998B1099E7C50041064A /* threading.h */, 4B3379CE1979326A0088E97E /* threading.m */, | > | 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 | 4BE17AD812FD744C002CEB0B /* foundation-compat.m */, 4BBA36C511406AB700CBA3AC /* macros.h */, 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 */, 4B67998B1099E7C50041064A /* threading.h */, 4B3379CE1979326A0088E97E /* threading.m */, |
| ︙ | ︙ | |||
1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 | 4B3D23E71337FCB000DD29B8 /* base64.h in Headers */, 4B837D7916829C5F007A3E83 /* block.h in Headers */, 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 */, 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 */, 4B90B7A0133AD87D00BD33CB /* OFAddressTranslationFailedException.h in Headers */, 4B17FF7F133A2D17003E6DCD /* OFAllocFailedException.h in Headers */, | > | 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 | 4B3D23E71337FCB000DD29B8 /* base64.h in Headers */, 4B837D7916829C5F007A3E83 /* block.h in Headers */, 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 */, 4B90B7A0133AD87D00BD33CB /* OFAddressTranslationFailedException.h in Headers */, 4B17FF7F133A2D17003E6DCD /* OFAllocFailedException.h in Headers */, |
| ︙ | ︙ |
Changes to configure.ac.
| ︙ | ︙ | |||
1002 1003 1004 1005 1006 1007 1008 | AS_IF([test x"$enable_static" = x"yes" \ -o x"$enable_shared" = x"no"], [ AC_SUBST(OBJFW_BRIDGE_STATIC_LIB, "libobjfw-bridge.a") ]) ]) ]) | < < < < < < | 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 |
AS_IF([test x"$enable_static" = x"yes" \
-o x"$enable_shared" = x"no"], [
AC_SUBST(OBJFW_BRIDGE_STATIC_LIB, "libobjfw-bridge.a")
])
])
])
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([
@interface OFConstantString
{
|
| ︙ | ︙ |
Changes to src/Makefile.
| ︙ | ︙ | |||
117 118 119 120 121 122 123 |
OFTLSSocket.h \
ObjFW.h \
autorelease.h \
${ATOMIC_H} \
block.h \
instance.h \
macros.h \
| | > | 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
OFTLSSocket.h \
ObjFW.h \
autorelease.h \
${ATOMIC_H} \
block.h \
instance.h \
macros.h \
objfw-defs.h \
platform.h
SRCS += OFArray_adjacent.m \
OFArray_adjacentSubarray.m \
OFCountedSet_hashtable.m \
OFDictionary_hashtable.m \
OFMutableArray_adjacent.m \
OFMutableDictionary_hashtable.m \
|
| ︙ | ︙ |
Changes to src/OFApplication.h.
| ︙ | ︙ | |||
59 60 61 62 63 64 65 | * @warning You are not allowed to send any messages inside this method, as * message dispatching is not signal-safe! You are only allowed to do * signal-safe operations like setting a variable or calling a * signal-safe function! */ - (void)applicationDidReceiveSIGINT; | | | 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | * @warning You are not allowed to send any messages inside this method, as * message dispatching is not signal-safe! You are only allowed to do * signal-safe operations like setting a variable or calling a * signal-safe function! */ - (void)applicationDidReceiveSIGINT; #ifndef OF_WINDOWS /*! * @brief A method which is called when the application received a SIGHUP. * * This signal is not available on Windows. * * @warning You are not allowed to send any messages inside this method, as * message dispatching is not signal-safe! You are only allowed to do |
| ︙ | ︙ | |||
119 120 121 122 123 124 125 | OFArray OF_GENERIC(OFString*) *_arguments; OFDictionary OF_GENERIC(OFString*, OFString*) *_environment; int *_argc; char ***_argv; @public id <OFApplicationDelegate> _delegate; void (*_SIGINTHandler)(id, SEL); | | | 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | OFArray OF_GENERIC(OFString*) *_arguments; OFDictionary OF_GENERIC(OFString*, OFString*) *_environment; int *_argc; char ***_argv; @public id <OFApplicationDelegate> _delegate; void (*_SIGINTHandler)(id, SEL); #ifndef OF_WINDOWS void (*_SIGHUPHandler)(id, SEL); void (*_SIGUSR1Handler)(id, SEL); void (*_SIGUSR2Handler)(id, SEL); #endif } #ifdef OF_HAVE_PROPERTIES |
| ︙ | ︙ |
Changes to src/OFApplication.m.
| ︙ | ︙ | |||
28 29 30 31 32 33 34 | #import "OFDictionary.h" #import "OFSystemInfo.h" #import "OFRunLoop.h" #import "OFRunLoop+Private.h" #import "OFThread.h" #import "OFThread+Private.h" | | | | | | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
#import "OFDictionary.h"
#import "OFSystemInfo.h"
#import "OFRunLoop.h"
#import "OFRunLoop+Private.h"
#import "OFThread.h"
#import "OFThread+Private.h"
#if defined(OF_MAC_OS_X)
# include <crt_externs.h>
#elif defined(OF_WINDOWS)
# include <windows.h>
extern int _CRT_glob;
extern void __wgetmainargs(int*, wchar_t***, wchar_t***, int, int*);
#elif !defined(OF_IOS)
extern char **environ;
#endif
#ifdef OF_PSP
# include <pspkerneltypes.h>
# include <psploadexec.h>
#endif
#ifdef OF_NINTENDO_DS
# define asm __asm__
# include <nds.h>
# undef asm
#endif
@interface OFApplication (OF_PRIVATE_CATEGORY)
- (void)OF_setArgumentCount: (int*)argc
andArgumentValues: (char**[])argv;
#ifdef OF_WINDOWS
- (void)OF_setArgumentCount: (int)argc
andWideArgumentValues: (wchar_t*[])argv;
#endif
- (void)OF_run;
@end
static OFApplication *app = nil;
|
| ︙ | ︙ | |||
81 82 83 84 85 86 87 |
static void \
handle##sig(int signal) \
{ \
app->_##sig##Handler(app->_delegate, \
@selector(applicationDidReceive##sig)); \
}
SIGNAL_HANDLER(SIGINT)
| | | | | 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
static void \
handle##sig(int signal) \
{ \
app->_##sig##Handler(app->_delegate, \
@selector(applicationDidReceive##sig)); \
}
SIGNAL_HANDLER(SIGINT)
#ifndef OF_WINDOWS
SIGNAL_HANDLER(SIGHUP)
SIGNAL_HANDLER(SIGUSR1)
SIGNAL_HANDLER(SIGUSR2)
#endif
#undef SIGNAL_HANDLER
int
of_application_main(int *argc, char **argv[], Class cls)
{
id <OFApplicationDelegate> delegate;
#ifdef OF_WINDOWS
wchar_t **wargv, **wenvp;
int wargc, si = 0;
#endif
if ([cls isSubclassOfClass: [OFApplication class]]) {
fprintf(stderr, "FATAL ERROR:\n Class %s is a subclass of "
"class OFApplication, but class\n %s was specified as "
"application delegate!\n Most likely, you wanted to "
"subclass OFObject instead or specified\n the wrong class "
"with OF_APPLICATION_DELEGATE().\n",
class_getName(cls), class_getName(cls));
exit(1);
}
app = [[OFApplication alloc] init];
[app OF_setArgumentCount: argc
andArgumentValues: argv];
#ifdef OF_WINDOWS
__wgetmainargs(&wargc, &wargv, &wenvp, _CRT_glob, &si);
[app OF_setArgumentCount: wargc
andWideArgumentValues: wargv];
#endif
delegate = [[cls alloc] init];
[app setDelegate: delegate];
|
| ︙ | ︙ | |||
156 157 158 159 160 161 162 |
+ (void)terminate
{
exit(0);
}
+ (void)terminateWithStatus: (int)status
{
| | | | | | 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
+ (void)terminate
{
exit(0);
}
+ (void)terminateWithStatus: (int)status
{
#ifdef OF_PSP
sceKernelExitGame();
abort(); /* sceKernelExitGame() is not marked noreturn */
#else
exit(status);
#endif
}
- init
{
self = [super init];
@try {
void *pool;
OFMutableDictionary *environment;
#if defined(OF_MAC_OS_X)
char **env = *_NSGetEnviron();
#elif defined(OF_WINDOWS)
of_char16_t *env, *env0;
#elif !defined(OF_IOS)
char **env = environ;
#else
char *env;
#endif
environment = [[OFMutableDictionary alloc] init];
atexit(atexitHandler);
#if defined(OF_WINDOWS)
env = env0 = GetEnvironmentStringsW();
while (*env != 0) {
OFString *tmp, *key, *value;
size_t length, pos;
pool = objc_autoreleasePoolPush();
|
| ︙ | ︙ | |||
325 326 327 328 329 330 331 |
[super dealloc];
}
- (void)OF_setArgumentCount: (int*)argc
andArgumentValues: (char***)argv
{
| | | 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 |
[super dealloc];
}
- (void)OF_setArgumentCount: (int*)argc
andArgumentValues: (char***)argv
{
#ifndef OF_WINDOWS
void *pool = objc_autoreleasePoolPush();
OFMutableArray *arguments;
int i;
of_string_encoding_t encoding;
_argc = argc;
_argv = argv;
|
| ︙ | ︙ | |||
362 363 364 365 366 367 368 | objc_autoreleasePoolPop(pool); #else _argc = argc; _argv = argv; #endif } | | | 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 |
objc_autoreleasePoolPop(pool);
#else
_argc = argc;
_argv = argv;
#endif
}
#ifdef OF_WINDOWS
- (void)OF_setArgumentCount: (int)argc
andWideArgumentValues: (wchar_t**)argv
{
void *pool = objc_autoreleasePoolPush();
OFMutableArray *arguments;
int i;
|
| ︙ | ︙ | |||
427 428 429 430 431 432 433 | _##sig##Handler = (void(*)(id, SEL))[(id)delegate \ methodForSelector: \ @selector(applicationDidReceive##sig)]; \ signal(sig, handle##sig); \ } else \ signal(sig, SIG_DFL); REGISTER_SIGNAL(SIGINT) | | | 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 | _##sig##Handler = (void(*)(id, SEL))[(id)delegate \ methodForSelector: \ @selector(applicationDidReceive##sig)]; \ signal(sig, handle##sig); \ } else \ signal(sig, SIG_DFL); REGISTER_SIGNAL(SIGINT) #ifndef OF_WINDOWS REGISTER_SIGNAL(SIGHUP) REGISTER_SIGNAL(SIGUSR1) REGISTER_SIGNAL(SIGUSR2) #endif #undef REGISTER_SIGNAL } |
| ︙ | ︙ |
Changes to src/OFBlock.m.
| ︙ | ︙ | |||
139 140 141 142 143 144 145 | const char *ivar_layout; struct class_ext *ext; }; struct class _NSConcreteStackBlock; struct class _NSConcreteGlobalBlock; struct class _NSConcreteMallocBlock; | | | 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
const char *ivar_layout;
struct class_ext *ext;
};
struct class _NSConcreteStackBlock;
struct class _NSConcreteGlobalBlock;
struct class _NSConcreteMallocBlock;
# if defined(__OBJC2__) && !defined(OF_POWERPC64)
struct class _NSConcreteStackBlock_metaclass;
struct class _NSConcreteGlobalBlock_metaclass;
struct class _NSConcreteMallocBlock_metaclass;
# endif
#endif
static struct {
|
| ︙ | ︙ | |||
317 318 319 320 321 322 323 | @throw [OFInitializationFailedException exceptionWithClass: self]; #endif #ifdef OF_APPLE_RUNTIME Class tmp; | | | 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 | @throw [OFInitializationFailedException exceptionWithClass: self]; #endif #ifdef OF_APPLE_RUNTIME Class tmp; # if defined(__OBJC2__) && !defined(OF_POWERPC64) tmp = objc_initializeClassPair(self, "OFStackBlock", (Class)&_NSConcreteStackBlock, (Class)&_NSConcreteStackBlock_metaclass); if (tmp == Nil) @throw [OFInitializationFailedException exceptionWithClass: self]; objc_registerClassPair(tmp); |
| ︙ | ︙ |
Changes to src/OFFile.h.
| ︙ | ︙ | |||
24 25 26 27 28 29 30 | #include <sys/types.h> #include <sys/stat.h> #import "OFSeekableStream.h" OF_ASSUME_NONNULL_BEGIN | | | 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | #include <sys/types.h> #include <sys/stat.h> #import "OFSeekableStream.h" OF_ASSUME_NONNULL_BEGIN #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; #endif |
| ︙ | ︙ |
Changes to src/OFFile.m.
| ︙ | ︙ | |||
17 18 19 20 21 22 23 | #include "config.h" #include <errno.h> #include <fcntl.h> #include <unistd.h> | > > | | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | #include "config.h" #include <errno.h> #include <fcntl.h> #include <unistd.h> #include "platform.h" #ifdef OF_WII # define BOOL OGC_BOOL # include <fat.h> # undef BOOL #endif #ifdef OF_NINTENDO_DS # include <stdbool.h> |
| ︙ | ︙ | |||
40 41 42 43 44 45 46 | #import "OFInvalidArgumentException.h" #import "OFOpenItemFailedException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFSeekFailedException.h" #import "OFWriteFailedException.h" | | | 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | #import "OFInvalidArgumentException.h" #import "OFOpenItemFailedException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFSeekFailedException.h" #import "OFWriteFailedException.h" #ifdef OF_WINDOWS # include <windows.h> #endif #ifndef O_BINARY # define O_BINARY 0 #endif #ifndef O_CLOEXEC |
| ︙ | ︙ | |||
112 113 114 115 116 117 118 |
@implementation OFFile
+ (void)initialize
{
if (self != [OFFile class])
return;
| | | 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
@implementation OFFile
+ (void)initialize
{
if (self != [OFFile class])
return;
#ifdef OF_WII
if (!fatInitDefault())
@throw [OFInitializationFailedException
exceptionWithClass: self];
#endif
#ifdef OF_NINTENDO_DS
if (!nitroFSInit(NULL))
|
| ︙ | ︙ | |||
156 157 158 159 160 161 162 | int flags; if ((flags = parseMode([mode UTF8String])) == -1) @throw [OFInvalidArgumentException exception]; flags |= O_CLOEXEC; | | | 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | int flags; if ((flags = parseMode([mode UTF8String])) == -1) @throw [OFInvalidArgumentException exception]; flags |= O_CLOEXEC; #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) #else if ((_fd = open([path cStringWithEncoding: [OFSystemInfo |
| ︙ | ︙ | |||
204 205 206 207 208 209 210 |
{
ssize_t ret;
if (_fd == -1 || _atEndOfStream)
@throw [OFReadFailedException exceptionWithObject: self
requestedLength: length];
| | | 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
{
ssize_t ret;
if (_fd == -1 || _atEndOfStream)
@throw [OFReadFailedException exceptionWithObject: self
requestedLength: length];
#ifndef OF_WINDOWS
if ((ret = read(_fd, buffer, length)) < 0)
@throw [OFReadFailedException exceptionWithObject: self
requestedLength: length
errNo: errno];
#else
if (length > UINT_MAX)
@throw [OFOutOfRangeException exception];
|
| ︙ | ︙ | |||
232 233 234 235 236 237 238 |
- (void)lowlevelWriteBuffer: (const void*)buffer
length: (size_t)length
{
if (_fd == -1 || _atEndOfStream)
@throw [OFWriteFailedException exceptionWithObject: self
requestedLength: length];
| | | 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 |
- (void)lowlevelWriteBuffer: (const void*)buffer
length: (size_t)length
{
if (_fd == -1 || _atEndOfStream)
@throw [OFWriteFailedException exceptionWithObject: self
requestedLength: length];
#ifndef OF_WINDOWS
if (length > SSIZE_MAX)
@throw [OFOutOfRangeException exception];
if (write(_fd, buffer, length) != (ssize_t)length)
@throw [OFWriteFailedException exceptionWithObject: self
requestedLength: length
errNo: errno];
|
| ︙ | ︙ | |||
254 255 256 257 258 259 260 |
errNo: errno];
#endif
}
- (of_offset_t)lowlevelSeekToOffset: (of_offset_t)offset
whence: (int)whence
{
| | | 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 |
errNo: errno];
#endif
}
- (of_offset_t)lowlevelSeekToOffset: (of_offset_t)offset
whence: (int)whence
{
#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);
#endif
|
| ︙ | ︙ |
Changes to src/OFFileManager.m.
| ︙ | ︙ | |||
53 54 55 56 57 58 59 | #import "OFOpenItemFailedException.h" #import "OFOutOfMemoryException.h" #import "OFReadFailedException.h" #import "OFRemoveItemFailedException.h" #import "OFStatItemFailedException.h" #import "OFUnlockFailedException.h" | | | 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | #import "OFOpenItemFailedException.h" #import "OFOutOfMemoryException.h" #import "OFReadFailedException.h" #import "OFRemoveItemFailedException.h" #import "OFStatItemFailedException.h" #import "OFUnlockFailedException.h" #ifdef OF_WINDOWS # include <windows.h> # include <direct.h> #endif #ifndef S_IRGRP # define S_IRGRP 0 #endif |
| ︙ | ︙ | |||
79 80 81 82 83 84 85 | #define DIR_MODE DEFAULT_MODE | S_IXUSR | S_IXGRP | S_IXOTH static OFFileManager *defaultManager; #if defined(OF_HAVE_CHOWN) && defined(OF_HAVE_THREADS) static of_mutex_t chownMutex; #endif | | | | | 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
#define DIR_MODE DEFAULT_MODE | S_IXUSR | S_IXGRP | S_IXOTH
static OFFileManager *defaultManager;
#if defined(OF_HAVE_CHOWN) && defined(OF_HAVE_THREADS)
static of_mutex_t chownMutex;
#endif
#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(OF_WINDOWS)
return _wstat64([path UTF16String], buffer);
#elif defined(OF_HAVE_OFF64_T)
return stat64([path cStringWithEncoding:
[OFSystemInfo native8BitEncoding]], buffer);
#else
return stat([path cStringWithEncoding:
[OFSystemInfo native8BitEncoding]], buffer);
#endif
}
int
of_lstat(OFString *path, of_stat_t *buffer)
{
#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);
# else
return lstat([path cStringWithEncoding:
|
| ︙ | ︙ | |||
139 140 141 142 143 144 145 | #if defined(OF_HAVE_CHOWN) && defined(OF_HAVE_THREADS) if (!of_mutex_new(&chownMutex)) @throw [OFInitializationFailedException exceptionWithClass: self]; #endif | | | | | 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
#if defined(OF_HAVE_CHOWN) && defined(OF_HAVE_THREADS)
if (!of_mutex_new(&chownMutex))
@throw [OFInitializationFailedException
exceptionWithClass: self];
#endif
#if !defined(HAVE_READDIR_R) && !defined(OF_WINDOWS) && defined(OF_HAVE_THREADS)
if (!of_mutex_new(&readdirMutex))
@throw [OFInitializationFailedException
exceptionWithClass: self];
#endif
defaultManager = [[OFFileManager alloc] init];
}
+ (OFFileManager*)defaultManager
{
return defaultManager;
}
- (OFString*)currentDirectoryPath
{
OFString *ret;
#ifndef OF_WINDOWS
char *buffer = getcwd(NULL, 0);
#else
wchar_t *buffer = _wgetcwd(NULL, 0);
#endif
@try {
#ifndef OF_WINDOWS
ret = [OFString
stringWithCString: buffer
encoding: [OFSystemInfo native8BitEncoding]];
#else
ret = [OFString stringWithUTF16String: buffer];
#endif
} @finally {
|
| ︙ | ︙ | |||
232 233 234 235 236 237 238 |
#endif
- (void)createDirectoryAtPath: (OFString*)path
{
if (path == nil)
@throw [OFInvalidArgumentException exception];
| | | 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
#endif
- (void)createDirectoryAtPath: (OFString*)path
{
if (path == nil)
@throw [OFInvalidArgumentException exception];
#ifndef OF_WINDOWS
if (mkdir([path cStringWithEncoding: [OFSystemInfo native8BitEncoding]],
DIR_MODE) != 0)
#else
if (_wmkdir([path UTF16String]) != 0)
#endif
@throw [OFCreateDirectoryFailedException
exceptionWithPath: path
|
| ︙ | ︙ | |||
289 290 291 292 293 294 295 |
objc_autoreleasePoolPop(pool);
}
- (OFArray*)contentsOfDirectoryAtPath: (OFString*)path
{
OFMutableArray *files;
| | | | 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 |
objc_autoreleasePoolPop(pool);
}
- (OFArray*)contentsOfDirectoryAtPath: (OFString*)path
{
OFMutableArray *files;
#ifndef OF_WINDOWS
of_string_encoding_t encoding;
#endif
if (path == nil)
@throw [OFInvalidArgumentException exception];
files = [OFMutableArray array];
#ifndef OF_WINDOWS
DIR *dir;
encoding = [OFSystemInfo native8BitEncoding];
if ((dir = opendir([path cStringWithEncoding: encoding])) == NULL)
@throw [OFOpenItemFailedException exceptionWithPath: path
errNo: errno];
|
| ︙ | ︙ | |||
414 415 416 417 418 419 420 |
}
- (void)changeCurrentDirectoryPath: (OFString*)path
{
if (path == nil)
@throw [OFInvalidArgumentException exception];
| | | 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 |
}
- (void)changeCurrentDirectoryPath: (OFString*)path
{
if (path == nil)
@throw [OFInvalidArgumentException exception];
#ifndef OF_WINDOWS
if (chdir([path cStringWithEncoding:
[OFSystemInfo native8BitEncoding]]) != 0)
#else
if (_wchdir([path UTF16String]) != 0)
#endif
@throw [OFChangeCurrentDirectoryPathFailedException
exceptionWithPath: path
|
| ︙ | ︙ | |||
491 492 493 494 495 496 497 |
#ifdef OF_HAVE_CHMOD
- (void)changePermissionsOfItemAtPath: (OFString*)path
permissions: (mode_t)permissions
{
if (path == nil)
@throw [OFInvalidArgumentException exception];
| | | 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 |
#ifdef OF_HAVE_CHMOD
- (void)changePermissionsOfItemAtPath: (OFString*)path
permissions: (mode_t)permissions
{
if (path == nil)
@throw [OFInvalidArgumentException exception];
# ifndef OF_WINDOWS
if (chmod([path cStringWithEncoding: [OFSystemInfo native8BitEncoding]],
permissions) != 0)
# else
if (_wchmod([path UTF16String], permissions) != 0)
# endif
@throw [OFChangePermissionsFailedException
exceptionWithPath: path
|
| ︙ | ︙ | |||
718 719 720 721 722 723 724 |
}
- (void)moveItemAtPath: (OFString*)source
toPath: (OFString*)destination
{
void *pool;
of_stat_t s;
| | | | 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 |
}
- (void)moveItemAtPath: (OFString*)source
toPath: (OFString*)destination
{
void *pool;
of_stat_t s;
#ifndef OF_WINDOWS
of_string_encoding_t encoding;
#endif
if (source == nil || destination == nil)
@throw [OFInvalidArgumentException exception];
pool = objc_autoreleasePoolPush();
if (of_lstat(destination, &s) == 0)
@throw [OFCopyItemFailedException
exceptionWithSourcePath: source
destinationPath: destination
errNo: EEXIST];
#ifndef OF_WINDOWS
encoding = [OFSystemInfo native8BitEncoding];
if (rename([source cStringWithEncoding: encoding],
[destination cStringWithEncoding: encoding]) != 0) {
#else
if (_wrename([source UTF16String], [destination UTF16String]) != 0) {
#endif
|
| ︙ | ︙ | |||
820 821 822 823 824 825 826 | [self removeItemAtPath: [path stringByAppendingPathComponent: item]]; objc_autoreleasePoolPop(pool2); } } | | | 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 | [self removeItemAtPath: [path stringByAppendingPathComponent: item]]; objc_autoreleasePoolPop(pool2); } } #ifndef OF_WINDOWS if (remove([path cStringWithEncoding: [OFSystemInfo native8BitEncoding]]) != 0) #else if (_wremove([path UTF16String]) != 0) #endif @throw [OFRemoveItemFailedException exceptionWithPath: path errNo: errno]; |
| ︙ | ︙ |
Changes to src/OFKernelEventObserver.m.
| ︙ | ︙ | |||
37 38 39 40 41 42 43 | #ifdef HAVE_KQUEUE # import "OFKernelEventObserver_kqueue.h" #endif #ifdef HAVE_EPOLL # import "OFKernelEventObserver_epoll.h" #endif | | | | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | #ifdef HAVE_KQUEUE # import "OFKernelEventObserver_kqueue.h" #endif #ifdef HAVE_EPOLL # import "OFKernelEventObserver_epoll.h" #endif #if defined(HAVE_POLL_H) || defined(OF_WII) # import "OFKernelEventObserver_poll.h" #endif #if defined(HAVE_SYS_SELECT_H) || defined(OF_WINDOWS) # import "OFKernelEventObserver_select.h" #endif #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFOutOfRangeException.h" |
| ︙ | ︙ | |||
82 83 84 85 86 87 88 |
+ alloc
{
if (self == [OFKernelEventObserver class])
#if defined(HAVE_KQUEUE)
return [OFKernelEventObserver_kqueue alloc];
#elif defined(HAVE_EPOLL)
return [OFKernelEventObserver_epoll alloc];
| | | | | 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
+ alloc
{
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(OF_WII)
return [OFKernelEventObserver_poll alloc];
#elif defined(HAVE_SYS_SELECT_H) || defined(OF_WINDOWS)
return [OFKernelEventObserver_select alloc];
#else
# error No kqueue / epoll / poll / select found!
#endif
return [super alloc];
}
- init
{
self = [super init];
@try {
#if !defined(OF_HAVE_PIPE) && !defined(OF_WII)
socklen_t cancelAddrLen;
#endif
_readObjects = [[OFMutableArray alloc] init];
_writeObjects = [[OFMutableArray alloc] init];
_queue = [[OFMutableArray alloc] init];
_queueActions = [[OFDataArray alloc]
|
| ︙ | ︙ | |||
123 124 125 126 127 128 129 |
@throw [OFInitializationFailedException
exceptionWithClass: [self class]];
_cancelAddr.sin_family = AF_INET;
_cancelAddr.sin_port = 0;
_cancelAddr.sin_addr.s_addr = inet_addr("127.0.0.1");
| | | | 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
@throw [OFInitializationFailedException
exceptionWithClass: [self class]];
_cancelAddr.sin_family = AF_INET;
_cancelAddr.sin_port = 0;
_cancelAddr.sin_addr.s_addr = inet_addr("127.0.0.1");
# 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
if (bind(_cancelFD[0], (struct sockaddr*)&_cancelAddr,
sizeof(_cancelAddr)))
@throw [OFInitializationFailedException
exceptionWithClass: [self class]];
# ifndef OF_WII
cancelAddrLen = sizeof(_cancelAddr);
if (of_getsockname(_cancelFD[0], (struct sockaddr*)&_cancelAddr,
&cancelAddrLen) != 0)
@throw [OFInitializationFailedException
exceptionWithClass: [self class]];
# endif
#endif
|
| ︙ | ︙ | |||
160 161 162 163 164 165 166 |
- (void)dealloc
{
close(_cancelFD[0]);
if (_cancelFD[1] != _cancelFD[0])
close(_cancelFD[1]);
| | | 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
- (void)dealloc
{
close(_cancelFD[0]);
if (_cancelFD[1] != _cancelFD[0])
close(_cancelFD[1]);
#ifdef OF_WII
of_socket_port_free(_cancelAddr.sin_port, SOCK_DGRAM);
#endif
[_readObjects release];
[_writeObjects release];
[_queue release];
[_queueActions release];
|
| ︙ | ︙ | |||
356 357 358 359 360 361 362 |
}
- (void)cancel
{
#ifdef OF_HAVE_PIPE
OF_ENSURE(write(_cancelFD[1], "", 1) > 0);
#else
| | | 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 |
}
- (void)cancel
{
#ifdef OF_HAVE_PIPE
OF_ENSURE(write(_cancelFD[1], "", 1) > 0);
#else
# 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);
# endif
#endif
|
| ︙ | ︙ |
Changes to src/OFKernelEventObserver_kqueue.m.
| ︙ | ︙ | |||
93 94 95 96 97 98 99 | if ([_changeList count] >= INT_MAX) @throw [OFOutOfRangeException exception]; memset(&event, 0, sizeof(event)); event.ident = [object fileDescriptorForReading]; event.filter = EVFILT_READ; event.flags = EV_ADD; | | | | 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
if ([_changeList count] >= INT_MAX)
@throw [OFOutOfRangeException exception];
memset(&event, 0, sizeof(event));
event.ident = [object fileDescriptorForReading];
event.filter = EVFILT_READ;
event.flags = EV_ADD;
#ifndef OF_NETBSD
event.udata = object;
#else
event.udata = (intptr_t)object;
#endif
[_changeList addItem: &event];
}
- (void)OF_addObjectForWriting: (id)object
{
struct kevent event;
if ([_changeList count] >= INT_MAX)
@throw [OFOutOfRangeException exception];
memset(&event, 0, sizeof(event));
event.ident = [object fileDescriptorForWriting];
event.filter = EVFILT_WRITE;
event.flags = EV_ADD;
#ifndef OF_NETBSD
event.udata = object;
#else
event.udata = (intptr_t)object;
#endif
[_changeList addItem: &event];
}
|
| ︙ | ︙ |
Changes to src/OFKernelEventObserver_poll.m.
| ︙ | ︙ | |||
31 32 33 34 35 36 37 | #import "OFDataArray.h" #import "OFObserveFailedException.h" #import "OFOutOfRangeException.h" #import "socket_helpers.h" | | | 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
#import "OFDataArray.h"
#import "OFObserveFailedException.h"
#import "OFOutOfRangeException.h"
#import "socket_helpers.h"
#ifdef OF_WII
# define pollfd pollsd
# define fd socket
#endif
@implementation OFKernelEventObserver_poll
- init
{
|
| ︙ | ︙ |
Changes to src/OFKernelEventObserver_select.h.
| ︙ | ︙ | |||
9 10 11 12 13 14 15 16 17 18 19 20 21 22 | * 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. */ #ifndef __STDC_LIMIT_MACROS # define __STDC_LIMIT_MACROS #endif #ifndef __STDC_CONSTANT_MACROS # define __STDC_CONSTANT_MACROS #endif | > > | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | * 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" #ifndef __STDC_LIMIT_MACROS # define __STDC_LIMIT_MACROS #endif #ifndef __STDC_CONSTANT_MACROS # define __STDC_CONSTANT_MACROS #endif |
| ︙ | ︙ |
Changes to src/OFKernelEventObserver_select.m.
| ︙ | ︙ | |||
14 15 16 17 18 19 20 | * file. */ #define __NO_EXT_QNX #include "config.h" | > > | | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | * file. */ #define __NO_EXT_QNX #include "config.h" #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 <errno.h> #include <math.h> #include <string.h> |
| ︙ | ︙ | |||
41 42 43 44 45 46 47 |
#import "socket_helpers.h"
@implementation OFKernelEventObserver_select
- init
{
self = [super init];
| | | 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
#import "socket_helpers.h"
@implementation OFKernelEventObserver_select
- init
{
self = [super init];
#ifndef OF_WINDOWS
if (_cancelFD[0] >= FD_SETSIZE)
@throw [OFInitializationFailedException exception];
#endif
FD_ZERO(&_readFDs);
FD_ZERO(&_writeFDs);
FD_SET(_cancelFD[0], &_readFDs);
|
| ︙ | ︙ | |||
65 66 67 68 69 70 71 |
- (void)OF_addObjectForReading: (id)object
{
int fd = [object fileDescriptorForReading];
if (fd < 0 || fd > INT_MAX - 1)
@throw [OFOutOfRangeException exception];
| | | | | | 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
- (void)OF_addObjectForReading: (id)object
{
int fd = [object fileDescriptorForReading];
if (fd < 0 || fd > INT_MAX - 1)
@throw [OFOutOfRangeException exception];
#ifndef OF_WINDOWS
if (fd >= FD_SETSIZE)
@throw [OFOutOfRangeException exception];
#endif
if (fd > _maxFD)
_maxFD = fd;
FD_SET(fd, &_readFDs);
}
- (void)OF_addObjectForWriting: (id)object
{
int fd = [object fileDescriptorForWriting];
if (fd < 0 || fd > INT_MAX - 1)
@throw [OFOutOfRangeException exception];
#ifndef OF_WINDOWS
if (fd >= FD_SETSIZE)
@throw [OFOutOfRangeException exception];
#endif
if (fd > _maxFD)
_maxFD = fd;
FD_SET(fd, &_writeFDs);
}
- (void)OF_removeObjectForReading: (id)object
{
/* TODO: Adjust _maxFD */
int fd = [object fileDescriptorForReading];
if (fd < 0)
@throw [OFOutOfRangeException exception];
#ifndef OF_WINDOWS
if (fd >= FD_SETSIZE)
@throw [OFOutOfRangeException exception];
#endif
FD_CLR(fd, &_readFDs);
}
- (void)OF_removeObjectForWriting: (id)object
{
/* TODO: Adjust _maxFD */
int fd = [object fileDescriptorForWriting];
if (fd < 0)
@throw [OFOutOfRangeException exception];
#ifndef OF_WINDOWS
if (fd >= FD_SETSIZE)
@throw [OFOutOfRangeException exception];
#endif
FD_CLR(fd, &_writeFDs);
}
|
| ︙ | ︙ | |||
157 158 159 160 161 162 163 | /* * 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. */ | | | 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | /* * 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 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); events = select(_maxFD + 1, &readFDs, &writeFDs, NULL, |
| ︙ | ︙ |
Changes to src/OFObject.h.
| ︙ | ︙ | |||
10 11 12 13 14 15 16 | * * 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. */ | | | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | * * 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 # define __STDC_CONSTANT_MACROS #endif |
| ︙ | ︙ |
Changes to src/OFObject.m.
| ︙ | ︙ | |||
42 43 44 45 46 47 48 | #if defined(OF_APPLE_RUNTIME) && __OBJC2__ # import <objc/objc-exception.h> #elif defined(OF_OBJFW_RUNTIME) # import "runtime.h" #endif | | | 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | #if defined(OF_APPLE_RUNTIME) && __OBJC2__ # import <objc/objc-exception.h> #elif defined(OF_OBJFW_RUNTIME) # import "runtime.h" #endif #ifdef OF_WINDOWS # include <windows.h> #endif #import "OFString.h" #import "instance.h" #if defined(OF_HAVE_ATOMIC_OPS) |
| ︙ | ︙ |
Changes to src/OFPlugin.h.
| ︙ | ︙ | |||
14 15 16 17 18 19 20 | * file. */ #import "OFObject.h" @class OFString; | | | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | * file. */ #import "OFObject.h" @class OFString; #ifndef OF_WINDOWS typedef void* of_plugin_handle_t; #else # include <windows.h> typedef HMODULE of_plugin_handle_t; #endif OF_ASSUME_NONNULL_BEGIN |
| ︙ | ︙ |
Changes to src/OFPlugin.m.
| ︙ | ︙ | |||
25 26 27 28 29 30 31 | #import "OFPlugin.h" #import "OFString.h" #import "OFSystemInfo.h" #import "OFInitializationFailedException.h" | | | | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
#import "OFPlugin.h"
#import "OFString.h"
#import "OFSystemInfo.h"
#import "OFInitializationFailedException.h"
#ifdef OF_WINDOWS
# define dlsym(handle, symbol) GetProcAddress(handle, symbol)
# define dlclose(handle) FreeLibrary(handle)
#endif
typedef OFPlugin* (*init_plugin_t)(void);
@implementation OFPlugin
+ (id)pluginFromFile: (OFString*)path
{
void *pool = objc_autoreleasePoolPush();
of_plugin_handle_t handle;
init_plugin_t initPlugin;
OFPlugin *plugin;
path = [path stringByAppendingString: @PLUGIN_SUFFIX];
#ifndef OF_WINDOWS
if ((handle = dlopen([path cStringWithEncoding:
[OFSystemInfo native8BitEncoding]], RTLD_LAZY)) == NULL)
#else
if ((handle = LoadLibraryW([path UTF16String])) == NULL)
#endif
@throw [OFInitializationFailedException
exceptionWithClass: self];
|
| ︙ | ︙ |
Changes to src/OFProcess.h.
| ︙ | ︙ | |||
22 23 24 25 26 27 28 | #endif #include <sys/types.h> #import "OFStream.h" #import "OFString.h" | | | | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
#endif
#include <sys/types.h>
#import "OFStream.h"
#import "OFString.h"
#ifdef OF_WINDOWS
# include <windows.h>
#endif
OF_ASSUME_NONNULL_BEGIN
@class OFArray OF_GENERIC(ObjectType);
@class OFDictionary OF_GENERIC(KeyType, ObjectType);
/*!
* @class OFProcess OFProcess.h ObjFW/OFProcess.h
*
* @brief A class for stream-like communication with a newly created process.
*/
@interface OFProcess: OFStream
{
#ifndef OF_WINDOWS
pid_t _pid;
int _readPipe[2], _writePipe[2];
#else
HANDLE _process, _readPipe[2], _writePipe[2];
#endif
int _status;
bool _atEndOfStream;
|
| ︙ | ︙ |
Changes to src/OFProcess.m.
| ︙ | ︙ | |||
20 21 22 23 24 25 26 | #include <string.h> /* Work around __block being used by glibc */ #ifdef __GLIBC__ # undef __USE_XOPEN #endif | > > | | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | #include <string.h> /* Work around __block being used by glibc */ #ifdef __GLIBC__ # undef __USE_XOPEN #endif #include "platform.h" #ifndef OF_WINDOWS # include <unistd.h> # include <signal.h> # include <sys/wait.h> #endif #ifdef HAVE_SPAWN_H # include <spawn.h> |
| ︙ | ︙ | |||
42 43 44 45 46 47 48 | #import "OFSystemInfo.h" #import "OFInitializationFailedException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFWriteFailedException.h" | | | | | 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
#import "OFSystemInfo.h"
#import "OFInitializationFailedException.h"
#import "OFOutOfRangeException.h"
#import "OFReadFailedException.h"
#import "OFWriteFailedException.h"
#ifdef OF_WINDOWS
# include <windows.h>
#endif
#if !defined(OF_WINDOWS) && !defined(HAVE_POSIX_SPAWNP)
extern char **environ;
#endif
@interface OFProcess (OF_PRIVATE_CATEGORY)
#ifndef OF_WINDOWS
- (void)OF_getArgV: (char***)argv
forProgramName: (OFString*)programName
andArguments: (OFArray*)arguments;
- (char**)OF_environmentForDictionary: (OFDictionary*)dictionary;
#else
- (of_char16_t*)OF_environmentForDictionary: (OFDictionary*)dictionary;
#endif
|
| ︙ | ︙ | |||
134 135 136 137 138 139 140 |
programName: (OFString*)programName
arguments: (OFArray*)arguments
environment: (OFDictionary*)environment
{
self = [super init];
@try {
| | | 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
programName: (OFString*)programName
arguments: (OFArray*)arguments
environment: (OFDictionary*)environment
{
self = [super init];
@try {
#ifndef OF_WINDOWS
void *pool = objc_autoreleasePoolPush();
const char *path;
char **argv;
if (pipe(_readPipe) != 0 || pipe(_writePipe) != 0)
@throw [OFInitializationFailedException
exceptionWithClass: [self class]];
|
| ︙ | ︙ | |||
335 336 337 338 339 340 341 |
- (void)dealloc
{
[self close];
[super dealloc];
}
| | | 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 |
- (void)dealloc
{
[self close];
[super dealloc];
}
#ifndef OF_WINDOWS
- (void)OF_getArgV: (char***)argv
forProgramName: (OFString*)programName
andArguments: (OFArray*)arguments
{
OFString *const *objects = [arguments objects];
size_t i, count = [arguments count];
of_string_encoding_t encoding;
|
| ︙ | ︙ | |||
433 434 435 436 437 438 439 |
return [env items];
}
#endif
- (bool)lowlevelIsAtEndOfStream
{
| | | < < < < > > | 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 |
return [env items];
}
#endif
- (bool)lowlevelIsAtEndOfStream
{
#ifndef OF_WINDOWS
if (_readPipe[0] == -1)
#else
if (_readPipe[0] == NULL)
#endif
return true;
return _atEndOfStream;
}
- (size_t)lowlevelReadIntoBuffer: (void*)buffer
length: (size_t)length
{
#ifndef OF_WINDOWS
ssize_t ret;
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
requestedLength: length];
|
| ︙ | ︙ | |||
489 490 491 492 493 494 495 |
return ret;
}
- (void)lowlevelWriteBuffer: (const void*)buffer
length: (size_t)length
{
| | | 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 |
return ret;
}
- (void)lowlevelWriteBuffer: (const void*)buffer
length: (size_t)length
{
#ifndef OF_WINDOWS
if (_writePipe[1] == -1 || _atEndOfStream)
@throw [OFWriteFailedException exceptionWithObject: self
requestedLength: length];
if (length > SSIZE_MAX)
@throw [OFOutOfRangeException exception];
|
| ︙ | ︙ | |||
527 528 529 530 531 532 533 |
errNo: errNo];
}
#endif
}
- (int)fileDescriptorForReading
{
| | | | | | 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 |
errNo: errNo];
}
#endif
}
- (int)fileDescriptorForReading
{
#ifndef OF_WINDOWS
return _readPipe[0];
#else
OF_UNRECOGNIZED_SELECTOR
#endif
}
- (int)fileDescriptorForWriting
{
#ifndef OF_WINDOWS
return _writePipe[1];
#else
OF_UNRECOGNIZED_SELECTOR
#endif
}
- (void)closeForWriting
{
#ifndef OF_WINDOWS
if (_writePipe[1] != -1)
close(_writePipe[1]);
_writePipe[1] = -1;
#else
if (_writePipe[1] != NULL)
CloseHandle(_writePipe[1]);
_writePipe[1] = NULL;
#endif
}
- (void)close
{
#ifndef OF_WINDOWS
if (_readPipe[0] != -1)
close(_readPipe[0]);
if (_writePipe[1] != -1)
close(_writePipe[1]);
if (_pid != -1) {
kill(_pid, SIGTERM);
|
| ︙ | ︙ |
Changes to src/OFSeekableStream.h.
| ︙ | ︙ | |||
23 24 25 26 27 28 29 | #include <sys/types.h> #import "OFStream.h" OF_ASSUME_NONNULL_BEGIN | | | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | #include <sys/types.h> #import "OFStream.h" OF_ASSUME_NONNULL_BEGIN #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; #else typedef off_t of_offset_t; |
| ︙ | ︙ |
Changes to src/OFStdIOStream.m.
| ︙ | ︙ | |||
99 100 101 102 103 104 105 |
{
ssize_t ret;
if (_fd == -1 || _atEndOfStream)
@throw [OFReadFailedException exceptionWithObject: self
requestedLength: length];
| | | 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
{
ssize_t ret;
if (_fd == -1 || _atEndOfStream)
@throw [OFReadFailedException exceptionWithObject: self
requestedLength: length];
#ifndef OF_WINDOWS
if ((ret = read(_fd, buffer, length)) < 0)
@throw [OFReadFailedException exceptionWithObject: self
requestedLength: length
errNo: errno];
#else
if (length > UINT_MAX)
@throw [OFOutOfRangeException exception];
|
| ︙ | ︙ | |||
127 128 129 130 131 132 133 |
- (void)lowlevelWriteBuffer: (const void*)buffer
length: (size_t)length
{
if (_fd == -1 || _atEndOfStream)
@throw [OFWriteFailedException exceptionWithObject: self
requestedLength: length];
| | | 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
- (void)lowlevelWriteBuffer: (const void*)buffer
length: (size_t)length
{
if (_fd == -1 || _atEndOfStream)
@throw [OFWriteFailedException exceptionWithObject: self
requestedLength: length];
#ifndef OF_WINDOWS
if (length > SSIZE_MAX)
@throw [OFOutOfRangeException exception];
if (write(_fd, buffer, length) != (ssize_t)length)
@throw [OFWriteFailedException exceptionWithObject: self
requestedLength: length
errNo: errno];
|
| ︙ | ︙ |
Changes to src/OFStream.m.
| ︙ | ︙ | |||
23 24 25 26 27 28 29 | #include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <fcntl.h> | > > | | | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include "platform.h"
#ifndef OF_WINDOWS
# include <signal.h>
#endif
#import "OFStream.h"
#import "OFStream+Private.h"
#import "OFString.h"
#import "OFDataArray.h"
#import "OFSystemInfo.h"
#import "OFRunLoop.h"
#import "OFRunLoop+Private.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFNotImplementedException.h"
#import "OFOutOfRangeException.h"
#import "OFSetOptionFailedException.h"
#import "of_asprintf.h"
@implementation OFStream
#ifndef OF_WINDOWS
+ (void)initialize
{
if (self == [OFStream class])
signal(SIGPIPE, SIG_IGN);
}
#endif
|
| ︙ | ︙ |
Changes to src/OFStreamSocket.m.
| ︙ | ︙ | |||
62 63 64 65 66 67 68 | @throw [OFNotOpenException exceptionWithObject: self]; if (_atEndOfStream) @throw [OFReadFailedException exceptionWithObject: self requestedLength: length errNo: ENOTCONN]; | | | 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | @throw [OFNotOpenException exceptionWithObject: self]; if (_atEndOfStream) @throw [OFReadFailedException exceptionWithObject: self requestedLength: length errNo: ENOTCONN]; #ifndef OF_WINDOWS if ((ret = recv(_socket, buffer, length, 0)) < 0) @throw [OFReadFailedException exceptionWithObject: self requestedLength: length errNo: of_socket_errno()]; #else if (length > UINT_MAX) |
| ︙ | ︙ | |||
96 97 98 99 100 101 102 | @throw [OFNotOpenException exceptionWithObject: self]; if (_atEndOfStream) @throw [OFWriteFailedException exceptionWithObject: self requestedLength: length errNo: ENOTCONN]; | | | | | | 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
@throw [OFNotOpenException exceptionWithObject: self];
if (_atEndOfStream)
@throw [OFWriteFailedException exceptionWithObject: self
requestedLength: length
errNo: ENOTCONN];
#ifndef OF_WINDOWS
if (length > SSIZE_MAX)
@throw [OFOutOfRangeException exception];
if (send(_socket, buffer, length, 0) != (ssize_t)length)
@throw [OFWriteFailedException
exceptionWithObject: self
requestedLength: length
errNo: of_socket_errno()];
#else
if (length > INT_MAX)
@throw [OFOutOfRangeException exception];
if (send(_socket, buffer, (int)length, 0) != (int)length)
@throw [OFWriteFailedException
exceptionWithObject: self
requestedLength: length
errNo: of_socket_errno()];
#endif
}
#ifdef OF_WINDOWS
- (void)setBlocking: (bool)enable
{
u_long v = enable;
_blocking = enable;
if (ioctlsocket(_socket, FIONBIO, &v) == SOCKET_ERROR)
@throw [OFSetOptionFailedException
exceptionWithStream: self
errNo: of_socket_errno()];
}
#endif
- (int)fileDescriptorForReading
{
#ifndef OF_WINDOWS
return _socket;
#else
if (_socket == INVALID_SOCKET)
return -1;
if (_socket > INT_MAX)
@throw [OFOutOfRangeException exception];
return (int)_socket;
#endif
}
- (int)fileDescriptorForWriting
{
#ifndef OF_WINDOWS
return _socket;
#else
if (_socket == INVALID_SOCKET)
return -1;
if (_socket > INT_MAX)
@throw [OFOutOfRangeException exception];
|
| ︙ | ︙ |
Changes to src/OFString.m.
| ︙ | ︙ | |||
58 59 60 61 62 63 64 | #import "of_asprintf.h" #import "unicode.h" /* * It seems strtod is buggy on Win32. * However, the MinGW version __strtod seems to be ok. */ | | | 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | #import "of_asprintf.h" #import "unicode.h" /* * It seems strtod is buggy on Win32. * However, the MinGW version __strtod seems to be ok. */ #ifdef __MINGW32__ # define strtod __strtod #endif @interface OFString (OF_PRIVATE_CATEGORY) - (size_t)OF_getCString: (char*)cString maxLength: (size_t)maxLength encoding: (of_string_encoding_t)encoding |
| ︙ | ︙ |
Changes to src/OFSystemInfo.m.
| ︙ | ︙ | |||
30 31 32 33 34 35 36 | #import "OFString.h" #import "OFArray.h" #import "OFDictionary.h" #import "OFApplication.h" #import "OFNotImplementedException.h" | | | | | | 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
#import "OFString.h"
#import "OFArray.h"
#import "OFDictionary.h"
#import "OFApplication.h"
#import "OFNotImplementedException.h"
#if defined(OF_MAC_OS_X)
# include <NSSystemDirectories.h>
#endif
#ifdef OF_WINDOWS
# include <windows.h>
#endif
#ifdef OF_HAIKU
# include <FindDirectory.h>
#endif
#ifdef OF_QNX
# include <sys/syspage.h>
#endif
#if defined(OF_X86_64_ASM) || defined(OF_X86_ASM)
struct x86_regs {
uint32_t eax, ebx, ecx, edx;
};
|
| ︙ | ︙ | |||
97 98 99 100 101 102 103 |
@implementation OFSystemInfo
+ (void)initialize
{
if (self != [OFSystemInfo class])
return;
| | | | 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
@implementation OFSystemInfo
+ (void)initialize
{
if (self != [OFSystemInfo class])
return;
#if defined(OF_WINDOWS)
SYSTEM_INFO si;
GetSystemInfo(&si);
pageSize = si.dwPageSize;
numberOfCPUs = si.dwNumberOfProcessors;
#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)
if ((pageSize = sysconf(_SC_PAGESIZE)) < 1)
# endif
|
| ︙ | ︙ | |||
142 143 144 145 146 147 148 |
/* FIXME */
return OF_STRING_ENCODING_UTF_8;
}
+ (OFString*)userDataPath
{
/* TODO: Return something more sensible for iOS */
| | | 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
/* FIXME */
return OF_STRING_ENCODING_UTF_8;
}
+ (OFString*)userDataPath
{
/* TODO: Return something more sensible for iOS */
#if defined(OF_MAC_OS_X)
void *pool = objc_autoreleasePoolPush();
char pathC[PATH_MAX];
NSSearchPathEnumerationState state;
OFMutableString *path;
OFString *home;
state = NSStartSearchPathEnumeration(NSApplicationSupportDirectory,
|
| ︙ | ︙ | |||
173 174 175 176 177 178 179 | } [path makeImmutable]; [path retain]; objc_autoreleasePoolPop(pool); return [path autorelease]; | | | | 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | } [path makeImmutable]; [path retain]; objc_autoreleasePoolPop(pool); return [path autorelease]; #elif defined(OF_WINDOWS) void *pool = objc_autoreleasePoolPush(); OFDictionary *env = [OFApplication environment]; OFString *appData; if ((appData = [env objectForKey: @"APPDATA"]) == nil) @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; [appData retain]; objc_autoreleasePoolPop(pool); return [appData autorelease]; #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 object: self]; |
| ︙ | ︙ | |||
222 223 224 225 226 227 228 |
return [var autorelease];
#endif
}
+ (OFString*)userConfigPath
{
/* TODO: Return something more sensible for iOS */
| | | 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
return [var autorelease];
#endif
}
+ (OFString*)userConfigPath
{
/* TODO: Return something more sensible for iOS */
#if defined(OF_MAC_OS_X)
void *pool = objc_autoreleasePoolPush();
char pathC[PATH_MAX];
NSSearchPathEnumerationState state;
OFMutableString *path;
OFString *home;
state = NSStartSearchPathEnumeration(NSLibraryDirectory,
|
| ︙ | ︙ | |||
255 256 257 258 259 260 261 | [path appendString: @"/Preferences"]; [path makeImmutable]; [path retain]; objc_autoreleasePoolPop(pool); return [path autorelease]; | | | | 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | [path appendString: @"/Preferences"]; [path makeImmutable]; [path retain]; objc_autoreleasePoolPop(pool); return [path autorelease]; #elif defined(OF_WINDOWS) void *pool = objc_autoreleasePoolPush(); OFDictionary *env = [OFApplication environment]; OFString *appData; if ((appData = [env objectForKey: @"APPDATA"]) == nil) @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; [appData retain]; objc_autoreleasePoolPop(pool); return [appData autorelease]; #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 object: self]; |
| ︙ | ︙ |
Changes to src/OFTCPSocket.h.
| ︙ | ︙ | |||
61 62 63 64 65 66 67 |
@interface OFTCPSocket: OFStreamSocket
{
bool _listening;
struct sockaddr *_address;
socklen_t _addressLength;
OFString *_SOCKS5Host;
uint16_t _SOCKS5Port;
| | | 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
@interface OFTCPSocket: OFStreamSocket
{
bool _listening;
struct sockaddr *_address;
socklen_t _addressLength;
OFString *_SOCKS5Host;
uint16_t _SOCKS5Port;
#ifdef OF_WII
uint16_t _port;
bool _keepAliveEnabled, _TCPNoDelayEnabled;
#endif
}
#ifdef OF_HAVE_PROPERTIES
@property (readonly, getter=isListening) bool listening;
|
| ︙ | ︙ |
Changes to src/OFTCPSocket.m.
| ︙ | ︙ | |||
11 12 13 14 15 16 17 | * 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. */ #define OF_TCP_SOCKET_M | < | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | * 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. */ #define OF_TCP_SOCKET_M #define __NO_EXT_QNX #include "config.h" #include <assert.h> #include <errno.h> #include <stdio.h> |
| ︙ | ︙ | |||
236 237 238 239 240 241 242 |
return self;
}
- (void)close
{
[super close];
| | | 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 |
return self;
}
- (void)close
{
[super close];
#ifdef OF_WII
if (_port > 0) {
of_socket_port_free(_port, SOCK_STREAM);
_port = 0;
}
#endif
}
|
| ︙ | ︙ | |||
385 386 387 388 389 390 391 |
#endif
- (uint16_t)bindToHost: (OFString*)host
port: (uint16_t)port
{
of_resolver_result_t **results;
const int one = 1;
| | | | | 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 |
#endif
- (uint16_t)bindToHost: (OFString*)host
port: (uint16_t)port
{
of_resolver_result_t **results;
const int one = 1;
#ifndef OF_WII
union {
struct sockaddr_storage storage;
struct sockaddr_in in;
# ifdef AF_INET6
struct sockaddr_in6 in6;
# endif
} addr;
socklen_t addrLen;
#endif
if (_socket != INVALID_SOCKET)
@throw [OFAlreadyConnectedException exceptionWithSocket: self];
if (_SOCKS5Host != nil)
@throw [OFNotImplementedException exceptionWithSelector: _cmd
object: self];
#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
socket: self
errNo: EADDRINUSE];
#endif
@try {
results = of_resolve_host(host, port, SOCK_STREAM);
} @catch (id e) {
#ifdef OF_WII
of_socket_port_free(port, SOCK_STREAM);
#endif
@throw e;
}
@try {
#if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC)
|
| ︙ | ︙ | |||
457 458 459 460 461 462 463 |
@throw [OFBindFailedException exceptionWithHost: host
port: port
socket: self
errNo: errNo];
}
} @catch (id e) {
| | | | | 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 |
@throw [OFBindFailedException exceptionWithHost: host
port: port
socket: self
errNo: errNo];
}
} @catch (id e) {
#ifdef OF_WII
of_socket_port_free(port, SOCK_STREAM);
#endif
@throw e;
} @finally {
of_resolver_free(results);
}
if (port > 0) {
#ifdef OF_WII
_port = port;
#endif
return port;
}
#ifndef OF_WII
addrLen = (socklen_t)sizeof(addr.storage);
if (of_getsockname(_socket, (struct sockaddr*)&addr.storage,
&addrLen) != 0) {
int errNo = of_socket_errno();
close(_socket);
_socket = INVALID_SOCKET;
|
| ︙ | ︙ | |||
621 622 623 624 625 626 627 | if (setsockopt(_socket, SOL_SOCKET, SO_KEEPALIVE, (char*)&v, (socklen_t)sizeof(v)) != 0) @throw [OFSetOptionFailedException exceptionWithStream: self errNo: of_socket_errno()]; | | | | 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 |
if (setsockopt(_socket, SOL_SOCKET, SO_KEEPALIVE,
(char*)&v, (socklen_t)sizeof(v)) != 0)
@throw [OFSetOptionFailedException
exceptionWithStream: self
errNo: of_socket_errno()];
#ifdef OF_WII
_keepAliveEnabled = enabled;
#endif
}
- (bool)isKeepAliveEnabled
{
#ifndef OF_WII
int v;
socklen_t len = sizeof(v);
if (getsockopt(_socket, SOL_SOCKET, SO_KEEPALIVE,
(char*)&v, &len) != 0 || len != sizeof(v))
@throw [OFGetOptionFailedException
exceptionWithStream: self
|
| ︙ | ︙ | |||
654 655 656 657 658 659 660 | if (setsockopt(_socket, IPPROTO_TCP, TCP_NODELAY, (char*)&v, (socklen_t)sizeof(v)) != 0) @throw [OFSetOptionFailedException exceptionWithStream: self errNo: of_socket_errno()]; | | | | 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 |
if (setsockopt(_socket, IPPROTO_TCP, TCP_NODELAY,
(char*)&v, (socklen_t)sizeof(v)) != 0)
@throw [OFSetOptionFailedException
exceptionWithStream: self
errNo: of_socket_errno()];
#ifdef OF_WII
_TCPNoDelayEnabled = enabled;
#endif
}
- (bool)isTCPNoDelayEnabled
{
#ifndef OF_WII
int v;
socklen_t len = sizeof(v);
if (getsockopt(_socket, IPPROTO_TCP, TCP_NODELAY,
(char*)&v, &len) != 0 || len != sizeof(v))
@throw [OFGetOptionFailedException
exceptionWithStream: self
|
| ︙ | ︙ |
Changes to src/OFThread.m.
| ︙ | ︙ | |||
25 26 27 28 29 30 31 | #include <time.h> /* Work around __block being used by glibc */ #ifdef __GLIBC__ # undef __USE_XOPEN #endif | > > | | | | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | #include <time.h> /* Work around __block being used by glibc */ #ifdef __GLIBC__ # undef __USE_XOPEN #endif #include "platform.h" #ifndef OF_WINDOWS # include <unistd.h> #endif #ifdef OF_HAVE_SCHED_YIELD # include <sched.h> #endif #ifdef OF_WII # define BOOL OGC_BOOL # define nanosleep ogc_nanosleep # include <ogcsys.h> # undef BOOL # undef nanosleep #endif #import "OFThread.h" #import "OFThread+Private.h" #import "OFRunLoop.h" #import "OFList.h" #import "OFDate.h" #import "OFDictionary.h" #import "OFAutoreleasePool.h" #import "OFAutoreleasePool+Private.h" #ifdef OF_WINDOWS # include <windows.h> #endif #ifdef OF_NINTENDO_DS # define asm __asm__ # include <nds.h> # undef asm |
| ︙ | ︙ | |||
172 173 174 175 176 177 178 |
#endif
+ (void)sleepForTimeInterval: (of_time_interval_t)timeInterval
{
if (timeInterval < 0)
return;
| | | 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
#endif
+ (void)sleepForTimeInterval: (of_time_interval_t)timeInterval
{
if (timeInterval < 0)
return;
#if defined(OF_WINDOWS)
if (timeInterval * 1000 > UINT_MAX)
@throw [OFOutOfRangeException exception];
Sleep((unsigned int)(timeInterval * 1000));
#elif defined(HAVE_NANOSLEEP)
struct timespec rqtp;
|
| ︙ | ︙ |
Changes to src/OFUDPSocket.h.
| ︙ | ︙ | |||
86 87 88 89 90 91 92 |
* than one thread at the same time is not thread-safe, even if copy
* was called to create one "instance" for every thread!
*/
@interface OFUDPSocket: OFObject <OFCopying, OFReadyForReadingObserving,
OFReadyForWritingObserving>
{
of_socket_t _socket;
| | | 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
* than one thread at the same time is not thread-safe, even if copy
* was called to create one "instance" for every thread!
*/
@interface OFUDPSocket: OFObject <OFCopying, OFReadyForReadingObserving,
OFReadyForWritingObserving>
{
of_socket_t _socket;
#ifdef OF_WII
uint16_t _port;
#endif
}
/*!
* @brief Returns a new, autoreleased OFUDPSocket.
*
|
| ︙ | ︙ |
Changes to src/OFUDPSocket.m.
| ︙ | ︙ | |||
181 182 183 184 185 186 187 |
#endif
if (address1->address.ss_family != address2->address.ss_family)
return false;
switch (address1->address.ss_family) {
case AF_INET:
| | | 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
#endif
if (address1->address.ss_family != address2->address.ss_family)
return false;
switch (address1->address.ss_family) {
case AF_INET:
#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)
@throw [OFInvalidArgumentException exception];
#endif
|
| ︙ | ︙ | |||
239 240 241 242 243 244 245 |
size_t i;
#endif
hash += address->address.ss_family;
switch (address->address.ss_family) {
case AF_INET:
| | | 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
size_t i;
#endif
hash += address->address.ss_family;
switch (address->address.ss_family) {
case AF_INET:
#ifndef OF_WII
if (address->length < sizeof(struct sockaddr_in))
@throw [OFInvalidArgumentException exception];
#else
if (address->length < 8)
@throw [OFInvalidArgumentException exception];
#endif
|
| ︙ | ︙ | |||
382 383 384 385 386 387 388 |
return [self retain];
}
- (uint16_t)bindToHost: (OFString*)host
port: (uint16_t)port
{
of_resolver_result_t **results;
| | | | | 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 |
return [self retain];
}
- (uint16_t)bindToHost: (OFString*)host
port: (uint16_t)port
{
of_resolver_result_t **results;
#ifndef OF_WII
union {
struct sockaddr_storage storage;
struct sockaddr_in in;
# ifdef AF_INET6
struct sockaddr_in6 in6;
# endif
} addr;
socklen_t addrLen;
#endif
#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
socket: self
errNo: EADDRINUSE];
#endif
@try {
results = of_resolve_host(host, port, SOCK_DGRAM);
} @catch (id e) {
#ifdef OF_WII
of_socket_port_free(port, SOCK_DGRAM);
#endif
@throw e;
}
@try {
#if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC)
|
| ︙ | ︙ | |||
444 445 446 447 448 449 450 |
@throw [OFBindFailedException exceptionWithHost: host
port: port
socket: self
errNo: errNo];
}
} @catch (id e) {
| | | | | 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 |
@throw [OFBindFailedException exceptionWithHost: host
port: port
socket: self
errNo: errNo];
}
} @catch (id e) {
#ifdef OF_WII
of_socket_port_free(port, SOCK_DGRAM);
#endif
@throw e;
} @finally {
of_resolver_free(results);
}
if (port > 0) {
#ifdef OF_WII
_port = port;
#endif
return port;
}
#ifndef OF_WII
addrLen = (socklen_t)sizeof(addr.storage);
if (of_getsockname(_socket, (struct sockaddr*)&addr.storage,
&addrLen) != 0) {
int errNo = of_socket_errno();
close(_socket);
_socket = INVALID_SOCKET;
|
| ︙ | ︙ | |||
501 502 503 504 505 506 507 | ssize_t ret; if (_socket == INVALID_SOCKET) @throw [OFNotOpenException exceptionWithObject: self]; sender->length = (socklen_t)sizeof(sender->address); | | | 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 | ssize_t ret; if (_socket == INVALID_SOCKET) @throw [OFNotOpenException exceptionWithObject: self]; sender->length = (socklen_t)sizeof(sender->address); #ifndef OF_WINDOWS if ((ret = recvfrom(_socket, buffer, length, 0, (struct sockaddr*)&sender->address, &sender->length)) < 0) @throw [OFReadFailedException exceptionWithObject: self requestedLength: length errNo: of_socket_errno()]; #else |
| ︙ | ︙ | |||
554 555 556 557 558 559 560 |
- (void)sendBuffer: (const void*)buffer
length: (size_t)length
receiver: (const of_udp_socket_address_t*)receiver
{
if (_socket == INVALID_SOCKET)
@throw [OFNotOpenException exceptionWithObject: self];
| | | 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 |
- (void)sendBuffer: (const void*)buffer
length: (size_t)length
receiver: (const of_udp_socket_address_t*)receiver
{
if (_socket == INVALID_SOCKET)
@throw [OFNotOpenException exceptionWithObject: self];
#ifndef OF_WINDOWS
if (length > SSIZE_MAX)
@throw [OFOutOfRangeException exception];
if (sendto(_socket, buffer, length, 0,
(struct sockaddr*)&receiver->address,
receiver->length) != (ssize_t)length)
@throw [OFWriteFailedException
|
| ︙ | ︙ | |||
586 587 588 589 590 591 592 |
- (void)cancelAsyncRequests
{
[OFRunLoop OF_cancelAsyncRequestsForObject: self];
}
- (int)fileDescriptorForReading
{
| | | | | 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 |
- (void)cancelAsyncRequests
{
[OFRunLoop OF_cancelAsyncRequestsForObject: self];
}
- (int)fileDescriptorForReading
{
#ifndef OF_WINDOWS
return _socket;
#else
if (_socket == INVALID_SOCKET)
return -1;
if (_socket > INT_MAX)
@throw [OFOutOfRangeException exception];
return (int)_socket;
#endif
}
- (int)fileDescriptorForWriting
{
#ifndef OF_WINDOWS
return _socket;
#else
if (_socket == INVALID_SOCKET)
return -1;
if (_socket > INT_MAX)
@throw [OFOutOfRangeException exception];
return (int)_socket;
#endif
}
- (void)close
{
if (_socket == INVALID_SOCKET)
@throw [OFNotOpenException exceptionWithObject: self];
close(_socket);
_socket = INVALID_SOCKET;
#ifdef OF_WII
if (_port > 0) {
of_socket_port_free(_port, SOCK_DGRAM);
_port = 0;
}
#endif
}
@end
|
Changes to src/ObjFW.h.
| ︙ | ︙ | |||
10 11 12 13 14 15 16 | * * 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. */ | < < | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | * * 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. */ #import "OFObject.h" #import "OFBlock.h" #import "OFAutoreleasePool.h" #import "OFString.h" #import "OFDataArray.h" |
| ︙ | ︙ |
Changes to src/atomic.h.
| ︙ | ︙ | |||
10 11 12 13 14 15 16 | * * 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. */ | > > | < < < < | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | * * 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 <stdlib.h> #import "macros.h" #ifndef OF_HAVE_ATOMIC_OPS # error No atomic operations available! #endif #ifdef OF_HAVE_OSATOMIC # include <libkern/OSAtomic.h> #endif OF_ASSUME_NONNULL_BEGIN static OF_INLINE int |
| ︙ | ︙ | |||
56 57 58 59 60 61 62 | : "r"(i), "m"(*p) ); # endif else abort(); return i; | | | 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | : "r"(i), "m"(*p) ); # endif else abort(); return i; #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" "bne- 0b" : "=&r"(i) |
| ︙ | ︙ | |||
92 93 94 95 96 97 98 | "xaddl %0, %2\n\t" "addl %1, %0" : "+&r"(i) : "r"(i), "m"(*p) ); return i; | | | 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | "xaddl %0, %2\n\t" "addl %1, %0" : "+&r"(i) : "r"(i), "m"(*p) ); return i; #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" "bne- 0b" : "=&r"(i) |
| ︙ | ︙ | |||
138 139 140 141 142 143 144 | "xaddl %0, %2\n\t" "addl %1, %0" : "+&r"(i) : "r"(i), "m"(*p) ); return (void*)i; | | | 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | "xaddl %0, %2\n\t" "addl %1, %0" : "+&r"(i) : "r"(i), "m"(*p) ); return (void*)i; #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" "bne- 0b" : "=&r"(i) |
| ︙ | ︙ | |||
193 194 195 196 197 198 199 | : "r"(i), "m"(*p) ); # endif else abort(); return i; | | | 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | : "r"(i), "m"(*p) ); # endif else abort(); return i; #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" "bne- 0b" : "=&r"(i) |
| ︙ | ︙ | |||
230 231 232 233 234 235 236 | "xaddl %0, %2\n\t" "subl %1, %0" : "+&r"(i) : "r"(i), "m"(*p) ); return i; | | | 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 | "xaddl %0, %2\n\t" "subl %1, %0" : "+&r"(i) : "r"(i), "m"(*p) ); return i; #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" "bne- 0b" : "=&r"(i) |
| ︙ | ︙ | |||
278 279 280 281 282 283 284 | "xaddl %0, %2\n\t" "subl %1, %0" : "+&r"(i) : "r"(i), "m"(*p) ); return (void*)i; | | | 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 | "xaddl %0, %2\n\t" "subl %1, %0" : "+&r"(i) : "r"(i), "m"(*p) ); return (void*)i; #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" "bne- 0b" : "=&r"(i) |
| ︙ | ︙ | |||
337 338 339 340 341 342 343 | : "m"(*p) ); # endif else abort(); return i; | | | 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 | : "m"(*p) ); # endif else abort(); return i; #elif defined(OF_POWERPC_ASM) int i; __asm__ __volatile__ ( "0:\n\t" "lwarx %0, 0, %1\n\t" "addi %0, %0, 1\n\t" "stwcx. %0, 0, %1\n\t" |
| ︙ | ︙ | |||
379 380 381 382 383 384 385 | "xaddl %0, %1\n\t" "incl %0" : "=&r"(i) : "m"(*p) ); return i; | | | 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 | "xaddl %0, %1\n\t" "incl %0" : "=&r"(i) : "m"(*p) ); return i; #elif defined(OF_POWERPC_ASM) int32_t i; __asm__ __volatile__ ( "0:\n\t" "lwarx %0, 0, %1\n\t" "addi %0, %0, 1\n\t" "stwcx. %0, 0, %1\n\t" |
| ︙ | ︙ | |||
436 437 438 439 440 441 442 | : "m"(*p) ); # endif else abort(); return i; | | | 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 | : "m"(*p) ); # endif else abort(); return i; #elif defined(OF_POWERPC_ASM) int i; __asm__ __volatile__ ( "0:\n\t" "lwarx %0, 0, %1\n\t" "subi %0, %0, 1\n\t" "stwcx. %0, 0, %1\n\t" |
| ︙ | ︙ | |||
478 479 480 481 482 483 484 | "xaddl %0, %1\n\t" "decl %0" : "=&r"(i) : "m"(*p) ); return i; | | | 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 | "xaddl %0, %1\n\t" "decl %0" : "=&r"(i) : "m"(*p) ); return i; #elif defined(OF_POWERPC_ASM) int32_t i; __asm__ __volatile__ ( "0:\n\t" "lwarx %0, 0, %1\n\t" "subi %0, %0, 1\n\t" "stwcx. %0, 0, %1\n\t" |
| ︙ | ︙ | |||
539 540 541 542 543 544 545 | : "rax", "cc" ); # endif else abort(); return i; | | | 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 | : "rax", "cc" ); # endif else abort(); return i; #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" "bne- 0b" : "=&r"(i) |
| ︙ | ︙ | |||
580 581 582 583 584 585 586 | "jne 0b" : "=&r"(i) : "r"(i), "m"(*p) : "eax", "cc" ); return i; | | | 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 | "jne 0b" : "=&r"(i) : "r"(i), "m"(*p) : "eax", "cc" ); return i; #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" "bne- 0b" : "=&r"(i) |
| ︙ | ︙ | |||
639 640 641 642 643 644 645 | : "rax", "cc" ); # endif else abort(); return i; | | | 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 | : "rax", "cc" ); # endif else abort(); return i; #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" "bne- 0b" : "=&r"(i) |
| ︙ | ︙ | |||
680 681 682 683 684 685 686 | "jne 0b" : "=&r"(i) : "r"(i), "m"(*p) : "eax", "cc" ); return i; | | | 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 | "jne 0b" : "=&r"(i) : "r"(i), "m"(*p) : "eax", "cc" ); return i; #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" "bne- 0b" : "=&r"(i) |
| ︙ | ︙ | |||
739 740 741 742 743 744 745 | : "rax", "cc" ); # endif else abort(); return i; | | | 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 | : "rax", "cc" ); # endif else abort(); return i; #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" "bne- 0b" : "=&r"(i) |
| ︙ | ︙ | |||
780 781 782 783 784 785 786 | "jne 0b" : "=&r"(i) : "r"(i), "m"(*p) : "eax", "cc" ); return i; | | | 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 | "jne 0b" : "=&r"(i) : "r"(i), "m"(*p) : "eax", "cc" ); return i; #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" "bne- 0b" : "=&r"(i) |
| ︙ | ︙ | |||
825 826 827 828 829 830 831 | "movzbl %b0, %0" : "=&d"(r), "+a"(o) /* use d instead of r to avoid a gcc bug */ : "r"(n), "m"(*p) : "cc" ); return r; | | | 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 | "movzbl %b0, %0" : "=&d"(r), "+a"(o) /* use d instead of r to avoid a gcc bug */ : "r"(n), "m"(*p) : "cc" ); return r; #elif defined(OF_POWERPC_ASM) int r; __asm__ __volatile__ ( "0:\n\t" "lwarx %0, 0, %3\n\t" "cmpw %0, %1\n\t" "bne 1f\n\t" |
| ︙ | ︙ | |||
880 881 882 883 884 885 886 | "movzbl %b0, %0" : "=&d"(r), "+a"(o) /* use d instead of r to avoid a gcc bug */ : "r"(n), "m"(*p) : "cc" ); return r; | | | 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 | "movzbl %b0, %0" : "=&d"(r), "+a"(o) /* use d instead of r to avoid a gcc bug */ : "r"(n), "m"(*p) : "cc" ); return r; #elif defined(OF_POWERPC_ASM) int r; __asm__ __volatile__ ( "0:\n\t" "lwarx %0, 0, %3\n\t" "cmpw %0, %1\n\t" "bne 1f\n\t" |
| ︙ | ︙ | |||
936 937 938 939 940 941 942 | "movzbl %b0, %0" : "=&d"(r), "+a"(o) /* use d instead of r to avoid a gcc bug */ : "r"(n), "m"(*p) : "cc" ); return r; | | | 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 | "movzbl %b0, %0" : "=&d"(r), "+a"(o) /* use d instead of r to avoid a gcc bug */ : "r"(n), "m"(*p) : "cc" ); return r; #elif defined(OF_POWERPC_ASM) int r; __asm__ __volatile__ ( "0:\n\t" "lwarx %0, 0, %3\n\t" "cmpw %0, %1\n\t" "bne 1f\n\t" |
| ︙ | ︙ | |||
973 974 975 976 977 978 979 |
of_memory_barrier(void)
{
#if !defined(OF_HAVE_THREADS)
#elif defined(OF_X86_64_ASM) || defined(OF_X86_ASM)
__asm__ __volatile__ (
"mfence"
);
| | | 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 |
of_memory_barrier(void)
{
#if !defined(OF_HAVE_THREADS)
#elif defined(OF_X86_64_ASM) || defined(OF_X86_ASM)
__asm__ __volatile__ (
"mfence"
);
#elif defined(OF_POWERPC_ASM)
__asm__ __volatile__ (
"sync"
);
#elif defined(OF_HAVE_GCC_ATOMIC_OPS)
__sync_synchronize();
#elif defined(OF_HAVE_OSATOMIC)
OSMemoryBarrier();
|
| ︙ | ︙ |
Changes to src/base64.h.
| ︙ | ︙ | |||
10 11 12 13 14 15 16 | * * 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. */ | < < | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | * * 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. */ #ifndef __STDC_LIMIT_MACROS # define __STDC_LIMIT_MACROS #endif #ifndef __STDC_CONSTANT_MACROS # define __STDC_CONSTANT_MACROS #endif |
| ︙ | ︙ |
Changes to src/exceptions/OFAddressTranslationFailedException.m.
| ︙ | ︙ | |||
105 106 107 108 109 110 111 |
[super dealloc];
}
- (OFString*)description
{
/* FIXME: Add proper description for Win32 */
| | | | 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
[super dealloc];
}
- (OFString*)description
{
/* FIXME: Add proper description for 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 OF_WINDOWS
}
# ifdef HAVE_GETADDRINFO
# if defined(OF_HAVE_THREADS) && !defined(HAVE_THREADSAFE_GETADDRINFO)
if (!of_mutex_lock(&mutex))
@throw [OFLockFailedException exception];
|
| ︙ | ︙ |
Changes to src/exceptions/OFException.h.
| ︙ | ︙ | |||
20 21 22 23 24 25 26 | #ifndef DOXYGEN @class OFArray OF_GENERIC(ObjectType); @class OFMutableArray OF_GENERIC(ObjectType); #endif #define OF_BACKTRACE_SIZE 32 | | | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | #ifndef DOXYGEN @class OFArray OF_GENERIC(ObjectType); @class OFMutableArray OF_GENERIC(ObjectType); #endif #define OF_BACKTRACE_SIZE 32 #if defined(OF_WINDOWS) && defined(OF_HAVE_SOCKETS) # ifndef EADDRINUSE # define EADDRINUSE WSAEADDRINUSE # endif # ifndef EADDRNOTAVAIL # define EADDRNOTAVAIL WSAEADDRNOTAVAIL # endif # ifndef EAFNOSUPPORT |
| ︙ | ︙ |
Changes to src/exceptions/OFException.m.
| ︙ | ︙ | |||
34 35 36 37 38 39 40 | #import "OFLockFailedException.h" #import "OFUnlockFailedException.h" #if !defined(HAVE_STRERROR_R) && defined(OF_HAVE_THREADS) # import "threading.h" #endif | | | 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | #import "OFLockFailedException.h" #import "OFUnlockFailedException.h" #if !defined(HAVE_STRERROR_R) && defined(OF_HAVE_THREADS) # import "threading.h" #endif #if defined(OF_WINDOWS) && defined(OF_HAVE_SOCKETS) # include <winerror.h> #endif /* * Define HAVE_DWARF_EXCEPTIONS if OBJC_ZEROCOST_EXCEPTIONS is defined, but * don't do so on iOS, as it is defined there even if SjLj exceptions are used. */ |
| ︙ | ︙ | |||
70 71 72 73 74 75 76 |
struct backtrace_ctx {
void **backtrace;
uint_fast8_t i;
};
extern _Unwind_Reason_Code _Unwind_Backtrace(
_Unwind_Reason_Code(*)(struct _Unwind_Context*, void*), void*);
| | | 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
struct backtrace_ctx {
void **backtrace;
uint_fast8_t i;
};
extern _Unwind_Reason_Code _Unwind_Backtrace(
_Unwind_Reason_Code(*)(struct _Unwind_Context*, void*), void*);
# 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
#if !defined(HAVE_STRERROR_R) && defined(OF_HAVE_THREADS)
|
| ︙ | ︙ | |||
96 97 98 99 100 101 102 |
of_strerror(int errNo)
{
OFString *ret;
#ifdef HAVE_STRERROR_R
char buffer[256];
#endif
| | | 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
of_strerror(int errNo)
{
OFString *ret;
#ifdef HAVE_STRERROR_R
char buffer[256];
#endif
#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!
*/
switch (errNo) {
|
| ︙ | ︙ | |||
211 212 213 214 215 216 217 |
#ifdef HAVE_DWARF_EXCEPTIONS
static _Unwind_Reason_Code
backtrace_callback(struct _Unwind_Context *ctx, void *data)
{
struct backtrace_ctx *bt = data;
if (bt->i < OF_BACKTRACE_SIZE) {
| | | 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
#ifdef HAVE_DWARF_EXCEPTIONS
static _Unwind_Reason_Code
backtrace_callback(struct _Unwind_Context *ctx, void *data)
{
struct backtrace_ctx *bt = data;
if (bt->i < OF_BACKTRACE_SIZE) {
# ifdef OF_ARM
uintptr_t ip;
_Unwind_VRS_Get(ctx, 0, 15, 0, &ip);
bt->backtrace[bt->i++] = (void*)(ip & ~1);
# else
bt->backtrace[bt->i++] = (void*)_Unwind_GetIP(ctx);
# endif
|
| ︙ | ︙ |
Changes to src/forwarding/Makefile.
1 2 3 4 5 6 7 8 9 |
include ../../extra.mk
STATIC_PIC_LIB_NOINST = ${FORWARDING_LIB_A}
STATIC_LIB_NOINST = ${FORWARDING_A}
SRCS = forwarding.S
include ../../buildsys.mk
| | | 1 2 3 4 5 6 7 8 9 10 |
include ../../extra.mk
STATIC_PIC_LIB_NOINST = ${FORWARDING_LIB_A}
STATIC_LIB_NOINST = ${FORWARDING_A}
SRCS = forwarding.S
include ../../buildsys.mk
ASFLAGS += -I../.. -I..
|
Changes to src/forwarding/forwarding-arm-elf.S.
| ︙ | ︙ | |||
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
* 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"
.globl of_forward
.globl of_forward_stret
.section .text
of_forward:
#ifdef HAVE_VFP2
fstmfdd sp!, {d0-d7}
| > > | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#include "platform.h"
.globl of_forward
.globl of_forward_stret
.section .text
of_forward:
#ifdef HAVE_VFP2
fstmfdd sp!, {d0-d7}
|
| ︙ | ︙ | |||
163 164 165 166 167 168 169 | .long 0, sel_forwardingTargetForSelector_ .short 0, 0 .long 0 .long 0 module: .long 8, 16, 0, symtab | | | 165 166 167 168 169 170 171 172 173 174 | .long 0, sel_forwardingTargetForSelector_ .short 0, 0 .long 0 .long 0 module: .long 8, 16, 0, symtab #ifdef OF_LINUX .section .note.GNU-stack, "", %progbits #endif |
Changes to src/forwarding/forwarding-mips-elf.S.
| ︙ | ︙ | |||
12 13 14 15 16 17 18 19 20 21 | * 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" .globl of_forward .globl of_forward_stret | > > | | | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #include "platform.h" .globl of_forward .globl of_forward_stret #ifdef OF_PIC .macro j_pic symbol lw $t9, %call16(\symbol)($gp) jr $t9 .endm .macro jal_pic symbol lw $t9, %call16(\symbol)($gp) jalr $t9 .endm #else .macro j_pic symbol j \symbol .endm .macro jal_pic symbol jal \symbol .endm #endif .section .text of_forward: #ifdef OF_PIC lui $gp, %hi(_gp_disp) addiu $gp, $gp, %lo(_gp_disp) addu $gp, $gp, $t9 #endif addiu $sp, $sp, -96 |
| ︙ | ︙ | |||
58 59 60 61 62 63 64 | sw $s0, 20($sp) sw $s1, 24($sp) sw $a0, 28($sp) sw $a1, 32($sp) sw $a2, 36($sp) sw $a3, 40($sp) | | | | 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | sw $s0, 20($sp) sw $s1, 24($sp) sw $a0, 28($sp) sw $a1, 32($sp) sw $a2, 36($sp) sw $a3, 40($sp) #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) swc1 $f12, 60($sp) swc1 $f13, 64($sp) swc1 $f14, 68($sp) swc1 $f15, 72($sp) swc1 $f16, 76($sp) swc1 $f17, 80($sp) swc1 $f18, 84($sp) swc1 $f19, 88($sp) #endif move $s0, $gp #ifdef OF_PIC lw $s1, %got(sel_forwardingTargetForSelector_)($gp) #else lui $s1, %hi(sel_forwardingTargetForSelector_) #endif addiu $s1, $s1, %lo(sel_forwardingTargetForSelector_) jal_pic object_getClass |
| ︙ | ︙ | |||
114 115 116 117 118 119 120 | sw $v0, 28($sp) move $gp, $s0 move $a0, $v0 lw $a1, 32($sp) jal_pic objc_msg_lookup | | | 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | sw $v0, 28($sp) move $gp, $s0 move $a0, $v0 lw $a1, 32($sp) jal_pic objc_msg_lookup #ifdef OF_MIPS_EABI lwc1 $f19, 88($sp) lwc1 $f18, 84($sp) lwc1 $f17, 80($sp) lwc1 $f16, 76($sp) lwc1 $f15, 72($sp) lwc1 $f14, 68($sp) lwc1 $f13, 64($sp) |
| ︙ | ︙ | |||
159 160 161 162 163 164 165 | addiu $sp, $sp, 96 j_pic of_method_not_found .type of_forward, %function .size of_forward, .-of_forward of_forward_stret: | | | 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | addiu $sp, $sp, 96 j_pic of_method_not_found .type of_forward, %function .size of_forward, .-of_forward of_forward_stret: #ifdef OF_PIC lui $gp, %hi(_gp_disp) addiu $gp, $gp, %lo(_gp_disp) addu $gp, $gp, $t9 #endif addiu $sp, $sp, -96 |
| ︙ | ︙ | |||
182 183 184 185 186 187 188 | sw $s0, 20($sp) sw $s1, 24($sp) sw $a0, 28($sp) sw $a1, 32($sp) sw $a2, 36($sp) sw $a3, 40($sp) | | | | 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | sw $s0, 20($sp) sw $s1, 24($sp) sw $a0, 28($sp) sw $a1, 32($sp) sw $a2, 36($sp) sw $a3, 40($sp) #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) swc1 $f12, 60($sp) swc1 $f13, 64($sp) swc1 $f14, 68($sp) swc1 $f15, 72($sp) swc1 $f16, 76($sp) swc1 $f17, 80($sp) swc1 $f18, 84($sp) swc1 $f19, 88($sp) #endif move $s0, $gp #ifdef OF_PIC lw $s1, %got(sel_forwardingTargetForSelector_)($gp) #else lui $s1, %hi(sel_forwardingTargetForSelector_) #endif addiu $s1, $s1, %lo(sel_forwardingTargetForSelector_) move $a0, $a1 |
| ︙ | ︙ | |||
239 240 241 242 243 244 245 | sw $v0, 32($sp) move $gp, $s0 move $a0, $v0 lw $a1, 36($sp) jal_pic objc_msg_lookup_stret | | | 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | sw $v0, 32($sp) move $gp, $s0 move $a0, $v0 lw $a1, 36($sp) jal_pic objc_msg_lookup_stret #ifdef OF_MIPS_EABI lwc1 $f19, 88($sp) lwc1 $f18, 84($sp) lwc1 $f17, 80($sp) lwc1 $f16, 76($sp) lwc1 $f15, 72($sp) lwc1 $f14, 68($sp) lwc1 $f13, 64($sp) |
| ︙ | ︙ | |||
285 286 287 288 289 290 291 | addiu $sp, $sp, 96 j_pic of_method_not_found_stret .type of_forward_stret, %function .size of_forward_stret, .-of_forward_stret init: | | | 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 | addiu $sp, $sp, 96 j_pic of_method_not_found_stret .type of_forward_stret, %function .size of_forward_stret, .-of_forward_stret init: #ifdef OF_PIC lui $gp, %hi(_gp_disp) addiu $gp, $gp, %lo(_gp_disp) addu $gp, $gp, $t9 lw $a0, %got(module)($gp) addiu $a0, $a0, %lo(module) lw $t9, %call16(__objc_exec_class)($gp) |
| ︙ | ︙ | |||
319 320 321 322 323 324 325 | .long 0, sel_forwardingTargetForSelector_ .short 0, 0 .long 0 .long 0 module: .long 8, 16, 0, symtab | | | 321 322 323 324 325 326 327 328 329 330 | .long 0, sel_forwardingTargetForSelector_ .short 0, 0 .long 0 .long 0 module: .long 8, 16, 0, symtab #ifdef OF_LINUX .section .note.GNU-stack, "", %progbits #endif |
Changes to src/forwarding/forwarding-ppc-elf.S.
| ︙ | ︙ | |||
12 13 14 15 16 17 18 19 20 21 22 23 24 25 | * 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" .globl of_forward .globl of_forward_stret .section .text of_forward: stwu %r1, -112(%r1) mflr %r0 | > > | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #include "platform.h" .globl of_forward .globl of_forward_stret .section .text of_forward: stwu %r1, -112(%r1) mflr %r0 |
| ︙ | ︙ | |||
232 233 234 235 236 237 238 | .long 0, sel_forwardingTargetForSelector_ .short 0, 0 .long 0 .long 0 module: .long 8, 16, 0, symtab | | | 234 235 236 237 238 239 240 241 242 243 | .long 0, sel_forwardingTargetForSelector_ .short 0, 0 .long 0 .long 0 module: .long 8, 16, 0, symtab #ifdef OF_LINUX .section .note.GNU-stack, "", %progbits #endif |
Changes to src/forwarding/forwarding-x86-elf.S.
| ︙ | ︙ | |||
12 13 14 15 16 17 18 19 20 21 22 23 24 25 | * 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" .globl of_forward .globl of_forward_stret .section .text of_forward: pushl %ebp movl %esp, %ebp | > > | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #include "platform.h" .globl of_forward .globl of_forward_stret .section .text of_forward: pushl %ebp movl %esp, %ebp |
| ︙ | ︙ | |||
198 199 200 201 202 203 204 | .long 0, sel_forwardingTargetForSelector_ .short 0, 0 .long 0 .long 0 module: .long 8, 16, 0, symtab | | | 200 201 202 203 204 205 206 207 208 209 | .long 0, sel_forwardingTargetForSelector_ .short 0, 0 .long 0 .long 0 module: .long 8, 16, 0, symtab #ifdef OF_LINUX .section .note.GNU-stack, "", %progbits #endif |
Changes to src/forwarding/forwarding-x86_64-elf.S.
| ︙ | ︙ | |||
12 13 14 15 16 17 18 19 20 21 22 23 24 25 | * 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" .globl of_forward .globl of_forward_stret .section .text of_forward: pushq %rbp movq %rsp, %rbp | > > | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #include "platform.h" .globl of_forward .globl of_forward_stret .section .text of_forward: pushq %rbp movq %rsp, %rbp |
| ︙ | ︙ | |||
211 212 213 214 215 216 217 | .quad 0, sel_forwardingTargetForSelector_ .short 0, 0 .long 0 .quad 0 module: .quad 8, 32, 0, symtab | | | 213 214 215 216 217 218 219 220 221 222 | .quad 0, sel_forwardingTargetForSelector_ .short 0, 0 .long 0 .quad 0 module: .quad 8, 32, 0, symtab #ifdef OF_LINUX .section .note.GNU-stack, "", %progbits #endif |
Changes to src/forwarding/forwarding.S.
| ︙ | ︙ | |||
11 12 13 14 15 16 17 18 19 | * 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 OF_APPLE_RUNTIME | > > | | | | | | | | | | < | | | | | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #include "platform.h" #ifdef OF_APPLE_RUNTIME # if defined(OF_X86_64) # include "apple-forwarding-x86_64.S" # elif defined(OF_X86) # include "apple-forwarding-i386.S" # elif defined(OF_ARM64) # include "apple-forwarding-arm64.S" # elif defined(OF_ARM) # include "apple-forwarding-arm.S" # elif defined(OF_POWERPC) # include "apple-forwarding-ppc.S" # endif #else # if defined(OF_ELF) # if defined(OF_X86_64) # include "forwarding-x86_64-elf.S" # elif defined(OF_X86) # include "forwarding-x86-elf.S" # elif defined(OF_ARM) # include "forwarding-arm-elf.S" # elif defined(OF_POWERPC) # include "forwarding-ppc-elf.S" # elif defined(OF_MIPS) # include "forwarding-mips-elf.S" # endif # elif defined(OF_WINDOWS) # if defined(OF_X86_64) # include "forwarding-x86_64-win64.S" # elif defined(OF_X86) # include "forwarding-x86-win32.S" # endif # endif #endif |
Changes to src/macros.h.
| ︙ | ︙ | |||
10 11 12 13 14 15 16 | * * 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. */ | | > > | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | * * 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 # define __STDC_CONSTANT_MACROS #endif #include <stdbool.h> #include <stddef.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "platform.h" #ifdef OF_OBJFW_RUNTIME # import "runtime.h" #endif #ifdef OF_APPLE_RUNTIME # import <objc/objc.h> # import <objc/runtime.h> |
| ︙ | ︙ | |||
72 73 74 75 76 77 78 | # define OF_INLINE inline # define OF_LIKELY(cond) cond # define OF_UNLIKELY(cond) cond # define OF_CONST_FUNC # define OF_NO_RETURN_FUNC #endif | < < < < < < < < < < | 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | # define OF_INLINE inline # define OF_LIKELY(cond) cond # define OF_UNLIKELY(cond) cond # define OF_CONST_FUNC # define OF_NO_RETURN_FUNC #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 #if __STDC_VERSION__ >= 201112L && defined(OF_HAVE_MAX_ALIGN_T) |
| ︙ | ︙ | |||
227 228 229 230 231 232 233 | # define OF_SUBCLASSING_RESTRICTED \ __attribute__((__objc_subclassing_restricted__)) #else # define OF_SUBCLASSING_RESTRICTED #endif #ifdef __GNUC__ | < | < | < < < < < < | | | | | | | | | | < < < | | | < | < < | | < | < < | | < < < | < < < < < < | | | | | < < < < < < < < | | | | 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 | # define OF_SUBCLASSING_RESTRICTED \ __attribute__((__objc_subclassing_restricted__)) #else # define OF_SUBCLASSING_RESTRICTED #endif #ifdef __GNUC__ # ifdef OF_X86_64 # define OF_X86_64_ASM # endif # ifdef OF_X86 # define OF_X86_ASM # endif # ifdef OF_POWERPC # define OF_POWERPC_ASM # endif # ifdef OF_ARM64 # define OF_ARM64_ASM # endif # ifdef OF_ARM # define OF_ARM_ASM # 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(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(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 # 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 # endif #endif #define OF_RETAIN_COUNT_MAX UINT_MAX #define OF_NOT_FOUND SIZE_MAX #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 '\\' # define OF_PATH_DELIMITER_STRING @"\\" # define OF_IS_PATH_DELIMITER(c) (c == '\\' || c == '/') |
| ︙ | ︙ | |||
403 404 405 406 407 408 409 | return __builtin_bswap16(i); #elif defined(OF_X86_64_ASM) || defined(OF_X86_ASM) __asm__ ( "xchgb %h0, %b0" : "=Q"(i) : "0"(i) ); | | | 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 | return __builtin_bswap16(i); #elif defined(OF_X86_64_ASM) || defined(OF_X86_ASM) __asm__ ( "xchgb %h0, %b0" : "=Q"(i) : "0"(i) ); #elif defined(OF_POWERPC_ASM) __asm__ ( "lhbrx %0, 0, %1" : "=r"(i) : "r"(&i), "m"(i) ); #elif defined(OF_ARMV6_ASM) __asm__ ( |
| ︙ | ︙ | |||
433 434 435 436 437 438 439 | return __builtin_bswap32(i); #elif defined(OF_X86_64_ASM) || defined(OF_X86_ASM) __asm__ ( "bswap %0" : "=q"(i) : "0"(i) ); | | | 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 | return __builtin_bswap32(i); #elif defined(OF_X86_64_ASM) || defined(OF_X86_ASM) __asm__ ( "bswap %0" : "=q"(i) : "0"(i) ); #elif defined(OF_POWERPC_ASM) __asm__ ( "lwbrx %0, 0, %1" : "=r"(i) : "r"(&i), "m"(i) ); #elif defined(OF_ARMV6_ASM) __asm__ ( |
| ︙ | ︙ |
Changes to src/of_asprintf.m.
| ︙ | ︙ | |||
210 211 212 213 214 215 216 |
ctx->lengthModifier = LENGTH_MODIFIER_H;
}
break;
case 'l': /* and also ll */
if (ctx->formatLen > ctx->i + 1 &&
ctx->format[ctx->i + 1] == 'l') {
| | | | | | | 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 |
ctx->lengthModifier = LENGTH_MODIFIER_H;
}
break;
case 'l': /* and also ll */
if (ctx->formatLen > ctx->i + 1 &&
ctx->format[ctx->i + 1] == 'l') {
#ifndef OF_WINDOWS
if (!appendSubformat(ctx, ctx->format + ctx->i, 2))
return false;
#else
if (!appendSubformat(ctx, "I64", 3))
return false;
#endif
ctx->i++;
ctx->lengthModifier = LENGTH_MODIFIER_LL;
} else {
if (!appendSubformat(ctx, ctx->format + ctx->i, 1))
return false;
ctx->lengthModifier = LENGTH_MODIFIER_L;
}
break;
case 'j':
#if defined(OF_WINDOWS)
if (!appendSubformat(ctx, "I64", 3))
return false;
#elif defined(_NEWLIB_VERSION)
if (!appendSubformat(ctx, "ll", 2))
return false;
#else
if (!appendSubformat(ctx, ctx->format + ctx->i, 1))
return false;
#endif
ctx->lengthModifier = LENGTH_MODIFIER_J;
break;
case 'z':
#if defined(OF_WINDOWS)
if (!appendSubformat(ctx, "I", 1))
return false;
#elif defined(_NEWLIB_VERSION)
if (!appendSubformat(ctx, "l", 1))
return false;
#else
if (!appendSubformat(ctx, ctx->format + ctx->i, 1))
return false;
#endif
ctx->lengthModifier = LENGTH_MODIFIER_Z;
break;
case 't':
#if defined(OF_WINDOWS)
if (!appendSubformat(ctx, "I", 1))
return false;
#elif defined(_NEWLIB_VERSION)
if (!appendSubformat(ctx, "l", 1))
return false;
#else
if (!appendSubformat(ctx, ctx->format + ctx->i, 1))
return false;
#endif
ctx->lengthModifier = LENGTH_MODIFIER_T;
break;
case 'L':
if (!appendSubformat(ctx, ctx->format + ctx->i, 1))
return false;
ctx->lengthModifier = LENGTH_MODIFIER_CAPITAL_L;
break;
#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))
return false;
|
| ︙ | ︙ |
Changes to src/of_strptime.m.
| ︙ | ︙ | |||
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
*/
#include "config.h"
#include <string.h>
#include <time.h>
const char*
of_strptime(const char *buffer, const char *format, struct tm *tm)
{
enum {
SEARCH_CONVERSION_SPECIFIER,
IN_CONVERSION_SPECIFIER
| > > | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
*/
#include "config.h"
#include <string.h>
#include <time.h>
#include "macros.h"
const char*
of_strptime(const char *buffer, const char *format, struct tm *tm)
{
enum {
SEARCH_CONVERSION_SPECIFIER,
IN_CONVERSION_SPECIFIER
|
| ︙ | ︙ |
Added src/platform.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | /* * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 * Jonathan Schleifer <js@webkeks.org> * * 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 |
Changes to src/resolver.m.
| ︙ | ︙ | |||
161 162 163 164 165 166 167 |
if ((addr = calloc(1, sizeof(*addr))) == NULL) {
free(ret);
free(tmp);
@throw [OFOutOfMemoryException
exceptionWithRequestedSize: sizeof(*addr)];
}
| | | | 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
if ((addr = calloc(1, sizeof(*addr))) == NULL) {
free(ret);
free(tmp);
@throw [OFOutOfMemoryException
exceptionWithRequestedSize: sizeof(*addr)];
}
#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;
tmp->family = AF_INET;
tmp->type = type;
tmp->protocol = 0;
tmp->address = (struct sockaddr*)addr;
#ifndef OF_WII
tmp->addressLength = sizeof(*addr);
#else
tmp->addressLength = 8;
#endif
ret[0] = tmp;
ret[1] = NULL;
|
| ︙ | ︙ |
Changes to src/runtime/exception.m.
| ︙ | ︙ | |||
20 21 22 23 24 25 26 27 28 29 30 31 32 33 | #include <string.h> #ifdef HAVE_SEH_EXCEPTIONS # include <windows.h> #endif #import "runtime.h" #if defined(HAVE_DWARF_EXCEPTIONS) # define PERSONALITY __gnu_objc_personality_v0 #elif defined(HAVE_SJLJ_EXCEPTIONS) # define PERSONALITY __gnu_objc_personality_sj0 # define _Unwind_RaiseException _Unwind_SjLj_RaiseException # define __builtin_eh_return_data_regno(i) (i) | > > | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | #include <string.h> #ifdef HAVE_SEH_EXCEPTIONS # include <windows.h> #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 # define _Unwind_RaiseException _Unwind_SjLj_RaiseException # define __builtin_eh_return_data_regno(i) (i) |
| ︙ | ︙ | |||
82 83 84 85 86 87 88 |
_URC_FAILURE = 9
} _Unwind_Reason_Code;
struct objc_exception {
struct _Unwind_Exception {
uint64_t class;
void (*cleanup)(_Unwind_Reason_Code, struct _Unwind_Exception*);
| | | 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
_URC_FAILURE = 9
} _Unwind_Reason_Code;
struct objc_exception {
struct _Unwind_Exception {
uint64_t class;
void (*cleanup)(_Unwind_Reason_Code, struct _Unwind_Exception*);
#ifdef OF_ARM
/* From "Exception Handling ABI for the ARM(R) Architecture" */
struct {
uint32_t reserved1, reserved2, reserved3, reserved4;
uint32_t reserved;
} unwinder_cache;
struct {
uint32_t sp;
|
| ︙ | ︙ | |||
115 116 117 118 119 120 121 | * them. */ uint64_t private1, private2; # endif #endif } exception; id object; | | | 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
* them.
*/
uint64_t private1, private2;
# endif
#endif
} exception;
id object;
#ifndef OF_ARM
uintptr_t landingpad;
intptr_t filter;
#endif
};
struct lsda {
uintptr_t region_start, landingpads_start;
|
| ︙ | ︙ | |||
137 138 139 140 141 142 143 | extern _Unwind_Reason_Code _Unwind_RaiseException(struct _Unwind_Exception*); extern void _Unwind_DeleteException(struct _Unwind_Exception*); 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*); | | | 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
extern _Unwind_Reason_Code _Unwind_RaiseException(struct _Unwind_Exception*);
extern void _Unwind_DeleteException(struct _Unwind_Exception*);
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*);
#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*);
# define CONTINUE_UNWIND \
{ \
|
| ︙ | ︙ | |||
310 311 312 313 314 315 316 | abort(); } #undef READ return value; } | | | 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 |
abort();
}
#undef READ
return value;
}
#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;
value += ((enc & 0x70) == DW_EH_PE_pcrel ? (uintptr_t)start : base);
|
| ︙ | ︙ | |||
457 458 459 460 461 462 463 |
if (filter > 0 && !(actions & _UA_FORCE_UNWIND) && !foreign) {
Class class;
const char *className;
uintptr_t c;
const uint8_t *tmp;
| | | | 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 |
if (filter > 0 && !(actions & _UA_FORCE_UNWIND) && !foreign) {
Class class;
const char *className;
uintptr_t c;
const uint8_t *tmp;
#ifdef OF_ARM
tmp = lsda->typestable - (filter * 4);
c = *(uintptr_t*)(void*)tmp;
if (c != 0) {
c += (uintptr_t)tmp;
# if defined(OF_LINUX) || defined(OF_NETBSD)
c = *(uintptr_t*)c;
# endif
}
#else
uintptr_t i;
i = filter * size_for_encoding(lsda->typestable_enc);
|
| ︙ | ︙ | |||
498 499 500 501 502 503 504 | else abort(); } while (displacement != 0); return 0; } | | | 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 |
else
abort();
} while (displacement != 0);
return 0;
}
#ifdef OF_ARM
_Unwind_Reason_Code
PERSONALITY(uint32_t state, struct _Unwind_Exception *ex,
struct _Unwind_Context *ctx)
{
int version = 1;
uint64_t ex_class = ex->class;
int actions;
|
| ︙ | ︙ | |||
554 555 556 557 558 559 560 |
if (actions & _UA_HANDLER_FRAME && !foreign) {
/*
* 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);
| | | 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 |
if (actions & _UA_HANDLER_FRAME && !foreign) {
/*
* 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);
#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),
e->filter);
_Unwind_SetIP(ctx, e->landingpad);
|
| ︙ | ︙ | |||
592 593 594 595 596 597 598 |
CONTINUE_UNWIND;
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 */
| | | 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 |
CONTINUE_UNWIND;
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 */
#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;
e->filter = filter;
#endif
|
| ︙ | ︙ |
Changes to src/runtime/lookup-asm/Makefile.
1 2 3 4 5 6 7 8 9 |
include ../../../extra.mk
STATIC_PIC_LIB_NOINST = ${LOOKUP_ASM_LIB_A}
STATIC_LIB_NOINST = ${LOOKUP_ASM_A}
SRCS = lookup-asm.S
include ../../../buildsys.mk
| | | 1 2 3 4 5 6 7 8 9 10 |
include ../../../extra.mk
STATIC_PIC_LIB_NOINST = ${LOOKUP_ASM_LIB_A}
STATIC_LIB_NOINST = ${LOOKUP_ASM_A}
SRCS = lookup-asm.S
include ../../../buildsys.mk
ASFLAGS += -I../../.. -I../..
|
Changes to src/runtime/lookup-asm/lookup-asm-arm-elf.S.
| ︙ | ︙ | |||
11 12 13 14 15 16 17 18 19 20 21 22 23 24 | * 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" .globl objc_msg_lookup .globl objc_msg_lookup_stret .globl objc_msg_lookup_super .globl objc_msg_lookup_super_stret .section .text | > > | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #include "platform.h" .globl objc_msg_lookup .globl objc_msg_lookup_stret .globl objc_msg_lookup_super .globl objc_msg_lookup_super_stret .section .text |
| ︙ | ︙ | |||
72 73 74 75 76 77 78 | adr r0, nil_method bx lr nil_method: mov r0, #0 bx lr | | | 74 75 76 77 78 79 80 81 82 83 | adr r0, nil_method bx lr nil_method: mov r0, #0 bx lr #ifdef OF_LINUX .section .note.GNU-stack, "", %progbits #endif |
Changes to src/runtime/lookup-asm/lookup-asm-mips-elf.S.
| ︙ | ︙ | |||
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | * 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" .globl objc_msg_lookup .globl objc_msg_lookup_stret .globl objc_msg_lookup_super .globl objc_msg_lookup_super_stret .section .text .macro generate_lookup name not_found \name: beqz $a0, 0f lw $t0, 0($a0) lw $t0, 32($t0) .Lmain_\name: | > > < | < < < < < > > | > > | | | | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #include "platform.h" .globl objc_msg_lookup .globl objc_msg_lookup_stret .globl objc_msg_lookup_super .globl objc_msg_lookup_super_stret .section .text .macro generate_lookup name not_found \name: beqz $a0, 0f lw $t0, 0($a0) lw $t0, 32($t0) .Lmain_\name: #ifdef OF_BIGENDIAN # ifdef OF_SELUID24 lbu $t1, 1($a1) # endif lbu $t2, 2($a1) lbu $t3, 3($a1) #else # 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 sll $t2, $t2, 2 sll $t3, $t3, 2 #ifdef OF_SELUID24 addu $t0, $t0, $t1 lw $t0, 0($t0) #endif addu $t0, $t0, $t2 lw $t0, 0($t0) addu $t0, $t0, $t3 lw $t0, 0($t0) #ifdef OF_PIC beqz $t0, 1f #else beqz $t0, \not_found #endif move $v0, $t0 j $ra 0: #ifdef OF_PIC addiu $v0, $t9, nil_method-\name #else la $v0, nil_method #endif j $ra #ifdef OF_PIC 1: lui $gp, %hi(_gp_disp) addiu $gp, $gp, %lo(_gp_disp) addu $gp, $gp, $t9 addiu $gp, $gp, 1b-\name lw $t9, %call16(\not_found)($gp) |
| ︙ | ︙ | |||
99 100 101 102 103 104 105 | lw $t0, 4($a0) lw $t0, 32($t0) b .Lmain_\lookup 0: | | | | 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | lw $t0, 4($a0) lw $t0, 32($t0) b .Lmain_\lookup 0: #ifdef OF_PIC addiu $v0, $t9, nil_method-\name #else la $v0, nil_method #endif j $ra .type \name, %function .size \name, .-\name .endm generate_lookup objc_msg_lookup objc_method_not_found generate_lookup objc_msg_lookup_stret objc_method_not_found_stret generate_lookup_super objc_msg_lookup_super objc_msg_lookup generate_lookup_super objc_msg_lookup_super_stret objc_msg_lookup_stret nil_method: move $v0, $zero j $ra #ifdef OF_LINUX .section .note.GNU-stack, "", %progbits #endif |
Changes to src/runtime/lookup-asm/lookup-asm-ppc-elf.S.
| ︙ | ︙ | |||
11 12 13 14 15 16 17 18 19 20 21 22 23 24 | * 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" .globl objc_msg_lookup .globl objc_msg_lookup_stret .globl objc_msg_lookup_super .globl objc_msg_lookup_super_stret .section .text | > > | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #include "platform.h" .globl objc_msg_lookup .globl objc_msg_lookup_stret .globl objc_msg_lookup_super .globl objc_msg_lookup_super_stret .section .text |
| ︙ | ︙ | |||
87 88 89 90 91 92 93 | li %r3, 0 blr get_pc: mflr %r3 blr | | | 89 90 91 92 93 94 95 96 97 98 | li %r3, 0 blr get_pc: mflr %r3 blr #ifdef OF_LINUX .section .note.GNU-stack, "", %progbits #endif |
Changes to src/runtime/lookup-asm/lookup-asm-sparc-elf.S.
| ︙ | ︙ | |||
11 12 13 14 15 16 17 18 19 20 21 22 23 24 | * 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" .globl objc_msg_lookup .globl objc_msg_lookup_stret .globl objc_msg_lookup_super .globl objc_msg_lookup_super_stret .section .text | > > | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #include "platform.h" .globl objc_msg_lookup .globl objc_msg_lookup_stret .globl objc_msg_lookup_super .globl objc_msg_lookup_super_stret .section .text |
| ︙ | ︙ | |||
100 101 102 103 104 105 106 | or %o0, %lo(nil_method), %o0 #endif nil_method: retl clr %o0 | | | 102 103 104 105 106 107 108 109 110 111 | or %o0, %lo(nil_method), %o0 #endif nil_method: retl clr %o0 #ifdef OF_LINUX .section .note.GNU-stack, "", %progbits #endif |
Changes to src/runtime/lookup-asm/lookup-asm-x86-elf.S.
| ︙ | ︙ | |||
11 12 13 14 15 16 17 18 19 20 21 22 23 24 | * 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" .globl objc_msg_lookup .globl objc_msg_lookup_stret .globl objc_msg_lookup_super .globl objc_msg_lookup_super_stret .section .text | > > | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #include "platform.h" .globl objc_msg_lookup .globl objc_msg_lookup_stret .globl objc_msg_lookup_super .globl objc_msg_lookup_super_stret .section .text |
| ︙ | ︙ | |||
86 87 88 89 90 91 92 | xorl %eax, %eax ret get_eip: movl (%esp), %eax ret | | | 88 89 90 91 92 93 94 95 96 97 | xorl %eax, %eax ret get_eip: movl (%esp), %eax ret #ifdef OF_LINUX .section .note.GNU-stack, "", %progbits #endif |
Changes to src/runtime/lookup-asm/lookup-asm-x86_64-elf.S.
| ︙ | ︙ | |||
11 12 13 14 15 16 17 18 19 20 21 22 23 24 | * 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" .globl objc_msg_lookup .globl objc_msg_lookup_stret .globl objc_msg_lookup_super .globl objc_msg_lookup_super_stret .section .text | > > | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #include "platform.h" .globl objc_msg_lookup .globl objc_msg_lookup_stret .globl objc_msg_lookup_super .globl objc_msg_lookup_super_stret .section .text |
| ︙ | ︙ | |||
72 73 74 75 76 77 78 | leaq nil_method(%rip), %rax ret nil_method: xorq %rax, %rax ret | | | 74 75 76 77 78 79 80 81 82 83 | leaq nil_method(%rip), %rax ret nil_method: xorq %rax, %rax ret #ifdef OF_LINUX .section .note.GNU-stack, "", %progbits #endif |
Changes to src/runtime/lookup-asm/lookup-asm.S.
| ︙ | ︙ | |||
12 13 14 15 16 17 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. */ #include "config.h" | > > | | | | | < | | | | | | | | | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #include "platform.h" #if defined(OF_ELF) # if defined(OF_X86_64) # include "lookup-asm-x86_64-elf.S" # elif defined(OF_X86) # include "lookup-asm-x86-elf.S" # elif defined(OF_ARM) # include "lookup-asm-arm-elf.S" # elif defined(OF_POWERPC) # include "lookup-asm-ppc-elf.S" # elif defined(OF_MIPS) # include "lookup-asm-mips-elf.S" # elif defined(OF_SPARC) # include "lookup-asm-sparc-elf.S" # endif #elif defined(OF_MACH_O) # if defined(OF_X86_64) # include "lookup-asm-x86_64-macho.S" # elif defined(OF_POWERPC) # include "lookup-asm-ppc-macho.S" # endif #elif defined(OF_WINDOWS) # if defined(OF_X86_64) # include "lookup-asm-x86_64-win64.S" # elif defined(OF_X86) # include "lookup-asm-x86-win32.S" # endif #endif |
Changes to src/runtime/runtime-private.h.
| ︙ | ︙ | |||
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
* 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"
struct objc_abi_class {
struct objc_abi_class *metaclass;
const char *superclass;
const char *name;
unsigned long version;
unsigned long info;
| > > | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#include "platform.h"
struct objc_abi_class {
struct objc_abi_class *metaclass;
const char *superclass;
const char *name;
unsigned long version;
unsigned long info;
|
| ︙ | ︙ | |||
178 179 180 181 182 183 184 | uint8_t i = idx >> 8; uint8_t j = idx; return dtable->buckets[i]->buckets[j]; #endif } | | < | | < < < < < < < | | | | | 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
uint8_t i = idx >> 8;
uint8_t j = idx;
return dtable->buckets[i]->buckets[j];
#endif
}
#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(...) \
{ \
fprintf(stderr, "[objc @ " __FILE__ ":%d] ", __LINE__); \
fprintf(stderr, __VA_ARGS__); \
fputs("\n", stderr); \
abort(); \
}
|
Changes to src/socket.h.
| ︙ | ︙ | |||
10 11 12 13 14 15 16 | * * 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. */ | | > > | | | | | | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
*
* 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 OF_HAVE_SOCKETS
# error No sockets available!
#endif
#include <stdbool.h>
#ifdef OF_HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef OF_HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#ifdef OF_HAVE_NETINET_TCP_H
# include <netinet/tcp.h>
#endif
#include "platform.h"
#ifdef OF_WINDOWS
# ifdef __MINGW32__
# include <_mingw.h>
# ifdef __MINGW64_VERSION_MAJOR
# include <winsock2.h>
# endif
# endif
# include <windows.h>
# include <ws2tcpip.h>
#endif
#ifdef OF_WII
# define BOOL OGC_BOOL
# include <network.h>
# undef BOOL
struct sockaddr_storage {
u8 ss_len;
u8 ss_family;
u8 ss_data[14];
};
#endif
#ifdef OF_PSP
# include <stdint.h>
struct sockaddr_storage {
uint8_t ss_len;
sa_family_t ss_family;
in_port_t ss_data1;
struct in_addr ss_data2;
int8_t ss_data3[8];
};
#endif
#import "macros.h"
OF_ASSUME_NONNULL_BEGIN
#ifndef OF_WINDOWS
typedef int of_socket_t;
#else
typedef SOCKET of_socket_t;
#endif
#ifdef __cplusplus
extern "C" {
#endif
extern bool of_socket_init(void);
extern int of_socket_errno(void);
# 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);
extern uint16_t of_socket_port_find(int type);
# endif
#ifdef __cplusplus
}
#endif
OF_ASSUME_NONNULL_END
|
Changes to src/socket.m.
| ︙ | ︙ | |||
28 29 30 31 32 33 34 | # include "threading.h" static of_once_t onceControl = OF_ONCE_INIT; static of_mutex_t mutex; #endif static bool initialized = false; | | | | | | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# include "threading.h"
static of_once_t onceControl = OF_ONCE_INIT;
static of_mutex_t mutex;
#endif
static bool initialized = false;
#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(OF_WINDOWS)
WSADATA wsa;
if (WSAStartup(MAKEWORD(2, 0), &wsa))
return;
#elif defined(OF_WII)
if (net_init() < 0)
return;
#endif
#ifdef OF_HAVE_THREADS
if (!of_mutex_new(&mutex))
return;
# ifdef OF_WII
if (!of_spinlock_new(&spinlock))
return;
# endif
#endif
initialized = true;
}
|
| ︙ | ︙ | |||
77 78 79 80 81 82 83 |
return initialized;
}
int
of_socket_errno()
{
| | | 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
return initialized;
}
int
of_socket_errno()
{
#ifndef OF_WINDOWS
return errno;
#else
switch (WSAGetLastError()) {
case WSAEACCES:
return EACCES;
case WSAEADDRINUSE:
return EADDRINUSE;
|
| ︙ | ︙ | |||
173 174 175 176 177 178 179 | return EWOULDBLOCK; } return 0; #endif } | | | 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
return EWOULDBLOCK;
}
return 0;
#endif
}
#ifndef OF_WII
int
of_getsockname(of_socket_t socket, struct sockaddr *restrict address,
socklen_t *restrict address_len)
{
int ret;
# ifdef OF_HAVE_THREADS
|
| ︙ | ︙ |
Changes to src/socket_helpers.h.
| ︙ | ︙ | |||
9 10 11 12 13 14 15 16 17 18 19 20 21 22 | * 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. */ /* Work around __block being used by glibc */ #ifdef __GLIBC__ # undef __USE_XOPEN #endif #include <unistd.h> | > > | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | * the packaging of this file. * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" /* Work around __block being used by glibc */ #ifdef __GLIBC__ # undef __USE_XOPEN #endif #include <unistd.h> |
| ︙ | ︙ | |||
51 52 53 54 55 56 57 | # define SOMAXCONN 32 #endif #ifndef SOCK_CLOEXEC # define SOCK_CLOEXEC 0 #endif | | | | | 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | # define SOMAXCONN 32 #endif #ifndef SOCK_CLOEXEC # define SOCK_CLOEXEC 0 #endif #ifdef OF_WINDOWS # define close(sock) closesocket(sock) #endif #ifdef OF_PSP /* PSP defines AF_INET6, even though sockaddr_in6 is missing */ # undef AF_INET6 #endif #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) # define h_errno 0 # define hstrerror(err) "unknown (no hstrerror)" |
| ︙ | ︙ |
Changes to src/threading.h.
| ︙ | ︙ | |||
10 11 12 13 14 15 16 | * * 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. */ | | > > | | | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | * * 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" #include "platform.h" #if !defined(OF_HAVE_THREADS) || \ (!defined(OF_HAVE_PTHREADS) && !defined(OF_WINDOWS)) # error No threads available! #endif #include <math.h> #import "OFObject.h" #if defined(OF_HAVE_PTHREADS) # include <pthread.h> # include <sched.h> typedef pthread_t of_thread_t; 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(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. */ # ifdef OF_HAVE_SOCKETS # include <winsock2.h> |
| ︙ | ︙ | |||
67 68 69 70 71 72 73 | typedef of_mutex_t of_spinlock_t; #endif #ifdef OF_HAVE_SCHED_YIELD # include <sched.h> #endif | | | | 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
typedef of_mutex_t of_spinlock_t;
#endif
#ifdef OF_HAVE_SCHED_YIELD
# include <sched.h>
#endif
#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;
} of_rmutex_t;
#endif
typedef struct of_thread_attr_t {
float priority;
size_t stackSize;
} 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(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!
#endif
|
| ︙ | ︙ | |||
125 126 127 128 129 130 131 |
/* TLS keys and spinlocks are inlined for performance. */
static OF_INLINE bool
of_tlskey_new(of_tlskey_t *key)
{
#if defined(OF_HAVE_PTHREADS)
return !pthread_key_create(key, NULL);
| | | | | | 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
/* TLS keys and spinlocks are inlined for performance. */
static OF_INLINE bool
of_tlskey_new(of_tlskey_t *key)
{
#if defined(OF_HAVE_PTHREADS)
return !pthread_key_create(key, NULL);
#elif defined(OF_WINDOWS)
return ((*key = TlsAlloc()) != TLS_OUT_OF_INDEXES);
#else
# error of_tlskey_new not implemented!
#endif
}
static OF_INLINE void*
of_tlskey_get(of_tlskey_t key)
{
#if defined(OF_HAVE_PTHREADS)
return pthread_getspecific(key);
#elif defined(OF_WINDOWS)
return TlsGetValue(key);
#else
# error of_tlskey_get not implemented!
#endif
}
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(OF_WINDOWS)
return TlsSetValue(key, ptr);
#else
# error of_tlskey_set not implemented!
#endif
}
static OF_INLINE bool
of_tlskey_free(of_tlskey_t key)
{
#if defined(OF_HAVE_PTHREADS)
return !pthread_key_delete(key);
#elif defined(OF_WINDOWS)
return TlsFree(key);
#else
# error of_tlskey_free not implemented!
#endif
}
static OF_INLINE bool
|
| ︙ | ︙ | |||
197 198 199 200 201 202 203 |
#endif
}
static OF_INLINE bool
of_spinlock_lock(of_spinlock_t *spinlock)
{
#if defined(OF_HAVE_ATOMIC_OPS)
| | | | 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
#endif
}
static OF_INLINE bool
of_spinlock_lock(of_spinlock_t *spinlock)
{
#if defined(OF_HAVE_ATOMIC_OPS)
# 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 OF_WINDOWS
sched_yield();
# else
Sleep(0);
# endif
# else
while (!of_spinlock_trylock(spinlock));
# endif
|
| ︙ | ︙ |
Changes to src/threading.m.
| ︙ | ︙ | |||
16 17 18 19 20 21 22 | #include "config.h" #import "threading.h" #if defined(OF_HAVE_PTHREADS) # include "threading_pthread.m" | | | | 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
#include "config.h"
#import "threading.h"
#if defined(OF_HAVE_PTHREADS)
# include "threading_pthread.m"
#elif defined(OF_WINDOWS)
# include "threading_winapi.m"
#else
# error No threads available!
#endif
#ifdef OF_HAIKU
# include <kernel/OS.h>
#endif
bool
of_rmutex_new(of_rmutex_t *rmutex)
{
#if defined(OF_HAVE_RECURSIVE_PTHREAD_MUTEXES)
|
| ︙ | ︙ | |||
45 46 47 48 49 50 51 | if (pthread_mutex_init(rmutex, &attr) != 0) return false; if (pthread_mutexattr_destroy(&attr) != 0) return false; return true; | | | | 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
if (pthread_mutex_init(rmutex, &attr) != 0)
return false;
if (pthread_mutexattr_destroy(&attr) != 0)
return false;
return true;
#elif defined(OF_WINDOWS)
return of_mutex_new(rmutex);
#else
if (!of_mutex_new(&rmutex->mutex))
return false;
if (!of_tlskey_new(&rmutex->count))
return false;
return true;
#endif
}
bool
of_rmutex_lock(of_rmutex_t *rmutex)
{
#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) {
if (!of_tlskey_set(rmutex->count, (void*)(count + 1)))
return false;
|
| ︙ | ︙ | |||
88 89 90 91 92 93 94 |
return true;
#endif
}
bool
of_rmutex_trylock(of_rmutex_t *rmutex)
{
| | | 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
return true;
#endif
}
bool
of_rmutex_trylock(of_rmutex_t *rmutex)
{
#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) {
if (!of_tlskey_set(rmutex->count, (void*)(count + 1)))
return false;
|
| ︙ | ︙ | |||
115 116 117 118 119 120 121 |
return true;
#endif
}
bool
of_rmutex_unlock(of_rmutex_t *rmutex)
{
| | | 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
return true;
#endif
}
bool
of_rmutex_unlock(of_rmutex_t *rmutex)
{
#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) {
if (!of_tlskey_set(rmutex->count, (void*)(count - 1)))
return false;
|
| ︙ | ︙ | |||
140 141 142 143 144 145 146 |
return true;
#endif
}
bool
of_rmutex_free(of_rmutex_t *rmutex)
{
| | | 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
return true;
#endif
}
bool
of_rmutex_free(of_rmutex_t *rmutex)
{
#if defined(OF_HAVE_RECURSIVE_PTHREAD_MUTEXES) || defined(OF_WINDOWS)
return of_mutex_free(rmutex);
#else
if (!of_mutex_free(&rmutex->mutex))
return false;
if (!of_tlskey_free(rmutex->count))
return false;
return true;
#endif
}
|
Changes to src/threading_pthread.m.
| ︙ | ︙ | |||
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
* 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.
*/
#ifdef HAVE_PTHREAD_NP_H
# include <pthread_np.h>
#endif
struct thread_ctx {
void (*function)(id object);
id object;
};
static void*
| > > > > | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#ifdef HAVE_PTHREAD_NP_H
# include <pthread_np.h>
#endif
#import "macros.h"
struct thread_ctx {
void (*function)(id object);
id object;
};
static void*
|
| ︙ | ︙ | |||
159 160 161 162 163 164 165 |
OF_UNREACHABLE
}
void
of_thread_set_name(of_thread_t thread, const char *name)
{
| | | | 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
OF_UNREACHABLE
}
void
of_thread_set_name(of_thread_t thread, const char *name)
{
#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(OF_MAC_OS_X) || defined(OF_IOS)
pthread_setname_np(name);
# elif defined(__GLIBC__)
char buffer[16];
strncpy(buffer, name, 15);
buffer[15] = 0;
|
| ︙ | ︙ |
Changes to src/threading_winapi.m.
| ︙ | ︙ | |||
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
* 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.
*/
bool
of_thread_attr_init(of_thread_attr_t *attr)
{
attr->priority =
(float)(THREAD_PRIORITY_NORMAL - THREAD_PRIORITY_LOWEST) /
(THREAD_PRIORITY_HIGHEST - THREAD_PRIORITY_LOWEST);
| > > > > | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#import "macros.h"
bool
of_thread_attr_init(of_thread_attr_t *attr)
{
attr->priority =
(float)(THREAD_PRIORITY_NORMAL - THREAD_PRIORITY_LOWEST) /
(THREAD_PRIORITY_HIGHEST - THREAD_PRIORITY_LOWEST);
|
| ︙ | ︙ |
Changes to tests/ForwardingTests.m.
| ︙ | ︙ | |||
208 209 210 211 212 213 214 | : 2.75] == 0x12345678) TEST(@"-[forwardingTargetForSelector:] variable arguments", [[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. */ | > | | 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | : 2.75] == 0x12345678) TEST(@"-[forwardingTargetForSelector:] variable arguments", [[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(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", !memcmp([t forwardingTargetStRetTest].s, "abcdefghijklmnopqrstuvwxyz", 27)) |
| ︙ | ︙ |
Changes to tests/OFINIFileTests.m.
| ︙ | ︙ | |||
22 23 24 25 26 27 28 | #import "OFArray.h" #import "OFFile.h" #import "OFFileManager.h" #import "OFAutoreleasePool.h" #import "TestsAppDelegate.h" | | | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | #import "OFArray.h" #import "OFFile.h" #import "OFFileManager.h" #import "OFAutoreleasePool.h" #import "TestsAppDelegate.h" #if defined(OF_WINDOWS) || defined(OF_MSDOS) # define NL @"\r\n" #else # define NL @"\n" #endif static OFString *module = @"OFINIFile"; |
| ︙ | ︙ |
Changes to tests/OFKernelEventObserverTests.m.
| ︙ | ︙ | |||
18 19 20 21 22 23 24 | #import "OFKernelEventObserver.h" #import "OFString.h" #import "OFDate.h" #import "OFTCPSocket.h" #import "OFAutoreleasePool.h" | | | | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | #import "OFKernelEventObserver.h" #import "OFString.h" #import "OFDate.h" #import "OFTCPSocket.h" #import "OFAutoreleasePool.h" #if defined(HAVE_SYS_SELECT_H) || defined(OF_WINDOWS) # import "OFKernelEventObserver_select.h" #endif #if defined(HAVE_POLL_H) || defined(OF_WII) # import "OFKernelEventObserver_poll.h" #endif #ifdef HAVE_EPOLL # import "OFKernelEventObserver_epoll.h" #endif #ifdef HAVE_KQUEUE # import "OFKernelEventObserver_kqueue.h" |
| ︙ | ︙ | |||
208 209 210 211 212 213 214 |
[test run];
}
- (void)kernelEventObserverTests
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
| | | | 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
[test run];
}
- (void)kernelEventObserverTests
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
#if defined(HAVE_SYS_SELECT_H) || defined(OF_WINDOWS)
[self kernelEventObserverTestsWithClass:
[OFKernelEventObserver_select class]];
#endif
#if defined(HAVE_POLL_H) || defined(OF_WII)
[self kernelEventObserverTestsWithClass:
[OFKernelEventObserver_poll class]];
#endif
#ifdef HAVE_EPOLL
[self kernelEventObserverTestsWithClass:
[OFKernelEventObserver_epoll class]];
|
| ︙ | ︙ |
Changes to tests/OFObjectTests.m.
| ︙ | ︙ | |||
20 21 22 23 24 25 26 | #import "OFAutoreleasePool.h" #import "OFMemoryNotPartOfObjectException.h" #import "OFOutOfMemoryException.h" #import "TestsAppDelegate.h" | | | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | #import "OFAutoreleasePool.h" #import "OFMemoryNotPartOfObjectException.h" #import "OFOutOfMemoryException.h" #import "TestsAppDelegate.h" #if defined(OF_DRAGONFLYBSD) && defined(__LP64__) # define TOO_BIG (SIZE_MAX / 3) #else # define TOO_BIG (SIZE_MAX - 128) #endif static OFString *module = @"OFObject"; |
| ︙ | ︙ |
Changes to tests/OFStringTests.m.
| ︙ | ︙ | |||
345 346 347 348 349 350 351 | componentsSeparatedByString: @"XX" options: OF_STRING_SKIP_EMPTY]) && [a count] == 3 && [[a objectAtIndex: i++] isEqual: @"foo"] && [[a objectAtIndex: i++] isEqual: @"bar"] && [[a objectAtIndex: i++] isEqual: @"baz"]) | | | 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 | componentsSeparatedByString: @"XX" options: OF_STRING_SKIP_EMPTY]) && [a count] == 3 && [[a objectAtIndex: i++] isEqual: @"foo"] && [[a objectAtIndex: i++] isEqual: @"bar"] && [[a objectAtIndex: i++] isEqual: @"baz"]) #if !defined(OF_WINDOWS) && !defined(OF_MSDOS) # define EXPECTED @"foo/bar/baz" #else # define EXPECTED @"foo\\bar\\baz" #endif TEST(@"+[pathWithComponents:]", (is = [OFString pathWithComponents: [OFArray arrayWithObjects: @"foo", @"bar", @"baz", nil]]) && |
| ︙ | ︙ | |||
409 410 411 412 413 414 415 | [[@"/tmp/" stringByDeletingLastPathComponent] isEqual: @"/"] && [[@"/tmp/foo/" stringByDeletingLastPathComponent] isEqual: @"/tmp"] && [[@"foo/bar" stringByDeletingLastPathComponent] isEqual: @"foo"] && [[@"/" stringByDeletingLastPathComponent] isEqual: @"/"] && [[@"foo" stringByDeletingLastPathComponent] isEqual: @"."]) | | | 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 | [[@"/tmp/" stringByDeletingLastPathComponent] isEqual: @"/"] && [[@"/tmp/foo/" stringByDeletingLastPathComponent] isEqual: @"/tmp"] && [[@"foo/bar" stringByDeletingLastPathComponent] isEqual: @"foo"] && [[@"/" stringByDeletingLastPathComponent] isEqual: @"/"] && [[@"foo" stringByDeletingLastPathComponent] isEqual: @"."]) #if !defined(OF_WINDOWS) && !defined(OF_MSDOS) # define EXPECTED @"/foo./bar" #else # define EXPECTED @"\\foo.\\bar" #endif TEST(@"-[stringByDeletingPathExtension]", [[@"foo.bar" stringByDeletingPathExtension] isEqual: @"foo"] && [[@"foo..bar" stringByDeletingPathExtension] isEqual: @"foo."] && |
| ︙ | ︙ | |||
449 450 451 452 453 454 455 | * floating point numbers, thus we can use == on them. */ TEST(@"-[floatValue]", [@"\t-0.25 " floatValue] == -0.25 && [@"\r-INFINITY\n" floatValue] == -INFINITY && isnan([@" NAN\t\t" floatValue])) | | | | 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 | * floating point numbers, thus we can use == on them. */ TEST(@"-[floatValue]", [@"\t-0.25 " floatValue] == -0.25 && [@"\r-INFINITY\n" floatValue] == -INFINITY && isnan([@" NAN\t\t" floatValue])) #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(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 " # define EXPECTED -0.125 # endif |
| ︙ | ︙ |
Changes to tests/TestsAppDelegate.m.
| ︙ | ︙ | |||
18 19 20 21 22 23 24 | #include <stdlib.h> #import "ObjFW.h" #import "TestsAppDelegate.h" | | | | | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
#include <stdlib.h>
#import "ObjFW.h"
#import "TestsAppDelegate.h"
#if defined(STDOUT) && (defined(OF_WINDOWS) || defined(OF_MSDOS))
# undef STDOUT
# define STDOUT_SIMPLE
#endif
#ifdef OF_PSP
# include <pspmoduleinfo.h>
# include <pspkernel.h>
# include <pspdebug.h>
# include <pspctrl.h>
PSP_MODULE_INFO("ObjFW Tests", 0, 0, 0);
#endif
#ifdef OF_WII
# define BOOL OGC_BOOL
# define asm __asm__
# include <gccore.h>
# include <wiiuse/wpad.h>
# undef BOOL
# undef asm
#endif
|
| ︙ | ︙ | |||
53 54 55 56 57 58 59 |
enum {
NO_COLOR,
RED,
GREEN,
YELLOW
};
| | | 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
enum {
NO_COLOR,
RED,
GREEN,
YELLOW
};
#ifdef OF_PSP
static int
exit_cb(int arg1, int arg2, void *arg)
{
sceKernelExitGame();
return 0;
}
|
| ︙ | ︙ | |||
76 77 78 79 80 81 82 |
return 0;
}
#endif
int
main(int argc, char *argv[])
{
| | | | | 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
return 0;
}
#endif
int
main(int argc, char *argv[])
{
#ifdef OF_PSP
int tid;
#endif
#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 OF_WII
GXRModeObj *rmode;
void *xfb;
VIDEO_Init();
WPAD_Init();
rmode = VIDEO_GetPreferredMode(NULL);
|
| ︙ | ︙ | |||
110 111 112 113 114 115 116 | if (rmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync(); CON_InitEx(rmode, 10, 20, rmode->fbWidth - 10, rmode->xfbHeight - 20); VIDEO_ClearFrameBuffer(rmode, xfb, COLOR_BLACK); #endif | | | | | | 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
if (rmode->viTVMode & VI_NON_INTERLACE)
VIDEO_WaitVSync();
CON_InitEx(rmode, 10, 20, rmode->fbWidth - 10, rmode->xfbHeight - 20);
VIDEO_ClearFrameBuffer(rmode, xfb, COLOR_BLACK);
#endif
#ifdef OF_PSP
pspDebugScreenInit();
sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingMode(PSP_CTRL_MODE_DIGITAL);
if ((tid = sceKernelCreateThread("update_thread", callback_thread,
0x11, 0xFA0, 0, 0)) >= 0)
sceKernelStartThread(tid, 0, 0);
#endif
#ifdef OF_NINTENDO_DS
consoleDemoInit();
#endif
#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 =
[[OFApplication sharedApplication] delegate];
OFString *string = [OFString stringWithFormat:
@"\nRuntime error: Unhandled exception:\n%@\n", e];
OFString *backtrace = [OFString stringWithFormat:
@"\nBacktrace:\n %@\n\n",
[[e backtrace] componentsJoinedByString: @"\n "]];
[delegate outputString: string
inColor: RED];
[delegate outputString: backtrace
inColor: RED];
# if defined(OF_WII)
[delegate outputString: @"Press home button to exit!\n"
inColor: NO_COLOR];
for (;;) {
WPAD_ScanPads();
if (WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME)
[OFApplication terminateWithStatus: 1];
VIDEO_WaitVSync();
}
# elif defined(OF_PSP)
sceKernelSleepThreadCB();
# elif defined(OF_NINTENDO_DS)
[delegate outputString: @"Press start button to exit!"
inColor: NO_COLOR];
for (;;) {
swiWaitForVBlank();
scanKeys();
|
| ︙ | ︙ | |||
177 178 179 180 181 182 183 |
#endif
}
@implementation TestsAppDelegate
- (void)outputString: (OFString*)str
inColor: (int)color
{
| | | 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
#endif
}
@implementation TestsAppDelegate
- (void)outputString: (OFString*)str
inColor: (int)color
{
#if defined(OF_PSP)
char i, space = ' ';
int y = pspDebugScreenGetY();
pspDebugScreenSetXY(0, y);
for (i = 0; i < 68; i++)
pspDebugScreenPrintData(&space, 1);
|
| ︙ | ︙ | |||
206 207 208 209 210 211 212 |
pspDebugScreenSetXY(0, y);
pspDebugScreenPrintData([str UTF8String], [str UTF8StringLength]);
#elif defined(STDOUT)
switch (color) {
case NO_COLOR:
[of_stdout writeString: @"\r\033[K"];
| | | 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
pspDebugScreenSetXY(0, y);
pspDebugScreenPrintData([str UTF8String], [str UTF8StringLength]);
#elif defined(STDOUT)
switch (color) {
case NO_COLOR:
[of_stdout writeString: @"\r\033[K"];
# 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"];
break;
case GREEN:
|
| ︙ | ︙ | |||
271 272 273 274 275 276 277 | #ifndef STDOUT_SIMPLE OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; [self outputString: [OFString stringWithFormat: @"[%@] %@: failed\n", module, test] inColor: RED]; [pool release]; | | | | 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 |
#ifndef STDOUT_SIMPLE
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
[self outputString: [OFString stringWithFormat: @"[%@] %@: failed\n",
module, test]
inColor: RED];
[pool release];
# ifdef OF_WII
[self outputString: @"Press A to continue!\n"
inColor: NO_COLOR];
for (;;) {
WPAD_ScanPads();
if (WPAD_ButtonsDown(0) & WPAD_BUTTON_A)
return;
VIDEO_WaitVSync();
}
# endif
# ifdef OF_PSP
[self outputString: @"Press X to continue!\n"
inColor: NO_COLOR];
for (;;) {
SceCtrlData pad;
sceCtrlReadBufferPositive(&pad, 1);
if (pad.Buttons & PSP_CTRL_CROSS) {
|
| ︙ | ︙ | |||
317 318 319 320 321 322 323 |
[self outputString: @"failed\n"
inColor: RED];
#endif
}
- (void)applicationDidFinishLaunching
{
| | | 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 |
[self outputString: @"failed\n"
inColor: RED];
#endif
}
- (void)applicationDidFinishLaunching
{
#if defined(OF_WII) && defined(OF_HAVE_FILES)
[[OFFileManager defaultManager]
changeCurrentDirectoryPath: @"/apps/objfw-tests"];
#endif
[self objectTests];
#ifdef OF_HAVE_BLOCKS
[self blockTests];
|
| ︙ | ︙ | |||
372 373 374 375 376 377 378 | [self pluginTests]; #endif [self forwardingTests]; #ifdef OF_HAVE_PROPERTIES [self propertiesTests]; #endif | | | | 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 |
[self pluginTests];
#endif
[self forwardingTests];
#ifdef OF_HAVE_PROPERTIES
[self propertiesTests];
#endif
#if defined(OF_WII)
[self outputString: @"Press home button to exit!\n"
inColor: NO_COLOR];
for (;;) {
WPAD_ScanPads();
if (WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME)
[OFApplication terminateWithStatus: _fails];
VIDEO_WaitVSync();
}
#elif defined(OF_PSP)
[self outputString: [OFString stringWithFormat: @"%d tests failed!",
_fails]
inColor: NO_COLOR];
sceKernelSleepThreadCB();
#elif defined(OF_NINTENDO_DS)
[self outputString: @"Press start button to exit!"
inColor: NO_COLOR];
|
| ︙ | ︙ |
Changes to utils/ofzip/OFZIP.m.
| ︙ | ︙ | |||
310 311 312 313 314 315 316 | int_fast8_t percent = -1, newPercent; if (!all && ![files containsObject: fileName]) continue; [missing removeObject: fileName]; | | | 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 |
int_fast8_t percent = -1, newPercent;
if (!all && ![files containsObject: fileName])
continue;
[missing removeObject: fileName];
#if !defined(OF_WINDOWS) && !defined(OF_MSDOS)
if ([outFileName hasPrefix: @"/"]) {
#else
if ([outFileName hasPrefix: @"/"] ||
[outFileName containsString: @":"]) {
#endif
[of_stderr writeFormat: @"Refusing to extract %@!\n",
fileName];
|
| ︙ | ︙ |