summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--SConstruct19
-rw-r--r--configs/test/SysPaths.py60
-rw-r--r--configs/test/fs.py1
-rw-r--r--configs/test/test.py1
-rw-r--r--src/SConscript3
-rw-r--r--src/arch/alpha/system.cc1
-rw-r--r--src/arch/alpha/system.hh1
-rw-r--r--src/base/timebuf.hh3
-rw-r--r--src/cpu/SConscript2
-rw-r--r--src/cpu/ozone/front_end_impl.hh1
-rw-r--r--src/dev/ns_gige.cc3
-rw-r--r--src/dev/ns_gige.hh3
-rw-r--r--src/dev/platform.hh1
-rw-r--r--src/kern/linux/events.cc3
-rw-r--r--src/kern/linux/events.hh3
-rw-r--r--src/kern/linux/linux.hh4
-rw-r--r--src/kern/linux/printk.cc3
-rw-r--r--src/kern/linux/printk.hh3
-rw-r--r--src/kern/solaris/solaris.hh4
-rw-r--r--src/kern/system_events.hh3
-rw-r--r--src/mem/bus.hh1
-rw-r--r--src/python/SConscript6
-rw-r--r--src/python/m5/__init__.py29
-rw-r--r--src/python/m5/config.py6
-rw-r--r--src/sim/byteswap.hh50
-rw-r--r--src/sim/main.cc23
-rw-r--r--src/sim/serialize.cc3
-rw-r--r--src/sim/serialize.hh3
-rw-r--r--src/sim/syscall_emul.hh8
29 files changed, 154 insertions, 97 deletions
diff --git a/SConstruct b/SConstruct
index ca87842ba..6f20d9756 100644
--- a/SConstruct
+++ b/SConstruct
@@ -39,17 +39,20 @@
#
# You can build M5 in a different directory as long as there is a
# 'build/<CONFIG>' somewhere along the target path. The build system
-# expdects that all configs under the same build directory are being
+# expects that all configs under the same build directory are being
# built for the same host system.
#
# Examples:
-# These two commands are equivalent. The '-u' option tells scons to
-# search up the directory tree for this SConstruct file.
+#
+# The following two commands are equivalent. The '-u' option tells
+# scons to search up the directory tree for this SConstruct file.
# % cd <path-to-src>/m5 ; scons build/ALPHA_FS/m5.debug
# % cd <path-to-src>/m5/build/ALPHA_FS; scons -u m5.debug
-# These two commands are equivalent and demonstrate building in a
-# directory outside of the source tree. The '-C' option tells scons
-# to chdir to the specified directory to find this SConstruct file.
+#
+# The following two commands are equivalent and demonstrate building
+# in a directory outside of the source tree. The '-C' option tells
+# scons to chdir to the specified directory to find this SConstruct
+# file.
# % cd <path-to-src>/m5 ; scons /local/foo/build/ALPHA_FS/m5.debug
# % cd /local/foo/build/ALPHA_FS; scons -C <path-to-src>/m5 m5.debug
#
@@ -302,7 +305,7 @@ nonsticky_opts.AddOptions(
BoolOption('update_ref', 'Update test reference outputs', False)
)
-# These options get exported to #defines in config/*.hh (see m5/SConscript).
+# These options get exported to #defines in config/*.hh (see src/SConscript).
env.ExportOptions = ['FULL_SYSTEM', 'ALPHA_TLASER', 'USE_FENV', \
'USE_MYSQL', 'NO_FAST_ALLOC', 'SS_COMPATIBLE_FP', \
'USE_CHECKER']
@@ -484,7 +487,7 @@ for build_path in build_paths:
if env['USE_SSE2']:
env.Append(CCFLAGS='-msse2')
- # The m5/SConscript file sets up the build rules in 'env' according
+ # The src/SConscript file sets up the build rules in 'env' according
# to the configured options. It returns a list of environments,
# one for each variant build (debug, opt, etc.)
envList = SConscript('src/SConscript', build_dir = build_path,
diff --git a/configs/test/SysPaths.py b/configs/test/SysPaths.py
index c7c7db4e7..9acfedc8b 100644
--- a/configs/test/SysPaths.py
+++ b/configs/test/SysPaths.py
@@ -1,32 +1,42 @@
-from m5 import *
-
-import os.path
-import sys
-
-# Edit the following list to include the possible paths to the binary
-# and disk image directories. The first directory on the list that
-# exists will be selected.
-SYSTEMDIR_PATH = ['/n/poolfs/z/dist/m5/system']
-
-SYSTEMDIR = None
-for d in SYSTEMDIR_PATH:
- if os.path.exists(d):
- SYSTEMDIR = d
- break
-
-if not SYSTEMDIR:
- print >>sys.stderr, "Can't find a path to system files."
- sys.exit(1)
-
-BINDIR = SYSTEMDIR + '/binaries'
-DISKDIR = SYSTEMDIR + '/disks'
+import os, sys
+from os.path import isdir, join as joinpath
+from os import environ as env
+
+systemdir = None
+bindir = None
+diskdir = None
+scriptdir = None
+
+def load_defaults():
+ global systemdir, bindir, diskdir, scriptdir
+ if not systemdir:
+ try:
+ path = env['M5_PATH'].split(':')
+ except KeyError:
+ path = [ '/dist/m5/system' ]
+
+ for systemdir in path:
+ if os.path.isdir(systemdir):
+ break
+ else:
+ raise ImportError, "Can't find a path to system files."
+
+ if not bindir:
+ bindir = joinpath(systemdir, 'binaries')
+ if not diskdir:
+ diskdir = joinpath(systemdir, 'disks')
+ if not scriptdir:
+ scriptdir = joinpath(systemdir, 'boot')
def disk(file):
- return os.path.join(DISKDIR, file)
+ load_defaults()
+ return joinpath(diskdir, file)
def binary(file):
- return os.path.join(BINDIR, file)
+ load_defaults()
+ return joinpath(bindir, file)
def script(file):
- return os.path.join(SYSTEMDIR, 'boot', file)
+ load_defaults()
+ return joinpath(scriptdir, file)
diff --git a/configs/test/fs.py b/configs/test/fs.py
index c742e916c..aa530dd55 100644
--- a/configs/test/fs.py
+++ b/configs/test/fs.py
@@ -8,6 +8,7 @@ parser = optparse.OptionParser(option_list=m5.standardOptions)
parser.add_option("-t", "--timing", action="store_true")
(options, args) = parser.parse_args()
+m5.setStandardOptions(options)
if args:
print "Error: script doesn't take any positional arguments"
diff --git a/configs/test/test.py b/configs/test/test.py
index 2b5a6769f..a570c1a08 100644
--- a/configs/test/test.py
+++ b/configs/test/test.py
@@ -17,6 +17,7 @@ parser.add_option("-d", "--detailed", action="store_true")
parser.add_option("-m", "--maxtick", type="int")
(options, args) = parser.parse_args()
+m5.setStandardOptions(options)
if args:
print "Error: script doesn't take any positional arguments"
diff --git a/src/SConscript b/src/SConscript
index 933158f5f..124f88708 100644
--- a/src/SConscript
+++ b/src/SConscript
@@ -106,9 +106,8 @@ base_sources = Split('''
sim/eventq.cc
sim/faults.cc
sim/main.cc
- python/swig/main_wrap.cc
+ python/swig/cc_main_wrap.cc
sim/param.cc
- sim/profile.cc
sim/root.cc
sim/serialize.cc
sim/sim_events.cc
diff --git a/src/arch/alpha/system.cc b/src/arch/alpha/system.cc
index 3aaba7d58..dce7365aa 100644
--- a/src/arch/alpha/system.cc
+++ b/src/arch/alpha/system.cc
@@ -26,6 +26,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Authors: Ali Saidi
+ * Nathan Binkert
*/
#include "arch/alpha/ev5.hh"
diff --git a/src/arch/alpha/system.hh b/src/arch/alpha/system.hh
index b26a5e301..0f4f64581 100644
--- a/src/arch/alpha/system.hh
+++ b/src/arch/alpha/system.hh
@@ -26,6 +26,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Authors: Ali Saidi
+ * Nathan Binkert
*/
#ifndef __ARCH_ALPHA_SYSTEM_HH__
diff --git a/src/base/timebuf.hh b/src/base/timebuf.hh
index 6a326d25a..160a97034 100644
--- a/src/base/timebuf.hh
+++ b/src/base/timebuf.hh
@@ -25,7 +25,8 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * Authors: Kevin Lim
+ * Authors: Nathan Binkert
+ * Kevin Lim
*/
#ifndef __BASE_TIMEBUF_HH__
diff --git a/src/cpu/SConscript b/src/cpu/SConscript
index 1bb8e8a9f..eea9ba64b 100644
--- a/src/cpu/SConscript
+++ b/src/cpu/SConscript
@@ -194,7 +194,7 @@ if env['USE_CHECKER']:
Exit(1)
-# FullCPU sources are included from m5/SConscript since they're not
+# FullCPU sources are included from src/SConscript since they're not
# below this point in the file hierarchy.
# Convert file names to SCons File objects. This takes care of the
diff --git a/src/cpu/ozone/front_end_impl.hh b/src/cpu/ozone/front_end_impl.hh
index 467567c10..8082e01b9 100644
--- a/src/cpu/ozone/front_end_impl.hh
+++ b/src/cpu/ozone/front_end_impl.hh
@@ -35,7 +35,6 @@
#include "cpu/exetrace.hh"
#include "cpu/ozone/front_end.hh"
#include "mem/mem_interface.hh"
-#include "sim/byte_swap.hh"
using namespace TheISA;
diff --git a/src/dev/ns_gige.cc b/src/dev/ns_gige.cc
index decffaf73..360fe8c9b 100644
--- a/src/dev/ns_gige.cc
+++ b/src/dev/ns_gige.cc
@@ -25,7 +25,8 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * Authors: Lisa Hsu
+ * Authors: Nathan Binkert
+ * Lisa Hsu
*/
/** @file
diff --git a/src/dev/ns_gige.hh b/src/dev/ns_gige.hh
index 2de11c951..2f47026f3 100644
--- a/src/dev/ns_gige.hh
+++ b/src/dev/ns_gige.hh
@@ -25,7 +25,8 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * Authors: Lisa Hsu
+ * Authors: Nathan Binkert
+ * Lisa Hsu
*/
/** @file
diff --git a/src/dev/platform.hh b/src/dev/platform.hh
index bfc229748..0e6f4ba4a 100644
--- a/src/dev/platform.hh
+++ b/src/dev/platform.hh
@@ -26,6 +26,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Authors: Andrew Schultz
+ * Nathan Binkert
*/
/**
diff --git a/src/kern/linux/events.cc b/src/kern/linux/events.cc
index 5ff7e26db..289ece5ce 100644
--- a/src/kern/linux/events.cc
+++ b/src/kern/linux/events.cc
@@ -25,7 +25,8 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * Authors: Ali Saidi
+ * Authors: Nathan Binkert
+ * Ali Saidi
*/
#include "arch/arguments.hh"
diff --git a/src/kern/linux/events.hh b/src/kern/linux/events.hh
index 65f794a9c..b0510c18f 100644
--- a/src/kern/linux/events.hh
+++ b/src/kern/linux/events.hh
@@ -25,7 +25,8 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * Authors: Ali Saidi
+ * Authors: Nathan Binkert
+ * Ali Saidi
*/
#ifndef __KERN_LINUX_EVENTS_HH__
diff --git a/src/kern/linux/linux.hh b/src/kern/linux/linux.hh
index af5e23b95..e3f554a22 100644
--- a/src/kern/linux/linux.hh
+++ b/src/kern/linux/linux.hh
@@ -69,7 +69,7 @@ class Linux {
typedef uint32_t gid_t;
//@}
-#if BSD_HOST
+#if NO_STAT64
typedef struct stat hst_stat;
typedef struct stat hst_stat64;
#else
@@ -176,7 +176,7 @@ class Linux {
/// Helper function to convert a host stat buffer to a target stat
/// buffer. Also copies the target buffer out to the simulated
/// memory space. Used by stat(), fstat(), and lstat().
-#if !BSD_HOST
+#if !NO_STAT64
static void
copyOutStatBuf(TranslatingPort *mem, Addr addr, hst_stat *host)
{
diff --git a/src/kern/linux/printk.cc b/src/kern/linux/printk.cc
index e39a15982..004d1be2f 100644
--- a/src/kern/linux/printk.cc
+++ b/src/kern/linux/printk.cc
@@ -25,7 +25,8 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * Authors: Ali Saidi
+ * Authors: Nathan Binkert
+ * Ali Saidi
*/
#include <sys/types.h>
diff --git a/src/kern/linux/printk.hh b/src/kern/linux/printk.hh
index f9203717a..5ddf0a018 100644
--- a/src/kern/linux/printk.hh
+++ b/src/kern/linux/printk.hh
@@ -25,7 +25,8 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * Authors: Ali Saidi
+ * Authors: Nathan Binkert
+ * Ali Saidi
*/
#ifndef __PRINTK_HH__
diff --git a/src/kern/solaris/solaris.hh b/src/kern/solaris/solaris.hh
index 0fec0bcce..b819fb6d2 100644
--- a/src/kern/solaris/solaris.hh
+++ b/src/kern/solaris/solaris.hh
@@ -74,7 +74,7 @@ class Solaris {
typedef uint32_t nlink_t;
//@}
-#if BSD_HOST
+#if NO_STAT64
typedef struct stat hst_stat;
typedef struct stat hst_stat64;
#else
@@ -177,7 +177,7 @@ class Solaris {
/// Helper function to convert a host stat buffer to a target stat
/// buffer. Also copies the target buffer out to the simulated
/// memory space. Used by stat(), fstat(), and lstat().
-#if !BSD_HOST
+#if !NO_STAT64
static void
copyOutStatBuf(TranslatingPort *mem, Addr addr, hst_stat *host)
{
diff --git a/src/kern/system_events.hh b/src/kern/system_events.hh
index ccd6bd9a4..93b5eb528 100644
--- a/src/kern/system_events.hh
+++ b/src/kern/system_events.hh
@@ -25,7 +25,8 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * Authors: Lisa Hsu
+ * Authors: Nathan Binkert
+ * Lisa Hsu
* Ali Saidi
*/
diff --git a/src/mem/bus.hh b/src/mem/bus.hh
index c2b78c31f..9c7054b94 100644
--- a/src/mem/bus.hh
+++ b/src/mem/bus.hh
@@ -26,6 +26,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Authors: Ron Dreslinski
+ * Ali Saidi
*/
/**
diff --git a/src/python/SConscript b/src/python/SConscript
index 7b0f591eb..3a9def9a8 100644
--- a/src/python/SConscript
+++ b/src/python/SConscript
@@ -87,12 +87,12 @@ addPkg('m5')
pyzip_files.append('m5/defines.py')
pyzip_files.append(join(env['ROOT'], 'util/pbs/jobfile.py'))
-env.Command(['swig/main_wrap.cc', 'm5/main.py'],
- 'swig/main.i',
+env.Command(['swig/cc_main_wrap.cc', 'm5/cc_main.py'],
+ 'swig/cc_main.i',
'$SWIG $SWIGFLAGS -outdir ${TARGETS[1].dir} '
'-o ${TARGETS[0]} $SOURCES')
-pyzip_dep_files.append('m5/main.py')
+pyzip_dep_files.append('m5/cc_main.py')
# Action function to build the zip archive. Uses the PyZipFile module
# included in the standard Python library.
diff --git a/src/python/m5/__init__.py b/src/python/m5/__init__.py
index d1e443b64..a7e653fc2 100644
--- a/src/python/m5/__init__.py
+++ b/src/python/m5/__init__.py
@@ -30,11 +30,11 @@
import sys, os, time, atexit, optparse
# import the SWIG-wrapped main C++ functions
-import main
+import cc_main
# import a few SWIG-wrapped items (those that are likely to be used
# directly by user scripts) completely into this module for
# convenience
-from main import simulate, SimLoopExitEvent
+from cc_main import simulate, SimLoopExitEvent
# import the m5 compile options
import defines
@@ -58,6 +58,20 @@ def AddToPath(path):
sys.path.insert(1, path)
+# The m5 module's pointer to the parsed options object
+options = None
+
+
+# User should call this function after calling parse_args() to pass
+# parsed standard option values back into the m5 module for
+# processing.
+def setStandardOptions(_options):
+ # Set module global var
+ global options
+ options = _options
+ # tell C++ about output directory
+ cc_main.setOutputDir(options.outdir)
+
# Callback to set trace flags. Not necessarily the best way to do
# things in the long run (particularly if we change how these global
# options are handled).
@@ -110,6 +124,7 @@ TorF = "True | False"
# Standard optparse options. Need to be explicitly included by the
# user script when it calls optparse.OptionParser().
standardOptions = [
+ optparse.make_option("--outdir", type="string", default="."),
optparse.make_option("--traceflags", type="string", action="callback",
callback=setTraceFlags),
optparse.make_option("--tracestart", type="int", action="callback",
@@ -171,14 +186,14 @@ def resolveSimObject(name):
def instantiate(root):
config.ticks_per_sec = float(root.clock.frequency)
# ugly temporary hack to get output to config.ini
- sys.stdout = file('config.ini', 'w')
+ sys.stdout = file(os.path.join(options.outdir, 'config.ini'), 'w')
root.print_ini()
sys.stdout.close() # close config.ini
sys.stdout = sys.__stdout__ # restore to original
- main.loadIniFile(resolveSimObject) # load config.ini into C++
+ cc_main.loadIniFile(resolveSimObject) # load config.ini into C++
root.createCCObject()
root.connectPorts()
- main.finalInit()
+ cc_main.finalInit()
noDot = True # temporary until we fix dot
if not noDot:
dot = pydot.Dot()
@@ -192,10 +207,10 @@ def instantiate(root):
# Export curTick to user script.
def curTick():
- return main.cvar.curTick
+ return cc_main.cvar.curTick
# register our C++ exit callback function with Python
-atexit.register(main.doExitCleanup)
+atexit.register(cc_main.doExitCleanup)
# This import allows user scripts to reference 'm5.objects.Foo' after
# just doing an 'import m5' (without an 'import m5.objects'). May not
diff --git a/src/python/m5/config.py b/src/python/m5/config.py
index 058e72578..c29477465 100644
--- a/src/python/m5/config.py
+++ b/src/python/m5/config.py
@@ -30,7 +30,7 @@
import os, re, sys, types, inspect, copy
import m5
-from m5 import panic
+from m5 import panic, cc_main
from convert import *
from multidict import multidict
@@ -529,7 +529,7 @@ class SimObject(object):
def getCCObject(self):
if not self._ccObject:
self._ccObject = -1 # flag to catch cycles in recursion
- self._ccObject = m5.main.createSimObject(self.path())
+ self._ccObject = cc_main.createSimObject(self.path())
elif self._ccObject == -1:
raise RuntimeError, "%s: recursive call to getCCObject()" \
% self.path()
@@ -1443,7 +1443,7 @@ class PortRef(object):
if self.ccConnected: # already done this
return
peer = self.peer
- m5.main.connectPorts(self.simobj.getCCObject(), self.name, self.index,
+ cc_main.connectPorts(self.simobj.getCCObject(), self.name, self.index,
peer.simobj.getCCObject(), peer.name, peer.index)
self.ccConnected = True
peer.ccConnected = True
diff --git a/src/sim/byteswap.hh b/src/sim/byteswap.hh
index a3138a25e..f1f244150 100644
--- a/src/sim/byteswap.hh
+++ b/src/sim/byteswap.hh
@@ -25,7 +25,8 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * Authors: Gabe Black
+ * Authors: Ali Saidi
+ * Nathan Binkert
*/
//The purpose of this file is to provide endainness conversion utility
@@ -35,6 +36,7 @@
#ifndef __SIM_BYTE_SWAP_HH__
#define __SIM_BYTE_SWAP_HH__
+#include "base/misc.hh"
#include "sim/host.hh"
// This lets us figure out what the byte order of the host system is
@@ -48,6 +50,10 @@
#include <machine/endian.h>
#endif
+#if defined(__APPLE__)
+#include <libkern/OSByteOrder.h>
+#endif
+
//These functions actually perform the swapping for parameters
//of various bit lengths
static inline uint64_t
@@ -55,6 +61,8 @@ swap_byte64(uint64_t x)
{
#if defined(linux)
return bswap_64(x);
+#elif defined(__APPLE__)
+ return OSSwapInt64(x);
#else
return (uint64_t)((((uint64_t)(x) & 0xff) << 56) |
((uint64_t)(x) & 0xff00ULL) << 40 |
@@ -72,6 +80,8 @@ swap_byte32(uint32_t x)
{
#if defined(linux)
return bswap_32(x);
+#elif defined(__APPLE__)
+ return OSSwapInt32(x);
#else
return (uint32_t)(((uint32_t)(x) & 0xff) << 24 |
((uint32_t)(x) & 0xff00) << 8 | ((uint32_t)(x) & 0xff0000) >> 8 |
@@ -84,31 +94,31 @@ swap_byte16(uint16_t x)
{
#if defined(linux)
return bswap_16(x);
+#elif defined(__APPLE__)
+ return OSSwapInt16(x);
#else
return (uint16_t)(((uint16_t)(x) & 0xff) << 8 |
((uint16_t)(x) & 0xff00) >> 8);
#endif
}
-//This lets the compiler figure out how to call the swap_byte functions above
-//for different data types.
-static inline uint64_t swap_byte(uint64_t x) {return swap_byte64(x);}
-static inline int64_t swap_byte(int64_t x) {return swap_byte64((uint64_t)x);}
-static inline uint32_t swap_byte(uint32_t x) {return swap_byte32(x);}
-static inline int32_t swap_byte(int32_t x) {return swap_byte32((uint32_t)x);}
-//This is to prevent the following two functions from compiling on
-//64bit machines. It won't detect everything, so it should be changed.
-#ifndef __x86_64__
-static inline long swap_byte(long x) {return swap_byte32((long)x);}
-static inline unsigned long swap_byte(unsigned long x)
- { return swap_byte32((unsigned long)x);}
-#endif
-static inline uint16_t swap_byte(uint16_t x) {return swap_byte32(x);}
-static inline int16_t swap_byte(int16_t x) {return swap_byte16((uint16_t)x);}
-static inline uint8_t swap_byte(uint8_t x) {return x;}
-static inline int8_t swap_byte(int8_t x) {return x;}
-static inline double swap_byte(double x) {return swap_byte64((uint64_t)x);}
-static inline float swap_byte(float x) {return swap_byte32((uint32_t)x);}
+// This function lets the compiler figure out how to call the
+// swap_byte functions above for different data types. Since the
+// sizeof() values are known at compiel time, it should inline to a
+// direct call to the right swap_byteNN() function.
+template <typename T>
+static inline T swap_byte(T x) {
+ if (sizeof(T) == 8)
+ return swap_byte64((uint64_t)x);
+ else if (sizeof(T) == 4)
+ return swap_byte32((uint32_t)x);
+ else if (sizeof(T) == 2)
+ return swap_byte16((uint16_t)x);
+ else if (sizeof(T) == 1)
+ return x;
+ else
+ panic("Can't byte-swap values larger than 64 bits");
+}
//The conversion functions with fixed endianness on both ends don't need to
//be in a namespace
diff --git a/src/sim/main.cc b/src/sim/main.cc
index f63aec9cc..bf844da7f 100644
--- a/src/sim/main.cc
+++ b/src/sim/main.cc
@@ -135,7 +135,9 @@ showBriefHelp(ostream &out)
" script is executed (just like the -i option to the\n"
" Python interpreter).\n\n"
" -h Prints this help\n\n"
-" <configfile> config file name (ends in .py)\n\n",
+" <configfile> config file name which ends in .py. (Normally you can\n"
+" run <configfile> --help to get help on that config files\n"
+" parameters.\n\n",
prog);
}
@@ -166,7 +168,7 @@ sayHello(ostream &out)
}
-extern "C" { void init_main(); }
+extern "C" { void init_cc_main(); }
int
main(int argc, char **argv)
@@ -258,8 +260,8 @@ main(int argc, char **argv)
Py_Initialize();
PySys_SetArgv(argc, argv);
- // initialize SWIG 'main' module
- init_main();
+ // initialize SWIG 'cc_main' module
+ init_cc_main();
if (argc > 0) {
// extra arg(s): first is script file, remaining ones are args
@@ -297,6 +299,14 @@ main(int argc, char **argv)
Py_Finalize();
}
+
+void
+setOutputDir(const string &dir)
+{
+ simout.setDirectory(dir);
+}
+
+
IniFile inifile;
SimObject *
@@ -417,11 +427,6 @@ finalInit()
SimObject::regAllStats();
- // uncomment the following to get PC-based execution-time profile
-#ifdef DO_PROFILE
- init_profile((char *)&_init, (char *)&_fini);
-#endif
-
// Check to make sure that the stats package is properly initialized
Stats::check();
diff --git a/src/sim/serialize.cc b/src/sim/serialize.cc
index 07e3b8a56..0e3139116 100644
--- a/src/sim/serialize.cc
+++ b/src/sim/serialize.cc
@@ -25,7 +25,8 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * Authors: Erik Hallnor
+ * Authors: Nathan Binkert
+ * Erik Hallnor
* Steve Reinhardt
*/
diff --git a/src/sim/serialize.hh b/src/sim/serialize.hh
index 1bcb235e6..64ed6142f 100644
--- a/src/sim/serialize.hh
+++ b/src/sim/serialize.hh
@@ -25,7 +25,8 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * Authors: Erik Hallnor
+ * Authors: Nathan Binkert
+ * Erik Hallnor
* Steve Reinhardt
*/
diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh
index f027dbf24..a3990e2fd 100644
--- a/src/sim/syscall_emul.hh
+++ b/src/sim/syscall_emul.hh
@@ -33,8 +33,8 @@
#ifndef __SIM_SYSCALL_EMUL_HH__
#define __SIM_SYSCALL_EMUL_HH__
-#define BSD_HOST (defined(__APPLE__) || defined(__OpenBSD__) || \
- defined(__FreeBSD__))
+#define NO_STAT64 (defined(__APPLE__) || defined(__OpenBSD__) || \
+ defined(__FreeBSD__) || defined(__CYGWIN__))
///
/// @file syscall_emul.hh
@@ -507,7 +507,7 @@ fstat64Func(SyscallDesc *desc, int callnum, Process *process,
return -EBADF;
}
-#if BSD_HOST
+#if NO_STAT64
struct stat hostBuf;
int result = fstat(process->sim_fd(fd), &hostBuf);
#else
@@ -557,7 +557,7 @@ lstat64Func(SyscallDesc *desc, int callnum, Process *process,
if (!tc->getMemPort()->tryReadString(path, tc->getSyscallArg(0)))
return -EFAULT;
-#if BSD_HOST
+#if NO_STAT64
struct stat hostBuf;
int result = lstat(path.c_str(), &hostBuf);
#else