blob: 976ce3a19f1b23646c4494029929e538f5e0204b [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _LINUX_SEM_H
2#define _LINUX_SEM_H
3
Arun Sharma600634972011-07-26 16:09:06 -07004#include <linux/atomic.h>
Manfred Spraul380af1b2008-07-25 01:48:06 -07005#include <linux/rcupdate.h>
Manfred Spraul31a7c472010-05-26 14:43:42 -07006#include <linux/cache.h>
David Howells607ca462012-10-13 10:46:48 +01007#include <uapi/linux/sem.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008
Tim Schmielau8c65b4a2005-11-07 00:59:43 -08009struct task_struct;
10
Linus Torvalds1da177e2005-04-16 15:20:36 -070011/* One sem_array data structure for each set of semaphores in the system. */
12struct sem_array {
Manfred Spraul31a7c472010-05-26 14:43:42 -070013 struct kern_ipc_perm ____cacheline_aligned_in_smp
14 sem_perm; /* permissions .. see ipc.h */
Linus Torvalds1da177e2005-04-16 15:20:36 -070015 time_t sem_ctime; /* last change time */
16 struct sem *sem_base; /* ptr to first semaphore in array */
Manfred Spraul1a82e9e2013-07-08 16:01:23 -070017 struct list_head pending_alter; /* pending operations */
18 /* that alter the array */
19 struct list_head pending_const; /* pending complex operations */
20 /* that do not alter semvals */
Manfred Spraul4daa28f2008-07-25 01:48:04 -070021 struct list_head list_id; /* undo requests on this array */
Manfred Spraulb97e8202009-12-15 16:47:32 -080022 int sem_nsems; /* no. of semaphores in array */
23 int complex_count; /* pending complex operations */
Linus Torvalds1da177e2005-04-16 15:20:36 -070024};
25
Manfred Spraulf567a182011-11-02 13:38:56 -070026#ifdef CONFIG_SYSVIPC
27
Linus Torvalds1da177e2005-04-16 15:20:36 -070028struct sysv_sem {
29 struct sem_undo_list *undo_list;
30};
31
Linus Torvalds1da177e2005-04-16 15:20:36 -070032extern int copy_semundo(unsigned long clone_flags, struct task_struct *tsk);
33extern void exit_sem(struct task_struct *tsk);
34
35#else
Manfred Spraulf567a182011-11-02 13:38:56 -070036
37struct sysv_sem {
38 /* empty */
39};
40
Linus Torvalds1da177e2005-04-16 15:20:36 -070041static inline int copy_semundo(unsigned long clone_flags, struct task_struct *tsk)
42{
43 return 0;
44}
45
46static inline void exit_sem(struct task_struct *tsk)
47{
48 return;
49}
50#endif
51
Linus Torvalds1da177e2005-04-16 15:20:36 -070052#endif /* _LINUX_SEM_H */