Skip to content

Commit 05c1e66

Browse files
committed
post-merge
1 parent dde68c4 commit 05c1e66

File tree

7 files changed

+10
-31
lines changed

7 files changed

+10
-31
lines changed

Modules/blake2module.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ type_to_impl(PyTypeObject *type)
350350
}
351351

352352
typedef struct {
353-
PyObject_HEAD
353+
PyObject_HASHLIB_HEAD
354354
union {
355355
Hacl_Hash_Blake2s_state_t *blake2s_state;
356356
Hacl_Hash_Blake2b_state_t *blake2b_state;
@@ -362,8 +362,6 @@ typedef struct {
362362
#endif
363363
};
364364
blake2_impl impl;
365-
bool use_mutex;
366-
PyMutex mutex;
367365
} Blake2Object;
368366

369367
#define _Blake2Object_CAST(op) ((Blake2Object *)(op))

Modules/hashlib.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@
5050

5151
#include "pythread.h"
5252

53-
#define HASHLIB_LOCK_HEAD \
53+
#define PyObject_HASHLIB_HEAD \
54+
PyObject_HEAD \
5455
/* Guard against race conditions during incremental update(). */ \
5556
PyMutex mutex;
5657

Modules/hmacmodule.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,7 @@ get_hmacmodule_state_by_cls(PyTypeObject *cls)
283283
typedef Hacl_Streaming_HMAC_agile_state HACL_HMAC_state;
284284

285285
typedef struct HMACObject {
286-
PyObject_HEAD
287-
288-
bool use_mutex;
289-
PyMutex mutex;
290-
286+
PyObject_HASHLIB_HEAD
291287
// Hash function information
292288
PyObject *name; // rendered name (exact unicode object)
293289
HMAC_Hash_Kind kind; // can be used for runtime dispatch (must be known)
@@ -878,12 +874,11 @@ _hmac_HMAC_copy_impl(HMACObject *self, PyTypeObject *cls)
878874
return NULL;
879875
}
880876

881-
int rc = 0;
882877
HASHLIB_ACQUIRE_LOCK(self);
883878
/* copy hash information */
884879
hmac_copy_hinfo(copy, self);
885880
/* copy internal state */
886-
rc = hmac_copy_state(copy, self);
881+
int rc = hmac_copy_state(copy, self);
887882
HASHLIB_RELEASE_LOCK(self);
888883

889884
if (rc < 0) {

Modules/md5module.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,8 @@ class MD5Type "MD5object *" "&PyType_Type"
3737

3838
#include "_hacl/Hacl_Hash_MD5.h"
3939

40-
4140
typedef struct {
42-
PyObject_HEAD
43-
HASHLIB_LOCK_HEAD
41+
PyObject_HASHLIB_HEAD
4442
Hacl_Hash_MD5_state_t *hash_state;
4543
} MD5object;
4644

Modules/sha1module.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,7 @@ class SHA1Type "SHA1object *" "&PyType_Type"
3838
#include "_hacl/Hacl_Hash_SHA1.h"
3939

4040
typedef struct {
41-
PyObject_HEAD
42-
// Prevents undefined behavior via multiple threads entering the C API.
43-
bool use_mutex;
44-
PyMutex mutex;
45-
PyThread_type_lock lock;
41+
PyObject_HASHLIB_HEAD
4642
Hacl_Hash_SHA1_state_t *hash_state;
4743
} SHA1object;
4844

Modules/sha2module.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,14 @@ class SHA512Type "SHA512object *" "&PyType_Type"
5050
// TODO: Get rid of int digestsize in favor of Hacl state info?
5151

5252
typedef struct {
53-
PyObject_HEAD
53+
PyObject_HASHLIB_HEAD
5454
int digestsize;
55-
// Prevents undefined behavior via multiple threads entering the C API.
56-
bool use_mutex;
57-
PyMutex mutex;
5855
Hacl_Hash_SHA2_state_t_256 *state;
5956
} SHA256object;
6057

6158
typedef struct {
62-
PyObject_HEAD
59+
PyObject_HASHLIB_HEAD
6360
int digestsize;
64-
// Prevents undefined behavior via multiple threads entering the C API.
65-
bool use_mutex;
66-
PyMutex mutex;
6761
Hacl_Hash_SHA2_state_t_512 *state;
6862
} SHA512object;
6963

Modules/sha3module.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,7 @@ class _sha3.shake_256 "SHA3object *" "&SHAKE256type"
5959
#include "_hacl/Hacl_Hash_SHA3.h"
6060

6161
typedef struct {
62-
PyObject_HEAD
63-
// Prevents undefined behavior via multiple threads entering the C API.
64-
bool use_mutex;
65-
PyMutex mutex;
62+
PyObject_HASHLIB_HEAD
6663
Hacl_Hash_SHA3_state_t *hash_state;
6764
} SHA3object;
6865

0 commit comments

Comments
 (0)