Skip to content

Commit fbf327b

Browse files
committed
Minimal code changes to allow msvc compilation.
1 parent 1f4375f commit fbf327b

File tree

8 files changed

+23
-9
lines changed

8 files changed

+23
-9
lines changed

src/bench/base58.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ static void Base58Encode(benchmark::State& state)
2222
}
2323
};
2424
while (state.KeepRunning()) {
25-
EncodeBase58(buff.begin(), buff.end());
25+
EncodeBase58(buff.data(), buff.data() + buff.size());
2626
}
2727
}
2828

src/bench/checkqueue.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ static const int MIN_CORES = 2;
1919
static const size_t BATCHES = 101;
2020
static const size_t BATCH_SIZE = 30;
2121
static const int PREVECTOR_SIZE = 28;
22-
static const int QUEUE_BATCH_SIZE = 128;
22+
static const unsigned int QUEUE_BATCH_SIZE = 128;
2323
static void CCheckQueueSpeed(benchmark::State& state)
2424
{
2525
struct FakeJobNoWork {

src/chainparams.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ class CMainParams : public CChainParams {
146146
fRequireStandard = true;
147147
fMineBlocksOnDemand = false;
148148

149-
checkpointData = (CCheckpointData) {
149+
checkpointData = {
150150
{
151151
{ 11111, uint256S("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d")},
152152
{ 33333, uint256S("0x000000002dd5588a74784eaa7ab0507a18ad16a236e7b1ce69f00d7ddfb5d0a6")},
@@ -248,7 +248,7 @@ class CTestNetParams : public CChainParams {
248248
fMineBlocksOnDemand = false;
249249

250250

251-
checkpointData = (CCheckpointData) {
251+
checkpointData = {
252252
{
253253
{546, uint256S("000000002a936ca763904c3c35fce2f3556c559c0214345d31b1bcebf76acb70")},
254254
}
@@ -319,7 +319,7 @@ class CRegTestParams : public CChainParams {
319319
fRequireStandard = false;
320320
fMineBlocksOnDemand = true;
321321

322-
checkpointData = (CCheckpointData) {
322+
checkpointData = {
323323
{
324324
{0, uint256S("0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206")},
325325
}

src/compat.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <mswsock.h>
3232
#include <windows.h>
3333
#include <ws2tcpip.h>
34+
#include <stdint.h>
3435
#else
3536
#include <sys/fcntl.h>
3637
#include <sys/mman.h>
@@ -71,6 +72,15 @@ typedef unsigned int SOCKET;
7172
#else
7273
#define MAX_PATH 1024
7374
#endif
75+
#ifdef _MSC_VER
76+
#if !defined(ssize_t)
77+
#ifdef _WIN64
78+
typedef int64_t ssize_t;
79+
#else
80+
typedef int32_t ssize_t;
81+
#endif
82+
#endif
83+
#endif
7484

7585
#if HAVE_DECL_STRNLEN == 0
7686
size_t strnlen( const char *start, size_t max_len);

src/net_processing.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ std::atomic<int64_t> nTimeBestReceived(0); // Used only to inform the wallet of
4141
struct IteratorComparator
4242
{
4343
template<typename I>
44-
bool operator()(const I& a, const I& b)
44+
bool operator()(const I& a, const I& b) const
4545
{
4646
return &(*a) < &(*b);
4747
}

src/random.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ class FastRandomContext {
128128
* sure that the underlying OS APIs for all platforms support the number.
129129
* (many cap out at 256 bytes).
130130
*/
131-
static const ssize_t NUM_OS_RANDOM_BYTES = 32;
131+
static const int NUM_OS_RANDOM_BYTES = 32;
132132

133133
/** Get 32 bytes of system entropy. Do not use this in application code: use
134134
* GetStrongRandBytes instead.

src/support/cleanse.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77

88
#include <cstring>
99

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

src/test/checkqueue_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
// otherwise.
2525
BOOST_FIXTURE_TEST_SUITE(checkqueue_tests, TestingSetup)
2626

27-
static const int QUEUE_BATCH_SIZE = 128;
27+
static const unsigned int QUEUE_BATCH_SIZE = 128;
2828

2929
struct FakeCheck {
3030
bool operator()()

0 commit comments

Comments
 (0)