decompress.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // SPDX-License-Identifier: GPL-2.0
  2. #define _LINUX_STRING_H_
  3. #include <linux/compiler.h> /* for inline */
  4. #include <linux/types.h> /* for size_t */
  5. #include <linux/stddef.h> /* for NULL */
  6. #include <linux/linkage.h>
  7. #include <asm/string.h>
  8. #include "misc.h"
  9. #define STATIC static
  10. #define STATIC_RW_DATA /* non-static please */
  11. /* Diagnostic functions */
  12. #ifdef DEBUG
  13. # define Assert(cond,msg) {if(!(cond)) error(msg);}
  14. # define Trace(x) fprintf x
  15. # define Tracev(x) {if (verbose) fprintf x ;}
  16. # define Tracevv(x) {if (verbose>1) fprintf x ;}
  17. # define Tracec(c,x) {if (verbose && (c)) fprintf x ;}
  18. # define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;}
  19. #else
  20. # define Assert(cond,msg)
  21. # define Trace(x)
  22. # define Tracev(x)
  23. # define Tracevv(x)
  24. # define Tracec(c,x)
  25. # define Tracecv(c,x)
  26. #endif
  27. /* Not needed, but used in some headers pulled in by decompressors */
  28. extern char * strstr(const char * s1, const char *s2);
  29. extern size_t strlen(const char *s);
  30. extern int strcmp(const char *cs, const char *ct);
  31. extern int memcmp(const void *cs, const void *ct, size_t count);
  32. extern char * strchrnul(const char *, int);
  33. #ifdef CONFIG_KERNEL_GZIP
  34. #include "../../../../lib/decompress_inflate.c"
  35. #endif
  36. #ifdef CONFIG_KERNEL_LZO
  37. #include "../../../../lib/decompress_unlzo.c"
  38. #endif
  39. #ifdef CONFIG_KERNEL_LZMA
  40. #include "../../../../lib/decompress_unlzma.c"
  41. #endif
  42. #ifdef CONFIG_KERNEL_XZ
  43. /* Prevent KASAN override of string helpers in decompressor */
  44. #undef memmove
  45. #define memmove memmove
  46. #undef memcpy
  47. #define memcpy memcpy
  48. #include "../../../../lib/decompress_unxz.c"
  49. #endif
  50. #ifdef CONFIG_KERNEL_LZ4
  51. #include "../../../../lib/decompress_unlz4.c"
  52. #endif
  53. int do_decompress(u8 *input, int len, u8 *output, void (*error)(char *x))
  54. {
  55. return __decompress(input, len, NULL, NULL, output, 0, NULL, error);
  56. }