PostgreSQL Source Code: src/include/storage/shmem.h Source File

PostgreSQL Source Code git master
shmem.h
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 *
3 * shmem.h
4 * shared memory management structures
5 *
6 * Historical note:
7 * A long time ago, Postgres' shared memory region was allowed to be mapped
8 * at a different address in each process, and shared memory "pointers" were
9 * 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 region
11 * at the same address. This means shared memory pointers can be passed
12 * around directly between different processes.
13 *
14 * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
15 * Portions Copyright (c) 1994, Regents of the University of California
16 *
17 * src/include/storage/shmem.h
18 *
19 *-------------------------------------------------------------------------
20 */
21#ifndef SHMEM_H
22#define SHMEM_H
23
24#include "storage/spin.h"
25#include "utils/hsearch.h"
26
27
28/* shmem.c */
29extern PGDLLIMPORT slock_t *ShmemLock;
30 typedef struct PGShmemHeader PGShmemHeader; /* avoid including
31 * storage/pg_shmem.h here */
32extern void InitShmemAccess(PGShmemHeader *seghdr);
33extern void InitShmemAllocation(void);
34extern void *ShmemAlloc(Size size);
35extern void *ShmemAllocNoError(Size size);
36extern void *ShmemAllocUnlocked(Size size);
37extern bool ShmemAddrIsValid(const void *addr);
38extern void InitShmemIndex(void);
39extern HTAB *ShmemInitHash(const char *name, int64 init_size, int64 max_size,
40 HASHCTL *infoP, int hash_flags);
41extern void *ShmemInitStruct(const char *name, Size size, bool *foundPtr);
42extern Size add_size(Size s1, Size s2);
43extern Size mul_size(Size s1, Size s2);
44
45extern PGDLLIMPORT Size pg_get_shmem_pagesize(void);
46
47/* ipci.c */
48extern void RequestAddinShmemSpace(Size size);
49
50/* size constants for the shmem index table */
51 /* max size of data structure string name */
52 #define SHMEM_INDEX_KEYSIZE (48)
53 /* estimated size of the shmem index table (not a hard limit) */
54 #define SHMEM_INDEX_SIZE (64)
55
56/* this is a hash bucket in the shmem index table */
57 typedef struct
58{
59 char key[SHMEM_INDEX_KEYSIZE]; /* string name */
60 void *location; /* location in shared mem */
61 Size size; /* # bytes requested for the structure */
62 Size allocated_size; /* # bytes actually allocated */
63} ShmemIndexEnt;
64
65#endif /* SHMEM_H */
#define PGDLLIMPORT
Definition: c.h:1319
int64_t int64
Definition: c.h:535
size_t Size
Definition: c.h:610
char * s1
char * s2
bool ShmemAddrIsValid(const void *addr)
Definition: shmem.c:274
void InitShmemIndex(void)
Definition: shmem.c:283
void InitShmemAccess(PGShmemHeader *seghdr)
Definition: shmem.c:102
Size add_size(Size s1, Size s2)
Definition: shmem.c:493
void * ShmemAllocUnlocked(Size size)
Definition: shmem.c:238
PGDLLIMPORT Size pg_get_shmem_pagesize(void)
Definition: shmem.c:740
PGDLLIMPORT slock_t * ShmemLock
Definition: shmem.c:88
void * ShmemAllocNoError(Size size)
Definition: shmem.c:172
Size mul_size(Size s1, Size s2)
Definition: shmem.c:510
void * ShmemAlloc(Size size)
Definition: shmem.c:152
HTAB * ShmemInitHash(const char *name, int64 init_size, int64 max_size, HASHCTL *infoP, int hash_flags)
Definition: shmem.c:332
void InitShmemAllocation(void)
Definition: shmem.c:115
void RequestAddinShmemSpace(Size size)
Definition: ipci.c:74
void * ShmemInitStruct(const char *name, Size size, bool *foundPtr)
Definition: shmem.c:387
#define SHMEM_INDEX_KEYSIZE
Definition: shmem.h:52
Definition: hsearch.h:66
Definition: dynahash.c:222
void * location
Definition: shmem.h:60
Size size
Definition: shmem.h:61
Size allocated_size
Definition: shmem.h:62
const char * name

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