TIMERADD(3)

๐Ÿ“ฆ version 15.1, in freebsd 14.5, freebsd 15.1

๐Ÿ’– 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() and timespecadd() โ€” these add the time information stored in a to b, then store the result in res โœจ. The results are simplified so that the value of res->tv_usec or res->tv_nsec is always less than 1 second. periodt.
  • timersub() and timespecsub() โ€” these subtract the time information stored in b from a, then store the result in res ๐Ÿ’–.
  • timerclear() and timespecclear() โ€” these initialize their argument to midnight (0 hour) January 1st, 1970 (the Epoch) ๐Ÿ•›.
  • timerisset() and timespecisset() โ€” these return true if their argument is set to any time value other than the Epoch ๐Ÿ‘€.
  • timercmp() and timespeccmp() โ€” these compare a to b using the comparison operator given in CMP, 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