]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
include/linux/lz4.h: add some missing macros
authorGao Xiang <hsiangkao@linux.alibaba.com>
Tue, 14 Jan 2025 13:04:54 +0000 (21:04 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Sat, 25 Jan 2025 06:47:28 +0000 (22:47 -0800)
Currently, LZ4_DISTANCE_MAX and LZ4_DECOMPRESS_INPLACE_MARGIN are
defined in the erofs subsystem for LZ4 in-place decompression, which is
somewhat unsuitable since they should belong to the LZ4 itself and
may change with future LZ4 codebase updates.

Move them to include/linux/lz4.h to match the upstream LZ4 library [1].
No logic changes.

[1] https://github.com/lz4/lz4/blob/v1.10.0/lib/lz4.h#L670

Link: https://lkml.kernel.org/r/20250114130454.1191150-1-hsiangkao@linux.alibaba.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Cc: Yann Collet <yann.collet.73@gmail.com>
Cc: Nick Terrell <terrelln@fb.com>
Cc: Chao Yu <chao@kernel.org>
Cc: Yue Hu <zbestahu@gmail.com>
Cc; Jeffle Xu <jefflexu@linux.alibaba.com>
Cc: Sandeep Dhavale <dhavale@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
fs/erofs/decompressor.c
include/linux/lz4.h
lib/lz4/lz4_compress.c
lib/lz4/lz4_decompress.c
lib/lz4/lz4defs.h
lib/lz4/lz4hc_compress.c

index eb318c7ddd80ed7a4d5a3dfab9881d13fbe478d7..2b123b070a421e72d53b8db5fecb86c97f808849 100644 (file)
@@ -7,14 +7,7 @@
 #include "compress.h"
 #include <linux/lz4.h>
 
-#ifndef LZ4_DISTANCE_MAX       /* history window size */
-#define LZ4_DISTANCE_MAX 65535 /* set to maximum value by default */
-#endif
-
 #define LZ4_MAX_DISTANCE_PAGES (DIV_ROUND_UP(LZ4_DISTANCE_MAX, PAGE_SIZE) + 1)
-#ifndef LZ4_DECOMPRESS_INPLACE_MARGIN
-#define LZ4_DECOMPRESS_INPLACE_MARGIN(srcsize)  (((srcsize) >> 8) + 32)
-#endif
 
 struct z_erofs_lz4_decompress_ctx {
        struct z_erofs_decompress_req *rq;
index b16e15b9587a110fdce82b2271ef4b9097644357..ad6042a718b5428792b795db7a8d4ad44c24a985 100644 (file)
@@ -645,4 +645,10 @@ int LZ4_decompress_safe_usingDict(const char *source, char *dest,
 int LZ4_decompress_fast_usingDict(const char *source, char *dest,
        int originalSize, const char *dictStart, int dictSize);
 
+#define LZ4_DECOMPRESS_INPLACE_MARGIN(compressedSize)          (((compressedSize) >> 8) + 32)
+
+#ifndef LZ4_DISTANCE_MAX       /* history window size; can be user-defined at compile time */
+#define LZ4_DISTANCE_MAX 65535 /* set to maximum value by default */
+#endif
+
 #endif
index b0bbeeb74b9ec782926998a0c246b036b754d61e..2a397bb2c661d9c2e4a7a67d5f50f06bfd42f1f2 100644 (file)
@@ -33,7 +33,6 @@
 /*-************************************
  *     Dependencies
  **************************************/
-#include <linux/lz4.h>
 #include "lz4defs.h"
 #include <linux/module.h>
 #include <linux/kernel.h>
index 0e31e6da5ce7102bda1b0d1aa431650c37b767e4..3a2cd9acada4a09ef70a344090d48167c46088a1 100644 (file)
@@ -33,7 +33,6 @@
 /*-************************************
  *     Dependencies
  **************************************/
-#include <linux/lz4.h>
 #include "lz4defs.h"
 #include <linux/init.h>
 #include <linux/module.h>
index cb358d6bde5a7fb7ada0c14733de579d48d06cad..17277ec16919f3a554afc7d91ad515c493d745ca 100644 (file)
@@ -39,6 +39,7 @@
 
 #include <linux/bitops.h>
 #include <linux/string.h>       /* memset, memcpy */
+#include <linux/lz4.h>
 
 #define FORCE_INLINE __always_inline
 
@@ -92,8 +93,7 @@ typedef uintptr_t uptrval;
 #define MB (1 << 20)
 #define GB (1U << 30)
 
-#define MAXD_LOG 16
-#define MAX_DISTANCE ((1 << MAXD_LOG) - 1)
+#define MAX_DISTANCE LZ4_DISTANCE_MAX
 #define STEPSIZE sizeof(size_t)
 
 #define ML_BITS        4
index bc45594ad2a80c9227c3c423ec3bbbd7866b17f0..91936dc3d14bca31752a361693380aad8eb3b98a 100644 (file)
@@ -34,7 +34,6 @@
 /*-************************************
  *     Dependencies
  **************************************/
-#include <linux/lz4.h>
 #include "lz4defs.h"
 #include <linux/module.h>
 #include <linux/kernel.h>