summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authoralivshits <[email protected]>2022-02-10 16:51:43 +0300
committerDaniil Cherednik <[email protected]>2022-02-10 16:51:43 +0300
commit9a3354258cc740927a49f403277c5ada11712452 (patch)
tree94baa3bb560391500e8d815fd8bf482b8dc1db4c /util
parentefc65bacee6120d0454d2fa4e003ebd4f3e0e5ff (diff)
Restoring authorship annotation for <[email protected]>. Commit 1 of 2.
Diffstat (limited to 'util')
-rw-r--r--util/system/filemap.cpp20
-rw-r--r--util/system/mlock.cpp74
-rw-r--r--util/system/mlock.h24
3 files changed, 59 insertions, 59 deletions
diff --git a/util/system/filemap.cpp b/util/system/filemap.cpp
index 7454a4cb948..a170b6028ef 100644
--- a/util/system/filemap.cpp
+++ b/util/system/filemap.cpp
@@ -297,7 +297,7 @@ public:
void Evict(void* ptr, size_t len) {
MadviseEvict(ptr, len);
}
-
+
void Evict() {
#if defined(_unix_)
// Evict(PtrStart_, Length_);
@@ -309,7 +309,7 @@ public:
if (Mapping_) {
::CloseHandle(Mapping_); // != FALSE
Mapping_ = nullptr;
- }
+ }
#elif defined(_unix_)
if (PtrStart_) {
munmap((caddr_t)PtrStart_, Length_);
@@ -411,14 +411,14 @@ void TMemoryMap::SetSequential() {
Impl_->SetSequential();
}
-void TMemoryMap::Evict(void* ptr, size_t len) {
- Impl_->Evict(ptr, len);
-}
-
-void TMemoryMap::Evict() {
- Impl_->Evict();
-}
-
+void TMemoryMap::Evict(void* ptr, size_t len) {
+ Impl_->Evict(ptr, len);
+}
+
+void TMemoryMap::Evict() {
+ Impl_->Evict();
+}
+
i64 TMemoryMap::Length() const noexcept {
return Impl_->Length();
}
diff --git a/util/system/mlock.cpp b/util/system/mlock.cpp
index 435338c98fb..6d5cbe18daa 100644
--- a/util/system/mlock.cpp
+++ b/util/system/mlock.cpp
@@ -1,10 +1,10 @@
-#include <util/generic/yexception.h>
-#include "align.h"
-#include "error.h"
-#include "info.h"
-#include "mlock.h"
-
-#if defined(_unix_)
+#include <util/generic/yexception.h>
+#include "align.h"
+#include "error.h"
+#include "info.h"
+#include "mlock.h"
+
+#if defined(_unix_)
#include <sys/mman.h>
#if !defined(MCL_ONFAULT) && defined(MCL_FUTURE) // Old glibc.
#define MCL_ONFAULT (MCL_FUTURE << 1)
@@ -13,45 +13,45 @@
#include <sys/syscall.h>
#define munlockall() syscall(__NR_munlockall)
#endif
-#else
+#else
#include "winint.h"
-#endif
-
+#endif
+
void LockMemory(const void* addr, size_t len) {
-#if defined(_unix_)
- const size_t pageSize = NSystemInfo::GetPageSize();
+#if defined(_unix_)
+ const size_t pageSize = NSystemInfo::GetPageSize();
if (mlock(AlignDown(addr, pageSize), AlignUp(len, pageSize))) {
ythrow yexception() << LastSystemErrorText();
}
-#elif defined(_win_)
- HANDLE hndl = GetCurrentProcess();
- SIZE_T min, max;
+#elif defined(_win_)
+ HANDLE hndl = GetCurrentProcess();
+ SIZE_T min, max;
if (!GetProcessWorkingSetSize(hndl, &min, &max))
- ythrow yexception() << LastSystemErrorText();
- if (!SetProcessWorkingSetSize(hndl, min + len, max + len))
- ythrow yexception() << LastSystemErrorText();
+ ythrow yexception() << LastSystemErrorText();
+ if (!SetProcessWorkingSetSize(hndl, min + len, max + len))
+ ythrow yexception() << LastSystemErrorText();
if (!VirtualLock((LPVOID)addr, len))
- ythrow yexception() << LastSystemErrorText();
-#endif
-}
-
+ ythrow yexception() << LastSystemErrorText();
+#endif
+}
+
void UnlockMemory(const void* addr, size_t len) {
-#if defined(_unix_)
+#if defined(_unix_)
if (munlock(addr, len)) {
- ythrow yexception() << LastSystemErrorText();
+ ythrow yexception() << LastSystemErrorText();
}
-#elif defined(_win_)
- HANDLE hndl = GetCurrentProcess();
- SIZE_T min, max;
+#elif defined(_win_)
+ HANDLE hndl = GetCurrentProcess();
+ SIZE_T min, max;
if (!GetProcessWorkingSetSize(hndl, &min, &max))
- ythrow yexception() << LastSystemErrorText();
- if (!SetProcessWorkingSetSize(hndl, min - len, max - len))
- ythrow yexception() << LastSystemErrorText();
+ ythrow yexception() << LastSystemErrorText();
+ if (!SetProcessWorkingSetSize(hndl, min - len, max - len))
+ ythrow yexception() << LastSystemErrorText();
if (!VirtualUnlock((LPVOID)addr, len))
- ythrow yexception() << LastSystemErrorText();
-#endif
-}
-
+ ythrow yexception() << LastSystemErrorText();
+#endif
+}
+
void LockAllMemory(ELockAllMemoryFlags flags) {
Y_UNUSED(flags);
#if defined(_android_)
@@ -80,7 +80,7 @@ void UnlockAllMemory() {
// unimplemented
#elif defined(_unix_)
if (munlockall()) {
- ythrow yexception() << LastSystemErrorText();
+ ythrow yexception() << LastSystemErrorText();
}
-#endif
-}
+#endif
+}
diff --git a/util/system/mlock.h b/util/system/mlock.h
index f021c0fe670..e401f27e4c9 100644
--- a/util/system/mlock.h
+++ b/util/system/mlock.h
@@ -1,18 +1,18 @@
-#pragma once
-
-#include "defaults.h"
-
+#pragma once
+
+#include "defaults.h"
+
#include <util/generic/flags.h>
-//on some systems (not win, freebd, linux, but darwin (Mac OS X)
-//multiple mlock calls on the same address range
-//require the corresponding number of munlock calls to actually unlock the pages
-
-//on some systems you must have privilege and resource limit
-
+//on some systems (not win, freebd, linux, but darwin (Mac OS X)
+//multiple mlock calls on the same address range
+//require the corresponding number of munlock calls to actually unlock the pages
+
+//on some systems you must have privilege and resource limit
+
void LockMemory(const void* addr, size_t len);
void UnlockMemory(const void* addr, size_t len);
-
+
enum ELockAllMemoryFlag {
/** Lock all pages which are currently mapped into the address space of the process. */
LockCurrentMemory = 1,
@@ -40,4 +40,4 @@ void LockAllMemory(ELockAllMemoryFlags flags);
*
* Does nothing on windows.
*/
-void UnlockAllMemory();
+void UnlockAllMemory();