setjmp.h (3139B) - Raw
1 /* 2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 6 * This file contains Original Code and/or Modifications of Original Code 7 * as defined in and that are subject to the Apple Public Source License 8 * Version 2.0 (the 'License'). You may not use this file except in 9 * compliance with the License. Please obtain a copy of the License at 10 * http://www.opensource.apple.com/apsl/ and read it before using this 11 * file. 12 * 13 * The Original Code and all software distributed under the License are 14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 * Please see the License for the specific language governing rights and 19 * limitations under the License. 20 * 21 * @APPLE_LICENSE_HEADER_END@ 22 */ 23 #ifndef _BSD_SETJMP_H 24 #define _BSD_SETJMP_H 25 26 #include <sys/cdefs.h> 27 #include <Availability.h> 28 29 #if defined(__x86_64__) 30 /* 31 * _JBLEN is number of ints required to save the following: 32 * rflags, rip, rbp, rsp, rbx, r12, r13, r14, r15... these are 8 bytes each 33 * mxcsr, fp control word, sigmask... these are 4 bytes each 34 * add 16 ints for future expansion needs... 35 */ 36 #define _JBLEN ((9 * 2) + 3 + 16) 37 typedef int jmp_buf[_JBLEN]; 38 typedef int sigjmp_buf[_JBLEN + 1]; 39 40 #elif defined(__i386__) 41 42 /* 43 * _JBLEN is number of ints required to save the following: 44 * eax, ebx, ecx, edx, edi, esi, ebp, esp, ss, eflags, eip, 45 * cs, de, es, fs, gs == 16 ints 46 * onstack, mask = 2 ints 47 */ 48 49 #define _JBLEN (18) 50 typedef int jmp_buf[_JBLEN]; 51 typedef int sigjmp_buf[_JBLEN + 1]; 52 53 #elif defined(__arm__) && !defined(__ARM_ARCH_7K__) 54 55 #include <machine/signal.h> 56 57 /* 58 * _JBLEN is number of ints required to save the following: 59 * r4-r8, r10, fp, sp, lr, sig == 10 register_t sized 60 * s16-s31 == 16 register_t sized + 1 int for FSTMX 61 * 1 extra int for future use 62 */ 63 #define _JBLEN (10 + 16 + 2) 64 #define _JBLEN_MAX _JBLEN 65 66 typedef int jmp_buf[_JBLEN]; 67 typedef int sigjmp_buf[_JBLEN + 1]; 68 69 #elif defined(__arm64__) || defined(__ARM_ARCH_7K__) 70 /* 71 * _JBLEN is the number of ints required to save the following: 72 * r21-r29, sp, fp, lr == 12 registers, 8 bytes each. d8-d15 73 * are another 8 registers, each 8 bytes long. (aapcs64 specifies 74 * that only 64-bit versions of FP registers need to be saved). 75 * Finally, two 8-byte fields for signal handling purposes. 76 */ 77 #define _JBLEN ((14 + 8 + 2) * 2) 78 79 typedef int jmp_buf[_JBLEN]; 80 typedef int sigjmp_buf[_JBLEN + 1]; 81 82 #else 83 # error Undefined platform for setjmp 84 #endif 85 86 __BEGIN_DECLS 87 extern int setjmp(jmp_buf); 88 extern void longjmp(jmp_buf, int) __dead2; 89 90 #ifndef _ANSI_SOURCE 91 int _setjmp(jmp_buf); 92 void _longjmp(jmp_buf, int) __dead2; 93 int sigsetjmp(sigjmp_buf, int); 94 void siglongjmp(sigjmp_buf, int) __dead2; 95 #endif /* _ANSI_SOURCE */ 96 97 #if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) 98 void longjmperror(void); 99 #endif /* neither ANSI nor POSIX */ 100 __END_DECLS 101 102 #endif /* _BSD_SETJMP_H */