From 4522d9e7f65dd66e242ef5164a0c5e599203f78a Mon Sep 17 00:00:00 2001 From: "John Hodge (sonata)" Date: Sun, 20 Jan 2013 12:47:23 +0800 Subject: [PATCH] Usermode/ld-acess - Fixed error in FD_CLR that nuked the entire block --- .../Libraries/ld-acess.so_src/include_exp/acess/fd_set.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Usermode/Libraries/ld-acess.so_src/include_exp/acess/fd_set.h b/Usermode/Libraries/ld-acess.so_src/include_exp/acess/fd_set.h index 8972cbe4..b2367d19 100644 --- a/Usermode/Libraries/ld-acess.so_src/include_exp/acess/fd_set.h +++ b/Usermode/Libraries/ld-acess.so_src/include_exp/acess/fd_set.h @@ -30,17 +30,20 @@ static inline void FD_ZERO(fd_set *fdsetp) static inline void FD_CLR(int fd, fd_set *fdsetp) { if(fd < 0 || fd > FD_SETSIZE) return; - fdsetp->flags[fd/16] &= (fd_set_ent_t) ((~1 << (fd%16))) & 0xFFFF; + 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; - fdsetp->flags[fd/16] |= (fd_set_ent_t) (1 << (fd%16)); + fd_set_ent_t mask = 1 << (fd % 16); + fdsetp->flags[fd/16] |= mask; } 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)) ); + fd_set_ent_t mask = 1 << (fd % 16); + return !!( fdsetp->flags[fd/16] & mask ); } #endif -- 2.20.1