/src/upx/src/util/cxxlib.h
Line | Count | Source |
1 | | /* cxxlib.h -- C++ support library |
2 | | |
3 | | This file is part of the UPX executable compressor. |
4 | | |
5 | | Copyright (C) Markus Franz Xaver Johannes Oberhumer |
6 | | All Rights Reserved. |
7 | | |
8 | | UPX and the UCL library are free software; you can redistribute them |
9 | | and/or modify them under the terms of the GNU General Public License as |
10 | | published by the Free Software Foundation; either version 2 of |
11 | | the License, or (at your option) any later version. |
12 | | |
13 | | This program is distributed in the hope that it will be useful, |
14 | | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | | GNU General Public License for more details. |
17 | | |
18 | | You should have received a copy of the GNU General Public License |
19 | | along with this program; see the file COPYING. |
20 | | If not, write to the Free Software Foundation, Inc., |
21 | | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
22 | | |
23 | | Markus F.X.J. Oberhumer |
24 | | <markus@oberhumer.com> |
25 | | */ |
26 | | |
27 | | #pragma once |
28 | | |
29 | | // #include <atomic> |
30 | | // #include <cstddef> |
31 | | // #include <new> |
32 | | // #include <type_traits> |
33 | | |
34 | | namespace upx { |
35 | | |
36 | | /************************************************************************* |
37 | | // compile_time |
38 | | **************************************************************************/ |
39 | | |
40 | | namespace compile_time { |
41 | | |
42 | 0 | constexpr std::size_t string_len(const char *a) noexcept { |
43 | 0 | return *a == '\0' ? 0 : 1 + string_len(a + 1); |
44 | 0 | } |
45 | 0 | constexpr bool string_eq(const char *a, const char *b) noexcept { |
46 | 0 | return *a == *b && (*a == '\0' || string_eq(a + 1, b + 1)); |
47 | 0 | } |
48 | 0 | constexpr bool string_lt(const char *a, const char *b) noexcept { |
49 | 0 | return (uchar) *a < (uchar) *b || (*a != '\0' && *a == *b && string_lt(a + 1, b + 1)); |
50 | 0 | } |
51 | 0 | forceinline constexpr bool string_ne(const char *a, const char *b) noexcept { |
52 | 0 | return !string_eq(a, b); |
53 | 0 | } |
54 | 0 | forceinline constexpr bool string_gt(const char *a, const char *b) noexcept { |
55 | 0 | return string_lt(b, a); |
56 | 0 | } |
57 | 0 | forceinline constexpr bool string_le(const char *a, const char *b) noexcept { |
58 | 0 | return !string_lt(b, a); |
59 | 0 | } |
60 | 0 | forceinline constexpr bool string_ge(const char *a, const char *b) noexcept { |
61 | 0 | return !string_lt(a, b); |
62 | 0 | } |
63 | | |
64 | 0 | constexpr bool mem_eq(const char *a, const char *b, std::size_t n) noexcept { |
65 | 0 | return n == 0 || (*a == *b && mem_eq(a + 1, b + 1, n - 1)); |
66 | 0 | } |
67 | 188k | constexpr bool mem_eq(const unsigned char *a, const unsigned char *b, std::size_t n) noexcept { |
68 | 188k | return n == 0 || (*a == *b && mem_eq(a + 1, b + 1, n - 1)); |
69 | 188k | } |
70 | 0 | constexpr bool mem_eq(const char *a, const unsigned char *b, std::size_t n) noexcept { |
71 | 0 | return n == 0 || ((uchar) *a == *b && mem_eq(a + 1, b + 1, n - 1)); |
72 | 0 | } |
73 | 0 | constexpr bool mem_eq(const unsigned char *a, const char *b, std::size_t n) noexcept { |
74 | 0 | return n == 0 || (*a == (uchar) *b && mem_eq(a + 1, b + 1, n - 1)); |
75 | 0 | } |
76 | | |
77 | 0 | constexpr void mem_set(char *p, char c, std::size_t n) noexcept { |
78 | 0 | (void) (n == 0 || (*p = c, mem_set(p + 1, c, n - 1), 0)); |
79 | 0 | } |
80 | 1.86M | constexpr void mem_set(unsigned char *p, unsigned char c, std::size_t n) noexcept { |
81 | 1.86M | (void) (n == 0 || (*p = c, mem_set(p + 1, c, n - 1), 0)); |
82 | 1.86M | } |
83 | 0 | forceinline constexpr void mem_clear(char *p, std::size_t n) noexcept { mem_set(p, (char) 0, n); } |
84 | 167k | forceinline constexpr void mem_clear(unsigned char *p, std::size_t n) noexcept { |
85 | 167k | mem_set(p, (unsigned char) 0, n); |
86 | 167k | } |
87 | | |
88 | 41.8k | forceinline constexpr upx_uint16_t bswap16(upx_uint16_t v) noexcept { |
89 | 41.8k | typedef unsigned U; |
90 | 41.8k | return (upx_uint16_t) ((((U) v >> 8) & 0xff) | (((U) v & 0xff) << 8)); |
91 | 41.8k | } |
92 | 125k | forceinline constexpr upx_uint32_t bswap32(upx_uint32_t v) noexcept { |
93 | 125k | typedef upx_uint32_t U; |
94 | 125k | return (upx_uint32_t) ((((U) v >> 24) & 0xff) | (((U) v >> 8) & 0xff00) | |
95 | 125k | (((U) v & 0xff00) << 8) | (((U) v & 0xff) << 24)); |
96 | 125k | } |
97 | 41.8k | forceinline constexpr upx_uint64_t bswap64(upx_uint64_t v) noexcept { |
98 | 41.8k | return (upx_uint64_t) (((upx_uint64_t) bswap32((upx_uint32_t) v) << 32) | |
99 | 41.8k | bswap32((upx_uint32_t) (v >> 32))); |
100 | 41.8k | } |
101 | | |
102 | 125k | forceinline constexpr upx_uint16_t get_be16(const byte *p) noexcept { |
103 | 125k | typedef unsigned U; |
104 | 125k | return (upx_uint16_t) (((U) p[0] << 8) | ((U) p[1] << 0)); |
105 | 125k | } |
106 | 469k | forceinline constexpr upx_uint32_t get_be24(const byte *p) noexcept { |
107 | 469k | typedef upx_uint32_t U; |
108 | 469k | return (upx_uint32_t) (((U) p[0] << 16) | ((U) p[1] << 8) | ((U) p[2] << 0)); |
109 | 469k | } |
110 | 125k | forceinline constexpr upx_uint32_t get_be32(const byte *p) noexcept { |
111 | 125k | typedef upx_uint32_t U; |
112 | 125k | return (upx_uint32_t) (((U) p[0] << 24) | ((U) p[1] << 16) | ((U) p[2] << 8) | ((U) p[3] << 0)); |
113 | 125k | } |
114 | 125k | forceinline constexpr upx_uint64_t get_be64(const byte *p) noexcept { |
115 | 125k | typedef upx_uint64_t U; |
116 | 125k | return (upx_uint64_t) (((U) p[0] << 56) | ((U) p[1] << 48) | ((U) p[2] << 40) | |
117 | 125k | ((U) p[3] << 32) | ((U) p[4] << 24) | ((U) p[5] << 16) | |
118 | 125k | ((U) p[6] << 8) | ((U) p[7] << 0)); |
119 | 125k | } |
120 | | |
121 | 62.7k | forceinline constexpr void set_be16(byte *p, upx_uint16_t v) noexcept { |
122 | 62.7k | p[0] = (byte) ((v >> 8) & 0xff); |
123 | 62.7k | p[1] = (byte) ((v >> 0) & 0xff); |
124 | 62.7k | } |
125 | 406k | forceinline constexpr void set_be24(byte *p, upx_uint32_t v) noexcept { |
126 | 406k | p[0] = (byte) ((v >> 16) & 0xff); |
127 | 406k | p[1] = (byte) ((v >> 8) & 0xff); |
128 | 406k | p[2] = (byte) ((v >> 0) & 0xff); |
129 | 406k | } |
130 | 62.7k | forceinline constexpr void set_be32(byte *p, upx_uint32_t v) noexcept { |
131 | 62.7k | p[0] = (byte) ((v >> 24) & 0xff); |
132 | 62.7k | p[1] = (byte) ((v >> 16) & 0xff); |
133 | 62.7k | p[2] = (byte) ((v >> 8) & 0xff); |
134 | 62.7k | p[3] = (byte) ((v >> 0) & 0xff); |
135 | 62.7k | } |
136 | 62.7k | forceinline constexpr void set_be64(byte *p, upx_uint64_t v) noexcept { |
137 | 62.7k | p[0] = (byte) ((v >> 56) & 0xff); |
138 | 62.7k | p[1] = (byte) ((v >> 48) & 0xff); |
139 | 62.7k | p[2] = (byte) ((v >> 40) & 0xff); |
140 | 62.7k | p[3] = (byte) ((v >> 32) & 0xff); |
141 | 62.7k | p[4] = (byte) ((v >> 24) & 0xff); |
142 | 62.7k | p[5] = (byte) ((v >> 16) & 0xff); |
143 | 62.7k | p[6] = (byte) ((v >> 8) & 0xff); |
144 | 62.7k | p[7] = (byte) ((v >> 0) & 0xff); |
145 | 62.7k | } |
146 | | |
147 | 83.6k | forceinline constexpr upx_uint16_t get_le16(const byte *p) noexcept { |
148 | 83.6k | typedef unsigned U; |
149 | 83.6k | return (upx_uint16_t) (((U) p[0] << 0) | ((U) p[1] << 8)); |
150 | 83.6k | } |
151 | 884k | forceinline constexpr upx_uint32_t get_le24(const byte *p) noexcept { |
152 | 884k | typedef upx_uint32_t U; |
153 | 884k | return (upx_uint32_t) (((U) p[0] << 0) | ((U) p[1] << 8) | ((U) p[2] << 16)); |
154 | 884k | } |
155 | 83.6k | forceinline constexpr upx_uint32_t get_le32(const byte *p) noexcept { |
156 | 83.6k | typedef upx_uint32_t U; |
157 | 83.6k | return (upx_uint32_t) (((U) p[0] << 0) | ((U) p[1] << 8) | ((U) p[2] << 16) | ((U) p[3] << 24)); |
158 | 83.6k | } |
159 | 83.6k | forceinline constexpr upx_uint64_t get_le64(const byte *p) noexcept { |
160 | 83.6k | typedef upx_uint64_t U; |
161 | 83.6k | return (upx_uint64_t) (((U) p[0] << 0) | ((U) p[1] << 8) | ((U) p[2] << 16) | ((U) p[3] << 24) | |
162 | 83.6k | ((U) p[4] << 32) | ((U) p[5] << 40) | ((U) p[6] << 48) | |
163 | 83.6k | ((U) p[7] << 56)); |
164 | 83.6k | } |
165 | | |
166 | 62.7k | forceinline constexpr void set_le16(byte *p, upx_uint16_t v) noexcept { |
167 | 62.7k | p[0] = (byte) ((v >> 0) & 0xff); |
168 | 62.7k | p[1] = (byte) ((v >> 8) & 0xff); |
169 | 62.7k | } |
170 | 821k | forceinline constexpr void set_le24(byte *p, upx_uint32_t v) noexcept { |
171 | 821k | p[0] = (byte) ((v >> 0) & 0xff); |
172 | 821k | p[1] = (byte) ((v >> 8) & 0xff); |
173 | 821k | p[2] = (byte) ((v >> 16) & 0xff); |
174 | 821k | } |
175 | 62.7k | forceinline constexpr void set_le32(byte *p, upx_uint32_t v) noexcept { |
176 | 62.7k | p[0] = (byte) ((v >> 0) & 0xff); |
177 | 62.7k | p[1] = (byte) ((v >> 8) & 0xff); |
178 | 62.7k | p[2] = (byte) ((v >> 16) & 0xff); |
179 | 62.7k | p[3] = (byte) ((v >> 24) & 0xff); |
180 | 62.7k | } |
181 | 62.7k | forceinline constexpr void set_le64(byte *p, upx_uint64_t v) noexcept { |
182 | 62.7k | p[0] = (byte) ((v >> 0) & 0xff); |
183 | 62.7k | p[1] = (byte) ((v >> 8) & 0xff); |
184 | 62.7k | p[2] = (byte) ((v >> 16) & 0xff); |
185 | 62.7k | p[3] = (byte) ((v >> 24) & 0xff); |
186 | 62.7k | p[4] = (byte) ((v >> 32) & 0xff); |
187 | 62.7k | p[5] = (byte) ((v >> 40) & 0xff); |
188 | 62.7k | p[6] = (byte) ((v >> 48) & 0xff); |
189 | 62.7k | p[7] = (byte) ((v >> 56) & 0xff); |
190 | 62.7k | } |
191 | | |
192 | 0 | forceinline constexpr upx_uint16_t get_ne16(const byte *p) noexcept { |
193 | 0 | #if (ACC_ABI_BIG_ENDIAN) |
194 | 0 | return get_be16(p); |
195 | 0 | #elif (ACC_ABI_LITTLE_ENDIAN) |
196 | 0 | return get_le16(p); |
197 | 0 | #else |
198 | 0 | #error "ACC_ABI_ENDIAN" |
199 | 0 | #endif |
200 | 0 | } |
201 | 292k | forceinline constexpr upx_uint32_t get_ne24(const byte *p) noexcept { |
202 | | #if (ACC_ABI_BIG_ENDIAN) |
203 | | return get_be24(p); |
204 | | #elif (ACC_ABI_LITTLE_ENDIAN) |
205 | | return get_le24(p); |
206 | | #else |
207 | | #error "ACC_ABI_ENDIAN" |
208 | | #endif |
209 | 292k | } |
210 | 0 | forceinline constexpr upx_uint32_t get_ne32(const byte *p) noexcept { |
211 | 0 | #if (ACC_ABI_BIG_ENDIAN) |
212 | 0 | return get_be32(p); |
213 | 0 | #elif (ACC_ABI_LITTLE_ENDIAN) |
214 | 0 | return get_le32(p); |
215 | 0 | #else |
216 | 0 | #error "ACC_ABI_ENDIAN" |
217 | 0 | #endif |
218 | 0 | } |
219 | 0 | forceinline constexpr upx_uint64_t get_ne64(const byte *p) noexcept { |
220 | 0 | #if (ACC_ABI_BIG_ENDIAN) |
221 | 0 | return get_be64(p); |
222 | 0 | #elif (ACC_ABI_LITTLE_ENDIAN) |
223 | 0 | return get_le64(p); |
224 | 0 | #else |
225 | 0 | #error "ACC_ABI_ENDIAN" |
226 | 0 | #endif |
227 | 0 | } |
228 | | |
229 | 0 | forceinline constexpr void set_ne16(byte *p, upx_uint16_t v) noexcept { |
230 | 0 | #if (ACC_ABI_BIG_ENDIAN) |
231 | 0 | set_be16(p, v); |
232 | 0 | #elif (ACC_ABI_LITTLE_ENDIAN) |
233 | 0 | set_le16(p, v); |
234 | 0 | #else |
235 | 0 | #error "ACC_ABI_ENDIAN" |
236 | 0 | #endif |
237 | 0 | } |
238 | 292k | forceinline constexpr void set_ne24(byte *p, upx_uint32_t v) noexcept { |
239 | | #if (ACC_ABI_BIG_ENDIAN) |
240 | | set_be24(p, v); |
241 | | #elif (ACC_ABI_LITTLE_ENDIAN) |
242 | | set_le24(p, v); |
243 | | #else |
244 | | #error "ACC_ABI_ENDIAN" |
245 | | #endif |
246 | 292k | } |
247 | 0 | forceinline constexpr void set_ne32(byte *p, upx_uint32_t v) noexcept { |
248 | 0 | #if (ACC_ABI_BIG_ENDIAN) |
249 | 0 | set_be32(p, v); |
250 | 0 | #elif (ACC_ABI_LITTLE_ENDIAN) |
251 | 0 | set_le32(p, v); |
252 | 0 | #else |
253 | 0 | #error "ACC_ABI_ENDIAN" |
254 | 0 | #endif |
255 | 0 | } |
256 | 0 | forceinline constexpr void set_ne64(byte *p, upx_uint64_t v) noexcept { |
257 | 0 | #if (ACC_ABI_BIG_ENDIAN) |
258 | 0 | set_be64(p, v); |
259 | 0 | #elif (ACC_ABI_LITTLE_ENDIAN) |
260 | 0 | set_le64(p, v); |
261 | 0 | #else |
262 | 0 | #error "ACC_ABI_ENDIAN" |
263 | 0 | #endif |
264 | 0 | } |
265 | | |
266 | | } // namespace compile_time |
267 | | |
268 | | /************************************************************************* |
269 | | // core util |
270 | | **************************************************************************/ |
271 | | |
272 | | // disable taking the address => force passing by reference (instead of pointer) |
273 | | #define UPX_CXX_DISABLE_ADDRESS(Klass) \ |
274 | | private: \ |
275 | | Klass *operator&() const noexcept DELETED_FUNCTION; |
276 | | |
277 | | // disable copy and move |
278 | | #define UPX_CXX_DISABLE_COPY(KlassName) \ |
279 | | private: \ |
280 | | KlassName(const KlassName &) noexcept DELETED_FUNCTION; /* copy constructor */ \ |
281 | | KlassName &operator=(const KlassName &) noexcept DELETED_FUNCTION; /* copy assignment */ |
282 | | #define UPX_CXX_DISABLE_MOVE(KlassName) \ |
283 | | private: \ |
284 | | KlassName(KlassName &&) noexcept DELETED_FUNCTION; /* move constructor */ \ |
285 | | KlassName &operator=(KlassName &&) noexcept DELETED_FUNCTION; /* move assignment */ |
286 | | #define UPX_CXX_DISABLE_COPY_MOVE(KlassName) \ |
287 | | UPX_CXX_DISABLE_COPY(KlassName) \ |
288 | | UPX_CXX_DISABLE_MOVE(KlassName) |
289 | | |
290 | | // fun with C++: disable common "new" and ALL "delete" operators |
291 | | // https://en.cppreference.com/w/cpp/memory/new/operator_delete |
292 | | #define UPX_CXX_DISABLE_NEW_DELETE_IMPL__(Klass) \ |
293 | | private: \ |
294 | | /* common allocation functions (4) */ \ |
295 | | static void *operator new(std::size_t) DELETED_FUNCTION; \ |
296 | | static void *operator new[](std::size_t) DELETED_FUNCTION; \ |
297 | | static void *operator new(std::size_t, void *) DELETED_FUNCTION; \ |
298 | | static void *operator new[](std::size_t, void *) DELETED_FUNCTION; \ |
299 | | /* replaceable placement deallocation functions (4) */ \ |
300 | | static void operator delete(void *, const std::nothrow_t &) noexcept DELETED_FUNCTION; \ |
301 | | static void operator delete[](void *, const std::nothrow_t &) noexcept DELETED_FUNCTION; \ |
302 | | static void operator delete(void *, std::align_val_t, const std::nothrow_t &) \ |
303 | | noexcept DELETED_FUNCTION; \ |
304 | | static void operator delete[](void *, std::align_val_t, const std::nothrow_t &) \ |
305 | | noexcept DELETED_FUNCTION; \ |
306 | | /* non-allocating placement deallocation functions (2) */ \ |
307 | | static void operator delete(void *, void *) noexcept DELETED_FUNCTION; \ |
308 | | static void operator delete[](void *, void *) noexcept DELETED_FUNCTION; |
309 | | |
310 | | /* class-specific usual deallocation functions (8) */ |
311 | | #define UPX_CXX_DISABLE_NEW_DELETE_IMPL_CSUDF_A__(Klass) \ |
312 | | protected: \ |
313 | 0 | static void operator delete(void *) noexcept {} \Unexecuted instantiation: Options::operator delete(void*) Unexecuted instantiation: Throwable::operator delete(void*) Unexecuted instantiation: N_BELE_CTP::BEPolicy::operator delete(void*) Unexecuted instantiation: N_BELE_CTP::LEPolicy::operator delete(void*) Unexecuted instantiation: N_BELE_RTP::AbstractPolicy::operator delete(void*) Unexecuted instantiation: N_BELE_RTP::BEPolicy::operator delete(void*) Unexecuted instantiation: N_BELE_RTP::LEPolicy::operator delete(void*) Unexecuted instantiation: PackMaster::operator delete(void*) Unexecuted instantiation: dt_cxxlib.cpp:(anonymous namespace)::MyVType1<char, int, 1>::operator delete(void*) Unexecuted instantiation: dt_cxxlib.cpp:(anonymous namespace)::MyVType2<char, int, 2>::operator delete(void*) Unexecuted instantiation: test_disable_new_delete::X2::operator delete(void*) Unexecuted instantiation: test_disable_new_delete::Y2_X1::operator delete(void*) Unexecuted instantiation: test_disable_new_delete::Y2_X2::operator delete(void*) Unexecuted instantiation: test_disable_new_delete::Z2_X1::operator delete(void*) Unexecuted instantiation: test_disable_new_delete::Z2_X2::operator delete(void*) Unexecuted instantiation: PackHeader::operator delete(void*) |
314 | 0 | static void operator delete(void *, std::align_val_t) noexcept {} \Unexecuted instantiation: Options::operator delete(void*, std::align_val_t) Unexecuted instantiation: Throwable::operator delete(void*, std::align_val_t) Unexecuted instantiation: N_BELE_CTP::BEPolicy::operator delete(void*, std::align_val_t) Unexecuted instantiation: N_BELE_CTP::LEPolicy::operator delete(void*, std::align_val_t) Unexecuted instantiation: N_BELE_RTP::AbstractPolicy::operator delete(void*, std::align_val_t) Unexecuted instantiation: N_BELE_RTP::BEPolicy::operator delete(void*, std::align_val_t) Unexecuted instantiation: N_BELE_RTP::LEPolicy::operator delete(void*, std::align_val_t) Unexecuted instantiation: PackMaster::operator delete(void*, std::align_val_t) Unexecuted instantiation: test_disable_new_delete::X2::operator delete(void*, std::align_val_t) Unexecuted instantiation: test_disable_new_delete::Y2_X1::operator delete(void*, std::align_val_t) Unexecuted instantiation: test_disable_new_delete::Y2_X2::operator delete(void*, std::align_val_t) Unexecuted instantiation: test_disable_new_delete::Z2_X1::operator delete(void*, std::align_val_t) Unexecuted instantiation: test_disable_new_delete::Z2_X2::operator delete(void*, std::align_val_t) Unexecuted instantiation: PackHeader::operator delete(void*, std::align_val_t) |
315 | 0 | static void operator delete(void *, std::size_t) noexcept {} \Unexecuted instantiation: Options::operator delete(void*, unsigned long) Unexecuted instantiation: Throwable::operator delete(void*, unsigned long) Unexecuted instantiation: N_BELE_CTP::BEPolicy::operator delete(void*, unsigned long) Unexecuted instantiation: N_BELE_CTP::LEPolicy::operator delete(void*, unsigned long) Unexecuted instantiation: N_BELE_RTP::AbstractPolicy::operator delete(void*, unsigned long) Unexecuted instantiation: N_BELE_RTP::BEPolicy::operator delete(void*, unsigned long) Unexecuted instantiation: N_BELE_RTP::LEPolicy::operator delete(void*, unsigned long) Unexecuted instantiation: PackMaster::operator delete(void*, unsigned long) Unexecuted instantiation: test_disable_new_delete::X2::operator delete(void*, unsigned long) Unexecuted instantiation: test_disable_new_delete::Y2_X1::operator delete(void*, unsigned long) Unexecuted instantiation: test_disable_new_delete::Y2_X2::operator delete(void*, unsigned long) Unexecuted instantiation: test_disable_new_delete::Z2_X1::operator delete(void*, unsigned long) Unexecuted instantiation: test_disable_new_delete::Z2_X2::operator delete(void*, unsigned long) Unexecuted instantiation: PackHeader::operator delete(void*, unsigned long) |
316 | 0 | static void operator delete(void *, std::size_t, std::align_val_t) noexcept {} \Unexecuted instantiation: Options::operator delete(void*, unsigned long, std::align_val_t) Unexecuted instantiation: Throwable::operator delete(void*, unsigned long, std::align_val_t) Unexecuted instantiation: N_BELE_CTP::BEPolicy::operator delete(void*, unsigned long, std::align_val_t) Unexecuted instantiation: N_BELE_CTP::LEPolicy::operator delete(void*, unsigned long, std::align_val_t) Unexecuted instantiation: N_BELE_RTP::AbstractPolicy::operator delete(void*, unsigned long, std::align_val_t) Unexecuted instantiation: N_BELE_RTP::BEPolicy::operator delete(void*, unsigned long, std::align_val_t) Unexecuted instantiation: N_BELE_RTP::LEPolicy::operator delete(void*, unsigned long, std::align_val_t) Unexecuted instantiation: PackMaster::operator delete(void*, unsigned long, std::align_val_t) Unexecuted instantiation: test_disable_new_delete::X2::operator delete(void*, unsigned long, std::align_val_t) Unexecuted instantiation: test_disable_new_delete::Y2_X1::operator delete(void*, unsigned long, std::align_val_t) Unexecuted instantiation: test_disable_new_delete::Y2_X2::operator delete(void*, unsigned long, std::align_val_t) Unexecuted instantiation: test_disable_new_delete::Z2_X1::operator delete(void*, unsigned long, std::align_val_t) Unexecuted instantiation: test_disable_new_delete::Z2_X2::operator delete(void*, unsigned long, std::align_val_t) Unexecuted instantiation: PackHeader::operator delete(void*, unsigned long, std::align_val_t) |
317 | | private: \ |
318 | | static void operator delete[](void *) noexcept DELETED_FUNCTION; \ |
319 | | static void operator delete[](void *, std::align_val_t) noexcept DELETED_FUNCTION; \ |
320 | | static void operator delete[](void *, std::size_t) noexcept DELETED_FUNCTION; \ |
321 | | static void operator delete[](void *, std::size_t, std::align_val_t) noexcept DELETED_FUNCTION; |
322 | | #define UPX_CXX_DISABLE_NEW_DELETE_IMPL_CSUDF_B__(Klass) \ |
323 | | private: \ |
324 | | static void operator delete(void *) noexcept DELETED_FUNCTION; \ |
325 | | static void operator delete[](void *) noexcept DELETED_FUNCTION; \ |
326 | | static void operator delete(void *, std::align_val_t) noexcept DELETED_FUNCTION; \ |
327 | | static void operator delete[](void *, std::align_val_t) noexcept DELETED_FUNCTION; \ |
328 | | static void operator delete(void *, std::size_t) noexcept DELETED_FUNCTION; \ |
329 | | static void operator delete[](void *, std::size_t) noexcept DELETED_FUNCTION; \ |
330 | | static void operator delete(void *, std::size_t, std::align_val_t) noexcept DELETED_FUNCTION; \ |
331 | | static void operator delete[](void *, std::size_t, std::align_val_t) noexcept DELETED_FUNCTION; |
332 | | |
333 | | /* class-specific usual destroying deallocation functions (4) */ |
334 | | #if __cplusplus >= 202002L |
335 | | #define UPX_CXX_DISABLE_NEW_DELETE_IMPL_CSUDDF_A__(Klass) \ |
336 | | protected: \ |
337 | | static void operator delete(Klass *, std::destroying_delete_t) noexcept {} \ |
338 | | static void operator delete(Klass *, std::destroying_delete_t, std::align_val_t) noexcept {} \ |
339 | | static void operator delete(Klass *, std::destroying_delete_t, std::size_t) noexcept {} \ |
340 | | static void operator delete(Klass *, std::destroying_delete_t, std::size_t, std::align_val_t) \ |
341 | | noexcept {} \ |
342 | | private: |
343 | | #define UPX_CXX_DISABLE_NEW_DELETE_IMPL_CSUDDF_B__(Klass) \ |
344 | | private: \ |
345 | | static void operator delete(Klass *, std::destroying_delete_t) noexcept DELETED_FUNCTION; \ |
346 | | static void operator delete(Klass *, std::destroying_delete_t, std::align_val_t) \ |
347 | | noexcept DELETED_FUNCTION; \ |
348 | | static void operator delete(Klass *, std::destroying_delete_t, std::size_t) \ |
349 | | noexcept DELETED_FUNCTION; \ |
350 | | static void operator delete(Klass *, std::destroying_delete_t, std::size_t, std::align_val_t) \ |
351 | | noexcept DELETED_FUNCTION; |
352 | | #else |
353 | | #define UPX_CXX_DISABLE_NEW_DELETE_IMPL_CSUDDF_A__(Klass) private: |
354 | | #define UPX_CXX_DISABLE_NEW_DELETE_IMPL_CSUDDF_B__(Klass) private: |
355 | | #endif |
356 | | |
357 | | // for classes which may have virtual methods |
358 | | #define UPX_CXX_DISABLE_NEW_DELETE(Klass) \ |
359 | | UPX_CXX_DISABLE_NEW_DELETE_IMPL__(Klass) \ |
360 | | UPX_CXX_DISABLE_NEW_DELETE_IMPL_CSUDF_A__(Klass) \ |
361 | | UPX_CXX_DISABLE_NEW_DELETE_IMPL_CSUDDF_A__(Klass) |
362 | | |
363 | | // this only works for classes WITHOUT any virtual methods |
364 | | #define UPX_CXX_DISABLE_NEW_DELETE_NO_VIRTUAL(Klass) \ |
365 | | UPX_CXX_DISABLE_NEW_DELETE_IMPL__(Klass) \ |
366 | | UPX_CXX_DISABLE_NEW_DELETE_IMPL_CSUDF_B__(Klass) \ |
367 | | UPX_CXX_DISABLE_NEW_DELETE_IMPL_CSUDDF_B__(Klass) |
368 | | |
369 | | #if defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) // do not use std::align_val_t |
370 | | #undef UPX_CXX_DISABLE_NEW_DELETE |
371 | | #undef UPX_CXX_DISABLE_NEW_DELETE_NO_VIRTUAL |
372 | | #define UPX_CXX_DISABLE_NEW_DELETE(Klass) private: |
373 | | #define UPX_CXX_DISABLE_NEW_DELETE_NO_VIRTUAL(Klass) private: |
374 | | #endif |
375 | | |
376 | | class NonCopyAble { |
377 | | protected: |
378 | 20.9k | forceinline constexpr NonCopyAble() noexcept {} |
379 | | #if __cplusplus >= 202002L |
380 | | forceinline constexpr ~NonCopyAble() noexcept = default; |
381 | | #else |
382 | | forceinline ~NonCopyAble() noexcept = default; |
383 | | #endif |
384 | | UPX_CXX_DISABLE_COPY_MOVE(NonCopyAble) |
385 | | }; |
386 | | typedef NonCopyAble noncopyable; |
387 | | |
388 | | /************************************************************************* |
389 | | // <type_traits> |
390 | | **************************************************************************/ |
391 | | |
392 | | // is_bounded_array from C++20 |
393 | | template <class T> |
394 | | struct is_bounded_array : public std::false_type {}; |
395 | | template <class T, std::size_t N> |
396 | | struct is_bounded_array<T[N]> : public std::true_type {}; |
397 | | template <class T> |
398 | | inline constexpr bool is_bounded_array_v = is_bounded_array<T>::value; |
399 | | |
400 | | // is_same_all and is_same_any: std::is_same for multiple types |
401 | | template <class T, class... Ts> |
402 | | struct is_same_all : public std::conjunction<std::is_same<T, Ts>...> {}; |
403 | | template <class T, class... Ts> |
404 | | struct is_same_any : public std::disjunction<std::is_same<T, Ts>...> {}; |
405 | | template <class T, class... Ts> |
406 | | inline constexpr bool is_same_all_v = is_same_all<T, Ts...>::value; |
407 | | template <class T, class... Ts> |
408 | | inline constexpr bool is_same_any_v = is_same_any<T, Ts...>::value; |
409 | | |
410 | | // remove_cvref from C++20 |
411 | | template <class T> |
412 | | struct remove_cvref { |
413 | | typedef typename std::remove_cv<typename std::remove_reference<T>::type>::type type; |
414 | | }; |
415 | | template <class T> |
416 | | using remove_cvref_t = typename remove_cvref<T>::type; |
417 | | |
418 | | // type_identity from C++20 |
419 | | template <class T> |
420 | | struct type_identity { |
421 | | typedef T type; |
422 | | }; |
423 | | template <class T> |
424 | | using type_identity_t = typename type_identity<T>::type; |
425 | | |
426 | | /************************************************************************* |
427 | | // <bit> C++20 |
428 | | **************************************************************************/ |
429 | | |
430 | | template <class T> |
431 | 1.04M | forceinline constexpr bool has_single_bit(const T &x) noexcept { |
432 | 1.04M | return !(x == 0) && (x & (x - 1)) == 0; |
433 | 1.04M | } bool upx::has_single_bit<unsigned long>(unsigned long const&) Line | Count | Source | 431 | 41.8k | forceinline constexpr bool has_single_bit(const T &x) noexcept { | 432 | 41.8k | return !(x == 0) && (x & (x - 1)) == 0; | 433 | 41.8k | } |
bool upx::has_single_bit<LE16>(LE16 const&) Line | Count | Source | 431 | 167k | forceinline constexpr bool has_single_bit(const T &x) noexcept { | 432 | 167k | return !(x == 0) && (x & (x - 1)) == 0; | 433 | 167k | } |
bool upx::has_single_bit<LE32>(LE32 const&) Line | Count | Source | 431 | 167k | forceinline constexpr bool has_single_bit(const T &x) noexcept { | 432 | 167k | return !(x == 0) && (x & (x - 1)) == 0; | 433 | 167k | } |
bool upx::has_single_bit<LE64>(LE64 const&) Line | Count | Source | 431 | 167k | forceinline constexpr bool has_single_bit(const T &x) noexcept { | 432 | 167k | return !(x == 0) && (x & (x - 1)) == 0; | 433 | 167k | } |
bool upx::has_single_bit<BE16>(BE16 const&) Line | Count | Source | 431 | 167k | forceinline constexpr bool has_single_bit(const T &x) noexcept { | 432 | 167k | return !(x == 0) && (x & (x - 1)) == 0; | 433 | 167k | } |
bool upx::has_single_bit<BE32>(BE32 const&) Line | Count | Source | 431 | 167k | forceinline constexpr bool has_single_bit(const T &x) noexcept { | 432 | 167k | return !(x == 0) && (x & (x - 1)) == 0; | 433 | 167k | } |
bool upx::has_single_bit<BE64>(BE64 const&) Line | Count | Source | 431 | 167k | forceinline constexpr bool has_single_bit(const T &x) noexcept { | 432 | 167k | return !(x == 0) && (x & (x - 1)) == 0; | 433 | 167k | } |
Unexecuted instantiation: bool upx::has_single_bit<int>(int const&) Unexecuted instantiation: bool upx::has_single_bit<unsigned int>(unsigned int const&) |
434 | | |
435 | | /************************************************************************* |
436 | | // <algorithm> |
437 | | **************************************************************************/ |
438 | | |
439 | | template <class T> |
440 | 12.0M | inline constexpr T align_down(const T &x, const T &alignment) noexcept { |
441 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) |
442 | 12.0M | T r = {}; |
443 | 12.0M | r = x - (x & (alignment - 1)); |
444 | 12.0M | return r; |
445 | 12.0M | } char upx::align_down<char>(char const&, char const&) Line | Count | Source | 440 | 334k | inline constexpr T align_down(const T &x, const T &alignment) noexcept { | 441 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 442 | 334k | T r = {}; | 443 | 334k | r = x - (x & (alignment - 1)); | 444 | 334k | return r; | 445 | 334k | } |
signed char upx::align_down<signed char>(signed char const&, signed char const&) Line | Count | Source | 440 | 668k | inline constexpr T align_down(const T &x, const T &alignment) noexcept { | 441 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 442 | 668k | T r = {}; | 443 | 668k | r = x - (x & (alignment - 1)); | 444 | 668k | return r; | 445 | 668k | } |
unsigned char upx::align_down<unsigned char>(unsigned char const&, unsigned char const&) Line | Count | Source | 440 | 668k | inline constexpr T align_down(const T &x, const T &alignment) noexcept { | 441 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 442 | 668k | T r = {}; | 443 | 668k | r = x - (x & (alignment - 1)); | 444 | 668k | return r; | 445 | 668k | } |
short upx::align_down<short>(short const&, short const&) Line | Count | Source | 440 | 668k | inline constexpr T align_down(const T &x, const T &alignment) noexcept { | 441 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 442 | 668k | T r = {}; | 443 | 668k | r = x - (x & (alignment - 1)); | 444 | 668k | return r; | 445 | 668k | } |
unsigned short upx::align_down<unsigned short>(unsigned short const&, unsigned short const&) Line | Count | Source | 440 | 668k | inline constexpr T align_down(const T &x, const T &alignment) noexcept { | 441 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 442 | 668k | T r = {}; | 443 | 668k | r = x - (x & (alignment - 1)); | 444 | 668k | return r; | 445 | 668k | } |
int upx::align_down<int>(int const&, int const&) Line | Count | Source | 440 | 668k | inline constexpr T align_down(const T &x, const T &alignment) noexcept { | 441 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 442 | 668k | T r = {}; | 443 | 668k | r = x - (x & (alignment - 1)); | 444 | 668k | return r; | 445 | 668k | } |
unsigned int upx::align_down<unsigned int>(unsigned int const&, unsigned int const&) Line | Count | Source | 440 | 668k | inline constexpr T align_down(const T &x, const T &alignment) noexcept { | 441 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 442 | 668k | T r = {}; | 443 | 668k | r = x - (x & (alignment - 1)); | 444 | 668k | return r; | 445 | 668k | } |
long upx::align_down<long>(long const&, long const&) Line | Count | Source | 440 | 1.33M | inline constexpr T align_down(const T &x, const T &alignment) noexcept { | 441 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 442 | 1.33M | T r = {}; | 443 | 1.33M | r = x - (x & (alignment - 1)); | 444 | 1.33M | return r; | 445 | 1.33M | } |
unsigned long upx::align_down<unsigned long>(unsigned long const&, unsigned long const&) Line | Count | Source | 440 | 2.00M | inline constexpr T align_down(const T &x, const T &alignment) noexcept { | 441 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 442 | 2.00M | T r = {}; | 443 | 2.00M | r = x - (x & (alignment - 1)); | 444 | 2.00M | return r; | 445 | 2.00M | } |
long long upx::align_down<long long>(long long const&, long long const&) Line | Count | Source | 440 | 1.00M | inline constexpr T align_down(const T &x, const T &alignment) noexcept { | 441 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 442 | 1.00M | T r = {}; | 443 | 1.00M | r = x - (x & (alignment - 1)); | 444 | 1.00M | return r; | 445 | 1.00M | } |
unsigned long long upx::align_down<unsigned long long>(unsigned long long const&, unsigned long long const&) Line | Count | Source | 440 | 668k | inline constexpr T align_down(const T &x, const T &alignment) noexcept { | 441 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 442 | 668k | T r = {}; | 443 | 668k | r = x - (x & (alignment - 1)); | 444 | 668k | return r; | 445 | 668k | } |
__int128 upx::align_down<__int128>(__int128 const&, __int128 const&) Line | Count | Source | 440 | 334k | inline constexpr T align_down(const T &x, const T &alignment) noexcept { | 441 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 442 | 334k | T r = {}; | 443 | 334k | r = x - (x & (alignment - 1)); | 444 | 334k | return r; | 445 | 334k | } |
unsigned __int128 upx::align_down<unsigned __int128>(unsigned __int128 const&, unsigned __int128 const&) Line | Count | Source | 440 | 334k | inline constexpr T align_down(const T &x, const T &alignment) noexcept { | 441 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 442 | 334k | T r = {}; | 443 | 334k | r = x - (x & (alignment - 1)); | 444 | 334k | return r; | 445 | 334k | } |
LE16 upx::align_down<LE16>(LE16 const&, LE16 const&) Line | Count | Source | 440 | 334k | inline constexpr T align_down(const T &x, const T &alignment) noexcept { | 441 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 442 | 334k | T r = {}; | 443 | 334k | r = x - (x & (alignment - 1)); | 444 | 334k | return r; | 445 | 334k | } |
LE32 upx::align_down<LE32>(LE32 const&, LE32 const&) Line | Count | Source | 440 | 334k | inline constexpr T align_down(const T &x, const T &alignment) noexcept { | 441 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 442 | 334k | T r = {}; | 443 | 334k | r = x - (x & (alignment - 1)); | 444 | 334k | return r; | 445 | 334k | } |
LE64 upx::align_down<LE64>(LE64 const&, LE64 const&) Line | Count | Source | 440 | 334k | inline constexpr T align_down(const T &x, const T &alignment) noexcept { | 441 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 442 | 334k | T r = {}; | 443 | 334k | r = x - (x & (alignment - 1)); | 444 | 334k | return r; | 445 | 334k | } |
BE16 upx::align_down<BE16>(BE16 const&, BE16 const&) Line | Count | Source | 440 | 334k | inline constexpr T align_down(const T &x, const T &alignment) noexcept { | 441 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 442 | 334k | T r = {}; | 443 | 334k | r = x - (x & (alignment - 1)); | 444 | 334k | return r; | 445 | 334k | } |
BE32 upx::align_down<BE32>(BE32 const&, BE32 const&) Line | Count | Source | 440 | 334k | inline constexpr T align_down(const T &x, const T &alignment) noexcept { | 441 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 442 | 334k | T r = {}; | 443 | 334k | r = x - (x & (alignment - 1)); | 444 | 334k | return r; | 445 | 334k | } |
BE64 upx::align_down<BE64>(BE64 const&, BE64 const&) Line | Count | Source | 440 | 334k | inline constexpr T align_down(const T &x, const T &alignment) noexcept { | 441 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 442 | 334k | T r = {}; | 443 | 334k | r = x - (x & (alignment - 1)); | 444 | 334k | return r; | 445 | 334k | } |
|
446 | | template <class T> |
447 | 0 | inline constexpr T align_down_gap(const T &x, const T &alignment) noexcept { |
448 | 0 | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) |
449 | 0 | T r = {}; |
450 | 0 | r = x & (alignment - 1); |
451 | 0 | return r; |
452 | 0 | } Unexecuted instantiation: LE16 upx::align_down_gap<LE16>(LE16 const&, LE16 const&) Unexecuted instantiation: LE32 upx::align_down_gap<LE32>(LE32 const&, LE32 const&) Unexecuted instantiation: LE64 upx::align_down_gap<LE64>(LE64 const&, LE64 const&) Unexecuted instantiation: BE16 upx::align_down_gap<BE16>(BE16 const&, BE16 const&) Unexecuted instantiation: BE32 upx::align_down_gap<BE32>(BE32 const&, BE32 const&) Unexecuted instantiation: BE64 upx::align_down_gap<BE64>(BE64 const&, BE64 const&) |
453 | | template <class T> |
454 | 12.0M | inline constexpr T align_up(const T &x, const T &alignment) noexcept { |
455 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) |
456 | 12.0M | T r = {}; |
457 | 12.0M | constexpr T zero = {}; |
458 | 12.0M | r = x + ((zero - x) & (alignment - 1)); |
459 | 12.0M | return r; |
460 | 12.0M | } char upx::align_up<char>(char const&, char const&) Line | Count | Source | 454 | 334k | inline constexpr T align_up(const T &x, const T &alignment) noexcept { | 455 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 456 | 334k | T r = {}; | 457 | 334k | constexpr T zero = {}; | 458 | 334k | r = x + ((zero - x) & (alignment - 1)); | 459 | 334k | return r; | 460 | 334k | } |
signed char upx::align_up<signed char>(signed char const&, signed char const&) Line | Count | Source | 454 | 668k | inline constexpr T align_up(const T &x, const T &alignment) noexcept { | 455 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 456 | 668k | T r = {}; | 457 | 668k | constexpr T zero = {}; | 458 | 668k | r = x + ((zero - x) & (alignment - 1)); | 459 | 668k | return r; | 460 | 668k | } |
unsigned char upx::align_up<unsigned char>(unsigned char const&, unsigned char const&) Line | Count | Source | 454 | 668k | inline constexpr T align_up(const T &x, const T &alignment) noexcept { | 455 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 456 | 668k | T r = {}; | 457 | 668k | constexpr T zero = {}; | 458 | 668k | r = x + ((zero - x) & (alignment - 1)); | 459 | 668k | return r; | 460 | 668k | } |
short upx::align_up<short>(short const&, short const&) Line | Count | Source | 454 | 668k | inline constexpr T align_up(const T &x, const T &alignment) noexcept { | 455 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 456 | 668k | T r = {}; | 457 | 668k | constexpr T zero = {}; | 458 | 668k | r = x + ((zero - x) & (alignment - 1)); | 459 | 668k | return r; | 460 | 668k | } |
unsigned short upx::align_up<unsigned short>(unsigned short const&, unsigned short const&) Line | Count | Source | 454 | 668k | inline constexpr T align_up(const T &x, const T &alignment) noexcept { | 455 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 456 | 668k | T r = {}; | 457 | 668k | constexpr T zero = {}; | 458 | 668k | r = x + ((zero - x) & (alignment - 1)); | 459 | 668k | return r; | 460 | 668k | } |
int upx::align_up<int>(int const&, int const&) Line | Count | Source | 454 | 668k | inline constexpr T align_up(const T &x, const T &alignment) noexcept { | 455 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 456 | 668k | T r = {}; | 457 | 668k | constexpr T zero = {}; | 458 | 668k | r = x + ((zero - x) & (alignment - 1)); | 459 | 668k | return r; | 460 | 668k | } |
unsigned int upx::align_up<unsigned int>(unsigned int const&, unsigned int const&) Line | Count | Source | 454 | 669k | inline constexpr T align_up(const T &x, const T &alignment) noexcept { | 455 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 456 | 669k | T r = {}; | 457 | 669k | constexpr T zero = {}; | 458 | 669k | r = x + ((zero - x) & (alignment - 1)); | 459 | 669k | return r; | 460 | 669k | } |
long upx::align_up<long>(long const&, long const&) Line | Count | Source | 454 | 1.33M | inline constexpr T align_up(const T &x, const T &alignment) noexcept { | 455 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 456 | 1.33M | T r = {}; | 457 | 1.33M | constexpr T zero = {}; | 458 | 1.33M | r = x + ((zero - x) & (alignment - 1)); | 459 | 1.33M | return r; | 460 | 1.33M | } |
unsigned long upx::align_up<unsigned long>(unsigned long const&, unsigned long const&) Line | Count | Source | 454 | 2.00M | inline constexpr T align_up(const T &x, const T &alignment) noexcept { | 455 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 456 | 2.00M | T r = {}; | 457 | 2.00M | constexpr T zero = {}; | 458 | 2.00M | r = x + ((zero - x) & (alignment - 1)); | 459 | 2.00M | return r; | 460 | 2.00M | } |
long long upx::align_up<long long>(long long const&, long long const&) Line | Count | Source | 454 | 1.00M | inline constexpr T align_up(const T &x, const T &alignment) noexcept { | 455 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 456 | 1.00M | T r = {}; | 457 | 1.00M | constexpr T zero = {}; | 458 | 1.00M | r = x + ((zero - x) & (alignment - 1)); | 459 | 1.00M | return r; | 460 | 1.00M | } |
unsigned long long upx::align_up<unsigned long long>(unsigned long long const&, unsigned long long const&) Line | Count | Source | 454 | 668k | inline constexpr T align_up(const T &x, const T &alignment) noexcept { | 455 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 456 | 668k | T r = {}; | 457 | 668k | constexpr T zero = {}; | 458 | 668k | r = x + ((zero - x) & (alignment - 1)); | 459 | 668k | return r; | 460 | 668k | } |
__int128 upx::align_up<__int128>(__int128 const&, __int128 const&) Line | Count | Source | 454 | 334k | inline constexpr T align_up(const T &x, const T &alignment) noexcept { | 455 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 456 | 334k | T r = {}; | 457 | 334k | constexpr T zero = {}; | 458 | 334k | r = x + ((zero - x) & (alignment - 1)); | 459 | 334k | return r; | 460 | 334k | } |
unsigned __int128 upx::align_up<unsigned __int128>(unsigned __int128 const&, unsigned __int128 const&) Line | Count | Source | 454 | 334k | inline constexpr T align_up(const T &x, const T &alignment) noexcept { | 455 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 456 | 334k | T r = {}; | 457 | 334k | constexpr T zero = {}; | 458 | 334k | r = x + ((zero - x) & (alignment - 1)); | 459 | 334k | return r; | 460 | 334k | } |
LE16 upx::align_up<LE16>(LE16 const&, LE16 const&) Line | Count | Source | 454 | 334k | inline constexpr T align_up(const T &x, const T &alignment) noexcept { | 455 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 456 | 334k | T r = {}; | 457 | 334k | constexpr T zero = {}; | 458 | 334k | r = x + ((zero - x) & (alignment - 1)); | 459 | 334k | return r; | 460 | 334k | } |
LE32 upx::align_up<LE32>(LE32 const&, LE32 const&) Line | Count | Source | 454 | 334k | inline constexpr T align_up(const T &x, const T &alignment) noexcept { | 455 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 456 | 334k | T r = {}; | 457 | 334k | constexpr T zero = {}; | 458 | 334k | r = x + ((zero - x) & (alignment - 1)); | 459 | 334k | return r; | 460 | 334k | } |
LE64 upx::align_up<LE64>(LE64 const&, LE64 const&) Line | Count | Source | 454 | 334k | inline constexpr T align_up(const T &x, const T &alignment) noexcept { | 455 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 456 | 334k | T r = {}; | 457 | 334k | constexpr T zero = {}; | 458 | 334k | r = x + ((zero - x) & (alignment - 1)); | 459 | 334k | return r; | 460 | 334k | } |
BE16 upx::align_up<BE16>(BE16 const&, BE16 const&) Line | Count | Source | 454 | 334k | inline constexpr T align_up(const T &x, const T &alignment) noexcept { | 455 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 456 | 334k | T r = {}; | 457 | 334k | constexpr T zero = {}; | 458 | 334k | r = x + ((zero - x) & (alignment - 1)); | 459 | 334k | return r; | 460 | 334k | } |
BE32 upx::align_up<BE32>(BE32 const&, BE32 const&) Line | Count | Source | 454 | 334k | inline constexpr T align_up(const T &x, const T &alignment) noexcept { | 455 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 456 | 334k | T r = {}; | 457 | 334k | constexpr T zero = {}; | 458 | 334k | r = x + ((zero - x) & (alignment - 1)); | 459 | 334k | return r; | 460 | 334k | } |
BE64 upx::align_up<BE64>(BE64 const&, BE64 const&) Line | Count | Source | 454 | 334k | inline constexpr T align_up(const T &x, const T &alignment) noexcept { | 455 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 456 | 334k | T r = {}; | 457 | 334k | constexpr T zero = {}; | 458 | 334k | r = x + ((zero - x) & (alignment - 1)); | 459 | 334k | return r; | 460 | 334k | } |
|
461 | | template <class T> |
462 | 12.0M | inline constexpr T align_up_gap(const T &x, const T &alignment) noexcept { |
463 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) |
464 | 12.0M | T r = {}; |
465 | 12.0M | constexpr T zero = {}; |
466 | 12.0M | r = (zero - x) & (alignment - 1); |
467 | 12.0M | return r; |
468 | 12.0M | } char upx::align_up_gap<char>(char const&, char const&) Line | Count | Source | 462 | 334k | inline constexpr T align_up_gap(const T &x, const T &alignment) noexcept { | 463 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 464 | 334k | T r = {}; | 465 | 334k | constexpr T zero = {}; | 466 | 334k | r = (zero - x) & (alignment - 1); | 467 | 334k | return r; | 468 | 334k | } |
signed char upx::align_up_gap<signed char>(signed char const&, signed char const&) Line | Count | Source | 462 | 668k | inline constexpr T align_up_gap(const T &x, const T &alignment) noexcept { | 463 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 464 | 668k | T r = {}; | 465 | 668k | constexpr T zero = {}; | 466 | 668k | r = (zero - x) & (alignment - 1); | 467 | 668k | return r; | 468 | 668k | } |
unsigned char upx::align_up_gap<unsigned char>(unsigned char const&, unsigned char const&) Line | Count | Source | 462 | 668k | inline constexpr T align_up_gap(const T &x, const T &alignment) noexcept { | 463 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 464 | 668k | T r = {}; | 465 | 668k | constexpr T zero = {}; | 466 | 668k | r = (zero - x) & (alignment - 1); | 467 | 668k | return r; | 468 | 668k | } |
short upx::align_up_gap<short>(short const&, short const&) Line | Count | Source | 462 | 668k | inline constexpr T align_up_gap(const T &x, const T &alignment) noexcept { | 463 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 464 | 668k | T r = {}; | 465 | 668k | constexpr T zero = {}; | 466 | 668k | r = (zero - x) & (alignment - 1); | 467 | 668k | return r; | 468 | 668k | } |
unsigned short upx::align_up_gap<unsigned short>(unsigned short const&, unsigned short const&) Line | Count | Source | 462 | 668k | inline constexpr T align_up_gap(const T &x, const T &alignment) noexcept { | 463 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 464 | 668k | T r = {}; | 465 | 668k | constexpr T zero = {}; | 466 | 668k | r = (zero - x) & (alignment - 1); | 467 | 668k | return r; | 468 | 668k | } |
int upx::align_up_gap<int>(int const&, int const&) Line | Count | Source | 462 | 668k | inline constexpr T align_up_gap(const T &x, const T &alignment) noexcept { | 463 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 464 | 668k | T r = {}; | 465 | 668k | constexpr T zero = {}; | 466 | 668k | r = (zero - x) & (alignment - 1); | 467 | 668k | return r; | 468 | 668k | } |
unsigned int upx::align_up_gap<unsigned int>(unsigned int const&, unsigned int const&) Line | Count | Source | 462 | 668k | inline constexpr T align_up_gap(const T &x, const T &alignment) noexcept { | 463 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 464 | 668k | T r = {}; | 465 | 668k | constexpr T zero = {}; | 466 | 668k | r = (zero - x) & (alignment - 1); | 467 | 668k | return r; | 468 | 668k | } |
long upx::align_up_gap<long>(long const&, long const&) Line | Count | Source | 462 | 1.33M | inline constexpr T align_up_gap(const T &x, const T &alignment) noexcept { | 463 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 464 | 1.33M | T r = {}; | 465 | 1.33M | constexpr T zero = {}; | 466 | 1.33M | r = (zero - x) & (alignment - 1); | 467 | 1.33M | return r; | 468 | 1.33M | } |
unsigned long upx::align_up_gap<unsigned long>(unsigned long const&, unsigned long const&) Line | Count | Source | 462 | 2.00M | inline constexpr T align_up_gap(const T &x, const T &alignment) noexcept { | 463 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 464 | 2.00M | T r = {}; | 465 | 2.00M | constexpr T zero = {}; | 466 | 2.00M | r = (zero - x) & (alignment - 1); | 467 | 2.00M | return r; | 468 | 2.00M | } |
long long upx::align_up_gap<long long>(long long const&, long long const&) Line | Count | Source | 462 | 1.00M | inline constexpr T align_up_gap(const T &x, const T &alignment) noexcept { | 463 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 464 | 1.00M | T r = {}; | 465 | 1.00M | constexpr T zero = {}; | 466 | 1.00M | r = (zero - x) & (alignment - 1); | 467 | 1.00M | return r; | 468 | 1.00M | } |
unsigned long long upx::align_up_gap<unsigned long long>(unsigned long long const&, unsigned long long const&) Line | Count | Source | 462 | 668k | inline constexpr T align_up_gap(const T &x, const T &alignment) noexcept { | 463 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 464 | 668k | T r = {}; | 465 | 668k | constexpr T zero = {}; | 466 | 668k | r = (zero - x) & (alignment - 1); | 467 | 668k | return r; | 468 | 668k | } |
__int128 upx::align_up_gap<__int128>(__int128 const&, __int128 const&) Line | Count | Source | 462 | 334k | inline constexpr T align_up_gap(const T &x, const T &alignment) noexcept { | 463 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 464 | 334k | T r = {}; | 465 | 334k | constexpr T zero = {}; | 466 | 334k | r = (zero - x) & (alignment - 1); | 467 | 334k | return r; | 468 | 334k | } |
unsigned __int128 upx::align_up_gap<unsigned __int128>(unsigned __int128 const&, unsigned __int128 const&) Line | Count | Source | 462 | 334k | inline constexpr T align_up_gap(const T &x, const T &alignment) noexcept { | 463 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 464 | 334k | T r = {}; | 465 | 334k | constexpr T zero = {}; | 466 | 334k | r = (zero - x) & (alignment - 1); | 467 | 334k | return r; | 468 | 334k | } |
LE16 upx::align_up_gap<LE16>(LE16 const&, LE16 const&) Line | Count | Source | 462 | 334k | inline constexpr T align_up_gap(const T &x, const T &alignment) noexcept { | 463 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 464 | 334k | T r = {}; | 465 | 334k | constexpr T zero = {}; | 466 | 334k | r = (zero - x) & (alignment - 1); | 467 | 334k | return r; | 468 | 334k | } |
LE32 upx::align_up_gap<LE32>(LE32 const&, LE32 const&) Line | Count | Source | 462 | 334k | inline constexpr T align_up_gap(const T &x, const T &alignment) noexcept { | 463 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 464 | 334k | T r = {}; | 465 | 334k | constexpr T zero = {}; | 466 | 334k | r = (zero - x) & (alignment - 1); | 467 | 334k | return r; | 468 | 334k | } |
LE64 upx::align_up_gap<LE64>(LE64 const&, LE64 const&) Line | Count | Source | 462 | 334k | inline constexpr T align_up_gap(const T &x, const T &alignment) noexcept { | 463 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 464 | 334k | T r = {}; | 465 | 334k | constexpr T zero = {}; | 466 | 334k | r = (zero - x) & (alignment - 1); | 467 | 334k | return r; | 468 | 334k | } |
BE16 upx::align_up_gap<BE16>(BE16 const&, BE16 const&) Line | Count | Source | 462 | 334k | inline constexpr T align_up_gap(const T &x, const T &alignment) noexcept { | 463 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 464 | 334k | T r = {}; | 465 | 334k | constexpr T zero = {}; | 466 | 334k | r = (zero - x) & (alignment - 1); | 467 | 334k | return r; | 468 | 334k | } |
BE32 upx::align_up_gap<BE32>(BE32 const&, BE32 const&) Line | Count | Source | 462 | 334k | inline constexpr T align_up_gap(const T &x, const T &alignment) noexcept { | 463 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 464 | 334k | T r = {}; | 465 | 334k | constexpr T zero = {}; | 466 | 334k | r = (zero - x) & (alignment - 1); | 467 | 334k | return r; | 468 | 334k | } |
BE64 upx::align_up_gap<BE64>(BE64 const&, BE64 const&) Line | Count | Source | 462 | 334k | inline constexpr T align_up_gap(const T &x, const T &alignment) noexcept { | 463 | | // assert_noexcept(has_single_bit(alignment)); // (not constexpr) | 464 | 334k | T r = {}; | 465 | 334k | constexpr T zero = {}; | 466 | 334k | r = (zero - x) & (alignment - 1); | 467 | 334k | return r; | 468 | 334k | } |
|
469 | | |
470 | | template <class T> |
471 | 9.03M | forceinline constexpr T min(const T &a, const T &b) noexcept { |
472 | 9.03M | return b < a ? b : a; |
473 | 9.03M | } char upx::min<char>(char const&, char const&) Line | Count | Source | 471 | 83.6k | forceinline constexpr T min(const T &a, const T &b) noexcept { | 472 | 83.6k | return b < a ? b : a; | 473 | 83.6k | } |
signed char upx::min<signed char>(signed char const&, signed char const&) Line | Count | Source | 471 | 167k | forceinline constexpr T min(const T &a, const T &b) noexcept { | 472 | 167k | return b < a ? b : a; | 473 | 167k | } |
unsigned char upx::min<unsigned char>(unsigned char const&, unsigned char const&) Line | Count | Source | 471 | 167k | forceinline constexpr T min(const T &a, const T &b) noexcept { | 472 | 167k | return b < a ? b : a; | 473 | 167k | } |
short upx::min<short>(short const&, short const&) Line | Count | Source | 471 | 167k | forceinline constexpr T min(const T &a, const T &b) noexcept { | 472 | 167k | return b < a ? b : a; | 473 | 167k | } |
unsigned short upx::min<unsigned short>(unsigned short const&, unsigned short const&) Line | Count | Source | 471 | 167k | forceinline constexpr T min(const T &a, const T &b) noexcept { | 472 | 167k | return b < a ? b : a; | 473 | 167k | } |
int upx::min<int>(int const&, int const&) Line | Count | Source | 471 | 167k | forceinline constexpr T min(const T &a, const T &b) noexcept { | 472 | 167k | return b < a ? b : a; | 473 | 167k | } |
unsigned int upx::min<unsigned int>(unsigned int const&, unsigned int const&) Line | Count | Source | 471 | 2.84M | forceinline constexpr T min(const T &a, const T &b) noexcept { | 472 | 2.84M | return b < a ? b : a; | 473 | 2.84M | } |
long upx::min<long>(long const&, long const&) Line | Count | Source | 471 | 334k | forceinline constexpr T min(const T &a, const T &b) noexcept { | 472 | 334k | return b < a ? b : a; | 473 | 334k | } |
unsigned long upx::min<unsigned long>(unsigned long const&, unsigned long const&) Line | Count | Source | 471 | 501k | forceinline constexpr T min(const T &a, const T &b) noexcept { | 472 | 501k | return b < a ? b : a; | 473 | 501k | } |
long long upx::min<long long>(long long const&, long long const&) Line | Count | Source | 471 | 250k | forceinline constexpr T min(const T &a, const T &b) noexcept { | 472 | 250k | return b < a ? b : a; | 473 | 250k | } |
unsigned long long upx::min<unsigned long long>(unsigned long long const&, unsigned long long const&) Line | Count | Source | 471 | 1.50M | forceinline constexpr T min(const T &a, const T &b) noexcept { | 472 | 1.50M | return b < a ? b : a; | 473 | 1.50M | } |
__int128 upx::min<__int128>(__int128 const&, __int128 const&) Line | Count | Source | 471 | 83.6k | forceinline constexpr T min(const T &a, const T &b) noexcept { | 472 | 83.6k | return b < a ? b : a; | 473 | 83.6k | } |
unsigned __int128 upx::min<unsigned __int128>(unsigned __int128 const&, unsigned __int128 const&) Line | Count | Source | 471 | 83.6k | forceinline constexpr T min(const T &a, const T &b) noexcept { | 472 | 83.6k | return b < a ? b : a; | 473 | 83.6k | } |
LE16 upx::min<LE16>(LE16 const&, LE16 const&) Line | Count | Source | 471 | 418k | forceinline constexpr T min(const T &a, const T &b) noexcept { | 472 | 418k | return b < a ? b : a; | 473 | 418k | } |
LE32 upx::min<LE32>(LE32 const&, LE32 const&) Line | Count | Source | 471 | 418k | forceinline constexpr T min(const T &a, const T &b) noexcept { | 472 | 418k | return b < a ? b : a; | 473 | 418k | } |
LE64 upx::min<LE64>(LE64 const&, LE64 const&) Line | Count | Source | 471 | 418k | forceinline constexpr T min(const T &a, const T &b) noexcept { | 472 | 418k | return b < a ? b : a; | 473 | 418k | } |
BE16 upx::min<BE16>(BE16 const&, BE16 const&) Line | Count | Source | 471 | 418k | forceinline constexpr T min(const T &a, const T &b) noexcept { | 472 | 418k | return b < a ? b : a; | 473 | 418k | } |
BE32 upx::min<BE32>(BE32 const&, BE32 const&) Line | Count | Source | 471 | 418k | forceinline constexpr T min(const T &a, const T &b) noexcept { | 472 | 418k | return b < a ? b : a; | 473 | 418k | } |
BE64 upx::min<BE64>(BE64 const&, BE64 const&) Line | Count | Source | 471 | 418k | forceinline constexpr T min(const T &a, const T &b) noexcept { | 472 | 418k | return b < a ? b : a; | 473 | 418k | } |
|
474 | | template <class T> |
475 | 9.03M | forceinline constexpr T max(const T &a, const T &b) noexcept { |
476 | 9.03M | return a < b ? b : a; |
477 | 9.03M | } char upx::max<char>(char const&, char const&) Line | Count | Source | 475 | 83.6k | forceinline constexpr T max(const T &a, const T &b) noexcept { | 476 | 83.6k | return a < b ? b : a; | 477 | 83.6k | } |
signed char upx::max<signed char>(signed char const&, signed char const&) Line | Count | Source | 475 | 167k | forceinline constexpr T max(const T &a, const T &b) noexcept { | 476 | 167k | return a < b ? b : a; | 477 | 167k | } |
unsigned char upx::max<unsigned char>(unsigned char const&, unsigned char const&) Line | Count | Source | 475 | 167k | forceinline constexpr T max(const T &a, const T &b) noexcept { | 476 | 167k | return a < b ? b : a; | 477 | 167k | } |
short upx::max<short>(short const&, short const&) Line | Count | Source | 475 | 167k | forceinline constexpr T max(const T &a, const T &b) noexcept { | 476 | 167k | return a < b ? b : a; | 477 | 167k | } |
unsigned short upx::max<unsigned short>(unsigned short const&, unsigned short const&) Line | Count | Source | 475 | 167k | forceinline constexpr T max(const T &a, const T &b) noexcept { | 476 | 167k | return a < b ? b : a; | 477 | 167k | } |
int upx::max<int>(int const&, int const&) Line | Count | Source | 475 | 167k | forceinline constexpr T max(const T &a, const T &b) noexcept { | 476 | 167k | return a < b ? b : a; | 477 | 167k | } |
unsigned int upx::max<unsigned int>(unsigned int const&, unsigned int const&) Line | Count | Source | 475 | 2.84M | forceinline constexpr T max(const T &a, const T &b) noexcept { | 476 | 2.84M | return a < b ? b : a; | 477 | 2.84M | } |
long upx::max<long>(long const&, long const&) Line | Count | Source | 475 | 334k | forceinline constexpr T max(const T &a, const T &b) noexcept { | 476 | 334k | return a < b ? b : a; | 477 | 334k | } |
unsigned long upx::max<unsigned long>(unsigned long const&, unsigned long const&) Line | Count | Source | 475 | 501k | forceinline constexpr T max(const T &a, const T &b) noexcept { | 476 | 501k | return a < b ? b : a; | 477 | 501k | } |
long long upx::max<long long>(long long const&, long long const&) Line | Count | Source | 475 | 250k | forceinline constexpr T max(const T &a, const T &b) noexcept { | 476 | 250k | return a < b ? b : a; | 477 | 250k | } |
unsigned long long upx::max<unsigned long long>(unsigned long long const&, unsigned long long const&) Line | Count | Source | 475 | 1.50M | forceinline constexpr T max(const T &a, const T &b) noexcept { | 476 | 1.50M | return a < b ? b : a; | 477 | 1.50M | } |
__int128 upx::max<__int128>(__int128 const&, __int128 const&) Line | Count | Source | 475 | 83.6k | forceinline constexpr T max(const T &a, const T &b) noexcept { | 476 | 83.6k | return a < b ? b : a; | 477 | 83.6k | } |
unsigned __int128 upx::max<unsigned __int128>(unsigned __int128 const&, unsigned __int128 const&) Line | Count | Source | 475 | 83.6k | forceinline constexpr T max(const T &a, const T &b) noexcept { | 476 | 83.6k | return a < b ? b : a; | 477 | 83.6k | } |
LE16 upx::max<LE16>(LE16 const&, LE16 const&) Line | Count | Source | 475 | 418k | forceinline constexpr T max(const T &a, const T &b) noexcept { | 476 | 418k | return a < b ? b : a; | 477 | 418k | } |
LE32 upx::max<LE32>(LE32 const&, LE32 const&) Line | Count | Source | 475 | 418k | forceinline constexpr T max(const T &a, const T &b) noexcept { | 476 | 418k | return a < b ? b : a; | 477 | 418k | } |
LE64 upx::max<LE64>(LE64 const&, LE64 const&) Line | Count | Source | 475 | 418k | forceinline constexpr T max(const T &a, const T &b) noexcept { | 476 | 418k | return a < b ? b : a; | 477 | 418k | } |
BE16 upx::max<BE16>(BE16 const&, BE16 const&) Line | Count | Source | 475 | 418k | forceinline constexpr T max(const T &a, const T &b) noexcept { | 476 | 418k | return a < b ? b : a; | 477 | 418k | } |
BE32 upx::max<BE32>(BE32 const&, BE32 const&) Line | Count | Source | 475 | 418k | forceinline constexpr T max(const T &a, const T &b) noexcept { | 476 | 418k | return a < b ? b : a; | 477 | 418k | } |
BE64 upx::max<BE64>(BE64 const&, BE64 const&) Line | Count | Source | 475 | 418k | forceinline constexpr T max(const T &a, const T &b) noexcept { | 476 | 418k | return a < b ? b : a; | 477 | 418k | } |
|
478 | | |
479 | | template <class T> |
480 | | inline constexpr bool is_uminmax_type = std::is_integral_v<T> && std::is_unsigned_v<T>; |
481 | | |
482 | | template <class T, class = std::enable_if_t<is_uminmax_type<T>, T> > |
483 | 8.98k | forceinline constexpr T umin(const T &a, const T &b) noexcept { |
484 | 8.98k | return b < a ? b : a; |
485 | 8.98k | } Unexecuted instantiation: unsigned char upx::umin<unsigned char, unsigned char>(unsigned char const&, unsigned char const&) Unexecuted instantiation: unsigned short upx::umin<unsigned short, unsigned short>(unsigned short const&, unsigned short const&) unsigned int upx::umin<unsigned int, unsigned int>(unsigned int const&, unsigned int const&) Line | Count | Source | 483 | 5.68k | forceinline constexpr T umin(const T &a, const T &b) noexcept { | 484 | 5.68k | return b < a ? b : a; | 485 | 5.68k | } |
unsigned long long upx::umin<unsigned long long, unsigned long long>(unsigned long long const&, unsigned long long const&) Line | Count | Source | 483 | 3.29k | forceinline constexpr T umin(const T &a, const T &b) noexcept { | 484 | 3.29k | return b < a ? b : a; | 485 | 3.29k | } |
Unexecuted instantiation: unsigned long upx::umin<unsigned long, unsigned long>(unsigned long const&, unsigned long const&) |
486 | | template <class T, class = std::enable_if_t<is_uminmax_type<T>, T> > |
487 | 420k | forceinline constexpr T umax(const T &a, const T &b) noexcept { |
488 | 420k | return a < b ? b : a; |
489 | 420k | } Unexecuted instantiation: unsigned char upx::umax<unsigned char, unsigned char>(unsigned char const&, unsigned char const&) Unexecuted instantiation: unsigned short upx::umax<unsigned short, unsigned short>(unsigned short const&, unsigned short const&) unsigned int upx::umax<unsigned int, unsigned int>(unsigned int const&, unsigned int const&) Line | Count | Source | 487 | 2.18k | forceinline constexpr T umax(const T &a, const T &b) noexcept { | 488 | 2.18k | return a < b ? b : a; | 489 | 2.18k | } |
Unexecuted instantiation: unsigned long long upx::umax<unsigned long long, unsigned long long>(unsigned long long const&, unsigned long long const&) unsigned long upx::umax<unsigned long, unsigned long>(unsigned long const&, unsigned long const&) Line | Count | Source | 487 | 418k | forceinline constexpr T umax(const T &a, const T &b) noexcept { | 488 | 418k | return a < b ? b : a; | 489 | 418k | } |
|
490 | | |
491 | | template <class T> |
492 | 0 | forceinline constexpr T wrapping_add(const T &a, const T &b) noexcept { |
493 | 0 | static_assert(std::is_integral_v<T>); |
494 | 0 | typedef std::make_unsigned_t<T> U; |
495 | 0 | return T(U(a) + U(b)); |
496 | 0 | } Unexecuted instantiation: signed char upx::wrapping_add<signed char>(signed char const&, signed char const&) Unexecuted instantiation: short upx::wrapping_add<short>(short const&, short const&) Unexecuted instantiation: int upx::wrapping_add<int>(int const&, int const&) Unexecuted instantiation: long long upx::wrapping_add<long long>(long long const&, long long const&) Unexecuted instantiation: unsigned char upx::wrapping_add<unsigned char>(unsigned char const&, unsigned char const&) |
497 | | template <class T> |
498 | 0 | forceinline constexpr T wrapping_sub(const T &a, const T &b) noexcept { |
499 | 0 | static_assert(std::is_integral_v<T>); |
500 | 0 | typedef std::make_unsigned_t<T> U; |
501 | 0 | return T(U(a) - U(b)); |
502 | 0 | } Unexecuted instantiation: signed char upx::wrapping_sub<signed char>(signed char const&, signed char const&) Unexecuted instantiation: short upx::wrapping_sub<short>(short const&, short const&) Unexecuted instantiation: int upx::wrapping_sub<int>(int const&, int const&) Unexecuted instantiation: long long upx::wrapping_sub<long long>(long long const&, long long const&) Unexecuted instantiation: unsigned char upx::wrapping_sub<unsigned char>(unsigned char const&, unsigned char const&) |
503 | | |
504 | | /************************************************************************* |
505 | | // util |
506 | | **************************************************************************/ |
507 | | |
508 | | template <std::size_t Size> |
509 | | struct UnsignedSizeOf final { |
510 | | static_assert(Size >= 1 && Size <= UPX_RSIZE_MAX_MEM); |
511 | | static constexpr unsigned value = unsigned(Size); |
512 | | }; |
513 | | |
514 | | // a static_cast that does not trigger -Wcast-align warnings |
515 | | template <class Result, class From> |
516 | 1.63M | forceinline constexpr Result ptr_static_cast(From *ptr) noexcept { |
517 | 1.63M | static_assert(std::is_pointer_v<Result>); |
518 | | // don't cast through "void *" if type is convertible |
519 | 1.63M | typedef std::conditional_t<std::is_convertible_v<decltype(ptr), Result>, Result, void *> |
520 | 1.63M | VoidPtr; |
521 | | // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion) |
522 | 1.63M | return static_cast<Result>(static_cast<VoidPtr>(ptr)); |
523 | 1.63M | } unsigned char* upx::ptr_static_cast<unsigned char*, void>(void*) Line | Count | Source | 516 | 104k | forceinline constexpr Result ptr_static_cast(From *ptr) noexcept { | 517 | 104k | static_assert(std::is_pointer_v<Result>); | 518 | | // don't cast through "void *" if type is convertible | 519 | 104k | typedef std::conditional_t<std::is_convertible_v<decltype(ptr), Result>, Result, void *> | 520 | 104k | VoidPtr; | 521 | | // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion) | 522 | 104k | return static_cast<Result>(static_cast<VoidPtr>(ptr)); | 523 | 104k | } |
unsigned char* upx::ptr_static_cast<unsigned char*, unsigned short>(unsigned short*) Line | Count | Source | 516 | 41.8k | forceinline constexpr Result ptr_static_cast(From *ptr) noexcept { | 517 | 41.8k | static_assert(std::is_pointer_v<Result>); | 518 | | // don't cast through "void *" if type is convertible | 519 | 41.8k | typedef std::conditional_t<std::is_convertible_v<decltype(ptr), Result>, Result, void *> | 520 | 41.8k | VoidPtr; | 521 | | // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion) | 522 | 41.8k | return static_cast<Result>(static_cast<VoidPtr>(ptr)); | 523 | 41.8k | } |
unsigned char* upx::ptr_static_cast<unsigned char*, unsigned int>(unsigned int*) Line | Count | Source | 516 | 41.8k | forceinline constexpr Result ptr_static_cast(From *ptr) noexcept { | 517 | 41.8k | static_assert(std::is_pointer_v<Result>); | 518 | | // don't cast through "void *" if type is convertible | 519 | 41.8k | typedef std::conditional_t<std::is_convertible_v<decltype(ptr), Result>, Result, void *> | 520 | 41.8k | VoidPtr; | 521 | | // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion) | 522 | 41.8k | return static_cast<Result>(static_cast<VoidPtr>(ptr)); | 523 | 41.8k | } |
unsigned char* upx::ptr_static_cast<unsigned char*, unsigned long long>(unsigned long long*) Line | Count | Source | 516 | 41.8k | forceinline constexpr Result ptr_static_cast(From *ptr) noexcept { | 517 | 41.8k | static_assert(std::is_pointer_v<Result>); | 518 | | // don't cast through "void *" if type is convertible | 519 | 41.8k | typedef std::conditional_t<std::is_convertible_v<decltype(ptr), Result>, Result, void *> | 520 | 41.8k | VoidPtr; | 521 | | // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion) | 522 | 41.8k | return static_cast<Result>(static_cast<VoidPtr>(ptr)); | 523 | 41.8k | } |
void* upx::ptr_static_cast<void*, void>(void*) Line | Count | Source | 516 | 20.9k | forceinline constexpr Result ptr_static_cast(From *ptr) noexcept { | 517 | 20.9k | static_assert(std::is_pointer_v<Result>); | 518 | | // don't cast through "void *" if type is convertible | 519 | 20.9k | typedef std::conditional_t<std::is_convertible_v<decltype(ptr), Result>, Result, void *> | 520 | 20.9k | VoidPtr; | 521 | | // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion) | 522 | 20.9k | return static_cast<Result>(static_cast<VoidPtr>(ptr)); | 523 | 20.9k | } |
void* upx::ptr_static_cast<void*, unsigned char>(unsigned char*) Line | Count | Source | 516 | 20.9k | forceinline constexpr Result ptr_static_cast(From *ptr) noexcept { | 517 | 20.9k | static_assert(std::is_pointer_v<Result>); | 518 | | // don't cast through "void *" if type is convertible | 519 | 20.9k | typedef std::conditional_t<std::is_convertible_v<decltype(ptr), Result>, Result, void *> | 520 | 20.9k | VoidPtr; | 521 | | // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion) | 522 | 20.9k | return static_cast<Result>(static_cast<VoidPtr>(ptr)); | 523 | 20.9k | } |
void* upx::ptr_static_cast<void*, int>(int*) Line | Count | Source | 516 | 20.9k | forceinline constexpr Result ptr_static_cast(From *ptr) noexcept { | 517 | 20.9k | static_assert(std::is_pointer_v<Result>); | 518 | | // don't cast through "void *" if type is convertible | 519 | 20.9k | typedef std::conditional_t<std::is_convertible_v<decltype(ptr), Result>, Result, void *> | 520 | 20.9k | VoidPtr; | 521 | | // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion) | 522 | 20.9k | return static_cast<Result>(static_cast<VoidPtr>(ptr)); | 523 | 20.9k | } |
void* upx::ptr_static_cast<void*, double>(double*) Line | Count | Source | 516 | 20.9k | forceinline constexpr Result ptr_static_cast(From *ptr) noexcept { | 517 | 20.9k | static_assert(std::is_pointer_v<Result>); | 518 | | // don't cast through "void *" if type is convertible | 519 | 20.9k | typedef std::conditional_t<std::is_convertible_v<decltype(ptr), Result>, Result, void *> | 520 | 20.9k | VoidPtr; | 521 | | // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion) | 522 | 20.9k | return static_cast<Result>(static_cast<VoidPtr>(ptr)); | 523 | 20.9k | } |
unsigned char* upx::ptr_static_cast<unsigned char*, unsigned char>(unsigned char*) Line | Count | Source | 516 | 550k | forceinline constexpr Result ptr_static_cast(From *ptr) noexcept { | 517 | 550k | static_assert(std::is_pointer_v<Result>); | 518 | | // don't cast through "void *" if type is convertible | 519 | 550k | typedef std::conditional_t<std::is_convertible_v<decltype(ptr), Result>, Result, void *> | 520 | 550k | VoidPtr; | 521 | | // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion) | 522 | 550k | return static_cast<Result>(static_cast<VoidPtr>(ptr)); | 523 | 550k | } |
unsigned char* upx::ptr_static_cast<unsigned char*, int>(int*) Line | Count | Source | 516 | 41.8k | forceinline constexpr Result ptr_static_cast(From *ptr) noexcept { | 517 | 41.8k | static_assert(std::is_pointer_v<Result>); | 518 | | // don't cast through "void *" if type is convertible | 519 | 41.8k | typedef std::conditional_t<std::is_convertible_v<decltype(ptr), Result>, Result, void *> | 520 | 41.8k | VoidPtr; | 521 | | // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion) | 522 | 41.8k | return static_cast<Result>(static_cast<VoidPtr>(ptr)); | 523 | 41.8k | } |
unsigned char* upx::ptr_static_cast<unsigned char*, double>(double*) Line | Count | Source | 516 | 20.9k | forceinline constexpr Result ptr_static_cast(From *ptr) noexcept { | 517 | 20.9k | static_assert(std::is_pointer_v<Result>); | 518 | | // don't cast through "void *" if type is convertible | 519 | 20.9k | typedef std::conditional_t<std::is_convertible_v<decltype(ptr), Result>, Result, void *> | 520 | 20.9k | VoidPtr; | 521 | | // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion) | 522 | 20.9k | return static_cast<Result>(static_cast<VoidPtr>(ptr)); | 523 | 20.9k | } |
int* upx::ptr_static_cast<int*, void>(void*) Line | Count | Source | 516 | 20.9k | forceinline constexpr Result ptr_static_cast(From *ptr) noexcept { | 517 | 20.9k | static_assert(std::is_pointer_v<Result>); | 518 | | // don't cast through "void *" if type is convertible | 519 | 20.9k | typedef std::conditional_t<std::is_convertible_v<decltype(ptr), Result>, Result, void *> | 520 | 20.9k | VoidPtr; | 521 | | // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion) | 522 | 20.9k | return static_cast<Result>(static_cast<VoidPtr>(ptr)); | 523 | 20.9k | } |
int* upx::ptr_static_cast<int*, unsigned char>(unsigned char*) Line | Count | Source | 516 | 41.8k | forceinline constexpr Result ptr_static_cast(From *ptr) noexcept { | 517 | 41.8k | static_assert(std::is_pointer_v<Result>); | 518 | | // don't cast through "void *" if type is convertible | 519 | 41.8k | typedef std::conditional_t<std::is_convertible_v<decltype(ptr), Result>, Result, void *> | 520 | 41.8k | VoidPtr; | 521 | | // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion) | 522 | 41.8k | return static_cast<Result>(static_cast<VoidPtr>(ptr)); | 523 | 41.8k | } |
int* upx::ptr_static_cast<int*, int>(int*) Line | Count | Source | 516 | 41.8k | forceinline constexpr Result ptr_static_cast(From *ptr) noexcept { | 517 | 41.8k | static_assert(std::is_pointer_v<Result>); | 518 | | // don't cast through "void *" if type is convertible | 519 | 41.8k | typedef std::conditional_t<std::is_convertible_v<decltype(ptr), Result>, Result, void *> | 520 | 41.8k | VoidPtr; | 521 | | // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion) | 522 | 41.8k | return static_cast<Result>(static_cast<VoidPtr>(ptr)); | 523 | 41.8k | } |
int* upx::ptr_static_cast<int*, double>(double*) Line | Count | Source | 516 | 20.9k | forceinline constexpr Result ptr_static_cast(From *ptr) noexcept { | 517 | 20.9k | static_assert(std::is_pointer_v<Result>); | 518 | | // don't cast through "void *" if type is convertible | 519 | 20.9k | typedef std::conditional_t<std::is_convertible_v<decltype(ptr), Result>, Result, void *> | 520 | 20.9k | VoidPtr; | 521 | | // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion) | 522 | 20.9k | return static_cast<Result>(static_cast<VoidPtr>(ptr)); | 523 | 20.9k | } |
double* upx::ptr_static_cast<double*, void>(void*) Line | Count | Source | 516 | 20.9k | forceinline constexpr Result ptr_static_cast(From *ptr) noexcept { | 517 | 20.9k | static_assert(std::is_pointer_v<Result>); | 518 | | // don't cast through "void *" if type is convertible | 519 | 20.9k | typedef std::conditional_t<std::is_convertible_v<decltype(ptr), Result>, Result, void *> | 520 | 20.9k | VoidPtr; | 521 | | // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion) | 522 | 20.9k | return static_cast<Result>(static_cast<VoidPtr>(ptr)); | 523 | 20.9k | } |
double* upx::ptr_static_cast<double*, unsigned char>(unsigned char*) Line | Count | Source | 516 | 20.9k | forceinline constexpr Result ptr_static_cast(From *ptr) noexcept { | 517 | 20.9k | static_assert(std::is_pointer_v<Result>); | 518 | | // don't cast through "void *" if type is convertible | 519 | 20.9k | typedef std::conditional_t<std::is_convertible_v<decltype(ptr), Result>, Result, void *> | 520 | 20.9k | VoidPtr; | 521 | | // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion) | 522 | 20.9k | return static_cast<Result>(static_cast<VoidPtr>(ptr)); | 523 | 20.9k | } |
double* upx::ptr_static_cast<double*, int>(int*) Line | Count | Source | 516 | 20.9k | forceinline constexpr Result ptr_static_cast(From *ptr) noexcept { | 517 | 20.9k | static_assert(std::is_pointer_v<Result>); | 518 | | // don't cast through "void *" if type is convertible | 519 | 20.9k | typedef std::conditional_t<std::is_convertible_v<decltype(ptr), Result>, Result, void *> | 520 | 20.9k | VoidPtr; | 521 | | // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion) | 522 | 20.9k | return static_cast<Result>(static_cast<VoidPtr>(ptr)); | 523 | 20.9k | } |
double* upx::ptr_static_cast<double*, double>(double*) Line | Count | Source | 516 | 20.9k | forceinline constexpr Result ptr_static_cast(From *ptr) noexcept { | 517 | 20.9k | static_assert(std::is_pointer_v<Result>); | 518 | | // don't cast through "void *" if type is convertible | 519 | 20.9k | typedef std::conditional_t<std::is_convertible_v<decltype(ptr), Result>, Result, void *> | 520 | 20.9k | VoidPtr; | 521 | | // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion) | 522 | 20.9k | return static_cast<Result>(static_cast<VoidPtr>(ptr)); | 523 | 20.9k | } |
Unexecuted instantiation: void** upx::ptr_static_cast<void**, void*>(void**) Unexecuted instantiation: unsigned char** upx::ptr_static_cast<unsigned char**, unsigned char*>(unsigned char**) Unexecuted instantiation: int** upx::ptr_static_cast<int**, int*>(int**) Unexecuted instantiation: double** upx::ptr_static_cast<double**, double*>(double**) Unexecuted instantiation: void const** upx::ptr_static_cast<void const**, void const*>(void const**) Unexecuted instantiation: unsigned char const** upx::ptr_static_cast<unsigned char const**, unsigned char const*>(unsigned char const**) Unexecuted instantiation: int const** upx::ptr_static_cast<int const**, int const*>(int const**) Unexecuted instantiation: double const** upx::ptr_static_cast<double const**, double const*>(double const**) Unexecuted instantiation: void const* upx::ptr_static_cast<void const*, void>(void*) Unexecuted instantiation: void const* upx::ptr_static_cast<void const*, double>(double*) Unexecuted instantiation: void const* upx::ptr_static_cast<void const*, unsigned char>(unsigned char*) Unexecuted instantiation: void const* upx::ptr_static_cast<void const*, int>(int*) unsigned short* upx::ptr_static_cast<unsigned short*, char>(char*) Line | Count | Source | 516 | 501k | forceinline constexpr Result ptr_static_cast(From *ptr) noexcept { | 517 | 501k | static_assert(std::is_pointer_v<Result>); | 518 | | // don't cast through "void *" if type is convertible | 519 | 501k | typedef std::conditional_t<std::is_convertible_v<decltype(ptr), Result>, Result, void *> | 520 | 501k | VoidPtr; | 521 | | // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion) | 522 | 501k | return static_cast<Result>(static_cast<VoidPtr>(ptr)); | 523 | 501k | } |
Unexecuted instantiation: unsigned char* upx::ptr_static_cast<unsigned char*, LE32>(LE32*) Unexecuted instantiation: unsigned char* upx::ptr_static_cast<unsigned char*, LE16>(LE16*) unsigned char* upx::ptr_static_cast<unsigned char*, PeFile::Reloc::BaseReloc>(PeFile::Reloc::BaseReloc*) Line | Count | Source | 516 | 1.08k | forceinline constexpr Result ptr_static_cast(From *ptr) noexcept { | 517 | 1.08k | static_assert(std::is_pointer_v<Result>); | 518 | | // don't cast through "void *" if type is convertible | 519 | 1.08k | typedef std::conditional_t<std::is_convertible_v<decltype(ptr), Result>, Result, void *> | 520 | 1.08k | VoidPtr; | 521 | | // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion) | 522 | 1.08k | return static_cast<Result>(static_cast<VoidPtr>(ptr)); | 523 | 1.08k | } |
Unexecuted instantiation: unsigned char* upx::ptr_static_cast<unsigned char*, char>(char*) PeFile::Reloc::BaseReloc* upx::ptr_static_cast<PeFile::Reloc::BaseReloc*, unsigned char>(unsigned char*) Line | Count | Source | 516 | 10 | forceinline constexpr Result ptr_static_cast(From *ptr) noexcept { | 517 | 10 | static_assert(std::is_pointer_v<Result>); | 518 | | // don't cast through "void *" if type is convertible | 519 | 10 | typedef std::conditional_t<std::is_convertible_v<decltype(ptr), Result>, Result, void *> | 520 | 10 | VoidPtr; | 521 | | // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion) | 522 | 10 | return static_cast<Result>(static_cast<VoidPtr>(ptr)); | 523 | 10 | } |
LE16* upx::ptr_static_cast<LE16*, unsigned char>(unsigned char*) Line | Count | Source | 516 | 10 | forceinline constexpr Result ptr_static_cast(From *ptr) noexcept { | 517 | 10 | static_assert(std::is_pointer_v<Result>); | 518 | | // don't cast through "void *" if type is convertible | 519 | 10 | typedef std::conditional_t<std::is_convertible_v<decltype(ptr), Result>, Result, void *> | 520 | 10 | VoidPtr; | 521 | | // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion) | 522 | 10 | return static_cast<Result>(static_cast<VoidPtr>(ptr)); | 523 | 10 | } |
|
524 | | template <class Result, class From> |
525 | 5.69M | forceinline constexpr Result ptr_static_cast(const From *ptr) noexcept { |
526 | 5.69M | static_assert(std::is_pointer_v<Result>); |
527 | 5.69M | static_assert(std::is_const_v<std::remove_pointer_t<Result> >); // required |
528 | | // don't cast through "const void *" if type is convertible |
529 | 5.69M | typedef std::conditional_t<std::is_convertible_v<decltype(ptr), Result>, Result, const void *> |
530 | 5.69M | VoidPtr; |
531 | | // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion) |
532 | 5.69M | return static_cast<Result>(static_cast<VoidPtr>(ptr)); |
533 | 5.69M | } unsigned char const* upx::ptr_static_cast<unsigned char const*, void>(void const*) Line | Count | Source | 525 | 5.39M | forceinline constexpr Result ptr_static_cast(const From *ptr) noexcept { | 526 | 5.39M | static_assert(std::is_pointer_v<Result>); | 527 | 5.39M | static_assert(std::is_const_v<std::remove_pointer_t<Result> >); // required | 528 | | // don't cast through "const void *" if type is convertible | 529 | 5.39M | typedef std::conditional_t<std::is_convertible_v<decltype(ptr), Result>, Result, const void *> | 530 | 5.39M | VoidPtr; | 531 | | // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion) | 532 | 5.39M | return static_cast<Result>(static_cast<VoidPtr>(ptr)); | 533 | 5.39M | } |
unsigned char const* upx::ptr_static_cast<unsigned char const*, unsigned short>(unsigned short const*) Line | Count | Source | 525 | 41.8k | forceinline constexpr Result ptr_static_cast(const From *ptr) noexcept { | 526 | 41.8k | static_assert(std::is_pointer_v<Result>); | 527 | 41.8k | static_assert(std::is_const_v<std::remove_pointer_t<Result> >); // required | 528 | | // don't cast through "const void *" if type is convertible | 529 | 41.8k | typedef std::conditional_t<std::is_convertible_v<decltype(ptr), Result>, Result, const void *> | 530 | 41.8k | VoidPtr; | 531 | | // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion) | 532 | 41.8k | return static_cast<Result>(static_cast<VoidPtr>(ptr)); | 533 | 41.8k | } |
unsigned char const* upx::ptr_static_cast<unsigned char const*, unsigned int>(unsigned int const*) Line | Count | Source | 525 | 41.8k | forceinline constexpr Result ptr_static_cast(const From *ptr) noexcept { | 526 | 41.8k | static_assert(std::is_pointer_v<Result>); | 527 | 41.8k | static_assert(std::is_const_v<std::remove_pointer_t<Result> >); // required | 528 | | // don't cast through "const void *" if type is convertible | 529 | 41.8k | typedef std::conditional_t<std::is_convertible_v<decltype(ptr), Result>, Result, const void *> | 530 | 41.8k | VoidPtr; | 531 | | // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion) | 532 | 41.8k | return static_cast<Result>(static_cast<VoidPtr>(ptr)); | 533 | 41.8k | } |
unsigned char const* upx::ptr_static_cast<unsigned char const*, unsigned long long>(unsigned long long const*) Line | Count | Source | 525 | 41.8k | forceinline constexpr Result ptr_static_cast(const From *ptr) noexcept { | 526 | 41.8k | static_assert(std::is_pointer_v<Result>); | 527 | 41.8k | static_assert(std::is_const_v<std::remove_pointer_t<Result> >); // required | 528 | | // don't cast through "const void *" if type is convertible | 529 | 41.8k | typedef std::conditional_t<std::is_convertible_v<decltype(ptr), Result>, Result, const void *> | 530 | 41.8k | VoidPtr; | 531 | | // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion) | 532 | 41.8k | return static_cast<Result>(static_cast<VoidPtr>(ptr)); | 533 | 41.8k | } |
unsigned char const* upx::ptr_static_cast<unsigned char const*, unsigned char>(unsigned char const*) Line | Count | Source | 525 | 20.9k | forceinline constexpr Result ptr_static_cast(const From *ptr) noexcept { | 526 | 20.9k | static_assert(std::is_pointer_v<Result>); | 527 | 20.9k | static_assert(std::is_const_v<std::remove_pointer_t<Result> >); // required | 528 | | // don't cast through "const void *" if type is convertible | 529 | 20.9k | typedef std::conditional_t<std::is_convertible_v<decltype(ptr), Result>, Result, const void *> | 530 | 20.9k | VoidPtr; | 531 | | // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion) | 532 | 20.9k | return static_cast<Result>(static_cast<VoidPtr>(ptr)); | 533 | 20.9k | } |
unsigned char const* upx::ptr_static_cast<unsigned char const*, int>(int const*) Line | Count | Source | 525 | 20.9k | forceinline constexpr Result ptr_static_cast(const From *ptr) noexcept { | 526 | 20.9k | static_assert(std::is_pointer_v<Result>); | 527 | 20.9k | static_assert(std::is_const_v<std::remove_pointer_t<Result> >); // required | 528 | | // don't cast through "const void *" if type is convertible | 529 | 20.9k | typedef std::conditional_t<std::is_convertible_v<decltype(ptr), Result>, Result, const void *> | 530 | 20.9k | VoidPtr; | 531 | | // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion) | 532 | 20.9k | return static_cast<Result>(static_cast<VoidPtr>(ptr)); | 533 | 20.9k | } |
int const* upx::ptr_static_cast<int const*, unsigned char>(unsigned char const*) Line | Count | Source | 525 | 20.9k | forceinline constexpr Result ptr_static_cast(const From *ptr) noexcept { | 526 | 20.9k | static_assert(std::is_pointer_v<Result>); | 527 | 20.9k | static_assert(std::is_const_v<std::remove_pointer_t<Result> >); // required | 528 | | // don't cast through "const void *" if type is convertible | 529 | 20.9k | typedef std::conditional_t<std::is_convertible_v<decltype(ptr), Result>, Result, const void *> | 530 | 20.9k | VoidPtr; | 531 | | // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion) | 532 | 20.9k | return static_cast<Result>(static_cast<VoidPtr>(ptr)); | 533 | 20.9k | } |
int const* upx::ptr_static_cast<int const*, int>(int const*) Line | Count | Source | 525 | 20.9k | forceinline constexpr Result ptr_static_cast(const From *ptr) noexcept { | 526 | 20.9k | static_assert(std::is_pointer_v<Result>); | 527 | 20.9k | static_assert(std::is_const_v<std::remove_pointer_t<Result> >); // required | 528 | | // don't cast through "const void *" if type is convertible | 529 | 20.9k | typedef std::conditional_t<std::is_convertible_v<decltype(ptr), Result>, Result, const void *> | 530 | 20.9k | VoidPtr; | 531 | | // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion) | 532 | 20.9k | return static_cast<Result>(static_cast<VoidPtr>(ptr)); | 533 | 20.9k | } |
Unexecuted instantiation: void const* upx::ptr_static_cast<void const*, void>(void const*) Unexecuted instantiation: double const* upx::ptr_static_cast<double const*, double>(double const*) Unexecuted instantiation: void* const* upx::ptr_static_cast<void* const*, void*>(void* const*) Unexecuted instantiation: unsigned char* const* upx::ptr_static_cast<unsigned char* const*, unsigned char*>(unsigned char* const*) Unexecuted instantiation: int* const* upx::ptr_static_cast<int* const*, int*>(int* const*) Unexecuted instantiation: double* const* upx::ptr_static_cast<double* const*, double*>(double* const*) Unexecuted instantiation: void const* const* upx::ptr_static_cast<void const* const*, void const*>(void const* const*) Unexecuted instantiation: unsigned char const* const* upx::ptr_static_cast<unsigned char const* const*, unsigned char const*>(unsigned char const* const*) Unexecuted instantiation: int const* const* upx::ptr_static_cast<int const* const*, int const*>(int const* const*) Unexecuted instantiation: double const* const* upx::ptr_static_cast<double const* const*, double const*>(double const* const*) Unexecuted instantiation: void const* upx::ptr_static_cast<void const*, double>(double const*) Unexecuted instantiation: void const* upx::ptr_static_cast<void const*, unsigned char>(unsigned char const*) Unexecuted instantiation: void const* upx::ptr_static_cast<void const*, int>(int const*) unsigned char const* upx::ptr_static_cast<unsigned char const*, LE16>(LE16 const*) Line | Count | Source | 525 | 81.2k | forceinline constexpr Result ptr_static_cast(const From *ptr) noexcept { | 526 | 81.2k | static_assert(std::is_pointer_v<Result>); | 527 | 81.2k | static_assert(std::is_const_v<std::remove_pointer_t<Result> >); // required | 528 | | // don't cast through "const void *" if type is convertible | 529 | 81.2k | typedef std::conditional_t<std::is_convertible_v<decltype(ptr), Result>, Result, const void *> | 530 | 81.2k | VoidPtr; | 531 | | // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion) | 532 | 81.2k | return static_cast<Result>(static_cast<VoidPtr>(ptr)); | 533 | 81.2k | } |
unsigned char const* upx::ptr_static_cast<unsigned char const*, LE32>(LE32 const*) Line | Count | Source | 525 | 1.78k | forceinline constexpr Result ptr_static_cast(const From *ptr) noexcept { | 526 | 1.78k | static_assert(std::is_pointer_v<Result>); | 527 | 1.78k | static_assert(std::is_const_v<std::remove_pointer_t<Result> >); // required | 528 | | // don't cast through "const void *" if type is convertible | 529 | 1.78k | typedef std::conditional_t<std::is_convertible_v<decltype(ptr), Result>, Result, const void *> | 530 | 1.78k | VoidPtr; | 531 | | // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion) | 532 | 1.78k | return static_cast<Result>(static_cast<VoidPtr>(ptr)); | 533 | 1.78k | } |
Unexecuted instantiation: unsigned char const* upx::ptr_static_cast<unsigned char const*, char>(char const*) Unexecuted instantiation: LE32 const* upx::ptr_static_cast<LE32 const*, unsigned char>(unsigned char const*) |
534 | | |
535 | | #if WITH_THREADS |
536 | | // cast "T *" to "std::atomic<T> *" |
537 | | template <class T> |
538 | | forceinline std::atomic<T> *ptr_std_atomic_cast(T *ptr) noexcept { |
539 | | // TODO later: make sure that this cast is indeed legal |
540 | | std::atomic<T> *result = ptr_static_cast<std::atomic<T> *>(ptr); |
541 | | static_assert(sizeof(*result) == sizeof(*ptr)); |
542 | | static_assert(alignof(decltype(*result)) == alignof(decltype(*ptr))); |
543 | | return result; |
544 | | } |
545 | | #endif // WITH_THREADS |
546 | | |
547 | | // atomic_exchange |
548 | | template <class T> |
549 | 313k | forceinline T atomic_exchange(T *ptr, T new_value) noexcept { |
550 | 313k | #if 1 |
551 | 313k | static_assert(sizeof(T) == sizeof(void *)); // UPX convention: restrict to pointer-size for now |
552 | 313k | #endif |
553 | 313k | static_assert(std::is_standard_layout_v<T>); |
554 | 313k | static_assert(std::is_trivially_copyable_v<T>); |
555 | 313k | #if !(WITH_THREADS) |
556 | 313k | T old_value = *ptr; |
557 | 313k | *ptr = new_value; |
558 | 313k | return old_value; |
559 | | #else |
560 | | static_assert(sizeof(T) <= sizeof(void *)); // UPX convention: restrict to fundamental types |
561 | | static_assert(alignof(T) == sizeof(T)); // UPX convention: require proper alignment |
562 | | #if __has_builtin(__atomic_exchange_n) && defined(__ATOMIC_SEQ_CST) |
563 | | return __atomic_exchange_n(ptr, new_value, __ATOMIC_SEQ_CST); |
564 | | #elif __has_builtin(__sync_swap) |
565 | | return __sync_swap(ptr, new_value); |
566 | | #else |
567 | | return std::atomic_exchange(ptr_std_atomic_cast(ptr), new_value); |
568 | | #endif |
569 | | #endif |
570 | 313k | } unsigned long upx::atomic_exchange<unsigned long>(unsigned long*, unsigned long) Line | Count | Source | 549 | 20.9k | forceinline T atomic_exchange(T *ptr, T new_value) noexcept { | 550 | 20.9k | #if 1 | 551 | 20.9k | static_assert(sizeof(T) == sizeof(void *)); // UPX convention: restrict to pointer-size for now | 552 | 20.9k | #endif | 553 | 20.9k | static_assert(std::is_standard_layout_v<T>); | 554 | 20.9k | static_assert(std::is_trivially_copyable_v<T>); | 555 | 20.9k | #if !(WITH_THREADS) | 556 | 20.9k | T old_value = *ptr; | 557 | 20.9k | *ptr = new_value; | 558 | 20.9k | return old_value; | 559 | | #else | 560 | | static_assert(sizeof(T) <= sizeof(void *)); // UPX convention: restrict to fundamental types | 561 | | static_assert(alignof(T) == sizeof(T)); // UPX convention: require proper alignment | 562 | | #if __has_builtin(__atomic_exchange_n) && defined(__ATOMIC_SEQ_CST) | 563 | | return __atomic_exchange_n(ptr, new_value, __ATOMIC_SEQ_CST); | 564 | | #elif __has_builtin(__sync_swap) | 565 | | return __sync_swap(ptr, new_value); | 566 | | #else | 567 | | return std::atomic_exchange(ptr_std_atomic_cast(ptr), new_value); | 568 | | #endif | 569 | | #endif | 570 | 20.9k | } |
int const* upx::atomic_exchange<int const*>(int const**, int const*) Line | Count | Source | 549 | 41.8k | forceinline T atomic_exchange(T *ptr, T new_value) noexcept { | 550 | 41.8k | #if 1 | 551 | 41.8k | static_assert(sizeof(T) == sizeof(void *)); // UPX convention: restrict to pointer-size for now | 552 | 41.8k | #endif | 553 | 41.8k | static_assert(std::is_standard_layout_v<T>); | 554 | 41.8k | static_assert(std::is_trivially_copyable_v<T>); | 555 | 41.8k | #if !(WITH_THREADS) | 556 | 41.8k | T old_value = *ptr; | 557 | 41.8k | *ptr = new_value; | 558 | 41.8k | return old_value; | 559 | | #else | 560 | | static_assert(sizeof(T) <= sizeof(void *)); // UPX convention: restrict to fundamental types | 561 | | static_assert(alignof(T) == sizeof(T)); // UPX convention: require proper alignment | 562 | | #if __has_builtin(__atomic_exchange_n) && defined(__ATOMIC_SEQ_CST) | 563 | | return __atomic_exchange_n(ptr, new_value, __ATOMIC_SEQ_CST); | 564 | | #elif __has_builtin(__sync_swap) | 565 | | return __sync_swap(ptr, new_value); | 566 | | #else | 567 | | return std::atomic_exchange(ptr_std_atomic_cast(ptr), new_value); | 568 | | #endif | 569 | | #endif | 570 | 41.8k | } |
LE64* upx::atomic_exchange<LE64*>(LE64**, LE64*) Line | Count | Source | 549 | 41.8k | forceinline T atomic_exchange(T *ptr, T new_value) noexcept { | 550 | 41.8k | #if 1 | 551 | 41.8k | static_assert(sizeof(T) == sizeof(void *)); // UPX convention: restrict to pointer-size for now | 552 | 41.8k | #endif | 553 | 41.8k | static_assert(std::is_standard_layout_v<T>); | 554 | 41.8k | static_assert(std::is_trivially_copyable_v<T>); | 555 | 41.8k | #if !(WITH_THREADS) | 556 | 41.8k | T old_value = *ptr; | 557 | 41.8k | *ptr = new_value; | 558 | 41.8k | return old_value; | 559 | | #else | 560 | | static_assert(sizeof(T) <= sizeof(void *)); // UPX convention: restrict to fundamental types | 561 | | static_assert(alignof(T) == sizeof(T)); // UPX convention: require proper alignment | 562 | | #if __has_builtin(__atomic_exchange_n) && defined(__ATOMIC_SEQ_CST) | 563 | | return __atomic_exchange_n(ptr, new_value, __ATOMIC_SEQ_CST); | 564 | | #elif __has_builtin(__sync_swap) | 565 | | return __sync_swap(ptr, new_value); | 566 | | #else | 567 | | return std::atomic_exchange(ptr_std_atomic_cast(ptr), new_value); | 568 | | #endif | 569 | | #endif | 570 | 41.8k | } |
LE32* upx::atomic_exchange<LE32*>(LE32**, LE32*) Line | Count | Source | 549 | 41.8k | forceinline T atomic_exchange(T *ptr, T new_value) noexcept { | 550 | 41.8k | #if 1 | 551 | 41.8k | static_assert(sizeof(T) == sizeof(void *)); // UPX convention: restrict to pointer-size for now | 552 | 41.8k | #endif | 553 | 41.8k | static_assert(std::is_standard_layout_v<T>); | 554 | 41.8k | static_assert(std::is_trivially_copyable_v<T>); | 555 | 41.8k | #if !(WITH_THREADS) | 556 | 41.8k | T old_value = *ptr; | 557 | 41.8k | *ptr = new_value; | 558 | 41.8k | return old_value; | 559 | | #else | 560 | | static_assert(sizeof(T) <= sizeof(void *)); // UPX convention: restrict to fundamental types | 561 | | static_assert(alignof(T) == sizeof(T)); // UPX convention: require proper alignment | 562 | | #if __has_builtin(__atomic_exchange_n) && defined(__ATOMIC_SEQ_CST) | 563 | | return __atomic_exchange_n(ptr, new_value, __ATOMIC_SEQ_CST); | 564 | | #elif __has_builtin(__sync_swap) | 565 | | return __sync_swap(ptr, new_value); | 566 | | #else | 567 | | return std::atomic_exchange(ptr_std_atomic_cast(ptr), new_value); | 568 | | #endif | 569 | | #endif | 570 | 41.8k | } |
LE16* upx::atomic_exchange<LE16*>(LE16**, LE16*) Line | Count | Source | 549 | 41.8k | forceinline T atomic_exchange(T *ptr, T new_value) noexcept { | 550 | 41.8k | #if 1 | 551 | 41.8k | static_assert(sizeof(T) == sizeof(void *)); // UPX convention: restrict to pointer-size for now | 552 | 41.8k | #endif | 553 | 41.8k | static_assert(std::is_standard_layout_v<T>); | 554 | 41.8k | static_assert(std::is_trivially_copyable_v<T>); | 555 | 41.8k | #if !(WITH_THREADS) | 556 | 41.8k | T old_value = *ptr; | 557 | 41.8k | *ptr = new_value; | 558 | 41.8k | return old_value; | 559 | | #else | 560 | | static_assert(sizeof(T) <= sizeof(void *)); // UPX convention: restrict to fundamental types | 561 | | static_assert(alignof(T) == sizeof(T)); // UPX convention: require proper alignment | 562 | | #if __has_builtin(__atomic_exchange_n) && defined(__ATOMIC_SEQ_CST) | 563 | | return __atomic_exchange_n(ptr, new_value, __ATOMIC_SEQ_CST); | 564 | | #elif __has_builtin(__sync_swap) | 565 | | return __sync_swap(ptr, new_value); | 566 | | #else | 567 | | return std::atomic_exchange(ptr_std_atomic_cast(ptr), new_value); | 568 | | #endif | 569 | | #endif | 570 | 41.8k | } |
BE64* upx::atomic_exchange<BE64*>(BE64**, BE64*) Line | Count | Source | 549 | 41.8k | forceinline T atomic_exchange(T *ptr, T new_value) noexcept { | 550 | 41.8k | #if 1 | 551 | 41.8k | static_assert(sizeof(T) == sizeof(void *)); // UPX convention: restrict to pointer-size for now | 552 | 41.8k | #endif | 553 | 41.8k | static_assert(std::is_standard_layout_v<T>); | 554 | 41.8k | static_assert(std::is_trivially_copyable_v<T>); | 555 | 41.8k | #if !(WITH_THREADS) | 556 | 41.8k | T old_value = *ptr; | 557 | 41.8k | *ptr = new_value; | 558 | 41.8k | return old_value; | 559 | | #else | 560 | | static_assert(sizeof(T) <= sizeof(void *)); // UPX convention: restrict to fundamental types | 561 | | static_assert(alignof(T) == sizeof(T)); // UPX convention: require proper alignment | 562 | | #if __has_builtin(__atomic_exchange_n) && defined(__ATOMIC_SEQ_CST) | 563 | | return __atomic_exchange_n(ptr, new_value, __ATOMIC_SEQ_CST); | 564 | | #elif __has_builtin(__sync_swap) | 565 | | return __sync_swap(ptr, new_value); | 566 | | #else | 567 | | return std::atomic_exchange(ptr_std_atomic_cast(ptr), new_value); | 568 | | #endif | 569 | | #endif | 570 | 41.8k | } |
BE32* upx::atomic_exchange<BE32*>(BE32**, BE32*) Line | Count | Source | 549 | 41.8k | forceinline T atomic_exchange(T *ptr, T new_value) noexcept { | 550 | 41.8k | #if 1 | 551 | 41.8k | static_assert(sizeof(T) == sizeof(void *)); // UPX convention: restrict to pointer-size for now | 552 | 41.8k | #endif | 553 | 41.8k | static_assert(std::is_standard_layout_v<T>); | 554 | 41.8k | static_assert(std::is_trivially_copyable_v<T>); | 555 | 41.8k | #if !(WITH_THREADS) | 556 | 41.8k | T old_value = *ptr; | 557 | 41.8k | *ptr = new_value; | 558 | 41.8k | return old_value; | 559 | | #else | 560 | | static_assert(sizeof(T) <= sizeof(void *)); // UPX convention: restrict to fundamental types | 561 | | static_assert(alignof(T) == sizeof(T)); // UPX convention: require proper alignment | 562 | | #if __has_builtin(__atomic_exchange_n) && defined(__ATOMIC_SEQ_CST) | 563 | | return __atomic_exchange_n(ptr, new_value, __ATOMIC_SEQ_CST); | 564 | | #elif __has_builtin(__sync_swap) | 565 | | return __sync_swap(ptr, new_value); | 566 | | #else | 567 | | return std::atomic_exchange(ptr_std_atomic_cast(ptr), new_value); | 568 | | #endif | 569 | | #endif | 570 | 41.8k | } |
BE16* upx::atomic_exchange<BE16*>(BE16**, BE16*) Line | Count | Source | 549 | 41.8k | forceinline T atomic_exchange(T *ptr, T new_value) noexcept { | 550 | 41.8k | #if 1 | 551 | 41.8k | static_assert(sizeof(T) == sizeof(void *)); // UPX convention: restrict to pointer-size for now | 552 | 41.8k | #endif | 553 | 41.8k | static_assert(std::is_standard_layout_v<T>); | 554 | 41.8k | static_assert(std::is_trivially_copyable_v<T>); | 555 | 41.8k | #if !(WITH_THREADS) | 556 | 41.8k | T old_value = *ptr; | 557 | 41.8k | *ptr = new_value; | 558 | 41.8k | return old_value; | 559 | | #else | 560 | | static_assert(sizeof(T) <= sizeof(void *)); // UPX convention: restrict to fundamental types | 561 | | static_assert(alignof(T) == sizeof(T)); // UPX convention: require proper alignment | 562 | | #if __has_builtin(__atomic_exchange_n) && defined(__ATOMIC_SEQ_CST) | 563 | | return __atomic_exchange_n(ptr, new_value, __ATOMIC_SEQ_CST); | 564 | | #elif __has_builtin(__sync_swap) | 565 | | return __sync_swap(ptr, new_value); | 566 | | #else | 567 | | return std::atomic_exchange(ptr_std_atomic_cast(ptr), new_value); | 568 | | #endif | 569 | | #endif | 570 | 41.8k | } |
Unexecuted instantiation: ElfLinker::Section* upx::atomic_exchange<ElfLinker::Section*>(ElfLinker::Section**, ElfLinker::Section*) Unexecuted instantiation: ElfLinker::Symbol* upx::atomic_exchange<ElfLinker::Symbol*>(ElfLinker::Symbol**, ElfLinker::Symbol*) Unexecuted instantiation: ElfLinker::Relocation* upx::atomic_exchange<ElfLinker::Relocation*>(ElfLinker::Relocation**, ElfLinker::Relocation*) Unexecuted instantiation: char* upx::atomic_exchange<char*>(char**, char*) |
571 | | |
572 | | // helper classes so we don't leak memory on exceptions |
573 | | template <class T> |
574 | | struct ObjectDeleter final { |
575 | | static_assert(std::is_nothrow_destructible_v<T>); |
576 | | T **items; // public |
577 | | std::size_t count; // public |
578 | 62.7k | explicit ObjectDeleter(T **p, std::size_t n) noexcept : items(p), count(n) {}upx::ObjectDeleter<LE16>::ObjectDeleter(LE16**, unsigned long) Line | Count | Source | 578 | 41.8k | explicit ObjectDeleter(T **p, std::size_t n) noexcept : items(p), count(n) {} |
upx::ObjectDeleter<BE16>::ObjectDeleter(BE16**, unsigned long) Line | Count | Source | 578 | 20.9k | explicit ObjectDeleter(T **p, std::size_t n) noexcept : items(p), count(n) {} |
|
579 | 62.7k | ~ObjectDeleter() noexcept { delete_items(); }upx::ObjectDeleter<LE16>::~ObjectDeleter() Line | Count | Source | 579 | 41.8k | ~ObjectDeleter() noexcept { delete_items(); } |
upx::ObjectDeleter<BE16>::~ObjectDeleter() Line | Count | Source | 579 | 20.9k | ~ObjectDeleter() noexcept { delete_items(); } |
|
580 | 62.7k | void delete_items() noexcept { |
581 | 146k | for (std::size_t i = 0; i < count; i++) { |
582 | 83.6k | T *item = atomic_exchange(&items[i], (T *) nullptr); |
583 | 83.6k | delete item; // single object delete |
584 | 83.6k | } |
585 | 62.7k | } upx::ObjectDeleter<LE16>::delete_items() Line | Count | Source | 580 | 41.8k | void delete_items() noexcept { | 581 | 83.6k | for (std::size_t i = 0; i < count; i++) { | 582 | 41.8k | T *item = atomic_exchange(&items[i], (T *) nullptr); | 583 | 41.8k | delete item; // single object delete | 584 | 41.8k | } | 585 | 41.8k | } |
upx::ObjectDeleter<BE16>::delete_items() Line | Count | Source | 580 | 20.9k | void delete_items() noexcept { | 581 | 62.7k | for (std::size_t i = 0; i < count; i++) { | 582 | 41.8k | T *item = atomic_exchange(&items[i], (T *) nullptr); | 583 | 41.8k | delete item; // single object delete | 584 | 41.8k | } | 585 | 20.9k | } |
|
586 | | }; |
587 | | template <class T> |
588 | | struct ArrayDeleter final { |
589 | | static_assert(std::is_nothrow_destructible_v<T>); |
590 | | T **items; // public |
591 | | std::size_t count; // public |
592 | 62.7k | explicit ArrayDeleter(T **p, std::size_t n) noexcept : items(p), count(n) {}upx::ArrayDeleter<LE32>::ArrayDeleter(LE32**, unsigned long) Line | Count | Source | 592 | 41.8k | explicit ArrayDeleter(T **p, std::size_t n) noexcept : items(p), count(n) {} |
upx::ArrayDeleter<BE32>::ArrayDeleter(BE32**, unsigned long) Line | Count | Source | 592 | 20.9k | explicit ArrayDeleter(T **p, std::size_t n) noexcept : items(p), count(n) {} |
Unexecuted instantiation: upx::ArrayDeleter<char>::ArrayDeleter(char**, unsigned long) |
593 | 62.7k | ~ArrayDeleter() noexcept { delete_items(); }upx::ArrayDeleter<LE32>::~ArrayDeleter() Line | Count | Source | 593 | 41.8k | ~ArrayDeleter() noexcept { delete_items(); } |
upx::ArrayDeleter<BE32>::~ArrayDeleter() Line | Count | Source | 593 | 20.9k | ~ArrayDeleter() noexcept { delete_items(); } |
Unexecuted instantiation: upx::ArrayDeleter<char>::~ArrayDeleter() |
594 | 62.7k | void delete_items() noexcept { |
595 | 146k | for (std::size_t i = 0; i < count; i++) { |
596 | 83.6k | T *item = atomic_exchange(&items[i], (T *) nullptr); |
597 | 83.6k | delete[] item; // array delete |
598 | 83.6k | } |
599 | 62.7k | } upx::ArrayDeleter<LE32>::delete_items() Line | Count | Source | 594 | 41.8k | void delete_items() noexcept { | 595 | 83.6k | for (std::size_t i = 0; i < count; i++) { | 596 | 41.8k | T *item = atomic_exchange(&items[i], (T *) nullptr); | 597 | 41.8k | delete[] item; // array delete | 598 | 41.8k | } | 599 | 41.8k | } |
upx::ArrayDeleter<BE32>::delete_items() Line | Count | Source | 594 | 20.9k | void delete_items() noexcept { | 595 | 62.7k | for (std::size_t i = 0; i < count; i++) { | 596 | 41.8k | T *item = atomic_exchange(&items[i], (T *) nullptr); | 597 | 41.8k | delete[] item; // array delete | 598 | 41.8k | } | 599 | 20.9k | } |
Unexecuted instantiation: upx::ArrayDeleter<char>::delete_items() |
600 | | }; |
601 | | template <class T> |
602 | | struct MallocDeleter final { |
603 | | T **items; // public |
604 | | std::size_t count; // public |
605 | 62.7k | explicit MallocDeleter(T **p, std::size_t n) noexcept : items(p), count(n) {}upx::MallocDeleter<LE64>::MallocDeleter(LE64**, unsigned long) Line | Count | Source | 605 | 41.8k | explicit MallocDeleter(T **p, std::size_t n) noexcept : items(p), count(n) {} |
upx::MallocDeleter<BE64>::MallocDeleter(BE64**, unsigned long) Line | Count | Source | 605 | 20.9k | explicit MallocDeleter(T **p, std::size_t n) noexcept : items(p), count(n) {} |
Unexecuted instantiation: upx::MallocDeleter<char>::MallocDeleter(char**, unsigned long) |
606 | 62.7k | ~MallocDeleter() noexcept { delete_items(); }upx::MallocDeleter<LE64>::~MallocDeleter() Line | Count | Source | 606 | 41.8k | ~MallocDeleter() noexcept { delete_items(); } |
upx::MallocDeleter<BE64>::~MallocDeleter() Line | Count | Source | 606 | 20.9k | ~MallocDeleter() noexcept { delete_items(); } |
Unexecuted instantiation: upx::MallocDeleter<char>::~MallocDeleter() |
607 | 62.7k | void delete_items() noexcept { |
608 | 146k | for (std::size_t i = 0; i < count; i++) { |
609 | 83.6k | T *item = atomic_exchange(&items[i], (T *) nullptr); |
610 | 83.6k | ::free(item); // free memory from malloc() |
611 | 83.6k | } |
612 | 62.7k | } upx::MallocDeleter<LE64>::delete_items() Line | Count | Source | 607 | 41.8k | void delete_items() noexcept { | 608 | 83.6k | for (std::size_t i = 0; i < count; i++) { | 609 | 41.8k | T *item = atomic_exchange(&items[i], (T *) nullptr); | 610 | 41.8k | ::free(item); // free memory from malloc() | 611 | 41.8k | } | 612 | 41.8k | } |
upx::MallocDeleter<BE64>::delete_items() Line | Count | Source | 607 | 20.9k | void delete_items() noexcept { | 608 | 62.7k | for (std::size_t i = 0; i < count; i++) { | 609 | 41.8k | T *item = atomic_exchange(&items[i], (T *) nullptr); | 610 | 41.8k | ::free(item); // free memory from malloc() | 611 | 41.8k | } | 612 | 20.9k | } |
Unexecuted instantiation: upx::MallocDeleter<char>::delete_items() |
613 | | }; |
614 | | |
615 | | /************************************************************************* |
616 | | // TriBool - tri-state bool |
617 | | // an enum with an underlying type and 3 values |
618 | | // IsThirdTrue determines if Third is false or true |
619 | | **************************************************************************/ |
620 | | |
621 | | template <class T = int, bool IsThirdTrue = false> // Third is false by default |
622 | | struct TriBool final { |
623 | | static constexpr bool is_third_true = IsThirdTrue; |
624 | | // types |
625 | | typedef T underlying_type; |
626 | | typedef decltype(T(0) + T(0)) promoted_type; |
627 | | enum value_type : underlying_type { False = 0, True = 1, Third = 2 }; |
628 | | static_assert(std::is_integral_v<underlying_type>); |
629 | | static_assert(std::is_integral_v<promoted_type>); |
630 | | static_assert(sizeof(value_type) == sizeof(underlying_type)); |
631 | | static_assert(sizeof(underlying_type) <= sizeof(promoted_type)); |
632 | | // constructors |
633 | 5.78M | forceinline constexpr TriBool() noexcept {}upx::TriBool<int, false>::TriBool() Line | Count | Source | 633 | 41.8k | forceinline constexpr TriBool() noexcept {} |
upx::TriBool<signed char, false>::TriBool() Line | Count | Source | 633 | 20.9k | forceinline constexpr TriBool() noexcept {} |
upx::TriBool<unsigned char, false>::TriBool() Line | Count | Source | 633 | 20.9k | forceinline constexpr TriBool() noexcept {} |
upx::TriBool<short, false>::TriBool() Line | Count | Source | 633 | 20.9k | forceinline constexpr TriBool() noexcept {} |
upx::TriBool<unsigned short, false>::TriBool() Line | Count | Source | 633 | 20.9k | forceinline constexpr TriBool() noexcept {} |
upx::TriBool<unsigned int, false>::TriBool() Line | Count | Source | 633 | 20.9k | forceinline constexpr TriBool() noexcept {} |
upx::TriBool<long long, false>::TriBool() Line | Count | Source | 633 | 20.9k | forceinline constexpr TriBool() noexcept {} |
upx::TriBool<unsigned long long, false>::TriBool() Line | Count | Source | 633 | 20.9k | forceinline constexpr TriBool() noexcept {} |
upx::TriBool<signed char, true>::TriBool() Line | Count | Source | 633 | 5.45M | forceinline constexpr TriBool() noexcept {} |
upx::TriBool<unsigned char, true>::TriBool() Line | Count | Source | 633 | 20.9k | forceinline constexpr TriBool() noexcept {} |
upx::TriBool<short, true>::TriBool() Line | Count | Source | 633 | 20.9k | forceinline constexpr TriBool() noexcept {} |
upx::TriBool<unsigned short, true>::TriBool() Line | Count | Source | 633 | 20.9k | forceinline constexpr TriBool() noexcept {} |
upx::TriBool<int, true>::TriBool() Line | Count | Source | 633 | 20.9k | forceinline constexpr TriBool() noexcept {} |
upx::TriBool<unsigned int, true>::TriBool() Line | Count | Source | 633 | 20.9k | forceinline constexpr TriBool() noexcept {} |
upx::TriBool<long long, true>::TriBool() Line | Count | Source | 633 | 20.9k | forceinline constexpr TriBool() noexcept {} |
upx::TriBool<unsigned long long, true>::TriBool() Line | Count | Source | 633 | 20.9k | forceinline constexpr TriBool() noexcept {} |
|
634 | 355k | forceinline constexpr TriBool(value_type x) noexcept : value(x) {}upx::TriBool<int, false>::TriBool(upx::TriBool<int, false>::value_type) Line | Count | Source | 634 | 41.8k | forceinline constexpr TriBool(value_type x) noexcept : value(x) {} |
upx::TriBool<signed char, false>::TriBool(upx::TriBool<signed char, false>::value_type) Line | Count | Source | 634 | 20.9k | forceinline constexpr TriBool(value_type x) noexcept : value(x) {} |
upx::TriBool<unsigned char, false>::TriBool(upx::TriBool<unsigned char, false>::value_type) Line | Count | Source | 634 | 20.9k | forceinline constexpr TriBool(value_type x) noexcept : value(x) {} |
upx::TriBool<short, false>::TriBool(upx::TriBool<short, false>::value_type) Line | Count | Source | 634 | 20.9k | forceinline constexpr TriBool(value_type x) noexcept : value(x) {} |
upx::TriBool<unsigned short, false>::TriBool(upx::TriBool<unsigned short, false>::value_type) Line | Count | Source | 634 | 20.9k | forceinline constexpr TriBool(value_type x) noexcept : value(x) {} |
upx::TriBool<unsigned int, false>::TriBool(upx::TriBool<unsigned int, false>::value_type) Line | Count | Source | 634 | 20.9k | forceinline constexpr TriBool(value_type x) noexcept : value(x) {} |
upx::TriBool<long long, false>::TriBool(upx::TriBool<long long, false>::value_type) Line | Count | Source | 634 | 20.9k | forceinline constexpr TriBool(value_type x) noexcept : value(x) {} |
upx::TriBool<unsigned long long, false>::TriBool(upx::TriBool<unsigned long long, false>::value_type) Line | Count | Source | 634 | 20.9k | forceinline constexpr TriBool(value_type x) noexcept : value(x) {} |
upx::TriBool<signed char, true>::TriBool(upx::TriBool<signed char, true>::value_type) Line | Count | Source | 634 | 20.9k | forceinline constexpr TriBool(value_type x) noexcept : value(x) {} |
upx::TriBool<unsigned char, true>::TriBool(upx::TriBool<unsigned char, true>::value_type) Line | Count | Source | 634 | 20.9k | forceinline constexpr TriBool(value_type x) noexcept : value(x) {} |
upx::TriBool<short, true>::TriBool(upx::TriBool<short, true>::value_type) Line | Count | Source | 634 | 20.9k | forceinline constexpr TriBool(value_type x) noexcept : value(x) {} |
upx::TriBool<unsigned short, true>::TriBool(upx::TriBool<unsigned short, true>::value_type) Line | Count | Source | 634 | 20.9k | forceinline constexpr TriBool(value_type x) noexcept : value(x) {} |
upx::TriBool<int, true>::TriBool(upx::TriBool<int, true>::value_type) Line | Count | Source | 634 | 20.9k | forceinline constexpr TriBool(value_type x) noexcept : value(x) {} |
upx::TriBool<unsigned int, true>::TriBool(upx::TriBool<unsigned int, true>::value_type) Line | Count | Source | 634 | 20.9k | forceinline constexpr TriBool(value_type x) noexcept : value(x) {} |
upx::TriBool<long long, true>::TriBool(upx::TriBool<long long, true>::value_type) Line | Count | Source | 634 | 20.9k | forceinline constexpr TriBool(value_type x) noexcept : value(x) {} |
upx::TriBool<unsigned long long, true>::TriBool(upx::TriBool<unsigned long long, true>::value_type) Line | Count | Source | 634 | 20.9k | forceinline constexpr TriBool(value_type x) noexcept : value(x) {} |
|
635 | | // IMPORTANT NOTE: permissive, converts all other values to Third! |
636 | 8.07M | constexpr TriBool(promoted_type x) noexcept : value(x == 0 ? False : (x == 1 ? True : Third)) {}upx::TriBool<int, false>::TriBool(int) Line | Count | Source | 636 | 1.48M | constexpr TriBool(promoted_type x) noexcept : value(x == 0 ? False : (x == 1 ? True : Third)) {} |
upx::TriBool<signed char, false>::TriBool(int) Line | Count | Source | 636 | 62.7k | constexpr TriBool(promoted_type x) noexcept : value(x == 0 ? False : (x == 1 ? True : Third)) {} |
upx::TriBool<unsigned char, false>::TriBool(int) Line | Count | Source | 636 | 62.7k | constexpr TriBool(promoted_type x) noexcept : value(x == 0 ? False : (x == 1 ? True : Third)) {} |
upx::TriBool<short, false>::TriBool(int) Line | Count | Source | 636 | 62.7k | constexpr TriBool(promoted_type x) noexcept : value(x == 0 ? False : (x == 1 ? True : Third)) {} |
upx::TriBool<unsigned short, false>::TriBool(int) Line | Count | Source | 636 | 62.7k | constexpr TriBool(promoted_type x) noexcept : value(x == 0 ? False : (x == 1 ? True : Third)) {} |
upx::TriBool<unsigned int, false>::TriBool(unsigned int) Line | Count | Source | 636 | 62.7k | constexpr TriBool(promoted_type x) noexcept : value(x == 0 ? False : (x == 1 ? True : Third)) {} |
upx::TriBool<long long, false>::TriBool(long long) Line | Count | Source | 636 | 62.7k | constexpr TriBool(promoted_type x) noexcept : value(x == 0 ? False : (x == 1 ? True : Third)) {} |
upx::TriBool<unsigned long long, false>::TriBool(unsigned long long) Line | Count | Source | 636 | 62.7k | constexpr TriBool(promoted_type x) noexcept : value(x == 0 ? False : (x == 1 ? True : Third)) {} |
upx::TriBool<signed char, true>::TriBool(int) Line | Count | Source | 636 | 5.70M | constexpr TriBool(promoted_type x) noexcept : value(x == 0 ? False : (x == 1 ? True : Third)) {} |
upx::TriBool<unsigned char, true>::TriBool(int) Line | Count | Source | 636 | 62.7k | constexpr TriBool(promoted_type x) noexcept : value(x == 0 ? False : (x == 1 ? True : Third)) {} |
upx::TriBool<short, true>::TriBool(int) Line | Count | Source | 636 | 62.7k | constexpr TriBool(promoted_type x) noexcept : value(x == 0 ? False : (x == 1 ? True : Third)) {} |
upx::TriBool<unsigned short, true>::TriBool(int) Line | Count | Source | 636 | 62.7k | constexpr TriBool(promoted_type x) noexcept : value(x == 0 ? False : (x == 1 ? True : Third)) {} |
upx::TriBool<int, true>::TriBool(int) Line | Count | Source | 636 | 62.7k | constexpr TriBool(promoted_type x) noexcept : value(x == 0 ? False : (x == 1 ? True : Third)) {} |
upx::TriBool<unsigned int, true>::TriBool(unsigned int) Line | Count | Source | 636 | 62.7k | constexpr TriBool(promoted_type x) noexcept : value(x == 0 ? False : (x == 1 ? True : Third)) {} |
upx::TriBool<long long, true>::TriBool(long long) Line | Count | Source | 636 | 62.7k | constexpr TriBool(promoted_type x) noexcept : value(x == 0 ? False : (x == 1 ? True : Third)) {} |
upx::TriBool<unsigned long long, true>::TriBool(unsigned long long) Line | Count | Source | 636 | 62.7k | constexpr TriBool(promoted_type x) noexcept : value(x == 0 ? False : (x == 1 ? True : Third)) {} |
|
637 | | #if __cplusplus >= 202002L |
638 | | forceinline constexpr ~TriBool() noexcept = default; |
639 | | #else |
640 | | forceinline ~TriBool() noexcept = default; |
641 | | #endif |
642 | | // explicit conversion to bool |
643 | 7.59M | explicit constexpr operator bool() const noexcept { |
644 | 7.59M | return IsThirdTrue ? (value != False) : (value == True); |
645 | 7.59M | } upx::TriBool<int, false>::operator bool() const Line | Count | Source | 643 | 2.03M | explicit constexpr operator bool() const noexcept { | 644 | 2.03M | return IsThirdTrue ? (value != False) : (value == True); | 645 | 2.03M | } |
upx::TriBool<signed char, false>::operator bool() const Line | Count | Source | 643 | 334k | explicit constexpr operator bool() const noexcept { | 644 | 334k | return IsThirdTrue ? (value != False) : (value == True); | 645 | 334k | } |
upx::TriBool<unsigned char, false>::operator bool() const Line | Count | Source | 643 | 334k | explicit constexpr operator bool() const noexcept { | 644 | 334k | return IsThirdTrue ? (value != False) : (value == True); | 645 | 334k | } |
upx::TriBool<short, false>::operator bool() const Line | Count | Source | 643 | 334k | explicit constexpr operator bool() const noexcept { | 644 | 334k | return IsThirdTrue ? (value != False) : (value == True); | 645 | 334k | } |
upx::TriBool<unsigned short, false>::operator bool() const Line | Count | Source | 643 | 334k | explicit constexpr operator bool() const noexcept { | 644 | 334k | return IsThirdTrue ? (value != False) : (value == True); | 645 | 334k | } |
upx::TriBool<unsigned int, false>::operator bool() const Line | Count | Source | 643 | 334k | explicit constexpr operator bool() const noexcept { | 644 | 334k | return IsThirdTrue ? (value != False) : (value == True); | 645 | 334k | } |
upx::TriBool<long long, false>::operator bool() const Line | Count | Source | 643 | 334k | explicit constexpr operator bool() const noexcept { | 644 | 334k | return IsThirdTrue ? (value != False) : (value == True); | 645 | 334k | } |
upx::TriBool<unsigned long long, false>::operator bool() const Line | Count | Source | 643 | 334k | explicit constexpr operator bool() const noexcept { | 644 | 334k | return IsThirdTrue ? (value != False) : (value == True); | 645 | 334k | } |
upx::TriBool<signed char, true>::operator bool() const Line | Count | Source | 643 | 878k | explicit constexpr operator bool() const noexcept { | 644 | 878k | return IsThirdTrue ? (value != False) : (value == True); | 645 | 878k | } |
upx::TriBool<unsigned char, true>::operator bool() const Line | Count | Source | 643 | 334k | explicit constexpr operator bool() const noexcept { | 644 | 334k | return IsThirdTrue ? (value != False) : (value == True); | 645 | 334k | } |
upx::TriBool<short, true>::operator bool() const Line | Count | Source | 643 | 334k | explicit constexpr operator bool() const noexcept { | 644 | 334k | return IsThirdTrue ? (value != False) : (value == True); | 645 | 334k | } |
upx::TriBool<unsigned short, true>::operator bool() const Line | Count | Source | 643 | 334k | explicit constexpr operator bool() const noexcept { | 644 | 334k | return IsThirdTrue ? (value != False) : (value == True); | 645 | 334k | } |
upx::TriBool<int, true>::operator bool() const Line | Count | Source | 643 | 334k | explicit constexpr operator bool() const noexcept { | 644 | 334k | return IsThirdTrue ? (value != False) : (value == True); | 645 | 334k | } |
upx::TriBool<unsigned int, true>::operator bool() const Line | Count | Source | 643 | 334k | explicit constexpr operator bool() const noexcept { | 644 | 334k | return IsThirdTrue ? (value != False) : (value == True); | 645 | 334k | } |
upx::TriBool<long long, true>::operator bool() const Line | Count | Source | 643 | 334k | explicit constexpr operator bool() const noexcept { | 644 | 334k | return IsThirdTrue ? (value != False) : (value == True); | 645 | 334k | } |
upx::TriBool<unsigned long long, true>::operator bool() const Line | Count | Source | 643 | 334k | explicit constexpr operator bool() const noexcept { | 644 | 334k | return IsThirdTrue ? (value != False) : (value == True); | 645 | 334k | } |
|
646 | | // query; this is NOT the same as operator bool() |
647 | 2.13M | constexpr bool isStrictFalse() const noexcept { return value == False; }upx::TriBool<int, false>::isStrictFalse() const Line | Count | Source | 647 | 250k | constexpr bool isStrictFalse() const noexcept { return value == False; } |
upx::TriBool<signed char, false>::isStrictFalse() const Line | Count | Source | 647 | 125k | constexpr bool isStrictFalse() const noexcept { return value == False; } |
upx::TriBool<unsigned char, false>::isStrictFalse() const Line | Count | Source | 647 | 125k | constexpr bool isStrictFalse() const noexcept { return value == False; } |
upx::TriBool<short, false>::isStrictFalse() const Line | Count | Source | 647 | 125k | constexpr bool isStrictFalse() const noexcept { return value == False; } |
upx::TriBool<unsigned short, false>::isStrictFalse() const Line | Count | Source | 647 | 125k | constexpr bool isStrictFalse() const noexcept { return value == False; } |
upx::TriBool<unsigned int, false>::isStrictFalse() const Line | Count | Source | 647 | 125k | constexpr bool isStrictFalse() const noexcept { return value == False; } |
upx::TriBool<long long, false>::isStrictFalse() const Line | Count | Source | 647 | 125k | constexpr bool isStrictFalse() const noexcept { return value == False; } |
upx::TriBool<unsigned long long, false>::isStrictFalse() const Line | Count | Source | 647 | 125k | constexpr bool isStrictFalse() const noexcept { return value == False; } |
upx::TriBool<signed char, true>::isStrictFalse() const Line | Count | Source | 647 | 125k | constexpr bool isStrictFalse() const noexcept { return value == False; } |
upx::TriBool<unsigned char, true>::isStrictFalse() const Line | Count | Source | 647 | 125k | constexpr bool isStrictFalse() const noexcept { return value == False; } |
upx::TriBool<short, true>::isStrictFalse() const Line | Count | Source | 647 | 125k | constexpr bool isStrictFalse() const noexcept { return value == False; } |
upx::TriBool<unsigned short, true>::isStrictFalse() const Line | Count | Source | 647 | 125k | constexpr bool isStrictFalse() const noexcept { return value == False; } |
upx::TriBool<int, true>::isStrictFalse() const Line | Count | Source | 647 | 125k | constexpr bool isStrictFalse() const noexcept { return value == False; } |
upx::TriBool<unsigned int, true>::isStrictFalse() const Line | Count | Source | 647 | 125k | constexpr bool isStrictFalse() const noexcept { return value == False; } |
upx::TriBool<long long, true>::isStrictFalse() const Line | Count | Source | 647 | 125k | constexpr bool isStrictFalse() const noexcept { return value == False; } |
upx::TriBool<unsigned long long, true>::isStrictFalse() const Line | Count | Source | 647 | 125k | constexpr bool isStrictFalse() const noexcept { return value == False; } |
|
648 | 1.77M | constexpr bool isStrictTrue() const noexcept { return value == True; }upx::TriBool<int, false>::isStrictTrue() const Line | Count | Source | 648 | 209k | constexpr bool isStrictTrue() const noexcept { return value == True; } |
upx::TriBool<signed char, false>::isStrictTrue() const Line | Count | Source | 648 | 104k | constexpr bool isStrictTrue() const noexcept { return value == True; } |
upx::TriBool<unsigned char, false>::isStrictTrue() const Line | Count | Source | 648 | 104k | constexpr bool isStrictTrue() const noexcept { return value == True; } |
upx::TriBool<short, false>::isStrictTrue() const Line | Count | Source | 648 | 104k | constexpr bool isStrictTrue() const noexcept { return value == True; } |
upx::TriBool<unsigned short, false>::isStrictTrue() const Line | Count | Source | 648 | 104k | constexpr bool isStrictTrue() const noexcept { return value == True; } |
upx::TriBool<unsigned int, false>::isStrictTrue() const Line | Count | Source | 648 | 104k | constexpr bool isStrictTrue() const noexcept { return value == True; } |
upx::TriBool<long long, false>::isStrictTrue() const Line | Count | Source | 648 | 104k | constexpr bool isStrictTrue() const noexcept { return value == True; } |
upx::TriBool<unsigned long long, false>::isStrictTrue() const Line | Count | Source | 648 | 104k | constexpr bool isStrictTrue() const noexcept { return value == True; } |
upx::TriBool<signed char, true>::isStrictTrue() const Line | Count | Source | 648 | 104k | constexpr bool isStrictTrue() const noexcept { return value == True; } |
upx::TriBool<unsigned char, true>::isStrictTrue() const Line | Count | Source | 648 | 104k | constexpr bool isStrictTrue() const noexcept { return value == True; } |
upx::TriBool<short, true>::isStrictTrue() const Line | Count | Source | 648 | 104k | constexpr bool isStrictTrue() const noexcept { return value == True; } |
upx::TriBool<unsigned short, true>::isStrictTrue() const Line | Count | Source | 648 | 104k | constexpr bool isStrictTrue() const noexcept { return value == True; } |
upx::TriBool<int, true>::isStrictTrue() const Line | Count | Source | 648 | 104k | constexpr bool isStrictTrue() const noexcept { return value == True; } |
upx::TriBool<unsigned int, true>::isStrictTrue() const Line | Count | Source | 648 | 104k | constexpr bool isStrictTrue() const noexcept { return value == True; } |
upx::TriBool<long long, true>::isStrictTrue() const Line | Count | Source | 648 | 104k | constexpr bool isStrictTrue() const noexcept { return value == True; } |
upx::TriBool<unsigned long long, true>::isStrictTrue() const Line | Count | Source | 648 | 104k | constexpr bool isStrictTrue() const noexcept { return value == True; } |
|
649 | 1.77M | constexpr bool isStrictBool() const noexcept { return value == False || value == True; }upx::TriBool<int, false>::isStrictBool() const Line | Count | Source | 649 | 209k | constexpr bool isStrictBool() const noexcept { return value == False || value == True; } |
upx::TriBool<signed char, false>::isStrictBool() const Line | Count | Source | 649 | 104k | constexpr bool isStrictBool() const noexcept { return value == False || value == True; } |
upx::TriBool<unsigned char, false>::isStrictBool() const Line | Count | Source | 649 | 104k | constexpr bool isStrictBool() const noexcept { return value == False || value == True; } |
upx::TriBool<short, false>::isStrictBool() const Line | Count | Source | 649 | 104k | constexpr bool isStrictBool() const noexcept { return value == False || value == True; } |
upx::TriBool<unsigned short, false>::isStrictBool() const Line | Count | Source | 649 | 104k | constexpr bool isStrictBool() const noexcept { return value == False || value == True; } |
upx::TriBool<unsigned int, false>::isStrictBool() const Line | Count | Source | 649 | 104k | constexpr bool isStrictBool() const noexcept { return value == False || value == True; } |
upx::TriBool<long long, false>::isStrictBool() const Line | Count | Source | 649 | 104k | constexpr bool isStrictBool() const noexcept { return value == False || value == True; } |
upx::TriBool<unsigned long long, false>::isStrictBool() const Line | Count | Source | 649 | 104k | constexpr bool isStrictBool() const noexcept { return value == False || value == True; } |
upx::TriBool<signed char, true>::isStrictBool() const Line | Count | Source | 649 | 104k | constexpr bool isStrictBool() const noexcept { return value == False || value == True; } |
upx::TriBool<unsigned char, true>::isStrictBool() const Line | Count | Source | 649 | 104k | constexpr bool isStrictBool() const noexcept { return value == False || value == True; } |
upx::TriBool<short, true>::isStrictBool() const Line | Count | Source | 649 | 104k | constexpr bool isStrictBool() const noexcept { return value == False || value == True; } |
upx::TriBool<unsigned short, true>::isStrictBool() const Line | Count | Source | 649 | 104k | constexpr bool isStrictBool() const noexcept { return value == False || value == True; } |
upx::TriBool<int, true>::isStrictBool() const Line | Count | Source | 649 | 104k | constexpr bool isStrictBool() const noexcept { return value == False || value == True; } |
upx::TriBool<unsigned int, true>::isStrictBool() const Line | Count | Source | 649 | 104k | constexpr bool isStrictBool() const noexcept { return value == False || value == True; } |
upx::TriBool<long long, true>::isStrictBool() const Line | Count | Source | 649 | 104k | constexpr bool isStrictBool() const noexcept { return value == False || value == True; } |
upx::TriBool<unsigned long long, true>::isStrictBool() const Line | Count | Source | 649 | 104k | constexpr bool isStrictBool() const noexcept { return value == False || value == True; } |
|
650 | 2.99M | constexpr bool isThird() const noexcept { return value != False && value != True; }upx::TriBool<int, false>::isThird() const Line | Count | Source | 650 | 1.42M | constexpr bool isThird() const noexcept { return value != False && value != True; } |
upx::TriBool<signed char, false>::isThird() const Line | Count | Source | 650 | 104k | constexpr bool isThird() const noexcept { return value != False && value != True; } |
upx::TriBool<unsigned char, false>::isThird() const Line | Count | Source | 650 | 104k | constexpr bool isThird() const noexcept { return value != False && value != True; } |
upx::TriBool<short, false>::isThird() const Line | Count | Source | 650 | 104k | constexpr bool isThird() const noexcept { return value != False && value != True; } |
upx::TriBool<unsigned short, false>::isThird() const Line | Count | Source | 650 | 104k | constexpr bool isThird() const noexcept { return value != False && value != True; } |
upx::TriBool<unsigned int, false>::isThird() const Line | Count | Source | 650 | 104k | constexpr bool isThird() const noexcept { return value != False && value != True; } |
upx::TriBool<long long, false>::isThird() const Line | Count | Source | 650 | 104k | constexpr bool isThird() const noexcept { return value != False && value != True; } |
upx::TriBool<unsigned long long, false>::isThird() const Line | Count | Source | 650 | 104k | constexpr bool isThird() const noexcept { return value != False && value != True; } |
upx::TriBool<signed char, true>::isThird() const Line | Count | Source | 650 | 104k | constexpr bool isThird() const noexcept { return value != False && value != True; } |
upx::TriBool<unsigned char, true>::isThird() const Line | Count | Source | 650 | 104k | constexpr bool isThird() const noexcept { return value != False && value != True; } |
upx::TriBool<short, true>::isThird() const Line | Count | Source | 650 | 104k | constexpr bool isThird() const noexcept { return value != False && value != True; } |
upx::TriBool<unsigned short, true>::isThird() const Line | Count | Source | 650 | 104k | constexpr bool isThird() const noexcept { return value != False && value != True; } |
upx::TriBool<int, true>::isThird() const Line | Count | Source | 650 | 104k | constexpr bool isThird() const noexcept { return value != False && value != True; } |
upx::TriBool<unsigned int, true>::isThird() const Line | Count | Source | 650 | 104k | constexpr bool isThird() const noexcept { return value != False && value != True; } |
upx::TriBool<long long, true>::isThird() const Line | Count | Source | 650 | 104k | constexpr bool isThird() const noexcept { return value != False && value != True; } |
upx::TriBool<unsigned long long, true>::isThird() const Line | Count | Source | 650 | 104k | constexpr bool isThird() const noexcept { return value != False && value != True; } |
|
651 | | // access |
652 | 1.77M | constexpr value_type getValue() const noexcept { return value; }upx::TriBool<int, false>::getValue() const Line | Count | Source | 652 | 209k | constexpr value_type getValue() const noexcept { return value; } |
upx::TriBool<signed char, false>::getValue() const Line | Count | Source | 652 | 104k | constexpr value_type getValue() const noexcept { return value; } |
upx::TriBool<unsigned char, false>::getValue() const Line | Count | Source | 652 | 104k | constexpr value_type getValue() const noexcept { return value; } |
upx::TriBool<short, false>::getValue() const Line | Count | Source | 652 | 104k | constexpr value_type getValue() const noexcept { return value; } |
upx::TriBool<unsigned short, false>::getValue() const Line | Count | Source | 652 | 104k | constexpr value_type getValue() const noexcept { return value; } |
upx::TriBool<unsigned int, false>::getValue() const Line | Count | Source | 652 | 104k | constexpr value_type getValue() const noexcept { return value; } |
upx::TriBool<long long, false>::getValue() const Line | Count | Source | 652 | 104k | constexpr value_type getValue() const noexcept { return value; } |
upx::TriBool<unsigned long long, false>::getValue() const Line | Count | Source | 652 | 104k | constexpr value_type getValue() const noexcept { return value; } |
upx::TriBool<signed char, true>::getValue() const Line | Count | Source | 652 | 104k | constexpr value_type getValue() const noexcept { return value; } |
upx::TriBool<unsigned char, true>::getValue() const Line | Count | Source | 652 | 104k | constexpr value_type getValue() const noexcept { return value; } |
upx::TriBool<short, true>::getValue() const Line | Count | Source | 652 | 104k | constexpr value_type getValue() const noexcept { return value; } |
upx::TriBool<unsigned short, true>::getValue() const Line | Count | Source | 652 | 104k | constexpr value_type getValue() const noexcept { return value; } |
upx::TriBool<int, true>::getValue() const Line | Count | Source | 652 | 104k | constexpr value_type getValue() const noexcept { return value; } |
upx::TriBool<unsigned int, true>::getValue() const Line | Count | Source | 652 | 104k | constexpr value_type getValue() const noexcept { return value; } |
upx::TriBool<long long, true>::getValue() const Line | Count | Source | 652 | 104k | constexpr value_type getValue() const noexcept { return value; } |
upx::TriBool<unsigned long long, true>::getValue() const Line | Count | Source | 652 | 104k | constexpr value_type getValue() const noexcept { return value; } |
|
653 | | // equality |
654 | 0 | constexpr bool operator==(TriBool other) const noexcept { return value == other.value; }Unexecuted instantiation: upx::TriBool<int, false>::operator==(upx::TriBool<int, false>) const Unexecuted instantiation: upx::TriBool<signed char, false>::operator==(upx::TriBool<signed char, false>) const Unexecuted instantiation: upx::TriBool<unsigned char, false>::operator==(upx::TriBool<unsigned char, false>) const Unexecuted instantiation: upx::TriBool<short, false>::operator==(upx::TriBool<short, false>) const Unexecuted instantiation: upx::TriBool<unsigned short, false>::operator==(upx::TriBool<unsigned short, false>) const Unexecuted instantiation: upx::TriBool<unsigned int, false>::operator==(upx::TriBool<unsigned int, false>) const Unexecuted instantiation: upx::TriBool<long long, false>::operator==(upx::TriBool<long long, false>) const Unexecuted instantiation: upx::TriBool<unsigned long long, false>::operator==(upx::TriBool<unsigned long long, false>) const Unexecuted instantiation: upx::TriBool<signed char, true>::operator==(upx::TriBool<signed char, true>) const Unexecuted instantiation: upx::TriBool<unsigned char, true>::operator==(upx::TriBool<unsigned char, true>) const Unexecuted instantiation: upx::TriBool<short, true>::operator==(upx::TriBool<short, true>) const Unexecuted instantiation: upx::TriBool<unsigned short, true>::operator==(upx::TriBool<unsigned short, true>) const Unexecuted instantiation: upx::TriBool<int, true>::operator==(upx::TriBool<int, true>) const Unexecuted instantiation: upx::TriBool<unsigned int, true>::operator==(upx::TriBool<unsigned int, true>) const Unexecuted instantiation: upx::TriBool<long long, true>::operator==(upx::TriBool<long long, true>) const Unexecuted instantiation: upx::TriBool<unsigned long long, true>::operator==(upx::TriBool<unsigned long long, true>) const |
655 | 0 | constexpr bool operator==(value_type other) const noexcept { return value == other; }Unexecuted instantiation: upx::TriBool<int, false>::operator==(upx::TriBool<int, false>::value_type) const Unexecuted instantiation: upx::TriBool<signed char, false>::operator==(upx::TriBool<signed char, false>::value_type) const Unexecuted instantiation: upx::TriBool<unsigned char, false>::operator==(upx::TriBool<unsigned char, false>::value_type) const Unexecuted instantiation: upx::TriBool<short, false>::operator==(upx::TriBool<short, false>::value_type) const Unexecuted instantiation: upx::TriBool<unsigned short, false>::operator==(upx::TriBool<unsigned short, false>::value_type) const Unexecuted instantiation: upx::TriBool<unsigned int, false>::operator==(upx::TriBool<unsigned int, false>::value_type) const Unexecuted instantiation: upx::TriBool<long long, false>::operator==(upx::TriBool<long long, false>::value_type) const Unexecuted instantiation: upx::TriBool<unsigned long long, false>::operator==(upx::TriBool<unsigned long long, false>::value_type) const Unexecuted instantiation: upx::TriBool<signed char, true>::operator==(upx::TriBool<signed char, true>::value_type) const Unexecuted instantiation: upx::TriBool<unsigned char, true>::operator==(upx::TriBool<unsigned char, true>::value_type) const Unexecuted instantiation: upx::TriBool<short, true>::operator==(upx::TriBool<short, true>::value_type) const Unexecuted instantiation: upx::TriBool<unsigned short, true>::operator==(upx::TriBool<unsigned short, true>::value_type) const Unexecuted instantiation: upx::TriBool<int, true>::operator==(upx::TriBool<int, true>::value_type) const Unexecuted instantiation: upx::TriBool<unsigned int, true>::operator==(upx::TriBool<unsigned int, true>::value_type) const Unexecuted instantiation: upx::TriBool<long long, true>::operator==(upx::TriBool<long long, true>::value_type) const Unexecuted instantiation: upx::TriBool<unsigned long long, true>::operator==(upx::TriBool<unsigned long long, true>::value_type) const |
656 | 0 | constexpr bool operator==(promoted_type other) const noexcept { |
657 | 0 | return value == TriBool(other).value; |
658 | 0 | } Unexecuted instantiation: upx::TriBool<int, false>::operator==(int) const Unexecuted instantiation: upx::TriBool<signed char, false>::operator==(int) const Unexecuted instantiation: upx::TriBool<unsigned char, false>::operator==(int) const Unexecuted instantiation: upx::TriBool<short, false>::operator==(int) const Unexecuted instantiation: upx::TriBool<unsigned short, false>::operator==(int) const Unexecuted instantiation: upx::TriBool<unsigned int, false>::operator==(unsigned int) const Unexecuted instantiation: upx::TriBool<long long, false>::operator==(long long) const Unexecuted instantiation: upx::TriBool<unsigned long long, false>::operator==(unsigned long long) const Unexecuted instantiation: upx::TriBool<signed char, true>::operator==(int) const Unexecuted instantiation: upx::TriBool<unsigned char, true>::operator==(int) const Unexecuted instantiation: upx::TriBool<short, true>::operator==(int) const Unexecuted instantiation: upx::TriBool<unsigned short, true>::operator==(int) const Unexecuted instantiation: upx::TriBool<int, true>::operator==(int) const Unexecuted instantiation: upx::TriBool<unsigned int, true>::operator==(unsigned int) const Unexecuted instantiation: upx::TriBool<long long, true>::operator==(long long) const Unexecuted instantiation: upx::TriBool<unsigned long long, true>::operator==(unsigned long long) const |
659 | | |
660 | | // "Third" can mean many things - depending on usage context, so provide some alternate names: |
661 | | #if 0 |
662 | | // constexpr bool isDefault() const noexcept { return isThird(); } // might be misleading |
663 | | constexpr bool isIndeterminate() const noexcept { return isThird(); } |
664 | | constexpr bool isNone() const noexcept { return isThird(); } |
665 | | constexpr bool isOther() const noexcept { return isThird(); } |
666 | | constexpr bool isUndecided() const noexcept { return isThird(); } |
667 | | // constexpr bool isUnset() const noexcept { return isThird(); } // might be misleading |
668 | | #endif |
669 | | |
670 | | private: |
671 | | value_type value = False; // the actual value of this type |
672 | | UPX_CXX_DISABLE_NEW_DELETE_NO_VIRTUAL(TriBool) // UPX convention |
673 | | }; |
674 | | |
675 | | typedef TriBool<> tribool; |
676 | | |
677 | | /************************************************************************* |
678 | | // OptVar and oassign |
679 | | **************************************************************************/ |
680 | | |
681 | | template <class T, T default_value_, T min_value_, T max_value_> |
682 | | struct OptVar final { |
683 | | static_assert(std::is_integral_v<T>); |
684 | | typedef T value_type; |
685 | | static constexpr T default_value = default_value_; |
686 | | static constexpr T min_value = min_value_; |
687 | | static constexpr T max_value = max_value_; |
688 | | static_assert(min_value <= default_value && default_value <= max_value); |
689 | | |
690 | 1.67M | explicit constexpr OptVar() noexcept {}upx::OptVar<unsigned int, 8u, 1u, 9u>::OptVar() Line | Count | Source | 690 | 209k | explicit constexpr OptVar() noexcept {} |
upx::OptVar<unsigned int, 15u, 9u, 15u>::OptVar() Line | Count | Source | 690 | 209k | explicit constexpr OptVar() noexcept {} |
upx::OptVar<unsigned int, 0u, 0u, 4u>::OptVar() Line | Count | Source | 690 | 418k | explicit constexpr OptVar() noexcept {} |
upx::OptVar<unsigned int, 2u, 0u, 4u>::OptVar() Line | Count | Source | 690 | 209k | explicit constexpr OptVar() noexcept {} |
upx::OptVar<unsigned int, 3u, 0u, 8u>::OptVar() Line | Count | Source | 690 | 209k | explicit constexpr OptVar() noexcept {} |
upx::OptVar<unsigned int, 4194304u, 1u, 1073741824u>::OptVar() Line | Count | Source | 690 | 209k | explicit constexpr OptVar() noexcept {} |
upx::OptVar<unsigned int, 64u, 5u, 273u>::OptVar() Line | Count | Source | 690 | 209k | explicit constexpr OptVar() noexcept {} |
|
691 | | |
692 | | // automatic conversion |
693 | 0 | constexpr operator T() const noexcept { return value; }Unexecuted instantiation: upx::OptVar<unsigned int, 15u, 9u, 15u>::operator unsigned int() const Unexecuted instantiation: upx::OptVar<unsigned int, 8u, 1u, 9u>::operator unsigned int() const Unexecuted instantiation: upx::OptVar<unsigned int, 0u, 0u, 4u>::operator unsigned int() const |
694 | | |
695 | 0 | static void assertValue(const T &value) noexcept { |
696 | | // info: this generates annoying warnings "unsigned >= 0 is always true" |
697 | | // assert_noexcept(value >= min_value); |
698 | 0 | assert_noexcept(value == min_value || value >= min_value + 1); |
699 | 0 | assert_noexcept(value <= max_value); |
700 | 0 | } Unexecuted instantiation: upx::OptVar<unsigned int, 2u, 0u, 4u>::assertValue(unsigned int const&) Unexecuted instantiation: upx::OptVar<unsigned int, 0u, 0u, 4u>::assertValue(unsigned int const&) Unexecuted instantiation: upx::OptVar<unsigned int, 3u, 0u, 8u>::assertValue(unsigned int const&) Unexecuted instantiation: upx::OptVar<unsigned int, 4194304u, 1u, 1073741824u>::assertValue(unsigned int const&) Unexecuted instantiation: upx::OptVar<unsigned int, 64u, 5u, 273u>::assertValue(unsigned int const&) Unexecuted instantiation: upx::OptVar<unsigned int, 8u, 1u, 9u>::assertValue(unsigned int const&) Unexecuted instantiation: upx::OptVar<unsigned int, 15u, 9u, 15u>::assertValue(unsigned int const&) |
701 | | void assertValue() const noexcept { assertValue(value); } |
702 | | |
703 | 0 | OptVar &operator=(const T &other) noexcept { // copy constructor |
704 | 0 | assertValue(other); |
705 | 0 | value = other; |
706 | 0 | is_set = true; |
707 | 0 | return *this; |
708 | 0 | } Unexecuted instantiation: upx::OptVar<unsigned int, 2u, 0u, 4u>::operator=(unsigned int const&) Unexecuted instantiation: upx::OptVar<unsigned int, 0u, 0u, 4u>::operator=(unsigned int const&) Unexecuted instantiation: upx::OptVar<unsigned int, 3u, 0u, 8u>::operator=(unsigned int const&) Unexecuted instantiation: upx::OptVar<unsigned int, 4194304u, 1u, 1073741824u>::operator=(unsigned int const&) Unexecuted instantiation: upx::OptVar<unsigned int, 64u, 5u, 273u>::operator=(unsigned int const&) Unexecuted instantiation: upx::OptVar<unsigned int, 8u, 1u, 9u>::operator=(unsigned int const&) Unexecuted instantiation: upx::OptVar<unsigned int, 15u, 9u, 15u>::operator=(unsigned int const&) |
709 | | |
710 | 1.83M | void reset() noexcept { |
711 | 1.83M | value = default_value; |
712 | 1.83M | is_set = false; |
713 | 1.83M | } upx::OptVar<unsigned int, 2u, 0u, 4u>::reset() Line | Count | Source | 710 | 229k | void reset() noexcept { | 711 | 229k | value = default_value; | 712 | 229k | is_set = false; | 713 | 229k | } |
upx::OptVar<unsigned int, 0u, 0u, 4u>::reset() Line | Count | Source | 710 | 459k | void reset() noexcept { | 711 | 459k | value = default_value; | 712 | 459k | is_set = false; | 713 | 459k | } |
upx::OptVar<unsigned int, 3u, 0u, 8u>::reset() Line | Count | Source | 710 | 229k | void reset() noexcept { | 711 | 229k | value = default_value; | 712 | 229k | is_set = false; | 713 | 229k | } |
upx::OptVar<unsigned int, 4194304u, 1u, 1073741824u>::reset() Line | Count | Source | 710 | 229k | void reset() noexcept { | 711 | 229k | value = default_value; | 712 | 229k | is_set = false; | 713 | 229k | } |
upx::OptVar<unsigned int, 64u, 5u, 273u>::reset() Line | Count | Source | 710 | 229k | void reset() noexcept { | 711 | 229k | value = default_value; | 712 | 229k | is_set = false; | 713 | 229k | } |
upx::OptVar<unsigned int, 8u, 1u, 9u>::reset() Line | Count | Source | 710 | 229k | void reset() noexcept { | 711 | 229k | value = default_value; | 712 | 229k | is_set = false; | 713 | 229k | } |
upx::OptVar<unsigned int, 15u, 9u, 15u>::reset() Line | Count | Source | 710 | 229k | void reset() noexcept { | 711 | 229k | value = default_value; | 712 | 229k | is_set = false; | 713 | 229k | } |
|
714 | | |
715 | | value_type value = default_value; |
716 | | bool is_set = false; |
717 | | UPX_CXX_DISABLE_NEW_DELETE_NO_VIRTUAL(OptVar) // UPX convention |
718 | | }; |
719 | | |
720 | | // optional assignments |
721 | | template <class T, T a, T b, T c> |
722 | 0 | inline void oassign(OptVar<T, a, b, c> &self, const OptVar<T, a, b, c> &other) noexcept { |
723 | 0 | if (other.is_set) { |
724 | 0 | self.value = other.value; |
725 | 0 | self.is_set = true; |
726 | 0 | } |
727 | 0 | } Unexecuted instantiation: _ZN3upx7oassignIjTnT_Lj8ETnS1_Lj1ETnS1_Lj9EEEvRNS_6OptVarIS1_XT0_EXT1_EXT2_EEERKS3_ Unexecuted instantiation: _ZN3upx7oassignIjTnT_Lj15ETnS1_Lj9ETnS1_Lj15EEEvRNS_6OptVarIS1_XT0_EXT1_EXT2_EEERKS3_ Unexecuted instantiation: _ZN3upx7oassignIjTnT_Lj0ETnS1_Lj0ETnS1_Lj4EEEvRNS_6OptVarIS1_XT0_EXT1_EXT2_EEERKS3_ Unexecuted instantiation: _ZN3upx7oassignIjTnT_Lj2ETnS1_Lj0ETnS1_Lj4EEEvRNS_6OptVarIS1_XT0_EXT1_EXT2_EEERKS3_ Unexecuted instantiation: _ZN3upx7oassignIjTnT_Lj3ETnS1_Lj0ETnS1_Lj8EEEvRNS_6OptVarIS1_XT0_EXT1_EXT2_EEERKS3_ Unexecuted instantiation: _ZN3upx7oassignIjTnT_Lj4194304ETnS1_Lj1ETnS1_Lj1073741824EEEvRNS_6OptVarIS1_XT0_EXT1_EXT2_EEERKS3_ Unexecuted instantiation: _ZN3upx7oassignIjTnT_Lj64ETnS1_Lj5ETnS1_Lj273EEEvRNS_6OptVarIS1_XT0_EXT1_EXT2_EEERKS3_ |
728 | | template <class T, T a, T b, T c> |
729 | 0 | inline void oassign(T &v, const OptVar<T, a, b, c> &other) noexcept { |
730 | 0 | if (other.is_set) |
731 | 0 | v = other.value; |
732 | 0 | } Unexecuted instantiation: _ZN3upx7oassignIjTnT_Lj2ETnS1_Lj0ETnS1_Lj4EEEvRS1_RKNS_6OptVarIS1_XT0_EXT1_EXT2_EEE Unexecuted instantiation: _ZN3upx7oassignIjTnT_Lj0ETnS1_Lj0ETnS1_Lj4EEEvRS1_RKNS_6OptVarIS1_XT0_EXT1_EXT2_EEE Unexecuted instantiation: _ZN3upx7oassignIjTnT_Lj3ETnS1_Lj0ETnS1_Lj8EEEvRS1_RKNS_6OptVarIS1_XT0_EXT1_EXT2_EEE Unexecuted instantiation: _ZN3upx7oassignIjTnT_Lj4194304ETnS1_Lj1ETnS1_Lj1073741824EEEvRS1_RKNS_6OptVarIS1_XT0_EXT1_EXT2_EEE Unexecuted instantiation: _ZN3upx7oassignIjTnT_Lj64ETnS1_Lj5ETnS1_Lj273EEEvRS1_RKNS_6OptVarIS1_XT0_EXT1_EXT2_EEE |
733 | | |
734 | | /************************************************************************* |
735 | | // OwningPointer(T) |
736 | | // simple pointer type alias to explicitly mark ownership of objects; purely |
737 | | // cosmetic to improve source code readability, no real functionality |
738 | | **************************************************************************/ |
739 | | |
740 | | #if 0 |
741 | | |
742 | | // this works |
743 | | #define OwningPointer(T) T * |
744 | | |
745 | | #elif !(DEBUG) |
746 | | |
747 | | // this also works |
748 | | template <class T> |
749 | | using OwningPointer = T *; |
750 | | #define OwningPointer(T) upx::OwningPointer<T> |
751 | | |
752 | | #else |
753 | | |
754 | | // also works: a trivial class with just a number of no-ops |
755 | | template <class T> |
756 | | struct OwningPointer final { |
757 | | typedef typename std::add_lvalue_reference<T>::type reference; |
758 | | typedef typename std::add_lvalue_reference<const T>::type const_reference; |
759 | | typedef typename std::add_pointer<T>::type pointer; |
760 | | typedef typename std::add_pointer<const T>::type const_pointer; |
761 | | constexpr OwningPointer(pointer p) noexcept : ptr(p) {} |
762 | | constexpr operator pointer() noexcept { return ptr; } |
763 | | constexpr operator const_pointer() const noexcept { return ptr; } |
764 | | constexpr reference operator*() noexcept { return *ptr; } |
765 | | constexpr const_reference operator*() const noexcept { return *ptr; } |
766 | | constexpr pointer operator->() noexcept { return ptr; } |
767 | | constexpr const_pointer operator->() const noexcept { return ptr; } |
768 | | private: |
769 | | pointer ptr; |
770 | | reference operator[](std::ptrdiff_t) noexcept DELETED_FUNCTION; |
771 | | const_reference operator[](std::ptrdiff_t) const noexcept DELETED_FUNCTION; |
772 | | UPX_CXX_DISABLE_ADDRESS(OwningPointer) // UPX convention |
773 | | UPX_CXX_DISABLE_NEW_DELETE_NO_VIRTUAL(OwningPointer) // UPX convention |
774 | | }; |
775 | | // must overload mem_clear() |
776 | | template <class T> |
777 | | inline void mem_clear(OwningPointer<T> object) noexcept { |
778 | | mem_clear((T *) object); |
779 | | } |
780 | | #define OwningPointer(T) upx::OwningPointer<T> |
781 | | |
782 | | #endif |
783 | | |
784 | | template <class T> |
785 | 1.96M | inline void owner_delete(OwningPointer(T)(&object)) noexcept { |
786 | 1.96M | static_assert(std::is_class_v<T>); // UPX convention |
787 | 1.96M | static_assert(std::is_nothrow_destructible_v<T>); |
788 | 1.96M | if (object != nullptr) { |
789 | 1.29M | delete (T *) object; // single object delete |
790 | 1.29M | object = nullptr; |
791 | 1.29M | } |
792 | 1.96M | assert_noexcept((T *) object == nullptr); |
793 | 1.96M | assert_noexcept(object == nullptr); |
794 | 1.96M | } void upx::owner_delete<UiPacker>(UiPacker*&) Line | Count | Source | 785 | 647k | inline void owner_delete(OwningPointer(T)(&object)) noexcept { | 786 | 647k | static_assert(std::is_class_v<T>); // UPX convention | 787 | 647k | static_assert(std::is_nothrow_destructible_v<T>); | 788 | 647k | if (object != nullptr) { | 789 | 647k | delete (T *) object; // single object delete | 790 | 647k | object = nullptr; | 791 | 647k | } | 792 | 647k | assert_noexcept((T *) object == nullptr); | 793 | 647k | assert_noexcept(object == nullptr); | 794 | 647k | } |
void upx::owner_delete<ElfLinker>(ElfLinker*&) Line | Count | Source | 785 | 647k | inline void owner_delete(OwningPointer(T)(&object)) noexcept { | 786 | 647k | static_assert(std::is_class_v<T>); // UPX convention | 787 | 647k | static_assert(std::is_nothrow_destructible_v<T>); | 788 | 647k | if (object != nullptr) { | 789 | 0 | delete (T *) object; // single object delete | 790 | 0 | object = nullptr; | 791 | 0 | } | 792 | 647k | assert_noexcept((T *) object == nullptr); | 793 | 647k | assert_noexcept(object == nullptr); | 794 | 647k | } |
void upx::owner_delete<PackerBase>(PackerBase*&) Line | Count | Source | 785 | 20.8k | inline void owner_delete(OwningPointer(T)(&object)) noexcept { | 786 | 20.8k | static_assert(std::is_class_v<T>); // UPX convention | 787 | 20.8k | static_assert(std::is_nothrow_destructible_v<T>); | 788 | 20.8k | if (object != nullptr) { | 789 | 3.22k | delete (T *) object; // single object delete | 790 | 3.22k | object = nullptr; | 791 | 3.22k | } | 792 | 20.8k | assert_noexcept((T *) object == nullptr); | 793 | 20.8k | assert_noexcept(object == nullptr); | 794 | 20.8k | } |
void upx::owner_delete<UiPacker::State>(UiPacker::State*&) Line | Count | Source | 785 | 647k | inline void owner_delete(OwningPointer(T)(&object)) noexcept { | 786 | 647k | static_assert(std::is_class_v<T>); // UPX convention | 787 | 647k | static_assert(std::is_nothrow_destructible_v<T>); | 788 | 647k | if (object != nullptr) { | 789 | 647k | delete (T *) object; // single object delete | 790 | 647k | object = nullptr; | 791 | 647k | } | 792 | 647k | assert_noexcept((T *) object == nullptr); | 793 | 647k | assert_noexcept(object == nullptr); | 794 | 647k | } |
|
795 | | |
796 | | template <class T> |
797 | 6.33M | inline void owner_free(OwningPointer(T)(&object)) noexcept { |
798 | 6.33M | static_assert(!std::is_class_v<T>); // UPX convention |
799 | 6.33M | if (object != nullptr) { |
800 | 6.33M | ::free((T *) object); // free memory from malloc() |
801 | 6.33M | object = nullptr; |
802 | 6.33M | } |
803 | 6.33M | assert_noexcept((T *) object == nullptr); |
804 | 6.33M | assert_noexcept(object == nullptr); |
805 | 6.33M | } |
806 | | |
807 | | // disable some overloads |
808 | | #if defined(__clang__) || __GNUC__ != 7 |
809 | | template <class T> |
810 | | inline void owner_delete(T (&array)[]) noexcept DELETED_FUNCTION; |
811 | | template <class T> |
812 | | inline void owner_free(T (&array)[]) noexcept DELETED_FUNCTION; |
813 | | #endif |
814 | | template <class T, std::size_t N> |
815 | | inline void owner_delete(T (&array)[N]) noexcept DELETED_FUNCTION; |
816 | | template <class T, std::size_t N> |
817 | | inline void owner_free(T (&array)[N]) noexcept DELETED_FUNCTION; |
818 | | |
819 | | } // namespace upx |