Skip to content

Commit cb691fb

Browse files
committed
[GR-51961] Keep our C file structure closer to CPython, part 4
PullRequest: graalpython/3255
2 parents 9bff2d9 + 727db54 commit cb691fb

38 files changed

+32504
-3297
lines changed

graalpython/com.oracle.graal.python.cext/CMakeLists.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,11 @@ set(SRC_FILES ${CAPI_SRC}/codecs.c ${CAPI_SRC}/setobject.c ${CAPI_SRC}/compile.c
109109
${CAPI_SRC}/getcompiler.c ${CAPI_SRC}/pyhash.c ${CAPI_SRC}/fileutils.c
110110
${CAPI_SRC}/modsupport.c ${CAPI_SRC}/context.c ${CAPI_SRC}/abstract.c ${CAPI_SRC}/frameobject.c
111111
${CAPI_SRC}/posixmodule.c ${CAPI_SRC}/exceptions.c ${CAPI_SRC}/pyctype.c
112-
${CAPI_SRC}/mystrtoul.c ${CAPI_SRC}/weakrefobject.c
113-
${CAPI_SRC}/modsupport_shared.c ${CAPI_SRC}/fileobject.c ${CAPI_SRC}/pystrcmp.c ${CAPI_SRC}/getversion.c
112+
${CAPI_SRC}/mystrtoul.c ${CAPI_SRC}/weakrefobject.c ${CAPI_SRC}/gcmodule.c
113+
${CAPI_SRC}/fileobject.c ${CAPI_SRC}/pystrcmp.c ${CAPI_SRC}/getversion.c
114114
${CAPI_SRC}/genobject.c ${CAPI_SRC}/methodobject.c ${CAPI_SRC}/boolobject.c ${CAPI_SRC}/pylifecycle.c
115115
${CAPI_SRC}/errors.c ${CAPI_SRC}/signals.c ${CAPI_SRC}/datetime.c ${CAPI_SRC}/call.c
116+
${CAPI_SRC}/getargs.c
116117
)
117118

118119
file(GLOB_RECURSE ACTUAL_SRC_FILES
@@ -252,7 +253,7 @@ target_include_directories(${TARGET_LIBPYTHON} PRIVATE
252253
# target-specific compile and link options
253254
######################################################################
254255

255-
target_compile_definitions(${TARGET_LIBPYTHON} PRIVATE Py_BUILD_CORE)
256+
target_compile_definitions(${TARGET_LIBPYTHON} PRIVATE Py_BUILD_CORE Py_BUILD_CORE_BUILTIN)
256257
target_compile_options(${TARGET_LIBPYTHON} PRIVATE ${CFLAGS_WARNINGS})
257258

258259
if(WIN32)

graalpython/com.oracle.graal.python.cext/include/internal/pycore_call.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ extern "C" {
1313
# error "this header requires Py_BUILD_CORE define"
1414
#endif
1515

16-
#if 0 // GraalPy change
1716
#include "pycore_pystate.h" // _PyThreadState_GET()
18-
#endif // GraalPy change
1917

2018
PyAPI_FUNC(PyObject *) _PyObject_Call_Prepend(
2119
PyThreadState *tstate,
@@ -110,7 +108,7 @@ _PyObject_CallNoArgsTstate(PyThreadState *tstate, PyObject *func) {
110108
// Private static inline function variant of public PyObject_CallNoArgs()
111109
static inline PyObject *
112110
_PyObject_CallNoArgs(PyObject *func) {
113-
PyThreadState *tstate = NULL; // GraalPy change: don't get thread state
111+
PyThreadState *tstate = _PyThreadState_GET();
114112
return _PyObject_VectorcallTstate(tstate, func, NULL, 0, NULL);
115113
}
116114

graalpython/com.oracle.graal.python.cext/include/internal/pycore_ceval.h

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,17 @@ struct _ceval_runtime_state;
2828
# endif
2929
#endif
3030

31-
// #include "pycore_interp.h" // PyInterpreterState.eval_frame
32-
// #include "pycore_pystate.h" // _PyThreadState_GET()
31+
#if 0 // GraalPy change
32+
#include "pycore_interp.h" // PyInterpreterState.eval_frame
33+
#endif // GraalPy change
34+
#include "pycore_pystate.h" // _PyThreadState_GET()
3335

3436

37+
#if 0 // GraalPy change
3538
extern void _Py_FinishPendingCalls(PyThreadState *tstate);
3639
extern void _PyEval_InitRuntimeState(struct _ceval_runtime_state *);
37-
// extern void _PyEval_InitState(struct _ceval_state *, PyThread_type_lock);
38-
// extern void _PyEval_FiniState(struct _ceval_state *ceval);
40+
extern void _PyEval_InitState(struct _ceval_state *, PyThread_type_lock);
41+
extern void _PyEval_FiniState(struct _ceval_state *ceval);
3942
PyAPI_FUNC(void) _PyEval_SignalReceived(PyInterpreterState *interp);
4043
PyAPI_FUNC(int) _PyEval_AddPendingCall(
4144
PyInterpreterState *interp,
@@ -71,7 +74,6 @@ extern PyObject* _PyEval_BuiltinsFromGlobals(
7174
PyObject *globals);
7275

7376

74-
/* GraalVM change
7577
static inline PyObject*
7678
_PyEval_EvalFrame(PyThreadState *tstate, struct _PyInterpreterFrame *frame, int throwflag)
7779
{
@@ -80,7 +82,6 @@ _PyEval_EvalFrame(PyThreadState *tstate, struct _PyInterpreterFrame *frame, int
8082
}
8183
return tstate->interp->eval_frame(tstate, frame, throwflag);
8284
}
83-
*/
8485

8586
extern PyObject*
8687
_PyEval_Vector(PyThreadState *tstate,
@@ -95,6 +96,7 @@ extern void _PyEval_FiniGIL(PyInterpreterState *interp);
9596
extern void _PyEval_ReleaseLock(PyThreadState *tstate);
9697

9798
extern void _PyEval_DeactivateOpCache(void);
99+
#endif // GraalPy change
98100

99101

100102
/* --- _Py_EnterRecursiveCall() ----------------------------------------- */
@@ -122,10 +124,7 @@ static inline int _Py_EnterRecursiveCallTstate(PyThreadState *tstate,
122124
}
123125

124126
static inline int _Py_EnterRecursiveCall(const char *where) {
125-
/* GraalVM change
126127
PyThreadState *tstate = _PyThreadState_GET();
127-
*/
128-
PyThreadState *tstate = PyThreadState_GET();
129128
return _Py_EnterRecursiveCallTstate(tstate, where);
130129
}
131130

@@ -134,16 +133,15 @@ static inline void _Py_LeaveRecursiveCallTstate(PyThreadState *tstate) {
134133
}
135134

136135
static inline void _Py_LeaveRecursiveCall(void) {
137-
/* GraalVM change
138136
PyThreadState *tstate = _PyThreadState_GET();
139-
*/
140-
PyThreadState *tstate = PyThreadState_GET();
141137
_Py_LeaveRecursiveCallTstate(tstate);
142138
}
143139

140+
#if 0 // GraalPy change
144141
extern struct _PyInterpreterFrame* _PyEval_GetFrame(void);
145142

146143
extern PyObject* _Py_MakeCoro(PyFunctionObject *func);
144+
#endif // GraalPy change
147145

148146
#ifdef __cplusplus
149147
}

graalpython/com.oracle.graal.python.cext/include/internal/pycore_pystate.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ extern "C" {
1313
# error "this header requires Py_BUILD_CORE define"
1414
#endif
1515

16-
// #include "pycore_runtime.h" /* PyRuntimeState */
16+
#if 0 // GraalPy change
17+
#include "pycore_runtime.h" /* PyRuntimeState */
1718

1819

1920
/* Check if the current thread is the main thread.
@@ -80,6 +81,7 @@ _PyRuntimeState_GetThreadState(_PyRuntimeState *runtime)
8081
{
8182
return (PyThreadState*)_Py_atomic_load_relaxed(&runtime->gilstate.tstate_current);
8283
}
84+
#endif // GraalPy change
8385

8486
/* Get the current Python thread state.
8587
@@ -97,6 +99,7 @@ _PyThreadState_GET(void)
9799
return PyThreadState_Get();
98100
}
99101

102+
#if 0 // GraalPy change
100103
PyAPI_FUNC(void) _Py_NO_RETURN _Py_FatalError_TstateNULL(const char *func);
101104

102105
static inline void
@@ -172,6 +175,7 @@ PyAPI_FUNC(int) _PyState_AddModule(
172175

173176

174177
PyAPI_FUNC(int) _PyOS_InterruptOccurred(PyThreadState *tstate);
178+
#endif // GraalPy change
175179

176180
#ifdef __cplusplus
177181
}

0 commit comments

Comments
 (0)