about summary refs log tree commit diff
path: root/src/libstd/sys/unix/thread.rs
AgeCommit message (Collapse)AuthorLines
2016-07-11std: Fix `Thread::set_name()` for newlib and solarisJosh Stone-1/+0
The `use ffi::CStr` in `unix/thread.rs` was previously guarded, but now all platforms need it for `Thread::set_name()`. Newlib and Solaris do nothing here, as they have no way to set a thread name, but they still define the same method signature.
2016-06-21Fix overflow error in thread::sleepGuillaume Gomez-6/+15
2016-04-06Remove accidental commentAlan Somers-1/+0
2016-04-05Reduce code duplication in thread.rsAlan Somers-42/+18
2016-04-04Fix stack overflow detection on FreeBSDAlan Somers-1/+44
src/libstd/sys/unix/thread.rs Implement several stack-related functions on FreeBSD src/libstd/sys/unix/stack_overflow.rs Fix a comment
2016-03-25Fix unsound behaviour with null characters in thread names (issue #32475)David Henningsson-16/+11
Previously, the thread name (&str) was converted to a CString in the new thread, but outside unwind::try, causing a panic to continue into FFI. This patch changes that behaviour, so that the panic instead happens in the parent thread (where panic infrastructure is properly set up), not the new thread. This could potentially be a breaking change for architectures who don't support thread names. Signed-off-by: David Henningsson <diwic@ubuntu.com>
2016-02-06Auto merge of #30629 - brson:emscripten-upstream, r=alexcrichtonbors-3/+5
Here's another go at adding emscripten support. This needs to wait again on new [libc definitions](https://github.com/rust-lang-nursery/libc/pull/122) landing. To get the libc definitions right I had to add support for i686-unknown-linux-musl, which are very similar to emscripten's, which are derived from arm/musl. This branch additionally removes the makefile dependency on the `EMSCRIPTEN` environment variable by not building the unused compiler-rt. Again, this is not sufficient for actually compiling to asmjs since it needs additional LLVM patches. r? @alexcrichton
2016-02-06Add support for i686-unknown-linux-muslBrian Anderson-2/+2
2016-02-06Add the asmjs-unknown-emscripten triple. Add cfgs to libs.Brian Anderson-1/+3
Backtraces, and the compilation of libbacktrace for asmjs, are disabled. This port doesn't use jemalloc so, like pnacl, it disables jemalloc *for all targets* in the configure file. It disables stack protection.
2016-02-05std: Add a helper for symbols that may not existAlex Crichton-27/+2
Right now we only attempt to call one symbol which my not exist everywhere, __pthread_get_minstack, but this pattern will come up more often as we start to bind newer functionality of systems like Linux. Take a similar strategy as the Windows implementation where we use `dlopen` to lookup whether a symbol exists or not.
2016-01-31Fix unresolved name in libstd/sys/unix/threadNikita Baksalyar-1/+1
2016-01-31Rename sunos to solarisNikita Baksalyar-6/+6
2016-01-31Add Illumos supportNikita Baksalyar-7/+17
2016-01-28std: Fix rumprun buildAlex Crichton-4/+9
Looks like the rumprun build has bitrotted over time, so this includes some libc fixes and some various libstd fixes which gets it back to bootstrapping.
2016-01-26Fix warnings during testsAlex Crichton-11/+8
The deny(warnings) attribute is now enabled for tests so we need to weed out these warnings as well.
2015-12-04Add JoinHandleExt to get the pthread_t on unix platformsPeter Atashian-0/+8
Signed-off-by: Peter Atashian <retep998@gmail.com>
2015-11-09std: Migrate to the new libcAlex Crichton-105/+38
* Delete `sys::unix::{c, sync}` as these are now all folded into libc itself * Update all references to use `libc` as a result. * Update all references to the new flat namespace. * Moves all windows bindings into sys::c
2015-10-29Auto merge of #29289 - DiamondLovesYou:pnacl-std-crates, r=alexcrichtonbors-0/+5
2015-10-28Port the standard crates to PNaCl/NaCl.Richard Diamond-0/+5
2015-10-25std: Stabilize library APIs for 1.5Alex Crichton-0/+1
This commit stabilizes and deprecates library APIs whose FCP has closed in the last cycle, specifically: Stabilized APIs: * `fs::canonicalize` * `Path::{metadata, symlink_metadata, canonicalize, read_link, read_dir, exists, is_file, is_dir}` - all moved to inherent methods from the `PathExt` trait. * `Formatter::fill` * `Formatter::width` * `Formatter::precision` * `Formatter::sign_plus` * `Formatter::sign_minus` * `Formatter::alternate` * `Formatter::sign_aware_zero_pad` * `string::ParseError` * `Utf8Error::valid_up_to` * `Iterator::{cmp, partial_cmp, eq, ne, lt, le, gt, ge}` * `<[T]>::split_{first,last}{,_mut}` * `Condvar::wait_timeout` - note that `wait_timeout_ms` is not yet deprecated but will be once 1.5 is released. * `str::{R,}MatchIndices` * `str::{r,}match_indices` * `char::from_u32_unchecked` * `VecDeque::insert` * `VecDeque::shrink_to_fit` * `VecDeque::as_slices` * `VecDeque::as_mut_slices` * `VecDeque::swap_remove_front` - (renamed from `swap_front_remove`) * `VecDeque::swap_remove_back` - (renamed from `swap_back_remove`) * `Vec::resize` * `str::slice_mut_unchecked` * `FileTypeExt` * `FileTypeExt::{is_block_device, is_char_device, is_fifo, is_socket}` * `BinaryHeap::from` - `from_vec` deprecated in favor of this * `BinaryHeap::into_vec` - plus a `Into` impl * `BinaryHeap::into_sorted_vec` Deprecated APIs * `slice::ref_slice` * `slice::mut_ref_slice` * `iter::{range_inclusive, RangeInclusive}` * `std::dynamic_lib` Closes #27706 Closes #27725 cc #27726 (align not stabilized yet) Closes #27734 Closes #27737 Closes #27742 Closes #27743 Closes #27772 Closes #27774 Closes #27777 Closes #27781 cc #27788 (a few remaining methods though) Closes #27790 Closes #27793 Closes #27796 Closes #27810 cc #28147 (not all parts stabilized)
2015-09-26Add support for the rumprun unikernelSebastian Wicki-2/+2
For most parts, rumprun currently looks like NetBSD, as they share the same libc and drivers. However, being a unikernel, rumprun does not support process management, signals or virtual memory, so related functions might fail at runtime. Stack guards are disabled exactly for this reason. Code for rumprun is always cross-compiled, it uses always static linking and needs a custom linker.
2015-09-21Various fixes for NetBSD/amd64Sebastian Wicki-7/+24
2015-09-08some more clippy-based improvementsAndre Bogus-1/+1
2015-09-03Use `null()`/`null_mut()` instead of `0 as *const T`/`0 as *mut T`Vadim Petrochenkov-1/+1
2015-08-11Register new snapshotsAlex Crichton-3/+0
* Lots of core prelude imports removed * Makefile support for MSVC env vars and Rust crates removed * Makefile support for morestack removed
2015-08-11Auto merge of #26818 - sfackler:duration-stabilization, r=aturonbors-2/+2
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-2/+2
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-10Remove morestack supportAlex Crichton-4/+1
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-04syntax: Don't assume `std` exists for testsAlex Crichton-0/+1
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-07-21std: Be resilient to failure in pthread_getattr_npAlex Crichton-38/+50
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-01Add netbsd amd64 supportAlex Newman-1/+5
2015-05-27Use `const fn` to abstract away the contents of UnsafeCell & friends.Eduard Burtescu-2/+2
2015-05-13std: Redesign Duration, implementing RFC 1040Alex Crichton-7/+2
This commit is an implementation of [RFC 1040][rfc] which is a redesign of the currently-unstable `Duration` type. The API of the type has been scaled back to be more conservative and it also no longer supports negative durations. [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/1040-duration-reform.md The inner `duration` module of the `time` module has now been hidden (as `Duration` is reexported) and the feature name for this type has changed from `std_misc` to `duration`. All APIs accepting durations have also been audited to take a more flavorful feature name instead of `std_misc`. Closes #24874
2015-04-27std: Don't assume dlopen() works on yourselfAlex Crichton-1/+4
Statically linked executables do not succeed (aka MUSL-based executables).
2015-04-22std: Audit std::thread implementationsAlex Crichton-130/+144
Much of this code hasn't been updated in quite some time and this commit does a small audit of the functionality: * Implementation functions now centralize all functionality on a locally defined `Thread` type. * The `detach` method has been removed in favor of a `Drop` implementation. This notably fixes leaking thread handles on Windows. * The `Thread` structure is now appropriately annotated with `Send` and `Sync` automatically on Windows and in a custom fashion on Unix. * The unsafety of creating a thread has been pushed out to the right boundaries now. Closes #24442
2015-04-08std: Stabilize io::Error::from_raw_os_errorAlex Crichton-1/+1
This commit stabilizes the old `io::Error::from_os_error` after being renamed to use the `raw_os_error` terminology instead. This function is often useful when writing bindings to OS functions but only actually converting to an I/O error at a later point.
2015-03-23Test fixes and rebase conflicts, round 2Alex Crichton-2/+3
2015-03-23rollup merge of #23640: nagisa/thread-less-weakAlex Crichton-11/+8
This is more portable as far as linux is concerned.
2015-03-23prctl instead of pthread on linux for name setupSimonas Kazlauskas-11/+8
This is more portable as far as linux is concerned.
2015-03-23min_stack_size: clarify both reasons to use dlsymAnders Kaseorg-5/+6
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2015-03-23min_stack_size: update non-Linux implementation commentAnders Kaseorg-2/+2
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2015-03-23Get __pthread_get_minstack at runtime with dlsymAnders Kaseorg-12/+23
Linking __pthread_get_minstack, even weakly, was causing Debian’s dpkg-shlibdeps to detect an unnecessarily strict versioned dependency on libc6. Closes #23628. Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2015-03-18openbsd/bitrig threadsSébastien Marie-4/+2
- remove `pub` from `struct` (visibility has no effect inside functions) - move `pthread_main_np` into function
2015-03-17std: Implement `thread::sleep`Alex Crichton-1/+15
This function is the current replacement for `std::old_io::timer` which will soon be deprecated. This function is unstable and has its own feature gate as it does not yet have an RFC nor has it existed for very long.
2015-03-15std: Clean up the sys::thread modulesAlex Crichton-181/+123
This module had become a #[cfg] jungle, try to bring at least a small semblance of order to it!
2015-03-12std: Remove #[allow] directives in sys modulesAlex Crichton-4/+7
These were suppressing lots of interesting warnings! Turns out there was also quite a bit of dead code.
2015-02-28openbsd: adjust page guard addressSébastien Marie-1/+1
some commits in OpenBSD base have corrected a problem of stack position. Now, we can adjust more accurately the page guard in rust.
2015-02-23Use boxed functions instead of transmuteStepan Koltsov-2/+5
... to convert between Box and raw pointers. E. g. use ``` let b: Box<Foo> = Box::from_raw(p); ``` instead of ``` let b: Box<Foo> = mem::transmute(p); ``` Patch also changes closure release code in `src/libstd/sys/unix/thread.rs` when `pthread_create` failed. Raw pointer was transmuted to box of `FnOnce()` instead of `Thunk`. This code was probably never executed, because `pthread_create` rarely fails in practice.
2015-02-21Auto merge of #21959 - dhuseby:bitrig-support, r=brsonbors-2/+33
This patch adds the necessary pieces to support rust on Bitrig https://bitrig.org
2015-02-18std: Implement CString-related RFCsAlex Crichton-3/+3
This commit is an implementation of [RFC 592][r592] and [RFC 840][r840]. These two RFCs tweak the behavior of `CString` and add a new `CStr` unsized slice type to the module. [r592]: https://github.com/rust-lang/rfcs/blob/master/text/0592-c-str-deref.md [r840]: https://github.com/rust-lang/rfcs/blob/master/text/0840-no-panic-in-c-string.md The new `CStr` type is only constructable via two methods: 1. By `deref`'ing from a `CString` 2. Unsafely via `CStr::from_ptr` The purpose of `CStr` is to be an unsized type which is a thin pointer to a `libc::c_char` (currently it is a fat pointer slice due to implementation limitations). Strings from C can be safely represented with a `CStr` and an appropriate lifetime as well. Consumers of `&CString` should now consume `&CStr` instead to allow producers to pass in C-originating strings instead of just Rust-allocated strings. A new constructor was added to `CString`, `new`, which takes `T: IntoBytes` instead of separate `from_slice` and `from_vec` methods (both have been deprecated in favor of `new`). The `new` method returns a `Result` instead of panicking. The error variant contains the relevant information about where the error happened and bytes (if present). Conversions are provided to the `io::Error` and `old_io::IoError` types via the `FromError` trait which translate to `InvalidInput`. This is a breaking change due to the modification of existing `#[unstable]` APIs and new deprecation, and more detailed information can be found in the two RFCs. Notable breakage includes: * All construction of `CString` now needs to use `new` and handle the outgoing `Result`. * Usage of `CString` as a byte slice now explicitly needs a `.as_bytes()` call. * The `as_slice*` methods have been removed in favor of just having the `as_bytes*` methods. Closes #22469 Closes #22470 [breaking-change]