Commit 79767740 authored by Rui Salvaterra's avatar Rui Salvaterra Committed by Jiri Slaby

lib: lz4: fixed zram with lz4 on big endian machines

commit 3e26a691 upstream.

Based on Sergey's test patch [1], this fixes zram with lz4 compression
on big endian cpus.

Note that the 64-bit preprocessor test is not a cleanup, it's part of
the fix, since those identifiers are bogus (for example, __ppc64__
isn't defined anywhere else in the kernel, which means we'd fall into
the 32-bit definitions on ppc64).

Tested on ppc64 with no regression on x86_64.

[1] http://marc.info/?l=linux-kernel&m=145994470805853&w=4Suggested-by: default avatarSergey Senozhatsky <sergey.senozhatsky@gmail.com>
Signed-off-by: default avatarRui Salvaterra <rsalvaterra@gmail.com>
Reviewed-by: default avatarSergey Senozhatsky <sergey.senozhatsky@gmail.com>
Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
parent bc1fdc24
...@@ -11,8 +11,7 @@ ...@@ -11,8 +11,7 @@
/* /*
* Detects 64 bits mode * Detects 64 bits mode
*/ */
#if (defined(__x86_64__) || defined(__x86_64) || defined(__amd64__) \ #if defined(CONFIG_64BIT)
|| defined(__ppc64__) || defined(__LP64__))
#define LZ4_ARCH64 1 #define LZ4_ARCH64 1
#else #else
#define LZ4_ARCH64 0 #define LZ4_ARCH64 0
...@@ -35,6 +34,10 @@ typedef struct _U64_S { u64 v; } U64_S; ...@@ -35,6 +34,10 @@ typedef struct _U64_S { u64 v; } U64_S;
#define PUT4(s, d) (A32(d) = A32(s)) #define PUT4(s, d) (A32(d) = A32(s))
#define PUT8(s, d) (A64(d) = A64(s)) #define PUT8(s, d) (A64(d) = A64(s))
#define LZ4_READ_LITTLEENDIAN_16(d, s, p) \
(d = s - A16(p))
#define LZ4_WRITE_LITTLEENDIAN_16(p, v) \ #define LZ4_WRITE_LITTLEENDIAN_16(p, v) \
do { \ do { \
A16(p) = v; \ A16(p) = v; \
...@@ -51,9 +54,12 @@ typedef struct _U64_S { u64 v; } U64_S; ...@@ -51,9 +54,12 @@ typedef struct _U64_S { u64 v; } U64_S;
#define PUT8(s, d) \ #define PUT8(s, d) \
put_unaligned(get_unaligned((const u64 *) s), (u64 *) d) put_unaligned(get_unaligned((const u64 *) s), (u64 *) d)
#define LZ4_READ_LITTLEENDIAN_16(d, s, p) \
(d = s - get_unaligned_le16(p))
#define LZ4_WRITE_LITTLEENDIAN_16(p, v) \ #define LZ4_WRITE_LITTLEENDIAN_16(p, v) \
do { \ do { \
put_unaligned(v, (u16 *)(p)); \ put_unaligned_le16(v, (u16 *)(p)); \
p += 2; \ p += 2; \
} while (0) } while (0)
#endif #endif
...@@ -140,9 +146,6 @@ typedef struct _U64_S { u64 v; } U64_S; ...@@ -140,9 +146,6 @@ typedef struct _U64_S { u64 v; } U64_S;
#endif #endif
#define LZ4_READ_LITTLEENDIAN_16(d, s, p) \
(d = s - get_unaligned_le16(p))
#define LZ4_WILDCOPY(s, d, e) \ #define LZ4_WILDCOPY(s, d, e) \
do { \ do { \
LZ4_COPYPACKET(s, d); \ LZ4_COPYPACKET(s, d); \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment