about summary refs log tree commit diff
path: root/src/libstd/sys
AgeCommit message (Collapse)AuthorLines
2017-07-12Rollup merge of #43100 - ids1024:stat2, r=aturonMark Simulacrum-2/+17
Redox: add stat methods(); support is_symlink()
2017-07-11Redox: Use O_NOFOLLOW for lstat()Ian Douglas Scott-1/+5
2017-07-09Auto merge of #43082 - ids1024:condvar2, r=alexcrichtonbors-3/+1
Redox: Fix Condvar.wait(); do not lock mutex twice The atomic_xchg() loop locks the mutex, so the call to mutex_lock is incorrect, and blocks.
2017-07-07Skip the main thread's manual stack guard on LinuxJosh Stone-15/+29
Linux doesn't allocate the whole stack right away, and the kernel has its own stack-guard mechanism to fault when growing too close to an existing mapping. If we map our own guard, then the kernel starts enforcing a rather large gap above that, rendering much of the possible stack space useless. Instead, we'll just note where we expect rlimit to start faulting, so our handler can report "stack overflow", and trust that the kernel's own stack guard will work. Fixes #43052.
2017-07-07Redox: Fix Condvar.wait(); do not lock mutex twiceIan Douglas Scott-3/+1
The atomic_xchg() loop locks the mutex, so the call to mutex_lock is incorrect, and blocks.
2017-07-06Implement TcpStream::connect_timeoutSteven Fackler-2/+152
This breaks the "single syscall rule", but it's really annoying to hand write and is pretty foundational.
2017-07-06Redox: add stat methods(); support is_symlink()Ian Douglas Scott-2/+17
2017-07-06Auto merge of #42727 - alexcrichton:allocators-new, r=eddybbors-38/+0
rustc: Implement the #[global_allocator] attribute This PR is an implementation of [RFC 1974] which specifies a new method of defining a global allocator for a program. This obsoletes the old `#![allocator]` attribute and also removes support for it. [RFC 1974]: https://github.com/rust-lang/rfcs/pull/1974 The new `#[global_allocator]` attribute solves many issues encountered with the `#![allocator]` attribute such as composition and restrictions on the crate graph itself. The compiler now has much more control over the ABI of the allocator and how it's implemented, allowing much more freedom in terms of how this feature is implemented. cc #27389
2017-07-05rustc: Implement the #[global_allocator] attributeAlex Crichton-38/+0
This PR is an implementation of [RFC 1974] which specifies a new method of defining a global allocator for a program. This obsoletes the old `#![allocator]` attribute and also removes support for it. [RFC 1974]: https://github.com/rust-lang/rfcs/pull/197 The new `#[global_allocator]` attribute solves many issues encountered with the `#![allocator]` attribute such as composition and restrictions on the crate graph itself. The compiler now has much more control over the ABI of the allocator and how it's implemented, allowing much more freedom in terms of how this feature is implemented. cc #27389
2017-07-04Rollup merge of #42975 - ids1024:symlink2, r=aturonMark Simulacrum-6/+15
redox: symlink and readlink
2017-06-30Fix long lineIan Douglas Scott-1/+2
2017-06-29Fix Redox build, apparently broken by #42687Ian Douglas Scott-1/+5
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