]> git.lizzy.rs Git - rust.git/blob - src/libstd/unstable/mod.rs
Convert most code to new inner attribute syntax.
[rust.git] / src / libstd / unstable / mod.rs
1 // Copyright 2012-2013 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 #![doc(hidden)]
12
13 use prelude::*;
14 use libc::uintptr_t;
15
16 pub mod dynamic_lib;
17
18 pub mod finally;
19 pub mod simd;
20 pub mod sync;
21 pub mod mutex;
22
23 /**
24
25 Start a new thread outside of the current runtime context and wait
26 for it to terminate.
27
28 The executing thread has no access to a task pointer and will be using
29 a normal large stack.
30 */
31 pub fn run_in_bare_thread(f: proc:Send()) {
32     use rt::thread::Thread;
33     Thread::start(f).join()
34 }
35
36 #[test]
37 fn test_run_in_bare_thread() {
38     let i = 100;
39     run_in_bare_thread(proc() {
40         assert_eq!(i, 100);
41     });
42 }
43
44 #[test]
45 fn test_run_in_bare_thread_exchange() {
46     // Does the exchange heap work without the runtime?
47     let i = ~100;
48     run_in_bare_thread(proc() {
49         assert!(i == ~100);
50     });
51 }
52
53 /// Dynamically inquire about whether we're running under V.
54 /// You should usually not use this unless your test definitely
55 /// can't run correctly un-altered. Valgrind is there to help
56 /// you notice weirdness in normal, un-doctored code paths!
57 pub fn running_on_valgrind() -> bool {
58     unsafe { rust_running_on_valgrind() != 0 }
59 }
60
61 extern {
62     fn rust_running_on_valgrind() -> uintptr_t;
63 }