1b2441318SGreg Kroah-Hartman// SPDX-License-Identifier: GPL-2.0
25de813b6SRussell King#define _LINUX_STRING_H_
35de813b6SRussell King
45de813b6SRussell King#include <linux/compiler.h>	/* for inline */
55de813b6SRussell King#include <linux/types.h>	/* for size_t */
65de813b6SRussell King#include <linux/stddef.h>	/* for NULL */
75de813b6SRussell King#include <linux/linkage.h>
85de813b6SRussell King#include <asm/string.h>
95f8d561fSRussell King#include "misc.h"
105de813b6SRussell King
115de813b6SRussell King#define STATIC static
12b89ebadcSRussell King#define STATIC_RW_DATA	/* non-static please */
135de813b6SRussell King
145de813b6SRussell King/* Diagnostic functions */
155de813b6SRussell King#ifdef DEBUG
165de813b6SRussell King#  define Assert(cond,msg) {if(!(cond)) error(msg);}
175de813b6SRussell King#  define Trace(x) fprintf x
185de813b6SRussell King#  define Tracev(x) {if (verbose) fprintf x ;}
195de813b6SRussell King#  define Tracevv(x) {if (verbose>1) fprintf x ;}
205de813b6SRussell King#  define Tracec(c,x) {if (verbose && (c)) fprintf x ;}
215de813b6SRussell King#  define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;}
225de813b6SRussell King#else
235de813b6SRussell King#  define Assert(cond,msg)
245de813b6SRussell King#  define Trace(x)
255de813b6SRussell King#  define Tracev(x)
265de813b6SRussell King#  define Tracevv(x)
275de813b6SRussell King#  define Tracec(c,x)
285de813b6SRussell King#  define Tracecv(c,x)
295de813b6SRussell King#endif
305de813b6SRussell King
31ef1c2096SRob Herring/* Not needed, but used in some headers pulled in by decompressors */
32ef1c2096SRob Herringextern char * strstr(const char * s1, const char *s2);
337b96ddd0SArnd Bergmannextern size_t strlen(const char *s);
342c6deb01SMatthew Wilcoxextern int memcmp(const void *cs, const void *ct, size_t count);
35fb092eb6SSebastian Andrzej Siewiorextern char * strchrnul(const char *, int);
36ef1c2096SRob Herring
375de813b6SRussell King#ifdef CONFIG_KERNEL_GZIP
385de813b6SRussell King#include "../../../../lib/decompress_inflate.c"
395de813b6SRussell King#endif
405de813b6SRussell King
415de813b6SRussell King#ifdef CONFIG_KERNEL_LZO
425de813b6SRussell King#include "../../../../lib/decompress_unlzo.c"
435de813b6SRussell King#endif
445de813b6SRussell King
456e8699f7SAlbin Tonnerre#ifdef CONFIG_KERNEL_LZMA
466e8699f7SAlbin Tonnerre#include "../../../../lib/decompress_unlzma.c"
476e8699f7SAlbin Tonnerre#endif
486e8699f7SAlbin Tonnerre
49a7f464f3SImre Kaloz#ifdef CONFIG_KERNEL_XZ
50eaf6cc71SArnd Bergmann/* Prevent KASAN override of string helpers in decompressor */
51eaf6cc71SArnd Bergmann#undef memmove
52a7f464f3SImre Kaloz#define memmove memmove
53eaf6cc71SArnd Bergmann#undef memcpy
54a7f464f3SImre Kaloz#define memcpy memcpy
55a7f464f3SImre Kaloz#include "../../../../lib/decompress_unxz.c"
56a7f464f3SImre Kaloz#endif
57a7f464f3SImre Kaloz
58f9b493acSKyungsik Lee#ifdef CONFIG_KERNEL_LZ4
59f9b493acSKyungsik Lee#include "../../../../lib/decompress_unlz4.c"
60f9b493acSKyungsik Lee#endif
61f9b493acSKyungsik Lee
62ccc1c7c6SNicolas Pitreint do_decompress(u8 *input, int len, u8 *output, void (*error)(char *x))
635de813b6SRussell King{
642d3862d2SYinghai Lu	return __decompress(input, len, NULL, NULL, output, 0, NULL, error);
655de813b6SRussell King}
66