MCPcopy Create free account
hub / github.com/catboost/catboost / CreateMapping

Method CreateMapping

util/system/filemap.cpp:129–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

127class TMemoryMap::TImpl: public TAtomicRefCount<TImpl> {
128public:
129 inline void CreateMapping() {
130#if defined(_win_)
131 Mapping_ = nullptr;
132 if (Length_) {
133 Mapping_ = CreateFileMapping(File_.GetHandle(), nullptr,
134 (Mode_ & oAccessMask) == TFileMap::oRdWr ? PAGE_READWRITE : PAGE_READONLY,
135 (DWORD)(Length_ >> 32), (DWORD)(Length_ & 0xFFFFFFFF), nullptr);
136 if (Mapping_ == nullptr) {
137 ythrow yexception() << "Can't create file mapping of '" << DbgName_ << "': " << LastSystemErrorText();
138 }
139 } else {
140 Mapping_ = MAP_FAILED;
141 }
142#elif defined(_unix_)
143 if (!(Mode_ & oNotGreedy)) {
144 PtrStart_ = mmap((caddr_t) nullptr, Length_, ModeToMmapProt(Mode_), ModeToMmapFlags(Mode_), File_.GetHandle(), 0);
145
146 if ((MAP_FAILED == PtrStart_) && Length_) {
147 ythrow yexception() << "Can't map " << (unsigned long)Length_ << " bytes of file '" << DbgName_ << "' at offset 0: " << LastSystemErrorText();
148 }
149 } else {
150 PtrStart_ = nullptr;
151 }
152#endif
153 }
154
155 void CheckFile() const {
156 if (!File_.IsOpen()) {

Callers

nothing calls this directly

Calls 4

ModeToMmapProtFunction · 0.85
ModeToMmapFlagsFunction · 0.85
LastSystemErrorTextFunction · 0.70
GetHandleMethod · 0.45

Tested by

no test coverage detected