Skip to content
CAI
Software that uses CAICheck a score

apple/swift-atomics

56.8

Adequate · 15 November 2026

3.7k

lines of production code

Swift

with Python

5

measurements over time

CAI band scale
CAI trend line
CAI lens gauges

What this system is

Features

Add CMake build support for the Atomics library

The Atomics library now includes a CMake build system (Sources/Atomics/CMakeLists.txt), allowing it to be built and installed via CMake in addition to the existing Xcode project. The configuration defines the library target, links against the \_AtomicsShims library, and applies platform-specific compiler flags (such as -mcx16 for x86\_64).

Sources/Atomics · high confidence

New Xcode project configuration for Swift Atomics

The Xcode directory now contains a complete project structure (Atomics.xcodeproj) with shared xcconfig files to build the Swift Atomics library as a single framework bundle. This configuration sets deployment targets to macOS 12.0, iOS 15.0, watchOS 8.0, and tvOS 15.0, uses Swift 5.5, and enables the BuiltinModule experimental feature. It also includes a test plan (Atomics.xctestplan) supporting default and Thread Sanitizer runs, and configures code signing identities for iOS, watchOS, and tvOS platforms.

Xcode · high confidence

New Xcode project for Atomics with native builtin support

Developers can now open and build the Atomics library directly in Xcode using a newly added project configuration. This setup exercises native builtins in a monomodule configuration and includes a comprehensive test suite covering atomic integers, pointers, references, and other types, along with utility scripts for source generation.

Xcode/Atomics.xcodeproj · high confidence

Behavioural changes

Add CMake build support and Darwin-specific linking for AtomicsShims

The \_AtomicsShims module now includes a CMake build configuration (CMakeLists.txt) to facilitate building the static library, and on Darwin platforms, it explicitly ensures linking against libswiftCore via assembly linker options to resolve dependency issues when built as a standalone module.

_Sources/\AtomicsShims · high confidence

Native atomic primitives restructured with custom storage types to fix alignment

The native atomic primitives implementation has been reorganized to use custom storage types (such as \\_AtomicInt8Storage\) for internal atomic operations. This change addresses alignment issues by ensuring proper memory alignment for atomic types, which improves reliability and correctness of atomic operations on native platforms. The autogenerated primitive definitions now explicitly manage alignment through dedicated storage structs rather than relying on implicit type alignment.

Sources/Atomics/Primitives · high confidence

Refactored atomic conformances to use dedicated storage types and native atomics

The atomic conformances for Bool, integers, pointers, and RawRepresentable types have been restructured to use specific internal storage types (such as \_AtomicInt8Storage and \_AtomicIntStorage) instead of generic or indirect wrappers. This change replaces the previous switch-based dispatch to C shim functions with direct calls to native atomic operations, simplifying the implementation and improving code clarity. Additionally, source files have been reorganized into the Conformances directory, and the Bool atomic representation now explicitly uses an 8-bit integer storage to ensure correct alignment and behavior.

Sources/Atomics/Conformances · high confidence

Refactored atomic protocol hierarchy and added weak compare-exchange support

The atomic protocol structure has been reorganized to improve type safety and clarity. The \AtomicValue\ protocol is now a base requirement, while \AtomicInteger\ and \AtomicOptionalWrappable\ have stricter constraints on their associated storage types to ensure the value type matches the representation. \AtomicStrongReference\ has been renamed to \AtomicReference\ and now uses a \\_AtomicBase\ associated type to better support non-final classes, with updated documentation clarifying subclass limitations. Additionally, the \AtomicStorage\ protocol now includes a new \atomicWeakCompareExchange\ method, allowing for more efficient atomic updates in loops where spurious failures are acceptable, along with a default implementation for the strong \atomicCompareExchange\ variant.

Sources/Atomics/Protocols · high confidence

Refactored atomic types into dedicated module and added weak compare-exchange operations

The atomic types have been reorganized into the Sources/Atomics/Types module, with source files moved and gyb templates de-templated into concrete Swift files. This change introduces a new weakCompareExchange method on UnsafeAtomic, allowing atomic updates that may spuriously fail and are designed for use in retry loops. Additionally, the DoubleWord type has been rewritten to use native Builtin types instead of shim functions, with its high/low properties deprecated in favor of first/second, and the library now requires Swift 5.10 or later, dropping support for versions 5.7–5.9.

Sources/Atomics/Types · high confidence

Regenerated atomic implementation sources

The autogenerated source files in Sources/Atomics/autogenerated, including AtomicLazyReference.swift and IntegerConformances.swift, have been regenerated. This update refreshes the underlying atomic operations and type conformances to align with the latest toolchain requirements and internal optimizations, ensuring correct behavior for atomic lazy references and integer atomic representations.

Sources/Atomics/autogenerated · medium confidence

The \_AtomicsShims header has been significantly reduced in size by removing the extensive C preprocessor macros that previously generated atomic operations for all standard integer types, Bool, and double-word integers. The file now primarily includes standard headers and defines basic inline attributes, indicating a shift away from the previous complex macro-based stamping mechanism. Additionally, the copyright notice has been updated to include the year 2025.

_Sources/\AtomicsShims/include · medium confidence

Utilities: Upgrade gyb to Python 3 and expand test coverage

The \Utilities/gyb\ tool and its supporting scripts (\gyb.py\, \gyb\_utils.py\) have been migrated from Python 2.7 to Python 3, updating syntax for modern compatibility (e.g., \io.StringIO\, \list()\ iteration). Additionally, the \Utilities/run-full-tests.sh\ script was introduced to automate building and testing the package across multiple configurations (SPM, CMake, Xcode) and platforms, including long-running and ThreadSanitizer tests. The \generate-sources.sh\ script was also updated to use \find\ for robust source discovery and to remove obsolete autogenerated files.

Utilities · high confidence

Test coverage

Expanded and refactored atomic reference tests; Expanded test coverage for Swift Atomics basics; Migrate test execution to CMake; Refactor autogenerated atomic tests into separate files.

Dependencies

Swift 5.10 toolchain support and native builtin atomics

The package now requires Swift 5.10, enabling the use of native Swift compiler builtins for atomic operations instead of relying on C atomics. This change updates the minimum supported toolchain version and configures the build settings to leverage the new BuiltinModule experimental feature for improved performance and integration with modern Swift compilers.

(dependencies) · high confidence

Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Score

  • CAI 60 → 57 (-3.0)
  • Rubric changed (rubric-2026.10.5 → rubric-2026.11.4) — scores are not directly comparable.

Lenses

  • Code Health 95 → 90 (-5.2)
  • Architecture 97 → 96 (-0.7)
  • Maturity 59 → 50 (-9.3)
  • Readiness 41 → 41 (-0.1)
  • Security 92 → 92 (+0.0)

New (20)

  • Edited copies of one member (3 members, 15+ corresponding lines) (Sources/Atomics/Conformances/RawRepresentable.swift)
  • Edited copies of one member (4 members, 17+ corresponding lines) (Sources/Atomics/Conformances/OptionalRawRepresentable.swift)
  • Edited copies of one member (6 members, 16+ corresponding lines) (Sources/Atomics/Protocols/AtomicReference.swift)
  • Edited copy of a member (10 corresponding lines) (Sources/Atomics/Conformances/OptionalRawRepresentable.swift)
  • Edited copy of a member (12 corresponding lines) (Sources/Atomics/Protocols/AtomicReference.swift)
  • Edited copy of a member (4 corresponding lines) (Sources/Atomics/Types/ManagedAtomicLazyReference.swift)
  • Edited copy of a member (6 corresponding lines) (Sources/Atomics/Types/UnsafeAtomic.swift)
  • Further orphaned files (smaller)
  • Orphaned file (Package.swift)
  • Orphaned file (Sources/Atomics/Conformances/OptionalRawRepresentable.swift)
  • Orphaned file (Sources/Atomics/Conformances/RawRepresentable.swift)
  • Orphaned file (Sources/Atomics/Protocols/AtomicInteger.swift)
  • Orphaned file (Sources/Atomics/Protocols/AtomicStorage.swift)
  • Orphaned file (Sources/Atomics/Types/AtomicMemoryOrderings.swift)
  • Orphaned file (Sources/Atomics/Types/DoubleWord.swift)
  • Orphaned file (Sources/Atomics/Types/ManagedAtomic.swift)
  • Orphaned file (Sources/Atomics/Types/ManagedAtomicLazyReference.swift)
  • Orphaned file (Sources/Atomics/Types/UnsafeAtomic.swift)
  • Orphaned file (Sources/Atomics/Types/UnsafeAtomicLazyReference.swift)
  • Orphaned knowledge (Utilities/gyb.py)

Changes since last survey

  • 2 commits — 2 feature/other, 0 fixes

By area

  • (repo) — 1 commit
  • (root) — 1 commit

Notable commits

  • change: Merge pull request #137 from charles-zablit/cz/cmake/cmp0157
  • change: [CMake] Require CMake 3.29 to enable CMP0157

Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

apple/swift-atomics was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 15 November 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit 3414b07b3ad442e6122e3fcaa1bd4ed419c49baf — the exact code this score is about.
  • Scored under rubric-2026.11.4 — the same rubric and the same method as every other entry in this index.
  • Measured by Canine Code Analyzer (cca.canine.dev) using cca measure-2026.11.65+preprod-3c33c1882dc1.