authorgravatar for koachan@protonmail.comKoakuma <koachan@protonmail.com> 2022-04-15 19:31:55+07:00
committergravatar for koachan@protonmail.comKoakuma <koachan@protonmail.com> 2022-04-15 19:31:55+07:00
log6aa89115f974b639d6006d8106a7df7d94f636ac
tree0b942ae7142fd12e3836f799b3a7dc00268b9c70
parent274e2a1ef1513bb2960becf60854e6e4d574ff5c

ompiler_rt: atomics: Split long lines and add comment on constants


1 files changed, 7 insertions(+), 1 deletions(-)

lib/std/special/compiler_rt/atomics.zig+7-1
...@@ -43,9 +43,15 @@ const SpinlockTable = struct {...@@ -43,9 +43,15 @@ const SpinlockTable = struct {
43 const max_spinlocks = 64;43 const max_spinlocks = 64;
4444
45 const Spinlock = struct {45 const Spinlock = struct {
46 // SPARC ldstub instruction will write a 255 into the memory location.
47 // We'll use that as a sign that the lock is currently held.
48 // See also: Section B.7 in SPARCv8 spec & A.29 in SPARCv9 spec.
49 const sparc_lock: type = enum(u8) { Unlocked = 0, Locked = 255 };
50 const other_lock: type = enum(usize) { Unlocked = 0, Locked };
51
46 // Prevent false sharing by providing enough padding between two52 // Prevent false sharing by providing enough padding between two
47 // consecutive spinlock elements53 // consecutive spinlock elements
48 v: if (arch.isSPARC()) enum(u8) { Unlocked = 0, Locked = 255 } else enum(usize) { Unlocked = 0, Locked } align(cache_line_size) = .Unlocked,54 v: if (arch.isSPARC()) sparc_lock else other_lock align(cache_line_size) = .Unlocked,
4955
50 fn acquire(self: *@This()) void {56 fn acquire(self: *@This()) void {
51 while (true) {57 while (true) {