test_setjmp.c 347 B

123456789101112131415161718192021
  1. /* 32-bit host test for libc/setjmp.S. */
  2. #include <stdio.h>
  3. #include <setjmp.h>
  4. static jmp_buf env;
  5. static int count;
  6. int main(void)
  7. {
  8. int r = setjmp(env);
  9. count++;
  10. if (r == 0)
  11. longjmp(env, 7);
  12. if (r != 7 || count != 2) {
  13. printf("setjmp test: FAIL r=%d count=%d\n", r, count);
  14. return 1;
  15. }
  16. printf("setjmp test: OK\n");
  17. return 0;
  18. }