Skip to content

Commit f0ef073

Browse files
hsiangkaoakpm00
authored andcommitted
include/linux/lz4.h: add some missing macros
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/[email protected] Signed-off-by: Gao Xiang <[email protected]> Cc: Yann Collet <[email protected]> Cc: Nick Terrell <[email protected]> Cc: Chao Yu <[email protected]> Cc: Yue Hu <[email protected]> Cc; Jeffle Xu <[email protected]> Cc: Sandeep Dhavale <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 13fd5cf commit f0ef073

File tree

6 files changed

+8
-12
lines changed

6 files changed

+8
-12
lines changed

fs/erofs/decompressor.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,7 @@
77
#include "compress.h"
88
#include <linux/lz4.h>
99

10-
#ifndef LZ4_DISTANCE_MAX /* history window size */
11-
#define LZ4_DISTANCE_MAX 65535 /* set to maximum value by default */
12-
#endif
13-
1410
#define LZ4_MAX_DISTANCE_PAGES (DIV_ROUND_UP(LZ4_DISTANCE_MAX, PAGE_SIZE) + 1)
15-
#ifndef LZ4_DECOMPRESS_INPLACE_MARGIN
16-
#define LZ4_DECOMPRESS_INPLACE_MARGIN(srcsize) (((srcsize) >> 8) + 32)
17-
#endif
1811

1912
struct z_erofs_lz4_decompress_ctx {
2013
struct z_erofs_decompress_req *rq;

include/linux/lz4.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,4 +645,10 @@ int LZ4_decompress_safe_usingDict(const char *source, char *dest,
645645
int LZ4_decompress_fast_usingDict(const char *source, char *dest,
646646
int originalSize, const char *dictStart, int dictSize);
647647

648+
#define LZ4_DECOMPRESS_INPLACE_MARGIN(compressedSize) (((compressedSize) >> 8) + 32)
649+
650+
#ifndef LZ4_DISTANCE_MAX /* history window size; can be user-defined at compile time */
651+
#define LZ4_DISTANCE_MAX 65535 /* set to maximum value by default */
652+
#endif
653+
648654
#endif

lib/lz4/lz4_compress.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
/*-************************************
3434
* Dependencies
3535
**************************************/
36-
#include <linux/lz4.h>
3736
#include "lz4defs.h"
3837
#include <linux/module.h>
3938
#include <linux/kernel.h>

lib/lz4/lz4_decompress.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
/*-************************************
3434
* Dependencies
3535
**************************************/
36-
#include <linux/lz4.h>
3736
#include "lz4defs.h"
3837
#include <linux/init.h>
3938
#include <linux/module.h>

lib/lz4/lz4defs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939

4040
#include <linux/bitops.h>
4141
#include <linux/string.h> /* memset, memcpy */
42+
#include <linux/lz4.h>
4243

4344
#define FORCE_INLINE __always_inline
4445

@@ -92,8 +93,7 @@ typedef uintptr_t uptrval;
9293
#define MB (1 << 20)
9394
#define GB (1U << 30)
9495

95-
#define MAXD_LOG 16
96-
#define MAX_DISTANCE ((1 << MAXD_LOG) - 1)
96+
#define MAX_DISTANCE LZ4_DISTANCE_MAX
9797
#define STEPSIZE sizeof(size_t)
9898

9999
#define ML_BITS 4

lib/lz4/lz4hc_compress.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
/*-************************************
3535
* Dependencies
3636
**************************************/
37-
#include <linux/lz4.h>
3837
#include "lz4defs.h"
3938
#include <linux/module.h>
4039
#include <linux/kernel.h>

0 commit comments

Comments
 (0)