4#ifndef BITCOIN_SCRIPT_INTMATH_H
5#define BITCOIN_SCRIPT_INTMATH_H
16 if (a > 0 && b > std::numeric_limits<int64_t>::max() - a) {
20 if (a < 0 && b <= std::numeric_limits<int64_t>::min() - a) {
25 return result == std::numeric_limits<int64_t>::min();
35#if HAVE_DECL___BUILTIN_SADDLL_OVERFLOW
36 if (__builtin_saddll_overflow(a, b, (
long long int *)&result)) {
39 return result == std::numeric_limits<int64_t>::min();
51 if (a < 0 && b > std::numeric_limits<int64_t>::max() + a) {
55 if (a > 0 && b <= std::numeric_limits<int64_t>::min() + a) {
60 return result == std::numeric_limits<int64_t>::min();
70#if HAVE_DECL___BUILTIN_SSUBLL_OVERFLOW
71 if (__builtin_ssubll_overflow(a, b, (
long long int *)&result)) {
74 return result == std::numeric_limits<int64_t>::min();
static bool AddInt63Overflow(int64_t a, int64_t b, int64_t &result)
Computes a + b and stores it in result.
static bool AddInt63OverflowEmulated(int64_t a, int64_t b, int64_t &result)
Computes a + b and stores it in result.
static bool SubInt63Overflow(int64_t a, int64_t b, int64_t &result)
Computes a - b and stores it in result.
static bool SubInt63OverflowEmulated(int64_t a, int64_t b, int64_t &result)
Computes a - b and stores it in result.