getcallerpc 666 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. .TH GETCALLERPC 2
  2. .SH NAME
  3. getcallerpc \- 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 uintptr getcallerpc(void *firstarg)
  11. .SH DESCRIPTION
  12. .I Getcallerpc
  13. is a portable way to discover the PC to which the current function will return.
  14. .I Firstarg
  15. should be a pointer to the first argument to the function in question.
  16. .SH EXAMPLE
  17. .IP
  18. .EX
  19. void
  20. printpc(int arg)
  21. {
  22. print("Called from %p\en", getcallerpc(&arg));
  23. }
  24. void
  25. main(int argc, char *argv[])
  26. {
  27. printpc(0);
  28. printpc(0);
  29. printpc(0);
  30. }
  31. .EE
  32. .SH SOURCE
  33. .B /sys/src/libc/$objtype/getcallerpc.[cs]
  34. .SH BUGS
  35. The
  36. .I firstarg
  37. parameter should not be necessary.