# zig.h: replace \`\_InterlockedExchangeAdd\` with a plain volatile load · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/bc28454b43b717dee47cf8c1a1abfb7e8ad09a1e)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: bc28454b43b717dee47cf8c1a1abfb7e8ad09a1e

Requested commit: bc28454b43b717dee47cf8c1a1abfb7e8ad09a1e

Commit: bc28454b43b717dee47cf8c1a1abfb7e8ad09a1e

Tree: 5b451406f50bd24cf9e357a0ff2af788a1798ac5

Author: kcbanner

Committer: kcbanner

## Message

```
zig.h: replace `_InterlockedExchangeAdd` with a plain volatile load

This was causing zig2.exe to crash during bootstrap, because there was an atomic
load of read-only memory, and the attempt to write to it as part of the (idempotent)
atomic exchange was invalid.

Aligned reads (of u32 / u64) are atomic on x86 / x64, so this is replaced with an
optimization-proof load (`__iso_volatile_load8*`) and a reordering barrier.

```

## Parents

- [11534aa34d6e9c66081eb2918bfaacbb21db0e56](https://git.cafe/gitcafe/zig/commit/11534aa34d6e9c66081eb2918bfaacbb21db0e56?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/bc28454b43b717dee47cf8c1a1abfb7e8ad09a1e?format=markdown)
