diff --git a/Cargo.lock b/Cargo.lock index d40503ef..55dca974 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -33,7 +33,7 @@ version = "0.0.2" [[package]] name = "cpufeatures" -version = "0.2.2" +version = "0.2.3" dependencies = [ "libc", ] diff --git a/cpufeatures/CHANGELOG.md b/cpufeatures/CHANGELOG.md index e2961e71..2a401c6b 100644 --- a/cpufeatures/CHANGELOG.md +++ b/cpufeatures/CHANGELOG.md @@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 0.2.3 (2022-08-18) +### Changed +- Update `libc` version to v0.2.95 ([#789]) +- Disable all target features under MIRI ([#779]) +- Check AVX availability when detecting AVX2 and FMA ([#792]) + +[#779]: https://github.com/RustCrypto/utils/pull/779 +[#789]: https://github.com/RustCrypto/utils/pull/789 +[#792]: https://github.com/RustCrypto/utils/pull/792 + ## 0.2.2 (2022-03-18) ### Added - Support for Android on `aarch64` ([#752]) diff --git a/cpufeatures/Cargo.toml b/cpufeatures/Cargo.toml index 31b328c8..3bd70f0b 100644 --- a/cpufeatures/Cargo.toml +++ b/cpufeatures/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cpufeatures" -version = "0.2.2" +version = "0.2.3" description = """ Lightweight runtime CPU feature detection for x86/x86_64 and aarch64 with no_std support and support for mobile targets including Android and iOS diff --git a/cpufeatures/src/x86.rs b/cpufeatures/src/x86.rs index 37e20ef6..e21131bf 100644 --- a/cpufeatures/src/x86.rs +++ b/cpufeatures/src/x86.rs @@ -46,17 +46,26 @@ macro_rules! __detect_target_features { } macro_rules! __expand_check_macro { - ($(($name:tt, $i:expr, $reg:ident, $offset:expr)),* $(,)?) => { + ($(($name:tt $(, $i:expr, $reg:ident, $offset:expr)*)),* $(,)?) => { #[macro_export] #[doc(hidden)] macro_rules! check { $( - ($cr:expr, $name) => { ($cr[$i].$reg & (1 << $offset) != 0) }; + ($cr:expr, $name) => { + true + $( + & ($cr[$i].$reg & (1 << $offset) != 0) + )* + }; )* } }; } +// Note that according to the [Intel manual][0] AVX2 and FMA require +// that we check availability of AVX before using them. +// +// [0]: https://www.intel.com/content/dam/develop/external/us/en/documents/36945 __expand_check_macro! { ("mmx", 0, edx, 23), ("sse", 0, edx, 25), @@ -64,7 +73,7 @@ __expand_check_macro! { ("sse3", 0, ecx, 0), ("pclmulqdq", 0, ecx, 1), ("ssse3", 0, ecx, 9), - ("fma", 0, ecx, 12), + ("fma", 0, ecx, 28, 0, ecx, 12), ("sse4.1", 0, ecx, 19), ("sse4.2", 0, ecx, 20), ("popcnt", 0, ecx, 23), @@ -73,7 +82,7 @@ __expand_check_macro! { ("rdrand", 0, ecx, 30), ("sgx", 1, ebx, 2), ("bmi1", 1, ebx, 3), - ("avx2", 1, ebx, 5), + ("avx2", 0, ecx, 28, 1, ebx, 5), ("bmi2", 1, ebx, 8), ("rdseed", 1, ebx, 18), ("adx", 1, ebx, 19),