signal.h revision 1.3
11.3Sagc/*	$NetBSD: signal.h,v 1.3 2003/08/07 16:26:36 agc 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.3Sagc * 3. Neither the name of the University nor the names of its contributors
161.1Sfvdl *    may be used to endorse or promote products derived from this software
171.1Sfvdl *    without specific prior written permission.
181.1Sfvdl *
191.1Sfvdl * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
201.1Sfvdl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
211.1Sfvdl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
221.1Sfvdl * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
231.1Sfvdl * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
241.1Sfvdl * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
251.1Sfvdl * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
261.1Sfvdl * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
271.1Sfvdl * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
281.1Sfvdl * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
291.1Sfvdl * SUCH DAMAGE.
301.1Sfvdl *
311.1Sfvdl *	@(#)signal.h	7.16 (Berkeley) 3/17/91
321.1Sfvdl */
331.1Sfvdl
341.1Sfvdl#ifndef _AMD64_SIGNAL_H_
351.1Sfvdl#define _AMD64_SIGNAL_H_
361.1Sfvdl
371.2Sbjh21#include <sys/featuretest.h>
381.2Sbjh21
391.1Sfvdltypedef int sig_atomic_t;
401.1Sfvdl
411.2Sbjh21#if defined(_NETBSD_SOURCE)
421.1Sfvdl/*
431.1Sfvdl * Get the "code" values
441.1Sfvdl */
451.1Sfvdl#include <machine/trap.h>
461.1Sfvdl#include <machine/fpu.h>
471.1Sfvdl#include <machine/mcontext.h>
481.1Sfvdl
491.1Sfvdl/*
501.1Sfvdl * Information pushed on stack when a signal is delivered.
511.1Sfvdl * This is used by the kernel to restore state following
521.1Sfvdl * execution of the signal handler.  It is also made available
531.1Sfvdl * to the handler to allow it to restore state properly if
541.1Sfvdl * a non-standard exit is performed.
551.1Sfvdl */
561.1Sfvdlstruct sigcontext {
571.1Sfvdl	struct fxsave64 *sc_fpstate;
581.1Sfvdl	u_int64_t	sc_onstack;
591.1Sfvdl	sigset_t	sc_mask;
601.1Sfvdl	mcontext_t	sc_mcontext;
611.1Sfvdl};
621.1Sfvdl
631.1Sfvdl#define _MCONTEXT_TO_SIGCONTEXT(uc, sc) 				\
641.1Sfvdldo {									\
651.1Sfvdl	memcpy(&(sc)->sc_mcontext.__gregs, &(uc)->uc_mcontext.__gregs,	\
661.1Sfvdl	    sizeof ((uc)->uc_mcontext.__gregs));			\
671.1Sfvdl	if ((uc)->uc_flags & _UC_FPU) {					\
681.1Sfvdl		memcpy(&(sc)->sc_mcontext.__fpregs,			\
691.1Sfvdl		    &(uc)->uc_mcontext.__fpregs,			\
701.1Sfvdl		    sizeof ((uc)->uc_mcontext.__fpregs));		\
711.1Sfvdl	}								\
721.1Sfvdl} while (/*CONSTCOND*/0)
731.1Sfvdl
741.1Sfvdl#define _SIGCONTEXT_TO_MCONTEXT(sc, uc)					\
751.1Sfvdldo {									\
761.1Sfvdl	memcpy(&(uc)->uc_mcontext.__gregs, &(sc)->sc_mcontext.__gregs,	\
771.1Sfvdl	    sizeof ((uc)->uc_mcontext.__gregs));			\
781.1Sfvdl	if ((uc)->uc_flags & _UC_FPU) {					\
791.1Sfvdl		memcpy(&(uc)->uc_mcontext.__fpregs,			\
801.1Sfvdl		    &(sc)->sc_mcontext.__fpregs,			\
811.1Sfvdl		    sizeof ((uc)->uc_mcontext.__fpregs));		\
821.1Sfvdl	}								\
831.1Sfvdl} while (/*CONSTCOND*/0)
841.1Sfvdl
851.2Sbjh21#endif	/* _NETBSD_SOURCE */
861.1Sfvdl#endif	/* !_AMD64_SIGNAL_H_ */
87