Added : lz4demo : software swap32 backend for compilers which do not support hardware ones. Thanks Dmitry Cherepanov for contribution
git-svn-id: https://lz4.googlecode.com/svn/trunk@60 650e7d94-2a16-8b24-b05c-7c0b3f6821cd
This commit is contained in:
parent
ad59ba1cfa
commit
fd281f8e5d
2
Makefile
2
Makefile
@ -14,7 +14,7 @@ lz4demo64: lz4.c lz4.h bench.c lz4demo.c
|
||||
gcc -O3 -I. -std=c99 -Wall -W -Wundef -Wno-implicit-function-declaration lz4.c bench.c lz4demo.c -o $(OUTPUT64)
|
||||
|
||||
lz4demo32: lz4.c lz4.h bench.c lz4demo.c
|
||||
gcc -m32 -O3 -I. -std=c99 -Wall -W -Wundef -Wno-implicit-function-declaration lz4.c bench.c lz4demo.c -o $(OUTPUT32)
|
||||
gcc -m32 -Os -march=native -I. -std=c99 -Wall -W -Wundef -Wno-implicit-function-declaration lz4.c bench.c lz4demo.c -o $(OUTPUT32)
|
||||
|
||||
clean:
|
||||
rm -f core *.o $(OUTPUT32) $(OUTPUT64)
|
||||
|
4
lz4.c
4
lz4.c
@ -215,10 +215,10 @@ typedef struct _U64_S { U64 v; } U64_S;
|
||||
|
||||
#if (defined(LZ4_BIG_ENDIAN) && !defined(BIG_ENDIAN_NATIVE_BUT_INCOMPATIBLE))
|
||||
#define LZ4_READ_LITTLEENDIAN_16(d,s,p) { U16 v = A16(p); v = bswap16(v); d = (s) - v; }
|
||||
#define LZ4_WRITE_LITTLEENDIAN_16(p,i) { U16 v = (U16)(i); v = bswap16(v); A16(p) = v; p+=2; }
|
||||
#define LZ4_WRITE_LITTLEENDIAN_16(p,i) { U16 v = (U16)(i); v = bswap16(v); A16(p) = v; p+=2; }
|
||||
#else // Little Endian
|
||||
#define LZ4_READ_LITTLEENDIAN_16(d,s,p) { d = (s) - A16(p); }
|
||||
#define LZ4_WRITE_LITTLEENDIAN_16(p,v) { A16(p) = v; p+=2; }
|
||||
#define LZ4_WRITE_LITTLEENDIAN_16(p,v) { A16(p) = v; p+=2; }
|
||||
#endif
|
||||
|
||||
|
||||
|
11
lz4demo.c
11
lz4demo.c
@ -45,10 +45,19 @@
|
||||
//**************************************
|
||||
// Compiler functions
|
||||
//**************************************
|
||||
#define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
|
||||
|
||||
#if defined(_MSC_VER) // Visual Studio
|
||||
#define swap32 _byteswap_ulong
|
||||
#else // GCC assumed
|
||||
#elif GCC_VERSION >= 402
|
||||
#define swap32 __builtin_bswap32
|
||||
#else
|
||||
static inline unsigned int swap32(unsigned int x) {
|
||||
return ((x << 24) & 0xff000000 ) |
|
||||
((x << 8) & 0x00ff0000 ) |
|
||||
((x >> 8) & 0x0000ff00 ) |
|
||||
((x >> 24) & 0x000000ff );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user