Merge pull request #1405 from boydgreenfield/add_mmap_map_populate
Add mmap map populate
This commit is contained in:
commit
bba644fbd1
2 changed files with 12 additions and 2 deletions
|
|
@ -1579,6 +1579,16 @@ var
|
||||||
MSG_OOB* {.importc, header: "<sys/socket.h>".}: cint
|
MSG_OOB* {.importc, header: "<sys/socket.h>".}: cint
|
||||||
## Out-of-band data.
|
## Out-of-band data.
|
||||||
|
|
||||||
|
|
||||||
|
when defined(linux):
|
||||||
|
var
|
||||||
|
MAP_POPULATE* {.importc, header: "<sys/mman.h>".}: cint
|
||||||
|
## Populate (prefault) page tables for a mapping.
|
||||||
|
else:
|
||||||
|
var
|
||||||
|
MAP_POPULATE*: cint = 0
|
||||||
|
|
||||||
|
|
||||||
when defined(macosx):
|
when defined(macosx):
|
||||||
var
|
var
|
||||||
MSG_HAVEMORE* {.importc, header: "<sys/socket.h>".}: cint
|
MSG_HAVEMORE* {.importc, header: "<sys/socket.h>".}: cint
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ proc mapMem*(m: var TMemFile, mode: TFileMode = fmRead,
|
||||||
nil,
|
nil,
|
||||||
mappedSize,
|
mappedSize,
|
||||||
if readonly: PROT_READ else: PROT_READ or PROT_WRITE,
|
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)
|
m.handle, offset)
|
||||||
if result == cast[pointer](MAP_FAILED):
|
if result == cast[pointer](MAP_FAILED):
|
||||||
osError(osLastError())
|
osError(osLastError())
|
||||||
|
|
@ -207,7 +207,7 @@ proc open*(filename: string, mode: TFileMode = fmRead,
|
||||||
nil,
|
nil,
|
||||||
result.size,
|
result.size,
|
||||||
if readonly: PROT_READ else: PROT_READ or PROT_WRITE,
|
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,
|
result.handle,
|
||||||
offset)
|
offset)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue