Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
wendelin.core
Commits
9c719e4c
Commit
9c719e4c
authored
Jun 24, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
bc40f44e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
1 deletion
+18
-1
wcfs/internal/mm.pyx
wcfs/internal/mm.pyx
+18
-1
No files found.
wcfs/internal/mm.pyx
View file @
9c719e4c
...
...
@@ -79,6 +79,8 @@ def lock(const unsigned char[::1] mem not None, int flags):
if
err
:
PyErr_SetFromErrno
(
OSError
)
return
# ok
# unlock unlocks mem pages from being pinned in RAM.
def
unlock
(
const
unsigned
char
[::
1
]
mem
not
None
):
...
...
@@ -89,6 +91,8 @@ def unlock(const unsigned char[::1] mem not None):
if
err
:
PyErr_SetFromErrno
(
OSError
)
return
# ok
from
posix.types
cimport
off_t
...
...
@@ -102,6 +106,16 @@ def map_ro(int fd, off_t offset, size_t size):
return
<
unsigned
char
[:
size
:
1
]
>
addr
# map_into mmaps fd[offset:...] into mem's memory.
def
map_into_ro
(
unsigned
char
[::
1
]
mem
not
None
,
int
fd
,
off_t
offset
):
cdef
void
*
addr
=
&
mem
[
0
]
cdef
size_t
size
=
mem
.
shape
[
0
]
addr
=
mman
.
mmap
(
addr
,
size
,
mman
.
PROT_READ
,
mman
.
MAP_SHARED
|
mman
.
MAP_FIXED
,
fd
,
offset
)
if
addr
==
mman
.
MAP_FAILED
:
PyErr_SetFromErrno
(
OSError
)
return
# ok
# unmap unmaps memory covered by mem.
def
unmap
(
const
unsigned
char
[::
1
]
mem
not
None
):
...
...
@@ -111,7 +125,8 @@ def unmap(const unsigned char[::1] mem not None):
cdef
err
=
mman
.
munmap
(
<
void
*>
addr
,
size
)
if
err
:
PyErr_SetFromErrno
(
OSError
)
# ok
return
# ok
# advise advises kernel about use of mem's memory.
...
...
@@ -125,3 +140,5 @@ def advise(const unsigned char[::1] mem not None, int advice):
cdef
err
=
mman
.
posix_madvise
(
<
void
*>
addr
,
size
,
advice
)
if
err
:
PyErr_SetFromErrno
(
OSError
)
return
# ok
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment