xref: /freebsd/sys/contrib/libsodium/m4/ax_check_catchable_abrt.m4 (revision dc318a4ffabcbfa23bb56a33403aad36e6de30af)
1# SYNOPSIS
2#
3#   AX_CHECK_CATCHABLE_ABRT
4#
5# DESCRIPTION
6#
7#  Check whether SIGABRT can be caught using signal handlers.
8
9#serial 1
10
11AC_DEFUN([AX_CHECK_CATCHABLE_ABRT], [dnl
12    AC_PREREQ(2.64)
13    AS_VAR_PUSHDEF([CACHEVAR], [ax_cv_check_[]_AC_LANG_ABBREV[]CATCHABLE_ABRT])dnl
14    AC_CACHE_CHECK([whether SIGABRT can be caught when using the _AC_LANG compiler], CACHEVAR, [
15        AC_RUN_IFELSE([
16            AC_LANG_PROGRAM([[
17#include <signal.h>
18#include <stdlib.h>
19
20#ifndef SIGABRT
21# error SIGABRT is not defined
22#endif
23
24static void sigabrt_handler_3(int _)
25{
26    exit(0);
27}
28
29static void sigabrt_handler_2(int _)
30{
31    signal(SIGABRT, sigabrt_handler_3);
32    abort();
33    exit(1);
34}
35
36static void sigabrt_handler_1(int _)
37{
38    signal(SIGABRT, sigabrt_handler_2);
39    abort();
40    exit(1);
41}
42            ]], [[
43signal(SIGABRT, sigabrt_handler_1);
44abort();
45exit(1);
46            ]])],
47            [AS_VAR_SET(CACHEVAR, [yes])],
48            [AS_VAR_SET(CACHEVAR, [no])],
49            [AS_VAR_SET(CACHEVAR, [unknown])]
50        )
51    ])
52    AS_VAR_IF(CACHEVAR, yes,
53        [AC_DEFINE([HAVE_CATCHABLE_ABRT], [1], [Define if SIGABRT can be caught using signal handlers])],
54        [AC_MSG_WARN([On this platform, SIGABRT cannot be caught using signal handlers.])]
55    )
56    AS_VAR_POPDEF([CACHEVAR])dnl
57])
58