]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/extern-fn-reachable.rs
doc: Update modules for containers
[rust.git] / src / test / run-pass / extern-fn-reachable.rs
1 // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // ignore-win32 dynamic_lib can read dllexported symbols only
12 // ignore-linux apparently dlsym doesn't work on program symbols?
13 // ignore-android apparently dlsym doesn't work on program symbols?
14 // ignore-freebsd apparently dlsym doesn't work on program symbols?
15
16 use std::unstable::dynamic_lib::DynamicLibrary;
17
18 #[no_mangle] pub extern "C" fn fun1() {}
19 #[no_mangle] extern "C" fn fun2() {}
20
21 mod foo {
22     #[no_mangle] pub extern "C" fn fun3() {}
23 }
24 pub mod bar {
25     #[no_mangle] pub extern "C" fn fun4() {}
26 }
27
28 #[no_mangle] pub fn fun5() {}
29
30 pub fn main() {
31     unsafe {
32         let a = DynamicLibrary::open(None).unwrap();
33         assert!(a.symbol::<int>("fun1").is_ok());
34         assert!(a.symbol::<int>("fun2").is_err());
35         assert!(a.symbol::<int>("fun3").is_err());
36         assert!(a.symbol::<int>("fun4").is_ok());
37         assert!(a.symbol::<int>("fun5").is_err());
38     }
39 }