setjmp.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /* This file is lisenced under LGPL
  2. * Copyright (C) 2002-2003, George Thanos <george.thanos@gdt.gr>
  3. * Yannis Mitsos <yannis.mitsos@gdt.gr>
  4. */
  5. #include <setjmp.h>
  6. #include <stdio.h>
  7. #include <signal.h>
  8. int setjmp( jmp_buf state)
  9. {
  10. asm volatile( "mov %0, G3\n\t"
  11. "mov %1, G4\n\t"
  12. :"=l"(state->__jmpbuf->G3),
  13. "=l"(state->__jmpbuf->G4)
  14. :/*no input*/
  15. :"%G3", "%G4" );
  16. asm volatile( "setadr %0\n\t"
  17. "mov %1, L1\n\t"
  18. "mov %2, L2\n\t"
  19. :"=l"(state->__jmpbuf->SavedSP),
  20. "=l"(state->__jmpbuf->SavedPC),
  21. "=l"(state->__jmpbuf->SavedSR)
  22. :/*no input*/);
  23. return 0;
  24. }
  25. int sigsetjmp( sigjmp_buf state , int savesigs)
  26. {
  27. if(savesigs) {
  28. state->__mask_was_saved = 1;
  29. /* how arg in <sigprocmask> is not significant */
  30. __sigprocmask(SIG_SETMASK, NULL, &state->__saved_mask);
  31. } else
  32. state->__mask_was_saved = 0;
  33. asm volatile( "mov %0, G3\n\t"
  34. "mov %1, G4\n\t"
  35. :"=l"(state->__jmpbuf->G3),
  36. "=l"(state->__jmpbuf->G4)
  37. :/*no input*/
  38. :"%G3", "%G4" );
  39. asm volatile( "setadr %0\n\t"
  40. "mov %1, L2\n\t"
  41. "mov %2, L3\n\t"
  42. :"=l"(state->__jmpbuf->SavedSP),
  43. "=l"(state->__jmpbuf->SavedPC),
  44. "=l"(state->__jmpbuf->SavedSR)
  45. :/*no input*/);
  46. return 0;
  47. }