]> wimlib.net Git - wimlib/blobdiff - include/wimlib/decompress_common.h
Improved error reporting if loading capture configuration file fails
[wimlib] / include / wimlib / decompress_common.h
index 296d0b1db6455d304e1d053c62131c81e49bc35e..148b44ef63d0ee5db26509140d13f95f0dbabf87 100644 (file)
@@ -10,9 +10,7 @@
 #ifndef _WIMLIB_DECOMPRESS_COMMON_H
 #define _WIMLIB_DECOMPRESS_COMMON_H
 
-#include "wimlib/assert.h"
 #include "wimlib/compiler.h"
-#include "wimlib/endianness.h"
 #include "wimlib/types.h"
 #include "wimlib/unaligned.h"
 
@@ -214,8 +212,8 @@ bitstream_align(struct input_bitstream *is)
  * input data is exhausted, the Huffman symbol is decoded as if the missing bits
  * are all zeroes.
  *
- * XXX: This is mostly duplicated in lzms_huffman_decode_symbol() in
- * lzms-decompress.c.  */
+ * XXX: This is mostly duplicated in lzms_decode_huffman_symbol() in
+ * lzms_decompress.c.  */
 static inline u16
 read_huffsym(struct input_bitstream *istream, const u16 decode_table[],
             unsigned table_bits, unsigned max_codeword_len)
@@ -253,6 +251,25 @@ make_huffman_decode_table(u16 decode_table[], unsigned num_syms,
                          unsigned num_bits, const u8 lens[],
                          unsigned max_codeword_len);
 
+static inline void
+copy_word_unaligned(const void *src, void *dst)
+{
+       store_word_unaligned(load_word_unaligned(src), dst);
+}
+
+static inline machine_word_t
+repeat_byte(u8 b)
+{
+       machine_word_t v;
+
+       BUILD_BUG_ON(WORDSIZE != 4 && WORDSIZE != 8);
+
+       v = b;
+       v |= v << 8;
+       v |= v << 16;
+       v |= v << ((WORDSIZE == 8) ? 32 : 0);
+       return v;
+}
 
 /*
  * Copy an LZ77 match at (dst - offset) to dst.