Skip to content

Commit e2c1bcf

Browse files
committed
[+0-args][runtime] Add temporary runtime swift convention macros.
These are temporary staging macros to ease having a runtime that supports both +0 and +1 conventions for functions exposed as Swift level functions in the stdlib (and thus needing to follow the swift convention). The macros values are toggled by the argument SWIFT_ENABLE_GUARANTEED_NORMAL_ARGUMENTS and thus have values described via the following table: | SWIFT_ENABLE_GUARANTEED_NORMAL_ARGUMENT | FALSE | TRUE | |-----------------------------------------+-------------------------------+-------------------------------| | SWIFT_NS_RELEASES_ARGUMENT | NS_RELEASES_ARGUMENT | "" | | SWIFT_CC_PLUSONE_GUARD(...) | do { __VA_ARGS__ ; } while(0) | "" | | SWIFT_CC_PLUSZERO_GUARD(...) | "" | do { __VA_ARGS__ ; } while(0) | Thus instead of having to write an ugly #ifdef multiple times in each function (for the arguments, destroys, and retains), we can just use these macros instead. In a subsequent commit I am going to cleanup the changes I made in the runtime already to use these macros. So this is a NFC change. rdar://34222540
1 parent 309ae61 commit e2c1bcf

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

include/swift/Runtime/Config.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,4 +249,16 @@
249249

250250
#endif
251251

252+
// These are temporary macros during the +0 cc exploration to cleanly support
253+
// both +0 and +1 in the runtime.
254+
#ifndef SWIFT_RUNTIME_ENABLE_GUARANTEED_NORMAL_ARGUMENTS
255+
#define SWIFT_NS_RELEASES_ARGUMENT NS_RELEASES_ARGUMENT
256+
#define SWIFT_CC_PLUSONE_GUARD(...) do { __VA_ARGS__ ; } while (0)
257+
#define SWIFT_CC_PLUSZERO_GUARD(...)
258+
#else
259+
#define SWIFT_NS_RELEASES_ARGUMENT
260+
#define SWIFT_CC_PLUSONE_GUARD(...)
261+
#define SWIFT_CC_PLUSZERO_GUARD(...) do { __VA_ARGS__ ; } while (0)
262+
#endif
263+
252264
#endif // SWIFT_RUNTIME_CONFIG_H

0 commit comments

Comments
 (0)