timeradd(3)
โจ timeradd โ the timeval glow-up page โจ
okay bestie, welcome to timeradd(3), aka the Library Functions Manual entry for a whole lil squad of macros: timeradd, timersub, timercmp, timerclear, timerisset. they do operations on timeval. that's the whole vibe. ๐
๐ธ NAME ๐ธ
timeradd, timersub, timercmp, timerclear, timerisset โ timeval operations ๐
๐ LIBRARY ๐
Standard C library (libc, -lc)
โจ 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);
๐ง Feature Test Macro Requirements for glibc ๐ง
(peep feature_test_macros(7) if you wanna go deeper, bestie)
- All functions shown above:
- Since glibc 2.19:
_DEFAULT_SOURCE
- glibc 2.19 and earlier:
_BSD_SOURCE
- Since glibc 2.19:
๐ DESCRIPTION ๐
so these macros are here to operate on timeval structures, and <sys/time.h> defines them like this:
struct timeval {
time_t tv_sec; /* seconds */
suseconds_t tv_usec; /* microseconds */
};
not me obsessing over how clean that is. anyway, one by one:
timeradd()โ adds the time values inaandb, and drops the sum into thetimevalpointed to byres. the result gets normalized so thatres->tv_useclands in the range 0 to 999,999. no cap. โจtimersub()โ subtracts the time value inbfrom the time value ina, and puts the result in thetimevalpointed to byres. also normalized sores->tv_usecis in the range 0 to 999,999. periodt. ๐ซถtimerclear()โ zeros out thetimevalstructure pointed to bytvp, so it represents the Epoch:1970-01-01 00:00:00 +0000 (UTC). it's giving the beginning of time, literally. ๐timerisset()โ returns true (nonzero) if either field of thetimevalstructure pointed to bytvpcontains a nonzero value. vibe check on your timer. ๐timercmp()โ compares the timer values inaandbusing the comparison operatorCMP, and returns true (nonzero) or false (0) depending on how that comparison went.
โ ๏ธ bestie listen. some systems (but not Linux/glibc) have a brokentimercmp()implementation whereCMPof>=,<=, and==just do not work. tragic. iconic fail. so portable applications can instead use:c !timercmp(..., <) !timercmp(..., >) !timercmp(..., !=)
๐ RETURN VALUE ๐
timerisset() and timercmp() return true (nonzero) or false (0). that's it, that's the tea. ๐
๐ ERRORS ๐
No errors are defined. โจ zero drama, zero errors, we love a low-maintenance function.
๐ STANDARDS ๐
None. ๐ญ it's just out here living its truth, unstandardized.
๐ฆ HISTORY ๐ฆ
BSD. old money, honestly. ๐
๐ซ SEE ALSO ๐ซ
and that's the whole page, bestie!! go forth and normalize your microseconds responsibly ๐
signing off โ this was Linux man-pages 6.20, dated 2026-02-08, page timeradd(3) ๐โจ
๐ฆ where this page comes from
- arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- ๐ the page's license: Linux-man-pages-copyleft
- Copyright 2007, Michael Kerrisk <mtk.manpages@gmail.com>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms