Skip to content

Commit

Permalink
add dlopen_e
Browse files Browse the repository at this point in the history
  • Loading branch information
nolta committed Mar 20, 2013
1 parent 5c1089c commit b6ea285
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
5 changes: 3 additions & 2 deletions base/c.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ const RTLD_NOLOAD = 0x00000010
const RTLD_DEEPBIND = 0x00000020
const RTLD_FIRST = 0x00000040

dlsym(hnd, s::String) = ccall(:jl_dlsym, Ptr{Void}, (Ptr{Void}, Ptr{Uint8}), hnd, s)
dlsym(hnd, s::Symbol) = ccall(:jl_dlsym, Ptr{Void}, (Ptr{Void}, Ptr{Uint8}), hnd, s)
dlsym(hnd, s::Union(Symbol,String)) = ccall(:jl_dlsym, Ptr{Void}, (Ptr{Void}, Ptr{Uint8}), hnd, s)
dlsym_e(hnd, s::Union(Symbol,String)) = ccall(:jl_dlsym_e, Ptr{Void}, (Ptr{Void}, Ptr{Uint8}), hnd, s)
dlopen(s::String, flags::Integer) = ccall(:jl_load_dynamic_library, Ptr{Void}, (Ptr{Uint8},Uint32), s, flags)
dlopen_e(s::String, flags::Integer) = ccall(:jl_load_dynamic_library_e, Ptr{Void}, (Ptr{Uint8},Uint32), s, flags)
dlopen(s::String) = dlopen(s, RTLD_LAZY | RTLD_DEEPBIND)
dlopen_e(s::String) = dlopen_e(s, RTLD_LAZY | RTLD_DEEPBIND)
dlclose(p::Ptr) = ccall(:uv_dlclose,Void,(Ptr{Void},),p)

cfunction(f::Function, r, a) =
Expand Down
1 change: 1 addition & 0 deletions base/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1124,6 +1124,7 @@ export
# C interface
c_free,
dlopen,
dlopen_e,
dlclose,
dlsym,
dlsym_e,
Expand Down
18 changes: 15 additions & 3 deletions src/dlload.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ int jl_uv_dlopen(const char* filename, uv_lib_t* lib, unsigned flags)
#endif
}

uv_lib_t *jl_load_dynamic_library(char *modname, unsigned flags)
uv_lib_t *jl_load_dynamic_library_(char *modname, unsigned flags, int throw_err)
{
int error;
char *ext;
Expand Down Expand Up @@ -112,15 +112,27 @@ uv_lib_t *jl_load_dynamic_library(char *modname, unsigned flags)
if (!error) goto done;
#endif

//JL_PRINTF(JL_STDERR, "could not load module %s (%d): %s\n", modname, error, uv_dlerror(handle));
jl_errorf("could not load module %s: %s", modname, uv_dlerror(handle));
if (throw_err) {
//JL_PRINTF(JL_STDERR, "could not load module %s (%d): %s\n", modname, error, uv_dlerror(handle));
jl_errorf("could not load module %s: %s", modname, uv_dlerror(handle));
}
uv_dlclose(handle);
free(handle);
return NULL;
done:
return handle;
}

uv_lib_t *jl_load_dynamic_library_e(char *modname, unsigned flags)
{
return jl_load_dynamic_library_(modname, flags, 0);
}

uv_lib_t *jl_load_dynamic_library(char *modname, unsigned flags)
{
return jl_load_dynamic_library_(modname, flags, 1);
}

void *jl_dlsym_e(uv_lib_t *handle, char *symbol)
{
void *ptr;
Expand Down
1 change: 1 addition & 0 deletions src/julia.expmap
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@
jl_load_;
jl_load;
jl_load_dynamic_library;
jl_load_dynamic_library_e;
jl_load_file_string;
jl_loaderror_type;
jl_load_file_string;
Expand Down
1 change: 1 addition & 0 deletions src/julia.h
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,7 @@ enum JL_RTLD_CONSTANT {
};
#define JL_RTLD_DEFAULT (JL_RTLD_LAZY | JL_RTLD_DEEPBIND)
DLLEXPORT uv_lib_t *jl_load_dynamic_library(char *fname, unsigned flags);
DLLEXPORT uv_lib_t *jl_load_dynamic_library_e(char *fname, unsigned flags);
DLLEXPORT void *jl_dlsym_e(uv_lib_t *handle, char *symbol);
DLLEXPORT void *jl_dlsym(uv_lib_t *handle, char *symbol);
DLLEXPORT uv_lib_t *jl_wrap_raw_dl_handle(void *handle);
Expand Down

0 comments on commit b6ea285

Please sign in to comment.