aboutsummaryrefslogtreecommitdiff
path: root/c/common/platform.h
diff options
context:
space:
mode:
authorStephen Kyle <stephen.kyle@arm.com>2018-09-27 12:15:46 +0100
committerEugene Kliuchnikov <eustas@google.com>2018-09-27 13:15:46 +0200
commit9402ac5c08806f4ba400bc390420c29ddd78ecd1 (patch)
tree40dc55ba7b0e88749e220c342290eb29d0d654f7 /c/common/platform.h
parent67f059eaf5eb6cf9201ffe7776b48229a442d864 (diff)
downloadbrotli-9402ac5c08806f4ba400bc390420c29ddd78ecd1.tar.gz
decode: faster huffman code loading on 32-bit Arm (#703)
* platform: add macro for using the 'aligned' attribute * decode: add accessor macros for HuffmanCode fields Adds a constructor function for building HuffmanCode values so they can be accessed quickly on different architectures. Also adds macros for marking a HuffmanCode table pointer that can be accessed quickly (BROTLI_HC_MARK_TABLE_FOR_FAST_LOAD), adjusting the index into that table (BROTLI_HC_ADJUST_TABLE_INDEX), and getting the .bits or .value fields out of the table at the current index (BROTLI_HC_GET_BITS/VALUE). For example, assuming |table| contains a HuffmanCode pointer: BROTLI_HC_MARK_TABLE_FOR_FAST_LOAD(table); BROTLI_HC_ADJUST_TABLE_INDEX(table, index_into_table); *bits = BROTLI_HC_GET_BITS(table); *value = BROTLI_HC_GET_VALUE(table); BROTLI_HC_ADJUST_TABLE_INDEX(table, offset); *bits2 = BROTLI_HC_GET_BITS(table); *value2 = BROTLI_HC_GET_VALUE(table); All uses of the HuffmanCode have been updated appropriately. * decode: add alternative accessors for HuffmanCode on Arm AArch32
Diffstat (limited to 'c/common/platform.h')
-rwxr-xr-xc/common/platform.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/c/common/platform.h b/c/common/platform.h
index 0d84b19..3945a27 100755
--- a/c/common/platform.h
+++ b/c/common/platform.h
@@ -180,6 +180,12 @@ OR:
#define BROTLI_UNUSED_FUNCTION static BROTLI_INLINE
#endif
+#if BROTLI_GNUC_HAS_ATTRIBUTE(aligned, 2, 7, 0)
+#define BROTLI_ALIGNED(N) __attribute__((aligned(N)))
+#else
+#define BROTLI_ALIGNED(N)
+#endif
+
#if (defined(__ARM_ARCH) && (__ARM_ARCH == 7)) || \
(defined(M_ARM) && (M_ARM == 7))
#define BROTLI_TARGET_ARMV7
@@ -343,7 +349,7 @@ static BROTLI_INLINE void BrotliUnalignedWrite64(void* p, uint64_t v) {
/* If __attribute__(aligned) is available, use that. Otherwise, memcpy. */
#if BROTLI_GNUC_HAS_ATTRIBUTE(aligned, 2, 7, 0)
-typedef __attribute__((aligned(1))) uint64_t brotli_unaligned_uint64_t;
+typedef BROTLI_ALIGNED(1) uint64_t brotli_unaligned_uint64_t;
static BROTLI_INLINE uint64_t BrotliUnalignedRead64(const void* p) {
return (uint64_t) ((brotli_unaligned_uint64_t*) p)[0];