Commits

Ronan Lamy committed d6af37d

move ENABLED_LONG_DOUBLE def to typespec.py

Comments (0)

Files changed (4)

pypy/module/micronumpy/interp_boxes.py

 from rpython.rlib.objectmodel import specialize
 from rpython.tool.sourcetools import func_with_new_name
 from pypy.module.micronumpy.arrayimpl.voidbox import VoidBoxStorage
+from pypy.module.micronumpy.typespec import (ENABLED_LONG_DOUBLE,
+        long_double_size)
 
 MIXIN_32 = (int_typedef,) if LONG_BIT == 32 else ()
 MIXIN_64 = (int_typedef,) if LONG_BIT == 64 else ()
 
-# Is this the proper place for this?
-ENABLED_LONG_DOUBLE = False
-long_double_size = rffi.sizeof_c_type('long double', ignore_errors=True)
-
-import os
-if long_double_size == 8 and os.name == 'nt':
-    # this is a lie, or maybe a wish, MS fakes longdouble math with double
-    long_double_size = 12
-
-
 def new_dtype_getter(name):
     def _get_dtype(space):
         from pypy.module.micronumpy.interp_dtype import get_dtype_cache

pypy/module/micronumpy/interp_dtype.py

 from rpython.rlib import jit
 
 from pypy.module.micronumpy.arrayimpl.concrete import SliceArray
+from pypy.module.micronumpy.typespec import (ENABLED_LONG_DOUBLE,
+        long_double_size)
 
 
 UNSIGNEDLTR = "u"
             aliases=["complex"],
             float_type = self.w_float64dtype,
         )
-        if interp_boxes.ENABLED_LONG_DOUBLE and interp_boxes.long_double_size > 8:
+        if ENABLED_LONG_DOUBLE and long_double_size > 8:
             self.w_longdouble = W_Dtype(
                 types.Float80_instance,
                 num=13,
                 aliases=["clongdouble", "clongfloat"],
                 float_type = self.w_longdouble,
             )
-            if interp_boxes.long_double_size == 12:
+            if long_double_size == 12:
                 self.w_longdouble.name = "float96"
                 self.w_float96dtype = self.w_longdouble
                 self.w_clongdouble.name = "complex192"
                 self.w_complex192dtype = self.w_clongdouble
-            elif interp_boxes.long_double_size == 16:
+            elif long_double_size == 16:
                 self.w_longdouble.name = "float128"
                 self.w_float128dtype = self.w_longdouble
                 self.w_clongdouble.name = "complex256"
                 self.w_complex256dtype = self.w_clongdouble
-        elif interp_boxes.ENABLED_LONG_DOUBLE:
+        elif ENABLED_LONG_DOUBLE:
             self.w_float64dtype.aliases += ["longdouble", "longfloat"]
             self.w_complex128dtype.aliases += ["clongdouble", "clongfloat"]
             self.w_longdouble = self.w_float64dtype
                 self.w_float32dtype, self.w_float64dtype,
                 ]
         complex_dtypes =  [self.w_complex64dtype, self.w_complex128dtype]
-        if interp_boxes.ENABLED_LONG_DOUBLE:
+        if ENABLED_LONG_DOUBLE:
             float_dtypes.append(self.w_longdouble)
             complex_dtypes.append(self.w_clongdouble)
         self.builtin_dtypes = [
             'FLOAT': self.w_float32dtype,
             'BOOL': self.w_booldtype,
         }
-        if interp_boxes.ENABLED_LONG_DOUBLE:
+        if ENABLED_LONG_DOUBLE:
             typeinfo_full['LONGDOUBLE'] = self.w_longdouble
             typeinfo_full['CLONGDOUBLE'] = self.w_clongdouble
 

pypy/module/micronumpy/types.py

         int16_spec, uint16_spec, int32_spec, uint32_spec, long_spec,
         ulong_spec, int64_spec, uint64_spec, float32_spec, float64_spec,
         float16_spec)
+from pypy.module.micronumpy.typespec import (ENABLED_LONG_DOUBLE,
+        long_double_size)
 
 degToRad = math.pi / 180.0
 log2 = math.log(2)
     BoxType = interp_boxes.W_Complex128Box
     FloatType = Float64_instance
 
-if interp_boxes.ENABLED_LONG_DOUBLE and interp_boxes.long_double_size > 8:
+if ENABLED_LONG_DOUBLE and long_double_size > 8:
     class Float80(BaseType, Float):
         _attrs_ = ()
         spec = longdouble_spec
         BoxType = interp_boxes.W_CLongDoubleBox
         FloatType = Float80_instance
 
-    if interp_boxes.long_double_size in (12, 16):
-        Float80.storage_bytes = interp_boxes.long_double_size
+    if long_double_size in (12, 16):
+        Float80.storage_bytes = long_double_size
     else:
         raise ImportError("Unsupported size for long double")
 

pypy/module/micronumpy/typespec.py

 """ Meta-data for the low-level types """
+import os
 
 from rpython.rtyper.lltypesystem import rffi, lltype
 from rpython.rlib.objectmodel import specialize
 float32_spec = TypeSpec("float32", rffi.FLOAT)
 float64_spec = TypeSpec("float64", rffi.DOUBLE)
 float16_spec = TypeSpec("float16", rffi.SHORT)
+
+ENABLED_LONG_DOUBLE = False
+long_double_size = rffi.sizeof_c_type('long double', ignore_errors=True)
+if long_double_size == 8 and os.name == 'nt':
+    # this is a lie, or maybe a wish, MS fakes longdouble math with double
+    long_double_size = 12
+
+