Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:06:43

0001 #ifndef Py_INTERNAL_CEVAL_H
0002 #define Py_INTERNAL_CEVAL_H
0003 #ifdef __cplusplus
0004 extern "C" {
0005 #endif
0006 
0007 #ifndef Py_BUILD_CORE
0008 #  error "this header requires Py_BUILD_CORE define"
0009 #endif
0010 
0011 /* Forward declarations */
0012 struct pyruntimestate;
0013 struct _ceval_runtime_state;
0014 
0015 #ifndef Py_DEFAULT_RECURSION_LIMIT
0016 #  define Py_DEFAULT_RECURSION_LIMIT 1000
0017 #endif
0018 
0019 #include "pycore_interp.h"        // PyInterpreterState.eval_frame
0020 #include "pycore_pystate.h"       // _PyThreadState_GET()
0021 
0022 
0023 extern void _Py_FinishPendingCalls(PyThreadState *tstate);
0024 extern void _PyEval_InitState(PyInterpreterState *, PyThread_type_lock);
0025 extern void _PyEval_FiniState(struct _ceval_state *ceval);
0026 PyAPI_FUNC(void) _PyEval_SignalReceived(PyInterpreterState *interp);
0027 PyAPI_FUNC(int) _PyEval_AddPendingCall(
0028     PyInterpreterState *interp,
0029     int (*func)(void *),
0030     void *arg,
0031     int mainthreadonly);
0032 PyAPI_FUNC(void) _PyEval_SignalAsyncExc(PyInterpreterState *interp);
0033 #ifdef HAVE_FORK
0034 extern PyStatus _PyEval_ReInitThreads(PyThreadState *tstate);
0035 #endif
0036 
0037 // Used by sys.call_tracing()
0038 extern PyObject* _PyEval_CallTracing(PyObject *func, PyObject *args);
0039 
0040 // Used by sys.get_asyncgen_hooks()
0041 extern PyObject* _PyEval_GetAsyncGenFirstiter(void);
0042 extern PyObject* _PyEval_GetAsyncGenFinalizer(void);
0043 
0044 // Used by sys.set_asyncgen_hooks()
0045 extern int _PyEval_SetAsyncGenFirstiter(PyObject *);
0046 extern int _PyEval_SetAsyncGenFinalizer(PyObject *);
0047 
0048 // Used by sys.get_coroutine_origin_tracking_depth()
0049 // and sys.set_coroutine_origin_tracking_depth()
0050 extern int _PyEval_GetCoroutineOriginTrackingDepth(void);
0051 extern int _PyEval_SetCoroutineOriginTrackingDepth(int depth);
0052 
0053 extern void _PyEval_Fini(void);
0054 
0055 
0056 extern PyObject* _PyEval_GetBuiltins(PyThreadState *tstate);
0057 extern PyObject* _PyEval_BuiltinsFromGlobals(
0058     PyThreadState *tstate,
0059     PyObject *globals);
0060 
0061 // Trampoline API
0062 
0063 typedef struct {
0064     // Callback to initialize the trampoline state
0065     void* (*init_state)(void);
0066     // Callback to register every trampoline being created
0067     void (*write_state)(void* state, const void *code_addr,
0068                         unsigned int code_size, PyCodeObject* code);
0069     // Callback to free the trampoline state
0070     int (*free_state)(void* state);
0071 } _PyPerf_Callbacks;
0072 
0073 extern int _PyPerfTrampoline_SetCallbacks(_PyPerf_Callbacks *);
0074 extern void _PyPerfTrampoline_GetCallbacks(_PyPerf_Callbacks *);
0075 extern int _PyPerfTrampoline_Init(int activate);
0076 extern int _PyPerfTrampoline_Fini(void);
0077 extern void _PyPerfTrampoline_FreeArenas(void);
0078 extern int _PyIsPerfTrampolineActive(void);
0079 extern PyStatus _PyPerfTrampoline_AfterFork_Child(void);
0080 #ifdef PY_HAVE_PERF_TRAMPOLINE
0081 extern _PyPerf_Callbacks _Py_perfmap_callbacks;
0082 #endif
0083 
0084 static inline PyObject*
0085 _PyEval_EvalFrame(PyThreadState *tstate, struct _PyInterpreterFrame *frame, int throwflag)
0086 {
0087     EVAL_CALL_STAT_INC(EVAL_CALL_TOTAL);
0088     if (tstate->interp->eval_frame == NULL) {
0089         return _PyEval_EvalFrameDefault(tstate, frame, throwflag);
0090     }
0091     return tstate->interp->eval_frame(tstate, frame, throwflag);
0092 }
0093 
0094 extern PyObject*
0095 _PyEval_Vector(PyThreadState *tstate,
0096             PyFunctionObject *func, PyObject *locals,
0097             PyObject* const* args, size_t argcount,
0098             PyObject *kwnames);
0099 
0100 extern int _PyEval_ThreadsInitialized(void);
0101 extern PyStatus _PyEval_InitGIL(PyThreadState *tstate, int own_gil);
0102 extern void _PyEval_FiniGIL(PyInterpreterState *interp);
0103 
0104 extern void _PyEval_AcquireLock(PyThreadState *tstate);
0105 extern void _PyEval_ReleaseLock(PyInterpreterState *, PyThreadState *);
0106 extern PyThreadState * _PyThreadState_SwapNoGIL(PyThreadState *);
0107 
0108 extern void _PyEval_DeactivateOpCache(void);
0109 
0110 
0111 /* --- _Py_EnterRecursiveCall() ----------------------------------------- */
0112 
0113 #ifdef USE_STACKCHECK
0114 /* With USE_STACKCHECK macro defined, trigger stack checks in
0115    _Py_CheckRecursiveCall() on every 64th call to _Py_EnterRecursiveCall. */
0116 static inline int _Py_MakeRecCheck(PyThreadState *tstate)  {
0117     return (tstate->c_recursion_remaining-- <= 0
0118             || (tstate->c_recursion_remaining & 63) == 0);
0119 }
0120 #else
0121 static inline int _Py_MakeRecCheck(PyThreadState *tstate) {
0122     return tstate->c_recursion_remaining-- <= 0;
0123 }
0124 #endif
0125 
0126 PyAPI_FUNC(int) _Py_CheckRecursiveCall(
0127     PyThreadState *tstate,
0128     const char *where);
0129 
0130 int _Py_CheckRecursiveCallPy(
0131     PyThreadState *tstate);
0132 
0133 static inline int _Py_EnterRecursiveCallTstate(PyThreadState *tstate,
0134                                                const char *where) {
0135     return (_Py_MakeRecCheck(tstate) && _Py_CheckRecursiveCall(tstate, where));
0136 }
0137 
0138 static inline int _Py_EnterRecursiveCall(const char *where) {
0139     PyThreadState *tstate = _PyThreadState_GET();
0140     return _Py_EnterRecursiveCallTstate(tstate, where);
0141 }
0142 
0143 static inline void _Py_LeaveRecursiveCallTstate(PyThreadState *tstate)  {
0144     tstate->c_recursion_remaining++;
0145 }
0146 
0147 static inline void _Py_LeaveRecursiveCall(void)  {
0148     PyThreadState *tstate = _PyThreadState_GET();
0149     _Py_LeaveRecursiveCallTstate(tstate);
0150 }
0151 
0152 extern struct _PyInterpreterFrame* _PyEval_GetFrame(void);
0153 
0154 extern PyObject* _Py_MakeCoro(PyFunctionObject *func);
0155 
0156 extern int _Py_HandlePending(PyThreadState *tstate);
0157 
0158 extern PyObject * _PyEval_GetFrameLocals(void);
0159 
0160 
0161 #ifdef __cplusplus
0162 }
0163 #endif
0164 #endif /* !Py_INTERNAL_CEVAL_H */