Path: blob/master/Utilities/cmliblzma/liblzma/lzma/fastpos_tablegen.c
3156 views
// SPDX-License-Identifier: 0BSD12///////////////////////////////////////////////////////////////////////////////3//4/// \file fastpos_tablegen.c5/// \brief Generates the lzma_fastpos[] lookup table6///7// Authors: Igor Pavlov8// Lasse Collin9//10///////////////////////////////////////////////////////////////////////////////1112#include <inttypes.h>13#include <stdio.h>1415#define lzma_attr_visibility_hidden16#include "fastpos.h"171819int20main(void)21{22uint8_t fastpos[1 << FASTPOS_BITS];2324const uint8_t fast_slots = 2 * FASTPOS_BITS;25uint32_t c = 2;2627fastpos[0] = 0;28fastpos[1] = 1;2930for (uint8_t slot_fast = 2; slot_fast < fast_slots; ++slot_fast) {31const uint32_t k = 1 << ((slot_fast >> 1) - 1);32for (uint32_t j = 0; j < k; ++j, ++c)33fastpos[c] = slot_fast;34}3536// Split the SPDX string so that it won't accidentally match37// when tools search for the string.38printf("// SPDX" "-License-Identifier" ": 0BSD\n\n"39"// This file has been generated by fastpos_tablegen.c.\n\n"40"#include \"common.h\"\n"41"#include \"fastpos.h\"\n\n"42"const uint8_t lzma_fastpos[1 << FASTPOS_BITS] = {");4344for (size_t i = 0; i < (1 << FASTPOS_BITS); ++i) {45if (i % 16 == 0)46printf("\n\t");4748printf("%3u", (unsigned int)(fastpos[i]));4950if (i != (1 << FASTPOS_BITS) - 1)51printf(",");52}5354printf("\n};\n");5556return 0;57}585960