at v5.4 1.9 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 12/* 13 * Futexes are matched on equal values of this key. 14 * The key type depends on whether it's a shared or private mapping. 15 * Don't rearrange members without looking at hash_futex(). 16 * 17 * offset is aligned to a multiple of sizeof(u32) (== 4) by definition. 18 * We use the two low order bits of offset to tell what is the kind of key : 19 * 00 : Private process futex (PTHREAD_PROCESS_PRIVATE) 20 * (no reference on an inode or mm) 21 * 01 : Shared futex (PTHREAD_PROCESS_SHARED) 22 * mapped on a file (reference on the underlying inode) 23 * 10 : Shared futex (PTHREAD_PROCESS_SHARED) 24 * (but private mapping on an mm, and reference taken on it) 25*/ 26 27#define FUT_OFF_INODE 1 /* We set bit 0 if key has a reference on inode */ 28#define FUT_OFF_MMSHARED 2 /* We set bit 1 if key has a reference on mm */ 29 30union futex_key { 31 struct { 32 unsigned long pgoff; 33 struct inode *inode; 34 int offset; 35 } shared; 36 struct { 37 unsigned long address; 38 struct mm_struct *mm; 39 int offset; 40 } private; 41 struct { 42 unsigned long word; 43 void *ptr; 44 int offset; 45 } both; 46}; 47 48#define FUTEX_KEY_INIT (union futex_key) { .both = { .ptr = NULL } } 49 50#ifdef CONFIG_FUTEX 51extern void exit_robust_list(struct task_struct *curr); 52 53long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout, 54 u32 __user *uaddr2, u32 val2, u32 val3); 55#else 56static inline void exit_robust_list(struct task_struct *curr) 57{ 58} 59 60static inline long do_futex(u32 __user *uaddr, int op, u32 val, 61 ktime_t *timeout, u32 __user *uaddr2, 62 u32 val2, u32 val3) 63{ 64 return -EINVAL; 65} 66#endif 67 68#ifdef CONFIG_FUTEX_PI 69extern void exit_pi_state_list(struct task_struct *curr); 70#else 71static inline void exit_pi_state_list(struct task_struct *curr) 72{ 73} 74#endif 75 76#endif