auto merge of #13532 : alexcrichton/rust/rollup, r=alexcrichton

This commit is contained in:
bors 2014-04-15 23:36:58 -07:00
commit 349d66af94
45 changed files with 546 additions and 413 deletions

View File

@ -182,8 +182,7 @@ rustdoc
See <\fBhttps://github.com/mozilla/rust/issues\fR> for issues.
.SH "AUTHOR"
See \fBAUTHORS.txt\fR in the rust source distribution. Graydon Hoare
<\fIgraydon@mozilla.com\fR> is the project leader.
See \fBAUTHORS.txt\fR in the Rust source distribution.
.SH "COPYRIGHT"
This work is dual-licensed under Apache 2.0 and MIT terms. See \fBCOPYRIGHT\fR

View File

@ -90,8 +90,7 @@ rustc
See <\fBhttps://github.com/mozilla/rust/issues\fR> for issues.
.SH "AUTHOR"
See \fBAUTHORS.txt\fR in the rust source distribution. Graydon Hoare
<\fIgraydon@mozilla.com\fR> is the project leader.
See \fBAUTHORS.txt\fR in the Rust source distribution.
.SH "COPYRIGHT"
This work is dual-licensed under Apache 2.0 and MIT terms. See \fBCOPYRIGHT\fR

View File

@ -118,7 +118,7 @@ PKG_EXE = dist/$(PKG_NAME)-install.exe
%.ico: $(S)src/etc/pkg/%.ico
cp $< $@
$(PKG_EXE): rust.iss modpath.iss LICENSE.txt rust-logo.ico \
$(PKG_EXE): rust.iss modpath.iss upgrade.iss LICENSE.txt rust-logo.ico \
$(CSREQ3_T_$(CFG_BUILD)_H_$(CFG_BUILD)) \
dist-prepare-win
$(CFG_PYTHON) $(S)src/etc/copy-runtime-deps.py tmp/dist/win/bin

View File

@ -20,13 +20,7 @@
# PREPARE_TARGETS - the target triples, space separated
# PREPARE_DEST_DIR - the directory to put the image
# On windows we install from stage3, but on unix only stage2
ifdef CFG_WINDOWSY_$(CFG_BUILD)
PREPARE_STAGE=3
else
PREPARE_STAGE=2
endif
DEFAULT_PREPARE_DIR_CMD = umask 022 && mkdir -p
DEFAULT_PREPARE_BIN_CMD = install -m755

View File

@ -27,7 +27,7 @@ Some examples that demonstrate different aspects of the language:
You may also be interested in browsing [GitHub's Rust][github-rust] page.
[github-rust]: https://github.com/languages/Rust
[github-rust]: https://github.com/trending?l=rust
## Does it run on Windows?
@ -141,8 +141,14 @@ export RUST_LOG=hello
./hello
```
**Long answer** RUST_LOG takes a 'logging spec' that consists of a comma-separated list of paths, where a path consists of the crate name and sequence of module names, each separated by double-colons. For standalone .rs files the crate is implicitly named after the source file, so in the above example we were setting RUST_LOG to the name of the hello crate. Multiple paths can be combined to control the exact logging you want to see. For example, when debugging linking in the compiler you might set `RUST_LOG=rustc::metadata::creader,rustc::util::filesearch,rustc::back::rpath`
If you aren't sure which paths you need, try setting RUST_LOG to `::help` and running your program. This will print a list of paths available for logging. For a full description see [the language reference][1].
**Long answer** RUST_LOG takes a 'logging spec' that consists of a
comma-separated list of paths, where a path consists of the crate name and
sequence of module names, each separated by double-colons. For standalone .rs
files the crate is implicitly named after the source file, so in the above
example we were setting RUST_LOG to the name of the hello crate. Multiple paths
can be combined to control the exact logging you want to see. For example, when
debugging linking in the compiler you might set
`RUST_LOG=rustc::metadata::creader,rustc::util::filesearch,rustc::back::rpath`
For a full description see [the language reference][1].
[1]:http://doc.rust-lang.org/doc/master/rust.html#logging-system

View File

@ -4056,10 +4056,6 @@ crate name the crate is given a default name that matches the source file,
with the extension removed. In that case, to turn on logging for a program
compiled from, e.g. `helloworld.rs`, `RUST_LOG` should be set to `helloworld`.
As a convenience, the logging spec can also be set to a special pseudo-crate,
`::help`. In this case, when the application starts, the runtime will
simply output a list of loaded modules containing log expressions, then exit.
#### Logging Expressions
Rust provides several macros to log information. Here's a simple Rust program

View File

@ -164,7 +164,7 @@ begin
end;
procedure CurStepChanged(CurStep: TSetupStep);
procedure ModPathCurStepChanged(CurStep: TSetupStep);
var
taskname: String;
begin

View File

@ -49,4 +49,15 @@ begin
setArrayLength(Result, 1)
Result[0] := ExpandConstant('{app}\bin');
end;
#include "modpath.iss"
#include "modpath.iss"
#include "upgrade.iss"
// Both modpath.iss and upgrade.iss want to overload CurStepChanged.
// This version does the overload then delegates to each.
procedure CurStepChanged(CurStep: TSetupStep);
begin
UpgradeCurStepChanged(CurStep);
ModPathCurStepChanged(CurStep);
end;

61
src/etc/pkg/upgrade.iss Normal file
View File

@ -0,0 +1,61 @@
// The following code taken from https://stackoverflow.com/questions/2000296/innosetup-how-to-automatically-uninstall-previous-installed-version
// It performs upgrades by running the uninstaller before the install
/////////////////////////////////////////////////////////////////////
function GetUninstallString(): String;
var
sUnInstPath: String;
sUnInstallString: String;
begin
sUnInstPath := ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\Rust_is1');
sUnInstallString := '';
if not RegQueryStringValue(HKLM, sUnInstPath, 'UninstallString', sUnInstallString) then
RegQueryStringValue(HKCU, sUnInstPath, 'UninstallString', sUnInstallString);
Result := sUnInstallString;
end;
/////////////////////////////////////////////////////////////////////
function IsUpgrade(): Boolean;
begin
Result := (GetUninstallString() <> '');
end;
/////////////////////////////////////////////////////////////////////
function UnInstallOldVersion(): Integer;
var
sUnInstallString: String;
iResultCode: Integer;
begin
// Return Values:
// 1 - uninstall string is empty
// 2 - error executing the UnInstallString
// 3 - successfully executed the UnInstallString
// default return value
Result := 0;
// get the uninstall string of the old app
sUnInstallString := GetUninstallString();
if sUnInstallString <> '' then begin
sUnInstallString := RemoveQuotes(sUnInstallString);
if Exec(sUnInstallString, '/SILENT /NORESTART /SUPPRESSMSGBOXES','', SW_HIDE, ewWaitUntilTerminated, iResultCode) then
Result := 3
else
Result := 2;
end else
Result := 1;
end;
/////////////////////////////////////////////////////////////////////
procedure UpgradeCurStepChanged(CurStep: TSetupStep);
begin
if (CurStep=ssInstall) then
begin
if (IsUpgrade()) then
begin
UnInstallOldVersion();
end;
end;
end;

View File

@ -1424,43 +1424,28 @@ impl<T: TotalEq + Hash<S>, S, H: Hasher<S>> Eq for HashSet<T, H> {
}
impl<T: TotalEq + Hash<S>, S, H: Hasher<S>> Container for HashSet<T, H> {
/// Return the number of elements in the set
fn len(&self) -> uint { self.map.len() }
}
impl<T: TotalEq + Hash<S>, S, H: Hasher<S>> Mutable for HashSet<T, H> {
/// Clear the set, removing all values.
fn clear(&mut self) { self.map.clear() }
}
impl<T: TotalEq + Hash<S>, S, H: Hasher<S>> Set<T> for HashSet<T, H> {
/// Return true if the set contains a value
fn contains(&self, value: &T) -> bool { self.map.search(value).is_some() }
/// Return true if the set has no elements in common with `other`.
/// This is equivalent to checking for an empty intersection.
fn is_disjoint(&self, other: &HashSet<T, H>) -> bool {
self.iter().all(|v| !other.contains(v))
}
/// Return true if the set is a subset of another
fn is_subset(&self, other: &HashSet<T, H>) -> bool {
self.iter().all(|v| other.contains(v))
}
/// Return true if the set is a superset of another
fn is_superset(&self, other: &HashSet<T, H>) -> bool {
other.is_subset(self)
}
}
impl<T: TotalEq + Hash<S>, S, H: Hasher<S>> MutableSet<T> for HashSet<T, H> {
/// Add a value to the set. Return true if the value was not already
/// present in the set.
fn insert(&mut self, value: T) -> bool { self.map.insert(value, ()) }
/// Remove a value from the set. Return true if the value was
/// present in the set.
fn remove(&mut self, value: &T) -> bool { self.map.remove(value) }
}

View File

@ -64,24 +64,13 @@ fn lt<K: Ord + TotalOrd, V: Ord>(a: &TreeMap<K, V>,
impl<K: Ord + TotalOrd, V: Ord> Ord for TreeMap<K, V> {
#[inline]
fn lt(&self, other: &TreeMap<K, V>) -> bool { lt(self, other) }
#[inline]
fn le(&self, other: &TreeMap<K, V>) -> bool { !lt(other, self) }
#[inline]
fn ge(&self, other: &TreeMap<K, V>) -> bool { !lt(self, other) }
#[inline]
fn gt(&self, other: &TreeMap<K, V>) -> bool { lt(other, self) }
}
impl<K: TotalOrd, V> Container for TreeMap<K, V> {
/// Return the number of elements in the map
fn len(&self) -> uint { self.length }
/// Return true if the map contains no elements
fn is_empty(&self) -> bool { self.root.is_none() }
}
impl<K: TotalOrd, V> Mutable for TreeMap<K, V> {
/// Clear the map, removing all key-value pairs.
fn clear(&mut self) {
self.root = None;
self.length = 0
@ -89,7 +78,6 @@ impl<K: TotalOrd, V> Mutable for TreeMap<K, V> {
}
impl<K: TotalOrd, V> Map<K, V> for TreeMap<K, V> {
/// Return a reference to the value corresponding to the key
fn find<'a>(&'a self, key: &K) -> Option<&'a V> {
let mut current: &'a Option<~TreeNode<K, V>> = &self.root;
loop {
@ -108,22 +96,17 @@ impl<K: TotalOrd, V> Map<K, V> for TreeMap<K, V> {
}
impl<K: TotalOrd, V> MutableMap<K, V> for TreeMap<K, V> {
/// Return a mutable reference to the value corresponding to the key
#[inline]
fn find_mut<'a>(&'a mut self, key: &K) -> Option<&'a mut V> {
find_mut(&mut self.root, key)
}
/// Insert a key-value pair from the map. If the key already had a value
/// present in the map, that value is returned. Otherwise None is returned.
fn swap(&mut self, key: K, value: V) -> Option<V> {
let ret = insert(&mut self.root, key, value);
if ret.is_none() { self.length += 1 }
ret
}
/// Removes a key from the map, returning the value at the key if the key
/// was previously in the map.
fn pop(&mut self, key: &K) -> Option<V> {
let ret = remove(&mut self.root, key);
if ret.is_some() { self.length -= 1 }
@ -531,7 +514,6 @@ impl<K, V> Iterator<(K, V)> for MoveEntries<K,V> {
}
impl<'a, T> Iterator<&'a T> for SetItems<'a, T> {
/// Advance the iterator to the next node (in order). If there are no more nodes, return `None`.
#[inline]
fn next(&mut self) -> Option<&'a T> {
self.iter.next().map(|(value, _)| value)
@ -539,7 +521,6 @@ impl<'a, T> Iterator<&'a T> for SetItems<'a, T> {
}
impl<'a, T> Iterator<&'a T> for RevSetItems<'a, T> {
/// Advance the iterator to the next node (in order). If there are no more nodes, return `None`.
#[inline]
fn next(&mut self) -> Option<&'a T> {
self.iter.next().map(|(value, _)| value)
@ -557,90 +538,62 @@ pub struct TreeSet<T> {
impl<T: Eq + TotalOrd> Eq for TreeSet<T> {
#[inline]
fn eq(&self, other: &TreeSet<T>) -> bool { self.map == other.map }
#[inline]
fn ne(&self, other: &TreeSet<T>) -> bool { self.map != other.map }
}
impl<T: Ord + TotalOrd> Ord for TreeSet<T> {
#[inline]
fn lt(&self, other: &TreeSet<T>) -> bool { self.map < other.map }
#[inline]
fn le(&self, other: &TreeSet<T>) -> bool { self.map <= other.map }
#[inline]
fn ge(&self, other: &TreeSet<T>) -> bool { self.map >= other.map }
#[inline]
fn gt(&self, other: &TreeSet<T>) -> bool { self.map > other.map }
}
impl<T: TotalOrd> Container for TreeSet<T> {
/// Return the number of elements in the set
#[inline]
fn len(&self) -> uint { self.map.len() }
/// Return true if the set contains no elements
#[inline]
fn is_empty(&self) -> bool { self.map.is_empty() }
}
impl<T: TotalOrd> Mutable for TreeSet<T> {
/// Clear the set, removing all values.
#[inline]
fn clear(&mut self) { self.map.clear() }
}
impl<T: TotalOrd> Set<T> for TreeSet<T> {
/// Return true if the set contains a value
#[inline]
fn contains(&self, value: &T) -> bool {
self.map.contains_key(value)
}
/// Return true if the set has no elements in common with `other`.
/// This is equivalent to checking for an empty intersection.
fn is_disjoint(&self, other: &TreeSet<T>) -> bool {
self.intersection(other).next().is_none()
}
/// Return true if the set is a subset of another
#[inline]
fn is_subset(&self, other: &TreeSet<T>) -> bool {
other.is_superset(self)
}
/// Return true if the set is a superset of another
fn is_superset(&self, other: &TreeSet<T>) -> bool {
let mut x = self.iter();
let mut y = other.iter();
let mut a = x.next();
let mut b = y.next();
while b.is_some() {
if a.is_none() {
return false
while a.is_some() {
if b.is_none() {
return false;
}
let a1 = a.unwrap();
let b1 = b.unwrap();
match a1.cmp(b1) {
Less => (),
Greater => return false,
Equal => b = y.next(),
match b1.cmp(a1) {
Less => (),
Greater => return false,
Equal => a = x.next(),
}
a = x.next();
b = y.next();
}
true
}
}
impl<T: TotalOrd> MutableSet<T> for TreeSet<T> {
/// Add a value to the set. Return true if the value was not already
/// present in the set.
#[inline]
fn insert(&mut self, value: T) -> bool { self.map.insert(value, ()) }
/// Remove a value from the set. Return true if the value was
/// present in the set.
#[inline]
fn remove(&mut self, value: &T) -> bool { self.map.remove(value) }
}

View File

@ -144,6 +144,19 @@
//! }
//! ```
//!
//! The above code can also be shortened with a macro from libgreen.
//!
//! ```
//! #![feature(phase)]
//! #[phase(syntax)] extern crate green;
//!
//! green_start!(main)
//!
//! fn main() {
//! // run inside of a green pool
//! }
//! ```
//!
//! # Using a scheduler pool
//!
//! ```rust
@ -229,6 +242,33 @@ pub mod sleeper_list;
pub mod stack;
pub mod task;
/// A helper macro for booting a program with libgreen
///
/// # Example
///
/// ```
/// #![feature(phase)]
/// #[phase(syntax)] extern crate green;
///
/// green_start!(main)
///
/// fn main() {
/// // running with libgreen
/// }
/// ```
#[macro_export]
macro_rules! green_start( ($f:ident) => (
mod __start {
extern crate green;
extern crate rustuv;
#[start]
fn start(argc: int, argv: **u8) -> int {
green::start(argc, argv, rustuv::event_loop, super::$f)
}
}
) )
/// Set up a default runtime configuration, given compiler-supplied arguments.
///
/// This function will block until the entire pool of M:N schedulers have

View File

@ -1035,10 +1035,10 @@ mod test {
fn sched_id() -> uint {
let mut task = Local::borrow(None::<Task>);
match task.get().maybe_take_runtime::<GreenTask>() {
match task.maybe_take_runtime::<GreenTask>() {
Some(green) => {
let ret = green.sched.get_ref().sched_id();
task.get().put_runtime(green);
task.put_runtime(green);
return ret;
}
None => fail!()

View File

@ -26,10 +26,10 @@ use super::{IoResult, retry, keep_going};
#[cfg(unix)] pub type sock_t = super::file::fd_t;
pub fn htons(u: u16) -> u16 {
mem::to_be16(u as i16) as u16
mem::to_be16(u)
}
pub fn ntohs(u: u16) -> u16 {
mem::from_be16(u as i16) as u16
mem::from_be16(u)
}
enum InAddr {

View File

@ -182,7 +182,7 @@ fn helper(input: libc::c_int, messages: Receiver<Req>) {
let t = active.remove(i).unwrap();
ack.send(t);
}
_ => break
Err(..) => break
}
}

View File

@ -201,19 +201,30 @@ impl rt::Runtime for Ops {
Err(task) => { cast::forget(task.wake()); }
}
} else {
let mut iter = task.make_selectable(times);
let iter = task.make_selectable(times);
let guard = (*me).lock.lock();
(*me).awoken = false;
let success = iter.all(|task| {
match f(task) {
Ok(()) => true,
Err(task) => {
cast::forget(task.wake());
false
// Apply the given closure to all of the "selectable tasks",
// bailing on the first one that produces an error. Note that
// care must be taken such that when an error is occurred, we
// may not own the task, so we may still have to wait for the
// task to become available. In other words, if task.wake()
// returns `None`, then someone else has ownership and we must
// wait for their signal.
match iter.map(f).filter_map(|a| a.err()).next() {
None => {}
Some(task) => {
match task.wake() {
Some(task) => {
cast::forget(task);
(*me).awoken = true;
}
None => {}
}
}
});
while success && !(*me).awoken {
}
while !(*me).awoken {
guard.wait();
}
}

View File

@ -4143,21 +4143,21 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) {
"nearbyintf64" => (0, vec!( ty::mk_f64() ), ty::mk_f64()),
"roundf32" => (0, vec!( ty::mk_f32() ), ty::mk_f32()),
"roundf64" => (0, vec!( ty::mk_f64() ), ty::mk_f64()),
"ctpop8" => (0, vec!( ty::mk_i8() ), ty::mk_i8()),
"ctpop16" => (0, vec!( ty::mk_i16() ), ty::mk_i16()),
"ctpop32" => (0, vec!( ty::mk_i32() ), ty::mk_i32()),
"ctpop64" => (0, vec!( ty::mk_i64() ), ty::mk_i64()),
"ctlz8" => (0, vec!( ty::mk_i8() ), ty::mk_i8()),
"ctlz16" => (0, vec!( ty::mk_i16() ), ty::mk_i16()),
"ctlz32" => (0, vec!( ty::mk_i32() ), ty::mk_i32()),
"ctlz64" => (0, vec!( ty::mk_i64() ), ty::mk_i64()),
"cttz8" => (0, vec!( ty::mk_i8() ), ty::mk_i8()),
"cttz16" => (0, vec!( ty::mk_i16() ), ty::mk_i16()),
"cttz32" => (0, vec!( ty::mk_i32() ), ty::mk_i32()),
"cttz64" => (0, vec!( ty::mk_i64() ), ty::mk_i64()),
"bswap16" => (0, vec!( ty::mk_i16() ), ty::mk_i16()),
"bswap32" => (0, vec!( ty::mk_i32() ), ty::mk_i32()),
"bswap64" => (0, vec!( ty::mk_i64() ), ty::mk_i64()),
"ctpop8" => (0, vec!( ty::mk_u8() ), ty::mk_u8()),
"ctpop16" => (0, vec!( ty::mk_u16() ), ty::mk_u16()),
"ctpop32" => (0, vec!( ty::mk_u32() ), ty::mk_u32()),
"ctpop64" => (0, vec!( ty::mk_u64() ), ty::mk_u64()),
"ctlz8" => (0, vec!( ty::mk_u8() ), ty::mk_u8()),
"ctlz16" => (0, vec!( ty::mk_u16() ), ty::mk_u16()),
"ctlz32" => (0, vec!( ty::mk_u32() ), ty::mk_u32()),
"ctlz64" => (0, vec!( ty::mk_u64() ), ty::mk_u64()),
"cttz8" => (0, vec!( ty::mk_u8() ), ty::mk_u8()),
"cttz16" => (0, vec!( ty::mk_u16() ), ty::mk_u16()),
"cttz32" => (0, vec!( ty::mk_u32() ), ty::mk_u32()),
"cttz64" => (0, vec!( ty::mk_u64() ), ty::mk_u64()),
"bswap16" => (0, vec!( ty::mk_u16() ), ty::mk_u16()),
"bswap32" => (0, vec!( ty::mk_u32() ), ty::mk_u32()),
"bswap64" => (0, vec!( ty::mk_u64() ), ty::mk_u64()),
"volatile_load" =>
(1, vec!( ty::mk_imm_ptr(tcx, param(ccx, 0)) ), param(ccx, 0)),

View File

@ -20,23 +20,21 @@ use serialize::hex::ToHex;
/// Write a u32 into a vector, which must be 4 bytes long. The value is written in big-endian
/// format.
fn write_u32_be(dst: &mut[u8], input: u32) {
use std::cast::transmute;
use std::mem::to_be32;
assert!(dst.len() == 4);
unsafe {
let x: *mut i32 = transmute(dst.unsafe_mut_ref(0));
*x = to_be32(input as i32);
let x = dst.unsafe_mut_ref(0) as *mut _ as *mut u32;
*x = to_be32(input);
}
}
/// Read a vector of bytes into a vector of u32s. The values are read in big-endian format.
fn read_u32v_be(dst: &mut[u32], input: &[u8]) {
use std::cast::transmute;
use std::mem::to_be32;
assert!(dst.len() * 4 == input.len());
unsafe {
let mut x: *mut i32 = transmute(dst.unsafe_mut_ref(0));
let mut y: *i32 = transmute(input.unsafe_ref(0));
let mut x = dst.unsafe_mut_ref(0) as *mut _ as *mut u32;
let mut y = input.unsafe_ref(0) as *_ as *u32;
for _ in range(0, dst.len()) {
*x = to_be32(*y);
x = x.offset(1);

View File

@ -189,67 +189,68 @@
for (var i = 0; i < nresults; i += 1) {
results[i].word = searchWords[results[i].id];
results[i].item = searchIndex[results[i].id] || {};
results[i].ty = results[i].item.ty;
results[i].path = results[i].item.path;
}
// if there are no results then return to default and fail
if (results.length === 0) {
return [];
}
// sort by exact match
results.sort(function search_complete_sort0(aaa, bbb) {
if (aaa.word === valLower &&
bbb.word !== valLower) {
return 1;
}
results.sort(function(aaa, bbb) {
var a, b;
// sort by crate (non-current crate goes later)
a = (aaa.item.crate !== window.currentCrate);
b = (bbb.item.crate !== window.currentCrate);
if (a !== b) return a - b;
// sort by exact match (mismatch goes later)
a = (aaa.word !== valLower);
b = (bbb.word !== valLower);
if (a !== b) return a - b;
// sort by item name length (longer goes later)
a = aaa.word.length;
b = bbb.word.length;
if (a !== b) return a - b;
// sort by item name (lexicographically larger goes later)
a = aaa.word;
b = bbb.word;
if (a !== b) return (a > b ? +1 : -1);
// sort by index of keyword in item name (no literal occurrence goes later)
a = (aaa.index < 0);
b = (bbb.index < 0);
if (a !== b) return a - b;
// (later literal occurrence, if any, goes later)
a = aaa.index;
b = bbb.index;
if (a !== b) return a - b;
// sort by description (no description goes later)
a = (aaa.item.desc === '');
b = (bbb.item.desc === '');
if (a !== b) return a - b;
// sort by type (later occurrence in `itemTypes` goes later)
a = aaa.item.ty;
b = bbb.item.ty;
if (a !== b) return a - b;
// sort by path (lexicographically larger goes later)
a = aaa.item.path;
b = bbb.item.path;
if (a !== b) return (a > b ? +1 : -1);
// que sera, sera
return 0;
});
// first sorting attempt
// sort by item name length
results.sort(function search_complete_sort1(aaa, bbb) {
if (aaa.word.length > bbb.word.length) {
return 1;
}
});
// second sorting attempt
// sort by item name
results.sort(function search_complete_sort1(aaa, bbb) {
if (aaa.word.length === bbb.word.length &&
aaa.word > bbb.word) {
return 1;
}
});
// third sorting attempt
// sort by index of keyword in item name
if (results[0].index !== -1) {
results.sort(function search_complete_sort1(aaa, bbb) {
if (aaa.index > bbb.index && bbb.index === 0) {
return 1;
}
});
}
// fourth sorting attempt
// sort by type
results.sort(function search_complete_sort3(aaa, bbb) {
if (aaa.word === bbb.word &&
aaa.ty > bbb.ty) {
return 1;
}
});
// fifth sorting attempt
// sort by path
results.sort(function search_complete_sort4(aaa, bbb) {
if (aaa.word === bbb.word &&
aaa.ty === bbb.ty && aaa.path > bbb.path) {
return 1;
}
});
// sixth sorting attempt
// remove duplicates, according to the data provided
for (var i = results.length - 1; i > 0; i -= 1) {
if (results[i].word === results[i - 1].word &&
results[i].ty === results[i - 1].ty &&
results[i].path === results[i - 1].path)
results[i].item.ty === results[i - 1].item.ty &&
results[i].item.path === results[i - 1].item.path)
{
results[i].id = -1;
}

View File

@ -462,7 +462,7 @@ fn local_loop() -> &'static mut uvio::UvIoFactory {
unsafe {
cast::transmute({
let mut task = Local::borrow(None::<Task>);
let mut io = task.get().local_io().unwrap();
let mut io = task.local_io().unwrap();
let (_vtable, uvio): (uint, &'static mut uvio::UvIoFactory) =
cast::transmute(io.get());
uvio

View File

@ -32,8 +32,8 @@ use uvll;
/// Generic functions related to dealing with sockaddr things
////////////////////////////////////////////////////////////////////////////////
pub fn htons(u: u16) -> u16 { mem::to_be16(u as i16) as u16 }
pub fn ntohs(u: u16) -> u16 { mem::from_be16(u as i16) as u16 }
pub fn htons(u: u16) -> u16 { mem::to_be16(u) }
pub fn ntohs(u: u16) -> u16 { mem::from_be16(u) }
pub fn sockaddr_to_addr(storage: &libc::sockaddr_storage,
len: uint) -> ip::SocketAddr {

View File

@ -179,8 +179,8 @@ pub mod reader {
];
unsafe {
let ptr = data.as_ptr().offset(start as int) as *i32;
let val = from_be32(*ptr) as u32;
let ptr = data.as_ptr().offset(start as int) as *u32;
let val = from_be32(*ptr);
let i = (val >> 28u) as uint;
let (shift, mask) = SHIFT_MASK_TABLE[i];

View File

@ -88,7 +88,9 @@ pub trait Set<T>: Container {
fn is_subset(&self, other: &Self) -> bool;
/// Return true if the set is a superset of another
fn is_superset(&self, other: &Self) -> bool;
fn is_superset(&self, other: &Self) -> bool {
other.is_subset(self)
}
// FIXME #8154: Add difference, sym. difference, intersection and union iterators
}

View File

@ -394,26 +394,50 @@ extern "rust-intrinsic" {
pub fn roundf32(x: f32) -> f32;
pub fn roundf64(x: f64) -> f64;
}
#[cfg(not(stage0))]
extern "rust-intrinsic" {
pub fn ctpop8(x: u8) -> u8;
pub fn ctpop16(x: u16) -> u16;
pub fn ctpop32(x: u32) -> u32;
pub fn ctpop64(x: u64) -> u64;
pub fn ctpop8(x: i8) -> i8;
pub fn ctpop16(x: i16) -> i16;
pub fn ctpop32(x: i32) -> i32;
pub fn ctpop64(x: i64) -> i64;
pub fn ctlz8(x: u8) -> u8;
pub fn ctlz16(x: u16) -> u16;
pub fn ctlz32(x: u32) -> u32;
pub fn ctlz64(x: u64) -> u64;
pub fn ctlz8(x: i8) -> i8;
pub fn ctlz16(x: i16) -> i16;
pub fn ctlz32(x: i32) -> i32;
pub fn ctlz64(x: i64) -> i64;
pub fn cttz8(x: u8) -> u8;
pub fn cttz16(x: u16) -> u16;
pub fn cttz32(x: u32) -> u32;
pub fn cttz64(x: u64) -> u64;
pub fn cttz8(x: i8) -> i8;
pub fn cttz16(x: i16) -> i16;
pub fn cttz32(x: i32) -> i32;
pub fn cttz64(x: i64) -> i64;
pub fn bswap16(x: u16) -> u16;
pub fn bswap32(x: u32) -> u32;
pub fn bswap64(x: u64) -> u64;
}
pub fn bswap16(x: i16) -> i16;
pub fn bswap32(x: i32) -> i32;
pub fn bswap64(x: i64) -> i64;
// NOTE: remove this after a snap, and merge the extern block above
macro_rules! stage0_hack {
($( $u_ty:ty, $i_ty:ty => $($name:ident),*);*) => {
$(
$(
#[cfg(stage0)]
pub unsafe fn $name(x: $u_ty) -> $u_ty {
extern "rust-intrinsic" { fn $name(x: $i_ty) -> $i_ty; }
$name(x as $i_ty) as $u_ty
}
)*)*
}
}
stage0_hack! {
u8, i8 => ctpop8, ctlz8, cttz8;
u16, i16 => ctpop16, ctlz16, cttz16, bswap16;
u32, i32 => ctpop32, ctlz32, cttz32, bswap32;
u64, i64 => ctpop64, ctlz64, cttz64, bswap64
}
extern "rust-intrinsic" {
pub fn i8_add_with_overflow(x: i8, y: i8) -> (i8, bool);
pub fn i16_add_with_overflow(x: i16, y: i16) -> (i16, bool);
pub fn i32_add_with_overflow(x: i32, y: i32) -> (i32, bool);

View File

@ -83,9 +83,9 @@ pub fn u64_to_le_bytes<T>(n: u64, size: uint, f: |v: &[u8]| -> T) -> T {
assert!(size <= 8u);
match size {
1u => f(&[n as u8]),
2u => f(unsafe { transmute::<i16, [u8, ..2]>(to_le16(n as i16)) }),
4u => f(unsafe { transmute::<i32, [u8, ..4]>(to_le32(n as i32)) }),
8u => f(unsafe { transmute::<i64, [u8, ..8]>(to_le64(n as i64)) }),
2u => f(unsafe { transmute::<_, [u8, ..2]>(to_le16(n as u16)) }),
4u => f(unsafe { transmute::<_, [u8, ..4]>(to_le32(n as u32)) }),
8u => f(unsafe { transmute::<_, [u8, ..8]>(to_le64(n)) }),
_ => {
let mut bytes = vec!();
@ -123,9 +123,9 @@ pub fn u64_to_be_bytes<T>(n: u64, size: uint, f: |v: &[u8]| -> T) -> T {
assert!(size <= 8u);
match size {
1u => f(&[n as u8]),
2u => f(unsafe { transmute::<i16, [u8, ..2]>(to_be16(n as i16)) }),
4u => f(unsafe { transmute::<i32, [u8, ..4]>(to_be32(n as i32)) }),
8u => f(unsafe { transmute::<i64, [u8, ..8]>(to_be64(n as i64)) }),
2u => f(unsafe { transmute::<_, [u8, ..2]>(to_be16(n as u16)) }),
4u => f(unsafe { transmute::<_, [u8, ..4]>(to_be32(n as u32)) }),
8u => f(unsafe { transmute::<_, [u8, ..8]>(to_be64(n)) }),
_ => {
let mut bytes = vec!();
let mut i = size;
@ -166,7 +166,7 @@ pub fn u64_from_be_bytes(data: &[u8], start: uint, size: uint) -> u64 {
let ptr = data.as_ptr().offset(start as int);
let out = buf.as_mut_ptr();
copy_nonoverlapping_memory(out.offset((8 - size) as int), ptr, size);
from_be64(*(out as *i64)) as u64
from_be64(*(out as *u64))
}
}

View File

@ -160,7 +160,7 @@ fn reset_helper(w: ~Writer:Send,
{
let mut t = Local::borrow(None::<Task>);
// Be sure to flush any pending output from the writer
match f(t.get(), w) {
match f(&mut *t, w) {
Some(mut w) => {
drop(t);
// FIXME: is failing right here?
@ -230,9 +230,7 @@ fn with_task_stdout(f: |&mut Writer| -> IoResult<()> ) {
// To protect against this, we do a little dance in which we
// temporarily take the task, swap the handles, put the task in TLS,
// and only then drop the previous handle.
let mut t = Local::borrow(None::<Task>);
let prev = replace(&mut t.get().stdout, my_stdout);
drop(t);
let prev = replace(&mut Local::borrow(None::<Task>).stdout, my_stdout);
drop(prev);
ret
}

View File

@ -99,128 +99,128 @@ pub unsafe fn move_val_init<T>(dst: &mut T, src: T) {
intrinsics::move_val_init(dst, src)
}
/// Convert an i16 to little endian from the target's endianness.
/// Convert an u16 to little endian from the target's endianness.
///
/// On little endian, this is a no-op. On big endian, the bytes are swapped.
#[cfg(target_endian = "little")] #[inline] pub fn to_le16(x: i16) -> i16 { x }
#[cfg(target_endian = "little")] #[inline] pub fn to_le16(x: u16) -> u16 { x }
/// Convert an i16 to little endian from the target's endianness.
/// Convert an u16 to little endian from the target's endianness.
///
/// On little endian, this is a no-op. On big endian, the bytes are swapped.
#[cfg(target_endian = "big")] #[inline] pub fn to_le16(x: i16) -> i16 { unsafe { bswap16(x) } }
#[cfg(target_endian = "big")] #[inline] pub fn to_le16(x: u16) -> u16 { unsafe { bswap16(x) } }
/// Convert an i32 to little endian from the target's endianness.
/// Convert an u32 to little endian from the target's endianness.
///
/// On little endian, this is a no-op. On big endian, the bytes are swapped.
#[cfg(target_endian = "little")] #[inline] pub fn to_le32(x: i32) -> i32 { x }
#[cfg(target_endian = "little")] #[inline] pub fn to_le32(x: u32) -> u32 { x }
/// Convert an i32 to little endian from the target's endianness.
/// Convert an u32 to little endian from the target's endianness.
///
/// On little endian, this is a no-op. On big endian, the bytes are swapped.
#[cfg(target_endian = "big")] #[inline] pub fn to_le32(x: i32) -> i32 { unsafe { bswap32(x) } }
#[cfg(target_endian = "big")] #[inline] pub fn to_le32(x: u32) -> u32 { unsafe { bswap32(x) } }
/// Convert an i64 to little endian from the target's endianness.
/// Convert an u64 to little endian from the target's endianness.
///
/// On little endian, this is a no-op. On big endian, the bytes are swapped.
#[cfg(target_endian = "little")] #[inline] pub fn to_le64(x: i64) -> i64 { x }
#[cfg(target_endian = "little")] #[inline] pub fn to_le64(x: u64) -> u64 { x }
/// Convert an i64 to little endian from the target's endianness.
/// Convert an u64 to little endian from the target's endianness.
///
/// On little endian, this is a no-op. On big endian, the bytes are swapped.
#[cfg(target_endian = "big")] #[inline] pub fn to_le64(x: i64) -> i64 { unsafe { bswap64(x) } }
#[cfg(target_endian = "big")] #[inline] pub fn to_le64(x: u64) -> u64 { unsafe { bswap64(x) } }
/// Convert an i16 to big endian from the target's endianness.
/// Convert an u16 to big endian from the target's endianness.
///
/// On big endian, this is a no-op. On little endian, the bytes are swapped.
#[cfg(target_endian = "little")] #[inline] pub fn to_be16(x: i16) -> i16 { unsafe { bswap16(x) } }
#[cfg(target_endian = "little")] #[inline] pub fn to_be16(x: u16) -> u16 { unsafe { bswap16(x) } }
/// Convert an i16 to big endian from the target's endianness.
/// Convert an u16 to big endian from the target's endianness.
///
/// On big endian, this is a no-op. On little endian, the bytes are swapped.
#[cfg(target_endian = "big")] #[inline] pub fn to_be16(x: i16) -> i16 { x }
#[cfg(target_endian = "big")] #[inline] pub fn to_be16(x: u16) -> u16 { x }
/// Convert an i32 to big endian from the target's endianness.
/// Convert an u32 to big endian from the target's endianness.
///
/// On big endian, this is a no-op. On little endian, the bytes are swapped.
#[cfg(target_endian = "little")] #[inline] pub fn to_be32(x: i32) -> i32 { unsafe { bswap32(x) } }
#[cfg(target_endian = "little")] #[inline] pub fn to_be32(x: u32) -> u32 { unsafe { bswap32(x) } }
/// Convert an i32 to big endian from the target's endianness.
/// Convert an u32 to big endian from the target's endianness.
///
/// On big endian, this is a no-op. On little endian, the bytes are swapped.
#[cfg(target_endian = "big")] #[inline] pub fn to_be32(x: i32) -> i32 { x }
#[cfg(target_endian = "big")] #[inline] pub fn to_be32(x: u32) -> u32 { x }
/// Convert an i64 to big endian from the target's endianness.
/// Convert an u64 to big endian from the target's endianness.
///
/// On big endian, this is a no-op. On little endian, the bytes are swapped.
#[cfg(target_endian = "little")] #[inline] pub fn to_be64(x: i64) -> i64 { unsafe { bswap64(x) } }
#[cfg(target_endian = "little")] #[inline] pub fn to_be64(x: u64) -> u64 { unsafe { bswap64(x) } }
/// Convert an i64 to big endian from the target's endianness.
/// Convert an u64 to big endian from the target's endianness.
///
/// On big endian, this is a no-op. On little endian, the bytes are swapped.
#[cfg(target_endian = "big")] #[inline] pub fn to_be64(x: i64) -> i64 { x }
#[cfg(target_endian = "big")] #[inline] pub fn to_be64(x: u64) -> u64 { x }
/// Convert an i16 from little endian to the target's endianness.
/// Convert an u16 from little endian to the target's endianness.
///
/// On little endian, this is a no-op. On big endian, the bytes are swapped.
#[cfg(target_endian = "little")] #[inline] pub fn from_le16(x: i16) -> i16 { x }
#[cfg(target_endian = "little")] #[inline] pub fn from_le16(x: u16) -> u16 { x }
/// Convert an i16 from little endian to the target's endianness.
/// Convert an u16 from little endian to the target's endianness.
///
/// On little endian, this is a no-op. On big endian, the bytes are swapped.
#[cfg(target_endian = "big")] #[inline] pub fn from_le16(x: i16) -> i16 { unsafe { bswap16(x) } }
#[cfg(target_endian = "big")] #[inline] pub fn from_le16(x: u16) -> u16 { unsafe { bswap16(x) } }
/// Convert an i32 from little endian to the target's endianness.
/// Convert an u32 from little endian to the target's endianness.
///
/// On little endian, this is a no-op. On big endian, the bytes are swapped.
#[cfg(target_endian = "little")] #[inline] pub fn from_le32(x: i32) -> i32 { x }
#[cfg(target_endian = "little")] #[inline] pub fn from_le32(x: u32) -> u32 { x }
/// Convert an i32 from little endian to the target's endianness.
/// Convert an u32 from little endian to the target's endianness.
///
/// On little endian, this is a no-op. On big endian, the bytes are swapped.
#[cfg(target_endian = "big")] #[inline] pub fn from_le32(x: i32) -> i32 { unsafe { bswap32(x) } }
#[cfg(target_endian = "big")] #[inline] pub fn from_le32(x: u32) -> u32 { unsafe { bswap32(x) } }
/// Convert an i64 from little endian to the target's endianness.
/// Convert an u64 from little endian to the target's endianness.
///
/// On little endian, this is a no-op. On big endian, the bytes are swapped.
#[cfg(target_endian = "little")] #[inline] pub fn from_le64(x: i64) -> i64 { x }
#[cfg(target_endian = "little")] #[inline] pub fn from_le64(x: u64) -> u64 { x }
/// Convert an i64 from little endian to the target's endianness.
/// Convert an u64 from little endian to the target's endianness.
///
/// On little endian, this is a no-op. On big endian, the bytes are swapped.
#[cfg(target_endian = "big")] #[inline] pub fn from_le64(x: i64) -> i64 { unsafe { bswap64(x) } }
#[cfg(target_endian = "big")] #[inline] pub fn from_le64(x: u64) -> u64 { unsafe { bswap64(x) } }
/// Convert an i16 from big endian to the target's endianness.
/// Convert an u16 from big endian to the target's endianness.
///
/// On big endian, this is a no-op. On little endian, the bytes are swapped.
#[cfg(target_endian = "little")] #[inline] pub fn from_be16(x: i16) -> i16 { unsafe { bswap16(x) } }
#[cfg(target_endian = "little")] #[inline] pub fn from_be16(x: u16) -> u16 { unsafe { bswap16(x) } }
/// Convert an i16 from big endian to the target's endianness.
/// Convert an u16 from big endian to the target's endianness.
///
/// On big endian, this is a no-op. On little endian, the bytes are swapped.
#[cfg(target_endian = "big")] #[inline] pub fn from_be16(x: i16) -> i16 { x }
#[cfg(target_endian = "big")] #[inline] pub fn from_be16(x: u16) -> u16 { x }
/// Convert an i32 from big endian to the target's endianness.
/// Convert an u32 from big endian to the target's endianness.
///
/// On big endian, this is a no-op. On little endian, the bytes are swapped.
#[cfg(target_endian = "little")] #[inline] pub fn from_be32(x: i32) -> i32 { unsafe { bswap32(x) } }
#[cfg(target_endian = "little")] #[inline] pub fn from_be32(x: u32) -> u32 { unsafe { bswap32(x) } }
/// Convert an i32 from big endian to the target's endianness.
/// Convert an u32 from big endian to the target's endianness.
///
/// On big endian, this is a no-op. On little endian, the bytes are swapped.
#[cfg(target_endian = "big")] #[inline] pub fn from_be32(x: i32) -> i32 { x }
#[cfg(target_endian = "big")] #[inline] pub fn from_be32(x: u32) -> u32 { x }
/// Convert an i64 from big endian to the target's endianness.
/// Convert an u64 from big endian to the target's endianness.
///
/// On big endian, this is a no-op. On little endian, the bytes are swapped.
#[cfg(target_endian = "little")] #[inline] pub fn from_be64(x: i64) -> i64 { unsafe { bswap64(x) } }
#[cfg(target_endian = "little")] #[inline] pub fn from_be64(x: u64) -> u64 { unsafe { bswap64(x) } }
/// Convert an i64 from big endian to the target's endianness.
/// Convert an u64 from big endian to the target's endianness.
///
/// On big endian, this is a no-op. On little endian, the bytes are swapped.
#[cfg(target_endian = "big")] #[inline] pub fn from_be64(x: i64) -> i64 { x }
#[cfg(target_endian = "big")] #[inline] pub fn from_be64(x: u64) -> u64 { x }
/**

View File

@ -1037,7 +1037,7 @@ mod tests {
assert_eq!(0f32.abs_sub(&INFINITY), 0f32);
}
#[test] #[ignore(cfg(windows))] // FIXME #8663
#[test]
fn test_abs_sub_nowin() {
assert!(NAN.abs_sub(&-1f32).is_nan());
assert!(1f32.abs_sub(&NAN).is_nan());

View File

@ -1041,7 +1041,7 @@ mod tests {
assert_eq!(0f64.abs_sub(&INFINITY), 0f64);
}
#[test] #[ignore(cfg(windows))] // FIXME #8663
#[test]
fn test_abs_sub_nowin() {
assert!(NAN.abs_sub(&-1f64).is_nan());
assert!(1f64.abs_sub(&NAN).is_nan());

View File

@ -28,17 +28,17 @@ int_module!(i16, 16)
impl Bitwise for i16 {
/// Returns the number of ones in the binary representation of the number.
#[inline]
fn count_ones(&self) -> i16 { unsafe { intrinsics::ctpop16(*self) } }
fn count_ones(&self) -> i16 { unsafe { intrinsics::ctpop16(*self as u16) as i16 } }
/// Returns the number of leading zeros in the in the binary representation
/// of the number.
#[inline]
fn leading_zeros(&self) -> i16 { unsafe { intrinsics::ctlz16(*self) } }
fn leading_zeros(&self) -> i16 { unsafe { intrinsics::ctlz16(*self as u16) as i16 } }
/// Returns the number of trailing zeros in the in the binary representation
/// of the number.
#[inline]
fn trailing_zeros(&self) -> i16 { unsafe { intrinsics::cttz16(*self) } }
fn trailing_zeros(&self) -> i16 { unsafe { intrinsics::cttz16(*self as u16) as i16 } }
}
impl CheckedAdd for i16 {

View File

@ -28,17 +28,17 @@ int_module!(i32, 32)
impl Bitwise for i32 {
/// Returns the number of ones in the binary representation of the number.
#[inline]
fn count_ones(&self) -> i32 { unsafe { intrinsics::ctpop32(*self) } }
fn count_ones(&self) -> i32 { unsafe { intrinsics::ctpop32(*self as u32) as i32 } }
/// Returns the number of leading zeros in the in the binary representation
/// of the number.
#[inline]
fn leading_zeros(&self) -> i32 { unsafe { intrinsics::ctlz32(*self) } }
fn leading_zeros(&self) -> i32 { unsafe { intrinsics::ctlz32(*self as u32) as i32 } }
/// Returns the number of trailing zeros in the in the binary representation
/// of the number.
#[inline]
fn trailing_zeros(&self) -> i32 { unsafe { intrinsics::cttz32(*self) } }
fn trailing_zeros(&self) -> i32 { unsafe { intrinsics::cttz32(*self as u32) as i32 } }
}
impl CheckedAdd for i32 {

View File

@ -30,16 +30,16 @@ int_module!(i64, 64)
impl Bitwise for i64 {
/// Returns the number of ones in the binary representation of the number.
#[inline]
fn count_ones(&self) -> i64 { unsafe { intrinsics::ctpop64(*self) } }
fn count_ones(&self) -> i64 { unsafe { intrinsics::ctpop64(*self as u64) as i64 } }
/// Returns the number of leading zeros in the in the binary representation
/// of the number.
#[inline]
fn leading_zeros(&self) -> i64 { unsafe { intrinsics::ctlz64(*self) } }
fn leading_zeros(&self) -> i64 { unsafe { intrinsics::ctlz64(*self as u64) as i64 } }
/// Counts the number of trailing zeros.
#[inline]
fn trailing_zeros(&self) -> i64 { unsafe { intrinsics::cttz64(*self) } }
fn trailing_zeros(&self) -> i64 { unsafe { intrinsics::cttz64(*self as u64) as i64 } }
}
impl CheckedAdd for i64 {

View File

@ -28,17 +28,17 @@ int_module!(i8, 8)
impl Bitwise for i8 {
/// Returns the number of ones in the binary representation of the number.
#[inline]
fn count_ones(&self) -> i8 { unsafe { intrinsics::ctpop8(*self) } }
fn count_ones(&self) -> i8 { unsafe { intrinsics::ctpop8(*self as u8) as i8 } }
/// Returns the number of leading zeros in the in the binary representation
/// of the number.
#[inline]
fn leading_zeros(&self) -> i8 { unsafe { intrinsics::ctlz8(*self) } }
fn leading_zeros(&self) -> i8 { unsafe { intrinsics::ctlz8(*self as u8) as i8 } }
/// Returns the number of trailing zeros in the in the binary representation
/// of the number.
#[inline]
fn trailing_zeros(&self) -> i8 { unsafe { intrinsics::cttz8(*self) } }
fn trailing_zeros(&self) -> i8 { unsafe { intrinsics::cttz8(*self as u8) as i8 } }
}
impl CheckedAdd for i8 {

View File

@ -1294,37 +1294,47 @@ impl Drop for MemoryMap {
/// Various useful system-specific constants.
pub mod consts {
#[cfg(unix)]
pub use os::consts::unix::*;
pub use os::consts::unix::FAMILY;
#[cfg(windows)]
pub use os::consts::windows::*;
pub use os::consts::windows::FAMILY;
#[cfg(target_os = "macos")]
pub use os::consts::macos::*;
pub use os::consts::macos::{SYSNAME, DLL_PREFIX, DLL_SUFFIX, DLL_EXTENSION};
#[cfg(target_os = "macos")]
pub use os::consts::macos::{EXE_SUFFIX, EXE_EXTENSION};
#[cfg(target_os = "freebsd")]
pub use os::consts::freebsd::*;
pub use os::consts::freebsd::{SYSNAME, DLL_PREFIX, DLL_SUFFIX, DLL_EXTENSION};
#[cfg(target_os = "freebsd")]
pub use os::consts::freebsd::{EXE_SUFFIX, EXE_EXTENSION};
#[cfg(target_os = "linux")]
pub use os::consts::linux::*;
pub use os::consts::linux::{SYSNAME, DLL_PREFIX, DLL_SUFFIX, DLL_EXTENSION};
#[cfg(target_os = "linux")]
pub use os::consts::linux::{EXE_SUFFIX, EXE_EXTENSION};
#[cfg(target_os = "android")]
pub use os::consts::android::*;
pub use os::consts::android::{SYSNAME, DLL_PREFIX, DLL_SUFFIX, DLL_EXTENSION};
#[cfg(target_os = "android")]
pub use os::consts::android::{EXE_SUFFIX, EXE_EXTENSION};
#[cfg(target_os = "win32")]
pub use os::consts::win32::*;
pub use os::consts::win32::{SYSNAME, DLL_PREFIX, DLL_SUFFIX, DLL_EXTENSION};
#[cfg(target_os = "win32")]
pub use os::consts::win32::{EXE_SUFFIX, EXE_EXTENSION};
#[cfg(target_arch = "x86")]
pub use os::consts::x86::*;
pub use os::consts::x86::{ARCH};
#[cfg(target_arch = "x86_64")]
pub use os::consts::x86_64::*;
pub use os::consts::x86_64::{ARCH};
#[cfg(target_arch = "arm")]
pub use os::consts::arm::*;
pub use os::consts::arm::{ARCH};
#[cfg(target_arch = "mips")]
pub use os::consts::mips::*;
pub use os::consts::mips::{ARCH};
/// Constants for Unix systems.
pub mod unix {

View File

@ -319,8 +319,7 @@ pub unsafe fn local_free(ptr: *u8) {
}
pub fn live_allocs() -> *mut Box {
let mut task = Local::borrow(None::<Task>);
task.get().heap.live_allocs
Local::borrow(None::<Task>).heap.live_allocs
}
#[cfg(test)]

View File

@ -18,15 +18,17 @@
#![allow(dead_code)]
use cast;
use ops::Drop;
use ops::{Drop, Deref, DerefMut};
use ptr::RawPtr;
#[cfg(windows)] // mingw-w32 doesn't like thread_local things
#[cfg(target_os = "android")] // see #10686
pub use self::native::*;
pub use self::native::{init, cleanup, put, take, try_take, unsafe_take, exists,
unsafe_borrow, try_unsafe_borrow};
#[cfg(not(windows), not(target_os = "android"))]
pub use self::compiled::*;
pub use self::compiled::{init, cleanup, put, take, try_take, unsafe_take, exists,
unsafe_borrow, try_unsafe_borrow};
/// Encapsulates a borrowed value. When this value goes out of scope, the
/// pointer is returned.
@ -48,13 +50,15 @@ impl<T> Drop for Borrowed<T> {
}
}
impl<T> Borrowed<T> {
pub fn get<'a>(&'a mut self) -> &'a mut T {
unsafe {
let val_ptr: &mut ~T = cast::transmute(&mut self.val);
let val_ptr: &'a mut T = *val_ptr;
val_ptr
}
impl<T> Deref<T> for Borrowed<T> {
fn deref<'a>(&'a self) -> &'a T {
unsafe { &*(self.val as *T) }
}
}
impl<T> DerefMut<T> for Borrowed<T> {
fn deref_mut<'a>(&'a mut self) -> &'a mut T {
unsafe { &mut *(self.val as *mut T) }
}
}

View File

@ -127,8 +127,8 @@ impl Task {
#[allow(unused_must_use)]
fn close_outputs() {
let mut task = Local::borrow(None::<Task>);
let stderr = task.get().stderr.take();
let stdout = task.get().stdout.take();
let stderr = task.stderr.take();
let stdout = task.stdout.take();
drop(task);
match stdout { Some(mut w) => { w.flush(); }, None => {} }
match stderr { Some(mut w) => { w.flush(); }, None => {} }
@ -159,8 +159,7 @@ impl Task {
// be intertwined, and miraculously work for now...
let mut task = Local::borrow(None::<Task>);
let storage_map = {
let task = task.get();
let LocalStorage(ref mut optmap) = task.storage;
let &LocalStorage(ref mut optmap) = &mut task.storage;
optmap.take()
};
drop(task);
@ -332,8 +331,7 @@ impl BlockedTask {
}
/// Converts one blocked task handle to a list of many handles to the same.
pub fn make_selectable(self, num_handles: uint) -> Take<BlockedTasks>
{
pub fn make_selectable(self, num_handles: uint) -> Take<BlockedTasks> {
let arc = match self {
Owned(task) => {
let flag = unsafe { AtomicUint::new(cast::transmute(task)) };

View File

@ -257,8 +257,8 @@ pub fn try<T:Send>(f: proc():Send -> T) -> Result<T, ~Any:Send> {
pub fn with_task_name<U>(blk: |Option<&str>| -> U) -> U {
use rt::task::Task;
let mut task = Local::borrow(None::<Task>);
match task.get().name {
let task = Local::borrow(None::<Task>);
match task.name {
Some(ref name) => blk(Some(name.as_slice())),
None => blk(None)
}
@ -276,11 +276,8 @@ pub fn deschedule() {
pub fn failing() -> bool {
//! True if the running task has failed
use rt::task::Task;
let mut local = Local::borrow(None::<Task>);
local.get().unwinder.unwinding()
Local::borrow(None::<Task>).unwinder.unwinding()
}
// The following 8 tests test the following 2^3 combinations:

View File

@ -194,7 +194,7 @@ pub fn encode(s: &str) -> ~str {
}
/**
* Encodes a URI component by replacing reserved characters with percent
* Encodes a URI component by replacing reserved characters with percent-
* encoded character sequences.
*
* This function is compliant with RFC 3986.

View File

@ -220,9 +220,9 @@ impl Uuid {
data4: [0, ..8]
};
fields.data1 = to_be32(d1 as i32) as u32;
fields.data2 = to_be16(d2 as i16) as u16;
fields.data3 = to_be16(d3 as i16) as u16;
fields.data1 = to_be32(d1);
fields.data2 = to_be16(d2);
fields.data3 = to_be16(d3);
slice::bytes::copy_memory(fields.data4, d4);
unsafe {
@ -343,9 +343,9 @@ impl Uuid {
unsafe {
uf = transmute_copy(&self.bytes);
}
uf.data1 = to_be32(uf.data1 as i32) as u32;
uf.data2 = to_be16(uf.data2 as i16) as u16;
uf.data3 = to_be16(uf.data3 as i16) as u16;
uf.data1 = to_be32(uf.data1);
uf.data2 = to_be16(uf.data2);
uf.data3 = to_be16(uf.data3);
let s = format!("{:08x}-{:04x}-{:04x}-{:02x}{:02x}-\
{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}",
uf.data1,

View File

@ -512,8 +512,9 @@ fn test() {
prep.declare_input("file", pth.as_str().unwrap(), file_content);
prep.exec(proc(_exe) {
let out = make_path(~"foo.o");
let compiler = if cfg!(windows) {"gcc"} else {"cc"};
// FIXME (#9639): This needs to handle non-utf8 paths
Process::status("gcc", [pth.as_str().unwrap().to_owned(),
Process::status(compiler, [pth.as_str().unwrap().to_owned(),
~"-o",
out.as_str().unwrap().to_owned()]).unwrap();

View File

@ -16,7 +16,7 @@ use std::io;
use std::io::stdio::StdReader;
use std::io::BufferedReader;
use std::os;
use std::intrinsics::cttz16;
use std::num::Bitwise;
// Computes a single solution to a given 9x9 sudoku
//
@ -187,9 +187,7 @@ impl Colors {
if (0u16 == val) {
return 0u8;
} else {
unsafe {
return cttz16(val as i16) as u8;
}
return val.trailing_zeros() as u8
}
}

View File

@ -1,4 +1,3 @@
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
@ -13,24 +12,24 @@
mod rusti {
extern "rust-intrinsic" {
pub fn ctpop8(x: i8) -> i8;
pub fn ctpop16(x: i16) -> i16;
pub fn ctpop32(x: i32) -> i32;
pub fn ctpop64(x: i64) -> i64;
pub fn ctpop8(x: u8) -> u8;
pub fn ctpop16(x: u16) -> u16;
pub fn ctpop32(x: u32) -> u32;
pub fn ctpop64(x: u64) -> u64;
pub fn ctlz8(x: i8) -> i8;
pub fn ctlz16(x: i16) -> i16;
pub fn ctlz32(x: i32) -> i32;
pub fn ctlz64(x: i64) -> i64;
pub fn ctlz8(x: u8) -> u8;
pub fn ctlz16(x: u16) -> u16;
pub fn ctlz32(x: u32) -> u32;
pub fn ctlz64(x: u64) -> u64;
pub fn cttz8(x: i8) -> i8;
pub fn cttz16(x: i16) -> i16;
pub fn cttz32(x: i32) -> i32;
pub fn cttz64(x: i64) -> i64;
pub fn cttz8(x: u8) -> u8;
pub fn cttz16(x: u16) -> u16;
pub fn cttz32(x: u32) -> u32;
pub fn cttz64(x: u64) -> u64;
pub fn bswap16(x: i16) -> i16;
pub fn bswap32(x: i32) -> i32;
pub fn bswap64(x: i64) -> i64;
pub fn bswap16(x: u16) -> u16;
pub fn bswap32(x: u32) -> u32;
pub fn bswap64(x: u64) -> u64;
}
}
@ -38,83 +37,83 @@ pub fn main() {
unsafe {
use rusti::*;
assert_eq!(ctpop8(0i8), 0i8);
assert_eq!(ctpop16(0i16), 0i16);
assert_eq!(ctpop32(0i32), 0i32);
assert_eq!(ctpop64(0i64), 0i64);
assert_eq!(ctpop8(0u8), 0u8);
assert_eq!(ctpop16(0u16), 0u16);
assert_eq!(ctpop32(0u32), 0u32);
assert_eq!(ctpop64(0u64), 0u64);
assert_eq!(ctpop8(1i8), 1i8);
assert_eq!(ctpop16(1i16), 1i16);
assert_eq!(ctpop32(1i32), 1i32);
assert_eq!(ctpop64(1i64), 1i64);
assert_eq!(ctpop8(1u8), 1u8);
assert_eq!(ctpop16(1u16), 1u16);
assert_eq!(ctpop32(1u32), 1u32);
assert_eq!(ctpop64(1u64), 1u64);
assert_eq!(ctpop8(10i8), 2i8);
assert_eq!(ctpop16(10i16), 2i16);
assert_eq!(ctpop32(10i32), 2i32);
assert_eq!(ctpop64(10i64), 2i64);
assert_eq!(ctpop8(10u8), 2u8);
assert_eq!(ctpop16(10u16), 2u16);
assert_eq!(ctpop32(10u32), 2u32);
assert_eq!(ctpop64(10u64), 2u64);
assert_eq!(ctpop8(100i8), 3i8);
assert_eq!(ctpop16(100i16), 3i16);
assert_eq!(ctpop32(100i32), 3i32);
assert_eq!(ctpop64(100i64), 3i64);
assert_eq!(ctpop8(100u8), 3u8);
assert_eq!(ctpop16(100u16), 3u16);
assert_eq!(ctpop32(100u32), 3u32);
assert_eq!(ctpop64(100u64), 3u64);
assert_eq!(ctpop8(-1i8), 8i8);
assert_eq!(ctpop16(-1i16), 16i16);
assert_eq!(ctpop32(-1i32), 32i32);
assert_eq!(ctpop64(-1i64), 64i64);
assert_eq!(ctpop8(-1u8), 8u8);
assert_eq!(ctpop16(-1u16), 16u16);
assert_eq!(ctpop32(-1u32), 32u32);
assert_eq!(ctpop64(-1u64), 64u64);
assert_eq!(ctlz8(0i8), 8i8);
assert_eq!(ctlz16(0i16), 16i16);
assert_eq!(ctlz32(0i32), 32i32);
assert_eq!(ctlz64(0i64), 64i64);
assert_eq!(ctlz8(0u8), 8u8);
assert_eq!(ctlz16(0u16), 16u16);
assert_eq!(ctlz32(0u32), 32u32);
assert_eq!(ctlz64(0u64), 64u64);
assert_eq!(ctlz8(1i8), 7i8);
assert_eq!(ctlz16(1i16), 15i16);
assert_eq!(ctlz32(1i32), 31i32);
assert_eq!(ctlz64(1i64), 63i64);
assert_eq!(ctlz8(1u8), 7u8);
assert_eq!(ctlz16(1u16), 15u16);
assert_eq!(ctlz32(1u32), 31u32);
assert_eq!(ctlz64(1u64), 63u64);
assert_eq!(ctlz8(10i8), 4i8);
assert_eq!(ctlz16(10i16), 12i16);
assert_eq!(ctlz32(10i32), 28i32);
assert_eq!(ctlz64(10i64), 60i64);
assert_eq!(ctlz8(10u8), 4u8);
assert_eq!(ctlz16(10u16), 12u16);
assert_eq!(ctlz32(10u32), 28u32);
assert_eq!(ctlz64(10u64), 60u64);
assert_eq!(ctlz8(100i8), 1i8);
assert_eq!(ctlz16(100i16), 9i16);
assert_eq!(ctlz32(100i32), 25i32);
assert_eq!(ctlz64(100i64), 57i64);
assert_eq!(ctlz8(100u8), 1u8);
assert_eq!(ctlz16(100u16), 9u16);
assert_eq!(ctlz32(100u32), 25u32);
assert_eq!(ctlz64(100u64), 57u64);
assert_eq!(cttz8(-1i8), 0i8);
assert_eq!(cttz16(-1i16), 0i16);
assert_eq!(cttz32(-1i32), 0i32);
assert_eq!(cttz64(-1i64), 0i64);
assert_eq!(cttz8(-1u8), 0u8);
assert_eq!(cttz16(-1u16), 0u16);
assert_eq!(cttz32(-1u32), 0u32);
assert_eq!(cttz64(-1u64), 0u64);
assert_eq!(cttz8(0i8), 8i8);
assert_eq!(cttz16(0i16), 16i16);
assert_eq!(cttz32(0i32), 32i32);
assert_eq!(cttz64(0i64), 64i64);
assert_eq!(cttz8(0u8), 8u8);
assert_eq!(cttz16(0u16), 16u16);
assert_eq!(cttz32(0u32), 32u32);
assert_eq!(cttz64(0u64), 64u64);
assert_eq!(cttz8(1i8), 0i8);
assert_eq!(cttz16(1i16), 0i16);
assert_eq!(cttz32(1i32), 0i32);
assert_eq!(cttz64(1i64), 0i64);
assert_eq!(cttz8(1u8), 0u8);
assert_eq!(cttz16(1u16), 0u16);
assert_eq!(cttz32(1u32), 0u32);
assert_eq!(cttz64(1u64), 0u64);
assert_eq!(cttz8(10i8), 1i8);
assert_eq!(cttz16(10i16), 1i16);
assert_eq!(cttz32(10i32), 1i32);
assert_eq!(cttz64(10i64), 1i64);
assert_eq!(cttz8(10u8), 1u8);
assert_eq!(cttz16(10u16), 1u16);
assert_eq!(cttz32(10u32), 1u32);
assert_eq!(cttz64(10u64), 1u64);
assert_eq!(cttz8(100i8), 2i8);
assert_eq!(cttz16(100i16), 2i16);
assert_eq!(cttz32(100i32), 2i32);
assert_eq!(cttz64(100i64), 2i64);
assert_eq!(cttz8(100u8), 2u8);
assert_eq!(cttz16(100u16), 2u16);
assert_eq!(cttz32(100u32), 2u32);
assert_eq!(cttz64(100u64), 2u64);
assert_eq!(cttz8(-1i8), 0i8);
assert_eq!(cttz16(-1i16), 0i16);
assert_eq!(cttz32(-1i32), 0i32);
assert_eq!(cttz64(-1i64), 0i64);
assert_eq!(cttz8(-1u8), 0u8);
assert_eq!(cttz16(-1u16), 0u16);
assert_eq!(cttz32(-1u32), 0u32);
assert_eq!(cttz64(-1u64), 0u64);
assert_eq!(bswap16(0x0A0Bi16), 0x0B0Ai16);
assert_eq!(bswap32(0x0ABBCC0Di32), 0x0DCCBB0Ai32);
assert_eq!(bswap64(0x0122334455667708i64), 0x0877665544332201i64);
assert_eq!(bswap16(0x0A0Bu16), 0x0B0Au16);
assert_eq!(bswap32(0x0ABBCC0Du32), 0x0DCCBB0Au32);
assert_eq!(bswap64(0x0122334455667708u64), 0x0877665544332201u64);
}
}

View File

@ -0,0 +1,56 @@
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// This test may not always fail, but it can be flaky if the race it used to
// expose is still present.
extern crate green;
extern crate rustuv;
extern crate native;
#[start]
fn start(argc: int, argv: **u8) -> int {
green::start(argc, argv, rustuv::event_loop, main)
}
fn helper(rx: Receiver<Sender<()>>) {
for tx in rx.iter() {
let _ = tx.send_opt(());
}
}
fn test() {
let (tx, rx) = channel();
spawn(proc() { helper(rx) });
let (snd, rcv) = channel();
for _ in range(1, 100000) {
snd.send(1);
let (tx2, rx2) = channel();
tx.send(tx2);
select! {
() = rx2.recv() => (),
_ = rcv.recv() => ()
}
}
}
fn main() {
let (tx, rx) = channel();
spawn(proc() {
tx.send(test());
});
rx.recv();
let (tx, rx) = channel();
native::task::spawn(proc() {
tx.send(test());
});
rx.recv();
}

View File

@ -8,30 +8,23 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// ignore-test - FIXME(#8538) some kind of problem linking induced by extern "C" fns
// ignore-android
// Smallest hello world with no runtime
// Smallest "hello world" with a libc runtime
#![no_std]
// This is an unfortunate thing to have to do on linux :(
#[cfg(target_os = "linux")]
#[doc(hidden)]
pub mod linkhack {
#[link_args="-lrustrt -lrt"]
extern {}
}
extern crate libc;
extern {
fn puts(s: *u8);
}
extern { fn puts(s: *u8); }
extern "rust-intrinsic" { fn transmute<T, U>(t: T) -> U; }
extern "rust-intrinsic" {
fn transmute<T, U>(t: T) -> U;
}
#[no_mangle]
pub extern fn rust_stack_exhausted() {}
#[start]
pub fn main(_: int, _: **u8, _: *u8) -> int {
#[no_split_stack]
fn main(_: int, _: **u8) -> int {
unsafe {
let (ptr, _): (*u8, uint) = transmute("Hello!");
puts(ptr);