Skip to content

Commit 5e0ca78

Browse files
committed
---
yaml --- r: 234779 b: refs/heads/tmp c: 8355d3a h: refs/heads/master i: 234777: 71d9e3a 234775: 0975752 v: v3
1 parent 1291778 commit 5e0ca78

File tree

33 files changed

+1026
-1097
lines changed

33 files changed

+1026
-1097
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
2626
refs/heads/beta: d2e13e822a73e0ea46ae9e21afdd3155fc997f6d
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
28-
refs/heads/tmp: a33e48771e75c82411da2c668366bec59cee718d
28+
refs/heads/tmp: 8355d3a60f103891959ede6112fc8f9ffedb45aa
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: ab792abf1fcc28afbd315426213f6428da25c085
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828

branches/tmp/mk/platform.mk

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -208,14 +208,6 @@ define CFG_MAKE_TOOLCHAIN
208208

209209
ifeq ($$(findstring $(HOST_$(1)),arm aarch64 mips mipsel powerpc),)
210210

211-
# On OpenBSD, we need to pass the path of libstdc++.so to the linker
212-
# (use path of libstdc++.a which is a known name for the same path)
213-
ifeq ($(OSTYPE_$(1)),unknown-openbsd)
214-
RUSTC_FLAGS_$(1)=-L "$$(dir $$(shell $$(CC_$(1)) $$(CFG_GCCISH_CFLAGS_$(1)) \
215-
-print-file-name=lib$(CFG_STDCPP_NAME).a))" \
216-
$(RUSTC_FLAGS_$(1))
217-
endif
218-
219211
# On Bitrig, we need the relocation model to be PIC for everything
220212
ifeq (,$(filter $(OSTYPE_$(1)),bitrig))
221213
LLVM_MC_RELOCATION_MODEL="pic"

branches/tmp/src/doc/complement-project-faq.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Existing languages at this level of abstraction and efficiency are unsatisfactor
2222

2323
# Is any part of this thing production-ready?
2424

25-
No. Feel free to play around, but don't expect completeness or stability yet. Expect incompleteness and breakage.
25+
Yes!
2626

2727
# Is this a completely Mozilla-planned and orchestrated thing?
2828

branches/tmp/src/doc/trpl/error-handling.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ fn find(haystack: &str, needle: char) -> Option<usize> {
154154
}
155155
```
156156

157-
Notice that when this function finds a matching character, it doesn't just
157+
Notice that when this function finds a matching character, it doen't just
158158
return the `offset`. Instead, it returns `Some(offset)`. `Some` is a variant or
159159
a *value constructor* for the `Option` type. You can think of it as a function
160160
with the type `fn<T>(value: T) -> Option<T>`. Correspondingly, `None` is also a
@@ -840,7 +840,7 @@ example, the very last call to `map` multiplies the `Ok(...)` value (which is
840840
an `i32`) by `2`. If an error had occurred before that point, this operation
841841
would have been skipped because of how `map` is defined.
842842

843-
`map_err` is the trick that makes all of this work. `map_err` is just like
843+
`map_err` is the trick the makes all of this work. `map_err` is just like
844844
`map`, except it applies a function to the `Err(...)` value of a `Result`. In
845845
this case, we want to convert all of our errors to one type: `String`. Since
846846
both `io::Error` and `num::ParseIntError` implement `ToString`, we can call the

branches/tmp/src/libcore/num/dec2flt/algorithm.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010

1111
//! The various algorithms from the paper.
1212
13+
use num::flt2dec::strategy::grisu::Fp;
1314
use prelude::v1::*;
1415
use cmp::min;
1516
use cmp::Ordering::{Less, Equal, Greater};
16-
use num::diy_float::Fp;
17-
use num::dec2flt::table;
18-
use num::dec2flt::rawfp::{self, Unpacked, RawFloat, fp_to_float, next_float, prev_float};
19-
use num::dec2flt::num::{self, Big};
17+
use super::table;
18+
use super::rawfp::{self, Unpacked, RawFloat, fp_to_float, next_float, prev_float};
19+
use super::num::{self, Big};
2020

2121
/// Number of significand bits in Fp
2222
const P: u32 = 64;

branches/tmp/src/libcore/num/dec2flt/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@
8686
//! "such that the exponent +/- the number of decimal digits fits into a 64 bit integer".
8787
//! Larger exponents are accepted, but we don't do arithmetic with them, they are immediately
8888
//! turned into {positive,negative} {zero,infinity}.
89+
//!
90+
//! FIXME: this uses several things from core::num::flt2dec, which is nonsense. Those things
91+
//! should be moved into core::num::<something else>.
8992
9093
#![doc(hidden)]
9194
#![unstable(feature = "dec2flt",

branches/tmp/src/libcore/num/dec2flt/num.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414

1515
use prelude::v1::*;
1616
use cmp::Ordering::{self, Less, Equal, Greater};
17+
use num::flt2dec::bignum::Big32x40;
1718

18-
pub use num::bignum::Big32x40 as Big;
19+
pub type Big = Big32x40;
1920

2021
/// Test whether truncating all bits less significant than `ones_place` introduces
2122
/// a relative error less, equal, or greater than 0.5 ULP.

branches/tmp/src/libcore/num/dec2flt/rawfp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ use cmp::Ordering::{Less, Equal, Greater};
3333
use ops::{Mul, Div, Neg};
3434
use fmt::{Debug, LowerExp};
3535
use mem::transmute;
36-
use num::diy_float::Fp;
36+
use num::flt2dec::strategy::grisu::Fp;
3737
use num::FpCategory::{Infinite, Zero, Subnormal, Normal, Nan};
3838
use num::Float;
39-
use num::dec2flt::num::{self, Big};
39+
use super::num::{self, Big};
4040

4141
#[derive(Copy, Clone, Debug)]
4242
pub struct Unpacked {

branches/tmp/src/libcore/num/diy_float.rs

Lines changed: 0 additions & 71 deletions
This file was deleted.

branches/tmp/src/libcore/num/bignum.rs renamed to branches/tmp/src/libcore/num/flt2dec/bignum.rs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@
1919
//! inputs, but we don't do so to avoid the code bloat. Each bignum is still
2020
//! tracked for the actual usages, so it normally doesn't matter.
2121
22-
// This module is only for dec2flt and flt2dec, and only public because of libcoretest.
23-
// It is not intended to ever be stabilized.
24-
#![doc(hidden)]
25-
#![unstable(feature = "core_private_bignum",
26-
reason = "internal routines only exposed for testing",
27-
issue = "0")]
2822
#![macro_use]
2923

3024
use prelude::v1::*;
@@ -200,7 +194,7 @@ macro_rules! define_bignum {
200194
/// Adds `other` to itself and returns its own mutable reference.
201195
pub fn add<'a>(&'a mut self, other: &$name) -> &'a mut $name {
202196
use cmp;
203-
use num::bignum::FullOps;
197+
use num::flt2dec::bignum::FullOps;
204198

205199
let mut sz = cmp::max(self.size, other.size);
206200
let mut carry = false;
@@ -218,7 +212,7 @@ macro_rules! define_bignum {
218212
}
219213

220214
pub fn add_small(&mut self, other: $ty) -> &mut $name {
221-
use num::bignum::FullOps;
215+
use num::flt2dec::bignum::FullOps;
222216

223217
let (mut carry, v) = self.base[0].full_add(other, false);
224218
self.base[0] = v;
@@ -238,7 +232,7 @@ macro_rules! define_bignum {
238232
/// Subtracts `other` from itself and returns its own mutable reference.
239233
pub fn sub<'a>(&'a mut self, other: &$name) -> &'a mut $name {
240234
use cmp;
241-
use num::bignum::FullOps;
235+
use num::flt2dec::bignum::FullOps;
242236

243237
let sz = cmp::max(self.size, other.size);
244238
let mut noborrow = true;
@@ -255,7 +249,7 @@ macro_rules! define_bignum {
255249
/// Multiplies itself by a digit-sized `other` and returns its own
256250
/// mutable reference.
257251
pub fn mul_small(&mut self, other: $ty) -> &mut $name {
258-
use num::bignum::FullOps;
252+
use num::flt2dec::bignum::FullOps;
259253

260254
let mut sz = self.size;
261255
let mut carry = 0;
@@ -316,7 +310,7 @@ macro_rules! define_bignum {
316310
/// Multiplies itself by `5^e` and returns its own mutable reference.
317311
pub fn mul_pow5(&mut self, mut e: usize) -> &mut $name {
318312
use mem;
319-
use num::bignum::SMALL_POW5;
313+
use num::flt2dec::bignum::SMALL_POW5;
320314

321315
// There are exactly n trailing zeros on 2^n, and the only relevant digit sizes
322316
// are consecutive powers of two, so this is well suited index for the table.
@@ -347,7 +341,7 @@ macro_rules! define_bignum {
347341
pub fn mul_digits<'a>(&'a mut self, other: &[$ty]) -> &'a mut $name {
348342
// the internal routine. works best when aa.len() <= bb.len().
349343
fn mul_inner(ret: &mut [$ty; $n], aa: &[$ty], bb: &[$ty]) -> usize {
350-
use num::bignum::FullOps;
344+
use num::flt2dec::bignum::FullOps;
351345

352346
let mut retsz = 0;
353347
for (i, &a) in aa.iter().enumerate() {
@@ -384,7 +378,7 @@ macro_rules! define_bignum {
384378
/// Divides itself by a digit-sized `other` and returns its own
385379
/// mutable reference *and* the remainder.
386380
pub fn div_rem_small(&mut self, other: $ty) -> (&mut $name, $ty) {
387-
use num::bignum::FullOps;
381+
use num::flt2dec::bignum::FullOps;
388382

389383
assert!(other > 0);
390384

branches/tmp/src/libcore/num/flt2dec/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ use slice::bytes;
136136
pub use self::decoder::{decode, DecodableFloat, FullDecoded, Decoded};
137137

138138
pub mod estimator;
139+
pub mod bignum;
139140
pub mod decoder;
140141

141142
/// Digit-generation algorithms.

branches/tmp/src/libcore/num/flt2dec/strategy/dragon.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ use cmp::Ordering;
2121

2222
use num::flt2dec::{Decoded, MAX_SIG_DIGITS, round_up};
2323
use num::flt2dec::estimator::estimate_scaling_factor;
24-
use num::bignum::Digit32 as Digit;
25-
use num::bignum::Big32x40 as Big;
24+
use num::flt2dec::bignum::Digit32 as Digit;
25+
use num::flt2dec::bignum::Big32x40 as Big;
2626

2727
static POW10: [Digit; 10] = [1, 10, 100, 1000, 10000, 100000,
2828
1000000, 10000000, 100000000, 1000000000];

branches/tmp/src/libcore/num/flt2dec/strategy/grisu.rs

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,60 @@ Rust adaptation of Grisu3 algorithm described in [1]. It uses about
1818

1919
use prelude::v1::*;
2020

21-
use num::diy_float::Fp;
2221
use num::flt2dec::{Decoded, MAX_SIG_DIGITS, round_up};
2322

23+
/// A custom 64-bit floating point type, representing `f * 2^e`.
24+
#[derive(Copy, Clone, Debug)]
25+
#[doc(hidden)]
26+
pub struct Fp {
27+
/// The integer mantissa.
28+
pub f: u64,
29+
/// The exponent in base 2.
30+
pub e: i16,
31+
}
32+
33+
impl Fp {
34+
/// Returns a correctly rounded product of itself and `other`.
35+
pub fn mul(&self, other: &Fp) -> Fp {
36+
const MASK: u64 = 0xffffffff;
37+
let a = self.f >> 32;
38+
let b = self.f & MASK;
39+
let c = other.f >> 32;
40+
let d = other.f & MASK;
41+
let ac = a * c;
42+
let bc = b * c;
43+
let ad = a * d;
44+
let bd = b * d;
45+
let tmp = (bd >> 32) + (ad & MASK) + (bc & MASK) + (1 << 31) /* round */;
46+
let f = ac + (ad >> 32) + (bc >> 32) + (tmp >> 32);
47+
let e = self.e + other.e + 64;
48+
Fp { f: f, e: e }
49+
}
50+
51+
/// Normalizes itself so that the resulting mantissa is at least `2^63`.
52+
pub fn normalize(&self) -> Fp {
53+
let mut f = self.f;
54+
let mut e = self.e;
55+
if f >> (64 - 32) == 0 { f <<= 32; e -= 32; }
56+
if f >> (64 - 16) == 0 { f <<= 16; e -= 16; }
57+
if f >> (64 - 8) == 0 { f <<= 8; e -= 8; }
58+
if f >> (64 - 4) == 0 { f <<= 4; e -= 4; }
59+
if f >> (64 - 2) == 0 { f <<= 2; e -= 2; }
60+
if f >> (64 - 1) == 0 { f <<= 1; e -= 1; }
61+
debug_assert!(f >= (1 >> 63));
62+
Fp { f: f, e: e }
63+
}
64+
65+
/// Normalizes itself to have the shared exponent.
66+
/// It can only decrease the exponent (and thus increase the mantissa).
67+
pub fn normalize_to(&self, e: i16) -> Fp {
68+
let edelta = self.e - e;
69+
assert!(edelta >= 0);
70+
let edelta = edelta as usize;
71+
assert_eq!(self.f << edelta >> edelta, self.f);
72+
Fp { f: self.f << edelta, e: e }
73+
}
74+
}
2475

2576
// see the comments in `format_shortest_opt` for the rationale.
2677
#[doc(hidden)] pub const ALPHA: i16 = -60;

branches/tmp/src/libcore/num/mod.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,8 @@ use slice::SliceExt;
4343
pub struct Wrapping<T>(#[stable(feature = "rust1", since = "1.0.0")] pub T);
4444

4545
pub mod wrapping;
46-
47-
// All these modules are technically private and only exposed for libcoretest:
4846
pub mod flt2dec;
4947
pub mod dec2flt;
50-
pub mod bignum;
51-
pub mod diy_float;
5248

5349
/// Types that have a "zero" value.
5450
///

branches/tmp/src/libcoretest/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
#![feature(const_fn)]
1616
#![feature(core)]
1717
#![feature(core_float)]
18-
#![feature(core_private_bignum)]
19-
#![feature(core_private_diy_float)]
2018
#![feature(dec2flt)]
2119
#![feature(decode_utf16)]
2220
#![feature(fixed_size_array)]

branches/tmp/src/libcoretest/num/dec2flt/rawfp.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
// except according to those terms.
1010

1111
use std::f64;
12-
use core::num::diy_float::Fp;
12+
use core::num::flt2dec::strategy::grisu::Fp;
1313
use core::num::dec2flt::rawfp::{fp_to_float, prev_float, next_float, round_normal};
1414

1515
#[test]
1616
fn fp_to_float_half_to_even() {
1717
fn is_normalized(sig: u64) -> bool {
18-
// intentionally written without {min,max}_sig() as a sanity check
19-
sig >> 52 == 1 && sig >> 53 == 0
18+
// intentionally written without {min,max}_sig() as a sanity check
19+
sig >> 52 == 1 && sig >> 53 == 0
2020
}
2121

2222
fn conv(sig: u64) -> u64 {

branches/tmp/src/libcoretest/num/bignum.rs renamed to branches/tmp/src/libcoretest/num/flt2dec/bignum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
use std::prelude::v1::*;
12-
use core::num::bignum::tests::Big8x3 as Big;
12+
use core::num::flt2dec::bignum::tests::Big8x3 as Big;
1313

1414
#[test]
1515
#[should_panic]

branches/tmp/src/libcoretest/num/flt2dec/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use core::num::flt2dec::{to_shortest_str, to_shortest_exp_str,
2323
pub use test::Bencher;
2424

2525
mod estimator;
26+
mod bignum;
2627
mod strategy {
2728
mod dragon;
2829
mod grisu;

branches/tmp/src/libcoretest/num/flt2dec/strategy/dragon.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use std::prelude::v1::*;
1212
use std::{i16, f64};
1313
use super::super::*;
1414
use core::num::flt2dec::*;
15-
use core::num::bignum::Big32x40 as Big;
15+
use core::num::flt2dec::bignum::Big32x40 as Big;
1616
use core::num::flt2dec::strategy::dragon::*;
1717

1818
#[test]

0 commit comments

Comments
 (0)