Browse Source
Merge pull request #1542 from martin-frbg/quickdiv64
Avoid out-of-bounds accesses in blas_quickdivide on big X86 systems
tags/v0.3.0^2
Martin Kroeker
GitHub
7 years ago
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
14 additions and
1 deletions
-
common_x86.h
-
common_x86_64.h
|
|
@@ -178,7 +178,13 @@ static __inline int blas_quickdivide(unsigned int x, unsigned int y){ |
|
|
|
result = x/y; |
|
|
|
return result; |
|
|
|
#else |
|
|
|
|
|
|
|
#if (MAX_CPU_NUMBER > 64) |
|
|
|
if ( y > 64) { |
|
|
|
result = x/y; |
|
|
|
return result; |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
y = blas_quick_divide_table[y]; |
|
|
|
|
|
|
|
__asm__ __volatile__ ("mull %0" :"=d" (result) :"a"(x), "0" (y)); |
|
|
|
|
|
@@ -196,6 +196,13 @@ static __inline int blas_quickdivide(unsigned int x, unsigned int y){ |
|
|
|
|
|
|
|
if (y <= 1) return x; |
|
|
|
|
|
|
|
#if (MAX_CPU_NUMBER > 64) |
|
|
|
if (y > 64) { |
|
|
|
result = x / y; |
|
|
|
return result; |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
y = blas_quick_divide_table[y]; |
|
|
|
|
|
|
|
__asm__ __volatile__ ("mull %0" :"=d" (result) :"a"(x), "0" (y)); |
|
|
|