timersub3
Operations on timevals and timespecs
Part of timeradd(3).
Usage
void
void
void
int
int
void
void
void
int
int
Overview
These macros are provided for manipulating timeval and timespec structures for use with the clock_gettime(2), clock_settime(2), gettimeofday(2) and settimeofday(2) calls. The timeval structure is defined in ⟨sys/time.h⟩ as:
struct timeval {
long tv_sec; /* seconds since Jan. 1, 1970 */
long tv_usec; /* and microseconds */
};
And the timespec structure is defined in ⟨time.h⟩ as:
struct timespec {
time_t tv_sec; /* seconds */
long tv_nsec; /* and nanoseconds */
};
timeradd() and timespecadd() add the time information stored in a to b and store the result in res. The results are simplified such that the value of res->tv_usec or res->tv_nsec is always less than 1 second.
timersub() and timespecsub() subtract the time information stored in b from a and store the result in res.
timerclear() and timespecclear() initialize their argument to midnight (0 hour) January 1st, 1970 (the Epoch).
timerisset() and timespecisset() return true if their argument is set to any time value other than the Epoch.
timercmp() and timespeccmp() compare a to b using the comparison operator given in CMP, and return the result of that comparison.
History
- FreeBSD 16.0-CURRENT (2026-10-27) to FreeBSD 14.3-RELEASE: the text shown here
- FreeBSD 14.2-RELEASE to FreeBSD 14.0-RELEASE
- FreeBSD 13.5-RELEASE
- FreeBSD 13.4-RELEASE to FreeBSD 13.3-RELEASE
- FreeBSD 13.2-RELEASE to FreeBSD 13.0-RELEASE
- FreeBSD 12.4-RELEASE
- FreeBSD 12.3-RELEASE
- FreeBSD 12.2-RELEASE
- FreeBSD 12.1-RELEASE
- FreeBSD 12.0-RELEASE
- FreeBSD 11.4-RELEASE
- FreeBSD 11.3-RELEASE
- FreeBSD 11.2-RELEASE
- FreeBSD 11.1-RELEASE
- FreeBSD 11.0-RELEASE
- FreeBSD 10.4-RELEASE
- FreeBSD 10.3-RELEASE
- FreeBSD 10.2-RELEASE
- FreeBSD 10.1-RELEASE
- FreeBSD 10.0-RELEASE
- FreeBSD 9.3-RELEASE
- FreeBSD 9.2-RELEASE
- FreeBSD 9.1-RELEASE
- FreeBSD 9.0-RELEASE
- FreeBSD 8.4-RELEASE
- FreeBSD 8.3-RELEASE
- FreeBSD 8.2-RELEASE
- FreeBSD 8.1-RELEASE
- FreeBSD 8.0-RELEASE
- FreeBSD 7.4-RELEASE
- FreeBSD 7.3-RELEASE
- FreeBSD 7.2-RELEASE
- FreeBSD 7.1-RELEASE
- FreeBSD 7.0-RELEASE
- FreeBSD 6.4-RELEASE
- FreeBSD 6.3-RELEASE to FreeBSD 5.2-RELEASE
- FreeBSD 5.1-RELEASE to FreeBSD 5.0-RELEASE