Skip to content

Instantly share code, notes, and snippets.

@epatel
Created April 1, 2016 11:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save epatel/ec14f7a699ce8a502bfbb964368a58b0 to your computer and use it in GitHub Desktop.
Save epatel/ec14f7a699ce8a502bfbb964368a58b0 to your computer and use it in GitHub Desktop.
Enable SIGFPE for iOS/Mac
fenv_t fe;
if (fegetenv(&fe) != 0) {
// error
}
#if defined __arm__
fe.__fpscr |= __fpscr_trap_divbyzero;
#elif defined __i386__
fe.__control &= ~FE_DIVBYZERO;
fe.__mxcsr &= ~_MM_MASK_DIV_ZERO;
#else
#error unknown processor architecture
#endif
if (fesetenv(&fe) != 0) {
// error
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment