mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
[3.14] gh-135755: rename undocumented HACL_CAN_COMPILE_SIMD{128,256} macros (GH-135847) (#136045)
Rename undocumented `HACL_CAN_COMPILE_SIMD{128,256}` macros
to `_Py_HACL_CAN_COMPILE_VEC{128,256}`. These macros are private.
(cherry picked from commit 1e975aee28)
This commit is contained in:
parent
eff347ccc3
commit
70280953d2
6 changed files with 67 additions and 60 deletions
|
|
@ -31,14 +31,15 @@
|
|||
#endif
|
||||
|
||||
#if defined(__APPLE__) && defined(__arm64__)
|
||||
# undef HACL_CAN_COMPILE_SIMD128
|
||||
# undef HACL_CAN_COMPILE_SIMD256
|
||||
# undef _Py_HACL_CAN_COMPILE_VEC128
|
||||
# undef _Py_HACL_CAN_COMPILE_VEC256
|
||||
#endif
|
||||
|
||||
// Small mismatch between the variable names Python defines as part of configure
|
||||
// at the ones HACL* expects to be set in order to enable those headers.
|
||||
#define HACL_CAN_COMPILE_VEC128 HACL_CAN_COMPILE_SIMD128
|
||||
#define HACL_CAN_COMPILE_VEC256 HACL_CAN_COMPILE_SIMD256
|
||||
// HACL* expects HACL_CAN_COMPILE_VEC* macros to be set in order to enable
|
||||
// the corresponding SIMD instructions so we need to "forward" the values
|
||||
// we just deduced above.
|
||||
#define HACL_CAN_COMPILE_VEC128 _Py_HACL_CAN_COMPILE_VEC128
|
||||
#define HACL_CAN_COMPILE_VEC256 _Py_HACL_CAN_COMPILE_VEC256
|
||||
|
||||
#include "_hacl/Hacl_HMAC.h"
|
||||
#include "_hacl/Hacl_Streaming_HMAC.h" // Hacl_Agile_Hash_* identifiers
|
||||
|
|
@ -464,7 +465,7 @@ narrow_hmac_hash_kind(hmacmodule_state *state, HMAC_Hash_Kind kind)
|
|||
{
|
||||
switch (kind) {
|
||||
case Py_hmac_kind_hmac_blake2s_32: {
|
||||
#if HACL_CAN_COMPILE_SIMD128
|
||||
#if _Py_HACL_CAN_COMPILE_VEC128
|
||||
if (state->can_run_simd128) {
|
||||
return Py_hmac_kind_hmac_vectorized_blake2s_32;
|
||||
}
|
||||
|
|
@ -472,7 +473,7 @@ narrow_hmac_hash_kind(hmacmodule_state *state, HMAC_Hash_Kind kind)
|
|||
return kind;
|
||||
}
|
||||
case Py_hmac_kind_hmac_blake2b_32: {
|
||||
#if HACL_CAN_COMPILE_SIMD256
|
||||
#if _Py_HACL_CAN_COMPILE_VEC256
|
||||
if (state->can_run_simd256) {
|
||||
return Py_hmac_kind_hmac_vectorized_blake2b_32;
|
||||
}
|
||||
|
|
@ -1761,7 +1762,7 @@ hmacmodule_init_cpu_features(hmacmodule_state *state)
|
|||
#undef ECX_SSE3
|
||||
#undef EBX_AVX2
|
||||
|
||||
#if HACL_CAN_COMPILE_SIMD128
|
||||
#if _Py_HACL_CAN_COMPILE_VEC128
|
||||
// TODO(picnixz): use py_cpuid_features (gh-125022) to improve detection
|
||||
state->can_run_simd128 = sse && sse2 && sse3 && sse41 && sse42 && cmov;
|
||||
#else
|
||||
|
|
@ -1771,7 +1772,7 @@ hmacmodule_init_cpu_features(hmacmodule_state *state)
|
|||
state->can_run_simd128 = false;
|
||||
#endif
|
||||
|
||||
#if HACL_CAN_COMPILE_SIMD256
|
||||
#if _Py_HACL_CAN_COMPILE_VEC256
|
||||
// TODO(picnixz): use py_cpuid_features (gh-125022) to improve detection
|
||||
state->can_run_simd256 = state->can_run_simd128 && avx && avx2;
|
||||
#else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue