Skip to content

Commit 51e59a7

Browse files
committed
safe-math: clarify documentation for __builtin_*_overflow emulation
In the old documentation it was unclear whether to use `__builtin_*_overflow(res, a, b)` or `__builtin_*_overflow(a, b, res)`. This should make it clear that it's the latter, which is compatible with the GCC builtins. The `psnip_safe_*` API remains the same, of course.
1 parent 77654db commit 51e59a7

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

safe-math/README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,14 @@ things to watch out for if you choose this:
8080
* The type-generic functions (`__builtin_add_overflow`,
8181
`__builtin_sub_overflow`, and `__builtin_mul_overflow`) will only
8282
be available in C11 mode.
83-
* The argument order is slightly different, with the result coming
84-
last instead of first. We prefer the result to come first so the
85-
call looks a bit more like an assignment operation, but GCC made a
86-
different choice.
83+
* The argument order in GCC's API is slightly different, with the
84+
result coming last instead of first. We prefer the result to come
85+
first so the call looks a bit more like an assignment operation,
86+
but GCC made a different choice.
87+
88+
In other words, `__builtin_*_overflow(a, b, res)` are macros
89+
defined to `psnip_safe_*(res, a, b)` so existing code needn't
90+
be altered.
8791

8892
## The `safe_larger_*` API
8993

0 commit comments

Comments
 (0)