summaryrefslogtreecommitdiff
path: root/src/sim/init.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/sim/init.cc')
-rw-r--r--src/sim/init.cc24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/sim/init.cc b/src/sim/init.cc
index 66ec40895..5a49f360a 100644
--- a/src/sim/init.cc
+++ b/src/sim/init.cc
@@ -191,7 +191,11 @@ EmbeddedPyBind::getMap()
return objs;
}
+#if PY_MAJOR_VERSION >= 3
+PyObject *
+#else
void
+#endif
EmbeddedPyBind::initAll()
{
std::list<EmbeddedPyBind *> pending;
@@ -226,13 +230,18 @@ EmbeddedPyBind::initAll()
}
}
}
+
+#if PY_MAJOR_VERSION >= 3
+ return m_m5.ptr();
+#endif
}
-int
-initM5Python()
+void
+registerNativeModules()
{
- EmbeddedPyBind::initAll();
- return EmbeddedPython::initAll();
+ auto result = PyImport_AppendInittab("_m5", EmbeddedPyBind::initAll);
+ if (result == -1)
+ panic("Failed to add _m5 to Python's inittab\n");
}
/*
@@ -307,10 +316,3 @@ m5Main(int argc, char **_argv)
return 0;
}
-
-PyMODINIT_FUNC
-initm5(void)
-{
- initM5Python();
- PyImport_ImportModule(PyCC("m5"));
-}