File tree Expand file tree Collapse file tree 4 files changed +26
-80
lines changed Expand file tree Collapse file tree 4 files changed +26
-80
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,6 @@ readme = "README.mkd"
1212description = " A safer binding to platform’s dynamic library loading utilities"
1313keywords = [" dlopen" , " load" , " shared" , " dylib" ]
1414categories = [" api-bindings" ]
15- build = " build.rs"
1615
1716[target .'cfg(windows)' .dependencies .winapi ]
1817version = " 0.3"
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -220,10 +220,25 @@ impl Library {
220220 /// care about, consider using the [`Library::get_singlethreaded`] call.
221221 #[ inline( always) ]
222222 pub unsafe fn get < T > ( & self , symbol : & [ u8 ] ) -> Result < Symbol < T > , crate :: Error > {
223- #[ cfg( mtsafe_dlerror) ]
224- { self . get_singlethreaded ( symbol) }
225- #[ cfg( not( mtsafe_dlerror) ) ]
226- { self . get_impl ( symbol, || Err ( crate :: Error :: DlSymUnknown ) ) }
223+ extern crate cfg_if;
224+ cfg_if:: cfg_if! {
225+ // These targets are known to have MT-safe `dlerror`.
226+ if #[ cfg( any(
227+ target_os = "linux" ,
228+ target_os = "android" ,
229+ target_os = "openbsd" ,
230+ target_os = "macos" ,
231+ target_os = "ios" ,
232+ target_os = "solaris" ,
233+ target_os = "illumos" ,
234+ target_os = "redox" ,
235+ target_os = "fuchsia"
236+ ) ) ] {
237+ self . get_singlethreaded( symbol)
238+ } else {
239+ self . get_impl( symbol, || Err ( crate :: Error :: DlSymUnknown ) )
240+ }
241+ }
227242 }
228243
229244 /// Get a pointer to function or static variable by symbol name.
@@ -387,6 +402,8 @@ impl<T> fmt::Debug for Symbol<T> {
387402}
388403
389404// Platform specific things
405+ #[ cfg_attr( any( target_os = "linux" , target_os = "android" ) , link( name="dl" ) ) ]
406+ #[ cfg_attr( any( target_os = "freebsd" , target_os = "dragonfly" ) , link( name="c" ) ) ]
390407extern {
391408 fn dlopen ( filename : * const raw:: c_char , flags : raw:: c_int ) -> * mut raw:: c_void ;
392409 fn dlclose ( handle : * mut raw:: c_void ) -> raw:: c_int ;
Original file line number Diff line number Diff line change @@ -4,19 +4,19 @@ extern crate winapi;
44extern crate libloading;
55use libloading:: { Symbol , Library } ;
66
7- const LIBPATH : & ' static str = concat ! ( env! ( "OUT_DIR" ) , " /libtest_helpers.module") ;
7+ const LIBPATH : & ' static str = "target /libtest_helpers.module";
88
99fn make_helpers ( ) {
1010 static ONCE : :: std:: sync:: Once = :: std:: sync:: Once :: new ( ) ;
1111 ONCE . call_once ( || {
12- let rustc = option_env ! ( "RUSTC" ) . unwrap_or_else ( || { "rustc" . into ( ) } ) ;
12+ let rustc = std :: env :: var_os ( "RUSTC" ) . unwrap_or_else ( || { "rustc" . into ( ) } ) ;
1313 let mut cmd = :: std:: process:: Command :: new ( rustc) ;
1414 cmd
1515 . arg ( "src/test_helpers.rs" )
1616 . arg ( "-o" )
1717 . arg ( LIBPATH )
18- . arg ( "--target" )
19- . arg ( env ! ( "LIBLOADING_TEST_TARGET" ) )
18+ // .arg("--target")
19+ // .arg(env!("LIBLOADING_TEST_TARGET"))
2020 . arg ( "-O" ) ;
2121
2222 cmd
@@ -67,7 +67,7 @@ fn test_0_no_0() {
6767
6868#[ test]
6969fn wrong_name_fails ( ) {
70- Library :: new ( concat ! ( env! ( "OUT_DIR" ) , "/libtest_help" ) ) . err ( ) . unwrap ( ) ;
70+ Library :: new ( "target/this_location_is_definitely_non existent:^~" ) . err ( ) . unwrap ( ) ;
7171}
7272
7373#[ test]
You can’t perform that action at this time.
0 commit comments