about summary refs log tree commit diff
path: root/library/std/src/sys/windows
AgeCommit message (Collapse)AuthorLines
2022-04-29Auto merge of #96441 - ChrisDenton:sync-pipes, r=m-ou-sebors-31/+107
Windows: Make stdin pipes synchronous Stdin pipes do not need to be used asynchronously within the standard library. This is a first step in making pipes mostly synchronous. r? `@m-ou-se`
2022-04-28Auto merge of #96393 - joboet:pthread_parker, r=thomccbors-7/+13
std: directly use pthread in UNIX parker implementation `Mutex` and `Condvar` are being replaced by more efficient implementations, which need thread parking themselves (see #93740). Therefore we should use the `pthread` synchronization primitives directly. Also, we can avoid allocating the mutex and condition variable because the `Parker` struct is being placed in an `Arc` anyways. This basically is just a copy of the current `Mutex` and `Condvar` code, which will however be removed (again, see #93740). An alternative implementation could be to use dedicated private `OsMutex` and `OsCondvar` types, but all the other platforms supported by std actually have their own thread parking primitives. I used `Pin` to guarantee a stable address for the `Parker` struct, while the current implementation does not, rather using extra unsafe declaration. Since the thread struct is shared anyways, I assumed this would not add too much clutter while being clearer.
2022-04-28Yield the thread when waiting to delete a fileChris Denton-0/+3
2022-04-27Note the importance of using sync pipesChris Denton-1/+19
2022-04-26Windows: Make stdin pipes synchronousChris Denton-31/+85
Stdin pipes do not need to be used asynchronously within the standard library.
2022-04-26Add `set_inheritable` for Windows `Handle`sChris Denton-0/+4
2022-04-26Retry deleting a directoryChris Denton-2/+15
It's possible that a file in the directory is pending deletion. In that case we might succeed after a few attempts.
2022-04-26Windows: Iterative `remove_dir_all`Chris Denton-77/+67
This will allow better strategies for use of memory and File handles. However, fully taking advantage of that is left to future work.
2022-04-25std: directly use pthread in UNIX parker implementationjoboet-7/+13
Mutex and Condvar are being replaced by more efficient implementations, which need thread parking themselves (see #93740). Therefore use the pthread synchronization primitives directly. Also, avoid allocating because the Parker struct is being placed in an Arc anyways.
2022-04-25Auto merge of #95246 - ChrisDenton:command-args, r=joshtriplettbors-91/+191
Windows Command: Don't run batch files using verbatim paths Fixes #95178 Note that the first commit does some minor refactoring (moving command line argument building to args.rs). The actual changes are in the second.
2022-04-23Auto merge of #96314 - AronParker:issue-96297-fix, r=thomccbors-1/+7
Reduce allocations for path conversions on Windows Previously, UTF-8 to UTF-16 Path conversions on Windows unnecessarily allocate twice, as described in #96297. This commit fixes that issue.
2022-04-23Auto merge of #94887 - dylni:move-normpath-crate-impl-to-libstd, r=ChrisDentonbors-29/+115
Improve Windows path prefix parsing This PR fixes improves parsing of Windows path prefixes. `parse_prefix` now supports both types of separators on Windows (`/` and `\`).
2022-04-22Remove redundant type annotationAron Parker-1/+1
2022-04-22Reduce allocations for path conversions on WindowsAron Parker-1/+7
Previously, UTF-8 to UTF-16 Path conversions on Windows unnecessarily allocate twice, as described in #96297. This commit fixes that issue.
2022-04-17Improve Windows path prefix parsingdylni-29/+115
2022-04-16Use a single ReentrantMutex implementation on all platforms.Mara Bos-50/+1
2022-04-15Auto merge of #94079 - petrochenkov:cstr, r=joshtriplettbors-1/+0
library: Move `CStr` to libcore, and `CString` to liballoc Closes https://github.com/rust-lang/rust/issues/46736 Interesting points: - Stability: - To make `CStr(ing)` from libcore/liballoc unusable without enabling features I had to make these structures unstable, and reexport them from libstd using stable type aliases instead of `pub use` reexports. (Because stability of `use` items is not checked.) - Relying on target ABI in libcore is ok: - https://github.com/rust-lang/rust/pull/94079#issuecomment-1044263371 - `trait CStrExt` (UPDATE: used only in `cfg(bootstrap)` mode, otherwise lang items are used instead) - https://github.com/rust-lang/rust/pull/94079#issuecomment-1047863450 - `strlen` - https://github.com/rust-lang/rust/pull/94079#issuecomment-1047863450 Otherwise it's just a code move + some minor hackery usual for liballoc in `cfg(test)` mode.
2022-04-15Auto merge of #95841 - ChrisDenton:pipe-server, r=m-ou-sebors-1/+50
Windows: Use a pipe relay for chaining pipes Fixes #95759 This fixes the issue by chaining pipes synchronously and manually pumping messages between them. It's not ideal but it has the advantage of not costing anything if pipes are not chained ("don't pay for what you don't use") and it also avoids breaking existing code that rely on our end of the pipe being asynchronous (which includes rustc's own testing framework). Libraries can avoid needing this by using their own pipes to chain commands.
2022-04-14library: Remove definitions and reexports of `strlen` from libstdVadim Petrochenkov-1/+0
2022-04-09Rollup merge of #95802 - RalfJung:unused-win, r=Dylan-DPCDylan DPC-0/+1
fix unused constant warning on some Windows targets When none of those `cfg_if!` apply (and on Miri), the constant remains unused.
2022-04-08fix some unused constant warning on some Windows targetsRalf Jung-0/+1
2022-04-08Auto merge of #95798 - Dylan-DPC:rollup-51hx1wl, r=Dylan-DPCbors-2/+5
Rollup of 7 pull requests Successful merges: - #95102 (Add known-bug for #95034) - #95579 (Add `<[[T; N]]>::flatten{_mut}`) - #95634 (Mailmap update) - #95705 (Promote x86_64-unknown-none target to Tier 2 and distribute build artifacts) - #95761 (Kickstart the inner usage of `macro_metavar_expr`) - #95782 (Windows: Increase a pipe's buffer capacity to 64kb) - #95791 (hide an #[allow] directive from the Arc::new_cyclic doc example) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-04-08Windows: Use a pipe relay for chaining pipesChris Denton-1/+50
2022-04-08Auto merge of #95775 - RalfJung:miri-windows-compat, r=ChrisDentonbors-8/+17
make windows compat_fn (crudely) work on Miri With https://github.com/rust-lang/rust/pull/95469, Windows `compat_fn!` now has to be supported by Miri to even make stdout work. Unfortunately, it relies on some outside-of-Rust linker hacks (`#[link_section = ".CRT$XCU"]`) that are rather hard to make work in Miri. So I came up with this crude hack to make this stuff work in Miri regardless. It should come at no cost for regular executions, so I hope this is okay. Cc https://github.com/rust-lang/rust/issues/95627 `@ChrisDenton`
2022-04-07Windows: Increase a pipe's buffer capacity to 64kbChris Denton-2/+5
This brings it inline with typical Linux defaults: https://www.man7.org/linux/man-pages/man7/pipe.7.html
2022-04-07do not round-trip function pointer through integerRalf Jung-5/+4
2022-04-07make windows compat_fn (crudely) work on MiriRalf Jung-4/+14
2022-04-06Rename RWLock to RwLock in std::sys.Mara Bos-8/+8
2022-04-05Use rtabortChris Denton-2/+1
2022-04-05Make `synchronous_write` safe to callChris Denton-23/+18
2022-04-05Complete reads and writes synchronously or abortChris Denton-66/+137
2022-04-05Correct definition of `IO_STATUS_BLOCK`Chris Denton-5/+11
2022-04-04Rollup merge of #95467 - ChrisDenton:async-read-pipe, r=joshtriplettDylan DPC-2/+140
Windows: Synchronize asynchronous pipe reads and writes On Windows, the pipes used for spawned processes are opened for asynchronous access but `read` and `write` are done using the standard methods that assume synchronous access. This means that the buffer (and variables on the stack) may be read/written to after the function returns. This PR ensures reads/writes complete before returning. Note that this only applies to pipes we create and does not affect the standard file read/write methods. Fixes #95411
2022-04-04Correct calling conventionChris Denton-2/+2
2022-04-04Update library/std/src/sys/windows/pipe.rsChris Denton-4/+6
2022-03-30Synchronize asynchronous pipe reads and writesChris Denton-2/+138
2022-03-29Make the stdlib largely conform to strict provenance.Aria Beingessner-16/+19
Some things like the unwinders and system APIs are not fully conformant, this only covers a lot of low-hanging fruit.
2022-03-25Check for `"` and `\` in a filenameChris Denton-1/+9
And also fix typo.
2022-03-23Auto merge of #95173 - m-ou-se:sys-locks-module, r=dtolnaybors-5/+9
Move std::sys::{mutex, condvar, rwlock} to std::sys::locks. This cleans up the the std::sys modules a bit by putting the locks in a single module called `locks` rather than spread over the three modules `mutex`, `condvar`, and `rwlock`. This makes it easier to organise lock implementations, which helps with https://github.com/rust-lang/rust/issues/93740.
2022-03-23Command: handle exe and batch files separatelyChris Denton-22/+113
2022-03-23Refactor: Move argument building into argsChris Denton-69/+70
2022-03-22Move std::sys::{mutex, condvar, rwlock} to std::sys::locks.Mara Bos-5/+9
2022-03-19Skip a test if symlink creation is not possibleChris Denton-2/+9
2022-03-19Rollup merge of #92519 - ChrisDenton:command-maybe-verbatim, r=dtolnayDylan DPC-30/+44
Use verbatim paths for `process::Command` if necessary In #89174, the standard library started using verbatim paths so longer paths are usable by default. However, `Command` was originally left out because of the way `CreateProcessW` was being called. This was changed as a side effect of #87704 so now `Command` paths can be converted to verbatim too (if necessary).
2022-03-10Use implicit capture syntax in format_argsT-O-R-U-S-5/+3
This updates the standard library's documentation to use the new syntax. The documentation is worthwhile to update as it should be more idiomatic (particularly for features like this, which are nice for users to get acquainted with). The general codebase is likely more hassle than benefit to update: it'll hurt git blame, and generally updates can be done by folks updating the code if (and when) that makes things more readable with the new format. A few places in the compiler and library code are updated (mostly just due to already having been done when this commit was first authored).
2022-03-09Use `unreachable!` for an unreachable code pathChris Denton-1/+7
2022-03-04Rollup merge of #94618 - lewisclark:remove-stack-size-rounding, r=yaahcDylan DPC-4/+1
Don't round stack size up for created threads in Windows Fixes #94454 Windows does the rounding itself, so there isn't a need to explicity do the rounding beforehand, as mentioned by ```@ChrisDenton``` in #94454 > The operating system rounds up the specified size to the nearest multiple of the system's allocation granularity (typically 64 KB). To retrieve the allocation granularity of the current system, use the [GetSystemInfo](https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsysteminfo) function. https://docs.microsoft.com/en-us/windows/win32/procthread/thread-stack-size
2022-03-04Don't round stack size up for created threadsLewis Clark-4/+1
2022-03-03Use `HandleOrNull` and `HandleOrInvalid` in the Windows FFI bindings.Dan Gohman-17/+21
Use the new `HandleOrNull` and `HandleOrInvalid` types that were introduced as part of [I/O safety] in a few functions in the Windows FFI bindings. This factors out an `unsafe` block and two `unsafe` function calls in the Windows implementation code. And, it helps test `HandleOrNull` and `HandleOrInvalid`, which indeed turned up a bug: `OwnedHandle` also needs to be `#[repr(transparent)]`, as it's used inside of `HandleOrNull` and `HandleOrInvalid` which are also `#[repr(transparent)]`. [I/O safety]: https://github.com/rust-lang/rust/issues/87074
2022-03-01Provide C FFI types via core::ffi, not just in stdJosh Triplett-1/+1
The ability to interoperate with C code via FFI is not limited to crates using std; this allows using these types without std. The existing types in `std::os::raw` become type aliases for the ones in `core::ffi`. This uses type aliases rather than re-exports, to allow the std types to remain stable while the core types are unstable. This also moves the currently unstable `NonZero_` variants and `c_size_t`/`c_ssize_t`/`c_ptrdiff_t` types to `core::ffi`, while leaving them unstable.