1 |
1325 |
phoenix |
/* `fd_set' type and related macros, and `select'/`pselect' declarations.
|
2 |
|
|
Copyright (C) 1996,1997,1998,1999,2000,2001 Free Software Foundation, Inc.
|
3 |
|
|
This file is part of the GNU C Library.
|
4 |
|
|
|
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.
|
9 |
|
|
|
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.
|
14 |
|
|
|
15 |
|
|
You should have received a copy of the GNU Lesser General Public
|
16 |
|
|
License along with the GNU C Library; if not, write to the Free
|
17 |
|
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
18 |
|
|
02111-1307 USA. */
|
19 |
|
|
|
20 |
|
|
/* POSIX 1003.1g: 6.2 Select from File Descriptor Sets <sys/select.h> */
|
21 |
|
|
|
22 |
|
|
#ifndef _SYS_SELECT_H
|
23 |
|
|
#define _SYS_SELECT_H 1
|
24 |
|
|
|
25 |
|
|
#include <features.h>
|
26 |
|
|
|
27 |
|
|
/* Get definition of needed basic types. */
|
28 |
|
|
#include <bits/types.h>
|
29 |
|
|
|
30 |
|
|
/* Get __FD_* definitions. */
|
31 |
|
|
#include <bits/select.h>
|
32 |
|
|
|
33 |
|
|
/* Get __sigset_t. */
|
34 |
|
|
#include <bits/sigset.h>
|
35 |
|
|
|
36 |
|
|
#ifndef __sigset_t_defined
|
37 |
|
|
# define __sigset_t_defined
|
38 |
|
|
typedef __sigset_t sigset_t;
|
39 |
|
|
#endif
|
40 |
|
|
|
41 |
|
|
/* Get definition of timer specification structures. */
|
42 |
|
|
#define __need_timespec
|
43 |
|
|
#include <time.h>
|
44 |
|
|
#define __need_timeval
|
45 |
|
|
#include <bits/time.h>
|
46 |
|
|
|
47 |
|
|
|
48 |
|
|
/* The fd_set member is required to be an array of longs. */
|
49 |
|
|
typedef long int __fd_mask;
|
50 |
|
|
|
51 |
|
|
/* It's easier to assume 8-bit bytes than to get CHAR_BIT. */
|
52 |
|
|
#define __NFDBITS (8 * sizeof (__fd_mask))
|
53 |
|
|
#define __FDELT(d) ((d) / __NFDBITS)
|
54 |
|
|
#define __FDMASK(d) ((__fd_mask) 1 << ((d) % __NFDBITS))
|
55 |
|
|
|
56 |
|
|
/* fd_set for select and pselect. */
|
57 |
|
|
typedef struct
|
58 |
|
|
{
|
59 |
|
|
/* XPG4.2 requires this member name. Otherwise avoid the name
|
60 |
|
|
from the global namespace. */
|
61 |
|
|
#ifdef __USE_XOPEN
|
62 |
|
|
__fd_mask fds_bits[__FD_SETSIZE / __NFDBITS];
|
63 |
|
|
# define __FDS_BITS(set) ((set)->fds_bits)
|
64 |
|
|
#else
|
65 |
|
|
__fd_mask __fds_bits[__FD_SETSIZE / __NFDBITS];
|
66 |
|
|
# define __FDS_BITS(set) ((set)->__fds_bits)
|
67 |
|
|
#endif
|
68 |
|
|
} fd_set;
|
69 |
|
|
|
70 |
|
|
/* Maximum number of file descriptors in `fd_set'. */
|
71 |
|
|
#define FD_SETSIZE __FD_SETSIZE
|
72 |
|
|
|
73 |
|
|
#ifdef __USE_MISC
|
74 |
|
|
/* Sometimes the fd_set member is assumed to have this type. */
|
75 |
|
|
typedef __fd_mask fd_mask;
|
76 |
|
|
|
77 |
|
|
/* Number of bits per word of `fd_set' (some code assumes this is 32). */
|
78 |
|
|
# define NFDBITS __NFDBITS
|
79 |
|
|
#endif
|
80 |
|
|
|
81 |
|
|
|
82 |
|
|
/* Access macros for `fd_set'. */
|
83 |
|
|
#define FD_SET(fd, fdsetp) __FD_SET (fd, fdsetp)
|
84 |
|
|
#define FD_CLR(fd, fdsetp) __FD_CLR (fd, fdsetp)
|
85 |
|
|
#define FD_ISSET(fd, fdsetp) __FD_ISSET (fd, fdsetp)
|
86 |
|
|
#define FD_ZERO(fdsetp) __FD_ZERO (fdsetp)
|
87 |
|
|
|
88 |
|
|
|
89 |
|
|
__BEGIN_DECLS
|
90 |
|
|
|
91 |
|
|
/* Check the first NFDS descriptors each in READFDS (if not NULL) for read
|
92 |
|
|
readiness, in WRITEFDS (if not NULL) for write readiness, and in EXCEPTFDS
|
93 |
|
|
(if not NULL) for exceptional conditions. If TIMEOUT is not NULL, time out
|
94 |
|
|
after waiting the interval specified therein. Returns the number of ready
|
95 |
|
|
descriptors, or -1 for errors. */
|
96 |
|
|
extern int select (int __nfds, fd_set *__restrict __readfds,
|
97 |
|
|
fd_set *__restrict __writefds,
|
98 |
|
|
fd_set *__restrict __exceptfds,
|
99 |
|
|
struct timeval *__restrict __timeout) __THROW;
|
100 |
|
|
|
101 |
|
|
#ifdef __USE_XOPEN2K
|
102 |
|
|
/* Same as above only that the TIMEOUT value is given with higher
|
103 |
|
|
resolution and a sigmask which is been set temporarily. This version
|
104 |
|
|
should be used. */
|
105 |
|
|
extern int pselect (int __nfds, fd_set *__restrict __readfds,
|
106 |
|
|
fd_set *__restrict __writefds,
|
107 |
|
|
fd_set *__restrict __exceptfds,
|
108 |
|
|
const struct timespec *__restrict __timeout,
|
109 |
|
|
const __sigset_t *__restrict __sigmask) __THROW;
|
110 |
|
|
#endif
|
111 |
|
|
|
112 |
|
|
__END_DECLS
|
113 |
|
|
|
114 |
|
|
#endif /* sys/select.h */
|