signal.h revision 1.9
11.9Schristos/* $NetBSD: signal.h,v 1.9 2003/10/18 18:34:10 christos 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.8Sskd 371.8Sskd#define __HAVE_SIGINFO 381.9Schristos#ifdef COMPAT_16 391.9Schristos#define SIGTRAMP_VALID(vers) ((unsigned)(vers) <= 2) 401.9Schristos#else 411.9Schristos#define SIGTRAMP_VALID(vers) ((vers) == 2) 421.9Schristos#endif 431.1Scgd 441.7Sbjh21#if defined(_NETBSD_SOURCE) 451.1Scgd/* 461.1Scgd * Information pushed on stack when a signal is delivered. 471.1Scgd * This is used by the kernel to restore state following 481.1Scgd * execution of the signal handler. It is also made available 491.1Scgd * to the handler to allow it to restore state properly if 501.1Scgd * a non-standard exit is performed. 511.1Scgd * 521.1Scgd * Note that sc_regs[] and sc_fpregs[]+sc_fpcr are inline 531.1Scgd * representations of 'struct reg' and 'struct fpreg', respectively. 541.1Scgd */ 551.5Sthorpej#if defined(__LIBC12_SOURCE__) || defined(_KERNEL) 561.5Sthorpejstruct sigcontext13 { 571.5Sthorpej long sc_onstack; /* sigstack state to restore */ 581.5Sthorpej long sc_mask; /* signal mask to restore (old style) */ 591.5Sthorpej long sc_pc; /* pc to restore */ 601.1Scgd long sc_ps; /* ps to restore */ 611.1Scgd unsigned long sc_regs[32]; /* integer register set (see above) */ 621.1Scgd#define sc_sp sc_regs[R_SP] 631.1Scgd long sc_ownedfp; /* fp has been used */ 641.1Scgd unsigned long sc_fpregs[32]; /* FP register set (see above) */ 651.1Scgd unsigned long sc_fpcr; /* FP control register (see above) */ 661.1Scgd unsigned long sc_fp_control; /* FP software control word */ 671.1Scgd long sc_reserved[2]; /* XXX */ 681.1Scgd long sc_xxx[8]; /* XXX */ 691.5Sthorpej}; 701.5Sthorpej#endif /* __LIBC12_SOURCE__ || _KERNEL */ 711.5Sthorpej 721.5Sthorpejstruct sigcontext { 731.5Sthorpej long sc_onstack; /* sigstack state to restore */ 741.5Sthorpej long __sc_mask13; /* signal mask to restore (old style) */ 751.5Sthorpej long sc_pc; /* pc to restore */ 761.5Sthorpej long sc_ps; /* ps to restore */ 771.5Sthorpej unsigned long sc_regs[32]; /* integer register set (see above) */ 781.5Sthorpej#define sc_sp sc_regs[R_SP] 791.5Sthorpej long sc_ownedfp; /* fp has been used */ 801.5Sthorpej unsigned long sc_fpregs[32]; /* FP register set (see above) */ 811.5Sthorpej unsigned long sc_fpcr; /* FP control register (see above) */ 821.5Sthorpej unsigned long sc_fp_control; /* FP software control word */ 831.5Sthorpej long sc_reserved[2]; /* XXX */ 841.5Sthorpej long sc_xxx[8]; /* XXX */ 851.5Sthorpej sigset_t sc_mask; /* signal mask to restore (new style) */ 861.1Scgd}; 871.6Sthorpej 881.6Sthorpej/* 891.6Sthorpej * The following macros are used to convert from a ucontext to sigcontext, 901.6Sthorpej * and vice-versa. This is for building a sigcontext to deliver to old-style 911.6Sthorpej * signal handlers, and converting back (in the event the handler modifies 921.6Sthorpej * the context). 931.6Sthorpej */ 941.6Sthorpej#define _MCONTEXT_TO_SIGCONTEXT(uc, sc) \ 951.6Sthorpejdo { \ 961.6Sthorpej (sc)->sc_pc = (uc)->uc_mcontext.__gregs[_REG_PC]; \ 971.6Sthorpej (sc)->sc_ps = (uc)->uc_mcontext.__gregs[_REG_PS]; \ 981.6Sthorpej memcpy(&(sc)->sc_regs, &(uc)->uc_mcontext.__gregs, \ 991.6Sthorpej 31 * sizeof(unsigned long)); \ 1001.6Sthorpej if ((uc)->uc_flags & _UC_FPU) { \ 1011.6Sthorpej (sc)->sc_ownedfp = 1; \ 1021.6Sthorpej memcpy(&(sc)->sc_fpregs, \ 1031.6Sthorpej &(uc)->uc_mcontext.__fpregs.__fp_fr, \ 1041.6Sthorpej 31 * sizeof(unsigned long)); \ 1051.6Sthorpej (sc)->sc_fpcr = (uc)->uc_mcontext.__fpregs.__fp_fpcr; \ 1061.6Sthorpej /* XXX sc_fp_control */ \ 1071.6Sthorpej } else \ 1081.6Sthorpej (sc)->sc_ownedfp = 0; \ 1091.6Sthorpej} while (/*CONSTCOND*/0) 1101.6Sthorpej 1111.6Sthorpej#define _SIGCONTEXT_TO_MCONTEXT(sc, uc) \ 1121.6Sthorpejdo { \ 1131.6Sthorpej (uc)->uc_mcontext.__gregs[_REG_PC] = (sc)->sc_pc; \ 1141.6Sthorpej (uc)->uc_mcontext.__gregs[_REG_PS] = (sc)->sc_ps; \ 1151.6Sthorpej memcpy(&(uc)->uc_mcontext.__gregs, &(sc)->sc_regs, \ 1161.6Sthorpej 31 * sizeof(unsigned long)); \ 1171.6Sthorpej if ((sc)->sc_ownedfp) { \ 1181.6Sthorpej memcpy(&(uc)->uc_mcontext.__fpregs.__fp_fr, \ 1191.6Sthorpej &(sc)->sc_fpregs, 31 * sizeof(unsigned long)); \ 1201.6Sthorpej (sc)->sc_fpcr = (uc)->uc_mcontext.__fpregs.__fp_fpcr; \ 1211.6Sthorpej /* XXX sc_fp_control */ \ 1221.6Sthorpej (uc)->uc_flags |= _UC_FPU; \ 1231.6Sthorpej } \ 1241.6Sthorpej} while (/*CONSTCOND*/0) 1251.1Scgd 1261.7Sbjh21#endif /* _NETBSD_SOURCE */ 1271.1Scgd#endif /* !_ALPHA_SIGNAL_H_*/ 128