diff --git a/Sources/_AtomicsShims/include/_AtomicsShims.h b/Sources/_AtomicsShims/include/_AtomicsShims.h index bcec8d6..c1614f1 100644 --- a/Sources/_AtomicsShims/include/_AtomicsShims.h +++ b/Sources/_AtomicsShims/include/_AtomicsShims.h @@ -56,8 +56,13 @@ #include #include -#include #include +// The atomic primitives are only needed when this is compiled using Swift's +// Clang Importer. This allows us to continue reling on some Clang extensions +// (see https://github.com/apple/swift-atomics/issues/37). +#if defined(__swift__) +# include +#endif // For now, assume double-wide atomics are available everywhere, // except on Linux/x86_64, where they need to be manually enabled @@ -73,6 +78,8 @@ # endif #endif +#if defined(__swift__) + #define SWIFTATOMIC_INLINE static inline __attribute__((__always_inline__)) #define SWIFTATOMIC_SWIFT_NAME(name) __attribute__((swift_name(#name))) @@ -348,6 +355,8 @@ SWIFTATOMIC_DEFINE_TYPE(COMPLEX, DoubleWord, _sa_dword, _sa_double_word_ctype) SWIFTATOMIC_STORAGE_TYPE(DoubleWord, _sa_dword, _sa_double_word_ctype) #endif +#endif // __swift__ + #if ENABLE_DOUBLEWIDE_ATOMICS extern void _sa_retain_n(void *object, uint32_t n); extern void _sa_release_n(void *object, uint32_t n);