Misc changes
[tpg/acess2.git] / Usermode / include / sys / types.h
index a1ed85b..ec3d43e 100644 (file)
@@ -70,9 +70,18 @@ typedef struct s_sysFInfo    t_sysFInfo;
 typedef struct s_sysACL        t_sysACL;
 
 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) { fdsetp->flags[fd/16]&=~(1<<(fd%16)); }
-static inline void FD_SET(int fd, fd_set *fdsetp) { fdsetp->flags[fd/16]|=1<<(fd%16); }
-static inline int FD_ISSET(int fd, fd_set *fdsetp) { return fdsetp->flags[fd/16]&(1<<(fd%16)); }
+static inline void FD_CLR(int fd, fd_set *fdsetp) {
+       if(fd < 0 || fd > FD_SETSIZE)   return;
+       fdsetp->flags[fd/16] &= (uint16_t) ((~1 << (fd%16))) & 0xFFFF;
+}
+static inline void FD_SET(int fd, fd_set *fdsetp) {
+       if(fd < 0 || fd > FD_SETSIZE)   return;
+       fdsetp->flags[fd/16] |= (uint16_t) (1 << (fd%16));
+}
+static inline int FD_ISSET(int fd, fd_set *fdsetp) {
+       if(fd < 0 || fd > FD_SETSIZE)   return 0;
+       return !!( fdsetp->flags[fd/16] & (1<<(fd%16)) );
+}
 
 typedef uint32_t       pid_t;
 typedef uint32_t       tid_t;

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