mirror of
https://github.com/robbert-vdh/nih-plug.git
synced 2026-07-01 02:36:54 +00:00
Fix for Issue #220
Resolved warning: use of deprecated function std::arch::x86_64::_MM_GET_FLUSH_ZERO_MODE Issue #220 Issue Link: https://github.com/robbert-vdh/nih-plug/issues/220
This commit is contained in:
@@ -207,14 +207,25 @@ impl ScopedFtz {
|
|||||||
{
|
{
|
||||||
#[cfg(target_feature = "sse")]
|
#[cfg(target_feature = "sse")]
|
||||||
{
|
{
|
||||||
let mode = unsafe { std::arch::x86_64::_MM_GET_FLUSH_ZERO_MODE() };
|
const X86_FTZ_BIT: u32 = 1 << 15;
|
||||||
let should_disable_again = mode != std::arch::x86_64::_MM_FLUSH_ZERO_ON;
|
let mut mxcsr: u32 = 0;
|
||||||
if should_disable_again {
|
|
||||||
unsafe {
|
unsafe {
|
||||||
std::arch::x86_64::_MM_SET_FLUSH_ZERO_MODE(
|
std::arch::asm!(
|
||||||
std::arch::x86_64::_MM_FLUSH_ZERO_ON,
|
"stmxcsr [{p}]",
|
||||||
)
|
p = in(reg) &mut mxcsr,
|
||||||
};
|
options(nostack, preserves_flags),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
let should_disable_again = (mxcsr & X86_FTZ_BIT) == 0;
|
||||||
|
if should_disable_again {
|
||||||
|
let new_mxcsr = mxcsr | X86_FTZ_BIT;
|
||||||
|
unsafe {
|
||||||
|
std::arch::asm!(
|
||||||
|
"ldmxcsr [{p}]",
|
||||||
|
p = in(reg) &new_mxcsr,
|
||||||
|
options(nostack, preserves_flags),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Self {
|
return Self {
|
||||||
@@ -257,11 +268,21 @@ impl Drop for ScopedFtz {
|
|||||||
if self.should_disable_again {
|
if self.should_disable_again {
|
||||||
#[cfg(target_feature = "sse")]
|
#[cfg(target_feature = "sse")]
|
||||||
{
|
{
|
||||||
|
const X86_FTZ_BIT: u32 = 1 << 15;
|
||||||
|
let mut mxcsr: u32 = 0;
|
||||||
unsafe {
|
unsafe {
|
||||||
std::arch::x86_64::_MM_SET_FLUSH_ZERO_MODE(
|
std::arch::asm!(
|
||||||
std::arch::x86_64::_MM_FLUSH_ZERO_OFF,
|
"stmxcsr [{p}]",
|
||||||
)
|
p = in(reg) &mut mxcsr,
|
||||||
};
|
options(nostack, preserves_flags),
|
||||||
|
);
|
||||||
|
let new_mxcsr = mxcsr & !X86_FTZ_BIT;
|
||||||
|
std::arch::asm!(
|
||||||
|
"ldmxcsr [{p}]",
|
||||||
|
p = in(reg) &new_mxcsr,
|
||||||
|
options(nostack, preserves_flags),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_arch = "aarch64")]
|
#[cfg(target_arch = "aarch64")]
|
||||||
|
|||||||
Reference in New Issue
Block a user