about summary refs log tree commit diff
path: root/src/libstd/sys
AgeCommit message (Collapse)AuthorLines
2017-06-29redox: symlink and readlinkIan Douglas Scott-4/+12
2017-06-29Auto merge of #42848 - ids1024:redox-fix, r=sfacklerbors-3/+2
Fix Redox build, broken in ecbb896b9eb2acadefde57be493e4298c1aa04a3
2017-06-24Auto merge of #42687 - alexcrichton:windows-tls, r=sfacklerbors-104/+26
rustc: Enable #[thread_local] for Windows I think LLVM has had support for quite some time now for this, we just never got around to testing it out and binding it. We've had some trouble landing this in the past I believe, but it's time to try again! This commit flags the `#[thread_local]` attribute as being available for Windows targets and adds an implementation of `register_dtor` in the `thread::local` module to ensure we can destroy these keys. The same functionality is implemented in clang via a function called `__tlregdtor` (presumably provided in some Windows runtime somewhere), but this function unfortunately does not take a data pointer (just a thunk) which means we can't easily call it. For now destructors are just run in the same way the Linux fallback is implemented, which is just keeping track via a single OS-based TLS key.
2017-06-23rustc: Enable #[thread_local] for WindowsAlex Crichton-104/+26
I think LLVM has had support for quite some time now for this, we just never got around to testing it out and binding it. We've had some trouble landing this in the past I believe, but it's time to try again! This commit flags the `#[thread_local]` attribute as being available for Windows targets and adds an implementation of `register_dtor` in the `thread::local` module to ensure we can destroy these keys. The same functionality is implemented in clang via a function called `__tlregdtor` (presumably provided in some Windows runtime somewhere), but this function unfortunately does not take a data pointer (just a thunk) which means we can't easily call it. For now destructors are just run in the same way the Linux fallback is implemented, which is just keeping track via a single OS-based TLS key.
2017-06-23Rollup merge of #42783 - ids1024:redox-env, r=sfacklerMark Simulacrum-1/+1
Redox: Use create() instead of open() when setting env variable See https://github.com/redox-os/kernel/pull/25.
2017-06-23Removed as many "```ignore" as possible.kennytm-29/+53
Replaced by adding extra imports, adding hidden code (`# ...`), modifying examples to be runnable (sorry Homura), specifying non-Rust code, and converting to should_panic, no_run, or compile_fail. Remaining "```ignore"s received an explanation why they are being ignored.
2017-06-22Fix Redox build, broken in ecbb896b9eb2acadefde57be493e4298c1aa04a3Ian Douglas Scott-3/+2
2017-06-22Auto merge of #42798 - stepancheg:args-debug, r=sfacklerbors-0/+43
Better Debug for Args and ArgsOs Display actual args instead of two dots.
2017-06-21Better Debug for Args and ArgsOsStepan Koltsov-0/+43
Display actual args instead of two dots.
2017-06-20Add `Read::initializer`.Steven Fackler-81/+7
This is an API that allows types to indicate that they can be passed buffers of uninitialized memory which can improve performance.
2017-06-20Redox: Use create() instead of open() when setting env variableIan Douglas Scott-1/+1
2017-06-17Auto merge of #42613 - stepancheg:lossy, r=alexcrichtonbors-21/+59
Avoid allocations in Display for OsStr and Path #38879
2017-06-15Fix condvar.wait(distant future) return immediately on OSXStepan Koltsov-4/+30
Fixes issue #37440: `pthread_cond_timedwait` on macOS Sierra seems to overflow `ts_sec` parameter and returns immediately. To work around this problem patch rounds timeout down to approximately 1000 years. Patch also fixes overflow when converting `u64` to `time_t`.
2017-06-15Avoid allocations in Debug for os_strStepan Koltsov-21/+59
Fixes #38879
2017-06-08std: Handle ENOSYS when calling `pipe2`Alex Crichton-6/+23
Should help fix an accidental regression from #39386.
2017-06-06Add conversions from File and Child* handles to StdioJosh Stone-0/+36
`Stdio` now implements `From<ChildStdin>`, `From<ChildStdout>`, `From<ChildStderr>`, and `From<File>`. The `Command::stdin`/`stdout`/`stderr` methods now take any type that implements `Into<Stdio>`. This makes it much easier to write shell-like command chains, piping to one another and redirecting to and from files. Otherwise one would need to use the unsafe and OS-specific `from_raw_fd` or `from_raw_handle`.
2017-06-06Auto merge of #42436 - ollie27:win_spawn_name, r=alexcrichtonbors-8/+10
Always quote program name in Command::spawn on Windows [`CreateProcess`](https://msdn.microsoft.com/en-us/library/windows/desktop/ms682425.aspx) will interpret args as part of the binary name if it doesn't find the binary using just the unquoted name. For example if `foo.exe` doesn't exist, `Command::new("foo").arg("bar").spawn()` will try to launch `foo bar.exe` which is clearly not desired.
2017-06-05[fuchsia] Track change of mx_job_defaultRaph Levien-5/+1
The implementation of mx_job_default changed from a macro which accessed the __magenta_job_default global variable to a proper function call. This patch tracks that change.
2017-06-04Always quote program name in Command::spawn on WindowsOliver Middleton-8/+10
`CreateProcess` will interpret args as part of the binary name if it doesn't find the binary using just the unquoted name. For example if `foo.exe` doesn't exist, `Command::new("foo").arg("bar").spawn()` will try to launch `foo bar.exe` which is clearly not desired.
2017-06-02Switch to repr(C) for syscall structsJeremy Soller-3/+3
2017-05-21Implement requires_synchronized_create() for RedoxIan Douglas Scott-0/+5
This was breaking the libstd build for Redox.
2017-05-20migrate everything to using mem::needs_dropAlexis Beingessner-6/+7
2017-05-19Rollup merge of #42056 - sylvestre:master, r=alexcrichtonMark Simulacrum-1/+6
Improve the error management when /proc is not mounted This PR does two things: * Triggers an error on GNU/Linux & Android when /proc/self/exe doesn't exist * Handle the error properly
2017-05-19Rollup merge of #41870 - excaliburHisSheath:iss29367-windows-docs, r=frewsxcvMark Simulacrum-57/+286
Improve docs in os::windows::ffi and os::windows::fs Part of #29367 This PR makes changes to the documentation in `os::windows::ffi` and `os::windows::fs` with the goal of fleshing them out and bringing them in line with Rust's quality standards. r? @steveklabnik
2017-05-19Fix doc test failure for OpenOptionsExtDavid LeGare-1/+1
2017-05-18Normalize docs in windows::ffi and windows::fsDavid LeGare-57/+64
- Remove `()` parens when referencing functions in docs. - Change some examples to be no_run instead of ignore. - Normalize style in examples for `OpenOptionsExt`. - Fix typo in windows mod docs.
2017-05-17Improve the error management when /proc is not mountedSylvestre Ledru-1/+6
This PR does two things: * Triggers an error on GNU/Linux & Android when /proc/self/exe doesn't exist * Handle the error properly
2017-05-11Auto merge of #41684 - jethrogb:feature/ntstatus, r=alexcrichtonbors-3/+38
Windows io::Error: also format NTSTATUS error codes `NTSTATUS` errors may be encoded as `HRESULT`, see [[MS-ERREF]](https://msdn.microsoft.com/en-us/library/cc231198.aspx). These error codes can still be formatted using `FormatMessageW` but require some different parameters to be passed in. I wasn't sure if this needed a test and if so, how to test it. Presumably we wouldn't want to make our tests dependent on localization-dependent strings returned from `FormatMessageW`. Users that get an `err: NTSTATUS` will need to do `io::Error::from_raw_os_error(err|0x1000_0000)` (the equivalent of [`HRESULT_FROM_NT`](https://msdn.microsoft.com/en-us/library/ms693780(VS.85).aspx))
2017-05-11Add testJethro Beekman-0/+14
2017-05-09Fix tidy errorsDavid LeGare-3/+6
2017-05-07Fix documentation tests in windows::fsDavid LeGare-3/+1
2017-05-06Update documentation in windows::fsDavid LeGare-10/+127
2017-05-06Fix definitions of ULONG_PTRJoshua Sheard-3/+4
2017-05-05Merge remote-tracking branch 'rust-lang/master' into iss29367-windows-docsDavid LeGare-118/+147
2017-05-05Update documentation in windows::ffiDavid LeGare-21/+91
2017-05-05Update documention in windows::ffiDavid LeGare-9/+43
2017-05-05std: Avoid locks during TLS destruction on WindowsAlex Crichton-100/+71
Gecko recently had a bug reported [1] with a deadlock in the Rust TLS implementation for Windows. TLS destructors are implemented in a sort of ad-hoc fashion on Windows as it doesn't natively support destructors for TLS keys. To work around this the runtime manages a list of TLS destructors and registers a hook to get run whenever a thread exits. When a thread exits it takes a look at the list and runs all destructors. Unfortunately it turns out that there's a lock which is held when our "at thread exit" callback is run. The callback then attempts to acquire a lock protecting the list of TLS destructors. Elsewhere in the codebase while we hold a lock over the TLS destructors we try to acquire the same lock held first before our special callback is run. And as a result, deadlock! This commit sidesteps the issue with a few small refactorings: * Removed support for destroying a TLS key on Windows. We don't actually ever exercise this as a public-facing API, and it's only used during `lazy_init` during racy situations. To handle that we just synchronize `lazy_init` globally on Windows so we never have to call `destroy`. * With no need to support removal the global synchronized `Vec` was tranformed to a lock-free linked list. With the removal of locks this means that iteration no long requires a lock and as such we won't run into the deadlock problem mentioned above. Note that it's still a general problem that you have to be extra super careful in TLS destructors. For example no code which runs a TLS destructor on Windows can call back into the Windows API to do a dynamic library lookup. Unfortunately I don't know of a great way around that, but this at least fixes the immediate problem that Gecko was seeing which is that with "well behaved" destructors the system would still deadlock! [1]: https://bugzilla.mozilla.org/show_bug.cgi?id=1358151
2017-05-03Windows io::Error: also format NTSTATUS error codesJethro Beekman-3/+24
2017-04-25Fix a copy-paste error in `Instant::sub_duration`Tobias Bucher-1/+1
Fixes #41514.
2017-04-18Rollup merge of #41353 - redox-os:master, r=alexcrichtonCorey Farwell-9/+18
Improve Process::spawn with piped stdio on Redox - Adds `dup2`, and uses it for stdio piping - Removes `O_CLOEXEC` from piped stdio, as `dup` on Redox does not disable O_CLOEXEC
2017-04-16Fix stdio descriptors in exec by removing cloexec if present. Use dup2 ↵Jeremy Soller-9/+18
instead of dup
2017-04-14Update magenta error codesTheodore DeRego-34/+43
2017-04-06Rollup merge of #41111 - ollie27:docs_markdown_fix, r=GuillaumeGomezCorey Farwell-1/+2
Fix Markdown issues in the docs * Since the switch to pulldown-cmark reference links need a blank line before the URLs. (#40912) * Reference link references are not case sensitive. * Doc comments need to be indented uniformly otherwise rustdoc gets confused.
2017-04-06Fix Markdown issues in the docsOliver Middleton-1/+2
* Since the switch to pulldown-cmark reference links need a blank line before the URLs. * Reference link references are not case sensitive. * Doc comments need to be indented uniformly otherwise rustdoc gets confused.
2017-04-06Auto merge of #41039 - alexcrichton:process-poll, r=nagisabors-13/+9
std: Use `poll` instead of `select` This gives us the benefit of supporting file descriptors over the limit that select supports, which... Closes #40894
2017-04-05Rollup merge of #41054 - anatol:master, r=alexcrichtonAriel Ben-Yehuda-1/+1
Replace magic number with readable sig constant SIG_ERR is defined as 'pub const SIG_ERR: sighandler_t = !0 as sighandler_t;'
2017-04-04std: Use `poll` instead of `select`Alex Crichton-13/+9
This gives us the benefit of supporting file descriptors over the limit that select supports, which... Closes #40894
2017-04-03Replace magic number with readable sig constantAnatol Pomozov-1/+1
SIG_ERR is defined as 'pub const SIG_ERR: sighandler_t = !0 as sighandler_t;'
2017-04-03Revert "Implement AsRawFd/IntoRawFd for RawFd"Cody P Schafer-15/+0
This reverts commit 2cf686f2cdd6446a3cd47df0305ead40fabe85df (#40842) RawFd is a type alias for c_int, which is itself a type alias for i32. As a result, adding AsRawFd and IntoRawFd impls for RawFd actually adds them for i32. As a result, the reverted commit makes this valid: ``` use std::os::unix::io::AsRawFd; fn arf<T: AsRawFd>(_: T) {} fn main() { arf(32i32) } ``` Implimenting AsRawFd and IntoRawFd for i32 breaks the promises of both those traits that their methods return a valid RawFd. r? @aturon cc @Mic92 @kamalmarhubi
2017-03-31Rollup merge of #40842 - Mic92:RawFd, r=aturonCorey Farwell-0/+15
Implement AsRawFd/IntoRawFd for RawFd This is useful to build os abstraction like the nix crate does. It allows to define functions, which accepts generic arguments of data structures convertible to RawFd, including RawFd itself. For example: ``` fn write<FD: AsRawFd>(fd: FD, buf: &[u8]) -> Result<usize> write(file, buf); ``` instead of: ``` fn write(fd: RawFd, buf: &[u8]) -> Result<usize> write(file.as_raw_fd(), buf); ``` cc @kamalmarhubi