Skip to content

Commit

Permalink
Fixes to make sure that we can restore control registers on 32-bit pl…
Browse files Browse the repository at this point in the history
…atforms.

A configure.ac check to see if we have native support, or if we need to employ the work around.

See #33
  • Loading branch information
pstanczyk committed Feb 28, 2013
1 parent 2af2abf commit 20061ef
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
5 changes: 4 additions & 1 deletion IlmBase/IexMath/IexMathFpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,17 @@ clearExceptions ()
const uint16_t cwRestoreMask = ~((3 << 10) | (3 << 8));
const uint16_t cwRestoreVal = (0 << 10) | (3 << 8);


#ifdef ILMBASE_HAVE_CONTROL_REGISTER_SUPPORT

inline void
restoreControlRegs (const ucontext_t & ucon, bool clearExceptions)
{
setCw ((ucon.uc_mcontext.fpregs->cwd & cwRestoreMask) | cwRestoreVal);
setMxcsr (ucon.uc_mcontext.fpregs->mxcsr, clearExceptions);
}

#if 0
#else

//
// Ugly, the mxcsr isn't defined in GNU libc ucontext_t, but
Expand Down
7 changes: 7 additions & 0 deletions IlmBase/config/IlmBaseConfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,16 @@

#undef HAVE_POSIX_SEMAPHORES


#undef HAVE_UCONTEXT_H


//
// Dealing with FPEs
//
#undef ILMBASE_HAVE_CONTROL_REGISTER_SUPPORT


//
// Define and set to 1 if the target system has support for large
// stack sizes.
Expand Down
21 changes: 21 additions & 0 deletions IlmBase/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ dnl Checks for library functions.
AC_CHECK_FUNCS(strerror)


dnl
dnl Checks for std::right etc. in iomanip
dnl
AC_MSG_CHECKING(for complete iomanip support in C++ standard library)
complete_iomanip="no"
AC_LANG_SAVE
Expand All @@ -88,6 +90,25 @@ AC_TRY_COMPILE([#include <iomanip>],[
],
AC_DEFINE(HAVE_COMPLETE_IOMANIP) complete_iomanip=yes)
AC_MSG_RESULT($complete_iomanip)


dnl
dnl Checks for dealing with fpe handling
dnl
AC_MSG_CHECKING(for fpe support handling)
control_register_support="no"
AC_TRY_COMPILE([
#include <iomanip>
#include <ucontext.h>
],[
ucontext_t ucon;
uint32_t mxcsr = ucon.uc_mcontext.fpregs->mxcsr;
uint16_t cw = ucon.uc_mcontext.fpregs->cwd;
],
AC_DEFINE(ILMBASE_HAVE_CONTROL_REGISTER_SUPPORT) control_register_support=yes)
AC_MSG_RESULT($control_register_support)

AC_LANG_RESTORE

dnl --enable-large-stack
Expand Down

0 comments on commit 20061ef

Please sign in to comment.