1 /* `fd_set' type and related macros, and `select'/`pselect' declarations.
2 Copyright (C) 1996,97,98,99,2000,01,02,2003 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
19 /* POSIX 1003.1g: 6.2 Select from File Descriptor Sets <sys/select.h> */
22 #define _SYS_SELECT_H 1
26 /* Get definition of needed basic types. */
27 #include <bits/types.h>
29 /* Get __FD_* definitions. */
30 #include <bits/select.h>
33 #include <bits/sigset.h>
35 #ifndef __sigset_t_defined
36 # define __sigset_t_defined
37 typedef __sigset_t sigset_t
;
40 /* Get definition of timer specification structures. */
42 #define __need_timespec
44 #define __need_timeval
45 #include <bits/time.h>
47 #ifndef __suseconds_t_defined
48 typedef __suseconds_t suseconds_t
;
49 # define __suseconds_t_defined
53 /* The fd_set member is required to be an array of longs. */
54 typedef long int __fd_mask
;
56 /* Some versions of <linux/posix_types.h> define these macros. */
60 /* It's easier to assume 8-bit bytes than to get CHAR_BIT. */
61 #define __NFDBITS (8 * sizeof (__fd_mask))
62 #define __FDELT(d) ((d) / __NFDBITS)
63 #define __FDMASK(d) ((__fd_mask) 1 << ((d) % __NFDBITS))
65 /* fd_set for select and pselect. */
68 /* XPG4.2 requires this member name. Otherwise avoid the name
69 from the global namespace. */
71 __fd_mask fds_bits
[__FD_SETSIZE
/ __NFDBITS
];
72 # define __FDS_BITS(set) ((set)->fds_bits)
74 __fd_mask __fds_bits
[__FD_SETSIZE
/ __NFDBITS
];
75 # define __FDS_BITS(set) ((set)->__fds_bits)
79 /* Maximum number of file descriptors in `fd_set'. */
80 #define FD_SETSIZE __FD_SETSIZE
83 /* Sometimes the fd_set member is assumed to have this type. */
84 typedef __fd_mask fd_mask
;
86 /* Number of bits per word of `fd_set' (some code assumes this is 32). */
87 # define NFDBITS __NFDBITS
91 /* Access macros for `fd_set'. */
92 #define FD_SET(fd, fdsetp) __FD_SET (fd, fdsetp)
93 #define FD_CLR(fd, fdsetp) __FD_CLR (fd, fdsetp)
94 #define FD_ISSET(fd, fdsetp) __FD_ISSET (fd, fdsetp)
95 #define FD_ZERO(fdsetp) __FD_ZERO (fdsetp)
100 /* Check the first NFDS descriptors each in READFDS (if not NULL) for read
101 readiness, in WRITEFDS (if not NULL) for write readiness, and in EXCEPTFDS
102 (if not NULL) for exceptional conditions. If TIMEOUT is not NULL, time out
103 after waiting the interval specified therein. Returns the number of ready
104 descriptors, or -1 for errors.
106 This function is a cancellation point and therefore not marked with
108 extern int select (int __nfds
, fd_set
*__restrict __readfds
,
109 fd_set
*__restrict __writefds
,
110 fd_set
*__restrict __exceptfds
,
111 struct timeval
*__restrict __timeout
);
113 extern __typeof(select
) __select_nocancel attribute_hidden
;
114 libc_hidden_proto(select
)
118 /* Same as above only that the TIMEOUT value is given with higher
119 resolution and a sigmask which is been set temporarily. This version
122 This function is a cancellation point and therefore not marked with
124 extern int pselect (int __nfds
, fd_set
*__restrict __readfds
,
125 fd_set
*__restrict __writefds
,
126 fd_set
*__restrict __exceptfds
,
127 const struct timespec
*__restrict __timeout
,
128 const __sigset_t
*__restrict __sigmask
);
133 #endif /* sys/select.h */