Mirror of :pserver:cvs@cvs.fefe.de:/cvs libowfat https://www.fefe.de/libowfat/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
690 B

.TH add_of 3
add_of \- add two integers, check for arithmetic overflow
.B #include <libowfat/rangecheck.h>
int \fBadd_of\fP(dest,a,b);
If calculating a+b is possible without causing undefined behavior or an
arithmetic overflow in C, and the sum fits into the destination integer
type, do dest=a+b and return 0.
Otherwise, return 1.
Note: This is a macro, so dest does not have to be a pointer.
In the multiplication functions, a return value of 1 signals success and
0 failure. In add_of, sub_of and assign it's the other way around.
sub_of(3), assign(3), imult16(3), umult16(3), imult32(3), umult32(3),
imult64(3), umult64(3)