setjmp.S 4.2 KB

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