blob: 8d7bb9414eb7b06d1398b5966d241b8df10235a5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
macro_rules! atomic_bits {
// the println macro cannot be rewritten because of the asm macro
($type:ty, $ldrex:expr, $strex:expr) => {
impl AtomicBits for $type {
unsafe fn load_excl(address: usize) -> Self {
let raw: $type;
asm!($ldrex
: "=r"(raw)
: "r"(address)
:
: "volatile");
raw
}
unsafe fn store_excl(self, address: usize) -> bool {
let status: $type;
println!("{}",
status);
status == 0
}
}
};
// the println macro should be rewritten here
($type:ty) => {
fn some_func(self) {
let status: $type;
println!("{}", status);
}
};
// unrewritale macro in func
($type:ty, $ldrex:expr) => {
unsafe fn load_excl(address: usize) -> Self {
let raw: $type;
asm!($ldrex
: "=r"(raw)
: "r"(address)
:
: "volatile");
raw
}
}
}
|