zstd-ruby 1.4.5.0 → 1.5.5.0
Sign up to get free protection for your applications and to get access to all the features.
- 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 +45 -62
- data/ext/zstdruby/libzstd/common/compiler.h +205 -22
- data/ext/zstdruby/libzstd/common/cpu.h +1 -3
- data/ext/zstdruby/libzstd/common/debug.c +1 -1
- data/ext/zstdruby/libzstd/common/debug.h +12 -19
- data/ext/zstdruby/libzstd/common/entropy_common.c +172 -48
- data/ext/zstdruby/libzstd/common/error_private.c +10 -2
- data/ext/zstdruby/libzstd/common/error_private.h +82 -3
- data/ext/zstdruby/libzstd/common/fse.h +37 -86
- data/ext/zstdruby/libzstd/common/fse_decompress.c +117 -92
- data/ext/zstdruby/libzstd/common/huf.h +99 -166
- 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 +10 -4
- data/ext/zstdruby/libzstd/common/portability_macros.h +156 -0
- data/ext/zstdruby/libzstd/common/threading.c +74 -19
- data/ext/zstdruby/libzstd/common/threading.h +5 -10
- data/ext/zstdruby/libzstd/common/xxhash.c +7 -847
- data/ext/zstdruby/libzstd/common/xxhash.h +5568 -167
- 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 +132 -187
- 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 +83 -157
- data/ext/zstdruby/libzstd/compress/hist.c +27 -29
- data/ext/zstdruby/libzstd/compress/hist.h +2 -2
- data/ext/zstdruby/libzstd/compress/huf_compress.c +916 -279
- data/ext/zstdruby/libzstd/compress/zstd_compress.c +3773 -1019
- data/ext/zstdruby/libzstd/compress/zstd_compress_internal.h +610 -203
- data/ext/zstdruby/libzstd/compress/zstd_compress_literals.c +119 -42
- data/ext/zstdruby/libzstd/compress/zstd_compress_literals.h +16 -6
- data/ext/zstdruby/libzstd/compress/zstd_compress_sequences.c +42 -19
- data/ext/zstdruby/libzstd/compress/zstd_compress_sequences.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstd_compress_superblock.c +49 -317
- data/ext/zstdruby/libzstd/compress/zstd_compress_superblock.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstd_cwksp.h +320 -103
- data/ext/zstdruby/libzstd/compress/zstd_double_fast.c +388 -151
- data/ext/zstdruby/libzstd/compress/zstd_double_fast.h +3 -2
- data/ext/zstdruby/libzstd/compress/zstd_fast.c +729 -265
- data/ext/zstdruby/libzstd/compress/zstd_fast.h +3 -2
- data/ext/zstdruby/libzstd/compress/zstd_lazy.c +1270 -251
- data/ext/zstdruby/libzstd/compress/zstd_lazy.h +61 -1
- data/ext/zstdruby/libzstd/compress/zstd_ldm.c +324 -219
- data/ext/zstdruby/libzstd/compress/zstd_ldm.h +9 -2
- data/ext/zstdruby/libzstd/compress/zstd_ldm_geartab.h +106 -0
- data/ext/zstdruby/libzstd/compress/zstd_opt.c +481 -209
- data/ext/zstdruby/libzstd/compress/zstd_opt.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstdmt_compress.c +181 -457
- data/ext/zstdruby/libzstd/compress/zstdmt_compress.h +34 -113
- data/ext/zstdruby/libzstd/decompress/huf_decompress.c +1199 -565
- data/ext/zstdruby/libzstd/decompress/huf_decompress_amd64.S +576 -0
- data/ext/zstdruby/libzstd/decompress/zstd_ddict.c +12 -12
- data/ext/zstdruby/libzstd/decompress/zstd_ddict.h +2 -2
- data/ext/zstdruby/libzstd/decompress/zstd_decompress.c +627 -157
- data/ext/zstdruby/libzstd/decompress/zstd_decompress_block.c +1086 -326
- data/ext/zstdruby/libzstd/decompress/zstd_decompress_block.h +19 -5
- data/ext/zstdruby/libzstd/decompress/zstd_decompress_internal.h +62 -13
- data/ext/zstdruby/libzstd/dictBuilder/cover.c +73 -52
- data/ext/zstdruby/libzstd/dictBuilder/cover.h +7 -6
- data/ext/zstdruby/libzstd/dictBuilder/divsufsort.c +1 -1
- data/ext/zstdruby/libzstd/dictBuilder/fastcover.c +44 -35
- data/ext/zstdruby/libzstd/dictBuilder/zdict.c +103 -111
- data/ext/zstdruby/libzstd/{dictBuilder/zdict.h → zdict.h} +203 -34
- data/ext/zstdruby/libzstd/zstd.h +1217 -287
- data/ext/zstdruby/libzstd/{common/zstd_errors.h → zstd_errors.h} +28 -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 +19 -36
- 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 -354
- data/ext/zstdruby/libzstd/README.md +0 -179
- 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 -48
- 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 -2158
- data/ext/zstdruby/libzstd/legacy/zstd_v01.h +0 -94
- data/ext/zstdruby/libzstd/legacy/zstd_v02.c +0 -3518
- data/ext/zstdruby/libzstd/legacy/zstd_v02.h +0 -93
- data/ext/zstdruby/libzstd/legacy/zstd_v03.c +0 -3160
- data/ext/zstdruby/libzstd/legacy/zstd_v03.h +0 -93
- data/ext/zstdruby/libzstd/legacy/zstd_v04.c +0 -3647
- data/ext/zstdruby/libzstd/legacy/zstd_v04.h +0 -142
- data/ext/zstdruby/libzstd/legacy/zstd_v05.c +0 -4050
- data/ext/zstdruby/libzstd/legacy/zstd_v05.h +0 -162
- data/ext/zstdruby/libzstd/legacy/zstd_v06.c +0 -4154
- data/ext/zstdruby/libzstd/legacy/zstd_v06.h +0 -172
- data/ext/zstdruby/libzstd/legacy/zstd_v07.c +0 -4541
- 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 */
|
@@ -23,8 +23,7 @@ int g_ZSTD_threading_useless_symbol;
|
|
23
23
|
#if defined(ZSTD_MULTITHREAD) && defined(_WIN32)
|
24
24
|
|
25
25
|
/**
|
26
|
-
* Windows minimalist Pthread Wrapper
|
27
|
-
* http://www.cse.wustl.edu/~schmidt/win32-cv-1.html
|
26
|
+
* Windows minimalist Pthread Wrapper
|
28
27
|
*/
|
29
28
|
|
30
29
|
|
@@ -35,37 +34,92 @@ int g_ZSTD_threading_useless_symbol;
|
|
35
34
|
|
36
35
|
/* === Implementation === */
|
37
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
|
+
|
38
45
|
static unsigned __stdcall worker(void *arg)
|
39
46
|
{
|
40
|
-
|
41
|
-
|
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
|
+
|
42
67
|
return 0;
|
43
68
|
}
|
44
69
|
|
45
70
|
int ZSTD_pthread_create(ZSTD_pthread_t* thread, const void* unused,
|
46
71
|
void* (*start_routine) (void*), void* arg)
|
47
72
|
{
|
73
|
+
ZSTD_thread_params_t thread_param;
|
48
74
|
(void)unused;
|
49
|
-
thread->arg = arg;
|
50
|
-
thread->start_routine = start_routine;
|
51
|
-
thread->handle = (HANDLE) _beginthreadex(NULL, 0, worker, thread, 0, NULL);
|
52
75
|
|
53
|
-
|
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);
|
54
97
|
return errno;
|
55
|
-
|
56
|
-
|
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;
|
57
110
|
}
|
58
111
|
|
59
|
-
int ZSTD_pthread_join(ZSTD_pthread_t thread
|
112
|
+
int ZSTD_pthread_join(ZSTD_pthread_t thread)
|
60
113
|
{
|
61
114
|
DWORD result;
|
62
115
|
|
63
|
-
if (!thread
|
116
|
+
if (!thread) return 0;
|
117
|
+
|
118
|
+
result = WaitForSingleObject(thread, INFINITE);
|
119
|
+
CloseHandle(thread);
|
64
120
|
|
65
|
-
result = WaitForSingleObject(thread.handle, INFINITE);
|
66
121
|
switch (result) {
|
67
122
|
case WAIT_OBJECT_0:
|
68
|
-
if (value_ptr) *value_ptr = thread.arg;
|
69
123
|
return 0;
|
70
124
|
case WAIT_ABANDONED:
|
71
125
|
return EINVAL;
|
@@ -78,11 +132,12 @@ int ZSTD_pthread_join(ZSTD_pthread_t thread, void **value_ptr)
|
|
78
132
|
|
79
133
|
#if defined(ZSTD_MULTITHREAD) && DEBUGLEVEL >= 1 && !defined(_WIN32)
|
80
134
|
|
81
|
-
#
|
135
|
+
#define ZSTD_DEPS_NEED_MALLOC
|
136
|
+
#include "zstd_deps.h"
|
82
137
|
|
83
138
|
int ZSTD_pthread_mutex_init(ZSTD_pthread_mutex_t* mutex, pthread_mutexattr_t const* attr)
|
84
139
|
{
|
85
|
-
*mutex = (pthread_mutex_t*)
|
140
|
+
*mutex = (pthread_mutex_t*)ZSTD_malloc(sizeof(pthread_mutex_t));
|
86
141
|
if (!*mutex)
|
87
142
|
return 1;
|
88
143
|
return pthread_mutex_init(*mutex, attr);
|
@@ -94,14 +149,14 @@ int ZSTD_pthread_mutex_destroy(ZSTD_pthread_mutex_t* mutex)
|
|
94
149
|
return 0;
|
95
150
|
{
|
96
151
|
int const ret = pthread_mutex_destroy(*mutex);
|
97
|
-
|
152
|
+
ZSTD_free(*mutex);
|
98
153
|
return ret;
|
99
154
|
}
|
100
155
|
}
|
101
156
|
|
102
157
|
int ZSTD_pthread_cond_init(ZSTD_pthread_cond_t* cond, pthread_condattr_t const* attr)
|
103
158
|
{
|
104
|
-
*cond = (pthread_cond_t*)
|
159
|
+
*cond = (pthread_cond_t*)ZSTD_malloc(sizeof(pthread_cond_t));
|
105
160
|
if (!*cond)
|
106
161
|
return 1;
|
107
162
|
return pthread_cond_init(*cond, attr);
|
@@ -113,7 +168,7 @@ int ZSTD_pthread_cond_destroy(ZSTD_pthread_cond_t* cond)
|
|
113
168
|
return 0;
|
114
169
|
{
|
115
170
|
int const ret = pthread_cond_destroy(*cond);
|
116
|
-
|
171
|
+
ZSTD_free(*cond);
|
117
172
|
return ret;
|
118
173
|
}
|
119
174
|
}
|
@@ -23,8 +23,7 @@ extern "C" {
|
|
23
23
|
#if defined(ZSTD_MULTITHREAD) && defined(_WIN32)
|
24
24
|
|
25
25
|
/**
|
26
|
-
* Windows minimalist Pthread Wrapper
|
27
|
-
* http://www.cse.wustl.edu/~schmidt/win32-cv-1.html
|
26
|
+
* Windows minimalist Pthread Wrapper
|
28
27
|
*/
|
29
28
|
#ifdef WINVER
|
30
29
|
# undef WINVER
|
@@ -62,16 +61,12 @@ extern "C" {
|
|
62
61
|
#define ZSTD_pthread_cond_broadcast(a) WakeAllConditionVariable((a))
|
63
62
|
|
64
63
|
/* ZSTD_pthread_create() and ZSTD_pthread_join() */
|
65
|
-
typedef
|
66
|
-
HANDLE handle;
|
67
|
-
void* (*start_routine)(void*);
|
68
|
-
void* arg;
|
69
|
-
} ZSTD_pthread_t;
|
64
|
+
typedef HANDLE ZSTD_pthread_t;
|
70
65
|
|
71
66
|
int ZSTD_pthread_create(ZSTD_pthread_t* thread, const void* unused,
|
72
67
|
void* (*start_routine) (void*), void* arg);
|
73
68
|
|
74
|
-
int ZSTD_pthread_join(ZSTD_pthread_t thread
|
69
|
+
int ZSTD_pthread_join(ZSTD_pthread_t thread);
|
75
70
|
|
76
71
|
/**
|
77
72
|
* add here more wrappers as required
|
@@ -99,7 +94,7 @@ int ZSTD_pthread_join(ZSTD_pthread_t thread, void** value_ptr);
|
|
99
94
|
|
100
95
|
#define ZSTD_pthread_t pthread_t
|
101
96
|
#define ZSTD_pthread_create(a, b, c, d) pthread_create((a), (b), (c), (d))
|
102
|
-
#define ZSTD_pthread_join(a
|
97
|
+
#define ZSTD_pthread_join(a) pthread_join((a),NULL)
|
103
98
|
|
104
99
|
#else /* DEBUGLEVEL >= 1 */
|
105
100
|
|
@@ -124,7 +119,7 @@ int ZSTD_pthread_cond_destroy(ZSTD_pthread_cond_t* cond);
|
|
124
119
|
|
125
120
|
#define ZSTD_pthread_t pthread_t
|
126
121
|
#define ZSTD_pthread_create(a, b, c, d) pthread_create((a), (b), (c), (d))
|
127
|
-
#define ZSTD_pthread_join(a
|
122
|
+
#define ZSTD_pthread_join(a) pthread_join((a),NULL)
|
128
123
|
|
129
124
|
#endif
|
130
125
|
|