10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*11913SRoger.Faulkner@Sun.COM * Common Development and Distribution License (the "License"). 6*11913SRoger.Faulkner@Sun.COM * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 21*11913SRoger.Faulkner@Sun.COM 22*11913SRoger.Faulkner@Sun.COM /* 23*11913SRoger.Faulkner@Sun.COM * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 24*11913SRoger.Faulkner@Sun.COM * Use is subject to license terms. 25*11913SRoger.Faulkner@Sun.COM */ 26*11913SRoger.Faulkner@Sun.COM 270Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 280Sstevel@tonic-gate /* All Rights Reserved */ 290Sstevel@tonic-gate 300Sstevel@tonic-gate #ifndef _SYS_UCONTEXT_H 310Sstevel@tonic-gate #define _SYS_UCONTEXT_H 320Sstevel@tonic-gate 330Sstevel@tonic-gate #include <sys/feature_tests.h> 340Sstevel@tonic-gate 350Sstevel@tonic-gate #include <sys/types.h> 360Sstevel@tonic-gate #include <sys/regset.h> 370Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__) 380Sstevel@tonic-gate #include <sys/signal.h> 390Sstevel@tonic-gate #endif 400Sstevel@tonic-gate 410Sstevel@tonic-gate #ifdef __cplusplus 420Sstevel@tonic-gate extern "C" { 430Sstevel@tonic-gate #endif 440Sstevel@tonic-gate 450Sstevel@tonic-gate /* 460Sstevel@tonic-gate * Inclusion of <sys/signal.h> for sigset_t and stack_t definitions 470Sstevel@tonic-gate * breaks XPG4v2 namespace. Therefore we must duplicate the defines 480Sstevel@tonic-gate * for these types here when _XPG4_2 is defined. 490Sstevel@tonic-gate */ 500Sstevel@tonic-gate 510Sstevel@tonic-gate #if defined(_XPG4_2) && !defined(__EXTENSIONS__) 520Sstevel@tonic-gate #ifndef _SIGSET_T 530Sstevel@tonic-gate #define _SIGSET_T 540Sstevel@tonic-gate typedef struct { /* signal set type */ 550Sstevel@tonic-gate unsigned long __sigbits[4]; 560Sstevel@tonic-gate } sigset_t; 570Sstevel@tonic-gate #endif /* _SIGSET_T */ 580Sstevel@tonic-gate 590Sstevel@tonic-gate #ifndef _STACK_T 600Sstevel@tonic-gate #define _STACK_T 610Sstevel@tonic-gate typedef struct { 620Sstevel@tonic-gate void *ss_sp; 630Sstevel@tonic-gate size_t ss_size; 640Sstevel@tonic-gate int ss_flags; 650Sstevel@tonic-gate } stack_t; 660Sstevel@tonic-gate #endif /* _STACK_T */ 670Sstevel@tonic-gate #endif /* defined(_XPG4_2) && !defined(__EXTENSIONS__) */ 680Sstevel@tonic-gate 690Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__) 700Sstevel@tonic-gate typedef struct ucontext ucontext_t; 710Sstevel@tonic-gate #else 720Sstevel@tonic-gate typedef struct __ucontext ucontext_t; 730Sstevel@tonic-gate #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ 740Sstevel@tonic-gate 750Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__) 760Sstevel@tonic-gate struct ucontext { 770Sstevel@tonic-gate #else 780Sstevel@tonic-gate struct __ucontext { 790Sstevel@tonic-gate #endif 800Sstevel@tonic-gate unsigned long uc_flags; 810Sstevel@tonic-gate ucontext_t *uc_link; 820Sstevel@tonic-gate sigset_t uc_sigmask; 830Sstevel@tonic-gate stack_t uc_stack; 840Sstevel@tonic-gate mcontext_t uc_mcontext; 850Sstevel@tonic-gate long uc_filler[5]; /* see ABI spec for Intel386 */ 860Sstevel@tonic-gate }; 870Sstevel@tonic-gate 880Sstevel@tonic-gate #if defined(_SYSCALL32) 890Sstevel@tonic-gate 900Sstevel@tonic-gate /* Kernel view of user ILP32 ucontext structure */ 910Sstevel@tonic-gate 920Sstevel@tonic-gate typedef struct ucontext32 { 930Sstevel@tonic-gate uint32_t uc_flags; 940Sstevel@tonic-gate caddr32_t uc_link; 95*11913SRoger.Faulkner@Sun.COM sigset_t uc_sigmask; 960Sstevel@tonic-gate stack32_t uc_stack; 970Sstevel@tonic-gate mcontext32_t uc_mcontext; 980Sstevel@tonic-gate int32_t uc_filler[5]; 990Sstevel@tonic-gate } ucontext32_t; 1000Sstevel@tonic-gate 1010Sstevel@tonic-gate #if defined(_KERNEL) 1020Sstevel@tonic-gate extern void ucontext_nto32(const ucontext_t *src, ucontext32_t *dest); 1030Sstevel@tonic-gate extern void ucontext_32ton(const ucontext32_t *src, ucontext_t *dest); 1040Sstevel@tonic-gate #endif 1050Sstevel@tonic-gate 1060Sstevel@tonic-gate #endif /* _SYSCALL32 */ 1070Sstevel@tonic-gate 1080Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__) 1090Sstevel@tonic-gate #define GETCONTEXT 0 1100Sstevel@tonic-gate #define SETCONTEXT 1 1110Sstevel@tonic-gate #define GETUSTACK 2 1120Sstevel@tonic-gate #define SETUSTACK 3 1130Sstevel@tonic-gate 1140Sstevel@tonic-gate /* 1150Sstevel@tonic-gate * values for uc_flags 1160Sstevel@tonic-gate * these are implementation dependent flags, that should be hidden 1170Sstevel@tonic-gate * from the user interface, defining which elements of ucontext 1180Sstevel@tonic-gate * are valid, and should be restored on call to setcontext 1190Sstevel@tonic-gate */ 1200Sstevel@tonic-gate 1210Sstevel@tonic-gate #define UC_SIGMASK 0x01 1220Sstevel@tonic-gate #define UC_STACK 0x02 1230Sstevel@tonic-gate #define UC_CPU 0x04 1240Sstevel@tonic-gate #define UC_MAU 0x08 1250Sstevel@tonic-gate #define UC_FPU UC_MAU 1260Sstevel@tonic-gate 1270Sstevel@tonic-gate #define UC_MCONTEXT (UC_CPU|UC_FPU) 1280Sstevel@tonic-gate 1290Sstevel@tonic-gate /* 1300Sstevel@tonic-gate * UC_ALL specifies the default context 1310Sstevel@tonic-gate */ 1320Sstevel@tonic-gate 1330Sstevel@tonic-gate #define UC_ALL (UC_SIGMASK|UC_STACK|UC_MCONTEXT) 1340Sstevel@tonic-gate #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ 1350Sstevel@tonic-gate 1360Sstevel@tonic-gate #ifdef _KERNEL 137*11913SRoger.Faulkner@Sun.COM void savecontext(ucontext_t *, const k_sigset_t *); 1380Sstevel@tonic-gate void restorecontext(ucontext_t *); 1390Sstevel@tonic-gate 1400Sstevel@tonic-gate #ifdef _SYSCALL32 141*11913SRoger.Faulkner@Sun.COM extern void savecontext32(ucontext32_t *, const k_sigset_t *); 1420Sstevel@tonic-gate #endif 1430Sstevel@tonic-gate #endif 1440Sstevel@tonic-gate 1450Sstevel@tonic-gate #ifdef __cplusplus 1460Sstevel@tonic-gate } 1470Sstevel@tonic-gate #endif 1480Sstevel@tonic-gate 1490Sstevel@tonic-gate #endif /* _SYS_UCONTEXT_H */ 150