Skip to content

Commit b0d9e84

Browse files
committed
---
yaml --- r: 147418 b: refs/heads/try2 c: 67c0222 h: refs/heads/master v: v3
1 parent 8af6c3d commit b0d9e84

Some content is hidden

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

41 files changed

+1484
-731
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 1b4bbc89b3ce40dc95abec688c322fef798292f1
8+
refs/heads/try2: 67c02222526d46875ddabfda1b7a936564f916ff
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/Makefile.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,11 @@ ifneq ($(strip $(findstring snap,$(MAKECMDGOALS)) \
657657
include $(CFG_SRC_DIR)mk/snap.mk
658658
endif
659659

660+
ifneq ($(findstring reformat,$(MAKECMDGOALS)),)
661+
CFG_INFO := $(info cfg: including reformat rules)
662+
include $(CFG_SRC_DIR)mk/pp.mk
663+
endif
664+
660665
ifneq ($(strip $(findstring check,$(MAKECMDGOALS)) \
661666
$(findstring test,$(MAKECMDGOALS)) \
662667
$(findstring perf,$(MAKECMDGOALS)) \

branches/try2/mk/clean.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ clean-generic-$(2)-$(1):
6363
-name '*.[odasS]' -o \
6464
-name '*.so' -o \
6565
-name '*.dylib' -o \
66-
-name '*.lib' -o \
6766
-name '*.dll' -o \
6867
-name '*.def' -o \
6968
-name '*.bc' \

branches/try2/mk/pp.mk

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
# Create a way to reformat just some files
12+
ifdef PPFILES
13+
PP_INPUTS_FILTERED := $(wildcard $(PPFILES))
14+
else
15+
PP_INPUTS = $(wildcard $(addprefix $(S)src/libstd/,*.rs */*.rs)) \
16+
$(wildcard $(addprefix $(S)src/libextra/,*.rs */*.rs)) \
17+
$(wildcard $(addprefix $(S)src/rustc/,*.rs */*.rs */*/*.rs)) \
18+
$(wildcard $(S)src/test/*/*.rs \
19+
$(S)src/test/*/*/*.rs) \
20+
$(wildcard $(S)src/rustpkg/*.rs) \
21+
$(wildcard $(S)src/rust/*.rs)
22+
23+
PP_INPUTS_FILTERED = $(shell echo $(PP_INPUTS) | xargs grep -L \
24+
"no-reformat\|xfail-pretty\|xfail-test")
25+
endif
26+
27+
reformat: $(SREQ1$(CFG_BUILD))
28+
@$(call E, reformat [stage1]: $@)
29+
for i in $(PP_INPUTS_FILTERED); \
30+
do $(call CFG_RUN_TARG_$(CFG_BUILD),1,$(CFG_BUILD)/stage1/rustc$(X_$(CFG_BUILD))) \
31+
--pretty normal $$i >$$i.tmp; \
32+
if [ $$? -ne 0 ]; \
33+
then echo failed to print $$i; rm $$i.tmp; \
34+
else if cmp --silent $$i.tmp $$i; \
35+
then echo no changes to $$i; rm $$i.tmp; \
36+
else echo reformated $$i; mv $$i.tmp $$i; \
37+
fi; \
38+
fi; \
39+
done

branches/try2/mk/tests.mk

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -908,8 +908,6 @@ define DEF_RMAKE_FOR_T_H
908908
# $(2) target triple
909909
# $(3) host triple
910910

911-
912-
ifeq ($(2)$(3),$$(CFG_BUILD)$$(CFG_BUILD))
913911
check-stage$(1)-T-$(2)-H-$(3)-rmake-exec: \
914912
$$(call TEST_OK_FILE,$(1),$(2),$(3),rmake)
915913

@@ -929,13 +927,6 @@ $(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok: \
929927
"$$(CC_$(3)) $$(CFG_GCCISH_CFLAGS_$(3))" \
930928
$$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3))
931929
@touch $$@
932-
else
933-
# FIXME #11094 - The above rule doesn't work right for multiple targets
934-
check-stage$(1)-T-$(2)-H-$(3)-rmake-exec:
935-
@true
936-
937-
endif
938-
939930

940931
endef
941932

branches/try2/src/libextra/arc.rs

Lines changed: 15 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ use std::borrow;
5151
/// As sync::condvar, a mechanism for unlock-and-descheduling and signaling.
5252
pub struct Condvar<'a> {
5353
priv is_mutex: bool,
54-
priv failed: &'a bool,
54+
priv failed: &'a mut bool,
5555
priv cond: &'a sync::Condvar<'a>
5656
}
5757

@@ -226,7 +226,7 @@ impl<T:Send> MutexArc<T> {
226226
// not already unsafe. See borrow_rwlock, far below.
227227
(&(*state).lock).lock(|| {
228228
check_poison(true, (*state).failed);
229-
let _z = PoisonOnFail::new(&mut (*state).failed);
229+
let _z = PoisonOnFail(&mut (*state).failed);
230230
blk(&mut (*state).data)
231231
})
232232
}
@@ -239,10 +239,10 @@ impl<T:Send> MutexArc<T> {
239239
let state = self.x.get();
240240
(&(*state).lock).lock_cond(|cond| {
241241
check_poison(true, (*state).failed);
242-
let _z = PoisonOnFail::new(&mut (*state).failed);
242+
let _z = PoisonOnFail(&mut (*state).failed);
243243
blk(&mut (*state).data,
244244
&Condvar {is_mutex: true,
245-
failed: &(*state).failed,
245+
failed: &mut (*state).failed,
246246
cond: cond })
247247
})
248248
}
@@ -311,28 +311,24 @@ fn check_poison(is_mutex: bool, failed: bool) {
311311

312312
#[doc(hidden)]
313313
struct PoisonOnFail {
314-
flag: *mut bool,
315-
failed: bool,
314+
failed: *mut bool,
316315
}
317316

318317
impl Drop for PoisonOnFail {
319318
fn drop(&mut self) {
320319
unsafe {
321320
/* assert!(!*self.failed);
322321
-- might be false in case of cond.wait() */
323-
if !self.failed && task::failing() {
324-
*self.flag = true;
322+
if task::failing() {
323+
*self.failed = true;
325324
}
326325
}
327326
}
328327
}
329328

330-
impl PoisonOnFail {
331-
fn new<'a>(flag: &'a mut bool) -> PoisonOnFail {
332-
PoisonOnFail {
333-
flag: flag,
334-
failed: task::failing()
335-
}
329+
fn PoisonOnFail<'r>(failed: &'r mut bool) -> PoisonOnFail {
330+
PoisonOnFail {
331+
failed: failed
336332
}
337333
}
338334

@@ -396,7 +392,7 @@ impl<T:Freeze + Send> RWArc<T> {
396392
let state = self.x.get();
397393
(*borrow_rwlock(state)).write(|| {
398394
check_poison(false, (*state).failed);
399-
let _z = PoisonOnFail::new(&mut (*state).failed);
395+
let _z = PoisonOnFail(&mut (*state).failed);
400396
blk(&mut (*state).data)
401397
})
402398
}
@@ -411,10 +407,10 @@ impl<T:Freeze + Send> RWArc<T> {
411407
let state = self.x.get();
412408
(*borrow_rwlock(state)).write_cond(|cond| {
413409
check_poison(false, (*state).failed);
414-
let _z = PoisonOnFail::new(&mut (*state).failed);
410+
let _z = PoisonOnFail(&mut (*state).failed);
415411
blk(&mut (*state).data,
416412
&Condvar {is_mutex: false,
417-
failed: &(*state).failed,
413+
failed: &mut (*state).failed,
418414
cond: cond})
419415
})
420416
}
@@ -467,7 +463,7 @@ impl<T:Freeze + Send> RWArc<T> {
467463
blk(RWWriteMode {
468464
data: &mut (*state).data,
469465
token: write_mode,
470-
poison: PoisonOnFail::new(&mut (*state).failed)
466+
poison: PoisonOnFail(&mut (*state).failed)
471467
})
472468
})
473469
}
@@ -567,7 +563,7 @@ impl<'a, T:Freeze + Send> RWWriteMode<'a, T> {
567563
unsafe {
568564
let cvar = Condvar {
569565
is_mutex: false,
570-
failed: &*poison.flag,
566+
failed: &mut *poison.failed,
571567
cond: cond
572568
};
573569
blk(data, &cvar)
@@ -718,25 +714,6 @@ mod tests {
718714
}
719715
}
720716

721-
#[test]
722-
fn test_mutex_arc_access_in_unwind() {
723-
let arc = MutexArc::new(1i);
724-
let arc2 = arc.clone();
725-
task::try::<()>(proc() {
726-
struct Unwinder {
727-
i: MutexArc<int>
728-
}
729-
impl Drop for Unwinder {
730-
fn drop(&mut self) {
731-
self.i.access(|num| *num += 1);
732-
}
733-
}
734-
let _u = Unwinder { i: arc2 };
735-
fail!();
736-
});
737-
assert_eq!(2, arc.access(|n| *n));
738-
}
739-
740717
#[test] #[should_fail]
741718
fn test_rw_arc_poison_wr() {
742719
let arc = RWArc::new(1);
@@ -863,26 +840,6 @@ mod tests {
863840
assert_eq!(*num, 10);
864841
})
865842
}
866-
867-
#[test]
868-
fn test_rw_arc_access_in_unwind() {
869-
let arc = RWArc::new(1i);
870-
let arc2 = arc.clone();
871-
task::try::<()>(proc() {
872-
struct Unwinder {
873-
i: RWArc<int>
874-
}
875-
impl Drop for Unwinder {
876-
fn drop(&mut self) {
877-
self.i.write(|num| *num += 1);
878-
}
879-
}
880-
let _u = Unwinder { i: arc2 };
881-
fail!();
882-
});
883-
assert_eq!(2, arc.read(|n| *n));
884-
}
885-
886843
#[test]
887844
fn test_rw_downgrade() {
888845
// (1) A downgrader gets in write mode and does cond.wait.

branches/try2/src/libextra/glob.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ use std::io;
2828
use std::io::fs;
2929
use std::path::is_sep;
3030

31+
use sort;
32+
3133
/**
3234
* An iterator that yields Paths from the filesystem that match a particular
3335
* pattern - see the `glob` function for more details.
@@ -147,8 +149,9 @@ impl Iterator<Path> for GlobIterator {
147149

148150
fn list_dir_sorted(path: &Path) -> ~[Path] {
149151
match io::result(|| fs::readdir(path)) {
150-
Ok(mut children) => {
151-
children.sort_by(|p1, p2| p2.filename().cmp(&p1.filename()));
152+
Ok(children) => {
153+
let mut children = children;
154+
sort::quick_sort(children, |p1, p2| p2.filename() <= p1.filename());
152155
children
153156
}
154157
Err(..) => ~[]
@@ -768,3 +771,4 @@ mod test {
768771
assert!(Pattern::new("a/b").matches_path(&Path::new("a/b")));
769772
}
770773
}
774+

branches/try2/src/libextra/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ pub mod ringbuf;
6161
pub mod priority_queue;
6262
pub mod smallintmap;
6363

64+
pub mod sort;
65+
6466
pub mod dlist;
6567
pub mod treemap;
6668
pub mod btree;

branches/try2/src/libextra/priority_queue.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ impl<T: Ord> Extendable<T> for PriorityQueue<T> {
213213

214214
#[cfg(test)]
215215
mod tests {
216+
use sort::merge_sort;
216217
use priority_queue::PriorityQueue;
217218

218219
#[test]
@@ -230,8 +231,7 @@ mod tests {
230231
#[test]
231232
fn test_top_and_pop() {
232233
let data = ~[2u, 4, 6, 2, 1, 8, 10, 3, 5, 7, 0, 9, 1];
233-
let mut sorted = data.clone();
234-
sorted.sort();
234+
let mut sorted = merge_sort(data, |x, y| x.le(y));
235235
let mut heap = PriorityQueue::from_vec(data);
236236
while !heap.is_empty() {
237237
assert_eq!(heap.top(), sorted.last());
@@ -311,14 +311,11 @@ mod tests {
311311
assert_eq!(heap.len(), 5);
312312
}
313313

314-
fn check_to_vec(mut data: ~[int]) {
314+
fn check_to_vec(data: ~[int]) {
315315
let heap = PriorityQueue::from_vec(data.clone());
316-
let mut v = heap.clone().to_vec();
317-
v.sort();
318-
data.sort();
319-
320-
assert_eq!(v, data);
321-
assert_eq!(heap.to_sorted_vec(), data);
316+
assert_eq!(merge_sort(heap.clone().to_vec(), |x, y| x.le(y)),
317+
merge_sort(data, |x, y| x.le(y)));
318+
assert_eq!(heap.to_sorted_vec(), merge_sort(data, |x, y| x.le(y)));
322319
}
323320

324321
#[test]

0 commit comments

Comments
 (0)