qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From astitc...@apache.org
Subject svn commit: r1601969 - in /qpid/trunk/qpid/cpp/src/qpid/sys/rdma: RdmaClient.cpp rdma_wrap.h
Date Wed, 11 Jun 2014 17:47:37 GMT
Author: astitcher
Date: Wed Jun 11 17:47:37 2014
New Revision: 1601969

URL: http://svn.apache.org/r1601969
Log:
QPID-3650: Avoid unaligned memory access

Modified:
    qpid/trunk/qpid/cpp/src/qpid/sys/rdma/RdmaClient.cpp
    qpid/trunk/qpid/cpp/src/qpid/sys/rdma/rdma_wrap.h

Modified: qpid/trunk/qpid/cpp/src/qpid/sys/rdma/RdmaClient.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/sys/rdma/RdmaClient.cpp?rev=1601969&r1=1601968&r2=1601969&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/rdma/RdmaClient.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/rdma/RdmaClient.cpp Wed Jun 11 17:47:37 2014
@@ -97,8 +97,8 @@ void write(Rdma::AsynchIO& aio) {
         Rdma::Buffer* b = aio.getSendBuffer();
         if (!b) break;
         b->dataCount(msgsize);
-        uint32_t* ip = reinterpret_cast<uint32_t*>(b->bytes());
-        uint32_t* lip = ip + b->dataCount() / sizeof(uint32_t);
+        uint32_t* ip = b->words();
+        uint32_t* lip = ip + b->wordCount();
         while (ip != lip) {*ip++ = *output; ++output;}
         aio.queueWrite(b);
         ++smsgs;
@@ -116,8 +116,8 @@ void data(Poller::shared_ptr p, Rdma::As
     
     // Check message is unaltered
     bool match = true;
-    uint32_t* ip = reinterpret_cast<uint32_t*>(b->bytes());
-    uint32_t* lip = ip + b->dataCount() / sizeof(uint32_t);
+    uint32_t* ip = b->words();
+    uint32_t* lip = ip + b->wordCount();
     while (ip != lip) { if (*ip++ != *input) {match = false; break;} ++input;}
     if (!match) {
         cout << "Data doesn't match: at msg " << rmsgs << " byte " <<
rbytes-b->dataCount() << " (ish)\n";

Modified: qpid/trunk/qpid/cpp/src/qpid/sys/rdma/rdma_wrap.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/sys/rdma/rdma_wrap.h?rev=1601969&r1=1601968&r2=1601969&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/rdma/rdma_wrap.h (original)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/rdma/rdma_wrap.h Wed Jun 11 17:47:37 2014
@@ -53,7 +53,9 @@ namespace Rdma {
         friend class QueuePairEvent;
 
         char* bytes() const;
+        uint32_t* words() const;
         int32_t byteCount() const;
+        int32_t wordCount() const;
         int32_t dataCount() const;
         void dataCount(int32_t);
 
@@ -68,11 +70,20 @@ namespace Rdma {
       return (char*) sge.addr;
     }
 
+    inline uint32_t* Buffer::words() const {
+        return (uint32_t*) sge.addr;
+    }
+
     /** return the number of bytes available for application data */
     inline int32_t Buffer::byteCount() const {
         return bufferSize - reserved;
     }
 
+    /** return the number of words available for application data */
+    inline int32_t Buffer::wordCount() const {
+        return (bufferSize - reserved) / sizeof(uint32_t);
+    }
+
     inline int32_t Buffer::dataCount() const {
         return sge.length;
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message