Authors: Christian Thalinger
- Changes:
-
- $Id: signal.c 5809 2006-10-20 13:09:54Z twisti $
+ $Id: signal.c 6256 2006-12-28 12:30:09Z twisti $
*/
#include "config.h"
+#include <errno.h>
#include <signal.h>
#include <stdlib.h>
+#include <unistd.h>
+#include <sys/mman.h>
+
+#if defined(__DARWIN__)
+/* If we compile with -ansi on darwin, <sys/types.h> is not
+ included. So let's do it here. */
+# include <sys/types.h>
+#endif
#include "vm/types.h"
# include "threads/native/threads.h"
#endif
+#include "mm/memory.h"
#include "vm/signallocal.h"
#include "vm/options.h"
#include "vm/vm.h"
void signal_init(void)
{
#if !defined(__CYGWIN__)
+ int pagesize;
struct sigaction act;
+ /* mmap a memory page at address 0x0, so our hardware-exceptions
+ work. */
+
+ pagesize = getpagesize();
+
+ (void) memory_mmap_anon(NULL, pagesize, PROT_NONE, MAP_PRIVATE | MAP_FIXED);
+
+#if defined(ENABLE_GC_BOEHM)
/* Allocate something so the garbage collector's signal handlers
are installed. */
(void) GCNEW(u1);
+#endif
/* install signal handlers we need to convert to exceptions */
# endif
/* catch NullPointerException/StackOverFlowException */
- if (!checknull) {
- act.sa_sigaction = md_signal_handler_sigsegv;
- act.sa_flags = SA_NODEFER | SA_SIGINFO;
+ act.sa_sigaction = md_signal_handler_sigsegv;
+ act.sa_flags = SA_NODEFER | SA_SIGINFO;
#if defined(SIGSEGV)
- sigaction(SIGSEGV, &act, NULL);
+ sigaction(SIGSEGV, &act, NULL);
#endif
#if defined(SIGBUS)
- sigaction(SIGBUS, &act, NULL);
+ sigaction(SIGBUS, &act, NULL);
#endif
- }
/* catch ArithmeticException */
-#if defined(__I386__) || defined(__X86_64__)
+#if SUPPORT_HARDWARE_DIVIDE_BY_ZERO
act.sa_sigaction = md_signal_handler_sigfpe;
act.sa_flags = SA_NODEFER | SA_SIGINFO;
sigaction(SIGFPE, &act, NULL);