};
/* Initialize a bitstream to read from the specified input buffer. */
-static inline void
+static forceinline void
init_input_bitstream(struct input_bitstream *is, const void *buffer, u32 size)
{
is->bitbuf = 0;
/* Ensure the bit buffer variable for the bitstream contains at least @num_bits
* bits. Following this, bitstream_peek_bits() and/or bitstream_remove_bits()
* may be called on the bitstream to peek or remove up to @num_bits bits. */
-static inline void
+static forceinline void
bitstream_ensure_bits(struct input_bitstream *is, const unsigned num_bits)
{
/* This currently works for at most 17 bits. */
/* Return the next @num_bits bits from the bitstream, without removing them.
* There must be at least @num_bits remaining in the buffer variable, from a
* previous call to bitstream_ensure_bits(). */
-static inline u32
+static forceinline u32
bitstream_peek_bits(const struct input_bitstream *is, const unsigned num_bits)
{
return (is->bitbuf >> 1) >> (sizeof(is->bitbuf) * 8 - num_bits - 1);
/* Remove @num_bits from the bitstream. There must be at least @num_bits
* remaining in the buffer variable, from a previous call to
* bitstream_ensure_bits(). */
-static inline void
+static forceinline void
bitstream_remove_bits(struct input_bitstream *is, unsigned num_bits)
{
is->bitbuf <<= num_bits;
/* Remove and return @num_bits bits from the bitstream. There must be at least
* @num_bits remaining in the buffer variable, from a previous call to
* bitstream_ensure_bits(). */
-static inline u32
+static forceinline u32
bitstream_pop_bits(struct input_bitstream *is, unsigned num_bits)
{
u32 bits = bitstream_peek_bits(is, num_bits);
}
/* Read and return the next @num_bits bits from the bitstream. */
-static inline u32
+static forceinline u32
bitstream_read_bits(struct input_bitstream *is, unsigned num_bits)
{
bitstream_ensure_bits(is, num_bits);
}
/* Read and return the next literal byte embedded in the bitstream. */
-static inline u8
+static forceinline u8
bitstream_read_byte(struct input_bitstream *is)
{
if (unlikely(is->end == is->next))
}
/* Read and return the next 16-bit integer embedded in the bitstream. */
-static inline u16
+static forceinline u16
bitstream_read_u16(struct input_bitstream *is)
{
u16 v;
}
/* Read and return the next 32-bit integer embedded in the bitstream. */
-static inline u32
+static forceinline u32
bitstream_read_u32(struct input_bitstream *is)
{
u32 v;
/* Read into @dst_buffer an array of literal bytes embedded in the bitstream.
* Return 0 if there were enough bytes remaining in the input, otherwise -1. */
-static inline int
+static forceinline int
bitstream_read_bytes(struct input_bitstream *is, void *dst_buffer, size_t count)
{
if (unlikely(is->end - is->next < count))
}
/* Align the input bitstream on a coding-unit boundary. */
-static inline void
+static forceinline void
bitstream_align(struct input_bitstream *is)
{
is->bitsleft = 0;
* XXX: This is mostly duplicated in lzms_decode_huffman_symbol() in
* lzms_decompress.c; keep them in sync!
*/
-static inline unsigned
+static forceinline unsigned
read_huffsym(struct input_bitstream *is, const u16 decode_table[],
unsigned table_bits, unsigned max_codeword_len)
{
(max_codeword_len))] \
_aligned_attribute(DECODE_TABLE_ALIGNMENT)
+/*
+ * Declare the temporary "working_space" array needed for building the decode
+ * table for a Huffman code.
+ */
+#define DECODE_TABLE_WORKING_SPACE(name, num_syms, max_codeword_len) \
+ u16 name[2 * ((max_codeword_len) + 1) + (num_syms)];
+
extern int
make_huffman_decode_table(u16 decode_table[], unsigned num_syms,
unsigned table_bits, const u8 lens[],
- unsigned max_codeword_len);
+ unsigned max_codeword_len, u16 working_space[]);
/******************************************************************************/
/* LZ match copying */
/*----------------------------------------------------------------------------*/
-static inline void
+static forceinline void
copy_word_unaligned(const void *src, void *dst)
{
store_word_unaligned(load_word_unaligned(src), dst);
}
-static inline machine_word_t
+static forceinline machine_word_t
repeat_u16(u16 b)
{
machine_word_t v = b;
return v;
}
-static inline machine_word_t
+static forceinline machine_word_t
repeat_byte(u8 b)
{
return repeat_u16(((u16)b << 8) | b);
* 'min_length' is a hint which specifies the minimum possible match length.
* This should be a compile-time constant.
*/
-static inline int
+static forceinline int
lz_copy(u32 length, u32 offset, u8 *out_begin, u8 *out_next, u8 *out_end,
u32 min_length)
{