shm.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #ifndef _LINUX_SHM_H_
  2. #define _LINUX_SHM_H_
  3. #include <linux/ipc.h>
  4. #include <linux/errno.h>
  5. #include <unistd.h>
  6. /*
  7. * SHMMNI, SHMMAX and SHMALL are default upper limits which can be
  8. * modified by sysctl. The SHMMAX and SHMALL values have been chosen to
  9. * be as large possible without facilitating scenarios where userspace
  10. * causes overflows when adjusting the limits via operations of the form
  11. * "retrieve current limit; add X; update limit". It is therefore not
  12. * advised to make SHMMAX and SHMALL any larger. These limits are
  13. * suitable for both 32 and 64-bit systems.
  14. */
  15. #define SHMMIN 1 /* min shared seg size (bytes) */
  16. #define SHMMNI 4096 /* max num of segs system wide */
  17. #define SHMMAX (ULONG_MAX - (1UL << 24)) /* max shared seg size (bytes) */
  18. #define SHMALL (ULONG_MAX - (1UL << 24)) /* max shm system wide (pages) */
  19. #define SHMSEG SHMMNI /* max shared segs per process */
  20. /* Obsolete, used only for backwards compatibility and libc5 compiles */
  21. struct shmid_ds {
  22. struct ipc_perm shm_perm; /* operation perms */
  23. int shm_segsz; /* size of segment (bytes) */
  24. __kernel_time_t shm_atime; /* last attach time */
  25. __kernel_time_t shm_dtime; /* last detach time */
  26. __kernel_time_t shm_ctime; /* last change time */
  27. __kernel_ipc_pid_t shm_cpid; /* pid of creator */
  28. __kernel_ipc_pid_t shm_lpid; /* pid of last operator */
  29. unsigned short shm_nattch; /* no. of current attaches */
  30. unsigned short shm_unused; /* compatibility */
  31. void *shm_unused2; /* ditto - used by DIPC */
  32. void *shm_unused3; /* unused */
  33. };
  34. /* Include the definition of shmid64_ds and shminfo64 */
  35. #include <asm/shmbuf.h>
  36. /* permission flag for shmget */
  37. #define SHM_R 0400 /* or S_IRUGO from <linux/stat.h> */
  38. #define SHM_W 0200 /* or S_IWUGO from <linux/stat.h> */
  39. /* mode for attach */
  40. #define SHM_RDONLY 010000 /* read-only access */
  41. #define SHM_RND 020000 /* round attach address to SHMLBA boundary */
  42. #define SHM_REMAP 040000 /* take-over region on attach */
  43. #define SHM_EXEC 0100000 /* execution access */
  44. /* super user shmctl commands */
  45. #define SHM_LOCK 11
  46. #define SHM_UNLOCK 12
  47. /* ipcs ctl commands */
  48. #define SHM_STAT 13
  49. #define SHM_INFO 14
  50. /* Obsolete, used only for backwards compatibility */
  51. struct shminfo {
  52. int shmmax;
  53. int shmmin;
  54. int shmmni;
  55. int shmseg;
  56. int shmall;
  57. };
  58. struct shm_info {
  59. int used_ids;
  60. __kernel_ulong_t shm_tot; /* total allocated shm */
  61. __kernel_ulong_t shm_rss; /* total resident shm */
  62. __kernel_ulong_t shm_swp; /* total swapped shm */
  63. __kernel_ulong_t swap_attempts;
  64. __kernel_ulong_t swap_successes;
  65. };
  66. #endif /* _LINUX_SHM_H_ */