networking · beginner · ~15 min

Count epoll events of interest

Filter the epoll event array by a mask.

Challenge

Implement int count_matching(const unsigned *events, int n, unsigned mask) returning how many event words have at least one bit in mask set.

Starter code

int count_matching(const unsigned *events, int n, unsigned mask) {
    /* TODO */
    return 0;
}

Solve this exercise in the browser editor — compile and run against the test harness, no setup required.