1 /* SPDX-License-Identifier: 0BSD */ 1 2 3 /* 4 * Private includes and definitions 5 * 6 * Author: Lasse Collin <lasse.collin@tukaani. 7 */ 8 9 #ifndef XZ_PRIVATE_H 10 #define XZ_PRIVATE_H 11 12 #ifdef __KERNEL__ 13 # include <linux/xz.h> 14 # include <linux/kernel.h> 15 # include <linux/unaligned.h> 16 /* XZ_PREBOOT may be defined only via 17 # ifndef XZ_PREBOOT 18 # include <linux/slab.h> 19 # include <linux/vmalloc.h> 20 # include <linux/string.h> 21 # ifdef CONFIG_XZ_DEC_X86 22 # define XZ_DEC_X86 23 # endif 24 # ifdef CONFIG_XZ_DEC_POWERPC 25 # define XZ_DEC_POWERPC 26 # endif 27 # ifdef CONFIG_XZ_DEC_IA64 28 # define XZ_DEC_IA64 29 # endif 30 # ifdef CONFIG_XZ_DEC_ARM 31 # define XZ_DEC_ARM 32 # endif 33 # ifdef CONFIG_XZ_DEC_ARMTHUMB 34 # define XZ_DEC_ARMTHUMB 35 # endif 36 # ifdef CONFIG_XZ_DEC_SPARC 37 # define XZ_DEC_SPARC 38 # endif 39 # ifdef CONFIG_XZ_DEC_ARM64 40 # define XZ_DEC_ARM64 41 # endif 42 # ifdef CONFIG_XZ_DEC_RISCV 43 # define XZ_DEC_RISCV 44 # endif 45 # ifdef CONFIG_XZ_DEC_MICROLZMA 46 # define XZ_DEC_MICROLZM 47 # endif 48 # define memeq(a, b, size) (memc 49 # define memzero(buf, size) mems 50 # endif 51 # define get_le32(p) le32_to_cpup((const 52 #else 53 /* 54 * For userspace builds, use a separat 55 * macros and functions. This makes it 56 * different environments and avoids c 57 */ 58 # include "xz_config.h" 59 #endif 60 61 /* If no specific decoding mode is requested, 62 #if !defined(XZ_DEC_SINGLE) && !defined(XZ_DEC 63 && !defined(XZ_DEC_DYNALLOC) 64 # define XZ_DEC_SINGLE 65 # define XZ_DEC_PREALLOC 66 # define XZ_DEC_DYNALLOC 67 #endif 68 69 /* 70 * The DEC_IS_foo(mode) macros are used in "if 71 * of the supported modes are enabled, these m 72 * false at compile time and thus allow the co 73 */ 74 #ifdef XZ_DEC_SINGLE 75 # define DEC_IS_SINGLE(mode) ((mode) == 76 #else 77 # define DEC_IS_SINGLE(mode) (false) 78 #endif 79 80 #ifdef XZ_DEC_PREALLOC 81 # define DEC_IS_PREALLOC(mode) ((mode) = 82 #else 83 # define DEC_IS_PREALLOC(mode) (false) 84 #endif 85 86 #ifdef XZ_DEC_DYNALLOC 87 # define DEC_IS_DYNALLOC(mode) ((mode) = 88 #else 89 # define DEC_IS_DYNALLOC(mode) (false) 90 #endif 91 92 #if !defined(XZ_DEC_SINGLE) 93 # define DEC_IS_MULTI(mode) (true) 94 #elif defined(XZ_DEC_PREALLOC) || defined(XZ_D 95 # define DEC_IS_MULTI(mode) ((mode) != X 96 #else 97 # define DEC_IS_MULTI(mode) (false) 98 #endif 99 100 /* 101 * If any of the BCJ filter decoders are wante 102 * XZ_DEC_BCJ is used to enable generic suppor 103 */ 104 #ifndef XZ_DEC_BCJ 105 # if defined(XZ_DEC_X86) || defined(XZ_D 106 || defined(XZ_DEC_IA64 107 || defined(XZ_DEC_ARM) 108 || defined(XZ_DEC_SPAR 109 || defined(XZ_DEC_RISC 110 # define XZ_DEC_BCJ 111 # endif 112 #endif 113 114 /* 115 * Allocate memory for LZMA2 decoder. xz_dec_l 116 * before calling xz_dec_lzma2_run(). 117 */ 118 struct xz_dec_lzma2 *xz_dec_lzma2_create(enum 119 120 /* 121 * Decode the LZMA2 properties (one byte) and 122 * XZ_OK on success, XZ_MEMLIMIT_ERROR if the 123 * big enough, and XZ_OPTIONS_ERROR if props i 124 * decoder doesn't support. 125 */ 126 enum xz_ret xz_dec_lzma2_reset(struct xz_dec_l 127 128 /* Decode raw LZMA2 stream from b->in to b->ou 129 enum xz_ret xz_dec_lzma2_run(struct xz_dec_lzm 130 131 /* Free the memory allocated for the LZMA2 dec 132 void xz_dec_lzma2_end(struct xz_dec_lzma2 *s); 133 134 #ifdef XZ_DEC_BCJ 135 /* 136 * Allocate memory for BCJ decoders. xz_dec_bc 137 * calling xz_dec_bcj_run(). 138 */ 139 struct xz_dec_bcj *xz_dec_bcj_create(bool sing 140 141 /* 142 * Decode the Filter ID of a BCJ filter. This 143 * support custom start offsets, so no decodin 144 * is needed. Returns XZ_OK if the given Filte 145 * Otherwise XZ_OPTIONS_ERROR is returned. 146 */ 147 enum xz_ret xz_dec_bcj_reset(struct xz_dec_bcj 148 149 /* 150 * Decode raw BCJ + LZMA2 stream. This must be 151 * a BCJ filter in the chain. If the chain has 152 * must be called directly. 153 */ 154 enum xz_ret xz_dec_bcj_run(struct xz_dec_bcj * 155 struct xz_buf *b); 156 157 /* Free the memory allocated for the BCJ filte 158 #define xz_dec_bcj_end(s) kfree(s) 159 #endif 160 161 #endif 162
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.