linux/include/uapi/linux/futex.h

/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
#ifndef _UAPI_LINUX_FUTEX_H
#define _UAPI_LINUX_FUTEX_H

#include <linux/compiler.h>
#include <linux/types.h>

/* Second argument to futex syscall */


#define FUTEX_WAIT
#define FUTEX_WAKE
#define FUTEX_FD
#define FUTEX_REQUEUE
#define FUTEX_CMP_REQUEUE
#define FUTEX_WAKE_OP
#define FUTEX_LOCK_PI
#define FUTEX_UNLOCK_PI
#define FUTEX_TRYLOCK_PI
#define FUTEX_WAIT_BITSET
#define FUTEX_WAKE_BITSET
#define FUTEX_WAIT_REQUEUE_PI
#define FUTEX_CMP_REQUEUE_PI
#define FUTEX_LOCK_PI2

#define FUTEX_PRIVATE_FLAG
#define FUTEX_CLOCK_REALTIME
#define FUTEX_CMD_MASK

#define FUTEX_WAIT_PRIVATE
#define FUTEX_WAKE_PRIVATE
#define FUTEX_REQUEUE_PRIVATE
#define FUTEX_CMP_REQUEUE_PRIVATE
#define FUTEX_WAKE_OP_PRIVATE
#define FUTEX_LOCK_PI_PRIVATE
#define FUTEX_LOCK_PI2_PRIVATE
#define FUTEX_UNLOCK_PI_PRIVATE
#define FUTEX_TRYLOCK_PI_PRIVATE
#define FUTEX_WAIT_BITSET_PRIVATE
#define FUTEX_WAKE_BITSET_PRIVATE
#define FUTEX_WAIT_REQUEUE_PI_PRIVATE
#define FUTEX_CMP_REQUEUE_PI_PRIVATE

/*
 * Flags for futex2 syscalls.
 *
 * NOTE: these are not pure flags, they can also be seen as:
 *
 *   union {
 *     u32  flags;
 *     struct {
 *       u32 size    : 2,
 *           numa    : 1,
 *                   : 4,
 *           private : 1;
 *     };
 *   };
 */
#define FUTEX2_SIZE_U8
#define FUTEX2_SIZE_U16
#define FUTEX2_SIZE_U32
#define FUTEX2_SIZE_U64
#define FUTEX2_NUMA
			/*	0x08 */
			/*	0x10 */
			/*	0x20 */
			/*	0x40 */
#define FUTEX2_PRIVATE

#define FUTEX2_SIZE_MASK

/* do not use */
#define FUTEX_32

/*
 * Max numbers of elements in a futex_waitv array
 */
#define FUTEX_WAITV_MAX

/**
 * struct futex_waitv - A waiter for vectorized wait
 * @val:	Expected value at uaddr
 * @uaddr:	User address to wait on
 * @flags:	Flags for this waiter
 * @__reserved:	Reserved member to preserve data alignment. Should be 0.
 */
struct futex_waitv {};

/*
 * Support for robust futexes: the kernel cleans up held futexes at
 * thread exit time.
 */

/*
 * Per-lock list entry - embedded in user-space locks, somewhere close
 * to the futex field. (Note: user-space uses a double-linked list to
 * achieve O(1) list add and remove, but the kernel only needs to know
 * about the forward link)
 *
 * NOTE: this structure is part of the syscall ABI, and must not be
 * changed.
 */
struct robust_list {};

/*
 * Per-thread list head:
 *
 * NOTE: this structure is part of the syscall ABI, and must only be
 * changed if the change is first communicated with the glibc folks.
 * (When an incompatible change is done, we'll increase the structure
 *  size, which glibc will detect)
 */
struct robust_list_head {};

/*
 * Are there any waiters for this robust futex:
 */
#define FUTEX_WAITERS

/*
 * The kernel signals via this bit that a thread holding a futex
 * has exited without unlocking the futex. The kernel also does
 * a FUTEX_WAKE on such futexes, after setting the bit, to wake
 * up any possible waiters:
 */
#define FUTEX_OWNER_DIED

/*
 * The rest of the robust-futex field is for the TID:
 */
#define FUTEX_TID_MASK

/*
 * This limit protects against a deliberately circular list.
 * (Not worth introducing an rlimit for it)
 */
#define ROBUST_LIST_LIMIT

/*
 * bitset with all bits set for the FUTEX_xxx_BITSET OPs to request a
 * match of any bit.
 */
#define FUTEX_BITSET_MATCH_ANY


#define FUTEX_OP_SET
#define FUTEX_OP_ADD
#define FUTEX_OP_OR
#define FUTEX_OP_ANDN
#define FUTEX_OP_XOR

#define FUTEX_OP_OPARG_SHIFT

#define FUTEX_OP_CMP_EQ
#define FUTEX_OP_CMP_NE
#define FUTEX_OP_CMP_LT
#define FUTEX_OP_CMP_LE
#define FUTEX_OP_CMP_GT
#define FUTEX_OP_CMP_GE

/* FUTEX_WAKE_OP will perform atomically
   int oldval = *(int *)UADDR2;
   *(int *)UADDR2 = oldval OP OPARG;
   if (oldval CMP CMPARG)
     wake UADDR2;  */

#define FUTEX_OP(op, oparg, cmp, cmparg)

#endif /* _UAPI_LINUX_FUTEX_H */