TIMERADD(3)
๐ NAME ๐
timeradd, timersub, timerclear, timerisset, timercmp, timespecadd, timespecsub, timespecclear, timespecisset, timespeccmp โ operations on timevals and timespecs
okay bestie, welcome to TIMERADD(3) from the Library Functions Manual ๐
โจ
โจ SYNOPSIS โจ
#include <sys/time.h>
void
timeradd(struct timeval *a, struct timeval *b, struct timeval *res);
void
timersub(struct timeval *a, struct timeval *b, struct timeval *res);
void
timerclear(struct timeval *tvp);
int
timerisset(struct timeval *tvp);
int
timercmp(struct timeval *a, struct timeval *b, CMP);
void
timespecadd(struct timespec *a, struct timespec *b,
struct timespec *res);
void
timespecsub(struct timespec *a, struct timespec *b,
struct timespec *res);
void
timespecclear(struct timespec *ts);
int
timespecisset(struct timespec *ts);
int
timespeccmp(struct timespec *a, struct timespec *b, CMP);
๐ฆ DESCRIPTION ๐ฆ
okay so these macros are literally here to help you manipulate timeval and timespec structures โ the ones you use with the clock_gettime(2), clock_settime(2), gettimeofday(2), and settimeofday(2) calls. no cap, they're little time-math besties ๐ซถ
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()andtimespecadd()โ these add the time information stored inatob, then store the result inresโจ. The results are simplified so that the value ofres->tv_usecorres->tv_nsecis always less than 1 second. periodt.timersub()andtimespecsub()โ these subtract the time information stored inbfroma, then store the result inres๐.timerclear()andtimespecclear()โ these initialize their argument to midnight (0 hour) January 1st, 1970 (the Epoch) ๐.timerisset()andtimespecisset()โ these return true if their argument is set to any time value other than the Epoch ๐.timercmp()andtimespeccmp()โ these compareatobusing the comparison operator given inCMP, and return the result of that comparison ๐ .
๐ SEE ALSO ๐
go peek at clock_gettime(2) and gettimeofday(2) โ linked-up besties, iykyk ๐ง
๐ HISTORY ๐
The timeradd() family of macros were imported from NetBSD 1.1, and appeared in FreeBSD 2.2.6. The timespecadd() family of macros were imported from NetBSD 1.3 into FreeBSD 3.0, though they were not exposed to userland until FreeBSD 12.0. iconic timeline behavior, honestly ๐
xoxo, your Debian manual girlie โ this page's source/version is Debian, dated July 30, 2018, and it's TIMERADD(3) through and through ๐๐ซถ
๐ฆ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright (c) 1999 Kelly Yancey <kbyanc@posi.net>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms