Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / third_party / pigweed / repo / pw_router / size_report / base.cc
1 // Copyright 2021 The Pigweed Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not
4 // use this file except in compliance with the License. You may obtain a copy of
5 // the License at
6 //
7 //     https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 // License for the specific language governing permissions and limitations under
13 // the License.
14
15 #include "pw_assert/assert.h"
16 #include "pw_bloat/bloat_this_binary.h"
17 #include "pw_log/log.h"
18 #include "pw_sys_io/sys_io.h"
19
20 namespace {
21
22 struct BasicPacket {
23   static constexpr uint32_t kMagic = 0x8badf00d;
24
25   constexpr BasicPacket(uint32_t addr, uint64_t data)
26       : magic(kMagic), address(addr), payload(data) {}
27
28   uint32_t magic;
29   uint32_t address;
30   uint64_t payload;
31 };
32
33 }  // namespace
34
35 int main() {
36   pw::bloat::BloatThisBinary();
37
38   // Ensure we are paying the cost for log and assert.
39   BasicPacket packet(0x1, 0x2);
40   PW_CHECK_UINT_EQ(packet.magic, BasicPacket::kMagic, "Some CHECK logic");
41   PW_LOG_INFO("Packet has address %u", static_cast<unsigned>(packet.address));
42   PW_LOG_INFO("pw_StatusString %s", pw::OkStatus().str());
43
44   std::array<std::byte, sizeof(BasicPacket)> packet_buffer;
45   pw::sys_io::ReadBytes(packet_buffer);
46   pw::sys_io::WriteBytes(packet_buffer);
47
48   return static_cast<int>(packet.payload);
49 }