timespec(3type)
β¨ timespec β your girl's guide to time in seconds AND nanoseconds π
okay so bestie, welcome to timespec(3type), the manual page itself πΈ this is a 3type page, which means it's all about a type you can use in your C code, and I'm about to make it make sense. no cap.
π LIBRARY
Standard C library (that's libc, queen π)
π SYNOPSIS
#include <time.h>
struct timespec {
time_t tv_sec; /* Seconds */
/* ... */ tv_nsec; /* Nanoseconds [0, 999'999'999] */
};
π DESCRIPTION
So like, a timespec describes times in seconds and nanoseconds. That's the whole vibe. Seconds + nanoseconds, together, holding hands π«Ά
Now let's talk tv_nsec, because she's the interesting one. She's of an implementation-defined signed type capable of holding the specified range. Under glibc, this is usually long, and on X32 it's long long. The good news? It can be safely down-cast to any concrete 32-bit integer type for processing. So you can go ahead and narrow her down, she won't break, it's chill π
ngl the "implementation-defined" part is the important bit β don't go assuming she's always the exact same type everywhere, because she is not π
π VERSIONS
Prior to C23, tv_nsec was long. so bestie if you're reading old code, that's the tea β
β STANDARDS
C11, POSIX.1-2024. she's got credentials, periodt π
β¨
π¦ HISTORY
POSIX.1-1996. vintage. iconic. she's been around π
π NOTES
The following headers also provide this type, so you might get timespec even if you didn't ask for it directly β sneaky little fairy π§:
<aio.h><mqueue.h><sched.h><signal.h><sys/select.h><sys/stat.h>
π₯ SEE ALSO
clock_gettime(2)clock_nanosleep(2)nanosleep(2)timerfd_gettime(2)timer_gettime(2)time_t(3type)timeval(3type)
okay that's the whole page and you ATE it π this little gem comes from Linux man-pages 6.20, dated 2026-02-08 β go forth and measure some nanoseconds, bestie, I'm obsessed πβ¨
π¦ 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 2020, 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