Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/City.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,11 @@ static uint128 CityMurmur(const char *s, size_t len, uint128 seed) {
uint64 b = Uint128High64(seed);
uint64 c = 0;
uint64 d = 0;
#if defined(__PPC64__) && defined (__LITTLE_ENDIAN__)
signed int l = len - 16;
#else
signed long l = len - 16;
#endif /* PPC64 && LITTLE_ENDIAN */
if (l <= 0) { // len <= 16
a = ShiftMix(a * k1) * k1;
c = b * k1 + HashLen0to16(s, len);
Expand Down
4 changes: 4 additions & 0 deletions src/PMurHash.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,11 @@ void PMurHash32_Process(uint32_t *ph1, uint32_t *pcarry, const void *key, int le
/* This CPU does not handle unaligned word access */

/* Consume enough so that the next data byte is word aligned */
#if defined(__PPC64__) && defined (__LITTLE_ENDIAN__)
int i = -(int)ptr & 3;
#else
int i = -(long)ptr & 3;
#endif /* PPC64 && LITTLE_ENDIAN */
if(i && i <= len) {
DOBYTES(i, h1, c, n, ptr, len);
}
Expand Down
5 changes: 5 additions & 0 deletions src/Platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ __inline__ unsigned long long int rdtsc()
unsigned long long int x;
__asm__ volatile ("rdtsc" : "=A" (x));
return x;
#elif defined(__PPC64__) && defined(__LITTLE_ENDIAN__) && \
( __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))
unsigned long long int val;
val = __builtin_ppc_get_timebase();
return val;
#else
#define NO_CYCLE_COUNTER
return 0;
Expand Down
4 changes: 4 additions & 0 deletions src/Stats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ void plot ( double n )
printf(".");
else
{
#if defined(__PPC64__) && defined (__LITTLE_ENDIAN__)
signed char x = '0' + (signed char)n3;
#else
char x = '0' + char(n3);
#endif /* PPC64 && LITTLE_ENDIAN */

if(x > '9') x = 'X';

Expand Down
9 changes: 9 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,17 @@ HashInfo g_hashes[] =

// MurmurHash2

#if defined(__PPC64__) && defined (__LITTLE_ENDIAN__)
{ MurmurHash2_test, 32, 0x27864C1E, "Murmur2", "MurmurHash2 for ppc64le, 32-bit" },
{ MurmurHash2A_test, 32, 0x7FBD4396, "Murmur2A", "MurmurHash2A for ppc64le, 32-bit" },
{ MurmurHash64A_test, 64, 0x1F0D3804, "Murmur2B", "MurmurHash2 for ppc64le, 64-bit" },
{ MurmurHash64B_test, 64, 0xDD537C05, "Murmur2C", "MurmurHash2 for ppc64le, 64-bit" },
#else
{ MurmurHash2_test, 32, 0x27864C1E, "Murmur2", "MurmurHash2 for x86, 32-bit" },
{ MurmurHash2A_test, 32, 0x7FBD4396, "Murmur2A", "MurmurHash2A for x86, 32-bit" },
{ MurmurHash64A_test, 64, 0x1F0D3804, "Murmur2B", "MurmurHash2 for x64, 64-bit" },
{ MurmurHash64B_test, 64, 0xDD537C05, "Murmur2C", "MurmurHash2 for x86, 64-bit" },
#endif /* PPC64 && LITTLE_ENDIAN */

// MurmurHash3

Expand Down Expand Up @@ -562,7 +569,9 @@ int main ( int argc, char ** argv )

// Code runs on the 3rd CPU by default

#if !defined (__PPC64__) && !defined (__LITTLE_ENDIAN__)
SetAffinity((1 << 2));
#endif /* PPC64 && LITTLE_ENDIAN */

SelfTest();

Expand Down
24 changes: 23 additions & 1 deletion src/md5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@
*/
typedef struct
{
#if defined(__PPC64__) && defined (__LITTLE_ENDIAN__)
unsigned int total[2]; /*!< number of bytes processed */
unsigned int state[4]; /*!< intermediate digest state */
#else
unsigned long total[2]; /*!< number of bytes processed */
unsigned long state[4]; /*!< intermediate digest state */
#endif /* PPC64 && LITTLE_ENDIAN */
unsigned char buffer[64]; /*!< data block being processed */

unsigned char ipad[64]; /*!< HMAC: inner padding */
Expand Down Expand Up @@ -146,7 +151,11 @@ void md5_starts( md5_context *ctx )

static void md5_process( md5_context *ctx, unsigned char data[64] )
{
#if defined(__PPC64__) && defined (__LITTLE_ENDIAN__)
unsigned int X[16], A, B, C, D;
#else
unsigned long X[16], A, B, C, D;
#endif /* PPC64 && LITTLE_ENDIAN */

GET_ULONG_LE( X[ 0], data, 0 );
GET_ULONG_LE( X[ 1], data, 4 );
Expand Down Expand Up @@ -273,7 +282,11 @@ static void md5_process( md5_context *ctx, unsigned char data[64] )
void md5_update( md5_context *ctx, unsigned char *input, int ilen )
{
int fill;
#if defined(__PPC64__) && defined (__LITTLE_ENDIAN__)
unsigned int left;
#else
unsigned long left;
#endif /* PPC64 && LITTLE_ENDIAN */

if( ilen <= 0 )
return;
Expand All @@ -284,7 +297,11 @@ void md5_update( md5_context *ctx, unsigned char *input, int ilen )
ctx->total[0] += ilen;
ctx->total[0] &= 0xFFFFFFFF;

#if defined(__PPC64__) && defined (__LITTLE_ENDIAN__)
if( ctx->total[0] < (unsigned int) ilen )
#else
if( ctx->total[0] < (unsigned long) ilen )
#endif /* PPC64 && LITTLE_ENDIAN */
ctx->total[1]++;

if( left && ilen >= fill )
Expand Down Expand Up @@ -324,8 +341,13 @@ static const unsigned char md5_padding[64] =
*/
void md5_finish( md5_context *ctx, unsigned char output[16] )
{
#if defined(__PPC64__) && defined (__LITTLE_ENDIAN__)
unsigned int last, padn;
unsigned int high, low;
#else
unsigned long last, padn;
unsigned long high, low;
#endif /* PPC64 && LITTLE_ENDIAN */
unsigned char msglen[8];

high = ( ctx->total[0] >> 29 )
Expand Down Expand Up @@ -379,4 +401,4 @@ void md5_32 ( const void * key, int len, uint32_t /*seed*/, void * ou
md5((unsigned char*)key,len,(unsigned char*)hash);

*(uint32_t*)out = hash[0];
}
}