__longjmp.S 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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, write to the Free
  14. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  15. 02111-1307 USA. */
  16. #include <features.h>
  17. #include <bits/arm_asm.h>
  18. #define _SETJMP_H
  19. #define _ASM
  20. #include <bits/setjmp.h>
  21. .global __longjmp
  22. .type __longjmp,%function
  23. .align 2
  24. #if defined(THUMB1_ONLY)
  25. .thumb_func
  26. __longjmp:
  27. mov r2, r0
  28. movs r0, r1
  29. /* can't let setjmp() return zero! */
  30. bne 1f
  31. mov r0, #1
  32. 1:
  33. mov r1, r2
  34. /* Restore registers, shuffling them through low regs. */
  35. add r2, #(4 * 4)
  36. ldmia r2!, {r4, r5, r6, r7}
  37. mov r8, r4
  38. mov r9, r5
  39. mov sl, r6
  40. mov fp, r7
  41. ldmia r2!, {r4, r5}
  42. mov sp, r4
  43. mov lr, r5
  44. ldmia r1!, {r4, r5, r6, r7}
  45. bx lr
  46. #else
  47. __longjmp:
  48. mov ip, r0 /* save jmp_buf pointer */
  49. movs r0, r1 /* get the return value in place */
  50. IT(t, eq)
  51. moveq r0, #1 /* can't let setjmp() return zero! */
  52. #if defined(__thumb2__)
  53. /* Thumb-2 does not allow loading sp with ldm. */
  54. ldmia ip!, {v1-v6, sl, fp}
  55. ldr sp, [ip], #4
  56. ldr lr, [ip], #4
  57. #else
  58. ldmia ip!, {v1-v6, sl, fp, sp, lr}
  59. #endif
  60. #if defined __UCLIBC_HAS_FLOATS__ && ! defined __UCLIBC_HAS_SOFT_FLOAT__
  61. #ifdef __VFP_FP__
  62. /* Restore the VFP registers. */
  63. /* Following instruction is fldmiax ip!, {d8-d15}. */
  64. ldc p11, cr8, [r12], #68
  65. /* Restore the floating-point status register. */
  66. ldr r1, [ip], #4
  67. /* Following instruction is fmxr fpscr, r1. */
  68. mcr p10, 7, r1, cr1, cr0, 0
  69. # elif defined __MAVERICK__
  70. cfldrd mvd4, [ip], #8 ; nop
  71. cfldrd mvd5, [ip], #8 ; nop
  72. cfldrd mvd6, [ip], #8 ; nop
  73. cfldrd mvd7, [ip], #8 ; nop
  74. cfldrd mvd8, [ip], #8 ; nop
  75. cfldrd mvd9, [ip], #8 ; nop
  76. cfldrd mvd10, [ip], #8 ; nop
  77. cfldrd mvd11, [ip], #8 ; nop
  78. cfldrd mvd12, [ip], #8 ; nop
  79. cfldrd mvd13, [ip], #8 ; nop
  80. cfldrd mvd14, [ip], #8 ; nop
  81. cfldrd mvd15, [ip], #8
  82. # else
  83. lfmfd f4, 4, [ip] ! /* load the floating point regs */
  84. # endif
  85. #endif
  86. #ifdef __IWMMXT__
  87. /* Restore the call-preserved iWMMXt registers. */
  88. /* Following instructions are wldrd wr10, [ip], #8 (etc.) */
  89. ldcl p1, cr10, [r12], #8
  90. ldcl p1, cr11, [r12], #8
  91. ldcl p1, cr12, [r12], #8
  92. ldcl p1, cr13, [r12], #8
  93. ldcl p1, cr14, [r12], #8
  94. ldcl p1, cr15, [r12], #8
  95. #endif
  96. #if defined(__USE_BX__)
  97. bx lr
  98. #else
  99. mov pc, lr
  100. #endif
  101. #endif
  102. .size __longjmp,.-__longjmp
  103. libc_hidden_def(__longjmp)