summary refs log tree commit diff
path: root/library/std/src/sys/windows
AgeCommit message (Collapse)AuthorLines
2020-10-02Auto merge of #77029 - ehuss:command-access, r=dtolnaybors-1/+47
Add accessors to Command. This adds some accessor methods to `Command` to provide a way to access the values set when building the `Command`. An example where this can be useful is to display the command to be executed. This is roughly based on the [`ProcessBuilder`](https://github.com/rust-lang/cargo/blob/13b73cdaf76b2d9182515c9cf26a8f68342d08ef/src/cargo/util/process_builder.rs#L105-L134) in Cargo. Possible concerns about the API: - Values with NULs on Unix will be returned as `"<string-with-nul>"`. I don't think it is practical to avoid this, since otherwise a whole separate copy of all the values would need to be kept in `Command`. - Does not handle `arg0` on Unix. This can be awkward to support in `get_args` and is rarely used. I figure if someone really wants it, it can be added to `CommandExt` as a separate method. - Does not offer a way to detect `env_clear`. I'm uncertain if it would be useful for anyone. - Does not offer a way to get an environment variable by name (`get_env`). I figure this can be added later if anyone really wants it. I think the motivation for this is weak, though. Also, the API could be a little awkward (return a `Option<Option<&OsStr>>`?). - `get_envs` could skip "cleared" entries and just return `&OsStr` values instead of `Option<&OsStr>`. I'm on the fence here. My use case is to display a shell command, and I only intend it to be roughly equivalent to the actual execution, and I probably won't display `None` entries. I erred on the side of providing extra information, but I suspect many situations will just filter out the `None`s. - Could implement more iterator stuff (like `DoubleEndedIterator`). I have not implemented new std items before, so I'm uncertain if the existing issue should be reused, or if a new tracking issue is needed. cc #44434
2020-10-01Work around potential merging/duplication issues in sys/windows/compat.Mara Bos-3/+19
2020-10-01Formatting.Mara Bos-5/+1
2020-10-01Use AcquireSRWLockExclusive::is_available() instead of an extra lookup.Mara Bos-17/+6
2020-10-01Improve std::sys::windows::compat.Mara Bos-28/+35
- Module name can now be any string, not just an ident. (Not all Windows api modules are valid Rust identifiers.) - Adds c::FuncName::is_available() for checking if a function is really available without having to do a duplicate lookup. - Add comment explaining the lack of locking. - Use `$_:block` to simplify the macro_rules. - Apply allow(unused_variables) only to the fallback instead of everything.
2020-09-26Add accessors to Command.Eric Huss-1/+47
2020-09-16Avoid creating `&mut`s in Windows ReentrantMutex.Mara Bos-7/+7
2020-09-16Don't use `mut` in Windows Mutex.Mara Bos-9/+7
2020-09-12Small cleanups in Windows Mutex.Mara Bos-32/+32
- Move `held` into the boxed part, since the SRW lock implementation does not use this. This makes the Mutex 50% smaller. - Use `Cell` instead of `UnsafeCell` for `held`, such that `.replace()` can be used. - Add some comments.
2020-09-11Update `std::os` module documentation.Christiaan Dirkx-1/+3
Adds missing descriptions for the modules std::os::linux::fs and std::os::windows::io. Also adds punctuation for consistency with other descriptions.
2020-09-08Capitalize safety commentsFlying-Toast-2/+2
2020-08-31std: move "mod tests/benches" to separate filesLzu Tao-121/+114
Also doing fmt inplace as requested.
2020-08-29Explicitly look for 'thumb-mode' before using __fastfail on 'arm'Ryan Levick-1/+1
2020-08-28Back to opcode for 32 bit ARM __fastfailRyan Levick-1/+1
2020-08-28Switch to asm! macro and use brk instruction on ARMRyan Levick-3/+3
2020-08-27Add __fastfail for Windows on arm/aarch64Ryan Levick-3/+13
2020-08-25Auto merge of #75364 - rylev:libpanic-abort-failfast, r=alexcrichtonbors-8/+4
Call into fastfail on abort in libpanic_abort on Windows x86(_64) This partially resolves #73215 though this is only for x86 targets. This code is directly lifted from [libstd](https://github.com/rust-lang/rust/blob/13290e83a6e20f3b408d177a9d64d8cf98fe4615/library/std/src/sys/windows/mod.rs#L315). `__fastfail` is the preferred way to abort a process on Windows as it will hook into debugger toolchains. Other platforms expose a `_rust_abort` symbol which wraps `std::sys::abort_internal`. This would also work on Windows, but is a slightly largely change as we'd need to make sure that the symbol is properly exposed to the linker. I'm inlining the call to the `__fastfail`, but the indirection through `rust_abort` might be a cleaner approach. A different instruction must be used on ARM architectures. I'd like to verify this works first before tackling ARM.
2020-08-21Make raw standard stream constructors constTomasz Miąsko-6/+6
2020-08-21Remove result type from raw standard streams constructorsTomasz Miąsko-14/+14
Raw standard streams constructors are infallible. Remove unnecessary result type.
2020-08-16Switch to intra-doc links in /sys/windows/ext/{ffi,fs,process}.rsPrabakaran Kumaresshan-34/+8
2020-08-10Reverse formattingRyan Levick-5/+1
2020-08-10Fix up docsRyan Levick-9/+9
2020-07-28Get pointer from address of c directlyLzu Tao-2/+2
2020-07-28Make use of macro to avoid repetitionLzu Tao-23/+10
2020-07-28Remove redundant len bindingLzu Tao-3/+1
2020-07-27mv std libs to library/mark-0/+7710