Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Synchronize with Sereal fork of Snappy, fix issues with "exotic" platforms #17

Merged
merged 4 commits into from
Sep 26, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion csnappy_compress.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
22 changes: 20 additions & 2 deletions csnappy_internal_userspace.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ Zeev Tarantov <zeev.tarantov@gmail.com>

File modified for Sereal by
Steffen Mueller <smueller@cpan.org>
Yves Orton <demerphq@gmail.com>

*/

#ifndef CSNAPPY_INTERNAL_USERSPACE_H_
Expand Down Expand Up @@ -187,6 +189,22 @@ Albert Lee
#define int32_t int
#define int16_t short

#define __SNAPPY_STRICT_ALIGN

#elif defined(__s390x__) || defined(__zarch__) || defined(__SYSC_ZARCH__)

#ifndef __BIG_ENDIAN
#define __BIG_ENDIAN 87654321
#endif
#ifndef __LITTLE_ENDIAN
#define __LITTLE_ENDIAN 12345678
#endif
#ifndef __BYTE_ORDER
#define __BYTE_ORDER __BIG_ENDIAN
#endif

#define __SNAPPY_STRICT_ALIGN

#endif

#ifndef bswap_16
Expand Down Expand Up @@ -261,7 +279,7 @@ static INLINE void UNALIGNED_STORE64(void *p, uint64_t v)
ptr->x = v;
}

#elif defined(__hpux) /* strict architectures */
#elif defined(__SNAPPY_STRICT_ALIGN) || defined(__sparc) || defined(__sparc__) /* strict architectures */

/* For these platforms, there really are no unaligned loads/stores.
* Read/write everything as uint8_t. Smart compilers might recognize
Expand Down Expand Up @@ -406,7 +424,7 @@ static INLINE void UNALIGNED_STORE64(void *p, uint64_t v)
* supported (unsupported pragmas are ignored) but which do require
* strict alignment, the below pragma pack trickery will fail.
* Therefore this option is the last and the default, and the platforms
* requiring strict alignment are detected earlier.
* requiring strict alignment are detected earlier. */

#pragma pack(1)
struct una_u16 { uint16_t x; };
Expand Down