about summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2013-10-09std::rand: Add a trait for seeding RNGs: SeedableRng.Huon Wilson-104/+223
This provides 2 methods: .reseed() and ::from_seed that modify and create respecitively. Implement this trait for the RNGs in the stdlib for which this makes sense.
2013-10-09std::rand: Add ReseedingRng, which will reseed an RNG after it generates a ↵Huon Wilson-0/+129
certain number of bytes. It is an "RNG adaptor" and so any RNG can be wrapped to have this behaviour.
2013-10-09std::rand: add the StdRng wrapper for a blessed RNG.Huon Wilson-7/+54
This is implemented as a wrapper around another RNG. It is designed to allow the actual implementation to be changed without changing the external API (e.g. it currently uses a 64-bit generator on 64- bit platforms, and a 32-bit one on 32-bit platforms; but one could imagine that the IsaacRng may be deprecated later, and having this ability to switch algorithms without having to update the points of use is convenient.) This is the recommended general use RNG.
2013-10-09std::rand: Add OSRng, ReaderRng wrappers around the OS RNG & generic Readers ↵Huon Wilson-30/+435
respectively. The former reads from e.g. /dev/urandom, the latter just wraps any std::rt::io::Reader into an interface that implements Rng. This also adds Rng.fill_bytes for efficient implementations of the above (reading 8 bytes at a time is inefficient when you can read 1000), and removes the dependence on src/rt (i.e. rand_gen_seed) although this last one requires implementing hand-seeding of the XorShiftRng used in the scheduler on Linux/unixes, since OSRng relies on a scheduler existing to be able to read from /dev/urandom.
2013-10-09std::rand: Add an implementation of ISAAC64.Huon Wilson-50/+281
This is 2x faster on 64-bit computers at generating anything larger than 32-bits. It has been verified against the canonical C implementation from the website of the creator of ISAAC64. Also, move `Rng.next` to `Rng.next_u32` and add `Rng.next_u64` to take full advantage of the wider word width; otherwise Isaac64 will always be squeezed down into a u32 wasting half the entropy and offering no advantage over the 32-bit variant.
2013-10-09std::rand: move the Isaac implementation to its own file.Huon Wilson-184/+207
2013-10-08Make std::rt::io::extensions publicSteven Fackler-1/+1
This works around #9779, but is probably the right thing to do anyways since that's the module where all of the documentation for those traits lives.
2013-10-08Fix float to float ToPrimitive implementation.Sébastien Crozet-2/+1
The mimimum (negative) value of a float is -Bounded::max_value(), not Bounded::min_value().
2013-10-08auto merge of #9757 : erickt/rust/master, r=alexcrichtonbors-3/+48
I accidentally left an infinite loop in a default method in `num::ToPrimitive::to_u64()`. This fixes it.
2013-10-08rm useless fast_ffi attributesDaniel Micay-24/+0
this is no longer used by the compiler
2013-10-08auto merge of #9759 : thestinger/rust/immediate, r=alexcrichtonbors-1/+3
Closes #9651
2013-10-08make small ty_struct immediateDaniel Micay-1/+3
Closes #9651
2013-10-07Fix merge fallout of privacy changesAlex Crichton-1/+1
2013-10-07std: fix an infinite loop in num::ToPrimitive and add testsErick Tryzelaar-3/+48
2013-10-07Fix existing privacy/visibility violationsAlex Crichton-21/+35
This commit fixes all of the fallout of the previous commit which is an attempt to refine privacy. There were a few unfortunate leaks which now must be plugged, and the most horrible one is the current `shouldnt_be_public` module now inside `std::rt`. I think that this either needs a slight reorganization of the runtime, or otherwise it needs to just wait for the external users of these modules to get replaced with their `rt` implementations. Other fixes involve making things pub which should be pub, and otherwise updating error messages that now reference privacy instead of referencing an "unresolved name" (yay!).
2013-10-06auto merge of #9703 : alexcrichton/rust/compiler-features, r=cmrbors-0/+2
This implements the necessary logic for gating particular features off by default in the compiler. There are a number of issues which have been wanting this form of mechanism, and this initially gates features which we have open issues for. Additionally, this should unblock #9255
2013-10-06auto merge of #9593 : fhahn/rust/logging-unsafe-removal, r=alexcrichtonbors-202/+305
This pull request changes to memory layout of the `CrateMap` struct to use static slices instead of raw pointers. Most of the discussion took place [here](https://github.com/fhahn/rust/commit/63b5975efa10af7df3df0a50d8d7f9c8d5bcf9e9#L1R92) . The memory layout of CrateMap changed, without bumping the version number in the struct. Another, more backward compatible, solution would be to keep the old code and increase the version number in the new struct. On the other hand, the `annihilate_fn` pointer was removed without bumping the version number recently. At the moment, the stage0 compiler does not use the new memory layout, which would lead the segfaults during stage0 compilation, so I've added a dummy `iter_crate_map` function for stage0, which does nothing. Again, this could be avoided if we'd bump the version number in the struct and keep the old code. I'd like to use a normal `for` loop [here](https://github.com/fhahn/rust/compare/logging-unsafe-removal?expand=1#L1R109), for child in children.iter() { do_iter_crate_map(child, |x| f(x), visited); } but for some reason this only yields `error: unresolved enum variant, struct or const 'Some'` and I have no idea why.
2013-10-06get_crate_map returns an OptionFlorian Hahn-23/+42
2013-10-06Fix a typo in std::ops documentationHuon Wilson-1/+1
2013-10-05Implement feature-gating for the compilerAlex Crichton-0/+2
A few features are now hidden behind various #[feature(...)] directives. These include struct-like enum variants, glob imports, and macro_rules! invocations. Closes #9304 Closes #9305 Closes #9306 Closes #9331
2013-10-05auto merge of #9713 : sfackler/rust/dynamic_lib, r=alexcrichtonbors-10/+19
The root issue is that dlerror isn't reentrant or even thread safe. The solution implemented here is to make a yielding spin lock over an AtomicFlag. This is pretty hacky, but the best we can do at this point. As far as I can tell, it isn't possible to create a global mutex without having to initialize it in a single threaded context. The Windows code isn't affected since errno is thread-local on Windows and it's running in an atomically block to ensure there isn't a green thread context switch. Closes #8156
2013-10-05auto merge of #9250 : erickt/rust/num, r=ericktbors-100/+897
This PR solves one of the pain points with c-style enums. Simplifies writing a fn to convert from an int/uint to an enum. It does this through a `#[deriving(FromPrimitive)]` syntax extension. Before this is committed though, we need to discuss if `ToPrimitive`/`FromPrimitive` has the right design (cc #4819). I've changed all the `.to_int()` and `from_int()` style functions to return `Option<int>` so we can handle partial functions. For this PR though only enums and `extra::num::bigint::*` take advantage of returning None for unrepresentable values. In the long run it'd be better if `i64.to_i8()` returned `None` if the value was too large, but I'll save this for a future PR. Closes #3868.
2013-10-05std: add Primitive.is_signedErick Tryzelaar-0/+13
2013-10-05std: ToPrimitive's default impls should use `.to_*()`Erick Tryzelaar-22/+11
This allows the default methods to be properly range checked.
2013-10-05std: fix some warningsErick Tryzelaar-5/+0
2013-10-05std: check bounds for ints/uints in {To,From}PrimitiveErick Tryzelaar-60/+598
2013-10-05Implemented `IntoSendStr` on `SendStr` to allow naming aMarvin Löbel-0/+20
task with a `SendStr` directly
2013-10-05Make a task name use a `SendStr`, allowing for eitherMarvin Löbel-6/+22
static or owned strings
2013-10-05Fix thread safety issues in dynamic_libSteven Fackler-10/+19
The root issue is that dlerror isn't reentrant or even thread safe. The Windows code isn't affected since errno is thread-local on Windows and it's running in an atomically block to ensure there isn't a green thread context switch. Closes #8156
2013-10-05Add code for older crate map versions, bumped crate map version numberFlorian Hahn-38/+171
2013-10-05Use &'self str instead of raw char pointer in ModEntryFlorian Hahn-127/+99
2013-10-05Use slice representation for module entries in CrateMapFlorian Hahn-87/+47
Relaxe lifetime of CrateMap as well.
2013-10-05Use slice representation for child crate mapsFlorian Hahn-116/+135
2013-10-04auto merge of #9727 : Valloric/rust/doc-fixes, r=catamorphismbors-1/+1
2013-10-04Fixed another minor typo in std::str docsStrahinja Val Markovic-1/+1
2013-10-04Fix minor typo in std::str module docsStrahinja Val Markovic-1/+1
2013-10-04auto merge of #9718 : alexcrichton/rust/snapshots, r=sanxiynbors-12/+0
Now that #9662 is merged, we should be much more easily bootstrappable on windows now.
2013-10-05rt::io::net::tcp: Fix eof_twice tests on Win32klutzy-6/+20
cc #8811
2013-10-05std::rt: Add NotConnected to IoErrorKindklutzy-0/+5
2013-10-05std::rt::uv::net: Handle `read_start` errorklutzy-2/+13
cc #9605
2013-10-04Register new snapshotsAlex Crichton-12/+0
Now that #9662 is merged, we should be much more easily bootstrappable on windows now.
2013-10-04fix some examples in std::rand::Rngflo-l-6/+14
2013-10-03auto merge of #9522 : steveklabnik/rust/doc_std_opts, r=alexcrichtonbors-2/+382
Added an overview with a 'real' example, as well as toy implementations of all of the traits. Closes #9356.
2013-10-03Update std::ops docs as per feedbackSteve Klabnik-140/+112
from @chris-morgan
2013-10-03Document logging and remove old functionsAlex Crichton-46/+90
This adds a large doc-block to the top of the std::logging module explaining how to use it. This is mostly just making sure that all the information in the manual's section about logging is also here (in case someone decides to look into this module first). This also removes the old console_{on,off} methods. As far as I can tell, the functions were only used by the compiler, and there's no reason for them to be used because they're all turned off by default anyway (maybe they were turned on by default at some point...) I believe that this is the final nail in the coffin and closes #5021
2013-10-03Merge pull request #9697 from sfackler/issue_9155Daniel Micay-13/+9
Close out #9155
2013-10-03auto merge of #9691 : alexcrichton/rust/rustdoc, r=cmrbors-1/+2
This slurps in the commits from #9684 as well as closing #9539.
2013-10-03Close out #9155Steven Fackler-13/+9
Add a test to make sure it works and switch a private struct over to a newtype. Closes #9155
2013-10-02auto merge of #9693 : sfackler/rust/newtype-removal, r=alexcrichtonbors-30/+48
UnboundedPipeStream is still a newtype since process::set_stdio needs to look into its internals. Closes #9667
2013-10-02Stop using newtype wrappers in std::rt::ioSteven Fackler-30/+48
UnboundedPipeStream is still a newtype since process::set_stdio needs to look into its internals. Closes #9667