Blame m4/sys_select_h.m4

Packit Service 4684c1
# sys_select_h.m4 serial 20
Packit Service 4684c1
dnl Copyright (C) 2006-2020 Free Software Foundation, Inc.
Packit Service 4684c1
dnl This file is free software; the Free Software Foundation
Packit Service 4684c1
dnl gives unlimited permission to copy and/or distribute it,
Packit Service 4684c1
dnl with or without modifications, as long as this notice is preserved.
Packit Service 4684c1
Packit Service 4684c1
AC_DEFUN([gl_HEADER_SYS_SELECT],
Packit Service 4684c1
[
Packit Service 4684c1
  AC_REQUIRE([AC_C_RESTRICT])
Packit Service 4684c1
  AC_REQUIRE([gl_SYS_SELECT_H_DEFAULTS])
Packit Service 4684c1
  AC_CACHE_CHECK([whether <sys/select.h> is self-contained],
Packit Service 4684c1
    [gl_cv_header_sys_select_h_selfcontained],
Packit Service 4684c1
    [
Packit Service 4684c1
      dnl Test against two bugs:
Packit Service 4684c1
      dnl 1. On many platforms, <sys/select.h> assumes prior inclusion of
Packit Service 4684c1
      dnl    <sys/types.h>.
Packit Service 4684c1
      dnl 2. On OSF/1 4.0, <sys/select.h> provides only a forward declaration
Packit Service 4684c1
      dnl    of 'struct timeval', and no definition of this type.
Packit Service 4684c1
      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/select.h>]],
Packit Service 4684c1
                                         [[struct timeval b;]])],
Packit Service 4684c1
        [gl_cv_header_sys_select_h_selfcontained=yes],
Packit Service 4684c1
        [gl_cv_header_sys_select_h_selfcontained=no])
Packit Service 4684c1
      dnl Test against another bug:
Packit Service 4684c1
      dnl 3. On Solaris 10, <sys/select.h> provides an FD_ZERO implementation
Packit Service 4684c1
      dnl    that relies on memset(), but without including <string.h>.
Packit Service 4684c1
      if test $gl_cv_header_sys_select_h_selfcontained = yes; then
Packit Service 4684c1
        AC_COMPILE_IFELSE(
Packit Service 4684c1
          [AC_LANG_PROGRAM([[#include <sys/select.h>]],
Packit Service 4684c1
                           [[int memset; int bzero;]])
Packit Service 4684c1
          ],
Packit Service 4684c1
          [AC_LINK_IFELSE(
Packit Service 4684c1
             [AC_LANG_PROGRAM([[#include <sys/select.h>]], [[
Packit Service 4684c1
                  #undef memset
Packit Service 4684c1
                  #define memset nonexistent_memset
Packit Service 4684c1
                  extern
Packit Service 4684c1
                  #ifdef __cplusplus
Packit Service 4684c1
                  "C"
Packit Service 4684c1
                  #endif
Packit Service 4684c1
                  void *memset (void *, int, unsigned long);
Packit Service 4684c1
                  #undef bzero
Packit Service 4684c1
                  #define bzero nonexistent_bzero
Packit Service 4684c1
                  extern
Packit Service 4684c1
                  #ifdef __cplusplus
Packit Service 4684c1
                  "C"
Packit Service 4684c1
                  #endif
Packit Service 4684c1
                  void bzero (void *, unsigned long);
Packit Service 4684c1
                  fd_set fds;
Packit Service 4684c1
                  FD_ZERO (&fds);
Packit Service 4684c1
                ]])
Packit Service 4684c1
             ],
Packit Service 4684c1
             [],
Packit Service 4684c1
             [gl_cv_header_sys_select_h_selfcontained=no])
Packit Service 4684c1
          ])
Packit Service 4684c1
      fi
Packit Service 4684c1
    ])
Packit Service 4684c1
  dnl <sys/select.h> is always overridden, because of GNULIB_POSIXCHECK.
Packit Service 4684c1
  gl_CHECK_NEXT_HEADERS([sys/select.h])
Packit Service 4684c1
  if test $ac_cv_header_sys_select_h = yes; then
Packit Service 4684c1
    HAVE_SYS_SELECT_H=1
Packit Service 4684c1
  else
Packit Service 4684c1
    HAVE_SYS_SELECT_H=0
Packit Service 4684c1
  fi
Packit Service 4684c1
  AC_SUBST([HAVE_SYS_SELECT_H])
Packit Service 4684c1
  gl_PREREQ_SYS_H_WINSOCK2
Packit Service 4684c1
Packit Service 4684c1
  dnl Check for declarations of anything we want to poison if the
Packit Service 4684c1
  dnl corresponding gnulib module is not in use.
Packit Service 4684c1
  gl_WARN_ON_USE_PREPARE([[
Packit Service 4684c1
/* Some systems require prerequisite headers.  */
Packit Service 4684c1
#include <sys/types.h>
Packit Service 4684c1
#if !(defined __GLIBC__ && !defined __UCLIBC__) && HAVE_SYS_TIME_H
Packit Service 4684c1
# include <sys/time.h>
Packit Service 4684c1
#endif
Packit Service 4684c1
#include <sys/select.h>
Packit Service 4684c1
    ]], [pselect select])
Packit Service 4684c1
])
Packit Service 4684c1
Packit Service 4684c1
AC_DEFUN([gl_SYS_SELECT_MODULE_INDICATOR],
Packit Service 4684c1
[
Packit Service 4684c1
  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
Packit Service 4684c1
  AC_REQUIRE([gl_SYS_SELECT_H_DEFAULTS])
Packit Service 4684c1
  gl_MODULE_INDICATOR_SET_VARIABLE([$1])
Packit Service 4684c1
  dnl Define it also as a C macro, for the benefit of the unit tests.
Packit Service 4684c1
  gl_MODULE_INDICATOR_FOR_TESTS([$1])
Packit Service 4684c1
])
Packit Service 4684c1
Packit Service 4684c1
AC_DEFUN([gl_SYS_SELECT_H_DEFAULTS],
Packit Service 4684c1
[
Packit Service 4684c1
  GNULIB_PSELECT=0; AC_SUBST([GNULIB_PSELECT])
Packit Service 4684c1
  GNULIB_SELECT=0; AC_SUBST([GNULIB_SELECT])
Packit Service 4684c1
  dnl Assume proper GNU behavior unless another module says otherwise.
Packit Service 4684c1
  HAVE_PSELECT=1; AC_SUBST([HAVE_PSELECT])
Packit Service 4684c1
  REPLACE_PSELECT=0; AC_SUBST([REPLACE_PSELECT])
Packit Service 4684c1
  REPLACE_SELECT=0; AC_SUBST([REPLACE_SELECT])
Packit Service 4684c1
])