Skip to content

Commit

Permalink
Fix libc issue and deprecations.
Browse files Browse the repository at this point in the history
  • Loading branch information
ajkeller34 committed Mar 2, 2018
1 parent 81a4e3a commit a554245
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/PageAlignedArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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.is_windows() ? begin
@static Compat.Sys.iswindows() ? begin
MEM_COMMIT = 0x1000
PAGE_READWRITE = 0x4
addr = ccall((:VirtualAlloc, "Kernel32"), Ptr{T},
(Ptr{Void}, Csize_t, Culong, Culong),
C_NULL, size_bytes, MEM_COMMIT, PAGE_READWRITE)
end : @static Compat.Sys.is_linux() ? begin
addr = ccall((:valloc, "libc"), Ptr{T}, (Csize_t,), size_bytes)
end : @static Compat.Sys.is_apple() ? begin
end : @static Compat.Sys.islinux() ? begin
addr = ccall(:valloc, Ptr{T}, (Csize_t,), size_bytes)
end : @static Compat.Sys.isapple() ? begin
addr = ccall((:valloc, "libSystem.dylib"), Ptr{T}, (Csize_t,), size_bytes)
end : throw(SystemError())

Expand All @@ -66,13 +66,13 @@ 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.is_windows() ? begin
@static Compat.Sys.iswindows() ? begin
MEM_RELEASE = 0x8000
return ccall((:VirtualFree, "Kernel32"), Cint, (Ptr{Void}, Csize_t, Culong),
addr, 0, MEM_RELEASE)
end : @static Compat.Sys.is_linux() ? begin
return ccall((:free, "libc"), Void, (Ptr{Void},), addr)
end : @static Compat.Sys.is_apple() ? begin
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 : error("OS not supported")
end
Expand Down

0 comments on commit a554245

Please sign in to comment.