Gabe Black has submitted this change. (
https://gem5-review.googlesource.com/c/public/gem5/+/39537 )
Change subject: sim: Stop "using namespace std"
......................................................................
sim: Stop "using namespace std"
Change-Id: Ic641cb82a069ccb2b185d74a3b49a96b27111035
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/39537
Reviewed-by: Gabe Black <[email protected]>
Maintainer: Gabe Black <[email protected]>
Tested-by: kokoro <[email protected]>
---
M src/sim/core.cc
M src/sim/debug.cc
M src/sim/eventq.cc
M src/sim/init.cc
M src/sim/init_signals.cc
M src/sim/process.cc
M src/sim/pseudo_inst.cc
M src/sim/serialize.cc
M src/sim/sim_events.cc
M src/sim/sim_object.cc
M src/sim/stat_control.cc
M src/sim/syscall_emul.cc
M src/sim/syscall_emul.hh
M src/sim/system.cc
14 files changed, 70 insertions(+), 88 deletions(-)
Approvals:
Gabe Black: Looks good to me, approved; Looks good to me, approved
kokoro: Regressions pass
diff --git a/src/sim/core.cc b/src/sim/core.cc
index ace699a..928e6c8 100644
--- a/src/sim/core.cc
+++ b/src/sim/core.cc
@@ -39,8 +39,6 @@
#include "base/output.hh"
#include "sim/eventq.hh"
-using namespace std;
-
namespace Gem5Internal
{
@@ -125,7 +123,7 @@
Tick getClockFrequency() { return _ticksPerSecond; }
void
-setOutputDir(const string &dir)
+setOutputDir(const std::string &dir)
{
simout.setDirectory(dir);
}
@@ -159,6 +157,6 @@
exitCallbacks().process();
exitCallbacks().clear();
- cout.flush();
+ std::cout.flush();
}
diff --git a/src/sim/debug.cc b/src/sim/debug.cc
index b2b3d45..4144caf 100644
--- a/src/sim/debug.cc
+++ b/src/sim/debug.cc
@@ -40,8 +40,6 @@
#include "sim/sim_exit.hh"
#include "sim/system.hh"
-using namespace std;
-
//
// Debug event: place a breakpoint on the process function and
// schedule the event to break at a particular cycle
diff --git a/src/sim/eventq.cc b/src/sim/eventq.cc
index adce51e..3e99683 100644
--- a/src/sim/eventq.cc
+++ b/src/sim/eventq.cc
@@ -43,8 +43,6 @@
#include "debug/Checkpoint.hh"
#include "sim/core.hh"
-using namespace std;
-
Tick simQuantum = 0;
//
@@ -54,7 +52,7 @@
// cycle, before the pipeline simulation is performed.
//
uint32_t numMainEventQueues = 0;
-vector<EventQueue *> mainEventQueue;
+std::vector<EventQueue *> mainEventQueue;
__thread EventQueue *_curEventQueue = NULL;
bool inParallelMode = false;
@@ -419,7 +417,7 @@
}
}
-EventQueue::EventQueue(const string &n)
+EventQueue::EventQueue(const std::string &n)
: objName(n), head(NULL), _curTick(0)
{
}
diff --git a/src/sim/init.cc b/src/sim/init.cc
index 73d4dbd..6abb0e1 100644
--- a/src/sim/init.cc
+++ b/src/sim/init.cc
@@ -65,7 +65,6 @@
#endif
-using namespace std;
namespace py = pybind11;
// The python library is totally messed up with respect to constness,
@@ -81,16 +80,16 @@
{
// if we've added the importer keep track of it because we need it
// to bootstrap.
- if (string(modpath) == string("importer"))
+ if (std::string(modpath) == std::string("importer"))
importer = this;
else
getList().push_back(this);
}
-list<EmbeddedPython *> &
+std::list<EmbeddedPython *> &
EmbeddedPython::getList()
{
- static list<EmbeddedPython *> the_list;
+ static std::list<EmbeddedPython *> the_list;
return the_list;
}
@@ -142,8 +141,8 @@
// Load the rest of the embedded python files into the embedded
// python importer
- list<EmbeddedPython *>::iterator i = getList().begin();
- list<EmbeddedPython *>::iterator end = getList().end();
+ std::list<EmbeddedPython *>::iterator i = getList().begin();
+ std::list<EmbeddedPython *>::iterator end = getList().end();
for (; i != end; ++i)
if (!(*i)->addModule())
return 1;
diff --git a/src/sim/init_signals.cc b/src/sim/init_signals.cc
index 305f0cf..db82682 100644
--- a/src/sim/init_signals.cc
+++ b/src/sim/init_signals.cc
@@ -61,8 +61,6 @@
#include "sim/core.hh"
#include "sim/eventq.hh"
-using namespace std;
-
// Use an separate stack for fatal signal handlers
static uint8_t fatalSigStack[2 * SIGSTKSZ];
@@ -146,7 +144,8 @@
{
const EventQueue *const eq(curEventQueue());
if (eq) {
- ccprintf(cerr, "Program aborted at tick %llu\n", eq->getCurTick());
+ ccprintf(std::cerr, "Program aborted at tick %llu\n",
+ eq->getCurTick());
} else {
STATIC_ERR("Program aborted\n\n");
}
diff --git a/src/sim/process.cc b/src/sim/process.cc
index 409b48a..1ae8d40 100644
--- a/src/sim/process.cc
+++ b/src/sim/process.cc
@@ -67,7 +67,6 @@
#include "sim/syscall_desc.hh"
#include "sim/system.hh"
-using namespace std;
using namespace TheISA;
namespace
@@ -127,7 +126,8 @@
_gid(params.gid), _egid(params.egid),
_pid(params.pid), _ppid(params.ppid),
_pgid(params.pgid), drivers(params.drivers),
- fds(make_shared<FDArray>(params.input, params.output,
params.errout)),
+ fds(std::make_shared<FDArray>(
+ params.input, params.output, params.errout)),
childClearTID(0),
ADD_STAT(numSyscalls, "Number of system calls")
{
@@ -189,7 +189,7 @@
* Duplicate the process memory address space. The state needs to
be
* copied over (rather than using pointers to share everything).
*/
- typedef std::vector<pair<Addr,Addr>> MapVec;
+ typedef std::vector<std::pair<Addr,Addr>> MapVec;
MapVec mappings;
pTable->getMappings(&mappings);
diff --git a/src/sim/pseudo_inst.cc b/src/sim/pseudo_inst.cc
index 0079ebd..9b51b9f 100644
--- a/src/sim/pseudo_inst.cc
+++ b/src/sim/pseudo_inst.cc
@@ -69,7 +69,6 @@
#include "sim/stats.hh"
#include "sim/system.hh"
-using namespace std;
using namespace Stats;
namespace PseudoInst
@@ -203,13 +202,13 @@
{
DPRINTF(PseudoInst, "PseudoInst::loadsymbol()\n");
- const string &filename = tc->getCpuPtr()->system->params().symbolfile;
+ const std::string &filename =
tc->getCpuPtr()->system->params().symbolfile;
if (filename.empty()) {
return;
}
std::string buffer;
- ifstream file(filename.c_str());
+ std::ifstream file(filename.c_str());
if (!file)
fatal("file error: Can't open symbol table file %s\n", filename);
@@ -220,17 +219,17 @@
if (buffer.empty())
continue;
- string::size_type idx = buffer.find(' ');
- if (idx == string::npos)
+ std::string::size_type idx = buffer.find(' ');
+ if (idx == std::string::npos)
continue;
- string address = "0x" + buffer.substr(0, idx);
+ std::string address = "0x" + buffer.substr(0, idx);
eat_white(address);
if (address.empty())
continue;
// Skip over letter and space
- string symbol = buffer.substr(idx + 3);
+ std::string symbol = buffer.substr(idx + 3);
eat_white(symbol);
if (symbol.empty())
continue;
@@ -278,11 +277,11 @@
// concatenate them in the key character buffer
const int len = 2 * sizeof(uint64_t) + 1;
char key[len];
- memset(key, '\0', len);
+ std::memset(key, '\0', len);
std::array<uint64_t, 2> key_regs = {{ key_str1, key_str2 }};
key_regs = letoh(key_regs);
- memcpy(key, key_regs.data(), sizeof(key_regs));
+ std::memcpy(key, key_regs.data(), sizeof(key_regs));
// Check key parameter to figure out what to return.
const std::string key_str(key);
@@ -359,7 +358,7 @@
DPRINTF(PseudoInst, "PseudoInst::readfile(0x%x, 0x%x, 0x%x)\n",
vaddr, len, offset);
- const string &file = tc->getSystemPtr()->params().readfile;
+ const std::string &file = tc->getSystemPtr()->params().readfile;
if (file.empty()) {
return ULL(0);
}
@@ -410,10 +409,11 @@
// do not truncate file if offset is non-zero
// (ios::in flag is required as well to keep the existing data
// intact, otherwise existing data will be zeroed out.)
- out = simout.open(filename, ios::in | ios::out | ios::binary,
true);
+ out = simout.open(filename,
+ std::ios::in | std::ios::out | std::ios::binary, true);
}
- ostream *os(out->stream());
+ std::ostream *os(out->stream());
if (!os)
panic("could not open file %s\n", filename);
diff --git a/src/sim/serialize.cc b/src/sim/serialize.cc
index a563332..e81f49d 100644
--- a/src/sim/serialize.cc
+++ b/src/sim/serialize.cc
@@ -65,8 +65,6 @@
// For stat reset hack
#include "sim/stat_control.hh"
-using namespace std;
-
int ckptMaxCount = 0;
int ckptCount = 0;
int ckptPrevCount = -1;
@@ -183,14 +181,14 @@
}
void
-Serializable::serializeAll(const string &cpt_dir)
+Serializable::serializeAll(const std::string &cpt_dir)
{
- string dir = CheckpointIn::setDir(cpt_dir);
+ std::string dir = CheckpointIn::setDir(cpt_dir);
if (mkdir(dir.c_str(), 0775) == -1 && errno != EEXIST)
fatal("couldn't mkdir %s\n", dir);
- string cpt_file = dir + CheckpointIn::baseFilename;
- ofstream outstream(cpt_file.c_str());
+ std::string cpt_file = dir + CheckpointIn::baseFilename;
+ std::ofstream outstream(cpt_file.c_str());
time_t t = time(NULL);
if (!outstream.is_open())
fatal("Unable to open file %s for writing\n", cpt_file.c_str());
@@ -246,30 +244,31 @@
const char *CheckpointIn::baseFilename = "m5.cpt";
-string CheckpointIn::currentDirectory;
+std::string CheckpointIn::currentDirectory;
-string
-CheckpointIn::setDir(const string &name)
+std::string
+CheckpointIn::setDir(const std::string &name)
{
// use csprintf to insert curTick() into directory name if it
// appears to have a format placeholder in it.
- currentDirectory = (name.find("%") != string::npos) ?
+ currentDirectory = (name.find("%") != std::string::npos) ?
csprintf(name, curTick()) : name;
if (currentDirectory[currentDirectory.size() - 1] != '/')
currentDirectory += "/";
return currentDirectory;
}
-string
+std::string
CheckpointIn::dir()
{
return currentDirectory;
}
-CheckpointIn::CheckpointIn(const string &cpt_dir, SimObjectResolver
&resolver)
+CheckpointIn::CheckpointIn(const std::string &cpt_dir,
+ SimObjectResolver &resolver)
: db(new IniFile), objNameResolver(resolver), _cptDir(setDir(cpt_dir))
{
- string filename = getCptDir() + "/" + CheckpointIn::baseFilename;
+ std::string filename = getCptDir() + "/" + CheckpointIn::baseFilename;
if (!db->load(filename)) {
fatal("Can't load checkpoint file '%s'\n", filename);
}
@@ -289,7 +288,7 @@
* we are looking in.
*/
bool
-CheckpointIn::entryExists(const string §ion, const string &entry)
+CheckpointIn::entryExists(const std::string §ion, const std::string
&entry)
{
return db->entryExists(section, entry);
}
@@ -304,7 +303,8 @@
* the value, given the section .
*/
bool
-CheckpointIn::find(const string §ion, const string &entry, string
&value)
+CheckpointIn::find(const std::string §ion, const std::string &entry,
+ std::string &value)
{
return db->find(section, entry, value);
}
@@ -319,10 +319,10 @@
*
*/
bool
-CheckpointIn::findObj(const string §ion, const string &entry,
+CheckpointIn::findObj(const std::string §ion, const std::string &entry,
SimObject *&value)
{
- string path;
+ std::string path;
if (!db->find(section, entry, path))
return false;
@@ -332,7 +332,7 @@
}
bool
-CheckpointIn::sectionExists(const string §ion)
+CheckpointIn::sectionExists(const std::string §ion)
{
return db->sectionExists(section);
}
@@ -345,16 +345,16 @@
}
void
-objParamIn(CheckpointIn &cp, const string &name, SimObject * ¶m)
+objParamIn(CheckpointIn &cp, const std::string &name, SimObject * ¶m)
{
- const string §ion(Serializable::currentSection());
+ const std::string §ion(Serializable::currentSection());
if (!cp.findObj(section, name, param)) {
fatal("Can't unserialize '%s:%s'\n", section, name);
}
}
void
-debug_serialize(const string &cpt_dir)
+debug_serialize(const std::string &cpt_dir)
{
Serializable::serializeAll(cpt_dir);
}
diff --git a/src/sim/sim_events.cc b/src/sim/sim_events.cc
index 5888ea0..af516d3 100644
--- a/src/sim/sim_events.cc
+++ b/src/sim/sim_events.cc
@@ -50,8 +50,6 @@
#include "sim/sim_exit.hh"
#include "sim/stats.hh"
-using namespace std;
-
GlobalSimLoopExitEvent::GlobalSimLoopExitEvent(Tick when,
const std::string &_cause,
int c, Tick r)
diff --git a/src/sim/sim_object.cc b/src/sim/sim_object.cc
index 58780b2..17dbd1d 100644
--- a/src/sim/sim_object.cc
+++ b/src/sim/sim_object.cc
@@ -35,9 +35,6 @@
#include "debug/Checkpoint.hh"
#include "sim/probe/probe.hh"
-using namespace std;
-
-
////////////////////////////////////////////////////////////////////////
//
// SimObject member definitions
@@ -148,7 +145,7 @@
// static function: flag which objects should have the debugger break
//
void
-SimObject::debugObjectBreak(const string &objs)
+SimObject::debugObjectBreak(const std::string &objs)
{
SimObjectList::const_iterator i = simObjectList.begin();
SimObjectList::const_iterator end = simObjectList.end();
diff --git a/src/sim/stat_control.cc b/src/sim/stat_control.cc
index 8189bfe..a78e69c 100644
--- a/src/sim/stat_control.cc
+++ b/src/sim/stat_control.cc
@@ -54,8 +54,6 @@
#include "base/time.hh"
#include "sim/global_event.hh"
-using namespace std;
-
namespace Stats {
GlobalEvent *dumpEvent;
diff --git a/src/sim/syscall_emul.cc b/src/sim/syscall_emul.cc
index fd5699c..c85d893 100644
--- a/src/sim/syscall_emul.cc
+++ b/src/sim/syscall_emul.cc
@@ -53,7 +53,6 @@
#include "sim/syscall_desc.hh"
#include "sim/system.hh"
-using namespace std;
using namespace TheISA;
void
@@ -321,7 +320,7 @@
return -errno;
// Assuming that the size of loff_t is 64 bits on the target platform
BufferArg result_buf(result_ptr, sizeof(result));
- memcpy(result_buf.bufferPtr(), &result, sizeof(result));
+ std::memcpy(result_buf.bufferPtr(), &result, sizeof(result));
result_buf.copyOut(tc->getVirtProxy());
return 0;
}
@@ -368,7 +367,7 @@
BufferArg buf(buf_ptr, size);
// Is current working directory defined?
- string cwd = p->tgtCwd;
+ std::string cwd = p->tgtCwd;
if (!cwd.empty()) {
if (cwd.length() >= size) {
// Buffer too small
@@ -393,7 +392,7 @@
readlinkFunc(SyscallDesc *desc, ThreadContext *tc,
Addr pathname, Addr buf_ptr, size_t bufsiz)
{
- string path;
+ std::string path;
auto p = tc->getProcessPtr();
if (!tc->getVirtProxy().tryReadString(path, pathname))
@@ -450,7 +449,7 @@
SyscallReturn
unlinkFunc(SyscallDesc *desc, ThreadContext *tc, Addr pathname)
{
- string path;
+ std::string path;
auto p = tc->getProcessPtr();
if (!tc->getVirtProxy().tryReadString(path, pathname))
@@ -466,8 +465,8 @@
linkFunc(SyscallDesc *desc, ThreadContext *tc,
Addr pathname, Addr new_pathname)
{
- string path;
- string new_path;
+ std::string path;
+ std::string new_path;
auto p = tc->getProcessPtr();
auto &virt_mem = tc->getVirtProxy();
@@ -487,8 +486,8 @@
symlinkFunc(SyscallDesc *desc, ThreadContext *tc,
Addr pathname, Addr new_pathname)
{
- string path;
- string new_path;
+ std::string path;
+ std::string new_path;
auto p = tc->getProcessPtr();
auto &virt_mem = tc->getVirtProxy();
@@ -523,11 +522,11 @@
{
auto p = tc->getProcessPtr();
- string old_name;
+ std::string old_name;
if (!tc->getVirtProxy().tryReadString(old_name, oldpath))
return -EFAULT;
- string new_name;
+ std::string new_name;
if (!tc->getVirtProxy().tryReadString(new_name, newpath))
return -EFAULT;
@@ -542,7 +541,7 @@
SyscallReturn
truncateFunc(SyscallDesc *desc, ThreadContext *tc, Addr pathname, off_t
length)
{
- string path;
+ std::string path;
auto p = tc->getProcessPtr();
if (!tc->getVirtProxy().tryReadString(path, pathname))
@@ -574,7 +573,7 @@
Addr pathname, int64_t length)
{
auto process = tc->getProcessPtr();
- string path;
+ std::string path;
if (!tc->getVirtProxy().tryReadString(path, pathname))
return -EFAULT;
@@ -624,7 +623,7 @@
chownFunc(SyscallDesc *desc, ThreadContext *tc,
Addr pathname, uint32_t owner, uint32_t group)
{
- string path;
+ std::string path;
auto p = tc->getProcessPtr();
if (!tc->getVirtProxy().tryReadString(path, pathname))
@@ -998,7 +997,7 @@
accessFunc(SyscallDesc *desc, ThreadContext *tc,
Addr pathname, mode_t mode)
{
- string path;
+ std::string path;
auto p = tc->getProcessPtr();
if (!tc->getVirtProxy().tryReadString(path, pathname))
return -EFAULT;
diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh
index 79cd35a..581e8db 100644
--- a/src/sim/syscall_emul.hh
+++ b/src/sim/syscall_emul.hh
@@ -372,8 +372,6 @@
futexFunc(SyscallDesc *desc, ThreadContext *tc,
Addr uaddr, int op, int val, int timeout, Addr uaddr2, int val3)
{
- using namespace std;
-
auto process = tc->getProcessPtr();
/*
diff --git a/src/sim/system.cc b/src/sim/system.cc
index 80aa2fb..f2f10bc 100644
--- a/src/sim/system.cc
+++ b/src/sim/system.cc
@@ -71,10 +71,9 @@
#include "sim/full_system.hh"
#include "sim/redirect_path.hh"
-using namespace std;
using namespace TheISA;
-vector<System *> System::systemList;
+std::vector<System *> System::systemList;
void
System::Threads::Thread::resume()
@@ -484,7 +483,7 @@
for (uint32_t j = 0; j < numWorkIds ; j++) {
workItemStats[j] = new Stats::Histogram(this);
- stringstream namestr;
+ std::stringstream namestr;
ccprintf(namestr, "work_item_type%d", j);
workItemStats[j]->init(20)
.name(name() + "." + namestr.str())
@@ -513,16 +512,17 @@
void
System::printSystems()
{
- ios::fmtflags flags(cerr.flags());
+ std::ios::fmtflags flags(std::cerr.flags());
- vector<System *>::iterator i = systemList.begin();
- vector<System *>::iterator end = systemList.end();
+ std::vector<System *>::iterator i = systemList.begin();
+ std::vector<System *>::iterator end = systemList.end();
for (; i != end; ++i) {
System *sys = *i;
- cerr << "System " << sys->name() << ": " << hex << sys << endl;
+ std::cerr << "System " << sys->name() << ": " << std::hex << sys
+ << std::endl;
}
- cerr.flags(flags);
+ std::cerr.flags(flags);
}
void
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/39537
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: Ic641cb82a069ccb2b185d74a3b49a96b27111035
Gerrit-Change-Number: 39537
Gerrit-PatchSet: 6
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-Reviewer: Andreas Sandberg <[email protected]>
Gerrit-Reviewer: Daniel Carvalho <[email protected]>
Gerrit-Reviewer: Gabe Black <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
Gerrit-Reviewer: kokoro <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s