mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-17 00:24:16 +00:00
Add automatic MAP_POPULATE flag for opening read_only (MAP_PRIVATE) and shared (MAP_SHARED) mmap files.
This commit is contained in:
@@ -1375,6 +1375,8 @@ var
|
||||
## Share changes.
|
||||
MAP_PRIVATE* {.importc, header: "<sys/mman.h>".}: cint
|
||||
## Changes are private.
|
||||
MAP_POPULATE* {.importc, header: "<sys/mman.h>".}: cint
|
||||
## Populate (prefault) page tables for a mapping.
|
||||
MAP_FIXED* {.importc, header: "<sys/mman.h>".}: cint
|
||||
## Interpret addr exactly.
|
||||
MS_ASYNC* {.importc, header: "<sys/mman.h>".}: cint
|
||||
|
||||
@@ -54,7 +54,7 @@ proc mapMem*(m: var TMemFile, mode: TFileMode = fmRead,
|
||||
nil,
|
||||
mappedSize,
|
||||
if readonly: PROT_READ else: PROT_READ or PROT_WRITE,
|
||||
if readonly: MAP_PRIVATE else: MAP_SHARED,
|
||||
if readonly: (MAP_PRIVATE or MAP_POPULATE) else: (MAP_SHARED or MAP_POPULATE),
|
||||
m.handle, offset)
|
||||
if result == cast[pointer](MAP_FAILED):
|
||||
osError(osLastError())
|
||||
@@ -207,7 +207,7 @@ proc open*(filename: string, mode: TFileMode = fmRead,
|
||||
nil,
|
||||
result.size,
|
||||
if readonly: PROT_READ else: PROT_READ or PROT_WRITE,
|
||||
if readonly: MAP_PRIVATE else: MAP_SHARED,
|
||||
if readonly: (MAP_PRIVATE or MAP_POPULATE) else: (MAP_SHARED or MAP_POPULATE),
|
||||
result.handle,
|
||||
offset)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user