Skip to content

Commit 5d56da1

Browse files
committed
Convert over some residual uses of #oldmacros.
1 parent 38fee95 commit 5d56da1

File tree

3 files changed

+31
-21
lines changed

3 files changed

+31
-21
lines changed

src/libcore/hash.rs

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -131,24 +131,34 @@ impl &SipState : io::Writer {
131131
// Methods for io::writer
132132
fn write(msg: &[const u8]) {
133133

134-
#macro[[#u8to64_le(buf,i),
135-
(buf[0+i] as u64 |
136-
buf[1+i] as u64 << 8 |
137-
buf[2+i] as u64 << 16 |
138-
buf[3+i] as u64 << 24 |
139-
buf[4+i] as u64 << 32 |
140-
buf[5+i] as u64 << 40 |
141-
buf[6+i] as u64 << 48 |
142-
buf[7+i] as u64 << 56)]];
143-
144-
#macro[[#rotl(x,b), (x << b) | (x >> (64 - b))]];
145-
146-
#macro[[#compress(v0,v1,v2,v3), {
147-
v0 += v1; v1 = #rotl(v1, 13); v1 ^= v0; v0 = #rotl(v0, 32);
148-
v2 += v3; v3 = #rotl(v3, 16); v3 ^= v2;
149-
v0 += v3; v3 = #rotl(v3, 21); v3 ^= v0;
150-
v2 += v1; v1 = #rotl(v1, 17); v1 ^= v2; v2 = #rotl(v2, 32);
151-
}]];
134+
macro_rules! u8to64_le (
135+
($buf:expr, $i:expr) =>
136+
($buf[0+$i] as u64 |
137+
$buf[1+$i] as u64 << 8 |
138+
$buf[2+$i] as u64 << 16 |
139+
$buf[3+$i] as u64 << 24 |
140+
$buf[4+$i] as u64 << 32 |
141+
$buf[5+$i] as u64 << 40 |
142+
$buf[6+$i] as u64 << 48 |
143+
$buf[7+$i] as u64 << 56)
144+
);
145+
146+
macro_rules! rotl (
147+
($x:expr, $b:expr) =>
148+
(($x << $b) | ($x >> (64 - $b)))
149+
);
150+
151+
macro_rules! compress (
152+
($v0:expr, $v1:expr, $v2:expr, $v3:expr) =>
153+
{
154+
$v0 += $v1; $v1 = rotl!($v1, 13); $v1 ^= $v0;
155+
$v0 = rotl!($v0, 32);
156+
$v2 += $v3; $v3 = rotl!($v3, 16); $v3 ^= $v2;
157+
$v0 += $v3; $v3 = rotl!($v3, 21); $v3 ^= $v0;
158+
$v2 += $v1; $v1 = rotl!($v1, 17); $v1 ^= $v2;
159+
$v2 = rotl!($v2, 32);
160+
}
161+
);
152162

153163
let length = msg.len();
154164
self.length += length;

src/libcore/run.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,8 @@ fn program_output(prog: &str, args: &[~str]) ->
321321
errs = s;
322322
}
323323
(n, _) => {
324-
fail(#fmt("program_output received an unexpected file \
325-
number: %u", n));
324+
fail(fmt!("program_output received an unexpected file \
325+
number: %u", n));
326326
}
327327
};
328328
count -= 1;

src/libcore/vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ fn pop<T>(&v: ~[const T]) -> T {
541541
fn swap_remove<T>(&v: ~[const T], index: uint) -> T {
542542
let ln = len(v);
543543
if index >= ln {
544-
fail #fmt("vec::swap_remove - index %u >= length %u", index, ln);
544+
fail fmt!("vec::swap_remove - index %u >= length %u", index, ln);
545545
}
546546
let lastptr = ptr::mut_addr_of(v[ln - 1]);
547547
unsafe {

0 commit comments

Comments
 (0)