Merge branch 'master' of git://localhost/acess2
[tpg/acess2.git] / Usermode / Libraries / ld-acess.so_src / include_exp / acess / fd_set.h
1 /*
2  * Acess2 Dynamic Linker
3  * - By John Hodge (thePowersGang)
4  *
5  * acess/fd_set.h
6  * - fd_set structure used by select()
7  */
8 #ifndef _ACESS__FD_SET_H_
9 #define _ACESS__FD_SET_H_
10
11 #define FD_SETSIZE      128
12
13 typedef unsigned short  fd_set_ent_t;
14
15 /**
16  * \brief fd_set for select()
17  */
18 typedef struct
19 {
20         fd_set_ent_t    flags[FD_SETSIZE/16];
21 }       fd_set;
22
23
24 static inline void      FD_ZERO(fd_set *fdsetp)
25 {
26         int i = FD_SETSIZE/16;
27         while( i-- )
28                 fdsetp->flags[i] = 0;
29 }
30 static inline  void     FD_CLR(int fd, fd_set *fdsetp)
31 {
32         if(fd < 0 || fd > FD_SETSIZE)   return;
33         fd_set_ent_t    mask = 1 << (fd % 16);
34         fdsetp->flags[fd/16] &= ~mask;
35 }
36 static inline  void     FD_SET(int fd, fd_set *fdsetp)
37 {
38         if(fd < 0 || fd > FD_SETSIZE)   return;
39         fd_set_ent_t    mask = 1 << (fd % 16);
40         fdsetp->flags[fd/16] |= mask;
41 }
42 static inline  int      FD_ISSET(int fd, fd_set *fdsetp)
43 {
44         if(fd < 0 || fd > FD_SETSIZE)   return 0;
45         fd_set_ent_t    mask = 1 << (fd % 16);
46         return !!( fdsetp->flags[fd/16] & mask );
47 }
48
49 #endif

UCC git Repository :: git.ucc.asn.au