Skip to content

Commit

Permalink
Merge pull request #5 from Cyan4973/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Cyan4973 committed Aug 15, 2014
2 parents fa48fc2 + 1cdcb5d commit 3332e5d
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 41 deletions.
10 changes: 10 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Set the default behavior
* text eol=lf

# Explicitly declare source files
*.c text eol=lf
*.h text eol=lf

# Denote files that should not be modified.
*.odt binary

5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ The reference system uses a Core i5-3340M @2.7GHz


This is an official mirror of xxHash project, [hosted on Google Code](http://code.google.com/p/xxhash/).
The intention is to offer github's capabilities to xxHash users, such as cloning, branch, or source download.

The "master" branch will reflect, the status of xxHash at its official homepage. Other branches will also exist, typically to fix some open issues or new requirements, and be available for testing before merge into master.
The intention is to offer github's capabilities to xxhash users, such as cloning, branch, pull requests or source download.

The "master" branch will reflect, the status of xxhash at its official homepage. The "dev" branch is the one where all contributions will be merged. If you plan to propose a patch, please commit into the "dev" branch. Direct commit to "master" are not permitted. Feature branches will also exist, typically to introduce new requirements, and be temporarily available for testing before merge into "dev" branch.
4 changes: 4 additions & 0 deletions bench.c
Original file line number Diff line number Diff line change
Expand Up @@ -472,13 +472,17 @@ static void BMK_sanityCheck(void)
prime *= prime;
}

BMK_testSequence(NULL, 0, 0, 0x02CC5D05);
BMK_testSequence(NULL, 0, PRIME, 0x36B78AE7);
BMK_testSequence(sanityBuffer, 1, 0, 0xB85CBEE5);
BMK_testSequence(sanityBuffer, 1, PRIME, 0xD5845D64);
BMK_testSequence(sanityBuffer, 14, 0, 0xE5AA0AB4);
BMK_testSequence(sanityBuffer, 14, PRIME, 0x4481951D);
BMK_testSequence(sanityBuffer, SANITY_BUFFER_SIZE, 0, 0x1F1AA412);
BMK_testSequence(sanityBuffer, SANITY_BUFFER_SIZE, PRIME, 0x498EC8E2);

BMK_testSequence64(NULL , 0, 0, 0xEF46DB3751D8E999ULL);
BMK_testSequence64(NULL , 0, PRIME, 0xAC75FDA2929B17EFULL);
BMK_testSequence64(sanityBuffer, 1, 0, 0x4FCE394CC88952D8ULL);
BMK_testSequence64(sanityBuffer, 1, PRIME, 0x739840CB819FA723ULL);
BMK_testSequence64(sanityBuffer, 14, 0, 0xCFFA8DB881BC3A3DULL);
Expand Down
44 changes: 9 additions & 35 deletions xxhash.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ FORCE_INLINE U32 XXH32_endian_align(const void* input, unsigned int len, U32 see

h32 += (U32) len;

while (p<=bEnd-4)
while (p+4<=bEnd)
{
h32 += XXH_get32bits(p) * PRIME32_3;
h32 = XXH_rotl32(h32, 17) * PRIME32_4 ;
Expand Down Expand Up @@ -366,17 +366,15 @@ FORCE_INLINE U64 XXH64_endian_align(const void* input, unsigned int len, U64 see

h64 += (U64) len;

while (p<=bEnd-8)
while (p+8<=bEnd)
{
U64 k1 = XXH_get64bits(p);
k1 *= PRIME64_2; k1 = XXH_rotl64(k1,31); k1 *= PRIME64_1; h64 ^= k1;
h64 = XXH_rotl64(h64,27) * PRIME64_1 + PRIME64_4;
p+=8;
}

#if 1

if (p<=bEnd-4)
if (p+4<=bEnd)
{
h64 ^= (U64)(XXH_get32bits(p)) * PRIME64_1;
h64 = XXH_rotl64(h64, 23) * PRIME64_2 + PRIME64_3;
Expand All @@ -390,30 +388,6 @@ FORCE_INLINE U64 XXH64_endian_align(const void* input, unsigned int len, U64 see
p++;
}

#else

if( p<bEnd )
{
// Copy the remaining bytes
U64 k1 = PRIME64_5;
BYTE* _k1 = (BYTE*)&k1;
switch( (size_t)(bEnd-p)) // Yes, I tried multiple ways of doing this memcopy
{
case 7: *_k1++ = *p++;
case 6: *_k1++ = *p++;
case 5: *_k1++ = *p++;
case 4: *_k1++ = *p++;
case 3: *_k1++ = *p++;
case 2: *_k1++ = *p++;
case 1: *_k1++ = *p++;
}

k1 *= PRIME64_5; k1 = XXH_rotl64(k1,31); k1 *= PRIME64_3; h64 ^= k1;
h64 = XXH_rotl64(h64, 11) * PRIME64_1 + PRIME64_4;
}

#endif

h64 ^= h64 >> 33;
h64 *= PRIME64_2;
h64 ^= h64 >> 29;
Expand Down Expand Up @@ -516,14 +490,14 @@ XXH_errorcode XXH64_resetState(void* state_in, unsigned long long seed)
void* XXH32_init (U32 seed)
{
void* state = XXH_malloc (sizeof(struct XXH_state32_t));
XXH32_resetState(state, seed);
if (state != NULL) XXH32_resetState(state, seed);
return state;
}

void* XXH64_init (unsigned long long seed)
{
void* state = XXH_malloc (sizeof(struct XXH_state64_t));
XXH64_resetState(state, seed);
if (state != NULL) XXH64_resetState(state, seed);
return state;
}

Expand Down Expand Up @@ -622,7 +596,7 @@ FORCE_INLINE U32 XXH32_intermediateDigest_endian (void* state_in, XXH_endianess

h32 += (U32) state->total_len;

while (p<=bEnd-4)
while (p+4<=bEnd)
{
h32 += XXH_readLE32((const U32*)p, endian) * PRIME32_3;
h32 = XXH_rotl32(h32, 17) * PRIME32_4;
Expand Down Expand Up @@ -700,7 +674,7 @@ FORCE_INLINE XXH_errorcode XXH64_update_endian (void* state_in, const void* inpu
state->memsize = 0;
}

if (p <= bEnd-32)
if (p+32 <= bEnd)
{
const BYTE* const limit = bEnd - 32;
U64 v1 = state->v1;
Expand Down Expand Up @@ -778,15 +752,15 @@ FORCE_INLINE U64 XXH64_intermediateDigest_endian (void* state_in, XXH_endianess

h64 += (U64) state->total_len;

while (p<=bEnd-8)
while (p+8<=bEnd)
{
U64 k1 = XXH_readLE64((const U64*)p, endian);
k1 *= PRIME64_2; k1 = XXH_rotl64(k1,31); k1 *= PRIME64_1; h64 ^= k1;
h64 = XXH_rotl64(h64,27) * PRIME64_1 + PRIME64_4;
p+=8;
}

if (p<=bEnd-4)
if (p+4<=bEnd)
{
h64 ^= (U64)(XXH_readLE32((const U32*)p, endian)) * PRIME64_1;
h64 = XXH_rotl64(h64, 23) * PRIME64_2 + PRIME64_3;
Expand Down
7 changes: 4 additions & 3 deletions xxhash.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,10 @@ as opposed to an input provided as a single block.
It must be started with :
void* XXHnn_init()
The function returns a pointer which holds the state of calculation.
The function returns a pointer which holds the state of calculation.
If the pointer is NULL, allocation has failed, so no state can be tracked.
This pointer must be provided as "void* state" parameter for XXHnn_update().
The state pointer must be provided as "void* state" parameter for XXHnn_update().
XXHnn_update() can be called as many times as necessary.
The user must provide a valid (allocated) input.
The function returns an error code, with 0 meaning OK, and any other value meaning there is an error.
Expand Down Expand Up @@ -155,7 +156,7 @@ use the structure XXHnn_stateSpace_t, which will ensure that memory space is lar
unsigned int XXH32_intermediateDigest (void* state);
unsigned long long XXH64_intermediateDigest (void* state);
/*
This function does the same as XXHnn_digest(), generating a nn-bit hash,
These functions do the same as XXHnn_digest(), generating a nn-bit hash,
but preserve memory context.
This way, it becomes possible to generate intermediate hashes, and then continue feeding data with XXHnn_update().
To free memory context, use XXHnn_digest(), or free().
Expand Down

0 comments on commit 3332e5d

Please sign in to comment.