Blame m4/sys_select_h.m4

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