xref: /illumos-gate/usr/src/ucbhead/setjmp.h (revision 6a3e8e8695d5c7d1d18c6800d676990d7f61a2a4)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
28 /*	  All Rights Reserved  	*/
29 
30 /*
31  * University Copyright- Copyright (c) 1982, 1986, 1988
32  * The Regents of the University of California
33  * All Rights Reserved
34  *
35  * University Acknowledgment- Portions of this document are derived from
36  * software developed by the University of California, Berkeley, and its
37  * contributors.
38  */
39 
40 /*
41  * 4.3BSD setjmp compatibility header
42  *
43  * 4.3BSD setjmp/longjmp is equivalent to SVR4 sigsetjmp/siglongjmp -
44  * 4.3BSD _setjmp/_longjmp is equivalent to SVR4 setjmp/longjmp
45  */
46 
47 #ifndef _SETJMP_H
48 #define	_SETJMP_H
49 
50 #include <sys/types.h>
51 #include <sys/signal.h>
52 #include <sys/ucontext.h>
53 
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57 
58 /*
59  * The sizes of the jump-buffer (_JBLEN) and the sigjump-buffer
60  * (_SIGJBLEN) are defined by the appropriate, processor specific, ABI.
61  */
62 #if defined(__amd64)
63 #define	_JBLEN		128	/* must be the same as _SIGJBLEN for libucb */
64 #define	_SIGJBLEN	128	/* ABI value */
65 #elif defined(__i386)
66 #define	_JBLEN		128	/* must be the same as _SIGJBLEN for libucb */
67 #define	_SIGJBLEN	128	/* ABI value */
68 #elif defined(__sparcv9)
69 #define	_JBLEN		19	/* ABI value */
70 #define	_SIGJBLEN	19	/* ABI value */
71 #elif defined(__sparc)
72 #define	_JBLEN		19	/* _SIGJBLEN */
73 #define	_SIGJBLEN	19	/* ABI value */
74 #else
75 #error "ISA not supported"
76 #endif
77 
78 #if defined(__i386) || defined(__amd64) || \
79 	defined(__sparc) || defined(__sparcv9)
80 
81 #if !defined(_LP64) && defined(__cplusplus)
82 typedef int jmp_buf[_JBLEN];
83 #else
84 typedef long jmp_buf[_JBLEN];
85 #endif
86 
87 #else
88 #error "ISA not supported"
89 #endif
90 
91 #if defined(__i386) || defined(__amd64) || \
92 	defined(__sparc) || defined(__sparcv9)
93 
94 #if !defined(_LP64) && defined(__cplusplus)
95 typedef int sigjmp_buf[_SIGJBLEN];
96 #else
97 typedef long sigjmp_buf[_SIGJBLEN];
98 #endif
99 
100 #else
101 #error "ISA not supported"
102 #endif
103 
104 #define	setjmp(env)		_sigsetjmp((env), 1)
105 #define	longjmp(env, val)	_siglongjmp((env), (val))
106 #define	_setjmp(env)		_sigsetjmp((env), 0)
107 #define	_longjmp(env, val)	_siglongjmp((env), (val))
108 
109 #if defined(__STDC__)
110 
111 extern int _sigsetjmp(sigjmp_buf, int) __RETURNS_TWICE;
112 #pragma unknown_control_flow(_sigsetjmp)
113 extern void _siglongjmp(sigjmp_buf, int) __NORETURN;
114 
115 extern int	sigsetjmp(sigjmp_buf, int) __RETURNS_TWICE;
116 #pragma unknown_control_flow(sigsetjmp)
117 extern void	siglongjmp(sigjmp_buf, int) __NORETURN;
118 
119 #else
120 
121 extern int _sigsetjmp() __RETURNS_TWICE;
122 #pragma unknown_control_flow(_sigsetjmp)
123 extern void _siglongjmp();
124 
125 extern int sigsetjmp() __RETURNS_TWICE;
126 #pragma unknown_control_flow(sigsetjmp)
127 extern void siglongjmp();
128 
129 #endif  /* __STDC__ */
130 
131 #ifdef __cplusplus
132 }
133 #endif
134 
135 #endif /* _SETJMP_H */
136