setjmp.S 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* setjmp for Nios II.
  2. Copyright (C) 1991-2019 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. <http://www.gnu.org/licenses/>. */
  15. #include <sysdep.h>
  16. #include <jmpbuf-offsets.h>
  17. .text
  18. ENTRY(setjmp)
  19. movi r5, 1
  20. br __sigsetjmp
  21. END(setjmp)
  22. ENTRY(_setjmp)
  23. mov r5, zero
  24. br __sigsetjmp
  25. END(_setjmp)
  26. libc_hidden_def (_setjmp)
  27. /* Save the current program position in ENV and return 0. */
  28. ENTRY(__sigsetjmp)
  29. #ifdef PTR_MANGLE
  30. PTR_MANGLE_GUARD (r9)
  31. #endif
  32. stw r16, (JB_R16*4)(r4)
  33. stw r17, (JB_R17*4)(r4)
  34. stw r18, (JB_R18*4)(r4)
  35. stw r19, (JB_R19*4)(r4)
  36. stw r20, (JB_R20*4)(r4)
  37. stw r21, (JB_R21*4)(r4)
  38. stw r22, (JB_R22*4)(r4)
  39. stw fp, (JB_FP*4)(r4)
  40. #ifdef PTR_MANGLE
  41. PTR_MANGLE (r6, ra, r9)
  42. PTR_MANGLE (r7, sp, r9)
  43. stw r6, (JB_RA*4)(r4)
  44. stw r7, (JB_SP*4)(r4)
  45. #else
  46. stw ra, (JB_RA*4)(r4)
  47. stw sp, (JB_SP*4)(r4)
  48. #endif
  49. #if IS_IN (rtld)
  50. /* In ld.so we never save the signal mask. */
  51. mov r2, zero
  52. ret
  53. #else
  54. /* Save the signal mask if requested. */
  55. #if defined(__PIC__) || defined(PIC)
  56. nextpc r2
  57. 1: movhi r3, %hiadj(__sigjmp_save - 1b)
  58. addi r3, r3, %lo(__sigjmp_save - 1b)
  59. add r2, r2, r3
  60. jmp r2
  61. #else
  62. jmpi __sigjmp_save
  63. #endif
  64. #endif
  65. END (__sigsetjmp)
  66. libc_hidden_def (__sigsetjmp)