summaryrefslogtreecommitdiffstats
path: root/Modules/_sha3
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2012-10-17 21:52:17 (GMT)
committerChristian Heimes <christian@cheimes.de>2012-10-17 21:52:17 (GMT)
commit743e0cd6b5d59767aae2524700857f188ca1e80e (patch)
tree89897c0424a3b361e04d451e2b3a64e5c7c17756 /Modules/_sha3
parent1e9af84e2ef41115dd07d00b57e5a2a7041bfeed (diff)
downloadcpython-743e0cd6b5d59767aae2524700857f188ca1e80e.zip
cpython-743e0cd6b5d59767aae2524700857f188ca1e80e.tar.gz
cpython-743e0cd6b5d59767aae2524700857f188ca1e80e.tar.bz2
Issue #16166: Add PY_LITTLE_ENDIAN and PY_BIG_ENDIAN macros and unified
endianess detection and handling.
Diffstat (limited to 'Modules/_sha3')
-rwxr-xr-xModules/_sha3/cleanup.py8
-rw-r--r--Modules/_sha3/keccak/KeccakF-1600-opt32.c2
-rw-r--r--Modules/_sha3/keccak/KeccakF-1600-opt64.c2
-rw-r--r--Modules/_sha3/sha3module.c13
4 files changed, 14 insertions, 11 deletions
diff --git a/Modules/_sha3/cleanup.py b/Modules/_sha3/cleanup.py
index 5238ab3..aabcb04 100755
--- a/Modules/_sha3/cleanup.py
+++ b/Modules/_sha3/cleanup.py
@@ -32,10 +32,10 @@ def cleanup(f):
if line.startswith("typedef unsigned long long int"):
buf.append("/* %s */\n" % line.strip())
continue
- ## remove #include "brg_endian.h"
- #if "brg_endian.h" in line:
- # buf.append("/* %s */\n" % line.strip())
- # continue
+ # remove #include "brg_endian.h"
+ if "brg_endian.h" in line:
+ buf.append("/* %s */\n" % line.strip())
+ continue
# transform C++ comments into ANSI C comments
line = CPP1.sub(r"/* \1 */", line)
line = CPP2.sub(r" /* \1 */", line)
diff --git a/Modules/_sha3/keccak/KeccakF-1600-opt32.c b/Modules/_sha3/keccak/KeccakF-1600-opt32.c
index 473dde5..dba6d59 100644
--- a/Modules/_sha3/keccak/KeccakF-1600-opt32.c
+++ b/Modules/_sha3/keccak/KeccakF-1600-opt32.c
@@ -12,7 +12,7 @@ http://creativecommons.org/publicdomain/zero/1.0/
*/
#include <string.h>
-#include "brg_endian.h"
+/* #include "brg_endian.h" */
#include "KeccakF-1600-opt32-settings.h"
#include "KeccakF-1600-interface.h"
diff --git a/Modules/_sha3/keccak/KeccakF-1600-opt64.c b/Modules/_sha3/keccak/KeccakF-1600-opt64.c
index 57e2aa4..f19b18b 100644
--- a/Modules/_sha3/keccak/KeccakF-1600-opt64.c
+++ b/Modules/_sha3/keccak/KeccakF-1600-opt64.c
@@ -12,7 +12,7 @@ http://creativecommons.org/publicdomain/zero/1.0/
*/
#include <string.h>
-#include "brg_endian.h"
+/* #include "brg_endian.h" */
#include "KeccakF-1600-opt64-settings.h"
#include "KeccakF-1600-interface.h"
diff --git a/Modules/_sha3/sha3module.c b/Modules/_sha3/sha3module.c
index 08f6839..4c3c6db 100644
--- a/Modules/_sha3/sha3module.c
+++ b/Modules/_sha3/sha3module.c
@@ -124,11 +124,14 @@
#define UseInterleaveTables
#endif
-/* replacement for brg_endian.h
-#define IS_BIG_ENDIAN BIG_ENDIAN
-#define IS_LITTLE_ENDIAN LITTLE_ENDIAN
-#define PLATFORM_BYTE_ORDER BYTE_ORDER
-*/
+/* replacement for brg_endian.h */
+#define IS_BIG_ENDIAN 4321
+#define IS_LITTLE_ENDIAN 1234
+#if PY_BIG_ENDIAN
+# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
+#else
+# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
+#endif
/* inline all Keccak dependencies */
#include "keccak/KeccakNISTInterface.h"