From: Casey Bodley Date: Fri, 31 Jul 2015 15:50:57 +0000 (-0400) Subject: c++11: remove hash_namespace.h and default to std X-Git-Tag: v9.1.0~419^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3a6808049a844f343c8ce5cf7c12a96a8298898d;p=ceph.git c++11: remove hash_namespace.h and default to std Signed-off-by: Casey Bodley --- diff --git a/src/common/hobject.h b/src/common/hobject.h index 4f07cca3bca5..1b7c3db2831b 100644 --- a/src/common/hobject.h +++ b/src/common/hobject.h @@ -153,7 +153,7 @@ public: /* Do not use when a particular hash function is needed */ explicit hobject_t(const sobject_t &o) : oid(o.oid), snap(o.snap), max(false), pool(POOL_META) { - set_hash(CEPH_HASH_NAMESPACE::hash()(o)); + set_hash(std::hash()(o)); } // maximum sorted value. @@ -235,7 +235,7 @@ public: }; WRITE_CLASS_ENCODER(hobject_t) -CEPH_HASH_NAMESPACE_START +namespace std { template<> struct hash { size_t operator()(const hobject_t &r) const { static hash H; @@ -243,7 +243,7 @@ CEPH_HASH_NAMESPACE_START return H(r.oid) ^ I(r.snap); } }; -CEPH_HASH_NAMESPACE_END +} // namespace std ostream& operator<<(ostream& out, const hobject_t& o); @@ -364,7 +364,7 @@ public: }; WRITE_CLASS_ENCODER(ghobject_t) -CEPH_HASH_NAMESPACE_START +namespace std { template<> struct hash { size_t operator()(const ghobject_t &r) const { static hash H; @@ -372,7 +372,7 @@ CEPH_HASH_NAMESPACE_START return H(r.hobj.oid) ^ I(r.hobj.snap); } }; -CEPH_HASH_NAMESPACE_END +} // namespace std ostream& operator<<(ostream& out, const ghobject_t& o); diff --git a/src/common/lockdep.cc b/src/common/lockdep.cc index 5f9fa191a07d..79fd56c61ba7 100644 --- a/src/common/lockdep.cc +++ b/src/common/lockdep.cc @@ -19,10 +19,9 @@ #include "lockdep.h" #include "include/unordered_map.h" -#include "include/hash_namespace.h" #if defined(__FreeBSD__) && defined(__LP64__) // On FreeBSD pthread_t is a pointer. -CEPH_HASH_NAMESPACE_START +namespace std { template<> struct hash { @@ -30,7 +29,7 @@ CEPH_HASH_NAMESPACE_START operator()(pthread_t __x) const { return (uintptr_t)__x; } }; -CEPH_HASH_NAMESPACE_END +} // namespace std #endif /******* Constants **********/ diff --git a/src/include/Makefile.am b/src/include/Makefile.am index c07aa9f5800b..b3ceb24bf1a5 100644 --- a/src/include/Makefile.am +++ b/src/include/Makefile.am @@ -111,6 +111,5 @@ noinst_HEADERS += \ include/on_exit.h \ include/memory.h \ include/rados/memory.h \ - include/hash_namespace.h \ include/unordered_set.h \ include/unordered_map.h diff --git a/src/include/hash_namespace.h b/src/include/hash_namespace.h deleted file mode 100644 index 5a3dbe8df2c2..000000000000 --- a/src/include/hash_namespace.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef CEPH_HASH_NAMESPACE_H -#define CEPH_HASH_NAMESPACE_H - -#include - -#include - -#define CEPH_HASH_NAMESPACE_START namespace std { -#define CEPH_HASH_NAMESPACE_END } -#define CEPH_HASH_NAMESPACE std - -#endif diff --git a/src/include/object.h b/src/include/object.h index 57f099a57b6d..0f511435b9b6 100644 --- a/src/include/object.h +++ b/src/include/object.h @@ -23,7 +23,6 @@ using namespace std; #include "include/unordered_map.h" -#include "include/hash_namespace.h" #include "hash.h" #include "encoding.h" @@ -75,7 +74,7 @@ inline ostream& operator<<(ostream& out, const object_t& o) { return out << o.name; } -CEPH_HASH_NAMESPACE_START +namespace std { template<> struct hash { size_t operator()(const object_t& r) const { //static hash H; @@ -83,7 +82,7 @@ CEPH_HASH_NAMESPACE_START return ceph_str_hash_linux(r.name.c_str(), r.name.length()); } }; -CEPH_HASH_NAMESPACE_END +} // namespace std struct file_object_t { @@ -176,7 +175,7 @@ inline bool operator<=(const sobject_t &l, const sobject_t &r) { inline ostream& operator<<(ostream& out, const sobject_t &o) { return out << o.oid << "/" << o.snap; } -CEPH_HASH_NAMESPACE_START +namespace std { template<> struct hash { size_t operator()(const sobject_t &r) const { static hash H; @@ -184,6 +183,6 @@ CEPH_HASH_NAMESPACE_START return H(r.oid) ^ I(r.snap); } }; -CEPH_HASH_NAMESPACE_END +} // namespace std #endif diff --git a/src/include/types.h b/src/include/types.h index ddb0e9aed729..5cbcfc00c854 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -62,7 +62,6 @@ extern "C" { using namespace std; #include "include/unordered_map.h" -#include "include/hash_namespace.h" #include "object.h" #include "intarith.h" @@ -303,7 +302,7 @@ inline ostream& operator<<(ostream& out, inodeno_t ino) { return out << hex << ino.val << dec; } -CEPH_HASH_NAMESPACE_START +namespace std { template<> struct hash< inodeno_t > { size_t operator()( const inodeno_t& x ) const @@ -312,7 +311,7 @@ CEPH_HASH_NAMESPACE_START return H(x.val); } }; -CEPH_HASH_NAMESPACE_END +} // namespace std // file modes diff --git a/src/mds/mdstypes.h b/src/mds/mdstypes.h index e0a421fdd85f..9ed51e249938 100644 --- a/src/mds/mdstypes.h +++ b/src/mds/mdstypes.h @@ -25,7 +25,6 @@ #include #include "include/assert.h" -#include "include/hash_namespace.h" #include @@ -301,7 +300,7 @@ inline bool operator==(const quota_info_t &l, const quota_info_t &r) { ostream& operator<<(ostream &out, const quota_info_t &n); -CEPH_HASH_NAMESPACE_START +namespace std { template<> struct hash { size_t operator()(const vinodeno_t &vino) const { hash H; @@ -309,7 +308,7 @@ CEPH_HASH_NAMESPACE_START return H(vino.ino) ^ I(vino.snapid); } }; -CEPH_HASH_NAMESPACE_END +} // namespace std @@ -811,14 +810,14 @@ inline bool operator<=(const metareqid_t& l, const metareqid_t& r) { inline bool operator>(const metareqid_t& l, const metareqid_t& r) { return !(l <= r); } inline bool operator>=(const metareqid_t& l, const metareqid_t& r) { return !(l < r); } -CEPH_HASH_NAMESPACE_START +namespace std { template<> struct hash { size_t operator()(const metareqid_t &r) const { hash H; return H(r.name.num()) ^ H(r.name.type()) ^ H(r.tid); } }; -CEPH_HASH_NAMESPACE_END +} // namespace std // cap info for client reconnect @@ -936,7 +935,7 @@ inline bool operator==(dirfrag_t l, dirfrag_t r) { return l.ino == r.ino && l.frag == r.frag; } -CEPH_HASH_NAMESPACE_START +namespace std { template<> struct hash { size_t operator()(const dirfrag_t &df) const { static rjhash H; @@ -944,7 +943,7 @@ CEPH_HASH_NAMESPACE_START return H(df.ino) ^ I(df.frag); } }; -CEPH_HASH_NAMESPACE_END +} // namespace std diff --git a/src/msg/msg_types.h b/src/msg/msg_types.h index 4f4629b2d67d..62deacffffa5 100644 --- a/src/msg/msg_types.h +++ b/src/msg/msg_types.h @@ -20,7 +20,6 @@ #include "include/types.h" #include "include/blobhash.h" #include "include/encoding.h" -#include "include/hash_namespace.h" namespace ceph { class Formatter; @@ -133,7 +132,7 @@ inline std::ostream& operator<<(std::ostream& out, const ceph_entity_name& addr) return out << *(const entity_name_t*)&addr; } -CEPH_HASH_NAMESPACE_START +namespace std { template<> struct hash< entity_name_t > { size_t operator()( const entity_name_t &m ) const @@ -141,7 +140,7 @@ CEPH_HASH_NAMESPACE_START return rjhash32(m.type() ^ m.num()); } }; -CEPH_HASH_NAMESPACE_END +} // namespace std @@ -353,7 +352,7 @@ inline bool operator<=(const entity_addr_t& a, const entity_addr_t& b) { return inline bool operator>(const entity_addr_t& a, const entity_addr_t& b) { return memcmp(&a, &b, sizeof(a)) > 0; } inline bool operator>=(const entity_addr_t& a, const entity_addr_t& b) { return memcmp(&a, &b, sizeof(a)) >= 0; } -CEPH_HASH_NAMESPACE_START +namespace std { template<> struct hash< entity_addr_t > { size_t operator()( const entity_addr_t& x ) const @@ -362,7 +361,7 @@ CEPH_HASH_NAMESPACE_START return H((const char*)&x, sizeof(x)); } }; -CEPH_HASH_NAMESPACE_END +} // namespace std /* @@ -407,7 +406,7 @@ inline bool operator<=(const entity_inst_t& a, const entity_inst_t& b) { inline bool operator>(const entity_inst_t& a, const entity_inst_t& b) { return b < a; } inline bool operator>=(const entity_inst_t& a, const entity_inst_t& b) { return b <= a; } -CEPH_HASH_NAMESPACE_START +namespace std { template<> struct hash< entity_inst_t > { size_t operator()( const entity_inst_t& x ) const @@ -417,7 +416,7 @@ CEPH_HASH_NAMESPACE_START return H(x.name) ^ I(x.addr); } }; -CEPH_HASH_NAMESPACE_END +} // namespace std inline ostream& operator<<(ostream& out, const entity_inst_t &i) diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index 0c45f413ebc0..a87d9ed97e9b 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -134,14 +134,14 @@ inline bool operator<=(const osd_reqid_t& l, const osd_reqid_t& r) { inline bool operator>(const osd_reqid_t& l, const osd_reqid_t& r) { return !(l <= r); } inline bool operator>=(const osd_reqid_t& l, const osd_reqid_t& r) { return !(l < r); } -CEPH_HASH_NAMESPACE_START +namespace std { template<> struct hash { size_t operator()(const osd_reqid_t &r) const { static hash H; return H(r.name.num() ^ r.tid ^ r.inc); } }; -CEPH_HASH_NAMESPACE_END +} // namespace std // ----- @@ -399,7 +399,7 @@ inline bool operator>=(const pg_t& l, const pg_t& r) { ostream& operator<<(ostream& out, const pg_t &pg); -CEPH_HASH_NAMESPACE_START +namespace std { template<> struct hash< pg_t > { size_t operator()( const pg_t& x ) const @@ -408,7 +408,7 @@ CEPH_HASH_NAMESPACE_START return H((x.pool() & 0xffffffff) ^ (x.pool() >> 32) ^ x.ps() ^ x.preferred()); } }; -CEPH_HASH_NAMESPACE_END +} // namespace std struct spg_t { pg_t pgid; @@ -480,7 +480,7 @@ WRITE_CLASS_ENCODER(spg_t) WRITE_EQ_OPERATORS_2(spg_t, pgid, shard) WRITE_CMP_OPERATORS_2(spg_t, pgid, shard) -CEPH_HASH_NAMESPACE_START +namespace std { template<> struct hash< spg_t > { size_t operator()( const spg_t& x ) const @@ -489,7 +489,7 @@ CEPH_HASH_NAMESPACE_START return H(hash()(x.pgid) ^ x.shard); } }; -CEPH_HASH_NAMESPACE_END +} // namespace std ostream& operator<<(ostream& out, const spg_t &pg); @@ -623,7 +623,7 @@ inline ostream& operator<<(ostream& out, const coll_t& c) { return out; } -CEPH_HASH_NAMESPACE_START +namespace std { template<> struct hash { size_t operator()(const coll_t &c) const { size_t h = 0; @@ -640,7 +640,7 @@ CEPH_HASH_NAMESPACE_START return h; } }; -CEPH_HASH_NAMESPACE_END +} // namespace std inline ostream& operator<<(ostream& out, const ceph_object_layout &ol) {