summaryrefslogtreecommitdiff
path: root/os_dep.c
diff options
context:
space:
mode:
authorivmai <ivmai>2011-02-12 19:28:44 +0100
committerIvan Maidanski <ivmai@mail.ru>2011-07-26 19:06:56 +0200
commite14ec43a449c3437fd0887adce7ed6a333d073c1 (patch)
tree6f27551eec02d7584e04f8584a79c6f118afcc82 /os_dep.c
parentc57fa2338ee2a5ad9da4d08142c33bd958ea9aaa (diff)
2011-02-10 Ivan Maidanski <ivmai@mail.ru> (with input from Dimitry Andric)
* os_dep.c: Don't include signal.h for GC_write_fault_handler on Win32. * os_dep.c (SIG_OK): Don't return true unless SIGSEGV or SIGBUS on FreeBSD. * os_dep.c (CODE_OK): Use SEGV_ACCERR on FreeBSD (define SEGV_ACCERR for older FreeBSD releases). * os_dep.c (SIG_OK, CODE_OK, GC_write_fault_handler): Reformat the code.
Diffstat (limited to 'os_dep.c')
-rw-r--r--os_dep.c62
1 files changed, 31 insertions, 31 deletions
diff --git a/os_dep.c b/os_dep.c
index 1e27a42..b939d5b 100644
--- a/os_dep.c
+++ b/os_dep.c
@@ -3050,53 +3050,53 @@ STATIC void GC_default_push_other_roots(void)
void GC_record_fault(struct hblk * h); /* from checksums.c */
#endif
-#if !defined(DARWIN)
+#ifndef DARWIN
+
+# if !defined(MSWIN32) && !defined(MSWINCE)
# include <errno.h>
+# if defined(FREEBSD) || defined(HURD) || defined(HPUX)
+# define SIG_OK (sig == SIGBUS || sig == SIGSEGV)
+# else
+# define SIG_OK (sig == SIGSEGV)
+# endif
# if defined(FREEBSD)
-# define SIG_OK TRUE /* sig == SIGSEGV */
+# ifndef SEGV_ACCERR
+# define SEGV_ACCERR 2
+# endif
# define CODE_OK (si -> si_code == BUS_PAGE_FAULT \
- || si -> si_code == 2 /* experimentally determined (SEGV_ACCERR) */)
+ || si -> si_code == SEGV_ACCERR)
# elif defined(OSF1)
-# define SIG_OK (sig == SIGSEGV)
# define CODE_OK (si -> si_code == 2 /* experimentally determined */)
# elif defined(IRIX5)
-# define SIG_OK (sig == SIGSEGV)
# define CODE_OK (si -> si_code == EACCES)
# elif defined(HURD)
-# define SIG_OK (sig == SIGBUS || sig == SIGSEGV)
-# define CODE_OK TRUE
+# define CODE_OK TRUE
# elif defined(LINUX)
-# define SIG_OK (sig == SIGSEGV)
# define CODE_OK TRUE
- /* Empirically c.trapno == 14, on IA32, but is that useful? */
- /* Should probably consider alignment issues on other */
- /* architectures. */
+ /* Empirically c.trapno == 14, on IA32, but is that useful? */
+ /* Should probably consider alignment issues on other */
+ /* architectures. */
# elif defined(HPUX)
-# define SIG_OK (sig == SIGSEGV || sig == SIGBUS)
# define CODE_OK (si -> si_code == SEGV_ACCERR \
|| si -> si_code == BUS_ADRERR \
|| si -> si_code == BUS_UNKNOWN \
|| si -> si_code == SEGV_UNKNOWN \
|| si -> si_code == BUS_OBJERR)
# elif defined(SUNOS5SIGS)
-# define SIG_OK (sig == SIGSEGV)
# define CODE_OK (si -> si_code == SEGV_ACCERR)
-# elif defined(MSWIN32) || defined(MSWINCE)
-# define SIG_OK (exc_info -> ExceptionRecord -> ExceptionCode \
- == STATUS_ACCESS_VIOLATION)
-# define CODE_OK (exc_info -> ExceptionRecord -> ExceptionInformation[0] \
- == 1) /* Write fault */
# endif
-
-# if defined(MSWIN32) || defined(MSWINCE)
- GC_INNER LONG WINAPI GC_write_fault_handler(
- struct _EXCEPTION_POINTERS *exc_info)
-# else
# include <ucontext.h>
/*ARGSUSED*/
STATIC void GC_write_fault_handler(int sig, siginfo_t *si, void *raw_sc)
+# else
+# define SIG_OK (exc_info -> ExceptionRecord -> ExceptionCode \
+ == STATUS_ACCESS_VIOLATION)
+# define CODE_OK (exc_info -> ExceptionRecord -> ExceptionInformation[0] \
+ == 1) /* Write fault */
+ GC_INNER LONG WINAPI GC_write_fault_handler(
+ struct _EXCEPTION_POINTERS *exc_info)
# endif /* MSWIN32 || MSWINCE */
-{
+ {
# if !defined(MSWIN32) && !defined(MSWINCE)
char *addr = si -> si_addr;
# else
@@ -3197,14 +3197,14 @@ STATIC void GC_default_push_other_roots(void)
return;
# endif
}
-#if defined(MSWIN32) || defined(MSWINCE)
- return EXCEPTION_CONTINUE_SEARCH;
-#else
- if (GC_print_stats)
+# if defined(MSWIN32) || defined(MSWINCE)
+ return EXCEPTION_CONTINUE_SEARCH;
+# else
+ if (GC_print_stats)
GC_printf("Unexpected segfault at %p\n", addr);
- ABORT("Unexpected bus error or segmentation fault");
-#endif
-}
+ ABORT("Unexpected bus error or segmentation fault");
+# endif
+ }
#endif /* !DARWIN */
/*