liblzma: CRC CLMUL: Omit is_arch_extension_supported() when not needed
[xz/debian.git] / src / liblzma / common / stream_flags_common.c
blob41b8dcb70d745729303e35f8cfc3b88d71c07aa8
1 // SPDX-License-Identifier: 0BSD
3 ///////////////////////////////////////////////////////////////////////////////
4 //
5 /// \file stream_flags_common.c
6 /// \brief Common stuff for Stream flags coders
7 //
8 // Author: Lasse Collin
9 //
10 ///////////////////////////////////////////////////////////////////////////////
12 #include "stream_flags_common.h"
15 const uint8_t lzma_header_magic[6] = { 0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00 };
16 const uint8_t lzma_footer_magic[2] = { 0x59, 0x5A };
19 extern LZMA_API(lzma_ret)
20 lzma_stream_flags_compare(
21 const lzma_stream_flags *a, const lzma_stream_flags *b)
23 // We can compare only version 0 structures.
24 if (a->version != 0 || b->version != 0)
25 return LZMA_OPTIONS_ERROR;
27 // Check type
28 if ((unsigned int)(a->check) > LZMA_CHECK_ID_MAX
29 || (unsigned int)(b->check) > LZMA_CHECK_ID_MAX)
30 return LZMA_PROG_ERROR;
32 if (a->check != b->check)
33 return LZMA_DATA_ERROR;
35 // Backward Sizes are compared only if they are known in both.
36 if (a->backward_size != LZMA_VLI_UNKNOWN
37 && b->backward_size != LZMA_VLI_UNKNOWN) {
38 if (!is_backward_size_valid(a) || !is_backward_size_valid(b))
39 return LZMA_PROG_ERROR;
41 if (a->backward_size != b->backward_size)
42 return LZMA_DATA_ERROR;
45 return LZMA_OK;