[libc-commits] [libc] [libc] Implement sleep and usleep for Linux (PR #213912)
Pavel Labath via libc-commits
libc-commits at lists.llvm.org
Tue Aug 4 04:35:27 PDT 2026
labath wrote:
This is based on https://github.com/llvm/llvm-project/pull/205922 by @kaladron. The main changes are:
- usleep allows values over 1 million, matching other libc implementations. Although the spec says the value “shall be less than one million”, this is a requirement on the caller, not on the implementation: “For an application or user, describes a behavior that is mandatory.” This means we can implement larger values any way we want, including the “right way” :P. I’m certain there is code that depends on this behavior. I found at least one instance in LLVM.
- sleep does not loop and rounds the returned value down. POSIX is quiet on the rounding direction, but this matches other implementations. I suspect that applications that really care about sleeping the right amount of time will be using higher resolution functions.
https://github.com/llvm/llvm-project/pull/213912
More information about the libc-commits
mailing list