]>
Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
1da177e4 LT |
2 | #ifndef _LINUX_SEM_H |
3 | #define _LINUX_SEM_H | |
4 | ||
60063497 | 5 | #include <linux/atomic.h> |
380af1b3 | 6 | #include <linux/rcupdate.h> |
31a7c474 | 7 | #include <linux/cache.h> |
e54d02b2 | 8 | #include <linux/time64.h> |
607ca46e | 9 | #include <uapi/linux/sem.h> |
1da177e4 | 10 | |
8c65b4a6 TS |
11 | struct task_struct; |
12 | ||
1a233956 MS |
13 | /* One semaphore structure for each semaphore in the system. */ |
14 | struct sem { | |
15 | int semval; /* current value */ | |
16 | /* | |
17 | * PID of the process that last modified the semaphore. For | |
18 | * Linux, specifically these are: | |
19 | * - semop | |
20 | * - semctl, via SETVAL and SETALL. | |
21 | * - at task exit when performing undo adjustments (see exit_sem). | |
22 | */ | |
23 | int sempid; | |
24 | spinlock_t lock; /* spinlock for fine-grained semtimedop */ | |
25 | struct list_head pending_alter; /* pending single-sop operations */ | |
26 | /* that alter the semaphore */ | |
27 | struct list_head pending_const; /* pending single-sop operations */ | |
28 | /* that do not alter the semaphore*/ | |
29 | time_t sem_otime; /* candidate for sem_otime */ | |
30 | } ____cacheline_aligned_in_smp; | |
31 | ||
1da177e4 LT |
32 | /* One sem_array data structure for each set of semaphores in the system. */ |
33 | struct sem_array { | |
60f3e00d | 34 | struct kern_ipc_perm sem_perm; /* permissions .. see ipc.h */ |
e54d02b2 | 35 | time64_t sem_ctime; /* create/last semctl() time */ |
1a82e9e1 MS |
36 | struct list_head pending_alter; /* pending operations */ |
37 | /* that alter the array */ | |
38 | struct list_head pending_const; /* pending complex operations */ | |
39 | /* that do not alter semvals */ | |
4daa28f6 | 40 | struct list_head list_id; /* undo requests on this array */ |
b97e820f MS |
41 | int sem_nsems; /* no. of semaphores in array */ |
42 | int complex_count; /* pending complex operations */ | |
9de5ab8a | 43 | unsigned int use_global_lock;/* >0: global lock required */ |
1a233956 MS |
44 | |
45 | struct sem sems[]; | |
3859a271 | 46 | } __randomize_layout; |
1da177e4 | 47 | |
f567a185 MS |
48 | #ifdef CONFIG_SYSVIPC |
49 | ||
1da177e4 LT |
50 | struct sysv_sem { |
51 | struct sem_undo_list *undo_list; | |
52 | }; | |
53 | ||
1da177e4 LT |
54 | extern int copy_semundo(unsigned long clone_flags, struct task_struct *tsk); |
55 | extern void exit_sem(struct task_struct *tsk); | |
56 | ||
57 | #else | |
f567a185 MS |
58 | |
59 | struct sysv_sem { | |
60 | /* empty */ | |
61 | }; | |
62 | ||
1da177e4 LT |
63 | static inline int copy_semundo(unsigned long clone_flags, struct task_struct *tsk) |
64 | { | |
65 | return 0; | |
66 | } | |
67 | ||
68 | static inline void exit_sem(struct task_struct *tsk) | |
69 | { | |
70 | return; | |
71 | } | |
72 | #endif | |
73 | ||
1da177e4 | 74 | #endif /* _LINUX_SEM_H */ |