Usermode/ld-acess - Fix constness in FD_ISSET
[tpg/acess2.git] / Usermode / Libraries / ld-acess.so_src / include_exp / acess / fd_set.h
index 0793901..a0fbe43 100644 (file)
@@ -21,9 +21,29 @@ typedef struct
 }      fd_set;
 
 
-extern void    FD_ZERO(fd_set *fdsetp);
-extern void    FD_CLR(int fd, fd_set *fdsetp);
-extern void    FD_SET(int fd, fd_set *fdsetp);
-extern int     FD_ISSET(int fd, fd_set *fdsetp);
+static inline void     FD_ZERO(fd_set *fdsetp)
+{
+       int i = FD_SETSIZE/16;
+       while( i-- )
+               fdsetp->flags[i] = 0;
+}
+static inline  void    FD_CLR(int fd, fd_set *fdsetp)
+{
+       if(fd < 0 || fd > FD_SETSIZE)   return;
+       fd_set_ent_t    mask = 1 << (fd % 16);
+       fdsetp->flags[fd/16] &= ~mask;
+}
+static inline  void    FD_SET(int fd, fd_set *fdsetp)
+{
+       if(fd < 0 || fd > FD_SETSIZE)   return;
+       fd_set_ent_t    mask = 1 << (fd % 16);
+       fdsetp->flags[fd/16] |= mask;
+}
+static inline  int     FD_ISSET(int fd, const fd_set *fdsetp)
+{
+       if(fd < 0 || fd > FD_SETSIZE)   return 0;
+       fd_set_ent_t    mask = 1 << (fd % 16);
+       return !!( fdsetp->flags[fd/16] & mask );
+}
 
 #endif

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