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.8)
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"'
41 dnl ========================== Determine PLATFORM ==========================
42 dnl Requires AC_CANONICAL_HOST.
43 dnl PLATFORM is a modified config.guess triple that is supposed to contain
44 dnl the bits of information which influence the configuration or functioning
45 dnl of catching faults.
47 AC_MSG_CHECKING([host platform])
49 changequote(,)dnl Autoconf 2.52 brokenness
52 kernelversion=`uname -r | sed -e 's/^\([0-9.]*\).*/\1/'`
53 sv_cv_host=`echo $sv_cv_host | sed -e "s/linux/linux$kernelversion/"`
56 changequote([,])dnl Autoconf 2.52 brokenness
57 cat > conftest.c << EOF
59 #ifdef __GNU_LIBRARY__
60 Version __GLIBC__ . __GLIBC_MINOR__
63 glibcversion=`$CPP $CPPFLAGS conftest.c 2>/dev/null | grep Version | sed -e 's/Version//' -e 's/ //g'`
64 if test -n "$glibcversion"; then
65 sv_cv_host="$sv_cv_host-glibc$glibcversion"
67 AC_MSG_RESULT([$sv_cv_host])
68 PLATFORM="$sv_cv_host"
71 dnl ========================== Done with PLATFORM ==========================
76 LT_INIT([disable-shared])
78 # For testing cross-compilation behaviour.
81 { echo; echo "${term_bold}Optional Platform Environment:${term_norm}"; } >& AS_MESSAGE_FD
83 dnl Headers to be included with <signal.h>. On MacOS X (Darwin) one also
84 dnl needs <sys/signal.h>.
85 AC_CHECK_HEADERS([sys/signal.h])
88 dnl ========================== Determine CFG_SIGNALS ==========================
89 dnl Requires AC_CANONICAL_HOST.
91 dnl List of signals that are sent when an invalid virtual memory address
92 dnl is accessed, or when the stack overflows.
94 sunos4* | freebsd* | dragonfly* | openbsd* | netbsd* | kfreebsd* | knetbsd*)
95 CFG_SIGNALS=signals-bsd.h ;;
97 CFG_SIGNALS=signals-hpux.h ;;
99 CFG_SIGNALS=signals-macos.h ;;
101 CFG_SIGNALS=signals-hurd.h ;;
103 CFG_SIGNALS=signals.h ;;
105 AC_DEFINE_UNQUOTED([CFG_SIGNALS], ["$CFG_SIGNALS"],
106 [The name of the include file describing the fault signals.])
108 dnl ========================== Done with CFG_SIGNALS ==========================
111 # How to determine the memory page size.
114 # How to allocate fresh memory using mmap.
115 # (We need mmap, because mprotect() doesn't work on malloc()ed memory on
120 dnl ================== Determine CFG_HANDLER partially, ==================
121 dnl ================== CFG_FAULT, CFG_MACHFAULT, ==================
122 dnl ================== FAULT_CONTEXT, FAULT_CONTEXT_INCLUDE ==================
123 dnl Requires AC_CANONICAL_HOST, SV_MMAP_ANON.
125 # How to write a SIGSEGV handler with access to the fault address.
127 # On MacOS X 10.2 or newer, we don't need these tests, because we'll end up
128 # using handler-macos.c anyway. If we were to perform the tests, 5 Crash Report
129 # dialog windows would pop up.
131 macos* | darwin[[6-9]]* | darwin[[1-9]][[0-9]]*) ;;
134 dnl FIXME: Put in some more known values into the third argument.
135 SV_TRY_FAULT([POSIX], sv_cv_fault_posix,
136 [*-*-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*],
138 [int sig, siginfo_t *sip, void *ucp],
140 [action.sa_sigaction = &sigsegv_handler;
141 action.sa_flags = SA_SIGINFO;])
143 SV_TRY_FAULT([Linux/i386], sv_cv_fault_linux_i386, [i?86-*-linux2.[2-9]*],
144 [#include <asm/sigcontext.h>],
145 [int sig, struct sigcontext sc],
148 SV_TRY_FAULT([old Linux/i386], sv_cv_fault_linux_i386_old,
149 [i?86-*-linux2.[2-9]*],
151 [int sig, unsigned int more],
152 [((unsigned long *) &more) [21]])
154 dnl FIXME: Put in some more known values into the third argument.
155 SV_TRY_FAULT([Linux/m68k], sv_cv_fault_linux_m68k, [],
156 [#include <asm/sigcontext.h>
157 #include "$srcdir/src/fault-linux-m68k-old.c"],
158 [int sig, int code, struct sigcontext *scp],
159 [get_fault_addr (scp)])
161 dnl FIXME: Put in some more known values into the third argument.
162 SV_TRY_FAULT([Linux/PowerPC], sv_cv_fault_linux_powerpc, [],
163 [#include <asm/sigcontext.h>],
164 [int sig, struct sigcontext *scp],
167 dnl FIXME: Put in some more known values into the third argument.
168 SV_TRY_FAULT([Linux/HPPA], sv_cv_fault_linux_hppa, [],
170 [int sig, siginfo_t *sip, void *ucp],
172 [action.sa_sigaction = &sigsegv_handler;
173 action.sa_flags = SA_SIGINFO;])
175 dnl FIXME: Put in some more known values into the third argument.
176 SV_TRY_FAULT([BSD], sv_cv_fault_bsd, [i?86-*-freebsd[4-9]*],
178 [int sig, int code, struct sigcontext *scp, void *addr],
181 dnl FIXME: Put in some more known values into the third argument.
182 SV_TRY_FAULT([IRIX], sv_cv_fault_irix, [mips-sgi-irix6*],
184 [int sig, int code, struct sigcontext *scp],
185 [(unsigned long) scp->sc_badvaddr])
187 dnl FIXME: Put in some more known values into the third argument.
188 SV_TRY_FAULT([HP-UX HPPA], sv_cv_fault_hpux_hppa, [hppa*-*-hpux11*],
190 #define USE_64BIT_REGS(mc) \
191 (((mc).ss_flags & SS_WIDEREGS) && ((mc).ss_flags & SS_NARROWISINVALID))
192 #define GET_CR21(mc) \
193 (USE_64BIT_REGS(mc) ? (mc).ss_wide.ss_64.ss_cr21 : (mc).ss_narrow.ss_cr21)
195 [int sig, int code, struct sigcontext *scp],
196 [GET_CR21 (scp->sc_sl.sl_ss)])
198 dnl FIXME: Put in some more known values into the third argument.
199 SV_TRY_FAULT([OSF/1 Alpha], sv_cv_fault_osf_alpha,
200 [alpha*-*-osf[4-9]* | alpha*-*-linux2.[4-9]*],
202 [int sig, int code, struct sigcontext *scp],
203 [scp->sc_traparg_a0])
205 dnl FIXME: Put in some more known values into the third argument.
206 SV_TRY_FAULT([NetBSD Alpha], sv_cv_fault_netbsd_alpha,
207 [alpha*-*-osf[4-9]* | alpha-*-*bsd*],
208 [#include "$srcdir/src/fault-netbsd-alpha.c"],
209 [int sig, int code, struct sigcontext *scp],
210 [get_fault_addr (scp)])
212 dnl FIXME: Put in some more known values into the third argument.
213 SV_TRY_FAULT([AIX], sv_cv_fault_aix, [*-*-aix[34]*],
215 [int sig, int code, struct sigcontext *scp],
216 [scp->sc_jmpbuf.jmp_context.o_vaddr])
218 SV_TRY_FAULT([MacOSX/Darwin7 PowerPC], sv_cv_fault_macosdarwin7_ppc,
219 [powerpc-*-darwin7*],
220 [#include "$srcdir/src/fault-macosdarwin7-powerpc.c"],
221 [int sig, siginfo_t *sip, ucontext_t *ucp],
222 [get_fault_addr (sip, ucp)],
223 [action.sa_sigaction = &sigsegv_handler;
224 action.sa_flags = SA_SIGINFO;])
226 if test "$sv_cv_fault_macosdarwin7_ppc" != yes; then
227 SV_TRY_FAULT([MacOSX/Darwin5 PowerPC], sv_cv_fault_macosdarwin5_ppc,
228 [powerpc-*-darwin5*],
229 [#include "$srcdir/src/fault-macosdarwin5-powerpc.c"],
230 [int sig, int code, struct sigcontext *scp],
231 [get_fault_addr (scp)])
234 dnl FIXME: Put in some more known values into the third argument.
235 SV_TRY_FAULT([Hurd], sv_cv_fault_hurd, [],
237 [int sig, int code, struct sigcontext *scp],
240 # End of MacOS X special casing.
244 dnl Now determine the fault handler include file.
245 dnl We prefer the platform specific include files to the generic fault-posix.h
246 dnl because the former often defines SIGSEGV_FAULT_STACKPOINTER.
247 dnl Also we put the BSD test second-to-last, because the test may produce
253 FAULT_CONTEXT_INCLUDE=
255 dnl First the cases where the OS provides the fault address.
257 if test -z "$CFG_FAULT" && test "$sv_cv_fault_aix" = yes; then
259 powerpc* | rs6000) CFG_FAULT=fault-aix3-powerpc.h ;;
260 *) CFG_FAULT=fault-aix3.h ;;
262 FAULT_CONTEXT='struct sigcontext'
264 if test -z "$CFG_FAULT" && test "$sv_cv_fault_irix" = yes; then
266 mips*) CFG_FAULT=fault-irix-mips.h ;;
267 *) CFG_FAULT=fault-irix.h ;;
269 FAULT_CONTEXT='struct sigcontext'
271 if test -z "$CFG_FAULT" && test "$sv_cv_fault_hpux_hppa" = yes; then
273 hppa* | parisc*) CFG_FAULT=fault-hpux-hppa.h ;;
274 *) CFG_FAULT=fault-hpux.h ;;
276 FAULT_CONTEXT='struct sigcontext'
278 if test -z "$CFG_FAULT" && test "$sv_cv_fault_osf_alpha" = yes; then
280 alpha*) CFG_FAULT=fault-osf-alpha.h ;;
281 *) CFG_FAULT=fault-osf.h ;;
283 FAULT_CONTEXT='struct sigcontext'
285 if test -z "$CFG_FAULT" && test "$sv_cv_fault_netbsd_alpha" = yes; then
287 alpha*) CFG_FAULT=fault-netbsd-alpha.h ;;
289 FAULT_CONTEXT='struct sigcontext'
291 if test -z "$CFG_FAULT" && test "$sv_cv_fault_hurd" = yes; then
293 netbsd*) # A false positive.
296 CFG_FAULT=fault-hurd.h
297 FAULT_CONTEXT='struct sigcontext'
301 if test -z "$CFG_FAULT" && test "$sv_cv_fault_bsd" = yes; then
303 freebsd* | dragonfly* | kfreebsd*)
306 CFG_FAULT=fault-freebsd-i386.h
307 FAULT_CONTEXT='struct sigcontext'
310 CFG_FAULT=fault-bsd.h
316 CFG_FAULT=fault-bsd.h
321 if test -z "$CFG_FAULT" && test "$sv_cv_fault_posix" = yes; then
325 i?86 | x86_64) CFG_FAULT=fault-openbsd-i386.h ;;
326 *) CFG_FAULT=fault-openbsd.h ;;
328 FAULT_CONTEXT='struct sigcontext'
333 CFG_FAULT=fault-openbsd-i386.h
334 FAULT_CONTEXT='struct sigcontext'
341 CFG_FAULT=fault-linux-ia64-old.h
342 FAULT_CONTEXT='struct sigcontext'
347 if test -z "$CFG_FAULT"; then
348 dnl <ucontext.h> was required by POSIX:2001, and many systems have it. But
349 dnl POSIX:2008 does not require it any more, and MirBSD does not have it.
350 AC_CHECK_HEADERS([ucontext.h])
351 if test $ac_cv_header_ucontext_h = yes; then
355 i?86 | x86_64) CFG_FAULT=fault-solaris-i386.h ;;
356 sparc*) CFG_FAULT=fault-solaris-sparc.h ;;
357 *) CFG_FAULT=fault-solaris.h ;;
362 powerpc* | rs6000) CFG_FAULT=fault-aix5-powerpc.h ;;
363 *) CFG_FAULT=fault-aix5.h ;;
367 CFG_FAULT=fault-netbsd.h
372 CFG_FAULT=fault-linux-alpha.h
374 arm* | strongarm* | xscale*)
375 CFG_FAULT=fault-linux-arm.h
378 CFG_FAULT=fault-linux-cris.h
381 CFG_FAULT=fault-linux-hppa.h
384 CFG_FAULT=fault-linux-i386.h
387 CFG_FAULT=fault-linux-ia64.h
390 CFG_FAULT=fault-linux-m68k.h
393 CFG_FAULT=fault-linux-mips.h
396 CFG_FAULT=fault-linux-powerpc.h
399 CFG_FAULT=fault-linux-s390.h
402 CFG_FAULT=fault-linux-sh.h
405 CFG_FAULT=fault-linux-sparc.h
408 CFG_FAULT=fault-posix-ucontext.h
413 CFG_FAULT=fault-posix-ucontext.h
416 FAULT_CONTEXT='ucontext_t'
417 FAULT_CONTEXT_INCLUDE='#include <ucontext.h>'
419 CFG_FAULT=fault-posix.h
424 if test -z "$CFG_FAULT" && test "$sv_cv_fault_linux_i386" = yes; then
426 i?86 | x86_64) CFG_FAULT=fault-linux-i386-old.h ;;
428 FAULT_CONTEXT='struct sigcontext'
430 if test -z "$CFG_FAULT" && test "$sv_cv_fault_linux_i386_old" = yes; then
432 i?86 | x86_64) CFG_FAULT=fault-linux-i386-oldold.h ;;
434 FAULT_CONTEXT='struct sigcontext'
436 if test -z "$CFG_FAULT" && test "$sv_cv_fault_linux_powerpc" = yes; then
438 powerpc* | rs6000) CFG_FAULT=fault-linux-powerpc-old.h ;;
440 FAULT_CONTEXT='struct sigcontext'
442 if test -z "$CFG_FAULT" && test "$sv_cv_fault_linux_hppa" = yes; then
444 hppa* | parisc*) CFG_FAULT=fault-linux-hppa-old.h ;;
447 if test -z "$CFG_FAULT"; then
449 macos* | darwin[[6-9]]* | darwin[[1-9]][[0-9]]*)
451 powerpc* | rs6000 | i?86 | x86_64)
452 CFG_MACHFAULT=machfault-macos.h
453 FAULT_CONTEXT_INCLUDE='#include <signal.h>
454 #include <mach/thread_status.h>
455 #if defined __ppc64__
456 #define sigsegv_thread_state_t ppc_thread_state64_t
457 #elif defined __ppc__
458 #define sigsegv_thread_state_t ppc_thread_state_t
460 #if defined __x86_64__
461 #define sigsegv_thread_state_t x86_thread_state64_t
462 #elif defined __i386__
463 #if defined x86_THREAD_STATE32
464 #define sigsegv_thread_state_t x86_thread_state32_t
466 #define sigsegv_thread_state_t i386_thread_state_t
469 FAULT_CONTEXT='sigsegv_thread_state_t'
472 if test -n "$CFG_MACHFAULT"; then
473 CFG_HANDLER=handler-macos.c
474 CFG_FAULT=fault-macos.h # nonexistent, just a dummy
480 dnl Next, the cases where there is a hairy CPU dependent way to get the
483 if test -z "$CFG_FAULT" && test "$sv_cv_fault_linux_m68k" = yes; then
486 CFG_FAULT=fault-linux-m68k-old.h
487 FAULT_CONTEXT='struct sigcontext'
491 if test -z "$CFG_FAULT" && test "$sv_cv_fault_macosdarwin7_ppc" = yes; then
494 CFG_FAULT=fault-macosdarwin7-powerpc.h
495 FAULT_CONTEXT='ucontext_t'
496 FAULT_CONTEXT_INCLUDE='#include <signal.h>
497 #include <ucontext.h>'
501 if test -z "$CFG_FAULT" && test "$sv_cv_fault_macosdarwin5_ppc" = yes; then
504 CFG_FAULT=fault-macosdarwin5-powerpc.h
505 FAULT_CONTEXT='struct sigcontext'
511 FAULT_CONTEXT='CONTEXT'
512 FAULT_CONTEXT_INCLUDE='#include <windows.h>'
513 CFG_FAULT=fault-win32.h # nonexistent, just a dummy
516 FAULT_CONTEXT='CONTEXT'
517 FAULT_CONTEXT_INCLUDE='#include <windows.h>'
518 # Cygwin 1.7 uses fault-posix.h. Cygwin 1.5.x needs a hacky workaround.
519 if test -z "$CFG_FAULT"; then
520 CFG_FAULT=fault-cygwin-old.h
521 AC_DEFINE([OLD_CYGWIN_WORKAROUND], [1],
522 [Define to 1 on Cygwin versions older than 1.7.])
526 if test -n "$CFG_FAULT"; then
527 sv_cv_have_sigsegv_recovery=yes
529 sv_cv_have_sigsegv_recovery=no
531 dnl No way to get the fault address. But other information is available.
537 CFG_FAULT=fault-linux-alpha-old.h
538 FAULT_CONTEXT='struct sigcontext'
540 arm* | strongarm* | xscale*)
541 CFG_FAULT=fault-linux-arm-old.h
542 FAULT_CONTEXT='struct sigcontext'
545 CFG_FAULT=fault-linux-cris-old.h
546 FAULT_CONTEXT='struct sigcontext'
549 CFG_FAULT=fault-linux-mips-old.h
550 FAULT_CONTEXT='struct sigcontext'
553 CFG_FAULT=fault-linux-s390-old.h
554 FAULT_CONTEXT='struct sigcontext'
557 CFG_FAULT=fault-linux-sh-old.h
558 FAULT_CONTEXT='struct sigcontext'
561 CFG_FAULT=fault-linux-sparc-old.h
562 FAULT_CONTEXT='struct sigcontext'
565 CFG_FAULT=fault-linux-x86_64-old.h
566 FAULT_CONTEXT='struct sigcontext'
572 i?86 | x86_64) CFG_FAULT=fault-beos-i386.h ;;
573 *) CFG_FAULT=fault-beos.h ;;
575 FAULT_CONTEXT='struct vregs'
579 i?86 | x86_64) CFG_FAULT=fault-macos-i386.h ;;
581 FAULT_CONTEXT='struct sigcontext'
585 AC_MSG_CHECKING([for the fault handler specifics])
586 if test -n "$CFG_FAULT"; then
587 sv_cv_fault_include=$CFG_FAULT
589 if test -n "$CFG_MACHFAULT"; then
590 sv_cv_fault_include=$CFG_MACHFAULT
592 sv_cv_fault_include=none
595 AC_MSG_RESULT([$sv_cv_fault_include])
596 if test -z "$CFG_FAULT"; then
597 CFG_FAULT=fault-none.h
599 AC_DEFINE_UNQUOTED([CFG_FAULT], ["$CFG_FAULT"],
600 [The name of the include file describing the fault handler.])
601 if test -z "$CFG_MACHFAULT"; then
602 CFG_MACHFAULT=fault-none.h
604 AC_DEFINE_UNQUOTED([CFG_MACHFAULT], ["$CFG_MACHFAULT"],
605 [The name of the include file describing the Mach fault handler.])
606 AC_SUBST([FAULT_CONTEXT])
607 AC_SUBST([FAULT_CONTEXT_INCLUDE])
608 dnl AM_SUBST_NOTMAKE, because FAULT_CONTEXT_INCLUDE may have a multiline value.
609 AM_SUBST_NOTMAKE([FAULT_CONTEXT_INCLUDE])
611 dnl ================== Done with CFG_HANDLER partially, ==================
612 dnl ================== CFG_FAULT, CFG_MACHFAULT, ==================
613 dnl ================== FAULT_CONTEXT, FAULT_CONTEXT_INCLUDE ==================
616 dnl ===================== Determine HAVE_SIGSEGV_RECOVERY =====================
617 dnl Requires CFG_HANDLER / CFG_FAULT / etc.
619 AC_MSG_CHECKING([if the system supports catching SIGSEGV])
620 AC_MSG_RESULT([$sv_cv_have_sigsegv_recovery])
621 if test $sv_cv_have_sigsegv_recovery != no; then
622 HAVE_SIGSEGV_RECOVERY=1
624 HAVE_SIGSEGV_RECOVERY=0
626 AC_SUBST([HAVE_SIGSEGV_RECOVERY])
628 dnl ===================== Done with HAVE_SIGSEGV_RECOVERY =====================
631 dnl The stackoverflow_context_t type depends on the CFG_FAULT include file.
637 dnl ========================= Determine CFG_STACKVMA =========================
638 dnl Requires AC_CANONICAL_HOST.
640 dnl Determination of the stack's virtual memory area.
641 AC_CACHE_CHECK([for PIOCMAP in sys/procfs.h], [sv_cv_procfsvma], [
642 AC_TRY_LINK([#include <sys/procfs.h>],
643 [int x = PIOCNMAP + PIOCMAP; prmap_t y;],
644 [sv_cv_procfsvma=yes], [sv_cv_procfsvma=no])
646 AC_CHECK_FUNCS([mincore])
648 if test $sv_cv_procfsvma = yes; then
649 CFG_STACKVMA=stackvma-procfs.c
652 linux*) CFG_STACKVMA=stackvma-linux.c ;;
653 freebsd* | dragonfly*) CFG_STACKVMA=stackvma-freebsd.c ;;
654 beos*) CFG_STACKVMA=stackvma-beos.c ;;
655 macos* | darwin*) CFG_STACKVMA=stackvma-mach.c ;;
658 if test -z "$CFG_STACKVMA" && test $ac_cv_func_mincore = yes; then
659 CFG_STACKVMA=stackvma-mincore.c
661 if test -n "$CFG_STACKVMA"; then
662 AC_DEFINE([HAVE_STACKVMA], [1],
663 [Define if CFG_STACKVMA is set to a nontrivial source file.])
665 CFG_STACKVMA=stackvma-none.c
667 AC_DEFINE_UNQUOTED([CFG_STACKVMA], ["$CFG_STACKVMA"],
668 [The name of the file determining the stack virtual memory area.])
669 AC_SUBST([CFG_STACKVMA])
671 dnl ========================= Done with CFG_STACKVMA =========================
674 AC_CHECK_FUNCS([getrlimit setrlimit])
676 dnl Catching stack overflow requires an alternate signal stack.
677 dnl The old "install a guard page" trick would be unreliable, because
678 dnl we don't know where exactly to place the guard page.
682 dnl =========================== Determine CFG_LEAVE ===========================
683 dnl Requires AC_CANONICAL_HOST.
685 # How to longjmp out of a signal handler, in such a way that the
686 # alternate signal stack remains functional.
688 # On MacOS X 10.2 or newer, we don't need these tests, because we'll end up
689 # using handler-macos.c anyway. If we were to perform the tests, 2 Crash Report
690 # dialog windows would pop up.
692 macos* | darwin[[6-9]]* | darwin[[1-9]][[0-9]]*) ;;
695 dnl FIXME: Put in some more known values into the third argument.
696 SV_TRY_LEAVE_HANDLER_LONGJMP([], sv_cv_leave_handler_longjmp,
697 [*-*-osf[4-9]* | *-*-hpux11* | *-*-linux2.[2-9]*],
700 dnl FIXME: Put in some more known values into the third argument.
701 SV_TRY_LEAVE_HANDLER_LONGJMP([ and sigaltstack],
702 sv_cv_leave_handler_longjmp_sigaltstack,
706 #define SS_ONSTACK SA_ONSTACK
710 if (sigaltstack (NULL, &ss) >= 0)
712 ss.ss_flags &= ~SS_ONSTACK;
713 sigaltstack (&ss, NULL);
717 dnl FIXME: Put in some more known values into the third argument.
718 SV_TRY_LEAVE_HANDLER_LONGJMP([ and setcontext],
719 sv_cv_leave_handler_longjmp_setcontext,
720 [*-*-irix* | *-*-solaris*],
721 [#include <ucontext.h>
723 #define SS_ONSTACK SA_ONSTACK
727 static ucontext_t uc;
729 if (getcontext (&uc) >= 0)
731 if (uc.uc_stack.ss_flags & SS_ONSTACK)
733 uc.uc_stack.ss_flags &= ~SS_ONSTACK;
739 # End of MacOS X special casing.
743 # How to siglongjmp out of a signal handler, in such a way that the
744 # alternate signal stack remains functional.
746 # On MacOS X 10.2 or newer, we don't need these tests, because we'll end up
747 # using handler-macos.c anyway. If we were to perform the tests, 2 Crash Report
748 # dialog windows would pop up.
750 macos* | darwin[[6-9]]* | darwin[[1-9]][[0-9]]*) ;;
753 dnl FIXME: Put in some more known values into the third argument.
754 SV_TRY_LEAVE_HANDLER_SIGLONGJMP([], sv_cv_leave_handler_siglongjmp,
755 [*-*-osf[4-9]* | *-*-hpux11* | *-*-linux2.[2-9]* | *-*-irix* | *-*-solaris*],
758 dnl FIXME: Put in some more known values into the third argument.
759 SV_TRY_LEAVE_HANDLER_SIGLONGJMP([ and sigaltstack],
760 sv_cv_leave_handler_siglongjmp_sigaltstack,
764 #define SS_ONSTACK SA_ONSTACK
768 if (sigaltstack (NULL, &ss) >= 0)
770 ss.ss_flags &= ~SS_ONSTACK;
771 sigaltstack (&ss, NULL);
775 dnl FIXME: Put in some more known values into the third argument.
776 SV_TRY_LEAVE_HANDLER_SIGLONGJMP([ and setcontext],
777 sv_cv_leave_handler_siglongjmp_setcontext,
779 [#include <ucontext.h>
781 #define SS_ONSTACK SA_ONSTACK
785 static ucontext_t uc;
787 if (getcontext(&uc) >= 0)
789 if (uc.uc_stack.ss_flags & SS_ONSTACK)
791 uc.uc_stack.ss_flags &= ~SS_ONSTACK;
797 # End of MacOS X special casing.
802 if test "$sv_cv_leave_handler_longjmp" != no; then
803 CFG_LEAVE=leave-nop.c
805 if test "$sv_cv_leave_handler_longjmp_sigaltstack" != no; then
806 CFG_LEAVE=leave-sigaltstack.c
808 if test "$sv_cv_leave_handler_longjmp_setcontext" != no; then
809 CFG_LEAVE=leave-setcontext.c
814 # On BeOS, the 6 tests fail because sigaltstack() doesn't exist.
815 # If one uses set_signal_stack() instead of sigaltstack(), the first
816 # test actually works. i.e. sv_cv_leave_handler_longjmp would be 'yes'.
817 beos*) CFG_LEAVE=leave-nop.c ;;
819 if test -z "$CFG_LEAVE"; then
820 CFG_LEAVE=leave-none.c
822 AC_DEFINE_UNQUOTED([CFG_LEAVE], ["$CFG_LEAVE"],
823 [The name of the file implementing sigsegv_reset_onstack_flag.])
824 AC_SUBST([CFG_LEAVE])
826 dnl =========================== Done with CFG_LEAVE ===========================
829 dnl ================= Determine HAVE_STACK_OVERFLOW_RECOVERY =================
830 dnl Requires AC_CANONICAL_HOST, CFG_HANDLER / CFG_FAULT / etc., CFG_STACKVMA,
833 AC_CACHE_CHECK([if the system supports catching stack overflow],
834 [sv_cv_have_stack_overflow_recovery],
836 dnl On Mach, it requires a machfault-*.h (see src/handler-macos.c).
837 dnl On Unix, it requires either sigaltstack() or the BeOS set_signal_stack()
838 dnl function, and the ability to longjmp out of the signal handler, and on
839 dnl Unix it also requires a fault-*.h or a stackvma-*.c with certain
840 dnl properties (see src/handler-unix.c).
841 if test "$CFG_MACHFAULT" != fault-none.h; then
842 sv_cv_have_stack_overflow_recovery=yes
845 mingw* | cygwin*) sv_cv_have_stack_overflow_recovery=yes ;;
847 if test "$CFG_LEAVE" != 'leave-none.c'; then
848 if test "$sv_cv_sigaltstack" != no; then
849 sv_cv_have_stack_overflow_recovery=maybe
852 beos*) sv_cv_have_stack_overflow_recovery=maybe ;;
853 *) sv_cv_have_stack_overflow_recovery=no ;;
857 sv_cv_have_stack_overflow_recovery=no
862 if test $sv_cv_have_stack_overflow_recovery = maybe; then
863 if test -n "$CFG_FAULT"; then
864 AC_EGREP_CPP([xyzzy], [
865 #include "$srcdir/src/$CFG_FAULT"
866 #ifdef SIGSEGV_FAULT_HANDLER_ARGLIST
867 #ifdef SIGSEGV_FAULT_ADDRESS
871 ], [condA=true], [condA=false])
875 if test -n "$CFG_FAULT"; then
876 AC_EGREP_CPP([xyzzy], [
877 #include "$srcdir/src/$CFG_FAULT"
878 #ifdef SIGSEGV_FAULT_HANDLER_ARGLIST
879 #ifdef SIGSEGV_FAULT_STACKPOINTER
883 ], [condB=true], [condB=false])
887 if test "$CFG_STACKVMA" != "stackvma-none.c"; then
892 if { $condA && $condB; } || { $condA && $condC; } || { $condB && $condC; }; then
893 sv_cv_have_stack_overflow_recovery=yes
895 sv_cv_have_stack_overflow_recovery=no
899 if test $sv_cv_have_stack_overflow_recovery != no; then
900 HAVE_STACK_OVERFLOW_RECOVERY=1
902 HAVE_STACK_OVERFLOW_RECOVERY=0
904 AC_SUBST([HAVE_STACK_OVERFLOW_RECOVERY])
906 dnl ================= Done with HAVE_STACK_OVERFLOW_RECOVERY =================
909 dnl ======================= Determine CFG_HANDLER fully =======================
910 dnl Requires AC_CANONICAL_HOST, CFG_HANDLER / CFG_FAULT / etc.,
911 dnl HAVE_SIGSEGV_RECOVERY, HAVE_STACK_OVERFLOW_RECOVERY.
914 mingw* | cygwin*) CFG_HANDLER=handler-win32.c ;;
916 if test -z "$CFG_HANDLER"; then
917 if test $sv_cv_have_sigsegv_recovery = no \
918 && test $sv_cv_have_stack_overflow_recovery = no; then
919 CFG_HANDLER=handler-none.c
921 CFG_HANDLER=handler-unix.c
926 AC_DEFINE_UNQUOTED([CFG_HANDLER], ["$CFG_HANDLER"],
927 [The name of the file implementing the handler functionality.])
928 AC_SUBST([CFG_HANDLER])
930 dnl ======================= Done with CFG_HANDLER fully =======================
933 dnl Test whether to enable Cygwin specific tests.
934 AM_CONDITIONAL([CYGWIN],
940 dnl Test whether to make system calls fail with error EFAULT.
941 dnl More precisely: whether passing invalid memory accesses to system calls
942 dnl should make the system call fail with error EFAULT, rather than invoking
943 dnl the signal handler.
944 dnl It is necessary on Cygwin: otherwise the cygwin1 test fails.
946 cygwin*) enable_EFAULT=yes ;;
947 *) enable_EFAULT=no ;;
949 if test $enable_EFAULT = yes; then
950 AC_DEFINE([ENABLE_EFAULT], [1],
951 [Define to 1 if attempting to make system calls fail with error EFAULT])
953 AM_CONDITIONAL([ENABLE_EFAULT], [test $enable_EFAULT = yes])
955 if test $enable_EFAULT = yes; then
960 { echo; echo "${term_bold}Build Parameters:${term_norm}"; } >& AS_MESSAGE_FD
962 dnl Relocatability is a nop for this package.
965 { echo; echo "${term_bold}Output Substitution:${term_norm}"; } >& AS_MESSAGE_FD
967 dnl AC_OUTPUT([Makefile])
969 src/Makefile src/sigsegv.h
972 { echo; echo "Now please type '${term_bold}make${term_norm}' to compile. Good luck."; echo; } >& AS_MESSAGE_FD