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-2008, PostgreSQL Global Development Group
18 * Portions Copyright (c) 1994, Regents of the University of California
22 *-------------------------------------------------------------------------
27 typedef struct PGShmemHeader
/* standard header for all Postgres shmem */
29 int32 magic
; /* magic # to identify Postgres segments */
30 #define PGShmemMagic 679834894
31 pid_t creatorPID
; /* PID of creating process */
32 Size totalsize
; /* total size of segment */
33 Size freeoffset
; /* offset to first free space */
34 void *index
; /* pointer to ShmemIndex table */
35 #ifndef WIN32 /* Windows doesn't have useful inode#s */
36 dev_t device
; /* device data directory is on */
37 ino_t inode
; /* inode number of data directory */
43 extern unsigned long UsedShmemSegID
;
44 extern void *UsedShmemSegAddr
;
46 extern void PGSharedMemoryReAttach(void);
49 extern PGShmemHeader
*PGSharedMemoryCreate(Size size
, bool makePrivate
,
51 extern bool PGSharedMemoryIsInUse(unsigned long id1
, unsigned long id2
);
52 extern void PGSharedMemoryDetach(void);
54 #endif /* PG_SHMEM_H */