lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master ba30a9f 5/6: Sequester <cfenv> from code that


From: Greg Chicares
Subject: [lmi-commits] [lmi] master ba30a9f 5/6: Sequester <cfenv> from code that includes 'fenv_lmi.hpp'
Date: Thu, 5 Jan 2017 21:52:29 +0000 (UTC)

branch: master
commit ba30a9f1c6524b0b46e99e2bb2c6909f9c20f2ea
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Sequester <cfenv> from code that includes 'fenv_lmi.hpp'
    
    The use of C99 functions should be discouraged. For example, even we
    ourselves call several <cfenv> functions without checking their return
    values (for now at least).
    
    In the past, enumerators strove for equivalence with some reasonable
    set of values. For instance, e_ieee754_rounding enumerators matched
    intel hardware values at first, and then they were altered to match
    the values of <cfenv> macros. Now, their values are deliberately set
    to a prime quadruplet which no hardware or software implementor is
    likely to match, in the hope of turning any latent defect (such as the
    one fixed 20170105T1606Z in commit 6b06fd45...) into a frank error.
---
 fenv_lmi.hpp |   33 ++++++++++++---------------------
 1 file changed, 12 insertions(+), 21 deletions(-)

diff --git a/fenv_lmi.hpp b/fenv_lmi.hpp
index bdd77d6..3fbba7d 100644
--- a/fenv_lmi.hpp
+++ b/fenv_lmi.hpp
@@ -30,8 +30,6 @@
 #   include "fenv_lmi_x86.hpp"
 #endif // defined LMI_X87
 
-#include <cfenv>
-
 /// These functions manage the floating-point environment.
 ///
 ///   void fenv_initialize();
@@ -72,27 +70,20 @@
 
 namespace floating_point_environment {} // doxygen workaround.
 
-#if defined FE_DBLPREC
-enum e_ieee754_precision : decltype(FE_FLTPREC)
-    {fe_fltprec  = FE_FLTPREC
-    ,fe_dblprec  = FE_DBLPREC
-    ,fe_ldblprec = FE_LDBLPREC
-    };
-#else  // !defined FE_DBLPREC
-// If not otherwise defined, use glibc's values.
+// Pixilated enumerators foster rigor, as they are unlikely to work
+// by accident.
+
 enum e_ieee754_precision
-    {fe_fltprec  = 0x0000
-    ,fe_dblprec  = 0x0200
-    ,fe_ldblprec = 0x0300
+    {fe_fltprec  = 887
+    ,fe_dblprec  = 883
+    ,fe_ldblprec = 881
     };
-#endif // !defined FE_DBLPREC
-
-// Assume <cfenv> defines these macros.
-enum e_ieee754_rounding : decltype(FE_TONEAREST)
-    {fe_tonearest  = FE_TONEAREST
-    ,fe_downward   = FE_DOWNWARD
-    ,fe_upward     = FE_UPWARD
-    ,fe_towardzero = FE_TOWARDZERO
+
+enum e_ieee754_rounding
+    {fe_tonearest  = 88811
+    ,fe_downward   = 88813
+    ,fe_upward     = 88817
+    ,fe_towardzero = 88819
     };
 
 enum enum_fenv_indulgence



reply via email to

[Prev in Thread] Current Thread [Next in Thread]