Commit ba7c8c7b authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent f3cb4f8f
......@@ -62,7 +62,7 @@ class _RAMFileH(object):
# mmap(2) allows mmaping past the end, but python's mmap does not.
# we workaround it with explicitly growing file as needed.
# however we need to protect against races between concurrent .mmap() calls.
# ._mmapmu is used for this.
# ._mmapmu is used for this. XXX -> our mmap?
self._mmapmu = threading.Lock()
def mmap(self, pgoffset, pglen):
......
......@@ -77,3 +77,27 @@ def munlock(const unsigned char[::1] mem not None):
cdef err = mman.munlock(addr, size)
if err:
PyErr_SetFromErrno(OSError)
from posix.types cimport off_t
# XXX PROT_READ | MAP_SHARED
def mmap_ro(int fd, off_t offset, size_t size):
cdef void *addr
addr = mman.mmap(NULL, size, mman.PROT_READ, mman.MAP_SHARED, fd, offset)
if addr == mman.MAP_FAILED:
PyErr_SetFromErrno(OSError)
return <unsigned char[:size:1]>addr
# munmap unmaps memory coverd by mem.
def munmap(const unsigned char[::1] mem not None):
cdef const void *addr = &mem[0]
cdef size_t size = mem.shape[0]
cdef err = mman.munmap(<void *>addr, size)
if err:
PyErr_SetFromErrno(OSError)
# ok
......@@ -37,13 +37,7 @@ from errno import EINVAL
from golang import func, defer
from zodbtools.util import ashex as h, fromhex
from pytest import raises
from . import mman
print(mman.PAGE_SIZE)
print(mman.MLOCK_ONFAULT)
print(mman.MCL_CURRENT)
print(mman.MCL_ONFAULT)
mman.mincore(bytearray(b'hello world'))
# setup:
# - create test database, compute zurl and mountpoint for wcfs
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment