87 #ifndef MEMUTILS_MEMORYCHUNK_H
88 #define MEMUTILS_MEMORYCHUNK_H
96 #define MEMORYCHUNK_MAX_VALUE UINT64CONST(0x3FFFFFFF)
102 #define MEMORYCHUNK_MAX_BLOCKOFFSET UINT64CONST(0x3FFFFFFF)
108 #define MEMORYCHUNK_BLOCKOFFSET_MASK UINT64CONST(0x3FFFFFFE)
111 #define MEMORYCHUNK_EXTERNAL_BASEBIT MEMORY_CONTEXT_METHODID_BITS
112 #define MEMORYCHUNK_VALUE_BASEBIT (MEMORYCHUNK_EXTERNAL_BASEBIT + 1)
113 #define MEMORYCHUNK_BLOCKOFFSET_BASEBIT (MEMORYCHUNK_VALUE_BASEBIT + 29)
120 #define MEMORYCHUNK_MAGIC (UINT64CONST(0xB1A8DB858EB6EFBA) >> \
121 MEMORYCHUNK_VALUE_BASEBIT << \
122 MEMORYCHUNK_VALUE_BASEBIT)
126 #ifdef MEMORY_CONTEXT_CHECKING
135 #define PointerGetMemoryChunk(p) \
136 ((MemoryChunk *) ((char *) (p) - sizeof(MemoryChunk)))
138 #define MemoryChunkGetPointer(c) \
139 ((void *) ((char *) (c) + sizeof(MemoryChunk)))
142 #define HdrMaskIsExternal(hdrmask) \
143 ((hdrmask) & (((uint64) 1) << MEMORYCHUNK_EXTERNAL_BASEBIT))
144 #define HdrMaskGetValue(hdrmask) \
145 (((hdrmask) >> MEMORYCHUNK_VALUE_BASEBIT) & MEMORYCHUNK_MAX_VALUE)
151 #define HdrMaskBlockOffset(hdrmask) \
152 (((hdrmask) >> MEMORYCHUNK_BLOCKOFFSET_BASEBIT) & MEMORYCHUNK_BLOCKOFFSET_MASK)
155 #define HdrMaskCheckMagic(hdrmask) \
156 (MEMORYCHUNK_MAGIC == \
157 ((hdrmask) >> MEMORYCHUNK_VALUE_BASEBIT << MEMORYCHUNK_VALUE_BASEBIT))
172 Size blockoffset = (
char *)
chunk - (
char *) block;
243 #undef MEMORYCHUNK_BLOCKOFFSET_MASK
244 #undef MEMORYCHUNK_EXTERNAL_BASEBIT
245 #undef MEMORYCHUNK_VALUE_BASEBIT
246 #undef MEMORYCHUNK_BLOCKOFFSET_BASEBIT
247 #undef MEMORYCHUNK_MAGIC
248 #undef HdrMaskIsExternal
249 #undef HdrMaskGetValue
250 #undef HdrMaskBlockOffset
251 #undef HdrMaskCheckMagic
#define Assert(condition)
#define MEMORY_CONTEXT_METHODID_MASK
#define MEMORYCHUNK_MAX_VALUE
static Size MemoryChunkGetValue(MemoryChunk *chunk)
#define MEMORYCHUNK_VALUE_BASEBIT
#define MEMORYCHUNK_BLOCKOFFSET_MASK
#define MEMORYCHUNK_EXTERNAL_BASEBIT
#define HdrMaskBlockOffset(hdrmask)
static bool MemoryChunkIsExternal(MemoryChunk *chunk)
static void MemoryChunkSetHdrMaskExternal(MemoryChunk *chunk, MemoryContextMethodID methodid)
#define HdrMaskCheckMagic(hdrmask)
#define HdrMaskIsExternal(hdrmask)
struct MemoryChunk MemoryChunk
#define MEMORYCHUNK_BLOCKOFFSET_BASEBIT
static void * MemoryChunkGetBlock(MemoryChunk *chunk)
static void MemoryChunkSetHdrMask(MemoryChunk *chunk, void *block, Size value, MemoryContextMethodID methodid)
#define MEMORYCHUNK_MAGIC
#define HdrMaskGetValue(hdrmask)