extzstd 0.0.3.CONCEPT → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. checksums.yaml +5 -5
  2. data/HISTORY.ja.md +39 -0
  3. data/LICENSE +6 -6
  4. data/README.md +26 -45
  5. data/contrib/zstd/CHANGELOG +555 -0
  6. data/contrib/zstd/CODE_OF_CONDUCT.md +5 -0
  7. data/contrib/zstd/CONTRIBUTING.md +392 -0
  8. data/contrib/zstd/COPYING +339 -0
  9. data/contrib/zstd/LICENSE +13 -9
  10. data/contrib/zstd/Makefile +414 -0
  11. data/contrib/zstd/README.md +170 -45
  12. data/contrib/zstd/TESTING.md +44 -0
  13. data/contrib/zstd/appveyor.yml +289 -0
  14. data/contrib/zstd/lib/BUCK +234 -0
  15. data/contrib/zstd/lib/Makefile +354 -0
  16. data/contrib/zstd/lib/README.md +179 -0
  17. data/contrib/zstd/{common → lib/common}/bitstream.h +170 -130
  18. data/contrib/zstd/lib/common/compiler.h +175 -0
  19. data/contrib/zstd/lib/common/cpu.h +215 -0
  20. data/contrib/zstd/lib/common/debug.c +24 -0
  21. data/contrib/zstd/lib/common/debug.h +114 -0
  22. data/contrib/zstd/{common → lib/common}/entropy_common.c +79 -94
  23. data/contrib/zstd/lib/common/error_private.c +55 -0
  24. data/contrib/zstd/lib/common/error_private.h +80 -0
  25. data/contrib/zstd/{common → lib/common}/fse.h +153 -93
  26. data/contrib/zstd/{common → lib/common}/fse_decompress.c +37 -82
  27. data/contrib/zstd/lib/common/huf.h +340 -0
  28. data/contrib/zstd/{common → lib/common}/mem.h +154 -78
  29. data/contrib/zstd/lib/common/pool.c +344 -0
  30. data/contrib/zstd/lib/common/pool.h +84 -0
  31. data/contrib/zstd/lib/common/threading.c +121 -0
  32. data/contrib/zstd/lib/common/threading.h +155 -0
  33. data/contrib/zstd/{common → lib/common}/xxhash.c +85 -75
  34. data/contrib/zstd/{common → lib/common}/xxhash.h +85 -73
  35. data/contrib/zstd/lib/common/zstd_common.c +83 -0
  36. data/contrib/zstd/lib/common/zstd_errors.h +94 -0
  37. data/contrib/zstd/lib/common/zstd_internal.h +447 -0
  38. data/contrib/zstd/{compress → lib/compress}/fse_compress.c +194 -303
  39. data/contrib/zstd/lib/compress/hist.c +183 -0
  40. data/contrib/zstd/lib/compress/hist.h +75 -0
  41. data/contrib/zstd/lib/compress/huf_compress.c +798 -0
  42. data/contrib/zstd/lib/compress/zstd_compress.c +4278 -0
  43. data/contrib/zstd/lib/compress/zstd_compress_internal.h +1125 -0
  44. data/contrib/zstd/lib/compress/zstd_compress_literals.c +158 -0
  45. data/contrib/zstd/lib/compress/zstd_compress_literals.h +29 -0
  46. data/contrib/zstd/lib/compress/zstd_compress_sequences.c +419 -0
  47. data/contrib/zstd/lib/compress/zstd_compress_sequences.h +54 -0
  48. data/contrib/zstd/lib/compress/zstd_compress_superblock.c +845 -0
  49. data/contrib/zstd/lib/compress/zstd_compress_superblock.h +32 -0
  50. data/contrib/zstd/lib/compress/zstd_cwksp.h +525 -0
  51. data/contrib/zstd/lib/compress/zstd_double_fast.c +521 -0
  52. data/contrib/zstd/lib/compress/zstd_double_fast.h +38 -0
  53. data/contrib/zstd/lib/compress/zstd_fast.c +496 -0
  54. data/contrib/zstd/lib/compress/zstd_fast.h +37 -0
  55. data/contrib/zstd/lib/compress/zstd_lazy.c +1138 -0
  56. data/contrib/zstd/lib/compress/zstd_lazy.h +67 -0
  57. data/contrib/zstd/lib/compress/zstd_ldm.c +619 -0
  58. data/contrib/zstd/lib/compress/zstd_ldm.h +110 -0
  59. data/contrib/zstd/lib/compress/zstd_opt.c +1200 -0
  60. data/contrib/zstd/lib/compress/zstd_opt.h +56 -0
  61. data/contrib/zstd/lib/compress/zstdmt_compress.c +2143 -0
  62. data/contrib/zstd/lib/compress/zstdmt_compress.h +192 -0
  63. data/contrib/zstd/lib/decompress/huf_decompress.c +1248 -0
  64. data/contrib/zstd/lib/decompress/zstd_ddict.c +244 -0
  65. data/contrib/zstd/lib/decompress/zstd_ddict.h +44 -0
  66. data/contrib/zstd/lib/decompress/zstd_decompress.c +1885 -0
  67. data/contrib/zstd/lib/decompress/zstd_decompress_block.c +1432 -0
  68. data/contrib/zstd/lib/decompress/zstd_decompress_block.h +59 -0
  69. data/contrib/zstd/lib/decompress/zstd_decompress_internal.h +189 -0
  70. data/contrib/zstd/{common → lib/deprecated}/zbuff.h +86 -69
  71. data/contrib/zstd/lib/deprecated/zbuff_common.c +26 -0
  72. data/contrib/zstd/lib/deprecated/zbuff_compress.c +147 -0
  73. data/contrib/zstd/lib/deprecated/zbuff_decompress.c +75 -0
  74. data/contrib/zstd/lib/dictBuilder/cover.c +1236 -0
  75. data/contrib/zstd/lib/dictBuilder/cover.h +157 -0
  76. data/contrib/zstd/{dictBuilder → lib/dictBuilder}/divsufsort.c +3 -3
  77. data/contrib/zstd/{dictBuilder → lib/dictBuilder}/divsufsort.h +5 -5
  78. data/contrib/zstd/lib/dictBuilder/fastcover.c +757 -0
  79. data/contrib/zstd/{dictBuilder → lib/dictBuilder}/zdict.c +437 -347
  80. data/contrib/zstd/lib/dictBuilder/zdict.h +305 -0
  81. data/contrib/zstd/lib/legacy/zstd_legacy.h +415 -0
  82. data/contrib/zstd/{legacy → lib/legacy}/zstd_v01.c +272 -292
  83. data/contrib/zstd/{legacy → lib/legacy}/zstd_v01.h +26 -32
  84. data/contrib/zstd/{legacy → lib/legacy}/zstd_v02.c +162 -392
  85. data/contrib/zstd/{legacy → lib/legacy}/zstd_v02.h +26 -32
  86. data/contrib/zstd/{legacy → lib/legacy}/zstd_v03.c +162 -391
  87. data/contrib/zstd/{legacy → lib/legacy}/zstd_v03.h +27 -33
  88. data/contrib/zstd/{legacy → lib/legacy}/zstd_v04.c +195 -604
  89. data/contrib/zstd/{legacy → lib/legacy}/zstd_v04.h +26 -32
  90. data/contrib/zstd/{legacy → lib/legacy}/zstd_v05.c +300 -575
  91. data/contrib/zstd/{legacy → lib/legacy}/zstd_v05.h +22 -31
  92. data/contrib/zstd/{legacy → lib/legacy}/zstd_v06.c +165 -592
  93. data/contrib/zstd/{legacy → lib/legacy}/zstd_v06.h +54 -67
  94. data/contrib/zstd/lib/legacy/zstd_v07.c +4541 -0
  95. data/contrib/zstd/lib/legacy/zstd_v07.h +187 -0
  96. data/contrib/zstd/lib/libzstd.pc.in +15 -0
  97. data/contrib/zstd/lib/zstd.h +2090 -0
  98. data/ext/depend +2 -0
  99. data/ext/extconf.rb +18 -5
  100. data/ext/extzstd.c +296 -214
  101. data/ext/extzstd.h +81 -36
  102. data/ext/extzstd_nogvls.h +0 -117
  103. data/ext/extzstd_stream.c +622 -0
  104. data/ext/libzstd_conf.h +8 -0
  105. data/ext/zstd_common.c +11 -0
  106. data/ext/zstd_compress.c +15 -0
  107. data/ext/zstd_decompress.c +6 -0
  108. data/ext/zstd_dictbuilder.c +10 -0
  109. data/ext/zstd_dictbuilder_fastcover.c +3 -0
  110. data/ext/zstd_legacy_v01.c +3 -1
  111. data/ext/zstd_legacy_v02.c +3 -1
  112. data/ext/zstd_legacy_v03.c +3 -1
  113. data/ext/zstd_legacy_v04.c +3 -1
  114. data/ext/zstd_legacy_v05.c +3 -1
  115. data/ext/zstd_legacy_v06.c +3 -1
  116. data/ext/zstd_legacy_v07.c +3 -0
  117. data/gemstub.rb +27 -21
  118. data/lib/extzstd.rb +82 -161
  119. data/lib/extzstd/version.rb +1 -1
  120. data/test/test_basic.rb +19 -6
  121. metadata +127 -59
  122. data/contrib/zstd/common/error_private.h +0 -125
  123. data/contrib/zstd/common/error_public.h +0 -77
  124. data/contrib/zstd/common/huf.h +0 -228
  125. data/contrib/zstd/common/zstd.h +0 -475
  126. data/contrib/zstd/common/zstd_common.c +0 -91
  127. data/contrib/zstd/common/zstd_internal.h +0 -238
  128. data/contrib/zstd/compress/huf_compress.c +0 -577
  129. data/contrib/zstd/compress/zbuff_compress.c +0 -327
  130. data/contrib/zstd/compress/zstd_compress.c +0 -3074
  131. data/contrib/zstd/compress/zstd_opt.h +0 -1046
  132. data/contrib/zstd/decompress/huf_decompress.c +0 -894
  133. data/contrib/zstd/decompress/zbuff_decompress.c +0 -294
  134. data/contrib/zstd/decompress/zstd_decompress.c +0 -1362
  135. data/contrib/zstd/dictBuilder/zdict.h +0 -113
  136. data/contrib/zstd/legacy/zstd_legacy.h +0 -140
  137. data/ext/extzstd_buffered.c +0 -265
  138. data/ext/zstd_amalgam.c +0 -18
@@ -0,0 +1,175 @@
1
+ /*
2
+ * Copyright (c) 2016-2020, Yann Collet, Facebook, Inc.
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_COMPILER_H
12
+ #define ZSTD_COMPILER_H
13
+
14
+ /*-*******************************************************
15
+ * Compiler specifics
16
+ *********************************************************/
17
+ /* force inlining */
18
+
19
+ #if !defined(ZSTD_NO_INLINE)
20
+ #if (defined(__GNUC__) && !defined(__STRICT_ANSI__)) || defined(__cplusplus) || defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */
21
+ # define INLINE_KEYWORD inline
22
+ #else
23
+ # define INLINE_KEYWORD
24
+ #endif
25
+
26
+ #if defined(__GNUC__) || defined(__ICCARM__)
27
+ # define FORCE_INLINE_ATTR __attribute__((always_inline))
28
+ #elif defined(_MSC_VER)
29
+ # define FORCE_INLINE_ATTR __forceinline
30
+ #else
31
+ # define FORCE_INLINE_ATTR
32
+ #endif
33
+
34
+ #else
35
+
36
+ #define INLINE_KEYWORD
37
+ #define FORCE_INLINE_ATTR
38
+
39
+ #endif
40
+
41
+ /**
42
+ * FORCE_INLINE_TEMPLATE is used to define C "templates", which take constant
43
+ * parameters. They must be inlined for the compiler to eliminate the constant
44
+ * branches.
45
+ */
46
+ #define FORCE_INLINE_TEMPLATE static INLINE_KEYWORD FORCE_INLINE_ATTR
47
+ /**
48
+ * HINT_INLINE is used to help the compiler generate better code. It is *not*
49
+ * used for "templates", so it can be tweaked based on the compilers
50
+ * performance.
51
+ *
52
+ * gcc-4.8 and gcc-4.9 have been shown to benefit from leaving off the
53
+ * always_inline attribute.
54
+ *
55
+ * clang up to 5.0.0 (trunk) benefit tremendously from the always_inline
56
+ * attribute.
57
+ */
58
+ #if !defined(__clang__) && defined(__GNUC__) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 8 && __GNUC__ < 5
59
+ # define HINT_INLINE static INLINE_KEYWORD
60
+ #else
61
+ # define HINT_INLINE static INLINE_KEYWORD FORCE_INLINE_ATTR
62
+ #endif
63
+
64
+ /* UNUSED_ATTR tells the compiler it is okay if the function is unused. */
65
+ #if defined(__GNUC__)
66
+ # define UNUSED_ATTR __attribute__((unused))
67
+ #else
68
+ # define UNUSED_ATTR
69
+ #endif
70
+
71
+ /* force no inlining */
72
+ #ifdef _MSC_VER
73
+ # define FORCE_NOINLINE static __declspec(noinline)
74
+ #else
75
+ # if defined(__GNUC__) || defined(__ICCARM__)
76
+ # define FORCE_NOINLINE static __attribute__((__noinline__))
77
+ # else
78
+ # define FORCE_NOINLINE static
79
+ # endif
80
+ #endif
81
+
82
+ /* target attribute */
83
+ #ifndef __has_attribute
84
+ #define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
85
+ #endif
86
+ #if defined(__GNUC__) || defined(__ICCARM__)
87
+ # define TARGET_ATTRIBUTE(target) __attribute__((__target__(target)))
88
+ #else
89
+ # define TARGET_ATTRIBUTE(target)
90
+ #endif
91
+
92
+ /* Enable runtime BMI2 dispatch based on the CPU.
93
+ * Enabled for clang & gcc >=4.8 on x86 when BMI2 isn't enabled by default.
94
+ */
95
+ #ifndef DYNAMIC_BMI2
96
+ #if ((defined(__clang__) && __has_attribute(__target__)) \
97
+ || (defined(__GNUC__) \
98
+ && (__GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)))) \
99
+ && (defined(__x86_64__) || defined(_M_X86)) \
100
+ && !defined(__BMI2__)
101
+ # define DYNAMIC_BMI2 1
102
+ #else
103
+ # define DYNAMIC_BMI2 0
104
+ #endif
105
+ #endif
106
+
107
+ /* prefetch
108
+ * can be disabled, by declaring NO_PREFETCH build macro */
109
+ #if defined(NO_PREFETCH)
110
+ # define PREFETCH_L1(ptr) (void)(ptr) /* disabled */
111
+ # define PREFETCH_L2(ptr) (void)(ptr) /* disabled */
112
+ #else
113
+ # if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_I86)) /* _mm_prefetch() is not defined outside of x86/x64 */
114
+ # include <mmintrin.h> /* https://msdn.microsoft.com/fr-fr/library/84szxsww(v=vs.90).aspx */
115
+ # define PREFETCH_L1(ptr) _mm_prefetch((const char*)(ptr), _MM_HINT_T0)
116
+ # define PREFETCH_L2(ptr) _mm_prefetch((const char*)(ptr), _MM_HINT_T1)
117
+ # elif defined(__aarch64__)
118
+ # define PREFETCH_L1(ptr) __asm__ __volatile__("prfm pldl1keep, %0" ::"Q"(*(ptr)))
119
+ # define PREFETCH_L2(ptr) __asm__ __volatile__("prfm pldl2keep, %0" ::"Q"(*(ptr)))
120
+ # elif defined(__GNUC__) && ( (__GNUC__ >= 4) || ( (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1) ) )
121
+ # define PREFETCH_L1(ptr) __builtin_prefetch((ptr), 0 /* rw==read */, 3 /* locality */)
122
+ # define PREFETCH_L2(ptr) __builtin_prefetch((ptr), 0 /* rw==read */, 2 /* locality */)
123
+ # else
124
+ # define PREFETCH_L1(ptr) (void)(ptr) /* disabled */
125
+ # define PREFETCH_L2(ptr) (void)(ptr) /* disabled */
126
+ # endif
127
+ #endif /* NO_PREFETCH */
128
+
129
+ #define CACHELINE_SIZE 64
130
+
131
+ #define PREFETCH_AREA(p, s) { \
132
+ const char* const _ptr = (const char*)(p); \
133
+ size_t const _size = (size_t)(s); \
134
+ size_t _pos; \
135
+ for (_pos=0; _pos<_size; _pos+=CACHELINE_SIZE) { \
136
+ PREFETCH_L2(_ptr + _pos); \
137
+ } \
138
+ }
139
+
140
+ /* vectorization
141
+ * older GCC (pre gcc-4.3 picked as the cutoff) uses a different syntax */
142
+ #if !defined(__INTEL_COMPILER) && !defined(__clang__) && defined(__GNUC__)
143
+ # if (__GNUC__ == 4 && __GNUC_MINOR__ > 3) || (__GNUC__ >= 5)
144
+ # define DONT_VECTORIZE __attribute__((optimize("no-tree-vectorize")))
145
+ # else
146
+ # define DONT_VECTORIZE _Pragma("GCC optimize(\"no-tree-vectorize\")")
147
+ # endif
148
+ #else
149
+ # define DONT_VECTORIZE
150
+ #endif
151
+
152
+ /* Tell the compiler that a branch is likely or unlikely.
153
+ * Only use these macros if it causes the compiler to generate better code.
154
+ * If you can remove a LIKELY/UNLIKELY annotation without speed changes in gcc
155
+ * and clang, please do.
156
+ */
157
+ #if defined(__GNUC__)
158
+ #define LIKELY(x) (__builtin_expect((x), 1))
159
+ #define UNLIKELY(x) (__builtin_expect((x), 0))
160
+ #else
161
+ #define LIKELY(x) (x)
162
+ #define UNLIKELY(x) (x)
163
+ #endif
164
+
165
+ /* disable warnings */
166
+ #ifdef _MSC_VER /* Visual Studio */
167
+ # include <intrin.h> /* For Visual 2005 */
168
+ # pragma warning(disable : 4100) /* disable: C4100: unreferenced formal parameter */
169
+ # pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */
170
+ # pragma warning(disable : 4204) /* disable: C4204: non-constant aggregate initializer */
171
+ # pragma warning(disable : 4214) /* disable: C4214: non-int bitfields */
172
+ # pragma warning(disable : 4324) /* disable: C4324: padded structure */
173
+ #endif
174
+
175
+ #endif /* ZSTD_COMPILER_H */
@@ -0,0 +1,215 @@
1
+ /*
2
+ * Copyright (c) 2018-2020, Facebook, Inc.
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_COMMON_CPU_H
12
+ #define ZSTD_COMMON_CPU_H
13
+
14
+ /**
15
+ * Implementation taken from folly/CpuId.h
16
+ * https://github.com/facebook/folly/blob/master/folly/CpuId.h
17
+ */
18
+
19
+ #include <string.h>
20
+
21
+ #include "mem.h"
22
+
23
+ #ifdef _MSC_VER
24
+ #include <intrin.h>
25
+ #endif
26
+
27
+ typedef struct {
28
+ U32 f1c;
29
+ U32 f1d;
30
+ U32 f7b;
31
+ U32 f7c;
32
+ } ZSTD_cpuid_t;
33
+
34
+ MEM_STATIC ZSTD_cpuid_t ZSTD_cpuid(void) {
35
+ U32 f1c = 0;
36
+ U32 f1d = 0;
37
+ U32 f7b = 0;
38
+ U32 f7c = 0;
39
+ #if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_IX86))
40
+ int reg[4];
41
+ __cpuid((int*)reg, 0);
42
+ {
43
+ int const n = reg[0];
44
+ if (n >= 1) {
45
+ __cpuid((int*)reg, 1);
46
+ f1c = (U32)reg[2];
47
+ f1d = (U32)reg[3];
48
+ }
49
+ if (n >= 7) {
50
+ __cpuidex((int*)reg, 7, 0);
51
+ f7b = (U32)reg[1];
52
+ f7c = (U32)reg[2];
53
+ }
54
+ }
55
+ #elif defined(__i386__) && defined(__PIC__) && !defined(__clang__) && defined(__GNUC__)
56
+ /* The following block like the normal cpuid branch below, but gcc
57
+ * reserves ebx for use of its pic register so we must specially
58
+ * handle the save and restore to avoid clobbering the register
59
+ */
60
+ U32 n;
61
+ __asm__(
62
+ "pushl %%ebx\n\t"
63
+ "cpuid\n\t"
64
+ "popl %%ebx\n\t"
65
+ : "=a"(n)
66
+ : "a"(0)
67
+ : "ecx", "edx");
68
+ if (n >= 1) {
69
+ U32 f1a;
70
+ __asm__(
71
+ "pushl %%ebx\n\t"
72
+ "cpuid\n\t"
73
+ "popl %%ebx\n\t"
74
+ : "=a"(f1a), "=c"(f1c), "=d"(f1d)
75
+ : "a"(1));
76
+ }
77
+ if (n >= 7) {
78
+ __asm__(
79
+ "pushl %%ebx\n\t"
80
+ "cpuid\n\t"
81
+ "movl %%ebx, %%eax\n\t"
82
+ "popl %%ebx"
83
+ : "=a"(f7b), "=c"(f7c)
84
+ : "a"(7), "c"(0)
85
+ : "edx");
86
+ }
87
+ #elif defined(__x86_64__) || defined(_M_X64) || defined(__i386__)
88
+ U32 n;
89
+ __asm__("cpuid" : "=a"(n) : "a"(0) : "ebx", "ecx", "edx");
90
+ if (n >= 1) {
91
+ U32 f1a;
92
+ __asm__("cpuid" : "=a"(f1a), "=c"(f1c), "=d"(f1d) : "a"(1) : "ebx");
93
+ }
94
+ if (n >= 7) {
95
+ U32 f7a;
96
+ __asm__("cpuid"
97
+ : "=a"(f7a), "=b"(f7b), "=c"(f7c)
98
+ : "a"(7), "c"(0)
99
+ : "edx");
100
+ }
101
+ #endif
102
+ {
103
+ ZSTD_cpuid_t cpuid;
104
+ cpuid.f1c = f1c;
105
+ cpuid.f1d = f1d;
106
+ cpuid.f7b = f7b;
107
+ cpuid.f7c = f7c;
108
+ return cpuid;
109
+ }
110
+ }
111
+
112
+ #define X(name, r, bit) \
113
+ MEM_STATIC int ZSTD_cpuid_##name(ZSTD_cpuid_t const cpuid) { \
114
+ return ((cpuid.r) & (1U << bit)) != 0; \
115
+ }
116
+
117
+ /* cpuid(1): Processor Info and Feature Bits. */
118
+ #define C(name, bit) X(name, f1c, bit)
119
+ C(sse3, 0)
120
+ C(pclmuldq, 1)
121
+ C(dtes64, 2)
122
+ C(monitor, 3)
123
+ C(dscpl, 4)
124
+ C(vmx, 5)
125
+ C(smx, 6)
126
+ C(eist, 7)
127
+ C(tm2, 8)
128
+ C(ssse3, 9)
129
+ C(cnxtid, 10)
130
+ C(fma, 12)
131
+ C(cx16, 13)
132
+ C(xtpr, 14)
133
+ C(pdcm, 15)
134
+ C(pcid, 17)
135
+ C(dca, 18)
136
+ C(sse41, 19)
137
+ C(sse42, 20)
138
+ C(x2apic, 21)
139
+ C(movbe, 22)
140
+ C(popcnt, 23)
141
+ C(tscdeadline, 24)
142
+ C(aes, 25)
143
+ C(xsave, 26)
144
+ C(osxsave, 27)
145
+ C(avx, 28)
146
+ C(f16c, 29)
147
+ C(rdrand, 30)
148
+ #undef C
149
+ #define D(name, bit) X(name, f1d, bit)
150
+ D(fpu, 0)
151
+ D(vme, 1)
152
+ D(de, 2)
153
+ D(pse, 3)
154
+ D(tsc, 4)
155
+ D(msr, 5)
156
+ D(pae, 6)
157
+ D(mce, 7)
158
+ D(cx8, 8)
159
+ D(apic, 9)
160
+ D(sep, 11)
161
+ D(mtrr, 12)
162
+ D(pge, 13)
163
+ D(mca, 14)
164
+ D(cmov, 15)
165
+ D(pat, 16)
166
+ D(pse36, 17)
167
+ D(psn, 18)
168
+ D(clfsh, 19)
169
+ D(ds, 21)
170
+ D(acpi, 22)
171
+ D(mmx, 23)
172
+ D(fxsr, 24)
173
+ D(sse, 25)
174
+ D(sse2, 26)
175
+ D(ss, 27)
176
+ D(htt, 28)
177
+ D(tm, 29)
178
+ D(pbe, 31)
179
+ #undef D
180
+
181
+ /* cpuid(7): Extended Features. */
182
+ #define B(name, bit) X(name, f7b, bit)
183
+ B(bmi1, 3)
184
+ B(hle, 4)
185
+ B(avx2, 5)
186
+ B(smep, 7)
187
+ B(bmi2, 8)
188
+ B(erms, 9)
189
+ B(invpcid, 10)
190
+ B(rtm, 11)
191
+ B(mpx, 14)
192
+ B(avx512f, 16)
193
+ B(avx512dq, 17)
194
+ B(rdseed, 18)
195
+ B(adx, 19)
196
+ B(smap, 20)
197
+ B(avx512ifma, 21)
198
+ B(pcommit, 22)
199
+ B(clflushopt, 23)
200
+ B(clwb, 24)
201
+ B(avx512pf, 26)
202
+ B(avx512er, 27)
203
+ B(avx512cd, 28)
204
+ B(sha, 29)
205
+ B(avx512bw, 30)
206
+ B(avx512vl, 31)
207
+ #undef B
208
+ #define C(name, bit) X(name, f7c, bit)
209
+ C(prefetchwt1, 0)
210
+ C(avx512vbmi, 1)
211
+ #undef C
212
+
213
+ #undef X
214
+
215
+ #endif /* ZSTD_COMMON_CPU_H */
@@ -0,0 +1,24 @@
1
+ /* ******************************************************************
2
+ * debug
3
+ * Part of FSE library
4
+ * Copyright (c) 2013-2020, Yann Collet, Facebook, Inc.
5
+ *
6
+ * You can contact the author at :
7
+ * - Source repository : https://github.com/Cyan4973/FiniteStateEntropy
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.
13
+ ****************************************************************** */
14
+
15
+
16
+ /*
17
+ * This module only hosts one global variable
18
+ * which can be used to dynamically influence the verbosity of traces,
19
+ * such as DEBUGLOG and RAWLOG
20
+ */
21
+
22
+ #include "debug.h"
23
+
24
+ int g_debuglevel = DEBUGLEVEL;
@@ -0,0 +1,114 @@
1
+ /* ******************************************************************
2
+ * debug
3
+ * Part of FSE library
4
+ * Copyright (c) 2013-2020, Yann Collet, Facebook, Inc.
5
+ *
6
+ * You can contact the author at :
7
+ * - Source repository : https://github.com/Cyan4973/FiniteStateEntropy
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.
13
+ ****************************************************************** */
14
+
15
+
16
+ /*
17
+ * The purpose of this header is to enable debug functions.
18
+ * They regroup assert(), DEBUGLOG() and RAWLOG() for run-time,
19
+ * and DEBUG_STATIC_ASSERT() for compile-time.
20
+ *
21
+ * By default, DEBUGLEVEL==0, which means run-time debug is disabled.
22
+ *
23
+ * Level 1 enables assert() only.
24
+ * Starting level 2, traces can be generated and pushed to stderr.
25
+ * The higher the level, the more verbose the traces.
26
+ *
27
+ * It's possible to dynamically adjust level using variable g_debug_level,
28
+ * which is only declared if DEBUGLEVEL>=2,
29
+ * and is a global variable, not multi-thread protected (use with care)
30
+ */
31
+
32
+ #ifndef DEBUG_H_12987983217
33
+ #define DEBUG_H_12987983217
34
+
35
+ #if defined (__cplusplus)
36
+ extern "C" {
37
+ #endif
38
+
39
+
40
+ /* static assert is triggered at compile time, leaving no runtime artefact.
41
+ * static assert only works with compile-time constants.
42
+ * Also, this variant can only be used inside a function. */
43
+ #define DEBUG_STATIC_ASSERT(c) (void)sizeof(char[(c) ? 1 : -1])
44
+
45
+
46
+ /* DEBUGLEVEL is expected to be defined externally,
47
+ * typically through compiler command line.
48
+ * Value must be a number. */
49
+ #ifndef DEBUGLEVEL
50
+ # define DEBUGLEVEL 0
51
+ #endif
52
+
53
+
54
+ /* DEBUGFILE can be defined externally,
55
+ * typically through compiler command line.
56
+ * note : currently useless.
57
+ * Value must be stderr or stdout */
58
+ #ifndef DEBUGFILE
59
+ # define DEBUGFILE stderr
60
+ #endif
61
+
62
+
63
+ /* recommended values for DEBUGLEVEL :
64
+ * 0 : release mode, no debug, all run-time checks disabled
65
+ * 1 : enables assert() only, no display
66
+ * 2 : reserved, for currently active debug path
67
+ * 3 : events once per object lifetime (CCtx, CDict, etc.)
68
+ * 4 : events once per frame
69
+ * 5 : events once per block
70
+ * 6 : events once per sequence (verbose)
71
+ * 7+: events at every position (*very* verbose)
72
+ *
73
+ * It's generally inconvenient to output traces > 5.
74
+ * In which case, it's possible to selectively trigger high verbosity levels
75
+ * by modifying g_debug_level.
76
+ */
77
+
78
+ #if (DEBUGLEVEL>=1)
79
+ # include <assert.h>
80
+ #else
81
+ # ifndef assert /* assert may be already defined, due to prior #include <assert.h> */
82
+ # define assert(condition) ((void)0) /* disable assert (default) */
83
+ # endif
84
+ #endif
85
+
86
+ #if (DEBUGLEVEL>=2)
87
+ # include <stdio.h>
88
+ extern int g_debuglevel; /* the variable is only declared,
89
+ it actually lives in debug.c,
90
+ and is shared by the whole process.
91
+ It's not thread-safe.
92
+ It's useful when enabling very verbose levels
93
+ on selective conditions (such as position in src) */
94
+
95
+ # define RAWLOG(l, ...) { \
96
+ if (l<=g_debuglevel) { \
97
+ fprintf(stderr, __VA_ARGS__); \
98
+ } }
99
+ # define DEBUGLOG(l, ...) { \
100
+ if (l<=g_debuglevel) { \
101
+ fprintf(stderr, __FILE__ ": " __VA_ARGS__); \
102
+ fprintf(stderr, " \n"); \
103
+ } }
104
+ #else
105
+ # define RAWLOG(l, ...) {} /* disabled */
106
+ # define DEBUGLOG(l, ...) {} /* disabled */
107
+ #endif
108
+
109
+
110
+ #if defined (__cplusplus)
111
+ }
112
+ #endif
113
+
114
+ #endif /* DEBUG_H_12987983217 */