Skip to content

Commit 73bb7f1

Browse files
committed
Resync imported files
1 parent e6a820f commit 73bb7f1

26 files changed

+52413
-1794
lines changed
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
#ifndef Py_INTERNAL_CEVAL_H
2+
#define Py_INTERNAL_CEVAL_H
3+
#ifdef __cplusplus
4+
extern "C" {
5+
#endif
6+
7+
#ifndef Py_BUILD_CORE
8+
# error "this header requires Py_BUILD_CORE define"
9+
#endif
10+
11+
/* Forward declarations */
12+
struct pyruntimestate;
13+
struct _ceval_runtime_state;
14+
15+
/* WASI has limited call stack. Python's recursion limit depends on code
16+
layout, optimization, and WASI runtime. Wasmtime can handle about 700-750
17+
recursions, sometimes less. 600 is a more conservative limit. */
18+
#ifndef Py_DEFAULT_RECURSION_LIMIT
19+
# ifdef __wasi__
20+
# define Py_DEFAULT_RECURSION_LIMIT 600
21+
# else
22+
# define Py_DEFAULT_RECURSION_LIMIT 1000
23+
# endif
24+
#endif
25+
26+
#include "pycore_interp.h" // PyInterpreterState.eval_frame
27+
#include "pycore_pystate.h" // _PyThreadState_GET()
28+
29+
30+
extern void _Py_FinishPendingCalls(PyThreadState *tstate);
31+
extern void _PyEval_InitRuntimeState(struct _ceval_runtime_state *);
32+
extern void _PyEval_InitState(struct _ceval_state *, PyThread_type_lock);
33+
extern void _PyEval_FiniState(struct _ceval_state *ceval);
34+
PyAPI_FUNC(void) _PyEval_SignalReceived(PyInterpreterState *interp);
35+
PyAPI_FUNC(int) _PyEval_AddPendingCall(
36+
PyInterpreterState *interp,
37+
int (*func)(void *),
38+
void *arg);
39+
PyAPI_FUNC(void) _PyEval_SignalAsyncExc(PyInterpreterState *interp);
40+
#ifdef HAVE_FORK
41+
extern PyStatus _PyEval_ReInitThreads(PyThreadState *tstate);
42+
#endif
43+
44+
// Used by sys.call_tracing()
45+
extern PyObject* _PyEval_CallTracing(PyObject *func, PyObject *args);
46+
47+
// Used by sys.get_asyncgen_hooks()
48+
extern PyObject* _PyEval_GetAsyncGenFirstiter(void);
49+
extern PyObject* _PyEval_GetAsyncGenFinalizer(void);
50+
51+
// Used by sys.set_asyncgen_hooks()
52+
extern int _PyEval_SetAsyncGenFirstiter(PyObject *);
53+
extern int _PyEval_SetAsyncGenFinalizer(PyObject *);
54+
55+
// Used by sys.get_coroutine_origin_tracking_depth()
56+
// and sys.set_coroutine_origin_tracking_depth()
57+
extern int _PyEval_GetCoroutineOriginTrackingDepth(void);
58+
extern int _PyEval_SetCoroutineOriginTrackingDepth(int depth);
59+
60+
extern void _PyEval_Fini(void);
61+
62+
63+
extern PyObject* _PyEval_GetBuiltins(PyThreadState *tstate);
64+
extern PyObject* _PyEval_BuiltinsFromGlobals(
65+
PyThreadState *tstate,
66+
PyObject *globals);
67+
68+
69+
static inline PyObject*
70+
_PyEval_EvalFrame(PyThreadState *tstate, struct _PyInterpreterFrame *frame, int throwflag)
71+
{
72+
if (tstate->interp->eval_frame == NULL) {
73+
return _PyEval_EvalFrameDefault(tstate, frame, throwflag);
74+
}
75+
return tstate->interp->eval_frame(tstate, frame, throwflag);
76+
}
77+
78+
extern PyObject*
79+
_PyEval_Vector(PyThreadState *tstate,
80+
PyFunctionObject *func, PyObject *locals,
81+
PyObject* const* args, size_t argcount,
82+
PyObject *kwnames);
83+
84+
extern int _PyEval_ThreadsInitialized(struct pyruntimestate *runtime);
85+
extern PyStatus _PyEval_InitGIL(PyThreadState *tstate);
86+
extern void _PyEval_FiniGIL(PyInterpreterState *interp);
87+
88+
extern void _PyEval_ReleaseLock(PyThreadState *tstate);
89+
90+
extern void _PyEval_DeactivateOpCache(void);
91+
92+
93+
/* --- _Py_EnterRecursiveCall() ----------------------------------------- */
94+
95+
#ifdef USE_STACKCHECK
96+
/* With USE_STACKCHECK macro defined, trigger stack checks in
97+
_Py_CheckRecursiveCall() on every 64th call to _Py_EnterRecursiveCall. */
98+
static inline int _Py_MakeRecCheck(PyThreadState *tstate) {
99+
return (tstate->recursion_remaining-- <= 0
100+
|| (tstate->recursion_remaining & 63) == 0);
101+
}
102+
#else
103+
static inline int _Py_MakeRecCheck(PyThreadState *tstate) {
104+
return tstate->recursion_remaining-- <= 0;
105+
}
106+
#endif
107+
108+
PyAPI_FUNC(int) _Py_CheckRecursiveCall(
109+
PyThreadState *tstate,
110+
const char *where);
111+
112+
static inline int _Py_EnterRecursiveCallTstate(PyThreadState *tstate,
113+
const char *where) {
114+
return (_Py_MakeRecCheck(tstate) && _Py_CheckRecursiveCall(tstate, where));
115+
}
116+
117+
static inline int _Py_EnterRecursiveCall(const char *where) {
118+
PyThreadState *tstate = _PyThreadState_GET();
119+
return _Py_EnterRecursiveCallTstate(tstate, where);
120+
}
121+
122+
static inline void _Py_LeaveRecursiveCallTstate(PyThreadState *tstate) {
123+
tstate->recursion_remaining++;
124+
}
125+
126+
static inline void _Py_LeaveRecursiveCall(void) {
127+
PyThreadState *tstate = _PyThreadState_GET();
128+
_Py_LeaveRecursiveCallTstate(tstate);
129+
}
130+
131+
extern struct _PyInterpreterFrame* _PyEval_GetFrame(void);
132+
133+
extern PyObject* _Py_MakeCoro(PyFunctionObject *func);
134+
135+
#ifdef __cplusplus
136+
}
137+
#endif
138+
#endif /* !Py_INTERNAL_CEVAL_H */
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#ifndef Py_INTERNAL_GLOBAL_OBJECTS_H
2+
#define Py_INTERNAL_GLOBAL_OBJECTS_H
3+
#ifdef __cplusplus
4+
extern "C" {
5+
#endif
6+
7+
#ifndef Py_BUILD_CORE
8+
# error "this header requires Py_BUILD_CORE define"
9+
#endif
10+
11+
#include "pycore_gc.h" // PyGC_Head
12+
#include "pycore_global_strings.h" // struct _Py_global_strings
13+
14+
15+
// These would be in pycore_long.h if it weren't for an include cycle.
16+
#define _PY_NSMALLPOSINTS 257
17+
#define _PY_NSMALLNEGINTS 5
18+
19+
20+
// Only immutable objects should be considered runtime-global.
21+
// All others must be per-interpreter.
22+
23+
#define _Py_GLOBAL_OBJECT(NAME) \
24+
_PyRuntime.global_objects.NAME
25+
#define _Py_SINGLETON(NAME) \
26+
_Py_GLOBAL_OBJECT(singletons.NAME)
27+
28+
struct _Py_global_objects {
29+
struct {
30+
/* Small integers are preallocated in this array so that they
31+
* can be shared.
32+
* The integers that are preallocated are those in the range
33+
* -_PY_NSMALLNEGINTS (inclusive) to _PY_NSMALLPOSINTS (exclusive).
34+
*/
35+
PyLongObject small_ints[_PY_NSMALLNEGINTS + _PY_NSMALLPOSINTS];
36+
37+
PyBytesObject bytes_empty;
38+
struct {
39+
PyBytesObject ob;
40+
char eos;
41+
} bytes_characters[256];
42+
43+
struct _Py_global_strings strings;
44+
45+
_PyGC_Head_UNUSED _tuple_empty_gc_not_used;
46+
PyTupleObject tuple_empty;
47+
} singletons;
48+
};
49+
50+
51+
#ifdef __cplusplus
52+
}
53+
#endif
54+
#endif /* !Py_INTERNAL_GLOBAL_OBJECTS_H */

0 commit comments

Comments
 (0)