Go to main content

man pages section 9: DDI and DKI Kernel Functions

Exit Print View

Updated: Wednesday, August 8, 2018
 
 

timespeccompare (9F)

Name

timespeccompare, timespecadd, timespecsub, timespecfix, timespecclear, timespecisset, timevaltotimespec - timespec utility functions. Used to add, subtract, normalize, clear, check if set, and compare two timespec structures.

Synopsis

#include <sys/timespec_util.h>
int timespeccompare(struct timespec *t1, struct timespec *t2);
void timespecadd(struct timespec *t1, struct timespec *t2, struct timespec *res);
void timespecsub(struct timespec *t1, struct timespec *t2, struct timespec *res);
void timespecfix(struct timespec *t1);
void timespecclear(struct timespec *t1);
int timespecisset(struct timespec *t1);
void timevaltotimespec(struct timeval *t1, timespec_t  *t2);

Description

The timespeccompare() function compares two timespec structures. It returns an integer greater than, equal to, or less than 0, if t1 is greater than, equal to, or less than t2 respectively.

The timespecadd() function adds the timespec t2 to t1. The resulting timespec is normalized and stored in res.

The timespecsub() function subtracts timespec t2 from t1. The resulting timespec is normalized and stored in res.

The timespecfix() function, given a timespec t1, adjusts the second and nanosecond values such that the nanoseconds are between 0 and 1 billion, inclusive of 0 and exclusive of 1 billion. Any left over nanoseconds are converted to seconds and added to the value in seconds.

The timespecclear() function initializes the given timespec structure to zero.

The timespecisset() function returns true if the input timespec structure is set to any non-zero time value.

The timevaltotimespec() function converts the value of time in timeval structure to timespec format. Basically, it converts the microseconds in timeval to nanoseconds in timespec.

Attributes

See attributes(7) for descriptions of the following attributes:

ATTRIBUTE TYPE
ATTRIBUTE VALUE
Architecture
SPARC and x86
Interface Stability
Committed
MT-Level
MT-Safe

See Also

timercmp(3C), timeradd(3C)