From 33cd3cfa1d21d9f3557f01a137bec43322a3ec93 Mon Sep 17 00:00:00 2001 From: Shahid Date: Sat, 2 Feb 2019 00:46:46 +0530 Subject: Update varint.int.h --- upb/pb/varint.int.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'upb') diff --git a/upb/pb/varint.int.h b/upb/pb/varint.int.h index 9c54311..5de1296 100644 --- a/upb/pb/varint.int.h +++ b/upb/pb/varint.int.h @@ -9,6 +9,7 @@ #include #include #include +#include #include "upb/upb.h" #ifdef __cplusplus @@ -130,6 +131,9 @@ UPB_INLINE uint64_t upb_vencode32(uint32_t val) { uint64_t ret = 0; UPB_ASSERT(bytes <= 5); memcpy(&ret, buf, bytes); +#ifdef UPB_BIG_ENDIAN + ret = bswap_64(ret); +#endif UPB_ASSERT(ret <= 0xffffffffffU); return ret; } -- cgit v1.2.3 From e223001916b5ca8d914dcf9fe39fa1d9b4028275 Mon Sep 17 00:00:00 2001 From: Shahid Date: Sat, 2 Feb 2019 00:48:10 +0530 Subject: Update table.c --- upb/table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'upb') diff --git a/upb/table.c b/upb/table.c index 4239c6f..96dccf6 100644 --- a/upb/table.c +++ b/upb/table.c @@ -726,7 +726,7 @@ bool upb_inttable_iter_isequal(const upb_inttable_iter *i1, i1->array_part == i2->array_part; } -#ifdef UPB_UNALIGNED_READS_OK +#if defined(UPB_UNALIGNED_READS_OK) || defined(__s390x__) /* ----------------------------------------------------------------------------- * MurmurHash2, by Austin Appleby (released as public domain). * Reformatted and C99-ified by Joshua Haberman. -- cgit v1.2.3 From 17db3722678f2ea11edbe2aeb34efdbce030c07f Mon Sep 17 00:00:00 2001 From: Shahid Date: Mon, 25 Feb 2019 13:40:12 +0530 Subject: Removing the 'byteswap.h' header which is not portable Incorporating code review changes: https://github.com/google/upb/pull/151#discussion_r257529497 --- upb/pb/varint.int.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'upb') diff --git a/upb/pb/varint.int.h b/upb/pb/varint.int.h index 5de1296..b216a94 100644 --- a/upb/pb/varint.int.h +++ b/upb/pb/varint.int.h @@ -9,7 +9,6 @@ #include #include #include -#include #include "upb/upb.h" #ifdef __cplusplus @@ -25,6 +24,18 @@ extern "C" { * descriptor type (upb_descriptortype_t). */ extern const uint8_t upb_pb_native_wire_types[]; +UPB_INLINE uint64_t byteswap64(uint64_t val) +{ + return ((((val) & 0xff00000000000000ull) >> 56) + | (((val) & 0x00ff000000000000ull) >> 40) + | (((val) & 0x0000ff0000000000ull) >> 24) + | (((val) & 0x000000ff00000000ull) >> 8) + | (((val) & 0x00000000ff000000ull) << 8) + | (((val) & 0x0000000000ff0000ull) << 24) + | (((val) & 0x000000000000ff00ull) << 40) + | (((val) & 0x00000000000000ffull) << 56)); +} + /* Zig-zag encoding/decoding **************************************************/ UPB_INLINE int32_t upb_zzdec_32(uint32_t n) { @@ -132,7 +143,7 @@ UPB_INLINE uint64_t upb_vencode32(uint32_t val) { UPB_ASSERT(bytes <= 5); memcpy(&ret, buf, bytes); #ifdef UPB_BIG_ENDIAN - ret = bswap_64(ret); + ret = byteswap64(ret); #endif UPB_ASSERT(ret <= 0xffffffffffU); return ret; -- cgit v1.2.3