GCC Code Coverage Report


Directory: ../
File: src/util/GlobalDefinitions.h
Date: 2025-10-09 06:28:01
Coverage Exec Excl Total
Lines: 100.0% 2 0 2
Functions: -% 0 0 0
Branches: 57.9% 22 0 38

Line Branch Exec Source
1 // Copyright (c) 2021-2025 ChilliBits. All rights reserved.
2
3 #pragma once
4
5 #include <cassert>
6
7 #ifdef __GNUC__
8 #pragma GCC diagnostic push
9 #pragma GCC diagnostic ignored "-Wattributes"
10 #endif
11
12 // Add this to the function signature to force inlining the function
13 #define ALWAYS_INLINE __attribute__((always_inline))
14
15 // Casts a pointer to another pointer type and asserts that the cast was successful in debug mode
16 template <typename T> ALWAYS_INLINE static T spice_pointer_cast(auto source) {
17 static_assert(std::is_pointer_v<decltype(source)>, "Source is not a pointer type");
18
22/38
✓ Branch 2 → 3 taken 10160 times.
✗ Branch 2 → 4 not taken.
✓ Branch 3 → 4 taken 10428 times.
✗ Branch 3 → 5 not taken.
✗ Branch 5 → 6 not taken.
✓ Branch 5 → 7 taken 10160 times.
✓ Branch 6 → 7 taken 54062 times.
✓ Branch 6 → 8 taken 10428 times.
✗ Branch 9 → 10 not taken.
✓ Branch 9 → 11 taken 54062 times.
✓ Branch 24 → 25 taken 210040 times.
✗ Branch 24 → 26 not taken.
✗ Branch 27 → 28 not taken.
✓ Branch 27 → 29 taken 210040 times.
✓ Branch 39 → 40 taken 263 times.
✗ Branch 39 → 41 not taken.
✓ Branch 40 → 41 taken 161 times.
✗ Branch 40 → 42 not taken.
✗ Branch 42 → 43 not taken.
✓ Branch 42 → 44 taken 263 times.
✗ Branch 43 → 44 not taken.
✓ Branch 43 → 45 taken 161 times.
✓ Branch 49 → 50 taken 26 times.
✗ Branch 49 → 51 not taken.
✗ Branch 52 → 53 not taken.
✓ Branch 52 → 54 taken 26 times.
✓ Branch 60 → 61 taken 2886 times.
✗ Branch 60 → 62 not taken.
✓ Branch 63 → 64 taken 8 times.
✓ Branch 63 → 65 taken 2886 times.
✗ Branch 66 → 67 not taken.
✓ Branch 66 → 68 taken 8 times.
✓ Branch 83 → 84 taken 1653 times.
✗ Branch 83 → 85 not taken.
✓ Branch 86 → 87 taken 164 times.
✓ Branch 86 → 88 taken 1653 times.
✗ Branch 89 → 90 not taken.
✓ Branch 89 → 91 taken 164 times.
289851 assert(dynamic_cast<T>(source) != nullptr);
19 289851 return static_cast<T>(source);
20 }
21
22 // Fail with an assertion error message
23 #define assert_fail(msg) assert(false && (msg))
24
25 #ifdef __GNUC__
26 #pragma GCC diagnostic pop
27 #endif
28