Coverage Report

Created: 2025-12-14 06:35

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/upx/src/util/xspan_fwd.h
Line
Count
Source
1
/* xspan -- a minimally invasive checked memory smart pointer
2
3
   This file is part of the UPX executable compressor.
4
5
   Copyright (C) 1996-2025 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
// manually forward a number of well-known functions using a checked "raw_bytes()" call
28
//
29
// uses C
30
// uses optional D, E and XSPAN_FWD_C_IS_MEMBUFFER
31
// needs XSPAN_REQUIRES_CONVERTIBLE_ANY_DIRECTION
32
//
33
// example for a default implementation:
34
//   #define XSPAN_REQUIRES_CONVERTIBLE_ANY_DIRECTION(A, B, RType)
35
//       std::enable_if_t<std::is_convertible_v<A *, B *> || std::is_convertible_v<B *, A *>, RType>
36
37
// requires convertible T* to U* or U* to T*
38
#define XSPAN_FWD_TU_CONVERTIBLE(RType)                                                            \
39
    template <class T, class U>                                                                    \
40
    inline XSPAN_REQUIRES_CONVERTIBLE_ANY_DIRECTION(T, U, RType)
41
// requires convertible to void* (i.e. any pointer type matches)
42
#define XSPAN_FWD_TU_VOIDPTR(RType)                                                                \
43
    template <class T, class U>                                                                    \
44
    inline RType
45
46
/*************************************************************************
47
// overloads of global operators
48
**************************************************************************/
49
50
#ifndef XSPAN_FWD_C_IS_MEMBUFFER
51
52
// global operator: disallow "n + C" => force using "C + n" (member function) instead
53
template <class T, class U>
54
inline typename std::enable_if<std::is_integral<U>::value, void *>::type operator+(U, const C<T> &)
55
    XSPAN_DELETED_FUNCTION;
56
57
#endif // XSPAN_FWD_C_IS_MEMBUFFER
58
59
/*************************************************************************
60
// overloads for standard functions
61
**************************************************************************/
62
63
template <class T>
64
inline void *memchr(const C<T> &a, int v, size_t n) {
65
    return memchr(a.raw_bytes(n), v, n);
66
}
67
template <class T>
68
0
inline const void *memchr(const C<const T> &a, int v, size_t n) {
69
0
    return memchr(a.raw_bytes(n), v, n);
70
0
}
71
72
template <class T>
73
37.5k
inline int memcmp(const C<T> &a, const void *b, size_t n) {
74
37.5k
    return memcmp(a.raw_bytes(n), b, n);
75
37.5k
}
76
template <class T>
77
18.7k
inline int memcmp(const void *a, const C<T> &b, size_t n) {
78
18.7k
    return memcmp(a, b.raw_bytes(n), n);
79
18.7k
}
int memcmp<unsigned char>(void const*, MemBufferBase<unsigned char> const&, unsigned long)
Line
Count
Source
77
18.7k
inline int memcmp(const void *a, const C<T> &b, size_t n) {
78
18.7k
    return memcmp(a, b.raw_bytes(n), n);
79
18.7k
}
Unexecuted instantiation: int memcmp<unsigned char const>(void const*, XSpan::Span<unsigned char const> const&, unsigned long)
80
37.5k
XSPAN_FWD_TU_VOIDPTR(int) memcmp(const C<T> &a, const C<U> &b, size_t n) {
81
37.5k
    return memcmp(a.raw_bytes(n), b.raw_bytes(n), n);
82
37.5k
}
83
#ifdef D
84
XSPAN_FWD_TU_VOIDPTR(int) memcmp(const C<T> &a, const D<U> &b, size_t n) {
85
    return memcmp(a.raw_bytes(n), b.raw_bytes(n), n);
86
}
87
#endif
88
#ifdef E
89
XSPAN_FWD_TU_VOIDPTR(int) memcmp(const C<T> &a, const E<U> &b, size_t n) {
90
    return memcmp(a.raw_bytes(n), b.raw_bytes(n), n);
91
}
92
#endif
93
94
template <class T>
95
852
inline void *memcpy(const C<T> a, const void *b, size_t n) {
96
852
    return memcpy(a.raw_bytes(n), b, n);
97
852
}
void* memcpy<unsigned char>(MemBufferBase<unsigned char>, void const*, unsigned long)
Line
Count
Source
95
678
inline void *memcpy(const C<T> a, const void *b, size_t n) {
96
678
    return memcpy(a.raw_bytes(n), b, n);
97
678
}
void* memcpy<unsigned char>(XSpan::Span<unsigned char>, void const*, unsigned long)
Line
Count
Source
95
174
inline void *memcpy(const C<T> a, const void *b, size_t n) {
96
174
    return memcpy(a.raw_bytes(n), b, n);
97
174
}
Unexecuted instantiation: void* memcpy<unsigned char>(XSpan::PtrOrSpanOrNull<unsigned char>, void const*, unsigned long)
98
template <class T>
99
158
inline void *memcpy(void *a, const C<T> &b, size_t n) {
100
158
    return memcpy(a, b.raw_bytes(n), n);
101
158
}
void* memcpy<unsigned char>(void*, XSpan::Span<unsigned char> const&, unsigned long)
Line
Count
Source
99
139
inline void *memcpy(void *a, const C<T> &b, size_t n) {
100
139
    return memcpy(a, b.raw_bytes(n), n);
101
139
}
Unexecuted instantiation: void* memcpy<unsigned char>(void*, XSpan::PtrOrSpanOrNull<unsigned char> const&, unsigned long)
Unexecuted instantiation: void* memcpy<unsigned char>(void*, MemBufferBase<unsigned char> const&, unsigned long)
void* memcpy<unsigned char const>(void*, XSpan::Span<unsigned char const> const&, unsigned long)
Line
Count
Source
99
19
inline void *memcpy(void *a, const C<T> &b, size_t n) {
100
19
    return memcpy(a, b.raw_bytes(n), n);
101
19
}
Unexecuted instantiation: void* memcpy<PeFile::pe_section_t>(void*, XSpan::PtrOrSpanOrNull<PeFile::pe_section_t> const&, unsigned long)
102
193
XSPAN_FWD_TU_VOIDPTR(void *) memcpy(const C<T> &a, const C<U> &b, size_t n) {
103
193
    return memcpy(a.raw_bytes(n), b.raw_bytes(n), n);
104
193
}
105
#ifdef D
106
XSPAN_FWD_TU_VOIDPTR(void *) memcpy(const C<T> &a, const D<U> &b, size_t n) {
107
    return memcpy(a.raw_bytes(n), b.raw_bytes(n), n);
108
}
109
#endif
110
#ifdef E
111
0
XSPAN_FWD_TU_VOIDPTR(void *) memcpy(const C<T> &a, const E<U> &b, size_t n) {
112
0
    return memcpy(a.raw_bytes(n), b.raw_bytes(n), n);
113
0
}
114
#endif
115
116
template <class T>
117
0
inline void *memmove(const C<T> a, const void *b, size_t n) {
118
0
    return memmove(a.raw_bytes(n), b, n);
119
0
}
120
template <class T>
121
0
inline void *memmove(void *a, const C<T> &b, size_t n) {
122
0
    return memmove(a, b.raw_bytes(n), n);
123
0
}
124
6.51k
XSPAN_FWD_TU_VOIDPTR(void *) memmove(const C<T> &a, const C<U> &b, size_t n) {
125
6.51k
    return memmove(a.raw_bytes(n), b.raw_bytes(n), n);
126
6.51k
}
Unexecuted instantiation: void* memmove<unsigned char, unsigned char>(XSpan::PtrOrSpanOrNull<unsigned char> const&, XSpan::PtrOrSpanOrNull<unsigned char> const&, unsigned long)
void* memmove<unsigned char, unsigned char const>(XSpan::Span<unsigned char> const&, XSpan::Span<unsigned char const> const&, unsigned long)
Line
Count
Source
124
6.51k
XSPAN_FWD_TU_VOIDPTR(void *) memmove(const C<T> &a, const C<U> &b, size_t n) {
125
6.51k
    return memmove(a.raw_bytes(n), b.raw_bytes(n), n);
126
6.51k
}
127
#ifdef D
128
XSPAN_FWD_TU_VOIDPTR(void *) memmove(const C<T> &a, const D<U> &b, size_t n) {
129
    return memmove(a.raw_bytes(n), b.raw_bytes(n), n);
130
}
131
#endif
132
#ifdef E
133
XSPAN_FWD_TU_VOIDPTR(void *) memmove(const C<T> &a, const E<U> &b, size_t n) {
134
    return memmove(a.raw_bytes(n), b.raw_bytes(n), n);
135
}
136
#endif
137
138
template <class T>
139
37.5k
inline void *memset(const C<T> &a, int v, size_t n) {
140
37.5k
    return memset(a.raw_bytes(n), v, n);
141
37.5k
}
Unexecuted instantiation: void* memset<unsigned char>(XSpan::Span<unsigned char> const&, int, unsigned long)
void* memset<unsigned char>(MemBufferBase<unsigned char> const&, int, unsigned long)
Line
Count
Source
139
37.5k
inline void *memset(const C<T> &a, int v, size_t n) {
140
37.5k
    return memset(a.raw_bytes(n), v, n);
141
37.5k
}
Unexecuted instantiation: void* memset<unsigned char>(XSpan::PtrOrSpanOrNull<unsigned char> const&, int, unsigned long)
142
143
/*************************************************************************
144
// overloads for UPX extras 1
145
**************************************************************************/
146
147
template <class T>
148
0
inline int ptr_diff_bytes(const C<T> &a, const void *b) {
149
0
    return ptr_diff_bytes(a.raw_bytes(0), b);
150
0
}
151
template <class T>
152
0
inline int ptr_diff_bytes(const void *a, const C<T> &b) {
153
0
    return ptr_diff_bytes(a, b.raw_bytes(0));
154
0
}
155
51.2k
XSPAN_FWD_TU_VOIDPTR(int) ptr_diff_bytes(const C<T> &a, const C<U> &b) {
156
51.2k
    return ptr_diff_bytes(a.raw_bytes(0), b.raw_bytes(0));
157
51.2k
}
Unexecuted instantiation: int ptr_diff_bytes<unsigned char const, unsigned char const>(XSpan::Span<unsigned char const> const&, XSpan::Span<unsigned char const> const&)
int ptr_diff_bytes<LE16, unsigned char>(XSpan::PtrOrSpanOrNull<LE16> const&, XSpan::PtrOrSpanOrNull<unsigned char> const&)
Line
Count
Source
155
51.2k
XSPAN_FWD_TU_VOIDPTR(int) ptr_diff_bytes(const C<T> &a, const C<U> &b) {
156
51.2k
    return ptr_diff_bytes(a.raw_bytes(0), b.raw_bytes(0));
157
51.2k
}
158
#ifdef D
159
0
XSPAN_FWD_TU_VOIDPTR(int) ptr_diff_bytes(const C<T> &a, const D<U> &b) {
160
0
    return ptr_diff_bytes(a.raw_bytes(0), b.raw_bytes(0));
161
0
}
162
#endif
163
#ifdef E
164
XSPAN_FWD_TU_VOIDPTR(int) ptr_diff_bytes(const C<T> &a, const E<U> &b) {
165
    return ptr_diff_bytes(a.raw_bytes(0), b.raw_bytes(0));
166
}
167
#endif
168
169
template <class T>
170
5
inline unsigned ptr_udiff_bytes(const C<T> &a, const void *b) {
171
5
    return ptr_udiff_bytes(a.raw_bytes(0), b);
172
5
}
Unexecuted instantiation: unsigned int ptr_udiff_bytes<unsigned char const>(XSpan::Span<unsigned char const> const&, void const*)
Unexecuted instantiation: unsigned int ptr_udiff_bytes<unsigned char>(XSpan::Span<unsigned char> const&, void const*)
unsigned int ptr_udiff_bytes<LE32>(XSpan::Span<LE32> const&, void const*)
Line
Count
Source
170
5
inline unsigned ptr_udiff_bytes(const C<T> &a, const void *b) {
171
5
    return ptr_udiff_bytes(a.raw_bytes(0), b);
172
5
}
Unexecuted instantiation: unsigned int ptr_udiff_bytes<unsigned char>(XSpan::PtrOrSpanOrNull<unsigned char> const&, void const*)
173
template <class T>
174
0
inline unsigned ptr_udiff_bytes(const void *a, const C<T> &b) {
175
0
    return ptr_udiff_bytes(a, b.raw_bytes(0));
176
0
}
Unexecuted instantiation: unsigned int ptr_udiff_bytes<unsigned char>(void const*, MemBufferBase<unsigned char> const&)
Unexecuted instantiation: unsigned int ptr_udiff_bytes<unsigned char>(void const*, XSpan::PtrOrSpanOrNull<unsigned char> const&)
177
112k
XSPAN_FWD_TU_VOIDPTR(unsigned) ptr_udiff_bytes(const C<T> &a, const C<U> &b) {
178
112k
    return ptr_udiff_bytes(a.raw_bytes(0), b.raw_bytes(0));
179
112k
}
unsigned int ptr_udiff_bytes<unsigned short, char>(XSpan::PtrOrSpanOrNull<unsigned short> const&, XSpan::PtrOrSpanOrNull<char> const&)
Line
Count
Source
177
37.5k
XSPAN_FWD_TU_VOIDPTR(unsigned) ptr_udiff_bytes(const C<T> &a, const C<U> &b) {
178
37.5k
    return ptr_udiff_bytes(a.raw_bytes(0), b.raw_bytes(0));
179
37.5k
}
unsigned int ptr_udiff_bytes<unsigned short, char>(XSpan::PtrOrSpan<unsigned short> const&, XSpan::PtrOrSpan<char> const&)
Line
Count
Source
177
37.5k
XSPAN_FWD_TU_VOIDPTR(unsigned) ptr_udiff_bytes(const C<T> &a, const C<U> &b) {
178
37.5k
    return ptr_udiff_bytes(a.raw_bytes(0), b.raw_bytes(0));
179
37.5k
}
unsigned int ptr_udiff_bytes<unsigned short, char>(XSpan::Span<unsigned short> const&, XSpan::Span<char> const&)
Line
Count
Source
177
37.5k
XSPAN_FWD_TU_VOIDPTR(unsigned) ptr_udiff_bytes(const C<T> &a, const C<U> &b) {
178
37.5k
    return ptr_udiff_bytes(a.raw_bytes(0), b.raw_bytes(0));
179
37.5k
}
Unexecuted instantiation: unsigned int ptr_udiff_bytes<unsigned char, unsigned char>(XSpan::Span<unsigned char> const&, XSpan::Span<unsigned char> const&)
Unexecuted instantiation: unsigned int ptr_udiff_bytes<unsigned char const, unsigned char const>(XSpan::Span<unsigned char const> const&, XSpan::Span<unsigned char const> const&)
Unexecuted instantiation: unsigned int ptr_udiff_bytes<unsigned char, unsigned char>(XSpan::PtrOrSpanOrNull<unsigned char> const&, XSpan::PtrOrSpanOrNull<unsigned char> const&)
180
#ifdef D
181
112k
XSPAN_FWD_TU_VOIDPTR(unsigned) ptr_udiff_bytes(const C<T> &a, const D<U> &b) {
182
112k
    return ptr_udiff_bytes(a.raw_bytes(0), b.raw_bytes(0));
183
112k
}
unsigned int ptr_udiff_bytes<unsigned short, char>(XSpan::PtrOrSpan<unsigned short> const&, XSpan::PtrOrSpanOrNull<char> const&)
Line
Count
Source
181
37.5k
XSPAN_FWD_TU_VOIDPTR(unsigned) ptr_udiff_bytes(const C<T> &a, const D<U> &b) {
182
37.5k
    return ptr_udiff_bytes(a.raw_bytes(0), b.raw_bytes(0));
183
37.5k
}
unsigned int ptr_udiff_bytes<unsigned short, char>(XSpan::Span<unsigned short> const&, XSpan::PtrOrSpanOrNull<char> const&)
Line
Count
Source
181
37.5k
XSPAN_FWD_TU_VOIDPTR(unsigned) ptr_udiff_bytes(const C<T> &a, const D<U> &b) {
182
37.5k
    return ptr_udiff_bytes(a.raw_bytes(0), b.raw_bytes(0));
183
37.5k
}
unsigned int ptr_udiff_bytes<unsigned short, char>(XSpan::PtrOrSpanOrNull<unsigned short> const&, XSpan::PtrOrSpan<char> const&)
Line
Count
Source
181
37.5k
XSPAN_FWD_TU_VOIDPTR(unsigned) ptr_udiff_bytes(const C<T> &a, const D<U> &b) {
182
37.5k
    return ptr_udiff_bytes(a.raw_bytes(0), b.raw_bytes(0));
183
37.5k
}
184
#endif
185
#ifdef E
186
112k
XSPAN_FWD_TU_VOIDPTR(unsigned) ptr_udiff_bytes(const C<T> &a, const E<U> &b) {
187
112k
    return ptr_udiff_bytes(a.raw_bytes(0), b.raw_bytes(0));
188
112k
}
unsigned int ptr_udiff_bytes<unsigned short, char>(XSpan::Span<unsigned short> const&, XSpan::PtrOrSpan<char> const&)
Line
Count
Source
186
37.5k
XSPAN_FWD_TU_VOIDPTR(unsigned) ptr_udiff_bytes(const C<T> &a, const E<U> &b) {
187
37.5k
    return ptr_udiff_bytes(a.raw_bytes(0), b.raw_bytes(0));
188
37.5k
}
unsigned int ptr_udiff_bytes<unsigned short, char>(XSpan::PtrOrSpanOrNull<unsigned short> const&, XSpan::Span<char> const&)
Line
Count
Source
186
37.5k
XSPAN_FWD_TU_VOIDPTR(unsigned) ptr_udiff_bytes(const C<T> &a, const E<U> &b) {
187
37.5k
    return ptr_udiff_bytes(a.raw_bytes(0), b.raw_bytes(0));
188
37.5k
}
unsigned int ptr_udiff_bytes<unsigned short, char>(XSpan::PtrOrSpan<unsigned short> const&, XSpan::Span<char> const&)
Line
Count
Source
186
37.5k
XSPAN_FWD_TU_VOIDPTR(unsigned) ptr_udiff_bytes(const C<T> &a, const E<U> &b) {
187
37.5k
    return ptr_udiff_bytes(a.raw_bytes(0), b.raw_bytes(0));
188
37.5k
}
189
#endif
190
191
/*************************************************************************
192
// overloads for UPX extras 2
193
**************************************************************************/
194
195
#ifdef UPX_VERSION_HEX
196
197
template <class T>
198
0
inline unsigned upx_adler32(const C<T> &a, unsigned n, unsigned adler = 1) {
199
0
    return upx_adler32(a.raw_bytes(n), n, adler);
200
0
}
Unexecuted instantiation: unsigned int upx_adler32<unsigned char>(MemBufferBase<unsigned char> const&, unsigned int, unsigned int)
Unexecuted instantiation: unsigned int upx_adler32<unsigned char>(XSpan::PtrOrSpan<unsigned char> const&, unsigned int, unsigned int)
Unexecuted instantiation: unsigned int upx_adler32<unsigned char>(XSpan::Span<unsigned char> const&, unsigned int, unsigned int)
Unexecuted instantiation: unsigned int upx_adler32<unsigned char const>(XSpan::Span<unsigned char const> const&, unsigned int, unsigned int)
201
202
template <class T>
203
300k
inline unsigned get_ne16(const C<T> &a) {
204
300k
    return get_ne16(a.raw_bytes(2));
205
300k
}
206
template <class T>
207
300k
inline unsigned get_ne24(const C<T> &a) {
208
300k
    return get_ne24(a.raw_bytes(3));
209
300k
}
210
template <class T>
211
351k
inline unsigned get_ne32(const C<T> &a) {
212
351k
    return get_ne32(a.raw_bytes(4));
213
351k
}
unsigned int get_ne32<unsigned char const>(XSpan::PtrOrSpan<unsigned char const> const&)
Line
Count
Source
211
51.2k
inline unsigned get_ne32(const C<T> &a) {
212
51.2k
    return get_ne32(a.raw_bytes(4));
213
51.2k
}
unsigned int get_ne32<unsigned char>(MemBufferBase<unsigned char> const&)
Line
Count
Source
211
300k
inline unsigned get_ne32(const C<T> &a) {
212
300k
    return get_ne32(a.raw_bytes(4));
213
300k
}
214
template <class T>
215
300k
inline upx_uint64_t get_ne64(const C<T> &a) {
216
300k
    return get_ne64(a.raw_bytes(8));
217
300k
}
218
219
template <class T>
220
300k
inline unsigned get_be16(const C<T> &a) {
221
300k
    return get_be16(a.raw_bytes(2));
222
300k
}
223
template <class T>
224
300k
inline unsigned get_be24(const C<T> &a) {
225
300k
    return get_be24(a.raw_bytes(3));
226
300k
}
227
template <class T>
228
303k
inline unsigned get_be32(const C<T> &a) {
229
303k
    return get_be32(a.raw_bytes(4));
230
303k
}
unsigned int get_be32<unsigned char const>(XSpan::Span<unsigned char const> const&)
Line
Count
Source
228
3.32k
inline unsigned get_be32(const C<T> &a) {
229
3.32k
    return get_be32(a.raw_bytes(4));
230
3.32k
}
unsigned int get_be32<unsigned char>(MemBufferBase<unsigned char> const&)
Line
Count
Source
228
300k
inline unsigned get_be32(const C<T> &a) {
229
300k
    return get_be32(a.raw_bytes(4));
230
300k
}
231
template <class T>
232
300k
inline upx_uint64_t get_be64(const C<T> &a) {
233
300k
    return get_be64(a.raw_bytes(8));
234
300k
}
235
236
template <class T>
237
303k
inline unsigned get_le16(const C<T> &a) {
238
303k
    return get_le16(a.raw_bytes(2));
239
303k
}
unsigned int get_le16<unsigned char>(XSpan::Span<unsigned char> const&)
Line
Count
Source
237
56
inline unsigned get_le16(const C<T> &a) {
238
56
    return get_le16(a.raw_bytes(2));
239
56
}
unsigned int get_le16<unsigned char const>(XSpan::Span<unsigned char const> const&)
Line
Count
Source
237
2.88k
inline unsigned get_le16(const C<T> &a) {
238
2.88k
    return get_le16(a.raw_bytes(2));
239
2.88k
}
Unexecuted instantiation: unsigned int get_le16<unsigned char>(XSpan::PtrOrSpanOrNull<unsigned char> const&)
unsigned int get_le16<unsigned char>(MemBufferBase<unsigned char> const&)
Line
Count
Source
237
300k
inline unsigned get_le16(const C<T> &a) {
238
300k
    return get_le16(a.raw_bytes(2));
239
300k
}
240
template <class T>
241
300k
inline unsigned get_le24(const C<T> &a) {
242
300k
    return get_le24(a.raw_bytes(3));
243
300k
}
unsigned int get_le24<unsigned char const>(XSpan::Span<unsigned char const> const&)
Line
Count
Source
241
681
inline unsigned get_le24(const C<T> &a) {
242
681
    return get_le24(a.raw_bytes(3));
243
681
}
unsigned int get_le24<unsigned char>(MemBufferBase<unsigned char> const&)
Line
Count
Source
241
300k
inline unsigned get_le24(const C<T> &a) {
242
300k
    return get_le24(a.raw_bytes(3));
243
300k
}
244
template <class T>
245
538k
inline unsigned get_le32(const C<T> &a) {
246
538k
    return get_le32(a.raw_bytes(4));
247
538k
}
unsigned int get_le32<unsigned char const>(XSpan::Span<unsigned char const> const&)
Line
Count
Source
245
53.7k
inline unsigned get_le32(const C<T> &a) {
246
53.7k
    return get_le32(a.raw_bytes(4));
247
53.7k
}
unsigned int get_le32<unsigned char>(MemBufferBase<unsigned char> const&)
Line
Count
Source
245
300k
inline unsigned get_le32(const C<T> &a) {
246
300k
    return get_le32(a.raw_bytes(4));
247
300k
}
unsigned int get_le32<unsigned char>(XSpan::Span<unsigned char> const&)
Line
Count
Source
245
143k
inline unsigned get_le32(const C<T> &a) {
246
143k
    return get_le32(a.raw_bytes(4));
247
143k
}
Unexecuted instantiation: unsigned int get_le32<unsigned char>(XSpan::PtrOrSpanOrNull<unsigned char> const&)
unsigned int get_le32<unsigned char>(XSpan::PtrOrSpan<unsigned char> const&)
Line
Count
Source
245
41.0k
inline unsigned get_le32(const C<T> &a) {
246
41.0k
    return get_le32(a.raw_bytes(4));
247
41.0k
}
248
template <class T>
249
320k
inline upx_uint64_t get_le64(const C<T> &a) {
250
320k
    return get_le64(a.raw_bytes(8));
251
320k
}
unsigned long long get_le64<unsigned char>(XSpan::PtrOrSpan<unsigned char> const&)
Line
Count
Source
249
10.1k
inline upx_uint64_t get_le64(const C<T> &a) {
250
10.1k
    return get_le64(a.raw_bytes(8));
251
10.1k
}
unsigned long long get_le64<unsigned char>(XSpan::Span<unsigned char> const&)
Line
Count
Source
249
10.1k
inline upx_uint64_t get_le64(const C<T> &a) {
250
10.1k
    return get_le64(a.raw_bytes(8));
251
10.1k
}
unsigned long long get_le64<unsigned char>(MemBufferBase<unsigned char> const&)
Line
Count
Source
249
300k
inline upx_uint64_t get_le64(const C<T> &a) {
250
300k
    return get_le64(a.raw_bytes(8));
251
300k
}
252
253
template <class T>
254
300k
inline void set_ne16(const C<T> &a, unsigned v) {
255
300k
    return set_ne16(a.raw_bytes(2), v);
256
300k
}
257
template <class T>
258
300k
inline void set_ne24(const C<T> &a, unsigned v) {
259
300k
    return set_ne24(a.raw_bytes(3), v);
260
300k
}
261
template <class T>
262
351k
inline void set_ne32(const C<T> &a, unsigned v) {
263
351k
    return set_ne32(a.raw_bytes(4), v);
264
351k
}
void set_ne32<unsigned char>(XSpan::PtrOrSpan<unsigned char> const&, unsigned int)
Line
Count
Source
262
51.2k
inline void set_ne32(const C<T> &a, unsigned v) {
263
51.2k
    return set_ne32(a.raw_bytes(4), v);
264
51.2k
}
void set_ne32<unsigned char>(MemBufferBase<unsigned char> const&, unsigned int)
Line
Count
Source
262
300k
inline void set_ne32(const C<T> &a, unsigned v) {
263
300k
    return set_ne32(a.raw_bytes(4), v);
264
300k
}
265
template <class T>
266
300k
inline void set_ne64(const C<T> &a, upx_uint64_t v) {
267
300k
    return set_ne64(a.raw_bytes(8), v);
268
300k
}
269
270
template <class T>
271
300k
inline void set_be16(const C<T> &a, unsigned v) {
272
300k
    return set_be16(a.raw_bytes(2), v);
273
300k
}
274
template <class T>
275
300k
inline void set_be24(const C<T> &a, unsigned v) {
276
300k
    return set_be24(a.raw_bytes(3), v);
277
300k
}
278
template <class T>
279
341k
inline void set_be32(const C<T> &a, unsigned v) {
280
341k
    return set_be32(a.raw_bytes(4), v);
281
341k
}
void set_be32<unsigned char>(XSpan::PtrOrSpan<unsigned char> const&, unsigned int)
Line
Count
Source
279
41.0k
inline void set_be32(const C<T> &a, unsigned v) {
280
41.0k
    return set_be32(a.raw_bytes(4), v);
281
41.0k
}
Unexecuted instantiation: void set_be32<unsigned char>(XSpan::Span<unsigned char> const&, unsigned int)
void set_be32<unsigned char>(MemBufferBase<unsigned char> const&, unsigned int)
Line
Count
Source
279
300k
inline void set_be32(const C<T> &a, unsigned v) {
280
300k
    return set_be32(a.raw_bytes(4), v);
281
300k
}
282
template <class T>
283
310k
inline void set_be64(const C<T> &a, upx_uint64_t v) {
284
310k
    return set_be64(a.raw_bytes(8), v);
285
310k
}
void set_be64<unsigned char>(XSpan::PtrOrSpan<unsigned char> const&, unsigned long long)
Line
Count
Source
283
10.1k
inline void set_be64(const C<T> &a, upx_uint64_t v) {
284
10.1k
    return set_be64(a.raw_bytes(8), v);
285
10.1k
}
void set_be64<unsigned char>(MemBufferBase<unsigned char> const&, unsigned long long)
Line
Count
Source
283
300k
inline void set_be64(const C<T> &a, upx_uint64_t v) {
284
300k
    return set_be64(a.raw_bytes(8), v);
285
300k
}
286
287
template <class T>
288
300k
inline void set_le16(const C<T> &a, unsigned v) {
289
300k
    return set_le16(a.raw_bytes(2), v);
290
300k
}
Unexecuted instantiation: void set_le16<unsigned char>(XSpan::Span<unsigned char> const&, unsigned int)
Unexecuted instantiation: void set_le16<unsigned char>(XSpan::PtrOrSpanOrNull<unsigned char> const&, unsigned int)
void set_le16<unsigned char>(MemBufferBase<unsigned char> const&, unsigned int)
Line
Count
Source
288
300k
inline void set_le16(const C<T> &a, unsigned v) {
289
300k
    return set_le16(a.raw_bytes(2), v);
290
300k
}
291
template <class T>
292
300k
inline void set_le24(const C<T> &a, unsigned v) {
293
300k
    return set_le24(a.raw_bytes(3), v);
294
300k
}
Unexecuted instantiation: void set_le24<unsigned char>(XSpan::Span<unsigned char> const&, unsigned int)
void set_le24<unsigned char>(MemBufferBase<unsigned char> const&, unsigned int)
Line
Count
Source
292
300k
inline void set_le24(const C<T> &a, unsigned v) {
293
300k
    return set_le24(a.raw_bytes(3), v);
294
300k
}
295
template <class T>
296
341k
inline void set_le32(const C<T> &a, unsigned v) {
297
341k
    return set_le32(a.raw_bytes(4), v);
298
341k
}
void set_le32<unsigned char>(XSpan::Span<unsigned char> const&, unsigned int)
Line
Count
Source
296
41.0k
inline void set_le32(const C<T> &a, unsigned v) {
297
41.0k
    return set_le32(a.raw_bytes(4), v);
298
41.0k
}
Unexecuted instantiation: void set_le32<unsigned char>(XSpan::PtrOrSpanOrNull<unsigned char> const&, unsigned int)
void set_le32<unsigned char>(MemBufferBase<unsigned char> const&, unsigned int)
Line
Count
Source
296
300k
inline void set_le32(const C<T> &a, unsigned v) {
297
300k
    return set_le32(a.raw_bytes(4), v);
298
300k
}
299
template <class T>
300
310k
inline void set_le64(const C<T> &a, upx_uint64_t v) {
301
310k
    return set_le64(a.raw_bytes(8), v);
302
310k
}
void set_le64<unsigned char>(XSpan::Span<unsigned char> const&, unsigned long long)
Line
Count
Source
300
10.1k
inline void set_le64(const C<T> &a, upx_uint64_t v) {
301
10.1k
    return set_le64(a.raw_bytes(8), v);
302
10.1k
}
void set_le64<unsigned char>(MemBufferBase<unsigned char> const&, unsigned long long)
Line
Count
Source
300
300k
inline void set_le64(const C<T> &a, upx_uint64_t v) {
301
300k
    return set_le64(a.raw_bytes(8), v);
302
300k
}
303
304
#ifndef XSPAN_FWD_C_IS_MEMBUFFER
305
template <class T>
306
inline C<T> operator+(const C<T> &a, const BE16 &v) {
307
    return a + unsigned(v);
308
}
309
template <class T>
310
inline C<T> operator+(const C<T> &a, const BE32 &v) {
311
    return a + unsigned(v);
312
}
313
template <class T>
314
inline C<T> operator+(const C<T> &a, const LE16 &v) {
315
    return a + unsigned(v);
316
}
317
template <class T>
318
inline C<T> operator+(const C<T> &a, const LE32 &v) {
319
    return a + unsigned(v);
320
}
321
322
template <class T>
323
inline C<T> operator-(const C<T> &a, const BE16 &v) {
324
    return a - unsigned(v);
325
}
326
template <class T>
327
inline C<T> operator-(const C<T> &a, const BE32 &v) {
328
    return a - unsigned(v);
329
}
330
template <class T>
331
inline C<T> operator-(const C<T> &a, const LE16 &v) {
332
    return a - unsigned(v);
333
}
334
template <class T>
335
inline C<T> operator-(const C<T> &a, const LE32 &v) {
336
    return a - unsigned(v);
337
}
338
#endif // XSPAN_FWD_C_IS_MEMBUFFER
339
340
template <class T>
341
13.0k
typename std::enable_if<sizeof(T) == 1, upx_rsize_t>::type upx_safe_strlen(const C<T> &a) {
342
    // not fully checked, but can require at least 1 byte
343
13.0k
    upx_rsize_t len = upx_safe_strlen(a.raw_bytes(1));
344
13.0k
    (void) a.raw_bytes(len + 1); // now can do a full check
345
13.0k
    return len;
346
13.0k
}
Unexecuted instantiation: std::__1::enable_if<(sizeof (char))==(1), unsigned long>::type upx_safe_strlen<char>(XSpan::Span<char> const&)
std::__1::enable_if<(sizeof (unsigned char const))==(1), unsigned long>::type upx_safe_strlen<unsigned char const>(XSpan::Span<unsigned char const> const&)
Line
Count
Source
341
13.0k
typename std::enable_if<sizeof(T) == 1, upx_rsize_t>::type upx_safe_strlen(const C<T> &a) {
342
    // not fully checked, but can require at least 1 byte
343
13.0k
    upx_rsize_t len = upx_safe_strlen(a.raw_bytes(1));
344
13.0k
    (void) a.raw_bytes(len + 1); // now can do a full check
345
13.0k
    return len;
346
13.0k
}
347
348
#endif // UPX_VERSION_HEX
349
350
#undef XSPAN_FWD_TU_CONVERTIBLE
351
#undef XSPAN_FWD_TU_VOIDPTR
352
353
/* vim:set ts=4 sw=4 et: */