extzstd 0.1 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/HISTORY.ja +5 -0
  3. data/README.md +5 -5
  4. data/contrib/zstd/CONTRIBUTING.md +42 -0
  5. data/contrib/zstd/LICENSE-examples +11 -0
  6. data/contrib/zstd/Makefile +315 -0
  7. data/contrib/zstd/NEWS +261 -0
  8. data/contrib/zstd/PATENTS +33 -0
  9. data/contrib/zstd/README.md +121 -41
  10. data/contrib/zstd/TESTING.md +44 -0
  11. data/contrib/zstd/appveyor.yml +178 -0
  12. data/contrib/zstd/circle.yml +75 -0
  13. data/contrib/zstd/lib/BUCK +186 -0
  14. data/contrib/zstd/lib/Makefile +163 -0
  15. data/contrib/zstd/lib/README.md +77 -0
  16. data/contrib/zstd/{common → lib/common}/bitstream.h +7 -4
  17. data/contrib/zstd/{common → lib/common}/entropy_common.c +19 -23
  18. data/contrib/zstd/{common → lib/common}/error_private.c +0 -0
  19. data/contrib/zstd/{common → lib/common}/error_private.h +0 -0
  20. data/contrib/zstd/{common → lib/common}/fse.h +94 -34
  21. data/contrib/zstd/{common → lib/common}/fse_decompress.c +18 -19
  22. data/contrib/zstd/{common → lib/common}/huf.h +52 -20
  23. data/contrib/zstd/{common → lib/common}/mem.h +17 -13
  24. data/contrib/zstd/lib/common/pool.c +194 -0
  25. data/contrib/zstd/lib/common/pool.h +56 -0
  26. data/contrib/zstd/lib/common/threading.c +80 -0
  27. data/contrib/zstd/lib/common/threading.h +104 -0
  28. data/contrib/zstd/{common → lib/common}/xxhash.c +3 -1
  29. data/contrib/zstd/{common → lib/common}/xxhash.h +11 -15
  30. data/contrib/zstd/{common → lib/common}/zstd_common.c +1 -11
  31. data/contrib/zstd/{common → lib/common}/zstd_errors.h +16 -2
  32. data/contrib/zstd/{common → lib/common}/zstd_internal.h +17 -1
  33. data/contrib/zstd/{compress → lib/compress}/fse_compress.c +138 -91
  34. data/contrib/zstd/{compress → lib/compress}/huf_compress.c +218 -67
  35. data/contrib/zstd/{compress → lib/compress}/zstd_compress.c +231 -108
  36. data/contrib/zstd/{compress → lib/compress}/zstd_opt.h +44 -25
  37. data/contrib/zstd/lib/compress/zstdmt_compress.c +739 -0
  38. data/contrib/zstd/lib/compress/zstdmt_compress.h +78 -0
  39. data/contrib/zstd/{decompress → lib/decompress}/huf_decompress.c +28 -23
  40. data/contrib/zstd/{decompress → lib/decompress}/zstd_decompress.c +814 -176
  41. data/contrib/zstd/{common → lib/deprecated}/zbuff.h +60 -39
  42. data/contrib/zstd/lib/deprecated/zbuff_common.c +26 -0
  43. data/contrib/zstd/lib/deprecated/zbuff_compress.c +145 -0
  44. data/contrib/zstd/lib/deprecated/zbuff_decompress.c +74 -0
  45. data/contrib/zstd/lib/dictBuilder/cover.c +1029 -0
  46. data/contrib/zstd/{dictBuilder → lib/dictBuilder}/divsufsort.c +0 -0
  47. data/contrib/zstd/{dictBuilder → lib/dictBuilder}/divsufsort.h +0 -0
  48. data/contrib/zstd/{dictBuilder → lib/dictBuilder}/zdict.c +68 -18
  49. data/contrib/zstd/lib/dictBuilder/zdict.h +201 -0
  50. data/contrib/zstd/{legacy → lib/legacy}/zstd_legacy.h +122 -7
  51. data/contrib/zstd/{legacy → lib/legacy}/zstd_v01.c +34 -3
  52. data/contrib/zstd/{legacy → lib/legacy}/zstd_v01.h +8 -0
  53. data/contrib/zstd/{legacy → lib/legacy}/zstd_v02.c +45 -12
  54. data/contrib/zstd/{legacy → lib/legacy}/zstd_v02.h +8 -0
  55. data/contrib/zstd/{legacy → lib/legacy}/zstd_v03.c +45 -12
  56. data/contrib/zstd/{legacy → lib/legacy}/zstd_v03.h +8 -0
  57. data/contrib/zstd/{legacy → lib/legacy}/zstd_v04.c +56 -33
  58. data/contrib/zstd/{legacy → lib/legacy}/zstd_v04.h +8 -0
  59. data/contrib/zstd/{legacy → lib/legacy}/zstd_v05.c +45 -18
  60. data/contrib/zstd/{legacy → lib/legacy}/zstd_v05.h +7 -0
  61. data/contrib/zstd/{legacy → lib/legacy}/zstd_v06.c +43 -16
  62. data/contrib/zstd/{legacy → lib/legacy}/zstd_v06.h +7 -0
  63. data/contrib/zstd/{legacy → lib/legacy}/zstd_v07.c +57 -23
  64. data/contrib/zstd/{legacy → lib/legacy}/zstd_v07.h +8 -0
  65. data/contrib/zstd/lib/libzstd.pc.in +14 -0
  66. data/contrib/zstd/{zstd.h → lib/zstd.h} +206 -71
  67. data/ext/depend +2 -0
  68. data/ext/extconf.rb +4 -4
  69. data/ext/extzstd.c +1 -1
  70. data/ext/zstd_common.c +5 -5
  71. data/ext/zstd_compress.c +3 -3
  72. data/ext/zstd_decompress.c +2 -2
  73. data/ext/zstd_dictbuilder.c +2 -2
  74. data/ext/zstd_legacy_v01.c +1 -1
  75. data/ext/zstd_legacy_v02.c +1 -1
  76. data/ext/zstd_legacy_v03.c +1 -1
  77. data/ext/zstd_legacy_v04.c +1 -1
  78. data/ext/zstd_legacy_v05.c +1 -1
  79. data/ext/zstd_legacy_v06.c +1 -1
  80. data/ext/zstd_legacy_v07.c +1 -1
  81. data/gemstub.rb +9 -5
  82. data/lib/extzstd/version.rb +1 -1
  83. metadata +73 -51
  84. data/contrib/zstd/compress/zbuff_compress.c +0 -319
  85. data/contrib/zstd/decompress/zbuff_decompress.c +0 -252
  86. data/contrib/zstd/dictBuilder/zdict.h +0 -111
@@ -0,0 +1,194 @@
1
+ /**
2
+ * Copyright (c) 2016-present, Facebook, Inc.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
8
+ */
9
+
10
+
11
+ /* ====== Dependencies ======= */
12
+ #include <stddef.h> /* size_t */
13
+ #include <stdlib.h> /* malloc, calloc, free */
14
+ #include "pool.h"
15
+
16
+ /* ====== Compiler specifics ====== */
17
+ #if defined(_MSC_VER)
18
+ # pragma warning(disable : 4204) /* disable: C4204: non-constant aggregate initializer */
19
+ #endif
20
+
21
+
22
+ #ifdef ZSTD_MULTITHREAD
23
+
24
+ #include "threading.h" /* pthread adaptation */
25
+
26
+ /* A job is a function and an opaque argument */
27
+ typedef struct POOL_job_s {
28
+ POOL_function function;
29
+ void *opaque;
30
+ } POOL_job;
31
+
32
+ struct POOL_ctx_s {
33
+ /* Keep track of the threads */
34
+ pthread_t *threads;
35
+ size_t numThreads;
36
+
37
+ /* The queue is a circular buffer */
38
+ POOL_job *queue;
39
+ size_t queueHead;
40
+ size_t queueTail;
41
+ size_t queueSize;
42
+ /* The mutex protects the queue */
43
+ pthread_mutex_t queueMutex;
44
+ /* Condition variable for pushers to wait on when the queue is full */
45
+ pthread_cond_t queuePushCond;
46
+ /* Condition variables for poppers to wait on when the queue is empty */
47
+ pthread_cond_t queuePopCond;
48
+ /* Indicates if the queue is shutting down */
49
+ int shutdown;
50
+ };
51
+
52
+ /* POOL_thread() :
53
+ Work thread for the thread pool.
54
+ Waits for jobs and executes them.
55
+ @returns : NULL on failure else non-null.
56
+ */
57
+ static void* POOL_thread(void* opaque) {
58
+ POOL_ctx* const ctx = (POOL_ctx*)opaque;
59
+ if (!ctx) { return NULL; }
60
+ for (;;) {
61
+ /* Lock the mutex and wait for a non-empty queue or until shutdown */
62
+ pthread_mutex_lock(&ctx->queueMutex);
63
+ while (ctx->queueHead == ctx->queueTail && !ctx->shutdown) {
64
+ pthread_cond_wait(&ctx->queuePopCond, &ctx->queueMutex);
65
+ }
66
+ /* empty => shutting down: so stop */
67
+ if (ctx->queueHead == ctx->queueTail) {
68
+ pthread_mutex_unlock(&ctx->queueMutex);
69
+ return opaque;
70
+ }
71
+ /* Pop a job off the queue */
72
+ { POOL_job const job = ctx->queue[ctx->queueHead];
73
+ ctx->queueHead = (ctx->queueHead + 1) % ctx->queueSize;
74
+ /* Unlock the mutex, signal a pusher, and run the job */
75
+ pthread_mutex_unlock(&ctx->queueMutex);
76
+ pthread_cond_signal(&ctx->queuePushCond);
77
+ job.function(job.opaque);
78
+ }
79
+ }
80
+ /* Unreachable */
81
+ }
82
+
83
+ POOL_ctx *POOL_create(size_t numThreads, size_t queueSize) {
84
+ POOL_ctx *ctx;
85
+ /* Check the parameters */
86
+ if (!numThreads || !queueSize) { return NULL; }
87
+ /* Allocate the context and zero initialize */
88
+ ctx = (POOL_ctx *)calloc(1, sizeof(POOL_ctx));
89
+ if (!ctx) { return NULL; }
90
+ /* Initialize the job queue.
91
+ * It needs one extra space since one space is wasted to differentiate empty
92
+ * and full queues.
93
+ */
94
+ ctx->queueSize = queueSize + 1;
95
+ ctx->queue = (POOL_job *)malloc(ctx->queueSize * sizeof(POOL_job));
96
+ ctx->queueHead = 0;
97
+ ctx->queueTail = 0;
98
+ pthread_mutex_init(&ctx->queueMutex, NULL);
99
+ pthread_cond_init(&ctx->queuePushCond, NULL);
100
+ pthread_cond_init(&ctx->queuePopCond, NULL);
101
+ ctx->shutdown = 0;
102
+ /* Allocate space for the thread handles */
103
+ ctx->threads = (pthread_t *)malloc(numThreads * sizeof(pthread_t));
104
+ ctx->numThreads = 0;
105
+ /* Check for errors */
106
+ if (!ctx->threads || !ctx->queue) { POOL_free(ctx); return NULL; }
107
+ /* Initialize the threads */
108
+ { size_t i;
109
+ for (i = 0; i < numThreads; ++i) {
110
+ if (pthread_create(&ctx->threads[i], NULL, &POOL_thread, ctx)) {
111
+ ctx->numThreads = i;
112
+ POOL_free(ctx);
113
+ return NULL;
114
+ } }
115
+ ctx->numThreads = numThreads;
116
+ }
117
+ return ctx;
118
+ }
119
+
120
+ /*! POOL_join() :
121
+ Shutdown the queue, wake any sleeping threads, and join all of the threads.
122
+ */
123
+ static void POOL_join(POOL_ctx *ctx) {
124
+ /* Shut down the queue */
125
+ pthread_mutex_lock(&ctx->queueMutex);
126
+ ctx->shutdown = 1;
127
+ pthread_mutex_unlock(&ctx->queueMutex);
128
+ /* Wake up sleeping threads */
129
+ pthread_cond_broadcast(&ctx->queuePushCond);
130
+ pthread_cond_broadcast(&ctx->queuePopCond);
131
+ /* Join all of the threads */
132
+ { size_t i;
133
+ for (i = 0; i < ctx->numThreads; ++i) {
134
+ pthread_join(ctx->threads[i], NULL);
135
+ } }
136
+ }
137
+
138
+ void POOL_free(POOL_ctx *ctx) {
139
+ if (!ctx) { return; }
140
+ POOL_join(ctx);
141
+ pthread_mutex_destroy(&ctx->queueMutex);
142
+ pthread_cond_destroy(&ctx->queuePushCond);
143
+ pthread_cond_destroy(&ctx->queuePopCond);
144
+ if (ctx->queue) free(ctx->queue);
145
+ if (ctx->threads) free(ctx->threads);
146
+ free(ctx);
147
+ }
148
+
149
+ void POOL_add(void *ctxVoid, POOL_function function, void *opaque) {
150
+ POOL_ctx *ctx = (POOL_ctx *)ctxVoid;
151
+ if (!ctx) { return; }
152
+
153
+ pthread_mutex_lock(&ctx->queueMutex);
154
+ { POOL_job const job = {function, opaque};
155
+ /* Wait until there is space in the queue for the new job */
156
+ size_t newTail = (ctx->queueTail + 1) % ctx->queueSize;
157
+ while (ctx->queueHead == newTail && !ctx->shutdown) {
158
+ pthread_cond_wait(&ctx->queuePushCond, &ctx->queueMutex);
159
+ newTail = (ctx->queueTail + 1) % ctx->queueSize;
160
+ }
161
+ /* The queue is still going => there is space */
162
+ if (!ctx->shutdown) {
163
+ ctx->queue[ctx->queueTail] = job;
164
+ ctx->queueTail = newTail;
165
+ }
166
+ }
167
+ pthread_mutex_unlock(&ctx->queueMutex);
168
+ pthread_cond_signal(&ctx->queuePopCond);
169
+ }
170
+
171
+ #else /* ZSTD_MULTITHREAD not defined */
172
+ /* No multi-threading support */
173
+
174
+ /* We don't need any data, but if it is empty malloc() might return NULL. */
175
+ struct POOL_ctx_s {
176
+ int data;
177
+ };
178
+
179
+ POOL_ctx *POOL_create(size_t numThreads, size_t queueSize) {
180
+ (void)numThreads;
181
+ (void)queueSize;
182
+ return (POOL_ctx *)malloc(sizeof(POOL_ctx));
183
+ }
184
+
185
+ void POOL_free(POOL_ctx *ctx) {
186
+ if (ctx) free(ctx);
187
+ }
188
+
189
+ void POOL_add(void *ctx, POOL_function function, void *opaque) {
190
+ (void)ctx;
191
+ function(opaque);
192
+ }
193
+
194
+ #endif /* ZSTD_MULTITHREAD */
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Copyright (c) 2016-present, Facebook, Inc.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
8
+ */
9
+ #ifndef POOL_H
10
+ #define POOL_H
11
+
12
+ #if defined (__cplusplus)
13
+ extern "C" {
14
+ #endif
15
+
16
+
17
+ #include <stddef.h> /* size_t */
18
+
19
+ typedef struct POOL_ctx_s POOL_ctx;
20
+
21
+ /*! POOL_create() :
22
+ Create a thread pool with at most `numThreads` threads.
23
+ `numThreads` must be at least 1.
24
+ The maximum number of queued jobs before blocking is `queueSize`.
25
+ `queueSize` must be at least 1.
26
+ @return : The POOL_ctx pointer on success else NULL.
27
+ */
28
+ POOL_ctx *POOL_create(size_t numThreads, size_t queueSize);
29
+
30
+ /*! POOL_free() :
31
+ Free a thread pool returned by POOL_create().
32
+ */
33
+ void POOL_free(POOL_ctx *ctx);
34
+
35
+ /*! POOL_function :
36
+ The function type that can be added to a thread pool.
37
+ */
38
+ typedef void (*POOL_function)(void *);
39
+ /*! POOL_add_function :
40
+ The function type for a generic thread pool add function.
41
+ */
42
+ typedef void (*POOL_add_function)(void *, POOL_function, void *);
43
+
44
+ /*! POOL_add() :
45
+ Add the job `function(opaque)` to the thread pool.
46
+ Possibly blocks until there is room in the queue.
47
+ Note : The function may be executed asynchronously, so `opaque` must live until the function has been completed.
48
+ */
49
+ void POOL_add(void *ctx, POOL_function function, void *opaque);
50
+
51
+
52
+ #if defined (__cplusplus)
53
+ }
54
+ #endif
55
+
56
+ #endif
@@ -0,0 +1,80 @@
1
+
2
+ /**
3
+ * Copyright (c) 2016 Tino Reichardt
4
+ * All rights reserved.
5
+ *
6
+ * This source code is licensed under the BSD-style license found in the
7
+ * LICENSE file in the root directory of this source tree. An additional grant
8
+ * of patent rights can be found in the PATENTS file in the same directory.
9
+ *
10
+ * You can contact the author at:
11
+ * - zstdmt source repository: https://github.com/mcmilk/zstdmt
12
+ */
13
+
14
+ /**
15
+ * This file will hold wrapper for systems, which do not support pthreads
16
+ */
17
+
18
+ /* When ZSTD_MULTITHREAD is not defined, this file would become an empty translation unit.
19
+ * Include some ISO C header code to prevent this and portably avoid related warnings.
20
+ * (Visual C++: C4206 / GCC: -Wpedantic / Clang: -Wempty-translation-unit)
21
+ */
22
+ #include <stddef.h>
23
+
24
+
25
+ #if defined(ZSTD_MULTITHREAD) && defined(_WIN32)
26
+
27
+ /**
28
+ * Windows minimalist Pthread Wrapper, based on :
29
+ * http://www.cse.wustl.edu/~schmidt/win32-cv-1.html
30
+ */
31
+
32
+
33
+ /* === Dependencies === */
34
+ #include <process.h>
35
+ #include <errno.h>
36
+ #include "threading.h"
37
+
38
+
39
+ /* === Implementation === */
40
+
41
+ static unsigned __stdcall worker(void *arg)
42
+ {
43
+ pthread_t* const thread = (pthread_t*) arg;
44
+ thread->arg = thread->start_routine(thread->arg);
45
+ return 0;
46
+ }
47
+
48
+ int pthread_create(pthread_t* thread, const void* unused,
49
+ void* (*start_routine) (void*), void* arg)
50
+ {
51
+ (void)unused;
52
+ thread->arg = arg;
53
+ thread->start_routine = start_routine;
54
+ thread->handle = (HANDLE) _beginthreadex(NULL, 0, worker, thread, 0, NULL);
55
+
56
+ if (!thread->handle)
57
+ return errno;
58
+ else
59
+ return 0;
60
+ }
61
+
62
+ int _pthread_join(pthread_t * thread, void **value_ptr)
63
+ {
64
+ DWORD result;
65
+
66
+ if (!thread->handle) return 0;
67
+
68
+ result = WaitForSingleObject(thread->handle, INFINITE);
69
+ switch (result) {
70
+ case WAIT_OBJECT_0:
71
+ if (value_ptr) *value_ptr = thread->arg;
72
+ return 0;
73
+ case WAIT_ABANDONED:
74
+ return EINVAL;
75
+ default:
76
+ return GetLastError();
77
+ }
78
+ }
79
+
80
+ #endif /* ZSTD_MULTITHREAD */
@@ -0,0 +1,104 @@
1
+
2
+ /**
3
+ * Copyright (c) 2016 Tino Reichardt
4
+ * All rights reserved.
5
+ *
6
+ * This source code is licensed under the BSD-style license found in the
7
+ * LICENSE file in the root directory of this source tree. An additional grant
8
+ * of patent rights can be found in the PATENTS file in the same directory.
9
+ *
10
+ * You can contact the author at:
11
+ * - zstdmt source repository: https://github.com/mcmilk/zstdmt
12
+ */
13
+
14
+ #ifndef THREADING_H_938743
15
+ #define THREADING_H_938743
16
+
17
+ #if defined (__cplusplus)
18
+ extern "C" {
19
+ #endif
20
+
21
+ #if defined(ZSTD_MULTITHREAD) && defined(_WIN32)
22
+
23
+ /**
24
+ * Windows minimalist Pthread Wrapper, based on :
25
+ * http://www.cse.wustl.edu/~schmidt/win32-cv-1.html
26
+ */
27
+ #ifdef WINVER
28
+ # undef WINVER
29
+ #endif
30
+ #define WINVER 0x0600
31
+
32
+ #ifdef _WIN32_WINNT
33
+ # undef _WIN32_WINNT
34
+ #endif
35
+ #define _WIN32_WINNT 0x0600
36
+
37
+ #ifndef WIN32_LEAN_AND_MEAN
38
+ # define WIN32_LEAN_AND_MEAN
39
+ #endif
40
+
41
+ #include <windows.h>
42
+
43
+ /* mutex */
44
+ #define pthread_mutex_t CRITICAL_SECTION
45
+ #define pthread_mutex_init(a,b) InitializeCriticalSection((a))
46
+ #define pthread_mutex_destroy(a) DeleteCriticalSection((a))
47
+ #define pthread_mutex_lock(a) EnterCriticalSection((a))
48
+ #define pthread_mutex_unlock(a) LeaveCriticalSection((a))
49
+
50
+ /* condition variable */
51
+ #define pthread_cond_t CONDITION_VARIABLE
52
+ #define pthread_cond_init(a, b) InitializeConditionVariable((a))
53
+ #define pthread_cond_destroy(a) /* No delete */
54
+ #define pthread_cond_wait(a, b) SleepConditionVariableCS((a), (b), INFINITE)
55
+ #define pthread_cond_signal(a) WakeConditionVariable((a))
56
+ #define pthread_cond_broadcast(a) WakeAllConditionVariable((a))
57
+
58
+ /* pthread_create() and pthread_join() */
59
+ typedef struct {
60
+ HANDLE handle;
61
+ void* (*start_routine)(void*);
62
+ void* arg;
63
+ } pthread_t;
64
+
65
+ int pthread_create(pthread_t* thread, const void* unused,
66
+ void* (*start_routine) (void*), void* arg);
67
+
68
+ #define pthread_join(a, b) _pthread_join(&(a), (b))
69
+ int _pthread_join(pthread_t* thread, void** value_ptr);
70
+
71
+ /**
72
+ * add here more wrappers as required
73
+ */
74
+
75
+
76
+ #elif defined(ZSTD_MULTITHREAD) /* posix assumed ; need a better detection method */
77
+ /* === POSIX Systems === */
78
+ # include <pthread.h>
79
+
80
+ #else /* ZSTD_MULTITHREAD not defined */
81
+ /* No multithreading support */
82
+
83
+ #define pthread_mutex_t int /* #define rather than typedef, as sometimes pthread support is implicit, resulting in duplicated symbols */
84
+ #define pthread_mutex_init(a,b)
85
+ #define pthread_mutex_destroy(a)
86
+ #define pthread_mutex_lock(a)
87
+ #define pthread_mutex_unlock(a)
88
+
89
+ #define pthread_cond_t int
90
+ #define pthread_cond_init(a,b)
91
+ #define pthread_cond_destroy(a)
92
+ #define pthread_cond_wait(a,b)
93
+ #define pthread_cond_signal(a)
94
+ #define pthread_cond_broadcast(a)
95
+
96
+ /* do not use pthread_t */
97
+
98
+ #endif /* ZSTD_MULTITHREAD */
99
+
100
+ #if defined (__cplusplus)
101
+ }
102
+ #endif
103
+
104
+ #endif /* THREADING_H_938743 */
@@ -104,7 +104,9 @@ static void XXH_free (void* p) { free(p); }
104
104
  #include <string.h>
105
105
  static void* XXH_memcpy(void* dest, const void* src, size_t size) { return memcpy(dest,src,size); }
106
106
 
107
- #define XXH_STATIC_LINKING_ONLY
107
+ #ifndef XXH_STATIC_LINKING_ONLY
108
+ # define XXH_STATIC_LINKING_ONLY
109
+ #endif
108
110
  #include "xxhash.h"
109
111
 
110
112
 
@@ -64,16 +64,12 @@ XXH64 13.8 GB/s 1.9 GB/s
64
64
  XXH32 6.8 GB/s 6.0 GB/s
65
65
  */
66
66
 
67
- #ifndef XXHASH_H_5627135585666179
68
- #define XXHASH_H_5627135585666179 1
69
-
70
67
  #if defined (__cplusplus)
71
68
  extern "C" {
72
69
  #endif
73
70
 
74
- #ifndef XXH_NAMESPACE
75
- # define XXH_NAMESPACE ZSTD_ /* Zstandard specific */
76
- #endif
71
+ #ifndef XXHASH_H_5627135585666179
72
+ #define XXHASH_H_5627135585666179 1
77
73
 
78
74
 
79
75
  /* ****************************
@@ -242,6 +238,11 @@ XXH_PUBLIC_API void XXH64_copyState(XXH64_state_t* restrict dst_state, const XXH
242
238
  /* **************************
243
239
  * Canonical representation
244
240
  ****************************/
241
+ /* Default result type for XXH functions are primitive unsigned 32 and 64 bits.
242
+ * The canonical representation uses human-readable write convention, aka big-endian (large digits first).
243
+ * These functions allow transformation of hash result into and from its canonical format.
244
+ * This way, hash values can be written into a file / memory, and remain comparable on different systems and programs.
245
+ */
245
246
  typedef struct { unsigned char digest[4]; } XXH32_canonical_t;
246
247
  typedef struct { unsigned char digest[8]; } XXH64_canonical_t;
247
248
 
@@ -251,14 +252,9 @@ XXH_PUBLIC_API void XXH64_canonicalFromHash(XXH64_canonical_t* dst, XXH64_hash_t
251
252
  XXH_PUBLIC_API XXH32_hash_t XXH32_hashFromCanonical(const XXH32_canonical_t* src);
252
253
  XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical(const XXH64_canonical_t* src);
253
254
 
254
- /* Default result type for XXH functions are primitive unsigned 32 and 64 bits.
255
- * The canonical representation uses human-readable write convention, aka big-endian (large digits first).
256
- * These functions allow transformation of hash result into and from its canonical format.
257
- * This way, hash values can be written into a file / memory, and remain comparable on different systems and programs.
258
- */
255
+ #endif /* XXHASH_H_5627135585666179 */
259
256
 
260
257
 
261
- #ifdef XXH_STATIC_LINKING_ONLY
262
258
 
263
259
  /* ================================================================================================
264
260
  This section contains definitions which are not guaranteed to remain stable.
@@ -266,6 +262,8 @@ XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical(const XXH64_canonical_t* src
266
262
  They shall only be used with static linking.
267
263
  Never use these definitions in association with dynamic linking !
268
264
  =================================================================================================== */
265
+ #if defined(XXH_STATIC_LINKING_ONLY) && !defined(XXH_STATIC_H_3543687687345)
266
+ #define XXH_STATIC_H_3543687687345
269
267
 
270
268
  /* These definitions are only meant to allow allocation of XXH state
271
269
  statically, on stack, or in a struct for example.
@@ -299,11 +297,9 @@ XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical(const XXH64_canonical_t* src
299
297
  # include "xxhash.c" /* include xxhash functions as `static`, for inlining */
300
298
  # endif
301
299
 
302
- #endif /* XXH_STATIC_LINKING_ONLY */
300
+ #endif /* XXH_STATIC_LINKING_ONLY && XXH_STATIC_H_3543687687345 */
303
301
 
304
302
 
305
303
  #if defined (__cplusplus)
306
304
  }
307
305
  #endif
308
-
309
- #endif /* XXHASH_H_5627135585666179 */
@@ -16,7 +16,6 @@
16
16
  #include "error_private.h"
17
17
  #define ZSTD_STATIC_LINKING_ONLY
18
18
  #include "zstd.h" /* declaration of ZSTD_isError, ZSTD_getErrorName, ZSTD_getErrorCode, ZSTD_getErrorString, ZSTD_versionNumber */
19
- #include "zbuff.h" /* declaration of ZBUFF_isError, ZBUFF_getErrorName */
20
19
 
21
20
 
22
21
  /*-****************************************
@@ -42,16 +41,7 @@ ZSTD_ErrorCode ZSTD_getErrorCode(size_t code) { return ERR_getErrorCode(code); }
42
41
 
43
42
  /*! ZSTD_getErrorString() :
44
43
  * provides error code string from enum */
45
- const char* ZSTD_getErrorString(ZSTD_ErrorCode code) { return ERR_getErrorName(code); }
46
-
47
-
48
- /* **************************************************************
49
- * ZBUFF Error Management
50
- ****************************************************************/
51
- unsigned ZBUFF_isError(size_t errorCode) { return ERR_isError(errorCode); }
52
-
53
- const char* ZBUFF_getErrorName(size_t errorCode) { return ERR_getErrorName(errorCode); }
54
-
44
+ const char* ZSTD_getErrorString(ZSTD_ErrorCode code) { return ERR_getErrorString(code); }
55
45
 
56
46
 
57
47
  /*=**************************************************************
@@ -18,6 +18,20 @@ extern "C" {
18
18
  #include <stddef.h> /* size_t */
19
19
 
20
20
 
21
+ /* ===== ZSTDERRORLIB_API : control library symbols visibility ===== */
22
+ #if defined(__GNUC__) && (__GNUC__ >= 4)
23
+ # define ZSTDERRORLIB_VISIBILITY __attribute__ ((visibility ("default")))
24
+ #else
25
+ # define ZSTDERRORLIB_VISIBILITY
26
+ #endif
27
+ #if defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1)
28
+ # define ZSTDERRORLIB_API __declspec(dllexport) ZSTDERRORLIB_VISIBILITY
29
+ #elif defined(ZSTD_DLL_IMPORT) && (ZSTD_DLL_IMPORT==1)
30
+ # define ZSTDERRORLIB_API __declspec(dllimport) ZSTDERRORLIB_VISIBILITY /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/
31
+ #else
32
+ # define ZSTDERRORLIB_API ZSTDERRORLIB_VISIBILITY
33
+ #endif
34
+
21
35
  /*-****************************************
22
36
  * error codes list
23
37
  ******************************************/
@@ -49,8 +63,8 @@ typedef enum {
49
63
  /*! ZSTD_getErrorCode() :
50
64
  convert a `size_t` function result into a `ZSTD_ErrorCode` enum type,
51
65
  which can be used to compare directly with enum list published into "error_public.h" */
52
- ZSTD_ErrorCode ZSTD_getErrorCode(size_t functionResult);
53
- const char* ZSTD_getErrorString(ZSTD_ErrorCode code);
66
+ ZSTDERRORLIB_API ZSTD_ErrorCode ZSTD_getErrorCode(size_t functionResult);
67
+ ZSTDERRORLIB_API const char* ZSTD_getErrorString(ZSTD_ErrorCode code);
54
68
 
55
69
 
56
70
  #if defined (__cplusplus)
@@ -49,6 +49,10 @@
49
49
  #include "error_private.h"
50
50
  #define ZSTD_STATIC_LINKING_ONLY
51
51
  #include "zstd.h"
52
+ #ifndef XXH_STATIC_LINKING_ONLY
53
+ # define XXH_STATIC_LINKING_ONLY /* XXH64_state_t */
54
+ #endif
55
+ #include "xxhash.h" /* XXH_reset, update, digest */
52
56
 
53
57
 
54
58
  /*-*************************************
@@ -147,7 +151,7 @@ static void ZSTD_copy8(void* dst, const void* src) { memcpy(dst, src, 8); }
147
151
  /*! ZSTD_wildcopy() :
148
152
  * custom version of memcpy(), can copy up to 7 bytes too many (8 bytes if length==0) */
149
153
  #define WILDCOPY_OVERLENGTH 8
150
- MEM_STATIC void ZSTD_wildcopy(void* dst, const void* src, size_t length)
154
+ MEM_STATIC void ZSTD_wildcopy(void* dst, const void* src, ptrdiff_t length)
151
155
  {
152
156
  const BYTE* ip = (const BYTE*)src;
153
157
  BYTE* op = (BYTE*)dst;
@@ -222,6 +226,7 @@ typedef struct {
222
226
  U32 log2litSum;
223
227
  U32 log2offCodeSum;
224
228
  U32 factor;
229
+ U32 staticPrices;
225
230
  U32 cachedPrice;
226
231
  U32 cachedLitLength;
227
232
  const BYTE* cachedLiterals;
@@ -234,7 +239,9 @@ int ZSTD_isSkipFrame(ZSTD_DCtx* dctx);
234
239
  /* custom memory allocation functions */
235
240
  void* ZSTD_defaultAllocFunction(void* opaque, size_t size);
236
241
  void ZSTD_defaultFreeFunction(void* opaque, void* address);
242
+ #ifndef ZSTD_DLL_IMPORT
237
243
  static const ZSTD_customMem defaultCustomMem = { ZSTD_defaultAllocFunction, ZSTD_defaultFreeFunction, NULL };
244
+ #endif
238
245
  void* ZSTD_malloc(size_t size, ZSTD_customMem customMem);
239
246
  void ZSTD_free(void* ptr, ZSTD_customMem customMem);
240
247
 
@@ -264,4 +271,13 @@ MEM_STATIC U32 ZSTD_highbit32(U32 val)
264
271
  }
265
272
 
266
273
 
274
+ /* hidden functions */
275
+
276
+ /* ZSTD_invalidateRepCodes() :
277
+ * ensures next compression will not use repcodes from previous block.
278
+ * Note : only works with regular variant;
279
+ * do not use with extDict variant ! */
280
+ void ZSTD_invalidateRepCodes(ZSTD_CCtx* cctx);
281
+
282
+
267
283
  #endif /* ZSTD_CCOMMON_H_MODULE */