blob: d0efd6e6c20a6a6a39273639dbd33f3d77c2e156 [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 */
Manfred Spraul5864a2f2016-10-11 13:54:50 -070024 bool complex_mode; /* no parallel simple ops */
Linus Torvalds1da177e2005-04-16 15:20:36 -070025};
26
Manfred Spraulf567a182011-11-02 13:38:56 -070027#ifdef CONFIG_SYSVIPC
28
Linus Torvalds1da177e2005-04-16 15:20:36 -070029struct sysv_sem {
30 struct sem_undo_list *undo_list;
31};
32
Linus Torvalds1da177e2005-04-16 15:20:36 -070033extern int copy_semundo(unsigned long clone_flags, struct task_struct *tsk);
34extern void exit_sem(struct task_struct *tsk);
35
36#else
Manfred Spraulf567a182011-11-02 13:38:56 -070037
38struct sysv_sem {
39 /* empty */
40};
41
Linus Torvalds1da177e2005-04-16 15:20:36 -070042static inline int copy_semundo(unsigned long clone_flags, struct task_struct *tsk)
43{
44 return 0;
45}
46
47static inline void exit_sem(struct task_struct *tsk)
48{
49 return;
50}
51#endif
52
Linus Torvalds1da177e2005-04-16 15:20:36 -070053#endif /* _LINUX_SEM_H */