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