about summary refs log tree commit diff
path: root/src/libstd/sys
AgeCommit message (Collapse)AuthorLines
2016-03-09std: Don't spawn threads in `wait_with_output`Alex Crichton-17/+438
Semantically there's actually no reason for us to spawn threads as part of the call to `wait_with_output`, and that's generally an incredibly heavyweight operation for just reading a few bytes (especially when stderr probably rarely has bytes!). An equivalent operation in terms of what's implemented today would be to just drain both pipes of all contents and then call `wait` on the child process itself. On Unix we can implement this through some convenient use of the `select` function, whereas on Windows we can make use of overlapped I/O. Note that on Windows this requires us to use named pipes instead of anonymous pipes, but they're semantically the same under the hood.
2016-03-08std: Don't always create stdin for childrenAlex Crichton-7/+12
For example if `Command::output` or `Command::status` is used then stdin is just immediately closed. Add an option for this so as an optimization we can avoid creating pipes entirely. This should help reduce the number of active file descriptors when spawning processes on Unix and the number of active handles on Windows.
2016-03-08std: Funnel read_to_end through to one locationAlex Crichton-4/+114
This pushes the implementation detail of proxying `read_to_end` through to `read_to_end_uninitialized` all the way down to the `FileDesc` and `Handle` implementations on Unix/Windows. This way intermediate layers will also be able to take advantage of this optimized implementation. This commit also adds the optimized implementation for `ChildStdout` and `ChildStderr`.
2016-03-08Auto merge of #31986 - ashleysommer:emscripten_fixes, r=alexcrichtonbors-3/+7
Fix building libstd on emscripten targets. The main cause of the problem is that libstd/os/mod.rs treats emscripten targets as an alias of linux targets, whereas liblibc treats emscripten targets as musl-compliant, so it gets a slightly different struct stat64 defined. This commit adds conditional compilation checks to use the correct timestamp format on fs metadata functions in the case of compiling to emscripten targets. This commit also depends needs https://github.com/ashleysommer/rust/commit/f1575cff2d631e977038fdba3fa3422ba5f8f2fe applied in order to successfully build libstd with emscripten target.
2016-03-07Fix building libstd on on emscripten targets.ashleysommer-3/+7
Squashed 10 commits: 1) The main cause of the problem is that libstd/os/mod.rs treats emscripten targets as an alias of linux targets, whereas liblibc treats emscripten targets as musl-compliant, so it gets a slightly different struct stat64 defined. This commit adds conditional compilation checks to use the correct timestamp format on fs metadata functions in the case of compiling to emscripten targets. 2) Update previous commit to comply with rust formatting standards. Removed tab characters, remove trailing whitespaces. 3) Move emscripten changes into their own file under libstd/os/emscripten Put libstd/os/linux/fs back to the way it was. 4) Cannot use stat.st_ctim on emscripten to get created time. 5) Remove compile-time conditionals for target_env = musl, it looks like musl builds compile fine already. 6) Undone some formatting changes that are no longer needed, Removed some more target_env="musl" compilation checks that I missed from my previous commit. 7) upgrade to liblibc e19309c, it fixes the differences in the musl stat and stat64 definitions. 8) Undo the compile-time checks to check for emscripten (or musl targets) in the FileAttr struct. No longer needed after updating liblibc to e19309c. 9) Change the MetadataExt implementation of emscripten fs.rs module to match the changes in new liblibc. 10) remove a stray return statement, should have been removed in the previous commit.
2016-03-06rustbuild: fix cross compilation of libstd to i686-unknown-linux-muslJorge Aparicio-2/+8
- make sure we copy the third party objects (crt*.o) to the target stage directory. - apply the x86_64-musl logic also to the i686-musl target.
2016-03-04Auto merge of #31945 - sfackler:net2, r=alexcrichtonbors-3/+286
I have these tagged as stable in 1.9, so this shouldn't merge until the 1.8 beta's cut.
2016-03-03Fix netbsdSteven Fackler-4/+4
2016-03-03Fix android buildSteven Fackler-3/+3
2016-03-02Fix comments and OSX buildSteven Fackler-3/+21
2016-02-29std: Stabilize APIs for the 1.8 releaseAlex Crichton-2/+2
This commit is the result of the FCPs ending for the 1.8 release cycle for both the libs and the lang suteams. The full list of changes are: Stabilized * `braced_empty_structs` * `augmented_assignments` * `str::encode_utf16` - renamed from `utf16_units` * `str::EncodeUtf16` - renamed from `Utf16Units` * `Ref::map` * `RefMut::map` * `ptr::drop_in_place` * `time::Instant` * `time::SystemTime` * `{Instant,SystemTime}::now` * `{Instant,SystemTime}::duration_since` - renamed from `duration_from_earlier` * `{Instant,SystemTime}::elapsed` * Various `Add`/`Sub` impls for `Time` and `SystemTime` * `SystemTimeError` * `SystemTimeError::duration` * Various impls for `SystemTimeError` * `UNIX_EPOCH` * `ops::{Add,Sub,Mul,Div,Rem,BitAnd,BitOr,BitXor,Shl,Shr}Assign` Deprecated * Scoped TLS (the `scoped_thread_local!` macro) * `Ref::filter_map` * `RefMut::filter_map` * `RwLockReadGuard::map` * `RwLockWriteGuard::map` * `Condvar::wait_timeout_with` Closes #27714 Closes #27715 Closes #27746 Closes #27748 Closes #27908 Closes #29866
2016-02-28Fix windowsSteven Fackler-131/+55
Also back out keepalive support for TCP since the API is perhaps not actually what we want. You can't read the interval on Windows, and we should probably separate the functionality of turning keepalive on and overriding the interval.
2016-02-28Add UDP functionality from net2Steven Fackler-3/+135
2016-02-28Add TCP functionality from net2Steven Fackler-0/+209
2016-02-27Auto merge of #31914 - bluss:copy-from-slice-everywhere, r=alexcrichtonbors-1/+1
Use .copy_from_slice() where applicable .copy_from_slice() does the same job of .clone_from_slice(), but the former is explicitly for Copy elements and calls `memcpy` directly, and thus is it efficient without optimization too.
2016-02-26Auto merge of #31876 - ollie27:win_fill_bytes, r=brsonbors-7/+11
CryptGenRandom takes a DWORD (u32) for the length so it only supports writing u32::MAX bytes at a time. Casting the length from a usize caused truncation meaning the whole buffer was not always filled. cc #31841 This is the same as rust-lang-nursery/rand#99. I think it's a good idea to keep the implementations in sync. r? @alexcrichton
2016-02-26Auto merge of #31858 - alexcrichton:fix-networking-cast, r=brsonbors-5/+10
Similar to #31825 where the read/write limits were capped for files, this implements similar limits when reading/writing networking types. On Unix this shouldn't affect anything because the write size is already a `usize`, but on Windows this will cap the read/write amounts to `i32::max_value`. cc #31841
2016-02-26Use .copy_from_slice() where applicableUlrik Sverdrup-1/+1
.copy_from_slice() does the same job of .clone_from_slice(), but the former is explicitly for Copy elements and calls `memcpy` directly, and thus is it efficient without optimization too.
2016-02-25Rollup merge of #31362 - jseyfried:fix_extern_crate_visibility, r=nikomatsakisManish Goregaokar-1/+1
This PR changes the visibility of extern crate declarations to match that of items (fixes #26775). To avoid breakage, the PR makes it a `public_in_private` lint to reexport a private extern crate, and it adds the lint `inaccessible_extern_crate` for uses of an inaccessible extern crate. The lints can be avoided by making the appropriate `extern crate` declaration public.
2016-02-25rand: Fix filling buffers 4 GiB or larger with OsRng::fill_bytes on WindowsOliver Middleton-7/+11
CryptGenRandom takes a DWORD (u32) for the length so it only supports writing u32::MAX bytes at a time. Casting the length from a usize caused truncation meaning the whole buffer was not always filled.
2016-02-25Rollup merge of #31842 - dileepbapat:master, r=alexcrichtonManish Goregaokar-3/+2
I have made changes and built it after that. Please advise, https://github.com/rust-lang/rust/issues/31820
2016-02-24std: Cap read/write limits on Windows networkingAlex Crichton-5/+10
Similar to #31825 where the read/write limits were capped for files, this implements similar limits when reading/writing networking types. On Unix this shouldn't affect anything because the write size is already a `usize`, but on Windows this will cap the read/write amounts to `i32::max_value`. cc #31841
2016-02-24Auto merge of #31782 - pitdicker:clean_out_windows_c, r=alexcrichtonbors-210/+38
I am not entirely sure I have got everything right, but if it compiles it is ok probably... I tested it with msvc x86_64 and gnu. Somehow a lot of `EXCEPTION-*` constants are dead code when running test, no idea why. I have put `#![cfg_attr(test, allow(dead_code))]` at the top for this.
2016-02-24Auto merge of #31778 - aturon:snapshot, r=alexcrichtonbors-49/+1
r? @alexcrichton
2016-02-24Warn when reexporting a private extern crateJeffrey Seyfried-1/+1
2016-02-23#31820 - Utilize `if..let` instead of single `match` branchdileepb-3/+2
2016-02-23Register new snapshotsAaron Turon-49/+1
2016-02-23Fix reading/writing 4 GiB or larger files on Windows 64-bitOliver Middleton-5/+11
`ReadFile` and `WriteFile` take a DWORD (u32) for the length argument which was erroneously cast from a usize causing truncation. This meant methods like `write_all` and `read_exact` would unexpectedly fail if given a buffer 4 GiB or larger. We can instead just ask for `u32::MAX` bytes if the given buffer is too big.
2016-02-22Auto merge of #31813 - nbaksalyar:solaris-fix, r=sanxiynbors-1/+2
A quick fix for several issues that break a Solaris/Illumos build. Also, adds a CPU target specification (as seen in a patch for OpenBSD #31727).
2016-02-22Auto merge of #31805 - cuviper:android-lfs, r=alexcrichtonbors-1/+4
Android should use 64-bit LFS symbols for `lseek` and `ftruncate`, lest those offset parameters suffer a lossy cast down to a 32-bit `off_t`. Unlike GNU/Linux, Android's `stat`, `dirent`, and related functions are always 64-bit LFS compatible, and `open` already implies `O_LARGEFILE`, so all those don't need to follow Linux. It might be nice to unify them anyway, but those other LFS symbols aren't present in API 18 bionic. r? @alexcrichton
2016-02-22Fix broken Solaris buildNikita Baksalyar-1/+2
2016-02-21RaiseException is used by everything except x86 gnuPaul Dicker-0/+1
2016-02-21Fixes for 32-bitPaul Dicker-10/+11
2016-02-21Fix `struct stat` usage on NetBSDSebastian Wicki-1/+25
Some struct members have a slighty different name on NetBSD. This has been fixed in the libc crate, but not in libstd. This also removes `st_spare` from MetadataExt, since it is private field reserved for future use.
2016-02-21std: Use Android LFS off64_t, ftruncate64, and lseek64Josh Stone-1/+4
Android should use 64-bit LFS symbols for `lseek` and `ftruncate`, lest those offset parameters suffer a lossy cast down to a 32-bit `off_t`. Unlike GNU/Linux, Android's `stat`, `dirent`, and related functions are always 64-bit LFS compatible, and `open` already implies `O_LARGEFILE`, so all those don't need to follow Linux. It might be nice to unify them anyway, but those other LFS symbols aren't present in API 18 bionic. r? @alexcrichton
2016-02-20Auto merge of #31608 - frewsxcv:osstring-simple-functions, r=alexcrichtonbors-0/+90
https://github.com/rust-lang/rust/issues/29453
2016-02-20Add Capacity/length methods for OsString.Corey Farwell-0/+90
https://github.com/rust-lang/rust/issues/29453
2016-02-20Remove dead code from sys::windows::cPaul Dicker-210/+36
2016-02-19Auto merge of #31738 - seanmonstar:sys-rand, r=alexcrichtonbors-0/+347
2016-02-18Auto merge of #31684 - tmiasko:alternate-stack, r=alexcrichtonbors-5/+24
Remove alternate stack with sigaltstack before unmaping it. Also reuse existing signal stack if already set, this is especially useful when working with sanitizers that configure alternate stack themselves. This change depends on SS_DISABLE recently introduced in libc crate and updates this git submodule accordingly.
2016-02-18Remove alternate stack with sigaltstack before unmapping it.Tomasz Miąsko-5/+24
Also reuse existing signal stack if already set, this is especially useful when working with sanitizers that configure alternate stack themselves.
2016-02-17std: restructure rand os code into sys modulesSean McArthur-0/+347
2016-02-16Auto merge of #31675 - pitdicker:fs_metadata, r=alexcrichtonbors-28/+26
Because we no longer use `GetFileAttributesExW` FileAttr is never created directly from `WIN32_FILE_ATTRIBUTE_DATA` anymore. So we should no longer store FileAttr's attributes in that c struct. r? @alexcrichton Is this what you had in mind?
2016-02-15Refactor windows::fs::FileAttrPaul Dicker-28/+26
Because we no longer use `GetFileAttributesExW` FileAttr is never created directly from `WIN32_FILE_ATTRIBUTE_DATA` anymore. So we should no longer store FileAttr's attributes in that c struct.
2016-02-14std: use LFS open64 on LinuxJosh Stone-3/+3
2016-02-14std: use LFS readdir64_r on LinuxJosh Stone-5/+7
2016-02-14std: use LFS lseek64 on LinuxJosh Stone-7/+7
2016-02-14std: use LFS ftruncate64 on LinuxJosh Stone-3/+4
2016-02-14Auto merge of #31630 - pitdicker:read_link, r=alexcrichtonbors-58/+72
2016-02-14Auto merge of #31551 - alexcrichton:deprecate-std-os-raw, r=brsonbors-109/+114
This commit is an implementation of [RFC 1415][rfc] which deprecates all types in the `std::os::*::raw` modules. [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/1415-trim-std-os.md Many of the types in these modules don't actually have a canonical platform representation, for example the definition of `stat` on 32-bit Linux will change depending on whether C code is compiled with LFS support or not. Unfortunately the current types in `std::os::*::raw` are billed as "compatible with C", which in light of this means it isn't really possible. To make matters worse, platforms like Android sometimes define these types as *smaller* than the way they're actually represented in the `stat` structure itself. This means that when methods like `DirEntry::ino` are called on Android the result may be truncated as we're tied to returning a `ino_t` type, not the underlying type. The commit here incorporates two backwards-compatible components: * Deprecate all `raw` types that aren't in `std::os::raw` * Expand the `std::os::*::fs::MetadataExt` trait on all platforms for method accessors of all fields. The fields now returned widened types which are the same across platforms (consistency across platforms is not required, however, it's just convenient). and two also backwards-incompatible components: * Change the definition of all `std::os::*::raw` type aliases to correspond to the newly widened types that are being returned on each platform. * Change the definition of `std::os::*::raw::stat` on Linux to match the LFS definitions rather than the standard ones. The breaking changes here will specifically break code that assumes that `libc` and `std` agree on the definition of `std::os::*::raw` types, or that the `std` types are faithful representations of the types in C. An [audit] has been performed of crates.io to determine the fallout which was determined two be minimal, with the two found cases of breakage having been fixed now. [audit]: https://github.com/rust-lang/rfcs/pull/1415#issuecomment-180645582 --- Ok, so after all that, we're finally able to support LFS on Linux! This commit then simultaneously starts using `stat64` and friends on Linux to ensure that we can open >4GB files on 32-bit Linux. Yay! Closes #28978 Closes #30050 Closes #31549