* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#pragma once
+#ifndef _BT_MATCHFINDER_H
+#define _BT_MATCHFINDER_H
#include "wimlib/lz_extend.h"
#include "wimlib/lz_hash3.h"
}
}
}
+
+#endif /* _BT_MATCHFINDER_H */
#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"
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.
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#pragma once
+#ifndef _HC_MATCHFINDER_H
+#define _HC_MATCHFINDER_H
#include "wimlib/lz_extend.h"
#include "wimlib/lz_hash3.h"
pos_t mf_data[HC_MATCHFINDER_TOTAL_LENGTH];
struct {
pos_t hash_tab[HC_MATCHFINDER_HASH_LENGTH];
- pos_t child_tab[MATCHFINDER_WINDOW_SIZE];
+ pos_t next_tab[MATCHFINDER_WINDOW_SIZE];
};
};
} _aligned_attribute(MATCHFINDER_ALIGNMENT);
first_3_bytes = load_u24_unaligned(in_next);
hash = lz_hash_u24(first_3_bytes, HC_MATCHFINDER_HASH_ORDER);
cur_match = mf->hash_tab[hash];
- mf->child_tab[in_next - in_base] = cur_match;
+ mf->next_tab[in_next - in_base] = cur_match;
mf->hash_tab[hash] = in_next - in_base;
if (unlikely(best_len >= max_len))
break;
/* Not a match; keep trying. */
- cur_match = mf->child_tab[
+ cur_match = mf->next_tab[
matchfinder_slot_for_match(cur_match)];
if (!matchfinder_match_in_window(cur_match,
in_base, in_next))
best_len = lz_extend(in_next, best_matchptr, 3, max_len);
if (best_len >= nice_len)
goto out;
- cur_match = mf->child_tab[matchfinder_slot_for_match(cur_match)];
+ cur_match = mf->next_tab[matchfinder_slot_for_match(cur_match)];
if (!matchfinder_match_in_window(cur_match, in_base, in_next))
goto out;
if (!--depth_remaining)
#endif
break;
- cur_match = mf->child_tab[matchfinder_slot_for_match(cur_match)];
+ cur_match = mf->next_tab[matchfinder_slot_for_match(cur_match)];
if (!matchfinder_match_in_window(cur_match, in_base, in_next))
goto out;
if (!--depth_remaining)
goto out;
}
- #if UNALIGNED_ACCESS_IS_FAST
- len = 4;
- #else
- len = 0;
- #endif
+ if (UNALIGNED_ACCESS_IS_FAST)
+ len = 4;
+ else
+ len = 0;
len = lz_extend(in_next, matchptr, len, max_len);
if (len > best_len) {
best_len = len;
if (best_len >= nice_len)
goto out;
}
- cur_match = mf->child_tab[matchfinder_slot_for_match(cur_match)];
+ cur_match = mf->next_tab[matchfinder_slot_for_match(cur_match)];
if (!matchfinder_match_in_window(cur_match, in_base, in_next))
goto out;
if (!--depth_remaining)
do {
hash = lz_hash(in_next, HC_MATCHFINDER_HASH_ORDER);
- mf->child_tab[in_next - in_base] = mf->hash_tab[hash];
+ mf->next_tab[in_next - in_base] = mf->hash_tab[hash];
mf->hash_tab[hash] = in_next - in_base;
in_next++;
} while (--count);
}
+
+#endif /* _HC_MATCHFINDER_H */
const u32 start_len, const u32 max_len)
{
u32 len = start_len;
+ machine_word_t v_word;
- if (UNALIGNED_ACCESS_IS_FAST && CPU_IS_LITTLE_ENDIAN) {
-
- machine_word_t v_word;
+ if (UNALIGNED_ACCESS_IS_FAST) {
if (likely(max_len - len >= 4 * WORDSIZE)) {
goto word_differs;
len += WORDSIZE;
}
+ }
- while (len < max_len && matchptr[len] == strptr[len])
- len++;
- return len;
+ while (len < max_len && matchptr[len] == strptr[len])
+ len++;
+ return len;
- word_differs:
- return len + (ffsw(v_word) >> 3);
- } else {
- while (len < max_len && matchptr[len] == strptr[len])
- len++;
- return len;
- }
+word_differs:
+ if (CPU_IS_LITTLE_ENDIAN)
+ len += (ffsw(v_word) >> 3);
+ else
+ len += (flsw(v_word) >> 3);
+ return len;
}
#endif /* _WIMLIB_LZ_EXTEND_H */
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#pragma once
+#ifndef _MATCHFINDER_COMMON_H
+#define _MATCHFINDER_COMMON_H
#include "wimlib/types.h"
}
}
#endif /* MATCHFINDER_IS_SLIDING */
+
+#endif /* _MATCHFINDER_COMMON_H */
#define load_word_unaligned load_machine_word_t_unaligned
#define store_word_unaligned store_machine_word_t_unaligned
-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;
-}
-
static inline u16
get_unaligned_u16_le(const void *p)
{
# include "config.h"
#endif
-#include "wimlib/assert.h"
#include "wimlib/compress_common.h"
#include "wimlib/util.h"
# include "config.h"
#endif
-#include "wimlib/assert.h"
#include "wimlib/decompress_common.h"
#include <string.h>
#if defined(ENABLE_ERROR_MESSAGES) || defined(ENABLE_DEBUG)
static void
-wimlib_vmsg(const tchar *tag, const tchar *format,
- va_list va, bool perror)
+wimlib_vmsg(const tchar *tag, const tchar *format, va_list va, bool perror)
{
-#if !defined(ENABLE_DEBUG)
- if (wimlib_print_errors)
+#ifndef ENABLE_DEBUG
+ if (!wimlib_print_errors)
+ return;
#endif
- {
- int errno_save = errno;
- fflush(stdout);
- tfputs(tag, wimlib_error_file);
- tvfprintf(wimlib_error_file, format, va);
- if (perror && errno_save != 0) {
- tchar buf[64];
- int res;
- res = tstrerror_r(errno_save, buf, ARRAY_LEN(buf));
- if (res) {
- tsprintf(buf,
- T("unknown error (errno=%d)"),
- errno_save);
- }
- #ifdef WIN32
- if (errno_save == EBUSY)
- tstrcpy(buf, T("Resource busy"));
- #endif
- tfprintf(wimlib_error_file, T(": %"TS), buf);
+ int errno_save = errno;
+ fflush(stdout);
+ tfputs(tag, wimlib_error_file);
+ tvfprintf(wimlib_error_file, format, va);
+ if (perror && errno_save != 0) {
+ tchar buf[64];
+ int res;
+ res = tstrerror_r(errno_save, buf, ARRAY_LEN(buf));
+ if (res) {
+ tsprintf(buf,
+ T("unknown error (errno=%d)"),
+ errno_save);
}
- tputc(T('\n'), wimlib_error_file);
- fflush(wimlib_error_file);
- errno = errno_save;
+ #ifdef WIN32
+ if (errno_save == EBUSY)
+ tstrcpy(buf, T("Resource busy"));
+ #endif
+ tfprintf(wimlib_error_file, T(": %"TS), buf);
}
+ tputc(T('\n'), wimlib_error_file);
+ fflush(wimlib_error_file);
+ errno = errno_save;
}
#endif