timespec(3type)

timespec3type

Time in seconds and nanoseconds

Usage

#include <time.h>

struct timespec { time_t tv_sec; /* Seconds */ /* ... */ tv_nsec; /* Nanoseconds [0, 999'999'999] */ };

Library

Standard C library (libc)

Overview

Describes times in seconds and nanoseconds.

tv_nsec is of an implementation-defined signed type capable of holding the specified range. Under glibc, this is usually long, and long long on X32. It can be safely down-cast to any concrete 32-bit integer type for processing.

Versions

Prior to C23, tv_nsec was long.

Notes

The following headers also provide this type: <aio.h>, <mqueue.h>, <sched.h>, <signal.h>, <sys/select.h>, and <sys/stat.h>.

Releases

3 releases since Debian 12 (Bookworm); the text changed 2 times.

  1. 12
  2. 13
  3. Arch

Standards

C11, POSIX.1-2024.

History

POSIX.1-1996.

From man-pages 6.19-1 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.