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