From 3efd4745fc5f43fea3df75db10eb8cea78a7bc80 Mon Sep 17 00:00:00 2001 From: sageweil Date: Fri, 2 Mar 2007 20:03:58 +0000 Subject: [PATCH] build on 64-bit machines (LP64) git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1159 29311d96-e01e-0410-9327-a35deaab8ce9 --- trunk/ceph/include/object.h | 5 +++++ trunk/ceph/include/types.h | 2 ++ trunk/ceph/mon/MonitorStore.cc | 4 ++++ trunk/ceph/mon/MonitorStore.h | 12 ++++++++++++ trunk/ceph/osd/FakeStore.cc | 17 +++++++++++++++++ 5 files changed, 40 insertions(+) diff --git a/trunk/ceph/include/object.h b/trunk/ceph/include/object.h index 9773ecb4b3288..5d5a87727e5ad 100644 --- a/trunk/ceph/include/object.h +++ b/trunk/ceph/include/object.h @@ -72,13 +72,17 @@ inline ostream& operator<<(ostream& out, const object_t o) { out << '.' << o.rev; return out; } + + namespace __gnu_cxx { +#ifndef __LP64__ template<> struct hash<__uint64_t> { size_t operator()(__uint64_t __x) const { static hash<__uint32_t> H; return H((__x >> 32) ^ (__x & 0xffffffff)); } }; +#endif template<> struct hash { size_t operator()(const object_t &r) const { @@ -89,4 +93,5 @@ namespace __gnu_cxx { }; } + #endif diff --git a/trunk/ceph/include/types.h b/trunk/ceph/include/types.h index b09ee2d4726be..72893cb62141b 100644 --- a/trunk/ceph/include/types.h +++ b/trunk/ceph/include/types.h @@ -82,12 +82,14 @@ namespace __gnu_cxx { } }; +#ifndef __LP64__ template<> struct hash<__int64_t> { size_t operator()(__int64_t __x) const { static hash<__int32_t> H; return H((__x >> 32) ^ (__x & 0xffffffff)); } }; +#endif } diff --git a/trunk/ceph/mon/MonitorStore.cc b/trunk/ceph/mon/MonitorStore.cc index f93bb2082427b..35822d2db4e08 100644 --- a/trunk/ceph/mon/MonitorStore.cc +++ b/trunk/ceph/mon/MonitorStore.cc @@ -89,7 +89,11 @@ void MonitorStore::put_int(version_t val, const char *a, const char *b) } char vs[30]; +#ifdef __LP64__ + sprintf(vs, "%ld\n", val); +#else sprintf(vs, "%lld\n", val); +#endif char tfn[200]; sprintf(tfn, "%s.new", fn); diff --git a/trunk/ceph/mon/MonitorStore.h b/trunk/ceph/mon/MonitorStore.h index f1d5f67ab3473..122118f33f556 100644 --- a/trunk/ceph/mon/MonitorStore.h +++ b/trunk/ceph/mon/MonitorStore.h @@ -42,17 +42,29 @@ public: int put_bl_ss(bufferlist& bl, const char *a, const char *b); bool exists_bl_sn(const char *a, version_t b) { char bs[20]; +#ifdef __LP64__ + sprintf(bs, "%lu", b); +#else sprintf(bs, "%llu", b); +#endif return exists_bl_ss(a, bs); } int get_bl_sn(bufferlist& bl, const char *a, version_t b) { char bs[20]; +#ifdef __LP64__ + sprintf(bs, "%lu", b); +#else sprintf(bs, "%llu", b); +#endif return get_bl_ss(bl, a, bs); } int put_bl_sn(bufferlist& bl, const char *a, version_t b) { char bs[20]; +#ifdef __LP64__ + sprintf(bs, "%lu", b); +#else sprintf(bs, "%llu", b); +#endif return put_bl_ss(bl, a, bs); } diff --git a/trunk/ceph/osd/FakeStore.cc b/trunk/ceph/osd/FakeStore.cc index 1ff08530e4cfd..1360711f3b417 100644 --- a/trunk/ceph/osd/FakeStore.cc +++ b/trunk/ceph/osd/FakeStore.cc @@ -68,24 +68,41 @@ void FakeStore::get_oname(object_t oid, char *s) { static hash H; assert(sizeof(oid) == 16); +#ifdef __LP64__ + sprintf(s, "%s/objects/%02lx/%016lx.%016lx", basedir.c_str(), H(oid) & HASH_MASK, + *((__uint64_t*)&oid), + *(((__uint64_t*)&oid) + 1)); +#else sprintf(s, "%s/objects/%02x/%016llx.%016llx", basedir.c_str(), H(oid) & HASH_MASK, *((__uint64_t*)&oid), *(((__uint64_t*)&oid) + 1)); +#endif } void FakeStore::get_cdir(coll_t cid, char *s) { assert(sizeof(cid) == 8); +#ifdef __LP64__ + sprintf(s, "%s/collections/%016lx", basedir.c_str(), + cid); +#else sprintf(s, "%s/collections/%016llx", basedir.c_str(), cid); +#endif } void FakeStore::get_coname(coll_t cid, object_t oid, char *s) { assert(sizeof(oid) == 16); +#ifdef __LP64__ + sprintf(s, "%s/collections/%016lx/%016lx.%016lx", basedir.c_str(), cid, + *((__uint64_t*)&oid), + *(((__uint64_t*)&oid) + 1)); +#else sprintf(s, "%s/collections/%016llx/%016llx.%016llx", basedir.c_str(), cid, *((__uint64_t*)&oid), *(((__uint64_t*)&oid) + 1)); +#endif } -- 2.39.5