shm.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #ifndef _LINUX_SHM_H_
  2. #define _LINUX_SHM_H_
  3. #include <linux/list.h>
  4. #include <asm/page.h>
  5. #include <uapi/linux/shm.h>
  6. #include <asm/shmparam.h>
  7. struct shmid_kernel /* private to the kernel */
  8. {
  9. struct kern_ipc_perm shm_perm;
  10. struct file *shm_file;
  11. unsigned long shm_nattch;
  12. unsigned long shm_segsz;
  13. time_t shm_atim;
  14. time_t shm_dtim;
  15. time_t shm_ctim;
  16. pid_t shm_cprid;
  17. pid_t shm_lprid;
  18. struct user_struct *mlock_user;
  19. /* The task created the shm object. NULL if the task is dead. */
  20. struct task_struct *shm_creator;
  21. struct list_head shm_clist; /* list by creator */
  22. };
  23. /* shm_mode upper byte flags */
  24. #define SHM_DEST 01000 /* segment will be destroyed on last detach */
  25. #define SHM_LOCKED 02000 /* segment will not be swapped */
  26. #define SHM_HUGETLB 04000 /* segment will use huge TLB pages */
  27. #define SHM_NORESERVE 010000 /* don't check for reservations */
  28. /* Bits [26:31] are reserved */
  29. /*
  30. * When SHM_HUGETLB is set bits [26:31] encode the log2 of the huge page size.
  31. * This gives us 6 bits, which is enough until someone invents 128 bit address
  32. * spaces.
  33. *
  34. * Assume these are all power of twos.
  35. * When 0 use the default page size.
  36. */
  37. #define SHM_HUGE_SHIFT 26
  38. #define SHM_HUGE_MASK 0x3f
  39. #define SHM_HUGE_2MB (21 << SHM_HUGE_SHIFT)
  40. #define SHM_HUGE_1GB (30 << SHM_HUGE_SHIFT)
  41. #ifdef CONFIG_SYSVIPC
  42. struct sysv_shm {
  43. struct list_head shm_clist;
  44. };
  45. long do_shmat(int shmid, char __user *shmaddr, int shmflg, unsigned long *addr,
  46. unsigned long shmlba);
  47. bool is_file_shm_hugepages(struct file *file);
  48. void exit_shm(struct task_struct *task);
  49. #define shm_init_task(task) INIT_LIST_HEAD(&(task)->sysvshm.shm_clist)
  50. #else
  51. struct sysv_shm {
  52. /* empty */
  53. };
  54. static inline long do_shmat(int shmid, char __user *shmaddr,
  55. int shmflg, unsigned long *addr,
  56. unsigned long shmlba)
  57. {
  58. return -ENOSYS;
  59. }
  60. static inline bool is_file_shm_hugepages(struct file *file)
  61. {
  62. return false;
  63. }
  64. static inline void exit_shm(struct task_struct *task)
  65. {
  66. }
  67. static inline void shm_init_task(struct task_struct *task)
  68. {
  69. }
  70. #endif
  71. #endif /* _LINUX_SHM_H_ */