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