summary refs log tree commit diff
path: root/src/libstd/sys
AgeCommit message (Collapse)AuthorLines
2015-08-11Stabilize 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. Conflicts: src/librustc/lib.rs src/libstd/time/duration.rs
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
2015-07-01msvc: Fix TLS destructorsAlex Crichton-2/+6
Just like the original article our Windows TLS support is based on predicted, this symbol must be linked in on MSVC to pull in the necessary support for TLS variables. This commit fixes a number of unit tests which require that TLS destructors are run.
2015-06-30std: Avoid the WSA_FLAG_NO_HANDLE_INHERIT optionAlex Crichton-16/+34
This was added after Windows 7 SP1, so it's not always available. Instead use the `SetHandleInformation` function to flag a socket as not inheritable. This is not atomic with respect to creating new processes, but it mirrors what Unix does with respect to possibly using the atomic option in the future. Closes #26543
2015-06-27std: Fix Windows XP compatibilityAlex Crichton-242/+352
This commit enables executables linked against the standard library to run on Windows XP. There are two main components of this commit: * APIs not available on XP are shimmed to have a fallback implementation and use runtime detection to determine if they are available. * Mutexes on Windows were reimplemented to use critical sections on XP where rwlocks are not available. The APIs which are not available on XP are: * SetFileInformationByHandle - this is just used by `File::truncate` and that function just returns an error now. * SetThreadStackGuarantee - this is used by the stack overflow support on windows, but if this isn't available then it's just ignored (it seems non-critical). * All condition variable APIs are missing - the shims added for these apis simply always panic for now. We may eventually provide a fallback implementation, but for now the standard library does not rely on condition variables for normal use. * RWLocks, like condition variables, are missing entirely. The same story for condition variables is taken here. These APIs are all now panicking stubs as the standard library doesn't rely on RWLocks for normal use. Currently, as an optimization, we use SRWLOCKs for the standard `sync::Mutex` implementation on Windows, which is indeed required for normal operation of the standard library. To allow the standard library to run on XP, this commit reimplements mutexes on Windows to use SRWLOCK instances *if available* and otherwise a CriticalSection is used (with some checking for recursive locking). With all these changes put together, a 32-bit MSVC-built executable can run on Windows XP and print "hello world" Closes #12842 Closes #19992 Closes #24776
2015-06-23Auto merge of #26219 - Veedrac:patch-1, r=alexcrichtonbors-0/+5
Fixes #26196. Alternatively we could explicitly check and complain (eg. panic), but I don't see the value-add.
2015-06-22Fix build on Android API levels below 21Geoffrey Thomas-0/+20
signal(), sigemptyset(), and sigaddset() are only available as inline functions until Android API 21. liblibc already handles signal() appropriately, so drop it from c.rs; translate sigemptyset() and sigaddset() (which is only used in a test) by hand from the C inlines. We probably want to revert this commit when we bump Android API level.
2015-06-22sys/unix/process: Reset signal behavior before execGeoffrey Thomas-2/+85
Make sure that child processes don't get affected by libstd's desire to ignore SIGPIPE, nor a third-party library's signal mask (which is needed to use either a signal-handling thread correctly or to use signalfd / kqueue correctly).
2015-06-22sys/unix: Consolidate signal-handling FFI bindingsGeoffrey Thomas-268/+199
Both c.rs and stack_overflow.rs had bindings of libc's signal-handling routines. It looks like the split dated from #16388, when (what is now) c.rs was in libnative but not libgreen. Nobody is currently using the c.rs bindings, but they're a bit more accurate in some places. Move everything to c.rs (since I'll need signal handling in process.rs, and we should avoid duplication), clean up the bindings, and manually double-check everything against the relevant system headers (fixing a few things in the process).
2015-06-22sys/unix/c.rs: Remove unused codeGeoffrey Thomas-75/+5
It looks like a lot of this dated to previous incarnations of the io module, etc., and went unused in the reworking leading up to 1.0. Remove everything we're not actively using (except for signal handling, which will be reworked in the next commit).
2015-06-19liblibc: Fix prototype of functions taking `char *const argv[]`Geoffrey Thomas-1/+1
The execv family of functions do not modify their arguments, so they do not need mutable pointers. The C prototypes take a constant array of mutable C-strings, but that's a legacy quirk from before C had const (since C string literals have type `char *`). The Rust prototypes had `*mut` in the wrong place, anyway: to match the C prototypes, it should have been `*const *mut c_char`. But it is safe to pass constant strings (like string literals) to these functions. getopt is a special case, since GNU getopt modifies its arguments despite the `const` claim in the prototype. It is apparently only well-defined to call getopt on the actual argc and argv parameters passed to main, anyway. Change it to take `*mut *mut c_char` for an attempt at safety, but probably nobody should be using it from Rust, since there's no great way to get at the parameters as passed to main. Also fix the one caller of execvp in libstd, which now no longer needs an unsafe cast. Fixes #16290.
2015-06-18std: Add FromRaw{Fd,Handle,Socket} to os preludesAlex Crichton-1/+3
These were just left out by mistake!
2015-06-18Fix libstd testsAlex Crichton-2/+1
2015-06-17More test fixes and fallout of stability changesAlex Crichton-25/+1
2015-06-17std: Stabilize the sync_poison featureAlex Crichton-4/+4
These accessor/constructor methods for a `PoisonError` are quite standard for a wrapper type and enable manipulation of the underlying type.
2015-06-17std: Remove two internal `str_internals` functionsAlex Crichton-25/+0
These were just exposed to be used elsewhere at some point, but neither is currently being used so just make them private again.
2015-06-17std: Split the `std_misc` featureAlex Crichton-4/+4