summaryrefslogtreecommitdiffstats
path: root/Modules/_testinternalcapi.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/_testinternalcapi.c')
-rw-r--r--Modules/_testinternalcapi.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/Modules/_testinternalcapi.c b/Modules/_testinternalcapi.c
index 4ead1b6..1869f48 100644
--- a/Modules/_testinternalcapi.c
+++ b/Modules/_testinternalcapi.c
@@ -1556,6 +1556,36 @@ _testinternalcapi_test_long_numbits_impl(PyObject *module)
Py_RETURN_NONE;
}
+static PyObject *
+compile_perf_trampoline_entry(PyObject *self, PyObject *args)
+{
+ PyObject *co;
+ if (!PyArg_ParseTuple(args, "O!", &PyCode_Type, &co)) {
+ return NULL;
+ }
+ int ret = PyUnstable_PerfTrampoline_CompileCode((PyCodeObject *)co);
+ if (ret != 0) {
+ PyErr_SetString(PyExc_AssertionError, "Failed to compile trampoline");
+ return NULL;
+ }
+ return PyLong_FromLong(ret);
+}
+
+static PyObject *
+perf_trampoline_set_persist_after_fork(PyObject *self, PyObject *args)
+{
+ int enable;
+ if (!PyArg_ParseTuple(args, "i", &enable)) {
+ return NULL;
+ }
+ int ret = PyUnstable_PerfTrampoline_SetPersistAfterFork(enable);
+ if (ret == 0) {
+ PyErr_SetString(PyExc_AssertionError, "Failed to set persist_after_fork");
+ return NULL;
+ }
+ return PyLong_FromLong(ret);
+}
+
static PyMethodDef module_functions[] = {
{"get_configs", get_configs, METH_NOARGS},
@@ -1613,6 +1643,8 @@ static PyMethodDef module_functions[] = {
{"run_in_subinterp_with_config",
_PyCFunction_CAST(run_in_subinterp_with_config),
METH_VARARGS | METH_KEYWORDS},
+ {"compile_perf_trampoline_entry", compile_perf_trampoline_entry, METH_VARARGS},
+ {"perf_trampoline_set_persist_after_fork", perf_trampoline_set_persist_after_fork, METH_VARARGS},
_TESTINTERNALCAPI_WRITE_UNRAISABLE_EXC_METHODDEF
_TESTINTERNALCAPI_TEST_LONG_NUMBITS_METHODDEF
{NULL, NULL} /* sentinel */