device/linux-asus-z00vd: add python3 support (!707)

Signed-off-by: Danct12 <danct12@disroot.org>

[ci:skip-build]: already built successfully in CI
This commit is contained in:
Danct12 2019-10-31 09:52:19 +07:00 committed by Oliver Smith
parent 094982dd5f
commit ed2a658bd3
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
3 changed files with 1475 additions and 3 deletions

View file

@ -0,0 +1,616 @@
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 262916f4..ef05d9d4 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -155,7 +155,7 @@ PYTHON_EXTBUILD_LIB := $(PYTHON_EXTBUILD)lib/
PYTHON_EXTBUILD_TMP := $(PYTHON_EXTBUILD)tmp/
export PYTHON_EXTBUILD_LIB PYTHON_EXTBUILD_TMP
-python-clean := $(call QUIET_CLEAN, python) $(RM) -r $(PYTHON_EXTBUILD) $(OUTPUT)python/perf.so
+python-clean := $(call QUIET_CLEAN, python) $(RM) -r $(PYTHON_EXTBUILD) $(OUTPUT)python/perf*.so
PYTHON_EXT_SRCS := $(shell grep -v ^\# util/python-ext-sources)
PYTHON_EXT_DEPS := util/python-ext-sources util/setup.py $(LIBTRACEEVENT) $(LIBAPIKFS)
@@ -164,7 +164,7 @@ $(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS)
$(QUIET_GEN)CFLAGS='$(CFLAGS)' $(PYTHON_WORD) util/setup.py \
--quiet build_ext; \
mkdir -p $(OUTPUT)python && \
- cp $(PYTHON_EXTBUILD_LIB)perf.so $(OUTPUT)python/
+ cp $(PYTHON_EXTBUILD_LIB)perf*.so $(OUTPUT)python/
#
# No Perl scripts right now:
#
diff --git a/tools/perf/scripts/python/Perf-Trace-Util/Context.c b/tools/perf/scripts/python/Perf-Trace-Util/Context.c
index fcd1dd66..1a0d2775 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 @@
#include "../../../perf.h"
#include "../../../util/trace-event.h"
+#if PY_MAJOR_VERSION < 3
+#define _PyCapsule_GetPointer(arg1, arg2) \
+ PyCObject_AsVoidPtr(arg1)
+
PyMODINIT_FUNC initperf_trace_context(void);
+#else
+#define _PyCapsule_GetPointer(arg1, arg2) \
+ PyCapsule_GetPointer((arg1), (arg2))
+
+PyMODINIT_FUNC PyInit_perf_trace_context(void);
+#endif
static PyObject *perf_trace_context_common_pc(PyObject *obj, PyObject *args)
{
@@ -34,7 +44,7 @@ static PyObject *perf_trace_context_common_pc(PyObject *obj, PyObject *args)
if (!PyArg_ParseTuple(args, "O", &context))
return NULL;
- scripting_context = PyCObject_AsVoidPtr(context);
+ scripting_context = _PyCapsule_GetPointer(context, NULL);
retval = common_pc(scripting_context);
return Py_BuildValue("i", retval);
@@ -50,7 +60,7 @@ static PyObject *perf_trace_context_common_flags(PyObject *obj,
if (!PyArg_ParseTuple(args, "O", &context))
return NULL;
- scripting_context = PyCObject_AsVoidPtr(context);
+ scripting_context = _PyCapsule_GetPointer(context, NULL);
retval = common_flags(scripting_context);
return Py_BuildValue("i", retval);
@@ -66,7 +76,7 @@ static PyObject *perf_trace_context_common_lock_depth(PyObject *obj,
if (!PyArg_ParseTuple(args, "O", &context))
return NULL;
- scripting_context = PyCObject_AsVoidPtr(context);
+ scripting_context = _PyCapsule_GetPointer(context, NULL);
retval = common_lock_depth(scripting_context);
return Py_BuildValue("i", retval);
@@ -82,7 +92,25 @@ static PyMethodDef ContextMethods[] = {
{ NULL, NULL, 0, NULL}
};
+#if PY_MAJOR_VERSION < 3
PyMODINIT_FUNC initperf_trace_context(void)
{
(void) Py_InitModule("perf_trace_context", ContextMethods);
}
+#else
+PyMODINIT_FUNC PyInit_perf_trace_context(void)
+{
+ static struct PyModuleDef moduledef = {
+ PyModuleDef_HEAD_INIT,
+ "perf_trace_context", /* m_name */
+ "", /* m_doc */
+ -1, /* m_size */
+ ContextMethods, /* m_methods */
+ NULL, /* m_reload */
+ NULL, /* m_traverse */
+ NULL, /* m_clear */
+ NULL, /* m_free */
+ };
+ return PyModule_Create(&moduledef);
+}
+#endif
diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
index 3dda85ca..7e34376c 100644
--- a/tools/perf/util/python.c
+++ b/tools/perf/util/python.c
@@ -8,6 +8,30 @@
#include "cpumap.h"
#include "thread_map.h"
+#if PY_MAJOR_VERSION < 3
+#define _PyUnicode_FromString(arg) \
+ PyString_FromString(arg)
+#define _PyUnicode_AsString(arg) \
+ PyString_AsString(arg)
+#define _PyUnicode_FromFormat(...) \
+ PyString_FromFormat(__VA_ARGS__)
+#define _PyLong_FromLong(arg) \
+ PyInt_FromLong(arg)
+
+#else
+
+#define _PyUnicode_FromString(arg) \
+ PyUnicode_FromString(arg)
+#define _PyUnicode_FromFormat(...) \
+ PyUnicode_FromFormat(__VA_ARGS__)
+#define _PyLong_FromLong(arg) \
+ PyLong_FromLong(arg)
+#endif
+
+#ifndef Py_TYPE
+#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
+#endif
+
/*
* Support debug printing even though util/debug.c is not linked. That means
* implementing 'verbose' and 'eprintf'.
@@ -33,7 +57,11 @@ int eprintf(int level, int var, const char *fmt, ...)
# define PyVarObject_HEAD_INIT(type, size) PyObject_HEAD_INIT(type) size,
#endif
+#if PY_MAJOR_VERSION < 3
PyMODINIT_FUNC initperf(void);
+#else
+PyMODINIT_FUNC PyInit_perf(void);
+#endif
#define member_def(type, member, ptype, help) \
{ #member, ptype, \
@@ -89,7 +117,7 @@ static PyObject *pyrf_mmap_event__repr(struct pyrf_event *pevent)
pevent->event.mmap.pgoff, pevent->event.mmap.filename) < 0) {
ret = PyErr_NoMemory();
} else {
- ret = PyString_FromString(s);
+ ret = _PyUnicode_FromString(s);
free(s);
}
return ret;
@@ -120,7 +148,7 @@ static PyMemberDef pyrf_task_event__members[] = {
static PyObject *pyrf_task_event__repr(struct pyrf_event *pevent)
{
- return PyString_FromFormat("{ type: %s, pid: %u, ppid: %u, tid: %u, "
+ return _PyUnicode_FromFormat("{ type: %s, pid: %u, ppid: %u, tid: %u, "
"ptid: %u, time: %" PRIu64 "}",
pevent->event.header.type == PERF_RECORD_FORK ? "fork" : "exit",
pevent->event.fork.pid,
@@ -153,7 +181,7 @@ static PyMemberDef pyrf_comm_event__members[] = {
static PyObject *pyrf_comm_event__repr(struct pyrf_event *pevent)
{
- return PyString_FromFormat("{ type: comm, pid: %u, tid: %u, comm: %s }",
+ return _PyUnicode_FromFormat("{ type: comm, pid: %u, tid: %u, comm: %s }",
pevent->event.comm.pid,
pevent->event.comm.tid,
pevent->event.comm.comm);
@@ -184,7 +212,7 @@ static PyObject *pyrf_throttle_event__repr(struct pyrf_event *pevent)
{
struct throttle_event *te = (struct throttle_event *)(&pevent->event.header + 1);
- return PyString_FromFormat("{ type: %sthrottle, time: %" PRIu64 ", id: %" PRIu64
+ return _PyUnicode_FromFormat("{ type: %sthrottle, time: %" PRIu64 ", id: %" PRIu64
", stream_id: %" PRIu64 " }",
pevent->event.header.type == PERF_RECORD_THROTTLE ? "" : "un",
te->time, te->id, te->stream_id);
@@ -219,7 +247,7 @@ static PyObject *pyrf_lost_event__repr(struct pyrf_event *pevent)
pevent->event.lost.id, pevent->event.lost.lost) < 0) {
ret = PyErr_NoMemory();
} else {
- ret = PyString_FromString(s);
+ ret = _PyUnicode_FromString(s);
free(s);
}
return ret;
@@ -246,7 +274,7 @@ static PyMemberDef pyrf_read_event__members[] = {
static PyObject *pyrf_read_event__repr(struct pyrf_event *pevent)
{
- return PyString_FromFormat("{ type: read, pid: %u, tid: %u }",
+ return _PyUnicode_FromFormat("{ type: read, pid: %u, tid: %u }",
pevent->event.read.pid,
pevent->event.read.tid);
/*
@@ -281,7 +309,7 @@ static PyObject *pyrf_sample_event__repr(struct pyrf_event *pevent)
if (asprintf(&s, "{ type: sample }") < 0) {
ret = PyErr_NoMemory();
} else {
- ret = PyString_FromString(s);
+ ret = _PyUnicode_FromString(s);
free(s);
}
return ret;
@@ -385,7 +413,7 @@ static int pyrf_cpu_map__init(struct pyrf_cpu_map *pcpus,
static void pyrf_cpu_map__delete(struct pyrf_cpu_map *pcpus)
{
cpu_map__delete(pcpus->cpus);
- pcpus->ob_type->tp_free((PyObject*)pcpus);
+ Py_TYPE(pcpus)->tp_free((PyObject*)pcpus);
}
static Py_ssize_t pyrf_cpu_map__length(PyObject *obj)
@@ -454,7 +482,7 @@ static int pyrf_thread_map__init(struct pyrf_thread_map *pthreads,
static void pyrf_thread_map__delete(struct pyrf_thread_map *pthreads)
{
thread_map__delete(pthreads->threads);
- pthreads->ob_type->tp_free((PyObject*)pthreads);
+ Py_TYPE(pthreads)->tp_free((PyObject*)pthreads);
}
static Py_ssize_t pyrf_thread_map__length(PyObject *obj)
@@ -612,7 +640,7 @@ static int pyrf_evsel__init(struct pyrf_evsel *pevsel,
static void pyrf_evsel__delete(struct pyrf_evsel *pevsel)
{
perf_evsel__exit(&pevsel->evsel);
- pevsel->ob_type->tp_free((PyObject*)pevsel);
+ Py_TYPE(pevsel)->tp_free((PyObject*)pevsel);
}
static PyObject *pyrf_evsel__open(struct pyrf_evsel *pevsel,
@@ -703,7 +731,7 @@ static int pyrf_evlist__init(struct pyrf_evlist *pevlist,
static void pyrf_evlist__delete(struct pyrf_evlist *pevlist)
{
perf_evlist__exit(&pevlist->evlist);
- pevlist->ob_type->tp_free((PyObject*)pevlist);
+ Py_TYPE(pevlist)->tp_free((PyObject*)pevlist);
}
static PyObject *pyrf_evlist__mmap(struct pyrf_evlist *pevlist,
@@ -755,12 +783,16 @@ static PyObject *pyrf_evlist__get_pollfd(struct pyrf_evlist *pevlist,
for (i = 0; i < evlist->pollfd.nr; ++i) {
PyObject *file;
+#if PY_MAJOR_VERSION < 3
FILE *fp = fdopen(evlist->pollfd.entries[i].fd, "r");
if (fp == NULL)
goto free_list;
file = PyFile_FromFile(fp, "perf", "r", NULL);
+#else
+ file = PyFile_FromFd(evlist->pollfd.entries[i].fd, "perf", "r", -1, NULL, NULL, NULL, 1);
+#endif
if (file == NULL)
goto free_list;
@@ -1018,11 +1050,31 @@ static PyMethodDef perf__methods[] = {
{ .ml_name = NULL, }
};
+#if PY_MAJOR_VERSION < 3
PyMODINIT_FUNC initperf(void)
+#else
+PyMODINIT_FUNC PyInit_perf(void)
+#endif
{
PyObject *obj;
int i;
- PyObject *dict, *module = Py_InitModule("perf", perf__methods);
+ PyObject *dict;
+#if PY_MAJOR_VERSION < 3
+ PyObject *module = Py_InitModule("perf", perf__methods);
+#else
+ static struct PyModuleDef moduledef = {
+ PyModuleDef_HEAD_INIT,
+ "perf", /* m_name */
+ "", /* m_doc */
+ -1, /* m_size */
+ perf__methods, /* m_methods */
+ NULL, /* m_reload */
+ NULL, /* m_traverse */
+ NULL, /* m_clear */
+ NULL, /* m_free */
+ };
+ PyObject *module = PyModule_Create(&moduledef);
+#endif
if (module == NULL ||
pyrf_event__setup_types() < 0 ||
@@ -1030,7 +1082,11 @@ PyMODINIT_FUNC initperf(void)
pyrf_evsel__setup_types() < 0 ||
pyrf_thread_map__setup_types() < 0 ||
pyrf_cpu_map__setup_types() < 0)
+#if PY_MAJOR_VERSION < 3
return;
+#else
+ return module;
+#endif
/* The page_size is placed in util object. */
page_size = sysconf(_SC_PAGE_SIZE);
@@ -1052,7 +1108,7 @@ PyMODINIT_FUNC initperf(void)
goto error;
for (i = 0; perf__constants[i].name != NULL; i++) {
- obj = PyInt_FromLong(perf__constants[i].value);
+ obj = _PyLong_FromLong(perf__constants[i].value);
if (obj == NULL)
goto error;
PyDict_SetItemString(dict, perf__constants[i].name, obj);
@@ -1062,6 +1118,9 @@ PyMODINIT_FUNC initperf(void)
error:
if (PyErr_Occurred())
PyErr_SetString(PyExc_ImportError, "perf: Init failed!");
+#if PY_MAJOR_VERSION >= 3
+ return module;
+#endif
}
/*
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
index 496f21ca..1f4657d3 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -36,7 +36,37 @@
#include "../trace-event.h"
#include "../machine.h"
+#if PY_MAJOR_VERSION < 3
+#define _PyUnicode_FromString(arg) \
+ PyString_FromString(arg)
+#define _PyUnicode_FromStringAndSize(arg1, arg2) \
+ PyString_FromStringAndSize((arg1), (arg2))
+#define _PyBytes_FromStringAndSize(arg1, arg2) \
+ PyString_FromStringAndSize((arg1), (arg2))
+#define _PyLong_FromLong(arg) \
+ PyInt_FromLong(arg)
+#define _PyLong_AsLong(arg) \
+ PyInt_AsLong(arg)
+#define _PyCapsule_New(arg1, arg2, arg3) \
+ PyCObject_FromVoidPtr((arg1), (arg2))
+
PyMODINIT_FUNC initperf_trace_context(void);
+#else
+#define _PyUnicode_FromString(arg) \
+ PyUnicode_FromString(arg)
+#define _PyUnicode_FromStringAndSize(arg1, arg2) \
+ PyUnicode_FromStringAndSize((arg1), (arg2))
+#define _PyBytes_FromStringAndSize(arg1, arg2) \
+ PyBytes_FromStringAndSize((arg1), (arg2))
+#define _PyLong_FromLong(arg) \
+ PyLong_FromLong(arg)
+#define _PyLong_AsLong(arg) \
+ PyLong_AsLong(arg)
+#define _PyCapsule_New(arg1, arg2, arg3) \
+ PyCapsule_New((arg1), (arg2), (arg3))
+
+PyMODINIT_FUNC PyInit_perf_trace_context(void);
+#endif
#define FTRACE_MAX_EVENT \
((1 << (sizeof(unsigned short) * 8)) - 1)
@@ -123,10 +153,10 @@ static void define_value(enum print_arg_type field_type,
value = eval_flag(field_value);
- PyTuple_SetItem(t, n++, PyString_FromString(ev_name));
- PyTuple_SetItem(t, n++, PyString_FromString(field_name));
- PyTuple_SetItem(t, n++, PyInt_FromLong(value));
- PyTuple_SetItem(t, n++, PyString_FromString(field_str));
+ PyTuple_SetItem(t, n++, _PyUnicode_FromString(ev_name));
+ PyTuple_SetItem(t, n++, _PyUnicode_FromString(field_name));
+ PyTuple_SetItem(t, n++, _PyLong_FromLong(value));
+ PyTuple_SetItem(t, n++, _PyUnicode_FromString(field_str));
try_call_object(handler_name, t);
@@ -164,10 +194,10 @@ static void define_field(enum print_arg_type field_type,
if (!t)
Py_FatalError("couldn't create Python tuple");
- PyTuple_SetItem(t, n++, PyString_FromString(ev_name));
- PyTuple_SetItem(t, n++, PyString_FromString(field_name));
+ PyTuple_SetItem(t, n++, _PyUnicode_FromString(ev_name));
+ PyTuple_SetItem(t, n++, _PyUnicode_FromString(field_name));
if (field_type == PRINT_FLAGS)
- PyTuple_SetItem(t, n++, PyString_FromString(delim));
+ PyTuple_SetItem(t, n++, _PyUnicode_FromString(delim));
try_call_object(handler_name, t);
@@ -281,12 +311,12 @@ static PyObject *get_field_numeric_entry(struct event_format *event,
if (field->flags & FIELD_IS_SIGNED) {
if ((long long)val >= LONG_MIN &&
(long long)val <= LONG_MAX)
- obj = PyInt_FromLong(val);
+ obj = _PyLong_FromLong(val);
else
obj = PyLong_FromLongLong(val);
} else {
if (val <= LONG_MAX)
- obj = PyInt_FromLong(val);
+ obj = _PyLong_FromLong(val);
else
obj = PyLong_FromUnsignedLongLong(val);
}
@@ -345,9 +375,9 @@ static PyObject *python_process_callchain(struct perf_sample *sample,
pydict_set_item_string_decref(pysym, "end",
PyLong_FromUnsignedLongLong(node->sym->end));
pydict_set_item_string_decref(pysym, "binding",
- PyInt_FromLong(node->sym->binding));
+ _PyLong_FromLong(node->sym->binding));
pydict_set_item_string_decref(pysym, "name",
- PyString_FromStringAndSize(node->sym->name,
+ _PyUnicode_FromStringAndSize(node->sym->name,
node->sym->namelen));
pydict_set_item_string_decref(pyelem, "sym", pysym);
}
@@ -362,7 +392,7 @@ static PyObject *python_process_callchain(struct perf_sample *sample,
dsoname = map->dso->name;
}
pydict_set_item_string_decref(pyelem, "dso",
- PyString_FromString(dsoname));
+ _PyUnicode_FromString(dsoname));
}
callchain_cursor_advance(&callchain_cursor);
@@ -417,27 +447,27 @@ static void python_process_tracepoint(struct perf_sample *sample,
scripting_context->event_data = data;
scripting_context->pevent = evsel->tp_format->pevent;
- context = PyCObject_FromVoidPtr(scripting_context, NULL);
+ context = _PyCapsule_New(scripting_context, NULL, NULL);
- PyTuple_SetItem(t, n++, PyString_FromString(handler_name));
+ PyTuple_SetItem(t, n++, _PyUnicode_FromString(handler_name));
PyTuple_SetItem(t, n++, context);
/* ip unwinding */
callchain = python_process_callchain(sample, evsel, al);
if (handler) {
- PyTuple_SetItem(t, n++, PyInt_FromLong(cpu));
- PyTuple_SetItem(t, n++, PyInt_FromLong(s));
- PyTuple_SetItem(t, n++, PyInt_FromLong(ns));
- PyTuple_SetItem(t, n++, PyInt_FromLong(pid));
- PyTuple_SetItem(t, n++, PyString_FromString(comm));
+ PyTuple_SetItem(t, n++, _PyLong_FromLong(cpu));
+ PyTuple_SetItem(t, n++, _PyLong_FromLong(s));
+ PyTuple_SetItem(t, n++, _PyLong_FromLong(ns));
+ PyTuple_SetItem(t, n++, _PyLong_FromLong(pid));
+ PyTuple_SetItem(t, n++, _PyUnicode_FromString(comm));
PyTuple_SetItem(t, n++, callchain);
} else {
- pydict_set_item_string_decref(dict, "common_cpu", PyInt_FromLong(cpu));
- pydict_set_item_string_decref(dict, "common_s", PyInt_FromLong(s));
- pydict_set_item_string_decref(dict, "common_ns", PyInt_FromLong(ns));
- pydict_set_item_string_decref(dict, "common_pid", PyInt_FromLong(pid));
- pydict_set_item_string_decref(dict, "common_comm", PyString_FromString(comm));
+ pydict_set_item_string_decref(dict, "common_cpu", _PyLong_FromLong(cpu));
+ pydict_set_item_string_decref(dict, "common_s", _PyLong_FromLong(s));
+ pydict_set_item_string_decref(dict, "common_ns", _PyLong_FromLong(ns));
+ pydict_set_item_string_decref(dict, "common_pid", _PyLong_FromLong(pid));
+ pydict_set_item_string_decref(dict, "common_comm", _PyUnicode_FromString(comm));
pydict_set_item_string_decref(dict, "common_callchain", callchain);
}
for (field = event->format.fields; field; field = field->next) {
@@ -448,7 +478,7 @@ static void python_process_tracepoint(struct perf_sample *sample,
offset &= 0xffff;
} else
offset = field->offset;
- obj = PyString_FromString((char *)data + offset);
+ obj = _PyUnicode_FromString((char *)data + offset);
} else { /* FIELD_IS_NUMERIC */
obj = get_field_numeric_entry(event, field, data);
}
@@ -506,16 +536,16 @@ static void python_process_general_event(struct perf_sample *sample,
if (!handler)
goto exit;
- pydict_set_item_string_decref(dict, "ev_name", PyString_FromString(perf_evsel__name(evsel)));
- pydict_set_item_string_decref(dict, "attr", PyString_FromStringAndSize(
+ pydict_set_item_string_decref(dict, "ev_name", _PyUnicode_FromString(perf_evsel__name(evsel)));
+ pydict_set_item_string_decref(dict, "attr", _PyUnicode_FromStringAndSize(
(const char *)&evsel->attr, sizeof(evsel->attr)));
pydict_set_item_string_decref(dict_sample, "pid",
- PyInt_FromLong(sample->pid));
+ _PyLong_FromLong(sample->pid));
pydict_set_item_string_decref(dict_sample, "tid",
- PyInt_FromLong(sample->tid));
+ _PyLong_FromLong(sample->tid));
pydict_set_item_string_decref(dict_sample, "cpu",
- PyInt_FromLong(sample->cpu));
+ _PyLong_FromLong(sample->cpu));
pydict_set_item_string_decref(dict_sample, "ip",
PyLong_FromUnsignedLongLong(sample->ip));
pydict_set_item_string_decref(dict_sample, "time",
@@ -524,17 +554,17 @@ static void python_process_general_event(struct perf_sample *sample,
PyLong_FromUnsignedLongLong(sample->period));
pydict_set_item_string_decref(dict, "sample", dict_sample);
- pydict_set_item_string_decref(dict, "raw_buf", PyString_FromStringAndSize(
+ pydict_set_item_string_decref(dict, "raw_buf", _PyBytes_FromStringAndSize(
(const char *)sample->raw_data, sample->raw_size));
pydict_set_item_string_decref(dict, "comm",
- PyString_FromString(thread__comm_str(thread)));
+ _PyUnicode_FromString(thread__comm_str(thread)));
if (al->map) {
pydict_set_item_string_decref(dict, "dso",
- PyString_FromString(al->map->dso->name));
+ _PyUnicode_FromString(al->map->dso->name));
}
if (al->sym) {
pydict_set_item_string_decref(dict, "symbol",
- PyString_FromString(al->sym->name));
+ _PyUnicode_FromString(al->sym->name));
}
/* ip unwinding */
@@ -589,26 +619,56 @@ error:
return -1;
}
+#if PY_MAJOR_VERSION < 3
+static void _free_command_line(const char **command_line, int num)
+{
+ free(command_line);
+}
+#else
+static void _free_command_line(wchar_t **command_line, int num)
+{
+ int i;
+ for (i = 0; i < num; i++)
+ PyMem_RawFree(command_line[i]);
+ free(command_line);
+}
+#endif
+
/*
* Start trace script
*/
static int python_start_script(const char *script, int argc, const char **argv)
{
+#if PY_MAJOR_VERSION < 3
const char **command_line;
+#else
+ wchar_t **command_line;
+#endif
char buf[PATH_MAX];
int i, err = 0;
FILE *fp;
+#if PY_MAJOR_VERSION < 3
command_line = malloc((argc + 1) * sizeof(const char *));
command_line[0] = script;
for (i = 1; i < argc + 1; i++)
command_line[i] = argv[i - 1];
+#else
+ command_line = malloc((argc + 1) * sizeof(wchar_t *));
+ command_line[0] = Py_DecodeLocale(script, NULL);
+ for (i = 1; i < argc + 1; i++)
+ command_line[i] = Py_DecodeLocale(argv[i - 1], NULL);
+#endif
Py_Initialize();
+#if PY_MAJOR_VERSION < 3
initperf_trace_context();
-
PySys_SetArgv(argc + 1, (char **)command_line);
+#else
+ PyInit_perf_trace_context();
+ PySys_SetArgv(argc + 1, command_line);
+#endif
fp = fopen(script, "r");
if (!fp) {
@@ -630,12 +690,12 @@ static int python_start_script(const char *script, int argc, const char **argv)
goto error;
}
- free(command_line);
+ _free_command_line(command_line, argc + 1);
return err;
error:
Py_Finalize();
- free(command_line);
+ _free_command_line(command_line, argc + 1);
return err;
}
diff --git a/tools/perf/util/setup.py b/tools/perf/util/setup.py
index d0aee4b9..fc25b50d 100644
--- a/tools/perf/util/setup.py
+++ b/tools/perf/util/setup.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python2
+#!/usr/bin/python3
from distutils.core import setup, Extension
from os import getenv
@@ -27,7 +27,7 @@ build_tmp = getenv('PYTHON_EXTBUILD_TMP')
libtraceevent = getenv('LIBTRACEEVENT')
libapikfs = getenv('LIBAPIKFS')
-ext_sources = [f.strip() for f in file('util/python-ext-sources')
+ext_sources = [f.strip() for f in open('util/python-ext-sources')
if len(f.strip()) > 0 and f[0] != '#']
perf = Extension('perf',

View file

@ -0,0 +1,852 @@
diff --git a/tools/dct/DrvGen.py b/tools/dct/DrvGen.py
index 6a1e5ba3..45c66f1b 100755
--- a/tools/dct/DrvGen.py
+++ b/tools/dct/DrvGen.py
@@ -1,4 +1,4 @@
-#! /usr/bin/python
+#! /usr/bin/python3
import os, sys
import getopt
@@ -19,7 +19,7 @@ from utility.util import LogLevel
from utility.util import log
def usage():
- print '''
+ print('''
usage: DrvGen [dws_path] [file_path] [log_path] [paras]...
options and arguments:
@@ -28,7 +28,7 @@ dws_path : dws file path
file_path : where you want to put generated files
log_path : where to store the log files
paras : parameter for generate wanted file
-'''
+''')
def is_oldDws(path, gen_spec):
if not os.path.exists(path):
@@ -37,7 +37,7 @@ def is_oldDws(path, gen_spec):
try:
root = xml.dom.minidom.parse(dws_path)
- except Exception, e:
+ except Exception as e:
log(LogLevel.warn, '%s is not xml format, try to use old DCT!' %(dws_path))
if len(gen_spec) == 0:
log(LogLevel.warn, 'Please use old DCT UI to gen all files!')
diff --git a/tools/dct/data/EintData.py b/tools/dct/data/EintData.py
index 79f1c53e..5f9baa86 100755
--- a/tools/dct/data/EintData.py
+++ b/tools/dct/data/EintData.py
@@ -59,7 +59,7 @@ class EintData:
def get_modeName(gpio_num, mode_idx):
key = 'gpio%s' %(gpio_num)
- if key in EintData._mode_map.keys():
+ if key in list(EintData._mode_map.keys()):
list = EintData._mode_map[key]
if mode_idx < len(list) and mode_idx >= 0:
return list[mode_idx]
@@ -68,7 +68,7 @@ class EintData:
@staticmethod
def set_modeMap(map):
- for (key, value) in map.items():
+ for (key, value) in list(map.items()):
list = []
for item in value:
list.append(item[6:len(item)-1])
@@ -83,7 +83,7 @@ class EintData:
@staticmethod
def get_gpioNum(num):
if len(EintData._map_table):
- for (key,value) in EintData._map_table.items():
+ for (key,value) in list(EintData._map_table.items()):
if num == value:
return key
diff --git a/tools/dct/data/GpioData.py b/tools/dct/data/GpioData.py
index 26f40192..9989cdb0 100755
--- a/tools/dct/data/GpioData.py
+++ b/tools/dct/data/GpioData.py
@@ -113,7 +113,7 @@ class GpioData:
@staticmethod
def get_modeName(key, idx):
- if key in GpioData._modeMap.keys():
+ if key in list(GpioData._modeMap.keys()):
value = GpioData._modeMap[key]
return value[idx]
diff --git a/tools/dct/data/KpdData.py b/tools/dct/data/KpdData.py
index 445b2277..fb670b0b 100755
--- a/tools/dct/data/KpdData.py
+++ b/tools/dct/data/KpdData.py
@@ -141,7 +141,7 @@ class KpdData:
@staticmethod
def get_keyVal(key):
- if key in KpdData._keyValueMap.keys():
+ if key in list(KpdData._keyValueMap.keys()):
return KpdData._keyValueMap[key]
return 0
diff --git a/tools/dct/obj/AdcObj.py b/tools/dct/obj/AdcObj.py
index f4528e70..7bcf7952 100755
--- a/tools/dct/obj/AdcObj.py
+++ b/tools/dct/obj/AdcObj.py
@@ -61,7 +61,7 @@ class AdcObj(ModuleObj):
# sort by the key, or the sequence is dissorted
#sorted_list = sorted(ModuleObj.get_data(self).keys())
- for key in sorted_key(ModuleObj.get_data(self).keys()):
+ for key in sorted_key(list(ModuleObj.get_data(self).keys())):
value = ModuleObj.get_data(self)[key]
if value == "TEMPERATURE":
diff --git a/tools/dct/obj/ChipObj.py b/tools/dct/obj/ChipObj.py
index 5c4a4eef..847e7b59 100755
--- a/tools/dct/obj/ChipObj.py
+++ b/tools/dct/obj/ChipObj.py
@@ -4,19 +4,19 @@
import os, sys
import xml.dom.minidom
-from GpioObj import GpioObj
-from EintObj import EintObj
-from AdcObj import AdcObj
-from ClkObj import ClkObj
-from ClkObj import ClkObj_Everest
-from ClkObj import ClkObj_Olympus
-from ClkObj import ClkObj_Rushmore
-from I2cObj import I2cObj
-from PmicObj import PmicObj
-from Md1EintObj import Md1EintObj
-from PowerObj import PowerObj
-from KpdObj import KpdObj
-from ModuleObj import ModuleObj
+from .GpioObj import GpioObj
+from .EintObj import EintObj
+from .AdcObj import AdcObj
+from .ClkObj import ClkObj
+from .ClkObj import ClkObj_Everest
+from .ClkObj import ClkObj_Olympus
+from .ClkObj import ClkObj_Rushmore
+from .I2cObj import I2cObj
+from .PmicObj import PmicObj
+from .Md1EintObj import Md1EintObj
+from .PowerObj import PowerObj
+from .KpdObj import KpdObj
+from .ModuleObj import ModuleObj
from utility.util import log
from utility.util import LogLevel
@@ -54,13 +54,13 @@ class ChipObj:
self.__objs["kpd"] = KpdObj()
def replace_obj(self, tag, obj):
- if not tag in self.__objs.keys():
+ if not tag in list(self.__objs.keys()):
return False
self.__objs[tag] = obj
def append_obj(self, tag, obj):
- if tag in self.__objs.keys():
+ if tag in list(self.__objs.keys()):
return False
self.__objs[tag] = obj
@@ -114,7 +114,7 @@ class ChipObj:
def generate(self, paras):
if len(paras) == 0:
- for obj in self.__objs.values():
+ for obj in list(self.__objs.values()):
obj.gen_files()
self.gen_custDtsi()
@@ -125,7 +125,7 @@ class ChipObj:
def create_obj(self, tag):
obj = None
- if tag in self.__objs.keys():
+ if tag in list(self.__objs.keys()):
obj = self.__objs[tag]
return obj
@@ -140,9 +140,9 @@ class ChipObj:
idx = 0
name = ''
if para.strip() != '':
- for value in para_map.values():
+ for value in list(para_map.values()):
if para in value:
- name = para_map.keys()[idx]
+ name = list(para_map.keys())[idx]
break
idx += 1
diff --git a/tools/dct/obj/ClkObj.py b/tools/dct/obj/ClkObj.py
index 758e7d6a..a8ab55ed 100755
--- a/tools/dct/obj/ClkObj.py
+++ b/tools/dct/obj/ClkObj.py
@@ -4,11 +4,11 @@
import os
import re
import string
-import ConfigParser
+import configparser
import xml.dom.minidom
-from ModuleObj import ModuleObj
+from .ModuleObj import ModuleObj
from data.ClkData import ClkData
from utility.util import log
from utility.util import LogLevel
@@ -47,7 +47,7 @@ class ClkObj(ModuleObj):
return True
def get_cfgInfo(self):
- cp = ConfigParser.ConfigParser(allow_no_value=True)
+ cp = configparser.ConfigParser(allow_no_value=True)
cp.read(ModuleObj.get_figPath())
count = string.atoi(cp.get('CLK_BUF', 'CLK_BUF_COUNT'))
@@ -95,13 +95,13 @@ class ClkObj(ModuleObj):
gen_str += '''} MTK_CLK_BUF_DRIVING_CURR;\n'''
gen_str += '''\n'''
- for key in sorted_key(ModuleObj.get_data(self).keys()):
+ for key in sorted_key(list(ModuleObj.get_data(self).keys())):
value = ModuleObj.get_data(self)[key]
gen_str += '''#define %s_STATUS_PMIC\t\tCLOCK_BUFFER_%s\n''' %(key[5:], value.get_varName().upper())
gen_str += '''\n'''
- for key in sorted_key(ModuleObj.get_data(self).keys()):
+ for key in sorted_key(list(ModuleObj.get_data(self).keys())):
value = ModuleObj.get_data(self)[key]
idx = value.get_curList().index(value.get_current())
if cmp(value.get_curList()[0], DEFAULT_AUTOK) == 0:
@@ -122,7 +122,7 @@ class ClkObj(ModuleObj):
gen_str += '''\tmediatek,clkbuf-config = <'''
#sorted_list = sorted(ModuleObj.get_data(self).keys())
- for key in sorted_key(ModuleObj.get_data(self).keys()):
+ for key in sorted_key(list(ModuleObj.get_data(self).keys())):
if key.find('PMIC') == -1:
continue
value = ModuleObj.get_data(self)[key]
@@ -134,7 +134,7 @@ class ClkObj(ModuleObj):
gen_str += '''\tmediatek,clkbuf-driving-current = <'''
#sorted_list = sorted(ModuleObj.get_data(self).keys())
- for key in sorted_key(ModuleObj.get_data(self).keys()):
+ for key in sorted_key(list(ModuleObj.get_data(self).keys())):
if key.find('PMIC') == -1:
continue
value = ModuleObj.get_data(self)[key]
@@ -183,14 +183,14 @@ class ClkObj_Everest(ClkObj):
gen_str += '''} MTK_CLK_BUF_DRIVING_CURR;\n'''
gen_str += '''\n'''
- for key in sorted_key(ModuleObj.get_data(self).keys()):
+ for key in sorted_key(list(ModuleObj.get_data(self).keys())):
value = ModuleObj.get_data(self)[key]
if key.find(self.__pmic) != -1:
gen_str += '''#define %s_STATUS_PMIC\t\t\t\tCLOCK_BUFFER_%s\n''' %(key[5:], value.get_varName())
gen_str += '''\n'''
- for key in sorted_key(ModuleObj.get_data(self).keys()):
+ for key in sorted_key(list(ModuleObj.get_data(self).keys())):
value = ModuleObj.get_data(self)[key]
if key.find(self.__pmic) != -1:
gen_str += '''#define %s_DRIVING_CURR\t\tCLK_BUF_DRIVING_CURR_%sMA\n''' %(key, value.get_current().replace('.', '_'))
@@ -198,14 +198,14 @@ class ClkObj_Everest(ClkObj):
gen_str += '''\n'''
- for key in sorted_key(ModuleObj.get_data(self).keys()):
+ for key in sorted_key(list(ModuleObj.get_data(self).keys())):
value = ModuleObj.get_data(self)[key]
if key.find(self.__rf) != -1:
gen_str += '''#define %s_STATUS\t\tCLOCK_BUFFER_%s\n''' %(key[3:], value.get_varName())
gen_str += '''\n'''
- for key in sorted_key(ModuleObj.get_data(self).keys()):
+ for key in sorted_key(list(ModuleObj.get_data(self).keys())):
value = ModuleObj.get_data(self)[key]
if key.find(self.__rf) != -1:
gen_str += '''#define %s_DRIVING_CURR\t\tCLK_BUF_DRIVING_CURR_%sMA\n''' %(key, value.get_current().replace('.', '_'))
@@ -227,7 +227,7 @@ class ClkObj_Everest(ClkObj):
#sorted_list = sorted(ModuleObj.get_data(self).keys())
- for key in sorted_key(ModuleObj.get_data(self).keys()):
+ for key in sorted_key(list(ModuleObj.get_data(self).keys())):
value = ModuleObj.get_data(self)[key]
if key.find(self.__rf) != -1:
@@ -237,7 +237,7 @@ class ClkObj_Everest(ClkObj):
gen_str += '''\tmediatek,clkbuf-driving-current = <'''
- for key in sorted_key(ModuleObj.get_data(self).keys()):
+ for key in sorted_key(list(ModuleObj.get_data(self).keys())):
value = ModuleObj.get_data(self)[key]
if key.find(self.__rf) != -1:
idx = value.get_curList().index(value.get_current())
@@ -284,14 +284,14 @@ class ClkObj_Olympus(ClkObj_Everest):
gen_str += '''} MTK_CLK_BUF_DRIVING_CURR;\n'''
gen_str += '''\n'''
- for key in sorted_key(ModuleObj.get_data(self).keys()):
+ for key in sorted_key(list(ModuleObj.get_data(self).keys())):
value = ModuleObj.get_data(self)[key]
if key.find('PMIC') != -1:
gen_str += '''#define %s_STATUS_PMIC\t\tCLOCK_BUFFER_%s\n''' %(key[5:], value.get_varName())
gen_str += '''\n'''
- for key in sorted_key(ModuleObj.get_data(self).keys()):
+ for key in sorted_key(list(ModuleObj.get_data(self).keys())):
value = ModuleObj.get_data(self)[key]
if key.find('RF') != -1:
gen_str += '''#define %s_STATUS\t\t\t\tCLOCK_BUFFER_%s\n''' %(key[3:], value.get_varName())
@@ -299,7 +299,7 @@ class ClkObj_Olympus(ClkObj_Everest):
gen_str += '''\n'''
- for key in sorted_key(ModuleObj.get_data(self).keys()):
+ for key in sorted_key(list(ModuleObj.get_data(self).keys())):
if key.find('PMIC') != -1:
continue
value = ModuleObj.get_data(self)[key]
@@ -315,7 +315,7 @@ class ClkObj_Olympus(ClkObj_Everest):
gen_str += '''\n'''
- for key in sorted_key(ModuleObj.get_data(self).keys()):
+ for key in sorted_key(list(ModuleObj.get_data(self).keys())):
if key.find('RF') != -1:
continue
value = ModuleObj.get_data(self)[key]
@@ -342,7 +342,7 @@ class ClkObj_Rushmore(ClkObj):
ClkObj.parse(self, node)
def get_cfgInfo(self):
- cp = ConfigParser.ConfigParser(allow_no_value=True)
+ cp = configparser.ConfigParser(allow_no_value=True)
cp.read(ModuleObj.get_figPath())
count = string.atoi(cp.get('CLK_BUF', 'CLK_BUF_COUNT'))
@@ -388,14 +388,14 @@ class ClkObj_Rushmore(ClkObj):
gen_str += '''\n'''
- for key in sorted_key(ModuleObj.get_data(self).keys()):
+ for key in sorted_key(list(ModuleObj.get_data(self).keys())):
value = ModuleObj.get_data(self)[key]
if key.find('RF') != -1:
gen_str += '''#define %s_STATUS\t\t\t\tCLOCK_BUFFER_%s\n''' %(key[3:], value.get_varName())
gen_str += '''\n'''
- for key in sorted_key(ModuleObj.get_data(self).keys()):
+ for key in sorted_key(list(ModuleObj.get_data(self).keys())):
if key.find('RF') != -1:
continue
value = ModuleObj.get_data(self)[key]
@@ -418,7 +418,7 @@ class ClkObj_Rushmore(ClkObj):
gen_str += '''\tmediatek,clkbuf-config = <'''
#sorted_list = sorted(ModuleObj.get_data(self).keys())
- for key in sorted_key(ModuleObj.get_data(self).keys()):
+ for key in sorted_key(list(ModuleObj.get_data(self).keys())):
if key.find('RF') == -1:
continue
value = ModuleObj.get_data(self)[key]
diff --git a/tools/dct/obj/EintObj.py b/tools/dct/obj/EintObj.py
index d4c7e80f..f27b1812 100755
--- a/tools/dct/obj/EintObj.py
+++ b/tools/dct/obj/EintObj.py
@@ -5,7 +5,7 @@ import re
import os
import string
-import ConfigParser
+import configparser
import xml.dom.minidom
from data.EintData import EintData
@@ -70,7 +70,7 @@ class EintObj(ModuleObj):
ModuleObj.gen_spec(self, para)
def get_cfgInfo(self):
- cp = ConfigParser.ConfigParser(allow_no_value=True)
+ cp = configparser.ConfigParser(allow_no_value=True)
cp.read(ModuleObj.get_figPath())
ops = cp.options('GPIO')
@@ -135,7 +135,7 @@ class EintObj(ModuleObj):
gen_str += '''\n\n'''
- sorted_list = sorted(ModuleObj.get_data(self).keys(), key=compare)
+ sorted_list = sorted(list(ModuleObj.get_data(self).keys()), key=compare)
for key in sorted_list:
value = ModuleObj.get_data(self)[key]
@@ -193,7 +193,7 @@ class EintObj(ModuleObj):
if value != -1:
gen_str += '''<%d %d>,\n\t\t\t\t\t''' %(key, value)
- for (key, value) in EintData._int_eint.items():
+ for (key, value) in list(EintData._int_eint.items()):
gen_str += '''<%s %s>,\n\t\t\t\t\t''' %(value, key)
gen_str = gen_str[0:len(gen_str)-7]
@@ -205,8 +205,8 @@ class EintObj(ModuleObj):
gen_str += '''\t\t\t\t\t/* gpio, built-in func mode, built-in eint */\n'''
gen_str += '''\tmediatek,builtin_mapping = '''
- for (key, value) in EintData._builtin_map.items():
- for (sub_key, sub_value) in value.items():
+ for (key, value) in list(EintData._builtin_map.items()):
+ for (sub_key, sub_value) in list(value.items()):
gen_str += '''<%s %s %s>, /* %s */\n\t\t\t\t\t''' %(sub_key, sub_value[0:1], key, sub_value)
gen_str = gen_str[0:gen_str.rfind(',')]
@@ -216,7 +216,7 @@ class EintObj(ModuleObj):
return gen_str
def get_gpioNum(self, eint_num):
- for (key, value) in EintData.get_mapTable().items():
+ for (key, value) in list(EintData.get_mapTable().items()):
if cmp(eint_num, value) == 0:
return key
@@ -235,14 +235,14 @@ class EintObj(ModuleObj):
if re.match(r'GPIO[\d]+', mode_name) or re.match(r'EINT[\d]+', mode_name):
return gpio_vec
- for key in EintData._builtin_map.keys():
+ for key in list(EintData._builtin_map.keys()):
if string.atoi(eint_num) == string.atoi(key):
temp_map = EintData._builtin_map[key]
- for key in temp_map.keys():
+ for key in list(temp_map.keys()):
gpio_vec.append(key)
if flag:
- for item in temp_map.keys():
+ for item in list(temp_map.keys()):
item_data = self.__gpio_obj.get_gpioData(string.atoi(item))
if item_data.get_defMode() == string.atoi(temp_map[item].split(':')[0]):
@@ -261,7 +261,7 @@ class EintObj(ModuleObj):
gen_str += self.fill_mappingTable()
- sorted_list = sorted(ModuleObj.get_data(self).keys(), key=compare)
+ sorted_list = sorted(list(ModuleObj.get_data(self).keys()), key=compare)
for key in sorted_list:
value = ModuleObj.get_data(self)[key]
diff --git a/tools/dct/obj/GpioObj.py b/tools/dct/obj/GpioObj.py
index 0539c297..c8452efd 100755
--- a/tools/dct/obj/GpioObj.py
+++ b/tools/dct/obj/GpioObj.py
@@ -5,14 +5,14 @@ import re
import os
import sys
import string
-import ConfigParser
+import configparser
import xml.dom.minidom
from data.GpioData import GpioData
from data.EintData import EintData
-from ModuleObj import ModuleObj
-import ChipObj
+from .ModuleObj import ModuleObj
+from . import ChipObj
from utility.util import compare
from utility.util import sorted_key
@@ -26,7 +26,7 @@ class GpioObj(ModuleObj):
self.__fileMap = 'cust_gpio_usage_mapping.dtsi'
def get_cfgInfo(self):
- cp = ConfigParser.ConfigParser(allow_no_value=True)
+ cp = configparser.ConfigParser(allow_no_value=True)
cp.read(ModuleObj.get_cmpPath())
# get GPIO_FREQ section
@@ -260,7 +260,7 @@ class GpioObj(ModuleObj):
def fill_hFile(self):
gen_str = '''//Configuration for GPIO SMT(Schmidt Trigger) Group output start\n'''
temp_list = []
- for key in sorted_key(ModuleObj.get_data(self).keys()):
+ for key in sorted_key(list(ModuleObj.get_data(self).keys())):
#for value in ModuleObj.get_data(self).values():
value = ModuleObj.get_data(self)[key]
num = value.get_smtNum()
@@ -275,7 +275,7 @@ class GpioObj(ModuleObj):
gen_str += '''\n\n'''
- sorted_list = sorted(ModuleObj.get_data(self).keys(), key = compare)
+ sorted_list = sorted(list(ModuleObj.get_data(self).keys()), key = compare)
for key in sorted_list:
value = ModuleObj.get_data(self)[key]
@@ -357,7 +357,7 @@ class GpioObj(ModuleObj):
gen_str = ''
#sorted_list = sorted(ModuleObj.get_data(self).keys(), key = compare)
- for key in sorted_key(ModuleObj.get_data(self).keys()):
+ for key in sorted_key(list(ModuleObj.get_data(self).keys())):
#for key in sorted_list:
value = ModuleObj.get_data(self)[key]
for varName in value.get_varNames():
@@ -367,7 +367,7 @@ class GpioObj(ModuleObj):
gen_str += '''#define %s_M_EINT\t\tGPIO_MODE_00\n''' %(varName)
temp_list = []
- for item in GpioData._specMap.keys():
+ for item in list(GpioData._specMap.keys()):
regExp = '[_A-Z0-9:]*%s[_A-Z0-9:]*' %(item.upper())
pat = re.compile(regExp)
for i in range(0, GpioData._modNum):
@@ -414,7 +414,7 @@ class GpioObj(ModuleObj):
if pat.match(mode):
gen_str += '''#define %s_CLK\t\tCLK_OUT%s\n''' %(varName, mode[4:])
temp = ''
- if varName in GpioData._freqMap.keys():
+ if varName in list(GpioData._freqMap.keys()):
temp = GpioData._freqMap[varName]
else:
temp = 'GPIO_CLKSRC_NONE'
@@ -430,7 +430,7 @@ class GpioObj(ModuleObj):
gen_str += '''\tgpio_pins_default: gpiodef{\n\t};\n\n'''
#sorted_list = sorted(ModuleObj.get_data(self).keys(), key = compare)
- for key in sorted_key(ModuleObj.get_data(self).keys()):
+ for key in sorted_key(list(ModuleObj.get_data(self).keys())):
#for key in sorted_list:
value = ModuleObj.get_data(self)[key]
gen_str += '''\t%s: gpio@%s {\n''' %(key.lower(), key[4:])
@@ -501,7 +501,7 @@ class GpioObj(ModuleObj):
def fill_pinfunc_hFile(self):
gen_str = '''#include \"mt65xx.h\"\n\n'''
#sorted_list = sorted(ModuleObj.get_data(self).keys(), key = compare)
- for key in sorted_key(ModuleObj.get_data(self).keys()):
+ for key in sorted_key(list(ModuleObj.get_data(self).keys())):
#for key in sorted_list:
value = ModuleObj.get_data(self)[key]
for i in range(0, GpioData._modNum):
@@ -528,7 +528,7 @@ class GpioObj(ModuleObj):
gen_str += '''static const struct mtk_desc_pin mtk_pins_%s[] = {\n''' %(ModuleObj.get_chipId().lower())
#sorted_list = sorted(ModuleObj.get_data(self).keys(), key = compare)
- for key in sorted_key(ModuleObj.get_data(self).keys()):
+ for key in sorted_key(list(ModuleObj.get_data(self).keys())):
#for key in sorted_list:
value = ModuleObj.get_data(self)[key]
gen_str += '''\tMTK_PIN(\n'''
@@ -556,7 +556,7 @@ class GpioObj(ModuleObj):
gen_str = '''&gpio_usage_mapping {\n'''
#sorted_list = sorted(ModuleObj.get_data(self).keys(), key = compare)
- for key in sorted_key(ModuleObj.get_data(self).keys()):
+ for key in sorted_key(list(ModuleObj.get_data(self).keys())):
#for key in sorted_list:
value = ModuleObj.get_data(self)[key]
for varName in value.get_varNames():
diff --git a/tools/dct/obj/I2cObj.py b/tools/dct/obj/I2cObj.py
index 25006902..1a885d0e 100755
--- a/tools/dct/obj/I2cObj.py
+++ b/tools/dct/obj/I2cObj.py
@@ -4,14 +4,14 @@
import re
import string
import xml.dom.minidom
-import ConfigParser
+import configparser
-from ModuleObj import ModuleObj
+from .ModuleObj import ModuleObj
#from utility import util
from utility.util import sorted_key
from data.I2cData import I2cData
from data.I2cData import BusData
-import ChipObj
+from . import ChipObj
class I2cObj(ModuleObj):
def __init__(self):
@@ -20,7 +20,7 @@ class I2cObj(ModuleObj):
self.__bBusEnable = True
def get_cfgInfo(self):
- cp = ConfigParser.ConfigParser(allow_no_value=True)
+ cp = configparser.ConfigParser(allow_no_value=True)
cp.read(ModuleObj.get_figPath())
I2cData._i2c_count = string.atoi(cp.get('I2C', 'I2C_COUNT'))
@@ -84,7 +84,7 @@ class I2cObj(ModuleObj):
gen_str += '''\n'''
#sorted_lst = sorted(ModuleObj.get_data(self).keys(), key=compare)
- for key in sorted_key(ModuleObj.get_data(self).keys()):
+ for key in sorted_key(list(ModuleObj.get_data(self).keys())):
value = ModuleObj.get_data(self)[key]
temp = ''
if value.get_address().strip() == '':
@@ -114,7 +114,7 @@ class I2cObj(ModuleObj):
temp_str = 'use-push-pull'
gen_str += '''\tmediatek,%s;\n''' %(temp_str)
- for key in sorted_key(ModuleObj.get_data(self).keys()):
+ for key in sorted_key(list(ModuleObj.get_data(self).keys())):
value = ModuleObj.get_data(self)[key]
channel = 'I2C_CHANNEL_%d' %(i)
if cmp(value.get_channel(), channel) == 0 and cmp(value.get_varName(), 'NC') != 0 and value.get_address().strip() != '':
diff --git a/tools/dct/obj/KpdObj.py b/tools/dct/obj/KpdObj.py
index 52f3bad2..64500bfe 100755
--- a/tools/dct/obj/KpdObj.py
+++ b/tools/dct/obj/KpdObj.py
@@ -3,10 +3,10 @@
import re
import string
-import ConfigParser
+import configparser
import xml.dom.minidom
-from ModuleObj import ModuleObj
+from .ModuleObj import ModuleObj
from utility.util import LogLevel
from utility.util import log
from data.KpdData import KpdData
@@ -18,7 +18,7 @@ class KpdObj(ModuleObj):
def get_cfgInfo(self):
- cp = ConfigParser.ConfigParser(allow_no_value=True)
+ cp = configparser.ConfigParser(allow_no_value=True)
cp.read(ModuleObj.get_cmpPath())
ops = cp.options('Key_definition')
@@ -204,7 +204,7 @@ class KpdObj(ModuleObj):
gen_str += '''/****************Uboot Customation**************************/\n'''
gen_str += '''/***********************************************************/\n'''
- for (key, value) in KpdData.get_modeKeys().items():
+ for (key, value) in list(KpdData.get_modeKeys().items()):
if cmp(value, 'NC') != 0:
idx = self.get_matrixIdx(value)
#idx = KpdData.get_matrix().index(value)
@@ -274,7 +274,7 @@ class KpdObj(ModuleObj):
continue
gen_str += '''\tmediatek,kpd-hw-dl-key%d = <%s>;\n''' %(KpdData.get_downloadKeys().index(key), self.get_matrixIdx(key))
- for (key, value) in KpdData.get_modeKeys().items():
+ for (key, value) in list(KpdData.get_modeKeys().items()):
if cmp(value, 'NC') == 0:
continue
gen_str += '''\tmediatek,kpd-hw-%s-key = <%d>;\n''' %(key.lower(), self.get_matrixIdx(value))
diff --git a/tools/dct/obj/Md1EintObj.py b/tools/dct/obj/Md1EintObj.py
index 9d48e173..41bc500e 100755
--- a/tools/dct/obj/Md1EintObj.py
+++ b/tools/dct/obj/Md1EintObj.py
@@ -1,13 +1,13 @@
#! /usr/bin/python
# -*- coding: utf-8 -*-
-import ConfigParser
+import configparser
import string
import xml.dom.minidom
from utility import util
from utility.util import sorted_key
-from ModuleObj import ModuleObj
+from .ModuleObj import ModuleObj
from data.Md1EintData import Md1EintData
from utility.util import LogLevel
@@ -19,7 +19,7 @@ class Md1EintObj(ModuleObj):
def get_cfgInfo(self):
# ConfigParser accept ":" and "=", so SRC_PIN will be treated specially
- cp = ConfigParser.ConfigParser(allow_no_value=True)
+ cp = configparser.ConfigParser(allow_no_value=True)
cp.read(ModuleObj.get_figPath())
if cp.has_option('Chip Type', 'MD1_EINT_SRC_PIN'):
@@ -95,7 +95,7 @@ class Md1EintObj(ModuleObj):
gen_str += '''\n'''
if self.__bSrcPinEnable:
- for (key, value) in self.__srcPin.items():
+ for (key, value) in list(self.__srcPin.items()):
gen_str += '''#define %s\t\t%s\n''' %(key, value)
gen_str += '''\n'''
@@ -108,7 +108,7 @@ class Md1EintObj(ModuleObj):
gen_str += '''\n'''
count = 0
- for key in sorted_key(ModuleObj.get_data(self).keys()):
+ for key in sorted_key(list(ModuleObj.get_data(self).keys())):
value = ModuleObj.get_data(self)[key]
if cmp(value.get_varName(), 'NC') == 0:
continue
@@ -133,7 +133,7 @@ class Md1EintObj(ModuleObj):
def fill_dtsiFile(self):
gen_str = ''
gen_str += '''&eintc {\n'''
- for key in sorted_key(ModuleObj.get_data(self).keys()):
+ for key in sorted_key(list(ModuleObj.get_data(self).keys())):
value = ModuleObj.get_data(self)[key]
if cmp(value.get_varName(), 'NC') == 0:
continue
diff --git a/tools/dct/obj/PmicObj.py b/tools/dct/obj/PmicObj.py
index fd35aca3..1cb9f590 100755
--- a/tools/dct/obj/PmicObj.py
+++ b/tools/dct/obj/PmicObj.py
@@ -3,10 +3,10 @@
import sys, os
import re
-import ConfigParser
+import configparser
import xml.dom.minidom
-from ModuleObj import ModuleObj
+from .ModuleObj import ModuleObj
from data.PmicData import PmicData
from utility.util import log
@@ -28,7 +28,7 @@ class PmicObj(ModuleObj):
def get_cfgInfo(self):
- cp = ConfigParser.ConfigParser(allow_no_value=True)
+ cp = configparser.ConfigParser(allow_no_value=True)
cp.read(ModuleObj.get_cmpPath())
PmicData._var_list = cp.options('APPLICATION')
@@ -116,7 +116,7 @@ class PmicObj(ModuleObj):
def fill_hFile(self):
gen_str = ''
used = []
- for key in sorted_key(ModuleObj.get_data(self).keys()):
+ for key in sorted_key(list(ModuleObj.get_data(self).keys())):
value = ModuleObj.get_data(self)[key]
for name in value.get_nameList():
if name.strip() != '':
@@ -138,7 +138,7 @@ class PmicObj(ModuleObj):
def fill_dtsiFile(self):
gen_str = ''
- for key in sorted_key(ModuleObj.get_data(self).keys()):
+ for key in sorted_key(list(ModuleObj.get_data(self).keys())):
value = ModuleObj.get_data(self)[key]
gen_str += '''&mt_pmic_%s_ldo_reg {\n''' %(value.get_ldoName().lower())
gen_str += '''\tregulator-name = \"%s\";\n''' %((value.get_ldoName().replace('_', '')).lower())
@@ -149,7 +149,7 @@ class PmicObj(ModuleObj):
gen_str += '''\n'''
gen_str += '''&kd_camera_hw1 {\n'''
- for key in sorted_key(ModuleObj.get_data(self).keys()):
+ for key in sorted_key(list(ModuleObj.get_data(self).keys())):
value = ModuleObj.get_data(self)[key]
for varName in value.get_nameList():
#for i in range(0, self.__appCount):
@@ -174,7 +174,7 @@ class PmicObj(ModuleObj):
gen_str += '''};\n\n'''
gen_str += '''&touch {\n'''
- for key in sorted_key(ModuleObj.get_data(self).keys()):
+ for key in sorted_key(list(ModuleObj.get_data(self).keys())):
value = ModuleObj.get_data(self)[key]
for name in value.get_nameList():
if name.find('TOUCH') != -1:
@@ -195,7 +195,7 @@ class PmicObj(ModuleObj):
gen_str += '''{\n'''
idx = 0
- for key in sorted_key(ModuleObj.get_data(self).keys()):
+ for key in sorted_key(list(ModuleObj.get_data(self).keys())):
value = ModuleObj.get_data(self)[key]
if value.get_defEnable() != 0:
gen_str += '''\t%s(%s,%d);\n''' %(self.__func, self.__paraList[idx], value.get_defEnable()-1)
diff --git a/tools/dct/obj/PowerObj.py b/tools/dct/obj/PowerObj.py
index 0351adb2..0074e970 100755
--- a/tools/dct/obj/PowerObj.py
+++ b/tools/dct/obj/PowerObj.py
@@ -4,15 +4,15 @@
import sys,os
import re
import string
-import ConfigParser
+import configparser
import xml.dom.minidom
-import ChipObj
+from . import ChipObj
from data.PowerData import PowerData
from utility.util import log
from utility.util import LogLevel
from utility.util import sorted_key
-from ModuleObj import ModuleObj
+from .ModuleObj import ModuleObj
class PowerObj(ModuleObj):
def __init__(self):
@@ -20,7 +20,7 @@ class PowerObj(ModuleObj):
self.__list = {}
def getCfgInfo(self):
- cp = ConfigParser.ConfigParser(allow_no_value=True)
+ cp = configparser.ConfigParser(allow_no_value=True)
cp.read(ModuleObj.get_figPath())
self.__list = cp.options('POWER')
@@ -60,7 +60,7 @@ class PowerObj(ModuleObj):
def fill_hFile(self):
gen_str = ''
- for key in sorted_key(ModuleObj.get_data(self).keys()):
+ for key in sorted_key(list(ModuleObj.get_data(self).keys())):
value = ModuleObj.get_data(self)[key]
if value.get_varName() == '':
continue
diff --git a/tools/dct/utility/util.py b/tools/dct/utility/util.py
index afb27718..e6eff039 100755
--- a/tools/dct/utility/util.py
+++ b/tools/dct/utility/util.py
@@ -16,11 +16,11 @@ class LogLevel:
def log(level, msg):
if level == LogLevel.info:
- print LEVEL_INFO + msg
+ print(LEVEL_INFO + msg)
elif level == LogLevel.warn:
- print LEVEL_WARN + msg
+ print(LEVEL_WARN + msg)
elif level == LogLevel.error:
- print LEVEL_ERROR + msg
+ print(LEVEL_ERROR + msg)
def compare(value):
lst = re.findall(r'\d+', value)

View file

@ -2,7 +2,7 @@
pkgname="linux-asus-z00vd"
pkgver=3.18.41
pkgrel=1
pkgrel=2
pkgdesc="ASUS Zenfone Go kernel fork"
arch="armv7"
_carch="arm"
@ -10,7 +10,7 @@ _flavor="asus-z00vd"
url="https://kernel.org"
license="GPL2"
options="!strip !check !tracedeps"
makedepends="perl sed installkernel bash gmp-dev bc linux-headers elfutils-dev devicepkg-dev python2"
makedepends="perl sed installkernel bash gmp-dev bc linux-headers elfutils-dev devicepkg-dev python3"
# Compiler: latest GCC from Alpine
HOSTCC="${CC:-gcc}"
@ -25,6 +25,8 @@ source="
$_config
01_fix_warnings.patch
02_gcc8_error.patch
03_perf_python3.patch
04_dct_python3.patch
"
builddir="$srcdir/${_repository}-${_commit}"
@ -81,4 +83,6 @@ package() {
sha512sums="eb4575d8d3603097141991bc207a51f3ed9281d6e1432570666aeeb3299c86574e80724e27721e2f64844fe9efdfd99df898138e1d2053f143132d1b0e89414b linux-asus-z00vd-7957ae0b17bb46d56a5cddd1d313aec76296aee8.tar.gz
c0bbe3df4f9f1cbd89a3817377ab1ecc45b679c852d0376f4c3bff74cee8fe1c84e90acfb56db560664e752927989c91bf8562de24a73ae3b06fde032524a86c config-asus-z00vd.armv7
1db0eb57279ab2b0ad70e0f93dfe6faa0d807cf24832c2e55b2c726b43cdece84edfc614e6455cddddbce890de1df80e37fd1805b9fd6ccc259047c5ef7a6ba6 01_fix_warnings.patch
f60b91c7cffd1704e6ac51d1c352b87f74432fc645deff2ff4feeeffff3c441af425191254f871a999555b3abcd1d199eeba0c12dbef4d9364f4d70df4484976 02_gcc8_error.patch"
f60b91c7cffd1704e6ac51d1c352b87f74432fc645deff2ff4feeeffff3c441af425191254f871a999555b3abcd1d199eeba0c12dbef4d9364f4d70df4484976 02_gcc8_error.patch
c64bbad5e6f33e086d35e8f4e08ffc840b3bfb09fba49f635dd2eb671301cb8e5fd2915b3406a8bb7fce2de6638ce0337adcd14182316b7a5941ff84352744de 03_perf_python3.patch
b1aef615711138992101466b7fea4762698ba87620a55f748bd66f20a2114122678e85c3bb85ef0ae0d394552d2f4577535086a5d80a878459aadc9a9fb42ce0 04_dct_python3.patch"