[PATCH v3 2/3] linux: Add futex_wait, futex_timedwait, futex_wake, and futex_requeue

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Mon Nov 9 13:48:20 GMT 2026



On 06/11/26 05:42, Gabriel Ravier wrote:
>> +@deftypefun int futex_timedwait (uint32_t *@var{futexp}, uint32_t @var{expected}, clockid_t @var{clockid}, const struct timespec *@var{abstime}, unsigned int @var{flags})
>> +@standards{Linux, sys/futex.h}
>> +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
>> +Like @code{futex_wait}, but block at most until the absolute time @var{abstime},
>> +measured against the clock @var{clockid}.  The @var{clockid} must be either
>> +@code{CLOCK_REALTIME} or @code{CLOCK_MONOTONIC}.  If @var{abstime} is @code{NULL},
>> +block without a timeout.
>> +
>> +In addition to the @code{futex_wait} error codes, the following error
>> +codes can be set:
>> +
>> +@table @code
>> +@item ETIMEDOUT
>> +The absolute time @var{abstime} passed before the thread was woken.
>> +An @var{abstime} that already expired is reported as @code{ETIMEDOUT}.
>> +
>> +@item EOVERFLOW
>> +@var{abstime} cannot be represented in the time type used by the
>> +kernel interface.
>> +@end table
>> +@end deftypefun
>> +
>> +@deftypefun int futex_wake (uint32_t *@var{futexp}, int @var{count}, unsigned int @var{flags})
>> +@standards{Linux, sys/futex.h}
>> +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
>> +Wake up to @var{count} threads blocked on the @code{futexp} word.
>> +Using @code{INT_MAX} wake all threads waiting of the futex.
> 
> waiting on the futex, I believe.
> 
>> +
>> +The return value is the number of threads actually woken, which is
>> +zero if no thread was blocked, or @minus{}1 with @code{errno} set to
>> +@code{EINVAL} if @var{futexp} is not aligned to four bytes,
>> +@var{count} is negative, or @var{flags} is not valid.
>> +@end deftypefun
>> +
>> +@deftypefun int futex_requeue (uint32_t *@var{futexp}, uint32_t @var{expected}, int @var{nwake}, uint32_t *@var{targetp}, int @var{nrequeue}, unsigned int @var{flags})
>> +@standards{Linux, sys/futex.h}
>> +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
>> +If the @code{futexp} word  still contains the value @var{expected}, wake upto
> 
> upto -> up to

Ack, I will fix both on next version.


More information about the Libc-alpha mailing list