setjmp.h revision 292407
11149Shannesw/*-
21149Shannesw * Copyright (c) 2015 Ruslan Bukin <br@bsdpad.com>
31149Shannesw * All rights reserved.
41149Shannesw *
51149Shannesw * Portions of this software were developed by SRI International and the
61149Shannesw * University of Cambridge Computer Laboratory under DARPA/AFRL contract
71149Shannesw * FA8750-10-C-0237 ("CTSRD"), as part of the DARPA CRASH research programme.
81149Shannesw *
91149Shannesw * Portions of this software were developed by the University of Cambridge
101149Shannesw * Computer Laboratory as part of the CTSRD Project, with support from the
111149Shannesw * UK Higher Education Innovation Fund (HEIF).
121149Shannesw *
131149Shannesw * Redistribution and use in source and binary forms, with or without
141149Shannesw * modification, are permitted provided that the following conditions
151149Shannesw * are met:
161149Shannesw * 1. Redistributions of source code must retain the above copyright
171149Shannesw *    notice, this list of conditions and the following disclaimer.
181149Shannesw * 2. Redistributions in binary form must reproduce the above copyright
191149Shannesw *    notice, this list of conditions and the following disclaimer in the
201149Shannesw *    documentation and/or other materials provided with the distribution.
211149Shannesw *
221149Shannesw * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
231149Shannesw * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
241149Shannesw * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
251149Shannesw * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
261149Shannesw * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
271149Shannesw * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
281149Shannesw * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
291149Shannesw * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
301149Shannesw * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
311149Shannesw * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
321149Shannesw * SUCH DAMAGE.
331149Shannesw *
341149Shannesw * $FreeBSD: head/sys/riscv/include/setjmp.h 292407 2015-12-17 18:44:30Z br $
351149Shannesw */
361149Shannesw
371149Shannesw#ifndef _MACHINE_SETJMP_H_
381149Shannesw#define	_MACHINE_SETJMP_H_
391149Shannesw
401149Shannesw#include <sys/cdefs.h>
411149Shannesw
421149Shannesw#define	_JBLEN		32	/* sp, ra, [f]s0-11, magic val, sigmask */
431149Shannesw#define	_JB_SIGMASK	21
441149Shannesw
451149Shannesw#ifdef	__ASSEMBLER__
461149Shannesw#define	_JB_MAGIC__SETJMP	0xbe87fd8a2910af00
471149Shannesw#define	_JB_MAGIC_SETJMP	0xbe87fd8a2910af01
481149Shannesw#endif /* !__ASSEMBLER__ */
491149Shannesw
501149Shannesw#ifndef	__ASSEMBLER__
511149Shannesw/*
521149Shannesw * jmp_buf and sigjmp_buf are encapsulated in different structs to force
531149Shannesw * compile-time diagnostics for mismatches.  The structs are the same
541149Shannesw * internally to avoid some run-time errors for mismatches.
551149Shannesw */
561149Shannesw#if __BSD_VISIBLE || __POSIX_VISIBLE || __XSI_VISIBLE
571149Shanneswtypedef	struct _sigjmp_buf { long _sjb[_JBLEN + 1]; } sigjmp_buf[1];
581149Shannesw#endif
591149Shannesw
601149Shanneswtypedef	struct _jmp_buf { long _jb[_JBLEN + 1]; } jmp_buf[1];
611149Shannesw#endif	/* __ASSEMBLER__ */
621149Shannesw
631149Shannesw#endif /* !_MACHINE_SETJMP_H_ */
641149Shannesw