zig
zig copied to clipboard
Incorrect documentation for @cmpxchgStrong and @cmpxchgWeak
Zig Version
0.12.0
Steps to Reproduce and Observed Behavior
The documentation for @cmpxchgStrong and @cmpxchgWeak says:
This function performs a [strong|weak] atomic compare-and-exchange operation, returning `null` if the current value is not the given expected value.
It's the equivalent of this code, except atomic:
[...]
This is wrong and does not match the behavior of either the builtin nor the code example below these descriptions. I would like to open a PR for this, but I am unsure in which file to implement it, my assumption was doc/langref.html.in but that appears to be auto-generated.
Expected Behavior
I would propose the following wording:
This function performs a [strong|weak] atomic compare-and-exchange operation, returning `null` if the operation was successful and the previous value matched the given expected value.
Otherwise, it returns the actual value.
It's the equivalent of this code, except atomic:
[...]