timespec_get()

Updated: May 06, 2022

Get the number of seconds and nanoseconds since a given epoch

Synopsis:

#include <time.h>

int timespec_get( struct timespec *ts,
                  int base );

Arguments:

ts
A pointer to a timespec structure where the function can store the time.
base
The epoch; this must currently be TIME_UTC, which corresponds to January 1, 1970.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The timespec_get() function gets the number of seconds and nanoseconds since a given epoch. It's similar to calling clock_gettime(CLOCK_REALTIME, ts).

Returns:

The given base, or 0 if an error occurred.

Classification:

C11

Safety:  
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes