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

Function CountMapped

library/cpp/coroutine/engine/stack/stack_utils.cpp:52–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50
51#ifdef _linux_
52 size_t CountMapped(char* alignedPtr, size_t numOfPages) noexcept {
53 Y_ABORT_UNLESS( !((size_t)alignedPtr & PageSizeMask) );
54 Y_ASSERT(numOfPages);
55
56 size_t result = 0;
57 unsigned char* mappedPages = (unsigned char*) calloc(numOfPages, numOfPages);
58 Y_ABORT_UNLESS(mappedPages);
59 Y_DEFER {
60 free(mappedPages);
61 };
62
63 if (!mincore((void*)alignedPtr, numOfPages * PageSize, mappedPages)) {
64 for (size_t i = 0; i < numOfPages; ++i) {
65 if (mappedPages[i] & 1) {
66 ++result;
67 }
68 }
69 } else {
70 Y_ASSERT(false);
71 return 0;
72 }
73
74 return result;
75 }
76
77#else
78 size_t CountMapped(char*, size_t) noexcept {

Callers 1

TESTFunction · 0.85

Calls 2

callocFunction · 0.50
freeFunction · 0.50

Tested by

no test coverage detected