xref: /illumos-gate/usr/src/uts/sparc/sys/ucontext.h (revision 66582b606a8194f7f3ba5b3a3a6dca5b0d346361)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
24  *
25  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
26  * Use is subject to license terms.
27  */
28 
29 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
30 /*	  All Rights Reserved  	*/
31 
32 #ifndef _SYS_UCONTEXT_H
33 #define	_SYS_UCONTEXT_H
34 
35 #include <sys/feature_tests.h>
36 
37 #include <sys/types.h>
38 #include <sys/mcontext.h>
39 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
40 #include <sys/signal.h>
41 #endif
42 
43 #ifdef	__cplusplus
44 extern "C" {
45 #endif
46 
47 /*
48  * Inclusion of <sys/signal.h> for sigset_t and stack_t definitions
49  * breaks XPG4v2 namespace.  Therefore we must duplicate the defines
50  * for these types here when _XPG4_2 is defined.
51  */
52 
53 #if defined(_XPG4_2) && !defined(__EXTENSIONS__)
54 #ifndef	_SIGSET_T
55 #define	_SIGSET_T
56 typedef	struct {	/* signal set type */
57 	unsigned int	__sigbits[4];
58 } sigset_t;
59 #endif /* _SIGSET_T */
60 
61 #ifndef	_STACK_T
62 #define	_STACK_T
63 typedef	struct {
64 	void	*ss_sp;
65 	size_t	ss_size;
66 	int	ss_flags;
67 } stack_t;
68 
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 	uint_t		uc_flags;
84 	ucontext_t	*uc_link;
85 	sigset_t   	uc_sigmask;
86 	stack_t 	uc_stack;
87 	mcontext_t	uc_mcontext;
88 #ifdef	__sparcv9
89 	long		uc_filler[4];
90 #else	/* __sparcv9 */
91 	long		uc_filler[23];
92 #endif	/* __sparcv9 */
93 };
94 
95 #ifdef _SYSCALL32
96 
97 /* Kernel view of user ILP32 ucontext structure */
98 
99 typedef struct ucontext32 {
100 	uint32_t	uc_flags;
101 	caddr32_t	uc_link;
102 	sigset_t	uc_sigmask;
103 	stack32_t	uc_stack;
104 	mcontext32_t	uc_mcontext;
105 	int32_t		uc_filler[23];
106 } ucontext32_t;
107 
108 #ifdef _KERNEL
109 extern void ucontext_32ton(const ucontext32_t *, ucontext_t *,
110     const struct fq32 *, struct _fq *);
111 extern void fpuregset_nto32(const fpregset_t *, fpregset32_t *, struct fq32 *);
112 #endif
113 
114 #endif	/* _SYSCALL32 */
115 
116 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
117 #define	GETCONTEXT	0
118 #define	SETCONTEXT	1
119 #define	GETUSTACK	2
120 #define	SETUSTACK	3
121 
122 /*
123  * values for uc_flags
124  * these are implementation dependent flags, that should be hidden
125  * from the user interface, defining which elements of ucontext
126  * are valid, and should be restored on call to setcontext
127  */
128 
129 #define	UC_SIGMASK	0x01
130 #define	UC_STACK	0x02
131 #define	UC_CPU		0x04
132 #define	UC_MAU		0x08
133 #define	UC_FPU		UC_MAU
134 #define	UC_INTR		0x10
135 #define	UC_ASR		0x20
136 
137 #define	UC_MCONTEXT	(UC_CPU|UC_FPU|UC_ASR)
138 
139 /*
140  * UC_ALL specifies the default context
141  */
142 
143 #define	UC_ALL		(UC_SIGMASK|UC_STACK|UC_MCONTEXT)
144 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
145 
146 #ifdef _KERNEL
147 extern void savecontext(ucontext_t *, const k_sigset_t *);
148 extern void restorecontext(ucontext_t *);
149 
150 #ifdef _SYSCALL32
151 extern void savecontext32(ucontext32_t *, const k_sigset_t *, struct fq32 *);
152 #endif
153 #endif
154 
155 #ifdef	__cplusplus
156 }
157 #endif
158 
159 #endif /* _SYS_UCONTEXT_H */
160