Blame m4/sys_select_h.m4

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