[MOAB-dev] r1477 - MOAB/trunk
kraftche at mcs.anl.gov
kraftche at mcs.anl.gov
Wed Dec 19 10:15:03 CST 2007
Author: kraftche
Date: 2007-12-19 10:15:03 -0600 (Wed, 19 Dec 2007)
New Revision: 1477
Modified:
MOAB/trunk/MBSysUtil.cpp
Log:
Fix build erro on 32-bit platforms due to 64-bit constants.
Modified: MOAB/trunk/MBSysUtil.cpp
===================================================================
--- MOAB/trunk/MBSysUtil.cpp 2007-12-19 15:12:22 UTC (rev 1476)
+++ MOAB/trunk/MBSysUtil.cpp 2007-12-19 16:15:03 UTC (rev 1477)
@@ -99,16 +99,25 @@
((value & (uint32_t)0X000000FF) << 24);
}
+const uint64_t m64b1 = 0xFF;
+const uint64_t m64b2 = m64b1 << 8;
+const uint64_t m64b3 = m64b1 << 16;
+const uint64_t m64b4 = m64b1 << 24;
+const uint64_t m64b5 = m64b1 << 32;
+const uint64_t m64b6 = m64b1 << 40;
+const uint64_t m64b7 = m64b1 << 48;
+const uint64_t m64b8 = m64b1 << 56;
+
inline static uint64_t swap_bytes( uint64_t value )
{
- return ((value & (uint64_t)0xFF00000000000000) >> 56) |
- ((value & (uint64_t)0x00FF000000000000) >> 40) |
- ((value & (uint64_t)0x0000FF0000000000) >> 24) |
- ((value & (uint64_t)0x000000FF00000000) >> 8) |
- ((value & (uint64_t)0x00000000FF000000) << 8) |
- ((value & (uint64_t)0X0000000000FF0000) << 24) |
- ((value & (uint64_t)0x000000000000FF00) << 40) |
- ((value & (uint64_t)0X00000000000000FF) << 56);
+ return ((value & m64b8) >> 56) |
+ ((value & m64b7) >> 40) |
+ ((value & m64b6) >> 24) |
+ ((value & m64b5) >> 8) |
+ ((value & m64b4) << 8) |
+ ((value & m64b3) << 24) |
+ ((value & m64b2) << 40) |
+ ((value & m64b1) << 56);
}
/*
inline static uint32_t swap_byte_pairs( uint32_t value )
@@ -121,26 +130,26 @@
inline static uint64_t swap_byte_quads( uint64_t value )
{
- return ((value & (uint64_t)0xFF00000000000000) >> 24) |
- ((value & (uint64_t)0x00FF000000000000) >> 8) |
- ((value & (uint64_t)0x0000FF0000000000) << 8) |
- ((value & (uint64_t)0x000000FF00000000) << 24) |
- ((value & (uint64_t)0x00000000FF000000) >> 24) |
- ((value & (uint64_t)0X0000000000FF0000) >> 8) |
- ((value & (uint64_t)0x000000000000FF00) << 8) |
- ((value & (uint64_t)0X00000000000000FF) << 24);
+ return ((value & m64b8) >> 24) |
+ ((value & m64b7) >> 8) |
+ ((value & m64b6) << 8) |
+ ((value & m64b5) << 24) |
+ ((value & m64b4) >> 24) |
+ ((value & m64b3) >> 8) |
+ ((value & m64b2) << 8) |
+ ((value & m64b1) << 24);
}
inline static uint64_t swap_byte_pairs( uint64_t value )
{
- return ((value & (uint64_t)0xFF00000000000000) >> 8) |
- ((value & (uint64_t)0x00FF000000000000) << 8) |
- ((value & (uint64_t)0x0000FF0000000000) >> 8) |
- ((value & (uint64_t)0x000000FF00000000) << 8) |
- ((value & (uint64_t)0x00000000FF000000) >> 8) |
- ((value & (uint64_t)0X0000000000FF0000) << 8) |
- ((value & (uint64_t)0x000000000000FF00) >> 8) |
- ((value & (uint64_t)0X00000000000000FF) << 8);
+ return ((value & m64b8) >> 8) |
+ ((value & m64b7) << 8) |
+ ((value & m64b6) >> 8) |
+ ((value & m64b5) << 8) |
+ ((value & m64b4) >> 8) |
+ ((value & m64b3) << 8) |
+ ((value & m64b2) >> 8) |
+ ((value & m64b1) << 8);
}
*/
void byteswap2( void* data, size_t num_elem )
More information about the moab-dev
mailing list