gettimeofday on x64
get / set time
sys_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz)
| number | 96 (0x60) |
|---|---|
| abi | common |
| entry point | sys_gettimeofday |
| since | Linux 3.3 or earlier (3.3 is the first release scanned for x64) |
| man page | gettimeofday(2) |
| source | elixir.bootlin.com |
Registers
| register | value |
|---|---|
rax | 96, the syscall number |
rdi | struct __kernel_old_timeval *tv |
rsi | struct timezone *tz |
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 78
- arm64 169
- arm 78
- riscv64 169
- ia32 78
- x32 1073741920
- loongarch64 169
- ppc64 78
- ppc 78
- s390x 78
- mips64 5094
- mipsn32 6094
- mipso32 4078
- alpha 359
- arc 169
- blackfin 78, removed in 4.17
- cris 78, removed in 4.17
- csky 169
- frv 78, removed in 4.17
- hexagon 169
- ia64 1087, removed in 6.7
- m32r 78, removed in 4.17
- m68k 78
- metag 169, removed in 4.17
- microblaze 78
- mn10300 78, removed in 4.17
- nds32 169, removed in 5.18
- nios2 169
- openrisc 169
- parisc 78
- score 169, removed in 4.17
- sh 78
- sparc 116
- sparc64 116
- tilegx 169, removed in 4.17
- tilepro 169, removed in 4.17
- xtensa 192
Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/gettimeofday