1#ifndef _KERNEL_LIBKERN_BITS_SYS_SELECT_H
2#define _KERNEL_LIBKERN_BITS_SYS_SELECT_H
3
4#include <libkern/types.h>
5
6#define FD_SETSIZE 8
7
8struct fd_set {
9 uint8_t fds[FD_SETSIZE / 8];
10};
11typedef struct fd_set fd_set_t;
12
13#define FD_SET(fd, fd_set_ptr) ((fd_set_ptr)->fds[fd / 8] |= (1 << (fd % 8)))
14#define FD_CLR(fd, fd_set_ptr) ((fd_set_ptr)->fds[fd / 8] &= ~(1 << (fd % 8)))
15#define FD_ZERO(fd_set_ptr) (memset((uint8_t*)(fd_set_ptr), 0, sizeof(fd_set_t)))
16#define FD_ISSET(fd, fd_set_ptr) ((fd_set_ptr)->fds[fd / 8] & (1 << (fd % 8)))
17
18#endif // _KERNEL_LIBKERN_BITS_SYS_SELECT_H