Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _LINUX_FUTEX_H |
| 2 | #define _LINUX_FUTEX_H |
| 3 | |
David Howells | 607ca46 | 2012-10-13 10:46:48 +0100 | [diff] [blame] | 4 | #include <uapi/linux/futex.h> |
Ingo Molnar | 0771dfe | 2006-03-27 01:16:22 -0800 | [diff] [blame] | 5 | |
Mike Frysinger | 9064a67 | 2009-09-23 15:57:23 -0700 | [diff] [blame] | 6 | struct inode; |
| 7 | struct mm_struct; |
| 8 | struct task_struct; |
| 9 | union ktime; |
| 10 | |
Pierre Peiffer | c19384b | 2007-05-09 02:35:02 -0700 | [diff] [blame] | 11 | long do_futex(u32 __user *uaddr, int op, u32 val, union ktime *timeout, |
Ingo Molnar | e2970f2 | 2006-06-27 02:54:47 -0700 | [diff] [blame] | 12 | u32 __user *uaddr2, u32 val2, u32 val3); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | |
Ingo Molnar | e3f2dde | 2006-07-29 05:17:57 +0200 | [diff] [blame] | 14 | extern int |
| 15 | handle_futex_death(u32 __user *uaddr, struct task_struct *curr, int pi); |
Ingo Molnar | 0771dfe | 2006-03-27 01:16:22 -0800 | [diff] [blame] | 16 | |
Rusty Russell | 9adef58 | 2007-05-08 00:26:42 -0700 | [diff] [blame] | 17 | /* |
| 18 | * Futexes are matched on equal values of this key. |
| 19 | * The key type depends on whether it's a shared or private mapping. |
| 20 | * Don't rearrange members without looking at hash_futex(). |
| 21 | * |
| 22 | * offset is aligned to a multiple of sizeof(u32) (== 4) by definition. |
Eric Dumazet | 34f01cc | 2007-05-09 02:35:04 -0700 | [diff] [blame] | 23 | * We use the two low order bits of offset to tell what is the kind of key : |
| 24 | * 00 : Private process futex (PTHREAD_PROCESS_PRIVATE) |
| 25 | * (no reference on an inode or mm) |
| 26 | * 01 : Shared futex (PTHREAD_PROCESS_SHARED) |
| 27 | * mapped on a file (reference on the underlying inode) |
| 28 | * 10 : Shared futex (PTHREAD_PROCESS_SHARED) |
| 29 | * (but private mapping on an mm, and reference taken on it) |
| 30 | */ |
| 31 | |
| 32 | #define FUT_OFF_INODE 1 /* We set bit 0 if key has a reference on inode */ |
| 33 | #define FUT_OFF_MMSHARED 2 /* We set bit 1 if key has a reference on mm */ |
| 34 | |
Rusty Russell | 9adef58 | 2007-05-08 00:26:42 -0700 | [diff] [blame] | 35 | union futex_key { |
| 36 | struct { |
| 37 | unsigned long pgoff; |
| 38 | struct inode *inode; |
| 39 | int offset; |
| 40 | } shared; |
| 41 | struct { |
| 42 | unsigned long address; |
| 43 | struct mm_struct *mm; |
| 44 | int offset; |
| 45 | } private; |
| 46 | struct { |
| 47 | unsigned long word; |
| 48 | void *ptr; |
| 49 | int offset; |
| 50 | } both; |
| 51 | }; |
Rusty Russell | 9adef58 | 2007-05-08 00:26:42 -0700 | [diff] [blame] | 52 | |
Peter Zijlstra | 38d47c1 | 2008-09-26 19:32:20 +0200 | [diff] [blame] | 53 | #define FUTEX_KEY_INIT (union futex_key) { .both = { .ptr = NULL } } |
| 54 | |
Ingo Molnar | 0771dfe | 2006-03-27 01:16:22 -0800 | [diff] [blame] | 55 | #ifdef CONFIG_FUTEX |
| 56 | extern void exit_robust_list(struct task_struct *curr); |
Ingo Molnar | c87e283 | 2006-06-27 02:54:58 -0700 | [diff] [blame] | 57 | extern void exit_pi_state_list(struct task_struct *curr); |
Thomas Gleixner | a0c1e90 | 2008-02-23 15:23:57 -0800 | [diff] [blame] | 58 | extern int futex_cmpxchg_enabled; |
Ingo Molnar | 0771dfe | 2006-03-27 01:16:22 -0800 | [diff] [blame] | 59 | #else |
| 60 | static inline void exit_robust_list(struct task_struct *curr) |
| 61 | { |
| 62 | } |
Ingo Molnar | c87e283 | 2006-06-27 02:54:58 -0700 | [diff] [blame] | 63 | static inline void exit_pi_state_list(struct task_struct *curr) |
| 64 | { |
| 65 | } |
Ingo Molnar | 0771dfe | 2006-03-27 01:16:22 -0800 | [diff] [blame] | 66 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | #endif |