diff options
author | Igor Pavlov <87184205+ip7z@users.noreply.github.com> | 2023-06-21 00:00:00 +0000 |
---|---|---|
committer | Igor Pavlov <87184205+ip7z@users.noreply.github.com> | 2023-12-17 14:59:19 +0500 |
commit | 5b39dc76f1bc82f941d5c800ab9f34407a06b53a (patch) | |
tree | fe5e17420300b715021a76328444088d32047963 /C/Compiler.h | |
parent | 93be7d4abfd4233228f58ee1fbbcd76d91be66a4 (diff) | |
download | 7zip-23.01.tar.gz 7zip-23.01.tar.bz2 7zip-23.01.zip |
23.0123.01
Diffstat (limited to 'C/Compiler.h')
-rw-r--r-- | C/Compiler.h | 162 |
1 files changed, 139 insertions, 23 deletions
diff --git a/C/Compiler.h b/C/Compiler.h index a9816fa..185a52d 100644 --- a/C/Compiler.h +++ b/C/Compiler.h | |||
@@ -1,12 +1,37 @@ | |||
1 | /* Compiler.h | 1 | /* Compiler.h : Compiler specific defines and pragmas |
2 | 2021-01-05 : Igor Pavlov : Public domain */ | 2 | 2023-04-02 : Igor Pavlov : Public domain */ |
3 | 3 | ||
4 | #ifndef __7Z_COMPILER_H | 4 | #ifndef ZIP7_INC_COMPILER_H |
5 | #define __7Z_COMPILER_H | 5 | #define ZIP7_INC_COMPILER_H |
6 | |||
7 | #if defined(__clang__) | ||
8 | # define Z7_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) | ||
9 | #endif | ||
10 | #if defined(__clang__) && defined(__apple_build_version__) | ||
11 | # define Z7_APPLE_CLANG_VERSION Z7_CLANG_VERSION | ||
12 | #elif defined(__clang__) | ||
13 | # define Z7_LLVM_CLANG_VERSION Z7_CLANG_VERSION | ||
14 | #elif defined(__GNUC__) | ||
15 | # define Z7_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) | ||
16 | #endif | ||
17 | |||
18 | #ifdef _MSC_VER | ||
19 | #if !defined(__clang__) && !defined(__GNUC__) | ||
20 | #define Z7_MSC_VER_ORIGINAL _MSC_VER | ||
21 | #endif | ||
22 | #endif | ||
23 | |||
24 | #if defined(__MINGW32__) || defined(__MINGW64__) | ||
25 | #define Z7_MINGW | ||
26 | #endif | ||
27 | |||
28 | // #pragma GCC diagnostic ignored "-Wunknown-pragmas" | ||
29 | |||
30 | #ifdef __clang__ | ||
31 | // padding size of '' with 4 bytes to alignment boundary | ||
32 | #pragma GCC diagnostic ignored "-Wpadded" | ||
33 | #endif | ||
6 | 34 | ||
7 | #ifdef __clang__ | ||
8 | #pragma clang diagnostic ignored "-Wunused-private-field" | ||
9 | #endif | ||
10 | 35 | ||
11 | #ifdef _MSC_VER | 36 | #ifdef _MSC_VER |
12 | 37 | ||
@@ -17,24 +42,115 @@ | |||
17 | #pragma warning(disable : 4214) // nonstandard extension used : bit field types other than int | 42 | #pragma warning(disable : 4214) // nonstandard extension used : bit field types other than int |
18 | #endif | 43 | #endif |
19 | 44 | ||
20 | #if _MSC_VER >= 1300 | 45 | #if defined(_MSC_VER) && _MSC_VER >= 1800 |
21 | #pragma warning(disable : 4996) // This function or variable may be unsafe | 46 | #pragma warning(disable : 4464) // relative include path contains '..' |
22 | #else | 47 | #endif |
23 | #pragma warning(disable : 4511) // copy constructor could not be generated | 48 | |
24 | #pragma warning(disable : 4512) // assignment operator could not be generated | 49 | // == 1200 : -O1 : for __forceinline |
25 | #pragma warning(disable : 4514) // unreferenced inline function has been removed | 50 | // >= 1900 : -O1 : for printf |
26 | #pragma warning(disable : 4702) // unreachable code | 51 | #pragma warning(disable : 4710) // function not inlined |
27 | #pragma warning(disable : 4710) // not inlined | 52 | |
28 | #pragma warning(disable : 4714) // function marked as __forceinline not inlined | 53 | #if _MSC_VER < 1900 |
29 | #pragma warning(disable : 4786) // identifier was truncated to '255' characters in the debug information | 54 | // winnt.h: 'Int64ShllMod32' |
30 | #endif | 55 | #pragma warning(disable : 4514) // unreferenced inline function has been removed |
56 | #endif | ||
57 | |||
58 | #if _MSC_VER < 1300 | ||
59 | // #pragma warning(disable : 4702) // unreachable code | ||
60 | // Bra.c : -O1: | ||
61 | #pragma warning(disable : 4714) // function marked as __forceinline not inlined | ||
62 | #endif | ||
63 | |||
64 | /* | ||
65 | #if _MSC_VER > 1400 && _MSC_VER <= 1900 | ||
66 | // strcat: This function or variable may be unsafe | ||
67 | // sysinfoapi.h: kit10: GetVersion was declared deprecated | ||
68 | #pragma warning(disable : 4996) | ||
69 | #endif | ||
70 | */ | ||
71 | |||
72 | #if _MSC_VER > 1200 | ||
73 | // -Wall warnings | ||
74 | |||
75 | #pragma warning(disable : 4711) // function selected for automatic inline expansion | ||
76 | #pragma warning(disable : 4820) // '2' bytes padding added after data member | ||
77 | |||
78 | #if _MSC_VER >= 1400 && _MSC_VER < 1920 | ||
79 | // 1400: string.h: _DBG_MEMCPY_INLINE_ | ||
80 | // 1600 - 191x : smmintrin.h __cplusplus' | ||
81 | // is not defined as a preprocessor macro, replacing with '0' for '#if/#elif' | ||
82 | #pragma warning(disable : 4668) | ||
83 | |||
84 | // 1400 - 1600 : WinDef.h : 'FARPROC' : | ||
85 | // 1900 - 191x : immintrin.h: _readfsbase_u32 | ||
86 | // no function prototype given : converting '()' to '(void)' | ||
87 | #pragma warning(disable : 4255) | ||
88 | #endif | ||
89 | |||
90 | #if _MSC_VER >= 1914 | ||
91 | // Compiler will insert Spectre mitigation for memory load if /Qspectre switch specified | ||
92 | #pragma warning(disable : 5045) | ||
93 | #endif | ||
94 | |||
95 | #endif // _MSC_VER > 1200 | ||
96 | #endif // _MSC_VER | ||
97 | |||
98 | |||
99 | #if defined(__clang__) && (__clang_major__ >= 4) | ||
100 | #define Z7_PRAGMA_OPT_DISABLE_LOOP_UNROLL_VECTORIZE \ | ||
101 | _Pragma("clang loop unroll(disable)") \ | ||
102 | _Pragma("clang loop vectorize(disable)") | ||
103 | #define Z7_ATTRIB_NO_VECTORIZE | ||
104 | #elif defined(__GNUC__) && (__GNUC__ >= 5) | ||
105 | #define Z7_ATTRIB_NO_VECTORIZE __attribute__((optimize("no-tree-vectorize"))) | ||
106 | // __attribute__((optimize("no-unroll-loops"))); | ||
107 | #define Z7_PRAGMA_OPT_DISABLE_LOOP_UNROLL_VECTORIZE | ||
108 | #elif defined(_MSC_VER) && (_MSC_VER >= 1920) | ||
109 | #define Z7_PRAGMA_OPT_DISABLE_LOOP_UNROLL_VECTORIZE \ | ||
110 | _Pragma("loop( no_vector )") | ||
111 | #define Z7_ATTRIB_NO_VECTORIZE | ||
112 | #else | ||
113 | #define Z7_PRAGMA_OPT_DISABLE_LOOP_UNROLL_VECTORIZE | ||
114 | #define Z7_ATTRIB_NO_VECTORIZE | ||
115 | #endif | ||
116 | |||
117 | #if defined(MY_CPU_X86_OR_AMD64) && ( \ | ||
118 | defined(__clang__) && (__clang_major__ >= 4) \ | ||
119 | || defined(__GNUC__) && (__GNUC__ >= 5)) | ||
120 | #define Z7_ATTRIB_NO_SSE __attribute__((__target__("no-sse"))) | ||
121 | #else | ||
122 | #define Z7_ATTRIB_NO_SSE | ||
123 | #endif | ||
124 | |||
125 | #define Z7_ATTRIB_NO_VECTOR \ | ||
126 | Z7_ATTRIB_NO_VECTORIZE \ | ||
127 | Z7_ATTRIB_NO_SSE | ||
128 | |||
129 | |||
130 | #if defined(__clang__) && (__clang_major__ >= 8) \ | ||
131 | || defined(__GNUC__) && (__GNUC__ >= 1000) \ | ||
132 | /* || defined(_MSC_VER) && (_MSC_VER >= 1920) */ | ||
133 | // GCC is not good for __builtin_expect() | ||
134 | #define Z7_LIKELY(x) (__builtin_expect((x), 1)) | ||
135 | #define Z7_UNLIKELY(x) (__builtin_expect((x), 0)) | ||
136 | // #define Z7_unlikely [[unlikely]] | ||
137 | // #define Z7_likely [[likely]] | ||
138 | #else | ||
139 | #define Z7_LIKELY(x) (x) | ||
140 | #define Z7_UNLIKELY(x) (x) | ||
141 | // #define Z7_likely | ||
142 | #endif | ||
31 | 143 | ||
32 | #ifdef __clang__ | ||
33 | #pragma clang diagnostic ignored "-Wdeprecated-declarations" | ||
34 | #pragma clang diagnostic ignored "-Wmicrosoft-exception-spec" | ||
35 | // #pragma clang diagnostic ignored "-Wreserved-id-macro" | ||
36 | #endif | ||
37 | 144 | ||
145 | #if (defined(Z7_CLANG_VERSION) && (Z7_CLANG_VERSION >= 36000)) | ||
146 | #define Z7_DIAGNOSCTIC_IGNORE_BEGIN_RESERVED_MACRO_IDENTIFIER \ | ||
147 | _Pragma("GCC diagnostic push") \ | ||
148 | _Pragma("GCC diagnostic ignored \"-Wreserved-macro-identifier\"") | ||
149 | #define Z7_DIAGNOSCTIC_IGNORE_END_RESERVED_MACRO_IDENTIFIER \ | ||
150 | _Pragma("GCC diagnostic pop") | ||
151 | #else | ||
152 | #define Z7_DIAGNOSCTIC_IGNORE_BEGIN_RESERVED_MACRO_IDENTIFIER | ||
153 | #define Z7_DIAGNOSCTIC_IGNORE_END_RESERVED_MACRO_IDENTIFIER | ||
38 | #endif | 154 | #endif |
39 | 155 | ||
40 | #define UNUSED_VAR(x) (void)x; | 156 | #define UNUSED_VAR(x) (void)x; |