Blame m4/ioctl.m4

Packit Service fdd496
# ioctl.m4 serial 4
Packit Service fdd496
dnl Copyright (C) 2008-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_FUNC_IOCTL],
Packit Service fdd496
[
Packit Service fdd496
  AC_REQUIRE([gl_SYS_IOCTL_H_DEFAULTS])
Packit Service fdd496
  AC_REQUIRE([gl_HEADER_SYS_SOCKET])
Packit Service fdd496
  HAVE_IOCTL=1
Packit Service fdd496
  if test "$ac_cv_header_winsock2_h" = yes; then
Packit Service fdd496
    dnl Even if the 'socket' module is not used here, another part of the
Packit Service fdd496
    dnl application may use it and pass file descriptors that refer to
Packit Service fdd496
    dnl sockets to the ioctl() function. So enable the support for sockets.
Packit Service fdd496
    HAVE_IOCTL=0
Packit Service fdd496
  else
Packit Service fdd496
    AC_CHECK_FUNCS([ioctl])
Packit Service fdd496
    dnl On glibc systems, the second parameter is 'unsigned long int request',
Packit Service fdd496
    dnl not 'int request'. We cannot simply cast the function pointer, but
Packit Service fdd496
    dnl instead need a wrapper.
Packit Service fdd496
    AC_CACHE_CHECK([for ioctl with POSIX signature],
Packit Service fdd496
      [gl_cv_func_ioctl_posix_signature],
Packit Service fdd496
      [AC_COMPILE_IFELSE(
Packit Service fdd496
         [AC_LANG_PROGRAM(
Packit Service fdd496
            [[#include <sys/ioctl.h>]],
Packit Service fdd496
            [[extern
Packit Service fdd496
              #ifdef __cplusplus
Packit Service fdd496
              "C"
Packit Service fdd496
              #endif
Packit Service fdd496
              int ioctl (int, int, ...);
Packit Service fdd496
            ]])
Packit Service fdd496
         ],
Packit Service fdd496
         [gl_cv_func_ioctl_posix_signature=yes],
Packit Service fdd496
         [gl_cv_func_ioctl_posix_signature=no])
Packit Service fdd496
      ])
Packit Service fdd496
    if test $gl_cv_func_ioctl_posix_signature != yes; then
Packit Service fdd496
      REPLACE_IOCTL=1
Packit Service fdd496
    fi
Packit Service fdd496
  fi
Packit Service fdd496
])