__longjmp.S 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /* Copyright (C) 1997, 1998 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 Library General Public License as
  5. published by the Free Software Foundation; either version 2 of the
  6. 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. Library General Public License for more details.
  11. You should have received a copy of the GNU Library General Public
  12. License along with the GNU C Library; see the file COPYING.LIB. If not,
  13. see <http://www.gnu.org/licenses/>. */
  14. #include <jmpbuf-offsets.h>
  15. ;----------------------------------------
  16. ; Name: __longjmp
  17. ; Description: Restore the current context
  18. ; as saved by a previous nr_setjmp
  19. ; Input: %o0: jmp_buf (ptr to) array to restore context from
  20. ; %o1: integer to return
  21. ; Output: %o0 = 0 the first time we're called, or
  22. ; whatever longjmp returns later
  23. ; Side Effects: uses %g0, %g1 & %g2
  24. ; CWP Depth: 0
  25. ;
  26. .align 2
  27. .global __longjmp
  28. __longjmp:
  29. ;
  30. ; The way we'll do this is by executing
  31. ; RESTORE instructions until the old
  32. ; return address matches. Then we'll
  33. ; jump to where setjmp was called from.
  34. ;
  35. ; Since we're moving the window pointer
  36. ; all over the place, we'll naturally
  37. ; only use the %g registers.
  38. ;
  39. mov %g0,%o0 ; %g0 -> jmp_buf
  40. mov %g1,%o1 ; %g1 = return value
  41. pfx jmpbuf_callersret
  42. ld %g2,[%g0] ; %g2 = old return address
  43. __longjmp_loop:
  44. cmp %g2,%i7 ; Are we there yet?
  45. skps cc_ne
  46. br __longjmp_done
  47. nop ; (delay slot)
  48. br __longjmp_loop
  49. restore ; (delay slot)
  50. ;
  51. ; One might put in a watchdog counter here, to
  52. ; prevent a runaway stack crawl... but what would that
  53. ; accomplish? What error can we throw? To whom?
  54. ;
  55. __longjmp_done:
  56. pfx jmpbuf_l0 ; Restore local register l0
  57. ld %l0,[%g0]
  58. pfx jmpbuf_l1 ; Restore local register l1
  59. ld %l1,[%g0]
  60. pfx jmpbuf_l2 ; Restore local register l2
  61. ld %l2,[%g0]
  62. pfx jmpbuf_l3 ; Restore local register l3
  63. ld %l3,[%g0]
  64. pfx jmpbuf_l4 ; Restore local register l4
  65. ld %l4,[%g0]
  66. pfx jmpbuf_l5 ; Restore local register l5
  67. ld %l5,[%g0]
  68. pfx jmpbuf_l6 ; Restore local register l6
  69. ld %l6,[%g0]
  70. pfx jmpbuf_l7 ; Restore local register l7
  71. ld %l7,[%g0]
  72. pfx jmpbuf_i0 ; Restore input register i0
  73. ld %i0,[%g0]
  74. pfx jmpbuf_i1 ; Restore input register i1
  75. ld %i1,[%g0]
  76. pfx jmpbuf_i2 ; Restore input register i2
  77. ld %i2,[%g0]
  78. pfx jmpbuf_i3 ; Restore input register i3
  79. ld %i3,[%g0]
  80. pfx jmpbuf_i4 ; Restore input register i4
  81. ld %i4,[%g0]
  82. pfx jmpbuf_i5 ; Restore input register i5
  83. ld %i5,[%g0]
  84. pfx jmpbuf_jmpret
  85. ld %o7,[%g0] ; set fake return address
  86. jmp %o7 ; and kinda return there.
  87. mov %o0,%g1 ; (delay slot) return value
  88. libc_hidden_def(__longjmp)