longjmp.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Copyright (C) 2002-2003, George Thanos <george.thanos@gdt.gr>
  3. * Yannis Mitsos <yannis.mitsos@gdt.gr>
  4. * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
  5. *
  6. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  7. */
  8. #include <syscall.h>
  9. #include <setjmp.h>
  10. #include <stdio.h>
  11. #include <signal.h>
  12. #define __NR_e1newSP 224
  13. static inline _syscall1(int, e1newSP, unsigned long, SavedSP )
  14. unsigned long jmpbuf_ptr;
  15. void longjmp(jmp_buf state, int value )
  16. {
  17. if(!value)
  18. state->__jmpbuf->ReturnValue = 1;
  19. else
  20. state->__jmpbuf->ReturnValue = value;
  21. jmpbuf_ptr = (unsigned long)state;
  22. e1newSP(state->__jmpbuf->SavedSP);
  23. #define _state_ ((struct __jmp_buf_tag*)jmpbuf_ptr)
  24. __asm__ __volatile__("mov L0, %0\n\t"
  25. "mov L1, %1\n\t"
  26. "mov L2, %2\n\t"
  27. "mov G3, %3\n\t"
  28. "mov G4, %4\n\t"
  29. "ret PC, L1\n\t"
  30. :/*no output*/
  31. :"l"(_state_->__jmpbuf->ReturnValue),
  32. "l"(_state_->__jmpbuf->SavedPC),
  33. "l"(_state_->__jmpbuf->SavedSR),
  34. "l"(_state_->__jmpbuf->G3),
  35. "l"(_state_->__jmpbuf->G4)
  36. :"%G3", "%G4", "%L0", "%L1" );
  37. #undef _state_
  38. }
  39. libc_hidden_proto(sigprocmask)
  40. void siglongjmp(sigjmp_buf state, int value )
  41. {
  42. if( state->__mask_was_saved )
  43. sigprocmask(SIG_SETMASK, &state->__saved_mask, NULL);
  44. if(!value)
  45. state->__jmpbuf->ReturnValue = 1;
  46. else
  47. state->__jmpbuf->ReturnValue = value;
  48. jmpbuf_ptr = (unsigned long)state;
  49. e1newSP(state->__jmpbuf->SavedSP);
  50. #define _state_ ((struct __jmp_buf_tag*)jmpbuf_ptr)
  51. __asm__ __volatile__("mov L0, %0\n\t"
  52. "mov L1, %1\n\t"
  53. "mov L2, %2\n\t"
  54. "mov G3, %3\n\t"
  55. "mov G4, %4\n\t"
  56. "ret PC, L1\n\t"
  57. :/*no output*/
  58. :"l"(_state_->__jmpbuf->ReturnValue),
  59. "l"(_state_->__jmpbuf->SavedPC),
  60. "l"(_state_->__jmpbuf->SavedSR),
  61. "l"(_state_->__jmpbuf->G3),
  62. "l"(_state_->__jmpbuf->G4)
  63. :"%G3", "%G4", "%L0", "%L1" );
  64. #undef _state_
  65. }