[pypy-svn] r78496 - in pypy/branch/fast-forward/pypy: module/mmap module/mmap/test rlib
afa at codespeak.net
afa at codespeak.net
Sat Oct 30 00:13:56 CEST 2010
Author: afa
Date: Sat Oct 30 00:13:55 2010
New Revision: 78496
Modified:
pypy/branch/fast-forward/pypy/module/mmap/__init__.py
pypy/branch/fast-forward/pypy/module/mmap/interp_mmap.py
pypy/branch/fast-forward/pypy/module/mmap/test/test_mmap.py
pypy/branch/fast-forward/pypy/rlib/rmmap.py
Log:
Add mmap.ALLOCATIONGRANULARITY
Modified: pypy/branch/fast-forward/pypy/module/mmap/__init__.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/mmap/__init__.py (original)
+++ pypy/branch/fast-forward/pypy/module/mmap/__init__.py Sat Oct 30 00:13:55 2010
@@ -4,6 +4,7 @@
class Module(MixedModule):
interpleveldefs = {
'PAGESIZE': 'space.wrap(interp_mmap.PAGESIZE)',
+ 'ALLOCATIONGRANULARITY': 'space.wrap(interp_mmap.ALLOCATIONGRANULARITY)',
'mmap': 'interp_mmap.W_MMap'
}
Modified: pypy/branch/fast-forward/pypy/module/mmap/interp_mmap.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/mmap/interp_mmap.py (original)
+++ pypy/branch/fast-forward/pypy/module/mmap/interp_mmap.py Sat Oct 30 00:13:55 2010
@@ -248,3 +248,4 @@
constants = rmmap.constants
PAGESIZE = rmmap.PAGESIZE
+ALLOCATIONGRANULARITY = rmmap.ALLOCATIONGRANULARITY
Modified: pypy/branch/fast-forward/pypy/module/mmap/test/test_mmap.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/mmap/test/test_mmap.py (original)
+++ pypy/branch/fast-forward/pypy/module/mmap/test/test_mmap.py Sat Oct 30 00:13:55 2010
@@ -11,8 +11,11 @@
def test_page_size(self):
import mmap
assert mmap.PAGESIZE > 0
+ assert mmap.ALLOCATIONGRANULARITY > 0
assert isinstance(mmap.PAGESIZE, int)
-
+ assert isinstance(mmap.ALLOCATIONGRANULARITY, int)
+ assert mmap.ALLOCATIONGRANULARITY % mmap.PAGESIZE == 0
+
def test_attributes(self):
import mmap
import os
Modified: pypy/branch/fast-forward/pypy/rlib/rmmap.py
==============================================================================
--- pypy/branch/fast-forward/pypy/rlib/rmmap.py (original)
+++ pypy/branch/fast-forward/pypy/rlib/rmmap.py Sat Oct 30 00:13:55 2010
@@ -119,6 +119,7 @@
# this one is always safe
_, _get_page_size = external('getpagesize', [], rffi.INT)
+ _get_allocation_granularity = _get_page_size
def _get_error_no():
return rposix.get_errno()
@@ -195,7 +196,7 @@
VirtualFree = winexternal('VirtualFree',
[rffi.VOIDP, rffi.SIZE_T, DWORD], BOOL)
-
+
def _get_page_size():
try:
si = rffi.make(SYSTEM_INFO)
@@ -203,7 +204,15 @@
return int(si.c_dwPageSize)
finally:
lltype.free(si, flavor="raw")
-
+
+ def _get_allocation_granularity():
+ try:
+ si = rffi.make(SYSTEM_INFO)
+ GetSystemInfo(si)
+ return int(si.c_dwAllocationGranularity)
+ finally:
+ lltype.free(si, flavor="raw")
+
def _get_file_size(handle):
# XXX use native Windows types like WORD
high_ref = lltype.malloc(LPDWORD.TO, 1, flavor='raw')
@@ -232,6 +241,7 @@
INVALID_HANDLE = INVALID_HANDLE_VALUE
PAGESIZE = _get_page_size()
+ALLOCATIONGRANULARITY = _get_allocation_granularity()
NULL = lltype.nullptr(PTR.TO)
NODATA = lltype.nullptr(PTR.TO)
More information about the Pypy-commit
mailing list