Blame m4/ioctl.m4

Packit 33f14e
# ioctl.m4 serial 4
Packit 33f14e
dnl Copyright (C) 2008-2017 Free Software Foundation, Inc.
Packit 33f14e
dnl This file is free software; the Free Software Foundation
Packit 33f14e
dnl gives unlimited permission to copy and/or distribute it,
Packit 33f14e
dnl with or without modifications, as long as this notice is preserved.
Packit 33f14e
Packit 33f14e
AC_DEFUN([gl_FUNC_IOCTL],
Packit 33f14e
[
Packit 33f14e
  AC_REQUIRE([gl_SYS_IOCTL_H_DEFAULTS])
Packit 33f14e
  AC_REQUIRE([gl_HEADER_SYS_SOCKET])
Packit 33f14e
  HAVE_IOCTL=1
Packit 33f14e
  if test "$ac_cv_header_winsock2_h" = yes; then
Packit 33f14e
    dnl Even if the 'socket' module is not used here, another part of the
Packit 33f14e
    dnl application may use it and pass file descriptors that refer to
Packit 33f14e
    dnl sockets to the ioctl() function. So enable the support for sockets.
Packit 33f14e
    HAVE_IOCTL=0
Packit 33f14e
  else
Packit 33f14e
    AC_CHECK_FUNCS([ioctl])
Packit 33f14e
    dnl On glibc systems, the second parameter is 'unsigned long int request',
Packit 33f14e
    dnl not 'int request'. We cannot simply cast the function pointer, but
Packit 33f14e
    dnl instead need a wrapper.
Packit 33f14e
    AC_CACHE_CHECK([for ioctl with POSIX signature],
Packit 33f14e
      [gl_cv_func_ioctl_posix_signature],
Packit 33f14e
      [AC_COMPILE_IFELSE(
Packit 33f14e
         [AC_LANG_PROGRAM(
Packit 33f14e
            [[#include <sys/ioctl.h>]],
Packit 33f14e
            [[extern
Packit 33f14e
              #ifdef __cplusplus
Packit 33f14e
              "C"
Packit 33f14e
              #endif
Packit 33f14e
              int ioctl (int, int, ...);
Packit 33f14e
            ]])
Packit 33f14e
         ],
Packit 33f14e
         [gl_cv_func_ioctl_posix_signature=yes],
Packit 33f14e
         [gl_cv_func_ioctl_posix_signature=no])
Packit 33f14e
      ])
Packit 33f14e
    if test $gl_cv_func_ioctl_posix_signature != yes; then
Packit 33f14e
      REPLACE_IOCTL=1
Packit 33f14e
    fi
Packit 33f14e
  fi
Packit 33f14e
])