Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenBSD build fix proposal. #258

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/pal/pal_openbsd.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,28 @@ namespace snmalloc
* should add any required features.
*/
static constexpr uint64_t pal_features = PALBSD::pal_features;

/**
*
* On OpenBSD, pages seem not discarded in due time
* despite normally MADV_FREE is normally fast enough
* in other platforms, thus some unit tests are failing.
*
* Notifying by discarding access instead.
*/

static void notify_not_using(void* p, size_t size) noexcept
{
SNMALLOC_ASSERT(is_aligned_block<PALOpenBSD::page_size>(p, size));
mprotect(p, size, PROT_NONE);
}

template<ZeroMem zero_mem>
static void notify_using(void* p, size_t size)
{
SNMALLOC_ASSERT(is_aligned_block<PALOpenBSD::page_size>(p, size));
mprotect(p, size, PROT_READ | PROT_WRITE);
}
};
} // namespace snmalloc
#endif