blob: 53d42650b1935f255feac8bc88401240057068c6 [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_otime; /* last semop time */
16 time_t sem_ctime; /* last change time */
17 struct sem *sem_base; /* ptr to first semaphore in array */
Manfred Spraula1193f82008-07-25 01:48:06 -070018 struct list_head sem_pending; /* pending operations to be processed */
Manfred Spraul4daa28f2008-07-25 01:48:04 -070019 struct list_head list_id; /* undo requests on this array */
Manfred Spraulb97e8202009-12-15 16:47:32 -080020 int sem_nsems; /* no. of semaphores in array */
21 int complex_count; /* pending complex operations */
Linus Torvalds1da177e2005-04-16 15:20:36 -070022};
23
Manfred Spraulf567a182011-11-02 13:38:56 -070024#ifdef CONFIG_SYSVIPC
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026struct sysv_sem {
27 struct sem_undo_list *undo_list;
28};
29
Linus Torvalds1da177e2005-04-16 15:20:36 -070030extern int copy_semundo(unsigned long clone_flags, struct task_struct *tsk);
31extern void exit_sem(struct task_struct *tsk);
32
33#else
Manfred Spraulf567a182011-11-02 13:38:56 -070034
35struct sysv_sem {
36 /* empty */
37};
38
Linus Torvalds1da177e2005-04-16 15:20:36 -070039static inline int copy_semundo(unsigned long clone_flags, struct task_struct *tsk)
40{
41 return 0;
42}
43
44static inline void exit_sem(struct task_struct *tsk)
45{
46 return;
47}
48#endif
49
Linus Torvalds1da177e2005-04-16 15:20:36 -070050#endif /* _LINUX_SEM_H */