Skip to content

Commit 3c36f4a

Browse files
committed
---
yaml --- r: 63635 b: refs/heads/snap-stage3 c: bc70edb h: refs/heads/master i: 63633: 464370a 63631: bc5b088 v: v3
1 parent 9a178dc commit 3c36f4a

File tree

159 files changed

+4174
-2361
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

159 files changed

+4174
-2361
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: f8ae3cdcaacb29c7b56e546a9ddab1396b615f8f
4+
refs/heads/snap-stage3: bc70edbb25487e539386c68bd6e821eedd704194
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/RELEASES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ Version 0.7 (July 2013)
7878
* extra: `BigInt`, `BigUint` implement numeric and comparison traits.
7979
* extra: `term` uses terminfo now, is more correct.
8080
* extra: `arc` functions converted to methods.
81+
* extra: Implementation of fixed output size variations of SHA-2.
8182

8283
* Tooling
8384
* `unused_unsafe` lint mode for detecting unnecessary `unsafe` blocks.

branches/snap-stage3/src/etc/vim/syntax/rust.vim

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
" Language: Rust
33
" Maintainer: Patrick Walton <[email protected]>
44
" Maintainer: Ben Blum <[email protected]>
5-
" Last Change: 2012 Dec 25
5+
" Last Change: 2012 Jun 14
66

77
if version < 600
88
syntax clear
@@ -13,13 +13,16 @@ endif
1313
syn keyword rustConditional match if else
1414
syn keyword rustOperator as
1515

16+
syn match rustAssert "\<assert\(\w\)*!"
17+
syn match rustFail "\<fail\(\w\)*!"
1618
syn keyword rustKeyword break copy do drop extern
1719
syn keyword rustKeyword for if impl let log
1820
syn keyword rustKeyword copy do extern
1921
syn keyword rustKeyword for impl let log
2022
syn keyword rustKeyword loop mod once priv pub
2123
syn keyword rustKeyword return
22-
syn keyword rustKeyword unsafe use while
24+
syn keyword rustKeyword unsafe while
25+
syn keyword rustKeyword use nextgroup=rustModPath skipwhite
2326
" FIXME: Scoped impl's name is also fallen in this category
2427
syn keyword rustKeyword mod trait struct enum type nextgroup=rustIdentifier skipwhite
2528
syn keyword rustKeyword fn nextgroup=rustFuncName skipwhite
@@ -45,7 +48,8 @@ syn keyword rustType c_longlong c_ulonglong intptr_t uintptr_t
4548
syn keyword rustType off_t dev_t ino_t pid_t mode_t ssize_t
4649

4750
syn keyword rustTrait Const Copy Send Owned Sized " inherent traits
48-
syn keyword rustTrait Eq Ord Num Ptr
51+
syn keyword rustTrait Clone Decodable Encodable IterBytes Rand ToStr
52+
syn keyword rustTrait Eq Ord TotalEq TotalOrd Num Ptr
4953
syn keyword rustTrait Drop Add Sub Mul Quot Rem Neg BitAnd BitOr
5054
syn keyword rustTrait BitXor Shl Shr Index
5155

@@ -72,19 +76,21 @@ syn keyword rustConstant STDIN_FILENO STDOUT_FILENO STDERR_FILENO
7276
" If foo::bar changes to foo.bar, change this ("::" to "\.").
7377
" If foo::bar changes to Foo::bar, change this (first "\w" to "\u").
7478
syn match rustModPath "\w\(\w\)*::[^<]"he=e-3,me=e-3
79+
syn match rustModPath "\w\(\w\)*" contained " only for 'use path;'
7580
syn match rustModPathSep "::"
7681

7782
syn match rustFuncCall "\w\(\w\)*("he=e-1,me=e-1
7883
syn match rustFuncCall "\w\(\w\)*::<"he=e-3,me=e-3 " foo::<T>();
7984

80-
syn match rustMacro '\w\(\w\)*!'
81-
syn match rustMacro '#\w\(\w\)*'
85+
syn match rustMacro '\w\(\w\)*!' contains=rustAssert,rustFail
86+
syn match rustMacro '#\w\(\w\)*' contains=rustAssert,rustFail
8287

8388
syn match rustFormat display "%\(\d\+\$\)\=[-+' #0*]*\(\d*\|\*\|\*\d\+\$\)\(\.\(\d*\|\*\|\*\d\+\$\)\)\=\([hlLjzt]\|ll\|hh\)\=\([aAbdiuoxXDOUfFeEgGcCsSpn?]\|\[\^\=.[^]]*\]\)" contained
8489
syn match rustFormat display "%%" contained
8590
syn region rustString start=+L\="+ skip=+\\\\\|\\"+ end=+"+ contains=rustTodo,rustFormat
8691

87-
syn region rustAttribute start="#\[" end="\]" contains=rustString
92+
syn region rustAttribute start="#\[" end="\]" contains=rustString,rustDeriving
93+
syn region rustDeriving start="deriving(" end=")" contains=rustTrait
8894

8995
" Number literals
9096
syn match rustNumber display "\<[0-9][0-9_]*\>"
@@ -143,11 +149,17 @@ hi def link rustMacro Macro
143149
hi def link rustType Type
144150
hi def link rustTodo Todo
145151
hi def link rustAttribute PreProc
152+
hi def link rustDeriving PreProc
146153
hi def link rustStorage StorageClass
147154
hi def link rustLifetime Special
148155

149156
" Other Suggestions:
157+
" hi rustAttribute ctermfg=cyan
158+
" hi rustDeriving ctermfg=cyan
159+
" hi rustAssert ctermfg=yellow
160+
" hi rustFail ctermfg=red
150161
" hi rustMacro ctermfg=magenta
162+
" hi rustModPathSep ctermfg=grey
151163

152164
syn sync minlines=200
153165
syn sync maxlines=500

branches/snap-stage3/src/libextra/arena.rs

Lines changed: 36 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -39,23 +39,32 @@ use core::prelude::*;
3939
use list::{MutList, MutCons, MutNil};
4040

4141
use core::at_vec;
42-
use core::cast::{transmute, transmute_mut_region};
42+
use core::cast::{transmute, transmute_mut, transmute_mut_region};
4343
use core::cast;
44+
use core::libc::size_t;
4445
use core::ptr;
46+
use core::sys::TypeDesc;
4547
use core::sys;
4648
use core::uint;
4749
use core::vec;
4850
use core::unstable::intrinsics;
49-
use core::unstable::intrinsics::{TyDesc};
5051

51-
#[cfg(not(stage0))]
52-
use core::unstable::intrinsics::{get_tydesc};
52+
pub mod rustrt {
53+
use core::libc::size_t;
54+
use core::sys::TypeDesc;
5355

54-
#[cfg(stage0)]
55-
unsafe fn get_tydesc<T>() -> *TyDesc {
56-
intrinsics::get_tydesc::<T>() as *TyDesc
56+
pub extern {
57+
#[rust_stack]
58+
unsafe fn rust_call_tydesc_glue(root: *u8,
59+
tydesc: *TypeDesc,
60+
field: size_t);
61+
}
5762
}
5863

64+
// This probably belongs somewhere else. Needs to be kept in sync with
65+
// changes to glue...
66+
static tydesc_drop_glue_index: size_t = 3 as size_t;
67+
5968
// The way arena uses arrays is really deeply awful. The arrays are
6069
// allocated, and have capacities reserved, but the fill for the array
6170
// will always stay at 0.
@@ -65,6 +74,7 @@ struct Chunk {
6574
is_pod: bool,
6675
}
6776

77+
#[mutable]
6878
pub struct Arena {
6979
// The head is separated out from the list as a unbenchmarked
7080
// microoptimization, to avoid needing to case on the list to
@@ -115,19 +125,6 @@ fn round_up_to(base: uint, align: uint) -> uint {
115125
(base + (align - 1)) & !(align - 1)
116126
}
117127

118-
#[inline]
119-
#[cfg(not(stage0))]
120-
unsafe fn call_drop_glue(tydesc: *TyDesc, data: *i8) {
121-
// This function should be inlined when stage0 is gone
122-
((*tydesc).drop_glue)(data);
123-
}
124-
125-
#[inline]
126-
#[cfg(stage0)]
127-
unsafe fn call_drop_glue(tydesc: *TyDesc, data: *i8) {
128-
((*tydesc).drop_glue)(0 as **TyDesc, data);
129-
}
130-
131128
// Walk down a chunk, running the destructors for any objects stored
132129
// in it.
133130
unsafe fn destroy_chunk(chunk: &Chunk) {
@@ -140,18 +137,19 @@ unsafe fn destroy_chunk(chunk: &Chunk) {
140137
let (tydesc, is_done) = un_bitpack_tydesc_ptr(*tydesc_data);
141138
let (size, align) = ((*tydesc).size, (*tydesc).align);
142139

143-
let after_tydesc = idx + sys::size_of::<*TyDesc>();
140+
let after_tydesc = idx + sys::size_of::<*TypeDesc>();
144141

145142
let start = round_up_to(after_tydesc, align);
146143

147144
//debug!("freeing object: idx = %u, size = %u, align = %u, done = %b",
148145
// start, size, align, is_done);
149146
if is_done {
150-
call_drop_glue(tydesc, ptr::offset(buf, start) as *i8);
147+
rustrt::rust_call_tydesc_glue(
148+
ptr::offset(buf, start), tydesc, tydesc_drop_glue_index);
151149
}
152150

153151
// Find where the next tydesc lives
154-
idx = round_up_to(start + size, sys::pref_align_of::<*TyDesc>());
152+
idx = round_up_to(start + size, sys::pref_align_of::<*TypeDesc>());
155153
}
156154
}
157155

@@ -160,12 +158,12 @@ unsafe fn destroy_chunk(chunk: &Chunk) {
160158
// is necessary in order to properly do cleanup if a failure occurs
161159
// during an initializer.
162160
#[inline]
163-
unsafe fn bitpack_tydesc_ptr(p: *TyDesc, is_done: bool) -> uint {
161+
unsafe fn bitpack_tydesc_ptr(p: *TypeDesc, is_done: bool) -> uint {
164162
let p_bits: uint = transmute(p);
165163
p_bits | (is_done as uint)
166164
}
167165
#[inline]
168-
unsafe fn un_bitpack_tydesc_ptr(p: uint) -> (*TyDesc, bool) {
166+
unsafe fn un_bitpack_tydesc_ptr(p: uint) -> (*TypeDesc, bool) {
169167
(transmute(p & !1), p & 1 == 1)
170168
}
171169

@@ -205,7 +203,7 @@ impl Arena {
205203
#[inline]
206204
fn alloc_pod<'a, T>(&'a mut self, op: &fn() -> T) -> &'a T {
207205
unsafe {
208-
let tydesc = get_tydesc::<T>();
206+
let tydesc = sys::get_type_desc::<T>();
209207
let ptr = self.alloc_pod_inner((*tydesc).size, (*tydesc).align);
210208
let ptr: *mut T = transmute(ptr);
211209
intrinsics::move_val_init(&mut (*ptr), op());
@@ -233,13 +231,13 @@ impl Arena {
233231
let head = transmute_mut_region(&mut self.head);
234232

235233
let tydesc_start = head.fill;
236-
let after_tydesc = head.fill + sys::size_of::<*TyDesc>();
234+
let after_tydesc = head.fill + sys::size_of::<*TypeDesc>();
237235
let start = round_up_to(after_tydesc, align);
238236
let end = start + n_bytes;
239237
if end > at_vec::capacity(head.data) {
240238
return self.alloc_nonpod_grow(n_bytes, align);
241239
}
242-
head.fill = round_up_to(end, sys::pref_align_of::<*TyDesc>());
240+
head.fill = round_up_to(end, sys::pref_align_of::<*TypeDesc>());
243241

244242
//debug!("idx = %u, size = %u, align = %u, fill = %u",
245243
// start, n_bytes, align, head.fill);
@@ -252,7 +250,7 @@ impl Arena {
252250
#[inline]
253251
fn alloc_nonpod<'a, T>(&'a mut self, op: &fn() -> T) -> &'a T {
254252
unsafe {
255-
let tydesc = get_tydesc::<T>();
253+
let tydesc = sys::get_type_desc::<T>();
256254
let (ty_ptr, ptr) =
257255
self.alloc_nonpod_inner((*tydesc).size, (*tydesc).align);
258256
let ty_ptr: *mut uint = transmute(ty_ptr);
@@ -272,23 +270,22 @@ impl Arena {
272270

273271
// The external interface
274272
#[inline]
275-
pub fn alloc<'a, T>(&'a mut self, op: &fn() -> T) -> &'a T {
273+
pub fn alloc<'a, T>(&'a self, op: &fn() -> T) -> &'a T {
276274
unsafe {
277275
// XXX: Borrow check
278-
let this = transmute_mut_region(self);
279-
if !intrinsics::needs_drop::<T>() {
280-
return this.alloc_pod(op);
276+
let this = transmute_mut(self);
277+
if intrinsics::needs_drop::<T>() {
278+
this.alloc_nonpod(op)
279+
} else {
280+
this.alloc_pod(op)
281281
}
282-
// XXX: Borrow check
283-
let this = transmute_mut_region(self);
284-
this.alloc_nonpod(op)
285282
}
286283
}
287284
}
288285

289286
#[test]
290287
fn test_arena_destructors() {
291-
let mut arena = Arena();
288+
let arena = Arena();
292289
for uint::range(0, 10) |i| {
293290
// Arena allocate something with drop glue to make sure it
294291
// doesn't leak.
@@ -303,7 +300,7 @@ fn test_arena_destructors() {
303300
#[should_fail]
304301
#[ignore(cfg(windows))]
305302
fn test_arena_destructors_fail() {
306-
let mut arena = Arena();
303+
let arena = Arena();
307304
// Put some stuff in the arena.
308305
for uint::range(0, 10) |i| {
309306
// Arena allocate something with drop glue to make sure it

branches/snap-stage3/src/libextra/bitv.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -666,12 +666,8 @@ impl BitvSet {
666666
pub fn symmetric_difference_with(&mut self, other: &BitvSet) {
667667
self.other_op(other, |w1, w2| w1 ^ w2);
668668
}
669-
}
670-
671-
impl BaseIter<uint> for BitvSet {
672-
fn size_hint(&self) -> Option<uint> { Some(self.len()) }
673669

674-
fn each(&self, blk: &fn(v: &uint) -> bool) -> bool {
670+
pub fn each(&self, blk: &fn(v: &uint) -> bool) -> bool {
675671
for self.bitv.storage.iter().enumerate().advance |(i, &w)| {
676672
if !iterate_bits(i * uint::bits, w, |b| blk(&b)) {
677673
return false;
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
use core::prelude::*;
12+
13+
use core::uint;
14+
use core::vec;
15+
16+
/**
17+
* The Digest trait specifies an interface common to digest functions, such as SHA-1 and the SHA-2
18+
* family of digest functions.
19+
*/
20+
pub trait Digest {
21+
/**
22+
* Provide message data.
23+
*
24+
* # Arguments
25+
*
26+
* * input - A vector of message data
27+
*/
28+
fn input(&mut self, input: &[u8]);
29+
30+
/**
31+
* Retrieve the digest result. This method may be called multiple times.
32+
*/
33+
fn result(&mut self, out: &mut [u8]);
34+
35+
/**
36+
* Reset the digest. This method must be called after result() and before supplying more
37+
* data.
38+
*/
39+
fn reset(&mut self);
40+
41+
/**
42+
* Get the output size in bits.
43+
*/
44+
fn output_bits(&self) -> uint;
45+
}
46+
47+
fn to_hex(rr: &[u8]) -> ~str {
48+
let mut s = ~"";
49+
for rr.iter().advance() |b| {
50+
let hex = uint::to_str_radix(*b as uint, 16u);
51+
if hex.len() == 1 {
52+
s += "0";
53+
}
54+
s += hex;
55+
}
56+
return s;
57+
}
58+
59+
/// Contains utility methods for Digests.
60+
/// FIXME: #7339: Convert to default methods when issues with them are resolved.
61+
pub trait DigestUtil {
62+
/**
63+
* Convenience functon that feeds a string into a digest
64+
*
65+
* # Arguments
66+
*
67+
* * in The string to feed into the digest
68+
*/
69+
fn input_str(&mut self, in: &str);
70+
71+
/**
72+
* Convenience functon that retrieves the result of a digest as a
73+
* ~str in hexadecimal format.
74+
*/
75+
fn result_str(&mut self) -> ~str;
76+
}
77+
78+
impl<D: Digest> DigestUtil for D {
79+
fn input_str(&mut self, in: &str) {
80+
self.input(in.as_bytes());
81+
}
82+
83+
fn result_str(&mut self) -> ~str {
84+
let mut buf = vec::from_elem((self.output_bits()+7)/8, 0u8);
85+
self.result(buf);
86+
return to_hex(buf);
87+
}
88+
}

0 commit comments

Comments
 (0)