---
name: "futex_wait_setup"
section: "9"
platform: "linux"
package: "linux-manual-4.9"
version: "4.9.228-1"
release: "Debian 9 (Stretch)"
platforms: ["linux"]
url: "https://new.carta.tech/futex_wait_setup"
---

# futex\_wait\_setup(9)

Prepare to wait on a futex

## NAME

futex\_wait\_setup - Prepare to wait on a futex

## SYNOPSIS

**int futex\_wait\_setup(u32 \_\_user \*** *uaddr***, u32** *val***, unsigned int** *flags***, struct futex\_q \*** *q***, struct futex\_hash\_bucket \*\*** *hb***);**

## ARGUMENTS

*uaddr*

the futex userspace address

*val*

the expected value

*flags*

futex flags (FLAGS\_SHARED, etc.)

*q*

the associated futex\_q

*hb*

storage for hash\_bucket pointer to be returned to caller

## DESCRIPTION

Setup the futex\_q and locate the hash\_bucket. Get the futex value and compare it with the expected value. Handle atomic faults internally. Return with the hb lock held and a q.key reference on success, and unlocked with no q.key reference on failure.

## RETURN

0 - uaddr contains val and hb has been locked; \<1 - -EFAULT or -EWOULDBLOCK (uaddr does not contain val) and hb is unlocked

## AUTHOR

**Rusty Russell** \<rusty@rustcorp.com.au\>

Author.

## COPYRIGHT
