Skip to content

Commit

Permalink
options/posix: move mremap and remap_file_pages to the linux option
Browse files Browse the repository at this point in the history
  • Loading branch information
streaksu committed Feb 6, 2025
1 parent f02c85c commit 7f05871
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
34 changes: 17 additions & 17 deletions options/posix/generic/sys-mman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,23 +70,6 @@ int msync(void *addr, size_t length, int flags) {
return 0;
}

void *mremap(void *pointer, size_t size, size_t new_size, int flags, ...) {
__ensure(flags == MREMAP_MAYMOVE);

void *window;
MLIBC_CHECK_OR_ENOSYS(mlibc::sys_vm_remap, (void *)-1);
if(int e = mlibc::sys_vm_remap(pointer, size, new_size, &window); e) {
errno = e;
return (void *)-1;
}
return window;
}

int remap_file_pages(void *, size_t, int, size_t, int) {
__ensure(!"Not implemented");
__builtin_unreachable();
}

void *mmap(void *hint, size_t size, int prot, int flags, int fd, off_t offset) {
void *window;
if(int e = mlibc::sys_vm_map(hint, size, prot, flags, fd, offset, &window); e) {
Expand Down Expand Up @@ -146,6 +129,23 @@ int shm_unlink(const char *name) {
}

#if __MLIBC_LINUX_OPTION
void *mremap(void *pointer, size_t size, size_t new_size, int flags, ...) {
__ensure(flags == MREMAP_MAYMOVE);

void *window;
MLIBC_CHECK_OR_ENOSYS(mlibc::sys_vm_remap, (void *)-1);
if(int e = mlibc::sys_vm_remap(pointer, size, new_size, &window); e) {
errno = e;
return (void *)-1;
}
return window;
}

int remap_file_pages(void *, size_t, int, size_t, int) {
__ensure(!"Not implemented");
__builtin_unreachable();
}

int memfd_create(const char *name, unsigned int flags) {
int ret = -1;

Expand Down
4 changes: 1 addition & 3 deletions options/posix/include/sys/mman.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@ int msync(void *__addr, size_t __size, int __flags);
int shm_open(const char *__name, int __oflag, mode_t __mode);
int shm_unlink(const char *__name);

/* Linux extension: */
#if __MLIBC_LINUX_OPTION
void *mremap(void *__old_address, size_t __old_size, size_t __new_size, int __flags, ...);
int remap_file_pages(void *__addr, size_t __size, int __prot, size_t __pgoff, int __flags);

#if __MLIBC_LINUX_OPTION
int memfd_create(const char *__name, unsigned int __flags);
int madvise(void *__addr, size_t __size, int __advise);
int mincore(void *__addr, size_t __size, unsigned char *__vec);
Expand Down

0 comments on commit 7f05871

Please sign in to comment.