Skip to content

Commit

Permalink
allow dlopen to handle library symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
jakebolewski committed Aug 26, 2014
1 parent 6486825 commit 47bdd14
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions base/c.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,18 @@ function dlsym_e(hnd::Ptr, s::Union(Symbol,String))
ccall(:jl_dlsym_e, Ptr{Void}, (Ptr{Void}, Ptr{Uint8}), hnd, s)
end

dlopen(s::Symbol, flags::Integer = RTLD_LAZY | RTLD_DEEPBIND) =
dlopen(string(s), flags)

dlopen(s::String, flags::Integer = RTLD_LAZY | RTLD_DEEPBIND) =
ccall(:jl_load_dynamic_library, Ptr{Void}, (Ptr{Uint8},Uint32), s, flags)

dlopen_e(s::String, flags::Integer = RTLD_LAZY | RTLD_DEEPBIND) =
ccall(:jl_load_dynamic_library_e, Ptr{Void}, (Ptr{Uint8},Uint32), s, flags)

dlopen_e(s::Symbol, flags::Integer = RTLD_LAZY | RTLD_DEEPBIND) =
dlopen_e(string(s), flags)

dlclose(p::Ptr) = if p!=C_NULL; ccall(:uv_dlclose,Void,(Ptr{Void},),p); end

cfunction(f::Function, r, a) =
Expand Down
4 changes: 2 additions & 2 deletions base/sysinfo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,9 @@ function dlpath( handle::Ptr{Void} )
return s
end

function dlpath( libname::String )
function dlpath{T<:Union(String, Symbol)}(libname::T)
handle = dlopen(libname)
path = dlpath( handle )
path = dlpath(handle)
dlclose(handle)
return path
end
Expand Down

0 comments on commit 47bdd14

Please sign in to comment.