Skip to content
Snippets Groups Projects
Commit 342beebb authored by cshapiro's avatar cshapiro
Browse files

Use sa_sigaction signal handlers on Linux. The glibc definition of

sigset_t is different from the one used in the Linux kernel.  This means
that we cannot make assignments of sigset_t objects without corrupting
memory.  To work around this problem we update uc_sigmask differently
on Linux than on other systems.  Also, remove x87 control word updates
since the x87 is setup correctly inside call_into_lisp.
parent 091c1f26
Branches
No related tags found
No related merge requests found
...@@ -20,7 +20,7 @@ endif ...@@ -20,7 +20,7 @@ endif
RUNTIME = $(GENCGC) $(LINKAGE) RUNTIME = $(GENCGC) $(LINKAGE)
# __NO_CTYPE so builds on glibc 2.3 will run on (some) older glibc's. # __NO_CTYPE so builds on glibc 2.3 will run on (some) older glibc's.
CPPFLAGS = -D__NO_CTYPE -I. -I$(PATH1) -I- -I/usr/X11R6/include $(RUNTIME) CPPFLAGS = -D__NO_CTYPE -D_GNU_SOURCE -I. -I$(PATH1) -I- -I/usr/X11R6/include $(RUNTIME)
CFLAGS = -rdynamic -Wstrict-prototypes -Wall -O2 -g $(RUNTIME) CFLAGS = -rdynamic -Wstrict-prototypes -Wall -O2 -g $(RUNTIME)
ASFLAGS = -g -DGENCGC -DLINKAGE_TABLE ASFLAGS = -g -DGENCGC -DLINKAGE_TABLE
NM = $(PATH1)/linux-nm NM = $(PATH1)/linux-nm
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* GENCGC support by Douglas Crosher, 1996, 1997. * GENCGC support by Douglas Crosher, 1996, 1997.
* Alpha support by Julian Dolby, 1999. * Alpha support by Julian Dolby, 1999.
* *
* $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/Linux-os.c,v 1.30 2007/07/15 21:33:14 cshapiro Exp $ * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/Linux-os.c,v 1.31 2007/07/25 10:23:54 cshapiro Exp $
* *
*/ */
...@@ -97,25 +97,25 @@ os_init(void) ...@@ -97,25 +97,25 @@ os_init(void)
#ifdef i386 #ifdef i386
int * int *
sc_reg(struct sigcontext *c, int offset) sc_reg(ucontext_t *context, int offset)
{ {
switch (offset) { switch (offset) {
case 0: case 0:
return &c->eax; return &context->uc_mcontext.gregs[REG_EAX];
case 2: case 2:
return &c->ecx; return &context->uc_mcontext.gregs[REG_ECX];
case 4: case 4:
return &c->edx; return &context->uc_mcontext.gregs[REG_EDX];
case 6: case 6:
return &c->ebx; return &context->uc_mcontext.gregs[REG_EBX];
case 8: case 8:
return &c->esp; return &context->uc_mcontext.gregs[REG_ESP];
case 10: case 10:
return &c->ebp; return &context->uc_mcontext.gregs[REG_EBP];
case 12: case 12:
return &c->esi; return &context->uc_mcontext.gregs[REG_ESI];
case 14: case 14:
return &c->edi; return &context->uc_mcontext.gregs[REG_EDI];
} }
return (int *) 0; return (int *) 0;
} }
...@@ -250,28 +250,28 @@ valid_addr(os_vm_address_t addr) ...@@ -250,28 +250,28 @@ valid_addr(os_vm_address_t addr)
static void static void
sigsegv_handle_now(HANDLER_ARGS) sigsegv_handle_now(HANDLER_ARGS)
{ {
interrupt_handle_now(signal, contextstruct); interrupt_handle_now(signal, code, context);
} }
static int tramp_signal; static int tramp_signal;
static struct sigcontext tramp_contextstruct; static siginfo_t tramp_code;
static ucontext_t tramp_context;
static void static void
sigsegv_handler_tramp(void) sigsegv_handler_tramp(void)
{ {
sigsegv_handle_now(tramp_signal, tramp_contextstruct); sigsegv_handle_now(tramp_signal, &tramp_code, &tramp_context);
assert(0); assert(0);
} }
void void
sigsegv_handler(HANDLER_ARGS) sigsegv_handler(HANDLER_ARGS)
{ {
GET_CONTEXT int fault_addr = context->uc_mcontext.cr2;
int fault_addr = ((struct sigcontext *) (&contextstruct))->cr2;
int page_index = find_page_index((void *) fault_addr); int page_index = find_page_index((void *) fault_addr);
#ifdef RED_ZONE_HIT #ifdef RED_ZONE_HIT
if (os_control_stack_overflow((void *) fault_addr, &contextstruct)) if (os_control_stack_overflow((void *) fault_addr, context))
return; return;
#endif #endif
...@@ -292,7 +292,7 @@ sigsegv_handler(HANDLER_ARGS) ...@@ -292,7 +292,7 @@ sigsegv_handler(HANDLER_ARGS)
#if defined(__x86_64) #if defined(__x86_64)
DPRINTF(0, (stderr, "sigsegv: rip: %p\n", context->rip)); DPRINTF(0, (stderr, "sigsegv: rip: %p\n", context->rip));
#else #else
DPRINTF(0, (stderr, "sigsegv: eip: %lx\n", context->eip)); DPRINTF(0, (stderr, "sigsegv: eip: %x\n", context->uc_mcontext.gregs[REG_EIP]));
#endif #endif
#ifdef RED_ZONE_HIT #ifdef RED_ZONE_HIT
...@@ -301,13 +301,14 @@ sigsegv_handler(HANDLER_ARGS) ...@@ -301,13 +301,14 @@ sigsegv_handler(HANDLER_ARGS)
handler there. Global variables are used to pass the context handler there. Global variables are used to pass the context
to the other stack. */ to the other stack. */
tramp_signal = signal; tramp_signal = signal;
tramp_contextstruct = contextstruct; tramp_code = *code;
tramp_context = *context;
SC_PC(context) = sigsegv_handler_tramp; SC_PC(context) = sigsegv_handler_tramp;
return; return;
} }
#endif #endif
sigsegv_handle_now(signal, contextstruct); sigsegv_handle_now(signal, code, context);
} }
#else #else
static void static void
...@@ -315,10 +316,7 @@ sigsegv_handler(HANDLER_ARGS) ...@@ -315,10 +316,7 @@ sigsegv_handler(HANDLER_ARGS)
{ {
os_vm_address_t addr; os_vm_address_t addr;
#ifdef i386 DPRINTF(0, (stderr, "sigsegv\n"));
GET_CONTEXT
#endif
DPRINTF(0, (stderr, "sigsegv\n"));
#ifdef i386 #ifdef i386
interrupt_handle_now(signal, contextstruct); interrupt_handle_now(signal, contextstruct);
#else #else
...@@ -345,15 +343,8 @@ sigsegv_handler(HANDLER_ARGS) ...@@ -345,15 +343,8 @@ sigsegv_handler(HANDLER_ARGS)
static void static void
sigbus_handler(HANDLER_ARGS) sigbus_handler(HANDLER_ARGS)
{ {
#if defined(i386) || defined(__x86_64)
GET_CONTEXT
#endif
DPRINTF(1, (stderr, "sigbus:\n")); /* there is no sigbus in linux??? */ DPRINTF(1, (stderr, "sigbus:\n")); /* there is no sigbus in linux??? */
#if defined(i386) || defined(__x86_64)
interrupt_handle_now(signal, contextstruct);
#else
interrupt_handle_now(signal, code, context); interrupt_handle_now(signal, code, context);
#endif
} }
void void
......
/* $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/Linux-os.h,v 1.24 2007/07/15 21:33:14 cshapiro Exp $ /* $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/Linux-os.h,v 1.25 2007/07/25 10:23:54 cshapiro Exp $
This code was written as part of the CMU Common Lisp project at This code was written as part of the CMU Common Lisp project at
Carnegie Mellon University, and has been placed in the public domain. Carnegie Mellon University, and has been placed in the public domain.
...@@ -30,6 +30,7 @@ typedef caddr_t os_vm_address_t; /* like hpux */ ...@@ -30,6 +30,7 @@ typedef caddr_t os_vm_address_t; /* like hpux */
typedef size_t os_vm_size_t; /* like hpux */ typedef size_t os_vm_size_t; /* like hpux */
typedef off_t os_vm_offset_t; /* like hpux */ typedef off_t os_vm_offset_t; /* like hpux */
typedef int os_vm_prot_t; /* like hpux */ typedef int os_vm_prot_t; /* like hpux */
#define os_context_t ucontext_t
#define OS_VM_PROT_READ PROT_READ /* like hpux */ #define OS_VM_PROT_READ PROT_READ /* like hpux */
#define OS_VM_PROT_WRITE PROT_WRITE /* like hpux */ #define OS_VM_PROT_WRITE PROT_WRITE /* like hpux */
...@@ -41,38 +42,20 @@ typedef int os_vm_prot_t; /* like hpux */ ...@@ -41,38 +42,20 @@ typedef int os_vm_prot_t; /* like hpux */
#define OS_VM_DEFAULT_PAGESIZE 8192 /* like hpux */ #define OS_VM_DEFAULT_PAGESIZE 8192 /* like hpux */
#endif #endif
int *sc_reg(struct sigcontext *, int); int *sc_reg(ucontext_t *, int);
typedef struct sigcontext sigcontext;
/* Don't want the SIGINFO flag on linux as it causes the creation
of real-time interrupt frames.
*/
#define USE_SA_SIGINFO 0
/* Alpha uses OSF/1 signals which are the defaults in os.h,
so there is no need to define the following for Alpha
Linux
*/
#if (defined(i386) || defined(__x86_64)) #if (defined(i386) || defined(__x86_64))
#define HANDLER_ARGS int signal, struct sigcontext contextstruct #define HANDLER_ARGS int signal, siginfo_t *code, ucontext_t *context
#define GET_CONTEXT int code=0; struct sigcontext *context=&contextstruct; #define CODE(code) ((code) ? code->si_code : 0)
#include <fpu_control.h> #include <fpu_control.h>
#define setfpucw(cw) {fpu_control_t cw_tmp=cw;_FPU_SETCW(cw_tmp);} #define setfpucw(cw) {fpu_control_t cw_tmp=cw;_FPU_SETCW(cw_tmp);}
#define uc_sigmask oldmask
#if defined (__x86_64) #if defined (__x86_64)
#define sc_pc rip #define sc_pc rip
#define sc_sp rsp #define sc_sp rsp
#else
#define sc_pc eip
#define sc_sp esp
#endif #endif
#define sc_mask oldmask
#define sigcontext sigcontext
#define sc_efl eflags
#ifdef __x86_64 #ifdef __x86_64
#define sc_rax rax #define sc_rax rax
...@@ -84,28 +67,10 @@ typedef struct sigcontext sigcontext; ...@@ -84,28 +67,10 @@ typedef struct sigcontext sigcontext;
#define sc_rsi rsi #define sc_rsi rsi
#define sc_rdi rdi #define sc_rdi rdi
#define sc_rip rip #define sc_rip rip
#else
#define sc_eax eax
#define sc_ecx ecx
#define sc_edx edx
#define sc_ebx ebx
#define sc_esp esp
#define sc_ebp ebp
#define sc_esi esi
#define sc_edi edi
#define sc_eip eip
#endif #endif
#endif /* i386 */ #endif /* i386 */
#ifdef alpha
#define uc_sigmask sc_mask
#endif /* alpha */
#ifndef sa_sigaction
#define sa_sigaction sa_handler
#endif
#define PROTECTION_VIOLATION_SIGNAL SIGSEGV #define PROTECTION_VIOLATION_SIGNAL SIGSEGV
#endif /* _LINUX_OS_H_ */ #endif /* _LINUX_OS_H_ */
/* $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/interrupt.c,v 1.48 2007/07/15 09:24:57 cshapiro Exp $ */ /* $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/interrupt.c,v 1.49 2007/07/25 10:23:54 cshapiro Exp $ */
/* Interrupt handling magic. */ /* Interrupt handling magic. */
...@@ -32,11 +32,11 @@ void (*interrupt_low_level_handlers[NSIG]) (HANDLER_ARGS) = { ...@@ -32,11 +32,11 @@ void (*interrupt_low_level_handlers[NSIG]) (HANDLER_ARGS) = {
static int pending_signal = 0; static int pending_signal = 0;
#if defined(SOLARIS) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) #if defined(SOLARIS) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__linux__)
static siginfo_t *pending_code; static siginfo_t pending_code = { 0 };
#define PASSCODE(code) ((code)) #define PASSCODE(code) (&(code))
#define DEREFCODE(code) ((code)) #define DEREFCODE(code) (*(code))
#else #else
static int pending_code = 0; static int pending_code = 0;
...@@ -163,30 +163,17 @@ interrupt_internal_error(HANDLER_ARGS, boolean continuable) ...@@ -163,30 +163,17 @@ interrupt_internal_error(HANDLER_ARGS, boolean continuable)
{ {
lispobj context_sap = NIL; lispobj context_sap = NIL;
#if ( defined( __linux__ ) && (defined( i386 ) || defined( __x86_64 ) ) ) fake_foreign_function_call(context);
GET_CONTEXT
#endif
fake_foreign_function_call(context);
/* Allocate the SAP object while the interrupts are still disabled. */ /* Allocate the SAP object while the interrupts are still disabled. */
if (internal_errors_enabled) if (internal_errors_enabled)
#if (defined(DARWIN) || defined(__FreeBSD__)) && defined(__i386__) #if (defined(DARWIN) || defined(__FreeBSD__) || defined(__linux__)) && defined(i386)
context_sap = alloc_sap(&context->uc_mcontext); context_sap = alloc_sap(&context->uc_mcontext);
#else #else
context_sap = alloc_sap(context); context_sap = alloc_sap(context);
#endif #endif
#if !defined(__linux__) || (defined(__linux__) && (__GNU_LIBRARY__ < 6))
sigprocmask(SIG_SETMASK, &context->uc_sigmask, 0); sigprocmask(SIG_SETMASK, &context->uc_sigmask, 0);
#else
{
sigset_t temp;
sigemptyset(&temp);
temp.__val[0] = context->uc_sigmask;
sigprocmask(SIG_SETMASK, &temp, 0);
}
#endif
if (internal_errors_enabled) if (internal_errors_enabled)
funcall2(SymbolFunction(INTERNAL_ERROR), context_sap, funcall2(SymbolFunction(INTERNAL_ERROR), context_sap,
...@@ -217,18 +204,18 @@ interrupt_handle_pending(os_context_t * context) ...@@ -217,18 +204,18 @@ interrupt_handle_pending(os_context_t * context)
#endif #endif
undo_fake_foreign_function_call(context); undo_fake_foreign_function_call(context);
} }
#if !defined(__linux__) || (defined(__linux__) && (__GNU_LIBRARY__ < 6)) #ifndef __linux__
context->uc_sigmask = pending_mask; context->uc_sigmask = pending_mask;
#else #else
context->uc_sigmask = pending_mask.__val[0]; memcpy(&context->uc_sigmask, &pending_mask, NSIG / LONG_BIT);
#endif #endif
sigemptyset(&pending_mask); sigemptyset(&pending_mask);
if (pending_signal) { if (pending_signal) {
int signal; int signal;
#if defined(SOLARIS) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) #if defined(SOLARIS) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__linux__)
siginfo_t *code; siginfo_t code;
#else #else
int code; int code;
#endif #endif
...@@ -236,11 +223,7 @@ interrupt_handle_pending(os_context_t * context) ...@@ -236,11 +223,7 @@ interrupt_handle_pending(os_context_t * context)
code = pending_code; code = pending_code;
pending_signal = 0; pending_signal = 0;
/* pending_code = 0; */ /* pending_code = 0; */
#if ( defined( __linux__ ) && ( defined( i386 ) || defined ( __x86_64 ) ) )
interrupt_handle_now(signal, *context);
#else
interrupt_handle_now(signal, PASSCODE(code), context); interrupt_handle_now(signal, PASSCODE(code), context);
#endif
} }
} }
...@@ -256,11 +239,7 @@ interrupt_handle_pending(os_context_t * context) ...@@ -256,11 +239,7 @@ interrupt_handle_pending(os_context_t * context)
void void
interrupt_handle_now_handler(HANDLER_ARGS) interrupt_handle_now_handler(HANDLER_ARGS)
{ {
#if defined(__linux__) && (defined(i386) || defined(__x86_64))
interrupt_handle_now(signal, contextstruct);
#else
interrupt_handle_now(signal, code, context); interrupt_handle_now(signal, code, context);
#endif
#if defined(DARWIN) && defined(__ppc__) #if defined(DARWIN) && defined(__ppc__)
/* Work around G5 bug; fix courtesy gbyers via chandler */ /* Work around G5 bug; fix courtesy gbyers via chandler */
...@@ -271,25 +250,9 @@ interrupt_handle_now_handler(HANDLER_ARGS) ...@@ -271,25 +250,9 @@ interrupt_handle_now_handler(HANDLER_ARGS)
void void
interrupt_handle_now(HANDLER_ARGS) interrupt_handle_now(HANDLER_ARGS)
{ {
#if defined(__linux__) && (defined(i386) || defined(__x86_64))
GET_CONTEXT
#endif
int were_in_lisp; int were_in_lisp;
union interrupt_handler handler; union interrupt_handler handler;
#if defined(__linux__) && ( defined(i386) || defined(__x86_64) )
/*
* Restore the FPU control word, setting the rounding mode to nearest.
*/
if (contextstruct.fpstate)
#if defined(__x86_64)
setfpucw(contextstruct.fpstate->cwd & ~0xc00);
#else
setfpucw(contextstruct.fpstate->cw & ~0xc00);
#endif
#endif
handler = interrupt_handlers[signal]; handler = interrupt_handlers[signal];
if (handler.c == (void (*)(HANDLER_ARGS)) SIG_IGN) if (handler.c == (void (*)(HANDLER_ARGS)) SIG_IGN)
...@@ -310,24 +273,14 @@ interrupt_handle_now(HANDLER_ARGS) ...@@ -310,24 +273,14 @@ interrupt_handle_now(HANDLER_ARGS)
else if (LowtagOf(handler.lisp) == type_FunctionPointer) { else if (LowtagOf(handler.lisp) == type_FunctionPointer) {
/* Allocate the SAP object while the interrupts are still /* Allocate the SAP object while the interrupts are still
disabled. */ disabled. */
#if (defined(DARWIN) || defined(__FreeBSD__)) && defined(__i386__) #if (defined(DARWIN) || defined(__FreeBSD__) || defined(__linux__)) && defined(__i386__)
lispobj context_sap = alloc_sap(&context->uc_mcontext); lispobj context_sap = alloc_sap(&context->uc_mcontext);
#else #else
lispobj context_sap = alloc_sap(context); lispobj context_sap = alloc_sap(context);
#endif #endif
/* Allow signals again. */ /* Allow signals again. */
#if !defined(__linux__) || (defined(__linux__) && (__GNU_LIBRARY__ < 6))
sigprocmask(SIG_SETMASK, &context->uc_sigmask, 0); sigprocmask(SIG_SETMASK, &context->uc_sigmask, 0);
#else
{
sigset_t temp;
sigemptyset(&temp);
temp.__val[0] = context->uc_sigmask;
sigprocmask(SIG_SETMASK, &temp, 0);
}
#endif
#if 1 #if 1
funcall3(handler.lisp, make_fixnum(signal), make_fixnum(CODE(code)), funcall3(handler.lisp, make_fixnum(signal), make_fixnum(CODE(code)),
...@@ -338,23 +291,9 @@ interrupt_handle_now(HANDLER_ARGS) ...@@ -338,23 +291,9 @@ interrupt_handle_now(HANDLER_ARGS)
#endif #endif
} else { } else {
/* Allow signals again. */ /* Allow signals again. */
#if !defined(__linux__) || (defined(__linux__) && (__GNU_LIBRARY__ < 6))
sigprocmask(SIG_SETMASK, &context->uc_sigmask, 0); sigprocmask(SIG_SETMASK, &context->uc_sigmask, 0);
#else
{
sigset_t temp;
sigemptyset(&temp);
temp.__val[0] = context->uc_sigmask;
sigprocmask(SIG_SETMASK, &temp, 0);
}
#endif
#if ( defined( __linux__ ) && ( defined( i386 ) || defined ( __x86_64 ) ) )
(*handler.c) (signal, contextstruct);
#else
(*handler.c) (signal, code, context); (*handler.c) (signal, code, context);
#endif
} }
#if !(defined(i386) || defined(__x86_64)) #if !(defined(i386) || defined(__x86_64))
...@@ -366,30 +305,12 @@ interrupt_handle_now(HANDLER_ARGS) ...@@ -366,30 +305,12 @@ interrupt_handle_now(HANDLER_ARGS)
static void static void
maybe_now_maybe_later(HANDLER_ARGS) maybe_now_maybe_later(HANDLER_ARGS)
{ {
#if defined(__linux__) && (defined(i386) || defined(__x86_64)) SAVE_CONTEXT();
GET_CONTEXT
#endif
SAVE_CONTEXT();
/**/ if (SymbolValue(INTERRUPTS_ENABLED) == NIL) { /**/ if (SymbolValue(INTERRUPTS_ENABLED) == NIL) {
pending_signal = signal; pending_signal = signal;
pending_code = DEREFCODE(code); pending_code = DEREFCODE(code);
#if !defined(__linux__) || (defined(__linux__) && (__GNU_LIBRARY__ < 6))
pending_mask = context->uc_sigmask; pending_mask = context->uc_sigmask;
FILLBLOCKSET(&context->uc_sigmask); FILLBLOCKSET(&context->uc_sigmask);
#else
{
sigset_t temp;
sigemptyset(&temp);
pending_mask.__val[0] = context->uc_sigmask;
temp.__val[0] = context->uc_sigmask;
FILLBLOCKSET(&temp);
context->uc_sigmask = temp.__val[0];
}
#endif
SetSymbolValue(INTERRUPT_PENDING, T); SetSymbolValue(INTERRUPT_PENDING, T);
} else if ( } else if (
#if !(defined(i386) || defined(__x86_64)) #if !(defined(i386) || defined(__x86_64))
...@@ -398,42 +319,11 @@ maybe_now_maybe_later(HANDLER_ARGS) ...@@ -398,42 +319,11 @@ maybe_now_maybe_later(HANDLER_ARGS)
arch_pseudo_atomic_atomic(context)) { arch_pseudo_atomic_atomic(context)) {
pending_signal = signal; pending_signal = signal;
pending_code = DEREFCODE(code); pending_code = DEREFCODE(code);
#if !defined(__linux__) || (defined(__linux__) && (__GNU_LIBRARY__ < 6))
pending_mask = context->uc_sigmask; pending_mask = context->uc_sigmask;
FILLBLOCKSET(&context->uc_sigmask); FILLBLOCKSET(&context->uc_sigmask);
#else
{
sigset_t temp;
sigemptyset(&temp);
pending_mask.__val[0] = context->uc_sigmask;
temp.__val[0] = context->uc_sigmask;
FILLBLOCKSET(&temp);
context->uc_sigmask = temp.__val[0];
}
#endif
arch_set_pseudo_atomic_interrupted(context); arch_set_pseudo_atomic_interrupted(context);
} else { } else {
#if defined(__linux__) && (defined(i386) || defined(__x86_64))
/*
* Restore the FPU control word, setting the rounding mode to nearest.
*/
if (contextstruct.fpstate)
#if defined(__x86_64)
setfpucw(contextstruct.fpstate->cwd & ~0xc00);
#else
setfpucw(contextstruct.fpstate->cw & ~0xc00);
#endif
#endif
#if ( defined( __linux__ ) && ( defined( i386 ) || defined( __x86_64 ) ) )
interrupt_handle_now(signal, contextstruct);
#else
interrupt_handle_now(signal, code, context); interrupt_handle_now(signal, code, context);
#endif
} }
#if defined(DARWIN) && defined(__ppc__) #if defined(DARWIN) && defined(__ppc__)
...@@ -485,21 +375,12 @@ interrupt_maybe_gc(HANDLER_ARGS) ...@@ -485,21 +375,12 @@ interrupt_maybe_gc(HANDLER_ARGS)
if (arch_pseudo_atomic_atomic(context)) { if (arch_pseudo_atomic_atomic(context)) {
maybe_gc_pending = TRUE; maybe_gc_pending = TRUE;
if (pending_signal == 0) { if (pending_signal == 0) {
#if !defined(__linux__) || (defined(__linux__) && (__GNU_LIBRARY__ < 6)) #ifndef __linux__
pending_mask = context->uc_sigmask; pending_mask = context->uc_sigmask;
FILLBLOCKSET(&context->uc_sigmask);
#else #else
{ memcpy(&pending_mask, &context->uc_sigmask, NSIG / LONG_BIT);
sigset_t temp;
sigemptyset(&temp);
pending_mask.__val[0] = context->uc_sigmask;
temp.__val[0] = context->uc_sigmask;
FILLBLOCKSET(&temp);
context->uc_sigmask = temp.__val[0];
}
#endif #endif
FILLBLOCKSET(&context->uc_sigmask);
} }
arch_set_pseudo_atomic_interrupted(context); arch_set_pseudo_atomic_interrupted(context);
} else { } else {
......
/* /*
* main() entry point for a stand alone lisp image. * main() entry point for a stand alone lisp image.
* *
* $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/lisp.c,v 1.59 2007/07/24 19:09:14 rtoy Exp $ * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/lisp.c,v 1.60 2007/07/25 10:23:54 cshapiro Exp $
* *
*/ */
...@@ -46,10 +46,7 @@ ...@@ -46,10 +46,7 @@
static void static void
sigint_handler(HANDLER_ARGS) sigint_handler(HANDLER_ARGS)
{ {
#if ( defined( __linux__ ) && ( defined( i386 ) || defined ( __x86_64 ) ) ) SAVE_CONTEXT();
GET_CONTEXT
#endif
SAVE_CONTEXT();
printf("\nSIGINT hit at 0x%08lX\n", (unsigned long) SC_PC(context)); printf("\nSIGINT hit at 0x%08lX\n", (unsigned long) SC_PC(context));
ldb_monitor(); ldb_monitor();
......
/* x86-arch.c -*- Mode: C; comment-column: 40 -*- /* x86-arch.c -*- Mode: C; comment-column: 40 -*-
* *
* $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/x86-arch.c,v 1.27 2007/07/15 09:24:57 cshapiro Exp $ * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/x86-arch.c,v 1.28 2007/07/25 10:23:54 cshapiro Exp $
* *
*/ */
...@@ -142,7 +142,7 @@ arch_do_displaced_inst(os_context_t * context, unsigned long orig_inst) ...@@ -142,7 +142,7 @@ arch_do_displaced_inst(os_context_t * context, unsigned long orig_inst)
*((char *) pc + 1) = (orig_inst & 0xff00) >> 8; *((char *) pc + 1) = (orig_inst & 0xff00) >> 8;
#ifdef __linux__ #ifdef __linux__
context->eflags |= 0x100; context->uc_mcontext.gregs[REG_EFL] |= 0x100;
#else #else
/* /*
...@@ -171,13 +171,10 @@ sigtrap_handler(HANDLER_ARGS) ...@@ -171,13 +171,10 @@ sigtrap_handler(HANDLER_ARGS)
{ {
unsigned int trap; unsigned int trap;
#ifdef __linux__
GET_CONTEXT
#endif
#if 0 #if 0
fprintf(stderr, "x86sigtrap: %8x %x\n", fprintf(stderr, "x86sigtrap: %8x %x\n",
SC_PC(context), *(unsigned char *) (SC_PC(context) - 1)); SC_PC(context), *(unsigned char *) (SC_PC(context) - 1));
fprintf(stderr, "sigtrap(%d %d %x)\n", signal, code, context); fprintf(stderr, "sigtrap(%d %d %x)\n", signal, CODE(code), context);
#endif #endif
if (single_stepping && (signal == SIGTRAP)) { if (single_stepping && (signal == SIGTRAP)) {
...@@ -191,7 +188,7 @@ sigtrap_handler(HANDLER_ARGS) ...@@ -191,7 +188,7 @@ sigtrap_handler(HANDLER_ARGS)
*(single_stepping - 2) = single_step_save2; *(single_stepping - 2) = single_step_save2;
*(single_stepping - 1) = single_step_save3; *(single_stepping - 1) = single_step_save3;
#else #else
context->eflags ^= 0x100; context->uc_mcontext.gregs[REG_EFL] ^= 0x100;
#endif #endif
/* /*
...@@ -215,15 +212,6 @@ sigtrap_handler(HANDLER_ARGS) ...@@ -215,15 +212,6 @@ sigtrap_handler(HANDLER_ARGS)
/* This is just for info in case monitor wants to print an approx */ /* This is just for info in case monitor wants to print an approx */
current_control_stack_pointer = (unsigned long *) SC_SP(context); current_control_stack_pointer = (unsigned long *) SC_SP(context);
#if defined(__linux__) && defined(i386)
/*
* Restore the FPU control word, setting the rounding mode to nearest.
*/
if (contextstruct.fpstate)
setfpucw(contextstruct.fpstate->cw & ~0xc00);
#endif
/* /*
* On entry %eip points just after the INT3 byte and aims at the * On entry %eip points just after the INT3 byte and aims at the
* 'kind' value (eg trap_Cerror). For error-trap and Cerror-trap a * 'kind' value (eg trap_Cerror). For error-trap and Cerror-trap a
...@@ -259,12 +247,8 @@ sigtrap_handler(HANDLER_ARGS) ...@@ -259,12 +247,8 @@ sigtrap_handler(HANDLER_ARGS)
case trap_Error: case trap_Error:
case trap_Cerror: case trap_Cerror:
DPRINTF(0, (stderr, "<trap Error %p>\n", code)); DPRINTF(0, (stderr, "<trap Error %x>\n", CODE(code)));
#ifdef __linux__
interrupt_internal_error(signal, contextstruct, code == trap_Cerror);
#else
interrupt_internal_error(signal, code, context, CODE(code) == trap_Cerror); interrupt_internal_error(signal, code, context, CODE(code) == trap_Cerror);
#endif
break; break;
case trap_Breakpoint: case trap_Breakpoint:
...@@ -273,7 +257,7 @@ sigtrap_handler(HANDLER_ARGS) ...@@ -273,7 +257,7 @@ sigtrap_handler(HANDLER_ARGS)
#endif #endif
SC_PC(context) -= 1; SC_PC(context) -= 1;
handle_breakpoint(signal, code, context); handle_breakpoint(signal, CODE(code), context);
#if 0 #if 0
fprintf(stderr, "*C break return\n"); fprintf(stderr, "*C break return\n");
#endif #endif
...@@ -282,7 +266,7 @@ sigtrap_handler(HANDLER_ARGS) ...@@ -282,7 +266,7 @@ sigtrap_handler(HANDLER_ARGS)
case trap_FunctionEndBreakpoint: case trap_FunctionEndBreakpoint:
SC_PC(context) -= 1; SC_PC(context) -= 1;
SC_PC(context) = SC_PC(context) =
(int) handle_function_end_breakpoint(signal, code, context); (int) handle_function_end_breakpoint(signal, CODE(code), context);
break; break;
#ifdef trap_DynamicSpaceOverflowWarning #ifdef trap_DynamicSpaceOverflowWarning
...@@ -303,11 +287,7 @@ sigtrap_handler(HANDLER_ARGS) ...@@ -303,11 +287,7 @@ sigtrap_handler(HANDLER_ARGS)
DPRINTF(0, DPRINTF(0,
(stderr, "[C--trap default %d %d %p]\n", signal, CODE(code), (stderr, "[C--trap default %d %d %p]\n", signal, CODE(code),
context)); context));
#ifdef __linux__
interrupt_handle_now(signal, contextstruct);
#else
interrupt_handle_now(signal, code, context); interrupt_handle_now(signal, code, context);
#endif
break; break;
} }
} }
......
/* x86-lispregs.h -*- Mode: C; -*- /* x86-lispregs.h -*- Mode: C; -*-
* $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/x86-lispregs.h,v 1.8 2007/07/18 09:45:03 cshapiro Exp $ * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/x86-lispregs.h,v 1.9 2007/07/25 10:23:54 cshapiro Exp $
*/ */
#ifndef _X86_LISPREGS_H_ #ifndef _X86_LISPREGS_H_
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
#define SC_PC(sc) ((sc)->uc_mcontext.mc_eip) #define SC_PC(sc) ((sc)->uc_mcontext.mc_eip)
#define SC_SP(sc) SC_REG(sc, reg_ESP) #define SC_SP(sc) SC_REG(sc, reg_ESP)
#elif defined(__linux__) #elif defined(__linux__)
#define SC_PC(sc) ((sc)->eip) #define SC_PC(sc) ((sc)->uc_mcontext.gregs[REG_EIP])
#define SC_SP(sc) SC_REG(sc, reg_ESP) #define SC_SP(sc) SC_REG(sc, reg_ESP)
#endif #endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment