1 /* SPDX-License-Identifier: 0BSD */
4 * Definitions for handling the .xz file format
6 * Author: Lasse Collin <lasse.collin@tukaani.org>
12 #if defined(__KERNEL__) && !XZ_INTERNAL_CRC32
13 # include <linux/crc32.h>
15 # define xz_crc32(buf, size, crc) \
16 (~crc32_le(~(uint32_t)(crc), buf, size))
20 * See the .xz file format specification at
21 * https://tukaani.org/xz/xz-file-format.txt
22 * to understand the container format.
25 #define STREAM_HEADER_SIZE 12
27 #define HEADER_MAGIC "\3757zXZ"
28 #define HEADER_MAGIC_SIZE 6
30 #define FOOTER_MAGIC "YZ"
31 #define FOOTER_MAGIC_SIZE 2
34 * Variable-length integer can hold a 63-bit unsigned integer or a special
35 * value indicating that the value is unknown.
37 * Experimental: vli_type can be defined to uint32_t to save a few bytes
38 * in code size (no effect on speed). Doing so limits the uncompressed and
39 * compressed size of the file to less than 256 MiB and may also weaken
40 * error detection slightly.
42 typedef uint64_t vli_type
;
44 #define VLI_MAX ((vli_type)-1 / 2)
45 #define VLI_UNKNOWN ((vli_type)-1)
47 /* Maximum encoded size of a VLI */
48 #define VLI_BYTES_MAX (sizeof(vli_type) * 8 / 7)
50 /* Integrity Check types */
58 /* Maximum possible Check ID */
59 #define XZ_CHECK_MAX 15