setjmp.S 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. /* Copyright (C) 1999, 2000, 2001, 2002, 2004, 2005
  2. Free Software Foundation, Inc.
  3. Contributed by David Mosberger-Tang <davidm@hpl.hp.com>.
  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. The layout of the jmp_buf is as follows. This is subject to change
  16. and user-code should never depend on the particular layout of
  17. jmp_buf!
  18. offset: description:
  19. ------- ------------
  20. 0x000 stack pointer (r12) ; unchangeable (see _JMPBUF_UNWINDS)
  21. 0x008 r1 (gp)
  22. 0x010 caller's unat
  23. 0x018 fpsr
  24. 0x020 r4
  25. 0x028 r5
  26. 0x030 r6
  27. 0x038 r7
  28. 0x040 rp (b0)
  29. 0x048 b1
  30. 0x050 b2
  31. 0x058 b3
  32. 0x060 b4
  33. 0x068 b5
  34. 0x070 ar.pfs
  35. 0x078 ar.lc
  36. 0x080 pr
  37. 0x088 ar.bsp ; unchangeable (see __longjmp.S)
  38. 0x090 ar.unat
  39. 0x098 &__jmp_buf ; address of the jmpbuf (needed to locate NaT bits in unat)
  40. 0x0a0 f2
  41. 0x0b0 f3
  42. 0x0c0 f4
  43. 0x0d0 f5
  44. 0x0e0 f16
  45. 0x0f0 f17
  46. 0x100 f18
  47. 0x110 f19
  48. 0x120 f20
  49. 0x130 f21
  50. 0x130 f22
  51. 0x140 f23
  52. 0x150 f24
  53. 0x160 f25
  54. 0x170 f26
  55. 0x180 f27
  56. 0x190 f28
  57. 0x1a0 f29
  58. 0x1b0 f30
  59. 0x1c0 f31 */
  60. #include "sysdep.h"
  61. #include <features.h>
  62. /* The following two entry points are the traditional entry points: */
  63. LEAF(setjmp)
  64. alloc r8=ar.pfs,2,0,0,0
  65. mov in1=1
  66. br.cond.sptk.many _GI___sigsetjmp
  67. END(setjmp)
  68. LEAF(_setjmp)
  69. alloc r8=ar.pfs,2,0,0,0
  70. mov in1=0
  71. br.cond.sptk.many _GI___sigsetjmp
  72. END(_setjmp)
  73. libc_hidden_def (_setjmp)
  74. /* __sigsetjmp(__jmp_buf buf, int savemask) */
  75. ENTRY(__sigsetjmp)
  76. .prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(2)
  77. alloc loc1=ar.pfs,2,5,2,0
  78. .save ar.unat, loc2
  79. mov loc2=ar.unat
  80. ;;
  81. mov r17=ar.fpsr
  82. mov r2=in0
  83. add r3=8,in0
  84. ;;
  85. .mem.offset 8,0; st8.spill.nta [r2]=sp,16 /* r12 (sp) */
  86. .mem.offset 0,0; st8.spill.nta [r3]=gp,16 /* r1 (gp) */
  87. ;;
  88. st8.nta [r2]=loc2,16 /* save caller's unat */
  89. st8.nta [r3]=r17,16 /* save fpsr */
  90. add r8=0xa0,in0
  91. ;;
  92. .mem.offset 8,0; st8.spill.nta [r2]=r4,16 /* r4 */
  93. .mem.offset 0,0; st8.spill.nta [r3]=r5,16 /* r5 */
  94. add r9=0xb0,in0
  95. ;;
  96. stf.spill.nta [r8]=f2,32
  97. stf.spill.nta [r9]=f3,32
  98. mov loc0=rp
  99. .body
  100. ;;
  101. stf.spill.nta [r8]=f4,32
  102. stf.spill.nta [r9]=f5,32
  103. mov r17=b1
  104. ;;
  105. stf.spill.nta [r8]=f16,32
  106. stf.spill.nta [r9]=f17,32
  107. mov r18=b2
  108. ;;
  109. stf.spill.nta [r8]=f18,32
  110. stf.spill.nta [r9]=f19,32
  111. mov r19=b3
  112. ;;
  113. stf.spill.nta [r8]=f20,32
  114. stf.spill.nta [r9]=f21,32
  115. mov r20=b4
  116. ;;
  117. stf.spill.nta [r8]=f22,32
  118. stf.spill.nta [r9]=f23,32
  119. mov r21=b5
  120. ;;
  121. stf.spill.nta [r8]=f24,32
  122. stf.spill.nta [r9]=f25,32
  123. mov r22=ar.lc
  124. ;;
  125. stf.spill.nta [r8]=f26,32
  126. stf.spill.nta [r9]=f27,32
  127. mov r24=pr
  128. ;;
  129. stf.spill.nta [r8]=f28,32
  130. stf.spill.nta [r9]=f29,32
  131. ;;
  132. stf.spill.nta [r8]=f30
  133. stf.spill.nta [r9]=f31
  134. .mem.offset 8,0; st8.spill.nta [r2]=r6,16 /* r6 */
  135. .mem.offset 0,0; st8.spill.nta [r3]=r7,16 /* r7 */
  136. ;;
  137. mov r23=ar.bsp
  138. mov r25=ar.unat
  139. mov out0=in0
  140. st8.nta [r2]=loc0,16 /* b0 */
  141. st8.nta [r3]=r17,16 /* b1 */
  142. mov out1=in1
  143. ;;
  144. st8.nta [r2]=r18,16 /* b2 */
  145. st8.nta [r3]=r19,16 /* b3 */
  146. ;;
  147. st8.nta [r2]=r20,16 /* b4 */
  148. st8.nta [r3]=r21,16 /* b5 */
  149. ;;
  150. st8.nta [r2]=loc1,16 /* ar.pfs */
  151. st8.nta [r3]=r22,16 /* ar.lc */
  152. ;;
  153. st8.nta [r2]=r24,16 /* pr */
  154. st8.nta [r3]=r23,16 /* ar.bsp */
  155. ;;
  156. st8.nta [r2]=r25 /* ar.unat */
  157. st8.nta [r3]=in0 /* &__jmp_buf */
  158. #if defined NOT_IN_libc && defined IS_IN_rtld
  159. /* In ld.so we never save the signal mask. */
  160. ;;
  161. #else
  162. br.call.dpnt.few rp=__sigjmp_save
  163. #endif
  164. .ret0: /* force a new bundle ::q */
  165. mov.m ar.unat=loc2 /* restore caller's unat */
  166. mov rp=loc0
  167. mov ar.pfs=loc1
  168. mov r8=0
  169. ret
  170. END(__sigsetjmp)
  171. strong_alias(__sigsetjmp, _GI___sigsetjmp)
  172. weak_extern(_setjmp)
  173. weak_extern(setjmp)