setjmp.S 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /* Copyright (C) 1992-2026 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library. If not, see
  13. <https://www.gnu.org/licenses/>. */
  14. #define __ASSEMBLY__
  15. #include <sysdep.h>
  16. #include <pointer_guard.h>
  17. #include <jmpbuf-offsets.h>
  18. .ent __sigsetjmp
  19. .global __sigsetjmp
  20. __sigsetjmp:
  21. ldgp gp, 0(pv)
  22. $sigsetjmp_local:
  23. #ifndef PIC
  24. #define FRAME 16
  25. subq sp, FRAME, sp
  26. .frame sp, FRAME, ra, 0
  27. stq ra, 0(sp)
  28. .mask 0x04000000, -FRAME
  29. #else
  30. #define FRAME 0
  31. .frame sp, FRAME, ra, 0
  32. #endif
  33. #ifdef PROF
  34. .set noat
  35. lda AT, _mcount
  36. jsr AT, (AT), _mcount
  37. .set at
  38. #endif
  39. .prologue 1
  40. stq s0, JB_S0*8(a0)
  41. stq s1, JB_S1*8(a0)
  42. stq s2, JB_S2*8(a0)
  43. stq s3, JB_S3*8(a0)
  44. stq s4, JB_S4*8(a0)
  45. stq s5, JB_S5*8(a0)
  46. #ifdef PTR_MANGLE
  47. PTR_MANGLE(t1, ra, t0)
  48. stq t1, JB_PC*8(a0)
  49. #else
  50. stq ra, JB_PC*8(a0)
  51. #endif
  52. #if defined(PTR_MANGLE) && FRAME == 0
  53. PTR_MANGLE2(t1, sp, t0)
  54. #else
  55. addq sp, FRAME, t1
  56. # ifdef PTR_MANGLE
  57. PTR_MANGLE2(t1, t1, t0)
  58. # endif
  59. #endif
  60. stq t1, JB_SP*8(a0)
  61. #ifdef PTR_MANGLE
  62. PTR_MANGLE2(t1, fp, t0)
  63. stq t1, JB_FP*8(a0)
  64. #else
  65. stq fp, JB_FP*8(a0)
  66. #endif
  67. stt $f2, JB_F2*8(a0)
  68. stt $f3, JB_F3*8(a0)
  69. stt $f4, JB_F4*8(a0)
  70. stt $f5, JB_F5*8(a0)
  71. stt $f6, JB_F6*8(a0)
  72. stt $f7, JB_F7*8(a0)
  73. stt $f8, JB_F8*8(a0)
  74. stt $f9, JB_F9*8(a0)
  75. #ifndef PIC
  76. /* Call to C to (potentially) save our signal mask. */
  77. jsr ra, __sigjmp_save
  78. ldq ra, 0(sp)
  79. addq sp, 16, sp
  80. ret
  81. #elif IS_IN (rtld)
  82. /* In ld.so we never save the signal mask. */
  83. mov 0, v0
  84. ret
  85. #else
  86. /* Tailcall to save the signal mask. */
  87. br $31, __sigjmp_save !samegp
  88. #endif
  89. END(__sigsetjmp)
  90. hidden_def (__sigsetjmp)
  91. /* Put these traditional entry points in the same file so that we can
  92. elide much of the nonsense in trying to jmp to the real function. */
  93. ENTRY(_setjmp)
  94. ldgp gp, 0(pv)
  95. .prologue 1
  96. mov 0, a1
  97. br $sigsetjmp_local
  98. END(_setjmp)
  99. libc_hidden_def (_setjmp)
  100. ENTRY(setjmp)
  101. ldgp gp, 0(pv)
  102. .prologue 1
  103. mov 1, a1
  104. br $sigsetjmp_local
  105. END(setjmp)
  106. weak_extern(_setjmp)
  107. weak_extern(setjmp)