Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compiler errors, warnings, and crash #14

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Archive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ Filter* Archive::Algorithm::createFilter(Stream* stream, Analyzer* analyzer, Arc
fout << s.Word() << std::endl;
}
}
auto& freq = builder.FrequencyCounter();
auto& freq = builder.GetFrequencyCounter();
dict_filter->AddCodeWords(code_words.GetCodeWords(), code_words.num1_, code_words.num2_, code_words.num3_, &freq, dict_codes.Count());
if (false) {
std::cerr << std::endl << "Before " << freq.Sum() << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion CM-inl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ inline void CM<kInputs, kUseSSE, HistoryType>::init() {
if (kInputs > idx++) binary_profile_.EnableModel(kModelSparse3);
if (kInputs > idx++) binary_profile_.EnableModel(kModelSparse4);
if (kInputs > idx++) binary_profile_.EnableModel(kModelOrder0);
if (kInputs > idx++) binary_profile_.EnableModel(static_cast<ModelType>(opts_[0]));
// if (kInputs > idx++) binary_profile_.EnableModel(static_cast<ModelType>(opts_[0]));
// binary_profile_ = CMProfile();
binary_profile_.SetMatchModelOrder(binary_mm_order);
binary_profile_.SetMinLZPLen(lzp_enabled_ ? 0 : kMaxMatch + 1);
Expand Down
6 changes: 3 additions & 3 deletions CM.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ namespace cm {
*(ctx_ptr++) = HashLookup(IntervalHash(hash) + interval_add, true);
}
if (cur.ModelEnabled(kModelInterval2, enabled)) {
*(ctx_ptr++) = HashLookup(hashify(interval_model2_ & interval2_mask_) + (22 * 123456781 + 1), true);
*(ctx_ptr++) = HashLookup(hashify(interval_model2_ & interval2_mask_) + (22 * 123456781ULL + 1), true);
}
if (cur.ModelEnabled(kModelBracket, enabled)) {
auto hash = bracket_.GetHash();
Expand All @@ -822,7 +822,7 @@ namespace cm {
static const size_t kCount = 1 << 16;
int64_t total[kCount];
std::fill_n(total, kCount, -1);
return DPOptimalLeaves(cost, total, 0, 64);
return OptimalByteStates(cost, total, 0, 64);
}

int NextNibbleLeaf(int node, size_t next) {
Expand Down Expand Up @@ -911,7 +911,7 @@ namespace cm {
}
}

uint32_t h = HashFunc((last_bytes_ & 0xFFFF) * 3, 0x4ec457c1 * 19);
uint32_t h = HashFunc((last_bytes_ & 0xFFFF) * 3, 0x4ec457c1ULL * 19);
if (mm_len == 0) {
++miss_len_;
if (kStatistics) {
Expand Down
2 changes: 1 addition & 1 deletion Dict.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ class Dict {
words_.Clear();
}

FrequencyCounter<256>& FrequencyCounter() {
FrequencyCounter<256>& GetFrequencyCounter() {
return counter_;
}

Expand Down
39 changes: 28 additions & 11 deletions Util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,31 +39,48 @@

#define OVERRIDE

#ifdef WIN32
#define ALWAYS_INLINE __forceinline
#define NO_INLINE __declspec(noinline)
#if defined(__GNUC__) && (__GNUC__ >= 4)
#define ALWAYS_INLINE __attribute__((__always_inline__)) inline
#define NO_INLINE __attribute__((__noinline__))
#elif defined(_MSC_VER) && (_MSC_VER >= 1200)
# define ALWAYS_INLINE __forceinline
# if _MSC_VER >= 1310
# define NO_INLINE __declspec(noinline)
# else
# define NO_INLINE
# endif
#else
#define ALWAYS_INLINE __attribute__((always_inline))
#define NO_INLINE __declspec(noinline)
# define ALWAYS_INLINE
# define NO_INLINE
#endif

#define no_alias __restrict
#define rst // no_alias

// TODO: Implement these.
#define LIKELY(x) x
#define UNLIKELY(x) x
#if defined(__GNUC__) && (__GNUC__ >= 3)
#define LIKELY(x) __builtin_expect(!!(x), 1)
#define UNLIKELY(x) __builtin_expect(!!(x), 0)
#else
#define LIKELY(x) !!(x)
#define UNLIKELY(x) !!(x)
#endif

#ifdef _DEBUG
static const bool kIsDebugBuild = true;
#else
static const bool kIsDebugBuild = false;
#endif

#ifdef _MSC_VER
#define ASSUME(x) __assume(x)
#if defined(_MSC_VER) && (_MSC_VER >= 1310)
# define ASSUME(x) __assume(x)
#elif defined(__has_builtin)
# if __has_builtin(__builtin_assume)
# define ASSUME(x) __builtin_assume(x)
# else
# define ASSUME(x)
# endif
#else
#define ASSUME(x)
# define ASSUME(x)
#endif

typedef uint32_t hash_t;
Expand Down