about summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2014-01-28std: comment about OOM & allocs in begin_unwind_fmt.Huon Wilson-0/+4
Follow-up to #11841 which added this function.
2014-01-27auto merge of #11723 : eddyb/rust/more-trans-cleanup, r=pcwaltonbors-0/+2
2014-01-27Removed take_glue from tydesc, inlining the equivalent refcount increment ↵Eduard Burtescu-0/+2
code instead.
2014-01-27auto merge of #11841 : huonw/rust/noinline-fail, r=alexcrichtonbors-6/+43
In two ways: - for a plain `fail!(a)` we make the generic part of `begin_unwind` as small as possible (makes `fn main() { fail!() }` compile 2-3x faster, due to less monomorphisation bloat) - for `fail!("format {}", "string")`, we avoid touching the generics completely by doing the formatting in a specialised function, which (with optimisations) saves a function call at the call-site of `fail!`. (This one has significantly less benefit than the first.)
2014-01-27std: add begin_unwind_fmt that reduces codesize for formatted fail!().Huon Wilson-3/+25
This ends up saving a single `call` instruction in the optimised code, but saves a few hundred lines of non-optimised IR for `fn main() { fail!("foo {}", "bar"); }` (comparing against the minimal generic baseline from the parent commit).
2014-01-27Demote self to an (almost) regular argument and remove the env param.Eduard Burtescu-17/+8
Fixes #10667 and closes #10259.
2014-01-27std: reduce the generic code instantiated by fail!().Huon Wilson-3/+18
This splits the vast majority of the code path taken by `fail!()` (`begin_unwind`) into a separate non-generic inline(never) function, so that uses of `fail!()` only monomorphise a small amount of code, reducing code bloat and making very small crates compile faster.
2014-01-26auto merge of #11817 : salemtalha/rust/master, r=brsonbors-37/+37
Fixes Issue #11815
2014-01-26Removed all instances of XXX in preparation for relaxing of FIXME ruleSalem Talha-37/+37
2014-01-26Fix privacy fallout from previous changeAlex Crichton-1/+1
2014-01-26auto merge of #11762 : alexcrichton/rust/guard_pages, r=alexcrichtonbors-68/+132
Rebasing of the previous PRs, I believe I've found the problems.
2014-01-26Bring in the line-length policeAlex Crichton-51/+79
2014-01-25auto merge of #11808 : huonw/rust/std-visible-types, r=brsonbors-3/+4
These are either returned from public functions, and really should appear in the documentation, but don't since they're private, or are implementation details that are currently public.
2014-01-26std,extra: Make some types public and other private.Huon Wilson-3/+4
These are either returned from public functions, and really should appear in the documentation, but don't since they're private, or are implementation details that are currently public.
2014-01-25auto merge of #11790 : lfairy/rust/rename-num-consts, r=alexcrichtonbors-331/+331
The following are renamed: * `min_value` => `MIN` * `max_value` => `MAX` * `bits` => `BITS` * `bytes` => `BYTES` All tests pass, except for `run-pass/phase-syntax-link-does-resolve.rs`. I doubt that failure is related, though. Fixes #10010.
2014-01-25auto merge of #11788 : salemtalha/rust/master, r=huonwbors-1/+2
Fixes #11785.
2014-01-25auto merge of #11775 : alexcrichton/rust/select-fix, r=pcwaltonbors-1/+4
The race here happened when a port had its deschedule in select() canceled, but the other chan had already been dropped. This meant that the DISCONNECTED case was hit in abort_selection, but the to_wake cell hadn't been emptied yet (this was done after aborting), causing an assert in abort_selection to trip. To fix this, the to_wake cell is just emptied before abort_selection is called (we know that we're the owner of it already).
2014-01-25Uppercase numeric constantsChris Wong-331/+331
The following are renamed: * `min_value` => `MIN` * `max_value` => `MAX` * `bits` => `BITS` * `bytes` => `BYTES` Fixes #10010.
2014-01-25Fixed iter's is_empty to use is_none() and added relevant test flagSalem Talha-1/+2
2014-01-25Fix some docs about rtDerek Chiang-3/+1
2014-01-24Fix zero-sized memory mappingCorey Richardson-2/+13
2014-01-24Use `mmap` to map in task stacks and guard pageCorey Richardson-24/+41
Also implement caching of stacks.
2014-01-24Add support for arbitrary flags to MemoryMap.Corey Richardson-7/+15
This also fixes up the documentation a bit, it was subtly incorrect.
2014-01-24auto merge of #11774 : sfackler/rust/move-macros, r=pcwaltonbors-1/+192
They all have to go into a single module at the moment unfortunately. Ideally, the logging macros would live in std::logging, condition! would live in std::condition, format! in std::fmt, etc. However, this introduces cyclic dependencies between those modules and the macros they use which the current expansion system can't deal with. We may be able to get around this by changing the expansion phase to a two-pass system but that's for a later PR. Closes #2247 cc #11763
2014-01-24auto merge of #11732 : luqmana/rust/native-getaddrinfo, r=alexcrichtonbors-9/+55
The last bit I needed to be able to use libnative :P
2014-01-24libstd: Use iotest! for for get_host_addresses.Luqman Aden-5/+11
2014-01-24Fix a spuriously tripped assert in select()Alex Crichton-1/+4
The race here happened when a port had its deschedule in select() canceled, but the other chan had already been dropped. This meant that the DISCONNECTED case was hit in abort_selection, but the to_wake cell hadn't been emptied yet (this was done after aborting), causing an assert in abort_selection to trip. To fix this, the to_wake cell is just emptied before abort_selection is called (we know that we're the owner of it already).
2014-01-24Delete ignore! macroSteven Fackler-3/+0
This was a holdover from when we didn't allow nested comment blocks (think #if 0). It isn't used anywhere.
2014-01-24Move macro_rules! macros to libstdSteven Fackler-1/+195
They all have to go into a single module at the moment unfortunately. Ideally, the logging macros would live in std::logging, condition! would live in std::condition, format! in std::fmt, etc. However, this introduces cyclic dependencies between those modules and the macros they use which the current expansion system can't deal with. We may be able to get around this by changing the expansion phase to a two-pass system but that's for a later PR. Closes #2247 cc #11763
2014-01-24auto merge of #11750 : bnoordhuis/rust/follow-rustc-symlink, r=thestingerbors-3/+21
Before this commit, rustc looked in `dirname $0`/../lib for libraries but that doesn't work when rustc is invoked through a symlink. This commit makes rustc look in `dirname $(readlink $0)`/../lib, i.e. it first canonicalizes the symlink before walking up the directory tree. Fixes #3632.
2014-01-23Update flip() to be rev().Sean Chalmers-55/+55
Consensus leaned in favour of using rev instead of flip.
2014-01-23Rename Invert to Flip - Issue 10632Sean Chalmers-57/+57
Renamed the invert() function in iter.rs to flip(). Also renamed the Invert<T> type to Flip<T>. Some related code comments changed. Documentation that I could find has been updated, and all the instances I could locate where the function/type were called have been updated as well.
2014-01-22auto merge of #11682 : thestinger/rust/vector, r=brsonbors-57/+289
This is just an initial implementation and does not yet fully replace `~[T]`. A generic initialization syntax for containers is missing, and the slice functionality needs to be reworked to make auto-slicing unnecessary. Traits for supporting indexing properly are also required. This also needs to be fixed to make ring buffers as easy to use as vectors. The tests and documentation for `~[T]` can be ported over to this type when it is removed. I don't really expect DST to happen for vectors as having both `~[T]` and `Vec<T>` is overcomplicated and changing the slice representation to 3 words is not at all appealing. Unlike with traits, it's possible (and easy) to implement `RcSlice<T>` and `GcSlice<T>` without compiler help.
2014-01-22auto merge of #11611 : SiegeLord/rust/exp_printing, r=alexcrichtonbors-89/+167
Fixes #6593 Currently, Rust provides no way to print very large or very small floating point values which come up routinely in scientific and modeling work. The classical solution to this is to use the scientific/exponential notation, which not-coincidentally, corresponds to how floating point values are encoded in memory. Given this, there are two solutions to the problem. One is what, as far as I understand it, Python does. I.e. for floating point numbers in a certain range it does what we do today with the `'f'` formatting flag, otherwise it switches to exponential notation. The other way is to provide a set of formatting flags to explicitly choose the exponential notation, like it is done in C. I've chosen the second way as I think its important to provide that kind of control to the user. This pull request changes the `std::num::strconv::float_to_str_common` function to optionally format floating point numbers using the exponential (scientific) notation. The base of the significant can be varied between 2 and 25, while the base of the exponent can be 2 or 10. Additionally this adds two new formatting specifiers to `format!` and friends: `'e'` and `'E'` which switch between outputs like `1.0e5` and `1.0E5`. Mostly parroting C stdlib in this sense, although I wasn't going for an exact output match.
2014-01-22hashmap: port to Vec<T>Daniel Micay-25/+25
2014-01-22add new vector representation as a libraryDaniel Micay-1/+233
2014-01-22vec: make unsafe indexing functions higher-levelDaniel Micay-6/+6
2014-01-22libc: switch `free` to the proper signatureDaniel Micay-26/+26
This does not attempt to fully propagate the mutability everywhere, but gives new code a hint to avoid the same issues.
2014-01-22Implement native timersAlex Crichton-29/+154
Native timers are a much hairier thing to deal with than green timers due to the interface that we would like to expose (both a blocking sleep() and a channel-based interface). I ended up implementing timers in three different ways for the various platforms that we supports. In all three of the implementations, there is a worker thread which does send()s on channels for timers. This worker thread is initialized once and then communicated to in a platform-specific manner, but there's always a shared channel available for sending messages to the worker thread. * Windows - I decided to use windows kernel timer objects via CreateWaitableTimer and SetWaitableTimer in order to provide sleeping capabilities. The worker thread blocks via WaitForMultipleObjects where one of the objects is an event that is used to wake up the helper thread (which then drains the incoming message channel for requests). * Linux/(Android?) - These have the ideal interface for implementing timers, timerfd_create. Each timer corresponds to a timerfd, and the helper thread uses epoll to wait for all active timers and then send() for the next one that wakes up. The tricky part in this implementation is updating a timerfd, but see the implementation for the fun details * OSX/FreeBSD - These obviously don't have the windows APIs, and sadly don't have the timerfd api available to them, so I have thrown together a solution which uses select() plus a timeout in order to ad-hoc-ly implement a timer solution for threads. The implementation is backed by a sorted array of timers which need to fire. As I said, this is an ad-hoc solution which is certainly not accurate timing-wise. I have done this implementation due to the lack of other primitives to provide an implementation, and I've done it the best that I could, but I'm sure that there's room for improvement. I'm pretty happy with how these implementations turned out. In theory we could drop the timerfd implementation and have linux use the select() + timeout implementation, but it's so inaccurate that I would much rather continue to use timerfd rather than my ad-hoc select() implementation. The only change that I would make to the API in general is to have a generic sleep() method on an IoFactory which doesn't require allocating a Timer object. For everything but windows it's super-cheap to request a blocking sleep for a set amount of time, and it's probably worth it to provide a sleep() which doesn't do something like allocate a file descriptor on linux.
2014-01-22Remove the initial and trailing blank doc-comment linesSiegeLord-80/+0
2014-01-22Add LowerExp 'e' and UpperExp 'E' format traits/specifiersSiegeLord-0/+98
2014-01-22float_to_str_bytes_common can now handle exponential notationSiegeLord-17/+77
2014-01-22libnative: Implement get_host_addresses.Luqman Aden-4/+44
2014-01-22Implement std::rt::at_exitAlex Crichton-0/+87
This routine is currently only used to clean up the timer helper thread in the libnative implementation, but there are possibly other uses for this. The documentation is clear that the procedures are *not* run with any task context and hence have very little available to them. I also opted to disallow at_exit inside of at_exit and just abort the process at that point.
2014-01-22Add std::os::self_exe_name()Ben Noordhuis-3/+21
2014-01-22Replace C types with Rust types in libstd, closes #7313Florian Hahn-173/+158
2014-01-22auto merge of #11711 : alexcrichton/rust/issue-11683, r=brsonbors-4/+58
There's lots of fun rationale in the comments of the diff. Closes #11683
2014-01-21[std::str] Remove the now unused not_utf8 condition.Simon Sapin-11/+3
2014-01-21[std::str] Rename from_utf8_owned_opt() to from_utf8_owned(), drop the old ↵Simon Sapin-46/+20
from_utf8_owned() behavior
2014-01-21[std::str] Rename from_utf8_opt() to from_utf8(), drop the old from_utf8() ↵Simon Sapin-50/+25
behavior