In Swift 5.5, `UnsafeAtomic` has gained an implicit, unconditional `Sendable` conformance, because it is a `@frozen public struct` whose sole stored property (an `UnsafeMutablePointer` is also `Sendable`. This is not correct -- we only want `UnsafeAtomic` to conform to `Sendable` if its `Value` does.
Explicitly declare the conformance on 5.5 to disable the bogus inference.
These are only ever called from opaque function bodies, so there is no need to make them inlinable anyway.
This allows us to stop linking client code with _AtomicsShims. (Although I don't quite understand how it was necessary before.)
- Disable building tests on Darwin
- Fix test registration on Linux when double-wide atomics aren't available
- Unconditionally enable double-wide atomics
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.)
Unify the double word path by using a bit more macro expansion. The two
differences between 32-bit and 64-bit is:
- `__uint128_t` vs `uint64_t`
- 64-bit shifts vs 32-bit shifts
We can simply use a macro to expand out the underlying C type rather
than bifurcating the definitions. For the second difference, we can
simply use the `__INTPTR_WIDTH__` for the shifts. We explicitly use
macros for the type-definitions to hide the typedef from Swift.
Use the C11 aggregate constructor to further reduce the code.
Linux on x86_64 unfortunately disables support for cmpxchg16 by default, making double-wide atomic operations fall back to using locks. We cannot currently override this on the package level, so stop providing double-wide atomics in this configuration by default.
To enable codegen support for double-wide atomics on Linux/x86_64, compile the package with `-Xcc -mcx16 -Xswiftc -DENABLE_DOUBLEWIDE_ATOMICS`.