mirror of
https://github.com/apple/swift-atomics
synced 2026-11-27 04:44:21 +00:00
[shims] Only define atomic shims in Swift's Clang Importer
Per #37, we currently happen to use some non-standard C atomics that only work in Clang; to prevent issues when this module gets compiled using other compilers, `#ifdef` out all the actual shims, leaving only the definitions for `retain_n`/`release_n`. (For example, CMake builds the shims module using the system C compiler by default, which is usually GCC on Linux.)
This commit is contained in:
1 parent
59f7fbf479
commit
5d07eab6fe
1 file changed
+10
-1
@@ -56,8 +56,13 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdatomic.h>
|
||||
#include <assert.h>
|
||||
// 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 <stdatomic.h>
|
||||
#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);
|
||||
|
||||
Reference in new issue
Block a user