ObjFW  Check-in [cbc09c6e26]

Overview
Comment:Work around bugs in Apple GCC 4.2.1
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: cbc09c6e268957178078ad677b58a68217833c4f5aacca88d66f6ace180c1ccc
User & Date: js on 2020-09-27 00:57:30
Other Links: manifest | tags
Context
2020-09-27
01:00
Don't assume arc4random_buf if we have arc4random check-in: 9aa85c25b5 user: js tags: trunk
00:57
Work around bugs in Apple GCC 4.2.1 check-in: cbc09c6e26 user: js tags: trunk
2020-09-26
21:58
Don't require __COUNTER__ for OF_RESERVE_IVARS check-in: ef614a225d user: js tags: trunk
Changes

Modified src/OFColor.m from [eeffafbeab] to [cc4d687d8e].

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
	{								\
		static of_once_t onceControl = OF_ONCE_INIT;		\
		of_once(&onceControl, initPredefinedColor_##name);	\
									\
		return name##Color;					\
	}

PREDEFINED_COLOR(black,   0.00, 0.00, 0.00)
PREDEFINED_COLOR(silver,  0.75, 0.75, 0.75)
PREDEFINED_COLOR(grey,    0.50, 0.50, 0.50)
PREDEFINED_COLOR(white,   1.00, 1.00, 1.00)
PREDEFINED_COLOR(maroon,  0.50, 0.00, 0.00)
PREDEFINED_COLOR(red,     1.00, 0.00, 0.00)
PREDEFINED_COLOR(purple,  0.50, 0.00, 0.50)
PREDEFINED_COLOR(fuchsia, 1.00, 0.00, 1.00)
PREDEFINED_COLOR(green,   0.00, 0.50, 0.00)
PREDEFINED_COLOR(lime,    0.00, 1.00, 0.00)
PREDEFINED_COLOR(olive,   0.50, 0.50, 0.00)
PREDEFINED_COLOR(yellow,  1.00, 1.00, 0.00)
PREDEFINED_COLOR(navy,    0.00, 0.00, 0.50)
PREDEFINED_COLOR(blue,    0.00, 0.00, 1.00)
PREDEFINED_COLOR(teal,    0.00, 0.50, 0.50)
PREDEFINED_COLOR(aqua,    0.00, 1.00, 1.00)

+ (instancetype)colorWithRed: (float)red
		       green: (float)green
			blue: (float)blue
		       alpha: (float)alpha
{
	return [[[self alloc] initWithRed: red







|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|







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
	{								\
		static of_once_t onceControl = OF_ONCE_INIT;		\
		of_once(&onceControl, initPredefinedColor_##name);	\
									\
		return name##Color;					\
	}

PREDEFINED_COLOR(black,   0.00f, 0.00f, 0.00f)
PREDEFINED_COLOR(silver,  0.75f, 0.75f, 0.75f)
PREDEFINED_COLOR(grey,    0.50f, 0.50f, 0.50f)
PREDEFINED_COLOR(white,   1.00f, 1.00f, 1.00f)
PREDEFINED_COLOR(maroon,  0.50f, 0.00f, 0.00f)
PREDEFINED_COLOR(red,     1.00f, 0.00f, 0.00f)
PREDEFINED_COLOR(purple,  0.50f, 0.00f, 0.50f)
PREDEFINED_COLOR(fuchsia, 1.00f, 0.00f, 1.00f)
PREDEFINED_COLOR(green,   0.00f, 0.50f, 0.00f)
PREDEFINED_COLOR(lime,    0.00f, 1.00f, 0.00f)
PREDEFINED_COLOR(olive,   0.50f, 0.50f, 0.00f)
PREDEFINED_COLOR(yellow,  1.00f, 1.00f, 0.00f)
PREDEFINED_COLOR(navy,    0.00f, 0.00f, 0.50f)
PREDEFINED_COLOR(blue,    0.00f, 0.00f, 1.00f)
PREDEFINED_COLOR(teal,    0.00f, 0.50f, 0.50f)
PREDEFINED_COLOR(aqua,    0.00f, 1.00f, 1.00f)

+ (instancetype)colorWithRed: (float)red
		       green: (float)green
			blue: (float)blue
		       alpha: (float)alpha
{
	return [[[self alloc] initWithRed: red

Modified src/OFDNSResolverSettings.m from [aa15389045] to [92fa7c4194].

68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#endif

#ifndef OF_WII
static OFString *
domainFromHostname(void)
{
	char hostname[256];
	OFString *domain;

	if (gethostname(hostname, 256) != 0)
		return nil;

	domain = [OFString stringWithCString: hostname
				    encoding: [OFLocale encoding]];








|







68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#endif

#ifndef OF_WII
static OFString *
domainFromHostname(void)
{
	char hostname[256];
	OFString *domain, *ret;

	if (gethostname(hostname, 256) != 0)
		return nil;

	domain = [OFString stringWithCString: hostname
				    encoding: [OFLocale encoding]];

91
92
93
94
95
96
97
98
99
100


101
102
103
104
105
106
107
	} @catch (OFInvalidFormatException *e) {
		/* Not an IP address -> we can use it if it contains a dot. */
		size_t pos = [domain rangeOfString: @"."].location;

		if (pos == OF_NOT_FOUND)
			return nil;

		return [domain substringWithRange:
		    of_range(pos + 1, domain.length - pos - 1)];
	}


}
#endif

@implementation OFDNSResolverSettings
- (void)dealloc
{
	[_staticHosts release];







|


>
>







91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
	} @catch (OFInvalidFormatException *e) {
		/* Not an IP address -> we can use it if it contains a dot. */
		size_t pos = [domain rangeOfString: @"."].location;

		if (pos == OF_NOT_FOUND)
			return nil;

		ret = [domain substringWithRange:
		    of_range(pos + 1, domain.length - pos - 1)];
	}

	return ret;
}
#endif

@implementation OFDNSResolverSettings
- (void)dealloc
{
	[_staticHosts release];

Modified src/OFDate.m from [c70c88b347] to [34afa10ebd].

466
467
468
469
470
471
472
473

474
475
476
477
478
479
480
	return [element autorelease];
}

- (OFData *)messagePackRepresentation
{
	void *pool = objc_autoreleasePoolPush();
	int64_t seconds = (int64_t)_seconds;
	uint32_t nanoseconds = (_seconds - trunc(_seconds)) * 1000000000;

	OFData *ret;

	if (seconds >= 0 && seconds < 0x400000000) {
		if (seconds <= UINT32_MAX && nanoseconds == 0) {
			uint32_t seconds32 = (uint32_t)seconds;
			OFData *data;








|
>







466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
	return [element autorelease];
}

- (OFData *)messagePackRepresentation
{
	void *pool = objc_autoreleasePoolPush();
	int64_t seconds = (int64_t)_seconds;
	uint32_t nanoseconds =
	    (uint32_t)((_seconds - trunc(_seconds)) * 1000000000);
	OFData *ret;

	if (seconds >= 0 && seconds < 0x400000000) {
		if (seconds <= UINT32_MAX && nanoseconds == 0) {
			uint32_t seconds32 = (uint32_t)seconds;
			OFData *data;

Modified src/OFKqueueKernelEventObserver.m from [9821cf501a] to [56c8bac78d].

161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
	struct kevent eventList[EVENTLIST_SIZE];
	int events;

	if ([self of_processReadBuffers])
		return;

	timeout.tv_sec = (time_t)timeInterval;
	timeout.tv_nsec = (timeInterval - timeout.tv_sec) * 1000000000;

	events = kevent(_kernelQueue, NULL, 0, eventList, EVENTLIST_SIZE,
	    (timeInterval != -1 ? &timeout : NULL));

	if (events < 0)
		@throw [OFObserveFailedException exceptionWithObserver: self
								 errNo: errno];







|







161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
	struct kevent eventList[EVENTLIST_SIZE];
	int events;

	if ([self of_processReadBuffers])
		return;

	timeout.tv_sec = (time_t)timeInterval;
	timeout.tv_nsec = (long)((timeInterval - timeout.tv_sec) * 1000000000);

	events = kevent(_kernelQueue, NULL, 0, eventList, EVENTLIST_SIZE,
	    (timeInterval != -1 ? &timeout : NULL));

	if (events < 0)
		@throw [OFObserveFailedException exceptionWithObserver: self
								 errNo: errno];

Modified src/OFNumber.m from [17a849254e] to [d23a5a6bf5].

882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
	if (*_typeEncoding == 'B') {
		uint8_t type = (_value.unsigned_ ? 0xC3 : 0xC2);

		data = [OFMutableData dataWithItems: &type
					      count: 1];
	} else if (*_typeEncoding == 'f') {
		uint8_t type = 0xCA;
		float tmp = OF_BSWAP_FLOAT_IF_LE(_value.float_);

		data = [OFMutableData dataWithItemSize: 1
					      capacity: 5];

		[data addItem: &type];
		[data addItems: &tmp
			 count: sizeof(tmp)];







|







882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
	if (*_typeEncoding == 'B') {
		uint8_t type = (_value.unsigned_ ? 0xC3 : 0xC2);

		data = [OFMutableData dataWithItems: &type
					      count: 1];
	} else if (*_typeEncoding == 'f') {
		uint8_t type = 0xCA;
		float tmp = OF_BSWAP_FLOAT_IF_LE((float)_value.float_);

		data = [OFMutableData dataWithItemSize: 1
					      capacity: 5];

		[data addItem: &type];
		[data addItems: &tmp
			 count: sizeof(tmp)];

Modified src/OFObject.h from [f46ea6f043] to [78dcc54e1b].

293
294
295
296
297
298
299


300
301
302
303
304
305
306
307
308


309
310
311
312
313
314
315
316
317
318
319
320
321


322
323
324
325


326
327
328
329
330


331
332
333
334
335


336
337
338
339
340
341
342
343
344
345
/*!
 * @protocol OFObject OFObject.h ObjFW/OFObject.h
 *
 * @brief The protocol which all root classes implement.
 */
@protocol OFObject
/*!


 * @brief The class of the object.
 */
# ifndef __cplusplus
@property (readonly, nonatomic) Class class;
# else
@property (readonly, nonatomic, getter=class) Class class_;
# endif

/*!


 * @brief The superclass of the object.
 */
@property OF_NULLABLE_PROPERTY (readonly, nonatomic) Class superclass;

/*!
 * @brief A 32 bit hash for the object.
 *
 * Classes containing data (like strings, arrays, lists etc.) should reimplement
 * this!
 *
 * @warning If you reimplement this, you also need to reimplement @ref isEqual:
 *	    to behave in a way compatible to your reimplementation of this
 *	    method!


 */
@property (readonly, nonatomic) uint32_t hash;

/*!


 * @brief The retain count.
 */
@property (readonly, nonatomic) unsigned int retainCount;

/*!


 * @brief Whether the object is a proxy object.
 */
@property (readonly, nonatomic) bool isProxy;

/*!


 * @brief Whether the object allows weak references.
 */
@property (readonly, nonatomic) bool allowsWeakReference;

/*!
 * @brief Returns a boolean whether the object of the specified kind.
 *
 * @param class_ The class whose kind is checked
 * @return A boolean whether the object is of the specified kind
 */







>
>
|

<
|
<
<
<


>
>
|

|


|







>
>

|


>
>
|

|


>
>
|

|


>
>
|

|







293
294
295
296
297
298
299
300
301
302
303

304



305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
/*!
 * @protocol OFObject OFObject.h ObjFW/OFObject.h
 *
 * @brief The protocol which all root classes implement.
 */
@protocol OFObject
/*!
 * @brief Returns the class of the object.
 *
 * @return The class of the object
 */

- (Class)class;




/*!
 * @brief Returns the superclass of the object.
 *
 * @return The superclass of the object
 */
- (nullable Class)superclass;

/*!
 * @brief Returns a 32 bit hash for the object.
 *
 * Classes containing data (like strings, arrays, lists etc.) should reimplement
 * this!
 *
 * @warning If you reimplement this, you also need to reimplement @ref isEqual:
 *	    to behave in a way compatible to your reimplementation of this
 *	    method!
 *
 * @return A 32 bit hash for the object
 */
- (uint32_t)hash;

/*!
 * @brief Returns the retain count.
 *
 * @return The retain count
 */
- (unsigned int)retainCount;

/*!
 * @brief Returns whether the object is a proxy object.
 *
 * @return Whether the object is a proxy object
 */
- (bool)isProxy;

/*!
 * @brief Returns whether the object allows weak references.
 *
 * @return Whether the object allows weak references
 */
- (bool)allowsWeakReference;

/*!
 * @brief Returns a boolean whether the object of the specified kind.
 *
 * @param class_ The class whose kind is checked
 * @return A boolean whether the object is of the specified kind
 */
527
528
529
530
531
532
533











534
535
536
537
538
539
540
@property (class, readonly, nonatomic, getter=class) Class class_;
#  endif
@property (class, readonly, nonatomic) OFString *className;
@property (class, readonly, nullable, nonatomic) Class superclass;
@property (class, readonly, nonatomic) OFString *description;
# endif












/*!
 * @brief The name of the object's class.
 */
@property (readonly, nonatomic) OFString *className;

/*!
 * @brief A description for the object.







>
>
>
>
>
>
>
>
>
>
>







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
@property (class, readonly, nonatomic, getter=class) Class class_;
#  endif
@property (class, readonly, nonatomic) OFString *className;
@property (class, readonly, nullable, nonatomic) Class superclass;
@property (class, readonly, nonatomic) OFString *description;
# endif

# ifdef __cplusplus
@property (readonly, nonatomic) Class class;
# else
@property (readonly, nonatomic, getter=class) Class class_;
#endif
@property OF_NULLABLE_PROPERTY (readonly, nonatomic) Class superclass;
@property (readonly, nonatomic) uint32_t hash;
@property (readonly, nonatomic) unsigned int retainCount;
@property (readonly, nonatomic) bool isProxy;
@property (readonly, nonatomic) bool allowsWeakReference;

/*!
 * @brief The name of the object's class.
 */
@property (readonly, nonatomic) OFString *className;

/*!
 * @brief A description for the object.

Modified src/OFString.m from [ed5bfcb060] to [a28b46c55c].

832
833
834
835
836
837
838


839
840
841
842
843
844


845
846
847
848
849
850


851
852
853
854
855
856
857


858
859
860
861
862
863
864
			    encoding: OF_STRING_ENCODING_UTF_8
			      length: UTF8StringLength];
}

- (instancetype)initWithUTF8StringNoCopy: (char *)UTF8String
			    freeWhenDone: (bool)freeWhenDone
{


	@try {
		return [self initWithUTF8String: UTF8String];
	} @finally {
		if (freeWhenDone)
			free(UTF8String);
	}


}

- (instancetype)initWithUTF8StringNoCopy: (char *)UTF8String
				  length: (size_t)UTF8StringLength
			    freeWhenDone: (bool)freeWhenDone
{


	@try {
		return [self initWithUTF8String: UTF8String
					 length: UTF8StringLength];
	} @finally {
		if (freeWhenDone)
			free(UTF8String);
	}


}

- (instancetype)initWithCString: (const char *)cString
		       encoding: (of_string_encoding_t)encoding
{
	return [self initWithCString: cString
			    encoding: encoding







>
>

|




>
>






>
>

|
|




>
>







832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
			    encoding: OF_STRING_ENCODING_UTF_8
			      length: UTF8StringLength];
}

- (instancetype)initWithUTF8StringNoCopy: (char *)UTF8String
			    freeWhenDone: (bool)freeWhenDone
{
	id ret;

	@try {
		ret = [self initWithUTF8String: UTF8String];
	} @finally {
		if (freeWhenDone)
			free(UTF8String);
	}

	return ret;
}

- (instancetype)initWithUTF8StringNoCopy: (char *)UTF8String
				  length: (size_t)UTF8StringLength
			    freeWhenDone: (bool)freeWhenDone
{
	id ret;

	@try {
		ret = [self initWithUTF8String: UTF8String
					length: UTF8StringLength];
	} @finally {
		if (freeWhenDone)
			free(UTF8String);
	}

	return ret;
}

- (instancetype)initWithCString: (const char *)cString
		       encoding: (of_string_encoding_t)encoding
{
	return [self initWithCString: cString
			    encoding: encoding

Modified src/OFSystemInfo.m from [4e15025453] to [3f56016e9e].

146
147
148
149
150
151
152
153
154

155
156
157
158
159
160
161
162
initOperatingSystemVersion(void)
{
#if defined(OF_IOS) || defined(OF_MACOS)
# ifdef OF_HAVE_FILES
	void *pool = objc_autoreleasePoolPush();

	@try {
		OFDictionary *propertyList = [OFString stringWithContentsOfFile:
		    @"/System/Library/CoreServices/SystemVersion.plist"]

		    .objectByParsingPropertyList;

		operatingSystemVersion = [[propertyList
		    objectForKey: @"ProductVersion"] copy];
	} @finally {
		objc_autoreleasePoolPop(pool);
	}
# endif







|
|
>
|







146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
initOperatingSystemVersion(void)
{
#if defined(OF_IOS) || defined(OF_MACOS)
# ifdef OF_HAVE_FILES
	void *pool = objc_autoreleasePoolPush();

	@try {
		OFDictionary *propertyList = [[OFString
		    stringWithContentsOfFile: @"/System/Library/CoreServices/"
		                              @"SystemVersion.plist"]
		    objectByParsingPropertyList];

		operatingSystemVersion = [[propertyList
		    objectForKey: @"ProductVersion"] copy];
	} @finally {
		objc_autoreleasePoolPop(pool);
	}
# endif

Modified src/OFThread.m from [5a3f2982c0] to [64242ae003].

252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
		@throw [OFOutOfRangeException exception];

	svcSleepThread((int64_t)(timeInterval * 1000000000));
#elif defined(HAVE_NANOSLEEP)
	struct timespec rqtp;

	rqtp.tv_sec = (time_t)timeInterval;
	rqtp.tv_nsec = (timeInterval - rqtp.tv_sec) * 1000000000;

	if (rqtp.tv_sec != trunc(timeInterval))
		@throw [OFOutOfRangeException exception];

	nanosleep(&rqtp, NULL);
#elif defined(OF_AMIGAOS)
	if (timeInterval * 50 > ULONG_MAX)







|







252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
		@throw [OFOutOfRangeException exception];

	svcSleepThread((int64_t)(timeInterval * 1000000000));
#elif defined(HAVE_NANOSLEEP)
	struct timespec rqtp;

	rqtp.tv_sec = (time_t)timeInterval;
	rqtp.tv_nsec = (long)((timeInterval - rqtp.tv_sec) * 1000000000);

	if (rqtp.tv_sec != trunc(timeInterval))
		@throw [OFOutOfRangeException exception];

	nanosleep(&rqtp, NULL);
#elif defined(OF_AMIGAOS)
	if (timeInterval * 50 > ULONG_MAX)

Modified src/OFURLHandler.m from [b1ea4038d8] to [2d065f473d].

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
		handler = [[class alloc] initWithScheme: scheme];
		@try {
			[handlers setObject: handler
				     forKey: scheme];
		} @finally {
			[handler release];
		}

		return true;
#ifdef OF_HAVE_THREADS
	} @finally {
		[mutex unlock];
	}
#endif


}

+ (OF_KINDOF(OFURLHandler *))handlerForURL: (OFURL *)URL
{


#ifdef OF_HAVE_THREADS
	[mutex lock];
	@try {
#endif
		return [handlers objectForKey: URL.scheme];
#ifdef OF_HAVE_THREADS
	} @finally {
		[mutex unlock];
	}
#endif


}

- (instancetype)init
{
	OF_INVALID_INIT_METHOD
}








<
<





>
>




>
>




|





>
>







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
		handler = [[class alloc] initWithScheme: scheme];
		@try {
			[handlers setObject: handler
				     forKey: scheme];
		} @finally {
			[handler release];
		}


#ifdef OF_HAVE_THREADS
	} @finally {
		[mutex unlock];
	}
#endif

	return true;
}

+ (OF_KINDOF(OFURLHandler *))handlerForURL: (OFURL *)URL
{
	OF_KINDOF(OFURLHandler *) handler;

#ifdef OF_HAVE_THREADS
	[mutex lock];
	@try {
#endif
		handler = [handlers objectForKey: URL.scheme];
#ifdef OF_HAVE_THREADS
	} @finally {
		[mutex unlock];
	}
#endif

	return handler;
}

- (instancetype)init
{
	OF_INVALID_INIT_METHOD
}

Modified src/OFValue.m from [ef18897f3a] to [a224fd5a05].

164
165
166
167
168
169
170

171
172
173
174
175
176
177
}

- (bool)isEqual: (id)object
{
	const char *objCType;
	size_t size;
	void *value, *otherValue;


	if (object == self)
		return true;

	if (![object isKindOfClass: [OFValue class]])
		return false;








>







164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
}

- (bool)isEqual: (id)object
{
	const char *objCType;
	size_t size;
	void *value, *otherValue;
	bool ret;

	if (object == self)
		return true;

	if (![object isKindOfClass: [OFValue class]])
		return false;

194
195
196
197
198
199
200
201
202
203
204
205


206
207
208
209
210
211
212

	@try {
		[self getValue: value
			  size: size];
		[object getValue: otherValue
			    size: size];

		return (memcmp(value, otherValue, size) == 0);
	} @finally {
		free(value);
		free(otherValue);
	}


}

- (uint32_t)hash
{
	size_t size = of_sizeof_type_encoding(self.objCType);
	unsigned char *value;
	uint32_t hash;







|




>
>







195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215

	@try {
		[self getValue: value
			  size: size];
		[object getValue: otherValue
			    size: size];

		ret = (memcmp(value, otherValue, size) == 0);
	} @finally {
		free(value);
		free(otherValue);
	}

	return ret;
}

- (uint32_t)hash
{
	size_t size = of_sizeof_type_encoding(self.objCType);
	unsigned char *value;
	uint32_t hash;

Modified src/platform/posix/condition.m from [3ba4daa8bb] to [59d3a90643].

46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
bool
of_condition_timed_wait(of_condition_t *condition, of_mutex_t *mutex,
    of_time_interval_t timeout)
{
	struct timespec ts;

	ts.tv_sec = (time_t)timeout;
	ts.tv_nsec = (timeout - ts.tv_sec) * 1000000000;

	return (pthread_cond_timedwait(condition, mutex, &ts) == 0);
}

bool
of_condition_free(of_condition_t *condition)
{







|







46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
bool
of_condition_timed_wait(of_condition_t *condition, of_mutex_t *mutex,
    of_time_interval_t timeout)
{
	struct timespec ts;

	ts.tv_sec = (time_t)timeout;
	ts.tv_nsec = (long)((timeout - ts.tv_sec) * 1000000000);

	return (pthread_cond_timedwait(condition, mutex, &ts) == 0);
}

bool
of_condition_free(of_condition_t *condition)
{

Modified src/socket.m from [0757bca949] to [e490baa3be].

40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#ifdef OF_HAVE_THREADS
# ifndef OF_AMIGAOS
#  import "mutex.h"
# else
#  import "tlskey.h"
# endif
#endif
#include "once.h"

#ifdef OF_AMIGAOS
# include <proto/exec.h>
#endif

#ifdef OF_NINTENDO_3DS
# include <3ds/types.h>







|







40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#ifdef OF_HAVE_THREADS
# ifndef OF_AMIGAOS
#  import "mutex.h"
# else
#  import "tlskey.h"
# endif
#endif
#import "once.h"

#ifdef OF_AMIGAOS
# include <proto/exec.h>
#endif

#ifdef OF_NINTENDO_3DS
# include <3ds/types.h>
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
			@throw [OFInvalidFormatException exception];

		number = component.unsignedLongLongValue;

		if (number > UINT8_MAX)
			@throw [OFInvalidFormatException exception];

		addr = (addr << 8) | (number & 0xFF);
	}

	addrIn->sin_addr.s_addr = OF_BSWAP32_IF_LE(addr);

	objc_autoreleasePoolPop(pool);

	return ret;







|







386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
			@throw [OFInvalidFormatException exception];

		number = component.unsignedLongLongValue;

		if (number > UINT8_MAX)
			@throw [OFInvalidFormatException exception];

		addr = (addr << 8) | ((uint32_t)number & 0xFF);
	}

	addrIn->sin_addr.s_addr = OF_BSWAP32_IF_LE(addr);

	objc_autoreleasePoolPop(pool);

	return ret;
497
498
499
500
501
502
503


504
505
506
507
508


509
510
511
512
513
514
515

	return ret;
}

of_socket_address_t
of_socket_address_parse_ip(OFString *IP, uint16_t port)
{


	@try {
		return of_socket_address_parse_ipv6(IP, port);
	} @catch (OFInvalidFormatException *e) {
		return of_socket_address_parse_ipv4(IP, port);
	}


}

of_socket_address_t
of_socket_address_ipx(const unsigned char node[IPX_NODE_LEN], uint32_t network,
    uint16_t port)
{
	of_socket_address_t ret;







>
>

|

|

>
>







497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519

	return ret;
}

of_socket_address_t
of_socket_address_parse_ip(OFString *IP, uint16_t port)
{
	of_socket_address_t ret;

	@try {
		ret = of_socket_address_parse_ipv6(IP, port);
	} @catch (OFInvalidFormatException *e) {
		ret = of_socket_address_parse_ipv4(IP, port);
	}

	return ret;
}

of_socket_address_t
of_socket_address_ipx(const unsigned char node[IPX_NODE_LEN], uint32_t network,
    uint16_t port)
{
	of_socket_address_t ret;