]> wimlib.net Git - wimlib/blobdiff - include/wimlib/decompress_common.h
mount_image.c: add fallback definitions of RENAME_* constants
[wimlib] / include / wimlib / decompress_common.h
index d20085db61736fdb5b0dfddf1f87619215115525..46fce94fda6224716b0411baed52b1371c8ea98d 100644 (file)
@@ -3,21 +3,28 @@
  *
  * Header for decompression code shared by multiple compression formats.
  *
- * The following copying information applies to this specific source code file:
+ * Copyright 2022 Eric Biggers
  *
- * Written in 2012-2016 by Eric Biggers <ebiggers3@gmail.com>
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
  *
- * To the extent possible under law, the author(s) have dedicated all copyright
- * and related and neighboring rights to this software to the public domain
- * worldwide via the Creative Commons Zero 1.0 Universal Public Domain
- * Dedication (the "CC0").
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
  *
- * This software is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the CC0 for more details.
- *
- * You should have received a copy of the CC0 along with this software; if not
- * see <http://creativecommons.org/publicdomain/zero/1.0/>.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
  */
 
 #ifndef _WIMLIB_DECOMPRESS_COMMON_H
@@ -54,7 +61,7 @@ struct input_bitstream {
 };
 
 /* 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;
@@ -73,7 +80,7 @@ init_input_bitstream(struct input_bitstream *is, const void *buffer, u32 size)
 /* 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.  */
@@ -106,7 +113,7 @@ overflow:
 /* 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);
@@ -115,7 +122,7 @@ bitstream_peek_bits(const struct input_bitstream *is, const unsigned num_bits)
 /* 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;
@@ -125,7 +132,7 @@ bitstream_remove_bits(struct input_bitstream *is, unsigned 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);
@@ -134,7 +141,7 @@ bitstream_pop_bits(struct input_bitstream *is, unsigned 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);
@@ -142,7 +149,7 @@ bitstream_read_bits(struct input_bitstream *is, unsigned 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))
@@ -151,7 +158,7 @@ bitstream_read_byte(struct input_bitstream *is)
 }
 
 /* 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;
@@ -164,7 +171,7 @@ bitstream_read_u16(struct input_bitstream *is)
 }
 
 /* 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;
@@ -178,7 +185,7 @@ bitstream_read_u32(struct input_bitstream *is)
 
 /* 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))
@@ -189,7 +196,7 @@ bitstream_read_bytes(struct input_bitstream *is, void *dst_buffer, size_t 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;
@@ -242,7 +249,7 @@ bitstream_align(struct input_bitstream *is)
  * 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)
 {
@@ -396,7 +403,7 @@ read_huffsym(struct input_bitstream *is, const u16 decode_table[],
 #define DECODE_TABLE(name, num_syms, table_bits, max_codeword_len) \
        u16 name[DECODE_TABLE_SIZE((num_syms), (table_bits), \
                                   (max_codeword_len))] \
-               _aligned_attribute(DECODE_TABLE_ALIGNMENT)
+               __attribute__((aligned(DECODE_TABLE_ALIGNMENT)))
 
 /*
  * Declare the temporary "working_space" array needed for building the decode
@@ -405,7 +412,7 @@ read_huffsym(struct input_bitstream *is, const u16 decode_table[],
 #define DECODE_TABLE_WORKING_SPACE(name, num_syms, max_codeword_len)   \
        u16 name[2 * ((max_codeword_len) + 1)  + (num_syms)];
 
-extern int
+int
 make_huffman_decode_table(u16 decode_table[], unsigned num_syms,
                          unsigned table_bits, const u8 lens[],
                          unsigned max_codeword_len, u16 working_space[]);
@@ -414,13 +421,13 @@ make_huffman_decode_table(u16 decode_table[], unsigned num_syms,
 /*                             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;
@@ -431,7 +438,7 @@ repeat_u16(u16 b)
        return v;
 }
 
-static inline machine_word_t
+static forceinline machine_word_t
 repeat_byte(u8 b)
 {
        return repeat_u16(((u16)b << 8) | b);
@@ -450,7 +457,7 @@ repeat_byte(u8 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)
 {