mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
gh-117657: Make Py_TYPE and Py_SET_TYPE thread safe (GH-120165)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Nadeshiko Manju <me@manjusaka.me>
This commit is contained in:
parent
ce3879bd45
commit
e16aed63f6
5 changed files with 45 additions and 4 deletions
|
@ -401,7 +401,10 @@ PyAPI_FUNC(PyStatus) _PyInterpreterState_New(
|
|||
#define RARE_EVENT_INTERP_INC(interp, name) \
|
||||
do { \
|
||||
/* saturating add */ \
|
||||
if (interp->rare_events.name < UINT8_MAX) interp->rare_events.name++; \
|
||||
int val = FT_ATOMIC_LOAD_UINT8_RELAXED(interp->rare_events.name); \
|
||||
if (val < UINT8_MAX) { \
|
||||
FT_ATOMIC_STORE_UINT8(interp->rare_events.name, val + 1); \
|
||||
} \
|
||||
RARE_EVENT_STAT_INC(name); \
|
||||
} while (0); \
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue