2002-05-05 02:03:29 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* pg_shmem.h
|
|
|
|
* Platform-independent API for shared memory support.
|
|
|
|
*
|
|
|
|
* Every port is expected to support shared memory with approximately
|
|
|
|
* SysV-ish semantics; in particular, a memory block is not anonymous
|
|
|
|
* but has an ID, and we must be able to tell whether there are any
|
|
|
|
* remaining processes attached to a block of a specified ID.
|
|
|
|
*
|
|
|
|
* To simplify life for the SysV implementation, the ID is assumed to
|
|
|
|
* consist of two unsigned long values (these are key and ID in SysV
|
2002-09-04 22:31:48 +02:00
|
|
|
* terms). Other platforms may ignore the second value if they need
|
2002-05-05 02:03:29 +02:00
|
|
|
* only one ID number.
|
|
|
|
*
|
|
|
|
*
|
2004-08-29 06:13:13 +02:00
|
|
|
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
|
2002-05-05 02:03:29 +02:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
|
|
*
|
2004-08-29 06:13:13 +02:00
|
|
|
* $PostgreSQL: pgsql/src/include/storage/pg_shmem.h,v 1.11 2004/08/29 04:13:10 momjian Exp $
|
2002-05-05 02:03:29 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#ifndef PG_SHMEM_H
|
|
|
|
#define PG_SHMEM_H
|
|
|
|
|
|
|
|
typedef struct PGShmemHeader /* standard header for all Postgres shmem */
|
|
|
|
{
|
|
|
|
int32 magic; /* magic # to identify Postgres segments */
|
|
|
|
#define PGShmemMagic 679834892
|
|
|
|
pid_t creatorPID; /* PID of creating process */
|
|
|
|
uint32 totalsize; /* total size of segment */
|
|
|
|
uint32 freeoffset; /* offset to first free space */
|
|
|
|
} PGShmemHeader;
|
|
|
|
|
|
|
|
|
2003-05-07 01:34:56 +02:00
|
|
|
#ifdef EXEC_BACKEND
|
2003-12-01 23:15:38 +01:00
|
|
|
extern unsigned long UsedShmemSegID;
|
2003-05-08 16:49:04 +02:00
|
|
|
extern void *UsedShmemSegAddr;
|
2003-05-07 01:34:56 +02:00
|
|
|
#endif
|
|
|
|
|
2002-05-05 02:03:29 +02:00
|
|
|
extern PGShmemHeader *PGSharedMemoryCreate(uint32 size, bool makePrivate,
|
2002-09-04 22:31:48 +02:00
|
|
|
int port);
|
2002-05-05 02:03:29 +02:00
|
|
|
extern bool PGSharedMemoryIsInUse(unsigned long id1, unsigned long id2);
|
2003-11-07 22:55:50 +01:00
|
|
|
extern void PGSharedMemoryDetach(void);
|
2002-05-05 02:03:29 +02:00
|
|
|
|
|
|
|
#endif /* PG_SHMEM_H */
|