From cefadfa1f487b3f44682a553fee76e62f41b5522 Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Mon, 17 Oct 2016 19:25:27 -0700 Subject: [PATCH] build: fix on MSVC 2013 --- common/log.cc | 2 +- common/threads.cc | 6 +++--- include/vis/leafbits.hh | 7 +++++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/common/log.cc b/common/log.cc index 52edbae4..92b091f0 100644 --- a/common/log.cc +++ b/common/log.cc @@ -29,7 +29,7 @@ #include static FILE *logfile; -static _Bool log_ok; +static bool log_ok; void init_log(const char *filename) diff --git a/common/threads.cc b/common/threads.cc index 65ac4191..3584e439 100644 --- a/common/threads.cc +++ b/common/threads.cc @@ -16,7 +16,7 @@ void Error(const char *error, ...) __attribute__((format(printf,1,2),noreturn)); /* Make the locks no-ops if we aren't running threads */ -static _Bool threads_active = false; +static bool threads_active = false; static int dispatch; static int workcount; @@ -128,8 +128,8 @@ RunThreadsOn(int start, int workcnt, void *(func)(void *), void *arg) workcount = workcnt; oldpercent = -1; - threadid = malloc(sizeof(*threadid) * numthreads); - threadhandle = malloc(sizeof(*threadhandle) * numthreads); + threadid = static_cast(malloc(sizeof(*threadid) * numthreads)); + threadhandle = static_cast(malloc(sizeof(*threadhandle) * numthreads)); if (!threadid || !threadhandle) Error("Failed to allocate memory for threads"); diff --git a/include/vis/leafbits.hh b/include/vis/leafbits.hh index 46623341..e3c33ba8 100644 --- a/include/vis/leafbits.hh +++ b/include/vis/leafbits.hh @@ -28,6 +28,7 @@ #if !defined(ffsl) && defined(__GNUC__) #define ffsl __builtin_ffsl #elif defined(WIN32) +#include inline int ffsl(long int val) { unsigned long indexout; @@ -48,9 +49,11 @@ typedef struct { leafblock_t bits[]; /* Variable Sized */ } leafbits_t; -int __ERRORLONGSIZE(void); /* to generate an error at link time */ -#define QBYTESHIFT(x) ((x) == 8 ? 6 : ((x) == 4 ? 5 : __ERRORLONGSIZE() )) +#define QBYTESHIFT(x) ((x) == 8 ? 6 : ((x) == 4 ? 5 : 0 )) #define LEAFSHIFT QBYTESHIFT(sizeof(leafblock_t)) + +static_assert(LEAFSHIFT != 0, "unsupported sizeof(unsigned long)"); + #define LEAFMASK ((sizeof(leafblock_t) << 3) - 1UL) static inline int