Skip to content

Commit dda9e04

Browse files
committed
Add API in the sys module
1 parent b43f902 commit dda9e04

File tree

3 files changed

+80
-6
lines changed

3 files changed

+80
-6
lines changed

Objects/perf_trampoline.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
#include "Python.h"
2+
#include "pycore_ceval.h"
3+
#include "pycore_frame.h"
4+
#include "pycore_interp.h"
5+
6+
#ifdef HAVE_PERF_TRAMPOLINE
27

38
#include <stdio.h>
49
#include <stdlib.h>
510
#include <sys/mman.h>
611
#include <sys/types.h>
712
#include <unistd.h>
813

9-
#include "pycore_ceval.h"
10-
#include "pycore_frame.h"
11-
#include "pycore_interp.h"
12-
13-
#ifdef HAVE_PERF_TRAMPOLINE
1414
typedef PyObject *(*py_evaluator)(PyThreadState *, _PyInterpreterFrame *,
1515
int throwflag);
1616
typedef PyObject *(*py_trampoline)(py_evaluator, PyThreadState *,

Python/clinic/sysmodule.c.h

Lines changed: 37 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/sysmodule.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1994,6 +1994,42 @@ sys_getandroidapilevel_impl(PyObject *module)
19941994
}
19951995
#endif /* ANDROID_API_LEVEL */
19961996

1997+
/*[clinic input]
1998+
sys._activate_perf_trampoline
1999+
2000+
Activate the perf profiler trampoline.
2001+
[clinic start generated code]*/
2002+
2003+
static PyObject *
2004+
sys__activate_perf_trampoline_impl(PyObject *module)
2005+
/*[clinic end generated code: output=248f6dc862887fd0 input=67667f43ffabb1e4]*/
2006+
{
2007+
if (_PyPerfTrampoline_Init(1) < 0) {
2008+
return NULL;
2009+
}
2010+
Py_RETURN_NONE;
2011+
}
2012+
2013+
2014+
/*[clinic input]
2015+
sys._deactivate_perf_trampoline
2016+
2017+
Activate the perf profiler trampoline.
2018+
[clinic start generated code]*/
2019+
2020+
static PyObject *
2021+
sys__deactivate_perf_trampoline_impl(PyObject *module)
2022+
/*[clinic end generated code: output=7dde745eb7ba5e54 input=3d4fbb4aef9ad3d8]*/
2023+
{
2024+
if (_PyPerfTrampoline_Init(0) < 0) {
2025+
return NULL;
2026+
}
2027+
Py_RETURN_NONE;
2028+
}
2029+
2030+
2031+
2032+
19972033
static PyMethodDef sys_methods[] = {
19982034
/* Might as well keep this in alphabetic order */
19992035
SYS_ADDAUDITHOOK_METHODDEF
@@ -2047,6 +2083,8 @@ static PyMethodDef sys_methods[] = {
20472083
METH_VARARGS | METH_KEYWORDS, set_asyncgen_hooks_doc},
20482084
SYS_GET_ASYNCGEN_HOOKS_METHODDEF
20492085
SYS_GETANDROIDAPILEVEL_METHODDEF
2086+
SYS__ACTIVATE_PERF_TRAMPOLINE_METHODDEF
2087+
SYS__DEACTIVATE_PERF_TRAMPOLINE_METHODDEF
20502088
SYS_UNRAISABLEHOOK_METHODDEF
20512089
#ifdef Py_STATS
20522090
SYS__STATS_ON_METHODDEF

0 commit comments

Comments
 (0)