'\"macro stdmacro
.\"
.\" Copyright (c) 2022 Red Hat.  All Rights Reserved.
.\" Copyright (c) 2017 Ken McDonell.  All Rights Reserved.
.\"
.\" This program is free software; you can redistribute it and/or modify it
.\" under the terms of the GNU General Public License as published by the
.\" Free Software Foundation; either version 2 of the License, or (at your
.\" option) any later version.
.\"
.\" This program is distributed in the hope that it will be useful, but
.\" WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
.\" or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
.\" for more details.
.\"
.\"
.TH PMTIMESPECNOW 3 "PCP" "Performance Co-Pilot"
.SH NAME
\f3pmtimespecNow\f1,
\f3pmtimespecInc\f1,
\f3pmtimespecDec\f1,
\f3pmtimespecAdd\f1,
\f3pmtimespecSub\f1,
\f3pmtimespecToReal\f1,
\f3pmtimespecFromReal\f1,
\f3pmPrintHighResStamp\f1 \- helper routines for time stored as a struct timespec
.SH "C SYNOPSIS"
.ft 3
#include <pcp/pmapi.h>
.sp
void pmtimespecNow(struct timespec *\fItp\fP);
.br
void pmtimespecInc(struct timespec *\fIap\fP, const struct timespec *\fIbp\fP);
.br
void pmtimespecDec(struct timespec *\fIap\fP, const struct timespec *\fIbp\fP);
.br
double pmtimespecAdd(const struct timespec *\fIap\fP, const struct timespec *\fIbp\fP);
.br
double pmtimespecSub(const struct timespec *\fIap\fP, const struct timespec *\fIbp\fP);
.br
double pmtimespecToReal(const struct timespec *\fItp\fP);
.br
void pmtimespecFromReal(double \fIsecs\fP, struct timespec *\fItp\fP);
.br
void pmPrintHighResStamp(FILE *\fIf\fP, const struct timespec *\fItp\fP);
.sp
cc ... \-lpcp
.ft 1
.SH DESCRIPTION
.B pmtimespecNow
is a platform-independent method that returns the current system time
since the Epoch in
.IR tp .
.PP
.B pmtimespecInc
adds the time in
.I ap
to the time in
.I bp
and stores the result in
.IR ap .
Similarly
.B pmtimespecDec
subtracts the time in
.I bp
from the time in
.I ap
and stores the result in
.IR ap .
.PP
.B pmtimespecAdd
(and
.BR pmtimespecSub )
add (and subtract) times and return the result as a double value.
The time in the
.I ap
argument is not changed.
.PP
.B pmtimespecToReal
converts the time in
.I tp
to an equivalent double value.
.B pmtimespecFromReal
provides the reverse conversion, taking the time in
.I secs
and returning the equivalent time in
.IR tp .
.PP
.B pmPrintHighResStamp
prints the timestamp from
.I tp
on the stream
.I f
in the local time (as returned by
.BR pmLocaltime (3))
in the format HH:MM:SS.XXXXXXXXX.
.SH NOTES
For variants of these interfaces using microsecond precision
and the timeval structure, refer to
.BR pmtimevalNow (3).
.SH SEE ALSO
.BR PMAPI (3),
.BR pmLocaltime (3)
and
.BR pmtimevalNow (3).