setjmp.S 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.
  3. * This program and the accompanying materials are licensed and made
  4. available
  5. * under the terms and conditions of the BSD License which accompanies
  6. this
  7. * distribution. The full text of the license may be found at
  8. * http://opensource.org/licenses/bsd-license.php.
  9. *
  10. * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
  11. BASIS,
  12. * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR
  13. * IMPLIED.
  14. */
  15. .text
  16. .p2align 3
  17. #define GPR_LAYOUT \
  18. REG_PAIR (x19, x20, 0); \
  19. REG_PAIR (x21, x22, 16); \
  20. REG_PAIR (x23, x24, 32); \
  21. REG_PAIR (x25, x26, 48); \
  22. REG_PAIR (x27, x28, 64); \
  23. REG_PAIR (x29, x30, 80); \
  24. REG_ONE (x16, 96)
  25. #define FPR_LAYOUT \
  26. REG_PAIR(d8, d9, 112); \
  27. REG_PAIR(d10, d11, 128); \
  28. REG_PAIR(d12, d13, 144); \
  29. REG_PAIR(d14, d15, 160);
  30. #define REG_PAIR(REG1, REG2, OFFS) stp REG1, REG2, [x0, OFFS]
  31. #define REG_ONE(REG1, OFFS) str REG1, [x0, OFFS]
  32. .globl setjmp
  33. .type setjmp, @function
  34. setjmp:
  35. mov x16, sp
  36. GPR_LAYOUT
  37. FPR_LAYOUT
  38. mov w0, #0
  39. ret
  40. #undef REG_PAIR
  41. #undef REG_ONE
  42. #define REG_PAIR(REG1, REG2, OFFS) ldp REG1, REG2, [x0, OFFS]
  43. #define REG_ONE(REG1, OFFS) ldr REG1, [x0, OFFS]
  44. .globl longjmp
  45. .type longjmp, @function
  46. longjmp:
  47. GPR_LAYOUT
  48. FPR_LAYOUT
  49. mov sp, x16
  50. cmp w1, #0
  51. mov w0, #1
  52. csel w0, w1, w0, ne
  53. br x30
  54. #if defined(__ELF__) && defined(__linux__)
  55. .section .note.GNU-stack,"",%progbits
  56. #endif