/
githubmirror
/
nbs
Обзор
Документация
Войти
/
githubmirror
/
nbs
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
util/system/mincore.cpp
33 строки
889 B
qkrorlqr
Initial NBS OpenSource export
28 апр 2023, 21:54
28 апр 2023, 21:54
783a858
Код
Авторство
О чём код?
#include "align.h" #include "info.h" #include "mincore.h" #include <util/generic/yexception.h> #include <cstring> #if defined(_unix_) #include <sys/mman.h> #if defined(_android_) #include <sys/syscall.h> #endif #endif void InCoreMemory(const void* addr, size_t len, unsigned char* vec, size_t vecLen) { #if defined(_linux_) const size_t pageSize = NSystemInfo::GetPageSize(); void* maddr = const_cast<void*>(AlignDown(addr, pageSize)); len = AlignUp(len, pageSize); if (vecLen * pageSize < len) { ythrow yexception() << "vector argument for mincore is too small: " << vecLen * pageSize << " < " << len; } if (::mincore(maddr, len, vec)) { ythrow yexception() << LastSystemErrorText(); } #else // pessimistic assumption: nothing is in core Y_UNUSED(addr); Y_UNUSED(len); ::memset(vec, 0, vecLen); #endif }