]> git.saurik.com Git - apple/objc4.git/blob - runtime/objc-config.h
objc4-779.1.tar.gz
[apple/objc4.git] / runtime / objc-config.h
1 /*
2 * Copyright (c) 1999-2002, 2005-2008 Apple 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
24 #ifndef _OBJC_CONFIG_H_
25 #define _OBJC_CONFIG_H_
26
27 #include <TargetConditionals.h>
28
29 // Define __OBJC2__ for the benefit of our asm files.
30 #ifndef __OBJC2__
31 # if TARGET_OS_OSX && !TARGET_OS_IOSMAC && __i386__
32 // old ABI
33 # else
34 # define __OBJC2__ 1
35 # endif
36 #endif
37
38 // Avoid the !NDEBUG double negative.
39 #if !NDEBUG
40 # define DEBUG 1
41 #else
42 # define DEBUG 0
43 #endif
44
45 // Define SUPPORT_GC_COMPAT=1 to enable compatibility where GC once was.
46 // OBJC_NO_GC and OBJC_NO_GC_API in objc-api.h mean something else.
47 #if !TARGET_OS_OSX
48 # define SUPPORT_GC_COMPAT 0
49 #else
50 # define SUPPORT_GC_COMPAT 1
51 #endif
52
53 // Define SUPPORT_ZONES=1 to enable malloc zone support in NXHashTable.
54 #if !(TARGET_OS_OSX || TARGET_OS_IOSMAC)
55 # define SUPPORT_ZONES 0
56 #else
57 # define SUPPORT_ZONES 1
58 #endif
59
60 // Define SUPPORT_MOD=1 to use the mod operator in NXHashTable and objc-sel-set
61 #if defined(__arm__)
62 # define SUPPORT_MOD 0
63 #else
64 # define SUPPORT_MOD 1
65 #endif
66
67 // Define SUPPORT_PREOPT=1 to enable dyld shared cache optimizations
68 #if TARGET_OS_WIN32
69 # define SUPPORT_PREOPT 0
70 #else
71 # define SUPPORT_PREOPT 1
72 #endif
73
74 // Define SUPPORT_TAGGED_POINTERS=1 to enable tagged pointer objects
75 // Be sure to edit tagged pointer SPI in objc-internal.h as well.
76 #if !(__OBJC2__ && __LP64__)
77 # define SUPPORT_TAGGED_POINTERS 0
78 #else
79 # define SUPPORT_TAGGED_POINTERS 1
80 #endif
81
82 // Define SUPPORT_MSB_TAGGED_POINTERS to use the MSB
83 // as the tagged pointer marker instead of the LSB.
84 // Be sure to edit tagged pointer SPI in objc-internal.h as well.
85 #if !SUPPORT_TAGGED_POINTERS || (TARGET_OS_OSX || TARGET_OS_IOSMAC)
86 # define SUPPORT_MSB_TAGGED_POINTERS 0
87 #else
88 # define SUPPORT_MSB_TAGGED_POINTERS 1
89 #endif
90
91 // Define SUPPORT_INDEXED_ISA=1 on platforms that store the class in the isa
92 // field as an index into a class table.
93 // Note, keep this in sync with any .s files which also define it.
94 // Be sure to edit objc-abi.h as well.
95 #if __ARM_ARCH_7K__ >= 2 || (__arm64__ && !__LP64__)
96 # define SUPPORT_INDEXED_ISA 1
97 #else
98 # define SUPPORT_INDEXED_ISA 0
99 #endif
100
101 // Define SUPPORT_PACKED_ISA=1 on platforms that store the class in the isa
102 // field as a maskable pointer with other data around it.
103 #if (!__LP64__ || TARGET_OS_WIN32 || \
104 (TARGET_OS_SIMULATOR && !TARGET_OS_IOSMAC))
105 # define SUPPORT_PACKED_ISA 0
106 #else
107 # define SUPPORT_PACKED_ISA 1
108 #endif
109
110 // Define SUPPORT_NONPOINTER_ISA=1 on any platform that may store something
111 // in the isa field that is not a raw pointer.
112 #if !SUPPORT_INDEXED_ISA && !SUPPORT_PACKED_ISA
113 # define SUPPORT_NONPOINTER_ISA 0
114 #else
115 # define SUPPORT_NONPOINTER_ISA 1
116 #endif
117
118 // Define SUPPORT_FIXUP=1 to repair calls sites for fixup dispatch.
119 // Fixup messaging itself is no longer supported.
120 // Be sure to edit objc-abi.h as well (objc_msgSend*_fixup)
121 #if !(defined(__x86_64__) && (TARGET_OS_OSX || TARGET_OS_SIMULATOR))
122 # define SUPPORT_FIXUP 0
123 #else
124 # define SUPPORT_FIXUP 1
125 #endif
126
127 // Define SUPPORT_ZEROCOST_EXCEPTIONS to use "zero-cost" exceptions for OBJC2.
128 // Be sure to edit objc-exception.h as well (objc_add/removeExceptionHandler)
129 #if !__OBJC2__ || (defined(__arm__) && __USING_SJLJ_EXCEPTIONS__)
130 # define SUPPORT_ZEROCOST_EXCEPTIONS 0
131 #else
132 # define SUPPORT_ZEROCOST_EXCEPTIONS 1
133 #endif
134
135 // Define SUPPORT_ALT_HANDLERS if you're using zero-cost exceptions
136 // but also need to support AppKit's alt-handler scheme
137 // Be sure to edit objc-exception.h as well (objc_add/removeExceptionHandler)
138 #if !SUPPORT_ZEROCOST_EXCEPTIONS || !TARGET_OS_OSX
139 # define SUPPORT_ALT_HANDLERS 0
140 #else
141 # define SUPPORT_ALT_HANDLERS 1
142 #endif
143
144 // Define SUPPORT_RETURN_AUTORELEASE to optimize autoreleased return values
145 #if TARGET_OS_WIN32
146 # define SUPPORT_RETURN_AUTORELEASE 0
147 #else
148 # define SUPPORT_RETURN_AUTORELEASE 1
149 #endif
150
151 // Define SUPPORT_STRET on architectures that need separate struct-return ABI.
152 #if defined(__arm64__)
153 # define SUPPORT_STRET 0
154 #else
155 # define SUPPORT_STRET 1
156 #endif
157
158 // Define SUPPORT_MESSAGE_LOGGING to enable NSObjCMessageLoggingEnabled
159 #if !TARGET_OS_OSX
160 # define SUPPORT_MESSAGE_LOGGING 0
161 #else
162 # define SUPPORT_MESSAGE_LOGGING 1
163 #endif
164
165 // Define HAVE_TASK_RESTARTABLE_RANGES to enable usage of
166 // task_restartable_ranges_synchronize()
167 #if TARGET_OS_SIMULATOR || defined(__i386__) || defined(__arm__) || !TARGET_OS_MAC
168 # define HAVE_TASK_RESTARTABLE_RANGES 0
169 #else
170 # define HAVE_TASK_RESTARTABLE_RANGES 1
171 #endif
172
173 // OBJC_INSTRUMENTED controls whether message dispatching is dynamically
174 // monitored. Monitoring introduces substantial overhead.
175 // NOTE: To define this condition, do so in the build command, NOT by
176 // uncommenting the line here. This is because objc-class.h heeds this
177 // condition, but objc-class.h can not #include this file (objc-config.h)
178 // because objc-class.h is public and objc-config.h is not.
179 //#define OBJC_INSTRUMENTED
180
181 // In __OBJC2__, the runtimeLock is a mutex always held
182 // hence the cache lock is redundant and can be elided.
183 //
184 // If the runtime lock ever becomes a rwlock again,
185 // the cache lock would need to be used again
186 #if __OBJC2__
187 #define CONFIG_USE_CACHE_LOCK 0
188 #else
189 #define CONFIG_USE_CACHE_LOCK 1
190 #endif
191
192 // Determine how the method cache stores IMPs.
193 #define CACHE_IMP_ENCODING_NONE 1 // Method cache contains raw IMP.
194 #define CACHE_IMP_ENCODING_ISA_XOR 2 // Method cache contains ISA ^ IMP.
195 #define CACHE_IMP_ENCODING_PTRAUTH 3 // Method cache contains ptrauth'd IMP.
196
197 #if __PTRAUTH_INTRINSICS__
198 // Always use ptrauth when it's supported.
199 #define CACHE_IMP_ENCODING CACHE_IMP_ENCODING_PTRAUTH
200 #elif defined(__arm__)
201 // 32-bit ARM uses no encoding.
202 #define CACHE_IMP_ENCODING CACHE_IMP_ENCODING_NONE
203 #else
204 // Everything else uses ISA ^ IMP.
205 #define CACHE_IMP_ENCODING CACHE_IMP_ENCODING_ISA_XOR
206 #endif
207
208 #define CACHE_MASK_STORAGE_OUTLINED 1
209 #define CACHE_MASK_STORAGE_HIGH_16 2
210 #define CACHE_MASK_STORAGE_LOW_4 3
211
212 #if defined(__arm64__) && __LP64__
213 #define CACHE_MASK_STORAGE CACHE_MASK_STORAGE_HIGH_16
214 #elif defined(__arm64__) && !__LP64__
215 #define CACHE_MASK_STORAGE CACHE_MASK_STORAGE_LOW_4
216 #else
217 #define CACHE_MASK_STORAGE CACHE_MASK_STORAGE_OUTLINED
218 #endif
219
220 #endif