sys_select: Avoid warning due to undeclared memset() on OpenBSD 4.5.
[gnulib.git] / lib / sys_select.in.h
1 /* Substitute for <sys/select.h>.
2    Copyright (C) 2007-2010 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 _GL_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    But avoid namespace pollution on glibc systems.  */
48 # ifndef __GLIBC__
49 #  include <sys/time.h>
50 # endif
51
52 /* On Solaris 10, <sys/select.h> provides an FD_ZERO implementation
53    that relies on memset(), but without including <string.h>.
54    But in any case avoid namespace pollution on glibc systems.  */
55 # if (defined __OpenBSD__ || defined __sun || defined __osf__ || defined __BEOS__) \
56      && ! defined __GLIBC__
57 #  include <string.h>
58 # endif
59
60 /* The include_next requires a split double-inclusion guard.  */
61 # @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@
62
63 #endif
64
65 #ifndef _GL_SYS_SELECT_H
66 #define _GL_SYS_SELECT_H
67
68 #if !@HAVE_SYS_SELECT_H@ || @REPLACE_SELECT@
69 /* A platform that lacks <sys/select.h>.  */
70 # include <sys/socket.h>
71 #endif
72
73 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
74
75 /* The definition of _GL_WARN_ON_USE is copied here.  */
76
77
78 #if @GNULIB_SELECT@
79 # if @HAVE_WINSOCK2_H@ || @REPLACE_SELECT@
80 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
81 #   undef select
82 #   define select rpl_select
83 #  endif
84 _GL_FUNCDECL_RPL (select, int,
85                   (int, fd_set *, fd_set *, fd_set *, struct timeval *));
86 _GL_CXXALIAS_RPL (select, int,
87                   (int, fd_set *, fd_set *, fd_set *, struct timeval *));
88 # else
89 _GL_CXXALIAS_SYS (select, int,
90                   (int, fd_set *, fd_set *, fd_set *, struct timeval *));
91 # endif
92 _GL_CXXALIASWARN (select);
93 #elif @HAVE_WINSOCK2_H@
94 # undef select
95 # define select select_used_without_requesting_gnulib_module_select
96 #elif defined GNULIB_POSIXCHECK
97 # undef select
98 # if HAVE_RAW_DECL_SELECT
99 _GL_WARN_ON_USE (select, "select is not always POSIX compliant - "
100                  "use gnulib module select for portability");
101 # endif
102 #endif
103
104
105 #endif /* _GL_SYS_SELECT_H */
106 #endif /* _GL_SYS_SELECT_H */
107 #endif /* OSF/1 */