@@ -77,23 +77,23 @@ typedef struct {
7777 PyTypeObject * blake2s_type ;
7878 bool can_run_simd128 ;
7979 bool can_run_simd256 ;
80- } Blake2State ;
80+ } blake2module_state ;
8181
82- static inline Blake2State *
83- blake2_get_state (PyObject * module )
82+ static inline blake2module_state *
83+ get_blake2module_state (PyObject * module )
8484{
8585 void * state = _PyModule_GetState (module );
8686 assert (state != NULL );
87- return (Blake2State * )state ;
87+ return (blake2module_state * )state ;
8888}
8989
9090#if defined(HACL_CAN_COMPILE_SIMD128 ) || defined(HACL_CAN_COMPILE_SIMD256 )
91- static inline Blake2State *
91+ static inline blake2module_state *
9292blake2_get_state_from_type (PyTypeObject * module )
9393{
9494 void * state = _PyType_GetModuleState (module );
9595 assert (state != NULL );
96- return (Blake2State * )state ;
96+ return (blake2module_state * )state ;
9797}
9898#endif
9999
@@ -104,7 +104,7 @@ static struct PyMethodDef blake2mod_functions[] = {
104104static int
105105_blake2_traverse (PyObject * module , visitproc visit , void * arg )
106106{
107- Blake2State * state = blake2_get_state (module );
107+ blake2module_state * state = get_blake2module_state (module );
108108 Py_VISIT (state -> blake2b_type );
109109 Py_VISIT (state -> blake2s_type );
110110 return 0 ;
@@ -113,7 +113,7 @@ _blake2_traverse(PyObject *module, visitproc visit, void *arg)
113113static int
114114_blake2_clear (PyObject * module )
115115{
116- Blake2State * state = blake2_get_state (module );
116+ blake2module_state * state = get_blake2module_state (module );
117117 Py_CLEAR (state -> blake2b_type );
118118 Py_CLEAR (state -> blake2s_type );
119119 return 0 ;
@@ -126,7 +126,7 @@ _blake2_free(void *module)
126126}
127127
128128static void
129- blake2module_init_cpu_features (Blake2State * state )
129+ blake2module_init_cpu_features (blake2module_state * state )
130130{
131131 /* This must be kept in sync with hmacmodule_init_cpu_features()
132132 * in hmacmodule.c */
@@ -204,8 +204,8 @@ blake2module_init_cpu_features(Blake2State *state)
204204static int
205205blake2_exec (PyObject * m )
206206{
207- Blake2State * st = blake2_get_state (m );
208- blake2module_init_cpu_features (st );
207+ blake2module_state * state = get_blake2module_state (m );
208+ blake2module_init_cpu_features (state );
209209
210210#define ADD_INT (DICT , NAME , VALUE ) \
211211 do { \
@@ -229,17 +229,17 @@ blake2_exec(PyObject *m)
229229
230230 ADD_INT_CONST ("_GIL_MINSIZE" , HASHLIB_GIL_MINSIZE );
231231
232- st -> blake2b_type = (PyTypeObject * )PyType_FromModuleAndSpec (
232+ state -> blake2b_type = (PyTypeObject * )PyType_FromModuleAndSpec (
233233 m , & blake2b_type_spec , NULL );
234234
235- if (st -> blake2b_type == NULL ) {
235+ if (state -> blake2b_type == NULL ) {
236236 return -1 ;
237237 }
238- if (PyModule_AddType (m , st -> blake2b_type ) < 0 ) {
238+ if (PyModule_AddType (m , state -> blake2b_type ) < 0 ) {
239239 return -1 ;
240240 }
241241
242- PyObject * d = st -> blake2b_type -> tp_dict ;
242+ PyObject * d = state -> blake2b_type -> tp_dict ;
243243 ADD_INT (d , "SALT_SIZE" , HACL_HASH_BLAKE2B_SALT_BYTES );
244244 ADD_INT (d , "PERSON_SIZE" , HACL_HASH_BLAKE2B_PERSONAL_BYTES );
245245 ADD_INT (d , "MAX_KEY_SIZE" , HACL_HASH_BLAKE2B_KEY_BYTES );
@@ -251,17 +251,17 @@ blake2_exec(PyObject *m)
251251 ADD_INT_CONST ("BLAKE2B_MAX_DIGEST_SIZE" , HACL_HASH_BLAKE2B_OUT_BYTES );
252252
253253 /* BLAKE2s */
254- st -> blake2s_type = (PyTypeObject * )PyType_FromModuleAndSpec (
254+ state -> blake2s_type = (PyTypeObject * )PyType_FromModuleAndSpec (
255255 m , & blake2s_type_spec , NULL );
256256
257- if (st -> blake2s_type == NULL ) {
257+ if (state -> blake2s_type == NULL ) {
258258 return -1 ;
259259 }
260- if (PyModule_AddType (m , st -> blake2s_type ) < 0 ) {
260+ if (PyModule_AddType (m , state -> blake2s_type ) < 0 ) {
261261 return -1 ;
262262 }
263263
264- d = st -> blake2s_type -> tp_dict ;
264+ d = state -> blake2s_type -> tp_dict ;
265265 ADD_INT (d , "SALT_SIZE" , HACL_HASH_BLAKE2S_SALT_BYTES );
266266 ADD_INT (d , "PERSON_SIZE" , HACL_HASH_BLAKE2S_PERSONAL_BYTES );
267267 ADD_INT (d , "MAX_KEY_SIZE" , HACL_HASH_BLAKE2S_KEY_BYTES );
@@ -288,7 +288,7 @@ static struct PyModuleDef blake2_module = {
288288 .m_base = PyModuleDef_HEAD_INIT ,
289289 .m_name = "_blake2" ,
290290 .m_doc = blake2mod__doc__ ,
291- .m_size = sizeof (Blake2State ),
291+ .m_size = sizeof (blake2module_state ),
292292 .m_methods = blake2mod_functions ,
293293 .m_slots = _blake2_slots ,
294294 .m_traverse = _blake2_traverse ,
@@ -332,18 +332,18 @@ static inline blake2_impl
332332type_to_impl (PyTypeObject * type )
333333{
334334#if defined(HACL_CAN_COMPILE_SIMD128 ) || defined(HACL_CAN_COMPILE_SIMD256 )
335- Blake2State * st = blake2_get_state_from_type (type );
335+ blake2module_state * state = blake2_get_state_from_type (type );
336336#endif
337337 if (!strcmp (type -> tp_name , blake2b_type_spec .name )) {
338338#if HACL_CAN_COMPILE_SIMD256
339- return st -> can_run_simd256 ? Blake2b_256 : Blake2b ;
339+ return state -> can_run_simd256 ? Blake2b_256 : Blake2b ;
340340#else
341341 return Blake2b ;
342342#endif
343343 }
344344 else if (!strcmp (type -> tp_name , blake2s_type_spec .name )) {
345345#if HACL_CAN_COMPILE_SIMD128
346- return st -> can_run_simd128 ? Blake2s_128 : Blake2s ;
346+ return state -> can_run_simd128 ? Blake2s_128 : Blake2s ;
347347#else
348348 return Blake2s ;
349349#endif
0 commit comments