*/
#include <stdio.h>
-
+#include <stdlib.h>
+#include <string.h>
#include <signal.h>
-#ifdef mach /* KLUDGE: #ifdef on lowercase symbols? Ick. -- WHN 19990904 */
-#ifdef mips
-#include <mips/cpu.h>
-#endif
-#endif
#include "runtime.h"
#include "arch.h"
#include "dynbind.h"
#include "interr.h"
+
void sigaddset_blockable(sigset_t *s)
{
sigaddset(s, SIGHUP);
sigaddset(s, SIGPIPE);
sigaddset(s, SIGALRM);
sigaddset(s, SIGURG);
+ sigaddset(s, SIGFPE);
sigaddset(s, SIGTSTP);
sigaddset(s, SIGCHLD);
sigaddset(s, SIGIO);
== current_control_frame_pointer) {
/* There is a small window during call where the callee's
* frame isn't built yet. */
- if (LowtagOf(*os_context_register_addr(context, reg_CODE))
- == type_FunctionPointer) {
+ if (lowtag_of(*os_context_register_addr(context, reg_CODE))
+ == FUN_POINTER_LOWTAG) {
/* We have called, but not built the new frame, so
* build it for them. */
current_control_frame_pointer[0] =
* FREE_INTERRUPT_CONTEXT_INDEX? If so, we should say so. And
* perhaps yes, unbind_to_here() really would be clearer and less
* fragile.. */
+ /* dan (2001.08.10) thinks the above supposition is probably correct */
unbind();
#ifdef reg_ALLOC
* anyway. Why we still need to copy the pending_mask into the
* context given that we're now done with the context anyway, I
* couldn't say. */
- memcpy(os_context_sigmask_addr(context), &pending_mask, sizeof(sigset_t));
+#if 0
+ memcpy(os_context_sigmask_addr(context), &pending_mask,
+ 4 /* sizeof(sigset_t) */ );
+#endif
sigemptyset(&pending_mask);
if (pending_signal) {
int signal = pending_signal;
#endif
union interrupt_handler handler;
- /* FIXME: The CMU CL we forked off of had this Linux-only
- * operation here. Newer CMU CLs (e.g. 18c) have hairier
- * Linux/i386-only logic here. SBCL seems to be more reliable
- * without anything here. However, if we start supporting code
- * which sets the rounding mode, then we may want to do something
- * special to force the rounding mode back to some standard value
- * here, so that ISRs can have a standard environment. (OTOH, if
- * rounding modes are under user control, then perhaps we should
- * leave this up to the user.)
- *
- * In the absence of a test case to show that this is really a
- * problem, we just suppress this code completely (just like the
- * parallel code in maybe_now_maybe_later).
- * #ifdef __linux__
- * SET_FPU_CONTROL_WORD(context->__fpregs_mem.cw);
- * #endif */
-
+#ifdef LISP_FEATURE_LINUX
+ /* Under Linux, we appear to have to restore the fpu control word
+ from the context, as after the signal is delivered we appear to
+ have a null fpu control word. */
+ os_restore_fp_control(context);
+#endif
handler = interrupt_handlers[signal];
if (ARE_SAME_HANDLER(handler.c, SIG_IGN)) {
return;
}
-
+
#ifndef __i386__
were_in_lisp = !foreign_function_call_active;
if (were_in_lisp)
* support decides to pass on it. */
lose("no handler for signal %d in interrupt_handle_now(..)", signal);
- } else if (LowtagOf(handler.lisp) == type_FunctionPointer) {
+ } else if (lowtag_of(handler.lisp) == FUN_POINTER_LOWTAG) {
/* Allocate the SAPs while the interrupts are still disabled.
* (FIXME: Why? This is the way it was done in CMU CL, and it
* interrupt time which should be ported into SBCL. Also see the
* analogous logic at the head of interrupt_handle_now for
* more related FIXME stuff.
- *
- * For now, we just suppress this code completely.
- * #ifdef __linux__
- * SET_FPU_CONTROL_WORD(context->__fpregs_mem.cw);
- * #endif */
-
+ */
+
+#ifdef LISP_FEATURE_LINUX
+ os_restore_fp_control(context);
+#endif
+
/* see comments at top of code/signal.lisp for what's going on here
* with INTERRUPTS_ENABLED/INTERRUPT_HANDLE_NOW
*/
* stuff to detect and handle hitting the GC trigger
*/
-#ifndef INTERNAL_GC_TRIGGER
+#ifndef GENCGC /* since GENCGC has its own way to record trigger */
static boolean
gc_trigger_hit(int signal, siginfo_t *info, os_context_t *context)
{
os_context_t *context=(os_context_t *) void_context;
if (!foreign_function_call_active
-#ifndef INTERNAL_GC_TRIGGER
+#ifndef GENCGC /* since GENCGC has its own way to record trigger */
&& gc_trigger_hit(signal, info, context)
#endif
) {
-#ifndef INTERNAL_GC_TRIGGER
+#ifndef GENCGC /* since GENCGC has its own way to record trigger */
clear_auto_gc_trigger();
#endif
arch_set_pseudo_atomic_interrupted(context);
}
else {
+ lispobj *old_free_space=current_dynamic_space;
fake_foreign_function_call(context);
funcall0(SymbolFunction(MAYBE_GC));
undo_fake_foreign_function_call(context);
- }
-
+ if(current_dynamic_space==old_free_space)
+ /* MAYBE-GC (as the name suggest) might not. If it
+ * doesn't, it won't reset the GC trigger either, so we
+ * have to do it ourselves. Add small amount of space
+ * to tide us over while GC is inhibited
+ */
+ set_auto_gc_trigger((u32)dynamic_space_free_pointer
+ -(u32)current_dynamic_space
+ +(u32)os_vm_page_size);
+ }
return 1;
} else {
return 0;
sigaddset_blockable(&sa.sa_mask);
sa.sa_flags = SA_SIGINFO | SA_RESTART;
- /* In the case of interrupt handlers which are modified
- * more than once, we only save the original unmodified
- * copy. */
+ /* In the case of interrupt handlers which are modified more than
+ * once, we only save the original unmodified copy. */
if (!old_low_level_signal_handler_state->was_modified) {
+ struct sigaction *old_handler =
+ (struct sigaction*) &old_low_level_signal_handler_state->handler;
old_low_level_signal_handler_state->was_modified = 1;
- sigaction(signal, &sa, &old_low_level_signal_handler_state->handler);
+ sigaction(signal, &sa, old_handler);
} else {
sigaction(signal, &sa, NULL);
}
interrupt_low_level_handlers[signal] =
- (ARE_SAME_HANDLER(handler,SIG_DFL) ? 0 : handler);
+ (ARE_SAME_HANDLER(handler, SIG_DFL) ? 0 : handler);
}
/* This is called from Lisp. */