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 |
14/28✓ Branch 0 (24→25) taken 215091 times.
✗ Branch 1 (24→26) not taken.
✗ Branch 2 (27→28) not taken.
✓ Branch 3 (27→29) taken 215091 times.
✓ Branch 4 (24→25) taken 8589 times.
✗ Branch 5 (24→26) not taken.
✗ Branch 6 (27→28) not taken.
✓ Branch 7 (27→29) taken 8589 times.
✓ Branch 8 (24→25) taken 28698 times.
✗ Branch 9 (24→26) not taken.
✗ Branch 10 (27→28) not taken.
✓ Branch 11 (27→29) taken 28698 times.
✓ Branch 12 (2→3) taken 668 times.
✗ Branch 13 (2→4) not taken.
✗ Branch 14 (5→6) not taken.
✓ Branch 15 (5→7) taken 668 times.
✓ Branch 16 (40→41) taken 1167 times.
✗ Branch 17 (40→42) not taken.
✗ Branch 18 (43→44) not taken.
✓ Branch 19 (43→45) taken 1167 times.
✓ Branch 20 (2→3) taken 580 times.
✗ Branch 21 (2→4) not taken.
✗ Branch 22 (5→6) not taken.
✓ Branch 23 (5→7) taken 580 times.
✓ Branch 24 (49→50) taken 24 times.
✗ Branch 25 (49→51) not taken.
✗ Branch 26 (52→53) not taken.
✓ Branch 27 (52→54) taken 24 times.
|
254817 | assert(dynamic_cast<T>(source) != nullptr); |
19 | 254817 | 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 |