nmsg 1.1.2
Functions
timespec.h File Reference

Sleeping and getting the current time. More...

Go to the source code of this file.

Functions

void nmsg_timespec_get (struct timespec *ts)
 Get the current time.
 
void nmsg_timespec_sleep (const struct timespec *ts)
 Sleep.
 
void nmsg_timespec_add (const struct timespec *a, struct timespec *b)
 Add timespecs a and b, placing result in b.
 
void nmsg_timespec_sub (const struct timespec *a, struct timespec *b)
 Subtract timespec a from b, placing result in b.
 
double nmsg_timespec_to_double (const struct timespec *ts)
 Convert timespec to floating point representation.
 
void nmsg_timespec_from_double (double seconds, struct timespec *ts)
 Convert floating point number of seconds to timespec.
 

Detailed Description

Sleeping and getting the current time.

Definition in file timespec.h.

Function Documentation

◆ nmsg_timespec_get()

void nmsg_timespec_get ( struct timespec *  ts)

Get the current time.

If available, clock_gettime() will be used to attempt to get the current real time. If unavailable, gettimeofday() will be used and scaled up to nanosecond precision.

Parameters
[out]tscurrent time.

◆ nmsg_timespec_sleep()

void nmsg_timespec_sleep ( const struct timespec *  ts)

Sleep.

nanosleep() will be called, and reinvoked if interrupted.

Parameters
[in]tsduration to sleep.

◆ nmsg_timespec_add()

void nmsg_timespec_add ( const struct timespec *  a,
struct timespec *  b 
)

Add timespecs a and b, placing result in b.

(b = b + a).

Parameters
[in]a
[in,out]b

◆ nmsg_timespec_sub()

void nmsg_timespec_sub ( const struct timespec *  a,
struct timespec *  b 
)

Subtract timespec a from b, placing result in b.

(b = b - a).

Parameters
[in]a
[in,out]b

◆ nmsg_timespec_to_double()

double nmsg_timespec_to_double ( const struct timespec *  ts)

Convert timespec to floating point representation.

Parameters
[in]ts
Returns
Floating point number of seconds.

◆ nmsg_timespec_from_double()

void nmsg_timespec_from_double ( double  seconds,
struct timespec *  ts 
)

Convert floating point number of seconds to timespec.

Parameters
[in]secondsFloating point number of seconds.
[out]ts