Skip to content

Commit b860f02

Browse files
committed
---
yaml --- r: 89234 b: refs/heads/snap-stage3 c: 3249de8 h: refs/heads/master v: v3
1 parent e0eabf8 commit b860f02

Some content is hidden

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

94 files changed

+1942
-688
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: 645bb327dbd1fab65a87d2f0bd6ca8c3ec620422
4+
refs/heads/snap-stage3: 3249de8c4f5d4c7cf34a4bda5e98f047b6b72263
55
refs/heads/try: b160761e35efcd1207112b3b782c06633cf441a8
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/RELEASES.txt

Lines changed: 149 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,156 @@
1-
Version 0.9 (XXX 2013)
1+
Version 0.9 (January 2014)
22
--------------------------
33

4-
* ~XXX changes, numerous bugfixes
4+
* ~1600 changes, numerous bugfixes
5+
6+
* Language
7+
* The `float` type has been removed. Use `f32` or `f64` instead.
8+
* A new facility for enabling experimental features (feature gating) has
9+
been added, using the crate-level `#[feature(foo)]` attribute.
10+
* Managed boxes (@) are now behind a feature gate
11+
(`#[feature(managed_boxes)]`) in preperation for future removal. Use the
12+
standard library's `Gc` or `Rc` types instead.
13+
* `@mut` has been removed. Use `std::cell::{Cell, RefCell}` instead.
14+
* Jumping back to the top of a loop is now done with `continue` instead of
15+
`loop`.
16+
* Strings can no longer be mutated through index assignment.
17+
* Raw strings can be created via the basic `r"foo"` syntax or with matched
18+
hash delimiters, as in `r###"foo"###`.
19+
* `~fn` is now written `proc (args) -> retval { ... }` and may only be
20+
called once.
21+
* The `&fn` type is now written `|args| -> ret` to match the literal form.
22+
* `@fn`s have been removed.
23+
* `do` only works with procs in order to make it obvious what the cost
24+
of `do` is.
25+
* The `#[link(...)]` attribute has been replaced with
26+
`#[crate_id = "name#vers"]`.
27+
* Empty `impl`s must be terminated with empty braces and may not be
28+
terminated with a semicolon.
29+
* Keywords are no longer allowed as lifetime names; the `self` lifetime
30+
no longer has any special meaning.
31+
* The old `fmt!` string formatting macro has been removed.
32+
* `printf!` and `printfln!` (old-style formatting) removed in favor of
33+
`print!` and `println!`.
34+
* `mut` works in patterns now, as in `let (mut x, y) = (1, 2);`.
35+
* New reserved keywords: `alignof`, `offsetof`, `sizeof`.
36+
* Macros can have attributes.
37+
* Macros can expand to items with attributes.
38+
* Macros can expand to multiple items.
39+
* The `asm!` macro is feature-gated (`#[feature(asm)]`).
40+
* Comments may be nested.
41+
* Values automatically coerce to trait objects they implement, without
42+
an explicit `as`.
43+
* Enum discriminants are no longer an entire word but as small as needed to
44+
contain all the variants. The `repr` attribute can be used to override
45+
the discriminant size, as in `#[repr(int)]` for integer-sized, and
46+
`#[repr(C)]` to match C enums.
47+
* Non-string literals are not allowed in attributes (they never worked).
48+
* The FFI now supports variadic functions.
49+
* Octal numeric literals, as in `0o7777`.
50+
* The `concat!` syntax extension performs compile-time string concatenation.
51+
* The `#[fixed_stack_segment]` and `#[rust_stack]` attributes have been
52+
removed as Rust no longer uses segmented stacks.
53+
* Non-ascii identifiers are feature-gated (`#[feature(non_ascii_idents)]`).
54+
* Ignoring all fields of an enum variant or tuple-struct is done with `..`,
55+
not `*`; ignoring remaining fields of a struct is also done with `..`,
56+
not `_`; ignoring a slice of a vector is done with `..`, not `.._`.
57+
* `rustc` supports the "win64" calling convention via `extern "win64"`.
58+
* `rustc` supports the "system" calling convention, which defaults to the
59+
preferred convention for the target platform, "stdcall" on 32-bit Windows,
60+
"C" elsewhere.
61+
* The `type_overflow` lint (default: warn) checks literals for overflow.
62+
* The `unsafe_block` lint (default: allow) checks for usage of `unsafe`.
63+
* The `attribute_usage` lint (default: warn) warns about unknown
64+
attributes.
65+
* The `unknown_features` lint (default: warn) warns about unknown
66+
feature gates.
67+
* The `dead_code` lint (default: warn) checks for dead code.
68+
* Rust libraries can be linked statically to one another
69+
* `#[link_args]` is behind the `link_args` feature gate.
70+
* Native libraries are now linked with `#[link(name = "foo")]`
71+
* Native libraries can be statically linked to a rust crate
72+
(`#[link(name = "foo", kind = "static")]`).
73+
* Native OS X frameworks are now officially supported
74+
(`#[link(name = "foo", kind = "framework")]`).
75+
* The `#[thread_local]` attribute creates thread-local (not task-local)
76+
variables. Currently behind the `thread_local` feature gate.
77+
* The `return` keyword may be used in closures.
78+
* Types that can be copied via a memcpy implement the `Pod` kind.
79+
80+
* Libraries
81+
* std: The `option` and `result` API's have been overhauled to make them
82+
simpler, more consistent, and more composable.
83+
* std: The entire `std::io` module has been replaced with one that is
84+
more comprehensive and that properly interfaces with the underlying
85+
scheduler. File, TCP, UDP, Unix sockets, pipes, and timers are all
86+
implemented.
87+
* std: `io::util` contains a number of useful implementations of
88+
`Reader` and `Writer`, including `NullReader`, `NullWriter`,
89+
`ZeroReader`, `TeeReader`.
90+
* std: The reference counted pointer type `extra::rc` moved into std.
91+
* std: The `Gc` type in the `gc` module will replace `@` (it is currently
92+
just a wrapper around it).
93+
* std: `fmt::Default` can be implemented for any type to provide default
94+
formatting to the `format!` macro, as in `format!("{}", myfoo)`.
95+
* std: The `rand` API continues to be tweaked.
96+
* std: Functions dealing with type size and alignment have moved from the
97+
`sys` module to the `mem` module.
98+
* std: The `path` module was written and API changed.
99+
* std: `str::from_utf8` has been changed to cast instead of allocate.
100+
* std: `starts_with` and `ends_with` methods added to vectors via the
101+
`ImmutableEqVector` trait, which is in the prelude.
102+
* std: Vectors can be indexed with the `get_opt` method, which returns `None`
103+
if the index is out of bounds.
104+
* std: Task failure no longer propagates between tasks, as the model was
105+
complex, expensive, and incompatible with thread-based tasks.
106+
* std: The `Any` type can be used for dynamic typing.
107+
* std: `~Any` can be passed to the `fail!` macro and retrieved via
108+
`task::try`.
109+
* std: Methods that produce iterators generally do not have an `_iter`
110+
suffix now.
111+
* std: `cell::Cell` and `cell::RefCell` can be used to introduce mutability
112+
roots (mutable fields, etc.). Use instead of e.g. `@mut`.
113+
* std: `util::ignore` renamed to `prelude::drop`.
114+
* std: Slices have `sort` and `sort_by` methods via the `MutableVector`
115+
trait.
116+
* std: `vec::raw` has seen a lot of cleanup and API changes.
117+
* std: The standard library no longer includes any C++ code, and very
118+
minimal C, eliminating the dependency on libstdc++.
119+
* std: Runtime scheduling and I/O functionality has been factored out into
120+
extensible interfaces and is now implemented by two different crates:
121+
libnative, for native threading and I/O; and libgreen, for green threading
122+
and I/O. This paves the way for using the standard library in more limited
123+
embeded environments.
124+
* std: The `comm` module has been rewritten to be much faster, have a
125+
simpler, more consistent API, and to work for both native and green
126+
threading.
127+
* std: All libuv dependencies have been moved into the rustuv crate.
128+
* native: New implementations of runtime scheduling on top of OS threads.
129+
* native: New native implementations of TCP, UDP, file I/O, process spawning,
130+
and other I/O.
131+
* green: The green thread scheduler and message passing types are almost
132+
entirely lock-free.
133+
* extra: The `flatpipes` module had bitrotted and was removed.
134+
* extra: All crypto functions have been removed and Rust now has a policy of
135+
not reimplementing crypto in the standard library. In the future crypto
136+
will be provided by external crates with bindings to established libraries.
137+
* extra: `c_vec` has been modernized.
138+
* extra: The `sort` module has been removed. Use the `sort` method on
139+
mutable slices.
5140

6141
* Tooling
7-
* The `rust` and `rusti` commands have been removed, due to lack of maintenance.
142+
* The `rust` and `rusti` commands have been removed, due to lack of
143+
maintenance.
144+
* `rustdoc` was completely rewritten.
145+
* `rustdoc` can test code examples in documentation.
146+
* `rustpkg` can test packages with the argument, 'test'.
147+
* `rustpkg` supports arbitrary dependencies, including C libraries.
148+
* `rustc`'s support for generating debug info is improved again.
149+
* `rustc` has better error reporting for unbalanced delimiters.
150+
* `rustc`'s JIT support was removed due to bitrot.
151+
* Executables and static libraries can be built with LTO (-Z lto)
152+
* `rustc` adds a `--dep-info` flag for communicating dependencies to
153+
build tools.
8154

9155
Version 0.8 (September 2013)
10156
--------------------------

branches/snap-stage3/doc/rust.md

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3806,25 +3806,6 @@ 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-
38283809
#### Logging Expressions
38293810

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

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

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

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

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@
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:]]") (forward-to-word 1))
57+
(when (looking-at "[[:space:]]")
58+
(forward-word 1)
59+
(backward-word 1))
5860
(current-column))))
5961

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

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

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,9 @@ pub mod reader {
122122
fail!("vint too big");
123123
}
124124

125-
#[cfg(target_arch = "x86")]
126-
#[cfg(target_arch = "x86_64")]
127125
pub fn vuint_at(data: &[u8], start: uint) -> Res {
128126
use std::ptr::offset;
129-
use std::unstable::intrinsics::bswap32;
127+
use std::unstable::intrinsics::from_be32;
130128

131129
if data.len() - start < 4 {
132130
return vuint_at_slow(data, start);
@@ -136,7 +134,7 @@ pub mod reader {
136134
let (ptr, _): (*u8, uint) = transmute(data);
137135
let ptr = offset(ptr, start as int);
138136
let ptr: *i32 = transmute(ptr);
139-
let val = bswap32(*ptr);
137+
let val = from_be32(*ptr);
140138
let val: u32 = transmute(val);
141139
if (val & 0x80000000) != 0 {
142140
Res {
@@ -162,11 +160,6 @@ pub mod reader {
162160
}
163161
}
164162

165-
#[cfg(not(target_arch = "x86"), not(target_arch = "x86_64"))]
166-
pub fn vuint_at(data: &[u8], start: uint) -> Res {
167-
vuint_at_slow(data, start)
168-
}
169-
170163
pub fn Doc<'a>(data: &'a [u8]) -> Doc<'a> {
171164
Doc { data: data, start: 0u, end: data.len() }
172165
}

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

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

1313
use std::io::Reader;
1414
use std::io::mem::BufReader;
15+
use std::libc;
1516
use std::num;
1617
use std::str;
1718

1819
static NSEC_PER_SEC: i32 = 1_000_000_000_i32;
1920

20-
pub mod rustrt {
21+
mod rustrt {
2122
use super::Tm;
2223

2324
extern {
24-
pub fn rust_get_time(sec: &mut i64, nsec: &mut i32);
25-
pub fn rust_precise_time_ns(ns: &mut u64);
2625
pub fn rust_tzset();
2726
pub fn rust_gmtime(sec: i64, nsec: i32, result: &mut Tm);
2827
pub fn rust_localtime(sec: i64, nsec: i32, result: &mut Tm);
@@ -31,6 +30,31 @@ pub mod rustrt {
3130
}
3231
}
3332

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+
3458
/// A record specifying a time value in seconds and nanoseconds.
3559
3660

@@ -64,11 +88,45 @@ impl Ord for Timespec {
6488
*/
6589
pub fn get_time() -> Timespec {
6690
unsafe {
67-
let mut sec = 0i64;
68-
let mut nsec = 0i32;
69-
rustrt::rust_get_time(&mut sec, &mut nsec);
91+
let (sec, nsec) = os_get_time();
7092
return Timespec::new(sec, nsec);
7193
}
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+
}
72130
}
73131

74132

@@ -77,10 +135,38 @@ pub fn get_time() -> Timespec {
77135
* in nanoseconds since an unspecified epoch.
78136
*/
79137
pub fn precise_time_ns() -> u64 {
80-
unsafe {
81-
let mut ns = 0u64;
82-
rustrt::rust_precise_time_ns(&mut ns);
83-
ns
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)
84170
}
85171
}
86172

0 commit comments

Comments
 (0)