at v4.17 2.1 kB view raw
1/* SPDX-License-Identifier: GPL-2.0 */ 2#ifndef _LINUX_FUTEX_H 3#define _LINUX_FUTEX_H 4 5#include <linux/ktime.h> 6#include <uapi/linux/futex.h> 7 8struct inode; 9struct mm_struct; 10struct task_struct; 11 12extern int 13handle_futex_death(u32 __user *uaddr, struct task_struct *curr, int pi); 14 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. 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 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}; 50 51#define FUTEX_KEY_INIT (union futex_key) { .both = { .ptr = NULL } } 52 53#ifdef CONFIG_FUTEX 54extern void exit_robust_list(struct task_struct *curr); 55 56long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout, 57 u32 __user *uaddr2, u32 val2, u32 val3); 58#ifdef CONFIG_HAVE_FUTEX_CMPXCHG 59#define futex_cmpxchg_enabled 1 60#else 61extern int futex_cmpxchg_enabled; 62#endif 63#else 64static inline void exit_robust_list(struct task_struct *curr) 65{ 66} 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} 74#endif 75 76#ifdef CONFIG_FUTEX_PI 77extern void exit_pi_state_list(struct task_struct *curr); 78#else 79static inline void exit_pi_state_list(struct task_struct *curr) 80{ 81} 82#endif 83 84#endif