1c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#ifndef _LINUX_SHM_H_ 2c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#define _LINUX_SHM_H_ 3c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru 4c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#include <linux/ipc.h> 5c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#include <linux/errno.h> 6c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#include <asm/page.h> 7c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru 8c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru/* 9c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru * SHMMAX, SHMMNI and SHMALL are upper limits are defaults which can 10c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru * be increased by sysctl 11c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru */ 12c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru 13c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#define SHMMAX 0x2000000 /* max shared seg size (bytes) */ 14c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#define SHMMIN 1 /* min shared seg size (bytes) */ 15c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#define SHMMNI 4096 /* max num of segs system wide */ 16c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#define SHMALL (SHMMAX/PAGE_SIZE*(SHMMNI/16)) /* max shm system wide (pages) */ 17c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#define SHMSEG SHMMNI /* max shared segs per process */ 18c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru 19c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#include <asm/shmparam.h> 20c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru 21c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru/* Obsolete, used only for backwards compatibility and libc5 compiles */ 22c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Querustruct shmid_ds { 23c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru struct ipc_perm shm_perm; /* operation perms */ 24c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru int shm_segsz; /* size of segment (bytes) */ 25c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru __kernel_time_t shm_atime; /* last attach time */ 26c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru __kernel_time_t shm_dtime; /* last detach time */ 27c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru __kernel_time_t shm_ctime; /* last change time */ 28c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru __kernel_ipc_pid_t shm_cpid; /* pid of creator */ 29c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru __kernel_ipc_pid_t shm_lpid; /* pid of last operator */ 30c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru unsigned short shm_nattch; /* no. of current attaches */ 31c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru unsigned short shm_unused; /* compatibility */ 32c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru void *shm_unused2; /* ditto - used by DIPC */ 33c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru void *shm_unused3; /* unused */ 34c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru}; 35c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru 36c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru/* Include the definition of shmid64_ds and shminfo64 */ 37c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#include <asm/shmbuf.h> 38c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru 39c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru/* permission flag for shmget */ 40c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#define SHM_R 0400 /* or S_IRUGO from <linux/stat.h> */ 41c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#define SHM_W 0200 /* or S_IWUGO from <linux/stat.h> */ 42c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru 43c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru/* mode for attach */ 44c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#define SHM_RDONLY 010000 /* read-only access */ 45c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#define SHM_RND 020000 /* round attach address to SHMLBA boundary */ 46c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#define SHM_REMAP 040000 /* take-over region on attach */ 47c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#define SHM_EXEC 0100000 /* execution access */ 48c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru 49c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru/* super user shmctl commands */ 50c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#define SHM_LOCK 11 51c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#define SHM_UNLOCK 12 52c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru 53c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru/* ipcs ctl commands */ 54c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#define SHM_STAT 13 55c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#define SHM_INFO 14 56c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru 57c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru/* Obsolete, used only for backwards compatibility */ 58c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Querustruct shminfo { 59c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru int shmmax; 60c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru int shmmin; 61c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru int shmmni; 62c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru int shmseg; 63c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru int shmall; 64c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru}; 65c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru 66c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Querustruct shm_info { 67c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru int used_ids; 68c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru unsigned long shm_tot; /* total allocated shm */ 69c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru unsigned long shm_rss; /* total resident shm */ 70c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru unsigned long shm_swp; /* total swapped shm */ 71c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru unsigned long swap_attempts; 72c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru unsigned long swap_successes; 73c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru}; 74c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru 75c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#ifdef __KERNEL__ 76c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Querustruct shmid_kernel /* private to the kernel */ 77c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru{ 78c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru struct kern_ipc_perm shm_perm; 79c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru struct file * shm_file; 80c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru int id; 81c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru unsigned long shm_nattch; 82c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru unsigned long shm_segsz; 83c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru time_t shm_atim; 84c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru time_t shm_dtim; 85c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru time_t shm_ctim; 86c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru pid_t shm_cprid; 87c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru pid_t shm_lprid; 88c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru struct user_struct *mlock_user; 89c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru}; 90c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru 91c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru/* shm_mode upper byte flags */ 92c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#define SHM_DEST 01000 /* segment will be destroyed on last detach */ 93c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#define SHM_LOCKED 02000 /* segment will not be swapped */ 94c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#define SHM_HUGETLB 04000 /* segment will use huge TLB pages */ 95c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#define SHM_NORESERVE 010000 /* don't check for reservations */ 96c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru 97c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#ifdef CONFIG_SYSVIPC 98c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Querulong do_shmat(int shmid, char __user *shmaddr, int shmflg, unsigned long *addr); 99c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#else 100c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Querustatic inline long do_shmat(int shmid, char __user *shmaddr, 101c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru int shmflg, unsigned long *addr) 102c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru{ 103c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru return -ENOSYS; 104c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru} 105c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#endif 106c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru 107c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#endif /* __KERNEL__ */ 108c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru 109c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#endif /* _LINUX_SHM_H_ */ 110