Revert "Do not automatically use MAP_POPULATE for opening mmap files."
This reverts commit cba75db4e3. The prior
commit yields a compiler error 'error: lvalue required as left operand
of assignment; MAP_POPULATE = ((int) 0);'. So for now this branch
*always* adds MAP_POPULATE when using the open and mapMem procs.
This commit is contained in:
parent
cba75db4e3
commit
3a57052e57
1 changed files with 3 additions and 9 deletions
|
|
@ -30,17 +30,14 @@ type
|
||||||
|
|
||||||
when defined(windows):
|
when defined(windows):
|
||||||
fHandle: int
|
fHandle: int
|
||||||
mapHandle: int
|
mapHandle: int
|
||||||
else:
|
else:
|
||||||
handle: cint
|
handle: cint
|
||||||
|
|
||||||
|
|
||||||
proc mapMem*(m: var TMemFile, mode: TFileMode = fmRead,
|
proc mapMem*(m: var TMemFile, mode: TFileMode = fmRead,
|
||||||
mappedSize = -1, offset = 0,
|
mappedSize = -1, offset = 0): pointer =
|
||||||
use_map_populate = false): pointer =
|
|
||||||
var readonly = mode == fmRead
|
var readonly = mode == fmRead
|
||||||
if not use_map_populate:
|
|
||||||
MAP_POPULATE = 0
|
|
||||||
when defined(windows):
|
when defined(windows):
|
||||||
result = mapViewOfFileEx(
|
result = mapViewOfFileEx(
|
||||||
m.mapHandle,
|
m.mapHandle,
|
||||||
|
|
@ -75,8 +72,7 @@ proc unmapMem*(f: var TMemFile, p: pointer, size: int) =
|
||||||
|
|
||||||
|
|
||||||
proc open*(filename: string, mode: TFileMode = fmRead,
|
proc open*(filename: string, mode: TFileMode = fmRead,
|
||||||
mappedSize = -1, offset = 0, newFileSize = -1,
|
mappedSize = -1, offset = 0, newFileSize = -1): TMemFile =
|
||||||
use_map_populate = false): TMemFile =
|
|
||||||
## opens a memory mapped file. If this fails, ``EOS`` is raised.
|
## opens a memory mapped file. If this fails, ``EOS`` is raised.
|
||||||
## `newFileSize` can only be set if the file does not exist and is opened
|
## `newFileSize` can only be set if the file does not exist and is opened
|
||||||
## with write access (e.g., with fmReadWrite). `mappedSize` and `offset`
|
## with write access (e.g., with fmReadWrite). `mappedSize` and `offset`
|
||||||
|
|
@ -98,8 +94,6 @@ proc open*(filename: string, mode: TFileMode = fmRead,
|
||||||
# The file can be resized only when write mode is used:
|
# The file can be resized only when write mode is used:
|
||||||
assert newFileSize == -1 or mode != fmRead
|
assert newFileSize == -1 or mode != fmRead
|
||||||
var readonly = mode == fmRead
|
var readonly = mode == fmRead
|
||||||
if not use_map_populate:
|
|
||||||
MAP_POPULATE = 0
|
|
||||||
|
|
||||||
template rollback =
|
template rollback =
|
||||||
result.mem = nil
|
result.mem = nil
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue