#ifndef SCUDO_CHUNK_H_
#define SCUDO_CHUNK_H_
#include "platform.h"
#include "atomic_helpers.h"
#include "checksum.h"
#include "common.h"
#include "report.h"
namespace scudo {
extern Checksum HashAlgorithm;
inline u16 computeChecksum(u32 Seed, uptr Value, uptr *Array, uptr ArraySize) { … }
namespace Chunk {
enum Origin : u8 { … };
enum State : u8 { … };
PackedHeader;
struct UnpackedHeader { … };
AtomicPackedHeader;
static_assert …;
constexpr uptr ClassIdMask = …;
constexpr u8 StateMask = …;
constexpr u8 OriginMask = …;
constexpr uptr SizeOrUnusedBytesMask = …;
constexpr uptr OffsetMask = …;
constexpr uptr ChecksumMask = …;
constexpr uptr getHeaderSize() { … }
inline AtomicPackedHeader *getAtomicHeader(void *Ptr) { … }
inline const AtomicPackedHeader *getConstAtomicHeader(const void *Ptr) { … }
static inline u16 computeHeaderChecksum(u32 Cookie, const void *Ptr,
UnpackedHeader *Header) { … }
inline void storeHeader(u32 Cookie, void *Ptr,
UnpackedHeader *NewUnpackedHeader) { … }
inline void loadHeader(u32 Cookie, const void *Ptr,
UnpackedHeader *NewUnpackedHeader) { … }
inline bool isValid(u32 Cookie, const void *Ptr,
UnpackedHeader *NewUnpackedHeader) { … }
}
}
#endif