clock_nanosleep on x64
high-resolution sleep with specifiable clock
sys_clock_nanosleep(clockid_t which_clock, int flags, const struct __kernel_timespec *rqtp, struct __kernel_timespec *rmtp)
| number | 230 (0xe6) |
|---|---|
| abi | common |
| entry point | sys_clock_nanosleep |
| since | Linux 3.3 or earlier (3.3 is the first release scanned for x64) |
| man page | clock_nanosleep(2) |
| source | elixir.bootlin.com |
Registers
| register | value |
|---|---|
rax | 230, the syscall number |
rdi | clockid_t which_clock |
rsi | int flags |
rdx | const struct __kernel_timespec *rqtp |
r10 | struct __kernel_timespec *rmtp |
rax | the return value |
Then run syscall to enter the kernel.
The syscall instruction clobbers rcx (the return address lands in rcx) and r11 (the flags land in r11).
Since Linux 5.14 the kernel reads the syscall number from eax and ignores the upper 32 bits of rax. Older kernels fail with ENOSYS when those bits are not zero, and mov eax, N clears them, so it works on both.
Same syscall on other architectures
- x86 267
- arm64 115
- arm 265
- riscv64 115
- ia32 267
- x32 1073742054
- loongarch64 115
- ppc64 248
- ppc 248
- s390x 262
- mips64 5224
- mipsn32 6228
- mipso32 4265
- alpha 422
- arc 115
- blackfin 268, removed in 4.17
- cris 267, removed in 4.17
- csky 115
- frv 267, removed in 4.17
- hexagon 115
- ia64 1256, removed in 6.7
- m32r 267, removed in 4.17
- m68k 262
- metag 115, removed in 4.17
- microblaze 267
- mn10300 267, removed in 4.17
- nds32 115, removed in 5.18
- nios2 115
- openrisc 115
- parisc 258
- score 115, removed in 4.17
- sh 267
- sparc 259
- sparc64 259
- tilegx 115, removed in 4.17
- tilepro 115, removed in 4.17
- xtensa 247
Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/clock_nanosleep