Convert over some residual uses of #oldmacros.

This commit is contained in:
Graydon Hoare 2012-08-27 13:50:40 -07:00
parent 38fee9526a
commit 5d56da1678
3 changed files with 29 additions and 19 deletions

View file

@ -131,24 +131,34 @@ impl &SipState : io::Writer {
// Methods for io::writer
fn write(msg: &[const u8]) {
#macro[[#u8to64_le(buf,i),
(buf[0+i] as u64 |
buf[1+i] as u64 << 8 |
buf[2+i] as u64 << 16 |
buf[3+i] as u64 << 24 |
buf[4+i] as u64 << 32 |
buf[5+i] as u64 << 40 |
buf[6+i] as u64 << 48 |
buf[7+i] as u64 << 56)]];
macro_rules! u8to64_le (
($buf:expr, $i:expr) =>
($buf[0+$i] as u64 |
$buf[1+$i] as u64 << 8 |
$buf[2+$i] as u64 << 16 |
$buf[3+$i] as u64 << 24 |
$buf[4+$i] as u64 << 32 |
$buf[5+$i] as u64 << 40 |
$buf[6+$i] as u64 << 48 |
$buf[7+$i] as u64 << 56)
);
#macro[[#rotl(x,b), (x << b) | (x >> (64 - b))]];
macro_rules! rotl (
($x:expr, $b:expr) =>
(($x << $b) | ($x >> (64 - $b)))
);
#macro[[#compress(v0,v1,v2,v3), {
v0 += v1; v1 = #rotl(v1, 13); v1 ^= v0; v0 = #rotl(v0, 32);
v2 += v3; v3 = #rotl(v3, 16); v3 ^= v2;
v0 += v3; v3 = #rotl(v3, 21); v3 ^= v0;
v2 += v1; v1 = #rotl(v1, 17); v1 ^= v2; v2 = #rotl(v2, 32);
}]];
macro_rules! compress (
($v0:expr, $v1:expr, $v2:expr, $v3:expr) =>
{
$v0 += $v1; $v1 = rotl!($v1, 13); $v1 ^= $v0;
$v0 = rotl!($v0, 32);
$v2 += $v3; $v3 = rotl!($v3, 16); $v3 ^= $v2;
$v0 += $v3; $v3 = rotl!($v3, 21); $v3 ^= $v0;
$v2 += $v1; $v1 = rotl!($v1, 17); $v1 ^= $v2;
$v2 = rotl!($v2, 32);
}
);
let length = msg.len();
self.length += length;

View file

@ -321,8 +321,8 @@ fn program_output(prog: &str, args: &[~str]) ->
errs = s;
}
(n, _) => {
fail(#fmt("program_output received an unexpected file \
number: %u", n));
fail(fmt!("program_output received an unexpected file \
number: %u", n));
}
};
count -= 1;

View file

@ -541,7 +541,7 @@ fn pop<T>(&v: ~[const T]) -> T {
fn swap_remove<T>(&v: ~[const T], index: uint) -> T {
let ln = len(v);
if index >= ln {
fail #fmt("vec::swap_remove - index %u >= length %u", index, ln);
fail fmt!("vec::swap_remove - index %u >= length %u", index, ln);
}
let lastptr = ptr::mut_addr_of(v[ln - 1]);
unsafe {