1 ///////////////////////////////////////////////////////////////////////////////
3 /// \file fastpos_tablegen.c
4 /// \brief Generates the lzma_fastpos[] lookup table
6 // Authors: Igor Pavlov
9 // This file has been put into the public domain.
10 // You can do whatever you want with this file.
12 ///////////////////////////////////////////////////////////////////////////////
14 #include <sys/types.h>
23 uint8_t fastpos
[1 << FASTPOS_BITS
];
25 const uint8_t fast_slots
= 2 * FASTPOS_BITS
;
31 for (uint8_t slot_fast
= 2; slot_fast
< fast_slots
; ++slot_fast
) {
32 const uint32_t k
= 1 << ((slot_fast
>> 1) - 1);
33 for (uint32_t j
= 0; j
< k
; ++j
, ++c
)
34 fastpos
[c
] = slot_fast
;
37 printf("/* This file has been automatically generated "
38 "by fastpos_tablegen.c. */\n\n"
39 "#include \"common.h\"\n"
40 "#include \"fastpos.h\"\n\n"
41 "const uint8_t lzma_fastpos[1 << FASTPOS_BITS] = {");
43 for (size_t i
= 0; i
< (1 << FASTPOS_BITS
); ++i
) {
47 printf("%3u", (unsigned int)(fastpos
[i
]));
49 if (i
!= (1 << FASTPOS_BITS
) - 1)