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