From 422db3e21d15ba57746aefeefa82eb5b0a37abaf Mon Sep 17 00:00:00 2001 From: Horst Schirmeier Date: Thu, 14 Mar 2013 18:13:13 +0100 Subject: [PATCH] core/util: indirection to CommandLine class added to make bochs compile If CommandLine.hpp and (indirectly) optionparser.h is #included in FailBochsInit.ah, bochs compilation fails (for, e.g., gui/x.cc, at least on Debian 6). --- src/core/sal/bochs/BochsController.cc | 6 ++++++ src/core/sal/bochs/BochsController.hpp | 14 ++++++++++++++ src/core/sal/bochs/FailBochsInit.ah | 3 +-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/core/sal/bochs/BochsController.cc b/src/core/sal/bochs/BochsController.cc index 6095f71f..1a3c14aa 100644 --- a/src/core/sal/bochs/BochsController.cc +++ b/src/core/sal/bochs/BochsController.cc @@ -4,6 +4,7 @@ #include "BochsMemory.hpp" #include "../SALInst.hpp" #include "../Listener.hpp" +#include "util/CommandLine.hpp" namespace fail { @@ -173,4 +174,9 @@ ConcreteCPU& BochsController::detectCPU(BX_CPU_C* pCPU) const return getCPU(i); } +void BochsController::collectCommandLineArguments(int argc, char **argv) const +{ + CommandLine::Inst().collect_args(bx_startup_flags.argc, bx_startup_flags.argv); +} + } // end-of-namespace: fail diff --git a/src/core/sal/bochs/BochsController.hpp b/src/core/sal/bochs/BochsController.hpp index f3de852e..05cb7877 100644 --- a/src/core/sal/bochs/BochsController.hpp +++ b/src/core/sal/bochs/BochsController.hpp @@ -150,6 +150,20 @@ public: * @see The uses SimulatorController::getCPU(). */ ConcreteCPU& detectCPU(BX_CPU_C* pCPU) const; + +protected: + /** + * Hack: Indirection for commandline argument collection + * + * This prevents CommandLine.hpp (and optionparser.h) from being pulled + * inbe to every single Bochs translation unit via FailBochsInit.ah, + * leading to compilation errors in some of them. + * TODO: Move this upwards to SimulatorController? + * + * @param argc main()'s argument counter + * @param argv main()'s argument value vector + */ + void collectCommandLineArguments(int argc, char **argv) const; }; } // end-of-namespace: fail diff --git a/src/core/sal/bochs/FailBochsInit.ah b/src/core/sal/bochs/FailBochsInit.ah index 5b64ee4d..63a82082 100644 --- a/src/core/sal/bochs/FailBochsInit.ah +++ b/src/core/sal/bochs/FailBochsInit.ah @@ -6,12 +6,11 @@ #ifdef BUILD_BOCHS #include "../SALInst.hpp" -#include "util/CommandLine.hpp" aspect FailBochsInit { advice call("int bxmain()") : before () { - fail::CommandLine::Inst().collect_args(bx_startup_flags.argc, bx_startup_flags.argv); + fail::simulator.collectCommandLineArguments(bx_startup_flags.argc, bx_startup_flags.argv); fail::simulator.startup(); } };