Skip to content

Commit 5df010d

Browse files
committed
Tweak the constraint on pages_[de]hugify.
1 parent f0c360c commit 5df010d

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

sdlib/d/gc/memmap.d

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -133,21 +133,18 @@ void pages_zero(void* addr, size_t size) {
133133
* check for the first case, that the page is not aligned or the size is
134134
* negative (which is odd, since size_t is unsigned, even in C).
135135
*/
136+
bool pages_hugify(void* addr, size_t size) {
137+
assert(isAligned(addr, BlockSize), "Invalid addr!");
138+
assert(size > 0 && isAligned(size, BlockSize), "Invalid size!");
136139

137-
void pages_hugify(void* addr, size_t size) {
138-
assert(isAligned(addr, PageSize), "Not aligned!");
139-
assert(cast(long) size > 0, "Negative size!");
140-
auto ret = madvise(addr, size, Madv.HugePage);
141-
// See note above.
142-
// assert(ret == 0, "madvise failed!");
140+
return madvise(addr, size, Madv.HugePage) != 0;
143141
}
144142

145-
void pages_dehugify(void* addr, size_t size) {
146-
assert(isAligned(addr, PageSize), "Not aligned!");
147-
assert(cast(long) size > 0, "Negative size!");
148-
auto ret = madvise(addr, size, Madv.NoHugePage);
149-
// See note above.
150-
//assert(ret == 0, "madvise failed!");
143+
bool pages_dehugify(void* addr, size_t size) {
144+
assert(isAligned(addr, BlockSize), "Invalid addr!");
145+
assert(size > 0 && isAligned(size, BlockSize), "Invalid size!");
146+
147+
return madvise(addr, size, Madv.NoHugePage) != 0;
151148
}
152149

153150
private:

0 commit comments

Comments
 (0)