* ChangeLog: Fix misspelling
[gnulib.git] / m4 / ioctl.m4
blobf4592e1ed609178a0dd56e73d9d93c58e6ee543c
1 # ioctl.m4
2 # serial 6
3 dnl Copyright (C) 2008-2024 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
8 AC_DEFUN([gl_FUNC_IOCTL],
10   AC_REQUIRE([gl_SYS_IOCTL_H_DEFAULTS])
11   AC_REQUIRE([gl_SYS_SOCKET_H])
12   HAVE_IOCTL=1
13   if test "$ac_cv_header_winsock2_h" = yes; then
14     dnl Even if the 'socket' module is not used here, another part of the
15     dnl application may use it and pass file descriptors that refer to
16     dnl sockets to the ioctl() function. So enable the support for sockets.
17     HAVE_IOCTL=0
18   else
19     AC_CHECK_FUNCS([ioctl])
20     dnl On glibc systems, the second parameter is 'unsigned long int request',
21     dnl not 'int request'. We cannot simply cast the function pointer, but
22     dnl instead need a wrapper.
23     AC_CACHE_CHECK([for ioctl with POSIX signature],
24       [gl_cv_func_ioctl_posix_signature],
25       [AC_COMPILE_IFELSE(
26          [AC_LANG_PROGRAM(
27             [[#include <sys/ioctl.h>
28               /* On some platforms, ioctl() is declared in <unistd.h>.  */
29               #include <unistd.h>
30             ]],
31             [[extern
32               #ifdef __cplusplus
33               "C"
34               #endif
35               int ioctl (int, int, ...);
36             ]])
37          ],
38          [gl_cv_func_ioctl_posix_signature=yes],
39          [gl_cv_func_ioctl_posix_signature=no])
40       ])
41     if test $gl_cv_func_ioctl_posix_signature != yes; then
42       REPLACE_IOCTL=1
43     fi
44   fi