8000 Add pycore_ceval_state.h. · python/cpython@bceb0bb · GitHub
[go: up one dir, main page]

Skip to content

Commit bceb0bb

Browse files
Add pycore_ceval_state.h.
1 parent 530cc9d commit bceb0bb

File tree

6 files changed

+67
-41
lines changed

6 files changed

+67
-41
lines changed

Include/internal/pycore_ceval_state.h

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#ifndef Py_INTERNAL_CEVAL_STATE_H
2+
#define Py_INTERNAL_CEVAL_STATE_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+
12+
#include "pycore_atomic.h" /* _Py_atomic_address */
13+
#include "pycore_gil.h" // struct _gil_runtime_state
14+
15+
16+
struct _ceval_runtime_state {
17+
/* Request for checking signals. It is shared by all interpreters (see
18+
bpo-40513). Any thread of any interpreter can receive a signal, but only
19+
the main thread of the main interpreter can handle signals: see
20+
_Py_ThreadCanHandleSignals(). */
21+
_Py_atomic_int signals_pending;
22+
struct _gil_runtime_state gil;
23+
};
24+
25+
26+
struct _pending_calls {
27+
int busy;
28+
PyThread_type_lock lock;
29+
/* Request for running pending calls. */
30+
_Py_atomic_int calls_to_do;
31+
/* Request for looking at the `async_exc` field of the current
32+
thread state.
33+
Guarded by the GIL. */
34+
int async_exc;
35+
#define NPENDINGCALLS 32
36+
struct {
37+
int (*func)(void *);
38+
void *arg;
39+
} calls[NPENDINGCALLS];
40+
int first;
41+
int last;
42+
};
43+
44+
struct _ceval_state {
45+
int recursion_limit;
46+
/* This single variable consolidates all requests to break out of
47+
the fast path in the eval loop. */
48+
_Py_atomic_int eval_breaker;
49+
/* Request for dropping the GIL */
50+
_Py_atomic_int gil_drop_request;
51+
/* The GC is ready to be executed */
52+
_Py_atomic_int gc_scheduled;
53+
struct _pending_calls pending;
54+
};
55+
56+
57+
#ifdef __cplusplus
58+
}
59+
#endif
60+
#endif /* !Py_INTERNAL_CEVAL_STATE_H */

Include/internal/pycore_interp.h

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ extern "C" {
1212

1313
#include "pycore_atomic.h" // _Py_atomic_address
1414
#include "pycore_ast_state.h" // struct ast_state
15+
#include "pycore_ceval_state.h" // struct _ceval_state
1516
#include "pycore_code.h" // struct callable_cache
1617
#include "pycore_context.h" // struct _Py_context_state
1718
#include "pycore_dict_state.h" // struct _Py_dict_state
@@ -28,37 +29,6 @@ extern "C" {
2829
#include "pycore_warnings.h" // struct _warnings_runtime_state
2930

3031

31-
struct _pending_calls {
32-
int busy;
33-
PyThread_type_lock lock;
34-
/* Request for running pending calls. */
35-
_Py_atomic_int calls_to_do;
36-
/* Request for looking at the `async_exc` field of the current
37-
thread state.
38-
Guarded by the GIL. */
39-
int async_exc;
40-
#define NPENDINGCALLS 32
41-
struct {
42-
int (*func)(void *);
43-
void *arg;
44-
} calls[NPENDINGCALLS];
45-
int first;
46-
int last;
47-
};
48-
49-
struct _ceval_state {
50-
int recursion_limit;
51-
/* This single variable consolidates all requests to break out of
52-
the fast path in the eval loop. */
53-
_Py_atomic_int eval_breaker;
54-
/* Request for dropping the GIL */
55-
_Py_atomic_int gil_drop_request;
56-
/* The GC is ready to be executed */
57-
_Py_atomic_int gc_scheduled;
58-
struct _pending_calls pending;
59-
};
60-
61-
6232
// atexit state
6333
typedef struct {
6434
PyObject *func;

Include/internal/pycore_runtime.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ extern "C" {
99
#endif
1010

1111
#include "pycore_atomic.h" /* _Py_atomic_address */
12+
#include "pycore_ceval_state.h" // struct _ceval_runtime_state
1213
#include "pycore_dict_state.h" // struct _Py_dict_runtime_state
1314
#include "pycore_dtoa.h" // struct _dtoa_runtime_state
1415
#include "pycore_floatobject.h" // struct _Py_float_runtime_state
1516
#include "pycore_function.h" // struct _func_runtime_state
16-
#include "pycore_gil.h" // struct _gil_runtime_state
1717
#include "pycore_global_objects.h" // struct _Py_global_objects
1818
#include "pycore_import.h" // struct _import_runtime_state
1919
#include "pycore_interp.h" // PyInterpreterState
@@ -29,15 +29,6 @@ struct _getargs_runtime_state {
2929

3030
/* ceval state */
3131

32-
struct _ceval_runtime_state {
33-
/* Request for checking signals. It is shared by all interpreters (see
34-
bpo-40513). Any thread of any interpreter can receive a signal, but only
35-
the main thread of the main interpreter can handle signals: see
36-
_Py_ThreadCanHandleSignals(). */
37-
_Py_atomic_int signals_pending;
38-
struct _gil_runtime_state gil;
39-
};
40-
4132
/* GIL state */
4233

4334
struct _gilstate_runtime_state {

Makefile.pre.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,6 +1623,7 @@ PYTHON_HEADERS= \
16231623
$(srcdir)/Include/internal/pycore_bytesobject.h \
16241624
$(srcdir)/Include/internal/pycore_call.h \
16251625
$(srcdir)/Include/internal/pycore_ceval.h \
1626+
$(srcdir)/Include/internal/pycore_ceval_state.h \
16261627
$(srcdir)/Include/internal/pycore_code.h \
16271628
$(srcdir)/Include/internal/pycore_compile.h \
16281629
$(srcdir)/Include/internal/pycore_condvar.h \

PCbuild/pythoncore.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@
204204
<ClInclude Include="..\Include\internal\pycore_bytesobject.h" />
205205
<ClInclude Include="..\Include\internal\pycore_call.h" />
206206
<ClInclude Include="..\Include\internal\pycore_ceval.h" />
207+
<ClInclude Include="..\Include\internal\pycore_ceval_state.h" />
207208
<ClInclude Include="..\Include\internal\pycore_code.h" />
208209
<ClInclude Include="..\Include\internal\pycore_compile.h" />
209210
<ClInclude Include="..\Include\internal\pycore_condvar.h" />

PCbuild/pythoncore.vcxproj.filters

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,9 @@
519519
<ClInclude Include="..\Include\internal\pycore_ceval.h">
520520
<Filter>Include\internal</Filter>
521521
</ClInclude>
522+
<ClInclude Include="..\Include\internal\pycore_ceval_state.h">
523+
<Filter>Include\internal</Filter>
524+
</ClInclude>
522525
<ClInclude Include="..\Include\internal\pycore_code.h">
523526
<Filter>Include\internal</Filter>
524527
</ClInclude>

0 commit comments

Comments
 (0)
0