zstdlib 0.3.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +30 -1
- data/README.md +2 -2
- data/Rakefile +1 -1
- data/ext/zstdlib/extconf.rb +3 -3
- data/ext/zstdlib/ruby/zlib-2.7/zstdlib.c +4895 -0
- data/ext/zstdlib/ruby/zlib-3.0/zstdlib.c +4994 -0
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/common/bitstream.h +59 -51
- data/ext/zstdlib/zstd-1.5.0/lib/common/compiler.h +289 -0
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/common/cpu.h +1 -3
- data/ext/zstdlib/zstd-1.5.0/lib/common/debug.c +24 -0
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/common/debug.h +22 -49
- data/ext/zstdlib/zstd-1.5.0/lib/common/entropy_common.c +362 -0
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/common/error_private.c +3 -1
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/common/error_private.h +8 -4
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/common/fse.h +50 -42
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/common/fse_decompress.c +149 -55
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/common/huf.h +43 -39
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/common/mem.h +69 -25
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/common/pool.c +30 -20
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/common/pool.h +3 -3
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/common/threading.c +51 -4
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/common/threading.h +36 -4
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/common/xxhash.c +40 -92
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/common/xxhash.h +12 -32
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/common/zstd_common.c +10 -10
- data/ext/zstdlib/zstd-1.5.0/lib/common/zstd_deps.h +111 -0
- data/ext/zstdlib/zstd-1.5.0/lib/common/zstd_internal.h +490 -0
- data/ext/zstdlib/zstd-1.5.0/lib/common/zstd_trace.h +154 -0
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/compress/fse_compress.c +47 -63
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/compress/hist.c +41 -63
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/compress/hist.h +13 -33
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/compress/huf_compress.c +332 -193
- data/ext/zstdlib/zstd-1.5.0/lib/compress/zstd_compress.c +6393 -0
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/compress/zstd_compress_internal.h +522 -86
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/compress/zstd_compress_literals.c +25 -16
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/compress/zstd_compress_literals.h +2 -2
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/compress/zstd_compress_sequences.c +50 -24
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/compress/zstd_compress_sequences.h +11 -4
- data/ext/zstdlib/zstd-1.5.0/lib/compress/zstd_compress_superblock.c +572 -0
- data/ext/zstdlib/zstd-1.5.0/lib/compress/zstd_compress_superblock.h +32 -0
- data/ext/zstdlib/zstd-1.5.0/lib/compress/zstd_cwksp.h +662 -0
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/compress/zstd_double_fast.c +43 -41
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/compress/zstd_double_fast.h +2 -2
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/compress/zstd_fast.c +85 -80
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/compress/zstd_fast.h +2 -2
- data/ext/zstdlib/zstd-1.5.0/lib/compress/zstd_lazy.c +2184 -0
- data/ext/zstdlib/zstd-1.5.0/lib/compress/zstd_lazy.h +125 -0
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/compress/zstd_ldm.c +333 -208
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/compress/zstd_ldm.h +15 -3
- data/ext/zstdlib/zstd-1.5.0/lib/compress/zstd_ldm_geartab.h +103 -0
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/compress/zstd_opt.c +228 -129
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/compress/zstd_opt.h +1 -1
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/compress/zstdmt_compress.c +151 -440
- data/ext/zstdlib/zstd-1.5.0/lib/compress/zstdmt_compress.h +110 -0
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/decompress/huf_decompress.c +395 -276
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/decompress/zstd_ddict.c +20 -16
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/decompress/zstd_ddict.h +3 -3
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/decompress/zstd_decompress.c +628 -231
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/decompress/zstd_decompress_block.c +606 -380
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/decompress/zstd_decompress_block.h +8 -5
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/decompress/zstd_decompress_internal.h +39 -9
- data/ext/zstdlib/zstd-1.5.0/lib/zdict.h +452 -0
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/zstd.h +740 -153
- data/ext/zstdlib/{zstd-1.4.2/lib/common → zstd-1.5.0/lib}/zstd_errors.h +3 -1
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/zlibWrapper/gzclose.c +1 -1
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/zlibWrapper/gzcompatibility.h +1 -1
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/zlibWrapper/gzguts.h +0 -0
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/zlibWrapper/gzlib.c +9 -9
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/zlibWrapper/gzread.c +16 -8
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/zlibWrapper/gzwrite.c +8 -8
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/zlibWrapper/zstd_zlibwrapper.c +131 -45
- data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/zlibWrapper/zstd_zlibwrapper.h +1 -1
- metadata +74 -65
- data/ext/zstdlib/zstd-1.4.2/lib/common/compiler.h +0 -147
- data/ext/zstdlib/zstd-1.4.2/lib/common/debug.c +0 -44
- data/ext/zstdlib/zstd-1.4.2/lib/common/entropy_common.c +0 -236
- data/ext/zstdlib/zstd-1.4.2/lib/common/zstd_internal.h +0 -371
- data/ext/zstdlib/zstd-1.4.2/lib/compress/zstd_compress.c +0 -3904
- data/ext/zstdlib/zstd-1.4.2/lib/compress/zstd_lazy.c +0 -1111
- data/ext/zstdlib/zstd-1.4.2/lib/compress/zstd_lazy.h +0 -67
- data/ext/zstdlib/zstd-1.4.2/lib/compress/zstdmt_compress.h +0 -192
@@ -2,18 +2,21 @@
|
|
2
2
|
* Copyright (c) 2016 Tino Reichardt
|
3
3
|
* All rights reserved.
|
4
4
|
*
|
5
|
+
* You can contact the author at:
|
6
|
+
* - zstdmt source repository: https://github.com/mcmilk/zstdmt
|
7
|
+
*
|
5
8
|
* This source code is licensed under both the BSD-style license (found in the
|
6
9
|
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
7
10
|
* in the COPYING file in the root directory of this source tree).
|
8
|
-
*
|
9
|
-
* You can contact the author at:
|
10
|
-
* - zstdmt source repository: https://github.com/mcmilk/zstdmt
|
11
|
+
* You may select, at your option, one of the above-listed licenses.
|
11
12
|
*/
|
12
13
|
|
13
14
|
/**
|
14
15
|
* This file will hold wrapper for systems, which do not support pthreads
|
15
16
|
*/
|
16
17
|
|
18
|
+
#include "threading.h"
|
19
|
+
|
17
20
|
/* create fake symbol to avoid empty translation unit warning */
|
18
21
|
int g_ZSTD_threading_useless_symbol;
|
19
22
|
|
@@ -28,7 +31,6 @@ int g_ZSTD_threading_useless_symbol;
|
|
28
31
|
/* === Dependencies === */
|
29
32
|
#include <process.h>
|
30
33
|
#include <errno.h>
|
31
|
-
#include "threading.h"
|
32
34
|
|
33
35
|
|
34
36
|
/* === Implementation === */
|
@@ -73,3 +75,48 @@ int ZSTD_pthread_join(ZSTD_pthread_t thread, void **value_ptr)
|
|
73
75
|
}
|
74
76
|
|
75
77
|
#endif /* ZSTD_MULTITHREAD */
|
78
|
+
|
79
|
+
#if defined(ZSTD_MULTITHREAD) && DEBUGLEVEL >= 1 && !defined(_WIN32)
|
80
|
+
|
81
|
+
#define ZSTD_DEPS_NEED_MALLOC
|
82
|
+
#include "zstd_deps.h"
|
83
|
+
|
84
|
+
int ZSTD_pthread_mutex_init(ZSTD_pthread_mutex_t* mutex, pthread_mutexattr_t const* attr)
|
85
|
+
{
|
86
|
+
*mutex = (pthread_mutex_t*)ZSTD_malloc(sizeof(pthread_mutex_t));
|
87
|
+
if (!*mutex)
|
88
|
+
return 1;
|
89
|
+
return pthread_mutex_init(*mutex, attr);
|
90
|
+
}
|
91
|
+
|
92
|
+
int ZSTD_pthread_mutex_destroy(ZSTD_pthread_mutex_t* mutex)
|
93
|
+
{
|
94
|
+
if (!*mutex)
|
95
|
+
return 0;
|
96
|
+
{
|
97
|
+
int const ret = pthread_mutex_destroy(*mutex);
|
98
|
+
ZSTD_free(*mutex);
|
99
|
+
return ret;
|
100
|
+
}
|
101
|
+
}
|
102
|
+
|
103
|
+
int ZSTD_pthread_cond_init(ZSTD_pthread_cond_t* cond, pthread_condattr_t const* attr)
|
104
|
+
{
|
105
|
+
*cond = (pthread_cond_t*)ZSTD_malloc(sizeof(pthread_cond_t));
|
106
|
+
if (!*cond)
|
107
|
+
return 1;
|
108
|
+
return pthread_cond_init(*cond, attr);
|
109
|
+
}
|
110
|
+
|
111
|
+
int ZSTD_pthread_cond_destroy(ZSTD_pthread_cond_t* cond)
|
112
|
+
{
|
113
|
+
if (!*cond)
|
114
|
+
return 0;
|
115
|
+
{
|
116
|
+
int const ret = pthread_cond_destroy(*cond);
|
117
|
+
ZSTD_free(*cond);
|
118
|
+
return ret;
|
119
|
+
}
|
120
|
+
}
|
121
|
+
|
122
|
+
#endif
|
@@ -2,17 +2,20 @@
|
|
2
2
|
* Copyright (c) 2016 Tino Reichardt
|
3
3
|
* All rights reserved.
|
4
4
|
*
|
5
|
+
* You can contact the author at:
|
6
|
+
* - zstdmt source repository: https://github.com/mcmilk/zstdmt
|
7
|
+
*
|
5
8
|
* This source code is licensed under both the BSD-style license (found in the
|
6
9
|
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
7
10
|
* in the COPYING file in the root directory of this source tree).
|
8
|
-
*
|
9
|
-
* You can contact the author at:
|
10
|
-
* - zstdmt source repository: https://github.com/mcmilk/zstdmt
|
11
|
+
* You may select, at your option, one of the above-listed licenses.
|
11
12
|
*/
|
12
13
|
|
13
14
|
#ifndef THREADING_H_938743
|
14
15
|
#define THREADING_H_938743
|
15
16
|
|
17
|
+
#include "debug.h"
|
18
|
+
|
16
19
|
#if defined (__cplusplus)
|
17
20
|
extern "C" {
|
18
21
|
#endif
|
@@ -75,10 +78,12 @@ int ZSTD_pthread_join(ZSTD_pthread_t thread, void** value_ptr);
|
|
75
78
|
*/
|
76
79
|
|
77
80
|
|
78
|
-
#elif defined(ZSTD_MULTITHREAD)
|
81
|
+
#elif defined(ZSTD_MULTITHREAD) /* posix assumed ; need a better detection method */
|
79
82
|
/* === POSIX Systems === */
|
80
83
|
# include <pthread.h>
|
81
84
|
|
85
|
+
#if DEBUGLEVEL < 1
|
86
|
+
|
82
87
|
#define ZSTD_pthread_mutex_t pthread_mutex_t
|
83
88
|
#define ZSTD_pthread_mutex_init(a, b) pthread_mutex_init((a), (b))
|
84
89
|
#define ZSTD_pthread_mutex_destroy(a) pthread_mutex_destroy((a))
|
@@ -96,6 +101,33 @@ int ZSTD_pthread_join(ZSTD_pthread_t thread, void** value_ptr);
|
|
96
101
|
#define ZSTD_pthread_create(a, b, c, d) pthread_create((a), (b), (c), (d))
|
97
102
|
#define ZSTD_pthread_join(a, b) pthread_join((a),(b))
|
98
103
|
|
104
|
+
#else /* DEBUGLEVEL >= 1 */
|
105
|
+
|
106
|
+
/* Debug implementation of threading.
|
107
|
+
* In this implementation we use pointers for mutexes and condition variables.
|
108
|
+
* This way, if we forget to init/destroy them the program will crash or ASAN
|
109
|
+
* will report leaks.
|
110
|
+
*/
|
111
|
+
|
112
|
+
#define ZSTD_pthread_mutex_t pthread_mutex_t*
|
113
|
+
int ZSTD_pthread_mutex_init(ZSTD_pthread_mutex_t* mutex, pthread_mutexattr_t const* attr);
|
114
|
+
int ZSTD_pthread_mutex_destroy(ZSTD_pthread_mutex_t* mutex);
|
115
|
+
#define ZSTD_pthread_mutex_lock(a) pthread_mutex_lock(*(a))
|
116
|
+
#define ZSTD_pthread_mutex_unlock(a) pthread_mutex_unlock(*(a))
|
117
|
+
|
118
|
+
#define ZSTD_pthread_cond_t pthread_cond_t*
|
119
|
+
int ZSTD_pthread_cond_init(ZSTD_pthread_cond_t* cond, pthread_condattr_t const* attr);
|
120
|
+
int ZSTD_pthread_cond_destroy(ZSTD_pthread_cond_t* cond);
|
121
|
+
#define ZSTD_pthread_cond_wait(a, b) pthread_cond_wait(*(a), *(b))
|
122
|
+
#define ZSTD_pthread_cond_signal(a) pthread_cond_signal(*(a))
|
123
|
+
#define ZSTD_pthread_cond_broadcast(a) pthread_cond_broadcast(*(a))
|
124
|
+
|
125
|
+
#define ZSTD_pthread_t pthread_t
|
126
|
+
#define ZSTD_pthread_create(a, b, c, d) pthread_create((a), (b), (c), (d))
|
127
|
+
#define ZSTD_pthread_join(a, b) pthread_join((a),(b))
|
128
|
+
|
129
|
+
#endif
|
130
|
+
|
99
131
|
#else /* ZSTD_MULTITHREAD not defined */
|
100
132
|
/* No multithreading support */
|
101
133
|
|
@@ -1,35 +1,15 @@
|
|
1
1
|
/*
|
2
|
-
* xxHash - Fast Hash algorithm
|
3
|
-
* Copyright (
|
4
|
-
*
|
5
|
-
*
|
6
|
-
*
|
7
|
-
*
|
8
|
-
*
|
9
|
-
*
|
10
|
-
*
|
11
|
-
*
|
12
|
-
*
|
13
|
-
* * Redistributions in binary form must reproduce the above
|
14
|
-
* copyright notice, this list of conditions and the following disclaimer
|
15
|
-
* in the documentation and/or other materials provided with the
|
16
|
-
* distribution.
|
17
|
-
*
|
18
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
19
|
-
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
20
|
-
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
21
|
-
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
22
|
-
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
23
|
-
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
24
|
-
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
25
|
-
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
26
|
-
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
27
|
-
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
28
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
29
|
-
*
|
30
|
-
* You can contact the author at :
|
31
|
-
* - xxHash homepage: http://www.xxhash.com
|
32
|
-
* - xxHash source repository : https://github.com/Cyan4973/xxHash
|
2
|
+
* xxHash - Fast Hash algorithm
|
3
|
+
* Copyright (c) Yann Collet, Facebook, Inc.
|
4
|
+
*
|
5
|
+
* You can contact the author at :
|
6
|
+
* - xxHash homepage: http://www.xxhash.com
|
7
|
+
* - xxHash source repository : https://github.com/Cyan4973/xxHash
|
8
|
+
*
|
9
|
+
* This source code is licensed under both the BSD-style license (found in the
|
10
|
+
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
11
|
+
* in the COPYING file in the root directory of this source tree).
|
12
|
+
* You may select, at your option, one of the above-listed licenses.
|
33
13
|
*/
|
34
14
|
|
35
15
|
|
@@ -50,10 +30,9 @@
|
|
50
30
|
* Prefer these methods in priority order (0 > 1 > 2)
|
51
31
|
*/
|
52
32
|
#ifndef XXH_FORCE_MEMORY_ACCESS /* can be defined externally, on command line for example */
|
53
|
-
# if defined(
|
54
|
-
|
55
|
-
|
56
|
-
(defined(__GNUC__) && ( defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__) ))
|
33
|
+
# if (defined(__INTEL_COMPILER) && !defined(WIN32)) || \
|
34
|
+
(defined(__GNUC__) && ( defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__) )) || \
|
35
|
+
defined(__ICCARM__)
|
57
36
|
# define XXH_FORCE_MEMORY_ACCESS 1
|
58
37
|
# endif
|
59
38
|
#endif
|
@@ -96,14 +75,12 @@
|
|
96
75
|
* Includes & Memory related functions
|
97
76
|
***************************************/
|
98
77
|
/* Modify the local functions below should you wish to use some other memory routines */
|
99
|
-
/* for
|
100
|
-
#
|
101
|
-
#include
|
102
|
-
static void* XXH_malloc(size_t s) { return
|
103
|
-
static void XXH_free (void* p) {
|
104
|
-
|
105
|
-
#include <string.h>
|
106
|
-
static void* XXH_memcpy(void* dest, const void* src, size_t size) { return memcpy(dest,src,size); }
|
78
|
+
/* for ZSTD_malloc(), ZSTD_free() */
|
79
|
+
#define ZSTD_DEPS_NEED_MALLOC
|
80
|
+
#include "zstd_deps.h" /* size_t, ZSTD_malloc, ZSTD_free, ZSTD_memcpy */
|
81
|
+
static void* XXH_malloc(size_t s) { return ZSTD_malloc(s); }
|
82
|
+
static void XXH_free (void* p) { ZSTD_free(p); }
|
83
|
+
static void* XXH_memcpy(void* dest, const void* src, size_t size) { return ZSTD_memcpy(dest,src,size); }
|
107
84
|
|
108
85
|
#ifndef XXH_STATIC_LINKING_ONLY
|
109
86
|
# define XXH_STATIC_LINKING_ONLY
|
@@ -114,49 +91,13 @@ static void* XXH_memcpy(void* dest, const void* src, size_t size) { return memcp
|
|
114
91
|
/* *************************************
|
115
92
|
* Compiler Specific Options
|
116
93
|
***************************************/
|
117
|
-
#
|
118
|
-
# define INLINE_KEYWORD inline
|
119
|
-
#else
|
120
|
-
# define INLINE_KEYWORD
|
121
|
-
#endif
|
122
|
-
|
123
|
-
#if defined(__GNUC__)
|
124
|
-
# define FORCE_INLINE_ATTR __attribute__((always_inline))
|
125
|
-
#elif defined(_MSC_VER)
|
126
|
-
# define FORCE_INLINE_ATTR __forceinline
|
127
|
-
#else
|
128
|
-
# define FORCE_INLINE_ATTR
|
129
|
-
#endif
|
130
|
-
|
131
|
-
#define FORCE_INLINE_TEMPLATE static INLINE_KEYWORD FORCE_INLINE_ATTR
|
132
|
-
|
133
|
-
|
134
|
-
#ifdef _MSC_VER
|
135
|
-
# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */
|
136
|
-
#endif
|
94
|
+
#include "compiler.h"
|
137
95
|
|
138
96
|
|
139
97
|
/* *************************************
|
140
98
|
* Basic Types
|
141
99
|
***************************************/
|
142
|
-
#
|
143
|
-
# define MEM_MODULE
|
144
|
-
# if !defined (__VMS) && (defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) )
|
145
|
-
# include <stdint.h>
|
146
|
-
typedef uint8_t BYTE;
|
147
|
-
typedef uint16_t U16;
|
148
|
-
typedef uint32_t U32;
|
149
|
-
typedef int32_t S32;
|
150
|
-
typedef uint64_t U64;
|
151
|
-
# else
|
152
|
-
typedef unsigned char BYTE;
|
153
|
-
typedef unsigned short U16;
|
154
|
-
typedef unsigned int U32;
|
155
|
-
typedef signed int S32;
|
156
|
-
typedef unsigned long long U64; /* if your compiler doesn't support unsigned long long, replace by another 64-bit type here. Note that xxhash.h will also need to be updated. */
|
157
|
-
# endif
|
158
|
-
#endif
|
159
|
-
|
100
|
+
#include "mem.h" /* BYTE, U32, U64, size_t */
|
160
101
|
|
161
102
|
#if (defined(XXH_FORCE_MEMORY_ACCESS) && (XXH_FORCE_MEMORY_ACCESS==2))
|
162
103
|
|
@@ -182,14 +123,14 @@ static U64 XXH_read64(const void* ptr) { return ((const unalign*)ptr)->u64; }
|
|
182
123
|
static U32 XXH_read32(const void* memPtr)
|
183
124
|
{
|
184
125
|
U32 val;
|
185
|
-
|
126
|
+
ZSTD_memcpy(&val, memPtr, sizeof(val));
|
186
127
|
return val;
|
187
128
|
}
|
188
129
|
|
189
130
|
static U64 XXH_read64(const void* memPtr)
|
190
131
|
{
|
191
132
|
U64 val;
|
192
|
-
|
133
|
+
ZSTD_memcpy(&val, memPtr, sizeof(val));
|
193
134
|
return val;
|
194
135
|
}
|
195
136
|
|
@@ -206,7 +147,12 @@ static U64 XXH_read64(const void* memPtr)
|
|
206
147
|
# define XXH_rotl32(x,r) _rotl(x,r)
|
207
148
|
# define XXH_rotl64(x,r) _rotl64(x,r)
|
208
149
|
#else
|
150
|
+
#if defined(__ICCARM__)
|
151
|
+
# include <intrinsics.h>
|
152
|
+
# define XXH_rotl32(x,r) __ROR(x,(32 - r))
|
153
|
+
#else
|
209
154
|
# define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
|
155
|
+
#endif
|
210
156
|
# define XXH_rotl64(x,r) ((x << r) | (x >> (64 - r)))
|
211
157
|
#endif
|
212
158
|
|
@@ -321,12 +267,12 @@ XXH_PUBLIC_API unsigned XXH_versionNumber (void) { return XXH_VERSION_NUMBER; }
|
|
321
267
|
****************************/
|
322
268
|
XXH_PUBLIC_API void XXH32_copyState(XXH32_state_t* restrict dstState, const XXH32_state_t* restrict srcState)
|
323
269
|
{
|
324
|
-
|
270
|
+
ZSTD_memcpy(dstState, srcState, sizeof(*dstState));
|
325
271
|
}
|
326
272
|
|
327
273
|
XXH_PUBLIC_API void XXH64_copyState(XXH64_state_t* restrict dstState, const XXH64_state_t* restrict srcState)
|
328
274
|
{
|
329
|
-
|
275
|
+
ZSTD_memcpy(dstState, srcState, sizeof(*dstState));
|
330
276
|
}
|
331
277
|
|
332
278
|
|
@@ -568,12 +514,12 @@ XXH_PUBLIC_API XXH_errorcode XXH64_freeState(XXH64_state_t* statePtr)
|
|
568
514
|
XXH_PUBLIC_API XXH_errorcode XXH32_reset(XXH32_state_t* statePtr, unsigned int seed)
|
569
515
|
{
|
570
516
|
XXH32_state_t state; /* using a local state to memcpy() in order to avoid strict-aliasing warnings */
|
571
|
-
|
517
|
+
ZSTD_memset(&state, 0, sizeof(state)-4); /* do not write into reserved, for future removal */
|
572
518
|
state.v1 = seed + PRIME32_1 + PRIME32_2;
|
573
519
|
state.v2 = seed + PRIME32_2;
|
574
520
|
state.v3 = seed + 0;
|
575
521
|
state.v4 = seed - PRIME32_1;
|
576
|
-
|
522
|
+
ZSTD_memcpy(statePtr, &state, sizeof(state));
|
577
523
|
return XXH_OK;
|
578
524
|
}
|
579
525
|
|
@@ -581,12 +527,12 @@ XXH_PUBLIC_API XXH_errorcode XXH32_reset(XXH32_state_t* statePtr, unsigned int s
|
|
581
527
|
XXH_PUBLIC_API XXH_errorcode XXH64_reset(XXH64_state_t* statePtr, unsigned long long seed)
|
582
528
|
{
|
583
529
|
XXH64_state_t state; /* using a local state to memcpy() in order to avoid strict-aliasing warnings */
|
584
|
-
|
530
|
+
ZSTD_memset(&state, 0, sizeof(state)-8); /* do not write into reserved, for future removal */
|
585
531
|
state.v1 = seed + PRIME64_1 + PRIME64_2;
|
586
532
|
state.v2 = seed + PRIME64_2;
|
587
533
|
state.v3 = seed + 0;
|
588
534
|
state.v4 = seed - PRIME64_1;
|
589
|
-
|
535
|
+
ZSTD_memcpy(statePtr, &state, sizeof(state));
|
590
536
|
return XXH_OK;
|
591
537
|
}
|
592
538
|
|
@@ -723,7 +669,9 @@ FORCE_INLINE_TEMPLATE XXH_errorcode XXH64_update_endian (XXH64_state_t* state, c
|
|
723
669
|
state->total_len += len;
|
724
670
|
|
725
671
|
if (state->memsize + len < 32) { /* fill in tmp buffer */
|
726
|
-
|
672
|
+
if (input != NULL) {
|
673
|
+
XXH_memcpy(((BYTE*)state->mem64) + state->memsize, input, len);
|
674
|
+
}
|
727
675
|
state->memsize += (U32)len;
|
728
676
|
return XXH_OK;
|
729
677
|
}
|
@@ -855,14 +803,14 @@ XXH_PUBLIC_API void XXH32_canonicalFromHash(XXH32_canonical_t* dst, XXH32_hash_t
|
|
855
803
|
{
|
856
804
|
XXH_STATIC_ASSERT(sizeof(XXH32_canonical_t) == sizeof(XXH32_hash_t));
|
857
805
|
if (XXH_CPU_LITTLE_ENDIAN) hash = XXH_swap32(hash);
|
858
|
-
|
806
|
+
ZSTD_memcpy(dst, &hash, sizeof(*dst));
|
859
807
|
}
|
860
808
|
|
861
809
|
XXH_PUBLIC_API void XXH64_canonicalFromHash(XXH64_canonical_t* dst, XXH64_hash_t hash)
|
862
810
|
{
|
863
811
|
XXH_STATIC_ASSERT(sizeof(XXH64_canonical_t) == sizeof(XXH64_hash_t));
|
864
812
|
if (XXH_CPU_LITTLE_ENDIAN) hash = XXH_swap64(hash);
|
865
|
-
|
813
|
+
ZSTD_memcpy(dst, &hash, sizeof(*dst));
|
866
814
|
}
|
867
815
|
|
868
816
|
XXH_PUBLIC_API XXH32_hash_t XXH32_hashFromCanonical(const XXH32_canonical_t* src)
|
@@ -1,35 +1,15 @@
|
|
1
1
|
/*
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
notice, this list of conditions and the following disclaimer.
|
14
|
-
* Redistributions in binary form must reproduce the above
|
15
|
-
copyright notice, this list of conditions and the following disclaimer
|
16
|
-
in the documentation and/or other materials provided with the
|
17
|
-
distribution.
|
18
|
-
|
19
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
20
|
-
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
21
|
-
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
22
|
-
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
23
|
-
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
24
|
-
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
25
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
26
|
-
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
27
|
-
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
28
|
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
29
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
30
|
-
|
31
|
-
You can contact the author at :
|
32
|
-
- xxHash source repository : https://github.com/Cyan4973/xxHash
|
2
|
+
* xxHash - Extremely Fast Hash algorithm
|
3
|
+
* Header File
|
4
|
+
* Copyright (c) Yann Collet, Facebook, Inc.
|
5
|
+
*
|
6
|
+
* You can contact the author at :
|
7
|
+
* - xxHash source repository : https://github.com/Cyan4973/xxHash
|
8
|
+
*
|
9
|
+
* This source code is licensed under both the BSD-style license (found in the
|
10
|
+
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
11
|
+
* in the COPYING file in the root directory of this source tree).
|
12
|
+
* You may select, at your option, one of the above-listed licenses.
|
33
13
|
*/
|
34
14
|
|
35
15
|
/* Notice extracted from xxHash homepage :
|
@@ -75,7 +55,7 @@ extern "C" {
|
|
75
55
|
/* ****************************
|
76
56
|
* Definitions
|
77
57
|
******************************/
|
78
|
-
#include
|
58
|
+
#include "zstd_deps.h"
|
79
59
|
typedef enum { XXH_OK=0, XXH_ERROR } XXH_errorcode;
|
80
60
|
|
81
61
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
* Copyright (c)
|
2
|
+
* Copyright (c) Yann Collet, Facebook, Inc.
|
3
3
|
* All rights reserved.
|
4
4
|
*
|
5
5
|
* This source code is licensed under both the BSD-style license (found in the
|
@@ -13,8 +13,8 @@
|
|
13
13
|
/*-*************************************
|
14
14
|
* Dependencies
|
15
15
|
***************************************/
|
16
|
-
#
|
17
|
-
#include
|
16
|
+
#define ZSTD_DEPS_NEED_MALLOC
|
17
|
+
#include "zstd_deps.h" /* ZSTD_malloc, ZSTD_calloc, ZSTD_free, ZSTD_memset */
|
18
18
|
#include "error_private.h"
|
19
19
|
#include "zstd_internal.h"
|
20
20
|
|
@@ -53,31 +53,31 @@ const char* ZSTD_getErrorString(ZSTD_ErrorCode code) { return ERR_getErrorString
|
|
53
53
|
/*=**************************************************************
|
54
54
|
* Custom allocator
|
55
55
|
****************************************************************/
|
56
|
-
void*
|
56
|
+
void* ZSTD_customMalloc(size_t size, ZSTD_customMem customMem)
|
57
57
|
{
|
58
58
|
if (customMem.customAlloc)
|
59
59
|
return customMem.customAlloc(customMem.opaque, size);
|
60
|
-
return
|
60
|
+
return ZSTD_malloc(size);
|
61
61
|
}
|
62
62
|
|
63
|
-
void*
|
63
|
+
void* ZSTD_customCalloc(size_t size, ZSTD_customMem customMem)
|
64
64
|
{
|
65
65
|
if (customMem.customAlloc) {
|
66
66
|
/* calloc implemented as malloc+memset;
|
67
67
|
* not as efficient as calloc, but next best guess for custom malloc */
|
68
68
|
void* const ptr = customMem.customAlloc(customMem.opaque, size);
|
69
|
-
|
69
|
+
ZSTD_memset(ptr, 0, size);
|
70
70
|
return ptr;
|
71
71
|
}
|
72
|
-
return
|
72
|
+
return ZSTD_calloc(1, size);
|
73
73
|
}
|
74
74
|
|
75
|
-
void
|
75
|
+
void ZSTD_customFree(void* ptr, ZSTD_customMem customMem)
|
76
76
|
{
|
77
77
|
if (ptr!=NULL) {
|
78
78
|
if (customMem.customFree)
|
79
79
|
customMem.customFree(customMem.opaque, ptr);
|
80
80
|
else
|
81
|
-
|
81
|
+
ZSTD_free(ptr);
|
82
82
|
}
|
83
83
|
}
|