Skip to content

Commit 8e96d2b

Browse files
committed
Export objc_retainAutoreleasedReturnValue()
- This allows it to be used by Foundation so that the duplicate function can be removed from CFRuntime.c in corelibs-foundation. - This also makes the export match the symbol in libdispatch.a.
1 parent 56f36b6 commit 8e96d2b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/swift/DispatchStubs.cc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,17 @@ SOURCE(VNODE)
199199
#endif
200200
SOURCE(WRITE)
201201

202-
// See comment in CFFuntime.c explaining why objc_retainAutoreleasedReturnValue is needed.
202+
203+
// For CF functions with 'Get' semantics, the compiler currently assumes that
204+
// the result is autoreleased and must be retained. It does so on all platforms
205+
// by emitting a call to objc_retainAutoreleasedReturnValue. On Darwin, this is
206+
// implemented by the ObjC runtime. On Linux, there is no runtime, and therefore
207+
// we have to stub it out here ourselves. The compiler will eventually call
208+
// swift_release to balance the retain below. This is a workaround until the
209+
// compiler no longer emits this callout on Linux.
203210
extern "C" void swift_retain(void *);
211+
212+
SWIFT_CC(swift) DISPATCH_RUNTIME_STDLIB_INTERFACE
204213
extern "C" void * objc_retainAutoreleasedReturnValue(void *obj) {
205214
if (obj) {
206215
swift_retain(obj);

0 commit comments

Comments
 (0)