We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4b61a21 commit 111fa41Copy full SHA for 111fa41
lib/Utils/PlatformPosix.cpp
@@ -58,9 +58,9 @@ namespace {
58
}
59
60
public:
61
- PointerCheck() {
62
- page_size = ::sysconf(_SC_PAGESIZE);
63
- page_mask = ~(page_size - 1);
+ PointerCheck() : page_size(::sysconf(_SC_PAGESIZE)), page_mask(~(page_size - 1))
+ {
+ assert(IsPowerOfTwo(page_size));
64
65
66
bool operator () (const void* P) {
@@ -81,6 +81,13 @@ namespace {
81
push(P);
82
return true;
83
84
+ private:
85
+ bool IsPowerOfTwo(size_t n) {
86
+ /* While n is even and larger than 1, divide by 2 */
87
+ while (((n & 1) == 0) && n > 1)
88
+ n >>= 1;
89
+ return n == 1;
90
+ }
91
};
92
thread_local std::array<const void*, 8> PointerCheck::lines = {};
93
thread_local unsigned PointerCheck::mostRecent = 0;
0 commit comments