#ifndef PARTITION_ALLOC_PARTITION_ALLOC_INL_H_
#define PARTITION_ALLOC_PARTITION_ALLOC_INL_H_
#include <algorithm>
#include <cstring>
#include "partition_alloc/build_config.h"
#include "partition_alloc/buildflags.h"
#include "partition_alloc/in_slot_metadata.h"
#include "partition_alloc/partition_alloc_base/compiler_specific.h"
#include "partition_alloc/partition_alloc_config.h"
#include "partition_alloc/random.h"
#include "partition_alloc/tagging.h"
#include "partition_alloc/thread_isolation/thread_isolation.h"
#if defined(__clang__) || PA_BUILDFLAG(PA_COMPILER_GCC)
#define PA_PREFETCH(x) …
#else
#define PA_PREFETCH …
#endif
#if defined(__clang__) || PA_BUILDFLAG(PA_COMPILER_GCC)
#define PA_PREFETCH_FOR_WRITE(x) …
#else
#define PA_PREFETCH_FOR_WRITE …
#endif
namespace partition_alloc::internal {
#if PA_CONFIG(IS_NONCLANG_MSVC)
#pragma optimize("", off)
#endif
PA_ALWAYS_INLINE void SecureMemset(void* ptr, uint8_t value, size_t size) { … }
#if PA_CONFIG(IS_NONCLANG_MSVC)
#pragma optimize("", on)
#endif
#if PA_BUILDFLAG(EXPENSIVE_DCHECKS_ARE_ON)
PA_ALWAYS_INLINE void DebugMemset(void* ptr, int value, size_t size) { … }
#endif
#if !PA_BUILDFLAG(DCHECKS_ARE_ON)
PA_ALWAYS_INLINE bool RandomPeriod() {
static thread_local uint8_t counter = 0;
if (counter == 0) [[unlikely]] {
counter = static_cast<uint8_t>(RandomValue());
}
counter--;
return counter == 0;
}
#endif
PA_ALWAYS_INLINE uintptr_t ObjectInnerPtr2Addr(const void* ptr) { … }
PA_ALWAYS_INLINE uintptr_t ObjectPtr2Addr(const void* object) { … }
PA_ALWAYS_INLINE void* SlotStartAddr2Ptr(uintptr_t slot_start) { … }
PA_ALWAYS_INLINE uintptr_t SlotStartPtr2Addr(const void* slot_start) { … }
}
#endif