setjmp.S 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /* setjmp for LoongArch.
  2. Copyright (C) 2022-2026 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. <https://www.gnu.org/licenses/>. */
  15. #include <sysdep.h>
  16. #include <pointer_guard.h>
  17. #include <sys/asm.h>
  18. ENTRY (_setjmp)
  19. li.w a1,0
  20. b HIDDEN_JUMPTARGET (__sigsetjmp)
  21. END (_setjmp)
  22. ENTRY (setjmp)
  23. li.w a1,1
  24. END (setjmp)
  25. ENTRY (__sigsetjmp)
  26. #ifdef PTR_MANGLE
  27. PTR_MANGLE (t0, ra, t1)
  28. REG_S t0, a0, 0*SZREG
  29. PTR_MANGLE2 (t0, sp, t1)
  30. REG_S t0, a0, 1*SZREG
  31. #else
  32. REG_S ra, a0, 0*SZREG
  33. REG_S sp, a0, 1*SZREG
  34. #endif
  35. REG_S x, a0, 2*SZREG
  36. REG_S fp, a0, 3*SZREG
  37. REG_S s0, a0, 4*SZREG
  38. REG_S s1, a0, 5*SZREG
  39. REG_S s2, a0, 6*SZREG
  40. REG_S s3, a0, 7*SZREG
  41. REG_S s4, a0, 8*SZREG
  42. REG_S s5, a0, 9*SZREG
  43. REG_S s6, a0, 10*SZREG
  44. REG_S s7, a0, 11*SZREG
  45. REG_S s8, a0, 12*SZREG
  46. #ifndef __loongarch_soft_float
  47. FREG_S fs0, a0, 13*SZREG + 0*SZFREG
  48. FREG_S fs1, a0, 13*SZREG + 1*SZFREG
  49. FREG_S fs2, a0, 13*SZREG + 2*SZFREG
  50. FREG_S fs3, a0, 13*SZREG + 3*SZFREG
  51. FREG_S fs4, a0, 13*SZREG + 4*SZFREG
  52. FREG_S fs5, a0, 13*SZREG + 5*SZFREG
  53. FREG_S fs6, a0, 13*SZREG + 6*SZFREG
  54. FREG_S fs7, a0, 13*SZREG + 7*SZFREG
  55. #endif
  56. #if !IS_IN (libc) && IS_IN(rtld)
  57. li.w v0, 0
  58. jirl zero, ra, 0
  59. #else
  60. b __sigjmp_save
  61. #endif
  62. END (__sigsetjmp)
  63. hidden_def (__sigsetjmp)
  64. weak_alias (_setjmp, __GI__setjmp)