Blame view
include/linux/futex.h
2.39 KB
b24413180
|
1 |
/* SPDX-License-Identifier: GPL-2.0 */ |
1da177e4c
|
2 3 |
#ifndef _LINUX_FUTEX_H #define _LINUX_FUTEX_H |
8012f98f9
|
4 |
#include <linux/sched.h> |
2456e8553
|
5 |
#include <linux/ktime.h> |
8012f98f9
|
6 |
|
607ca46e9
|
7 |
#include <uapi/linux/futex.h> |
0771dfefc
|
8 |
|
9064a6787
|
9 10 11 |
struct inode; struct mm_struct; struct task_struct; |
9064a6787
|
12 |
|
9adef58b1
|
13 14 15 16 17 18 |
/* * Futexes are matched on equal values of this key. * The key type depends on whether it's a shared or private mapping. * Don't rearrange members without looking at hash_futex(). * * offset is aligned to a multiple of sizeof(u32) (== 4) by definition. |
34f01cc1f
|
19 20 21 22 23 24 25 26 27 28 29 |
* We use the two low order bits of offset to tell what is the kind of key : * 00 : Private process futex (PTHREAD_PROCESS_PRIVATE) * (no reference on an inode or mm) * 01 : Shared futex (PTHREAD_PROCESS_SHARED) * mapped on a file (reference on the underlying inode) * 10 : Shared futex (PTHREAD_PROCESS_SHARED) * (but private mapping on an mm, and reference taken on it) */ #define FUT_OFF_INODE 1 /* We set bit 0 if key has a reference on inode */ #define FUT_OFF_MMSHARED 2 /* We set bit 1 if key has a reference on mm */ |
9adef58b1
|
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
union futex_key { struct { unsigned long pgoff; struct inode *inode; int offset; } shared; struct { unsigned long address; struct mm_struct *mm; int offset; } private; struct { unsigned long word; void *ptr; int offset; } both; }; |
9adef58b1
|
47 |
|
38d47c1b7
|
48 |
#define FUTEX_KEY_INIT (union futex_key) { .both = { .ptr = NULL } } |
0771dfefc
|
49 |
#ifdef CONFIG_FUTEX |
52507cfaf
|
50 51 |
enum { FUTEX_STATE_OK, |
b2f4e1067
|
52 |
FUTEX_STATE_EXITING, |
52507cfaf
|
53 54 |
FUTEX_STATE_DEAD, }; |
2de0db992
|
55 |
|
8012f98f9
|
56 |
static inline void futex_init_task(struct task_struct *tsk) |
0771dfefc
|
57 |
{ |
8012f98f9
|
58 59 60 61 62 63 |
tsk->robust_list = NULL; #ifdef CONFIG_COMPAT tsk->compat_robust_list = NULL; #endif INIT_LIST_HEAD(&tsk->pi_state_list); tsk->pi_state_cache = NULL; |
52507cfaf
|
64 |
tsk->futex_state = FUTEX_STATE_OK; |
d3ba1e8d5
|
65 |
mutex_init(&tsk->futex_exit_mutex); |
52507cfaf
|
66 |
} |
b2f4e1067
|
67 |
void futex_exit_recursive(struct task_struct *tsk); |
1bcee2337
|
68 69 |
void futex_exit_release(struct task_struct *tsk); void futex_exec_release(struct task_struct *tsk); |
8012f98f9
|
70 71 72 73 74 |
long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout, u32 __user *uaddr2, u32 val2, u32 val3); #else static inline void futex_init_task(struct task_struct *tsk) { } |
b2f4e1067
|
75 |
static inline void futex_exit_recursive(struct task_struct *tsk) { } |
1bcee2337
|
76 77 |
static inline void futex_exit_release(struct task_struct *tsk) { } static inline void futex_exec_release(struct task_struct *tsk) { } |
2de0db992
|
78 79 80 81 82 83 |
static inline long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout, u32 __user *uaddr2, u32 val2, u32 val3) { return -EINVAL; } |
bc2eecd7e
|
84 |
#endif |
1da177e4c
|
85 |
#endif |