Trevor Gross 8995ac0448 Use runtime feature detection for fma routines on x86
Get performance closer to the glibc implementations by adding assembly
fma routines, with runtime feature detection so they are used even if
not compiled with `+fma` (as the distributed standard library is often
not). Glibc uses ifuncs, this implementation stores a function pointer
in an atomic.

Results of CPU flags are also cached in order to avoid repeating the
startup time in calls to different functions. The feature detection code
is a slightly simplified version of `std-detect`.

Musl sources were used as a reference [1].

Fixes: https://github.com/rust-lang/rust/issues/140452 once synced

[1]: c47ad25ea3/src/math/x32/fma.c
2025-05-03 14:17:49 -04:00
..
2025-04-19 17:20:24 -04:00
2025-04-22 04:44:00 -04:00
2025-04-22 04:44:00 -04:00
2025-04-19 19:05:49 -04:00

libm

A Rust implementations of the C math library.

Usage

libm provides fallback implementations for Rust's float math functions in core, and the core_float_math feature. If what is available suits your needs, there is no need to add libm as a dependency.

If more functionality is needed, this crate can also be used directly:

[dependencies]
libm = "0.2.11"

Contributing

Please check CONTRIBUTING.md

Minimum Rust version policy

This crate supports rustc 1.63 and newer.

License

Usage is under the MIT license, available at https://opensource.org/license/mit.

Contribution

Contributions are licensed under both the MIT license and the Apache License, Version 2.0, available at htps://www.apache.org/licenses/LICENSE-2.0. Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as mentioned, without any additional terms or conditions.

See LICENSE.txt for full details.