summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndreas Hansson <andreas.hansson@arm.com>2012-04-14 05:43:31 -0400
committerAndreas Hansson <andreas.hansson@arm.com>2012-04-14 05:43:31 -0400
commitb6aa6d55eb856f99a06c400b5dcda118c46dacfa (patch)
tree02d6e99ad1c38462725aac4ed6c39216d6d93d71 /src
parent29482e90bad9d1d93b20d4f55fc4583756d68b3b (diff)
downloadgem5-b6aa6d55eb856f99a06c400b5dcda118c46dacfa.tar.xz
clang/gcc: Fix compilation issues with clang 3.0 and gcc 4.6
This patch addresses a number of minor issues that cause problems when compiling with clang >= 3.0 and gcc >= 4.6. Most importantly, it avoids using the deprecated ext/hash_map and instead uses unordered_map (and similarly so for the hash_set). To make use of the new STL containers, g++ and clang has to be invoked with "-std=c++0x", and this is now added for all gcc versions >= 4.6, and for clang >= 3.0. For gcc >= 4.3 and <= 4.5 and clang <= 3.0 we use the tr1 unordered_map to avoid the deprecation warning. The addition of c++0x in turn causes a few problems, as the compiler is more stringent and adds a number of new warnings. Below, the most important issues are enumerated: 1) the use of namespaces is more strict, e.g. for isnan, and all headers opening the entire namespace std are now fixed. 2) another other issue caused by the more stringent compiler is the narrowing of the embedded python, which used to be a char array, and is now unsigned char since there were values larger than 128. 3) a particularly odd issue that arose with the new c++0x behaviour is found in range.hh, where the operator< causes gcc to complain about the template type parsing (the "<" is interpreted as the beginning of a template argument), and the problem seems to be related to the begin/end members introduced for the range-type iteration, which is a new feature in c++11. As a minor update, this patch also fixes the build flags for the clang debug target that used to be shared with gcc and incorrectly use "-ggdb".
Diffstat (limited to 'src')
-rwxr-xr-xsrc/SConscript11
-rw-r--r--src/arch/alpha/isa/main.isa2
-rw-r--r--src/arch/alpha/mt.hh1
-rw-r--r--src/arch/arm/isa/includes.isa2
-rw-r--r--src/arch/arm/types.hh4
-rw-r--r--src/arch/mips/isa/includes.isa4
-rw-r--r--src/arch/power/isa/includes.isa2
-rw-r--r--src/arch/power/types.hh4
-rw-r--r--src/arch/sparc/isa/decoder.isa8
-rw-r--r--src/arch/sparc/mt.hh1
-rw-r--r--src/arch/sparc/tlb_map.hh2
-rw-r--r--src/arch/x86/isa/microops/fpop.isa2
-rw-r--r--src/arch/x86/isa/microops/mediaop.isa4
-rw-r--r--src/arch/x86/types.hh4
-rw-r--r--src/base/hashmap.hh113
-rw-r--r--src/base/inifile.cc1
-rw-r--r--src/base/range.hh8
-rw-r--r--src/base/stats/text.cc8
-rw-r--r--src/cpu/inorder/inorder_dyn_inst.cc2
-rw-r--r--src/mem/ruby/common/Address.hh6
-rw-r--r--src/mem/ruby/common/NetDest.cc2
-rw-r--r--src/mem/ruby/network/fault_model/FaultModel.cc7
-rw-r--r--src/mem/ruby/network/fault_model/FaultModel.hh9
-rw-r--r--src/mem/ruby/network/garnet/BaseGarnetNetwork.cc2
-rw-r--r--src/mem/ruby/network/orion/OrionConfig.hh27
-rw-r--r--src/mem/ruby/network/orion/OrionRouter.cc2
-rw-r--r--src/mem/ruby/network/orion/TechParameter.hh2
-rw-r--r--src/mem/ruby/profiler/Profiler.cc2
-rw-r--r--src/mem/ruby/system/PerfectCacheMemory.hh1
-rw-r--r--src/mem/slicc/symbols/StateMachine.py6
-rw-r--r--src/sim/init.cc2
-rw-r--r--src/sim/init.hh6
32 files changed, 184 insertions, 73 deletions
diff --git a/src/SConscript b/src/SConscript
index 8c50f9fbb..fd6e725a4 100755
--- a/src/SConscript
+++ b/src/SConscript
@@ -791,7 +791,7 @@ def embedPyFile(target, source, env):
namespace {
-const char data_${sym}[] = {
+const uint8_t data_${sym}[] = {
''')
code.indent()
step = 16
@@ -852,7 +852,7 @@ def makeEnv(label, objsfx, strip = False, **kwargs):
swig_env.Append(CCFLAGS='-Wno-sign-compare')
swig_env.Append(CCFLAGS='-Wno-parentheses')
swig_env.Append(CCFLAGS='-Wno-unused-label')
- if compareVersions(env['GCC_VERSION'], '4.6.0') != -1:
+ if compareVersions(env['GCC_VERSION'], '4.6') >= 0:
swig_env.Append(CCFLAGS='-Wno-unused-but-set-variable')
if env['CLANG']:
swig_env.Append(CCFLAGS=['-Wno-unused-label'])
@@ -931,7 +931,7 @@ def makeEnv(label, objsfx, strip = False, **kwargs):
# Debug binary
ccflags = {}
-if env['GCC'] or env['CLANG']:
+if env['GCC']:
if sys.platform == 'sunos5':
ccflags['debug'] = '-gstabs+'
else:
@@ -949,6 +949,11 @@ elif env['ICC']:
ccflags['opt'] = '-g -O'
ccflags['fast'] = '-fast'
ccflags['prof'] = '-fast -g -pg'
+elif env['CLANG']:
+ ccflags['debug'] = '-g -O0'
+ ccflags['opt'] = '-g -O3'
+ ccflags['fast'] = '-O3'
+ ccflags['prof'] = '-O3 -g -pg'
else:
print 'Unknown compiler, please fix compiler options'
Exit(1)
diff --git a/src/arch/alpha/isa/main.isa b/src/arch/alpha/isa/main.isa
index 163e0a26f..5285d0572 100644
--- a/src/arch/alpha/isa/main.isa
+++ b/src/arch/alpha/isa/main.isa
@@ -70,7 +70,7 @@ using namespace AlphaISA;
}};
output exec {{
-#include <math.h>
+#include <cmath>
#include "arch/alpha/registers.hh"
#include "arch/alpha/regredir.hh"
diff --git a/src/arch/alpha/mt.hh b/src/arch/alpha/mt.hh
index 03ecf8486..cce27303a 100644
--- a/src/arch/alpha/mt.hh
+++ b/src/arch/alpha/mt.hh
@@ -44,7 +44,6 @@
#include "base/bitfield.hh"
#include "base/misc.hh"
#include "base/trace.hh"
-using namespace std;
namespace AlphaISA
{
diff --git a/src/arch/arm/isa/includes.isa b/src/arch/arm/isa/includes.isa
index bfd6fedd4..607a5c8b8 100644
--- a/src/arch/arm/isa/includes.isa
+++ b/src/arch/arm/isa/includes.isa
@@ -94,6 +94,6 @@ output exec {{
#include "sim/sim_exit.hh"
using namespace ArmISA;
-using std::isnan;
+
}};
diff --git a/src/arch/arm/types.hh b/src/arch/arm/types.hh
index 15f9f4d0a..31dec7bcb 100644
--- a/src/arch/arm/types.hh
+++ b/src/arch/arm/types.hh
@@ -540,13 +540,13 @@ namespace ArmISA
} // namespace ArmISA
-namespace __hash_namespace {
+__hash_namespace_begin
template<>
struct hash<ArmISA::ExtMachInst> : public hash<uint32_t> {
size_t operator()(const ArmISA::ExtMachInst &emi) const {
return hash<uint32_t>::operator()((uint32_t)emi);
};
};
-}
+__hash_namespace_end
#endif
diff --git a/src/arch/mips/isa/includes.isa b/src/arch/mips/isa/includes.isa
index d2e9c797e..ac9945b09 100644
--- a/src/arch/mips/isa/includes.isa
+++ b/src/arch/mips/isa/includes.isa
@@ -45,7 +45,7 @@ output header {{
}};
output decoder {{
-#include <math.h>
+#include <cmath>
#include "arch/mips/dsp.hh"
#include "arch/mips/dt_constants.hh"
@@ -69,7 +69,7 @@ using namespace MipsISA;
}};
output exec {{
-#include <math.h>
+#include <cmath>
#include "arch/generic/memhelpers.hh"
#include "arch/mips/dsp.hh"
diff --git a/src/arch/power/isa/includes.isa b/src/arch/power/isa/includes.isa
index f6292eaab..ed2076d62 100644
--- a/src/arch/power/isa/includes.isa
+++ b/src/arch/power/isa/includes.isa
@@ -66,7 +66,6 @@ output decoder {{
#include "cpu/thread_context.hh"
using namespace PowerISA;
-using std::isnan;
}};
output exec {{
@@ -87,6 +86,5 @@ output exec {{
#include "sim/sim_exit.hh"
using namespace PowerISA;
-using std::isnan;
}};
diff --git a/src/arch/power/types.hh b/src/arch/power/types.hh
index 071b4b439..a5d204827 100644
--- a/src/arch/power/types.hh
+++ b/src/arch/power/types.hh
@@ -89,7 +89,7 @@ typedef GenericISA::SimplePCState<MachInst> PCState;
} // PowerISA namespace
-namespace __hash_namespace {
+__hash_namespace_begin
template<>
struct hash<PowerISA::ExtMachInst> : public hash<uint32_t> {
@@ -98,6 +98,6 @@ struct hash<PowerISA::ExtMachInst> : public hash<uint32_t> {
};
};
-} // namespace __hash_namespace
+__hash_namespace_end
#endif // __ARCH_POWER_TYPES_HH__
diff --git a/src/arch/sparc/isa/decoder.isa b/src/arch/sparc/isa/decoder.isa
index 44d2643c6..ad8ba5300 100644
--- a/src/arch/sparc/isa/decoder.isa
+++ b/src/arch/sparc/isa/decoder.isa
@@ -683,7 +683,7 @@ decode OP default Unknown::unknown()
0x47: FpUnimpl::fmovrqlez();
0x51: fcmps({{
uint8_t fcc;
- if (isnan(Frs1s) || isnan(Frs2s))
+ if (std::isnan(Frs1s) || std::isnan(Frs2s))
fcc = 3;
else if (Frs1s < Frs2s)
fcc = 1;
@@ -698,7 +698,7 @@ decode OP default Unknown::unknown()
}});
0x52: fcmpd({{
uint8_t fcc;
- if (isnan(Frs1) || isnan(Frs2))
+ if (std::isnan(Frs1) || std::isnan(Frs2))
fcc = 3;
else if (Frs1 < Frs2)
fcc = 1;
@@ -714,7 +714,7 @@ decode OP default Unknown::unknown()
0x53: FpUnimpl::fcmpq();
0x55: fcmpes({{
uint8_t fcc = 0;
- if (isnan(Frs1s) || isnan(Frs2s))
+ if (std::isnan(Frs1s) || std::isnan(Frs2s))
fault = new FpExceptionIEEE754;
if (Frs1s < Frs2s)
fcc = 1;
@@ -727,7 +727,7 @@ decode OP default Unknown::unknown()
}});
0x56: fcmped({{
uint8_t fcc = 0;
- if (isnan(Frs1) || isnan(Frs2))
+ if (std::isnan(Frs1) || std::isnan(Frs2))
fault = new FpExceptionIEEE754;
if (Frs1 < Frs2)
fcc = 1;
diff --git a/src/arch/sparc/mt.hh b/src/arch/sparc/mt.hh
index 8b3d97aad..7fb054902 100644
--- a/src/arch/sparc/mt.hh
+++ b/src/arch/sparc/mt.hh
@@ -44,7 +44,6 @@
#include "base/bitfield.hh"
#include "base/misc.hh"
#include "base/trace.hh"
-using namespace std;
namespace SparcISA
{
diff --git a/src/arch/sparc/tlb_map.hh b/src/arch/sparc/tlb_map.hh
index 5541ff7e9..c09e6eb95 100644
--- a/src/arch/sparc/tlb_map.hh
+++ b/src/arch/sparc/tlb_map.hh
@@ -98,7 +98,7 @@ class TlbMap
if (intersect(r))
return tree.end();
- return tree.insert(std::make_pair<TlbRange,TlbEntry*>(r, d)).first;
+ return tree.insert(std::make_pair(r, d)).first;
}
size_t
diff --git a/src/arch/x86/isa/microops/fpop.isa b/src/arch/x86/isa/microops/fpop.isa
index 17698f198..01f26b0f5 100644
--- a/src/arch/x86/isa/microops/fpop.isa
+++ b/src/arch/x86/isa/microops/fpop.isa
@@ -285,7 +285,7 @@ let {{
// OF = SF = AF = 0
ccFlagBits = ccFlagBits & ~(OFBit | SFBit | AFBit |
ZFBit | PFBit | CFBit);
- if (isnan(FpSrcReg1) || isnan(FpSrcReg2))
+ if (std::isnan(FpSrcReg1) || std::isnan(FpSrcReg2))
ccFlagBits = ccFlagBits | (ZFBit | PFBit | CFBit);
else if(FpSrcReg1 < FpSrcReg2)
ccFlagBits = ccFlagBits | CFBit;
diff --git a/src/arch/x86/isa/microops/mediaop.isa b/src/arch/x86/isa/microops/mediaop.isa
index 9320d9f39..0c4827990 100644
--- a/src/arch/x86/isa/microops/mediaop.isa
+++ b/src/arch/x86/isa/microops/mediaop.isa
@@ -1404,7 +1404,7 @@ let {{
}
uint64_t resBits = 0;
- bool nanop = isnan(arg1) || isnan(arg2);
+ bool nanop = std::isnan(arg1) || std::isnan(arg2);
switch (ext & mask(3)) {
case 0:
if (arg1 == arg2 && !nanop)
@@ -1492,7 +1492,7 @@ let {{
// OF = SF = AF = 0
ccFlagBits = ccFlagBits & ~(OFBit | SFBit | AFBit |
ZFBit | PFBit | CFBit);
- if (isnan(arg1) || isnan(arg2))
+ if (std::isnan(arg1) || std::isnan(arg2))
ccFlagBits = ccFlagBits | (ZFBit | PFBit | CFBit);
else if(arg1 < arg2)
ccFlagBits = ccFlagBits | CFBit;
diff --git a/src/arch/x86/types.hh b/src/arch/x86/types.hh
index c7e824fb7..6d9f600ff 100644
--- a/src/arch/x86/types.hh
+++ b/src/arch/x86/types.hh
@@ -280,7 +280,7 @@ namespace X86ISA
}
-namespace __hash_namespace {
+__hash_namespace_begin
template<>
struct hash<X86ISA::ExtMachInst> {
size_t operator()(const X86ISA::ExtMachInst &emi) const {
@@ -298,7 +298,7 @@ namespace __hash_namespace {
emi.stackSize ^ emi.dispSize;
};
};
-}
+__hash_namespace_end
// These two functions allow ExtMachInst to be used with SERIALIZE_SCALAR
// and UNSERIALIZE_SCALAR.
diff --git a/src/base/hashmap.hh b/src/base/hashmap.hh
index e3a72bcf5..ce9325881 100644
--- a/src/base/hashmap.hh
+++ b/src/base/hashmap.hh
@@ -1,4 +1,16 @@
/*
+ * Copyright (c) 2012 ARM Limited
+ * All rights reserved
+ *
+ * The license below extends only to copyright in the software and shall
+ * not be construed as granting a license to any other intellectual
+ * property including but not limited to intellectual property relating
+ * to a hardware implementation of the functionality of the software
+ * licensed hereunder. You may use the software subject to the license
+ * terms below provided that you ensure that this notice is replicated
+ * unmodified and in its entirety in all distributions of the software,
+ * modified or unmodified, in source code or in binary form.
+ *
* Copyright (c) 2003-2005 The Regents of The University of Michigan
* All rights reserved.
*
@@ -26,29 +38,106 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Authors: Nathan Binkert
+ * Andreas Hansson
*/
#ifndef __HASHMAP_HH__
#define __HASHMAP_HH__
-#if defined(__GNUC__) && __GNUC__ >= 3
+#if defined(__GNUC__)
+
+// for compilers that deprecate ext/hash_map, i.e. gcc >= 4.3 and
+// clang, use unordered_map
+
+// we need to determine what is available, as in the non-c++0x case,
+// e.g. gcc >= 4.3 and <= 4.5, the containers are in the std::tr1
+// namespace, and only gcc >= 4.6 (with -std=c++0x) adds the final
+// container implementation in the std namespace
+
+#if defined(__clang__)
+// align with -std=c++0x only for clang >= 3.0 in CCFLAGS and also
+// check if the header is present as this depends on what clang was
+// built against, using XCode clang 3.1, for example, the header is
+// not present without adding -stdlib=libc++
+#if (__clang_major__ >= 3 && __has_include(<unordered_map>))
+#define HAVE_STD_UNORDERED_MAP 1
+#else
+// we only support clang versions above 2.9 and these all have the tr1
+// unordered_map
+#define HAVE_STD_TR1_UNORDERED_MAP 1
+#endif
+#else
+// align with -std=c++0x only for gcc >= 4.6 in CCFLAGS, contrary to
+// clang we can rely entirely on the compiler version
+#if ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4)
+#define HAVE_STD_UNORDERED_MAP 1
+#else
+#define HAVE_STD_TR1_UNORDERED_MAP 1
+#endif
+#endif
+
+// set a default value of 0
+#ifndef HAVE_STD_UNORDERED_MAP
+#define HAVE_STD_UNORDERED_MAP 0
+#endif
+
+// set a default value of 0
+#ifndef HAVE_STD_TR1_UNORDERED_MAP
+#define HAVE_STD_TR1_UNORDERED_MAP 0
+#endif
+
+// now we are ready to deal with the actual includes based on what is
+// available
+#if (HAVE_STD_UNORDERED_MAP || HAVE_STD_TR1_UNORDERED_MAP)
+
+#define hash_map unordered_map
+#define hash_multimap unordered_multimap
+#define hash_set unordered_set
+#define hash_multiset unordered_multiset
+
+// these versions also have an existing hash function for strings
+#define HAVE_STRING_HASH 1
+
+#if HAVE_STD_UNORDERED_MAP
+
+// clang or gcc >= 4.6
+#include <unordered_map>
+#include <unordered_set>
+// note that this assumes that -std=c++0x is added to the command line
+// which is done in the SConstruct CXXFLAGS for gcc >= 4.6 and clang
+// >= 3.0
+#define __hash_namespace std
+#define __hash_namespace_begin namespace std {
+#define __hash_namespace_end }
+#else
+// clang <= 3.0, gcc >= 4.3 and < 4.6
+#include <tr1/unordered_map>
+#include <tr1/unordered_set>
+#define __hash_namespace std::tr1
+#define __hash_namespace_begin namespace std { namespace tr1 {
+#define __hash_namespace_end } }
+#endif
+#else
+// gcc < 4.3
#include <ext/hash_map>
#include <ext/hash_set>
+#define __hash_namespace __gnu_cxx
+#define __hash_namespace_begin namespace __gnu_cxx {
+#define __hash_namespace_end }
+#endif
#else
+// non GNU compiler
#include <hash_map>
#include <hash_set>
+#define __hash_namsepace std
+#define __hash_namespace_begin namespace std {
+#define __hash_namespace_end }
#endif
#include <string>
#include "base/types.hh"
-#if defined(__GNUC__) && __GNUC__ >= 3
- #define __hash_namespace __gnu_cxx
-#else
- #define __hash_namespace std
-#endif
-
namespace m5 {
using ::__hash_namespace::hash_multimap;
using ::__hash_namespace::hash_multiset;
@@ -62,8 +151,8 @@ namespace m5 {
// Some default Hashing Functions
//
-namespace __hash_namespace {
-#if defined(__APPLE__) || !defined(__LP64__) && !defined(__alpha__) && !defined(__SUNPRO_CC)
+__hash_namespace_begin
+#if !defined(__LP64__) && !defined(__alpha__) && !defined(__SUNPRO_CC)
template<>
struct hash<uint64_t> {
size_t operator()(uint64_t r) const {
@@ -79,6 +168,9 @@ namespace __hash_namespace {
};
#endif
+// if the hash functions for strings are not already defined, then
+// declare them here
+#if !defined(HAVE_STRING_HASH)
template<>
struct hash<std::string> {
size_t operator()(const std::string &s) const {
@@ -92,6 +184,7 @@ namespace __hash_namespace {
return (__stl_hash_string(r.first.c_str())) ^ r.second;
}
};
-} // namespace __hash_namespace
+#endif
+__hash_namespace_end
#endif // __HASHMAP_HH__
diff --git a/src/base/inifile.cc b/src/base/inifile.cc
index 451198033..91e37f327 100644
--- a/src/base/inifile.cc
+++ b/src/base/inifile.cc
@@ -29,6 +29,7 @@
* Steve Reinhardt
*/
+#include <algorithm>
#include <fstream>
#include <iostream>
#include <string>
diff --git a/src/base/range.hh b/src/base/range.hh
index d9542c0ca..ac64a37f9 100644
--- a/src/base/range.hh
+++ b/src/base/range.hh
@@ -316,7 +316,13 @@ template <class T, class U>
inline bool
operator<(const Range<T> &range, const U &pos)
{
- return range.end < pos;
+ // with -std=gnu++0x, gcc and clang get confused when range.end is
+ // compared to pos using the operator "<", and the parser expects it
+ // to be the opening bracket for a template parameter,
+ // i.e. range.end<pos>(...);, the reason seems to be the range-type
+ // iteration introduced in c++11 where begin and end are members
+ // that return iterators
+ return operator<(range.end, pos);
}
/**
diff --git a/src/base/stats/text.cc b/src/base/stats/text.cc
index 8fb49dc59..28541ff59 100644
--- a/src/base/stats/text.cc
+++ b/src/base/stats/text.cc
@@ -166,7 +166,7 @@ ValueToString(Result value, int precision)
{
stringstream val;
- if (!isnan(value)) {
+ if (!std::isnan(value)) {
if (precision != -1)
val.precision(precision);
else if (value == rint(value))
@@ -211,15 +211,15 @@ void
ScalarPrint::operator()(ostream &stream) const
{
if ((flags.isSet(nozero) && value == 0.0) ||
- (flags.isSet(nonan) && isnan(value)))
+ (flags.isSet(nonan) && std::isnan(value)))
return;
stringstream pdfstr, cdfstr;
- if (!isnan(pdf))
+ if (!std::isnan(pdf))
ccprintf(pdfstr, "%.2f%%", pdf * 100.0);
- if (!isnan(cdf))
+ if (!std::isnan(cdf))
ccprintf(cdfstr, "%.2f%%", cdf * 100.0);
ccprintf(stream, "%-40s %12s %10s %10s", name,
diff --git a/src/cpu/inorder/inorder_dyn_inst.cc b/src/cpu/inorder/inorder_dyn_inst.cc
index 24895750b..760c63948 100644
--- a/src/cpu/inorder/inorder_dyn_inst.cc
+++ b/src/cpu/inorder/inorder_dyn_inst.cc
@@ -68,7 +68,7 @@ InOrderDynInst::InOrderDynInst(InOrderCPU *cpu,
inFrontEnd(true), frontSked(NULL), backSked(NULL),
squashingStage(0), predictTaken(false), procDelaySlotOnMispred(false),
fetchMemReq(NULL), dataMemReq(NULL), instEffAddr(0), eaCalcDone(false),
- lqIdx(0), sqIdx(0), instListIt(NULL), onInstList(false)
+ lqIdx(0), sqIdx(0), onInstList(false)
{
for(int i = 0; i < MaxInstSrcRegs; i++) {
_readySrcRegIdx[i] = false;
diff --git a/src/mem/ruby/common/Address.hh b/src/mem/ruby/common/Address.hh
index 7ab3d1251..ce1e76e91 100644
--- a/src/mem/ruby/common/Address.hh
+++ b/src/mem/ruby/common/Address.hh
@@ -31,6 +31,7 @@
#include <cassert>
#include <iomanip>
+#include <iostream>
#include "base/hashmap.hh"
#include "mem/ruby/common/TypeDefines.hh"
@@ -201,8 +202,7 @@ Address::shiftLowOrderBits(int number) const
return (m_address >> number);
}
-class Address;
-namespace __hash_namespace {
+__hash_namespace_begin
template <> struct hash<Address>
{
size_t
@@ -211,7 +211,7 @@ template <> struct hash<Address>
return (size_t)s.getAddress();
}
};
-} // namespace __hash_namespace
+__hash_namespace_end
namespace std {
template <> struct equal_to<Address>
diff --git a/src/mem/ruby/common/NetDest.cc b/src/mem/ruby/common/NetDest.cc
index 82c60f415..2d070d33d 100644
--- a/src/mem/ruby/common/NetDest.cc
+++ b/src/mem/ruby/common/NetDest.cc
@@ -26,6 +26,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <algorithm>
+
#include "mem/ruby/common/NetDest.hh"
NetDest::NetDest()
diff --git a/src/mem/ruby/network/fault_model/FaultModel.cc b/src/mem/ruby/network/fault_model/FaultModel.cc
index 195f7c66c..83679984d 100644
--- a/src/mem/ruby/network/fault_model/FaultModel.cc
+++ b/src/mem/ruby/network/fault_model/FaultModel.cc
@@ -37,11 +37,8 @@
* Proceedings of the 48th Design Automation Conference (DAC'11)
*/
-// C includes
-#include <assert.h>
-#include <stdio.h>
-
// C++ includes
+#include <cassert>
#include <fstream>
#include <iostream>
#include <vector>
@@ -50,6 +47,8 @@
#include "FaultModel.hh"
#include "base/misc.hh"
+using namespace std;
+
#define MAX(a,b) ((a > b) ? (a) : (b))
diff --git a/src/mem/ruby/network/fault_model/FaultModel.hh b/src/mem/ruby/network/fault_model/FaultModel.hh
index 12a3f3844..c099220ca 100644
--- a/src/mem/ruby/network/fault_model/FaultModel.hh
+++ b/src/mem/ruby/network/fault_model/FaultModel.hh
@@ -47,7 +47,6 @@
// C++ includes
#include <string>
-using namespace std;
// GEM5 includes
#include "params/FaultModel.hh"
@@ -112,7 +111,7 @@ class FaultModel : public SimObject
int number_of_buff_per_data_vc,
int number_of_buff_per_ctrl_vc);
- string fault_type_to_string(int fault_type_index);
+ std::string fault_type_to_string(int fault_type_index);
// the following 2 functions are called at runtime, to get the probability
// of each fault type (fault_vector) or the aggregate fault probability
@@ -134,9 +133,9 @@ class FaultModel : public SimObject
void print(void);
private:
- vector <system_conf> configurations;
- vector <system_conf> routers;
- vector <int> temperature_weights;
+ std::vector <system_conf> configurations;
+ std::vector <system_conf> routers;
+ std::vector <int> temperature_weights;
};
#endif // __MEM_RUBY_NETWORK_FAULT_MODEL_HH__
diff --git a/src/mem/ruby/network/garnet/BaseGarnetNetwork.cc b/src/mem/ruby/network/garnet/BaseGarnetNetwork.cc
index f7093c8ba..69d513329 100644
--- a/src/mem/ruby/network/garnet/BaseGarnetNetwork.cc
+++ b/src/mem/ruby/network/garnet/BaseGarnetNetwork.cc
@@ -33,6 +33,8 @@
#include "mem/ruby/network/Topology.hh"
#include "mem/ruby/network/garnet/BaseGarnetNetwork.hh"
+using namespace std;
+
BaseGarnetNetwork::BaseGarnetNetwork(const Params *p)
: Network(p)
{
diff --git a/src/mem/ruby/network/orion/OrionConfig.hh b/src/mem/ruby/network/orion/OrionConfig.hh
index 7138fd8a2..d9b0e0830 100644
--- a/src/mem/ruby/network/orion/OrionConfig.hh
+++ b/src/mem/ruby/network/orion/OrionConfig.hh
@@ -37,8 +37,6 @@
#include "mem/ruby/network/orion/Type.hh"
-using namespace std;
-
class TechParameter;
class OrionConfig
@@ -56,12 +54,12 @@ class OrionConfig
void set_in_buf_num_set(uint32_t in_buf_num_set_);
void set_flit_width(uint32_t flit_width_);
- void read_file(const string& filename_);
- void print_config(ostream& out_);
+ void read_file(const std::string& filename_);
+ void print_config(std::ostream& out_);
public:
template<class T>
- T get(const string& key_) const;
+ T get(const std::string& key_) const;
const TechParameter* get_tech_param_ptr() const { return m_tech_param_ptr; }
uint32_t get_num_in_port() const { return m_num_in_port; }
uint32_t get_num_out_port() const { return m_num_out_port; }
@@ -71,7 +69,7 @@ class OrionConfig
uint32_t get_flit_width() const { return m_flit_width; }
private:
- map<string, string> m_params_map;
+ std::map<std::string, std::string> m_params_map;
TechParameter* m_tech_param_ptr;
uint32_t m_num_in_port;
@@ -84,28 +82,28 @@ class OrionConfig
protected:
struct key_not_found
{
- string m_key;
- key_not_found(const string& key_ = string()) : m_key(key_)
+ std::string m_key;
+ key_not_found(const std::string& key_ = string()) : m_key(key_)
{}
};
template<class T>
- static T string_as_T(const string& str_);
+ static T string_as_T(const std::string& str_);
template<class T>
- static string T_as_string(const T& t_);
+ static std::string T_as_string(const T& t_);
private:
- static string ms_param_name[];
+ static std::string ms_param_name[];
};
template<class T>
T OrionConfig::get(const string& key_) const
{
- map<string, string>::const_iterator it;
+ std::map<std::string, std::string>::const_iterator it;
it = m_params_map.find(key_);
if (it == m_params_map.end())
{
- cerr << key_ << " NOT FOUND!" << endl;
+ std::cerr << key_ << " NOT FOUND!" << std::endl;
throw key_not_found(key_);
}
return string_as_T<T>(it->second);
@@ -140,7 +138,8 @@ inline bool OrionConfig::string_as_T<bool>(const string& str_)
}
else
{
- cerr << "Invalid bool value: '" << str_ << "'. Treated as FALSE." << endl;
+ std::cerr << "Invalid bool value: '" << str_ <<
+ "'. Treated as FALSE." << std::endl;
ret = false;
}
return ret;
diff --git a/src/mem/ruby/network/orion/OrionRouter.cc b/src/mem/ruby/network/orion/OrionRouter.cc
index e6fc88a78..bcf7c3920 100644
--- a/src/mem/ruby/network/orion/OrionRouter.cc
+++ b/src/mem/ruby/network/orion/OrionRouter.cc
@@ -43,6 +43,8 @@
#include "mem/ruby/network/orion/OrionConfig.hh"
#include "OrionRouter.hh"
+using namespace std;
+
OrionRouter::OrionRouter(
uint32_t num_in_port_,
uint32_t num_out_port_,
diff --git a/src/mem/ruby/network/orion/TechParameter.hh b/src/mem/ruby/network/orion/TechParameter.hh
index af9ba65d4..c894a513c 100644
--- a/src/mem/ruby/network/orion/TechParameter.hh
+++ b/src/mem/ruby/network/orion/TechParameter.hh
@@ -40,8 +40,6 @@
#include "mem/ruby/network/orion/Type.hh"
-using namespace std;
-
class OrionConfig;
class TechParameter
diff --git a/src/mem/ruby/profiler/Profiler.cc b/src/mem/ruby/profiler/Profiler.cc
index 04e44bc13..098eb9b1f 100644
--- a/src/mem/ruby/profiler/Profiler.cc
+++ b/src/mem/ruby/profiler/Profiler.cc
@@ -45,6 +45,8 @@
// Allows use of times() library call, which determines virtual runtime
#include <sys/resource.h>
#include <sys/times.h>
+#include <sys/types.h>
+#include <unistd.h>
#include <algorithm>
#include <fstream>
diff --git a/src/mem/ruby/system/PerfectCacheMemory.hh b/src/mem/ruby/system/PerfectCacheMemory.hh
index b880b6434..33419c5c7 100644
--- a/src/mem/ruby/system/PerfectCacheMemory.hh
+++ b/src/mem/ruby/system/PerfectCacheMemory.hh
@@ -188,7 +188,6 @@ PerfectCacheMemory<ENTRY>::changePermission(const Address& address,
Address line_address = address;
line_address.makeLineAddress();
PerfectCacheLineState<ENTRY>& line_state = m_map[line_address];
- AccessPermission old_perm = line_state.m_permission;
line_state.m_permission = new_perm;
}
diff --git a/src/mem/slicc/symbols/StateMachine.py b/src/mem/slicc/symbols/StateMachine.py
index a9886b229..41348ba6d 100644
--- a/src/mem/slicc/symbols/StateMachine.py
+++ b/src/mem/slicc/symbols/StateMachine.py
@@ -408,6 +408,9 @@ void unset_tbe(${{self.TBEType.c_ident}}*& m_tbe_ptr);
* Created by slicc definition of Module "${{self.short}}"
*/
+#include <sys/types.h>
+#include <unistd.h>
+
#include <cassert>
#include <sstream>
#include <string>
@@ -990,6 +993,9 @@ $c_ident::${{action.ident}}(const Address& addr)
// Auto generated C++ code started by $__file__:$__line__
// ${ident}: ${{self.short}}
+#include <sys/types.h>
+#include <unistd.h>
+
#include <cassert>
#include "base/misc.hh"
diff --git a/src/sim/init.cc b/src/sim/init.cc
index 02361fd84..788d125c3 100644
--- a/src/sim/init.cc
+++ b/src/sim/init.cc
@@ -113,7 +113,7 @@ initSignals()
EmbeddedPython *EmbeddedPython::importer = NULL;
PyObject *EmbeddedPython::importerModule = NULL;
EmbeddedPython::EmbeddedPython(const char *filename, const char *abspath,
- const char *modpath, const char *code, int zlen, int len)
+ const char *modpath, const unsigned char *code, int zlen, int len)
: filename(filename), abspath(abspath), modpath(modpath), code(code),
zlen(zlen), len(len)
{
diff --git a/src/sim/init.hh b/src/sim/init.hh
index 8fc0be982..ee40b9790 100644
--- a/src/sim/init.hh
+++ b/src/sim/init.hh
@@ -36,6 +36,8 @@
*/
#include <list>
+#include <inttypes.h>
+
#ifndef PyObject_HEAD
struct _object;
typedef _object PyObject;
@@ -46,12 +48,12 @@ struct EmbeddedPython
const char *filename;
const char *abspath;
const char *modpath;
- const char *code;
+ const uint8_t *code;
int zlen;
int len;
EmbeddedPython(const char *filename, const char *abspath,
- const char *modpath, const char *code, int zlen, int len);
+ const char *modpath, const uint8_t *code, int zlen, int len);
PyObject *getCode() const;
bool addModule() const;