1996-08-28 03:59:28 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* shmem.h
|
1997-09-07 07:04:48 +02:00
|
|
|
* shared memory management structures
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
2008-11-02 22:24:52 +01:00
|
|
|
* Historical note:
|
|
|
|
* A long time ago, Postgres' shared memory region was allowed to be mapped
|
|
|
|
* at a different address in each process, and shared memory "pointers" were
|
|
|
|
* passed around as offsets relative to the start of the shared memory region.
|
|
|
|
* That is no longer the case: each process must map the shared memory region
|
|
|
|
* at the same address. This means shared memory pointers can be passed
|
|
|
|
* around directly between different processes.
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
2008-01-01 20:46:01 +01:00
|
|
|
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
2008-11-02 22:24:52 +01:00
|
|
|
* $PostgreSQL: pgsql/src/include/storage/shmem.h,v 1.54 2008/11/02 21:24:52 tgl Exp $
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
1997-09-07 07:04:48 +02:00
|
|
|
#ifndef SHMEM_H
|
1996-08-28 03:59:28 +02:00
|
|
|
#define SHMEM_H
|
|
|
|
|
1999-07-16 19:07:40 +02:00
|
|
|
#include "utils/hsearch.h"
|
1996-11-05 07:11:08 +01:00
|
|
|
|
1996-08-28 03:59:28 +02:00
|
|
|
|
2002-08-17 15:04:19 +02:00
|
|
|
/* shmqueue.c */
|
1997-09-07 07:04:48 +02:00
|
|
|
typedef struct SHM_QUEUE
|
|
|
|
{
|
2008-11-02 22:24:52 +01:00
|
|
|
struct SHM_QUEUE *prev;
|
|
|
|
struct SHM_QUEUE *next;
|
1997-09-08 23:56:23 +02:00
|
|
|
} SHM_QUEUE;
|
1996-08-28 03:59:28 +02:00
|
|
|
|
|
|
|
/* shmem.c */
|
2006-01-04 22:06:32 +01:00
|
|
|
extern void InitShmemAccess(void *seghdr);
|
|
|
|
extern void InitShmemAllocation(void);
|
2000-06-28 05:33:33 +02:00
|
|
|
extern void *ShmemAlloc(Size size);
|
2008-11-02 22:24:52 +01:00
|
|
|
extern bool ShmemAddrIsValid(void *addr);
|
2001-09-29 06:02:27 +02:00
|
|
|
extern void InitShmemIndex(void);
|
2001-10-05 19:28:13 +02:00
|
|
|
extern HTAB *ShmemInitHash(const char *name, long init_size, long max_size,
|
1997-09-08 23:56:23 +02:00
|
|
|
HASHCTL *infoP, int hash_flags);
|
2001-10-05 19:28:13 +02:00
|
|
|
extern void *ShmemInitStruct(const char *name, Size size, bool *foundPtr);
|
2005-08-21 01:26:37 +02:00
|
|
|
extern Size add_size(Size s1, Size s2);
|
|
|
|
extern Size mul_size(Size s1, Size s2);
|
1996-08-28 03:59:28 +02:00
|
|
|
|
2006-10-16 00:04:08 +02:00
|
|
|
/* ipci.c */
|
|
|
|
extern void RequestAddinShmemSpace(Size size);
|
|
|
|
|
1998-06-27 17:47:48 +02:00
|
|
|
/* size constants for the shmem index table */
|
1997-09-07 07:04:48 +02:00
|
|
|
/* max size of data structure string name */
|
2001-10-01 07:36:17 +02:00
|
|
|
#define SHMEM_INDEX_KEYSIZE (48)
|
2008-11-02 22:24:52 +01:00
|
|
|
/* estimated size of the shmem index table (not a hard limit) */
|
2004-09-28 22:46:37 +02:00
|
|
|
#define SHMEM_INDEX_SIZE (32)
|
1996-08-28 03:59:28 +02:00
|
|
|
|
1998-06-27 17:47:48 +02:00
|
|
|
/* this is a hash bucket in the shmem index table */
|
1997-09-07 07:04:48 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
1998-09-01 06:40:42 +02:00
|
|
|
char key[SHMEM_INDEX_KEYSIZE]; /* string name */
|
2008-11-02 22:24:52 +01:00
|
|
|
void *location; /* location in shared mem */
|
|
|
|
Size size; /* # bytes allocated for the structure */
|
1999-05-26 00:43:53 +02:00
|
|
|
} ShmemIndexEnt;
|
1996-08-28 03:59:28 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* prototypes for functions in shmqueue.c
|
|
|
|
*/
|
1997-09-08 23:56:23 +02:00
|
|
|
extern void SHMQueueInit(SHM_QUEUE *queue);
|
|
|
|
extern void SHMQueueElemInit(SHM_QUEUE *queue);
|
|
|
|
extern void SHMQueueDelete(SHM_QUEUE *queue);
|
2001-01-22 23:30:06 +01:00
|
|
|
extern void SHMQueueInsertBefore(SHM_QUEUE *queue, SHM_QUEUE *elem);
|
|
|
|
extern Pointer SHMQueueNext(SHM_QUEUE *queue, SHM_QUEUE *curElem,
|
2001-03-22 05:01:46 +01:00
|
|
|
Size linkOffset);
|
1997-09-08 23:56:23 +02:00
|
|
|
extern bool SHMQueueEmpty(SHM_QUEUE *queue);
|
2001-10-28 07:26:15 +01:00
|
|
|
|
2001-11-05 18:46:40 +01:00
|
|
|
#endif /* SHMEM_H */
|