perf python: Fix build on 32-bit

Where there are lots of errors related to python methods receiving
'char *' for things like file open mode, which break the build, also
disable strict aliasing and fixup some other warnings. Now builds on
both 32-bit and 64-bit fedora systems.

Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <new-submission>
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 823c7164
...@@ -15,6 +15,8 @@ struct throttle_event { ...@@ -15,6 +15,8 @@ struct throttle_event {
u64 stream_id; u64 stream_id;
}; };
PyMODINIT_FUNC initperf(void);
#define member_def(type, member, ptype, help) \ #define member_def(type, member, ptype, help) \
{ #member, ptype, \ { #member, ptype, \
offsetof(struct pyrf_event, event) + offsetof(struct type, member), \ offsetof(struct pyrf_event, event) + offsetof(struct type, member), \
...@@ -31,17 +33,15 @@ struct pyrf_event { ...@@ -31,17 +33,15 @@ struct pyrf_event {
union perf_event event; union perf_event event;
}; };
#define T_ULONG_LONG T_ULONG
#define sample_members \ #define sample_members \
sample_member_def(sample_ip, ip, T_ULONG_LONG, "event type"), \ sample_member_def(sample_ip, ip, T_ULONGLONG, "event type"), \
sample_member_def(sample_pid, pid, T_INT, "event pid"), \ sample_member_def(sample_pid, pid, T_INT, "event pid"), \
sample_member_def(sample_tid, tid, T_INT, "event tid"), \ sample_member_def(sample_tid, tid, T_INT, "event tid"), \
sample_member_def(sample_time, time, T_ULONG_LONG, "event timestamp"), \ sample_member_def(sample_time, time, T_ULONGLONG, "event timestamp"), \
sample_member_def(sample_addr, addr, T_ULONG_LONG, "event addr"), \ sample_member_def(sample_addr, addr, T_ULONGLONG, "event addr"), \
sample_member_def(sample_id, id, T_ULONG_LONG, "event id"), \ sample_member_def(sample_id, id, T_ULONGLONG, "event id"), \
sample_member_def(sample_stream_id, stream_id, T_ULONG_LONG, "event stream id"), \ sample_member_def(sample_stream_id, stream_id, T_ULONGLONG, "event stream id"), \
sample_member_def(sample_period, period, T_ULONG_LONG, "event period"), \ sample_member_def(sample_period, period, T_ULONGLONG, "event period"), \
sample_member_def(sample_cpu, cpu, T_UINT, "event cpu"), sample_member_def(sample_cpu, cpu, T_UINT, "event cpu"),
static char pyrf_mmap_event__doc[] = PyDoc_STR("perf mmap event object."); static char pyrf_mmap_event__doc[] = PyDoc_STR("perf mmap event object.");
...@@ -51,11 +51,11 @@ static PyMemberDef pyrf_mmap_event__members[] = { ...@@ -51,11 +51,11 @@ static PyMemberDef pyrf_mmap_event__members[] = {
member_def(perf_event_header, type, T_UINT, "event type"), member_def(perf_event_header, type, T_UINT, "event type"),
member_def(mmap_event, pid, T_UINT, "event pid"), member_def(mmap_event, pid, T_UINT, "event pid"),
member_def(mmap_event, tid, T_UINT, "event tid"), member_def(mmap_event, tid, T_UINT, "event tid"),
member_def(mmap_event, start, T_ULONG_LONG, "start of the map"), member_def(mmap_event, start, T_ULONGLONG, "start of the map"),
member_def(mmap_event, len, T_ULONG_LONG, "map length"), member_def(mmap_event, len, T_ULONGLONG, "map length"),
member_def(mmap_event, pgoff, T_ULONG_LONG, "page offset"), member_def(mmap_event, pgoff, T_ULONGLONG, "page offset"),
member_def(mmap_event, filename, T_STRING_INPLACE, "backing store"), member_def(mmap_event, filename, T_STRING_INPLACE, "backing store"),
{ NULL, }, { .name = NULL, },
}; };
static PyObject *pyrf_mmap_event__repr(struct pyrf_event *pevent) static PyObject *pyrf_mmap_event__repr(struct pyrf_event *pevent)
...@@ -96,8 +96,8 @@ static PyMemberDef pyrf_task_event__members[] = { ...@@ -96,8 +96,8 @@ static PyMemberDef pyrf_task_event__members[] = {
member_def(fork_event, ppid, T_UINT, "event ppid"), member_def(fork_event, ppid, T_UINT, "event ppid"),
member_def(fork_event, tid, T_UINT, "event tid"), member_def(fork_event, tid, T_UINT, "event tid"),
member_def(fork_event, ptid, T_UINT, "event ptid"), member_def(fork_event, ptid, T_UINT, "event ptid"),
member_def(fork_event, time, T_ULONG_LONG, "timestamp"), member_def(fork_event, time, T_ULONGLONG, "timestamp"),
{ NULL, }, { .name = NULL, },
}; };
static PyObject *pyrf_task_event__repr(struct pyrf_event *pevent) static PyObject *pyrf_task_event__repr(struct pyrf_event *pevent)
...@@ -130,7 +130,7 @@ static PyMemberDef pyrf_comm_event__members[] = { ...@@ -130,7 +130,7 @@ static PyMemberDef pyrf_comm_event__members[] = {
member_def(comm_event, pid, T_UINT, "event pid"), member_def(comm_event, pid, T_UINT, "event pid"),
member_def(comm_event, tid, T_UINT, "event tid"), member_def(comm_event, tid, T_UINT, "event tid"),
member_def(comm_event, comm, T_STRING_INPLACE, "process name"), member_def(comm_event, comm, T_STRING_INPLACE, "process name"),
{ NULL, }, { .name = NULL, },
}; };
static PyObject *pyrf_comm_event__repr(struct pyrf_event *pevent) static PyObject *pyrf_comm_event__repr(struct pyrf_event *pevent)
...@@ -156,10 +156,10 @@ static char pyrf_throttle_event__doc[] = PyDoc_STR("perf throttle event object." ...@@ -156,10 +156,10 @@ static char pyrf_throttle_event__doc[] = PyDoc_STR("perf throttle event object."
static PyMemberDef pyrf_throttle_event__members[] = { static PyMemberDef pyrf_throttle_event__members[] = {
sample_members sample_members
member_def(perf_event_header, type, T_UINT, "event type"), member_def(perf_event_header, type, T_UINT, "event type"),
member_def(throttle_event, time, T_ULONG_LONG, "timestamp"), member_def(throttle_event, time, T_ULONGLONG, "timestamp"),
member_def(throttle_event, id, T_ULONG_LONG, "event id"), member_def(throttle_event, id, T_ULONGLONG, "event id"),
member_def(throttle_event, stream_id, T_ULONG_LONG, "event stream id"), member_def(throttle_event, stream_id, T_ULONGLONG, "event stream id"),
{ NULL, }, { .name = NULL, },
}; };
static PyObject *pyrf_throttle_event__repr(struct pyrf_event *pevent) static PyObject *pyrf_throttle_event__repr(struct pyrf_event *pevent)
...@@ -522,7 +522,7 @@ static PyMethodDef pyrf_evsel__methods[] = { ...@@ -522,7 +522,7 @@ static PyMethodDef pyrf_evsel__methods[] = {
.ml_flags = METH_VARARGS | METH_KEYWORDS, .ml_flags = METH_VARARGS | METH_KEYWORDS,
.ml_doc = PyDoc_STR("open the event selector file descriptor table.") .ml_doc = PyDoc_STR("open the event selector file descriptor table.")
}, },
{ NULL, } { .ml_name = NULL, }
}; };
static char pyrf_evsel__doc[] = PyDoc_STR("perf event selector list object."); static char pyrf_evsel__doc[] = PyDoc_STR("perf event selector list object.");
...@@ -551,7 +551,7 @@ struct pyrf_evlist { ...@@ -551,7 +551,7 @@ struct pyrf_evlist {
}; };
static int pyrf_evlist__init(struct pyrf_evlist *pevlist, static int pyrf_evlist__init(struct pyrf_evlist *pevlist,
PyObject *args, PyObject *kwargs) PyObject *args, PyObject *kwargs __used)
{ {
PyObject *pcpus = NULL, *pthreads = NULL; PyObject *pcpus = NULL, *pthreads = NULL;
struct cpu_map *cpus; struct cpu_map *cpus;
...@@ -613,7 +613,7 @@ static PyObject *pyrf_evlist__poll(struct pyrf_evlist *pevlist, ...@@ -613,7 +613,7 @@ static PyObject *pyrf_evlist__poll(struct pyrf_evlist *pevlist,
} }
static PyObject *pyrf_evlist__get_pollfd(struct pyrf_evlist *pevlist, static PyObject *pyrf_evlist__get_pollfd(struct pyrf_evlist *pevlist,
PyObject *args, PyObject *kwargs) PyObject *args __used, PyObject *kwargs __used)
{ {
struct perf_evlist *evlist = &pevlist->evlist; struct perf_evlist *evlist = &pevlist->evlist;
PyObject *list = PyList_New(0); PyObject *list = PyList_New(0);
...@@ -645,7 +645,7 @@ static PyObject *pyrf_evlist__get_pollfd(struct pyrf_evlist *pevlist, ...@@ -645,7 +645,7 @@ static PyObject *pyrf_evlist__get_pollfd(struct pyrf_evlist *pevlist,
static PyObject *pyrf_evlist__add(struct pyrf_evlist *pevlist, static PyObject *pyrf_evlist__add(struct pyrf_evlist *pevlist,
PyObject *args, PyObject *kwargs) PyObject *args, PyObject *kwargs __used)
{ {
struct perf_evlist *evlist = &pevlist->evlist; struct perf_evlist *evlist = &pevlist->evlist;
PyObject *pevsel; PyObject *pevsel;
...@@ -724,7 +724,7 @@ static PyMethodDef pyrf_evlist__methods[] = { ...@@ -724,7 +724,7 @@ static PyMethodDef pyrf_evlist__methods[] = {
.ml_flags = METH_VARARGS | METH_KEYWORDS, .ml_flags = METH_VARARGS | METH_KEYWORDS,
.ml_doc = PyDoc_STR("reads an event.") .ml_doc = PyDoc_STR("reads an event.")
}, },
{ NULL, } { .ml_name = NULL, }
}; };
static Py_ssize_t pyrf_evlist__length(PyObject *obj) static Py_ssize_t pyrf_evlist__length(PyObject *obj)
...@@ -840,11 +840,11 @@ static struct { ...@@ -840,11 +840,11 @@ static struct {
{ "RECORD_FORK", PERF_RECORD_FORK }, { "RECORD_FORK", PERF_RECORD_FORK },
{ "RECORD_READ", PERF_RECORD_READ }, { "RECORD_READ", PERF_RECORD_READ },
{ "RECORD_SAMPLE", PERF_RECORD_SAMPLE }, { "RECORD_SAMPLE", PERF_RECORD_SAMPLE },
{ NULL, }, { .name = NULL, },
}; };
static PyMethodDef perf__methods[] = { static PyMethodDef perf__methods[] = {
{ NULL, NULL } { .ml_name = NULL, }
}; };
PyMODINIT_FUNC initperf(void) PyMODINIT_FUNC initperf(void)
......
...@@ -6,7 +6,8 @@ perf = Extension('perf', ...@@ -6,7 +6,8 @@ perf = Extension('perf',
sources = ['util/python.c', 'util/ctype.c', 'util/evlist.c', sources = ['util/python.c', 'util/ctype.c', 'util/evlist.c',
'util/evsel.c', 'util/cpumap.c', 'util/thread_map.c', 'util/evsel.c', 'util/cpumap.c', 'util/thread_map.c',
'util/util.c', 'util/xyarray.c'], 'util/util.c', 'util/xyarray.c'],
include_dirs = ['util/include']) include_dirs = ['util/include'],
extra_compile_args = ['-fno-strict-aliasing', '-Wno-write-strings'])
setup(name='perf', setup(name='perf',
version='0.1', version='0.1',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment