]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
endian: simplify __le* type hackery
authorSage Weil <sage@newdream.net>
Fri, 7 May 2010 20:45:00 +0000 (13:45 -0700)
committerSage Weil <sage@newdream.net>
Wed, 26 May 2010 23:43:22 +0000 (16:43 -0700)
Instead of preventing linux/types.h from being included, instead name
our types ceph_le*, and remap using #define _only_ when including the
shared kernel/userspace headers.

Also redefine some templates for both __u64 and uint64_t, which are
apparently not the same on x86_64.

src/include/byteorder.h
src/include/encoding.h
src/include/hash.h
src/include/inttypes.h
src/include/types.h
src/include/utime.h
src/mds/CDir.cc
src/msg/SimpleMessenger.cc
src/osd/osd_types.h

index 304ed5ee755a475ff74b4e53a38d6f9c4391fd34..3907d89020572d2a5908bf710b2e88092049f2b2 100644 (file)
@@ -48,15 +48,15 @@ static __inline__ __u64 swab64(__u64 val)
 
 
 #define MAKE_LE_CLASS(bits)                                            \
-  struct __le##bits {                                                  \
+  struct ceph_le##bits {                                                       \
     __u##bits v;                                                       \
-    __le##bits &operator=(__u##bits nv) {                              \
+    ceph_le##bits &operator=(__u##bits nv) {                           \
       v = mswab##bits(nv);                                             \
       return *this;                                                    \
     }                                                                  \
     operator __u##bits() const { return mswab##bits(v); }              \
   } __attribute__ ((packed));                                          \
-  static inline bool operator==(__le##bits a, __le##bits b) {          \
+  static inline bool operator==(ceph_le##bits a, ceph_le##bits b) {            \
     return a.v == b.v;                                                 \
   }
   
index 16d08799c88a0812246e0921f01526f5581edc50..af79670c2d47f338b358915a309e745ce702b568 100644 (file)
@@ -42,9 +42,9 @@ inline void decode_raw(T& t, bufferlist::iterator &p)
 WRITE_RAW_ENCODER(__u8)
 WRITE_RAW_ENCODER(__s8)
 WRITE_RAW_ENCODER(char)
-WRITE_RAW_ENCODER(__le64)
-WRITE_RAW_ENCODER(__le32)
-WRITE_RAW_ENCODER(__le16)
+WRITE_RAW_ENCODER(ceph_le64)
+WRITE_RAW_ENCODER(ceph_le32)
+WRITE_RAW_ENCODER(ceph_le16)
 
 // FIXME: we need to choose some portable floating point encoding here
 WRITE_RAW_ENCODER(float)
index bb1499cada46b10023a75063aa68da55241b72ff..7f95dd74f828e92a8dae7cab35b6734b10c306de 100644 (file)
@@ -57,6 +57,12 @@ template<> struct rjhash<uint64_t> {
   }
 };
 
+template<> struct rjhash<__u64> {
+  inline size_t operator()(const __u64 x) const {
+    return rjhash64(x);
+  }
+};
+
 #if defined(__CYGWIN__) || defined(DARWIN)
 template<> struct rjhash<size_t> {
   inline size_t operator()(const size_t x) const {
index c9147102fc488ffe22018886bdeabb76d6f0a777..9862be963c48ac77c0af970e6bf021b80eefd2f1 100644 (file)
@@ -2,14 +2,6 @@
 #define _CEPH_INTTYPES_H
 
 #include <stdint.h>
-
-typedef uint64_t __u64;
-typedef int64_t __s64;
-typedef uint32_t __u32;
-typedef int32_t __s32;
-typedef uint16_t __u16;
-typedef int16_t __s16;
-typedef uint8_t __u8;
-typedef int8_t __s8;
+#include <linux/types.h>
 
 #endif
index 802cfca6cbc274b54bbfa17f4915c01d59eead8f..395e611147090878064c5a2e30b7e77668843302 100644 (file)
 #define __CEPH_TYPES_H
 
 // this is needed for ceph_fs to compile in userland
-#include <netinet/in.h>
-#define _LINUX_TYPES_H /* we don't want linux/types.h's __u32, __le32, etc. */
 #include "inttypes.h"
 #include "byteorder.h"
+
+#include <netinet/in.h>
 #include <fcntl.h>
 #include <string.h>
 
+// <macro hackery>
+// temporarily remap __le* to ceph_le* for benefit of shared kernel/userland headers
+#define __le16 ceph_le16
+#define __le32 ceph_le32
+#define __le64 ceph_le64
 #include "ceph_fs.h"
 #include "ceph_frag.h"
+#include "rbd_types.h"
+#undef __le16
+#undef __le32
+#undef __le64
+// </macro hackery>
+
 
 #define _BACKWARD_BACKWARD_WARNING_H   /* make gcc 4.3 shut up about hash_*. */
 
index 473d9821ea05ca88fc3193c0f544801a06ba958b..99b31f03f1631c75dfeb990f265fc80de6e09c5f 100644 (file)
 #ifndef __UTIME_H
 #define __UTIME_H
 
-// this is needed for ceph_fs to compile in userland
-#include <netinet/in.h>
-#define _LINUX_TYPES_H /* we don't want linux/types.h's __u32, __le32, etc. */
-#include "inttypes.h"
-#include "byteorder.h"
-#include <fcntl.h>
-#include <string.h>
-
-#include "ceph_fs.h"
-
 #include <math.h>
 #include <sys/time.h>
 #include <time.h>
 
-#include "buffer.h"
-#include "encoding.h"
-
 // --------
 // utime_t
 
index 99838e55b4ed2f9f7e67bdaf753825771e352c74..924eb915ce6068193b3c2b13615ba254f34b2888 100644 (file)
@@ -1499,7 +1499,7 @@ void CDir::_encode_dentry(CDentry *dn, bufferlist& bl,
 
   dn->key().encode(bl);
 
-  __le32 plen = init_le32(0);
+  ceph_le32 plen = init_le32(0);
   unsigned plen_off = bl.length();
   ::encode(plen, bl);
 
@@ -1545,7 +1545,7 @@ void CDir::_encode_dentry(CDentry *dn, bufferlist& bl,
   
   plen = bl.length() - plen_off - sizeof(__u32);
 
-  __le32 eplen;
+  ceph_le32 eplen;
   eplen = plen;
   bl.copy_in(plen_off, sizeof(eplen), (char*)&eplen);
 }
index c2c9521ffbbedf4e7318f76fe8bced924dca650a..5f72aca530e20030eb966ffc549a74ca89f1de00 100644 (file)
@@ -1446,7 +1446,7 @@ void SimpleMessenger::Pipe::reader()
     // open ...
     if (tag == CEPH_MSGR_TAG_ACK) {
       dout(20) << "reader got ACK" << dendl;
-      __le64 seq;
+      ceph_le64 seq;
       int rc = tcp_read( sd, (char*)&seq, sizeof(seq));
       pipe_lock.Lock();
       if (rc < 0) {
@@ -1884,7 +1884,7 @@ int SimpleMessenger::Pipe::write_ack(__u64 seq)
   dout(10) << "write_ack " << seq << dendl;
 
   char c = CEPH_MSGR_TAG_ACK;
-  __le64 s;
+  ceph_le64 s;
   s = seq;
 
   struct msghdr msg;
index ee56b32e00b27fd015db07fcd65853acf22ed526..36136fc7ae5221459fcf8aad5728fbbf76541c29 100644 (file)
@@ -83,7 +83,7 @@ inline bool operator>=(const osd_reqid_t& l, const osd_reqid_t& r) { return !(l
 namespace __gnu_cxx {
   template<> struct hash<osd_reqid_t> {
     size_t operator()(const osd_reqid_t &r) const { 
-      static hash<__u64> H;
+      static hash<uint64_t> H;
       return H(r.name.num() ^ r.tid ^ r.inc);
     }
   };