Blame gl/tests/sys_select.in.h

Packit aea12f
/* Substitute for <sys/select.h>.
Packit Service 991b93
   Copyright (C) 2007-2020 Free Software Foundation, Inc.
Packit aea12f
Packit aea12f
   This program is free software; you can redistribute it and/or modify
Packit aea12f
   it under the terms of the GNU General Public License as published by
Packit aea12f
   the Free Software Foundation; either version 3, or (at your option)
Packit aea12f
   any later version.
Packit aea12f
Packit aea12f
   This program is distributed in the hope that it will be useful,
Packit aea12f
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit aea12f
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit aea12f
   GNU General Public License for more details.
Packit aea12f
Packit aea12f
   You should have received a copy of the GNU General Public License
Packit aea12f
   along with this program; if not, see <https://www.gnu.org/licenses/>.  */
Packit aea12f
Packit aea12f
# if __GNUC__ >= 3
Packit aea12f
@PRAGMA_SYSTEM_HEADER@
Packit aea12f
# endif
Packit aea12f
@PRAGMA_COLUMNS@
Packit aea12f
Packit aea12f
/* On OSF/1 and Solaris 2.6, <sys/types.h> and <sys/time.h>
Packit aea12f
   both include <sys/select.h>.
Packit aea12f
   On Cygwin, <sys/time.h> includes <sys/select.h>.
Packit aea12f
   Simply delegate to the system's header in this case.  */
Packit aea12f
#if (@HAVE_SYS_SELECT_H@                                                \
Packit aea12f
     && !defined _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TYPES_H             \
Packit aea12f
     && ((defined __osf__ && defined _SYS_TYPES_H_                      \
Packit aea12f
          && defined _OSF_SOURCE)                                       \
Packit aea12f
         || (defined __sun && defined _SYS_TYPES_H                      \
Packit aea12f
             && (! (defined _XOPEN_SOURCE || defined _POSIX_C_SOURCE)   \
Packit aea12f
                 || defined __EXTENSIONS__))))
Packit aea12f
Packit aea12f
# define _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TYPES_H
Packit aea12f
# @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@
Packit aea12f
Packit aea12f
#elif (@HAVE_SYS_SELECT_H@                                              \
Packit aea12f
       && (defined _CYGWIN_SYS_TIME_H                                   \
Packit aea12f
           || (!defined _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TIME_H       \
Packit aea12f
               && ((defined __osf__ && defined _SYS_TIME_H_             \
Packit aea12f
                    && defined _OSF_SOURCE)                             \
Packit aea12f
                   || (defined __sun && defined _SYS_TIME_H             \
Packit aea12f
                       && (! (defined _XOPEN_SOURCE                     \
Packit aea12f
                              || defined _POSIX_C_SOURCE)               \
Packit aea12f
                           || defined __EXTENSIONS__))))))
Packit aea12f
Packit aea12f
# define _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TIME_H
Packit aea12f
# @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@
Packit aea12f
Packit aea12f
/* On IRIX 6.5, <sys/timespec.h> includes <sys/types.h>, which includes
Packit aea12f
   <sys/bsd_types.h>, which includes <sys/select.h>.  At this point we cannot
Packit aea12f
   include <signal.h>, because that includes <internal/signal_core.h>, which
Packit aea12f
   gives a syntax error because <sys/timespec.h> has not been completely
Packit aea12f
   processed.  Simply delegate to the system's header in this case.  */
Packit aea12f
#elif @HAVE_SYS_SELECT_H@ && defined __sgi && (defined _SYS_BSD_TYPES_H && !defined _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_BSD_TYPES_H)
Packit aea12f
Packit aea12f
# define _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_BSD_TYPES_H
Packit aea12f
# @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@
Packit aea12f
Packit aea12f
/* On OpenBSD 5.0, <pthread.h> includes <sys/types.h>, which includes
Packit aea12f
   <sys/select.h>.  At this point we cannot include <signal.h>, because that
Packit aea12f
   includes gnulib's pthread.h override, which gives a syntax error because
Packit aea12f
   /usr/include/pthread.h has not been completely processed.  Simply delegate
Packit aea12f
   to the system's header in this case.  */
Packit aea12f
#elif @HAVE_SYS_SELECT_H@ && defined __OpenBSD__ && (defined _PTHREAD_H_ && !defined PTHREAD_MUTEX_INITIALIZER)
Packit aea12f
Packit aea12f
# @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@
Packit aea12f
Packit aea12f
#else
Packit aea12f
Packit aea12f
#ifndef _@GUARD_PREFIX@_SYS_SELECT_H
Packit aea12f
Packit aea12f
/* On many platforms, <sys/select.h> assumes prior inclusion of
Packit aea12f
   <sys/types.h>.  Also, mingw defines sigset_t there, instead of
Packit aea12f
   in <signal.h> where it belongs.  */
Packit aea12f
#include <sys/types.h>
Packit aea12f
Packit aea12f
#if @HAVE_SYS_SELECT_H@
Packit aea12f
Packit aea12f
/* On OSF/1 4.0, <sys/select.h> provides only a forward declaration
Packit aea12f
   of 'struct timeval', and no definition of this type.
Packit aea12f
   Also, Mac OS X, AIX, HP-UX, IRIX, Solaris, Interix declare select()
Packit aea12f
   in <sys/time.h>.
Packit aea12f
   But avoid namespace pollution on glibc systems and "unknown type
Packit aea12f
   name" problems on Cygwin.  */
Packit aea12f
# if !(defined __GLIBC__ || defined __CYGWIN__)
Packit aea12f
#  include <sys/time.h>
Packit aea12f
# endif
Packit aea12f
Packit aea12f
/* On AIX 7 and Solaris 10, <sys/select.h> provides an FD_ZERO implementation
Packit aea12f
   that relies on memset(), but without including <string.h>.
Packit aea12f
   But in any case avoid namespace pollution on glibc systems.  */
Packit aea12f
# if (defined __OpenBSD__ || defined _AIX || defined __sun || defined __osf__ || defined __BEOS__) \
Packit aea12f
     && ! defined __GLIBC__
Packit aea12f
#  include <string.h>
Packit aea12f
# endif
Packit aea12f
Packit aea12f
/* The include_next requires a split double-inclusion guard.  */
Packit aea12f
# @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@
Packit aea12f
Packit aea12f
#endif
Packit aea12f
Packit aea12f
/* Get definition of 'sigset_t'.
Packit aea12f
   But avoid namespace pollution on glibc systems and "unknown type
Packit aea12f
   name" problems on Cygwin.
Packit aea12f
   Do this after the include_next (for the sake of OpenBSD 5.0) but before
Packit aea12f
   the split double-inclusion guard (for the sake of Solaris).  */
Packit aea12f
#if !((defined __GLIBC__ || defined __CYGWIN__) && !defined __UCLIBC__)
Packit aea12f
# include <signal.h>
Packit aea12f
#endif
Packit aea12f
Packit aea12f
#ifndef _@GUARD_PREFIX@_SYS_SELECT_H
Packit aea12f
#define _@GUARD_PREFIX@_SYS_SELECT_H
Packit aea12f
Packit aea12f
#if !@HAVE_SYS_SELECT_H@
Packit aea12f
/* A platform that lacks <sys/select.h>.  */
Packit aea12f
/* Get the 'struct timeval' and 'fd_set' types and the FD_* macros
Packit aea12f
   on most platforms.  */
Packit aea12f
# include <sys/time.h>
Packit aea12f
/* On HP-UX 11, <sys/time.h> provides an FD_ZERO implementation
Packit aea12f
   that relies on memset(), but without including <string.h>.  */
Packit aea12f
# if defined __hpux
Packit aea12f
#  include <string.h>
Packit aea12f
# endif
Packit aea12f
/* On native Windows platforms:
Packit aea12f
   Get the 'fd_set' type.
Packit aea12f
   Get the close() declaration before we override it.  */
Packit aea12f
# if @HAVE_WINSOCK2_H@
Packit aea12f
#  if !defined _GL_INCLUDING_WINSOCK2_H
Packit aea12f
#   define _GL_INCLUDING_WINSOCK2_H
Packit aea12f
#   include <winsock2.h>
Packit aea12f
#   undef _GL_INCLUDING_WINSOCK2_H
Packit aea12f
#  endif
Packit aea12f
#  include <io.h>
Packit aea12f
# endif
Packit aea12f
#endif
Packit aea12f
Packit aea12f
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
Packit aea12f
Packit aea12f
/* The definition of _GL_WARN_ON_USE is copied here.  */
Packit aea12f
Packit aea12f
Packit aea12f
/* Fix some definitions from <winsock2.h>.  */
Packit aea12f
Packit aea12f
#if @HAVE_WINSOCK2_H@
Packit aea12f
Packit aea12f
# if !GNULIB_defined_rpl_fd_isset
Packit aea12f
Packit aea12f
/* Re-define FD_ISSET to avoid a WSA call while we are not using
Packit aea12f
   network sockets.  */
Packit aea12f
static int
Packit aea12f
rpl_fd_isset (SOCKET fd, fd_set * set)
Packit aea12f
{
Packit aea12f
  u_int i;
Packit aea12f
  if (set == NULL)
Packit aea12f
    return 0;
Packit aea12f
Packit aea12f
  for (i = 0; i < set->fd_count; i++)
Packit aea12f
    if (set->fd_array[i] == fd)
Packit aea12f
      return 1;
Packit aea12f
Packit aea12f
  return 0;
Packit aea12f
}
Packit aea12f
Packit aea12f
#  define GNULIB_defined_rpl_fd_isset 1
Packit aea12f
# endif
Packit aea12f
Packit aea12f
# undef FD_ISSET
Packit aea12f
# define FD_ISSET(fd, set) rpl_fd_isset(fd, set)
Packit aea12f
Packit aea12f
#endif
Packit aea12f
Packit aea12f
/* Hide some function declarations from <winsock2.h>.  */
Packit aea12f
Packit aea12f
#if @HAVE_WINSOCK2_H@
Packit aea12f
# if !defined _@GUARD_PREFIX@_UNISTD_H
Packit aea12f
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit aea12f
#   undef close
Packit aea12f
#   define close close_used_without_including_unistd_h
Packit aea12f
#  else
Packit aea12f
    _GL_WARN_ON_USE (close,
Packit aea12f
                     "close() used without including <unistd.h>");
Packit aea12f
#  endif
Packit aea12f
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit aea12f
#   undef gethostname
Packit aea12f
#   define gethostname gethostname_used_without_including_unistd_h
Packit aea12f
#  else
Packit aea12f
    _GL_WARN_ON_USE (gethostname,
Packit aea12f
                     "gethostname() used without including <unistd.h>");
Packit aea12f
#  endif
Packit aea12f
# endif
Packit aea12f
# if !defined _@GUARD_PREFIX@_SYS_SOCKET_H
Packit aea12f
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit aea12f
#   undef socket
Packit aea12f
#   define socket              socket_used_without_including_sys_socket_h
Packit aea12f
#   undef connect
Packit aea12f
#   define connect             connect_used_without_including_sys_socket_h
Packit aea12f
#   undef accept
Packit aea12f
#   define accept              accept_used_without_including_sys_socket_h
Packit aea12f
#   undef bind
Packit aea12f
#   define bind                bind_used_without_including_sys_socket_h
Packit aea12f
#   undef getpeername
Packit aea12f
#   define getpeername         getpeername_used_without_including_sys_socket_h
Packit aea12f
#   undef getsockname
Packit aea12f
#   define getsockname         getsockname_used_without_including_sys_socket_h
Packit aea12f
#   undef getsockopt
Packit aea12f
#   define getsockopt          getsockopt_used_without_including_sys_socket_h
Packit aea12f
#   undef listen
Packit aea12f
#   define listen              listen_used_without_including_sys_socket_h
Packit aea12f
#   undef recv
Packit aea12f
#   define recv                recv_used_without_including_sys_socket_h
Packit aea12f
#   undef send
Packit aea12f
#   define send                send_used_without_including_sys_socket_h
Packit aea12f
#   undef recvfrom
Packit aea12f
#   define recvfrom            recvfrom_used_without_including_sys_socket_h
Packit aea12f
#   undef sendto
Packit aea12f
#   define sendto              sendto_used_without_including_sys_socket_h
Packit aea12f
#   undef setsockopt
Packit aea12f
#   define setsockopt          setsockopt_used_without_including_sys_socket_h
Packit aea12f
#   undef shutdown
Packit aea12f
#   define shutdown            shutdown_used_without_including_sys_socket_h
Packit aea12f
#  else
Packit aea12f
    _GL_WARN_ON_USE (socket,
Packit aea12f
                     "socket() used without including <sys/socket.h>");
Packit aea12f
    _GL_WARN_ON_USE (connect,
Packit aea12f
                     "connect() used without including <sys/socket.h>");
Packit aea12f
    _GL_WARN_ON_USE (accept,
Packit aea12f
                     "accept() used without including <sys/socket.h>");
Packit aea12f
    _GL_WARN_ON_USE (bind,
Packit aea12f
                     "bind() used without including <sys/socket.h>");
Packit aea12f
    _GL_WARN_ON_USE (getpeername,
Packit aea12f
                     "getpeername() used without including <sys/socket.h>");
Packit aea12f
    _GL_WARN_ON_USE (getsockname,
Packit aea12f
                     "getsockname() used without including <sys/socket.h>");
Packit aea12f
    _GL_WARN_ON_USE (getsockopt,
Packit aea12f
                     "getsockopt() used without including <sys/socket.h>");
Packit aea12f
    _GL_WARN_ON_USE (listen,
Packit aea12f
                     "listen() used without including <sys/socket.h>");
Packit aea12f
    _GL_WARN_ON_USE (recv,
Packit aea12f
                     "recv() used without including <sys/socket.h>");
Packit aea12f
    _GL_WARN_ON_USE (send,
Packit aea12f
                     "send() used without including <sys/socket.h>");
Packit aea12f
    _GL_WARN_ON_USE (recvfrom,
Packit aea12f
                     "recvfrom() used without including <sys/socket.h>");
Packit aea12f
    _GL_WARN_ON_USE (sendto,
Packit aea12f
                     "sendto() used without including <sys/socket.h>");
Packit aea12f
    _GL_WARN_ON_USE (setsockopt,
Packit aea12f
                     "setsockopt() used without including <sys/socket.h>");
Packit aea12f
    _GL_WARN_ON_USE (shutdown,
Packit aea12f
                     "shutdown() used without including <sys/socket.h>");
Packit aea12f
#  endif
Packit aea12f
# endif
Packit aea12f
#endif
Packit aea12f
Packit aea12f
Packit aea12f
#if @GNULIB_PSELECT@
Packit aea12f
# if @REPLACE_PSELECT@
Packit aea12f
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit aea12f
#   undef pselect
Packit aea12f
#   define pselect rpl_pselect
Packit aea12f
#  endif
Packit aea12f
_GL_FUNCDECL_RPL (pselect, int,
Packit aea12f
                  (int, fd_set *restrict, fd_set *restrict, fd_set *restrict,
Packit aea12f
                   struct timespec const *restrict, const sigset_t *restrict));
Packit aea12f
_GL_CXXALIAS_RPL (pselect, int,
Packit aea12f
                  (int, fd_set *restrict, fd_set *restrict, fd_set *restrict,
Packit aea12f
                   struct timespec const *restrict, const sigset_t *restrict));
Packit aea12f
# else
Packit aea12f
#  if !@HAVE_PSELECT@
Packit aea12f
_GL_FUNCDECL_SYS (pselect, int,
Packit aea12f
                  (int, fd_set *restrict, fd_set *restrict, fd_set *restrict,
Packit aea12f
                   struct timespec const *restrict, const sigset_t *restrict));
Packit aea12f
#  endif
Packit aea12f
_GL_CXXALIAS_SYS (pselect, int,
Packit aea12f
                  (int, fd_set *restrict, fd_set *restrict, fd_set *restrict,
Packit aea12f
                   struct timespec const *restrict, const sigset_t *restrict));
Packit aea12f
# endif
Packit aea12f
_GL_CXXALIASWARN (pselect);
Packit aea12f
#elif defined GNULIB_POSIXCHECK
Packit aea12f
# undef pselect
Packit aea12f
# if HAVE_RAW_DECL_PSELECT
Packit aea12f
_GL_WARN_ON_USE (pselect, "pselect is not portable - "
Packit aea12f
                 "use gnulib module pselect for portability");
Packit aea12f
# endif
Packit aea12f
#endif
Packit aea12f
Packit aea12f
#if @GNULIB_SELECT@
Packit aea12f
# if @REPLACE_SELECT@
Packit aea12f
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit aea12f
#   undef select
Packit aea12f
#   define select rpl_select
Packit aea12f
#  endif
Packit aea12f
_GL_FUNCDECL_RPL (select, int,
Packit aea12f
                  (int, fd_set *restrict, fd_set *restrict, fd_set *restrict,
Packit aea12f
                   struct timeval *restrict));
Packit aea12f
_GL_CXXALIAS_RPL (select, int,
Packit aea12f
                  (int, fd_set *restrict, fd_set *restrict, fd_set *restrict,
Packit Service 991b93
                   timeval *restrict));
Packit aea12f
# else
Packit aea12f
_GL_CXXALIAS_SYS (select, int,
Packit aea12f
                  (int, fd_set *restrict, fd_set *restrict, fd_set *restrict,
Packit Service 991b93
                   timeval *restrict));
Packit aea12f
# endif
Packit aea12f
_GL_CXXALIASWARN (select);
Packit aea12f
#elif @HAVE_WINSOCK2_H@
Packit aea12f
# undef select
Packit aea12f
# define select select_used_without_requesting_gnulib_module_select
Packit aea12f
#elif defined GNULIB_POSIXCHECK
Packit aea12f
# undef select
Packit aea12f
# if HAVE_RAW_DECL_SELECT
Packit aea12f
_GL_WARN_ON_USE (select, "select is not always POSIX compliant - "
Packit aea12f
                 "use gnulib module select for portability");
Packit aea12f
# endif
Packit aea12f
#endif
Packit aea12f
Packit aea12f
Packit aea12f
#endif /* _@GUARD_PREFIX@_SYS_SELECT_H */
Packit aea12f
#endif /* _@GUARD_PREFIX@_SYS_SELECT_H */
Packit aea12f
#endif /* OSF/1 */