forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request rust-lang#3001 from scampi/issue2977
propagate errors about failing to rewrite a macro
- Loading branch information
Showing
9 changed files
with
236 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
macro_rules! atomic_bits { | ||
// the println macro cannot be rewritten because of the asm macro | ||
($type:ty, $ldrex:expr, $strex:expr) => { | ||
trait $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 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
macro_rules! atomic_bits { | ||
($ldrex:expr) => { | ||
execute(|| { | ||
asm!($ldrex | ||
: "=r"(raw) | ||
: "r"(address) | ||
: | ||
: "volatile"); | ||
}) | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
macro_rules! atomic_bits { | ||
($ldrex:expr) => { | ||
some_macro!(pub fn foo() { | ||
asm!($ldrex | ||
: "=r"(raw) | ||
: "r"(address) | ||
: | ||
: "volatile"); | ||
}) | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
macro_rules! atomic_bits { | ||
// the println macro cannot be rewritten because of the asm macro | ||
($type:ty, $ldrex:expr, $strex:expr) => { | ||
trait $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 | ||
} | ||
} | ||
} |