]> git.saurik.com Git - apple/libdispatch.git/blame - os/object_private.h
libdispatch-913.30.4.tar.gz
[apple/libdispatch.git] / os / object_private.h
CommitLineData
c093abd6
A
1/*
2 * Copyright (c) 2011-2012 Apple Inc. All rights reserved.
3 *
4 * @APPLE_APACHE_LICENSE_HEADER_START@
5 *
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
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
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.
17 *
18 * @APPLE_APACHE_LICENSE_HEADER_END@
19 */
20
21/*
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.
25 */
26
27#ifndef __OS_OBJECT_PRIVATE__
28#define __OS_OBJECT_PRIVATE__
29
c093abd6 30#include <os/object.h>
6b746eb4
A
31#include <stddef.h>
32#include <stdint.h>
c093abd6
A
33
34#if __GNUC__
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__))
6b746eb4 39#ifndef OS_OBJECT_EXPORT
c093abd6 40#define OS_OBJECT_EXPORT extern __attribute__((visibility("default")))
6b746eb4 41#endif
c093abd6
A
42#else
43/*! @parseOnly */
44#define OS_OBJECT_NOTHROW
45/*! @parseOnly */
46#define OS_OBJECT_NONNULL
47/*! @parseOnly */
48#define OS_OBJECT_WARN_RESULT
49/*! @parseOnly */
50#define OS_OBJECT_MALLOC
6b746eb4
A
51#ifndef OS_OBJECT_EXPORT
52/*! @parseOnly */
c093abd6
A
53#define OS_OBJECT_EXPORT extern
54#endif
6b746eb4 55#endif
c093abd6 56
beb15981 57#if OS_OBJECT_USE_OBJC && __has_feature(objc_arc)
c093abd6
A
58#define _OS_OBJECT_OBJC_ARC 1
59#else
60#define _OS_OBJECT_OBJC_ARC 0
61#endif
62
63#define _OS_OBJECT_GLOBAL_REFCNT INT_MAX
64
65#define _OS_OBJECT_HEADER(isa, ref_cnt, xref_cnt) \
66 isa; /* must be pointer-sized */ \
67 int volatile ref_cnt; \
68 int volatile xref_cnt
69
70#if OS_OBJECT_HAVE_OBJC_SUPPORT
beb15981
A
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
79#else
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)
c093abd6
A
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]
beb15981
A
86#endif
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)))
c093abd6 90#else
beb15981
A
91#define OS_OBJECT_HAVE_OBJC1 0
92#define OS_OBJECT_HAVE_OBJC2 0
c093abd6
A
93#define _OS_OBJECT_CLASS_HEADER() \
94 void (*_os_obj_xref_dispose)(_os_object_t); \
95 void (*_os_obj_dispose)(_os_object_t)
96#endif
97
98#define OS_OBJECT_CLASS(name) OS_##name
99
beb15981
A
100#if OS_OBJECT_USE_OBJC && OS_OBJECT_SWIFT3
101@interface OS_OBJECT_CLASS(object) (OSObjectPrivate)
102- (void)_xref_dispose;
103- (void)_dispose;
104@end
105OS_OBJECT_DECL_PROTOCOL(object, <NSObject>);
106typedef 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)> \
110 @end
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
6b746eb4 116API_AVAILABLE(macos(10.8), ios(6.0))
c093abd6
A
117OS_OBJECT_EXPORT
118@interface OS_OBJECT_CLASS(object) : NSObject
119- (void)_xref_dispose;
120- (void)_dispose;
121@end
122typedef 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)> \
126 @end
127#else
beb15981
A
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)
c093abd6
A
131typedef struct _os_object_s *_os_object_t;
132#endif
133
beb15981
A
134OS_ASSUME_NONNULL_BEGIN
135
c093abd6
A
136__BEGIN_DECLS
137
138#if !_OS_OBJECT_OBJC_ARC
139
6b746eb4 140API_AVAILABLE(macos(10.8), ios(6.0))
c093abd6 141OS_OBJECT_EXPORT OS_OBJECT_MALLOC OS_OBJECT_WARN_RESULT OS_OBJECT_NOTHROW
beb15981 142OS_SWIFT_UNAVAILABLE("Unavailable in Swift")
c093abd6
A
143_os_object_t
144_os_object_alloc(const void *cls, size_t size);
145
6b746eb4 146API_AVAILABLE(macos(10.8), ios(6.0))
517da941 147OS_OBJECT_EXPORT OS_OBJECT_MALLOC OS_OBJECT_WARN_RESULT OS_OBJECT_NOTHROW
beb15981 148OS_SWIFT_UNAVAILABLE("Unavailable in Swift")
517da941
A
149_os_object_t
150_os_object_alloc_realized(const void *cls, size_t size);
151
6b746eb4 152API_AVAILABLE(macos(10.8), ios(6.0))
c093abd6 153OS_OBJECT_EXPORT OS_OBJECT_NONNULL OS_OBJECT_NOTHROW
beb15981 154OS_SWIFT_UNAVAILABLE("Unavailable in Swift")
c093abd6
A
155void _os_object_dealloc(_os_object_t object);
156
6b746eb4 157API_AVAILABLE(macos(10.8), ios(6.0))
c093abd6 158OS_OBJECT_EXPORT OS_OBJECT_NONNULL OS_OBJECT_NOTHROW
beb15981 159OS_SWIFT_UNAVAILABLE("Unavailable in Swift")
c093abd6
A
160_os_object_t
161_os_object_retain(_os_object_t object);
162
6b746eb4 163API_AVAILABLE(macos(10.8), ios(6.0))
45201a42 164OS_OBJECT_EXPORT OS_OBJECT_NONNULL OS_OBJECT_NOTHROW
beb15981 165OS_SWIFT_UNAVAILABLE("Unavailable in Swift")
45201a42
A
166_os_object_t
167_os_object_retain_with_resurrect(_os_object_t obj);
168
6b746eb4 169API_AVAILABLE(macos(10.8), ios(6.0))
c093abd6 170OS_OBJECT_EXPORT OS_OBJECT_NONNULL OS_OBJECT_NOTHROW
beb15981 171OS_SWIFT_UNAVAILABLE("Unavailable in Swift")
c093abd6
A
172void
173_os_object_release(_os_object_t object);
174
6b746eb4 175API_AVAILABLE(macos(10.8), ios(6.0))
c093abd6 176OS_OBJECT_EXPORT OS_OBJECT_NONNULL OS_OBJECT_NOTHROW
beb15981 177OS_SWIFT_UNAVAILABLE("Unavailable in Swift")
c093abd6
A
178_os_object_t
179_os_object_retain_internal(_os_object_t object);
180
6b746eb4 181API_AVAILABLE(macos(10.8), ios(6.0))
c093abd6 182OS_OBJECT_EXPORT OS_OBJECT_NONNULL OS_OBJECT_NOTHROW
beb15981 183OS_SWIFT_UNAVAILABLE("Unavailable in Swift")
c093abd6
A
184void
185_os_object_release_internal(_os_object_t object);
186
6b746eb4
A
187API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0))
188OS_OBJECT_EXPORT OS_OBJECT_NONNULL OS_OBJECT_NOTHROW
189OS_SWIFT_UNAVAILABLE("Unavailable in Swift")
190_os_object_t
191_os_object_retain_internal_n(_os_object_t object, uint16_t n);
192
193API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0))
194OS_OBJECT_EXPORT OS_OBJECT_NONNULL OS_OBJECT_NOTHROW
195OS_SWIFT_UNAVAILABLE("Unavailable in Swift")
196void
197_os_object_release_internal_n(_os_object_t object, uint16_t n);
198
c093abd6
A
199#endif // !_OS_OBJECT_OBJC_ARC
200
201__END_DECLS
202
beb15981
A
203OS_ASSUME_NONNULL_END
204
c093abd6 205#endif