sim: Stop "using namespace std"

Change-Id: Ic641cb82a069ccb2b185d74a3b49a96b27111035
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/39537
Reviewed-by: Gabe Black <gabe.black@gmail.com>
Maintainer: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Gabe Black
2021-01-20 23:14:24 -08:00
parent f5c18ada1b
commit 592b075fc8
14 changed files with 70 additions and 88 deletions

View File

@@ -39,8 +39,6 @@
#include "base/output.hh"
#include "sim/eventq.hh"
using namespace std;
namespace Gem5Internal
{
@@ -125,7 +123,7 @@ setClockFrequency(Tick tps)
Tick getClockFrequency() { return _ticksPerSecond; }
void
setOutputDir(const string &dir)
setOutputDir(const std::string &dir)
{
simout.setDirectory(dir);
}
@@ -159,6 +157,6 @@ doExitCleanup()
exitCallbacks().process();
exitCallbacks().clear();
cout.flush();
std::cout.flush();
}

View File

@@ -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

View File

@@ -43,8 +43,6 @@
#include "debug/Checkpoint.hh"
#include "sim/core.hh"
using namespace std;
Tick simQuantum = 0;
//
@@ -54,7 +52,7 @@ Tick simQuantum = 0;
// 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 @@ Event::dump() const
}
}
EventQueue::EventQueue(const string &n)
EventQueue::EventQueue(const std::string &n)
: objName(n), head(NULL), _curTick(0)
{
}

View File

@@ -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 @@ EmbeddedPython::EmbeddedPython(const char *filename, const char *abspath,
{
// 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 @@ EmbeddedPython::initAll()
// 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;

View File

@@ -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 @@ abortHandler(int sigtype)
{
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");
}

View File

@@ -67,7 +67,6 @@
#include "sim/syscall_desc.hh"
#include "sim/system.hh"
using namespace std;
using namespace TheISA;
namespace
@@ -127,7 +126,8 @@ Process::Process(const ProcessParams &params, EmulationPageTable *pTable,
_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 @@ Process::clone(ThreadContext *otc, ThreadContext *ntc,
* 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);

View File

@@ -69,7 +69,6 @@
#include "sim/stats.hh"
#include "sim/system.hh"
using namespace std;
using namespace Stats;
namespace PseudoInst
@@ -203,13 +202,13 @@ loadsymbol(ThreadContext *tc)
{
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 @@ loadsymbol(ThreadContext *tc)
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 @@ initParam(ThreadContext *tc, uint64_t key_str1, uint64_t key_str2)
// 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 @@ readfile(ThreadContext *tc, Addr vaddr, uint64_t len, uint64_t offset)
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 @@ writefile(ThreadContext *tc, Addr vaddr, uint64_t len, uint64_t offset,
// 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);

View File

@@ -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 @@ Serializable::unserializeSection(CheckpointIn &cp, const char *name)
}
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 @@ Serializable::currentSection()
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 @@ CheckpointIn::~CheckpointIn()
* we are looking in.
*/
bool
CheckpointIn::entryExists(const string &section, const string &entry)
CheckpointIn::entryExists(const std::string &section, const std::string &entry)
{
return db->entryExists(section, entry);
}
@@ -304,7 +303,8 @@ CheckpointIn::entryExists(const string &section, const string &entry)
* the value, given the section .
*/
bool
CheckpointIn::find(const string &section, const string &entry, string &value)
CheckpointIn::find(const std::string &section, const std::string &entry,
std::string &value)
{
return db->find(section, entry, value);
}
@@ -319,10 +319,10 @@ CheckpointIn::find(const string &section, const string &entry, string &value)
*
*/
bool
CheckpointIn::findObj(const string &section, const string &entry,
CheckpointIn::findObj(const std::string &section, const std::string &entry,
SimObject *&value)
{
string path;
std::string path;
if (!db->find(section, entry, path))
return false;
@@ -332,7 +332,7 @@ CheckpointIn::findObj(const string &section, const string &entry,
}
bool
CheckpointIn::sectionExists(const string &section)
CheckpointIn::sectionExists(const std::string &section)
{
return db->sectionExists(section);
}
@@ -345,16 +345,16 @@ CheckpointIn::visitSection(const std::string &section,
}
void
objParamIn(CheckpointIn &cp, const string &name, SimObject * &param)
objParamIn(CheckpointIn &cp, const std::string &name, SimObject * &param)
{
const string &section(Serializable::currentSection());
const std::string &section(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);
}

View File

@@ -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)

View File

@@ -35,9 +35,6 @@
#include "debug/Checkpoint.hh"
#include "sim/probe/probe.hh"
using namespace std;
////////////////////////////////////////////////////////////////////////
//
// SimObject member definitions
@@ -148,7 +145,7 @@ SimObject::serializeAll(CheckpointOut &cp)
// 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();

View File

@@ -54,8 +54,6 @@
#include "base/time.hh"
#include "sim/global_event.hh"
using namespace std;
namespace Stats {
GlobalEvent *dumpEvent;

View File

@@ -53,7 +53,6 @@
#include "sim/syscall_desc.hh"
#include "sim/system.hh"
using namespace std;
using namespace TheISA;
void
@@ -321,7 +320,7 @@ _llseekFunc(SyscallDesc *desc, ThreadContext *tc,
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 @@ getcwdFunc(SyscallDesc *desc, ThreadContext *tc,
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 @@ SyscallReturn
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 @@ readlinkFunc(SyscallDesc *desc, ThreadContext *tc,
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 @@ SyscallReturn
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 @@ SyscallReturn
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 @@ renameFunc(SyscallDesc *desc, ThreadContext *tc, Addr oldpath, Addr newpath)
{
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 @@ renameFunc(SyscallDesc *desc, ThreadContext *tc, Addr oldpath, Addr newpath)
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 @@ truncate64Func(SyscallDesc *desc, ThreadContext *tc,
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 @@ SyscallReturn
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 @@ SyscallReturn
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;

View File

@@ -372,8 +372,6 @@ SyscallReturn
futexFunc(SyscallDesc *desc, ThreadContext *tc,
Addr uaddr, int op, int val, int timeout, Addr uaddr2, int val3)
{
using namespace std;
auto process = tc->getProcessPtr();
/*

View File

@@ -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 @@ System::regStats()
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 @@ System::workItemEnd(uint32_t tid, uint32_t workid)
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