__longjmp.S 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /* longjmp for ARM.
  2. Copyright (C) 1997, 1998 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <http://www.gnu.org/licenses/>. */
  15. #include <features.h>
  16. #include <bits/arm_asm.h>
  17. #include <bits/arm_bx.h>
  18. .global __longjmp
  19. .type __longjmp,%function
  20. .align 2
  21. #if defined(THUMB1_ONLY)
  22. .thumb_func
  23. __longjmp:
  24. mov r2, r0
  25. movs r0, r1
  26. /* can't let setjmp() return zero! */
  27. bne 1f
  28. mov r0, #1
  29. 1:
  30. mov r1, r2
  31. /* Restore registers, shuffling them through low regs. */
  32. add r2, #(4 * 4)
  33. ldmia r2!, {r4, r5, r6, r7}
  34. mov r8, r4
  35. mov r9, r5
  36. mov sl, r6
  37. mov fp, r7
  38. ldmia r2!, {r4, r5}
  39. mov sp, r4
  40. mov lr, r5
  41. ldmia r1!, {r4, r5, r6, r7}
  42. bx lr
  43. #else
  44. __longjmp:
  45. mov ip, r0 /* save jmp_buf pointer */
  46. movs r0, r1 /* get the return value in place */
  47. IT(t, eq)
  48. moveq r0, #1 /* can't let setjmp() return zero! */
  49. #if defined(__thumb2__)
  50. /* Thumb-2 does not allow loading sp with ldm. */
  51. ldmia ip!, {v1-v6, sl, fp}
  52. ldr sp, [ip], #4
  53. ldr lr, [ip], #4
  54. #else
  55. ldmia ip!, {v1-v6, sl, fp, sp, lr}
  56. #endif
  57. #if defined __UCLIBC_HAS_FLOATS__ && ! defined __UCLIBC_HAS_SOFT_FLOAT__
  58. #ifdef __VFP_FP__
  59. /* Restore the VFP registers. */
  60. /* Following instruction is fldmiax ip!, {d8-d15}. */
  61. ldc p11, cr8, [r12], #68
  62. /* Restore the floating-point status register. */
  63. ldr r1, [ip], #4
  64. /* Following instruction is fmxr fpscr, r1. */
  65. mcr p10, 7, r1, cr1, cr0, 0
  66. # elif defined __MAVERICK__
  67. cfldrd mvd4, [ip], #8 ; nop
  68. cfldrd mvd5, [ip], #8 ; nop
  69. cfldrd mvd6, [ip], #8 ; nop
  70. cfldrd mvd7, [ip], #8 ; nop
  71. cfldrd mvd8, [ip], #8 ; nop
  72. cfldrd mvd9, [ip], #8 ; nop
  73. cfldrd mvd10, [ip], #8 ; nop
  74. cfldrd mvd11, [ip], #8 ; nop
  75. cfldrd mvd12, [ip], #8 ; nop
  76. cfldrd mvd13, [ip], #8 ; nop
  77. cfldrd mvd14, [ip], #8 ; nop
  78. cfldrd mvd15, [ip], #8
  79. # else
  80. lfmfd f4, 4, [ip] ! /* load the floating point regs */
  81. # endif
  82. #endif
  83. #ifdef __IWMMXT__
  84. /* Restore the call-preserved iWMMXt registers. */
  85. /* Following instructions are wldrd wr10, [ip], #8 (etc.) */
  86. ldcl p1, cr10, [r12], #8
  87. ldcl p1, cr11, [r12], #8
  88. ldcl p1, cr12, [r12], #8
  89. ldcl p1, cr13, [r12], #8
  90. ldcl p1, cr14, [r12], #8
  91. ldcl p1, cr15, [r12], #8
  92. #endif
  93. BX(lr)
  94. #endif
  95. .size __longjmp,.-__longjmp
  96. libc_hidden_def(__longjmp)