Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

posix: options: mlock: refine imply for MMU and DEMAND_PAGING #83648

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/posix/options/Kconfig.mem
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ config POSIX_MEMLOCK

config POSIX_MEMLOCK_RANGE
bool "POSIX range memory locking"
imply MMU
imply MMU if (CPU_HAS_MMU && ARCH_HAS_DEMAND_PAGING)
imply DEMAND_PAGING
help
Select 'y' here and Zephyr will provide support for mlock() and munlock().
Expand Down
22 changes: 16 additions & 6 deletions lib/posix/options/mlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,28 @@

int mlock(const void *addr, size_t len)
{
void *const _addr = (void *)addr;
if (IS_ENABLED(CONFIG_DEMAND_PAGING)) {
void *const _addr = (void *)addr;

k_mem_pin(_addr, len);
k_mem_pin(_addr, len);

return 0;
return 0;
}

errno = ENOTSUP;
return -1;
}

int munlock(const void *addr, size_t len)
{
void *const _addr = (void *)addr;
if (IS_ENABLED(CONFIG_DEMAND_PAGING)) {
void *const _addr = (void *)addr;

k_mem_unpin(_addr, len);

k_mem_unpin(_addr, len);
return 0;
}

return 0;
errno = ENOTSUP;
return -1;
}
Loading