zephyr/lib/posix/options/mlock.c
Chris Friedt 8609a05236 posix: options: mlock: refine imply for MMU and DEMAND_PAGING
POSIX mlock() and munlock() require an MMU as well as
DEMAND_PAGING.

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2025-01-11 18:31:02 +01:00

40 lines
614 B
C

/*
* Copyright (c) 2024, Tenstorrent AI ULC
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stddef.h>
#include <zephyr/kernel.h>
#include <zephyr/posix/sys/mman.h>
#include <zephyr/kernel/mm/demand_paging.h>
int mlock(const void *addr, size_t len)
{
if (IS_ENABLED(CONFIG_DEMAND_PAGING)) {
void *const _addr = (void *)addr;
k_mem_pin(_addr, len);
return 0;
}
errno = ENOTSUP;
return -1;
}
int munlock(const void *addr, size_t len)
{
if (IS_ENABLED(CONFIG_DEMAND_PAGING)) {
void *const _addr = (void *)addr;
k_mem_unpin(_addr, len);
return 0;
}
errno = ENOTSUP;
return -1;
}