apple / swift-atomics

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

Fix alignment issues with double-wide atomics on i386 #102

Closed lorentey closed 11 months ago

lorentey commented 11 months ago

The SysV ABI defined uint64_t with 4 byte alignment on i386 — so we can’t just assume that the integer types will have the right alignment for atomics out of the box.

Emulate the original _Atomic<Width>Storage types from the old C shims even in native atomics configuration, so that they can carry a custom @_alignment attribute.

Change things up so that these storage types define atomic operations taking and returning themselves, rather than some standard scalar type. This gets things a little closer in spirit to what we're planning to do in the stdlib, and it really cuts down the size of the gyb output for the native definitions.

Resolves #99.

Checklist

lorentey commented 11 months ago

@swift-ci test