mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-26 19:03:27 +00:00
Minor optimizations on both lat-syscall-stat
and lat-syscall-open
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
fc77c474db
commit
f2af6136da
@ -191,7 +191,7 @@ impl<'a> ReadCString for VmReader<'a, Fallible> {
|
||||
|
||||
// Handle the first few bytes to make `cur_addr` aligned with `size_of::<usize>`
|
||||
read_one_byte_at_a_time_while!(
|
||||
(self.cursor() as usize) % mem::size_of::<usize>() != 0 && buffer.len() < max_len
|
||||
!is_addr_aligned(self.cursor() as usize) && buffer.len() < max_len
|
||||
);
|
||||
|
||||
// Handle the rest of the bytes in bulk
|
||||
@ -253,3 +253,8 @@ fn check_vaddr(va: Vaddr) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// Checks if the given address is aligned.
|
||||
const fn is_addr_aligned(addr: usize) -> bool {
|
||||
(addr & (mem::size_of::<usize>() - 1)) == 0
|
||||
}
|
||||
|
Reference in New Issue
Block a user