File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -199,12 +199,25 @@ SOURCE(VNODE)
199
199
#endif
200
200
SOURCE (WRITE)
201
201
202
- // See comment in CFFuntime.c explaining why objc_retainAutoreleasedReturnValue is needed.
202
+ #if !USE_OBJC
203
+
204
+ // For CF functions with 'Get' semantics, the compiler currently assumes that
205
+ // the result is autoreleased and must be retained. It does so on all platforms
206
+ // by emitting a call to objc_retainAutoreleasedReturnValue. On Darwin, this is
207
+ // implemented by the ObjC runtime. On non-ObjC platforms, there is no runtime,
208
+ // and therefore we have to stub it out here ourselves. The compiler will
209
+ // eventually call swift_release to balance the retain below. This is a
210
+ // workaround until the compiler no longer emits this callout on non-ObjC
211
+ // platforms.
203
212
extern " C" void swift_retain (void *);
213
+
214
+ SWIFT_CC (swift) DISPATCH_RUNTIME_STDLIB_INTERFACE
204
215
extern "C" void * objc_retainAutoreleasedReturnValue(void *obj) {
205
216
if (obj) {
206
217
swift_retain (obj);
207
218
return obj;
208
219
}
209
220
else return NULL ;
210
221
}
222
+
223
+ #endif // !USE_OBJC
You can’t perform that action at this time.
0 commit comments