|
|
|
@ -28,6 +28,7 @@
|
|
|
|
|
|
|
|
|
|
static int _next_index;
|
|
|
|
|
static int _fds[ASYNC_READ_NUMOF];
|
|
|
|
|
static void *_args[ASYNC_READ_NUMOF];
|
|
|
|
|
static native_async_read_callback_t _native_async_read_callbacks[ASYNC_READ_NUMOF];
|
|
|
|
|
|
|
|
|
|
#ifdef __MACH__
|
|
|
|
@ -55,7 +56,7 @@ static void _async_io_isr(void) {
|
|
|
|
|
if (real_select(max_fd + 1, &rfds, NULL, NULL, &timeout) > 0) {
|
|
|
|
|
for (int i = 0; i < _next_index; i++) {
|
|
|
|
|
if (FD_ISSET(_fds[i], &rfds)) {
|
|
|
|
|
_native_async_read_callbacks[i](_fds[i]);
|
|
|
|
|
_native_async_read_callbacks[i](_fds[i], _args[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -86,12 +87,13 @@ void native_async_read_continue(int fd) {
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void native_async_read_add_handler(int fd, native_async_read_callback_t handler) {
|
|
|
|
|
void native_async_read_add_handler(int fd, void *arg, native_async_read_callback_t handler) {
|
|
|
|
|
if (_next_index >= ASYNC_READ_NUMOF) {
|
|
|
|
|
err(EXIT_FAILURE, "native_async_read_add_handler(): too many callbacks");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_fds[_next_index] = fd;
|
|
|
|
|
_args[_next_index] = arg;
|
|
|
|
|
_native_async_read_callbacks[_next_index] = handler;
|
|
|
|
|
|
|
|
|
|
#ifdef __MACH__
|
|
|
|
|