diff options
-rw-r--r-- | Misc/NEWS.d/next/Library/2017-10-23-23-27-52.bpo-31834.InwC6O.rst | 2 | ||||
-rw-r--r-- | Modules/_blake2/blake2b_impl.c | 4 | ||||
-rw-r--r-- | Modules/_blake2/blake2s_impl.c | 4 | ||||
-rw-r--r-- | setup.py | 9 |
4 files changed, 8 insertions, 11 deletions
diff --git a/Misc/NEWS.d/next/Library/2017-10-23-23-27-52.bpo-31834.InwC6O.rst b/Misc/NEWS.d/next/Library/2017-10-23-23-27-52.bpo-31834.InwC6O.rst new file mode 100644 index 00000000000..0fe3950e69d --- /dev/null +++ b/Misc/NEWS.d/next/Library/2017-10-23-23-27-52.bpo-31834.InwC6O.rst @@ -0,0 +1,2 @@ +Use optimized code for BLAKE2 only with SSSE3+. The pure SSE2 implementation +is slower than the pure C reference implementation. diff --git a/Modules/_blake2/blake2b_impl.c b/Modules/_blake2/blake2b_impl.c index b1ae3e9b628..3c2a035f3d7 100644 --- a/Modules/_blake2/blake2b_impl.c +++ b/Modules/_blake2/blake2b_impl.c @@ -26,7 +26,9 @@ #include "impl/blake2.h" #include "impl/blake2-impl.h" /* for secure_zero_memory() and store48() */ -#ifdef BLAKE2_USE_SSE +/* pure SSE2 implementation is very slow, so only use the more optimized SSSE3+ + * https://bugs.python.org/issue31834 */ +#if defined(__SSSE3__) || defined(__SSE4_1__) || defined(__AVX__) || defined(__XOP__) #include "impl/blake2b.c" #else #include "impl/blake2b-ref.c" diff --git a/Modules/_blake2/blake2s_impl.c b/Modules/_blake2/blake2s_impl.c index 3615a383db3..2c5697299fc 100644 --- a/Modules/_blake2/blake2s_impl.c +++ b/Modules/_blake2/blake2s_impl.c @@ -26,7 +26,9 @@ #include "impl/blake2.h" #include "impl/blake2-impl.h" /* for secure_zero_memory() and store48() */ -#ifdef BLAKE2_USE_SSE +/* pure SSE2 implementation is very slow, so only use the more optimized SSSE3+ + * https://bugs.python.org/issue31834 */ +#if defined(__SSSE3__) || defined(__SSE4_1__) || defined(__AVX__) || defined(__XOP__) #include "impl/blake2s.c" #else #include "impl/blake2s-ref.c" @@ -922,19 +922,10 @@ class PyBuildExt(build_ext): 'Modules/_blake2/impl/*')) blake2_deps.append('hashlib.h') - blake2_macros = [] - if (not cross_compiling and - os.uname().machine == "x86_64" and - sys.maxsize > 2**32): - # Every x86_64 machine has at least SSE2. Check for sys.maxsize - # in case that kernel is 64-bit but userspace is 32-bit. - blake2_macros.append(('BLAKE2_USE_SSE', '1')) - exts.append( Extension('_blake2', ['_blake2/blake2module.c', '_blake2/blake2b_impl.c', '_blake2/blake2s_impl.c'], - define_macros=blake2_macros, depends=blake2_deps) ) sha3_deps = glob(os.path.join(os.getcwd(), srcdir, |