@@ -42,7 +42,7 @@ PyAPI_FUNC(int) _PyEval_MakePendingCalls(PyThreadState *);
42
42
43
43
extern void _Py_FinishPendingCalls (PyThreadState * tstate );
44
44
extern void _PyEval_InitState (PyInterpreterState * );
45
- extern void _PyEval_SignalReceived (PyInterpreterState * interp );
45
+ extern void _PyEval_SignalReceived (void );
46
46
47
47
// bitwise flags:
48
48
#define _Py_PENDING_MAINTHREADONLY 1
@@ -55,7 +55,6 @@ PyAPI_FUNC(int) _PyEval_AddPendingCall(
55
55
void * arg ,
56
56
int flags );
57
57
58
- extern void _PyEval_SignalAsyncExc (PyInterpreterState * interp );
59
58
#ifdef HAVE_FORK
60
59
extern PyStatus _PyEval_ReInitThreads (PyThreadState * tstate );
61
60
#endif
@@ -200,40 +199,43 @@ int _PyEval_UnpackIterable(PyThreadState *tstate, PyObject *v, int argcnt, int a
200
199
void _PyEval_FrameClearAndPop (PyThreadState * tstate , _PyInterpreterFrame * frame );
201
200
202
201
203
- #define _PY_GIL_DROP_REQUEST_BIT 0
204
- #define _PY_SIGNALS_PENDING_BIT 1
205
- #define _PY_CALLS_TO_DO_BIT 2
206
- #define _PY_ASYNC_EXCEPTION_BIT 3
207
- #define _PY_GC_SCHEDULED_BIT 4
208
- #define _PY_EVAL_PLEASE_STOP_BIT 5
209
- #define _PY_EVAL_EXPLICIT_MERGE_BIT 6
202
+ /* Bits that can be set in PyThreadState.eval_breaker */
203
+ #define _PY_GIL_DROP_REQUEST_BIT (1U << 0)
204
+ #define _PY_SIGNALS_PENDING_BIT (1U << 1)
205
+ #define _PY_CALLS_TO_DO_BIT (1U << 2)
206
+ #define _PY_ASYNC_EXCEPTION_BIT (1U << 3)
207
+ #define _PY_GC_SCHEDULED_BIT (1U << 4)
208
+ #define _PY_EVAL_PLEASE_STOP_BIT (1U << 5)
209
+ #define _PY_EVAL_EXPLICIT_MERGE_BIT (1U << 6)
210
210
211
211
/* Reserve a few bits for future use */
212
212
#define _PY_EVAL_EVENTS_BITS 8
213
213
#define _PY_EVAL_EVENTS_MASK ((1 << _PY_EVAL_EVENTS_BITS)-1)
214
214
215
215
static inline void
216
- _Py_set_eval_breaker_bit (PyInterpreterState * interp , uint32_t bit , uint32_t set )
216
+ _Py_set_eval_breaker_bit (PyThreadState * tstate , uintptr_t bit )
217
217
{
218
- assert (set == 0 || set == 1 );
219
- uintptr_t to_set = set << bit ;
220
- uintptr_t mask = ((uintptr_t )1 ) << bit ;
221
- uintptr_t old = _Py_atomic_load_uintptr (& interp -> ceval .eval_breaker );
222
- if ((old & mask ) == to_set ) {
223
- return ;
224
- }
225
- uintptr_t new ;
226
- do {
227
- new = (old & ~mask ) | to_set ;
228
- } while (!_Py_atomic_compare_exchange_uintptr (& interp -> ceval .eval_breaker , & old , new ));
218
+ _Py_atomic_or_uintptr (& tstate -> eval_breaker , bit );
219
+ }
220
+
221
+ static inline void
222
+ _Py_unset_eval_breaker_bit (PyThreadState * tstate , uintptr_t bit )
223
+ {
224
+ _Py_atomic_and_uintptr (& tstate -> eval_breaker , ~bit );
229
225
}
230
226
231
- static inline bool
232
- _Py_eval_breaker_bit_is_set (PyInterpreterState * interp , int32_t bit )
227
+ static inline int
228
+ _Py_eval_breaker_bit_is_set (PyThreadState * tstate , uintptr_t bit )
233
229
{
234
- return _Py_atomic_load_uintptr_relaxed (& interp -> ceval .eval_breaker ) & (((uintptr_t )1 ) << bit );
230
+ uintptr_t b = _Py_atomic_load_uintptr_relaxed (& tstate -> eval_breaker );
231
+ return (b & bit ) != 0 ;
235
232
}
236
233
234
+ // Free-threaded builds use these functions to set or unset a bit on all
235
+ // threads in the given interpreter.
236
+ void _Py_set_eval_breaker_bit_all (PyInterpreterState * interp , uintptr_t bit );
237
+ void _Py_unset_eval_breaker_bit_all (PyInterpreterState * interp , uintptr_t bit );
238
+
237
239
238
240
#ifdef __cplusplus
239
241
}
0 commit comments