[pypy-svn] r47239 - pypy/dist/pypy/module/mmap

arigo at codespeak.net arigo at codespeak.net
Sat Oct 6 13:53:42 CEST 2007


Author: arigo
Date: Sat Oct  6 13:53:42 2007
New Revision: 47239

Modified:
   pypy/dist/pypy/module/mmap/interp_mmap.py
Log:
For pointer arithmetic, we don't need the same broken logic as we did
with rctypes: there is rffi.ptradd().


Modified: pypy/dist/pypy/module/mmap/interp_mmap.py
==============================================================================
--- pypy/dist/pypy/module/mmap/interp_mmap.py	(original)
+++ pypy/dist/pypy/module/mmap/interp_mmap.py	Sat Oct  6 13:53:42 2007
@@ -68,7 +68,7 @@
 def external(name, args, result):
     return rffi.llexternal(name, args, result, includes=CConfig._includes_)
 
-PTR = rffi.VOIDP # XXX?
+PTR = rffi.CCHARP
 
 has_mremap = cConfig['has_mremap']
 
@@ -400,14 +400,7 @@
     write_byte.unwrap_spec = ['self', str]
 
     def getptr(self, offset):
-        if offset > 0:
-            # XXX 64-bit support for pointer arithmetic!
-            # is this still valid?
-            dataptr = lltype.cast_int_to_ptr(PTR, lltype.cast_ptr_to_int(
-                self.data) + offset)
-            return dataptr
-        else:
-            return self.data
+        return rffi.ptradd(self.data, offset)
 
     def flush(self, offset=0, size=0):
         self.check_valid()
@@ -666,7 +659,7 @@
                                      space.wrap(os.strerror(e.errno)))
 
         res = c_mmap(NULL, map_size, prot, flags, fd, 0)
-        if lltype.cast_ptr_to_int(res) == -1:
+        if res == rffi.cast(PTR, -1):
             raise OperationError(space.w_EnvironmentError,
                 space.wrap(_get_error_msg()))
         



More information about the Pypy-commit mailing list