// Need to find standard way to not print
// this info. Maybe add bool variable to
// class?
- if (mnemonic != "syscall") {
+ if (strcmp(mnemonic, "syscall") != 0) {
if(_numDestRegs > 0){
printReg(ss, _destRegIdx[0]);
}
// Should we define a separate inst. class
// just for two insts?
- if(mnemonic == "sll" || mnemonic == "sra"){
+ if (strcmp(mnemonic, "sll") == 0 || strcmp(mnemonic, "sra") == 0) {
ccprintf(ss,", %d",SA);
}
ccprintf(ss, "%-10s ", mnemonic);
- if ( mnemonic == "jal" ) {
+ if (strcmp(mnemonic, "jal") == 0) {
Addr npc = pc + 4;
ccprintf(ss,"0x%x",(npc & 0xF0000000) | disp);
} else if (_numSrcRegs == 0) {
{
//If Bit 15 is 1 then Sign Extend
int32_t temp = sextImm & 0x00008000;
- if (temp > 0 && mnemonic != "lui") {
+ if (temp > 0 && strcmp(mnemonic, "lui") != 0) {
sextImm |= 0xFFFF0000;
}
}
ss << ", ";
}
- if( mnemonic == "lui")
+ if (strcmp(mnemonic, "lui") == 0)
ccprintf(ss, "0x%x ", sextImm);
else
ss << (int) sextImm;
{
std::stringstream ss;
- if (mnemonic == "mttc0" || mnemonic == "mftc0") {
+ if (strcmp(mnemonic, "mttc0") == 0 || strcmp(mnemonic, "mftc0") == 0) {
ccprintf(ss, "%-10s r%d, r%d, %d", mnemonic, RT, RD, SEL);
- } else if (mnemonic == "mftgpr") {
+ } else if (strcmp(mnemonic, "mftgpr") == 0) {
ccprintf(ss, "%-10s r%d, r%d", mnemonic, RD, RT);
} else {
ccprintf(ss, "%-10s r%d, r%d", mnemonic, RT, RD);
FOrdered=0xF
};
- extern char * CondTestAbbrev[];
+ extern const char *CondTestAbbrev[];
/**
* Base class for all SPARC static instructions.
output decoder {{
- char * CondTestAbbrev[] =
+ const char *CondTestAbbrev[] =
{
"nev", //Never
"e", //Equal
{"", "t%db", "t%dw", "", "t%dd", "", "", "", "t%d"};
if (reg < FP_Base_DepTag) {
- char * suffix = "";
+ const char * suffix = "";
bool fold = reg & (1 << 6);
reg &= ~(1 << 6);
}
uint64_t
-procInfo(char *filename, char *target)
+procInfo(const char *filename, const char *target)
{
int done = 0;
char line[80];
std::string &hostname();
-uint64_t procInfo(char *filename, char *target);
+uint64_t procInfo(const char *filename, const char *target);
inline uint64_t memUsage()
{ return procInfo("/proc/self/status", "VmSize:"); }
int arg_count = cppArgs.size();
- char **args = new char *[arg_count + 20];
+ const char **args = new const char *[arg_count + 20];
int nextArg = 0;
args[nextArg++] = "g++";
if (dup2(tmp_fd, STDOUT_FILENO) == -1)
exit(1);
- execvp("g++", args);
+ // execvp signature is intentionally broken wrt const-ness for
+ // backwards compatibility... see man page
+ execvp("g++", const_cast<char * const *>(args));
exit(0);
}
// Utility methods for pretty printing a report about a difference
//
-inline char * genCenteredLabel(int length, char * buffer, char * label)
+inline char * genCenteredLabel(int length, char * buffer, const char * label)
{
int labelLength = strlen(label);
assert(labelLength <= length);
ccprintf(os, "--------------------+-----------------------+-----------------------\n");
}
-inline void printSectionHeader(ostream & os, char * name)
+inline void printSectionHeader(ostream & os, const char * name)
{
char sectionString[70];
genCenteredLabel(69, sectionString, name);
break;
case 's': {
- char *s = (char *)args;
+ const char *s = (const char *)args;
if (!s)
s = "<NULL>";
break;
case 's': {
- char *s = (char *)args;
+ const char *s = (const char *)args;
if (!s)
s = "<NULL>";
*/
extern "C" SimObject *convertSwigSimObjectPtr(PyObject *);
+// Python.h is notoriously not const-correct (for 2.4, anyway)... make
+// a little define here to reduce the noise and make it easier to
+// #ifdef away if Python.h gets fixed. Note there are a couple of
+// these in sim/main.cc as well that are handled without this define.
+#define PCC(s) const_cast<char *>(s)
+
+
SimObject *
resolveSimObject(const string &name)
{
- PyObject *module = PyImport_ImportModule("m5.SimObject");
+ PyObject *module = PyImport_ImportModule(PCC("m5.SimObject"));
if (module == NULL)
panic("Could not import m5.SimObject");
- PyObject *resolver = PyObject_GetAttrString(module, "resolveSimObject");
+ PyObject *resolver =
+ PyObject_GetAttrString(module, PCC("resolveSimObject"));
if (resolver == NULL) {
PyErr_Print();
panic("resolveSimObject: failed to find resolveSimObject");
}
- PyObject *ptr = PyObject_CallFunction(resolver, "(s)", name.c_str());
+ PyObject *ptr = PyObject_CallFunction(resolver, PCC("(s)"), name.c_str());
if (ptr == NULL) {
PyErr_Print();
panic("resolveSimObject: failure on call to Python for %s", name);
PyObject *dict;
PyObject *result;
- module = PyImport_AddModule("__main__");
+ module = PyImport_AddModule(const_cast<char*>("__main__"));
if (module == NULL)
fatal("Could not import __main__");
if (setenv("PYTHONPATH", pythonpath.c_str(), true) == -1)
fatal("setenv: %s\n", strerror(errno));
- char *python_home = getenv("PYTHONHOME");
+ const char *python_home = getenv("PYTHONHOME");
if (!python_home)
python_home = PYTHONHOME;
- Py_SetPythonHome(python_home);
+ Py_SetPythonHome(const_cast<char*>(python_home));
// initialize embedded Python interpreter
Py_Initialize();