Skip to content

Commit fa0ceab

Browse files
committed
---
yaml --- r: 89567 b: refs/heads/master c: 3a15482 h: refs/heads/master i: 89565: 5233722 89563: 0d7864a 89559: 07d7e1a 89551: 6c5bfee 89535: 311ce0b v: v3
1 parent 90b3434 commit fa0ceab

File tree

22 files changed

+522
-387
lines changed

22 files changed

+522
-387
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 8f258ab532eebce705b5eb27cc8635400992ca54
2+
refs/heads/master: 3a15482b9c602d162c6c26c36ab608eb1bef953d
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a6d3e57dca68fde4effdda3e4ae2887aa535fcd6
55
refs/heads/try: b160761e35efcd1207112b3b782c06633cf441a8

trunk/configure

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,13 @@ do
670670
fi
671671
;;
672672

673+
arm-apple-darwin)
674+
if [ $CFG_OSTYPE != apple-darwin ]
675+
then
676+
err "The iOS target is only supported on Mac OS X"
677+
fi
678+
;;
679+
673680
*)
674681
;;
675682
esac

trunk/mk/platform.mk

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,35 @@ CFG_LDPATH_i686-unknown-linux-gnu :=
193193
CFG_RUN_i686-unknown-linux-gnu=$(2)
194194
CFG_RUN_TARG_i686-unknown-linux-gnu=$(call CFG_RUN_i686-unknown-linux-gnu,,$(2))
195195

196+
# arm-apple-darwin configuration
197+
ifeq ($(CFG_OSTYPE),apple-darwin)
198+
CFG_IOS_SDK = $(shell xcrun --show-sdk-path -sdk iphoneos)
199+
CFG_IOS_FLAGS = -target arm-apple-darwin -isysroot $(CFG_IOS_SDK) -I $(CFG_IOS_SDK)/usr/include -I $(CFG_IOS_SDK)/usr/include/c++/4.2.1 -I /usr/include
200+
CC_arm-apple-darwin = $(shell xcrun -find -sdk iphoneos clang)
201+
CXX_arm-apple-darwin = $(shell xcrun -find -sdk iphoneos clang++)
202+
CPP_arm-apple-darwin = $(shell xcrun -find -sdk iphoneos clang++)
203+
AR_arm-apple-darwin = $(shell xcrun -find -sdk iphoneos ar)
204+
CFG_LIB_NAME_arm-apple-darwin = lib$(1).dylib
205+
CFG_LIB_GLOB_arm-apple-darwin = lib$(1)-*.dylib
206+
CFG_LIB_DSYM_GLOB_arm-apple-darwin = lib$(1)-*.dylib.dSYM
207+
CFG_GCCISH_CFLAGS_arm-apple-darwin := -Wall -Werror -g -fPIC $(CFG_IOS_FLAGS)
208+
CFG_GCCISH_CXXFLAGS_arm-apple-darwin := -fno-rtti $(CFG_IOS_FLAGS)
209+
CFG_GCCISH_LINK_FLAGS_arm-apple-darwin := -dynamiclib -lpthread -framework CoreServices -Wl,-no_compact_unwind
210+
CFG_GCCISH_DEF_FLAG_arm-apple-darwin := -Wl,-exported_symbols_list,
211+
CFG_GCCISH_PRE_LIB_FLAGS_arm-apple-darwin :=
212+
CFG_GCCISH_POST_LIB_FLAGS_arm-apple-darwin :=
213+
CFG_DEF_SUFFIX_arm-apple-darwin := .darwin.def
214+
CFG_INSTALL_NAME_arm-apple-darwin = -Wl,-install_name,@rpath/$(1)
215+
CFG_LIBUV_LINK_FLAGS_arm-apple-darwin =
216+
CFG_EXE_SUFFIX_arm-apple-darwin :=
217+
CFG_WINDOWSY_arm-apple-darwin :=
218+
CFG_UNIXY_arm-apple-darwin := 1
219+
CFG_PATH_MUNGE_arm-apple-darwin := true
220+
CFG_LDPATH_arm-apple-darwin :=
221+
CFG_RUN_arm-apple-darwin = $(2)
222+
CFG_RUN_TARG_arm-apple-darwin = $(call CFG_RUN_arm-apple-darwin,,$(2))
223+
endif
224+
196225
# x86_64-apple-darwin configuration
197226
CC_x86_64-apple-darwin=$(CC)
198227
CXX_x86_64-apple-darwin=$(CXX)

trunk/src/etc/ziggurat_tables.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import random
2020

2121
# The order should match the return value of `tables`
22-
TABLE_NAMES = ['X', 'F', 'F_DIFF']
22+
TABLE_NAMES = ['X', 'F']
2323

2424
# The actual length of the table is 1 more, to stop
2525
# index-out-of-bounds errors. This should match the bitwise operation
@@ -43,13 +43,10 @@ def tables(r, v, f, f_inv):
4343

4444
# cache the f's
4545
fvec = [0]*(TABLE_LEN+1)
46-
fdiff = [0]*(TABLE_LEN+1)
4746
for i in range(TABLE_LEN+1):
4847
fvec[i] = f(xvec[i])
49-
if i > 0:
50-
fdiff[i] = fvec[i] - fvec[i-1]
5148

52-
return xvec, fvec, fdiff
49+
return xvec, fvec
5350

5451
# Distributions
5552
# N(0, 1)

trunk/src/librustc/front/feature_gate.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,12 @@ impl Visitor<()> for Context {
140140

141141
},
142142
ast::ty_box(_) => {
143-
self.gate_feature("managed_boxes", t.span, "The managed box syntax may be replaced \
144-
by a library type, and a garbage \
145-
collector is not yet implemented. \
146-
Consider using the `std::rc` module \
147-
as it performs much better as a \
148-
reference counting implementation.");
143+
self.gate_feature("managed_boxes", t.span,
144+
"The managed box syntax will be replaced \
145+
by a library type, and a garbage \
146+
collector is not yet implemented. \
147+
Consider using the `std::rc::Rc` type \
148+
for reference counted pointers.");
149149
}
150150
_ => {}
151151
}

trunk/src/librustc/middle/trans/base.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ pub fn decl_fn(llmod: ModuleRef, name: &str, cc: lib::llvm::CallConv, ty: Type)
182182
};
183183

184184
lib::llvm::SetFunctionCallConv(llfn, cc);
185+
// Function addresses in Rust are never significant, allowing functions to be merged.
186+
lib::llvm::SetUnnamedAddr(llfn, true);
185187
return llfn;
186188
}
187189

trunk/src/librustc/util/ppaux.rs

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -308,10 +308,11 @@ pub fn ty_to_str(cx: ctxt, typ: t) -> ~str {
308308
ident: Option<ast::Ident>,
309309
sig: &ty::FnSig)
310310
-> ~str {
311-
let mut s = ~"extern ";
312-
313-
s.push_str(abis.to_str());
314-
s.push_char(' ');
311+
let mut s = if abis.is_rust() {
312+
~""
313+
} else {
314+
format!("extern {} ", abis.to_str())
315+
};
315316

316317
match purity {
317318
ast::impure_fn => {}
@@ -331,16 +332,16 @@ pub fn ty_to_str(cx: ctxt, typ: t) -> ~str {
331332
_ => { }
332333
}
333334

334-
push_sig_to_str(cx, &mut s, sig);
335+
push_sig_to_str(cx, &mut s, '(', ')', sig);
335336

336337
return s;
337338
}
338-
fn closure_to_str(cx: ctxt, cty: &ty::ClosureTy) -> ~str
339-
{
339+
fn closure_to_str(cx: ctxt, cty: &ty::ClosureTy) -> ~str {
340340
let is_proc =
341341
(cty.sigil, cty.onceness) == (ast::OwnedSigil, ast::Once);
342+
let is_borrowed_closure = cty.sigil == ast::BorrowedSigil;
342343

343-
let mut s = if is_proc {
344+
let mut s = if is_proc || is_borrowed_closure {
344345
~""
345346
} else {
346347
cty.sigil.to_str()
@@ -374,23 +375,42 @@ pub fn ty_to_str(cx: ctxt, typ: t) -> ~str {
374375
}
375376
};
376377

377-
s.push_str("fn");
378+
if !is_borrowed_closure {
379+
s.push_str("fn");
380+
}
378381
}
379382

380-
if !cty.bounds.is_empty() {
381-
s.push_str(":");
382-
}
383-
s.push_str(cty.bounds.repr(cx));
383+
if !is_borrowed_closure {
384+
// Print bounds before `fn` if this is not a borrowed closure.
385+
if !cty.bounds.is_empty() {
386+
s.push_str(":");
387+
s.push_str(cty.bounds.repr(cx));
388+
}
389+
390+
push_sig_to_str(cx, &mut s, '(', ')', &cty.sig);
391+
} else {
392+
// Print bounds after the signature if this is a borrowed closure.
393+
push_sig_to_str(cx, &mut s, '|', '|', &cty.sig);
384394

385-
push_sig_to_str(cx, &mut s, &cty.sig);
395+
if is_borrowed_closure {
396+
if !cty.bounds.is_empty() {
397+
s.push_str(":");
398+
s.push_str(cty.bounds.repr(cx));
399+
}
400+
}
401+
}
386402

387403
return s;
388404
}
389-
fn push_sig_to_str(cx: ctxt, s: &mut ~str, sig: &ty::FnSig) {
390-
s.push_char('(');
405+
fn push_sig_to_str(cx: ctxt,
406+
s: &mut ~str,
407+
bra: char,
408+
ket: char,
409+
sig: &ty::FnSig) {
410+
s.push_char(bra);
391411
let strs = sig.inputs.map(|a| fn_input_to_str(cx, *a));
392412
s.push_str(strs.connect(", "));
393-
s.push_char(')');
413+
s.push_char(ket);
394414
if ty::get(sig.output).sty != ty_nil {
395415
s.push_str(" -> ");
396416
if ty::type_is_bot(sig.output) {

trunk/src/libstd/rand/distributions.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@ fn ziggurat<R:Rng>(rng: &mut R,
207207
symmetric: bool,
208208
X: ziggurat_tables::ZigTable,
209209
F: ziggurat_tables::ZigTable,
210-
F_DIFF: ziggurat_tables::ZigTable,
211210
pdf: &'static fn(f64) -> f64,
212211
zero_case: &'static fn(&mut R, f64) -> f64) -> f64 {
213212
static SCALE: f64 = (1u64 << 53) as f64;
@@ -237,7 +236,7 @@ fn ziggurat<R:Rng>(rng: &mut R,
237236
return zero_case(rng, u);
238237
}
239238
// algebraically equivalent to f1 + DRanU()*(f0 - f1) < 1
240-
if F[i + 1] + F_DIFF[i + 1] * rng.gen() < pdf(x) {
239+
if F[i + 1] + (F[i] - F[i + 1]) * rng.gen() < pdf(x) {
241240
return x;
242241
}
243242
}
@@ -288,7 +287,7 @@ impl Rand for StandardNormal {
288287
rng,
289288
true, // this is symmetric
290289
&ziggurat_tables::ZIG_NORM_X,
291-
&ziggurat_tables::ZIG_NORM_F, &ziggurat_tables::ZIG_NORM_F_DIFF,
290+
&ziggurat_tables::ZIG_NORM_F,
292291
pdf, zero_case))
293292
}
294293
}
@@ -366,7 +365,7 @@ impl Rand for Exp1 {
366365

367366
Exp1(ziggurat(rng, false,
368367
&ziggurat_tables::ZIG_EXP_X,
369-
&ziggurat_tables::ZIG_EXP_F, &ziggurat_tables::ZIG_EXP_F_DIFF,
368+
&ziggurat_tables::ZIG_EXP_F,
370369
pdf, zero_case))
371370
}
372371
}

trunk/src/libstd/rand/reseeding.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl<R: Rng, Rsdr: Reseeder<R>> Rng for ReseedingRng<R, Rsdr> {
7272
fn fill_bytes(&mut self, dest: &mut [u8]) {
7373
self.reseed_if_necessary();
7474
self.bytes_generated += dest.len();
75-
self.fill_bytes(dest)
75+
self.rng.fill_bytes(dest)
7676
}
7777
}
7878

@@ -201,4 +201,24 @@ mod test {
201201
let string2 = r.gen_ascii_str(100);
202202
assert_eq!(string1, string2);
203203
}
204+
205+
static fill_bytes_v_len: uint = 13579;
206+
#[test]
207+
fn test_rng_fill_bytes() {
208+
use rand::task_rng;
209+
let mut v = ~[0u8, .. fill_bytes_v_len];
210+
task_rng().fill_bytes(v);
211+
212+
// Sanity test: if we've gotten here, `fill_bytes` has not infinitely
213+
// recursed.
214+
assert_eq!(v.len(), fill_bytes_v_len);
215+
216+
// To test that `fill_bytes` actually did something, check that the
217+
// average of `v` is not 0.
218+
let mut sum = 0.0;
219+
for &x in v.iter() {
220+
sum += x as f64;
221+
}
222+
assert!(sum / v.len() as f64 != 0.0);
223+
}
204224
}

0 commit comments

Comments
 (0)