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