decompress.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 memcmp(const void *cs, const void *ct, size_t count);
  31. extern char * strchrnul(const char *, int);
  32. #ifdef CONFIG_KERNEL_GZIP
  33. #include "../../../../lib/decompress_inflate.c"
  34. #endif
  35. #ifdef CONFIG_KERNEL_LZO
  36. #include "../../../../lib/decompress_unlzo.c"
  37. #endif
  38. #ifdef CONFIG_KERNEL_LZMA
  39. #include "../../../../lib/decompress_unlzma.c"
  40. #endif
  41. #ifdef CONFIG_KERNEL_XZ
  42. /* Prevent KASAN override of string helpers in decompressor */
  43. #undef memmove
  44. #define memmove memmove
  45. #undef memcpy
  46. #define memcpy memcpy
  47. #include "../../../../lib/decompress_unxz.c"
  48. #endif
  49. #ifdef CONFIG_KERNEL_LZ4
  50. #include "../../../../lib/decompress_unlz4.c"
  51. #endif
  52. int do_decompress(u8 *input, int len, u8 *output, void (*error)(char *x))
  53. {
  54. return __decompress(input, len, NULL, NULL, output, 0, NULL, error);
  55. }