[Python-checkins] cpython: Issue #16113: take 2 on big endian machines.

christian.heimes python-checkins at python.org
Wed Sep 7 07:01:27 EDT 2016


https://hg.python.org/cpython/rev/68df416e94ba
changeset:   103220:68df416e94ba
user:        Christian Heimes <christian at python.org>
date:        Wed Sep 07 13:01:15 2016 +0200
summary:
  Issue #16113: take 2 on big endian machines.

files:
  Modules/_sha3/kcp/KeccakP-1600-inplace32BI.c |  20 +++++----
  1 files changed, 11 insertions(+), 9 deletions(-)


diff --git a/Modules/_sha3/kcp/KeccakP-1600-inplace32BI.c b/Modules/_sha3/kcp/KeccakP-1600-inplace32BI.c
--- a/Modules/_sha3/kcp/KeccakP-1600-inplace32BI.c
+++ b/Modules/_sha3/kcp/KeccakP-1600-inplace32BI.c
@@ -188,17 +188,18 @@
     unsigned int lanePosition;
     for(lanePosition=0; lanePosition<laneCount; lanePosition++) {
         UINT8 laneAsBytes[8];
+        UINT32 low, high, temp, temp0, temp1;
+        UINT32 *stateAsHalfLanes;
         memcpy(laneAsBytes, data+lanePosition*8, 8);
-        UINT32 low = laneAsBytes[0]
+        low = laneAsBytes[0]
             | ((UINT32)(laneAsBytes[1]) << 8)
             | ((UINT32)(laneAsBytes[2]) << 16)
             | ((UINT32)(laneAsBytes[3]) << 24);
-        UINT32 high = laneAsBytes[4]
+        high = laneAsBytes[4]
             | ((UINT32)(laneAsBytes[5]) << 8)
             | ((UINT32)(laneAsBytes[6]) << 16)
             | ((UINT32)(laneAsBytes[7]) << 24);
-        UINT32 even, odd, temp, temp0, temp1;
-        UINT32 *stateAsHalfLanes = (UINT32*)state;
+        stateAsHalfLanes = (UINT32*)state;
         toBitInterleavingAndXOR(low, high, stateAsHalfLanes[lanePosition*2+0], stateAsHalfLanes[lanePosition*2+1], temp, temp0, temp1);
     }
 #endif
@@ -243,17 +244,18 @@
     unsigned int lanePosition;
     for(lanePosition=0; lanePosition<laneCount; lanePosition++) {
         UINT8 laneAsBytes[8];
+        UINT32 low, high, temp, temp0, temp1;
+        UINT32 *stateAsHalfLanes;
         memcpy(laneAsBytes, data+lanePosition*8, 8);
-        UINT32 low = laneAsBytes[0]
+        low = laneAsBytes[0]
             | ((UINT32)(laneAsBytes[1]) << 8)
             | ((UINT32)(laneAsBytes[2]) << 16)
             | ((UINT32)(laneAsBytes[3]) << 24);
-        UINT32 high = laneAsBytes[4]
+        high = laneAsBytes[4]
             | ((UINT32)(laneAsBytes[5]) << 8)
             | ((UINT32)(laneAsBytes[6]) << 16)
             | ((UINT32)(laneAsBytes[7]) << 24);
-        UINT32 even, odd, temp, temp0, temp1;
-        UINT32 *stateAsHalfLanes = (UINT32*)state;
+        stateAsHalfLanes = (UINT32*)state;
         toBitInterleavingAndSet(low, high, stateAsHalfLanes[lanePosition*2+0], stateAsHalfLanes[lanePosition*2+1], temp, temp0, temp1);
     }
 #endif
@@ -406,8 +408,8 @@
     for(lanePosition=0; lanePosition<laneCount; lanePosition++) {
         UINT32 *stateAsHalfLanes = (UINT32*)state;
         UINT32 low, high, temp, temp0, temp1;
+        UINT8 laneAsBytes[8];
         fromBitInterleaving(stateAsHalfLanes[lanePosition*2], stateAsHalfLanes[lanePosition*2+1], low, high, temp, temp0, temp1);
-        UINT8 laneAsBytes[8];
         laneAsBytes[0] = low & 0xFF;
         laneAsBytes[1] = (low >> 8) & 0xFF;
         laneAsBytes[2] = (low >> 16) & 0xFF;

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list