]> git.openfabrics.org - ~adrianc/mstflint.git/commitdiff
fixed compilation issues on PPC64 arch
authorAdrian Chiris <adrianc@mellanox.com>
Tue, 21 Apr 2015 17:17:07 +0000 (20:17 +0300)
committerAdrian Chiris <adrianc@mellanox.com>
Tue, 21 Apr 2015 17:17:07 +0000 (20:17 +0300)
cmdif/tools_cif.c
mtcr_ul/mtcr_tools_cif.c

index 29b2fc90a66e2a62392f39d59bcda5e4510d1eb1..fa16a2d04af65f85674d13ba89a96e7b51df2652 100644 (file)
 
 #if __BYTE_ORDER == __BIG_ENDIAN
 
-static u_int64_t swap_dwords_be(u_int8_t* buff) {
-    u_int32_t first = *(u_int32_t*)(&buff[0]);\
-    u_int32_t second = *(u_int32_t*)(&buff[4]);\
-    u_int64_t dest = 0;
-    dest = MERGE64(dest, first, 0, 32);
-    dest = MERGE64(dest, second, 32, 32);
-    return dest;
-}
+#define SWAP_DW_BE(uint64_num)\
+    (((uint64_num) & 0xffffffffULL) << 32) | (((uint64_num) >> 32) & 0xffffffffULL)
+
 #else
-static u_int64_t swap_dwords_be(u_int8_t* buff) {
-    return *((u_int64_t*)buff);
-}
+#define SWAP_DW_BE(uint64_num) (uint64_num)
 #endif
 
 //TODO: adrianc: if we find ourselves adding more and more commands consider using a macro to save code.
@@ -82,8 +75,7 @@ MError tcif_query_dev_cap(mfile *dev, u_int32_t offset, u_int64_t* data)
 {
     int rc = tools_cmdif_send_mbox_command(dev, 0, QUERY_DEV_CAP_OP, 0, offset, (u_int32_t*)data, 8, 1); CHECK_RC(rc);
     BE32_TO_CPU(data, 2);
-    *data = swap_dwords_be((u_int8_t*)data);
-
+    *data = SWAP_DW_BE(*data);
     return ME_OK;
 }
 
index eca6da8ae80468a163043e93163668977176d21b..45da20ab74e977562cb7f41cf3b5fc1fc45e77ee 100644 (file)
 
 #if __BYTE_ORDER == __BIG_ENDIAN
 
-static u_int64_t swap_dwords_be(u_int8_t* buff) {
-    u_int32_t first = *(u_int32_t*)(&buff[0]);\
-    u_int32_t second = *(u_int32_t*)(&buff[4]);\
-    u_int64_t dest = 0;
-    dest = MERGE64(dest, first, 0, 32);
-    dest = MERGE64(dest, second, 32, 32);
-    return dest;
-}
+#define SWAP_DW_BE(uint64_num)\
+    (((uint64_num) & 0xffffffffULL) << 32) | (((uint64_num) >> 32) & 0xffffffffULL)
+
 #else
-static u_int64_t swap_dwords_be(u_int8_t* buff) {
-    return *((u_int64_t*)buff);
-}
+#define SWAP_DW_BE(uint64_num) (uint64_num)
 #endif
 
 typedef struct tools_cmdif_t {
@@ -302,10 +295,10 @@ int tools_cmdif_send_inline_cmd(mfile* mf,
                      u_int8_t  opcode_modifier)
 {
     int rc;
-    in_param = swap_dwords_be((u_int8_t*)&in_param);
+    in_param = SWAP_DW_BE(in_param);
     rc = tools_cmdif_send_inline_cmd_int(mf, (u_int32_t*)((u_int8_t*)&in_param), (u_int32_t*)out_param, input_modifier, opcode, opcode_modifier);
     if (out_param) {
-        *out_param = swap_dwords_be((u_int8_t*)out_param);
+        *out_param = SWAP_DW_BE(*out_param);
     }
     return rc;
 }