2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
6 #include "ProfilingUtils.hpp"
8 #include <boost/assert.hpp>
16 void WriteUint32(unsigned char* buffer, unsigned int offset, uint32_t value)
20 buffer[offset] = static_cast<unsigned char>(value & 0xFF);
21 buffer[offset + 1] = static_cast<unsigned char>((value >> 8) & 0xFF);
22 buffer[offset + 2] = static_cast<unsigned char>((value >> 16) & 0xFF);
23 buffer[offset + 3] = static_cast<unsigned char>((value >> 24) & 0xFF);
26 void WriteUint16(unsigned char* buffer, unsigned int offset, uint16_t value)
28 BOOST_ASSERT(buffer != nullptr);
30 buffer[offset] = static_cast<unsigned char>(value & 0xFF);
31 buffer[offset + 1] = static_cast<unsigned char>((value >> 8) & 0xFF);
34 uint32_t ReadUint32(const unsigned char* buffer, unsigned int offset)
39 value = static_cast<uint32_t>(buffer[offset]);
40 value |= static_cast<uint32_t>(buffer[offset + 1]) << 8;
41 value |= static_cast<uint32_t>(buffer[offset + 2]) << 16;
42 value |= static_cast<uint32_t>(buffer[offset + 3]) << 24;
46 uint16_t ReadUint16(const unsigned char* buffer, unsigned int offset)
51 value = static_cast<uint32_t>(buffer[offset]);
52 value |= static_cast<uint32_t>(buffer[offset + 1]) << 8;
53 return static_cast<uint16_t>(value);
56 } // namespace profiling