|
| 1 | +//! Binary that instantiates every public function with a concrete type. |
| 2 | +//! |
| 3 | +//! This exists solely to trigger monomorphization so that `no_panic`'s |
| 4 | +//! linker-level check can verify that no panic paths survive optimization. |
| 5 | +//! It is only compiled under the `verify-no-panic` feature. |
| 6 | +
|
| 7 | +#[cfg(not(feature = "verify-no-panic"))] |
| 8 | +compile_error!("this binary should only be built with --features verify-no-panic"); |
| 9 | + |
| 10 | +use fixed::types::I16F16; |
| 11 | +use fixed_analytics::bounded::{NonNegative, OpenUnitInterval}; |
| 12 | +use fixed_analytics::ops::algebraic::sqrt_nonneg; |
| 13 | +use fixed_analytics::ops::hyperbolic::atanh_open; |
| 14 | +use fixed_analytics::{ |
| 15 | + acos, acosh, acoth, asin, asinh, atan, atan2, atanh, cos, cosh, coth, exp, ln, log2, log10, |
| 16 | + pow2, sin, sin_cos, sinh, sinh_cosh, sqrt, tan, tanh, |
| 17 | +}; |
| 18 | + |
| 19 | +fn main() { |
| 20 | + // Use black_box to prevent the optimizer from eliminating calls entirely. |
| 21 | + let x = std::hint::black_box(I16F16::from_num(0.5)); |
| 22 | + let y = std::hint::black_box(I16F16::from_num(0.25)); |
| 23 | + |
| 24 | + // Total functions (return T) |
| 25 | + let _ = std::hint::black_box(sin(x)); |
| 26 | + let _ = std::hint::black_box(cos(x)); |
| 27 | + let _ = std::hint::black_box(tan(x)); |
| 28 | + let _ = std::hint::black_box(sin_cos(x)); |
| 29 | + let _ = std::hint::black_box(atan(x)); |
| 30 | + let _ = std::hint::black_box(atan2(y, x)); |
| 31 | + let _ = std::hint::black_box(exp(x)); |
| 32 | + let _ = std::hint::black_box(pow2(x)); |
| 33 | + let _ = std::hint::black_box(sinh(x)); |
| 34 | + let _ = std::hint::black_box(cosh(x)); |
| 35 | + let _ = std::hint::black_box(tanh(x)); |
| 36 | + let _ = std::hint::black_box(sinh_cosh(x)); |
| 37 | + let _ = std::hint::black_box(asinh(x)); |
| 38 | + |
| 39 | + // Fallible functions (return Result<T>) |
| 40 | + let _ = std::hint::black_box(asin(x)); |
| 41 | + let _ = std::hint::black_box(acos(x)); |
| 42 | + let _ = std::hint::black_box(sqrt(x)); |
| 43 | + let _ = std::hint::black_box(ln(x)); |
| 44 | + let _ = std::hint::black_box(log2(x)); |
| 45 | + let _ = std::hint::black_box(log10(x)); |
| 46 | + let _ = std::hint::black_box(acosh(I16F16::from_num(2))); |
| 47 | + let _ = std::hint::black_box(atanh(x)); |
| 48 | + let _ = std::hint::black_box(coth(x)); |
| 49 | + let _ = std::hint::black_box(acoth(I16F16::from_num(2))); |
| 50 | + |
| 51 | + // Type-safe wrapper functions |
| 52 | + let nn = NonNegative::new(x).unwrap(); |
| 53 | + let _ = std::hint::black_box(sqrt_nonneg(nn)); |
| 54 | + let ou = OpenUnitInterval::new(x).unwrap(); |
| 55 | + let _ = std::hint::black_box(atanh_open(ou)); |
| 56 | +} |
0 commit comments