From a1a96589aace11129bef34cccb959cad3a5501d6 Mon Sep 17 00:00:00 2001 From: Zhang Xianyi Date: Thu, 4 Feb 2016 15:23:32 -0500 Subject: [PATCH] Fixed #773 blas_quickdivide bug on CMake and Visual Studio x86 32-bit. --- common.h | 2 +- common_x86.h | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/common.h b/common.h index 52f2402..6b65c37 100644 --- a/common.h +++ b/common.h @@ -411,7 +411,7 @@ please https://github.com/xianyi/OpenBLAS/issues/246 #ifndef ASSEMBLER #ifdef OS_WINDOWS typedef char env_var_t[MAX_PATH]; -#define readenv(p, n) GetEnvironmentVariable((n), (p), sizeof(p)) +#define readenv(p, n) GetEnvironmentVariable((LPCTSTR)(n), (LPTSTR)(p), sizeof(p)) #else typedef char* env_var_t; #define readenv(p, n) ((p)=getenv(n)) diff --git a/common_x86.h b/common_x86.h index 1ace84c..ab9f22b 100644 --- a/common_x86.h +++ b/common_x86.h @@ -41,6 +41,10 @@ #ifndef ASSEMBLER +#ifdef C_MSVC +#include +#endif + #define MB #define WMB @@ -170,12 +174,13 @@ static __inline int blas_quickdivide(unsigned int x, unsigned int y){ if (y <= 1) return x; - y = blas_quick_divide_table[y]; - #if defined(_MSC_VER) && !defined(__clang__) - (void*)result; - return x*y; + result = x/y; + return result; #else + + y = blas_quick_divide_table[y]; + __asm__ __volatile__ ("mull %0" :"=d" (result) :"a"(x), "0" (y)); return result; -- 2.7.4