PostgreSQL Source Code git master
Data Structures | Macros | Typedefs | Functions
memutils_memorychunk.h File Reference
#include "utils/memutils_internal.h"
Include dependency graph for memutils_memorychunk.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct   MemoryChunk
 

Macros

#define  MEMORYCHUNK_MAX_VALUE   UINT64CONST(0x3FFFFFFF)
 
#define  MEMORYCHUNK_MAX_BLOCKOFFSET   UINT64CONST(0x3FFFFFFF)
 
#define  MEMORYCHUNK_BLOCKOFFSET_MASK   UINT64CONST(0x3FFFFFFE)
 
 
 
 
#define  MEMORYCHUNK_MAGIC
 
#define  PointerGetMemoryChunk(p)    ((MemoryChunk *) ((char *) (p) - sizeof(MemoryChunk)))
 
#define  MemoryChunkGetPointer(c)    ((void *) ((char *) (c) + sizeof(MemoryChunk)))
 
#define  HdrMaskIsExternal(hdrmask)    ((hdrmask) & (((uint64) 1) << MEMORYCHUNK_EXTERNAL_BASEBIT))
 
#define  HdrMaskGetValue(hdrmask)    (((hdrmask) >> MEMORYCHUNK_VALUE_BASEBIT) & MEMORYCHUNK_MAX_VALUE)
 
 
#define  HdrMaskCheckMagic(hdrmask)
 

Typedefs

typedef struct MemoryChunk  MemoryChunk
 

Functions

static void  MemoryChunkSetHdrMask (MemoryChunk *chunk, void *block, Size value, MemoryContextMethodID methodid)
 
 
static bool  MemoryChunkIsExternal (MemoryChunk *chunk)
 
 
static void *  MemoryChunkGetBlock (MemoryChunk *chunk)
 

Macro Definition Documentation

HdrMaskBlockOffset

#define HdrMaskBlockOffset (   hdrmask )     (((hdrmask) >> MEMORYCHUNK_BLOCKOFFSET_BASEBIT) & MEMORYCHUNK_BLOCKOFFSET_MASK)

Definition at line 151 of file memutils_memorychunk.h.

HdrMaskCheckMagic

#define HdrMaskCheckMagic (   hdrmask )
Value:
#define MEMORYCHUNK_VALUE_BASEBIT
#define MEMORYCHUNK_MAGIC

Definition at line 155 of file memutils_memorychunk.h.

HdrMaskGetValue

#define HdrMaskGetValue (   hdrmask )     (((hdrmask) >> MEMORYCHUNK_VALUE_BASEBIT) & MEMORYCHUNK_MAX_VALUE)

Definition at line 144 of file memutils_memorychunk.h.

HdrMaskIsExternal

#define HdrMaskIsExternal (   hdrmask )     ((hdrmask) & (((uint64) 1) << MEMORYCHUNK_EXTERNAL_BASEBIT))

Definition at line 142 of file memutils_memorychunk.h.

MEMORYCHUNK_BLOCKOFFSET_BASEBIT

#define MEMORYCHUNK_BLOCKOFFSET_BASEBIT   (MEMORYCHUNK_VALUE_BASEBIT + 29)

Definition at line 113 of file memutils_memorychunk.h.

MEMORYCHUNK_BLOCKOFFSET_MASK

#define MEMORYCHUNK_BLOCKOFFSET_MASK   UINT64CONST(0x3FFFFFFE)

Definition at line 108 of file memutils_memorychunk.h.

MEMORYCHUNK_EXTERNAL_BASEBIT

#define MEMORYCHUNK_EXTERNAL_BASEBIT   MEMORY_CONTEXT_METHODID_BITS

Definition at line 111 of file memutils_memorychunk.h.

MEMORYCHUNK_MAGIC

#define MEMORYCHUNK_MAGIC
Value:
(UINT64CONST(0xB1A8DB858EB6EFBA) >> \
MEMORYCHUNK_VALUE_BASEBIT << \
MEMORYCHUNK_VALUE_BASEBIT)
#define UINT64CONST(x)
Definition: c.h:553

Definition at line 120 of file memutils_memorychunk.h.

MEMORYCHUNK_MAX_BLOCKOFFSET

#define MEMORYCHUNK_MAX_BLOCKOFFSET   UINT64CONST(0x3FFFFFFF)

Definition at line 102 of file memutils_memorychunk.h.

MEMORYCHUNK_MAX_VALUE

#define MEMORYCHUNK_MAX_VALUE   UINT64CONST(0x3FFFFFFF)

Definition at line 96 of file memutils_memorychunk.h.

MEMORYCHUNK_VALUE_BASEBIT

#define MEMORYCHUNK_VALUE_BASEBIT   (MEMORYCHUNK_EXTERNAL_BASEBIT + 1)

Definition at line 112 of file memutils_memorychunk.h.

MemoryChunkGetPointer

#define MemoryChunkGetPointer (   c )     ((void *) ((char *) (c) + sizeof(MemoryChunk)))

Definition at line 138 of file memutils_memorychunk.h.

PointerGetMemoryChunk

#define PointerGetMemoryChunk (   p )     ((MemoryChunk *) ((char *) (p) - sizeof(MemoryChunk)))

Definition at line 135 of file memutils_memorychunk.h.

Typedef Documentation

MemoryChunk

typedef struct MemoryChunk MemoryChunk

Function Documentation

MemoryChunkGetBlock()

static void * MemoryChunkGetBlock ( MemoryChunkchunk )
inlinestatic

Definition at line 235 of file memutils_memorychunk.h.

236{
238
239 return (void *) ((char *) chunk - HdrMaskBlockOffset(chunk->hdrmask));
240}
Assert(PointerIsAligned(start, uint64))
#define HdrMaskBlockOffset(hdrmask)
#define HdrMaskIsExternal(hdrmask)

References Assert(), MemoryChunk::hdrmask, HdrMaskBlockOffset, and HdrMaskIsExternal.

Referenced by AlignedAllocFree(), AlignedAllocGetChunkContext(), AlignedAllocGetChunkSpace(), AlignedAllocRealloc(), AllocSetFree(), AllocSetGetChunkContext(), AllocSetRealloc(), GenerationFree(), GenerationGetChunkContext(), GenerationRealloc(), SlabFree(), SlabGetChunkContext(), SlabGetChunkSpace(), and SlabRealloc().

MemoryChunkGetValue()

static Size MemoryChunkGetValue ( MemoryChunkchunk )
inlinestatic

Definition at line 222 of file memutils_memorychunk.h.

223{
225
226 return HdrMaskGetValue(chunk->hdrmask);
227}
#define HdrMaskGetValue(hdrmask)

References Assert(), MemoryChunk::hdrmask, HdrMaskGetValue, and HdrMaskIsExternal.

Referenced by AlignedAllocRealloc(), AllocSetAlloc(), AllocSetFree(), AllocSetGetChunkSpace(), AllocSetRealloc(), AllocSetStats(), GenerationFree(), GenerationGetChunkSpace(), and GenerationRealloc().

MemoryChunkIsExternal()

static bool MemoryChunkIsExternal ( MemoryChunkchunk )
inlinestatic

Definition at line 204 of file memutils_memorychunk.h.

205{
206 /*
207 * External chunks should always store MEMORYCHUNK_MAGIC in the upper
208 * portion of the hdrmask, check that nothing has stomped on that.
209 */
211 HdrMaskCheckMagic(chunk->hdrmask));
212
213 return HdrMaskIsExternal(chunk->hdrmask);
214}
#define HdrMaskCheckMagic(hdrmask)

References Assert(), MemoryChunk::hdrmask, HdrMaskCheckMagic, and HdrMaskIsExternal.

Referenced by AlignedAllocFree(), AlignedAllocGetChunkContext(), AllocSetFree(), AllocSetGetChunkContext(), AllocSetGetChunkSpace(), AllocSetRealloc(), GenerationFree(), GenerationGetChunkContext(), GenerationGetChunkSpace(), and GenerationRealloc().

MemoryChunkSetHdrMask()

static void MemoryChunkSetHdrMask ( MemoryChunkchunk,
void *  block,
Size  value,
MemoryContextMethodID  methodid 
)
inlinestatic

Definition at line 169 of file memutils_memorychunk.h.

171{
172 Size blockoffset = (char *) chunk - (char *) block;
173
174 Assert((char *) chunk >= (char *) block);
175 Assert((blockoffset & MEMORYCHUNK_BLOCKOFFSET_MASK) == blockoffset);
177 Assert((int) methodid <= MEMORY_CONTEXT_METHODID_MASK);
178
179 chunk->hdrmask = (((uint64) blockoffset) << MEMORYCHUNK_BLOCKOFFSET_BASEBIT) |
181 methodid;
182}
uint64_t uint64
Definition: c.h:539
size_t Size
Definition: c.h:610
static struct @169 value
#define MEMORY_CONTEXT_METHODID_MASK
#define MEMORYCHUNK_MAX_VALUE
#define MEMORYCHUNK_BLOCKOFFSET_MASK
#define MEMORYCHUNK_BLOCKOFFSET_BASEBIT

References Assert(), MemoryChunk::hdrmask, MEMORY_CONTEXT_METHODID_MASK, MEMORYCHUNK_BLOCKOFFSET_BASEBIT, MEMORYCHUNK_BLOCKOFFSET_MASK, MEMORYCHUNK_MAX_VALUE, MEMORYCHUNK_VALUE_BASEBIT, and value.

Referenced by AllocSetAllocChunkFromBlock(), AllocSetAllocFromNewBlock(), BumpAllocChunkFromBlock(), GenerationAllocChunkFromBlock(), MemoryContextAllocAligned(), and SlabAllocSetupNewChunk().

MemoryChunkSetHdrMaskExternal()

static void MemoryChunkSetHdrMaskExternal ( MemoryChunkchunk,
MemoryContextMethodID  methodid 
)
inlinestatic

Definition at line 190 of file memutils_memorychunk.h.

192{
193 Assert((int) methodid <= MEMORY_CONTEXT_METHODID_MASK);
194
196 methodid;
197}
#define MEMORYCHUNK_EXTERNAL_BASEBIT

References Assert(), MemoryChunk::hdrmask, MEMORY_CONTEXT_METHODID_MASK, MEMORYCHUNK_EXTERNAL_BASEBIT, and MEMORYCHUNK_MAGIC.

Referenced by AllocSetAllocLarge(), BumpAllocLarge(), and GenerationAllocLarge().

AltStyle によって変換されたページ (->オリジナル) /