extlzham 0.0.1.PROTOTYPE3-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.md +27 -0
- data/README.md +74 -0
- data/Rakefile +152 -0
- data/contrib/lzham/LICENSE +22 -0
- data/contrib/lzham/README.md +209 -0
- data/contrib/lzham/include/lzham.h +781 -0
- data/contrib/lzham/lzhamcomp/lzham_comp.h +38 -0
- data/contrib/lzham/lzhamcomp/lzham_lzbase.cpp +244 -0
- data/contrib/lzham/lzhamcomp/lzham_lzbase.h +45 -0
- data/contrib/lzham/lzhamcomp/lzham_lzcomp.cpp +608 -0
- data/contrib/lzham/lzhamcomp/lzham_lzcomp_internal.cpp +1966 -0
- data/contrib/lzham/lzhamcomp/lzham_lzcomp_internal.h +472 -0
- data/contrib/lzham/lzhamcomp/lzham_lzcomp_state.cpp +1413 -0
- data/contrib/lzham/lzhamcomp/lzham_match_accel.cpp +562 -0
- data/contrib/lzham/lzhamcomp/lzham_match_accel.h +146 -0
- data/contrib/lzham/lzhamcomp/lzham_null_threading.h +97 -0
- data/contrib/lzham/lzhamcomp/lzham_pthreads_threading.cpp +229 -0
- data/contrib/lzham/lzhamcomp/lzham_pthreads_threading.h +520 -0
- data/contrib/lzham/lzhamcomp/lzham_threading.h +12 -0
- data/contrib/lzham/lzhamcomp/lzham_win32_threading.cpp +220 -0
- data/contrib/lzham/lzhamcomp/lzham_win32_threading.h +368 -0
- data/contrib/lzham/lzhamdecomp/lzham_assert.cpp +66 -0
- data/contrib/lzham/lzhamdecomp/lzham_assert.h +40 -0
- data/contrib/lzham/lzhamdecomp/lzham_checksum.cpp +73 -0
- data/contrib/lzham/lzhamdecomp/lzham_checksum.h +13 -0
- data/contrib/lzham/lzhamdecomp/lzham_config.h +23 -0
- data/contrib/lzham/lzhamdecomp/lzham_core.h +264 -0
- data/contrib/lzham/lzhamdecomp/lzham_decomp.h +37 -0
- data/contrib/lzham/lzhamdecomp/lzham_helpers.h +54 -0
- data/contrib/lzham/lzhamdecomp/lzham_huffman_codes.cpp +262 -0
- data/contrib/lzham/lzhamdecomp/lzham_huffman_codes.h +14 -0
- data/contrib/lzham/lzhamdecomp/lzham_lzdecomp.cpp +1527 -0
- data/contrib/lzham/lzhamdecomp/lzham_lzdecompbase.cpp +131 -0
- data/contrib/lzham/lzhamdecomp/lzham_lzdecompbase.h +89 -0
- data/contrib/lzham/lzhamdecomp/lzham_math.h +142 -0
- data/contrib/lzham/lzhamdecomp/lzham_mem.cpp +284 -0
- data/contrib/lzham/lzhamdecomp/lzham_mem.h +112 -0
- data/contrib/lzham/lzhamdecomp/lzham_platform.cpp +157 -0
- data/contrib/lzham/lzhamdecomp/lzham_platform.h +284 -0
- data/contrib/lzham/lzhamdecomp/lzham_prefix_coding.cpp +351 -0
- data/contrib/lzham/lzhamdecomp/lzham_prefix_coding.h +146 -0
- data/contrib/lzham/lzhamdecomp/lzham_symbol_codec.cpp +1484 -0
- data/contrib/lzham/lzhamdecomp/lzham_symbol_codec.h +556 -0
- data/contrib/lzham/lzhamdecomp/lzham_timer.cpp +147 -0
- data/contrib/lzham/lzhamdecomp/lzham_timer.h +99 -0
- data/contrib/lzham/lzhamdecomp/lzham_traits.h +141 -0
- data/contrib/lzham/lzhamdecomp/lzham_types.h +97 -0
- data/contrib/lzham/lzhamdecomp/lzham_utils.h +58 -0
- data/contrib/lzham/lzhamdecomp/lzham_vector.cpp +75 -0
- data/contrib/lzham/lzhamdecomp/lzham_vector.h +588 -0
- data/contrib/lzham/lzhamlib/lzham_lib.cpp +179 -0
- data/examples/basic.rb +48 -0
- data/ext/constants.c +64 -0
- data/ext/decoder.c +313 -0
- data/ext/depend +5 -0
- data/ext/encoder.c +372 -0
- data/ext/error.c +80 -0
- data/ext/extconf.rb +29 -0
- data/ext/extlzham.c +34 -0
- data/ext/extlzham.h +62 -0
- data/gemstub.rb +22 -0
- data/lib/2.0/extlzham.so +0 -0
- data/lib/2.1/extlzham.so +0 -0
- data/lib/2.2/extlzham.so +0 -0
- data/lib/extlzham.rb +158 -0
- data/lib/extlzham/version.rb +5 -0
- data/test/test_extlzham.rb +35 -0
- metadata +156 -0
@@ -0,0 +1,66 @@
|
|
1
|
+
// File: lzham_assert.cpp
|
2
|
+
// See Copyright Notice and license at the end of include/lzham.h
|
3
|
+
#include "lzham_core.h"
|
4
|
+
|
5
|
+
static bool g_fail_exceptions;
|
6
|
+
static bool g_exit_on_failure = true;
|
7
|
+
|
8
|
+
void lzham_enable_fail_exceptions(bool enabled)
|
9
|
+
{
|
10
|
+
g_fail_exceptions = enabled;
|
11
|
+
}
|
12
|
+
|
13
|
+
void lzham_assert(const char* pExp, const char* pFile, unsigned line)
|
14
|
+
{
|
15
|
+
char buf[512];
|
16
|
+
|
17
|
+
sprintf_s(buf, sizeof(buf), "%s(%u): Assertion failed: \"%s\"\n", pFile, line, pExp);
|
18
|
+
|
19
|
+
lzham_output_debug_string(buf);
|
20
|
+
|
21
|
+
printf("%s", buf);
|
22
|
+
|
23
|
+
if (lzham_is_debugger_present())
|
24
|
+
lzham_debug_break();
|
25
|
+
}
|
26
|
+
|
27
|
+
void lzham_fail(const char* pExp, const char* pFile, unsigned line)
|
28
|
+
{
|
29
|
+
char buf[512];
|
30
|
+
|
31
|
+
sprintf_s(buf, sizeof(buf), "%s(%u): Failure: \"%s\"\n", pFile, line, pExp);
|
32
|
+
|
33
|
+
lzham_output_debug_string(buf);
|
34
|
+
|
35
|
+
printf("%s", buf);
|
36
|
+
|
37
|
+
if (lzham_is_debugger_present())
|
38
|
+
lzham_debug_break();
|
39
|
+
|
40
|
+
#if LZHAM_USE_WIN32_API
|
41
|
+
if (g_fail_exceptions)
|
42
|
+
RaiseException(LZHAM_FAIL_EXCEPTION_CODE, 0, 0, NULL);
|
43
|
+
else
|
44
|
+
#endif
|
45
|
+
if (g_exit_on_failure)
|
46
|
+
exit(EXIT_FAILURE);
|
47
|
+
}
|
48
|
+
|
49
|
+
void lzham_trace(const char* pFmt, va_list args)
|
50
|
+
{
|
51
|
+
if (lzham_is_debugger_present())
|
52
|
+
{
|
53
|
+
char buf[512];
|
54
|
+
vsprintf_s(buf, sizeof(buf), pFmt, args);
|
55
|
+
|
56
|
+
lzham_output_debug_string(buf);
|
57
|
+
}
|
58
|
+
};
|
59
|
+
|
60
|
+
void lzham_trace(const char* pFmt, ...)
|
61
|
+
{
|
62
|
+
va_list args;
|
63
|
+
va_start(args, pFmt);
|
64
|
+
lzham_trace(pFmt, args);
|
65
|
+
va_end(args);
|
66
|
+
};
|
@@ -0,0 +1,40 @@
|
|
1
|
+
// File: lzham_assert.h
|
2
|
+
// See Copyright Notice and license at the end of include/lzham.h
|
3
|
+
#pragma once
|
4
|
+
|
5
|
+
const unsigned int LZHAM_FAIL_EXCEPTION_CODE = 256U;
|
6
|
+
void lzham_enable_fail_exceptions(bool enabled);
|
7
|
+
|
8
|
+
void lzham_assert(const char* pExp, const char* pFile, unsigned line);
|
9
|
+
void lzham_fail(const char* pExp, const char* pFile, unsigned line);
|
10
|
+
|
11
|
+
#ifdef NDEBUG
|
12
|
+
#define LZHAM_ASSERT(x) ((void)0)
|
13
|
+
#else
|
14
|
+
#define LZHAM_ASSERT(_exp) (void)( (!!(_exp)) || (lzham_assert(#_exp, __FILE__, __LINE__), 0) )
|
15
|
+
#define LZHAM_ASSERTS_ENABLED 1
|
16
|
+
#endif
|
17
|
+
|
18
|
+
#define LZHAM_VERIFY(_exp) (void)( (!!(_exp)) || (lzham_assert(#_exp, __FILE__, __LINE__), 0) )
|
19
|
+
|
20
|
+
#define LZHAM_FAIL(msg) do { lzham_fail(#msg, __FILE__, __LINE__); } while(0)
|
21
|
+
|
22
|
+
#define LZHAM_ASSERT_OPEN_RANGE(x, l, h) LZHAM_ASSERT((x >= l) && (x < h))
|
23
|
+
#define LZHAM_ASSERT_CLOSED_RANGE(x, l, h) LZHAM_ASSERT((x >= l) && (x <= h))
|
24
|
+
|
25
|
+
void lzham_trace(const char* pFmt, va_list args);
|
26
|
+
void lzham_trace(const char* pFmt, ...);
|
27
|
+
|
28
|
+
// Borrowed from boost libraries.
|
29
|
+
template <bool x> struct assume_failure;
|
30
|
+
template <> struct assume_failure<true> { enum { blah = 1 }; };
|
31
|
+
template<int x> struct assume_try { };
|
32
|
+
|
33
|
+
#define LZHAM_JOINER_FINAL(a, b) a##b
|
34
|
+
#define LZHAM_JOINER(a, b) LZHAM_JOINER_FINAL(a, b)
|
35
|
+
#define LZHAM_JOIN(a, b) LZHAM_JOINER(a, b)
|
36
|
+
#if defined(__GNUC__)
|
37
|
+
#define LZHAM_ASSUME(p) typedef assume_try < sizeof(assume_failure< (bool)(p) > ) > LZHAM_JOIN(assume_typedef, __COUNTER__) __attribute__((unused))
|
38
|
+
#else
|
39
|
+
#define LZHAM_ASSUME(p) typedef assume_try < sizeof(assume_failure< (bool)(p) > ) > LZHAM_JOIN(assume_typedef, __COUNTER__)
|
40
|
+
#endif
|
@@ -0,0 +1,73 @@
|
|
1
|
+
// File: lzham_checksum.cpp
|
2
|
+
#include "lzham_core.h"
|
3
|
+
#include "lzham_checksum.h"
|
4
|
+
|
5
|
+
namespace lzham
|
6
|
+
{
|
7
|
+
// Originally from the public domain stb.h header.
|
8
|
+
uint adler32(const void* pBuf, size_t buflen, uint adler32)
|
9
|
+
{
|
10
|
+
if (!pBuf)
|
11
|
+
return cInitAdler32;
|
12
|
+
|
13
|
+
const uint8* buffer = static_cast<const uint8*>(pBuf);
|
14
|
+
|
15
|
+
const unsigned long ADLER_MOD = 65521;
|
16
|
+
unsigned long s1 = adler32 & 0xffff, s2 = adler32 >> 16;
|
17
|
+
size_t blocklen;
|
18
|
+
unsigned long i;
|
19
|
+
|
20
|
+
blocklen = buflen % 5552;
|
21
|
+
while (buflen)
|
22
|
+
{
|
23
|
+
for (i=0; i + 7 < blocklen; i += 8)
|
24
|
+
{
|
25
|
+
s1 += buffer[0], s2 += s1;
|
26
|
+
s1 += buffer[1], s2 += s1;
|
27
|
+
s1 += buffer[2], s2 += s1;
|
28
|
+
s1 += buffer[3], s2 += s1;
|
29
|
+
s1 += buffer[4], s2 += s1;
|
30
|
+
s1 += buffer[5], s2 += s1;
|
31
|
+
s1 += buffer[6], s2 += s1;
|
32
|
+
s1 += buffer[7], s2 += s1;
|
33
|
+
|
34
|
+
buffer += 8;
|
35
|
+
}
|
36
|
+
|
37
|
+
for (; i < blocklen; ++i)
|
38
|
+
s1 += *buffer++, s2 += s1;
|
39
|
+
|
40
|
+
s1 %= ADLER_MOD, s2 %= ADLER_MOD;
|
41
|
+
buflen -= blocklen;
|
42
|
+
blocklen = 5552;
|
43
|
+
}
|
44
|
+
return static_cast<uint>((s2 << 16) + s1);
|
45
|
+
}
|
46
|
+
|
47
|
+
// Karl Malbrain's compact CRC-32, with pre and post conditioning.
|
48
|
+
// See "A compact CCITT crc16 and crc32 C implementation that balances processor cache usage against speed":
|
49
|
+
// http://www.geocities.com/malbrain/
|
50
|
+
static const lzham_uint32 s_crc32[16] =
|
51
|
+
{
|
52
|
+
0x00000000, 0x1db71064, 0x3b6e20c8, 0x26d930ac, 0x76dc4190, 0x6b6b51f4, 0x4db26158, 0x5005713c,
|
53
|
+
0xedb88320, 0xf00f9344, 0xd6d6a3e8, 0xcb61b38c, 0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, 0xbdbdf21c
|
54
|
+
};
|
55
|
+
|
56
|
+
uint crc32(uint crc, const lzham_uint8 *ptr, size_t buf_len)
|
57
|
+
{
|
58
|
+
if (!ptr)
|
59
|
+
return cInitCRC32;
|
60
|
+
|
61
|
+
crc = ~crc;
|
62
|
+
while (buf_len--)
|
63
|
+
{
|
64
|
+
lzham_uint8 b = *ptr++;
|
65
|
+
crc = (crc >> 4) ^ s_crc32[(crc & 0xF) ^ (b & 0xF)];
|
66
|
+
crc = (crc >> 4) ^ s_crc32[(crc & 0xF) ^ (b >> 4)];
|
67
|
+
}
|
68
|
+
return ~crc;
|
69
|
+
}
|
70
|
+
|
71
|
+
|
72
|
+
} // namespace lzham
|
73
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// File: lzham_checksum.h
|
2
|
+
// See Copyright Notice and license at the end of include/lzham.h
|
3
|
+
#pragma once
|
4
|
+
|
5
|
+
namespace lzham
|
6
|
+
{
|
7
|
+
const uint cInitAdler32 = 1U;
|
8
|
+
uint adler32(const void* pBuf, size_t buflen, uint adler32 = cInitAdler32);
|
9
|
+
|
10
|
+
const uint cInitCRC32 = 0U;
|
11
|
+
uint crc32(uint crc, const lzham_uint8 *ptr, size_t buf_len);
|
12
|
+
|
13
|
+
} // namespace lzham
|
@@ -0,0 +1,23 @@
|
|
1
|
+
// File: lzham_config.h
|
2
|
+
// See Copyright Notice and license at the end of include/lzham.h
|
3
|
+
#pragma once
|
4
|
+
|
5
|
+
#if defined(_DEBUG) || defined(DEBUG)
|
6
|
+
#define LZHAM_BUILD_DEBUG
|
7
|
+
|
8
|
+
#ifndef DEBUG
|
9
|
+
#define DEBUG
|
10
|
+
#endif
|
11
|
+
#else
|
12
|
+
#define LZHAM_BUILD_RELEASE
|
13
|
+
|
14
|
+
#ifndef NDEBUG
|
15
|
+
#define NDEBUG
|
16
|
+
#endif
|
17
|
+
|
18
|
+
#ifdef DEBUG
|
19
|
+
#error DEBUG cannot be defined in LZHAM_BUILD_RELEASE
|
20
|
+
#endif
|
21
|
+
#endif
|
22
|
+
#define LZHAM_BUFFERED_PRINTF 0
|
23
|
+
#define LZHAM_PERF_SECTIONS 0
|
@@ -0,0 +1,264 @@
|
|
1
|
+
// File: lzham_core.h
|
2
|
+
// See Copyright Notice and license at the end of include/lzham.h
|
3
|
+
#pragma once
|
4
|
+
|
5
|
+
#if defined(_MSC_VER)
|
6
|
+
#pragma warning (disable: 4127) // conditional expression is constant
|
7
|
+
#endif
|
8
|
+
|
9
|
+
// Enable this when first porting to new platforms - disables all threading and atomic ops in compressor:
|
10
|
+
//#define LZHAM_ANSI_CPLUSPLUS 1
|
11
|
+
|
12
|
+
#if defined(__FreeBSD__) || defined(__NetBSD__)
|
13
|
+
// TODO: I haven't compiled/tested on these platforms yet, let's play it safe for now.
|
14
|
+
#define LZHAM_ANSI_CPLUSPLUS 1
|
15
|
+
#endif
|
16
|
+
|
17
|
+
#if defined(__APPLE__) && defined(__MACH__)
|
18
|
+
// Apple OSX and iOS
|
19
|
+
#include <TargetConditionals.h>
|
20
|
+
#endif
|
21
|
+
|
22
|
+
#if defined(_XBOX) && !defined(LZHAM_ANSI_CPLUSPLUS)
|
23
|
+
// --- X360 - This hasn't been tested since early an alpha.
|
24
|
+
#include <xtl.h>
|
25
|
+
#define _HAS_EXCEPTIONS 0
|
26
|
+
#define NOMINMAX
|
27
|
+
|
28
|
+
#define LZHAM_PLATFORM_X360 1
|
29
|
+
#define LZHAM_USE_WIN32_API 1
|
30
|
+
#define LZHAM_USE_WIN32_ATOMIC_FUNCTIONS 1
|
31
|
+
#define LZHAM_64BIT_POINTERS 0
|
32
|
+
#define LZHAM_CPU_HAS_64BIT_REGISTERS 1
|
33
|
+
#define LZHAM_BIG_ENDIAN_CPU 1
|
34
|
+
#define LZHAM_USE_UNALIGNED_INT_LOADS 1
|
35
|
+
#define LZHAM_RESTRICT __restrict
|
36
|
+
#define LZHAM_FORCE_INLINE __forceinline
|
37
|
+
#define LZHAM_NOTE_UNUSED(x) (void)x
|
38
|
+
|
39
|
+
#elif defined(WIN32) && !defined(LZHAM_ANSI_CPLUSPLUS)
|
40
|
+
// --- Windows: MSVC or MinGW, x86 or x64, Win32 API's for threading and Win32 Interlocked API's or GCC built-ins for atomic ops.
|
41
|
+
#ifdef NDEBUG
|
42
|
+
// Ensure checked iterators are disabled.
|
43
|
+
#define _SECURE_SCL 0
|
44
|
+
#define _HAS_ITERATOR_DEBUGGING 0
|
45
|
+
#endif
|
46
|
+
#ifndef _DLL
|
47
|
+
// If we're using the DLL form of the run-time libs, we're also going to be enabling exceptions because we'll be building CLR apps.
|
48
|
+
// Otherwise, we disable exceptions for a small speed boost.
|
49
|
+
#define _HAS_EXCEPTIONS 0
|
50
|
+
#endif
|
51
|
+
#define NOMINMAX
|
52
|
+
|
53
|
+
#ifndef _WIN32_WINNT
|
54
|
+
#define _WIN32_WINNT 0x500
|
55
|
+
#endif
|
56
|
+
|
57
|
+
#ifndef WIN32_LEAN_AND_MEAN
|
58
|
+
#define WIN32_LEAN_AND_MEAN
|
59
|
+
#endif
|
60
|
+
|
61
|
+
#include <windows.h>
|
62
|
+
|
63
|
+
#define LZHAM_USE_WIN32_API 1
|
64
|
+
|
65
|
+
#if defined(__MINGW32__) || defined(__MINGW64__)
|
66
|
+
#define LZHAM_USE_GCC_ATOMIC_BUILTINS 1
|
67
|
+
#else
|
68
|
+
#define LZHAM_USE_WIN32_ATOMIC_FUNCTIONS 1
|
69
|
+
#endif
|
70
|
+
|
71
|
+
#define LZHAM_PLATFORM_PC 1
|
72
|
+
|
73
|
+
#ifdef _WIN64
|
74
|
+
#define LZHAM_PLATFORM_PC_X64 1
|
75
|
+
#define LZHAM_64BIT_POINTERS 1
|
76
|
+
#define LZHAM_CPU_HAS_64BIT_REGISTERS 1
|
77
|
+
#define LZHAM_LITTLE_ENDIAN_CPU 1
|
78
|
+
#else
|
79
|
+
#define LZHAM_PLATFORM_PC_X86 1
|
80
|
+
#define LZHAM_64BIT_POINTERS 0
|
81
|
+
#define LZHAM_CPU_HAS_64BIT_REGISTERS 0
|
82
|
+
#define LZHAM_LITTLE_ENDIAN_CPU 1
|
83
|
+
#endif
|
84
|
+
|
85
|
+
#define LZHAM_USE_UNALIGNED_INT_LOADS 1
|
86
|
+
#define LZHAM_RESTRICT __restrict
|
87
|
+
#define LZHAM_FORCE_INLINE __forceinline
|
88
|
+
|
89
|
+
#if defined(_MSC_VER) || defined(__MINGW32__) || defined(__MINGW64__)
|
90
|
+
#define LZHAM_USE_MSVC_INTRINSICS 1
|
91
|
+
#endif
|
92
|
+
|
93
|
+
#define LZHAM_NOTE_UNUSED(x) (void)x
|
94
|
+
|
95
|
+
#elif defined(__APPLE__) && !defined(LZHAM_ANSI_CPLUSPLUS)
|
96
|
+
// --- Apple: iOS or OSX
|
97
|
+
#if (TARGET_IPHONE_SIMULATOR == 1) || (TARGET_OS_IPHONE == 1)
|
98
|
+
#define LZHAM_PLATFORM_PC 0
|
99
|
+
|
100
|
+
#if defined(_WIN64) || defined(__MINGW64__) || defined(_LP64) || defined(__LP64__)
|
101
|
+
#define LZHAM_PLATFORM_PC_X64 0
|
102
|
+
#define LZHAM_64BIT_POINTERS 1
|
103
|
+
#define LZHAM_CPU_HAS_64BIT_REGISTERS 1
|
104
|
+
#else
|
105
|
+
#define LZHAM_PLATFORM_PC_X86 0
|
106
|
+
#define LZHAM_64BIT_POINTERS 0
|
107
|
+
#define LZHAM_CPU_HAS_64BIT_REGISTERS 0
|
108
|
+
#endif
|
109
|
+
|
110
|
+
#define LZHAM_USE_UNALIGNED_INT_LOADS 0
|
111
|
+
|
112
|
+
#if __BIG_ENDIAN__
|
113
|
+
#define LZHAM_BIG_ENDIAN_CPU 1
|
114
|
+
#else
|
115
|
+
#define LZHAM_LITTLE_ENDIAN_CPU 1
|
116
|
+
#endif
|
117
|
+
|
118
|
+
#define LZHAM_USE_PTHREADS_API 1
|
119
|
+
#define LZHAM_USE_GCC_ATOMIC_BUILTINS 1
|
120
|
+
|
121
|
+
#define LZHAM_RESTRICT
|
122
|
+
|
123
|
+
#if defined(__clang__)
|
124
|
+
#define LZHAM_FORCE_INLINE inline
|
125
|
+
#else
|
126
|
+
#define LZHAM_FORCE_INLINE inline __attribute__((__always_inline__,__gnu_inline__))
|
127
|
+
#endif
|
128
|
+
|
129
|
+
#define LZHAM_NOTE_UNUSED(x) (void)x
|
130
|
+
|
131
|
+
#elif (TARGET_OS_MAC == 1)
|
132
|
+
#define LZHAM_PLATFORM_PC 1
|
133
|
+
|
134
|
+
#if defined(_WIN64) || defined(__MINGW64__) || defined(_LP64) || defined(__LP64__)
|
135
|
+
#define LZHAM_PLATFORM_PC_X64 1
|
136
|
+
#define LZHAM_64BIT_POINTERS 1
|
137
|
+
#define LZHAM_CPU_HAS_64BIT_REGISTERS 1
|
138
|
+
#else
|
139
|
+
#define LZHAM_PLATFORM_PC_X86 1
|
140
|
+
#define LZHAM_64BIT_POINTERS 0
|
141
|
+
#define LZHAM_CPU_HAS_64BIT_REGISTERS 0
|
142
|
+
#endif
|
143
|
+
|
144
|
+
#define LZHAM_USE_UNALIGNED_INT_LOADS 1
|
145
|
+
|
146
|
+
#if __BIG_ENDIAN__
|
147
|
+
#define LZHAM_BIG_ENDIAN_CPU 1
|
148
|
+
#else
|
149
|
+
#define LZHAM_LITTLE_ENDIAN_CPU 1
|
150
|
+
#endif
|
151
|
+
|
152
|
+
#define LZHAM_USE_PTHREADS_API 1
|
153
|
+
#define LZHAM_USE_GCC_ATOMIC_BUILTINS 1
|
154
|
+
|
155
|
+
#define LZHAM_RESTRICT
|
156
|
+
|
157
|
+
#if defined(__clang__)
|
158
|
+
#define LZHAM_FORCE_INLINE inline
|
159
|
+
#else
|
160
|
+
#define LZHAM_FORCE_INLINE inline __attribute__((__always_inline__,__gnu_inline__))
|
161
|
+
#endif
|
162
|
+
|
163
|
+
#define LZHAM_NOTE_UNUSED(x) (void)x
|
164
|
+
#elif
|
165
|
+
#error TODO: Unknown Apple target
|
166
|
+
#endif
|
167
|
+
|
168
|
+
#elif defined(__linux__) && (defined(__i386__) || defined(__x86_64__)) && !defined(LZHAM_ANSI_CPLUSPLUS)
|
169
|
+
// --- Generic GCC/clang path for x86/x64, clang or GCC, Linux, OSX, FreeBSD or NetBSD, pthreads for threading, GCC built-ins for atomic ops.
|
170
|
+
#define LZHAM_PLATFORM_PC 1
|
171
|
+
|
172
|
+
#if defined(_LP64) || defined(__LP64__) || defined(__x86_64__)
|
173
|
+
// 64-bit build assumes pointers are always 64-bit
|
174
|
+
#define LZHAM_PLATFORM_PC_X64 1
|
175
|
+
#define LZHAM_64BIT_POINTERS 1
|
176
|
+
#define LZHAM_CPU_HAS_64BIT_REGISTERS 1
|
177
|
+
#else
|
178
|
+
#define LZHAM_PLATFORM_PC_X86 1
|
179
|
+
#define LZHAM_64BIT_POINTERS 0
|
180
|
+
#define LZHAM_CPU_HAS_64BIT_REGISTERS 0
|
181
|
+
#endif
|
182
|
+
|
183
|
+
#define LZHAM_USE_UNALIGNED_INT_LOADS 1
|
184
|
+
|
185
|
+
#if __BIG_ENDIAN__
|
186
|
+
#define LZHAM_BIG_ENDIAN_CPU 1
|
187
|
+
#else
|
188
|
+
#define LZHAM_LITTLE_ENDIAN_CPU 1
|
189
|
+
#endif
|
190
|
+
|
191
|
+
#define LZHAM_USE_PTHREADS_API 1
|
192
|
+
#define LZHAM_USE_GCC_ATOMIC_BUILTINS 1
|
193
|
+
|
194
|
+
#define LZHAM_RESTRICT
|
195
|
+
|
196
|
+
#if defined(__clang__)
|
197
|
+
#define LZHAM_FORCE_INLINE inline
|
198
|
+
#else
|
199
|
+
#define LZHAM_FORCE_INLINE inline __attribute__((__always_inline__,__gnu_inline__))
|
200
|
+
#endif
|
201
|
+
|
202
|
+
#define LZHAM_NOTE_UNUSED(x) (void)x
|
203
|
+
#else
|
204
|
+
#warning Building as vanilla ANSI-C/C++, multi-threaded compression is disabled! Please configure lzhamdecomp/lzham_core.h.
|
205
|
+
|
206
|
+
// --- Vanilla ANSI-C/C++
|
207
|
+
// No threading support, unaligned loads are NOT okay, no atomic ops.
|
208
|
+
#if defined(_WIN64) || defined(__MINGW64__) || defined(_LP64) || defined(__LP64__)
|
209
|
+
#define LZHAM_64BIT_POINTERS 1
|
210
|
+
#define LZHAM_CPU_HAS_64BIT_REGISTERS 1
|
211
|
+
#else
|
212
|
+
#define LZHAM_64BIT_POINTERS 0
|
213
|
+
#define LZHAM_CPU_HAS_64BIT_REGISTERS 0
|
214
|
+
#endif
|
215
|
+
|
216
|
+
#define LZHAM_USE_UNALIGNED_INT_LOADS 0
|
217
|
+
|
218
|
+
#if __BIG_ENDIAN__
|
219
|
+
#define LZHAM_BIG_ENDIAN_CPU 1
|
220
|
+
#else
|
221
|
+
#define LZHAM_LITTLE_ENDIAN_CPU 1
|
222
|
+
#endif
|
223
|
+
|
224
|
+
#define LZHAM_USE_GCC_ATOMIC_BUILTINS 0
|
225
|
+
#define LZHAM_USE_WIN32_ATOMIC_FUNCTIONS 0
|
226
|
+
|
227
|
+
#define LZHAM_RESTRICT
|
228
|
+
#define LZHAM_FORCE_INLINE inline
|
229
|
+
|
230
|
+
#define LZHAM_NOTE_UNUSED(x) (void)x
|
231
|
+
#endif
|
232
|
+
|
233
|
+
#if LZHAM_LITTLE_ENDIAN_CPU
|
234
|
+
const bool c_lzham_little_endian_platform = true;
|
235
|
+
#else
|
236
|
+
const bool c_lzham_little_endian_platform = false;
|
237
|
+
#endif
|
238
|
+
|
239
|
+
const bool c_lzham_big_endian_platform = !c_lzham_little_endian_platform;
|
240
|
+
|
241
|
+
#include <stdlib.h>
|
242
|
+
#include <stdio.h>
|
243
|
+
#include <math.h>
|
244
|
+
#if !defined(__APPLE__) && !defined(__FreeBSD__)
|
245
|
+
#include <malloc.h>
|
246
|
+
#endif
|
247
|
+
#include <stdarg.h>
|
248
|
+
#include <memory.h>
|
249
|
+
#include <limits.h>
|
250
|
+
#include <algorithm>
|
251
|
+
#include <errno.h>
|
252
|
+
|
253
|
+
#include "lzham.h"
|
254
|
+
#include "lzham_config.h"
|
255
|
+
#include "lzham_types.h"
|
256
|
+
#include "lzham_assert.h"
|
257
|
+
#include "lzham_platform.h"
|
258
|
+
|
259
|
+
#include "lzham_helpers.h"
|
260
|
+
#include "lzham_traits.h"
|
261
|
+
#include "lzham_mem.h"
|
262
|
+
#include "lzham_math.h"
|
263
|
+
#include "lzham_utils.h"
|
264
|
+
#include "lzham_vector.h"
|