From 7b35aa206589e5d5f68dead1d09540c7982271d7 Mon Sep 17 00:00:00 2001 From: DeckerSU Date: Mon, 22 Jul 2019 04:35:17 +0300 Subject: [PATCH] payments cc fix --- src/cc/payments.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index 17507a80e..e329ff5bf 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -75,6 +75,36 @@ */ +// payments cc fix +#if (defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32)) + #undef mpz_set_si + #undef mpz_get_si + #define GMP_LIMB_HIGHBIT ((mp_limb_t) 1 << (GMP_LIMB_BITS - 1)) + #define GMP_NEG_CAST(T,x) (-(int64_t)((T)((x) + 1) - 1)) + + int64_t mpz_get_si (const mpz_t u) + { + mp_size_t us = u->_mp_size; + if (us > 0) + return (int64_t) (u->_mp_d[0] & ~GMP_LIMB_HIGHBIT); + else if (us < 0) + return (int64_t) (- u->_mp_d[0] | GMP_LIMB_HIGHBIT); + else + return 0; + } + + void mpz_set_si (mpz_t r, int64_t x) + { + if (x >= 0) + mpz_set_ui (r, x); + else /* (x < 0) */ + { + r->_mp_size = -1; + r->_mp_d[0] = GMP_NEG_CAST (uint64_t, x); + } + } +#endif + // start of consensus code CScript EncodePaymentsTxidOpRet(int64_t allocation,std::vector scriptPubKey,std::vector destopret)