abort-debug: Don't assume that signal SIGABRT is unmasked and unhandled.
[gnulib.git] / m4 / sys_ioctl_h.m4
blob915dc02f63c7096917f862cd17ad14898d4eb6f5
1 # sys_ioctl_h.m4
2 # serial 15
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 dnl Written by Bruno Haible.
10 AC_DEFUN_ONCE([gl_SYS_IOCTL_H],
12   dnl Ensure to expand the default settings once only, before all statements
13   dnl that occur in other macros.
14   AC_REQUIRE([gl_SYS_IOCTL_H_DEFAULTS])
16   AC_CHECK_HEADERS_ONCE([sys/ioctl.h])
17   if test $ac_cv_header_sys_ioctl_h = yes; then
18     HAVE_SYS_IOCTL_H=1
19     dnl Test whether <sys/ioctl.h> declares ioctl(), or whether some other
20     dnl header file, such as <unistd.h> or <stropts.h>, is needed for that.
21     AC_CACHE_CHECK([whether <sys/ioctl.h> declares ioctl],
22       [gl_cv_decl_ioctl_in_sys_ioctl_h],
23       [dnl We cannot use AC_CHECK_DECL because it produces its own messages.
24        AC_COMPILE_IFELSE(
25          [AC_LANG_PROGRAM(
26             [[#include <sys/ioctl.h>]],
27             [[(void) ioctl;]])],
28          [gl_cv_decl_ioctl_in_sys_ioctl_h=yes],
29          [gl_cv_decl_ioctl_in_sys_ioctl_h=no])
30       ])
31   else
32     HAVE_SYS_IOCTL_H=0
33   fi
34   AC_SUBST([HAVE_SYS_IOCTL_H])
35   dnl <sys/ioctl.h> is always overridden, because of GNULIB_POSIXCHECK.
36   gl_CHECK_NEXT_HEADERS([sys/ioctl.h])
38   dnl Check for declarations of anything we want to poison if the
39   dnl corresponding gnulib module is not in use.
40   gl_WARN_ON_USE_PREPARE([[#include <sys/ioctl.h>
41 /* Some platforms declare ioctl in the wrong header.  */
42 #if !(defined __GLIBC__ && !defined __UCLIBC__)
43 # include <unistd.h>
44 #endif
45     ]], [ioctl])
48 # gl_SYS_IOCTL_MODULE_INDICATOR([modulename])
49 # sets the shell variable that indicates the presence of the given module
50 # to a C preprocessor expression that will evaluate to 1.
51 # This macro invocation must not occur in macros that are AC_REQUIREd.
52 AC_DEFUN([gl_SYS_IOCTL_MODULE_INDICATOR],
54   dnl Ensure to expand the default settings once only.
55   gl_SYS_IOCTL_H_REQUIRE_DEFAULTS
56   gl_MODULE_INDICATOR_SET_VARIABLE([$1])
57   dnl Define it also as a C macro, for the benefit of the unit tests.
58   gl_MODULE_INDICATOR_FOR_TESTS([$1])
61 # Initializes the default values for AC_SUBSTed shell variables.
62 # This macro must not be AC_REQUIREd.  It must only be invoked, and only
63 # outside of macros or in macros that are not AC_REQUIREd.
64 AC_DEFUN([gl_SYS_IOCTL_H_REQUIRE_DEFAULTS],
66   m4_defun(GL_MODULE_INDICATOR_PREFIX[_SYS_IOCTL_H_MODULE_INDICATOR_DEFAULTS], [
67     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_IOCTL])
68   ])
69   m4_require(GL_MODULE_INDICATOR_PREFIX[_SYS_IOCTL_H_MODULE_INDICATOR_DEFAULTS])
70   AC_REQUIRE([gl_SYS_IOCTL_H_DEFAULTS])
73 AC_DEFUN([gl_SYS_IOCTL_H_DEFAULTS],
75   dnl Assume proper GNU behavior unless another module says otherwise.
76   SYS_IOCTL_H_HAVE_WINSOCK2_H=0; AC_SUBST([SYS_IOCTL_H_HAVE_WINSOCK2_H])
77   SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS=0;
78                         AC_SUBST([SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS])
79   REPLACE_IOCTL=0;      AC_SUBST([REPLACE_IOCTL])