diff options
| author | bors <bors@rust-lang.org> | 2019-09-24 21:46:26 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-09-24 21:46:26 +0000 |
| commit | dcd473d7b554a82013913244da8aba1e22a002a9 (patch) | |
| tree | e3d95102edba19987d74cf0c961be6c86d5d8cab /src/libstd | |
| parent | 6ef275e6c3cb1384ec78128eceeb4963ff788dca (diff) | |
| parent | aeb24142be8f39975c72a63f57c70d0adc6cc7a6 (diff) | |
| download | rust-dcd473d7b554a82013913244da8aba1e22a002a9.tar.gz rust-dcd473d7b554a82013913244da8aba1e22a002a9.zip | |
Auto merge of #64751 - Centril:rollup-hpbmcfj, r=Centril
Rollup of 16 pull requests Successful merges: - #63356 (Issue#63183: Add fs::read_dir() and ReadDir warning about iterator order + example) - #63934 (Fix coherence checking for impl trait in type aliases) - #64016 (Streamline `Compiler`) - #64296 (Document the unstable iter_order_by library feature) - #64443 (rustdoc: general cleanup) - #64622 (Add a cycle detector for generic `Graph`s and `mir::Body`s) - #64689 (Refactor macro by example) - #64698 (Recover on `const X = 42;` and infer type + Error Stash API) - #64702 (Remove unused dependencies) - #64717 (update mem::discriminant test to use assert_eq and assert_ne over comparison operators) - #64720 ( remove rtp.rs, and move rtpSpawn and RTP_ID_ERROR to libc) - #64721 (Fixed issue from #64447) - #64725 (fix one typo) - #64737 (fix several issues in String docs) - #64742 (relnotes: make compatibility section more sterile and fix rustc version) - #64748 (Fix #64744. Account for the Zero sub-pattern case.) Failed merges: r? @ghost
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/Cargo.toml | 3 | ||||
| -rw-r--r-- | src/libstd/fs.rs | 25 | ||||
| -rw-r--r-- | src/libstd/sys/vxworks/process/mod.rs | 1 | ||||
| -rw-r--r-- | src/libstd/sys/vxworks/process/process_vxworks.rs | 5 | ||||
| -rw-r--r-- | src/libstd/sys/vxworks/process/rtp.rs | 298 |
5 files changed, 27 insertions, 305 deletions
diff --git a/src/libstd/Cargo.toml b/src/libstd/Cargo.toml index af1d2402f88..ee4b367b5c5 100644 --- a/src/libstd/Cargo.toml +++ b/src/libstd/Cargo.toml @@ -53,9 +53,6 @@ fortanix-sgx-abi = { version = "0.3.2", features = ['rustc-dep-of-std'] } [target.wasm32-wasi.dependencies] wasi = { version = "0.7.0", features = ['rustc-dep-of-std', 'alloc'] } -[build-dependencies] -cc = "1.0" - [features] default = ["std_detect_file_io", "std_detect_dlsym_getauxval"] diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index b5265fe369e..8933f027a06 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -114,6 +114,9 @@ pub struct Metadata(fs_imp::FileAttr); /// information like the entry's path and possibly other metadata can be /// learned. /// +/// The order in which this iterator returns entries is platform and filesystem +/// dependent. +/// /// # Errors /// /// This [`io::Result`] will be an [`Err`] if there's some sort of intermittent @@ -1962,6 +1965,9 @@ pub fn remove_dir_all<P: AsRef<Path>>(path: P) -> io::Result<()> { /// /// [changes]: ../io/index.html#platform-specific-behavior /// +/// The order in which this iterator returns entries is platform and filesystem +/// dependent. +/// /// # Errors /// /// This function will return an error in the following situations, but is not @@ -1994,6 +2000,25 @@ pub fn remove_dir_all<P: AsRef<Path>>(path: P) -> io::Result<()> { /// Ok(()) /// } /// ``` +/// +/// ```rust,no_run +/// use std::{fs, io}; +/// +/// fn main() -> io::Result<()> { +/// let mut entries = fs::read_dir(".")? +/// .map(|res| res.map(|e| e.path())) +/// .collect::<Result<Vec<_>, io::Error>>()?; +/// +/// // The order in which `read_dir` returns entries is not guaranteed. If reproducible +/// // ordering is required the entries should be explicitly sorted. +/// +/// entries.sort(); +/// +/// // The entries have now been sorted by their path. +/// +/// Ok(()) +/// } +/// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn read_dir<P: AsRef<Path>>(path: P) -> io::Result<ReadDir> { fs_imp::readdir(path.as_ref()).map(ReadDir) diff --git a/src/libstd/sys/vxworks/process/mod.rs b/src/libstd/sys/vxworks/process/mod.rs index 1fc88fbde74..3ecbe4e3b28 100644 --- a/src/libstd/sys/vxworks/process/mod.rs +++ b/src/libstd/sys/vxworks/process/mod.rs @@ -5,4 +5,3 @@ pub use crate::ffi::OsString as EnvKey; mod process_common; #[path = "process_vxworks.rs"] mod process_inner; -mod rtp; diff --git a/src/libstd/sys/vxworks/process/process_vxworks.rs b/src/libstd/sys/vxworks/process/process_vxworks.rs index 8780df17a1c..beb20aa4816 100644 --- a/src/libstd/sys/vxworks/process/process_vxworks.rs +++ b/src/libstd/sys/vxworks/process/process_vxworks.rs @@ -3,7 +3,6 @@ use libc::{self, c_int, c_char}; use libc::{RTP_ID}; use crate::sys; use crate::sys::cvt; -use crate::sys::process::rtp; use crate::sys::process::process_common::*; use crate::sys_common::thread; @@ -53,7 +52,7 @@ impl Command { t!(cvt(libc::chdir(cwd.as_ptr()))); } - let ret = rtp::rtpSpawn( + let ret = libc::rtpSpawn( self.get_argv()[0], // executing program self.get_argv().as_ptr() as *const _, // argv *sys::os::environ() as *const *const c_char, @@ -78,7 +77,7 @@ impl Command { libc::close(orig_stderr); } - if ret != rtp::RTP_ID_ERROR { + if ret != libc::RTP_ID_ERROR { p.pid = ret; Ok((p, ours)) } else { diff --git a/src/libstd/sys/vxworks/process/rtp.rs b/src/libstd/sys/vxworks/process/rtp.rs deleted file mode 100644 index 3e6e0017abc..00000000000 --- a/src/libstd/sys/vxworks/process/rtp.rs +++ /dev/null @@ -1,298 +0,0 @@ -#![allow(non_camel_case_types, unused)] - -use libc::{self, c_int, size_t, c_char, BOOL, RTP_DESC, RTP_ID, TASK_ID}; - - -// Copied directly from rtpLibCommon.h, rtpLib.h, signal.h and taskLibCommon.h (for task options) - -// **** definitions for rtpLibCommon.h **** - -pub const RTP_GLOBAL_SYMBOLS : c_int = 0x01; // register global symbols for RTP -pub const RTP_LOCAL_SYMBOLS : c_int = 0x02; // idem for local symbols -pub const RTP_ALL_SYMBOLS : c_int = (RTP_GLOBAL_SYMBOLS | RTP_LOCAL_SYMBOLS); -pub const RTP_DEBUG : c_int = 0x10; // set RTP in debug mode when created -pub const RTP_BUFFER_VAL_OFF : c_int = 0x20; // disable buffer validation for all - // system calls issued from the RTP -pub const RTP_LOADED_WAIT : c_int = 0x40; // Wait until the RTP is loaded -pub const RTP_CPU_AFFINITY_NONE : c_int = 0x80; // Remove any CPU affinity (SMP) - -// Error Status codes - -pub const M_rtpLib : c_int = 178 << 16; - -pub const S_rtpLib_INVALID_FILE : c_int = (M_rtpLib | 1); -pub const S_rtpLib_INVALID_OPTION : c_int = (M_rtpLib | 2); -pub const S_rtpLib_ACCESS_DENIED : c_int = (M_rtpLib | 3); -pub const S_rtpLib_INVALID_RTP_ID : c_int = (M_rtpLib | 4); -pub const S_rtpLib_NO_SYMBOL_TABLE : c_int = (M_rtpLib | 5); -pub const S_rtpLib_INVALID_SEGMENT_START_ADDRESS : c_int = (M_rtpLib | 6); -pub const S_rtpLib_INVALID_SYMBOL_REGISTR_POLICY : c_int = (M_rtpLib | 7); -pub const S_rtpLib_INSTANTIATE_FAILED : c_int = (M_rtpLib | 8); -pub const S_rtpLib_INVALID_TASK_OPTION : c_int = (M_rtpLib | 9); -pub const S_rtpLib_RTP_NAME_LENGTH_EXCEEDED : c_int = (M_rtpLib | 10); // rtpInfoGet - -pub const VX_RTP_NAME_LENGTH : c_int = 255; // max name length for diplay - - -// The 'status' field (32 bit integer) of a RTP holds the RTP state and status. -// -// NOTE: RTP_STATE_GET() : read the RTP state(s) -// RTP_STATE_PUT() : write the RTP state(s) -// RTP_STATE_SET() : set a RTP state -// RTP_STATE_UNSET() : unset a RTP state -// -// RTP_STATUS_GET() : read the RTP status -// RTP_STATUS_PUT() : write the RTP status -// RTP_STATUS_SET() : set a RTP status -// RTP_STATUS_UNSET() : unset a RTP status -// -// The PUT/SET/UNSET macros are available only in the kernel headers. - - -// RTP states - -pub const RTP_STATE_CREATE : c_int = 0x0001; // RrtpStructTP is under construction -pub const RTP_STATE_NORMAL : c_int = 0x0002; // RrtpStructTP is ready -pub const RTP_STATE_DELETE : c_int = 0x0004; // RrtpStructTP is being deleted - -pub const RTP_STATUS_STOP : c_int = 0x0100; // RTP hrtpStructas recieved stopped signal -pub const RTP_STATUS_ELECTED_DELETER : c_int = 0x0200; // RTP drtpStructelete has started - -pub const RTP_STATE_MASK : c_int = (RTP_STATE_CREATE | RTP_STATE_NORMAL | - RTP_STATE_DELETE); -pub const RTP_STATUS_MASK : c_int = (RTP_STATUS_STOP | RTP_STATUS_ELECTED_DELETER); - -pub fn RTP_STATE_GET (value : c_int) -> c_int { - value & RTP_STATE_MASK -} -pub fn RTP_STATUS_GET (value : c_int) -> c_int { - value & RTP_STATUS_MASK -} - -// Indicates that the RTP_ID returned is not valid. - -// RTP_ID_ERROR is supposed to be set to -1, but you can't set -// an unsigned value to a negative without casting, and you -// can't cast unless the size of the integer types are the same, -// but the size of RTP_ID may differ between kernel and user space. -// Bitwise or-ing min and max should get the same result. -pub const RTP_ID_ERROR : RTP_ID = RTP_ID::min_value() | RTP_ID::max_value(); - -// IS_RTP_ C macros - -pub fn IS_RTP_STATE_NORMAL (value : c_int) -> bool { - (RTP_STATE_GET(value) & RTP_STATE_NORMAL) == RTP_STATE_NORMAL -} -pub fn IS_RTP_STATE_CREATE (value : c_int) -> bool { - (RTP_STATE_GET(value) & RTP_STATE_CREATE) == RTP_STATE_CREATE -} -pub fn IS_RTP_STATE_DELETE (value : c_int) -> bool { - (RTP_STATE_GET(value) & RTP_STATE_DELETE) == RTP_STATE_DELETE -} -pub fn IS_RTP_STATUS_STOP (value : c_int) -> bool { - (RTP_STATUS_GET(value) & RTP_STATUS_STOP ) == RTP_STATUS_STOP -} -pub fn IS_RTP_STATUS_ELECTED_DELETER (value : c_int) -> bool { - (RTP_STATUS_GET(value) & RTP_STATUS_ELECTED_DELETER) == RTP_STATUS_ELECTED_DELETER -} - -// **** end of definitions for rtpLibCommon.h **** - - - - -// **** definitions for rtpLib.h **** - -pub fn rtpExit(exitCode : c_int) -> ! { - unsafe{ libc::exit (exitCode) } -} - -/* rtpLib.h in the kernel -pub const RTP_DEL_VIA_TASK_DELETE : c_int = 0x1; // rtpDelete() via taskDestroy() -pub const RTP_DEL_FORCE : c_int = 0x2; // Forceful rtpDelete() -pub const RTP_ID_ANY : RTP_ID = 0; // used for when a kernel task - // wants to wait for the next - // RTP to finish - - -// Function pointers - -pub type RTP_PRE_CREATE_HOOK = size_t; -pub type RTP_POST_CREATE_HOOK = size_t; -pub type RTP_INIT_COMPLETE_HOOK = size_t; -pub type RTP_DELETE_HOOK = size_t; -*/ - -// **** end of definitions for rtpLib.h **** - - - - - -// **** definitions for signal.h **** -pub fn rtpKill(rtpId : RTP_ID, signo : c_int) -> c_int { - unsafe{ libc::kill(rtpId as c_int, signo) } -} - -pub fn rtpSigqueue(rtpId : RTP_ID, signo : c_int, value : size_t) -> c_int { - unsafe{ libc::sigqueue(rtpId as c_int, signo, value) } -} - -pub fn _rtpSigqueue(rtpId : RTP_ID, signo : c_int, value : *mut size_t, code : c_int) -> c_int { - unsafe{ libc::_sigqueue(rtpId, signo, value, code) } -} - -pub fn taskRaise(signo : c_int) -> c_int { - unsafe{ libc::taskKill(libc::taskIdSelf(), signo) } -} -pub fn rtpRaise(signo : c_int) -> c_int { - unsafe{ libc::raise(signo) } -} - -// **** end of definitions for signal.h **** - - - -// **** definitions for taskLibCommon.h **** -pub const VX_PRIVATE_ENV : c_int = 0x0080; // 1 = private environment variables -pub const VX_NO_STACK_FILL : c_int = 0x0100; // 1 = avoid stack fill of 0xee -pub const VX_PRIVATE_UMASK : c_int = 0x0400; // 1 = private file creation mode mask -pub const VX_TASK_NOACTIVATE : c_int = 0x2000; // taskOpen() does not taskActivate() -pub const VX_NO_STACK_PROTECT : c_int = 0x4000; // no over/underflow stack protection, - // stack space remains executable - -// define for all valid user task options - -pub const VX_USR_TASK_OPTIONS_BASE: c_int = (VX_PRIVATE_ENV | - VX_NO_STACK_FILL | - VX_TASK_NOACTIVATE | - VX_NO_STACK_PROTECT | - VX_PRIVATE_UMASK); - -// **** end of definitions for taskLibCommon.h **** - - - -extern "C" { -// functions in rtpLibCommon.h - -// forward declarations - pub fn rtpSpawn ( - pubrtpFileName : *const c_char, - argv : *const *const c_char, - envp : *const *const c_char, - priority : c_int, - uStackSize : size_t, - options : c_int, - taskOptions : c_int, - ) -> RTP_ID; - - pub fn rtpInfoGet ( - rtpId : RTP_ID, - rtpStruct : *mut RTP_DESC, - ) -> c_int; - -/* functions in rtpLib.h for kernel - - - // function declarations - - pub fn rtpDelete ( - id : RTP_ID, - options : c_int, - status : c_int, - ) -> c_int; - - pub fn rtpDeleteForce ( - rtpId : RTP_ID - ) -> c_int; - - pub fn rtpShow ( - rtpNameOrId : *mut c_char, - level : c_int, - ) -> BOOL; - - // RTP signals are always present when RTPs are included. The public RTP - // signal APIs are declared here. - - - pub fn rtpKill ( - rtpId : RTP_ID, - signo : c_int, - ) -> c_int; - - pub fn rtpSigqueue ( - rtpId : RTP_ID, - signo : c_int, - value : size_t, // Actual type is const union sigval value, - // which is a union of int and void * - ) -> c_int; - - pub fn rtpTaskKill ( - tid : TASK_ID, - signo : c_int, - ) -> c_int; - - pub fn rtpTaskSigqueue ( - tid : TASK_ID, - signo : c_int, - value : const size_t, // Actual type is const union sigval, - // which is a union of int and void * - ) -> c_int; - - pub fn rtpWait ( - rtpWaitId : RTP_ID, - timeout : libc::alloc_jemalloc_Vx_ticks_t, - pRtpId : *mut RTP_ID, - pStatus : *mut c_int, - ) -> c_int; - - // Other public functions - - - pub fn rtpPreCreateHookAdd ( - hook : RTP_PRE_CREATE_HOOK, - addToHead : BOOL, - ) -> c_int; - - pub fn rtpPreCreateHookDelete ( - hook : RTP_POST_CREATE_HOOK, - ) -> c_int; - - pub fn rtpPostCreateHookAdd ( - hook : RTP_POST_CREATE_HOOK, - addToHead : BOOL, - ) -> c_int; - - pub fn rtpPostCreateHookDelete ( - hook : RTP_POST_CREATE_HOOK, - ) -> c_int; - - pub fn rtpInitCompleteHookAdd ( - hook : RTP_INIT_COMPLETE_HOOK, - addToHead : BOOL, - ) -> c_int; - - pub fn rtpInitCompleteHookDelete ( - hook : RTP_INIT_COMPLETE_HOOK, - ) -> c_int; - - pub fn rtpDeleteHookAdd ( - hook : RTP_DELETE_HOOK, - addToHead : BOOL, - ) -> c_int; - - pub fn rtpDeleteHookDelete ( - hook : RTP_DELETE_HOOK, - ) -> c_int; - - pub fn rtpMemShow ( - rtpNameOrId : *mut c_char, - level : c_int, - ) -> c_int; - - pub fn rtpHookShow ( - - ); -*/ -} |
