Debian Codegraph @

m4/ioctl.m4

raw
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.
7 dnl This file is offered as-is, without any warranty.
8
9 AC_DEFUN([gl_FUNC_IOCTL],
10 [
11 AC_REQUIRE([gl_SYS_IOCTL_H_DEFAULTS])
12 AC_REQUIRE([gl_SYS_SOCKET_H])
13 HAVE_IOCTL=1
14 if test "$ac_cv_header_winsock2_h" = yes; then
15 dnl Even if the 'socket' module is not used here, another part of the
16 dnl application may use it and pass file descriptors that refer to
17 dnl sockets to the ioctl() function. So enable the support for sockets.
18 HAVE_IOCTL=0
19 else
20 AC_CHECK_FUNCS([ioctl])
21 dnl On glibc systems, the second parameter is 'unsigned long int request',
22 dnl not 'int request'. We cannot simply cast the function pointer, but
23 dnl instead need a wrapper.
24 AC_CACHE_CHECK([for ioctl with POSIX signature],
25 [gl_cv_func_ioctl_posix_signature],
26 [AC_COMPILE_IFELSE(
27 [AC_LANG_PROGRAM(
28 [[#include <sys/ioctl.h>
29 /* On some platforms, ioctl() is declared in <unistd.h>. */
30 #include <unistd.h>
31 ]],
32 [[extern
33 #ifdef __cplusplus
34 "C"
35 #endif
36 int ioctl (int, int, ...);
37 ]])
38 ],
39 [gl_cv_func_ioctl_posix_signature=yes],
40 [gl_cv_func_ioctl_posix_signature=no])
41 ])
42 if test $gl_cv_func_ioctl_posix_signature != yes; then
43 REPLACE_IOCTL=1
44 fi
45 fi
46 ])