shm.h 2.6 KB

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