auto merge of #13532 : alexcrichton/rust/rollup, r=alexcrichton
This commit is contained in:
commit
349d66af94
45 changed files with 546 additions and 413 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
56
src/test/run-pass/issue-13494.rs
Normal file
56
src/test/run-pass/issue-13494.rs
Normal 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();
|
||||
}
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue