GCC Code Coverage Report


Directory: ../
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 2 / 0 / 2
Functions: -% 0 / 0 / 0
Branches: 52.9% 18 / 0 / 34

src/util/GlobalDefinitions.h
Line Branch Exec Source
1 // Copyright (c) 2021-2026 ChilliBits. All rights reserved.
2
3 #pragma once
4
5 #include <cassert>
6 #include <type_traits>
7
8 #ifdef __GNUC__
9 #pragma GCC diagnostic push
10 #pragma GCC diagnostic ignored "-Wattributes"
11 #endif
12
13 // Add this to the function signature to force inlining the function
14 #define ALWAYS_INLINE __attribute__((always_inline))
15
16 // Casts a pointer to another pointer type and asserts that the cast was successful in debug mode
17 template <typename DstT, typename SrcT>
18 ALWAYS_INLINE static DstT spice_pointer_cast(SrcT source)
19 requires(std::is_pointer_v<SrcT> && std::is_pointer_v<DstT>)
20 {
21
18/34
✓ Branch 2 → 3 taken 11123 times.
✗ Branch 2 → 4 not taken.
✓ Branch 3 → 4 taken 11498 times.
✗ Branch 3 → 5 not taken.
✗ Branch 5 → 6 not taken.
✓ Branch 5 → 7 taken 11123 times.
✓ Branch 6 → 7 taken 60418 times.
✓ Branch 6 → 8 taken 11498 times.
✗ Branch 9 → 10 not taken.
✓ Branch 9 → 11 taken 60418 times.
✓ Branch 24 → 25 taken 242522 times.
✗ Branch 24 → 26 not taken.
✓ Branch 26 → 27 taken 115 times.
✗ Branch 26 → 28 not taken.
✗ Branch 27 → 28 not taken.
✓ Branch 27 → 29 taken 242522 times.
✗ Branch 29 → 30 not taken.
✓ Branch 29 → 31 taken 115 times.
✓ Branch 39 → 40 taken 266 times.
✗ Branch 39 → 41 not taken.
✗ Branch 42 → 43 not taken.
✓ Branch 42 → 44 taken 266 times.
✓ Branch 56 → 57 taken 10 times.
✗ Branch 56 → 58 not taken.
✗ Branch 59 → 60 not taken.
✓ Branch 59 → 61 taken 10 times.
✓ Branch 60 → 61 taken 3167 times.
✗ Branch 60 → 62 not taken.
✗ Branch 63 → 64 not taken.
✓ Branch 63 → 65 taken 3167 times.
✓ Branch 83 → 84 taken 1813 times.
✗ Branch 83 → 85 not taken.
✗ Branch 86 → 87 not taken.
✓ Branch 86 → 88 taken 1813 times.
330932 assert(dynamic_cast<DstT>(source) != nullptr);
22 330932 return static_cast<DstT>(source);
23 }
24
25 // Fail with an assertion error message
26 #define assert_fail(msg) assert(false && (msg))
27
28 #ifdef __GNUC__
29 #pragma GCC diagnostic pop
30 #endif
31