decompress.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. #ifdef CONFIG_KERNEL_GZIP
  32. #include "../../../../lib/decompress_inflate.c"
  33. #endif
  34. #ifdef CONFIG_KERNEL_LZO
  35. #include "../../../../lib/decompress_unlzo.c"
  36. #endif
  37. #ifdef CONFIG_KERNEL_LZMA
  38. #include "../../../../lib/decompress_unlzma.c"
  39. #endif
  40. #ifdef CONFIG_KERNEL_XZ
  41. #define memmove memmove
  42. #define memcpy memcpy
  43. #include "../../../../lib/decompress_unxz.c"
  44. #endif
  45. #ifdef CONFIG_KERNEL_LZ4
  46. #include "../../../../lib/decompress_unlz4.c"
  47. #endif
  48. int do_decompress(u8 *input, int len, u8 *output, void (*error)(char *x))
  49. {
  50. return __decompress(input, len, NULL, NULL, output, 0, NULL, error);
  51. }