xref: /titanic_44/usr/src/ucbhead/setjmp.h (revision 03831d35f7499c87d51205817c93e9a8d42c4bae)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
51 
52 #include <sys/types.h>
53 #include <sys/signal.h>
54 #include <sys/ucontext.h>
55 
56 #ifdef __cplusplus
57 extern "C" {
58 #endif
59 
60 /*
61  * The sizes of the jump-buffer (_JBLEN) and the sigjump-buffer
62  * (_SIGJBLEN) are defined by the appropriate, processor specific, ABI.
63  */
64 #if defined(__amd64)
65 #define	_JBLEN		128	/* must be the same as _SIGJBLEN for libucb */
66 #define	_SIGJBLEN	128	/* ABI value */
67 #elif defined(__i386)
68 #define	_JBLEN		128	/* must be the same as _SIGJBLEN for libucb */
69 #define	_SIGJBLEN	128	/* ABI value */
70 #elif defined(__sparcv9)
71 #define	_JBLEN		19	/* ABI value */
72 #define	_SIGJBLEN	19	/* ABI value */
73 #elif defined(__sparc)
74 #define	_JBLEN		19	/* _SIGJBLEN */
75 #define	_SIGJBLEN	19	/* ABI value */
76 #else
77 #error "ISA not supported"
78 #endif
79 
80 #if defined(__i386) || defined(__amd64) || \
81 	defined(__sparc) || defined(__sparcv9)
82 
83 #if !defined(_LP64) && defined(__cplusplus)
84 typedef int jmp_buf[_JBLEN];
85 #else
86 typedef long jmp_buf[_JBLEN];
87 #endif
88 
89 #else
90 #error "ISA not supported"
91 #endif
92 
93 #if defined(__i386) || defined(__amd64) || \
94 	defined(__sparc) || defined(__sparcv9)
95 
96 #if !defined(_LP64) && defined(__cplusplus)
97 typedef int sigjmp_buf[_SIGJBLEN];
98 #else
99 typedef long sigjmp_buf[_SIGJBLEN];
100 #endif
101 
102 #else
103 #error "ISA not supported"
104 #endif
105 
106 #define	setjmp(env)		_sigsetjmp((env), 1)
107 #define	longjmp(env, val)	_siglongjmp((env), (val))
108 #define	_setjmp(env)		_sigsetjmp((env), 0)
109 #define	_longjmp(env, val)	_siglongjmp((env), (val))
110 
111 #if defined(__STDC__)
112 
113 extern int _sigsetjmp(sigjmp_buf, int);
114 #pragma unknown_control_flow(_sigsetjmp)
115 extern void _siglongjmp(sigjmp_buf, int) __NORETURN;
116 
117 extern int	sigsetjmp(sigjmp_buf, int);
118 #pragma unknown_control_flow(sigsetjmp)
119 extern void	siglongjmp(sigjmp_buf, int) __NORETURN;
120 
121 #else
122 
123 extern int _sigsetjmp();
124 #pragma unknown_control_flow(_sigsetjmp)
125 extern void _siglongjmp();
126 
127 extern int sigsetjmp();
128 #pragma unknown_control_flow(sigsetjmp)
129 extern void siglongjmp();
130 
131 #endif  /* __STDC__ */
132 
133 #ifdef __cplusplus
134 }
135 #endif
136 
137 #endif /* _SETJMP_H */
138