0001
0002 #ifndef _LINUX_FUTEX_H
0003 #define _LINUX_FUTEX_H
0004
0005 #include <linux/sched.h>
0006 #include <linux/ktime.h>
0007
0008 #include <uapi/linux/futex.h>
0009
0010 struct inode;
0011 struct mm_struct;
0012 struct task_struct;
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 #define FUT_OFF_INODE 1
0030 #define FUT_OFF_MMSHARED 2
0031
0032 union futex_key {
0033 struct {
0034 u64 i_seq;
0035 unsigned long pgoff;
0036 unsigned int offset;
0037 } shared;
0038 struct {
0039 union {
0040 struct mm_struct *mm;
0041 u64 __tmp;
0042 };
0043 unsigned long address;
0044 unsigned int offset;
0045 } private;
0046 struct {
0047 u64 ptr;
0048 unsigned long word;
0049 unsigned int offset;
0050 } both;
0051 };
0052
0053 #define FUTEX_KEY_INIT (union futex_key) { .both = { .ptr = 0ULL } }
0054
0055 #ifdef CONFIG_FUTEX
0056 enum {
0057 FUTEX_STATE_OK,
0058 FUTEX_STATE_EXITING,
0059 FUTEX_STATE_DEAD,
0060 };
0061
0062 static inline void futex_init_task(struct task_struct *tsk)
0063 {
0064 tsk->robust_list = NULL;
0065 #ifdef CONFIG_COMPAT
0066 tsk->compat_robust_list = NULL;
0067 #endif
0068 INIT_LIST_HEAD(&tsk->pi_state_list);
0069 tsk->pi_state_cache = NULL;
0070 tsk->futex_state = FUTEX_STATE_OK;
0071 mutex_init(&tsk->futex_exit_mutex);
0072 }
0073
0074 void futex_exit_recursive(struct task_struct *tsk);
0075 void futex_exit_release(struct task_struct *tsk);
0076 void futex_exec_release(struct task_struct *tsk);
0077
0078 long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout,
0079 u32 __user *uaddr2, u32 val2, u32 val3);
0080 #else
0081 static inline void futex_init_task(struct task_struct *tsk) { }
0082 static inline void futex_exit_recursive(struct task_struct *tsk) { }
0083 static inline void futex_exit_release(struct task_struct *tsk) { }
0084 static inline void futex_exec_release(struct task_struct *tsk) { }
0085 static inline long do_futex(u32 __user *uaddr, int op, u32 val,
0086 ktime_t *timeout, u32 __user *uaddr2,
0087 u32 val2, u32 val3)
0088 {
0089 return -EINVAL;
0090 }
0091 #endif
0092
0093 #endif