2 * include/bits/select.h -- fd_set operations
4 * Copyright (C) 2003 John Williams <jwilliams@itee.uq.edu.au>
5 * Copyright (C) 2001 NEC Corporation
6 * Copyright (C) 2001 Miles Bader <miles@gnu.org>
7 * Copyright (C) 1997, 1998 Free Software Foundation, Inc.
9 * This file is subject to the terms and conditions of the GNU Lesser
10 * General Public License. See the file COPYING.LIB in the main
11 * directory of this archive for more details.
15 # error "Never use <bits/select.h> directly; include <sys/select.h> instead."
20 /* We don't use `memset' because this would require a prototype and
21 the array isn't too big. */
22 #define __FD_ZERO(s) \
25 fd_set *__arr = (s); \
26 for (__i = 0; __i < sizeof (fd_set) / sizeof (__fd_mask); ++__i) \
27 __FDS_BITS (__arr)[__i] = 0; \
30 #define __FD_SET(fd, s) \
33 unsigned int *__addr = (unsigned int *)&__FDS_BITS (s); \
34 *__addr |= (1 << __fd); \
37 #define __FD_CLR(fd, s) \
40 unsigned int *__addr = (unsigned int *)&__FDS_BITS (s); \
41 *__addr &= ~(1 << __fd); \
44 #define __FD_ISSET(fd, s) \
47 unsigned int *__addr = (unsigned int *)&__FDS_BITS (s); \
49 res = (*__addr & (1 << fd)) ? 1 : 0; \
54 #define __FD_SET(d, s) (__FDS_BITS (s)[__FDELT(d)] |= __FDMASK(d))
55 #define __FD_CLR(d, s) (__FDS_BITS (s)[__FDELT(d)] &= ~__FDMASK(d))
56 #define __FD_ISSET(d, s) ((__FDS_BITS (s)[__FDELT(d)] & __FDMASK(d)) != 0)