about summary refs log tree commit diff
path: root/library/std/src
diff options
context:
space:
mode:
Diffstat (limited to 'library/std/src')
-rw-r--r--library/std/src/sys/mod.rs5
-rw-r--r--library/std/src/sys/unix/env.rs11
-rw-r--r--library/std/src/sys/unix/ext/mod.rs2
-rw-r--r--library/std/src/sys/unix/mod.rs1
-rw-r--r--library/std/src/sys/unix/process/mod.rs22
-rw-r--r--library/std/src/sys/unix/process/process_vxworks.rs (renamed from library/std/src/sys/vxworks/process/process_vxworks.rs)2
-rw-r--r--library/std/src/sys/unix/rand.rs29
-rw-r--r--library/std/src/sys/unix/thread_local_dtor.rs6
-rw-r--r--library/std/src/sys/vxworks/env.rs9
-rw-r--r--library/std/src/sys/vxworks/mod.rs138
-rw-r--r--library/std/src/sys/vxworks/process/mod.rs9
-rw-r--r--library/std/src/sys/vxworks/rand.rs36
-rw-r--r--library/std/src/sys/vxworks/thread_local_dtor.rs7
13 files changed, 64 insertions, 213 deletions
diff --git a/library/std/src/sys/mod.rs b/library/std/src/sys/mod.rs
index 50c2660ebcf..2450a7aac5e 100644
--- a/library/std/src/sys/mod.rs
+++ b/library/std/src/sys/mod.rs
@@ -25,10 +25,7 @@
 mod common;
 
 cfg_if::cfg_if! {
-    if #[cfg(target_os = "vxworks")] {
-        mod vxworks;
-        pub use self::vxworks::*;
-    } else if #[cfg(unix)] {
+    if #[cfg(unix)] {
         mod unix;
         pub use self::unix::*;
     } else if #[cfg(windows)] {
diff --git a/library/std/src/sys/unix/env.rs b/library/std/src/sys/unix/env.rs
index 7f5e9b04dba..3a88dc083b0 100644
--- a/library/std/src/sys/unix/env.rs
+++ b/library/std/src/sys/unix/env.rs
@@ -173,3 +173,14 @@ pub mod os {
     pub const EXE_SUFFIX: &str = "";
     pub const EXE_EXTENSION: &str = "";
 }
+
+#[cfg(target_os = "vxworks")]
+pub mod os {
+    pub const FAMILY: &str = "unix";
+    pub const OS: &str = "vxworks";
+    pub const DLL_PREFIX: &str = "lib";
+    pub const DLL_SUFFIX: &str = ".so";
+    pub const DLL_EXTENSION: &str = "so";
+    pub const EXE_SUFFIX: &str = "";
+    pub const EXE_EXTENSION: &str = "";
+}
diff --git a/library/std/src/sys/unix/ext/mod.rs b/library/std/src/sys/unix/ext/mod.rs
index e5048f7e545..735bf35a3ce 100644
--- a/library/std/src/sys/unix/ext/mod.rs
+++ b/library/std/src/sys/unix/ext/mod.rs
@@ -62,6 +62,8 @@ cfg_if::cfg_if! {
         use crate::os::redox as platform;
         #[cfg(target_os = "solaris")]
         use crate::os::solaris as platform;
+        #[cfg(target_os = "vxworks")]
+        use crate::os::vxworks as platform;
     }
 }
 
diff --git a/library/std/src/sys/unix/mod.rs b/library/std/src/sys/unix/mod.rs
index 6e44ac19c7b..1316835a89d 100644
--- a/library/std/src/sys/unix/mod.rs
+++ b/library/std/src/sys/unix/mod.rs
@@ -71,6 +71,7 @@ pub fn init() {
         } else if #[cfg(not(any(
             target_os = "emscripten",
             target_os = "fuchsia",
+            target_os = "vxworks",
             // The poll on Darwin doesn't set POLLNVAL for closed fds.
             target_os = "macos",
             target_os = "ios",
diff --git a/library/std/src/sys/unix/process/mod.rs b/library/std/src/sys/unix/process/mod.rs
index 1b7b93f9d4a..f67c70c0177 100644
--- a/library/std/src/sys/unix/process/mod.rs
+++ b/library/std/src/sys/unix/process/mod.rs
@@ -4,11 +4,17 @@ pub use crate::ffi::OsString as EnvKey;
 pub use crate::sys_common::process::CommandEnvs;
 
 mod process_common;
-#[cfg(not(target_os = "fuchsia"))]
-#[path = "process_unix.rs"]
-mod process_inner;
-#[cfg(target_os = "fuchsia")]
-#[path = "process_fuchsia.rs"]
-mod process_inner;
-#[cfg(target_os = "fuchsia")]
-mod zircon;
+
+cfg_if::cfg_if! {
+    if #[cfg(target_os = "fuchsia")] {
+        #[path = "process_fuchsia.rs"]
+        mod process_inner;
+        mod zircon;
+    } else if #[cfg(target_os = "vxworks")] {
+        #[path = "process_vxworks.rs"]
+        mod process_inner;
+    } else {
+        #[path = "process_unix.rs"]
+        mod process_inner;
+    }
+}
diff --git a/library/std/src/sys/vxworks/process/process_vxworks.rs b/library/std/src/sys/unix/process/process_vxworks.rs
index 295452327eb..68605c2dfee 100644
--- a/library/std/src/sys/vxworks/process/process_vxworks.rs
+++ b/library/std/src/sys/unix/process/process_vxworks.rs
@@ -68,7 +68,7 @@ impl Command {
             let stack_size = thread::min_stack();
 
             // ensure that access to the environment is synchronized
-            let _lock = sys::os::env_lock();
+            let _lock = sys::os::env_read_lock();
 
             let ret = libc::rtpSpawn(
                 self.get_program_cstr().as_ptr(),
diff --git a/library/std/src/sys/unix/rand.rs b/library/std/src/sys/unix/rand.rs
index 38ddb41700c..44f9eabc319 100644
--- a/library/std/src/sys/unix/rand.rs
+++ b/library/std/src/sys/unix/rand.rs
@@ -18,7 +18,8 @@ pub fn hashmap_random_keys() -> (u64, u64) {
     not(target_os = "freebsd"),
     not(target_os = "netbsd"),
     not(target_os = "fuchsia"),
-    not(target_os = "redox")
+    not(target_os = "redox"),
+    not(target_os = "vxworks")
 ))]
 mod imp {
     use crate::fs::File;
@@ -237,3 +238,29 @@ mod imp {
         file.read_exact(v).expect("failed to read rand:")
     }
 }
+
+#[cfg(target_os = "vxworks")]
+mod imp {
+    use crate::io;
+    use core::sync::atomic::{AtomicBool, Ordering::Relaxed};
+
+    pub fn fill_bytes(v: &mut [u8]) {
+        static RNG_INIT: AtomicBool = AtomicBool::new(false);
+        while !RNG_INIT.load(Relaxed) {
+            let ret = unsafe { libc::randSecure() };
+            if ret < 0 {
+                panic!("couldn't generate random bytes: {}", io::Error::last_os_error());
+            } else if ret > 0 {
+                RNG_INIT.store(true, Relaxed);
+                break;
+            }
+            unsafe { libc::usleep(10) };
+        }
+        let ret = unsafe {
+            libc::randABytes(v.as_mut_ptr() as *mut libc::c_uchar, v.len() as libc::c_int)
+        };
+        if ret < 0 {
+            panic!("couldn't generate random bytes: {}", io::Error::last_os_error());
+        }
+    }
+}
diff --git a/library/std/src/sys/unix/thread_local_dtor.rs b/library/std/src/sys/unix/thread_local_dtor.rs
index c3275eb6f0e..c3f410353b9 100644
--- a/library/std/src/sys/unix/thread_local_dtor.rs
+++ b/library/std/src/sys/unix/thread_local_dtor.rs
@@ -92,3 +92,9 @@ pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) {
         }
     }
 }
+
+#[cfg(target_os = "vxworks")]
+pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) {
+    use crate::sys_common::thread_local_dtor::register_dtor_fallback;
+    register_dtor_fallback(t, dtor);
+}
diff --git a/library/std/src/sys/vxworks/env.rs b/library/std/src/sys/vxworks/env.rs
deleted file mode 100644
index fe1aedd5859..00000000000
--- a/library/std/src/sys/vxworks/env.rs
+++ /dev/null
@@ -1,9 +0,0 @@
-pub mod os {
-    pub const FAMILY: &str = "vxworks";
-    pub const OS: &str = "vxworks";
-    pub const DLL_PREFIX: &str = "lib";
-    pub const DLL_SUFFIX: &str = ".so";
-    pub const DLL_EXTENSION: &str = "so";
-    pub const EXE_SUFFIX: &str = "";
-    pub const EXE_EXTENSION: &str = "";
-}
diff --git a/library/std/src/sys/vxworks/mod.rs b/library/std/src/sys/vxworks/mod.rs
deleted file mode 100644
index 12d0147a129..00000000000
--- a/library/std/src/sys/vxworks/mod.rs
+++ /dev/null
@@ -1,138 +0,0 @@
-#![allow(dead_code)]
-#![allow(missing_docs, nonstandard_style)]
-
-use crate::io::ErrorKind;
-
-pub use self::rand::hashmap_random_keys;
-pub use crate::os::vxworks as platform;
-pub use libc::strlen;
-
-#[macro_use]
-#[path = "../unix/weak.rs"]
-pub mod weak;
-
-#[path = "../unix/alloc.rs"]
-pub mod alloc;
-#[path = "../unix/args.rs"]
-pub mod args;
-#[path = "../unix/cmath.rs"]
-pub mod cmath;
-#[path = "../unix/condvar.rs"]
-pub mod condvar;
-pub mod env;
-#[path = "../unix/ext/mod.rs"]
-pub mod ext;
-#[path = "../unix/fd.rs"]
-pub mod fd;
-#[path = "../unix/fs.rs"]
-pub mod fs;
-#[path = "../unix/io.rs"]
-pub mod io;
-#[path = "../unix/memchr.rs"]
-pub mod memchr;
-#[path = "../unix/mutex.rs"]
-pub mod mutex;
-#[path = "../unix/net.rs"]
-pub mod net;
-#[path = "../unix/os.rs"]
-pub mod os;
-#[path = "../unix/path.rs"]
-pub mod path;
-#[path = "../unix/pipe.rs"]
-pub mod pipe;
-pub mod process;
-pub mod rand;
-#[path = "../unix/rwlock.rs"]
-pub mod rwlock;
-#[path = "../unix/stack_overflow.rs"]
-pub mod stack_overflow;
-#[path = "../unix/stdio.rs"]
-pub mod stdio;
-#[path = "../unix/thread.rs"]
-pub mod thread;
-pub mod thread_local_dtor;
-#[path = "../unix/thread_local_key.rs"]
-pub mod thread_local_key;
-#[path = "../unix/time.rs"]
-pub mod time;
-
-pub use crate::sys_common::os_str_bytes as os_str;
-
-#[cfg(not(test))]
-pub fn init() {
-    // ignore SIGPIPE
-    unsafe {
-        assert!(signal(libc::SIGPIPE, libc::SIG_IGN) != libc::SIG_ERR);
-    }
-}
-
-pub use libc::signal;
-
-pub fn decode_error_kind(errno: i32) -> ErrorKind {
-    match errno as libc::c_int {
-        libc::ECONNREFUSED => ErrorKind::ConnectionRefused,
-        libc::ECONNRESET => ErrorKind::ConnectionReset,
-        libc::EPERM | libc::EACCES => ErrorKind::PermissionDenied,
-        libc::EPIPE => ErrorKind::BrokenPipe,
-        libc::ENOTCONN => ErrorKind::NotConnected,
-        libc::ECONNABORTED => ErrorKind::ConnectionAborted,
-        libc::EADDRNOTAVAIL => ErrorKind::AddrNotAvailable,
-        libc::EADDRINUSE => ErrorKind::AddrInUse,
-        libc::ENOENT => ErrorKind::NotFound,
-        libc::EINTR => ErrorKind::Interrupted,
-        libc::EINVAL => ErrorKind::InvalidInput,
-        libc::ETIMEDOUT => ErrorKind::TimedOut,
-        libc::EEXIST => ErrorKind::AlreadyExists,
-        libc::ENOSYS => ErrorKind::Unsupported,
-
-        // These two constants can have the same value on some systems,
-        // but different values on others, so we can't use a match
-        // clause
-        x if x == libc::EAGAIN || x == libc::EWOULDBLOCK => ErrorKind::WouldBlock,
-
-        _ => ErrorKind::Other,
-    }
-}
-
-#[doc(hidden)]
-pub trait IsMinusOne {
-    fn is_minus_one(&self) -> bool;
-}
-
-macro_rules! impl_is_minus_one {
-    ($($t:ident)*) => ($(impl IsMinusOne for $t {
-        fn is_minus_one(&self) -> bool {
-            *self == -1
-        }
-    })*)
-}
-
-impl_is_minus_one! { i8 i16 i32 i64 isize }
-
-pub fn cvt<T: IsMinusOne>(t: T) -> crate::io::Result<T> {
-    if t.is_minus_one() { Err(crate::io::Error::last_os_error()) } else { Ok(t) }
-}
-
-pub fn cvt_r<T, F>(mut f: F) -> crate::io::Result<T>
-where
-    T: IsMinusOne,
-    F: FnMut() -> T,
-{
-    loop {
-        match cvt(f()) {
-            Err(ref e) if e.kind() == ErrorKind::Interrupted => {}
-            other => return other,
-        }
-    }
-}
-
-// On Unix-like platforms, libc::abort will unregister signal handlers
-// including the SIGABRT handler, preventing the abort from being blocked, and
-// fclose streams, with the side effect of flushing them so libc buffered
-// output will be printed.  Additionally the shell will generally print a more
-// understandable error message like "Abort trap" rather than "Illegal
-// instruction" that intrinsics::abort would cause, as intrinsics::abort is
-// implemented as an illegal instruction.
-pub fn abort_internal() -> ! {
-    unsafe { libc::abort() }
-}
diff --git a/library/std/src/sys/vxworks/process/mod.rs b/library/std/src/sys/vxworks/process/mod.rs
deleted file mode 100644
index dc6130eaa24..00000000000
--- a/library/std/src/sys/vxworks/process/mod.rs
+++ /dev/null
@@ -1,9 +0,0 @@
-pub use self::process_common::{Command, CommandArgs, ExitCode, Stdio, StdioPipes};
-pub use self::process_inner::{ExitStatus, Process};
-pub use crate::ffi::OsString as EnvKey;
-pub use crate::sys_common::process::CommandEnvs;
-
-#[path = "../../unix/process/process_common.rs"]
-mod process_common;
-#[path = "process_vxworks.rs"]
-mod process_inner;
diff --git a/library/std/src/sys/vxworks/rand.rs b/library/std/src/sys/vxworks/rand.rs
deleted file mode 100644
index 3a1ff5fd3b9..00000000000
--- a/library/std/src/sys/vxworks/rand.rs
+++ /dev/null
@@ -1,36 +0,0 @@
-use crate::mem;
-use crate::slice;
-
-pub fn hashmap_random_keys() -> (u64, u64) {
-    let mut v = (0, 0);
-    unsafe {
-        let view = slice::from_raw_parts_mut(&mut v as *mut _ as *mut u8, mem::size_of_val(&v));
-        imp::fill_bytes(view);
-    }
-    return v;
-}
-
-mod imp {
-    use crate::io;
-    use core::sync::atomic::{AtomicBool, Ordering::Relaxed};
-
-    pub fn fill_bytes(v: &mut [u8]) {
-        static RNG_INIT: AtomicBool = AtomicBool::new(false);
-        while !RNG_INIT.load(Relaxed) {
-            let ret = unsafe { libc::randSecure() };
-            if ret < 0 {
-                panic!("couldn't generate random bytes: {}", io::Error::last_os_error());
-            } else if ret > 0 {
-                RNG_INIT.store(true, Relaxed);
-                break;
-            }
-            unsafe { libc::usleep(10) };
-        }
-        let ret = unsafe {
-            libc::randABytes(v.as_mut_ptr() as *mut libc::c_uchar, v.len() as libc::c_int)
-        };
-        if ret < 0 {
-            panic!("couldn't generate random bytes: {}", io::Error::last_os_error());
-        }
-    }
-}
diff --git a/library/std/src/sys/vxworks/thread_local_dtor.rs b/library/std/src/sys/vxworks/thread_local_dtor.rs
deleted file mode 100644
index 5391ed83ebc..00000000000
--- a/library/std/src/sys/vxworks/thread_local_dtor.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-#![cfg(target_thread_local)]
-#![unstable(feature = "thread_local_internals", issue = "none")]
-
-pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) {
-    use crate::sys_common::thread_local_dtor::register_dtor_fallback;
-    register_dtor_fallback(t, dtor);
-}