10#if defined(HAVE_CONFIG_H)
11#include <config/bitcoin-config.h>
15 if (
a > 0 &&
b > std::numeric_limits<int64_t>::max() -
a) {
19 if (
a < 0 &&
b <= std::numeric_limits<int64_t>::min() -
a) {
24 return result == std::numeric_limits<int64_t>::min();
28#if HAVE_DECL___BUILTIN_SADDLL_OVERFLOW
32 return result == std::numeric_limits<int64_t>::min();
43 if (
a > 0 &&
b <= std::numeric_limits<int64_t>::min() +
a) {
48 return result == std::numeric_limits<int64_t>::min();
52#if HAVE_DECL___BUILTIN_SSUBLL_OVERFLOW
56 return result == std::numeric_limits<int64_t>::min();
bool AddInt63Overflow(int64_t a, int64_t b, int64_t &result)
Computes a + b and stores it in result.
bool SubInt63OverflowEmulated(int64_t a, int64_t b, int64_t &result)
Computes a - b and stores it in result.
bool AddInt63OverflowEmulated(int64_t a, int64_t b, int64_t &result)
Computes a + b and stores it in result.
bool SubInt63Overflow(int64_t a, int64_t b, int64_t &result)
Computes a - b and stores it in result.
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...