Minimal code changes to allow msvc compilation.

pull/11558/head
Aaron Clauson 7 years ago
parent 1f4375f8e7
commit fbf327b138

@ -22,7 +22,7 @@ static void Base58Encode(benchmark::State& state)
} }
}; };
while (state.KeepRunning()) { while (state.KeepRunning()) {
EncodeBase58(buff.begin(), buff.end()); EncodeBase58(buff.data(), buff.data() + buff.size());
} }
} }

@ -19,7 +19,7 @@ static const int MIN_CORES = 2;
static const size_t BATCHES = 101; static const size_t BATCHES = 101;
static const size_t BATCH_SIZE = 30; static const size_t BATCH_SIZE = 30;
static const int PREVECTOR_SIZE = 28; static const int PREVECTOR_SIZE = 28;
static const int QUEUE_BATCH_SIZE = 128; static const unsigned int QUEUE_BATCH_SIZE = 128;
static void CCheckQueueSpeed(benchmark::State& state) static void CCheckQueueSpeed(benchmark::State& state)
{ {
struct FakeJobNoWork { struct FakeJobNoWork {

@ -146,7 +146,7 @@ public:
fRequireStandard = true; fRequireStandard = true;
fMineBlocksOnDemand = false; fMineBlocksOnDemand = false;
checkpointData = (CCheckpointData) { checkpointData = {
{ {
{ 11111, uint256S("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d")}, { 11111, uint256S("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d")},
{ 33333, uint256S("0x000000002dd5588a74784eaa7ab0507a18ad16a236e7b1ce69f00d7ddfb5d0a6")}, { 33333, uint256S("0x000000002dd5588a74784eaa7ab0507a18ad16a236e7b1ce69f00d7ddfb5d0a6")},
@ -248,7 +248,7 @@ public:
fMineBlocksOnDemand = false; fMineBlocksOnDemand = false;
checkpointData = (CCheckpointData) { checkpointData = {
{ {
{546, uint256S("000000002a936ca763904c3c35fce2f3556c559c0214345d31b1bcebf76acb70")}, {546, uint256S("000000002a936ca763904c3c35fce2f3556c559c0214345d31b1bcebf76acb70")},
} }
@ -319,7 +319,7 @@ public:
fRequireStandard = false; fRequireStandard = false;
fMineBlocksOnDemand = true; fMineBlocksOnDemand = true;
checkpointData = (CCheckpointData) { checkpointData = {
{ {
{0, uint256S("0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206")}, {0, uint256S("0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206")},
} }

@ -31,6 +31,7 @@
#include <mswsock.h> #include <mswsock.h>
#include <windows.h> #include <windows.h>
#include <ws2tcpip.h> #include <ws2tcpip.h>
#include <stdint.h>
#else #else
#include <sys/fcntl.h> #include <sys/fcntl.h>
#include <sys/mman.h> #include <sys/mman.h>
@ -71,6 +72,15 @@ typedef unsigned int SOCKET;
#else #else
#define MAX_PATH 1024 #define MAX_PATH 1024
#endif #endif
#ifdef _MSC_VER
#if !defined(ssize_t)
#ifdef _WIN64
typedef int64_t ssize_t;
#else
typedef int32_t ssize_t;
#endif
#endif
#endif
#if HAVE_DECL_STRNLEN == 0 #if HAVE_DECL_STRNLEN == 0
size_t strnlen( const char *start, size_t max_len); size_t strnlen( const char *start, size_t max_len);

@ -41,7 +41,7 @@ std::atomic<int64_t> nTimeBestReceived(0); // Used only to inform the wallet of
struct IteratorComparator struct IteratorComparator
{ {
template<typename I> template<typename I>
bool operator()(const I& a, const I& b) bool operator()(const I& a, const I& b) const
{ {
return &(*a) < &(*b); return &(*a) < &(*b);
} }

@ -128,7 +128,7 @@ public:
* sure that the underlying OS APIs for all platforms support the number. * sure that the underlying OS APIs for all platforms support the number.
* (many cap out at 256 bytes). * (many cap out at 256 bytes).
*/ */
static const ssize_t NUM_OS_RANDOM_BYTES = 32; static const int NUM_OS_RANDOM_BYTES = 32;
/** Get 32 bytes of system entropy. Do not use this in application code: use /** Get 32 bytes of system entropy. Do not use this in application code: use
* GetStrongRandBytes instead. * GetStrongRandBytes instead.

@ -7,6 +7,10 @@
#include <cstring> #include <cstring>
#if defined(_MSC_VER)
#include <Windows.h> // For SecureZeroMemory.
#endif
/* Compilers have a bad habit of removing "superfluous" memset calls that /* Compilers have a bad habit of removing "superfluous" memset calls that
* are trying to zero memory. For example, when memset()ing a buffer and * are trying to zero memory. For example, when memset()ing a buffer and
* then free()ing it, the compiler might decide that the memset is * then free()ing it, the compiler might decide that the memset is
@ -32,7 +36,7 @@ void memory_cleanse(void *ptr, size_t len)
might try to eliminate "superfluous" memsets. If there's an easy way to might try to eliminate "superfluous" memsets. If there's an easy way to
detect memset_s, it would be better to use that. */ detect memset_s, it would be better to use that. */
#if defined(_MSC_VER) #if defined(_MSC_VER)
__asm; SecureZeroMemory(ptr, len);
#else #else
__asm__ __volatile__("" : : "r"(ptr) : "memory"); __asm__ __volatile__("" : : "r"(ptr) : "memory");
#endif #endif

@ -24,7 +24,7 @@
// otherwise. // otherwise.
BOOST_FIXTURE_TEST_SUITE(checkqueue_tests, TestingSetup) BOOST_FIXTURE_TEST_SUITE(checkqueue_tests, TestingSetup)
static const int QUEUE_BATCH_SIZE = 128; static const unsigned int QUEUE_BATCH_SIZE = 128;
struct FakeCheck { struct FakeCheck {
bool operator()() bool operator()()

Loading…
Cancel
Save