]> git.saurik.com Git - apple/xnu.git/blob - bsd/i386/setjmp.h
a9d64e0547289b164733c5ea8e3101bc75335650
[apple/xnu.git] / bsd / i386 / setjmp.h
1 /*
2 * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22 /* Copyright (c) 1992 NeXT Computer, Inc. All rights reserved.
23 *
24 * File: setjmp.h
25 *
26 * Declaration of setjmp routines and data structures.
27 */
28 #ifndef _BSD_I386_SETJMP_H
29 #define _BSD_I386_SETJMP_H
30
31 #include <sys/cdefs.h>
32 #include <machine/signal.h>
33
34
35 #if defined(__x86_64__)
36 /*
37 * _JBLEN is number of ints required to save the following:
38 * rflags, rip, rbp, rsp, rbx, r12, r13, r14, r15... these are 8 bytes each
39 * mxcsr, fp control word, sigmask... these are 4 bytes each
40 * add 16 ints for future expansion needs...
41 */
42 #define _JBLEN ((9 * 2) + 3 + 16)
43 typedef int jmp_buf[_JBLEN];
44 typedef int sigjmp_buf[_JBLEN + 1];
45
46 #else
47
48 /*
49 * _JBLEN is number of ints required to save the following:
50 * eax, ebx, ecx, edx, edi, esi, ebp, esp, ss, eflags, eip,
51 * cs, de, es, fs, gs == 16 ints
52 * onstack, mask = 2 ints
53 */
54
55 #if defined(KERNEL)
56 typedef struct sigcontext jmp_buf[1];
57 #define _JBLEN ((sizeof(struct sigcontext)) / sizeof(int))
58 typedef int sigjmp_buf[_JBLEN+1];
59 #else
60 #define _JBLEN (18)
61 typedef int jmp_buf[_JBLEN];
62 typedef int sigjmp_buf[_JBLEN + 1];
63 #endif
64
65 #endif
66
67 __BEGIN_DECLS
68 extern int setjmp(jmp_buf env);
69 extern void longjmp(jmp_buf env, int val);
70
71 #ifndef _ANSI_SOURCE
72 int _setjmp(jmp_buf env);
73 void _longjmp(jmp_buf, int val);
74 int sigsetjmp(sigjmp_buf env, int val);
75 void siglongjmp(sigjmp_buf env, int val);
76 #endif /* _ANSI_SOURCE */
77
78 #if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE)
79 void longjmperror(void);
80 #endif /* neither ANSI nor POSIX */
81 __END_DECLS
82 #endif /* !_BSD_I386_SETJMP_H */