xref: /illumos-gate/usr/src/uts/sparc/sys/ucontext.h (revision 4eaa471005973e11a6110b69fe990530b3b95a38)
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 2003 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"	/* from SVr4.0 1.10 */
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 int	__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 
70 #endif /* _STACK_T */
71 #endif /* defined(_XPG4_2) && !defined(__EXTENSIONS__) */
72 
73 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
74 typedef	struct ucontext ucontext_t;
75 #else
76 typedef	struct __ucontext ucontext_t;
77 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
78 
79 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
80 struct	ucontext {
81 #else
82 struct	__ucontext {
83 #endif
84 	uint_t		uc_flags;
85 	ucontext_t	*uc_link;
86 	sigset_t   	uc_sigmask;
87 	stack_t 	uc_stack;
88 	mcontext_t	uc_mcontext;
89 #ifdef	__sparcv9
90 	long		uc_filler[4];
91 #else	/* __sparcv9 */
92 	long		uc_filler[23];
93 #endif	/* __sparcv9 */
94 };
95 
96 #ifdef _SYSCALL32
97 
98 /* Kernel view of user ILP32 ucontext structure */
99 
100 typedef struct ucontext32 {
101 	uint32_t	uc_flags;
102 	caddr32_t	uc_link;
103 	sigset32_t	uc_sigmask;
104 	stack32_t	uc_stack;
105 	mcontext32_t	uc_mcontext;
106 	int32_t		uc_filler[23];
107 } ucontext32_t;
108 
109 #ifdef _KERNEL
110 extern void ucontext_32ton(const ucontext32_t *, ucontext_t *,
111     const struct fq32 *, struct fq *);
112 extern void fpuregset_nto32(const fpregset_t *, fpregset32_t *, struct fq32 *);
113 #endif
114 
115 #endif	/* _SYSCALL32 */
116 
117 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
118 #define	GETCONTEXT	0
119 #define	SETCONTEXT	1
120 #define	GETUSTACK	2
121 #define	SETUSTACK	3
122 
123 /*
124  * values for uc_flags
125  * these are implementation dependent flags, that should be hidden
126  * from the user interface, defining which elements of ucontext
127  * are valid, and should be restored on call to setcontext
128  */
129 
130 #define	UC_SIGMASK	0x01
131 #define	UC_STACK	0x02
132 #define	UC_CPU		0x04
133 #define	UC_MAU		0x08
134 #define	UC_FPU		UC_MAU
135 #define	UC_INTR		0x10
136 #define	UC_ASR		0x20
137 
138 #define	UC_MCONTEXT	(UC_CPU|UC_FPU|UC_ASR)
139 
140 /*
141  * UC_ALL specifies the default context
142  */
143 
144 #define	UC_ALL		(UC_SIGMASK|UC_STACK|UC_MCONTEXT)
145 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
146 
147 #ifdef _KERNEL
148 extern void savecontext(ucontext_t *, k_sigset_t);
149 extern void restorecontext(ucontext_t *);
150 
151 #ifdef _SYSCALL32
152 extern void savecontext32(ucontext32_t *, k_sigset_t, struct fq32 *);
153 #endif
154 #endif
155 
156 #ifdef	__cplusplus
157 }
158 #endif
159 
160 #endif /* _SYS_UCONTEXT_H */
161