aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkinan-sarmini <kinan-sarmini@yandex-team.ru>2022-02-10 16:51:47 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:51:47 +0300
commit68a7c0941a56f80e7e4a500f483ae9b33be1084c (patch)
treeab7fbbf3253d4c0e2793218f09378908beb025fb
parent3ceb84696d5141dce2da03d35b8040d6d932bb0c (diff)
downloadydb-68a7c0941a56f80e7e4a500f483ae9b33be1084c.tar.gz
Restoring authorship annotation for <kinan-sarmini@yandex-team.ru>. Commit 2 of 2.
-rw-r--r--util/system/filemap.cpp54
-rw-r--r--util/system/filemap.h2
-rw-r--r--util/system/filemap_ut.cpp20
3 files changed, 38 insertions, 38 deletions
diff --git a/util/system/filemap.cpp b/util/system/filemap.cpp
index 100cef7389..7454a4cb94 100644
--- a/util/system/filemap.cpp
+++ b/util/system/filemap.cpp
@@ -19,7 +19,7 @@
#endif
#define MAP_POPULATE 0
#endif
-
+
#if !defined(_freebsd_)
#ifdef MAP_NOCORE
#error unlisted platform supporting MAP_NOCORE
@@ -79,29 +79,29 @@ static inline i64 DownToGranularity(i64 offset) noexcept {
return offset & ~((i64)(GRANULARITY - 1));
}
-#if defined(_unix_)
-static int ModeToMmapFlags(TMemoryMapCommon::EOpenMode mode) {
- int flags = MAP_NOCORE;
- if ((mode & TMemoryMapCommon::oAccessMask) == TMemoryMapCommon::oCopyOnWr) {
- flags |= MAP_PRIVATE;
- } else {
- flags |= MAP_SHARED;
- }
- if (mode & TMemoryMapCommon::oPopulate) {
- flags |= MAP_POPULATE;
- }
- return flags;
-}
-
-static int ModeToMmapProt(TMemoryMapCommon::EOpenMode mode) {
- int prot = PROT_READ;
- if ((mode & TMemoryMapCommon::oAccessMask) != TMemoryMapCommon::oRdOnly) {
- prot |= PROT_WRITE;
- }
- return prot;
-}
-#endif
-
+#if defined(_unix_)
+static int ModeToMmapFlags(TMemoryMapCommon::EOpenMode mode) {
+ int flags = MAP_NOCORE;
+ if ((mode & TMemoryMapCommon::oAccessMask) == TMemoryMapCommon::oCopyOnWr) {
+ flags |= MAP_PRIVATE;
+ } else {
+ flags |= MAP_SHARED;
+ }
+ if (mode & TMemoryMapCommon::oPopulate) {
+ flags |= MAP_POPULATE;
+ }
+ return flags;
+}
+
+static int ModeToMmapProt(TMemoryMapCommon::EOpenMode mode) {
+ int prot = PROT_READ;
+ if ((mode & TMemoryMapCommon::oAccessMask) != TMemoryMapCommon::oRdOnly) {
+ prot |= PROT_WRITE;
+ }
+ return prot;
+}
+#endif
+
// maybe we should move this function to another .cpp file to avoid unwanted optimization?
void NPrivate::Precharge(const void* data, size_t dataSize, size_t off, size_t size) {
if (off > dataSize) {
@@ -141,8 +141,8 @@ public:
}
#elif defined(_unix_)
if (!(Mode_ & oNotGreedy)) {
- PtrStart_ = mmap((caddr_t) nullptr, Length_, ModeToMmapProt(Mode_), ModeToMmapFlags(Mode_), File_.GetHandle(), 0);
-
+ PtrStart_ = mmap((caddr_t) nullptr, Length_, ModeToMmapProt(Mode_), ModeToMmapFlags(Mode_), File_.GetHandle(), 0);
+
if ((MAP_FAILED == PtrStart_) && Length_) {
ythrow yexception() << "Can't map " << (unsigned long)Length_ << " bytes of file '" << DbgName_ << "' at offset 0: " << LastSystemErrorText();
}
@@ -244,7 +244,7 @@ public:
#if defined(_unix_)
if (Mode_ & oNotGreedy) {
#endif
- result.Ptr = mmap((caddr_t) nullptr, size, ModeToMmapProt(Mode_), ModeToMmapFlags(Mode_), File_.GetHandle(), base);
+ result.Ptr = mmap((caddr_t) nullptr, size, ModeToMmapProt(Mode_), ModeToMmapFlags(Mode_), File_.GetHandle(), base);
if (result.Ptr == (char*)(-1)) {
result.Ptr = nullptr;
diff --git a/util/system/filemap.h b/util/system/filemap.h
index 6b820824b2..11be64bff4 100644
--- a/util/system/filemap.h
+++ b/util/system/filemap.h
@@ -56,7 +56,7 @@ struct TMemoryMapCommon {
oAccessMask = 7,
oNotGreedy = 8,
oPrecharge = 16,
- oPopulate = 32, // Populate page table entries (see mmap's MAP_POPULATE)
+ oPopulate = 32, // Populate page table entries (see mmap's MAP_POPULATE)
};
Y_DECLARE_FLAGS(EOpenMode, EOpenModeFlag)
diff --git a/util/system/filemap_ut.cpp b/util/system/filemap_ut.cpp
index a42af17fb9..73f109dc88 100644
--- a/util/system/filemap_ut.cpp
+++ b/util/system/filemap_ut.cpp
@@ -14,7 +14,7 @@
Y_UNIT_TEST_SUITE(TFileMapTest) {
static const char* FileName_("./mappped_file");
- void BasicTest(TMemoryMapCommon::EOpenMode mode) {
+ void BasicTest(TMemoryMapCommon::EOpenMode mode) {
char data[] = "abcdefgh";
TFile file(FileName_, CreateAlways | WrOnly);
@@ -22,7 +22,7 @@ Y_UNIT_TEST_SUITE(TFileMapTest) {
file.Close();
{
- TFileMap mappedFile(FileName_, mode);
+ TFileMap mappedFile(FileName_, mode);
mappedFile.Map(0, mappedFile.Length());
UNIT_ASSERT(mappedFile.MappedSize() == sizeof(data) && mappedFile.Length() == sizeof(data));
UNIT_ASSERT(mappedFile.IsOpen());
@@ -51,14 +51,14 @@ Y_UNIT_TEST_SUITE(TFileMapTest) {
NFs::Remove(FileName_);
}
- Y_UNIT_TEST(TestFileMap) {
- BasicTest(TMemoryMapCommon::oRdWr);
- }
-
- Y_UNIT_TEST(TestFileMapPopulate) {
- BasicTest(TMemoryMapCommon::oRdWr | TMemoryMapCommon::oPopulate);
- }
-
+ Y_UNIT_TEST(TestFileMap) {
+ BasicTest(TMemoryMapCommon::oRdWr);
+ }
+
+ Y_UNIT_TEST(TestFileMapPopulate) {
+ BasicTest(TMemoryMapCommon::oRdWr | TMemoryMapCommon::oPopulate);
+ }
+
Y_UNIT_TEST(TestFileRemap) {
const char data1[] = "01234";
const char data2[] = "abcdefg";