apple / swift-atomics

Low-level atomic operations for Swift
Apache License 2.0
1.06k stars 50 forks source link

Avoid C atomic operations in Swift 5.9+ #90

Closed lorentey closed 1 year ago

lorentey commented 1 year ago

Importing _AtomicsShims with C++ interoperability enabled uncovers some issues with double-wide atomics as currently implemented in C.

It's time to stop tweaking these C definitions -- instead, disable C atomics, and switch to using native Swift atomic operations from Swift 5.9 onward.

(For now, we'll still need _AtomicsShims for its swift_retain_n/swift_release_n wrappers. I'm planning to get rid of the need for those, too, but that'll need some compiler tweaks that aren't targeted for 5.9.)

Resolves #88.

Checklist

lorentey commented 1 year ago

@swift-ci test

lorentey commented 1 year ago

@swift-ci test

finagolfin commented 1 year ago

This pull breaks building the latest trunk of this package with Swift 5.8, as can be seen on my daily Android CI, and presumably 5.7 too.

Maybe this can be reconfigured in such a way that #if compiler(>5.8) or similar checks are used in the Package manifest instead, to choose whether native builtins are used or not?