Linux Audio

Check our new training course

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