Mercurial > public > mercurial-scm > hg
comparison contrib/python-zstandard/zstd/common/compiler.h @ 42070:675775c33ab6
zstandard: vendor python-zstandard 0.11
The upstream source distribution from PyPI was extracted. Unwanted
files were removed.
The clang-format ignore list was updated to reflect the new source
of files.
The project contains a vendored copy of zstandard 1.3.8. The old
version was 1.3.6. This should result in some minor performance wins.
test-check-py3-compat.t was updated to reflect now-passing tests on
Python 3.8.
Some HTTP tests were updated to reflect new zstd compression output.
# no-check-commit because 3rd party code has different style guidelines
Differential Revision: https://phab.mercurial-scm.org/D6199
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Thu, 04 Apr 2019 17:34:43 -0700 |
parents | 73fef626dae3 |
children | 69de49c4e39c |
comparison
equal
deleted
inserted
replaced
42069:668eff08387f | 42070:675775c33ab6 |
---|---|
13 | 13 |
14 /*-******************************************************* | 14 /*-******************************************************* |
15 * Compiler specifics | 15 * Compiler specifics |
16 *********************************************************/ | 16 *********************************************************/ |
17 /* force inlining */ | 17 /* force inlining */ |
18 | |
19 #if !defined(ZSTD_NO_INLINE) | |
18 #if defined (__GNUC__) || defined(__cplusplus) || defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */ | 20 #if defined (__GNUC__) || defined(__cplusplus) || defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */ |
19 # define INLINE_KEYWORD inline | 21 # define INLINE_KEYWORD inline |
20 #else | 22 #else |
21 # define INLINE_KEYWORD | 23 # define INLINE_KEYWORD |
22 #endif | 24 #endif |
25 # define FORCE_INLINE_ATTR __attribute__((always_inline)) | 27 # define FORCE_INLINE_ATTR __attribute__((always_inline)) |
26 #elif defined(_MSC_VER) | 28 #elif defined(_MSC_VER) |
27 # define FORCE_INLINE_ATTR __forceinline | 29 # define FORCE_INLINE_ATTR __forceinline |
28 #else | 30 #else |
29 # define FORCE_INLINE_ATTR | 31 # define FORCE_INLINE_ATTR |
32 #endif | |
33 | |
34 #else | |
35 | |
36 #define INLINE_KEYWORD | |
37 #define FORCE_INLINE_ATTR | |
38 | |
30 #endif | 39 #endif |
31 | 40 |
32 /** | 41 /** |
33 * FORCE_INLINE_TEMPLATE is used to define C "templates", which take constant | 42 * FORCE_INLINE_TEMPLATE is used to define C "templates", which take constant |
34 * parameters. They must be inlined for the compiler to elimininate the constant | 43 * parameters. They must be inlined for the compiler to elimininate the constant |
87 # define DYNAMIC_BMI2 0 | 96 # define DYNAMIC_BMI2 0 |
88 #endif | 97 #endif |
89 #endif | 98 #endif |
90 | 99 |
91 /* prefetch | 100 /* prefetch |
92 * can be disabled, by declaring NO_PREFETCH macro | 101 * can be disabled, by declaring NO_PREFETCH build macro */ |
93 * All prefetch invocations use a single default locality 2, | |
94 * generating instruction prefetcht1, | |
95 * which, according to Intel, means "load data into L2 cache". | |
96 * This is a good enough "middle ground" for the time being, | |
97 * though in theory, it would be better to specialize locality depending on data being prefetched. | |
98 * Tests could not determine any sensible difference based on locality value. */ | |
99 #if defined(NO_PREFETCH) | 102 #if defined(NO_PREFETCH) |
100 # define PREFETCH(ptr) (void)(ptr) /* disabled */ | 103 # define PREFETCH_L1(ptr) (void)(ptr) /* disabled */ |
104 # define PREFETCH_L2(ptr) (void)(ptr) /* disabled */ | |
101 #else | 105 #else |
102 # if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_I86)) /* _mm_prefetch() is not defined outside of x86/x64 */ | 106 # if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_I86)) /* _mm_prefetch() is not defined outside of x86/x64 */ |
103 # include <mmintrin.h> /* https://msdn.microsoft.com/fr-fr/library/84szxsww(v=vs.90).aspx */ | 107 # include <mmintrin.h> /* https://msdn.microsoft.com/fr-fr/library/84szxsww(v=vs.90).aspx */ |
104 # define PREFETCH(ptr) _mm_prefetch((const char*)(ptr), _MM_HINT_T1) | 108 # define PREFETCH_L1(ptr) _mm_prefetch((const char*)(ptr), _MM_HINT_T0) |
109 # define PREFETCH_L2(ptr) _mm_prefetch((const char*)(ptr), _MM_HINT_T1) | |
105 # elif defined(__GNUC__) && ( (__GNUC__ >= 4) || ( (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1) ) ) | 110 # elif defined(__GNUC__) && ( (__GNUC__ >= 4) || ( (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1) ) ) |
106 # define PREFETCH(ptr) __builtin_prefetch((ptr), 0 /* rw==read */, 2 /* locality */) | 111 # define PREFETCH_L1(ptr) __builtin_prefetch((ptr), 0 /* rw==read */, 3 /* locality */) |
112 # define PREFETCH_L2(ptr) __builtin_prefetch((ptr), 0 /* rw==read */, 2 /* locality */) | |
107 # else | 113 # else |
108 # define PREFETCH(ptr) (void)(ptr) /* disabled */ | 114 # define PREFETCH_L1(ptr) (void)(ptr) /* disabled */ |
115 # define PREFETCH_L2(ptr) (void)(ptr) /* disabled */ | |
109 # endif | 116 # endif |
110 #endif /* NO_PREFETCH */ | 117 #endif /* NO_PREFETCH */ |
111 | 118 |
112 #define CACHELINE_SIZE 64 | 119 #define CACHELINE_SIZE 64 |
113 | 120 |
114 #define PREFETCH_AREA(p, s) { \ | 121 #define PREFETCH_AREA(p, s) { \ |
115 const char* const _ptr = (const char*)(p); \ | 122 const char* const _ptr = (const char*)(p); \ |
116 size_t const _size = (size_t)(s); \ | 123 size_t const _size = (size_t)(s); \ |
117 size_t _pos; \ | 124 size_t _pos; \ |
118 for (_pos=0; _pos<_size; _pos+=CACHELINE_SIZE) { \ | 125 for (_pos=0; _pos<_size; _pos+=CACHELINE_SIZE) { \ |
119 PREFETCH(_ptr + _pos); \ | 126 PREFETCH_L2(_ptr + _pos); \ |
120 } \ | 127 } \ |
121 } | 128 } |
122 | 129 |
123 /* disable warnings */ | 130 /* disable warnings */ |
124 #ifdef _MSC_VER /* Visual Studio */ | 131 #ifdef _MSC_VER /* Visual Studio */ |