Pigweed
 
Loading...
Searching...
No Matches
bloat_this_binary.h
1// Copyright 2019 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#pragma once
15
16#include <cstdint>
17
18namespace pw::bloat {
19
20// Function providing fundamental C/C++ functions to prevent them from appearing
21// in size reports. Must be called in binaries which are compared to the bloat
22// base in order to get accurate reports.
23void BloatThisBinary();
24
29[[maybe_unused]] constexpr uint32_t kDefaultMask = ~0u;
30
48#define PW_BLOAT_COND(cond, mask) \
49 do { \
50 if ((mask & 1) != 0 && (cond)) { \
51 mask = (mask >> 1) | 0x8000000; \
52 } else { \
53 mask >>= 1; \
54 } \
55 } while (0)
56
75#define PW_BLOAT_EXPR(expr, mask) \
76 do { \
77 if ((mask & 1) != 0) { \
78 (expr); \
79 mask = (mask >> 1) | 0x8000000; \
80 } else { \
81 mask >>= 1; \
82 } \
83 } while (0)
84
85} // namespace pw::bloat