Przeglądaj źródła

Merge branch 'candidate-6.0.0'

Signed-off-by: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 9 lat temu
rodzic
commit
d7600be32a
2 zmienionych plików z 13 dodań i 6 usunięć
  1. 8 1
      rtl/eclrtl/rtlbcd.cpp
  2. 5 5
      rtl/nbcd/nbcd.hpp

+ 8 - 1
rtl/eclrtl/rtlbcd.cpp

@@ -22,8 +22,15 @@
 #include "jmutex.hpp"
 #include "jexcept.hpp"
 
+#ifdef __APPLE__
+//Apple does not currently support thread_local (very strange), so need to use __thread.
+static __thread Decimal stack[32];
+static __thread unsigned curStack = 0;
+#else
+//gcc needs to use thread_local because it doesn't support __thread on arrays of constexpr objects
 static thread_local Decimal stack[32];
-static thread_local unsigned curStack;
+static thread_local unsigned curStack = 0;
+#endif
 
 //---------------------------------------------------------------------------------------------------------------------
 

+ 5 - 5
rtl/nbcd/nbcd.hpp

@@ -51,7 +51,7 @@ template <byte length, byte precision> class decimal;
 class nbcd_decl Decimal
 {
 public:
-    Decimal() { setZero(); }
+    constexpr Decimal() = default;
     Decimal(const Decimal & other);
 
     Decimal & abs();
@@ -144,10 +144,10 @@ protected:
         lastDigit = maxDigits-1,                  // Last decimal digit
         zeroDigit = (maxDigits-maxIntegerDigits), // Unity digit (decimal point)
     };
-    byte digits[maxDigits];                       // stored little endian.
-    byte msb;                                     // Most significant integer digit
-    byte lsb;                                     // Least significant decimal digit
-    byte negative;                                // byte to allow ^ operation
+    byte digits[maxDigits] = { 0 } ;              // stored little endian.
+    byte msb = zeroDigit;                         // Most significant integer digit
+    byte lsb = zeroDigit;                         // Least significant decimal digit
+    byte negative = false;                        // byte to allow ^ operation
 };