comparison contrib/python-zstandard/zstd/common/compiler.h @ 42937:69de49c4e39c

zstandard: vendor python-zstandard 0.12 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. test-repo-compengines.t was updated to reflect a change in behavior of the zstd library. The project contains a vendored copy of zstandard 1.4.3. The old version was 1.3.8. This should result in some minor performance wins. # no-check-commit because 3rd party code has different style guidelines Differential Revision: https://phab.mercurial-scm.org/D6858
author Gregory Szorc <gregory.szorc@gmail.com>
date Sun, 15 Sep 2019 20:04:00 -0700
parents 675775c33ab6
children de7838053207
comparison
equal deleted inserted replaced
42936:2da754532dd3 42937:69de49c4e39c
21 # define INLINE_KEYWORD inline 21 # define INLINE_KEYWORD inline
22 #else 22 #else
23 # define INLINE_KEYWORD 23 # define INLINE_KEYWORD
24 #endif 24 #endif
25 25
26 #if defined(__GNUC__) 26 #if defined(__GNUC__) || defined(__ICCARM__)
27 # define FORCE_INLINE_ATTR __attribute__((always_inline)) 27 # define FORCE_INLINE_ATTR __attribute__((always_inline))
28 #elif defined(_MSC_VER) 28 #elif defined(_MSC_VER)
29 # define FORCE_INLINE_ATTR __forceinline 29 # define FORCE_INLINE_ATTR __forceinline
30 #else 30 #else
31 # define FORCE_INLINE_ATTR 31 # define FORCE_INLINE_ATTR
38 38
39 #endif 39 #endif
40 40
41 /** 41 /**
42 * 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
43 * parameters. They must be inlined for the compiler to elimininate the constant 43 * parameters. They must be inlined for the compiler to eliminate the constant
44 * branches. 44 * branches.
45 */ 45 */
46 #define FORCE_INLINE_TEMPLATE static INLINE_KEYWORD FORCE_INLINE_ATTR 46 #define FORCE_INLINE_TEMPLATE static INLINE_KEYWORD FORCE_INLINE_ATTR
47 /** 47 /**
48 * HINT_INLINE is used to help the compiler generate better code. It is *not* 48 * HINT_INLINE is used to help the compiler generate better code. It is *not*
63 63
64 /* force no inlining */ 64 /* force no inlining */
65 #ifdef _MSC_VER 65 #ifdef _MSC_VER
66 # define FORCE_NOINLINE static __declspec(noinline) 66 # define FORCE_NOINLINE static __declspec(noinline)
67 #else 67 #else
68 # ifdef __GNUC__ 68 # if defined(__GNUC__) || defined(__ICCARM__)
69 # define FORCE_NOINLINE static __attribute__((__noinline__)) 69 # define FORCE_NOINLINE static __attribute__((__noinline__))
70 # else 70 # else
71 # define FORCE_NOINLINE static 71 # define FORCE_NOINLINE static
72 # endif 72 # endif
73 #endif 73 #endif
74 74
75 /* target attribute */ 75 /* target attribute */
76 #ifndef __has_attribute 76 #ifndef __has_attribute
77 #define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */ 77 #define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
78 #endif 78 #endif
79 #if defined(__GNUC__) 79 #if defined(__GNUC__) || defined(__ICCARM__)
80 # define TARGET_ATTRIBUTE(target) __attribute__((__target__(target))) 80 # define TARGET_ATTRIBUTE(target) __attribute__((__target__(target)))
81 #else 81 #else
82 # define TARGET_ATTRIBUTE(target) 82 # define TARGET_ATTRIBUTE(target)
83 #endif 83 #endif
84 84
125 for (_pos=0; _pos<_size; _pos+=CACHELINE_SIZE) { \ 125 for (_pos=0; _pos<_size; _pos+=CACHELINE_SIZE) { \
126 PREFETCH_L2(_ptr + _pos); \ 126 PREFETCH_L2(_ptr + _pos); \
127 } \ 127 } \
128 } 128 }
129 129
130 /* vectorization */
131 #if !defined(__clang__) && defined(__GNUC__)
132 # define DONT_VECTORIZE __attribute__((optimize("no-tree-vectorize")))
133 #else
134 # define DONT_VECTORIZE
135 #endif
136
130 /* disable warnings */ 137 /* disable warnings */
131 #ifdef _MSC_VER /* Visual Studio */ 138 #ifdef _MSC_VER /* Visual Studio */
132 # include <intrin.h> /* For Visual 2005 */ 139 # include <intrin.h> /* For Visual 2005 */
133 # pragma warning(disable : 4100) /* disable: C4100: unreferenced formal parameter */ 140 # pragma warning(disable : 4100) /* disable: C4100: unreferenced formal parameter */
134 # pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */ 141 # pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */