ev.h
static int ev_process_event(ev_context *ctx, int idx, int mask) {
    if (mask == EV_NONE) return EV_OK;
    struct ev *e = ev_api_fetch_event(ctx, idx, mask);
    int err = 0, fired = 0, fd = e->fd;
    if (mask & EV_CLOSEFD) {
#ifdef __linux__
        err = eventfd_read(fd, &(eventfd_t){0});
#else
        err = read(fd, &(unsigned long){0}, sizeof(unsigned long));
#endif // __linux__
        if (err < 0) return EV_OK;
        e->rcallback(ctx, e->rdata);
        ++fired;
    } else {
        if (mask & EV_EVENTFD) {
#ifdef __linux__
            err = eventfd_read(fd, &(eventfd_t){0L});
#else
            err = read(fd, &(unsigned long){0}, sizeof(unsigned long));
#endif // __linux__
            close(fd);
        } else if (mask & EV_TIMERFD) {
            err = read(fd, &(unsigned long int){0L}, sizeof(unsigned long int));
        }
        if (err < 0) return EV_OK;
        if (mask & EV_READ) {
            e->rcallback(ctx, e->rdata);
            ++fired;
        }
        if (mask & EV_WRITE) {
            if (!fired || e->wcallback != e->rcallback) {
                e->wcallback(ctx, e->wdata);
                ++fired;
            }
        }
    }
    return fired;
}
/*
 * Process the event at the position idx in the events_monitored array. Read or
 * write events can be executed on the same iteration, differentiating just
 * on EV_CLOSEFD or EV_EVENTFD.
 * Returns the number of fired callbacks.
 */
Process the event at the position idx in the events_monitored array. Read or
write events can be executed on the same iteration, differentiating just
on EV_CLOSEFD or EV_EVENTFD.
Returns the number of fired callbacks.
Process the event at the position idx in the events_monitored array . Read or write events can be executed on the same iteration differentiating just on EV_CLOSEFD or EV_EVENTFD . Returns the number of fired callbacks .
static int ev_process_event(ev_context *ctx, int idx, int mask) {
    if (mask == EV_NONE) return EV_OK;
    struct ev *e = ev_api_fetch_event(ctx, idx, mask);
    int err = 0, fired = 0, fd = e->fd;
    if (mask & EV_CLOSEFD) {
#ifdef __linux__
        err = eventfd_read(fd, &(eventfd_t){0});
#else
        err = read(fd, &(unsigned long){0}, sizeof(unsigned long));
#endif 
        if (err < 0) return EV_OK;
        e->rcallback(ctx, e->rdata);
        ++fired;
    } else {
        if (mask & EV_EVENTFD) {
#ifdef __linux__
            err = eventfd_read(fd, &(eventfd_t){0L});
#else
            err = read(fd, &(unsigned long){0}, sizeof(unsigned long));
#endif 
            close(fd);
        } else if (mask & EV_TIMERFD) {
            err = read(fd, &(unsigned long int){0L}, sizeof(unsigned long int));
        }
        if (err < 0) return EV_OK;
        if (mask & EV_READ) {
            e->rcallback(ctx, e->rdata);
            ++fired;
        }
        if (mask & EV_WRITE) {
            if (!fired || e->wcallback != e->rcallback) {
                e->wcallback(ctx, e->wdata);
                ++fired;
            }
        }
    }
    return fired;
}
static int ev_process_event ( ev_context * ctx , int idx , int mask ) { if ( mask == EV_NONE ) return EV_OK ; struct ev * e = ev_api_fetch_event ( ctx , idx , mask ) ; int err = 0 , fired = 0 , fd = e -> fd ; if ( mask & EV_CLOSEFD ) { #ifdef __linux__ err = eventfd_read ( fd , & ( eventfd_t ) { 0 } ) ; #else err = read ( fd , & ( unsigned long ) { 0 } , sizeof ( unsigned long ) ) ; #endif if ( err < 0 ) return EV_OK ; e -> rcallback ( ctx , e -> rdata ) ; ++ fired ; } else { if ( mask & EV_EVENTFD ) { #ifdef __linux__ err = eventfd_read ( fd , & ( eventfd_t ) { 0L } ) ; #else err = read ( fd , & ( unsigned long ) { 0 } , sizeof ( unsigned long ) ) ; #endif close ( fd ) ; } else if ( mask & EV_TIMERFD ) { err = read ( fd , & ( unsigned long int ) { 0L } , sizeof ( unsigned long int ) ) ; } if ( err < 0 ) return EV_OK ; if ( mask & EV_READ ) { e -> rcallback ( ctx , e -> rdata ) ; ++ fired ; } if ( mask & EV_WRITE ) { if ( ! fired || e -> wcallback != e -> rcallback ) { e -> wcallback ( ctx , e -> wdata ) ; ++ fired ; } } } return fired ; }
Process the event at the position idx in the events_monitored array.
Process the event at the position idx in the events_monitored array .
// __linux__ // __linux__