1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
pub use self::os::{RTLD_LAZY};
pub use self::os::{RTLD_NOW};
pub use self::os::{RTLD_GLOBAL};
pub use self::os::{RTLD_LOCAL};

use {NTStr, int_t, char_t, void_t};

#[cfg(target_os = "linux")]
#[path = "linux/mod.rs"]
mod os;

pub fn dlopen<T: NTStr>(file: &T, mode: int_t) -> *mut void_t {
    extern { fn dlopen(file: *const char_t, mode: int_t) -> *mut void_t; }
    unsafe { dlopen(file.as_ptr(), mode) }
}

pub fn dlclose(handle: *mut void_t) -> int_t {
    extern { fn dlclose(handle: *mut void_t) -> int_t; }
    unsafe { dlclose(handle) }
}

pub fn dlsym<T: NTStr>(handle: *mut void_t, name: &T) -> *mut void_t {
    extern { fn dlsym(handle: *mut void_t, name: *const char_t) -> *mut void_t; }
    unsafe { dlsym(handle, name.as_ptr()) }
}

pub fn dlerror() -> *mut char_t {
    extern { fn dlerror() -> *mut char_t; }
    unsafe { dlerror() }
}