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