about summary refs log tree commit diff
path: root/src/libstd/os
diff options
context:
space:
mode:
authorBaoshan Pang <baoshan.pang@windriver.com>2019-07-15 23:57:53 -0700
committerBaoshan Pang <baoshan.pang@windriver.com>2019-07-16 00:13:07 -0700
commit4c0c0f6158b464ee5070b32bb37f2863d0eff012 (patch)
tree3306eadf9f3bb9023cfca1fc16b44e18132916e9 /src/libstd/os
parent4a95e9704de0eeaecba55df102c1129e79a3a929 (diff)
downloadrust-4c0c0f6158b464ee5070b32bb37f2863d0eff012.tar.gz
rust-4c0c0f6158b464ee5070b32bb37f2863d0eff012.zip
Add supporting for vxWorks
r? @alexcrichton
Diffstat (limited to 'src/libstd/os')
-rw-r--r--src/libstd/os/mod.rs3
-rw-r--r--src/libstd/os/raw/mod.rs8
-rw-r--r--src/libstd/os/vxworks/fs.rs84
-rw-r--r--src/libstd/os/vxworks/mod.rs6
-rw-r--r--src/libstd/os/vxworks/raw.rs7
5 files changed, 107 insertions, 1 deletions
diff --git a/src/libstd/os/mod.rs b/src/libstd/os/mod.rs
index 94e8b7805cf..c9aa5f4de95 100644
--- a/src/libstd/os/mod.rs
+++ b/src/libstd/os/mod.rs
@@ -24,7 +24,7 @@ cfg_if::cfg_if! {
         // If we're not documenting libstd then we just expose the main modules
         // as we otherwise would.
 
-        #[cfg(any(target_os = "redox", unix))]
+        #[cfg(any(target_os = "redox", unix, target_os = "vxworks"))]
         #[stable(feature = "rust1", since = "1.0.0")]
         pub use crate::sys::ext as unix;
 
@@ -51,6 +51,7 @@ cfg_if::cfg_if! {
 #[cfg(target_os = "fuchsia")]    pub mod fuchsia;
 #[cfg(target_os = "hermit")]     pub mod hermit;
 #[cfg(target_os = "wasi")]       pub mod wasi;
+#[cfg(target_os = "vxworks")]    pub mod vxworks;
 #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))] pub mod fortanix_sgx;
 
 pub mod raw;
diff --git a/src/libstd/os/raw/mod.rs b/src/libstd/os/raw/mod.rs
index e9043b4b40d..c0b0b6d40d8 100644
--- a/src/libstd/os/raw/mod.rs
+++ b/src/libstd/os/raw/mod.rs
@@ -25,6 +25,10 @@
                                         target_arch = "arm",
                                         target_arch = "powerpc")),
           all(target_os = "openbsd", target_arch = "aarch64"),
+          all(target_os = "vxworks", any(target_arch = "aarch64",
+                                         target_arch = "arm",
+                                         target_arch = "powerpc64",
+                                         target_arch = "powerpc")),
           all(target_os = "fuchsia", target_arch = "aarch64")))]
 #[stable(feature = "raw_os", since = "1.1.0")] pub type c_char = u8;
 #[doc(include = "os/raw/char.md")]
@@ -44,6 +48,10 @@
                                             target_arch = "arm",
                                             target_arch = "powerpc")),
               all(target_os = "openbsd", target_arch = "aarch64"),
+              all(target_os = "vxworks", any(target_arch = "aarch64",
+                                             target_arch = "arm",
+                                             target_arch = "powerpc64",
+                                             target_arch = "powerpc")),
               all(target_os = "fuchsia", target_arch = "aarch64"))))]
 #[stable(feature = "raw_os", since = "1.1.0")] pub type c_char = i8;
 #[doc(include = "os/raw/schar.md")]
diff --git a/src/libstd/os/vxworks/fs.rs b/src/libstd/os/vxworks/fs.rs
new file mode 100644
index 00000000000..57ab4fb943e
--- /dev/null
+++ b/src/libstd/os/vxworks/fs.rs
@@ -0,0 +1,84 @@
+#![stable(feature = "metadata_ext", since = "1.1.0")]
+
+use crate::fs::Metadata;
+use crate::sys_common::AsInner;
+
+///
+/// [`fs::Metadata`]: ../../../../std/fs/struct.Metadata.html
+#[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_mtime(&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_blksize(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_blocks(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_attrib(&self) -> u8;
+}
+
+#[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_mtime(&self) -> i64 {
+        self.as_inner().as_inner().st_mtime as i64
+    }
+    fn st_ctime(&self) -> i64 {
+        self.as_inner().as_inner().st_ctime 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
+    }
+    fn st_attrib(&self) -> u8 {
+        self.as_inner().as_inner().st_attrib as u8
+    }
+}
diff --git a/src/libstd/os/vxworks/mod.rs b/src/libstd/os/vxworks/mod.rs
new file mode 100644
index 00000000000..2255a103d35
--- /dev/null
+++ b/src/libstd/os/vxworks/mod.rs
@@ -0,0 +1,6 @@
+//! VxWorks-specific definitions
+
+#![stable(feature = "raw_ext", since = "1.1.0")]
+
+pub mod raw;
+pub mod fs;
diff --git a/src/libstd/os/vxworks/raw.rs b/src/libstd/os/vxworks/raw.rs
new file mode 100644
index 00000000000..ae0560a5a92
--- /dev/null
+++ b/src/libstd/os/vxworks/raw.rs
@@ -0,0 +1,7 @@
+//! VxWorks-specific raw type definitions
+#![stable(feature = "metadata_ext", since = "1.1.0")]
+
+use crate::os::raw::{c_ulong};
+
+#[stable(feature = "pthread_t", since = "1.8.0")]
+pub type pthread_t = c_ulong;