tag 742409 patch thanks On Wed, Sep 17, 2014 at 03:57:24PM +0200, demerphq wrote: > On 17 September 2014 07:52, Niko Tyni <nt...@debian.org> wrote:
> > So I suspect it's a general 64-bit big-endian problem. > I was under the impression that Jarkko got Sereal to work on big-endian 64 > bit HPUX. But maybe I am wrong. Jarkko can you speak to that? Finally found it. Can't see how it could have worked on big endian 64 bit HPUX either as csnappy_internal_userspace.h seems to define __LITTLE_ENDIAN there too. But never mind. Patch attached. This passes for me on both x86_64 and s390x. I can test run it on the Debian buildds if you like but it seems straightforward? -- Niko Tyni nt...@debian.org
>From f3466c76541f66213ad04f1a14ee07c343d2d0d5 Mon Sep 17 00:00:00 2001 From: Niko Tyni <nt...@debian.org> Date: Fri, 26 Sep 2014 13:25:36 +0300 Subject: [PATCH] Fix snappy roundtrip failures on big-endian 64-bit architectures Bug: https://github.com/Sereal/Sereal/issues/47 Bug-Debian: https://bugs.debian.org/742409 csnappy_compress_fragment() was returning nonsense because GetUint32AtOffset() would always take the little endian code path. --- snappy/csnappy_compress.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snappy/csnappy_compress.c b/snappy/csnappy_compress.c index abc103b..007bb82 100644 --- a/snappy/csnappy_compress.c +++ b/snappy/csnappy_compress.c @@ -441,7 +441,7 @@ static INLINE EightBytesReference GetEightBytesAt(const char* ptr) { static INLINE uint32_t GetUint32AtOffset(uint64_t v, int offset) { DCHECK_GE(offset, 0); DCHECK_LE(offset, 4); -#ifdef __LITTLE_ENDIAN +#if __BYTE_ORDER == __LITTLE_ENDIAN return v >> (8 * offset); #else return v >> (32 - 8 * offset); -- 2.1.1