mirror of
https://github.com/paboyle/Grid.git
synced 2025-04-09 21:50:45 +01:00
FPE's on macos set up
This commit is contained in:
parent
7422953e36
commit
296396646d
39
lib/Init.cc
39
lib/Init.cc
@ -46,23 +46,10 @@ Author: paboyle <paboyle@ph.ed.ac.uk>
|
|||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <cxxabi.h>
|
|
||||||
|
|
||||||
|
|
||||||
namespace Grid {
|
namespace Grid {
|
||||||
|
|
||||||
std::string demangle(const char* name) {
|
|
||||||
|
|
||||||
int status = -4; // some arbitrary value to eliminate the compiler warning
|
|
||||||
|
|
||||||
// enable c++11 by passing the flag -std=c++11 to g++
|
|
||||||
std::unique_ptr<char, void(*)(void*)> res {
|
|
||||||
abi::__cxa_demangle(name, NULL, NULL, &status),
|
|
||||||
std::free
|
|
||||||
};
|
|
||||||
|
|
||||||
return (status==0) ? res.get() : name ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////
|
||||||
// Convenience functions to access stadard command line arg
|
// Convenience functions to access stadard command line arg
|
||||||
@ -343,10 +330,30 @@ void Grid_sa_signal_handler(int sig,siginfo_t *si,void * ptr)
|
|||||||
exit(0);
|
exit(0);
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
#ifdef GRID_FPE
|
|
||||||
|
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
#include <fenv.h>
|
#include <fenv.h>
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
static int
|
||||||
|
feenableexcept (unsigned int excepts)
|
||||||
|
{
|
||||||
|
static fenv_t fenv;
|
||||||
|
unsigned int new_excepts = excepts & FE_ALL_EXCEPT,
|
||||||
|
old_excepts; // previous masks
|
||||||
|
|
||||||
|
if ( fegetenv (&fenv) ) return -1;
|
||||||
|
old_excepts = fenv.__control & FE_ALL_EXCEPT;
|
||||||
|
|
||||||
|
// unmask
|
||||||
|
fenv.__control &= ~new_excepts;
|
||||||
|
fenv.__mxcsr &= ~(new_excepts << 7);
|
||||||
|
|
||||||
|
return ( fesetenv (&fenv) ? -1 : old_excepts );
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void Grid_debug_handler_init(void)
|
void Grid_debug_handler_init(void)
|
||||||
{
|
{
|
||||||
struct sigaction sa,osa;
|
struct sigaction sa,osa;
|
||||||
@ -355,9 +362,9 @@ void Grid_debug_handler_init(void)
|
|||||||
sa.sa_flags = SA_SIGINFO;
|
sa.sa_flags = SA_SIGINFO;
|
||||||
sigaction(SIGSEGV,&sa,NULL);
|
sigaction(SIGSEGV,&sa,NULL);
|
||||||
sigaction(SIGTRAP,&sa,NULL);
|
sigaction(SIGTRAP,&sa,NULL);
|
||||||
#ifdef GRID_FPE
|
|
||||||
feenableexcept( FE_INVALID|FE_OVERFLOW|FE_DIVBYZERO);
|
feenableexcept( FE_INVALID|FE_OVERFLOW|FE_DIVBYZERO);
|
||||||
|
|
||||||
sigaction(SIGFPE,&sa,NULL);
|
sigaction(SIGFPE,&sa,NULL);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,6 @@ namespace Grid {
|
|||||||
void GridCmdOptionCSL(std::string str,std::vector<std::string> & vec);
|
void GridCmdOptionCSL(std::string str,std::vector<std::string> & vec);
|
||||||
void GridCmdOptionIntVector(std::string &str,std::vector<int> & vec);
|
void GridCmdOptionIntVector(std::string &str,std::vector<int> & vec);
|
||||||
|
|
||||||
std::string demangle(const char* name) ;
|
|
||||||
|
|
||||||
void GridParseLayout(char **argv,int argc,
|
void GridParseLayout(char **argv,int argc,
|
||||||
std::vector<int> &latt,
|
std::vector<int> &latt,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user