summaryrefslogtreecommitdiffstats
path: root/lz4demo.c
diff options
context:
space:
mode:
authoryann.collet.73@gmail.com <yann.collet.73@gmail.com@650e7d94-2a16-8b24-b05c-7c0b3f6821cd>2012-03-16 19:50:58 (GMT)
committeryann.collet.73@gmail.com <yann.collet.73@gmail.com@650e7d94-2a16-8b24-b05c-7c0b3f6821cd>2012-03-16 19:50:58 (GMT)
commitfd281f8e5d8822b0f2178d63c80315869c42cc58 (patch)
tree51f319119bf0663547ae0b259b56433dc0dd45a8 /lz4demo.c
parentad59ba1cfad62af37c44ded985fe1e2a0dffae05 (diff)
downloadlz4-fd281f8e5d8822b0f2178d63c80315869c42cc58.zip
lz4-fd281f8e5d8822b0f2178d63c80315869c42cc58.tar.gz
lz4-fd281f8e5d8822b0f2178d63c80315869c42cc58.tar.bz2
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
Diffstat (limited to 'lz4demo.c')
-rw-r--r--lz4demo.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/lz4demo.c b/lz4demo.c
index 0d7b020..61bf75c 100644
--- a/lz4demo.c
+++ b/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