ObjFW  Diff

Differences From Artifact [0d55873c55]:

To Artifact [855b79f521]:


15
16
17
18
19
20
21

22
23
24
25
26
27
28
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29







+







 */

#include "config.h"

#define __NO_EXT_QNX

#include <string.h>
#include <math.h>
#include <unistd.h>

#include <sys/time.h>

#import "OFStreamObserver_select.h"
#import "OFStream.h"
#import "OFArray.h"
67
68
69
70
71
72
73
74

75
76
77
78
79
80
81

82
83
84
85
86
87
88
68
69
70
71
72
73
74

75
76
77
78
79
80
81

82
83
84
85
86
87
88
89







-
+






-
+







{
	FD_CLR(fd, &_writeFDs);

	if (!FD_ISSET(fd, &_readFDs))
		FD_CLR(fd, &_exceptFDs);
}

- (bool)observeWithTimeout: (double)timeout
- (bool)observeForTimeInterval: (double)timeInterval
{
	void *pool = objc_autoreleasePoolPush();
	OFStream **objects;
	fd_set readFDs;
	fd_set writeFDs;
	fd_set exceptFDs;
	struct timeval time;
	struct timeval timeout;
	size_t i, count, realEvents = 0;

	[self OF_processQueue];

	if ([self OF_processCache]) {
		objc_autoreleasePoolPop(pool);
		return true;
102
103
104
105
106
107
108
109
110


111
112
113

114
115
116
117
118
119
120
103
104
105
106
107
108
109


110
111
112
113

114
115
116
117
118
119
120
121







-
-
+
+


-
+








	/*
	 * 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.
	 */
	time.tv_sec = (time_t)timeout;
	time.tv_usec = (int)((timeout - time.tv_sec) * 1000);
	timeout.tv_sec = (time_t)timeInterval;
	timeout.tv_usec = (int)lrint((timeInterval - timeout.tv_sec) * 1000);

	if (select((int)_maxFD + 1, &readFDs, &writeFDs, &exceptFDs,
	    (timeout != -1 ? &time : NULL)) < 1)
	    (timeInterval != -1 ? &timeout : NULL)) < 1)
		return false;

	if (FD_ISSET(_cancelFD[0], &readFDs)) {
		char buffer;
#ifndef _WIN32
		OF_ENSURE(read(_cancelFD[0], &buffer, 1) > 0);
#else