Toychain!
A toy blockchain in C
|
A helper file for checking overflows. More...
#include <limits.h>
Go to the source code of this file.
Macros | |
#define | LONG_LONG_MAX LLONG_MAX |
#define | LONG_LONG_MIN LLONG_MIN |
#define | ADDITION_OVERFLOW_CHECK(a, x, tmax, tmin) |
checks for overflows while adding two numbers More... | |
#define | SUBTRACTION_OVERFLOW_CHECK(a, x, tmax, tmin) |
checks for overflows while subtracting two numbers More... | |
#define | MULTIPLICATION_OVERFLOW_CHECK(a, x, tmax, tmin) |
checks for overflows while multiplying two numbers More... | |
#define | ADDITION_OVERFLOW_CHECK_i32(a, x) ADDITION_OVERFLOW_CHECK(a, x, INT_MAX, INT_MIN) |
checks for overflows while adding two 32 bit signed numbers More... | |
#define | SUBTRACTION_OVERFLOW_CHECK_i32(a, x) SUBTRACTION_OVERFLOW_CHECK(a, x, INT_MAX, INT_MIN) |
checks for overflows while subtracting two 32 bit signed numbers More... | |
#define | MULTIPLICATION_OVERFLOW_CHECK_i32(a, x) MULTIPLICATION_OVERFLOW_CHECK(a, x, INT_MAX, INT_MIN) |
checks for overflows while multiplying two 32 bit signed numbers More... | |
#define | ADDITION_OVERFLOW_CHECK_i64(a, x) ADDITION_OVERFLOW_CHECK(a, x, LONG_LONG_MAX, LONG_LONG_MIN) |
checks for overflows while adding two 64 bit signed numbers More... | |
#define | SUBTRACTION_OVERFLOW_CHECK_i64(a, x) SUBTRACTION_OVERFLOW_CHECK(a, x, LONG_LONG_MAX, LONG_LONG_MIN) |
checks for overflows while subtracting two 64 bit signed numbers More... | |
#define | MULTIPLICATION_OVERFLOW_CHECK_i64(a, x) MULTIPLICATION_OVERFLOW_CHECK(a, x, LONG_LONG_MAX, LONG_LONG_MIN) |
checks for overflows while multiplying two 64 bit signed numbers More... | |
A helper file for checking overflows.
#define ADDITION_OVERFLOW_CHECK | ( | a, | |
x, | |||
tmax, | |||
tmin | |||
) |
checks for overflows while adding two numbers
a | |
x | |
tmax | : the max value of the type in question |
tmin | : the min value of the type in question |
#define ADDITION_OVERFLOW_CHECK_i32 | ( | a, | |
x | |||
) | ADDITION_OVERFLOW_CHECK(a, x, INT_MAX, INT_MIN) |
checks for overflows while adding two 32 bit signed numbers
a | |
x |
#define ADDITION_OVERFLOW_CHECK_i64 | ( | a, | |
x | |||
) | ADDITION_OVERFLOW_CHECK(a, x, LONG_LONG_MAX, LONG_LONG_MIN) |
checks for overflows while adding two 64 bit signed numbers
a | |
x |
#define MULTIPLICATION_OVERFLOW_CHECK | ( | a, | |
x, | |||
tmax, | |||
tmin | |||
) |
checks for overflows while multiplying two numbers
a | |
x | |
tmax | : the max value of the type in question |
tmin | : the min value of the type in question |
#define MULTIPLICATION_OVERFLOW_CHECK_i32 | ( | a, | |
x | |||
) | MULTIPLICATION_OVERFLOW_CHECK(a, x, INT_MAX, INT_MIN) |
checks for overflows while multiplying two 32 bit signed numbers
a | |
x |
#define MULTIPLICATION_OVERFLOW_CHECK_i64 | ( | a, | |
x | |||
) | MULTIPLICATION_OVERFLOW_CHECK(a, x, LONG_LONG_MAX, LONG_LONG_MIN) |
checks for overflows while multiplying two 64 bit signed numbers
a | |
x |
#define SUBTRACTION_OVERFLOW_CHECK | ( | a, | |
x, | |||
tmax, | |||
tmin | |||
) |
checks for overflows while subtracting two numbers
a | |
x | |
tmax | : the max value of the type in question |
tmin | : the min value of the type in question |
#define SUBTRACTION_OVERFLOW_CHECK_i32 | ( | a, | |
x | |||
) | SUBTRACTION_OVERFLOW_CHECK(a, x, INT_MAX, INT_MIN) |
checks for overflows while subtracting two 32 bit signed numbers
a | |
x |
#define SUBTRACTION_OVERFLOW_CHECK_i64 | ( | a, | |
x | |||
) | SUBTRACTION_OVERFLOW_CHECK(a, x, LONG_LONG_MAX, LONG_LONG_MIN) |
checks for overflows while subtracting two 64 bit signed numbers
a | |
x |