home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / intrvews / xgrab.lha / xgrab / ui / GC / setjmp_test.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-04-25  |  684 b   |  38 lines

  1. /* Check whether setjmp actually saves registers in jmp_buf. */
  2. /* If it doesn't, the generic mark_regs code won't work.     */
  3. #include <stdio.h>
  4. #include <setjmp.h>
  5. #include "gc.h"
  6. main()
  7. {
  8.     jmp_buf b;
  9.     register int x = 1;
  10.     static int y = 0;
  11.  
  12.     setjmp(b);
  13.     if (y == 1) {
  14.         if (x == 2) {
  15.         printf("Generic mark_regs code wont work\n");
  16. #        ifdef SPARC
  17.             printf("Assembly code supplied\n");
  18. #        else
  19.             printf("Need assembly code\n");
  20. #        endif
  21.         } else if (x == 1) {
  22.         printf("Generic mark_regs code may work\n");
  23.         } else {
  24.         printf("Very strange setjmp implementation\n");
  25.         }
  26.     }
  27.     y++;
  28.     x = 2;
  29.     if (y == 1) longjmp(b);
  30.     return(0);
  31. }
  32.  
  33. int g(x)
  34. int x;
  35. {
  36.     return(x);
  37. }
  38.