signal.h revision 1.6
11.6Sthorpej/* $NetBSD: signal.h,v 1.6 2003/01/17 22:11:16 thorpej 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.1Scgdtypedef long sig_atomic_t; 341.1Scgd 351.4Skleink#if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) && \ 361.4Skleink !defined(_XOPEN_SOURCE) 371.1Scgd/* 381.1Scgd * Information pushed on stack when a signal is delivered. 391.1Scgd * This is used by the kernel to restore state following 401.1Scgd * execution of the signal handler. It is also made available 411.1Scgd * to the handler to allow it to restore state properly if 421.1Scgd * a non-standard exit is performed. 431.1Scgd * 441.1Scgd * Note that sc_regs[] and sc_fpregs[]+sc_fpcr are inline 451.1Scgd * representations of 'struct reg' and 'struct fpreg', respectively. 461.1Scgd */ 471.5Sthorpej#if defined(__LIBC12_SOURCE__) || defined(_KERNEL) 481.5Sthorpejstruct sigcontext13 { 491.5Sthorpej long sc_onstack; /* sigstack state to restore */ 501.5Sthorpej long sc_mask; /* signal mask to restore (old style) */ 511.5Sthorpej long sc_pc; /* pc to restore */ 521.1Scgd long sc_ps; /* ps to restore */ 531.1Scgd unsigned long sc_regs[32]; /* integer register set (see above) */ 541.1Scgd#define sc_sp sc_regs[R_SP] 551.1Scgd long sc_ownedfp; /* fp has been used */ 561.1Scgd unsigned long sc_fpregs[32]; /* FP register set (see above) */ 571.1Scgd unsigned long sc_fpcr; /* FP control register (see above) */ 581.1Scgd unsigned long sc_fp_control; /* FP software control word */ 591.1Scgd long sc_reserved[2]; /* XXX */ 601.1Scgd long sc_xxx[8]; /* XXX */ 611.5Sthorpej}; 621.5Sthorpej#endif /* __LIBC12_SOURCE__ || _KERNEL */ 631.5Sthorpej 641.5Sthorpejstruct sigcontext { 651.5Sthorpej long sc_onstack; /* sigstack state to restore */ 661.5Sthorpej long __sc_mask13; /* signal mask to restore (old style) */ 671.5Sthorpej long sc_pc; /* pc to restore */ 681.5Sthorpej long sc_ps; /* ps to restore */ 691.5Sthorpej unsigned long sc_regs[32]; /* integer register set (see above) */ 701.5Sthorpej#define sc_sp sc_regs[R_SP] 711.5Sthorpej long sc_ownedfp; /* fp has been used */ 721.5Sthorpej unsigned long sc_fpregs[32]; /* FP register set (see above) */ 731.5Sthorpej unsigned long sc_fpcr; /* FP control register (see above) */ 741.5Sthorpej unsigned long sc_fp_control; /* FP software control word */ 751.5Sthorpej long sc_reserved[2]; /* XXX */ 761.5Sthorpej long sc_xxx[8]; /* XXX */ 771.5Sthorpej sigset_t sc_mask; /* signal mask to restore (new style) */ 781.1Scgd}; 791.6Sthorpej 801.6Sthorpej/* 811.6Sthorpej * The following macros are used to convert from a ucontext to sigcontext, 821.6Sthorpej * and vice-versa. This is for building a sigcontext to deliver to old-style 831.6Sthorpej * signal handlers, and converting back (in the event the handler modifies 841.6Sthorpej * the context). 851.6Sthorpej */ 861.6Sthorpej#define _MCONTEXT_TO_SIGCONTEXT(uc, sc) \ 871.6Sthorpejdo { \ 881.6Sthorpej (sc)->sc_pc = (uc)->uc_mcontext.__gregs[_REG_PC]; \ 891.6Sthorpej (sc)->sc_ps = (uc)->uc_mcontext.__gregs[_REG_PS]; \ 901.6Sthorpej memcpy(&(sc)->sc_regs, &(uc)->uc_mcontext.__gregs, \ 911.6Sthorpej 31 * sizeof(unsigned long)); \ 921.6Sthorpej if ((uc)->uc_flags & _UC_FPU) { \ 931.6Sthorpej (sc)->sc_ownedfp = 1; \ 941.6Sthorpej memcpy(&(sc)->sc_fpregs, \ 951.6Sthorpej &(uc)->uc_mcontext.__fpregs.__fp_fr, \ 961.6Sthorpej 31 * sizeof(unsigned long)); \ 971.6Sthorpej (sc)->sc_fpcr = (uc)->uc_mcontext.__fpregs.__fp_fpcr; \ 981.6Sthorpej /* XXX sc_fp_control */ \ 991.6Sthorpej } else \ 1001.6Sthorpej (sc)->sc_ownedfp = 0; \ 1011.6Sthorpej} while (/*CONSTCOND*/0) 1021.6Sthorpej 1031.6Sthorpej#define _SIGCONTEXT_TO_MCONTEXT(sc, uc) \ 1041.6Sthorpejdo { \ 1051.6Sthorpej (uc)->uc_mcontext.__gregs[_REG_PC] = (sc)->sc_pc; \ 1061.6Sthorpej (uc)->uc_mcontext.__gregs[_REG_PS] = (sc)->sc_ps; \ 1071.6Sthorpej memcpy(&(uc)->uc_mcontext.__gregs, &(sc)->sc_regs, \ 1081.6Sthorpej 31 * sizeof(unsigned long)); \ 1091.6Sthorpej if ((sc)->sc_ownedfp) { \ 1101.6Sthorpej memcpy(&(uc)->uc_mcontext.__fpregs.__fp_fr, \ 1111.6Sthorpej &(sc)->sc_fpregs, 31 * sizeof(unsigned long)); \ 1121.6Sthorpej (sc)->sc_fpcr = (uc)->uc_mcontext.__fpregs.__fp_fpcr; \ 1131.6Sthorpej /* XXX sc_fp_control */ \ 1141.6Sthorpej (uc)->uc_flags |= _UC_FPU; \ 1151.6Sthorpej } \ 1161.6Sthorpej} while (/*CONSTCOND*/0) 1171.1Scgd 1181.4Skleink#endif /* !_ANSI_SOURCE && !_POSIX_C_SOURCE && !_XOPEN_SOURCE */ 1191.1Scgd#endif /* !_ALPHA_SIGNAL_H_*/ 120