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-2017, PostgreSQL Global Development Group
18 * Portions Copyright (c) 1994, Regents of the University of California
20 * src/include/storage/pg_shmem.h
22 *-------------------------------------------------------------------------
27 #include "storage/dsm_impl.h"
29 typedef struct PGShmemHeader /* standard header for all Postgres shmem */
31 int32 magic; /* magic # to identify Postgres segments */
32 #define PGShmemMagic 679834894
33 pid_t creatorPID; /* PID of creating process */
34 Size totalsize; /* total size of segment */
35 Size freeoffset; /* offset to first free space */
36 dsm_handle dsm_control; /* ID of dynamic shared memory control seg */
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 */
45 extern int huge_pages;
47 /* Possible values for huge_pages */
56 extern unsigned long UsedShmemSegID;
58 extern HANDLE UsedShmemSegID;
60 extern void *UsedShmemSegAddr;
63 extern void PGSharedMemoryReAttach(void);
64 extern void PGSharedMemoryNoReAttach(void);
67 extern PGShmemHeader *PGSharedMemoryCreate(Size size, bool makePrivate,
68 int port, PGShmemHeader **shim);
69 extern bool PGSharedMemoryIsInUse(unsigned long id1, unsigned long id2);
70 extern void PGSharedMemoryDetach(void);
72 #endif /* PG_SHMEM_H */