Update.
[glibc.git] / misc / sys / select.h
blob0972560b972183e1f2dd0a98ffabccdc910c0380
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.
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.
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.
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. */
20 /* POSIX 1003.1g: 6.2 Select from File Descriptor Sets <sys/select.h> */
22 #ifndef _SYS_SELECT_H
23 #define _SYS_SELECT_H 1
25 #include <features.h>
27 /* Get definition of needed basic types. */
28 #include <bits/types.h>
30 /* Get __FD_* definitions. */
31 #include <bits/select.h>
33 /* Get __sigset_t. */
34 #include <bits/sigset.h>
36 /* Get definition of timer specification structures. */
37 #define __need_timespec
38 #include <time.h>
40 __BEGIN_DECLS
42 /* This declaration puts `struct timeval' in global scope even if
43 <sys/time.h> has not been included to define it. That way the
44 `select' prototype below will not conflict with a later definition
45 of `struct timeval'. */
46 struct timeval;
48 typedef __fd_mask fd_mask;
50 /* Representation of a set of file descriptors. */
51 typedef __fd_set fd_set;
53 /* Maximum number of file descriptors in `fd_set'. */
54 #define FD_SETSIZE __FD_SETSIZE
56 #ifdef __USE_MISC
57 /* Number of bits per word of `fd_set' (some code assumes this is 32). */
58 # define NFDBITS __NFDBITS
59 #endif
62 /* Access macros for `fd_set'. */
63 #define FD_SET(fd, fdsetp) __FD_SET ((fd), (fdsetp))
64 #define FD_CLR(fd, fdsetp) __FD_CLR ((fd), (fdsetp))
65 #define FD_ISSET(fd, fdsetp) __FD_ISSET ((fd), (fdsetp))
66 #define FD_ZERO(fdsetp) __FD_ZERO (fdsetp)
69 /* Check the first NFDS descriptors each in READFDS (if not NULL) for read
70 readiness, in WRITEFDS (if not NULL) for write readiness, and in EXCEPTFDS
71 (if not NULL) for exceptional conditions. If TIMEOUT is not NULL, time out
72 after waiting the interval specified therein. Returns the number of ready
73 descriptors, or -1 for errors. */
74 extern int __select __P ((int __nfds, __fd_set *__readfds,
75 __fd_set *__writefds, __fd_set *__exceptfds,
76 struct timeval *__timeout));
77 extern int select __P ((int __nfds, __fd_set *__readfds,
78 __fd_set *__writefds, __fd_set *__exceptfds,
79 struct timeval *__timeout));
81 #ifdef __USE_GNU
82 /* XXX Once/if POSIX.1g gets official this prototype will be available
83 when defining __USE_POSIX. */
84 /* Same as above only that the TIMEOUT value is given with higher
85 resolution and a sigmask which is been set temporarily. This version
86 should be used. */
87 extern int pselect __P ((int __nfds, __fd_set *__readfds,
88 __fd_set *__writefds, __fd_set *__exceptfds,
89 const struct timespec *__timeout,
90 const __sigset_t *__sigmask));
91 #endif
93 __END_DECLS
95 #endif /* sys/select.h */