Endianess correction

git-svn-id: https://lz4.googlecode.com/svn/trunk@42 650e7d94-2a16-8b24-b05c-7c0b3f6821cd
This commit is contained in:
yann.collet.73@gmail.com 2011-12-09 13:59:59 +00:00
parent bf12ca9a1e
commit 39630716d7
2 changed files with 14 additions and 2 deletions

View File

@ -1,10 +1,10 @@
all: lz4demo64 lz4demo32
lz4demo64: lz4.c lz4.h lz4demo.c
gcc -g -O3 -I. -std=c99 -Wall -W lz4.c lz4demo.c -o lz4demo64.exe
gcc -g -O3 -I. -std=c99 -Wall -W -Wno-implicit-function-declaration lz4.c lz4demo.c -o lz4demo64.exe
lz4demo32: lz4.c lz4.h lz4demo.c
gcc -m32 -g -O3 -I. -std=c99 -Wall -W lz4.c lz4demo.c -o lz4demo32.exe
gcc -m32 -g -O3 -I. -std=c99 -Wall -W -Wno-implicit-function-declaration lz4.c lz4demo.c -o lz4demo32.exe
clean:
rm -f core *.o lz4demo32.exe lz4demo64.exe

12
lz4.c
View File

@ -230,9 +230,15 @@ _next_match:
anchor = ip;
while (ip<matchlimit-3)
{
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
int diff = A32(ref) ^ A32(ip);
if (!diff) { ip+=4; ref+=4; continue; }
ip += DeBruijnBytePos[((U32)((diff & -diff) * 0x077CB531U)) >> 27];
#else
if (A32(ref) == A32(ip)) { ip+=4; ref+=4; continue; }
if (A16(ref) == A16(ip)) { ip+=2; ref+=2; }
if (*ref == *ip) ip++;
#endif
goto _endCount;
}
if ((ip<(matchlimit-1)) && (A16(ref) == A16(ip))) { ip+=2; ref+=2; }
@ -371,9 +377,15 @@ _next_match:
anchor = ip;
while (ip<matchlimit-3)
{
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
int diff = A32(ref) ^ A32(ip);
if (!diff) { ip+=4; ref+=4; continue; }
ip += DeBruijnBytePos[((U32)((diff & -diff) * 0x077CB531U)) >> 27];
#else
if (A32(ref) == A32(ip)) { ip+=4; ref+=4; continue; }
if (A16(ref) == A16(ip)) { ip+=2; ref+=2; }
if (*ref == *ip) ip++;
#endif
goto _endCount;
}
if ((ip<(matchlimit-1)) && (A16(ref) == A16(ip))) { ip+=2; ref+=2; }