]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/blame - include/linux/futex.h
Merge tag 'imx-fixes-4.20-3' of git://git.kernel.org/pub/scm/linux/kernel/git/shawngu...
[mirror_ubuntu-eoan-kernel.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
e3f2ddea
IM
12extern int
13handle_futex_death(u32 __user *uaddr, struct task_struct *curr, int pi);
0771dfef 14
9adef58b
RR
15/*
16 * Futexes are matched on equal values of this key.
17 * The key type depends on whether it's a shared or private mapping.
18 * Don't rearrange members without looking at hash_futex().
19 *
20 * offset is aligned to a multiple of sizeof(u32) (== 4) by definition.
34f01cc1
ED
21 * We use the two low order bits of offset to tell what is the kind of key :
22 * 00 : Private process futex (PTHREAD_PROCESS_PRIVATE)
23 * (no reference on an inode or mm)
24 * 01 : Shared futex (PTHREAD_PROCESS_SHARED)
25 * mapped on a file (reference on the underlying inode)
26 * 10 : Shared futex (PTHREAD_PROCESS_SHARED)
27 * (but private mapping on an mm, and reference taken on it)
28*/
29
30#define FUT_OFF_INODE 1 /* We set bit 0 if key has a reference on inode */
31#define FUT_OFF_MMSHARED 2 /* We set bit 1 if key has a reference on mm */
32
9adef58b
RR
33union futex_key {
34 struct {
35 unsigned long pgoff;
36 struct inode *inode;
37 int offset;
38 } shared;
39 struct {
40 unsigned long address;
41 struct mm_struct *mm;
42 int offset;
43 } private;
44 struct {
45 unsigned long word;
46 void *ptr;
47 int offset;
48 } both;
49};
9adef58b 50
38d47c1b
PZ
51#define FUTEX_KEY_INIT (union futex_key) { .both = { .ptr = NULL } }
52
0771dfef
IM
53#ifdef CONFIG_FUTEX
54extern void exit_robust_list(struct task_struct *curr);
2de0db99
DB
55
56long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout,
57 u32 __user *uaddr2, u32 val2, u32 val3);
03b8c7b6
HC
58#ifdef CONFIG_HAVE_FUTEX_CMPXCHG
59#define futex_cmpxchg_enabled 1
60#else
a0c1e907 61extern int futex_cmpxchg_enabled;
03b8c7b6 62#endif
0771dfef
IM
63#else
64static inline void exit_robust_list(struct task_struct *curr)
65{
66}
2de0db99
DB
67
68static inline long do_futex(u32 __user *uaddr, int op, u32 val,
69 ktime_t *timeout, u32 __user *uaddr2,
70 u32 val2, u32 val3)
71{
72 return -EINVAL;
73}
bc2eecd7
NP
74#endif
75
76#ifdef CONFIG_FUTEX_PI
77extern void exit_pi_state_list(struct task_struct *curr);
78#else
c87e2837
IM
79static inline void exit_pi_state_list(struct task_struct *curr)
80{
81}
0771dfef 82#endif
bc2eecd7 83
1da177e4 84#endif