blob: 4815bc9a3cb8151e7fb612670308fe84bb4b533b [file] [log] [blame]
rsccfa37a72004-04-10 18:53:55 +00001.TH GETCALLERPC 3
2.SH NAME
3getcallerpc \- fetch return PC of current function
4.SH SYNOPSIS
5.br
6.B #include <u.h>
7.br
8.B #include <libc.h>
9.PP
10.B ulong getcallerpc(void *firstarg)
11.SH DESCRIPTION
12.I Getcallerpc
13is a portable way to discover the PC to which the current function will return.
14.I Firstarg
15should be a pointer to the first argument to the function in question.
16.SH EXAMPLE
17.IP
18.EX
19void
20printpc(ulong arg)
21{
22 print("Called from %.8lux\en", getcallerpc(&arg));
23}
24
25void
26main(int argc, char *argv[])
27{
28 printpc(0);
29 printpc(0);
30 printpc(0);
31}
32.EE
33.SH SOURCE
rscc3674de2005-01-11 17:37:33 +000034.B \*9/src/lib9/
rsccfa37a72004-04-10 18:53:55 +000035.SH BUGS
36The
37.I firstarg
38parameter should not be necessary.