shm.h 3.2 KB

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