aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/scripts/python
diff options
context:
space:
mode:
authorMaarten Lankhorst <maarten.lankhorst@linux.intel.com>2018-05-11 12:08:10 -0400
committerMaarten Lankhorst <maarten.lankhorst@linux.intel.com>2018-05-11 12:08:10 -0400
commit94cc2fde365fb4484080ea6675bb1e0c933f8002 (patch)
treea249c6f6b12ff2dbe39d78bfb050e9c28619bee9 /tools/perf/scripts/python
parent900aa8ad21587e909603f471b6cd81fd5338ec45 (diff)
parent8eb008c80841e3410ef2c043093478ea36bb5ff1 (diff)
Merge remote-tracking branch 'drm/drm-next' into drm-misc-next
drm-misc-next is still based on v4.16-rc7, and was getting a bit stale. Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Diffstat (limited to 'tools/perf/scripts/python')
-rw-r--r--tools/perf/scripts/python/Perf-Trace-Util/Context.c34
1 files changed, 31 insertions, 3 deletions
diff --git a/tools/perf/scripts/python/Perf-Trace-Util/Context.c b/tools/perf/scripts/python/Perf-Trace-Util/Context.c
index fcd1dd667906..1a0d27757eec 100644
--- a/tools/perf/scripts/python/Perf-Trace-Util/Context.c
+++ b/tools/perf/scripts/python/Perf-Trace-Util/Context.c
@@ -23,7 +23,17 @@
23#include "../../../perf.h" 23#include "../../../perf.h"
24#include "../../../util/trace-event.h" 24#include "../../../util/trace-event.h"
25 25
26#if PY_MAJOR_VERSION < 3
27#define _PyCapsule_GetPointer(arg1, arg2) \
28 PyCObject_AsVoidPtr(arg1)
29
26PyMODINIT_FUNC initperf_trace_context(void); 30PyMODINIT_FUNC initperf_trace_context(void);
31#else
32#define _PyCapsule_GetPointer(arg1, arg2) \
33 PyCapsule_GetPointer((arg1), (arg2))
34
35PyMODINIT_FUNC PyInit_perf_trace_context(void);
36#endif
27 37
28static PyObject *perf_trace_context_common_pc(PyObject *obj, PyObject *args) 38static PyObject *perf_trace_context_common_pc(PyObject *obj, PyObject *args)
29{ 39{
@@ -34,7 +44,7 @@ static PyObject *perf_trace_context_common_pc(PyObject *obj, PyObject *args)
34 if (!PyArg_ParseTuple(args, "O", &context)) 44 if (!PyArg_ParseTuple(args, "O", &context))
35 return NULL; 45 return NULL;
36 46
37 scripting_context = PyCObject_AsVoidPtr(context); 47 scripting_context = _PyCapsule_GetPointer(context, NULL);
38 retval = common_pc(scripting_context); 48 retval = common_pc(scripting_context);
39 49
40 return Py_BuildValue("i", retval); 50 return Py_BuildValue("i", retval);
@@ -50,7 +60,7 @@ static PyObject *perf_trace_context_common_flags(PyObject *obj,
50 if (!PyArg_ParseTuple(args, "O", &context)) 60 if (!PyArg_ParseTuple(args, "O", &context))
51 return NULL; 61 return NULL;
52 62
53 scripting_context = PyCObject_AsVoidPtr(context); 63 scripting_context = _PyCapsule_GetPointer(context, NULL);
54 retval = common_flags(scripting_context); 64 retval = common_flags(scripting_context);
55 65
56 return Py_BuildValue("i", retval); 66 return Py_BuildValue("i", retval);
@@ -66,7 +76,7 @@ static PyObject *perf_trace_context_common_lock_depth(PyObject *obj,
66 if (!PyArg_ParseTuple(args, "O", &context)) 76 if (!PyArg_ParseTuple(args, "O", &context))
67 return NULL; 77 return NULL;
68 78
69 scripting_context = PyCObject_AsVoidPtr(context); 79 scripting_context = _PyCapsule_GetPointer(context, NULL);
70 retval = common_lock_depth(scripting_context); 80 retval = common_lock_depth(scripting_context);
71 81
72 return Py_BuildValue("i", retval); 82 return Py_BuildValue("i", retval);
@@ -82,7 +92,25 @@ static PyMethodDef ContextMethods[] = {
82 { NULL, NULL, 0, NULL} 92 { NULL, NULL, 0, NULL}
83}; 93};
84 94
95#if PY_MAJOR_VERSION < 3
85PyMODINIT_FUNC initperf_trace_context(void) 96PyMODINIT_FUNC initperf_trace_context(void)
86{ 97{
87 (void) Py_InitModule("perf_trace_context", ContextMethods); 98 (void) Py_InitModule("perf_trace_context", ContextMethods);
88} 99}
100#else
101PyMODINIT_FUNC PyInit_perf_trace_context(void)
102{
103 static struct PyModuleDef moduledef = {
104 PyModuleDef_HEAD_INIT,
105 "perf_trace_context", /* m_name */
106 "", /* m_doc */
107 -1, /* m_size */
108 ContextMethods, /* m_methods */
109 NULL, /* m_reload */
110 NULL, /* m_traverse */
111 NULL, /* m_clear */
112 NULL, /* m_free */
113 };
114 return PyModule_Create(&moduledef);
115}
116#endif