Consistently use "superuser" instead of "super user"
[pgsql.git] / src / include / storage / shmem.h
blob31024e5a50f39dbb7e5bef1323030c4d817136f3
1 /*-------------------------------------------------------------------------
3 * shmem.h
4 * shared memory management structures
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.
14 * Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group
15 * Portions Copyright (c) 1994, Regents of the University of California
17 * src/include/storage/shmem.h
19 *-------------------------------------------------------------------------
21 #ifndef SHMEM_H
22 #define SHMEM_H
24 #include "utils/hsearch.h"
27 /* shmqueue.c */
28 typedef struct SHM_QUEUE
30 struct SHM_QUEUE *prev;
31 struct SHM_QUEUE *next;
32 } SHM_QUEUE;
34 /* shmem.c */
35 extern void InitShmemAccess(void *seghdr);
36 extern void InitShmemAllocation(void);
37 extern void *ShmemAlloc(Size size);
38 extern void *ShmemAllocNoError(Size size);
39 extern void *ShmemAllocUnlocked(Size size);
40 extern bool ShmemAddrIsValid(const void *addr);
41 extern void InitShmemIndex(void);
42 extern HTAB *ShmemInitHash(const char *name, long init_size, long max_size,
43 HASHCTL *infoP, int hash_flags);
44 extern void *ShmemInitStruct(const char *name, Size size, bool *foundPtr);
45 extern Size add_size(Size s1, Size s2);
46 extern Size mul_size(Size s1, Size s2);
48 /* ipci.c */
49 extern void RequestAddinShmemSpace(Size size);
51 /* size constants for the shmem index table */
52 /* max size of data structure string name */
53 #define SHMEM_INDEX_KEYSIZE (48)
54 /* estimated size of the shmem index table (not a hard limit) */
55 #define SHMEM_INDEX_SIZE (64)
57 /* this is a hash bucket in the shmem index table */
58 typedef struct
60 char key[SHMEM_INDEX_KEYSIZE]; /* string name */
61 void *location; /* location in shared mem */
62 Size size; /* # bytes requested for the structure */
63 Size allocated_size; /* # bytes actually allocated */
64 } ShmemIndexEnt;
67 * prototypes for functions in shmqueue.c
69 extern void SHMQueueInit(SHM_QUEUE *queue);
70 extern void SHMQueueElemInit(SHM_QUEUE *queue);
71 extern void SHMQueueDelete(SHM_QUEUE *queue);
72 extern void SHMQueueInsertBefore(SHM_QUEUE *queue, SHM_QUEUE *elem);
73 extern void SHMQueueInsertAfter(SHM_QUEUE *queue, SHM_QUEUE *elem);
74 extern Pointer SHMQueueNext(const SHM_QUEUE *queue, const SHM_QUEUE *curElem,
75 Size linkOffset);
76 extern Pointer SHMQueuePrev(const SHM_QUEUE *queue, const SHM_QUEUE *curElem,
77 Size linkOffset);
78 extern bool SHMQueueEmpty(const SHM_QUEUE *queue);
79 extern bool SHMQueueIsDetached(const SHM_QUEUE *queue);
81 #endif /* SHMEM_H */