yuezonghe | 824eb0c | 2024-06-27 02:32:26 -0700 | [diff] [blame] | 1 | #ifndef __LZMA_H__ |
| 2 | #define __LZMA_H__ |
| 3 | |
| 4 | #ifdef __KERNEL__ |
| 5 | #include <linux/kernel.h> |
| 6 | #include <linux/sched.h> |
| 7 | #include <linux/slab.h> |
| 8 | #include <linux/vmalloc.h> |
| 9 | #include <linux/init.h> |
| 10 | #define LZMA_MALLOC vmalloc |
| 11 | #define LZMA_FREE vfree |
| 12 | #define PRINT_ERROR(msg) printk(KERN_WARNING #msg) |
| 13 | #define INIT __init |
| 14 | #define STATIC static |
| 15 | #else |
| 16 | #include <stdint.h> |
| 17 | #include <stdlib.h> |
| 18 | #include <stdio.h> |
| 19 | #include <unistd.h> |
| 20 | #include <string.h> |
| 21 | #include <asm/types.h> |
| 22 | #include <errno.h> |
| 23 | #include <linux/jffs2.h> |
| 24 | #ifndef PAGE_SIZE |
| 25 | extern int page_size; |
| 26 | #define PAGE_SIZE page_size |
| 27 | #endif |
| 28 | #define LZMA_MALLOC malloc |
| 29 | #define LZMA_FREE free |
| 30 | #define PRINT_ERROR(msg) fprintf(stderr, msg) |
| 31 | #define INIT |
| 32 | #define STATIC |
| 33 | #endif |
| 34 | |
| 35 | #include "lzma/LzmaDec.h" |
| 36 | #include "lzma/LzmaEnc.h" |
| 37 | |
| 38 | #define LZMA_BEST_LEVEL (9) |
| 39 | #define LZMA_BEST_LC (0) |
| 40 | #define LZMA_BEST_LP (0) |
| 41 | #define LZMA_BEST_PB (0) |
| 42 | #define LZMA_BEST_FB (273) |
| 43 | |
| 44 | #define LZMA_BEST_DICT(n) (((int)((n) / 2)) * 2) |
| 45 | |
| 46 | static void *p_lzma_malloc(void *p, size_t size) |
| 47 | { |
| 48 | if (size == 0) |
| 49 | return NULL; |
| 50 | |
| 51 | return LZMA_MALLOC(size); |
| 52 | } |
| 53 | |
| 54 | static void p_lzma_free(void *p, void *address) |
| 55 | { |
| 56 | if (address != NULL) |
| 57 | LZMA_FREE(address); |
| 58 | } |
| 59 | |
| 60 | static ISzAlloc lzma_alloc = {p_lzma_malloc, p_lzma_free}; |
| 61 | |
| 62 | #endif |