Fixed #773 blas_quickdivide bug on CMake and Visual Studio x86 32-bit.
authorZhang Xianyi <traits.zhang@gmail.com>
Thu, 4 Feb 2016 20:23:32 +0000 (15:23 -0500)
committerZhang Xianyi <traits.zhang@gmail.com>
Thu, 4 Feb 2016 20:23:32 +0000 (15:23 -0500)
common.h
common_x86.h

index 52f2402..6b65c37 100644 (file)
--- 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))
index 1ace84c..ab9f22b 100644 (file)
 
 #ifndef ASSEMBLER
 
+#ifdef C_MSVC
+#include <intrin.h>
+#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;