signal.h revision 1.7
11.7Sbjh21/* $NetBSD: signal.h,v 1.7 2003/04/28 23:16:16 bjh21 Exp $ */ 21.1Scgd 31.1Scgd/* 41.1Scgd * Copyright (c) 1994, 1995 Carnegie-Mellon University. 51.1Scgd * All rights reserved. 61.1Scgd * 71.1Scgd * Author: Chris G. Demetriou 81.1Scgd * 91.1Scgd * Permission to use, copy, modify and distribute this software and 101.1Scgd * its documentation is hereby granted, provided that both the copyright 111.1Scgd * notice and this permission notice appear in all copies of the 121.1Scgd * software, derivative works or modified versions, and any portions 131.1Scgd * thereof, and that both notices appear in supporting documentation. 141.1Scgd * 151.1Scgd * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 161.1Scgd * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 171.1Scgd * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 181.1Scgd * 191.1Scgd * Carnegie Mellon requests users of this software to return to 201.1Scgd * 211.1Scgd * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 221.1Scgd * School of Computer Science 231.1Scgd * Carnegie Mellon University 241.1Scgd * Pittsburgh PA 15213-3890 251.1Scgd * 261.1Scgd * any improvements or extensions that they make and grant Carnegie the 271.1Scgd * rights to redistribute these changes. 281.1Scgd */ 291.1Scgd 301.1Scgd#ifndef _ALPHA_SIGNAL_H_ 311.1Scgd#define _ALPHA_SIGNAL_H_ 321.1Scgd 331.7Sbjh21#include <sys/featuretest.h> 341.7Sbjh21 351.1Scgdtypedef long sig_atomic_t; 361.1Scgd 371.7Sbjh21#if defined(_NETBSD_SOURCE) 381.1Scgd/* 391.1Scgd * Information pushed on stack when a signal is delivered. 401.1Scgd * This is used by the kernel to restore state following 411.1Scgd * execution of the signal handler. It is also made available 421.1Scgd * to the handler to allow it to restore state properly if 431.1Scgd * a non-standard exit is performed. 441.1Scgd * 451.1Scgd * Note that sc_regs[] and sc_fpregs[]+sc_fpcr are inline 461.1Scgd * representations of 'struct reg' and 'struct fpreg', respectively. 471.1Scgd */ 481.5Sthorpej#if defined(__LIBC12_SOURCE__) || defined(_KERNEL) 491.5Sthorpejstruct sigcontext13 { 501.5Sthorpej long sc_onstack; /* sigstack state to restore */ 511.5Sthorpej long sc_mask; /* signal mask to restore (old style) */ 521.5Sthorpej long sc_pc; /* pc to restore */ 531.1Scgd long sc_ps; /* ps to restore */ 541.1Scgd unsigned long sc_regs[32]; /* integer register set (see above) */ 551.1Scgd#define sc_sp sc_regs[R_SP] 561.1Scgd long sc_ownedfp; /* fp has been used */ 571.1Scgd unsigned long sc_fpregs[32]; /* FP register set (see above) */ 581.1Scgd unsigned long sc_fpcr; /* FP control register (see above) */ 591.1Scgd unsigned long sc_fp_control; /* FP software control word */ 601.1Scgd long sc_reserved[2]; /* XXX */ 611.1Scgd long sc_xxx[8]; /* XXX */ 621.5Sthorpej}; 631.5Sthorpej#endif /* __LIBC12_SOURCE__ || _KERNEL */ 641.5Sthorpej 651.5Sthorpejstruct sigcontext { 661.5Sthorpej long sc_onstack; /* sigstack state to restore */ 671.5Sthorpej long __sc_mask13; /* signal mask to restore (old style) */ 681.5Sthorpej long sc_pc; /* pc to restore */ 691.5Sthorpej long sc_ps; /* ps to restore */ 701.5Sthorpej unsigned long sc_regs[32]; /* integer register set (see above) */ 711.5Sthorpej#define sc_sp sc_regs[R_SP] 721.5Sthorpej long sc_ownedfp; /* fp has been used */ 731.5Sthorpej unsigned long sc_fpregs[32]; /* FP register set (see above) */ 741.5Sthorpej unsigned long sc_fpcr; /* FP control register (see above) */ 751.5Sthorpej unsigned long sc_fp_control; /* FP software control word */ 761.5Sthorpej long sc_reserved[2]; /* XXX */ 771.5Sthorpej long sc_xxx[8]; /* XXX */ 781.5Sthorpej sigset_t sc_mask; /* signal mask to restore (new style) */ 791.1Scgd}; 801.6Sthorpej 811.6Sthorpej/* 821.6Sthorpej * The following macros are used to convert from a ucontext to sigcontext, 831.6Sthorpej * and vice-versa. This is for building a sigcontext to deliver to old-style 841.6Sthorpej * signal handlers, and converting back (in the event the handler modifies 851.6Sthorpej * the context). 861.6Sthorpej */ 871.6Sthorpej#define _MCONTEXT_TO_SIGCONTEXT(uc, sc) \ 881.6Sthorpejdo { \ 891.6Sthorpej (sc)->sc_pc = (uc)->uc_mcontext.__gregs[_REG_PC]; \ 901.6Sthorpej (sc)->sc_ps = (uc)->uc_mcontext.__gregs[_REG_PS]; \ 911.6Sthorpej memcpy(&(sc)->sc_regs, &(uc)->uc_mcontext.__gregs, \ 921.6Sthorpej 31 * sizeof(unsigned long)); \ 931.6Sthorpej if ((uc)->uc_flags & _UC_FPU) { \ 941.6Sthorpej (sc)->sc_ownedfp = 1; \ 951.6Sthorpej memcpy(&(sc)->sc_fpregs, \ 961.6Sthorpej &(uc)->uc_mcontext.__fpregs.__fp_fr, \ 971.6Sthorpej 31 * sizeof(unsigned long)); \ 981.6Sthorpej (sc)->sc_fpcr = (uc)->uc_mcontext.__fpregs.__fp_fpcr; \ 991.6Sthorpej /* XXX sc_fp_control */ \ 1001.6Sthorpej } else \ 1011.6Sthorpej (sc)->sc_ownedfp = 0; \ 1021.6Sthorpej} while (/*CONSTCOND*/0) 1031.6Sthorpej 1041.6Sthorpej#define _SIGCONTEXT_TO_MCONTEXT(sc, uc) \ 1051.6Sthorpejdo { \ 1061.6Sthorpej (uc)->uc_mcontext.__gregs[_REG_PC] = (sc)->sc_pc; \ 1071.6Sthorpej (uc)->uc_mcontext.__gregs[_REG_PS] = (sc)->sc_ps; \ 1081.6Sthorpej memcpy(&(uc)->uc_mcontext.__gregs, &(sc)->sc_regs, \ 1091.6Sthorpej 31 * sizeof(unsigned long)); \ 1101.6Sthorpej if ((sc)->sc_ownedfp) { \ 1111.6Sthorpej memcpy(&(uc)->uc_mcontext.__fpregs.__fp_fr, \ 1121.6Sthorpej &(sc)->sc_fpregs, 31 * sizeof(unsigned long)); \ 1131.6Sthorpej (sc)->sc_fpcr = (uc)->uc_mcontext.__fpregs.__fp_fpcr; \ 1141.6Sthorpej /* XXX sc_fp_control */ \ 1151.6Sthorpej (uc)->uc_flags |= _UC_FPU; \ 1161.6Sthorpej } \ 1171.6Sthorpej} while (/*CONSTCOND*/0) 1181.1Scgd 1191.7Sbjh21#endif /* _NETBSD_SOURCE */ 1201.1Scgd#endif /* !_ALPHA_SIGNAL_H_*/ 121