Merge pull request #405 from kvirund/alignment.issues

Added -xmemalign=4i for Sparc
This commit is contained in:
Jeffrey Walton 2017-04-27 15:52:39 -04:00 committed by GitHub
commit ff9b46e513
4 changed files with 9 additions and 42 deletions

View File

@ -262,9 +262,12 @@ if ((NOT CRYPTOPP_CROSS_COMPILE) AND "${UNAME_SYSTEM}" STREQUAL "SunOS")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -template=no%extdef")
endif()
# Try this if you are encountering unexplained SIGBUS'es on SPARC
# SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -xmemalign=4i")
execute_process(COMMAND "uname" "-p" OUTPUT_VARIABLE PLATFORM_SUNOS_ARCH OUTPUT_STRIP_TRAILING_WHITESPACE)
string(TOUPPER "${PLATFORM_SUNOS_ARCH}" PLATFORM_SUNOS_ARCH)
message(STATUS "SunOS platform arch: ${PLATFORM_SUNOS_ARCH}")
if (${PLATFORM_SUNOS_ARCH} MATCHES SPARC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -xmemalign=4i")
endif ()
endif()
# Link is driven through the compiler, but CXXFLAGS are not used. Also see

16
sha.cpp
View File

@ -40,21 +40,7 @@ typedef void (CRYPTOPP_FASTCALL *pfnSHAHashBlocks)(word32 *state, const word32 *
// start of Steve Reid's code //
////////////////////////////////
template <typename T>
inline T BLK0_TEMPLATE(const T* y, const int i)
{
T t;
memcpy(&t, y+i, sizeof(t));
return t;
}
#if defined(__SUNPRO_CC)
# define blk0(i) (W[i] = BLK0_TEMPLATE(data,i))
#else
# define blk0(i) (W[i] = data[i])
#endif
#define blk0(i) (W[i] = data[i])
#define blk1(i) (W[i&15] = rotlFixed(W[(i+13)&15]^W[(i+8)&15]^W[(i+2)&15]^W[i&15],1))
#define f1(x,y,z) (z^(x&(y^z)))

View File

@ -546,23 +546,9 @@ void VMAC_Base::VHASH_Update_Template(const word64 *data, size_t blocksRemaining
CRYPTOPP_ASSERT(IsAlignedOn(m_polyState(),GetAlignmentOf<word64>()));
CRYPTOPP_ASSERT(IsAlignedOn(m_nhKey(),GetAlignmentOf<word64>()));
#if defined(__SUNPRO_CC)
#define PREPARE_D0_D1(j) \
word64 d0_original = 0;\
memcpy(&d0_original, data + i + 2*j + 0, sizeof(d0_original));\
word64 d1_original = 0;\
memcpy(&d1_original, data + i + 2*j + 1, sizeof(d1_original));\
\
word64 d0 = ConditionalByteReverse(LITTLE_ENDIAN_ORDER, d0_original);\
word64 d1 = ConditionalByteReverse(LITTLE_ENDIAN_ORDER, d1_original)
#else
#define PREPARE_D0_D1(j) \
word64 d0 = ConditionalByteReverse(LITTLE_ENDIAN_ORDER, data[i+2*j+0]);\
word64 d1 = ConditionalByteReverse(LITTLE_ENDIAN_ORDER, data[i+2*j+1])
#endif
#define INNER_LOOP_ITERATION(j) {\
PREPARE_D0_D1(j);\
word64 d0 = ConditionalByteReverse(LITTLE_ENDIAN_ORDER, data[i+2*j+0]);\
word64 d1 = ConditionalByteReverse(LITTLE_ENDIAN_ORDER, data[i+2*j+1]);\
AccumulateNH(nhA, d0+nhK[i+2*j+0], d1+nhK[i+2*j+1]);\
if (T_128BitTag)\
AccumulateNH(nhB, d0+nhK[i+2*j+2], d1+nhK[i+2*j+3]);\

View File

@ -609,15 +609,7 @@ void Whirlpool::Transform(word64 *digest, const word64 *block)
// Compute and apply K^0 to the cipher state
// Also apply part of the Miyaguchi-Preneel compression function
for (int i=0; i<8; i++)
{
#if defined (__SUNPRO_CC)
word64 block_i = 0;
memcpy(&block_i, &block[i], sizeof(block_i));
digest[i] = s[i] = block_i ^ (k[i] = digest[i]);
#else
digest[i] = s[i] = block[i] ^ (k[i] = digest[i]);
#endif
}
#define KSL(op, i, a, b, c, d) \
t = (word32)k[i];\