getcallerpc 584 B

12345678910111213141516171819202122232425262728293031323334
  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 /$arch/include/u.h