getcallerpc.c 511 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include <u.h>
  2. #include <libc.h>
  3. /*
  4. * Do nothing. We can't exits from this one. It tests correctness of programs
  5. * that just return.
  6. */
  7. void c(void);
  8. void b(void);
  9. void a(void)
  10. {
  11. uintptr_t d = getcallerpc()
  12. ;
  13. fprint(2, "This should print something more than %p and less than %p: %p\n",
  14. b, c, d);
  15. if ((d > b) && (d < c)) {
  16. print("PASS\n");
  17. exits("PASS");
  18. return;
  19. }
  20. print("FAIL\n");
  21. exits("FAIL");
  22. }
  23. void b(void)
  24. {
  25. a();
  26. }
  27. void c(void)
  28. {
  29. b();
  30. }
  31. void
  32. main(int argc, char *argv[])
  33. {
  34. c();
  35. }