1 // Copyright 2014 The Crashpad Authors. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef CRASHPAD_COMPAT_MAC_MACH_MACH_H_
16 #define CRASHPAD_COMPAT_MAC_MACH_MACH_H_
17 
18 #include_next <mach/mach.h>
19 
20 // <mach/exception_types.h>
21 
22 // 10.8 SDK
23 
24 #ifndef EXC_RESOURCE
25 #define EXC_RESOURCE 11
26 #endif
27 
28 #ifndef EXC_MASK_RESOURCE
29 #define EXC_MASK_RESOURCE (1 << EXC_RESOURCE)
30 #endif
31 
32 // 10.9 SDK
33 
34 #ifndef EXC_GUARD
35 #define EXC_GUARD 12
36 #endif
37 
38 #ifndef EXC_MASK_GUARD
39 #define EXC_MASK_GUARD (1 << EXC_GUARD)
40 #endif
41 
42 // 10.11 SDK
43 
44 #ifndef EXC_CORPSE_NOTIFY
45 #define EXC_CORPSE_NOTIFY 13
46 #endif
47 
48 #ifndef EXC_MASK_CORPSE_NOTIFY
49 #define EXC_MASK_CORPSE_NOTIFY (1 << EXC_CORPSE_NOTIFY)
50 #endif
51 
52 // Don’t expose EXC_MASK_ALL at all, because its definition varies with SDK, and
53 // older kernels will reject values that they don’t understand. Instead, use
54 // crashpad::ExcMaskAll(), which computes the correct value of EXC_MASK_ALL for
55 // the running system.
56 #undef EXC_MASK_ALL
57 
58 #if defined(__i386__) || defined(__x86_64__)
59 
60 // <mach/i386/exception.h>
61 
62 // 10.11 SDK
63 
64 #if EXC_TYPES_COUNT > 14  // Definition varies with SDK
65 #error Update this file for new exception types
66 #elif EXC_TYPES_COUNT != 14
67 #undef EXC_TYPES_COUNT
68 #define EXC_TYPES_COUNT 14
69 #endif
70 
71 // <mach/i386/thread_status.h>
72 
73 // 10.6 SDK
74 //
75 // Earlier versions of this SDK didn’t have AVX definitions. They didn’t appear
76 // until the version of the 10.6 SDK that shipped with Xcode 4.2, although
77 // versions of this SDK appeared with Xcode releases as early as Xcode 3.2.
78 // Similarly, the kernel didn’t handle AVX state until Mac OS X 10.6.8
79 // (xnu-1504.15.3) and presumably the hardware-specific versions of Mac OS X
80 // 10.6.7 intended to run on processors with AVX.
81 
82 #ifndef x86_AVX_STATE32
83 #define x86_AVX_STATE32 16
84 #endif
85 
86 #ifndef x86_AVX_STATE64
87 #define x86_AVX_STATE64 17
88 #endif
89 
90 // 10.8 SDK
91 
92 #ifndef x86_AVX_STATE
93 #define x86_AVX_STATE 18
94 #endif
95 
96 // 10.13 SDK
97 
98 #ifndef x86_AVX512_STATE32
99 #define x86_AVX512_STATE32 19
100 #endif
101 
102 #ifndef x86_AVX512_STATE64
103 #define x86_AVX512_STATE64 20
104 #endif
105 
106 #ifndef x86_AVX512_STATE
107 #define x86_AVX512_STATE 21
108 #endif
109 
110 #endif  // defined(__i386__) || defined(__x86_64__)
111 
112 // <mach/thread_status.h>
113 
114 // 10.8 SDK
115 
116 #ifndef THREAD_STATE_FLAVOR_LIST_10_9
117 #define THREAD_STATE_FLAVOR_LIST_10_9 129
118 #endif
119 
120 #endif  // CRASHPAD_COMPAT_MAC_MACH_MACH_H_
121