From 23456de8a0af6529fa040cd9bf53e1111b4ee77e Mon Sep 17 00:00:00 2001 From: Abe Fettig Date: Tue, 15 Feb 2022 13:53:05 -0500 Subject: [PATCH] Fix logic for detecting _libc_fpstate API This fixes use of the incorrect API on x86 64-bit Linux, which was causing OpenEXR compilation to fail on the latest 64-bit Ubuntu. See https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/x86/sys/ucontext.h which defines two different `_libc_fpstate` structs inside an `#ifdef __x86_64__` Signed-off-by: Abe Fettig --- src/lib/Iex/IexMathFpu.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/Iex/IexMathFpu.cpp b/src/lib/Iex/IexMathFpu.cpp index f6d8a01660..89c66403b6 100644 --- a/src/lib/Iex/IexMathFpu.cpp +++ b/src/lib/Iex/IexMathFpu.cpp @@ -243,14 +243,14 @@ restoreControlRegs (const ucontext_t& ucon, bool clearExceptions) inline void restoreControlRegs (const ucontext_t& ucon, bool clearExceptions) { -# if defined(__GLIBC__) || defined(__i386__) +# if defined(__GLIBC__) && defined(__i386__) setCw ((ucon.uc_mcontext.fpregs->cw & cwRestoreMask) | cwRestoreVal); # else setCw ((ucon.uc_mcontext.fpregs->cwd & cwRestoreMask) | cwRestoreVal); # endif _fpstate* kfp = reinterpret_cast<_fpstate*> (ucon.uc_mcontext.fpregs); -# if defined(__GLIBC__) || defined(__i386__) +# if defined(__GLIBC__) && defined(__i386__) setMxcsr (kfp->magic == 0 ? kfp->mxcsr : 0, clearExceptions); # else setMxcsr (kfp->mxcsr, clearExceptions);