diff --git a/.travis.yml b/.travis.yml index 93231ad..01c9bd0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,11 @@ os: - osx julia: - 0.6 + - 1.1 + - 1.2 + - 1.3 + - 1.4 + - 1.5 - nightly notifications: email: false @@ -13,9 +18,9 @@ git: ## uncomment the following lines to allow failures on nightly julia ## (tests will run but not make your overall status red) -#matrix: -# allow_failures: -# - julia: nightly +matrix: + allow_failures: + - julia: nightly ## uncomment and modify the following lines to manually install system packages #addons: diff --git a/Project.toml b/Project.toml index 8cd1870..986178f 100644 --- a/Project.toml +++ b/Project.toml @@ -1,13 +1,14 @@ name = "PageAlignedArrays" uuid = "ba0cfe35-a769-40a2-96c5-fb706a08f4a0" authors = ["Andrew Keller"] -version = "0.1" +version = "0.1.0" [deps] -Compat = "8f399da3-3557-5675-b5ff-fb832c97cbdb" +Compat = "34da2185-b29b-5c13-b0c7-acf172513d20" +Mmap = "a63ad114-7e13-5084-954f-fe012c677804" [compat] -julia = "1.5" +julia = "1" [extras] Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/src/PageAlignedArrays.jl b/src/PageAlignedArrays.jl index 1d2aa6d..ccad833 100644 --- a/src/PageAlignedArrays.jl +++ b/src/PageAlignedArrays.jl @@ -20,7 +20,7 @@ mutable struct PageAlignedArray{T,N} <: AbstractArray{T,N} function PageAlignedArray{T,N}(dims::NTuple{N,Integer}) where {T,N} n = N == 0 ? 1 : reduce(*, dims) addr = virtualalloc(sizeof(T) * n, T) - backing = unsafe_wrap(Array, addr, dims, false) + backing = unsafe_wrap(Array, addr, dims, own=false) array = new{T,N}(backing, addr) @compat finalizer(x->virtualfree(x.addr), array) return array @@ -44,15 +44,15 @@ Allocate page-aligned memory and return a `Ptr{T}` to the allocation. The caller responsible for de-allocating the memory using `virtualfree`, otherwise it will leak. """ function virtualalloc(size_bytes::Integer, ::Type{T}) where {T} - @static Compat.Sys.iswindows() ? begin + @static Base.Sys.iswindows() ? begin MEM_COMMIT = 0x1000 PAGE_READWRITE = 0x4 addr = ccall((:VirtualAlloc, "Kernel32"), Ptr{T}, - (Ptr{Void}, Csize_t, Culong, Culong), + (Ptr{Cvoid}, Csize_t, Culong, Culong), C_NULL, size_bytes, MEM_COMMIT, PAGE_READWRITE) - end : @static Compat.Sys.islinux() ? begin + end : @static Base.Sys.islinux() ? begin addr = ccall(:valloc, Ptr{T}, (Csize_t,), size_bytes) - end : @static Compat.Sys.isapple() ? begin + end : @static Base.Sys.isapple() ? begin addr = ccall((:valloc, "libSystem.dylib"), Ptr{T}, (Csize_t,), size_bytes) end : throw(SystemError()) @@ -66,14 +66,14 @@ Free memory that has been allocated using `virtualalloc`. Undefined, likely very behavior if called on a pointer coming from elsewhere. """ function virtualfree(addr::Ptr{T}) where {T} - @static Compat.Sys.iswindows() ? begin + @static Base.Sys.iswindows() ? begin MEM_RELEASE = 0x8000 - return ccall((:VirtualFree, "Kernel32"), Cint, (Ptr{Void}, Csize_t, Culong), + return ccall((:VirtualFree, "Kernel32"), Cint, (Ptr{Cvoid}, Csize_t, Culong), addr, 0, MEM_RELEASE) - end : @static Compat.Sys.islinux() ? begin - return ccall(:free, Void, (Ptr{Void},), addr) - end : @static Compat.Sys.isapple() ? begin - return ccall((:free, "libSystem.dylib"), Void, (Ptr{Void},), addr) + end : @static Base.Sys.islinux() ? begin + return ccall(:free, Void, (Ptr{Cvoid},), addr) + end : @static Base.Sys.isapple() ? begin + return ccall((:free, "libSystem.dylib"), Void, (Ptr{Cvoid},), addr) end : error("OS not supported") end end # module diff --git a/test/Project.toml b/test/Project.toml index 0c36332..a2114c2 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -1,2 +1,3 @@ [deps] Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" +Mmap = "a63ad114-7e13-5084-954f-fe012c677804" diff --git a/test/runtests.jl b/test/runtests.jl index 03ec0b3..8dc2697 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -4,7 +4,7 @@ using Mmap p = PageAlignedVector{Int}(512) -@test (p[:] = 1) == 1 +p[:] .= 1 @test eltype(p) == Int @test @inferred(p[1]) == 1 @test all(p .== 1) @@ -12,4 +12,4 @@ p = PageAlignedVector{Int}(512) @test size(p) == (512,) @test Base.IndexStyle(p) == Base.IndexLinear() -@test Integer(pointer(p)) % Mmap.PAGESIZE == 0 +@test Int(pointer(p)) % Mmap.PAGESIZE == 0