Skip to content

Commit

Permalink
Merge pull request #47 from JuliaStats/jq/0.7
Browse files Browse the repository at this point in the history
0.7 compat
  • Loading branch information
quinnj authored Jan 21, 2018
2 parents f9379c0 + 3ae6e3e commit 3435e1f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
1 change: 1 addition & 0 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
julia 0.6
BinDeps 0.6.0
Compat 0.48.0
2 changes: 1 addition & 1 deletion deps/build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ if Sys.KERNEL === :Darwin && (!success(`command -v xcode-select`) || isempty(rea
"You can install them from the command line using `xcode-select --install`.")
end

using BinDeps
using BinDeps, Compat.Libdl

@BinDeps.setup

Expand Down
18 changes: 10 additions & 8 deletions src/Rmath.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ __precompile__()

module Rmath

using Compat, Compat.Random

# use dirname(@__FILE__) instead of Pkg.dir, since the latter will
# cause the package to not work if installed in some other location
depsjl = joinpath(dirname(@__FILE__), "..", "deps", "deps.jl")
Expand Down Expand Up @@ -42,33 +44,33 @@ end

function __init__()
# initialize RNG hooks
unsafe_store!(cglobal((:unif_rand_ptr,libRmath),Ptr{Void}),
unsafe_store!(cglobal((:unif_rand_ptr,libRmath),Ptr{Cvoid}),
cfunction(rand,Float64,Tuple{}))
unsafe_store!(cglobal((:norm_rand_ptr,libRmath),Ptr{Void}),
unsafe_store!(cglobal((:norm_rand_ptr,libRmath),Ptr{Cvoid}),
cfunction(randn,Float64,Tuple{}))
unsafe_store!(cglobal((:exp_rand_ptr,libRmath),Ptr{Void}),
cfunction(randexp,Float64,Tuple{}))
unsafe_store!(cglobal((:exp_rand_ptr,libRmath),Ptr{Cvoid}),
cfunction(Random.randexp,Float64,Tuple{}))
end

## Macro for deferring freeing data until GC for wilcox and signrank
macro libRmath_deferred_free(base)
libcall = Symbol(base, "_free")
func = Symbol(base, "_deferred_free")
quote
esc(quote
let gc_tracking_obj = []
global $func
function $libcall(x::Vector)
gc_tracking_obj = []
ccall(($(string(libcall)),libRmath), Void, ())
ccall(($(string(libcall)),libRmath), Cvoid, ())
end
function $func()
if !isa(gc_tracking_obj, Bool)
finalizer(gc_tracking_obj, $libcall)
@compat finalizer($libcall, gc_tracking_obj)
gc_tracking_obj = false
end
end
end
end
end)
end

## Non-ccall functions for distributions with 1 parameter and no defaults
Expand Down
5 changes: 2 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Base.Test
using Rmath
using Rmath, Compat, Compat.Test, Compat.Random

srand(124)
Random.srand(124)

function allEq(target::Vector{Float64}, current::Vector{Float64}, tolerance::Float64)
@test length(target) == length(current)
Expand Down

0 comments on commit 3435e1f

Please sign in to comment.