mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-04 15:19:42 +00:00
LibCore/System: Add mmap, munmap for Windows
This commit is contained in:
parent
4ae3a0dcba
commit
3f7affa825
Notes:
github-actions[bot]
2024-11-26 09:01:21 +00:00
Author: https://github.com/stasoid
Commit: 3f7affa825
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2353
Reviewed-by: https://github.com/ADKaster ✅
4 changed files with 28 additions and 0 deletions
|
@ -15,6 +15,7 @@
|
|||
#include <Windows.h>
|
||||
#include <direct.h>
|
||||
#include <io.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
namespace Core::System {
|
||||
|
||||
|
@ -166,4 +167,21 @@ ErrorOr<struct stat> fstatat(int, StringView, int)
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
ErrorOr<void*> mmap(void* address, size_t size, int protection, int flags, int fd, off_t offset, size_t alignment, StringView)
|
||||
{
|
||||
// custom alignment is not supported
|
||||
VERIFY(!alignment);
|
||||
void* ptr = ::mmap(address, size, protection, flags, fd, offset);
|
||||
if (ptr == MAP_FAILED)
|
||||
return Error::from_syscall("mmap"sv, -errno);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
ErrorOr<void> munmap(void* address, size_t size)
|
||||
{
|
||||
if (::munmap(address, size) < 0)
|
||||
return Error::from_syscall("munmap"sv, -errno);
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue