From 5bd834bdb4e2c1fe6666be8c8fad41526d72e3d1 Mon Sep 17 00:00:00 2001 From: "Stephen M. Coakley" Date: Wed, 7 Sep 2016 23:48:07 -0500 Subject: Add ThreadId for comparing threads --- src/libstd/thread/mod.rs | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'src/libstd/thread') diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index d8e021bb04f..97a277e7bb4 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -165,6 +165,7 @@ use panic; use panicking; use str; use sync::{Mutex, Condvar, Arc}; +use sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT}; use sys::thread as imp; use sys_common::thread_info; use sys_common::util; @@ -524,6 +525,35 @@ pub fn park_timeout(dur: Duration) { *guard = false; } +//////////////////////////////////////////////////////////////////////////////// +// ThreadId +//////////////////////////////////////////////////////////////////////////////// + +/// A unique identifier for a running thread. +/// +/// A `ThreadId` is an opaque object that has a unique value for each thread +/// that creates one. `ThreadId`s do not correspond to a thread's system- +/// designated identifier. +#[unstable(feature = "thread_id", issue = "21507")] +#[derive(Eq, PartialEq, Copy, Clone)] +pub struct ThreadId(usize); + +impl ThreadId { + /// Returns an identifier unique to the current calling thread. + #[unstable(feature = "thread_id", issue = "21507")] + pub fn current() -> ThreadId { + static THREAD_ID_COUNT: AtomicUsize = ATOMIC_USIZE_INIT; + #[thread_local] static mut THREAD_ID: ThreadId = ThreadId(0); + + unsafe { + if THREAD_ID.0 == 0 { + THREAD_ID.0 = 1 + THREAD_ID_COUNT.fetch_add(1, Ordering::SeqCst); + } + THREAD_ID + } + } +} + //////////////////////////////////////////////////////////////////////////////// // Thread //////////////////////////////////////////////////////////////////////////////// @@ -977,6 +1007,16 @@ mod tests { thread::sleep(Duration::from_millis(2)); } + #[test] + fn test_thread_id_equal() { + assert_eq!(ThreadId::current(), ThreadId::current()); + } + + #[test] + fn test_thread_id_not_equal() { + assert!(ThreadId::current() != spawn(|| ThreadId::current()).join()); + } + // NOTE: the corresponding test for stderr is in run-pass/thread-stderr, due // to the test harness apparently interfering with stderr configuration. } -- cgit 1.4.1-3-g733a5 From 6e10e29a9702ef2fb5b1cedced4e2a72a1a81b69 Mon Sep 17 00:00:00 2001 From: "Stephen M. Coakley" Date: Thu, 8 Sep 2016 00:08:15 -0500 Subject: Fix tests --- src/libstd/thread/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/libstd/thread') diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index 97a277e7bb4..ea20c93fc26 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -1009,12 +1009,12 @@ mod tests { #[test] fn test_thread_id_equal() { - assert_eq!(ThreadId::current(), ThreadId::current()); + assert!(thread::ThreadId::current() == thread::ThreadId::current()); } #[test] fn test_thread_id_not_equal() { - assert!(ThreadId::current() != spawn(|| ThreadId::current()).join()); + assert!(thread::ThreadId::current() != thread::spawn(|| thread::ThreadId::current()).join().unwrap()); } // NOTE: the corresponding test for stderr is in run-pass/thread-stderr, due -- cgit 1.4.1-3-g733a5 From f6ab636b86c2a1acefc8b9211d8fa07195efb8a5 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 16 Sep 2016 17:50:34 +0200 Subject: Update to new macro url syntax --- src/libcore/fmt/mod.rs | 4 ++-- src/libstd/thread/mod.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/libstd/thread') diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index 66ef92928eb..ab07aa4b0c1 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -792,7 +792,7 @@ pub trait UpperExp { /// assert_eq!(output, "Hello world!"); /// ``` /// -/// Please note that using [`write!`][write_macro] might be preferrable. Example: +/// Please note that using [`write!`] might be preferrable. Example: /// /// ``` /// use std::fmt::Write; @@ -803,7 +803,7 @@ pub trait UpperExp { /// assert_eq!(output, "Hello world!"); /// ``` /// -/// [write_macro]: ../../std/macro.write!.html +/// [`write!`]: ../../std/macro.write.html #[stable(feature = "rust1", since = "1.0.0")] pub fn write(output: &mut Write, args: Arguments) -> Result { let mut formatter = Formatter { diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index d8e021bb04f..a634c8f77a4 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -151,7 +151,7 @@ //! //! [`Cell`]: ../cell/struct.Cell.html //! [`RefCell`]: ../cell/struct.RefCell.html -//! [`thread_local!`]: ../macro.thread_local!.html +//! [`thread_local!`]: ../macro.thread_local.html //! [`with`]: struct.LocalKey.html#method.with #![stable(feature = "rust1", since = "1.0.0")] -- cgit 1.4.1-3-g733a5 From 9c4a01ee9eea6fc50252f08afbf98a91270e9d5e Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Wed, 7 Sep 2016 05:34:15 +0000 Subject: Ignore lots and lots of std tests on emscripten --- src/liballoc/arc.rs | 1 + src/libcollections/linked_list.rs | 1 + src/libcollectionstest/slice.rs | 1 + src/libstd/env.rs | 3 +++ src/libstd/fs.rs | 49 +++++++++++++++++++++++++++++++++++ src/libstd/io/buffered.rs | 1 + src/libstd/io/mod.rs | 2 ++ src/libstd/io/stdio.rs | 1 + src/libstd/net/addr.rs | 3 +++ src/libstd/net/tcp.rs | 30 ++++++++++++++++++++++ src/libstd/net/udp.rs | 13 ++++++++++ src/libstd/process.rs | 17 +++++++++++++ src/libstd/rand/mod.rs | 1 + src/libstd/sync/barrier.rs | 1 + src/libstd/sync/condvar.rs | 4 +++ src/libstd/sync/mpsc/mod.rs | 52 ++++++++++++++++++++++++++++++++++++++ src/libstd/sync/mpsc/mpsc_queue.rs | 1 + src/libstd/sync/mpsc/select.rs | 11 ++++++++ src/libstd/sync/mpsc/spsc_queue.rs | 1 + src/libstd/sync/mutex.rs | 8 ++++++ src/libstd/sync/once.rs | 2 ++ src/libstd/sync/rwlock.rs | 9 +++++++ src/libstd/sys/common/io.rs | 1 + src/libstd/sys/common/remutex.rs | 3 +++ src/libstd/sys/unix/ext/net.rs | 13 ++++++++++ src/libstd/sys/unix/process.rs | 1 + src/libstd/thread/local.rs | 6 +++++ src/libstd/thread/mod.rs | 19 ++++++++++++++ 28 files changed, 255 insertions(+) (limited to 'src/libstd/thread') diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index e3c92fc1aa8..29e18781ce2 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -1000,6 +1000,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn manually_share_arc() { let v = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; let arc_v = Arc::new(v); diff --git a/src/libcollections/linked_list.rs b/src/libcollections/linked_list.rs index 690c4f4af35..67f3708a62b 100644 --- a/src/libcollections/linked_list.rs +++ b/src/libcollections/linked_list.rs @@ -1294,6 +1294,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_send() { let n = list_from(&[1, 2, 3]); thread::spawn(move || { diff --git a/src/libcollectionstest/slice.rs b/src/libcollectionstest/slice.rs index 5b341ab62d0..9580714075a 100644 --- a/src/libcollectionstest/slice.rs +++ b/src/libcollectionstest/slice.rs @@ -1116,6 +1116,7 @@ fn test_box_slice_clone() { } #[test] +#[cfg_attr(target_os = "emscripten", ignore)] fn test_box_slice_clone_panics() { use std::sync::Arc; use std::sync::atomic::{AtomicUsize, Ordering}; diff --git a/src/libstd/env.rs b/src/libstd/env.rs index 5da6e5a8b80..76a2f93c162 100644 --- a/src/libstd/env.rs +++ b/src/libstd/env.rs @@ -1033,6 +1033,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_var_big() { let mut s = "".to_string(); let mut i = 0; @@ -1046,6 +1047,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_self_exe_path() { let path = current_exe(); assert!(path.is_ok()); @@ -1056,6 +1058,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_env_set_get_huge() { let n = make_rand_name(); let s = repeat("x").take(10000).collect::(); diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index 576198564db..08d71c1d9f8 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -1745,6 +1745,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn file_test_io_smoke_test() { let message = "it's alright. have a good time"; let tmpdir = tmpdir(); @@ -1766,6 +1767,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn invalid_path_raises() { let tmpdir = tmpdir(); let filename = &tmpdir.join("file_that_does_not_exist.txt"); @@ -1780,6 +1782,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn file_test_iounlinking_invalid_path_should_raise_condition() { let tmpdir = tmpdir(); let filename = &tmpdir.join("file_another_file_that_does_not_exist.txt"); @@ -1795,6 +1798,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn file_test_io_non_positional_read() { let message: &str = "ten-four"; let mut read_mem = [0; 8]; @@ -1821,6 +1825,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn file_test_io_seek_and_tell_smoke_test() { let message = "ten-four"; let mut read_mem = [0; 4]; @@ -1848,6 +1853,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn file_test_io_seek_and_write() { let initial_msg = "food-is-yummy"; let overwrite_msg = "-the-bar!!"; @@ -1872,6 +1878,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn file_test_io_seek_shakedown() { // 01234567890123 let initial_msg = "qwer-asdf-zxcv"; @@ -1904,6 +1911,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn file_test_stat_is_correct_on_is_file() { let tmpdir = tmpdir(); let filename = &tmpdir.join("file_stat_correct_on_is_file.txt"); @@ -1925,6 +1933,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn file_test_stat_is_correct_on_is_dir() { let tmpdir = tmpdir(); let filename = &tmpdir.join("file_stat_correct_on_is_dir"); @@ -1937,6 +1946,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn file_test_fileinfo_false_when_checking_is_file_on_a_directory() { let tmpdir = tmpdir(); let dir = &tmpdir.join("fileinfo_false_on_dir"); @@ -1946,6 +1956,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn file_test_fileinfo_check_exists_before_and_after_file_creation() { let tmpdir = tmpdir(); let file = &tmpdir.join("fileinfo_check_exists_b_and_a.txt"); @@ -1956,6 +1967,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn file_test_directoryinfo_check_exists_before_and_after_mkdir() { let tmpdir = tmpdir(); let dir = &tmpdir.join("before_and_after_dir"); @@ -1968,6 +1980,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn file_test_directoryinfo_readdir() { let tmpdir = tmpdir(); let dir = &tmpdir.join("di_readdir"); @@ -1997,6 +2010,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn file_create_new_already_exists_error() { let tmpdir = tmpdir(); let file = &tmpdir.join("file_create_new_error_exists"); @@ -2006,6 +2020,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn mkdir_path_already_exists_error() { let tmpdir = tmpdir(); let dir = &tmpdir.join("mkdir_error_twice"); @@ -2015,6 +2030,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn recursive_mkdir() { let tmpdir = tmpdir(); let dir = tmpdir.join("d1/d2"); @@ -2023,6 +2039,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn recursive_mkdir_failure() { let tmpdir = tmpdir(); let dir = tmpdir.join("d1"); @@ -2037,11 +2054,13 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn recursive_mkdir_slash() { check!(fs::create_dir_all(&Path::new("/"))); } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn recursive_rmdir() { let tmpdir = tmpdir(); let d1 = tmpdir.join("d1"); @@ -2061,6 +2080,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn recursive_rmdir_of_symlink() { // test we do not recursively delete a symlink but only dirs. let tmpdir = tmpdir(); @@ -2094,6 +2114,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn unicode_path_is_dir() { assert!(Path::new(".").is_dir()); assert!(!Path::new("test/stdtest/fs.rs").is_dir()); @@ -2113,6 +2134,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn unicode_path_exists() { assert!(Path::new(".").exists()); assert!(!Path::new("test/nonexistent-bogus-path").exists()); @@ -2126,6 +2148,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn copy_file_does_not_exist() { let from = Path::new("test/nonexistent-bogus-path"); let to = Path::new("test/other-bogus-path"); @@ -2140,6 +2163,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn copy_src_does_not_exist() { let tmpdir = tmpdir(); let from = Path::new("test/nonexistent-bogus-path"); @@ -2153,6 +2177,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn copy_file_ok() { let tmpdir = tmpdir(); let input = tmpdir.join("in.txt"); @@ -2169,6 +2194,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn copy_file_dst_dir() { let tmpdir = tmpdir(); let out = tmpdir.join("out"); @@ -2180,6 +2206,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn copy_file_dst_exists() { let tmpdir = tmpdir(); let input = tmpdir.join("in"); @@ -2195,6 +2222,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn copy_file_src_dir() { let tmpdir = tmpdir(); let out = tmpdir.join("out"); @@ -2206,6 +2234,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn copy_file_preserves_perm_bits() { let tmpdir = tmpdir(); let input = tmpdir.join("in.txt"); @@ -2234,6 +2263,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn symlinks_work() { let tmpdir = tmpdir(); if !got_symlink_permission(&tmpdir) { return }; @@ -2252,6 +2282,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn symlink_noexist() { // Symlinks can point to things that don't exist let tmpdir = tmpdir(); @@ -2265,6 +2296,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn read_link() { if cfg!(windows) { // directory symlink @@ -2285,6 +2317,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn readlink_not_symlink() { let tmpdir = tmpdir(); match fs::read_link(tmpdir.path()) { @@ -2294,6 +2327,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn links_work() { let tmpdir = tmpdir(); let input = tmpdir.join("in.txt"); @@ -2322,6 +2356,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn chmod_works() { let tmpdir = tmpdir(); let file = tmpdir.join("in.txt"); @@ -2345,6 +2380,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn sync_doesnt_kill_anything() { let tmpdir = tmpdir(); let path = tmpdir.join("in.txt"); @@ -2358,6 +2394,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn truncate_works() { let tmpdir = tmpdir(); let path = tmpdir.join("in.txt"); @@ -2392,6 +2429,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn open_flavors() { use fs::OpenOptions as OO; fn c(t: &T) -> T { t.clone() } @@ -2511,6 +2549,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn binary_file() { let mut bytes = [0; 1024]; StdRng::new().unwrap().fill_bytes(&mut bytes); @@ -2524,6 +2563,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn file_try_clone() { let tmpdir = tmpdir(); @@ -2546,6 +2586,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] #[cfg(not(windows))] fn unlink_readonly() { let tmpdir = tmpdir(); @@ -2558,6 +2599,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn mkdir_trailing_slash() { let tmpdir = tmpdir(); let path = tmpdir.join("file"); @@ -2565,6 +2607,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn canonicalize_works_simple() { let tmpdir = tmpdir(); let tmpdir = fs::canonicalize(tmpdir.path()).unwrap(); @@ -2574,6 +2617,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn realpath_works() { let tmpdir = tmpdir(); if !got_symlink_permission(&tmpdir) { return }; @@ -2599,6 +2643,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn realpath_works_tricky() { let tmpdir = tmpdir(); if !got_symlink_permission(&tmpdir) { return }; @@ -2628,6 +2673,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn dir_entry_methods() { let tmpdir = tmpdir(); @@ -2662,12 +2708,14 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn read_dir_not_found() { let res = fs::read_dir("/path/that/does/not/exist"); assert_eq!(res.err().unwrap().kind(), ErrorKind::NotFound); } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn create_dir_all_with_junctions() { let tmpdir = tmpdir(); let target = tmpdir.join("target"); @@ -2695,6 +2743,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn metadata_access_times() { let tmpdir = tmpdir(); diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs index 4ff8c6ac128..21a0cc1fb3b 100644 --- a/src/libstd/io/buffered.rs +++ b/src/libstd/io/buffered.rs @@ -1107,6 +1107,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn panic_in_write_doesnt_flush_in_drop() { static WRITES: AtomicUsize = AtomicUsize::new(0); diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index 0de02cbf19c..2ba2e8de71b 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -1761,6 +1761,7 @@ mod tests { use super::repeat; #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn read_until() { let mut buf = Cursor::new(&b"12"[..]); let mut v = Vec::new(); @@ -1971,6 +1972,7 @@ mod tests { } #[bench] + #[cfg_attr(target_os = "emscripten", ignore)] fn bench_read_to_end(b: &mut test::Bencher) { b.iter(|| { let mut lr = repeat(1).take(10000000); diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs index 9a782e95f6e..89cb9909956 100644 --- a/src/libstd/io/stdio.rs +++ b/src/libstd/io/stdio.rs @@ -668,6 +668,7 @@ mod tests { use super::*; #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn panic_doesnt_poison() { thread::spawn(|| { let _a = stdin(); diff --git a/src/libstd/net/addr.rs b/src/libstd/net/addr.rs index d0b59b42c17..930f2c721a7 100644 --- a/src/libstd/net/addr.rs +++ b/src/libstd/net/addr.rs @@ -533,6 +533,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn to_socket_addr_str_u16() { let a = sa4(Ipv4Addr::new(77, 88, 21, 11), 24352); assert_eq!(Ok(vec![a]), tsa(("77.88.21.11", 24352))); @@ -545,6 +546,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn to_socket_addr_str() { let a = sa4(Ipv4Addr::new(77, 88, 21, 11), 24352); assert_eq!(Ok(vec![a]), tsa("77.88.21.11:24352")); @@ -559,6 +561,7 @@ mod tests { // FIXME: figure out why this fails on openbsd and bitrig and fix it #[test] #[cfg(not(any(windows, target_os = "openbsd", target_os = "bitrig")))] + #[cfg_attr(target_os = "emscripten", ignore)] fn to_socket_addr_str_bad() { assert!(tsa("1200::AB00:1234::2552:7777:1313:34300").is_err()); } diff --git a/src/libstd/net/tcp.rs b/src/libstd/net/tcp.rs index 3c5f07c3e33..d34fce2be43 100644 --- a/src/libstd/net/tcp.rs +++ b/src/libstd/net/tcp.rs @@ -454,6 +454,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn bind_error() { match TcpListener::bind("1.1.1.1:9999") { Ok(..) => panic!(), @@ -463,6 +464,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn connect_error() { match TcpStream::connect("0.0.0.0:1") { Ok(..) => panic!(), @@ -475,6 +477,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn listen_localhost() { let socket_addr = next_test_ip4(); let listener = t!(TcpListener::bind(&socket_addr)); @@ -492,6 +495,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn connect_loopback() { each_ip(&mut |addr| { let acceptor = t!(TcpListener::bind(&addr)); @@ -513,6 +517,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn smoke_test() { each_ip(&mut |addr| { let acceptor = t!(TcpListener::bind(&addr)); @@ -533,6 +538,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn read_eof() { each_ip(&mut |addr| { let acceptor = t!(TcpListener::bind(&addr)); @@ -552,6 +558,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn write_close() { each_ip(&mut |addr| { let acceptor = t!(TcpListener::bind(&addr)); @@ -578,6 +585,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn multiple_connect_serial() { each_ip(&mut |addr| { let max = 10; @@ -600,6 +608,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn multiple_connect_interleaved_greedy_schedule() { const MAX: usize = 10; each_ip(&mut |addr| { @@ -635,6 +644,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn multiple_connect_interleaved_lazy_schedule() { const MAX: usize = 10; each_ip(&mut |addr| { @@ -668,6 +678,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn socket_and_peer_name() { each_ip(&mut |addr| { let listener = t!(TcpListener::bind(&addr)); @@ -683,6 +694,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn partial_read() { each_ip(&mut |addr| { let (tx, rx) = channel(); @@ -704,6 +716,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn double_bind() { each_ip(&mut |addr| { let _listener = t!(TcpListener::bind(&addr)); @@ -720,6 +733,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn fast_rebind() { each_ip(&mut |addr| { let acceptor = t!(TcpListener::bind(&addr)); @@ -735,6 +749,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn tcp_clone_smoke() { each_ip(&mut |addr| { let acceptor = t!(TcpListener::bind(&addr)); @@ -766,6 +781,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn tcp_clone_two_read() { each_ip(&mut |addr| { let acceptor = t!(TcpListener::bind(&addr)); @@ -800,6 +816,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn tcp_clone_two_write() { each_ip(&mut |addr| { let acceptor = t!(TcpListener::bind(&addr)); @@ -827,6 +844,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn shutdown_smoke() { each_ip(&mut |addr| { let a = t!(TcpListener::bind(&addr)); @@ -847,6 +865,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn close_readwrite_smoke() { each_ip(&mut |addr| { let a = t!(TcpListener::bind(&addr)); @@ -885,6 +904,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn close_read_wakes_up() { each_ip(&mut |addr| { let a = t!(TcpListener::bind(&addr)); @@ -912,6 +932,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn clone_while_reading() { each_ip(&mut |addr| { let accept = t!(TcpListener::bind(&addr)); @@ -952,6 +973,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn clone_accept_smoke() { each_ip(&mut |addr| { let a = t!(TcpListener::bind(&addr)); @@ -970,6 +992,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn clone_accept_concurrent() { each_ip(&mut |addr| { let a = t!(TcpListener::bind(&addr)); @@ -998,6 +1021,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn debug() { let name = if cfg!(windows) {"socket"} else {"fd"}; let socket_addr = next_test_ip4(); @@ -1024,6 +1048,7 @@ mod tests { // no longer has rounding errors. #[cfg_attr(any(target_os = "bitrig", target_os = "netbsd", target_os = "openbsd"), ignore)] #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn timeouts() { let addr = next_test_ip4(); let listener = t!(TcpListener::bind(&addr)); @@ -1050,6 +1075,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_read_timeout() { let addr = next_test_ip4(); let listener = t!(TcpListener::bind(&addr)); @@ -1066,6 +1092,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_read_with_timeout() { let addr = next_test_ip4(); let listener = t!(TcpListener::bind(&addr)); @@ -1088,6 +1115,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn nodelay() { let addr = next_test_ip4(); let _listener = t!(TcpListener::bind(&addr)); @@ -1102,6 +1130,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn ttl() { let ttl = 100; @@ -1118,6 +1147,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn set_nonblocking() { let addr = next_test_ip4(); let listener = t!(TcpListener::bind(&addr)); diff --git a/src/libstd/net/udp.rs b/src/libstd/net/udp.rs index 781f026c12c..7315b6aaeb6 100644 --- a/src/libstd/net/udp.rs +++ b/src/libstd/net/udp.rs @@ -378,6 +378,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn bind_error() { match UdpSocket::bind("1.1.1.1:9999") { Ok(..) => panic!(), @@ -388,6 +389,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn socket_smoke_test_ip4() { each_ip(&mut |server_ip, client_ip| { let (tx1, rx1) = channel(); @@ -412,6 +414,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn socket_name_ip4() { each_ip(&mut |addr, _| { let server = t!(UdpSocket::bind(&addr)); @@ -420,6 +423,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn udp_clone_smoke() { each_ip(&mut |addr1, addr2| { let sock1 = t!(UdpSocket::bind(&addr1)); @@ -449,6 +453,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn udp_clone_two_read() { each_ip(&mut |addr1, addr2| { let sock1 = t!(UdpSocket::bind(&addr1)); @@ -481,6 +486,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn udp_clone_two_write() { each_ip(&mut |addr1, addr2| { let sock1 = t!(UdpSocket::bind(&addr1)); @@ -519,6 +525,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn debug() { let name = if cfg!(windows) {"socket"} else {"fd"}; let socket_addr = next_test_ip4(); @@ -534,6 +541,7 @@ mod tests { // no longer has rounding errors. #[cfg_attr(any(target_os = "bitrig", target_os = "netbsd", target_os = "openbsd"), ignore)] #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn timeouts() { let addr = next_test_ip4(); @@ -558,6 +566,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_read_timeout() { let addr = next_test_ip4(); @@ -573,6 +582,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_read_with_timeout() { let addr = next_test_ip4(); @@ -592,6 +602,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn connect_send_recv() { let addr = next_test_ip4(); @@ -606,6 +617,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn ttl() { let ttl = 100; @@ -618,6 +630,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn set_nonblocking() { let addr = next_test_ip4(); diff --git a/src/libstd/process.rs b/src/libstd/process.rs index f0c44430700..233a4d3639c 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -819,6 +819,7 @@ mod tests { #[test] #[cfg_attr(target_os = "android", ignore)] + #[cfg_attr(target_os = "emscripten", ignore)] fn smoke() { let p = Command::new("true").spawn(); assert!(p.is_ok()); @@ -837,6 +838,7 @@ mod tests { #[test] #[cfg_attr(target_os = "android", ignore)] + #[cfg_attr(target_os = "emscripten", ignore)] fn exit_reported_right() { let p = Command::new("false").spawn(); assert!(p.is_ok()); @@ -848,6 +850,7 @@ mod tests { #[test] #[cfg(unix)] #[cfg_attr(target_os = "android", ignore)] + #[cfg_attr(target_os = "emscripten", ignore)] fn signal_reported_right() { use os::unix::process::ExitStatusExt; @@ -876,6 +879,7 @@ mod tests { #[test] #[cfg_attr(target_os = "android", ignore)] + #[cfg_attr(target_os = "emscripten", ignore)] fn stdout_works() { let mut cmd = Command::new("echo"); cmd.arg("foobar").stdout(Stdio::piped()); @@ -884,6 +888,7 @@ mod tests { #[test] #[cfg_attr(any(windows, target_os = "android"), ignore)] + #[cfg_attr(target_os = "emscripten", ignore)] fn set_current_dir_works() { let mut cmd = Command::new("/bin/sh"); cmd.arg("-c").arg("pwd") @@ -894,6 +899,7 @@ mod tests { #[test] #[cfg_attr(any(windows, target_os = "android"), ignore)] + #[cfg_attr(target_os = "emscripten", ignore)] fn stdin_works() { let mut p = Command::new("/bin/sh") .arg("-c").arg("read line; echo $line") @@ -912,6 +918,7 @@ mod tests { #[test] #[cfg_attr(target_os = "android", ignore)] #[cfg(unix)] + #[cfg_attr(target_os = "emscripten", ignore)] fn uid_works() { use os::unix::prelude::*; use libc; @@ -938,6 +945,7 @@ mod tests { #[test] #[cfg_attr(target_os = "android", ignore)] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_process_status() { let mut status = Command::new("false").status().unwrap(); assert!(status.code() == Some(1)); @@ -947,6 +955,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_process_output_fail_to_start() { match Command::new("/no-binary-by-this-name-should-exist").output() { Err(e) => assert_eq!(e.kind(), ErrorKind::NotFound), @@ -956,6 +965,7 @@ mod tests { #[test] #[cfg_attr(target_os = "android", ignore)] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_process_output_output() { let Output {status, stdout, stderr} = Command::new("echo").arg("hello").output().unwrap(); @@ -968,6 +978,7 @@ mod tests { #[test] #[cfg_attr(target_os = "android", ignore)] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_process_output_error() { let Output {status, stdout, stderr} = Command::new("mkdir").arg(".").output().unwrap(); @@ -979,6 +990,7 @@ mod tests { #[test] #[cfg_attr(target_os = "android", ignore)] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_finish_once() { let mut prog = Command::new("false").spawn().unwrap(); assert!(prog.wait().unwrap().code() == Some(1)); @@ -986,6 +998,7 @@ mod tests { #[test] #[cfg_attr(target_os = "android", ignore)] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_finish_twice() { let mut prog = Command::new("false").spawn().unwrap(); assert!(prog.wait().unwrap().code() == Some(1)); @@ -994,6 +1007,7 @@ mod tests { #[test] #[cfg_attr(target_os = "android", ignore)] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_wait_with_output_once() { let prog = Command::new("echo").arg("hello").stdout(Stdio::piped()) .spawn().unwrap(); @@ -1024,6 +1038,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_inherit_env() { use env; @@ -1049,6 +1064,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_override_env() { use env; @@ -1069,6 +1085,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_add_to_env() { let result = env_cmd().env("RUN_TEST_NEW_ENV", "123").output().unwrap(); let output = String::from_utf8_lossy(&result.stdout).to_string(); diff --git a/src/libstd/rand/mod.rs b/src/libstd/rand/mod.rs index 3f14fcd239f..69cd37651d5 100644 --- a/src/libstd/rand/mod.rs +++ b/src/libstd/rand/mod.rs @@ -242,6 +242,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_os_rng_tasks() { let mut txs = vec!(); diff --git a/src/libstd/sync/barrier.rs b/src/libstd/sync/barrier.rs index ac0f400379e..f46eab68484 100644 --- a/src/libstd/sync/barrier.rs +++ b/src/libstd/sync/barrier.rs @@ -118,6 +118,7 @@ mod tests { use thread; #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_barrier() { const N: usize = 10; diff --git a/src/libstd/sync/condvar.rs b/src/libstd/sync/condvar.rs index 3db8b05b954..a983ae716a4 100644 --- a/src/libstd/sync/condvar.rs +++ b/src/libstd/sync/condvar.rs @@ -270,6 +270,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn notify_one() { let m = Arc::new(Mutex::new(())); let m2 = m.clone(); @@ -286,6 +287,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn notify_all() { const N: usize = 10; @@ -322,6 +324,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn wait_timeout_ms() { let m = Arc::new(Mutex::new(())); let m2 = m.clone(); @@ -343,6 +346,7 @@ mod tests { #[test] #[should_panic] + #[cfg_attr(target_os = "emscripten", ignore)] fn two_mutexes() { let m = Arc::new(Mutex::new(())); let m2 = m.clone(); diff --git a/src/libstd/sync/mpsc/mod.rs b/src/libstd/sync/mpsc/mod.rs index 3d9f81413dc..b8101ae85cf 100644 --- a/src/libstd/sync/mpsc/mod.rs +++ b/src/libstd/sync/mpsc/mod.rs @@ -1314,6 +1314,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn smoke_threads() { let (tx, rx) = channel::(); let _t = thread::spawn(move|| { @@ -1346,6 +1347,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn port_gone_concurrent() { let (tx, rx) = channel::(); let _t = thread::spawn(move|| { @@ -1355,6 +1357,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn port_gone_concurrent_shared() { let (tx, rx) = channel::(); let tx2 = tx.clone(); @@ -1381,6 +1384,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn chan_gone_concurrent() { let (tx, rx) = channel::(); let _t = thread::spawn(move|| { @@ -1391,6 +1395,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn stress() { let (tx, rx) = channel::(); let t = thread::spawn(move|| { @@ -1403,6 +1408,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn stress_shared() { const AMT: u32 = 10000; const NTHREADS: u32 = 8; @@ -1429,6 +1435,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn send_from_outside_runtime() { let (tx1, rx1) = channel::<()>(); let (tx2, rx2) = channel::(); @@ -1449,6 +1456,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn recv_from_outside_runtime() { let (tx, rx) = channel::(); let t = thread::spawn(move|| { @@ -1463,6 +1471,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn no_runtime() { let (tx1, rx1) = channel::(); let (tx2, rx2) = channel::(); @@ -1501,6 +1510,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn oneshot_single_thread_recv_chan_close() { // Receiving on a closed chan will panic let res = thread::spawn(move|| { @@ -1570,6 +1580,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn oneshot_multi_task_recv_then_send() { let (tx, rx) = channel::>(); let _t = thread::spawn(move|| { @@ -1580,6 +1591,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn oneshot_multi_task_recv_then_close() { let (tx, rx) = channel::>(); let _t = thread::spawn(move|| { @@ -1592,6 +1604,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn oneshot_multi_thread_close_stress() { for _ in 0..stress_factor() { let (tx, rx) = channel::(); @@ -1603,6 +1616,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn oneshot_multi_thread_send_close_stress() { for _ in 0..stress_factor() { let (tx, rx) = channel::(); @@ -1616,6 +1630,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn oneshot_multi_thread_recv_close_stress() { for _ in 0..stress_factor() { let (tx, rx) = channel::(); @@ -1634,6 +1649,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn oneshot_multi_thread_send_recv_stress() { for _ in 0..stress_factor() { let (tx, rx) = channel::>(); @@ -1645,6 +1661,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn stream_send_recv_stress() { for _ in 0..stress_factor() { let (tx, rx) = channel(); @@ -1683,6 +1700,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn stress_recv_timeout_two_threads() { let (tx, rx) = channel(); let stress = stress_factor() + 100; @@ -1724,6 +1742,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn stress_recv_timeout_shared() { let (tx, rx) = channel(); let stress = stress_factor() + 100; @@ -1762,6 +1781,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn shared_recv_timeout() { let (tx, rx) = channel(); let total = 5; @@ -1780,6 +1800,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn shared_chan_stress() { let (tx, rx) = channel(); let total = stress_factor() + 100; @@ -1796,6 +1817,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_nested_recv_iter() { let (tx, rx) = channel::(); let (total_tx, total_rx) = channel::(); @@ -1816,6 +1838,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_recv_iter_break() { let (tx, rx) = channel::(); let (count_tx, count_rx) = channel(); @@ -1841,6 +1864,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_recv_try_iter() { let (request_tx, request_rx) = channel(); let (response_tx, response_rx) = channel(); @@ -1895,6 +1919,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn try_recv_states() { let (tx1, rx1) = channel::(); let (tx2, rx2) = channel::<()>(); @@ -1921,6 +1946,7 @@ mod tests { // This bug used to end up in a livelock inside of the Receiver destructor // because the internal state of the Shared packet was corrupted #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn destroy_upgraded_shared_port_when_sender_still_active() { let (tx, rx) = channel(); let (tx2, rx2) = channel(); @@ -1988,6 +2014,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn smoke_threads() { let (tx, rx) = sync_channel::(0); let _t = thread::spawn(move|| { @@ -2013,6 +2040,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn port_gone_concurrent() { let (tx, rx) = sync_channel::(0); let _t = thread::spawn(move|| { @@ -2022,6 +2050,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn port_gone_concurrent_shared() { let (tx, rx) = sync_channel::(0); let tx2 = tx.clone(); @@ -2048,6 +2077,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn chan_gone_concurrent() { let (tx, rx) = sync_channel::(0); thread::spawn(move|| { @@ -2058,6 +2088,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn stress() { let (tx, rx) = sync_channel::(0); thread::spawn(move|| { @@ -2069,6 +2100,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn stress_recv_timeout_two_threads() { let (tx, rx) = sync_channel::(0); @@ -2092,6 +2124,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn stress_recv_timeout_shared() { const AMT: u32 = 1000; const NTHREADS: u32 = 8; @@ -2130,6 +2163,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn stress_shared() { const AMT: u32 = 1000; const NTHREADS: u32 = 8; @@ -2180,6 +2214,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn oneshot_single_thread_recv_chan_close() { // Receiving on a closed chan will panic let res = thread::spawn(move|| { @@ -2264,6 +2299,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn oneshot_multi_task_recv_then_send() { let (tx, rx) = sync_channel::>(0); let _t = thread::spawn(move|| { @@ -2274,6 +2310,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn oneshot_multi_task_recv_then_close() { let (tx, rx) = sync_channel::>(0); let _t = thread::spawn(move|| { @@ -2286,6 +2323,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn oneshot_multi_thread_close_stress() { for _ in 0..stress_factor() { let (tx, rx) = sync_channel::(0); @@ -2297,6 +2335,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn oneshot_multi_thread_send_close_stress() { for _ in 0..stress_factor() { let (tx, rx) = sync_channel::(0); @@ -2310,6 +2349,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn oneshot_multi_thread_recv_close_stress() { for _ in 0..stress_factor() { let (tx, rx) = sync_channel::(0); @@ -2328,6 +2368,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn oneshot_multi_thread_send_recv_stress() { for _ in 0..stress_factor() { let (tx, rx) = sync_channel::>(0); @@ -2339,6 +2380,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn stream_send_recv_stress() { for _ in 0..stress_factor() { let (tx, rx) = sync_channel::>(0); @@ -2375,6 +2417,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn shared_chan_stress() { let (tx, rx) = sync_channel(0); let total = stress_factor() + 100; @@ -2391,6 +2434,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_nested_recv_iter() { let (tx, rx) = sync_channel::(0); let (total_tx, total_rx) = sync_channel::(0); @@ -2411,6 +2455,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_recv_iter_break() { let (tx, rx) = sync_channel::(0); let (count_tx, count_rx) = sync_channel(0); @@ -2436,6 +2481,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn try_recv_states() { let (tx1, rx1) = sync_channel::(1); let (tx2, rx2) = sync_channel::<()>(1); @@ -2462,6 +2508,7 @@ mod sync_tests { // This bug used to end up in a livelock inside of the Receiver destructor // because the internal state of the Shared packet was corrupted #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn destroy_upgraded_shared_port_when_sender_still_active() { let (tx, rx) = sync_channel::<()>(0); let (tx2, rx2) = sync_channel::<()>(0); @@ -2483,6 +2530,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn send1() { let (tx, rx) = sync_channel::(0); let _t = thread::spawn(move|| { rx.recv().unwrap(); }); @@ -2490,6 +2538,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn send2() { let (tx, rx) = sync_channel::(0); let _t = thread::spawn(move|| { drop(rx); }); @@ -2497,6 +2546,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn send3() { let (tx, rx) = sync_channel::(1); assert_eq!(tx.send(1), Ok(())); @@ -2505,6 +2555,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn send4() { let (tx, rx) = sync_channel::(0); let tx2 = tx.clone(); @@ -2545,6 +2596,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn issue_15761() { fn repro() { let (tx1, rx1) = sync_channel::<()>(3); diff --git a/src/libstd/sync/mpsc/mpsc_queue.rs b/src/libstd/sync/mpsc/mpsc_queue.rs index d926043fbbc..2ff9ffe6d08 100644 --- a/src/libstd/sync/mpsc/mpsc_queue.rs +++ b/src/libstd/sync/mpsc/mpsc_queue.rs @@ -161,6 +161,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test() { let nthreads = 8; let nmsgs = 1000; diff --git a/src/libstd/sync/mpsc/select.rs b/src/libstd/sync/mpsc/select.rs index 51b08bd75c4..3058282edf3 100644 --- a/src/libstd/sync/mpsc/select.rs +++ b/src/libstd/sync/mpsc/select.rs @@ -444,6 +444,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn unblocks() { let (tx1, rx1) = channel::(); let (_tx2, rx2) = channel::(); @@ -468,6 +469,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn both_ready() { let (tx1, rx1) = channel::(); let (tx2, rx2) = channel::(); @@ -494,6 +496,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn stress() { const AMT: i32 = 10000; let (tx1, rx1) = channel::(); @@ -521,6 +524,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn cloning() { let (tx1, rx1) = channel::(); let (_tx2, rx2) = channel::(); @@ -543,6 +547,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn cloning2() { let (tx1, rx1) = channel::(); let (_tx2, rx2) = channel::(); @@ -565,6 +570,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn cloning3() { let (tx1, rx1) = channel::<()>(); let (tx2, rx2) = channel::<()>(); @@ -682,6 +688,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn oneshot_data_waiting() { let (tx1, rx1) = channel(); let (tx2, rx2) = channel(); @@ -698,6 +705,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn stream_data_waiting() { let (tx1, rx1) = channel(); let (tx2, rx2) = channel(); @@ -718,6 +726,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn shared_data_waiting() { let (tx1, rx1) = channel(); let (tx2, rx2) = channel(); @@ -746,6 +755,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn sync2() { let (tx, rx) = sync_channel::(0); let _t = thread::spawn(move|| { @@ -758,6 +768,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn sync3() { let (tx1, rx1) = sync_channel::(0); let (tx2, rx2): (Sender, Receiver) = channel(); diff --git a/src/libstd/sync/mpsc/spsc_queue.rs b/src/libstd/sync/mpsc/spsc_queue.rs index 724d7b1be73..cb9577f155e 100644 --- a/src/libstd/sync/mpsc/spsc_queue.rs +++ b/src/libstd/sync/mpsc/spsc_queue.rs @@ -305,6 +305,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn stress() { unsafe { stress_bound(0); diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs index 098a3e44258..07d60f0610f 100644 --- a/src/libstd/sync/mutex.rs +++ b/src/libstd/sync/mutex.rs @@ -375,6 +375,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn lots_and_lots() { const J: u32 = 1000; const K: u32 = 3; @@ -435,6 +436,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_into_inner_poison() { let m = Arc::new(Mutex::new(NonCopy(10))); let m2 = m.clone(); @@ -458,6 +460,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_get_mut_poison() { let m = Arc::new(Mutex::new(NonCopy(10))); let m2 = m.clone(); @@ -474,6 +477,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_mutex_arc_condvar() { let packet = Packet(Arc::new((Mutex::new(false), Condvar::new()))); let packet2 = Packet(packet.0.clone()); @@ -497,6 +501,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_arc_condvar_poison() { let packet = Packet(Arc::new((Mutex::new(1), Condvar::new()))); let packet2 = Packet(packet.0.clone()); @@ -526,6 +531,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_mutex_arc_poison() { let arc = Arc::new(Mutex::new(1)); assert!(!arc.is_poisoned()); @@ -539,6 +545,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_mutex_arc_nested() { // Tests nested mutexes and access // to underlying data. @@ -555,6 +562,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_mutex_arc_access_in_unwind() { let arc = Arc::new(Mutex::new(1)); let arc2 = arc.clone(); diff --git a/src/libstd/sync/once.rs b/src/libstd/sync/once.rs index 86d2986959c..64c3e2bb42f 100644 --- a/src/libstd/sync/once.rs +++ b/src/libstd/sync/once.rs @@ -385,6 +385,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn stampede_once() { static O: Once = Once::new(); static mut run: bool = false; @@ -447,6 +448,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn wait_for_force_to_finish() { static O: Once = Once::new(); diff --git a/src/libstd/sync/rwlock.rs b/src/libstd/sync/rwlock.rs index 7f053c6704b..cb46b694f37 100644 --- a/src/libstd/sync/rwlock.rs +++ b/src/libstd/sync/rwlock.rs @@ -403,6 +403,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn frob() { const N: usize = 10; const M: usize = 1000; @@ -430,6 +431,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_rw_arc_poison_wr() { let arc = Arc::new(RwLock::new(1)); let arc2 = arc.clone(); @@ -441,6 +443,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_rw_arc_poison_ww() { let arc = Arc::new(RwLock::new(1)); assert!(!arc.is_poisoned()); @@ -454,6 +457,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_rw_arc_no_poison_rr() { let arc = Arc::new(RwLock::new(1)); let arc2 = arc.clone(); @@ -465,6 +469,7 @@ mod tests { assert_eq!(*lock, 1); } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_rw_arc_no_poison_rw() { let arc = Arc::new(RwLock::new(1)); let arc2 = arc.clone(); @@ -477,6 +482,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_rw_arc() { let arc = Arc::new(RwLock::new(0)); let arc2 = arc.clone(); @@ -515,6 +521,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_rw_arc_access_in_unwind() { let arc = Arc::new(RwLock::new(1)); let arc2 = arc.clone(); @@ -587,6 +594,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_into_inner_poison() { let m = Arc::new(RwLock::new(NonCopy(10))); let m2 = m.clone(); @@ -610,6 +618,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_get_mut_poison() { let m = Arc::new(RwLock::new(NonCopy(10))); let m2 = m.clone(); diff --git a/src/libstd/sys/common/io.rs b/src/libstd/sys/common/io.rs index 3cd70eddb85..2778ed9326c 100644 --- a/src/libstd/sys/common/io.rs +++ b/src/libstd/sys/common/io.rs @@ -165,6 +165,7 @@ mod tests { } #[bench] + #[cfg_attr(target_os = "emscripten", ignore)] fn bench_uninitialized(b: &mut ::test::Bencher) { b.iter(|| { let mut lr = repeat(1).take(10000000); diff --git a/src/libstd/sys/common/remutex.rs b/src/libstd/sys/common/remutex.rs index cbdeaad7f6b..4935afe6afc 100644 --- a/src/libstd/sys/common/remutex.rs +++ b/src/libstd/sys/common/remutex.rs @@ -181,6 +181,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn is_mutex() { let m = Arc::new(ReentrantMutex::new(RefCell::new(0))); let m2 = m.clone(); @@ -198,6 +199,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn trylock_works() { let m = Arc::new(ReentrantMutex::new(())); let m2 = m.clone(); @@ -218,6 +220,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn poison_works() { let m = Arc::new(ReentrantMutex::new(RefCell::new(0))); let mc = m.clone(); diff --git a/src/libstd/sys/unix/ext/net.rs b/src/libstd/sys/unix/ext/net.rs index 3f93fce1935..8224696db2f 100644 --- a/src/libstd/sys/unix/ext/net.rs +++ b/src/libstd/sys/unix/ext/net.rs @@ -806,6 +806,7 @@ mod test { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn basic() { let dir = tmpdir(); let socket_path = dir.path().join("sock"); @@ -834,6 +835,7 @@ mod test { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn pair() { let msg1 = b"hello"; let msg2 = b"world!"; @@ -857,6 +859,7 @@ mod test { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn try_clone() { let dir = tmpdir(); let socket_path = dir.path().join("sock"); @@ -883,6 +886,7 @@ mod test { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn iter() { let dir = tmpdir(); let socket_path = dir.path().join("sock"); @@ -905,6 +909,7 @@ mod test { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn long_path() { let dir = tmpdir(); let socket_path = dir.path() @@ -930,6 +935,7 @@ mod test { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn timeouts() { let dir = tmpdir(); let socket_path = dir.path().join("sock"); @@ -957,6 +963,7 @@ mod test { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_read_timeout() { let dir = tmpdir(); let socket_path = dir.path().join("sock"); @@ -972,6 +979,7 @@ mod test { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_read_with_timeout() { let dir = tmpdir(); let socket_path = dir.path().join("sock"); @@ -993,6 +1001,7 @@ mod test { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_unix_datagram() { let dir = tmpdir(); let path1 = dir.path().join("sock1"); @@ -1009,6 +1018,7 @@ mod test { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_unnamed_unix_datagram() { let dir = tmpdir(); let path1 = dir.path().join("sock1"); @@ -1026,6 +1036,7 @@ mod test { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_connect_unix_datagram() { let dir = tmpdir(); let path1 = dir.path().join("sock1"); @@ -1052,6 +1063,7 @@ mod test { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_unix_datagram_recv() { let dir = tmpdir(); let path1 = dir.path().join("sock1"); @@ -1069,6 +1081,7 @@ mod test { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn datagram_pair() { let msg1 = b"hello"; let msg2 = b"world!"; diff --git a/src/libstd/sys/unix/process.rs b/src/libstd/sys/unix/process.rs index 50014f51f6c..85aba4b9b15 100644 --- a/src/libstd/sys/unix/process.rs +++ b/src/libstd/sys/unix/process.rs @@ -630,6 +630,7 @@ mod tests { #[test] #[cfg_attr(target_os = "macos", ignore)] #[cfg_attr(target_os = "nacl", ignore)] // no signals on NaCl. + #[cfg_attr(target_os = "emscripten", ignore)] fn test_process_mask() { unsafe { // Test to make sure that a signal mask does not get inherited. diff --git a/src/libstd/thread/local.rs b/src/libstd/thread/local.rs index c44dee49f14..59748b47d81 100644 --- a/src/libstd/thread/local.rs +++ b/src/libstd/thread/local.rs @@ -541,6 +541,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn smoke_no_dtor() { thread_local!(static FOO: Cell = Cell::new(1)); @@ -563,6 +564,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn states() { struct Foo; impl Drop for Foo { @@ -586,6 +588,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn smoke_dtor() { thread_local!(static FOO: UnsafeCell> = UnsafeCell::new(None)); @@ -600,6 +603,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn circular() { struct S1; struct S2; @@ -640,6 +644,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn self_referential() { struct S1; thread_local!(static K1: UnsafeCell> = UnsafeCell::new(None)); @@ -661,6 +666,7 @@ mod tests { // test on OSX. #[test] #[cfg_attr(target_os = "macos", ignore)] + #[cfg_attr(target_os = "emscripten", ignore)] fn dtors_in_dtors_in_dtors() { struct S1(Sender<()>); thread_local!(static K1: UnsafeCell> = UnsafeCell::new(None)); diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index d8e021bb04f..b42a0fa3ac1 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -755,6 +755,7 @@ mod tests { // !!! instead of exiting cleanly. This might wedge the buildbots. !!! #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_unnamed_thread() { thread::spawn(move|| { assert!(thread::current().name().is_none()); @@ -762,6 +763,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_named_thread() { Builder::new().name("ada lovelace".to_string()).spawn(move|| { assert!(thread::current().name().unwrap() == "ada lovelace".to_string()); @@ -770,11 +772,13 @@ mod tests { #[test] #[should_panic] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_invalid_named_thread() { let _ = Builder::new().name("ada l\0velace".to_string()).spawn(|| {}); } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_run_basic() { let (tx, rx) = channel(); thread::spawn(move|| { @@ -784,6 +788,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_join_panic() { match thread::spawn(move|| { panic!() @@ -794,6 +799,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_spawn_sched() { let (tx, rx) = channel(); @@ -813,6 +819,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_spawn_sched_childs_on_default_sched() { let (tx, rx) = channel(); @@ -841,6 +848,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_avoid_copying_the_body_spawn() { avoid_copying_the_body(|v| { thread::spawn(move || v()); @@ -848,6 +856,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_avoid_copying_the_body_thread_spawn() { avoid_copying_the_body(|f| { thread::spawn(move|| { @@ -857,6 +866,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_avoid_copying_the_body_join() { avoid_copying_the_body(|f| { let _ = thread::spawn(move|| { @@ -866,6 +876,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_child_doesnt_ref_parent() { // If the child refcounts the parent thread, this will stack overflow when // climbing the thread tree to dereference each ancestor. (See #1789) @@ -883,11 +894,13 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_simple_newsched_spawn() { thread::spawn(move || {}); } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_try_panic_message_static_str() { match thread::spawn(move|| { panic!("static string"); @@ -902,6 +915,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_try_panic_message_owned_str() { match thread::spawn(move|| { panic!("owned string".to_string()); @@ -916,6 +930,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_try_panic_message_any() { match thread::spawn(move|| { panic!(box 413u16 as Box); @@ -932,6 +947,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_try_panic_message_unit_struct() { struct Juju; @@ -944,6 +960,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_park_timeout_unpark_before() { for _ in 0..10 { thread::current().unpark(); @@ -952,6 +969,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_park_timeout_unpark_not_called() { for _ in 0..10 { thread::park_timeout(Duration::from_millis(10)); @@ -959,6 +977,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_park_timeout_unpark_called_other_thread() { for _ in 0..10 { let th = thread::current(); -- cgit 1.4.1-3-g733a5 From 096670ca41a2aada11722acf4d0ab35a422448f6 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Thu, 22 Sep 2016 20:04:48 +0000 Subject: Ignore various entire test modules on emscripten --- src/libstd/fs.rs | 51 +------------------------------------- src/libstd/net/addr.rs | 3 --- src/libstd/sync/mpsc/mpsc_queue.rs | 3 +-- src/libstd/sync/mpsc/spsc_queue.rs | 3 +-- src/libstd/sync/mutex.rs | 10 +------- src/libstd/sync/once.rs | 4 +-- src/libstd/sync/rwlock.rs | 11 +------- src/libstd/sys/common/io.rs | 2 +- src/libstd/sys/common/remutex.rs | 5 +--- src/libstd/sys/unix/ext/net.rs | 15 +---------- src/libstd/thread/local.rs | 8 +----- src/libstd/thread/mod.rs | 21 +--------------- 12 files changed, 11 insertions(+), 125 deletions(-) (limited to 'src/libstd/thread') diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index 08d71c1d9f8..2f2969b110d 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -1686,7 +1686,7 @@ impl AsInnerMut for DirBuilder { } } -#[cfg(test)] +#[cfg(all(test, not(target_os = "emscripten")))] mod tests { use io::prelude::*; @@ -1745,7 +1745,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn file_test_io_smoke_test() { let message = "it's alright. have a good time"; let tmpdir = tmpdir(); @@ -1767,7 +1766,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn invalid_path_raises() { let tmpdir = tmpdir(); let filename = &tmpdir.join("file_that_does_not_exist.txt"); @@ -1782,7 +1780,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn file_test_iounlinking_invalid_path_should_raise_condition() { let tmpdir = tmpdir(); let filename = &tmpdir.join("file_another_file_that_does_not_exist.txt"); @@ -1798,7 +1795,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn file_test_io_non_positional_read() { let message: &str = "ten-four"; let mut read_mem = [0; 8]; @@ -1825,7 +1821,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn file_test_io_seek_and_tell_smoke_test() { let message = "ten-four"; let mut read_mem = [0; 4]; @@ -1853,7 +1848,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn file_test_io_seek_and_write() { let initial_msg = "food-is-yummy"; let overwrite_msg = "-the-bar!!"; @@ -1878,7 +1872,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn file_test_io_seek_shakedown() { // 01234567890123 let initial_msg = "qwer-asdf-zxcv"; @@ -1911,7 +1904,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn file_test_stat_is_correct_on_is_file() { let tmpdir = tmpdir(); let filename = &tmpdir.join("file_stat_correct_on_is_file.txt"); @@ -1933,7 +1925,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn file_test_stat_is_correct_on_is_dir() { let tmpdir = tmpdir(); let filename = &tmpdir.join("file_stat_correct_on_is_dir"); @@ -1946,7 +1937,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn file_test_fileinfo_false_when_checking_is_file_on_a_directory() { let tmpdir = tmpdir(); let dir = &tmpdir.join("fileinfo_false_on_dir"); @@ -1956,7 +1946,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn file_test_fileinfo_check_exists_before_and_after_file_creation() { let tmpdir = tmpdir(); let file = &tmpdir.join("fileinfo_check_exists_b_and_a.txt"); @@ -1967,7 +1956,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn file_test_directoryinfo_check_exists_before_and_after_mkdir() { let tmpdir = tmpdir(); let dir = &tmpdir.join("before_and_after_dir"); @@ -1980,7 +1968,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn file_test_directoryinfo_readdir() { let tmpdir = tmpdir(); let dir = &tmpdir.join("di_readdir"); @@ -2010,7 +1997,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn file_create_new_already_exists_error() { let tmpdir = tmpdir(); let file = &tmpdir.join("file_create_new_error_exists"); @@ -2020,7 +2006,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn mkdir_path_already_exists_error() { let tmpdir = tmpdir(); let dir = &tmpdir.join("mkdir_error_twice"); @@ -2030,7 +2015,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn recursive_mkdir() { let tmpdir = tmpdir(); let dir = tmpdir.join("d1/d2"); @@ -2039,7 +2023,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn recursive_mkdir_failure() { let tmpdir = tmpdir(); let dir = tmpdir.join("d1"); @@ -2054,13 +2037,11 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn recursive_mkdir_slash() { check!(fs::create_dir_all(&Path::new("/"))); } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn recursive_rmdir() { let tmpdir = tmpdir(); let d1 = tmpdir.join("d1"); @@ -2080,7 +2061,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn recursive_rmdir_of_symlink() { // test we do not recursively delete a symlink but only dirs. let tmpdir = tmpdir(); @@ -2114,7 +2094,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn unicode_path_is_dir() { assert!(Path::new(".").is_dir()); assert!(!Path::new("test/stdtest/fs.rs").is_dir()); @@ -2134,7 +2113,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn unicode_path_exists() { assert!(Path::new(".").exists()); assert!(!Path::new("test/nonexistent-bogus-path").exists()); @@ -2148,7 +2126,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn copy_file_does_not_exist() { let from = Path::new("test/nonexistent-bogus-path"); let to = Path::new("test/other-bogus-path"); @@ -2163,7 +2140,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn copy_src_does_not_exist() { let tmpdir = tmpdir(); let from = Path::new("test/nonexistent-bogus-path"); @@ -2177,7 +2153,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn copy_file_ok() { let tmpdir = tmpdir(); let input = tmpdir.join("in.txt"); @@ -2194,7 +2169,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn copy_file_dst_dir() { let tmpdir = tmpdir(); let out = tmpdir.join("out"); @@ -2206,7 +2180,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn copy_file_dst_exists() { let tmpdir = tmpdir(); let input = tmpdir.join("in"); @@ -2222,7 +2195,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn copy_file_src_dir() { let tmpdir = tmpdir(); let out = tmpdir.join("out"); @@ -2234,7 +2206,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn copy_file_preserves_perm_bits() { let tmpdir = tmpdir(); let input = tmpdir.join("in.txt"); @@ -2263,7 +2234,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn symlinks_work() { let tmpdir = tmpdir(); if !got_symlink_permission(&tmpdir) { return }; @@ -2282,7 +2252,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn symlink_noexist() { // Symlinks can point to things that don't exist let tmpdir = tmpdir(); @@ -2296,7 +2265,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn read_link() { if cfg!(windows) { // directory symlink @@ -2317,7 +2285,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn readlink_not_symlink() { let tmpdir = tmpdir(); match fs::read_link(tmpdir.path()) { @@ -2327,7 +2294,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn links_work() { let tmpdir = tmpdir(); let input = tmpdir.join("in.txt"); @@ -2356,7 +2322,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn chmod_works() { let tmpdir = tmpdir(); let file = tmpdir.join("in.txt"); @@ -2380,7 +2345,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn sync_doesnt_kill_anything() { let tmpdir = tmpdir(); let path = tmpdir.join("in.txt"); @@ -2394,7 +2358,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn truncate_works() { let tmpdir = tmpdir(); let path = tmpdir.join("in.txt"); @@ -2429,7 +2392,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn open_flavors() { use fs::OpenOptions as OO; fn c(t: &T) -> T { t.clone() } @@ -2549,7 +2511,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn binary_file() { let mut bytes = [0; 1024]; StdRng::new().unwrap().fill_bytes(&mut bytes); @@ -2563,7 +2524,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn file_try_clone() { let tmpdir = tmpdir(); @@ -2586,7 +2546,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] #[cfg(not(windows))] fn unlink_readonly() { let tmpdir = tmpdir(); @@ -2599,7 +2558,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn mkdir_trailing_slash() { let tmpdir = tmpdir(); let path = tmpdir.join("file"); @@ -2607,7 +2565,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn canonicalize_works_simple() { let tmpdir = tmpdir(); let tmpdir = fs::canonicalize(tmpdir.path()).unwrap(); @@ -2617,7 +2574,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn realpath_works() { let tmpdir = tmpdir(); if !got_symlink_permission(&tmpdir) { return }; @@ -2643,7 +2599,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn realpath_works_tricky() { let tmpdir = tmpdir(); if !got_symlink_permission(&tmpdir) { return }; @@ -2673,7 +2628,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn dir_entry_methods() { let tmpdir = tmpdir(); @@ -2708,14 +2662,12 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn read_dir_not_found() { let res = fs::read_dir("/path/that/does/not/exist"); assert_eq!(res.err().unwrap().kind(), ErrorKind::NotFound); } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn create_dir_all_with_junctions() { let tmpdir = tmpdir(); let target = tmpdir.join("target"); @@ -2743,7 +2695,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn metadata_access_times() { let tmpdir = tmpdir(); diff --git a/src/libstd/net/addr.rs b/src/libstd/net/addr.rs index a77d83a23ce..58daa7dbf8d 100644 --- a/src/libstd/net/addr.rs +++ b/src/libstd/net/addr.rs @@ -533,7 +533,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn to_socket_addr_str_u16() { let a = sa4(Ipv4Addr::new(77, 88, 21, 11), 24352); assert_eq!(Ok(vec![a]), tsa(("77.88.21.11", 24352))); @@ -546,7 +545,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn to_socket_addr_str() { let a = sa4(Ipv4Addr::new(77, 88, 21, 11), 24352); assert_eq!(Ok(vec![a]), tsa("77.88.21.11:24352")); @@ -561,7 +559,6 @@ mod tests { // FIXME: figure out why this fails on openbsd and bitrig and fix it #[test] #[cfg(not(any(windows, target_os = "openbsd", target_os = "bitrig")))] - #[cfg_attr(target_os = "emscripten", ignore)] fn to_socket_addr_str_bad() { assert!(tsa("1200::AB00:1234::2552:7777:1313:34300").is_err()); } diff --git a/src/libstd/sync/mpsc/mpsc_queue.rs b/src/libstd/sync/mpsc/mpsc_queue.rs index 2ff9ffe6d08..8d80f942ff7 100644 --- a/src/libstd/sync/mpsc/mpsc_queue.rs +++ b/src/libstd/sync/mpsc/mpsc_queue.rs @@ -146,7 +146,7 @@ impl Drop for Queue { } } -#[cfg(test)] +#[cfg(all(test, not(target_os = "emscripten")))] mod tests { use sync::mpsc::channel; use super::{Queue, Data, Empty, Inconsistent}; @@ -161,7 +161,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test() { let nthreads = 8; let nmsgs = 1000; diff --git a/src/libstd/sync/mpsc/spsc_queue.rs b/src/libstd/sync/mpsc/spsc_queue.rs index cb9577f155e..5858e4b6ddb 100644 --- a/src/libstd/sync/mpsc/spsc_queue.rs +++ b/src/libstd/sync/mpsc/spsc_queue.rs @@ -231,7 +231,7 @@ impl Drop for Queue { } } -#[cfg(test)] +#[cfg(all(test, not(target_os = "emscripten")))] mod tests { use sync::Arc; use super::Queue; @@ -305,7 +305,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn stress() { unsafe { stress_bound(0); diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs index 07d60f0610f..812724c7a16 100644 --- a/src/libstd/sync/mutex.rs +++ b/src/libstd/sync/mutex.rs @@ -352,7 +352,7 @@ pub fn guard_poison<'a, T: ?Sized>(guard: &MutexGuard<'a, T>) -> &'a poison::Fla &guard.__lock.poison } -#[cfg(test)] +#[cfg(all(test, not(target_os = "emscripten")))] mod tests { use sync::mpsc::channel; use sync::{Arc, Mutex, Condvar}; @@ -375,7 +375,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn lots_and_lots() { const J: u32 = 1000; const K: u32 = 3; @@ -436,7 +435,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_into_inner_poison() { let m = Arc::new(Mutex::new(NonCopy(10))); let m2 = m.clone(); @@ -460,7 +458,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_get_mut_poison() { let m = Arc::new(Mutex::new(NonCopy(10))); let m2 = m.clone(); @@ -477,7 +474,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_mutex_arc_condvar() { let packet = Packet(Arc::new((Mutex::new(false), Condvar::new()))); let packet2 = Packet(packet.0.clone()); @@ -501,7 +497,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_arc_condvar_poison() { let packet = Packet(Arc::new((Mutex::new(1), Condvar::new()))); let packet2 = Packet(packet.0.clone()); @@ -531,7 +526,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_mutex_arc_poison() { let arc = Arc::new(Mutex::new(1)); assert!(!arc.is_poisoned()); @@ -545,7 +539,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_mutex_arc_nested() { // Tests nested mutexes and access // to underlying data. @@ -562,7 +555,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_mutex_arc_access_in_unwind() { let arc = Arc::new(Mutex::new(1)); let arc2 = arc.clone(); diff --git a/src/libstd/sync/once.rs b/src/libstd/sync/once.rs index 64c3e2bb42f..ad9d0b37544 100644 --- a/src/libstd/sync/once.rs +++ b/src/libstd/sync/once.rs @@ -367,7 +367,7 @@ impl OnceState { } } -#[cfg(test)] +#[cfg(all(test, not(target_os = "emscripten")))] mod tests { use panic; use sync::mpsc::channel; @@ -385,7 +385,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn stampede_once() { static O: Once = Once::new(); static mut run: bool = false; @@ -448,7 +447,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn wait_for_force_to_finish() { static O: Once = Once::new(); diff --git a/src/libstd/sync/rwlock.rs b/src/libstd/sync/rwlock.rs index cb46b694f37..48ecae185f9 100644 --- a/src/libstd/sync/rwlock.rs +++ b/src/libstd/sync/rwlock.rs @@ -380,7 +380,7 @@ impl<'a, T: ?Sized> Drop for RwLockWriteGuard<'a, T> { } } -#[cfg(test)] +#[cfg(all(test, not(target_os = "emscripten")))] mod tests { #![allow(deprecated)] // rand @@ -403,7 +403,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn frob() { const N: usize = 10; const M: usize = 1000; @@ -431,7 +430,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_rw_arc_poison_wr() { let arc = Arc::new(RwLock::new(1)); let arc2 = arc.clone(); @@ -443,7 +441,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_rw_arc_poison_ww() { let arc = Arc::new(RwLock::new(1)); assert!(!arc.is_poisoned()); @@ -457,7 +454,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_rw_arc_no_poison_rr() { let arc = Arc::new(RwLock::new(1)); let arc2 = arc.clone(); @@ -469,7 +465,6 @@ mod tests { assert_eq!(*lock, 1); } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_rw_arc_no_poison_rw() { let arc = Arc::new(RwLock::new(1)); let arc2 = arc.clone(); @@ -482,7 +477,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_rw_arc() { let arc = Arc::new(RwLock::new(0)); let arc2 = arc.clone(); @@ -521,7 +515,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_rw_arc_access_in_unwind() { let arc = Arc::new(RwLock::new(1)); let arc2 = arc.clone(); @@ -594,7 +587,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_into_inner_poison() { let m = Arc::new(RwLock::new(NonCopy(10))); let m2 = m.clone(); @@ -618,7 +610,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_get_mut_poison() { let m = Arc::new(RwLock::new(NonCopy(10))); let m2 = m.clone(); diff --git a/src/libstd/sys/common/io.rs b/src/libstd/sys/common/io.rs index 2778ed9326c..47cec4ef5c2 100644 --- a/src/libstd/sys/common/io.rs +++ b/src/libstd/sys/common/io.rs @@ -50,7 +50,7 @@ pub unsafe fn read_to_end_uninitialized(r: &mut Read, buf: &mut Vec) -> io:: } } -#[cfg(test)] +#[cfg(all(test, not(target_os = "emscripten")))] pub mod test { use path::{Path, PathBuf}; use env; diff --git a/src/libstd/sys/common/remutex.rs b/src/libstd/sys/common/remutex.rs index 4935afe6afc..4d0407ccf6c 100644 --- a/src/libstd/sys/common/remutex.rs +++ b/src/libstd/sys/common/remutex.rs @@ -156,7 +156,7 @@ impl<'a, T> Drop for ReentrantMutexGuard<'a, T> { } -#[cfg(test)] +#[cfg(all(test, not(target_os = "emscripten")))] mod tests { use sys_common::remutex::{ReentrantMutex, ReentrantMutexGuard}; use cell::RefCell; @@ -181,7 +181,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn is_mutex() { let m = Arc::new(ReentrantMutex::new(RefCell::new(0))); let m2 = m.clone(); @@ -199,7 +198,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn trylock_works() { let m = Arc::new(ReentrantMutex::new(())); let m2 = m.clone(); @@ -220,7 +218,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn poison_works() { let m = Arc::new(ReentrantMutex::new(RefCell::new(0))); let mc = m.clone(); diff --git a/src/libstd/sys/unix/ext/net.rs b/src/libstd/sys/unix/ext/net.rs index 8224696db2f..40fe24cf10e 100644 --- a/src/libstd/sys/unix/ext/net.rs +++ b/src/libstd/sys/unix/ext/net.rs @@ -786,7 +786,7 @@ impl IntoRawFd for UnixDatagram { } } -#[cfg(test)] +#[cfg(all(test, not(target_os = "emscripten")))] mod test { use thread; use io; @@ -806,7 +806,6 @@ mod test { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn basic() { let dir = tmpdir(); let socket_path = dir.path().join("sock"); @@ -835,7 +834,6 @@ mod test { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn pair() { let msg1 = b"hello"; let msg2 = b"world!"; @@ -859,7 +857,6 @@ mod test { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn try_clone() { let dir = tmpdir(); let socket_path = dir.path().join("sock"); @@ -886,7 +883,6 @@ mod test { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn iter() { let dir = tmpdir(); let socket_path = dir.path().join("sock"); @@ -909,7 +905,6 @@ mod test { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn long_path() { let dir = tmpdir(); let socket_path = dir.path() @@ -935,7 +930,6 @@ mod test { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn timeouts() { let dir = tmpdir(); let socket_path = dir.path().join("sock"); @@ -963,7 +957,6 @@ mod test { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_read_timeout() { let dir = tmpdir(); let socket_path = dir.path().join("sock"); @@ -979,7 +972,6 @@ mod test { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_read_with_timeout() { let dir = tmpdir(); let socket_path = dir.path().join("sock"); @@ -1001,7 +993,6 @@ mod test { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_unix_datagram() { let dir = tmpdir(); let path1 = dir.path().join("sock1"); @@ -1018,7 +1009,6 @@ mod test { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_unnamed_unix_datagram() { let dir = tmpdir(); let path1 = dir.path().join("sock1"); @@ -1036,7 +1026,6 @@ mod test { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_connect_unix_datagram() { let dir = tmpdir(); let path1 = dir.path().join("sock1"); @@ -1063,7 +1052,6 @@ mod test { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_unix_datagram_recv() { let dir = tmpdir(); let path1 = dir.path().join("sock1"); @@ -1081,7 +1069,6 @@ mod test { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn datagram_pair() { let msg1 = b"hello"; let msg2 = b"world!"; diff --git a/src/libstd/thread/local.rs b/src/libstd/thread/local.rs index 59748b47d81..a333a7d967d 100644 --- a/src/libstd/thread/local.rs +++ b/src/libstd/thread/local.rs @@ -524,7 +524,7 @@ pub mod os { } } -#[cfg(test)] +#[cfg(all(test, not(target_os = "emscripten")))] mod tests { use sync::mpsc::{channel, Sender}; use cell::{Cell, UnsafeCell}; @@ -541,7 +541,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn smoke_no_dtor() { thread_local!(static FOO: Cell = Cell::new(1)); @@ -564,7 +563,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn states() { struct Foo; impl Drop for Foo { @@ -588,7 +586,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn smoke_dtor() { thread_local!(static FOO: UnsafeCell> = UnsafeCell::new(None)); @@ -603,7 +600,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn circular() { struct S1; struct S2; @@ -644,7 +640,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn self_referential() { struct S1; thread_local!(static K1: UnsafeCell> = UnsafeCell::new(None)); @@ -666,7 +661,6 @@ mod tests { // test on OSX. #[test] #[cfg_attr(target_os = "macos", ignore)] - #[cfg_attr(target_os = "emscripten", ignore)] fn dtors_in_dtors_in_dtors() { struct S1(Sender<()>); thread_local!(static K1: UnsafeCell> = UnsafeCell::new(None)); diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index b42a0fa3ac1..775dfababc6 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -741,7 +741,7 @@ fn _assert_sync_and_send() { // Tests //////////////////////////////////////////////////////////////////////////////// -#[cfg(test)] +#[cfg(all(test, not(target_os = "emscripten")))] mod tests { use any::Any; use sync::mpsc::{channel, Sender}; @@ -755,7 +755,6 @@ mod tests { // !!! instead of exiting cleanly. This might wedge the buildbots. !!! #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_unnamed_thread() { thread::spawn(move|| { assert!(thread::current().name().is_none()); @@ -763,7 +762,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_named_thread() { Builder::new().name("ada lovelace".to_string()).spawn(move|| { assert!(thread::current().name().unwrap() == "ada lovelace".to_string()); @@ -772,13 +770,11 @@ mod tests { #[test] #[should_panic] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_invalid_named_thread() { let _ = Builder::new().name("ada l\0velace".to_string()).spawn(|| {}); } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_run_basic() { let (tx, rx) = channel(); thread::spawn(move|| { @@ -788,7 +784,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_join_panic() { match thread::spawn(move|| { panic!() @@ -799,7 +794,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_spawn_sched() { let (tx, rx) = channel(); @@ -819,7 +813,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_spawn_sched_childs_on_default_sched() { let (tx, rx) = channel(); @@ -848,7 +841,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_avoid_copying_the_body_spawn() { avoid_copying_the_body(|v| { thread::spawn(move || v()); @@ -856,7 +848,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_avoid_copying_the_body_thread_spawn() { avoid_copying_the_body(|f| { thread::spawn(move|| { @@ -866,7 +857,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_avoid_copying_the_body_join() { avoid_copying_the_body(|f| { let _ = thread::spawn(move|| { @@ -876,7 +866,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_child_doesnt_ref_parent() { // If the child refcounts the parent thread, this will stack overflow when // climbing the thread tree to dereference each ancestor. (See #1789) @@ -894,13 +883,11 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_simple_newsched_spawn() { thread::spawn(move || {}); } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_try_panic_message_static_str() { match thread::spawn(move|| { panic!("static string"); @@ -915,7 +902,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_try_panic_message_owned_str() { match thread::spawn(move|| { panic!("owned string".to_string()); @@ -930,7 +916,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_try_panic_message_any() { match thread::spawn(move|| { panic!(box 413u16 as Box); @@ -947,7 +932,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_try_panic_message_unit_struct() { struct Juju; @@ -960,7 +944,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_park_timeout_unpark_before() { for _ in 0..10 { thread::current().unpark(); @@ -969,7 +952,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_park_timeout_unpark_not_called() { for _ in 0..10 { thread::park_timeout(Duration::from_millis(10)); @@ -977,7 +959,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_park_timeout_unpark_called_other_thread() { for _ in 0..10 { let th = thread::current(); -- cgit 1.4.1-3-g733a5 From 894ef966c631facd13cd0d021acca43e37c8510e Mon Sep 17 00:00:00 2001 From: "Stephen M. Coakley" Date: Wed, 5 Oct 2016 11:34:25 -0500 Subject: Generate ID using u64 + atomic spinlock --- src/libstd/thread/mod.rs | 68 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 54 insertions(+), 14 deletions(-) (limited to 'src/libstd/thread') diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index ea20c93fc26..a20c2c5002b 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -165,7 +165,7 @@ use panic; use panicking; use str; use sync::{Mutex, Condvar, Arc}; -use sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT}; +use sync::atomic::{AtomicBool, Ordering}; use sys::thread as imp; use sys_common::thread_info; use sys_common::util; @@ -536,21 +536,52 @@ pub fn park_timeout(dur: Duration) { /// designated identifier. #[unstable(feature = "thread_id", issue = "21507")] #[derive(Eq, PartialEq, Copy, Clone)] -pub struct ThreadId(usize); +pub struct ThreadId(u64); impl ThreadId { - /// Returns an identifier unique to the current calling thread. - #[unstable(feature = "thread_id", issue = "21507")] - pub fn current() -> ThreadId { - static THREAD_ID_COUNT: AtomicUsize = ATOMIC_USIZE_INIT; - #[thread_local] static mut THREAD_ID: ThreadId = ThreadId(0); + // Generate a new unique thread ID. Since this function is called every + // time a thread is created, this is optimized to generate unique values + // as quickly as possible. + fn new() -> ThreadId { + // 64-bit operations are not atomic on all systems, so use an atomic + // flag as a guard around a 64-bit global counter. The window for + // contention on the counter is rather narrow since the general case + // should be compiled down to three instructions between locking and + // unlocking the guard. Since contention on the guard is low, use a + // spinlock that optimizes for the fast path of the guard being + // unlocked. + static GUARD: AtomicBool = AtomicBool::new(false); + static mut COUNTER: u64 = 0; + + // Get exclusive access to the counter. + while GUARD.compare_exchange_weak( + false, + true, + Ordering::Acquire, + Ordering::Relaxed + ).is_err() { + // Give up the rest of our thread quantum if another thread is + // using the counter. This is the slow_er_ path. + yield_now(); + } - unsafe { - if THREAD_ID.0 == 0 { - THREAD_ID.0 = 1 + THREAD_ID_COUNT.fetch_add(1, Ordering::SeqCst); + // We have exclusive access to the counter, so use it fast and get out. + let id = unsafe { + // If we somehow use up all our bits, panic so that we're not + // covering up subtle bugs of IDs being reused. + if COUNTER == ::u64::MAX { + panic!("failed to generate unique thread ID: bitspace exhausted"); } - THREAD_ID - } + + let id = COUNTER; + COUNTER += 1; + id + }; + + // Unlock the guard. + GUARD.store(false, Ordering::Release); + + ThreadId(id) } } @@ -561,6 +592,7 @@ impl ThreadId { /// The internal representation of a `Thread` handle struct Inner { name: Option, // Guaranteed to be UTF-8 + id: ThreadId, lock: Mutex, // true when there is a buffered unpark cvar: Condvar, } @@ -581,6 +613,7 @@ impl Thread { Thread { inner: Arc::new(Inner { name: cname, + id: ThreadId::new(), lock: Mutex::new(false), cvar: Condvar::new(), }) @@ -599,6 +632,12 @@ impl Thread { } } + /// Gets the thread's unique identifier. + #[unstable(feature = "thread_id", issue = "21507")] + pub fn id(&self) -> ThreadId { + self.inner.id + } + /// Gets the thread's name. /// /// # Examples @@ -1009,12 +1048,13 @@ mod tests { #[test] fn test_thread_id_equal() { - assert!(thread::ThreadId::current() == thread::ThreadId::current()); + assert!(thread::current().id() == thread::current().id()); } #[test] fn test_thread_id_not_equal() { - assert!(thread::ThreadId::current() != thread::spawn(|| thread::ThreadId::current()).join().unwrap()); + let spawned_id = thread::spawn(|| thread::current().id()).join().unwrap(); + assert!(thread::current().id() != spawned_id); } // NOTE: the corresponding test for stderr is in run-pass/thread-stderr, due -- cgit 1.4.1-3-g733a5 From e80fd2531bbb8d2ca30e4036d7be5bcfcaefb6c0 Mon Sep 17 00:00:00 2001 From: "Stephen M. Coakley" Date: Wed, 5 Oct 2016 18:11:28 -0500 Subject: Use mutex to guard thread ID counter --- src/libstd/thread/mod.rs | 38 ++++++++------------------------------ 1 file changed, 8 insertions(+), 30 deletions(-) (limited to 'src/libstd/thread') diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index a20c2c5002b..c8b6046bb8d 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -165,8 +165,8 @@ use panic; use panicking; use str; use sync::{Mutex, Condvar, Arc}; -use sync::atomic::{AtomicBool, Ordering}; use sys::thread as imp; +use sys_common::mutex; use sys_common::thread_info; use sys_common::util; use sys_common::{AsInner, IntoInner}; @@ -539,34 +539,14 @@ pub fn park_timeout(dur: Duration) { pub struct ThreadId(u64); impl ThreadId { - // Generate a new unique thread ID. Since this function is called every - // time a thread is created, this is optimized to generate unique values - // as quickly as possible. + // Generate a new unique thread ID. fn new() -> ThreadId { - // 64-bit operations are not atomic on all systems, so use an atomic - // flag as a guard around a 64-bit global counter. The window for - // contention on the counter is rather narrow since the general case - // should be compiled down to three instructions between locking and - // unlocking the guard. Since contention on the guard is low, use a - // spinlock that optimizes for the fast path of the guard being - // unlocked. - static GUARD: AtomicBool = AtomicBool::new(false); + static GUARD: mutex::Mutex = mutex::Mutex::new(); static mut COUNTER: u64 = 0; - // Get exclusive access to the counter. - while GUARD.compare_exchange_weak( - false, - true, - Ordering::Acquire, - Ordering::Relaxed - ).is_err() { - // Give up the rest of our thread quantum if another thread is - // using the counter. This is the slow_er_ path. - yield_now(); - } + unsafe { + GUARD.lock(); - // We have exclusive access to the counter, so use it fast and get out. - let id = unsafe { // If we somehow use up all our bits, panic so that we're not // covering up subtle bugs of IDs being reused. if COUNTER == ::u64::MAX { @@ -575,13 +555,11 @@ impl ThreadId { let id = COUNTER; COUNTER += 1; - id - }; - // Unlock the guard. - GUARD.store(false, Ordering::Release); + GUARD.unlock(); - ThreadId(id) + ThreadId(id) + } } } -- cgit 1.4.1-3-g733a5 From 032bffa5b8ae6c3977884c4e10fd6ab6a5dc5ef6 Mon Sep 17 00:00:00 2001 From: "Stephen M. Coakley" Date: Fri, 7 Oct 2016 17:45:04 -0500 Subject: Unlock guard before overflow panic --- src/libstd/thread/mod.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'src/libstd/thread') diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index c8b6046bb8d..98feea96f8c 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -550,6 +550,7 @@ impl ThreadId { // If we somehow use up all our bits, panic so that we're not // covering up subtle bugs of IDs being reused. if COUNTER == ::u64::MAX { + GUARD.unlock(); panic!("failed to generate unique thread ID: bitspace exhausted"); } -- cgit 1.4.1-3-g733a5 From 76bac5d33e09e8ae1b243c045584646431147cce Mon Sep 17 00:00:00 2001 From: Raph Levien Date: Tue, 18 Oct 2016 13:43:18 -0700 Subject: Add Fuchsia support Adds support for the x86_64-unknown-fuchsia target, which covers the Fuchsia operating system. --- mk/cfg/x86_64-unknown-fuchsia.mk | 1 + src/liballoc_jemalloc/build.rs | 2 +- src/librustc_back/target/fuchsia_base.rs | 39 +++ src/librustc_back/target/mod.rs | 3 + src/librustc_back/target/x86_64_unknown_fuchsia.rs | 30 +++ src/libstd/build.rs | 2 +- src/libstd/os/fuchsia/fs.rs | 103 ++++++++ src/libstd/os/fuchsia/mod.rs | 16 ++ src/libstd/os/fuchsia/raw.rs | 275 +++++++++++++++++++++ src/libstd/os/mod.rs | 1 + src/libstd/sys/unix/args.rs | 3 +- src/libstd/sys/unix/env.rs | 11 + src/libstd/sys/unix/ext/fs.rs | 1 + src/libstd/sys/unix/fs.rs | 3 +- src/libstd/sys/unix/mod.rs | 5 +- src/libstd/sys/unix/os.rs | 8 +- src/libstd/sys/unix/thread.rs | 4 + src/libstd/thread/local.rs | 72 +++--- src/libtest/lib.rs | 3 +- src/libunwind/build.rs | 2 + src/libunwind/libunwind.rs | 2 + 21 files changed, 548 insertions(+), 38 deletions(-) create mode 100644 mk/cfg/x86_64-unknown-fuchsia.mk create mode 100644 src/librustc_back/target/fuchsia_base.rs create mode 100644 src/librustc_back/target/x86_64_unknown_fuchsia.rs create mode 100644 src/libstd/os/fuchsia/fs.rs create mode 100644 src/libstd/os/fuchsia/mod.rs create mode 100644 src/libstd/os/fuchsia/raw.rs (limited to 'src/libstd/thread') diff --git a/mk/cfg/x86_64-unknown-fuchsia.mk b/mk/cfg/x86_64-unknown-fuchsia.mk new file mode 100644 index 00000000000..34aee77ae21 --- /dev/null +++ b/mk/cfg/x86_64-unknown-fuchsia.mk @@ -0,0 +1 @@ +# rustbuild-only target diff --git a/src/liballoc_jemalloc/build.rs b/src/liballoc_jemalloc/build.rs index 369db8e75a3..08a1f8ae8c6 100644 --- a/src/liballoc_jemalloc/build.rs +++ b/src/liballoc_jemalloc/build.rs @@ -36,7 +36,7 @@ fn main() { // targets, which means we have to build the alloc_jemalloc crate // for targets like emscripten, even if we don't use it. if target.contains("rumprun") || target.contains("bitrig") || target.contains("openbsd") || - target.contains("msvc") || target.contains("emscripten") { + target.contains("msvc") || target.contains("emscripten") || target.contains("fuchsia") { println!("cargo:rustc-cfg=dummy_jemalloc"); return; } diff --git a/src/librustc_back/target/fuchsia_base.rs b/src/librustc_back/target/fuchsia_base.rs new file mode 100644 index 00000000000..e763d6d8fba --- /dev/null +++ b/src/librustc_back/target/fuchsia_base.rs @@ -0,0 +1,39 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use target::TargetOptions; +use std::default::Default; + +pub fn opts() -> TargetOptions { + TargetOptions { + dynamic_linking: true, + executables: true, + linker_is_gnu: true, + has_rpath: true, + pre_link_args: vec![ + // We want to be able to strip as much executable code as possible + // from the linker command line, and this flag indicates to the + // linker that it can avoid linking in dynamic libraries that don't + // actually satisfy any symbols up to that point (as with many other + // resolutions the linker does). This option only applies to all + // following libraries so we're sure to pass it as one of the first + // arguments. + // TODO: doesn't seem to be supported by clang toolchain + //"-Wl,--as-needed".to_string(), + + // Always enable NX protection when it is available + //"-Wl,-z,noexecstack".to_string(), + ], + position_independent_executables: true, + exe_allocation_crate: "alloc_system".to_string(), + has_elf_tls: true, + .. Default::default() + } +} diff --git a/src/librustc_back/target/mod.rs b/src/librustc_back/target/mod.rs index 1843fc581f1..931080daef2 100644 --- a/src/librustc_back/target/mod.rs +++ b/src/librustc_back/target/mod.rs @@ -67,6 +67,7 @@ mod solaris_base; mod windows_base; mod windows_msvc_base; mod thumb_base; +mod fuchsia_base; pub type TargetResult = Result; @@ -175,6 +176,8 @@ supported_targets! { ("x86_64-apple-darwin", x86_64_apple_darwin), ("i686-apple-darwin", i686_apple_darwin), + ("x86_64-unknown-fuchsia", x86_64_unknown_fuchsia), + ("i386-apple-ios", i386_apple_ios), ("x86_64-apple-ios", x86_64_apple_ios), ("aarch64-apple-ios", aarch64_apple_ios), diff --git a/src/librustc_back/target/x86_64_unknown_fuchsia.rs b/src/librustc_back/target/x86_64_unknown_fuchsia.rs new file mode 100644 index 00000000000..08fe17a556e --- /dev/null +++ b/src/librustc_back/target/x86_64_unknown_fuchsia.rs @@ -0,0 +1,30 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use target::{Target, TargetResult}; + +pub fn target() -> TargetResult { + let mut base = super::fuchsia_base::opts(); + base.cpu = "x86-64".to_string(); + base.max_atomic_width = Some(64); + base.pre_link_args.push("-m64".to_string()); + + Ok(Target { + llvm_target: "x86_64-unknown-fuchsia".to_string(), + target_endian: "little".to_string(), + target_pointer_width: "64".to_string(), + data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(), + arch: "x86_64".to_string(), + target_os: "fuchsia".to_string(), + target_env: "".to_string(), + target_vendor: "unknown".to_string(), + options: base, + }) +} diff --git a/src/libstd/build.rs b/src/libstd/build.rs index c5732278db9..c811ed3bded 100644 --- a/src/libstd/build.rs +++ b/src/libstd/build.rs @@ -26,7 +26,7 @@ fn main() { let target = env::var("TARGET").expect("TARGET was not set"); let host = env::var("HOST").expect("HOST was not set"); if cfg!(feature = "backtrace") && !target.contains("apple") && !target.contains("msvc") && - !target.contains("emscripten") { + !target.contains("emscripten") && !target.contains("fuchsia") { build_libbacktrace(&host, &target); } diff --git a/src/libstd/os/fuchsia/fs.rs b/src/libstd/os/fuchsia/fs.rs new file mode 100644 index 00000000000..d22f9a628bd --- /dev/null +++ b/src/libstd/os/fuchsia/fs.rs @@ -0,0 +1,103 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![stable(feature = "metadata_ext", since = "1.1.0")] + +use fs::Metadata; +use sys_common::AsInner; + +/// OS-specific extension methods for `fs::Metadata` +#[stable(feature = "metadata_ext", since = "1.1.0")] +pub trait MetadataExt { + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_dev(&self) -> u64; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_ino(&self) -> u64; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_mode(&self) -> u32; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_nlink(&self) -> u64; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_uid(&self) -> u32; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_gid(&self) -> u32; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_rdev(&self) -> u64; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_size(&self) -> u64; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_atime(&self) -> i64; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_atime_nsec(&self) -> i64; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_mtime(&self) -> i64; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_mtime_nsec(&self) -> i64; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_ctime(&self) -> i64; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_ctime_nsec(&self) -> i64; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_blksize(&self) -> u64; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_blocks(&self) -> u64; +} + +#[stable(feature = "metadata_ext", since = "1.1.0")] +impl MetadataExt for Metadata { + fn st_dev(&self) -> u64 { + self.as_inner().as_inner().st_dev as u64 + } + fn st_ino(&self) -> u64 { + self.as_inner().as_inner().st_ino as u64 + } + fn st_mode(&self) -> u32 { + self.as_inner().as_inner().st_mode as u32 + } + fn st_nlink(&self) -> u64 { + self.as_inner().as_inner().st_nlink as u64 + } + fn st_uid(&self) -> u32 { + self.as_inner().as_inner().st_uid as u32 + } + fn st_gid(&self) -> u32 { + self.as_inner().as_inner().st_gid as u32 + } + fn st_rdev(&self) -> u64 { + self.as_inner().as_inner().st_rdev as u64 + } + fn st_size(&self) -> u64 { + self.as_inner().as_inner().st_size as u64 + } + fn st_atime(&self) -> i64 { + self.as_inner().as_inner().st_atime as i64 + } + fn st_atime_nsec(&self) -> i64 { + self.as_inner().as_inner().st_atime_nsec as i64 + } + fn st_mtime(&self) -> i64 { + self.as_inner().as_inner().st_mtime as i64 + } + fn st_mtime_nsec(&self) -> i64 { + self.as_inner().as_inner().st_mtime_nsec as i64 + } + fn st_ctime(&self) -> i64 { + self.as_inner().as_inner().st_ctime as i64 + } + fn st_ctime_nsec(&self) -> i64 { + self.as_inner().as_inner().st_ctime_nsec as i64 + } + fn st_blksize(&self) -> u64 { + self.as_inner().as_inner().st_blksize as u64 + } + fn st_blocks(&self) -> u64 { + self.as_inner().as_inner().st_blocks as u64 + } +} diff --git a/src/libstd/os/fuchsia/mod.rs b/src/libstd/os/fuchsia/mod.rs new file mode 100644 index 00000000000..1ebcbba9147 --- /dev/null +++ b/src/libstd/os/fuchsia/mod.rs @@ -0,0 +1,16 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Fuchsia-specific definitions + +#![stable(feature = "raw_ext", since = "1.1.0")] + +pub mod raw; +pub mod fs; diff --git a/src/libstd/os/fuchsia/raw.rs b/src/libstd/os/fuchsia/raw.rs new file mode 100644 index 00000000000..696c0c70aa9 --- /dev/null +++ b/src/libstd/os/fuchsia/raw.rs @@ -0,0 +1,275 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Fuchsia-specific raw type definitions + +#![stable(feature = "raw_ext", since = "1.1.0")] +#![rustc_deprecated(since = "1.8.0", + reason = "these type aliases are no longer supported by \ + the standard library, the `libc` crate on \ + crates.io should be used instead for the correct \ + definitions")] +#![allow(deprecated)] + +use os::raw::c_ulong; + +#[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = u64; +#[stable(feature = "raw_ext", since = "1.1.0")] pub type mode_t = u32; + +#[stable(feature = "pthread_t", since = "1.8.0")] +pub type pthread_t = c_ulong; + +#[doc(inline)] +#[stable(feature = "raw_ext", since = "1.1.0")] +pub use self::arch::{off_t, ino_t, nlink_t, blksize_t, blkcnt_t, stat, time_t}; + +#[cfg(any(target_arch = "x86", + target_arch = "le32", + target_arch = "powerpc", + target_arch = "arm"))] +mod arch { + use os::raw::{c_long, c_short, c_uint}; + + #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64; + #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64; + #[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64; + #[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u64; + #[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = u64; + #[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64; + + #[repr(C)] + #[derive(Clone)] + #[stable(feature = "raw_ext", since = "1.1.0")] + pub struct stat { + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_dev: u64, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub __pad1: c_short, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub __st_ino: u32, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_mode: u32, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_nlink: u32, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_uid: u32, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_gid: u32, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_rdev: u64, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub __pad2: c_uint, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_size: i64, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_blksize: i32, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_blocks: i64, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_atime: i32, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_atime_nsec: c_long, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_mtime: i32, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_mtime_nsec: c_long, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_ctime: i32, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_ctime_nsec: c_long, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_ino: u64, + } +} + +#[cfg(target_arch = "mips")] +mod arch { + use os::raw::{c_long, c_ulong}; + + #[cfg(target_env = "musl")] + #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = i64; + #[cfg(not(target_env = "musl"))] + #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64; + #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64; + #[cfg(target_env = "musl")] + #[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64; + #[cfg(not(target_env = "musl"))] + #[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64; + #[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u64; + #[cfg(target_env = "musl")] + #[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = u64; + #[cfg(not(target_env = "musl"))] + #[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = u64; + #[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64; + + #[repr(C)] + #[derive(Clone)] + #[stable(feature = "raw_ext", since = "1.1.0")] + pub struct stat { + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_dev: c_ulong, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_pad1: [c_long; 3], + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_ino: u64, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_mode: u32, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_nlink: u32, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_uid: u32, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_gid: u32, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_rdev: c_ulong, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_pad2: [c_long; 2], + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_size: i64, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_atime: i32, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_atime_nsec: c_long, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_mtime: i32, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_mtime_nsec: c_long, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_ctime: i32, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_ctime_nsec: c_long, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_blksize: i32, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_blocks: i64, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_pad5: [c_long; 14], + } +} + +#[cfg(target_arch = "mips64")] +mod arch { + pub use libc::{off_t, ino_t, nlink_t, blksize_t, blkcnt_t, stat, time_t}; +} + +#[cfg(target_arch = "s390x")] +mod arch { + pub use libc::{off_t, ino_t, nlink_t, blksize_t, blkcnt_t, stat, time_t}; +} + +#[cfg(target_arch = "aarch64")] +mod arch { + use os::raw::{c_long, c_int}; + + #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64; + #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64; + #[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64; + #[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u64; + #[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = u64; + #[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64; + + #[repr(C)] + #[derive(Clone)] + #[stable(feature = "raw_ext", since = "1.1.0")] + pub struct stat { + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_dev: u64, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_ino: u64, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_mode: u32, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_nlink: u32, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_uid: u32, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_gid: u32, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_rdev: u64, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub __pad1: u64, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_size: i64, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_blksize: i32, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub __pad2: c_int, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_blocks: i64, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_atime: i64, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_atime_nsec: c_long, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_mtime: i64, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_mtime_nsec: c_long, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_ctime: i64, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_ctime_nsec: c_long, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub __unused: [c_int; 2], + } +} + +#[cfg(target_arch = "x86_64")] +mod arch { + use os::raw::{c_long, c_int}; + + #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64; + #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64; + #[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64; + #[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u64; + #[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = u64; + #[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64; + + #[repr(C)] + #[derive(Clone)] + #[stable(feature = "raw_ext", since = "1.1.0")] + pub struct stat { + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_dev: u64, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_ino: u64, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_nlink: u64, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_mode: u32, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_uid: u32, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_gid: u32, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub __pad0: c_int, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_rdev: u64, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_size: i64, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_blksize: i64, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_blocks: i64, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_atime: i64, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_atime_nsec: c_long, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_mtime: i64, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_mtime_nsec: c_long, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_ctime: i64, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_ctime_nsec: c_long, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub __unused: [c_long; 3], + } +} diff --git a/src/libstd/os/mod.rs b/src/libstd/os/mod.rs index 7622ef88693..366a1674156 100644 --- a/src/libstd/os/mod.rs +++ b/src/libstd/os/mod.rs @@ -33,5 +33,6 @@ pub use sys::ext as windows; #[cfg(target_os = "openbsd")] pub mod openbsd; #[cfg(target_os = "solaris")] pub mod solaris; #[cfg(target_os = "emscripten")] pub mod emscripten; +#[cfg(target_os = "fuchsia")] pub mod fuchsia; pub mod raw; diff --git a/src/libstd/sys/unix/args.rs b/src/libstd/sys/unix/args.rs index c64db333e51..c04fd863674 100644 --- a/src/libstd/sys/unix/args.rs +++ b/src/libstd/sys/unix/args.rs @@ -58,7 +58,8 @@ impl DoubleEndedIterator for Args { target_os = "openbsd", target_os = "solaris", target_os = "emscripten", - target_os = "haiku"))] + target_os = "haiku", + target_os = "fuchsia"))] mod imp { use os::unix::prelude::*; use mem; diff --git a/src/libstd/sys/unix/env.rs b/src/libstd/sys/unix/env.rs index 66ff2fec832..eff3a8c2a34 100644 --- a/src/libstd/sys/unix/env.rs +++ b/src/libstd/sys/unix/env.rs @@ -171,3 +171,14 @@ pub mod os { pub const EXE_SUFFIX: &'static str = ".js"; pub const EXE_EXTENSION: &'static str = "js"; } + +#[cfg(target_os = "fuchsia")] +pub mod os { + pub const FAMILY: &'static str = "unix"; + pub const OS: &'static str = "fuchsia"; + pub const DLL_PREFIX: &'static str = "lib"; + pub const DLL_SUFFIX: &'static str = ".so"; + pub const DLL_EXTENSION: &'static str = "so"; + pub const EXE_SUFFIX: &'static str = ""; + pub const EXE_EXTENSION: &'static str = ""; +} diff --git a/src/libstd/sys/unix/ext/fs.rs b/src/libstd/sys/unix/ext/fs.rs index fcfab051588..3ff21a07827 100644 --- a/src/libstd/sys/unix/ext/fs.rs +++ b/src/libstd/sys/unix/ext/fs.rs @@ -312,6 +312,7 @@ pub trait DirEntryExt { } #[stable(feature = "dir_entry_ext", since = "1.1.0")] +#[cfg(not(target_os = "fuchsia"))] impl DirEntryExt for fs::DirEntry { fn ino(&self) -> u64 { self.as_inner().ino() } } diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs index b77008676b1..ee2887eb019 100644 --- a/src/libstd/sys/unix/fs.rs +++ b/src/libstd/sys/unix/fs.rs @@ -342,7 +342,8 @@ impl DirEntry { #[cfg(any(target_os = "android", target_os = "linux", target_os = "emscripten", - target_os = "haiku"))] + target_os = "haiku", + target_os = "fuchsia"))] fn name_bytes(&self) -> &[u8] { unsafe { CStr::from_ptr(self.entry.d_name.as_ptr()).to_bytes() diff --git a/src/libstd/sys/unix/mod.rs b/src/libstd/sys/unix/mod.rs index 501329772ce..66bc9d4a491 100644 --- a/src/libstd/sys/unix/mod.rs +++ b/src/libstd/sys/unix/mod.rs @@ -26,6 +26,7 @@ use libc; #[cfg(target_os = "openbsd")] pub use os::openbsd as platform; #[cfg(target_os = "solaris")] pub use os::solaris as platform; #[cfg(target_os = "emscripten")] pub use os::emscripten as platform; +#[cfg(target_os = "fuchsia")] pub use os::fuchsia as platform; #[macro_use] pub mod weak; @@ -88,11 +89,11 @@ pub fn init() { } } - #[cfg(not(any(target_os = "nacl", target_os = "emscripten")))] + #[cfg(not(any(target_os = "nacl", target_os = "emscripten", target_os="fuchsia")))] unsafe fn reset_sigpipe() { assert!(signal(libc::SIGPIPE, libc::SIG_IGN) != !0); } - #[cfg(any(target_os = "nacl", target_os = "emscripten"))] + #[cfg(any(target_os = "nacl", target_os = "emscripten", target_os="fuchsia"))] unsafe fn reset_sigpipe() {} } diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs index 91f6ba80f83..e591f25cac1 100644 --- a/src/libstd/sys/unix/os.rs +++ b/src/libstd/sys/unix/os.rs @@ -38,7 +38,7 @@ static ENV_LOCK: Mutex = Mutex::new(); extern { #[cfg(not(target_os = "dragonfly"))] - #[cfg_attr(any(target_os = "linux", target_os = "emscripten"), + #[cfg_attr(any(target_os = "linux", target_os = "emscripten", target_os = "fuchsia"), link_name = "__errno_location")] #[cfg_attr(any(target_os = "bitrig", target_os = "netbsd", @@ -346,6 +346,12 @@ pub fn current_exe() -> io::Result { } } +#[cfg(target_os = "fuchsia")] +pub fn current_exe() -> io::Result { + use io::ErrorKind; + Err(io::Error::new(ErrorKind::Other, "Not yet implemented on fuchsia")) +} + pub struct Env { iter: vec::IntoIter<(OsString, OsString)>, _dont_send_or_sync_me: PhantomData<*mut ()>, diff --git a/src/libstd/sys/unix/thread.rs b/src/libstd/sys/unix/thread.rs index 87d82cdab97..df98d2e0169 100644 --- a/src/libstd/sys/unix/thread.rs +++ b/src/libstd/sys/unix/thread.rs @@ -135,6 +135,10 @@ impl Thread { pub fn set_name(_name: &CStr) { // Newlib, Illumos, Haiku, and Emscripten have no way to set a thread name. } + #[cfg(target_os = "fuchsia")] + pub fn set_name(_name: &CStr) { + // TODO: determine whether Fuchsia has a way to set a thread name. + } pub fn sleep(dur: Duration) { let mut secs = dur.as_secs(); diff --git a/src/libstd/thread/local.rs b/src/libstd/thread/local.rs index a333a7d967d..54d3f793045 100644 --- a/src/libstd/thread/local.rs +++ b/src/libstd/thread/local.rs @@ -358,36 +358,8 @@ pub mod elf { } } - // Since what appears to be glibc 2.18 this symbol has been shipped which - // GCC and clang both use to invoke destructors in thread_local globals, so - // let's do the same! - // - // Note, however, that we run on lots older linuxes, as well as cross - // compiling from a newer linux to an older linux, so we also have a - // fallback implementation to use as well. - // - // Due to rust-lang/rust#18804, make sure this is not generic! - #[cfg(target_os = "linux")] - unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern fn(*mut u8)) { - use mem; - use libc; - use sys_common::thread_local as os; - - extern { - #[linkage = "extern_weak"] - static __dso_handle: *mut u8; - #[linkage = "extern_weak"] - static __cxa_thread_atexit_impl: *const libc::c_void; - } - if !__cxa_thread_atexit_impl.is_null() { - type F = unsafe extern fn(dtor: unsafe extern fn(*mut u8), - arg: *mut u8, - dso_handle: *mut u8) -> libc::c_int; - mem::transmute::<*const libc::c_void, F>(__cxa_thread_atexit_impl) - (dtor, t, &__dso_handle as *const _ as *mut _); - return - } - + #[cfg(any(target_os = "linux", target_os = "fuchsia"))] + unsafe fn register_dtor_fallback(t: *mut u8, dtor: unsafe extern fn(*mut u8)) { // The fallback implementation uses a vanilla OS-based TLS key to track // the list of destructors that need to be run for this thread. The key // then has its own destructor which runs all the other destructors. @@ -397,6 +369,8 @@ pub mod elf { // *should* be the case that this loop always terminates because we // provide the guarantee that a TLS key cannot be set after it is // flagged for destruction. + use sys_common::thread_local as os; + static DTORS: os::StaticKey = os::StaticKey::new(Some(run_dtors)); type List = Vec<(*mut u8, unsafe extern fn(*mut u8))>; if DTORS.get().is_null() { @@ -418,6 +392,37 @@ pub mod elf { } } + // Since what appears to be glibc 2.18 this symbol has been shipped which + // GCC and clang both use to invoke destructors in thread_local globals, so + // let's do the same! + // + // Note, however, that we run on lots older linuxes, as well as cross + // compiling from a newer linux to an older linux, so we also have a + // fallback implementation to use as well. + // + // Due to rust-lang/rust#18804, make sure this is not generic! + #[cfg(target_os = "linux")] + unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern fn(*mut u8)) { + use mem; + use libc; + + extern { + #[linkage = "extern_weak"] + static __dso_handle: *mut u8; + #[linkage = "extern_weak"] + static __cxa_thread_atexit_impl: *const libc::c_void; + } + if !__cxa_thread_atexit_impl.is_null() { + type F = unsafe extern fn(dtor: unsafe extern fn(*mut u8), + arg: *mut u8, + dso_handle: *mut u8) -> libc::c_int; + mem::transmute::<*const libc::c_void, F>(__cxa_thread_atexit_impl) + (dtor, t, &__dso_handle as *const _ as *mut _); + return + } + register_dtor_fallback(t, dtor); + } + // OSX's analog of the above linux function is this _tlv_atexit function. // The disassembly of thread_local globals in C++ (at least produced by // clang) will have this show up in the output. @@ -430,6 +435,13 @@ pub mod elf { _tlv_atexit(dtor, t); } + // Just use the thread_local fallback implementation, at least until there's + // a more direct implementation. + #[cfg(target_os = "fuchsia")] + unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern fn(*mut u8)) { + register_dtor_fallback(t, dtor); + } + pub unsafe extern fn destroy_value(ptr: *mut u8) { let ptr = ptr as *mut Key; // Right before we run the user destructor be sure to flag the diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 625666e641c..8b0fd1ca0cb 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -1036,7 +1036,8 @@ fn get_concurrency() -> usize { target_os = "ios", target_os = "android", target_os = "solaris", - target_os = "emscripten"))] + target_os = "emscripten", + target_os = "fuchsia"))] fn num_cpus() -> usize { unsafe { libc::sysconf(libc::_SC_NPROCESSORS_ONLN) as usize } } diff --git a/src/libunwind/build.rs b/src/libunwind/build.rs index e1ddf8b4b7e..db41a368a16 100644 --- a/src/libunwind/build.rs +++ b/src/libunwind/build.rs @@ -35,5 +35,7 @@ fn main() { println!("cargo:rustc-link-lib=gcc_pic"); } else if target.contains("windows-gnu") { println!("cargo:rustc-link-lib=gcc_eh"); + } else if target.contains("fuchsia") { + println!("cargo:rustc-link-lib=unwind"); } } diff --git a/src/libunwind/libunwind.rs b/src/libunwind/libunwind.rs index c2edf754e49..bbac6c07c57 100644 --- a/src/libunwind/libunwind.rs +++ b/src/libunwind/libunwind.rs @@ -252,6 +252,8 @@ if #[cfg(not(all(target_os = "ios", target_arch = "arm")))] { any(target_arch = "x86", target_arch = "x86_64"), not(test)), link(name = "unwind", kind = "static"))] +#[cfg_attr(target_os = "fuchsia", + link(name = "unwind"))] #[cfg_attr(any(target_os = "android", target_os = "openbsd"), link(name = "gcc"))] #[cfg_attr(all(target_os = "netbsd", not(target_vendor = "rumprun")), -- cgit 1.4.1-3-g733a5