Commit Graph

23454 Commits

Author SHA1 Message Date
bors b0c475229a auto merge of #10055 : pcwalton/rust/arc-clone-inline, r=alexcrichton
r? @thestinger
2013-10-24 17:36:07 -07:00
Alex Crichton 3ee5ef12fb Remove the 'callback_ms' function from EventLoop
This is a peculiar function to require event loops to implement, and it's only
used in one spot during tests right now. Instead, a possibly more robust apis
for timers should be used rather than requiring all event loops to implement a
curious-looking function.
2013-10-24 15:17:27 -07:00
Alex Crichton 3b30377e14 Fix a bug with the scheduler and destructor order
The PausibleIdleCallback must have some handle into the event loop, and because
struct destructors are run in order of top-to-bottom in order of fields, this
meant that the event loop was getting destroyed before the idle callback was
getting destroyed.

I can't confirm that this fixes a problem in how we use libuv, but it does
semantically fix a problem for usage with other event loops.
2013-10-24 15:16:58 -07:00
bors 3f5b2219cc auto merge of #9901 : alexcrichton/rust/unix-sockets, r=brson
Large topics:

* Implemented `rt::io::net::unix`. We've got an implementation backed by "named pipes" for windows for free from libuv, so I'm not sure if these should be `cfg(unix)` or whether they'd be better placed in `rt::io::pipe` (which is currently kinda useless), or to leave in `unix`. Regardless, we probably shouldn't deny windows of functionality which it certainly has.
* Fully implemented `net::addrinfo`, or at least fully implemented in the sense of making the best attempt to wrap libuv's `getaddrinfo` api
* Moved standard I/O to a libuv TTY instead of just a plain old file descriptor. I found that this interacted better when closing stdin, and it has the added bonus of getting things like terminal dimentions (someone should make a progress bar now!)
* Migrate to `~Trait` instead of a typedef'd object where possible. There are only two more types which are blocked on this, and those are traits which have a method which takes by-value self (there's an open issue on this)
* Drop `rt::io::support::PathLike` in favor of just `ToCStr`. We recently had a lot of Path work done, but it still wasn't getting passed down to libuv (there was an intermediate string conversion), and this allows true paths to work all the way down to libuv (and anything else that can become a C string).
* Removes `extra::fileinput` and `extra::io_util`


Closes #9895 
Closes #9975
Closes #8330
Closes #6850 (ported lots of libraries away from std::io)
cc #4248 (implemented unix/dns)
cc #9128 (made everything truly trait objects)
2013-10-24 14:26:15 -07:00
Alex Crichton 188e471339 Another round of test fixes and merge conflicts 2013-10-24 14:22:35 -07:00
Alex Crichton d425218395 Bring io::signal up to date with changes to rt::rtio 2013-10-24 14:22:35 -07:00
Do Nhat Minh b5a02e0784 wrapping libuv signal for use in Rust
descriptive names
easier-to-use api
reorganize and document
2013-10-24 14:22:35 -07:00
Alex Crichton 816e46dd63 Fixing some tests, adding some pipes
This adds constructors to pipe streams in the new runtime to take ownership of
file descriptors, and also fixes a few tests relating to the std::run changes
(new errors are raised on io_error and one test is xfail'd).
2013-10-24 14:22:35 -07:00
Alex Crichton 262b958a4b Migrate std::run to libuv processes 2013-10-24 14:22:35 -07:00
Alex Crichton 6bb1df9251 Remove std::io once and for all! 2013-10-24 14:22:34 -07:00
Alex Crichton c4907cfd14 Remove std::io from ebml 2013-10-24 14:21:58 -07:00
Alex Crichton 620ab3853a Test fixes and merge conflicts 2013-10-24 14:21:58 -07:00
Alex Crichton 279c351820 Move stdin to using libuv's pipes instead of a tty
I was seeing a lot of weird behavior with stdin behaving as a tty, and it
doesn't really quite make sense, so instead this moves to using libuv's pipes
instead (which make more sense for stdin specifically).

This prevents piping input to rustc hanging forever.
2013-10-24 14:21:58 -07:00
Alex Crichton 6b70ddfba1 Remove io::read_error
The general idea is to remove conditions completely from I/O, so in the meantime
remove the read_error condition to mean the same thing as the io_error condition.
2013-10-24 14:21:57 -07:00
Alex Crichton e117aa0e2a Stop logging task failure to task loggers
The isn't an ideal patch, and the comment why is in the code. Basically uvio
uses task::unkillable which touches the kill flag for a task, and if the task is
failing due to mismangement of the kill flag, then there will be serious
problems when the task tries to print that it's failing.
2013-10-24 14:21:57 -07:00
Alex Crichton 61ed2cfb55 Remove even more of std::io
Big fish fried here:

    extra::json
    most of the compiler
    extra::io_util removed
    extra::fileinput removed

Fish left to fry

    extra::ebml
2013-10-24 14:21:57 -07:00
Alex Crichton 4eb5336054 Move as much I/O as possible off of native::io
When uv's TTY I/O is used for the stdio streams, the file descriptors are put
into a non-blocking mode. This means that other concurrent writes to the same
stream can fail with EAGAIN or EWOULDBLOCK. By all I/O to event-loop I/O, we
avoid this error.

There is one location which cannot move, which is the runtime's dumb_println
function. This was implemented to handle the EAGAIN and EWOULDBLOCK errors and
simply retry again and again.
2013-10-24 14:21:57 -07:00
Alex Crichton 4ce71eaca3 Migrate the last typedefs to ~Trait in rtio
There are no longer any remnants of typedefs, and everything is now built on
true trait objects.
2013-10-24 14:21:57 -07:00
Alex Crichton 59d45b8fe7 Don't attempt to export uv functions directly 2013-10-24 14:21:57 -07:00
Alex Crichton b46f60a729 Remove IoFactoryObject for ~IoFactory
This involved changing a fair amount of code, rooted in how we access the local
IoFactory instance. I added a helper method to the rtio module to access the
optional local IoFactory. This is different than before in which it was assumed
that a local IoFactory was *always* present. Now, a separate io_error is raised
when an IoFactory is not present, yet I/O is requested.
2013-10-24 14:21:57 -07:00
Alex Crichton 9110a38cbf Remove rt::io::support
This removes the PathLike trait associated with this "support module". This is
yet another "container of bytes" trait, so I didn't want to duplicate what
already exists throughout libstd. In actuality, we're going to pass of C strings
to the libuv APIs, so instead the arguments are now bound with the 'ToCStr'
trait instead.

Additionally, a layer of complexity was removed by immediately converting these
type-generic parameters into CStrings to get handed off to libuv apis.
2013-10-24 14:21:57 -07:00
Alex Crichton 0cad984765 Migrate Rtio objects to true trait objects
This moves as many as I could over to ~Trait instead of ~Typedef. The only
remaining one is the IoFactoryObject which should be coming soon...
2013-10-24 14:21:57 -07:00
Alex Crichton 35756fbcf6 Move rt::io::stdio from FileStream to a TTY
We get a little more functionality from libuv for these kinds of streams (things
like terminal dimentions), and it also appears to more gracefully handle the
stream being a window. Beforehand, if you used stdio and hit CTRL+d on a
process, libuv would continually return 0-length successful reads instead of
interpreting that the stream was closed.

I was hoping to be able to write tests for this, but currently the testing
infrastructure doesn't allow tests with a stdin and a stdout, but this has been
manually tested! (not that it means much)
2013-10-24 14:21:57 -07:00
Alex Crichton 32b07c6a40 Remove unbound pipes from io::pipe
This isn't necessary for creating processes (or at least not right now), and
it inherently attempts to expose implementation details.
2013-10-24 14:21:56 -07:00
Alex Crichton c6fa4e277f Address a few XXX comments throughout the runtime
* Implement Seek for Option<Seek>
* Remove outdated comment for io::process
* De-pub a component which didn't need to be pub
2013-10-24 14:21:56 -07:00
Alex Crichton 1db783bdcf Finish implementing io::net::addrinfo
This fills in the `hints` structure and exposes libuv's full functionality for
doing dns lookups.
2013-10-24 14:21:56 -07:00
Alex Crichton bac9681858 Implement io::net::unix 2013-10-24 14:21:56 -07:00
Patrick Walton b13415cccc libextra: Make arc::get and arc::new inline too.
Should be a 2x improvement in a Servo test case.
2013-10-24 13:50:21 -07:00
Patrick Walton 76287ccbb0 libextra: Make arc clone inline 2013-10-24 13:21:49 -07:00
bors 61f8c059c4 auto merge of #10007 : Kimundi/rust/add_docs_01, r=cmr
Additionally:
- Sorted the prelude reexports
- Removed unused import warning in std::mem and cleaned it up too

(I was bored 👻 )
2013-10-24 13:01:18 -07:00
Marvin Löbel e53aae4772 Cleaned, documented, wrote tests for up std::bool
Removed unused import warning in std::mem and cleaned it up too

Removed is_true and is_false from std::bool

Removed freestanding functions in std::bool
2013-10-24 17:21:39 +02:00
gifnksm 7d5c7b8083 extra: Add getter methods to extra::rational::Ratio
After merging 0ada7c7, user code have not been able to access to `Ratio`'s numerator and denominator fields.
In some algorithms, it is needed to get an rational number's numerator or denominator, but keeping these fields private is necessary for guaranteeing that `Ratio` numbers are irreducible.
So, I added the getter methods `numer()` and `denom()`.

As a bonus, this commit adds utility methods relating to the ratio-integer conversion.
2013-10-24 23:05:03 +09:00
bors 7075eb3625 auto merge of #10042 : thestinger/rust/fail, r=sanxiyn
Closes #10023
2013-10-24 05:11:06 -07:00
Igor Bukanov 47fff53597 rust / build: make install should use explicit permissions when creating directories
Closes #10046
2013-10-24 10:23:12 +02:00
bors f27dfa04e5 auto merge of #10040 : thestinger/rust/frame_address, r=alexcrichton
Closes #10001
2013-10-23 21:46:03 -07:00
Daniel Micay ce54c34f02 drop unused `frame_address` intrinsic
Closes #10001
2013-10-24 00:42:29 -04:00
Daniel Micay a3ae48cb36 mark some functions as returning !
Closes #10023
2013-10-23 22:23:28 -04:00
bors e2428b791c auto merge of #10032 : thestinger/rust/snapshot, r=huonw 2013-10-23 15:11:07 -07:00
Daniel Micay 142672dca4 register snapshots 2013-10-23 18:06:12 -04:00
bors 860cb81b59 auto merge of #10022 : hatahet/rust/master, r=alexcrichton
Fixes #9958
2013-10-23 11:36:13 -07:00
Ziad Hatahet dabf377438 Made uv_stat_t.{st_dev, st_ino} public, #9958 2013-10-23 11:16:35 -07:00
Ziad Hatahet 7d69837bd2 Merge remote-tracking branch 'upstream/master' 2013-10-23 10:09:06 -07:00
bors f09959361b auto merge of #10034 : sfackler/rust/time, r=alexcrichton
These are supposed to be raw C-like structs mirroring time.h's struct tm
and struct timespec.
2013-10-23 09:41:14 -07:00
Steven Fackler 870f3bc341 Re-make time struct fields public
These are supposed to be raw C-like structs mirroring time.h's struct tm
and struct timespec.
2013-10-23 09:06:31 -07:00
bors a4ec8af4c5 auto merge of #9810 : huonw/rust/rand3, r=alexcrichton
- Adds the `Sample` and `IndependentSample` traits for generating numbers where there are parameters (e.g. a list of elements to draw from, or the mean/variance of a normal distribution). The former takes `&mut self` and the latter takes `&self` (this is the only difference).
- Adds proper `Normal` and `Exp`-onential distributions
- Adds `Range` which generates `[lo, hi)` generically & properly (via a new trait) replacing the incorrect behaviour of `Rng.gen_integer_range` (this has become `Rng.gen_range` for convenience, it's far more efficient to use `Range` itself)
- Move the `Weighted` struct from `std::rand` to `std::rand::distributions` & improve it
- optimisations and docs
2013-10-23 08:31:21 -07:00
bors 5de50a3f71 auto merge of #10027 : catamorphism/rust/testcases-2013-10-22, r=catamorphism 2013-10-23 02:06:12 -07:00
bors 8c97c5ebfd auto merge of #10021 : alexcrichton/rust/asm-now-analyzed-correctly, r=luqmana
We got a snapshot, taking care of a note to myself.
2013-10-23 00:01:23 -07:00
bors c1ef1ce947 auto merge of #10015 : huonw/rust/minor-fixes, r=alexcrichton
- Use ["nothing up my sleeve numbers"](http://en.wikipedia.org/wiki/Nothing_up_my_sleeve_number) for the ISAAC tests.
- Replace the default implementation of `Rng.fill_bytes` with something that doesn't try to do bad things with `transmute` and vectors just for the sake of a little speed.
- Replace the transmutes used to seed the ISAAC RNGs with calls into `vec::raw`.
2013-10-22 22:51:10 -07:00
Tim Chevalier 567a03d19b testsuite: Test cases, all except issue-5216 xfailed 2013-10-22 21:04:15 -07:00
bors 4cbc8ad397 auto merge of #9654 : catamorphism/rust/rustpkg-c-dependencies, r=brson
r? @brson api::install_pkg now accepts an argument that's a list of
(kind, path) dependency pairs. This allows custom package scripts to
declare C dependencies, as is demonstrated in
rustpkg::tests::test_c_dependency_ok.

Closes #6403
2013-10-22 20:56:05 -07:00