summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Schleifer <js@heap.zone>2017-11-19 13:56:14 +0100
committerJonathan Schleifer <js@heap.zone>2017-11-19 13:56:14 +0100
commit415c35278aa3f76d7370e7a83fbd92c201de6d9d (patch)
tree90a1434ab899be0a65ad79530cad655ecba82b74
parent241bb028eebd779fd39809894810b0311014c2c8 (diff)
Fix compilation with GCC
-rw-r--r--src/OFData.m4
-rw-r--r--src/OFDate.m4
-rw-r--r--src/OFNumber.m4
-rw-r--r--src/OFStream.m65
-rw-r--r--src/OFStreamSocket.m72
-rw-r--r--src/OFString.m4
-rw-r--r--src/OFString_UTF8.m4
-rw-r--r--src/OFTimer.m4
8 files changed, 81 insertions, 80 deletions
diff --git a/src/OFData.m b/src/OFData.m
index f0e536be..1f136768 100644
--- a/src/OFData.m
+++ b/src/OFData.m
@@ -436,13 +436,13 @@ _references_to_categories_of_OFData(void)
return true;
}
-- (of_comparison_result_t)compare: (id <OFObject, OFComparing>)object
+- (of_comparison_result_t)compare: (id <OFComparing>)object
{
OFData *data;
int comparison;
size_t count, minCount;
- if (![object isKindOfClass: [OFData class]])
+ if (![(id)object isKindOfClass: [OFData class]])
@throw [OFInvalidArgumentException exception];
data = (OFData *)object;
diff --git a/src/OFDate.m b/src/OFDate.m
index 4296a7ee..d5760ad7 100644
--- a/src/OFDate.m
+++ b/src/OFDate.m
@@ -397,11 +397,11 @@ tmAndTzToTime(struct tm *tm, int16_t *tz)
return [self retain];
}
-- (of_comparison_result_t)compare: (id <OFObject, OFComparing>)object
+- (of_comparison_result_t)compare: (id <OFComparing>)object
{
OFDate *otherDate;
- if (![object isKindOfClass: [OFDate class]])
+ if (![(id)object isKindOfClass: [OFDate class]])
@throw [OFInvalidArgumentException exception];
otherDate = (OFDate *)object;
diff --git a/src/OFNumber.m b/src/OFNumber.m
index 0b45ce63..bed57375 100644
--- a/src/OFNumber.m
+++ b/src/OFNumber.m
@@ -763,11 +763,11 @@
return ([number uIntMaxValue] == [self uIntMaxValue]);
}
-- (of_comparison_result_t)compare: (id <OFObject, OFComparing>)object
+- (of_comparison_result_t)compare: (id <OFComparing>)object
{
OFNumber *number;
- if (![object isKindOfClass: [OFNumber class]])
+ if (![(id)object isKindOfClass: [OFNumber class]])
@throw [OFInvalidArgumentException exception];
number = (OFNumber *)object;
diff --git a/src/OFStream.m b/src/OFStream.m
index 3a7e1976..d86905ae 100644
--- a/src/OFStream.m
+++ b/src/OFStream.m
@@ -25,10 +25,6 @@
#include <stdlib.h>
#include <string.h>
-#ifdef HAVE_FCNTL_H
-# include <fcntl.h>
-#endif
-
#include "platform.h"
#if !defined(OF_WINDOWS) && !defined(OF_MORPHOS)
@@ -1641,67 +1637,7 @@
- (void)setBlocking: (bool)enable
{
-#ifdef HAVE_FCNTL
- bool readImplemented = false, writeImplemented = false;
-
- @try {
- int readFlags;
-
- readFlags = fcntl([self fileDescriptorForReading], F_GETFL);
-
- readImplemented = true;
-
- if (readFlags == -1)
- @throw [OFSetOptionFailedException
- exceptionWithStream: self
- errNo: errno];
-
- if (enable)
- readFlags &= ~O_NONBLOCK;
- else
- readFlags |= O_NONBLOCK;
-
- if (fcntl([self fileDescriptorForReading], F_SETFL,
- readFlags) == -1)
- @throw [OFSetOptionFailedException
- exceptionWithStream: self
- errNo: errno];
- } @catch (OFNotImplementedException *e) {
- }
-
- @try {
- int writeFlags;
-
- writeFlags = fcntl([self fileDescriptorForWriting], F_GETFL);
-
- writeImplemented = true;
-
- if (writeFlags == -1)
- @throw [OFSetOptionFailedException
- exceptionWithStream: self
- errNo: errno];
-
- if (enable)
- writeFlags &= ~O_NONBLOCK;
- else
- writeFlags |= O_NONBLOCK;
-
- if (fcntl([self fileDescriptorForWriting], F_SETFL,
- writeFlags) == -1)
- @throw [OFSetOptionFailedException
- exceptionWithStream: self
- errNo: errno];
- } @catch (OFNotImplementedException *e) {
- }
-
- if (!readImplemented && !writeImplemented)
- @throw [OFNotImplementedException exceptionWithSelector: _cmd
- object: self];
-
- _blocking = enable;
-#else
OF_UNRECOGNIZED_SELECTOR
-#endif
}
- (int)fileDescriptorForReading
@@ -1750,6 +1686,5 @@
_writeBuffered = false;
_waitingForDelimiter = false;
- _blocking = false;
}
@end
diff --git a/src/OFStreamSocket.m b/src/OFStreamSocket.m
index 9ed21bde..7deeef80 100644
--- a/src/OFStreamSocket.m
+++ b/src/OFStreamSocket.m
@@ -21,9 +21,14 @@
#include <errno.h>
#include <string.h>
+#ifdef HAVE_FCNTL_H
+# include <fcntl.h>
+#endif
+
#import "OFStreamSocket.h"
#import "OFInitializationFailedException.h"
+#import "OFNotImplementedException.h"
#import "OFNotOpenException.h"
#import "OFOutOfRangeException.h"
#import "OFReadFailedException.h"
@@ -122,18 +127,79 @@
return (size_t)bytesWritten;
}
-#ifdef OF_WINDOWS
- (void)setBlocking: (bool)enable
{
- u_long v = enable;
+#if defined(HAVE_FCNTL)
+ bool readImplemented = false, writeImplemented = false;
+
+ @try {
+ int readFlags;
+
+ readFlags = fcntl([self fileDescriptorForReading], F_GETFL);
+
+ readImplemented = true;
+
+ if (readFlags == -1)
+ @throw [OFSetOptionFailedException
+ exceptionWithStream: self
+ errNo: errno];
+
+ if (enable)
+ readFlags &= ~O_NONBLOCK;
+ else
+ readFlags |= O_NONBLOCK;
+
+ if (fcntl([self fileDescriptorForReading], F_SETFL,
+ readFlags) == -1)
+ @throw [OFSetOptionFailedException
+ exceptionWithStream: self
+ errNo: errno];
+ } @catch (OFNotImplementedException *e) {
+ }
+
+ @try {
+ int writeFlags;
+
+ writeFlags = fcntl([self fileDescriptorForWriting], F_GETFL);
+
+ writeImplemented = true;
+
+ if (writeFlags == -1)
+ @throw [OFSetOptionFailedException
+ exceptionWithStream: self
+ errNo: errno];
+
+ if (enable)
+ writeFlags &= ~O_NONBLOCK;
+ else
+ writeFlags |= O_NONBLOCK;
+
+ if (fcntl([self fileDescriptorForWriting], F_SETFL,
+ writeFlags) == -1)
+ @throw [OFSetOptionFailedException
+ exceptionWithStream: self
+ errNo: errno];
+ } @catch (OFNotImplementedException *e) {
+ }
+
+ if (!readImplemented && !writeImplemented)
+ @throw [OFNotImplementedException exceptionWithSelector: _cmd
+ object: self];
+
_blocking = enable;
+#elif defined(OF_WINDOWS)
+ u_long v = enable;
if (ioctlsocket(_socket, FIONBIO, &v) == SOCKET_ERROR)
@throw [OFSetOptionFailedException
exceptionWithStream: self
errNo: of_socket_errno()];
-}
+
+ _blocking = enable;
+#else
+ OF_UNRECOGNIZED_SELECTOR
#endif
+}
- (int)fileDescriptorForReading
{
diff --git a/src/OFString.m b/src/OFString.m
index 803dae66..7d75bb37 100644
--- a/src/OFString.m
+++ b/src/OFString.m
@@ -1552,7 +1552,7 @@ decomposedString(OFString *self, const char *const *const *table, size_t size)
return [[OFMutableString alloc] initWithString: self];
}
-- (of_comparison_result_t)compare: (id <OFObject, OFComparing>)object
+- (of_comparison_result_t)compare: (id <OFComparing>)object
{
void *pool;
OFString *otherString;
@@ -1562,7 +1562,7 @@ decomposedString(OFString *self, const char *const *const *table, size_t size)
if (object == self)
return OF_ORDERED_SAME;
- if (![object isKindOfClass: [OFString class]])
+ if (![(id)object isKindOfClass: [OFString class]])
@throw [OFInvalidArgumentException exception];
otherString = (OFString *)object;
diff --git a/src/OFString_UTF8.m b/src/OFString_UTF8.m
index 38aeb0f5..b777994b 100644
--- a/src/OFString_UTF8.m
+++ b/src/OFString_UTF8.m
@@ -808,7 +808,7 @@ of_string_utf8_get_position(const char *string, size_t idx, size_t length)
return true;
}
-- (of_comparison_result_t)compare: (id <OFObject, OFComparing>)object
+- (of_comparison_result_t)compare: (id <OFComparing>)object
{
OFString *otherString;
size_t otherCStringLength, minimumCStringLength;
@@ -817,7 +817,7 @@ of_string_utf8_get_position(const char *string, size_t idx, size_t length)
if (object == self)
return OF_ORDERED_SAME;
- if (![object isKindOfClass: [OFString class]])
+ if (![(id)object isKindOfClass: [OFString class]])
@throw [OFInvalidArgumentException exception];
otherString = (OFString *)object;
diff --git a/src/OFTimer.m b/src/OFTimer.m
index 083b0f76..e7839c78 100644
--- a/src/OFTimer.m
+++ b/src/OFTimer.m
@@ -506,11 +506,11 @@
[super dealloc];
}
-- (of_comparison_result_t)compare: (id <OFObject, OFComparing>)object
+- (of_comparison_result_t)compare: (id <OFComparing>)object
{
OFTimer *timer;
- if (![object isKindOfClass: [OFTimer class]])
+ if (![(id)object isKindOfClass: [OFTimer class]])
@throw [OFInvalidArgumentException exception];
timer = (OFTimer *)object;