From b5d19efd6fe6e9ffb284159a4a7e176d007da434 Mon Sep 17 00:00:00 2001 From: Javier Smooth Date: Mon, 27 Jul 2015 15:47:26 -0700 Subject: [PATCH 1/2] clean up portable 128-bit multiply --- src/common/int-util.h | 12 ++++++++++++ src/cryptonote_core/difficulty.cpp | 15 --------------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/common/int-util.h b/src/common/int-util.h index 6df00a8..0ca5ba6 100644 --- a/src/common/int-util.h +++ b/src/common/int-util.h @@ -68,6 +68,17 @@ static inline uint64_t lo_dword(uint64_t val) { return val & 0xFFFFFFFF; } +#if defined(__GNUC__) && defined(__x86_64__) + +static inline uint64_t mul128(uint64_t a, uint64_t b, uint64_t *high) { + typedef unsigned __int128 uint128_t; + uint128_t res = (uint128_t) a * (uint128_t) b; + *high = (uint64_t) (res >> 64); + return (uint64_t) res; +} + +#else + static inline uint64_t mul128(uint64_t multiplier, uint64_t multiplicand, uint64_t* product_hi) { // multiplier = ab = a * 2^32 + b // multiplicand = cd = c * 2^32 + d @@ -93,6 +104,7 @@ static inline uint64_t mul128(uint64_t multiplier, uint64_t multiplicand, uint64 return product_lo; } +#endif static inline uint64_t div_with_reminder(uint64_t dividend, uint32_t divisor, uint32_t* remainder) { dividend |= ((uint64_t)*remainder) << 32; diff --git a/src/cryptonote_core/difficulty.cpp b/src/cryptonote_core/difficulty.cpp index 389112c..ddc7481 100644 --- a/src/cryptonote_core/difficulty.cpp +++ b/src/cryptonote_core/difficulty.cpp @@ -45,25 +45,10 @@ namespace cryptonote { using std::uint64_t; using std::vector; -#if defined(_MSC_VER) -#include -#include - static inline void mul(uint64_t a, uint64_t b, uint64_t &low, uint64_t &high) { low = mul128(a, b, &high); } -#else - - static inline void mul(uint64_t a, uint64_t b, uint64_t &low, uint64_t &high) { - typedef unsigned __int128 uint128_t; - uint128_t res = (uint128_t) a * (uint128_t) b; - low = (uint64_t) res; - high = (uint64_t) (res >> 64); - } - -#endif - static inline bool cadd(uint64_t a, uint64_t b) { return a + b < a; } From bf65fe5b670fccd4357f1e849d9e6361b0aae0df Mon Sep 17 00:00:00 2001 From: Javier Smooth Date: Sat, 1 Aug 2015 02:24:27 -0700 Subject: [PATCH 2/2] remove unused data from in-mem blockchain (small mem savings) --- src/cryptonote_core/blockchain_storage.h | 2 +- src/cryptonote_core/blockchain_storage_boost_serialization.h | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cryptonote_core/blockchain_storage.h b/src/cryptonote_core/blockchain_storage.h index 08fc90e..a1656ae 100644 --- a/src/cryptonote_core/blockchain_storage.h +++ b/src/cryptonote_core/blockchain_storage.h @@ -38,6 +38,7 @@ #include #include #include +#include #include "syncobj.h" #include "string_tools.h" @@ -65,7 +66,6 @@ namespace cryptonote { transaction tx; uint64_t m_keeper_block_height; - size_t m_blob_size; std::vector m_global_output_indexes; }; diff --git a/src/cryptonote_core/blockchain_storage_boost_serialization.h b/src/cryptonote_core/blockchain_storage_boost_serialization.h index 627367c..44e5fe5 100644 --- a/src/cryptonote_core/blockchain_storage_boost_serialization.h +++ b/src/cryptonote_core/blockchain_storage_boost_serialization.h @@ -29,6 +29,7 @@ // Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers #pragma once +#include namespace boost { @@ -41,7 +42,8 @@ namespace boost { ar & te.tx; ar & te.m_keeper_block_height; - ar & te.m_blob_size; + size_t dummy; + ar & dummy; // formerly te.m_blob_size; ar & te.m_global_output_indexes; }