about summary refs log tree commit diff
path: root/src/libstd/sys
AgeCommit message (Collapse)AuthorLines
2015-08-11Rollup merge of #27577 - diaphore:trailing-newline-formatmessagew, ↵Manish Goregaokar-3/+7
r=alexcrichton `FormatMessageW` always inserts trailing `\r\n` to system messages which is a minor annoyance when they're fed to `Debug` but can break formatting with `Display`. ```rust fn main() { use std::env; if let Err(err) = env::set_current_dir("???") { println!("{:#?}\n{}", err, err); } } ``` ```_ Error { repr: Os { code: 2, message: "The system cannot find the file specified.\r\n" } } The system cannot find the file specified. (os error 2) ```
2015-08-11Auto merge of #27549 - tshepang:clarity, r=alexcrichtonbors-1/+1
2015-08-11Auto merge of #26818 - sfackler:duration-stabilization, r=aturonbors-11/+11
This commit stabilizes the `std::time` module and the `Duration` type. `Duration::span` remains unstable, and the `Display` implementation for `Duration` has been removed as it is still being reworked and all trait implementations for stable types are de facto stable. This is a [breaking-change] to those using `Duration`'s `Display` implementation. I'm opening this PR as a platform for discussion - there may be some method renaming to do as part of the stabilization process.
2015-08-10Stabilize the Duration APISteven Fackler-11/+11
This commit stabilizes the `std::time` module and the `Duration` type. `Duration::span` remains unstable, and the `Display` implementation for `Duration` has been removed as it is still being reworked and all trait implementations for stable types are de facto stable. This is a [breaking-change] to those using `Duration`'s `Display` implementation.
2015-08-10Auto merge of #27338 - alexcrichton:remove-morestack, r=brsonbors-453/+85
This commit removes all morestack support from the compiler which entails: * Segmented stacks are no longer emitted in codegen. * We no longer build or distribute libmorestack.a * The `stack_exhausted` lang item is no longer required The only current use of the segmented stack support in LLVM is to detect stack overflow. This is no longer really required, however, because we already have guard pages for all threads and registered signal handlers watching for a segfault on those pages (to print out a stack overflow message). Additionally, major platforms (aka Windows) already don't use morestack. This means that Rust is by default less likely to catch stack overflows because if a function takes up more than one page of stack space it won't hit the guard page. This is what the purpose of morestack was (to catch this case), but it's better served with stack probes which have more cross platform support and no runtime support necessary. Until LLVM supports this for all platform it looks like morestack isn't really buying us much. cc #16012 (still need stack probes) Closes #26458 (a drive-by fix to help diagnostics on stack overflow) r? @brson
2015-08-10Remove morestack supportAlex Crichton-453/+85
This commit removes all morestack support from the compiler which entails: * Segmented stacks are no longer emitted in codegen. * We no longer build or distribute libmorestack.a * The `stack_exhausted` lang item is no longer required The only current use of the segmented stack support in LLVM is to detect stack overflow. This is no longer really required, however, because we already have guard pages for all threads and registered signal handlers watching for a segfault on those pages (to print out a stack overflow message). Additionally, major platforms (aka Windows) already don't use morestack. This means that Rust is by default less likely to catch stack overflows because if a function takes up more than one page of stack space it won't hit the guard page. This is what the purpose of morestack was (to catch this case), but it's better served with stack probes which have more cross platform support and no runtime support necessary. Until LLVM supports this for all platform it looks like morestack isn't really buying us much. cc #16012 (still need stack probes) Closes #26458 (a drive-by fix to help diagnostics on stack overflow)
2015-08-10Auto merge of #27252 - tbu-:pr_less_transmutes, r=alexcrichtonbors-2/+1
The replacements are functions that usually use a single `mem::transmute` in their body and restrict input and output via more concrete types than `T` and `U`. Worth noting are the `transmute` functions for slices and the `from_utf8*` family for mutable slices. Additionally, `mem::transmute` was often used for casting raw pointers, when you can already cast raw pointers just fine with `as`. This builds upon #27233.
2015-08-10Auto merge of #27516 - alexcrichton:osx-flaky-zomg, r=brsonbors-0/+4
The investigation into #14232 discovered that it's possible that signal delivery to a newly spawned process is racy on OSX. This test has been failing spuriously on the OSX bots for some time now, so ignore it as we don't currently know a solution and it looks like it may be out of our control.
2015-08-09Replace many uses of `mem::transmute` with more specific functionsTobias Bucher-2/+1
The replacements are functions that usually use a single `mem::transmute` in their body and restrict input and output via more concrete types than `T` and `U`. Worth noting are the `transmute` functions for slices and the `from_utf8*` family for mutable slices. Additionally, `mem::transmute` was often used for casting raw pointers, when you can already cast raw pointers just fine with `as`.
2015-08-07Trim trailing newline from FormatMessageWdiaphore-3/+7
2015-08-06fs: indicate that we only copy regular filesTshepang Lekhonkhobe-1/+1
2015-08-05Auto merge of #27393 - alexcrichton:no-std-changes, r=brsonbors-8/+40
This commit is an implementation of [RFC 1184][rfc] which tweaks the behavior of the `#![no_std]` attribute and adds a new `#![no_core]` attribute. The `#![no_std]` attribute now injects `extern crate core` at the top of the crate as well as the libcore prelude into all modules (in the same manner as the standard library's prelude). The `#![no_core]` attribute disables both std and core injection. [rfc]: https://github.com/rust-lang/rfcs/pull/1184 Closes #27394
2015-08-04syntax: Don't assume `std` exists for testsAlex Crichton-1/+2
This commit removes the injection of `std::env::args()` from `--test` expanded code, relying on the test runner itself to call this funciton. This is more hygienic because we can't assume that `std` exists at the top layer all the time, and it meaks the injected test module entirely self contained.
2015-08-04std: Ignore test_process_mask on OSXAlex Crichton-0/+4
The investigation into #14232 discovered that it's possible that signal delivery to a newly spawned process is racy on OSX. This test has been failing spuriously on the OSX bots for some time now, so ignore it as we don't currently know a solution and it looks like it may be out of our control.
2015-08-03syntax: Implement #![no_core]Alex Crichton-8/+39
This commit is an implementation of [RFC 1184][rfc] which tweaks the behavior of the `#![no_std]` attribute and adds a new `#![no_core]` attribute. The `#![no_std]` attribute now injects `extern crate core` at the top of the crate as well as the libcore prelude into all modules (in the same manner as the standard library's prelude). The `#![no_core]` attribute disables both std and core injection. [rfc]: https://github.com/rust-lang/rfcs/pull/1184
2015-08-01std: Allow to spawn a process as a session leader on UNIXMickaël Salaün-3/+19
2015-07-29std: Fix sub-second Condvar::wait_timeout_msAlex Crichton-13/+14
The API we're calling requires us to pass an absolute point in time as an argument (`pthread_cond_timedwait`) so we call `gettimeofday` ahead of time to then add the specified duration to. Unfortuantely the current "add the duration" logic forgot to take into account the current time's sub-second precision (e.g. the `tv_usec` field was ignored), causing sub-second duration waits to return spuriously.
2015-07-27Fix escaping of characters in Debug for OsStrdiaphore-15/+25
Fixes #27211 Fix Debug for {char, str} in core::fmt
2015-07-25Auto merge of #27233 - tbu-:pr_wtf8, r=alexcrichtonbors-12/+19
2015-07-23Rewrite the improper_ctypes lint.Eli Friedman-0/+2
Makes the lint a bit more accurate, and improves the quality of the diagnostic messages by explicitly returning an error message. The new lint is also a little more aggressive: specifically, it now rejects tuples, and it recurses into function pointers.
2015-07-23wtf8, char: Replace uses of `mem::transmute` with more specific functionsTobias Bucher-12/+19
2015-07-22Auto merge of #27172 - alexcrichton:snapshots, r=brsonbors-1/+4
Enables bootstrapping a 32-bit MSVC host compiler! Closes #26602
2015-07-21Auto merge of #27073 - alexcrichton:less-proc-fs, r=brsonbors-45/+58
This can fail on linux for various reasons, such as the /proc filesystem not being mounted. There are already many cases where we can't set up stack guards, so just don't worry about this case and communicate that no guard was enabled. I've confirmed that this allows the compiler to run in a chroot without /proc mounted. Closes #22642
2015-07-21std: Be resilient to failure in pthread_getattr_npAlex Crichton-45/+58
This can fail on linux for various reasons, such as the /proc filesystem not being mounted. There are already many cases where we can't set up stack guards, so just don't worry about this case and communicate that no guard was enabled. I've confirmed that this allows the compiler to run in a chroot without /proc mounted. Closes #22642
2015-07-21Auto merge of #27150 - retep998:where-are-my-files, r=alexcrichtonbors-9/+15
cc #24570 r? @alexcrichton
2015-07-20std: Fix compiling the standard library on i686-MSVCAlex Crichton-1/+4
This commit fixes building the standard library with the `i686-pc-windows-msvc` target by correcting an included symbol name to the linker.
2015-07-20Improve Debug impl for File on WindowsPeter Atashian-9/+15
Adds a path field if a path could be obtained Signed-off-by: Peter Atashian <retep998@gmail.com>
2015-07-20std: Add IntoRaw{Fd,Handle,Socket} traitsAlex Crichton-10/+157
This commit is an implementation of [RFC 1174][rfc] which adds three new traits to the standard library: * `IntoRawFd` - implemented on Unix for all I/O types (files, sockets, etc) * `IntoRawHandle` - implemented on Windows for files, processes, etc * `IntoRawSocket` - implemented on Windows for networking types [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/1174-into-raw-fd-socket-handle-traits.md Closes #27062
2015-07-18Auto merge of #27088 - tamird:fix-ios-build, r=alexcrichtonbors-6/+4
Fixes #26939.
2015-07-17[ios] std: avoid `result::fold`Tamir Duberstein-6/+4
2015-07-17Rollup merge of #27069 - Eljay:fix-raw-attr-typo, r=alexcrichtonManish Goregaokar-1/+1
Pretty sure this should apply to the module. r? @alexcrichton
2015-07-16Fix typo in stability attribute.Lee Jeffery-1/+1
2015-07-15Add specializations of read_to_end for Stdin, TcpStream and File,Alisdair Owens-0/+140
allowing them to read into a buffer containing uninitialized data, rather than pay the cost of zeroing.
2015-07-11fixing trailing whitespaceDave Huseby-1/+1
2015-07-11adding support for i686-unknown-freebsd targetDave Huseby-7/+9
2015-07-11Auto merge of #26929 - alexcrichton:windows-dir-junction, r=brsonbors-35/+225
Previously on Windows a directory junction would return false from `is_dir`, causing various odd behavior, specifically calls to `create_dir_all` might fail when they would otherwise continue to succeed. Closes #26716
2015-07-11Auto merge of #26941 - fhartwig:osx-file-debug, r=alexcrichtonbors-3/+15
This makes `Debug` for `File` show the file path and access mode of the file on OS X, just like on Linux. I'd be happy about any feedback how to make this code better. In particular, I'm not sure how to handle the buffer passed to `fnctl`. This way works, but it feels a bit cumbersome. `fcntl` unfortunately doesn't return the length of the path.
2015-07-10Auto merge of #26896 - tbu-:pr_getcwd, r=alexcrichtonbors-19/+26
(On Windows, it works already.)
2015-07-10std: Consider directory junctions as directoriesAlex Crichton-35/+225
Previously on Windows a directory junction would return false from `is_dir`, causing various odd behavior, specifically calls to `create_dir_all` might fail when they would otherwise continue to succeed. Closes #26716
2015-07-10Show file name and access mode in Debug instance for File on OS XFlorian Hartwig-3/+15
2015-07-10Auto merge of #26751 - retep998:copy-that-floppy, r=alexcrichtonbors-1/+66
Using the OS mechanism for copying files allows the OS to optimize the transfer using stuff such as [Offloaded Data Transfers (ODX)](https://msdn.microsoft.com/en-us/library/windows/desktop/hh848056%28v=vs.85%29.aspx). Also preserves a lot more information, including NTFS [File Streams](https://msdn.microsoft.com/en-us/library/windows/desktop/aa364404%28v=vs.85%29.aspx), which the manual implementation threw away. In addition, it is an atomic operation, unlike the manual implementation which has extra calls for copying over permissions. r? @alexcrichton
2015-07-10Remove the generic `fill_bytes_buf` functionTobias Bucher-31/+13
2015-07-10Use CopyFileEx for fs::copy on WindowsPeter Atashian-1/+66
Adds a couple more tests for fs::copy Signed-off-by: Peter Atashian <retep998@gmail.com>
2015-07-09Auto merge of #26766 - jespino:add-more-filetypes, r=alexcrichtonbors-2/+24
I find that isn't supported on the current API and I think is necesary. It is my first PR to rust (I'm not a rust expert and I'm not sure if this is the better way to propose this thinks), of course any suggestion of change will be welcome. I'm almost sure that in windows aren't supported this filetypes, then, i put in the api of win::fs the functions with a fixed false in the response, I hope this is correct.
2015-07-09Address some comments on the pull requestTobias Bucher-40/+25
2015-07-09Use vec![elt; n] where possibleUlrik Sverdrup-2/+1
The common pattern `iter::repeat(elt).take(n).collect::<Vec<_>>()` is exactly equivalent to `vec![elt; n]`, do this replacement in the whole tree. (Actually, vec![] is smart enough to only call clone n - 1 times, while the former solution would call clone n times, and this fact is virtually irrelevant in practice.)
2015-07-09Add FileTypeUnix trait to add unix special file typesJesús Espino-2/+24
2015-07-08Make `std::env::current_dir` work for path names longer than 2048 bytes on ↵Tobias Bucher-9/+49
non-Windows
2015-07-06Auto merge of #26741 - alexcrichton:noinline-destructors, r=brsonbors-2/+6
This PR was originally going to be a "let's start running tests on MSVC" PR, but it didn't quite get to that point. It instead gets us ~80% of the way there! The steps taken in this PR are: * Landing pads are turned on by default for 64-bit MSVC. The LLVM support is "good enough" with the caveat the destructor glue is now marked noinline. This was recommended [on the associated bug](https://llvm.org/bugs/show_bug.cgi?id=23884) as a stopgap until LLVM has a better representation for exception handling in MSVC. The consequence of this is that MSVC will have a bit of a perf hit, but there are possible routes we can take if this workaround sticks around for too long. * The linker (`link.exe`) is now looked up in the Windows Registry if it's not otherwise available in the environment. This improves using the compiler outside of a VS shell (e.g. in a MSYS shell or in a vanilla cmd.exe shell). This also makes cross compiles via Cargo "just work" when crossing between 32 and 64 bit! * TLS destructors were fixed to start running on MSVC (they previously weren't running at all) * A few assorted `run-pass` tests were fixed. * The dependency on the `rust_builtin` library was removed entirely for MSVC to try to prevent any `cl.exe` compiled objects get into the standard library. This should help us later remove any dependence on the CRT by the standard library. * I re-added `rust_try_msvc_32.ll` for 32-bit MSVC and ensured that landing pads were turned off by default there as well. Despite landing pads being enabled, there are still *many* failing tests on MSVC. The two major classes I've identified so far are: * Spurious aborts. It appears that when optimizations are enabled that landing pads aren't always lined up properly, and sometimes an exception being thrown can't find the catch block down the stack, causing the program to abort. I've been working to reduce this test case but haven't been met with great success just yet. * Parallel codegen does not work on MSVC. Our current strategy is to take the N object files emitted by the N codegen threads and use `ld -r` to assemble them into *one* object file. The MSVC linker, however, does not have this ability, and this will need to be rearchitected to work on MSVC. I will fix parallel codegen in a future PR, and I'll also be watching LLVM closely to see if the aborts... disappear!
2015-07-01Add netbsd amd64 supportAlex Newman-16/+26