From 1d0ec5bd382bfa242d9843b45de683d3d8af359b Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Mon, 17 Oct 2016 18:12:33 +0200 Subject: [PATCH] WIP: make variables atomic; it no longer compiles :( --- CGAL_Core/include/CGAL/CORE/CoreDefs.h | 23 +++++++++++---------- CGAL_Core/include/CGAL/CORE/CoreDefs_impl.h | 22 ++++++++++---------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/CGAL_Core/include/CGAL/CORE/CoreDefs.h b/CGAL_Core/include/CGAL/CORE/CoreDefs.h index 46c43e25f5e..35e6b5b8151 100644 --- a/CGAL_Core/include/CGAL/CORE/CoreDefs.h +++ b/CGAL_Core/include/CGAL/CORE/CoreDefs.h @@ -39,6 +39,7 @@ #define _CORE_COREDEFS_H_ #include +#include #ifdef CGAL_HEADER_ONLY @@ -80,14 +81,14 @@ 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 */ -CGAL_GLOBAL_STATE_VAR(bool, AbortFlag, true) +CGAL_GLOBAL_STATE_VAR(CGAL::cpp11::atomic, AbortFlag, true) /// 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. */ -CGAL_GLOBAL_STATE_VAR(int, InvalidFlag, 0) +CGAL_GLOBAL_STATE_VAR(CGAL::cpp11::atomic, InvalidFlag, 0) /// Escape Precision in bits CGAL_GLOBAL_STATE_VAR(extLong, EscapePrec, CORE_posInfty) @@ -99,7 +100,7 @@ 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(bool, EscapePrecWarning, true) + CGAL_GLOBAL_STATE_VAR(CGAL::cpp11::atomic, EscapePrecWarning, true) // These following two values determine the precision of computing // approximations in Expr. @@ -117,7 +118,7 @@ CGAL_GLOBAL_STATE_VAR(extLong, defAbsPrec, CORE_posInfty) "controls the printout precision of std::cout for BigFloat" Perhaps, we should merge defOutputDigits and defBigFloatOutputDigits? */ -CGAL_GLOBAL_STATE_VAR(long, defBigFloatOutputDigits, 10) + CGAL_GLOBAL_STATE_VAR(CGAL::cpp11::atomic, defBigFloatOutputDigits, 10) /// default input precision in digits for converting a string to a Real or Expr /** This value can be CORE_INFTY */ @@ -127,11 +128,11 @@ 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)). */ -CGAL_GLOBAL_STATE_VAR(long, defOutputDigits, get_static_defBigFloatOutputDigits()) +CGAL_GLOBAL_STATE_VAR(CGAL::cpp11::atomic, defOutputDigits, get_static_defBigFloatOutputDigits()) /// default input precision in digits for converting a string to a BigFloat /** This value cannot be CORE_INFTY. */ -CGAL_GLOBAL_STATE_VAR(long, defBigFloatInputDigits, 16) +CGAL_GLOBAL_STATE_VAR(CGAL::cpp11::atomic, defBigFloatInputDigits, 16) /// default BigFloat Division Relative Precision CGAL_GLOBAL_STATE_VAR(extLong, defBFdivRelPrec, 54) @@ -143,15 +144,15 @@ CGAL_GLOBAL_STATE_VAR(extLong, defBFsqrtAbsPrec, 54) ////////////////////////////////////////////////////////////// /// floating point filter flag -CGAL_GLOBAL_STATE_VAR(bool, fpFilterFlag, true) +CGAL_GLOBAL_STATE_VAR(CGAL::cpp11::atomic, fpFilterFlag, true) /// if true, evaluation of expressions would be incremental -CGAL_GLOBAL_STATE_VAR(bool, incrementalEvalFlag, true) +CGAL_GLOBAL_STATE_VAR(CGAL::cpp11::atomic, incrementalEvalFlag, true) /// progressive evaluation flag -CGAL_GLOBAL_STATE_VAR(bool, progressiveEvalFlag, true) +CGAL_GLOBAL_STATE_VAR(CGAL::cpp11::atomic, progressiveEvalFlag, true) /// rational reduction flag -CGAL_GLOBAL_STATE_VAR(bool, rationalReduceFlag, false) +CGAL_GLOBAL_STATE_VAR(CGAL::cpp11::atomic, rationalReduceFlag, false) /// default initial (bit) precision for AddSub Progressive Evaluation -CGAL_GLOBAL_STATE_VAR(long, defInitialProgressivePrec, 64) +CGAL_GLOBAL_STATE_VAR(CGAL::cpp11::atomic, defInitialProgressivePrec, 64) ////////////////////////////////////////////////////////////// // methods for setting global precision parameters diff --git a/CGAL_Core/include/CGAL/CORE/CoreDefs_impl.h b/CGAL_Core/include/CGAL/CORE/CoreDefs_impl.h index 6c87f3176ec..2bdcc096b15 100644 --- a/CGAL_Core/include/CGAL/CORE/CoreDefs_impl.h +++ b/CGAL_Core/include/CGAL/CORE/CoreDefs_impl.h @@ -58,14 +58,14 @@ int IOErrorFlag = 0; * If AbortFlag is true when invalid expression is constructed, system will abort */ -bool AbortFlag = true; +CGAL::cpp11::atomic AbortFlag = true; /** * InvalidFlag is set to negative whenever an invalid expression is constructed. * The user has the responsibility to reset to non-negative value. */ -int InvalidFlag = 0; +CGAL::cpp11::atomic InvalidFlag = 0; /* ************************************************************ * PRECISION PARAMETERS @@ -97,7 +97,7 @@ 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 */ -bool EscapePrecWarning = true; +CGAL::cpp11::atomic EscapePrecWarning = true; /** The Composite Precision [defAbsPrec, defRelPrec] * determines the precision to which an Expr evaluates its @@ -113,11 +113,11 @@ extLong defAbsPrec = CORE_posInfty; extLong defRelPrec = 60; /** number of BigFloat digits to print out */ -long defBigFloatOutputDigits = 10; +CGAL::cpp11::atomic defBigFloatOutputDigits = 10; /** NORMALLY, we like to make this equal to defBigFloatOutputDigits * 8/3/01, Chee: re-introduced this parameter */ -long defOutputDigits = defBigFloatOutputDigits; +CGAL::cpp11::atomic defOutputDigits = defBigFloatOutputDigits; /** String Input Precision */ @@ -130,7 +130,7 @@ extLong defInputDigits = CORE_posInfty; /** This controls the absolute error in converting from string to BigFloat * The absolute error will be at most 10^{-defInputDigits} */ -long defBigFloatInputDigits = 16; +CGAL::cpp11::atomic defBigFloatInputDigits = 16; /* ************************************************************ * EVALUATION FLAGS @@ -138,24 +138,24 @@ long defBigFloatInputDigits = 16; /** Floating Point filter * true = turn on floating point filter */ -bool fpFilterFlag = true; +CGAL::cpp11::atomic fpFilterFlag = true; /** IncrementaL evaluation flag * incremental evaluation is requested, This means, we try to use previous * approximate values to improve an approximation */ -bool incrementalEvalFlag = true; +CGAL::cpp11::atomic incrementalEvalFlag = true; /** Progressive evaluation flag * true = turn on progressive evaluation flag */ -bool progressiveEvalFlag = true; +CGAL::cpp11::atomic progressiveEvalFlag = true; /** Initial progressive evaluation precision * Used by AddSubRep */ -long defInitialProgressivePrec = 64; +CGAL::cpp11::atomic defInitialProgressivePrec = 64; /** RATIONAL REDUCTION FLAG * true = turn on rational reduction */ -bool rationalReduceFlag = false; +CGAL::cpp11::atomic rationalReduceFlag = false; #endif // CGAL_HEADER_ONLY