diff options
author | yann.collet.73@gmail.com <yann.collet.73@gmail.com@650e7d94-2a16-8b24-b05c-7c0b3f6821cd> | 2011-12-09 13:59:59 (GMT) |
---|---|---|
committer | yann.collet.73@gmail.com <yann.collet.73@gmail.com@650e7d94-2a16-8b24-b05c-7c0b3f6821cd> | 2011-12-09 13:59:59 (GMT) |
commit | 39630716d78c27714aa1827a92f12c29f2ab66fd (patch) | |
tree | 23aa686414cec97d238f86b478a29ae2b2700ca7 | |
parent | bf12ca9a1e60e513fe5a59f07624357bc2d1d001 (diff) | |
download | lz4-39630716d78c27714aa1827a92f12c29f2ab66fd.zip lz4-39630716d78c27714aa1827a92f12c29f2ab66fd.tar.gz lz4-39630716d78c27714aa1827a92f12c29f2ab66fd.tar.bz2 |
Endianess correction
git-svn-id: https://lz4.googlecode.com/svn/trunk@42 650e7d94-2a16-8b24-b05c-7c0b3f6821cd
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | lz4.c | 12 |
2 files changed, 14 insertions, 2 deletions
@@ -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 @@ -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; }
|