Skip to content

Instantly share code, notes, and snippets.

@OrangeTide
Created June 1, 2011 16:49
Show Gist options
  • Save OrangeTide/1002727 to your computer and use it in GitHub Desktop.
Save OrangeTide/1002727 to your computer and use it in GitHub Desktop.
fast copy of select's fd_set
#define _XOPEN_SOURCE 700
#include <sys/select.h>
static void copyfdset(fd_set *d, fd_set *s, unsigned fd_max) {
unsigned i;
unsigned n = (fd_max + 1 + __NFDBITS - 1) / __NFDBITS;
for(i = 0; i < n; i++) {
d->fds_bits[i] = s->fds_bits[i];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment