/* -*-C-*-
-$Id: uxsig.c,v 1.40 2005/06/26 04:34:48 cph Exp $
+$Id: uxsig.c,v 1.41 2005/06/27 06:03:21 cph Exp $
Copyright 1990,1991,1992,1993,1994,1996 Massachusetts Institute of Technology
Copyright 2000,2001,2005 Massachusetts Institute of Technology
#ifdef HAVE_POSIX_SIGNALS
+#ifdef _POSIX_REALTIME_SIGNALS
+# define SIGACT_HANDLER(act) ((act) -> sa_sigaction)
+#else
+# define SIGACT_HANDLER(act) ((act) -> sa_handler)
+# ifndef SA_SIGINFO
+# define SA_SIGINFO 0
+# endif
+#endif
+
static Tsignal_handler
DEFUN (current_handler, (signo), int signo)
{
struct sigaction act;
UX_sigaction (signo, 0, (&act));
- return (act . sa_handler);
+ return (SIGACT_HANDLER (&act));
}
-#ifndef SA_SIGINFO
-#define SA_SIGINFO 0
-#endif
-
void
DEFUN (INSTALL_HANDLER, (signo, handler),
int signo AND
Tsignal_handler handler)
{
struct sigaction act;
- (act . sa_handler) = handler;
+ if ((handler == ((Tsignal_handler) SIG_IGN))
+ || (handler == ((Tsignal_handler) SIG_DFL)))
+ {
+ (act . sa_handler) = ((PTR) handler);
+ (act . sa_flags) = 0;
+ }
+ else
+ {
+ (SIGACT_HANDLER (&act)) = handler;
+ (act . sa_flags) = SA_SIGINFO;
+ }
UX_sigemptyset (& (act . sa_mask));
UX_sigaddset ((& (act . sa_mask)), signo);
- (act . sa_flags) = SA_SIGINFO;
UX_sigaction (signo, (&act), 0);
}
void
DEFUN (deactivate_handler, (signo), int signo)
{
- INSTALL_HANDLER (signo, SIG_IGN);
+ INSTALL_HANDLER (signo, ((Tsignal_handler) SIG_IGN));
}
void
tty_set_next_interrupt_char (CONTROL_B_INTERRUPT_CHAR);
})
-static void EXFUN (interactive_interrupt_handler, (FULL_SIGCONTEXT_T * scp));
+static void EXFUN (interactive_interrupt_handler, (SIGCONTEXT_T * scp));
static
DEFUN_STD_HANDLER (sighnd_interactive,
/* Temporarily unbind this handler. */
handler = (current_handler (signo));
- INSTALL_HANDLER (signo, SIG_DFL);
+ INSTALL_HANDLER (signo, ((Tsignal_handler) SIG_DFL));
/* Perform the default action for this signal. */
UX_sigemptyset (&signo_mask);
int signo AND
Tsignal_handler handler)
{
- Tsignal_handler
- old_handler = ((signo == 0) ? SIG_DFL : (current_handler (signo)));
+ Tsignal_handler old_handler
+ = ((signo == 0)
+ ? ((Tsignal_handler) SIG_DFL)
+ : (current_handler (signo)));
if ((signo != 0)
- && ((old_handler == SIG_DFL)
- || ((old_handler == SIG_IGN) && (signo == SIGCHLD)))
+ && ((old_handler == ((Tsignal_handler) SIG_DFL))
+ || ((old_handler == ((Tsignal_handler) SIG_IGN))
+ && (signo == SIGCHLD)))
&& ((handler != ((Tsignal_handler) sighnd_stop))
|| (UX_SC_JOB_CONTROL ())))
INSTALL_HANDLER (signo, handler);
/* If this signal is ignored, then the system call that would have
caused it will return EPIPE instead. This is much easier for us
to handle. */
- bind_handler (SIGPIPE, SIG_IGN);
+ bind_handler (SIGPIPE, ((Tsignal_handler) SIG_IGN));
if ((isatty (STDIN_FILENO)) || option_emacs_subprocess)
{
if (getenv ("USE_SCHEMATIK_STYLE_INTERRUPTS"))
unblock_all_signals ();
/* SIGPIPE was ignored above; we must set it back to the default
because some programs depend on this. */
- INSTALL_HANDLER (SIGPIPE, SIG_DFL);
+ INSTALL_HANDLER (SIGPIPE, ((Tsignal_handler) SIG_DFL));
}
\f
/* Interactive Interrupt Handler */
static void EXFUN (print_interactive_help, (void));
static void EXFUN (print_interrupt_chars, (void));
static void EXFUN (examine_memory, (void));
-static void EXFUN (reset_query, (FULL_SIGCONTEXT_T * scp));
+static void EXFUN (reset_query, (SIGCONTEXT_T * scp));
static void EXFUN (interactive_back_trace, (void));
#define INTERACTIVE_NEWLINE() \
}
static void
-DEFUN (interactive_interrupt_handler, (scp), FULL_SIGCONTEXT_T * scp)
+DEFUN (interactive_interrupt_handler, (scp), SIGCONTEXT_T * scp)
{
if (!option_emacs_subprocess)
{
}
static void
-DEFUN (reset_query, (scp), FULL_SIGCONTEXT_T * scp)
+DEFUN (reset_query, (scp), SIGCONTEXT_T * scp)
{
putc ('\n', stdout);
fflush (stdout);
struct sigaction act;
struct sigaction oact;
- (act . sa_handler) = handler;
+ (SIGACT_HANDLER (&act)) = handler;
UX_sigemptyset (& (act . sa_mask));
(act . sa_flags) = (SA_RESETHAND | SA_NODEFER);
- if (handler == SIG_IGN)
+ if (handler == ((Tsignal_handler) SIG_IGN))
(act . sa_flags) |= SA_NOCLDWAIT;
if ((UX_sigaction (signo, (&act), (&oact))) < 0)
return (SIG_ERR);
else
- return (oact . sa_handler);
+ return (SIGACT_HANDLER (&oact));
}
/* It is best to reinstall the SIGCHLD handler after `grantpt' is
/* -*-C-*-
-$Id: uxtrap.c,v 1.40 2005/06/26 04:35:03 cph Exp $
+$Id: uxtrap.c,v 1.41 2005/06/27 06:03:36 cph Exp $
Copyright 1990,1991,1992,1993,1995,1997 Massachusetts Institute of Technology
Copyright 2000,2001,2002,2003,2005 Massachusetts Institute of Technology
#ifdef HAS_COMPILER_SUPPORT
# include "gccode.h"
-#endif
-
-#if defined(HAVE_STRUCT_SIGCONTEXT) && defined(HAS_COMPILER_SUPPORT) && !defined(USE_STACKLETS)
-# define ENABLE_TRAP_RECOVERY 1
+# if defined(HAVE_SIGCONTEXT) && !defined(USE_STACKLETS)
+# define ENABLE_TRAP_RECOVERY 1
+# endif
#endif
extern CONST char * EXFUN (find_signal_name, (int signo));
i += 1; \
}
+#define DECLARE_GENERIC_SIGNAL_CODE(v, n) \
+ DECLARE_UX_SIGNAL_CODE ((-1), (~ 0L), v, n)
+
enum pc_location
{
pcl_heap,
static enum trap_state saved_trap_state;
static int saved_signo;
static SIGINFO_T saved_info;
-static DECLARE_FULL_SIGCONTEXT (saved_scp);
+static SIGCONTEXT_T * saved_scp;
static void EXFUN
- (continue_from_trap, (int, SIGINFO_T, FULL_SIGCONTEXT_T *));
+ (continue_from_trap, (int, SIGINFO_T, SIGCONTEXT_T *));
static SCHEME_OBJECT * EXFUN (find_heap_address, (unsigned long));
static SCHEME_OBJECT * EXFUN (find_constant_address, (unsigned long));
static void EXFUN
(setup_trap_frame, (int,
SIGINFO_T,
- FULL_SIGCONTEXT_T *,
+ SIGCONTEXT_T *,
struct trap_recovery_info *,
SCHEME_OBJECT *));
static void EXFUN (initialize_ux_signal_codes, (void));
static SCHEME_OBJECT EXFUN
- (find_signal_code_name, (int, SIGINFO_T, FULL_SIGCONTEXT_T *));
+ (find_signal_code_name, (int, SIGINFO_T, SIGCONTEXT_T *));
static enum pc_location EXFUN
(classify_pc, (unsigned long, SCHEME_OBJECT **, unsigned int *));
}
void
-DEFUN (hard_reset, (scp), FULL_SIGCONTEXT_T * scp)
+DEFUN (hard_reset, (scp), SIGCONTEXT_T * scp)
{
/* 0 is an invalid signal, it means a user requested reset. */
continue_from_trap (0, 0, scp);
CONST char * message AND
int signo AND
SIGINFO_T info AND
- FULL_SIGCONTEXT_T * scp)
+ SIGCONTEXT_T * scp)
{
int code = ((SIGINFO_VALID_P (info)) ? (SIGINFO_CODE (info)) : 0);
Boolean stack_overflowed_p = (STACK_OVERFLOWED_P ());
DEFUN (continue_from_trap, (signo, info, scp),
int signo AND
SIGINFO_T info AND
- FULL_SIGCONTEXT_T * scp)
+ SIGCONTEXT_T * scp)
{
- unsigned long pc = (FULL_SIGCONTEXT_PC (scp));
+ unsigned long pc = (SIGCONTEXT_PC (scp));
SCHEME_OBJECT primitive = (Registers[REGBLOCK_PRIMITIVE]);
SCHEME_OBJECT * block_addr;
int index;
case pcl_heap:
case pcl_constant:
- new_sp = ((SCHEME_OBJECT *) (FULL_SIGCONTEXT_SCHSP (scp)));
- Free = ((SCHEME_OBJECT *) (FULL_SIGCONTEXT_RFREE (scp)));
+ new_sp = ((SCHEME_OBJECT *) (SIGCONTEXT_SCHSP (scp)));
+ Free = ((SCHEME_OBJECT *) (SIGCONTEXT_RFREE (scp)));
SET_RECOVERY_INFO
(STATE_COMPILED_CODE,
(MAKE_POINTER_OBJECT (TC_COMPILED_CODE_BLOCK, block_addr)),
break;
case pcl_builtin:
- new_sp = ((SCHEME_OBJECT *) (FULL_SIGCONTEXT_SCHSP (scp)));
- Free = ((SCHEME_OBJECT *) (FULL_SIGCONTEXT_RFREE (scp)));
+ new_sp = ((SCHEME_OBJECT *) (SIGCONTEXT_SCHSP (scp)));
+ Free = ((SCHEME_OBJECT *) (SIGCONTEXT_RFREE (scp)));
SET_RECOVERY_INFO
(STATE_BUILTIN,
(LONG_TO_UNSIGNED_FIXNUM (index)),
(recovery_info . extra_trap_info) =
(MAKE_POINTER_OBJECT (TC_NON_MARKED_VECTOR, Free));
(*Free++) =
- (MAKE_OBJECT (TC_MANIFEST_NM_VECTOR, (2 + FULL_SIGCONTEXT_NREGS)));
+ (MAKE_OBJECT (TC_MANIFEST_NM_VECTOR, (2 + SIGCONTEXT_NREGS)));
(*Free++) = ((SCHEME_OBJECT) pc);
- (*Free++) = ((SCHEME_OBJECT) (FULL_SIGCONTEXT_SP (scp)));
+ (*Free++) = ((SCHEME_OBJECT) (SIGCONTEXT_SP (scp)));
{
unsigned long * scan
- = ((unsigned long *) (FULL_SIGCONTEXT_FIRST_REG (scp)));
- unsigned long * end = (scan + FULL_SIGCONTEXT_NREGS);
+ = ((unsigned long *) (SIGCONTEXT_FIRST_REG (scp)));
+ unsigned long * end = (scan + SIGCONTEXT_NREGS);
while (scan < end)
(*Free++) = ((SCHEME_OBJECT) (*scan++));
}
DEFUN (continue_from_trap, (signo, info, scp),
int signo AND
SIGINFO_T info AND
- FULL_SIGCONTEXT_T * scp)
+ SIGCONTEXT_T * scp)
{
if (Free < MemTop)
Free = MemTop;
DEFUN (setup_trap_frame, (signo, info, scp, trinfo, new_stack_pointer),
int signo AND
SIGINFO_T info AND
- FULL_SIGCONTEXT_T * scp AND
+ SIGCONTEXT_T * scp AND
struct trap_recovery_info * trinfo AND
SCHEME_OBJECT * new_stack_pointer)
{
{
unsigned int i = 0;
INITIALIZE_UX_SIGNAL_CODES ();
- DECLARE_UX_SIGNAL_CODE (0, 0, 0, ((char *) 0));
+
+#ifdef _POSIX_REALTIME_SIGNALS
+ DECLARE_GENERIC_SIGNAL_CODE
+ (SI_USER, "signal sent by kill");
+ DECLARE_GENERIC_SIGNAL_CODE
+ (SI_QUEUE, "signal sent by sigqueue");
+ DECLARE_GENERIC_SIGNAL_CODE
+ (SI_TIMER, "signal generated by timer expiration");
+ DECLARE_GENERIC_SIGNAL_CODE
+ (SI_ASYNCIO, "signal generated by asynchronous I/O completion");
+ DECLARE_GENERIC_SIGNAL_CODE
+ (SI_MESGQ, "signal generated by message queue arrival");
+#endif /* _POSIX_REALTIME_SIGNALS */
+
+ DECLARE_UX_SIGNAL_CODE (0, 0, 0, 0);
}
static SCHEME_OBJECT
DEFUN (find_signal_code_name, (signo, info, scp),
int signo AND
SIGINFO_T info AND
- FULL_SIGCONTEXT_T * scp)
+ SIGCONTEXT_T * scp)
{
unsigned long code = 0;
char * name = 0;
{
struct ux_sig_code_desc * entry = (& (ux_signal_codes[0]));
while ((entry -> signo) != 0)
- if (((entry -> signo) == signo)
+ if ((((entry -> signo) < 0) || ((entry -> signo) == signo))
&& (((entry -> code_mask) & code) == (entry -> code_value)))
{
name = (entry -> name);
/* -*-C-*-
-$Id: uxtrap.h,v 1.34 2005/06/26 04:35:11 cph Exp $
+$Id: uxtrap.h,v 1.35 2005/06/27 06:03:43 cph Exp $
Copyright 1990,1991,1992,1993,1996,1998 Massachusetts Institute of Technology
Copyright 2000,2001,2004,2005 Massachusetts Institute of Technology
#include <machine/sendsig.h>
#include <machine/reg.h>
-#define FULL_SIGCONTEXT_NREGS GPR_REGS /* Missing sp */
-
-#define RFREE AR5
-#define SIGCONTEXT_T struct full_sigcontext
+#define HAVE_SIGCONTEXT
+#define SIGCONTEXT_ARG_T struct full_sigcontext
+#define SIGCONTEXT_NREGS GPR_REGS /* Missing sp */
+#define SIGCONTEXT_FIRST_REG(scp) (&((scp)->fs_regs[GPR_START]))
#define SIGCONTEXT_SP(scp) ((scp)->fs_context.sc_sp)
#define SIGCONTEXT_PC(scp) ((scp)->fs_context.sc_pc)
-#define FULL_SIGCONTEXT_RFREE(scp) ((scp)->fs_regs[RFREE])
-#define FULL_SIGCONTEXT_FIRST_REG(scp) (&((scp)->fs_regs[GPR_START]))
+#define SIGCONTEXT_RFREE(scp) ((scp)->fs_regs[AR5])
#define INITIALIZE_UX_SIGNAL_CODES() \
{ \
They should be masked away before looking at the PC.
*/
-#define PC_VALUE_MASK ((~0) << 2)
+#define PC_VALUE_MASK ((~0) << 2)
/* pcoq is the offset (32 bit in 64 bit virtual address space)
in the space included in the corresponding sc_pcsq.
#ifdef __HPUX__
-/* HPUX 09.x does not have siginfo, but HPUX 10.x does. This can be
-tested by the definition of SA_SIGINFO. Since we want to support
-both, we use the no-siginfo way */
+/* HPUX 9.x does not have siginfo, but HPUX 10.x does. This can be
+ tested by the definition of SA_SIGINFO. Since we want to support
+ both, we use the no-siginfo way. */
#ifdef SA_SIGINFO
-#undef SA_SIGINFO
+# undef SA_SIGINFO
#endif
-# include <sys/sysmacros.h>
+#include <sys/sysmacros.h>
/* See <machine/save_state.h> included by <signal.h> */
+#ifndef sc_pc
+# define sc_pc sc_pcoq_head
+#endif
-# ifndef sc_pc
-# define sc_pc sc_pcoq_head
-# endif /* sc_pc */
-
-# define ss_gr0 ss_flags /* not really true */
-# define ss_rfree ss_gr21 /* or some such */
-# define ss_schsp ss_gr22
+#define ss_gr0 ss_flags /* not really true */
-# define FULL_SIGCONTEXT_RFREE(scp) ((scp)->sc_sl.sl_ss.ss_rfree)
-# define FULL_SIGCONTEXT_SCHSP(scp) ((scp)->sc_sl.sl_ss.ss_schsp)
-# define FULL_SIGCONTEXT_FIRST_REG(scp) (&((scp)->sc_sl.sl_ss.ss_gr0))
-# define FULL_SIGCONTEXT_NREGS 32
+#define HAVE_SIGCONTEXT
+#define SIGCONTEXT_ARG_T struct sigcontext
+#define SIGCONTEXT_NREGS 32
+#define SIGCONTEXT_FIRST_REG(scp) (&((scp)->sc_sl.sl_ss.ss_gr0))
+#define SIGCONTEXT_SP(scp) ((scp) -> sc_sp)
+#define SIGCONTEXT_PC(scp) ((scp) -> sc_pc)
+#define SIGCONTEXT_RFREE(scp) ((scp)->sc_sl.sl_ss.ss_gr21)
+#define SIGCONTEXT_SCHSP(scp) ((scp)->sc_sl.sl_ss.ss_gr22)
# define INITIALIZE_UX_SIGNAL_CODES() \
{ \
\f
#ifdef sun3
-#define FULL_SIGCONTEXT_NREGS 15 /* missing sp */
-
struct full_sigcontext
{
struct sigcontext * fs_original;
- int fs_regs[FULL_SIGCONTEXT_NREGS];
+ unsigned long fs_regs [SIGCONTEXT_NREGS];
};
-#define RFREE (8 + 5) /* A5 */
-#define FULL_SIGCONTEXT_T struct full_sigcontext
-#define FULL_SIGCONTEXT_SP(scp) (scp->fs_original->sc_sp)
-#define FULL_SIGCONTEXT_PC(scp) (scp->fs_original->sc_pc)
-#define FULL_SIGCONTEXT_RFREE(scp) (scp->fs_regs[RFREE])
-#define FULL_SIGCONTEXT_FIRST_REG(scp) (&((scp)->fs_regs[0]))
-
-#define DECLARE_FULL_SIGCONTEXT(name) FULL_SIGCONTEXT_T name [1]
-
-#define INITIALIZE_FULL_SIGCONTEXT(partial, full) \
-{ \
- static void EXFUN (sun3_save_regs, (int * regs)); \
- sun3_save_regs (& ((((full) [0]) . fs_regs) [0])); \
- (((full) [0]) . fs_original) = (partial); \
-}
+#define HAVE_SIGCONTEXT
+#define SIGCONTEXT_ARG_T struct sigcontext
+#define SIGCONTEXT_T struct full_sigcontext
+#define SIGCONTEXT_NREGS 15 /* missing sp */
+#define SIGCONTEXT_FIRST_REG(scp) (& (((scp) -> fs_regs) [0]))
+#define SIGCONTEXT_SP(scp) ((scp)->fs_original->sc_sp)
+#define SIGCONTEXT_PC(scp) ((scp)->fs_original->sc_pc)
+#define SIGCONTEXT_RFREE(scp) (((scp) -> fs_regs) [8 + 5]) /* A5 */
+
+#define DECLARE_SIGCONTEXT(scp, arg) \
+ SIGCONTEXT_T scp [1]; \
+ static void EXFUN (sun3_save_regs, (int *)); \
+ sun3_save_regs (& ((((scp) [0]) . fs_regs) [0])); \
+ (((scp) [0]) . fs_original) = (arg)
#endif /* sun3 */
#ifdef vax
-#define FULL_SIGCONTEXT_NREGS 16
-
struct full_sigcontext
{
struct sigcontext * fs_original;
- int fs_regs [FULL_SIGCONTEXT_NREGS];
+ int fs_regs [SIGCONTEXT_NREGS];
};
-#define RFREE 12 /* fp */
-#define FULL_SIGCONTEXT_T struct full_sigcontext
-#define FULL_SIGCONTEXT_SP(scp) ((scp)->fs_original->sc_sp)
-#define FULL_SIGCONTEXT_PC(scp) ((scp)->fs_original->sc_pc)
-#define FULL_SIGCONTEXT_RFREE(scp) ((scp)->fs_regs[RFREE])
-#define FULL_SIGCONTEXT_FIRST_REG(scp) (&((scp)->fs_regs[0]))
-
-#define DECLARE_FULL_SIGCONTEXT(name) FULL_SIGCONTEXT_T name [1]
+#define HAVE_SIGCONTEXT
+#define SIGCONTEXT_ARG_T struct sigcontext
+#define SIGCONTEXT_T struct full_sigcontext
+#define SIGCONTEXT_NREGS 16
+#define SIGCONTEXT_FIRST_REG(scp) (&((scp)->fs_regs[0]))
+#define SIGCONTEXT_SP(scp) ((scp)->fs_original->sc_sp)
+#define SIGCONTEXT_PC(scp) ((scp)->fs_original->sc_pc)
+#define SIGCONTEXT_RFREE(scp) ((scp)->fs_regs[12]) /* fp */
/* r0 has to be kludged. */
-
-#define INITIALIZE_FULL_SIGCONTEXT(partial, full) \
-{ \
+#define DECLARE_SIGCONTEXT(partial, full) \
+ SIGCONTEXT_T scp [1]; \
static int EXFUN (vax_get_r0, (void)); \
- static int * EXFUN (vax_save_start, (int * regs, int r0)); \
+ static int * EXFUN (vax_save_start, (int *, int)); \
static void EXFUN \
- (vax_save_finish, (int * fp, \
- struct sigcontext * pscp, \
- struct full_sigcontext * scp)); \
+ (vax_save_finish, (int *, \
+ struct sigcontext *, \
+ struct full_sigcontext *)); \
vax_save_finish ((vax_save_start ((& ((((full) [0]) . fs_regs) [0])), \
(vax_get_r0 ()))), \
(partial), \
- (&(full)[0])); \
-}
+ (&(full)[0]))
#endif /* vax */
\f
/* Information on sigcontext structure in signal.h */
-#ifndef sc_sp
-#define sc_sp sc_regs[29]
-#endif
-
-#define sc_rfree sc_regs[9]
-#define sc_schsp sc_regs[3]
-
-#define FULL_SIGCONTEXT_RFREE(scp) ((scp)->sc_rfree)
-#define FULL_SIGCONTEXT_SCHSP(scp) ((scp)->sc_schsp)
-#define FULL_SIGCONTEXT_FIRST_REG(scp) (&((scp)->sc_regs[0]))
-#define FULL_SIGCONTEXT_NREGS 32
+#define HAVE_SIGCONTEXT
+#define SIGCONTEXT_ARG_T struct sigcontext
+#define SIGCONTEXT_NREGS 32
+#define SIGCONTEXT_FIRST_REG(scp) (& (((scp) -> sc_regs) [0]))
+#define SIGCONTEXT_SP(scp) (((scp) -> sc_regs) [29])
+#define SIGCONTEXT_PC(scp) ((scp) -> sc_pc)
+#define SIGCONTEXT_RFREE(scp) (((scp) -> sc_regs) [9])
+#define SIGCONTEXT_SCHSP(scp) (((scp) -> sc_regs) [3])
#define INITIALIZE_UX_SIGNAL_CODES() \
{ \
#else /* not __IRIX__ */
#ifndef _SYSV4
-/* Information on sigcontext structure in signal.h */
-
-#ifndef sc_sp
-#define sc_sp sc_regs[29]
-#endif
-
-#define sc_rfree sc_regs[9]
-#define sc_schsp sc_regs[3]
-
-#define FULL_SIGCONTEXT_RFREE(scp) ((scp)->sc_rfree)
-#define FULL_SIGCONTEXT_SCHSP(scp) ((scp)->sc_schsp)
-#define FULL_SIGCONTEXT_FIRST_REG(scp) (&((scp)->sc_regs[0]))
-#define FULL_SIGCONTEXT_NREGS 32
+#define HAVE_SIGCONTEXT
+#define SIGCONTEXT_ARG_T struct sigcontext
+#define SIGCONTEXT_NREGS 32
+#define SIGCONTEXT_FIRST_REG(scp) (& (((scp) -> sc_regs) [0]))
+#define SIGCONTEXT_SP(scp) (((scp) -> sc_regs) [29])
+#define SIGCONTEXT_PC(scp) ((scp) -> sc_pc)
+#define SIGCONTEXT_RFREE(scp) (((scp) -> sc_regs) [9])
+#define SIGCONTEXT_SCHSP(scp) (((scp) -> sc_regs) [3])
#define INITIALIZE_UX_SIGNAL_CODES() \
{ \
/* For Sony NEWS-OS 5.0.1 and earlier: */
#if defined(sonyrisc) && !defined(_CFE)
-#define gregs gpregs
+# define gregs gpregs
#endif
#define SIGINFO_T siginfo_t *
#define SIGINFO_VALID_P(info) ((info) != 0)
#define SIGINFO_CODE(info) ((info) -> si_code)
-#define SIGCONTEXT_T ucontext_t
-#define SIGCONTEXT_SP(scp) ((((scp) -> uc_mcontext) . gregs) [CXT_SP])
-#define SIGCONTEXT_PC(scp) ((((scp) -> uc_mcontext) . gregs) [CXT_EPC])
+#define __SIGCONTEXT_REG(scp, ir) ((((scp) -> uc_mcontext) . gregs) [(ir)])
-#define FULL_SIGCONTEXT_RFREE(scp) ((((scp) -> uc_mcontext) . gregs) [CXT_T1])
-#define FULL_SIGCONTEXT_SCHSP(scp) ((((scp) -> uc_mcontext) . gregs) [CXT_V1])
-#define FULL_SIGCONTEXT_FIRST_REG(scp) (((scp) -> uc_mcontext) . gregs)
-#define FULL_SIGCONTEXT_NREGS NGREG
+#define HAVE_SIGCONTEXT
+#define SIGCONTEXT_ARG_T void
+#define SIGCONTEXT_T ucontext_t
+#define SIGCONTEXT_NREGS NGREG
+#define SIGCONTEXT_FIRST_REG(scp) (& (__SIGCONTEXT_REG (scp, 0)))
+#define SIGCONTEXT_SP(scp) (__SIGCONTEXT_REG (scp, CXT_SP))
+#define SIGCONTEXT_PC(scp) (__SIGCONTEXT_REG (scp, CXT_EPC))
+#define SIGCONTEXT_RFREE(scp) (__SIGCONTEXT_REG (scp, CXT_T1))
+#define SIGCONTEXT_SCHSP(scp) (__SIGCONTEXT_REG (scp, CXT_V1))
#define INITIALIZE_UX_SIGNAL_CODES() \
{ \
#ifdef __linux__
-#define SIGINFO_T siginfo_t *
-#define SIGINFO_VALID_P(info) ((info) != 0)
-#define SIGINFO_CODE(info) ((info) -> si_code)
+/* This isn't really the right test: what we really want to know is if
+ the kernel supports the newer signal-delivery mechanism. */
-#define SIGCONTEXT_T ucontext_t
-#define __SIGCONTEXT_REG(scp, ir) \
- ((unsigned long) ((((scp) -> uc_mcontext) . gregs) [(ir)]))
+#ifdef _POSIX_REALTIME_SIGNALS
+
+#define __SIGCONTEXT_REG(scp, ir) ((((scp) -> uc_mcontext) . gregs) [(ir)])
+#define HAVE_SIGCONTEXT
+#define SIGCONTEXT_NREGS NGREG
+#define SIGCONTEXT_FIRST_REG(scp) (& (__SIGCONTEXT_REG (scp, REG_GS)))
#define SIGCONTEXT_SP(scp) (__SIGCONTEXT_REG (scp, REG_ESP))
#define SIGCONTEXT_PC(scp) (__SIGCONTEXT_REG (scp, REG_EIP))
-
-/* Grab them all. Nobody looks at them, but grab them anyway. */
-#define FULL_SIGCONTEXT_NREGS NGREG
-#define FULL_SIGCONTEXT_FIRST_REG(scp) (((scp) -> uc_mcontext) . gregs)
-#define FULL_SIGCONTEXT_RFREE(scp) (__SIGCONTEXT_REG (scp, REG_EDI))
+#define SIGCONTEXT_RFREE(scp) (__SIGCONTEXT_REG (scp, REG_EDI))
#define INITIALIZE_UX_SIGNAL_CODES() \
{ \
(SIGILL, (~ 0L), ILL_BADSTK, "bad stack trap"); \
}
+#else /* not _POSIX_REALTIME_SIGNALS */
+
+/* In Linux 2.0 and earlier, signal handlers are called with one
+ argument. There's an "iBCS2 signal stack" register dump just above
+ it. Thus, the fictitious `info' argument to the handler is
+ actually the first member of this register dump (described by
+ linux_sigcontext_t, below). Unfortunately, kludging SIGINFO_CODE
+ to access the sc_trapno will fail later on when looking at the
+ saved_info. */
+
+typedef struct
+{
+ unsigned short gs, __gsh;
+ unsigned short fs, __fsh;
+ unsigned short es, __esh;
+ unsigned short ds, __dsh;
+ unsigned long edi;
+ unsigned long esi;
+ unsigned long ebp;
+ unsigned long esp;
+ unsigned long ebx;
+ unsigned long edx;
+ unsigned long ecx;
+ unsigned long eax;
+ unsigned long trapno;
+ unsigned long err;
+ unsigned long eip;
+ unsigned short cs, __csh;
+ unsigned long eflags;
+ unsigned long esp_at_signal;
+ unsigned short ss, __ssh;
+ void * fpstate;
+} linux_sigcontext_t;
+
+#define HAVE_SIGCONTEXT
+#define SIGCONTEXT_T linux_sigcontext_t
+#define SIGCONTEXT_NREGS 19
+#define SIGCONTEXT_FIRST_REG(scp) (scp)
+#define SIGCONTEXT_SP(scp) ((scp) -> esp)
+#define SIGCONTEXT_PC(scp) ((scp) -> eip)
+#define SIGCONTEXT_RFREE(scp) ((scp) -> edi)
+
+/* DECLARE_SIGCONTEXT gives us a chance to generate a pointer to the
+ register dump, since it is used at the beginning of STD_HANDLER's.
+ In terms of the expected arguments to the STD_ signal HANDLER's,
+ the register dump is right above `signo', at `info', one long below
+ `pscp', which is what DECLARE_SIGCONTEXT is getting for `arg'.
+ Thus, our pointer to a scp is initialized to the address of `arg'
+ minus 1 long. */
+
+#define DECLARE_SIGCONTEXT(scp, arg) \
+ SIGCONTEXT_T * scp; \
+ scp = ((SIGCONTEXT_T *) (((unsigned long *) (& (arg))) - 1))
+
+#endif /* not _POSIX_REALTIME_SIGNALS */
+
#endif /* __linux__ */
#ifdef _MACH_UNIX
/* The following are true for Mach (BSD 4.3 compatible).
I don't know about SCO or other versions. */
-#define FULL_SIGCONTEXT_NREGS 8
-
-#define SIGCONTEXT_T struct sigcontext
-#define SIGCONTEXT_SP(scp) ((scp)->sc_esp)
-#define SIGCONTEXT_PC(scp) ((scp)->sc_eip)
-#define FULL_SIGCONTEXT_RFREE(scp) ((scp)->sc_edi)
-#define FULL_SIGCONTEXT_FIRST_REG(scp) (&((scp)->sc_edi))
+#define HAVE_SIGCONTEXT
+#define SIGCONTEXT_ARG_T struct sigcontext
+#define SIGCONTEXT_NREGS 8
+#define SIGCONTEXT_FIRST_REG(scp) (& ((scp) -> sc_edi))
+#define SIGCONTEXT_SP(scp) ((scp) -> sc_esp)
+#define SIGCONTEXT_PC(scp) ((scp) -> sc_eip)
+#define SIGCONTEXT_RFREE(scp) ((scp) -> sc_edi)
/* INITIALIZE_UX_SIGNAL_CODES should be defined. */
\f
#ifdef __alpha
-#define sc_sp sc_regs[30]
-#define sc_rfree sc_regs[4]
-#define sc_schsp sc_regs[2]
-
-#define FULL_SIGCONTEXT_RFREE(scp) ((scp)->sc_rfree)
-#define FULL_SIGCONTEXT_SCHSP(scp) ((scp)->sc_schsp)
-#define FULL_SIGCONTEXT_FIRST_REG(scp) (&((scp)->sc_regs[0]))
-#define FULL_SIGCONTEXT_NREGS 32
+#define HAVE_SIGCONTEXT
+#define SIGCONTEXT_ARG_T struct sigcontext
+#define SIGCONTEXT_NREGS 32
+#define SIGCONTEXT_FIRST_REG(scp) (& (((scp) -> sc_regs) [0]))
+#define SIGCONTEXT_SP(scp) (((scp) -> sc_regs) [30])
+#define SIGCONTEXT_PC(scp) ((scp) -> sc_pc)
+#define SIGCONTEXT_RFREE(scp) (((scp) -> sc_regs) [4])
+#define SIGCONTEXT_SCHSP(scp) (((scp) -> sc_regs) [2])
#ifdef FPE_COMPLETE_FAULT
#define STUPID_FIRST_SIGNAL() \
}
#endif /* __alpha */
-
-#ifdef _AIX
-/* For now */
-# define SIGCONTEXT_T struct sigcontext
-# define SIGCONTEXT_SP(scp) 0
-# define SIGCONTEXT_PC(scp) 0
-#endif /* _AIX */
\f
+#ifdef _POSIX_REALTIME_SIGNALS
+# define SIGINFO_T siginfo_t *
+# define SIGINFO_VALID_P(info) (1)
+# define SIGINFO_CODE(info) ((info) -> si_code)
+# define SIGCONTEXT_ARG_T void
+# define SIGCONTEXT_T ucontext_t
+#endif
+
#ifndef SIGINFO_T
# define SIGINFO_T int
-# define SIGINFO_VALID_P(info) (1)
-# define SIGINFO_CODE(info) (info)
+# define SIGINFO_VALID_P(info) (0)
+# define SIGINFO_CODE(info) (0)
#endif
-#ifndef HAVE_STRUCT_SIGCONTEXT
- struct sigcontext { long sc_sp; long sc_pc; };
+#ifndef SIGCONTEXT_ARG_T
+# define SIGCONTEXT_ARG_T int
#endif
#ifndef SIGCONTEXT_T
-# define SIGCONTEXT_T struct sigcontext
-# define SIGCONTEXT_SP(scp) ((scp) -> sc_sp)
-# define SIGCONTEXT_PC(scp) ((scp) -> sc_pc)
+# define SIGCONTEXT_T SIGCONTEXT_ARG_T
+#endif
+
+#ifndef DECLARE_SIGCONTEXT
+# define DECLARE_SIGCONTEXT(scp, arg) \
+ SIGCONTEXT_T * scp; \
+ scp = ((SIGCONTEXT_T *) (arg))
+#endif
+
+#ifndef SIGCONTEXT_NREGS
+# define SIGCONTEXT_NREGS (0)
+#endif
+
+#ifndef SIGCONTEXT_FIRST_REG
+# define SIGCONTEXT_FIRST_REG(scp) (0)
#endif
-#ifndef FULL_SIGCONTEXT_T
-# define FULL_SIGCONTEXT_T SIGCONTEXT_T
-# define FULL_SIGCONTEXT_SP SIGCONTEXT_SP
-# define FULL_SIGCONTEXT_PC SIGCONTEXT_PC
-# define DECLARE_FULL_SIGCONTEXT(name) FULL_SIGCONTEXT_T * name
-# define INITIALIZE_FULL_SIGCONTEXT(partial, full) \
- ((full) = ((FULL_SIGCONTEXT_T *) (partial)))
+#ifndef SIGCONTEXT_SP
+# define SIGCONTEXT_SP(scp) (0)
#endif
-#ifndef FULL_SIGCONTEXT_NREGS
-# define FULL_SIGCONTEXT_NREGS 0
-# define FULL_SIGCONTEXT_FIRST_REG(scp) ((int *) 0)
+#ifndef SIGCONTEXT_PC
+# define SIGCONTEXT_PC(scp) (0)
#endif
-#ifndef FULL_SIGCONTEXT_RFREE
-# define FULL_SIGCONTEXT_RFREE ((unsigned long) MemTop)
+#ifndef SIGCONTEXT_RFREE
+# define SIGCONTEXT_RFREE ((unsigned long) MemTop)
#endif
-#ifndef FULL_SIGCONTEXT_SCHSP
-# define FULL_SIGCONTEXT_SCHSP FULL_SIGCONTEXT_SP
+#ifndef SIGCONTEXT_SCHSP
+# define SIGCONTEXT_SCHSP SIGCONTEXT_SP
#endif
#ifndef INITIALIZE_UX_SIGNAL_CODES
/* PCs must be aligned according to this. */
-#define PC_ALIGNMENT_MASK ((1 << PC_ZERO_BITS) - 1)
+#define PC_ALIGNMENT_MASK ((1 << PC_ZERO_BITS) - 1)
#ifndef HAS_COMPILER_SUPPORT
# define PLAUSIBLE_CC_BLOCK_P(block) 0
#endif
#ifndef ADDRESS_UCODE_P
-# define ADDRESS_UCODE_P(addr) 0
+# define ADDRESS_UCODE_P(addr) (0)
#endif
\f
/* Machine/OS-independent section */
extern void EXFUN (UX_initialize_trap_recovery, (void));
extern enum trap_state EXFUN (OS_set_trap_state, (enum trap_state state));
-extern void EXFUN (hard_reset, (FULL_SIGCONTEXT_T * scp));
+extern void EXFUN (hard_reset, (SIGCONTEXT_T * scp));
extern void EXFUN (soft_reset, (void));
extern void EXFUN
- (trap_handler, (CONST char *, int, SIGINFO_T, FULL_SIGCONTEXT_T *));
+ (trap_handler, (CONST char *, int, SIGINFO_T, SIGCONTEXT_T *));
extern SCHEME_OBJECT find_ccblock (unsigned long);
#define STATE_UNKNOWN (LONG_TO_UNSIGNED_FIXNUM (0))