Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: signal.c 7344 2007-02-13 12:23:54Z ajordan $
+ $Id: signal.c 7811 2007-04-25 18:33:30Z twisti $
*/
#include "config.h"
+#include <assert.h>
#include <errno.h>
#include <signal.h>
#include <stdlib.h>
#include "vm/types.h"
+#include "arch.h"
+
#include "mm/memory.h"
#if defined(ENABLE_THREADS)
# include "threads/threads-common.h"
#endif
+#include "vm/exceptions.h"
#include "vm/signallocal.h"
#include "vm/vm.h"
#include "vmcore/options.h"
+#if defined(ENABLE_STATISTICS)
+# include "vmcore/statistics.h"
+#endif
+
/* global variables ***********************************************************/
(void) memory_mmap_anon(NULL, pagesize, PROT_NONE, MAP_PRIVATE | MAP_FIXED);
-#if 0
+ /* check if we get into trouble with our hardware-exceptions */
+
+ assert(OFFSET(java_bytearray, data) > EXCEPTION_HARDWARE_PATCHER);
+
/* Block the following signals (SIGINT for <ctrl>-c, SIGQUIT for
<ctrl>-\). We enable them later in signal_thread, but only for
this thread. */
if (sigprocmask(SIG_BLOCK, &mask, NULL) != 0)
vm_abort("signal_init: sigprocmask failed: %s", strerror(errno));
-#endif
#if defined(ENABLE_GC_BOEHM)
/* Allocate something so the garbage collector's signal handlers
act.sa_sigaction = md_signal_handler_sigsegv;
act.sa_flags = SA_NODEFER | SA_SIGINFO;
-#if defined(SIGSEGV)
+# if defined(SIGSEGV)
sigaction(SIGSEGV, &act, NULL);
-#endif
+# endif
-#if defined(SIGBUS)
+# if defined(SIGBUS)
sigaction(SIGBUS, &act, NULL);
-#endif
+# endif
-#if SUPPORT_HARDWARE_DIVIDE_BY_ZERO
+# if SUPPORT_HARDWARE_DIVIDE_BY_ZERO
/* SIGFPE handler */
act.sa_sigaction = md_signal_handler_sigfpe;
act.sa_flags = SA_NODEFER | SA_SIGINFO;
sigaction(SIGFPE, &act, NULL);
-#endif
+# endif
+
+# if defined(__ARM__)
+ /* XXX use better defines for that (in arch.h) */
+ /* SIGILL handler */
+
+ act.sa_sigaction = md_signal_handler_sigill;
+ act.sa_flags = SA_NODEFER | SA_SIGINFO;
+ sigaction(SIGILL, &act, NULL);
+# endif
+
+# if defined(__POWERPC__)
+ /* XXX use better defines for that (in arch.h) */
+ /* SIGTRAP handler */
+
+ act.sa_sigaction = md_signal_handler_sigtrap;
+ act.sa_flags = SA_NODEFER | SA_SIGINFO;
+ sigaction(SIGTRAP, &act, NULL);
+# endif
# if defined(ENABLE_INTRP)
}
# endif
if (sigemptyset(&mask) != 0)
vm_abort("signal_thread: sigemptyset failed: %s", strerror(errno));
- sigaddset(&mask, SIGINT);
+ if (sigaddset(&mask, SIGINT) != 0)
+ vm_abort("signal_thread: sigaddset failed: %s", strerror(errno));
+
#if !defined(__FREEBSD__)
- sigaddset(&mask, SIGQUIT);
+ if (sigaddset(&mask, SIGQUIT) != 0)
+ vm_abort("signal_thread: sigaddset failed: %s", strerror(errno));
#endif
while (true) {
/* just wait for a signal */
+ /* XXX We don't check for an error here, although the man-page
+ states sigwait does not return an error (which is wrong!),
+ but it seems to make problems with Boehm-GC. We should
+ revisit this code with our new exact-GC. */
+
+/* if (sigwait(&mask, &sig) != 0) */
+/* vm_abort("signal_thread: sigwait failed: %s", strerror(errno)); */
(void) sigwait(&mask, &sig);
switch (sig) {
name = utf_new_char("Signal Handler");
- thread_signal = threads_create_thread(name);
+ thread_signal = threads_thread_create_internal(name);
if (thread_signal == NULL)
return false;