diff --git a/bitunpack.c b/bitunpack.c index 08cde96..c90e995 100644 --- a/bitunpack.c +++ b/bitunpack.c @@ -764,7 +764,7 @@ size_t bitnfunpack128v32( unsigned char *__restrict in, size_t n, uint32_t *__re #define mm256_maskz_expand_epi32(_m_,_v_) _mm256_maskz_expand_epi32(_m_,_v_) #define mm256_maskz_loadu_epi32( _m_,_v_) _mm256_maskz_loadu_epi32( _m_,_v_) #else -static unsigned char permv[256][8] __attribute__((aligned(32))) = { +static ALIGNED(unsigned char, permv[256][8], 32) = { 0,0,0,0,0,0,0,0, 0,1,1,1,1,1,1,1, 1,0,1,1,1,1,1,1, diff --git a/conf.h b/conf.h index aec756a..25e5bfb 100644 --- a/conf.h +++ b/conf.h @@ -85,7 +85,7 @@ static inline unsigned short bswap16(unsigned short x) { return __builtin_bswap3 #define __builtin_prefetch(x,a) _mm_prefetch(x, _MM_HINT_NTA) #endif -#define ALIGNED(x) __declspec(align(x)) +#define ALIGNED(t,v,n) __declspec(align(n)) t v #define ALWAYS_INLINE __forceinline #define NOINLINE __declspec(noinline) #define THREADLOCAL __declspec(thread) @@ -109,8 +109,12 @@ static inline int clz64(uint64_t x) { unsigned long z; _BitScanReverse64(&z, x #define bswap32(x) _byteswap_ulong(x) #define bswap64(x) _byteswap_uint64(x) -#define popcnt32(x) __popcnt(x) +#define popcnt32(x) __popcnt(x) +#ifdef _WIN64 #define popcnt64(x) __popcnt64(x) +#else +#define popcnt64(x) (popcnt32(x) + popcnt32(x>>32)) +#endif #define sleep(x) Sleep(x/1000) #define fseeko _fseeki64 diff --git a/fp.c b/fp.c index 1c3b5b3..a348d0b 100644 --- a/fp.c +++ b/fp.c @@ -40,7 +40,11 @@ #define bitflush( _bw_,_br_,_op_) ctou64(_op_) = _bw_, _op_ += (_br_+7)>>3, _bw_=_br_=0 #ifdef __AVX2__ +#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) +#include +#else #include +#endif #else #define _bzhi_u64(_u_, _b_) ((_u_) & ((1ull<<(_b_))-1)) #define _bzhi_u32(_u_, _b_) ((_u_) & ((1u <<(_b_))-1)) diff --git a/transpose.c b/transpose.c index 428494a..c311d05 100644 --- a/transpose.c +++ b/transpose.c @@ -120,7 +120,9 @@ #include "transpose.c" //--------------------- CPU detection ------------------------------------------- -#if (_MSC_VER >=1300) || defined (__INTEL_COMPILER) +#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) +#include +#elif defined(__INTEL_COMPILER) #include #endif