signal.h revision 1.6
11.6Sbjh21/*	$NetBSD: signal.h,v 1.6 2003/04/28 23:16:23 bjh21 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.1Sitojun * 3. All advertising materials mentioning features or use of this software
161.1Sitojun *    must display the following acknowledgement:
171.1Sitojun *	This product includes software developed by the University of
181.1Sitojun *	California, Berkeley and its contributors.
191.1Sitojun * 4. Neither the name of the University nor the names of its contributors
201.1Sitojun *    may be used to endorse or promote products derived from this software
211.1Sitojun *    without specific prior written permission.
221.1Sitojun *
231.1Sitojun * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
241.1Sitojun * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
251.1Sitojun * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
261.1Sitojun * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
271.1Sitojun * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
281.1Sitojun * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
291.1Sitojun * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
301.1Sitojun * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
311.1Sitojun * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
321.1Sitojun * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
331.1Sitojun * SUCH DAMAGE.
341.1Sitojun *
351.1Sitojun *	@(#)signal.h	7.16 (Berkeley) 3/17/91
361.1Sitojun */
371.1Sitojun
381.1Sitojun#ifndef _SH3_SIGNAL_H_
391.2Such#define	_SH3_SIGNAL_H_
401.1Sitojun
411.6Sbjh21#include <sys/featuretest.h>
421.6Sbjh21
431.1Sitojuntypedef int sig_atomic_t;
441.1Sitojun
451.6Sbjh21#if defined(_NETBSD_SOURCE)
461.1Sitojun
471.1Sitojun/*
481.1Sitojun * Information pushed on stack when a signal is delivered.
491.1Sitojun * This is used by the kernel to restore state following
501.1Sitojun * execution of the signal handler.  It is also made available
511.1Sitojun * to the handler to allow it to restore state properly if
521.1Sitojun * a non-standard exit is performed.
531.1Sitojun */
541.1Sitojun#if defined(__LIBC12_SOURCE__) || defined(_KERNEL)
551.1Sitojunstruct sigcontext13 {
561.1Sitojun	int	sc_spc;
571.1Sitojun	int	sc_ssr;
581.1Sitojun	int	sc_pr;
591.1Sitojun	int	sc_r14;
601.1Sitojun	int	sc_r13;
611.1Sitojun	int	sc_r12;
621.1Sitojun	int	sc_r11;
631.1Sitojun	int	sc_r10;
641.1Sitojun	int	sc_r9;
651.1Sitojun	int	sc_r8;
661.1Sitojun	int	sc_r7;
671.1Sitojun	int	sc_r6;
681.1Sitojun	int	sc_r5;
691.1Sitojun	int	sc_r4;
701.1Sitojun	int	sc_r3;
711.1Sitojun	int	sc_r2;
721.1Sitojun	int	sc_r1;
731.1Sitojun	int	sc_r0;
741.1Sitojun	int	sc_r15;
751.1Sitojun
761.1Sitojun	int	sc_onstack;		/* sigstack state to restore */
771.1Sitojun	int	sc_mask;		/* signal mask to restore (old style) */
781.1Sitojun
791.3Such	int	sc_expevt;		/* XXX should be above */
801.1Sitojun	int	sc_err;
811.1Sitojun};
821.1Sitojun#endif
831.1Sitojun
841.1Sitojunstruct sigcontext {
851.1Sitojun	int	sc_spc;
861.1Sitojun	int	sc_ssr;
871.1Sitojun	int	sc_pr;
881.1Sitojun	int	sc_r14;
891.1Sitojun	int	sc_r13;
901.1Sitojun	int	sc_r12;
911.1Sitojun	int	sc_r11;
921.1Sitojun	int	sc_r10;
931.1Sitojun	int	sc_r9;
941.1Sitojun	int	sc_r8;
951.1Sitojun	int	sc_r7;
961.1Sitojun	int	sc_r6;
971.1Sitojun	int	sc_r5;
981.1Sitojun	int	sc_r4;
991.1Sitojun	int	sc_r3;
1001.1Sitojun	int	sc_r2;
1011.1Sitojun	int	sc_r1;
1021.1Sitojun	int	sc_r0;
1031.1Sitojun	int	sc_r15;
1041.1Sitojun
1051.1Sitojun	int	sc_onstack;	/* sigstack state to restore */
1061.1Sitojun
1071.3Such	int	sc_expevt;	/* XXX should be above */
1081.1Sitojun	int	sc_err;
1091.1Sitojun
1101.1Sitojun	sigset_t sc_mask;	/* signal mask to restore (new style) */
1111.1Sitojun};
1121.5Sthorpej
1131.5Sthorpej/*
1141.5Sthorpej * The following macros are used to convert from a ucontext to sigcontext,
1151.5Sthorpej * and vice-versa.  This is for building a sigcontext to deliver to old-style
1161.5Sthorpej * signal handlers, and converting back (in the event the handler modifies
1171.5Sthorpej * the context).
1181.5Sthorpej */
1191.5Sthorpej#define	_MCONTEXT_TO_SIGCONTEXT(uc, sc)					\
1201.5Sthorpejdo {									\
1211.5Sthorpej	memcpy(&(sc)->sc_pr, &(uc)->uc_mcontext.__gregs[_REG_PR],	\
1221.5Sthorpej	    17 * sizeof(unsigned int));					\
1231.5Sthorpej	(sc)->sc_spc    = (uc)->uc_mcontext.__gregs[_REG_PC];		\
1241.5Sthorpej	(sc)->sc_ssr    = (uc)->uc_mcontext.__gregs[_REG_SR];		\
1251.5Sthorpej	(sc)->sc_expevt = (uc)->uc_mcontext.__gregs[_REG_EXPEVT];	\
1261.5Sthorpej	(sc)->sc_err    = 0;	/* XXX */				\
1271.5Sthorpej} while (/*CONSTCOND*/0)
1281.5Sthorpej
1291.5Sthorpej#define	_SIGCONTEXT_TO_MCONTEXT(sc, uc)					\
1301.5Sthorpejdo {									\
1311.5Sthorpej	memcpy(&(uc)->uc_mcontext.__gregs[_REG_PR], &(sc)->sc_pr,	\
1321.5Sthorpej	    17 * sizeof(unsigned int));					\
1331.5Sthorpej	(uc)->uc_mcontext.__gregs[_REG_PC]     = (sc)->sc_spc;		\
1341.5Sthorpej	(uc)->uc_mcontext.__gregs[_REG_SR]     = (sc)->sc_ssr;		\
1351.5Sthorpej	(uc)->uc_mcontext.__gregs[_REG_EXPEVT] = (sc)->sc_expevt;	\
1361.5Sthorpej} while (/*CONSTCOND*/0)
1371.1Sitojun
1381.6Sbjh21#endif	/* _NETBSD_SOURCE */
1391.1Sitojun#endif	/* !_SH3_SIGNAL_H_ */
140