mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 05:39:11 +00:00
UserspaceEmulator: Enable splitting regions at arbitrary points
This is not yet useful in and of itself, but enables the feature in the next commit.
This commit is contained in:
parent
7cc8f20a30
commit
45443f24ec
Notes:
sideshowbarker
2024-07-18 21:36:29 +09:00
Author: https://github.com/BenWiederhake
Commit: 45443f24ec
Pull-request: https://github.com/SerenityOS/serenity/pull/5697
Issue: https://github.com/SerenityOS/serenity/issues/5663
Reviewed-by: https://github.com/awesomekling
7 changed files with 66 additions and 2 deletions
|
@ -223,6 +223,19 @@ void MmapRegion::write64(u32 offset, ValueWithShadow<u64> value)
|
|||
*reinterpret_cast<u64*>(m_shadow_data + offset) = value.shadow();
|
||||
}
|
||||
|
||||
NonnullOwnPtr<MmapRegion> MmapRegion::split_at(VirtualAddress offset)
|
||||
{
|
||||
VERIFY(!m_malloc);
|
||||
VERIFY(!m_malloc_metadata);
|
||||
Range new_range = range();
|
||||
Range other_range = new_range.split_at(offset);
|
||||
auto other_region = adopt_own(*new MmapRegion(other_range.base().get(), other_range.size(), prot(), data() + new_range.size(), shadow_data() + new_range.size()));
|
||||
other_region->m_file_backed = m_file_backed;
|
||||
other_region->m_name = m_name;
|
||||
set_range(new_range);
|
||||
return other_region;
|
||||
}
|
||||
|
||||
void MmapRegion::set_prot(int prot)
|
||||
{
|
||||
set_readable(prot & PROT_READ);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue