Go to main content

man pages section 3: Basic Library Functions

Exit Print View

Updated: Wednesday, July 27, 2022
 
 

timespeccmp (3C)

Name

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

Synopsis

#include <sys/timespec_util.h>
int timespeccmp(struct timespec *t1, struct timespec *t2, CMP)
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);

Description

The timespeccmp() macro compares t1 to t2 using the comparison operator given in CMP, where CMP is one of <, <=, ==, !=, >=, or >. The result of the comparison is returned.

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 t2 to t1. The resulting timespec value is normalized and stored in res.

The timespecsub() function subtracts t2 from t1. The resulting timespec value 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.

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)