Blame cjdns.ppc64.patch

4ed812
diff -up ./crypto/random/Random.c.ppc64 ./crypto/random/Random.c
4ed812
--- ./crypto/random/Random.c.ppc64	2016-12-05 00:06:42.586930523 -0500
4ed812
+++ ./crypto/random/Random.c	2016-12-05 00:07:36.524592652 -0500
4ed812
@@ -20,6 +20,7 @@
4ed812
 #include "util/Assert.h"
4ed812
 #include "util/Base32.h"
4ed812
 #include "util/Identity.h"
4ed812
+#include "util/Endian.h"
4ed812
 
4ed812
 #include <crypto_hash_sha256.h>
4ed812
 #include <crypto_stream_salsa20.h>
4ed812
@@ -163,10 +164,11 @@ void Random_addRandom(struct Random* ran
4ed812
 
4ed812
 static void stir(struct Random* rand)
4ed812
 {
4ed812
+    uint64_t nonce = Endian_hostToLittleEndian64(rand->nonce);
4ed812
     crypto_stream_salsa20_xor((uint8_t*)rand->buff,
4ed812
                               (uint8_t*)rand->buff,
4ed812
                               BUFFSIZE,
4ed812
-                              (uint8_t*)&rand->nonce,
4ed812
+                              (uint8_t*)&nonce,
4ed812
                               (uint8_t*)rand->tempSeed);
4ed812
     rand->nonce++;
4ed812
     rand->nextByte = 0;
21a248
diff -up ./util/ArchInfo.c.ppc64 ./util/ArchInfo.c
21a248
--- ./util/ArchInfo.c.ppc64	2016-10-11 17:39:44.000000000 -0400
4ed812
+++ ./util/ArchInfo.c	2016-12-05 00:05:56.482360588 -0500
21a248
@@ -98,8 +98,15 @@ gcc arch.c
21a248
         #error unknown endian
21a248
     #endif
21a248
 #elif defined(__powerpc64__) || defined(__ppc64__) || defined(__PPC64__) || defined(_ARCH_PPC64)
21a248
-    #define ARCH ArchInfo_AUDIT_ARCH_PPC64
21a248
-    #define ARCHSTR "ppc64"
21a248
+    #if defined(Endian_BIG)
21a248
+        #define ARCH ArchInfo_AUDIT_ARCH_PPC64
21a248
+        #define ARCHSTR "ppc64"
21a248
+    #elif defined(Endian_LITTLE)
21a248
+        #define ARCH ArchInfo_AUDIT_ARCH_PPC64LE
21a248
+        #define ARCHSTR "ppc64le"
21a248
+    #else
21a248
+        #error unknown endian
21a248
+    #endif
21a248
 #elif defined(__powerpc__) || defined(__ppc__) || defined(__PPC__) || defined(_ARCH_PPC)
21a248
     #define ARCH ArchInfo_AUDIT_ARCH_PPC
21a248
     #define ARCHSTR "ppc"
21a248
@@ -145,6 +152,9 @@ gcc arch.c
21a248
     #else
21a248
         #error unknown bit width
21a248
     #endif
21a248
+#elif defined(__s390x__)
21a248
+    #define ARCH ArchInfo_AUDIT_ARCH_S390X
21a248
+    #define ARCHSTR "s390x"
21a248
 #else
21a248
     #error architecture unknown
21a248
 #endif
bd1824
diff -up ./util/test/Endian_test.c.ppc64 ./util/test/Endian_test.c
bd1824
--- ./util/test/Endian_test.c.ppc64	2016-12-05 10:48:46.767433986 -0500
bd1824
+++ ./util/test/Endian_test.c	2016-12-05 10:50:23.116623515 -0500
bd1824
@@ -40,32 +40,32 @@ int main()
bd1824
         Assert_true(c == Endian_bigEndianToHost16(sc));
bd1824
         Assert_true(c == Endian_hostToBigEndian16(sc));
bd1824
         Assert_true(c == Endian_hostToLittleEndian16(c));
bd1824
-        Assert_true(c == Endian_hostToLittleEndian16(c));
bd1824
+        Assert_true(c == Endian_littleEndianToHost16(c));
bd1824
 
bd1824
         Assert_true(a == Endian_bigEndianToHost32(sa));
bd1824
         Assert_true(a == Endian_hostToBigEndian32(sa));
bd1824
         Assert_true(a == Endian_hostToLittleEndian32(a));
bd1824
-        Assert_true(a == Endian_hostToLittleEndian32(a));
bd1824
+        Assert_true(a == Endian_littleEndianToHost32(a));
bd1824
 
bd1824
         Assert_true(b == Endian_bigEndianToHost64(sb));
bd1824
         Assert_true(b == Endian_hostToBigEndian64(sb));
bd1824
         Assert_true(b == Endian_hostToLittleEndian64(b));
bd1824
-        Assert_true(b == Endian_hostToLittleEndian64(b));
bd1824
+        Assert_true(b == Endian_littleEndianToHost64(b));
bd1824
     } else {
bd1824
         Assert_true(c == Endian_bigEndianToHost16(c));
bd1824
         Assert_true(c == Endian_hostToBigEndian16(c));
bd1824
         Assert_true(c == Endian_hostToLittleEndian16(sc));
bd1824
-        Assert_true(c == Endian_hostToLittleEndian16(sc));
bd1824
+        Assert_true(c == Endian_littleEndianToHost16(sc));
bd1824
 
bd1824
         Assert_true(a == Endian_bigEndianToHost32(a));
bd1824
         Assert_true(a == Endian_hostToBigEndian32(a));
bd1824
         Assert_true(a == Endian_hostToLittleEndian32(sa));
bd1824
-        Assert_true(a == Endian_hostToLittleEndian32(sa));
bd1824
+        Assert_true(a == Endian_littleEndianToHost32(sa));
bd1824
 
bd1824
         Assert_true(b == Endian_bigEndianToHost64(b));
bd1824
         Assert_true(b == Endian_hostToBigEndian64(b));
bd1824
         Assert_true(b == Endian_hostToLittleEndian64(sb));
bd1824
-        Assert_true(b == Endian_hostToLittleEndian64(sb));
bd1824
+        Assert_true(b == Endian_littleEndianToHost64(sb));
bd1824
     }
bd1824
 
bd1824
     Assert_true(b == Endian_byteSwap64(sb));
bd1824