xref: /titanic_52/usr/src/uts/intel/sys/ucontext.h (revision 5c51f1241dbbdf2656d0e10011981411ed0c9673)
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 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
23 /*	  All Rights Reserved  	*/
24 
25 
26 /*
27  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
28  * Use is subject to license terms.
29  */
30 
31 #ifndef _SYS_UCONTEXT_H
32 #define	_SYS_UCONTEXT_H
33 
34 #pragma ident	"%Z%%M%	%I%	%E% SMI"
35 
36 #include <sys/feature_tests.h>
37 
38 #include <sys/types.h>
39 #include <sys/regset.h>
40 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
41 #include <sys/signal.h>
42 #endif
43 
44 #ifdef	__cplusplus
45 extern "C" {
46 #endif
47 
48 /*
49  * Inclusion of <sys/signal.h> for sigset_t and stack_t definitions
50  * breaks XPG4v2 namespace.  Therefore we must duplicate the defines
51  * for these types here when _XPG4_2 is defined.
52  */
53 
54 #if defined(_XPG4_2) && !defined(__EXTENSIONS__)
55 #ifndef	_SIGSET_T
56 #define	_SIGSET_T
57 typedef	struct {	/* signal set type */
58 	unsigned long	__sigbits[4];
59 } sigset_t;
60 #endif /* _SIGSET_T */
61 
62 #ifndef	_STACK_T
63 #define	_STACK_T
64 typedef	struct {
65 	void	*ss_sp;
66 	size_t	ss_size;
67 	int	ss_flags;
68 } stack_t;
69 #endif /* _STACK_T */
70 #endif /* defined(_XPG4_2) && !defined(__EXTENSIONS__) */
71 
72 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
73 typedef	struct ucontext ucontext_t;
74 #else
75 typedef	struct __ucontext ucontext_t;
76 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
77 
78 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
79 struct	ucontext {
80 #else
81 struct	__ucontext {
82 #endif
83 	unsigned long	uc_flags;
84 	ucontext_t	*uc_link;
85 	sigset_t   	uc_sigmask;
86 	stack_t 	uc_stack;
87 	mcontext_t 	uc_mcontext;
88 	long		uc_filler[5];	/* see ABI spec for Intel386 */
89 };
90 
91 #if defined(_SYSCALL32)
92 
93 /* Kernel view of user ILP32 ucontext structure */
94 
95 typedef struct ucontext32 {
96 	uint32_t	uc_flags;
97 	caddr32_t	uc_link;
98 	sigset32_t	uc_sigmask;
99 	stack32_t	uc_stack;
100 	mcontext32_t	uc_mcontext;
101 	int32_t		uc_filler[5];
102 } ucontext32_t;
103 
104 #if defined(_KERNEL)
105 extern void ucontext_nto32(const ucontext_t *src, ucontext32_t *dest);
106 extern void ucontext_32ton(const ucontext32_t *src, ucontext_t *dest);
107 #endif
108 
109 #endif	/* _SYSCALL32 */
110 
111 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
112 #define	GETCONTEXT	0
113 #define	SETCONTEXT	1
114 #define	GETUSTACK	2
115 #define	SETUSTACK	3
116 
117 /*
118  * values for uc_flags
119  * these are implementation dependent flags, that should be hidden
120  * from the user interface, defining which elements of ucontext
121  * are valid, and should be restored on call to setcontext
122  */
123 
124 #define	UC_SIGMASK	0x01
125 #define	UC_STACK	0x02
126 #define	UC_CPU		0x04
127 #define	UC_MAU		0x08
128 #define	UC_FPU		UC_MAU
129 
130 #define	UC_MCONTEXT	(UC_CPU|UC_FPU)
131 
132 /*
133  * UC_ALL specifies the default context
134  */
135 
136 #define	UC_ALL		(UC_SIGMASK|UC_STACK|UC_MCONTEXT)
137 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
138 
139 #ifdef _KERNEL
140 void savecontext(ucontext_t *, k_sigset_t);
141 void restorecontext(ucontext_t *);
142 
143 #ifdef _SYSCALL32
144 extern void savecontext32(ucontext32_t *ucp, k_sigset_t mask);
145 #endif
146 #endif
147 
148 #ifdef	__cplusplus
149 }
150 #endif
151 
152 #endif /* _SYS_UCONTEXT_H */
153