Skip to content

Commit 856cb41

Browse files
committed
---
yaml --- r: 89217 b: refs/heads/snap-stage3 c: 0daaeab h: refs/heads/master i: 89215: a747265 v: v3
1 parent 6c3e78c commit 856cb41

Some content is hidden

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

91 files changed

+931
-1619
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: deeca5d586bfaa4aa60246f671a8d611d38f6248
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: b3b49d9873afaa600ba9dc00566dba73c3eae195
4+
refs/heads/snap-stage3: 0daaeab244a583b6bb5b88c41ad0fdd51388619d
55
refs/heads/try: b160761e35efcd1207112b3b782c06633cf441a8
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/doc/rust.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3806,6 +3806,25 @@ As a convenience, the logging spec can also be set to a special pseudo-crate,
38063806
`::help`. In this case, when the application starts, the runtime will
38073807
simply output a list of loaded modules containing log expressions, then exit.
38083808

3809+
The Rust runtime itself generates logging information. The runtime's logs are
3810+
generated for a number of artificial modules in the `::rt` pseudo-crate,
3811+
and can be enabled just like the logs for any standard module. The full list
3812+
of runtime logging modules follows.
3813+
3814+
* `::rt::mem` Memory management
3815+
* `::rt::comm` Messaging and task communication
3816+
* `::rt::task` Task management
3817+
* `::rt::dom` Task scheduling
3818+
* `::rt::trace` Unused
3819+
* `::rt::cache` Type descriptor cache
3820+
* `::rt::upcall` Compiler-generated runtime calls
3821+
* `::rt::timer` The scheduler timer
3822+
* `::rt::gc` Garbage collection
3823+
* `::rt::stdlib` Functions used directly by the standard library
3824+
* `::rt::kern` The runtime kernel
3825+
* `::rt::backtrace` Log a backtrace on task failure
3826+
* `::rt::callback` Unused
3827+
38093828
#### Logging Expressions
38103829

38113830
Rust provides several macros to log information. Here's a simple Rust program

branches/snap-stage3/src/driver/driver.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,7 @@ extern mod this = "rustdoc";
1919
#[cfg(rustc)]
2020
extern mod this = "rustc";
2121

22+
#[cfg(rustdoc_ng)]
23+
extern mod this = "rustdoc_ng";
24+
2225
fn main() { this::main() }

branches/snap-stage3/src/etc/emacs/rust-mode.el

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@
5454
;; We don't want to indent out to the open bracket if the
5555
;; open bracket ends the line
5656
(when (not (looking-at "[[:blank:]]*\\(?://.*\\)?$"))
57-
(when (looking-at "[[:space:]]")
58-
(forward-word 1)
59-
(backward-word 1))
57+
(when (looking-at "[[:space:]]") (forward-to-word 1))
6058
(current-column))))
6159

6260
(defun rust-mode-indent-line ()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
//!
3232
//! ~~~{.rust}
3333
//! extern mod extra;
34-
//! use extra::getopts::{optopt,optflag,getopts,Opt};
34+
//! use extra::getopts::*;
3535
//! use std::os;
3636
//!
3737
//! fn do_work(inp: &str, out: Option<~str>) {

branches/snap-stage3/src/libextra/num/rational.rs

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use std::cmp;
1515
use std::from_str::FromStr;
1616
use std::num::{Zero,One,ToStrRadix,FromStrRadix,Round};
17-
use super::bigint::{BigInt, BigUint, Sign, Plus, Minus};
17+
use super::bigint::BigInt;
1818

1919
/// Represents the ratio between 2 numbers.
2020
#[deriving(Clone)]
@@ -107,27 +107,6 @@ impl<T: Clone + Integer + Ord>
107107
}
108108
}
109109

110-
impl Ratio<BigInt> {
111-
/// Converts a float into a rational number
112-
pub fn from_float<T: Float>(f: T) -> Option<BigRational> {
113-
if !f.is_finite() {
114-
return None;
115-
}
116-
let (mantissa, exponent, sign) = f.integer_decode();
117-
let bigint_sign: Sign = if sign == 1 { Plus } else { Minus };
118-
if exponent < 0 {
119-
let one: BigInt = One::one();
120-
let denom: BigInt = one << ((-exponent) as uint);
121-
let numer: BigUint = FromPrimitive::from_u64(mantissa).unwrap();
122-
Some(Ratio::new(BigInt::from_biguint(bigint_sign, numer), denom))
123-
} else {
124-
let mut numer: BigUint = FromPrimitive::from_u64(mantissa).unwrap();
125-
numer = numer << (exponent as uint);
126-
Some(Ratio::from_integer(BigInt::from_biguint(bigint_sign, numer)))
127-
}
128-
}
129-
}
130-
131110
/* Comparisons */
132111

133112
// comparing a/b and c/d is the same as comparing a*d and b*c, so we
@@ -642,42 +621,4 @@ mod test {
642621
test(s);
643622
}
644623
}
645-
646-
#[test]
647-
fn test_from_float() {
648-
fn test<T: Float>(given: T, (numer, denom): (&str, &str)) {
649-
let ratio: BigRational = Ratio::from_float(given).unwrap();
650-
assert_eq!(ratio, Ratio::new(
651-
FromStr::from_str(numer).unwrap(),
652-
FromStr::from_str(denom).unwrap()));
653-
}
654-
655-
// f32
656-
test(3.14159265359f32, ("13176795", "4194304"));
657-
test(2f32.pow(&100.), ("1267650600228229401496703205376", "1"));
658-
test(-2f32.pow(&100.), ("-1267650600228229401496703205376", "1"));
659-
test(1.0 / 2f32.pow(&100.), ("1", "1267650600228229401496703205376"));
660-
test(684729.48391f32, ("1369459", "2"));
661-
test(-8573.5918555f32, ("-4389679", "512"));
662-
663-
// f64
664-
test(3.14159265359f64, ("3537118876014453", "1125899906842624"));
665-
test(2f64.pow(&100.), ("1267650600228229401496703205376", "1"));
666-
test(-2f64.pow(&100.), ("-1267650600228229401496703205376", "1"));
667-
test(684729.48391f64, ("367611342500051", "536870912"));
668-
test(-8573.5918555, ("-4713381968463931", "549755813888"));
669-
test(1.0 / 2f64.pow(&100.), ("1", "1267650600228229401496703205376"));
670-
}
671-
672-
#[test]
673-
fn test_from_float_fail() {
674-
use std::{f32, f64};
675-
676-
assert_eq!(Ratio::from_float(f32::NAN), None);
677-
assert_eq!(Ratio::from_float(f32::INFINITY), None);
678-
assert_eq!(Ratio::from_float(f32::NEG_INFINITY), None);
679-
assert_eq!(Ratio::from_float(f64::NAN), None);
680-
assert_eq!(Ratio::from_float(f64::INFINITY), None);
681-
assert_eq!(Ratio::from_float(f64::NEG_INFINITY), None);
682-
}
683624
}

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

Lines changed: 10 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,17 @@
1212

1313
use std::io::Reader;
1414
use std::io::mem::BufReader;
15-
use std::libc;
1615
use std::num;
1716
use std::str;
1817

1918
static NSEC_PER_SEC: i32 = 1_000_000_000_i32;
2019

21-
mod rustrt {
20+
pub mod rustrt {
2221
use super::Tm;
2322

2423
extern {
24+
pub fn rust_get_time(sec: &mut i64, nsec: &mut i32);
25+
pub fn rust_precise_time_ns(ns: &mut u64);
2526
pub fn rust_tzset();
2627
pub fn rust_gmtime(sec: i64, nsec: i32, result: &mut Tm);
2728
pub fn rust_localtime(sec: i64, nsec: i32, result: &mut Tm);
@@ -30,31 +31,6 @@ mod rustrt {
3031
}
3132
}
3233

33-
#[cfg(unix, not(target_os = "macos"))]
34-
mod imp {
35-
use std::libc::{c_int, timespec};
36-
37-
// Apparently android provides this in some other library?
38-
#[cfg(not(target_os = "android"))]
39-
#[link(name = "rt")]
40-
extern {}
41-
42-
extern {
43-
pub fn clock_gettime(clk_id: c_int, tp: *mut timespec) -> c_int;
44-
}
45-
46-
}
47-
#[cfg(target_os = "macos")]
48-
mod imp {
49-
use std::libc::{timeval, timezone, c_int, mach_timebase_info};
50-
51-
extern {
52-
pub fn gettimeofday(tp: *mut timeval, tzp: *mut timezone) -> c_int;
53-
pub fn mach_absolute_time() -> u64;
54-
pub fn mach_timebase_info(info: *mut mach_timebase_info) -> c_int;
55-
}
56-
}
57-
5834
/// A record specifying a time value in seconds and nanoseconds.
5935
6036

@@ -88,45 +64,11 @@ impl Ord for Timespec {
8864
*/
8965
pub fn get_time() -> Timespec {
9066
unsafe {
91-
let (sec, nsec) = os_get_time();
67+
let mut sec = 0i64;
68+
let mut nsec = 0i32;
69+
rustrt::rust_get_time(&mut sec, &mut nsec);
9270
return Timespec::new(sec, nsec);
9371
}
94-
95-
#[cfg(windows)]
96-
unsafe fn os_get_time() -> (i64, i32) {
97-
static NANOSECONDS_FROM_1601_TO_1970: u64 = 11644473600000000;
98-
99-
let mut time = libc::FILETIME {
100-
dwLowDateTime: 0,
101-
dwHighDateTime: 0,
102-
};
103-
libc::GetSystemTimeAsFileTime(&mut time);
104-
105-
// A FILETIME contains a 64-bit value representing the number of
106-
// hectonanosecond (100-nanosecond) intervals since 1601-01-01T00:00:00Z.
107-
// http://support.microsoft.com/kb/167296/en-us
108-
let ns_since_1601 = ((time.dwHighDateTime as u64 << 32) |
109-
(time.dwLowDateTime as u64 << 0)) / 10;
110-
let ns_since_1970 = ns_since_1601 - NANOSECONDS_FROM_1601_TO_1970;
111-
112-
((ns_since_1970 / 1000000) as i64,
113-
((ns_since_1970 % 1000000) * 1000) as i32)
114-
}
115-
116-
#[cfg(target_os = "macos")]
117-
unsafe fn os_get_time() -> (i64, i32) {
118-
use std::ptr;
119-
let mut tv = libc::timeval { tv_sec: 0, tv_usec: 0 };
120-
imp::gettimeofday(&mut tv, ptr::mut_null());
121-
(tv.tv_sec as i64, tv.tv_usec * 1000)
122-
}
123-
124-
#[cfg(not(target_os = "macos"), not(windows))]
125-
unsafe fn os_get_time() -> (i64, i32) {
126-
let mut tv = libc::timespec { tv_sec: 0, tv_nsec: 0 };
127-
imp::clock_gettime(libc::CLOCK_REALTIME, &mut tv);
128-
(tv.tv_sec as i64, tv.tv_nsec as i32)
129-
}
13072
}
13173

13274

@@ -135,38 +77,10 @@ pub fn get_time() -> Timespec {
13577
* in nanoseconds since an unspecified epoch.
13678
*/
13779
pub fn precise_time_ns() -> u64 {
138-
return os_precise_time_ns();
139-
140-
#[cfg(windows)]
141-
fn os_precise_time_ns() -> u64 {
142-
let mut ticks_per_s = 0;
143-
assert_eq!(unsafe {
144-
libc::QueryPerformanceFrequency(&mut ticks_per_s)
145-
}, 1);
146-
let ticks_per_s = if ticks_per_s == 0 {1} else {ticks_per_s};
147-
let mut ticks = 0;
148-
assert_eq!(unsafe {
149-
libc::QueryPerformanceCounter(&mut ticks)
150-
}, 1);
151-
152-
return (ticks as u64 * 1000000000) / (ticks_per_s as u64);
153-
}
154-
155-
#[cfg(target_os = "macos")]
156-
fn os_precise_time_ns() -> u64 {
157-
let time = unsafe { imp::mach_absolute_time() };
158-
let mut info = libc::mach_timebase_info { numer: 0, denom: 0 };
159-
unsafe { imp::mach_timebase_info(&mut info); }
160-
return time * ((info.numer / info.denom) as u64);
161-
}
162-
163-
#[cfg(not(windows), not(target_os = "macos"))]
164-
fn os_precise_time_ns() -> u64 {
165-
let mut ts = libc::timespec { tv_sec: 0, tv_nsec: 0 };
166-
unsafe {
167-
imp::clock_gettime(libc::CLOCK_MONOTONIC, &mut ts);
168-
}
169-
return (ts.tv_sec as u64) * 1000000000 + (ts.tv_nsec as u64)
80+
unsafe {
81+
let mut ns = 0u64;
82+
rustrt::rust_precise_time_ns(&mut ns);
83+
ns
17084
}
17185
}
17286

0 commit comments

Comments
 (0)