BSD syscall#116
svc · unix #116
gettimeofday
Returns the current wall-clock time and (legacy) timezone information.
Prototype
int gettimeofday(struct timeval *tp, struct timezone *tzp);Returns: int
Arguments
| Name | Type | Dir | Description |
|---|---|---|---|
| tp | struct timeval | - | |
| tzp | struct timezone | - |
Version history
| XNU tag | macOS | # |
|---|---|---|
| xnu-1456.1.26 | macOS 10.6 Snow Leopard | 116 |
| xnu-1486.2.11 | — | 116 |
| xnu-1504.15.3 | — | 116 |
| xnu-1504.3.12 | — | 116 |
| xnu-1504.7.4 | — | 116 |
| xnu-1504.9.17 | — | 116 |
| xnu-1504.9.26 | — | 116 |
| xnu-1504.9.37 | — | 116 |
Notes
On macOS, the commpage exports a vDSO-style fast path so most calls do not enter the kernel. The second tzp argument is obsolete and should be NULL; timezone data lives in /var/db/timezone. For monotonic timings prefer clock_gettime(CLOCK_MONOTONIC) or mach_absolute_time().
Related APIs
settimeofdayadjtimentp_gettimegetitimersetitimer