]> git.ipfire.org Git - thirdparty/glibc.git/blob - misc/sys/select.h
Update.
[thirdparty/glibc.git] / misc / sys / select.h
1 /* `fd_set' type and related macros, and `select'/`pselect' declarations.
2 Copyright (C) 1996, 1997, 1998 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 Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 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 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 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 definition of timer specification structures. */
34 #define __need_timespec
35 #include <time.h>
36
37 __BEGIN_DECLS
38
39 /* This declaration puts `struct timeval' in global scope even if
40 <sys/time.h> has not been included to define it. That way the
41 `select' prototype below will not conflict with a later definition
42 of `struct timeval'. */
43 struct timeval;
44
45 typedef __fd_mask fd_mask;
46
47 /* Representation of a set of file descriptors. */
48 typedef __fd_set fd_set;
49
50 /* Maximum number of file descriptors in `fd_set'. */
51 #define FD_SETSIZE __FD_SETSIZE
52
53 #ifdef __USE_MISC
54 /* Number of bits per word of `fd_set' (some code assumes this is 32). */
55 # define NFDBITS __NFDBITS
56 #endif
57
58
59 /* Access macros for `fd_set'. */
60 #define FD_SET(fd, fdsetp) __FD_SET ((fd), (fdsetp))
61 #define FD_CLR(fd, fdsetp) __FD_CLR ((fd), (fdsetp))
62 #define FD_ISSET(fd, fdsetp) __FD_ISSET ((fd), (fdsetp))
63 #define FD_ZERO(fdsetp) __FD_ZERO (fdsetp)
64
65
66 /* Check the first NFDS descriptors each in READFDS (if not NULL) for read
67 readiness, in WRITEFDS (if not NULL) for write readiness, and in EXCEPTFDS
68 (if not NULL) for exceptional conditions. If TIMEOUT is not NULL, time out
69 after waiting the interval specified therein. Returns the number of ready
70 descriptors, or -1 for errors. */
71 extern int __select __P ((int __nfds, __fd_set *__readfds,
72 __fd_set *__writefds, __fd_set *__exceptfds,
73 struct timeval *__timeout));
74 extern int select __P ((int __nfds, __fd_set *__readfds,
75 __fd_set *__writefds, __fd_set *__exceptfds,
76 struct timeval *__timeout));
77
78 #ifdef __USE_GNU
79 /* XXX Once/if POSIX.1g gets official this prototype will be available
80 when defining __USE_POSIX. */
81 /* Same as above only that the TIMEOUT value is given with higher
82 resolution. This version should be used. */
83 extern int pselect __P ((int __nfds, __fd_set *__readfds,
84 __fd_set *__writefds, __fd_set *__exceptfds,
85 struct timespec *__timeout));
86 #endif
87
88 __END_DECLS
89
90 #endif /* sys/select.h */