#include "perfetto/ext/tracing/core/shared_memory_abi.h"
#include "perfetto/base/build_config.h"
#include "perfetto/base/time.h"
#if !PERFETTO_BUILDFLAG(PERFETTO_OS_WIN)
#include <sys/mman.h>
#endif
#include "perfetto/ext/base/utils.h"
#include "perfetto/ext/tracing/core/basic_types.h"
namespace perfetto {
namespace {
constexpr int kRetryAttempts = …;
inline void WaitBeforeNextAttempt(int attempt) { … }
constexpr size_t GetChunkSize(size_t page_size, size_t divider) { … }
std::array<uint16_t, SharedMemoryABI::kNumPageLayouts> InitChunkSizes(
size_t page_size) { … }
inline void ClearChunkHeader(SharedMemoryABI::ChunkHeader* header) { … }
}
SharedMemoryABI::SharedMemoryABI() = default;
SharedMemoryABI::SharedMemoryABI(uint8_t* start,
size_t size,
size_t page_size,
ShmemMode mode) { … }
void SharedMemoryABI::Initialize(uint8_t* start,
size_t size,
size_t page_size,
ShmemMode mode) { … }
SharedMemoryABI::Chunk SharedMemoryABI::GetChunkUnchecked(size_t page_idx,
uint32_t page_layout,
size_t chunk_idx) { … }
SharedMemoryABI::Chunk SharedMemoryABI::TryAcquireChunk(
size_t page_idx,
size_t chunk_idx,
ChunkState desired_chunk_state,
const ChunkHeader* header) { … }
bool SharedMemoryABI::TryPartitionPage(size_t page_idx, PageLayout layout) { … }
uint32_t SharedMemoryABI::GetFreeChunks(size_t page_idx) { … }
size_t SharedMemoryABI::ReleaseChunk(Chunk chunk,
ChunkState desired_chunk_state) { … }
SharedMemoryABI::Chunk::Chunk() = default;
SharedMemoryABI::Chunk::Chunk(uint8_t* begin, uint16_t size, uint8_t chunk_idx)
: … { … }
SharedMemoryABI::Chunk::Chunk(Chunk&& o) noexcept { … }
SharedMemoryABI::Chunk& SharedMemoryABI::Chunk::operator=(Chunk&& o) { … }
std::pair<size_t, size_t> SharedMemoryABI::GetPageAndChunkIndex(
const Chunk& chunk) { … }
}