Skip to content

ours-atomic64 ​

libs/atomic64 — a 64-bit counter on any target.

Why ​

32-bit MIPS (MT7621, mipsel-unknown-linux-musl) has no 64-bit atomics, while byte and connection counters must be 64-bit. The crate provides one type AtomicU64:

  • where target_has_atomic = "64" — it is std::sync::atomic::AtomicU64 (a re-export);
  • otherwise — a fallback implementation on a lock with the same API subset: new (const fn), load, store, fetch_add, swap, compare_exchange.

Code that writes ours_atomic64::AtomicU64 builds both on x86_64 and on MIPS without cfg.

Who uses it ​

Every byte or connection counter: ours-tracker (connection counters), ours-metrics, ours-clock (the offset), ours-runtime, ours-quinn-ext (Brutal's rate), ours-wireguard and the modules group (probe results), router, adblock, tun, wireguard.

Specifics ​

  • No dependencies.
  • The fallback branch is checked only by the MIPS build (see Checks, the MIPS check): on x86_64 it is not compiled.

Tests ​

One unit test in src/lib.rs, matches_std_semantics. It checks the fallback only on targets without 64-bit atomics; elsewhere it checks the std type.

GPL-3.0-or-later