summaryrefslogtreecommitdiff
path: root/sim
diff options
context:
space:
mode:
authorKevin Lim <ktlim@umich.edu>2005-01-18 13:02:47 -0500
committerKevin Lim <ktlim@umich.edu>2005-01-18 13:02:47 -0500
commitaed3e6780a54f2d4f008a8cf7f66e2bbdc788a0d (patch)
treef48c9d361d04cc6276ef33a9898eb0ac61de36d7 /sim
parent783f701247a1013a32d7caab324660c211215a11 (diff)
parentf31a27a030d2e93fef2934aa8642609bb38974af (diff)
downloadgem5-aed3e6780a54f2d4f008a8cf7f66e2bbdc788a0d.tar.xz
Merge changes to make m5 g++ 3.4 compatible.
sim/param.cc: Merge changes. --HG-- extra : convert_revision : b5044e1f7c48ae2d74d5233dd4fabfb7a801d7c8
Diffstat (limited to 'sim')
-rw-r--r--sim/eventq.hh34
-rw-r--r--sim/param.cc8
-rw-r--r--sim/param.hh9
-rw-r--r--sim/serialize.cc1
-rw-r--r--sim/startup.cc24
-rw-r--r--sim/syscall_emul.hh84
-rw-r--r--sim/universe.cc1
7 files changed, 89 insertions, 72 deletions
diff --git a/sim/eventq.hh b/sim/eventq.hh
index 304e4b16a..d62e7df10 100644
--- a/sim/eventq.hh
+++ b/sim/eventq.hh
@@ -30,8 +30,8 @@
* EventQueue interfaces
*/
-#ifndef __EVENTQ_HH__
-#define __EVENTQ_HH__
+#ifndef __SIM_EVENTQ_HH__
+#define __SIM_EVENTQ_HH__
#include <assert.h>
@@ -43,11 +43,24 @@
#include "sim/host.hh" // for Tick
#include "base/fast_alloc.hh"
-#include "sim/serialize.hh"
#include "base/trace.hh"
+#include "sim/serialize.hh"
class EventQueue; // forward declaration
+//////////////////////
+//
+// Main Event Queue
+//
+// Events on this queue are processed at the *beginning* of each
+// cycle, before the pipeline simulation is performed.
+//
+// defined in eventq.cc
+//
+//////////////////////
+extern EventQueue mainEventQueue;
+
+
/*
* An item on an event queue. The action caused by a given
* event is specified by deriving a subclass and overriding the
@@ -228,7 +241,7 @@ DelayFunction(Tick when, T *object)
public:
DelayEvent(Tick when, T *o)
: Event(&mainEventQueue), object(o)
- { setFlags(AutoDestroy); schedule(when); }
+ { setFlags(this->AutoDestroy); schedule(when); }
void process() { (object->*F)(); }
const char *description() { return "delay"; }
};
@@ -386,16 +399,5 @@ EventQueue::reschedule(Event *event)
}
-//////////////////////
-//
-// Main Event Queue
-//
-// Events on this queue are processed at the *beginning* of each
-// cycle, before the pipeline simulation is performed.
-//
-// defined in eventq.cc
-//
-//////////////////////
-extern EventQueue mainEventQueue;
-#endif // __EVENTQ_HH__
+#endif // __SIM_EVENTQ_HH__
diff --git a/sim/param.cc b/sim/param.cc
index d666463c9..d16578a2d 100644
--- a/sim/param.cc
+++ b/sim/param.cc
@@ -493,11 +493,11 @@ EnumVectorParam<Map>::showType(ostream &os) const
showEnumType(os, map, num_values);
}
-template EnumParam<const char *>;
-template EnumVectorParam<const char *>;
+template class EnumParam<const char *>;
+template class EnumVectorParam<const char *>;
-template EnumParam<EnumParamMap>;
-template EnumVectorParam<EnumParamMap>;
+template class EnumParam<EnumParamMap>;
+template class EnumVectorParam<EnumParamMap>;
////////////////////////////////////////////////////////////////////////
//
diff --git a/sim/param.hh b/sim/param.hh
index ac57afa31..f4b9d3450 100644
--- a/sim/param.hh
+++ b/sim/param.hh
@@ -26,9 +26,10 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef __PARAM_HH__
-#define __PARAM_HH__
+#ifndef __SIM_PARAM_HH__
+#define __SIM_PARAM_HH__
+#include <iostream>
#include <list>
#include <string>
#include <vector>
@@ -524,7 +525,7 @@ class MappedEnumParam : public EnumParam<EnumParamMap>
{
if (!isValid())
die("not found");
- return (ENUM)value[n];
+ return (ENUM)value[this->n];
}
};
@@ -782,4 +783,4 @@ SimObjectVectorParam<OBJ_CLASS *>::showType(std::ostream &os) const \
template <class T> bool parseParam(const std::string &str, T &data);
template <class T> void showParam(std::ostream &os, const T &data);
-#endif // _PARAM_HH
+#endif // _SIM_PARAM_HH_
diff --git a/sim/serialize.cc b/sim/serialize.cc
index 2a5e3d398..3a073f68d 100644
--- a/sim/serialize.cc
+++ b/sim/serialize.cc
@@ -29,6 +29,7 @@
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <errno.h>
#include <fstream>
#include <list>
diff --git a/sim/startup.cc b/sim/startup.cc
index ebb4c0bc0..7cc0ac8fb 100644
--- a/sim/startup.cc
+++ b/sim/startup.cc
@@ -29,20 +29,32 @@
#include <list>
#include "base/misc.hh"
-#include "sim/startup.hh"
#include "sim/debug.hh"
+#include "sim/startup.hh"
typedef std::list<StartupCallback *> startupq_t;
-startupq_t &startupq() { static startupq_t queue; return queue; }
-StartupCallback::StartupCallback() { startupq().push_back(this); }
-StartupCallback::~StartupCallback() { startupq().remove(this); }
+
+startupq_t *startupq = NULL;
+
+StartupCallback::StartupCallback()
+{
+ if (startupq == NULL)
+ startupq = new startupq_t;
+ startupq->push_back(this);
+}
+
+StartupCallback::~StartupCallback()
+{
+ startupq->remove(this);
+}
+
void StartupCallback::startup() { }
void
SimStartup()
{
- startupq_t::iterator i = startupq().begin();
- startupq_t::iterator end = startupq().end();
+ startupq_t::iterator i = startupq->begin();
+ startupq_t::iterator end = startupq->end();
while (i != end) {
(*i)->startup();
diff --git a/sim/syscall_emul.hh b/sim/syscall_emul.hh
index 77d104449..768bc3700 100644
--- a/sim/syscall_emul.hh
+++ b/sim/syscall_emul.hh
@@ -26,8 +26,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef __SYSCALL_EMUL_HH__
-#define __SYSCALL_EMUL_HH__
+#ifndef __SIM_SYSCALL_EMUL_HH__
+#define __SIM_SYSCALL_EMUL_HH__
///
/// @file syscall_emul.hh
@@ -35,14 +35,16 @@
/// This file defines objects used to emulate syscalls from the target
/// application on the host machine.
+#include <errno.h>
#include <string>
#include "base/intmath.hh" // for RoundUp
-#include "targetarch/isa_traits.hh" // for Addr
#include "mem/functional_mem/functional_memory.hh"
+#include "targetarch/isa_traits.hh" // for Addr
-class Process;
-class ExecContext;
+#include "base/trace.hh"
+#include "cpu/exec_context.hh"
+#include "sim/process.hh"
///
/// System call descriptor.
@@ -197,6 +199,36 @@ int unlinkFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc);
/// Target rename() handler.
int renameFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc);
+/// This struct is used to build an target-OS-dependent table that
+/// maps the target's open() flags to the host open() flags.
+struct OpenFlagTransTable {
+ int tgtFlag; //!< Target system flag value.
+ int hostFlag; //!< Corresponding host system flag value.
+};
+
+
+
+/// A readable name for 1,000,000, for converting microseconds to seconds.
+const int one_million = 1000000;
+
+/// Approximate seconds since the epoch (1/1/1970). About a billion,
+/// by my reckoning. We want to keep this a constant (not use the
+/// real-world time) to keep simulations repeatable.
+const unsigned seconds_since_epoch = 1000000000;
+
+/// Helper function to convert current elapsed time to seconds and
+/// microseconds.
+template <class T1, class T2>
+void
+getElapsedTime(T1 &sec, T2 &usec)
+{
+ int cycles_per_usec = ticksPerSecond / one_million;
+
+ int elapsed_usecs = curTick / cycles_per_usec;
+ sec = elapsed_usecs / one_million;
+ usec = elapsed_usecs % one_million;
+}
+
//////////////////////////////////////////////////////////////////////
//
// The following emulation functions are generic, but need to be
@@ -238,14 +270,6 @@ ioctlFunc(SyscallDesc *desc, int callnum, Process *process,
}
}
-/// This struct is used to build an target-OS-dependent table that
-/// maps the target's open() flags to the host open() flags.
-struct OpenFlagTransTable {
- int tgtFlag; //!< Target system flag value.
- int hostFlag; //!< Corresponding host system flag value.
-};
-
-
/// Target open() handler.
template <class OS>
int
@@ -260,7 +284,7 @@ openFunc(SyscallDesc *desc, int callnum, Process *process,
if (path == "/dev/sysdev0") {
// This is a memory-mapped high-resolution timer device on Alpha.
// We don't support it, so just punt.
- DCOUT(SyscallWarnings) << "Ignoring open(" << path << ", ...)" << endl;
+ DCOUT(SyscallWarnings) << "Ignoring open(" << path << ", ...)" << std::endl;
return -ENOENT;
}
@@ -278,7 +302,7 @@ openFunc(SyscallDesc *desc, int callnum, Process *process,
// any target flags left?
if (tgtFlags != 0)
- cerr << "Syscall: open: cannot decode flags: " << tgtFlags << endl;
+ std::cerr << "Syscall: open: cannot decode flags: " << tgtFlags << std::endl;
#ifdef __CYGWIN32__
hostFlags |= O_BINARY;
@@ -414,7 +438,7 @@ getrlimitFunc(SyscallDesc *desc, int callnum, Process *process,
break;
default:
- cerr << "getrlimitFunc: unimplemented resource " << resource << endl;
+ std::cerr << "getrlimitFunc: unimplemented resource " << resource << std::endl;
abort();
break;
}
@@ -423,28 +447,6 @@ getrlimitFunc(SyscallDesc *desc, int callnum, Process *process,
return 0;
}
-/// A readable name for 1,000,000, for converting microseconds to seconds.
-const int one_million = 1000000;
-
-/// Approximate seconds since the epoch (1/1/1970). About a billion,
-/// by my reckoning. We want to keep this a constant (not use the
-/// real-world time) to keep simulations repeatable.
-const unsigned seconds_since_epoch = 1000000000;
-
-/// Helper function to convert current elapsed time to seconds and
-/// microseconds.
-template <class T1, class T2>
-void
-getElapsedTime(T1 &sec, T2 &usec)
-{
- int cycles_per_usec = ticksPerSecond / one_million;
-
- int elapsed_usecs = curTick / cycles_per_usec;
- sec = elapsed_usecs / one_million;
- usec = elapsed_usecs % one_million;
-}
-
-
/// Target gettimeofday() handler.
template <class OS>
int
@@ -476,7 +478,7 @@ getrusageFunc(SyscallDesc *desc, int callnum, Process *process,
// plow ahead
DCOUT(SyscallWarnings)
<< "Warning: getrusage() only supports RUSAGE_SELF."
- << " Parameter " << who << " ignored." << endl;
+ << " Parameter " << who << " ignored." << std::endl;
}
getElapsedTime(rup->ru_utime.tv_sec, rup->ru_utime.tv_usec);
@@ -502,6 +504,4 @@ getrusageFunc(SyscallDesc *desc, int callnum, Process *process,
return 0;
}
-
-
-#endif // __SYSCALL_EMUL_HH__
+#endif // __SIM_SYSCALL_EMUL_HH__
diff --git a/sim/universe.cc b/sim/universe.cc
index 69563650d..52353db11 100644
--- a/sim/universe.cc
+++ b/sim/universe.cc
@@ -28,6 +28,7 @@
#include <sys/types.h>
#include <sys/stat.h>
+#include <errno.h>
#include <cstring>
#include <fstream>