mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-24 22:21:32 +00:00
Protect::ReadWriteExec is readable and writable.
Also assert that page size is a power of two in two places we assume it is.
This commit is contained in:
@ -261,14 +261,14 @@ impl Protect {
|
|||||||
|
|
||||||
pub fn is_readable(self) -> bool {
|
pub fn is_readable(self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
Protect::Read | Protect::ReadWrite | Protect::ReadExec => true,
|
Protect::Read | Protect::ReadWrite | Protect::ReadExec | Protect::ReadWriteExec => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_writable(self) -> bool {
|
pub fn is_writable(self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
Protect::ReadWrite => true,
|
Protect::ReadWrite | Protect::ReadWriteExec => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -297,10 +297,12 @@ impl Drop for RawFd {
|
|||||||
|
|
||||||
/// Round `size` up to the nearest multiple of `page_size`.
|
/// Round `size` up to the nearest multiple of `page_size`.
|
||||||
fn round_up_to_page_size(size: usize, page_size: usize) -> usize {
|
fn round_up_to_page_size(size: usize, page_size: usize) -> usize {
|
||||||
|
assert!(page_size.is_power_of_two());
|
||||||
(size + (page_size - 1)) & !(page_size - 1)
|
(size + (page_size - 1)) & !(page_size - 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Round `size` down to the nearest multiple of `page_size`.
|
/// Round `size` down to the nearest multiple of `page_size`.
|
||||||
fn round_down_to_page_size(size: usize, page_size: usize) -> usize {
|
fn round_down_to_page_size(size: usize, page_size: usize) -> usize {
|
||||||
|
assert!(page_size.is_power_of_two());
|
||||||
size & !(page_size - 1)
|
size & !(page_size - 1)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user