1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:58:12 +00:00

Kernel+LibC: Allow sys$mmap() callers to specify address alignment

This is exposed via the non-standard serenity_mmap() call in userspace.
This commit is contained in:
Andreas Kling 2020-02-16 12:55:56 +01:00
parent 02e199a9cb
commit 31e1af732f
7 changed files with 66 additions and 30 deletions

View file

@ -32,14 +32,9 @@
extern "C" {
void* mmap(void* addr, size_t size, int prot, int flags, int fd, off_t offset)
void* serenity_mmap(void* addr, size_t size, int prot, int flags, int fd, off_t offset, size_t alignment, const char* name)
{
return mmap_with_name(addr, size, prot, flags, fd, offset, nullptr);
}
void* mmap_with_name(void* addr, size_t size, int prot, int flags, int fd, off_t offset, const char* name)
{
Syscall::SC_mmap_params params { (u32)addr, size, prot, flags, fd, offset, { name, name ? strlen(name) : 0 } };
Syscall::SC_mmap_params params { (u32)addr, size, alignment, prot, flags, fd, offset, { name, name ? strlen(name) : 0 } };
int rc = syscall(SC_mmap, &params);
if (rc < 0 && -rc < EMAXERRNO) {
errno = -rc;
@ -48,6 +43,16 @@ void* mmap_with_name(void* addr, size_t size, int prot, int flags, int fd, off_t
return (void*)rc;
}
void* mmap(void* addr, size_t size, int prot, int flags, int fd, off_t offset)
{
return serenity_mmap(addr, size, prot, flags, fd, offset, PAGE_SIZE, nullptr);
}
void* mmap_with_name(void* addr, size_t size, int prot, int flags, int fd, off_t offset, const char* name)
{
return serenity_mmap(addr, size, prot, flags, fd, offset, PAGE_SIZE, name);
}
int munmap(void* addr, size_t size)
{
int rc = syscall(SC_munmap, addr, size);