hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/lib/lz4/lz4defs.h
....@@ -75,6 +75,11 @@
7575 #define WILDCOPYLENGTH 8
7676 #define LASTLITERALS 5
7777 #define MFLIMIT (WILDCOPYLENGTH + MINMATCH)
78
+/*
79
+ * ensure it's possible to write 2 x wildcopyLength
80
+ * without overflowing output buffer
81
+ */
82
+#define MATCH_SAFEGUARD_DISTANCE ((2 * WILDCOPYLENGTH) - MINMATCH)
7883
7984 /* Increase this value ==> compression run slower on incompressible data */
8085 #define LZ4_SKIPTRIGGER 6
....@@ -131,6 +136,17 @@
131136 {
132137 return put_unaligned_le16(value, memPtr);
133138 }
139
+
140
+/*
141
+ * LZ4 relies on memcpy with a constant size being inlined. In freestanding
142
+ * environments, the compiler can't assume the implementation of memcpy() is
143
+ * standard compliant, so apply its specialized memcpy() inlining logic. When
144
+ * possible, use __builtin_memcpy() to tell the compiler to analyze memcpy()
145
+ * as-if it were standard compliant, so it can inline it in freestanding
146
+ * environments. This is needed when decompressing the Linux Kernel, for example.
147
+ */
148
+#define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
149
+#define LZ4_memmove(dst, src, size) __builtin_memmove(dst, src, size)
134150
135151 static FORCE_INLINE void LZ4_copy8(void *dst, const void *src)
136152 {
....@@ -222,6 +238,8 @@
222238 typedef enum { noDictIssue = 0, dictSmall } dictIssue_directive;
223239
224240 typedef enum { endOnOutputSize = 0, endOnInputSize = 1 } endCondition_directive;
225
-typedef enum { full = 0, partial = 1 } earlyEnd_directive;
241
+typedef enum { decode_full_block = 0, partial_decode = 1 } earlyEnd_directive;
242
+
243
+#define LZ4_STATIC_ASSERT(c) BUILD_BUG_ON(!(c))
226244
227245 #endif