1/*-------------------------------------------------------------------------
4 * Platform-independent API for shared memory support.
6 * Every port is expected to support shared memory with approximately
7 * SysV-ish semantics; in particular, a memory block is not anonymous
8 * but has an ID, and we must be able to tell whether there are any
9 * remaining processes attached to a block of a specified ID.
11 * To simplify life for the SysV implementation, the ID is assumed to
12 * consist of two unsigned long values (these are key and ID in SysV
13 * terms). Other platforms may ignore the second value if they need
17 * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
18 * Portions Copyright (c) 1994, Regents of the University of California
20 * src/include/storage/pg_shmem.h
22 *-------------------------------------------------------------------------
29 typedef struct PGShmemHeader /* standard header for all Postgres shmem */
32 #define PGShmemMagic 679834894
33 pid_t
creatorPID;
/* PID of creating process (set but unread) */
37 void *
index;
/* pointer to ShmemIndex table */
38#ifndef WIN32 /* Windows doesn't have useful inode#s */
39 dev_t
device;
/* device data directory is on */
40 ino_t
inode;
/* inode number of data directory */
50/* Possible values for huge_pages and huge_pages_status */
59/* Possible values for shared_memory_type */
75#if !defined(WIN32) && !defined(EXEC_BACKEND)
76 #define DEFAULT_SHARED_MEMORY_TYPE SHMEM_TYPE_MMAP
78#define DEFAULT_SHARED_MEMORY_TYPE SHMEM_TYPE_SYSV
80#define DEFAULT_SHARED_MEMORY_TYPE SHMEM_TYPE_WINDOWS
94#endif /* PG_SHMEM_H */
void PGSharedMemoryDetach(void)
PGShmemHeader * PGSharedMemoryCreate(Size size, PGShmemHeader **shim)
PGDLLIMPORT void * UsedShmemSegAddr
struct PGShmemHeader PGShmemHeader
PGDLLIMPORT int huge_page_size
PGDLLIMPORT unsigned long UsedShmemSegID
void GetHugePageSize(Size *hugepagesize, int *mmap_flags)
PGDLLIMPORT int huge_pages
PGDLLIMPORT int huge_pages_status
bool PGSharedMemoryIsInUse(unsigned long id1, unsigned long id2)
PGDLLIMPORT int shared_memory_type
void PGSharedMemoryReAttach(void)
void * ShmemProtectiveRegion
void PGSharedMemoryNoReAttach(void)