PMEVENTFLAGSSTR(3)
π PMEVENTFLAGSSTR(3) β the pmEventFlagsStr & pmEventFlagsStr_r glow-up π
okay bestie, this is a page from the Library Functions Manual for PCP (Performance Co-Pilot), and it's literally so simple it's giving β¨main characterβ¨. two lil functions, one job: turn a flags number into something a human can actually read. no cap. let's go π«Ά
β¨ NAME β¨
pmEventFlagsStr, pmEventFlagsStr_r β convert an event record flags value into a string π
π C SYNOPSIS π
#include <pcp/pmapi.h>
const char *pmEventFlagsStr(int flags);
char *pmEventFlagsStr_r(int flags, char *buf, int buflen);
cc ... -lpcp
π¦ DESCRIPTION π¦
so here's the vibe. when you're throwing error and diagnostic messages and you've got a raw flags number just sitting there looking cryptic, pmEventFlagsStr swoops in and returns a human readable version of the value flags π
and like β it's assuming that flags is the er_flags field of a pmEventRecord or a pmHighResEventRecord. iykyk. it's not guessing, it's assuming, and that assumption is the whole point π
then there's pmEventFlagsStr_r, which does literally the same thing but drops the result into your buffer instead of its own. that's the buf (user-supplied, you bring it) and buflen (its length). and bestie, make sure buf has room for at least 64 bytes. at least. 64. don't play with it π
β οΈ ok so important tea: the string thatpmEventFlagsStrhands back lives in a single static buffer. that means the value it returns is only valid until the next call topmEventFlagsStr. one call later and your pointer is pointing at somebody else's business π copy it if you need to keep it, fr fr.
πΈ NOTES πΈ
because pmEventFlagsStr returns a pointer to a static buffer, it is not thread-safe π that's just how it is.
multi-threaded applications should use pmEventFlagsStr_r instead β it's the one with the user-supplied buffer, so every thread gets its own lil space and nobody's stepping on anybody π iconic behavior.
π SEE ALSO π
PMAPI(3) and pmdaEventAddRecord(3). go read those next, they're also slay β
k bye bestie, that's the whole page π stay safe out there with your static buffers, and remember: if you're multithreaded, use the _r version, periodt π
β¨ this has been a page from Performance Co-Pilot (PCP) β PMEVENTFLAGSSTR(3) β¨
π¦ where this page comes from
- arch rolling: pcp 7.2.2-2 Β· GPL-2.0-or-later AND LGPL-2.1-or-later AND CC-BY-3.0
- centos-stream 10: pcp-doc 7.1.5-6.el10 Β· GPL-2.0-or-later AND CC-BY-3.0
- fedora 43: pcp-doc 7.0.1-1.fc43 Β· GPL-2.0-or-later AND CC-BY-3.0
- fedora 43: pcp-doc 7.2.1-1.fc43
- fedora 43: pcp-doc 7.2.2-1.fc43
- fedora 43: pcp-doc 7.2.2-2.fc43 Β· GPL-2.0-or-later AND CC-BY-3.0
- fedora 44: pcp-doc 7.1.0-6.fc44 Β· GPL-2.0-or-later AND CC-BY-3.0
- fedora 44: pcp-doc 7.2.1-1.fc44
- fedora 44: pcp-doc 7.2.2-1.fc44
- fedora 44: pcp-doc 7.2.2-2.fc44 Β· GPL-2.0-or-later AND CC-BY-3.0
- ubuntu resolute: libpcp4-dev 7.1.1-1
- ubuntu stonking: libpcp4-dev 7.2.1-2build1
- Copyright (c) 2010 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