tools/testing/selftests/futex/include/futextest.h
Source file repositories/reference/linux-study-clean/tools/testing/selftests/futex/include/futextest.h
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/futex/include/futextest.h- Extension
.h- Size
- 8400 bytes
- Lines
- 291
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
unistd.hsys/syscall.hsys/types.hlinux/futex.h
Detected Declarations
function architecturesfunction futex_wakefunction futex_wait_bitsetfunction futex_wake_bitsetfunction futex_lock_pifunction futex_unlock_pifunction futex_wake_opfunction futex_requeuefunction futex_cmp_requeuefunction futex_wait_requeue_pifunction futex_cmp_requeue_pifunction futex_cmpxchgfunction futex_decfunction futex_incfunction futex_set
Annotated Snippet
#ifndef _FUTEXTEST_H
#define _FUTEXTEST_H
#include <unistd.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <linux/futex.h>
typedef volatile u_int32_t futex_t;
#define FUTEX_INITIALIZER 0
/* Define the newer op codes if the system header file is not up to date. */
#ifndef FUTEX_WAIT_BITSET
#define FUTEX_WAIT_BITSET 9
#endif
#ifndef FUTEX_WAKE_BITSET
#define FUTEX_WAKE_BITSET 10
#endif
#ifndef FUTEX_WAIT_REQUEUE_PI
#define FUTEX_WAIT_REQUEUE_PI 11
#endif
#ifndef FUTEX_CMP_REQUEUE_PI
#define FUTEX_CMP_REQUEUE_PI 12
#endif
#ifndef FUTEX_ROBUST_UNLOCK
#define FUTEX_ROBUST_UNLOCK 512
#endif
#ifndef FUTEX_ROBUST_LIST32
#define FUTEX_ROBUST_LIST32 1024
#endif
#ifndef FUTEX_WAIT_REQUEUE_PI_PRIVATE
#define FUTEX_WAIT_REQUEUE_PI_PRIVATE (FUTEX_WAIT_REQUEUE_PI | \
FUTEX_PRIVATE_FLAG)
#endif
#ifndef FUTEX_REQUEUE_PI_PRIVATE
#define FUTEX_CMP_REQUEUE_PI_PRIVATE (FUTEX_CMP_REQUEUE_PI | \
FUTEX_PRIVATE_FLAG)
#endif
/*
* SYS_futex is expected from system C library, in glibc some 32-bit
* architectures (e.g. RV32) are using 64-bit time_t, therefore it doesn't have
* SYS_futex defined but just SYS_futex_time64. Define SYS_futex as
* SYS_futex_time64 in this situation to ensure the compilation and the
* compatibility.
*/
#if !defined(SYS_futex) && defined(SYS_futex_time64)
#define SYS_futex SYS_futex_time64
#endif
/*
* On 32bit systems if we use "-D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64" or if
* we are using a newer compiler then the size of the timestamps will be 64bit,
* however, the SYS_futex will still point to the 32bit futex system call.
*/
#if __SIZEOF_POINTER__ == 4 && defined(SYS_futex_time64) && \
defined(_TIME_BITS) && _TIME_BITS == 64
# undef SYS_futex
# define SYS_futex SYS_futex_time64
#endif
/**
* futex() - SYS_futex syscall wrapper
* @uaddr: address of first futex
* @op: futex op code
* @val: typically expected value of uaddr, but varies by op
* @timeout: typically an absolute struct timespec (except where noted
* otherwise). Overloaded by some ops
* @uaddr2: address of second futex for some ops\
* @val3: varies by op
* @opflags: flags to be bitwise OR'd with op, such as FUTEX_PRIVATE_FLAG
*
* futex() is used by all the following futex op wrappers. It can also be
* used for misuse and abuse testing. Generally, the specific op wrappers
* should be used instead. It is a macro instead of an static inline function as
* some of the types over overloaded (timeout is used for nr_requeue for
* example).
*
* These argument descriptions are the defaults for all
* like-named arguments in the following wrappers except where noted below.
*/
#define futex(uaddr, op, val, timeout, uaddr2, val3, opflags) \
syscall(SYS_futex, uaddr, op | opflags, val, timeout, uaddr2, val3)
/**
* futex_wait() - block on uaddr with optional timeout
* @timeout: relative timeout
*/
static inline int
futex_wait(futex_t *uaddr, futex_t val, struct timespec *timeout, int opflags)
Annotation
- Immediate include surface: `unistd.h`, `sys/syscall.h`, `sys/types.h`, `linux/futex.h`.
- Detected declarations: `function architectures`, `function futex_wake`, `function futex_wait_bitset`, `function futex_wake_bitset`, `function futex_lock_pi`, `function futex_unlock_pi`, `function futex_wake_op`, `function futex_requeue`, `function futex_cmp_requeue`, `function futex_wait_requeue_pi`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.