signal.h revision 1.7
11.7Sagc/*	$NetBSD: signal.h,v 1.7 2003/08/07 16:29:29 agc Exp $	*/
21.1Sitojun
31.1Sitojun/*
41.1Sitojun * Copyright (c) 1982, 1986, 1989, 1991 Regents of the University of California.
51.1Sitojun * All rights reserved.
61.1Sitojun *
71.1Sitojun * Redistribution and use in source and binary forms, with or without
81.1Sitojun * modification, are permitted provided that the following conditions
91.1Sitojun * are met:
101.1Sitojun * 1. Redistributions of source code must retain the above copyright
111.1Sitojun *    notice, this list of conditions and the following disclaimer.
121.1Sitojun * 2. Redistributions in binary form must reproduce the above copyright
131.1Sitojun *    notice, this list of conditions and the following disclaimer in the
141.1Sitojun *    documentation and/or other materials provided with the distribution.
151.7Sagc * 3. Neither the name of the University nor the names of its contributors
161.1Sitojun *    may be used to endorse or promote products derived from this software
171.1Sitojun *    without specific prior written permission.
181.1Sitojun *
191.1Sitojun * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
201.1Sitojun * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
211.1Sitojun * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
221.1Sitojun * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
231.1Sitojun * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
241.1Sitojun * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
251.1Sitojun * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
261.1Sitojun * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
271.1Sitojun * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
281.1Sitojun * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
291.1Sitojun * SUCH DAMAGE.
301.1Sitojun *
311.1Sitojun *	@(#)signal.h	7.16 (Berkeley) 3/17/91
321.1Sitojun */
331.1Sitojun
341.1Sitojun#ifndef _SH3_SIGNAL_H_
351.2Such#define	_SH3_SIGNAL_H_
361.1Sitojun
371.6Sbjh21#include <sys/featuretest.h>
381.6Sbjh21
391.1Sitojuntypedef int sig_atomic_t;
401.1Sitojun
411.6Sbjh21#if defined(_NETBSD_SOURCE)
421.1Sitojun
431.1Sitojun/*
441.1Sitojun * Information pushed on stack when a signal is delivered.
451.1Sitojun * This is used by the kernel to restore state following
461.1Sitojun * execution of the signal handler.  It is also made available
471.1Sitojun * to the handler to allow it to restore state properly if
481.1Sitojun * a non-standard exit is performed.
491.1Sitojun */
501.1Sitojun#if defined(__LIBC12_SOURCE__) || defined(_KERNEL)
511.1Sitojunstruct sigcontext13 {
521.1Sitojun	int	sc_spc;
531.1Sitojun	int	sc_ssr;
541.1Sitojun	int	sc_pr;
551.1Sitojun	int	sc_r14;
561.1Sitojun	int	sc_r13;
571.1Sitojun	int	sc_r12;
581.1Sitojun	int	sc_r11;
591.1Sitojun	int	sc_r10;
601.1Sitojun	int	sc_r9;
611.1Sitojun	int	sc_r8;
621.1Sitojun	int	sc_r7;
631.1Sitojun	int	sc_r6;
641.1Sitojun	int	sc_r5;
651.1Sitojun	int	sc_r4;
661.1Sitojun	int	sc_r3;
671.1Sitojun	int	sc_r2;
681.1Sitojun	int	sc_r1;
691.1Sitojun	int	sc_r0;
701.1Sitojun	int	sc_r15;
711.1Sitojun
721.1Sitojun	int	sc_onstack;		/* sigstack state to restore */
731.1Sitojun	int	sc_mask;		/* signal mask to restore (old style) */
741.1Sitojun
751.3Such	int	sc_expevt;		/* XXX should be above */
761.1Sitojun	int	sc_err;
771.1Sitojun};
781.1Sitojun#endif
791.1Sitojun
801.1Sitojunstruct sigcontext {
811.1Sitojun	int	sc_spc;
821.1Sitojun	int	sc_ssr;
831.1Sitojun	int	sc_pr;
841.1Sitojun	int	sc_r14;
851.1Sitojun	int	sc_r13;
861.1Sitojun	int	sc_r12;
871.1Sitojun	int	sc_r11;
881.1Sitojun	int	sc_r10;
891.1Sitojun	int	sc_r9;
901.1Sitojun	int	sc_r8;
911.1Sitojun	int	sc_r7;
921.1Sitojun	int	sc_r6;
931.1Sitojun	int	sc_r5;
941.1Sitojun	int	sc_r4;
951.1Sitojun	int	sc_r3;
961.1Sitojun	int	sc_r2;
971.1Sitojun	int	sc_r1;
981.1Sitojun	int	sc_r0;
991.1Sitojun	int	sc_r15;
1001.1Sitojun
1011.1Sitojun	int	sc_onstack;	/* sigstack state to restore */
1021.1Sitojun
1031.3Such	int	sc_expevt;	/* XXX should be above */
1041.1Sitojun	int	sc_err;
1051.1Sitojun
1061.1Sitojun	sigset_t sc_mask;	/* signal mask to restore (new style) */
1071.1Sitojun};
1081.5Sthorpej
1091.5Sthorpej/*
1101.5Sthorpej * The following macros are used to convert from a ucontext to sigcontext,
1111.5Sthorpej * and vice-versa.  This is for building a sigcontext to deliver to old-style
1121.5Sthorpej * signal handlers, and converting back (in the event the handler modifies
1131.5Sthorpej * the context).
1141.5Sthorpej */
1151.5Sthorpej#define	_MCONTEXT_TO_SIGCONTEXT(uc, sc)					\
1161.5Sthorpejdo {									\
1171.5Sthorpej	memcpy(&(sc)->sc_pr, &(uc)->uc_mcontext.__gregs[_REG_PR],	\
1181.5Sthorpej	    17 * sizeof(unsigned int));					\
1191.5Sthorpej	(sc)->sc_spc    = (uc)->uc_mcontext.__gregs[_REG_PC];		\
1201.5Sthorpej	(sc)->sc_ssr    = (uc)->uc_mcontext.__gregs[_REG_SR];		\
1211.5Sthorpej	(sc)->sc_expevt = (uc)->uc_mcontext.__gregs[_REG_EXPEVT];	\
1221.5Sthorpej	(sc)->sc_err    = 0;	/* XXX */				\
1231.5Sthorpej} while (/*CONSTCOND*/0)
1241.5Sthorpej
1251.5Sthorpej#define	_SIGCONTEXT_TO_MCONTEXT(sc, uc)					\
1261.5Sthorpejdo {									\
1271.5Sthorpej	memcpy(&(uc)->uc_mcontext.__gregs[_REG_PR], &(sc)->sc_pr,	\
1281.5Sthorpej	    17 * sizeof(unsigned int));					\
1291.5Sthorpej	(uc)->uc_mcontext.__gregs[_REG_PC]     = (sc)->sc_spc;		\
1301.5Sthorpej	(uc)->uc_mcontext.__gregs[_REG_SR]     = (sc)->sc_ssr;		\
1311.5Sthorpej	(uc)->uc_mcontext.__gregs[_REG_EXPEVT] = (sc)->sc_expevt;	\
1321.5Sthorpej} while (/*CONSTCOND*/0)
1331.1Sitojun
1341.6Sbjh21#endif	/* _NETBSD_SOURCE */
1351.1Sitojun#endif	/* !_SH3_SIGNAL_H_ */
136