zstd-ruby 1.4.4.0 → 1.5.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/README.md +78 -5
- data/Rakefile +8 -2
- data/ext/zstdruby/common.h +15 -0
- data/ext/zstdruby/extconf.rb +3 -2
- data/ext/zstdruby/libzstd/common/allocations.h +55 -0
- data/ext/zstdruby/libzstd/common/bits.h +200 -0
- data/ext/zstdruby/libzstd/common/bitstream.h +74 -97
- data/ext/zstdruby/libzstd/common/compiler.h +219 -20
- data/ext/zstdruby/libzstd/common/cpu.h +1 -3
- data/ext/zstdruby/libzstd/common/debug.c +11 -31
- data/ext/zstdruby/libzstd/common/debug.h +22 -49
- data/ext/zstdruby/libzstd/common/entropy_common.c +184 -80
- data/ext/zstdruby/libzstd/common/error_private.c +11 -2
- data/ext/zstdruby/libzstd/common/error_private.h +87 -4
- data/ext/zstdruby/libzstd/common/fse.h +47 -116
- data/ext/zstdruby/libzstd/common/fse_decompress.c +127 -127
- data/ext/zstdruby/libzstd/common/huf.h +112 -197
- data/ext/zstdruby/libzstd/common/mem.h +124 -142
- data/ext/zstdruby/libzstd/common/pool.c +54 -27
- data/ext/zstdruby/libzstd/common/pool.h +11 -5
- data/ext/zstdruby/libzstd/common/portability_macros.h +156 -0
- data/ext/zstdruby/libzstd/common/threading.c +78 -22
- data/ext/zstdruby/libzstd/common/threading.h +9 -13
- data/ext/zstdruby/libzstd/common/xxhash.c +15 -873
- data/ext/zstdruby/libzstd/common/xxhash.h +5572 -191
- data/ext/zstdruby/libzstd/common/zstd_common.c +2 -37
- data/ext/zstdruby/libzstd/common/zstd_deps.h +111 -0
- data/ext/zstdruby/libzstd/common/zstd_internal.h +186 -144
- data/ext/zstdruby/libzstd/common/zstd_trace.h +163 -0
- data/ext/zstdruby/libzstd/compress/clevels.h +134 -0
- data/ext/zstdruby/libzstd/compress/fse_compress.c +99 -196
- data/ext/zstdruby/libzstd/compress/hist.c +41 -63
- data/ext/zstdruby/libzstd/compress/hist.h +13 -33
- data/ext/zstdruby/libzstd/compress/huf_compress.c +968 -331
- data/ext/zstdruby/libzstd/compress/zstd_compress.c +4120 -1191
- data/ext/zstdruby/libzstd/compress/zstd_compress_internal.h +688 -159
- data/ext/zstdruby/libzstd/compress/zstd_compress_literals.c +121 -40
- data/ext/zstdruby/libzstd/compress/zstd_compress_literals.h +16 -6
- data/ext/zstdruby/libzstd/compress/zstd_compress_sequences.c +62 -35
- data/ext/zstdruby/libzstd/compress/zstd_compress_sequences.h +10 -3
- data/ext/zstdruby/libzstd/compress/zstd_compress_superblock.c +577 -0
- data/ext/zstdruby/libzstd/compress/zstd_compress_superblock.h +32 -0
- data/ext/zstdruby/libzstd/compress/zstd_cwksp.h +322 -115
- data/ext/zstdruby/libzstd/compress/zstd_double_fast.c +394 -154
- data/ext/zstdruby/libzstd/compress/zstd_double_fast.h +4 -3
- data/ext/zstdruby/libzstd/compress/zstd_fast.c +729 -253
- data/ext/zstdruby/libzstd/compress/zstd_fast.h +4 -3
- data/ext/zstdruby/libzstd/compress/zstd_lazy.c +1289 -247
- data/ext/zstdruby/libzstd/compress/zstd_lazy.h +61 -1
- data/ext/zstdruby/libzstd/compress/zstd_ldm.c +339 -212
- data/ext/zstdruby/libzstd/compress/zstd_ldm.h +15 -3
- data/ext/zstdruby/libzstd/compress/zstd_ldm_geartab.h +106 -0
- data/ext/zstdruby/libzstd/compress/zstd_opt.c +508 -282
- data/ext/zstdruby/libzstd/compress/zstd_opt.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstdmt_compress.c +217 -466
- data/ext/zstdruby/libzstd/compress/zstdmt_compress.h +35 -114
- data/ext/zstdruby/libzstd/decompress/huf_decompress.c +1220 -572
- data/ext/zstdruby/libzstd/decompress/huf_decompress_amd64.S +576 -0
- data/ext/zstdruby/libzstd/decompress/zstd_ddict.c +23 -19
- data/ext/zstdruby/libzstd/decompress/zstd_ddict.h +3 -3
- data/ext/zstdruby/libzstd/decompress/zstd_decompress.c +859 -273
- data/ext/zstdruby/libzstd/decompress/zstd_decompress_block.c +1244 -375
- data/ext/zstdruby/libzstd/decompress/zstd_decompress_block.h +21 -7
- data/ext/zstdruby/libzstd/decompress/zstd_decompress_internal.h +74 -11
- data/ext/zstdruby/libzstd/dictBuilder/cover.c +75 -54
- data/ext/zstdruby/libzstd/dictBuilder/cover.h +20 -9
- data/ext/zstdruby/libzstd/dictBuilder/divsufsort.c +1 -1
- data/ext/zstdruby/libzstd/dictBuilder/fastcover.c +55 -36
- data/ext/zstdruby/libzstd/dictBuilder/zdict.c +126 -110
- data/ext/zstdruby/libzstd/{dictBuilder/zdict.h → zdict.h} +248 -56
- data/ext/zstdruby/libzstd/zstd.h +1277 -306
- data/ext/zstdruby/libzstd/{common/zstd_errors.h → zstd_errors.h} +29 -8
- data/ext/zstdruby/main.c +20 -0
- data/ext/zstdruby/skippable_frame.c +63 -0
- data/ext/zstdruby/streaming_compress.c +177 -0
- data/ext/zstdruby/streaming_compress.h +5 -0
- data/ext/zstdruby/streaming_decompress.c +123 -0
- data/ext/zstdruby/zstdruby.c +114 -32
- data/lib/zstd-ruby/version.rb +1 -1
- data/lib/zstd-ruby.rb +0 -1
- data/zstd-ruby.gemspec +1 -1
- metadata +24 -39
- data/.travis.yml +0 -14
- data/ext/zstdruby/libzstd/.gitignore +0 -3
- data/ext/zstdruby/libzstd/BUCK +0 -234
- data/ext/zstdruby/libzstd/Makefile +0 -289
- data/ext/zstdruby/libzstd/README.md +0 -159
- data/ext/zstdruby/libzstd/deprecated/zbuff.h +0 -214
- data/ext/zstdruby/libzstd/deprecated/zbuff_common.c +0 -26
- data/ext/zstdruby/libzstd/deprecated/zbuff_compress.c +0 -147
- data/ext/zstdruby/libzstd/deprecated/zbuff_decompress.c +0 -75
- data/ext/zstdruby/libzstd/dll/example/Makefile +0 -47
- data/ext/zstdruby/libzstd/dll/example/README.md +0 -69
- data/ext/zstdruby/libzstd/dll/example/build_package.bat +0 -20
- data/ext/zstdruby/libzstd/dll/example/fullbench-dll.sln +0 -25
- data/ext/zstdruby/libzstd/dll/example/fullbench-dll.vcxproj +0 -181
- data/ext/zstdruby/libzstd/legacy/zstd_legacy.h +0 -415
- data/ext/zstdruby/libzstd/legacy/zstd_v01.c +0 -2152
- data/ext/zstdruby/libzstd/legacy/zstd_v01.h +0 -94
- data/ext/zstdruby/libzstd/legacy/zstd_v02.c +0 -3514
- data/ext/zstdruby/libzstd/legacy/zstd_v02.h +0 -93
- data/ext/zstdruby/libzstd/legacy/zstd_v03.c +0 -3156
- data/ext/zstdruby/libzstd/legacy/zstd_v03.h +0 -93
- data/ext/zstdruby/libzstd/legacy/zstd_v04.c +0 -3641
- data/ext/zstdruby/libzstd/legacy/zstd_v04.h +0 -142
- data/ext/zstdruby/libzstd/legacy/zstd_v05.c +0 -4046
- data/ext/zstdruby/libzstd/legacy/zstd_v05.h +0 -162
- data/ext/zstdruby/libzstd/legacy/zstd_v06.c +0 -4150
- data/ext/zstdruby/libzstd/legacy/zstd_v06.h +0 -172
- data/ext/zstdruby/libzstd/legacy/zstd_v07.c +0 -4533
- data/ext/zstdruby/libzstd/legacy/zstd_v07.h +0 -187
- data/ext/zstdruby/libzstd/libzstd.pc.in +0 -15
- data/ext/zstdruby/zstdruby.h +0 -6
@@ -0,0 +1,156 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
|
+
* All rights reserved.
|
4
|
+
*
|
5
|
+
* This source code is licensed under both the BSD-style license (found in the
|
6
|
+
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
7
|
+
* in the COPYING file in the root directory of this source tree).
|
8
|
+
* You may select, at your option, one of the above-listed licenses.
|
9
|
+
*/
|
10
|
+
|
11
|
+
#ifndef ZSTD_PORTABILITY_MACROS_H
|
12
|
+
#define ZSTD_PORTABILITY_MACROS_H
|
13
|
+
|
14
|
+
/**
|
15
|
+
* This header file contains macro definitions to support portability.
|
16
|
+
* This header is shared between C and ASM code, so it MUST only
|
17
|
+
* contain macro definitions. It MUST not contain any C code.
|
18
|
+
*
|
19
|
+
* This header ONLY defines macros to detect platforms/feature support.
|
20
|
+
*
|
21
|
+
*/
|
22
|
+
|
23
|
+
|
24
|
+
/* compat. with non-clang compilers */
|
25
|
+
#ifndef __has_attribute
|
26
|
+
#define __has_attribute(x) 0
|
27
|
+
#endif
|
28
|
+
|
29
|
+
/* compat. with non-clang compilers */
|
30
|
+
#ifndef __has_builtin
|
31
|
+
# define __has_builtin(x) 0
|
32
|
+
#endif
|
33
|
+
|
34
|
+
/* compat. with non-clang compilers */
|
35
|
+
#ifndef __has_feature
|
36
|
+
# define __has_feature(x) 0
|
37
|
+
#endif
|
38
|
+
|
39
|
+
/* detects whether we are being compiled under msan */
|
40
|
+
#ifndef ZSTD_MEMORY_SANITIZER
|
41
|
+
# if __has_feature(memory_sanitizer)
|
42
|
+
# define ZSTD_MEMORY_SANITIZER 1
|
43
|
+
# else
|
44
|
+
# define ZSTD_MEMORY_SANITIZER 0
|
45
|
+
# endif
|
46
|
+
#endif
|
47
|
+
|
48
|
+
/* detects whether we are being compiled under asan */
|
49
|
+
#ifndef ZSTD_ADDRESS_SANITIZER
|
50
|
+
# if __has_feature(address_sanitizer)
|
51
|
+
# define ZSTD_ADDRESS_SANITIZER 1
|
52
|
+
# elif defined(__SANITIZE_ADDRESS__)
|
53
|
+
# define ZSTD_ADDRESS_SANITIZER 1
|
54
|
+
# else
|
55
|
+
# define ZSTD_ADDRESS_SANITIZER 0
|
56
|
+
# endif
|
57
|
+
#endif
|
58
|
+
|
59
|
+
/* detects whether we are being compiled under dfsan */
|
60
|
+
#ifndef ZSTD_DATAFLOW_SANITIZER
|
61
|
+
# if __has_feature(dataflow_sanitizer)
|
62
|
+
# define ZSTD_DATAFLOW_SANITIZER 1
|
63
|
+
# else
|
64
|
+
# define ZSTD_DATAFLOW_SANITIZER 0
|
65
|
+
# endif
|
66
|
+
#endif
|
67
|
+
|
68
|
+
/* Mark the internal assembly functions as hidden */
|
69
|
+
#ifdef __ELF__
|
70
|
+
# define ZSTD_HIDE_ASM_FUNCTION(func) .hidden func
|
71
|
+
#else
|
72
|
+
# define ZSTD_HIDE_ASM_FUNCTION(func)
|
73
|
+
#endif
|
74
|
+
|
75
|
+
/* Enable runtime BMI2 dispatch based on the CPU.
|
76
|
+
* Enabled for clang & gcc >=4.8 on x86 when BMI2 isn't enabled by default.
|
77
|
+
*/
|
78
|
+
#ifndef DYNAMIC_BMI2
|
79
|
+
#if ((defined(__clang__) && __has_attribute(__target__)) \
|
80
|
+
|| (defined(__GNUC__) \
|
81
|
+
&& (__GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)))) \
|
82
|
+
&& (defined(__x86_64__) || defined(_M_X64)) \
|
83
|
+
&& !defined(__BMI2__)
|
84
|
+
# define DYNAMIC_BMI2 1
|
85
|
+
#else
|
86
|
+
# define DYNAMIC_BMI2 0
|
87
|
+
#endif
|
88
|
+
#endif
|
89
|
+
|
90
|
+
/**
|
91
|
+
* Only enable assembly for GNUC compatible compilers,
|
92
|
+
* because other platforms may not support GAS assembly syntax.
|
93
|
+
*
|
94
|
+
* Only enable assembly for Linux / MacOS, other platforms may
|
95
|
+
* work, but they haven't been tested. This could likely be
|
96
|
+
* extended to BSD systems.
|
97
|
+
*
|
98
|
+
* Disable assembly when MSAN is enabled, because MSAN requires
|
99
|
+
* 100% of code to be instrumented to work.
|
100
|
+
*/
|
101
|
+
#if defined(__GNUC__)
|
102
|
+
# if defined(__linux__) || defined(__linux) || defined(__APPLE__)
|
103
|
+
# if ZSTD_MEMORY_SANITIZER
|
104
|
+
# define ZSTD_ASM_SUPPORTED 0
|
105
|
+
# elif ZSTD_DATAFLOW_SANITIZER
|
106
|
+
# define ZSTD_ASM_SUPPORTED 0
|
107
|
+
# else
|
108
|
+
# define ZSTD_ASM_SUPPORTED 1
|
109
|
+
# endif
|
110
|
+
# else
|
111
|
+
# define ZSTD_ASM_SUPPORTED 0
|
112
|
+
# endif
|
113
|
+
#else
|
114
|
+
# define ZSTD_ASM_SUPPORTED 0
|
115
|
+
#endif
|
116
|
+
|
117
|
+
/**
|
118
|
+
* Determines whether we should enable assembly for x86-64
|
119
|
+
* with BMI2.
|
120
|
+
*
|
121
|
+
* Enable if all of the following conditions hold:
|
122
|
+
* - ASM hasn't been explicitly disabled by defining ZSTD_DISABLE_ASM
|
123
|
+
* - Assembly is supported
|
124
|
+
* - We are compiling for x86-64 and either:
|
125
|
+
* - DYNAMIC_BMI2 is enabled
|
126
|
+
* - BMI2 is supported at compile time
|
127
|
+
*/
|
128
|
+
#if !defined(ZSTD_DISABLE_ASM) && \
|
129
|
+
ZSTD_ASM_SUPPORTED && \
|
130
|
+
defined(__x86_64__) && \
|
131
|
+
(DYNAMIC_BMI2 || defined(__BMI2__))
|
132
|
+
# define ZSTD_ENABLE_ASM_X86_64_BMI2 1
|
133
|
+
#else
|
134
|
+
# define ZSTD_ENABLE_ASM_X86_64_BMI2 0
|
135
|
+
#endif
|
136
|
+
|
137
|
+
/*
|
138
|
+
* For x86 ELF targets, add .note.gnu.property section for Intel CET in
|
139
|
+
* assembly sources when CET is enabled.
|
140
|
+
*
|
141
|
+
* Additionally, any function that may be called indirectly must begin
|
142
|
+
* with ZSTD_CET_ENDBRANCH.
|
143
|
+
*/
|
144
|
+
#if defined(__ELF__) && (defined(__x86_64__) || defined(__i386__)) \
|
145
|
+
&& defined(__has_include)
|
146
|
+
# if __has_include(<cet.h>)
|
147
|
+
# include <cet.h>
|
148
|
+
# define ZSTD_CET_ENDBRANCH _CET_ENDBR
|
149
|
+
# endif
|
150
|
+
#endif
|
151
|
+
|
152
|
+
#ifndef ZSTD_CET_ENDBRANCH
|
153
|
+
# define ZSTD_CET_ENDBRANCH
|
154
|
+
#endif
|
155
|
+
|
156
|
+
#endif /* ZSTD_PORTABILITY_MACROS_H */
|
@@ -2,12 +2,13 @@
|
|
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
|
/**
|
@@ -22,8 +23,7 @@ int g_ZSTD_threading_useless_symbol;
|
|
22
23
|
#if defined(ZSTD_MULTITHREAD) && defined(_WIN32)
|
23
24
|
|
24
25
|
/**
|
25
|
-
* Windows minimalist Pthread Wrapper
|
26
|
-
* http://www.cse.wustl.edu/~schmidt/win32-cv-1.html
|
26
|
+
* Windows minimalist Pthread Wrapper
|
27
27
|
*/
|
28
28
|
|
29
29
|
|
@@ -34,37 +34,92 @@ int g_ZSTD_threading_useless_symbol;
|
|
34
34
|
|
35
35
|
/* === Implementation === */
|
36
36
|
|
37
|
+
typedef struct {
|
38
|
+
void* (*start_routine)(void*);
|
39
|
+
void* arg;
|
40
|
+
int initialized;
|
41
|
+
ZSTD_pthread_cond_t initialized_cond;
|
42
|
+
ZSTD_pthread_mutex_t initialized_mutex;
|
43
|
+
} ZSTD_thread_params_t;
|
44
|
+
|
37
45
|
static unsigned __stdcall worker(void *arg)
|
38
46
|
{
|
39
|
-
|
40
|
-
|
47
|
+
void* (*start_routine)(void*);
|
48
|
+
void* thread_arg;
|
49
|
+
|
50
|
+
/* Initialized thread_arg and start_routine and signal main thread that we don't need it
|
51
|
+
* to wait any longer.
|
52
|
+
*/
|
53
|
+
{
|
54
|
+
ZSTD_thread_params_t* thread_param = (ZSTD_thread_params_t*)arg;
|
55
|
+
thread_arg = thread_param->arg;
|
56
|
+
start_routine = thread_param->start_routine;
|
57
|
+
|
58
|
+
/* Signal main thread that we are running and do not depend on its memory anymore */
|
59
|
+
ZSTD_pthread_mutex_lock(&thread_param->initialized_mutex);
|
60
|
+
thread_param->initialized = 1;
|
61
|
+
ZSTD_pthread_cond_signal(&thread_param->initialized_cond);
|
62
|
+
ZSTD_pthread_mutex_unlock(&thread_param->initialized_mutex);
|
63
|
+
}
|
64
|
+
|
65
|
+
start_routine(thread_arg);
|
66
|
+
|
41
67
|
return 0;
|
42
68
|
}
|
43
69
|
|
44
70
|
int ZSTD_pthread_create(ZSTD_pthread_t* thread, const void* unused,
|
45
71
|
void* (*start_routine) (void*), void* arg)
|
46
72
|
{
|
73
|
+
ZSTD_thread_params_t thread_param;
|
47
74
|
(void)unused;
|
48
|
-
thread->arg = arg;
|
49
|
-
thread->start_routine = start_routine;
|
50
|
-
thread->handle = (HANDLE) _beginthreadex(NULL, 0, worker, thread, 0, NULL);
|
51
75
|
|
52
|
-
|
76
|
+
thread_param.start_routine = start_routine;
|
77
|
+
thread_param.arg = arg;
|
78
|
+
thread_param.initialized = 0;
|
79
|
+
*thread = NULL;
|
80
|
+
|
81
|
+
/* Setup thread initialization synchronization */
|
82
|
+
if(ZSTD_pthread_cond_init(&thread_param.initialized_cond, NULL)) {
|
83
|
+
/* Should never happen on Windows */
|
84
|
+
return -1;
|
85
|
+
}
|
86
|
+
if(ZSTD_pthread_mutex_init(&thread_param.initialized_mutex, NULL)) {
|
87
|
+
/* Should never happen on Windows */
|
88
|
+
ZSTD_pthread_cond_destroy(&thread_param.initialized_cond);
|
89
|
+
return -1;
|
90
|
+
}
|
91
|
+
|
92
|
+
/* Spawn thread */
|
93
|
+
*thread = (HANDLE)_beginthreadex(NULL, 0, worker, &thread_param, 0, NULL);
|
94
|
+
if (!thread) {
|
95
|
+
ZSTD_pthread_mutex_destroy(&thread_param.initialized_mutex);
|
96
|
+
ZSTD_pthread_cond_destroy(&thread_param.initialized_cond);
|
53
97
|
return errno;
|
54
|
-
|
55
|
-
|
98
|
+
}
|
99
|
+
|
100
|
+
/* Wait for thread to be initialized */
|
101
|
+
ZSTD_pthread_mutex_lock(&thread_param.initialized_mutex);
|
102
|
+
while(!thread_param.initialized) {
|
103
|
+
ZSTD_pthread_cond_wait(&thread_param.initialized_cond, &thread_param.initialized_mutex);
|
104
|
+
}
|
105
|
+
ZSTD_pthread_mutex_unlock(&thread_param.initialized_mutex);
|
106
|
+
ZSTD_pthread_mutex_destroy(&thread_param.initialized_mutex);
|
107
|
+
ZSTD_pthread_cond_destroy(&thread_param.initialized_cond);
|
108
|
+
|
109
|
+
return 0;
|
56
110
|
}
|
57
111
|
|
58
|
-
int ZSTD_pthread_join(ZSTD_pthread_t thread
|
112
|
+
int ZSTD_pthread_join(ZSTD_pthread_t thread)
|
59
113
|
{
|
60
114
|
DWORD result;
|
61
115
|
|
62
|
-
if (!thread
|
116
|
+
if (!thread) return 0;
|
117
|
+
|
118
|
+
result = WaitForSingleObject(thread, INFINITE);
|
119
|
+
CloseHandle(thread);
|
63
120
|
|
64
|
-
result = WaitForSingleObject(thread.handle, INFINITE);
|
65
121
|
switch (result) {
|
66
122
|
case WAIT_OBJECT_0:
|
67
|
-
if (value_ptr) *value_ptr = thread.arg;
|
68
123
|
return 0;
|
69
124
|
case WAIT_ABANDONED:
|
70
125
|
return EINVAL;
|
@@ -77,11 +132,12 @@ int ZSTD_pthread_join(ZSTD_pthread_t thread, void **value_ptr)
|
|
77
132
|
|
78
133
|
#if defined(ZSTD_MULTITHREAD) && DEBUGLEVEL >= 1 && !defined(_WIN32)
|
79
134
|
|
80
|
-
#
|
135
|
+
#define ZSTD_DEPS_NEED_MALLOC
|
136
|
+
#include "zstd_deps.h"
|
81
137
|
|
82
138
|
int ZSTD_pthread_mutex_init(ZSTD_pthread_mutex_t* mutex, pthread_mutexattr_t const* attr)
|
83
139
|
{
|
84
|
-
*mutex = (pthread_mutex_t*)
|
140
|
+
*mutex = (pthread_mutex_t*)ZSTD_malloc(sizeof(pthread_mutex_t));
|
85
141
|
if (!*mutex)
|
86
142
|
return 1;
|
87
143
|
return pthread_mutex_init(*mutex, attr);
|
@@ -93,14 +149,14 @@ int ZSTD_pthread_mutex_destroy(ZSTD_pthread_mutex_t* mutex)
|
|
93
149
|
return 0;
|
94
150
|
{
|
95
151
|
int const ret = pthread_mutex_destroy(*mutex);
|
96
|
-
|
152
|
+
ZSTD_free(*mutex);
|
97
153
|
return ret;
|
98
154
|
}
|
99
155
|
}
|
100
156
|
|
101
157
|
int ZSTD_pthread_cond_init(ZSTD_pthread_cond_t* cond, pthread_condattr_t const* attr)
|
102
158
|
{
|
103
|
-
*cond = (pthread_cond_t*)
|
159
|
+
*cond = (pthread_cond_t*)ZSTD_malloc(sizeof(pthread_cond_t));
|
104
160
|
if (!*cond)
|
105
161
|
return 1;
|
106
162
|
return pthread_cond_init(*cond, attr);
|
@@ -112,7 +168,7 @@ int ZSTD_pthread_cond_destroy(ZSTD_pthread_cond_t* cond)
|
|
112
168
|
return 0;
|
113
169
|
{
|
114
170
|
int const ret = pthread_cond_destroy(*cond);
|
115
|
-
|
171
|
+
ZSTD_free(*cond);
|
116
172
|
return ret;
|
117
173
|
}
|
118
174
|
}
|
@@ -2,12 +2,13 @@
|
|
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
|
@@ -22,8 +23,7 @@ extern "C" {
|
|
22
23
|
#if defined(ZSTD_MULTITHREAD) && defined(_WIN32)
|
23
24
|
|
24
25
|
/**
|
25
|
-
* Windows minimalist Pthread Wrapper
|
26
|
-
* http://www.cse.wustl.edu/~schmidt/win32-cv-1.html
|
26
|
+
* Windows minimalist Pthread Wrapper
|
27
27
|
*/
|
28
28
|
#ifdef WINVER
|
29
29
|
# undef WINVER
|
@@ -61,16 +61,12 @@ extern "C" {
|
|
61
61
|
#define ZSTD_pthread_cond_broadcast(a) WakeAllConditionVariable((a))
|
62
62
|
|
63
63
|
/* ZSTD_pthread_create() and ZSTD_pthread_join() */
|
64
|
-
typedef
|
65
|
-
HANDLE handle;
|
66
|
-
void* (*start_routine)(void*);
|
67
|
-
void* arg;
|
68
|
-
} ZSTD_pthread_t;
|
64
|
+
typedef HANDLE ZSTD_pthread_t;
|
69
65
|
|
70
66
|
int ZSTD_pthread_create(ZSTD_pthread_t* thread, const void* unused,
|
71
67
|
void* (*start_routine) (void*), void* arg);
|
72
68
|
|
73
|
-
int ZSTD_pthread_join(ZSTD_pthread_t thread
|
69
|
+
int ZSTD_pthread_join(ZSTD_pthread_t thread);
|
74
70
|
|
75
71
|
/**
|
76
72
|
* add here more wrappers as required
|
@@ -98,7 +94,7 @@ int ZSTD_pthread_join(ZSTD_pthread_t thread, void** value_ptr);
|
|
98
94
|
|
99
95
|
#define ZSTD_pthread_t pthread_t
|
100
96
|
#define ZSTD_pthread_create(a, b, c, d) pthread_create((a), (b), (c), (d))
|
101
|
-
#define ZSTD_pthread_join(a
|
97
|
+
#define ZSTD_pthread_join(a) pthread_join((a),NULL)
|
102
98
|
|
103
99
|
#else /* DEBUGLEVEL >= 1 */
|
104
100
|
|
@@ -123,7 +119,7 @@ int ZSTD_pthread_cond_destroy(ZSTD_pthread_cond_t* cond);
|
|
123
119
|
|
124
120
|
#define ZSTD_pthread_t pthread_t
|
125
121
|
#define ZSTD_pthread_create(a, b, c, d) pthread_create((a), (b), (c), (d))
|
126
|
-
#define ZSTD_pthread_join(a
|
122
|
+
#define ZSTD_pthread_join(a) pthread_join((a),NULL)
|
127
123
|
|
128
124
|
#endif
|
129
125
|
|