signal.h revision 1.2
11.2Sbjh21/*	$NetBSD: signal.h,v 1.2 2003/04/28 23:16:17 bjh21 Exp $	*/
21.1Sfvdl
31.1Sfvdl/*
41.1Sfvdl * Copyright (c) 1982, 1986, 1989, 1991 Regents of the University of California.
51.1Sfvdl * All rights reserved.
61.1Sfvdl *
71.1Sfvdl * Redistribution and use in source and binary forms, with or without
81.1Sfvdl * modification, are permitted provided that the following conditions
91.1Sfvdl * are met:
101.1Sfvdl * 1. Redistributions of source code must retain the above copyright
111.1Sfvdl *    notice, this list of conditions and the following disclaimer.
121.1Sfvdl * 2. Redistributions in binary form must reproduce the above copyright
131.1Sfvdl *    notice, this list of conditions and the following disclaimer in the
141.1Sfvdl *    documentation and/or other materials provided with the distribution.
151.1Sfvdl * 3. All advertising materials mentioning features or use of this software
161.1Sfvdl *    must display the following acknowledgement:
171.1Sfvdl *	This product includes software developed by the University of
181.1Sfvdl *	California, Berkeley and its contributors.
191.1Sfvdl * 4. Neither the name of the University nor the names of its contributors
201.1Sfvdl *    may be used to endorse or promote products derived from this software
211.1Sfvdl *    without specific prior written permission.
221.1Sfvdl *
231.1Sfvdl * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
241.1Sfvdl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
251.1Sfvdl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
261.1Sfvdl * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
271.1Sfvdl * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
281.1Sfvdl * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
291.1Sfvdl * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
301.1Sfvdl * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
311.1Sfvdl * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
321.1Sfvdl * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
331.1Sfvdl * SUCH DAMAGE.
341.1Sfvdl *
351.1Sfvdl *	@(#)signal.h	7.16 (Berkeley) 3/17/91
361.1Sfvdl */
371.1Sfvdl
381.1Sfvdl#ifndef _AMD64_SIGNAL_H_
391.1Sfvdl#define _AMD64_SIGNAL_H_
401.1Sfvdl
411.2Sbjh21#include <sys/featuretest.h>
421.2Sbjh21
431.1Sfvdltypedef int sig_atomic_t;
441.1Sfvdl
451.2Sbjh21#if defined(_NETBSD_SOURCE)
461.1Sfvdl/*
471.1Sfvdl * Get the "code" values
481.1Sfvdl */
491.1Sfvdl#include <machine/trap.h>
501.1Sfvdl#include <machine/fpu.h>
511.1Sfvdl#include <machine/mcontext.h>
521.1Sfvdl
531.1Sfvdl/*
541.1Sfvdl * Information pushed on stack when a signal is delivered.
551.1Sfvdl * This is used by the kernel to restore state following
561.1Sfvdl * execution of the signal handler.  It is also made available
571.1Sfvdl * to the handler to allow it to restore state properly if
581.1Sfvdl * a non-standard exit is performed.
591.1Sfvdl */
601.1Sfvdlstruct sigcontext {
611.1Sfvdl	struct fxsave64 *sc_fpstate;
621.1Sfvdl	u_int64_t	sc_onstack;
631.1Sfvdl	sigset_t	sc_mask;
641.1Sfvdl	mcontext_t	sc_mcontext;
651.1Sfvdl};
661.1Sfvdl
671.1Sfvdl#define _MCONTEXT_TO_SIGCONTEXT(uc, sc) 				\
681.1Sfvdldo {									\
691.1Sfvdl	memcpy(&(sc)->sc_mcontext.__gregs, &(uc)->uc_mcontext.__gregs,	\
701.1Sfvdl	    sizeof ((uc)->uc_mcontext.__gregs));			\
711.1Sfvdl	if ((uc)->uc_flags & _UC_FPU) {					\
721.1Sfvdl		memcpy(&(sc)->sc_mcontext.__fpregs,			\
731.1Sfvdl		    &(uc)->uc_mcontext.__fpregs,			\
741.1Sfvdl		    sizeof ((uc)->uc_mcontext.__fpregs));		\
751.1Sfvdl	}								\
761.1Sfvdl} while (/*CONSTCOND*/0)
771.1Sfvdl
781.1Sfvdl#define _SIGCONTEXT_TO_MCONTEXT(sc, uc)					\
791.1Sfvdldo {									\
801.1Sfvdl	memcpy(&(uc)->uc_mcontext.__gregs, &(sc)->sc_mcontext.__gregs,	\
811.1Sfvdl	    sizeof ((uc)->uc_mcontext.__gregs));			\
821.1Sfvdl	if ((uc)->uc_flags & _UC_FPU) {					\
831.1Sfvdl		memcpy(&(uc)->uc_mcontext.__fpregs,			\
841.1Sfvdl		    &(sc)->sc_mcontext.__fpregs,			\
851.1Sfvdl		    sizeof ((uc)->uc_mcontext.__fpregs));		\
861.1Sfvdl	}								\
871.1Sfvdl} while (/*CONSTCOND*/0)
881.1Sfvdl
891.2Sbjh21#endif	/* _NETBSD_SOURCE */
901.1Sfvdl#endif	/* !_AMD64_SIGNAL_H_ */
91