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
29 if (__builtin_saddll_overflow(a, b, (
long long int *)&result)) {
32 return result == std::numeric_limits<int64_t>::min();
39 if (a < 0 && b > std::numeric_limits<int64_t>::max() + a) {
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
53 if (__builtin_ssubll_overflow(a, b, (
long long int *)&result)) {
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.