Skip to content

Commit 8aaf752

Browse files
authored
gh-123189: [Modules/blake2module.c]: Move function definitions and their usage under the macros (#123190)
1 parent f8a736b commit 8aaf752

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Modules/blake2module.c

+8
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,19 @@ void detect_cpu_features(cpu_flags *flags) {
104104
}
105105
}
106106

107+
#ifdef HACL_CAN_COMPILE_SIMD128
107108
static inline bool has_simd128(cpu_flags *flags) {
108109
// For now this is Intel-only, could conceivably be #ifdef'd to something
109110
// else.
110111
return flags->sse && flags->sse2 && flags->sse3 && flags->sse41 && flags->sse42 && flags->cmov;
111112
}
113+
#endif
112114

115+
#ifdef HACL_CAN_COMPILE_SIMD256
113116
static inline bool has_simd256(cpu_flags *flags) {
114117
return flags->avx && flags->avx2;
115118
}
119+
#endif
116120

117121
// Small mismatch between the variable names Python defines as part of configure
118122
// at the ones HACL* expects to be set in order to enable those headers.
@@ -151,13 +155,15 @@ blake2_get_state(PyObject *module)
151155
return (Blake2State *)state;
152156
}
153157

158+
#if defined(HACL_CAN_COMPILE_SIMD128) || defined(HACL_CAN_COMPILE_SIMD256)
154159
static inline Blake2State*
155160
blake2_get_state_from_type(PyTypeObject *module)
156161
{
157162
void *state = _PyType_GetModuleState(module);
158163
assert(state != NULL);
159164
return (Blake2State *)state;
160165
}
166+
#endif
161167

162168
static struct PyMethodDef blake2mod_functions[] = {
163169
{NULL, NULL}
@@ -311,7 +317,9 @@ static inline bool is_blake2s(blake2_impl impl) {
311317
}
312318

313319
static inline blake2_impl type_to_impl(PyTypeObject *type) {
320+
#if defined(HACL_CAN_COMPILE_SIMD128) || defined(HACL_CAN_COMPILE_SIMD256)
314321
Blake2State* st = blake2_get_state_from_type(type);
322+
#endif
315323
if (!strcmp(type->tp_name, blake2b_type_spec.name)) {
316324
#ifdef HACL_CAN_COMPILE_SIMD256
317325
if (has_simd256(&st->flags))

0 commit comments

Comments
 (0)