signal.h revision 1.8
1/* $NetBSD: signal.h,v 1.8 2003/10/07 17:04:19 skd Exp $ */ 2 3/* 4 * Copyright (c) 1994, 1995 Carnegie-Mellon University. 5 * All rights reserved. 6 * 7 * Author: Chris G. Demetriou 8 * 9 * Permission to use, copy, modify and distribute this software and 10 * its documentation is hereby granted, provided that both the copyright 11 * notice and this permission notice appear in all copies of the 12 * software, derivative works or modified versions, and any portions 13 * thereof, and that both notices appear in supporting documentation. 14 * 15 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 16 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 17 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 18 * 19 * Carnegie Mellon requests users of this software to return to 20 * 21 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 22 * School of Computer Science 23 * Carnegie Mellon University 24 * Pittsburgh PA 15213-3890 25 * 26 * any improvements or extensions that they make and grant Carnegie the 27 * rights to redistribute these changes. 28 */ 29 30#ifndef _ALPHA_SIGNAL_H_ 31#define _ALPHA_SIGNAL_H_ 32 33#include <sys/featuretest.h> 34 35typedef long sig_atomic_t; 36 37#define __HAVE_SIGINFO 38 39#if defined(_NETBSD_SOURCE) 40/* 41 * Information pushed on stack when a signal is delivered. 42 * This is used by the kernel to restore state following 43 * execution of the signal handler. It is also made available 44 * to the handler to allow it to restore state properly if 45 * a non-standard exit is performed. 46 * 47 * Note that sc_regs[] and sc_fpregs[]+sc_fpcr are inline 48 * representations of 'struct reg' and 'struct fpreg', respectively. 49 */ 50#if defined(__LIBC12_SOURCE__) || defined(_KERNEL) 51struct sigcontext13 { 52 long sc_onstack; /* sigstack state to restore */ 53 long sc_mask; /* signal mask to restore (old style) */ 54 long sc_pc; /* pc to restore */ 55 long sc_ps; /* ps to restore */ 56 unsigned long sc_regs[32]; /* integer register set (see above) */ 57#define sc_sp sc_regs[R_SP] 58 long sc_ownedfp; /* fp has been used */ 59 unsigned long sc_fpregs[32]; /* FP register set (see above) */ 60 unsigned long sc_fpcr; /* FP control register (see above) */ 61 unsigned long sc_fp_control; /* FP software control word */ 62 long sc_reserved[2]; /* XXX */ 63 long sc_xxx[8]; /* XXX */ 64}; 65#endif /* __LIBC12_SOURCE__ || _KERNEL */ 66 67struct sigcontext { 68 long sc_onstack; /* sigstack state to restore */ 69 long __sc_mask13; /* signal mask to restore (old style) */ 70 long sc_pc; /* pc to restore */ 71 long sc_ps; /* ps to restore */ 72 unsigned long sc_regs[32]; /* integer register set (see above) */ 73#define sc_sp sc_regs[R_SP] 74 long sc_ownedfp; /* fp has been used */ 75 unsigned long sc_fpregs[32]; /* FP register set (see above) */ 76 unsigned long sc_fpcr; /* FP control register (see above) */ 77 unsigned long sc_fp_control; /* FP software control word */ 78 long sc_reserved[2]; /* XXX */ 79 long sc_xxx[8]; /* XXX */ 80 sigset_t sc_mask; /* signal mask to restore (new style) */ 81}; 82 83/* 84 * The following macros are used to convert from a ucontext to sigcontext, 85 * and vice-versa. This is for building a sigcontext to deliver to old-style 86 * signal handlers, and converting back (in the event the handler modifies 87 * the context). 88 */ 89#define _MCONTEXT_TO_SIGCONTEXT(uc, sc) \ 90do { \ 91 (sc)->sc_pc = (uc)->uc_mcontext.__gregs[_REG_PC]; \ 92 (sc)->sc_ps = (uc)->uc_mcontext.__gregs[_REG_PS]; \ 93 memcpy(&(sc)->sc_regs, &(uc)->uc_mcontext.__gregs, \ 94 31 * sizeof(unsigned long)); \ 95 if ((uc)->uc_flags & _UC_FPU) { \ 96 (sc)->sc_ownedfp = 1; \ 97 memcpy(&(sc)->sc_fpregs, \ 98 &(uc)->uc_mcontext.__fpregs.__fp_fr, \ 99 31 * sizeof(unsigned long)); \ 100 (sc)->sc_fpcr = (uc)->uc_mcontext.__fpregs.__fp_fpcr; \ 101 /* XXX sc_fp_control */ \ 102 } else \ 103 (sc)->sc_ownedfp = 0; \ 104} while (/*CONSTCOND*/0) 105 106#define _SIGCONTEXT_TO_MCONTEXT(sc, uc) \ 107do { \ 108 (uc)->uc_mcontext.__gregs[_REG_PC] = (sc)->sc_pc; \ 109 (uc)->uc_mcontext.__gregs[_REG_PS] = (sc)->sc_ps; \ 110 memcpy(&(uc)->uc_mcontext.__gregs, &(sc)->sc_regs, \ 111 31 * sizeof(unsigned long)); \ 112 if ((sc)->sc_ownedfp) { \ 113 memcpy(&(uc)->uc_mcontext.__fpregs.__fp_fr, \ 114 &(sc)->sc_fpregs, 31 * sizeof(unsigned long)); \ 115 (sc)->sc_fpcr = (uc)->uc_mcontext.__fpregs.__fp_fpcr; \ 116 /* XXX sc_fp_control */ \ 117 (uc)->uc_flags |= _UC_FPU; \ 118 } \ 119} while (/*CONSTCOND*/0) 120 121#endif /* _NETBSD_SOURCE */ 122#endif /* !_ALPHA_SIGNAL_H_*/ 123