replace assert with SNMALLOC_ASSERT
This commit is contained in:
@@ -2,11 +2,6 @@
|
||||
|
||||
#include "pal_consts.h"
|
||||
|
||||
namespace snmalloc
|
||||
{
|
||||
void error(const char* const str);
|
||||
} // namespace snmalloc
|
||||
|
||||
// If simultating OE, then we need the underlying platform
|
||||
#if !defined(OPEN_ENCLAVE) || defined(OPEN_ENCLAVE_SIMULATION)
|
||||
# include "pal_apple.h"
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace snmalloc
|
||||
{
|
||||
if (page_aligned || is_aligned_block<OS_PAGE_SIZE>(p, size))
|
||||
{
|
||||
assert(is_aligned_block<OS_PAGE_SIZE>(p, size));
|
||||
SNMALLOC_ASSERT(is_aligned_block<OS_PAGE_SIZE>(p, size));
|
||||
void* r = mmap(
|
||||
p,
|
||||
size,
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace snmalloc
|
||||
*/
|
||||
void notify_not_using(void* p, size_t size) noexcept
|
||||
{
|
||||
assert(is_aligned_block<OS_PAGE_SIZE>(p, size));
|
||||
SNMALLOC_ASSERT(is_aligned_block<OS_PAGE_SIZE>(p, size));
|
||||
madvise(p, size, MADV_FREE);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace snmalloc
|
||||
void* reserve(size_t size, size_t align) noexcept
|
||||
{
|
||||
// Alignment must be a power of 2.
|
||||
assert(align == bits::next_pow2(align));
|
||||
SNMALLOC_ASSERT(align == bits::next_pow2(align));
|
||||
|
||||
align = bits::max<size_t>(4096, align);
|
||||
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "../ds/defines.h"
|
||||
|
||||
#include <atomic>
|
||||
|
||||
namespace snmalloc
|
||||
{
|
||||
/**
|
||||
@@ -112,4 +116,4 @@ namespace snmalloc
|
||||
}
|
||||
}
|
||||
};
|
||||
} // namespace snmalloc
|
||||
} // namespace snmalloc
|
||||
@@ -39,7 +39,7 @@ namespace snmalloc
|
||||
{
|
||||
if (page_aligned || is_aligned_block<OS_PAGE_SIZE>(p, size))
|
||||
{
|
||||
assert(is_aligned_block<OS_PAGE_SIZE>(p, size));
|
||||
SNMALLOC_ASSERT(is_aligned_block<OS_PAGE_SIZE>(p, size));
|
||||
madvise(p, size, MADV_DONTNEED);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace snmalloc
|
||||
*/
|
||||
void notify_not_using(void* p, size_t size) noexcept
|
||||
{
|
||||
assert(is_aligned_block<OS_PAGE_SIZE>(p, size));
|
||||
SNMALLOC_ASSERT(is_aligned_block<OS_PAGE_SIZE>(p, size));
|
||||
#ifdef USE_POSIX_COMMIT_CHECKS
|
||||
mprotect(p, size, PROT_NONE);
|
||||
#else
|
||||
@@ -72,7 +72,8 @@ namespace snmalloc
|
||||
template<ZeroMem zero_mem>
|
||||
void notify_using(void* p, size_t size) noexcept
|
||||
{
|
||||
assert(is_aligned_block<OS_PAGE_SIZE>(p, size) || (zero_mem == NoZero));
|
||||
SNMALLOC_ASSERT(
|
||||
is_aligned_block<OS_PAGE_SIZE>(p, size) || (zero_mem == NoZero));
|
||||
|
||||
if constexpr (zero_mem == YesZero)
|
||||
static_cast<OS*>(this)->template zero<true>(p, size);
|
||||
@@ -101,7 +102,7 @@ namespace snmalloc
|
||||
{
|
||||
if (page_aligned || is_aligned_block<OS_PAGE_SIZE>(p, size))
|
||||
{
|
||||
assert(is_aligned_block<OS_PAGE_SIZE>(p, size));
|
||||
SNMALLOC_ASSERT(is_aligned_block<OS_PAGE_SIZE>(p, size));
|
||||
void* r = mmap(
|
||||
p,
|
||||
size,
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace snmalloc
|
||||
/// Notify platform that we will not be using these pages
|
||||
void notify_not_using(void* p, size_t size) noexcept
|
||||
{
|
||||
assert(is_aligned_block<OS_PAGE_SIZE>(p, size));
|
||||
SNMALLOC_ASSERT(is_aligned_block<OS_PAGE_SIZE>(p, size));
|
||||
|
||||
BOOL ok = VirtualFree(p, size, MEM_DECOMMIT);
|
||||
|
||||
@@ -122,7 +122,8 @@ namespace snmalloc
|
||||
template<ZeroMem zero_mem>
|
||||
void notify_using(void* p, size_t size) noexcept
|
||||
{
|
||||
assert(is_aligned_block<OS_PAGE_SIZE>(p, size) || (zero_mem == NoZero));
|
||||
SNMALLOC_ASSERT(
|
||||
is_aligned_block<OS_PAGE_SIZE>(p, size) || (zero_mem == NoZero));
|
||||
|
||||
void* r = VirtualAlloc(p, size, MEM_COMMIT, PAGE_READWRITE);
|
||||
|
||||
@@ -136,7 +137,7 @@ namespace snmalloc
|
||||
{
|
||||
if (page_aligned || is_aligned_block<OS_PAGE_SIZE>(p, size))
|
||||
{
|
||||
assert(is_aligned_block<OS_PAGE_SIZE>(p, size));
|
||||
SNMALLOC_ASSERT(is_aligned_block<OS_PAGE_SIZE>(p, size));
|
||||
notify_not_using(p, size);
|
||||
notify_using<YesZero>(p, size);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user