Skip to content

Commit d91c4b9

Browse files
committed
---
yaml --- r: 110879 b: refs/heads/auto c: c60d9ad h: refs/heads/master i: 110877: d5aae1e 110875: 42f99db 110871: f91055d 110863: fa51ea6 110847: abbd2cd v: v3
1 parent bb318a8 commit d91c4b9

Some content is hidden

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

114 files changed

+1725
-1193
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: 96aeb7e3c35ee0d0cf5b9ab8db5ef69e4cfb264e
16+
refs/heads/auto: c60d9ad57c1d409a0737838eefe82da0eeb9a9ec
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/mk/main.mk

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -349,21 +349,44 @@ EXTRAFLAGS_STAGE$(1) = $$(RUSTFLAGS_STAGE$(1))
349349

350350
CFGFLAG$(1)_T_$(2)_H_$(3) = stage$(1)
351351

352+
endef
353+
354+
# Same macro/variables as above, but defined in a separate loop so it can use
355+
# all the varibles above for all archs. The RPATH_VAR setup sometimes needs to
356+
# reach across triples to get things in order.
357+
define SREQ_CMDS
358+
359+
ifeq ($$(OSTYPE_$(3)),apple-darwin)
360+
RPATH_VAR$(1)_T_$(2)_H_$(3) := \
361+
DYLD_LIBRARY_PATH="$$$$DYLD_LIBRARY_PATH:$$(CURDIR)/$$(HLIB$(1)_H_$(3))"
362+
else
363+
RPATH_VAR$(1)_T_$(2)_H_$(3) := \
364+
LD_LIBRARY_PATH="$$$$LD_LIBRARY_PATH:$$(CURDIR)/$$(HLIB$(1)_H_$(3))"
365+
endif
366+
352367
# Pass --cfg stage0 only for the build->host part of stage0;
353368
# if you're building a cross config, the host->* parts are
354369
# effectively stage1, since it uses the just-built stage0.
370+
#
371+
# This logic is similar to how the LD_LIBRARY_PATH variable must
372+
# change be slightly different when doing cross compilations.
373+
# The build doesn't copy over all target libraries into
374+
# a new directory, so we need to point the library path at
375+
# the build directory where all the target libraries came
376+
# from (the stage0 build host). Otherwise the relative rpaths
377+
# inside of the rustc binary won't get resolved correctly.
355378
ifeq ($(1),0)
356379
ifneq ($(strip $(CFG_BUILD)),$(strip $(3)))
357380
CFGFLAG$(1)_T_$(2)_H_$(3) = stage1
358-
endif
359-
endif
360381

361382
ifeq ($$(OSTYPE_$(3)),apple-darwin)
362383
RPATH_VAR$(1)_T_$(2)_H_$(3) := \
363-
DYLD_LIBRARY_PATH="$$$$DYLD_LIBRARY_PATH:$$(CURDIR)/$$(HLIB$(1)_H_$(3))"
384+
DYLD_LIBRARY_PATH="$$$$DYLD_LIBRARY_PATH:$$(CURDIR)/$$(TLIB1_T_$(2)_H_$(CFG_BUILD))"
364385
else
365386
RPATH_VAR$(1)_T_$(2)_H_$(3) := \
366-
LD_LIBRARY_PATH="$$$$LD_LIBRARY_PATH:$$(CURDIR)/$$(HLIB$(1)_H_$(3))"
387+
LD_LIBRARY_PATH="$$$$LD_LIBRARY_PATH:$$(CURDIR)/$$(TLIB1_T_$(2)_H_$(CFG_BUILD))"
388+
endif
389+
endif
367390
endif
368391

369392
STAGE$(1)_T_$(2)_H_$(3) := \
@@ -390,6 +413,11 @@ $(foreach build,$(CFG_HOST), \
390413
$(eval $(foreach stage,$(STAGES), \
391414
$(eval $(call SREQ,$(stage),$(target),$(build))))))))
392415

416+
$(foreach build,$(CFG_HOST), \
417+
$(eval $(foreach target,$(CFG_TARGET), \
418+
$(eval $(foreach stage,$(STAGES), \
419+
$(eval $(call SREQ_CMDS,$(stage),$(target),$(build))))))))
420+
393421
######################################################################
394422
# rustc-H-targets
395423
#

branches/auto/src/doc/guide-ffi.md

Lines changed: 23 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,14 @@ snappy includes a C interface (documented in
1111
The following is a minimal example of calling a foreign function which will
1212
compile if snappy is installed:
1313

14-
~~~~
14+
~~~~ {.ignore}
1515
extern crate libc;
1616
use libc::size_t;
1717
1818
#[link(name = "snappy")]
19-
# #[cfg(ignore_this)]
2019
extern {
2120
fn snappy_max_compressed_length(source_length: size_t) -> size_t;
2221
}
23-
# unsafe fn snappy_max_compressed_length(a: size_t) -> size_t { a }
2422
2523
fn main() {
2624
let x = unsafe { snappy_max_compressed_length(100) };
@@ -80,11 +78,7 @@ vectors as pointers to memory. Rust's vectors are guaranteed to be a contiguous
8078
length is number of elements currently contained, and the capacity is the total size in elements of
8179
the allocated memory. The length is less than or equal to the capacity.
8280

83-
~~~~
84-
# extern crate libc;
85-
# use libc::{c_int, size_t};
86-
# unsafe fn snappy_validate_compressed_buffer(_: *u8, _: size_t) -> c_int { 0 }
87-
# fn main() {}
81+
~~~~ {.ignore}
8882
pub fn validate_compressed_buffer(src: &[u8]) -> bool {
8983
unsafe {
9084
snappy_validate_compressed_buffer(src.as_ptr(), src.len() as size_t) == 0
@@ -104,20 +98,14 @@ required capacity to hold the compressed output. The vector can then be passed t
10498
`snappy_compress` function as an output parameter. An output parameter is also passed to retrieve
10599
the true length after compression for setting the length.
106100

107-
~~~~
108-
# extern crate libc;
109-
# use libc::{size_t, c_int};
110-
# unsafe fn snappy_compress(a: *u8, b: size_t, c: *mut u8,
111-
# d: *mut size_t) -> c_int { 0 }
112-
# unsafe fn snappy_max_compressed_length(a: size_t) -> size_t { a }
113-
# fn main() {}
114-
pub fn compress(src: &[u8]) -> Vec<u8> {
101+
~~~~ {.ignore}
102+
pub fn compress(src: &[u8]) -> ~[u8] {
115103
unsafe {
116104
let srclen = src.len() as size_t;
117105
let psrc = src.as_ptr();
118106
119107
let mut dstlen = snappy_max_compressed_length(srclen);
120-
let mut dst = Vec::with_capacity(dstlen as uint);
108+
let mut dst = slice::with_capacity(dstlen as uint);
121109
let pdst = dst.as_mut_ptr();
122110
123111
snappy_compress(psrc, srclen, pdst, &mut dstlen);
@@ -130,26 +118,16 @@ pub fn compress(src: &[u8]) -> Vec<u8> {
130118
Decompression is similar, because snappy stores the uncompressed size as part of the compression
131119
format and `snappy_uncompressed_length` will retrieve the exact buffer size required.
132120

133-
~~~~
134-
# extern crate libc;
135-
# use libc::{size_t, c_int};
136-
# unsafe fn snappy_uncompress(compressed: *u8,
137-
# compressed_length: size_t,
138-
# uncompressed: *mut u8,
139-
# uncompressed_length: *mut size_t) -> c_int { 0 }
140-
# unsafe fn snappy_uncompressed_length(compressed: *u8,
141-
# compressed_length: size_t,
142-
# result: *mut size_t) -> c_int { 0 }
143-
# fn main() {}
144-
pub fn uncompress(src: &[u8]) -> Option<Vec<u8>> {
121+
~~~~ {.ignore}
122+
pub fn uncompress(src: &[u8]) -> Option<~[u8]> {
145123
unsafe {
146124
let srclen = src.len() as size_t;
147125
let psrc = src.as_ptr();
148126
149127
let mut dstlen: size_t = 0;
150128
snappy_uncompressed_length(psrc, srclen, &mut dstlen);
151129
152-
let mut dst = Vec::with_capacity(dstlen as uint);
130+
let mut dst = slice::with_capacity(dstlen as uint);
153131
let pdst = dst.as_mut_ptr();
154132
155133
if snappy_uncompress(psrc, srclen, pdst, &mut dstlen) == 0 {
@@ -209,19 +187,16 @@ A basic example is:
209187

210188
Rust code:
211189

212-
~~~~
190+
~~~~ {.ignore}
213191
extern fn callback(a:i32) {
214192
println!("I'm called from C with value {0}", a);
215193
}
216194
217195
#[link(name = "extlib")]
218-
# #[cfg(ignore)]
219196
extern {
220-
fn register_callback(cb: extern fn(i32)) -> i32;
197+
fn register_callback(cb: extern "C" fn(i32)) -> i32;
221198
fn trigger_callback();
222199
}
223-
# unsafe fn register_callback(cb: extern fn(i32)) -> i32 { 0 }
224-
# unsafe fn trigger_callback() { }
225200
226201
fn main() {
227202
unsafe {
@@ -265,39 +240,33 @@ referenced Rust object.
265240

266241
Rust code:
267242

268-
~~~~
243+
~~~~ {.ignore}
269244
270245
struct RustObject {
271246
a: i32,
272247
// other members
273248
}
274249
275-
extern fn callback(target: *mut RustObject, a:i32) {
250+
extern fn callback(target: *RustObject, a:i32) {
276251
println!("I'm called from C with value {0}", a);
277-
unsafe {
278-
// Update the value in RustObject with the value received from the callback
279-
(*target).a = a;
280-
}
252+
(*target).a = a; // Update the value in RustObject with the value received from the callback
281253
}
282254
283255
#[link(name = "extlib")]
284-
# #[cfg(ignore)]
285256
extern {
286-
fn register_callback(target: *mut RustObject,
287-
cb: extern fn(*mut RustObject, i32)) -> i32;
257+
fn register_callback(target: *RustObject, cb: extern "C" fn(*RustObject, i32)) -> i32;
288258
fn trigger_callback();
289259
}
290-
# unsafe fn register_callback(a: *mut RustObject,
291-
# b: extern fn(*mut RustObject, i32)) -> i32 { 0 }
292-
# unsafe fn trigger_callback() {}
293260
294261
fn main() {
295262
// Create the object that will be referenced in the callback
296-
let mut rust_object = ~RustObject{ a: 5 };
263+
let rust_object = ~RustObject{a: 5, ...};
297264
298265
unsafe {
299-
register_callback(&mut *rust_object, callback);
300-
trigger_callback();
266+
// Gets a raw pointer to the object
267+
let target_addr:*RustObject = ptr::to_unsafe_ptr(rust_object);
268+
register_callback(target_addr, callback);
269+
trigger_callback(); // Triggers the callback
301270
}
302271
}
303272
~~~~
@@ -434,15 +403,13 @@ Foreign APIs often export a global variable which could do something like track
434403
global state. In order to access these variables, you declare them in `extern`
435404
blocks with the `static` keyword:
436405

437-
~~~
406+
~~~{.ignore}
438407
extern crate libc;
439408
440409
#[link(name = "readline")]
441-
# #[cfg(ignore)]
442410
extern {
443411
static rl_readline_version: libc::c_int;
444412
}
445-
# static rl_readline_version: libc::c_int = 0;
446413
447414
fn main() {
448415
println!("You have readline version {} installed.",
@@ -454,23 +421,21 @@ Alternatively, you may need to alter global state provided by a foreign
454421
interface. To do this, statics can be declared with `mut` so rust can mutate
455422
them.
456423

457-
~~~
424+
~~~{.ignore}
458425
extern crate libc;
459426
use std::ptr;
460427
461428
#[link(name = "readline")]
462-
# #[cfg(ignore)]
463429
extern {
464430
static mut rl_prompt: *libc::c_char;
465431
}
466-
# static mut rl_prompt: *libc::c_char = 0 as *libc::c_char;
467432
468433
fn main() {
469-
"[my-awesome-shell] $".with_c_str(|buf| {
434+
do "[my-awesome-shell] $".as_c_str |buf| {
470435
unsafe { rl_prompt = buf; }
471436
// get a line, process it
472437
unsafe { rl_prompt = ptr::null(); }
473-
});
438+
}
474439
}
475440
~~~
476441

branches/auto/src/doc/guide-testing.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ runner.
170170

171171
The type signature of a benchmark function differs from a unit test:
172172
it takes a mutable reference to type
173-
`test::Bencher`. Inside the benchmark function, any
173+
`test::BenchHarness`. Inside the benchmark function, any
174174
time-variable or "setup" code should execute first, followed by a call
175175
to `iter` on the benchmark harness, passing a closure that contains
176176
the portion of the benchmark you wish to actually measure the
@@ -189,16 +189,16 @@ For example:
189189
extern crate test;
190190
191191
use std::slice;
192-
use test::Bencher;
192+
use test::BenchHarness;
193193
194194
#[bench]
195-
fn bench_sum_1024_ints(b: &mut Bencher) {
195+
fn bench_sum_1024_ints(b: &mut BenchHarness) {
196196
let v = slice::from_fn(1024, |n| n);
197197
b.iter(|| {v.iter().fold(0, |old, new| old + *new);} );
198198
}
199199
200200
#[bench]
201-
fn initialise_a_vector(b: &mut Bencher) {
201+
fn initialise_a_vector(b: &mut BenchHarness) {
202202
b.iter(|| {slice::from_elem(1024, 0u64);} );
203203
b.bytes = 1024 * 8;
204204
}
@@ -249,11 +249,11 @@ it entirely.
249249
~~~
250250
# #[allow(unused_imports)];
251251
extern crate test;
252-
use test::Bencher;
252+
use test::BenchHarness;
253253
254254
#[bench]
255-
fn bench_xor_1000_ints(b: &mut Bencher) {
256-
b.iter(|| {
255+
fn bench_xor_1000_ints(bh: &mut BenchHarness) {
256+
bh.iter(|| {
257257
range(0, 1000).fold(0, |old, new| old ^ new);
258258
});
259259
}

branches/auto/src/libarena/lib.rs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,9 @@ impl<T> Drop for TypedArena<T> {
481481
#[cfg(test)]
482482
mod tests {
483483
extern crate test;
484-
use self::test::Bencher;
484+
485+
486+
use self::test::BenchHarness;
485487
use super::{Arena, TypedArena};
486488

487489
struct Point {
@@ -503,9 +505,9 @@ mod tests {
503505
}
504506

505507
#[bench]
506-
pub fn bench_copy(b: &mut Bencher) {
508+
pub fn bench_copy(bh: &mut BenchHarness) {
507509
let arena = TypedArena::new();
508-
b.iter(|| {
510+
bh.iter(|| {
509511
arena.alloc(Point {
510512
x: 1,
511513
y: 2,
@@ -515,8 +517,8 @@ mod tests {
515517
}
516518

517519
#[bench]
518-
pub fn bench_copy_nonarena(b: &mut Bencher) {
519-
b.iter(|| {
520+
pub fn bench_copy_nonarena(bh: &mut BenchHarness) {
521+
bh.iter(|| {
520522
~Point {
521523
x: 1,
522524
y: 2,
@@ -526,9 +528,9 @@ mod tests {
526528
}
527529

528530
#[bench]
529-
pub fn bench_copy_old_arena(b: &mut Bencher) {
531+
pub fn bench_copy_old_arena(bh: &mut BenchHarness) {
530532
let arena = Arena::new();
531-
b.iter(|| {
533+
bh.iter(|| {
532534
arena.alloc(|| {
533535
Point {
534536
x: 1,
@@ -556,9 +558,9 @@ mod tests {
556558
}
557559

558560
#[bench]
559-
pub fn bench_noncopy(b: &mut Bencher) {
561+
pub fn bench_noncopy(bh: &mut BenchHarness) {
560562
let arena = TypedArena::new();
561-
b.iter(|| {
563+
bh.iter(|| {
562564
arena.alloc(Noncopy {
563565
string: ~"hello world",
564566
array: vec!( 1, 2, 3, 4, 5 ),
@@ -567,8 +569,8 @@ mod tests {
567569
}
568570

569571
#[bench]
570-
pub fn bench_noncopy_nonarena(b: &mut Bencher) {
571-
b.iter(|| {
572+
pub fn bench_noncopy_nonarena(bh: &mut BenchHarness) {
573+
bh.iter(|| {
572574
~Noncopy {
573575
string: ~"hello world",
574576
array: vec!( 1, 2, 3, 4, 5 ),
@@ -577,9 +579,9 @@ mod tests {
577579
}
578580

579581
#[bench]
580-
pub fn bench_noncopy_old_arena(b: &mut Bencher) {
582+
pub fn bench_noncopy_old_arena(bh: &mut BenchHarness) {
581583
let arena = Arena::new();
582-
b.iter(|| {
584+
bh.iter(|| {
583585
arena.alloc(|| Noncopy {
584586
string: ~"hello world",
585587
array: vec!( 1, 2, 3, 4, 5 ),

0 commit comments

Comments
 (0)