pselect: new module
[gnulib.git] / lib / sys_select.in.h
1 /* Substitute for <sys/select.h>.
2    Copyright (C) 2007-2011 Free Software Foundation, Inc.
3
4    This program is free software; you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation; either version 2, or (at your option)
7    any later version.
8
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13
14    You should have received a copy of the GNU General Public License
15    along with this program; if not, write to the Free Software Foundation,
16    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
17
18 # if __GNUC__ >= 3
19 @PRAGMA_SYSTEM_HEADER@
20 # endif
21 @PRAGMA_COLUMNS@
22
23 /* On OSF/1, <sys/types.h> and <sys/time.h> include <sys/select.h>.
24    Simply delegate to the system's header in this case.  */
25 #if @HAVE_SYS_SELECT_H@ && defined __osf__ && (defined _SYS_TYPES_H_ && !defined _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TYPES_H) && defined _OSF_SOURCE
26
27 # define _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TYPES_H
28 # @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@
29
30 #elif @HAVE_SYS_SELECT_H@ && defined __osf__ && (defined _SYS_TIME_H_ && !defined _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TIME_H) && defined _OSF_SOURCE
31
32 # define _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TIME_H
33 # @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@
34
35 #else
36
37 #ifndef _@GUARD_PREFIX@_SYS_SELECT_H
38
39 #if @HAVE_SYS_SELECT_H@
40
41 /* On many platforms, <sys/select.h> assumes prior inclusion of
42    <sys/types.h>.  */
43 # include <sys/types.h>
44
45 /* On OSF/1 4.0, <sys/select.h> provides only a forward declaration
46    of 'struct timeval', and no definition of this type.
47    Also, MacOS X, AIX, HP-UX, IRIX, Solaris, Interix declare select()
48    in <sys/time.h>.
49    But avoid namespace pollution on glibc systems.  */
50 # ifndef __GLIBC__
51 #  include <sys/time.h>
52 # endif
53
54 /* On AIX 7 and Solaris 10, <sys/select.h> provides an FD_ZERO implementation
55    that relies on memset(), but without including <string.h>.
56    But in any case avoid namespace pollution on glibc systems.  */
57 # if (defined __OpenBSD__ || defined _AIX || defined __sun || defined __osf__ || defined __BEOS__) \
58      && ! defined __GLIBC__
59 #  include <string.h>
60 # endif
61
62 /* The include_next requires a split double-inclusion guard.  */
63 # @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@
64
65 #endif
66
67 #ifndef _@GUARD_PREFIX@_SYS_SELECT_H
68 #define _@GUARD_PREFIX@_SYS_SELECT_H
69
70 #if !@HAVE_SYS_SELECT_H@
71 /* A platform that lacks <sys/select.h>.  */
72 /* Get the 'struct timeval' and 'fd_set' types and the FD_* macros
73    on most platforms.  */
74 # include <sys/time.h>
75 /* On HP-UX 11, <sys/time.h> provides an FD_ZERO implementation
76    that relies on memset(), but without including <string.h>.  */
77 # if defined __hpux
78 #  include <string.h>
79 # endif
80 /* On native Windows platforms:
81    Get the 'fd_set' type.  Also, gnulib's <sys/socket.h> redefines select
82    so as to hide the declaration from <winsock2.h>.  */
83 # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
84 #  include <sys/socket.h>
85 # endif
86 #endif
87
88 /* Get definition of 'sigset_t'.
89    But avoid namespace pollution on glibc systems.  */
90 #if !(defined __GLIBC__ && !defined __UCLIBC__)
91 # include <signal.h>
92 #endif
93
94 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
95
96 /* The definition of _GL_WARN_ON_USE is copied here.  */
97
98
99 #if @GNULIB_PSELECT@
100 # if @REPLACE_PSELECT@
101 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
102 #   undef pselect
103 #   define pselect rpl_pselect
104 #  endif
105 _GL_FUNCDECL_RPL (pselect, int,
106                   (int, fd_set *restrict, fd_set *restrict, fd_set *restrict,
107                    struct timespec const *restrict, const sigset_t *restrict));
108 _GL_CXXALIAS_RPL (pselect, int,
109                   (int, fd_set *restrict, fd_set *restrict, fd_set *restrict,
110                    struct timespec const *restrict, const sigset_t *restrict));
111 # else
112 #  if !@HAVE_PSELECT@
113 _GL_FUNCDECL_SYS (pselect, int,
114                   (int, fd_set *restrict, fd_set *restrict, fd_set *restrict,
115                    struct timespec const *restrict, const sigset_t *restrict));
116 #  endif
117 _GL_CXXALIAS_SYS (pselect, int,
118                   (int, fd_set *restrict, fd_set *restrict, fd_set *restrict,
119                    struct timespec const *restrict, const sigset_t *restrict));
120 # endif
121 _GL_CXXALIASWARN (pselect);
122 #elif defined GNULIB_POSIXCHECK
123 # undef pselect
124 # if HAVE_RAW_DECL_PSELECT
125 _GL_WARN_ON_USE (pselect, "pselect is not portable - "
126                  "use gnulib module pselect for portability");
127 # endif
128 #endif
129
130 #if @GNULIB_SELECT@
131 # if @REPLACE_SELECT@
132 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
133 #   undef select
134 #   define select rpl_select
135 #  endif
136 _GL_FUNCDECL_RPL (select, int,
137                   (int, fd_set *, fd_set *, fd_set *, struct timeval *));
138 _GL_CXXALIAS_RPL (select, int,
139                   (int, fd_set *, fd_set *, fd_set *, struct timeval *));
140 # else
141 _GL_CXXALIAS_SYS (select, int,
142                   (int, fd_set *, fd_set *, fd_set *, struct timeval *));
143 # endif
144 _GL_CXXALIASWARN (select);
145 #elif @HAVE_WINSOCK2_H@
146 # undef select
147 # define select select_used_without_requesting_gnulib_module_select
148 #elif defined GNULIB_POSIXCHECK
149 # undef select
150 # if HAVE_RAW_DECL_SELECT
151 _GL_WARN_ON_USE (select, "select is not always POSIX compliant - "
152                  "use gnulib module select for portability");
153 # endif
154 #endif
155
156
157 #endif /* _@GUARD_PREFIX@_SYS_SELECT_H */
158 #endif /* _@GUARD_PREFIX@_SYS_SELECT_H */
159 #endif /* OSF/1 */