| 
									
										
										
										
											2017-09-07 23:51:28 -06:00
										 |  |  | #ifndef Py_INTERNAL_CEVAL_H
 | 
					
						
							|  |  |  | #define Py_INTERNAL_CEVAL_H
 | 
					
						
							|  |  |  | #ifdef __cplusplus
 | 
					
						
							|  |  |  | extern "C" { | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-17 23:02:26 +02:00
										 |  |  | #ifndef Py_BUILD_CORE
 | 
					
						
							|  |  |  | #  error "this header requires Py_BUILD_CORE define"
 | 
					
						
							| 
									
										
										
										
											2018-11-09 13:03:37 +01:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-02 23:51:20 +02:00
										 |  |  | /* Forward declarations */ | 
					
						
							| 
									
										
										
										
											2019-10-04 02:21:05 +02:00
										 |  |  | struct pyruntimestate; | 
					
						
							| 
									
										
										
										
											2019-10-02 23:51:20 +02:00
										 |  |  | struct _ceval_runtime_state; | 
					
						
							| 
									
										
										
										
											2019-11-14 12:20:46 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-13 17:09:24 -07:00
										 |  |  | #ifndef Py_DEFAULT_RECURSION_LIMIT
 | 
					
						
							|  |  |  | #  define Py_DEFAULT_RECURSION_LIMIT 1000
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-13 14:09:13 +02:00
										 |  |  | #include "pycore_interp.h"        // PyInterpreterState.eval_frame
 | 
					
						
							|  |  |  | #include "pycore_pystate.h"       // _PyThreadState_GET()
 | 
					
						
							| 
									
										
										
										
											2017-09-07 23:51:28 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-13 17:09:24 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-17 18:56:44 +01:00
										 |  |  | extern void _Py_FinishPendingCalls(PyThreadState *tstate); | 
					
						
							|  |  |  | extern void _PyEval_InitRuntimeState(struct _ceval_runtime_state *); | 
					
						
							| 
									
										
										
										
											2021-12-07 14:02:17 -07:00
										 |  |  | extern void _PyEval_InitState(struct _ceval_state *, PyThread_type_lock); | 
					
						
							| 
									
										
										
										
											2020-04-08 17:54:59 +02:00
										 |  |  | extern void _PyEval_FiniState(struct _ceval_state *ceval); | 
					
						
							| 
									
										
										
										
											2020-04-08 23:35:05 +02:00
										 |  |  | PyAPI_FUNC(void) _PyEval_SignalReceived(PyInterpreterState *interp); | 
					
						
							| 
									
										
										
										
											2019-05-10 23:39:09 +02:00
										 |  |  | PyAPI_FUNC(int) _PyEval_AddPendingCall( | 
					
						
							| 
									
										
										
										
											2020-04-08 23:35:05 +02:00
										 |  |  |     PyInterpreterState *interp, | 
					
						
							| 
									
										
										
										
											2019-05-10 23:39:09 +02:00
										 |  |  |     int (*func)(void *), | 
					
						
							|  |  |  |     void *arg); | 
					
						
							| 
									
										
										
										
											2021-02-19 15:10:45 +01:00
										 |  |  | PyAPI_FUNC(void) _PyEval_SignalAsyncExc(PyInterpreterState *interp); | 
					
						
							| 
									
										
										
										
											2020-04-15 01:16:24 +09:00
										 |  |  | #ifdef HAVE_FORK
 | 
					
						
							| 
									
										
										
										
											2020-06-02 18:44:54 +02:00
										 |  |  | extern PyStatus _PyEval_ReInitThreads(PyThreadState *tstate); | 
					
						
							| 
									
										
										
										
											2020-04-15 01:16:24 +09:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2019-06-13 22:41:23 +02:00
										 |  |  | PyAPI_FUNC(void) _PyEval_SetCoroutineOriginTrackingDepth( | 
					
						
							|  |  |  |     PyThreadState *tstate, | 
					
						
							|  |  |  |     int new_depth); | 
					
						
							| 
									
										
										
										
											2017-09-07 23:51:28 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-03 21:30:58 +09:00
										 |  |  | void _PyEval_Fini(void); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-18 19:20:16 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-20 15:17:18 +01:00
										 |  |  | extern PyObject* _PyEval_GetBuiltins(PyThreadState *tstate); | 
					
						
							|  |  |  | extern PyObject *_PyEval_BuiltinsFromGlobals( | 
					
						
							|  |  |  |     PyThreadState *tstate, | 
					
						
							|  |  |  |     PyObject *globals); | 
					
						
							| 
									
										
										
										
											2021-02-18 19:20:16 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-14 12:20:46 +01:00
										 |  |  | static inline PyObject* | 
					
						
							| 
									
										
										
										
											2022-02-25 16:22:00 +01:00
										 |  |  | _PyEval_EvalFrame(PyThreadState *tstate, struct _PyInterpreterFrame *frame, int throwflag) | 
					
						
							| 
									
										
										
										
											2019-11-14 12:20:46 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2021-10-11 11:34:02 +01:00
										 |  |  |     if (tstate->interp->eval_frame == NULL) { | 
					
						
							|  |  |  |         return _PyEval_EvalFrameDefault(tstate, frame, throwflag); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-07-26 11:22:16 +01:00
										 |  |  |     return tstate->interp->eval_frame(tstate, frame, throwflag); | 
					
						
							| 
									
										
										
										
											2019-11-14 12:20:46 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-01 10:42:03 +00:00
										 |  |  | extern PyObject * | 
					
						
							|  |  |  | _PyEval_Vector(PyThreadState *tstate, | 
					
						
							| 
									
										
										
										
											2021-11-23 09:53:24 +00:00
										 |  |  |             PyFunctionObject *func, PyObject *locals, | 
					
						
							| 
									
										
										
										
											2021-02-01 10:42:03 +00:00
										 |  |  |             PyObject* const* args, size_t argcount, | 
					
						
							|  |  |  |             PyObject *kwnames); | 
					
						
							| 
									
										
										
										
											2019-11-16 01:03:22 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-05 20:27:47 +02:00
										 |  |  | #ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
 | 
					
						
							|  |  |  | extern int _PyEval_ThreadsInitialized(PyInterpreterState *interp); | 
					
						
							|  |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2020-04-14 14:26:24 +02:00
										 |  |  | extern int _PyEval_ThreadsInitialized(struct pyruntimestate *runtime); | 
					
						
							| 
									
										
										
										
											2020-05-05 20:27:47 +02:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2020-04-08 17:54:59 +02:00
										 |  |  | extern PyStatus _PyEval_InitGIL(PyThreadState *tstate); | 
					
						
							| 
									
										
										
										
											2021-02-19 15:10:45 +01:00
										 |  |  | extern void _PyEval_FiniGIL(PyInterpreterState *interp); | 
					
						
							| 
									
										
										
										
											2020-03-09 21:24:14 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-18 02:26:04 +01:00
										 |  |  | extern void _PyEval_ReleaseLock(PyThreadState *tstate); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-08 22:56:37 +01:00
										 |  |  | extern void _PyEval_DeactivateOpCache(void); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-13 10:19:38 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* --- _Py_EnterRecursiveCall() ----------------------------------------- */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef USE_STACKCHECK
 | 
					
						
							|  |  |  | /* With USE_STACKCHECK macro defined, trigger stack checks in
 | 
					
						
							|  |  |  |    _Py_CheckRecursiveCall() on every 64th call to Py_EnterRecursiveCall. */ | 
					
						
							|  |  |  | static inline int _Py_MakeRecCheck(PyThreadState *tstate)  { | 
					
						
							| 
									
										
										
										
											2021-11-16 11:01:57 +00:00
										 |  |  |     return (tstate->recursion_remaining-- <= 0 | 
					
						
							|  |  |  |             || (tstate->recursion_remaining & 63) == 0); | 
					
						
							| 
									
										
										
										
											2020-03-13 10:19:38 +01:00
										 |  |  | } | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  | static inline int _Py_MakeRecCheck(PyThreadState *tstate) { | 
					
						
							| 
									
										
										
										
											2021-11-16 11:01:57 +00:00
										 |  |  |     return tstate->recursion_remaining-- <= 0; | 
					
						
							| 
									
										
										
										
											2020-03-13 10:19:38 +01:00
										 |  |  | } | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyAPI_FUNC(int) _Py_CheckRecursiveCall( | 
					
						
							|  |  |  |     PyThreadState *tstate, | 
					
						
							|  |  |  |     const char *where); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static inline int _Py_EnterRecursiveCall(PyThreadState *tstate, | 
					
						
							|  |  |  |                                          const char *where) { | 
					
						
							|  |  |  |     return (_Py_MakeRecCheck(tstate) && _Py_CheckRecursiveCall(tstate, where)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static inline int _Py_EnterRecursiveCall_inline(const char *where) { | 
					
						
							| 
									
										
										
										
											2021-10-13 14:09:13 +02:00
										 |  |  |     PyThreadState *tstate = _PyThreadState_GET(); | 
					
						
							| 
									
										
										
										
											2020-03-13 10:19:38 +01:00
										 |  |  |     return _Py_EnterRecursiveCall(tstate, where); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define Py_EnterRecursiveCall(where) _Py_EnterRecursiveCall_inline(where)
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static inline void _Py_LeaveRecursiveCall(PyThreadState *tstate)  { | 
					
						
							| 
									
										
										
										
											2021-11-16 11:01:57 +00:00
										 |  |  |     tstate->recursion_remaining++; | 
					
						
							| 
									
										
										
										
											2020-03-13 10:19:38 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static inline void _Py_LeaveRecursiveCall_inline(void)  { | 
					
						
							| 
									
										
										
										
											2021-10-13 14:09:13 +02:00
										 |  |  |     PyThreadState *tstate = _PyThreadState_GET(); | 
					
						
							| 
									
										
										
										
											2020-03-13 10:19:38 +01:00
										 |  |  |     _Py_LeaveRecursiveCall(tstate); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define Py_LeaveRecursiveCall() _Py_LeaveRecursiveCall_inline()
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-25 16:22:00 +01:00
										 |  |  | struct _PyInterpreterFrame *_PyEval_GetFrame(void); | 
					
						
							| 
									
										
										
										
											2021-07-26 11:22:16 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-06 10:13:49 +00:00
										 |  |  | PyObject *_Py_MakeCoro(PyFunctionObject *func); | 
					
						
							| 
									
										
										
										
											2020-03-13 10:19:38 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-07 23:51:28 -06:00
										 |  |  | #ifdef __cplusplus
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | #endif /* !Py_INTERNAL_CEVAL_H */
 |