You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

longjmp.c 865B

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. * Copyright 2003 Yannis Mitsos and George Thanos
  3. * {gmitsos@gthanos}@telecom.ntua.gr
  4. * Released under GPL2, see the file COPYING in the top directory
  5. *
  6. */
  7. #include "setjmp.h"
  8. unsigned long jmpbuf_ptr;
  9. void longjmp(jmp_buf state, int value )
  10. {
  11. if(!value)
  12. state->__jmpbuf->ReturnValue = 1;
  13. else
  14. state->__jmpbuf->ReturnValue = value;
  15. jmpbuf_ptr = (unsigned long)state;
  16. #define _state_ ((struct __jmp_buf_tag*)jmpbuf_ptr)
  17. asm volatile("mov L0, %0\n\t"
  18. "mov L1, %1\n\t"
  19. "mov L2, %2\n\t"
  20. "mov G3, %3\n\t"
  21. "mov G4, %4\n\t"
  22. "ret PC, L1\n\t"
  23. :/*no output*/
  24. :"l"(_state_->__jmpbuf->ReturnValue),
  25. "l"(_state_->__jmpbuf->SavedPC),
  26. "l"(_state_->__jmpbuf->SavedSR),
  27. "l"(_state_->__jmpbuf->G3),
  28. "l"(_state_->__jmpbuf->G4)
  29. :"%G3", "%G4", "%L0", "%L1" );
  30. #undef _state_
  31. }