Merge tag 'drm-misc-next-2019-04-10' of git://anongit.freedesktop.org/drm/drm-misc...
[linux-block.git] / include / linux / futex.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
1da177e4
LT
2#ifndef _LINUX_FUTEX_H
3#define _LINUX_FUTEX_H
4
2456e855 5#include <linux/ktime.h>
607ca46e 6#include <uapi/linux/futex.h>
0771dfef 7
9064a678
MF
8struct inode;
9struct mm_struct;
10struct task_struct;
9064a678 11
9adef58b
RR
12/*
13 * Futexes are matched on equal values of this key.
14 * The key type depends on whether it's a shared or private mapping.
15 * Don't rearrange members without looking at hash_futex().
16 *
17 * offset is aligned to a multiple of sizeof(u32) (== 4) by definition.
34f01cc1
ED
18 * We use the two low order bits of offset to tell what is the kind of key :
19 * 00 : Private process futex (PTHREAD_PROCESS_PRIVATE)
20 * (no reference on an inode or mm)
21 * 01 : Shared futex (PTHREAD_PROCESS_SHARED)
22 * mapped on a file (reference on the underlying inode)
23 * 10 : Shared futex (PTHREAD_PROCESS_SHARED)
24 * (but private mapping on an mm, and reference taken on it)
25*/
26
27#define FUT_OFF_INODE 1 /* We set bit 0 if key has a reference on inode */
28#define FUT_OFF_MMSHARED 2 /* We set bit 1 if key has a reference on mm */
29
9adef58b
RR
30union futex_key {
31 struct {
32 unsigned long pgoff;
33 struct inode *inode;
34 int offset;
35 } shared;
36 struct {
37 unsigned long address;
38 struct mm_struct *mm;
39 int offset;
40 } private;
41 struct {
42 unsigned long word;
43 void *ptr;
44 int offset;
45 } both;
46};
9adef58b 47
38d47c1b
PZ
48#define FUTEX_KEY_INIT (union futex_key) { .both = { .ptr = NULL } }
49
0771dfef
IM
50#ifdef CONFIG_FUTEX
51extern void exit_robust_list(struct task_struct *curr);
2de0db99
DB
52
53long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout,
54 u32 __user *uaddr2, u32 val2, u32 val3);
0771dfef
IM
55#else
56static inline void exit_robust_list(struct task_struct *curr)
57{
58}
2de0db99
DB
59
60static inline long do_futex(u32 __user *uaddr, int op, u32 val,
61 ktime_t *timeout, u32 __user *uaddr2,
62 u32 val2, u32 val3)
63{
64 return -EINVAL;
65}
bc2eecd7
NP
66#endif
67
68#ifdef CONFIG_FUTEX_PI
69extern void exit_pi_state_list(struct task_struct *curr);
70#else
c87e2837
IM
71static inline void exit_pi_state_list(struct task_struct *curr)
72{
73}
0771dfef 74#endif
bc2eecd7 75
1da177e4 76#endif