Commit Graph

20931 Commits

Author SHA1 Message Date
Kevin Ballard
75155cd1b0 Explicitly impl Clone for RWArc
RWArc had a clone() method, but it was part of impl RWArc instead of
an implementation of Clone.

Stick with the explicit implementation instead of deriving Clone so we
can have a docstring.

Fixes #8052.
2013-08-03 03:17:07 -04:00
Huon Wilson
1992765dd3 std: add benchmark for vec.mut_iter. 2013-08-03 03:13:13 -04:00
Huon Wilson
fbb7cd32c3 std: use ptr.offset where possible in the vec iterator.
Closes #8212.
2013-08-03 03:13:11 -04:00
Kevin Ballard
54e685d4fd option: mutate() and mutate_default() should return bool
Fixes #8047.
2013-08-03 03:11:11 -04:00
toddaaro
1f9c392389 fixed the buffer to make it a more reasonable size 2013-08-03 03:09:23 -04:00
toddaaro
eab749a5f3 modified logging function to truncate output and adjusted error output formatting tests to be compatible with both the new and old runtimes 2013-08-03 03:09:04 -04:00
Daniel Micay
deddb009f0 Merge pull request #8244 from thestinger/for
make `for` parse as `foreach` does

r=huonw, bors is acting up and this has been run through the try bots
2013-08-03 00:07:20 -07:00
Daniel Micay
87cf2864b1 rm obsolete documentation on for
it is documented in the container/iterator tutorial, not the basic
tutorial
2013-08-03 03:00:42 -04:00
Daniel Micay
b41d04763e make for parse as foreach does
Closes #6997
2013-08-03 03:00:42 -04:00
Daniel Micay
b3ad685f7f replace all remaining for with foreach or do 2013-08-03 03:00:42 -04:00
Chris Morgan
ceb651671a Vim highlighting: remove foreach keyword 2013-08-03 15:56:18 +10:00
Brian Anderson
8f9c1724d0 Suppress a libuv leak on mac
I suspect that this is a race between process exit and the termination of
worker threads used by libuv (if I sleep before exit it doesn't leak). This
isn't going to cause any real problems but should probably be fixed at
some point.
2013-08-02 22:05:34 -07:00
bors
2a7be1c9e4 auto merge of #8235 : pcwalton/rust/unsafe-extern-fns, r=pcwalton
r? @brson
2013-08-02 22:05:03 -07:00
Patrick Walton
9457ebee55 librustc: Disallow "unsafe" for external functions 2013-08-02 21:57:59 -07:00
Patrick Walton
887c656970 librustc: Introduce a new visitor type based on traits and port syntax to it.
This is preparation for removing `@fn`.

This does *not* use default methods yet, because I don't know
whether they work. If they do, a forthcoming PR will use them.

This also changes the precedence of `as`.
2013-08-02 21:57:58 -07:00
Chris Morgan
44cb1c3adb Highlight sigils and operators in Vim.
Sigil highlighting isn't perfect (especially how it handles ``&``) but
after having used it for a week I feel it to be considerably nicer than
nothing. As usual, if you don't like it, you can turn it off easily by
overriding the default highlighting.

Generics are not handled specially; this means that for something like
``S<T>``, the ``<`` and ``>`` are highlighted as operators. For myself,
I like this, and there is no way to make it properly context aware
without expanding the syntax matching enormously.

Also, special characters are highlighted properly in strings/chars, e.g.
``"\x00"`` or ``'\Ufedcba98'`` appropriately.
2013-08-03 14:36:27 +10:00
Kevin Ballard
2001cc043b Bump fd limit on macos when running rt tests
OS X defaults the ulimit for open files to 256 for programs launched
from the Terminal (GUI apps get a higher default). Unfortunately this is
too low for the rt tests, which deliberately overcommit and create a lot
of threads (which means a lot of schedulers, and each scheduler needs at
least 2 fds).

By calling sysctl() and setrlimit() we can bump the fd limit up to the
maximum allowed (on stock OS X it's 10240).

Fixes #7772.
2013-08-02 21:20:15 -07:00
Kevin Ballard
70d2be0cec Revert "std::rt: Use a constant 4 threads for multithreaded sched tests"
This workaround was less than ideal. A better solution is to raise the
fd limit.

This reverts commit 49b72bdd77.
2013-08-02 21:18:32 -07:00
bors
efd6eafeb4 auto merge of #8174 : DaGenix/rust/digest-improvements, r=brson
Same content as #8097, but bors had an issue with that pull request. Opening a new one.
2013-08-02 19:29:00 -07:00
Stepan Koltsov
cf9e9b21d5 Add default implementation of Map::contains_key function
Map::contains_key can be implemented with Map::find.

Remove several implementations of contains_key.
2013-08-03 05:54:05 +04:00
Palmer Cox
1252472bb7 Sha1: Update Sha1 to use new functionality in cryptoutil.rs 2013-08-02 18:49:00 -04:00
Palmer Cox
4e7b0ee3cd Crypto: Add overflow checking addition functions.
Added functions to cryptoutil.rs that perform an addition after shifting
the 2nd parameter by a specified constant. These function fail!() if integer
overflow will result. Updated the Sha2 implementation to use these functions.
2013-08-02 18:49:00 -04:00
Palmer Cox
281b79525b Crypto: Add large input tests for all Digests
Create a helper function in cryptoutil.rs which feeds 1,000,000 'a's into
a Digest with varying input sizes and then checks the result. This is
essentially the same as one of Sha1's existing tests, so, that test was
re-implemented using this method. New tests were added using this method for
Sha512 and Sha256.
2013-08-02 18:49:00 -04:00
Palmer Cox
2cbe312343 Crypto: Remove DigestUtil and convert to default methods on the Digest trait. 2013-08-02 18:49:00 -04:00
Palmer Cox
ee3f75366c Sha2: Re-write the Sha2 compression functions to improve performance.
The Sha2 compression functions were re-written to execute the message
scheduling calculations in the same loop as the rest of the compression
function. The compiler is able to generate much better code. Additionally,
innermost part of the compression functions were turned into macros to
reduce code duplicate and to make the functions more concise.
2013-08-02 18:49:00 -04:00
Palmer Cox
654c536fec Sha2: Create cryptoutil.rs and re-write the Sha2 module to make use of it.
There are 2 main pieces of functionality in cryptoutil.rs:
* A set of unsafe function for efficiently reading and writing u32 and u64
  values. All of these functions are fairly easy to audit to confirm that
  they do what they are supposed to.
* A FixedBuffer struct. This struct keeps track of input data until there
  is enough of it to execute the a function on it which expects a fixed
  block of data.

The Sha2 module was rewritten to take advantage of the new functions in
cryptoutil as well as FixedBuffer. The result is that the duplicate code
for maintaining a buffer of input data is removed from the Sha512 and
Sha256 implementation. Additionally, the FixedBuffer code is much more
efficient than the previous code was.
2013-08-02 18:48:14 -04:00
Palmer Cox
3cac62822e Sha2: Remove the result_X() methods; move logic into the Digest impls.
The result_X() methods just calculate an output of a fixed size. They don't
really have much to do with running the actually hash algorithm until the very
last step - the output. It makes much more sense to put all this logic into
the Digest impls for each specific variation on the hash function.
2013-08-02 18:46:11 -04:00
Palmer Cox
5b01555155 Sha2: Rearrage traits / impls / structs.
The code was arranged so that the core Sha2 code came first, and then
all of the various implementation of Digest followed along later. The
problem is that the Sha512 compression function code is far away from
the Sha512 Digest implementation, so, if you are trying to read over
the code, you need to scroll all around the file for no good reason. The
code was rearranged so that all of the Sha512 code is in one place and
all of the Sha256 code is in another and so that all impls for a struct
are near the definition of that struct.
2013-08-02 18:46:11 -04:00
Palmer Cox
a1bbd18dc1 Sha2: Remove unecessary integer type specifications. 2013-08-02 18:46:11 -04:00
Stepan Koltsov
9046516444 Rename IpAddr -> SocketAddr, extract IpAddr from SocketAddr
multicast functions now take IpAddr (without port), because they dont't
need port.

Uv* types renamed:
* UvIpAddr -> UvSocketAddr
* UvIpv4 -> UvIpv4SocketAddr
* UvIpv6 -> UvIpv6SocketAddr

"Socket address" is a common name for (ip-address, port) pair (e.g. in
sockaddr_in struct).
2013-08-03 02:06:24 +04:00
bors
3ddc72f69b auto merge of #8234 : bblum/rust/assorted-fixes, r=brson
This fixes 4 bugs that prevented the extra::arc and extra::sync tests from passing on the new runtime.

* In ```Add SendDeferred trait``` I add a non-rescheduling ```send_deferred``` method to our various channel types. The ```extra::sync``` concurrency primitives need this guarantee so they can send while inside of an exclusive. (This fixes deterministic deadlocks seen with ```RUST_THREADS=1```.)
* In "Fix nasty double-free bug" I make sure that a ```ChanOne``` suppresses_finalize *before* rescheduling away to the receiver, so in case it gets a kill signal upon coming back, the destructor is inhibited as desired. (This is pretty uncommon on multiple CPUs but showed up always with ```RUST_THREADS=1```.)
* In ```Fix embarrassing bug where 'unkillable' would unwind improperly``` I make sure the task's unkillable counter stays consistent when a kill signal is received right at the start of an unkillable section. (This is a very uncommon race and can only occur with multiple CPUs.)
* In ```Don't fail from kill signals if already unwinding``` I do pretty much what it says on the tin. Surprising that it took the whole suite of sync/arc tests to expose this.

The other two commits are cleanup.

r @brson
2013-08-02 14:55:54 -07:00
David Halperin
fe8ad14c87 Add backticks around trait name in conflicting implementations error message 2013-08-02 17:54:54 -04:00
David Halperin
77adec9c9b Add trait name to conflicting implementation error message 2013-08-02 17:54:53 -04:00
Ben Blum
43fecf3556 Add an assert_may_sleep() check on every context switch. 2013-08-02 17:31:45 -04:00
Ben Blum
92f60f4365 Don't fail from kill signals if already unwinding. 2013-08-02 17:31:45 -04:00
Ben Blum
bd35798773 (cleanup) Use more do...finally in extra::sync. 2013-08-02 17:31:45 -04:00
Ben Blum
d30cca46e6 Fix embarrassing bug where 'unkillable' would unwind improperly when it receives a kill signal. 2013-08-02 17:31:45 -04:00
Ben Blum
cde6ad3992 Fix nasty double-free bug where a newrt chan could get killed after rescheduling but before suppressing_finalize. 2013-08-02 17:31:44 -04:00
Ben Blum
be7738bfa1 Add SendDeferred trait and use it to fix #8214. 2013-08-02 17:31:44 -04:00
blake2-ppc
0504d7e57b std: Speed up str::is_utf8
Use unchecked vec indexing since the vector bounds are checked by the
loop. Iterators are not easy to use in this case since we skip 1-4 bytes
each lap. This part of the commit speeds up is_utf8 for ASCII input.

Check codepoint ranges by checking the byte ranges manually instead of
computing a full decoding for multibyte encodings. This is easy to read
and corresponds to the UTF-8 syntax in the RFC.

No changes to what we accept. A comment notes that surrogate halves are
accepted.

Before:

	test str::bench::is_utf8_100_ascii ... bench: 165 ns/iter (+/- 3)
	test str::bench::is_utf8_100_multibyte ... bench: 218 ns/iter (+/- 5)

After:
	test str::bench::is_utf8_100_ascii ... bench: 130 ns/iter (+/- 1)
	test str::bench::is_utf8_100_multibyte ... bench: 156 ns/iter (+/- 3)
2013-08-02 23:20:57 +02:00
bors
f1c1f92d0c auto merge of #8221 : brson/rust/single-threaded, r=graydon
This is the last major runtime feature needed for the transition to the new scheduler.
2013-08-02 10:52:50 -07:00
bors
fc571820d1 auto merge of #8202 : pnkfelix/rust/fsk-issue8056-make-crates-must-dep-on-subcrates, r=graydon
Reorder TEST_HOST_CRATES in hopes of exposing future instances of this bug.

Fix #8056
2013-08-02 09:13:53 -07:00
bors
986df44753 auto merge of #8195 : bblum/rust/task-cleanup, r=brson
In the first commit it is obvious why some of the barriers can be changed to ```Relaxed```, but it is not as obvious for the once I changed in ```kill.rs```. The rationale for those is documented as part of the documenting commit.

Also the last commit is a temporary hack to prevent kill signals from being received in taskgroup cleanup code, which could be fixed in a more principled way once the old runtime is gone.
2013-08-02 07:31:52 -07:00
bors
af97339771 auto merge of #8193 : cmr/rust/linux-errno, r=graydon 2013-08-02 05:49:53 -07:00
bors
2460170e6a auto merge of #8188 : huonw/rust/cfg-macro, r=pcwalton
Example:

    if cfg!(test) {
       calculation_to_run_only_when_testing();
    }

Closes #8130.
2013-08-02 03:52:51 -07:00
bors
dbde42e59e auto merge of #8175 : brson/rust/nodbg, r=graydon
This stuff is ancient, unused, and tied to oldsched
2013-08-02 01:13:51 -07:00
Brian Anderson
c3fa411459 std: Implement SingleThreaded spawn mode for newsched 2013-08-02 00:26:45 -07:00
Steven Stewart-Gallus
2047026fef Fix calling destructor on uninitialized dynamic library crash.
A test case was also created for this situation to prevent the problem
occuring again.

A similar problem was also fixed for the symbol method.

There was some minor code cleanup.
2013-08-01 23:41:33 -07:00
bors
bbcce8d95c auto merge of #8216 : thestinger/rust/range, r=huonw 2013-08-01 22:10:45 -07:00
Daniel Micay
234acad404 replace range with an external iterator 2013-08-02 00:51:14 -04:00