root/lib/sys_select.in.h

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. rpl_fd_isset

     1 /* Substitute for <sys/select.h>.
     2    Copyright (C) 2007-2023 Free Software Foundation, Inc.
     3 
     4    This file is free software: you can redistribute it and/or modify
     5    it under the terms of the GNU Lesser General Public License as
     6    published by the Free Software Foundation; either version 2.1 of the
     7    License, or (at your option) any later version.
     8 
     9    This file 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 Lesser General Public License for more details.
    13 
    14    You should have received a copy of the GNU Lesser General Public License
    15    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
    16 
    17 # if __GNUC__ >= 3
    18 @PRAGMA_SYSTEM_HEADER@
    19 # endif
    20 @PRAGMA_COLUMNS@
    21 
    22 /* This file uses #include_next of a system file that defines time_t.
    23    For the 'year2038' module to work right, <config.h> needs to have been
    24    included before.  */
    25 #if !_GL_CONFIG_H_INCLUDED
    26  #error "Please include config.h first."
    27 #endif
    28 
    29 /* On OSF/1 and Solaris 2.6, <sys/types.h> and <sys/time.h>
    30    both include <sys/select.h>.
    31    On Cygwin and OpenBSD, <sys/time.h> includes <sys/select.h>.
    32    Simply delegate to the system's header in this case.  */
    33 #if (@HAVE_SYS_SELECT_H@                                                \
    34      && !defined _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TYPES_H             \
    35      && ((defined __osf__ && defined _SYS_TYPES_H_                      \
    36           && defined _OSF_SOURCE)                                       \
    37          || (defined __sun && defined _SYS_TYPES_H                      \
    38              && (! (defined _XOPEN_SOURCE || defined _POSIX_C_SOURCE)   \
    39                  || defined __EXTENSIONS__))))
    40 
    41 # define _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TYPES_H
    42 # @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@
    43 
    44 #elif (@HAVE_SYS_SELECT_H@                                              \
    45        && (defined _CYGWIN_SYS_TIME_H                                   \
    46            || (!defined _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TIME_H       \
    47                && ((defined __osf__ && defined _SYS_TIME_H_             \
    48                     && defined _OSF_SOURCE)                             \
    49                    || (defined __OpenBSD__ && defined _SYS_TIME_H_)     \
    50                    || (defined __sun && defined _SYS_TIME_H             \
    51                        && (! (defined _XOPEN_SOURCE                     \
    52                               || defined _POSIX_C_SOURCE)               \
    53                            || defined __EXTENSIONS__))))))
    54 
    55 # define _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TIME_H
    56 # @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@
    57 
    58 /* On IRIX 6.5, <sys/timespec.h> includes <sys/types.h>, which includes
    59    <sys/bsd_types.h>, which includes <sys/select.h>.  At this point we cannot
    60    include <signal.h>, because that includes <internal/signal_core.h>, which
    61    gives a syntax error because <sys/timespec.h> has not been completely
    62    processed.  Simply delegate to the system's header in this case.  */
    63 #elif @HAVE_SYS_SELECT_H@ && defined __sgi && (defined _SYS_BSD_TYPES_H && !defined _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_BSD_TYPES_H)
    64 
    65 # define _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_BSD_TYPES_H
    66 # @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@
    67 
    68 /* On OpenBSD 5.0, <pthread.h> includes <sys/types.h>, which includes
    69    <sys/select.h>.  At this point we cannot include <signal.h>, because that
    70    includes gnulib's pthread.h override, which gives a syntax error because
    71    /usr/include/pthread.h has not been completely processed.  Simply delegate
    72    to the system's header in this case.  */
    73 #elif @HAVE_SYS_SELECT_H@ && defined __OpenBSD__ && (defined _PTHREAD_H_ && !defined PTHREAD_MUTEX_INITIALIZER)
    74 
    75 # @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@
    76 
    77 #else
    78 
    79 #ifndef _@GUARD_PREFIX@_SYS_SELECT_H
    80 
    81 /* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*.  */
    82 #if !_GL_CONFIG_H_INCLUDED
    83  #error "Please include config.h first."
    84 #endif
    85 
    86 /* On many platforms, <sys/select.h> assumes prior inclusion of
    87    <sys/types.h>.  Also, mingw defines sigset_t there, instead of
    88    in <signal.h> where it belongs.  */
    89 #include <sys/types.h>
    90 
    91 #if @HAVE_SYS_SELECT_H@
    92 
    93 /* On OSF/1 4.0, <sys/select.h> provides only a forward declaration
    94    of 'struct timeval', and no definition of this type.
    95    Also, Mac OS X, AIX, HP-UX, IRIX, Solaris, Interix declare select()
    96    in <sys/time.h>.
    97    But avoid namespace pollution on glibc systems, a circular include
    98    <sys/select.h> -> <sys/time.h> -> <sys/select.h> on FreeBSD 13.1, and
    99    "unknown type name" problems on Cygwin.  */
   100 # if !(defined __GLIBC__ || defined __FreeBSD__ || defined __CYGWIN__)
   101 #  include <sys/time.h>
   102 # endif
   103 
   104 /* On AIX 7 and Solaris 10, <sys/select.h> provides an FD_ZERO implementation
   105    that relies on memset(), but without including <string.h>.
   106    But in any case avoid namespace pollution on glibc systems.  */
   107 # if (defined __OpenBSD__ || defined _AIX || defined __sun || defined __osf__ || defined __BEOS__) \
   108      && ! defined __GLIBC__
   109 #  include <string.h>
   110 # endif
   111 
   112 /* The include_next requires a split double-inclusion guard.  */
   113 # @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@
   114 
   115 #endif
   116 
   117 /* Get definition of 'sigset_t'.
   118    But avoid namespace pollution on glibc systems and "unknown type
   119    name" problems on Cygwin.
   120    On OS/2 kLIBC, sigset_t is defined in <sys/select.h>, too. In addition,
   121    if <sys/param.h> is included, <types.h> -> <sys/types.h> -> <sys/select.h>
   122    are included. Then <signal.h> -> <pthread.h> are included by GNULIB. By the
   123    way, <pthread.h> requires PAGE_SIZE defined in <sys/param.h>. However,
   124    <sys/param.h> has not been processed, yet. As a result, 'PAGE_SIZE'
   125    undeclared error occurs in <pthread.h>.
   126    Do this after the include_next (for the sake of OpenBSD 5.0) but before
   127    the split double-inclusion guard (for the sake of Solaris).  */
   128 #if !((defined __GLIBC__ || defined __CYGWIN__ || defined __KLIBC__) \
   129       && !defined __UCLIBC__)
   130 # include <signal.h>
   131 #endif
   132 
   133 #ifndef _@GUARD_PREFIX@_SYS_SELECT_H
   134 #define _@GUARD_PREFIX@_SYS_SELECT_H
   135 
   136 #if !@HAVE_SYS_SELECT_H@
   137 /* A platform that lacks <sys/select.h>.  */
   138 /* Get the 'struct timeval' and 'fd_set' types and the FD_* macros
   139    on most platforms.  */
   140 # include <sys/time.h>
   141 /* On HP-UX 11, <sys/time.h> provides an FD_ZERO implementation
   142    that relies on memset(), but without including <string.h>.  */
   143 # if defined __hpux
   144 #  include <string.h>
   145 # endif
   146 /* On native Windows platforms:
   147    Get the 'fd_set' type.
   148    Get the close() declaration before we override it.  */
   149 # if @HAVE_WINSOCK2_H@
   150 #  if !defined _GL_INCLUDING_WINSOCK2_H
   151 #   define _GL_INCLUDING_WINSOCK2_H
   152 #   include <winsock2.h>
   153 #   undef _GL_INCLUDING_WINSOCK2_H
   154 #  endif
   155 #  include <io.h>
   156 # endif
   157 #endif
   158 
   159 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
   160 
   161 /* The definition of _GL_WARN_ON_USE is copied here.  */
   162 
   163 
   164 /* Fix some definitions from <winsock2.h>.  */
   165 
   166 #if @HAVE_WINSOCK2_H@
   167 
   168 # if !GNULIB_defined_rpl_fd_isset
   169 
   170 /* Re-define FD_ISSET to avoid a WSA call while we are not using
   171    network sockets.  */
   172 static int
   173 rpl_fd_isset (SOCKET fd, fd_set * set)
   174 {
   175   u_int i;
   176   if (set == NULL)
   177     return 0;
   178 
   179   for (i = 0; i < set->fd_count; i++)
   180     if (set->fd_array[i] == fd)
   181       return 1;
   182 
   183   return 0;
   184 }
   185 
   186 #  define GNULIB_defined_rpl_fd_isset 1
   187 # endif
   188 
   189 # undef FD_ISSET
   190 # define FD_ISSET(fd, set) rpl_fd_isset(fd, set)
   191 
   192 #endif
   193 
   194 /* Hide some function declarations from <winsock2.h>.  */
   195 
   196 #if @HAVE_WINSOCK2_H@
   197 # if !defined _@GUARD_PREFIX@_UNISTD_H
   198 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
   199 #   undef close
   200 #   define close close_used_without_including_unistd_h
   201 #  elif !defined __clang__
   202     _GL_WARN_ON_USE (close,
   203                      "close() used without including <unistd.h>");
   204 #  endif
   205 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
   206 #   undef gethostname
   207 #   define gethostname gethostname_used_without_including_unistd_h
   208 #  elif !defined __clang__
   209     _GL_WARN_ON_USE (gethostname,
   210                      "gethostname() used without including <unistd.h>");
   211 #  endif
   212 # endif
   213 # if !defined _@GUARD_PREFIX@_SYS_SOCKET_H
   214 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
   215 #   undef socket
   216 #   define socket              socket_used_without_including_sys_socket_h
   217 #   undef connect
   218 #   define connect             connect_used_without_including_sys_socket_h
   219 #   undef accept
   220 #   define accept              accept_used_without_including_sys_socket_h
   221 #   undef bind
   222 #   define bind                bind_used_without_including_sys_socket_h
   223 #   undef getpeername
   224 #   define getpeername         getpeername_used_without_including_sys_socket_h
   225 #   undef getsockname
   226 #   define getsockname         getsockname_used_without_including_sys_socket_h
   227 #   undef getsockopt
   228 #   define getsockopt          getsockopt_used_without_including_sys_socket_h
   229 #   undef listen
   230 #   define listen              listen_used_without_including_sys_socket_h
   231 #   undef recv
   232 #   define recv                recv_used_without_including_sys_socket_h
   233 #   undef send
   234 #   define send                send_used_without_including_sys_socket_h
   235 #   undef recvfrom
   236 #   define recvfrom            recvfrom_used_without_including_sys_socket_h
   237 #   undef sendto
   238 #   define sendto              sendto_used_without_including_sys_socket_h
   239 #   undef setsockopt
   240 #   define setsockopt          setsockopt_used_without_including_sys_socket_h
   241 #   undef shutdown
   242 #   define shutdown            shutdown_used_without_including_sys_socket_h
   243 #  elif !defined __clang__
   244     _GL_WARN_ON_USE (socket,
   245                      "socket() used without including <sys/socket.h>");
   246     _GL_WARN_ON_USE (connect,
   247                      "connect() used without including <sys/socket.h>");
   248     _GL_WARN_ON_USE (accept,
   249                      "accept() used without including <sys/socket.h>");
   250     _GL_WARN_ON_USE (bind,
   251                      "bind() used without including <sys/socket.h>");
   252     _GL_WARN_ON_USE (getpeername,
   253                      "getpeername() used without including <sys/socket.h>");
   254     _GL_WARN_ON_USE (getsockname,
   255                      "getsockname() used without including <sys/socket.h>");
   256     _GL_WARN_ON_USE (getsockopt,
   257                      "getsockopt() used without including <sys/socket.h>");
   258     _GL_WARN_ON_USE (listen,
   259                      "listen() used without including <sys/socket.h>");
   260     _GL_WARN_ON_USE (recv,
   261                      "recv() used without including <sys/socket.h>");
   262     _GL_WARN_ON_USE (send,
   263                      "send() used without including <sys/socket.h>");
   264     _GL_WARN_ON_USE (recvfrom,
   265                      "recvfrom() used without including <sys/socket.h>");
   266     _GL_WARN_ON_USE (sendto,
   267                      "sendto() used without including <sys/socket.h>");
   268     _GL_WARN_ON_USE (setsockopt,
   269                      "setsockopt() used without including <sys/socket.h>");
   270     _GL_WARN_ON_USE (shutdown,
   271                      "shutdown() used without including <sys/socket.h>");
   272 #  endif
   273 # endif
   274 #endif
   275 
   276 
   277 #if @GNULIB_PSELECT@
   278 # if @REPLACE_PSELECT@
   279 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
   280 #   undef pselect
   281 #   define pselect rpl_pselect
   282 #  endif
   283 _GL_FUNCDECL_RPL (pselect, int,
   284                   (int, fd_set *restrict, fd_set *restrict, fd_set *restrict,
   285                    struct timespec const *restrict, const sigset_t *restrict));
   286 _GL_CXXALIAS_RPL (pselect, int,
   287                   (int, fd_set *restrict, fd_set *restrict, fd_set *restrict,
   288                    struct timespec const *restrict, const sigset_t *restrict));
   289 # else
   290 #  if !@HAVE_PSELECT@
   291 _GL_FUNCDECL_SYS (pselect, int,
   292                   (int, fd_set *restrict, fd_set *restrict, fd_set *restrict,
   293                    struct timespec const *restrict, const sigset_t *restrict));
   294 #  endif
   295 /* Need to cast, because on AIX 7, the second, third, fourth argument may be
   296                         void *restrict,   void *restrict,   void *restrict.  */
   297 _GL_CXXALIAS_SYS_CAST (pselect, int,
   298                        (int,
   299                         fd_set *restrict, fd_set *restrict, fd_set *restrict,
   300                         struct timespec const *restrict,
   301                         const sigset_t *restrict));
   302 # endif
   303 # if __GLIBC__ >= 2
   304 _GL_CXXALIASWARN (pselect);
   305 # endif
   306 #elif defined GNULIB_POSIXCHECK
   307 # undef pselect
   308 # if HAVE_RAW_DECL_PSELECT
   309 _GL_WARN_ON_USE (pselect, "pselect is not portable - "
   310                  "use gnulib module pselect for portability");
   311 # endif
   312 #endif
   313 
   314 #if @GNULIB_SELECT@
   315 # if @REPLACE_SELECT@
   316 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
   317 #   undef select
   318 #   define select rpl_select
   319 #  endif
   320 _GL_FUNCDECL_RPL (select, int,
   321                   (int, fd_set *restrict, fd_set *restrict, fd_set *restrict,
   322                    struct timeval *restrict));
   323 _GL_CXXALIAS_RPL (select, int,
   324                   (int, fd_set *restrict, fd_set *restrict, fd_set *restrict,
   325                    timeval *restrict));
   326 # else
   327 _GL_CXXALIAS_SYS (select, int,
   328                   (int, fd_set *restrict, fd_set *restrict, fd_set *restrict,
   329                    timeval *restrict));
   330 # endif
   331 _GL_CXXALIASWARN (select);
   332 #elif @HAVE_WINSOCK2_H@
   333 # undef select
   334 # define select select_used_without_requesting_gnulib_module_select
   335 #elif defined GNULIB_POSIXCHECK
   336 # undef select
   337 # if HAVE_RAW_DECL_SELECT
   338 _GL_WARN_ON_USE (select, "select is not always POSIX compliant - "
   339                  "use gnulib module select for portability");
   340 # endif
   341 #endif
   342 
   343 
   344 #endif /* _@GUARD_PREFIX@_SYS_SELECT_H */
   345 #endif /* _@GUARD_PREFIX@_SYS_SELECT_H */
   346 #endif /* OSF/1 */

/* [<][>][^][v][top][bottom][index][help] */