Gabe Black has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/49417 )

Change subject: sim: Collapse gem5Main into main.
......................................................................

sim: Collapse gem5Main into main.

gem5Main is short and simple and only calls into python's m5.main()
function. It's also only called from one place and only makes sense to
call from one place, so lets just put it there inline and keep
everything together.

Change-Id: I17e303e3a29d5473f0f31cd51d7fb367f6c81f9e
---
M src/sim/init.cc
M src/sim/init.hh
M src/sim/main.cc
3 files changed, 21 insertions(+), 33 deletions(-)



diff --git a/src/sim/init.cc b/src/sim/init.cc
index f24999f..c8a545f 100644
--- a/src/sim/init.cc
+++ b/src/sim/init.cc
@@ -191,33 +191,4 @@
     EmbeddedPyBind::initAll(_m5);
 }

-/*
- * Start up the M5 simulator.  This mostly vectors into the python
- * main function.
- */
-int
-gem5Main(int argc, char **argv)
-{
-    // Embedded python doesn't set up sys.argv, so we'll do that ourselves.
-    py::list py_argv;
-    auto sys = py::module::import("sys");
-    if (py::hasattr(sys, "argv")) {
-        // sys.argv already exists, so grab that.
-        py_argv = sys.attr("argv");
-    } else {
-        // sys.argv doesn't exist, so create it.
-        sys.add_object("argv", py_argv);
-    }
-    // Clear out argv just in case it has something in it.
-    py_argv.attr("clear")();
-
-    // Fill it with our argvs.
-    for (int i = 0; i < argc; i++)
-        py_argv.append(argv[i]);
-
-    py::module_::import("m5").attr("main")();
-
-    return 0;
-}
-
 } // namespace gem5
diff --git a/src/sim/init.hh b/src/sim/init.hh
index b4c248d..95c597b 100644
--- a/src/sim/init.hh
+++ b/src/sim/init.hh
@@ -98,8 +98,6 @@
     static std::map<std::string, EmbeddedPyBind *> &getMap();
 };

-int gem5Main(int argc, char **argv);
-
 } // namespace gem5

 #endif // __SIM_INIT_HH__
diff --git a/src/sim/main.cc b/src/sim/main.cc
index c89e67f..612785a 100644
--- a/src/sim/main.cc
+++ b/src/sim/main.cc
@@ -41,7 +41,7 @@
 // main() is now pretty stripped down and just sets up python and then
 // calls EmbeddedPython::initAll which loads the various embedded python
 // modules into the python environment and then starts things running by
-// calling gem5Main.
+// running python's m5.main().
 int
 main(int argc, char **argv)
 {
@@ -63,5 +63,24 @@
     auto importer = py::module_::import("importer");
     importer.attr("install")();

-    return gem5Main(argc, argv);
+    // Embedded python doesn't set up sys.argv, so we'll do that ourselves.
+    py::list py_argv;
+    auto sys = py::module::import("sys");
+    if (py::hasattr(sys, "argv")) {
+        // sys.argv already exists, so grab that.
+        py_argv = sys.attr("argv");
+    } else {
+        // sys.argv doesn't exist, so create it.
+        sys.add_object("argv", py_argv);
+    }
+    // Clear out argv just in case it has something in it.
+    py_argv.attr("clear")();
+
+    // Fill it with our argvs.
+    for (int i = 0; i < argc; i++)
+        py_argv.append(argv[i]);
+
+    py::module_::import("m5").attr("main")();
+
+    return 0;
 }

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/49417
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I17e303e3a29d5473f0f31cd51d7fb367f6c81f9e
Gerrit-Change-Number: 49417
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to