/* "@(#)shm.h	1.1		2/13/87"	*/


/*
**	IPC Shared Memory Facility.
*/

/*
**	Implementation Constants.
*/

#define	SHMLBA	0x1000	/* segment low boundary address multiple */
			/* (SHMLBA must be a power of 2) */

/*
**	Permission Definitions.
*/

#define	SHM_R	0400	/* read permission */
#define	SHM_W	0200	/* write permission */

/*
**	ipc_perm Mode Definitions.
*/

#define	SHM_CLEAR	01000	/* clear segment on next attach */
#define	SHM_DEST	02000	/* destroy segment when # attached = 0 */

/*
**	Shared Memory Operation Flags.
*/

#define	SHM_RDONLY	010000	/* attach read-only (else read-write) */
#define	SHM_RND		020000	/* round attach address to SHMLBA */
#define SHM_PHYS	040000	/* Used to map phys. mem. */

/*
**	Structure Definitions.
*/

/*
**	There is a shared mem id data structure for each segment in the system.
*/

struct shmid_ds {
	struct ipc_perm	shm_perm;	/* operation permission struct */
	int		shm_segsz;	/* segment size in bytes */
	/*ushort		shm_addr;	 index into shm_seg or
					   phys. addr. when SHM_PHYS */
	int		shm_lpid;	/* pid of last shmop */
	int		shm_cpid;	/* pid of creator */
	int		shm_nattch;	/* current # attached */
	/*ushort		shm_cnattch;	 in memory # attached */
	time_t		shm_atime;	/* last shmat time */
	time_t		shm_dtime;	/* last shmdt time */
	time_t		shm_ctime;	/* last change time */
};

struct	shmpt_ds {
	ushort	shm_sgt;	/* starting sgt (relative to first proc one) */
	int	shm_sflg;	/* R/W permission on segment */
};

struct	shminfo {
	int	shmmax,	/* max shared memory segment size */
		shmmin,	/* min shared memory segment size */
		shmmni,	/* # of shared memory identifiers */
		shmseg,	/* max attached shared memory segments per process */
		shmbrk,	/* gap (in segs) used between data and shared memory */
		shmall,	/* max total shared memory system wide (in clicks) */
		shmsgs;	/* size of shm_seg */
};
