diff options
author | Andreas Hansson <andreas.hansson@arm.com> | 2012-04-14 05:43:31 -0400 |
---|---|---|
committer | Andreas Hansson <andreas.hansson@arm.com> | 2012-04-14 05:43:31 -0400 |
commit | b6aa6d55eb856f99a06c400b5dcda118c46dacfa (patch) | |
tree | 02d6e99ad1c38462725aac4ed6c39216d6d93d71 /src/mem/ruby/network | |
parent | 29482e90bad9d1d93b20d4f55fc4583756d68b3b (diff) | |
download | gem5-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/mem/ruby/network')
-rw-r--r-- | src/mem/ruby/network/fault_model/FaultModel.cc | 7 | ||||
-rw-r--r-- | src/mem/ruby/network/fault_model/FaultModel.hh | 9 | ||||
-rw-r--r-- | src/mem/ruby/network/garnet/BaseGarnetNetwork.cc | 2 | ||||
-rw-r--r-- | src/mem/ruby/network/orion/OrionConfig.hh | 27 | ||||
-rw-r--r-- | src/mem/ruby/network/orion/OrionRouter.cc | 2 | ||||
-rw-r--r-- | src/mem/ruby/network/orion/TechParameter.hh | 2 |
6 files changed, 24 insertions, 25 deletions
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 |