]> git.saurik.com Git - apple/objc4.git/blob - runtime/objc-abi.h
objc4-493.11.tar.gz
[apple/objc4.git] / runtime / objc-abi.h
1 /*
2 * Copyright (c) 2009 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
25 #ifndef _OBJC_ABI_H
26 #define _OBJC_ABI_H
27
28 /*
29 * WARNING DANGER HAZARD BEWARE EEK
30 *
31 * Everything in this file is for Apple Internal use only.
32 * These will change in arbitrary OS updates and in unpredictable ways.
33 * When your program breaks, you get to keep both pieces.
34 */
35
36 /*
37 * objc-abi.h: Declarations for functions used by compiler codegen.
38 */
39
40 #include <malloc/malloc.h>
41 #include <objc/objc.h>
42 #include <objc/runtime.h>
43 #include <objc/message.h>
44
45 /* Runtime startup. */
46
47 // Old static initializer. Used by old crt1.o and old bug workarounds.
48 OBJC_EXPORT void _objcInit(void)
49 __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_2_0);
50
51
52 /* Properties */
53
54 // Read or write an object property. Not all object properties use these.
55 OBJC_EXPORT id objc_getProperty(id self, SEL _cmd, ptrdiff_t offset, BOOL atomic)
56 __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
57 OBJC_EXPORT void objc_setProperty(id self, SEL _cmd, ptrdiff_t offset, id newValue, BOOL atomic, BOOL shouldCopy)
58 __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
59
60 // Read or write a non-object property. Not all uses are C structs,
61 // and not all C struct properties use this.
62 OBJC_EXPORT void objc_copyStruct(void *dest, const void *src, ptrdiff_t size, BOOL atomic, BOOL hasStrong)
63 __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
64
65
66 /* Classes. */
67 #if __OBJC2__
68 OBJC_EXPORT IMP _objc_empty_vtable
69 __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
70 #endif
71 OBJC_EXPORT struct objc_cache _objc_empty_cache
72 __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_2_0);
73
74
75 /* Messages */
76
77 #if __OBJC2__
78 // objc_msgSendSuper2() takes the current search class, not its superclass.
79 OBJC_EXPORT id objc_msgSendSuper2(struct objc_super *super, SEL op, ...)
80 __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
81 OBJC_EXPORT void objc_msgSendSuper2_stret(struct objc_super *super, SEL op,...)
82 __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
83
84 // objc_msgSend_noarg() may be faster for methods with no additional arguments.
85 OBJC_EXPORT id objc_msgSend_noarg(id self, SEL _cmd)
86 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0);
87 #endif
88
89 #if __OBJC2__
90 // Debug messengers. Messengers used by the compiler have a debug flavor that
91 // may perform extra sanity checking.
92 // Old objc_msgSendSuper() does not have a debug version; this is OBJC2 only.
93 // *_fixup() do not have debug versions; use non-fixup only for debug mode.
94 OBJC_EXPORT id objc_msgSend_debug(id self, SEL op, ...)
95 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0);
96 OBJC_EXPORT id objc_msgSendSuper2_debug(struct objc_super *super, SEL op, ...)
97 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0);
98 OBJC_EXPORT void objc_msgSend_stret_debug(id self, SEL op, ...)
99 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0);
100 OBJC_EXPORT void objc_msgSendSuper2_stret_debug(struct objc_super *super, SEL op,...)
101 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0);
102
103 # if defined(__i386__)
104 OBJC_EXPORT double objc_msgSend_fpret_debug(id self, SEL op, ...)
105 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0);
106 # elif defined(__x86_64__)
107 OBJC_EXPORT long double objc_msgSend_fpret_debug(id self, SEL op, ...)
108 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0);
109 # if __STDC_VERSION__ >= 199901L
110 OBJC_EXPORT _Complex long double objc_msgSend_fp2ret_debug(id self, SEL op, ...)
111 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0);
112 # else
113 OBJC_EXPORT void objc_msgSend_fp2ret_debug(id self, SEL op, ...)
114 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0);
115 # endif
116 # endif
117
118 #endif
119
120 #if __OBJC2__ && defined(__x86_64__)
121 // objc_msgSend_fixup() is used for vtable-dispatchable call sites.
122 OBJC_EXPORT id objc_msgSend_fixup(id self, SEL op, ...)
123 __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_NA);
124 OBJC_EXPORT void objc_msgSend_stret_fixup(id self, SEL op, ...)
125 __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_NA);
126 OBJC_EXPORT id objc_msgSendSuper2_fixup(struct objc_super *super, SEL op, ...)
127 __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_NA);
128 OBJC_EXPORT void objc_msgSendSuper2_stret_fixup(struct objc_super *super, SEL op,...)
129 __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_NA);
130 OBJC_EXPORT long double objc_msgSend_fpret_fixup(id self, SEL op, ...)
131 __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_NA);
132 # if __STDC_VERSION__ >= 199901L
133 OBJC_EXPORT _Complex long double objc_msgSend_fp2ret_fixup(id self, SEL op, ...)
134 __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_NA);
135 # else
136 OBJC_EXPORT void objc_msgSend_fp2ret_fixup(id self, SEL op, ...)
137 __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_NA);
138 # endif
139 #endif
140
141 /* C++-compatible exception handling. */
142 #if __OBJC2__
143
144 // fixme these conflict with C++ compiler's internal definitions
145 #if !defined(__cplusplus)
146
147 // Vtable for C++ exception typeinfo for Objective-C types.
148 OBJC_EXPORT const void *objc_ehtype_vtable[]
149 __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
150
151 // C++ exception typeinfo for type `id`.
152 OBJC_EXPORT struct objc_typeinfo OBJC_EHTYPE_id
153 __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
154
155 #endif
156
157 // Exception personality function for Objective-C and Objective-C++ code.
158 struct _Unwind_Exception;
159 struct _Unwind_Context;
160 OBJC_EXPORT int
161 __objc_personality_v0(int version,
162 int actions,
163 uint64_t exceptionClass,
164 struct _Unwind_Exception *exceptionObject,
165 struct _Unwind_Context *context)
166 __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
167
168 #endif
169
170 /* ARR */
171
172 OBJC_EXPORT id objc_retainBlock(id)
173 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0);
174
175 #endif