Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix Mmap.sync! for array mapped from an offset
This fixes error when calling `Mmap.sync!` on an array that is not memory mapped from a pagesized offset of a file. ```` julia> using Base.Mmap julia> f = open("arrayfile", "r+"); julia> A = Mmap.mmap(f, Vector{Int64}, (200,), 0); julia> Mmap.sync!(A) julia> B = Mmap.mmap(f, Vector{Int64}, (200,), 8); julia> Mmap.sync!(B) ERROR: SystemError: msync: Invalid argument [inlined code] from ./int.jl:33 in sync!(Base.Mmap.#sync!, Array{Int64,1}, Int64) at ./mmap.jl:207 (repeats 2 times) in eval at ./boot.jl:267 ```` Since `Mmap.mmap` maps from the beginning of a page boundary, `pointer(A)` is not at the page boundary when an offset is provided. But since the pointer returned from `mmap` is aligned at page boundary, `sync!` now recalculates the offset before calling `msync!`. ```` julia> using Base.Mmap julia> f = open("arrayfile", "r+"); julia> B = Mmap.mmap(f, Vector{Int64}, (200,), 8); julia> Mmap.sync!(B) ````
- Loading branch information