codekingpro/portable-devtools
114k
1/*-------------------------------------------------------------------------2 *3 * shmem.h4 * shared memory management structures5 *6 * Historical note:7 * A long time ago, Postgres' shared memory region was allowed to be mapped8 * at a different address in each process, and shared memory "pointers" were9 * passed around as offsets relative to the start of the shared memory region.10 * That is no longer the case: each process must map the shared memory region11 * at the same address. This means shared memory pointers can be passed12 * around directly between different processes.13 *14 * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group15 * Portions Copyright (c) 1994, Regents of the University of California16 *17 * src/include/storage/shmem.h18 *19 *-------------------------------------------------------------------------20 */21#ifndef SHMEM_H22#define SHMEM_H23 24#include "utils/hsearch.h"25 26 27/* shmem.c */28extern void InitShmemAccess(void *seghdr);29extern void InitShmemAllocation(void);30extern void *ShmemAlloc(Size size);31extern void *ShmemAllocNoError(Size size);32extern void *ShmemAllocUnlocked(Size size);33extern bool ShmemAddrIsValid(const void *addr);34extern void InitShmemIndex(void);35extern HTAB *ShmemInitHash(const char *name, long init_size, long max_size,36 HASHCTL *infoP, int hash_flags);37extern void *ShmemInitStruct(const char *name, Size size, bool *foundPtr);38extern Size add_size(Size s1, Size s2);39extern Size mul_size(Size s1, Size s2);40 41/* ipci.c */42extern void RequestAddinShmemSpace(Size size);43 44/* size constants for the shmem index table */45 /* max size of data structure string name */46#define SHMEM_INDEX_KEYSIZE (48)47 /* estimated size of the shmem index table (not a hard limit) */48#define SHMEM_INDEX_SIZE (64)49 50/* this is a hash bucket in the shmem index table */51typedef struct52{53 char key[SHMEM_INDEX_KEYSIZE]; /* string name */54 void *location; /* location in shared mem */55 Size size; /* # bytes requested for the structure */56 Size allocated_size; /* # bytes actually allocated */57} ShmemIndexEnt;58 59#endif /* SHMEM_H */60 