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 (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 24 */ 25 26 #ifndef _SIGJMP_STRUCT_H 27 #define _SIGJMP_STRUCT_H 28 29 #ifdef __cplusplus 30 extern "C" { 31 #endif 32 33 #include <sys/types.h> 34 #include <sys/stack.h> 35 #include <sys/sysmacros.h> 36 #include <ucontext.h> 37 #include <setjmp.h> 38 39 #if defined(__sparc) 40 41 /* 42 * The following structure MUST match the ABI size specifier _SIGJBLEN. 43 * This is 19 (longs). The ABI value for _JBLEN is 12 (longs). 44 * A greg_t is a long. A sigset_t is 4 ints and a stack_t is 3 longs. 45 * 46 * The layout of this structure must match the layout of the same 47 * structures defined in usr/src/lib/libbc/libc/sys/common/ucontext.h 48 * and usr/src/ucblib/libucb/sparc/sys/setjmp.c. Other than that, 49 * the layout is private, not known to applications. 50 * 51 * We make the first 5 members match the implementations of 52 * setjmp()/longjmp(), so that an application could (stupidly) 53 * do sigsetjmp(env) followed by longjmp(env) (but not setjmp(env) 54 * followed by siglongjmp(env)). 55 */ 56 typedef struct { 57 int sjs_flags; /* JBUF[ 0] */ 58 greg_t sjs_sp; /* JBUF[ 1] */ 59 greg_t sjs_pc; /* JBUF[ 2] */ 60 greg_t sjs_fp; /* JBUF[ 3] */ 61 greg_t sjs_i7; /* JBUF[ 4] */ 62 ucontext_t *sjs_uclink; 63 ulong_t sjs_pad[_JBLEN - 6]; 64 sigset_t sjs_sigmask; 65 #if defined(_LP64) 66 greg_t sjs_asi; 67 greg_t sjs_fprs; 68 #endif 69 stack_t sjs_stack; 70 } sigjmp_struct_t; 71 72 #define JB_SAVEMASK 0x1 73 #define JB_FRAMEPTR 0x2 74 75 #endif /* __sparc */ 76 77 #if defined(__amd64) 78 /* 79 * The "sigjmp_buf" type is an array of long and thus can have 8-byte alignment 80 * on AMD64 systems. The "ucontext_t" type has a stricter 16-byte alignment 81 * requirement, so we must round the pointer up when casting. 82 * 83 * This is not required on other architectures: 84 * - SPARC does not store the ucontext_t in the sigjmp_buf 85 * - i386 only requires 4-byte alignment for ucontext_t 86 */ 87 #define SIGJMP2UCONTEXT(x) \ 88 ((ucontext_t *)P2ROUNDUP((uintptr_t)(x), sizeof (upad128_t))) 89 #endif 90 91 #ifdef __cplusplus 92 } 93 #endif 94 95 #endif /* _SIGJMP_STRUCT_H */ 96