Armin Rigo avatar Armin Rigo committed a3bed57

More long long removal.

Comments (0)

Files changed (3)

pypy/module/_cffi_backend/ctypeprim.py

 
     def convert_to_object(self, cdata):
         if self.value_fits_long:
-            value = misc.read_raw_ulong_data(cdata, self.size)
+            value = misc.read_raw_uint_data(cdata, self.size)
             return self.space.wrap(value)
         else:
             value = misc.read_raw_unsigned_data(cdata, self.size)

pypy/module/_cffi_backend/ctypestruct.py

 from pypy.interpreter.baseobjspace import Wrappable
 from pypy.interpreter.typedef import TypeDef, interp_attrproperty
 from pypy.rlib.objectmodel import keepalive_until_here
-from pypy.rlib.rarithmetic import r_ulonglong, r_longlong, intmask
+from pypy.rlib.rarithmetic import r_uint, r_ulonglong, r_longlong, intmask
 from pypy.rlib import jit
 
 from pypy.module._cffi_backend.ctypeobj import W_CType
         space = ctype.space
         #
         if isinstance(ctype, ctypeprim.W_CTypePrimitiveSigned):
-            value = r_ulonglong(misc.read_raw_signed_data(cdata, ctype.size))
-            valuemask = (r_ulonglong(1) << self.bitsize) - 1
-            shiftforsign = r_ulonglong(1) << (self.bitsize - 1)
-            value = ((value >> self.bitshift) + shiftforsign) & valuemask
-            result = r_longlong(value) - r_longlong(shiftforsign)
             if ctype.value_fits_long:
-                return space.wrap(intmask(result))
+                value = r_uint(misc.read_raw_long_data(cdata, ctype.size))
+                valuemask = (r_uint(1) << self.bitsize) - 1
+                shiftforsign = r_uint(1) << (self.bitsize - 1)
+                value = ((value >> self.bitshift) + shiftforsign) & valuemask
+                result = intmask(value) - intmask(shiftforsign)
+                return space.wrap(result)
             else:
+                value = misc.read_raw_unsigned_data(cdata, ctype.size)
+                valuemask = (r_ulonglong(1) << self.bitsize) - 1
+                shiftforsign = r_ulonglong(1) << (self.bitsize - 1)
+                value = ((value >> self.bitshift) + shiftforsign) & valuemask
+                result = r_longlong(value) - r_longlong(shiftforsign)
                 return space.wrap(result)
         #
         if isinstance(ctype, ctypeprim.W_CTypePrimitiveUnsigned):
         else:
             raise NotImplementedError
         #
-        value = misc.read_raw_unsigned_data(cdata, ctype.size)
-        valuemask = (r_ulonglong(1) << self.bitsize) - 1
-        value = (value >> self.bitshift) & valuemask
         if value_fits_long:
+            value = r_uint(misc.read_raw_uint_data(cdata, ctype.size))
+            valuemask = (r_uint(1) << self.bitsize) - 1
+            value = (value >> self.bitshift) & valuemask
             return space.wrap(intmask(value))
         else:
+            value = misc.read_raw_unsigned_data(cdata, ctype.size)
+            valuemask = (r_ulonglong(1) << self.bitsize) - 1
+            value = (value >> self.bitshift) & valuemask
             return space.wrap(value)
 
     def convert_bitfield_from_object(self, cdata, w_ob):

pypy/module/_cffi_backend/misc.py

             return rffi.cast(lltype.UnsignedLongLong, rffi.cast(TPP,target)[0])
     raise NotImplementedError("bad integer size")
 
-def read_raw_ulong_data(target, size):
+def read_raw_uint_data(target, size):
     # only for types smaller than Unsigned
     for TP, TPP in _prim_unsigned_types:
         if size == rffi.sizeof(TP):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.