00001 /*------------------------------------------------------------------------- 00002 * 00003 * pg_shmem.h 00004 * Platform-independent API for shared memory support. 00005 * 00006 * Every port is expected to support shared memory with approximately 00007 * SysV-ish semantics; in particular, a memory block is not anonymous 00008 * but has an ID, and we must be able to tell whether there are any 00009 * remaining processes attached to a block of a specified ID. 00010 * 00011 * To simplify life for the SysV implementation, the ID is assumed to 00012 * consist of two unsigned long values (these are key and ID in SysV 00013 * terms). Other platforms may ignore the second value if they need 00014 * only one ID number. 00015 * 00016 * 00017 * Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group 00018 * Portions Copyright (c) 1994, Regents of the University of California 00019 * 00020 * src/include/storage/pg_shmem.h 00021 * 00022 *------------------------------------------------------------------------- 00023 */ 00024 #ifndef PG_SHMEM_H 00025 #define PG_SHMEM_H 00026 00027 typedef struct PGShmemHeader /* standard header for all Postgres shmem */ 00028 { 00029 int32 magic; /* magic # to identify Postgres segments */ 00030 #define PGShmemMagic 679834894 00031 pid_t creatorPID; /* PID of creating process */ 00032 Size totalsize; /* total size of segment */ 00033 Size freeoffset; /* offset to first free space */ 00034 void *index; /* pointer to ShmemIndex table */ 00035 #ifndef WIN32 /* Windows doesn't have useful inode#s */ 00036 dev_t device; /* device data directory is on */ 00037 ino_t inode; /* inode number of data directory */ 00038 #endif 00039 } PGShmemHeader; 00040 00041 00042 #ifdef EXEC_BACKEND 00043 #ifndef WIN32 00044 extern unsigned long UsedShmemSegID; 00045 #else 00046 extern HANDLE UsedShmemSegID; 00047 #endif 00048 extern void *UsedShmemSegAddr; 00049 00050 extern void PGSharedMemoryReAttach(void); 00051 #endif 00052 00053 extern PGShmemHeader *PGSharedMemoryCreate(Size size, bool makePrivate, 00054 int port); 00055 extern bool PGSharedMemoryIsInUse(unsigned long id1, unsigned long id2); 00056 extern void PGSharedMemoryDetach(void); 00057 00058 #endif /* PG_SHMEM_H */