Overflow-checked integer arithmetic for GPU byte-size and extent math.
More...
#include <cstdint>
#include <optional>
|
| std::optional< uint64_t > | donner::gpu::CheckedAdd (uint64_t a, uint64_t b) |
| | Overflow-checked addition of unsigned 64-bit sizes.
|
| std::optional< uint64_t > | donner::gpu::CheckedMul (uint64_t a, uint64_t b) |
| | Overflow-checked multiplication of unsigned 64-bit sizes.
|
Overflow-checked integer arithmetic for GPU byte-size and extent math.
◆ CheckedAdd()
| std::optional< uint64_t > donner::gpu::CheckedAdd |
( |
uint64_t | a, |
|
|
uint64_t | b ) |
|
inline |
Overflow-checked addition of unsigned 64-bit sizes.
All byte-size and extent arithmetic in the GPU runtime is checked (design 0053 "Security and Reliability"): untrusted SVG content controls geometry volume and image sizes, so silent wraparound must be impossible.
- Parameters
-
| a | First operand. |
| b | Second operand. |
- Returns
- The sum, or
std::nullopt on overflow.
◆ CheckedMul()
| std::optional< uint64_t > donner::gpu::CheckedMul |
( |
uint64_t | a, |
|
|
uint64_t | b ) |
|
inline |
Overflow-checked multiplication of unsigned 64-bit sizes.
- Parameters
-
| a | First operand. |
| b | Second operand. |
- Returns
- The product, or
std::nullopt on overflow.