[pypy-svn] pypy 32ptr-on-64bit: Fix, mostly for tests: let c_mmap_safe() be a no-gc operation.

arigo commits-noreply at bitbucket.org
Sat Apr 16 22:12:00 CEST 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: 32ptr-on-64bit
Changeset: r43408:dd7b2ce8b037
Date: 2011-04-16 22:10 +0200
http://bitbucket.org/pypy/pypy/changeset/dd7b2ce8b037/

Log:	Fix, mostly for tests: let c_mmap_safe() be a no-gc operation.

diff --git a/pypy/rlib/rmmap.py b/pypy/rlib/rmmap.py
--- a/pypy/rlib/rmmap.py
+++ b/pypy/rlib/rmmap.py
@@ -101,7 +101,8 @@
                              compilation_info=CConfig._compilation_info_)
     safe = rffi.llexternal(name, args, result,
                            compilation_info=CConfig._compilation_info_,
-                           sandboxsafe=True, threadsafe=False)
+                           sandboxsafe=True, threadsafe=False,
+                           _nowrapper=True)
     return unsafe, safe
 
 def winexternal(name, args, result, **kwargs):
@@ -118,18 +119,31 @@
     has_mremap = cConfig['has_mremap']
     c_mmap, _c_mmap_safe = external('mmap', [PTR, size_t, rffi.INT, rffi.INT,
                                rffi.INT, off_t], PTR)
-    c_munmap, c_munmap_safe = external('munmap', [PTR, size_t], rffi.INT)
+    c_munmap, _c_munmap_safe = external('munmap', [PTR, size_t], rffi.INT)
     c_msync, _ = external('msync', [PTR, size_t, rffi.INT], rffi.INT)
     if has_mremap:
         c_mremap, _ = external('mremap',
                                [PTR, size_t, size_t, rffi.ULONG], PTR)
 
     def c_mmap_safe(addr, length, prot, flags, fd, offset):
+        length = rffi.cast(rffi.SIZE_T, length)
+        prot = rffi.cast(rffi.INT, prot)
+        flags = rffi.cast(rffi.INT, flags)
+        fd = rffi.cast(rffi.INT, fd)
+        offset = rffi.cast(off_t, offset)
         return _c_mmap_safe(addr, length, prot, flags, fd, offset)
     c_mmap_safe._annenforceargs_ = (PTR, int, int, int, int, int)
 
+    def c_munmap_safe(addr, length):
+        length = rffi.cast(rffi.SIZE_T, length)
+        res = _c_munmap_safe(addr, length)
+        return rffi.cast(lltype.Signed, res)
+    c_munmap_safe._annenforceargs_ = (PTR, int)
+
     # this one is always safe
-    _, _get_page_size = external('getpagesize', [], rffi.INT)
+    _, _c_get_page_size = external('getpagesize', [], rffi.INT)
+    def _get_page_size():
+        return rffi.cast(lltype.Signed, _c_get_page_size())
     _get_allocation_granularity = _get_page_size
 
 elif _MS_WINDOWS:


More information about the Pypy-commit mailing list