liveBook · Manning

Struct timespec

struct timespec is a C structure type representing a time value with integral seconds and a fractional nanosecond component.

How 2 Manning books explain it

Modern C, Third Edition

struct timespec is a C structure type representing a time value with seconds and a nanosecond component.

How it is used
Represents time values when the one-second granularity of time_t is insufficient.
How deep it goes
Defines the two fields and their value ranges, then connects the type to acquisition, resolution, and difference operations.
Examples
Uses a declaration listing tv_sec and tv_nsec, plus timespec_get and timespec_getres function prototypes.
What you can do after
Apply it via timespec_get to obtain nanosecond-precision time values and implement portable differences between them.

Read how Modern C, Third Edition explains struct timespec →

Modern C

struct timespec is a C structure type that represents a time interval or timestamp with integral seconds and fractional nanoseconds.

How it is used
Represents timestamps or intervals when second-level time_t precision is insufficient.
How deep it goes
Defines nanosecond precision and timespec_get usage, but does not explain representation or arithmetic internals.
Examples
Uses a timespec_get declaration and contrasts wall-clock, monotonic, and processor-time clocks.
What you can do after
Operate timespec_get with TIME_UTC to obtain a timestamp containing nanosecond precision.

Read how Modern C explains struct timespec →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.