Commit 9258b558 authored by Alexey Matveichev's avatar Alexey Matveichev Committed by Mark OLESEN
Browse files

ENH: Darwin adjustments

- link CGAL (clang version) without reference to mpfr,gmp libraries

- use offset address in printStack for Darwin as well

- alternative handling of feexcept on Darwin
parent e3f85039
......@@ -115,7 +115,13 @@ void printSourceFileAndLine
uintptr_t address = uintptr_t(addr);
word myAddress = addressToWord(address);
if (filename.ext() == "so")
if
(
filename.hasExt("so")
#ifdef darwin
|| filename.hasExt("dylib")
#endif
)
{
// Convert address into offset into dynamic library
uintptr_t offset = uintptr_t(info->dli_fbase);
......
// ============================================================================
// Generic handling of floating point exceptions
//
// 2018 Alexey Matveichev
// ----------------------------------------------------------------------------
//
// Original Author
// David N. Williams
//
// License
// Public Domain
//
// Description
// Alternate, nondefault handling of IEEE 754 floating-point exceptions
// in OS X, based on the GNU functions feenableexcept(), fedisableeexcept()
// and fegetexcept() [in libm]
//
// http://www-personal.umich.edu/~williams/archive/computation/fe-handling-example.c
// ============================================================================
#ifndef feexceptErsatz_H
#define feexceptErsatz_H
#ifdef darwin
#include <fenv.h>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
inline int feenableexcept(unsigned int excepts)
{
static fenv_t fenv;
unsigned int new_excepts = excepts & FE_ALL_EXCEPT;
unsigned int 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;
}
inline int fedisableexcept(unsigned int excepts)
{
static fenv_t fenv;
unsigned int new_excepts = excepts & FE_ALL_EXCEPT;
unsigned int old_excepts; // all previous masks
if (fegetenv(&fenv))
{
return -1;
}
old_excepts = fenv.__control & FE_ALL_EXCEPT;
// mask
fenv.__control |= new_excepts;
fenv.__mxcsr |= new_excepts << 7;
return fesetenv(&fenv) ? -1 : old_excepts;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif // darwin
#endif
// ************************************************************************* //
......@@ -41,6 +41,10 @@ License
#include <sigfpe.h>
#endif
#ifdef darwin
#include "feexceptErsatz.H"
#endif
#include <limits>
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
......@@ -108,11 +112,15 @@ void* Foam::sigFpe::mallocNan(size_t size)
return result;
}
#endif // __linux__
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
#ifdef __GNUC__
void Foam::sigFpe::sigHandler(int)
{
#if (defined(__linux__) && defined(__GNUC__)) || defined(darwin)
// Reset old handling
if (sigaction(SIGFPE, &oldAction_, nullptr) < 0)
{
......@@ -124,9 +132,9 @@ void Foam::sigFpe::sigHandler(int)
jobInfo.signalEnd(); // Update jobInfo file
error::printStack(Perr);
raise(SIGFPE); // Throw signal (to old handler)
#endif // (__linux__ && __GNUC__) || darwin
}
#endif // __GNUC__
#endif // __linux__
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
......@@ -157,7 +165,7 @@ void Foam::sigFpe::set(bool verbose)
{
if (!sigActive_ && requested())
{
#if defined(__linux__) && defined(__GNUC__)
#if (defined(__linux__) && defined(__GNUC__)) || defined(darwin)
feenableexcept
(
......@@ -247,7 +255,7 @@ void Foam::sigFpe::set(bool verbose)
void Foam::sigFpe::unset(bool verbose)
{
#if defined(__linux__) && defined(__GNUC__)
#if (defined(__linux__) && defined(__GNUC__)) || defined(darwin)
if (sigActive_)
{
if (verbose)
......
......@@ -91,12 +91,10 @@ class sigFpe
static struct sigaction oldAction_;
// Static data members
// Private Member Functions
#if defined(__linux__) && defined(__GNUC__)
//- Handler for caught signals
static void sigHandler(int);
#endif
public:
......@@ -111,7 +109,7 @@ public:
~sigFpe();
// Member functions
// Member Functions
//- Check if SIGFPE signals handler is to be enabled.
// This is controlled by the trapFpe entry or the FOAM_SIGFPE
......
......@@ -73,7 +73,7 @@ class sigStopAtWriteNow
public:
//- wip. Have setter have access to signal_
//- Allow setter access to signal_
friend class addstopAtWriteNowSignalToOpt;
......
......@@ -74,9 +74,10 @@ public:
friend class sigStopAtWriteNow;
//- wip. Have setter have access to signal_
//- Allow setter access to signal_
friend class addwriteNowSignalToOpt;
// Constructors
//- Construct null
......@@ -90,7 +91,7 @@ public:
~sigWriteNow();
// Member functions
// Member Functions
//- Is active?
bool active() const;
......
# Clang build of CGAL on Darwin without mpfr,gmp
CGAL_INC = \
-I$(BOOST_ARCH_PATH)/include \
-I$(CGAL_ARCH_PATH)/include
CGAL_LIBS = \
-L$(BOOST_ARCH_PATH)/lib \
-L$(CGAL_ARCH_PATH)/lib \
-lCGAL
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment