Author: mattip <[email protected]>
Branch: safe-win-mmap
Changeset: r66959:8283a926aa30
Date: 2013-09-15 20:08 +0300
http://bitbucket.org/pypy/pypy/changeset/8283a926aa30/
Log: cleanup (amaury)
diff --git a/rpython/rlib/rmmap.py b/rpython/rlib/rmmap.py
--- a/rpython/rlib/rmmap.py
+++ b/rpython/rlib/rmmap.py
@@ -200,27 +200,16 @@
DuplicateHandle, _ = winexternal('DuplicateHandle', [HANDLE, HANDLE,
HANDLE, LPHANDLE, DWORD, BOOL, DWORD], BOOL)
CreateFileMapping, _ = winexternal('CreateFileMappingA', [HANDLE,
rwin32.LPSECURITY_ATTRIBUTES, DWORD, DWORD, DWORD, LPCSTR], HANDLE)
MapViewOfFile, _ = winexternal('MapViewOfFile', [HANDLE, DWORD, DWORD,
DWORD, SIZE_T], LPCSTR)##!!LPVOID)
- _, UnmapViewOfFile = winexternal('UnmapViewOfFile', [LPCSTR], BOOL)
+ _, UnmapViewOfFile_safe = winexternal('UnmapViewOfFile', [LPCSTR], BOOL)
FlushViewOfFile, _ = winexternal('FlushViewOfFile', [LPCSTR, SIZE_T], BOOL)
SetFilePointer, _ = winexternal('SetFilePointer', [HANDLE, LONG, PLONG,
DWORD], DWORD)
SetEndOfFile, _ = winexternal('SetEndOfFile', [HANDLE], BOOL)
VirtualAlloc, VirtualAlloc_safe = winexternal('VirtualAlloc',
[rffi.VOIDP, rffi.SIZE_T, DWORD, DWORD],
rffi.VOIDP)
- # VirtualProtect is used in llarena and should not release the GIL
- _VirtualProtect, _ = winexternal('VirtualProtect',
- [rffi.VOIDP, rffi.SIZE_T, DWORD, LPDWORD],
- BOOL,
- _nowrapper=True)
_, VirtualProtect_safe = winexternal('VirtualProtect',
[rffi.VOIDP, rffi.SIZE_T, DWORD, LPDWORD],
BOOL)
- def VirtualProtect(addr, size, mode, oldmode_ptr):
- return _VirtualProtect(addr,
- rffi.cast(rffi.SIZE_T, size),
- rffi.cast(DWORD, mode),
- oldmode_ptr)
- VirtualProtect._annspecialcase_ = 'specialize:ll'
VirtualFree, VirtualFree_safe = winexternal('VirtualFree',
[rffi.VOIDP, rffi.SIZE_T, DWORD], BOOL)
@@ -308,7 +297,7 @@
def unmap(self):
if _MS_WINDOWS:
- UnmapViewOfFile(self.getptr(0))
+ UnmapViewOfFile_safe(self.getptr(0))
elif _POSIX:
self.unmap_range(0, self.size)
diff --git a/rpython/rtyper/lltypesystem/llarena.py
b/rpython/rtyper/lltypesystem/llarena.py
--- a/rpython/rtyper/lltypesystem/llarena.py
+++ b/rpython/rtyper/lltypesystem/llarena.py
@@ -529,13 +529,14 @@
elif os.name == 'nt':
def llimpl_protect(addr, size, inaccessible):
- from rpython.rlib.rmmap import VirtualProtect, LPDWORD
+ from rpython.rlib.rmmap import VirtualProtect_safe, LPDWORD
if inaccessible:
from rpython.rlib.rmmap import PAGE_NOACCESS as newprotect
else:
from rpython.rlib.rmmap import PAGE_READWRITE as newprotect
arg = lltype.malloc(LPDWORD.TO, 1, zero=True, flavor='raw')
- VirtualProtect(rffi.cast(rffi.VOIDP, addr),
+ #does not release the GIL
+ VirtualProtect_safe(rffi.cast(rffi.VOIDP, addr),
size, newprotect, arg)
# ignore potential errors
lltype.free(arg, flavor='raw')
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit