Daniel Carvalho has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/46324 )

Change subject: misc: Move namespace std out of namespace gem5
......................................................................

misc: Move namespace std out of namespace gem5

These included in the gem5 namespace, but they shouldn't
be.

Change-Id: Ic52886395420871a5b965f426d6c5871d8fef141
Signed-off-by: Daniel R. Carvalho <[email protected]>
---
M src/arch/power/types.hh
M src/arch/x86/types.hh
M src/base/bitunion.hh
M src/base/channel_addr.hh
M src/cpu/reg_class.hh
M src/cpu/simple/probes/simpoint.hh
M src/mem/ruby/common/MachineID.hh
M src/sim/futex_map.cc
M src/sim/futex_map.hh
9 files changed, 96 insertions(+), 84 deletions(-)



diff --git a/src/arch/power/types.hh b/src/arch/power/types.hh
index a4437c8..2073f4f 100644
--- a/src/arch/power/types.hh
+++ b/src/arch/power/types.hh
@@ -91,19 +91,19 @@
 // typedef int RegContextParam;
 // typedef int RegContextVal;

-} // PowerISA namespace
+} // namespace PowerISA
+} // namespace gem5

 namespace std {

 template<>
-struct hash<PowerISA::ExtMachInst> : public hash<uint32_t>
+struct hash<gem5::PowerISA::ExtMachInst> : public hash<uint32_t>
 {
-    size_t operator()(const PowerISA::ExtMachInst &emi) const {
+    size_t operator()(const gem5::PowerISA::ExtMachInst &emi) const {
         return hash<uint32_t>::operator()((uint32_t)emi);
     };
 };

 } // namespace std
-} // namespace gem5

 #endif // __ARCH_POWER_TYPES_HH__
diff --git a/src/arch/x86/types.hh b/src/arch/x86/types.hh
index 94dfd3e..a2c2771 100644
--- a/src/arch/x86/types.hh
+++ b/src/arch/x86/types.hh
@@ -290,16 +290,27 @@
     return true;
 }

-}
+} // namespace X86ISA
+
+// These two functions allow ExtMachInst to be used with SERIALIZE_SCALAR
+// and UNSERIALIZE_SCALAR.
+template <>
+void paramOut(CheckpointOut &cp, const std::string &name,
+        const X86ISA::ExtMachInst &machInst);
+template <>
+void paramIn(CheckpointIn &cp, const std::string &name,
+        X86ISA::ExtMachInst &machInst);
+
+} // namespace gem5

 namespace std
 {

 template<>
-struct hash<X86ISA::ExtMachInst>
+struct hash<gem5::X86ISA::ExtMachInst>
 {
     size_t
-    operator()(const X86ISA::ExtMachInst &emi) const
+    operator()(const gem5::X86ISA::ExtMachInst &emi) const
     {
         return (((uint64_t)emi.legacy << 48) |
                 ((uint64_t)emi.rex << 40) |
@@ -315,17 +326,6 @@
     };
 };

-}
-
-// These two functions allow ExtMachInst to be used with SERIALIZE_SCALAR
-// and UNSERIALIZE_SCALAR.
-template <>
-void paramOut(CheckpointOut &cp, const std::string &name,
-        const X86ISA::ExtMachInst &machInst);
-template <>
-void paramIn(CheckpointIn &cp, const std::string &name,
-        X86ISA::ExtMachInst &machInst);
-
-} // namespace gem5
+} // namespace std

 #endif // __ARCH_X86_TYPES_HH__
diff --git a/src/base/bitunion.hh b/src/base/bitunion.hh
index 7e6892a..0ef2695 100644
--- a/src/base/bitunion.hh
+++ b/src/base/bitunion.hh
@@ -540,21 +540,6 @@
 template <typename T>
using BitUnionBaseType = typename bitfield_backend::BitUnionBaseType<T>::Type;

-
-//An STL style hash structure for hashing BitUnions based on their base type.
-namespace std
-{
-    template <typename T>
-    struct hash<BitUnionType<T> > : public hash<BitUnionBaseType<T> >
-    {
-        size_t
-        operator() (const BitUnionType<T> &val) const
-        {
-            return hash<BitUnionBaseType<T> >::operator()(val);
-        }
-    };
-} // namespace std
-
 namespace bitfield_backend
 {
     template<typename T>
@@ -627,4 +612,18 @@

 } // namespace gem5

+//An STL style hash structure for hashing BitUnions based on their base type.
+namespace std
+{
+    template <typename T>
+ struct hash<gem5::BitUnionType<T>> : public hash<gem5::BitUnionBaseType<T>>
+    {
+        size_t
+        operator() (const gem5::BitUnionType<T> &val) const
+        {
+            return hash<gem5::BitUnionBaseType<T> >::operator()(val);
+        }
+    };
+} // namespace std
+
 #endif // __BASE_BITUNION_HH__
diff --git a/src/base/channel_addr.hh b/src/base/channel_addr.hh
index 168c8b2..ad60bae 100644
--- a/src/base/channel_addr.hh
+++ b/src/base/channel_addr.hh
@@ -195,17 +195,20 @@
     ChannelAddr _end;
 };

+} // namespace gem5
+
 namespace std
 {
     template<>
-    struct hash<ChannelAddr>
+    struct hash<gem5::ChannelAddr>
     {
-        typedef ChannelAddr argument_type;
+        typedef gem5::ChannelAddr argument_type;
         typedef std::size_t result_type;

         result_type
-        operator()(argument_type const &a) const noexcept {
-            return std::hash<ChannelAddr::Type>{}(
+        operator()(argument_type const &a) const noexcept
+        {
+            return std::hash<gem5::ChannelAddr::Type>{}(
                 static_cast<argument_type::Type>(a));
         }
     };
@@ -214,8 +217,6 @@
 /**
  * @ingroup api_channel_addr
  */
-std::ostream &operator<<(std::ostream &out, const ChannelAddr &addr);
-
-} // namespace gem5
+std::ostream &operator<<(std::ostream &out, const gem5::ChannelAddr &addr);

 #endif // __BASE_CHANNEL_ADDR_HH__
diff --git a/src/cpu/reg_class.hh b/src/cpu/reg_class.hh
index 2edcc28..eaa2c0e 100644
--- a/src/cpu/reg_class.hh
+++ b/src/cpu/reg_class.hh
@@ -307,19 +307,22 @@

 using PhysRegIdPtr = PhysRegId*;

+} // namespace gem5
+
 namespace std
 {
 template<>
-struct hash<RegId>
+struct hash<gem5::RegId>
 {
     size_t
-    operator()(const RegId& reg_id) const
+    operator()(const gem5::RegId& reg_id) const
     {
// Extract unique integral values for the effective fields of a RegId.
         const size_t flat_index = static_cast<size_t>(reg_id.flatIndex());
         const size_t class_num = static_cast<size_t>(reg_id.regClass);

- const size_t shifted_class_num = class_num << (sizeof(RegIndex) << 3);
+        const size_t shifted_class_num =
+            class_num << (sizeof(gem5::RegIndex) << 3);

// Concatenate the class_num to the end of the flat_index, in order to
         // maximize information retained.
@@ -328,14 +331,12 @@
         // If RegIndex is larger than size_t, then class_num will not be
         // considered by this hash function, so we may wish to perform a
         // different operation to include that information in the hash.
-        static_assert(sizeof(RegIndex) < sizeof(size_t),
+        static_assert(sizeof(gem5::RegIndex) < sizeof(size_t),
             "sizeof(RegIndex) should be less than sizeof(size_t)");

         return concatenated_hash;
     }
 };
-}
-
-} // namespace gem5
+} // namespace std

 #endif // __CPU__REG_CLASS_HH__
diff --git a/src/cpu/simple/probes/simpoint.hh b/src/cpu/simple/probes/simpoint.hh
index bf33916..4df51f5 100644
--- a/src/cpu/simple/probes/simpoint.hh
+++ b/src/cpu/simple/probes/simpoint.hh
@@ -60,17 +60,24 @@
  */
 typedef std::pair<Addr, Addr> BasicBlockRange;

+} // namespace gem5
+
 /** Overload hash function for BasicBlockRange type */
-namespace std {
+namespace std
+{
 template <>
-struct hash<BasicBlockRange>
+struct hash<gem5::BasicBlockRange>
 {
   public:
-    size_t operator()(const BasicBlockRange &bb) const {
-        return hash<Addr>()(bb.first + bb.second);
+    size_t operator()(const gem5::BasicBlockRange &bb) const
+    {
+        return hash<gem5::Addr>()(bb.first + bb.second);
     }
 };
-}
+} // namespace std
+
+namespace gem5
+{

 class SimPoint : public ProbeListenerObject
 {
diff --git a/src/mem/ruby/common/MachineID.hh b/src/mem/ruby/common/MachineID.hh
index 992976b..13649e0 100644
--- a/src/mem/ruby/common/MachineID.hh
+++ b/src/mem/ruby/common/MachineID.hh
@@ -84,22 +84,11 @@
     return (obj1.type != obj2.type || obj1.num != obj2.num);
 }

-namespace std {
-    template<>
-    struct hash<MachineID>
-    {
-        inline size_t operator()(const MachineID& id) const {
-            size_t hval = MachineType_base_level(id.type) << 16 | id.num;
-            return hval;
-        }
-    };
-}
-
 // Output operator declaration
-std::ostream& operator<<(std::ostream& out, const MachineID& obj);
+::std::ostream& operator<<(::std::ostream& out, const gem5::MachineID& obj);

-inline std::ostream&
-operator<<(std::ostream& out, const MachineID& obj)
+inline ::std::ostream&
+operator<<(::std::ostream& out, const MachineID& obj)
 {
     if ((obj.type < MachineType_NUM) && (obj.type >= MachineType_FIRST)) {
         out << MachineType_to_string(obj.type);
@@ -108,10 +97,23 @@
     }
     out << "-";
     out << obj.num;
-    out << std::flush;
+    out << ::std::flush;
     return out;
 }

 } // namespace gem5

+namespace std
+{
+    template<>
+    struct hash<gem5::MachineID>
+    {
+        inline size_t operator()(const gem5::MachineID& id) const
+        {
+ size_t hval = gem5::MachineType_base_level(id.type) << 16 | id.num;
+            return hval;
+        }
+    };
+} // namespace std
+
 #endif // __MEM_RUBY_COMMON_MACHINEID_HH__
diff --git a/src/sim/futex_map.cc b/src/sim/futex_map.cc
index ba4371c..8f622e2 100644
--- a/src/sim/futex_map.cc
+++ b/src/sim/futex_map.cc
@@ -40,18 +40,6 @@
     return addr == in.addr && tgid == in.tgid;
 }

-namespace std {
-    size_t hash<FutexKey>::operator()(const FutexKey& in) const
-    {
-        size_t hash = 65521;
-        for (int i = 0; i < sizeof(uint64_t) / sizeof(size_t); i++) {
-            hash ^= (size_t)(in.addr >> sizeof(size_t) * i) ^
-                    (size_t)(in.tgid >> sizeof(size_t) * i);
-        }
-        return hash;
-    }
-}
-
 WaiterState::WaiterState(ThreadContext* _tc, int _bitmask)
       : tc(_tc), bitmask(_bitmask) { }

diff --git a/src/sim/futex_map.hh b/src/sim/futex_map.hh
index 1521d4e..9348c43 100644
--- a/src/sim/futex_map.hh
+++ b/src/sim/futex_map.hh
@@ -52,18 +52,32 @@
     bool operator==(const FutexKey &in) const;
 };

-namespace std {
+} // namespace gem5
+
+namespace std
+{
     /**
* The unordered_map structure needs the parenthesis operator defined for
      * std::hash if a user defined key is used. Our key is is user defined
      * so we need to provide the hash functor.
      */
     template <>
-    struct hash<FutexKey>
+    struct hash<gem5::FutexKey>
     {
-        size_t operator()(const FutexKey& in) const;
+        size_t operator()(const gem5::FutexKey& in) const
+        {
+            size_t hash = 65521;
+            for (int i = 0; i < sizeof(uint64_t) / sizeof(size_t); i++) {
+                hash ^= (size_t)(in.addr >> sizeof(size_t) * i) ^
+                        (size_t)(in.tgid >> sizeof(size_t) * i);
+            }
+            return hash;
+        }
     };
-}
+} // namespace std
+
+namespace gem5
+{

 /**
  * WaiterState defines internal state of a waiter thread. The state

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/46324
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Ic52886395420871a5b965f426d6c5871d8fef141
Gerrit-Change-Number: 46324
Gerrit-PatchSet: 1
Gerrit-Owner: Daniel Carvalho <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to