2 * Copyright (c) 2011-2012 Apple Inc. All rights reserved.
4 * @APPLE_APACHE_LICENSE_HEADER_START@
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * @APPLE_APACHE_LICENSE_HEADER_END@
22 * IMPORTANT: This header file describes INTERNAL interfaces to libdispatch
23 * which are subject to change in future releases of Mac OS X. Any applications
24 * relying on these interfaces WILL break.
27 #ifndef __OS_OBJECT_PRIVATE__
28 #define __OS_OBJECT_PRIVATE__
30 #include <os/object.h>
35 #define OS_OBJECT_NOTHROW __attribute__((__nothrow__))
36 #define OS_OBJECT_NONNULL __attribute__((__nonnull__))
37 #define OS_OBJECT_WARN_RESULT __attribute__((__warn_unused_result__))
38 #define OS_OBJECT_MALLOC __attribute__((__malloc__))
39 #ifndef OS_OBJECT_EXPORT
40 #define OS_OBJECT_EXPORT extern __attribute__((visibility("default")))
44 #define OS_OBJECT_NOTHROW
46 #define OS_OBJECT_NONNULL
48 #define OS_OBJECT_WARN_RESULT
50 #define OS_OBJECT_MALLOC
51 #ifndef OS_OBJECT_EXPORT
53 #define OS_OBJECT_EXPORT extern
57 #if OS_OBJECT_USE_OBJC && __has_feature(objc_arc)
58 #define _OS_OBJECT_OBJC_ARC 1
60 #define _OS_OBJECT_OBJC_ARC 0
63 #define _OS_OBJECT_GLOBAL_REFCNT INT_MAX
65 #define _OS_OBJECT_HEADER(isa, ref_cnt, xref_cnt) \
66 isa; /* must be pointer-sized */ \
67 int volatile ref_cnt; \
70 #if OS_OBJECT_HAVE_OBJC_SUPPORT
71 #define OS_OBJECT_CLASS_SYMBOL(name) OS_##name##_class
72 #if TARGET_OS_MAC && !TARGET_OS_SIMULATOR && defined(__i386__)
73 #define OS_OBJECT_HAVE_OBJC1 1
74 #define OS_OBJECT_HAVE_OBJC2 0
75 #define OS_OBJC_CLASS_RAW_SYMBOL_NAME(name) \
76 ".objc_class_name_" OS_STRINGIFY(name)
77 #define _OS_OBJECT_CLASS_HEADER() \
78 const void *_os_obj_objc_isa
80 #define OS_OBJECT_HAVE_OBJC1 0
81 #define OS_OBJECT_HAVE_OBJC2 1
82 #define OS_OBJC_CLASS_RAW_SYMBOL_NAME(name) "_OBJC_CLASS_$_" OS_STRINGIFY(name)
83 // Must match size of compiler-generated OBJC_CLASS structure rdar://10640168
84 #define _OS_OBJECT_CLASS_HEADER() \
85 void *_os_obj_objc_class_t[5]
87 #define OS_OBJECT_OBJC_CLASS_DECL(name) \
88 extern void *OS_OBJECT_CLASS_SYMBOL(name) \
89 asm(OS_OBJC_CLASS_RAW_SYMBOL_NAME(OS_OBJECT_CLASS(name)))
91 #define OS_OBJECT_HAVE_OBJC1 0
92 #define OS_OBJECT_HAVE_OBJC2 0
93 #define _OS_OBJECT_CLASS_HEADER() \
94 void (*_os_obj_xref_dispose)(_os_object_t); \
95 void (*_os_obj_dispose)(_os_object_t)
98 #define OS_OBJECT_CLASS(name) OS_##name
100 #if OS_OBJECT_USE_OBJC && OS_OBJECT_SWIFT3
101 @interface
OS_OBJECT_CLASS(object
) (OSObjectPrivate
)
102 - (void)_xref_dispose
;
105 OS_OBJECT_DECL_PROTOCOL(object
, <NSObject
>);
106 typedef OS_OBJECT_CLASS(object
) *_os_object_t
;
107 #define _OS_OBJECT_DECL_SUBCLASS_INTERFACE(name, super) \
108 @interface OS_OBJECT_CLASS(name) : OS_OBJECT_CLASS(super) \
109 <OS_OBJECT_CLASS(name)> \
111 #define _OS_OBJECT_DECL_PROTOCOL(name, super) \
112 OS_OBJECT_DECL_PROTOCOL(name, <OS_OBJECT_CLASS(super)>)
113 #define _OS_OBJECT_CLASS_IMPLEMENTS_PROTOCOL(name, super) \
114 OS_OBJECT_CLASS_IMPLEMENTS_PROTOCOL(name, super)
115 #elif OS_OBJECT_USE_OBJC
116 API_AVAILABLE(macos(10.8), ios(6.0))
118 @interface
OS_OBJECT_CLASS(object
) : NSObject
119 - (void)_xref_dispose
;
122 typedef OS_OBJECT_CLASS(object
) *_os_object_t
;
123 #define _OS_OBJECT_DECL_SUBCLASS_INTERFACE(name, super) \
124 @interface OS_OBJECT_CLASS(name) : OS_OBJECT_CLASS(super) \
125 <OS_OBJECT_CLASS(name)> \
128 #define _OS_OBJECT_DECL_SUBCLASS_INTERFACE(name, super)
129 #define _OS_OBJECT_DECL_PROTOCOL(name, super)
130 #define _OS_OBJECT_CLASS_IMPLEMENTS_PROTOCOL(name, super)
131 typedef struct _os_object_s
*_os_object_t
;
134 OS_ASSUME_NONNULL_BEGIN
138 #if !_OS_OBJECT_OBJC_ARC
140 API_AVAILABLE(macos(10.8), ios(6.0))
141 OS_OBJECT_EXPORT OS_OBJECT_MALLOC OS_OBJECT_WARN_RESULT OS_OBJECT_NOTHROW
142 OS_SWIFT_UNAVAILABLE("Unavailable in Swift")
144 _os_object_alloc(const void *cls
, size_t size
);
146 API_AVAILABLE(macos(10.8), ios(6.0))
147 OS_OBJECT_EXPORT OS_OBJECT_MALLOC OS_OBJECT_WARN_RESULT OS_OBJECT_NOTHROW
148 OS_SWIFT_UNAVAILABLE("Unavailable in Swift")
150 _os_object_alloc_realized(const void *cls
, size_t size
);
152 API_AVAILABLE(macos(10.8), ios(6.0))
153 OS_OBJECT_EXPORT OS_OBJECT_NONNULL OS_OBJECT_NOTHROW
154 OS_SWIFT_UNAVAILABLE("Unavailable in Swift")
155 void _os_object_dealloc(_os_object_t object
);
157 API_AVAILABLE(macos(10.8), ios(6.0))
158 OS_OBJECT_EXPORT OS_OBJECT_NONNULL OS_OBJECT_NOTHROW
159 OS_SWIFT_UNAVAILABLE("Unavailable in Swift")
161 _os_object_retain(_os_object_t object
);
163 API_AVAILABLE(macos(10.8), ios(6.0))
164 OS_OBJECT_EXPORT OS_OBJECT_NONNULL OS_OBJECT_NOTHROW
165 OS_SWIFT_UNAVAILABLE("Unavailable in Swift")
167 _os_object_retain_with_resurrect(_os_object_t obj
);
169 API_AVAILABLE(macos(10.8), ios(6.0))
170 OS_OBJECT_EXPORT OS_OBJECT_NONNULL OS_OBJECT_NOTHROW
171 OS_SWIFT_UNAVAILABLE("Unavailable in Swift")
173 _os_object_release(_os_object_t object
);
175 API_AVAILABLE(macos(10.8), ios(6.0))
176 OS_OBJECT_EXPORT OS_OBJECT_NONNULL OS_OBJECT_NOTHROW
177 OS_SWIFT_UNAVAILABLE("Unavailable in Swift")
179 _os_object_retain_internal(_os_object_t object
);
181 API_AVAILABLE(macos(10.8), ios(6.0))
182 OS_OBJECT_EXPORT OS_OBJECT_NONNULL OS_OBJECT_NOTHROW
183 OS_SWIFT_UNAVAILABLE("Unavailable in Swift")
185 _os_object_release_internal(_os_object_t object
);
187 API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0))
188 OS_OBJECT_EXPORT OS_OBJECT_NONNULL OS_OBJECT_NOTHROW
189 OS_SWIFT_UNAVAILABLE("Unavailable in Swift")
191 _os_object_retain_internal_n(_os_object_t object
, uint16_t n
);
193 API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0))
194 OS_OBJECT_EXPORT OS_OBJECT_NONNULL OS_OBJECT_NOTHROW
195 OS_SWIFT_UNAVAILABLE("Unavailable in Swift")
197 _os_object_release_internal_n(_os_object_t object
, uint16_t n
);
199 #endif // !_OS_OBJECT_OBJC_ARC
203 OS_ASSUME_NONNULL_END