ObjFW  Check-in [e9eb87694a]

Overview
Comment:OFKernelEventObserver: Support for Exec Signals
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: e9eb87694af3d1b3d07a3862c06c3ec14e95c1e93434265ff62515af6beb18d3
User & Date: js on 2019-08-31 12:40:36
Other Links: manifest | tags
Context
2019-08-31
12:50
Update PLATFORMS.md check-in: 9d6b6d0c05 user: js tags: trunk
12:40
OFKernelEventObserver: Support for Exec Signals check-in: e9eb87694a user: js tags: trunk
2019-08-22
19:01
ofhttp: Allow sandbox to read continued files check-in: a93dc48427 user: js tags: trunk
Changes

Modified src/OFKernelEventObserver.h from [79a475a756] to [860be5ffa7].

57
58
59
60
61
62
63









64
65
66
67
68
69
70

/*!
 * @brief This callback is called when an object did get ready for writing.
 *
 * @param object The object which did become ready for writing
 */
- (void)objectIsReadyForWriting: (id)object;









@end

/*!
 * @protocol OFReadyForReadingObserving
 *	     OFKernelEventObserver.h ObjFW/OFKernelEventObserver.h
 *
 * @brief This protocol is implemented by classes which can be observed for







>
>
>
>
>
>
>
>
>







57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79

/*!
 * @brief This callback is called when an object did get ready for writing.
 *
 * @param object The object which did become ready for writing
 */
- (void)objectIsReadyForWriting: (id)object;

#ifdef OF_AMIGAOS
/*!
 * @brief This callback is called when an Exec Signal was received.
 *
 * @note This is only available on AmigaOS!
 */
- (void)execSignalWasReceived: (ULONG)signalMask;
#endif
@end

/*!
 * @protocol OFReadyForReadingObserving
 *	     OFKernelEventObserver.h ObjFW/OFKernelEventObserver.h
 *
 * @brief This protocol is implemented by classes which can be observed for
117
118
119
120
121
122
123



124
125
126
127
128
129
130









131
132
133
134
135
136
137
	struct sockaddr_in _cancelAddr;
#endif
#ifdef OF_HAVE_THREADS
	OFMutex *_mutex;
#endif
	OFMutableData *_queueActions;
	OFMutableArray *_queueObjects;



}

/*!
 * @brief The delegate for the OFKernelEventObserver.
 */
@property OF_NULLABLE_PROPERTY (assign, nonatomic)
    id <OFKernelEventObserverDelegate> delegate;










/*!
 * @brief Creates a new OFKernelEventObserver.
 *
 * @return A new, autoreleased OFKernelEventObserver
 */
+ (instancetype)observer;







>
>
>







>
>
>
>
>
>
>
>
>







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
	struct sockaddr_in _cancelAddr;
#endif
#ifdef OF_HAVE_THREADS
	OFMutex *_mutex;
#endif
	OFMutableData *_queueActions;
	OFMutableArray *_queueObjects;
#ifdef OF_AMIGAOS
	ULONG _execSignalMask;
#endif
}

/*!
 * @brief The delegate for the OFKernelEventObserver.
 */
@property OF_NULLABLE_PROPERTY (assign, nonatomic)
    id <OFKernelEventObserverDelegate> delegate;

#ifdef OF_AMIGAOS
/*!
 * @brief A mask of Exec Signals to wait for.
 *
 * @note This is only available on AmigaOS!
 */
@property (nonatomic) ULONG execSignalMask;
#endif

/*!
 * @brief Creates a new OFKernelEventObserver.
 *
 * @return A new, autoreleased OFKernelEventObserver
 */
+ (instancetype)observer;

Modified src/OFKernelEventObserver.m from [8f3db9a0ca] to [6f6bd90234].

61
62
63
64
65
66
67



68
69
70
71
72
73
74
	QUEUE_READ = 0,
	QUEUE_WRITE = 2
};
#define QUEUE_ACTION (QUEUE_ADD | QUEUE_REMOVE)

@implementation OFKernelEventObserver
@synthesize delegate = _delegate;




+ (void)initialize
{
	if (self != [OFKernelEventObserver class])
		return;

	if (!of_socket_init())







>
>
>







61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
	QUEUE_READ = 0,
	QUEUE_WRITE = 2
};
#define QUEUE_ACTION (QUEUE_ADD | QUEUE_REMOVE)

@implementation OFKernelEventObserver
@synthesize delegate = _delegate;
#ifdef OF_AMIGAOS
@synthesize execSignalMask = _execSignalMask;
#endif

+ (void)initialize
{
	if (self != [OFKernelEventObserver class])
		return;

	if (!of_socket_init())

Modified src/OFSelectKernelEventObserver.m from [4d2c210634] to [b202b955cf].

139
140
141
142
143
144
145



146
147
148
149
150
151
152
- (void)observeForTimeInterval: (of_time_interval_t)timeInterval
{
	id const *objects;
	fd_set readFDs;
	fd_set writeFDs;
	struct timeval timeout;
	int events;



	size_t count;

	[self of_processQueue];

	if ([self of_processReadBuffers])
		return;








>
>
>







139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
- (void)observeForTimeInterval: (of_time_interval_t)timeInterval
{
	id const *objects;
	fd_set readFDs;
	fd_set writeFDs;
	struct timeval timeout;
	int events;
#ifdef OF_AMIGAOS
	ULONG execSignalMask;
#endif
	size_t count;

	[self of_processQueue];

	if ([self of_processReadBuffers])
		return;

167
168
169
170
171
172
173





174
175

176
177
178
179






180
181
182
183
184
185
186
#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,
	    (timeInterval != -1 ? &timeout : NULL));


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







	if (FD_ISSET(_cancelFD[0], &readFDs)) {
		char buffer;

#ifdef OF_HAVE_PIPE
		OF_ENSURE(read(_cancelFD[0], &buffer, 1) == 1);
#else







>
>
>
>
>


>




>
>
>
>
>
>







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
199
200
201
#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);

#ifdef OF_AMIGAOS
	execSignalMask = _execSignalMask;
	events = WaitSelect(_maxFD + 1, &readFDs, &writeFDs, NULL,
	    (void *)(timeInterval != -1 ? &timeout : NULL), &execSignalMask);
#else
	events = select(_maxFD + 1, &readFDs, &writeFDs, NULL,
	    (timeInterval != -1 ? &timeout : NULL));
#endif

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

#ifdef OF_AMIGAOS
	if (execSignalMask != 0 &&
	    [_delegate respondsToSelector: @selector(execSignalWasReceived:)])
		[_delegate execSignalWasReceived: execSignalMask];
#endif

	if (FD_ISSET(_cancelFD[0], &readFDs)) {
		char buffer;

#ifdef OF_HAVE_PIPE
		OF_ENSURE(read(_cancelFD[0], &buffer, 1) == 1);
#else

Modified src/socket_helpers.h from [2c4f4edda3] to [9adc1700dc].

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
# define closesocket(sock) close(sock)
#endif

#ifdef OF_MORPHOS_IXEMUL
typedef uint32_t in_addr_t;
#endif

#if defined(OF_AMIGAOS_M68K)
# define select(nfds, readfds, writefds, errorfds, timeout) \
    WaitSelect(nfds, readfds, writefds, errorfds, (struct __timeval *)timeout, \
    NULL)
#elif defined(OF_AMIGAOS4)
# define select(nfds, readfds, writefds, errorfds, timeout) \
    WaitSelect(nfds, readfds, writefds, errorfds, (struct TimeVal *)timeout, \
    NULL)
#elif defined(OF_MORPHOS)
# define select(nfds, readfds, writefds, errorfds, timeout) \
    WaitSelect(nfds, readfds, writefds, errorfds, timeout, NULL)
#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 closesocket(sock) net_close(sock)
# define connect(sock, addr, addrlen) \
    net_connect(sock, (struct sockaddr *)addr, addrlen)
# define fcntl(fd, cmd, flags) net_fcntl(fd, cmd, flags)







<
<
<
<
<
<
<
<
<
<
<
<
<







69
70
71
72
73
74
75













76
77
78
79
80
81
82
# define closesocket(sock) close(sock)
#endif

#ifdef OF_MORPHOS_IXEMUL
typedef uint32_t in_addr_t;
#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 closesocket(sock) net_close(sock)
# define connect(sock, addr, addrlen) \
    net_connect(sock, (struct sockaddr *)addr, addrlen)
# define fcntl(fd, cmd, flags) net_fcntl(fd, cmd, flags)