GETCALLERPC(3)

πŸ“¦ version 0_git20260208, in alpine 3.24, arch rolling, nixos 26.05, nixpkgs unstable

✨ NAME ✨

getcallerpc β€” fetch return PC of current function. This is the GETCALLERPC(3) manual page, bestie, and we’re about to get a little PC-coded. πŸ’…

πŸŽ€ SYNOPSIS πŸŽ€

#include <u.h>
#include <libc.h>

ulong getcallerpc(void *firstarg)

πŸ’… DESCRIPTION πŸ’…

Okay so Getcallerpc is a portable way to discover the PC to which the current function will return. That’s the whole assignment, no cap. ✨

firstarg should be a pointer to the first argument to the function in question. That’s it β€” pointer to the first arg, main character of the parameter list. 🫢

🌸 EXAMPLE 🌸

Here’s the example, exactly as the page gives it, bestie β€” don’t let the indentation vibe-check you:

void
printpc(ulong arg)
{
     print("Called from %.8lux\n", getcallerpc(&arg));
}

void
main(int argc, char *argv[])
{
     printpc(0);
     printpc(0);
     printpc(0);
}

πŸ¦‹ SOURCE πŸ¦‹

/src/lib9/

πŸ’€ BUGS πŸ’€

ngl, the firstarg parameter should not be necessary. That’s the bug note, periodt. πŸ’€


that’s the whole page, bestie β€” GETCALLERPC(3) from the Library Functions Manual, source at /src/lib9/, and the footer gave us no date, so we’re not inventing one. πŸ«ΆπŸ’–