We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 23e5439 commit 0eca4b1Copy full SHA for 0eca4b1
compiler-rt/lib/memprof/memprof_rawprofile.cpp
@@ -22,13 +22,13 @@ namespace {
22
template <class T> char *WriteBytes(const T &Pod, char *Buffer) {
23
static_assert(is_trivially_copyable<T>::value, "T must be POD");
24
const uint8_t *Src = reinterpret_cast<const uint8_t *>(&Pod);
25
- for (size_t I = 0; I < sizeof(T); ++I) {
26
- Buffer[I] = Src[I];
27
- }
+
+ for (size_t I = 0; I < sizeof(T); ++I)
28
#if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
29
- for (size_t i = 0; i < sizeof(T) / 2; ++i) {
30
- std::swap(buffer[i], buffer[sizeof(T) - 1 - i]);
31
+ // Reverse byte order since reader is little-endian.
+ Buffer[I] = Src[sizeof(T) - 1 - I];
+#else
+ Buffer[I] = Src[I];
32
#endif
33
return Buffer + sizeof(T);
34
}
0 commit comments