]> git.saurik.com Git - apple/xnu.git/blob - bsd/ppc/setjmp.h
be2d04a225ad51df35e726ab5b3b0546c7c3d624
[apple/xnu.git] / bsd / ppc / setjmp.h
1 /*
2 * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved.
3 *
4 * @APPLE_LICENSE_OSREFERENCE_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. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
14 * agreement.
15 *
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
18 * file.
19 *
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
27 *
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
29 */
30 /* Copyright (c) 1998 Apple Computer, Inc. All rights reserved.
31 *
32 * File: ppc/setjmp.h
33 *
34 * Declaration of setjmp routines and data structures.
35 */
36 #ifndef _BSD_PPC_SETJMP_H_
37 #define _BSD_PPC_SETJMP_H_
38
39 #include <sys/cdefs.h>
40 #include <machine/signal.h>
41
42 struct _jmp_buf {
43 struct sigcontext sigcontext; /* kernel state preserved by set/longjmp */
44 unsigned int vmask __attribute__((aligned(8))); /* vector mask register */
45 unsigned int vreg[32 * 4] __attribute__((aligned(16)));
46 /* 32 128-bit vector registers */
47 };
48
49 /*
50 * _JBLEN is number of ints required to save the following:
51 * r1, r2, r13-r31, lr, cr, ctr, xer, sig == 26 register_t sized
52 * fr14 - fr31 = 18 doubles
53 * vmask, 32 vector registers = 129 ints
54 * 2 ints to get all the elements aligned
55 *
56 * register_t is 2 ints for ppc64 threads
57 */
58 #define _JBLEN64 (26*2 + 18*2 + 129 + 1)
59 #define _JBLEN32 (26 + 18*2 + 129 + 1)
60 #define _JBLEN_MAX _JBLEN64
61
62 /*
63 * Locally scoped sizes
64 */
65 #if defined(__ppc64__)
66 #define _JBLEN _JBLEN64
67 #else
68 #define _JBLEN _JBLEN32
69 #endif
70
71 #if defined(KERNEL)
72 typedef struct sigcontext32 jmp_buf32[1];
73 typedef struct __sigjmp_buf32 {
74 int __storage[_JBLEN32 + 1] __attribute__((aligned(8)));
75 } sigjmp_buf32[1];
76
77 typedef struct sigcontext64 jmp_buf64[1];
78 typedef struct __sigjmp_buf64 {
79 int __storage[_JBLEN64 + 1] __attribute__((aligned(8)));
80 } sigjmp_buf64[1];
81
82 /*
83 * JMM - have to decide how the kernel will deal with this.
84 * For now, hard-code the 32-bit types.
85 */
86 typedef struct sigcontext32 jmp_buf[1];
87 typedef struct __sigjmp_buf32 sigjmp_buf[1];
88
89 #else
90 typedef int jmp_buf[_JBLEN];
91 typedef int sigjmp_buf[_JBLEN + 1];
92 #endif
93
94 __BEGIN_DECLS
95 extern int setjmp(jmp_buf env);
96 extern void longjmp(jmp_buf env, int val);
97
98 #ifndef _ANSI_SOURCE
99 int _setjmp(jmp_buf env);
100 void _longjmp(jmp_buf, int val);
101 int sigsetjmp(sigjmp_buf env, int val);
102 void siglongjmp(sigjmp_buf env, int val);
103 #endif /* _ANSI_SOURCE */
104
105 #if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE)
106 void longjmperror(void);
107 #endif /* neither ANSI nor POSIX */
108 __END_DECLS
109
110 #endif /* !_BSD_PPC_SETJMP_H_ */