File: libm_no_std_cant_float.rs

package info (click to toggle)
rustc 1.85.0%2Bdfsg3-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, sid, trixie
  • size: 893,396 kB
  • sloc: xml: 158,127; python: 35,830; javascript: 19,497; cpp: 19,002; sh: 17,245; ansic: 13,127; asm: 4,376; makefile: 1,051; perl: 29; lisp: 29; ruby: 19; sql: 11
file content (22 lines) | stat: -rw-r--r-- 820 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#![crate_type = "rlib"]
#![no_std]
#![feature(portable_simd)]
use core::simd::f32x4;
use core::simd::num::SimdFloat;

// For SIMD float ops, the LLIR version which is used to implement the portable
// forms of them may become calls to math.h AKA libm. So, we can't guarantee
// we can compile them for #![no_std] crates.
// Someday we may solve this.
// Until then, this test at least guarantees these functions require std.
fn guarantee_no_std_nolibm_calls() -> f32x4 {
    let x = f32x4::from_array([0.1, 0.5, 0.6, -1.5]);
    let x2 = x + x;
    let _xc = x.ceil(); //~ ERROR E0599
    let _xf = x.floor(); //~ ERROR E0599
    let _xr = x.round(); //~ ERROR E0599
    let _xt = x.trunc(); //~ ERROR E0599
    let _xfma = x.mul_add(x, x); //~ ERROR E0599
    let _xsqrt = x.sqrt(); //~ ERROR E0599
    x2.abs() * x2
}