Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 784fde7

Browse files
committed
Force 32bit Keccak implementation on SPARC. It look like the Solaris CC compiler doesn't like the address alignment.
1 parent ba3e4a0 commit 784fde7

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

Modules/_sha3/sha3module.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,21 +95,27 @@
9595
*
9696
* *************************************************************************/
9797

98-
#if SIZEOF_VOID_P == 8 && defined(PY_UINT64_T)
99-
/* 64bit platforms with unsigned int64 */
100-
#define KeccakImplementation 64
98+
#ifdef __sparc
99+
/* On SPARC with Solaris CC opt64 fails with 'invalid address alignment' */
100+
#define KeccakOpt 32
101+
#elif SIZEOF_VOID_P == 8
102+
#define KeccakOpt 64
103+
#elif SIZEOF_VOID_P == 4
104+
#define KeccakOpt 32
105+
#endif
106+
107+
#if KeccakOpt == 64 && defined(PY_UINT64_T)
108+
/* 64bit platforms with unsigned int64 */
101109
#define Unrolling 24
102110
#define UseBebigokimisa
103111
typedef PY_UINT64_T UINT64;
104-
#elif SIZEOF_VOID_P == 4 && defined(PY_UINT64_T)
112+
#elif KeccakOpt == 32 && defined(PY_UINT64_T)
105113
/* 32bit platforms with unsigned int64 */
106-
#define KeccakImplementation 32
107114
#define Unrolling 2
108115
#define UseSchedule 3
109116
typedef PY_UINT64_T UINT64;
110117
#else
111118
/* 32 or 64bit platforms without unsigned int64 */
112-
#define KeccakImplementation 32
113119
#define Unrolling 2
114120
#define UseSchedule 3
115121
#define UseInterleaveTables
@@ -125,9 +131,9 @@
125131
#include "keccak/KeccakNISTInterface.h"
126132
#include "keccak/KeccakNISTInterface.c"
127133
#include "keccak/KeccakSponge.c"
128-
#if KeccakImplementation == 64
134+
#if KeccakOpt == 64
129135
#include "keccak/KeccakF-1600-opt64.c"
130-
#elif KeccakImplementation == 32
136+
#elif KeccakOpt == 32
131137
#include "keccak/KeccakF-1600-opt32.c"
132138
#endif
133139

0 commit comments

Comments
 (0)