From 83e5832bc16275002d1bb98e018446c8a67be08a Mon Sep 17 00:00:00 2001 From: XMRig Date: Mon, 12 Mar 2018 14:44:23 +0700 Subject: [PATCH] Some small fixes. --- src/Cpu_stub.cpp | 15 ++++++++++----- src/crypto/CryptoNight_x86.h | 6 ++---- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/Cpu_stub.cpp b/src/Cpu_stub.cpp index 0b9196eea..87d9de755 100644 --- a/src/Cpu_stub.cpp +++ b/src/Cpu_stub.cpp @@ -24,13 +24,18 @@ #ifdef _MSC_VER # include - -# define bit_AES (1 << 25) -# define bit_BMI2 (1 << 8) #else # include #endif +#ifndef bit_AES +# define bit_AES (1 << 25) +#endif + +#ifndef bit_BMI2 +# define bit_BMI2 (1 << 8) +#endif + #include @@ -87,7 +92,7 @@ static inline bool has_aes_ni() int cpu_info[4] = { 0 }; cpuid(PROCESSOR_INFO, cpu_info); - return cpu_info[ECX_Reg] & bit_AES; + return (cpu_info[ECX_Reg] & bit_AES) != 0; } @@ -95,7 +100,7 @@ static inline bool has_bmi2() { int cpu_info[4] = { 0 }; cpuid(EXTENDED_FEATURES, cpu_info); - return cpu_info[EBX_Reg] & bit_BMI2; + return (cpu_info[EBX_Reg] & bit_BMI2) != 0; } diff --git a/src/crypto/CryptoNight_x86.h b/src/crypto/CryptoNight_x86.h index d39948e84..7393bbfa6 100644 --- a/src/crypto/CryptoNight_x86.h +++ b/src/crypto/CryptoNight_x86.h @@ -310,7 +310,7 @@ static inline void cn_implode_scratchpad(const __m128i *input, __m128i *output) template -inline bool cryptonight_hash(const void *__restrict__ input, size_t size, void *__restrict__ output, cryptonight_ctx *__restrict__ ctx, uint8_t version) +inline void cryptonight_hash(const void *__restrict__ input, size_t size, void *__restrict__ output, cryptonight_ctx *__restrict__ ctx, uint8_t version) { keccak(static_cast(input), (int) size, ctx->state0, 200); @@ -364,12 +364,11 @@ inline bool cryptonight_hash(const void *__restrict__ input, size_t size, void * keccakf(h0, 24); extra_hashes[ctx->state0[0] & 3](ctx->state0, 200, static_cast(output)); - return true; } template -inline bool cryptonight_double_hash(const void *__restrict__ input, size_t size, void *__restrict__ output, struct cryptonight_ctx *__restrict__ ctx, uint8_t version) +inline void cryptonight_double_hash(const void *__restrict__ input, size_t size, void *__restrict__ output, struct cryptonight_ctx *__restrict__ ctx, uint8_t version) { keccak((const uint8_t *) input, (int) size, ctx->state0, 200); keccak((const uint8_t *) input + size, (int) size, ctx->state1, 200); @@ -463,7 +462,6 @@ inline bool cryptonight_double_hash(const void *__restrict__ input, size_t size, extra_hashes[ctx->state0[0] & 3](ctx->state0, 200, static_cast(output)); extra_hashes[ctx->state1[0] & 3](ctx->state1, 200, static_cast(output) + 32); - return true; } #endif /* __CRYPTONIGHT_X86_H__ */