Deal with CGAL_NO_ATOMIC

This commit is contained in:
Andreas Fabri 2016-12-12 12:53:14 +01:00 committed by Laurent Rineau
parent e696a857f9
commit 46c6ea1f3f
3 changed files with 98 additions and 4 deletions

View File

@ -81,14 +81,22 @@ namespace CORE {
/** The normal behavior is to abort when an invalid expression
* is constructed. This flag can be used to turn off this abort.
* In any case, an error message will be printed */
#ifdef CGAL_NO_ATOMIC
CGAL_GLOBAL_STATE_VAR(bool, AbortFlag, true)
#else
CGAL_GLOBAL_STATE_VAR(CGAL::cpp11::atomic<bool>, AbortFlag, true)
#endif
/// Invalid Flag -- initiallly value is non-negative
/** If the Abort Flag is false, then the Invalid flag will be set to
* a negative value whenever an invalid expression is constructed.
* It is the user's responsibility to check this flag and to make
* it non-negative again. */
#ifdef CGAL_NO_ATOMIC
CGAL_GLOBAL_STATE_VAR(int, InvalidFlag, 0)
#else
CGAL_GLOBAL_STATE_VAR(CGAL::cpp11::atomic<int>, InvalidFlag, 0)
#endif
/// Escape Precision in bits
CGAL_GLOBAL_STATE_VAR(extLong, EscapePrec, CORE_posInfty)
@ -100,7 +108,11 @@ CGAL_GLOBAL_STATE_VAR(long, EscapePrecFlag, 0)
/// Escape Precision Warning Flag
/** this flag is true by default, and will cause a warning to be printed
when EscapePrec is reached */
CGAL_GLOBAL_STATE_VAR(CGAL::cpp11::atomic<bool>, EscapePrecWarning, true)
#ifdef CGAL_NO_ATOMIC
CGAL_GLOBAL_STATE_VAR(bool, EscapePrecWarning, true)
#else
CGAL_GLOBAL_STATE_VAR(CGAL::cpp11::atomic<bool>, EscapePrecWarning, true)
#endif
// These following two values determine the precision of computing
// approximations in Expr.
@ -118,7 +130,11 @@ CGAL_GLOBAL_STATE_VAR(extLong, defAbsPrec, CORE_posInfty)
"controls the printout precision of std::cout for BigFloat"
Perhaps, we should merge defOutputDigits and defBigFloatOutputDigits?
*/
#ifdef CGAL_NO_ATOMIC
CGAL_GLOBAL_STATE_VAR(long, defBigFloatOutputDigits, 10)
#else
CGAL_GLOBAL_STATE_VAR(CGAL::cpp11::atomic<long>, defBigFloatOutputDigits, 10)
#endif
/// default input precision in digits for converting a string to a Real or Expr
/** This value can be CORE_INFTY */
@ -128,11 +144,19 @@ CGAL_GLOBAL_STATE_VAR(extLong, defInputDigits, CORE_posInfty)
/** This value cannot be CORE_INFTY
See also defBigFloatOutputDigits.
(it really should be an int, as in std::cout.setprecision(int)). */
#ifdef CGAL_NO_ATOMIC
CGAL_GLOBAL_STATE_VAR(long, defOutputDigits, 10) // == get_static_defBigFloatOutputDigits()
#else
CGAL_GLOBAL_STATE_VAR(CGAL::cpp11::atomic<long>, defOutputDigits, 10) // == get_static_defBigFloatOutputDigits()
#endif
/// default input precision in digits for converting a string to a BigFloat
/** This value cannot be CORE_INFTY. */
#ifdef CGAL_NO_ATOMIC
CGAL_GLOBAL_STATE_VAR(long, defBigFloatInputDigits, 16)
#else
CGAL_GLOBAL_STATE_VAR(CGAL::cpp11::atomic<long>, defBigFloatInputDigits, 16)
#endif
inline
long
@ -151,15 +175,42 @@ CGAL_GLOBAL_STATE_VAR(extLong, defBFsqrtAbsPrec, 54)
//////////////////////////////////////////////////////////////
/// floating point filter flag
#ifdef CGAL_NO_ATOMIC
CGAL_GLOBAL_STATE_VAR(bool, fpFilterFlag, true)
#else
CGAL_GLOBAL_STATE_VAR(CGAL::cpp11::atomic<bool>, fpFilterFlag, true)
#endif
/// if true, evaluation of expressions would be incremental
#ifdef CGAL_NO_ATOMIC
CGAL_GLOBAL_STATE_VAR(bool, incrementalEvalFlag, true)
#else
CGAL_GLOBAL_STATE_VAR(CGAL::cpp11::atomic<bool>, incrementalEvalFlag, true)
#endif
/// progressive evaluation flag
#ifdef CGAL_NO_ATOMIC
CGAL_GLOBAL_STATE_VAR(bool, progressiveEvalFlag, true)
#else
CGAL_GLOBAL_STATE_VAR(CGAL::cpp11::atomic<bool>, progressiveEvalFlag, true)
#endif
/// rational reduction flag
#ifdef CGAL_NO_ATOMIC
CGAL_GLOBAL_STATE_VAR(bool, rationalReduceFlag, false)
#else
CGAL_GLOBAL_STATE_VAR(CGAL::cpp11::atomic<bool>, rationalReduceFlag, false)
#endif
/// default initial (bit) precision for AddSub Progressive Evaluation
#ifdef CGAL_NO_ATOMIC
CGAL_GLOBAL_STATE_VAR(long, defInitialProgressivePrec, 64)
#else
CGAL_GLOBAL_STATE_VAR(CGAL::cpp11::atomic<long>, defInitialProgressivePrec, 64)
#endif
//////////////////////////////////////////////////////////////
// methods for setting global precision parameters

View File

@ -57,15 +57,22 @@ int IOErrorFlag = 0;
/**
* If AbortFlag is true when invalid expression is constructed, system will abort
*/
#ifdef CGAL_NO_ATOMIC
bool AbortFlag = true;
#else
CGAL::cpp11::atomic<bool> AbortFlag(true);
#endif
/**
* InvalidFlag is set to negative whenever an invalid expression is constructed.
* The user has the responsibility to reset to non-negative value.
*/
#ifdef CGAL_NO_ATOMIC
int InvalidFlag = 0;
#else
CGAL::cpp11::atomic<int> InvalidFlag(0);
#endif
/* ************************************************************
* PRECISION PARAMETERS
@ -97,7 +104,11 @@ long EscapePrecFlag = 0;
/// Escape Precision Warning Flag
/** this flag is true by default, and will cause a warning to be printed
when EscapePrec is reached */
#ifdef CGAL_NO_ATOMIC
bool EscapePrecWarning = true;
#else
CGAL::cpp11::atomic<bool> EscapePrecWarning(true);
#endif
/** The Composite Precision [defAbsPrec, defRelPrec]
* determines the precision to which an Expr evaluates its
@ -113,11 +124,19 @@ extLong defAbsPrec = CORE_posInfty;
extLong defRelPrec = 60;
/** number of BigFloat digits to print out */
#ifdef CGAL_NO_ATOMIC
long defBigFloatOutputDigits = 10;
#else
CGAL::cpp11::atomic<long> defBigFloatOutputDigits(10);
#endif
/** NORMALLY, we like to make this equal to defBigFloatOutputDigits
* 8/3/01, Chee: re-introduced this parameter */
#ifdef CGAL_NO_ATOMIC
long defOutputDigits = 10;
#else
CGAL::cpp11::atomic<long> defOutputDigits(10); // == defBigFloatOutputDigits;
#endif
/** String Input Precision */
@ -130,7 +149,11 @@ extLong defInputDigits = CORE_posInfty;
/** This controls the absolute error in converting from string to BigFloat
* The absolute error will be at most 10^{-defInputDigits} */
#ifdef CGAL_NO_ATOMIC
long defBigFloatInputDigits = 16;
#else
CGAL::cpp11::atomic<long> defBigFloatInputDigits(16);
#endif
/* ************************************************************
* EVALUATION FLAGS
@ -138,25 +161,44 @@ CGAL::cpp11::atomic<long> defBigFloatInputDigits(16);
/** Floating Point filter
* true = turn on floating point filter */
#ifdef CGAL_NO_ATOMIC
bool fpFilterFlag = true;
#else
CGAL::cpp11::atomic<bool> fpFilterFlag(true);
#endif
/** IncrementaL evaluation flag
* incremental evaluation is requested, This means, we try to use previous
* approximate values to improve an approximation */
#ifdef CGAL_NO_ATOMIC
bool incrementalEvalFlag = true;
#else
CGAL::cpp11::atomic<bool> incrementalEvalFlag(true);
#endif
/** Progressive evaluation flag
* true = turn on progressive evaluation flag */
#ifdef CGAL_NO_ATOMIC
bool progressiveEvalFlag = true;
#else
CGAL::cpp11::atomic<bool> progressiveEvalFlag(true);
#endif
/** Initial progressive evaluation precision
* Used by AddSubRep */
#ifdef CGAL_NO_ATOMIC
long defInitialProgressivePrec = 64;
#else
CGAL::cpp11::atomic<long> defInitialProgressivePrec(64);
#endif
/** RATIONAL REDUCTION FLAG
* true = turn on rational reduction */
#ifdef CGAL_NO_ATOMIC
bool rationalReduceFlag = false;
#else
CGAL::cpp11::atomic<bool> rationalReduceFlag(false);
#endif
#endif // CGAL_HEADER_ONLY
} //namespace CORE

View File

@ -42,6 +42,7 @@
#include <CGAL/assertions.h>
#include <CGAL/CORE/Real.h>
#include <cmath>
#include <limits>
#if !defined CGAL_CFG_NO_CPP0X_ISFINITE
#define CGAL_CORE_finite(x) std::isfinite(x)
@ -180,7 +181,7 @@ public:
/// helper function (to avoid warning under some compilers)
static double getDoubleInfty() {
return 2*DBL_MAX;
return std::numeric_limits<double>::infinity();
}
//@}
}; //filteredFp class