about summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2016-10-10Auto merge of #36341 - sagebind:thread_id, r=alexcrichtonbors-0/+59
Add ThreadId for comparing threads This adds the capability to store and compare threads with the current calling thread via a new struct, `std::thread::ThreadId`. Addresses the need outlined in issue #21507. This avoids the need to add any special checks to the existing thread structs and does not rely on the system to provide an identifier for a thread, since it seems that this approach is unreliable and undesirable. Instead, this simply uses a lazily-created, thread-local `usize` whose value is copied from a global atomic counter. The code should be simple enough that it should be as much reliable as the `#[thread_local]` attribute it uses (however much that is). `ThreadId`s can be compared directly for equality and have copy semantics. Also see these other attempts: - rust-lang/rust#29457 - rust-lang/rust#29448 - rust-lang/rust#29447 And this in the RFC repo: rust-lang/rfcs#1435
2016-10-09use MSG_NOSIGNAL on all relevant platformsMathieu Poumeyrol-6/+18
2016-10-09Use `try_into` and move some functionsTobias Bucher-29/+37
2016-10-09Dynamically detect presence of `p{read,write}64` on AndroidTobias Bucher-23/+68
2016-10-09Implement reading and writing atomically at certain offsetsTobias Bucher-2/+295
These functions allow to read from and write to a file in one atomic action from multiple threads, avoiding the race between the seek and the read. The functions are named `{read,write}_at` on non-Windows (which don't change the file cursor), and `seek_{read,write}` on Windows (which change the file cursor).
2016-10-08Use less `size_t` casts in libstd since it's now defined as `usize`Tobias Bucher-38/+32
2016-10-07Unlock guard before overflow panicStephen M. Coakley-0/+1
2016-10-06Auto merge of #36753 - srinivasreddy:hash, r=nrcbors-279/+438
run rustfmt on libstd/collections/hash folder
2016-10-06Rollup merge of #36977 - Razican:bufreader_typo_fix, r=alexcrichtonJonathan Turner-1/+1
Fixed small typo in `BufRead` comments `BufRead` comments, in the `Seek` trait implementation, was talking about allocating 8 *ebibytes*. It was a typo, the correct unit is *exbibytes*, since *ebibytes* don't even exist. The calculation is correct, though.
2016-10-06Rollup merge of #36965 - kallisti5:master, r=alexcrichtonJonathan Turner-1/+1
Haiku: Fix IPv6 target_os check
2016-10-05Auto merge of #36893 - apasel422:issue-32114, r=alexcrichtonbors-0/+9
Restore `DISCONNECTED` state in `oneshot::Packet::send` Closes #32114 I'm not sure if this is the best approach, but the current action of swapping `DISCONNECTED` with `DATA` seems wrong. Additionally, it is strange that the `send` method (and others in the `oneshot` module) takes `&mut self` despite performing atomic operations, as this requires extra discipline to avoid data races and lets us use methods like `AtomicUsize::get_mut` instead of methods that require a memory ordering.
2016-10-05Use mutex to guard thread ID counterStephen M. Coakley-30/+8
2016-10-05Restore `DISCONNECTED` state in `oneshot::Packet::send`Andrew Paseltiner-0/+9
Closes #32114
2016-10-05Generate ID using u64 + atomic spinlockStephen M. Coakley-14/+54
2016-10-05Auto merge of #36944 - brson:modos, r=alexcrichtonbors-3/+3
Fix mod declarations on untested platforms r? @alexcrichton
2016-10-05Fixed small typo in `BufRead` commentsRazican-1/+1
`BufRead` comments, in the `Seek` trait implementation, was talking about allocating 8 *ebibytes*. It was a typo, the correct unit is *exbibytes*, since *ebibytes* don't even exist. The calculation is correct, though.
2016-10-04Haiku: Fix IPv6 target_os checkAlexander von Gluck IV-1/+1
2016-10-04Rollup merge of #36938 - tmiasko:cursor-seek-overflow, r=alexcrichtonManish Goregaokar-7/+18
Check for overflow in Cursor<Vec<u8>>::write. Ensure that cursor position fits into usize, before proceeding with write. Fixes issue #36884.
2016-10-04Rollup merge of #36928 - GuillaumeGomez:error_urls, r=steveklabnikManish Goregaokar-4/+8
Add missing urls for error module r? @steveklabnik
2016-10-04Rollup merge of #36916 - frewsxcv:patch-1, r=alexcrichtonManish Goregaokar-1/+1
Update unstable attr to reference tracking issue.
2016-10-04Rollup merge of #36902 - ollie27:stab_impls, r=alexcrichtonManish Goregaokar-18/+15
std: Correct stability attributes for some implementations These are displayed by rustdoc so should be correct.
2016-10-03Add two functions to check type of SockAddrAbhishek Chanda-0/+35
These can be used to determine the type of the underlying IP address
2016-10-03Add two functions to check type of given addressAbhishek Chanda-0/+32
The is_v4 function returns true if the given IP is v4. The is_v6 function returns true if the IP is v6.
2016-10-03Fix mod declarations on untested platformsBrian Anderson-3/+3
2016-10-03Check for overflow in Cursor<Vec<u8>>::write.Tomasz Miąsko-7/+18
Ensure that cursor position fits into usize, before proceeding with write. Fixes issue #36884.
2016-10-03Auto merge of #36815 - alexcrichton:stabilize-1.13, r=aturonbors-12/+37
std: Stabilize and deprecate APIs for 1.13 This commit is intended to be backported to the 1.13 branch, and works with the following APIs: Stabilized * `i32::checked_abs` * `i32::wrapping_abs` * `i32::overflowing_abs` * `RefCell::try_borrow` * `RefCell::try_borrow_mut` Deprecated * `BinaryHeap::push_pop` * `BinaryHeap::replace` * `SipHash13` * `SipHash24` * `SipHasher` - use `DefaultHasher` instead in the `std::collections::hash_map` module Closes #28147 Closes #34767 Closes #35057 Closes #35070
2016-10-03std: Stabilize and deprecate APIs for 1.13Alex Crichton-12/+37
This commit is intended to be backported to the 1.13 branch, and works with the following APIs: Stabilized * `i32::checked_abs` * `i32::wrapping_abs` * `i32::overflowing_abs` * `RefCell::try_borrow` * `RefCell::try_borrow_mut` * `DefaultHasher` * `DefaultHasher::new` * `DefaultHasher::default` Deprecated * `BinaryHeap::push_pop` * `BinaryHeap::replace` * `SipHash13` * `SipHash24` * `SipHasher` - use `DefaultHasher` instead in the `std::collections::hash_map` module Closes #28147 Closes #34767 Closes #35057 Closes #35070
2016-10-03Add missing urls for error moduleGuillaume Gomez-4/+8
2016-10-03Auto merge of #36766 - nnethercote:hash-span-capacity, r=blussbors-90/+122
Clarify HashMap's capacity handling. HashMap has two notions of "capacity": - "Usable capacity": the number of elements a hash map can hold without resizing. This is the meaning of "capacity" used in HashMap's API, e.g. the `with_capacity()` function. - "Internal capacity": the number of allocated slots. Except for the zero case, it is always larger than the usable capacity (because some slots must be left empty) and is always a power of two. HashMap's code is confusing because it does a poor job of distinguishing these two meanings. I propose using two different terms for these two concepts. Because "capacity" is already used in HashMap's API to mean "usable capacity", I will use a different word for "internal capacity". I propose "span", though I'm happy to consider other names.
2016-10-03Avoid overflow check in `HashMap::reserve`'s fast path.Nicholas Nethercote-2/+3
2016-10-02Update unstable attr to reference tracking issue.Corey Farwell-1/+1
2016-10-02Auto merge of #36807 - brson:pal, r=brsonbors-880/+959
Restrict where in the tree platform-specific cfgs may be mentioned With the ports of Rust never ending, it's important that we keep things tidy. The main thing this PR does is introduce a new "pal" (platform abstraction layer) tidy check that limits where platform-specific CFGs may appear. This is intended to maintain existing standards of code organization in hopes that the standard library will continue to be refactored to isolate platform-specific bits, making porting easier; where "standard library" roughly means "all the dependencies of the std and test crates". This generally means placing restrictions on where `cfg(unix)`, `cfg(windows)`, `cfg(target_os)` and `cfg(target_env)` may appear, the basic objective being to isolate platform-specific code to the platform-specific `std::sys` modules, and to the allocation, unwinding, and libc crates. Following are the basic rules, though there are currently exceptions: - core may not have platform-specific code - liballoc_system may have platform-specific code - liballoc_jemalloc may have platform-specific code - libpanic_abort may have platform-specific code - libpanic_unwind may have platform-specific code - other crates in the std facade may not - std may have platform-specific code in the following places - sys/unix/ - sys/windows/ - os/ There are plenty of exceptions today though, noted in the whitelist. The end-state, IMO, is for the standard library to be portable by porting only `std::sys` (possibly extracted to its own crate), an allocator crate, an unwinder crate, and possibly a libc crate (if std depends on it); but that outcome is far off and independent of the utility of enforcing where such code lives today. cc @rust-lang/libs
2016-10-02Move platform-specific arg handling to sys::argsBrian Anderson-281/+294
2016-10-02Add a platform-abstraction tidy scriptBrian Anderson-3/+6
This is intended to maintain existing standards of code organization in hopes that the standard library will continue to be refactored to isolate platform-specific bits, making porting easier; where "standard library" roughly means "all the dependencies of the std and test crates". This generally means placing restrictions on where `cfg(unix)`, `cfg(windows)`, `cfg(target_os)` and `cfg(target_env)` may appear, the basic objective being to isolate platform-specific code to the platform-specific `std::sys` modules, and to the allocation, unwinding, and libc crates. Following are the basic rules, though there are currently exceptions: - core may not have platform-specific code - liballoc_system may have platform-specific code - liballoc_jemalloc may have platform-specific code - libpanic_abort may have platform-specific code - libpanic_unwind may have platform-specific code - other crates in the std facade may not - std may have platform-specific code in the following places - sys/unix/ - sys/windows/ - os/ There are plenty of exceptions today though, noted in the whitelist.
2016-10-02Auto merge of #36404 - christopherdumas:master, r=GuillaumeGomezbors-3/+10
Documentation change to macros.rs for `includes!` I'm not sure if this documentation is clear or extensive enough, but this is just to get started on the problem, fixes issue #36387.
2016-10-01std: Correct stability attributes for some implementationsOliver Middleton-18/+15
These are displayed by rustdoc so should be correct.
2016-10-01std: Remove plattform-specific code from os_strBrian Anderson-11/+0
2016-10-01std: Move platform specific stdio code into sysBrian Anderson-5/+6
2016-10-01std: Move platform specific memchr code into sysBrian Anderson-271/+309
2016-10-01std: Move platform specific env code into sysBrian Anderson-183/+203
2016-10-01std: Move platform specific path code into sysBrian Anderson-126/+141
2016-10-01Auto merge of #36824 - kali:master, r=alexcrichtonbors-5/+27
SO_NOSIGPIPE and MSG_NOSIGNAL (rebased #36426) I'm not sure what happened when I pushed a rebased branch on #36426 , github closed it...
2016-09-30Auto merge of #36339 - brson:emscripten-new, r=alexcrichtonbors-30/+76
Working asmjs and wasm targets This patch set results in a working standard library for the asmjs-unknown-emscripten and wasm32-unknown-emscripten targets. It is based on the work of @badboy and @rschulman. It does a few things: - Updates LLVM with the emscripten [fastcomp](https://github.com/rust-lang/llvm/pull/50) patches, which include the pnacl IR legalizer and the asm.js backend. This patch is thought not to have any significant effect on existing targets. - Teaches rustbuild to correctly link C code with emscripten - Updates gcc-rs to work correctly with emscripten - Teaches rustbuild to run crate tests for emscripten with node - Modifies Thread::new to return an error on emscripten, to facilitate debugging a common failure mode - Modifies libtest to run in single-threaded mode for emscripten - Ignores a host of tests that don't work yet, mostly dealing with threads and I/O - Updates libc with wasm32 definitions (presently the same as asmjs) - Adds a wasm32-unknown-emscripten target that feeds the output of LLVM's asmjs backend through emcc to generate wasm Notes and caveats: - This is only known to work with `--enable-rustbuild`. - The wasm32 target can't be tested correctly yet because of issues in compiletest and limitations in node https://github.com/kripken/emscripten/issues/4542, but hello.rs does seem to work when run on node via the binaryen interpreter - This requires an up to date installation of the emscripten sdk from its incoming branch - Unwinding is very broken - When enabling the emscripten targets jemalloc is disabled for all targets, which results in test failures for the host Next steps are to fix the jemalloc issue, start building the two emscripten targets on the auto builders, then start producing nightlies. https://github.com/rust-lang/rust/issues/36317 tracks work on this. Fixes https://github.com/rust-lang/rust/issues/36515 Fixes https://github.com/rust-lang/rust/issues/36515 Fixes https://github.com/rust-lang/rust/issues/36356
2016-09-30Call emcc with ERROR_ON_UNDEFINED_SYMBOLSBrian Anderson-5/+18
2016-09-30Ignore various entire test modules on emscriptenBrian Anderson-125/+11
2016-09-30Change the sigs of set_print/set_panic to allow restoring the default objectsBrian Anderson-4/+4
2016-09-30Ignore entire test modules on emscripten instead of individual testsBrian Anderson-132/+10
2016-09-30Ignore lots and lots of std tests on emscriptenBrian Anderson-0/+252
2016-09-30Preliminary wasm32 supportBrian Anderson-2/+19
2016-09-30Rollup merge of #36851 - tmiasko:fix-read-until-docs, r=blussSteve Klabnik-7/+3
Fix BufRead::read_until documentation. Second paragraph already fully explains what happens when EOF is encountered. The third paragraph (removed one) is spurious and misleading.