-
Notifications
You must be signed in to change notification settings - Fork 0
/
select.h
49 lines (36 loc) · 831 Bytes
/
select.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#ifndef SELECT_H
#define SELECT_H
#include "types.h"
#include "param.h"
struct spinlock;
struct selproc
{
int * sel[NSELPROC];
struct spinlock * lk[NSELPROC];
int selcount;
};
void initselproc(struct selproc *);
void clearselid(struct selproc *, int *);
void addselid(struct selproc *, int*, struct spinlock * lk);
void wakeupselect(struct selproc *);
static inline void _fd_set(int fd, fd_set* set)
{
*set |= (1 << fd);
}
static inline int _fd_isset(int fd, fd_set* set)
{
return *set & (1 << fd);
}
static inline void _fd_clr(int fd, fd_set* set)
{
*set &= ~(1 << fd);
}
static inline void _fd_zero(fd_set* set)
{
*set = 0;
}
#define FD_SET(fd, set) _fd_set(fd, set)
#define FD_ISSET(fd, set) _fd_isset(fd,set)
#define FD_CLR(fd, set) _fd_clr(fd, set)
#define FD_ZERO(set) _fd_zero(set)
#endif