about summary refs log tree commit diff
path: root/src/libstd/sys
AgeCommit message (Collapse)AuthorLines
2017-12-27Implement rename using new system callJeremy Soller-7/+34
Fix readlink and symlink to utilize O_CLOEXEC
2017-12-25Auto merge of #46914 - mikeyhew:raw_pointer_self, r=arielb1bors-2/+2
Convert warning about `*const _` to a future-compat lint #46664 was merged before I could convert the soft warning about method lookup on `*const _` into a future-compatibility lint. This PR makes that change. fixes #46837 tracking issue for the future-compatibility lint: #46906 r? @arielb1
2017-12-24Auto merge of #46789 - Diggsey:command-env-capture, r=dtolnaybors-163/+151
Capture `Command` environment at spawn Fixes #28975 This tracks a set of changes to the environment and then replays them at spawn time.
2017-12-24Capture environment at spawnDiggory Blake-163/+151
2017-12-23Annotate raw pointer target typesChristopher Durham-1/+1
cc https://github.com/rust-lang/rust/issues/46906 cc https://github.com/rust-lang/rust/pull/46914
2017-12-22fix some errors in libstdMichael Hewson-1/+1
2017-12-19Add Hash impl for SystemTime and InstantVitaly _Vi Shukela-9/+32
Closes #46670.
2017-12-18Add lossless debug implementation for unix OsStrsDiggory Blake-3/+6
2017-12-13Move rust memchr impl to libcoreManish Goregaokar-4/+4
2017-12-11Merge remote-tracking branch 'origin/master' into miriOliver Schneider-4/+1
2017-12-09Use Try syntax for Option in place of macros or matchMatt Brubeck-4/+1
2017-12-06Update miri to rustc changesOliver Schneider-552/+3166
2017-11-30NetBSD: add sysctl backend for std::env::current_exeJonathan A. Kollasch-1/+28
Use the CTL_KERN.KERN_PROC_ARGS.-1.KERN_PROC_PATHNAME sysctl in preference over the /proc/curproc/exe symlink. Additionally, perform more validation of aformentioned symlink. Particularly on pre-8.x NetBSD this symlink will point to '/' when accurate information is unavailable.
2017-11-25Implement `Rc`/`Arc` conversions for string-like typesMurarth-0/+96
Provides the following conversion implementations: * `From<`{`CString`,`&CStr`}`>` for {`Arc`,`Rc`}`<CStr>` * `From<`{`OsString`,`&OsStr`}`>` for {`Arc`,`Rc`}`<OsStr>` * `From<`{`PathBuf`,`&Path`}`>` for {`Arc`,`Rc`}`<Path>`
2017-11-25rustbuild: Enable WebAssembly backend by defaultAlex Crichton-46/+63
This commit alters how we compile LLVM by default enabling the WebAssembly backend. This then also adds the wasm32-unknown-unknown target to get compiled on the `cross` builder and distributed through rustup. Tests are not yet enabled for this target but that should hopefully be coming soon!
2017-11-24std: Flag Windows TLS dtor symbol as #[used]Alex Crichton-1/+2
Turns out ThinLTO was internalizing this symbol and eliminating it. Worse yet if you compiled with LTO turns out no TLS destructors would run on Windows! The `#[used]` annotation should be a more bulletproof implementation (in the face of LTO) of preserving this symbol all the way through in LLVM and ensuring it makes it all the way to the linker which will take care of it.
2017-11-21Rollup merge of #46092 - sfackler:ppid, r=alexcrichtonkennytm-0/+14
Add process::parent_id I have this as a Unix-only API since it seems like Windows doesn't have a similar API. r? @alexcrichton
2017-11-19std: Add a new wasm32-unknown-unknown targetAlex Crichton-0/+2014
This commit adds a new target to the compiler: wasm32-unknown-unknown. This target is a reimagining of what it looks like to generate WebAssembly code from Rust. Instead of using Emscripten which can bring with it a weighty runtime this instead is a target which uses only the LLVM backend for WebAssembly and a "custom linker" for now which will hopefully one day be direct calls to lld. Notable features of this target include: * There is zero runtime footprint. The target assumes nothing exists other than the wasm32 instruction set. * There is zero toolchain footprint beyond adding the target. No custom linker is needed, rustc contains everything. * Very small wasm modules can be generated directly from Rust code using this target. * Most of the standard library is stubbed out to return an error, but anything related to allocation works (aka `HashMap`, `Vec`, etc). * Naturally, any `#[no_std]` crate should be 100% compatible with this new target. This target is currently somewhat janky due to how linking works. The "linking" is currently unconditional whole program LTO (aka LLVM is being used as a linker). Naturally that means compiling programs is pretty slow! Eventually though this target should have a linker. This target is also intended to be quite experimental. I'm hoping that this can act as a catalyst for further experimentation in Rust with WebAssembly. Breaking changes are very likely to land to this target, so it's not recommended to rely on it in any critical capacity yet. We'll let you know when it's "production ready". --- Currently testing-wise this target is looking pretty good but isn't complete. I've got almost the entire `run-pass` test suite working with this target (lots of tests ignored, but many passing as well). The `core` test suite is still getting LLVM bugs fixed to get that working and will take some time. Relatively simple programs all seem to work though! --- It's worth nothing that you may not immediately see the "smallest possible wasm module" for the input you feed to rustc. For various reasons it's very difficult to get rid of the final "bloat" in vanilla rustc (again, a real linker should fix all this). For now what you'll have to do is: cargo install --git https://github.com/alexcrichton/wasm-gc wasm-gc foo.wasm bar.wasm And then `bar.wasm` should be the smallest we can get it! --- In any case for now I'd love feedback on this, particularly on the various integration points if you've got better ideas of how to approach them!
2017-11-19Add process::parent_idSteven Fackler-0/+14
I have this as a Unix-only API since it seems like Windows doesn't have a similar API.
2017-11-14Auto merge of #45896 - malbarbo:use-libc-const, r=alexcrichtonbors-50/+5
Use getrandom syscall for all Linux and Android targets. I suppose we can use it in all Linux and Android targets. In function `is_getrandom_available` is checked if the syscall is available (getrandom syscall was add in version 3.17 of Linux kernel), if the syscall is not available `fill_bytes` fallback to reading from `/dev/urandom`. Update libc to include getrandom related constants.
2017-11-13Rollup merge of #45893 - redox-os:futex_timeout, r=alexcrichtonkennytm-22/+38
Redox: Use futex timeout to implement CondVar::wait_timeout `CondVar::wait_timeout` is implemented by supplying a `TimeSpec` pointer to `futex`. In addition, all calls to `unimplemented!()` have been removed from the Redox `sys` module. Related to https://github.com/rust-lang/rust/pull/45892
2017-11-11Add missing links and examples for FileExtGuillaume Gomez-2/+40
2017-11-09Use getrandom syscall for all Linux and Android targets.Marco A L Barbosa-50/+5
2017-11-09Add futex timeoutJeremy Soller-22/+38
2017-11-09std: Avoid use of `libc` in portable modulesAlex Crichton-17/+19
This commit removes usage of the `libc` crate in "portable" modules like those at the top level and `sys_common`. Instead common types like `*mut u8` or `u32` are used instead of `*mut c_void` or `c_int` as well as switching to platform-specific functions like `sys::strlen` instead of `libc::strlen`.
2017-11-08std: Move the `cmath` module into the `sys` moduleAlex Crichton-0/+192
This commit moves the `f32::cmath` and `f64::cmath` modules into the `sys` module. Note that these are not publicly exported modules, simply implementation details. These modules are already platform-specific with shims on MSVC and this is mostly just a reflection of that reality. This should also help cut down on `#[cfg]` traffic if platforms are brought on which don't directly support these functions.
2017-11-08std: Change how EBADF is handled in `sys`Alex Crichton-3/+12
This commit removes the reexport of `EBADF_ERR` as a constant from libstd's portability facade, instead opting for a platform-specific function that specifically queries an `io::Error`. Not all platforms may have a constant for this, so it makes the intent a little more clear that a code need not be supplied, just an answer to a query.
2017-11-08std: Remove `rand` crate and moduleAlex Crichton-300/+107
This commit removes the `rand` crate from the standard library facade as well as the `__rand` module in the standard library. Neither of these were used in any meaningful way in the standard library itself. The only need for randomness in libstd is to initialize the thread-local keys of a `HashMap`, and that unconditionally used `OsRng` defined in the standard library anyway. The cruft of the `rand` crate and the extra `rand` support in the standard library makes libstd slightly more difficult to port to new platforms, namely WebAssembly which doesn't have any randomness at all (without interfacing with JS). The purpose of this commit is to clarify and streamline randomness in libstd, focusing on how it's only required in one location, hashmap seeds. Note that the `rand` crate out of tree has almost always been a drop-in replacement for the `rand` crate in-tree, so any usage (accidental or purposeful) of the crate in-tree should switch to the `rand` crate on crates.io. This then also has the further benefit of avoiding duplication (mostly) between the two crates!
2017-11-08Rollup merge of #45582 - GuillaumeGomez:doc-unix-missing-links, r=frewsxcvGuillaume Gomez-4/+70
Add missing links and examples r? @rust-lang/docs
2017-11-07Add missing links and examplesGuillaume Gomez-4/+70
2017-11-07Rollup merge of #45470 - GuillaumeGomez:unix-metadata-ext, r=QuietMisdreavuskennytm-0/+246
add missing docs for MetadataExt r? @rust-lang/docs
2017-11-05Auto merge of #44042 - LukasKalbertodt:ascii-methods-on-instrinsics, ↵bors-3/+1
r=alexcrichton Copy all `AsciiExt` methods to the primitive types directly in order to deprecate it later **EDIT:** [this PR is ready now](https://github.com/rust-lang/rust/pull/44042#issuecomment-333883548). I edited this post to reflect the current status of discussion, which is (apart from code review) pretty much settled. --- This is my current progress in order to prepare stabilization of #39658. As discussed there (and in #39659), the idea is to deprecated `AsciiExt` and copy all methods to the type directly. Apparently there isn't really a reason to have those methods in an extension trait¹. ~~This is **work in progress**: copy&pasting code while slightly modifying the documentation isn't the most exciting thing to do. Therefore I wanted to already open this WIP PR after doing basically 1/4 of the job (copying methods to `&[u8]`, `char` and `&str` is still missing) to get some feedback before I continue. Some questions possibly worth discussing:~~ 1. ~~Does everyone agree that deprecating `AsciiExt` is a good idea? Does everyone agree with the goal of this PR?~~ => apparently yes 2. ~~Are my changes OK so far? Did I do something wrong?~~ 3. ~~The issue of the unstable-attribute is currently set to 0. I would wait until you say "Ok" to the whole thing, then create a tracking issue and then insert the correct issue id. Is that ok?~~ 4. ~~I tweaked `eq_ignore_ascii_case()`: it now takes the argument `other: u8` instead of `other: &u8`. The latter was enforced by the trait. Since we're not bound to a trait anymore, we can drop the reference, ok?~~ => I reverted this, because the interface has to match the `AsciiExt` interface exactly. ¹ ~~Could it be that we can't write `impl [u8] {}`? This might be the reason for `AsciiExt`. If that is the case: is there a good reason we can't write such an impl block? What can we do instead?~~ => we couldn't at the time this PR was opened, but Simon made it possible. /cc @SimonSapin @zackw
2017-11-04Remove import of now unused AsciiExtLukas Kalbertodt-3/+1
I also replaced a wildcard import with a specific one, while I was at it.
2017-11-03Fix std compile error for windows-gnu targets without `backtrace` featureRolf Karp-2/+2
2017-11-01Rollup merge of #45652 - malbarbo:x32-2, r=alexcrichtonkennytm-1/+3
More fixes for x86_64-unknown-linux-gnux32 This update libc (all libc testing are passing) and fixes NR_GETRANDOM. Fix all but one run-pass test (lto-unwind.rs, see https://github.com/rust-lang/rust/issues/45416)
2017-10-31add missing docs for MetadataExtGuillaume Gomez-0/+246
2017-10-31Fix NR_GETRANDOM for linux x32Marco A L Barbosa-1/+3
2017-10-31Update doc comment for the Unix extension moduleTobias Bucher-2/+8
It was a bit outdated, claimed to be able to do less than it actually could.
2017-10-26Rollup merge of #45059 - tmccombs:pid, r=alexcrichtonkennytm-0/+12
Add current_pid function Fixes #44971
2017-10-21Rollup merge of #45419 - steveklabnik:fix-commonmark-renderings, ↵Corey Farwell-1/+1
r=QuietMisdreavus Fix most rendering warnings from switching to CommonMark There's one big one lift, I'm filing a bug for it soon. r? @rust-lang/docs
2017-10-21Auto merge of #45391 - malbarbo:x32-1, r=alexcrichtonbors-7/+8
Update libc and some fixes for x86_64-unknown-linux-gnux32
2017-10-20Fix most rendering warnings from switching to CommonMarksteveklabnik-1/+1
2017-10-20Fix some tests for linux gnux32Marco A L Barbosa-7/+8
2017-10-18std: Update randomness implementation on WindowsAlex Crichton-46/+10
This commit updates the OS random number generator on Windows to match the upstream implementation in the `rand` crate. First proposed in rust-lang-nursery/rand#111 this implementation uses a "private" API of `RtlGenRandom`. Despite the [documentation][dox] indicating this is a private function its widespread use in Chromium and Firefox as well as [comments] from Microsoft internally indicates that it's highly unlikely to break. Another motivation for switching this is to also attempt to make progress on #44911. It may be the case that this function succeeds while the previous implementation may fail in "weird" scenarios. [dox]: https://msdn.microsoft.com/en-us/library/windows/desktop/aa387694(v=vs.85).aspx [comments]: https://github.com/rust-lang-nursery/rand/issues/111#issuecomment-316140155
2017-10-17Remove duplicated wordGuillaume Gomez-2/+2
2017-10-14Fix TcpStream::connect_timeout on linuxSteven Fackler-4/+9
Linux appears to set POLLOUT when a conection's refused, which is pretty weird. Invert the check to look for an error explicitly. Also add an explict test for this case. Closes #45265.
2017-10-13Rollup merge of #44855 - federicomenaquintero:master, r=steveklabnikkennytm-0/+56
Improved docs for CStr, CString, OsStr, OsString This expands the documentation for those structs and their corresponding traits, per https://github.com/rust-lang/rust/issues/29354
2017-10-09Auto merge of #45041 - est31:master, r=alexcrichtonbors-29/+4
Remove support for the PNaCl target (le32-unknown-nacl) This removes support for the `le32-unknown-nacl` target which is currently supported by rustc on tier 3. Despite the "nacl" in the name, the target doesn't output native code (x86, ARM, MIPS), instead it outputs binaries in the PNaCl format. There are two reasons for the removal: * Google [has announced](https://blog.chromium.org/2017/05/goodbye-pnacl-hello-webassembly.html) deprecation of the PNaCl format. The suggestion is to migrate to wasm. Happens we already have a wasm backend! * Our PNaCl LLVM backend is provided by the fastcomp patch set that the LLVM fork used by rustc contains in addition to vanilla LLVM (`src/llvm/lib/Target/JSBackend/NaCl`). Upstream LLVM doesn't have PNaCl support. Removing PNaCl support will enable us to move away from fastcomp (#44006) and have a lighter set of patches on top of upstream LLVM inside our LLVM fork. This will help distribution packagers of Rust. Fixes #42420
2017-10-08Auto merge of #45030 - raggi:zircon-handle-t, r=alexcrichtonbors-18/+17
zircon: the type of zx_handle_t is now unsigned This is a kernel ABI change that landed today. I noticed some other ABI issues and have left a note to cleanup once they are better defined.
2017-10-06Add current_pid functionThayne McCombs-0/+12
Fixes #44971