1 dnl Autoconf configuration for libsigsegv.
2 dnl Process this file with autoconf to produce a configure script.
4 dnl Copyright (C) 2002-2009 Bruno Haible <bruno@clisp.org>
6 dnl This program is free software; you can redistribute it and/or modify
7 dnl it under the terms of the GNU General Public License as published by
8 dnl the Free Software Foundation; either version 2, or (at your option)
11 dnl This program is distributed in the hope that it will be useful,
12 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
13 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 dnl GNU General Public License for more details.
16 dnl You should have received a copy of the GNU General Public License
17 dnl along with this program; if not, write to the Free Software Foundation,
18 dnl Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 AC_CONFIG_SRCDIR([src/sigsegv.h.in])
23 AC_CONFIG_AUX_DIR([build-aux])
27 { echo; echo "${term_bold}Build Tools:${term_norm}"; } >& AS_MESSAGE_FD
29 AM_INIT_AUTOMAKE(libsigsegv, 2.7)
30 AM_CONFIG_HEADER(config.h)
32 dnl Override automake's tar command used for creating distributions.
33 am__tar='${AMTAR} chf - --owner=root --group=root "$$tardir"'
39 AC_MSG_CHECKING([host platform])
41 changequote(,)dnl Autoconf 2.52 brokenness
44 kernelversion=`uname -r | sed -e 's/^\([0-9.]*\).*/\1/'`
45 sv_cv_host=`echo $sv_cv_host | sed -e "s/linux/linux$kernelversion/"`
48 changequote([,])dnl Autoconf 2.52 brokenness
49 cat > conftest.c << EOF
51 #ifdef __GNU_LIBRARY__
52 Version __GLIBC__ . __GLIBC_MINOR__
55 glibcversion=`$CPP $CPPFLAGS conftest.c 2>/dev/null | grep Version | sed -e 's/Version//' -e 's/ //g'`
56 if test -n "$glibcversion"; then
57 sv_cv_host="$sv_cv_host-glibc$glibcversion"
59 AC_MSG_RESULT([$sv_cv_host])
60 PLATFORM="$sv_cv_host"
65 LT_INIT([disable-shared])
67 # For testing cross-compilation behaviour.
70 { echo; echo "${term_bold}Optional Platform Environment:${term_norm}"; } >& AS_MESSAGE_FD
72 dnl Headers to be included with <signal.h>. On MacOS X (Darwin) one also
73 dnl needs <sys/signal.h>.
74 AC_CHECK_HEADERS([sys/signal.h])
76 dnl List of signals that are sent when an invalid virtual memory address
77 dnl is accessed, or when the stack overflows.
79 sunos4* | freebsd* | dragonfly* | openbsd* | netbsd* | kfreebsd* | knetbsd*)
80 CFG_SIGNALS=signals-bsd.h ;;
82 CFG_SIGNALS=signals-hpux.h ;;
84 CFG_SIGNALS=signals-macos.h ;;
86 CFG_SIGNALS=signals-hurd.h ;;
88 CFG_SIGNALS=signals.h ;;
90 AC_DEFINE_UNQUOTED([CFG_SIGNALS], ["$CFG_SIGNALS"],
91 [The name of the include file describing the fault signals.])
93 # How to determine the memory page size.
96 # How to allocate fresh memory using mmap.
97 # (We need mmap, because mprotect() doesn't work on malloc()ed memory on
101 # How to write a SIGSEGV handler with access to the fault address.
103 # On MacOS X 10.2 or newer, we don't need these tests, because we'll end up
104 # using handler-macos.c anyway. If we were to perform the tests, 5 Crash Report
105 # dialog windows would pop up.
107 macos* | darwin[[6-9]]* | darwin[[1-9]][[0-9]]*) ;;
110 dnl FIXME: Put in some more known values into the third argument.
111 SV_TRY_FAULT([POSIX], sv_cv_fault_posix,
112 [*-*-solaris2.[7-9] | i?86-*-linux2.[4-9]* | i?86-*-freebsd[4-9]* | i?86-*-mirbsd1[0-9] | alpha*-dec-osf[4-9]* | *-*-hpux11* | mips-sgi-irix6*],
114 [int sig, siginfo_t *sip, void *ucp],
116 [action.sa_sigaction = &sigsegv_handler;
117 action.sa_flags = SA_SIGINFO;])
119 SV_TRY_FAULT([Linux/i386], sv_cv_fault_linux_i386, [i?86-*-linux2.[2-9]*],
120 [#include <asm/sigcontext.h>],
121 [int sig, struct sigcontext sc],
124 SV_TRY_FAULT([old Linux/i386], sv_cv_fault_linux_i386_old,
125 [i?86-*-linux2.[2-9]*],
127 [int sig, unsigned int more],
128 [((unsigned long *) &more) [21]])
130 dnl FIXME: Put in some more known values into the third argument.
131 SV_TRY_FAULT([Linux/m68k], sv_cv_fault_linux_m68k, [],
132 [#include <asm/sigcontext.h>
133 #include "$srcdir/src/fault-linux-m68k-old.c"],
134 [int sig, int code, struct sigcontext *scp],
135 [get_fault_addr (scp)])
137 dnl FIXME: Put in some more known values into the third argument.
138 SV_TRY_FAULT([Linux/PowerPC], sv_cv_fault_linux_powerpc, [],
139 [#include <asm/sigcontext.h>],
140 [int sig, struct sigcontext *scp],
143 dnl FIXME: Put in some more known values into the third argument.
144 SV_TRY_FAULT([Linux/HPPA], sv_cv_fault_linux_hppa, [],
146 [int sig, siginfo_t *sip, void *ucp],
148 [action.sa_sigaction = &sigsegv_handler;
149 action.sa_flags = SA_SIGINFO;])
151 dnl FIXME: Put in some more known values into the third argument.
152 SV_TRY_FAULT([BSD], sv_cv_fault_bsd, [i?86-*-freebsd[4-9]*],
154 [int sig, int code, struct sigcontext *scp, void *addr],
157 dnl FIXME: Put in some more known values into the third argument.
158 SV_TRY_FAULT([IRIX], sv_cv_fault_irix, [mips-sgi-irix6*],
160 [int sig, int code, struct sigcontext *scp],
161 [(unsigned long) scp->sc_badvaddr])
163 dnl FIXME: Put in some more known values into the third argument.
164 SV_TRY_FAULT([HP-UX HPPA], sv_cv_fault_hpux_hppa, [hppa*-*-hpux11*],
166 #define USE_64BIT_REGS(mc) \
167 (((mc).ss_flags & SS_WIDEREGS) && ((mc).ss_flags & SS_NARROWISINVALID))
168 #define GET_CR21(mc) \
169 (USE_64BIT_REGS(mc) ? (mc).ss_wide.ss_64.ss_cr21 : (mc).ss_narrow.ss_cr21)
171 [int sig, int code, struct sigcontext *scp],
172 [GET_CR21 (scp->sc_sl.sl_ss)])
174 dnl FIXME: Put in some more known values into the third argument.
175 SV_TRY_FAULT([OSF/1 Alpha], sv_cv_fault_osf_alpha,
176 [alpha*-*-osf[4-9]* | alpha*-*-linux2.[4-9]*],
178 [int sig, int code, struct sigcontext *scp],
179 [scp->sc_traparg_a0])
181 dnl FIXME: Put in some more known values into the third argument.
182 SV_TRY_FAULT([NetBSD Alpha], sv_cv_fault_netbsd_alpha,
183 [alpha*-*-osf[4-9]* | alpha-*-*bsd*],
184 [#include "$srcdir/src/fault-netbsd-alpha.c"],
185 [int sig, int code, struct sigcontext *scp],
186 [get_fault_addr (scp)])
188 dnl FIXME: Put in some more known values into the third argument.
189 SV_TRY_FAULT([AIX], sv_cv_fault_aix, [*-*-aix[34]*],
191 [int sig, int code, struct sigcontext *scp],
192 [scp->sc_jmpbuf.jmp_context.o_vaddr])
194 SV_TRY_FAULT([MacOSX/Darwin7 PowerPC], sv_cv_fault_macosdarwin7_ppc,
195 [powerpc-*-darwin7*],
196 [#include "$srcdir/src/fault-macosdarwin7-powerpc.c"],
197 [int sig, siginfo_t *sip, ucontext_t *ucp],
198 [get_fault_addr (sip, ucp)],
199 [action.sa_sigaction = &sigsegv_handler;
200 action.sa_flags = SA_SIGINFO;])
202 if test "$sv_cv_fault_macosdarwin7_ppc" != yes; then
203 SV_TRY_FAULT([MacOSX/Darwin5 PowerPC], sv_cv_fault_macosdarwin5_ppc,
204 [powerpc-*-darwin5*],
205 [#include "$srcdir/src/fault-macosdarwin5-powerpc.c"],
206 [int sig, int code, struct sigcontext *scp],
207 [get_fault_addr (scp)])
210 dnl FIXME: Put in some more known values into the third argument.
211 SV_TRY_FAULT([Hurd], sv_cv_fault_hurd, [],
213 [int sig, int code, struct sigcontext *scp],
216 # End of MacOS X special casing.
220 dnl Now determine the fault handler include file.
221 dnl We prefer the platform specific include files to the generic fault-posix.h
222 dnl because the former often defines SIGSEGV_FAULT_STACKPOINTER.
223 dnl Also we put the BSD test second-to-last, because the test may produce
229 FAULT_CONTEXT_INCLUDE=
231 dnl First the cases where the OS provides the fault address.
233 if test -z "$CFG_FAULT" && test "$sv_cv_fault_aix" = yes; then
235 powerpc* | rs6000) CFG_FAULT=fault-aix3-powerpc.h ;;
236 *) CFG_FAULT=fault-aix3.h ;;
238 FAULT_CONTEXT='struct sigcontext'
240 if test -z "$CFG_FAULT" && test "$sv_cv_fault_irix" = yes; then
242 mips*) CFG_FAULT=fault-irix-mips.h ;;
243 *) CFG_FAULT=fault-irix.h ;;
245 FAULT_CONTEXT='struct sigcontext'
247 if test -z "$CFG_FAULT" && test "$sv_cv_fault_hpux_hppa" = yes; then
249 hppa* | parisc*) CFG_FAULT=fault-hpux-hppa.h ;;
250 *) CFG_FAULT=fault-hpux.h ;;
252 FAULT_CONTEXT='struct sigcontext'
254 if test -z "$CFG_FAULT" && test "$sv_cv_fault_osf_alpha" = yes; then
256 alpha*) CFG_FAULT=fault-osf-alpha.h ;;
257 *) CFG_FAULT=fault-osf.h ;;
259 FAULT_CONTEXT='struct sigcontext'
261 if test -z "$CFG_FAULT" && test "$sv_cv_fault_netbsd_alpha" = yes; then
263 alpha*) CFG_FAULT=fault-netbsd-alpha.h ;;
265 FAULT_CONTEXT='struct sigcontext'
267 if test -z "$CFG_FAULT" && test "$sv_cv_fault_hurd" = yes; then
269 netbsd*) # A false positive.
272 CFG_FAULT=fault-hurd.h
273 FAULT_CONTEXT='struct sigcontext'
277 if test -z "$CFG_FAULT" && test "$sv_cv_fault_bsd" = yes; then
279 freebsd* | dragonfly* | kfreebsd*)
282 CFG_FAULT=fault-freebsd-i386.h
283 FAULT_CONTEXT='struct sigcontext'
286 CFG_FAULT=fault-bsd.h
292 CFG_FAULT=fault-bsd.h
297 if test -z "$CFG_FAULT" && test "$sv_cv_fault_posix" = yes; then
301 i?86 | x86_64) CFG_FAULT=fault-openbsd-i386.h ;;
302 *) CFG_FAULT=fault-openbsd.h ;;
304 FAULT_CONTEXT='struct sigcontext'
309 CFG_FAULT=fault-openbsd-i386.h
310 FAULT_CONTEXT='struct sigcontext'
317 CFG_FAULT=fault-linux-ia64-old.h
318 FAULT_CONTEXT='struct sigcontext'
323 if test -z "$CFG_FAULT"; then
324 dnl <ucontext.h> was required by POSIX:2001, and many systems have it. But
325 dnl POSIX:2008 does not require it any more, and MirBSD does not have it.
326 AC_CHECK_HEADERS([ucontext.h])
327 if test $ac_cv_header_ucontext_h = yes; then
331 i?86 | x86_64) CFG_FAULT=fault-solaris-i386.h ;;
332 sparc*) CFG_FAULT=fault-solaris-sparc.h ;;
333 *) CFG_FAULT=fault-solaris.h ;;
338 powerpc* | rs6000) CFG_FAULT=fault-aix5-powerpc.h ;;
339 *) CFG_FAULT=fault-aix5.h ;;
343 CFG_FAULT=fault-netbsd.h
348 CFG_FAULT=fault-linux-alpha.h
350 arm* | strongarm* | xscale*)
351 CFG_FAULT=fault-linux-arm.h
354 CFG_FAULT=fault-linux-cris.h
357 CFG_FAULT=fault-linux-hppa.h
360 CFG_FAULT=fault-linux-i386.h
363 CFG_FAULT=fault-linux-ia64.h
366 CFG_FAULT=fault-linux-m68k.h
369 CFG_FAULT=fault-linux-mips.h
372 CFG_FAULT=fault-linux-powerpc.h
375 CFG_FAULT=fault-linux-s390.h
378 CFG_FAULT=fault-linux-sh.h
381 CFG_FAULT=fault-linux-sparc.h
384 CFG_FAULT=fault-posix-ucontext.h
389 CFG_FAULT=fault-posix-ucontext.h
392 FAULT_CONTEXT='ucontext_t'
393 FAULT_CONTEXT_INCLUDE='#include <ucontext.h>'
395 CFG_FAULT=fault-posix.h
400 if test -z "$CFG_FAULT" && test "$sv_cv_fault_linux_i386" = yes; then
402 i?86 | x86_64) CFG_FAULT=fault-linux-i386-old.h ;;
404 FAULT_CONTEXT='struct sigcontext'
406 if test -z "$CFG_FAULT" && test "$sv_cv_fault_linux_i386_old" = yes; then
408 i?86 | x86_64) CFG_FAULT=fault-linux-i386-oldold.h ;;
410 FAULT_CONTEXT='struct sigcontext'
412 if test -z "$CFG_FAULT" && test "$sv_cv_fault_linux_powerpc" = yes; then
414 powerpc* | rs6000) CFG_FAULT=fault-linux-powerpc-old.h ;;
416 FAULT_CONTEXT='struct sigcontext'
418 if test -z "$CFG_FAULT" && test "$sv_cv_fault_linux_hppa" = yes; then
420 hppa* | parisc*) CFG_FAULT=fault-linux-hppa-old.h ;;
423 if test -z "$CFG_FAULT"; then
425 macos* | darwin[[6-9]]* | darwin[[1-9]][[0-9]]*)
427 powerpc* | rs6000 | i?86 | x86_64)
428 CFG_MACHFAULT=machfault-macos.h
429 FAULT_CONTEXT_INCLUDE='#include <signal.h>
430 #include <mach/thread_status.h>
431 #if defined __ppc64__
432 #define sigsegv_thread_state_t ppc_thread_state64_t
433 #elif defined __ppc__
434 #define sigsegv_thread_state_t ppc_thread_state_t
436 #if defined __x86_64__
437 #define sigsegv_thread_state_t x86_thread_state64_t
438 #elif defined __i386__
439 #if defined x86_THREAD_STATE32
440 #define sigsegv_thread_state_t x86_thread_state32_t
442 #define sigsegv_thread_state_t i386_thread_state_t
445 FAULT_CONTEXT='sigsegv_thread_state_t'
448 if test -n "$CFG_MACHFAULT"; then
449 CFG_HANDLER=handler-macos.c
450 CFG_FAULT=fault-macos.h # nonexistent, just a dummy
456 dnl Next, the cases where there is a hairy CPU dependent way to get the
459 if test -z "$CFG_FAULT" && test "$sv_cv_fault_linux_m68k" = yes; then
462 CFG_FAULT=fault-linux-m68k-old.h
463 FAULT_CONTEXT='struct sigcontext'
467 if test -z "$CFG_FAULT" && test "$sv_cv_fault_macosdarwin7_ppc" = yes; then
470 CFG_FAULT=fault-macosdarwin7-powerpc.h
471 FAULT_CONTEXT='ucontext_t'
472 FAULT_CONTEXT_INCLUDE='#include <signal.h>
473 #include <ucontext.h>'
477 if test -z "$CFG_FAULT" && test "$sv_cv_fault_macosdarwin5_ppc" = yes; then
480 CFG_FAULT=fault-macosdarwin5-powerpc.h
481 FAULT_CONTEXT='struct sigcontext'
485 if test -z "$CFG_FAULT"; then
488 FAULT_CONTEXT='CONTEXT'
489 FAULT_CONTEXT_INCLUDE='#include <windows.h>'
490 CFG_FAULT=fault-win32.h # nonexistent, just a dummy
494 if test -n "$CFG_FAULT"; then
495 sv_cv_have_sigsegv_recovery=yes
497 sv_cv_have_sigsegv_recovery=no
499 dnl No way to get the fault address. But other information is available.
505 CFG_FAULT=fault-linux-alpha-old.h
506 FAULT_CONTEXT='struct sigcontext'
508 arm* | strongarm* | xscale*)
509 CFG_FAULT=fault-linux-arm-old.h
510 FAULT_CONTEXT='struct sigcontext'
513 CFG_FAULT=fault-linux-cris-old.h
514 FAULT_CONTEXT='struct sigcontext'
517 CFG_FAULT=fault-linux-mips-old.h
518 FAULT_CONTEXT='struct sigcontext'
521 CFG_FAULT=fault-linux-s390-old.h
522 FAULT_CONTEXT='struct sigcontext'
525 CFG_FAULT=fault-linux-sh-old.h
526 FAULT_CONTEXT='struct sigcontext'
529 CFG_FAULT=fault-linux-sparc-old.h
530 FAULT_CONTEXT='struct sigcontext'
533 CFG_FAULT=fault-linux-x86_64-old.h
534 FAULT_CONTEXT='struct sigcontext'
540 i?86 | x86_64) CFG_FAULT=fault-beos-i386.h ;;
541 *) CFG_FAULT=fault-beos.h ;;
543 FAULT_CONTEXT='struct vregs'
547 i?86 | x86_64) CFG_FAULT=fault-macos-i386.h ;;
549 FAULT_CONTEXT='struct sigcontext'
553 AC_MSG_CHECKING([for the fault handler specifics])
554 if test -n "$CFG_FAULT"; then
555 sv_cv_fault_include=$CFG_FAULT
557 if test -n "$CFG_MACHFAULT"; then
558 sv_cv_fault_include=$CFG_MACHFAULT
560 sv_cv_fault_include=none
563 AC_MSG_RESULT([$sv_cv_fault_include])
564 if test -z "$CFG_FAULT"; then
565 CFG_FAULT=fault-none.h
567 AC_DEFINE_UNQUOTED([CFG_FAULT], ["$CFG_FAULT"],
568 [The name of the include file describing the fault handler.])
569 if test -z "$CFG_MACHFAULT"; then
570 CFG_MACHFAULT=fault-none.h
572 AC_DEFINE_UNQUOTED([CFG_MACHFAULT], ["$CFG_MACHFAULT"],
573 [The name of the include file describing the Mach fault handler.])
574 AC_SUBST([FAULT_CONTEXT])
575 AC_SUBST([FAULT_CONTEXT_INCLUDE])
576 dnl AM_SUBST_NOTMAKE, because FAULT_CONTEXT_INCLUDE may have a multiline value.
577 AM_SUBST_NOTMAKE([FAULT_CONTEXT_INCLUDE])
579 AC_MSG_CHECKING([if the system supports catching SIGSEGV])
580 AC_MSG_RESULT([$sv_cv_have_sigsegv_recovery])
581 if test $sv_cv_have_sigsegv_recovery != no; then
582 HAVE_SIGSEGV_RECOVERY=1
584 HAVE_SIGSEGV_RECOVERY=0
586 AC_SUBST([HAVE_SIGSEGV_RECOVERY])
588 dnl The stackoverflow_context_t type depends on the CFG_FAULT include file.
593 dnl Determination of the stack's virtual memory area.
594 AC_CACHE_CHECK([for PIOCMAP in sys/procfs.h], [sv_cv_procfsvma], [
595 AC_TRY_LINK([#include <sys/procfs.h>],
596 [int x = PIOCNMAP + PIOCMAP; prmap_t y;],
597 [sv_cv_procfsvma=yes], [sv_cv_procfsvma=no])
599 AC_CHECK_FUNCS([mincore])
601 if test $sv_cv_procfsvma = yes; then
602 CFG_STACKVMA=stackvma-procfs.c
605 linux*) CFG_STACKVMA=stackvma-linux.c ;;
606 freebsd* | dragonfly*) CFG_STACKVMA=stackvma-freebsd.c ;;
607 beos*) CFG_STACKVMA=stackvma-beos.c ;;
608 macos* | darwin*) CFG_STACKVMA=stackvma-mach.c ;;
611 if test -z "$CFG_STACKVMA" && test $ac_cv_func_mincore = yes; then
612 CFG_STACKVMA=stackvma-mincore.c
614 if test -n "$CFG_STACKVMA"; then
615 AC_DEFINE([HAVE_STACKVMA], [1],
616 [Define if CFG_STACKVMA is set to a nontrivial source file.])
618 CFG_STACKVMA=stackvma-none.c
620 AC_DEFINE_UNQUOTED([CFG_STACKVMA], ["$CFG_STACKVMA"],
621 [The name of the file determining the stack virtual memory area.])
622 AC_SUBST([CFG_STACKVMA])
624 AC_CHECK_FUNCS([getrlimit setrlimit])
626 dnl Catching stack overflow requires an alternate signal stack.
627 dnl The old "install a guard page" trick would be unreliable, because
628 dnl we don't know where exactly to place the guard page.
631 # How to longjmp out of a signal handler, in such a way that the
632 # alternate signal stack remains functional.
634 # On MacOS X 10.2 or newer, we don't need these tests, because we'll end up
635 # using handler-macos.c anyway. If we were to perform the tests, 2 Crash Report
636 # dialog windows would pop up.
638 macos* | darwin[[6-9]]* | darwin[[1-9]][[0-9]]*) ;;
641 dnl FIXME: Put in some more known values into the third argument.
642 SV_TRY_LEAVE_HANDLER_LONGJMP([], sv_cv_leave_handler_longjmp,
643 [*-*-osf[4-9]* | *-*-hpux11* | *-*-linux2.[2-9]*],
646 dnl FIXME: Put in some more known values into the third argument.
647 SV_TRY_LEAVE_HANDLER_LONGJMP([ and sigaltstack],
648 sv_cv_leave_handler_longjmp_sigaltstack,
652 #define SS_ONSTACK SA_ONSTACK
656 if (sigaltstack (NULL, &ss) >= 0)
658 ss.ss_flags &= ~SS_ONSTACK;
659 sigaltstack (&ss, NULL);
663 dnl FIXME: Put in some more known values into the third argument.
664 SV_TRY_LEAVE_HANDLER_LONGJMP([ and setcontext],
665 sv_cv_leave_handler_longjmp_setcontext,
666 [*-*-irix* | *-*-solaris*],
667 [#include <ucontext.h>
669 #define SS_ONSTACK SA_ONSTACK
673 static ucontext_t uc;
675 if (getcontext (&uc) >= 0)
677 if (uc.uc_stack.ss_flags & SS_ONSTACK)
679 uc.uc_stack.ss_flags &= ~SS_ONSTACK;
685 # End of MacOS X special casing.
689 # How to siglongjmp out of a signal handler, in such a way that the
690 # alternate signal stack remains functional.
692 # On MacOS X 10.2 or newer, we don't need these tests, because we'll end up
693 # using handler-macos.c anyway. If we were to perform the tests, 2 Crash Report
694 # dialog windows would pop up.
696 macos* | darwin[[6-9]]* | darwin[[1-9]][[0-9]]*) ;;
699 dnl FIXME: Put in some more known values into the third argument.
700 SV_TRY_LEAVE_HANDLER_SIGLONGJMP([], sv_cv_leave_handler_siglongjmp,
701 [*-*-osf[4-9]* | *-*-hpux11* | *-*-linux2.[2-9]* | *-*-irix* | *-*-solaris*],
704 dnl FIXME: Put in some more known values into the third argument.
705 SV_TRY_LEAVE_HANDLER_SIGLONGJMP([ and sigaltstack],
706 sv_cv_leave_handler_siglongjmp_sigaltstack,
710 #define SS_ONSTACK SA_ONSTACK
714 if (sigaltstack (NULL, &ss) >= 0)
716 ss.ss_flags &= ~SS_ONSTACK;
717 sigaltstack (&ss, NULL);
721 dnl FIXME: Put in some more known values into the third argument.
722 SV_TRY_LEAVE_HANDLER_SIGLONGJMP([ and setcontext],
723 sv_cv_leave_handler_siglongjmp_setcontext,
725 [#include <ucontext.h>
727 #define SS_ONSTACK SA_ONSTACK
731 static ucontext_t uc;
733 if (getcontext(&uc) >= 0)
735 if (uc.uc_stack.ss_flags & SS_ONSTACK)
737 uc.uc_stack.ss_flags &= ~SS_ONSTACK;
743 # End of MacOS X special casing.
748 if test "$sv_cv_leave_handler_longjmp" != no; then
749 CFG_LEAVE=leave-nop.c
751 if test "$sv_cv_leave_handler_longjmp_sigaltstack" != no; then
752 CFG_LEAVE=leave-sigaltstack.c
754 if test "$sv_cv_leave_handler_longjmp_setcontext" != no; then
755 CFG_LEAVE=leave-setcontext.c
760 # On BeOS, the 6 tests fail because sigaltstack() doesn't exist.
761 # If one uses set_signal_stack() instead of sigaltstack(), the first
762 # test actually works. i.e. sv_cv_leave_handler_longjmp would be 'yes'.
763 beos*) CFG_LEAVE=leave-nop.c ;;
765 if test -z "$CFG_LEAVE"; then
766 CFG_LEAVE=leave-none.c
768 AC_DEFINE_UNQUOTED([CFG_LEAVE], ["$CFG_LEAVE"],
769 [The name of the file implementing sigsegv_reset_onstack_flag.])
770 AC_SUBST([CFG_LEAVE])
772 AC_CACHE_CHECK([if the system supports catching stack overflow],
773 [sv_cv_have_stack_overflow_recovery],
775 dnl On Mach, it requires a machfault-*.h (see src/handler-macos.c).
776 dnl On Unix, it requires either sigaltstack() or the BeOS set_signal_stack()
777 dnl function, and the ability to longjmp out of the signal handler, and on
778 dnl Unix it also requires a fault-*.h or a stackvma-*.c with certain
779 dnl properties (see src/handler-unix.c).
780 if test "$CFG_MACHFAULT" != fault-none.h; then
781 sv_cv_have_stack_overflow_recovery=yes
784 mingw* | cygwin*) sv_cv_have_stack_overflow_recovery=yes ;;
786 if test "$CFG_LEAVE" != 'leave-none.c'; then
787 if test "$sv_cv_sigaltstack" != no; then
788 sv_cv_have_stack_overflow_recovery=maybe
791 beos*) sv_cv_have_stack_overflow_recovery=maybe ;;
792 *) sv_cv_have_stack_overflow_recovery=no ;;
796 sv_cv_have_stack_overflow_recovery=no
801 if test $sv_cv_have_stack_overflow_recovery = maybe; then
802 if test -n "$CFG_FAULT"; then
803 AC_EGREP_CPP([xyzzy], [
804 #include "$srcdir/src/$CFG_FAULT"
805 #ifdef SIGSEGV_FAULT_HANDLER_ARGLIST
806 #ifdef SIGSEGV_FAULT_ADDRESS
810 ], [condA=true], [condA=false])
814 if test -n "$CFG_FAULT"; then
815 AC_EGREP_CPP([xyzzy], [
816 #include "$srcdir/src/$CFG_FAULT"
817 #ifdef SIGSEGV_FAULT_HANDLER_ARGLIST
818 #ifdef SIGSEGV_FAULT_STACKPOINTER
822 ], [condB=true], [condB=false])
826 if test "$CFG_STACKVMA" != "stackvma-none.c"; then
831 if { $condA && $condB; } || { $condA && $condC; } || { $condB && $condC; }; then
832 sv_cv_have_stack_overflow_recovery=yes
834 sv_cv_have_stack_overflow_recovery=no
838 if test $sv_cv_have_stack_overflow_recovery != no; then
839 HAVE_STACK_OVERFLOW_RECOVERY=1
841 HAVE_STACK_OVERFLOW_RECOVERY=0
843 AC_SUBST([HAVE_STACK_OVERFLOW_RECOVERY])
846 mingw* | cygwin*) CFG_HANDLER=handler-win32.c ;;
848 if test -z "$CFG_HANDLER"; then
849 if test $sv_cv_have_sigsegv_recovery = no \
850 && test $sv_cv_have_stack_overflow_recovery = no; then
851 CFG_HANDLER=handler-none.c
853 CFG_HANDLER=handler-unix.c
858 AC_DEFINE_UNQUOTED([CFG_HANDLER], ["$CFG_HANDLER"],
859 [The name of the file implementing the handler functionality.])
860 AC_SUBST([CFG_HANDLER])
862 { echo; echo "${term_bold}Build Parameters:${term_norm}"; } >& AS_MESSAGE_FD
864 dnl Relocatability is a nop for this package.
867 { echo; echo "${term_bold}Output Substitution:${term_norm}"; } >& AS_MESSAGE_FD
869 dnl AC_OUTPUT([Makefile])
871 src/Makefile src/sigsegv.h
874 { echo; echo "Now please type '${term_bold}make${term_norm}' to compile. Good luck."; echo; } >& AS_MESSAGE_FD