From c80b2e38118a1156c762fa58766d51e146707efa Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Mon, 20 Apr 2020 07:49:19 -0700 Subject: [PATCH] dev,cpu: Make two very generic enums ScopedEnums. Two python Enum parameter types had some very generic elements which both include one named "none". When headers for both are included that creates a conflict which breaks the build. Enums which such extremely generic names need to be scoped so that they don't invite these sorts of collisions. This change converts them from Enum to ScopedEnum in python, and also makes a few small changes to where they're used in c++ to match. Issue-on: https://gem5.atlassian.net/browse/GEM5-447 Change-Id: Ibda6e6cfcd700a618f8c68d174f33ec1e178b9ac Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/27950 Reviewed-by: Giacomo Travaglini Reviewed-by: Nikos Nikoleris Maintainer: Gabe Black Tested-by: kokoro --- src/cpu/testers/traffic_gen/BaseTrafficGen.py | 2 +- src/cpu/testers/traffic_gen/stream_gen.cc | 6 +++--- src/dev/serial/Terminal.py | 3 ++- src/dev/serial/terminal.cc | 8 ++++---- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/cpu/testers/traffic_gen/BaseTrafficGen.py b/src/cpu/testers/traffic_gen/BaseTrafficGen.py index f9ed64b30..0dda4ecfe 100644 --- a/src/cpu/testers/traffic_gen/BaseTrafficGen.py +++ b/src/cpu/testers/traffic_gen/BaseTrafficGen.py @@ -42,7 +42,7 @@ from m5.objects.ClockedObject import ClockedObject # and are meant to initialize the stream and substream IDs for # every memory request, regardless of how the packet has been # generated (Random, Linear, Trace etc) -class StreamGenType(Enum): vals = [ 'none', 'fixed', 'random' ] +class StreamGenType(ScopedEnum): vals = [ 'none', 'fixed', 'random' ] # The traffic generator is a master module that generates stimuli for # the memory system, based on a collection of simple behaviours that diff --git a/src/cpu/testers/traffic_gen/stream_gen.cc b/src/cpu/testers/traffic_gen/stream_gen.cc index d8b9263fe..1f65d9af3 100644 --- a/src/cpu/testers/traffic_gen/stream_gen.cc +++ b/src/cpu/testers/traffic_gen/stream_gen.cc @@ -43,11 +43,11 @@ StreamGen* StreamGen::create(const BaseTrafficGenParams *p) { switch (p->stream_gen) { - case Enums::fixed: + case StreamGenType::fixed: return new FixedStreamGen(p); - case Enums::random: + case StreamGenType::random: return new RandomStreamGen(p); - case Enums::none: + case StreamGenType::none: default: return nullptr; } diff --git a/src/dev/serial/Terminal.py b/src/dev/serial/Terminal.py index 6dabdcddb..49d573762 100644 --- a/src/dev/serial/Terminal.py +++ b/src/dev/serial/Terminal.py @@ -42,7 +42,8 @@ from m5.proxy import * from m5.objects.Serial import SerialDevice -class TerminalDump(Enum): vals = ["none", "stdoutput", "stderror", "file"] +class TerminalDump(ScopedEnum): vals = [ + "none", "stdoutput", "stderror", "file"] class Terminal(SerialDevice): type = 'Terminal' diff --git a/src/dev/serial/terminal.cc b/src/dev/serial/terminal.cc index 45c0bc6ec..7cfc6d745 100644 --- a/src/dev/serial/terminal.cc +++ b/src/dev/serial/terminal.cc @@ -146,13 +146,13 @@ OutputStream * Terminal::terminalDump(const TerminalParams* p) { switch (p->outfile) { - case Enums::TerminalDump::none: + case TerminalDump::none: return nullptr; - case Enums::TerminalDump::stdoutput: + case TerminalDump::stdoutput: return simout.findOrCreate("stdout"); - case Enums::TerminalDump::stderror: + case TerminalDump::stderror: return simout.findOrCreate("stderr"); - case Enums::TerminalDump::file: + case TerminalDump::file: return simout.findOrCreate(p->name); default: panic("Invalid option\n"); -- 2.30.2