PMTIMEVALNOW(3)
π PMTIMEVALNOW(3) β bestie's guide to the timeval helpers π
okay so this is a page from the Library Functions Manual β it's all about the lil helper routines for time stored as a struct timeval. no cap, these are the glow-up squad for when you've got time in timeval form and you need to do math on it. π°οΈβ¨
β¨ NAME β¨
pmtimevalNow, pmtimevalInc, pmtimevalDec, pmtimevalAdd, pmtimevalSub, pmtimevalToReal, pmtimevalFromReal, pmPrintStamp β helper routines for time stored as a struct timeval π«Ά
π C SYNOPSIS π
#include <pcp/pmapi.h>
void pmtimevalNow(struct timeval *tv);
void pmtimevalInc(struct timeval *ap, const struct timeval *bp);
void pmtimevalDec(struct timeval *ap, const struct timeval *bp);
double pmtimevalAdd(const struct timeval *ap, const struct timeval *bp);
double pmtimevalSub(const struct timeval *ap, const struct timeval *bp);
double pmtimevalToReal(const struct timeval *val);
void pmtimevalFromReal(double secs, struct timeval *val);
void pmPrintStamp(FILE *f, const struct timeval *tp);
cc ... -lpcp
like literally just link -lpcp and you're in business π
πΈ DESCRIPTION πΈ
pmtimevalNow is the platform-independent girlie that grabs the current system time since the Epoch and drops it right into tv. no platform drama, she just delivers. β
pmtimevalInc takes the time in ap, adds the time in bp to it, and stores the result back in ap. and then pmtimevalDec is her mirror twin β she subtracts the time in bp from the time in ap and stores the result in ap. in-place queens, they don't make copies, they just edit ap on the spot. π
pmtimevalAdd (and its sibling pmtimevalSub) add (and subtract) times and hand you back the result as a double value. and the vibe check here? the time in the ap argument is not changed. she's respectful like that, leaves your ap exactly how she found it. π¦
pmtimevalToReal converts the time in tp into an equivalent double value. pmtimevalFromReal is the reverse conversion β takes the time in secs and returns the equivalent time in val. it's giving round-trip energy, iykyk. π₯
pmPrintStamp prints the timestamp from tp onto the stream f in local time (as returned by pmLocaltime(3)) in the format HH:MM:SS.XXX. cute lil stamp, very demure, very mindful. π
π NOTES π
if you want variants of these interfaces that use nanosecond precision and the timespec structure instead, go peek at pmtimespecNow(3). same energy, finer detail. β¨
π SEE ALSO π
and that's the whole page bestie!! this one's brought to you by Performance Co-Pilot (aka PCP), and it lives under the PMTIMEVALNOW(3) name in the manual. go forth and do your time math, you absolute icon ππ
πΈπ¦β¨
π¦ where this page comes from
- centos-stream 9: pcp-doc 6.3.7-14.el9 Β· GPL-2.0-or-later AND CC-BY-3.0
- debian trixie: libpcp3-dev 6.3.8-1
- ubuntu questing: libpcp3-dev 6.3.8-1
- Copyright (c) 2022 Red Hat. All Rights Reserved
- Copyright (c) 2017 Ken McDonell. All Rights Reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms