]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/uclibc/lib/contrib/uclibc/libc/sysdeps/linux/microblaze/bits/select.h
Inital import
[l4.git] / l4 / pkg / uclibc / lib / contrib / uclibc / libc / sysdeps / linux / microblaze / bits / select.h
1 /*
2  * include/bits/select.h -- fd_set operations
3  *
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.
8  *
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.
12  */
13
14 #ifndef _SYS_SELECT_H
15 # error "Never use <bits/select.h> directly; include <sys/select.h> instead."
16 #endif
17
18 #ifdef __GNUC__
19
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)                                                          \
23   do {                                                                        \
24     unsigned int __i;                                                         \
25     fd_set *__arr = (s);                                                      \
26     for (__i = 0; __i < sizeof (fd_set) / sizeof (__fd_mask); ++__i)          \
27       __FDS_BITS (__arr)[__i] = 0;                                            \
28   } while (0)
29
30 #define __FD_SET(fd, s)                                                       \
31   do {                                                                        \
32         int __fd = (fd);                                                      \
33         unsigned int *__addr = (unsigned int *)&__FDS_BITS (s);               \
34         *__addr |= (1 << __fd);                                               \
35   } while (0)
36
37 #define __FD_CLR(fd, s)                                                       \
38   do {                                                                        \
39         int __fd = (fd);                                                      \
40         unsigned int *__addr = (unsigned int *)&__FDS_BITS (s);               \
41         *__addr &= ~(1 << __fd);                                              \
42   } while (0)
43
44 #define __FD_ISSET(fd, s)                                                     \
45   ({                                                                          \
46         int __fd = (fd);                                                      \
47         unsigned int *__addr = (unsigned int *)&__FDS_BITS (s);               \
48         int res;                                                              \
49         res = (*__addr & (1 << fd)) ? 1 : 0;                                  \
50   })
51
52 #else /* !__GNUC__ */
53
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)
57
58 #endif /* __GNUC__ */