Blame m4/sys_select_h.m4

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