aboutsummaryrefslogtreecommitdiff
path: root/c/common/platform.h
diff options
context:
space:
mode:
Diffstat (limited to 'c/common/platform.h')
-rw-r--r--c/common/platform.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/c/common/platform.h b/c/common/platform.h
index c18ff02..7965fea 100644
--- a/c/common/platform.h
+++ b/c/common/platform.h
@@ -282,6 +282,11 @@ static BROTLI_INLINE uint64_t BrotliUnalignedRead64(const void* p) {
memcpy(&t, p, sizeof t);
return t;
}
+static BROTLI_INLINE size_t BrotliUnalignedReadSizeT(const void* p) {
+ size_t t;
+ memcpy(&t, p, sizeof t);
+ return t;
+}
static BROTLI_INLINE void BrotliUnalignedWrite64(void* p, uint64_t v) {
memcpy(p, &v, sizeof v);
}
@@ -489,6 +494,23 @@ BROTLI_COMMON_API void* BrotliDefaultAllocFunc(void* opaque, size_t size);
/* Default brotli_free_func */
BROTLI_COMMON_API void BrotliDefaultFreeFunc(void* opaque, void* address);
+/* Circular logical rotates. */
+static BROTLI_INLINE uint16_t BrotliRotateRight16(uint16_t const value,
+ size_t count) {
+ count &= 0x0F; /* for fickle pattern recognition */
+ return (value >> count) | (uint16_t)(value << ((0U - count) & 0x0F));
+}
+static BROTLI_INLINE uint32_t BrotliRotateRight32(uint32_t const value,
+ size_t count) {
+ count &= 0x1F; /* for fickle pattern recognition */
+ return (value >> count) | (uint32_t)(value << ((0U - count) & 0x1F));
+}
+static BROTLI_INLINE uint64_t BrotliRotateRight64(uint64_t const value,
+ size_t count) {
+ count &= 0x3F; /* for fickle pattern recognition */
+ return (value >> count) | (uint64_t)(value << ((0U - count) & 0x3F));
+}
+
BROTLI_UNUSED_FUNCTION void BrotliSuppressUnusedFunctions(void) {
BROTLI_UNUSED(&BrotliSuppressUnusedFunctions);
BROTLI_UNUSED(&BrotliUnalignedRead16);
@@ -534,6 +556,13 @@ BROTLI_UNUSED_FUNCTION void BrotliSuppressUnusedFunctions(void) {
# define PREFETCH_L1(ptr) do { (void)(ptr); } while (0) /* disabled */
# define PREFETCH_L2(ptr) do { (void)(ptr); } while (0) /* disabled */
#endif
+
+/* The SIMD matchers are only faster at certain quality levels. */
+#if defined(_M_X64) && defined(BROTLI_TZCNT64)
+#define BROTLI_MAX_SIMD_QUALITY 7
+#elif defined(BROTLI_TZCNT64)
+#define BROTLI_MAX_SIMD_QUALITY 6
+#endif
}
#endif /* BROTLI_COMMON_PLATFORM_H_ */