signal.h revision 1.9
1/* $NetBSD: signal.h,v 1.9 2003/10/18 18:34:10 christos 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#ifdef COMPAT_16 39#define SIGTRAMP_VALID(vers) ((unsigned)(vers) <= 2) 40#else 41#define SIGTRAMP_VALID(vers) ((vers) == 2) 42#endif 43 44#if defined(_NETBSD_SOURCE) 45/* 46 * Information pushed on stack when a signal is delivered. 47 * This is used by the kernel to restore state following 48 * execution of the signal handler. It is also made available 49 * to the handler to allow it to restore state properly if 50 * a non-standard exit is performed. 51 * 52 * Note that sc_regs[] and sc_fpregs[]+sc_fpcr are inline 53 * representations of 'struct reg' and 'struct fpreg', respectively. 54 */ 55#if defined(__LIBC12_SOURCE__) || defined(_KERNEL) 56struct sigcontext13 { 57 long sc_onstack; /* sigstack state to restore */ 58 long sc_mask; /* signal mask to restore (old style) */ 59 long sc_pc; /* pc to restore */ 60 long sc_ps; /* ps to restore */ 61 unsigned long sc_regs[32]; /* integer register set (see above) */ 62#define sc_sp sc_regs[R_SP] 63 long sc_ownedfp; /* fp has been used */ 64 unsigned long sc_fpregs[32]; /* FP register set (see above) */ 65 unsigned long sc_fpcr; /* FP control register (see above) */ 66 unsigned long sc_fp_control; /* FP software control word */ 67 long sc_reserved[2]; /* XXX */ 68 long sc_xxx[8]; /* XXX */ 69}; 70#endif /* __LIBC12_SOURCE__ || _KERNEL */ 71 72struct sigcontext { 73 long sc_onstack; /* sigstack state to restore */ 74 long __sc_mask13; /* signal mask to restore (old style) */ 75 long sc_pc; /* pc to restore */ 76 long sc_ps; /* ps to restore */ 77 unsigned long sc_regs[32]; /* integer register set (see above) */ 78#define sc_sp sc_regs[R_SP] 79 long sc_ownedfp; /* fp has been used */ 80 unsigned long sc_fpregs[32]; /* FP register set (see above) */ 81 unsigned long sc_fpcr; /* FP control register (see above) */ 82 unsigned long sc_fp_control; /* FP software control word */ 83 long sc_reserved[2]; /* XXX */ 84 long sc_xxx[8]; /* XXX */ 85 sigset_t sc_mask; /* signal mask to restore (new style) */ 86}; 87 88/* 89 * The following macros are used to convert from a ucontext to sigcontext, 90 * and vice-versa. This is for building a sigcontext to deliver to old-style 91 * signal handlers, and converting back (in the event the handler modifies 92 * the context). 93 */ 94#define _MCONTEXT_TO_SIGCONTEXT(uc, sc) \ 95do { \ 96 (sc)->sc_pc = (uc)->uc_mcontext.__gregs[_REG_PC]; \ 97 (sc)->sc_ps = (uc)->uc_mcontext.__gregs[_REG_PS]; \ 98 memcpy(&(sc)->sc_regs, &(uc)->uc_mcontext.__gregs, \ 99 31 * sizeof(unsigned long)); \ 100 if ((uc)->uc_flags & _UC_FPU) { \ 101 (sc)->sc_ownedfp = 1; \ 102 memcpy(&(sc)->sc_fpregs, \ 103 &(uc)->uc_mcontext.__fpregs.__fp_fr, \ 104 31 * sizeof(unsigned long)); \ 105 (sc)->sc_fpcr = (uc)->uc_mcontext.__fpregs.__fp_fpcr; \ 106 /* XXX sc_fp_control */ \ 107 } else \ 108 (sc)->sc_ownedfp = 0; \ 109} while (/*CONSTCOND*/0) 110 111#define _SIGCONTEXT_TO_MCONTEXT(sc, uc) \ 112do { \ 113 (uc)->uc_mcontext.__gregs[_REG_PC] = (sc)->sc_pc; \ 114 (uc)->uc_mcontext.__gregs[_REG_PS] = (sc)->sc_ps; \ 115 memcpy(&(uc)->uc_mcontext.__gregs, &(sc)->sc_regs, \ 116 31 * sizeof(unsigned long)); \ 117 if ((sc)->sc_ownedfp) { \ 118 memcpy(&(uc)->uc_mcontext.__fpregs.__fp_fr, \ 119 &(sc)->sc_fpregs, 31 * sizeof(unsigned long)); \ 120 (sc)->sc_fpcr = (uc)->uc_mcontext.__fpregs.__fp_fpcr; \ 121 /* XXX sc_fp_control */ \ 122 (uc)->uc_flags |= _UC_FPU; \ 123 } \ 124} while (/*CONSTCOND*/0) 125 126#endif /* _NETBSD_SOURCE */ 127#endif /* !_ALPHA_SIGNAL_H_*/ 128