setjmp.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. libc_hidden_proto(sigprocmask)
  9. int setjmp( jmp_buf state)
  10. {
  11. asm volatile( "mov %0, G3\n\t"
  12. "mov %1, G4\n\t"
  13. :"=l"(state->__jmpbuf->G3),
  14. "=l"(state->__jmpbuf->G4)
  15. :/*no input*/
  16. :"%G3", "%G4" );
  17. asm volatile( "setadr %0\n\t"
  18. "mov %1, L1\n\t"
  19. "mov %2, L2\n\t"
  20. :"=l"(state->__jmpbuf->SavedSP),
  21. "=l"(state->__jmpbuf->SavedPC),
  22. "=l"(state->__jmpbuf->SavedSR)
  23. :/*no input*/);
  24. return 0;
  25. }
  26. int sigsetjmp( sigjmp_buf state , int savesigs)
  27. {
  28. if(savesigs) {
  29. state->__mask_was_saved = 1;
  30. /* how arg in <sigprocmask> is not significant */
  31. sigprocmask(SIG_SETMASK, NULL, &state->__saved_mask);
  32. } else
  33. state->__mask_was_saved = 0;
  34. asm volatile( "mov %0, G3\n\t"
  35. "mov %1, G4\n\t"
  36. :"=l"(state->__jmpbuf->G3),
  37. "=l"(state->__jmpbuf->G4)
  38. :/*no input*/
  39. :"%G3", "%G4" );
  40. asm volatile( "setadr %0\n\t"
  41. "mov %1, L2\n\t"
  42. "mov %2, L3\n\t"
  43. :"=l"(state->__jmpbuf->SavedSP),
  44. "=l"(state->__jmpbuf->SavedPC),
  45. "=l"(state->__jmpbuf->SavedSR)
  46. :/*no input*/);
  47. return 0;
  48. }